@api-client/core 0.19.16 → 0.19.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/src/browser.d.ts +12 -12
- package/build/src/browser.d.ts.map +1 -1
- package/build/src/browser.js +3 -3
- package/build/src/browser.js.map +1 -1
- package/build/src/exceptions/exception.d.ts +56 -0
- package/build/src/exceptions/exception.d.ts.map +1 -1
- package/build/src/exceptions/exception.js +111 -14
- package/build/src/exceptions/exception.js.map +1 -1
- package/build/src/index.d.ts +12 -12
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +3 -3
- package/build/src/index.js.map +1 -1
- package/build/src/mocking/ProjectMock.d.ts +1 -1
- package/build/src/mocking/ProjectMock.d.ts.map +1 -1
- package/build/src/mocking/ProjectMock.js.map +1 -1
- package/build/src/mocking/lib/File.d.ts +5 -5
- package/build/src/mocking/lib/File.d.ts.map +1 -1
- package/build/src/mocking/lib/File.js.map +1 -1
- package/build/src/mocking/lib/Organization.d.ts +3 -3
- package/build/src/mocking/lib/Organization.d.ts.map +1 -1
- package/build/src/mocking/lib/Organization.js +2 -1
- package/build/src/mocking/lib/Organization.js.map +1 -1
- package/build/src/mocking/lib/Permission.d.ts +6 -6
- package/build/src/mocking/lib/Permission.d.ts.map +1 -1
- package/build/src/mocking/lib/Permission.js.map +1 -1
- package/build/src/mocking/lib/User.d.ts +8 -4
- package/build/src/mocking/lib/User.d.ts.map +1 -1
- package/build/src/mocking/lib/User.js.map +1 -1
- package/build/src/modeling/ApiFile.d.ts +8 -4
- package/build/src/modeling/ApiFile.d.ts.map +1 -1
- package/build/src/modeling/ApiFile.js.map +1 -1
- package/build/src/modeling/ApiModel.d.ts +2 -2
- package/build/src/modeling/ApiModel.d.ts.map +1 -1
- package/build/src/modeling/ApiModel.js.map +1 -1
- package/build/src/modeling/DataDomain.d.ts +2 -2
- package/build/src/modeling/DataDomain.d.ts.map +1 -1
- package/build/src/modeling/DataDomain.js.map +1 -1
- package/build/src/modeling/DomainAssociation.d.ts +2 -2
- package/build/src/modeling/DomainAssociation.d.ts.map +1 -1
- package/build/src/modeling/DomainAssociation.js.map +1 -1
- package/build/src/modeling/DomainEntity.d.ts +2 -2
- package/build/src/modeling/DomainEntity.d.ts.map +1 -1
- package/build/src/modeling/DomainEntity.js.map +1 -1
- package/build/src/modeling/DomainFile.d.ts +8 -4
- package/build/src/modeling/DomainFile.d.ts.map +1 -1
- package/build/src/modeling/DomainFile.js.map +1 -1
- package/build/src/modeling/DomainModel.d.ts +2 -2
- package/build/src/modeling/DomainModel.d.ts.map +1 -1
- package/build/src/modeling/DomainModel.js.map +1 -1
- package/build/src/modeling/DomainNamespace.d.ts +2 -2
- package/build/src/modeling/DomainNamespace.d.ts.map +1 -1
- package/build/src/modeling/DomainNamespace.js.map +1 -1
- package/build/src/modeling/DomainProperty.d.ts +2 -2
- package/build/src/modeling/DomainProperty.d.ts.map +1 -1
- package/build/src/modeling/DomainProperty.js.map +1 -1
- package/build/src/modeling/helpers/Intelisense.d.ts +38 -38
- package/build/src/modeling/helpers/Intelisense.d.ts.map +1 -1
- package/build/src/modeling/helpers/Intelisense.js.map +1 -1
- package/build/src/models/AiMessage.d.ts +3 -3
- package/build/src/models/AiMessage.d.ts.map +1 -1
- package/build/src/models/AiMessage.js.map +1 -1
- package/build/src/models/AiSession.d.ts +3 -3
- package/build/src/models/AiSession.d.ts.map +1 -1
- package/build/src/models/AiSession.js.map +1 -1
- package/build/src/models/CertificateFile.d.ts +2 -2
- package/build/src/models/CertificateFile.d.ts.map +1 -1
- package/build/src/models/CertificateFile.js.map +1 -1
- package/build/src/models/Environment.d.ts +2 -2
- package/build/src/models/Environment.d.ts.map +1 -1
- package/build/src/models/Environment.js.map +1 -1
- package/build/src/models/Folder.d.ts +9 -5
- package/build/src/models/Folder.d.ts.map +1 -1
- package/build/src/models/Folder.js.map +1 -1
- package/build/src/models/HttpProject.d.ts +2 -2
- package/build/src/models/HttpProject.d.ts.map +1 -1
- package/build/src/models/HttpProject.js.map +1 -1
- package/build/src/models/ProjectFolder.d.ts +2 -2
- package/build/src/models/ProjectFolder.d.ts.map +1 -1
- package/build/src/models/ProjectFolder.js.map +1 -1
- package/build/src/models/Request.d.ts +3 -3
- package/build/src/models/Request.d.ts.map +1 -1
- package/build/src/models/Request.js.map +1 -1
- package/build/src/models/Thing.d.ts +9 -5
- package/build/src/models/Thing.d.ts.map +1 -1
- package/build/src/models/Thing.js.map +1 -1
- package/build/src/models/TrashEntry.d.ts +2 -2
- package/build/src/models/TrashEntry.d.ts.map +1 -1
- package/build/src/models/TrashEntry.js.map +1 -1
- package/build/src/models/store/Capabilities.d.ts +5 -1
- package/build/src/models/store/Capabilities.d.ts.map +1 -1
- package/build/src/models/store/Capabilities.js.map +1 -1
- package/build/src/models/store/Deletion.d.ts +5 -1
- package/build/src/models/store/Deletion.d.ts.map +1 -1
- package/build/src/models/store/Deletion.js.map +1 -1
- package/build/src/models/store/File.d.ts +45 -37
- package/build/src/models/store/File.d.ts.map +1 -1
- package/build/src/models/store/File.js +1 -1
- package/build/src/models/store/File.js.map +1 -1
- package/build/src/models/store/Group.d.ts +3 -3
- package/build/src/models/store/Group.d.ts.map +1 -1
- package/build/src/models/store/Group.js.map +1 -1
- package/build/src/models/store/Invitation.d.ts +3 -3
- package/build/src/models/store/Invitation.d.ts.map +1 -1
- package/build/src/models/store/Invitation.js.map +1 -1
- package/build/src/models/store/Modification.d.ts +5 -1
- package/build/src/models/store/Modification.d.ts.map +1 -1
- package/build/src/models/store/Modification.js.map +1 -1
- package/build/src/models/store/Organization.d.ts +18 -13
- package/build/src/models/store/Organization.d.ts.map +1 -1
- package/build/src/models/store/Organization.js +29 -47
- package/build/src/models/store/Organization.js.map +1 -1
- package/build/src/models/store/Permission.d.ts +9 -5
- package/build/src/models/store/Permission.d.ts.map +1 -1
- package/build/src/models/store/Permission.js.map +1 -1
- package/build/src/models/store/User.d.ts +18 -6
- package/build/src/models/store/User.d.ts.map +1 -1
- package/build/src/models/store/User.js.map +1 -1
- package/build/src/models/store/UserIdentity.d.ts +9 -5
- package/build/src/models/store/UserIdentity.d.ts.map +1 -1
- package/build/src/models/store/UserIdentity.js.map +1 -1
- package/build/src/sdk/FilesSdk.d.ts +15 -15
- package/build/src/sdk/FilesSdk.d.ts.map +1 -1
- package/build/src/sdk/FilesSdk.js +1 -1
- package/build/src/sdk/FilesSdk.js.map +1 -1
- package/build/src/sdk/OrganizationsSdk.d.ts +9 -9
- package/build/src/sdk/OrganizationsSdk.d.ts.map +1 -1
- package/build/src/sdk/OrganizationsSdk.js.map +1 -1
- package/build/src/sdk/SdkMock.js +6 -6
- package/build/src/sdk/SdkMock.js.map +1 -1
- package/build/src/sdk/SharedSdk.d.ts +2 -2
- package/build/src/sdk/SharedSdk.d.ts.map +1 -1
- package/build/src/sdk/SharedSdk.js.map +1 -1
- package/build/src/sdk/StoreSdkNode.d.ts +1 -1
- package/build/src/sdk/StoreSdkNode.d.ts.map +1 -1
- package/build/src/sdk/StoreSdkNode.js.map +1 -1
- package/build/src/sdk/StoreSdkWeb.d.ts +1 -1
- package/build/src/sdk/StoreSdkWeb.d.ts.map +1 -1
- package/build/src/sdk/StoreSdkWeb.js.map +1 -1
- package/build/src/sdk/UsersSdk.d.ts +5 -5
- package/build/src/sdk/UsersSdk.d.ts.map +1 -1
- package/build/src/sdk/UsersSdk.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/exceptions/exception.ts +119 -15
- package/src/mocking/ProjectMock.ts +1 -1
- package/src/mocking/lib/File.ts +5 -5
- package/src/mocking/lib/Organization.ts +5 -3
- package/src/mocking/lib/Permission.ts +8 -8
- package/src/mocking/lib/User.ts +11 -6
- package/src/modeling/ApiFile.ts +11 -6
- package/src/modeling/ApiModel.ts +2 -2
- package/src/modeling/DataDomain.ts +2 -2
- package/src/modeling/DomainAssociation.ts +2 -2
- package/src/modeling/DomainEntity.ts +2 -2
- package/src/modeling/DomainFile.ts +11 -6
- package/src/modeling/DomainModel.ts +2 -2
- package/src/modeling/DomainNamespace.ts +2 -2
- package/src/modeling/DomainProperty.ts +2 -2
- package/src/modeling/helpers/Intelisense.ts +41 -38
- package/src/models/AiMessage.ts +3 -3
- package/src/models/AiSession.ts +3 -3
- package/src/models/CertificateFile.ts +2 -2
- package/src/models/Environment.ts +2 -2
- package/src/models/Folder.ts +13 -8
- package/src/models/HttpProject.ts +2 -2
- package/src/models/ProjectFolder.ts +2 -2
- package/src/models/Request.ts +3 -3
- package/src/models/Thing.ts +14 -9
- package/src/models/TrashEntry.ts +2 -2
- package/src/models/store/Capabilities.ts +6 -1
- package/src/models/store/Deletion.ts +6 -1
- package/src/models/store/File.ts +53 -43
- package/src/models/store/Group.ts +3 -3
- package/src/models/store/Invitation.ts +3 -3
- package/src/models/store/Modification.ts +6 -1
- package/src/models/store/Organization.ts +45 -60
- package/src/models/store/Permission.ts +17 -12
- package/src/models/store/User.ts +21 -6
- package/src/models/store/UserIdentity.ts +13 -8
- package/src/sdk/FilesSdk.ts +29 -25
- package/src/sdk/OrganizationsSdk.ts +20 -16
- package/src/sdk/SdkMock.ts +16 -16
- package/src/sdk/SharedSdk.ts +3 -3
- package/src/sdk/StoreSdkNode.ts +3 -3
- package/src/sdk/StoreSdkWeb.ts +3 -3
- package/src/sdk/UsersSdk.ts +6 -6
- package/tests/unit/exceptions/exception.spec.ts +261 -0
- package/tests/unit/mocking/current/File.spec.ts +5 -5
- package/tests/unit/mocking/current/Organization.spec.ts +4 -3
- package/tests/unit/mocking/current/Permission.spec.ts +2 -2
- package/tests/unit/mocking/current/User.spec.ts +2 -2
- package/tests/unit/modeling/domain_file.spec.ts +3 -3
- package/tests/unit/models/File/createFileCapabilities.spec.ts +3 -3
- package/tests/unit/models/File/new.spec.ts +2 -2
- package/tests/unit/models/File/setDeleted.spec.ts +3 -3
- package/tests/unit/models/File/setLastModified.spec.ts +3 -3
- package/tests/unit/models/File/toJSON.spec.ts +2 -2
- package/tests/unit/models/Folder/create.spec.ts +3 -3
- package/tests/unit/models/Permission/all.spec.ts +3 -3
- package/tests/unit/models/store/Invitation.spec.ts +2 -2
- package/tests/unit/models/store/Organization.spec.ts +100 -0
- package/tests/unit/models/store/Permission.spec.ts +16 -6
- package/tests/unit/models/thing.spec.ts +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"File.js","sourceRoot":"","sources":["../../../../src/models/store/File.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAe,UAAU,EAAkB,MAAM,iBAAiB,CAAA;AAGzE,OAAO,EAAS,IAAI,IAAI,QAAQ,EAAE,MAAM,WAAW,CAAA;AACnD,OAAO,EAAU,KAAK,EAAE,MAAM,aAAa,CAAA;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AA+HxC,MAAM,aAAa,GAAG,MAAM,CAAC,SAAS,CAAC,CAAA;AACvC,MAAM,aAAa,GAAG,MAAM,CAAC,SAAS,CAAC,CAAA;AACvC,MAAM,iBAAiB,GAAG,MAAM,CAAC,aAAa,CAAC,CAAA;AAC/C,MAAM,kBAAkB,GAAG,MAAM,CAAC,cAAc,CAAC,CAAA;AACjD,MAAM,kBAAkB,GAAG,MAAM,CAAC,cAAc,CAAC,CAAA;AACjD,MAAM,iBAAiB,GAAG,MAAM,CAAC,aAAa,CAAC,CAAA;AAC/C,MAAM,mBAAmB,GAAG,MAAM,CAAC,eAAe,CAAC,CAAA;AACnD,MAAM,oBAAoB,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAA;AAErD,MAAM,OAAO,UAAU;IACrB;;OAEG;IACH,IAAI,GAAG,EAAE,CAAA;IACT;;OAEG;IACH,GAAG,GAAG,EAAE,CAAA;IACR;;OAEG;IACH,IAAI,GAAU,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;IAEhC;;OAEG;IACH,SAAS,CAAS;IAElB;;;OAGG;IAC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CAAC,EAAE,CAAC;YAChC,IAAI,CAAC,MAAM,GAAG,EAAE,CAAA;QAClB,CAAC;QACD,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAChC,OAAM;QACR,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACzB,CAAC;IAED;;;;;;OAMG;IACH,UAAU,CAAC,IAAW;QACpB,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAA;QAC1C,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAA;QAC3E,CAAC;QACD,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAA;QAC1B,IAAI,CAAC,iBAAiB,CAAC,GAAG;YACxB,IAAI,EAAE,KAAK;YACX,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE;YAChB,IAAI,EAAE,IAAI,CAAC,GAAG;YACd,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAA;IACH,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,IAAI,KAAK,UAAU,CAAA;IACjC,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,IAAI,KAAK,UAAU,CAAA;IACjC,CAAC;CACF","sourcesContent":["import { nanoid } from '../../nanoid.js'\nimport { IPermission, Permission, PermissionRole } from './Permission.js'\nimport { IModification } from './Modification.js'\nimport { IDeletion } from './Deletion.js'\nimport { IUser, Kind as UserKind } from './User.js'\nimport { IThing, Thing } from '../Thing.js'\nimport { ICapabilities } from './Capabilities.js'\nimport { FolderKind } from '../kinds.js'\n// this causes error\n// import { Kind as FolderKind } from '../Folder.js';\n\nexport interface FileAddOptions {\n /**\n * The parent folder where to put the file.\n * The `parents` array is always cleared from the file object before adding it to the store.\n */\n parent?: string\n}\n\nexport interface MediaReadOptions {\n /**\n * When set it reads the file that was marked as `_deleted`. By default it throws when file was deleted.\n */\n deleted?: boolean\n}\n\n/**\n * A breadcrumb when creating the breadcrumb list for a file.\n */\nexport interface FileBreadcrumb {\n /**\n * The datastore key of the object.\n */\n key: string\n /**\n * THe kind of the object.\n */\n kind: string\n /**\n * The name of the object.\n */\n name: string\n}\n\nexport interface IStoredFile {\n /**\n * The kind of the File\n */\n kind: string\n /**\n * The identifier of the entity\n */\n key: string\n /**\n * The file's meta info.\n */\n info: IThing\n /**\n * The color of the icon to render for this file in the file explorer.\n * This should be a hex format, e.g.: #c00 for red.\n */\n iconColor?: string\n /**\n * Whether the file is a shortcut to another file.\n * Many properties cannot be changed of a shortcut, like, shortcuts cannot be shared.\n */\n isShortcut?: boolean\n /**\n * The ID of the target file.\n */\n shortcutTarget?: string\n}\n\n/**\n * An interface describing an object in the data store that\n * describes a file or an object that can be treated as a file or a folder.\n */\nexport interface IFile extends IStoredFile {\n /**\n * The list of parents of the object. It is an ordered list of parents\n * from the top (first element) to the lowest parent in the tree (last element).\n *\n * After creating the object, this property cannot be manipulated directly by the client.\n * Should be treated as opaque value.\n */\n parents: string[]\n /**\n * The list of permissions to this file object.\n *\n * This property cannot be manipulated directly by the client. Should be treated as\n * opaque value.\n */\n permissionIds: string[]\n /**\n * Whether the file object is deleted.\n */\n deleted?: boolean\n /**\n * The information about the delete information.\n * Always set when the `delete` is true.\n */\n deletedInfo?: IDeletion\n /**\n * The last modification made to this file.\n */\n lastModified: IModification\n /**\n * An arbitrary list of labels applied to the file.\n */\n labels?: string[]\n /**\n * This is populated when reading a file from the store.\n * A list of actions the user can perform on the file.\n *\n * This is a readonly field and it is ignored when creating / updating the file.\n */\n capabilities?: ICapabilities\n /**\n * Populated by the server when reading the file. The list of permissions to the object.\n *\n * This property cannot be manipulated directly by the client. Should be treated as\n * opaque value.\n *\n * Data store implementation note, this is not stored in the store but it is populated\n * when reading the object.\n */\n permissions: IPermission[]\n /**\n * Populated by the store in some situations. If it's missing then you should request\n * breadcrumbs from the store.\n */\n breadcrumb?: FileBreadcrumb[]\n}\n\nconst parentsSymbol = Symbol('parents')\nconst deletedSymbol = Symbol('deleted')\nconst deletedInfoSymbol = Symbol('deletedInfo')\nconst lastModifiedSymbol = Symbol('lastModified')\nconst capabilitiesSymbol = Symbol('capabilities')\nconst permissionsSymbol = Symbol('permissions')\nconst permissionIdsSymbol = Symbol('permissionIds')\nconst shortcutTargetSymbol = Symbol('shortcutTarget')\n\nexport class StoredFile {\n /**\n * The kind of the File\n */\n kind = ''\n /**\n * The identifier of the entity\n */\n key = ''\n /**\n * The name of the environment.\n */\n info: Thing = Thing.fromName('')\n\n /**\n * The color of the icon to render for this file in the file explorer.\n */\n iconColor?: string\n\n /**\n * Whether the file is a shortcut to another file.\n * Many properties cannot be changed of a shortcut, like, shortcuts cannot be shared.\n */\n get isShortcut(): boolean {\n return !!this.shortcutTarget\n }\n\n [shortcutTargetSymbol]?: string\n\n /**\n * The ID of the target file.\n */\n get shortcutTarget(): string | undefined {\n return this[shortcutTargetSymbol]\n }\n\n set shortcutTarget(value: string | undefined) {\n this[shortcutTargetSymbol] = value\n }\n\n /**\n * Creates a file schema object with the given properties.\n * The `key` is generated if not set.\n *\n * @param input The input to create the file schema.\n * @returns The file schema object.\n */\n static createSchema(input: Partial<IStoredFile> = {}): IStoredFile {\n const { key = nanoid(), kind, iconColor, shortcutTarget } = input\n const result: IStoredFile = {\n key,\n kind: kind || '',\n info: Thing.fromJSON(input.info, { name: 'Unnamed file' }).toJSON(),\n }\n if (iconColor) {\n result.iconColor = iconColor\n }\n if (shortcutTarget) {\n result.isShortcut = true\n result.shortcutTarget = shortcutTarget\n }\n return result\n }\n\n constructor(state: IStoredFile) {\n this.kind = state.kind\n this.key = state.key\n this.info = new Thing(state.info)\n if (state.iconColor) {\n this.iconColor = state.iconColor\n }\n if (state.shortcutTarget) {\n this.shortcutTarget = state.shortcutTarget\n }\n }\n\n /**\n * @deprecated Use `createSchema()` and setup values in the constructor instead.\n */\n new(init: IStoredFile): this {\n const { key = nanoid(), info, kind, iconColor, shortcutTarget } = init\n this.key = key\n this.kind = kind\n if (info) {\n this.info = new Thing(info)\n } else {\n this.info = Thing.fromName('')\n }\n if (iconColor) {\n this.iconColor = iconColor\n } else {\n this.iconColor = undefined\n }\n if (shortcutTarget) {\n this.shortcutTarget = shortcutTarget\n } else {\n this.shortcutTarget = undefined\n }\n return this\n }\n\n toJSON(): IStoredFile {\n const result: IStoredFile = {\n key: this.key,\n kind: this.kind,\n info: this.info.toJSON(),\n }\n if (this.iconColor) {\n result.iconColor = this.iconColor\n }\n if (this.shortcutTarget) {\n result.isShortcut = true\n result.shortcutTarget = this.shortcutTarget\n }\n return result\n }\n\n /**\n * Creates the Capabilities object for a file giving user level.\n *\n * @param file The file object to create the capabilities to. The object is not mutated.\n * @param role The user role to the file.\n */\n static createFileCapabilities(file: IStoredFile | StoredFile, role?: PermissionRole): ICapabilities {\n const isCommenter = Permission.hasRole('commenter', role)\n const isOwner = Permission.hasRole('owner', role)\n const isReader = Permission.hasRole('reader', role)\n const isWriter = Permission.hasRole('writer', role)\n const isFolder = file.kind === FolderKind\n const result: ICapabilities = {\n canReadMedia: !isFolder && isReader,\n canListChildren: isFolder && isReader,\n canComment: !isFolder && isCommenter,\n canEditMedia: !isFolder && isWriter,\n canEditMeta: isWriter,\n canReadRevisions: isWriter,\n canAddChildren: isFolder && isWriter,\n canDelete: isOwner,\n canTrash: isOwner,\n canUntrash: isOwner,\n canShare: isWriter,\n canMove: isWriter,\n }\n return result\n }\n\n createFileCapabilities(role: PermissionRole): ICapabilities {\n return File.createFileCapabilities(this, role)\n }\n\n /**\n * Mutates the file object by setting the `byMe` properties (on deleted and modified info)\n *\n * Note, this can be done only on file schema (IFile). The `File` object has\n * this properties frozen.\n *\n * @param file The file to mutate\n * @param user The user key to compare.\n */\n static updateByMeMeta(file: IFile, user: string): void {\n if (file.deletedInfo) {\n file.deletedInfo.byMe = file.deletedInfo.user === user\n }\n if (file.lastModified) {\n file.lastModified.byMe = file.lastModified.user === user\n }\n }\n\n /**\n * Static method to set the `lastModified` property on a file without creating an instance of a file meta.\n * Useful when the meta kind is unknown.\n *\n * @param file The file to update. Note, this method mutates the file.\n * @param user The user that modifies the file.\n * @returns The same file.\n */\n static setLastModified(file: IFile, user: IUser): IFile {\n if (!file) {\n throw new Error(`The file is required.`)\n }\n if (!user) {\n throw new Error(`The user is required.`)\n }\n if (user.kind !== UserKind) {\n throw new Error(`Invalid value for the user when setting \"lastModified\".`)\n }\n file.lastModified = {\n byMe: false,\n time: Date.now(),\n user: user.key,\n name: user.name,\n }\n return file\n }\n\n /**\n * Similar to the instance method `setDeleted()` but without creating\n * an instance of the file when the type is unknown.\n *\n * @param file The file to change. Note, this operation mutates the file.\n * @param user The deleting user\n * @returns The same file reference.\n */\n static setDeleted(file: IFile, user: IUser): IFile {\n if (!file) {\n throw new Error(`The file is required.`)\n }\n if (!user) {\n throw new Error(`The user is required.`)\n }\n if (user.kind !== UserKind) {\n throw new Error(`Invalid value for the user when setting \"deletedInfo\".`)\n }\n file.deleted = true\n file.deletedInfo = {\n byMe: false,\n time: Date.now(),\n user: user.key,\n name: user.name,\n }\n return file\n }\n}\n\nexport class File extends StoredFile {\n [parentsSymbol]: string[] = []\n\n /**\n * The list of parents of the object. It is an ordered list of parents\n * from the top (first element) to the lowest parent in the tree (last element).\n *\n * This property cannot be manipulated directly by the client. Should be treated as\n * opaque value.\n */\n get parents(): string[] {\n return this[parentsSymbol]\n }\n\n [permissionIdsSymbol]: readonly string[] = []\n\n /**\n * The list of permissions to this file object.\n *\n * This property cannot be manipulated directly by the client. Should be treated as\n * opaque value.\n */\n get permissionIds(): readonly string[] {\n return this[permissionIdsSymbol]\n }\n\n [deletedSymbol]?: boolean\n\n /**\n * Whether the file object is deleted.\n */\n get deleted(): boolean {\n return this[deletedSymbol] || false\n }\n\n [deletedInfoSymbol]?: Readonly<IDeletion>\n\n /**\n * The information about the delete information.\n * Always set when the `delete` is true.\n */\n get deletedInfo(): Readonly<IDeletion> | undefined {\n return this[deletedInfoSymbol]\n }\n\n [lastModifiedSymbol]: Readonly<IModification> = { user: '', time: 0, byMe: false }\n\n /**\n * The last modification made to this file.\n */\n get lastModified(): Readonly<IModification> {\n return this[lastModifiedSymbol]\n }\n\n /**\n * An arbitrary list of labels applied to the file.\n */\n labels?: string[];\n\n [capabilitiesSymbol]?: Readonly<ICapabilities>\n\n /**\n * This is populated when reading a file from the store.\n * A list of actions the user can perform on the file.\n *\n * This is a readonly field and it is ignored when creating / updating the file.\n */\n get capabilities(): Readonly<ICapabilities> | undefined {\n return this[capabilitiesSymbol]\n }\n\n [permissionsSymbol]: readonly IPermission[] = []\n\n /**\n * Populated by the server when reading the file. The list of permissions to the object.\n *\n * This property cannot be manipulated directly by the client. Should be treated as\n * opaque value.\n */\n get permissions(): readonly IPermission[] {\n return this[permissionsSymbol]\n }\n\n static override createSchema(input: Partial<IFile> = {}): IFile {\n const result = StoredFile.createSchema(input) as IFile\n if (Array.isArray(input.parents)) {\n result.parents = [...input.parents]\n } else {\n result.parents = []\n }\n if (Array.isArray(input.permissionIds)) {\n result.permissionIds = [...input.permissionIds]\n } else {\n result.permissionIds = []\n }\n if (Array.isArray(input.permissions)) {\n result.permissions = input.permissions.map((i) => ({ ...i }))\n } else {\n result.permissions = []\n }\n if (input.capabilities) {\n result.capabilities = { ...input.capabilities }\n }\n if (input.lastModified) {\n result.lastModified = { ...input.lastModified }\n } else {\n result.lastModified = { user: '', time: 0, byMe: false }\n }\n if (typeof input.deleted === 'boolean') {\n result.deleted = input.deleted\n result.deletedInfo = input.deletedInfo ? { ...input.deletedInfo } : undefined\n }\n if (Array.isArray(input.labels)) {\n result.labels = [...input.labels]\n }\n if (typeof input.shortcutTarget === 'string') {\n result.shortcutTarget = input.shortcutTarget\n }\n return result\n }\n\n constructor(state?: Partial<IFile>) {\n const init = File.createSchema(state)\n super(init)\n this[parentsSymbol] = [...init.parents]\n this[permissionIdsSymbol] = [...init.permissionIds]\n this[permissionsSymbol] = init.permissions.map((i) => ({ ...i }))\n this[capabilitiesSymbol] = init.capabilities ? { ...init.capabilities } : undefined\n this[lastModifiedSymbol] = Object.freeze({ ...init.lastModified })\n if (typeof init.deleted === 'boolean') {\n this[deletedSymbol] = init.deleted\n this[deletedInfoSymbol] = init.deletedInfo ? Object.freeze({ ...init.deletedInfo }) : undefined\n }\n if (Array.isArray(init.labels)) {\n this.labels = [...init.labels]\n }\n }\n\n /**\n * @deprecated Use `createSchema()` and setup values in the constructor instead.\n */\n override new(init: IFile): this {\n super.new(init)\n const { permissions = [], parents = [], permissionIds = [], deleted, deletedInfo, lastModified, labels } = init\n this[permissionsSymbol] = permissions.map((i) => ({ ...i }))\n this[parentsSymbol] = [...parents]\n this[permissionIdsSymbol] = [...permissionIds]\n this[lastModifiedSymbol] = lastModified\n ? Object.freeze({ ...lastModified })\n : Object.freeze({ user: '', time: 0, byMe: false })\n if (typeof deleted === 'boolean') {\n this[deletedSymbol] = deleted\n this[deletedInfoSymbol] = deletedInfo ? Object.freeze({ ...deletedInfo }) : undefined\n } else {\n this[deletedSymbol] = undefined\n this[deletedInfoSymbol] = undefined\n }\n if (Array.isArray(labels)) {\n this.labels = [...labels]\n } else {\n this.labels = undefined\n }\n return this\n }\n\n override toJSON(): IFile {\n const result: IFile = {\n ...super.toJSON(),\n parents: [...this.parents],\n permissionIds: [...this.permissionIds],\n lastModified: { ...this.lastModified },\n permissions: [...this.permissions],\n }\n if (this.deleted) {\n result.deleted = this.deleted\n result.deletedInfo = { ...this.deletedInfo } as IDeletion\n }\n if (Array.isArray(this.labels)) {\n result.labels = [...this.labels]\n }\n return result\n }\n\n /**\n * @param name The name to set.\n * @param kind The kind of the file to create.\n */\n static fromName(name: string, kind: string): File {\n const definition = new File({ kind, info: { name } })\n return definition\n }\n\n shortcutTo(fileId: string): this {\n this.shortcutTarget = fileId\n return this\n }\n\n /**\n * Updates the \"lastModified\" value.\n * A helper method for a common task.\n *\n * @param user The user that modifies the entity.\n */\n setLastModified(user: IUser): void {\n if (!user) {\n throw new Error(`The user is required.`)\n }\n if (user.kind !== UserKind) {\n throw new Error(`Invalid value for the user when setting \"lastModified\".`)\n }\n this[lastModifiedSymbol] = {\n byMe: false,\n time: Date.now(),\n user: user.key,\n name: user.name,\n }\n }\n\n /**\n * Adds a label to the list of labels.\n *\n * It makes sure the value is a valid, non-empty string and the `labels` array is set.\n *\n * It does nothing when the label already exists.\n *\n * @param label The label to set.\n */\n addLabel(label: string): void {\n if (typeof label !== 'string') {\n throw new Error(`The label must be a string.`)\n }\n if (!label.trim()) {\n throw new Error(`The label is required.`)\n }\n if (!Array.isArray(this.labels)) {\n this.labels = []\n }\n if (this.labels.includes(label)) {\n return\n }\n this.labels.push(label)\n }\n\n /**\n * Marks the entity as deleted.\n *\n * A helper method for a common task.\n *\n * @param user The user that deletes the entity.\n */\n setDeleted(user: IUser): void {\n if (!user) {\n throw new Error(`The user is required.`)\n }\n if (user.kind !== UserKind) {\n throw new Error(`Invalid value for the user when setting \"deletedInfo\".`)\n }\n this[deletedSymbol] = true\n this[deletedInfoSymbol] = {\n byMe: false,\n time: Date.now(),\n user: user.key,\n name: user.name,\n }\n }\n\n isFile(): boolean {\n return this.kind !== FolderKind\n }\n\n isFolder(): boolean {\n return this.kind === FolderKind\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"File.js","sourceRoot":"","sources":["../../../../src/models/store/File.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAoB,UAAU,EAAkB,MAAM,iBAAiB,CAAA;AAG9E,OAAO,EAAc,IAAI,IAAI,QAAQ,EAAE,MAAM,WAAW,CAAA;AACxD,OAAO,EAAe,KAAK,EAAE,MAAM,aAAa,CAAA;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAyIxC,MAAM,aAAa,GAAG,MAAM,CAAC,SAA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YACxB,IAAI,EAAE,KAAK;YACX,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE;YAChB,IAAI,EAAE,IAAI,CAAC,GAAG;YACd,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAA;IACH,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,IAAI,KAAK,UAAU,CAAA;IACjC,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,IAAI,KAAK,UAAU,CAAA;IACjC,CAAC;CACF","sourcesContent":["import { nanoid } from '../../nanoid.js'\nimport { PermissionSchema, Permission, PermissionRole } from './Permission.js'\nimport { ModificationSchema } from './Modification.js'\nimport { DeletionSchema } from './Deletion.js'\nimport { UserSchema, Kind as UserKind } from './User.js'\nimport { ThingSchema, Thing } from '../Thing.js'\nimport { CapabilitiesSchema } from './Capabilities.js'\nimport { FolderKind } from '../kinds.js'\n// this causes error\n// import { Kind as FolderKind } from '../Folder.js';\n\nexport interface FileAddOptions {\n /**\n * The parent folder where to put the file.\n * The `parents` array is always cleared from the file object before adding it to the store.\n */\n parent?: string\n}\n\nexport interface MediaReadOptions {\n /**\n * When set it reads the file that was marked as `_deleted`. By default it throws when file was deleted.\n */\n deleted?: boolean\n}\n\n/**\n * A breadcrumb when creating the breadcrumb list for a file.\n */\nexport interface FileBreadcrumb {\n /**\n * The datastore key of the object.\n */\n key: string\n /**\n * THe kind of the object.\n */\n kind: string\n /**\n * The name of the object.\n */\n name: string\n}\n\nexport interface StoredFileSchema {\n /**\n * The kind of the File\n */\n kind: string\n /**\n * The identifier of the entity\n */\n key: string\n /**\n * The file's meta info.\n */\n info: ThingSchema\n /**\n * The color of the icon to render for this file in the file explorer.\n * This should be a hex format, e.g.: #c00 for red.\n */\n iconColor?: string\n /**\n * Whether the file is a shortcut to another file.\n * Many properties cannot be changed of a shortcut, like, shortcuts cannot be shared.\n */\n isShortcut?: boolean\n /**\n * The ID of the target file.\n */\n shortcutTarget?: string\n}\n\n/**\n * @deprecated Use {@link StoredFileSchema} instead.\n */\nexport type IStoredFile = StoredFileSchema\n\n/**\n * An interface describing an object in the data store that\n * describes a file or an object that can be treated as a file or a folder.\n */\nexport interface FileSchema extends StoredFileSchema {\n /**\n * The list of parents of the object. It is an ordered list of parents\n * from the top (first element) to the lowest parent in the tree (last element).\n *\n * After creating the object, this property cannot be manipulated directly by the client.\n * Should be treated as opaque value.\n */\n parents: string[]\n /**\n * The list of permissions to this file object.\n *\n * This property cannot be manipulated directly by the client. Should be treated as\n * opaque value.\n */\n permissionIds: string[]\n /**\n * Whether the file object is deleted.\n */\n deleted?: boolean\n /**\n * The information about the delete information.\n * Always set when the `delete` is true.\n */\n deletedInfo?: DeletionSchema\n /**\n * The last modification made to this file.\n */\n lastModified: ModificationSchema\n /**\n * An arbitrary list of labels applied to the file.\n */\n labels?: string[]\n /**\n * This is populated when reading a file from the store.\n * A list of actions the user can perform on the file.\n *\n * This is a readonly field and it is ignored when creating / updating the file.\n */\n capabilities?: CapabilitiesSchema\n /**\n * Populated by the server when reading the file. The list of permissions to the object.\n *\n * This property cannot be manipulated directly by the client. Should be treated as\n * opaque value.\n *\n * Data store implementation note, this is not stored in the store but it is populated\n * when reading the object.\n */\n permissions: PermissionSchema[]\n /**\n * Populated by the store in some situations. If it's missing then you should request\n * breadcrumbs from the store.\n */\n breadcrumb?: FileBreadcrumb[]\n}\n\n/**\n * @deprecated Use {@link FileSchema} instead.\n */\nexport type IFile = FileSchema\n\nconst parentsSymbol = Symbol('parents')\nconst deletedSymbol = Symbol('deleted')\nconst deletedInfoSymbol = Symbol('deletedInfo')\nconst lastModifiedSymbol = Symbol('lastModified')\nconst capabilitiesSymbol = Symbol('capabilities')\nconst permissionsSymbol = Symbol('permissions')\nconst permissionIdsSymbol = Symbol('permissionIds')\nconst shortcutTargetSymbol = Symbol('shortcutTarget')\n\nexport class StoredFile {\n /**\n * The kind of the File\n */\n kind = ''\n /**\n * The identifier of the entity\n */\n key = ''\n /**\n * The name of the environment.\n */\n info: Thing = Thing.fromName('')\n\n /**\n * The color of the icon to render for this file in the file explorer.\n */\n iconColor?: string\n\n /**\n * Whether the file is a shortcut to another file.\n * Many properties cannot be changed of a shortcut, like, shortcuts cannot be shared.\n */\n get isShortcut(): boolean {\n return !!this.shortcutTarget\n }\n\n [shortcutTargetSymbol]?: string\n\n /**\n * The ID of the target file.\n */\n get shortcutTarget(): string | undefined {\n return this[shortcutTargetSymbol]\n }\n\n set shortcutTarget(value: string | undefined) {\n this[shortcutTargetSymbol] = value\n }\n\n /**\n * Creates a file schema object with the given properties.\n * The `key` is generated if not set.\n *\n * @param input The input to create the file schema.\n * @returns The file schema object.\n */\n static createSchema(input: Partial<StoredFileSchema> = {}): StoredFileSchema {\n const { key = nanoid(), kind, iconColor, shortcutTarget } = input\n const result: StoredFileSchema = {\n key,\n kind: kind || '',\n info: Thing.fromJSON(input.info, { name: 'Unnamed file' }).toJSON(),\n }\n if (iconColor) {\n result.iconColor = iconColor\n }\n if (shortcutTarget) {\n result.isShortcut = true\n result.shortcutTarget = shortcutTarget\n }\n return result\n }\n\n constructor(state: StoredFileSchema) {\n this.kind = state.kind\n this.key = state.key\n this.info = new Thing(state.info)\n if (state.iconColor) {\n this.iconColor = state.iconColor\n }\n if (state.shortcutTarget) {\n this.shortcutTarget = state.shortcutTarget\n }\n }\n\n /**\n * @deprecated Use `createSchema()` and setup values in the constructor instead.\n */\n new(init: StoredFileSchema): this {\n const { key = nanoid(), info, kind, iconColor, shortcutTarget } = init\n this.key = key\n this.kind = kind\n if (info) {\n this.info = new Thing(info)\n } else {\n this.info = Thing.fromName('')\n }\n if (iconColor) {\n this.iconColor = iconColor\n } else {\n this.iconColor = undefined\n }\n if (shortcutTarget) {\n this.shortcutTarget = shortcutTarget\n } else {\n this.shortcutTarget = undefined\n }\n return this\n }\n\n toJSON(): StoredFileSchema {\n const result: StoredFileSchema = {\n key: this.key,\n kind: this.kind,\n info: this.info.toJSON(),\n }\n if (this.iconColor) {\n result.iconColor = this.iconColor\n }\n if (this.shortcutTarget) {\n result.isShortcut = true\n result.shortcutTarget = this.shortcutTarget\n }\n return result\n }\n\n /**\n * Creates the Capabilities object for a file giving user level.\n *\n * @param file The file object to create the capabilities to. The object is not mutated.\n * @param role The user role to the file.\n */\n static createFileCapabilities(file: StoredFileSchema | StoredFile, role?: PermissionRole): CapabilitiesSchema {\n const isCommenter = Permission.hasRole('commenter', role)\n const isOwner = Permission.hasRole('owner', role)\n const isReader = Permission.hasRole('reader', role)\n const isWriter = Permission.hasRole('writer', role)\n const isFolder = file.kind === FolderKind\n const result: CapabilitiesSchema = {\n canReadMedia: !isFolder && isReader,\n canListChildren: isFolder && isReader,\n canComment: !isFolder && isCommenter,\n canEditMedia: !isFolder && isWriter,\n canEditMeta: isWriter,\n canReadRevisions: isWriter,\n canAddChildren: isFolder && isWriter,\n canDelete: isOwner,\n canTrash: isOwner,\n canUntrash: isOwner,\n canShare: isWriter,\n canMove: isWriter,\n }\n return result\n }\n\n createFileCapabilities(role: PermissionRole): CapabilitiesSchema {\n return File.createFileCapabilities(this, role)\n }\n\n /**\n * Mutates the file object by setting the `byMe` properties (on deleted and modified info)\n *\n * Note, this can be done only on file schema (FileSchema). The `File` object has\n * this properties frozen.\n *\n * @param file The file to mutate\n * @param user The user key to compare.\n */\n static updateByMeMeta(file: FileSchema, user: string): void {\n if (file.deletedInfo) {\n file.deletedInfo.byMe = file.deletedInfo.user === user\n }\n if (file.lastModified) {\n file.lastModified.byMe = file.lastModified.user === user\n }\n }\n\n /**\n * Static method to set the `lastModified` property on a file without creating an instance of a file meta.\n * Useful when the meta kind is unknown.\n *\n * @param file The file to update. Note, this method mutates the file.\n * @param user The user that modifies the file.\n * @returns The same file.\n */\n static setLastModified(file: FileSchema, user: UserSchema): FileSchema {\n if (!file) {\n throw new Error(`The file is required.`)\n }\n if (!user) {\n throw new Error(`The user is required.`)\n }\n if (user.kind !== UserKind) {\n throw new Error(`Invalid value for the user when setting \"lastModified\".`)\n }\n file.lastModified = {\n byMe: false,\n time: Date.now(),\n user: user.key,\n name: user.name,\n }\n return file\n }\n\n /**\n * Similar to the instance method `setDeleted()` but without creating\n * an instance of the file when the type is unknown.\n *\n * @param file The file to change. Note, this operation mutates the file.\n * @param user The deleting user\n * @returns The same file reference.\n */\n static setDeleted(file: FileSchema, user: UserSchema): FileSchema {\n if (!file) {\n throw new Error(`The file is required.`)\n }\n if (!user) {\n throw new Error(`The user is required.`)\n }\n if (user.kind !== UserKind) {\n throw new Error(`Invalid value for the user when setting \"deletedInfo\".`)\n }\n file.deleted = true\n file.deletedInfo = {\n byMe: false,\n time: Date.now(),\n user: user.key,\n name: user.name,\n }\n return file\n }\n}\n\nexport class File extends StoredFile {\n [parentsSymbol]: string[] = []\n\n /**\n * The list of parents of the object. It is an ordered list of parents\n * from the top (first element) to the lowest parent in the tree (last element).\n *\n * This property cannot be manipulated directly by the client. Should be treated as\n * opaque value.\n */\n get parents(): string[] {\n return this[parentsSymbol]\n }\n\n [permissionIdsSymbol]: readonly string[] = []\n\n /**\n * The list of permissions to this file object.\n *\n * This property cannot be manipulated directly by the client. Should be treated as\n * opaque value.\n */\n get permissionIds(): readonly string[] {\n return this[permissionIdsSymbol]\n }\n\n [deletedSymbol]?: boolean\n\n /**\n * Whether the file object is deleted.\n */\n get deleted(): boolean {\n return this[deletedSymbol] || false\n }\n\n [deletedInfoSymbol]?: Readonly<DeletionSchema>\n\n /**\n * The information about the delete information.\n * Always set when the `delete` is true.\n */\n get deletedInfo(): Readonly<DeletionSchema> | undefined {\n return this[deletedInfoSymbol]\n }\n\n [lastModifiedSymbol]: Readonly<ModificationSchema> = { user: '', time: 0, byMe: false }\n\n /**\n * The last modification made to this file.\n */\n get lastModified(): Readonly<ModificationSchema> {\n return this[lastModifiedSymbol]\n }\n\n /**\n * An arbitrary list of labels applied to the file.\n */\n labels?: string[];\n\n [capabilitiesSymbol]?: Readonly<CapabilitiesSchema>\n\n /**\n * This is populated when reading a file from the store.\n * A list of actions the user can perform on the file.\n *\n * This is a readonly field and it is ignored when creating / updating the file.\n */\n get capabilities(): Readonly<CapabilitiesSchema> | undefined {\n return this[capabilitiesSymbol]\n }\n\n [permissionsSymbol]: readonly PermissionSchema[] = []\n\n /**\n * Populated by the server when reading the file. The list of permissions to the object.\n *\n * This property cannot be manipulated directly by the client. Should be treated as\n * opaque value.\n */\n get permissions(): readonly PermissionSchema[] {\n return this[permissionsSymbol]\n }\n\n static override createSchema(input: Partial<FileSchema> = {}): FileSchema {\n const result = StoredFile.createSchema(input) as FileSchema\n if (Array.isArray(input.parents)) {\n result.parents = [...input.parents]\n } else {\n result.parents = []\n }\n if (Array.isArray(input.permissionIds)) {\n result.permissionIds = [...input.permissionIds]\n } else {\n result.permissionIds = []\n }\n if (Array.isArray(input.permissions)) {\n result.permissions = input.permissions.map((i) => ({ ...i }))\n } else {\n result.permissions = []\n }\n if (input.capabilities) {\n result.capabilities = { ...input.capabilities }\n }\n if (input.lastModified) {\n result.lastModified = { ...input.lastModified }\n } else {\n result.lastModified = { user: '', time: 0, byMe: false }\n }\n if (typeof input.deleted === 'boolean') {\n result.deleted = input.deleted\n result.deletedInfo = input.deletedInfo ? { ...input.deletedInfo } : undefined\n }\n if (Array.isArray(input.labels)) {\n result.labels = [...input.labels]\n }\n if (typeof input.shortcutTarget === 'string') {\n result.shortcutTarget = input.shortcutTarget\n }\n return result\n }\n\n constructor(state?: Partial<FileSchema>) {\n const init = File.createSchema(state)\n super(init)\n this[parentsSymbol] = [...init.parents]\n this[permissionIdsSymbol] = [...init.permissionIds]\n this[permissionsSymbol] = init.permissions.map((i) => ({ ...i }))\n this[capabilitiesSymbol] = init.capabilities ? { ...init.capabilities } : undefined\n this[lastModifiedSymbol] = Object.freeze({ ...init.lastModified })\n if (typeof init.deleted === 'boolean') {\n this[deletedSymbol] = init.deleted\n this[deletedInfoSymbol] = init.deletedInfo ? Object.freeze({ ...init.deletedInfo }) : undefined\n }\n if (Array.isArray(init.labels)) {\n this.labels = [...init.labels]\n }\n }\n\n /**\n * @deprecated Use `createSchema()` and setup values in the constructor instead.\n */\n override new(init: FileSchema): this {\n super.new(init)\n const { permissions = [], parents = [], permissionIds = [], deleted, deletedInfo, lastModified, labels } = init\n this[permissionsSymbol] = permissions.map((i) => ({ ...i }))\n this[parentsSymbol] = [...parents]\n this[permissionIdsSymbol] = [...permissionIds]\n this[lastModifiedSymbol] = lastModified\n ? Object.freeze({ ...lastModified })\n : Object.freeze({ user: '', time: 0, byMe: false })\n if (typeof deleted === 'boolean') {\n this[deletedSymbol] = deleted\n this[deletedInfoSymbol] = deletedInfo ? Object.freeze({ ...deletedInfo }) : undefined\n } else {\n this[deletedSymbol] = undefined\n this[deletedInfoSymbol] = undefined\n }\n if (Array.isArray(labels)) {\n this.labels = [...labels]\n } else {\n this.labels = undefined\n }\n return this\n }\n\n override toJSON(): FileSchema {\n const result: FileSchema = {\n ...super.toJSON(),\n parents: [...this.parents],\n permissionIds: [...this.permissionIds],\n lastModified: { ...this.lastModified },\n permissions: [...this.permissions],\n }\n if (this.deleted) {\n result.deleted = this.deleted\n result.deletedInfo = { ...this.deletedInfo } as DeletionSchema\n }\n if (Array.isArray(this.labels)) {\n result.labels = [...this.labels]\n }\n return result\n }\n\n /**\n * @param name The name to set.\n * @param kind The kind of the file to create.\n */\n static fromName(name: string, kind: string): File {\n const definition = new File({ kind, info: { name } })\n return definition\n }\n\n shortcutTo(fileId: string): this {\n this.shortcutTarget = fileId\n return this\n }\n\n /**\n * Updates the \"lastModified\" value.\n * A helper method for a common task.\n *\n * @param user The user that modifies the entity.\n */\n setLastModified(user: UserSchema): void {\n if (!user) {\n throw new Error(`The user is required.`)\n }\n if (user.kind !== UserKind) {\n throw new Error(`Invalid value for the user when setting \"lastModified\".`)\n }\n this[lastModifiedSymbol] = {\n byMe: false,\n time: Date.now(),\n user: user.key,\n name: user.name,\n }\n }\n\n /**\n * Adds a label to the list of labels.\n *\n * It makes sure the value is a valid, non-empty string and the `labels` array is set.\n *\n * It does nothing when the label already exists.\n *\n * @param label The label to set.\n */\n addLabel(label: string): void {\n if (typeof label !== 'string') {\n throw new Error(`The label must be a string.`)\n }\n if (!label.trim()) {\n throw new Error(`The label is required.`)\n }\n if (!Array.isArray(this.labels)) {\n this.labels = []\n }\n if (this.labels.includes(label)) {\n return\n }\n this.labels.push(label)\n }\n\n /**\n * Marks the entity as deleted.\n *\n * A helper method for a common task.\n *\n * @param user The user that deletes the entity.\n */\n setDeleted(user: UserSchema): void {\n if (!user) {\n throw new Error(`The user is required.`)\n }\n if (user.kind !== UserKind) {\n throw new Error(`Invalid value for the user when setting \"deletedInfo\".`)\n }\n this[deletedSymbol] = true\n this[deletedInfoSymbol] = {\n byMe: false,\n time: Date.now(),\n user: user.key,\n name: user.name,\n }\n }\n\n isFile(): boolean {\n return this.kind !== FolderKind\n }\n\n isFolder(): boolean {\n return this.kind === FolderKind\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GroupKind } from '../kinds.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { DeletionSchema } from './Deletion.js';
|
|
3
3
|
/**
|
|
4
4
|
* @deprecated Use `GroupSchema` instead.
|
|
5
5
|
* This interface is kept for backward compatibility.
|
|
@@ -73,7 +73,7 @@ export interface GroupSchema {
|
|
|
73
73
|
* This field is ignored by the API and is set automatically.
|
|
74
74
|
* @readonly
|
|
75
75
|
*/
|
|
76
|
-
deleteInfo?:
|
|
76
|
+
deleteInfo?: DeletionSchema;
|
|
77
77
|
}
|
|
78
78
|
export declare class Group implements GroupSchema {
|
|
79
79
|
kind: typeof GroupKind;
|
|
@@ -87,7 +87,7 @@ export declare class Group implements GroupSchema {
|
|
|
87
87
|
users: string[];
|
|
88
88
|
createdAt: number;
|
|
89
89
|
updatedAt: number;
|
|
90
|
-
deleteInfo?:
|
|
90
|
+
deleteInfo?: DeletionSchema;
|
|
91
91
|
static createSchema(input?: Partial<GroupSchema>): GroupSchema;
|
|
92
92
|
static fromName(name: string, oid: string): Group;
|
|
93
93
|
constructor(state?: Partial<GroupSchema>);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Group.d.ts","sourceRoot":"","sources":["../../../../src/models/store/Group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"Group.d.ts","sourceRoot":"","sources":["../../../../src/models/store/Group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAGnD;;;GAGG;AAEH,MAAM,WAAW,MAAO,SAAQ,WAAW;CAAG;AAE9C;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,OAAO,SAAS,CAAA;IACtB;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;;;OAIG;IACH,KAAK,EAAE,MAAM,EAAE,CAAA;IACf;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB;;;;OAIG;IACH,UAAU,CAAC,EAAE,cAAc,CAAA;CAC5B;AAED,qBAAa,KAAM,YAAW,WAAW;IACvC,IAAI,EAAE,OAAO,SAAS,CAAY;IAClC,GAAG,SAAK;IACR,IAAI,SAAK;IACT,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,SAAK;IACV,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,GAAG,SAAK;IACR,KAAK,EAAE,MAAM,EAAE,CAAK;IACpB,SAAS,SAAI;IACb,SAAS,SAAI;IACb,UAAU,CAAC,EAAE,cAAc,CAAA;IAE3B,MAAM,CAAC,YAAY,CAAC,KAAK,GAAE,OAAO,CAAC,WAAW,CAAM,GAAG,WAAW;IA2BlE,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,KAAK;gBAIrC,KAAK,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC;IAexC,MAAM,IAAI,WAAW;CAyBtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Group.js","sourceRoot":"","sources":["../../../../src/models/store/Group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AA+ExC,MAAM,OAAO,KAAK;IAChB,IAAI,GAAqB,SAAS,CAAA;IAClC,GAAG,GAAG,EAAE,CAAA;IACR,IAAI,GAAG,EAAE,CAAA;IACT,WAAW,CAAS;IACpB,KAAK,GAAG,EAAE,CAAA;IACV,IAAI,CAAS;IACb,KAAK,CAAS;IACd,GAAG,GAAG,EAAE,CAAA;IACR,KAAK,GAAa,EAAE,CAAA;IACpB,SAAS,GAAG,CAAC,CAAA;IACb,SAAS,GAAG,CAAC,CAAA;IACb,UAAU,
|
|
1
|
+
{"version":3,"file":"Group.js","sourceRoot":"","sources":["../../../../src/models/store/Group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AA+ExC,MAAM,OAAO,KAAK;IAChB,IAAI,GAAqB,SAAS,CAAA;IAClC,GAAG,GAAG,EAAE,CAAA;IACR,IAAI,GAAG,EAAE,CAAA;IACT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AI,IAAI,CAAC,IAAI,EAAE,CAAC;YACd,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA;QACzB,CAAC;QACD,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAA;QAC3B,CAAC;QACD,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,MAAM,CAAC,UAAU,GAAG,EAAE,GAAG,IAAI,CAAC,UAAU,EAAE,CAAA;QAC5C,CAAC;QACD,OAAO,MAAM,CAAA;IACf,CAAC;CACF","sourcesContent":["import { GroupKind } from '../kinds.js'\nimport type { DeletionSchema } from './Deletion.js'\nimport { nanoid } from '../../nanoid.js'\n\n/**\n * @deprecated Use `GroupSchema` instead.\n * This interface is kept for backward compatibility.\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface IGroup extends GroupSchema {}\n\n/**\n * An object representing a user group.\n */\nexport interface GroupSchema {\n kind: typeof GroupKind\n /**\n * The key of the group.\n * If not provided, it will be generated automatically by the API\n */\n key: string\n /**\n * The name of the group.\n * This is a required field and must be unique within the organization.\n * @required\n */\n name: string\n /**\n * The description of the group.\n */\n description?: string\n /**\n * The id of the user that created this group.\n * This field is ignored by the API and is set automatically.\n * @readonly\n */\n owner: string\n /**\n * The icon of the group, if any.\n * An optional icon for the group, stored as a URL or path.\n * Max 255 characters.\n */\n icon?: string\n /**\n * The color of the group, if any.\n * An optional color for the group, stored as a hex code.\n * Max 50 characters (including the #).\n */\n color?: string\n /**\n * The organization ID this group belongs to.\n * This field is ignored by the API and is set automatically.\n * @readonly\n */\n oid: string\n /**\n * The list of users in this group.\n * This field is ignored by the API and is set automatically.\n * @readonly\n */\n users: string[]\n /**\n * Describes when this group was created\n * This field is ignored by the API and is set automatically.\n * @readonly\n */\n createdAt: number\n /**\n * Describes when this group was updated\n * This field is ignored by the API and is set automatically.\n * @readonly\n */\n updatedAt: number\n /**\n * Optional deletion information if the group has been deleted.\n * This field is ignored by the API and is set automatically.\n * @readonly\n */\n deleteInfo?: DeletionSchema\n}\n\nexport class Group implements GroupSchema {\n kind: typeof GroupKind = GroupKind\n key = ''\n name = ''\n description?: string\n owner = ''\n icon?: string\n color?: string\n oid = ''\n users: string[] = []\n createdAt = 0\n updatedAt = 0\n deleteInfo?: DeletionSchema\n\n static createSchema(input: Partial<GroupSchema> = {}): GroupSchema {\n const { key = nanoid() } = input\n const result: GroupSchema = {\n kind: GroupKind,\n key,\n name: input.name || 'Unnamed group',\n oid: input.oid || '',\n owner: input.owner || '',\n users: input.users || [],\n createdAt: input.createdAt || Date.now(),\n updatedAt: input.updatedAt || Date.now(),\n }\n if (input.description) {\n result.description = input.description\n }\n if (input.icon) {\n result.icon = input.icon\n }\n if (input.color) {\n result.color = input.color\n }\n if (input.deleteInfo) {\n result.deleteInfo = input.deleteInfo\n }\n return result\n }\n\n static fromName(name: string, oid: string): Group {\n return new Group({ name, oid })\n }\n\n constructor(state?: Partial<GroupSchema>) {\n const init = Group.createSchema(state)\n this.key = init.key\n this.name = init.name\n this.description = init.description\n this.owner = init.owner\n this.icon = init.icon\n this.color = init.color\n this.oid = init.oid\n this.users = init.users\n this.createdAt = init.createdAt\n this.updatedAt = init.updatedAt\n this.deleteInfo = init.deleteInfo\n }\n\n toJSON(): GroupSchema {\n const result: GroupSchema = {\n kind: this.kind,\n key: GroupKind,\n name: this.name,\n oid: this.oid,\n owner: this.owner,\n users: [...this.users],\n createdAt: this.createdAt,\n updatedAt: this.updatedAt,\n }\n if (this.description) {\n result.description = this.description\n }\n if (this.icon) {\n result.icon = this.icon\n }\n if (this.color) {\n result.color = this.color\n }\n if (this.deleteInfo) {\n result.deleteInfo = { ...this.deleteInfo }\n }\n return result\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InvitationKind } from '../kinds.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { DeletionSchema } from './Deletion.js';
|
|
3
3
|
import type { UserOrganizationGrantType } from './Organization.js';
|
|
4
4
|
import type { Operation } from '@api-client/json/types.js';
|
|
5
5
|
import { Builder } from '@api-client/json/patch/builder.js';
|
|
@@ -70,7 +70,7 @@ export interface InvitationSchema {
|
|
|
70
70
|
* The information about the delete information.
|
|
71
71
|
* Always set when the `delete` is true.
|
|
72
72
|
*/
|
|
73
|
-
deletedInfo?:
|
|
73
|
+
deletedInfo?: DeletionSchema;
|
|
74
74
|
/**
|
|
75
75
|
* The timestamp when the invitation was created.
|
|
76
76
|
*/
|
|
@@ -107,7 +107,7 @@ export declare class Invitation implements InvitationSchema {
|
|
|
107
107
|
status: InvitationStatus;
|
|
108
108
|
grantType: UserOrganizationGrantType;
|
|
109
109
|
deleted: boolean;
|
|
110
|
-
deletedInfo:
|
|
110
|
+
deletedInfo: DeletionSchema | undefined;
|
|
111
111
|
createdAt: number;
|
|
112
112
|
updatedAt: number;
|
|
113
113
|
resent: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Invitation.d.ts","sourceRoot":"","sources":["../../../../src/models/store/Invitation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"Invitation.d.ts","sourceRoot":"","sources":["../../../../src/models/store/Invitation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAA;AAE3D;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,CAAA;AAElE;;;GAGG;AACH,MAAM,W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'\nimport { InvitationKind } from '../kinds.js'\nimport type { IDeletion } from './Deletion.js'\nimport type { UserOrganizationGrantType } from './Organization.js'\nimport type { Operation } from '@api-client/json/types.js'\nimport { Builder } from '@api-client/json/patch/builder.js'\n\n/**\n * The status of an invitation.\n * - `pending`: The invitation has been sent but not yet responded to.\n * - `accepted`: The invitation has been accepted by the user.\n * - `declined`: The invitation has been declined by the user.\n */\nexport type InvitationStatus = 'pending' | 'accepted' | 'declined'\n\n/**\n * The schema for an invitation.\n * This defines the structure of an invitation object in the system.\n */\nexport interface InvitationSchema {\n /**\n * The kind of the invitation.\n */\n kind: typeof InvitationKind\n /**\n * The database ID of the invitation.\n */\n key: string\n /**\n * The user ID of the user who sent the invitation.\n */\n uid: string\n /**\n * The organization ID to which the invitation belongs.\n */\n oid: string\n /**\n * The email address of the user to whom the invitation is sent.\n */\n email: string\n /**\n * The name of the user to whom the invitation is sent.\n * This is optional and can be empty if the user is not known.\n */\n name?: string\n /**\n * The token used to respond to the invitation.\n */\n token: string\n /**\n * The timestamp when the invitation expires.\n * This is used to determine if the invitation is still valid.\n */\n expiresAt: number\n /**\n * The timestamp when the invitation was responded to.\n * This is set when the user accepts or declines the invitation.\n */\n respondedAt?: number\n /**\n * The status of the invitation.\n */\n status: InvitationStatus\n /**\n * The grant type the user will have in the organization if they accept the invitation.\n */\n grantType: UserOrganizationGrantType\n /**\n * Whether the file object is deleted.\n */\n deleted?: boolean\n /**\n * The information about the delete information.\n * Always set when the `delete` is true.\n */\n deletedInfo?: IDeletion\n /**\n * The timestamp when the invitation was created.\n */\n createdAt: number\n /**\n * The timestamp when the invitation was last updated.\n */\n updatedAt: number\n /**\n * Number of times the invitation was resent to the user.\n */\n resent: number\n /**\n * The timestamp when the invitation was last sent.\n * This is used to track when the invitation was last communicated to the user.\n */\n lastSentAt: number\n}\n\n/**\n * Represents an invitation to join an organization.\n * This class implements the `InvitationSchema` interface and provides methods to create and manipulate invitations.\n */\nexport class Invitation implements InvitationSchema {\n kind: typeof InvitationKind\n key: string\n uid: string\n oid: string\n email: string\n name: string | undefined\n token: string\n expiresAt: number\n respondedAt: number | undefined\n status: InvitationStatus\n grantType: UserOrganizationGrantType\n deleted: boolean\n deletedInfo: IDeletion | undefined\n createdAt: number\n updatedAt: number\n resent: number\n lastSentAt: number\n\n #builder?: Builder<InvitationSchema>\n\n /**\n * The patch builder for this invitation.\n */\n get builder(): Builder<InvitationSchema> {\n if (!this.#builder) {\n this.#builder = new Builder(this.toJSON())\n }\n return this.#builder\n }\n\n /**\n * Creates a full invitation schema with defaults.\n *\n * @param input The partial invitation schema.\n * @returns The invitation schema.\n */\n static createSchema(input: Partial<InvitationSchema> = {}): InvitationSchema {\n const {\n key = nanoid(),\n email,\n oid,\n grantType,\n uid = '',\n updatedAt = 0,\n createdAt = 0,\n expiresAt = 0,\n resent = 0,\n lastSentAt = 0,\n status = 'pending',\n token = '',\n } = input\n if (!email) {\n throw new Error('Email is required to create an invitation schema.')\n }\n if (!oid) {\n throw new Error('Organization ID is required to create an invitation schema.')\n }\n if (!grantType) {\n throw new Error('Grant type is required to create an invitation schema.')\n }\n const result: InvitationSchema = {\n kind: InvitationKind,\n key,\n uid,\n oid,\n email,\n grantType,\n token,\n expiresAt,\n status,\n createdAt,\n updatedAt,\n resent,\n lastSentAt,\n }\n if (input.name) {\n result.name = input.name\n }\n if (input.token) {\n result.token = input.token\n }\n if (input.expiresAt) {\n result.expiresAt = input.expiresAt\n }\n if (input.respondedAt) {\n result.respondedAt = input.respondedAt\n }\n if (input.status) {\n result.status = input.status\n }\n if (input.deleted) {\n result.deleted = input.deleted\n result.deletedInfo = input.deletedInfo\n }\n return result\n }\n\n constructor(input?: Partial<InvitationSchema>) {\n const init: InvitationSchema = Invitation.createSchema(input)\n this.kind = InvitationKind\n this.key = init.key\n this.uid = init.uid\n this.oid = init.oid\n this.email = init.email\n this.name = init.name\n this.token = init.token\n this.expiresAt = init.expiresAt\n this.respondedAt = init.respondedAt\n this.status = init.status\n this.grantType = init.grantType\n this.deleted = init.deleted || false\n this.deletedInfo = init.deletedInfo\n this.createdAt = init.createdAt\n this.updatedAt = init.updatedAt\n this.resent = init.resent\n this.lastSentAt = init.lastSentAt\n }\n\n toJSON(): InvitationSchema {\n const result: InvitationSchema = {\n kind: this.kind,\n key: this.key,\n uid: this.uid,\n oid: this.oid,\n email: this.email,\n token: this.token,\n expiresAt: this.expiresAt,\n status: this.status,\n grantType: this.grantType,\n deleted: this.deleted,\n createdAt: this.createdAt,\n updatedAt: this.updatedAt,\n resent: this.resent,\n lastSentAt: this.lastSentAt,\n }\n if (this.name) {\n result.name = this.name\n }\n if (this.respondedAt) {\n result.respondedAt = this.respondedAt\n }\n if (this.deletedInfo) {\n result.deletedInfo = { ...this.deletedInfo }\n }\n return result\n }\n\n /**\n * Retrieves the patch operations for this invitation.\n * This method builds a JSON Patch representation of the invitation,\n * which can be used to update the invitation in a database or API.\n *\n * Use one of the `set*` methods to modify the invitation before calling this method.\n *\n * @returns An array of patch operations.\n * If no changes have been made, it returns an empty array.\n */\n getPatch(): Operation[] {\n if (!this.#builder) {\n return []\n }\n return this.builder.build()\n }\n\n /**\n * Sets the name of the user to whom the invitation is sent.\n * If the name is the same as the current name, no operation is performed.\n *\n * @param name The name to set. If undefined, it will be removed.\n */\n setName(name?: string): void {\n if (name === this.name) {\n return\n }\n const hasName = !!this.name\n if (hasName && !name) {\n this.builder.remove('/name')\n } else {\n // The add method handles both adding and replacing\n this.builder.add('/name', name)\n }\n this.name = name\n }\n\n /**\n * Sets the expiration timestamp of the invitation.\n * @param expiresAt The timestamp when the invitation expires.\n * If the expiresAt is the same as the current expiresAt, no operation is performed.\n */\n setExpiresAt(expiresAt: number): void {\n if (this.expiresAt !== expiresAt) {\n this.builder.replace('/expiresAt', expiresAt)\n this.expiresAt = expiresAt\n }\n }\n\n /**\n * Sets the grant type of the user in the organization.\n */\n setGrantType(grantType: UserOrganizationGrantType): void {\n if (this.grantType !== grantType) {\n this.builder.replace('/grantType', grantType)\n this.grantType = grantType\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Invitation.js","sourceRoot":"","sources":["../../../../src/models/store/Invitation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAI5C,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAA;AA0F3D;;;GAGG;AACH,MAAM,OAAO,UAAU;IACrB,IAAI,CAAuB;IAC3B,GAAG,CAAQ;IACX,GAAG,CAAQ;IACX,GAAG,CAAQ;IACX,KAAK,CAAQ;IACb,IAAI,CAAoB;IACxB,KAAK,CAAQ;IACb,SAAS,CAAQ;IACjB,WAAW,CAAoB;IAC/B,MAAM,CAAkB;IACxB,SAAS,CAA2B;IACpC,OAAO,CAAS;IAChB,WAAW,CAA4B;IACvC,SAAS,CAAQ;IACjB,SAAS,CAAQ;IACjB,MAAM,CAAQ;IACd,UAAU,CAAQ;IAElB,QAAQ,CAA4B;IAEpC;;OAEG;IACH,IAAI,OAAO;QACT,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnB,IAAI,CAAC,QAAQ,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAA;QAC5C,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAA;IACtB,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,YAAY,CAAC,QAAmC,EAAE;QACvD,MAAM,EACJ,GAAG,GAAG,MAAM,EAAE,EACd,KAAK,EACL,GAAG,EACH,SAAS,EACT,GAAG,GAAG,EAAE,EACR,SAAS,GAAG,CAAC,EACb,SAAS,GAAG,CAAC,EACb,SAAS,GAAG,CAAC,EACb,MAAM,GAAG,CAAC,EACV,UAAU,GAAG,CAAC,EACd,MAAM,GAAG,SAAS,EAClB,KAAK,GAAG,EAAE,GACX,GAAG,KAAK,CAAA;QACT,IAAI,CAAC,KA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,EAAE,IAAI,CAAC,CAAA;QACjC,CAAC;QACD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAED;;;;OAIG;IACH,YAAY,CAAC,SAAiB;QAC5B,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,EAAE,SAAS,CAAC,CAAA;YAC7C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC5B,CAAC;IACH,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,SAAoC;QAC/C,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,EAAE,SAAS,CAAC,CAAA;YAC7C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC5B,CAAC;IACH,CAAC;CACF","sourcesContent":["import { nanoid } from '../../nanoid.js'\nimport { InvitationKind } from '../kinds.js'\nimport type { DeletionSchema } from './Deletion.js'\nimport type { UserOrganizationGrantType } from './Organization.js'\nimport type { Operation } from '@api-client/json/types.js'\nimport { Builder } from '@api-client/json/patch/builder.js'\n\n/**\n * The status of an invitation.\n * - `pending`: The invitation has been sent but not yet responded to.\n * - `accepted`: The invitation has been accepted by the user.\n * - `declined`: The invitation has been declined by the user.\n */\nexport type InvitationStatus = 'pending' | 'accepted' | 'declined'\n\n/**\n * The schema for an invitation.\n * This defines the structure of an invitation object in the system.\n */\nexport interface InvitationSchema {\n /**\n * The kind of the invitation.\n */\n kind: typeof InvitationKind\n /**\n * The database ID of the invitation.\n */\n key: string\n /**\n * The user ID of the user who sent the invitation.\n */\n uid: string\n /**\n * The organization ID to which the invitation belongs.\n */\n oid: string\n /**\n * The email address of the user to whom the invitation is sent.\n */\n email: string\n /**\n * The name of the user to whom the invitation is sent.\n * This is optional and can be empty if the user is not known.\n */\n name?: string\n /**\n * The token used to respond to the invitation.\n */\n token: string\n /**\n * The timestamp when the invitation expires.\n * This is used to determine if the invitation is still valid.\n */\n expiresAt: number\n /**\n * The timestamp when the invitation was responded to.\n * This is set when the user accepts or declines the invitation.\n */\n respondedAt?: number\n /**\n * The status of the invitation.\n */\n status: InvitationStatus\n /**\n * The grant type the user will have in the organization if they accept the invitation.\n */\n grantType: UserOrganizationGrantType\n /**\n * Whether the file object is deleted.\n */\n deleted?: boolean\n /**\n * The information about the delete information.\n * Always set when the `delete` is true.\n */\n deletedInfo?: DeletionSchema\n /**\n * The timestamp when the invitation was created.\n */\n createdAt: number\n /**\n * The timestamp when the invitation was last updated.\n */\n updatedAt: number\n /**\n * Number of times the invitation was resent to the user.\n */\n resent: number\n /**\n * The timestamp when the invitation was last sent.\n * This is used to track when the invitation was last communicated to the user.\n */\n lastSentAt: number\n}\n\n/**\n * Represents an invitation to join an organization.\n * This class implements the `InvitationSchema` interface and provides methods to create and manipulate invitations.\n */\nexport class Invitation implements InvitationSchema {\n kind: typeof InvitationKind\n key: string\n uid: string\n oid: string\n email: string\n name: string | undefined\n token: string\n expiresAt: number\n respondedAt: number | undefined\n status: InvitationStatus\n grantType: UserOrganizationGrantType\n deleted: boolean\n deletedInfo: DeletionSchema | undefined\n createdAt: number\n updatedAt: number\n resent: number\n lastSentAt: number\n\n #builder?: Builder<InvitationSchema>\n\n /**\n * The patch builder for this invitation.\n */\n get builder(): Builder<InvitationSchema> {\n if (!this.#builder) {\n this.#builder = new Builder(this.toJSON())\n }\n return this.#builder\n }\n\n /**\n * Creates a full invitation schema with defaults.\n *\n * @param input The partial invitation schema.\n * @returns The invitation schema.\n */\n static createSchema(input: Partial<InvitationSchema> = {}): InvitationSchema {\n const {\n key = nanoid(),\n email,\n oid,\n grantType,\n uid = '',\n updatedAt = 0,\n createdAt = 0,\n expiresAt = 0,\n resent = 0,\n lastSentAt = 0,\n status = 'pending',\n token = '',\n } = input\n if (!email) {\n throw new Error('Email is required to create an invitation schema.')\n }\n if (!oid) {\n throw new Error('Organization ID is required to create an invitation schema.')\n }\n if (!grantType) {\n throw new Error('Grant type is required to create an invitation schema.')\n }\n const result: InvitationSchema = {\n kind: InvitationKind,\n key,\n uid,\n oid,\n email,\n grantType,\n token,\n expiresAt,\n status,\n createdAt,\n updatedAt,\n resent,\n lastSentAt,\n }\n if (input.name) {\n result.name = input.name\n }\n if (input.token) {\n result.token = input.token\n }\n if (input.expiresAt) {\n result.expiresAt = input.expiresAt\n }\n if (input.respondedAt) {\n result.respondedAt = input.respondedAt\n }\n if (input.status) {\n result.status = input.status\n }\n if (input.deleted) {\n result.deleted = input.deleted\n result.deletedInfo = input.deletedInfo\n }\n return result\n }\n\n constructor(input?: Partial<InvitationSchema>) {\n const init: InvitationSchema = Invitation.createSchema(input)\n this.kind = InvitationKind\n this.key = init.key\n this.uid = init.uid\n this.oid = init.oid\n this.email = init.email\n this.name = init.name\n this.token = init.token\n this.expiresAt = init.expiresAt\n this.respondedAt = init.respondedAt\n this.status = init.status\n this.grantType = init.grantType\n this.deleted = init.deleted || false\n this.deletedInfo = init.deletedInfo\n this.createdAt = init.createdAt\n this.updatedAt = init.updatedAt\n this.resent = init.resent\n this.lastSentAt = init.lastSentAt\n }\n\n toJSON(): InvitationSchema {\n const result: InvitationSchema = {\n kind: this.kind,\n key: this.key,\n uid: this.uid,\n oid: this.oid,\n email: this.email,\n token: this.token,\n expiresAt: this.expiresAt,\n status: this.status,\n grantType: this.grantType,\n deleted: this.deleted,\n createdAt: this.createdAt,\n updatedAt: this.updatedAt,\n resent: this.resent,\n lastSentAt: this.lastSentAt,\n }\n if (this.name) {\n result.name = this.name\n }\n if (this.respondedAt) {\n result.respondedAt = this.respondedAt\n }\n if (this.deletedInfo) {\n result.deletedInfo = { ...this.deletedInfo }\n }\n return result\n }\n\n /**\n * Retrieves the patch operations for this invitation.\n * This method builds a JSON Patch representation of the invitation,\n * which can be used to update the invitation in a database or API.\n *\n * Use one of the `set*` methods to modify the invitation before calling this method.\n *\n * @returns An array of patch operations.\n * If no changes have been made, it returns an empty array.\n */\n getPatch(): Operation[] {\n if (!this.#builder) {\n return []\n }\n return this.builder.build()\n }\n\n /**\n * Sets the name of the user to whom the invitation is sent.\n * If the name is the same as the current name, no operation is performed.\n *\n * @param name The name to set. If undefined, it will be removed.\n */\n setName(name?: string): void {\n if (name === this.name) {\n return\n }\n const hasName = !!this.name\n if (hasName && !name) {\n this.builder.remove('/name')\n } else {\n // The add method handles both adding and replacing\n this.builder.add('/name', name)\n }\n this.name = name\n }\n\n /**\n * Sets the expiration timestamp of the invitation.\n * @param expiresAt The timestamp when the invitation expires.\n * If the expiresAt is the same as the current expiresAt, no operation is performed.\n */\n setExpiresAt(expiresAt: number): void {\n if (this.expiresAt !== expiresAt) {\n this.builder.replace('/expiresAt', expiresAt)\n this.expiresAt = expiresAt\n }\n }\n\n /**\n * Sets the grant type of the user in the organization.\n */\n setGrantType(grantType: UserOrganizationGrantType): void {\n if (this.grantType !== grantType) {\n this.builder.replace('/grantType', grantType)\n this.grantType = grantType\n }\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Information about a modification of a File.
|
|
3
3
|
*/
|
|
4
|
-
export interface
|
|
4
|
+
export interface ModificationSchema {
|
|
5
5
|
/**
|
|
6
6
|
* The key of the user modifying the record.
|
|
7
7
|
*/
|
|
@@ -22,4 +22,8 @@ export interface IModification {
|
|
|
22
22
|
*/
|
|
23
23
|
time: number;
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated Use {@link ModificationSchema} instead.
|
|
27
|
+
*/
|
|
28
|
+
export type IModification = ModificationSchema;
|
|
25
29
|
//# sourceMappingURL=Modification.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modification.d.ts","sourceRoot":"","sources":["../../../../src/models/store/Modification.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"Modification.d.ts","sourceRoot":"","sources":["../../../../src/models/store/Modification.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;;;OAKG;IACH,IAAI,EAAE,OAAO,CAAA;IACb;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;CACb;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,kBAAkB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modification.js","sourceRoot":"","sources":["../../../../src/models/store/Modification.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Information about a modification of a File.\n */\nexport interface
|
|
1
|
+
{"version":3,"file":"Modification.js","sourceRoot":"","sources":["../../../../src/models/store/Modification.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Information about a modification of a File.\n */\nexport interface ModificationSchema {\n /**\n * The key of the user modifying the record.\n */\n user: string\n /**\n * User name modifying the record. May not be set when there's no actual user.\n */\n name?: string\n /**\n * Whether the modification was performed by the requesting the data user.\n *\n * Note for store implementers, this field should not be stored and populated every time the\n * record is requested.\n */\n byMe: boolean\n /**\n * A timestamp when the object was modified.\n */\n time: number\n}\n\n/**\n * @deprecated Use {@link ModificationSchema} instead.\n */\nexport type IModification = ModificationSchema\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DeletionSchema } from './Deletion.js';
|
|
2
2
|
import { OrganizationKind } from '../kinds.js';
|
|
3
3
|
export type UserOrganizationGrantType = 'owner' | 'manager' | 'editor' | 'viewer';
|
|
4
4
|
/**
|
|
@@ -6,7 +6,7 @@ export type UserOrganizationGrantType = 'owner' | 'manager' | 'editor' | 'viewer
|
|
|
6
6
|
* This association allows the user to use different identity providers that map to the same user, as long as the
|
|
7
7
|
* email stays consistent.
|
|
8
8
|
*/
|
|
9
|
-
export interface
|
|
9
|
+
export interface OrganizationSchema {
|
|
10
10
|
kind: typeof OrganizationKind;
|
|
11
11
|
/**
|
|
12
12
|
* The database ID
|
|
@@ -16,6 +16,10 @@ export interface IOrganization {
|
|
|
16
16
|
* The organization name
|
|
17
17
|
*/
|
|
18
18
|
name: string;
|
|
19
|
+
/**
|
|
20
|
+
* The organization slug. It is used to identify the organization in the URL.
|
|
21
|
+
*/
|
|
22
|
+
slug: string;
|
|
19
23
|
/**
|
|
20
24
|
* The key of the user that created the organization.
|
|
21
25
|
*/
|
|
@@ -32,28 +36,29 @@ export interface IOrganization {
|
|
|
32
36
|
* The information about the delete information.
|
|
33
37
|
* Always set when the `delete` is true.
|
|
34
38
|
*/
|
|
35
|
-
deletedInfo?:
|
|
39
|
+
deletedInfo?: DeletionSchema;
|
|
36
40
|
/**
|
|
37
41
|
* The grant type to the organization the **current user** has.
|
|
38
42
|
* By nature, it's a dynamic field populated by the data store.
|
|
39
43
|
*/
|
|
40
44
|
grantType: UserOrganizationGrantType;
|
|
41
45
|
}
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
/**
|
|
47
|
+
* @deprecated use OrganizationSchema instead.
|
|
48
|
+
*/
|
|
49
|
+
export type IOrganization = OrganizationSchema;
|
|
50
|
+
export declare class Organization implements OrganizationSchema {
|
|
51
|
+
readonly kind: typeof OrganizationKind;
|
|
44
52
|
key: string;
|
|
45
53
|
name: string;
|
|
54
|
+
slug: string;
|
|
46
55
|
createdBy: string;
|
|
47
56
|
createdDate: number;
|
|
48
57
|
deleted: boolean;
|
|
49
|
-
deletedInfo?:
|
|
58
|
+
deletedInfo?: DeletionSchema;
|
|
50
59
|
grantType: UserOrganizationGrantType;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
* Checks whether the input is a definition of an user organization.
|
|
55
|
-
*/
|
|
56
|
-
static isOrganization(input: unknown): boolean;
|
|
57
|
-
toJSON(): IOrganization;
|
|
60
|
+
static createSchema(input?: Partial<OrganizationSchema>): OrganizationSchema;
|
|
61
|
+
constructor(state?: Partial<OrganizationSchema>);
|
|
62
|
+
toJSON(): OrganizationSchema;
|
|
58
63
|
}
|
|
59
64
|
//# sourceMappingURL=Organization.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Organization.d.ts","sourceRoot":"","sources":["../../../../src/models/store/Organization.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"Organization.d.ts","sourceRoot":"","sources":["../../../../src/models/store/Organization.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAE9C,MAAM,MAAM,yBAAyB,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAEjF;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,OAAO,gBAAgB,CAAA;IAC7B;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;OAGG;IACH,WAAW,CAAC,EAAE,cAAc,CAAA;IAC5B;;;OAGG;IACH,SAAS,EAAE,yBAAyB,CAAA;CACrC;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,kBAAkB,CAAA;AAE9C,qBAAa,YAAa,YAAW,kBAAkB;IACrD,QAAQ,CAAC,IAAI,EAAE,OAAO,gBAAgB,CAAmB;IACzD,GAAG,SAAK;IACR,IAAI,SAAK;IACT,IAAI,SAAK;IACT,SAAS,SAAK;IACd,WAAW,SAAI;IACf,OAAO,UAAQ;IACf,WAAW,CAAC,EAAE,cAAc,CAAA;IAC5B,SAAS,EAAE,yBAAyB,CAAW;IAE/C,MAAM,CAAC,YAAY,CAAC,KAAK,GAAE,OAAO,CAAC,kBAAkB,CAAM,GAAG,kBAAkB;gBAkBpE,KAAK,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC;IAc/C,MAAM,IAAI,kBAAkB;CAgB7B"}
|
|
@@ -4,73 +4,55 @@ export class Organization {
|
|
|
4
4
|
kind = OrganizationKind;
|
|
5
5
|
key = '';
|
|
6
6
|
name = '';
|
|
7
|
+
slug = '';
|
|
7
8
|
createdBy = '';
|
|
8
9
|
createdDate = 0;
|
|
9
10
|
deleted = false;
|
|
10
11
|
deletedInfo;
|
|
11
12
|
grantType = 'viewer';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
createdDate: Date.now(),
|
|
27
|
-
deleted: false,
|
|
28
|
-
grantType: 'viewer',
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
this.new(init);
|
|
32
|
-
}
|
|
33
|
-
new(init) {
|
|
34
|
-
if (!Organization.isOrganization(init)) {
|
|
35
|
-
throw new Error(`Not an Organization.`);
|
|
36
|
-
}
|
|
37
|
-
const { key = nanoid(), name, createdBy, createdDate = Date.now(), deleted = false, deletedInfo, grantType = 'viewer', } = init;
|
|
38
|
-
this.kind = OrganizationKind;
|
|
39
|
-
this.key = key;
|
|
40
|
-
this.name = name;
|
|
41
|
-
this.createdBy = createdBy;
|
|
42
|
-
this.createdDate = createdDate;
|
|
43
|
-
this.deleted = deleted;
|
|
44
|
-
this.grantType = grantType;
|
|
45
|
-
if (deletedInfo) {
|
|
46
|
-
this.deletedInfo = deletedInfo;
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
this.deletedInfo = undefined;
|
|
13
|
+
static createSchema(input = {}) {
|
|
14
|
+
const { key = nanoid() } = input;
|
|
15
|
+
const result = {
|
|
16
|
+
kind: OrganizationKind,
|
|
17
|
+
key,
|
|
18
|
+
name: input.name || 'Unnamed organization',
|
|
19
|
+
slug: input.slug || '',
|
|
20
|
+
createdBy: input.createdBy || '',
|
|
21
|
+
createdDate: input.createdDate || Date.now(),
|
|
22
|
+
deleted: input.deleted || false,
|
|
23
|
+
grantType: input.grantType || 'viewer',
|
|
24
|
+
};
|
|
25
|
+
if (input.deletedInfo) {
|
|
26
|
+
result.deletedInfo = input.deletedInfo;
|
|
50
27
|
}
|
|
28
|
+
return result;
|
|
51
29
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
30
|
+
constructor(state) {
|
|
31
|
+
const init = Organization.createSchema(state);
|
|
32
|
+
this.key = init.key;
|
|
33
|
+
this.name = init.name;
|
|
34
|
+
this.slug = init.slug;
|
|
35
|
+
this.createdBy = init.createdBy;
|
|
36
|
+
this.createdDate = init.createdDate;
|
|
37
|
+
this.deleted = init.deleted ?? false;
|
|
38
|
+
this.grantType = init.grantType;
|
|
39
|
+
if (init.deletedInfo) {
|
|
40
|
+
this.deletedInfo = { ...init.deletedInfo };
|
|
59
41
|
}
|
|
60
|
-
return true;
|
|
61
42
|
}
|
|
62
43
|
toJSON() {
|
|
63
44
|
const result = {
|
|
64
45
|
kind: OrganizationKind,
|
|
65
46
|
key: this.key,
|
|
66
47
|
name: this.name,
|
|
48
|
+
slug: this.slug,
|
|
67
49
|
createdBy: this.createdBy,
|
|
68
50
|
createdDate: this.createdDate,
|
|
69
51
|
deleted: this.deleted,
|
|
70
52
|
grantType: this.grantType,
|
|
71
53
|
};
|
|
72
54
|
if (this.deletedInfo) {
|
|
73
|
-
result.deletedInfo = this.deletedInfo;
|
|
55
|
+
result.deletedInfo = { ...this.deletedInfo };
|
|
74
56
|
}
|
|
75
57
|
return result;
|
|
76
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Organization.js","sourceRoot":"","sources":["../../../../src/models/store/Organization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAExC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"Organization.js","sourceRoot":"","sources":["../../../../src/models/store/Organization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAExC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAoD9C,MAAM,OAAO,YAAY;IACd,IAAI,GAA4B,gBAAgB,CAAA;IACzD,GAAG,GAAG,EAAE,CAAA;IACR,IAAI,GAAG,EAAE,CAAA;IACT,IAAI,GAAG,EAAE,CAAA;IACT,SAAS,GAAG,EAAE,CAAA;IACd,WAAW,GAAG,CAAC,CAAA;IACf,OAAO,GAAG,KAAK,CAAA;IACf,WAAW,CAAiB;IAC5B,SAAS,GAA8B,QAAQ,CAAA;IAE/C,MAAM,CAAC,YAAY,CAAC,QAAqC,EAAE;QACzD,MAAM,EAAE,GAAG,GAAG,MAAM,EAAE,EAAE,GAAG,KAAK,CAAA;QAChC,MAAM,MAAM,GAAuB;YACjC,IAAI,EAAE,gBAAgB;YACtB,GAAG;YACH,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,sBAAsB;YAC1C,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,EAAE;YACtB,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,EAAE;YAChC,WAAW,EAAE,KAAK,CAAC,WAAW,IAAI,IAAI,CAAC,GAAG,EAAE;YAC5C,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,KAAK;YAC/B,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,QAAQ;SACvC,CAAA;QACD,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC;YACt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id.js'\nimport type { DeletionSchema } from './Deletion.js'\nimport { OrganizationKind } from '../kinds.js'\n\nexport type UserOrganizationGrantType = 'owner' | 'manager' | 'editor' | 'viewer'\n\n/**\n * In the system the user identity represents registration information associated with a specific identity provider.\n * This association allows the user to use different identity providers that map to the same user, as long as the\n * email stays consistent.\n */\nexport interface OrganizationSchema {\n kind: typeof OrganizationKind\n /**\n * The database ID\n */\n key: string\n /**\n * The organization name\n */\n name: string\n /**\n * The organization slug. It is used to identify the organization in the URL.\n */\n slug: string\n /**\n * The key of the user that created the organization.\n */\n createdBy: string\n /**\n * The timestamp when the organization was created.\n */\n createdDate: number\n /**\n * Whether the organization object is deleted.\n */\n deleted?: boolean\n /**\n * The information about the delete information.\n * Always set when the `delete` is true.\n */\n deletedInfo?: DeletionSchema\n /**\n * The grant type to the organization the **current user** has.\n * By nature, it's a dynamic field populated by the data store.\n */\n grantType: UserOrganizationGrantType\n}\n\n/**\n * @deprecated use OrganizationSchema instead.\n */\nexport type IOrganization = OrganizationSchema\n\nexport class Organization implements OrganizationSchema {\n readonly kind: typeof OrganizationKind = OrganizationKind\n key = ''\n name = ''\n slug = ''\n createdBy = ''\n createdDate = 0\n deleted = false\n deletedInfo?: DeletionSchema\n grantType: UserOrganizationGrantType = 'viewer'\n\n static createSchema(input: Partial<OrganizationSchema> = {}): OrganizationSchema {\n const { key = nanoid() } = input\n const result: OrganizationSchema = {\n kind: OrganizationKind,\n key,\n name: input.name || 'Unnamed organization',\n slug: input.slug || '',\n createdBy: input.createdBy || '',\n createdDate: input.createdDate || Date.now(),\n deleted: input.deleted || false,\n grantType: input.grantType || 'viewer',\n }\n if (input.deletedInfo) {\n result.deletedInfo = input.deletedInfo\n }\n return result\n }\n\n constructor(state?: Partial<OrganizationSchema>) {\n const init = Organization.createSchema(state)\n this.key = init.key\n this.name = init.name\n this.slug = init.slug\n this.createdBy = init.createdBy\n this.createdDate = init.createdDate\n this.deleted = init.deleted ?? false\n this.grantType = init.grantType\n if (init.deletedInfo) {\n this.deletedInfo = { ...init.deletedInfo }\n }\n }\n\n toJSON(): OrganizationSchema {\n const result: OrganizationSchema = {\n kind: OrganizationKind,\n key: this.key,\n name: this.name,\n slug: this.slug,\n createdBy: this.createdBy,\n createdDate: this.createdDate,\n deleted: this.deleted,\n grantType: this.grantType,\n }\n if (this.deletedInfo) {\n result.deletedInfo = { ...this.deletedInfo }\n }\n return result\n }\n}\n"]}
|