From 7a3e9114414646a564a4de0879d68a801686e34f Mon Sep 17 00:00:00 2001 From: Mough Date: Sun, 17 Oct 2021 11:42:35 -0500 Subject: [PATCH] fix: add new props to features type (#458) * fix: add new props to features type * chore: remove semicolons --- packages/features/package.json | 2 +- .../features/src/Domain/Feature/Feature.ts | 51 ++++++++++++------- packages/snjs/lib/models/app/component.ts | 27 +++------- .../snjs/lib/services/features_service.ts | 5 +- 4 files changed, 43 insertions(+), 42 deletions(-) diff --git a/packages/features/package.json b/packages/features/package.json index 05652cba5..389f483ac 100644 --- a/packages/features/package.json +++ b/packages/features/package.json @@ -1,6 +1,6 @@ { "name": "@standardnotes/features", - "version": "1.7.0", + "version": "1.7.1", "engines": { "node": ">=14.0.0 <16.0.0" }, diff --git a/packages/features/src/Domain/Feature/Feature.ts b/packages/features/src/Domain/Feature/Feature.ts index ec1f61608..ff14b9a4c 100644 --- a/packages/features/src/Domain/Feature/Feature.ts +++ b/packages/features/src/Domain/Feature/Feature.ts @@ -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; }; diff --git a/packages/snjs/lib/models/app/component.ts b/packages/snjs/lib/models/app/component.ts index 194550e8e..35ab6eb40 100644 --- a/packages/snjs/lib/models/app/component.ts +++ b/packages/snjs/lib/models/app/component.ts @@ -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 }; @@ -36,7 +40,7 @@ export enum ComponentAction { ThemesActivated = 'themes-activated', KeyDown = 'key-down', KeyUp = 'key-up', - Click = 'click' + Click = 'click', } export type ComponentPermission = { @@ -44,21 +48,6 @@ export type ComponentPermission = { 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; /** Items that have requested a component to be disabled in its context */ @@ -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; @@ -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; diff --git a/packages/snjs/lib/services/features_service.ts b/packages/snjs/lib/services/features_service.ts index c799efd03..597db7067 100644 --- a/packages/snjs/lib/services/features_service.ts +++ b/packages/snjs/lib/services/features_service.ts @@ -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'; @@ -219,7 +218,7 @@ export class SNFeaturesService extends PureService { 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); @@ -258,7 +257,7 @@ export class SNFeaturesService extends PureService { 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); } );