mirror of
https://github.com/standardnotes/app.git
synced 2026-01-16 23:01:30 +00:00
chore: fix ContentType usage (#2353)
* chore: fix ContentType usage * chore: fix specs
This commit is contained in:
parent
d057cdff84
commit
325737bfbd
247 changed files with 1092 additions and 1060 deletions
Binary file not shown.
Binary file not shown.
|
|
@ -36,8 +36,8 @@
|
|||
"typescript": "*"
|
||||
},
|
||||
"dependencies": {
|
||||
"@standardnotes/common": "^1.48.3",
|
||||
"@standardnotes/domain-core": "^1.12.0",
|
||||
"@standardnotes/common": "^1.50.0",
|
||||
"@standardnotes/domain-core": "^1.22.0",
|
||||
"@standardnotes/models": "workspace:*",
|
||||
"@standardnotes/responses": "workspace:*",
|
||||
"@standardnotes/security": "^1.7.6",
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@electron/remote": "^2.0.9",
|
||||
"@standardnotes/domain-core": "^1.18.0",
|
||||
"@standardnotes/domain-core": "^1.22.0",
|
||||
"@standardnotes/electron-clear-data": "1.1.1",
|
||||
"@standardnotes/web": "workspace:*",
|
||||
"axios": "^1.1.3",
|
||||
|
|
|
|||
|
|
@ -28,7 +28,8 @@
|
|||
"typescript": "*"
|
||||
},
|
||||
"dependencies": {
|
||||
"@standardnotes/common": "^1.48.3",
|
||||
"@standardnotes/common": "^1.50.0",
|
||||
"@standardnotes/domain-core": "^1.22.0",
|
||||
"@standardnotes/models": "workspace:*",
|
||||
"@standardnotes/responses": "workspace:*",
|
||||
"@standardnotes/sncrypto-common": "workspace:*",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { ContentType, ProtocolVersion } from '@standardnotes/common'
|
||||
import { ProtocolVersion } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import {
|
||||
ConflictStrategy,
|
||||
DecryptedItem,
|
||||
|
|
@ -10,7 +11,7 @@ import {
|
|||
} from '@standardnotes/models'
|
||||
|
||||
export function isItemsKey(x: unknown): x is ItemsKeyInterface {
|
||||
return (x as ItemsKeyInterface).content_type === ContentType.ItemsKey
|
||||
return (x as ItemsKeyInterface).content_type === ContentType.TYPES.ItemsKey
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
import { DecryptedItemMutator, ItemsKeyContent, RegisterItemClass } from '@standardnotes/models'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { SNItemsKey } from './ItemsKey'
|
||||
import { ItemsKeyMutator } from './ItemsKeyMutator'
|
||||
|
||||
RegisterItemClass(ContentType.ItemsKey, SNItemsKey, ItemsKeyMutator as unknown as DecryptedItemMutator<ItemsKeyContent>)
|
||||
RegisterItemClass(
|
||||
ContentType.TYPES.ItemsKey,
|
||||
SNItemsKey,
|
||||
ItemsKeyMutator as unknown as DecryptedItemMutator<ItemsKeyContent>,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { ContentType, ProtocolVersion } from '@standardnotes/common'
|
||||
import { ProtocolVersion } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import {
|
||||
ConflictStrategy,
|
||||
DecryptedItem,
|
||||
|
|
@ -10,7 +11,7 @@ import {
|
|||
} from '@standardnotes/models'
|
||||
|
||||
export function isKeySystemItemsKey(x: unknown): x is KeySystemItemsKeyInterface {
|
||||
return (x as KeySystemItemsKeyInterface).content_type === ContentType.KeySystemItemsKey
|
||||
return (x as KeySystemItemsKeyInterface).content_type === ContentType.TYPES.KeySystemItemsKey
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
import { DecryptedItemMutator, KeySystemItemsKeyContent, RegisterItemClass } from '@standardnotes/models'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
import { KeySystemItemsKey } from './KeySystemItemsKey'
|
||||
import { KeySystemItemsKeyMutator } from './KeySystemItemsKeyMutator'
|
||||
|
||||
RegisterItemClass(
|
||||
ContentType.KeySystemItemsKey,
|
||||
ContentType.TYPES.KeySystemItemsKey,
|
||||
KeySystemItemsKey,
|
||||
KeySystemItemsKeyMutator as unknown as DecryptedItemMutator<KeySystemItemsKeyContent>,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ContentType, ProtocolVersion } from '@standardnotes/common'
|
||||
import { ProtocolVersion } from '@standardnotes/common'
|
||||
import {
|
||||
DecryptedPayload,
|
||||
FillItemContentSpecialized,
|
||||
|
|
@ -9,13 +9,14 @@ import {
|
|||
} from '@standardnotes/models'
|
||||
import { UuidGenerator } from '@standardnotes/utils'
|
||||
import { SNRootKey } from './RootKey'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
export function CreateNewRootKey<K extends RootKeyInterface>(content: RootKeyContentSpecialized): K {
|
||||
const uuid = UuidGenerator.GenerateUuid()
|
||||
|
||||
const payload = new DecryptedPayload<RootKeyContent>({
|
||||
uuid: uuid,
|
||||
content_type: ContentType.RootKey,
|
||||
content_type: ContentType.TYPES.RootKey,
|
||||
content: FillRootKeyContent(content),
|
||||
...PayloadTimestampDefaults(),
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ContentType, KeyParamsOrigination, ProtocolVersion, ProtocolVersionLength } from '@standardnotes/common'
|
||||
import { KeyParamsOrigination, ProtocolVersion, ProtocolVersionLength } from '@standardnotes/common'
|
||||
import {
|
||||
CreateDecryptedItemFromPayload,
|
||||
DecryptedPayload,
|
||||
|
|
@ -32,6 +32,7 @@ import { PublicKeySet } from '../Types/PublicKeySet'
|
|||
import { AsymmetricDecryptResult } from '../Types/AsymmetricDecryptResult'
|
||||
import { AsymmetricSignatureVerificationDetachedResult } from '../Types/AsymmetricSignatureVerificationDetachedResult'
|
||||
import { AsyncOperatorInterface } from '../OperatorInterface/AsyncOperatorInterface'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
const NO_IV = '00000000000000000000000000000000'
|
||||
|
||||
|
|
@ -71,7 +72,7 @@ export class SNProtocolOperator001 implements OperatorInterface, AsyncOperatorIn
|
|||
public createItemsKey(): ItemsKeyInterface {
|
||||
const payload = new DecryptedPayload({
|
||||
uuid: UuidGenerator.GenerateUuid(),
|
||||
content_type: ContentType.ItemsKey,
|
||||
content_type: ContentType.TYPES.ItemsKey,
|
||||
content: this.generateNewItemsKeyContent(),
|
||||
...PayloadTimestampDefaults(),
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import * as Common from '@standardnotes/common'
|
||||
import * as Models from '@standardnotes/models'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { ItemContent, PayloadTimestampDefaults } from '@standardnotes/models'
|
||||
import * as Utils from '@standardnotes/utils'
|
||||
import { UuidGenerator } from '@standardnotes/utils'
|
||||
|
|
@ -44,7 +45,7 @@ export class SNProtocolOperator002 extends SNProtocolOperator001 {
|
|||
public override createItemsKey(): Models.ItemsKeyInterface {
|
||||
const payload = new Models.DecryptedPayload({
|
||||
uuid: UuidGenerator.GenerateUuid(),
|
||||
content_type: Common.ContentType.ItemsKey,
|
||||
content_type: ContentType.TYPES.ItemsKey,
|
||||
content: this.generateNewItemsKeyContent(),
|
||||
...PayloadTimestampDefaults(),
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ContentType, KeyParamsOrigination, ProtocolVersion } from '@standardnotes/common'
|
||||
import { KeyParamsOrigination, ProtocolVersion } from '@standardnotes/common'
|
||||
import {
|
||||
CreateDecryptedItemFromPayload,
|
||||
DecryptedPayload,
|
||||
|
|
@ -14,6 +14,7 @@ import { CreateNewRootKey } from '../../Keys/RootKey/Functions'
|
|||
import { Create003KeyParams } from '../../Keys/RootKey/KeyParamsFunctions'
|
||||
import { SNRootKeyParams } from '../../Keys/RootKey/RootKeyParams'
|
||||
import { SNProtocolOperator002 } from '../002/Operator002'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
/**
|
||||
* @legacy
|
||||
|
|
@ -46,7 +47,7 @@ export class SNProtocolOperator003 extends SNProtocolOperator002 {
|
|||
const content = this.generateNewItemsKeyContent()
|
||||
const payload = new DecryptedPayload({
|
||||
uuid: UuidGenerator.GenerateUuid(),
|
||||
content_type: ContentType.ItemsKey,
|
||||
content_type: ContentType.TYPES.ItemsKey,
|
||||
content: FillItemContent(content),
|
||||
...PayloadTimestampDefaults(),
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
import { ContentType, ProtocolVersion } from '@standardnotes/common'
|
||||
import { ProtocolVersion } from '@standardnotes/common'
|
||||
import { DecryptedPayload, ItemContent, ItemsKeyContent, PayloadTimestampDefaults } from '@standardnotes/models'
|
||||
import { SNItemsKey } from '../../Keys/ItemsKey/ItemsKey'
|
||||
import { SNProtocolOperator004 } from './Operator004'
|
||||
import { getMockedCrypto } from './MockedCrypto'
|
||||
import { deconstructEncryptedPayloadString } from './V004AlgorithmHelpers'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
describe('operator 004', () => {
|
||||
const crypto = getMockedCrypto()
|
||||
|
|
@ -31,7 +32,7 @@ describe('operator 004', () => {
|
|||
it('should generateEncryptedParameters', () => {
|
||||
const payload = {
|
||||
uuid: '123',
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: { foo: 'bar' } as unknown as jest.Mocked<ItemContent>,
|
||||
...PayloadTimestampDefaults(),
|
||||
} as jest.Mocked<DecryptedPayload>
|
||||
|
|
@ -39,7 +40,7 @@ describe('operator 004', () => {
|
|||
const key = new SNItemsKey(
|
||||
new DecryptedPayload<ItemsKeyContent>({
|
||||
uuid: 'key-456',
|
||||
content_type: ContentType.ItemsKey,
|
||||
content_type: ContentType.TYPES.ItemsKey,
|
||||
content: {
|
||||
itemsKey: 'secret',
|
||||
version: ProtocolVersion.V004,
|
||||
|
|
@ -56,7 +57,7 @@ describe('operator 004', () => {
|
|||
key_system_identifier: undefined,
|
||||
shared_vault_uuid: undefined,
|
||||
content: '004:random-string:<e>{"foo"|"bar"}<e>:base64-{"u"|"123","v"|"004"}:base64-{}',
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
enc_item_key: '004:random-string:<e>random-string<e>:base64-{"u"|"123","v"|"004"}:base64-{}',
|
||||
version: '004',
|
||||
})
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import {
|
|||
RootKeyInterface,
|
||||
KeySystemRootKeyParamsInterface,
|
||||
} from '@standardnotes/models'
|
||||
import { ContentType, KeyParamsOrigination, ProtocolVersion } from '@standardnotes/common'
|
||||
import { KeyParamsOrigination, ProtocolVersion } from '@standardnotes/common'
|
||||
import { HexString, PkcKeyPair, PureCryptoInterface, Utf8String } from '@standardnotes/sncrypto-common'
|
||||
import { V004Algorithm } from '../../Algorithm'
|
||||
import { SNRootKeyParams } from '../../Keys/RootKey/RootKeyParams'
|
||||
|
|
@ -48,6 +48,7 @@ import { AsymmetricSignatureVerificationDetachedResult } from '../Types/Asymmetr
|
|||
import { AsymmetricSignatureVerificationDetachedUseCase } from './UseCase/Asymmetric/AsymmetricSignatureVerificationDetached'
|
||||
import { DeriveKeySystemRootKeyUseCase } from './UseCase/KeySystem/DeriveKeySystemRootKey'
|
||||
import { SyncOperatorInterface } from '../OperatorInterface/SyncOperatorInterface'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
export class SNProtocolOperator004 implements OperatorInterface, SyncOperatorInterface {
|
||||
constructor(protected readonly crypto: PureCryptoInterface) {}
|
||||
|
|
@ -76,7 +77,7 @@ export class SNProtocolOperator004 implements OperatorInterface, SyncOperatorInt
|
|||
public createItemsKey(): ItemsKeyInterface {
|
||||
const payload = new DecryptedPayload({
|
||||
uuid: UuidGenerator.GenerateUuid(),
|
||||
content_type: ContentType.ItemsKey,
|
||||
content_type: ContentType.TYPES.ItemsKey,
|
||||
content: this.generateNewItemsKeyContent(),
|
||||
key_system_identifier: undefined,
|
||||
shared_vault_uuid: undefined,
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@ import {
|
|||
} from '@standardnotes/models'
|
||||
import { PureCryptoInterface } from '@standardnotes/sncrypto-common'
|
||||
import { V004Algorithm } from '../../../../Algorithm'
|
||||
import { ContentType, ProtocolVersion } from '@standardnotes/common'
|
||||
import { ProtocolVersion } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
export class CreateKeySystemItemsKeyUseCase {
|
||||
constructor(private readonly crypto: PureCryptoInterface) {}
|
||||
|
|
@ -31,7 +32,7 @@ export class CreateKeySystemItemsKeyUseCase {
|
|||
|
||||
const transferPayload: DecryptedTransferPayload = {
|
||||
uuid: dto.uuid,
|
||||
content_type: ContentType.KeySystemItemsKey,
|
||||
content_type: ContentType.TYPES.KeySystemItemsKey,
|
||||
key_system_identifier: dto.keySystemIdentifier,
|
||||
shared_vault_uuid: dto.sharedVaultUuid,
|
||||
content: content,
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ import {
|
|||
PayloadTimestampDefaults,
|
||||
KeySystemRootKeyParamsInterface,
|
||||
} from '@standardnotes/models'
|
||||
import { ContentType, ProtocolVersion } from '@standardnotes/common'
|
||||
import { ProtocolVersion } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
export class DeriveKeySystemRootKeyUseCase {
|
||||
constructor(private readonly crypto: PureCryptoInterface) {}
|
||||
|
|
@ -44,7 +45,7 @@ export class DeriveKeySystemRootKeyUseCase {
|
|||
|
||||
const payload = new DecryptedPayload<KeySystemRootKeyContent>({
|
||||
uuid: uuid,
|
||||
content_type: ContentType.KeySystemRootKey,
|
||||
content_type: ContentType.TYPES.KeySystemRootKey,
|
||||
content: FillItemContentSpecialized(content),
|
||||
...PayloadTimestampDefaults(),
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { CreateAnyKeyParams } from '../../../../Keys/RootKey/KeyParamsFunctions'
|
||||
import { AnyKeyParamsContent, ContentType, ProtocolVersion } from '@standardnotes/common'
|
||||
import { AnyKeyParamsContent, ProtocolVersion } from '@standardnotes/common'
|
||||
import { GenerateAuthenticatedDataUseCase } from './GenerateAuthenticatedData'
|
||||
import {
|
||||
DecryptedPayloadInterface,
|
||||
|
|
@ -8,6 +8,7 @@ import {
|
|||
RootKeyInterface,
|
||||
} from '@standardnotes/models'
|
||||
import { KeySystemItemsKey } from '../../../../Keys/KeySystemItemsKey/KeySystemItemsKey'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
describe('generate authenticated data use case', () => {
|
||||
let usecase: GenerateAuthenticatedDataUseCase
|
||||
|
|
@ -19,7 +20,7 @@ describe('generate authenticated data use case', () => {
|
|||
it('should include key params if payload being encrypted is an items key', () => {
|
||||
const payload = {
|
||||
uuid: '123',
|
||||
content_type: ContentType.ItemsKey,
|
||||
content_type: ContentType.TYPES.ItemsKey,
|
||||
} as jest.Mocked<DecryptedPayloadInterface>
|
||||
|
||||
const keyParams = CreateAnyKeyParams({
|
||||
|
|
@ -42,7 +43,7 @@ describe('generate authenticated data use case', () => {
|
|||
it('should include root key params if payload is a key system items key', () => {
|
||||
const payload = {
|
||||
uuid: '123',
|
||||
content_type: ContentType.KeySystemItemsKey,
|
||||
content_type: ContentType.TYPES.KeySystemItemsKey,
|
||||
shared_vault_uuid: 'shared-vault-uuid-123',
|
||||
key_system_identifier: 'key-system-identifier-123',
|
||||
} as jest.Mocked<DecryptedPayloadInterface>
|
||||
|
|
@ -52,7 +53,7 @@ describe('generate authenticated data use case', () => {
|
|||
keyParams: {
|
||||
seed: 'seed-123',
|
||||
},
|
||||
content_type: ContentType.KeySystemRootKey,
|
||||
content_type: ContentType.TYPES.KeySystemRootKey,
|
||||
token: '123',
|
||||
} as jest.Mocked<KeySystemRootKeyInterface>
|
||||
|
||||
|
|
@ -70,7 +71,7 @@ describe('generate authenticated data use case', () => {
|
|||
it('should include key system identifier and shared vault uuid', () => {
|
||||
const payload = {
|
||||
uuid: '123',
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
shared_vault_uuid: 'shared-vault-uuid-123',
|
||||
key_system_identifier: 'key-system-identifier-123',
|
||||
} as jest.Mocked<DecryptedPayloadInterface>
|
||||
|
|
@ -78,7 +79,7 @@ describe('generate authenticated data use case', () => {
|
|||
const itemsKey = {
|
||||
creationTimestamp: 123,
|
||||
keyVersion: ProtocolVersion.V004,
|
||||
content_type: ContentType.KeySystemItemsKey,
|
||||
content_type: ContentType.TYPES.KeySystemItemsKey,
|
||||
} as jest.Mocked<KeySystemItemsKey>
|
||||
|
||||
const authenticatedData = usecase.execute(payload, itemsKey)
|
||||
|
|
@ -94,11 +95,11 @@ describe('generate authenticated data use case', () => {
|
|||
it('should include only uuid and version if non-keysystem item with items key', () => {
|
||||
const payload = {
|
||||
uuid: '123',
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
} as jest.Mocked<DecryptedPayloadInterface>
|
||||
|
||||
const itemsKey = {
|
||||
content_type: ContentType.ItemsKey,
|
||||
content_type: ContentType.TYPES.ItemsKey,
|
||||
} as jest.Mocked<ItemsKeyInterface>
|
||||
|
||||
const authenticatedData = usecase.execute(payload, itemsKey)
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import { PkcKeyPair, PureCryptoInterface } from '@standardnotes/sncrypto-common'
|
||||
import { getMockedCrypto } from '../../MockedCrypto'
|
||||
import { GenerateDecryptedParametersUseCase } from './GenerateDecryptedParameters'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { DecryptedPayloadInterface, ItemsKeyInterface } from '@standardnotes/models'
|
||||
import { GenerateEncryptedParametersUseCase } from './GenerateEncryptedParameters'
|
||||
import { EncryptedInputParameters, EncryptedOutputParameters } from '../../../../Types/EncryptedParameters'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
describe('generate decrypted parameters usecase', () => {
|
||||
let crypto: PureCryptoInterface
|
||||
|
|
@ -18,7 +18,7 @@ describe('generate decrypted parameters usecase', () => {
|
|||
itemsKey = {
|
||||
uuid: 'items-key-id',
|
||||
itemsKey: 'items-key',
|
||||
content_type: ContentType.ItemsKey,
|
||||
content_type: ContentType.TYPES.ItemsKey,
|
||||
} as jest.Mocked<ItemsKeyInterface>
|
||||
})
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ describe('generate decrypted parameters usecase', () => {
|
|||
content: {
|
||||
text: plaintext,
|
||||
},
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
} as unknown as jest.Mocked<DecryptedPayloadInterface>
|
||||
|
||||
const encryptedParametersUsecase = new GenerateEncryptedParametersUseCase(crypto)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { PkcKeyPair, PureCryptoInterface } from '@standardnotes/sncrypto-common'
|
||||
import { getMockedCrypto } from '../../MockedCrypto'
|
||||
import { AnyKeyParamsContent, ContentType, ProtocolVersion } from '@standardnotes/common'
|
||||
import { AnyKeyParamsContent, ProtocolVersion } from '@standardnotes/common'
|
||||
import { GenerateEncryptedParametersUseCase } from './GenerateEncryptedParameters'
|
||||
import {
|
||||
DecryptedPayloadInterface,
|
||||
|
|
@ -11,6 +11,7 @@ import {
|
|||
import { deconstructEncryptedPayloadString } from '../../V004AlgorithmHelpers'
|
||||
import { ParseConsistentBase64JsonPayloadUseCase } from '../Utils/ParseConsistentBase64JsonPayload'
|
||||
import { SymmetricItemAdditionalData } from '../../../../Types/EncryptionAdditionalData'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
describe('generate encrypted parameters usecase', () => {
|
||||
let crypto: PureCryptoInterface
|
||||
|
|
@ -29,20 +30,20 @@ describe('generate encrypted parameters usecase', () => {
|
|||
title: 'title',
|
||||
text: 'text',
|
||||
},
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
} as unknown as jest.Mocked<DecryptedPayloadInterface>
|
||||
|
||||
const itemsKey = {
|
||||
uuid: 'items-key-id',
|
||||
itemsKey: 'items-key',
|
||||
content_type: ContentType.ItemsKey,
|
||||
content_type: ContentType.TYPES.ItemsKey,
|
||||
} as jest.Mocked<ItemsKeyInterface>
|
||||
|
||||
const result = usecase.execute(decrypted, itemsKey)
|
||||
|
||||
expect(result).toEqual({
|
||||
uuid: '123',
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
items_key_id: 'items-key-id',
|
||||
content: expect.any(String),
|
||||
enc_item_key: expect.any(String),
|
||||
|
|
@ -57,7 +58,7 @@ describe('generate encrypted parameters usecase', () => {
|
|||
content: {
|
||||
foo: 'bar',
|
||||
},
|
||||
content_type: ContentType.ItemsKey,
|
||||
content_type: ContentType.TYPES.ItemsKey,
|
||||
} as unknown as jest.Mocked<DecryptedPayloadInterface>
|
||||
|
||||
const rootKey = {
|
||||
|
|
@ -66,7 +67,7 @@ describe('generate encrypted parameters usecase', () => {
|
|||
keyParams: {
|
||||
content: {} as jest.Mocked<AnyKeyParamsContent>,
|
||||
},
|
||||
content_type: ContentType.RootKey,
|
||||
content_type: ContentType.TYPES.RootKey,
|
||||
} as jest.Mocked<RootKeyInterface>
|
||||
|
||||
const result = usecase.execute(decrypted, rootKey)
|
||||
|
|
@ -80,13 +81,13 @@ describe('generate encrypted parameters usecase', () => {
|
|||
content: {
|
||||
foo: 'bar',
|
||||
},
|
||||
content_type: ContentType.KeySystemItemsKey,
|
||||
content_type: ContentType.TYPES.KeySystemItemsKey,
|
||||
} as unknown as jest.Mocked<DecryptedPayloadInterface>
|
||||
|
||||
const rootKey = {
|
||||
uuid: 'items-key-id',
|
||||
itemsKey: 'items-key',
|
||||
content_type: ContentType.KeySystemRootKey,
|
||||
content_type: ContentType.TYPES.KeySystemRootKey,
|
||||
} as jest.Mocked<KeySystemRootKeyInterface>
|
||||
|
||||
const result = usecase.execute(decrypted, rootKey)
|
||||
|
|
@ -111,13 +112,13 @@ describe('generate encrypted parameters usecase', () => {
|
|||
title: 'title',
|
||||
text: 'text',
|
||||
},
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
} as unknown as jest.Mocked<DecryptedPayloadInterface>
|
||||
|
||||
const itemsKey = {
|
||||
uuid: 'items-key-id',
|
||||
itemsKey: 'items-key',
|
||||
content_type: ContentType.ItemsKey,
|
||||
content_type: ContentType.TYPES.ItemsKey,
|
||||
} as jest.Mocked<ItemsKeyInterface>
|
||||
|
||||
const result = usecase.execute(decrypted, itemsKey, signingKeyPair)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import { ContentType, ProtocolVersion } from '@standardnotes/common'
|
||||
import { ProtocolVersion } from '@standardnotes/common'
|
||||
import { EncryptedPayloadInterface, DecryptedPayloadInterface, PersistentSignatureData } from '@standardnotes/models'
|
||||
import { DecryptedParameters } from './DecryptedParameters'
|
||||
|
||||
export type EncryptedOutputParameters = {
|
||||
uuid: string
|
||||
content: string
|
||||
content_type: ContentType
|
||||
content_type: string
|
||||
items_key_id: string | undefined
|
||||
enc_item_key: string
|
||||
version: ProtocolVersion
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@
|
|||
"test": "jest"
|
||||
},
|
||||
"dependencies": {
|
||||
"@standardnotes/common": "^1.48.3",
|
||||
"@standardnotes/domain-core": "^1.12.0",
|
||||
"@standardnotes/common": "^1.50.0",
|
||||
"@standardnotes/domain-core": "^1.22.0",
|
||||
"@standardnotes/security": "^1.7.6",
|
||||
"reflect-metadata": "^0.1.13"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
import { ComponentAction } from './ComponentAction'
|
||||
|
||||
export type ComponentPermission = {
|
||||
name: ComponentAction
|
||||
content_types?: ContentType[]
|
||||
content_types?: string[]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { ComponentPermission } from '../Component/ComponentPermission'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ComponentArea } from '../Component/ComponentArea'
|
||||
import { PermissionName } from '../Permission/PermissionName'
|
||||
import { FeatureIdentifier } from './FeatureIdentifier'
|
||||
|
|
@ -51,7 +50,7 @@ export type ClientFeatureDescription = RoleFields & {
|
|||
export type ComponentFeatureDescription = BaseFeatureDescription & {
|
||||
/** The relative path of the index.html file or the main css file if theme, within the component folder itself */
|
||||
index_path: string
|
||||
content_type: ContentType
|
||||
content_type: string
|
||||
area: ComponentArea
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentType, RoleName } from '@standardnotes/domain-core'
|
||||
import {
|
||||
EditorFeatureDescription,
|
||||
IframeComponentFeatureDescription,
|
||||
|
|
@ -10,7 +10,6 @@ import { NoteType } from '../Component/NoteType'
|
|||
import { FillEditorComponentDefaults } from './Utilities/FillEditorComponentDefaults'
|
||||
import { ComponentAction } from '../Component/ComponentAction'
|
||||
import { ComponentArea } from '../Component/ComponentArea'
|
||||
import { RoleName } from '@standardnotes/domain-core'
|
||||
|
||||
export function GetDeprecatedFeatures(): FeatureDescription[] {
|
||||
const bold: EditorFeatureDescription = FillEditorComponentDefaults({
|
||||
|
|
@ -21,14 +20,14 @@ export function GetDeprecatedFeatures(): FeatureDescription[] {
|
|||
component_permissions: [
|
||||
{
|
||||
name: ComponentAction.StreamContextItem,
|
||||
content_types: [ContentType.Note],
|
||||
content_types: [ContentType.TYPES.Note],
|
||||
},
|
||||
{
|
||||
name: ComponentAction.StreamItems,
|
||||
content_types: [
|
||||
ContentType.FilesafeCredentials,
|
||||
ContentType.FilesafeFileMetadata,
|
||||
ContentType.FilesafeIntegration,
|
||||
ContentType.TYPES.FilesafeCredentials,
|
||||
ContentType.TYPES.FilesafeFileMetadata,
|
||||
ContentType.TYPES.FilesafeIntegration,
|
||||
],
|
||||
},
|
||||
],
|
||||
|
|
@ -101,14 +100,14 @@ export function GetDeprecatedFeatures(): FeatureDescription[] {
|
|||
component_permissions: [
|
||||
{
|
||||
name: ComponentAction.StreamContextItem,
|
||||
content_types: [ContentType.Note],
|
||||
content_types: [ContentType.TYPES.Note],
|
||||
},
|
||||
{
|
||||
name: ComponentAction.StreamItems,
|
||||
content_types: [
|
||||
ContentType.FilesafeCredentials,
|
||||
ContentType.FilesafeFileMetadata,
|
||||
ContentType.FilesafeIntegration,
|
||||
ContentType.TYPES.FilesafeCredentials,
|
||||
ContentType.TYPES.FilesafeFileMetadata,
|
||||
ContentType.TYPES.FilesafeIntegration,
|
||||
],
|
||||
},
|
||||
],
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
import { ComponentAction } from '../../Component/ComponentAction'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { EditorFeatureDescription } from '../../Feature/FeatureDescription'
|
||||
import { ComponentArea } from '../../Component/ComponentArea'
|
||||
|
||||
|
|
@ -16,12 +17,12 @@ export function FillEditorComponentDefaults(
|
|||
component.component_permissions = [
|
||||
{
|
||||
name: ComponentAction.StreamContextItem,
|
||||
content_types: [ContentType.Note],
|
||||
content_types: [ContentType.TYPES.Note],
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
component.content_type = ContentType.Component
|
||||
component.content_type = ContentType.TYPES.Component
|
||||
if (!component.area) {
|
||||
component.area = ComponentArea.Editor
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
import { ThemeFeatureDescription } from '../../Feature/FeatureDescription'
|
||||
import { ComponentArea } from '../../Component/ComponentArea'
|
||||
|
||||
|
|
@ -11,7 +12,7 @@ export function FillThemeComponentDefaults(
|
|||
theme.index_path = 'index.css'
|
||||
}
|
||||
|
||||
theme.content_type = ContentType.Theme
|
||||
theme.content_type = ContentType.TYPES.Theme
|
||||
|
||||
if (!theme.area) {
|
||||
theme.area = ComponentArea.Themes
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ export class ClassicFileApi {
|
|||
downloadFileBytes = async (remoteIdentifier: string): Promise<Uint8Array> => {
|
||||
console.log('Downloading file', remoteIdentifier)
|
||||
const file = this.application['itemManager']
|
||||
.getItems(ContentType.File)
|
||||
.getItems(ContentType.TYPES.File)
|
||||
.find((file: FileItem) => file.remoteIdentifier === remoteIdentifier)
|
||||
|
||||
let receivedBytes = new Uint8Array()
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
"typescript": "*"
|
||||
},
|
||||
"dependencies": {
|
||||
"@standardnotes/common": "^1.48.3",
|
||||
"@standardnotes/common": "^1.50.0",
|
||||
"@standardnotes/files": "workspace:*",
|
||||
"@standardnotes/utils": "workspace:*",
|
||||
"@types/wicg-file-system-access": "^2020.9.5",
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
"typescript": "*"
|
||||
},
|
||||
"dependencies": {
|
||||
"@standardnotes/common": "^1.48.3",
|
||||
"@standardnotes/common": "^1.50.0",
|
||||
"@standardnotes/encryption": "workspace:*",
|
||||
"@standardnotes/models": "workspace:*",
|
||||
"@standardnotes/responses": "workspace:*",
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@
|
|||
"test": "jest"
|
||||
},
|
||||
"dependencies": {
|
||||
"@standardnotes/common": "^1.48.3",
|
||||
"@standardnotes/common": "^1.50.0",
|
||||
"@standardnotes/domain-core": "^1.22.0",
|
||||
"@standardnotes/features": "workspace:*",
|
||||
"@standardnotes/responses": "workspace:*",
|
||||
"@standardnotes/sncrypto-common": "workspace:^",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
import { ComponentPermission } from '@standardnotes/features'
|
||||
|
||||
import { IncomingComponentItemPayload } from './IncomingComponentItemPayload'
|
||||
|
|
@ -8,7 +7,7 @@ export type MessageData = Partial<{
|
|||
/** Related to the stream-item-context action */
|
||||
item?: IncomingComponentItemPayload
|
||||
/** Related to the stream-items action */
|
||||
content_types?: ContentType[]
|
||||
content_types?: string[]
|
||||
items?: IncomingComponentItemPayload[]
|
||||
/** Related to the request-permission action */
|
||||
permissions?: ComponentPermission[]
|
||||
|
|
@ -25,7 +24,7 @@ export type MessageData = Partial<{
|
|||
/** Related to themes action */
|
||||
themes?: string[]
|
||||
/** Related to clear-selection action */
|
||||
content_type?: ContentType
|
||||
content_type?: string
|
||||
/** Related to key-pressed action */
|
||||
keyboardModifier?: KeyboardModifier
|
||||
}>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
import { ItemContent } from './../Content/ItemContent'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
|
||||
export type OutgoingItemMessagePayload<C extends ItemContent = ItemContent> = {
|
||||
uuid: string
|
||||
content_type: ContentType
|
||||
content_type: string
|
||||
created_at: Date
|
||||
updated_at: Date
|
||||
deleted?: boolean
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
import { ItemContent } from '../Content/ItemContent'
|
||||
|
||||
export interface ContextPayload<C extends ItemContent = ItemContent> {
|
||||
uuid: string
|
||||
content_type: ContentType
|
||||
content_type: string
|
||||
content: C | string | undefined
|
||||
deleted: boolean
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
import { DecryptedPayloadInterface, DeletedPayloadInterface, isDeletedPayload } from '../Payload'
|
||||
|
||||
/**
|
||||
|
|
@ -8,7 +7,7 @@ import { DecryptedPayloadInterface, DeletedPayloadInterface, isDeletedPayload }
|
|||
* nothing else.
|
||||
*/
|
||||
export interface OfflineSyncSavedContextualPayload {
|
||||
content_type: ContentType
|
||||
content_type: string
|
||||
created_at_timestamp: number
|
||||
deleted: boolean
|
||||
updated_at_timestamp?: number
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import { useBoolean } from '@standardnotes/utils'
|
||||
import { FilteredServerItem } from './FilteredServerItem'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
|
||||
/**
|
||||
* The saved sync item payload represents the payload we want to map
|
||||
|
|
@ -9,7 +8,7 @@ import { ContentType } from '@standardnotes/common'
|
|||
* nothing else.
|
||||
*/
|
||||
export interface ServerSyncSavedContextualPayload {
|
||||
content_type: ContentType
|
||||
content_type: string
|
||||
created_at_timestamp: number
|
||||
created_at: Date
|
||||
deleted: boolean
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
import { dateToLocalizedString, deepFreeze } from '@standardnotes/utils'
|
||||
import { TransferPayload } from './../../TransferPayload/Interfaces/TransferPayload'
|
||||
import { ItemContentsDiffer } from '../../../Utilities/Item/ItemContentsDiffer'
|
||||
|
|
@ -36,7 +35,7 @@ export abstract class GenericItem<P extends PayloadInterface = PayloadInterface>
|
|||
return this.payload.uuid
|
||||
}
|
||||
|
||||
get content_type(): ContentType {
|
||||
get content_type(): string {
|
||||
return this.payload.content_type
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
import { TransferPayload } from './../../TransferPayload/Interfaces/TransferPayload'
|
||||
import { PayloadInterface } from '../../Payload/Interfaces/PayloadInterface'
|
||||
import { PredicateInterface } from '../../../Runtime/Predicate/Interface'
|
||||
|
|
@ -21,7 +20,7 @@ export interface ItemInterface<P extends PayloadInterface = PayloadInterface> {
|
|||
get last_edited_by_uuid(): string | undefined
|
||||
get signatureData(): PersistentSignatureData | undefined
|
||||
|
||||
content_type: ContentType
|
||||
content_type: string
|
||||
created_at: Date
|
||||
serverUpdatedAt: Date
|
||||
serverUpdatedAtTimestamp: number | undefined
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
import { deepFreeze, useBoolean } from '@standardnotes/utils'
|
||||
import { PayloadInterface } from '../Interfaces/PayloadInterface'
|
||||
import { PayloadSource } from '../Types/PayloadSource'
|
||||
|
|
@ -19,7 +18,7 @@ export abstract class PurePayload<T extends TransferPayload<C>, C extends ItemCo
|
|||
{
|
||||
readonly source: PayloadSource
|
||||
readonly uuid: string
|
||||
readonly content_type: ContentType
|
||||
readonly content_type: string
|
||||
readonly deleted: boolean
|
||||
readonly content: C | string | undefined
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { SyncResolvedParams, SyncResolvedPayload } from './../../../Runtime/Deltas/Utilities/SyncResolvedPayload'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ItemContent } from '../../Content/ItemContent'
|
||||
import { TransferPayload } from '../../TransferPayload/Interfaces/TransferPayload'
|
||||
import { PayloadSource } from '../Types/PayloadSource'
|
||||
|
|
@ -8,7 +7,7 @@ import { PersistentSignatureData } from '../../../Runtime/Encryption/PersistentS
|
|||
export interface PayloadInterface<T extends TransferPayload = TransferPayload, C extends ItemContent = ItemContent> {
|
||||
readonly source: PayloadSource
|
||||
readonly uuid: string
|
||||
readonly content_type: ContentType
|
||||
readonly content_type: string
|
||||
content: C | string | undefined
|
||||
deleted: boolean
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentReferenceType } from './ContenteReferenceType'
|
||||
|
||||
export interface AnonymousReference {
|
||||
uuid: string
|
||||
content_type: ContentType
|
||||
content_type: string
|
||||
reference_type: ContentReferenceType
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
import { AnonymousReference } from './AnonymousReference'
|
||||
import { ContentReferenceType } from './ContenteReferenceType'
|
||||
|
||||
export interface FileToFileReference extends AnonymousReference {
|
||||
content_type: ContentType.File
|
||||
content_type: string
|
||||
reference_type: ContentReferenceType.FileToFile
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
import { AnonymousReference } from './AnonymousReference'
|
||||
import { ContentReferenceType } from './ContenteReferenceType'
|
||||
|
||||
export interface FileToNoteReference extends AnonymousReference {
|
||||
content_type: ContentType.Note
|
||||
content_type: string
|
||||
reference_type: ContentReferenceType.FileToNote
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
import { ItemInterface } from '../Item/Interfaces/ItemInterface'
|
||||
import { ContentReferenceType } from './ContenteReferenceType'
|
||||
import { ContentReference } from './ContentReference'
|
||||
|
|
@ -20,8 +20,8 @@ export const isLegacyTagToNoteReference = (
|
|||
x: LegacyAnonymousReference,
|
||||
currentItem: ItemInterface,
|
||||
): x is LegacyTagToNoteReference => {
|
||||
const isReferenceToANote = x.content_type === ContentType.Note
|
||||
const isReferenceFromATag = currentItem.content_type === ContentType.Tag
|
||||
const isReferenceToANote = x.content_type === ContentType.TYPES.Note
|
||||
const isReferenceFromATag = currentItem.content_type === ContentType.TYPES.Tag
|
||||
return isReferenceToANote && isReferenceFromATag
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
import { LegacyAnonymousReference } from './LegacyAnonymousReference'
|
||||
|
||||
export interface LegacyTagToNoteReference extends LegacyAnonymousReference {
|
||||
content_type: ContentType.Note
|
||||
content_type: string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
import { AnonymousReference } from './AnonymousReference'
|
||||
import { ContentReferenceType } from './ContenteReferenceType'
|
||||
|
||||
export interface NoteToNoteReference extends AnonymousReference {
|
||||
content_type: ContentType.Note
|
||||
content_type: string
|
||||
reference_type: ContentReferenceType.NoteToNote
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
import { AnonymousReference } from './AnonymousReference'
|
||||
import { ContentReferenceType } from './ContenteReferenceType'
|
||||
|
||||
export interface TagToFileReference extends AnonymousReference {
|
||||
content_type: ContentType.File
|
||||
content_type: string
|
||||
reference_type: ContentReferenceType.TagToFile
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
import { AnonymousReference } from './AnonymousReference'
|
||||
import { ContentReferenceType } from './ContenteReferenceType'
|
||||
|
||||
export interface TagToParentTagReference extends AnonymousReference {
|
||||
content_type: ContentType.Tag
|
||||
content_type: string
|
||||
reference_type: ContentReferenceType.TagToParentTag
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
import { ItemContent } from '../../Content/ItemContent'
|
||||
import { PersistentSignatureData } from '../../../Runtime/Encryption/PersistentSignatureData'
|
||||
|
||||
export interface TransferPayload<C extends ItemContent = ItemContent> {
|
||||
uuid: string
|
||||
content_type: ContentType
|
||||
content_type: string
|
||||
content: C | string | undefined
|
||||
deleted?: boolean
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { PayloadTimestampDefaults } from '../../Payload'
|
||||
import { isCorruptTransferPayload } from './TypeCheck'
|
||||
|
||||
|
|
@ -8,7 +8,7 @@ describe('type check', () => {
|
|||
expect(
|
||||
isCorruptTransferPayload({
|
||||
uuid: '123',
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: '123',
|
||||
...PayloadTimestampDefaults(),
|
||||
}),
|
||||
|
|
@ -19,7 +19,7 @@ describe('type check', () => {
|
|||
expect(
|
||||
isCorruptTransferPayload({
|
||||
uuid: undefined as never,
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: '123',
|
||||
...PayloadTimestampDefaults(),
|
||||
}),
|
||||
|
|
@ -30,7 +30,7 @@ describe('type check', () => {
|
|||
expect(
|
||||
isCorruptTransferPayload({
|
||||
uuid: '123',
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: '123',
|
||||
deleted: true,
|
||||
...PayloadTimestampDefaults(),
|
||||
|
|
@ -42,7 +42,7 @@ describe('type check', () => {
|
|||
expect(
|
||||
isCorruptTransferPayload({
|
||||
uuid: '123',
|
||||
content_type: ContentType.Unknown,
|
||||
content_type: ContentType.TYPES.Unknown,
|
||||
content: '123',
|
||||
...PayloadTimestampDefaults(),
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { isObject, isString } from '@standardnotes/utils'
|
||||
import { DecryptedTransferPayload } from './DecryptedTransferPayload'
|
||||
import { DeletedTransferPayload } from './DeletedTransferPayload'
|
||||
|
|
@ -26,5 +26,5 @@ export function isDeletedTransferPayload(payload: TransferPayload): payload is D
|
|||
export function isCorruptTransferPayload(payload: TransferPayload): boolean {
|
||||
const invalidDeletedState = payload.deleted === true && payload.content != undefined
|
||||
|
||||
return payload.uuid == undefined || invalidDeletedState || payload.content_type === ContentType.Unknown
|
||||
return payload.uuid == undefined || invalidDeletedState || payload.content_type === ContentType.TYPES.Unknown
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
import { extendArray, isObject, isString, UuidMap } from '@standardnotes/utils'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { remove } from 'lodash'
|
||||
import { ItemContent } from '../../Abstract/Content/ItemContent'
|
||||
import { ContentReference } from '../../Abstract/Item'
|
||||
|
||||
export interface CollectionElement {
|
||||
uuid: string
|
||||
content_type: ContentType
|
||||
content_type: string
|
||||
dirty?: boolean
|
||||
deleted?: boolean
|
||||
}
|
||||
|
|
@ -33,7 +32,7 @@ export abstract class Collection<
|
|||
Deleted extends DeletedCollectionElement,
|
||||
> {
|
||||
readonly map: Partial<Record<string, Element>> = {}
|
||||
readonly typedMap: Partial<Record<ContentType, Element[]>> = {}
|
||||
readonly typedMap: Partial<Record<string, Element[]>> = {}
|
||||
|
||||
/** An array of uuids of items that are dirty */
|
||||
dirtyIndex: Set<string> = new Set()
|
||||
|
|
@ -74,7 +73,7 @@ export abstract class Collection<
|
|||
constructor(
|
||||
copy = false,
|
||||
mapCopy?: Partial<Record<string, Element>>,
|
||||
typedMapCopy?: Partial<Record<ContentType, Element[]>>,
|
||||
typedMapCopy?: Partial<Record<string, Element[]>>,
|
||||
referenceMapCopy?: UuidMap,
|
||||
conflictMapCopy?: UuidMap,
|
||||
) {
|
||||
|
|
@ -93,7 +92,7 @@ export abstract class Collection<
|
|||
return Object.keys(this.map)
|
||||
}
|
||||
|
||||
public all(contentType?: ContentType | ContentType[]): Element[] {
|
||||
public all(contentType?: string | string[]): Element[] {
|
||||
if (contentType) {
|
||||
if (Array.isArray(contentType)) {
|
||||
const elements: Element[] = []
|
||||
|
|
@ -254,7 +253,7 @@ export abstract class Collection<
|
|||
return this.findAll(uuids)
|
||||
}
|
||||
|
||||
public elementsReferencingElement(element: Decrypted, contentType?: ContentType): Element[] {
|
||||
public elementsReferencingElement(element: Decrypted, contentType?: string): Element[] {
|
||||
const uuids = this.uuidsThatReferenceUuid(element.uuid)
|
||||
const items = this.findAll(uuids)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
|
||||
export interface SortableItem {
|
||||
uuid: string
|
||||
content_type: ContentType
|
||||
content_type: string
|
||||
created_at: Date
|
||||
userModifiedDate: Date
|
||||
title?: string
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { NoteContent } from './../../../Syncable/Note/NoteContent'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { DecryptedItem } from '../../../Abstract/Item'
|
||||
import { DecryptedPayload, PayloadTimestampDefaults } from '../../../Abstract/Payload'
|
||||
import { ItemCollection } from './ItemCollection'
|
||||
|
|
@ -9,7 +9,7 @@ describe('item collection', () => {
|
|||
const createDecryptedPayload = (uuid?: string, content?: Partial<NoteContent>): DecryptedPayload => {
|
||||
return new DecryptedPayload({
|
||||
uuid: uuid || String(Math.random()),
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: FillItemContent<NoteContent>({
|
||||
title: 'foo',
|
||||
...content,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import { ItemContent } from './../../../Abstract/Content/ItemContent'
|
||||
import { EncryptedItemInterface } from './../../../Abstract/Item/Interfaces/EncryptedItem'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { SNIndex } from '../../Index/SNIndex'
|
||||
import { isDecryptedItem } from '../../../Abstract/Item/Interfaces/TypeCheck'
|
||||
import { DecryptedItemInterface } from '../../../Abstract/Item/Interfaces/DecryptedItem'
|
||||
|
|
@ -53,7 +52,7 @@ export class ItemCollection
|
|||
return mapped as (DecryptedItemInterface<C> | undefined)[]
|
||||
}
|
||||
|
||||
public allDecrypted<T extends DecryptedItemInterface>(contentType: ContentType | ContentType[]): T[] {
|
||||
public allDecrypted<T extends DecryptedItemInterface>(contentType: string | string[]): T[] {
|
||||
return this.all(contentType).filter(isDecryptedItem) as T[]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { ItemCounter } from './ItemCounter'
|
||||
import { NoteContent } from '../../../Syncable/Note/NoteContent'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { DecryptedItem, EncryptedItem } from '../../../Abstract/Item'
|
||||
import { DecryptedPayload, EncryptedPayload, PayloadTimestampDefaults } from '../../../Abstract/Payload'
|
||||
import { ItemCollection } from './ItemCollection'
|
||||
|
|
@ -12,7 +12,7 @@ describe('tag notes index', () => {
|
|||
const createEncryptedItem = (uuid?: string) => {
|
||||
const payload = new EncryptedPayload({
|
||||
uuid: uuid || String(Math.random()),
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: '004:...',
|
||||
enc_item_key: '004:...',
|
||||
items_key_id: '123',
|
||||
|
|
@ -24,7 +24,7 @@ describe('tag notes index', () => {
|
|||
return new EncryptedItem(payload)
|
||||
}
|
||||
|
||||
const createDecryptedItem = (uuid?: string, content_type = ContentType.Note) => {
|
||||
const createDecryptedItem = (uuid?: string, content_type = ContentType.TYPES.Note) => {
|
||||
const payload = new DecryptedPayload({
|
||||
uuid: uuid || String(Math.random()),
|
||||
content_type,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { removeFromArray } from '@standardnotes/utils'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { isTag, SNTag } from '../../../Syncable/Tag/Tag'
|
||||
import { SNIndex } from '../../Index/SNIndex'
|
||||
import { ItemCollection } from './ItemCollection'
|
||||
|
|
@ -13,6 +12,7 @@ import { HiddenContentCriteriaValidator } from '../../Display/Validator/HiddenCo
|
|||
import { CustomFilterCriteriaValidator } from '../../Display/Validator/CustomFilterCriteriaValidator'
|
||||
import { AnyDisplayOptions, VaultDisplayOptions } from '../../Display'
|
||||
import { isExclusioanaryOptionsValue } from '../../Display/VaultDisplayOptionsTypes'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
type AllNotesUuidSignifier = undefined
|
||||
export type TagItemCountChangeObserver = (tagUuid: string | AllNotesUuidSignifier) => void
|
||||
|
|
@ -20,7 +20,7 @@ export type TagItemCountChangeObserver = (tagUuid: string | AllNotesUuidSignifie
|
|||
export class ItemCounter implements SNIndex {
|
||||
private tagToItemsMap: Partial<Record<string, Set<string>>> = {}
|
||||
private allCountableItems = new Set<string>()
|
||||
private countableItemsByType = new Map<ContentType, Set<string>>()
|
||||
private countableItemsByType = new Map<string, Set<string>>()
|
||||
private displayOptions?: AnyDisplayOptions
|
||||
private vaultDisplayOptions?: VaultDisplayOptions
|
||||
|
||||
|
|
@ -50,11 +50,11 @@ export class ItemCounter implements SNIndex {
|
|||
}
|
||||
|
||||
public allCountableNotesCount(): number {
|
||||
return this.countableItemsByType.get(ContentType.Note)?.size || 0
|
||||
return this.countableItemsByType.get(ContentType.TYPES.Note)?.size || 0
|
||||
}
|
||||
|
||||
public allCountableFilesCount(): number {
|
||||
return this.countableItemsByType.get(ContentType.File)?.size || 0
|
||||
return this.countableItemsByType.get(ContentType.TYPES.File)?.size || 0
|
||||
}
|
||||
|
||||
public countableItemsForTag(tag: SNTag): number {
|
||||
|
|
@ -63,7 +63,7 @@ export class ItemCounter implements SNIndex {
|
|||
|
||||
public onChange(delta: ItemDelta): void {
|
||||
const items = [...delta.changed, ...delta.inserted, ...delta.discarded].filter(
|
||||
(i) => i.content_type === ContentType.Note || i.content_type === ContentType.File,
|
||||
(i) => i.content_type === ContentType.TYPES.Note || i.content_type === ContentType.TYPES.File,
|
||||
)
|
||||
const tags = [...delta.changed, ...delta.inserted].filter(isDecryptedItem).filter(isTag)
|
||||
|
||||
|
|
@ -115,7 +115,7 @@ export class ItemCounter implements SNIndex {
|
|||
private receiveTagChanges(tags: SNTag[]): void {
|
||||
for (const tag of tags) {
|
||||
const uuids = tag.references
|
||||
.filter((ref) => ref.content_type === ContentType.Note || ref.content_type === ContentType.File)
|
||||
.filter((ref) => ref.content_type === ContentType.TYPES.Note || ref.content_type === ContentType.TYPES.File)
|
||||
.map((ref) => ref.uuid)
|
||||
const countableUuids = uuids.filter((uuid) => this.allCountableItems.has(uuid))
|
||||
const previousSet = this.tagToItemsMap[tag.uuid]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { FullyFormedPayloadInterface } from './../../../Abstract/Payload/Interfaces/UnionTypes'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { UuidMap } from '@standardnotes/utils'
|
||||
import { PayloadCollection } from './PayloadCollection'
|
||||
|
||||
|
|
@ -33,7 +32,7 @@ export class ImmutablePayloadCollection<
|
|||
const result = new ImmutablePayloadCollection<T>(
|
||||
true,
|
||||
mapCopy,
|
||||
typedMapCopy as Partial<Record<ContentType, T[]>>,
|
||||
typedMapCopy as Partial<Record<string, T[]>>,
|
||||
referenceMapCopy,
|
||||
conflictMapCopy,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { FillItemContent } from '../../Abstract/Content/ItemContent'
|
||||
import { ConflictStrategy } from '../../Abstract/Item'
|
||||
import {
|
||||
|
|
@ -25,7 +25,7 @@ describe('conflict delta', () => {
|
|||
const createDecryptedItemsKey = (uuid: string, key: string, timestamp = 0) => {
|
||||
return new DecryptedPayload<ItemsKeyContent>({
|
||||
uuid: uuid,
|
||||
content_type: ContentType.ItemsKey,
|
||||
content_type: ContentType.TYPES.ItemsKey,
|
||||
content: FillItemContent<ItemsKeyContent>({
|
||||
itemsKey: key,
|
||||
}),
|
||||
|
|
@ -37,7 +37,7 @@ describe('conflict delta', () => {
|
|||
const createErroredItemsKey = (uuid: string, timestamp = 0) => {
|
||||
return new EncryptedPayload({
|
||||
uuid: uuid,
|
||||
content_type: ContentType.ItemsKey,
|
||||
content_type: ContentType.TYPES.ItemsKey,
|
||||
content: '004:...',
|
||||
enc_item_key: '004:...',
|
||||
items_key_id: undefined,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { uniqCombineObjArrays } from '@standardnotes/utils'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { ImmutablePayloadCollection } from '../Collection/Payload/ImmutablePayloadCollection'
|
||||
import { CreateDecryptedItemFromPayload, CreateItemFromPayload } from '../../Utilities/Item/ItemGenerator'
|
||||
import { HistoryMap, historyMapFunctions } from '../History/HistoryMap'
|
||||
|
|
@ -11,7 +12,6 @@ import {
|
|||
isErrorDecryptingPayload,
|
||||
isDeletedPayload,
|
||||
} from '../../Abstract/Payload/Interfaces/TypeCheck'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { SyncResolvedPayload } from './Utilities/SyncResolvedPayload'
|
||||
import { ItemsKeyDelta } from './ItemsKeyDelta'
|
||||
import { SourcelessSyncDeltaEmit } from './Abstract/DeltaEmit'
|
||||
|
|
@ -26,7 +26,7 @@ export class ConflictDelta {
|
|||
) {}
|
||||
|
||||
public result(): SourcelessSyncDeltaEmit {
|
||||
if (this.applyPayload.content_type === ContentType.ItemsKey) {
|
||||
if (this.applyPayload.content_type === ContentType.TYPES.ItemsKey) {
|
||||
const keyDelta = new ItemsKeyDelta(this.baseCollection, [this.applyPayload])
|
||||
|
||||
return keyDelta.result()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { FillItemContent } from '../../Abstract/Content/ItemContent'
|
||||
import {
|
||||
DecryptedPayload,
|
||||
|
|
@ -16,7 +16,7 @@ describe('items key delta', () => {
|
|||
const baseCollection = new PayloadCollection()
|
||||
const basePayload = new DecryptedPayload<ItemsKeyContent>({
|
||||
uuid: '123',
|
||||
content_type: ContentType.ItemsKey,
|
||||
content_type: ContentType.TYPES.ItemsKey,
|
||||
content: FillItemContent<ItemsKeyContent>({
|
||||
itemsKey: 'secret',
|
||||
}),
|
||||
|
|
@ -28,7 +28,7 @@ describe('items key delta', () => {
|
|||
|
||||
const payloadToIgnore = new EncryptedPayload({
|
||||
uuid: '123',
|
||||
content_type: ContentType.ItemsKey,
|
||||
content_type: ContentType.TYPES.ItemsKey,
|
||||
content: '004:...',
|
||||
enc_item_key: '004:...',
|
||||
items_key_id: undefined,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { PayloadEmitSource } from '../../Abstract/Payload'
|
|||
import { isDecryptedPayload } from '../../Abstract/Payload/Interfaces/TypeCheck'
|
||||
import { PayloadContentsEqual } from '../../Utilities/Payload/PayloadContentsEqual'
|
||||
import { ConflictDelta } from './Conflict'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { ItemsKeyDelta } from './ItemsKeyDelta'
|
||||
import { payloadByFinalizingSyncState } from './Utilities/ApplyDirtyState'
|
||||
import { ImmutablePayloadCollection } from '../Collection/Payload/ImmutablePayloadCollection'
|
||||
|
|
@ -25,7 +25,7 @@ export class DeltaOutOfSync implements SyncDeltaInterface {
|
|||
}
|
||||
|
||||
for (const apply of this.applyCollection.all()) {
|
||||
if (apply.content_type === ContentType.ItemsKey) {
|
||||
if (apply.content_type === ContentType.TYPES.ItemsKey) {
|
||||
const itemsKeyDeltaEmit = new ItemsKeyDelta(this.baseCollection, [apply]).result()
|
||||
|
||||
extendSyncDelta(result, itemsKeyDeltaEmit)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { FillItemContent } from '../../Abstract/Content/ItemContent'
|
||||
import { DecryptedPayload, FullyFormedPayloadInterface, PayloadTimestampDefaults } from '../../Abstract/Payload'
|
||||
import { NoteContent } from '../../Syncable/Note'
|
||||
|
|
@ -15,7 +15,7 @@ describe('remote rejected delta', () => {
|
|||
const baseCollection = new PayloadCollection()
|
||||
const basePayload = new DecryptedPayload<NoteContent>({
|
||||
uuid: '123',
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
dirty: true,
|
||||
content: FillItemContent<NoteContent>({
|
||||
title: 'foo',
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import {
|
|||
ConflictType,
|
||||
} from '@standardnotes/responses'
|
||||
import { PayloadsByDuplicating } from '../../Utilities/Payload/PayloadsByDuplicating'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
export class DeltaRemoteRejected implements SyncDeltaInterface {
|
||||
constructor(
|
||||
|
|
@ -61,7 +61,7 @@ export class DeltaRemoteRejected implements SyncDeltaInterface {
|
|||
return this.resultByDuplicatingBasePayloadAsNonVaultedAndRemovingBaseItemLocally(base)
|
||||
}
|
||||
|
||||
if (base.content_type === ContentType.KeySystemItemsKey) {
|
||||
if (base.content_type === ContentType.TYPES.KeySystemItemsKey) {
|
||||
return this.discardChangesOfBasePayload(base)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { FillItemContent } from '../../Abstract/Content/ItemContent'
|
||||
import {
|
||||
DecryptedPayload,
|
||||
|
|
@ -16,7 +16,7 @@ describe('remote retrieved delta', () => {
|
|||
const baseCollection = new PayloadCollection()
|
||||
const basePayload = new DecryptedPayload<ItemsKeyContent>({
|
||||
uuid: '123',
|
||||
content_type: ContentType.ItemsKey,
|
||||
content_type: ContentType.TYPES.ItemsKey,
|
||||
content: FillItemContent<ItemsKeyContent>({
|
||||
itemsKey: 'secret',
|
||||
}),
|
||||
|
|
@ -28,7 +28,7 @@ describe('remote retrieved delta', () => {
|
|||
|
||||
const payloadToIgnore = new EncryptedPayload({
|
||||
uuid: '123',
|
||||
content_type: ContentType.ItemsKey,
|
||||
content_type: ContentType.TYPES.ItemsKey,
|
||||
content: '004:...',
|
||||
enc_item_key: '004:...',
|
||||
items_key_id: undefined,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { ImmutablePayloadCollection } from './../Collection/Payload/ImmutablePay
|
|||
import { ConflictDelta } from './Conflict'
|
||||
import { isErrorDecryptingPayload, isDecryptedPayload } from '../../Abstract/Payload/Interfaces/TypeCheck'
|
||||
import { FullyFormedPayloadInterface, PayloadEmitSource } from '../../Abstract/Payload'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { HistoryMap } from '../History'
|
||||
import { ServerSyncPushContextualPayload } from '../../Abstract/Contextual/ServerSyncPush'
|
||||
import { payloadByFinalizingSyncState } from './Utilities/ApplyDirtyState'
|
||||
|
|
@ -36,7 +36,10 @@ export class DeltaRemoteRetrieved implements SyncDeltaInterface {
|
|||
* or if the item is locally dirty, filter it out of retrieved_items, and add to potential conflicts.
|
||||
*/
|
||||
for (const apply of this.applyCollection.all()) {
|
||||
if (apply.content_type === ContentType.ItemsKey || apply.content_type === ContentType.KeySystemItemsKey) {
|
||||
if (
|
||||
apply.content_type === ContentType.TYPES.ItemsKey ||
|
||||
apply.content_type === ContentType.TYPES.KeySystemItemsKey
|
||||
) {
|
||||
const itemsKeyDeltaEmit = new ItemsKeyDelta(this.baseCollection, [apply]).result()
|
||||
|
||||
extendSyncDelta(result, itemsKeyDeltaEmit)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
import { SmartView } from '../../Syncable/SmartView'
|
||||
import { SNTag } from '../../Syncable/Tag'
|
||||
import { CollectionSortDirection, CollectionSortProperty } from '../Collection/CollectionSort'
|
||||
|
|
@ -16,7 +15,7 @@ export interface NotesAndFilesDisplayOptions extends GenericDisplayOptions {
|
|||
tags?: SNTag[]
|
||||
views?: SmartView[]
|
||||
searchQuery?: SearchQuery
|
||||
hiddenContentTypes?: ContentType[]
|
||||
hiddenContentTypes?: string[]
|
||||
customFilter?: DisplayControllerCustomFilter
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
import { DecryptedItem } from '../../Abstract/Item'
|
||||
import { SNTag } from '../../Syncable/Tag'
|
||||
import { CompoundPredicate } from '../Predicate/CompoundPredicate'
|
||||
|
|
@ -7,6 +6,7 @@ import { itemMatchesQuery, itemPassesFilters } from './Search/SearchUtilities'
|
|||
import { ItemFilter, ReferenceLookupCollection, SearchableDecryptedItem } from './Search/Types'
|
||||
import { NotesAndFilesDisplayOptions } from './DisplayOptions'
|
||||
import { SystemViewId } from '../../Syncable/SmartView'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
export function computeUnifiedFilterForDisplayOptions(
|
||||
options: NotesAndFilesDisplayOptions,
|
||||
|
|
@ -40,7 +40,7 @@ export function computeFiltersForDisplayOptions(
|
|||
const noteWithTags = ItemWithTags.Create(
|
||||
item.payload,
|
||||
item,
|
||||
collection.elementsReferencingElement(item, ContentType.Tag) as SNTag[],
|
||||
collection.elementsReferencingElement(item, ContentType.TYPES.Tag) as SNTag[],
|
||||
)
|
||||
return compoundPredicate.matchesItem(noteWithTags)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { CreateItemDelta } from './../Index/ItemDelta'
|
||||
import { DeletedPayload } from './../../Abstract/Payload/Implementations/DeletedPayload'
|
||||
import { createFile, createNote, createTagWithTitle, mockUuid, pinnedContent } from './../../Utilities/Test/SpecUtils'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { DeletedItem, EncryptedItem } from '../../Abstract/Item'
|
||||
import { EncryptedPayload, PayloadTimestampDefaults } from '../../Abstract/Payload'
|
||||
import { createNoteWithContent } from '../../Utilities/Test/SpecUtils'
|
||||
|
|
@ -16,7 +16,7 @@ describe('item display controller', () => {
|
|||
const noteB = createNoteWithContent({ title: 'b' })
|
||||
collection.set([noteA, noteB])
|
||||
|
||||
const controller = new ItemDisplayController(collection, [ContentType.Note], {
|
||||
const controller = new ItemDisplayController(collection, [ContentType.TYPES.Note], {
|
||||
sortBy: 'title',
|
||||
sortDirection: 'asc',
|
||||
})
|
||||
|
|
@ -36,7 +36,7 @@ describe('item display controller', () => {
|
|||
const noteB = createNoteWithContent({ title: 'b' })
|
||||
collection.set([noteA, noteB])
|
||||
|
||||
const controller = new ItemDisplayController(collection, [ContentType.Note], {
|
||||
const controller = new ItemDisplayController(collection, [ContentType.TYPES.Note], {
|
||||
sortBy: 'title',
|
||||
sortDirection: 'asc',
|
||||
})
|
||||
|
|
@ -56,7 +56,7 @@ describe('item display controller', () => {
|
|||
const noteA = createNoteWithContent({ title: 'a' })
|
||||
collection.set([noteA])
|
||||
|
||||
const controller = new ItemDisplayController(collection, [ContentType.Note], {
|
||||
const controller = new ItemDisplayController(collection, [ContentType.TYPES.Note], {
|
||||
sortBy: 'title',
|
||||
sortDirection: 'asc',
|
||||
})
|
||||
|
|
@ -76,7 +76,7 @@ describe('item display controller', () => {
|
|||
const noteA = new EncryptedItem(
|
||||
new EncryptedPayload({
|
||||
uuid: mockUuid(),
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: '004:...',
|
||||
enc_item_key: '004:...',
|
||||
items_key_id: mockUuid(),
|
||||
|
|
@ -87,7 +87,7 @@ describe('item display controller', () => {
|
|||
)
|
||||
collection.set([noteA])
|
||||
|
||||
const controller = new ItemDisplayController(collection, [ContentType.Note], {
|
||||
const controller = new ItemDisplayController(collection, [ContentType.TYPES.Note], {
|
||||
sortBy: 'title',
|
||||
sortDirection: 'asc',
|
||||
})
|
||||
|
|
@ -101,7 +101,7 @@ describe('item display controller', () => {
|
|||
const noteB = createNoteWithContent({ title: 'b' })
|
||||
collection.set([noteA, noteB])
|
||||
|
||||
const controller = new ItemDisplayController(collection, [ContentType.Note], {
|
||||
const controller = new ItemDisplayController(collection, [ContentType.TYPES.Note], {
|
||||
sortBy: 'title',
|
||||
sortDirection: 'asc',
|
||||
})
|
||||
|
|
@ -134,7 +134,7 @@ describe('item display controller', () => {
|
|||
const noteA = createNoteWithContent({ title: 'a' })
|
||||
collection.set([noteA])
|
||||
|
||||
const controller = new ItemDisplayController(collection, [ContentType.Note], {
|
||||
const controller = new ItemDisplayController(collection, [ContentType.TYPES.Note], {
|
||||
sortBy: 'title',
|
||||
sortDirection: 'asc',
|
||||
})
|
||||
|
|
@ -159,7 +159,7 @@ describe('item display controller', () => {
|
|||
const noteA = createNoteWithContent({ title: 'a' })
|
||||
collection.set([noteA])
|
||||
|
||||
const controller = new ItemDisplayController(collection, [ContentType.Note], {
|
||||
const controller = new ItemDisplayController(collection, [ContentType.TYPES.Note], {
|
||||
sortBy: 'title',
|
||||
sortDirection: 'asc',
|
||||
})
|
||||
|
|
@ -177,7 +177,7 @@ describe('item display controller', () => {
|
|||
const tag = createTagWithTitle()
|
||||
collection.set([note, tag])
|
||||
|
||||
const controller = new ItemDisplayController(collection, [ContentType.Note], {
|
||||
const controller = new ItemDisplayController(collection, [ContentType.TYPES.Note], {
|
||||
sortBy: 'title',
|
||||
sortDirection: 'asc',
|
||||
})
|
||||
|
|
@ -190,7 +190,7 @@ describe('item display controller', () => {
|
|||
const tag = createTagWithTitle()
|
||||
collection.set([note, tag])
|
||||
|
||||
const controller = new ItemDisplayController(collection, [ContentType.Note], {
|
||||
const controller = new ItemDisplayController(collection, [ContentType.TYPES.Note], {
|
||||
sortBy: 'title',
|
||||
sortDirection: 'asc',
|
||||
})
|
||||
|
|
@ -203,7 +203,7 @@ describe('item display controller', () => {
|
|||
const note = createNoteWithContent({ title: 'a' })
|
||||
collection.set([note])
|
||||
|
||||
const controller = new ItemDisplayController(collection, [ContentType.Note], {
|
||||
const controller = new ItemDisplayController(collection, [ContentType.TYPES.Note], {
|
||||
sortBy: 'title',
|
||||
sortDirection: 'asc',
|
||||
})
|
||||
|
|
@ -222,7 +222,7 @@ describe('item display controller', () => {
|
|||
const file = createFile('A')
|
||||
collection.set([note, file])
|
||||
|
||||
const controller = new ItemDisplayController(collection, [ContentType.Note, ContentType.File], {
|
||||
const controller = new ItemDisplayController(collection, [ContentType.TYPES.Note, ContentType.TYPES.File], {
|
||||
sortBy: 'title',
|
||||
sortDirection: 'asc',
|
||||
})
|
||||
|
|
@ -242,14 +242,14 @@ describe('item display controller', () => {
|
|||
const file = createFile()
|
||||
collection.set([note, file])
|
||||
|
||||
const controller = new ItemDisplayController(collection, [ContentType.Note, ContentType.File], {
|
||||
const controller = new ItemDisplayController(collection, [ContentType.TYPES.Note, ContentType.TYPES.File], {
|
||||
sortBy: 'title',
|
||||
sortDirection: 'asc',
|
||||
})
|
||||
|
||||
expect(controller.items()).toHaveLength(2)
|
||||
|
||||
controller.setDisplayOptions({ hiddenContentTypes: [ContentType.File] })
|
||||
controller.setDisplayOptions({ hiddenContentTypes: [ContentType.TYPES.File] })
|
||||
|
||||
expect(controller.items()).toHaveLength(1)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
import { compareValues } from '@standardnotes/utils'
|
||||
import { isDeletedItem, isEncryptedItem } from '../../Abstract/Item'
|
||||
import { ItemDelta } from '../Index/ItemDelta'
|
||||
|
|
@ -21,7 +20,7 @@ export class ItemDisplayController<I extends DisplayItem, O extends AnyDisplayOp
|
|||
|
||||
constructor(
|
||||
private readonly collection: ReadonlyItemCollection,
|
||||
public readonly contentTypes: ContentType[],
|
||||
public readonly contentTypes: string[],
|
||||
private options: DisplayControllerDisplayOptions & O,
|
||||
private vaultOptions?: VaultDisplayOptions,
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { SNTag } from '../../../Syncable/Tag'
|
||||
import { NotesAndFilesDisplayOptions } from '../DisplayOptions'
|
||||
import { computeFiltersForDisplayOptions } from '../DisplayOptionsToFilters'
|
||||
|
|
@ -38,7 +38,7 @@ export function itemMatchesQuery(
|
|||
searchQuery: SearchQuery,
|
||||
collection: ReferenceLookupCollection,
|
||||
): boolean {
|
||||
const itemTags = collection.elementsReferencingElement(itemToMatch, ContentType.Tag) as SNTag[]
|
||||
const itemTags = collection.elementsReferencingElement(itemToMatch, ContentType.TYPES.Tag) as SNTag[]
|
||||
const someTagsMatches = itemTags.some((tag) => matchResultForStringQuery(tag, searchQuery.query) !== MatchResult.None)
|
||||
|
||||
if (itemToMatch.protected && !searchQuery.includeProtectedNoteText) {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
import { DecryptedItemInterface } from './../../../Abstract/Item/Interfaces/DecryptedItem'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { CriteriaValidatorInterface } from './CriteriaValidatorInterface'
|
||||
|
||||
export class HiddenContentCriteriaValidator implements CriteriaValidatorInterface {
|
||||
constructor(private hiddenContentTypes: ContentType[], private element: DecryptedItemInterface) {}
|
||||
constructor(private hiddenContentTypes: string[], private element: DecryptedItemInterface) {}
|
||||
|
||||
public passes(): boolean {
|
||||
return !this.hiddenContentTypes.includes(this.element.content_type)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
export function ContentTypeUsesKeySystemRootKeyEncryption(contentType: ContentType): boolean {
|
||||
return contentType === ContentType.KeySystemItemsKey
|
||||
export function ContentTypeUsesKeySystemRootKeyEncryption(contentType: string): boolean {
|
||||
return contentType === ContentType.TYPES.KeySystemItemsKey
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentTypesUsingRootKeyEncryption } from './ContentTypesUsingRootKeyEncryption'
|
||||
|
||||
export function ContentTypeUsesRootKeyEncryption(contentType: ContentType): boolean {
|
||||
export function ContentTypeUsesRootKeyEncryption(contentType: string): boolean {
|
||||
return ContentTypesUsingRootKeyEncryption().includes(contentType)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
export function ContentTypesUsingRootKeyEncryption(): ContentType[] {
|
||||
export function ContentTypesUsingRootKeyEncryption(): string[] {
|
||||
return [
|
||||
ContentType.RootKey,
|
||||
ContentType.ItemsKey,
|
||||
ContentType.EncryptedStorage,
|
||||
ContentType.TrustedContact,
|
||||
ContentType.KeySystemRootKey,
|
||||
ContentType.TYPES.RootKey,
|
||||
ContentType.TYPES.ItemsKey,
|
||||
ContentType.TYPES.EncryptedStorage,
|
||||
ContentType.TYPES.TrustedContact,
|
||||
ContentType.TYPES.KeySystemRootKey,
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
import { DecryptedPayloadInterface } from './../../Abstract/Payload/Interfaces/DecryptedPayload'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { NoteContent } from '../../Syncable/Note'
|
||||
import { HistoryEntry } from './HistoryEntry'
|
||||
import { NoteHistoryEntry } from './NoteHistoryEntry'
|
||||
|
|
@ -14,9 +15,9 @@ export function CreateHistoryEntryForPayload(
|
|||
return entry
|
||||
}
|
||||
|
||||
function historyClassForContentType(contentType: ContentType) {
|
||||
function historyClassForContentType(contentType: string) {
|
||||
switch (contentType) {
|
||||
case ContentType.Note:
|
||||
case ContentType.TYPES.Note:
|
||||
return NoteHistoryEntry
|
||||
default:
|
||||
return HistoryEntry
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
|
||||
import { ItemInterface } from '../../Abstract/Item/Interfaces/ItemInterface'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import {
|
||||
compoundPredicateFromArguments,
|
||||
includesPredicateFromArguments,
|
||||
|
|
@ -13,9 +12,10 @@ import { IncludesPredicate } from './IncludesPredicate'
|
|||
import { Predicate } from './Predicate'
|
||||
import { CompoundPredicate } from './CompoundPredicate'
|
||||
import { NotPredicate } from './NotPredicate'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
interface Item extends ItemInterface {
|
||||
content_type: ContentType
|
||||
content_type: string
|
||||
updated_at: Date
|
||||
}
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ interface Tag extends Item {
|
|||
function createNote(content: Record<string, unknown>, tags?: Tag[]): Note {
|
||||
return {
|
||||
...content,
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
tags,
|
||||
} as jest.Mocked<Note>
|
||||
}
|
||||
|
|
@ -40,7 +40,7 @@ function createNote(content: Record<string, unknown>, tags?: Tag[]): Note {
|
|||
function createTag(title: string): Tag {
|
||||
return {
|
||||
title,
|
||||
content_type: ContentType.Tag,
|
||||
content_type: ContentType.TYPES.Tag,
|
||||
} as jest.Mocked<Tag>
|
||||
}
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ function createItem(content: Record<string, unknown>, updatedAt?: Date): Item {
|
|||
return {
|
||||
...content,
|
||||
updated_at: updatedAt,
|
||||
content_type: ContentType.Any,
|
||||
content_type: ContentType.TYPES.Any,
|
||||
} as jest.Mocked<Note>
|
||||
}
|
||||
|
||||
|
|
@ -100,7 +100,7 @@ describe('predicates', () => {
|
|||
expect(
|
||||
compoundPredicateFromArguments<Note>('or', [
|
||||
{ keypath: 'title', operator: '=', value: 'Hello' },
|
||||
{ keypath: 'content_type', operator: '=', value: ContentType.Note },
|
||||
{ keypath: 'content_type', operator: '=', value: ContentType.TYPES.Note },
|
||||
]).matchesItem(item),
|
||||
).toEqual(true)
|
||||
})
|
||||
|
|
@ -118,7 +118,7 @@ describe('predicates', () => {
|
|||
expect(
|
||||
compoundPredicateFromArguments<Note>('or', [
|
||||
{ keypath: 'title', operator: '=', value: 'Wrong' },
|
||||
{ keypath: 'content_type', operator: '=', value: ContentType.Note },
|
||||
{ keypath: 'content_type', operator: '=', value: ContentType.TYPES.Note },
|
||||
]).matchesItem(item),
|
||||
).toEqual(true)
|
||||
})
|
||||
|
|
@ -158,7 +158,7 @@ describe('predicates', () => {
|
|||
expect(
|
||||
compoundPredicateFromArguments<Note>('and', [
|
||||
{ keypath: 'title', operator: '=', value: title },
|
||||
{ keypath: 'content_type', operator: '=', value: ContentType.Note },
|
||||
{ keypath: 'content_type', operator: '=', value: ContentType.TYPES.Note },
|
||||
]).matchesItem(item),
|
||||
).toEqual(true)
|
||||
})
|
||||
|
|
@ -167,7 +167,7 @@ describe('predicates', () => {
|
|||
expect(
|
||||
compoundPredicateFromArguments<Note>('and', [
|
||||
{ keypath: 'title', operator: '=', value: 'Wrong' },
|
||||
{ keypath: 'content_type', operator: '=', value: ContentType.Note },
|
||||
{ keypath: 'content_type', operator: '=', value: ContentType.TYPES.Note },
|
||||
]).matchesItem(item),
|
||||
).toEqual(false)
|
||||
})
|
||||
|
|
@ -184,7 +184,7 @@ describe('predicates', () => {
|
|||
it('explicit compound syntax', () => {
|
||||
const compoundProd = new CompoundPredicate('and', [
|
||||
new Predicate<Note>('title', '=', title),
|
||||
new Predicate('content_type', '=', ContentType.Note),
|
||||
new Predicate('content_type', '=', ContentType.TYPES.Note),
|
||||
])
|
||||
expect(compoundProd.matchesItem(item)).toEqual(true)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { PayloadSource } from './../../Abstract/Payload/Types/PayloadSource'
|
||||
import { DecryptedPayload } from './../../Abstract/Payload/Implementations/DecryptedPayload'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { FillItemContent } from '../../Abstract/Content/ItemContent'
|
||||
import { SNComponent } from './Component'
|
||||
import { ComponentContent } from './ComponentContent'
|
||||
|
|
@ -13,7 +13,7 @@ describe('component model', () => {
|
|||
new DecryptedPayload(
|
||||
{
|
||||
uuid: String(Math.random()),
|
||||
content_type: ContentType.Component,
|
||||
content_type: ContentType.TYPES.Component,
|
||||
content: FillItemContent<ComponentContent>({
|
||||
url: 'http://foo.com',
|
||||
hosted_url: 'http://bar.com',
|
||||
|
|
@ -33,7 +33,7 @@ describe('component model', () => {
|
|||
new DecryptedPayload(
|
||||
{
|
||||
uuid: String(Math.random()),
|
||||
content_type: ContentType.Component,
|
||||
content_type: ContentType.TYPES.Component,
|
||||
content: FillItemContent({
|
||||
url: 'http://foo.com',
|
||||
hosted_url: '#{foo.zoo}',
|
||||
|
|
@ -53,7 +53,7 @@ describe('component model', () => {
|
|||
new DecryptedPayload(
|
||||
{
|
||||
uuid: String(Math.random()),
|
||||
content_type: ContentType.Component,
|
||||
content_type: ContentType.TYPES.Component,
|
||||
content: FillItemContent({
|
||||
package_info: {
|
||||
note_type: NoteType.Authentication,
|
||||
|
|
@ -73,7 +73,7 @@ describe('component model', () => {
|
|||
new DecryptedPayload(
|
||||
{
|
||||
uuid: String(Math.random()),
|
||||
content_type: ContentType.Component,
|
||||
content_type: ContentType.TYPES.Component,
|
||||
content: FillItemContent({
|
||||
package_info: {},
|
||||
} as ComponentContent),
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { isValidUrl } from '@standardnotes/utils'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import {
|
||||
FeatureIdentifier,
|
||||
ThirdPartyFeatureDescription,
|
||||
|
|
@ -20,11 +19,12 @@ import { Predicate } from '../../Runtime/Predicate/Predicate'
|
|||
import { ItemInterface } from '../../Abstract/Item/Interfaces/ItemInterface'
|
||||
import { DecryptedItemInterface } from './../../Abstract/Item/Interfaces/DecryptedItem'
|
||||
import { ComponentPackageInfo } from './PackageInfo'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
export const isComponent = (x: ItemInterface): x is SNComponent => x.content_type === ContentType.Component
|
||||
export const isComponent = (x: ItemInterface): x is SNComponent => x.content_type === ContentType.TYPES.Component
|
||||
|
||||
export const isComponentOrTheme = (x: ItemInterface): x is SNComponent =>
|
||||
x.content_type === ContentType.Component || x.content_type === ContentType.Theme
|
||||
x.content_type === ContentType.TYPES.Component || x.content_type === ContentType.TYPES.Theme
|
||||
|
||||
/**
|
||||
* Components are mostly iframe based extensions that communicate with the SN parent
|
||||
|
|
@ -111,7 +111,7 @@ export class SNComponent extends DecryptedItem<ComponentContent> implements Comp
|
|||
}
|
||||
|
||||
public isTheme(): boolean {
|
||||
return this.content_type === ContentType.Theme || this.area === ComponentArea.Themes
|
||||
return this.content_type === ContentType.TYPES.Theme || this.area === ComponentArea.Themes
|
||||
}
|
||||
|
||||
/** @deprecated Use global application PrefKey.DefaultEditorIdentifier */
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { ConflictStrategy } from './../../Abstract/Item/Types/ConflictStrategy'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { FillItemContent } from '../../Abstract/Content/ItemContent'
|
||||
import { DecryptedPayload, PayloadTimestampDefaults } from '../../Abstract/Payload'
|
||||
import { FileContent, FileItem } from './File'
|
||||
|
|
@ -12,7 +12,7 @@ describe('file', () => {
|
|||
return new FileItem(
|
||||
new DecryptedPayload<FileContent>({
|
||||
uuid: '123',
|
||||
content_type: ContentType.File,
|
||||
content_type: ContentType.TYPES.File,
|
||||
content: FillItemContent<FileContent>({
|
||||
name: 'name.png',
|
||||
key: 'secret',
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { DecryptedItem } from '../../Abstract/Item/Implementations/DecryptedItem'
|
||||
import { ItemContent } from '../../Abstract/Content/ItemContent'
|
||||
import { DecryptedPayloadInterface } from '../../Abstract/Payload/Interfaces/DecryptedPayload'
|
||||
|
|
@ -5,7 +6,6 @@ import { FileMetadata } from './FileMetadata'
|
|||
import { FileProtocolV1 } from './FileProtocolV1'
|
||||
import { SortableItem } from '../../Runtime/Collection/CollectionSort'
|
||||
import { ConflictStrategy, ItemInterface } from '../../Abstract/Item'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
|
||||
type EncryptedBytesLength = number
|
||||
type DecryptedBytesLength = number
|
||||
|
|
@ -32,7 +32,7 @@ export type FileContentSpecialized = FileContentWithoutSize & FileMetadata & Siz
|
|||
|
||||
export type FileContent = FileContentSpecialized & ItemContent
|
||||
|
||||
export const isFile = (x: ItemInterface): x is FileItem => x.content_type === ContentType.File
|
||||
export const isFile = (x: ItemInterface): x is FileItem => x.content_type === ContentType.TYPES.File
|
||||
|
||||
export class FileItem
|
||||
extends DecryptedItem<FileContent>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { SNNote } from '../Note/Note'
|
||||
import { FileContent, FileItem } from './File'
|
||||
import { FileToNoteReference } from '../../Abstract/Reference/FileToNoteReference'
|
||||
|
|
@ -18,7 +18,7 @@ export class FileMutator extends DecryptedItemMutator<FileContent> {
|
|||
public addNote(note: SNNote): void {
|
||||
const reference: FileToNoteReference = {
|
||||
reference_type: ContentReferenceType.FileToNote,
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
uuid: note.uuid,
|
||||
}
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ export class FileMutator extends DecryptedItemMutator<FileContent> {
|
|||
|
||||
const reference: FileToFileReference = {
|
||||
uuid: file.uuid,
|
||||
content_type: ContentType.File,
|
||||
content_type: ContentType.TYPES.File,
|
||||
reference_type: ContentReferenceType.FileToFile,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ContentType, ProtocolVersion } from '@standardnotes/common'
|
||||
import { ProtocolVersion } from '@standardnotes/common'
|
||||
import { ConflictStrategy, DecryptedItem } from '../../Abstract/Item'
|
||||
import { DecryptedPayloadInterface } from '../../Abstract/Payload'
|
||||
import { HistoryEntryInterface } from '../../Runtime/History'
|
||||
|
|
@ -6,9 +6,10 @@ import { KeySystemRootKeyContent } from './KeySystemRootKeyContent'
|
|||
import { KeySystemRootKeyInterface } from './KeySystemRootKeyInterface'
|
||||
import { KeySystemIdentifier } from './KeySystemIdentifier'
|
||||
import { KeySystemRootKeyParamsInterface } from '../../Local/KeyParams/KeySystemRootKeyParamsInterface'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
export function isKeySystemRootKey(x: { content_type: ContentType }): x is KeySystemRootKey {
|
||||
return x.content_type === ContentType.KeySystemRootKey
|
||||
export function isKeySystemRootKey(x: { content_type: string }): x is KeySystemRootKey {
|
||||
return x.content_type === ContentType.TYPES.KeySystemRootKey
|
||||
}
|
||||
|
||||
export class KeySystemRootKey extends DecryptedItem<KeySystemRootKeyContent> implements KeySystemRootKeyInterface {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
import { AppDataField } from './../../Abstract/Item/Types/AppDataField'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { FeatureIdentifier, NoteType } from '@standardnotes/features'
|
||||
import { DecryptedItem } from '../../Abstract/Item/Implementations/DecryptedItem'
|
||||
import { ItemInterface } from '../../Abstract/Item/Interfaces/ItemInterface'
|
||||
import { DecryptedPayloadInterface } from '../../Abstract/Payload/Interfaces/DecryptedPayload'
|
||||
import { NoteContent, NoteContentSpecialized } from './NoteContent'
|
||||
import { EditorLineWidth } from '../UserPrefs'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
export const isNote = (x: ItemInterface): x is SNNote => x.content_type === ContentType.Note
|
||||
export const isNote = (x: ItemInterface): x is SNNote => x.content_type === ContentType.TYPES.Note
|
||||
|
||||
export class SNNote extends DecryptedItem<NoteContent> implements NoteContentSpecialized {
|
||||
public readonly title: string
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@ import { NoteContent } from './NoteContent'
|
|||
import { DecryptedItemMutator } from '../../Abstract/Item/Mutator/DecryptedItemMutator'
|
||||
import { SNNote } from './Note'
|
||||
import { NoteToNoteReference } from '../../Abstract/Reference/NoteToNoteReference'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentReferenceType } from '../../Abstract/Item'
|
||||
import { FeatureIdentifier, NoteType } from '@standardnotes/features'
|
||||
import { EditorLineWidth } from '../UserPrefs'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
export class NoteMutator extends DecryptedItemMutator<NoteContent> {
|
||||
set title(title: string) {
|
||||
|
|
@ -63,7 +63,7 @@ export class NoteMutator extends DecryptedItemMutator<NoteContent> {
|
|||
|
||||
const reference: NoteToNoteReference = {
|
||||
uuid: note.uuid,
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
reference_type: ContentReferenceType.NoteToNote,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
import { DecryptedItem } from '../../Abstract/Item/Implementations/DecryptedItem'
|
||||
import { PredicateInterface } from '../../Runtime/Predicate/Interface'
|
||||
import { predicateFromJson } from '../../Runtime/Predicate/Generators'
|
||||
|
|
@ -8,7 +10,6 @@ import { SmartViewDefaultIconName, systemViewIcon } from './SmartViewIcons'
|
|||
import { SmartViewContent } from './SmartViewContent'
|
||||
import { TagPreferences } from '../Tag/TagPreferences'
|
||||
import { ItemInterface } from '../../Abstract/Item'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
|
||||
export const SMART_TAG_DSL_PREFIX = '!['
|
||||
|
||||
|
|
@ -16,7 +17,7 @@ export function isSystemView(view: SmartView): boolean {
|
|||
return Object.values(SystemViewId).includes(view.uuid as SystemViewId)
|
||||
}
|
||||
|
||||
export const isSmartView = (x: ItemInterface): x is SmartView => x.content_type === ContentType.SmartView
|
||||
export const isSmartView = (x: ItemInterface): x is SmartView => x.content_type === ContentType.TYPES.SmartView
|
||||
|
||||
export class SmartView extends DecryptedItem<SmartViewContent> {
|
||||
public readonly predicate!: PredicateInterface<DecryptedItem>
|
||||
|
|
|
|||
|
|
@ -4,19 +4,19 @@ import { SmartView } from './SmartView'
|
|||
import { SmartViewContent } from './SmartViewContent'
|
||||
import { SystemViewId } from './SystemViewId'
|
||||
import { ItemWithTags } from '../../Runtime/Display/Search/ItemWithTags'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { FillItemContent } from '../../Abstract/Content/ItemContent'
|
||||
import { Predicate } from '../../Runtime/Predicate/Predicate'
|
||||
import { CompoundPredicate } from '../../Runtime/Predicate/CompoundPredicate'
|
||||
import { PayloadTimestampDefaults } from '../../Abstract/Payload'
|
||||
import { NotesAndFilesDisplayOptions } from '../../Runtime/Display'
|
||||
import { FileItem } from '../File'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
export function BuildSmartViews(options: NotesAndFilesDisplayOptions): SmartView[] {
|
||||
const notes = new SmartView(
|
||||
new DecryptedPayload({
|
||||
uuid: SystemViewId.AllNotes,
|
||||
content_type: ContentType.SmartView,
|
||||
content_type: ContentType.TYPES.SmartView,
|
||||
...PayloadTimestampDefaults(),
|
||||
content: FillItemContent<SmartViewContent>({
|
||||
title: 'Notes',
|
||||
|
|
@ -28,7 +28,7 @@ export function BuildSmartViews(options: NotesAndFilesDisplayOptions): SmartView
|
|||
const files = new SmartView(
|
||||
new DecryptedPayload({
|
||||
uuid: SystemViewId.Files,
|
||||
content_type: ContentType.SmartView,
|
||||
content_type: ContentType.TYPES.SmartView,
|
||||
...PayloadTimestampDefaults(),
|
||||
content: FillItemContent<SmartViewContent>({
|
||||
title: 'Files',
|
||||
|
|
@ -40,7 +40,7 @@ export function BuildSmartViews(options: NotesAndFilesDisplayOptions): SmartView
|
|||
const archived = new SmartView(
|
||||
new DecryptedPayload({
|
||||
uuid: SystemViewId.ArchivedNotes,
|
||||
content_type: ContentType.SmartView,
|
||||
content_type: ContentType.TYPES.SmartView,
|
||||
...PayloadTimestampDefaults(),
|
||||
content: FillItemContent<SmartViewContent>({
|
||||
title: 'Archived',
|
||||
|
|
@ -52,7 +52,7 @@ export function BuildSmartViews(options: NotesAndFilesDisplayOptions): SmartView
|
|||
const trash = new SmartView(
|
||||
new DecryptedPayload({
|
||||
uuid: SystemViewId.TrashedNotes,
|
||||
content_type: ContentType.SmartView,
|
||||
content_type: ContentType.TYPES.SmartView,
|
||||
...PayloadTimestampDefaults(),
|
||||
content: FillItemContent<SmartViewContent>({
|
||||
title: 'Trash',
|
||||
|
|
@ -64,7 +64,7 @@ export function BuildSmartViews(options: NotesAndFilesDisplayOptions): SmartView
|
|||
const untagged = new SmartView(
|
||||
new DecryptedPayload({
|
||||
uuid: SystemViewId.UntaggedNotes,
|
||||
content_type: ContentType.SmartView,
|
||||
content_type: ContentType.TYPES.SmartView,
|
||||
...PayloadTimestampDefaults(),
|
||||
content: FillItemContent<SmartViewContent>({
|
||||
title: 'Untagged',
|
||||
|
|
@ -76,7 +76,7 @@ export function BuildSmartViews(options: NotesAndFilesDisplayOptions): SmartView
|
|||
const starred = new SmartView(
|
||||
new DecryptedPayload({
|
||||
uuid: SystemViewId.StarredNotes,
|
||||
content_type: ContentType.SmartView,
|
||||
content_type: ContentType.TYPES.SmartView,
|
||||
...PayloadTimestampDefaults(),
|
||||
content: FillItemContent<SmartViewContent>({
|
||||
title: 'Starred',
|
||||
|
|
@ -88,7 +88,7 @@ export function BuildSmartViews(options: NotesAndFilesDisplayOptions): SmartView
|
|||
const conflicts = new SmartView(
|
||||
new DecryptedPayload({
|
||||
uuid: SystemViewId.Conflicts,
|
||||
content_type: ContentType.SmartView,
|
||||
content_type: ContentType.TYPES.SmartView,
|
||||
...PayloadTimestampDefaults(),
|
||||
content: FillItemContent<SmartViewContent>({
|
||||
title: 'Conflicts',
|
||||
|
|
@ -101,7 +101,7 @@ export function BuildSmartViews(options: NotesAndFilesDisplayOptions): SmartView
|
|||
}
|
||||
|
||||
function allNotesPredicate(options: NotesAndFilesDisplayOptions) {
|
||||
const subPredicates: Predicate<SNNote>[] = [new Predicate('content_type', '=', ContentType.Note)]
|
||||
const subPredicates: Predicate<SNNote>[] = [new Predicate('content_type', '=', ContentType.TYPES.Note)]
|
||||
|
||||
if (options.includeTrashed === false) {
|
||||
subPredicates.push(new Predicate('trashed', '=', false))
|
||||
|
|
@ -121,7 +121,7 @@ function allNotesPredicate(options: NotesAndFilesDisplayOptions) {
|
|||
}
|
||||
|
||||
function filesPredicate(options: NotesAndFilesDisplayOptions) {
|
||||
const subPredicates: Predicate<FileItem>[] = [new Predicate('content_type', '=', ContentType.File)]
|
||||
const subPredicates: Predicate<FileItem>[] = [new Predicate('content_type', '=', ContentType.TYPES.File)]
|
||||
|
||||
if (options.includeTrashed === false) {
|
||||
subPredicates.push(new Predicate('trashed', '=', false))
|
||||
|
|
@ -143,7 +143,7 @@ function filesPredicate(options: NotesAndFilesDisplayOptions) {
|
|||
function archivedNotesPredicate(options: NotesAndFilesDisplayOptions) {
|
||||
const subPredicates: Predicate<SNNote>[] = [
|
||||
new Predicate('archived', '=', true),
|
||||
new Predicate('content_type', '=', ContentType.Note),
|
||||
new Predicate('content_type', '=', ContentType.TYPES.Note),
|
||||
]
|
||||
if (options.includeTrashed === false) {
|
||||
subPredicates.push(new Predicate('trashed', '=', false))
|
||||
|
|
@ -162,7 +162,7 @@ function archivedNotesPredicate(options: NotesAndFilesDisplayOptions) {
|
|||
function trashedNotesPredicate(options: NotesAndFilesDisplayOptions) {
|
||||
const subPredicates: Predicate<SNNote>[] = [
|
||||
new Predicate('trashed', '=', true),
|
||||
new Predicate('content_type', '=', ContentType.Note),
|
||||
new Predicate('content_type', '=', ContentType.TYPES.Note),
|
||||
]
|
||||
if (options.includeArchived === false) {
|
||||
subPredicates.push(new Predicate('archived', '=', false))
|
||||
|
|
@ -180,7 +180,7 @@ function trashedNotesPredicate(options: NotesAndFilesDisplayOptions) {
|
|||
|
||||
function untaggedNotesPredicate(options: NotesAndFilesDisplayOptions) {
|
||||
const subPredicates = [
|
||||
new Predicate('content_type', '=', ContentType.Note),
|
||||
new Predicate('content_type', '=', ContentType.TYPES.Note),
|
||||
new Predicate<ItemWithTags>('tagsCount', '=', 0),
|
||||
]
|
||||
if (options.includeArchived === false) {
|
||||
|
|
@ -200,7 +200,7 @@ function untaggedNotesPredicate(options: NotesAndFilesDisplayOptions) {
|
|||
function starredNotesPredicate(options: NotesAndFilesDisplayOptions) {
|
||||
const subPredicates: Predicate<SNNote>[] = [
|
||||
new Predicate('starred', '=', true),
|
||||
new Predicate('content_type', '=', ContentType.Note),
|
||||
new Predicate('content_type', '=', ContentType.TYPES.Note),
|
||||
]
|
||||
if (options.includeTrashed === false) {
|
||||
subPredicates.push(new Predicate('trashed', '=', false))
|
||||
|
|
@ -217,7 +217,7 @@ function starredNotesPredicate(options: NotesAndFilesDisplayOptions) {
|
|||
}
|
||||
|
||||
function conflictsPredicate(options: NotesAndFilesDisplayOptions) {
|
||||
const subPredicates: Predicate<SNNote>[] = [new Predicate('content_type', '=', ContentType.Note)]
|
||||
const subPredicates: Predicate<SNNote>[] = [new Predicate('content_type', '=', ContentType.TYPES.Note)]
|
||||
|
||||
if (options.includeTrashed === false) {
|
||||
subPredicates.push(new Predicate('trashed', '=', false))
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { PayloadSource } from './../../Abstract/Payload/Types/PayloadSource'
|
||||
import { DecryptedPayload } from './../../Abstract/Payload/Implementations/DecryptedPayload'
|
||||
import { SNTag } from './Tag'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { FillItemContent } from '../../Abstract/Content/ItemContent'
|
||||
import { ContentReference } from '../../Abstract/Reference/ContentReference'
|
||||
import { PayloadTimestampDefaults } from '../../Abstract/Payload'
|
||||
|
|
@ -14,7 +14,7 @@ const create = (title: string, references: ContentReference[] = []): SNTag => {
|
|||
new DecryptedPayload(
|
||||
{
|
||||
uuid: randUuid(),
|
||||
content_type: ContentType.Tag,
|
||||
content_type: ContentType.TYPES.Tag,
|
||||
content: FillItemContent({
|
||||
title,
|
||||
references,
|
||||
|
|
@ -31,9 +31,9 @@ const create = (title: string, references: ContentReference[] = []): SNTag => {
|
|||
describe('SNTag Tests', () => {
|
||||
it('should count notes in the basic case', () => {
|
||||
const tag = create('helloworld', [
|
||||
{ uuid: randUuid(), content_type: ContentType.Note },
|
||||
{ uuid: randUuid(), content_type: ContentType.Note },
|
||||
{ uuid: randUuid(), content_type: ContentType.Tag },
|
||||
{ uuid: randUuid(), content_type: ContentType.TYPES.Note },
|
||||
{ uuid: randUuid(), content_type: ContentType.TYPES.Note },
|
||||
{ uuid: randUuid(), content_type: ContentType.TYPES.Tag },
|
||||
])
|
||||
|
||||
expect(tag.noteCount).toEqual(2)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { VectorIconNameOrEmoji, IconType } from './../../Utilities/Icon/IconType'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { DecryptedItem } from '../../Abstract/Item/Implementations/DecryptedItem'
|
||||
import { ItemInterface } from '../../Abstract/Item/Interfaces/ItemInterface'
|
||||
import { ContentReference } from '../../Abstract/Reference/ContentReference'
|
||||
|
|
@ -7,12 +6,13 @@ import { isTagToParentTagReference } from '../../Abstract/Reference/Functions'
|
|||
import { DecryptedPayloadInterface } from '../../Abstract/Payload/Interfaces/DecryptedPayload'
|
||||
import { TagContent, TagContentSpecialized } from './TagContent'
|
||||
import { TagPreferences } from './TagPreferences'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
export const TagFolderDelimitter = '.'
|
||||
|
||||
export const DefaultTagIconName: IconType = 'hashtag'
|
||||
|
||||
export const isTag = (x: ItemInterface): x is SNTag => x.content_type === ContentType.Tag
|
||||
export const isTag = (x: ItemInterface): x is SNTag => x.content_type === ContentType.TYPES.Tag
|
||||
|
||||
export class SNTag extends DecryptedItem<TagContent> implements TagContentSpecialized {
|
||||
public readonly title: string
|
||||
|
|
@ -34,7 +34,7 @@ export class SNTag extends DecryptedItem<TagContent> implements TagContentSpecia
|
|||
|
||||
get noteReferences(): ContentReference[] {
|
||||
const references = this.payload.references
|
||||
return references.filter((ref) => ref.content_type === ContentType.Note)
|
||||
return references.filter((ref) => ref.content_type === ContentType.TYPES.Note)
|
||||
}
|
||||
|
||||
get noteCount(): number {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { ContentReferenceType, MutationType } from '../../Abstract/Item'
|
||||
import { createFile, createTagWithContent, createTagWithTitle } from '../../Utilities/Test/SpecUtils'
|
||||
import { SNTag } from './Tag'
|
||||
|
|
@ -15,7 +15,7 @@ describe('tag mutator', () => {
|
|||
|
||||
expect(result.content.references[0]).toEqual({
|
||||
uuid: file.uuid,
|
||||
content_type: ContentType.File,
|
||||
content_type: ContentType.TYPES.File,
|
||||
reference_type: ContentReferenceType.TagToFile,
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
import { SNTag } from './Tag'
|
||||
import { TagContent } from './TagContent'
|
||||
import { FileItem } from '../File'
|
||||
|
|
@ -10,6 +9,7 @@ import { DecryptedItemMutator } from '../../Abstract/Item/Mutator/DecryptedItemM
|
|||
import { TagToFileReference } from '../../Abstract/Reference/TagToFileReference'
|
||||
import { TagPreferences } from './TagPreferences'
|
||||
import { DecryptedItemInterface, MutationType } from '../../Abstract/Item'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
export class TagMutator<Content extends TagContent = TagContent> extends DecryptedItemMutator<Content> {
|
||||
private mutablePreferences?: TagPreferences
|
||||
|
|
@ -51,7 +51,7 @@ export class TagMutator<Content extends TagContent = TagContent> extends Decrypt
|
|||
|
||||
const reference: TagToParentTagReference = {
|
||||
reference_type: ContentReferenceType.TagToParentTag,
|
||||
content_type: ContentType.Tag,
|
||||
content_type: ContentType.TYPES.Tag,
|
||||
uuid: tag.uuid,
|
||||
}
|
||||
|
||||
|
|
@ -71,7 +71,7 @@ export class TagMutator<Content extends TagContent = TagContent> extends Decrypt
|
|||
|
||||
const reference: TagToFileReference = {
|
||||
reference_type: ContentReferenceType.TagToFile,
|
||||
content_type: ContentType.File,
|
||||
content_type: ContentType.TYPES.File,
|
||||
uuid: file.uuid,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ import { ConflictStrategy } from '../../Abstract/Item/Types/ConflictStrategy'
|
|||
import { AppDataField } from '../../Abstract/Item/Types/AppDataField'
|
||||
import { HistoryEntryInterface } from '../../Runtime/History'
|
||||
import { DecryptedItemInterface, ItemInterface } from '../../Abstract/Item'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { useBoolean } from '@standardnotes/utils'
|
||||
import { ThemePackageInfo } from '../Component/PackageInfo'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
export const isTheme = (x: ItemInterface): x is SNTheme => x.content_type === ContentType.Theme
|
||||
export const isTheme = (x: ItemInterface): x is SNTheme => x.content_type === ContentType.TYPES.Theme
|
||||
|
||||
export class SNTheme extends SNComponent {
|
||||
public override area: ComponentArea = ComponentArea.Themes
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { DecryptedItem } from '../../Abstract/Item/Implementations/DecryptedItem'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { Predicate } from '../../Runtime/Predicate/Predicate'
|
||||
import { PrefKey, PrefValue } from './PrefKey'
|
||||
|
||||
export class SNUserPrefs extends DecryptedItem {
|
||||
static singletonPredicate = new Predicate('content_type', '=', ContentType.UserPrefs)
|
||||
static singletonPredicate = new Predicate('content_type', '=', ContentType.TYPES.UserPrefs)
|
||||
|
||||
override get isSingleton(): true {
|
||||
return true
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
import { EncryptedItem } from '../../Abstract/Item/Implementations/EncryptedItem'
|
||||
import { DecryptedPayloadInterface } from '../../Abstract/Payload/Interfaces/DecryptedPayload'
|
||||
import { FileItem } from '../../Syncable/File/File'
|
||||
|
|
@ -40,6 +39,7 @@ import {
|
|||
isDeletedPayload,
|
||||
isEncryptedPayload,
|
||||
} from '../../Abstract/Payload'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
type ItemClass<C extends ItemContent = ItemContent> = new (payload: DecryptedPayloadInterface<C>) => DecryptedItem<C>
|
||||
|
||||
|
|
@ -53,24 +53,24 @@ type MappingEntry<C extends ItemContent = ItemContent> = {
|
|||
mutatorClass?: MutatorClass<C>
|
||||
}
|
||||
|
||||
const ContentTypeClassMapping: Partial<Record<ContentType, MappingEntry>> = {
|
||||
[ContentType.ActionsExtension]: {
|
||||
const ContentTypeClassMapping: Partial<Record<string, MappingEntry>> = {
|
||||
[ContentType.TYPES.ActionsExtension]: {
|
||||
itemClass: SNActionsExtension,
|
||||
mutatorClass: ActionsExtensionMutator,
|
||||
},
|
||||
[ContentType.Component]: { itemClass: SNComponent, mutatorClass: ComponentMutator },
|
||||
[ContentType.KeySystemRootKey]: { itemClass: KeySystemRootKey, mutatorClass: KeySystemRootKeyMutator },
|
||||
[ContentType.TrustedContact]: { itemClass: TrustedContact, mutatorClass: TrustedContactMutator },
|
||||
[ContentType.VaultListing]: { itemClass: VaultListing, mutatorClass: VaultListingMutator },
|
||||
[ContentType.Editor]: { itemClass: SNEditor },
|
||||
[ContentType.ExtensionRepo]: { itemClass: SNFeatureRepo },
|
||||
[ContentType.File]: { itemClass: FileItem, mutatorClass: FileMutator },
|
||||
[ContentType.Note]: { itemClass: SNNote, mutatorClass: NoteMutator },
|
||||
[ContentType.SmartView]: { itemClass: SmartView, mutatorClass: SmartViewMutator },
|
||||
[ContentType.Tag]: { itemClass: SNTag, mutatorClass: TagMutator },
|
||||
[ContentType.Theme]: { itemClass: SNTheme, mutatorClass: ThemeMutator },
|
||||
[ContentType.UserPrefs]: { itemClass: SNUserPrefs, mutatorClass: UserPrefsMutator },
|
||||
} as unknown as Partial<Record<ContentType, MappingEntry>>
|
||||
[ContentType.TYPES.Component]: { itemClass: SNComponent, mutatorClass: ComponentMutator },
|
||||
[ContentType.TYPES.KeySystemRootKey]: { itemClass: KeySystemRootKey, mutatorClass: KeySystemRootKeyMutator },
|
||||
[ContentType.TYPES.TrustedContact]: { itemClass: TrustedContact, mutatorClass: TrustedContactMutator },
|
||||
[ContentType.TYPES.VaultListing]: { itemClass: VaultListing, mutatorClass: VaultListingMutator },
|
||||
[ContentType.TYPES.Editor]: { itemClass: SNEditor },
|
||||
[ContentType.TYPES.ExtensionRepo]: { itemClass: SNFeatureRepo },
|
||||
[ContentType.TYPES.File]: { itemClass: FileItem, mutatorClass: FileMutator },
|
||||
[ContentType.TYPES.Note]: { itemClass: SNNote, mutatorClass: NoteMutator },
|
||||
[ContentType.TYPES.SmartView]: { itemClass: SmartView, mutatorClass: SmartViewMutator },
|
||||
[ContentType.TYPES.Tag]: { itemClass: SNTag, mutatorClass: TagMutator },
|
||||
[ContentType.TYPES.Theme]: { itemClass: SNTheme, mutatorClass: ThemeMutator },
|
||||
[ContentType.TYPES.UserPrefs]: { itemClass: SNUserPrefs, mutatorClass: UserPrefsMutator },
|
||||
} as unknown as Partial<Record<string, MappingEntry>>
|
||||
|
||||
export function CreateDecryptedMutatorForItem<
|
||||
I extends DecryptedItemInterface,
|
||||
|
|
@ -87,7 +87,7 @@ export function CreateDecryptedMutatorForItem<
|
|||
export function RegisterItemClass<
|
||||
C extends ItemContent = ItemContent,
|
||||
M extends DecryptedItemMutator<C> = DecryptedItemMutator<C>,
|
||||
>(contentType: ContentType, itemClass: ItemClass<C>, mutatorClass: M) {
|
||||
>(contentType: string, itemClass: ItemClass<C>, mutatorClass: M) {
|
||||
const entry: MappingEntry<C> = {
|
||||
itemClass: itemClass,
|
||||
mutatorClass: mutatorClass as unknown as MutatorClass<C>,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { DeletedPayload } from '../../Abstract/Payload/Implementations/DeletedPayload'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { extendArray, UuidGenerator } from '@standardnotes/utils'
|
||||
import { ImmutablePayloadCollection } from '../../Runtime/Collection/Payload/ImmutablePayloadCollection'
|
||||
import { DecryptedPayloadInterface } from '../../Abstract/Payload/Interfaces/DecryptedPayload'
|
||||
|
|
@ -9,6 +8,7 @@ import { EncryptedPayloadInterface } from '../../Abstract/Payload/Interfaces/Enc
|
|||
import { PayloadsByUpdatingReferencingPayloadReferences } from './PayloadsByUpdatingReferencingPayloadReferences'
|
||||
import { SyncResolvedPayload } from '../../Runtime/Deltas/Utilities/SyncResolvedPayload'
|
||||
import { getIncrementedDirtyIndex } from '../../Runtime/DirtyCounter/DirtyCounter'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
/**
|
||||
* Return the payloads that result if you alternated the uuid for the payload.
|
||||
|
|
@ -50,7 +50,7 @@ export function PayloadsByAlternatingUuid<P extends DecryptedPayloadInterface =
|
|||
|
||||
extendArray(results, updatedReferencing)
|
||||
|
||||
if (payload.content_type === ContentType.ItemsKey) {
|
||||
if (payload.content_type === ContentType.TYPES.ItemsKey) {
|
||||
/**
|
||||
* Update any payloads who are still encrypted and whose items_key_id point to this uuid
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import { TagContent } from './../../Syncable/Tag/TagContent'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { FillItemContent, ItemContent } from '../../Abstract/Content/ItemContent'
|
||||
import { DecryptedPayload, PayloadSource, PayloadTimestampDefaults } from '../../Abstract/Payload'
|
||||
import { FileContent, FileItem } from '../../Syncable/File'
|
||||
import { NoteContent, SNNote } from '../../Syncable/Note'
|
||||
import { SNTag } from '../../Syncable/Tag'
|
||||
import { SmartView, SmartViewContent } from '../../Syncable/SmartView'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
let currentId = 0
|
||||
|
||||
|
|
@ -18,7 +18,7 @@ export const createNote = (content?: Partial<NoteContent>): SNNote => {
|
|||
new DecryptedPayload(
|
||||
{
|
||||
uuid: mockUuid(),
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: FillItemContent({ ...content }),
|
||||
...PayloadTimestampDefaults(),
|
||||
},
|
||||
|
|
@ -32,7 +32,7 @@ export const createNoteWithContent = (content: Partial<NoteContent>, createdAt?:
|
|||
new DecryptedPayload(
|
||||
{
|
||||
uuid: mockUuid(),
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: FillItemContent<NoteContent>(content),
|
||||
...PayloadTimestampDefaults(),
|
||||
created_at: createdAt || new Date(),
|
||||
|
|
@ -47,7 +47,7 @@ export const createTagWithContent = (content: Partial<TagContent>): SNTag => {
|
|||
new DecryptedPayload(
|
||||
{
|
||||
uuid: mockUuid(),
|
||||
content_type: ContentType.Tag,
|
||||
content_type: ContentType.TYPES.Tag,
|
||||
content: FillItemContent<TagContent>(content),
|
||||
...PayloadTimestampDefaults(),
|
||||
},
|
||||
|
|
@ -61,7 +61,7 @@ export const createSmartViewWithContent = (content: Partial<SmartViewContent>):
|
|||
new DecryptedPayload(
|
||||
{
|
||||
uuid: mockUuid(),
|
||||
content_type: ContentType.SmartView,
|
||||
content_type: ContentType.TYPES.SmartView,
|
||||
content: FillItemContent<SmartViewContent>(content),
|
||||
...PayloadTimestampDefaults(),
|
||||
},
|
||||
|
|
@ -75,7 +75,7 @@ export const createTagWithTitle = (title = 'photos') => {
|
|||
new DecryptedPayload(
|
||||
{
|
||||
uuid: mockUuid(),
|
||||
content_type: ContentType.Tag,
|
||||
content_type: ContentType.TYPES.Tag,
|
||||
content: FillItemContent<TagContent>({ title }),
|
||||
...PayloadTimestampDefaults(),
|
||||
},
|
||||
|
|
@ -89,7 +89,7 @@ export const createSmartViewWithTitle = (title = 'photos') => {
|
|||
new DecryptedPayload(
|
||||
{
|
||||
uuid: mockUuid(),
|
||||
content_type: ContentType.SmartView,
|
||||
content_type: ContentType.TYPES.SmartView,
|
||||
content: FillItemContent<SmartViewContent>({ title }),
|
||||
...PayloadTimestampDefaults(),
|
||||
},
|
||||
|
|
@ -103,7 +103,7 @@ export const createFile = (name = 'screenshot.png') => {
|
|||
new DecryptedPayload(
|
||||
{
|
||||
uuid: mockUuid(),
|
||||
content_type: ContentType.File,
|
||||
content_type: ContentType.TYPES.File,
|
||||
content: FillItemContent<FileContent>({ name }),
|
||||
...PayloadTimestampDefaults(),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
"typescript": "*"
|
||||
},
|
||||
"dependencies": {
|
||||
"@standardnotes/common": "^1.48.3",
|
||||
"@standardnotes/common": "^1.50.0",
|
||||
"@standardnotes/features": "workspace:*",
|
||||
"@standardnotes/security": "^1.7.6",
|
||||
"reflect-metadata": "^0.1.13"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
import { ContentType } from '@standardnotes/common'
|
||||
|
||||
export interface ServerItemResponse {
|
||||
content_type: ContentType
|
||||
content_type: string
|
||||
content: string | undefined
|
||||
created_at_timestamp: number
|
||||
created_at: Date
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import { AnyKeyParamsContent, ContentType } from '@standardnotes/common'
|
||||
import { AnyKeyParamsContent } from '@standardnotes/common'
|
||||
import { DeprecatedHttpResponse } from '../Http/DeprecatedHttpResponse'
|
||||
import { ServerItemResponse } from '../Item/ServerItemResponse'
|
||||
|
||||
export type ActionResponse = DeprecatedHttpResponse & {
|
||||
description: string
|
||||
supported_types: ContentType[]
|
||||
supported_types: string[]
|
||||
deprecation?: string
|
||||
actions: unknown[]
|
||||
item?: ServerItemResponse
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@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/encryption": "workspace:^",
|
||||
"@standardnotes/features": "workspace:^",
|
||||
"@standardnotes/files": "workspace:^",
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue