@api-client/core 0.5.2 → 0.5.5
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 +2 -1
- package/build/browser.js +2 -1
- package/build/browser.js.map +1 -1
- package/build/index.d.ts +2 -1
- package/build/index.js +2 -1
- package/build/index.js.map +1 -1
- package/build/src/models/Backend.d.ts +7 -9
- package/build/src/models/HttpHistory.d.ts +2 -2
- package/build/src/models/Project.d.ts +41 -0
- package/build/src/models/Project.js +94 -0
- package/build/src/models/Project.js.map +1 -0
- package/build/src/models/RevisionInfo.d.ts +5 -0
- package/build/src/models/RevisionInfo.js.map +1 -1
- package/build/src/models/SerializableError.d.ts +1 -0
- package/build/src/models/SerializableError.js.map +1 -1
- package/build/src/models/Thing.js +1 -1
- package/build/src/models/Thing.js.map +1 -1
- package/build/src/models/Workspace.d.ts +0 -17
- package/build/src/models/Workspace.js +3 -19
- package/build/src/models/Workspace.js.map +1 -1
- package/build/src/models/store/Deletion.d.ts +24 -0
- package/build/src/models/store/Deletion.js +2 -0
- package/build/src/models/store/Deletion.js.map +1 -0
- package/build/src/models/store/File.d.ts +75 -12
- package/build/src/models/store/File.js +120 -19
- package/build/src/models/store/File.js.map +1 -1
- package/build/src/models/store/Modification.d.ts +24 -0
- package/build/src/models/store/Modification.js +2 -0
- package/build/src/models/store/Modification.js.map +1 -0
- package/build/src/runtime/store/Errors.d.ts +50 -0
- package/build/src/runtime/store/Errors.js +63 -0
- package/build/src/runtime/store/Errors.js.map +1 -0
- package/build/src/runtime/store/FilesSdk.d.ts +94 -0
- package/build/src/runtime/store/FilesSdk.js +247 -0
- package/build/src/runtime/store/FilesSdk.js.map +1 -0
- package/build/src/runtime/store/HistorySdk.d.ts +14 -7
- package/build/src/runtime/store/HistorySdk.js +34 -12
- package/build/src/runtime/store/HistorySdk.js.map +1 -1
- package/build/src/runtime/store/RouteBuilder.d.ts +9 -17
- package/build/src/runtime/store/RouteBuilder.js +14 -26
- package/build/src/runtime/store/RouteBuilder.js.map +1 -1
- package/build/src/runtime/store/Sdk.d.ts +6 -7
- package/build/src/runtime/store/Sdk.js +6 -7
- package/build/src/runtime/store/Sdk.js.map +1 -1
- package/build/src/runtime/store/SdkBase.d.ts +16 -6
- package/build/src/runtime/store/SdkBase.js +54 -4
- package/build/src/runtime/store/SdkBase.js.map +1 -1
- package/build/src/runtime/store/SharedSdk.d.ts +8 -2
- package/build/src/runtime/store/SharedSdk.js +22 -8
- package/build/src/runtime/store/SharedSdk.js.map +1 -1
- package/build/src/runtime/store/StoreSdkNode.d.ts +1 -1
- package/build/src/runtime/store/StoreSdkWeb.d.ts +1 -1
- package/build/src/runtime/store/UsersSdk.d.ts +10 -4
- package/build/src/runtime/store/UsersSdk.js +12 -6
- package/build/src/runtime/store/UsersSdk.js.map +1 -1
- package/package.json +2 -2
- package/src/models/Backend.ts +7 -9
- package/src/models/HttpHistory.ts +2 -2
- package/src/models/Project.ts +110 -0
- package/src/models/RevisionInfo.ts +6 -0
- package/src/models/SerializableError.ts +1 -0
- package/src/models/Thing.ts +1 -1
- package/src/models/Workspace.ts +4 -29
- package/src/models/store/Deletion.ts +24 -0
- package/src/models/store/File.ts +146 -26
- package/src/models/store/Modification.ts +24 -0
- package/src/runtime/store/Errors.ts +100 -0
- package/src/runtime/store/FilesSdk.ts +302 -0
- package/src/runtime/store/HistorySdk.ts +42 -17
- package/src/runtime/store/RouteBuilder.ts +14 -28
- package/src/runtime/store/Sdk.ts +7 -7
- package/src/runtime/store/SdkBase.ts +63 -9
- package/src/runtime/store/SharedSdk.ts +27 -10
- package/src/runtime/store/StoreSdkNode.ts +1 -1
- package/src/runtime/store/StoreSdkWeb.ts +1 -1
- package/src/runtime/store/UsersSdk.ts +14 -8
- package/build/src/models/HttpProjectListItem.d.ts +0 -23
- package/build/src/models/HttpProjectListItem.js +0 -2
- package/build/src/models/HttpProjectListItem.js.map +0 -1
- package/build/src/runtime/store/ProjectsSdk.d.ts +0 -43
- package/build/src/runtime/store/ProjectsSdk.js +0 -144
- package/build/src/runtime/store/ProjectsSdk.js.map +0 -1
- package/build/src/runtime/store/SpacesSdk.d.ts +0 -62
- package/build/src/runtime/store/SpacesSdk.js +0 -194
- package/build/src/runtime/store/SpacesSdk.js.map +0 -1
- package/src/models/HttpProjectListItem.ts +0 -23
- package/src/runtime/store/ProjectsSdk.ts +0 -147
- package/src/runtime/store/SpacesSdk.ts +0 -209
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { SdkBase, E_RESPONSE_STATUS, E_RESPONSE_NO_VALUE, E_INVALID_JSON, E_RESPONSE_UNKNOWN, E_RESPONSE_LOCATION } from './SdkBase.js';
|
|
2
|
-
import { RouteBuilder } from './RouteBuilder.js';
|
|
3
|
-
import { Kind as HttpProjectKind } from '../../models/HttpProject.js';
|
|
4
|
-
export class ProjectsSdk extends SdkBase {
|
|
5
|
-
/**
|
|
6
|
-
* Creates a project in a user space.
|
|
7
|
-
*
|
|
8
|
-
* @param space The user space key
|
|
9
|
-
* @param project THe project to create
|
|
10
|
-
* @returns The key of the created project.
|
|
11
|
-
*/
|
|
12
|
-
async create(space, project) {
|
|
13
|
-
const { token } = this.sdk;
|
|
14
|
-
const url = this.sdk.getUrl(RouteBuilder.spaceProjects(space));
|
|
15
|
-
const body = JSON.stringify(project);
|
|
16
|
-
const result = await this.sdk.http.post(url.toString(), { token, body });
|
|
17
|
-
this.inspectCommonStatusCodes(result.status);
|
|
18
|
-
const E_PREFIX = 'Unable to create a project. ';
|
|
19
|
-
if (result.status !== 204) {
|
|
20
|
-
this.logInvalidResponse(result);
|
|
21
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
|
|
22
|
-
}
|
|
23
|
-
const location = result.headers.get('location');
|
|
24
|
-
if (!location) {
|
|
25
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_LOCATION}`);
|
|
26
|
-
}
|
|
27
|
-
const id = location.split('/').pop();
|
|
28
|
-
return id;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Reads a project definition from the store.
|
|
32
|
-
* @param space The user space key
|
|
33
|
-
* @param project The project key
|
|
34
|
-
* @returns The definition of the project.
|
|
35
|
-
*/
|
|
36
|
-
async read(space, project) {
|
|
37
|
-
const { token } = this.sdk;
|
|
38
|
-
const url = this.sdk.getUrl(RouteBuilder.spaceProject(space, project));
|
|
39
|
-
const result = await this.sdk.http.get(url.toString(), { token });
|
|
40
|
-
this.inspectCommonStatusCodes(result.status);
|
|
41
|
-
const E_PREFIX = 'Unable to read a project. ';
|
|
42
|
-
if (result.status !== 200) {
|
|
43
|
-
this.logInvalidResponse(result);
|
|
44
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
|
|
45
|
-
}
|
|
46
|
-
if (!result.body) {
|
|
47
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
48
|
-
}
|
|
49
|
-
let data;
|
|
50
|
-
try {
|
|
51
|
-
data = JSON.parse(result.body);
|
|
52
|
-
}
|
|
53
|
-
catch (e) {
|
|
54
|
-
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
55
|
-
}
|
|
56
|
-
if (data.kind !== HttpProjectKind) {
|
|
57
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
|
|
58
|
-
}
|
|
59
|
-
return data;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Lists projects in the space
|
|
63
|
-
*
|
|
64
|
-
* @param space The user space key
|
|
65
|
-
* @param options Optional query options.
|
|
66
|
-
*/
|
|
67
|
-
async list(space, options) {
|
|
68
|
-
const { token } = this.sdk;
|
|
69
|
-
const url = this.sdk.getUrl(RouteBuilder.spaceProjects(space));
|
|
70
|
-
this.sdk.appendListOptions(url, options);
|
|
71
|
-
const result = await this.sdk.http.get(url.toString(), { token });
|
|
72
|
-
this.inspectCommonStatusCodes(result.status);
|
|
73
|
-
const E_PREFIX = 'Unable to list projects. ';
|
|
74
|
-
if (result.status !== 200) {
|
|
75
|
-
this.logInvalidResponse(result);
|
|
76
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
|
|
77
|
-
}
|
|
78
|
-
if (!result.body) {
|
|
79
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
80
|
-
}
|
|
81
|
-
let data;
|
|
82
|
-
try {
|
|
83
|
-
data = JSON.parse(result.body);
|
|
84
|
-
}
|
|
85
|
-
catch (e) {
|
|
86
|
-
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
87
|
-
}
|
|
88
|
-
if (!Array.isArray(data.data)) {
|
|
89
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
|
|
90
|
-
}
|
|
91
|
-
return data;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Deletes a project form the store.
|
|
95
|
-
*
|
|
96
|
-
* @param space The key of the parent space.
|
|
97
|
-
* @param project The key of the project to delete.
|
|
98
|
-
*/
|
|
99
|
-
async delete(space, project) {
|
|
100
|
-
const { token } = this.sdk;
|
|
101
|
-
const url = this.sdk.getUrl(RouteBuilder.spaceProject(space, project));
|
|
102
|
-
const result = await this.sdk.http.delete(url.toString(), { token });
|
|
103
|
-
this.inspectCommonStatusCodes(result.status);
|
|
104
|
-
const E_PREFIX = 'Unable to delete a project. ';
|
|
105
|
-
if (result.status !== 204) {
|
|
106
|
-
this.logInvalidResponse(result);
|
|
107
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Patches a project in the store.
|
|
112
|
-
* @param space The key of the parent user space
|
|
113
|
-
* @param project The key of project to patch.
|
|
114
|
-
* @param value The JSON patch to be processed.
|
|
115
|
-
* @returns The JSON patch to revert the change using the `json8-patch` library
|
|
116
|
-
*/
|
|
117
|
-
async patch(space, project, value) {
|
|
118
|
-
const { token } = this.sdk;
|
|
119
|
-
const url = this.sdk.getUrl(RouteBuilder.spaceProject(space, project));
|
|
120
|
-
const body = JSON.stringify(value);
|
|
121
|
-
const result = await this.sdk.http.patch(url.toString(), { token, body });
|
|
122
|
-
this.inspectCommonStatusCodes(result.status);
|
|
123
|
-
const E_PREFIX = 'Unable to patch a project. ';
|
|
124
|
-
if (result.status !== 200) {
|
|
125
|
-
this.logInvalidResponse(result);
|
|
126
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
|
|
127
|
-
}
|
|
128
|
-
if (!result.body) {
|
|
129
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
130
|
-
}
|
|
131
|
-
let data;
|
|
132
|
-
try {
|
|
133
|
-
data = JSON.parse(result.body);
|
|
134
|
-
}
|
|
135
|
-
catch (e) {
|
|
136
|
-
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
137
|
-
}
|
|
138
|
-
if (!data.revert) {
|
|
139
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
|
|
140
|
-
}
|
|
141
|
-
return data.revert;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
//# sourceMappingURL=ProjectsSdk.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProjectsSdk.js","sourceRoot":"","sources":["../../../../src/runtime/store/ProjectsSdk.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,EAA6B,IAAI,IAAI,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEjG,MAAM,OAAO,WAAY,SAAQ,OAAO;IACtC;;;;;;OAMG;IACH,KAAK,CAAC,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AAC,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,IAAS,CAAC;QACd,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,IAAI,CAAC,MAAM,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,GAAG,QAAQ,GAAG,kBAAkB,GAAG,CAAC,CAAC;SACtD;QACD,OAAO,IAAI,CAAC,MAAmB,CAAC;IAClC,CAAC;CACF"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { JsonPatch } from 'json8-patch';
|
|
2
|
-
import { SdkBase } from './SdkBase.js';
|
|
3
|
-
import { IListOptions, IListResponse } from '../../models/Backend.js';
|
|
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
|
-
}
|
|
14
|
-
export declare class SpacesSdk extends SdkBase {
|
|
15
|
-
/**
|
|
16
|
-
* Lists spaces in the store.
|
|
17
|
-
* @param options Optional query options.
|
|
18
|
-
*/
|
|
19
|
-
list(options?: IListOptions): Promise<IListResponse>;
|
|
20
|
-
/**
|
|
21
|
-
* Creates a workspace in the store.
|
|
22
|
-
* @param space The workspace definition.
|
|
23
|
-
* @returns The key of the creates space.
|
|
24
|
-
*/
|
|
25
|
-
create(space: IWorkspace | Workspace, opts?: ISpaceCreateOptions): Promise<string>;
|
|
26
|
-
/**
|
|
27
|
-
* Reads a user space definition from the store.
|
|
28
|
-
* @param key The user space key
|
|
29
|
-
* @returns The definition of the user space.
|
|
30
|
-
*/
|
|
31
|
-
read(key: string): Promise<IWorkspace>;
|
|
32
|
-
/**
|
|
33
|
-
* Patches a user space in the store.
|
|
34
|
-
* @param key The key of the user space to patch
|
|
35
|
-
* @param value The JSON patch to be processed.
|
|
36
|
-
* @returns The JSON patch to revert the change using the `json8-patch` library
|
|
37
|
-
*/
|
|
38
|
-
patch(key: string, value: JsonPatch): Promise<JsonPatch>;
|
|
39
|
-
/**
|
|
40
|
-
* Deletes the space in the store.
|
|
41
|
-
*
|
|
42
|
-
* @param key The key of the space to delete.
|
|
43
|
-
*/
|
|
44
|
-
delete(key: string): Promise<void>;
|
|
45
|
-
/**
|
|
46
|
-
* Updates the sharing options of the space.
|
|
47
|
-
*
|
|
48
|
-
* @param key The user space key
|
|
49
|
-
* @param value The patch operation on the space's ACL
|
|
50
|
-
*/
|
|
51
|
-
patchUsers(key: string, value: AccessOperation[]): Promise<void>;
|
|
52
|
-
/**
|
|
53
|
-
* Lists uses having access to the user space.
|
|
54
|
-
*
|
|
55
|
-
* @param key The user space key
|
|
56
|
-
*/
|
|
57
|
-
listUsers(key: string): Promise<IListResponse>;
|
|
58
|
-
/**
|
|
59
|
-
* Creates a WS client that listens to the spaces events.
|
|
60
|
-
*/
|
|
61
|
-
observeSpaces(): Promise<WebSocketNode | WebSocket>;
|
|
62
|
-
}
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import { SdkBase, E_RESPONSE_STATUS, E_RESPONSE_NO_VALUE, E_INVALID_JSON, E_RESPONSE_UNKNOWN, E_RESPONSE_LOCATION } from './SdkBase.js';
|
|
2
|
-
import { RouteBuilder } from './RouteBuilder.js';
|
|
3
|
-
import { Kind as WorkspaceKind } from '../../models/Workspace.js';
|
|
4
|
-
export class SpacesSdk extends SdkBase {
|
|
5
|
-
/**
|
|
6
|
-
* Lists spaces in the store.
|
|
7
|
-
* @param options Optional query options.
|
|
8
|
-
*/
|
|
9
|
-
async list(options) {
|
|
10
|
-
const { token } = this.sdk;
|
|
11
|
-
const url = this.sdk.getUrl(RouteBuilder.spaces());
|
|
12
|
-
this.sdk.appendListOptions(url, options);
|
|
13
|
-
const result = await this.sdk.http.get(url.toString(), { token });
|
|
14
|
-
this.inspectCommonStatusCodes(result.status);
|
|
15
|
-
const E_PREFIX = 'Unable to list spaces. ';
|
|
16
|
-
if (result.status !== 200) {
|
|
17
|
-
this.logInvalidResponse(result);
|
|
18
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
|
|
19
|
-
}
|
|
20
|
-
if (!result.body) {
|
|
21
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
22
|
-
}
|
|
23
|
-
let data;
|
|
24
|
-
try {
|
|
25
|
-
data = JSON.parse(result.body);
|
|
26
|
-
}
|
|
27
|
-
catch (e) {
|
|
28
|
-
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
29
|
-
}
|
|
30
|
-
if (!Array.isArray(data.data)) {
|
|
31
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
|
|
32
|
-
}
|
|
33
|
-
return data;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Creates a workspace in the store.
|
|
37
|
-
* @param space The workspace definition.
|
|
38
|
-
* @returns The key of the creates space.
|
|
39
|
-
*/
|
|
40
|
-
async create(space, opts = {}) {
|
|
41
|
-
const { token } = this.sdk;
|
|
42
|
-
const path = opts.parent ? RouteBuilder.space(opts.parent) : RouteBuilder.spaces();
|
|
43
|
-
const url = this.sdk.getUrl(path);
|
|
44
|
-
const body = JSON.stringify(space);
|
|
45
|
-
const result = await this.sdk.http.post(url.toString(), { token, body });
|
|
46
|
-
this.inspectCommonStatusCodes(result.status);
|
|
47
|
-
const E_PREFIX = 'Unable to create a user space. ';
|
|
48
|
-
if (result.status !== 204) {
|
|
49
|
-
this.logInvalidResponse(result);
|
|
50
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
|
|
51
|
-
}
|
|
52
|
-
const location = result.headers.get('location');
|
|
53
|
-
if (!location) {
|
|
54
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_LOCATION}`);
|
|
55
|
-
}
|
|
56
|
-
const id = location.split('/').pop();
|
|
57
|
-
return id;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Reads a user space definition from the store.
|
|
61
|
-
* @param key The user space key
|
|
62
|
-
* @returns The definition of the user space.
|
|
63
|
-
*/
|
|
64
|
-
async read(key) {
|
|
65
|
-
const { token } = this.sdk;
|
|
66
|
-
const url = this.sdk.getUrl(RouteBuilder.space(key));
|
|
67
|
-
const result = await this.sdk.http.get(url.toString(), { token });
|
|
68
|
-
this.inspectCommonStatusCodes(result.status);
|
|
69
|
-
const E_PREFIX = 'Unable to read a user space. ';
|
|
70
|
-
if (result.status !== 200) {
|
|
71
|
-
this.logInvalidResponse(result);
|
|
72
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
|
|
73
|
-
}
|
|
74
|
-
if (!result.body) {
|
|
75
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
76
|
-
}
|
|
77
|
-
let data;
|
|
78
|
-
try {
|
|
79
|
-
data = JSON.parse(result.body);
|
|
80
|
-
}
|
|
81
|
-
catch (e) {
|
|
82
|
-
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
83
|
-
}
|
|
84
|
-
if (data.kind !== WorkspaceKind) {
|
|
85
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
|
|
86
|
-
}
|
|
87
|
-
return data;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Patches a user space in the store.
|
|
91
|
-
* @param key The key of the user space to patch
|
|
92
|
-
* @param value The JSON patch to be processed.
|
|
93
|
-
* @returns The JSON patch to revert the change using the `json8-patch` library
|
|
94
|
-
*/
|
|
95
|
-
async patch(key, value) {
|
|
96
|
-
const { token } = this.sdk;
|
|
97
|
-
const url = this.sdk.getUrl(RouteBuilder.space(key));
|
|
98
|
-
const body = JSON.stringify(value);
|
|
99
|
-
const result = await this.sdk.http.patch(url.toString(), { token, body });
|
|
100
|
-
this.inspectCommonStatusCodes(result.status);
|
|
101
|
-
const E_PREFIX = 'Unable to patch a user space. ';
|
|
102
|
-
if (result.status !== 200) {
|
|
103
|
-
this.logInvalidResponse(result);
|
|
104
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
|
|
105
|
-
}
|
|
106
|
-
if (!result.body) {
|
|
107
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
108
|
-
}
|
|
109
|
-
let data;
|
|
110
|
-
try {
|
|
111
|
-
data = JSON.parse(result.body);
|
|
112
|
-
}
|
|
113
|
-
catch (e) {
|
|
114
|
-
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
115
|
-
}
|
|
116
|
-
if (!data.revert) {
|
|
117
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
|
|
118
|
-
}
|
|
119
|
-
return data.revert;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Deletes the space in the store.
|
|
123
|
-
*
|
|
124
|
-
* @param key The key of the space to delete.
|
|
125
|
-
*/
|
|
126
|
-
async delete(key) {
|
|
127
|
-
const { token } = this.sdk;
|
|
128
|
-
const url = this.sdk.getUrl(RouteBuilder.space(key));
|
|
129
|
-
const result = await this.sdk.http.delete(url.toString(), { token });
|
|
130
|
-
this.inspectCommonStatusCodes(result.status);
|
|
131
|
-
const E_PREFIX = 'Unable to delete a user space. ';
|
|
132
|
-
if (result.status !== 204) {
|
|
133
|
-
this.logInvalidResponse(result);
|
|
134
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Updates the sharing options of the space.
|
|
139
|
-
*
|
|
140
|
-
* @param key The user space key
|
|
141
|
-
* @param value The patch operation on the space's ACL
|
|
142
|
-
*/
|
|
143
|
-
async patchUsers(key, value) {
|
|
144
|
-
const { token } = this.sdk;
|
|
145
|
-
const url = this.sdk.getUrl(RouteBuilder.spaceUsers(key));
|
|
146
|
-
const body = JSON.stringify(value);
|
|
147
|
-
const result = await this.sdk.http.patch(url.toString(), { token, body });
|
|
148
|
-
this.inspectCommonStatusCodes(result.status);
|
|
149
|
-
const E_PREFIX = 'Unable to patch a user space. ';
|
|
150
|
-
if (result.status !== 204) {
|
|
151
|
-
this.logInvalidResponse(result);
|
|
152
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Lists uses having access to the user space.
|
|
157
|
-
*
|
|
158
|
-
* @param key The user space key
|
|
159
|
-
*/
|
|
160
|
-
async listUsers(key) {
|
|
161
|
-
const { token } = this.sdk;
|
|
162
|
-
const url = this.sdk.getUrl(RouteBuilder.spaceUsers(key));
|
|
163
|
-
const result = await this.sdk.http.get(url.toString(), { token });
|
|
164
|
-
this.inspectCommonStatusCodes(result.status);
|
|
165
|
-
const E_PREFIX = 'Unable to list users in the space. ';
|
|
166
|
-
if (result.status !== 200) {
|
|
167
|
-
this.logInvalidResponse(result);
|
|
168
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
|
|
169
|
-
}
|
|
170
|
-
if (!result.body) {
|
|
171
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
172
|
-
}
|
|
173
|
-
let data;
|
|
174
|
-
try {
|
|
175
|
-
data = JSON.parse(result.body);
|
|
176
|
-
}
|
|
177
|
-
catch (e) {
|
|
178
|
-
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
179
|
-
}
|
|
180
|
-
if (!Array.isArray(data.data)) {
|
|
181
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
|
|
182
|
-
}
|
|
183
|
-
return data;
|
|
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
|
-
}
|
|
193
|
-
}
|
|
194
|
-
//# sourceMappingURL=SpacesSdk.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,CAAC,CAAC;QACzC,MAAM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M,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,23 +0,0 @@
|
|
|
1
|
-
export const Kind = 'Core#HttpProjectListItem';
|
|
2
|
-
/**
|
|
3
|
-
* The HTTP Project definition to be used in lists.
|
|
4
|
-
*/
|
|
5
|
-
export interface IHttpProjectListItem {
|
|
6
|
-
/**
|
|
7
|
-
* The data store key of the project.
|
|
8
|
-
*/
|
|
9
|
-
key: string;
|
|
10
|
-
/**
|
|
11
|
-
* Project's name
|
|
12
|
-
*/
|
|
13
|
-
name: string;
|
|
14
|
-
/**
|
|
15
|
-
* Whether the project is one of the favourites.
|
|
16
|
-
* May be used by an UI to add projects to favourites.
|
|
17
|
-
*/
|
|
18
|
-
favourite?: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* The timestamp when the project was last updated.
|
|
21
|
-
*/
|
|
22
|
-
updated: number;
|
|
23
|
-
}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { JsonPatch } from 'json8-patch';
|
|
2
|
-
import { SdkBase, E_RESPONSE_STATUS, E_RESPONSE_NO_VALUE, E_INVALID_JSON, E_RESPONSE_UNKNOWN, E_RESPONSE_LOCATION } from './SdkBase.js';
|
|
3
|
-
import { RouteBuilder } from './RouteBuilder.js';
|
|
4
|
-
import { IListOptions, IListResponse } from '../../models/Backend.js';
|
|
5
|
-
import { HttpProject, IHttpProject, Kind as HttpProjectKind } from '../../models/HttpProject.js';
|
|
6
|
-
|
|
7
|
-
export class ProjectsSdk extends SdkBase {
|
|
8
|
-
/**
|
|
9
|
-
* Creates a project in a user space.
|
|
10
|
-
*
|
|
11
|
-
* @param space The user space key
|
|
12
|
-
* @param project THe project to create
|
|
13
|
-
* @returns The key of the created project.
|
|
14
|
-
*/
|
|
15
|
-
async create(space: string, project: IHttpProject | HttpProject): Promise<string> {
|
|
16
|
-
const { token } = this.sdk;
|
|
17
|
-
const url = this.sdk.getUrl(RouteBuilder.spaceProjects(space));
|
|
18
|
-
const body = JSON.stringify(project);
|
|
19
|
-
const result = await this.sdk.http.post(url.toString(), { token, body });
|
|
20
|
-
this.inspectCommonStatusCodes(result.status);
|
|
21
|
-
const E_PREFIX = 'Unable to create a project. ';
|
|
22
|
-
if (result.status !== 204) {
|
|
23
|
-
this.logInvalidResponse(result);
|
|
24
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
|
|
25
|
-
}
|
|
26
|
-
const location = result.headers.get('location');
|
|
27
|
-
if (!location) {
|
|
28
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_LOCATION}`);
|
|
29
|
-
}
|
|
30
|
-
const id = location.split('/').pop();
|
|
31
|
-
return id as string;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Reads a project definition from the store.
|
|
36
|
-
* @param space The user space key
|
|
37
|
-
* @param project The project key
|
|
38
|
-
* @returns The definition of the project.
|
|
39
|
-
*/
|
|
40
|
-
async read(space: string, project: string): Promise<IHttpProject> {
|
|
41
|
-
const { token } = this.sdk;
|
|
42
|
-
const url = this.sdk.getUrl(RouteBuilder.spaceProject(space, project));
|
|
43
|
-
const result = await this.sdk.http.get(url.toString(), { token });
|
|
44
|
-
this.inspectCommonStatusCodes(result.status);
|
|
45
|
-
const E_PREFIX = 'Unable to read a project. ';
|
|
46
|
-
if (result.status !== 200) {
|
|
47
|
-
this.logInvalidResponse(result);
|
|
48
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
|
|
49
|
-
}
|
|
50
|
-
if (!result.body) {
|
|
51
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
52
|
-
}
|
|
53
|
-
let data: IHttpProject;
|
|
54
|
-
try {
|
|
55
|
-
data = JSON.parse(result.body);
|
|
56
|
-
} catch (e) {
|
|
57
|
-
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
58
|
-
}
|
|
59
|
-
if (data.kind !== HttpProjectKind) {
|
|
60
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
|
|
61
|
-
}
|
|
62
|
-
return data;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Lists projects in the space
|
|
67
|
-
*
|
|
68
|
-
* @param space The user space key
|
|
69
|
-
* @param options Optional query options.
|
|
70
|
-
*/
|
|
71
|
-
async list(space: string, options?: IListOptions): Promise<IListResponse> {
|
|
72
|
-
const { token } = this.sdk;
|
|
73
|
-
const url = this.sdk.getUrl(RouteBuilder.spaceProjects(space));
|
|
74
|
-
this.sdk.appendListOptions(url, options);
|
|
75
|
-
const result = await this.sdk.http.get(url.toString(), { token });
|
|
76
|
-
this.inspectCommonStatusCodes(result.status);
|
|
77
|
-
const E_PREFIX = 'Unable to list projects. ';
|
|
78
|
-
if (result.status !== 200) {
|
|
79
|
-
this.logInvalidResponse(result);
|
|
80
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
|
|
81
|
-
}
|
|
82
|
-
if (!result.body) {
|
|
83
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
84
|
-
}
|
|
85
|
-
let data: IListResponse;
|
|
86
|
-
try {
|
|
87
|
-
data = JSON.parse(result.body);
|
|
88
|
-
} catch (e) {
|
|
89
|
-
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
90
|
-
}
|
|
91
|
-
if (!Array.isArray(data.data)) {
|
|
92
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
|
|
93
|
-
}
|
|
94
|
-
return data;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Deletes a project form the store.
|
|
99
|
-
*
|
|
100
|
-
* @param space The key of the parent space.
|
|
101
|
-
* @param project The key of the project to delete.
|
|
102
|
-
*/
|
|
103
|
-
async delete(space: string, project: string): Promise<void> {
|
|
104
|
-
const { token } = this.sdk;
|
|
105
|
-
const url = this.sdk.getUrl(RouteBuilder.spaceProject(space, project));
|
|
106
|
-
const result = await this.sdk.http.delete(url.toString(), { token });
|
|
107
|
-
this.inspectCommonStatusCodes(result.status);
|
|
108
|
-
const E_PREFIX = 'Unable to delete a project. ';
|
|
109
|
-
if (result.status !== 204) {
|
|
110
|
-
this.logInvalidResponse(result);
|
|
111
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Patches a project in the store.
|
|
117
|
-
* @param space The key of the parent user space
|
|
118
|
-
* @param project The key of project to patch.
|
|
119
|
-
* @param value The JSON patch to be processed.
|
|
120
|
-
* @returns The JSON patch to revert the change using the `json8-patch` library
|
|
121
|
-
*/
|
|
122
|
-
async patch(space: string, project: string, value: JsonPatch): Promise<JsonPatch> {
|
|
123
|
-
const { token } = this.sdk;
|
|
124
|
-
const url = this.sdk.getUrl(RouteBuilder.spaceProject(space, project));
|
|
125
|
-
const body = JSON.stringify(value);
|
|
126
|
-
const result = await this.sdk.http.patch(url.toString(), { token, body });
|
|
127
|
-
this.inspectCommonStatusCodes(result.status);
|
|
128
|
-
const E_PREFIX = 'Unable to patch a project. ';
|
|
129
|
-
if (result.status !== 200) {
|
|
130
|
-
this.logInvalidResponse(result);
|
|
131
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
|
|
132
|
-
}
|
|
133
|
-
if (!result.body) {
|
|
134
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
135
|
-
}
|
|
136
|
-
let data: any;
|
|
137
|
-
try {
|
|
138
|
-
data = JSON.parse(result.body);
|
|
139
|
-
} catch (e) {
|
|
140
|
-
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
141
|
-
}
|
|
142
|
-
if (!data.revert) {
|
|
143
|
-
throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
|
|
144
|
-
}
|
|
145
|
-
return data.revert as JsonPatch;
|
|
146
|
-
}
|
|
147
|
-
}
|