chore: fix ContentType usage (#2353)

* chore: fix ContentType usage

* chore: fix specs
This commit is contained in:
Karol Sójko
2023-07-12 13:53:29 +02:00
committed by GitHub
parent d057cdff84
commit 325737bfbd
247 changed files with 1092 additions and 1060 deletions

View File

@@ -36,8 +36,8 @@
"typescript": "*" "typescript": "*"
}, },
"dependencies": { "dependencies": {
"@standardnotes/common": "^1.48.3", "@standardnotes/common": "^1.50.0",
"@standardnotes/domain-core": "^1.12.0", "@standardnotes/domain-core": "^1.22.0",
"@standardnotes/models": "workspace:*", "@standardnotes/models": "workspace:*",
"@standardnotes/responses": "workspace:*", "@standardnotes/responses": "workspace:*",
"@standardnotes/security": "^1.7.6", "@standardnotes/security": "^1.7.6",

View File

@@ -35,7 +35,7 @@
}, },
"dependencies": { "dependencies": {
"@electron/remote": "^2.0.9", "@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/electron-clear-data": "1.1.1",
"@standardnotes/web": "workspace:*", "@standardnotes/web": "workspace:*",
"axios": "^1.1.3", "axios": "^1.1.3",

View File

@@ -28,7 +28,8 @@
"typescript": "*" "typescript": "*"
}, },
"dependencies": { "dependencies": {
"@standardnotes/common": "^1.48.3", "@standardnotes/common": "^1.50.0",
"@standardnotes/domain-core": "^1.22.0",
"@standardnotes/models": "workspace:*", "@standardnotes/models": "workspace:*",
"@standardnotes/responses": "workspace:*", "@standardnotes/responses": "workspace:*",
"@standardnotes/sncrypto-common": "workspace:*", "@standardnotes/sncrypto-common": "workspace:*",

View File

@@ -1,4 +1,5 @@
import { ContentType, ProtocolVersion } from '@standardnotes/common' import { ProtocolVersion } from '@standardnotes/common'
import { ContentType } from '@standardnotes/domain-core'
import { import {
ConflictStrategy, ConflictStrategy,
DecryptedItem, DecryptedItem,
@@ -10,7 +11,7 @@ import {
} from '@standardnotes/models' } from '@standardnotes/models'
export function isItemsKey(x: unknown): x is ItemsKeyInterface { 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
} }
/** /**

View File

@@ -1,6 +1,10 @@
import { ContentType } from '@standardnotes/common'
import { DecryptedItemMutator, ItemsKeyContent, RegisterItemClass } from '@standardnotes/models' import { DecryptedItemMutator, ItemsKeyContent, RegisterItemClass } from '@standardnotes/models'
import { ContentType } from '@standardnotes/domain-core'
import { SNItemsKey } from './ItemsKey' import { SNItemsKey } from './ItemsKey'
import { ItemsKeyMutator } from './ItemsKeyMutator' 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>,
)

View File

@@ -1,4 +1,5 @@
import { ContentType, ProtocolVersion } from '@standardnotes/common' import { ProtocolVersion } from '@standardnotes/common'
import { ContentType } from '@standardnotes/domain-core'
import { import {
ConflictStrategy, ConflictStrategy,
DecryptedItem, DecryptedItem,
@@ -10,7 +11,7 @@ import {
} from '@standardnotes/models' } from '@standardnotes/models'
export function isKeySystemItemsKey(x: unknown): x is KeySystemItemsKeyInterface { 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
} }
/** /**

View File

@@ -1,10 +1,11 @@
import { ContentType } from '@standardnotes/common'
import { DecryptedItemMutator, KeySystemItemsKeyContent, RegisterItemClass } from '@standardnotes/models' import { DecryptedItemMutator, KeySystemItemsKeyContent, RegisterItemClass } from '@standardnotes/models'
import { ContentType } from '@standardnotes/domain-core'
import { KeySystemItemsKey } from './KeySystemItemsKey' import { KeySystemItemsKey } from './KeySystemItemsKey'
import { KeySystemItemsKeyMutator } from './KeySystemItemsKeyMutator' import { KeySystemItemsKeyMutator } from './KeySystemItemsKeyMutator'
RegisterItemClass( RegisterItemClass(
ContentType.KeySystemItemsKey, ContentType.TYPES.KeySystemItemsKey,
KeySystemItemsKey, KeySystemItemsKey,
KeySystemItemsKeyMutator as unknown as DecryptedItemMutator<KeySystemItemsKeyContent>, KeySystemItemsKeyMutator as unknown as DecryptedItemMutator<KeySystemItemsKeyContent>,
) )

View File

@@ -1,4 +1,4 @@
import { ContentType, ProtocolVersion } from '@standardnotes/common' import { ProtocolVersion } from '@standardnotes/common'
import { import {
DecryptedPayload, DecryptedPayload,
FillItemContentSpecialized, FillItemContentSpecialized,
@@ -9,13 +9,14 @@ import {
} from '@standardnotes/models' } from '@standardnotes/models'
import { UuidGenerator } from '@standardnotes/utils' import { UuidGenerator } from '@standardnotes/utils'
import { SNRootKey } from './RootKey' import { SNRootKey } from './RootKey'
import { ContentType } from '@standardnotes/domain-core'
export function CreateNewRootKey<K extends RootKeyInterface>(content: RootKeyContentSpecialized): K { export function CreateNewRootKey<K extends RootKeyInterface>(content: RootKeyContentSpecialized): K {
const uuid = UuidGenerator.GenerateUuid() const uuid = UuidGenerator.GenerateUuid()
const payload = new DecryptedPayload<RootKeyContent>({ const payload = new DecryptedPayload<RootKeyContent>({
uuid: uuid, uuid: uuid,
content_type: ContentType.RootKey, content_type: ContentType.TYPES.RootKey,
content: FillRootKeyContent(content), content: FillRootKeyContent(content),
...PayloadTimestampDefaults(), ...PayloadTimestampDefaults(),
}) })

View File

@@ -1,4 +1,4 @@
import { ContentType, KeyParamsOrigination, ProtocolVersion, ProtocolVersionLength } from '@standardnotes/common' import { KeyParamsOrigination, ProtocolVersion, ProtocolVersionLength } from '@standardnotes/common'
import { import {
CreateDecryptedItemFromPayload, CreateDecryptedItemFromPayload,
DecryptedPayload, DecryptedPayload,
@@ -32,6 +32,7 @@ import { PublicKeySet } from '../Types/PublicKeySet'
import { AsymmetricDecryptResult } from '../Types/AsymmetricDecryptResult' import { AsymmetricDecryptResult } from '../Types/AsymmetricDecryptResult'
import { AsymmetricSignatureVerificationDetachedResult } from '../Types/AsymmetricSignatureVerificationDetachedResult' import { AsymmetricSignatureVerificationDetachedResult } from '../Types/AsymmetricSignatureVerificationDetachedResult'
import { AsyncOperatorInterface } from '../OperatorInterface/AsyncOperatorInterface' import { AsyncOperatorInterface } from '../OperatorInterface/AsyncOperatorInterface'
import { ContentType } from '@standardnotes/domain-core'
const NO_IV = '00000000000000000000000000000000' const NO_IV = '00000000000000000000000000000000'
@@ -71,7 +72,7 @@ export class SNProtocolOperator001 implements OperatorInterface, AsyncOperatorIn
public createItemsKey(): ItemsKeyInterface { public createItemsKey(): ItemsKeyInterface {
const payload = new DecryptedPayload({ const payload = new DecryptedPayload({
uuid: UuidGenerator.GenerateUuid(), uuid: UuidGenerator.GenerateUuid(),
content_type: ContentType.ItemsKey, content_type: ContentType.TYPES.ItemsKey,
content: this.generateNewItemsKeyContent(), content: this.generateNewItemsKeyContent(),
...PayloadTimestampDefaults(), ...PayloadTimestampDefaults(),
}) })

View File

@@ -1,5 +1,6 @@
import * as Common from '@standardnotes/common' import * as Common from '@standardnotes/common'
import * as Models from '@standardnotes/models' import * as Models from '@standardnotes/models'
import { ContentType } from '@standardnotes/domain-core'
import { ItemContent, PayloadTimestampDefaults } from '@standardnotes/models' import { ItemContent, PayloadTimestampDefaults } from '@standardnotes/models'
import * as Utils from '@standardnotes/utils' import * as Utils from '@standardnotes/utils'
import { UuidGenerator } from '@standardnotes/utils' import { UuidGenerator } from '@standardnotes/utils'
@@ -44,7 +45,7 @@ export class SNProtocolOperator002 extends SNProtocolOperator001 {
public override createItemsKey(): Models.ItemsKeyInterface { public override createItemsKey(): Models.ItemsKeyInterface {
const payload = new Models.DecryptedPayload({ const payload = new Models.DecryptedPayload({
uuid: UuidGenerator.GenerateUuid(), uuid: UuidGenerator.GenerateUuid(),
content_type: Common.ContentType.ItemsKey, content_type: ContentType.TYPES.ItemsKey,
content: this.generateNewItemsKeyContent(), content: this.generateNewItemsKeyContent(),
...PayloadTimestampDefaults(), ...PayloadTimestampDefaults(),
}) })

View File

@@ -1,4 +1,4 @@
import { ContentType, KeyParamsOrigination, ProtocolVersion } from '@standardnotes/common' import { KeyParamsOrigination, ProtocolVersion } from '@standardnotes/common'
import { import {
CreateDecryptedItemFromPayload, CreateDecryptedItemFromPayload,
DecryptedPayload, DecryptedPayload,
@@ -14,6 +14,7 @@ import { CreateNewRootKey } from '../../Keys/RootKey/Functions'
import { Create003KeyParams } from '../../Keys/RootKey/KeyParamsFunctions' import { Create003KeyParams } from '../../Keys/RootKey/KeyParamsFunctions'
import { SNRootKeyParams } from '../../Keys/RootKey/RootKeyParams' import { SNRootKeyParams } from '../../Keys/RootKey/RootKeyParams'
import { SNProtocolOperator002 } from '../002/Operator002' import { SNProtocolOperator002 } from '../002/Operator002'
import { ContentType } from '@standardnotes/domain-core'
/** /**
* @legacy * @legacy
@@ -46,7 +47,7 @@ export class SNProtocolOperator003 extends SNProtocolOperator002 {
const content = this.generateNewItemsKeyContent() const content = this.generateNewItemsKeyContent()
const payload = new DecryptedPayload({ const payload = new DecryptedPayload({
uuid: UuidGenerator.GenerateUuid(), uuid: UuidGenerator.GenerateUuid(),
content_type: ContentType.ItemsKey, content_type: ContentType.TYPES.ItemsKey,
content: FillItemContent(content), content: FillItemContent(content),
...PayloadTimestampDefaults(), ...PayloadTimestampDefaults(),
}) })

View File

@@ -1,9 +1,10 @@
import { ContentType, ProtocolVersion } from '@standardnotes/common' import { ProtocolVersion } from '@standardnotes/common'
import { DecryptedPayload, ItemContent, ItemsKeyContent, PayloadTimestampDefaults } from '@standardnotes/models' import { DecryptedPayload, ItemContent, ItemsKeyContent, PayloadTimestampDefaults } from '@standardnotes/models'
import { SNItemsKey } from '../../Keys/ItemsKey/ItemsKey' import { SNItemsKey } from '../../Keys/ItemsKey/ItemsKey'
import { SNProtocolOperator004 } from './Operator004' import { SNProtocolOperator004 } from './Operator004'
import { getMockedCrypto } from './MockedCrypto' import { getMockedCrypto } from './MockedCrypto'
import { deconstructEncryptedPayloadString } from './V004AlgorithmHelpers' import { deconstructEncryptedPayloadString } from './V004AlgorithmHelpers'
import { ContentType } from '@standardnotes/domain-core'
describe('operator 004', () => { describe('operator 004', () => {
const crypto = getMockedCrypto() const crypto = getMockedCrypto()
@@ -31,7 +32,7 @@ describe('operator 004', () => {
it('should generateEncryptedParameters', () => { it('should generateEncryptedParameters', () => {
const payload = { const payload = {
uuid: '123', uuid: '123',
content_type: ContentType.Note, content_type: ContentType.TYPES.Note,
content: { foo: 'bar' } as unknown as jest.Mocked<ItemContent>, content: { foo: 'bar' } as unknown as jest.Mocked<ItemContent>,
...PayloadTimestampDefaults(), ...PayloadTimestampDefaults(),
} as jest.Mocked<DecryptedPayload> } as jest.Mocked<DecryptedPayload>
@@ -39,7 +40,7 @@ describe('operator 004', () => {
const key = new SNItemsKey( const key = new SNItemsKey(
new DecryptedPayload<ItemsKeyContent>({ new DecryptedPayload<ItemsKeyContent>({
uuid: 'key-456', uuid: 'key-456',
content_type: ContentType.ItemsKey, content_type: ContentType.TYPES.ItemsKey,
content: { content: {
itemsKey: 'secret', itemsKey: 'secret',
version: ProtocolVersion.V004, version: ProtocolVersion.V004,
@@ -56,7 +57,7 @@ describe('operator 004', () => {
key_system_identifier: undefined, key_system_identifier: undefined,
shared_vault_uuid: undefined, shared_vault_uuid: undefined,
content: '004:random-string:<e>{"foo"|"bar"}<e>:base64-{"u"|"123","v"|"004"}:base64-{}', 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-{}', enc_item_key: '004:random-string:<e>random-string<e>:base64-{"u"|"123","v"|"004"}:base64-{}',
version: '004', version: '004',
}) })

View File

@@ -13,7 +13,7 @@ import {
RootKeyInterface, RootKeyInterface,
KeySystemRootKeyParamsInterface, KeySystemRootKeyParamsInterface,
} from '@standardnotes/models' } 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 { HexString, PkcKeyPair, PureCryptoInterface, Utf8String } from '@standardnotes/sncrypto-common'
import { V004Algorithm } from '../../Algorithm' import { V004Algorithm } from '../../Algorithm'
import { SNRootKeyParams } from '../../Keys/RootKey/RootKeyParams' import { SNRootKeyParams } from '../../Keys/RootKey/RootKeyParams'
@@ -48,6 +48,7 @@ import { AsymmetricSignatureVerificationDetachedResult } from '../Types/Asymmetr
import { AsymmetricSignatureVerificationDetachedUseCase } from './UseCase/Asymmetric/AsymmetricSignatureVerificationDetached' import { AsymmetricSignatureVerificationDetachedUseCase } from './UseCase/Asymmetric/AsymmetricSignatureVerificationDetached'
import { DeriveKeySystemRootKeyUseCase } from './UseCase/KeySystem/DeriveKeySystemRootKey' import { DeriveKeySystemRootKeyUseCase } from './UseCase/KeySystem/DeriveKeySystemRootKey'
import { SyncOperatorInterface } from '../OperatorInterface/SyncOperatorInterface' import { SyncOperatorInterface } from '../OperatorInterface/SyncOperatorInterface'
import { ContentType } from '@standardnotes/domain-core'
export class SNProtocolOperator004 implements OperatorInterface, SyncOperatorInterface { export class SNProtocolOperator004 implements OperatorInterface, SyncOperatorInterface {
constructor(protected readonly crypto: PureCryptoInterface) {} constructor(protected readonly crypto: PureCryptoInterface) {}
@@ -76,7 +77,7 @@ export class SNProtocolOperator004 implements OperatorInterface, SyncOperatorInt
public createItemsKey(): ItemsKeyInterface { public createItemsKey(): ItemsKeyInterface {
const payload = new DecryptedPayload({ const payload = new DecryptedPayload({
uuid: UuidGenerator.GenerateUuid(), uuid: UuidGenerator.GenerateUuid(),
content_type: ContentType.ItemsKey, content_type: ContentType.TYPES.ItemsKey,
content: this.generateNewItemsKeyContent(), content: this.generateNewItemsKeyContent(),
key_system_identifier: undefined, key_system_identifier: undefined,
shared_vault_uuid: undefined, shared_vault_uuid: undefined,

View File

@@ -10,7 +10,8 @@ import {
} from '@standardnotes/models' } from '@standardnotes/models'
import { PureCryptoInterface } from '@standardnotes/sncrypto-common' import { PureCryptoInterface } from '@standardnotes/sncrypto-common'
import { V004Algorithm } from '../../../../Algorithm' import { V004Algorithm } from '../../../../Algorithm'
import { ContentType, ProtocolVersion } from '@standardnotes/common' import { ProtocolVersion } from '@standardnotes/common'
import { ContentType } from '@standardnotes/domain-core'
export class CreateKeySystemItemsKeyUseCase { export class CreateKeySystemItemsKeyUseCase {
constructor(private readonly crypto: PureCryptoInterface) {} constructor(private readonly crypto: PureCryptoInterface) {}
@@ -31,7 +32,7 @@ export class CreateKeySystemItemsKeyUseCase {
const transferPayload: DecryptedTransferPayload = { const transferPayload: DecryptedTransferPayload = {
uuid: dto.uuid, uuid: dto.uuid,
content_type: ContentType.KeySystemItemsKey, content_type: ContentType.TYPES.KeySystemItemsKey,
key_system_identifier: dto.keySystemIdentifier, key_system_identifier: dto.keySystemIdentifier,
shared_vault_uuid: dto.sharedVaultUuid, shared_vault_uuid: dto.sharedVaultUuid,
content: content, content: content,

View File

@@ -12,7 +12,8 @@ import {
PayloadTimestampDefaults, PayloadTimestampDefaults,
KeySystemRootKeyParamsInterface, KeySystemRootKeyParamsInterface,
} from '@standardnotes/models' } from '@standardnotes/models'
import { ContentType, ProtocolVersion } from '@standardnotes/common' import { ProtocolVersion } from '@standardnotes/common'
import { ContentType } from '@standardnotes/domain-core'
export class DeriveKeySystemRootKeyUseCase { export class DeriveKeySystemRootKeyUseCase {
constructor(private readonly crypto: PureCryptoInterface) {} constructor(private readonly crypto: PureCryptoInterface) {}
@@ -44,7 +45,7 @@ export class DeriveKeySystemRootKeyUseCase {
const payload = new DecryptedPayload<KeySystemRootKeyContent>({ const payload = new DecryptedPayload<KeySystemRootKeyContent>({
uuid: uuid, uuid: uuid,
content_type: ContentType.KeySystemRootKey, content_type: ContentType.TYPES.KeySystemRootKey,
content: FillItemContentSpecialized(content), content: FillItemContentSpecialized(content),
...PayloadTimestampDefaults(), ...PayloadTimestampDefaults(),
}) })

View File

@@ -1,5 +1,5 @@
import { CreateAnyKeyParams } from '../../../../Keys/RootKey/KeyParamsFunctions' import { CreateAnyKeyParams } from '../../../../Keys/RootKey/KeyParamsFunctions'
import { AnyKeyParamsContent, ContentType, ProtocolVersion } from '@standardnotes/common' import { AnyKeyParamsContent, ProtocolVersion } from '@standardnotes/common'
import { GenerateAuthenticatedDataUseCase } from './GenerateAuthenticatedData' import { GenerateAuthenticatedDataUseCase } from './GenerateAuthenticatedData'
import { import {
DecryptedPayloadInterface, DecryptedPayloadInterface,
@@ -8,6 +8,7 @@ import {
RootKeyInterface, RootKeyInterface,
} from '@standardnotes/models' } from '@standardnotes/models'
import { KeySystemItemsKey } from '../../../../Keys/KeySystemItemsKey/KeySystemItemsKey' import { KeySystemItemsKey } from '../../../../Keys/KeySystemItemsKey/KeySystemItemsKey'
import { ContentType } from '@standardnotes/domain-core'
describe('generate authenticated data use case', () => { describe('generate authenticated data use case', () => {
let usecase: GenerateAuthenticatedDataUseCase 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', () => { it('should include key params if payload being encrypted is an items key', () => {
const payload = { const payload = {
uuid: '123', uuid: '123',
content_type: ContentType.ItemsKey, content_type: ContentType.TYPES.ItemsKey,
} as jest.Mocked<DecryptedPayloadInterface> } as jest.Mocked<DecryptedPayloadInterface>
const keyParams = CreateAnyKeyParams({ 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', () => { it('should include root key params if payload is a key system items key', () => {
const payload = { const payload = {
uuid: '123', uuid: '123',
content_type: ContentType.KeySystemItemsKey, content_type: ContentType.TYPES.KeySystemItemsKey,
shared_vault_uuid: 'shared-vault-uuid-123', shared_vault_uuid: 'shared-vault-uuid-123',
key_system_identifier: 'key-system-identifier-123', key_system_identifier: 'key-system-identifier-123',
} as jest.Mocked<DecryptedPayloadInterface> } as jest.Mocked<DecryptedPayloadInterface>
@@ -52,7 +53,7 @@ describe('generate authenticated data use case', () => {
keyParams: { keyParams: {
seed: 'seed-123', seed: 'seed-123',
}, },
content_type: ContentType.KeySystemRootKey, content_type: ContentType.TYPES.KeySystemRootKey,
token: '123', token: '123',
} as jest.Mocked<KeySystemRootKeyInterface> } as jest.Mocked<KeySystemRootKeyInterface>
@@ -70,7 +71,7 @@ describe('generate authenticated data use case', () => {
it('should include key system identifier and shared vault uuid', () => { it('should include key system identifier and shared vault uuid', () => {
const payload = { const payload = {
uuid: '123', uuid: '123',
content_type: ContentType.Note, content_type: ContentType.TYPES.Note,
shared_vault_uuid: 'shared-vault-uuid-123', shared_vault_uuid: 'shared-vault-uuid-123',
key_system_identifier: 'key-system-identifier-123', key_system_identifier: 'key-system-identifier-123',
} as jest.Mocked<DecryptedPayloadInterface> } as jest.Mocked<DecryptedPayloadInterface>
@@ -78,7 +79,7 @@ describe('generate authenticated data use case', () => {
const itemsKey = { const itemsKey = {
creationTimestamp: 123, creationTimestamp: 123,
keyVersion: ProtocolVersion.V004, keyVersion: ProtocolVersion.V004,
content_type: ContentType.KeySystemItemsKey, content_type: ContentType.TYPES.KeySystemItemsKey,
} as jest.Mocked<KeySystemItemsKey> } as jest.Mocked<KeySystemItemsKey>
const authenticatedData = usecase.execute(payload, itemsKey) 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', () => { it('should include only uuid and version if non-keysystem item with items key', () => {
const payload = { const payload = {
uuid: '123', uuid: '123',
content_type: ContentType.Note, content_type: ContentType.TYPES.Note,
} as jest.Mocked<DecryptedPayloadInterface> } as jest.Mocked<DecryptedPayloadInterface>
const itemsKey = { const itemsKey = {
content_type: ContentType.ItemsKey, content_type: ContentType.TYPES.ItemsKey,
} as jest.Mocked<ItemsKeyInterface> } as jest.Mocked<ItemsKeyInterface>
const authenticatedData = usecase.execute(payload, itemsKey) const authenticatedData = usecase.execute(payload, itemsKey)

View File

@@ -1,10 +1,10 @@
import { PkcKeyPair, PureCryptoInterface } from '@standardnotes/sncrypto-common' import { PkcKeyPair, PureCryptoInterface } from '@standardnotes/sncrypto-common'
import { getMockedCrypto } from '../../MockedCrypto' import { getMockedCrypto } from '../../MockedCrypto'
import { GenerateDecryptedParametersUseCase } from './GenerateDecryptedParameters' import { GenerateDecryptedParametersUseCase } from './GenerateDecryptedParameters'
import { ContentType } from '@standardnotes/common'
import { DecryptedPayloadInterface, ItemsKeyInterface } from '@standardnotes/models' import { DecryptedPayloadInterface, ItemsKeyInterface } from '@standardnotes/models'
import { GenerateEncryptedParametersUseCase } from './GenerateEncryptedParameters' import { GenerateEncryptedParametersUseCase } from './GenerateEncryptedParameters'
import { EncryptedInputParameters, EncryptedOutputParameters } from '../../../../Types/EncryptedParameters' import { EncryptedInputParameters, EncryptedOutputParameters } from '../../../../Types/EncryptedParameters'
import { ContentType } from '@standardnotes/domain-core'
describe('generate decrypted parameters usecase', () => { describe('generate decrypted parameters usecase', () => {
let crypto: PureCryptoInterface let crypto: PureCryptoInterface
@@ -18,7 +18,7 @@ describe('generate decrypted parameters usecase', () => {
itemsKey = { itemsKey = {
uuid: 'items-key-id', uuid: 'items-key-id',
itemsKey: 'items-key', itemsKey: 'items-key',
content_type: ContentType.ItemsKey, content_type: ContentType.TYPES.ItemsKey,
} as jest.Mocked<ItemsKeyInterface> } as jest.Mocked<ItemsKeyInterface>
}) })
@@ -28,7 +28,7 @@ describe('generate decrypted parameters usecase', () => {
content: { content: {
text: plaintext, text: plaintext,
}, },
content_type: ContentType.Note, content_type: ContentType.TYPES.Note,
} as unknown as jest.Mocked<DecryptedPayloadInterface> } as unknown as jest.Mocked<DecryptedPayloadInterface>
const encryptedParametersUsecase = new GenerateEncryptedParametersUseCase(crypto) const encryptedParametersUsecase = new GenerateEncryptedParametersUseCase(crypto)

View File

@@ -1,6 +1,6 @@
import { PkcKeyPair, PureCryptoInterface } from '@standardnotes/sncrypto-common' import { PkcKeyPair, PureCryptoInterface } from '@standardnotes/sncrypto-common'
import { getMockedCrypto } from '../../MockedCrypto' import { getMockedCrypto } from '../../MockedCrypto'
import { AnyKeyParamsContent, ContentType, ProtocolVersion } from '@standardnotes/common' import { AnyKeyParamsContent, ProtocolVersion } from '@standardnotes/common'
import { GenerateEncryptedParametersUseCase } from './GenerateEncryptedParameters' import { GenerateEncryptedParametersUseCase } from './GenerateEncryptedParameters'
import { import {
DecryptedPayloadInterface, DecryptedPayloadInterface,
@@ -11,6 +11,7 @@ import {
import { deconstructEncryptedPayloadString } from '../../V004AlgorithmHelpers' import { deconstructEncryptedPayloadString } from '../../V004AlgorithmHelpers'
import { ParseConsistentBase64JsonPayloadUseCase } from '../Utils/ParseConsistentBase64JsonPayload' import { ParseConsistentBase64JsonPayloadUseCase } from '../Utils/ParseConsistentBase64JsonPayload'
import { SymmetricItemAdditionalData } from '../../../../Types/EncryptionAdditionalData' import { SymmetricItemAdditionalData } from '../../../../Types/EncryptionAdditionalData'
import { ContentType } from '@standardnotes/domain-core'
describe('generate encrypted parameters usecase', () => { describe('generate encrypted parameters usecase', () => {
let crypto: PureCryptoInterface let crypto: PureCryptoInterface
@@ -29,20 +30,20 @@ describe('generate encrypted parameters usecase', () => {
title: 'title', title: 'title',
text: 'text', text: 'text',
}, },
content_type: ContentType.Note, content_type: ContentType.TYPES.Note,
} as unknown as jest.Mocked<DecryptedPayloadInterface> } as unknown as jest.Mocked<DecryptedPayloadInterface>
const itemsKey = { const itemsKey = {
uuid: 'items-key-id', uuid: 'items-key-id',
itemsKey: 'items-key', itemsKey: 'items-key',
content_type: ContentType.ItemsKey, content_type: ContentType.TYPES.ItemsKey,
} as jest.Mocked<ItemsKeyInterface> } as jest.Mocked<ItemsKeyInterface>
const result = usecase.execute(decrypted, itemsKey) const result = usecase.execute(decrypted, itemsKey)
expect(result).toEqual({ expect(result).toEqual({
uuid: '123', uuid: '123',
content_type: ContentType.Note, content_type: ContentType.TYPES.Note,
items_key_id: 'items-key-id', items_key_id: 'items-key-id',
content: expect.any(String), content: expect.any(String),
enc_item_key: expect.any(String), enc_item_key: expect.any(String),
@@ -57,7 +58,7 @@ describe('generate encrypted parameters usecase', () => {
content: { content: {
foo: 'bar', foo: 'bar',
}, },
content_type: ContentType.ItemsKey, content_type: ContentType.TYPES.ItemsKey,
} as unknown as jest.Mocked<DecryptedPayloadInterface> } as unknown as jest.Mocked<DecryptedPayloadInterface>
const rootKey = { const rootKey = {
@@ -66,7 +67,7 @@ describe('generate encrypted parameters usecase', () => {
keyParams: { keyParams: {
content: {} as jest.Mocked<AnyKeyParamsContent>, content: {} as jest.Mocked<AnyKeyParamsContent>,
}, },
content_type: ContentType.RootKey, content_type: ContentType.TYPES.RootKey,
} as jest.Mocked<RootKeyInterface> } as jest.Mocked<RootKeyInterface>
const result = usecase.execute(decrypted, rootKey) const result = usecase.execute(decrypted, rootKey)
@@ -80,13 +81,13 @@ describe('generate encrypted parameters usecase', () => {
content: { content: {
foo: 'bar', foo: 'bar',
}, },
content_type: ContentType.KeySystemItemsKey, content_type: ContentType.TYPES.KeySystemItemsKey,
} as unknown as jest.Mocked<DecryptedPayloadInterface> } as unknown as jest.Mocked<DecryptedPayloadInterface>
const rootKey = { const rootKey = {
uuid: 'items-key-id', uuid: 'items-key-id',
itemsKey: 'items-key', itemsKey: 'items-key',
content_type: ContentType.KeySystemRootKey, content_type: ContentType.TYPES.KeySystemRootKey,
} as jest.Mocked<KeySystemRootKeyInterface> } as jest.Mocked<KeySystemRootKeyInterface>
const result = usecase.execute(decrypted, rootKey) const result = usecase.execute(decrypted, rootKey)
@@ -111,13 +112,13 @@ describe('generate encrypted parameters usecase', () => {
title: 'title', title: 'title',
text: 'text', text: 'text',
}, },
content_type: ContentType.Note, content_type: ContentType.TYPES.Note,
} as unknown as jest.Mocked<DecryptedPayloadInterface> } as unknown as jest.Mocked<DecryptedPayloadInterface>
const itemsKey = { const itemsKey = {
uuid: 'items-key-id', uuid: 'items-key-id',
itemsKey: 'items-key', itemsKey: 'items-key',
content_type: ContentType.ItemsKey, content_type: ContentType.TYPES.ItemsKey,
} as jest.Mocked<ItemsKeyInterface> } as jest.Mocked<ItemsKeyInterface>
const result = usecase.execute(decrypted, itemsKey, signingKeyPair) const result = usecase.execute(decrypted, itemsKey, signingKeyPair)

View File

@@ -1,11 +1,11 @@
import { ContentType, ProtocolVersion } from '@standardnotes/common' import { ProtocolVersion } from '@standardnotes/common'
import { EncryptedPayloadInterface, DecryptedPayloadInterface, PersistentSignatureData } from '@standardnotes/models' import { EncryptedPayloadInterface, DecryptedPayloadInterface, PersistentSignatureData } from '@standardnotes/models'
import { DecryptedParameters } from './DecryptedParameters' import { DecryptedParameters } from './DecryptedParameters'
export type EncryptedOutputParameters = { export type EncryptedOutputParameters = {
uuid: string uuid: string
content: string content: string
content_type: ContentType content_type: string
items_key_id: string | undefined items_key_id: string | undefined
enc_item_key: string enc_item_key: string
version: ProtocolVersion version: ProtocolVersion

View File

@@ -25,8 +25,8 @@
"test": "jest" "test": "jest"
}, },
"dependencies": { "dependencies": {
"@standardnotes/common": "^1.48.3", "@standardnotes/common": "^1.50.0",
"@standardnotes/domain-core": "^1.12.0", "@standardnotes/domain-core": "^1.22.0",
"@standardnotes/security": "^1.7.6", "@standardnotes/security": "^1.7.6",
"reflect-metadata": "^0.1.13" "reflect-metadata": "^0.1.13"
}, },

View File

@@ -1,7 +1,6 @@
import { ContentType } from '@standardnotes/common'
import { ComponentAction } from './ComponentAction' import { ComponentAction } from './ComponentAction'
export type ComponentPermission = { export type ComponentPermission = {
name: ComponentAction name: ComponentAction
content_types?: ContentType[] content_types?: string[]
} }

View File

@@ -1,5 +1,4 @@
import { ComponentPermission } from '../Component/ComponentPermission' import { ComponentPermission } from '../Component/ComponentPermission'
import { ContentType } from '@standardnotes/common'
import { ComponentArea } from '../Component/ComponentArea' import { ComponentArea } from '../Component/ComponentArea'
import { PermissionName } from '../Permission/PermissionName' import { PermissionName } from '../Permission/PermissionName'
import { FeatureIdentifier } from './FeatureIdentifier' import { FeatureIdentifier } from './FeatureIdentifier'
@@ -51,7 +50,7 @@ export type ClientFeatureDescription = RoleFields & {
export type ComponentFeatureDescription = BaseFeatureDescription & { export type ComponentFeatureDescription = BaseFeatureDescription & {
/** The relative path of the index.html file or the main css file if theme, within the component folder itself */ /** The relative path of the index.html file or the main css file if theme, within the component folder itself */
index_path: string index_path: string
content_type: ContentType content_type: string
area: ComponentArea area: ComponentArea
} }

