@api-client/core 0.19.17 → 0.19.19
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/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 +7 -3
- package/build/src/mocking/lib/Organization.d.ts.map +1 -1
- package/build/src/mocking/lib/Organization.js +19 -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 +31 -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 +25 -9
- package/build/src/sdk/OrganizationsSdk.d.ts.map +1 -1
- package/build/src/sdk/OrganizationsSdk.js +76 -0
- package/build/src/sdk/OrganizationsSdk.js.map +1 -1
- package/build/src/sdk/RouteBuilder.d.ts +2 -0
- package/build/src/sdk/RouteBuilder.d.ts.map +1 -1
- package/build/src/sdk/RouteBuilder.js +6 -0
- package/build/src/sdk/RouteBuilder.js.map +1 -1
- package/build/src/sdk/SdkMock.d.ts +12 -0
- package/build/src/sdk/SdkMock.d.ts.map +1 -1
- package/build/src/sdk/SdkMock.js +38 -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/mocking/ProjectMock.ts +1 -1
- package/src/mocking/lib/File.ts +5 -5
- package/src/mocking/lib/Organization.ts +26 -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 +59 -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 +100 -16
- package/src/sdk/RouteBuilder.ts +8 -0
- package/src/sdk/SdkMock.ts +66 -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/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
|
@@ -75,7 +75,7 @@ interface IBasePermission {
|
|
|
75
75
|
/**
|
|
76
76
|
* A schema describing a permission to a store object.
|
|
77
77
|
*/
|
|
78
|
-
export interface
|
|
78
|
+
export interface PermissionSchema extends IBasePermission {
|
|
79
79
|
kind: typeof Kind;
|
|
80
80
|
/**
|
|
81
81
|
* The data store key of the permission.
|
|
@@ -83,6 +83,10 @@ export interface IPermission extends IBasePermission {
|
|
|
83
83
|
*/
|
|
84
84
|
key: string;
|
|
85
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* @deprecated Use {@link PermissionSchema} instead.
|
|
88
|
+
*/
|
|
89
|
+
export type IPermission = PermissionSchema;
|
|
86
90
|
export declare class Permission {
|
|
87
91
|
kind: string;
|
|
88
92
|
/**
|
|
@@ -175,8 +179,8 @@ export declare class Permission {
|
|
|
175
179
|
* Creates a permission object from other than key and kind values.
|
|
176
180
|
*/
|
|
177
181
|
static fromValues(init: IBasePermission): Permission;
|
|
178
|
-
constructor(input?: string |
|
|
179
|
-
new(init:
|
|
182
|
+
constructor(input?: string | PermissionSchema);
|
|
183
|
+
new(init: PermissionSchema): void;
|
|
180
184
|
static isPermission(input: unknown): boolean;
|
|
181
185
|
/**
|
|
182
186
|
* Checks whether the current user role meets the minimum required role.
|
|
@@ -207,8 +211,8 @@ export declare class Permission {
|
|
|
207
211
|
* @param permissions The list of permissions to check.
|
|
208
212
|
* @returns True if the user has the required role.
|
|
209
213
|
*/
|
|
210
|
-
static hasRoleIn(minimumLevel: PermissionRole, permissions:
|
|
211
|
-
toJSON():
|
|
214
|
+
static hasRoleIn(minimumLevel: PermissionRole, permissions: PermissionSchema[]): boolean;
|
|
215
|
+
toJSON(): PermissionSchema;
|
|
212
216
|
}
|
|
213
217
|
/**
|
|
214
218
|
* This is used in the communication with the backend to add/change user's access to the resource.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Permission.d.ts","sourceRoot":"","sources":["../../../../src/models/store/Permission.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,oBAAoB,CAAA;AAErC,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,OAAO,GAAG,cAAc,CAAA;AAC9D;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,QAAQ,GAAG,WAAW,GAAG,QAAQ,CAAA;AAExE;;;;;;GAMG;AACH,MAAM,MAAM,oBAAoB,GAAG,mBAAmB,GAAG,uBAAuB,GAAG,0BAA0B,CAAA;AAE7G,UAAU,eAAe;IACvB;;;;;;OAMG;IACH,IAAI,EAAE,cAAc,CAAA;IACpB;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,IAAI,EAAE,cAAc,CAAA;IACpB;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB;;;;;;;OAOG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;;OAGG;IACH,UAAU,EAAE,oBAAoB,CAAA;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"Permission.d.ts","sourceRoot":"","sources":["../../../../src/models/store/Permission.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,oBAAoB,CAAA;AAErC,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,OAAO,GAAG,cAAc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;YACV,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,UAAU,EAAE,IAAI,CAAC,UAAU;SAC5B,CAAA;QACD,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAA;QACvC,CAAC;QACD,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACxB,MAAM,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAA;QAC7C,CAAC;QACD,OAAO,MAAM,CAAA;IACf,CAAC;CACF","sourcesContent":["import { nanoid } from '../../nanoid.js'\n\nexport const Kind = 'Core#Permission'\n\nexport type PermissionType = 'user' | 'group' | 'organization'\n/**\n * - `owner`: Full control over the item.\n * - `writer`: Can view, comment, and edit the item.\n * - `commenter`: Can view and comment on the item.\n * - `reader`: Can only view the item.\n */\nexport type PermissionRole = 'owner' | 'reader' | 'commenter' | 'writer'\nconst orderedRoles: PermissionRole[] = ['reader', 'commenter', 'writer', 'owner']\n/**\n * A predefined set of rules that can be used to determine the source of the permission.\n * - `direct_user_grant`: The permission is granted directly to the user.\n * - `creator_default_owner`: The permission is granted to the creator of the item as the default owner.\n * - `parent_owner_editor_rule`: The object is placed in a folder and the owner of the folder\n * has automatically granted role to the object.\n */\nexport type PermissionSourceRule = 'direct_user_grant' | 'creator_default_owner' | 'parent_owner_editor_rule'\n\ninterface IBasePermission {\n /**\n * The type of the permission.\n *\n * - `user` can access the file by a specific user\n * - `group` can access the file by a group of users\n * - `organization` the object can be searched by anyone within the organization.\n */\n type: PermissionType\n /**\n * It represents the ID of the entity (user, group,or organization)\n * that is being granted the permission on a file or folder.\n */\n granteeId: string\n /**\n * The store id of the entity that is being granted the permission.\n */\n itemId: string\n /**\n * The role granted by this permission.\n */\n role: PermissionRole\n /**\n * The \"pretty\" name to render with the permission.\n *\n * - `user` type - user's full name\n * - `group` type - the name of the group\n * - `organization` type - no render name\n */\n displayName?: string\n /**\n * Optional expiration date of the permission. This is the timestamp when the permission expires.\n * When creating / updating the permission the expiration date must:\n *\n * - be used on a user or a group\n * - the time must be in the future\n */\n expirationTime?: number\n /**\n * The store id of the user that added this permission.\n */\n addingUser: string\n /**\n * The depth of the permission in the hierarchy.\n * When `0` it means that the permissions do not use inheritance.\n * When `1` it means the permission is set on the item itself.\n * When `2` it means the permission is set on the parent item.\n * When `3` it means the permission is set on the grandparent item, and so on.\n * This is used to determine the depth of the permission in the hierarchy.\n */\n depth: number\n /**\n * The source rule of the permission.\n * This is used to determine how the permission was granted.\n */\n sourceRule: PermissionSourceRule\n}\n\n/**\n * A schema describing a permission to a store object.\n */\nexport interface IPermission extends IBasePermission {\n kind: typeof Kind\n /**\n * The data store key of the permission.\n * This property is generated by the store and is not writable.\n */\n key: string\n}\n\nexport class Permission {\n kind = Kind\n /**\n * The data store key of the permission.\n * This property is generated by the store and is not writable.\n */\n key = ''\n /**\n * The type of the permission.\n *\n * - `user` can access the file by a specific user\n * - `group` can access the file by a group of users\n * - - `organization` the object can be searched by anyone within the organization.\n */\n type: PermissionType = 'user'\n /**\n * It represents the ID of the entity (user, group, or organization)\n * that is being granted the permission on a file or folder.\n */\n granteeId = ''\n /**\n * The role granted by this permission.\n */\n role: PermissionRole = 'reader'\n /**\n * The \"pretty\" name to render with the permission.\n *\n * - `user` type - user's full name\n * - `group` type - the name of the group\n * - `organization` type - the organization name.\n */\n displayName?: string\n /**\n * Optional expiration date of the permission. This is the timestamp when the permission expires.\n * When creating / updating the permission the expiration date must:\n *\n * - be used on a user or a group\n * - the time must be in the future\n */\n expirationTime?: number\n\n /**\n * The store id of the user that added this permission.\n */\n addingUser = ''\n\n /**\n * The store id of the entity that is being granted the permission.\n */\n itemId = ''\n /**\n * The depth of the permission in the hierarchy.\n * When `0` it means that the permissions do not use inheritance.\n * When `1` it means the permission is set on the item itself.\n * When `2` it means the permission is set on the parent item.\n * When `3` it means the permission is set on the grandparent item, and so on.\n * This is used to determine the depth of the permission in the hierarchy.\n */\n depth = 0\n /**\n * The source rule of the permission.\n * This is used to determine how the permission was granted.\n */\n sourceRule: PermissionSourceRule = 'direct_user_grant'\n\n /**\n * Creates a Permission object for a user.\n *\n * @param role The user role to set.\n * @param itemId The store id of the entity that is being granted the permission.\n * @param user The user id that has the role.\n * @param addingUser The key of the user that created this permission\n */\n static fromUserRole(role: PermissionRole, itemId: string, user: string, addingUser: string): Permission {\n const init: IPermission = {\n key: nanoid(),\n kind: Kind,\n itemId,\n granteeId: user,\n role,\n type: 'user',\n addingUser,\n depth: 0,\n sourceRule: 'direct_user_grant',\n }\n return new Permission(init)\n }\n\n /**\n * Creates a Permission object for a group.\n *\n * @param role The group role to set.\n * @param itemId The store id of the entity that is being granted the permission.\n * @param group The group id that has the role.\n * @param addingUser The key of the user that created this permission\n */\n static fromGroupRole(role: PermissionRole, itemId: string, group: string, addingUser: string): Permission {\n const init: IPermission = {\n key: nanoid(),\n kind: Kind,\n itemId,\n granteeId: group,\n role,\n type: 'group',\n addingUser,\n depth: 0,\n sourceRule: 'direct_user_grant',\n }\n return new Permission(init)\n }\n\n /**\n * Creates a Permission object for a group.\n *\n * @param role The group role to set.\n * @param itemId The store id of the entity that is being granted the permission.\n * @param addingUser The key of the user that created this permission\n */\n static fromOrganizationRole(\n role: PermissionRole,\n itemId: string,\n organizationId: string,\n addingUser: string\n ): Permission {\n const init: IPermission = {\n key: nanoid(),\n kind: Kind,\n itemId,\n granteeId: organizationId,\n role,\n type: 'organization',\n addingUser,\n depth: 0,\n sourceRule: 'direct_user_grant',\n }\n return new Permission(init)\n }\n\n /**\n * Creates a permission object from other than key and kind values.\n */\n static fromValues(init: IBasePermission): Permission {\n return new Permission({\n ...init,\n key: nanoid(),\n kind: Kind,\n })\n }\n\n constructor(input?: string | IPermission) {\n let init: IPermission\n if (typeof input === 'string') {\n init = JSON.parse(input)\n } else if (typeof input === 'object') {\n init = input\n } else {\n init = {\n kind: Kind,\n key: nanoid(),\n granteeId: '',\n itemId: '',\n role: 'reader',\n type: 'user',\n addingUser: '',\n depth: 0,\n sourceRule: 'direct_user_grant',\n }\n }\n this.new(init)\n }\n\n new(init: IPermission): void {\n if (!Permission.isPermission(init)) {\n throw new Error(`Not a permission.`)\n }\n const {\n key = nanoid(),\n granteeId,\n role,\n type,\n displayName,\n expirationTime,\n addingUser,\n itemId,\n depth,\n sourceRule,\n } = init\n this.kind = Kind\n this.key = key\n this.granteeId = granteeId\n this.itemId = itemId\n this.role = role\n this.type = type\n this.addingUser = addingUser\n this.depth = depth || 0\n this.sourceRule = sourceRule || 'direct_user_grant'\n if (displayName) {\n this.displayName = displayName\n } else {\n this.displayName = undefined\n }\n if (typeof expirationTime === 'number') {\n this.expirationTime = expirationTime\n } else {\n this.expirationTime = undefined\n }\n }\n\n static isPermission(input: unknown): boolean {\n const typed = input as IPermission\n if (!input || typed.kind !== Kind) {\n return false\n }\n return true\n }\n\n /**\n * Checks whether the current user role meets the minimum required role.\n *\n * @param minimumLevel The minimum requested role\n * @param currentRole The user role. When not set it always returns false.\n * @returns True if the `currentRole` is at least the `minimumRole`\n */\n static hasRole(minimumLevel: PermissionRole, currentRole?: PermissionRole): boolean {\n if (!currentRole) {\n return false\n }\n const currentAccessIndex = orderedRoles.indexOf(currentRole)\n const requestedAccessIndex = orderedRoles.indexOf(minimumLevel)\n // the current must be at least at the index of requested.\n return currentAccessIndex >= requestedAccessIndex\n }\n\n /**\n * Checks if role1 is higher than role2 in the permission hierarchy.\n *\n * @param role1 The first role to compare.\n * @param role2 The second role to compare.\n * @returns `true` if `role1` is higher than `role2`, `false` otherwise.\n */\n static isHigherRole(role1: PermissionRole, role2: PermissionRole): boolean {\n const role1Index = orderedRoles.indexOf(role1)\n const role2Index = orderedRoles.indexOf(role2)\n return role1Index > role2Index\n }\n\n /**\n * Link to the `Permission.hasRole(minimumLevel, currentRole)`.\n * @see {@link Permission.hasRole}\n */\n hasRole(minimumLevel: PermissionRole): boolean {\n return Permission.hasRole(minimumLevel, this.role)\n }\n\n /**\n * Checks if the user has the required role in the list of permissions.\n * The permissions list must be filtered for the user, user's organization, and user's groups.\n *\n * @param minimumLevel The minimum requested role\n * @param permissions The list of permissions to check.\n * @returns True if the user has the required role.\n */\n static hasRoleIn(minimumLevel: PermissionRole, permissions: IPermission[]): boolean {\n if (!permissions || !permissions.length) {\n return false\n }\n // 1. Sort/Group permissions by depth (ascending).\n // We want to process the closest permissions first.\n const sorted = [...permissions].sort((a, b) => a.depth - b.depth)\n const closestDepth = sorted[0].depth\n const closestPermissions = sorted.filter((p) => p.depth === closestDepth)\n\n // 2. Specificity: User > Group > Organization\n let effectivePermission: IPermission | undefined\n\n // Check for user permissions\n const userPermissions = closestPermissions.filter((p) => p.type === 'user')\n if (userPermissions.length) {\n // Pick highest role if multiple user permissions exist at same depth (unlikely but safe)\n effectivePermission = userPermissions.sort((a, b) => {\n return orderedRoles.indexOf(b.role) - orderedRoles.indexOf(a.role)\n })[0]\n } else {\n // Check for group permissions\n const groupPermissions = closestPermissions.filter((p) => p.type === 'group')\n if (groupPermissions.length) {\n effectivePermission = groupPermissions.sort((a, b) => {\n return orderedRoles.indexOf(b.role) - orderedRoles.indexOf(a.role)\n })[0]\n } else {\n // Check for organization permissions\n const orgPermissions = closestPermissions.filter((p) => p.type === 'organization')\n if (orgPermissions.length) {\n effectivePermission = orgPermissions.sort((a, b) => {\n return orderedRoles.indexOf(b.role) - orderedRoles.indexOf(a.role)\n })[0]\n }\n }\n }\n\n if (!effectivePermission) {\n return false\n }\n\n return Permission.hasRole(minimumLevel, effectivePermission.role)\n }\n\n toJSON(): IPermission {\n const result: IPermission = {\n kind: Kind,\n key: this.key,\n role: this.role,\n type: this.type,\n addingUser: this.addingUser,\n granteeId: this.granteeId,\n itemId: this.itemId,\n depth: this.depth,\n sourceRule: this.sourceRule,\n }\n if (this.displayName) {\n result.displayName = this.displayName\n }\n if (this.expirationTime) {\n result.expirationTime = this.expirationTime\n }\n return result\n }\n}\n\n/**\n * This is used in the communication with the backend to add/change user's access to the resource.\n */\nexport interface IAccessOperation {\n /**\n * The user, group, or organization id that this permission affects.\n */\n id: string\n /**\n * The permission type: user, group, or organization\n */\n type: PermissionType\n}\n\ninterface IUpdatingOperation {\n /**\n * The level that the user or the group has access to:\n * - owner\n * - reader\n * - commenter\n * - writer\n */\n value: PermissionRole\n /**\n * The timestamp when the permission expires.\n */\n expirationTime?: number\n}\n\nexport interface IAccessAddOperation extends IAccessOperation, IUpdatingOperation {\n op: 'add'\n}\n\nexport interface IAccessRemoveOperation extends IAccessOperation {\n op: 'remove'\n}\n\nexport interface IAccessUpdateOperation extends IAccessOperation, IUpdatingOperation {\n op: 'update'\n /**\n * The ID of the permission to update.\n */\n id: string\n}\n\nexport type AccessOperation = IAccessAddOperation | IAccessRemoveOperation | IAccessUpdateOperation\n"]}
|
|
1
|
+
{"version":3,"file":"Permission.js","sourceRoot":"","sources":["../../../../src/models/store/Permission.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAExC,MAAM,CAAC,MAAM,IAAI,GAAG,iBAAiB,CAAA;AAUrC,MAAM,YAAY,GAAqB,CAAC,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;AAqFjF,MAAM,OAAO,UAAU;IACrB,IAAI,GAAG,IAAI,CAAA;IACX;;;OAGG;IACH,GAAG,GAAG,EAAE,CAAA;IACR;;;;;;OAMG;IACH,IAAI,GAAmB,MAAM,CAAA;IAC7B;;;OAGG;IACH,SAAS,GAAG,EAAE,CAAA;IACd;;OAEG;IACH,IAAI,GAAmB,QAAQ,CAAA;IAC/B;;;;;;OAMG;IACH,WAAW,CAAS;I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,CAAC,OAAO,CAAC,YAAY,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAA;IACnE,CAAC;IAED,MAAM;QACJ,MAAM,MAAM,GAAqB;YAC/B,IAAI,EAAE,IAAI;YACV,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,UAAU,EAAE,IAAI,CAAC,UAAU;SAC5B,CAAA;QACD,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAA;QACvC,CAAC;QACD,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACxB,MAAM,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAA;QAC7C,CAAC;QACD,OAAO,MAAM,CAAA;IACf,CAAC;CACF","sourcesContent":["import { nanoid } from '../../nanoid.js'\n\nexport const Kind = 'Core#Permission'\n\nexport type PermissionType = 'user' | 'group' | 'organization'\n/**\n * - `owner`: Full control over the item.\n * - `writer`: Can view, comment, and edit the item.\n * - `commenter`: Can view and comment on the item.\n * - `reader`: Can only view the item.\n */\nexport type PermissionRole = 'owner' | 'reader' | 'commenter' | 'writer'\nconst orderedRoles: PermissionRole[] = ['reader', 'commenter', 'writer', 'owner']\n/**\n * A predefined set of rules that can be used to determine the source of the permission.\n * - `direct_user_grant`: The permission is granted directly to the user.\n * - `creator_default_owner`: The permission is granted to the creator of the item as the default owner.\n * - `parent_owner_editor_rule`: The object is placed in a folder and the owner of the folder\n * has automatically granted role to the object.\n */\nexport type PermissionSourceRule = 'direct_user_grant' | 'creator_default_owner' | 'parent_owner_editor_rule'\n\ninterface IBasePermission {\n /**\n * The type of the permission.\n *\n * - `user` can access the file by a specific user\n * - `group` can access the file by a group of users\n * - `organization` the object can be searched by anyone within the organization.\n */\n type: PermissionType\n /**\n * It represents the ID of the entity (user, group,or organization)\n * that is being granted the permission on a file or folder.\n */\n granteeId: string\n /**\n * The store id of the entity that is being granted the permission.\n */\n itemId: string\n /**\n * The role granted by this permission.\n */\n role: PermissionRole\n /**\n * The \"pretty\" name to render with the permission.\n *\n * - `user` type - user's full name\n * - `group` type - the name of the group\n * - `organization` type - no render name\n */\n displayName?: string\n /**\n * Optional expiration date of the permission. This is the timestamp when the permission expires.\n * When creating / updating the permission the expiration date must:\n *\n * - be used on a user or a group\n * - the time must be in the future\n */\n expirationTime?: number\n /**\n * The store id of the user that added this permission.\n */\n addingUser: string\n /**\n * The depth of the permission in the hierarchy.\n * When `0` it means that the permissions do not use inheritance.\n * When `1` it means the permission is set on the item itself.\n * When `2` it means the permission is set on the parent item.\n * When `3` it means the permission is set on the grandparent item, and so on.\n * This is used to determine the depth of the permission in the hierarchy.\n */\n depth: number\n /**\n * The source rule of the permission.\n * This is used to determine how the permission was granted.\n */\n sourceRule: PermissionSourceRule\n}\n\n/**\n * A schema describing a permission to a store object.\n */\nexport interface PermissionSchema extends IBasePermission {\n kind: typeof Kind\n /**\n * The data store key of the permission.\n * This property is generated by the store and is not writable.\n */\n key: string\n}\n\n/**\n * @deprecated Use {@link PermissionSchema} instead.\n */\nexport type IPermission = PermissionSchema\n\nexport class Permission {\n kind = Kind\n /**\n * The data store key of the permission.\n * This property is generated by the store and is not writable.\n */\n key = ''\n /**\n * The type of the permission.\n *\n * - `user` can access the file by a specific user\n * - `group` can access the file by a group of users\n * - - `organization` the object can be searched by anyone within the organization.\n */\n type: PermissionType = 'user'\n /**\n * It represents the ID of the entity (user, group, or organization)\n * that is being granted the permission on a file or folder.\n */\n granteeId = ''\n /**\n * The role granted by this permission.\n */\n role: PermissionRole = 'reader'\n /**\n * The \"pretty\" name to render with the permission.\n *\n * - `user` type - user's full name\n * - `group` type - the name of the group\n * - `organization` type - the organization name.\n */\n displayName?: string\n /**\n * Optional expiration date of the permission. This is the timestamp when the permission expires.\n * When creating / updating the permission the expiration date must:\n *\n * - be used on a user or a group\n * - the time must be in the future\n */\n expirationTime?: number\n\n /**\n * The store id of the user that added this permission.\n */\n addingUser = ''\n\n /**\n * The store id of the entity that is being granted the permission.\n */\n itemId = ''\n /**\n * The depth of the permission in the hierarchy.\n * When `0` it means that the permissions do not use inheritance.\n * When `1` it means the permission is set on the item itself.\n * When `2` it means the permission is set on the parent item.\n * When `3` it means the permission is set on the grandparent item, and so on.\n * This is used to determine the depth of the permission in the hierarchy.\n */\n depth = 0\n /**\n * The source rule of the permission.\n * This is used to determine how the permission was granted.\n */\n sourceRule: PermissionSourceRule = 'direct_user_grant'\n\n /**\n * Creates a Permission object for a user.\n *\n * @param role The user role to set.\n * @param itemId The store id of the entity that is being granted the permission.\n * @param user The user id that has the role.\n * @param addingUser The key of the user that created this permission\n */\n static fromUserRole(role: PermissionRole, itemId: string, user: string, addingUser: string): Permission {\n const init: PermissionSchema = {\n key: nanoid(),\n kind: Kind,\n itemId,\n granteeId: user,\n role,\n type: 'user',\n addingUser,\n depth: 0,\n sourceRule: 'direct_user_grant',\n }\n return new Permission(init)\n }\n\n /**\n * Creates a Permission object for a group.\n *\n * @param role The group role to set.\n * @param itemId The store id of the entity that is being granted the permission.\n * @param group The group id that has the role.\n * @param addingUser The key of the user that created this permission\n */\n static fromGroupRole(role: PermissionRole, itemId: string, group: string, addingUser: string): Permission {\n const init: PermissionSchema = {\n key: nanoid(),\n kind: Kind,\n itemId,\n granteeId: group,\n role,\n type: 'group',\n addingUser,\n depth: 0,\n sourceRule: 'direct_user_grant',\n }\n return new Permission(init)\n }\n\n /**\n * Creates a Permission object for a group.\n *\n * @param role The group role to set.\n * @param itemId The store id of the entity that is being granted the permission.\n * @param addingUser The key of the user that created this permission\n */\n static fromOrganizationRole(\n role: PermissionRole,\n itemId: string,\n organizationId: string,\n addingUser: string\n ): Permission {\n const init: PermissionSchema = {\n key: nanoid(),\n kind: Kind,\n itemId,\n granteeId: organizationId,\n role,\n type: 'organization',\n addingUser,\n depth: 0,\n sourceRule: 'direct_user_grant',\n }\n return new Permission(init)\n }\n\n /**\n * Creates a permission object from other than key and kind values.\n */\n static fromValues(init: IBasePermission): Permission {\n return new Permission({\n ...init,\n key: nanoid(),\n kind: Kind,\n })\n }\n\n constructor(input?: string | PermissionSchema) {\n let init: PermissionSchema\n if (typeof input === 'string') {\n init = JSON.parse(input)\n } else if (typeof input === 'object') {\n init = input\n } else {\n init = {\n kind: Kind,\n key: nanoid(),\n granteeId: '',\n itemId: '',\n role: 'reader',\n type: 'user',\n addingUser: '',\n depth: 0,\n sourceRule: 'direct_user_grant',\n }\n }\n this.new(init)\n }\n\n new(init: PermissionSchema): void {\n if (!Permission.isPermission(init)) {\n throw new Error(`Not a permission.`)\n }\n const {\n key = nanoid(),\n granteeId,\n role,\n type,\n displayName,\n expirationTime,\n addingUser,\n itemId,\n depth,\n sourceRule,\n } = init\n this.kind = Kind\n this.key = key\n this.granteeId = granteeId\n this.itemId = itemId\n this.role = role\n this.type = type\n this.addingUser = addingUser\n this.depth = depth || 0\n this.sourceRule = sourceRule || 'direct_user_grant'\n if (displayName) {\n this.displayName = displayName\n } else {\n this.displayName = undefined\n }\n if (typeof expirationTime === 'number') {\n this.expirationTime = expirationTime\n } else {\n this.expirationTime = undefined\n }\n }\n\n static isPermission(input: unknown): boolean {\n const typed = input as PermissionSchema\n if (!input || typed.kind !== Kind) {\n return false\n }\n return true\n }\n\n /**\n * Checks whether the current user role meets the minimum required role.\n *\n * @param minimumLevel The minimum requested role\n * @param currentRole The user role. When not set it always returns false.\n * @returns True if the `currentRole` is at least the `minimumRole`\n */\n static hasRole(minimumLevel: PermissionRole, currentRole?: PermissionRole): boolean {\n if (!currentRole) {\n return false\n }\n const currentAccessIndex = orderedRoles.indexOf(currentRole)\n const requestedAccessIndex = orderedRoles.indexOf(minimumLevel)\n // the current must be at least at the index of requested.\n return currentAccessIndex >= requestedAccessIndex\n }\n\n /**\n * Checks if role1 is higher than role2 in the permission hierarchy.\n *\n * @param role1 The first role to compare.\n * @param role2 The second role to compare.\n * @returns `true` if `role1` is higher than `role2`, `false` otherwise.\n */\n static isHigherRole(role1: PermissionRole, role2: PermissionRole): boolean {\n const role1Index = orderedRoles.indexOf(role1)\n const role2Index = orderedRoles.indexOf(role2)\n return role1Index > role2Index\n }\n\n /**\n * Link to the `Permission.hasRole(minimumLevel, currentRole)`.\n * @see {@link Permission.hasRole}\n */\n hasRole(minimumLevel: PermissionRole): boolean {\n return Permission.hasRole(minimumLevel, this.role)\n }\n\n /**\n * Checks if the user has the required role in the list of permissions.\n * The permissions list must be filtered for the user, user's organization, and user's groups.\n *\n * @param minimumLevel The minimum requested role\n * @param permissions The list of permissions to check.\n * @returns True if the user has the required role.\n */\n static hasRoleIn(minimumLevel: PermissionRole, permissions: PermissionSchema[]): boolean {\n if (!permissions || !permissions.length) {\n return false\n }\n // 1. Sort/Group permissions by depth (ascending).\n // We want to process the closest permissions first.\n const sorted = [...permissions].sort((a, b) => a.depth - b.depth)\n const closestDepth = sorted[0].depth\n const closestPermissions = sorted.filter((p) => p.depth === closestDepth)\n\n // 2. Specificity: User > Group > Organization\n let effectivePermission: PermissionSchema | undefined\n\n // Check for user permissions\n const userPermissions = closestPermissions.filter((p) => p.type === 'user')\n if (userPermissions.length) {\n // Pick highest role if multiple user permissions exist at same depth (unlikely but safe)\n effectivePermission = userPermissions.sort((a, b) => {\n return orderedRoles.indexOf(b.role) - orderedRoles.indexOf(a.role)\n })[0]\n } else {\n // Check for group permissions\n const groupPermissions = closestPermissions.filter((p) => p.type === 'group')\n if (groupPermissions.length) {\n effectivePermission = groupPermissions.sort((a, b) => {\n return orderedRoles.indexOf(b.role) - orderedRoles.indexOf(a.role)\n })[0]\n } else {\n // Check for organization permissions\n const orgPermissions = closestPermissions.filter((p) => p.type === 'organization')\n if (orgPermissions.length) {\n effectivePermission = orgPermissions.sort((a, b) => {\n return orderedRoles.indexOf(b.role) - orderedRoles.indexOf(a.role)\n })[0]\n }\n }\n }\n\n if (!effectivePermission) {\n return false\n }\n\n return Permission.hasRole(minimumLevel, effectivePermission.role)\n }\n\n toJSON(): PermissionSchema {\n const result: PermissionSchema = {\n kind: Kind,\n key: this.key,\n role: this.role,\n type: this.type,\n addingUser: this.addingUser,\n granteeId: this.granteeId,\n itemId: this.itemId,\n depth: this.depth,\n sourceRule: this.sourceRule,\n }\n if (this.displayName) {\n result.displayName = this.displayName\n }\n if (this.expirationTime) {\n result.expirationTime = this.expirationTime\n }\n return result\n }\n}\n\n/**\n * This is used in the communication with the backend to add/change user's access to the resource.\n */\nexport interface IAccessOperation {\n /**\n * The user, group, or organization id that this permission affects.\n */\n id: string\n /**\n * The permission type: user, group, or organization\n */\n type: PermissionType\n}\n\ninterface IUpdatingOperation {\n /**\n * The level that the user or the group has access to:\n * - owner\n * - reader\n * - commenter\n * - writer\n */\n value: PermissionRole\n /**\n * The timestamp when the permission expires.\n */\n expirationTime?: number\n}\n\nexport interface IAccessAddOperation extends IAccessOperation, IUpdatingOperation {\n op: 'add'\n}\n\nexport interface IAccessRemoveOperation extends IAccessOperation {\n op: 'remove'\n}\n\nexport interface IAccessUpdateOperation extends IAccessOperation, IUpdatingOperation {\n op: 'update'\n /**\n * The ID of the permission to update.\n */\n id: string\n}\n\nexport type AccessOperation = IAccessAddOperation | IAccessRemoveOperation | IAccessUpdateOperation\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DeletionSchema } from './Deletion.js';
|
|
2
2
|
import type { UserOrganizationGrantType } from './Organization.js';
|
|
3
|
-
export interface
|
|
3
|
+
export interface EmailSchema {
|
|
4
4
|
/**
|
|
5
5
|
* When available the email of the user.
|
|
6
6
|
*/
|
|
@@ -11,7 +11,11 @@ export interface IEmail {
|
|
|
11
11
|
*/
|
|
12
12
|
verified?: boolean;
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated Use {@link EmailSchema} instead.
|
|
16
|
+
*/
|
|
17
|
+
export type IEmail = EmailSchema;
|
|
18
|
+
export interface UserPictureSchema {
|
|
15
19
|
/**
|
|
16
20
|
* When available, the URL to the user's picture image.
|
|
17
21
|
*/
|
|
@@ -21,6 +25,10 @@ export interface IUserPicture {
|
|
|
21
25
|
*/
|
|
22
26
|
data?: string;
|
|
23
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated Use {@link UserPictureSchema} instead.
|
|
30
|
+
*/
|
|
31
|
+
export type IUserPicture = UserPictureSchema;
|
|
24
32
|
export declare const Kind = "Core#User";
|
|
25
33
|
export type UserStatus = 'active' | 'deleted' | 'suspended' | 'pending';
|
|
26
34
|
/**
|
|
@@ -31,7 +39,7 @@ export type UserStatus = 'active' | 'deleted' | 'suspended' | 'pending';
|
|
|
31
39
|
* Note, the store implementation may have additional fields that support external
|
|
32
40
|
* identity providers. However, this is not exposed to the user through the API.
|
|
33
41
|
*/
|
|
34
|
-
export interface
|
|
42
|
+
export interface UserSchema {
|
|
35
43
|
kind: typeof Kind;
|
|
36
44
|
/**
|
|
37
45
|
* The data store key of the user.
|
|
@@ -48,7 +56,7 @@ export interface IUser {
|
|
|
48
56
|
/**
|
|
49
57
|
* The user picture to render.
|
|
50
58
|
*/
|
|
51
|
-
picture?:
|
|
59
|
+
picture?: UserPictureSchema;
|
|
52
60
|
/**
|
|
53
61
|
* A general purpose tags field.
|
|
54
62
|
*/
|
|
@@ -104,6 +112,10 @@ export interface IUser {
|
|
|
104
112
|
* The information about the delete information.
|
|
105
113
|
* Always set when the `delete` is true.
|
|
106
114
|
*/
|
|
107
|
-
deletedInfo?:
|
|
115
|
+
deletedInfo?: DeletionSchema;
|
|
108
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* @deprecated Use {@link UserSchema} instead.
|
|
119
|
+
*/
|
|
120
|
+
export type IUser = UserSchema;
|
|
109
121
|
//# sourceMappingURL=User.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"User.d.ts","sourceRoot":"","sources":["../../../../src/models/store/User.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"User.d.ts","sourceRoot":"","sources":["../../../../src/models/store/User.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAA;AAElE,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG,WAAW,CAAA;AAEhC,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,iBAAiB,CAAA;AAE5C,eAAO,MAAM,IAAI,cAAc,CAAA;AAE/B,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,CAAA;AAEvE;;;;;;;GAOG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,OAAO,IAAI,CAAA;IACjB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,KAAK,EAAE,MAAM,EAAE,CAAA;IACf;;OAEG;IACH,OAAO,CAAC,EAAE,iBAAiB,CAAA;IAC3B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;IACf;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;;OAIG;IACH,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB;;;OAGG;IACH,SAAS,CAAC,EAAE,yBAAyB,CAAA;IACrC;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;;OAGG;IACH,WAAW,CAAC,EAAE,cAAc,CAAA;CAC7B;AAED;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG,UAAU,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"User.js","sourceRoot":"","sources":["../../../../src/models/store/User.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"User.js","sourceRoot":"","sources":["../../../../src/models/store/User.ts"],"names":[],"mappings":"AAoCA,MAAM,CAAC,MAAM,IAAI,GAAG,WAAW,CAAA","sourcesContent":["import type { DeletionSchema } from './Deletion.js'\nimport type { UserOrganizationGrantType } from './Organization.js'\n\nexport interface EmailSchema {\n /**\n * When available the email of the user.\n */\n email: string\n /**\n * Whether the `email` was verified.\n * Not verified emails should have limited use in the system.\n */\n verified?: boolean\n}\n\n/**\n * @deprecated Use {@link EmailSchema} instead.\n */\nexport type IEmail = EmailSchema\n\nexport interface UserPictureSchema {\n /**\n * When available, the URL to the user's picture image.\n */\n url?: string\n /**\n * Alternative to the `url`. When set it is a data URL value of the image.\n */\n data?: string\n}\n\n/**\n * @deprecated Use {@link UserPictureSchema} instead.\n */\nexport type IUserPicture = UserPictureSchema\n\nexport const Kind = 'Core#User'\n\nexport type UserStatus = 'active' | 'deleted' | 'suspended' | 'pending'\n\n/**\n * Represents a user in the system.\n * This can be embedded in various situations like project's revision history,\n * ACL, Authorization, etc.\n *\n * Note, the store implementation may have additional fields that support external\n * identity providers. However, this is not exposed to the user through the API.\n */\nexport interface UserSchema {\n kind: typeof Kind\n /**\n * The data store key of the user.\n */\n key: string\n /**\n * The display name of the user.\n */\n name: string\n /**\n * When available the email of the user.\n */\n email: IEmail[]\n /**\n * The user picture to render.\n */\n picture?: UserPictureSchema\n /**\n * A general purpose tags field.\n */\n tags?: string[]\n /**\n * Optional user locale information.\n */\n locale?: string\n /**\n * Optional metadata related to the auth provider.\n */\n provider?: unknown\n /**\n * Whether the user is deleted from the system.\n * @deprecated Use `status` instead.\n */\n deleted?: boolean\n /**\n * The timestamp of when the user was deleted.\n * @deprecated\n */\n deletedTime?: number\n /**\n * The id of the user that deleted the user.\n * @deprecated\n */\n deletingUser?: string\n /**\n * The status of the user.\n * May not be populated in all cases.\n * @default 'active'\n */\n status?: UserStatus\n /**\n * Populated when the user object is considered in the context of an organization.\n * This is used to determine the user's role in the organization.\n */\n grantType?: UserOrganizationGrantType\n /**\n * Populated when the user object is considered in the context of an organization.\n * The timestamp of when the user joined the organization.\n */\n joined?: number\n /**\n * The timestamp of when the user was created.\n */\n created: number\n /**\n * The timestamp of when the user was last updated.\n */\n updated: number\n /**\n * The information about the delete information.\n * Always set when the `delete` is true.\n */\n deletedInfo?: DeletionSchema\n}\n\n/**\n * @deprecated Use {@link UserSchema} instead.\n */\nexport type IUser = UserSchema\n"]}
|
|
@@ -5,7 +5,7 @@ type Provider = 'google';
|
|
|
5
5
|
* This association allows the user to use different identity providers that map to the same user, as long as the
|
|
6
6
|
* email stays consistent.
|
|
7
7
|
*/
|
|
8
|
-
export interface
|
|
8
|
+
export interface UserIdentitySchema {
|
|
9
9
|
kind: typeof Kind;
|
|
10
10
|
/**
|
|
11
11
|
* The database ID
|
|
@@ -34,7 +34,11 @@ export interface IUserIdentity {
|
|
|
34
34
|
*/
|
|
35
35
|
hostDomain?: string;
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
/**
|
|
38
|
+
* @deprecated Use {@link UserIdentitySchema} instead.
|
|
39
|
+
*/
|
|
40
|
+
export type IUserIdentity = UserIdentitySchema;
|
|
41
|
+
export declare class UserIdentity implements UserIdentitySchema {
|
|
38
42
|
kind: typeof Kind;
|
|
39
43
|
key: string;
|
|
40
44
|
userId: string;
|
|
@@ -42,10 +46,10 @@ export declare class UserIdentity implements IUserIdentity {
|
|
|
42
46
|
providerId: string;
|
|
43
47
|
emailVerified: boolean;
|
|
44
48
|
hostDomain?: string;
|
|
45
|
-
constructor(input?: string |
|
|
46
|
-
new(init:
|
|
49
|
+
constructor(input?: string | UserIdentitySchema);
|
|
50
|
+
new(init: UserIdentitySchema): void;
|
|
47
51
|
static isUserIdentity(input: unknown): boolean;
|
|
48
|
-
toJSON():
|
|
52
|
+
toJSON(): UserIdentitySchema;
|
|
49
53
|
}
|
|
50
54
|
export {};
|
|
51
55
|
//# sourceMappingURL=UserIdentity.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserIdentity.d.ts","sourceRoot":"","sources":["../../../../src/models/store/UserIdentity.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,sBAAsB,CAAA;AAEvC,KAAK,QAAQ,GAAG,QAAQ,CAAA;AAExB;;;;GAIG;AACH,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"UserIdentity.d.ts","sourceRoot":"","sources":["../../../../src/models/store/UserIdentity.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,sBAAsB,CAAA;AAEvC,KAAK,QAAQ,GAAG,QAAQ,CAAA;AAExB;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,OAAO,IAAI,CAAA;IACjB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,QAAQ,EAAE,QAAQ,CAAA;IAClB;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,aAAa,EAAE,OAAO,CAAA;IACtB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,kBAAkB,CAAA;AAE9C,qBAAa,YAAa,YAAW,kBAAkB;IACrD,IAAI,EAAE,OAAO,IAAI,CAAO;IACxB,GAAG,SAAK;IACR,MAAM,SAAK;IACX,QAAQ,EAAE,QAAQ,CAAW;IAC7B,UAAU,SAAK;IACf,aAAa,UAAQ;IACrB,UAAU,CAAC,EAAE,MAAM,CAAA;gBAEP,KAAK,CAAC,EAAE,MAAM,GAAG,kBAAkB;IAmB/C,GAAG,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI;IAkBnC,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;IAQ9C,MAAM,IAAI,kBAAkB;CAc7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserIdentity.js","sourceRoot":"","sources":["../../../../src/models/store/UserIdentity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAExC,MAAM,CAAC,MAAM,IAAI,GAAG,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"UserIdentity.js","sourceRoot":"","sources":["../../../../src/models/store/UserIdentity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAExC,MAAM,CAAC,MAAM,IAAI,GAAG,mBAAmB,CAAA;AA4CvC,MAAM,OAAO,YAAY;IACvB,IAAI,GAAgB,IAAI,CAAA;IACxB,GAAG,GAAG,EAAE,CAAA;IACR,MAAM,GAAG,EAAE,CAAA;IACX,QAAQ,GAAa,QAAQ,CAAA;IAC7B,UAAU,GAAG,EAAE,CAAA;IACf,aAAa,GAAG,KAAK,CAAA;IACrB,UAAU,CAAS;IAEnB,YAAY,KAAmC;QAC7C,I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ClC,MAAM,KAAK,GAAG,KAA2B,CAAA;QACzC,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;YAClC,OAAO,KAAK,CAAA;QACd,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM;QACJ,MAAM,MAAM,GAAuB;YACjC,IAAI,EAAE,IAAI;YACV,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,aAAa,EAAE,IAAI,CAAC,aAAa;SAClC,CAAA;QACD,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAA;QACrC,CAAC;QACD,OAAO,MAAM,CAAA;IACf,CAAC;CACF","sourcesContent":["import { nanoid } from '../../nanoid.js'\n\nexport const Kind = 'Core#UserIdentity'\n\ntype Provider = 'google'\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 UserIdentitySchema {\n kind: typeof Kind\n /**\n * The database ID\n */\n key: string\n /**\n * The related user id.\n */\n userId: string\n /**\n * The identity provider.\n */\n provider: Provider\n /**\n * The provider's unique ID.\n * This allows to recognize a returning user.\n */\n providerId: string\n /**\n * `true`, if the provider has verified the email address.\n */\n emailVerified: boolean\n /**\n * If present, the host domain of the user's GSuite email address.\n * Google specific.\n */\n hostDomain?: string\n}\n\n/**\n * @deprecated Use {@link UserIdentitySchema} instead.\n */\nexport type IUserIdentity = UserIdentitySchema\n\nexport class UserIdentity implements UserIdentitySchema {\n kind: typeof Kind = Kind\n key = ''\n userId = ''\n provider: Provider = 'google'\n providerId = ''\n emailVerified = false\n hostDomain?: string\n\n constructor(input?: string | UserIdentitySchema) {\n let init: UserIdentitySchema\n if (typeof input === 'string') {\n init = JSON.parse(input)\n } else if (typeof input === 'object') {\n init = input\n } else {\n init = {\n kind: Kind,\n key: nanoid(),\n userId: '',\n provider: 'google',\n providerId: '',\n emailVerified: false,\n }\n }\n this.new(init)\n }\n\n new(init: UserIdentitySchema): void {\n if (!UserIdentity.isUserIdentity(init)) {\n throw new Error(`Not a UserIdentity.`)\n }\n const { key = nanoid(), emailVerified, provider, providerId, userId, hostDomain } = init\n this.kind = Kind\n this.key = key\n this.provider = provider\n this.providerId = providerId\n this.userId = userId\n this.emailVerified = emailVerified\n if (hostDomain) {\n this.hostDomain = hostDomain\n } else {\n this.hostDomain = undefined\n }\n }\n\n static isUserIdentity(input: unknown): boolean {\n const typed = input as UserIdentitySchema\n if (!input || typed.kind !== Kind) {\n return false\n }\n return true\n }\n\n toJSON(): UserIdentitySchema {\n const result: UserIdentitySchema = {\n kind: Kind,\n key: this.key,\n provider: this.provider,\n providerId: this.providerId,\n userId: this.userId,\n emailVerified: this.emailVerified,\n }\n if (this.hostDomain) {\n result.hostDomain = this.hostDomain\n }\n return result\n }\n}\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { SdkBase, SdkOptions } from './SdkBase.js';
|
|
2
|
-
import type {
|
|
3
|
-
import type { FileBreadcrumb,
|
|
2
|
+
import type { UserSchema } from '../models/store/User.js';
|
|
3
|
+
import type { FileBreadcrumb, FileSchema } from '../models/store/File.js';
|
|
4
4
|
import { FolderKind, CertificateFileKind, ProjectKind, DomainFileKind } from '../models/kinds.js';
|
|
5
5
|
import type { ContextListResult, IBulkOperationResult, ContextListOptions } from '../events/BaseEvents.js';
|
|
6
6
|
import type { PermissionRole } from '../models/store/Permission.js';
|
|
7
|
-
import { type
|
|
7
|
+
import { type FolderSchema } from '../models/Folder.js';
|
|
8
8
|
import type { AccessPatchInfo, MediaPatchInfo, MediaPatchRevision, PatchInfo } from '../patch/types.js';
|
|
9
9
|
export interface IMetaCreateOptions {
|
|
10
10
|
/**
|
|
@@ -39,7 +39,7 @@ export declare class FilesSdk extends SdkBase {
|
|
|
39
39
|
* @param options Optional query options.
|
|
40
40
|
* @param request Optional request options.
|
|
41
41
|
*/
|
|
42
|
-
list(organization: string, options?: ContextListOptions, request?: SdkOptions): Promise<ContextListResult<
|
|
42
|
+
list(organization: string, options?: ContextListOptions, request?: SdkOptions): Promise<ContextListResult<FileSchema>>;
|
|
43
43
|
/**
|
|
44
44
|
* Creates both the meta and the media for a file.
|
|
45
45
|
*
|
|
@@ -49,16 +49,16 @@ export declare class FilesSdk extends SdkBase {
|
|
|
49
49
|
* @param request Optional request details
|
|
50
50
|
* @returns The id of the created file meta.
|
|
51
51
|
*/
|
|
52
|
-
create(meta:
|
|
52
|
+
create(meta: FileSchema, contents: unknown, organization: string, opts?: IFileCreateOptions, request?: SdkOptions): Promise<FileSchema>;
|
|
53
53
|
/**
|
|
54
54
|
* Creates a file in the store.
|
|
55
55
|
*
|
|
56
|
-
* @param file The definition of a file that extends the
|
|
56
|
+
* @param file The definition of a file that extends the FileSchema interface.
|
|
57
57
|
* @param opts Optional options when creating a file
|
|
58
58
|
* @param request Optional request options.
|
|
59
59
|
* @returns The key of the creates file.
|
|
60
60
|
*/
|
|
61
|
-
createMeta(file:
|
|
61
|
+
createMeta(file: FileSchema, organization: string, opts?: IMetaCreateOptions, request?: SdkOptions): Promise<FileSchema>;
|
|
62
62
|
/**
|
|
63
63
|
* Creates a file contents (the media) after the file meta was created.
|
|
64
64
|
*
|
|
@@ -68,7 +68,7 @@ export declare class FilesSdk extends SdkBase {
|
|
|
68
68
|
* @param request Optional request.
|
|
69
69
|
*/
|
|
70
70
|
createMedia(contents: unknown, organization: string, key: string, opts?: IMediaCreateOptions, request?: SdkOptions): Promise<void>;
|
|
71
|
-
createFolder(name: string, organization: string, opts?: IMetaCreateOptions, request?: SdkOptions): Promise<
|
|
71
|
+
createFolder(name: string, organization: string, opts?: IMetaCreateOptions, request?: SdkOptions): Promise<FolderSchema>;
|
|
72
72
|
/**
|
|
73
73
|
* Reads a file from the store.
|
|
74
74
|
*
|
|
@@ -76,7 +76,7 @@ export declare class FilesSdk extends SdkBase {
|
|
|
76
76
|
* @param fid The file key
|
|
77
77
|
* @param request Optional request options.
|
|
78
78
|
*/
|
|
79
|
-
read(oid: string, fid: string, request?: SdkOptions): Promise<
|
|
79
|
+
read(oid: string, fid: string, request?: SdkOptions): Promise<FileSchema>;
|
|
80
80
|
readMedia(oid: string, fid: string, request?: SdkOptions): Promise<{
|
|
81
81
|
media: unknown;
|
|
82
82
|
version: number;
|
|
@@ -88,7 +88,7 @@ export declare class FilesSdk extends SdkBase {
|
|
|
88
88
|
* in that place. It also inserts `undefined` in place of a file that doesn't exist.
|
|
89
89
|
* @param request Optional request options.
|
|
90
90
|
*/
|
|
91
|
-
readBulk(organization: string, keys: string[], request?: SdkOptions): Promise<IBulkOperationResult<
|
|
91
|
+
readBulk(organization: string, keys: string[], request?: SdkOptions): Promise<IBulkOperationResult<FileSchema>>;
|
|
92
92
|
/**
|
|
93
93
|
* Patches a file in the store.
|
|
94
94
|
* @param fid The key of the file to patch
|
|
@@ -96,7 +96,7 @@ export declare class FilesSdk extends SdkBase {
|
|
|
96
96
|
* @param request Optional request options.
|
|
97
97
|
* @returns The updated file object after applying the patch
|
|
98
98
|
*/
|
|
99
|
-
patch(oid: string, fid: string, info: PatchInfo, request?: SdkOptions): Promise<
|
|
99
|
+
patch(oid: string, fid: string, info: PatchInfo, request?: SdkOptions): Promise<FileSchema>;
|
|
100
100
|
/**
|
|
101
101
|
* Patches file media.
|
|
102
102
|
* @param oid Organization id
|
|
@@ -123,7 +123,7 @@ export declare class FilesSdk extends SdkBase {
|
|
|
123
123
|
* @param info The patch operation on the file's ACL
|
|
124
124
|
* @param request Optional request options.
|
|
125
125
|
*/
|
|
126
|
-
patchUsers(oid: string, fid: string, info: AccessPatchInfo, request?: SdkOptions): Promise<
|
|
126
|
+
patchUsers(oid: string, fid: string, info: AccessPatchInfo, request?: SdkOptions): Promise<FileSchema>;
|
|
127
127
|
/**
|
|
128
128
|
* A shorthand method to add access to the file to a single user.
|
|
129
129
|
*
|
|
@@ -133,7 +133,7 @@ export declare class FilesSdk extends SdkBase {
|
|
|
133
133
|
* @param role The user role to grant
|
|
134
134
|
* @param expires Optionally, when the permission expires.
|
|
135
135
|
*/
|
|
136
|
-
addUser(organization: string, key: string, otherUserKey: string, role: PermissionRole, expires?: number, request?: SdkOptions): Promise<
|
|
136
|
+
addUser(organization: string, key: string, otherUserKey: string, role: PermissionRole, expires?: number, request?: SdkOptions): Promise<FileSchema>;
|
|
137
137
|
/**
|
|
138
138
|
* A shorthand method to remove access to the organization to a single user.
|
|
139
139
|
*
|
|
@@ -141,14 +141,14 @@ export declare class FilesSdk extends SdkBase {
|
|
|
141
141
|
* @param key The file key
|
|
142
142
|
* @param otherUserKey The key of the user that gets access to the organization
|
|
143
143
|
*/
|
|
144
|
-
removeUser(organization: string, key: string, otherUserKey: string, request?: SdkOptions): Promise<
|
|
144
|
+
removeUser(organization: string, key: string, otherUserKey: string, request?: SdkOptions): Promise<FileSchema>;
|
|
145
145
|
/**
|
|
146
146
|
* Lists uses having access to the file.
|
|
147
147
|
*
|
|
148
148
|
* @param key The file key
|
|
149
149
|
* @param request Optional request options.
|
|
150
150
|
*/
|
|
151
|
-
listUsers(organization: string, key: string, request?: SdkOptions): Promise<ContextListResult<
|
|
151
|
+
listUsers(organization: string, key: string, request?: SdkOptions): Promise<ContextListResult<UserSchema>>;
|
|
152
152
|
/**
|
|
153
153
|
* Lists breadcrumbs to the file.
|
|
154
154
|
* @param key The lowest file in the hierarchy
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilesSdk.d.ts","sourceRoot":"","sources":["../../../src/sdk/FilesSdk.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAKP,UAAU,EACX,MAAM,cAAc,CAAA;AAErB,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"FilesSdk.d.ts","sourceRo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Ac,CAAC,CAAC;CAwB9C"}
|
|
@@ -63,7 +63,7 @@ export class FilesSdk extends SdkBase {
|
|
|
63
63
|
/**
|
|
64
64
|
* Creates a file in the store.
|
|
65
65
|
*
|
|
66
|
-
* @param file The definition of a file that extends the
|
|
66
|
+
* @param file The definition of a file that extends the FileSchema interface.
|
|
67
67
|
* @param opts Optional options when creating a file
|
|
68
68
|
* @param request Optional request options.
|
|
69
69
|
* @returns The key of the creates file.
|