feat: add snjs package
This commit is contained in:
16
packages/snjs/lib/Application/Options/ApplicationOptions.ts
Normal file
16
packages/snjs/lib/Application/Options/ApplicationOptions.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { ApplicationOptionsWhichHaveDefaults } from './Defaults'
|
||||
import {
|
||||
ApplicationDisplayOptions,
|
||||
ApplicationOptionalConfiguratioOptions,
|
||||
ApplicationSyncOptions,
|
||||
} from './OptionalOptions'
|
||||
import { RequiredApplicationOptions } from './RequiredOptions'
|
||||
|
||||
export type ApplicationConstructorOptions = RequiredApplicationOptions &
|
||||
Partial<ApplicationSyncOptions & ApplicationDisplayOptions & ApplicationOptionalConfiguratioOptions>
|
||||
|
||||
export type FullyResolvedApplicationOptions = RequiredApplicationOptions &
|
||||
ApplicationSyncOptions &
|
||||
ApplicationDisplayOptions &
|
||||
ApplicationOptionalConfiguratioOptions &
|
||||
ApplicationOptionsWhichHaveDefaults
|
||||
11
packages/snjs/lib/Application/Options/Defaults.ts
Normal file
11
packages/snjs/lib/Application/Options/Defaults.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { ApplicationDisplayOptions, ApplicationSyncOptions } from './OptionalOptions'
|
||||
|
||||
export interface ApplicationOptionsWhichHaveDefaults {
|
||||
loadBatchSize: ApplicationSyncOptions['loadBatchSize']
|
||||
supportsFileNavigation: ApplicationDisplayOptions['supportsFileNavigation']
|
||||
}
|
||||
|
||||
export const ApplicationOptionsDefaults: ApplicationOptionsWhichHaveDefaults = {
|
||||
loadBatchSize: 700,
|
||||
supportsFileNavigation: false,
|
||||
}
|
||||
25
packages/snjs/lib/Application/Options/OptionalOptions.ts
Normal file
25
packages/snjs/lib/Application/Options/OptionalOptions.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
export interface ApplicationSyncOptions {
|
||||
/**
|
||||
* The size of the item batch to decrypt and render upon application load.
|
||||
*/
|
||||
loadBatchSize: number
|
||||
}
|
||||
|
||||
export interface ApplicationDisplayOptions {
|
||||
supportsFileNavigation: boolean
|
||||
}
|
||||
|
||||
export interface ApplicationOptionalConfiguratioOptions {
|
||||
/**
|
||||
* Gives consumers the ability to provide their own custom
|
||||
* subclass for a service. swapClasses should be an array of key/value pairs
|
||||
* consisting of keys 'swap' and 'with'. 'swap' is the base class you wish to replace,
|
||||
* and 'with' is the custom subclass to use.
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
swapClasses?: { swap: any; with: any }[]
|
||||
/**
|
||||
* URL for WebSocket providing permissions and roles information.
|
||||
*/
|
||||
webSocketUrl?: string
|
||||
}
|
||||
42
packages/snjs/lib/Application/Options/RequiredOptions.ts
Normal file
42
packages/snjs/lib/Application/Options/RequiredOptions.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { ApplicationIdentifier } from '@standardnotes/common'
|
||||
import { AlertService, DeviceInterface, Environment, Platform } from '@standardnotes/services'
|
||||
import { PureCryptoInterface } from '@standardnotes/sncrypto-common'
|
||||
|
||||
export interface RequiredApplicationOptions {
|
||||
/**
|
||||
* The Environment that identifies your application.
|
||||
*/
|
||||
environment: Environment
|
||||
/**
|
||||
* The Platform that identifies your application.
|
||||
*/
|
||||
platform: Platform
|
||||
/**
|
||||
* The device interface that provides platform specific
|
||||
* utilities that are used to read/write raw values from/to the database or value storage.
|
||||
*/
|
||||
deviceInterface: DeviceInterface
|
||||
/**
|
||||
* The platform-dependent implementation of SNPureCrypto to use.
|
||||
* Web uses SNWebCrypto, mobile uses SNReactNativeCrypto.
|
||||
*/
|
||||
crypto: PureCryptoInterface
|
||||
/**
|
||||
* The platform-dependent implementation of alert service.
|
||||
*/
|
||||
alertService: AlertService
|
||||
/**
|
||||
* A unique persistent identifier to namespace storage and other
|
||||
* persistent properties. For an ephemeral runtime identifier, use ephemeralIdentifier.
|
||||
*/
|
||||
identifier: ApplicationIdentifier
|
||||
|
||||
/**
|
||||
* Default host to use in ApiService.
|
||||
*/
|
||||
defaultHost: string
|
||||
/**
|
||||
* Version of client application.
|
||||
*/
|
||||
appVersion: string
|
||||
}
|
||||
Reference in New Issue
Block a user