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,
|
||||
}),
|
||||
|
||||
@@ -71,7 +71,7 @@ describe('004 protocol operations', function () {
|
||||
it('properly encrypts and decrypts', async function () {
|
||||
const payload = new DecryptedPayload({
|
||||
uuid: '123',
|
||||
content_type: ContentType.ItemsKey,
|
||||
content_type: ContentType.TYPES.ItemsKey,
|
||||
content: FillItemContent({
|
||||
title: 'foo',
|
||||
text: 'bar',
|
||||
@@ -90,7 +90,7 @@ describe('004 protocol operations', function () {
|
||||
it('fails to decrypt non-matching aad', async function () {
|
||||
const payload = new DecryptedPayload({
|
||||
uuid: '123',
|
||||
content_type: ContentType.ItemsKey,
|
||||
content_type: ContentType.TYPES.ItemsKey,
|
||||
content: FillItemContent({
|
||||
title: 'foo',
|
||||
text: 'bar',
|
||||
|
||||
@@ -110,7 +110,7 @@ describe('actions service', () => {
|
||||
|
||||
const payload = new DecryptedPayload({
|
||||
uuid: Utils.generateUuid(),
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: {
|
||||
title: 'Testing',
|
||||
},
|
||||
@@ -170,7 +170,7 @@ describe('actions service', () => {
|
||||
})
|
||||
|
||||
// Extension item
|
||||
const extensionItem = await this.application.mutator.createItem(ContentType.ActionsExtension, this.actionsExtension)
|
||||
const extensionItem = await this.application.mutator.createItem(ContentType.TYPES.ActionsExtension, this.actionsExtension)
|
||||
this.extensionItemUuid = extensionItem.uuid
|
||||
})
|
||||
|
||||
@@ -182,7 +182,7 @@ describe('actions service', () => {
|
||||
})
|
||||
|
||||
it('should get extension items', async function () {
|
||||
await this.application.mutator.createItem(ContentType.Note, {
|
||||
await this.application.mutator.createItem(ContentType.TYPES.Note, {
|
||||
title: 'A simple note',
|
||||
text: 'Standard Notes rocks! lml.',
|
||||
})
|
||||
@@ -191,7 +191,7 @@ describe('actions service', () => {
|
||||
})
|
||||
|
||||
it('should get extensions in context of item', async function () {
|
||||
const noteItem = await this.application.mutator.createItem(ContentType.Note, {
|
||||
const noteItem = await this.application.mutator.createItem(ContentType.TYPES.Note, {
|
||||
title: 'Another note',
|
||||
text: 'Whiskey In The Jar',
|
||||
})
|
||||
@@ -202,7 +202,7 @@ describe('actions service', () => {
|
||||
})
|
||||
|
||||
it('should get actions based on item context', async function () {
|
||||
const tagItem = await this.application.mutator.createItem(ContentType.Tag, {
|
||||
const tagItem = await this.application.mutator.createItem(ContentType.TYPES.Tag, {
|
||||
title: 'Music',
|
||||
})
|
||||
|
||||
@@ -214,7 +214,7 @@ describe('actions service', () => {
|
||||
})
|
||||
|
||||
it('should load extension in context of item', async function () {
|
||||
const noteItem = await this.application.mutator.createItem(ContentType.Note, {
|
||||
const noteItem = await this.application.mutator.createItem(ContentType.TYPES.Note, {
|
||||
title: 'Yet another note',
|
||||
text: 'And all things will end ♫',
|
||||
})
|
||||
@@ -246,7 +246,7 @@ describe('actions service', () => {
|
||||
const sandbox = sinon.createSandbox()
|
||||
|
||||
before(async function () {
|
||||
this.noteItem = await this.application.mutator.createItem(ContentType.Note, {
|
||||
this.noteItem = await this.application.mutator.createItem(ContentType.TYPES.Note, {
|
||||
title: 'Hey',
|
||||
text: 'Welcome To Paradise',
|
||||
})
|
||||
@@ -328,7 +328,7 @@ describe('actions service', () => {
|
||||
const sandbox = sinon.createSandbox()
|
||||
|
||||
before(async function () {
|
||||
this.noteItem = await this.application.mutator.createItem(ContentType.Note, {
|
||||
this.noteItem = await this.application.mutator.createItem(ContentType.TYPES.Note, {
|
||||
title: 'Excuse Me',
|
||||
text: 'Time To Be King 8)',
|
||||
})
|
||||
|
||||
@@ -106,7 +106,7 @@ describe('backups', function () {
|
||||
it('backup file item should have correct fields', async function () {
|
||||
await Factory.createSyncedNote(this.application)
|
||||
let backupData = await this.application.createDecryptedBackupFile()
|
||||
let rawItem = backupData.items.find((i) => i.content_type === ContentType.Note)
|
||||
let rawItem = backupData.items.find((i) => i.content_type === ContentType.TYPES.Note)
|
||||
|
||||
expect(rawItem.fields).to.not.be.ok
|
||||
expect(rawItem.source).to.not.be.ok
|
||||
@@ -125,7 +125,7 @@ describe('backups', function () {
|
||||
})
|
||||
|
||||
backupData = await this.application.createEncryptedBackupFileForAutomatedDesktopBackups()
|
||||
rawItem = backupData.items.find((i) => i.content_type === ContentType.Note)
|
||||
rawItem = backupData.items.find((i) => i.content_type === ContentType.TYPES.Note)
|
||||
|
||||
expect(rawItem.fields).to.not.be.ok
|
||||
expect(rawItem.source).to.not.be.ok
|
||||
@@ -195,21 +195,21 @@ describe('backups', function () {
|
||||
|
||||
it('decrypted backup file should not have itemsKeys', async function () {
|
||||
const backup = await this.application.createDecryptedBackupFile()
|
||||
expect(backup.items.some((item) => item.content_type === ContentType.ItemsKey)).to.be.false
|
||||
expect(backup.items.some((item) => item.content_type === ContentType.TYPES.ItemsKey)).to.be.false
|
||||
})
|
||||
|
||||
it('encrypted backup file should have itemsKeys', async function () {
|
||||
await this.application.addPasscode('passcode')
|
||||
const backup = await this.application.createEncryptedBackupFileForAutomatedDesktopBackups()
|
||||
expect(backup.items.some((item) => item.content_type === ContentType.ItemsKey)).to.be.true
|
||||
expect(backup.items.some((item) => item.content_type === ContentType.TYPES.ItemsKey)).to.be.true
|
||||
})
|
||||
|
||||
it('backup file with no account and no passcode should be decrypted', async function () {
|
||||
const note = await Factory.createSyncedNote(this.application)
|
||||
const backup = await this.application.createDecryptedBackupFile()
|
||||
expect(backup).to.not.haveOwnProperty('keyParams')
|
||||
expect(backup.items.some((item) => item.content_type === ContentType.ItemsKey)).to.be.false
|
||||
expect(backup.items.find((item) => item.content_type === ContentType.Note).uuid).to.equal(note.uuid)
|
||||
expect(backup.items.some((item) => item.content_type === ContentType.TYPES.ItemsKey)).to.be.false
|
||||
expect(backup.items.find((item) => item.content_type === ContentType.TYPES.Note).uuid).to.equal(note.uuid)
|
||||
let error
|
||||
try {
|
||||
await this.application.createEncryptedBackupFileForAutomatedDesktopBackups()
|
||||
|
||||
@@ -41,11 +41,11 @@ describe('payload collections', () => {
|
||||
it('references by content type', async () => {
|
||||
const [notePayload1, tagPayload1] = createRelatedNoteTagPairPayload()
|
||||
const collection = ImmutablePayloadCollection.WithPayloads([notePayload1, tagPayload1])
|
||||
const referencingTags = collection.elementsReferencingElement(notePayload1, ContentType.Tag)
|
||||
const referencingTags = collection.elementsReferencingElement(notePayload1, ContentType.TYPES.Tag)
|
||||
expect(referencingTags.length).to.equal(1)
|
||||
expect(referencingTags[0].uuid).to.equal(tagPayload1.uuid)
|
||||
|
||||
const referencingNotes = collection.elementsReferencingElement(notePayload1, ContentType.Note)
|
||||
const referencingNotes = collection.elementsReferencingElement(notePayload1, ContentType.TYPES.Note)
|
||||
expect(referencingNotes.length).to.equal(0)
|
||||
})
|
||||
|
||||
@@ -78,7 +78,7 @@ describe('payload collections', () => {
|
||||
collection.set([payload])
|
||||
collection.set([payload, copy])
|
||||
|
||||
const sorted = collection.all(ContentType.Note)
|
||||
const sorted = collection.all(ContentType.TYPES.Note)
|
||||
expect(sorted.length).to.equal(1)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -84,7 +84,7 @@ describe('features', () => {
|
||||
expect(application.apiService.getUserFeatures.callCount).to.equal(1)
|
||||
expect(application.mutator.createItem.callCount).to.equal(2)
|
||||
|
||||
const themeItems = application.items.getItems(ContentType.Theme)
|
||||
const themeItems = application.items.getItems(ContentType.TYPES.Theme)
|
||||
const systemThemeCount = 1
|
||||
expect(themeItems).to.have.lengthOf(1 + systemThemeCount)
|
||||
expect(themeItems[1].content).to.containSubset(
|
||||
@@ -97,7 +97,7 @@ describe('features', () => {
|
||||
),
|
||||
)
|
||||
|
||||
const editorItems = application.items.getItems(ContentType.Component)
|
||||
const editorItems = application.items.getItems(ContentType.TYPES.Component)
|
||||
expect(editorItems).to.have.lengthOf(1)
|
||||
expect(editorItems[0].content).to.containSubset(
|
||||
JSON.parse(
|
||||
@@ -118,7 +118,7 @@ describe('features', () => {
|
||||
await application.featuresService.setOnlineRoles([])
|
||||
// Create pre-existing item for theme without all the info
|
||||
await application.mutator.createItem(
|
||||
ContentType.Theme,
|
||||
ContentType.TYPES.Theme,
|
||||
FillItemContent({
|
||||
package_info: {
|
||||
identifier: FeatureIdentifier.MidnightTheme,
|
||||
@@ -130,7 +130,7 @@ describe('features', () => {
|
||||
// Timeout since we don't await for features update
|
||||
await new Promise((resolve) => setTimeout(resolve, 1000))
|
||||
expect(application.mutator.changeComponent.callCount).to.equal(1)
|
||||
const themeItems = application.items.getItems(ContentType.Theme)
|
||||
const themeItems = application.items.getItems(ContentType.TYPES.Theme)
|
||||
expect(themeItems).to.have.lengthOf(1)
|
||||
expect(themeItems[0].content).to.containSubset(
|
||||
JSON.parse(
|
||||
@@ -161,7 +161,7 @@ describe('features', () => {
|
||||
})
|
||||
|
||||
const themeItem = application.items
|
||||
.getItems(ContentType.Theme)
|
||||
.getItems(ContentType.TYPES.Theme)
|
||||
.find((theme) => theme.identifier === midnightThemeFeature.identifier)
|
||||
|
||||
// Wipe roles from initial sync
|
||||
@@ -177,7 +177,7 @@ describe('features', () => {
|
||||
)
|
||||
|
||||
const noTheme = application.items
|
||||
.getItems(ContentType.Theme)
|
||||
.getItems(ContentType.TYPES.Theme)
|
||||
.find((theme) => theme.identifier === midnightThemeFeature.identifier)
|
||||
expect(noTheme).to.not.be.ok
|
||||
})
|
||||
@@ -203,7 +203,7 @@ describe('features', () => {
|
||||
})
|
||||
|
||||
await application.mutator.createItem(
|
||||
ContentType.ExtensionRepo,
|
||||
ContentType.TYPES.ExtensionRepo,
|
||||
FillItemContent({
|
||||
url: `https://extensions.standardnotes.org/${extensionKey}`,
|
||||
}),
|
||||
@@ -225,7 +225,7 @@ describe('features', () => {
|
||||
.callsFake(() => {})
|
||||
const extensionKey = UuidGenerator.GenerateUuid().split('-').join('')
|
||||
await application.mutator.createItem(
|
||||
ContentType.ExtensionRepo,
|
||||
ContentType.TYPES.ExtensionRepo,
|
||||
FillItemContent({
|
||||
url: `https://extensions.standardnotes.org/${extensionKey}`,
|
||||
}),
|
||||
@@ -256,7 +256,7 @@ describe('features', () => {
|
||||
})
|
||||
const extensionKey = UuidGenerator.GenerateUuid().split('-').join('')
|
||||
await application.mutator.createItem(
|
||||
ContentType.ExtensionRepo,
|
||||
ContentType.TYPES.ExtensionRepo,
|
||||
FillItemContent({
|
||||
url: `https://extensions.standardnotes.org/${extensionKey}`,
|
||||
}),
|
||||
@@ -282,7 +282,7 @@ describe('features', () => {
|
||||
expect(await application.settings.getDoesSensitiveSettingExist(SettingName.ExtensionKey)).to.equal(false)
|
||||
const extensionKey = UuidGenerator.GenerateUuid().split('-').join('')
|
||||
const promise = new Promise((resolve) => {
|
||||
application.streamItems(ContentType.ExtensionRepo, ({ changed }) => {
|
||||
application.streamItems(ContentType.TYPES.ExtensionRepo, ({ changed }) => {
|
||||
for (const item of changed) {
|
||||
if (item.content.migratedToUserSetting) {
|
||||
resolve()
|
||||
@@ -291,7 +291,7 @@ describe('features', () => {
|
||||
})
|
||||
})
|
||||
await application.mutator.createItem(
|
||||
ContentType.ExtensionRepo,
|
||||
ContentType.TYPES.ExtensionRepo,
|
||||
FillItemContent({
|
||||
url: `https://extensions.standardnotes.org/${extensionKey}`,
|
||||
}),
|
||||
@@ -305,7 +305,7 @@ describe('features', () => {
|
||||
application = await Factory.signOutApplicationAndReturnNew(application)
|
||||
const extensionKey = UuidGenerator.GenerateUuid().split('-').join('')
|
||||
await application.mutator.createItem(
|
||||
ContentType.ExtensionRepo,
|
||||
ContentType.TYPES.ExtensionRepo,
|
||||
FillItemContent({
|
||||
url: `https://extensions.standardnotes.org/${extensionKey}`,
|
||||
}),
|
||||
|
||||
@@ -97,7 +97,7 @@ describe('history manager', () => {
|
||||
it('creating new item and making 1 change should create 0 revisions', async function () {
|
||||
const context = await Factory.createAppContext()
|
||||
await context.launch()
|
||||
const item = await context.application.items.createTemplateItem(ContentType.Note, {
|
||||
const item = await context.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
references: [],
|
||||
})
|
||||
await context.application.mutator.insertItem(item)
|
||||
|
||||
@@ -9,7 +9,7 @@ describe('item', () => {
|
||||
this.createBarePayload = () => {
|
||||
return new DecryptedPayload({
|
||||
uuid: '123',
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: {
|
||||
title: 'hello',
|
||||
},
|
||||
@@ -30,7 +30,7 @@ describe('item', () => {
|
||||
return new SNTag(
|
||||
new DecryptedPayload({
|
||||
uuid: Factory.generateUuidish(),
|
||||
content_type: ContentType.Tag,
|
||||
content_type: ContentType.TYPES.Tag,
|
||||
content: {
|
||||
title: 'thoughts',
|
||||
references: references,
|
||||
|
||||
@@ -25,7 +25,7 @@ describe('item manager', function () {
|
||||
})
|
||||
|
||||
const createNote = async () => {
|
||||
return application.mutator.createItem(ContentType.Note, {
|
||||
return application.mutator.createItem(ContentType.TYPES.Note, {
|
||||
title: 'hello',
|
||||
text: 'world',
|
||||
})
|
||||
@@ -38,7 +38,7 @@ describe('item manager', function () {
|
||||
content_type: note.content_type,
|
||||
}
|
||||
})
|
||||
return application.mutator.createItem(ContentType.Tag, {
|
||||
return application.mutator.createItem(ContentType.TYPES.Tag, {
|
||||
title: 'thoughts',
|
||||
references: references,
|
||||
})
|
||||
@@ -110,7 +110,7 @@ describe('item manager', function () {
|
||||
|
||||
it('observer', async function () {
|
||||
const observed = []
|
||||
application.items.addObserver(ContentType.Any, ({ changed, inserted, removed, source, sourceKey }) => {
|
||||
application.items.addObserver(ContentType.TYPES.Any, ({ changed, inserted, removed, source, sourceKey }) => {
|
||||
observed.push({ changed, inserted, removed, source, sourceKey })
|
||||
})
|
||||
const note = await createNote()
|
||||
@@ -184,7 +184,7 @@ describe('item manager', function () {
|
||||
|
||||
it('remove all items from memory', async function () {
|
||||
const observed = []
|
||||
application.items.addObserver(ContentType.Any, ({ changed, inserted, removed, ignored }) => {
|
||||
application.items.addObserver(ContentType.TYPES.Any, ({ changed, inserted, removed, ignored }) => {
|
||||
observed.push({ changed, inserted, removed, ignored })
|
||||
})
|
||||
await createNote()
|
||||
@@ -197,7 +197,7 @@ describe('item manager', function () {
|
||||
|
||||
it('remove item locally', async function () {
|
||||
const observed = []
|
||||
application.items.addObserver(ContentType.Any, ({ changed, inserted, removed, ignored }) => {
|
||||
application.items.addObserver(ContentType.TYPES.Any, ({ changed, inserted, removed, ignored }) => {
|
||||
observed.push({ changed, inserted, removed, ignored })
|
||||
})
|
||||
const note = await createNote()
|
||||
@@ -220,7 +220,7 @@ describe('item manager', function () {
|
||||
const changedTitle = 'changed title'
|
||||
let didEmit = false
|
||||
let latestVersion
|
||||
application.items.addObserver(ContentType.Note, ({ changed, inserted }) => {
|
||||
application.items.addObserver(ContentType.TYPES.Note, ({ changed, inserted }) => {
|
||||
const all = changed.concat(inserted)
|
||||
if (!didEmit) {
|
||||
didEmit = true
|
||||
|
||||
@@ -272,7 +272,7 @@ describe('key recovery service', function () {
|
||||
const result = await contextB.application.changePassword(contextA.password, newPassword)
|
||||
|
||||
expect(result.error).to.not.be.ok
|
||||
expect(contextB.application.items.getAnyItems(ContentType.ItemsKey).length).to.equal(2)
|
||||
expect(contextB.application.items.getAnyItems(ContentType.TYPES.ItemsKey).length).to.equal(2)
|
||||
|
||||
const newItemsKey = contextB.application.items
|
||||
.getDisplayableItemsKeys()
|
||||
@@ -288,7 +288,7 @@ describe('key recovery service', function () {
|
||||
await recoveryPromise
|
||||
|
||||
/** Same previously errored key should now no longer be errored, */
|
||||
expect(contextA.application.items.getAnyItems(ContentType.ItemsKey).length).to.equal(2)
|
||||
expect(contextA.application.items.getAnyItems(ContentType.TYPES.ItemsKey).length).to.equal(2)
|
||||
for (const key of contextA.application.itemManager.getDisplayableItemsKeys()) {
|
||||
expect(key.errorDecrypting).to.not.be.ok
|
||||
}
|
||||
@@ -321,7 +321,7 @@ describe('key recovery service', function () {
|
||||
password: contextA.password,
|
||||
})
|
||||
|
||||
expect(appA.items.getItems(ContentType.ItemsKey).length).to.equal(1)
|
||||
expect(appA.items.getItems(ContentType.TYPES.ItemsKey).length).to.equal(1)
|
||||
|
||||
/** Create simultaneous appB signed into same account */
|
||||
const appB = await Factory.createApplicationWithFakeCrypto('another-namespace')
|
||||
|
||||
@@ -33,10 +33,10 @@ describe('keys', function () {
|
||||
})
|
||||
|
||||
it('validates content types requiring root encryption', function () {
|
||||
expect(ContentTypeUsesRootKeyEncryption(ContentType.ItemsKey)).to.equal(true)
|
||||
expect(ContentTypeUsesRootKeyEncryption(ContentType.EncryptedStorage)).to.equal(true)
|
||||
expect(ContentTypeUsesRootKeyEncryption(ContentType.Item)).to.equal(false)
|
||||
expect(ContentTypeUsesRootKeyEncryption(ContentType.Note)).to.equal(false)
|
||||
expect(ContentTypeUsesRootKeyEncryption(ContentType.TYPES.ItemsKey)).to.equal(true)
|
||||
expect(ContentTypeUsesRootKeyEncryption(ContentType.TYPES.EncryptedStorage)).to.equal(true)
|
||||
expect(ContentTypeUsesRootKeyEncryption(ContentType.TYPES.Item)).to.equal(false)
|
||||
expect(ContentTypeUsesRootKeyEncryption(ContentType.TYPES.Note)).to.equal(false)
|
||||
})
|
||||
|
||||
it('generating export params with no account or passcode should produce encrypted payload', async function () {
|
||||
@@ -126,7 +126,7 @@ describe('keys', function () {
|
||||
await this.application.sync.sync()
|
||||
|
||||
const rawPayloads = await this.application.diskStorageService.getAllRawPayloads()
|
||||
const rawNotePayload = rawPayloads.find((r) => r.content_type === ContentType.Note)
|
||||
const rawNotePayload = rawPayloads.find((r) => r.content_type === ContentType.TYPES.Note)
|
||||
expect(typeof rawNotePayload.content).to.equal('string')
|
||||
})
|
||||
|
||||
@@ -143,7 +143,7 @@ describe('keys', function () {
|
||||
it('should use items key for encryption of note', async function () {
|
||||
const notePayload = Factory.createNotePayload()
|
||||
const keyToUse = await this.application.encryptionService.itemsEncryption.keyToUseForItemEncryption(notePayload)
|
||||
expect(keyToUse.content_type).to.equal(ContentType.ItemsKey)
|
||||
expect(keyToUse.content_type).to.equal(ContentType.TYPES.ItemsKey)
|
||||
})
|
||||
|
||||
it('encrypting an item should associate an items key to it', async function () {
|
||||
@@ -848,7 +848,7 @@ describe('keys', function () {
|
||||
password: this.password,
|
||||
})
|
||||
await Factory.createSyncedNote(this.application)
|
||||
const itemsKey = this.application.items.getItems(ContentType.ItemsKey)[0]
|
||||
const itemsKey = this.application.items.getItems(ContentType.TYPES.ItemsKey)[0]
|
||||
|
||||
/** Create another client and sign into account */
|
||||
await Factory.loginToApplication({
|
||||
@@ -862,7 +862,7 @@ describe('keys', function () {
|
||||
expect(defaultKeys.length).to.equal(1)
|
||||
|
||||
const rawPayloads = await otherClient.diskStorageService.getAllRawPayloads()
|
||||
const notePayload = rawPayloads.find((p) => p.content_type === ContentType.Note)
|
||||
const notePayload = rawPayloads.find((p) => p.content_type === ContentType.TYPES.Note)
|
||||
|
||||
expect(notePayload.items_key_id).to.equal(itemsKey.uuid)
|
||||
})
|
||||
|
||||
@@ -415,7 +415,7 @@ export class AppContext {
|
||||
if (!didCompleteRelevantSync) {
|
||||
if (data?.savedPayloads) {
|
||||
const matching = data.savedPayloads.find((p) => {
|
||||
return p.content_type === ContentType.UserPrefs
|
||||
return p.content_type === ContentType.TYPES.UserPrefs
|
||||
})
|
||||
if (matching) {
|
||||
didCompleteRelevantSync = true
|
||||
@@ -510,7 +510,7 @@ export class AppContext {
|
||||
}
|
||||
|
||||
spyOnChangedItems(callback) {
|
||||
this.application.items.addObserver(ContentType.Any, ({ changed, unerrored }) => {
|
||||
this.application.items.addObserver(ContentType.TYPES.Any, ({ changed, unerrored }) => {
|
||||
callback([...changed, ...unerrored])
|
||||
})
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ export function createItemParams(contentType) {
|
||||
export function createNoteParams({ title, text, dirty = true } = {}) {
|
||||
const params = {
|
||||
uuid: Utils.generateUuid(),
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
dirty: dirty,
|
||||
dirtyIndex: dirty ? getIncrementedDirtyIndex() : undefined,
|
||||
content: FillItemContent({
|
||||
@@ -34,7 +34,7 @@ export function createNoteParams({ title, text, dirty = true } = {}) {
|
||||
export function createTagParams({ title, dirty = true, uuid = undefined } = {}) {
|
||||
const params = {
|
||||
uuid: uuid || Utils.generateUuid(),
|
||||
content_type: ContentType.Tag,
|
||||
content_type: ContentType.TYPES.Tag,
|
||||
dirty: dirty,
|
||||
dirtyIndex: dirty ? getIncrementedDirtyIndex() : undefined,
|
||||
content: FillItemContent({
|
||||
|
||||
@@ -99,7 +99,7 @@ describe('migrations', () => {
|
||||
const noDistractionItem = CreateDecryptedItemFromPayload(
|
||||
new DecryptedPayload({
|
||||
uuid: '123',
|
||||
content_type: ContentType.Theme,
|
||||
content_type: ContentType.TYPES.Theme,
|
||||
content: FillItemContent({
|
||||
package_info: {
|
||||
identifier: 'org.standardnotes.theme-no-distraction',
|
||||
@@ -111,14 +111,14 @@ describe('migrations', () => {
|
||||
await application.sync.sync()
|
||||
|
||||
const systemThemeCount = 1
|
||||
expect(application.items.getItems(ContentType.Theme).length).to.equal(1 + systemThemeCount)
|
||||
expect(application.items.getItems(ContentType.TYPES.Theme).length).to.equal(1 + systemThemeCount)
|
||||
|
||||
/** Run migration */
|
||||
const migration = new Migration2_42_0(application.migrationService.services)
|
||||
await migration.handleStage(ApplicationStage.FullSyncCompleted_13)
|
||||
await application.sync.sync()
|
||||
|
||||
expect(application.items.getItems(ContentType.Theme).length).to.equal(systemThemeCount)
|
||||
expect(application.items.getItems(ContentType.TYPES.Theme).length).to.equal(systemThemeCount)
|
||||
|
||||
await Factory.safeDeinit(application)
|
||||
})
|
||||
|
||||
@@ -361,11 +361,11 @@ describe('app models', () => {
|
||||
|
||||
it('maintains editor reference when duplicating note', async function () {
|
||||
const editor = await this.application.mutator.createItem(
|
||||
ContentType.Component,
|
||||
ContentType.TYPES.Component,
|
||||
{ area: ComponentArea.Editor, package_info: { identifier: 'foo-editor' } },
|
||||
true,
|
||||
)
|
||||
const note = await Factory.insertItemWithOverride(this.application, ContentType.Note, {
|
||||
const note = await Factory.insertItemWithOverride(this.application, ContentType.TYPES.Note, {
|
||||
editorIdentifier: 'foo-editor',
|
||||
})
|
||||
|
||||
|
||||
@@ -73,8 +73,8 @@ describe('importing', function () {
|
||||
|
||||
await application.mutator.emitItemsFromPayloads([notePayload, tagPayload], PayloadEmitSource.LocalChanged)
|
||||
expectedItemCount += 2
|
||||
const note = application.itemManager.getItems([ContentType.Note])[0]
|
||||
const tag = application.itemManager.getItems([ContentType.Tag])[0]
|
||||
const note = application.itemManager.getItems([ContentType.TYPES.Note])[0]
|
||||
const tag = application.itemManager.getItems([ContentType.TYPES.Tag])[0]
|
||||
|
||||
expect(tag.content.references.length).to.equal(1)
|
||||
expect(tag.noteCount).to.equal(1)
|
||||
@@ -352,8 +352,8 @@ describe('importing', function () {
|
||||
|
||||
const storedPayloads = await application.diskStorageService.getAllRawPayloads()
|
||||
expect(application.itemManager.items.length).to.equal(storedPayloads.length)
|
||||
const notes = storedPayloads.filter((p) => p.content_type === ContentType.Note)
|
||||
const itemsKeys = storedPayloads.filter((p) => p.content_type === ContentType.ItemsKey)
|
||||
const notes = storedPayloads.filter((p) => p.content_type === ContentType.TYPES.Note)
|
||||
const itemsKeys = storedPayloads.filter((p) => p.content_type === ContentType.TYPES.ItemsKey)
|
||||
expect(notes.length).to.equal(1)
|
||||
expect(itemsKeys.length).to.equal(1)
|
||||
})
|
||||
@@ -449,7 +449,7 @@ describe('importing', function () {
|
||||
version: oldVersion,
|
||||
})
|
||||
|
||||
const noteItem = await application.mutator.createItem(ContentType.Note, {
|
||||
const noteItem = await application.mutator.createItem(ContentType.TYPES.Note, {
|
||||
title: 'Encrypted note',
|
||||
text: 'On protocol version 003.',
|
||||
})
|
||||
@@ -530,7 +530,7 @@ describe('importing', function () {
|
||||
password: password,
|
||||
})
|
||||
|
||||
const noteItem = await application.mutator.createItem(ContentType.Note, {
|
||||
const noteItem = await application.mutator.createItem(ContentType.TYPES.Note, {
|
||||
title: 'Encrypted note',
|
||||
text: 'On protocol version 004.',
|
||||
})
|
||||
@@ -560,7 +560,7 @@ describe('importing', function () {
|
||||
password: password,
|
||||
})
|
||||
|
||||
const noteItem = await application.mutator.createItem(ContentType.Note, {
|
||||
const noteItem = await application.mutator.createItem(ContentType.TYPES.Note, {
|
||||
title: 'This is a valid, encrypted note',
|
||||
text: 'On protocol version 004.',
|
||||
})
|
||||
@@ -598,7 +598,7 @@ describe('importing', function () {
|
||||
version: oldVersion,
|
||||
})
|
||||
|
||||
await application.mutator.createItem(ContentType.Note, {
|
||||
await application.mutator.createItem(ContentType.TYPES.Note, {
|
||||
title: 'Encrypted note',
|
||||
text: 'On protocol version 003.',
|
||||
})
|
||||
@@ -635,7 +635,7 @@ describe('importing', function () {
|
||||
password: password,
|
||||
})
|
||||
|
||||
await application.mutator.createItem(ContentType.Note, {
|
||||
await application.mutator.createItem(ContentType.TYPES.Note, {
|
||||
title: 'This is a valid, encrypted note',
|
||||
text: 'On protocol version 004.',
|
||||
})
|
||||
@@ -666,7 +666,7 @@ describe('importing', function () {
|
||||
password: password,
|
||||
})
|
||||
|
||||
await application.mutator.createItem(ContentType.Note, {
|
||||
await application.mutator.createItem(ContentType.TYPES.Note, {
|
||||
title: 'Encrypted note',
|
||||
text: 'On protocol version 004.',
|
||||
})
|
||||
@@ -691,13 +691,13 @@ describe('importing', function () {
|
||||
})
|
||||
Factory.handlePasswordChallenges(application, password)
|
||||
|
||||
await application.mutator.createItem(ContentType.Note, {
|
||||
await application.mutator.createItem(ContentType.TYPES.Note, {
|
||||
title: 'Encrypted note',
|
||||
text: 'On protocol version 004.',
|
||||
})
|
||||
|
||||
const backupData = await application.createEncryptedBackupFileForAutomatedDesktopBackups()
|
||||
backupData.items = backupData.items.filter((payload) => payload.content_type !== ContentType.ItemsKey)
|
||||
backupData.items = backupData.items.filter((payload) => payload.content_type !== ContentType.TYPES.ItemsKey)
|
||||
|
||||
await Factory.safeDeinit(application)
|
||||
application = await Factory.createInitAppWithFakeCrypto()
|
||||
|
||||
@@ -118,7 +118,7 @@ describe('model manager mapping', () => {
|
||||
await this.application.mutator.emitItemsFromPayloads([payload], PayloadEmitSource.LocalChanged)
|
||||
const item = this.application.itemManager.items[0]
|
||||
return new Promise((resolve) => {
|
||||
this.application.itemManager.addObserver(ContentType.Any, ({ changed }) => {
|
||||
this.application.itemManager.addObserver(ContentType.TYPES.Any, ({ changed }) => {
|
||||
expect(changed[0].uuid === item.uuid)
|
||||
resolve()
|
||||
})
|
||||
|
||||
@@ -26,14 +26,14 @@ describe('notes and tags', () => {
|
||||
it('uses proper class for note', async function () {
|
||||
const payload = Factory.createNotePayload()
|
||||
await this.application.mutator.emitItemFromPayload(payload, PayloadEmitSource.LocalChanged)
|
||||
const note = this.application.itemManager.getItems([ContentType.Note])[0]
|
||||
const note = this.application.itemManager.getItems([ContentType.TYPES.Note])[0]
|
||||
expect(note.constructor === SNNote).to.equal(true)
|
||||
})
|
||||
|
||||
it('properly constructs syncing params', async function () {
|
||||
const title = 'Foo'
|
||||
const text = 'Bar'
|
||||
const note = await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
const note = await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title,
|
||||
text,
|
||||
})
|
||||
@@ -41,7 +41,7 @@ describe('notes and tags', () => {
|
||||
expect(note.content.title).to.equal(title)
|
||||
expect(note.content.text).to.equal(text)
|
||||
|
||||
const tag = await this.application.items.createTemplateItem(ContentType.Tag, {
|
||||
const tag = await this.application.items.createTemplateItem(ContentType.TYPES.Tag, {
|
||||
title,
|
||||
})
|
||||
|
||||
@@ -74,8 +74,8 @@ describe('notes and tags', () => {
|
||||
})
|
||||
|
||||
await this.application.mutator.emitItemsFromPayloads([mutatedNote, mutatedTag], PayloadEmitSource.LocalChanged)
|
||||
const note = this.application.itemManager.getItems([ContentType.Note])[0]
|
||||
const tag = this.application.itemManager.getItems([ContentType.Tag])[0]
|
||||
const note = this.application.itemManager.getItems([ContentType.TYPES.Note])[0]
|
||||
const tag = this.application.itemManager.getItems([ContentType.TYPES.Tag])[0]
|
||||
|
||||
expect(note.content.references.length).to.equal(1)
|
||||
expect(this.application.itemManager.itemsReferencingItem(tag).length).to.equal(1)
|
||||
@@ -131,8 +131,8 @@ describe('notes and tags', () => {
|
||||
const tagPayload = pair[1]
|
||||
|
||||
await this.application.mutator.emitItemsFromPayloads(pair, PayloadEmitSource.LocalChanged)
|
||||
let note = this.application.itemManager.getItems([ContentType.Note])[0]
|
||||
let tag = this.application.itemManager.getItems([ContentType.Tag])[0]
|
||||
let note = this.application.itemManager.getItems([ContentType.TYPES.Note])[0]
|
||||
let tag = this.application.itemManager.getItems([ContentType.TYPES.Tag])[0]
|
||||
|
||||
expect(note.content.references.length).to.equal(0)
|
||||
expect(tag.content.references.length).to.equal(1)
|
||||
@@ -178,8 +178,8 @@ describe('notes and tags', () => {
|
||||
const tagPayload = pair[1]
|
||||
|
||||
await this.application.mutator.emitItemsFromPayloads([notePayload, tagPayload], PayloadEmitSource.LocalChanged)
|
||||
const note = this.application.itemManager.getItems([ContentType.Note])[0]
|
||||
let tag = this.application.itemManager.getItems([ContentType.Tag])[0]
|
||||
const note = this.application.itemManager.getItems([ContentType.TYPES.Note])[0]
|
||||
let tag = this.application.itemManager.getItems([ContentType.TYPES.Tag])[0]
|
||||
|
||||
expect(note.content.references.length).to.equal(0)
|
||||
expect(tag.content.references.length).to.equal(1)
|
||||
@@ -233,7 +233,7 @@ describe('notes and tags', () => {
|
||||
const notePayload = pair[0]
|
||||
const tagPayload = pair[1]
|
||||
await this.application.mutator.emitItemsFromPayloads([notePayload, tagPayload], PayloadEmitSource.LocalChanged)
|
||||
const note = this.application.itemManager.getItems([ContentType.Note])[0]
|
||||
const note = this.application.itemManager.getItems([ContentType.TYPES.Note])[0]
|
||||
const duplicateNote = await this.application.mutator.duplicateItem(note, true)
|
||||
expect(note.uuid).to.not.equal(duplicateNote.uuid)
|
||||
|
||||
@@ -247,8 +247,8 @@ describe('notes and tags', () => {
|
||||
const notePayload = pair[0]
|
||||
const tagPayload = pair[1]
|
||||
await this.application.mutator.emitItemsFromPayloads([notePayload, tagPayload], PayloadEmitSource.LocalChanged)
|
||||
const note = this.application.itemManager.getItems([ContentType.Note])[0]
|
||||
let tag = this.application.itemManager.getItems([ContentType.Tag])[0]
|
||||
const note = this.application.itemManager.getItems([ContentType.TYPES.Note])[0]
|
||||
let tag = this.application.itemManager.getItems([ContentType.TYPES.Tag])[0]
|
||||
|
||||
expect(tag.content.references.length).to.equal(1)
|
||||
expect(tag.noteCount).to.equal(1)
|
||||
@@ -264,7 +264,7 @@ describe('notes and tags', () => {
|
||||
it('modifying item content should not modify payload content', async function () {
|
||||
const notePayload = Factory.createNotePayload()
|
||||
await this.application.mutator.emitItemsFromPayloads([notePayload], PayloadEmitSource.LocalChanged)
|
||||
let note = this.application.itemManager.getItems([ContentType.Note])[0]
|
||||
let note = this.application.itemManager.getItems([ContentType.TYPES.Note])[0]
|
||||
note = await this.application.changeAndSaveItem(
|
||||
note,
|
||||
(mutator) => {
|
||||
@@ -286,8 +286,8 @@ describe('notes and tags', () => {
|
||||
const tagPayload = pair[1]
|
||||
|
||||
await this.application.mutator.emitItemsFromPayloads([notePayload, tagPayload], PayloadEmitSource.LocalChanged)
|
||||
let note = this.application.itemManager.getItems([ContentType.Note])[0]
|
||||
let tag = this.application.itemManager.getItems([ContentType.Tag])[0]
|
||||
let note = this.application.itemManager.getItems([ContentType.TYPES.Note])[0]
|
||||
let tag = this.application.itemManager.getItems([ContentType.TYPES.Tag])[0]
|
||||
|
||||
await this.application.syncService.sync(syncOptions)
|
||||
await this.application.mutator.setItemToBeDeleted(tag)
|
||||
@@ -302,7 +302,7 @@ describe('notes and tags', () => {
|
||||
await Promise.all(
|
||||
['Y', 'Z', 'A', 'B'].map(async (title) => {
|
||||
return this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, { title }),
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, { title }),
|
||||
)
|
||||
}),
|
||||
)
|
||||
@@ -316,7 +316,7 @@ describe('notes and tags', () => {
|
||||
})
|
||||
|
||||
it('setting a note dirty should collapse its properties into content', async function () {
|
||||
let note = await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
let note = await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'Foo',
|
||||
})
|
||||
await this.application.mutator.insertItem(note)
|
||||
@@ -339,7 +339,7 @@ describe('notes and tags', () => {
|
||||
mutator.e2ePendingRefactor_addItemAsRelationship(taggedNote)
|
||||
})
|
||||
await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'A',
|
||||
}),
|
||||
)
|
||||
@@ -379,7 +379,7 @@ describe('notes and tags', () => {
|
||||
await Promise.all(
|
||||
['Y', 'Z', 'A', 'B'].map(async (title) => {
|
||||
return this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title,
|
||||
}),
|
||||
)
|
||||
@@ -413,17 +413,17 @@ describe('notes and tags', () => {
|
||||
describe('Smart views', function () {
|
||||
it('"title", "startsWith", "Foo"', async function () {
|
||||
const note = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'Foo 🎲',
|
||||
}),
|
||||
)
|
||||
await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'Not Foo 🎲',
|
||||
}),
|
||||
)
|
||||
const view = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.SmartView, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.SmartView, {
|
||||
title: 'Foo Notes',
|
||||
predicate: {
|
||||
keypath: 'title',
|
||||
@@ -447,7 +447,7 @@ describe('notes and tags', () => {
|
||||
|
||||
it('"pinned", "=", true', async function () {
|
||||
const note = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'A',
|
||||
}),
|
||||
)
|
||||
@@ -455,13 +455,13 @@ describe('notes and tags', () => {
|
||||
mutator.pinned = true
|
||||
})
|
||||
await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'B',
|
||||
pinned: false,
|
||||
}),
|
||||
)
|
||||
const view = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.SmartView, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.SmartView, {
|
||||
title: 'Pinned',
|
||||
predicate: {
|
||||
keypath: 'pinned',
|
||||
@@ -485,7 +485,7 @@ describe('notes and tags', () => {
|
||||
|
||||
it('"pinned", "=", false', async function () {
|
||||
const pinnedNote = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'A',
|
||||
}),
|
||||
)
|
||||
@@ -493,12 +493,12 @@ describe('notes and tags', () => {
|
||||
mutator.pinned = true
|
||||
})
|
||||
const unpinnedNote = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'B',
|
||||
}),
|
||||
)
|
||||
const view = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.SmartView, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.SmartView, {
|
||||
title: 'Not pinned',
|
||||
predicate: {
|
||||
keypath: 'pinned',
|
||||
@@ -522,19 +522,19 @@ describe('notes and tags', () => {
|
||||
|
||||
it('"text.length", ">", 500', async function () {
|
||||
const longNote = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'A',
|
||||
text: Array(501).fill(0).join(''),
|
||||
}),
|
||||
)
|
||||
await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'B',
|
||||
text: 'b',
|
||||
}),
|
||||
)
|
||||
const view = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.SmartView, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.SmartView, {
|
||||
title: 'Long',
|
||||
predicate: {
|
||||
keypath: 'text.length',
|
||||
@@ -563,7 +563,7 @@ describe('notes and tags', () => {
|
||||
})
|
||||
|
||||
const recentNote = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'A',
|
||||
}),
|
||||
true,
|
||||
@@ -572,7 +572,7 @@ describe('notes and tags', () => {
|
||||
await this.application.sync.sync()
|
||||
|
||||
const olderNote = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'B',
|
||||
text: 'b',
|
||||
}),
|
||||
@@ -584,13 +584,13 @@ describe('notes and tags', () => {
|
||||
|
||||
/** Create an unsynced note which shouldn't get an updated_at */
|
||||
await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'B',
|
||||
text: 'b',
|
||||
}),
|
||||
)
|
||||
const view = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.SmartView, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.SmartView, {
|
||||
title: 'One day ago',
|
||||
predicate: {
|
||||
keypath: 'serverUpdatedAt',
|
||||
@@ -614,7 +614,7 @@ describe('notes and tags', () => {
|
||||
|
||||
it('"tags.length", "=", 0', async function () {
|
||||
const untaggedNote = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'A',
|
||||
}),
|
||||
)
|
||||
@@ -625,7 +625,7 @@ describe('notes and tags', () => {
|
||||
})
|
||||
|
||||
const view = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.SmartView, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.SmartView, {
|
||||
title: 'Untagged',
|
||||
predicate: {
|
||||
keypath: 'tags.length',
|
||||
@@ -653,13 +653,13 @@ describe('notes and tags', () => {
|
||||
mutator.e2ePendingRefactor_addItemAsRelationship(taggedNote)
|
||||
})
|
||||
await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'A',
|
||||
}),
|
||||
)
|
||||
|
||||
const view = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.SmartView, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.SmartView, {
|
||||
title: 'B-tags',
|
||||
predicate: {
|
||||
keypath: 'tags',
|
||||
@@ -688,7 +688,7 @@ describe('notes and tags', () => {
|
||||
})
|
||||
|
||||
const pinnedNote = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'A',
|
||||
}),
|
||||
)
|
||||
@@ -697,7 +697,7 @@ describe('notes and tags', () => {
|
||||
})
|
||||
|
||||
const lockedNote = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'A',
|
||||
}),
|
||||
)
|
||||
@@ -706,7 +706,7 @@ describe('notes and tags', () => {
|
||||
})
|
||||
|
||||
const view = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.SmartView, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.SmartView, {
|
||||
title: 'Pinned & Locked',
|
||||
predicate: {
|
||||
operator: 'and',
|
||||
@@ -736,7 +736,7 @@ describe('notes and tags', () => {
|
||||
})
|
||||
|
||||
const pinnedNote = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'A',
|
||||
}),
|
||||
)
|
||||
@@ -745,7 +745,7 @@ describe('notes and tags', () => {
|
||||
})
|
||||
|
||||
const pinnedAndProtectedNote = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'A',
|
||||
}),
|
||||
)
|
||||
@@ -755,13 +755,13 @@ describe('notes and tags', () => {
|
||||
})
|
||||
|
||||
await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'A',
|
||||
}),
|
||||
)
|
||||
|
||||
const view = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.SmartView, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.SmartView, {
|
||||
title: 'Protected or Pinned',
|
||||
predicate: {
|
||||
operator: 'or',
|
||||
|
||||
@@ -20,7 +20,7 @@ describe('mapping performance', () => {
|
||||
for (let i = 0; i < tagCount; i++) {
|
||||
var tag = {
|
||||
uuid: UuidGenerator.GenerateUuid(),
|
||||
content_type: ContentType.Tag,
|
||||
content_type: ContentType.TYPES.Tag,
|
||||
content: {
|
||||
title: `${Math.random()}`,
|
||||
references: [],
|
||||
@@ -31,7 +31,7 @@ describe('mapping performance', () => {
|
||||
for (let i = 0; i < noteCount; i++) {
|
||||
const note = {
|
||||
uuid: UuidGenerator.GenerateUuid(),
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: {
|
||||
title: `${Math.random()}`,
|
||||
text: `${Math.random()}`,
|
||||
@@ -40,7 +40,7 @@ describe('mapping performance', () => {
|
||||
}
|
||||
const randomTag = Factory.randomArrayValue(tags)
|
||||
randomTag.content.references.push({
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
uuid: note.uuid,
|
||||
})
|
||||
notes.push(note)
|
||||
@@ -65,7 +65,7 @@ describe('mapping performance', () => {
|
||||
const expectedRunTime = 3 // seconds
|
||||
expect(seconds).to.be.at.most(expectedRunTime)
|
||||
|
||||
for (const note of application.itemManager.getItems(ContentType.Note)) {
|
||||
for (const note of application.itemManager.getItems(ContentType.TYPES.Note)) {
|
||||
expect(application.itemManager.itemsReferencingItem(note).length).to.be.above(0)
|
||||
}
|
||||
await Factory.safeDeinit(application)
|
||||
@@ -84,7 +84,7 @@ describe('mapping performance', () => {
|
||||
|
||||
const tag = {
|
||||
uuid: UuidGenerator.GenerateUuid(),
|
||||
content_type: ContentType.Tag,
|
||||
content_type: ContentType.TYPES.Tag,
|
||||
content: {
|
||||
title: `${Math.random()}`,
|
||||
references: [],
|
||||
@@ -94,7 +94,7 @@ describe('mapping performance', () => {
|
||||
for (let i = 0; i < noteCount; i++) {
|
||||
const note = {
|
||||
uuid: UuidGenerator.GenerateUuid(),
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: {
|
||||
title: `${Math.random()}`,
|
||||
text: `${Math.random()}`,
|
||||
@@ -103,7 +103,7 @@ describe('mapping performance', () => {
|
||||
}
|
||||
|
||||
tag.content.references.push({
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
uuid: note.uuid,
|
||||
})
|
||||
notes.push(note)
|
||||
@@ -131,8 +131,8 @@ describe('mapping performance', () => {
|
||||
const MAX_RUN_TIME = 15.0 // seconds
|
||||
expect(seconds).to.be.at.most(MAX_RUN_TIME)
|
||||
|
||||
application.itemManager.getItems(ContentType.Tag)[0]
|
||||
for (const note of application.itemManager.getItems(ContentType.Note)) {
|
||||
application.itemManager.getItems(ContentType.TYPES.Tag)[0]
|
||||
for (const note of application.itemManager.getItems(ContentType.TYPES.Note)) {
|
||||
expect(application.itemManager.itemsReferencingItem(note).length).to.equal(1)
|
||||
}
|
||||
await Factory.safeDeinit(application)
|
||||
|
||||
@@ -9,7 +9,7 @@ describe('item mutator', () => {
|
||||
this.createBarePayload = () => {
|
||||
return new DecryptedPayload({
|
||||
uuid: '123',
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: {
|
||||
title: 'hello',
|
||||
},
|
||||
@@ -30,7 +30,7 @@ describe('item mutator', () => {
|
||||
return new SNTag(
|
||||
new DecryptedPayload({
|
||||
uuid: Factory.generateUuidish(),
|
||||
content_type: ContentType.Tag,
|
||||
content_type: ContentType.TYPES.Tag,
|
||||
content: {
|
||||
title: 'thoughts',
|
||||
references: references,
|
||||
|
||||
@@ -28,7 +28,7 @@ describe('mutator service', function () {
|
||||
})
|
||||
|
||||
const createNote = async () => {
|
||||
return mutator.createItem(ContentType.Note, {
|
||||
return mutator.createItem(ContentType.TYPES.Note, {
|
||||
title: 'hello',
|
||||
text: 'world',
|
||||
})
|
||||
@@ -41,7 +41,7 @@ describe('mutator service', function () {
|
||||
content_type: note.content_type,
|
||||
}
|
||||
})
|
||||
return mutator.createItem(ContentType.Tag, {
|
||||
return mutator.createItem(ContentType.TYPES.Tag, {
|
||||
title: 'thoughts',
|
||||
references: references,
|
||||
})
|
||||
@@ -127,7 +127,7 @@ describe('mutator service', function () {
|
||||
})
|
||||
|
||||
it('change non-existant item through uuid should fail', async function () {
|
||||
const note = await application.items.createTemplateItem(ContentType.Note, {
|
||||
const note = await application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'hello',
|
||||
text: 'world',
|
||||
})
|
||||
@@ -219,7 +219,7 @@ describe('mutator service', function () {
|
||||
})
|
||||
|
||||
it('duplicates item with additional content', async function () {
|
||||
const note = await mutator.createItem(ContentType.Note, {
|
||||
const note = await mutator.createItem(ContentType.TYPES.Note, {
|
||||
title: 'hello',
|
||||
text: 'world',
|
||||
})
|
||||
|
||||
@@ -9,7 +9,7 @@ describe('note display criteria', function () {
|
||||
this.mutator = new MutatorService(this.itemManager, this.payloadManager)
|
||||
|
||||
this.createNote = async (title = 'hello', text = 'world') => {
|
||||
return this.mutator.createItem(ContentType.Note, {
|
||||
return this.mutator.createItem(ContentType.TYPES.Note, {
|
||||
title: title,
|
||||
text: text,
|
||||
})
|
||||
@@ -22,7 +22,7 @@ describe('note display criteria', function () {
|
||||
content_type: note.content_type,
|
||||
}
|
||||
})
|
||||
return this.mutator.createItem(ContentType.Tag, {
|
||||
return this.mutator.createItem(ContentType.TYPES.Tag, {
|
||||
title: title,
|
||||
references: references,
|
||||
})
|
||||
@@ -41,7 +41,7 @@ describe('note display criteria', function () {
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
criteria,
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -57,7 +57,7 @@ describe('note display criteria', function () {
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
criteria,
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(2)
|
||||
@@ -73,7 +73,7 @@ describe('note display criteria', function () {
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
criteria,
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -89,7 +89,7 @@ describe('note display criteria', function () {
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
criteria,
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(2)
|
||||
@@ -105,7 +105,7 @@ describe('note display criteria', function () {
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
criteria,
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -123,7 +123,7 @@ describe('note display criteria', function () {
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
criteria,
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(2)
|
||||
@@ -139,7 +139,7 @@ describe('note display criteria', function () {
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
criteria,
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -157,7 +157,7 @@ describe('note display criteria', function () {
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
criteria,
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(2)
|
||||
@@ -174,7 +174,7 @@ describe('note display criteria', function () {
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
criteria,
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
@@ -191,7 +191,7 @@ describe('note display criteria', function () {
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
criteria,
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -208,7 +208,7 @@ describe('note display criteria', function () {
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
matchingCriteria,
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -219,7 +219,7 @@ describe('note display criteria', function () {
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
nonmatchingCriteria,
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
@@ -233,7 +233,7 @@ describe('note display criteria', function () {
|
||||
{
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -243,7 +243,7 @@ describe('note display criteria', function () {
|
||||
{
|
||||
views: [this.itemManager.trashSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
@@ -253,7 +253,7 @@ describe('note display criteria', function () {
|
||||
{
|
||||
views: [this.itemManager.archivedSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
@@ -271,7 +271,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
includeTrashed: false,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
@@ -281,7 +281,7 @@ describe('note display criteria', function () {
|
||||
{
|
||||
views: [this.itemManager.trashSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -291,7 +291,7 @@ describe('note display criteria', function () {
|
||||
{
|
||||
views: [this.itemManager.archivedSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
@@ -309,7 +309,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
includeArchived: false,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
@@ -319,7 +319,7 @@ describe('note display criteria', function () {
|
||||
{
|
||||
views: [this.itemManager.trashSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
@@ -329,7 +329,7 @@ describe('note display criteria', function () {
|
||||
{
|
||||
views: [this.itemManager.archivedSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -347,7 +347,7 @@ describe('note display criteria', function () {
|
||||
{
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -357,7 +357,7 @@ describe('note display criteria', function () {
|
||||
{
|
||||
views: [this.itemManager.trashSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -367,7 +367,7 @@ describe('note display criteria', function () {
|
||||
{
|
||||
views: [this.itemManager.archivedSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -384,7 +384,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
includeTrashed: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -395,7 +395,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.trashSmartView],
|
||||
includeTrashed: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
@@ -414,7 +414,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
includeTrashed: false,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
@@ -425,7 +425,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
includeTrashed: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -436,7 +436,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.trashSmartView],
|
||||
includeTrashed: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -447,7 +447,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.archivedSmartView],
|
||||
includeTrashed: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
@@ -466,7 +466,7 @@ describe('note display criteria', function () {
|
||||
{
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -476,7 +476,7 @@ describe('note display criteria', function () {
|
||||
{
|
||||
views: [this.itemManager.trashSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -486,7 +486,7 @@ describe('note display criteria', function () {
|
||||
{
|
||||
views: [this.itemManager.archivedSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -503,7 +503,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
includeArchived: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -514,7 +514,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.trashSmartView],
|
||||
includeArchived: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
@@ -532,7 +532,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
includeArchived: false,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
@@ -543,7 +543,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
includeArchived: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -554,7 +554,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.trashSmartView],
|
||||
includeArchived: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
@@ -565,7 +565,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.archivedSmartView],
|
||||
includeArchived: false,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -584,7 +584,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
includeArchived: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -595,7 +595,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.trashSmartView],
|
||||
includeArchived: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -606,7 +606,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.archivedSmartView],
|
||||
includeArchived: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -626,7 +626,7 @@ describe('note display criteria', function () {
|
||||
this.itemManager.trashSmartView,
|
||||
],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -636,7 +636,7 @@ describe('note display criteria', function () {
|
||||
{
|
||||
views: [this.itemManager.trashSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
@@ -654,7 +654,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
includeArchived: false,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
@@ -665,7 +665,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
includeArchived: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -676,7 +676,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.trashSmartView],
|
||||
includeArchived: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
@@ -687,7 +687,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.archivedSmartView],
|
||||
includeArchived: false,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -706,7 +706,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
includeArchived: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
@@ -717,7 +717,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.trashSmartView],
|
||||
includeArchived: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -728,7 +728,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.archivedSmartView],
|
||||
includeArchived: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
|
||||
@@ -9,7 +9,7 @@ describe('payload', () => {
|
||||
this.createBarePayload = () => {
|
||||
return new DecryptedPayload({
|
||||
uuid: '123',
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: {
|
||||
title: 'hello',
|
||||
},
|
||||
@@ -19,7 +19,7 @@ describe('payload', () => {
|
||||
this.createEncryptedPayload = () => {
|
||||
return new EncryptedPayload({
|
||||
uuid: '123',
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: '004:foo:bar',
|
||||
})
|
||||
}
|
||||
@@ -36,7 +36,7 @@ describe('payload', () => {
|
||||
it('not supplying source should default to constructor source', function () {
|
||||
const payload = new DecryptedPayload({
|
||||
uuid: '123',
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: {
|
||||
title: 'hello',
|
||||
},
|
||||
@@ -74,7 +74,7 @@ describe('payload', () => {
|
||||
() =>
|
||||
new EncryptedPayload({
|
||||
uuid: '123',
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: '000:somebase64string',
|
||||
}),
|
||||
'Unrecognized protocol version 000',
|
||||
@@ -84,7 +84,7 @@ describe('payload', () => {
|
||||
it('payload format deleted', function () {
|
||||
const payload = new DeletedPayload({
|
||||
uuid: '123',
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
deleted: true,
|
||||
})
|
||||
|
||||
@@ -101,7 +101,7 @@ describe('payload', () => {
|
||||
const payload = this.createBarePayload()
|
||||
const merged = payload.copy({
|
||||
uuid: '123',
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
updated_at: new Date(),
|
||||
dirty: true,
|
||||
dirtyIndex: getIncrementedDirtyIndex(),
|
||||
@@ -116,7 +116,7 @@ describe('payload', () => {
|
||||
it('deleted and not dirty should be discardable', function () {
|
||||
const payload = new DeletedPayload({
|
||||
uuid: '123',
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
deleted: true,
|
||||
dirty: false,
|
||||
})
|
||||
|
||||
@@ -10,7 +10,7 @@ describe('payload manager', () => {
|
||||
this.createNotePayload = async () => {
|
||||
return new DecryptedPayload({
|
||||
uuid: Factory.generateUuidish(),
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: {
|
||||
title: 'hello',
|
||||
text: 'world',
|
||||
@@ -45,7 +45,7 @@ describe('payload manager', () => {
|
||||
|
||||
it('insertion observer', async function () {
|
||||
const observations = []
|
||||
this.payloadManager.addObserver(ContentType.Any, ({ inserted }) => {
|
||||
this.payloadManager.addObserver(ContentType.TYPES.Any, ({ inserted }) => {
|
||||
observations.push({ inserted })
|
||||
})
|
||||
const payload = await this.createNotePayload()
|
||||
@@ -57,7 +57,7 @@ describe('payload manager', () => {
|
||||
|
||||
it('change observer', async function () {
|
||||
const observations = []
|
||||
this.payloadManager.addObserver(ContentType.Any, ({ changed }) => {
|
||||
this.payloadManager.addObserver(ContentType.TYPES.Any, ({ changed }) => {
|
||||
if (changed.length > 0) {
|
||||
observations.push({ changed })
|
||||
}
|
||||
@@ -78,7 +78,7 @@ describe('payload manager', () => {
|
||||
})
|
||||
|
||||
it('reset state', async function () {
|
||||
this.payloadManager.addObserver(ContentType.Any, ({}) => {})
|
||||
this.payloadManager.addObserver(ContentType.TYPES.Any, ({}) => {})
|
||||
const payload = await this.createNotePayload()
|
||||
await this.payloadManager.emitPayload(payload)
|
||||
await this.payloadManager.resetState()
|
||||
|
||||
@@ -16,7 +16,7 @@ describe('singletons', function () {
|
||||
function createPrefsPayload() {
|
||||
const params = {
|
||||
uuid: UuidGenerator.GenerateUuid(),
|
||||
content_type: ContentType.UserPrefs,
|
||||
content_type: ContentType.TYPES.UserPrefs,
|
||||
content: {
|
||||
foo: 'bar',
|
||||
},
|
||||
@@ -25,7 +25,7 @@ describe('singletons', function () {
|
||||
}
|
||||
|
||||
function findOrCreatePrefsSingleton(application) {
|
||||
return application.singletonManager.findOrCreateContentTypeSingleton(ContentType.UserPrefs, FillItemContent({}))
|
||||
return application.singletonManager.findOrCreateContentTypeSingleton(ContentType.TYPES.UserPrefs, FillItemContent({}))
|
||||
}
|
||||
|
||||
beforeEach(async function () {
|
||||
@@ -59,13 +59,13 @@ describe('singletons', function () {
|
||||
this.extManagerId = 'org.standardnotes.extensions-manager'
|
||||
|
||||
this.extPred = new CompoundPredicate('and', [
|
||||
new Predicate('content_type', '=', ContentType.Component),
|
||||
new Predicate('content_type', '=', ContentType.TYPES.Component),
|
||||
new Predicate('package_info.identifier', '=', this.extManagerId),
|
||||
])
|
||||
|
||||
this.createExtMgr = () => {
|
||||
return this.application.mutator.createItem(
|
||||
ContentType.Component,
|
||||
ContentType.TYPES.Component,
|
||||
{
|
||||
package_info: {
|
||||
name: 'Extensions',
|
||||
@@ -121,14 +121,14 @@ describe('singletons', function () {
|
||||
|
||||
await this.application.sync.sync(syncOptions)
|
||||
|
||||
expect(this.application.itemManager.itemsMatchingPredicate(ContentType.Component, this.extPred).length).to.equal(1)
|
||||
expect(this.application.itemManager.itemsMatchingPredicate(ContentType.TYPES.Component, this.extPred).length).to.equal(1)
|
||||
})
|
||||
|
||||
it('resolves via find or create', async function () {
|
||||
/* Set to never synced as singleton manager will attempt to sync before resolving */
|
||||
this.application.syncService.ut_clearLastSyncDate()
|
||||
this.application.syncService.ut_setDatabaseLoaded(false)
|
||||
const contentType = ContentType.UserPrefs
|
||||
const contentType = ContentType.TYPES.UserPrefs
|
||||
const predicate = new Predicate('content_type', '=', contentType)
|
||||
/* Start a sync right after we await singleton resolve below */
|
||||
setTimeout(() => {
|
||||
@@ -198,7 +198,7 @@ describe('singletons', function () {
|
||||
didCompleteRelevantSync = true
|
||||
const saved = data.savedPayloads
|
||||
expect(saved.length).to.equal(1)
|
||||
const matching = saved.find((p) => p.content_type === ContentType.Component && p.deleted)
|
||||
const matching = saved.find((p) => p.content_type === ContentType.TYPES.Component && p.deleted)
|
||||
expect(matching).to.not.be.ok
|
||||
}
|
||||
})
|
||||
@@ -252,7 +252,7 @@ describe('singletons', function () {
|
||||
})
|
||||
|
||||
it('if only result is errorDecrypting, create new item', async function () {
|
||||
const item = this.application.itemManager.items.find((item) => item.content_type === ContentType.UserPrefs)
|
||||
const item = this.application.itemManager.items.find((item) => item.content_type === ContentType.TYPES.UserPrefs)
|
||||
|
||||
const erroredPayload = new EncryptedPayload({
|
||||
...item.payload.ejected(),
|
||||
@@ -292,7 +292,7 @@ describe('singletons', function () {
|
||||
const errorDecryptingFalse = false
|
||||
await Factory.insertItemWithOverride(
|
||||
this.application,
|
||||
ContentType.Component,
|
||||
ContentType.TYPES.Component,
|
||||
sharedContent,
|
||||
true,
|
||||
errorDecryptingFalse,
|
||||
@@ -301,7 +301,7 @@ describe('singletons', function () {
|
||||
const errorDecryptingTrue = true
|
||||
const errored = await Factory.insertItemWithOverride(
|
||||
this.application,
|
||||
ContentType.Component,
|
||||
ContentType.TYPES.Component,
|
||||
sharedContent,
|
||||
true,
|
||||
errorDecryptingTrue,
|
||||
@@ -324,7 +324,7 @@ describe('singletons', function () {
|
||||
await Factory.sleep(0)
|
||||
await this.application.syncService.sync(syncOptions)
|
||||
|
||||
expect(this.application.itemManager.itemsMatchingPredicate(ContentType.Component, this.extPred).length).to.equal(1)
|
||||
expect(this.application.itemManager.itemsMatchingPredicate(ContentType.TYPES.Component, this.extPred).length).to.equal(1)
|
||||
})
|
||||
|
||||
it('alternating the uuid of a singleton should return correct result', async function () {
|
||||
|
||||
@@ -62,7 +62,7 @@ describe('online conflict handling', function () {
|
||||
}
|
||||
|
||||
it('components should not be duplicated under any circumstances', async function () {
|
||||
const payload = createDirtyPayload(ContentType.Component)
|
||||
const payload = createDirtyPayload(ContentType.TYPES.Component)
|
||||
|
||||
const item = await this.application.mutator.emitItemFromPayload(payload, PayloadEmitSource.LocalChanged)
|
||||
|
||||
@@ -90,7 +90,7 @@ describe('online conflict handling', function () {
|
||||
})
|
||||
|
||||
it('items keys should not be duplicated under any circumstances', async function () {
|
||||
const payload = createDirtyPayload(ContentType.ItemsKey)
|
||||
const payload = createDirtyPayload(ContentType.TYPES.ItemsKey)
|
||||
const item = await this.application.mutator.emitItemFromPayload(payload, PayloadEmitSource.LocalChanged)
|
||||
this.expectedItemCount++
|
||||
await this.application.syncService.sync(syncOptions)
|
||||
@@ -527,13 +527,13 @@ describe('online conflict handling', function () {
|
||||
}).timeout(60000)
|
||||
|
||||
it('duplicating an item should maintian its relationships', async function () {
|
||||
const payload1 = Factory.createStorageItemPayload(ContentType.Tag)
|
||||
const payload2 = Factory.createStorageItemPayload(ContentType.UserPrefs)
|
||||
const payload1 = Factory.createStorageItemPayload(ContentType.TYPES.Tag)
|
||||
const payload2 = Factory.createStorageItemPayload(ContentType.TYPES.UserPrefs)
|
||||
this.expectedItemCount -= 1 /** auto-created user preferences */
|
||||
await this.application.mutator.emitItemsFromPayloads([payload1, payload2], PayloadEmitSource.LocalChanged)
|
||||
this.expectedItemCount += 2
|
||||
let tag = this.application.itemManager.getItems(ContentType.Tag)[0]
|
||||
let userPrefs = this.application.itemManager.getItems(ContentType.UserPrefs)[0]
|
||||
let tag = this.application.itemManager.getItems(ContentType.TYPES.Tag)[0]
|
||||
let userPrefs = this.application.itemManager.getItems(ContentType.TYPES.UserPrefs)[0]
|
||||
expect(tag).to.be.ok
|
||||
expect(userPrefs).to.be.ok
|
||||
|
||||
@@ -567,7 +567,7 @@ describe('online conflict handling', function () {
|
||||
const rawPayloads = await this.application.diskStorageService.getAllRawPayloads()
|
||||
expect(rawPayloads.length).to.equal(this.expectedItemCount)
|
||||
|
||||
const fooItems = this.application.itemManager.getItems(ContentType.Tag)
|
||||
const fooItems = this.application.itemManager.getItems(ContentType.TYPES.Tag)
|
||||
const fooItem2 = fooItems[1]
|
||||
|
||||
expect(fooItem2.content.conflict_of).to.equal(tag.uuid)
|
||||
@@ -772,9 +772,9 @@ describe('online conflict handling', function () {
|
||||
let backupFile = await this.application.createEncryptedBackupFileForAutomatedDesktopBackups()
|
||||
/** Sort matters, and is the cause of the original issue, where tag comes before the note */
|
||||
backupFile.items = [
|
||||
backupFile.items.find((i) => i.content_type === ContentType.ItemsKey),
|
||||
backupFile.items.find((i) => i.content_type === ContentType.Tag),
|
||||
backupFile.items.find((i) => i.content_type === ContentType.Note),
|
||||
backupFile.items.find((i) => i.content_type === ContentType.TYPES.ItemsKey),
|
||||
backupFile.items.find((i) => i.content_type === ContentType.TYPES.Tag),
|
||||
backupFile.items.find((i) => i.content_type === ContentType.TYPES.Note),
|
||||
]
|
||||
backupFile = JSON.parse(JSON.stringify(backupFile))
|
||||
/** Register new account and import this same data */
|
||||
@@ -806,10 +806,10 @@ describe('online conflict handling', function () {
|
||||
})
|
||||
let backupFile = await this.application.createEncryptedBackupFileForAutomatedDesktopBackups()
|
||||
backupFile.items = [
|
||||
backupFile.items.find((i) => i.content_type === ContentType.ItemsKey),
|
||||
backupFile.items.filter((i) => i.content_type === ContentType.Note)[0],
|
||||
backupFile.items.filter((i) => i.content_type === ContentType.Note)[1],
|
||||
backupFile.items.find((i) => i.content_type === ContentType.Tag),
|
||||
backupFile.items.find((i) => i.content_type === ContentType.TYPES.ItemsKey),
|
||||
backupFile.items.filter((i) => i.content_type === ContentType.TYPES.Note)[0],
|
||||
backupFile.items.filter((i) => i.content_type === ContentType.TYPES.Note)[1],
|
||||
backupFile.items.find((i) => i.content_type === ContentType.TYPES.Tag),
|
||||
]
|
||||
backupFile = JSON.parse(JSON.stringify(backupFile))
|
||||
/** Register new account and import this same data */
|
||||
|
||||
@@ -53,8 +53,8 @@ describe('notes + tags syncing', function () {
|
||||
const tagPayload = pair[1]
|
||||
|
||||
await this.application.mutator.emitItemsFromPayloads([notePayload, tagPayload], PayloadEmitSource.LocalChanged)
|
||||
const note = this.application.itemManager.getItems([ContentType.Note])[0]
|
||||
const tag = this.application.itemManager.getItems([ContentType.Tag])[0]
|
||||
const note = this.application.itemManager.getItems([ContentType.TYPES.Note])[0]
|
||||
const tag = this.application.itemManager.getItems([ContentType.TYPES.Tag])[0]
|
||||
expect(this.application.itemManager.getDisplayableNotes().length).to.equal(1)
|
||||
expect(this.application.itemManager.getDisplayableTags().length).to.equal(1)
|
||||
|
||||
|
||||
@@ -64,8 +64,8 @@ describe('offline syncing', () => {
|
||||
const rawPayloads2 = await this.application.diskStorageService.getAllRawPayloads()
|
||||
expect(rawPayloads2.length).to.equal(this.expectedItemCount)
|
||||
|
||||
const itemsKeyRaw = (await Factory.getStoragePayloadsOfType(this.application, ContentType.ItemsKey))[0]
|
||||
const noteRaw = (await Factory.getStoragePayloadsOfType(this.application, ContentType.Note))[0]
|
||||
const itemsKeyRaw = (await Factory.getStoragePayloadsOfType(this.application, ContentType.TYPES.ItemsKey))[0]
|
||||
const noteRaw = (await Factory.getStoragePayloadsOfType(this.application, ContentType.TYPES.Note))[0]
|
||||
|
||||
/** Encrypts with default items key */
|
||||
expect(typeof noteRaw.content).to.equal('string')
|
||||
|
||||
@@ -54,7 +54,7 @@ describe('online syncing', function () {
|
||||
})
|
||||
|
||||
function noteObjectsFromObjects(items) {
|
||||
return items.filter((item) => item.content_type === ContentType.Note)
|
||||
return items.filter((item) => item.content_type === ContentType.TYPES.Note)
|
||||
}
|
||||
|
||||
it('should register and sync basic model online', async function () {
|
||||
@@ -577,7 +577,7 @@ describe('online syncing', function () {
|
||||
await this.application.syncService.sync(syncOptions)
|
||||
this.expectedItemCount++
|
||||
const rawPayloads = await this.application.diskStorageService.getAllRawPayloads()
|
||||
const notePayload = rawPayloads.find((p) => p.content_type === ContentType.Note)
|
||||
const notePayload = rawPayloads.find((p) => p.content_type === ContentType.TYPES.Note)
|
||||
expect(typeof notePayload.content).to.equal('string')
|
||||
})
|
||||
|
||||
@@ -593,7 +593,7 @@ describe('online syncing', function () {
|
||||
await Factory.sleep(0.3)
|
||||
|
||||
const rawPayloads = await this.application.diskStorageService.getAllRawPayloads()
|
||||
const notePayload = rawPayloads.find((p) => p.content_type === ContentType.Note)
|
||||
const notePayload = rawPayloads.find((p) => p.content_type === ContentType.TYPES.Note)
|
||||
expect(typeof notePayload.content).to.equal('string')
|
||||
})
|
||||
|
||||
@@ -611,7 +611,7 @@ describe('online syncing', function () {
|
||||
)
|
||||
this.expectedItemCount++
|
||||
const rawPayloads = await this.application.diskStorageService.getAllRawPayloads()
|
||||
const notePayload = rawPayloads.find((p) => p.content_type === ContentType.Note)
|
||||
const notePayload = rawPayloads.find((p) => p.content_type === ContentType.TYPES.Note)
|
||||
expect(typeof notePayload.content).to.equal('string')
|
||||
expect(notePayload.content.length).to.be.above(text.length)
|
||||
})
|
||||
@@ -790,7 +790,7 @@ describe('online syncing', function () {
|
||||
/** Create an item and sync it */
|
||||
let note = await Factory.createMappedNote(this.application)
|
||||
|
||||
this.application.itemManager.addObserver(ContentType.Note, ({ source }) => {
|
||||
this.application.itemManager.addObserver(ContentType.TYPES.Note, ({ source }) => {
|
||||
if (source === PayloadEmitSource.RemoteSaved) {
|
||||
actualSaveCount++
|
||||
}
|
||||
@@ -837,7 +837,7 @@ describe('online syncing', function () {
|
||||
/** Create an item and sync it */
|
||||
let note = await Factory.createMappedNote(this.application)
|
||||
|
||||
this.application.itemManager.addObserver(ContentType.Note, ({ source }) => {
|
||||
this.application.itemManager.addObserver(ContentType.TYPES.Note, ({ source }) => {
|
||||
if (source === PayloadEmitSource.RemoteSaved) {
|
||||
actualSaveCount++
|
||||
}
|
||||
@@ -876,7 +876,7 @@ describe('online syncing', function () {
|
||||
let didPerformMutatation = false
|
||||
const newText = `${Math.random()}`
|
||||
|
||||
this.application.itemManager.addObserver(ContentType.Note, async ({ changed, source }) => {
|
||||
this.application.itemManager.addObserver(ContentType.TYPES.Note, async ({ changed, source }) => {
|
||||
if (source === PayloadEmitSource.RemoteSaved) {
|
||||
actualSaveCount++
|
||||
} else if (source === PayloadEmitSource.PreSyncSave && !didPerformMutatation) {
|
||||
@@ -1015,7 +1015,7 @@ describe('online syncing', function () {
|
||||
it('deleting an item permanently should include it in PayloadEmitSource.PreSyncSave item change observer', async function () {
|
||||
let conditionMet = false
|
||||
|
||||
this.application.streamItems([ContentType.Note], async ({ removed, source }) => {
|
||||
this.application.streamItems([ContentType.TYPES.Note], async ({ removed, source }) => {
|
||||
if (source === PayloadEmitSource.PreSyncSave && removed.length === 1) {
|
||||
conditionMet = true
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ describe('upgrading', () => {
|
||||
expect((await this.application.encryptionService.getRootKey()).keyVersion).to.equal(ProtocolVersion.V003)
|
||||
|
||||
/** Ensure note is encrypted with 003 */
|
||||
const notePayloads = await Factory.getStoragePayloadsOfType(this.application, ContentType.Note)
|
||||
const notePayloads = await Factory.getStoragePayloadsOfType(this.application, ContentType.TYPES.Note)
|
||||
expect(notePayloads.length).to.equal(1)
|
||||
expect(notePayloads[0].version).to.equal(ProtocolVersion.V003)
|
||||
|
||||
@@ -211,7 +211,7 @@ describe('upgrading', () => {
|
||||
const note = this.application.itemManager.getDisplayableNotes()[0]
|
||||
await Factory.markDirtyAndSyncItem(this.application, note)
|
||||
|
||||
const refreshedNotePayloads = await Factory.getStoragePayloadsOfType(this.application, ContentType.Note)
|
||||
const refreshedNotePayloads = await Factory.getStoragePayloadsOfType(this.application, ContentType.TYPES.Note)
|
||||
const refreshedNotePayload = refreshedNotePayloads[0]
|
||||
expect(refreshedNotePayload.version).to.equal(latestVersion)
|
||||
}).timeout(5000)
|
||||
|
||||
@@ -37,7 +37,7 @@ describe('shared vault conflicts', function () {
|
||||
|
||||
expect(conflicts.length).to.equal(1)
|
||||
expect(conflicts[0].type).to.equal(ConflictType.SharedVaultNotMemberError)
|
||||
expect(conflicts[0].unsaved_item.content_type).to.equal(ContentType.Note)
|
||||
expect(conflicts[0].unsaved_item.content_type).to.equal(ContentType.TYPES.Note)
|
||||
|
||||
const collaboratorNotes = contactContext.items.getDisplayableNotes()
|
||||
expect(collaboratorNotes.length).to.equal(1)
|
||||
@@ -89,7 +89,7 @@ describe('shared vault conflicts', function () {
|
||||
|
||||
expect(conflicts.length).to.equal(1)
|
||||
expect(conflicts[0].type).to.equal(ConflictType.SharedVaultInsufficientPermissionsError)
|
||||
expect(conflicts[0].unsaved_item.content_type).to.equal(ContentType.Note)
|
||||
expect(conflicts[0].unsaved_item.content_type).to.equal(ContentType.TYPES.Note)
|
||||
|
||||
await deinitContactContext()
|
||||
})
|
||||
@@ -135,7 +135,7 @@ describe('shared vault conflicts', function () {
|
||||
|
||||
expect(conflicts.length).to.equal(1)
|
||||
expect(conflicts[0].type).to.equal(ConflictType.SharedVaultNotMemberError)
|
||||
expect(conflicts[0].unsaved_item.content_type).to.equal(ContentType.Note)
|
||||
expect(conflicts[0].unsaved_item.content_type).to.equal(ContentType.TYPES.Note)
|
||||
})
|
||||
|
||||
it('should create a non-vaulted copy if attempting to move item from vault to user and item belongs to someone else', async () => {
|
||||
@@ -147,7 +147,7 @@ describe('shared vault conflicts', function () {
|
||||
const conflicts = await promise
|
||||
|
||||
expect(conflicts.length).to.equal(1)
|
||||
expect(conflicts[0].unsaved_item.content_type).to.equal(ContentType.Note)
|
||||
expect(conflicts[0].unsaved_item.content_type).to.equal(ContentType.TYPES.Note)
|
||||
|
||||
const duplicateNote = contactContext.findDuplicateNote(note.uuid)
|
||||
expect(duplicateNote).to.not.be.undefined
|
||||
@@ -172,7 +172,7 @@ describe('shared vault conflicts', function () {
|
||||
const conflicts = await promise
|
||||
|
||||
expect(conflicts.length).to.equal(1)
|
||||
expect(conflicts[0].unsaved_item.content_type).to.equal(ContentType.Note)
|
||||
expect(conflicts[0].unsaved_item.content_type).to.equal(ContentType.TYPES.Note)
|
||||
|
||||
const duplicateNote = context.findDuplicateNote(note.uuid)
|
||||
expect(duplicateNote).to.not.be.undefined
|
||||
|
||||
@@ -82,7 +82,7 @@ describe('shared vault permissions', function () {
|
||||
const conflicts = await promise
|
||||
|
||||
expect(conflicts.length).to.equal(1)
|
||||
expect(conflicts[0].unsaved_item.content_type).to.equal(ContentType.KeySystemItemsKey)
|
||||
expect(conflicts[0].unsaved_item.content_type).to.equal(ContentType.TYPES.KeySystemItemsKey)
|
||||
|
||||
await deinitContactContext()
|
||||
})
|
||||
@@ -103,7 +103,7 @@ describe('shared vault permissions', function () {
|
||||
const conflicts = await promise
|
||||
|
||||
expect(conflicts.length).to.equal(1)
|
||||
expect(conflicts[0].unsaved_item.content_type).to.equal(ContentType.Note)
|
||||
expect(conflicts[0].unsaved_item.content_type).to.equal(ContentType.TYPES.Note)
|
||||
|
||||
await deinitContactContext()
|
||||
})
|
||||
|
||||
@@ -36,8 +36,8 @@
|
||||
"@babel/core": "*",
|
||||
"@babel/preset-env": "*",
|
||||
"@standardnotes/api": "workspace:*",
|
||||
"@standardnotes/common": "^1.48.3",
|
||||
"@standardnotes/domain-core": "^1.12.0",
|
||||
"@standardnotes/common": "^1.50.0",
|
||||
"@standardnotes/domain-core": "^1.22.0",
|
||||
"@standardnotes/domain-events": "^2.108.1",
|
||||
"@standardnotes/encryption": "workspace:*",
|
||||
"@standardnotes/features": "workspace:*",
|
||||
|
||||
Reference in New Issue
Block a user