refactor: remove Uuid and RoleName from @standardnotes/common in favour of @standardnotes/domain-core value objects (#2167)
This commit is contained in:
BIN
.yarn/cache/@standardnotes-common-npm-1.46.3-a99a2b97e2-0fa509e304.zip
vendored
Normal file
BIN
.yarn/cache/@standardnotes-common-npm-1.46.3-a99a2b97e2-0fa509e304.zip
vendored
Normal file
Binary file not shown.
Binary file not shown.
@@ -36,8 +36,8 @@
|
||||
"typescript": "*"
|
||||
},
|
||||
"dependencies": {
|
||||
"@standardnotes/common": "^1.45.0",
|
||||
"@standardnotes/domain-core": "^1.11.0",
|
||||
"@standardnotes/common": "^1.46.3",
|
||||
"@standardnotes/domain-core": "^1.11.1",
|
||||
"@standardnotes/encryption": "workspace:*",
|
||||
"@standardnotes/models": "workspace:*",
|
||||
"@standardnotes/responses": "workspace:*",
|
||||
|
||||
@@ -10,7 +10,6 @@ import { SubscriptionInviteAcceptResponse } from '../../Response/Subscription/Su
|
||||
|
||||
import { SubscriptionApiServiceInterface } from './SubscriptionApiServiceInterface'
|
||||
import { SubscriptionApiOperations } from './SubscriptionApiOperations'
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
import { AppleIAPConfirmResponse } from './../../Response/Subscription/AppleIAPConfirmResponse'
|
||||
import { AppleIAPConfirmRequestParams } from '../../Request'
|
||||
|
||||
@@ -83,7 +82,7 @@ export class SubscriptionApiService implements SubscriptionApiServiceInterface {
|
||||
}
|
||||
}
|
||||
|
||||
async acceptInvite(inviteUuid: Uuid): Promise<SubscriptionInviteAcceptResponse> {
|
||||
async acceptInvite(inviteUuid: string): Promise<SubscriptionInviteAcceptResponse> {
|
||||
if (this.operationsInProgress.get(SubscriptionApiOperations.AcceptingInvite)) {
|
||||
throw new ApiCallError(ErrorMessage.GenericInProgress)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
import { AppleIAPConfirmResponse } from './../../Response/Subscription/AppleIAPConfirmResponse'
|
||||
import { AppleIAPConfirmRequestParams } from '../../Request'
|
||||
import { SubscriptionInviteAcceptResponse } from '../../Response/Subscription/SubscriptionInviteAcceptResponse'
|
||||
@@ -10,7 +8,7 @@ import { SubscriptionInviteResponse } from '../../Response/Subscription/Subscrip
|
||||
export interface SubscriptionApiServiceInterface {
|
||||
invite(inviteeEmail: string): Promise<SubscriptionInviteResponse>
|
||||
listInvites(): Promise<SubscriptionInviteListResponse>
|
||||
cancelInvite(inviteUuid: Uuid): Promise<SubscriptionInviteCancelResponse>
|
||||
acceptInvite(inviteUuid: Uuid): Promise<SubscriptionInviteAcceptResponse>
|
||||
cancelInvite(inviteUuid: string): Promise<SubscriptionInviteCancelResponse>
|
||||
acceptInvite(inviteUuid: string): Promise<SubscriptionInviteAcceptResponse>
|
||||
confirmAppleIAP(params: AppleIAPConfirmRequestParams): Promise<AppleIAPConfirmResponse>
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { UserRequestType, Uuid } from '@standardnotes/common'
|
||||
import { UserRequestType } from '@standardnotes/common'
|
||||
import { type RootKeyParamsInterface } from '@standardnotes/models'
|
||||
|
||||
import { UserDeletionResponse } from '../../Response/User/UserDeletionResponse'
|
||||
@@ -12,6 +12,6 @@ export interface UserApiServiceInterface {
|
||||
keyParams: RootKeyParamsInterface
|
||||
ephemeral: boolean
|
||||
}): Promise<UserRegistrationResponse>
|
||||
submitUserRequest(dto: { userUuid: Uuid; requestType: UserRequestType }): Promise<UserRequestResponse>
|
||||
submitUserRequest(dto: { userUuid: string; requestType: UserRequestType }): Promise<UserRequestResponse>
|
||||
deleteAccount(userUuid: string): Promise<UserDeletionResponse>
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Uuid, WorkspaceAccessLevel, WorkspaceType } from '@standardnotes/common'
|
||||
import { WorkspaceAccessLevel, WorkspaceType } from '@standardnotes/common'
|
||||
|
||||
import { ErrorMessage } from '../../Error/ErrorMessage'
|
||||
import { ApiCallError } from '../../Error/ApiCallError'
|
||||
@@ -96,7 +96,7 @@ export class WorkspaceApiService implements WorkspaceApiServiceInterface {
|
||||
|
||||
async inviteToWorkspace(dto: {
|
||||
inviteeEmail: string
|
||||
workspaceUuid: Uuid
|
||||
workspaceUuid: string
|
||||
accessLevel: WorkspaceAccessLevel
|
||||
}): Promise<WorkspaceInvitationResponse> {
|
||||
this.lockOperation(WorkspaceApiOperations.Inviting)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Uuid, WorkspaceAccessLevel, WorkspaceType } from '@standardnotes/common'
|
||||
import { WorkspaceAccessLevel, WorkspaceType } from '@standardnotes/common'
|
||||
|
||||
import { WorkspaceKeyshareInitiatingResponse } from '../../Response/Workspace/WorkspaceKeyshareInitiatingResponse'
|
||||
import { WorkspaceCreationResponse } from '../../Response/Workspace/WorkspaceCreationResponse'
|
||||
@@ -17,20 +17,20 @@ export interface WorkspaceApiServiceInterface {
|
||||
}): Promise<WorkspaceCreationResponse>
|
||||
inviteToWorkspace(dto: {
|
||||
inviteeEmail: string
|
||||
workspaceUuid: Uuid
|
||||
workspaceUuid: string
|
||||
accessLevel: WorkspaceAccessLevel
|
||||
}): Promise<WorkspaceInvitationResponse>
|
||||
acceptInvite(dto: {
|
||||
inviteUuid: Uuid
|
||||
userUuid: Uuid
|
||||
inviteUuid: string
|
||||
userUuid: string
|
||||
publicKey: string
|
||||
encryptedPrivateKey: string
|
||||
}): Promise<WorkspaceInvitationAcceptingResponse>
|
||||
listWorkspaces(): Promise<WorkspaceListResponse>
|
||||
listWorkspaceUsers(dto: { workspaceUuid: Uuid }): Promise<WorkspaceUserListResponse>
|
||||
listWorkspaceUsers(dto: { workspaceUuid: string }): Promise<WorkspaceUserListResponse>
|
||||
initiateKeyshare(dto: {
|
||||
workspaceUuid: Uuid
|
||||
userUuid: Uuid
|
||||
workspaceUuid: string
|
||||
userUuid: string
|
||||
encryptedWorkspaceKey: string
|
||||
}): Promise<WorkspaceKeyshareInitiatingResponse>
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { Uuid, WorkspaceAccessLevel, WorkspaceUserStatus } from '@standardnotes/common'
|
||||
import { WorkspaceAccessLevel, WorkspaceUserStatus } from '@standardnotes/common'
|
||||
|
||||
export type WorkspaceUser = {
|
||||
uuid: Uuid
|
||||
uuid: string
|
||||
accessLevel: WorkspaceAccessLevel
|
||||
userUuid: Uuid
|
||||
userUuid: string
|
||||
userDisplayName: string | null
|
||||
workspaceUuid: Uuid
|
||||
workspaceUuid: string
|
||||
encryptedWorkspaceKey: string | null
|
||||
publicKey: string | null
|
||||
encryptedPrivateKey: string | null
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { Role } from '@standardnotes/security'
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
export type HttpResponseMeta = {
|
||||
auth: {
|
||||
userUuid?: Uuid
|
||||
userUuid?: string
|
||||
roles?: Role[]
|
||||
}
|
||||
server: {
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
export type SubscriptionInviteAcceptRequestParams = {
|
||||
inviteUuid: Uuid
|
||||
inviteUuid: string
|
||||
[additionalParam: string]: unknown
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
import { ApiEndpointParam } from '../ApiEndpointParam'
|
||||
import { ApiVersion } from '../../Api/ApiVersion'
|
||||
|
||||
export type SubscriptionInviteCancelRequestParams = {
|
||||
[ApiEndpointParam.ApiVersion]: ApiVersion.v0
|
||||
inviteUuid: Uuid
|
||||
inviteUuid: string
|
||||
[additionalParam: string]: unknown
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
import { ApiEndpointParam } from '../ApiEndpointParam'
|
||||
import { ApiVersion } from '../../Api/ApiVersion'
|
||||
|
||||
export type SubscriptionInviteDeclineRequestParams = {
|
||||
[ApiEndpointParam.ApiVersion]: ApiVersion.v0
|
||||
inviteUuid: Uuid
|
||||
inviteUuid: string
|
||||
[additionalParam: string]: unknown
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
export type UserDeletionRequestParams = {
|
||||
userUuid: Uuid
|
||||
userUuid: string
|
||||
[additionalParam: string]: unknown
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { UserRequestType, Uuid } from '@standardnotes/common'
|
||||
import { UserRequestType } from '@standardnotes/common'
|
||||
|
||||
export type UserRequestRequestParams = {
|
||||
userUuid: Uuid
|
||||
userUuid: string
|
||||
requestType: UserRequestType
|
||||
[additionalParam: string]: unknown
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
export type WorkspaceInvitationAcceptingRequestParams = {
|
||||
inviteUuid: Uuid
|
||||
userUuid: Uuid
|
||||
inviteUuid: string
|
||||
userUuid: string
|
||||
publicKey: string
|
||||
encryptedPrivateKey: string
|
||||
[additionalParam: string]: unknown
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Uuid, WorkspaceAccessLevel } from '@standardnotes/common'
|
||||
import { WorkspaceAccessLevel } from '@standardnotes/common'
|
||||
|
||||
export type WorkspaceInvitationRequestParams = {
|
||||
workspaceUuid: Uuid
|
||||
workspaceUuid: string
|
||||
inviteeEmail: string
|
||||
accessLevel: WorkspaceAccessLevel
|
||||
[additionalParam: string]: unknown
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
export type WorkspaceKeyshareInitiatingRequestParams = {
|
||||
userUuid: Uuid
|
||||
workspaceUuid: Uuid
|
||||
userUuid: string
|
||||
workspaceUuid: string
|
||||
encryptedWorkspaceKey: string
|
||||
[additionalParam: string]: unknown
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
export type WorkspaceUserListRequestParams = {
|
||||
workspaceUuid: Uuid
|
||||
workspaceUuid: string
|
||||
[additionalParam: string]: unknown
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
export type SubscriptionInviteResponseBody =
|
||||
| {
|
||||
success: true
|
||||
sharedSubscriptionInvitationUuid: Uuid
|
||||
sharedSubscriptionInvitationUuid: string
|
||||
}
|
||||
| {
|
||||
success: false
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
import { KeyParamsData, SessionBody } from '@standardnotes/responses'
|
||||
|
||||
export type UserRegistrationResponseBody = {
|
||||
session: SessionBody
|
||||
key_params: KeyParamsData
|
||||
user: {
|
||||
uuid: Uuid
|
||||
uuid: string
|
||||
email: string
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
const SharingPaths = {
|
||||
invite: '/v1/subscription-invites',
|
||||
acceptInvite: (inviteUuid: Uuid) => `/v1/subscription-invites/${inviteUuid}/accept`,
|
||||
declineInvite: (inviteUuid: Uuid) => `/v1/subscription-invites/${inviteUuid}/decline`,
|
||||
cancelInvite: (inviteUuid: Uuid) => `/v1/subscription-invites/${inviteUuid}`,
|
||||
acceptInvite: (inviteUuid: string) => `/v1/subscription-invites/${inviteUuid}/accept`,
|
||||
declineInvite: (inviteUuid: string) => `/v1/subscription-invites/${inviteUuid}/decline`,
|
||||
cancelInvite: (inviteUuid: string) => `/v1/subscription-invites/${inviteUuid}`,
|
||||
listInvites: '/v1/subscription-invites',
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
const UserPaths = {
|
||||
register: '/v1/users',
|
||||
deleteAccount: (userUuid: Uuid) => `/v1/users/${userUuid}`,
|
||||
deleteAccount: (userUuid: string) => `/v1/users/${userUuid}`,
|
||||
}
|
||||
|
||||
export const Paths = {
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
const UserRequestPaths = {
|
||||
submitUserRequest: (userUuid: Uuid) => `/v1/users/${userUuid}/requests`,
|
||||
submitUserRequest: (userUuid: string) => `/v1/users/${userUuid}/requests`,
|
||||
}
|
||||
|
||||
export const Paths = {
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
const WorkspacePaths = {
|
||||
createWorkspace: '/v1/workspaces',
|
||||
listWorkspaces: '/v1/workspaces',
|
||||
listWorkspaceUsers: (uuid: Uuid) => `/v1/workspaces/${uuid}/users`,
|
||||
initiateKeyshare: (worksapceUuid: Uuid, userUuid: Uuid) =>
|
||||
listWorkspaceUsers: (uuid: string) => `/v1/workspaces/${uuid}/users`,
|
||||
initiateKeyshare: (worksapceUuid: string, userUuid: string) =>
|
||||
`/v1/workspaces/${worksapceUuid}/users/${userUuid}/keyshare`,
|
||||
inviteToWorkspace: (uuid: Uuid) => `/v1/workspaces/${uuid}/invites`,
|
||||
acceptInvite: (uuid: Uuid) => `/v1/invites/${uuid}/accept`,
|
||||
inviteToWorkspace: (uuid: string) => `/v1/workspaces/${uuid}/invites`,
|
||||
acceptInvite: (uuid: string) => `/v1/invites/${uuid}/accept`,
|
||||
}
|
||||
|
||||
export const Paths = {
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
"typescript": "*"
|
||||
},
|
||||
"dependencies": {
|
||||
"@standardnotes/common": "^1.45.0",
|
||||
"@standardnotes/common": "^1.46.3",
|
||||
"@standardnotes/models": "workspace:*",
|
||||
"@standardnotes/responses": "workspace:*",
|
||||
"@standardnotes/sncrypto-common": "workspace:*",
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
import { DecryptedPayloadInterface, EncryptedPayloadInterface, PayloadInterface } from '@standardnotes/models'
|
||||
import { EncryptionTypeSplit } from './EncryptionTypeSplit'
|
||||
import { KeyedDecryptionSplit } from './KeyedDecryptionSplit'
|
||||
@@ -36,7 +35,7 @@ export function CreateDecryptionSplitWithKeyLookup(
|
||||
return result
|
||||
}
|
||||
|
||||
export function FindPayloadInEncryptionSplit(uuid: Uuid, split: KeyedEncryptionSplit): DecryptedPayloadInterface {
|
||||
export function FindPayloadInEncryptionSplit(uuid: string, split: KeyedEncryptionSplit): DecryptedPayloadInterface {
|
||||
const inUsesItemsKey = split.usesItemsKey?.items.find((item: PayloadInterface) => item.uuid === uuid)
|
||||
if (inUsesItemsKey) {
|
||||
return inUsesItemsKey
|
||||
@@ -60,7 +59,7 @@ export function FindPayloadInEncryptionSplit(uuid: Uuid, split: KeyedEncryptionS
|
||||
throw Error('Cannot find payload in encryption split')
|
||||
}
|
||||
|
||||
export function FindPayloadInDecryptionSplit(uuid: Uuid, split: KeyedDecryptionSplit): EncryptedPayloadInterface {
|
||||
export function FindPayloadInDecryptionSplit(uuid: string, split: KeyedDecryptionSplit): EncryptedPayloadInterface {
|
||||
const inUsesItemsKey = split.usesItemsKey?.items.find((item: PayloadInterface) => item.uuid === uuid)
|
||||
if (inUsesItemsKey) {
|
||||
return inUsesItemsKey
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ProtocolVersion, Uuid } from '@standardnotes/common'
|
||||
import { ProtocolVersion } from '@standardnotes/common'
|
||||
|
||||
export type ItemAuthenticatedData = {
|
||||
u: Uuid
|
||||
u: string
|
||||
v: ProtocolVersion
|
||||
}
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@standardnotes/auth": "^3.19.4",
|
||||
"@standardnotes/common": "^1.45.0",
|
||||
"@standardnotes/common": "^1.46.3",
|
||||
"@standardnotes/domain-core": "^1.11.1",
|
||||
"@standardnotes/security": "^1.7.0",
|
||||
"reflect-metadata": "^0.1.13"
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ComponentPermission } from '../Component/ComponentPermission'
|
||||
import { ContentType, RoleName, SubscriptionName } from '@standardnotes/common'
|
||||
import { ContentType, SubscriptionName } from '@standardnotes/common'
|
||||
import { ComponentArea } from '../Component/ComponentArea'
|
||||
import { PermissionName } from '../Permission/PermissionName'
|
||||
import { FeatureIdentifier } from './FeatureIdentifier'
|
||||
@@ -9,11 +9,11 @@ import { ThemeDockIcon } from '../Component/ThemeDockIcon'
|
||||
|
||||
type RoleFields = {
|
||||
/** Server populated */
|
||||
role_name?: RoleName
|
||||
role_name?: string
|
||||
|
||||
/** Statically populated. Non-influencing; used as a reference by other static consumers (such as email service) */
|
||||
availableInSubscriptions: SubscriptionName[]
|
||||
availableInRoles?: RoleName[]
|
||||
availableInRoles?: string[]
|
||||
}
|
||||
|
||||
export type BaseFeatureDescription = RoleFields & {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { ClientFeatureDescription } from '../Feature/FeatureDescription'
|
||||
import { PermissionName } from '../Permission/PermissionName'
|
||||
import { FeatureIdentifier } from '../Feature/FeatureIdentifier'
|
||||
import { RoleName, SubscriptionName } from '@standardnotes/common'
|
||||
import { SubscriptionName } from '@standardnotes/common'
|
||||
import { RoleName } from '@standardnotes/domain-core'
|
||||
|
||||
export function clientFeatures(): ClientFeatureDescription[] {
|
||||
return [
|
||||
@@ -19,7 +20,7 @@ export function clientFeatures(): ClientFeatureDescription[] {
|
||||
permission_name: PermissionName.SuperEditor,
|
||||
description:
|
||||
'Type / to bring up the block selection menu, or @ to embed images or link other tags and notes. Type - then space to start a list, or [] then space to start a checklist. Drag and drop an image or file to embed it in your note.',
|
||||
availableInRoles: [RoleName.PlusUser, RoleName.ProUser],
|
||||
availableInRoles: [RoleName.NAMES.PlusUser, RoleName.NAMES.ProUser],
|
||||
},
|
||||
{
|
||||
availableInSubscriptions: [SubscriptionName.PlusPlan, SubscriptionName.ProPlan],
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
import { PermissionName } from './PermissionName'
|
||||
|
||||
export type Permission = {
|
||||
uuid: Uuid
|
||||
uuid: string
|
||||
name: PermissionName
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
"typescript": "*"
|
||||
},
|
||||
"dependencies": {
|
||||
"@standardnotes/common": "^1.45.0",
|
||||
"@standardnotes/common": "^1.46.3",
|
||||
"@standardnotes/files": "workspace:*",
|
||||
"@standardnotes/utils": "workspace:*",
|
||||
"@types/wicg-file-system-access": "^2020.9.5",
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
"typescript": "*"
|
||||
},
|
||||
"dependencies": {
|
||||
"@standardnotes/common": "^1.45.0",
|
||||
"@standardnotes/common": "^1.46.3",
|
||||
"@standardnotes/encryption": "workspace:*",
|
||||
"@standardnotes/models": "workspace:*",
|
||||
"@standardnotes/responses": "workspace:*",
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
import { removeFromArray } from '@standardnotes/utils'
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
import { EncryptedBytes } from '../Types/EncryptedBytes'
|
||||
|
||||
export class FileMemoryCache {
|
||||
private cache: Record<Uuid, EncryptedBytes> = {}
|
||||
private orderedQueue: Uuid[] = []
|
||||
private cache: Record<string, EncryptedBytes> = {}
|
||||
private orderedQueue: string[] = []
|
||||
|
||||
constructor(public readonly maxSize: number) {}
|
||||
|
||||
add(uuid: Uuid, data: EncryptedBytes): boolean {
|
||||
add(uuid: string, data: EncryptedBytes): boolean {
|
||||
if (data.encryptedBytes.length > this.maxSize) {
|
||||
return false
|
||||
}
|
||||
@@ -31,11 +30,11 @@ export class FileMemoryCache {
|
||||
.reduce((total, fileLength) => total + fileLength, 0)
|
||||
}
|
||||
|
||||
get(uuid: Uuid): EncryptedBytes | undefined {
|
||||
get(uuid: string): EncryptedBytes | undefined {
|
||||
return this.cache[uuid]
|
||||
}
|
||||
|
||||
remove(uuid: Uuid): void {
|
||||
remove(uuid: string): void {
|
||||
delete this.cache[uuid]
|
||||
|
||||
removeFromArray(this.orderedQueue, uuid)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
import { FileDownloadProgress } from '../Types/FileDownloadProgress'
|
||||
import { FileBackupRecord, FileBackupsMapping } from './FileBackupsMapping'
|
||||
|
||||
@@ -8,7 +7,7 @@ export type FileBackupReadChunkResponse = { chunk: Uint8Array; isLast: boolean;
|
||||
export interface FileBackupsDevice {
|
||||
getFilesBackupsMappingFile(): Promise<FileBackupsMapping>
|
||||
saveFilesBackupsFile(
|
||||
uuid: Uuid,
|
||||
uuid: string,
|
||||
metaFile: string,
|
||||
downloadRequest: {
|
||||
chunkSizes: number[]
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
import { FileBackupsConstantsV1 } from './FileBackupsConstantsV1'
|
||||
|
||||
export type FileBackupRecord = {
|
||||
@@ -12,5 +11,5 @@ export type FileBackupRecord = {
|
||||
|
||||
export interface FileBackupsMapping {
|
||||
version: typeof FileBackupsConstantsV1.Version
|
||||
files: Record<Uuid, FileBackupRecord>
|
||||
files: Record<string, FileBackupRecord>
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
"test": "jest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@standardnotes/common": "^1.45.0",
|
||||
"@standardnotes/common": "^1.46.3",
|
||||
"@standardnotes/features": "workspace:*",
|
||||
"@standardnotes/responses": "workspace:*",
|
||||
"@standardnotes/utils": "workspace:*",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ContentType, Uuid } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ComponentPermission } from '@standardnotes/features'
|
||||
|
||||
import { IncomingComponentItemPayload } from './IncomingComponentItemPayload'
|
||||
@@ -14,7 +14,7 @@ export type MessageData = Partial<{
|
||||
permissions?: ComponentPermission[]
|
||||
/** Related to the component-registered action */
|
||||
componentData?: Record<string, unknown>
|
||||
uuid?: Uuid
|
||||
uuid?: string
|
||||
environment?: string
|
||||
platform?: string
|
||||
activeThemeUrls?: string[]
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
import { AppData, DefaultAppDomain } from '../Item/Types/DefaultAppDomain'
|
||||
import { ContentReference } from '../Reference/ContentReference'
|
||||
import { AppDataField } from '../Item/Types/AppDataField'
|
||||
@@ -8,7 +7,7 @@ export interface SpecializedContent {}
|
||||
|
||||
export interface ItemContent {
|
||||
references: ContentReference[]
|
||||
conflict_of?: Uuid
|
||||
conflict_of?: string
|
||||
protected?: boolean
|
||||
trashed?: boolean
|
||||
pinned?: boolean
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
import { ItemContent } from '../Content/ItemContent'
|
||||
import { ContextPayload } from './ContextPayload'
|
||||
|
||||
@@ -6,7 +5,7 @@ export interface BackupFileDecryptedContextualPayload<C extends ItemContent = It
|
||||
content: C
|
||||
created_at_timestamp: number
|
||||
created_at: Date
|
||||
duplicate_of?: Uuid
|
||||
duplicate_of?: string
|
||||
updated_at: Date
|
||||
updated_at_timestamp: number
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
import { ContextPayload } from './ContextPayload'
|
||||
|
||||
export interface BackupFileEncryptedContextualPayload extends ContextPayload {
|
||||
@@ -6,7 +5,7 @@ export interface BackupFileEncryptedContextualPayload extends ContextPayload {
|
||||
content: string
|
||||
created_at_timestamp: number
|
||||
created_at: Date
|
||||
duplicate_of?: Uuid
|
||||
duplicate_of?: string
|
||||
enc_item_key: string
|
||||
items_key_id: string | undefined
|
||||
updated_at: Date
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
import { ContextPayload } from './ContextPayload'
|
||||
import { ItemContent } from '../Content/ItemContent'
|
||||
import { DecryptedPayloadInterface, DeletedPayloadInterface, EncryptedPayloadInterface } from '../Payload'
|
||||
@@ -19,7 +18,7 @@ export interface LocalStorageEncryptedContextualPayload extends ContextPayload {
|
||||
created_at_timestamp: number
|
||||
created_at: Date
|
||||
dirty: boolean
|
||||
duplicate_of: Uuid | undefined
|
||||
duplicate_of: string | undefined
|
||||
enc_item_key: string
|
||||
errorDecrypting: boolean
|
||||
items_key_id: string | undefined
|
||||
@@ -34,7 +33,7 @@ export interface LocalStorageDecryptedContextualPayload<C extends ItemContent =
|
||||
created_at: Date
|
||||
deleted: false
|
||||
dirty: boolean
|
||||
duplicate_of?: Uuid
|
||||
duplicate_of?: string
|
||||
updated_at_timestamp: number
|
||||
updated_at: Date
|
||||
}
|
||||
@@ -45,7 +44,7 @@ export interface LocalStorageDeletedContextualPayload extends ContextPayload {
|
||||
created_at: Date
|
||||
deleted: true
|
||||
dirty: true
|
||||
duplicate_of?: Uuid
|
||||
duplicate_of?: string
|
||||
updated_at_timestamp: number
|
||||
updated_at: Date
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
import { ItemContent } from '../Content/ItemContent'
|
||||
import { DecryptedPayloadInterface, DeletedPayloadInterface, isDecryptedPayload } from '../Payload'
|
||||
import { ContextPayload } from './ContextPayload'
|
||||
@@ -7,7 +6,7 @@ export interface OfflineSyncPushContextualPayload extends ContextPayload {
|
||||
content: ItemContent | undefined
|
||||
created_at_timestamp: number
|
||||
created_at: Date
|
||||
duplicate_of?: Uuid
|
||||
duplicate_of?: string
|
||||
updated_at_timestamp: number
|
||||
updated_at: Date
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
import { DeletedPayloadInterface, EncryptedPayloadInterface } from '../Payload'
|
||||
import { ContextPayload } from './ContextPayload'
|
||||
|
||||
@@ -7,7 +6,7 @@ export interface ServerSyncPushContextualPayload extends ContextPayload {
|
||||
content: string | undefined
|
||||
created_at_timestamp: number
|
||||
created_at: Date
|
||||
duplicate_of?: Uuid
|
||||
duplicate_of?: string
|
||||
enc_item_key?: string
|
||||
items_key_id?: string
|
||||
updated_at_timestamp: number
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { dateToLocalizedString, useBoolean } from '@standardnotes/utils'
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
import { DecryptedTransferPayload } from './../../TransferPayload/Interfaces/DecryptedTransferPayload'
|
||||
import { AppDataField } from '../Types/AppDataField'
|
||||
import { ComponentDataDomain, DefaultAppDomain } from '../Types/DefaultAppDomain'
|
||||
@@ -15,7 +14,7 @@ export class DecryptedItem<C extends ItemContent = ItemContent>
|
||||
extends GenericItem<DecryptedPayloadInterface<C>>
|
||||
implements DecryptedItemInterface<C>
|
||||
{
|
||||
public readonly conflictOf?: Uuid
|
||||
public readonly conflictOf?: string
|
||||
public readonly protected: boolean = false
|
||||
public readonly trashed: boolean = false
|
||||
public readonly pinned: boolean = false
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ContentType, Uuid } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { dateToLocalizedString, deepFreeze } from '@standardnotes/utils'
|
||||
import { TransferPayload } from './../../TransferPayload/Interfaces/TransferPayload'
|
||||
import { ItemContentsDiffer } from '../../../Utilities/Item/ItemContentsDiffer'
|
||||
@@ -13,7 +13,7 @@ import { isDecryptedItem, isDeletedItem, isEncryptedErroredItem } from '../Inter
|
||||
|
||||
export abstract class GenericItem<P extends PayloadInterface = PayloadInterface> implements ItemInterface<P> {
|
||||
payload: P
|
||||
public readonly duplicateOf?: Uuid
|
||||
public readonly duplicateOf?: string
|
||||
public readonly createdAtString?: string
|
||||
public updatedAtString?: string
|
||||
public userModifiedDate: Date
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
import { AppDataField } from '../Types/AppDataField'
|
||||
import { ComponentDataDomain, DefaultAppDomain } from '../Types/DefaultAppDomain'
|
||||
import { ContentReference } from '../../Reference/ContentReference'
|
||||
@@ -15,8 +14,8 @@ export interface DecryptedItemInterface<C extends ItemContent = ItemContent>
|
||||
SortableItem,
|
||||
SearchableItem {
|
||||
readonly content: C
|
||||
readonly conflictOf?: Uuid
|
||||
readonly duplicateOf?: Uuid
|
||||
readonly conflictOf?: string
|
||||
readonly duplicateOf?: string
|
||||
readonly protected: boolean
|
||||
readonly trashed: boolean
|
||||
readonly pinned: boolean
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Uuid, ContentType } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { TransferPayload } from './../../TransferPayload/Interfaces/TransferPayload'
|
||||
import { PayloadInterface } from '../../Payload/Interfaces/PayloadInterface'
|
||||
import { PredicateInterface } from '../../../Runtime/Predicate/Interface'
|
||||
@@ -8,12 +8,12 @@ import { SingletonStrategy } from '../Types/SingletonStrategy'
|
||||
|
||||
export interface ItemInterface<P extends PayloadInterface = PayloadInterface> {
|
||||
payload: P
|
||||
readonly conflictOf?: Uuid
|
||||
readonly duplicateOf?: Uuid
|
||||
readonly conflictOf?: string
|
||||
readonly duplicateOf?: string
|
||||
readonly createdAtString?: string
|
||||
readonly updatedAtString?: string
|
||||
|
||||
uuid: Uuid
|
||||
uuid: string
|
||||
|
||||
content_type: ContentType
|
||||
created_at: Date
|
||||
|
||||
@@ -2,7 +2,6 @@ import { DecryptedItemInterface } from './../Interfaces/DecryptedItem'
|
||||
import { Copy } from '@standardnotes/utils'
|
||||
import { MutationType } from '../Types/MutationType'
|
||||
import { PrefKey } from '../../../Syncable/UserPrefs/PrefKey'
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
import { ItemContent } from '../../Content/ItemContent'
|
||||
import { AppDataField } from '../Types/AppDataField'
|
||||
import { DefaultAppDomain, DomainDataValueType, ItemDomainKey } from '../Types/DefaultAppDomain'
|
||||
@@ -66,7 +65,7 @@ export class DecryptedItemMutator<C extends ItemContent = ItemContent> extends I
|
||||
this.setAppDataItem(AppDataField.UserModifiedDate, date)
|
||||
}
|
||||
|
||||
public set conflictOf(conflictOf: Uuid | undefined) {
|
||||
public set conflictOf(conflictOf: string | undefined) {
|
||||
this.mutableContent.conflict_of = conflictOf
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
import { MutationType } from '../Types/MutationType'
|
||||
|
||||
import { ItemMutator } from './ItemMutator'
|
||||
|
||||
export type TransactionalMutation = {
|
||||
itemUuid: Uuid
|
||||
itemUuid: string
|
||||
mutate: (mutator: ItemMutator) => void
|
||||
mutationType?: MutationType
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
import { Copy } from '@standardnotes/utils'
|
||||
import { SyncResolvedParams, SyncResolvedPayload } from '../../../Runtime/Deltas/Utilities/SyncResolvedPayload'
|
||||
import { FillItemContent, ItemContent } from '../../Content/ItemContent'
|
||||
@@ -29,7 +28,7 @@ export class DecryptedPayload<
|
||||
return this.content.references || []
|
||||
}
|
||||
|
||||
public getReference(uuid: Uuid): ContentReference {
|
||||
public getReference(uuid: string): ContentReference {
|
||||
const result = this.references.find((ref) => ref.uuid === uuid)
|
||||
|
||||
if (!result) {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
import { DecryptedTransferPayload } from './../../TransferPayload/Interfaces/DecryptedTransferPayload'
|
||||
import { ItemContent } from '../../Content/ItemContent'
|
||||
import { ContentReference } from '../../Reference/ContentReference'
|
||||
@@ -11,5 +10,5 @@ export interface DecryptedPayloadInterface<C extends ItemContent = ItemContent>
|
||||
|
||||
ejected(): DecryptedTransferPayload<C>
|
||||
get references(): ContentReference[]
|
||||
getReference(uuid: Uuid): ContentReference
|
||||
getReference(uuid: string): ContentReference
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { SyncResolvedParams, SyncResolvedPayload } from './../../../Runtime/Deltas/Utilities/SyncResolvedPayload'
|
||||
import { ContentType, Uuid } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ItemContent } from '../../Content/ItemContent'
|
||||
import { TransferPayload } from '../../TransferPayload/Interfaces/TransferPayload'
|
||||
import { PayloadSource } from '../Types/PayloadSource'
|
||||
|
||||
export interface PayloadInterface<T extends TransferPayload = TransferPayload, C extends ItemContent = ItemContent> {
|
||||
readonly source: PayloadSource
|
||||
readonly uuid: Uuid
|
||||
readonly uuid: string
|
||||
readonly content_type: ContentType
|
||||
content: C | string | undefined
|
||||
deleted: boolean
|
||||
@@ -26,7 +26,7 @@ export interface PayloadInterface<T extends TransferPayload = TransferPayload, C
|
||||
readonly lastSyncBegan?: Date
|
||||
readonly lastSyncEnd?: Date
|
||||
|
||||
readonly duplicate_of?: Uuid
|
||||
readonly duplicate_of?: string
|
||||
|
||||
/**
|
||||
* "Ejected" means a payload for
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { ContentType, Uuid } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ItemContent } from '../../Content/ItemContent'
|
||||
|
||||
export interface TransferPayload<C extends ItemContent = ItemContent> {
|
||||
uuid: Uuid
|
||||
uuid: string
|
||||
content_type: ContentType
|
||||
content: C | string | undefined
|
||||
deleted?: boolean
|
||||
@@ -19,5 +19,5 @@ export interface TransferPayload<C extends ItemContent = ItemContent> {
|
||||
lastSyncBegan?: Date
|
||||
lastSyncEnd?: Date
|
||||
|
||||
duplicate_of?: Uuid
|
||||
duplicate_of?: string
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { extendArray, isObject, isString, UuidMap } from '@standardnotes/utils'
|
||||
import { ContentType, Uuid } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { remove } from 'lodash'
|
||||
import { ItemContent } from '../../Abstract/Content/ItemContent'
|
||||
import { ContentReference } from '../../Abstract/Item'
|
||||
|
||||
export interface CollectionElement {
|
||||
uuid: Uuid
|
||||
uuid: string
|
||||
content_type: ContentType
|
||||
dirty?: boolean
|
||||
deleted?: boolean
|
||||
@@ -32,17 +32,17 @@ export abstract class Collection<
|
||||
Encrypted extends EncryptedCollectionElement,
|
||||
Deleted extends DeletedCollectionElement,
|
||||
> {
|
||||
readonly map: Partial<Record<Uuid, Element>> = {}
|
||||
readonly map: Partial<Record<string, Element>> = {}
|
||||
readonly typedMap: Partial<Record<ContentType, Element[]>> = {}
|
||||
|
||||
/** An array of uuids of items that are dirty */
|
||||
dirtyIndex: Set<Uuid> = new Set()
|
||||
dirtyIndex: Set<string> = new Set()
|
||||
|
||||
/** An array of uuids of items that are not marked as deleted */
|
||||
nondeletedIndex: Set<Uuid> = new Set()
|
||||
nondeletedIndex: Set<string> = new Set()
|
||||
|
||||
/** An array of uuids of items that are errorDecrypting or waitingForKey */
|
||||
invalidsIndex: Set<Uuid> = new Set()
|
||||
invalidsIndex: Set<string> = new Set()
|
||||
|
||||
readonly referenceMap: UuidMap
|
||||
|
||||
@@ -73,7 +73,7 @@ export abstract class Collection<
|
||||
|
||||
constructor(
|
||||
copy = false,
|
||||
mapCopy?: Partial<Record<Uuid, Element>>,
|
||||
mapCopy?: Partial<Record<string, Element>>,
|
||||
typedMapCopy?: Partial<Record<ContentType, Element[]>>,
|
||||
referenceMapCopy?: UuidMap,
|
||||
conflictMapCopy?: UuidMap,
|
||||
@@ -89,7 +89,7 @@ export abstract class Collection<
|
||||
}
|
||||
}
|
||||
|
||||
public uuids(): Uuid[] {
|
||||
public uuids(): string[] {
|
||||
return Object.keys(this.map)
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ export abstract class Collection<
|
||||
return this.typedMap[contentType]?.slice() || []
|
||||
}
|
||||
} else {
|
||||
return Object.keys(this.map).map((uuid: Uuid) => {
|
||||
return Object.keys(this.map).map((uuid: string) => {
|
||||
return this.map[uuid]
|
||||
}) as Element[]
|
||||
}
|
||||
@@ -129,7 +129,7 @@ export abstract class Collection<
|
||||
return this.findAll(uuids)
|
||||
}
|
||||
|
||||
public findAll(uuids: Uuid[]): Element[] {
|
||||
public findAll(uuids: string[]): Element[] {
|
||||
const results: Element[] = []
|
||||
|
||||
for (const id of uuids) {
|
||||
@@ -142,11 +142,11 @@ export abstract class Collection<
|
||||
return results
|
||||
}
|
||||
|
||||
public find(uuid: Uuid): Element | undefined {
|
||||
public find(uuid: string): Element | undefined {
|
||||
return this.map[uuid]
|
||||
}
|
||||
|
||||
public has(uuid: Uuid): boolean {
|
||||
public has(uuid: string): boolean {
|
||||
return this.find(uuid) != undefined
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ export abstract class Collection<
|
||||
* If an item is not found, an `undefined` element
|
||||
* will be inserted into the array.
|
||||
*/
|
||||
public findAllIncludingBlanks<E extends Element>(uuids: Uuid[]): (E | Deleted | undefined)[] {
|
||||
public findAllIncludingBlanks<E extends Element>(uuids: string[]): (E | Deleted | undefined)[] {
|
||||
const results: (E | Deleted | undefined)[] = []
|
||||
|
||||
for (const id of uuids) {
|
||||
@@ -219,11 +219,11 @@ export abstract class Collection<
|
||||
}
|
||||
}
|
||||
|
||||
public uuidReferencesForUuid(uuid: Uuid): Uuid[] {
|
||||
public uuidReferencesForUuid(uuid: string): string[] {
|
||||
return this.referenceMap.getDirectRelationships(uuid)
|
||||
}
|
||||
|
||||
public uuidsThatReferenceUuid(uuid: Uuid): Uuid[] {
|
||||
public uuidsThatReferenceUuid(uuid: string): string[] {
|
||||
return this.referenceMap.getInverseRelationships(uuid)
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ export abstract class Collection<
|
||||
return this.findAll(uuids)
|
||||
}
|
||||
|
||||
public conflictsOf(uuid: Uuid): Element[] {
|
||||
public conflictsOf(uuid: string): Element[] {
|
||||
const uuids = this.conflictMap.getDirectRelationships(uuid)
|
||||
return this.findAll(uuids)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Uuid, ContentType } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
|
||||
export interface SortableItem {
|
||||
uuid: Uuid
|
||||
uuid: string
|
||||
content_type: ContentType
|
||||
created_at: Date
|
||||
userModifiedDate: Date
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ItemContent } from './../../../Abstract/Content/ItemContent'
|
||||
import { EncryptedItemInterface } from './../../../Abstract/Item/Interfaces/EncryptedItem'
|
||||
import { ContentType, Uuid } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { SNIndex } from '../../Index/SNIndex'
|
||||
import { isDecryptedItem } from '../../../Abstract/Item/Interfaces/TypeCheck'
|
||||
import { DecryptedItemInterface } from '../../../Abstract/Item/Interfaces/DecryptedItem'
|
||||
@@ -24,7 +24,7 @@ export class ItemCollection
|
||||
this.discard(delta.discarded)
|
||||
}
|
||||
|
||||
public findDecrypted<T extends DecryptedItemInterface = DecryptedItemInterface>(uuid: Uuid): T | undefined {
|
||||
public findDecrypted<T extends DecryptedItemInterface = DecryptedItemInterface>(uuid: string): T | undefined {
|
||||
const result = this.find(uuid)
|
||||
|
||||
if (!result) {
|
||||
@@ -34,12 +34,12 @@ export class ItemCollection
|
||||
return isDecryptedItem(result) ? (result as T) : undefined
|
||||
}
|
||||
|
||||
public findAllDecrypted<T extends DecryptedItemInterface = DecryptedItemInterface>(uuids: Uuid[]): T[] {
|
||||
public findAllDecrypted<T extends DecryptedItemInterface = DecryptedItemInterface>(uuids: string[]): T[] {
|
||||
return this.findAll(uuids).filter(isDecryptedItem) as T[]
|
||||
}
|
||||
|
||||
public findAllDecryptedWithBlanks<C extends ItemContent = ItemContent>(
|
||||
uuids: Uuid[],
|
||||
uuids: string[],
|
||||
): (DecryptedItemInterface<C> | undefined)[] {
|
||||
const results = this.findAllIncludingBlanks(uuids)
|
||||
const mapped = results.map((i) => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { removeFromArray } from '@standardnotes/utils'
|
||||
import { ContentType, Uuid } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { isTag, SNTag } from '../../../Syncable/Tag/Tag'
|
||||
import { SNIndex } from '../../Index/SNIndex'
|
||||
import { ItemCollection } from './ItemCollection'
|
||||
@@ -7,12 +7,12 @@ import { ItemDelta } from '../../Index/ItemDelta'
|
||||
import { isDecryptedItem, ItemInterface } from '../../../Abstract/Item'
|
||||
|
||||
type AllNotesUuidSignifier = undefined
|
||||
export type TagItemCountChangeObserver = (tagUuid: Uuid | AllNotesUuidSignifier) => void
|
||||
export type TagItemCountChangeObserver = (tagUuid: string | AllNotesUuidSignifier) => void
|
||||
|
||||
export class TagItemsIndex implements SNIndex {
|
||||
private tagToItemsMap: Partial<Record<Uuid, Set<Uuid>>> = {}
|
||||
private allCountableItems = new Set<Uuid>()
|
||||
private countableItemsByType = new Map<ContentType, Set<Uuid>>()
|
||||
private tagToItemsMap: Partial<Record<string, Set<string>>> = {}
|
||||
private allCountableItems = new Set<string>()
|
||||
private countableItemsByType = new Map<ContentType, Set<string>>()
|
||||
|
||||
constructor(private collection: ItemCollection, public observers: TagItemCountChangeObserver[] = []) {}
|
||||
|
||||
@@ -32,7 +32,7 @@ export class TagItemsIndex implements SNIndex {
|
||||
}
|
||||
}
|
||||
|
||||
private notifyObservers(tagUuid: Uuid | undefined) {
|
||||
private notifyObservers(tagUuid: string | undefined) {
|
||||
for (const observer of this.observers) {
|
||||
observer(tagUuid)
|
||||
}
|
||||
@@ -119,7 +119,7 @@ export class TagItemsIndex implements SNIndex {
|
||||
}
|
||||
}
|
||||
|
||||
private setForTag(uuid: Uuid): Set<Uuid> {
|
||||
private setForTag(uuid: string): Set<string> {
|
||||
let set = this.tagToItemsMap[uuid]
|
||||
if (!set) {
|
||||
set = new Set()
|
||||
|
||||
@@ -2,7 +2,7 @@ import { ImmutablePayloadCollection } from './../Collection/Payload/ImmutablePay
|
||||
import { ConflictDelta } from './Conflict'
|
||||
import { isErrorDecryptingPayload, isDecryptedPayload } from '../../Abstract/Payload/Interfaces/TypeCheck'
|
||||
import { FullyFormedPayloadInterface, PayloadEmitSource } from '../../Abstract/Payload'
|
||||
import { ContentType, Uuid } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { HistoryMap } from '../History'
|
||||
import { ServerSyncPushContextualPayload } from '../../Abstract/Contextual/ServerSyncPush'
|
||||
import { payloadByFinalizingSyncState } from './Utilities/ApplyDirtyState'
|
||||
@@ -18,7 +18,7 @@ export class DeltaRemoteRetrieved implements SyncDeltaInterface {
|
||||
readonly historyMap: HistoryMap,
|
||||
) {}
|
||||
|
||||
private isUuidOfPayloadCurrentlySavingOrSaved(uuid: Uuid): boolean {
|
||||
private isUuidOfPayloadCurrentlySavingOrSaved(uuid: string): boolean {
|
||||
return this.itemsSavedOrSaving.find((i) => i.uuid === uuid) != undefined
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
import { DecryptedItemInterface } from '../../Abstract/Item'
|
||||
import { SortableItem } from '../Collection/CollectionSort'
|
||||
import { ItemCollection } from '../Collection/Item/ItemCollection'
|
||||
|
||||
export type DisplayControllerCustomFilter = (element: DisplayItem) => boolean
|
||||
export type UuidToSortedPositionMap = Record<Uuid, number>
|
||||
export type UuidToSortedPositionMap = Record<string, number>
|
||||
export type DisplayItem = SortableItem & DecryptedItemInterface
|
||||
|
||||
export interface ReadonlyItemCollection {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
import { HistoryEntry } from './HistoryEntry'
|
||||
|
||||
export type HistoryMap = Record<Uuid, HistoryEntry[]>
|
||||
export type HistoryMap = Record<string, HistoryEntry[]>
|
||||
|
||||
export const historyMapFunctions = {
|
||||
getNewestRevision: (history: HistoryEntry[]): HistoryEntry | undefined => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { isValidUrl } from '@standardnotes/utils'
|
||||
import { ContentType, Uuid } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import {
|
||||
FeatureIdentifier,
|
||||
ThirdPartyFeatureDescription,
|
||||
@@ -159,11 +159,11 @@ export class SNComponent extends DecryptedItem<ComponentContent> implements Comp
|
||||
return SNComponent.associativeAreas().includes(this.area)
|
||||
}
|
||||
|
||||
public isExplicitlyEnabledForItem(uuid: Uuid): boolean {
|
||||
public isExplicitlyEnabledForItem(uuid: string): boolean {
|
||||
return this.associatedItemIds.indexOf(uuid) !== -1
|
||||
}
|
||||
|
||||
public isExplicitlyDisabledForItem(uuid: Uuid): boolean {
|
||||
public isExplicitlyDisabledForItem(uuid: string): boolean {
|
||||
return this.disassociatedItemIds.indexOf(uuid) !== -1
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { ComponentArea, ComponentPermission } from '@standardnotes/features'
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
import { ItemContent } from '../../Abstract/Content/ItemContent'
|
||||
import { ComponentPackageInfo } from './PackageInfo'
|
||||
|
||||
@@ -30,7 +29,7 @@ export interface ComponentInterface {
|
||||
legacy_url?: string
|
||||
isMobileDefault: boolean
|
||||
isDeprecated: boolean
|
||||
isExplicitlyEnabledForItem(uuid: Uuid): boolean
|
||||
isExplicitlyEnabledForItem(uuid: string): boolean
|
||||
}
|
||||
|
||||
export type ComponentContent = ComponentInterface & ItemContent
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { addIfUnique, removeFromArray } from '@standardnotes/utils'
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
import { ComponentPermission, FeatureDescription } from '@standardnotes/features'
|
||||
import { AppDataField } from '../../Abstract/Item/Types/AppDataField'
|
||||
import { ComponentContent } from './ComponentContent'
|
||||
@@ -46,23 +45,23 @@ export class ComponentMutator extends DecryptedItemMutator<ComponentContent> {
|
||||
this.mutableContent.offlineOnly = offlineOnly
|
||||
}
|
||||
|
||||
public associateWithItem(uuid: Uuid): void {
|
||||
public associateWithItem(uuid: string): void {
|
||||
const associated = this.mutableContent.associatedItemIds || []
|
||||
addIfUnique(associated, uuid)
|
||||
this.mutableContent.associatedItemIds = associated
|
||||
}
|
||||
|
||||
public disassociateWithItem(uuid: Uuid): void {
|
||||
public disassociateWithItem(uuid: string): void {
|
||||
const disassociated = this.mutableContent.disassociatedItemIds || []
|
||||
addIfUnique(disassociated, uuid)
|
||||
this.mutableContent.disassociatedItemIds = disassociated
|
||||
}
|
||||
|
||||
public removeAssociatedItemId(uuid: Uuid): void {
|
||||
public removeAssociatedItemId(uuid: string): void {
|
||||
removeFromArray(this.mutableContent.associatedItemIds || [], uuid)
|
||||
}
|
||||
|
||||
public removeDisassociatedItemId(uuid: Uuid): void {
|
||||
public removeDisassociatedItemId(uuid: string): void {
|
||||
removeFromArray(this.mutableContent.disassociatedItemIds || [], uuid)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { VectorIconNameOrEmoji, IconType } from './../../Utilities/Icon/IconType'
|
||||
import { ContentType, Uuid } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { DecryptedItem } from '../../Abstract/Item/Implementations/DecryptedItem'
|
||||
import { ItemInterface } from '../../Abstract/Item/Interfaces/ItemInterface'
|
||||
import { ContentReference } from '../../Abstract/Reference/ContentReference'
|
||||
@@ -41,7 +41,7 @@ export class SNTag extends DecryptedItem<TagContent> implements TagContentSpecia
|
||||
return this.noteReferences.length
|
||||
}
|
||||
|
||||
public get parentId(): Uuid | undefined {
|
||||
public get parentId(): string | undefined {
|
||||
const reference = this.references.find(isTagToParentTagReference)
|
||||
return reference?.uuid
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
import { ItemInterface } from '../../Abstract/Item/Interfaces/ItemInterface'
|
||||
|
||||
export function FindItem<I extends ItemInterface = ItemInterface>(items: I[], uuid: Uuid): I | undefined {
|
||||
export function FindItem<I extends ItemInterface = ItemInterface>(items: I[], uuid: string): I | undefined {
|
||||
return items.find((item) => item.uuid === uuid)
|
||||
}
|
||||
|
||||
export function SureFindItem<I extends ItemInterface = ItemInterface>(items: I[], uuid: Uuid): I {
|
||||
export function SureFindItem<I extends ItemInterface = ItemInterface>(items: I[], uuid: string): I {
|
||||
return FindItem(items, uuid) as I
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
import { PayloadInterface } from '../../Abstract/Payload/Interfaces/PayloadInterface'
|
||||
|
||||
export function FindPayload<P extends PayloadInterface = PayloadInterface>(payloads: P[], uuid: Uuid): P | undefined {
|
||||
export function FindPayload<P extends PayloadInterface = PayloadInterface>(payloads: P[], uuid: string): P | undefined {
|
||||
return payloads.find((payload) => payload.uuid === uuid)
|
||||
}
|
||||
|
||||
export function SureFindPayload<P extends PayloadInterface = PayloadInterface>(payloads: P[], uuid: Uuid): P {
|
||||
export function SureFindPayload<P extends PayloadInterface = PayloadInterface>(payloads: P[], uuid: string): P {
|
||||
return FindPayload(payloads, uuid) as P
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
import { remove } from 'lodash'
|
||||
import { ImmutablePayloadCollection } from '../../Runtime/Collection/Payload/ImmutablePayloadCollection'
|
||||
import { ContentReference } from '../../Abstract/Reference/ContentReference'
|
||||
@@ -12,7 +11,7 @@ export function PayloadsByUpdatingReferencingPayloadReferences(
|
||||
payload: DecryptedPayloadInterface,
|
||||
baseCollection: ImmutablePayloadCollection<FullyFormedPayloadInterface>,
|
||||
add: FullyFormedPayloadInterface[] = [],
|
||||
removeIds: Uuid[] = [],
|
||||
removeIds: string[] = [],
|
||||
): SyncResolvedPayload[] {
|
||||
const referencingPayloads = baseCollection.elementsReferencingElement(payload).filter(isDecryptedPayload)
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
"typescript": "*"
|
||||
},
|
||||
"dependencies": {
|
||||
"@standardnotes/common": "^1.45.0",
|
||||
"@standardnotes/common": "^1.46.3",
|
||||
"@standardnotes/features": "workspace:*",
|
||||
"@standardnotes/security": "^1.7.0",
|
||||
"reflect-metadata": "^0.1.13"
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { Role } from '@standardnotes/security'
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
export type ResponseMeta = {
|
||||
auth: {
|
||||
userUuid?: Uuid
|
||||
userUuid?: string
|
||||
roles?: Role[]
|
||||
}
|
||||
server: {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { MicrosecondsTimestamp, Uuid } from '@standardnotes/common'
|
||||
import { MicrosecondsTimestamp } from '@standardnotes/common'
|
||||
|
||||
export type IntegrityPayload = {
|
||||
uuid: Uuid
|
||||
uuid: string
|
||||
updated_at_timestamp: MicrosecondsTimestamp
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ContentType, Uuid } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
|
||||
export interface ServerItemResponse {
|
||||
content_type: ContentType
|
||||
@@ -6,7 +6,7 @@ export interface ServerItemResponse {
|
||||
created_at_timestamp: number
|
||||
created_at: Date
|
||||
deleted: boolean
|
||||
duplicate_of?: Uuid
|
||||
duplicate_of?: string
|
||||
enc_item_key: string
|
||||
items_key_id?: string
|
||||
updated_at_timestamp: number
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
"dependencies": {
|
||||
"@standardnotes/api": "workspace:^",
|
||||
"@standardnotes/auth": "^3.19.4",
|
||||
"@standardnotes/common": "^1.45.0",
|
||||
"@standardnotes/domain-core": "^1.11.0",
|
||||
"@standardnotes/common": "^1.46.3",
|
||||
"@standardnotes/domain-core": "^1.11.1",
|
||||
"@standardnotes/encryption": "workspace:^",
|
||||
"@standardnotes/files": "workspace:^",
|
||||
"@standardnotes/models": "workspace:^",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Either, Uuid } from '@standardnotes/common'
|
||||
import { Either } from '@standardnotes/common'
|
||||
import { Role } from '@standardnotes/auth'
|
||||
import { FilesApiInterface } from '@standardnotes/files'
|
||||
import { Session } from '@standardnotes/domain-core'
|
||||
@@ -13,7 +13,7 @@ export enum ApiServiceEvent {
|
||||
}
|
||||
|
||||
export type MetaReceivedData = {
|
||||
userUuid: Uuid
|
||||
userUuid: string
|
||||
userRoles: Role[]
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ContentType, Uuid } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { EncryptionProviderInterface } from '@standardnotes/encryption'
|
||||
import { PayloadEmitSource, FileItem, CreateEncryptedBackupFileContextPayload } from '@standardnotes/models'
|
||||
import { ClientDisplayableError } from '@standardnotes/responses'
|
||||
@@ -20,7 +20,7 @@ import { log, LoggingDomain } from '../Logging'
|
||||
|
||||
export class FilesBackupService extends AbstractService implements BackupServiceInterface {
|
||||
private itemsObserverDisposer: () => void
|
||||
private pendingFiles = new Set<Uuid>()
|
||||
private pendingFiles = new Set<string>()
|
||||
private mappingCache?: FileBackupsMapping['files']
|
||||
|
||||
constructor(
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
import { ComponentArea, FeatureIdentifier } from '@standardnotes/features'
|
||||
import { ActionObserver, PermissionDialog, SNComponent, SNNote } from '@standardnotes/models'
|
||||
|
||||
@@ -15,7 +14,7 @@ export interface ComponentManagerInterface {
|
||||
destroyComponentViewer(viewer: ComponentViewerInterface): void
|
||||
createComponentViewer(
|
||||
component: SNComponent,
|
||||
contextItem?: Uuid,
|
||||
contextItem?: string,
|
||||
actionObserver?: ActionObserver,
|
||||
urlOverride?: string,
|
||||
): ComponentViewerInterface
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { DatabaseItemMetadata } from './DatabaseItemMetadata'
|
||||
import { DatabaseLoadOptions } from './DatabaseLoadOptions'
|
||||
import { ContentType, Uuid } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
|
||||
/**
|
||||
* Sorts payloads according by most recently modified first, according to the priority,
|
||||
@@ -47,7 +47,7 @@ function SortPayloadsByRecentAndContentPriority<T extends DatabaseItemMetadata =
|
||||
*/
|
||||
function SortPayloadsByRecentAndUuidPriority<T extends DatabaseItemMetadata = DatabaseItemMetadata>(
|
||||
payloads: T[],
|
||||
uuidPriorityList: Uuid[],
|
||||
uuidPriorityList: string[],
|
||||
): T[] {
|
||||
return payloads.sort((a, b) => {
|
||||
const dateResult = new Date(b.updated_at).getTime() - new Date(a.updated_at).getTime()
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { FeatureDescription, FeatureIdentifier } from '@standardnotes/features'
|
||||
import { SNComponent } from '@standardnotes/models'
|
||||
import { RoleName } from '@standardnotes/common'
|
||||
|
||||
import { FeatureStatus } from './FeatureStatus'
|
||||
import { SetOfflineFeaturesFunctionResponse } from './SetOfflineFeaturesFunctionResponse'
|
||||
@@ -12,7 +11,7 @@ export interface FeaturesClientInterface {
|
||||
|
||||
getFeatureStatus(featureId: FeatureIdentifier): FeatureStatus
|
||||
|
||||
hasMinimumRole(role: RoleName): boolean
|
||||
hasMinimumRole(role: string): boolean
|
||||
|
||||
setOfflineFeaturesCode(code: string): Promise<SetOfflineFeaturesFunctionResponse>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* istanbul ignore file */
|
||||
|
||||
import { ContentType, Uuid } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import {
|
||||
SNNote,
|
||||
FileItem,
|
||||
@@ -129,14 +129,14 @@ export interface ItemsClientInterface {
|
||||
/**
|
||||
* Finds an item by UUID.
|
||||
*/
|
||||
findItem<T extends DecryptedItemInterface = DecryptedItemInterface>(uuid: Uuid): T | undefined
|
||||
findItem<T extends DecryptedItemInterface = DecryptedItemInterface>(uuid: string): T | undefined
|
||||
|
||||
/**
|
||||
* Finds an item by predicate.
|
||||
*/
|
||||
findItems<T extends DecryptedItemInterface>(uuids: Uuid[]): T[]
|
||||
findItems<T extends DecryptedItemInterface>(uuids: string[]): T[]
|
||||
|
||||
findSureItem<T extends DecryptedItemInterface = DecryptedItemInterface>(uuid: Uuid): T
|
||||
findSureItem<T extends DecryptedItemInterface = DecryptedItemInterface>(uuid: string): T
|
||||
|
||||
/**
|
||||
* Finds an item by predicate.
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
import { GetSingleItemResponse } from '@standardnotes/responses'
|
||||
|
||||
export interface ItemsServerInterface {
|
||||
getSingleItem(itemUuid: Uuid): Promise<GetSingleItemResponse>
|
||||
getSingleItem(itemUuid: string): Promise<GetSingleItemResponse>
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
import { Invitation } from '@standardnotes/models'
|
||||
import { AppleIAPReceipt } from './AppleIAPReceipt'
|
||||
|
||||
export interface SubscriptionClientInterface {
|
||||
listSubscriptionInvitations(): Promise<Invitation[]>
|
||||
inviteToSubscription(inviteeEmail: string): Promise<boolean>
|
||||
cancelInvitation(inviteUuid: Uuid): Promise<boolean>
|
||||
acceptInvitation(inviteUuid: Uuid): Promise<{ success: true } | { success: false; message: string }>
|
||||
cancelInvitation(inviteUuid: string): Promise<boolean>
|
||||
acceptInvitation(inviteUuid: string): Promise<{ success: true } | { success: false; message: string }>
|
||||
confirmAppleIAP(
|
||||
receipt: AppleIAPReceipt,
|
||||
subscriptionToken: string,
|
||||
|
||||
@@ -3,7 +3,6 @@ import { SubscriptionApiServiceInterface } from '@standardnotes/api'
|
||||
import { InternalEventBusInterface } from '../Internal/InternalEventBusInterface'
|
||||
import { AbstractService } from '../Service/AbstractService'
|
||||
import { SubscriptionClientInterface } from './SubscriptionClientInterface'
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
import { AppleIAPReceipt } from './AppleIAPReceipt'
|
||||
|
||||
export class SubscriptionManager extends AbstractService implements SubscriptionClientInterface {
|
||||
@@ -48,7 +47,7 @@ export class SubscriptionManager extends AbstractService implements Subscription
|
||||
}
|
||||
}
|
||||
|
||||
async cancelInvitation(inviteUuid: Uuid): Promise<boolean> {
|
||||
async cancelInvitation(inviteUuid: string): Promise<boolean> {
|
||||
try {
|
||||
const result = await this.subscriptionApiService.cancelInvite(inviteUuid)
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Uuid, WorkspaceAccessLevel, WorkspaceType } from '@standardnotes/common'
|
||||
import { WorkspaceAccessLevel, WorkspaceType } from '@standardnotes/common'
|
||||
import { Workspace, WorkspaceUser } from '@standardnotes/api'
|
||||
|
||||
export interface WorkspaceClientInterface {
|
||||
@@ -11,20 +11,20 @@ export interface WorkspaceClientInterface {
|
||||
}): Promise<{ uuid: string } | null>
|
||||
inviteToWorkspace(dto: {
|
||||
inviteeEmail: string
|
||||
workspaceUuid: Uuid
|
||||
workspaceUuid: string
|
||||
accessLevel: WorkspaceAccessLevel
|
||||
}): Promise<{ uuid: string } | null>
|
||||
acceptInvite(dto: {
|
||||
inviteUuid: Uuid
|
||||
userUuid: Uuid
|
||||
inviteUuid: string
|
||||
userUuid: string
|
||||
publicKey: string
|
||||
encryptedPrivateKey: string
|
||||
}): Promise<{ success: boolean }>
|
||||
listWorkspaces(): Promise<{ ownedWorkspaces: Array<Workspace>; joinedWorkspaces: Array<Workspace> }>
|
||||
listWorkspaceUsers(dto: { workspaceUuid: Uuid }): Promise<{ users: Array<WorkspaceUser> }>
|
||||
listWorkspaceUsers(dto: { workspaceUuid: string }): Promise<{ users: Array<WorkspaceUser> }>
|
||||
initiateKeyshare(dto: {
|
||||
workspaceUuid: Uuid
|
||||
userUuid: Uuid
|
||||
workspaceUuid: string
|
||||
userUuid: string
|
||||
encryptedWorkspaceKey: string
|
||||
}): Promise<{ success: boolean }>
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { WorkspaceApiServiceInterface, Workspace, WorkspaceUser } from '@standardnotes/api'
|
||||
import { Uuid, WorkspaceAccessLevel, WorkspaceType } from '@standardnotes/common'
|
||||
import { WorkspaceAccessLevel, WorkspaceType } from '@standardnotes/common'
|
||||
import { InternalEventBusInterface } from '../Internal/InternalEventBusInterface'
|
||||
import { AbstractService } from '../Service/AbstractService'
|
||||
import { WorkspaceClientInterface } from './WorkspaceClientInterface'
|
||||
@@ -79,7 +79,7 @@ export class WorkspaceManager extends AbstractService implements WorkspaceClient
|
||||
|
||||
async inviteToWorkspace(dto: {
|
||||
inviteeEmail: string
|
||||
workspaceUuid: Uuid
|
||||
workspaceUuid: string
|
||||
accessLevel: WorkspaceAccessLevel
|
||||
}): Promise<{ uuid: string } | null> {
|
||||
try {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { FeatureDescription } from '@standardnotes/features'
|
||||
import { isNullOrUndefined, joinPaths } from '@standardnotes/utils'
|
||||
import { SettingName, SubscriptionSettingName } from '@standardnotes/settings'
|
||||
import { Uuid, ErrorTag } from '@standardnotes/common'
|
||||
import { ErrorTag } from '@standardnotes/common'
|
||||
import {
|
||||
AbstractService,
|
||||
ApiServiceInterface,
|
||||
@@ -852,7 +852,7 @@ export class SNApiService
|
||||
})
|
||||
}
|
||||
|
||||
async getSingleItem(itemUuid: Uuid): Promise<Responses.GetSingleItemResponse> {
|
||||
async getSingleItem(itemUuid: string): Promise<Responses.GetSingleItemResponse> {
|
||||
return await this.tokenRefreshableRequest<Responses.GetSingleItemResponse>({
|
||||
verb: HttpVerb.Get,
|
||||
url: joinPaths(this.host, Paths.v1.getSingleItem(itemUuid)),
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
import { SettingName, SubscriptionSettingName } from '@standardnotes/settings'
|
||||
|
||||
const FilesPaths = {
|
||||
@@ -12,7 +11,7 @@ const FilesPaths = {
|
||||
|
||||
const UserPaths = {
|
||||
changeCredentials: (userUuid: string) => `/v1/users/${userUuid}/attributes/credentials`,
|
||||
deleteAccount: (userUuid: Uuid) => `/v1/users/${userUuid}`,
|
||||
deleteAccount: (userUuid: string) => `/v1/users/${userUuid}`,
|
||||
keyParams: '/v1/login-params',
|
||||
refreshSession: '/v1/sessions/refresh',
|
||||
register: '/v1/users',
|
||||
@@ -24,23 +23,23 @@ const UserPaths = {
|
||||
|
||||
const ItemsPaths = {
|
||||
checkIntegrity: '/v1/items/check-integrity',
|
||||
getSingleItem: (uuid: Uuid) => `/v1/items/${uuid}`,
|
||||
getSingleItem: (uuid: string) => `/v1/items/${uuid}`,
|
||||
itemRevisions: (itemUuid: string) => `/v1/items/${itemUuid}/revisions`,
|
||||
itemRevision: (itemUuid: string, revisionUuid: string) => `/v1/items/${itemUuid}/revisions/${revisionUuid}`,
|
||||
sync: '/v1/items',
|
||||
}
|
||||
|
||||
const SettingsPaths = {
|
||||
settings: (userUuid: Uuid) => `/v1/users/${userUuid}/settings`,
|
||||
setting: (userUuid: Uuid, settingName: SettingName) => `/v1/users/${userUuid}/settings/${settingName}`,
|
||||
subscriptionSetting: (userUuid: Uuid, settingName: SubscriptionSettingName) =>
|
||||
settings: (userUuid: string) => `/v1/users/${userUuid}/settings`,
|
||||
setting: (userUuid: string, settingName: SettingName) => `/v1/users/${userUuid}/settings/${settingName}`,
|
||||
subscriptionSetting: (userUuid: string, settingName: SubscriptionSettingName) =>
|
||||
`/v1/users/${userUuid}/subscription-settings/${settingName}`,
|
||||
}
|
||||
|
||||
const SubscriptionPaths = {
|
||||
offlineFeatures: '/v1/offline/features',
|
||||
purchase: '/v1/purchase',
|
||||
subscription: (userUuid: Uuid) => `/v1/users/${userUuid}/subscription`,
|
||||
subscription: (userUuid: string) => `/v1/users/${userUuid}/subscription`,
|
||||
subscriptionTokens: '/v1/subscription-tokens',
|
||||
userFeatures: (userUuid: string) => `/v1/users/${userUuid}/features`,
|
||||
}
|
||||
@@ -55,7 +54,7 @@ const UserPathsV2 = {
|
||||
}
|
||||
|
||||
const ListedPaths = {
|
||||
listedRegistration: (userUuid: Uuid) => `/v1/users/${userUuid}/integrations/listed`,
|
||||
listedRegistration: (userUuid: string) => `/v1/users/${userUuid}/integrations/listed`,
|
||||
}
|
||||
|
||||
export const Paths = {
|
||||
|
||||
@@ -2,7 +2,8 @@ import { ItemInterface, SNComponent, SNFeatureRepo } from '@standardnotes/models
|
||||
import { SNSyncService } from '../Sync/SyncService'
|
||||
import { SettingName } from '@standardnotes/settings'
|
||||
import { SNFeaturesService } from '@Lib/Services/Features'
|
||||
import { ContentType, RoleName } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { RoleName } from '@standardnotes/domain-core'
|
||||
import { FeatureDescription, FeatureIdentifier, GetFeatures } from '@standardnotes/features'
|
||||
import { SNWebSocketsService } from '../Api/WebsocketsService'
|
||||
import { SNSettingsService } from '../Settings'
|
||||
@@ -31,7 +32,7 @@ describe('featuresService', () => {
|
||||
let alertService: AlertService
|
||||
let sessionManager: SNSessionManager
|
||||
let crypto: PureCryptoInterface
|
||||
let roles: RoleName[]
|
||||
let roles: string[]
|
||||
let features: FeatureDescription[]
|
||||
let items: ItemInterface[]
|
||||
let now: Date
|
||||
@@ -57,7 +58,7 @@ describe('featuresService', () => {
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
roles = [RoleName.CoreUser, RoleName.PlusUser]
|
||||
roles = [RoleName.NAMES.CoreUser, RoleName.NAMES.PlusUser]
|
||||
|
||||
now = new Date()
|
||||
tomorrow_client = now.setDate(now.getDate() + 1)
|
||||
@@ -161,7 +162,7 @@ describe('featuresService', () => {
|
||||
},
|
||||
})
|
||||
|
||||
const newRoles = [...roles, RoleName.PlusUser]
|
||||
const newRoles = [...roles, RoleName.NAMES.PlusUser]
|
||||
|
||||
storageService.getValue = jest.fn().mockReturnValue(roles)
|
||||
|
||||
@@ -180,7 +181,7 @@ describe('featuresService', () => {
|
||||
},
|
||||
})
|
||||
|
||||
const newRoles = [...roles, RoleName.PlusUser]
|
||||
const newRoles = [...roles, RoleName.NAMES.PlusUser]
|
||||
|
||||
storageService.getValue = jest.fn().mockReturnValue(roles)
|
||||
|
||||
@@ -211,7 +212,7 @@ describe('featuresService', () => {
|
||||
|
||||
const mock = (featuresService['notifyEvent'] = jest.fn())
|
||||
|
||||
const newRoles = [...roles, RoleName.PlusUser]
|
||||
const newRoles = [...roles, RoleName.NAMES.PlusUser]
|
||||
await featuresService.setRoles(newRoles)
|
||||
|
||||
expect(mock.mock.calls[0][0]).toEqual(FeaturesEvent.UserRolesChanged)
|
||||
@@ -224,7 +225,7 @@ describe('featuresService', () => {
|
||||
|
||||
const spy = jest.spyOn(featuresService, 'notifyEvent' as never)
|
||||
|
||||
const newRoles = [...roles, RoleName.ProUser]
|
||||
const newRoles = [...roles, RoleName.NAMES.ProUser]
|
||||
await featuresService.updateRolesAndFetchFeatures('123', newRoles)
|
||||
|
||||
expect(spy.mock.calls[2][0]).toEqual(FeaturesEvent.DidPurchaseSubscription)
|
||||
@@ -238,7 +239,7 @@ describe('featuresService', () => {
|
||||
|
||||
const spy = jest.spyOn(featuresService, 'notifyEvent' as never)
|
||||
|
||||
const newRoles = [...roles, RoleName.ProUser]
|
||||
const newRoles = [...roles, RoleName.NAMES.ProUser]
|
||||
await featuresService.updateRolesAndFetchFeatures('123', newRoles)
|
||||
|
||||
const triggeredEvents = spy.mock.calls.map((call) => call[0])
|
||||
@@ -246,7 +247,7 @@ describe('featuresService', () => {
|
||||
})
|
||||
|
||||
it('saves new roles to storage and fetches features if a role has been added', async () => {
|
||||
const newRoles = [...roles, RoleName.PlusUser]
|
||||
const newRoles = [...roles, RoleName.NAMES.PlusUser]
|
||||
|
||||
storageService.getValue = jest.fn().mockReturnValue(roles)
|
||||
const featuresService = createService()
|
||||
@@ -257,7 +258,7 @@ describe('featuresService', () => {
|
||||
})
|
||||
|
||||
it('saves new roles to storage and fetches features if a role has been removed', async () => {
|
||||
const newRoles = [RoleName.CoreUser]
|
||||
const newRoles = [RoleName.NAMES.CoreUser]
|
||||
|
||||
storageService.getValue = jest.fn().mockReturnValue(roles)
|
||||
const featuresService = createService()
|
||||
@@ -268,7 +269,7 @@ describe('featuresService', () => {
|
||||
})
|
||||
|
||||
it('saves features to storage when roles change', async () => {
|
||||
const newRoles = [...roles, RoleName.PlusUser]
|
||||
const newRoles = [...roles, RoleName.NAMES.PlusUser]
|
||||
|
||||
storageService.getValue = jest.fn().mockReturnValue(roles)
|
||||
const featuresService = createService()
|
||||
@@ -278,7 +279,7 @@ describe('featuresService', () => {
|
||||
})
|
||||
|
||||
it('creates items for non-expired features with content type if they do not exist', async () => {
|
||||
const newRoles = [...roles, RoleName.PlusUser]
|
||||
const newRoles = [...roles, RoleName.NAMES.PlusUser]
|
||||
|
||||
storageService.getValue = jest.fn().mockReturnValue(roles)
|
||||
const featuresService = createService()
|
||||
@@ -321,7 +322,7 @@ describe('featuresService', () => {
|
||||
},
|
||||
} as never)
|
||||
|
||||
const newRoles = [...roles, RoleName.PlusUser]
|
||||
const newRoles = [...roles, RoleName.NAMES.PlusUser]
|
||||
|
||||
storageService.getValue = jest.fn().mockReturnValue(roles)
|
||||
itemManager.getItems = jest.fn().mockReturnValue([existingItem])
|
||||
@@ -333,7 +334,7 @@ describe('featuresService', () => {
|
||||
})
|
||||
|
||||
it('creates items for expired components if they do not exist', async () => {
|
||||
const newRoles = [...roles, RoleName.PlusUser]
|
||||
const newRoles = [...roles, RoleName.NAMES.PlusUser]
|
||||
|
||||
const now = new Date()
|
||||
const yesterday_client = now.setDate(now.getDate() - 1)
|
||||
@@ -379,7 +380,7 @@ describe('featuresService', () => {
|
||||
},
|
||||
} as never)
|
||||
|
||||
const newRoles = [...roles, RoleName.PlusUser]
|
||||
const newRoles = [...roles, RoleName.NAMES.PlusUser]
|
||||
|
||||
const now = new Date()
|
||||
const yesterday = now.setDate(now.getDate() - 1)
|
||||
@@ -418,7 +419,7 @@ describe('featuresService', () => {
|
||||
},
|
||||
})
|
||||
|
||||
const newRoles = [...roles, RoleName.PlusUser]
|
||||
const newRoles = [...roles, RoleName.NAMES.PlusUser]
|
||||
|
||||
storageService.getValue = jest.fn().mockReturnValue(roles)
|
||||
const featuresService = createService()
|
||||
@@ -441,7 +442,7 @@ describe('featuresService', () => {
|
||||
},
|
||||
})
|
||||
|
||||
const newRoles = [...roles, RoleName.PlusUser]
|
||||
const newRoles = [...roles, RoleName.NAMES.PlusUser]
|
||||
|
||||
storageService.getValue = jest.fn().mockReturnValue(roles)
|
||||
const featuresService = createService()
|
||||
@@ -468,7 +469,7 @@ describe('featuresService', () => {
|
||||
expires_at: tomorrow_server,
|
||||
} as FeatureDescription
|
||||
|
||||
const newRoles = [...roles, RoleName.PlusUser]
|
||||
const newRoles = [...roles, RoleName.NAMES.PlusUser]
|
||||
|
||||
storageService.getValue = jest.fn().mockReturnValue(roles)
|
||||
apiService.getUserFeatures = jest.fn().mockReturnValue({
|
||||
@@ -516,13 +517,13 @@ describe('featuresService', () => {
|
||||
identifier: FeatureIdentifier.MidnightTheme,
|
||||
content_type: ContentType.Theme,
|
||||
expires_at: tomorrow_server,
|
||||
role_name: RoleName.PlusUser,
|
||||
role_name: RoleName.NAMES.PlusUser,
|
||||
},
|
||||
{
|
||||
identifier: FeatureIdentifier.PlusEditor,
|
||||
content_type: ContentType.Component,
|
||||
expires_at: expiredDate,
|
||||
role_name: RoleName.ProUser,
|
||||
role_name: RoleName.NAMES.ProUser,
|
||||
},
|
||||
] as jest.Mocked<FeatureDescription[]>
|
||||
|
||||
@@ -534,13 +535,13 @@ describe('featuresService', () => {
|
||||
|
||||
sessionManager.isSignedIntoFirstPartyServer = jest.fn().mockReturnValue(true)
|
||||
|
||||
await featuresService.updateRolesAndFetchFeatures('123', [RoleName.CoreUser, RoleName.PlusUser])
|
||||
await featuresService.updateRolesAndFetchFeatures('123', [RoleName.NAMES.CoreUser, RoleName.NAMES.PlusUser])
|
||||
|
||||
expect(featuresService.getFeatureStatus(FeatureIdentifier.MidnightTheme)).toBe(FeatureStatus.Entitled)
|
||||
expect(featuresService.getFeatureStatus(FeatureIdentifier.PlusEditor)).toBe(FeatureStatus.NotInCurrentPlan)
|
||||
expect(featuresService.getFeatureStatus(FeatureIdentifier.SheetsEditor)).toBe(FeatureStatus.NotInCurrentPlan)
|
||||
|
||||
await featuresService.updateRolesAndFetchFeatures('123', [RoleName.CoreUser])
|
||||
await featuresService.updateRolesAndFetchFeatures('123', [RoleName.NAMES.CoreUser])
|
||||
|
||||
expect(featuresService.getFeatureStatus(FeatureIdentifier.MidnightTheme)).toBe(FeatureStatus.NoUserSubscription)
|
||||
expect(featuresService.getFeatureStatus(FeatureIdentifier.PlusEditor)).toBe(FeatureStatus.NoUserSubscription)
|
||||
@@ -551,13 +552,13 @@ describe('featuresService', () => {
|
||||
identifier: FeatureIdentifier.MidnightTheme,
|
||||
content_type: ContentType.Theme,
|
||||
expires_at: expiredDate,
|
||||
role_name: RoleName.PlusUser,
|
||||
role_name: RoleName.NAMES.PlusUser,
|
||||
},
|
||||
{
|
||||
identifier: FeatureIdentifier.PlusEditor,
|
||||
content_type: ContentType.Component,
|
||||
expires_at: expiredDate,
|
||||
role_name: RoleName.ProUser,
|
||||
role_name: RoleName.NAMES.ProUser,
|
||||
},
|
||||
] as jest.Mocked<FeatureDescription[]>
|
||||
|
||||
@@ -567,7 +568,7 @@ describe('featuresService', () => {
|
||||
},
|
||||
})
|
||||
|
||||
await featuresService.updateRolesAndFetchFeatures('123', [RoleName.PlusUser])
|
||||
await featuresService.updateRolesAndFetchFeatures('123', [RoleName.NAMES.PlusUser])
|
||||
|
||||
expect(featuresService.getFeatureStatus(FeatureIdentifier.MidnightTheme)).toBe(
|
||||
FeatureStatus.InCurrentPlanButExpired,
|
||||
@@ -579,7 +580,7 @@ describe('featuresService', () => {
|
||||
it('availableInRoles-based features', async () => {
|
||||
const featuresService = createService()
|
||||
|
||||
await featuresService.updateRolesAndFetchFeatures('123', [RoleName.ProUser])
|
||||
await featuresService.updateRolesAndFetchFeatures('123', [RoleName.NAMES.ProUser])
|
||||
|
||||
expect(featuresService.getFeatureStatus(FeatureIdentifier.SuperEditor)).toBe(FeatureStatus.Entitled)
|
||||
})
|
||||
@@ -591,14 +592,14 @@ describe('featuresService', () => {
|
||||
identifier: 'third-party-theme' as FeatureIdentifier,
|
||||
content_type: ContentType.Theme,
|
||||
expires_at: tomorrow_server,
|
||||
role_name: RoleName.CoreUser,
|
||||
role_name: RoleName.NAMES.CoreUser,
|
||||
}
|
||||
|
||||
const editorFeature = {
|
||||
identifier: 'third-party-editor' as FeatureIdentifier,
|
||||
content_type: ContentType.Component,
|
||||
expires_at: expiredDate,
|
||||
role_name: RoleName.PlusUser,
|
||||
role_name: RoleName.NAMES.PlusUser,
|
||||
}
|
||||
|
||||
features = [themeFeature, editorFeature] as jest.Mocked<FeatureDescription[]>
|
||||
@@ -628,7 +629,7 @@ describe('featuresService', () => {
|
||||
} as never),
|
||||
])
|
||||
|
||||
await featuresService.updateRolesAndFetchFeatures('123', [RoleName.CoreUser])
|
||||
await featuresService.updateRolesAndFetchFeatures('123', [RoleName.NAMES.CoreUser])
|
||||
|
||||
expect(featuresService.getFeatureStatus(themeFeature.identifier)).toBe(FeatureStatus.Entitled)
|
||||
expect(featuresService.getFeatureStatus(editorFeature.identifier)).toBe(FeatureStatus.InCurrentPlanButExpired)
|
||||
@@ -640,7 +641,7 @@ describe('featuresService', () => {
|
||||
it('feature status should be not entitled if no account or offline repo', async () => {
|
||||
const featuresService = createService()
|
||||
|
||||
await featuresService.updateRolesAndFetchFeatures('123', [RoleName.CoreUser])
|
||||
await featuresService.updateRolesAndFetchFeatures('123', [RoleName.NAMES.CoreUser])
|
||||
|
||||
sessionManager.isSignedIntoFirstPartyServer = jest.fn().mockReturnValue(false)
|
||||
|
||||
@@ -661,7 +662,7 @@ describe('featuresService', () => {
|
||||
},
|
||||
})
|
||||
|
||||
await featuresService.updateRolesAndFetchFeatures('123', [RoleName.CoreUser, RoleName.PlusUser])
|
||||
await featuresService.updateRolesAndFetchFeatures('123', [RoleName.NAMES.CoreUser, RoleName.NAMES.PlusUser])
|
||||
|
||||
sessionManager.isSignedIntoFirstPartyServer = jest.fn().mockReturnValue(true)
|
||||
|
||||
@@ -689,7 +690,7 @@ describe('featuresService', () => {
|
||||
it('feature status should be dynamic for subscriber if cached features and no successful features request made yet', async () => {
|
||||
const featuresService = createService()
|
||||
|
||||
await featuresService.updateRolesAndFetchFeatures('123', [RoleName.CoreUser, RoleName.PlusUser])
|
||||
await featuresService.updateRolesAndFetchFeatures('123', [RoleName.NAMES.CoreUser, RoleName.NAMES.PlusUser])
|
||||
|
||||
featuresService['completedSuccessfulFeaturesRetrieval'] = false
|
||||
|
||||
@@ -707,7 +708,7 @@ describe('featuresService', () => {
|
||||
it('feature status for offline subscription', async () => {
|
||||
const featuresService = createService()
|
||||
|
||||
await featuresService.updateRolesAndFetchFeatures('123', [RoleName.CoreUser, RoleName.PlusUser])
|
||||
await featuresService.updateRolesAndFetchFeatures('123', [RoleName.NAMES.CoreUser, RoleName.NAMES.PlusUser])
|
||||
|
||||
sessionManager.isSignedIntoFirstPartyServer = jest.fn().mockReturnValue(false)
|
||||
featuresService.rolesIncludePaidSubscription = jest.fn().mockReturnValue(false)
|
||||
@@ -733,7 +734,7 @@ describe('featuresService', () => {
|
||||
FeatureStatus.NoUserSubscription,
|
||||
)
|
||||
|
||||
await featuresService.updateRolesAndFetchFeatures('123', [RoleName.CoreUser, RoleName.PlusUser])
|
||||
await featuresService.updateRolesAndFetchFeatures('123', [RoleName.NAMES.CoreUser, RoleName.NAMES.PlusUser])
|
||||
|
||||
expect(featuresService.getFeatureStatus(FeatureIdentifier.DeprecatedFileSafe as FeatureIdentifier)).toBe(
|
||||
FeatureStatus.Entitled,
|
||||
@@ -743,12 +744,12 @@ describe('featuresService', () => {
|
||||
it('has paid subscription', async () => {
|
||||
const featuresService = createService()
|
||||
|
||||
await featuresService.updateRolesAndFetchFeatures('123', [RoleName.CoreUser])
|
||||
await featuresService.updateRolesAndFetchFeatures('123', [RoleName.NAMES.CoreUser])
|
||||
sessionManager.isSignedIntoFirstPartyServer = jest.fn().mockReturnValue(true)
|
||||
|
||||
expect(featuresService.hasPaidOnlineOrOfflineSubscription()).toBeFalsy
|
||||
|
||||
await featuresService.updateRolesAndFetchFeatures('123', [RoleName.CoreUser, RoleName.PlusUser])
|
||||
await featuresService.updateRolesAndFetchFeatures('123', [RoleName.NAMES.CoreUser, RoleName.NAMES.PlusUser])
|
||||
|
||||
expect(featuresService.hasPaidOnlineOrOfflineSubscription()).toEqual(true)
|
||||
})
|
||||
@@ -756,7 +757,7 @@ describe('featuresService', () => {
|
||||
it('has paid subscription should be true if offline repo and signed into third party server', async () => {
|
||||
const featuresService = createService()
|
||||
|
||||
await featuresService.updateRolesAndFetchFeatures('123', [RoleName.CoreUser])
|
||||
await featuresService.updateRolesAndFetchFeatures('123', [RoleName.NAMES.CoreUser])
|
||||
|
||||
featuresService.hasOfflineRepo = jest.fn().mockReturnValue(true)
|
||||
sessionManager.isSignedIntoFirstPartyServer = jest.fn().mockReturnValue(false)
|
||||
@@ -828,9 +829,9 @@ describe('featuresService', () => {
|
||||
it('should sort given roles according to role hierarchy', () => {
|
||||
const featuresService = createService()
|
||||
|
||||
const sortedRoles = featuresService.rolesBySorting([RoleName.ProUser, RoleName.CoreUser, RoleName.PlusUser])
|
||||
const sortedRoles = featuresService.rolesBySorting([RoleName.NAMES.ProUser, RoleName.NAMES.CoreUser, RoleName.NAMES.PlusUser])
|
||||
|
||||
expect(sortedRoles).toStrictEqual([RoleName.CoreUser, RoleName.PlusUser, RoleName.ProUser])
|
||||
expect(sortedRoles).toStrictEqual([RoleName.NAMES.CoreUser, RoleName.NAMES.PlusUser, RoleName.NAMES.ProUser])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -838,9 +839,9 @@ describe('featuresService', () => {
|
||||
it('should be false if core user checks for plus role', async () => {
|
||||
const featuresService = createService()
|
||||
|
||||
await featuresService.updateRolesAndFetchFeatures('123', [RoleName.CoreUser])
|
||||
await featuresService.updateRolesAndFetchFeatures('123', [RoleName.NAMES.CoreUser])
|
||||
|
||||
const hasPlusUserRole = featuresService.hasMinimumRole(RoleName.PlusUser)
|
||||
const hasPlusUserRole = featuresService.hasMinimumRole(RoleName.NAMES.PlusUser)
|
||||
|
||||
expect(hasPlusUserRole).toBe(false)
|
||||
})
|
||||
@@ -848,9 +849,9 @@ describe('featuresService', () => {
|
||||
it('should be false if plus user checks for pro role', async () => {
|
||||
const featuresService = createService()
|
||||
|
||||
await featuresService.updateRolesAndFetchFeatures('123', [RoleName.PlusUser, RoleName.CoreUser])
|
||||
await featuresService.updateRolesAndFetchFeatures('123', [RoleName.NAMES.PlusUser, RoleName.NAMES.CoreUser])
|
||||
|
||||
const hasProUserRole = featuresService.hasMinimumRole(RoleName.ProUser)
|
||||
const hasProUserRole = featuresService.hasMinimumRole(RoleName.NAMES.ProUser)
|
||||
|
||||
expect(hasProUserRole).toBe(false)
|
||||
})
|
||||
@@ -858,9 +859,9 @@ describe('featuresService', () => {
|
||||
it('should be true if pro user checks for core user', async () => {
|
||||
const featuresService = createService()
|
||||
|
||||
await featuresService.updateRolesAndFetchFeatures('123', [RoleName.ProUser, RoleName.PlusUser])
|
||||
await featuresService.updateRolesAndFetchFeatures('123', [RoleName.NAMES.ProUser, RoleName.NAMES.PlusUser])
|
||||
|
||||
const hasCoreUserRole = featuresService.hasMinimumRole(RoleName.CoreUser)
|
||||
const hasCoreUserRole = featuresService.hasMinimumRole(RoleName.NAMES.CoreUser)
|
||||
|
||||
expect(hasCoreUserRole).toBe(true)
|
||||
})
|
||||
@@ -868,9 +869,9 @@ describe('featuresService', () => {
|
||||
it('should be true if pro user checks for pro user', async () => {
|
||||
const featuresService = createService()
|
||||
|
||||
await featuresService.updateRolesAndFetchFeatures('123', [RoleName.ProUser, RoleName.PlusUser])
|
||||
await featuresService.updateRolesAndFetchFeatures('123', [RoleName.NAMES.ProUser, RoleName.NAMES.PlusUser])
|
||||
|
||||
const hasProUserRole = featuresService.hasMinimumRole(RoleName.ProUser)
|
||||
const hasProUserRole = featuresService.hasMinimumRole(RoleName.NAMES.ProUser)
|
||||
|
||||
expect(hasProUserRole).toBe(true)
|
||||
})
|
||||
|
||||
@@ -8,7 +8,8 @@ import {
|
||||
isString,
|
||||
} from '@standardnotes/utils'
|
||||
import { ClientDisplayableError, UserFeaturesResponse } from '@standardnotes/responses'
|
||||
import { ContentType, RoleName } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { RoleName } from '@standardnotes/domain-core'
|
||||
import { FillItemContent, PayloadEmitSource } from '@standardnotes/models'
|
||||
import { ItemManager } from '../Items/ItemManager'
|
||||
import { LEGACY_PROD_EXT_ORIGIN, PROD_OFFLINE_FEATURES_URL } from '../../Hosts'
|
||||
@@ -57,7 +58,7 @@ export class SNFeaturesService
|
||||
implements FeaturesClientInterface, InternalEventHandlerInterface
|
||||
{
|
||||
private deinited = false
|
||||
private roles: RoleName[] = []
|
||||
private roles: string[] = []
|
||||
private features: FeaturesImports.FeatureDescription[] = []
|
||||
private enabledExperimentalFeatures: FeaturesImports.FeatureIdentifier[] = []
|
||||
private removeWebSocketsServiceObserver: () => void
|
||||
@@ -363,14 +364,14 @@ export class SNFeaturesService
|
||||
}
|
||||
|
||||
public initializeFromDisk(): void {
|
||||
this.roles = this.storageService.getValue<RoleName[]>(StorageKey.UserRoles, undefined, [])
|
||||
this.roles = this.storageService.getValue<string[]>(StorageKey.UserRoles, undefined, [])
|
||||
|
||||
this.features = this.storageService.getValue(StorageKey.UserFeatures, undefined, [])
|
||||
|
||||
this.enabledExperimentalFeatures = this.storageService.getValue(StorageKey.ExperimentalFeatures, undefined, [])
|
||||
}
|
||||
|
||||
public async updateRolesAndFetchFeatures(userUuid: UuidString, roles: RoleName[]): Promise<void> {
|
||||
public async updateRolesAndFetchFeatures(userUuid: UuidString, roles: string[]): Promise<void> {
|
||||
const previousRoles = this.roles
|
||||
|
||||
const userRolesChanged = this.haveRolesChanged(roles)
|
||||
@@ -403,7 +404,7 @@ export class SNFeaturesService
|
||||
}
|
||||
}
|
||||
|
||||
async setRoles(roles: RoleName[]): Promise<void> {
|
||||
async setRoles(roles: string[]): Promise<void> {
|
||||
const rolesChanged = !arraysEqual(this.roles, roles)
|
||||
|
||||
this.roles = roles
|
||||
@@ -469,7 +470,7 @@ export class SNFeaturesService
|
||||
}
|
||||
|
||||
rolesIncludePaidSubscription(): boolean {
|
||||
const unpaidRoles = [RoleName.CoreUser]
|
||||
const unpaidRoles = [RoleName.NAMES.CoreUser]
|
||||
return this.roles.some((role) => !unpaidRoles.includes(role))
|
||||
}
|
||||
|
||||
@@ -477,16 +478,16 @@ export class SNFeaturesService
|
||||
return this.rolesIncludePaidSubscription() || this.hasOfflineRepo()
|
||||
}
|
||||
|
||||
public rolesBySorting(roles: RoleName[]): RoleName[] {
|
||||
return Object.values(RoleName).filter((role) => roles.includes(role))
|
||||
public rolesBySorting(roles: string[]): string[] {
|
||||
return Object.values(RoleName.NAMES).filter((role) => roles.includes(role))
|
||||
}
|
||||
|
||||
public hasMinimumRole(role: RoleName): boolean {
|
||||
const sortedAllRoles = Object.values(RoleName)
|
||||
public hasMinimumRole(role: string): boolean {
|
||||
const sortedAllRoles = Object.values(RoleName.NAMES)
|
||||
|
||||
const sortedUserRoles = this.rolesBySorting(this.roles)
|
||||
|
||||
const highestUserRoleIndex = sortedAllRoles.indexOf(lastElement(sortedUserRoles) as RoleName)
|
||||
const highestUserRoleIndex = sortedAllRoles.indexOf(lastElement(sortedUserRoles) as string)
|
||||
|
||||
const indexOfRoleToCheck = sortedAllRoles.indexOf(role)
|
||||
|
||||
@@ -556,7 +557,7 @@ export class SNFeaturesService
|
||||
|
||||
const expired = feature.expires_at && new Date(feature.expires_at).getTime() < new Date().getTime()
|
||||
if (expired) {
|
||||
if (!this.roles.includes(feature.role_name as RoleName)) {
|
||||
if (!this.roles.includes(feature.role_name as string)) {
|
||||
return FeatureStatus.NotInCurrentPlan
|
||||
} else {
|
||||
return FeatureStatus.InCurrentPlanButExpired
|
||||
@@ -566,7 +567,7 @@ export class SNFeaturesService
|
||||
return FeatureStatus.Entitled
|
||||
}
|
||||
|
||||
private haveRolesChanged(roles: RoleName[]): boolean {
|
||||
private haveRolesChanged(roles: string[]): boolean {
|
||||
return roles.some((role) => !this.roles.includes(role)) || this.roles.some((role) => !roles.includes(role))
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ContentType, Uuid } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { assert, naturalSort, removeFromArray, UuidGenerator, Uuids } from '@standardnotes/utils'
|
||||
import { ItemsKeyMutator, SNItemsKey } from '@standardnotes/encryption'
|
||||
import { PayloadManager } from '../Payloads/PayloadManager'
|
||||
@@ -240,7 +240,7 @@ export class ItemManager
|
||||
return this.collection.findAll(uuids)
|
||||
}
|
||||
|
||||
private findSystemSmartView(uuid: Uuid): Models.SmartView | undefined {
|
||||
private findSystemSmartView(uuid: string): Models.SmartView | undefined {
|
||||
return this.systemSmartViews.find((view) => view.uuid === uuid)
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import { DiskStorageService } from '../Storage/DiskStorageService'
|
||||
import { PayloadManager } from '../Payloads/PayloadManager'
|
||||
import { ChallengeService } from '../Challenge'
|
||||
import { SNApiService } from '@Lib/Services/Api/ApiService'
|
||||
import { ContentType, Uuid } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ItemManager } from '../Items/ItemManager'
|
||||
import { removeFromArray, Uuids } from '@standardnotes/utils'
|
||||
import { ClientDisplayableError, KeyParamsResponse } from '@standardnotes/responses'
|
||||
@@ -240,7 +240,7 @@ export class SNKeyRecoveryService extends AbstractService<KeyRecoveryEvent, Decr
|
||||
this.persistUndecryptables(record)
|
||||
}
|
||||
|
||||
private removeFromUndecryptables(keyIds: Uuid[]) {
|
||||
private removeFromUndecryptables(keyIds: string[]) {
|
||||
const record = this.getUndecryptables()
|
||||
|
||||
for (const id of keyIds) {
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { SNNote } from '@standardnotes/models'
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
import { ListedAccount, ListedAccountInfo } from '@standardnotes/responses'
|
||||
|
||||
export interface ListedClientInterface {
|
||||
canRegisterNewListedAccount: () => boolean
|
||||
requestNewListedAccount: () => Promise<ListedAccount | undefined>
|
||||
getListedAccounts(): Promise<ListedAccount[]>
|
||||
getListedAccountInfo(account: ListedAccount, inContextOfItem?: Uuid): Promise<ListedAccountInfo | undefined>
|
||||
getListedAccountInfo(account: ListedAccount, inContextOfItem?: string): Promise<ListedAccountInfo | undefined>
|
||||
isNoteAuthorizedForListed(note: SNNote): boolean
|
||||
authorizeNoteForListed(note: SNNote): Promise<boolean>
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ContentType, Uuid } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { PayloadsChangeObserver, QueueElement, PayloadsChangeObserverCallback, EmitQueue } from './Types'
|
||||
import { removeFromArray, Uuids } from '@standardnotes/utils'
|
||||
import {
|
||||
@@ -66,11 +66,11 @@ export class PayloadManager extends AbstractService implements PayloadManagerInt
|
||||
this.collection = new PayloadCollection()
|
||||
}
|
||||
|
||||
public find(uuids: Uuid[]): FullyFormedPayloadInterface[] {
|
||||
public find(uuids: string[]): FullyFormedPayloadInterface[] {
|
||||
return this.collection.findAll(uuids)
|
||||
}
|
||||
|
||||
public findOne(uuid: Uuid): FullyFormedPayloadInterface | undefined {
|
||||
public findOne(uuid: string): FullyFormedPayloadInterface | undefined {
|
||||
return this.collection.findAll([uuid])[0]
|
||||
}
|
||||
|
||||
@@ -288,7 +288,7 @@ export class PayloadManager extends AbstractService implements PayloadManagerInt
|
||||
* and marks the items as dirty.
|
||||
* @returns Resulting items
|
||||
*/
|
||||
public async importPayloads(payloads: DecryptedPayloadInterface[], historyMap: HistoryMap): Promise<Uuid[]> {
|
||||
public async importPayloads(payloads: DecryptedPayloadInterface[], historyMap: HistoryMap): Promise<string[]> {
|
||||
const sourcedPayloads = payloads.map((p) => p.copy(undefined, PayloadSource.FileImport))
|
||||
|
||||
const delta = new DeltaFileImport(this.getMasterCollection(), sourcedPayloads, historyMap)
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
export type RawJwtPayload = {
|
||||
jwt?: string
|
||||
}
|
||||
@@ -15,7 +13,7 @@ export type RawSessionPayload = {
|
||||
export type RawStorageValue = RawJwtPayload | RawSessionPayload
|
||||
|
||||
export type RemoteSession = {
|
||||
uuid: Uuid
|
||||
uuid: string
|
||||
updated_at: Date
|
||||
device_info: string
|
||||
current: boolean
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ContentType, Uuid } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { Copy, extendArray, UuidGenerator } from '@standardnotes/utils'
|
||||
import { SNLog } from '../../Log'
|
||||
import { isErrorDecryptingParameters, SNRootKey } from '@standardnotes/encryption'
|
||||
@@ -448,7 +448,7 @@ export class DiskStorageService extends Services.AbstractService implements Serv
|
||||
await Promise.all(payloads.map((payload) => this.deletePayloadWithId(payload.uuid)))
|
||||
}
|
||||
|
||||
public async deletePayloadWithId(uuid: Uuid) {
|
||||
public async deletePayloadWithId(uuid: string) {
|
||||
return this.executeCriticalFunction(async () => {
|
||||
return this.deviceInterface.removeDatabaseEntry(uuid, this.identifier)
|
||||
})
|
||||
|
||||
@@ -8,6 +8,7 @@ export * from './Services'
|
||||
export * from './Types'
|
||||
export * from './Version'
|
||||
export * from '@standardnotes/common'
|
||||
export * from '@standardnotes/domain-core'
|
||||
export * from '@standardnotes/encryption'
|
||||
export * from '@standardnotes/features'
|
||||
export * from '@standardnotes/files'
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
"@babel/core": "*",
|
||||
"@babel/preset-env": "*",
|
||||
"@standardnotes/api": "workspace:*",
|
||||
"@standardnotes/common": "^1.45.0",
|
||||
"@standardnotes/common": "^1.46.3",
|
||||
"@standardnotes/domain-events": "^2.88.0",
|
||||
"@standardnotes/encryption": "workspace:*",
|
||||
"@standardnotes/features": "workspace:*",
|
||||
@@ -86,6 +86,6 @@
|
||||
"webpack-merge": "^5.8.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@standardnotes/domain-core": "^1.11.0"
|
||||
"@standardnotes/domain-core": "^1.11.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
"test": "jest spec"
|
||||
},
|
||||
"dependencies": {
|
||||
"@standardnotes/common": "^1.45.0",
|
||||
"@standardnotes/common": "^1.46.3",
|
||||
"@standardnotes/features": "workspace:^",
|
||||
"@standardnotes/filepicker": "workspace:^",
|
||||
"@standardnotes/services": "workspace:^",
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
export type SubscriptionInviteParams = {
|
||||
inviteUuid: Uuid
|
||||
inviteUuid: string
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { UserRequestType, Uuid } from '@standardnotes/common'
|
||||
import { UserRequestType } from '@standardnotes/common'
|
||||
import { PreferenceId } from './../Preferences/PreferenceId'
|
||||
import { DemoParams } from './Params/DemoParams'
|
||||
import { OnboardingParams } from './Params/OnboardingParams'
|
||||
@@ -41,7 +41,7 @@ export class RouteParser implements RouteParserInterface {
|
||||
this.checkForProperRouteType(RouteType.AcceptSubscriptionInvite)
|
||||
|
||||
return {
|
||||
inviteUuid: this.searchParams.get(RootQueryParam.AcceptSubscriptionInvite) as Uuid,
|
||||
inviteUuid: this.searchParams.get(RootQueryParam.AcceptSubscriptionInvite) as string,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user