@api-client/core 0.4.2 → 0.5.0

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.
Files changed (59) hide show
  1. package/build/browser.d.ts +5 -2
  2. package/build/browser.js +3 -1
  3. package/build/browser.js.map +1 -1
  4. package/build/index.d.ts +5 -2
  5. package/build/index.js +3 -1
  6. package/build/index.js.map +1 -1
  7. package/build/src/mocking/LegacyInterfaces.d.ts +1 -1
  8. package/build/src/mocking/ProjectMock.d.ts +1 -1
  9. package/build/src/mocking/legacy/Http.js +1 -1
  10. package/build/src/mocking/legacy/Http.js.map +1 -1
  11. package/build/src/mocking/legacy/HttpResponse.d.ts +1 -1
  12. package/build/src/mocking/legacy/HttpResponse.js +1 -1
  13. package/build/src/mocking/legacy/HttpResponse.js.map +1 -1
  14. package/build/src/mocking/lib/User.d.ts +1 -6
  15. package/build/src/mocking/lib/User.js +1 -15
  16. package/build/src/mocking/lib/User.js.map +1 -1
  17. package/build/src/models/Backend.d.ts +10 -2
  18. package/build/src/models/HttpProject.js +1 -1
  19. package/build/src/models/HttpProject.js.map +1 -1
  20. package/build/src/models/Workspace.d.ts +5 -35
  21. package/build/src/models/Workspace.js +13 -35
  22. package/build/src/models/Workspace.js.map +1 -1
  23. package/build/src/models/legacy/models/base.d.ts +90 -0
  24. package/build/src/models/legacy/models/base.js +2 -0
  25. package/build/src/models/legacy/models/base.js.map +1 -0
  26. package/build/src/models/store/File.d.ts +88 -0
  27. package/build/src/models/store/File.js +82 -0
  28. package/build/src/models/store/File.js.map +1 -0
  29. package/build/src/models/store/Group.d.ts +21 -0
  30. package/build/src/models/store/Group.js +2 -0
  31. package/build/src/models/store/Group.js.map +1 -0
  32. package/build/src/models/store/Permission.d.ts +189 -0
  33. package/build/src/models/store/Permission.js +211 -0
  34. package/build/src/models/store/Permission.js.map +1 -0
  35. package/build/src/models/{User.d.ts → store/User.d.ts} +12 -59
  36. package/build/src/models/{User.js → store/User.js} +0 -0
  37. package/build/src/models/store/User.js.map +1 -0
  38. package/build/src/runtime/store/SpacesSdk.d.ts +4 -4
  39. package/build/src/runtime/store/SpacesSdk.js.map +1 -1
  40. package/build/src/runtime/store/UsersSdk.d.ts +1 -1
  41. package/json8-patch.d.ts +270 -0
  42. package/package.json +2 -2
  43. package/src/mocking/LegacyInterfaces.ts +1 -1
  44. package/src/mocking/ProjectMock.ts +1 -1
  45. package/src/mocking/legacy/Http.ts +1 -1
  46. package/src/mocking/legacy/HttpResponse.ts +1 -1
  47. package/src/mocking/lib/User.ts +1 -21
  48. package/src/models/Backend.ts +10 -2
  49. package/src/models/HttpProject.ts +1 -1
  50. package/src/models/Workspace.ts +16 -54
  51. package/src/models/legacy/models/{base.d.ts → base.ts} +0 -0
  52. package/src/models/store/File.ts +135 -0
  53. package/src/models/store/Group.ts +21 -0
  54. package/src/models/store/Permission.ts +318 -0
  55. package/src/models/store/User.ts +83 -0
  56. package/src/runtime/store/SpacesSdk.ts +5 -5
  57. package/src/runtime/store/UsersSdk.ts +1 -1
  58. package/build/src/models/User.js.map +0 -1
  59. package/src/models/User.ts +0 -138
@@ -1,3 +1,4 @@
1
+ import { File } from "./store/File.js";
1
2
  import { Thing, Kind as ThingKind } from './Thing.js';
2
3
  import v4 from '../lib/uuid.js';
3
4
  export const Kind = 'Core#Space';
@@ -8,7 +9,7 @@ export const DefaultOwner = 'default';
8
9
  * A working space is a logical container in the data store
9
10
  * created by the system users, where they can store their projects and other data.
10
11
  */
