chore: fix ContentType usage (#2353)
* chore: fix ContentType usage * chore: fix specs
This commit is contained in:
@@ -690,7 +690,7 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli
|
||||
* items matching the constraint are added, changed, or deleted.
|
||||
*/
|
||||
public streamItems<I extends DecryptedItemInterface = DecryptedItemInterface>(
|
||||
contentType: Common.ContentType | Common.ContentType[],
|
||||
contentType: string | string[],
|
||||
stream: ItemStream<I>,
|
||||
): () => void {
|
||||
const removeItemManagerObserver = this.itemManager.addObserver<I>(
|
||||
|
||||
@@ -9,7 +9,6 @@ import {
|
||||
NoteContent,
|
||||
PayloadTimestampDefaults,
|
||||
} from '@standardnotes/models'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { EncryptionProviderInterface } from '@standardnotes/encryption'
|
||||
|
||||
import { GetRevisionDTO } from './GetRevisionDTO'
|
||||
@@ -51,7 +50,7 @@ export class GetRevision implements UseCaseInterface<HistoryEntry> {
|
||||
enc_item_key: revision.enc_item_key as string,
|
||||
items_key_id: revision.items_key_id as string,
|
||||
auth_hash: revision.auth_hash as string,
|
||||
content_type: revision.content_type as ContentType,
|
||||
content_type: revision.content_type,
|
||||
updated_at: new Date(revision.updated_at),
|
||||
created_at: new Date(revision.created_at),
|
||||
key_system_identifier: revision.key_system_identifier ?? undefined,
|
||||
|
||||
@@ -2,11 +2,11 @@ import { MutatorClientInterface } from '@standardnotes/services'
|
||||
import { SNTag, TagMutator, TagFolderDelimitter } from '@standardnotes/models'
|
||||
import { ItemManager } from '@Lib/Services'
|
||||
import { lastElement, sortByKey, withoutLastElement } from '@standardnotes/utils'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
export class TagsToFoldersMigrationApplicator {
|
||||
public static isApplicableToCurrentData(itemManager: ItemManager): boolean {
|
||||
const tags = itemManager.getItems<SNTag>(ContentType.Tag)
|
||||
const tags = itemManager.getItems<SNTag>(ContentType.TYPES.Tag)
|
||||
for (const tag of tags) {
|
||||
if (tag.title.includes(TagFolderDelimitter) && !tag.parentId) {
|
||||
return true
|
||||
@@ -17,7 +17,7 @@ export class TagsToFoldersMigrationApplicator {
|
||||
}
|
||||
|
||||
public static async run(itemManager: ItemManager, mutator: MutatorClientInterface): Promise<void> {
|
||||
const tags = itemManager.getItems(ContentType.Tag) as SNTag[]
|
||||
const tags = itemManager.getItems(ContentType.TYPES.Tag) as SNTag[]
|
||||
const sortedTags = sortByKey(tags, 'title')
|
||||
|
||||
for (const tag of sortedTags) {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { Migration } from '@Lib/Migrations/Migration'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ApplicationStage } from '@standardnotes/services'
|
||||
|
||||
export class Migration2_20_0 extends Migration {
|
||||
@@ -15,7 +14,7 @@ export class Migration2_20_0 extends Migration {
|
||||
}
|
||||
|
||||
private async deleteMfaItems(): Promise<void> {
|
||||
const contentType = 'SF|MFA' as ContentType
|
||||
const contentType = 'SF|MFA'
|
||||
const items = this.services.itemManager.getItems(contentType)
|
||||
|
||||
for (const item of items) {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { Migration } from '@Lib/Migrations/Migration'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ApplicationStage } from '@standardnotes/services'
|
||||
|
||||
export class Migration2_36_0 extends Migration {
|
||||
@@ -15,7 +14,7 @@ export class Migration2_36_0 extends Migration {
|
||||
}
|
||||
|
||||
private async removeServerExtensionsLocally(): Promise<void> {
|
||||
const contentType = 'SF|Extension' as ContentType
|
||||
const contentType = 'SF|Extension'
|
||||
const items = this.services.itemManager.getItems(contentType)
|
||||
|
||||
for (const item of items) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ApplicationStage } from '@standardnotes/services'
|
||||
import { FeatureIdentifier } from '@standardnotes/features'
|
||||
import { Migration } from '@Lib/Migrations/Migration'
|
||||
import { SNTheme } from '@standardnotes/models'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
const NoDistractionIdentifier = 'org.standardnotes.theme-no-distraction' as FeatureIdentifier
|
||||
|
||||
@@ -19,7 +19,7 @@ export class Migration2_42_0 extends Migration {
|
||||
}
|
||||
|
||||
private async deleteNoDistraction(): Promise<void> {
|
||||
const themes = (this.services.itemManager.getItems(ContentType.Theme) as SNTheme[]).filter((theme) => {
|
||||
const themes = (this.services.itemManager.getItems(ContentType.TYPES.Theme) as SNTheme[]).filter((theme) => {
|
||||
return theme.identifier === NoDistractionIdentifier
|
||||
})
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { CompoundPredicate, Predicate, SNComponent } from '@standardnotes/models'
|
||||
import { Migration } from '@Lib/Migrations/Migration'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ApplicationStage } from '@standardnotes/services'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
export class Migration2_7_0 extends Migration {
|
||||
static override version(): string {
|
||||
@@ -19,11 +19,11 @@ export class Migration2_7_0 extends Migration {
|
||||
const batchMgrId = 'org.standardnotes.batch-manager'
|
||||
|
||||
const batchMgrPred = new CompoundPredicate('and', [
|
||||
new Predicate<SNComponent>('content_type', '=', ContentType.Component),
|
||||
new Predicate<SNComponent>('content_type', '=', ContentType.TYPES.Component),
|
||||
new Predicate<SNComponent>('identifier', '=', batchMgrId),
|
||||
])
|
||||
|
||||
const batchMgrSingleton = this.services.singletonManager.findSingleton(ContentType.Component, batchMgrPred)
|
||||
const batchMgrSingleton = this.services.singletonManager.findSingleton(ContentType.TYPES.Component, batchMgrPred)
|
||||
|
||||
if (batchMgrSingleton) {
|
||||
await this.services.mutator.setItemToBeDeleted(batchMgrSingleton)
|
||||
|
||||
@@ -3,7 +3,6 @@ import { SNRootKey } from '@standardnotes/encryption'
|
||||
import { ChallengeService } from '../Challenge'
|
||||
import { ListedService } from '../Listed/ListedService'
|
||||
import { ActionResponse, DeprecatedHttpResponse } from '@standardnotes/responses'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ItemManager } from '@Lib/Services/Items/ItemManager'
|
||||
import {
|
||||
SNActionsExtension,
|
||||
@@ -36,6 +35,7 @@ import {
|
||||
EncryptionService,
|
||||
Challenge,
|
||||
} from '@standardnotes/services'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
type PayloadRequestHandler = (uuid: string) => TransferPayload | undefined
|
||||
|
||||
@@ -97,7 +97,7 @@ export class SNActionsService extends AbstractService {
|
||||
}
|
||||
|
||||
public getExtensions(): SNActionsExtension[] {
|
||||
const extensionItems = this.itemManager.getItems<SNActionsExtension>(ContentType.ActionsExtension)
|
||||
const extensionItems = this.itemManager.getItems<SNActionsExtension>(ContentType.TYPES.ActionsExtension)
|
||||
const excludingListed = extensionItems.filter((extension) => !extension.isListedExtension)
|
||||
return excludingListed
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import {
|
||||
FeatureIdentifier,
|
||||
NoteType,
|
||||
} from '@standardnotes/features'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { GenericItem, SNComponent, Environment, Platform } from '@standardnotes/models'
|
||||
import {
|
||||
DesktopManagerInterface,
|
||||
@@ -25,6 +24,7 @@ import { ItemManager } from '@Lib/Services/Items/ItemManager'
|
||||
import { SNFeaturesService } from '@Lib/Services/Features/FeaturesService'
|
||||
import { SNComponentManager } from './ComponentManager'
|
||||
import { SNSyncService } from '../Sync/SyncService'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
describe('featuresService', () => {
|
||||
let itemManager: ItemManager
|
||||
@@ -100,7 +100,7 @@ describe('featuresService', () => {
|
||||
const nativeComponent = (identifier?: FeatureIdentifier, file_type?: FeatureDescription['file_type']) => {
|
||||
return new SNComponent({
|
||||
uuid: '789',
|
||||
content_type: ContentType.Component,
|
||||
content_type: ContentType.TYPES.Component,
|
||||
content: {
|
||||
package_info: {
|
||||
hosted_url: 'https://example.com/component',
|
||||
@@ -115,7 +115,7 @@ describe('featuresService', () => {
|
||||
const deprecatedComponent = () => {
|
||||
return new SNComponent({
|
||||
uuid: '789',
|
||||
content_type: ContentType.Component,
|
||||
content_type: ContentType.TYPES.Component,
|
||||
content: {
|
||||
package_info: {
|
||||
hosted_url: 'https://example.com/component',
|
||||
@@ -129,7 +129,7 @@ describe('featuresService', () => {
|
||||
const thirdPartyComponent = () => {
|
||||
return new SNComponent({
|
||||
uuid: '789',
|
||||
content_type: ContentType.Component,
|
||||
content_type: ContentType.TYPES.Component,
|
||||
content: {
|
||||
local_url: 'sn://Extensions/non-native-identifier/dist/index.html',
|
||||
hosted_url: 'https://example.com/component',
|
||||
@@ -146,7 +146,7 @@ describe('featuresService', () => {
|
||||
const permissions: ComponentPermission[] = [
|
||||
{
|
||||
name: ComponentAction.StreamContextItem,
|
||||
content_types: [ContentType.Note],
|
||||
content_types: [ContentType.TYPES.Note],
|
||||
},
|
||||
]
|
||||
|
||||
@@ -160,7 +160,7 @@ describe('featuresService', () => {
|
||||
const permissions: ComponentPermission[] = [
|
||||
{
|
||||
name: ComponentAction.StreamItems,
|
||||
content_types: [ContentType.Note],
|
||||
content_types: [ContentType.TYPES.Note],
|
||||
},
|
||||
]
|
||||
|
||||
@@ -172,7 +172,7 @@ describe('featuresService', () => {
|
||||
const permissions: ComponentPermission[] = [
|
||||
{
|
||||
name: ComponentAction.StreamItems,
|
||||
content_types: [ContentType.Tag],
|
||||
content_types: [ContentType.TYPES.Tag],
|
||||
},
|
||||
]
|
||||
|
||||
@@ -184,7 +184,7 @@ describe('featuresService', () => {
|
||||
const permissions: ComponentPermission[] = [
|
||||
{
|
||||
name: ComponentAction.StreamItems,
|
||||
content_types: [ContentType.Tag, ContentType.Note],
|
||||
content_types: [ContentType.TYPES.Tag, ContentType.TYPES.Note],
|
||||
},
|
||||
]
|
||||
|
||||
@@ -196,7 +196,7 @@ describe('featuresService', () => {
|
||||
const permissions: ComponentPermission[] = [
|
||||
{
|
||||
name: ComponentAction.StreamItems,
|
||||
content_types: [ContentType.Tag, ContentType.FilesafeFileMetadata],
|
||||
content_types: [ContentType.TYPES.Tag, ContentType.TYPES.FilesafeFileMetadata],
|
||||
},
|
||||
]
|
||||
|
||||
@@ -211,9 +211,9 @@ describe('featuresService', () => {
|
||||
{
|
||||
name: ComponentAction.StreamItems,
|
||||
content_types: [
|
||||
ContentType.FilesafeFileMetadata,
|
||||
ContentType.FilesafeCredentials,
|
||||
ContentType.FilesafeIntegration,
|
||||
ContentType.TYPES.FilesafeFileMetadata,
|
||||
ContentType.TYPES.FilesafeCredentials,
|
||||
ContentType.TYPES.FilesafeIntegration,
|
||||
],
|
||||
},
|
||||
]
|
||||
@@ -229,9 +229,9 @@ describe('featuresService', () => {
|
||||
{
|
||||
name: ComponentAction.StreamItems,
|
||||
content_types: [
|
||||
ContentType.FilesafeFileMetadata,
|
||||
ContentType.FilesafeCredentials,
|
||||
ContentType.FilesafeIntegration,
|
||||
ContentType.TYPES.FilesafeFileMetadata,
|
||||
ContentType.TYPES.FilesafeCredentials,
|
||||
ContentType.TYPES.FilesafeIntegration,
|
||||
],
|
||||
},
|
||||
]
|
||||
@@ -247,9 +247,9 @@ describe('featuresService', () => {
|
||||
{
|
||||
name: ComponentAction.StreamItems,
|
||||
content_types: [
|
||||
ContentType.FilesafeFileMetadata,
|
||||
ContentType.FilesafeCredentials,
|
||||
ContentType.FilesafeIntegration,
|
||||
ContentType.TYPES.FilesafeFileMetadata,
|
||||
ContentType.TYPES.FilesafeCredentials,
|
||||
ContentType.TYPES.FilesafeIntegration,
|
||||
],
|
||||
},
|
||||
]
|
||||
@@ -290,7 +290,7 @@ describe('featuresService', () => {
|
||||
const manager = createManager(Environment.Desktop, Platform.MacDesktop)
|
||||
const component = new SNComponent({
|
||||
uuid: '789',
|
||||
content_type: ContentType.Component,
|
||||
content_type: ContentType.TYPES.Component,
|
||||
content: {
|
||||
hosted_url: 'https://example.com/component',
|
||||
package_info: {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { AllowedBatchStreaming } from './Types'
|
||||
import { SNPreferencesService } from '../Preferences/PreferencesService'
|
||||
import { SNFeaturesService } from '@Lib/Services/Features/FeaturesService'
|
||||
import { ContentType, DisplayStringForContentType } from '@standardnotes/common'
|
||||
import { ItemManager } from '@Lib/Services/Items/ItemManager'
|
||||
import {
|
||||
ActionObserver,
|
||||
@@ -41,6 +40,7 @@ import {
|
||||
isMobileDevice,
|
||||
MutatorClientInterface,
|
||||
} from '@standardnotes/services'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
const DESKTOP_URL_PREFIX = 'sn://'
|
||||
const LOCAL_HOST = 'localhost'
|
||||
@@ -223,7 +223,7 @@ export class SNComponentManager
|
||||
|
||||
addItemObserver(): void {
|
||||
this.removeItemObserver = this.itemManager.addObserver<SNComponent>(
|
||||
[ContentType.Component, ContentType.Theme],
|
||||
[ContentType.TYPES.Component, ContentType.TYPES.Theme],
|
||||
({ changed, inserted, removed, source }) => {
|
||||
const items = [...changed, ...inserted]
|
||||
this.handleChangedComponents(items, source)
|
||||
@@ -654,12 +654,17 @@ export class SNComponentManager
|
||||
if (!permission.content_types) {
|
||||
return
|
||||
}
|
||||
permission.content_types.forEach((contentType) => {
|
||||
const desc = DisplayStringForContentType(contentType)
|
||||
permission.content_types.forEach((contentTypeString: string) => {
|
||||
const contentTypeOrError = ContentType.create(contentTypeString)
|
||||
if (contentTypeOrError.isFailed()) {
|
||||
return
|
||||
}
|
||||
const contentType = contentTypeOrError.getValue()
|
||||
const desc = contentType.getDisplayName()
|
||||
if (desc) {
|
||||
contentTypeStrings.push(`${desc}s`)
|
||||
} else {
|
||||
contentTypeStrings.push(`items of type ${contentType}`)
|
||||
contentTypeStrings.push(`items of type ${contentType.value}`)
|
||||
}
|
||||
})
|
||||
break
|
||||
|
||||
@@ -52,7 +52,6 @@ import {
|
||||
import { ComponentAction, ComponentPermission, ComponentArea, FindNativeFeature } from '@standardnotes/features'
|
||||
import { ItemManager } from '@Lib/Services/Items/ItemManager'
|
||||
import { UuidString } from '@Lib/Types/UuidString'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import {
|
||||
isString,
|
||||
extendArray,
|
||||
@@ -65,6 +64,7 @@ import {
|
||||
sureSearchArray,
|
||||
isNotUndefined,
|
||||
} from '@standardnotes/utils'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
type RunWithPermissionsCallback = (
|
||||
componentUuid: UuidString,
|
||||
@@ -88,7 +88,7 @@ const ReadwriteActions = [
|
||||
type Writeable<T> = { -readonly [P in keyof T]: T[P] }
|
||||
|
||||
export class ComponentViewer implements ComponentViewerInterface {
|
||||
private streamItems?: ContentType[]
|
||||
private streamItems?: string[]
|
||||
private streamContextItemOriginalMessage?: ComponentMessage
|
||||
private streamItemsOriginalMessage?: ComponentMessage
|
||||
private removeItemObserver: () => void
|
||||
@@ -123,7 +123,7 @@ export class ComponentViewer implements ComponentViewerInterface {
|
||||
actionObserver?: ActionObserver,
|
||||
) {
|
||||
this.removeItemObserver = this.itemManager.addObserver(
|
||||
ContentType.Any,
|
||||
ContentType.TYPES.Any,
|
||||
({ changed, inserted, removed, source, sourceKey }) => {
|
||||
if (this.dealloced) {
|
||||
return
|
||||
@@ -686,7 +686,7 @@ export class ComponentViewer implements ComponentViewerInterface {
|
||||
if (item.locked) {
|
||||
remove(responsePayloads, { uuid: item.uuid })
|
||||
lockedCount++
|
||||
if (item.content_type === ContentType.Note) {
|
||||
if (item.content_type === ContentType.TYPES.Note) {
|
||||
lockedNoteCount++
|
||||
}
|
||||
}
|
||||
@@ -836,7 +836,7 @@ export class ComponentViewer implements ComponentViewerInterface {
|
||||
const data = message.data as DeleteItemsMessageData
|
||||
const items = data.items.filter((item) => AllowedBatchContentTypes.includes(item.content_type))
|
||||
|
||||
const requiredContentTypes = uniq(items.map((item) => item.content_type)).sort() as ContentType[]
|
||||
const requiredContentTypes = uniq(items.map((item) => item.content_type)).sort()
|
||||
|
||||
const requiredPermissions: ComponentPermission[] = [
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ComponentArea, ComponentAction, FeatureIdentifier, LegacyFileSafeIdentifier } from '@standardnotes/features'
|
||||
import { ComponentMessage, MessageData, OutgoingItemMessagePayload } from '@standardnotes/models'
|
||||
import { UuidString } from '@Lib/Types/UuidString'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
/**
|
||||
* Extensions allowed to batch stream AllowedBatchContentTypes
|
||||
@@ -16,9 +16,9 @@ export const AllowedBatchStreaming = Object.freeze([
|
||||
* Content types which are allowed to be managed/streamed in bulk by a component.
|
||||
*/
|
||||
export const AllowedBatchContentTypes = Object.freeze([
|
||||
ContentType.FilesafeCredentials,
|
||||
ContentType.FilesafeFileMetadata,
|
||||
ContentType.FilesafeIntegration,
|
||||
ContentType.TYPES.FilesafeCredentials,
|
||||
ContentType.TYPES.FilesafeFileMetadata,
|
||||
ContentType.TYPES.FilesafeIntegration,
|
||||
])
|
||||
|
||||
export type StreamObserver = {
|
||||
|
||||
@@ -2,8 +2,7 @@ import { ItemInterface, SNComponent, SNFeatureRepo } from '@standardnotes/models
|
||||
import { SNSyncService } from '../Sync/SyncService'
|
||||
import { SettingName } from '@standardnotes/settings'
|
||||
import { SNFeaturesService } from '@Lib/Services/Features'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { RoleName } from '@standardnotes/domain-core'
|
||||
import { ContentType, RoleName } from '@standardnotes/domain-core'
|
||||
import { FeatureDescription, FeatureIdentifier, GetFeatures } from '@standardnotes/features'
|
||||
import { SNWebSocketsService } from '../Api/WebsocketsService'
|
||||
import { SNSettingsService } from '../Settings'
|
||||
@@ -157,7 +156,7 @@ describe('featuresService', () => {
|
||||
{
|
||||
identifier: FeatureIdentifier.PlusEditor,
|
||||
expires_at: tomorrow_server,
|
||||
content_type: ContentType.Component,
|
||||
content_type: ContentType.TYPES.Component,
|
||||
},
|
||||
]
|
||||
|
||||
@@ -307,10 +306,10 @@ describe('featuresService', () => {
|
||||
|
||||
expect(mutator.createItem).toHaveBeenCalledTimes(2)
|
||||
expect(mutator.createItem).toHaveBeenCalledWith(
|
||||
ContentType.Theme,
|
||||
ContentType.TYPES.Theme,
|
||||
expect.objectContaining({
|
||||
package_info: expect.objectContaining({
|
||||
content_type: ContentType.Theme,
|
||||
content_type: ContentType.TYPES.Theme,
|
||||
expires_at: tomorrow_client,
|
||||
identifier: FeatureIdentifier.MidnightTheme,
|
||||
}),
|
||||
@@ -318,10 +317,10 @@ describe('featuresService', () => {
|
||||
true,
|
||||
)
|
||||
expect(mutator.createItem).toHaveBeenCalledWith(
|
||||
ContentType.Component,
|
||||
ContentType.TYPES.Component,
|
||||
expect.objectContaining({
|
||||
package_info: expect.objectContaining({
|
||||
content_type: ContentType.Component,
|
||||
content_type: ContentType.TYPES.Component,
|
||||
expires_at: tomorrow_client,
|
||||
identifier: FeatureIdentifier.PlusEditor,
|
||||
}),
|
||||
@@ -333,7 +332,7 @@ describe('featuresService', () => {
|
||||
it('if item for a feature exists updates its content', async () => {
|
||||
const existingItem = new SNComponent({
|
||||
uuid: '789',
|
||||
content_type: ContentType.Component,
|
||||
content_type: ContentType.TYPES.Component,
|
||||
content: {
|
||||
package_info: {
|
||||
identifier: FeatureIdentifier.PlusEditor,
|
||||
@@ -379,10 +378,10 @@ describe('featuresService', () => {
|
||||
await featuresService.fetchFeatures('123', didChangeRoles)
|
||||
|
||||
expect(mutator.createItem).toHaveBeenCalledWith(
|
||||
ContentType.Component,
|
||||
ContentType.TYPES.Component,
|
||||
expect.objectContaining({
|
||||
package_info: expect.objectContaining({
|
||||
content_type: ContentType.Component,
|
||||
content_type: ContentType.TYPES.Component,
|
||||
expires_at: yesterday_client,
|
||||
identifier: FeatureIdentifier.PlusEditor,
|
||||
}),
|
||||
@@ -394,7 +393,7 @@ describe('featuresService', () => {
|
||||
it('deletes items for expired themes', async () => {
|
||||
const existingItem = new SNComponent({
|
||||
uuid: '456',
|
||||
content_type: ContentType.Theme,
|
||||
content_type: ContentType.TYPES.Theme,
|
||||
content: {
|
||||
package_info: {
|
||||
identifier: FeatureIdentifier.MidnightTheme,
|
||||
@@ -498,7 +497,7 @@ describe('featuresService', () => {
|
||||
it('remote native features should be swapped with compiled version', async () => {
|
||||
const remoteFeature = {
|
||||
identifier: FeatureIdentifier.PlusEditor,
|
||||
content_type: ContentType.Component,
|
||||
content_type: ContentType.TYPES.Component,
|
||||
expires_at: tomorrow_server,
|
||||
} as FeatureDescription
|
||||
|
||||
@@ -528,7 +527,7 @@ describe('featuresService', () => {
|
||||
it('mapRemoteNativeFeatureToItem should throw if called with client controlled feature', async () => {
|
||||
const clientFeature = {
|
||||
identifier: FeatureIdentifier.DarkTheme,
|
||||
content_type: ContentType.Theme,
|
||||
content_type: ContentType.TYPES.Theme,
|
||||
clientControlled: true,
|
||||
} as FeatureDescription
|
||||
|
||||
@@ -573,13 +572,13 @@ describe('featuresService', () => {
|
||||
features = [
|
||||
{
|
||||
identifier: FeatureIdentifier.MidnightTheme,
|
||||
content_type: ContentType.Theme,
|
||||
content_type: ContentType.TYPES.Theme,
|
||||
expires_at: tomorrow_server,
|
||||
role_name: RoleName.NAMES.PlusUser,
|
||||
},
|
||||
{
|
||||
identifier: FeatureIdentifier.PlusEditor,
|
||||
content_type: ContentType.Component,
|
||||
content_type: ContentType.TYPES.Component,
|
||||
expires_at: expiredDate,
|
||||
role_name: RoleName.NAMES.ProUser,
|
||||
},
|
||||
@@ -617,14 +616,14 @@ describe('featuresService', () => {
|
||||
|
||||
const themeFeature = {
|
||||
identifier: 'third-party-theme' as FeatureIdentifier,
|
||||
content_type: ContentType.Theme,
|
||||
content_type: ContentType.TYPES.Theme,
|
||||
expires_at: tomorrow_server,
|
||||
role_name: RoleName.NAMES.CoreUser,
|
||||
}
|
||||
|
||||
const editorFeature = {
|
||||
identifier: 'third-party-editor' as FeatureIdentifier,
|
||||
content_type: ContentType.Component,
|
||||
content_type: ContentType.TYPES.Component,
|
||||
expires_at: expiredDate,
|
||||
role_name: RoleName.NAMES.PlusUser,
|
||||
}
|
||||
@@ -636,7 +635,7 @@ describe('featuresService', () => {
|
||||
itemManager.getDisplayableComponents = jest.fn().mockReturnValue([
|
||||
new SNComponent({
|
||||
uuid: '123',
|
||||
content_type: ContentType.Theme,
|
||||
content_type: ContentType.TYPES.Theme,
|
||||
content: {
|
||||
valid_until: themeFeature.expires_at,
|
||||
package_info: {
|
||||
@@ -646,7 +645,7 @@ describe('featuresService', () => {
|
||||
} as never),
|
||||
new SNComponent({
|
||||
uuid: '456',
|
||||
content_type: ContentType.Component,
|
||||
content_type: ContentType.TYPES.Component,
|
||||
content: {
|
||||
valid_until: new Date(editorFeature.expires_at),
|
||||
package_info: {
|
||||
@@ -774,7 +773,7 @@ describe('featuresService', () => {
|
||||
const extensionKey = '129b029707e3470c94a8477a437f9394'
|
||||
const extensionRepoItem = new SNFeatureRepo({
|
||||
uuid: '456',
|
||||
content_type: ContentType.ExtensionRepo,
|
||||
content_type: ContentType.TYPES.ExtensionRepo,
|
||||
content: {
|
||||
url: `https://extensions.standardnotes.org/${extensionKey}`,
|
||||
},
|
||||
|
||||
@@ -8,8 +8,7 @@ import {
|
||||
isString,
|
||||
} from '@standardnotes/utils'
|
||||
import { ClientDisplayableError, isErrorResponse } from '@standardnotes/responses'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { RoleName } from '@standardnotes/domain-core'
|
||||
import { ContentType, RoleName } from '@standardnotes/domain-core'
|
||||
import { FillItemContent, PayloadEmitSource } from '@standardnotes/models'
|
||||
import { ItemManager } from '../Items/ItemManager'
|
||||
import { LEGACY_PROD_EXT_ORIGIN, PROD_OFFLINE_FEATURES_URL } from '../../Hosts'
|
||||
@@ -96,7 +95,7 @@ export class SNFeaturesService
|
||||
})
|
||||
|
||||
this.removefeatureReposObserver = this.itemManager.addObserver(
|
||||
ContentType.ExtensionRepo,
|
||||
ContentType.TYPES.ExtensionRepo,
|
||||
async ({ changed, inserted, source }) => {
|
||||
const sources = [
|
||||
PayloadEmitSource.InitialObserverRegistrationPush,
|
||||
@@ -119,7 +118,7 @@ export class SNFeaturesService
|
||||
|
||||
this.removeSignInObserver = this.userService.addEventObserver((eventName: AccountEvent) => {
|
||||
if (eventName === AccountEvent.SignedInOrRegistered) {
|
||||
const featureRepos = this.itemManager.getItems(ContentType.ExtensionRepo) as Models.SNFeatureRepo[]
|
||||
const featureRepos = this.itemManager.getItems(ContentType.TYPES.ExtensionRepo) as Models.SNFeatureRepo[]
|
||||
|
||||
if (!this.apiService.isThirdPartyHostUsed()) {
|
||||
void this.migrateFeatureRepoToUserSetting(featureRepos)
|
||||
@@ -179,7 +178,10 @@ export class SNFeaturesService
|
||||
|
||||
private async mapClientControlledFeaturesToItems() {
|
||||
const clientFeatures = FeaturesImports.GetFeatures().filter((feature) => feature.clientControlled)
|
||||
const currentItems = this.itemManager.getItems<Models.SNComponent>([ContentType.Component, ContentType.Theme])
|
||||
const currentItems = this.itemManager.getItems<Models.SNComponent>([
|
||||
ContentType.TYPES.Component,
|
||||
ContentType.TYPES.Theme,
|
||||
])
|
||||
|
||||
for (const feature of clientFeatures) {
|
||||
if (!feature.content_type) {
|
||||
@@ -226,7 +228,7 @@ export class SNFeaturesService
|
||||
void this.storageService.setValue(StorageKey.ExperimentalFeatures, this.enabledExperimentalFeatures)
|
||||
|
||||
const component = this.itemManager
|
||||
.getItems<Models.SNComponent | Models.SNTheme>([ContentType.Component, ContentType.Theme])
|
||||
.getItems<Models.SNComponent | Models.SNTheme>([ContentType.TYPES.Component, ContentType.TYPES.Theme])
|
||||
.find((component) => component.identifier === identifier)
|
||||
if (!component) {
|
||||
return
|
||||
@@ -273,7 +275,7 @@ export class SNFeaturesService
|
||||
}
|
||||
|
||||
const offlineRepo = (await this.mutator.createItem(
|
||||
ContentType.ExtensionRepo,
|
||||
ContentType.TYPES.ExtensionRepo,
|
||||
FillItemContent({
|
||||
offlineFeaturesUrl: result.featuresUrl,
|
||||
offlineKey: result.extensionKey,
|
||||
@@ -289,7 +291,7 @@ export class SNFeaturesService
|
||||
}
|
||||
|
||||
private getOfflineRepo(): Models.SNFeatureRepo | undefined {
|
||||
const repos = this.itemManager.getItems(ContentType.ExtensionRepo) as Models.SNFeatureRepo[]
|
||||
const repos = this.itemManager.getItems(ContentType.TYPES.ExtensionRepo) as Models.SNFeatureRepo[]
|
||||
return repos.filter((repo) => repo.migratedToOfflineEntitlements)[0]
|
||||
}
|
||||
|
||||
@@ -638,7 +640,10 @@ export class SNFeaturesService
|
||||
}
|
||||
|
||||
private async mapRemoteNativeFeaturesToItems(features: FeaturesImports.FeatureDescription[]): Promise<void> {
|
||||
const currentItems = this.itemManager.getItems<Models.SNComponent>([ContentType.Component, ContentType.Theme])
|
||||
const currentItems = this.itemManager.getItems<Models.SNComponent>([
|
||||
ContentType.TYPES.Component,
|
||||
ContentType.TYPES.Theme,
|
||||
])
|
||||
const itemsToDelete: Models.SNComponent[] = []
|
||||
let hasChanges = false
|
||||
|
||||
@@ -715,7 +720,7 @@ export class SNFeaturesService
|
||||
} else {
|
||||
resultingItem = existingItem
|
||||
}
|
||||
} else if (!expired || feature.content_type === ContentType.Component) {
|
||||
} else if (!expired || feature.content_type === ContentType.TYPES.Component) {
|
||||
resultingItem = (await this.mutator.createItem(
|
||||
feature.content_type,
|
||||
this.componentContentForNativeFeatureDescription(feature),
|
||||
@@ -725,7 +730,7 @@ export class SNFeaturesService
|
||||
}
|
||||
|
||||
if (expired && resultingItem) {
|
||||
if (feature.content_type !== ContentType.Component) {
|
||||
if (feature.content_type !== ContentType.TYPES.Component) {
|
||||
itemsToDelete.push(resultingItem)
|
||||
hasChanges = true
|
||||
}
|
||||
@@ -786,10 +791,10 @@ export class SNFeaturesService
|
||||
}
|
||||
|
||||
const isValidContentType = [
|
||||
ContentType.Component,
|
||||
ContentType.Theme,
|
||||
ContentType.ActionsExtension,
|
||||
ContentType.ExtensionRepo,
|
||||
ContentType.TYPES.Component,
|
||||
ContentType.TYPES.Theme,
|
||||
ContentType.TYPES.ActionsExtension,
|
||||
ContentType.TYPES.ExtensionRepo,
|
||||
].includes(rawFeature.content_type)
|
||||
|
||||
if (!isValidContentType) {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { removeFromArray } from '@standardnotes/utils'
|
||||
import { ItemManager } from '@Lib/Services/Items/ItemManager'
|
||||
import { DiskStorageService } from '@Lib/Services/Storage/DiskStorageService'
|
||||
@@ -11,6 +10,7 @@ import {
|
||||
HistoryServiceInterface,
|
||||
InternalEventBusInterface,
|
||||
} from '@standardnotes/services'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
/** The amount of revisions per item above which should call for an optimization. */
|
||||
const DefaultItemRevisionsThreshold = 20
|
||||
@@ -53,7 +53,7 @@ export class SNHistoryManager extends AbstractService implements HistoryServiceI
|
||||
protected override internalEventBus: InternalEventBusInterface,
|
||||
) {
|
||||
super(internalEventBus)
|
||||
this.removeChangeObserver = this.itemManager.addObserver(ContentType.Note, ({ changed, inserted }) => {
|
||||
this.removeChangeObserver = this.itemManager.addObserver(ContentType.TYPES.Note, ({ changed, inserted }) => {
|
||||
this.recordNewHistoryForItems(changed.concat(inserted) as SNNote[])
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { AlertService, InternalEventBusInterface, ItemRelationshipDirection } from '@standardnotes/services'
|
||||
import { ItemManager } from './ItemManager'
|
||||
import { PayloadManager } from '../Payloads/PayloadManager'
|
||||
@@ -65,7 +65,7 @@ describe('itemManager', () => {
|
||||
return new Models.SNTag(
|
||||
new Models.DecryptedPayload({
|
||||
uuid: String(Math.random()),
|
||||
content_type: ContentType.Tag,
|
||||
content_type: ContentType.TYPES.Tag,
|
||||
content: Models.FillItemContent<Models.TagContent>({
|
||||
title: title,
|
||||
}),
|
||||
@@ -78,7 +78,7 @@ describe('itemManager', () => {
|
||||
return new Models.FileItem(
|
||||
new Models.DecryptedPayload({
|
||||
uuid: String(Math.random()),
|
||||
content_type: ContentType.File,
|
||||
content_type: ContentType.TYPES.File,
|
||||
content: Models.FillItemContent<Models.FileContent>({
|
||||
name: name,
|
||||
}),
|
||||
@@ -91,7 +91,7 @@ describe('itemManager', () => {
|
||||
it('deleted payloads should map to removed items', async () => {
|
||||
const payload = new DeletedPayload({
|
||||
uuid: String(Math.random()),
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: undefined,
|
||||
deleted: true,
|
||||
dirty: true,
|
||||
@@ -110,7 +110,7 @@ describe('itemManager', () => {
|
||||
it('decrypted items who become encrypted should be removed from ui', async () => {
|
||||
const decrypted = new DecryptedPayload({
|
||||
uuid: String(Math.random()),
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: FillItemContent<NoteContent>({
|
||||
title: 'foo',
|
||||
}),
|
||||
@@ -372,7 +372,7 @@ describe('itemManager', () => {
|
||||
it('create template item', async () => {
|
||||
setupRandomUuid()
|
||||
|
||||
const item = await itemManager.createTemplateItem(ContentType.Note, {
|
||||
const item = await itemManager.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'hello',
|
||||
references: [],
|
||||
})
|
||||
@@ -386,7 +386,7 @@ describe('itemManager', () => {
|
||||
it('isTemplateItem return the correct value', async () => {
|
||||
setupRandomUuid()
|
||||
|
||||
const item = await itemManager.createTemplateItem(ContentType.Note, {
|
||||
const item = await itemManager.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'hello',
|
||||
references: [],
|
||||
})
|
||||
@@ -511,9 +511,9 @@ describe('itemManager', () => {
|
||||
expect(view2).toBeTruthy()
|
||||
expect(view3).toBeTruthy()
|
||||
|
||||
expect(view1.content_type).toEqual(ContentType.SmartView)
|
||||
expect(view2.content_type).toEqual(ContentType.SmartView)
|
||||
expect(view3.content_type).toEqual(ContentType.SmartView)
|
||||
expect(view1.content_type).toEqual(ContentType.TYPES.SmartView)
|
||||
expect(view2.content_type).toEqual(ContentType.TYPES.SmartView)
|
||||
expect(view3.content_type).toEqual(ContentType.TYPES.SmartView)
|
||||
})
|
||||
|
||||
it('lets me use a smart view', async () => {
|
||||
@@ -550,9 +550,9 @@ describe('itemManager', () => {
|
||||
expect(tag2).toBeTruthy()
|
||||
expect(tag3).toBeTruthy()
|
||||
|
||||
expect(tag1.content_type).toEqual(ContentType.SmartView)
|
||||
expect(tag2.content_type).toEqual(ContentType.SmartView)
|
||||
expect(tag3.content_type).toEqual(ContentType.SmartView)
|
||||
expect(tag1.content_type).toEqual(ContentType.TYPES.SmartView)
|
||||
expect(tag2.content_type).toEqual(ContentType.TYPES.SmartView)
|
||||
expect(tag3.content_type).toEqual(ContentType.TYPES.SmartView)
|
||||
})
|
||||
|
||||
it('will create smart view or tags from the generic method', async () => {
|
||||
@@ -561,8 +561,8 @@ describe('itemManager', () => {
|
||||
const someTag = await mutator.createTagOrSmartView('some-tag')
|
||||
const someView = await mutator.createTagOrSmartView(VIEW_LONG)
|
||||
|
||||
expect(someTag.content_type).toEqual(ContentType.Tag)
|
||||
expect(someView.content_type).toEqual(ContentType.SmartView)
|
||||
expect(someTag.content_type).toEqual(ContentType.TYPES.Tag)
|
||||
expect(someView.content_type).toEqual(ContentType.TYPES.SmartView)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { assert, naturalSort, removeFromArray, UuidGenerator, Uuids } from '@standardnotes/utils'
|
||||
import { SNItemsKey } from '@standardnotes/encryption'
|
||||
import { PayloadManager } from '../Payloads/PayloadManager'
|
||||
@@ -8,9 +7,10 @@ import * as Models from '@standardnotes/models'
|
||||
import * as Services from '@standardnotes/services'
|
||||
import { PayloadManagerChangeData } from '../Payloads'
|
||||
import { ItemRelationshipDirection } from '@standardnotes/services'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
type ItemsChangeObserver<I extends Models.DecryptedItemInterface = Models.DecryptedItemInterface> = {
|
||||
contentType: ContentType[]
|
||||
contentType: string[]
|
||||
callback: Services.ItemManagerChangeObserverCallback<I>
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ export class ItemManager extends Services.AbstractService implements Services.It
|
||||
this.payloadManager = payloadManager
|
||||
this.systemSmartViews = this.rebuildSystemSmartViews({})
|
||||
this.createCollection()
|
||||
this.unsubChangeObserver = this.payloadManager.addObserver(ContentType.Any, this.setPayloads.bind(this))
|
||||
this.unsubChangeObserver = this.payloadManager.addObserver(ContentType.TYPES.Any, this.setPayloads.bind(this))
|
||||
}
|
||||
|
||||
private rebuildSystemSmartViews(criteria: Models.NotesAndFilesDisplayOptions): Models.SmartView[] {
|
||||
@@ -65,34 +65,34 @@ export class ItemManager extends Services.AbstractService implements Services.It
|
||||
|
||||
this.navigationDisplayController = new Models.ItemDisplayController(
|
||||
this.collection,
|
||||
[ContentType.Note, ContentType.File],
|
||||
[ContentType.TYPES.Note, ContentType.TYPES.File],
|
||||
{
|
||||
sortBy: 'created_at',
|
||||
sortDirection: 'dsc',
|
||||
hiddenContentTypes: [],
|
||||
},
|
||||
)
|
||||
this.tagDisplayController = new Models.ItemDisplayController(this.collection, [ContentType.Tag], {
|
||||
this.tagDisplayController = new Models.ItemDisplayController(this.collection, [ContentType.TYPES.Tag], {
|
||||
sortBy: 'title',
|
||||
sortDirection: 'asc',
|
||||
})
|
||||
this.itemsKeyDisplayController = new Models.ItemDisplayController(this.collection, [ContentType.ItemsKey], {
|
||||
this.itemsKeyDisplayController = new Models.ItemDisplayController(this.collection, [ContentType.TYPES.ItemsKey], {
|
||||
sortBy: 'created_at',
|
||||
sortDirection: 'asc',
|
||||
})
|
||||
this.componentDisplayController = new Models.ItemDisplayController(this.collection, [ContentType.Component], {
|
||||
this.componentDisplayController = new Models.ItemDisplayController(this.collection, [ContentType.TYPES.Component], {
|
||||
sortBy: 'created_at',
|
||||
sortDirection: 'asc',
|
||||
})
|
||||
this.themeDisplayController = new Models.ItemDisplayController(this.collection, [ContentType.Theme], {
|
||||
this.themeDisplayController = new Models.ItemDisplayController(this.collection, [ContentType.TYPES.Theme], {
|
||||
sortBy: 'title',
|
||||
sortDirection: 'asc',
|
||||
})
|
||||
this.smartViewDisplayController = new Models.ItemDisplayController(this.collection, [ContentType.SmartView], {
|
||||
this.smartViewDisplayController = new Models.ItemDisplayController(this.collection, [ContentType.TYPES.SmartView], {
|
||||
sortBy: 'title',
|
||||
sortDirection: 'asc',
|
||||
})
|
||||
this.fileDisplayController = new Models.ItemDisplayController(this.collection, [ContentType.File], {
|
||||
this.fileDisplayController = new Models.ItemDisplayController(this.collection, [ContentType.TYPES.File], {
|
||||
sortBy: 'title',
|
||||
sortDirection: 'asc',
|
||||
})
|
||||
@@ -177,7 +177,7 @@ export class ItemManager extends Services.AbstractService implements Services.It
|
||||
...{
|
||||
tags: mostRecentVersionOfTags,
|
||||
views: mostRecentVersionOfViews,
|
||||
hiddenContentTypes: [ContentType.Tag],
|
||||
hiddenContentTypes: [ContentType.TYPES.Tag],
|
||||
},
|
||||
}
|
||||
|
||||
@@ -324,7 +324,7 @@ export class ItemManager extends Services.AbstractService implements Services.It
|
||||
}
|
||||
|
||||
public addObserver<I extends Models.DecryptedItemInterface = Models.DecryptedItemInterface>(
|
||||
contentType: ContentType | ContentType[],
|
||||
contentType: string | string[],
|
||||
callback: Services.ItemManagerChangeObserverCallback<I>,
|
||||
): () => void {
|
||||
if (!Array.isArray(contentType)) {
|
||||
@@ -349,7 +349,7 @@ export class ItemManager extends Services.AbstractService implements Services.It
|
||||
*/
|
||||
public itemsReferencingItem<I extends Models.DecryptedItemInterface = Models.DecryptedItemInterface>(
|
||||
itemToLookupUuidFor: { uuid: UuidString },
|
||||
contentType?: ContentType,
|
||||
contentType?: string,
|
||||
): I[] {
|
||||
const uuids = this.collection.uuidsThatReferenceUuid(itemToLookupUuidFor.uuid)
|
||||
let referencing = this.findItems<I>(uuids)
|
||||
@@ -366,7 +366,7 @@ export class ItemManager extends Services.AbstractService implements Services.It
|
||||
*/
|
||||
public referencesForItem<I extends Models.DecryptedItemInterface = Models.DecryptedItemInterface>(
|
||||
itemToLookupUuidFor: Models.DecryptedItemInterface,
|
||||
contentType?: ContentType,
|
||||
contentType?: string,
|
||||
): I[] {
|
||||
const item = this.findSureItem<I>(itemToLookupUuidFor.uuid)
|
||||
const uuids = item.references.map((ref) => ref.uuid)
|
||||
@@ -386,7 +386,7 @@ export class ItemManager extends Services.AbstractService implements Services.It
|
||||
return Models.CreateItemFromPayload(payload)
|
||||
}
|
||||
|
||||
const affectedContentTypes = new Set<ContentType>()
|
||||
const affectedContentTypes = new Set<string>()
|
||||
|
||||
const changedItems = changed.map((p) => {
|
||||
affectedContentTypes.add(p.content_type)
|
||||
@@ -490,9 +490,9 @@ export class ItemManager extends Services.AbstractService implements Services.It
|
||||
source: Models.PayloadEmitSource,
|
||||
sourceKey?: string,
|
||||
) {
|
||||
const filter = <I extends Models.ItemInterface>(items: I[], types: ContentType[]) => {
|
||||
const filter = <I extends Models.ItemInterface>(items: I[], types: string[]) => {
|
||||
return items.filter((item) => {
|
||||
return types.includes(ContentType.Any) || types.includes(item.content_type)
|
||||
return types.includes(ContentType.TYPES.Any) || types.includes(item.content_type)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -536,7 +536,7 @@ export class ItemManager extends Services.AbstractService implements Services.It
|
||||
public createTemplateItem<
|
||||
C extends Models.ItemContent = Models.ItemContent,
|
||||
I extends Models.DecryptedItemInterface<C> = Models.DecryptedItemInterface<C>,
|
||||
>(contentType: ContentType, content?: C, override?: Partial<Models.DecryptedPayload<C>>): I {
|
||||
>(contentType: string, content?: C, override?: Partial<Models.DecryptedPayload<C>>): I {
|
||||
const payload = new Models.DecryptedPayload<C>({
|
||||
uuid: UuidGenerator.GenerateUuid(),
|
||||
content_type: contentType,
|
||||
@@ -556,23 +556,23 @@ export class ItemManager extends Services.AbstractService implements Services.It
|
||||
return !this.findItem(item.uuid)
|
||||
}
|
||||
|
||||
public getItems<T extends Models.DecryptedItemInterface>(contentType: ContentType | ContentType[]): T[] {
|
||||
public getItems<T extends Models.DecryptedItemInterface>(contentType: string | string[]): T[] {
|
||||
return this.collection.allDecrypted<T>(contentType)
|
||||
}
|
||||
|
||||
getAnyItems(contentType: ContentType | ContentType[]): Models.ItemInterface[] {
|
||||
getAnyItems(contentType: string | string[]): Models.ItemInterface[] {
|
||||
return this.collection.all(contentType)
|
||||
}
|
||||
|
||||
public itemsMatchingPredicate<T extends Models.DecryptedItemInterface>(
|
||||
contentType: ContentType,
|
||||
contentType: string,
|
||||
predicate: Models.PredicateInterface<T>,
|
||||
): T[] {
|
||||
return this.itemsMatchingPredicates(contentType, [predicate])
|
||||
}
|
||||
|
||||
public itemsMatchingPredicates<T extends Models.DecryptedItemInterface>(
|
||||
contentType: ContentType,
|
||||
contentType: string,
|
||||
predicates: Models.PredicateInterface<T>[],
|
||||
): T[] {
|
||||
const subItems = this.getItems<T>(contentType)
|
||||
@@ -687,7 +687,7 @@ export class ItemManager extends Services.AbstractService implements Services.It
|
||||
return []
|
||||
}
|
||||
|
||||
const tags = this.collection.elementsReferencingElement(tag, ContentType.Tag) as Models.SNTag[]
|
||||
const tags = this.collection.elementsReferencingElement(tag, ContentType.TYPES.Tag) as Models.SNTag[]
|
||||
|
||||
return tags.filter((tag) => tag.parentId === itemToLookupUuidFor.uuid)
|
||||
}
|
||||
@@ -736,7 +736,7 @@ export class ItemManager extends Services.AbstractService implements Services.It
|
||||
public getSortedTagsForItem(item: Models.DecryptedItemInterface<Models.ItemContent>): Models.SNTag[] {
|
||||
return naturalSort(
|
||||
this.itemsReferencingItem(item).filter((ref) => {
|
||||
return ref?.content_type === ContentType.Tag
|
||||
return ref?.content_type === ContentType.TYPES.Tag
|
||||
}) as Models.SNTag[],
|
||||
'title',
|
||||
)
|
||||
@@ -753,7 +753,7 @@ export class ItemManager extends Services.AbstractService implements Services.It
|
||||
|
||||
return Models.notesAndFilesMatchingOptions(
|
||||
criteria,
|
||||
this.collection.allDecrypted(ContentType.Note),
|
||||
this.collection.allDecrypted(ContentType.TYPES.Note),
|
||||
this.collection,
|
||||
) as Models.SNNote[]
|
||||
}
|
||||
@@ -790,7 +790,7 @@ export class ItemManager extends Services.AbstractService implements Services.It
|
||||
* The number of notes currently managed
|
||||
*/
|
||||
public get noteCount(): number {
|
||||
return this.collection.all(ContentType.Note).length
|
||||
return this.collection.all(ContentType.TYPES.Note).length
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ItemsKeyInterface } from '@standardnotes/models'
|
||||
import { dateSorted } from '@standardnotes/utils'
|
||||
import { SNRootKeyParams, EncryptionProviderInterface } from '@standardnotes/encryption'
|
||||
@@ -6,6 +5,7 @@ import { DecryptionQueueItem, KeyRecoveryOperationResult } from './Types'
|
||||
import { serverKeyParamsAreSafe } from './Utils'
|
||||
import { ChallengeServiceInterface, DecryptItemsKeyByPromptingUser } from '@standardnotes/services'
|
||||
import { ItemManager } from '../Items'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
export class KeyRecoveryOperation {
|
||||
constructor(
|
||||
@@ -29,7 +29,7 @@ export class KeyRecoveryOperation {
|
||||
|
||||
if (queueItemKeyParamsAreBetterOrEqualToClients) {
|
||||
const latestDecryptedItemsKey = dateSorted(
|
||||
this.itemManager.getItems<ItemsKeyInterface>(ContentType.ItemsKey),
|
||||
this.itemManager.getItems<ItemsKeyInterface>(ContentType.TYPES.ItemsKey),
|
||||
'created_at',
|
||||
false,
|
||||
)[0]
|
||||
|
||||
@@ -16,7 +16,6 @@ import { DiskStorageService } from '../Storage/DiskStorageService'
|
||||
import { PayloadManager } from '../Payloads/PayloadManager'
|
||||
import { ChallengeService } from '../Challenge'
|
||||
import { SNApiService } from '@Lib/Services/Api/ApiService'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ItemManager } from '../Items/ItemManager'
|
||||
import { removeFromArray, Uuids } from '@standardnotes/utils'
|
||||
import { ClientDisplayableError, isErrorResponse } from '@standardnotes/responses'
|
||||
@@ -43,6 +42,7 @@ import {
|
||||
KeyRecoveryOperationResult,
|
||||
} from './Types'
|
||||
import { serverKeyParamsAreSafe } from './Utils'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
/**
|
||||
* The key recovery service listens to items key changes to detect any that cannot be decrypted.
|
||||
@@ -99,7 +99,7 @@ export class SNKeyRecoveryService extends AbstractService<KeyRecoveryEvent, Decr
|
||||
super(internalEventBus)
|
||||
|
||||
this.removeItemObserver = this.payloadManager.addObserver(
|
||||
[ContentType.ItemsKey],
|
||||
[ContentType.TYPES.ItemsKey],
|
||||
({ changed, inserted, ignored, source }) => {
|
||||
if (source === PayloadEmitSource.LocalChanged) {
|
||||
return
|
||||
@@ -181,7 +181,7 @@ export class SNKeyRecoveryService extends AbstractService<KeyRecoveryEvent, Decr
|
||||
|
||||
public presentKeyRecoveryWizard(): void {
|
||||
const invalidKeys = this.itemManager.invalidItems
|
||||
.filter((i) => i.content_type === ContentType.ItemsKey)
|
||||
.filter((i) => i.content_type === ContentType.TYPES.ItemsKey)
|
||||
.map((i) => i.payload)
|
||||
|
||||
void this.handleIgnoredItemsKeys(invalidKeys, false)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { SyncClientInterface } from './../Sync/SyncClientInterface'
|
||||
import { isString, lastElement, sleep } from '@standardnotes/utils'
|
||||
import { UuidString } from '@Lib/Types/UuidString'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ItemManager } from '@Lib/Services/Items/ItemManager'
|
||||
import { DeprecatedHttpService } from '../Api/DeprecatedHttpService'
|
||||
import { SettingName } from '@standardnotes/settings'
|
||||
@@ -12,6 +11,7 @@ import { isErrorResponse, ListedAccount, ListedAccountInfo, ListedAccountInfoRes
|
||||
import { NoteMutator, SNActionsExtension, SNNote } from '@standardnotes/models'
|
||||
import { AbstractService, InternalEventBusInterface, MutatorClientInterface } from '@standardnotes/services'
|
||||
import { SNProtectionService } from '../Protection'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
export class ListedService extends AbstractService implements ListedClientInterface {
|
||||
constructor(
|
||||
@@ -124,7 +124,7 @@ export class ListedService extends AbstractService implements ListedClientInterf
|
||||
|
||||
private getLegacyListedAccounts(): ListedAccount[] {
|
||||
const extensions = this.itemManager
|
||||
.getItems<SNActionsExtension>(ContentType.ActionsExtension)
|
||||
.getItems<SNActionsExtension>(ContentType.TYPES.ActionsExtension)
|
||||
.filter((extension) => extension.isListedExtension)
|
||||
|
||||
const accounts: ListedAccount[] = []
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
FileItem,
|
||||
SNTag,
|
||||
} from '@standardnotes/models'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { AlertService, InternalEventBusInterface } from '@standardnotes/services'
|
||||
import { MutatorService, PayloadManager, ItemManager } from '../'
|
||||
import { UuidGenerator } from '@standardnotes/utils'
|
||||
@@ -42,7 +42,7 @@ describe('mutator service', () => {
|
||||
const note = new SNNote(
|
||||
new DecryptedPayload({
|
||||
uuid: String(Math.random()),
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: FillItemContent<NoteContent>({
|
||||
title: title,
|
||||
}),
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
AlertService,
|
||||
} from '@standardnotes/services'
|
||||
import { ItemsKeyMutator, SNItemsKey } from '@standardnotes/encryption'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { ItemManager } from '../Items'
|
||||
import { PayloadManager } from '../Payloads/PayloadManager'
|
||||
import { TagsToFoldersMigrationApplicator } from '@Lib/Migrations/Applicators/TagsToFolders'
|
||||
@@ -329,7 +329,7 @@ export class MutatorService extends AbstractService implements MutatorClientInte
|
||||
}
|
||||
|
||||
public async createItem<T extends DecryptedItemInterface, C extends ItemContent = ItemContent>(
|
||||
contentType: ContentType,
|
||||
contentType: string,
|
||||
content: C,
|
||||
needsSync = false,
|
||||
vault?: VaultListingInterface,
|
||||
@@ -451,7 +451,7 @@ export class MutatorService extends AbstractService implements MutatorClientInte
|
||||
createInVault?: VaultListingInterface
|
||||
}): Promise<SNTag> {
|
||||
const newTag = await this.createItem<SNTag>(
|
||||
ContentType.Tag,
|
||||
ContentType.TYPES.Tag,
|
||||
FillItemContent<TagContent>({ title: dto.title }),
|
||||
true,
|
||||
dto.createInVault,
|
||||
@@ -477,7 +477,7 @@ export class MutatorService extends AbstractService implements MutatorClientInte
|
||||
vault?: VaultListingInterface
|
||||
}): Promise<SmartView> {
|
||||
return this.createItem(
|
||||
ContentType.SmartView,
|
||||
ContentType.TYPES.SmartView,
|
||||
FillItemContent({
|
||||
title: dto.title,
|
||||
predicate: dto.predicate.toJson(),
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
} from '@standardnotes/models'
|
||||
import { PayloadManager } from './PayloadManager'
|
||||
import { InternalEventBusInterface } from '@standardnotes/services'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
describe('payload manager', () => {
|
||||
let payloadManager: PayloadManager
|
||||
@@ -23,7 +23,7 @@ describe('payload manager', () => {
|
||||
it('emitting a payload should emit as-is and not merge on top of existing payload', async () => {
|
||||
const decrypted = new DecryptedPayload({
|
||||
uuid: '123',
|
||||
content_type: ContentType.ItemsKey,
|
||||
content_type: ContentType.TYPES.ItemsKey,
|
||||
content: FillItemContent<ItemsKeyContent>({
|
||||
itemsKey: 'secret',
|
||||
}),
|
||||
@@ -36,7 +36,7 @@ describe('payload manager', () => {
|
||||
|
||||
const nondirty = new DecryptedPayload({
|
||||
uuid: '123',
|
||||
content_type: ContentType.ItemsKey,
|
||||
content_type: ContentType.TYPES.ItemsKey,
|
||||
...PayloadTimestampDefaults(),
|
||||
updated_at_timestamp: 2,
|
||||
content: FillItemContent<ItemsKeyContent>({
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { PayloadsChangeObserver, QueueElement, PayloadsChangeObserverCallback, EmitQueue } from './Types'
|
||||
import { removeFromArray, Uuids } from '@standardnotes/utils'
|
||||
import {
|
||||
@@ -74,7 +74,7 @@ export class PayloadManager extends AbstractService implements PayloadManagerInt
|
||||
return this.collection.findAll([uuid])[0]
|
||||
}
|
||||
|
||||
public all(contentType: ContentType): FullyFormedPayloadInterface[] {
|
||||
public all(contentType: string): FullyFormedPayloadInterface[] {
|
||||
return this.collection.all(contentType)
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ export class PayloadManager extends AbstractService implements PayloadManagerInt
|
||||
* @param priority - The lower the priority, the earlier the function is called
|
||||
* wrt to other observers
|
||||
*/
|
||||
public addObserver(types: ContentType | ContentType[], callback: PayloadsChangeObserverCallback, priority = 1) {
|
||||
public addObserver(types: string | string[], callback: PayloadsChangeObserverCallback, priority = 1) {
|
||||
if (!Array.isArray(types)) {
|
||||
types = [types]
|
||||
}
|
||||
@@ -261,9 +261,9 @@ export class PayloadManager extends AbstractService implements PayloadManagerInt
|
||||
|
||||
const filter = <P extends FullyFormedPayloadInterface = FullyFormedPayloadInterface>(
|
||||
payloads: P[],
|
||||
types: ContentType[],
|
||||
types: string[],
|
||||
) => {
|
||||
return types.includes(ContentType.Any)
|
||||
return types.includes(ContentType.TYPES.Any)
|
||||
? payloads.slice()
|
||||
: payloads.slice().filter((payload) => {
|
||||
return types.includes(payload.content_type)
|
||||
@@ -304,7 +304,7 @@ export class PayloadManager extends AbstractService implements PayloadManagerInt
|
||||
this.collection.discard(payload)
|
||||
}
|
||||
|
||||
public erroredPayloadsForContentType(contentType: ContentType): EncryptedPayloadInterface[] {
|
||||
public erroredPayloadsForContentType(contentType: string): EncryptedPayloadInterface[] {
|
||||
return this.collection.invalidElements().filter((p) => p.content_type === contentType)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import {
|
||||
DecryptedPayloadInterface,
|
||||
DeletedPayloadInterface,
|
||||
@@ -34,7 +33,7 @@ export type PayloadManagerChangeData = {
|
||||
export type PayloadsChangeObserverCallback = (data: PayloadManagerChangeData) => void
|
||||
|
||||
export type PayloadsChangeObserver = {
|
||||
types: ContentType[]
|
||||
types: string[]
|
||||
callback: PayloadsChangeObserverCallback
|
||||
priority: number
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { SNUserPrefs, PrefKey, PrefValue, UserPrefsMutator, ItemContent, FillItemContent } from '@standardnotes/models'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ItemManager } from '../Items/ItemManager'
|
||||
import { SNSingletonManager } from '../Singleton/SingletonManager'
|
||||
import { SNSyncService } from '../Sync/SyncService'
|
||||
@@ -12,6 +11,7 @@ import {
|
||||
PreferencesServiceEvent,
|
||||
MutatorClientInterface,
|
||||
} from '@standardnotes/services'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
export class SNPreferencesService
|
||||
extends AbstractService<PreferencesServiceEvent>
|
||||
@@ -32,7 +32,7 @@ export class SNPreferencesService
|
||||
) {
|
||||
super(internalEventBus)
|
||||
|
||||
this.removeItemObserver = itemManager.addObserver(ContentType.UserPrefs, () => {
|
||||
this.removeItemObserver = itemManager.addObserver(ContentType.TYPES.UserPrefs, () => {
|
||||
this.shouldReload = true
|
||||
})
|
||||
|
||||
@@ -58,7 +58,7 @@ export class SNPreferencesService
|
||||
if (stage === ApplicationStage.LoadedDatabase_12) {
|
||||
/** Try to read preferences singleton from storage */
|
||||
this.preferences = this.singletonManager.findSingleton<SNUserPrefs>(
|
||||
ContentType.UserPrefs,
|
||||
ContentType.TYPES.UserPrefs,
|
||||
SNUserPrefs.singletonPredicate,
|
||||
)
|
||||
|
||||
@@ -99,7 +99,7 @@ export class SNPreferencesService
|
||||
const previousRef = this.preferences
|
||||
|
||||
this.preferences = await this.singletonManager.findOrCreateContentTypeSingleton<ItemContent, SNUserPrefs>(
|
||||
ContentType.UserPrefs,
|
||||
ContentType.TYPES.UserPrefs,
|
||||
FillItemContent({}),
|
||||
)
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
FillItemContent,
|
||||
PayloadTimestampDefaults,
|
||||
} from '@standardnotes/models'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
const setupRandomUuid = () => {
|
||||
UuidGenerator.SetGenerator(() => String(Math.random()))
|
||||
@@ -38,7 +38,7 @@ describe('protectionService', () => {
|
||||
return new FileItem(
|
||||
new DecryptedPayload({
|
||||
uuid: String(Math.random()),
|
||||
content_type: ContentType.File,
|
||||
content_type: ContentType.TYPES.File,
|
||||
content: FillItemContent<FileContent>({
|
||||
name: name,
|
||||
protected: isProtected,
|
||||
|
||||
@@ -26,7 +26,7 @@ import {
|
||||
ProtectionsClientInterface,
|
||||
MutatorClientInterface,
|
||||
} from '@standardnotes/services'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
export enum ProtectionEvent {
|
||||
UnprotectedSessionBegan = 'UnprotectedSessionBegan',
|
||||
@@ -182,7 +182,7 @@ export class SNProtectionService extends AbstractService<ProtectionEvent> implem
|
||||
}
|
||||
|
||||
return this.authorizeAction(
|
||||
item.content_type === ContentType.Note
|
||||
item.content_type === ContentType.TYPES.Note
|
||||
? ChallengeReason.AccessProtectedNote
|
||||
: ChallengeReason.AccessProtectedFile,
|
||||
{ fallBackToAccountPassword: true, requireAccountPassword: false, forcePrompt: false },
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { PayloadManager } from './../Payloads/PayloadManager'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ItemManager } from '@Lib/Services/Items/ItemManager'
|
||||
import {
|
||||
DecryptedItemInterface,
|
||||
@@ -21,6 +20,7 @@ import {
|
||||
SingletonManagerInterface,
|
||||
SyncEvent,
|
||||
} from '@standardnotes/services'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
/**
|
||||
* The singleton manager allow consumers to ensure that only 1 item exists of a certain
|
||||
@@ -83,7 +83,7 @@ export class SNSingletonManager extends AbstractService implements SingletonMana
|
||||
* all items keys have been downloaded.
|
||||
*/
|
||||
private addObservers() {
|
||||
this.removeItemObserver = this.itemManager.addObserver(ContentType.Any, ({ inserted, unerrored }) => {
|
||||
this.removeItemObserver = this.itemManager.addObserver(ContentType.TYPES.Any, ({ inserted, unerrored }) => {
|
||||
if (unerrored.length > 0) {
|
||||
this.resolveQueue = this.resolveQueue.concat(unerrored)
|
||||
}
|
||||
@@ -104,7 +104,7 @@ export class SNSingletonManager extends AbstractService implements SingletonMana
|
||||
}
|
||||
|
||||
private validItemsMatchingPredicate<T extends DecryptedItemInterface>(
|
||||
contentType: ContentType,
|
||||
contentType: string,
|
||||
predicate: PredicateInterface<T>,
|
||||
) {
|
||||
return this.itemManager.itemsMatchingPredicate(contentType, predicate)
|
||||
@@ -161,7 +161,7 @@ export class SNSingletonManager extends AbstractService implements SingletonMana
|
||||
}
|
||||
|
||||
public findSingleton<T extends DecryptedItemInterface>(
|
||||
contentType: ContentType,
|
||||
contentType: string,
|
||||
predicate: PredicateInterface<T>,
|
||||
): T | undefined {
|
||||
const matchingItems = this.validItemsMatchingPredicate(contentType, predicate)
|
||||
@@ -174,7 +174,7 @@ export class SNSingletonManager extends AbstractService implements SingletonMana
|
||||
public async findOrCreateContentTypeSingleton<
|
||||
C extends ItemContent = ItemContent,
|
||||
T extends DecryptedItemInterface<C> = DecryptedItemInterface<C>,
|
||||
>(contentType: ContentType, createContent: ItemContent): Promise<T> {
|
||||
>(contentType: string, createContent: ItemContent): Promise<T> {
|
||||
const existingItems = this.itemManager.getItems<T>(contentType)
|
||||
|
||||
if (existingItems.length > 0) {
|
||||
@@ -241,7 +241,7 @@ export class SNSingletonManager extends AbstractService implements SingletonMana
|
||||
public async findOrCreateSingleton<
|
||||
C extends ItemContent = ItemContent,
|
||||
T extends DecryptedItemInterface<C> = DecryptedItemInterface<C>,
|
||||
>(predicate: Predicate<T>, contentType: ContentType, createContent: ItemContent): Promise<T> {
|
||||
>(predicate: Predicate<T>, contentType: string, createContent: ItemContent): Promise<T> {
|
||||
const existingItems = this.itemManager.itemsMatchingPredicate<T>(contentType, predicate)
|
||||
if (existingItems.length > 0) {
|
||||
return existingItems[0]
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { Copy, extendArray, UuidGenerator, Uuids } from '@standardnotes/utils'
|
||||
import { SNLog } from '../../Log'
|
||||
import { isErrorDecryptingParameters, SNRootKey } from '@standardnotes/encryption'
|
||||
@@ -20,6 +19,7 @@ import {
|
||||
LocalStorageEncryptedContextualPayload,
|
||||
FullyFormedTransferPayload,
|
||||
} from '@standardnotes/models'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
/**
|
||||
* The storage service is responsible for persistence of both simple key-values, and payload
|
||||
@@ -140,7 +140,7 @@ export class DiskStorageService extends Services.AbstractService implements Serv
|
||||
const payload = new EncryptedPayload({
|
||||
...wrappedValue,
|
||||
...PayloadTimestampDefaults(),
|
||||
content_type: ContentType.EncryptedStorage,
|
||||
content_type: ContentType.TYPES.EncryptedStorage,
|
||||
})
|
||||
|
||||
const split: Encryption.KeyedDecryptionSplit = key
|
||||
@@ -232,7 +232,7 @@ export class DiskStorageService extends Services.AbstractService implements Serv
|
||||
const payload = new DecryptedPayload({
|
||||
uuid: UuidGenerator.GenerateUuid(),
|
||||
content: valuesToWrap as unknown as ItemContent,
|
||||
content_type: ContentType.EncryptedStorage,
|
||||
content_type: ContentType.TYPES.EncryptedStorage,
|
||||
...PayloadTimestampDefaults(),
|
||||
})
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { ConflictParams, ConflictType } from '@standardnotes/responses'
|
||||
import { log, LoggingDomain } from './../../Logging'
|
||||
import { AccountSyncOperation } from '@Lib/Services/Sync/Account/Operation'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import {
|
||||
Uuids,
|
||||
extendArray,
|
||||
@@ -96,20 +95,21 @@ import {
|
||||
import { CreatePayloadFromRawServerItem } from './Account/Utilities'
|
||||
import { ApplicationSyncOptions } from '@Lib/Application/Options/OptionalOptions'
|
||||
import { DecryptedServerConflictMap, TrustedServerConflictMap } from './Account/ServerConflictMap'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
const DEFAULT_MAJOR_CHANGE_THRESHOLD = 15
|
||||
const INVALID_SESSION_RESPONSE_STATUS = 401
|
||||
|
||||
/** Content types appearing first are always mapped first */
|
||||
const ContentTypeLocalLoadPriorty = [
|
||||
ContentType.ItemsKey,
|
||||
ContentType.KeySystemRootKey,
|
||||
ContentType.KeySystemItemsKey,
|
||||
ContentType.VaultListing,
|
||||
ContentType.TrustedContact,
|
||||
ContentType.UserPrefs,
|
||||
ContentType.Component,
|
||||
ContentType.Theme,
|
||||
ContentType.TYPES.ItemsKey,
|
||||
ContentType.TYPES.KeySystemRootKey,
|
||||
ContentType.TYPES.KeySystemItemsKey,
|
||||
ContentType.TYPES.VaultListing,
|
||||
ContentType.TYPES.TrustedContact,
|
||||
ContentType.TYPES.UserPrefs,
|
||||
ContentType.TYPES.Component,
|
||||
ContentType.TYPES.Theme,
|
||||
]
|
||||
|
||||
/**
|
||||
@@ -1141,7 +1141,7 @@ export class SNSyncService
|
||||
const results = await this.encryptionService.decryptSplit<ItemsKeyContent>(rootKeySplit)
|
||||
|
||||
results.forEach((result) => {
|
||||
if (isDecryptedPayload<ItemsKeyContent>(result) && result.content_type === ContentType.ItemsKey) {
|
||||
if (isDecryptedPayload<ItemsKeyContent>(result) && result.content_type === ContentType.TYPES.ItemsKey) {
|
||||
map[result.uuid] = result
|
||||
}
|
||||
})
|
||||
@@ -1173,7 +1173,7 @@ export class SNSyncService
|
||||
results.forEach((result) => {
|
||||
if (
|
||||
isDecryptedPayload<KeySystemItemsKeyContent>(result) &&
|
||||
result.content_type === ContentType.KeySystemItemsKey
|
||||
result.content_type === ContentType.TYPES.KeySystemItemsKey
|
||||
) {
|
||||
map[result.uuid] = result
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import * as Models from '@standardnotes/models'
|
||||
|
||||
export const createNote = (payload?: Partial<Models.NoteContent>): Models.SNNote => {
|
||||
@@ -6,7 +6,7 @@ export const createNote = (payload?: Partial<Models.NoteContent>): Models.SNNote
|
||||
new Models.DecryptedPayload(
|
||||
{
|
||||
uuid: String(Math.random()),
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: Models.FillItemContent({ ...payload }),
|
||||
...Models.PayloadTimestampDefaults(),
|
||||
},
|
||||
@@ -19,7 +19,7 @@ export const createNoteWithTitle = (title: string) => {
|
||||
return new Models.SNNote(
|
||||
new Models.DecryptedPayload({
|
||||
uuid: String(Math.random()),
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: Models.FillItemContent<Models.NoteContent>({
|
||||
title: title,
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user