@api-client/core 0.8.21 → 0.9.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 +12 -5
- package/build/browser.js +2 -3
- package/build/browser.js.map +1 -1
- package/build/index.d.ts +12 -5
- package/build/index.js +2 -4
- package/build/index.js.map +1 -1
- package/build/src/events/BaseEvents.d.ts +125 -18
- package/build/src/events/BaseEvents.js.map +1 -1
- package/build/src/events/EventTypes.d.ts +0 -14
- package/build/src/events/EventTypes.js +0 -2
- package/build/src/events/EventTypes.js.map +1 -1
- package/build/src/events/Events.d.ts +1 -5
- package/build/src/events/Events.js +0 -2
- package/build/src/events/Events.js.map +1 -1
- package/build/src/events/transport/TransportEventTypes.d.ts +0 -1
- package/build/src/events/transport/TransportEventTypes.js +0 -1
- package/build/src/events/transport/TransportEventTypes.js.map +1 -1
- package/build/src/events/transport/TransportEvents.d.ts +0 -8
- package/build/src/events/transport/TransportEvents.js +0 -11
- package/build/src/events/transport/TransportEvents.js.map +1 -1
- package/build/src/mocking/ProjectMock.d.ts +0 -3
- package/build/src/mocking/ProjectMock.js +0 -3
- package/build/src/mocking/ProjectMock.js.map +1 -1
- package/build/src/mocking/lib/History.js +5 -0
- package/build/src/mocking/lib/History.js.map +1 -1
- package/build/src/models/{Workspace.d.ts → Folder.d.ts} +7 -7
- package/build/src/models/{Workspace.js → Folder.js} +5 -5
- package/build/src/models/Folder.js.map +1 -0
- package/build/src/models/HttpHistory.d.ts +38 -43
- package/build/src/models/HttpHistory.js +27 -34
- package/build/src/models/HttpHistory.js.map +1 -1
- package/build/src/models/HttpProject.d.ts +0 -2
- package/build/src/models/HttpProject.js +0 -27
- package/build/src/models/HttpProject.js.map +1 -1
- package/build/src/models/Project.d.ts +0 -8
- package/build/src/models/Project.js +0 -4
- package/build/src/models/Project.js.map +1 -1
- package/build/src/models/ProjectFolder.d.ts +0 -2
- package/build/src/models/ProjectFolder.js +0 -14
- package/build/src/models/ProjectFolder.js.map +1 -1
- package/build/src/models/ProjectItem.d.ts +0 -2
- package/build/src/models/ProjectItem.js +0 -20
- package/build/src/models/ProjectItem.js.map +1 -1
- package/build/src/models/ProjectRequest.d.ts +2 -3
- package/build/src/models/ProjectRequest.js.map +1 -1
- package/build/src/models/RequestConfig.d.ts +1 -1
- package/build/src/models/Space.d.ts +42 -0
- package/build/src/models/Space.js +81 -0
- package/build/src/models/Space.js.map +1 -0
- package/build/src/models/TrashEntry.d.ts +27 -0
- package/build/src/models/TrashEntry.js +2 -0
- package/build/src/models/TrashEntry.js.map +1 -0
- package/build/src/models/data/DataAssociation.d.ts +22 -5
- package/build/src/models/data/DataAssociation.js +29 -11
- package/build/src/models/data/DataAssociation.js.map +1 -1
- package/build/src/models/data/DataEntity.d.ts +12 -1
- package/build/src/models/data/DataEntity.js +49 -10
- package/build/src/models/data/DataEntity.js.map +1 -1
- package/build/src/models/data/DataNamespace.d.ts +34 -1
- package/build/src/models/data/DataNamespace.js +75 -1
- package/build/src/models/data/DataNamespace.js.map +1 -1
- package/build/src/models/store/Backend.d.ts +0 -315
- package/build/src/models/store/Backend.js +0 -1
- package/build/src/models/store/Backend.js.map +1 -1
- package/build/src/models/store/File.d.ts +30 -0
- package/build/src/models/store/File.js +5 -5
- package/build/src/models/store/File.js.map +1 -1
- package/build/src/proxy/ProxyService.d.ts +0 -10
- package/build/src/proxy/ProxyService.js +0 -14
- package/build/src/proxy/ProxyService.js.map +1 -1
- package/build/src/runtime/node/InteropInterfaces.d.ts +1 -2
- package/build/src/runtime/node/ProjectParallelRunner.d.ts +2 -3
- package/build/src/runtime/node/ProjectParallelRunner.js.map +1 -1
- package/build/src/runtime/node/ProjectRequestRunner.d.ts +7 -8
- package/build/src/runtime/node/ProjectRequestRunner.js +2 -3
- package/build/src/runtime/node/ProjectRequestRunner.js.map +1 -1
- package/build/src/runtime/node/ProjectRunner.d.ts +3 -4
- package/build/src/runtime/node/ProjectRunner.js.map +1 -1
- package/build/src/runtime/node/ProjectRunnerWorker.js +0 -4
- package/build/src/runtime/node/ProjectRunnerWorker.js.map +1 -1
- package/build/src/runtime/store/CertificatesSdk.d.ts +46 -0
- package/build/src/runtime/store/CertificatesSdk.js +227 -0
- package/build/src/runtime/store/CertificatesSdk.js.map +1 -0
- package/build/src/runtime/store/FilesSdk.d.ts +14 -9
- package/build/src/runtime/store/FilesSdk.js +60 -16
- package/build/src/runtime/store/FilesSdk.js.map +1 -1
- package/build/src/runtime/store/HistorySdk.d.ts +11 -8
- package/build/src/runtime/store/HistorySdk.js +140 -17
- package/build/src/runtime/store/HistorySdk.js.map +1 -1
- package/build/src/runtime/store/RevisionsSdk.d.ts +12 -0
- package/build/src/runtime/store/RevisionsSdk.js +43 -0
- package/build/src/runtime/store/RevisionsSdk.js.map +1 -0
- package/build/src/runtime/store/RouteBuilder.d.ts +16 -18
- package/build/src/runtime/store/RouteBuilder.js +33 -60
- package/build/src/runtime/store/RouteBuilder.js.map +1 -1
- package/build/src/runtime/store/Sdk.d.ts +10 -7
- package/build/src/runtime/store/Sdk.js +12 -5
- package/build/src/runtime/store/Sdk.js.map +1 -1
- package/build/src/runtime/store/SdkBase.js.map +1 -1
- package/build/src/runtime/store/SharedSdk.d.ts +2 -2
- package/build/src/runtime/store/SharedSdk.js.map +1 -1
- package/build/src/runtime/store/SpacesSdk.d.ts +29 -0
- package/build/src/runtime/store/SpacesSdk.js +135 -0
- package/build/src/runtime/store/SpacesSdk.js.map +1 -0
- package/build/src/runtime/store/TrashSdk.d.ts +35 -0
- package/build/src/runtime/store/TrashSdk.js +155 -0
- package/build/src/runtime/store/TrashSdk.js.map +1 -0
- package/build/src/runtime/store/UsersSdk.d.ts +2 -2
- package/build/src/runtime/store/UsersSdk.js.map +1 -1
- package/build/src/runtime/store/interfaces/ApiClientStore.d.ts +30 -0
- package/build/src/runtime/store/interfaces/ApiClientStore.js +2 -0
- package/build/src/runtime/store/interfaces/ApiClientStore.js.map +1 -0
- package/build/src/runtime/store/interfaces/Certificates.d.ts +49 -0
- package/build/src/runtime/store/interfaces/Certificates.js +2 -0
- package/build/src/runtime/store/interfaces/Certificates.js.map +1 -0
- package/build/src/runtime/store/interfaces/Files.d.ts +63 -0
- package/build/src/runtime/store/interfaces/Files.js +2 -0
- package/build/src/runtime/store/interfaces/Files.js.map +1 -0
- package/build/src/runtime/store/interfaces/History.d.ts +63 -0
- package/build/src/runtime/store/interfaces/History.js +2 -0
- package/build/src/runtime/store/interfaces/History.js.map +1 -0
- package/build/src/runtime/store/interfaces/Media.d.ts +42 -0
- package/build/src/runtime/store/interfaces/Media.js +2 -0
- package/build/src/runtime/store/interfaces/Media.js.map +1 -0
- package/build/src/runtime/store/interfaces/Revisions.d.ts +25 -0
- package/build/src/runtime/store/interfaces/Revisions.js +2 -0
- package/build/src/runtime/store/interfaces/Revisions.js.map +1 -0
- package/build/src/runtime/store/interfaces/Spaces.d.ts +42 -0
- package/build/src/runtime/store/interfaces/Spaces.js +2 -0
- package/build/src/runtime/store/interfaces/Spaces.js.map +1 -0
- package/build/src/runtime/store/interfaces/Trash.d.ts +38 -0
- package/build/src/runtime/store/interfaces/Trash.js +2 -0
- package/build/src/runtime/store/interfaces/Trash.js.map +1 -0
- package/package.json +12 -12
- package/src/events/BaseEvents.ts +136 -18
- package/src/events/EventTypes.ts +0 -2
- package/src/events/Events.ts +0 -2
- package/src/events/transport/TransportEventTypes.ts +0 -1
- package/src/events/transport/TransportEvents.ts +0 -13
- package/src/mocking/ProjectMock.ts +0 -4
- package/src/mocking/lib/History.ts +5 -0
- package/src/models/{Workspace.ts → Folder.ts} +12 -12
- package/src/models/HttpHistory.ts +53 -63
- package/src/models/HttpProject.ts +0 -29
- package/src/models/Project.ts +0 -8
- package/src/models/ProjectFolder.ts +0 -16
- package/src/models/ProjectItem.ts +0 -18
- package/src/models/ProjectRequest.ts +3 -4
- package/src/models/RequestConfig.ts +1 -1
- package/src/models/Space.ts +105 -0
- package/src/models/TrashEntry.ts +29 -0
- package/src/models/data/DataAssociation.ts +50 -15
- package/src/models/data/DataEntity.ts +51 -10
- package/src/models/data/DataNamespace.ts +78 -2
- package/src/models/store/Backend.ts +0 -342
- package/src/models/store/File.ts +38 -5
- package/src/proxy/ProxyService.ts +0 -15
- package/src/proxy/readme.md +0 -1
- package/src/runtime/node/InteropInterfaces.ts +1 -2
- package/src/runtime/node/ProjectParallelRunner.ts +2 -3
- package/src/runtime/node/ProjectRequestRunner.ts +13 -14
- package/src/runtime/node/ProjectRunner.ts +3 -4
- package/src/runtime/node/ProjectRunnerWorker.ts +1 -4
- package/src/runtime/store/CertificatesSdk.ts +231 -0
- package/src/runtime/store/FilesSdk.ts +71 -26
- package/src/runtime/store/HistorySdk.ts +145 -33
- package/src/runtime/store/RevisionsSdk.ts +44 -0
- package/src/runtime/store/RouteBuilder.ts +37 -69
- package/src/runtime/store/Sdk.ts +17 -7
- package/src/runtime/store/SdkBase.ts +1 -1
- package/src/runtime/store/SharedSdk.ts +3 -3
- package/src/runtime/store/SpacesSdk.ts +136 -0
- package/src/runtime/store/TrashSdk.ts +159 -0
- package/src/runtime/store/UsersSdk.ts +3 -3
- package/src/runtime/store/interfaces/ApiClientStore.ts +39 -0
- package/src/runtime/store/interfaces/Certificates.ts +56 -0
- package/src/runtime/store/interfaces/Files.ts +70 -0
- package/src/runtime/store/interfaces/History.ts +64 -0
- package/src/runtime/store/interfaces/Media.ts +46 -0
- package/src/runtime/store/interfaces/Revisions.ts +27 -0
- package/src/runtime/store/interfaces/Spaces.ts +48 -0
- package/src/runtime/store/interfaces/Trash.ts +42 -0
- package/build/src/events/models/ClientCertificateEvents.d.ts +0 -54
- package/build/src/events/models/ClientCertificateEvents.js +0 -78
- package/build/src/events/models/ClientCertificateEvents.js.map +0 -1
- package/build/src/events/models/ModelEventTypes.d.ts +0 -13
- package/build/src/events/models/ModelEventTypes.js +0 -14
- package/build/src/events/models/ModelEventTypes.js.map +0 -1
- package/build/src/events/models/ModelEvents.d.ts +0 -4
- package/build/src/events/models/ModelEvents.js +0 -5
- package/build/src/events/models/ModelEvents.js.map +0 -1
- package/build/src/mocking/lib/App.d.ts +0 -36
- package/build/src/mocking/lib/App.js +0 -70
- package/build/src/mocking/lib/App.js.map +0 -1
- package/build/src/models/AppProject.d.ts +0 -817
- package/build/src/models/AppProject.js +0 -1721
- package/build/src/models/AppProject.js.map +0 -1
- package/build/src/models/AppRequest.d.ts +0 -69
- package/build/src/models/AppRequest.js +0 -150
- package/build/src/models/AppRequest.js.map +0 -1
- package/build/src/models/Workspace.js.map +0 -1
- package/build/src/proxy/AppProjectProxy.d.ts +0 -28
- package/build/src/proxy/AppProjectProxy.js +0 -107
- package/build/src/proxy/AppProjectProxy.js.map +0 -1
- package/build/src/runtime/store/AppSdk.d.ts +0 -213
- package/build/src/runtime/store/AppSdk.js +0 -836
- package/build/src/runtime/store/AppSdk.js.map +0 -1
- package/src/events/models/ClientCertificateEvents.ts +0 -85
- package/src/events/models/ModelEventTypes.ts +0 -13
- package/src/events/models/ModelEvents.ts +0 -5
- package/src/mocking/lib/App.ts +0 -101
- package/src/models/AppProject.ts +0 -2188
- package/src/models/AppRequest.ts +0 -176
- package/src/proxy/AppProjectProxy.ts +0 -126
- package/src/runtime/store/AppSdk.ts +0 -842
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { SdkBase, E_RESPONSE_STATUS, E_RESPONSE_NO_VALUE, E_INVALID_JSON, E_RESPONSE_UNKNOWN,
|
|
1
|
+
import { SdkBase, E_RESPONSE_STATUS, E_RESPONSE_NO_VALUE, E_INVALID_JSON, E_RESPONSE_UNKNOWN, ISdkRequestOptions } from './SdkBase.js';
|
|
2
2
|
import { RouteBuilder } from './RouteBuilder.js';
|
|
3
|
-
import { IListResponse, HistoryListOptions, IHistoryRequestListOptions } from '../../models/store/Backend.js';
|
|
4
3
|
import { IHttpHistory, IHttpHistoryBulkAdd, Kind as HttpHistoryKind } from '../../models/HttpHistory.js';
|
|
4
|
+
import { ContextChangeRecord, ContextDeleteRecord, ContextListResult, HistoryListOptions, IBulkOperationResult, IHistoryRequestListOptions } from '../../events/BaseEvents.js';
|
|
5
|
+
import { SdkError } from './Errors.js';
|
|
5
6
|
|
|
6
7
|
export class HistorySdk extends SdkBase {
|
|
7
8
|
/**
|
|
@@ -17,7 +18,7 @@ export class HistorySdk extends SdkBase {
|
|
|
17
18
|
* @param request Optional request options.
|
|
18
19
|
* @returns The key of the created history.
|
|
19
20
|
*/
|
|
20
|
-
async
|
|
21
|
+
async add(history: IHttpHistory, request: ISdkRequestOptions = {}): Promise<ContextChangeRecord<IHttpHistory>> {
|
|
21
22
|
const token = request.token || this.sdk.token;
|
|
22
23
|
const url = this.sdk.getUrl(RouteBuilder.history());
|
|
23
24
|
const body = JSON.stringify(history);
|
|
@@ -26,14 +27,26 @@ export class HistorySdk extends SdkBase {
|
|
|
26
27
|
const E_PREFIX = 'Unable to create a history. ';
|
|
27
28
|
if (result.status !== 200) {
|
|
28
29
|
this.logInvalidResponse(result);
|
|
29
|
-
|
|
30
|
+
let e = this.createGenericSdkError(result.body)
|
|
31
|
+
if (!e) {
|
|
32
|
+
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
33
|
+
e.response = result.body;
|
|
34
|
+
}
|
|
35
|
+
throw e;
|
|
30
36
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
37
|
+
if (!result.body) {
|
|
38
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
39
|
+
}
|
|
40
|
+
let data: ContextChangeRecord<IHttpHistory>;
|
|
41
|
+
try {
|
|
42
|
+
data = JSON.parse(result.body);
|
|
43
|
+
} catch (e) {
|
|
44
|
+
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
34
45
|
}
|
|
35
|
-
|
|
36
|
-
|
|
46
|
+
if (!data.key) {
|
|
47
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
|
|
48
|
+
}
|
|
49
|
+
return data;
|
|
37
50
|
}
|
|
38
51
|
|
|
39
52
|
/**
|
|
@@ -42,7 +55,7 @@ export class HistorySdk extends SdkBase {
|
|
|
42
55
|
* @param info The bulk create info object.
|
|
43
56
|
* @param request Optional request options.
|
|
44
57
|
*/
|
|
45
|
-
async createBulk(info: IHttpHistoryBulkAdd, request: ISdkRequestOptions = {}): Promise<
|
|
58
|
+
async createBulk(info: IHttpHistoryBulkAdd, request: ISdkRequestOptions = {}): Promise<IBulkOperationResult<ContextChangeRecord<IHttpHistory>>> {
|
|
46
59
|
const token = request.token || this.sdk.token;
|
|
47
60
|
const url = this.sdk.getUrl(RouteBuilder.historyBatchCreate());
|
|
48
61
|
const body = JSON.stringify(info);
|
|
@@ -51,17 +64,25 @@ export class HistorySdk extends SdkBase {
|
|
|
51
64
|
const E_PREFIX = 'Unable to create a bulk history. ';
|
|
52
65
|
if (result.status !== 200) {
|
|
53
66
|
this.logInvalidResponse(result);
|
|
54
|
-
|
|
67
|
+
let e = this.createGenericSdkError(result.body)
|
|
68
|
+
if (!e) {
|
|
69
|
+
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
70
|
+
e.response = result.body;
|
|
71
|
+
}
|
|
72
|
+
throw e;
|
|
55
73
|
}
|
|
56
74
|
if (!result.body) {
|
|
57
75
|
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
58
76
|
}
|
|
59
|
-
let data:
|
|
77
|
+
let data: IBulkOperationResult<ContextChangeRecord<IHttpHistory>>;
|
|
60
78
|
try {
|
|
61
79
|
data = JSON.parse(result.body).items;
|
|
62
80
|
} catch (e) {
|
|
63
81
|
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
64
82
|
}
|
|
83
|
+
if (!data.items) {
|
|
84
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
|
|
85
|
+
}
|
|
65
86
|
return data;
|
|
66
87
|
}
|
|
67
88
|
|
|
@@ -71,7 +92,7 @@ export class HistorySdk extends SdkBase {
|
|
|
71
92
|
* @param options Optional query options.
|
|
72
93
|
* @param request Optional request options.
|
|
73
94
|
*/
|
|
74
|
-
async list(options: HistoryListOptions, request: ISdkRequestOptions = {}): Promise<
|
|
95
|
+
async list(options: HistoryListOptions, request: ISdkRequestOptions = {}): Promise<ContextListResult<IHttpHistory>> {
|
|
75
96
|
const token = request.token || this.sdk.token;
|
|
76
97
|
const url = this.sdk.getUrl(RouteBuilder.history());
|
|
77
98
|
this.appendHistoryListParameters(url, options);
|
|
@@ -80,12 +101,17 @@ export class HistorySdk extends SdkBase {
|
|
|
80
101
|
const E_PREFIX = 'Unable to list history. ';
|
|
81
102
|
if (result.status !== 200) {
|
|
82
103
|
this.logInvalidResponse(result);
|
|
83
|
-
|
|
104
|
+
let e = this.createGenericSdkError(result.body)
|
|
105
|
+
if (!e) {
|
|
106
|
+
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
107
|
+
e.response = result.body;
|
|
108
|
+
}
|
|
109
|
+
throw e;
|
|
84
110
|
}
|
|
85
111
|
if (!result.body) {
|
|
86
112
|
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
87
113
|
}
|
|
88
|
-
let data:
|
|
114
|
+
let data: ContextListResult<IHttpHistory>;
|
|
89
115
|
try {
|
|
90
116
|
data = JSON.parse(result.body);
|
|
91
117
|
} catch (e) {
|
|
@@ -100,6 +126,7 @@ export class HistorySdk extends SdkBase {
|
|
|
100
126
|
appendHistoryListParameters(url: URL, options: HistoryListOptions): void {
|
|
101
127
|
this.sdk.appendListOptions(url, options);
|
|
102
128
|
const { searchParams } = url;
|
|
129
|
+
searchParams.set('space', options.space);
|
|
103
130
|
if (options.type) {
|
|
104
131
|
searchParams.set('type', options.type);
|
|
105
132
|
}
|
|
@@ -121,32 +148,61 @@ export class HistorySdk extends SdkBase {
|
|
|
121
148
|
* @param key The key returned by the store when created the history. Also available via the `key` property on the history object.
|
|
122
149
|
* @param request Optional request options.
|
|
123
150
|
*/
|
|
124
|
-
delete(key: string, request
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
151
|
+
async delete(key: string, request: ISdkRequestOptions = {}): Promise<void> {
|
|
152
|
+
const token = request.token || this.sdk.token;
|
|
153
|
+
const path = RouteBuilder.historyItem(key);
|
|
154
|
+
const url = this.sdk.getUrl(path);
|
|
155
|
+
|
|
156
|
+
const result = await this.sdk.http.post(url.toString(), { token });
|
|
157
|
+
this.inspectCommonStatusCodes(result.status);
|
|
158
|
+
const E_PREFIX = 'Unable to delete history. ';
|
|
159
|
+
if (result.status !== 204) {
|
|
160
|
+
this.logInvalidResponse(result);
|
|
161
|
+
let e = this.createGenericSdkError(result.body)
|
|
162
|
+
if (!e) {
|
|
163
|
+
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
164
|
+
e.response = result.body;
|
|
165
|
+
}
|
|
166
|
+
throw e;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
132
170
|
/**
|
|
133
|
-
* Deletes
|
|
134
|
-
* @param
|
|
171
|
+
* Deletes history in a bulk operation.
|
|
172
|
+
* @param keys The list of keys of history objects to delete.
|
|
135
173
|
* @param request Optional request options.
|
|
174
|
+
* @returns The list of delete records.
|
|
136
175
|
*/
|
|
137
|
-
async
|
|
176
|
+
async deleteBulk(keys: string[], request: ISdkRequestOptions = {}): Promise<IBulkOperationResult<ContextDeleteRecord>> {
|
|
138
177
|
const token = request.token || this.sdk.token;
|
|
139
|
-
const
|
|
140
|
-
const path = isArray ? RouteBuilder.historyBatchDelete() : RouteBuilder.historyItem(key);
|
|
178
|
+
const path = RouteBuilder.historyBatchDelete();
|
|
141
179
|
const url = this.sdk.getUrl(path);
|
|
142
|
-
|
|
143
|
-
const result = isArray ? await this.sdk.http.post(url.toString(), { token, body: JSON.stringify(key) }) : await this.sdk.http.delete(url.toString(), { token });
|
|
180
|
+
const result = await this.sdk.http.post(url.toString(), { token, body: JSON.stringify(keys) });
|
|
144
181
|
this.inspectCommonStatusCodes(result.status);
|
|
145
182
|
const E_PREFIX = 'Unable to delete history. ';
|
|
146
|
-
if (result.status !==
|
|
183
|
+
if (result.status !== 200) {
|
|
147
184
|
this.logInvalidResponse(result);
|
|
148
|
-
|
|
185
|
+
let e = this.createGenericSdkError(result.body)
|
|
186
|
+
if (!e) {
|
|
187
|
+
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
188
|
+
e.response = result.body;
|
|
189
|
+
}
|
|
190
|
+
throw e;
|
|
191
|
+
}
|
|
192
|
+
if (!result.body) {
|
|
193
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
let data: IBulkOperationResult<ContextDeleteRecord>;
|
|
197
|
+
try {
|
|
198
|
+
data = JSON.parse(result.body);
|
|
199
|
+
} catch (e) {
|
|
200
|
+
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
149
201
|
}
|
|
202
|
+
if (!Array.isArray(data.items)) {
|
|
203
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
|
|
204
|
+
}
|
|
205
|
+
return data;
|
|
150
206
|
}
|
|
151
207
|
|
|
152
208
|
/**
|
|
@@ -163,7 +219,12 @@ export class HistorySdk extends SdkBase {
|
|
|
163
219
|
const E_PREFIX = 'Unable to read a history. ';
|
|
164
220
|
if (result.status !== 200) {
|
|
165
221
|
this.logInvalidResponse(result);
|
|
166
|
-
|
|
222
|
+
let e = this.createGenericSdkError(result.body)
|
|
223
|
+
if (!e) {
|
|
224
|
+
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
225
|
+
e.response = result.body;
|
|
226
|
+
}
|
|
227
|
+
throw e;
|
|
167
228
|
}
|
|
168
229
|
if (!result.body) {
|
|
169
230
|
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
@@ -179,4 +240,55 @@ export class HistorySdk extends SdkBase {
|
|
|
179
240
|
}
|
|
180
241
|
return data;
|
|
181
242
|
}
|
|
243
|
+
|
|
244
|
+
async clearSpace(spaceKey: string, request: ISdkRequestOptions = {}): Promise<void> {
|
|
245
|
+
const token = request.token || this.sdk.token;
|
|
246
|
+
const url = this.sdk.getUrl(RouteBuilder.historyClear('space', spaceKey));
|
|
247
|
+
const result = await this.sdk.http.delete(url.toString(), { token });
|
|
248
|
+
this.inspectCommonStatusCodes(result.status, result.body);
|
|
249
|
+
const E_PREFIX = 'Unable to clear history for the space. ';
|
|
250
|
+
if (result.status !== 204) {
|
|
251
|
+
this.logInvalidResponse(result);
|
|
252
|
+
let e = this.createGenericSdkError(result.body)
|
|
253
|
+
if (!e) {
|
|
254
|
+
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
255
|
+
e.response = result.body;
|
|
256
|
+
}
|
|
257
|
+
throw e;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
async clearProject(projectKey: string, request: ISdkRequestOptions = {}): Promise<void> {
|
|
262
|
+
const token = request.token || this.sdk.token;
|
|
263
|
+
const url = this.sdk.getUrl(RouteBuilder.historyClear('project', projectKey));
|
|
264
|
+
const result = await this.sdk.http.delete(url.toString(), { token });
|
|
265
|
+
this.inspectCommonStatusCodes(result.status, result.body);
|
|
266
|
+
const E_PREFIX = 'Unable to clear history for the project. ';
|
|
267
|
+
if (result.status !== 204) {
|
|
268
|
+
this.logInvalidResponse(result);
|
|
269
|
+
let e = this.createGenericSdkError(result.body)
|
|
270
|
+
if (!e) {
|
|
271
|
+
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
272
|
+
e.response = result.body;
|
|
273
|
+
}
|
|
274
|
+
throw e;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
async clearRequest(projectKey: string, requestKey: string, request: ISdkRequestOptions = {}): Promise<void> {
|
|
279
|
+
const token = request.token || this.sdk.token;
|
|
280
|
+
const url = this.sdk.getUrl(RouteBuilder.historyClear('request', projectKey, requestKey));
|
|
281
|
+
const result = await this.sdk.http.delete(url.toString(), { token });
|
|
282
|
+
this.inspectCommonStatusCodes(result.status, result.body);
|
|
283
|
+
const E_PREFIX = 'Unable to clear history for the request. ';
|
|
284
|
+
if (result.status !== 204) {
|
|
285
|
+
this.logInvalidResponse(result);
|
|
286
|
+
let e = this.createGenericSdkError(result.body)
|
|
287
|
+
if (!e) {
|
|
288
|
+
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
289
|
+
e.response = result.body;
|
|
290
|
+
}
|
|
291
|
+
throw e;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
182
294
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { SdkBase, E_RESPONSE_STATUS, E_RESPONSE_NO_VALUE, E_INVALID_JSON, E_RESPONSE_UNKNOWN, ISdkRequestOptions } from './SdkBase.js';
|
|
2
|
+
import { RouteBuilder } from './RouteBuilder.js';
|
|
3
|
+
import { ContextListResult, ContextSpaceListOptions } from '../../events/BaseEvents.js';
|
|
4
|
+
import { SdkError } from './Errors.js';
|
|
5
|
+
import { IRevision } from '../../models/store/Revision.js';
|
|
6
|
+
|
|
7
|
+
export class RevisionsSdk extends SdkBase {
|
|
8
|
+
/**
|
|
9
|
+
* Lists revisions for a single file.
|
|
10
|
+
*
|
|
11
|
+
* @param key The id of the file to lists revisions for.
|
|
12
|
+
* @param options The list query options
|
|
13
|
+
*/
|
|
14
|
+
async list(key: string, options: ContextSpaceListOptions, request: ISdkRequestOptions = {}): Promise<ContextListResult<IRevision>> {
|
|
15
|
+
const token = request.token || this.sdk.token;
|
|
16
|
+
const url = this.sdk.getUrl(RouteBuilder.fileRevisions(key));
|
|
17
|
+
this.sdk.appendListOptions(url, options);
|
|
18
|
+
const result = await this.sdk.http.get(url.toString(), { token });
|
|
19
|
+
this.inspectCommonStatusCodes(result.status);
|
|
20
|
+
const E_PREFIX = 'Unable to list revisions for a file. ';
|
|
21
|
+
if (result.status !== 200) {
|
|
22
|
+
this.logInvalidResponse(result);
|
|
23
|
+
let e = this.createGenericSdkError(result.body)
|
|
24
|
+
if (!e) {
|
|
25
|
+
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
26
|
+
e.response = result.body;
|
|
27
|
+
}
|
|
28
|
+
throw e;
|
|
29
|
+
}
|
|
30
|
+
if (!result.body) {
|
|
31
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
32
|
+
}
|
|
33
|
+
let data: ContextListResult<IRevision>;
|
|
34
|
+
try {
|
|
35
|
+
data = JSON.parse(result.body);
|
|
36
|
+
} catch (e) {
|
|
37
|
+
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
38
|
+
}
|
|
39
|
+
if (!Array.isArray(data.items)) {
|
|
40
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
|
|
41
|
+
}
|
|
42
|
+
return data;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
* A helper class to make sure routes user and reported by this service are consistent.
|
|
3
3
|
*/
|
|
4
4
|
export class RouteBuilder {
|
|
5
|
+
static spaces(): string {
|
|
6
|
+
return '/spaces';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
static space(key: string): string {
|
|
10
|
+
return `/spaces/${key}`;
|
|
11
|
+
}
|
|
12
|
+
|
|
5
13
|
/**
|
|
6
14
|
* @returns The path to the /files route.
|
|
7
15
|
*/
|
|
@@ -37,6 +45,13 @@ export class RouteBuilder {
|
|
|
37
45
|
return `/file/${file}/revisions`;
|
|
38
46
|
}
|
|
39
47
|
|
|
48
|
+
/**
|
|
49
|
+
* @returns The path to the /file/[id]/revisions route.
|
|
50
|
+
*/
|
|
51
|
+
static fileBreadcrumbs(file: string): string {
|
|
52
|
+
return `/file/${file}/breadcrumbs`;
|
|
53
|
+
}
|
|
54
|
+
|
|
40
55
|
/**
|
|
41
56
|
* @returns The path to the /backend route.
|
|
42
57
|
*/
|
|
@@ -80,94 +95,47 @@ export class RouteBuilder {
|
|
|
80
95
|
return `/history/${key}`;
|
|
81
96
|
}
|
|
82
97
|
|
|
83
|
-
static
|
|
84
|
-
return '/
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
static app(appId: string): string {
|
|
88
|
-
return `/app/${appId}`;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// GET
|
|
92
|
-
static appQuery(appId: string): string {
|
|
93
|
-
return `${this.app(appId)}/query`;
|
|
98
|
+
static historyClear(type: 'space' | 'project' | 'request', ...key: string[]): string {
|
|
99
|
+
return `/history/clear/${type}/${key.join('/')}`;
|
|
94
100
|
}
|
|
95
101
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
return `${this.app(appId)}/query/requests`;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// GET
|
|
102
|
-
static appQueryProjects(appId: string): string {
|
|
103
|
-
return `${this.app(appId)}/query/projects`;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// GET, POST
|
|
107
|
-
static appRequests(appId: string): string {
|
|
108
|
-
return `${this.app(appId)}/requests`;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// GET, DELETE
|
|
112
|
-
static appRequestItem(appId: string, key: string): string {
|
|
113
|
-
return `${this.appRequests(appId)}/${key}`;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
static appRequestsBatch(appId: string): string {
|
|
117
|
-
return `${this.appRequests(appId)}/batch`;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// POST
|
|
121
|
-
static appRequestsBatchCreate(appId: string): string {
|
|
122
|
-
return `${this.appRequestsBatch(appId)}/create`;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// POST
|
|
126
|
-
static appRequestsBatchRead(appId: string): string {
|
|
127
|
-
return `${this.appRequestsBatch(appId)}/read`;
|
|
102
|
+
static shared(): string {
|
|
103
|
+
return '/shared';
|
|
128
104
|
}
|
|
129
105
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
return `${this.appRequestsBatch(appId)}/delete`;
|
|
106
|
+
static certificates(): string {
|
|
107
|
+
return '/certificates';
|
|
133
108
|
}
|
|
134
109
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
return `${this.appRequestsBatch(appId)}/undelete`;
|
|
110
|
+
static certificate(key: string): string {
|
|
111
|
+
return `/certificates/${key}`;
|
|
138
112
|
}
|
|
139
113
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
return `${this.app(appId)}/projects`;
|
|
114
|
+
static certificatesEmpty(key: string): string {
|
|
115
|
+
return `/certificates/empty/${key}`;
|
|
143
116
|
}
|
|
144
117
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
return `${this.appProjects(appId)}/${key}`;
|
|
118
|
+
static certificateBatchCreate(): string {
|
|
119
|
+
return `/certificate/batch/create`;
|
|
148
120
|
}
|
|
149
121
|
|
|
150
|
-
static
|
|
151
|
-
return
|
|
122
|
+
static certificateBatchDelete(): string {
|
|
123
|
+
return `/certificate/batch/delete`;
|
|
152
124
|
}
|
|
153
125
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return `${this.appProjectsBatch(appId)}/create`;
|
|
126
|
+
static trash(): string {
|
|
127
|
+
return `/trash`
|
|
157
128
|
}
|
|
158
129
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
return `${this.appProjectsBatch(appId)}/read`;
|
|
130
|
+
static trashItem(key: string): string {
|
|
131
|
+
return `/trash/${key}`
|
|
162
132
|
}
|
|
163
133
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
return `${this.appProjectsBatch(appId)}/delete`;
|
|
134
|
+
static trashEmpty(space: string): string {
|
|
135
|
+
return `/trash/empty/${space}`
|
|
167
136
|
}
|
|
168
137
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
return `${this.appProjectsBatch(appId)}/undelete`;
|
|
138
|
+
static trashRestore(fileKey: string): string {
|
|
139
|
+
return `/trash/restore/${fileKey}`
|
|
172
140
|
}
|
|
173
141
|
}
|
package/src/runtime/store/Sdk.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { IListOptions } from '../../models/store/Backend.js';
|
|
2
1
|
import { Http } from './Http.js';
|
|
3
2
|
import { WsClient } from './WsClient.js';
|
|
4
3
|
import { AuthSdk } from './AuthSdk.js';
|
|
@@ -7,7 +6,11 @@ import { FilesSdk } from './FilesSdk.js';
|
|
|
7
6
|
import { UsersSdk } from './UsersSdk.js';
|
|
8
7
|
import { HistorySdk } from './HistorySdk.js';
|
|
9
8
|
import { SharedSdk } from './SharedSdk.js';
|
|
10
|
-
import {
|
|
9
|
+
import { ContextListOptions, ContextSpaceListOptions } from '../../events/BaseEvents.js';
|
|
10
|
+
import { CertificatesSdk } from './CertificatesSdk.js';
|
|
11
|
+
import { RevisionsSdk } from './RevisionsSdk.js';
|
|
12
|
+
import { SpacesSdk } from './SpacesSdk.js';
|
|
13
|
+
import { TrashSdk } from './TrashSdk.js';
|
|
11
14
|
|
|
12
15
|
const baseUriSymbol = Symbol('baseUri');
|
|
13
16
|
|
|
@@ -52,10 +55,13 @@ export abstract class Sdk {
|
|
|
52
55
|
*/
|
|
53
56
|
shared = new SharedSdk(this);
|
|
54
57
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
certificates = new CertificatesSdk(this);
|
|
59
|
+
|
|
60
|
+
revisions = new RevisionsSdk(this);
|
|
61
|
+
|
|
62
|
+
spaces = new SpacesSdk(this);
|
|
63
|
+
|
|
64
|
+
trash = new TrashSdk(this);
|
|
59
65
|
|
|
60
66
|
/**
|
|
61
67
|
* When set it limits log output to minimum.
|
|
@@ -121,7 +127,7 @@ export abstract class Sdk {
|
|
|
121
127
|
* @param url The URL object to the API endpoint
|
|
122
128
|
* @param options The list options, if any
|
|
123
129
|
*/
|
|
124
|
-
appendListOptions(url: URL, options:
|
|
130
|
+
appendListOptions(url: URL, options: ContextListOptions = {}): void {
|
|
125
131
|
const { searchParams } = url;
|
|
126
132
|
if (options.cursor) {
|
|
127
133
|
searchParams.set('cursor', options.cursor);
|
|
@@ -143,6 +149,10 @@ export abstract class Sdk {
|
|
|
143
149
|
if (options.since) {
|
|
144
150
|
searchParams.set('since', String(options.since));
|
|
145
151
|
}
|
|
152
|
+
const typed = options as ContextSpaceListOptions;
|
|
153
|
+
if (typed.space) {
|
|
154
|
+
searchParams.set('space', typed.space);
|
|
155
|
+
}
|
|
146
156
|
}
|
|
147
157
|
}
|
|
148
158
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { SdkBase, E_RESPONSE_STATUS, E_RESPONSE_NO_VALUE, E_INVALID_JSON, E_RESPONSE_UNKNOWN, ISdkRequestOptions } from './SdkBase.js';
|
|
2
2
|
import { RouteBuilder } from './RouteBuilder.js';
|
|
3
|
-
import { IListOptions, IListResponse } from '../../models/store/Backend.js';
|
|
4
3
|
import { IFile } from '../../models/store/File.js';
|
|
5
4
|
import { SdkError } from './Errors.js';
|
|
6
5
|
import { ListFileKind } from './FilesSdk.js';
|
|
6
|
+
import { ContextListResult, ContextSpaceListOptions } from '../../events/BaseEvents.js';
|
|
7
7
|
|
|
8
8
|
export class SharedSdk extends SdkBase {
|
|
9
9
|
/**
|
|
@@ -13,7 +13,7 @@ export class SharedSdk extends SdkBase {
|
|
|
13
13
|
* @param options Optional query options.
|
|
14
14
|
* @param request Optional request options.
|
|
15
15
|
*/
|
|
16
|
-
async list(kinds?: ListFileKind[], options?:
|
|
16
|
+
async list(kinds?: ListFileKind[], options?: ContextSpaceListOptions, request: ISdkRequestOptions = {}): Promise<ContextListResult<IFile>> {
|
|
17
17
|
const token = request.token || this.sdk.token;
|
|
18
18
|
const url = this.sdk.getUrl(RouteBuilder.shared());
|
|
19
19
|
this.sdk.appendListOptions(url, options);
|
|
@@ -35,7 +35,7 @@ export class SharedSdk extends SdkBase {
|
|
|
35
35
|
if (!result.body) {
|
|
36
36
|
throw new SdkError(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, 0);
|
|
37
37
|
}
|
|
38
|
-
let data:
|
|
38
|
+
let data: ContextListResult<IFile>;
|
|
39
39
|
try {
|
|
40
40
|
data = JSON.parse(result.body);
|
|
41
41
|
} catch (e) {
|