@api-client/core 0.12.9 → 0.12.11
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/src/browser.d.ts +1 -2
- package/build/src/browser.d.ts.map +1 -1
- package/build/src/browser.js +0 -1
- package/build/src/browser.js.map +1 -1
- package/build/src/exceptions/exception.d.ts +29 -1
- package/build/src/exceptions/exception.d.ts.map +1 -1
- package/build/src/exceptions/exception.js +37 -1
- package/build/src/exceptions/exception.js.map +1 -1
- package/build/src/index.d.ts +1 -2
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +0 -1
- package/build/src/index.js.map +1 -1
- package/build/src/mocking/lib/User.d.ts.map +1 -1
- package/build/src/mocking/lib/User.js +1 -0
- package/build/src/mocking/lib/User.js.map +1 -1
- package/build/src/models/store/User.d.ts +14 -0
- package/build/src/models/store/User.d.ts.map +1 -1
- package/build/src/models/store/User.js.map +1 -1
- package/build/src/proxy/HttpProjectProxy.d.ts.map +1 -1
- package/build/src/proxy/HttpProjectProxy.js +39 -43
- package/build/src/proxy/HttpProjectProxy.js.map +1 -1
- package/build/src/proxy/RequestProxy.d.ts.map +1 -1
- package/build/src/proxy/RequestProxy.js +11 -11
- package/build/src/proxy/RequestProxy.js.map +1 -1
- package/build/src/runtime/store/DataCatalogSdk.d.ts.map +1 -1
- package/build/src/runtime/store/DataCatalogSdk.js +49 -109
- package/build/src/runtime/store/DataCatalogSdk.js.map +1 -1
- package/build/src/runtime/store/FilesSdk.d.ts.map +1 -1
- package/build/src/runtime/store/FilesSdk.js +51 -115
- package/build/src/runtime/store/FilesSdk.js.map +1 -1
- package/build/src/runtime/store/HistorySdk.d.ts.map +1 -1
- package/build/src/runtime/store/HistorySdk.js +25 -70
- package/build/src/runtime/store/HistorySdk.js.map +1 -1
- package/build/src/runtime/store/OrganizationsSdk.d.ts +20 -1
- package/build/src/runtime/store/OrganizationsSdk.d.ts.map +1 -1
- package/build/src/runtime/store/OrganizationsSdk.js +103 -43
- package/build/src/runtime/store/OrganizationsSdk.js.map +1 -1
- package/build/src/runtime/store/RevisionsSdk.d.ts.map +1 -1
- package/build/src/runtime/store/RevisionsSdk.js +5 -10
- package/build/src/runtime/store/RevisionsSdk.js.map +1 -1
- package/build/src/runtime/store/RouteBuilder.d.ts +8 -0
- package/build/src/runtime/store/RouteBuilder.d.ts.map +1 -1
- package/build/src/runtime/store/RouteBuilder.js +12 -0
- package/build/src/runtime/store/RouteBuilder.js.map +1 -1
- package/build/src/runtime/store/SdkBase.d.ts +7 -5
- package/build/src/runtime/store/SdkBase.d.ts.map +1 -1
- package/build/src/runtime/store/SdkBase.js +45 -63
- package/build/src/runtime/store/SdkBase.js.map +1 -1
- package/build/src/runtime/store/SharedSdk.d.ts.map +1 -1
- package/build/src/runtime/store/SharedSdk.js +5 -14
- package/build/src/runtime/store/SharedSdk.js.map +1 -1
- package/build/src/runtime/store/TrashSdk.d.ts.map +1 -1
- package/build/src/runtime/store/TrashSdk.js +8 -28
- package/build/src/runtime/store/TrashSdk.js.map +1 -1
- package/build/src/runtime/store/UsersSdk.d.ts +2 -0
- package/build/src/runtime/store/UsersSdk.d.ts.map +1 -1
- package/build/src/runtime/store/UsersSdk.js +18 -11
- package/build/src/runtime/store/UsersSdk.js.map +1 -1
- package/package.json +1 -1
- package/src/exceptions/exception.ts +51 -4
- package/src/mocking/lib/User.ts +1 -0
- package/src/models/store/User.ts +16 -0
- package/src/proxy/HttpProjectProxy.ts +39 -43
- package/src/proxy/RequestProxy.ts +11 -11
- package/src/runtime/store/DataCatalogSdk.ts +49 -109
- package/src/runtime/store/FilesSdk.ts +51 -115
- package/src/runtime/store/HistorySdk.ts +25 -70
- package/src/runtime/store/OrganizationsSdk.ts +109 -44
- package/src/runtime/store/RevisionsSdk.ts +5 -10
- package/src/runtime/store/RouteBuilder.ts +14 -0
- package/src/runtime/store/SdkBase.ts +46 -65
- package/src/runtime/store/SharedSdk.ts +5 -14
- package/src/runtime/store/TrashSdk.ts +8 -28
- package/src/runtime/store/UsersSdk.ts +18 -11
- package/tests/unit/runtime/proxy/HttpProjectProxy.spec.ts +42 -40
- package/tests/unit/runtime/proxy/RequestProxy.spec.ts +11 -11
- package/build/src/runtime/store/Errors.d.ts +0 -51
- package/build/src/runtime/store/Errors.d.ts.map +0 -1
- package/build/src/runtime/store/Errors.js +0 -61
- package/build/src/runtime/store/Errors.js.map +0 -1
- package/src/runtime/store/Errors.ts +0 -98
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SdkBase, E_RESPONSE_STATUS, E_RESPONSE_NO_VALUE, E_INVALID_JSON, E_RESPONSE_UNKNOWN, } from './SdkBase.js';
|
|
2
2
|
import { RouteBuilder } from './RouteBuilder.js';
|
|
3
3
|
import { Kind as HttpHistoryKind } from '../../models/HttpHistory.js';
|
|
4
|
-
import {
|
|
4
|
+
import { Exception } from '../../exceptions/exception.js';
|
|
5
5
|
export class HistorySdk extends SdkBase {
|
|
6
6
|
/**
|
|
7
7
|
* Creates a history object.
|
|
@@ -25,25 +25,20 @@ export class HistorySdk extends SdkBase {
|
|
|
25
25
|
const E_PREFIX = 'Unable to create a history. ';
|
|
26
26
|
if (result.status !== 200) {
|
|
27
27
|
this.logInvalidResponse(result);
|
|
28
|
-
|
|
29
|
-
if (!e) {
|
|
30
|
-
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
31
|
-
e.response = result.body;
|
|
32
|
-
}
|
|
33
|
-
throw e;
|
|
28
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
34
29
|
}
|
|
35
30
|
if (!result.body) {
|
|
36
|
-
throw new
|
|
31
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status });
|
|
37
32
|
}
|
|
38
33
|
let data;
|
|
39
34
|
try {
|
|
40
35
|
data = JSON.parse(result.body);
|
|
41
36
|
}
|
|
42
37
|
catch {
|
|
43
|
-
throw new
|
|
38
|
+
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status });
|
|
44
39
|
}
|
|
45
40
|
if (!data.key) {
|
|
46
|
-
throw new
|
|
41
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status });
|
|
47
42
|
}
|
|
48
43
|
return data;
|
|
49
44
|
}
|
|
@@ -62,25 +57,20 @@ export class HistorySdk extends SdkBase {
|
|
|
62
57
|
const E_PREFIX = 'Unable to create a bulk history. ';
|
|
63
58
|
if (result.status !== 200) {
|
|
64
59
|
this.logInvalidResponse(result);
|
|
65
|
-
|
|
66
|
-
if (!e) {
|
|
67
|
-
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
68
|
-
e.response = result.body;
|
|
69
|
-
}
|
|
70
|
-
throw e;
|
|
60
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
71
61
|
}
|
|
72
62
|
if (!result.body) {
|
|
73
|
-
throw new
|
|
63
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status });
|
|
74
64
|
}
|
|
75
65
|
let data;
|
|
76
66
|
try {
|
|
77
67
|
data = JSON.parse(result.body);
|
|
78
68
|
}
|
|
79
69
|
catch {
|
|
80
|
-
throw new
|
|
70
|
+
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status });
|
|
81
71
|
}
|
|
82
72
|
if (!data.items) {
|
|
83
|
-
throw new
|
|
73
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status });
|
|
84
74
|
}
|
|
85
75
|
return data;
|
|
86
76
|
}
|
|
@@ -99,25 +89,20 @@ export class HistorySdk extends SdkBase {
|
|
|
99
89
|
const E_PREFIX = 'Unable to list history. ';
|
|
100
90
|
if (result.status !== 200) {
|
|
101
91
|
this.logInvalidResponse(result);
|
|
102
|
-
|
|
103
|
-
if (!e) {
|
|
104
|
-
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
105
|
-
e.response = result.body;
|
|
106
|
-
}
|
|
107
|
-
throw e;
|
|
92
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
108
93
|
}
|
|
109
94
|
if (!result.body) {
|
|
110
|
-
throw new
|
|
95
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status });
|
|
111
96
|
}
|
|
112
97
|
let data;
|
|
113
98
|
try {
|
|
114
99
|
data = JSON.parse(result.body);
|
|
115
100
|
}
|
|
116
101
|
catch {
|
|
117
|
-
throw new
|
|
102
|
+
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status });
|
|
118
103
|
}
|
|
119
104
|
if (!Array.isArray(data.items)) {
|
|
120
|
-
throw new
|
|
105
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status });
|
|
121
106
|
}
|
|
122
107
|
return data;
|
|
123
108
|
}
|
|
@@ -155,12 +140,7 @@ export class HistorySdk extends SdkBase {
|
|
|
155
140
|
const E_PREFIX = 'Unable to delete history. ';
|
|
156
141
|
if (result.status !== 204) {
|
|
157
142
|
this.logInvalidResponse(result);
|
|
158
|
-
|
|
159
|
-
if (!e) {
|
|
160
|
-
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
161
|
-
e.response = result.body;
|
|
162
|
-
}
|
|
163
|
-
throw e;
|
|
143
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
164
144
|
}
|
|
165
145
|
}
|
|
166
146
|
/**
|
|
@@ -178,25 +158,20 @@ export class HistorySdk extends SdkBase {
|
|
|
178
158
|
const E_PREFIX = 'Unable to delete history. ';
|
|
179
159
|
if (result.status !== 200) {
|
|
180
160
|
this.logInvalidResponse(result);
|
|
181
|
-
|
|
182
|
-
if (!e) {
|
|
183
|
-
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
184
|
-
e.response = result.body;
|
|
185
|
-
}
|
|
186
|
-
throw e;
|
|
161
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
187
162
|
}
|
|
188
163
|
if (!result.body) {
|
|
189
|
-
throw new
|
|
164
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status });
|
|
190
165
|
}
|
|
191
166
|
let data;
|
|
192
167
|
try {
|
|
193
168
|
data = JSON.parse(result.body);
|
|
194
169
|
}
|
|
195
170
|
catch {
|
|
196
|
-
throw new
|
|
171
|
+
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status });
|
|
197
172
|
}
|
|
198
173
|
if (!Array.isArray(data.items)) {
|
|
199
|
-
throw new
|
|
174
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status });
|
|
200
175
|
}
|
|
201
176
|
return data;
|
|
202
177
|
}
|
|
@@ -214,25 +189,20 @@ export class HistorySdk extends SdkBase {
|
|
|
214
189
|
const E_PREFIX = 'Unable to read a history. ';
|
|
215
190
|
if (result.status !== 200) {
|
|
216
191
|
this.logInvalidResponse(result);
|
|
217
|
-
|
|
218
|
-
if (!e) {
|
|
219
|
-
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
220
|
-
e.response = result.body;
|
|
221
|
-
}
|
|
222
|
-
throw e;
|
|
192
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
223
193
|
}
|
|
224
194
|
if (!result.body) {
|
|
225
|
-
throw new
|
|
195
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status });
|
|
226
196
|
}
|
|
227
197
|
let data;
|
|
228
198
|
try {
|
|
229
199
|
data = JSON.parse(result.body);
|
|
230
200
|
}
|
|
231
201
|
catch {
|
|
232
|
-
throw new
|
|
202
|
+
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status });
|
|
233
203
|
}
|
|
234
204
|
if (data.kind !== HttpHistoryKind) {
|
|
235
|
-
throw new
|
|
205
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status });
|
|
236
206
|
}
|
|
237
207
|
return data;
|
|
238
208
|
}
|
|
@@ -244,12 +214,7 @@ export class HistorySdk extends SdkBase {
|
|
|
244
214
|
const E_PREFIX = 'Unable to clear history for the organization. ';
|
|
245
215
|
if (result.status !== 204) {
|
|
246
216
|
this.logInvalidResponse(result);
|
|
247
|
-
|
|
248
|
-
if (!e) {
|
|
249
|
-
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
250
|
-
e.response = result.body;
|
|
251
|
-
}
|
|
252
|
-
throw e;
|
|
217
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
253
218
|
}
|
|
254
219
|
}
|
|
255
220
|
async clearProject(organizationKey, projectKey, request = {}) {
|
|
@@ -260,12 +225,7 @@ export class HistorySdk extends SdkBase {
|
|
|
260
225
|
const E_PREFIX = 'Unable to clear history for the project. ';
|
|
261
226
|
if (result.status !== 204) {
|
|
262
227
|
this.logInvalidResponse(result);
|
|
263
|
-
|
|
264
|
-
if (!e) {
|
|
265
|
-
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
266
|
-
e.response = result.body;
|
|
267
|
-
}
|
|
268
|
-
throw e;
|
|
228
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
269
229
|
}
|
|
270
230
|
}
|
|
271
231
|
async clearRequest(organizationKey, projectKey, requestKey, request = {}) {
|
|
@@ -276,12 +236,7 @@ export class HistorySdk extends SdkBase {
|
|
|
276
236
|
const E_PREFIX = 'Unable to clear history for the request. ';
|
|
277
237
|
if (result.status !== 204) {
|
|
278
238
|
this.logInvalidResponse(result);
|
|
279
|
-
|
|
280
|
-
if (!e) {
|
|
281
|
-
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
282
|
-
e.response = result.body;
|
|
283
|
-
}
|
|
284
|
-
throw e;
|
|
239
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
285
240
|
}
|
|
286
241
|
}
|
|
287
242
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HistorySdk.js","sourceRoot":"","sources":["../../../../src/runtime/store/HistorySdk.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,kBAAkB,GAEnB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAqC,IAAI,IAAI,eAAe,EAAE,MAAM,6BAA6B,CAAA;AASxG,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,MAAM,OAAO,UAAW,SAAQ,OAAO;IACrC;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,GAAG,CAAC,OAAqB,EAAE,UAAsB,EAAE;QACvD,MAAM,EAAE,KAAK,EAAE,GAAG,OAA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CAAC;IAED,KAAK,CAAC,YAAY,CAChB,eAAuB,EACvB,UAAkB,EAClB,UAAkB,EAClB,UAAsB,EAAE;QAExB,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAA;QACzB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,YAAY,CAAC,SAAS,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAA;QAC1G,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;QACpE,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAA;QACrC,MAAM,QAAQ,GAAG,2CAA2C,CAAA;QAC5D,IAAI,MAAM,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YAC1B,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAA;YAC/B,IAAI,CAAC,GAAG,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;YAC/C,IAAI,CAAC,CAAC,EAAE,CAAC;gBACP,CAAC,GAAG,IAAI,QAAQ,CAAC,GAAG,QAAQ,GAAG,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;gBAClF,CAAC,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAA;YAC1B,CAAC;YACD,MAAM,CAAC,CAAA;QACT,CAAC;IACH,CAAC;CACF","sourcesContent":["import {\n SdkBase,\n E_RESPONSE_STATUS,\n E_RESPONSE_NO_VALUE,\n E_INVALID_JSON,\n E_RESPONSE_UNKNOWN,\n SdkOptions,\n} from './SdkBase.js'\nimport { RouteBuilder } from './RouteBuilder.js'\nimport { IHttpHistory, IHttpHistoryBulkAdd, Kind as HttpHistoryKind } from '../../models/HttpHistory.js'\nimport {\n ContextChangeRecord,\n ContextDeleteRecord,\n ContextListResult,\n HistoryListOptions,\n IBulkOperationResult,\n IHistoryRequestListOptions,\n} from '../../events/BaseEvents.js'\nimport { SdkError } from './Errors.js'\n\nexport class HistorySdk extends SdkBase {\n /**\n * Creates a history object.\n * A history object can be created per app (type = app) or a store's organization/[project/[request]].\n *\n * The user can always read their own history. If the history is created for a organization/project then\n * history records are shared as any other object in the organization.\n *\n * Note, history objects cannot be updated. They can only be created or deleted.\n *\n * @param history The history to create\n * @param request Optional request options.\n * @returns The key of the created history.\n */\n async add(history: IHttpHistory, request: SdkOptions = {}): Promise<ContextChangeRecord<IHttpHistory>> {\n const { token } = request\n const url = this.sdk.getUrl(RouteBuilder.history())\n const body = JSON.stringify(history)\n const result = await this.sdk.http.post(url.toString(), { token, body })\n this.inspectCommonStatusCodes(result)\n const E_PREFIX = 'Unable to create a history. '\n if (result.status !== 200) {\n this.logInvalidResponse(result)\n let e = this.createGenericSdkError(result.body)\n if (!e) {\n e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status)\n e.response = result.body\n }\n throw e\n }\n if (!result.body) {\n throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`)\n }\n let data: ContextChangeRecord<IHttpHistory>\n try {\n data = JSON.parse(result.body)\n } catch {\n throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`)\n }\n if (!data.key) {\n throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`)\n }\n return data\n }\n\n /**\n * Creates a multiple history objects in a batch operation.\n *\n * @param info The bulk create info object.\n * @param request Optional request options.\n */\n async createBulk(\n info: IHttpHistoryBulkAdd,\n request: SdkOptions = {}\n ): Promise<IBulkOperationResult<ContextChangeRecord<IHttpHistory>>> {\n const { token } = request\n const url = this.sdk.getUrl(RouteBuilder.historyBatchCreate())\n const body = JSON.stringify(info)\n const result = await this.sdk.http.post(url.toString(), { token, body })\n this.inspectCommonStatusCodes(result)\n const E_PREFIX = 'Unable to create a bulk history. '\n if (result.status !== 200) {\n this.logInvalidResponse(result)\n let e = this.createGenericSdkError(result.body)\n if (!e) {\n e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status)\n e.response = result.body\n }\n throw e\n }\n if (!result.body) {\n throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`)\n }\n let data: IBulkOperationResult<ContextChangeRecord<IHttpHistory>>\n try {\n data = JSON.parse(result.body)\n } catch {\n throw new Error(`${E_PREFIX}${E_INVALID_JSON}`)\n }\n if (!data.items) {\n throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`)\n }\n return data\n }\n\n /**\n * Lists the history.\n *\n * @param options Optional query options.\n * @param request Optional request options.\n */\n async list(options: HistoryListOptions, request: SdkOptions = {}): Promise<ContextListResult<IHttpHistory>> {\n const { token } = request\n const url = this.sdk.getUrl(RouteBuilder.history())\n this.appendHistoryListParameters(url, options)\n const result = await this.sdk.http.get(url.toString(), { token })\n this.inspectCommonStatusCodes(result)\n const E_PREFIX = 'Unable to list history. '\n if (result.status !== 200) {\n this.logInvalidResponse(result)\n let e = this.createGenericSdkError(result.body)\n if (!e) {\n e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status)\n e.response = result.body\n }\n throw e\n }\n if (!result.body) {\n throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`)\n }\n let data: ContextListResult<IHttpHistory>\n try {\n data = JSON.parse(result.body)\n } catch {\n throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`)\n }\n if (!Array.isArray(data.items)) {\n throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`)\n }\n return data\n }\n\n appendHistoryListParameters(url: URL, options: HistoryListOptions): void {\n this.sdk.appendListOptions(url, options)\n const { searchParams } = url\n searchParams.set('organization', options.organization)\n if (options.type) {\n searchParams.set('type', options.type)\n }\n const projectOptions = options as IHistoryRequestListOptions\n if (projectOptions.id) {\n searchParams.set('id', projectOptions.id)\n }\n if (projectOptions.user) {\n searchParams.set('user', 'true')\n }\n if (projectOptions.project) {\n searchParams.set('project', projectOptions.project)\n }\n }\n\n /**\n * Deletes a history object form the store.\n *\n * @param key The key returned by the store when created the history. Also available via the\n * `key` property on the history object.\n * @param request Optional request options.\n */\n async delete(key: string, request: SdkOptions = {}): Promise<void> {\n const { token } = request\n const path = RouteBuilder.historyItem(key)\n const url = this.sdk.getUrl(path)\n\n const result = await this.sdk.http.delete(url.toString(), { token })\n this.inspectCommonStatusCodes(result)\n const E_PREFIX = 'Unable to delete history. '\n if (result.status !== 204) {\n this.logInvalidResponse(result)\n let e = this.createGenericSdkError(result.body)\n if (!e) {\n e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status)\n e.response = result.body\n }\n throw e\n }\n }\n\n /**\n * Deletes history in a bulk operation.\n * @param keys The list of keys of history objects to delete.\n * @param request Optional request options.\n * @returns The list of delete records.\n */\n async deleteBulk(keys: string[], request: SdkOptions = {}): Promise<IBulkOperationResult<ContextDeleteRecord>> {\n const { token } = request\n const path = RouteBuilder.historyBatchDelete()\n const url = this.sdk.getUrl(path)\n const result = await this.sdk.http.post(url.toString(), { token, body: JSON.stringify(keys) })\n this.inspectCommonStatusCodes(result)\n const E_PREFIX = 'Unable to delete history. '\n if (result.status !== 200) {\n this.logInvalidResponse(result)\n let e = this.createGenericSdkError(result.body)\n if (!e) {\n e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status)\n e.response = result.body\n }\n throw e\n }\n if (!result.body) {\n throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`)\n }\n\n let data: IBulkOperationResult<ContextDeleteRecord>\n try {\n data = JSON.parse(result.body)\n } catch {\n throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`)\n }\n if (!Array.isArray(data.items)) {\n throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`)\n }\n return data\n }\n\n /**\n * Reads a history definition from the store.\n * @param key The history key\n * @param request Optional request options.\n * @returns The history object\n */\n async read(key: string, request: SdkOptions = {}): Promise<IHttpHistory> {\n const { token } = request\n const url = this.sdk.getUrl(RouteBuilder.historyItem(key))\n const result = await this.sdk.http.get(url.toString(), { token })\n this.inspectCommonStatusCodes(result)\n const E_PREFIX = 'Unable to read a history. '\n if (result.status !== 200) {\n this.logInvalidResponse(result)\n let e = this.createGenericSdkError(result.body)\n if (!e) {\n e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status)\n e.response = result.body\n }\n throw e\n }\n if (!result.body) {\n throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`)\n }\n let data: IHttpHistory\n try {\n data = JSON.parse(result.body)\n } catch {\n throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`)\n }\n if (data.kind !== HttpHistoryKind) {\n throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`)\n }\n return data\n }\n\n async clearOrganization(organizationKey: string, request: SdkOptions = {}): Promise<void> {\n const { token } = request\n const url = this.sdk.getUrl(RouteBuilder.historyClear('organization', organizationKey))\n const result = await this.sdk.http.delete(url.toString(), { token })\n this.inspectCommonStatusCodes(result)\n const E_PREFIX = 'Unable to clear history for the organization. '\n if (result.status !== 204) {\n this.logInvalidResponse(result)\n let e = this.createGenericSdkError(result.body)\n if (!e) {\n e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status)\n e.response = result.body\n }\n throw e\n }\n }\n\n async clearProject(organizationKey: string, projectKey: string, request: SdkOptions = {}): Promise<void> {\n const { token } = request\n const url = this.sdk.getUrl(RouteBuilder.historyClear('project', organizationKey, projectKey))\n const result = await this.sdk.http.delete(url.toString(), { token })\n this.inspectCommonStatusCodes(result)\n const E_PREFIX = 'Unable to clear history for the project. '\n if (result.status !== 204) {\n this.logInvalidResponse(result)\n let e = this.createGenericSdkError(result.body)\n if (!e) {\n e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status)\n e.response = result.body\n }\n throw e\n }\n }\n\n async clearRequest(\n organizationKey: string,\n projectKey: string,\n requestKey: string,\n request: SdkOptions = {}\n ): Promise<void> {\n const { token } = request\n const url = this.sdk.getUrl(RouteBuilder.historyClear('request', organizationKey, projectKey, requestKey))\n const result = await this.sdk.http.delete(url.toString(), { token })\n this.inspectCommonStatusCodes(result)\n const E_PREFIX = 'Unable to clear history for the request. '\n if (result.status !== 204) {\n this.logInvalidResponse(result)\n let e = this.createGenericSdkError(result.body)\n if (!e) {\n e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status)\n e.response = result.body\n }\n throw e\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"HistorySdk.js","sourceRoot":"","sources":["../../../../src/runtime/store/HistorySdk.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,kBAAkB,GAEnB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAqC,IAAI,IAAI,eAAe,EAAE,MAAM,6BAA6B,CAAA;AASxG,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AAEzD,MAAM,OAAO,UAAW,SAAQ,OAAO;IACrC;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,GAAG,CAAC,OAAqB,EAAE,UAAsB,EAAE;QACvD,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAA;QACzB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC,CAAA;QACnD,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;QACpC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,I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ON,\n E_RESPONSE_UNKNOWN,\n SdkOptions,\n} from './SdkBase.js'\nimport { RouteBuilder } from './RouteBuilder.js'\nimport { IHttpHistory, IHttpHistoryBulkAdd, Kind as HttpHistoryKind } from '../../models/HttpHistory.js'\nimport {\n ContextChangeRecord,\n ContextDeleteRecord,\n ContextListResult,\n HistoryListOptions,\n IBulkOperationResult,\n IHistoryRequestListOptions,\n} from '../../events/BaseEvents.js'\nimport { Exception } from '../../exceptions/exception.js'\n\nexport class HistorySdk extends SdkBase {\n /**\n * Creates a history object.\n * A history object can be created per app (type = app) or a store's organization/[project/[request]].\n *\n * The user can always read their own history. If the history is created for a organization/project then\n * history records are shared as any other object in the organization.\n *\n * Note, history objects cannot be updated. They can only be created or deleted.\n *\n * @param history The history to create\n * @param request Optional request options.\n * @returns The key of the created history.\n */\n async add(history: IHttpHistory, request: SdkOptions = {}): Promise<ContextChangeRecord<IHttpHistory>> {\n const { token } = request\n const url = this.sdk.getUrl(RouteBuilder.history())\n const body = JSON.stringify(history)\n const result = await this.sdk.http.post(url.toString(), { token, body })\n this.inspectCommonStatusCodes(result)\n const E_PREFIX = 'Unable to create a history. '\n if (result.status !== 200) {\n this.logInvalidResponse(result)\n throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body)\n }\n if (!result.body) {\n throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status })\n }\n let data: ContextChangeRecord<IHttpHistory>\n try {\n data = JSON.parse(result.body)\n } catch {\n throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status })\n }\n if (!data.key) {\n throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status })\n }\n return data\n }\n\n /**\n * Creates a multiple history objects in a batch operation.\n *\n * @param info The bulk create info object.\n * @param request Optional request options.\n */\n async createBulk(\n info: IHttpHistoryBulkAdd,\n request: SdkOptions = {}\n ): Promise<IBulkOperationResult<ContextChangeRecord<IHttpHistory>>> {\n const { token } = request\n const url = this.sdk.getUrl(RouteBuilder.historyBatchCreate())\n const body = JSON.stringify(info)\n const result = await this.sdk.http.post(url.toString(), { token, body })\n this.inspectCommonStatusCodes(result)\n const E_PREFIX = 'Unable to create a bulk history. '\n if (result.status !== 200) {\n this.logInvalidResponse(result)\n throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body)\n }\n if (!result.body) {\n throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status })\n }\n let data: IBulkOperationResult<ContextChangeRecord<IHttpHistory>>\n try {\n data = JSON.parse(result.body)\n } catch {\n throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status })\n }\n if (!data.items) {\n throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status })\n }\n return data\n }\n\n /**\n * Lists the history.\n *\n * @param options Optional query options.\n * @param request Optional request options.\n */\n async list(options: HistoryListOptions, request: SdkOptions = {}): Promise<ContextListResult<IHttpHistory>> {\n const { token } = request\n const url = this.sdk.getUrl(RouteBuilder.history())\n this.appendHistoryListParameters(url, options)\n const result = await this.sdk.http.get(url.toString(), { token })\n this.inspectCommonStatusCodes(result)\n const E_PREFIX = 'Unable to list history. '\n if (result.status !== 200) {\n this.logInvalidResponse(result)\n throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body)\n }\n if (!result.body) {\n throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status })\n }\n let data: ContextListResult<IHttpHistory>\n try {\n data = JSON.parse(result.body)\n } catch {\n throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status })\n }\n if (!Array.isArray(data.items)) {\n throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status })\n }\n return data\n }\n\n appendHistoryListParameters(url: URL, options: HistoryListOptions): void {\n this.sdk.appendListOptions(url, options)\n const { searchParams } = url\n searchParams.set('organization', options.organization)\n if (options.type) {\n searchParams.set('type', options.type)\n }\n const projectOptions = options as IHistoryRequestListOptions\n if (projectOptions.id) {\n searchParams.set('id', projectOptions.id)\n }\n if (projectOptions.user) {\n searchParams.set('user', 'true')\n }\n if (projectOptions.project) {\n searchParams.set('project', projectOptions.project)\n }\n }\n\n /**\n * Deletes a history object form the store.\n *\n * @param key The key returned by the store when created the history. Also available via the\n * `key` property on the history object.\n * @param request Optional request options.\n */\n async delete(key: string, request: SdkOptions = {}): Promise<void> {\n const { token } = request\n const path = RouteBuilder.historyItem(key)\n const url = this.sdk.getUrl(path)\n\n const result = await this.sdk.http.delete(url.toString(), { token })\n this.inspectCommonStatusCodes(result)\n const E_PREFIX = 'Unable to delete history. '\n if (result.status !== 204) {\n this.logInvalidResponse(result)\n throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body)\n }\n }\n\n /**\n * Deletes history in a bulk operation.\n * @param keys The list of keys of history objects to delete.\n * @param request Optional request options.\n * @returns The list of delete records.\n */\n async deleteBulk(keys: string[], request: SdkOptions = {}): Promise<IBulkOperationResult<ContextDeleteRecord>> {\n const { token } = request\n const path = RouteBuilder.historyBatchDelete()\n const url = this.sdk.getUrl(path)\n const result = await this.sdk.http.post(url.toString(), { token, body: JSON.stringify(keys) })\n this.inspectCommonStatusCodes(result)\n const E_PREFIX = 'Unable to delete history. '\n if (result.status !== 200) {\n this.logInvalidResponse(result)\n throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body)\n }\n if (!result.body) {\n throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status })\n }\n\n let data: IBulkOperationResult<ContextDeleteRecord>\n try {\n data = JSON.parse(result.body)\n } catch {\n throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status })\n }\n if (!Array.isArray(data.items)) {\n throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status })\n }\n return data\n }\n\n /**\n * Reads a history definition from the store.\n * @param key The history key\n * @param request Optional request options.\n * @returns The history object\n */\n async read(key: string, request: SdkOptions = {}): Promise<IHttpHistory> {\n const { token } = request\n const url = this.sdk.getUrl(RouteBuilder.historyItem(key))\n const result = await this.sdk.http.get(url.toString(), { token })\n this.inspectCommonStatusCodes(result)\n const E_PREFIX = 'Unable to read a history. '\n if (result.status !== 200) {\n this.logInvalidResponse(result)\n throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body)\n }\n if (!result.body) {\n throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status })\n }\n let data: IHttpHistory\n try {\n data = JSON.parse(result.body)\n } catch {\n throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status })\n }\n if (data.kind !== HttpHistoryKind) {\n throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status })\n }\n return data\n }\n\n async clearOrganization(organizationKey: string, request: SdkOptions = {}): Promise<void> {\n const { token } = request\n const url = this.sdk.getUrl(RouteBuilder.historyClear('organization', organizationKey))\n const result = await this.sdk.http.delete(url.toString(), { token })\n this.inspectCommonStatusCodes(result)\n const E_PREFIX = 'Unable to clear history for the organization. '\n if (result.status !== 204) {\n this.logInvalidResponse(result)\n throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body)\n }\n }\n\n async clearProject(organizationKey: string, projectKey: string, request: SdkOptions = {}): Promise<void> {\n const { token } = request\n const url = this.sdk.getUrl(RouteBuilder.historyClear('project', organizationKey, projectKey))\n const result = await this.sdk.http.delete(url.toString(), { token })\n this.inspectCommonStatusCodes(result)\n const E_PREFIX = 'Unable to clear history for the project. '\n if (result.status !== 204) {\n this.logInvalidResponse(result)\n throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body)\n }\n }\n\n async clearRequest(\n organizationKey: string,\n projectKey: string,\n requestKey: string,\n request: SdkOptions = {}\n ): Promise<void> {\n const { token } = request\n const url = this.sdk.getUrl(RouteBuilder.historyClear('request', organizationKey, projectKey, requestKey))\n const result = await this.sdk.http.delete(url.toString(), { token })\n this.inspectCommonStatusCodes(result)\n const E_PREFIX = 'Unable to clear history for the request. '\n if (result.status !== 204) {\n this.logInvalidResponse(result)\n throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body)\n }\n }\n}\n"]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { SdkBase, SdkOptions } from './SdkBase.js';
|
|
2
|
-
import type { ContextListResult } from '../../events/BaseEvents.js';
|
|
2
|
+
import type { ContextListOptions, ContextListResult } from '../../events/BaseEvents.js';
|
|
3
3
|
import type { IOrganization, UserOrganizationGrantType } from '../../models/store/Organization.js';
|
|
4
4
|
import type { InvitationSchema } from '../../models/store/Invitation.js';
|
|
5
5
|
import type { PatchInfo } from '../../patch/types.js';
|
|
6
|
+
import type { IUser } from '../../models/store/User.js';
|
|
6
7
|
export declare class OrganizationsSdk extends SdkBase {
|
|
7
8
|
/**
|
|
8
9
|
* Lists all user organizations.
|
|
@@ -63,5 +64,23 @@ export declare class OrganizationsSdk extends SdkBase {
|
|
|
63
64
|
* @returns A promise that resolves to the patched invitation.
|
|
64
65
|
*/
|
|
65
66
|
patchInvitation(oid: string, id: string, info: PatchInfo, request?: SdkOptions): Promise<InvitationSchema>;
|
|
67
|
+
/**
|
|
68
|
+
* Lists users in the organization.
|
|
69
|
+
*
|
|
70
|
+
* @param oid The key of the organization we want to read the user from.
|
|
71
|
+
* @param options Optional query options.
|
|
72
|
+
* @param request Optional request options.
|
|
73
|
+
*/
|
|
74
|
+
listUsers(oid: string, options?: ContextListOptions, request?: SdkOptions): Promise<ContextListResult<IUser>>;
|
|
75
|
+
/**
|
|
76
|
+
* Gets a user by its key in the organization.
|
|
77
|
+
*
|
|
78
|
+
* @param oid The key of the organization parent organization.
|
|
79
|
+
* @param key The user key.
|
|
80
|
+
* @param request Optional request options.
|
|
81
|
+
* @returns The user object
|
|
82
|
+
* @deprecated Use `organizations.readUser()` instead.
|
|
83
|
+
*/
|
|
84
|
+
getUser(oid: string, key: string, request?: SdkOptions): Promise<IUser>;
|
|
66
85
|
}
|
|
67
86
|
//# sourceMappingURL=OrganizationsSdk.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrganizationsSdk.d.ts","sourceRoot":"","sources":["../../../../src/runtime/store/OrganizationsSdk.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAKP,UAAU,EACX,MAAM,cAAc,CAAA;AAErB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"OrganizationsSdk.d.ts","sourceRoot":"","sources":["../../../../src/runtime/store/OrganizationsSdk.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAKP,UAAU,EACX,MAAM,cAAc,CAAA;AAErB,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AACvF,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAA;AAClG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAA;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAA;AA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AAE,UAAe,GACvB,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IA0BpC;;;;;;;;OAQG;IACG,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,UAAe,GAAG,OAAO,CAAC,KAAK,CAAC;CAqBlF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SdkBase, E_RESPONSE_STATUS, E_RESPONSE_NO_VALUE, E_INVALID_JSON, E_RESPONSE_UNKNOWN, } from './SdkBase.js';
|
|
2
2
|
import { RouteBuilder } from './RouteBuilder.js';
|
|
3
|
-
import {
|
|
3
|
+
import { Exception } from '../../exceptions/exception.js';
|
|
4
4
|
export class OrganizationsSdk extends SdkBase {
|
|
5
5
|
/**
|
|
6
6
|
* Lists all user organizations.
|
|
@@ -13,25 +13,20 @@ export class OrganizationsSdk extends SdkBase {
|
|
|
13
13
|
const E_PREFIX = 'Unable to list your organizations. ';
|
|
14
14
|
if (result.status !== 200) {
|
|
15
15
|
this.logInvalidResponse(result);
|
|
16
|
-
|
|
17
|
-
if (!e) {
|
|
18
|
-
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
19
|
-
e.response = result.body;
|
|
20
|
-
}
|
|
21
|
-
throw e;
|
|
16
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
22
17
|
}
|
|
23
18
|
if (!result.body) {
|
|
24
|
-
throw new
|
|
19
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status });
|
|
25
20
|
}
|
|
26
21
|
let data;
|
|
27
22
|
try {
|
|
28
23
|
data = JSON.parse(result.body);
|
|
29
24
|
}
|
|
30
25
|
catch {
|
|
31
|
-
throw new
|
|
26
|
+
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status });
|
|
32
27
|
}
|
|
33
28
|
if (!Array.isArray(data.items)) {
|
|
34
|
-
throw new
|
|
29
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status });
|
|
35
30
|
}
|
|
36
31
|
return data;
|
|
37
32
|
}
|
|
@@ -51,20 +46,21 @@ export class OrganizationsSdk extends SdkBase {
|
|
|
51
46
|
this.inspectCommonStatusCodes(result);
|
|
52
47
|
const E_PREFIX = 'Unable to create an organization. ';
|
|
53
48
|
if (result.status !== 200) {
|
|
54
|
-
|
|
49
|
+
this.logInvalidResponse(result);
|
|
50
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
55
51
|
}
|
|
56
52
|
if (!result.body) {
|
|
57
|
-
throw new
|
|
53
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status });
|
|
58
54
|
}
|
|
59
55
|
let data;
|
|
60
56
|
try {
|
|
61
57
|
data = JSON.parse(result.body);
|
|
62
58
|
}
|
|
63
59
|
catch {
|
|
64
|
-
throw new
|
|
60
|
+
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status });
|
|
65
61
|
}
|
|
66
62
|
if (!data.kind) {
|
|
67
|
-
throw new
|
|
63
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status });
|
|
68
64
|
}
|
|
69
65
|
return data;
|
|
70
66
|
}
|
|
@@ -82,25 +78,20 @@ export class OrganizationsSdk extends SdkBase {
|
|
|
82
78
|
const E_PREFIX = 'Unable to list organization invitations. ';
|
|
83
79
|
if (result.status !== 200) {
|
|
84
80
|
this.logInvalidResponse(result);
|
|
85
|
-
|
|
86
|
-
if (!e) {
|
|
87
|
-
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
88
|
-
e.response = result.body;
|
|
89
|
-
}
|
|
90
|
-
throw e;
|
|
81
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
91
82
|
}
|
|
92
83
|
if (!result.body) {
|
|
93
|
-
throw new
|
|
84
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status });
|
|
94
85
|
}
|
|
95
86
|
let data;
|
|
96
87
|
try {
|
|
97
88
|
data = JSON.parse(result.body);
|
|
98
89
|
}
|
|
99
90
|
catch {
|
|
100
|
-
throw new
|
|
91
|
+
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status });
|
|
101
92
|
}
|
|
102
93
|
if (!Array.isArray(data.items)) {
|
|
103
|
-
throw new
|
|
94
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status });
|
|
104
95
|
}
|
|
105
96
|
return data;
|
|
106
97
|
}
|
|
@@ -130,20 +121,21 @@ export class OrganizationsSdk extends SdkBase {
|
|
|
130
121
|
this.inspectCommonStatusCodes(result);
|
|
131
122
|
const E_PREFIX = 'Unable to create an invitation. ';
|
|
132
123
|
if (result.status !== 200) {
|
|
133
|
-
|
|
124
|
+
this.logInvalidResponse(result);
|
|
125
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
134
126
|
}
|
|
135
127
|
if (!result.body) {
|
|
136
|
-
throw new
|
|
128
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status });
|
|
137
129
|
}
|
|
138
130
|
let data;
|
|
139
131
|
try {
|
|
140
132
|
data = JSON.parse(result.body);
|
|
141
133
|
}
|
|
142
134
|
catch {
|
|
143
|
-
throw new
|
|
135
|
+
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status });
|
|
144
136
|
}
|
|
145
137
|
if (!data.kind) {
|
|
146
|
-
throw new
|
|
138
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status });
|
|
147
139
|
}
|
|
148
140
|
return data;
|
|
149
141
|
}
|
|
@@ -161,20 +153,21 @@ export class OrganizationsSdk extends SdkBase {
|
|
|
161
153
|
this.inspectCommonStatusCodes(result);
|
|
162
154
|
const E_PREFIX = 'Unable to find invitation by token. ';
|
|
163
155
|
if (result.status !== 200) {
|
|
164
|
-
|
|
156
|
+
this.logInvalidResponse(result);
|
|
157
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
165
158
|
}
|
|
166
159
|
if (!result.body) {
|
|
167
|
-
throw new
|
|
160
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status });
|
|
168
161
|
}
|
|
169
162
|
let data;
|
|
170
163
|
try {
|
|
171
164
|
data = JSON.parse(result.body);
|
|
172
165
|
}
|
|
173
166
|
catch {
|
|
174
|
-
throw new
|
|
167
|
+
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status });
|
|
175
168
|
}
|
|
176
169
|
if (!data.kind) {
|
|
177
|
-
throw new
|
|
170
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status });
|
|
178
171
|
}
|
|
179
172
|
return data;
|
|
180
173
|
}
|
|
@@ -191,20 +184,21 @@ export class OrganizationsSdk extends SdkBase {
|
|
|
191
184
|
this.inspectCommonStatusCodes(result);
|
|
192
185
|
const E_PREFIX = 'Unable to decline invitation. ';
|
|
193
186
|
if (result.status !== 200) {
|
|
194
|
-
|
|
187
|
+
this.logInvalidResponse(result);
|
|
188
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
195
189
|
}
|
|
196
190
|
if (!result.body) {
|
|
197
|
-
throw new
|
|
191
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status });
|
|
198
192
|
}
|
|
199
193
|
let data;
|
|
200
194
|
try {
|
|
201
195
|
data = JSON.parse(result.body);
|
|
202
196
|
}
|
|
203
197
|
catch {
|
|
204
|
-
throw new
|
|
198
|
+
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status });
|
|
205
199
|
}
|
|
206
200
|
if (!data.kind) {
|
|
207
|
-
throw new
|
|
201
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status });
|
|
208
202
|
}
|
|
209
203
|
return data;
|
|
210
204
|
}
|
|
@@ -221,20 +215,21 @@ export class OrganizationsSdk extends SdkBase {
|
|
|
221
215
|
this.inspectCommonStatusCodes(result);
|
|
222
216
|
const E_PREFIX = 'Unable to delete invitation. ';
|
|
223
217
|
if (result.status !== 200) {
|
|
224
|
-
|
|
218
|
+
this.logInvalidResponse(result);
|
|
219
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
225
220
|
}
|
|
226
221
|
if (!result.body) {
|
|
227
|
-
throw new
|
|
222
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status });
|
|
228
223
|
}
|
|
229
224
|
let data;
|
|
230
225
|
try {
|
|
231
226
|
data = JSON.parse(result.body);
|
|
232
227
|
}
|
|
233
228
|
catch {
|
|
234
|
-
throw new
|
|
229
|
+
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status });
|
|
235
230
|
}
|
|
236
231
|
if (!data.kind) {
|
|
237
|
-
throw new
|
|
232
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status });
|
|
238
233
|
}
|
|
239
234
|
return data;
|
|
240
235
|
}
|
|
@@ -262,20 +257,85 @@ export class OrganizationsSdk extends SdkBase {
|
|
|
262
257
|
this.inspectCommonStatusCodes(result);
|
|
263
258
|
const E_PREFIX = 'Unable to update invitation. ';
|
|
264
259
|
if (result.status !== 200) {
|
|
265
|
-
|
|
260
|
+
this.logInvalidResponse(result);
|
|
261
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
266
262
|
}
|
|
267
263
|
if (!result.body) {
|
|
268
|
-
throw new
|
|
264
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status });
|
|
269
265
|
}
|
|
270
266
|
let data;
|
|
271
267
|
try {
|
|
272
268
|
data = JSON.parse(result.body);
|
|
273
269
|
}
|
|
274
270
|
catch {
|
|
275
|
-
throw new
|
|
271
|
+
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status });
|
|
276
272
|
}
|
|
277
273
|
if (!data.kind) {
|
|
278
|
-
throw new
|
|
274
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status });
|
|
275
|
+
}
|
|
276
|
+
return data;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Lists users in the organization.
|
|
280
|
+
*
|
|
281
|
+
* @param oid The key of the organization we want to read the user from.
|
|
282
|
+
* @param options Optional query options.
|
|
283
|
+
* @param request Optional request options.
|
|
284
|
+
*/
|
|
285
|
+
async listUsers(oid, options, request = {}) {
|
|
286
|
+
const { token } = request;
|
|
287
|
+
const url = this.sdk.getUrl(RouteBuilder.organizationUsers(oid));
|
|
288
|
+
this.sdk.appendListOptions(url, options);
|
|
289
|
+
const result = await this.sdk.http.get(url.toString(), { token });
|
|
290
|
+
this.inspectCommonStatusCodes(result);
|
|
291
|
+
const E_PREFIX = 'Unable to list projects. ';
|
|
292
|
+
if (result.status !== 200) {
|
|
293
|
+
this.logInvalidResponse(result);
|
|
294
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
295
|
+
}
|
|
296
|
+
if (!result.body) {
|
|
297
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status });
|
|
298
|
+
}
|
|
299
|
+
let data;
|
|
300
|
+
try {
|
|
301
|
+
data = JSON.parse(result.body);
|
|
302
|
+
}
|
|
303
|
+
catch {
|
|
304
|
+
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status });
|
|
305
|
+
}
|
|
306
|
+
if (!Array.isArray(data.items)) {
|
|
307
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status });
|
|
308
|
+
}
|
|
309
|
+
return data;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Gets a user by its key in the organization.
|
|
313
|
+
*
|
|
314
|
+
* @param oid The key of the organization parent organization.
|
|
315
|
+
* @param key The user key.
|
|
316
|
+
* @param request Optional request options.
|
|
317
|
+
* @returns The user object
|
|
318
|
+
* @deprecated Use `organizations.readUser()` instead.
|
|
319
|
+
*/
|
|
320
|
+
async getUser(oid, key, request = {}) {
|
|
321
|
+
const { token } = request;
|
|
322
|
+
const url = this.sdk.getUrl(RouteBuilder.organizationUser(oid, key));
|
|
323
|
+
const result = await this.sdk.http.get(url.toString(), { token });
|
|
324
|
+
this.inspectCommonStatusCodes(result);
|
|
325
|
+
const E_PREFIX = 'Unable to read the user info. ';
|
|
326
|
+
if (result.status !== 200) {
|
|
327
|
+
this.logInvalidResponse(result);
|
|
328
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
329
|
+
}
|
|
330
|
+
if (!result.body) {
|
|
331
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status });
|
|
332
|
+
}
|
|
333
|
+
let data;
|
|
334
|
+
try {
|
|
335
|
+
data = JSON.parse(result.body);
|
|
336
|
+
}
|
|
337
|
+
catch {
|
|
338
|
+
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status });
|
|
279
339
|
}
|
|
280
340
|
return data;
|
|
281
341
|
}
|