@api-client/core 0.4.3 → 0.5.1
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/browser.d.ts +5 -2
- package/build/browser.js +4 -2
- package/build/browser.js.map +1 -1
- package/build/index.d.ts +5 -2
- package/build/index.js +4 -2
- package/build/index.js.map +1 -1
- package/build/src/mocking/LegacyInterfaces.d.ts +1 -1
- package/build/src/mocking/ProjectMock.d.ts +1 -1
- package/build/src/mocking/legacy/Http.js +1 -1
- package/build/src/mocking/legacy/Http.js.map +1 -1
- package/build/src/mocking/legacy/HttpResponse.d.ts +1 -1
- package/build/src/mocking/legacy/HttpResponse.js +1 -1
- package/build/src/mocking/legacy/HttpResponse.js.map +1 -1
- package/build/src/mocking/lib/User.d.ts +1 -6
- package/build/src/mocking/lib/User.js +1 -15
- package/build/src/mocking/lib/User.js.map +1 -1
- package/build/src/models/Backend.d.ts +11 -2
- package/build/src/models/Workspace.d.ts +5 -46
- package/build/src/models/Workspace.js +12 -43
- package/build/src/models/Workspace.js.map +1 -1
- package/build/src/models/legacy/models/base.d.ts +90 -0
- package/build/src/models/legacy/models/base.js +2 -0
- package/build/src/models/legacy/models/base.js.map +1 -0
- package/build/src/models/store/File.d.ts +98 -0
- package/build/src/models/store/File.js +91 -0
- package/build/src/models/store/File.js.map +1 -0
- package/build/src/models/store/Group.d.ts +21 -0
- package/build/src/models/store/Group.js +2 -0
- package/build/src/models/store/Group.js.map +1 -0
- package/build/src/models/store/Permission.d.ts +196 -0
- package/build/src/models/store/Permission.js +221 -0
- package/build/src/models/store/Permission.js.map +1 -0
- package/build/src/models/{User.d.ts → store/User.d.ts} +12 -59
- package/build/src/models/{User.js → store/User.js} +0 -0
- package/build/src/models/store/User.js.map +1 -0
- package/build/src/runtime/store/RouteBuilder.d.ts +1 -0
- package/build/src/runtime/store/RouteBuilder.js +3 -0
- package/build/src/runtime/store/RouteBuilder.js.map +1 -1
- package/build/src/runtime/store/Sdk.d.ts +5 -0
- package/build/src/runtime/store/Sdk.js +8 -0
- package/build/src/runtime/store/Sdk.js.map +1 -1
- package/build/src/runtime/store/SharedSdk.d.ts +9 -0
- package/build/src/runtime/store/SharedSdk.js +35 -0
- package/build/src/runtime/store/SharedSdk.js.map +1 -0
- package/build/src/runtime/store/SpacesSdk.d.ts +12 -5
- package/build/src/runtime/store/SpacesSdk.js +3 -2
- package/build/src/runtime/store/SpacesSdk.js.map +1 -1
- package/build/src/runtime/store/UsersSdk.d.ts +1 -1
- package/json8-patch.d.ts +270 -0
- package/package.json +2 -2
- package/src/mocking/LegacyInterfaces.ts +1 -1
- package/src/mocking/ProjectMock.ts +1 -1
- package/src/mocking/legacy/Http.ts +1 -1
- package/src/mocking/legacy/HttpResponse.ts +1 -1
- package/src/mocking/lib/User.ts +1 -21
- package/src/models/Backend.ts +11 -2
- package/src/models/Workspace.ts +16 -67
- package/src/models/legacy/models/{base.d.ts → base.ts} +0 -0
- package/src/models/store/File.ts +149 -0
- package/src/models/store/Group.ts +21 -0
- package/src/models/store/Permission.ts +332 -0
- package/src/models/store/User.ts +83 -0
- package/src/runtime/store/RouteBuilder.ts +4 -0
- package/src/runtime/store/Sdk.ts +8 -0
- package/src/runtime/store/SharedSdk.ts +35 -0
- package/src/runtime/store/SpacesSdk.ts +16 -7
- package/src/runtime/store/UsersSdk.ts +1 -1
- package/build/src/models/User.js.map +0 -1
- package/src/models/User.ts +0 -138
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { IPermission } from './Permission.js';
|
|
2
|
+
export declare const DefaultOwner = "default";
|
|
3
|
+
export interface IStoredFile {
|
|
4
|
+
/**
|
|
5
|
+
* The list of parents of the object. It is an ordered list of parents
|
|
6
|
+
* from the top (first element) to the lowest parent in the tree (last element).
|
|
7
|
+
*
|
|
8
|
+
* After creating the object, this property cannot be manipulated directly by the client.
|
|
9
|
+
* Should be treated as opaque value.
|
|
10
|
+
*/
|
|
11
|
+
parents: string[];
|
|
12
|
+
/**
|
|
13
|
+
* The list of permissions to this file object.
|
|
14
|
+
*
|
|
15
|
+
* This property cannot be manipulated directly by the client. Should be treated as
|
|
16
|
+
* opaque value.
|
|
17
|
+
*/
|
|
18
|
+
permissionIds: string[];
|
|
19
|
+
/**
|
|
20
|
+
* Whether the file object is deleted.
|
|
21
|
+
*/
|
|
22
|
+
deleted?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* The timestamp of when the file was deleted.
|
|
25
|
+
*/
|
|
26
|
+
deletedTime?: number;
|
|
27
|
+
/**
|
|
28
|
+
* The id of the user that has deleted the file.
|
|
29
|
+
*/
|
|
30
|
+
deletingUser?: string;
|
|
31
|
+
/**
|
|
32
|
+
* The owner of this object. The id of the User object.
|
|
33
|
+
*/
|
|
34
|
+
owner: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* An interface describing an object in the data store that
|
|
38
|
+
* describes a file or an object that can be treated as a file or a folder.
|
|
39
|
+
*/
|
|
40
|
+
export interface IFile extends IStoredFile {
|
|
41
|
+
/**
|
|
42
|
+
* Populated by the server when reading the file. The list of permissions to the object.
|
|
43
|
+
*
|
|
44
|
+
* This property cannot be manipulated directly by the client. Should be treated as
|
|
45
|
+
* opaque value.
|
|
46
|
+
*
|
|
47
|
+
* Data store implementation note, this is not stored in the store but it is populated
|
|
48
|
+
* when reading the object.
|
|
49
|
+
*/
|
|
50
|
+
permissions: IPermission[];
|
|
51
|
+
}
|
|
52
|
+
export declare class StoredFile {
|
|
53
|
+
/**
|
|
54
|
+
* The list of parents of the object. It is an ordered list of parents
|
|
55
|
+
* from the top (first element) to the lowest parent in the tree (last element).
|
|
56
|
+
*
|
|
57
|
+
* This property cannot be manipulated directly by the client. Should be treated as
|
|
58
|
+
* opaque value.
|
|
59
|
+
*/
|
|
60
|
+
parents: string[];
|
|
61
|
+
/**
|
|
62
|
+
* The list of permissions to this file object.
|
|
63
|
+
*
|
|
64
|
+
* This property cannot be manipulated directly by the client. Should be treated as
|
|
65
|
+
* opaque value.
|
|
66
|
+
*/
|
|
67
|
+
permissionIds: string[];
|
|
68
|
+
/**
|
|
69
|
+
* Whether the file object is deleted.
|
|
70
|
+
*/
|
|
71
|
+
deleted?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* The timestamp of when the file was deleted.
|
|
74
|
+
*/
|
|
75
|
+
deletedTime?: number;
|
|
76
|
+
/**
|
|
77
|
+
* The id of the user that has deleted the file.
|
|
78
|
+
*/
|
|
79
|
+
deletingUser?: string;
|
|
80
|
+
/**
|
|
81
|
+
* The owner of this space. The id of the User object.
|
|
82
|
+
* Set to `default` when there are no users in the system (no authentication).
|
|
83
|
+
*/
|
|
84
|
+
owner: string;
|
|
85
|
+
new(init: IStoredFile): void;
|
|
86
|
+
toJSON(): IStoredFile;
|
|
87
|
+
}
|
|
88
|
+
export declare class File extends StoredFile {
|
|
89
|
+
/**
|
|
90
|
+
* Populated by the server when reading the file. The list of permissions to the object.
|
|
91
|
+
*
|
|
92
|
+
* This property cannot be manipulated directly by the client. Should be treated as
|
|
93
|
+
* opaque value.
|
|
94
|
+
*/
|
|
95
|
+
permissions: IPermission[];
|
|
96
|
+
new(init: IFile): void;
|
|
97
|
+
toJSON(): IFile;
|
|
98
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
export const DefaultOwner = 'default';
|
|
2
|
+
export class StoredFile {
|
|
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
|
+
* This property cannot be manipulated directly by the client. Should be treated as
|
|
8
|
+
* opaque value.
|
|
9
|
+
*/
|
|
10
|
+
parents = [];
|
|
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 = [];
|
|
18
|
+
/**
|
|
19
|
+
* Whether the file object is deleted.
|
|
20
|
+
*/
|
|
21
|
+
deleted;
|
|
22
|
+
/**
|
|
23
|
+
* The timestamp of when the file was deleted.
|
|
24
|
+
*/
|
|
25
|
+
deletedTime;
|
|
26
|
+
/**
|
|
27
|
+
* The id of the user that has deleted the file.
|
|
28
|
+
*/
|
|
29
|
+
deletingUser;
|
|
30
|
+
/**
|
|
31
|
+
* The owner of this space. The id of the User object.
|
|
32
|
+
* Set to `default` when there are no users in the system (no authentication).
|
|
33
|
+
*/
|
|
34
|
+
owner = '';
|
|
35
|
+
new(init) {
|
|
36
|
+
const { parents = [], permissionIds = [], deleted, deletedTime, deletingUser, owner = DefaultOwner } = init;
|
|
37
|
+
this.parents = parents;
|
|
38
|
+
this.permissionIds = permissionIds;
|
|
39
|
+
this.owner = owner;
|
|
40
|
+
if (typeof deleted === 'boolean') {
|
|
41
|
+
this.deleted = deleted;
|
|
42
|
+
this.deletedTime = deletedTime;
|
|
43
|
+
this.deletingUser = deletingUser;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
this.deleted = undefined;
|
|
47
|
+
this.deletedTime = undefined;
|
|
48
|
+
this.deletingUser = undefined;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
toJSON() {
|
|
52
|
+
const { owner = DefaultOwner } = this;
|
|
53
|
+
const result = {
|
|
54
|
+
parents: this.parents,
|
|
55
|
+
permissionIds: this.permissionIds,
|
|
56
|
+
owner,
|
|
57
|
+
};
|
|
58
|
+
if (typeof this.deleted === 'boolean') {
|
|
59
|
+
result.deleted = this.deleted;
|
|
60
|
+
if (this.deletedTime) {
|
|
61
|
+
result.deletedTime = this.deletedTime;
|
|
62
|
+
}
|
|
63
|
+
if (this.deletingUser) {
|
|
64
|
+
result.deletingUser = this.deletingUser;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
export class File extends StoredFile {
|
|
71
|
+
/**
|
|
72
|
+
* Populated by the server when reading the file. The list of permissions to the object.
|
|
73
|
+
*
|
|
74
|
+
* This property cannot be manipulated directly by the client. Should be treated as
|
|
75
|
+
* opaque value.
|
|
76
|
+
*/
|
|
77
|
+
permissions = [];
|
|
78
|
+
new(init) {
|
|
79
|
+
super.new(init);
|
|
80
|
+
const { permissions = [] } = init;
|
|
81
|
+
this.permissions = permissions;
|
|
82
|
+
}
|
|
83
|
+
toJSON() {
|
|
84
|
+
const result = {
|
|
85
|
+
...super.toJSON(),
|
|
86
|
+
permissions: this.permissions,
|
|
87
|
+
};
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=File.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"File.js","sourceRoot":"","sources":["../../../../src/models/store/File.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAC;AAqDtC,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;IACtB;;;OAGG;IACH,KAAK,GAAG,EAAE,CAAC;IAEX,GAAG,CAAC,IAAiB;QACnB,MAAM,EAAE,OAAO,GAAC,EAAE,EAAE,aAAa,GAAC,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,KAAK,GAAG,YAAY,EAAE,GAAG,IAAI,CAAC;QACxG,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,OAAO,OAAO,KAAK,SAAS,EAAE;YAChC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;YACvB,IAAI,CAAC,WAAW,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
|
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 @@
|
|
|
1
|
+
{"version":3,"file":"Group.js","sourceRoot":"","sources":["../../../../src/models/store/Group.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,196 @@
|
|
|
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
|
+
interface IBasePermission {
|
|
5
|
+
/**
|
|
6
|
+
* The type of the permission.
|
|
7
|
+
*
|
|
8
|
+
* - `user` can access the file by a specific user
|
|
9
|
+
* - `group` can access the file by a group of users
|
|
10
|
+
* - `anyone` the object can be searched by anyone who has access to the store.
|
|
11
|
+
*
|
|
12
|
+
* Note, the `anyone` object does not mean that the end-user sees the file when
|
|
13
|
+
* listing objects in the store. It means the file can be searched for.
|
|
14
|
+
*/
|
|
15
|
+
type: PermissionType;
|
|
16
|
+
/**
|
|
17
|
+
* The id of the owner of the permission.
|
|
18
|
+
* The value depends on the `type`. For the `user` type it is the user id.
|
|
19
|
+
* The `group` means the group id. It is not set when the role is `anyone`.
|
|
20
|
+
*/
|
|
21
|
+
owner?: string;
|
|
22
|
+
/**
|
|
23
|
+
* The role granted by this permission.
|
|
24
|
+
*/
|
|
25
|
+
role: PermissionRole;
|
|
26
|
+
/**
|
|
27
|
+
* The "pretty" name to render with the permission.
|
|
28
|
+
*
|
|
29
|
+
* - `user` type - user's full name
|
|
30
|
+
* - `group` type - the name of the group
|
|
31
|
+
* - `anyone` type - no render name
|
|
32
|
+
*/
|
|
33
|
+
displayName?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Optional expiration date of the permission. This is the timestamp when the permission expires.
|
|
36
|
+
* When creating / updating the permission the expiration date must:
|
|
37
|
+
*
|
|
38
|
+
* - be used on a user or a group
|
|
39
|
+
* - the time must be in the future
|
|
40
|
+
*/
|
|
41
|
+
expirationTime?: number;
|
|
42
|
+
/**
|
|
43
|
+
* The store id of the user that added this permission.
|
|
44
|
+
*/
|
|
45
|
+
addingUser: string;
|
|
46
|
+
/**
|
|
47
|
+
* Whether the permission object is deleted.
|
|
48
|
+
*/
|
|
49
|
+
deleted?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* The timestamp of when the permission was deleted.
|
|
52
|
+
*/
|
|
53
|
+
deletedTime?: number;
|
|
54
|
+
/**
|
|
55
|
+
* The id of the user that has deleted the permission.
|
|
56
|
+
*/
|
|
57
|
+
deletingUser?: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* A schema describing a permission to a store object.
|
|
61
|
+
*/
|
|
62
|
+
export interface IPermission extends IBasePermission {
|
|
63
|
+
kind: typeof Kind;
|
|
64
|
+
/**
|
|
65
|
+
* The data store key of the permission.
|
|
66
|
+
* This property is generated by the store and is not writable.
|
|
67
|
+
*/
|
|
68
|
+
key: string;
|
|
69
|
+
}
|
|
70
|
+
export declare class Permission {
|
|
71
|
+
kind: string;
|
|
72
|
+
/**
|
|
73
|
+
* The data store key of the permission.
|
|
74
|
+
* This property is generated by the store and is not writable.
|
|
75
|
+
*/
|
|
76
|
+
key: string;
|
|
77
|
+
/**
|
|
78
|
+
* The type of the permission.
|
|
79
|
+
*
|
|
80
|
+
* - `user` can access the file by a specific user
|
|
81
|
+
* - `group` can access the file by a group of users
|
|
82
|
+
* - `anyone` the object can be searched by anyone who has access to the store.
|
|
83
|
+
*
|
|
84
|
+
* Note, the `anyone` object does not mean that the end-user sees the file when
|
|
85
|
+
* listing objects in the store. It means the file can be searched for.
|
|
86
|
+
*/
|
|
87
|
+
type: PermissionType;
|
|
88
|
+
/**
|
|
89
|
+
* The id of the owner of the permission.
|
|
90
|
+
* The value depends on the `type`. For the `user` type it is the user id.
|
|
91
|
+
* The `group` means the group id. It is not set when the role is `anyone`.
|
|
92
|
+
*/
|
|
93
|
+
owner?: string;
|
|
94
|
+
/**
|
|
95
|
+
* The role granted by this permission.
|
|
96
|
+
*/
|
|
97
|
+
role: PermissionRole;
|
|
98
|
+
/**
|
|
99
|
+
* The "pretty" name to render with the permission.
|
|
100
|
+
*
|
|
101
|
+
* - `user` type - user's full name
|
|
102
|
+
* - `group` type - the name of the group
|
|
103
|
+
* - `anyone` type - no render name
|
|
104
|
+
*/
|
|
105
|
+
displayName?: string;
|
|
106
|
+
/**
|
|
107
|
+
* Optional expiration date of the permission. This is the timestamp when the permission expires.
|
|
108
|
+
* When creating / updating the permission the expiration date must:
|
|
109
|
+
*
|
|
110
|
+
* - be used on a user or a group
|
|
111
|
+
* - the time must be in the future
|
|
112
|
+
*/
|
|
113
|
+
expirationTime?: number;
|
|
114
|
+
/**
|
|
115
|
+
* The store id of the user that added this permission.
|
|
116
|
+
*/
|
|
117
|
+
addingUser: string;
|
|
118
|
+
/**
|
|
119
|
+
* Whether the file object is deleted.
|
|
120
|
+
*/
|
|
121
|
+
deleted?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* The timestamp of when the file was deleted.
|
|
124
|
+
*/
|
|
125
|
+
deletedTime?: number;
|
|
126
|
+
/**
|
|
127
|
+
* The id of the user that has deleted the file.
|
|
128
|
+
*/
|
|
129
|
+
deletingUser?: string;
|
|
130
|
+
/**
|
|
131
|
+
* Creates a Permission object for a user.
|
|
132
|
+
*
|
|
133
|
+
* @param role The user role to set.
|
|
134
|
+
* @param user The user id that has the role.
|
|
135
|
+
*/
|
|
136
|
+
static fromUserRole(role: PermissionRole, user: string, addingUser: string): Permission;
|
|
137
|
+
/**
|
|
138
|
+
* Creates a Permission object for a group.
|
|
139
|
+
*
|
|
140
|
+
* @param role The group role to set.
|
|
141
|
+
* @param group The group id that has the role.
|
|
142
|
+
*/
|
|
143
|
+
static fromGroupRole(role: PermissionRole, group: string, addingUser: string): Permission;
|
|
144
|
+
/**
|
|
145
|
+
* Creates a Permission object for a group.
|
|
146
|
+
*
|
|
147
|
+
* @param role The group role to set.
|
|
148
|
+
* @param group The group id that has the role.
|
|
149
|
+
*/
|
|
150
|
+
static fromAnyoneRole(role: PermissionRole, addingUser: string): Permission;
|
|
151
|
+
/**
|
|
152
|
+
* Creates a permission object from other than key and kind values.
|
|
153
|
+
*/
|
|
154
|
+
static fromValues(init: IBasePermission): Permission;
|
|
155
|
+
constructor(input?: string | IPermission);
|
|
156
|
+
/**
|
|
157
|
+
* Creates a new environment clearing anything that is so far defined.
|
|
158
|
+
*
|
|
159
|
+
* Note, this throws an error when the environment is not a space.
|
|
160
|
+
*/
|
|
161
|
+
new(init: IPermission): void;
|
|
162
|
+
/**
|
|
163
|
+
* Checks whether the input is a definition of an user space.
|
|
164
|
+
*/
|
|
165
|
+
static isPermission(input: unknown): boolean;
|
|
166
|
+
toJSON(): IPermission;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* This is used in the communication with the backend to add/change user's access to the resource.
|
|
170
|
+
*/
|
|
171
|
+
export interface IAccessOperation {
|
|
172
|
+
/**
|
|
173
|
+
* The user or group id. Not populated for `anyone` type.
|
|
174
|
+
*/
|
|
175
|
+
id?: string;
|
|
176
|
+
/**
|
|
177
|
+
* The permission type
|
|
178
|
+
*/
|
|
179
|
+
type: PermissionType;
|
|
180
|
+
}
|
|
181
|
+
export interface IAccessAddOperation extends IAccessOperation {
|
|
182
|
+
op: "add";
|
|
183
|
+
/**
|
|
184
|
+
* The level that the user or the group has access to.
|
|
185
|
+
*/
|
|
186
|
+
value: PermissionRole;
|
|
187
|
+
/**
|
|
188
|
+
* The timestamp when the permission expires.
|
|
189
|
+
*/
|
|
190
|
+
expirationTime?: number;
|
|
191
|
+
}
|
|
192
|
+
export interface IAccessRemoveOperation extends IAccessOperation {
|
|
193
|
+
op: "remove";
|
|
194
|
+
}
|
|
195
|
+
export declare type AccessOperation = IAccessAddOperation | IAccessRemoveOperation;
|
|
196
|
+
export {};
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import v4 from '../../lib/uuid.js';
|
|
2
|
+
export const Kind = 'Core#Permission';
|
|
3
|
+
export class Permission {
|
|
4
|
+
kind = Kind;
|
|
5
|
+
/**
|
|
6
|
+
* The data store key of the permission.
|
|
7
|
+
* This property is generated by the store and is not writable.
|
|
8
|
+
*/
|
|
9
|
+
key = '';
|
|
10
|
+
/**
|
|
11
|
+
* The type of the permission.
|
|
12
|
+
*
|
|
13
|
+
* - `user` can access the file by a specific user
|
|
14
|
+
* - `group` can access the file by a group of users
|
|
15
|
+
* - `anyone` the object can be searched by anyone who has access to the store.
|
|
16
|
+
*
|
|
17
|
+
* Note, the `anyone` object does not mean that the end-user sees the file when
|
|
18
|
+
* listing objects in the store. It means the file can be searched for.
|
|
19
|
+
*/
|
|
20
|
+
type = 'user';
|
|
21
|
+
/**
|
|
22
|
+
* The id of the owner of the permission.
|
|
23
|
+
* The value depends on the `type`. For the `user` type it is the user id.
|
|
24
|
+
* The `group` means the group id. It is not set when the role is `anyone`.
|
|
25
|
+
*/
|
|
26
|
+
owner;
|
|
27
|
+
/**
|
|
28
|
+
* The role granted by this permission.
|
|
29
|
+
*/
|
|
30
|
+
role = 'reader';
|
|
31
|
+
/**
|
|
32
|
+
* The "pretty" name to render with the permission.
|
|
33
|
+
*
|
|
34
|
+
* - `user` type - user's full name
|
|
35
|
+
* - `group` type - the name of the group
|
|
36
|
+
* - `anyone` type - no render name
|
|
37
|
+
*/
|
|
38
|
+
displayName;
|
|
39
|
+
/**
|
|
40
|
+
* Optional expiration date of the permission. This is the timestamp when the permission expires.
|
|
41
|
+
* When creating / updating the permission the expiration date must:
|
|
42
|
+
*
|
|
43
|
+
* - be used on a user or a group
|
|
44
|
+
* - the time must be in the future
|
|
45
|
+
*/
|
|
46
|
+
expirationTime;
|
|
47
|
+
/**
|
|
48
|
+
* The store id of the user that added this permission.
|
|
49
|
+
*/
|
|
50
|
+
addingUser = '';
|
|
51
|
+
/**
|
|
52
|
+
* Whether the file object is deleted.
|
|
53
|
+
*/
|
|
54
|
+
deleted;
|
|
55
|
+
/**
|
|
56
|
+
* The timestamp of when the file was deleted.
|
|
57
|
+
*/
|
|
58
|
+
deletedTime;
|
|
59
|
+
/**
|
|
60
|
+
* The id of the user that has deleted the file.
|
|
61
|
+
*/
|
|
62
|
+
deletingUser;
|
|
63
|
+
/**
|
|
64
|
+
* Creates a Permission object for a user.
|
|
65
|
+
*
|
|
66
|
+
* @param role The user role to set.
|
|
67
|
+
* @param user The user id that has the role.
|
|
68
|
+
*/
|
|
69
|
+
static fromUserRole(role, user, addingUser) {
|
|
70
|
+
const init = {
|
|
71
|
+
key: v4(),
|
|
72
|
+
kind: Kind,
|
|
73
|
+
owner: user,
|
|
74
|
+
role,
|
|
75
|
+
type: 'user',
|
|
76
|
+
addingUser,
|
|
77
|
+
};
|
|
78
|
+
return new Permission(init);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Creates a Permission object for a group.
|
|
82
|
+
*
|
|
83
|
+
* @param role The group role to set.
|
|
84
|
+
* @param group The group id that has the role.
|
|
85
|
+
*/
|
|
86
|
+
static fromGroupRole(role, group, addingUser) {
|
|
87
|
+
const init = {
|
|
88
|
+
key: v4(),
|
|
89
|
+
kind: Kind,
|
|
90
|
+
owner: group,
|
|
91
|
+
role,
|
|
92
|
+
type: 'group',
|
|
93
|
+
addingUser,
|
|
94
|
+
};
|
|
95
|
+
return new Permission(init);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Creates a Permission object for a group.
|
|
99
|
+
*
|
|
100
|
+
* @param role The group role to set.
|
|
101
|
+
* @param group The group id that has the role.
|
|
102
|
+
*/
|
|
103
|
+
static fromAnyoneRole(role, addingUser) {
|
|
104
|
+
const init = {
|
|
105
|
+
key: v4(),
|
|
106
|
+
kind: Kind,
|
|
107
|
+
role,
|
|
108
|
+
type: 'anyone',
|
|
109
|
+
addingUser,
|
|
110
|
+
};
|
|
111
|
+
return new Permission(init);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Creates a permission object from other than key and kind values.
|
|
115
|
+
*/
|
|
116
|
+
static fromValues(init) {
|
|
117
|
+
return new Permission({
|
|
118
|
+
...init,
|
|
119
|
+
key: v4(),
|
|
120
|
+
kind: Kind,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
constructor(input) {
|
|
124
|
+
let init;
|
|
125
|
+
if (typeof input === 'string') {
|
|
126
|
+
init = JSON.parse(input);
|
|
127
|
+
}
|
|
128
|
+
else if (typeof input === 'object') {
|
|
129
|
+
init = input;
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
init = {
|
|
133
|
+
kind: Kind,
|
|
134
|
+
key: v4(),
|
|
135
|
+
owner: '',
|
|
136
|
+
role: 'reader',
|
|
137
|
+
type: 'user',
|
|
138
|
+
addingUser: '',
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
this.new(init);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Creates a new environment clearing anything that is so far defined.
|
|
145
|
+
*
|
|
146
|
+
* Note, this throws an error when the environment is not a space.
|
|
147
|
+
*/
|
|
148
|
+
new(init) {
|
|
149
|
+
if (!Permission.isPermission(init)) {
|
|
150
|
+
throw new Error(`Not a permission.`);
|
|
151
|
+
}
|
|
152
|
+
const { key = v4(), owner, role, type, displayName, expirationTime, addingUser, deleted, deletedTime, deletingUser } = init;
|
|
153
|
+
this.kind = Kind;
|
|
154
|
+
this.key = key;
|
|
155
|
+
this.owner = owner;
|
|
156
|
+
this.role = role;
|
|
157
|
+
this.type = type;
|
|
158
|
+
this.addingUser = addingUser;
|
|
159
|
+
if (displayName) {
|
|
160
|
+
this.displayName = displayName;
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
this.displayName = undefined;
|
|
164
|
+
}
|
|
165
|
+
if (typeof expirationTime === 'number') {
|
|
166
|
+
this.expirationTime = expirationTime;
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
this.expirationTime = undefined;
|
|
170
|
+
}
|
|
171
|
+
if (typeof deleted === 'boolean') {
|
|
172
|
+
this.deleted = deleted;
|
|
173
|
+
this.deletedTime = deletedTime;
|
|
174
|
+
this.deletingUser = deletingUser;
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
this.deleted = undefined;
|
|
178
|
+
this.deletedTime = undefined;
|
|
179
|
+
this.deletingUser = undefined;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Checks whether the input is a definition of an user space.
|
|
184
|
+
*/
|
|
185
|
+
static isPermission(input) {
|
|
186
|
+
const typed = input;
|
|
187
|
+
if (!input || typed.kind !== Kind) {
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
|
+
toJSON() {
|
|
193
|
+
const result = {
|
|
194
|
+
kind: Kind,
|
|
195
|
+
key: this.key,
|
|
196
|
+
role: this.role,
|
|
197
|
+
type: this.type,
|
|
198
|
+
addingUser: this.addingUser,
|
|
199
|
+
};
|
|
200
|
+
if (this.owner) {
|
|
201
|
+
result.owner = this.owner;
|
|
202
|
+
}
|
|
203
|
+
if (this.displayName) {
|
|
204
|
+
result.displayName = this.displayName;
|
|
205
|
+
}
|
|
206
|
+
if (this.expirationTime) {
|
|
207
|
+
result.expirationTime = this.expirationTime;
|
|
208
|
+
}
|
|
209
|
+
if (typeof this.deleted === 'boolean') {
|
|
210
|
+
result.deleted = this.deleted;
|
|
211
|
+
if (this.deletedTime) {
|
|
212
|
+
result.deletedTime = this.deletedTime;
|
|
213
|
+
}
|
|
214
|
+
if (this.deletingUser) {
|
|
215
|
+
result.deletingUser = this.deletingUser;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return result;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
//# sourceMappingURL=Permission.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Permission.js","sourceRoot":"","sources":["../../../../src/models/store/Permission.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEnC,MAAM,CAAC,MAAM,IAAI,GAAG,iBAAiB,CAAC;AA0EtC,MAAM,OAAO,UAAU;IACrB,IAAI,GAAG,IAAI,CAAC;IACZ;;;OAGG;IACH,GAAG,GAAG,EAAE,CAAC;IACT;;;;;;;;;OASG;IACH,IAAI,GAAmB,MAAM,CAAC;IAC9B;;;;OAIG;IACH,KAAK,CAAU;IACf;;OAEG;IACH,IAAI,GAAmB,QAAQ,CAAC;IAChC;;;;;;OAMG;IACH,WAAW,CAAU;IACrB;;;;;;OAMG;IACH,cAAc,CAAU;IAExB;;OAEG;IACH,UAAU,GAAW,EAAE,CAAC;IAExB;;OAEG;IACH,OAAO,CAAW;IAClB;;OAEG;IACH,WAAW,CAAU;IACrB;;OAEG;IACH,YAAY,CAAU;IAEtB;;;;;OAKG;IACH,MAAM,CAAC,YAAY,CAAC,IAAoB,EAAE,IAAY,EAAE,UAAkB;QACxE,MAAM,IAAI,GAAgB;YACxB,GAAG,EAAE,EAAE,EAAE;YACT,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,IAAI;YACX,IAAI;YACJ,IAAI,EAAE,MAAM;YACZ,UAAU;SACX,CAAC;QACF,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,aAAa,CAAC,IAAoB,EAAE,KAAa,EAAE,UAAkB;QAC1E,MAAM,IAAI,GAAgB;YACxB,G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