@api-client/core 0.4.4 → 0.5.2
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 +6 -4
- package/build/browser.js +5 -3
- package/build/browser.js.map +1 -1
- package/build/index.d.ts +6 -4
- package/build/index.js +5 -3
- package/build/index.js.map +1 -1
- package/build/src/mocking/ProjectMock.d.ts +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/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 +17 -5
- package/build/src/runtime/store/SpacesSdk.js +11 -2
- package/build/src/runtime/store/SpacesSdk.js.map +1 -1
- package/build/src/runtime/store/StoreSdkNode.d.ts +2 -0
- package/build/src/runtime/store/StoreSdkNode.js.map +1 -1
- package/build/src/runtime/store/StoreSdkWeb.d.ts +2 -0
- package/build/src/runtime/store/StoreSdkWeb.js.map +1 -1
- package/build/src/runtime/store/UsersSdk.d.ts +1 -1
- package/package.json +1 -1
- package/src/mocking/ProjectMock.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/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 +26 -7
- package/src/runtime/store/StoreSdkNode.ts +3 -0
- package/src/runtime/store/StoreSdkWeb.ts +3 -0
- package/src/runtime/store/UsersSdk.ts +1 -1
- package/build/src/models/User.js.map +0 -1
- package/src/models/User.ts +0 -138
|
@@ -4,6 +4,7 @@ import { SpacesSdk } from './SpacesSdk.js';
|
|
|
4
4
|
import { ProjectsSdk } from './ProjectsSdk.js';
|
|
5
5
|
import { UsersSdk } from './UsersSdk.js';
|
|
6
6
|
import { HistorySdk } from './HistorySdk.js';
|
|
7
|
+
import { SharedSdk } from './SharedSdk.js';
|
|
7
8
|
const baseUriSymbol = Symbol('baseUri');
|
|
8
9
|
/**
|
|
9
10
|
* NodeJS API for API Client's net-store module.
|
|
@@ -38,6 +39,10 @@ export class Sdk {
|
|
|
38
39
|
* The history data.
|
|
39
40
|
*/
|
|
40
41
|
history = new HistorySdk(this);
|
|
42
|
+
/**
|
|
43
|
+
* The shared data.
|
|
44
|
+
*/
|
|
45
|
+
shared = new SharedSdk(this);
|
|
41
46
|
[baseUriSymbol] = '';
|
|
42
47
|
/**
|
|
43
48
|
* @returns The base URI to the store.
|
|
@@ -111,6 +116,9 @@ export class Sdk {
|
|
|
111
116
|
searchParams.append('queryField', field);
|
|
112
117
|
});
|
|
113
118
|
}
|
|
119
|
+
if (options.parent) {
|
|
120
|
+
searchParams.set('parent', options.parent);
|
|
121
|
+
}
|
|
114
122
|
}
|
|
115
123
|
}
|
|
116
124
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sdk.js","sourceRoot":"","sources":["../../../../src/runtime/store/Sdk.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"Sdk.js","sourceRoot":"","sources":["../../../../src/runtime/store/Sdk.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,aAAa,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;AAExC;;GAEG;AACH,MAAM,OAAgB,GAAG;IA8Ea;IA7EpC;;OAEG;IACH,KAAK,CAAU;IACf;;OAEG;IACH,IAAI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB;;OA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C,CAAC;aAC5C;SACF;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SdkBase } from './SdkBase.js';
|
|
2
|
+
import { IListOptions, IListResponse } from '../../models/Backend.js';
|
|
3
|
+
export declare class SharedSdk extends SdkBase {
|
|
4
|
+
/**
|
|
5
|
+
* Lists shared with the user spaces.
|
|
6
|
+
* @param options Optional query options.
|
|
7
|
+
*/
|
|
8
|
+
list(options?: IListOptions): Promise<IListResponse>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { SdkBase, E_RESPONSE_STATUS, E_RESPONSE_NO_VALUE, E_INVALID_JSON, E_RESPONSE_UNKNOWN } from './SdkBase.js';
|
|
2
|
+
import { RouteBuilder } from './RouteBuilder.js';
|
|
3
|
+
export class SharedSdk extends SdkBase {
|
|
4
|
+
/**
|
|
5
|
+
* Lists shared with the user spaces.
|
|
6
|
+
* @param options Optional query options.
|
|
7
|
+
*/
|
|
8
|
+
async list(options) {
|
|
9
|
+
const { token } = this.sdk;
|
|
10
|
+
const url = this.sdk.getUrl(RouteBuilder.sharedSpaces());
|
|
11
|
+
this.sdk.appendListOptions(url, options);
|
|
12
|
+
const result = await this.sdk.http.get(url.toString(), { token });
|
|
13
|
+
this.inspectCommonStatusCodes(result.status);
|
|
14
|
+
const E_PREFIX = 'Unable to list spaces. ';
|
|
15
|
+
if (result.status !== 200) {
|
|
16
|
+
this.logInvalidResponse(result);
|
|
17
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
|
|
18
|
+
}
|
|
19
|
+
if (!result.body) {
|
|
20
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
21
|
+
}
|
|
22
|
+
let data;
|
|
23
|
+
try {
|
|
24
|
+
data = JSON.parse(result.body);
|
|
25
|
+
}
|
|
26
|
+
catch (e) {
|
|
27
|
+
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
28
|
+
}
|
|
29
|
+
if (!Array.isArray(data.data)) {
|
|
30
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
|
|
31
|
+
}
|
|
32
|
+
return data;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=SharedSdk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SharedSdk.js","sourceRoot":"","sources":["../../../../src/runtime/store/SharedSdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACnH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,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,YAAY,EAAE,CAAC,CAAC;QACzD,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,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC7C,MAAM,QAAQ,GAAG,yBAAyB,CAAC;QAC3C,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,8 +1,16 @@
|
|
|
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
|
+
import WebSocketNode from 'ws';
|
|
7
|
+
export interface ISpaceCreateOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Optional parent space id.
|
|
10
|
+
* When set it creates a space under this parent.
|
|
11
|
+
*/
|
|
12
|
+
parent?: string;
|
|
13
|
+
}
|
|
6
14
|
export declare class SpacesSdk extends SdkBase {
|
|
7
15
|
/**
|
|
8
16
|
* Lists spaces in the store.
|
|
@@ -14,13 +22,13 @@ export declare class SpacesSdk extends SdkBase {
|
|
|
14
22
|
* @param space The workspace definition.
|
|
15
23
|
* @returns The key of the creates space.
|
|
16
24
|
*/
|
|
17
|
-
create(space: IWorkspace | Workspace): Promise<string>;
|
|
25
|
+
create(space: IWorkspace | Workspace, opts?: ISpaceCreateOptions): Promise<string>;
|
|
18
26
|
/**
|
|
19
27
|
* Reads a user space definition from the store.
|
|
20
28
|
* @param key The user space key
|
|
21
29
|
* @returns The definition of the user space.
|
|
22
30
|
*/
|
|
23
|
-
read(key: string): Promise<
|
|
31
|
+
read(key: string): Promise<IWorkspace>;
|
|
24
32
|
/**
|
|
25
33
|
* Patches a user space in the store.
|
|
26
34
|
* @param key The key of the user space to patch
|
|
@@ -40,11 +48,15 @@ export declare class SpacesSdk extends SdkBase {
|
|
|
40
48
|
* @param key The user space key
|
|
41
49
|
* @param value The patch operation on the space's ACL
|
|
42
50
|
*/
|
|
43
|
-
patchUsers(key: string, value:
|
|
51
|
+
patchUsers(key: string, value: AccessOperation[]): Promise<void>;
|
|
44
52
|
/**
|
|
45
53
|
* Lists uses having access to the user space.
|
|
46
54
|
*
|
|
47
55
|
* @param key The user space key
|
|
48
56
|
*/
|
|
49
57
|
listUsers(key: string): Promise<IListResponse>;
|
|
58
|
+
/**
|
|
59
|
+
* Creates a WS client that listens to the spaces events.
|
|
60
|
+
*/
|
|
61
|
+
observeSpaces(): Promise<WebSocketNode | WebSocket>;
|
|
50
62
|
}
|
|
@@ -37,9 +37,10 @@ export class SpacesSdk extends SdkBase {
|
|
|
37
37
|
* @param space The workspace definition.
|
|
38
38
|
* @returns The key of the creates space.
|
|
39
39
|
*/
|
|
40
|
-
async create(space) {
|
|
40
|
+
async create(space, opts = {}) {
|
|
41
41
|
const { token } = this.sdk;
|
|
42
|
-
const
|
|
42
|
+
const path = opts.parent ? RouteBuilder.space(opts.parent) : RouteBuilder.spaces();
|
|
43
|
+
const url = this.sdk.getUrl(path);
|
|
43
44
|
const body = JSON.stringify(space);
|
|
44
45
|
const result = await this.sdk.http.post(url.toString(), { token, body });
|
|
45
46
|
this.inspectCommonStatusCodes(result.status);
|
|
@@ -181,5 +182,13 @@ export class SpacesSdk extends SdkBase {
|
|
|
181
182
|
}
|
|
182
183
|
return data;
|
|
183
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* Creates a WS client that listens to the spaces events.
|
|
187
|
+
*/
|
|
188
|
+
async observeSpaces() {
|
|
189
|
+
const { token } = this.sdk;
|
|
190
|
+
const url = this.sdk.getUrl(RouteBuilder.spaces());
|
|
191
|
+
return this.sdk.ws.createAndConnect(url.toString(), token);
|
|
192
|
+
}
|
|
184
193
|
}
|
|
185
194
|
//# sourceMappingURL=SpacesSdk.js.map
|
|
@@ -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;AAYzF,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,CAA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AC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;QACnD,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,gBAAgB,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,KAAK,CAAC,CAAC;IAC7D,CAAC;CACF"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Sdk } from './Sdk.js';
|
|
2
2
|
import { Http } from './Http.js';
|
|
3
3
|
import { WsClient } from './WsClient.js';
|
|
4
|
+
export { IStoreTokenInfo, IStoreResponse, IStoreRequestOptions } from './SdkBase.js';
|
|
5
|
+
export { ISpaceCreateOptions } from './SpacesSdk.js';
|
|
4
6
|
/**
|
|
5
7
|
* NodeJS API for API Client's net-store module.
|
|
6
8
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StoreSdkNode.js","sourceRoot":"","sources":["../../../../src/runtime/store/StoreSdkNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"StoreSdkNode.js","sourceRoot":"","sources":["../../../../src/runtime/store/StoreSdkNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAO/B;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,GAAG;IAC/B,IAAI,GAAS,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;IAChC,EAAE,GAAa,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;CACvC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Sdk } from './Sdk.js';
|
|
2
2
|
import { Http } from './Http.js';
|
|
3
3
|
import { WsClient } from './WsClient.js';
|
|
4
|
+
export { IStoreTokenInfo, IStoreResponse, IStoreRequestOptions } from './SdkBase.js';
|
|
5
|
+
export { ISpaceCreateOptions } from './SpacesSdk.js';
|
|
4
6
|
/**
|
|
5
7
|
* NodeJS API for API Client's net-store module.
|
|
6
8
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StoreSdkWeb.js","sourceRoot":"","sources":["../../../../src/runtime/store/StoreSdkWeb.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"StoreSdkWeb.js","sourceRoot":"","sources":["../../../../src/runtime/store/StoreSdkWeb.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAO/B;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,GAAG;IAC/B,IAAI,GAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,EAAE,GAAa,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC;CACtC"}
|
|
@@ -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/package.json
CHANGED
|
@@ -6,7 +6,7 @@ import { History } from './lib/History.js';
|
|
|
6
6
|
|
|
7
7
|
export { IRequestLogInit } from './lib/Request.js';
|
|
8
8
|
export { IResponseInit } from './lib/Response.js';
|
|
9
|
-
export {
|
|
9
|
+
export { IUserInit } from './lib/User.js';
|
|
10
10
|
export { IHttpHistoryInit, IHttpHistoryListInit } from './lib/History.js';
|
|
11
11
|
|
|
12
12
|
export class ProjectMock extends DataMock {
|
package/src/mocking/lib/User.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Internet, Types, DataMockInit, Person, Random } from '@pawel-up/data-mock';
|
|
2
2
|
// import { randomValue } from '@pawel-up/data-mock/src/lib/Http.js';
|
|
3
|
-
import { IUser,
|
|
4
|
-
|
|
3
|
+
import { IUser, Kind as UserKind } from '../../models/store/User.js';
|
|
5
4
|
|
|
6
5
|
export interface IUserInit {
|
|
7
6
|
noEmail?: boolean;
|
|
@@ -9,13 +8,6 @@ export interface IUserInit {
|
|
|
9
8
|
noProvider?: boolean;
|
|
10
9
|
}
|
|
11
10
|
|
|
12
|
-
export interface ISpaceUserInit extends IUserInit {
|
|
13
|
-
level?: AccessControlLevel;
|
|
14
|
-
levelPool?: AccessControlLevel[];
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const accessPool: AccessControlLevel[] = ['read', 'comment', 'write', 'admin', 'owner'];
|
|
18
|
-
|
|
19
11
|
export class User {
|
|
20
12
|
person: Person;
|
|
21
13
|
types: Types;
|
|
@@ -53,16 +45,4 @@ export class User {
|
|
|
53
45
|
}
|
|
54
46
|
return result;
|
|
55
47
|
}
|
|
56
|
-
|
|
57
|
-
spaceUser(init: ISpaceUserInit = {}): ISpaceUser {
|
|
58
|
-
const user = this.user(init) as ISpaceUser;
|
|
59
|
-
if (init.level) {
|
|
60
|
-
user.level = init.level;
|
|
61
|
-
} else if (Array.isArray(init.levelPool)) {
|
|
62
|
-
user.level = this.random.pickOne(init.levelPool);
|
|
63
|
-
} else {
|
|
64
|
-
user.level = this.random.pickOne(accessPool);
|
|
65
|
-
}
|
|
66
|
-
return user;
|
|
67
|
-
}
|
|
68
48
|
}
|
package/src/models/Backend.ts
CHANGED
|
@@ -72,7 +72,7 @@ export interface IBackendEvent extends IBackendMessage {
|
|
|
72
72
|
id?: string;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
export interface IListResponse {
|
|
75
|
+
export interface IListResponse<T = unknown> {
|
|
76
76
|
/**
|
|
77
77
|
* The cursor to use with the next query.
|
|
78
78
|
* Not set when no more results.
|
|
@@ -81,7 +81,7 @@ export interface IListResponse {
|
|
|
81
81
|
/**
|
|
82
82
|
* The list of objects returned from the store.
|
|
83
83
|
*/
|
|
84
|
-
data:
|
|
84
|
+
data: T[];
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
export interface IListOptions {
|
|
@@ -105,7 +105,16 @@ export interface IListOptions {
|
|
|
105
105
|
* Only with the `query` property. Tells the system in which fields to search for the query term.
|
|
106
106
|
*/
|
|
107
107
|
queryField?: string[];
|
|
108
|
+
/**
|
|
109
|
+
* General purpose type property to filer the results.
|
|
110
|
+
* This is used, for example, by the history store to list history for a specific type of requests,
|
|
111
|
+
*/
|
|
108
112
|
type?: string;
|
|
113
|
+
/**
|
|
114
|
+
* Whether the list should contain children of a parent.
|
|
115
|
+
* This is a key of the parent.
|
|
116
|
+
*/
|
|
117
|
+
parent?: string;
|
|
109
118
|
}
|
|
110
119
|
|
|
111
120
|
export interface ICursorOptions {
|
package/src/models/Workspace.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IFile, File, DefaultOwner } from "./store/File.js";
|
|
2
2
|
import { IThing, Thing, Kind as ThingKind } from './Thing.js';
|
|
3
3
|
import v4 from '../lib/uuid.js';
|
|
4
4
|
|
|
@@ -9,7 +9,7 @@ export const Kind = 'Core#Space';
|
|
|
9
9
|
* A working space is a logical container in the data store
|
|
10
10
|
* created by the system users, where they can store their projects and other data.
|
|
11
11
|
*/
|
|
12
|
-
export interface IWorkspace {
|
|
12
|
+
export interface IWorkspace extends IFile {
|
|
13
13
|
kind: typeof Kind;
|
|
14
14
|
/**
|
|
15
15
|
* The space identifier.
|
|
@@ -19,30 +19,9 @@ export interface IWorkspace {
|
|
|
19
19
|
* The environment's meta info.
|
|
20
20
|
*/
|
|
21
21
|
info: IThing;
|
|
22
|
-
/**
|
|
23
|
-
* The list of users added to this space. May not be set when owner did not add anyone to the space.
|
|
24
|
-
*/
|
|
25
|
-
users?: string[];
|
|
26
|
-
/**
|
|
27
|
-
* The owner of this space. The id of the User object.
|
|
28
|
-
* Set to `default` when there are no users in the system (no authentication).
|
|
29
|
-
*/
|
|
30
|
-
owner: string;
|
|
31
|
-
/**
|
|
32
|
-
* The list of project keys added to the workspace.
|
|
33
|
-
* @deprecated This is not actually used.
|
|
34
|
-
*/
|
|
35
|
-
projects: string[];
|
|
36
22
|
}
|
|
37
23
|
|
|
38
|
-
/**
|
|
39
|
-
* The workspace information set to a specific client what contains user specific data.
|
|
40
|
-
*/
|
|
41
|
-
export interface IUserWorkspace extends IWorkspace {
|
|
42
|
-
access: AccessControlLevel;
|
|
43
|
-
}
|
|
44
24
|
|
|
45
|
-
export const DefaultOwner = 'default';
|
|
46
25
|
|
|
47
26
|
/**
|
|
48
27
|
* A definition of the working space for users.
|
|
@@ -50,7 +29,7 @@ export const DefaultOwner = 'default';
|
|
|
50
29
|
* A working space is a logical container in the data store
|
|
51
30
|
* created by the system users, where they can store their projects and other data.
|
|
52
31
|
*/
|
|
53
|
-
export class Workspace {
|
|
32
|
+
export class Workspace extends File {
|
|
54
33
|
kind = Kind;
|
|
55
34
|
/**
|
|
56
35
|
* The space identifier.
|
|
@@ -60,27 +39,7 @@ export class Workspace {
|
|
|
60
39
|
* The name of the environment.
|
|
61
40
|
*/
|
|
62
41
|
info: Thing = new Thing({ kind: ThingKind });
|
|
63
|
-
|
|
64
|
-
* The list of users added to this space. May not be set when owner did not add anyone to the space.
|
|
65
|
-
*/
|
|
66
|
-
users?: string[];
|
|
67
|
-
/**
|
|
68
|
-
* The owner of this space. The id of the User object.
|
|
69
|
-
* Set to `default` when there are no users in the system (no authentication).
|
|
70
|
-
*/
|
|
71
|
-
owner = '';
|
|
72
|
-
/**
|
|
73
|
-
* The list of keys of projects added to the workspace.
|
|
74
|
-
* @deprecated This is not actually used.
|
|
75
|
-
*/
|
|
76
|
-
projects: string[] = [];
|
|
77
|
-
/**
|
|
78
|
-
* Only set when the object was created from the data received by the API Client backend.
|
|
79
|
-
* Level access of the current user to the space.
|
|
80
|
-
* Note, this information is never serialized with the object.
|
|
81
|
-
*/
|
|
82
|
-
access?: AccessControlLevel;
|
|
83
|
-
|
|
42
|
+
|
|
84
43
|
/**
|
|
85
44
|
* Creates a new Space object from a name.
|
|
86
45
|
*
|
|
@@ -95,7 +54,9 @@ export class Workspace {
|
|
|
95
54
|
kind: Kind,
|
|
96
55
|
info: info.toJSON(),
|
|
97
56
|
owner,
|
|
98
|
-
|
|
57
|
+
parents: [],
|
|
58
|
+
permissionIds: [],
|
|
59
|
+
permissions: [],
|
|
99
60
|
});
|
|
100
61
|
return definition;
|
|
101
62
|
}
|
|
@@ -103,7 +64,8 @@ export class Workspace {
|
|
|
103
64
|
/**
|
|
104
65
|
* @param input The environment definition used to restore the state.
|
|
105
66
|
*/
|
|
106
|
-
constructor(input?: string | IWorkspace
|
|
67
|
+
constructor(input?: string | IWorkspace) {
|
|
68
|
+
super();
|
|
107
69
|
let init: IWorkspace;
|
|
108
70
|
if (typeof input === 'string') {
|
|
109
71
|
init = JSON.parse(input);
|
|
@@ -118,7 +80,9 @@ export class Workspace {
|
|
|
118
80
|
name: '',
|
|
119
81
|
},
|
|
120
82
|
owner: DefaultOwner,
|
|
121
|
-
|
|
83
|
+
parents: [],
|
|
84
|
+
permissionIds: [],
|
|
85
|
+
permissions: [],
|
|
122
86
|
};
|
|
123
87
|
}
|
|
124
88
|
this.new(init);
|
|
@@ -129,29 +93,19 @@ export class Workspace {
|
|
|
129
93
|
*
|
|
130
94
|
* Note, this throws an error when the environment is not a space.
|
|
131
95
|
*/
|
|
132
|
-
new(init: IWorkspace
|
|
96
|
+
new(init: IWorkspace): void {
|
|
133
97
|
if (!Workspace.isWorkspace(init)) {
|
|
134
98
|
throw new Error(`Not a space.`);
|
|
135
99
|
}
|
|
136
|
-
|
|
100
|
+
super.new(init);
|
|
101
|
+
const { key = v4(), info } = init;
|
|
137
102
|
this.kind = Kind;
|
|
138
103
|
this.key = key;
|
|
139
|
-
this.projects = projects;
|
|
140
|
-
this.owner = owner;
|
|
141
104
|
if (info) {
|
|
142
105
|
this.info = new Thing(info);
|
|
143
106
|
} else {
|
|
144
107
|
this.info = new Thing({ kind: ThingKind, name: '' });
|
|
145
108
|
}
|
|
146
|
-
if (Array.isArray(users)) {
|
|
147
|
-
this.users = [...users];
|
|
148
|
-
} else {
|
|
149
|
-
this.users = [];
|
|
150
|
-
}
|
|
151
|
-
const typed = init as IUserWorkspace;
|
|
152
|
-
if (typed.access) {
|
|
153
|
-
this.access = typed.access;
|
|
154
|
-
}
|
|
155
109
|
}
|
|
156
110
|
|
|
157
111
|
/**
|
|
@@ -166,17 +120,12 @@ export class Workspace {
|
|
|
166
120
|
}
|
|
167
121
|
|
|
168
122
|
toJSON(): IWorkspace {
|
|
169
|
-
const { projects = [], owner = DefaultOwner, users } = this;
|
|
170
123
|
const result: IWorkspace = {
|
|
171
124
|
kind: Kind,
|
|
172
125
|
key: this.key,
|
|
173
126
|
info: this.info.toJSON(),
|
|
174
|
-
|
|
175
|
-
owner,
|
|
127
|
+
...super.toJSON(),
|
|
176
128
|
};
|
|
177
|
-
if (Array.isArray(users) && users.length) {
|
|
178
|
-
result.users = [...users];
|
|
179
|
-
}
|
|
180
129
|
return result;
|
|
181
130
|
}
|
|
182
131
|
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { IPermission } from './Permission.js';
|
|
2
|
+
|
|
3
|
+
export const DefaultOwner = 'default';
|
|
4
|
+
|
|
5
|
+
export interface IStoredFile {
|
|
6
|
+
/**
|
|
7
|
+
* The list of parents of the object. It is an ordered list of parents
|
|
8
|
+
* from the top (first element) to the lowest parent in the tree (last element).
|
|
9
|
+
*
|
|
10
|
+
* After creating the object, this property cannot be manipulated directly by the client.
|
|
11
|
+
* Should be treated as opaque value.
|
|
12
|
+
*/
|
|
13
|
+
parents: string[];
|
|
14
|
+
/**
|
|
15
|
+
* The list of permissions to this file object.
|
|
16
|
+
*
|
|
17
|
+
* This property cannot be manipulated directly by the client. Should be treated as
|
|
18
|
+
* opaque value.
|
|
19
|
+
*/
|
|
20
|
+
permissionIds: string[];
|
|
21
|
+
/**
|
|
22
|
+
* Whether the file object is deleted.
|
|
23
|
+
*/
|
|
24
|
+
deleted?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* The timestamp of when the file was deleted.
|
|
27
|
+
*/
|
|
28
|
+
deletedTime?: number;
|
|
29
|
+
/**
|
|
30
|
+
* The id of the user that has deleted the file.
|
|
31
|
+
*/
|
|
32
|
+
deletingUser?: string;
|
|
33
|
+
/**
|
|
34
|
+
* The owner of this object. The id of the User object.
|
|
35
|
+
*/
|
|
36
|
+
owner: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* An interface describing an object in the data store that
|
|
41
|
+
* describes a file or an object that can be treated as a file or a folder.
|
|
42
|
+
*/
|
|
43
|
+
export interface IFile extends IStoredFile {
|
|
44
|
+
/**
|
|
45
|
+
* Populated by the server when reading the file. The list of permissions to the object.
|
|
46
|
+
*
|
|
47
|
+
* This property cannot be manipulated directly by the client. Should be treated as
|
|
48
|
+
* opaque value.
|
|
49
|
+
*
|
|
50
|
+
* Data store implementation note, this is not stored in the store but it is populated
|
|
51
|
+
* when reading the object.
|
|
52
|
+
*/
|
|
53
|
+
permissions: IPermission[];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export class StoredFile {
|
|
57
|
+
/**
|
|
58
|
+
* The list of parents of the object. It is an ordered list of parents
|
|
59
|
+
* from the top (first element) to the lowest parent in the tree (last element).
|
|
60
|
+
*
|
|
61
|
+
* This property cannot be manipulated directly by the client. Should be treated as
|
|
62
|
+
* opaque value.
|
|
63
|
+
*/
|
|
64
|
+
parents: string[] = [];
|
|
65
|
+
/**
|
|
66
|
+
* The list of permissions to this file object.
|
|
67
|
+
*
|
|
68
|
+
* This property cannot be manipulated directly by the client. Should be treated as
|
|
69
|
+
* opaque value.
|
|
70
|
+
*/
|
|
71
|
+
permissionIds: string[] = [];
|
|
72
|
+
/**
|
|
73
|
+
* Whether the file object is deleted.
|
|
74
|
+
*/
|
|
75
|
+
deleted?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* The timestamp of when the file was deleted.
|
|
78
|
+
*/
|
|
79
|
+
deletedTime?: number;
|
|
80
|
+
/**
|
|
81
|
+
* The id of the user that has deleted the file.
|
|
82
|
+
*/
|
|
83
|
+
deletingUser?: string;
|
|
84
|
+
/**
|
|
85
|
+
* The owner of this space. The id of the User object.
|
|
86
|
+
* Set to `default` when there are no users in the system (no authentication).
|
|
87
|
+
*/
|
|
88
|
+
owner = '';
|
|
89
|
+
|
|
90
|
+
new(init: IStoredFile): void {
|
|
91
|
+
const { parents=[], permissionIds=[], deleted, deletedTime, deletingUser, owner = DefaultOwner } = init;
|
|
92
|
+
this.parents = parents;
|
|
93
|
+
this.permissionIds = permissionIds;
|
|
94
|
+
this.owner = owner;
|
|
95
|
+
if (typeof deleted === 'boolean') {
|
|
96
|
+
this.deleted = deleted;
|
|
97
|
+
this.deletedTime = deletedTime;
|
|
98
|
+
this.deletingUser = deletingUser;
|
|
99
|
+
} else {
|
|
100
|
+
this.deleted = undefined;
|
|
101
|
+
this.deletedTime = undefined;
|
|
102
|
+
this.deletingUser = undefined;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
toJSON(): IStoredFile {
|
|
107
|
+
const { owner = DefaultOwner } = this;
|
|
108
|
+
const result: IStoredFile = {
|
|
109
|
+
parents: this.parents,
|
|
110
|
+
permissionIds: this.permissionIds,
|
|
111
|
+
owner,
|
|
112
|
+
};
|
|
113
|
+
if (typeof this.deleted === 'boolean') {
|
|
114
|
+
result.deleted = this.deleted;
|
|
115
|
+
|
|
116
|
+
if (this.deletedTime) {
|
|
117
|
+
result.deletedTime = this.deletedTime;
|
|
118
|
+
}
|
|
119
|
+
if (this.deletingUser) {
|
|
120
|
+
result.deletingUser = this.deletingUser;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return result;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export class File extends StoredFile {
|
|
128
|
+
/**
|
|
129
|
+
* Populated by the server when reading the file. The list of permissions to the object.
|
|
130
|
+
*
|
|
131
|
+
* This property cannot be manipulated directly by the client. Should be treated as
|
|
132
|
+
* opaque value.
|
|
133
|
+
*/
|
|
134
|
+
permissions: IPermission[] = [];
|
|
135
|
+
|
|
136
|
+
new(init: IFile): void {
|
|
137
|
+
super.new(init);
|
|
138
|
+
const { permissions=[] } = init;
|
|
139
|
+
this.permissions = permissions;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
toJSON(): IFile {
|
|
143
|
+
const result: IFile = {
|
|
144
|
+
...super.toJSON(),
|
|
145
|
+
permissions: this.permissions,
|
|
146
|
+
};
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
149
|
+
}
|