11
- export class Workspace {
12
+ export class Workspace extends File {
12
13
  kind = Kind;
13
14
  /**
14
15
  * The space identifier.
@@ -18,26 +19,11 @@ export class Workspace {
18
19
  * The name of the environment.
19
20
  */
20
21
  info = new Thing({ kind: ThingKind });
21
- /**
22
- * The list of users added to this space. May not be set when owner did not add anyone to the space.
23
- */
24
- users;
25
22
  /**
26
23
  * The owner of this space. The id of the User object.
27
24
  * Set to `default` when there are no users in the system (no authentication).
28
25
  */
29
26
  owner = '';
30
- /**
31
- * The list of keys of projects added to the workspace.
32
- * @deprecated This is not actually used.
33
- */
34
- projects = [];
35
- /**
36
- * Only set when the object was created from the data received by the API Client backend.
37
- * Level access of the current user to the space.
38
- * Note, this information is never serialized with the object.
39
- */
40
- access;
41
27
  /**
42
28
  * Creates a new Space object from a name.
43
29
  *
@@ -52,7 +38,9 @@ export class Workspace {
52
38
  kind: Kind,
53
39
  info: info.toJSON(),
54
40
  owner,
55
- projects: [],
41
+ parents: [],
42
+ permissionIds: [],
43
+ permissions: [],
56
44
  });
57
45
  return definition;
58
46
  }
@@ -60,6 +48,7 @@ export class Workspace {
60
48
  * @param input The environment definition used to restore the state.
61
49
  */
62
50
  constructor(input) {
51
+ super();
63
52
  let init;
64
53
  if (typeof input === 'string') {
65
54
  init = JSON.parse(input);
@@ -76,7 +65,9 @@ export class Workspace {
76
65
  name: '',
77
66
  },
78
67
  owner: DefaultOwner,
79
- projects: [],
68
+ parents: [],
69
+ permissionIds: [],
70
+ permissions: [],
80
71
  };
81
72
  }
82
73
  this.new(init);
@@ -90,10 +81,10 @@ export class Workspace {
90
81
  if (!Workspace.isWorkspace(init)) {
91
82
  throw new Error(`Not a space.`);
92
83
  }
93
- const { key = v4(), projects = [], info, owner = DefaultOwner, users } = init;
84
+ super.new(init);
85
+ const { key = v4(), info, owner = DefaultOwner } = init;
94
86
  this.kind = Kind;
95
87
  this.key = key;
96
- this.projects = projects;
97
88
  this.owner = owner;
98
89
  if (info) {
99
90
  this.info = new Thing(info);
@@ -101,16 +92,6 @@ export class Workspace {
101
92
  else {
102
93
  this.info = new Thing({ kind: ThingKind, name: '' });
103
94
  }
104
- if (Array.isArray(users)) {
105
- this.users = [...users];
106
- }
107
- else {
108
- this.users = [];
109
- }
110
- const typed = init;
111
- if (typed.access) {
112
- this.access = typed.access;
113
- }
114
95
  }
115
96
  /**
116
97
  * Checks whether the input is a definition of an user space.
@@ -123,17 +104,14 @@ export class Workspace {
123
104
  return true;
124
105
  }
125
106
  toJSON() {
126
- const { projects = [], owner = DefaultOwner, users } = this;
107
+ const { owner = DefaultOwner } = this;
127
108
  const result = {
128
109
  kind: Kind,
129
110
  key: this.key,
130
111
  info: this.info.toJSON(),
131
- projects,
132
112
  owner,
113
+ ...super.toJSON(),
133
114
  };
134
- if (Array.isArray(users) && users.length) {
135
- result.users = [...users];
136
- }
137
115
  return result;
138
116
  }
139
117
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Workspace.js","sourceRoot":"","sources":["../../../src/models/Workspace.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,KAAK,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEhC,MAAM,CAAC,MAAM,IAAI,GAAG,YAAY,CAAC;AAwCjC,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAC;AAEtC;;;;;GAKG;AACH,MAAM,OAAO,SAAS;IACpB,IAAI,GAAG,IAAI,CAAC;IACZ;;OAEG;IACH,GAAG,GAAG,EAAE,CAAC;IACT;;OAEG;IACH,IAAI,GAAU,IAAI,KAAK,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;IAC7C;;OAEG;IACH,KAAK,CAAY;IACjB;;;OAGG;IACH,KAAK,GAAG,EAAE,CAAC;IACX;;;OAGG;IACH,QAAQ,GAAa,EAAE,CAAC;IACxB;;;;OAIG;IACH,MAAM,CAAsB;IAE5B;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAY,EAAE,KAAK,GAAG,YAAY;QAChD,MAAM,GAAG,GAAG,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,GAAG,IAAI,KAAK,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAClD,MAAM,UAAU,GAAG,IAAI,SAAS,CAAC;YAC/B,GAAG;YACH,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE;YACnB,KAAK;YACL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V,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YACxB,KAAK;YACL,GAAG,KAAK,CAAC,MAAM,EAAE;SAClB,CAAC;QACF,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * @deprecated
3
+ */
4
+ export declare interface Entity {
5
+ /**
6
+ * Pouch DB datastore `_id`
7
+ */
8
+ _id?: string;
9
+ /**
10
+ * Pouch DB datastore `_rev` as a revision of the object
11
+ */
12
+ _rev?: string;
13
+ /**
14
+ * Special flag used by PouchDB to delete an object.
15
+ */
16
+ _deleted?: boolean;
17
+ }
18
+ /**
19
+ * @deprecated
20
+ */
21
+ export declare interface DeletedEntity {
22
+ /**
23
+ * Pouch DB datastore `_id`
24
+ */
25
+ id: string;
26
+ /**
27
+ * Pouch DB datastore revision of the deleted object
28
+ */
29
+ rev: string;
30
+ }
31
+ /**
32
+ * An entity change record base definition
33
+ * @deprecated
34
+ */
35
+ export declare interface ARCEntityChangeRecord<T> {
36
+ /**
37
+ * The ID of the changed entity
38
+ */
39
+ id: string;
40
+ /**
41
+ * The revision of the updated entity.
42
+ * It is not set when old revision is unavailable (new entity is created).
43
+ */
44
+ oldRev?: string;
45
+ /**
46
+ * New revision id of updated entity
47
+ */
48
+ rev: string;
49
+ /**
50
+ * The updated entity.
51
+ */
52
+ item?: T;
53
+ }
54
+ /**
55
+ * Event detail object for data store query result object.
56
+ * @deprecated
57
+ */
58
+ export declare interface ARCModelListResultDetail<T> {
59
+ result: Promise<ARCModelListResult<T>>;
60
+ }
61
+ /**
62
+ * Base query options for the data store.
63
+ * @deprecated
64
+ */
65
+ export declare interface ARCModelListOptions {
66
+ /**
67
+ * The number of results per the page.
68
+ */
69
+ limit?: number;
70
+ /**
71
+ * A string that should be used with pagination.
72
+ */
73
+ nextPageToken?: string;
74
+ }
75
+ /**
76
+ * Data store query result object.
77
+ * @deprecated
78
+ */
79
+ export declare interface ARCModelListResult<T> {
80
+ /**
81
+ * Next page token to be used with pagination.
82
+ * It is not set when the query has not returned any results.
83
+ */
84
+ nextPageToken?: string;
85
+ /**
86
+ * The list of items in the response.
87
+ * May be empty array when there was no more results.
88
+ */
89
+ items: T[];
90
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../../src/models/legacy/models/base.ts"],"names":[],"mappings":""}
@@ -0,0 +1,88 @@
1
+ import { IPermission } from './Permission.js';
2
+ export interface IStoredFile {
3
+ /**
4
+ * The list of parents of the object. It is an ordered list of parents
5
+ * from the top (first element) to the lowest parent in the tree (last element).
6
+ *
7
+ * After creating the object, this property cannot be manipulated directly by the client.
8
+ * Should be treated as opaque value.
9
+ */
10
+ parents: string[];
11
+ /**
12
+ * The list of permissions to this file object.
13
+ *
14
+ * This property cannot be manipulated directly by the client. Should be treated as
15
+ * opaque value.
16
+ */
17
+ permissionIds: string[];
18
+ /**
19
+ * Whether the file object is deleted.
20
+ */
21
+ deleted?: boolean;
22
+ /**
23
+ * The timestamp of when the file was deleted.
24
+ */
25
+ deletedTime?: number;
26
+ /**
27
+ * The id of the user that has deleted the file.
28
+ */
29
+ deletingUser?: string;
30
+ }
31
+ /**
32
+ * An interface describing an object in the data store that
33
+ * describes a file or an object that can be treated as a file or a folder.
34
+ */
35
+ export interface IFile extends IStoredFile {
36
+ /**
37
+ * Populated by the server when reading the file. The list of permissions to the object.
38
+ *
39
+ * This property cannot be manipulated directly by the client. Should be treated as
40
+ * opaque value.
41
+ *
42
+ * Data store implementation note, this is not stored in the store but it is populated
43
+ * when reading the object.
44
+ */
45
+ permissions: IPermission[];
46
+ }
47
+ export declare class StoredFile {
48
+ /**
49
+ * The list of parents of the object. It is an ordered list of parents
50
+ * from the top (first element) to the lowest parent in the tree (last element).
51
+ *
52
+ * This property cannot be manipulated directly by the client. Should be treated as
53
+ * opaque value.
54
+ */
55
+ parents: string[];
56
+ /**
57
+ * The list of permissions to this file object.
58
+ *
59
+ * This property cannot be manipulated directly by the client. Should be treated as
60
+ * opaque value.
61
+ */
62
+ permissionIds: string[];
63
+ /**
64
+ * Whether the file object is deleted.
65
+ */
66
+ deleted?: boolean;
67
+ /**
68
+ * The timestamp of when the file was deleted.
69
+ */
70
+ deletedTime?: number;
71
+ /**
72
+ * The id of the user that has deleted the file.
73
+ */
74
+ deletingUser?: string;
75
+ new(init: IStoredFile): void;
76
+ toJSON(): IStoredFile;
77
+ }
78
+ export declare class File extends StoredFile {
79
+ /**
80
+ * Populated by the server when reading the file. The list of permissions to the object.
81
+ *
82
+ * This property cannot be manipulated directly by the client. Should be treated as
83
+ * opaque value.
84
+ */
85
+ permissions: IPermission[];
86
+ new(init: IFile): void;
87
+ toJSON(): IFile;
88
+ }
@@ -0,0 +1,82 @@
1
+ export class StoredFile {
2
+ /**
3
+ * The list of parents of the object. It is an ordered list of parents
4
+ * from the top (first element) to the lowest parent in the tree (last element).
5
+ *
6
+ * This property cannot be manipulated directly by the client. Should be treated as
7
+ * opaque value.
8
+ */
9
+ parents = [];
10
+ /**
11
+ * The list of permissions to this file object.
12
+ *
13
+ * This property cannot be manipulated directly by the client. Should be treated as
14
+ * opaque value.
15
+ */
16
+ permissionIds = [];
17
+ /**
18
+ * Whether the file object is deleted.
19
+ */
20
+ deleted;
21
+ /**
22
+ * The timestamp of when the file was deleted.
23
+ */
24
+ deletedTime;
25
+ /**
26
+ * The id of the user that has deleted the file.
27
+ */
28
+ deletingUser;
29
+ new(init) {
30
+ const { parents = [], permissionIds = [], deleted, deletedTime, deletingUser } = init;
31
+ this.parents = parents;
32
+ this.permissionIds = permissionIds;
33
+ if (typeof deleted === 'boolean') {
34
+ this.deleted = deleted;
35
+ this.deletedTime = deletedTime;
36
+ this.deletingUser = deletingUser;
37
+ }
38
+ else {
39
+ this.deleted = undefined;
40
+ this.deletedTime = undefined;
41
+ this.deletingUser = undefined;
42
+ }
43
+ }
44
+ toJSON() {
45
+ const result = {
46
+ parents: this.parents,
47
+ permissionIds: this.permissionIds,
48
+ };
49
+ if (typeof this.deleted === 'boolean') {
50
+ result.deleted = this.deleted;
51
+ if (this.deletedTime) {
52
+ result.deletedTime = this.deletedTime;
53
+ }
54
+ if (this.deletingUser) {
55
+ result.deletingUser = this.deletingUser;
56
+ }
57
+ }
58
+ return result;
59
+ }
60
+ }
61
+ export class File extends StoredFile {
62
+ /**
63
+ * Populated by the server when reading the file. The list of permissions to the object.
64
+ *
65
+ * This property cannot be manipulated directly by the client. Should be treated as
66
+ * opaque value.
67
+ */
68
+ permissions = [];
69
+ new(init) {
70
+ super.new(init);
71
+ const { permissions = [] } = init;
72
+ this.permissions = permissions;
73
+ }
74
+ toJSON() {
75
+ const result = {
76
+ ...super.toJSON(),
77
+ permissions: this.permissions,
78
+ };
79
+ return result;
80
+ }
81
+ }
82
+ //# sourceMappingURL=File.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"File.js","sourceRoot":"","sources":["../../../../src/models/store/File.ts"],"names":[],"mappings":"AAiDA,MAAM,OAAO,UAAU;IACrB;;;;;;OAMG;IACH,OAAO,GAAa,EAAE,CAAC;IACvB;;;;;OAKG;IACH,aAAa,GAAa,EAAE,CAAC;IAC7B;;OAEG;IACH,OAAO,CAAW;IAClB;;OAEG;IACH,WAAW,CAAU;IACrB;;OAEG;IACH,YAAY,CAAU;IAEtB,GAAG,CAAC,IAAiB;QACnB,MAAM,EAAE,OAAO,GAAC,EAAE,EAAE,aAAa,GAAC,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;QAClF,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,OAAO,OAAO,KAAK,SAAS,EAAE;YAChC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;YACvB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;YAC/B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;SAClC;aAAM;YACL,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;YACzB,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;YAC7B,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;SAC/B;IACH,CAAC;IAED,MAAM;QACJ,MAAM,MAAM,GAAgB;YAC1B,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,aAAa,EAAE,IAAI,CAAC,aAAa;SAClC,CAAC;QACF,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE;YACrC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;YAE9B,IAAI,IAAI,CAAC,WAAW,EAAE;gBACpB,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;aACvC;YACD,IAAI,IAAI,CAAC,YAAY,EAAE;gBACrB,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;aACzC;SACF;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED,MAAM,OAAO,IAAK,SAAQ,UAAU;IAClC;;;;;OAKG;IACH,WAAW,GAAkB,EAAE,CAAC;IAEhC,GAAG,CAAC,IAAW;QACb,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAChB,MAAM,EAAE,WAAW,GAAC,EAAE,EAAE,GAAG,IAAI,CAAC;QAChC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED,MAAM;QACJ,MAAM,MAAM,GAAU;YACpB,GAAG,KAAK,CAAC,MAAM,EAAE;YACjB,WAAW,EAAE,IAAI,CAAC,WAAW;SAC9B,CAAC;QACF,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * An object representing a user group.
3
+ */
4
+ export interface IGroup {
5
+ /**
6
+ * The key of the group.
7
+ */
8
+ key: string;
9
+ /**
10
+ * The name of the group
11
+ */
12
+ name: string;
13
+ /**
14
+ * The id of the user that created this group.
15
+ */
16
+ owner: string;
17
+ /**
18
+ * The list of users in this group.
19
+ */
20
+ users: string[];
21
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Group.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Group.js","sourceRoot":"","sources":["../../../../src/models/store/Group.ts"],"names":[],"mappings":""}
@@ -0,0 +1,189 @@
1
+ export declare const Kind = "Core#Permission";
2
+ export declare type PermissionType = 'user' | 'group' | 'anyone';
3
+ export declare type PermissionRole = 'owner' | 'reader' | 'commenter' | 'writer';
4
+ /**
5
+ * A schema describing a permission to a store object.
6
+ */
7
+ export interface IPermission {
8
+ kind: typeof Kind;
9
+ /**
10
+ * The data store key of the permission.
11
+ * This property is generated by the store and is not writable.
12
+ */
13
+ key: string;
14
+ /**
15
+ * The type of the permission.
16
+ *
17
+ * - `user` can access the file by a specific user
18
+ * - `group` can access the file by a group of users
19
+ * - `anyone` the object can be searched by anyone who has access to the store.
20
+ *
21
+ * Note, the `anyone` object does not mean that the end-user sees the file when
22
+ * listing objects in the store. It means the file can be searched for.
23
+ */
24
+ type: PermissionType;
25
+ /**
26
+ * The id of the owner of the permission.
27
+ * The value depends on the `type`. For the `user` type it is the user id.
28
+ * The `group` means the group id. It is not set when the role is `anyone`.
29
+ */
30
+ owner?: string;
31
+ /**
32
+ * The role granted by this permission.
33
+ */
34
+ role: PermissionRole;
35
+ /**
36
+ * The "pretty" name to render with the permission.
37
+ *
38
+ * - `user` type - user's full name
39
+ * - `group` type - the name of the group
40
+ * - `anyone` type - no render name
41
+ */
42
+ displayName?: string;
43
+ /**
44
+ * Optional expiration date of the permission. This is the timestamp when the permission expires.
45
+ * When creating / updating the permission the expiration date must:
46
+ *
47
+ * - be used on a user or a group
48
+ * - the time must be in the future
49
+ */
50
+ expirationTime?: number;
51
+ /**
52
+ * The store id of the user that added this permission.
53
+ */
54
+ addingUser: string;
55
+ /**
56
+ * Whether the permission object is deleted.
57
+ */
58
+ deleted?: boolean;
59
+ /**
60
+ * The timestamp of when the permission was deleted.
61
+ */
62
+ deletedTime?: number;
63
+ /**
64
+ * The id of the user that has deleted the permission.
65
+ */
66
+ deletingUser?: string;
67
+ }
68
+ export declare class Permission {
69
+ kind: string;
70
+ /**
71
+ * The data store key of the permission.
72
+ * This property is generated by the store and is not writable.
73
+ */
74
+ key: string;
75
+ /**
76
+ * The type of the permission.
77
+ *
78
+ * - `user` can access the file by a specific user
79
+ * - `group` can access the file by a group of users
80
+ * - `anyone` the object can be searched by anyone who has access to the store.
81
+ *
82
+ * Note, the `anyone` object does not mean that the end-user sees the file when
83
+ * listing objects in the store. It means the file can be searched for.
84
+ */
85
+ type: PermissionType;
86
+ /**
87
+ * The id of the owner of the permission.
88
+ * The value depends on the `type`. For the `user` type it is the user id.
89
+ * The `group` means the group id. It is not set when the role is `anyone`.
90
+ */
91
+ owner?: string;
92
+ /**
93
+ * The role granted by this permission.
94
+ */
95
+ role: PermissionRole;
96
+ /**
97
+ * The "pretty" name to render with the permission.
98
+ *
99
+ * - `user` type - user's full name
100
+ * - `group` type - the name of the group
101
+ * - `anyone` type - no render name
102
+ */
103
+ displayName?: string;
104
+ /**
105
+ * Optional expiration date of the permission. This is the timestamp when the permission expires.
106
+ * When creating / updating the permission the expiration date must:
107
+ *
108
+ * - be used on a user or a group
109
+ * - the time must be in the future
110
+ */
111
+ expirationTime?: number;
112
+ /**
113
+ * The store id of the user that added this permission.
114
+ */
115
+ addingUser: string;
116
+ /**
117
+ * Whether the file object is deleted.
118
+ */
119
+ deleted?: boolean;
120
+ /**
121
+ * The timestamp of when the file was deleted.
122
+ */
123
+ deletedTime?: number;
124
+ /**
125
+ * The id of the user that has deleted the file.
126
+ */
127
+ deletingUser?: string;
128
+ /**
129
+ * Creates a Permission object for a user.
130
+ *
131
+ * @param role The user role to set.
132
+ * @param user The user id that has the role.
133
+ */
134
+ static fromUserRole(role: PermissionRole, user: string, addingUser: string): Permission;
135
+ /**
136
+ * Creates a Permission object for a group.
137
+ *
138
+ * @param role The group role to set.
139
+ * @param group The group id that has the role.
140
+ */
141
+ static fromGroupRole(role: PermissionRole, group: string, addingUser: string): Permission;
142
+ /**
143
+ * Creates a Permission object for a group.
144
+ *
145
+ * @param role The group role to set.
146
+ * @param group The group id that has the role.
147
+ */
148
+ static fromAnyoneRole(role: PermissionRole, addingUser: string): Permission;
149
+ constructor(input?: string | IPermission);
150
+ /**
151
+ * Creates a new environment clearing anything that is so far defined.
152
+ *
153
+ * Note, this throws an error when the environment is not a space.
154
+ */
155
+ new(init: IPermission): void;
156
+ /**
157
+ * Checks whether the input is a definition of an user space.
158
+ */
159
+ static isPermission(input: unknown): boolean;
160
+ toJSON(): IPermission;
161
+ }
162
+ /**
163
+ * This is used in the communication with the backend to add/change user's access to the resource.
164
+ */
165
+ export interface IAccessOperation {
166
+ /**
167
+ * The user or group id. Not populated for `anyone` type.
168
+ */
169
+ id?: string;
170
+ /**
171
+ * The permission type
172
+ */
173
+ type: PermissionType;
174
+ }
175
+ export interface IAccessAddOperation extends IAccessOperation {
176
+ op: "add";
177
+ /**
178
+ * The level that the user or the group has access to.
179
+ */
180
+ value: PermissionRole;
181
+ /**
182
+ * The timestamp when the permission expires.
183
+ */
184
+ expirationTime?: number;
185
+ }
186
+ export interface IAccessRemoveOperation extends IAccessOperation {
187
+ op: "remove";
188
+ }
189
+ export declare type AccessOperation = IAccessAddOperation | IAccessRemoveOperation;