View File

@@ -1,4 +1,4 @@
import { ContentType } from '@standardnotes/common' import { ContentType, RoleName } from '@standardnotes/domain-core'
import { import {
EditorFeatureDescription, EditorFeatureDescription,
IframeComponentFeatureDescription, IframeComponentFeatureDescription,
@@ -10,7 +10,6 @@ import { NoteType } from '../Component/NoteType'
import { FillEditorComponentDefaults } from './Utilities/FillEditorComponentDefaults' import { FillEditorComponentDefaults } from './Utilities/FillEditorComponentDefaults'
import { ComponentAction } from '../Component/ComponentAction' import { ComponentAction } from '../Component/ComponentAction'
import { ComponentArea } from '../Component/ComponentArea' import { ComponentArea } from '../Component/ComponentArea'
import { RoleName } from '@standardnotes/domain-core'
export function GetDeprecatedFeatures(): FeatureDescription[] { export function GetDeprecatedFeatures(): FeatureDescription[] {
const bold: EditorFeatureDescription = FillEditorComponentDefaults({ const bold: EditorFeatureDescription = FillEditorComponentDefaults({
@@ -21,14 +20,14 @@ export function GetDeprecatedFeatures(): FeatureDescription[] {
component_permissions: [ component_permissions: [
{ {
name: ComponentAction.StreamContextItem, name: ComponentAction.StreamContextItem,
content_types: [ContentType.Note], content_types: [ContentType.TYPES.Note],
}, },
{ {
name: ComponentAction.StreamItems, name: ComponentAction.StreamItems,
content_types: [ content_types: [
ContentType.FilesafeCredentials, ContentType.TYPES.FilesafeCredentials,
ContentType.FilesafeFileMetadata, ContentType.TYPES.FilesafeFileMetadata,
ContentType.FilesafeIntegration, ContentType.TYPES.FilesafeIntegration,
], ],
}, },
], ],
@@ -101,14 +100,14 @@ export function GetDeprecatedFeatures(): FeatureDescription[] {
component_permissions: [ component_permissions: [
{ {
name: ComponentAction.StreamContextItem, name: ComponentAction.StreamContextItem,
content_types: [ContentType.Note], content_types: [ContentType.TYPES.Note],
}, },
{ {
name: ComponentAction.StreamItems, name: ComponentAction.StreamItems,
content_types: [ content_types: [
ContentType.FilesafeCredentials, ContentType.TYPES.FilesafeCredentials,
ContentType.FilesafeFileMetadata, ContentType.TYPES.FilesafeFileMetadata,
ContentType.FilesafeIntegration, ContentType.TYPES.FilesafeIntegration,
], ],
}, },
], ],

View File

@@ -1,5 +1,6 @@
import { ContentType } from '@standardnotes/domain-core'
import { ComponentAction } from '../../Component/ComponentAction' import { ComponentAction } from '../../Component/ComponentAction'
import { ContentType } from '@standardnotes/common'
import { EditorFeatureDescription } from '../../Feature/FeatureDescription' import { EditorFeatureDescription } from '../../Feature/FeatureDescription'
import { ComponentArea } from '../../Component/ComponentArea' import { ComponentArea } from '../../Component/ComponentArea'
@@ -16,12 +17,12 @@ export function FillEditorComponentDefaults(
component.component_permissions = [ component.component_permissions = [
{ {
name: ComponentAction.StreamContextItem, 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) { if (!component.area) {
component.area = ComponentArea.Editor component.area = ComponentArea.Editor
} }

View File

@@ -1,4 +1,5 @@
import { ContentType } from '@standardnotes/common' import { ContentType } from '@standardnotes/domain-core'
import { ThemeFeatureDescription } from '../../Feature/FeatureDescription' import { ThemeFeatureDescription } from '../../Feature/FeatureDescription'
import { ComponentArea } from '../../Component/ComponentArea' import { ComponentArea } from '../../Component/ComponentArea'
@@ -11,7 +12,7 @@ export function FillThemeComponentDefaults(
theme.index_path = 'index.css' theme.index_path = 'index.css'
} }
theme.content_type = ContentType.Theme theme.content_type = ContentType.TYPES.Theme
if (!theme.area) { if (!theme.area) {
theme.area = ComponentArea.Themes theme.area = ComponentArea.Themes

View File

@@ -39,7 +39,7 @@ export class ClassicFileApi {
downloadFileBytes = async (remoteIdentifier: string): Promise<Uint8Array> => { downloadFileBytes = async (remoteIdentifier: string): Promise<Uint8Array> => {
console.log('Downloading file', remoteIdentifier) console.log('Downloading file', remoteIdentifier)
const file = this.application['itemManager'] const file = this.application['itemManager']
.getItems(ContentType.File) .getItems(ContentType.TYPES.File)
.find((file: FileItem) => file.remoteIdentifier === remoteIdentifier) .find((file: FileItem) => file.remoteIdentifier === remoteIdentifier)
let receivedBytes = new Uint8Array() let receivedBytes = new Uint8Array()

View File

@@ -26,7 +26,7 @@
"typescript": "*" "typescript": "*"
}, },
"dependencies": { "dependencies": {
"@standardnotes/common": "^1.48.3", "@standardnotes/common": "^1.50.0",
"@standardnotes/files": "workspace:*", "@standardnotes/files": "workspace:*",
"@standardnotes/utils": "workspace:*", "@standardnotes/utils": "workspace:*",
"@types/wicg-file-system-access": "^2020.9.5", "@types/wicg-file-system-access": "^2020.9.5",

View File

@@ -28,7 +28,7 @@
"typescript": "*" "typescript": "*"
}, },
"dependencies": { "dependencies": {
"@standardnotes/common": "^1.48.3", "@standardnotes/common": "^1.50.0",
"@standardnotes/encryption": "workspace:*", "@standardnotes/encryption": "workspace:*",
"@standardnotes/models": "workspace:*", "@standardnotes/models": "workspace:*",
"@standardnotes/responses": "workspace:*", "@standardnotes/responses": "workspace:*",

View File

@@ -22,7 +22,8 @@
"test": "jest" "test": "jest"
}, },
"dependencies": { "dependencies": {
"@standardnotes/common": "^1.48.3", "@standardnotes/common": "^1.50.0",
"@standardnotes/domain-core": "^1.22.0",
"@standardnotes/features": "workspace:*", "@standardnotes/features": "workspace:*",
"@standardnotes/responses": "workspace:*", "@standardnotes/responses": "workspace:*",
"@standardnotes/sncrypto-common": "workspace:^", "@standardnotes/sncrypto-common": "workspace:^",

View File

@@ -1,4 +1,3 @@
import { ContentType } from '@standardnotes/common'
import { ComponentPermission } from '@standardnotes/features' import { ComponentPermission } from '@standardnotes/features'
import { IncomingComponentItemPayload } from './IncomingComponentItemPayload' import { IncomingComponentItemPayload } from './IncomingComponentItemPayload'
@@ -8,7 +7,7 @@ export type MessageData = Partial<{
/** Related to the stream-item-context action */ /** Related to the stream-item-context action */
item?: IncomingComponentItemPayload item?: IncomingComponentItemPayload
/** Related to the stream-items action */ /** Related to the stream-items action */
content_types?: ContentType[] content_types?: string[]
items?: IncomingComponentItemPayload[] items?: IncomingComponentItemPayload[]
/** Related to the request-permission action */ /** Related to the request-permission action */
permissions?: ComponentPermission[] permissions?: ComponentPermission[]
@@ -25,7 +24,7 @@ export type MessageData = Partial<{
/** Related to themes action */ /** Related to themes action */
themes?: string[] themes?: string[]
/** Related to clear-selection action */ /** Related to clear-selection action */
content_type?: ContentType content_type?: string
/** Related to key-pressed action */ /** Related to key-pressed action */
keyboardModifier?: KeyboardModifier keyboardModifier?: KeyboardModifier
}> }>

View File

@@ -1,9 +1,8 @@
import { ItemContent } from './../Content/ItemContent' import { ItemContent } from './../Content/ItemContent'
import { ContentType } from '@standardnotes/common'
export type OutgoingItemMessagePayload<C extends ItemContent = ItemContent> = { export type OutgoingItemMessagePayload<C extends ItemContent = ItemContent> = {
uuid: string uuid: string
content_type: ContentType content_type: string
created_at: Date created_at: Date
updated_at: Date updated_at: Date
deleted?: boolean deleted?: boolean

View File

@@ -1,9 +1,8 @@
import { ContentType } from '@standardnotes/common'
import { ItemContent } from '../Content/ItemContent' import { ItemContent } from '../Content/ItemContent'
export interface ContextPayload<C extends ItemContent = ItemContent> { export interface ContextPayload<C extends ItemContent = ItemContent> {
uuid: string uuid: string
content_type: ContentType content_type: string
content: C | string | undefined content: C | string | undefined
deleted: boolean deleted: boolean

View File

@@ -1,4 +1,3 @@
import { ContentType } from '@standardnotes/common'
import { DecryptedPayloadInterface, DeletedPayloadInterface, isDeletedPayload } from '../Payload' import { DecryptedPayloadInterface, DeletedPayloadInterface, isDeletedPayload } from '../Payload'
/** /**
@@ -8,7 +7,7 @@ import { DecryptedPayloadInterface, DeletedPayloadInterface, isDeletedPayload }
* nothing else. * nothing else.
*/ */
export interface OfflineSyncSavedContextualPayload { export interface OfflineSyncSavedContextualPayload {
content_type: ContentType content_type: string
created_at_timestamp: number created_at_timestamp: number
deleted: boolean deleted: boolean
updated_at_timestamp?: number updated_at_timestamp?: number

View File

@@ -1,6 +1,5 @@
import { useBoolean } from '@standardnotes/utils' import { useBoolean } from '@standardnotes/utils'
import { FilteredServerItem } from './FilteredServerItem' import { FilteredServerItem } from './FilteredServerItem'
import { ContentType } from '@standardnotes/common'
/** /**
* The saved sync item payload represents the payload we want to map * The saved sync item payload represents the payload we want to map
@@ -9,7 +8,7 @@ import { ContentType } from '@standardnotes/common'
* nothing else. * nothing else.
*/ */
export interface ServerSyncSavedContextualPayload { export interface ServerSyncSavedContextualPayload {
content_type: ContentType content_type: string
created_at_timestamp: number created_at_timestamp: number
created_at: Date created_at: Date
deleted: boolean deleted: boolean

View File

@@ -1,4 +1,3 @@
import { ContentType } from '@standardnotes/common'
import { dateToLocalizedString, deepFreeze } from '@standardnotes/utils' import { dateToLocalizedString, deepFreeze } from '@standardnotes/utils'
import { TransferPayload } from './../../TransferPayload/Interfaces/TransferPayload' import { TransferPayload } from './../../TransferPayload/Interfaces/TransferPayload'
import { ItemContentsDiffer } from '../../../Utilities/Item/ItemContentsDiffer' import { ItemContentsDiffer } from '../../../Utilities/Item/ItemContentsDiffer'
@@ -36,7 +35,7 @@ export abstract class GenericItem<P extends PayloadInterface = PayloadInterface>
return this.payload.uuid return this.payload.uuid
} }
get content_type(): ContentType { get content_type(): string {
return this.payload.content_type return this.payload.content_type
} }

View File

@@ -1,4 +1,3 @@
import { ContentType } from '@standardnotes/common'
import { TransferPayload } from './../../TransferPayload/Interfaces/TransferPayload' import { TransferPayload } from './../../TransferPayload/Interfaces/TransferPayload'
import { PayloadInterface } from '../../Payload/Interfaces/PayloadInterface' import { PayloadInterface } from '../../Payload/Interfaces/PayloadInterface'
import { PredicateInterface } from '../../../Runtime/Predicate/Interface' 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 last_edited_by_uuid(): string | undefined
get signatureData(): PersistentSignatureData | undefined get signatureData(): PersistentSignatureData | undefined
content_type: ContentType content_type: string
created_at: Date created_at: Date
serverUpdatedAt: Date serverUpdatedAt: Date
serverUpdatedAtTimestamp: number | undefined serverUpdatedAtTimestamp: number | undefined

View File

@@ -1,4 +1,3 @@
import { ContentType } from '@standardnotes/common'
import { deepFreeze, useBoolean } from '@standardnotes/utils' import { deepFreeze, useBoolean } from '@standardnotes/utils'
import { PayloadInterface } from '../Interfaces/PayloadInterface' import { PayloadInterface } from '../Interfaces/PayloadInterface'
import { PayloadSource } from '../Types/PayloadSource' import { PayloadSource } from '../Types/PayloadSource'
@@ -19,7 +18,7 @@ export abstract class PurePayload<T extends TransferPayload<C>, C extends ItemCo
{ {
readonly source: PayloadSource readonly source: PayloadSource
readonly uuid: string readonly uuid: string
readonly content_type: ContentType readonly content_type: string
readonly deleted: boolean readonly deleted: boolean
readonly content: C | string | undefined readonly content: C | string | undefined

View File

@@ -1,5 +1,4 @@
import { SyncResolvedParams, SyncResolvedPayload } from './../../../Runtime/Deltas/Utilities/SyncResolvedPayload' import { SyncResolvedParams, SyncResolvedPayload } from './../../../Runtime/Deltas/Utilities/SyncResolvedPayload'
import { ContentType } from '@standardnotes/common'
import { ItemContent } from '../../Content/ItemContent' import { ItemContent } from '../../Content/ItemContent'
import { TransferPayload } from '../../TransferPayload/Interfaces/TransferPayload' import { TransferPayload } from '../../TransferPayload/Interfaces/TransferPayload'
import { PayloadSource } from '../Types/PayloadSource' 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> { export interface PayloadInterface<T extends TransferPayload = TransferPayload, C extends ItemContent = ItemContent> {
readonly source: PayloadSource readonly source: PayloadSource
readonly uuid: string readonly uuid: string
readonly content_type: ContentType readonly content_type: string
content: C | string | undefined content: C | string | undefined
deleted: boolean deleted: boolean

View File

@@ -1,8 +1,7 @@
import { ContentType } from '@standardnotes/common'
import { ContentReferenceType } from './ContenteReferenceType' import { ContentReferenceType } from './ContenteReferenceType'
export interface AnonymousReference { export interface AnonymousReference {
uuid: string uuid: string
content_type: ContentType content_type: string
reference_type: ContentReferenceType reference_type: ContentReferenceType
} }

View File

@@ -1,8 +1,7 @@
import { ContentType } from '@standardnotes/common'
import { AnonymousReference } from './AnonymousReference' import { AnonymousReference } from './AnonymousReference'
import { ContentReferenceType } from './ContenteReferenceType' import { ContentReferenceType } from './ContenteReferenceType'
export interface FileToFileReference extends AnonymousReference { export interface FileToFileReference extends AnonymousReference {
content_type: ContentType.File content_type: string
reference_type: ContentReferenceType.FileToFile reference_type: ContentReferenceType.FileToFile
} }

View File

@@ -1,8 +1,7 @@
import { ContentType } from '@standardnotes/common'
import { AnonymousReference } from './AnonymousReference' import { AnonymousReference } from './AnonymousReference'
import { ContentReferenceType } from './ContenteReferenceType' import { ContentReferenceType } from './ContenteReferenceType'
export interface FileToNoteReference extends AnonymousReference { export interface FileToNoteReference extends AnonymousReference {
content_type: ContentType.Note content_type: string
reference_type: ContentReferenceType.FileToNote reference_type: ContentReferenceType.FileToNote
} }

View File

@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */ import { ContentType } from '@standardnotes/domain-core'
import { ContentType } from '@standardnotes/common'
import { ItemInterface } from '../Item/Interfaces/ItemInterface' import { ItemInterface } from '../Item/Interfaces/ItemInterface'
import { ContentReferenceType } from './ContenteReferenceType' import { ContentReferenceType } from './ContenteReferenceType'
import { ContentReference } from './ContentReference' import { ContentReference } from './ContentReference'
@@ -20,8 +20,8 @@ export const isLegacyTagToNoteReference = (
x: LegacyAnonymousReference, x: LegacyAnonymousReference,
currentItem: ItemInterface, currentItem: ItemInterface,
): x is LegacyTagToNoteReference => { ): x is LegacyTagToNoteReference => {
const isReferenceToANote = x.content_type === ContentType.Note const isReferenceToANote = x.content_type === ContentType.TYPES.Note
const isReferenceFromATag = currentItem.content_type === ContentType.Tag const isReferenceFromATag = currentItem.content_type === ContentType.TYPES.Tag
return isReferenceToANote && isReferenceFromATag return isReferenceToANote && isReferenceFromATag
} }

View File

@@ -1,6 +1,5 @@
import { ContentType } from '@standardnotes/common'
import { LegacyAnonymousReference } from './LegacyAnonymousReference' import { LegacyAnonymousReference } from './LegacyAnonymousReference'
export interface LegacyTagToNoteReference extends LegacyAnonymousReference { export interface LegacyTagToNoteReference extends LegacyAnonymousReference {
content_type: ContentType.Note content_type: string
} }

View File

@@ -1,8 +1,7 @@
import { ContentType } from '@standardnotes/common'
import { AnonymousReference } from './AnonymousReference' import { AnonymousReference } from './AnonymousReference'
import { ContentReferenceType } from './ContenteReferenceType' import { ContentReferenceType } from './ContenteReferenceType'
export interface NoteToNoteReference extends AnonymousReference { export interface NoteToNoteReference extends AnonymousReference {
content_type: ContentType.Note content_type: string
reference_type: ContentReferenceType.NoteToNote reference_type: ContentReferenceType.NoteToNote
} }

View File

@@ -1,8 +1,7 @@
import { ContentType } from '@standardnotes/common'
import { AnonymousReference } from './AnonymousReference' import { AnonymousReference } from './AnonymousReference'
import { ContentReferenceType } from './ContenteReferenceType' import { ContentReferenceType } from './ContenteReferenceType'
export interface TagToFileReference extends AnonymousReference { export interface TagToFileReference extends AnonymousReference {
content_type: ContentType.File content_type: string
reference_type: ContentReferenceType.TagToFile reference_type: ContentReferenceType.TagToFile
} }

View File

@@ -1,8 +1,7 @@
import { ContentType } from '@standardnotes/common'
import { AnonymousReference } from './AnonymousReference' import { AnonymousReference } from './AnonymousReference'
import { ContentReferenceType } from './ContenteReferenceType' import { ContentReferenceType } from './ContenteReferenceType'
export interface TagToParentTagReference extends AnonymousReference { export interface TagToParentTagReference extends AnonymousReference {
content_type: ContentType.Tag content_type: string
reference_type: ContentReferenceType.TagToParentTag reference_type: ContentReferenceType.TagToParentTag
} }

View File

@@ -1,10 +1,9 @@
import { ContentType } from '@standardnotes/common'
import { ItemContent } from '../../Content/ItemContent' import { ItemContent } from '../../Content/ItemContent'
import { PersistentSignatureData } from '../../../Runtime/Encryption/PersistentSignatureData' import { PersistentSignatureData } from '../../../Runtime/Encryption/PersistentSignatureData'
export interface TransferPayload<C extends ItemContent = ItemContent> { export interface TransferPayload<C extends ItemContent = ItemContent> {
uuid: string uuid: string
content_type: ContentType content_type: string
content: C | string | undefined content: C | string | undefined
deleted?: boolean deleted?: boolean

View File

@@ -1,4 +1,4 @@
import { ContentType } from '@standardnotes/common' import { ContentType } from '@standardnotes/domain-core'
import { PayloadTimestampDefaults } from '../../Payload' import { PayloadTimestampDefaults } from '../../Payload'
import { isCorruptTransferPayload } from './TypeCheck' import { isCorruptTransferPayload } from './TypeCheck'
@@ -8,7 +8,7 @@ describe('type check', () => {
expect( expect(
isCorruptTransferPayload({ isCorruptTransferPayload({
uuid: '123', uuid: '123',
content_type: ContentType.Note, content_type: ContentType.TYPES.Note,
content: '123', content: '123',
...PayloadTimestampDefaults(), ...PayloadTimestampDefaults(),
}), }),
@@ -19,7 +19,7 @@ describe('type check', () => {
expect( expect(
isCorruptTransferPayload({ isCorruptTransferPayload({
uuid: undefined as never, uuid: undefined as never,
content_type: ContentType.Note, content_type: ContentType.TYPES.Note,
content: '123', content: '123',
...PayloadTimestampDefaults(), ...PayloadTimestampDefaults(),
}), }),
@@ -30,7 +30,7 @@ describe('type check', () => {
expect( expect(
isCorruptTransferPayload({ isCorruptTransferPayload({
uuid: '123', uuid: '123',
content_type: ContentType.Note, content_type: ContentType.TYPES.Note,
content: '123', content: '123',
deleted: true, deleted: true,
...PayloadTimestampDefaults(), ...PayloadTimestampDefaults(),
@@ -42,7 +42,7 @@ describe('type check', () => {
expect( expect(
isCorruptTransferPayload({ isCorruptTransferPayload({
uuid: '123', uuid: '123',
content_type: ContentType.Unknown, content_type: ContentType.TYPES.Unknown,
content: '123', content: '123',
...PayloadTimestampDefaults(), ...PayloadTimestampDefaults(),
}), }),

View File

@@ -1,4 +1,4 @@
import { ContentType } from '@standardnotes/common' import { ContentType } from '@standardnotes/domain-core'
import { isObject, isString } from '@standardnotes/utils' import { isObject, isString } from '@standardnotes/utils'
import { DecryptedTransferPayload } from './DecryptedTransferPayload' import { DecryptedTransferPayload } from './DecryptedTransferPayload'
import { DeletedTransferPayload } from './DeletedTransferPayload' import { DeletedTransferPayload } from './DeletedTransferPayload'
@@ -26,5 +26,5 @@ export function isDeletedTransferPayload(payload: TransferPayload): payload is D
export function isCorruptTransferPayload(payload: TransferPayload): boolean { export function isCorruptTransferPayload(payload: TransferPayload): boolean {
const invalidDeletedState = payload.deleted === true && payload.content != undefined 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
} }

View File

@@ -1,12 +1,11 @@
import { extendArray, isObject, isString, UuidMap } from '@standardnotes/utils' import { extendArray, isObject, isString, UuidMap } from '@standardnotes/utils'
import { ContentType } from '@standardnotes/common'
import { remove } from 'lodash' import { remove } from 'lodash'
import { ItemContent } from '../../Abstract/Content/ItemContent' import { ItemContent } from '../../Abstract/Content/ItemContent'
import { ContentReference } from '../../Abstract/Item' import { ContentReference } from '../../Abstract/Item'
export interface CollectionElement { export interface CollectionElement {
uuid: string uuid: string
content_type: ContentType content_type: string
dirty?: boolean dirty?: boolean
deleted?: boolean deleted?: boolean
} }
@@ -33,7 +32,7 @@ export abstract class Collection<
Deleted extends DeletedCollectionElement, Deleted extends DeletedCollectionElement,
> { > {
readonly map: Partial<Record<string, Element>> = {} 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 */ /** An array of uuids of items that are dirty */
dirtyIndex: Set<string> = new Set() dirtyIndex: Set<string> = new Set()
@@ -74,7 +73,7 @@ export abstract class Collection<
constructor( constructor(
copy = false, copy = false,
mapCopy?: Partial<Record<string, Element>>, mapCopy?: Partial<Record<string, Element>>,
typedMapCopy?: Partial<Record<ContentType, Element[]>>, typedMapCopy?: Partial<Record<string, Element[]>>,
referenceMapCopy?: UuidMap, referenceMapCopy?: UuidMap,
conflictMapCopy?: UuidMap, conflictMapCopy?: UuidMap,
) { ) {
@@ -93,7 +92,7 @@ export abstract class Collection<
return Object.keys(this.map) return Object.keys(this.map)
} }
public all(contentType?: ContentType | ContentType[]): Element[] { public all(contentType?: string | string[]): Element[] {
if (contentType) { if (contentType) {
if (Array.isArray(contentType)) { if (Array.isArray(contentType)) {
const elements: Element[] = [] const elements: Element[] = []
@@ -254,7 +253,7 @@ export abstract class Collection<
return this.findAll(uuids) 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 uuids = this.uuidsThatReferenceUuid(element.uuid)
const items = this.findAll(uuids) const items = this.findAll(uuids)

View File

@@ -1,8 +1,6 @@
import { ContentType } from '@standardnotes/common'
export interface SortableItem { export interface SortableItem {
uuid: string uuid: string
content_type: ContentType content_type: string
created_at: Date created_at: Date
userModifiedDate: Date userModifiedDate: Date
title?: string title?: string

View File

@@ -1,5 +1,5 @@
import { NoteContent } from './../../../Syncable/Note/NoteContent' import { NoteContent } from './../../../Syncable/Note/NoteContent'
import { ContentType } from '@standardnotes/common' import { ContentType } from '@standardnotes/domain-core'
import { DecryptedItem } from '../../../Abstract/Item' import { DecryptedItem } from '../../../Abstract/Item'
import { DecryptedPayload, PayloadTimestampDefaults } from '../../../Abstract/Payload' import { DecryptedPayload, PayloadTimestampDefaults } from '../../../Abstract/Payload'
import { ItemCollection } from './ItemCollection' import { ItemCollection } from './ItemCollection'
@@ -9,7 +9,7 @@ describe('item collection', () => {
const createDecryptedPayload = (uuid?: string, content?: Partial<NoteContent>): DecryptedPayload => { const createDecryptedPayload = (uuid?: string, content?: Partial<NoteContent>): DecryptedPayload => {
return new DecryptedPayload({ return new DecryptedPayload({
uuid: uuid || String(Math.random()), uuid: uuid || String(Math.random()),
content_type: ContentType.Note, content_type: ContentType.TYPES.Note,
content: FillItemContent<NoteContent>({ content: FillItemContent<NoteContent>({
title: 'foo', title: 'foo',
...content, ...content,

View File

@@ -1,6 +1,5 @@
import { ItemContent } from './../../../Abstract/Content/ItemContent' import { ItemContent } from './../../../Abstract/Content/ItemContent'
import { EncryptedItemInterface } from './../../../Abstract/Item/Interfaces/EncryptedItem' import { EncryptedItemInterface } from './../../../Abstract/Item/Interfaces/EncryptedItem'
import { ContentType } from '@standardnotes/common'
import { SNIndex } from '../../Index/SNIndex' import { SNIndex } from '../../Index/SNIndex'
import { isDecryptedItem } from '../../../Abstract/Item/Interfaces/TypeCheck' import { isDecryptedItem } from '../../../Abstract/Item/Interfaces/TypeCheck'
import { DecryptedItemInterface } from '../../../Abstract/Item/Interfaces/DecryptedItem' import { DecryptedItemInterface } from '../../../Abstract/Item/Interfaces/DecryptedItem'
@@ -53,7 +52,7 @@ export class ItemCollection
return mapped as (DecryptedItemInterface<C> | undefined)[] 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[] return this.all(contentType).filter(isDecryptedItem) as T[]
} }
} }

View File

@@ -1,6 +1,6 @@
import { ItemCounter } from './ItemCounter' import { ItemCounter } from './ItemCounter'
import { NoteContent } from '../../../Syncable/Note/NoteContent' import { NoteContent } from '../../../Syncable/Note/NoteContent'
import { ContentType } from '@standardnotes/common' import { ContentType } from '@standardnotes/domain-core'
import { DecryptedItem, EncryptedItem } from '../../../Abstract/Item' import { DecryptedItem, EncryptedItem } from '../../../Abstract/Item'
import { DecryptedPayload, EncryptedPayload, PayloadTimestampDefaults } from '../../../Abstract/Payload' import { DecryptedPayload, EncryptedPayload, PayloadTimestampDefaults } from '../../../Abstract/Payload'
import { ItemCollection } from './ItemCollection' import { ItemCollection } from './ItemCollection'
@@ -12,7 +12,7 @@ describe('tag notes index', () => {
const createEncryptedItem = (uuid?: string) => { const createEncryptedItem = (uuid?: string) => {
const payload = new EncryptedPayload({ const payload = new EncryptedPayload({
uuid: uuid || String(Math.random()), uuid: uuid || String(Math.random()),
content_type: ContentType.Note, content_type: ContentType.TYPES.Note,
content: '004:...', content: '004:...',
enc_item_key: '004:...', enc_item_key: '004:...',
items_key_id: '123', items_key_id: '123',
@@ -24,7 +24,7 @@ describe('tag notes index', () => {
return new EncryptedItem(payload) 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({ const payload = new DecryptedPayload({
uuid: uuid || String(Math.random()), uuid: uuid || String(Math.random()),
content_type, content_type,

View File

@@ -1,5 +1,4 @@
import { removeFromArray } from '@standardnotes/utils' import { removeFromArray } from '@standardnotes/utils'
import { ContentType } from '@standardnotes/common'
import { isTag, SNTag } from '../../../Syncable/Tag/Tag' import { isTag, SNTag } from '../../../Syncable/Tag/Tag'
import { SNIndex } from '../../Index/SNIndex' import { SNIndex } from '../../Index/SNIndex'
import { ItemCollection } from './ItemCollection' import { ItemCollection } from './ItemCollection'
@@ -13,6 +12,7 @@ import { HiddenContentCriteriaValidator } from '../../Display/Validator/HiddenCo
import { CustomFilterCriteriaValidator } from '../../Display/Validator/CustomFilterCriteriaValidator' import { CustomFilterCriteriaValidator } from '../../Display/Validator/CustomFilterCriteriaValidator'
import { AnyDisplayOptions, VaultDisplayOptions } from '../../Display' import { AnyDisplayOptions, VaultDisplayOptions } from '../../Display'
import { isExclusioanaryOptionsValue } from '../../Display/VaultDisplayOptionsTypes' import { isExclusioanaryOptionsValue } from '../../Display/VaultDisplayOptionsTypes'
import { ContentType } from '@standardnotes/domain-core'
type AllNotesUuidSignifier = undefined type AllNotesUuidSignifier = undefined
export type TagItemCountChangeObserver = (tagUuid: string | AllNotesUuidSignifier) => void export type TagItemCountChangeObserver = (tagUuid: string | AllNotesUuidSignifier) => void
@@ -20,7 +20,7 @@ export type TagItemCountChangeObserver = (tagUuid: string | AllNotesUuidSignifie
export class ItemCounter implements SNIndex { export class ItemCounter implements SNIndex {
private tagToItemsMap: Partial<Record<string, Set<string>>> = {} private tagToItemsMap: Partial<Record<string, Set<string>>> = {}
private allCountableItems = new 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 displayOptions?: AnyDisplayOptions
private vaultDisplayOptions?: VaultDisplayOptions private vaultDisplayOptions?: VaultDisplayOptions
@@ -50,11 +50,11 @@ export class ItemCounter implements SNIndex {
} }
public allCountableNotesCount(): number { public allCountableNotesCount(): number {
return this.countableItemsByType.get(ContentType.Note)?.size || 0 return this.countableItemsByType.get(ContentType.TYPES.Note)?.size || 0
} }
public allCountableFilesCount(): number { 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 { public countableItemsForTag(tag: SNTag): number {
@@ -63,7 +63,7 @@ export class ItemCounter implements SNIndex {
public onChange(delta: ItemDelta): void { public onChange(delta: ItemDelta): void {
const items = [...delta.changed, ...delta.inserted, ...delta.discarded].filter( 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) const tags = [...delta.changed, ...delta.inserted].filter(isDecryptedItem).filter(isTag)
@@ -115,7 +115,7 @@ export class ItemCounter implements SNIndex {
private receiveTagChanges(tags: SNTag[]): void { private receiveTagChanges(tags: SNTag[]): void {
for (const tag of tags) { for (const tag of tags) {
const uuids = tag.references 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) .map((ref) => ref.uuid)
const countableUuids = uuids.filter((uuid) => this.allCountableItems.has(uuid)) const countableUuids = uuids.filter((uuid) => this.allCountableItems.has(uuid))
const previousSet = this.tagToItemsMap[tag.uuid] const previousSet = this.tagToItemsMap[tag.uuid]

View File

@@ -1,5 +1,4 @@
import { FullyFormedPayloadInterface } from './../../../Abstract/Payload/Interfaces/UnionTypes' import { FullyFormedPayloadInterface } from './../../../Abstract/Payload/Interfaces/UnionTypes'
import { ContentType } from '@standardnotes/common'
import { UuidMap } from '@standardnotes/utils' import { UuidMap } from '@standardnotes/utils'
import { PayloadCollection } from './PayloadCollection' import { PayloadCollection } from './PayloadCollection'
@@ -33,7 +32,7 @@ export class ImmutablePayloadCollection<
const result = new ImmutablePayloadCollection<T>( const result = new ImmutablePayloadCollection<T>(
true, true,
mapCopy, mapCopy,
typedMapCopy as Partial<Record<ContentType, T[]>>, typedMapCopy as Partial<Record<string, T[]>>,
referenceMapCopy, referenceMapCopy,
conflictMapCopy, conflictMapCopy,
) )

View File

@@ -1,4 +1,4 @@
import { ContentType } from '@standardnotes/common' import { ContentType } from '@standardnotes/domain-core'
import { FillItemContent } from '../../Abstract/Content/ItemContent' import { FillItemContent } from '../../Abstract/Content/ItemContent'
import { ConflictStrategy } from '../../Abstract/Item' import { ConflictStrategy } from '../../Abstract/Item'
import { import {
@@ -25,7 +25,7 @@ describe('conflict delta', () => {
const createDecryptedItemsKey = (uuid: string, key: string, timestamp = 0) => { const createDecryptedItemsKey = (uuid: string, key: string, timestamp = 0) => {
return new DecryptedPayload<ItemsKeyContent>({ return new DecryptedPayload<ItemsKeyContent>({
uuid: uuid, uuid: uuid,
content_type: ContentType.ItemsKey, content_type: ContentType.TYPES.ItemsKey,
content: FillItemContent<ItemsKeyContent>({ content: FillItemContent<ItemsKeyContent>({
itemsKey: key, itemsKey: key,
}), }),
@@ -37,7 +37,7 @@ describe('conflict delta', () => {
const createErroredItemsKey = (uuid: string, timestamp = 0) => { const createErroredItemsKey = (uuid: string, timestamp = 0) => {
return new EncryptedPayload({ return new EncryptedPayload({
uuid: uuid, uuid: uuid,
content_type: ContentType.ItemsKey, content_type: ContentType.TYPES.ItemsKey,
content: '004:...', content: '004:...',
enc_item_key: '004:...', enc_item_key: '004:...',
items_key_id: undefined, items_key_id: undefined,

View File

@@ -1,4 +1,5 @@
import { uniqCombineObjArrays } from '@standardnotes/utils' import { uniqCombineObjArrays } from '@standardnotes/utils'
import { ContentType } from '@standardnotes/domain-core'
import { ImmutablePayloadCollection } from '../Collection/Payload/ImmutablePayloadCollection' import { ImmutablePayloadCollection } from '../Collection/Payload/ImmutablePayloadCollection'
import { CreateDecryptedItemFromPayload, CreateItemFromPayload } from '../../Utilities/Item/ItemGenerator' import { CreateDecryptedItemFromPayload, CreateItemFromPayload } from '../../Utilities/Item/ItemGenerator'
import { HistoryMap, historyMapFunctions } from '../History/HistoryMap' import { HistoryMap, historyMapFunctions } from '../History/HistoryMap'
@@ -11,7 +12,6 @@ import {
isErrorDecryptingPayload, isErrorDecryptingPayload,
isDeletedPayload, isDeletedPayload,
} from '../../Abstract/Payload/Interfaces/TypeCheck' } from '../../Abstract/Payload/Interfaces/TypeCheck'
import { ContentType } from '@standardnotes/common'
import { SyncResolvedPayload } from './Utilities/SyncResolvedPayload' import { SyncResolvedPayload } from './Utilities/SyncResolvedPayload'
import { ItemsKeyDelta } from './ItemsKeyDelta' import { ItemsKeyDelta } from './ItemsKeyDelta'
import { SourcelessSyncDeltaEmit } from './Abstract/DeltaEmit' import { SourcelessSyncDeltaEmit } from './Abstract/DeltaEmit'
@@ -26,7 +26,7 @@ export class ConflictDelta {
) {} ) {}
public result(): SourcelessSyncDeltaEmit { 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]) const keyDelta = new ItemsKeyDelta(this.baseCollection, [this.applyPayload])
return keyDelta.result() return keyDelta.result()

View File

@@ -1,4 +1,4 @@
import { ContentType } from '@standardnotes/common' import { ContentType } from '@standardnotes/domain-core'
import { FillItemContent } from '../../Abstract/Content/ItemContent' import { FillItemContent } from '../../Abstract/Content/ItemContent'
import { import {
DecryptedPayload, DecryptedPayload,
@@ -16,7 +16,7 @@ describe('items key delta', () => {
const baseCollection = new PayloadCollection() const baseCollection = new PayloadCollection()
const basePayload = new DecryptedPayload<ItemsKeyContent>({ const basePayload = new DecryptedPayload<ItemsKeyContent>({
uuid: '123', uuid: '123',
content_type: ContentType.ItemsKey, content_type: ContentType.TYPES.ItemsKey,
content: FillItemContent<ItemsKeyContent>({ content: FillItemContent<ItemsKeyContent>({
itemsKey: 'secret', itemsKey: 'secret',
}), }),
@@ -28,7 +28,7 @@ describe('items key delta', () => {
const payloadToIgnore = new EncryptedPayload({ const payloadToIgnore = new EncryptedPayload({
uuid: '123', uuid: '123',
content_type: ContentType.ItemsKey, content_type: ContentType.TYPES.ItemsKey,
content: '004:...', content: '004:...',
enc_item_key: '004:...', enc_item_key: '004:...',
items_key_id: undefined, items_key_id: undefined,

View File

@@ -2,7 +2,7 @@ import { PayloadEmitSource } from '../../Abstract/Payload'
import { isDecryptedPayload } from '../../Abstract/Payload/Interfaces/TypeCheck' import { isDecryptedPayload } from '../../Abstract/Payload/Interfaces/TypeCheck'
import { PayloadContentsEqual } from '../../Utilities/Payload/PayloadContentsEqual' import { PayloadContentsEqual } from '../../Utilities/Payload/PayloadContentsEqual'
import { ConflictDelta } from './Conflict' import { ConflictDelta } from './Conflict'
import { ContentType } from '@standardnotes/common' import { ContentType } from '@standardnotes/domain-core'
import { ItemsKeyDelta } from './ItemsKeyDelta' import { ItemsKeyDelta } from './ItemsKeyDelta'
import { payloadByFinalizingSyncState } from './Utilities/ApplyDirtyState' import { payloadByFinalizingSyncState } from './Utilities/ApplyDirtyState'
import { ImmutablePayloadCollection } from '../Collection/Payload/ImmutablePayloadCollection' import { ImmutablePayloadCollection } from '../Collection/Payload/ImmutablePayloadCollection'
@@ -25,7 +25,7 @@ export class DeltaOutOfSync implements SyncDeltaInterface {
} }
for (const apply of this.applyCollection.all()) { 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() const itemsKeyDeltaEmit = new ItemsKeyDelta(this.baseCollection, [apply]).result()
extendSyncDelta(result, itemsKeyDeltaEmit) extendSyncDelta(result, itemsKeyDeltaEmit)

View File

@@ -1,4 +1,4 @@
import { ContentType } from '@standardnotes/common' import { ContentType } from '@standardnotes/domain-core'
import { FillItemContent } from '../../Abstract/Content/ItemContent' import { FillItemContent } from '../../Abstract/Content/ItemContent'
import { DecryptedPayload, FullyFormedPayloadInterface, PayloadTimestampDefaults } from '../../Abstract/Payload' import { DecryptedPayload, FullyFormedPayloadInterface, PayloadTimestampDefaults } from '../../Abstract/Payload'
import { NoteContent } from '../../Syncable/Note' import { NoteContent } from '../../Syncable/Note'
@@ -15,7 +15,7 @@ describe('remote rejected delta', () => {
const baseCollection = new PayloadCollection() const baseCollection = new PayloadCollection()
const basePayload = new DecryptedPayload<NoteContent>({ const basePayload = new DecryptedPayload<NoteContent>({
uuid: '123', uuid: '123',
content_type: ContentType.Note, content_type: ContentType.TYPES.Note,
dirty: true, dirty: true,
content: FillItemContent<NoteContent>({ content: FillItemContent<NoteContent>({
title: 'foo', title: 'foo',

View File

@@ -15,7 +15,7 @@ import {
ConflictType, ConflictType,
} from '@standardnotes/responses' } from '@standardnotes/responses'
import { PayloadsByDuplicating } from '../../Utilities/Payload/PayloadsByDuplicating' import { PayloadsByDuplicating } from '../../Utilities/Payload/PayloadsByDuplicating'
import { ContentType } from '@standardnotes/common' import { ContentType } from '@standardnotes/domain-core'
export class DeltaRemoteRejected implements SyncDeltaInterface { export class DeltaRemoteRejected implements SyncDeltaInterface {
constructor( constructor(
@@ -61,7 +61,7 @@ export class DeltaRemoteRejected implements SyncDeltaInterface {
return this.resultByDuplicatingBasePayloadAsNonVaultedAndRemovingBaseItemLocally(base) return this.resultByDuplicatingBasePayloadAsNonVaultedAndRemovingBaseItemLocally(base)
} }
if (base.content_type === ContentType.KeySystemItemsKey) { if (base.content_type === ContentType.TYPES.KeySystemItemsKey) {
return this.discardChangesOfBasePayload(base) return this.discardChangesOfBasePayload(base)
} }

View File

@@ -1,4 +1,4 @@
import { ContentType } from '@standardnotes/common' import { ContentType } from '@standardnotes/domain-core'
import { FillItemContent } from '../../Abstract/Content/ItemContent' import { FillItemContent } from '../../Abstract/Content/ItemContent'
import { import {
DecryptedPayload, DecryptedPayload,
@@ -16,7 +16,7 @@ describe('remote retrieved delta', () => {
const baseCollection = new PayloadCollection() const baseCollection = new PayloadCollection()
const basePayload = new DecryptedPayload<ItemsKeyContent>({ const basePayload = new DecryptedPayload<ItemsKeyContent>({
uuid: '123', uuid: '123',
content_type: ContentType.ItemsKey, content_type: ContentType.TYPES.ItemsKey,
content: FillItemContent<ItemsKeyContent>({ content: FillItemContent<ItemsKeyContent>({
itemsKey: 'secret', itemsKey: 'secret',
}), }),
@@ -28,7 +28,7 @@ describe('remote retrieved delta', () => {
const payloadToIgnore = new EncryptedPayload({ const payloadToIgnore = new EncryptedPayload({
uuid: '123', uuid: '123',
content_type: ContentType.ItemsKey, content_type: ContentType.TYPES.ItemsKey,
content: '004:...', content: '004:...',
enc_item_key: '004:...', enc_item_key: '004:...',
items_key_id: undefined, items_key_id: undefined,

View File

@@ -2,7 +2,7 @@ import { ImmutablePayloadCollection } from './../Collection/Payload/ImmutablePay
import { ConflictDelta } from './Conflict' import { ConflictDelta } from './Conflict'
import { isErrorDecryptingPayload, isDecryptedPayload } from '../../Abstract/Payload/Interfaces/TypeCheck' import { isErrorDecryptingPayload, isDecryptedPayload } from '../../Abstract/Payload/Interfaces/TypeCheck'
import { FullyFormedPayloadInterface, PayloadEmitSource } from '../../Abstract/Payload' import { FullyFormedPayloadInterface, PayloadEmitSource } from '../../Abstract/Payload'
import { ContentType } from '@standardnotes/common' import { ContentType } from '@standardnotes/domain-core'
import { HistoryMap } from '../History' import { HistoryMap } from '../History'
import { ServerSyncPushContextualPayload } from '../../Abstract/Contextual/ServerSyncPush' import { ServerSyncPushContextualPayload } from '../../Abstract/Contextual/ServerSyncPush'
import { payloadByFinalizingSyncState } from './Utilities/ApplyDirtyState' 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. * 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()) { 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() const itemsKeyDeltaEmit = new ItemsKeyDelta(this.baseCollection, [apply]).result()
extendSyncDelta(result, itemsKeyDeltaEmit) extendSyncDelta(result, itemsKeyDeltaEmit)

View File

@@ -1,4 +1,3 @@
import { ContentType } from '@standardnotes/common'
import { SmartView } from '../../Syncable/SmartView' import { SmartView } from '../../Syncable/SmartView'
import { SNTag } from '../../Syncable/Tag' import { SNTag } from '../../Syncable/Tag'
import { CollectionSortDirection, CollectionSortProperty } from '../Collection/CollectionSort' import { CollectionSortDirection, CollectionSortProperty } from '../Collection/CollectionSort'
@@ -16,7 +15,7 @@ export interface NotesAndFilesDisplayOptions extends GenericDisplayOptions {
tags?: SNTag[] tags?: SNTag[]
views?: SmartView[] views?: SmartView[]
searchQuery?: SearchQuery searchQuery?: SearchQuery
hiddenContentTypes?: ContentType[] hiddenContentTypes?: string[]
customFilter?: DisplayControllerCustomFilter customFilter?: DisplayControllerCustomFilter
} }

View File

@@ -1,4 +1,3 @@
import { ContentType } from '@standardnotes/common'
import { DecryptedItem } from '../../Abstract/Item' import { DecryptedItem } from '../../Abstract/Item'
import { SNTag } from '../../Syncable/Tag' import { SNTag } from '../../Syncable/Tag'
import { CompoundPredicate } from '../Predicate/CompoundPredicate' import { CompoundPredicate } from '../Predicate/CompoundPredicate'
@@ -7,6 +6,7 @@ import { itemMatchesQuery, itemPassesFilters } from './Search/SearchUtilities'
import { ItemFilter, ReferenceLookupCollection, SearchableDecryptedItem } from './Search/Types' import { ItemFilter, ReferenceLookupCollection, SearchableDecryptedItem } from './Search/Types'
import { NotesAndFilesDisplayOptions } from './DisplayOptions' import { NotesAndFilesDisplayOptions } from './DisplayOptions'
import { SystemViewId } from '../../Syncable/SmartView' import { SystemViewId } from '../../Syncable/SmartView'
import { ContentType } from '@standardnotes/domain-core'
export function computeUnifiedFilterForDisplayOptions( export function computeUnifiedFilterForDisplayOptions(
options: NotesAndFilesDisplayOptions, options: NotesAndFilesDisplayOptions,
@@ -40,7 +40,7 @@ export function computeFiltersForDisplayOptions(
const noteWithTags = ItemWithTags.Create( const noteWithTags = ItemWithTags.Create(
item.payload, item.payload,
item, item,
collection.elementsReferencingElement(item, ContentType.Tag) as SNTag[], collection.elementsReferencingElement(item, ContentType.TYPES.Tag) as SNTag[],
) )
return compoundPredicate.matchesItem(noteWithTags) return compoundPredicate.matchesItem(noteWithTags)
} else { } else {

View File

@@ -1,7 +1,7 @@
import { CreateItemDelta } from './../Index/ItemDelta' import { CreateItemDelta } from './../Index/ItemDelta'
import { DeletedPayload } from './../../Abstract/Payload/Implementations/DeletedPayload' import { DeletedPayload } from './../../Abstract/Payload/Implementations/DeletedPayload'
import { createFile, createNote, createTagWithTitle, mockUuid, pinnedContent } from './../../Utilities/Test/SpecUtils' 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 { DeletedItem, EncryptedItem } from '../../Abstract/Item'
import { EncryptedPayload, PayloadTimestampDefaults } from '../../Abstract/Payload' import { EncryptedPayload, PayloadTimestampDefaults } from '../../Abstract/Payload'
import { createNoteWithContent } from '../../Utilities/Test/SpecUtils' import { createNoteWithContent } from '../../Utilities/Test/SpecUtils'
@@ -16,7 +16,7 @@ describe('item display controller', () => {
const noteB = createNoteWithContent({ title: 'b' }) const noteB = createNoteWithContent({ title: 'b' })
collection.set([noteA, noteB]) collection.set([noteA, noteB])
const controller = new ItemDisplayController(collection, [ContentType.Note], { const controller = new ItemDisplayController(collection, [ContentType.TYPES.Note], {
sortBy: 'title', sortBy: 'title',
sortDirection: 'asc', sortDirection: 'asc',
}) })
@@ -36,7 +36,7 @@ describe('item display controller', () => {
const noteB = createNoteWithContent({ title: 'b' }) const noteB = createNoteWithContent({ title: 'b' })
collection.set([noteA, noteB]) collection.set([noteA, noteB])
const controller = new ItemDisplayController(collection, [ContentType.Note], { const controller = new ItemDisplayController(collection, [ContentType.TYPES.Note], {
sortBy: 'title', sortBy: 'title',
sortDirection: 'asc', sortDirection: 'asc',
}) })
@@ -56,7 +56,7 @@ describe('item display controller', () => {
const noteA = createNoteWithContent({ title: 'a' }) const noteA = createNoteWithContent({ title: 'a' })
collection.set([noteA]) collection.set([noteA])
const controller = new ItemDisplayController(collection, [ContentType.Note], { const controller = new ItemDisplayController(collection, [ContentType.TYPES.Note], {
sortBy: 'title', sortBy: 'title',
sortDirection: 'asc', sortDirection: 'asc',
}) })
@@ -76,7 +76,7 @@ describe('item display controller', () => {
const noteA = new EncryptedItem( const noteA = new EncryptedItem(
new EncryptedPayload({ new EncryptedPayload({
uuid: mockUuid(), uuid: mockUuid(),
content_type: ContentType.Note, content_type: ContentType.TYPES.Note,
content: '004:...', content: '004:...',
enc_item_key: '004:...', enc_item_key: '004:...',
items_key_id: mockUuid(), items_key_id: mockUuid(),
@@ -87,7 +87,7 @@ describe('item display controller', () => {
) )
collection.set([noteA]) collection.set([noteA])
const controller = new ItemDisplayController(collection, [ContentType.Note], { const controller = new ItemDisplayController(collection, [ContentType.TYPES.Note], {
sortBy: 'title', sortBy: 'title',
sortDirection: 'asc', sortDirection: 'asc',
}) })
@@ -101,7 +101,7 @@ describe('item display controller', () => {
const noteB = createNoteWithContent({ title: 'b' }) const noteB = createNoteWithContent({ title: 'b' })
collection.set([noteA, noteB]) collection.set([noteA, noteB])
const controller = new ItemDisplayController(collection, [ContentType.Note], { const controller = new ItemDisplayController(collection, [ContentType.TYPES.Note], {
sortBy: 'title', sortBy: 'title',
sortDirection: 'asc', sortDirection: 'asc',
}) })
@@ -134,7 +134,7 @@ describe('item display controller', () => {
const noteA = createNoteWithContent({ title: 'a' }) const noteA = createNoteWithContent({ title: 'a' })
collection.set([noteA]) collection.set([noteA])
const controller = new ItemDisplayController(collection, [ContentType.Note], { const controller = new ItemDisplayController(collection, [ContentType.TYPES.Note], {
sortBy: 'title', sortBy: 'title',
sortDirection: 'asc', sortDirection: 'asc',
}) })
@@ -159,7 +159,7 @@ describe('item display controller', () => {
const noteA = createNoteWithContent({ title: 'a' }) const noteA = createNoteWithContent({ title: 'a' })
collection.set([noteA]) collection.set([noteA])
const controller = new ItemDisplayController(collection, [ContentType.Note], { const controller = new ItemDisplayController(collection, [ContentType.TYPES.Note], {
sortBy: 'title', sortBy: 'title',
sortDirection: 'asc', sortDirection: 'asc',
}) })
@@ -177,7 +177,7 @@ describe('item display controller', () => {
const tag = createTagWithTitle() const tag = createTagWithTitle()
collection.set([note, tag]) collection.set([note, tag])
const controller = new ItemDisplayController(collection, [ContentType.Note], { const controller = new ItemDisplayController(collection, [ContentType.TYPES.Note], {
sortBy: 'title', sortBy: 'title',
sortDirection: 'asc', sortDirection: 'asc',
}) })
@@ -190,7 +190,7 @@ describe('item display controller', () => {
const tag = createTagWithTitle() const tag = createTagWithTitle()
collection.set([note, tag]) collection.set([note, tag])
const controller = new ItemDisplayController(collection, [ContentType.Note], { const controller = new ItemDisplayController(collection, [ContentType.TYPES.Note], {
sortBy: 'title', sortBy: 'title',
sortDirection: 'asc', sortDirection: 'asc',
}) })
@@ -203,7 +203,7 @@ describe('item display controller', () => {
const note = createNoteWithContent({ title: 'a' }) const note = createNoteWithContent({ title: 'a' })
collection.set([note]) collection.set([note])
const controller = new ItemDisplayController(collection, [ContentType.Note], { const controller = new ItemDisplayController(collection, [ContentType.TYPES.Note], {
sortBy: 'title', sortBy: 'title',
sortDirection: 'asc', sortDirection: 'asc',
}) })
@@ -222,7 +222,7 @@ describe('item display controller', () => {
const file = createFile('A') const file = createFile('A')
collection.set([note, file]) 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', sortBy: 'title',
sortDirection: 'asc', sortDirection: 'asc',
}) })
@@ -242,14 +242,14 @@ describe('item display controller', () => {
const file = createFile() const file = createFile()
collection.set([note, file]) 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', sortBy: 'title',
sortDirection: 'asc', sortDirection: 'asc',
}) })
expect(controller.items()).toHaveLength(2) expect(controller.items()).toHaveLength(2)
controller.setDisplayOptions({ hiddenContentTypes: [ContentType.File] }) controller.setDisplayOptions({ hiddenContentTypes: [ContentType.TYPES.File] })
expect(controller.items()).toHaveLength(1) expect(controller.items()).toHaveLength(1)
}) })

View File

@@ -1,4 +1,3 @@
import { ContentType } from '@standardnotes/common'
import { compareValues } from '@standardnotes/utils' import { compareValues } from '@standardnotes/utils'
import { isDeletedItem, isEncryptedItem } from '../../Abstract/Item' import { isDeletedItem, isEncryptedItem } from '../../Abstract/Item'
import { ItemDelta } from '../Index/ItemDelta' import { ItemDelta } from '../Index/ItemDelta'
@@ -21,7 +20,7 @@ export class ItemDisplayController<I extends DisplayItem, O extends AnyDisplayOp
constructor( constructor(
private readonly collection: ReadonlyItemCollection, private readonly collection: ReadonlyItemCollection,
public readonly contentTypes: ContentType[], public readonly contentTypes: string[],
private options: DisplayControllerDisplayOptions & O, private options: DisplayControllerDisplayOptions & O,
private vaultOptions?: VaultDisplayOptions, private vaultOptions?: VaultDisplayOptions,
) { ) {

View File

@@ -1,4 +1,4 @@
import { ContentType } from '@standardnotes/common' import { ContentType } from '@standardnotes/domain-core'
import { SNTag } from '../../../Syncable/Tag' import { SNTag } from '../../../Syncable/Tag'
import { NotesAndFilesDisplayOptions } from '../DisplayOptions' import { NotesAndFilesDisplayOptions } from '../DisplayOptions'
import { computeFiltersForDisplayOptions } from '../DisplayOptionsToFilters' import { computeFiltersForDisplayOptions } from '../DisplayOptionsToFilters'
@@ -38,7 +38,7 @@ export function itemMatchesQuery(
searchQuery: SearchQuery, searchQuery: SearchQuery,
collection: ReferenceLookupCollection, collection: ReferenceLookupCollection,
): boolean { ): 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) const someTagsMatches = itemTags.some((tag) => matchResultForStringQuery(tag, searchQuery.query) !== MatchResult.None)
if (itemToMatch.protected && !searchQuery.includeProtectedNoteText) { if (itemToMatch.protected && !searchQuery.includeProtectedNoteText) {

View File

@@ -1,9 +1,8 @@
import { DecryptedItemInterface } from './../../../Abstract/Item/Interfaces/DecryptedItem' import { DecryptedItemInterface } from './../../../Abstract/Item/Interfaces/DecryptedItem'
import { ContentType } from '@standardnotes/common'
import { CriteriaValidatorInterface } from './CriteriaValidatorInterface' import { CriteriaValidatorInterface } from './CriteriaValidatorInterface'
export class HiddenContentCriteriaValidator implements CriteriaValidatorInterface { export class HiddenContentCriteriaValidator implements CriteriaValidatorInterface {
constructor(private hiddenContentTypes: ContentType[], private element: DecryptedItemInterface) {} constructor(private hiddenContentTypes: string[], private element: DecryptedItemInterface) {}
public passes(): boolean { public passes(): boolean {
return !this.hiddenContentTypes.includes(this.element.content_type) return !this.hiddenContentTypes.includes(this.element.content_type)

View File

@@ -1,5 +1,5 @@
import { ContentType } from '@standardnotes/common' import { ContentType } from '@standardnotes/domain-core'
export function ContentTypeUsesKeySystemRootKeyEncryption(contentType: ContentType): boolean { export function ContentTypeUsesKeySystemRootKeyEncryption(contentType: string): boolean {
return contentType === ContentType.KeySystemItemsKey return contentType === ContentType.TYPES.KeySystemItemsKey
} }

View File

@@ -1,6 +1,5 @@
import { ContentType } from '@standardnotes/common'
import { ContentTypesUsingRootKeyEncryption } from './ContentTypesUsingRootKeyEncryption' import { ContentTypesUsingRootKeyEncryption } from './ContentTypesUsingRootKeyEncryption'
export function ContentTypeUsesRootKeyEncryption(contentType: ContentType): boolean { export function ContentTypeUsesRootKeyEncryption(contentType: string): boolean {
return ContentTypesUsingRootKeyEncryption().includes(contentType) return ContentTypesUsingRootKeyEncryption().includes(contentType)
} }

View File

@@ -1,11 +1,11 @@
import { ContentType } from '@standardnotes/common' import { ContentType } from '@standardnotes/domain-core'
export function ContentTypesUsingRootKeyEncryption(): ContentType[] { export function ContentTypesUsingRootKeyEncryption(): string[] {
return [ return [
ContentType.RootKey, ContentType.TYPES.RootKey,
ContentType.ItemsKey, ContentType.TYPES.ItemsKey,
ContentType.EncryptedStorage, ContentType.TYPES.EncryptedStorage,
ContentType.TrustedContact, ContentType.TYPES.TrustedContact,
ContentType.KeySystemRootKey, ContentType.TYPES.KeySystemRootKey,
] ]
} }

View File

@@ -1,5 +1,6 @@
import { ContentType } from '@standardnotes/domain-core'
import { DecryptedPayloadInterface } from './../../Abstract/Payload/Interfaces/DecryptedPayload' import { DecryptedPayloadInterface } from './../../Abstract/Payload/Interfaces/DecryptedPayload'
import { ContentType } from '@standardnotes/common'
import { NoteContent } from '../../Syncable/Note' import { NoteContent } from '../../Syncable/Note'
import { HistoryEntry } from './HistoryEntry' import { HistoryEntry } from './HistoryEntry'
import { NoteHistoryEntry } from './NoteHistoryEntry' import { NoteHistoryEntry } from './NoteHistoryEntry'
@@ -14,9 +15,9 @@ export function CreateHistoryEntryForPayload(
return entry return entry
} }
function historyClassForContentType(contentType: ContentType) { function historyClassForContentType(contentType: string) {
switch (contentType) { switch (contentType) {
case ContentType.Note: case ContentType.TYPES.Note:
return NoteHistoryEntry return NoteHistoryEntry
default: default:
return HistoryEntry return HistoryEntry

View File

@@ -1,7 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
import { ItemInterface } from '../../Abstract/Item/Interfaces/ItemInterface' import { ItemInterface } from '../../Abstract/Item/Interfaces/ItemInterface'
import { ContentType } from '@standardnotes/common'
import { import {
compoundPredicateFromArguments, compoundPredicateFromArguments,
includesPredicateFromArguments, includesPredicateFromArguments,
@@ -13,9 +12,10 @@ import { IncludesPredicate } from './IncludesPredicate'
import { Predicate } from './Predicate' import { Predicate } from './Predicate'
import { CompoundPredicate } from './CompoundPredicate' import { CompoundPredicate } from './CompoundPredicate'
import { NotPredicate } from './NotPredicate' import { NotPredicate } from './NotPredicate'
import { ContentType } from '@standardnotes/domain-core'
interface Item extends ItemInterface { interface Item extends ItemInterface {
content_type: ContentType content_type: string
updated_at: Date updated_at: Date
} }
@@ -32,7 +32,7 @@ interface Tag extends Item {
function createNote(content: Record<string, unknown>, tags?: Tag[]): Note { function createNote(content: Record<string, unknown>, tags?: Tag[]): Note {
return { return {
...content, ...content,
content_type: ContentType.Note, content_type: ContentType.TYPES.Note,
tags, tags,
} as jest.Mocked<Note> } as jest.Mocked<Note>
} }
@@ -40,7 +40,7 @@ function createNote(content: Record<string, unknown>, tags?: Tag[]): Note {
function createTag(title: string): Tag { function createTag(title: string): Tag {
return { return {
title, title,
content_type: ContentType.Tag, content_type: ContentType.TYPES.Tag,
} as jest.Mocked<Tag> } as jest.Mocked<Tag>
} }
@@ -48,7 +48,7 @@ function createItem(content: Record<string, unknown>, updatedAt?: Date): Item {
return { return {
...content, ...content,
updated_at: updatedAt, updated_at: updatedAt,
content_type: ContentType.Any, content_type: ContentType.TYPES.Any,
} as jest.Mocked<Note> } as jest.Mocked<Note>
} }
@@ -100,7 +100,7 @@ describe('predicates', () => {
expect( expect(
compoundPredicateFromArguments<Note>('or', [ compoundPredicateFromArguments<Note>('or', [
{ keypath: 'title', operator: '=', value: 'Hello' }, { keypath: 'title', operator: '=', value: 'Hello' },
{ keypath: 'content_type', operator: '=', value: ContentType.Note }, { keypath: 'content_type', operator: '=', value: ContentType.TYPES.Note },
]).matchesItem(item), ]).matchesItem(item),
).toEqual(true) ).toEqual(true)
}) })
@@ -118,7 +118,7 @@ describe('predicates', () => {
expect( expect(
compoundPredicateFromArguments<Note>('or', [ compoundPredicateFromArguments<Note>('or', [
{ keypath: 'title', operator: '=', value: 'Wrong' }, { keypath: 'title', operator: '=', value: 'Wrong' },
{ keypath: 'content_type', operator: '=', value: ContentType.Note }, { keypath: 'content_type', operator: '=', value: ContentType.TYPES.Note },
]).matchesItem(item), ]).matchesItem(item),
).toEqual(true) ).toEqual(true)
}) })
@@ -158,7 +158,7 @@ describe('predicates', () => {
expect( expect(
compoundPredicateFromArguments<Note>('and', [ compoundPredicateFromArguments<Note>('and', [
{ keypath: 'title', operator: '=', value: title }, { keypath: 'title', operator: '=', value: title },
{ keypath: 'content_type', operator: '=', value: ContentType.Note }, { keypath: 'content_type', operator: '=', value: ContentType.TYPES.Note },
]).matchesItem(item), ]).matchesItem(item),
).toEqual(true) ).toEqual(true)
}) })
@@ -167,7 +167,7 @@ describe('predicates', () => {
expect( expect(
compoundPredicateFromArguments<Note>('and', [ compoundPredicateFromArguments<Note>('and', [
{ keypath: 'title', operator: '=', value: 'Wrong' }, { keypath: 'title', operator: '=', value: 'Wrong' },
{ keypath: 'content_type', operator: '=', value: ContentType.Note }, { keypath: 'content_type', operator: '=', value: ContentType.TYPES.Note },
]).matchesItem(item), ]).matchesItem(item),
).toEqual(false) ).toEqual(false)
}) })
@@ -184,7 +184,7 @@ describe('predicates', () => {
it('explicit compound syntax', () => { it('explicit compound syntax', () => {
const compoundProd = new CompoundPredicate('and', [ const compoundProd = new CompoundPredicate('and', [
new Predicate<Note>('title', '=', title), new Predicate<Note>('title', '=', title),
new Predicate('content_type', '=', ContentType.Note), new Predicate('content_type', '=', ContentType.TYPES.Note),
]) ])
expect(compoundProd.matchesItem(item)).toEqual(true) expect(compoundProd.matchesItem(item)).toEqual(true)
}) })

View File

@@ -1,6 +1,6 @@
import { PayloadSource } from './../../Abstract/Payload/Types/PayloadSource' import { PayloadSource } from './../../Abstract/Payload/Types/PayloadSource'
import { DecryptedPayload } from './../../Abstract/Payload/Implementations/DecryptedPayload' 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 { FillItemContent } from '../../Abstract/Content/ItemContent'
import { SNComponent } from './Component' import { SNComponent } from './Component'
import { ComponentContent } from './ComponentContent' import { ComponentContent } from './ComponentContent'
@@ -13,7 +13,7 @@ describe('component model', () => {
new DecryptedPayload( new DecryptedPayload(
{ {
uuid: String(Math.random()), uuid: String(Math.random()),
content_type: ContentType.Component, content_type: ContentType.TYPES.Component,
content: FillItemContent<ComponentContent>({ content: FillItemContent<ComponentContent>({
url: 'http://foo.com', url: 'http://foo.com',
hosted_url: 'http://bar.com', hosted_url: 'http://bar.com',
@@ -33,7 +33,7 @@ describe('component model', () => {
new DecryptedPayload( new DecryptedPayload(
{ {
uuid: String(Math.random()), uuid: String(Math.random()),
content_type: ContentType.Component, content_type: ContentType.TYPES.Component,
content: FillItemContent({ content: FillItemContent({
url: 'http://foo.com', url: 'http://foo.com',
hosted_url: '#{foo.zoo}', hosted_url: '#{foo.zoo}',
@@ -53,7 +53,7 @@ describe('component model', () => {
new DecryptedPayload( new DecryptedPayload(
{ {
uuid: String(Math.random()), uuid: String(Math.random()),
content_type: ContentType.Component, content_type: ContentType.TYPES.Component,
content: FillItemContent({ content: FillItemContent({
package_info: { package_info: {
note_type: NoteType.Authentication, note_type: NoteType.Authentication,
@@ -73,7 +73,7 @@ describe('component model', () => {
new DecryptedPayload( new DecryptedPayload(
{ {
uuid: String(Math.random()), uuid: String(Math.random()),
content_type: ContentType.Component, content_type: ContentType.TYPES.Component,
content: FillItemContent({ content: FillItemContent({
package_info: {}, package_info: {},
} as ComponentContent), } as ComponentContent),

View File

@@ -1,5 +1,4 @@
import { isValidUrl } from '@standardnotes/utils' import { isValidUrl } from '@standardnotes/utils'
import { ContentType } from '@standardnotes/common'
import { import {
FeatureIdentifier, FeatureIdentifier,
ThirdPartyFeatureDescription, ThirdPartyFeatureDescription,
@@ -20,11 +19,12 @@ import { Predicate } from '../../Runtime/Predicate/Predicate'
import { ItemInterface } from '../../Abstract/Item/Interfaces/ItemInterface' import { ItemInterface } from '../../Abstract/Item/Interfaces/ItemInterface'
import { DecryptedItemInterface } from './../../Abstract/Item/Interfaces/DecryptedItem' import { DecryptedItemInterface } from './../../Abstract/Item/Interfaces/DecryptedItem'
import { ComponentPackageInfo } from './PackageInfo' 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 => 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 * 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 { 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 */ /** @deprecated Use global application PrefKey.DefaultEditorIdentifier */

View File

@@ -1,5 +1,5 @@
import { ConflictStrategy } from './../../Abstract/Item/Types/ConflictStrategy' 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 { FillItemContent } from '../../Abstract/Content/ItemContent'
import { DecryptedPayload, PayloadTimestampDefaults } from '../../Abstract/Payload' import { DecryptedPayload, PayloadTimestampDefaults } from '../../Abstract/Payload'
import { FileContent, FileItem } from './File' import { FileContent, FileItem } from './File'
@@ -12,7 +12,7 @@ describe('file', () => {
return new FileItem( return new FileItem(
new DecryptedPayload<FileContent>({ new DecryptedPayload<FileContent>({
uuid: '123', uuid: '123',
content_type: ContentType.File, content_type: ContentType.TYPES.File,
content: FillItemContent<FileContent>({ content: FillItemContent<FileContent>({
name: 'name.png', name: 'name.png',
key: 'secret', key: 'secret',

View File

@@ -1,3 +1,4 @@
import { ContentType } from '@standardnotes/domain-core'
import { DecryptedItem } from '../../Abstract/Item/Implementations/DecryptedItem' import { DecryptedItem } from '../../Abstract/Item/Implementations/DecryptedItem'
import { ItemContent } from '../../Abstract/Content/ItemContent' import { ItemContent } from '../../Abstract/Content/ItemContent'
import { DecryptedPayloadInterface } from '../../Abstract/Payload/Interfaces/DecryptedPayload' import { DecryptedPayloadInterface } from '../../Abstract/Payload/Interfaces/DecryptedPayload'
@@ -5,7 +6,6 @@ import { FileMetadata } from './FileMetadata'
import { FileProtocolV1 } from './FileProtocolV1' import { FileProtocolV1 } from './FileProtocolV1'
import { SortableItem } from '../../Runtime/Collection/CollectionSort' import { SortableItem } from '../../Runtime/Collection/CollectionSort'
import { ConflictStrategy, ItemInterface } from '../../Abstract/Item' import { ConflictStrategy, ItemInterface } from '../../Abstract/Item'
import { ContentType } from '@standardnotes/common'
type EncryptedBytesLength = number type EncryptedBytesLength = number
type DecryptedBytesLength = number type DecryptedBytesLength = number
@@ -32,7 +32,7 @@ export type FileContentSpecialized = FileContentWithoutSize & FileMetadata & Siz
export type FileContent = FileContentSpecialized & ItemContent 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 export class FileItem
extends DecryptedItem<FileContent> extends DecryptedItem<FileContent>

View File

@@ -1,4 +1,4 @@
import { ContentType } from '@standardnotes/common' import { ContentType } from '@standardnotes/domain-core'
import { SNNote } from '../Note/Note' import { SNNote } from '../Note/Note'
import { FileContent, FileItem } from './File' import { FileContent, FileItem } from './File'
import { FileToNoteReference } from '../../Abstract/Reference/FileToNoteReference' import { FileToNoteReference } from '../../Abstract/Reference/FileToNoteReference'
@@ -18,7 +18,7 @@ export class FileMutator extends DecryptedItemMutator<FileContent> {
public addNote(note: SNNote): void { public addNote(note: SNNote): void {
const reference: FileToNoteReference = { const reference: FileToNoteReference = {
reference_type: ContentReferenceType.FileToNote, reference_type: ContentReferenceType.FileToNote,
content_type: ContentType.Note, content_type: ContentType.TYPES.Note,
uuid: note.uuid, uuid: note.uuid,
} }
@@ -39,7 +39,7 @@ export class FileMutator extends DecryptedItemMutator<FileContent> {
const reference: FileToFileReference = { const reference: FileToFileReference = {
uuid: file.uuid, uuid: file.uuid,
content_type: ContentType.File, content_type: ContentType.TYPES.File,
reference_type: ContentReferenceType.FileToFile, reference_type: ContentReferenceType.FileToFile,
} }

View File

@@ -1,4 +1,4 @@
import { ContentType, ProtocolVersion } from '@standardnotes/common' import { ProtocolVersion } from '@standardnotes/common'
import { ConflictStrategy, DecryptedItem } from '../../Abstract/Item' import { ConflictStrategy, DecryptedItem } from '../../Abstract/Item'
import { DecryptedPayloadInterface } from '../../Abstract/Payload' import { DecryptedPayloadInterface } from '../../Abstract/Payload'
import { HistoryEntryInterface } from '../../Runtime/History' import { HistoryEntryInterface } from '../../Runtime/History'
@@ -6,9 +6,10 @@ import { KeySystemRootKeyContent } from './KeySystemRootKeyContent'
import { KeySystemRootKeyInterface } from './KeySystemRootKeyInterface' import { KeySystemRootKeyInterface } from './KeySystemRootKeyInterface'
import { KeySystemIdentifier } from './KeySystemIdentifier' import { KeySystemIdentifier } from './KeySystemIdentifier'
import { KeySystemRootKeyParamsInterface } from '../../Local/KeyParams/KeySystemRootKeyParamsInterface' import { KeySystemRootKeyParamsInterface } from '../../Local/KeyParams/KeySystemRootKeyParamsInterface'
import { ContentType } from '@standardnotes/domain-core'
export function isKeySystemRootKey(x: { content_type: ContentType }): x is KeySystemRootKey { export function isKeySystemRootKey(x: { content_type: string }): x is KeySystemRootKey {
return x.content_type === ContentType.KeySystemRootKey return x.content_type === ContentType.TYPES.KeySystemRootKey
} }
export class KeySystemRootKey extends DecryptedItem<KeySystemRootKeyContent> implements KeySystemRootKeyInterface { export class KeySystemRootKey extends DecryptedItem<KeySystemRootKeyContent> implements KeySystemRootKeyInterface {

View File

@@ -1,13 +1,13 @@
import { AppDataField } from './../../Abstract/Item/Types/AppDataField' import { AppDataField } from './../../Abstract/Item/Types/AppDataField'
import { ContentType } from '@standardnotes/common'
import { FeatureIdentifier, NoteType } from '@standardnotes/features' import { FeatureIdentifier, NoteType } from '@standardnotes/features'
import { DecryptedItem } from '../../Abstract/Item/Implementations/DecryptedItem' import { DecryptedItem } from '../../Abstract/Item/Implementations/DecryptedItem'
import { ItemInterface } from '../../Abstract/Item/Interfaces/ItemInterface' import { ItemInterface } from '../../Abstract/Item/Interfaces/ItemInterface'
import { DecryptedPayloadInterface } from '../../Abstract/Payload/Interfaces/DecryptedPayload' import { DecryptedPayloadInterface } from '../../Abstract/Payload/Interfaces/DecryptedPayload'
import { NoteContent, NoteContentSpecialized } from './NoteContent' import { NoteContent, NoteContentSpecialized } from './NoteContent'
import { EditorLineWidth } from '../UserPrefs' 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 { export class SNNote extends DecryptedItem<NoteContent> implements NoteContentSpecialized {
public readonly title: string public readonly title: string

View File

@@ -2,10 +2,10 @@ import { NoteContent } from './NoteContent'
import { DecryptedItemMutator } from '../../Abstract/Item/Mutator/DecryptedItemMutator' import { DecryptedItemMutator } from '../../Abstract/Item/Mutator/DecryptedItemMutator'
import { SNNote } from './Note' import { SNNote } from './Note'
import { NoteToNoteReference } from '../../Abstract/Reference/NoteToNoteReference' import { NoteToNoteReference } from '../../Abstract/Reference/NoteToNoteReference'
import { ContentType } from '@standardnotes/common'
import { ContentReferenceType } from '../../Abstract/Item' import { ContentReferenceType } from '../../Abstract/Item'
import { FeatureIdentifier, NoteType } from '@standardnotes/features' import { FeatureIdentifier, NoteType } from '@standardnotes/features'
import { EditorLineWidth } from '../UserPrefs' import { EditorLineWidth } from '../UserPrefs'
import { ContentType } from '@standardnotes/domain-core'
export class NoteMutator extends DecryptedItemMutator<NoteContent> { export class NoteMutator extends DecryptedItemMutator<NoteContent> {
set title(title: string) { set title(title: string) {
@@ -63,7 +63,7 @@ export class NoteMutator extends DecryptedItemMutator<NoteContent> {
const reference: NoteToNoteReference = { const reference: NoteToNoteReference = {
uuid: note.uuid, uuid: note.uuid,
content_type: ContentType.Note, content_type: ContentType.TYPES.Note,
reference_type: ContentReferenceType.NoteToNote, reference_type: ContentReferenceType.NoteToNote,
} }

View File

@@ -1,3 +1,5 @@
import { ContentType } from '@standardnotes/domain-core'
import { DecryptedItem } from '../../Abstract/Item/Implementations/DecryptedItem' import { DecryptedItem } from '../../Abstract/Item/Implementations/DecryptedItem'
import { PredicateInterface } from '../../Runtime/Predicate/Interface' import { PredicateInterface } from '../../Runtime/Predicate/Interface'
import { predicateFromJson } from '../../Runtime/Predicate/Generators' import { predicateFromJson } from '../../Runtime/Predicate/Generators'
@@ -8,7 +10,6 @@ import { SmartViewDefaultIconName, systemViewIcon } from './SmartViewIcons'
import { SmartViewContent } from './SmartViewContent' import { SmartViewContent } from './SmartViewContent'
import { TagPreferences } from '../Tag/TagPreferences' import { TagPreferences } from '../Tag/TagPreferences'
import { ItemInterface } from '../../Abstract/Item' import { ItemInterface } from '../../Abstract/Item'
import { ContentType } from '@standardnotes/common'
export const SMART_TAG_DSL_PREFIX = '![' 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) 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> { export class SmartView extends DecryptedItem<SmartViewContent> {
public readonly predicate!: PredicateInterface<DecryptedItem> public readonly predicate!: PredicateInterface<DecryptedItem>

View File

@@ -4,19 +4,19 @@ import { SmartView } from './SmartView'
import { SmartViewContent } from './SmartViewContent' import { SmartViewContent } from './SmartViewContent'
import { SystemViewId } from './SystemViewId' import { SystemViewId } from './SystemViewId'
import { ItemWithTags } from '../../Runtime/Display/Search/ItemWithTags' import { ItemWithTags } from '../../Runtime/Display/Search/ItemWithTags'
import { ContentType } from '@standardnotes/common'
import { FillItemContent } from '../../Abstract/Content/ItemContent' import { FillItemContent } from '../../Abstract/Content/ItemContent'
import { Predicate } from '../../Runtime/Predicate/Predicate' import { Predicate } from '../../Runtime/Predicate/Predicate'
import { CompoundPredicate } from '../../Runtime/Predicate/CompoundPredicate' import { CompoundPredicate } from '../../Runtime/Predicate/CompoundPredicate'
import { PayloadTimestampDefaults } from '../../Abstract/Payload' import { PayloadTimestampDefaults } from '../../Abstract/Payload'
import { NotesAndFilesDisplayOptions } from '../../Runtime/Display' import { NotesAndFilesDisplayOptions } from '../../Runtime/Display'
import { FileItem } from '../File' import { FileItem } from '../File'
import { ContentType } from '@standardnotes/domain-core'
export function BuildSmartViews(options: NotesAndFilesDisplayOptions): SmartView[] { export function BuildSmartViews(options: NotesAndFilesDisplayOptions): SmartView[] {
const notes = new SmartView( const notes = new SmartView(
new DecryptedPayload({ new DecryptedPayload({
uuid: SystemViewId.AllNotes, uuid: SystemViewId.AllNotes,
content_type: ContentType.SmartView, content_type: ContentType.TYPES.SmartView,
...PayloadTimestampDefaults(), ...PayloadTimestampDefaults(),
content: FillItemContent<SmartViewContent>({ content: FillItemContent<SmartViewContent>({
title: 'Notes', title: 'Notes',
@@ -28,7 +28,7 @@ export function BuildSmartViews(options: NotesAndFilesDisplayOptions): SmartView
const files = new SmartView( const files = new SmartView(
new DecryptedPayload({ new DecryptedPayload({
uuid: SystemViewId.Files, uuid: SystemViewId.Files,
content_type: ContentType.SmartView, content_type: ContentType.TYPES.SmartView,
...PayloadTimestampDefaults(), ...PayloadTimestampDefaults(),
content: FillItemContent<SmartViewContent>({ content: FillItemContent<SmartViewContent>({
title: 'Files', title: 'Files',
@@ -40,7 +40,7 @@ export function BuildSmartViews(options: NotesAndFilesDisplayOptions): SmartView
const archived = new SmartView( const archived = new SmartView(
new DecryptedPayload({ new DecryptedPayload({
uuid: SystemViewId.ArchivedNotes, uuid: SystemViewId.ArchivedNotes,
content_type: ContentType.SmartView, content_type: ContentType.TYPES.SmartView,
...PayloadTimestampDefaults(), ...PayloadTimestampDefaults(),
content: FillItemContent<SmartViewContent>({ content: FillItemContent<SmartViewContent>({
title: 'Archived', title: 'Archived',
@@ -52,7 +52,7 @@ export function BuildSmartViews(options: NotesAndFilesDisplayOptions): SmartView
const trash = new SmartView( const trash = new SmartView(
new DecryptedPayload({ new DecryptedPayload({
uuid: SystemViewId.TrashedNotes, uuid: SystemViewId.TrashedNotes,
content_type: ContentType.SmartView, content_type: ContentType.TYPES.SmartView,
...PayloadTimestampDefaults(), ...PayloadTimestampDefaults(),
content: FillItemContent<SmartViewContent>({ content: FillItemContent<SmartViewContent>({
title: 'Trash', title: 'Trash',
@@ -64,7 +64,7 @@ export function BuildSmartViews(options: NotesAndFilesDisplayOptions): SmartView
const untagged = new SmartView( const untagged = new SmartView(
new DecryptedPayload({ new DecryptedPayload({
uuid: SystemViewId.UntaggedNotes, uuid: SystemViewId.UntaggedNotes,
content_type: ContentType.SmartView, content_type: ContentType.TYPES.SmartView,
...PayloadTimestampDefaults(), ...PayloadTimestampDefaults(),
content: FillItemContent<SmartViewContent>({ content: FillItemContent<SmartViewContent>({
title: 'Untagged', title: 'Untagged',
@@ -76,7 +76,7 @@ export function BuildSmartViews(options: NotesAndFilesDisplayOptions): SmartView
const starred = new SmartView( const starred = new SmartView(
new DecryptedPayload({ new DecryptedPayload({
uuid: SystemViewId.StarredNotes, uuid: SystemViewId.StarredNotes,
content_type: ContentType.SmartView, content_type: ContentType.TYPES.SmartView,
...PayloadTimestampDefaults(), ...PayloadTimestampDefaults(),
content: FillItemContent<SmartViewContent>({ content: FillItemContent<SmartViewContent>({
title: 'Starred', title: 'Starred',
@@ -88,7 +88,7 @@ export function BuildSmartViews(options: NotesAndFilesDisplayOptions): SmartView
const conflicts = new SmartView( const conflicts = new SmartView(
new DecryptedPayload({ new DecryptedPayload({
uuid: SystemViewId.Conflicts, uuid: SystemViewId.Conflicts,
content_type: ContentType.SmartView, content_type: ContentType.TYPES.SmartView,
...PayloadTimestampDefaults(), ...PayloadTimestampDefaults(),
content: FillItemContent<SmartViewContent>({ content: FillItemContent<SmartViewContent>({
title: 'Conflicts', title: 'Conflicts',
@@ -101,7 +101,7 @@ export function BuildSmartViews(options: NotesAndFilesDisplayOptions): SmartView
} }
function allNotesPredicate(options: NotesAndFilesDisplayOptions) { 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) { if (options.includeTrashed === false) {
subPredicates.push(new Predicate('trashed', '=', false)) subPredicates.push(new Predicate('trashed', '=', false))
@@ -121,7 +121,7 @@ function allNotesPredicate(options: NotesAndFilesDisplayOptions) {
} }
function filesPredicate(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) { if (options.includeTrashed === false) {
subPredicates.push(new Predicate('trashed', '=', false)) subPredicates.push(new Predicate('trashed', '=', false))
@@ -143,7 +143,7 @@ function filesPredicate(options: NotesAndFilesDisplayOptions) {
function archivedNotesPredicate(options: NotesAndFilesDisplayOptions) { function archivedNotesPredicate(options: NotesAndFilesDisplayOptions) {
const subPredicates: Predicate<SNNote>[] = [ const subPredicates: Predicate<SNNote>[] = [
new Predicate('archived', '=', true), new Predicate('archived', '=', true),
new Predicate('content_type', '=', ContentType.Note), new Predicate('content_type', '=', ContentType.TYPES.Note),
] ]
if (options.includeTrashed === false) { if (options.includeTrashed === false) {
subPredicates.push(new Predicate('trashed', '=', false)) subPredicates.push(new Predicate('trashed', '=', false))
@@ -162,7 +162,7 @@ function archivedNotesPredicate(options: NotesAndFilesDisplayOptions) {
function trashedNotesPredicate(options: NotesAndFilesDisplayOptions) { function trashedNotesPredicate(options: NotesAndFilesDisplayOptions) {
const subPredicates: Predicate<SNNote>[] = [ const subPredicates: Predicate<SNNote>[] = [
new Predicate('trashed', '=', true), new Predicate('trashed', '=', true),
new Predicate('content_type', '=', ContentType.Note), new Predicate('content_type', '=', ContentType.TYPES.Note),
] ]
if (options.includeArchived === false) { if (options.includeArchived === false) {
subPredicates.push(new Predicate('archived', '=', false)) subPredicates.push(new Predicate('archived', '=', false))
@@ -180,7 +180,7 @@ function trashedNotesPredicate(options: NotesAndFilesDisplayOptions) {
function untaggedNotesPredicate(options: NotesAndFilesDisplayOptions) { function untaggedNotesPredicate(options: NotesAndFilesDisplayOptions) {
const subPredicates = [ const subPredicates = [
new Predicate('content_type', '=', ContentType.Note), new Predicate('content_type', '=', ContentType.TYPES.Note),
new Predicate<ItemWithTags>('tagsCount', '=', 0), new Predicate<ItemWithTags>('tagsCount', '=', 0),
] ]
if (options.includeArchived === false) { if (options.includeArchived === false) {
@@ -200,7 +200,7 @@ function untaggedNotesPredicate(options: NotesAndFilesDisplayOptions) {
function starredNotesPredicate(options: NotesAndFilesDisplayOptions) { function starredNotesPredicate(options: NotesAndFilesDisplayOptions) {
const subPredicates: Predicate<SNNote>[] = [ const subPredicates: Predicate<SNNote>[] = [
new Predicate('starred', '=', true), new Predicate('starred', '=', true),
new Predicate('content_type', '=', ContentType.Note), new Predicate('content_type', '=', ContentType.TYPES.Note),
] ]
if (options.includeTrashed === false) { if (options.includeTrashed === false) {
subPredicates.push(new Predicate('trashed', '=', false)) subPredicates.push(new Predicate('trashed', '=', false))
@@ -217,7 +217,7 @@ function starredNotesPredicate(options: NotesAndFilesDisplayOptions) {
} }
function conflictsPredicate(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) { if (options.includeTrashed === false) {
subPredicates.push(new Predicate('trashed', '=', false)) subPredicates.push(new Predicate('trashed', '=', false))

View File

@@ -1,7 +1,7 @@
import { PayloadSource } from './../../Abstract/Payload/Types/PayloadSource' import { PayloadSource } from './../../Abstract/Payload/Types/PayloadSource'
import { DecryptedPayload } from './../../Abstract/Payload/Implementations/DecryptedPayload' import { DecryptedPayload } from './../../Abstract/Payload/Implementations/DecryptedPayload'
import { SNTag } from './Tag' import { SNTag } from './Tag'
import { ContentType } from '@standardnotes/common' import { ContentType } from '@standardnotes/domain-core'
import { FillItemContent } from '../../Abstract/Content/ItemContent' import { FillItemContent } from '../../Abstract/Content/ItemContent'
import { ContentReference } from '../../Abstract/Reference/ContentReference' import { ContentReference } from '../../Abstract/Reference/ContentReference'
import { PayloadTimestampDefaults } from '../../Abstract/Payload' import { PayloadTimestampDefaults } from '../../Abstract/Payload'
@@ -14,7 +14,7 @@ const create = (title: string, references: ContentReference[] = []): SNTag => {
new DecryptedPayload( new DecryptedPayload(
{ {
uuid: randUuid(), uuid: randUuid(),
content_type: ContentType.Tag, content_type: ContentType.TYPES.Tag,
content: FillItemContent({ content: FillItemContent({
title, title,
references, references,
@@ -31,9 +31,9 @@ const create = (title: string, references: ContentReference[] = []): SNTag => {
describe('SNTag Tests', () => { describe('SNTag Tests', () => {
it('should count notes in the basic case', () => { it('should count notes in the basic case', () => {
const tag = create('helloworld', [ const tag = create('helloworld', [
{ uuid: randUuid(), content_type: ContentType.Note }, { uuid: randUuid(), content_type: ContentType.TYPES.Note },
{ uuid: randUuid(), content_type: ContentType.Note }, { uuid: randUuid(), content_type: ContentType.TYPES.Note },
{ uuid: randUuid(), content_type: ContentType.Tag }, { uuid: randUuid(), content_type: ContentType.TYPES.Tag },
]) ])
expect(tag.noteCount).toEqual(2) expect(tag.noteCount).toEqual(2)

View File

@@ -1,5 +1,4 @@
import { VectorIconNameOrEmoji, IconType } from './../../Utilities/Icon/IconType' import { VectorIconNameOrEmoji, IconType } from './../../Utilities/Icon/IconType'
import { ContentType } from '@standardnotes/common'
import { DecryptedItem } from '../../Abstract/Item/Implementations/DecryptedItem' import { DecryptedItem } from '../../Abstract/Item/Implementations/DecryptedItem'
import { ItemInterface } from '../../Abstract/Item/Interfaces/ItemInterface' import { ItemInterface } from '../../Abstract/Item/Interfaces/ItemInterface'
import { ContentReference } from '../../Abstract/Reference/ContentReference' import { ContentReference } from '../../Abstract/Reference/ContentReference'
@@ -7,12 +6,13 @@ import { isTagToParentTagReference } from '../../Abstract/Reference/Functions'
import { DecryptedPayloadInterface } from '../../Abstract/Payload/Interfaces/DecryptedPayload' import { DecryptedPayloadInterface } from '../../Abstract/Payload/Interfaces/DecryptedPayload'
import { TagContent, TagContentSpecialized } from './TagContent' import { TagContent, TagContentSpecialized } from './TagContent'
import { TagPreferences } from './TagPreferences' import { TagPreferences } from './TagPreferences'
import { ContentType } from '@standardnotes/domain-core'
export const TagFolderDelimitter = '.' export const TagFolderDelimitter = '.'
export const DefaultTagIconName: IconType = 'hashtag' 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 { export class SNTag extends DecryptedItem<TagContent> implements TagContentSpecialized {
public readonly title: string public readonly title: string
@@ -34,7 +34,7 @@ export class SNTag extends DecryptedItem<TagContent> implements TagContentSpecia
get noteReferences(): ContentReference[] { get noteReferences(): ContentReference[] {
const references = this.payload.references 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 { get noteCount(): number {

View File

@@ -1,4 +1,4 @@
import { ContentType } from '@standardnotes/common' import { ContentType } from '@standardnotes/domain-core'
import { ContentReferenceType, MutationType } from '../../Abstract/Item' import { ContentReferenceType, MutationType } from '../../Abstract/Item'
import { createFile, createTagWithContent, createTagWithTitle } from '../../Utilities/Test/SpecUtils' import { createFile, createTagWithContent, createTagWithTitle } from '../../Utilities/Test/SpecUtils'
import { SNTag } from './Tag' import { SNTag } from './Tag'
@@ -15,7 +15,7 @@ describe('tag mutator', () => {
expect(result.content.references[0]).toEqual({ expect(result.content.references[0]).toEqual({
uuid: file.uuid, uuid: file.uuid,
content_type: ContentType.File, content_type: ContentType.TYPES.File,
reference_type: ContentReferenceType.TagToFile, reference_type: ContentReferenceType.TagToFile,
}) })
}) })

View File

@@ -1,4 +1,3 @@
import { ContentType } from '@standardnotes/common'
import { SNTag } from './Tag' import { SNTag } from './Tag'
import { TagContent } from './TagContent' import { TagContent } from './TagContent'
import { FileItem } from '../File' import { FileItem } from '../File'
@@ -10,6 +9,7 @@ import { DecryptedItemMutator } from '../../Abstract/Item/Mutator/DecryptedItemM
import { TagToFileReference } from '../../Abstract/Reference/TagToFileReference' import { TagToFileReference } from '../../Abstract/Reference/TagToFileReference'
import { TagPreferences } from './TagPreferences' import { TagPreferences } from './TagPreferences'
import { DecryptedItemInterface, MutationType } from '../../Abstract/Item' import { DecryptedItemInterface, MutationType } from '../../Abstract/Item'
import { ContentType } from '@standardnotes/domain-core'
export class TagMutator<Content extends TagContent = TagContent> extends DecryptedItemMutator<Content> { export class TagMutator<Content extends TagContent = TagContent> extends DecryptedItemMutator<Content> {
private mutablePreferences?: TagPreferences private mutablePreferences?: TagPreferences
@@ -51,7 +51,7 @@ export class TagMutator<Content extends TagContent = TagContent> extends Decrypt
const reference: TagToParentTagReference = { const reference: TagToParentTagReference = {
reference_type: ContentReferenceType.TagToParentTag, reference_type: ContentReferenceType.TagToParentTag,
content_type: ContentType.Tag, content_type: ContentType.TYPES.Tag,
uuid: tag.uuid, uuid: tag.uuid,
} }
@@ -71,7 +71,7 @@ export class TagMutator<Content extends TagContent = TagContent> extends Decrypt
const reference: TagToFileReference = { const reference: TagToFileReference = {
reference_type: ContentReferenceType.TagToFile, reference_type: ContentReferenceType.TagToFile,
content_type: ContentType.File, content_type: ContentType.TYPES.File,
uuid: file.uuid, uuid: file.uuid,
} }

View File

@@ -4,11 +4,11 @@ import { ConflictStrategy } from '../../Abstract/Item/Types/ConflictStrategy'
import { AppDataField } from '../../Abstract/Item/Types/AppDataField' import { AppDataField } from '../../Abstract/Item/Types/AppDataField'
import { HistoryEntryInterface } from '../../Runtime/History' import { HistoryEntryInterface } from '../../Runtime/History'
import { DecryptedItemInterface, ItemInterface } from '../../Abstract/Item' import { DecryptedItemInterface, ItemInterface } from '../../Abstract/Item'
import { ContentType } from '@standardnotes/common'
import { useBoolean } from '@standardnotes/utils' import { useBoolean } from '@standardnotes/utils'
import { ThemePackageInfo } from '../Component/PackageInfo' 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 { export class SNTheme extends SNComponent {
public override area: ComponentArea = ComponentArea.Themes public override area: ComponentArea = ComponentArea.Themes

View File

@@ -1,10 +1,10 @@
import { ContentType } from '@standardnotes/domain-core'
import { DecryptedItem } from '../../Abstract/Item/Implementations/DecryptedItem' import { DecryptedItem } from '../../Abstract/Item/Implementations/DecryptedItem'
import { ContentType } from '@standardnotes/common'
import { Predicate } from '../../Runtime/Predicate/Predicate' import { Predicate } from '../../Runtime/Predicate/Predicate'
import { PrefKey, PrefValue } from './PrefKey' import { PrefKey, PrefValue } from './PrefKey'
export class SNUserPrefs extends DecryptedItem { 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 { override get isSingleton(): true {
return true return true

View File

@@ -1,4 +1,3 @@
import { ContentType } from '@standardnotes/common'
import { EncryptedItem } from '../../Abstract/Item/Implementations/EncryptedItem' import { EncryptedItem } from '../../Abstract/Item/Implementations/EncryptedItem'
import { DecryptedPayloadInterface } from '../../Abstract/Payload/Interfaces/DecryptedPayload' import { DecryptedPayloadInterface } from '../../Abstract/Payload/Interfaces/DecryptedPayload'
import { FileItem } from '../../Syncable/File/File' import { FileItem } from '../../Syncable/File/File'
@@ -40,6 +39,7 @@ import {
isDeletedPayload, isDeletedPayload,
isEncryptedPayload, isEncryptedPayload,
} from '../../Abstract/Payload' } from '../../Abstract/Payload'
import { ContentType } from '@standardnotes/domain-core'
type ItemClass<C extends ItemContent = ItemContent> = new (payload: DecryptedPayloadInterface<C>) => DecryptedItem<C> 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> mutatorClass?: MutatorClass<C>
} }
const ContentTypeClassMapping: Partial<Record<ContentType, MappingEntry>> = { const ContentTypeClassMapping: Partial<Record<string, MappingEntry>> = {
[ContentType.ActionsExtension]: { [ContentType.TYPES.ActionsExtension]: {
itemClass: SNActionsExtension, itemClass: SNActionsExtension,
mutatorClass: ActionsExtensionMutator, mutatorClass: ActionsExtensionMutator,
}, },
[ContentType.Component]: { itemClass: SNComponent, mutatorClass: ComponentMutator }, [ContentType.TYPES.Component]: { itemClass: SNComponent, mutatorClass: ComponentMutator },
[ContentType.KeySystemRootKey]: { itemClass: KeySystemRootKey, mutatorClass: KeySystemRootKeyMutator }, [ContentType.TYPES.KeySystemRootKey]: { itemClass: KeySystemRootKey, mutatorClass: KeySystemRootKeyMutator },
[ContentType.TrustedContact]: { itemClass: TrustedContact, mutatorClass: TrustedContactMutator }, [ContentType.TYPES.TrustedContact]: { itemClass: TrustedContact, mutatorClass: TrustedContactMutator },
[ContentType.VaultListing]: { itemClass: VaultListing, mutatorClass: VaultListingMutator }, [ContentType.TYPES.VaultListing]: { itemClass: VaultListing, mutatorClass: VaultListingMutator },
[ContentType.Editor]: { itemClass: SNEditor }, [ContentType.TYPES.Editor]: { itemClass: SNEditor },
[ContentType.ExtensionRepo]: { itemClass: SNFeatureRepo }, [ContentType.TYPES.ExtensionRepo]: { itemClass: SNFeatureRepo },
[ContentType.File]: { itemClass: FileItem, mutatorClass: FileMutator }, [ContentType.TYPES.File]: { itemClass: FileItem, mutatorClass: FileMutator },
[ContentType.Note]: { itemClass: SNNote, mutatorClass: NoteMutator }, [ContentType.TYPES.Note]: { itemClass: SNNote, mutatorClass: NoteMutator },
[ContentType.SmartView]: { itemClass: SmartView, mutatorClass: SmartViewMutator }, [ContentType.TYPES.SmartView]: { itemClass: SmartView, mutatorClass: SmartViewMutator },
[ContentType.Tag]: { itemClass: SNTag, mutatorClass: TagMutator }, [ContentType.TYPES.Tag]: { itemClass: SNTag, mutatorClass: TagMutator },
[ContentType.Theme]: { itemClass: SNTheme, mutatorClass: ThemeMutator }, [ContentType.TYPES.Theme]: { itemClass: SNTheme, mutatorClass: ThemeMutator },
[ContentType.UserPrefs]: { itemClass: SNUserPrefs, mutatorClass: UserPrefsMutator }, [ContentType.TYPES.UserPrefs]: { itemClass: SNUserPrefs, mutatorClass: UserPrefsMutator },
} as unknown as Partial<Record<ContentType, MappingEntry>> } as unknown as Partial<Record<string, MappingEntry>>
export function CreateDecryptedMutatorForItem< export function CreateDecryptedMutatorForItem<
I extends DecryptedItemInterface, I extends DecryptedItemInterface,
@@ -87,7 +87,7 @@ export function CreateDecryptedMutatorForItem<
export function RegisterItemClass< export function RegisterItemClass<
C extends ItemContent = ItemContent, C extends ItemContent = ItemContent,
M extends DecryptedItemMutator<C> = DecryptedItemMutator<C>, M extends DecryptedItemMutator<C> = DecryptedItemMutator<C>,
>(contentType: ContentType, itemClass: ItemClass<C>, mutatorClass: M) { >(contentType: string, itemClass: ItemClass<C>, mutatorClass: M) {
const entry: MappingEntry<C> = { const entry: MappingEntry<C> = {
itemClass: itemClass, itemClass: itemClass,
mutatorClass: mutatorClass as unknown as MutatorClass<C>, mutatorClass: mutatorClass as unknown as MutatorClass<C>,

View File

@@ -1,5 +1,4 @@
import { DeletedPayload } from '../../Abstract/Payload/Implementations/DeletedPayload' import { DeletedPayload } from '../../Abstract/Payload/Implementations/DeletedPayload'
import { ContentType } from '@standardnotes/common'
import { extendArray, UuidGenerator } from '@standardnotes/utils' import { extendArray, UuidGenerator } from '@standardnotes/utils'
import { ImmutablePayloadCollection } from '../../Runtime/Collection/Payload/ImmutablePayloadCollection' import { ImmutablePayloadCollection } from '../../Runtime/Collection/Payload/ImmutablePayloadCollection'
import { DecryptedPayloadInterface } from '../../Abstract/Payload/Interfaces/DecryptedPayload' import { DecryptedPayloadInterface } from '../../Abstract/Payload/Interfaces/DecryptedPayload'
@@ -9,6 +8,7 @@ import { EncryptedPayloadInterface } from '../../Abstract/Payload/Interfaces/Enc
import { PayloadsByUpdatingReferencingPayloadReferences } from './PayloadsByUpdatingReferencingPayloadReferences' import { PayloadsByUpdatingReferencingPayloadReferences } from './PayloadsByUpdatingReferencingPayloadReferences'
import { SyncResolvedPayload } from '../../Runtime/Deltas/Utilities/SyncResolvedPayload' import { SyncResolvedPayload } from '../../Runtime/Deltas/Utilities/SyncResolvedPayload'
import { getIncrementedDirtyIndex } from '../../Runtime/DirtyCounter/DirtyCounter' 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. * 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) 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 * Update any payloads who are still encrypted and whose items_key_id point to this uuid
*/ */

View File

@@ -1,11 +1,11 @@
import { TagContent } from './../../Syncable/Tag/TagContent' import { TagContent } from './../../Syncable/Tag/TagContent'
import { ContentType } from '@standardnotes/common'
import { FillItemContent, ItemContent } from '../../Abstract/Content/ItemContent' import { FillItemContent, ItemContent } from '../../Abstract/Content/ItemContent'
import { DecryptedPayload, PayloadSource, PayloadTimestampDefaults } from '../../Abstract/Payload' import { DecryptedPayload, PayloadSource, PayloadTimestampDefaults } from '../../Abstract/Payload'
import { FileContent, FileItem } from '../../Syncable/File' import { FileContent, FileItem } from '../../Syncable/File'
import { NoteContent, SNNote } from '../../Syncable/Note' import { NoteContent, SNNote } from '../../Syncable/Note'
import { SNTag } from '../../Syncable/Tag' import { SNTag } from '../../Syncable/Tag'
import { SmartView, SmartViewContent } from '../../Syncable/SmartView' import { SmartView, SmartViewContent } from '../../Syncable/SmartView'
import { ContentType } from '@standardnotes/domain-core'
let currentId = 0 let currentId = 0
@@ -18,7 +18,7 @@ export const createNote = (content?: Partial<NoteContent>): SNNote => {
new DecryptedPayload( new DecryptedPayload(
{ {
uuid: mockUuid(), uuid: mockUuid(),
content_type: ContentType.Note, content_type: ContentType.TYPES.Note,
content: FillItemContent({ ...content }), content: FillItemContent({ ...content }),
...PayloadTimestampDefaults(), ...PayloadTimestampDefaults(),
}, },
@@ -32,7 +32,7 @@ export const createNoteWithContent = (content: Partial<NoteContent>, createdAt?:
new DecryptedPayload( new DecryptedPayload(
{ {
uuid: mockUuid(), uuid: mockUuid(),
content_type: ContentType.Note, content_type: ContentType.TYPES.Note,
content: FillItemContent<NoteContent>(content), content: FillItemContent<NoteContent>(content),
...PayloadTimestampDefaults(), ...PayloadTimestampDefaults(),
created_at: createdAt || new Date(), created_at: createdAt || new Date(),
@@ -47,7 +47,7 @@ export const createTagWithContent = (content: Partial<TagContent>): SNTag => {
new DecryptedPayload( new DecryptedPayload(
{ {
uuid: mockUuid(), uuid: mockUuid(),
content_type: ContentType.Tag, content_type: ContentType.TYPES.Tag,
content: FillItemContent<TagContent>(content), content: FillItemContent<TagContent>(content),
...PayloadTimestampDefaults(), ...PayloadTimestampDefaults(),
}, },
@@ -61,7 +61,7 @@ export const createSmartViewWithContent = (content: Partial<SmartViewContent>):
new DecryptedPayload( new DecryptedPayload(
{ {
uuid: mockUuid(), uuid: mockUuid(),
content_type: ContentType.SmartView, content_type: ContentType.TYPES.SmartView,
content: FillItemContent<SmartViewContent>(content), content: FillItemContent<SmartViewContent>(content),
...PayloadTimestampDefaults(), ...PayloadTimestampDefaults(),
}, },
@@ -75,7 +75,7 @@ export const createTagWithTitle = (title = 'photos') => {
new DecryptedPayload( new DecryptedPayload(
{ {
uuid: mockUuid(), uuid: mockUuid(),
content_type: ContentType.Tag, content_type: ContentType.TYPES.Tag,
content: FillItemContent<TagContent>({ title }), content: FillItemContent<TagContent>({ title }),
...PayloadTimestampDefaults(), ...PayloadTimestampDefaults(),
}, },
@@ -89,7 +89,7 @@ export const createSmartViewWithTitle = (title = 'photos') => {
new DecryptedPayload( new DecryptedPayload(
{ {
uuid: mockUuid(), uuid: mockUuid(),
content_type: ContentType.SmartView, content_type: ContentType.TYPES.SmartView,
content: FillItemContent<SmartViewContent>({ title }), content: FillItemContent<SmartViewContent>({ title }),
...PayloadTimestampDefaults(), ...PayloadTimestampDefaults(),
}, },
@@ -103,7 +103,7 @@ export const createFile = (name = 'screenshot.png') => {
new DecryptedPayload( new DecryptedPayload(
{ {
uuid: mockUuid(), uuid: mockUuid(),
content_type: ContentType.File, content_type: ContentType.TYPES.File,
content: FillItemContent<FileContent>({ name }), content: FillItemContent<FileContent>({ name }),
...PayloadTimestampDefaults(), ...PayloadTimestampDefaults(),
}, },

View File

@@ -33,7 +33,7 @@
"typescript": "*" "typescript": "*"
}, },
"dependencies": { "dependencies": {
"@standardnotes/common": "^1.48.3", "@standardnotes/common": "^1.50.0",
"@standardnotes/features": "workspace:*", "@standardnotes/features": "workspace:*",
"@standardnotes/security": "^1.7.6", "@standardnotes/security": "^1.7.6",
"reflect-metadata": "^0.1.13" "reflect-metadata": "^0.1.13"

View File

@@ -1,7 +1,5 @@
import { ContentType } from '@standardnotes/common'
export interface ServerItemResponse { export interface ServerItemResponse {
content_type: ContentType content_type: string
content: string | undefined content: string | undefined
created_at_timestamp: number created_at_timestamp: number
created_at: Date created_at: Date

View File

@@ -1,10 +1,10 @@
import { AnyKeyParamsContent, ContentType } from '@standardnotes/common' import { AnyKeyParamsContent } from '@standardnotes/common'
import { DeprecatedHttpResponse } from '../Http/DeprecatedHttpResponse' import { DeprecatedHttpResponse } from '../Http/DeprecatedHttpResponse'
import { ServerItemResponse } from '../Item/ServerItemResponse' import { ServerItemResponse } from '../Item/ServerItemResponse'
export type ActionResponse = DeprecatedHttpResponse & { export type ActionResponse = DeprecatedHttpResponse & {
description: string description: string
supported_types: ContentType[] supported_types: string[]
deprecation?: string deprecation?: string
actions: unknown[] actions: unknown[]
item?: ServerItemResponse item?: ServerItemResponse

View File

@@ -17,8 +17,8 @@
}, },
"dependencies": { "dependencies": {
"@standardnotes/api": "workspace:^", "@standardnotes/api": "workspace:^",
"@standardnotes/common": "^1.48.3", "@standardnotes/common": "^1.50.0",
"@standardnotes/domain-core": "^1.12.0", "@standardnotes/domain-core": "^1.22.0",
"@standardnotes/encryption": "workspace:^", "@standardnotes/encryption": "workspace:^",
"@standardnotes/features": "workspace:^", "@standardnotes/features": "workspace:^",
"@standardnotes/files": "workspace:^", "@standardnotes/files": "workspace:^",

Some files were not shown because too many files have changed in this diff Show More