Skip to content

Commit

Permalink
feat(web): extract ui-services package
Browse files Browse the repository at this point in the history
  • Loading branch information
Karol Sójko committed Aug 4, 2022
1 parent c72a407 commit 7e25126
Show file tree
Hide file tree
Showing 161 changed files with 1,106 additions and 825 deletions.
Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"build:desktop": "yarn workspaces foreach -pt --verbose -R --from @standardnotes/desktop --exclude @standardnotes/components-meta run build",
"build:mobile": "yarn workspaces foreach -pt --verbose -R --from @standardnotes/mobile --exclude @standardnotes/components-meta run build",
"build:snjs": "yarn workspaces foreach -pt --verbose -R --from @standardnotes/snjs --exclude @standardnotes/components-meta run build",
"build:services": "yarn workspaces foreach -pt --verbose -R --from @standardnotes/services --exclude @standardnotes/components-meta run build",
"start:server:web": "lerna run start --scope=@standardnotes/web",
"start:server:e2e": "lerna run start:test-server --scope=@standardnotes/snjs",
"prepare": "husky install",
Expand Down
9 changes: 0 additions & 9 deletions packages/encryption/src/Domain/Backups/BackupFile.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
ProtocolVersion,
} from '@standardnotes/common'
import {
BackupFile,
CreateDecryptedItemFromPayload,
CreatePayloadSplit,
DecryptedPayload,
Expand All @@ -28,7 +29,6 @@ import { CreateAnyKeyParams } from '../Keys/RootKey/KeyParamsFunctions'
import { SNRootKey } from '../Keys/RootKey/RootKey'
import { SNRootKeyParams } from '../Keys/RootKey/RootKeyParams'
import { EncryptionService } from '../Service/Encryption/EncryptionService'
import { BackupFile } from './BackupFile'
import { BackupFileType } from './BackupFileType'

export async function DecryptBackupFile(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { ProtocolVersion } from '@standardnotes/common'
import {
BackupFile,
DecryptedPayloadInterface,
EncryptedPayloadInterface,
ItemContent,
RootKeyInterface,
} from '@standardnotes/models'
import { ClientDisplayableError } from '@standardnotes/responses'
import { BackupFile } from '../../Backups/BackupFile'
import { SNRootKeyParams } from '../../Keys/RootKey/RootKeyParams'
import { KeyedDecryptionSplit } from '../../Split/KeyedDecryptionSplit'
import { KeyedEncryptionSplit } from '../../Split/KeyedEncryptionSplit'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as Common from '@standardnotes/common'
import * as Models from '@standardnotes/models'
import {
BackupFile,
CreateDecryptedBackupFileContextPayload,
CreateEncryptedBackupFileContextPayload,
EncryptedPayload,
Expand All @@ -15,7 +16,6 @@ import { PureCryptoInterface } from '@standardnotes/sncrypto-common'
import * as Utils from '@standardnotes/utils'
import { isNotUndefined } from '@standardnotes/utils'
import { V001Algorithm, V002Algorithm } from '../../Algorithm'
import { BackupFile } from '../../Backups/BackupFile'
import { DecryptBackupFile } from '../../Backups/BackupFileDecryptor'
import { CreateAnyKeyParams } from '../../Keys/RootKey/KeyParamsFunctions'
import { SNRootKey } from '../../Keys/RootKey/RootKey'
Expand Down
1 change: 0 additions & 1 deletion packages/encryption/src/Domain/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export * from './Algorithm'
export * from './Backups/BackupFile'
export * from './Backups/BackupFileDecryptor'
export * from './Backups/BackupFileType'
export * from './Keys/ItemsKey/ItemsKey'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { ComponentAction } from '@standardnotes/features'
import { MessageData } from './MessageData'

export type ActionObserver = (action: ComponentAction, messageData: MessageData) => void
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { ComponentViewerEvent } from './ComponentViewerEvent'

export type ComponentEventObserver = (event: ComponentViewerEvent) => void
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { ComponentAction } from '@standardnotes/features'
import { MessageData } from './MessageData'

export type ComponentMessage = {
action: ComponentAction
sessionKey?: string
componentData?: Record<string, unknown>
data: MessageData
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export enum ComponentViewerEvent {
FeatureStatusUpdated = 'FeatureStatusUpdated',
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { DecryptedTransferPayload } from '../TransferPayload/Interfaces/DecryptedTransferPayload'

export type IncomingComponentItemPayload = DecryptedTransferPayload & {
clientData: Record<string, unknown>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export enum KeyboardModifier {
Shift = 'Shift',
Ctrl = 'Control',
Meta = 'Meta',
}
31 changes: 31 additions & 0 deletions packages/models/src/Domain/Abstract/Component/MessageData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { ContentType, Uuid } from '@standardnotes/common'
import { ComponentPermission } from '@standardnotes/features'

import { IncomingComponentItemPayload } from './IncomingComponentItemPayload'
import { KeyboardModifier } from './KeyboardModifier'

export type MessageData = Partial<{
/** Related to the stream-item-context action */
item?: IncomingComponentItemPayload
/** Related to the stream-items action */
content_types?: ContentType[]
items?: IncomingComponentItemPayload[]
/** Related to the request-permission action */
permissions?: ComponentPermission[]
/** Related to the component-registered action */
componentData?: Record<string, unknown>
uuid?: Uuid
environment?: string
platform?: string
activeThemeUrls?: string[]
/** Related to set-size action */
width?: string | number
height?: string | number
type?: string
/** Related to themes action */
themes?: string[]
/** Related to clear-selection action */
content_type?: ContentType
/** Related to key-pressed action */
keyboardModifier?: KeyboardModifier
}>
10 changes: 10 additions & 0 deletions packages/models/src/Domain/Abstract/Component/PermissionDialog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ComponentPermission } from '@standardnotes/features'
import { SNComponent } from '../../Syncable/Component'

export type PermissionDialog = {
component: SNComponent
permissions: ComponentPermission[]
permissionsString: string
actionBlock: (approved: boolean) => void
callback: (approved: boolean) => void
}
68 changes: 9 additions & 59 deletions packages/models/src/Domain/Abstract/Contextual/BackupFile.ts
Original file line number Diff line number Diff line change
@@ -1,60 +1,10 @@
import { Uuid } from '@standardnotes/common'
import { ContextPayload } from './ContextPayload'
import { ItemContent } from '../Content/ItemContent'
import { DecryptedTransferPayload, EncryptedTransferPayload } from '../TransferPayload'

export interface BackupFileEncryptedContextualPayload extends ContextPayload {
auth_hash?: string
content: string
created_at_timestamp: number
created_at: Date
duplicate_of?: Uuid
enc_item_key: string
items_key_id: string | undefined
updated_at: Date
updated_at_timestamp: number
}

export interface BackupFileDecryptedContextualPayload<C extends ItemContent = ItemContent> extends ContextPayload {
content: C
created_at_timestamp: number
created_at: Date
duplicate_of?: Uuid
updated_at: Date
updated_at_timestamp: number
}

export function CreateEncryptedBackupFileContextPayload(
fromPayload: EncryptedTransferPayload,
): BackupFileEncryptedContextualPayload {
return {
auth_hash: fromPayload.auth_hash,
content_type: fromPayload.content_type,
content: fromPayload.content,
created_at_timestamp: fromPayload.created_at_timestamp,
created_at: fromPayload.created_at,
deleted: false,
duplicate_of: fromPayload.duplicate_of,
enc_item_key: fromPayload.enc_item_key,
items_key_id: fromPayload.items_key_id,
updated_at_timestamp: fromPayload.updated_at_timestamp,
updated_at: fromPayload.updated_at,
uuid: fromPayload.uuid,
}
}

export function CreateDecryptedBackupFileContextPayload(
fromPayload: DecryptedTransferPayload,
): BackupFileDecryptedContextualPayload {
return {
content_type: fromPayload.content_type,
content: fromPayload.content,
created_at_timestamp: fromPayload.created_at_timestamp,
created_at: fromPayload.created_at,
deleted: false,
duplicate_of: fromPayload.duplicate_of,
updated_at_timestamp: fromPayload.updated_at_timestamp,
updated_at: fromPayload.updated_at,
uuid: fromPayload.uuid,
}
import { AnyKeyParamsContent, ProtocolVersion } from '@standardnotes/common'
import { BackupFileDecryptedContextualPayload } from './BackupFileDecryptedContextualPayload'
import { BackupFileEncryptedContextualPayload } from './BackupFileEncryptedContextualPayload'

export type BackupFile = {
version?: ProtocolVersion
keyParams?: AnyKeyParamsContent
auth_params?: AnyKeyParamsContent
items: (BackupFileDecryptedContextualPayload | BackupFileEncryptedContextualPayload)[]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Uuid } from '@standardnotes/common'
import { ItemContent } from '../Content/ItemContent'
import { ContextPayload } from './ContextPayload'

export interface BackupFileDecryptedContextualPayload<C extends ItemContent = ItemContent> extends ContextPayload {
content: C
created_at_timestamp: number
created_at: Date
duplicate_of?: Uuid
updated_at: Date
updated_at_timestamp: number
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Uuid } from '@standardnotes/common'
import { ContextPayload } from './ContextPayload'

export interface BackupFileEncryptedContextualPayload extends ContextPayload {
auth_hash?: string
content: string
created_at_timestamp: number
created_at: Date
duplicate_of?: Uuid
enc_item_key: string
items_key_id: string | undefined
updated_at: Date
updated_at_timestamp: number
}
39 changes: 39 additions & 0 deletions packages/models/src/Domain/Abstract/Contextual/Functions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { DecryptedTransferPayload, EncryptedTransferPayload } from '../TransferPayload'

import { BackupFileDecryptedContextualPayload } from './BackupFileDecryptedContextualPayload'
import { BackupFileEncryptedContextualPayload } from './BackupFileEncryptedContextualPayload'

export function CreateEncryptedBackupFileContextPayload(
fromPayload: EncryptedTransferPayload,
): BackupFileEncryptedContextualPayload {
return {
auth_hash: fromPayload.auth_hash,
content_type: fromPayload.content_type,
content: fromPayload.content,
created_at_timestamp: fromPayload.created_at_timestamp,
created_at: fromPayload.created_at,
deleted: false,
duplicate_of: fromPayload.duplicate_of,
enc_item_key: fromPayload.enc_item_key,
items_key_id: fromPayload.items_key_id,
updated_at_timestamp: fromPayload.updated_at_timestamp,
updated_at: fromPayload.updated_at,
uuid: fromPayload.uuid,
}
}

export function CreateDecryptedBackupFileContextPayload(
fromPayload: DecryptedTransferPayload,
): BackupFileDecryptedContextualPayload {
return {
content_type: fromPayload.content_type,
content: fromPayload.content,
created_at_timestamp: fromPayload.created_at_timestamp,
created_at: fromPayload.created_at,
deleted: false,
duplicate_of: fromPayload.duplicate_of,
updated_at_timestamp: fromPayload.updated_at_timestamp,
updated_at: fromPayload.updated_at,
uuid: fromPayload.uuid,
}
}
10 changes: 0 additions & 10 deletions packages/models/src/Domain/Abstract/Contextual/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Uuid } from '@standardnotes/common'

import { MutationType } from '../Types/MutationType'

import { ItemMutator } from './ItemMutator'

export type TransactionalMutation = {
itemUuid: Uuid
mutate: (mutator: ItemMutator) => void
mutationType?: MutationType
}
11 changes: 11 additions & 0 deletions packages/models/src/Domain/Abstract/Item/Types/ItemStream.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { PayloadEmitSource } from '../../Payload'
import { DecryptedItemInterface } from '../Interfaces/DecryptedItem'
import { DeletedItemInterface } from '../Interfaces/DeletedItem'
import { EncryptedItemInterface } from '../Interfaces/EncryptedItem'

export type ItemStream<I extends DecryptedItemInterface> = (data: {
changed: I[]
inserted: I[]
removed: (DeletedItemInterface | EncryptedItemInterface)[]
source: PayloadEmitSource
}) => void
4 changes: 2 additions & 2 deletions packages/models/src/Domain/Abstract/Item/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ export * from './Interfaces/TypeCheck'
export * from './Mutator/DecryptedItemMutator'
export * from './Mutator/DeleteMutator'
export * from './Mutator/ItemMutator'
export * from './Types/AppDataField'
export * from './Mutator/TransactionalMutation'
export * from './Types/AppDataField'
export * from './Types/ConflictStrategy'
export * from './Types/DefaultAppDomain'
export * from './Types/DefaultAppDomain'
export * from './Types/ItemStream'
export * from './Types/MutationType'
export * from './Types/SingletonStrategy'
23 changes: 22 additions & 1 deletion packages/models/src/Domain/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
export * from './Abstract/Component/ActionObserver'
export * from './Abstract/Component/ComponentViewerEvent'
export * from './Abstract/Component/ComponentMessage'
export * from './Abstract/Component/ComponentEventObserver'
export * from './Abstract/Component/IncomingComponentItemPayload'
export * from './Abstract/Component/KeyboardModifier'
export * from './Abstract/Component/MessageData'
export * from './Abstract/Component/PermissionDialog'
export * from './Abstract/Content/ItemContent'
export * from './Abstract/Contextual'
export * from './Abstract/Contextual/BackupFile'
export * from './Abstract/Contextual/BackupFileDecryptedContextualPayload'
export * from './Abstract/Contextual/BackupFileEncryptedContextualPayload'
export * from './Abstract/Contextual/ComponentCreate'
export * from './Abstract/Contextual/ComponentRetrieved'
export * from './Abstract/Contextual/ContextPayload'
export * from './Abstract/Contextual/FilteredServerItem'
export * from './Abstract/Contextual/Functions'
export * from './Abstract/Contextual/LocalStorage'
export * from './Abstract/Contextual/OfflineSyncPush'
export * from './Abstract/Contextual/OfflineSyncSaved'
export * from './Abstract/Contextual/ServerSyncPush'
export * from './Abstract/Contextual/ServerSyncSaved'
export * from './Abstract/Contextual/SessionHistory'
export * from './Abstract/Item'
export * from './Abstract/Payload'
export * from './Abstract/TransferPayload'
Expand Down
4 changes: 2 additions & 2 deletions packages/services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
},
"dependencies": {
"@standardnotes/auth": "^3.19.4",
"@standardnotes/common": "^1.23.1",
"@standardnotes/models": "workspace:*",
"@standardnotes/common": "^1.30.0",
"@standardnotes/models": "workspace:^",
"@standardnotes/responses": "workspace:*",
"@standardnotes/security": "^1.2.0",
"@standardnotes/utils": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { ApplicationInterface } from './ApplicationInterface'
import { DeinitCallback } from './DeinitCallback'

export interface AppGroupManagedApplication extends ApplicationInterface {
onDeinit: DeinitCallback
setOnDeinit(onDeinit: DeinitCallback): void
}

0 comments on commit 7e25126

Please sign in to comment.