Skip to content
This repository has been archived by the owner on Jul 6, 2022. It is now read-only.

Commit

Permalink
fix: add new props to features type (#458)
Browse files Browse the repository at this point in the history
* fix: add new props to features type

* chore: remove semicolons
  • Loading branch information
Mough authored Oct 17, 2021
1 parent 8b9d264 commit 7a3e911
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 42 deletions.
2 changes: 1 addition & 1 deletion packages/features/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/features",
"version": "1.7.0",
"version": "1.7.1",
"engines": {
"node": ">=14.0.0 <16.0.0"
},
Expand Down
51 changes: 32 additions & 19 deletions packages/features/src/Domain/Feature/Feature.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,48 @@
import { ContentType } from '@standardnotes/common'

import { ComponentArea } from '../Component/ComponentArea'
import { PermissionName } from '../Permission/PermissionName'
import { FeatureIdentifier } from './FeatureIdentifier'
import { ComponentFlag } from './Flag'

export type ThemeDockIcon = {
type: 'svg' | 'circle',
background_color: string,
foreground_color: string,
border_color: string,
source?: string
type: 'svg' | 'circle';
background_color: string;
foreground_color: string;
border_color: string;
source?: string;
};

export enum NoteType {
Authentication = 'authentication',
Code = 'code',
Markdown = 'markdown',
RichText = 'rich-text',
Spreadsheet = 'spreadsheet',
Task = 'task',
}

export type FeatureDescription = {
name: string;
identifier: FeatureIdentifier;
permission_name: PermissionName;
content_type?: ContentType;
area?: ComponentArea;
layerable?: boolean;
no_mobile?: boolean;
version: string;
content_type?: ContentType;
deletion_warning?: string;
description: string;
url: string;
dock_icon?: ThemeDockIcon;
download_url: string;
marketing_url: string;
thumbnail_url?: string;
expires_at?: number;
file_type: 'txt' | 'html' | 'md' | 'json';
flags?: ComponentFlag[];
identifier: FeatureIdentifier;
/** Whether an editor is interchangable with another editor that has the same file_type */
interchangeable: boolean;
/** Some themes can be layered on top of other themes */
layerable?: boolean;
marketing_url: string;
name: string;
no_expire?: boolean;
dock_icon?: ThemeDockIcon;
deletion_warning?: string;
expires_at?: number;
no_mobile?: boolean;
note_type: NoteType;
permission_name: PermissionName;
thumbnail_url?: string;
url: string;
version: string;
};
27 changes: 8 additions & 19 deletions packages/snjs/lib/models/app/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import { PurePayload } from '@Payloads/pure_payload';
import { ItemMutator, SNItem } from '@Models/core/item';
import { ContentType } from '@Models/content_types';
import { HistoryEntry } from '@Lib/services/history/entries/history_entry';
import { ComponentArea, ThemeDockIcon, ComponentFlag } from '@standardnotes/features';
import {
ComponentArea,
ComponentFlag,
FeatureDescription,
} from '@standardnotes/features';

export { ComponentArea };

Expand Down Expand Up @@ -36,29 +40,14 @@ export enum ComponentAction {
ThemesActivated = 'themes-activated',
KeyDown = 'key-down',
KeyUp = 'key-up',
Click = 'click'
Click = 'click',
}

export type ComponentPermission = {
name: ComponentAction;
content_types?: ContentType[];
};

export type ComponentPackageInfo = {
description: string,
acceptsThemes?: boolean,
layerable?: boolean,
url: string,
download_url: string,
identifier: string,
flags?: string[],
deprecation_message?: string,
name: string,
version: string,
deletion_warning?: string,
dock_icon?: ThemeDockIcon
}

export interface ComponentContent {
componentData: Record<string, any>;
/** Items that have requested a component to be disabled in its context */
Expand All @@ -70,7 +59,7 @@ export interface ComponentContent {
offlineOnly: boolean;
name: string;
autoupdateDisabled: boolean;
package_info: ComponentPackageInfo;
package_info: FeatureDescription;
area: ComponentArea;
permissions: ComponentPermission[];
valid_until: Date | number;
Expand All @@ -96,7 +85,7 @@ export class SNComponent extends SNItem implements ComponentContent {
public readonly offlineOnly: boolean;
public readonly name: string;
public readonly autoupdateDisabled: boolean;
public readonly package_info: ComponentPackageInfo;
public readonly package_info: FeatureDescription;
public readonly area: ComponentArea;
public readonly permissions: ComponentPermission[] = [];
public readonly valid_until: Date;
Expand Down
5 changes: 2 additions & 3 deletions packages/snjs/lib/services/features_service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { SNSyncService } from './sync/sync_service';
import { AccountEvent, SNCredentialService } from './credential_service';
import { ComponentPackageInfo } from './../models/app/component';
import { UserRolesChangedEvent } from '@standardnotes/domain-events';
import { StorageKey } from '@Lib/storage_keys';
import { PureService } from './pure_service';
Expand Down Expand Up @@ -219,7 +218,7 @@ export class SNFeaturesService extends PureService<void> {
area: feature.area,
hosted_url: feature.url,
name: feature.name,
package_info: feature as ComponentPackageInfo,
package_info: feature,
valid_until: new Date(feature.expires_at || 0),
};
return FillItemContent(componentContent);
Expand Down Expand Up @@ -258,7 +257,7 @@ export class SNFeaturesService extends PureService<void> {
existingItem.uuid,
(mutator) => {
mutator.hosted_url = feature.url;
mutator.package_info = feature as ComponentPackageInfo;
mutator.package_info = feature;
mutator.valid_until = new Date(feature.expires_at || 0);
}
);
Expand Down

0 comments on commit 7a3e911

Please sign in to comment.