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