@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.
- package/build/browser.d.ts +5 -2
- package/build/browser.js +3 -1
- package/build/browser.js.map +1 -1
- package/build/index.d.ts +5 -2
- package/build/index.js +3 -1
- 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 +10 -2
- package/build/src/models/HttpProject.js +1 -1
- package/build/src/models/HttpProject.js.map +1 -1
- package/build/src/models/Workspace.d.ts +5 -35
- package/build/src/models/Workspace.js +13 -35
- 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 +88 -0
- package/build/src/models/store/File.js +82 -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 +189 -0
- package/build/src/models/store/Permission.js +211 -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/SpacesSdk.d.ts +4 -4
- 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 +10 -2
- package/src/models/HttpProject.ts +1 -1
- package/src/models/Workspace.ts +16 -54
- package/src/models/legacy/models/{base.d.ts → base.ts} +0 -0
- package/src/models/store/File.ts +135 -0
- package/src/models/store/Group.ts +21 -0
- package/src/models/store/Permission.ts +318 -0
- package/src/models/store/User.ts +83 -0
- package/src/runtime/store/SpacesSdk.ts +5 -5
- 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,211 @@
|
|
|
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
|
+
constructor(input) {
|
|
114
|
+
let init;
|
|
115
|
+
if (typeof input === 'string') {
|
|
116
|
+
init = JSON.parse(input);
|
|
117
|
+
}
|
|
118
|
+
else if (typeof input === 'object') {
|
|
119
|
+
init = input;
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
init = {
|
|
123
|
+
kind: Kind,
|
|
124
|
+
key: v4(),
|
|
125
|
+
owner: '',
|
|
126
|
+
role: 'reader',
|
|
127
|
+
type: 'user',
|
|
128
|
+
addingUser: '',
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
this.new(init);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Creates a new environment clearing anything that is so far defined.
|
|
135
|
+
*
|
|
136
|
+
* Note, this throws an error when the environment is not a space.
|
|
137
|
+
*/
|
|
138
|
+
new(init) {
|
|
139
|
+
if (!Permission.isPermission(init)) {
|
|
140
|
+
throw new Error(`Not a permission.`);
|
|
141
|
+
}
|
|
142
|
+
const { key = v4(), owner, role, type, displayName, expirationTime, addingUser, deleted, deletedTime, deletingUser } = init;
|
|
143
|
+
this.kind = Kind;
|
|
144
|
+
this.key = key;
|
|
145
|
+
this.owner = owner;
|
|
146
|
+
this.role = role;
|
|
147
|
+
this.type = type;
|
|
148
|
+
this.addingUser = addingUser;
|
|
149
|
+
if (displayName) {
|
|
150
|
+
this.displayName = displayName;
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
this.displayName = undefined;
|
|
154
|
+
}
|
|
155
|
+
if (typeof expirationTime === 'number') {
|
|
156
|
+
this.expirationTime = expirationTime;
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
this.expirationTime = undefined;
|
|
160
|
+
}
|
|
161
|
+
if (typeof deleted === 'boolean') {
|
|
162
|
+
this.deleted = deleted;
|
|
163
|
+
this.deletedTime = deletedTime;
|
|
164
|
+
this.deletingUser = deletingUser;
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
this.deleted = undefined;
|
|
168
|
+
this.deletedTime = undefined;
|
|
169
|
+
this.deletingUser = undefined;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Checks whether the input is a definition of an user space.
|
|
174
|
+
*/
|
|
175
|
+
static isPermission(input) {
|
|
176
|
+
const typed = input;
|
|
177
|
+
if (!input || typed.kind !== Kind) {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
return true;
|
|
181
|
+
}
|
|
182
|
+
toJSON() {
|
|
183
|
+
const result = {
|
|
184
|
+
kind: Kind,
|
|
185
|
+
key: this.key,
|
|
186
|
+
role: this.role,
|
|
187
|
+
type: this.type,
|
|
188
|
+
addingUser: this.addingUser,
|
|
189
|
+
};
|
|
190
|
+
if (this.owner) {
|
|
191
|
+
result.owner = this.owner;
|
|
192
|
+
}
|
|
193
|
+
if (this.displayName) {
|
|
194
|
+
result.displayName = this.displayName;
|
|
195
|
+
}
|
|
196
|
+
if (this.expirationTime) {
|
|
197
|
+
result.expirationTime = this.expirationTime;
|
|
198
|
+
}
|
|
199
|
+
if (typeof this.deleted === 'boolean') {
|
|
200
|
+
result.deleted = this.deleted;
|
|
201
|
+
if (this.deletedTime) {
|
|
202
|
+
result.deletedTime = this.deletedTime;
|
|
203
|
+
}
|
|
204
|
+
if (this.deletingUser) {
|
|
205
|
+
result.deletingUser = this.deletingUser;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return result;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
//# 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;AAuEtC,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;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,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;SAC5B,CAAC;QACF,IAAI,IAAI,CAAC,KAAK,EAAE;YACd,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;SAC3B;QACD,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;SACvC;QACD,IAAI,IAAI,CAAC,cAAc,EAAE;YACvB,MAAM,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;SAC7C;QACD,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"}
|
|
@@ -1,38 +1,3 @@
|
|
|
1
|
-
export declare type AccessControlLevel = 'read' | 'comment' | 'write' | 'admin' | 'owner';
|
|
2
|
-
/**
|
|
3
|
-
* This is used in the communication with the backend to add/change user's access to the resource.
|
|
4
|
-
*/
|
|
5
|
-
export interface IUserAccessOperation {
|
|
6
|
-
/**
|
|
7
|
-
* The user id.
|
|
8
|
-
*/
|
|
9
|
-
uid: string;
|
|
10
|
-
}
|
|
11
|
-
export interface IUserAccessAddOperation extends IUserAccessOperation {
|
|
12
|
-
op: "add";
|
|
13
|
-
/**
|
|
14
|
-
* The level that the user has access to.
|
|
15
|
-
*/
|
|
16
|
-
value: AccessControlLevel;
|
|
17
|
-
}
|
|
18
|
-
export interface IUserAccessRemoveOperation extends IUserAccessOperation {
|
|
19
|
-
op: "remove";
|
|
20
|
-
}
|
|
21
|
-
export declare type UserAccessOperation = IUserAccessAddOperation | IUserAccessRemoveOperation;
|
|
22
|
-
/**
|
|
23
|
-
* The definition of an access control.
|
|
24
|
-
* The user may have access to a workspace so this is the object describing the level of the workspace.
|
|
25
|
-
*/
|
|
26
|
-
export interface IAccessControl {
|
|
27
|
-
/**
|
|
28
|
-
* The data store key of the referenced object the user has access to.
|
|
29
|
-
*/
|
|
30
|
-
key: string;
|
|
31
|
-
/**
|
|
32
|
-
* The level that the user has access to.
|
|
33
|
-
*/
|
|
34
|
-
level: AccessControlLevel;
|
|
35
|
-
}
|
|
36
1
|
export interface IEmail {
|
|
37
2
|
/**
|
|
38
3
|
* When available the email of the user.
|
|
@@ -85,6 +50,18 @@ interface BaseUser {
|
|
|
85
50
|
* Optional metadata related to the auth provider.
|
|
86
51
|
*/
|
|
87
52
|
provider?: unknown;
|
|
53
|
+
/**
|
|
54
|
+
* Whether the user is deleted from the system.
|
|
55
|
+
*/
|
|
56
|
+
deleted?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* The timestamp of when the user was deleted.
|
|
59
|
+
*/
|
|
60
|
+
deletedTime?: number;
|
|
61
|
+
/**
|
|
62
|
+
* The id of the user that deleted the user.
|
|
63
|
+
*/
|
|
64
|
+
deletingUser?: string;
|
|
88
65
|
}
|
|
89
66
|
/**
|
|
90
67
|
* Represents a user in the system.
|
|
@@ -100,28 +77,4 @@ export interface IUser extends BaseUser {
|
|
|
100
77
|
*/
|
|
101
78
|
provider?: unknown;
|
|
102
79
|
}
|
|
103
|
-
/**
|
|
104
|
-
* This object may be created for each user in the system.
|
|
105
|
-
* It describes to which spaces user has access to.
|
|
106
|
-
*/
|
|
107
|
-
export interface IUserSpaces {
|
|
108
|
-
/**
|
|
109
|
-
* The list of access to the spaces for the user.
|
|
110
|
-
*/
|
|
111
|
-
spaces: IAccessControl[];
|
|
112
|
-
/**
|
|
113
|
-
* The data store key of the user that has access to the space.
|
|
114
|
-
* This is also the key of the entry.
|
|
115
|
-
*/
|
|
116
|
-
user: string;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* An abstract user object that contains access information to a space.
|
|
120
|
-
*/
|
|
121
|
-
export interface ISpaceUser extends BaseUser {
|
|
122
|
-
/**
|
|
123
|
-
* The level that the user has access to.
|
|
124
|
-
*/
|
|
125
|
-
level: AccessControlLevel;
|
|
126
|
-
}
|
|
127
80
|
export {};
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"User.js","sourceRoot":"","sources":["../../../../src/models/store/User.ts"],"names":[],"mappings":"AAuBA,MAAM,CAAC,MAAM,IAAI,GAAG,WAAW,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { JsonPatch } from 'json8-patch';
|
|
2
2
|
import { SdkBase } from './SdkBase.js';
|
|
3
3
|
import { IListOptions, IListResponse } from '../../models/Backend.js';
|
|
4
|
-
import { IWorkspace,
|
|
5
|
-
import {
|
|
4
|
+
import { IWorkspace, Workspace } from '../../models/Workspace.js';
|
|
5
|
+
import { AccessOperation } from '../../models/store/Permission.js';
|
|
6
6
|
export declare class SpacesSdk extends SdkBase {
|
|
7
7
|
/**
|
|
8
8
|
* Lists spaces in the store.
|
|
@@ -20,7 +20,7 @@ export declare class SpacesSdk extends SdkBase {
|
|
|
20
20
|
* @param key The user space key
|
|
21
21
|
* @returns The definition of the user space.
|
|
22
22
|
*/
|
|
23
|
-
read(key: string): Promise<
|
|
23
|
+
read(key: string): Promise<IWorkspace>;
|
|
24
24
|
/**
|
|
25
25
|
* Patches a user space in the store.
|
|
26
26
|
* @param key The key of the user space to patch
|
|
@@ -40,7 +40,7 @@ export declare class SpacesSdk extends SdkBase {
|
|
|
40
40
|
* @param key The user space key
|
|
41
41
|
* @param value The patch operation on the space's ACL
|
|
42
42
|
*/
|
|
43
|
-
patchUsers(key: string, value:
|
|
43
|
+
patchUsers(key: string, value: AccessOperation[]): Promise<void>;
|
|
44
44
|
/**
|
|
45
45
|
* Lists uses having access to the user space.
|
|
46
46
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpacesSdk.js","sourceRoot":"","sources":["../../../../src/runtime/store/SpacesSdk.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,cAAc,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxI,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,
|
|
1
|
+
{"version":3,"file":"SpacesSdk.js","sourceRoot":"","sources":["../../../../src/runtime/store/SpacesSdk.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,cAAc,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxI,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAyB,IAAI,IAAI,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAGzF,MAAM,OAAO,SAAU,SAAQ,OAAO;IACpC;;;OAGG;IACH,KAAK,CAAC,IAAI,CAAC,OAAsB;QAC/B,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC;QAC3B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;QACnD,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QACzC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAClE,IAAI,CAAC,wBAAwB,C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AC7C,MAAM,QAAQ,GAAG,qCAAqC,CAAC;QACvD,IAAI,MAAM,CAAC,MAAM,KAAK,GAAG,EAAE;YACzB,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,GAAG,QAAQ,GAAG,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;SACpE;QACD,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,GAAG,QAAQ,GAAG,mBAAmB,EAAE,CAAC,CAAC;SACtD;QACD,IAAI,IAAmB,CAAC;QACxB,IAAI;YACF,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;SAChC;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,IAAI,KAAK,CAAC,GAAG,QAAQ,GAAG,cAAc,GAAG,CAAC,CAAC;SAClD;QACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YAC7B,MAAM,IAAI,KAAK,CAAC,GAAG,QAAQ,GAAG,kBAAkB,GAAG,CAAC,CAAC;SACtD;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SdkBase } from './SdkBase.js';
|
|
2
2
|
import { IListOptions, IListResponse } from '../../models/Backend.js';
|
|
3
|
-
import { IUser } from '../../models/User.js';
|
|
3
|
+
import { IUser } from '../../models/store/User.js';
|
|
4
4
|
export declare class UsersSdk extends SdkBase {
|
|
5
5
|
me(): Promise<IUser>;
|
|
6
6
|
/**
|
package/json8-patch.d.ts
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
declare module "json8-patch" {
|
|
2
|
+
export interface BaseOperation {
|
|
3
|
+
path: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface AddOperation extends BaseOperation {
|
|
7
|
+
op: "add";
|
|
8
|
+
value: any;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface RemoveOperation extends BaseOperation {
|
|
12
|
+
op: "remove";
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The JSON patch replace operation
|
|
17
|
+
*/
|
|
18
|
+
export interface ReplaceOperation extends BaseOperation {
|
|
19
|
+
op: "replace";
|
|
20
|
+
value: any;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The JSON patch move operation
|
|
25
|
+
*/
|
|
26
|
+
export interface MoveOperation extends BaseOperation {
|
|
27
|
+
op: "move";
|
|
28
|
+
from: any;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The JSON patch copy operation.
|
|
33
|
+
*/
|
|
34
|
+
export interface CopyOperation extends BaseOperation {
|
|
35
|
+
op: "copy";
|
|
36
|
+
from: any;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The JSON patch test operation
|
|
41
|
+
*/
|
|
42
|
+
export interface TestOperation extends BaseOperation {
|
|
43
|
+
op: "test";
|
|
44
|
+
value: any;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* All possible JSON patch operations
|
|
49
|
+
*/
|
|
50
|
+
export type JsonPatchOperation = AddOperation | RemoveOperation | ReplaceOperation | MoveOperation | CopyOperation | TestOperation;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* A JSON patch as specified in RFC 6902
|
|
54
|
+
*/
|
|
55
|
+
export type JsonPatch = JsonPatchOperation[];
|
|
56
|
+
|
|
57
|
+
export interface ApplyResult<T> {
|
|
58
|
+
doc: T;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface ApplyResultWithRevert<T> extends ApplyResult<T> {
|
|
62
|
+
revert: JsonPatch;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export type PatchResult<T> = ApplyResult<T>;
|
|
66
|
+
export type PatchResultWithRevert<T> = ApplyResultWithRevert<T>;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The operation is atomic, if any of the patch operation fails, the document will be restored to its original state and an error will be thrown.
|
|
70
|
+
* @param doc The document to apply the patch operation to
|
|
71
|
+
* @param patch The patch operations
|
|
72
|
+
* @param options With `{reversible: false}` it will not return an additional value in the form of a `revert` property.
|
|
73
|
+
* @returns An object with a doc property because per specification a patch can replace the original root document.
|
|
74
|
+
*/
|
|
75
|
+
export function apply<T>(doc: T, patch: JsonPatch, options?: { reversible: false }): ApplyResult<T>;
|
|
76
|
+
/**
|
|
77
|
+
* The operation is atomic, if any of the patch operation fails, the document will be restored to its original state and an error will be thrown.
|
|
78
|
+
* @param doc The document to apply the patch operation to
|
|
79
|
+
* @param patch The patch operations
|
|
80
|
+
* @param options With `{reversible: true}` it will return an additional value in the form of a `revert` property.
|
|
81
|
+
* @returns An object with a doc property because per specification a patch can replace the original root document.
|
|
82
|
+
*/
|
|
83
|
+
export function apply<T>(doc: T, patch: JsonPatch, options?: { reversible: true }): ApplyResultWithRevert<T>;
|
|
84
|
+
/**
|
|
85
|
+
* Alias for the `apply()` method.
|
|
86
|
+
*/
|
|
87
|
+
export function patch<T>(doc: T, patch: JsonPatch, options?: { reversible: false }): PatchResult<T>;
|
|
88
|
+
/**
|
|
89
|
+
* Alias for the `apply()` method.
|
|
90
|
+
*/
|
|
91
|
+
export function patch<T>(doc: T, patch: JsonPatch, options?: { reversible: true }): PatchResultWithRevert<T>;
|
|
92
|
+
/**
|
|
93
|
+
* ```javascript
|
|
94
|
+
* ooPatch.diff(true, false);
|
|
95
|
+
* // [{"op": "replace", "path": "", "value": "false"}]
|
|
96
|
+
*
|
|
97
|
+
* ooPatch.diff([], []);
|
|
98
|
+
* // []
|
|
99
|
+
*
|
|
100
|
+
* ooPatch.diff({}, { foo: "bar" });
|
|
101
|
+
* // [{"op": "add", "path": "/foo", "value": "bar"}]
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
104
|
+
* @returns A diff in the form of a JSON Patch for 2 JSON values.
|
|
105
|
+
*/
|
|
106
|
+
export function diff(doc1: unknown, doc2: unknown): JsonPatch;
|
|
107
|
+
/**
|
|
108
|
+
* If the patch or apply method is called with a third argument `{reversible: true}` it will return an additional value in the form of a revert property.
|
|
109
|
+
*
|
|
110
|
+
* The revert object can be used to revert a patch on a document.
|
|
111
|
+
*
|
|
112
|
+
* ```javascript
|
|
113
|
+
* // apply the patch with the reversible option
|
|
114
|
+
* var applyResult = ooPatch.apply(doc, patch, { reversible: true });
|
|
115
|
+
* doc = applyResult.doc;
|
|
116
|
+
*
|
|
117
|
+
* // revert the patch
|
|
118
|
+
* doc = ooPatch.revert(doc, applyResult.revert).doc;
|
|
119
|
+
* // doc is strictly identical to the original
|
|
120
|
+
* ```
|
|
121
|
+
*
|
|
122
|
+
* See also the `buildRevertPatch()` function which offers more flexibility.
|
|
123
|
+
*/
|
|
124
|
+
export function revert<T>(doc: T, revertPatch: JsonPatch): ApplyResult<T>;
|
|
125
|
+
/**
|
|
126
|
+
* This method only check for JSON Patch semantic.
|
|
127
|
+
*
|
|
128
|
+
* ```javascript
|
|
129
|
+
* ooPatch.valid({}) // false
|
|
130
|
+
* ooPatch.valid([{}] // false
|
|
131
|
+
* ooPatch.valid([{op: "foo", path: null, value: undefined}]) // false
|
|
132
|
+
* ooPatch.valid([{op: "add", path: "/foo"}]) // false
|
|
133
|
+
*
|
|
134
|
+
* ooPatch.valid([]) // true
|
|
135
|
+
* ooPatch.valid([{op: "add", path: "/foo", value: "bar"}]) // true
|
|
136
|
+
* ```
|
|
137
|
+
*
|
|
138
|
+
* @returns `true` if the patch is valid, `false` otherwise.
|
|
139
|
+
*/
|
|
140
|
+
export function valid(patch: JsonPatch): boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Builds a valid JSON Patch from the result of a reversible `apply` operation.
|
|
143
|
+
* You can then use this patch with `apply()` method to revert a previously applied patch.
|
|
144
|
+
*
|
|
145
|
+
* Because `buildRevertPatch` + `apply` offers more flexibility over `revert` it is preferred.
|
|
146
|
+
*
|
|
147
|
+
* - use pack/unpack with the result of `buildRevertPatch` making it ideal for storage or transport
|
|
148
|
+
* - reverse a revert (and so on...) with `{reversible: true}`
|
|
149
|
+
* - `diff` between reverts
|
|
150
|
+
* - merge multiple reverts into one
|
|
151
|
+
* - rebase reverts
|
|
152
|
+
*
|
|
153
|
+
* @param revert The revert value from the `apply()` or `patch()` method with `{reversible: true}`
|
|
154
|
+
* @returns JSON Patch
|
|
155
|
+
*/
|
|
156
|
+
export function buildRevertPatch(revert: JsonPatch): JsonPatch;
|
|
157
|
+
|
|
158
|
+
export interface OperationResult<T> {
|
|
159
|
+
/**
|
|
160
|
+
* The patched document
|
|
161
|
+
*/
|
|
162
|
+
doc: T;
|
|
163
|
+
/**
|
|
164
|
+
* The previous/replaced value if any
|
|
165
|
+
*/
|
|
166
|
+
previous?: T;
|
|
167
|
+
idx?: number;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Add the value to the specified JSON Pointer location.
|
|
172
|
+
* @param doc JSON document to set the value to
|
|
173
|
+
* @param path JSON Pointer string or tokens path
|
|
174
|
+
* @param value The value to add
|
|
175
|
+
*/
|
|
176
|
+
export function add<T>(doc: T, path: string | string[], value: unknown): OperationResult<T>;
|
|
177
|
+
/**
|
|
178
|
+
* Copy the value at the specified JSON Pointer location to another location.
|
|
179
|
+
*
|
|
180
|
+
* @param doc JSON document to copy the value from and to
|
|
181
|
+
* @param path JSON Pointer string or tokens path
|
|
182
|
+
* @param dest JSON Pointer string destination of the value
|
|
183
|
+
*/
|
|
184
|
+
export function copy<T>(doc: T, path: string | string[], dest: string): OperationResult<T>;
|
|
185
|
+
/**
|
|
186
|
+
* Moves the value at the specified JSON Pointer location to another location.
|
|
187
|
+
*
|
|
188
|
+
* @param doc JSON document to move the value from and to
|
|
189
|
+
* @param path JSON Pointer string or tokens path
|
|
190
|
+
* @param dest JSON Pointer string destination of the value
|
|
191
|
+
*/
|
|
192
|
+
export function move<T>(doc: T, path: string | string[], dest: string): OperationResult<T>;
|
|
193
|
+
/**
|
|
194
|
+
* Removes the value at the JSON Pointer location.
|
|
195
|
+
*
|
|
196
|
+
* @param doc JSON document to search into
|
|
197
|
+
* @param path JSON Pointer string or tokens patch
|
|
198
|
+
*/
|
|
199
|
+
export function remove<T>(doc: T, path: string | string[]): OperationResult<T>;
|
|
200
|
+
/**
|
|
201
|
+
* Replaces the value at the JSON Pointer location
|
|
202
|
+
*
|
|
203
|
+
* @param doc JSON document
|
|
204
|
+
* @param path JSON Pointer string or tokens patch
|
|
205
|
+
* @param value JSON object to replace with
|
|
206
|
+
*/
|
|
207
|
+
export function replace<T>(doc: T, path: string | string[], value: unknown): OperationResult<T>;
|
|
208
|
+
/**
|
|
209
|
+
* Tests that the value at the specified JSON Pointer location is equal to the specified value.
|
|
210
|
+
*
|
|
211
|
+
* @param doc JSON document
|
|
212
|
+
* @param path JSON Pointer string or tokens patch
|
|
213
|
+
* @param value The value to compare with
|
|
214
|
+
*/
|
|
215
|
+
export function test<T>(doc: T, path: string | string[], value: unknown): OperationResult<T>;
|
|
216
|
+
/**
|
|
217
|
+
* Get the value at the JSON Pointer location.
|
|
218
|
+
*
|
|
219
|
+
* @param doc JSON document
|
|
220
|
+
* @param path JSON Pointer string or tokens patch
|
|
221
|
+
* @returns The value at the JSON Pointer location
|
|
222
|
+
*/
|
|
223
|
+
export function get(doc: unknown, path: string | string[]): unknown;
|
|
224
|
+
/**
|
|
225
|
+
* Checks if the document has the property at the specified JSON Pointer location.
|
|
226
|
+
*
|
|
227
|
+
* @param doc JSON document
|
|
228
|
+
* @param path JSON Pointer string or tokens path
|
|
229
|
+
*/
|
|
230
|
+
export function has(doc: unknown, path: string | string[]): boolean;
|
|
231
|
+
/**
|
|
232
|
+
* Per specification patches are pretty verbose. JSON8 provides the `pack()` and the `unpack()` methods
|
|
233
|
+
* to reduce the size of patches and save memory / space / bandwidth.
|
|
234
|
+
*
|
|
235
|
+
* ```javascript
|
|
236
|
+
* var patch = [
|
|
237
|
+
* { op: "add", path: "/a/b/c", value: ["foo", "bar"] },
|
|
238
|
+
* { op: "remove", path: "/a/b/c" },
|
|
239
|
+
* { op: "replace", path: "/a/b/c", value: 42 },
|
|
240
|
+
* { op: "move", from: "/a/b/c", path: "/a/b/d" },
|
|
241
|
+
* { op: "copy", from: "/a/b/c", path: "/a/b/e" },
|
|
242
|
+
* { op: "test", path: "/a/b/c", value: "foo" },
|
|
243
|
+
* ];
|
|
244
|
+
*
|
|
245
|
+
* var packed = ooPatch.pack(patch);
|
|
246
|
+
*
|
|
247
|
+
* // [
|
|
248
|
+
* // [0, "/a/b/c", ["foo", "bar"]],
|
|
249
|
+
* // [1, "/a/b/c"],
|
|
250
|
+
* // [2, "/a/b/c", 42],
|
|
251
|
+
* // [3, "/a/b/d", "/a/b/c"],
|
|
252
|
+
* // [4, "/a/b/e", "/a/b/c"],
|
|
253
|
+
* // [5, "/a/b/c", "foo"]
|
|
254
|
+
* // ]
|
|
255
|
+
* ```
|
|
256
|
+
*/
|
|
257
|
+
export function pack(patch: JsonPatch): any[];
|
|
258
|
+
/**
|
|
259
|
+
* Reverses the `pack()` on a patch.
|
|
260
|
+
*
|
|
261
|
+
* @param packed Previously packed values.
|
|
262
|
+
* @returns Restored patch value.
|
|
263
|
+
*/
|
|
264
|
+
export function unpack(packed: any[]): JsonPatch;
|
|
265
|
+
/**
|
|
266
|
+
* Concatenates multiple patches into one.
|
|
267
|
+
*/
|
|
268
|
+
export function concat(...patches: JsonPatch): JsonPatch;
|
|
269
|
+
|
|
270
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@api-client/core",
|
|
3
3
|
"description": "The API Client's core client library. Works in NodeJS and in a ES enabled browser.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.5.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "build/index.js",
|
|
7
7
|
"module": "build/index.js",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
},
|
|
85
85
|
"dependencies": {
|
|
86
86
|
"@metrichor/jmespath": "^0.3.1",
|
|
87
|
-
"@pawel-up/data-mock": "^0.
|
|
87
|
+
"@pawel-up/data-mock": "^0.2.0",
|
|
88
88
|
"@pawel-up/jexl": "^3.0.0",
|
|
89
89
|
"@xmldom/xmldom": "^0.8.1",
|
|
90
90
|
"console-table-printer": "^2.10.0",
|