@api-client/core 0.5.4 → 0.5.7
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 +1 -0
- package/build/browser.js +1 -0
- package/build/browser.js.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.js +1 -0
- 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 +1 -1
- package/build/src/models/Project.js +2 -2
- package/build/src/models/Project.js.map +1 -1
- package/build/src/models/RevisionInfo.d.ts +2 -2
- package/build/src/models/SerializableError.d.ts +1 -0
- package/build/src/models/SerializableError.js.map +1 -1
- 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 +43 -27
- package/build/src/runtime/store/FilesSdk.js +102 -54
- package/build/src/runtime/store/FilesSdk.js.map +1 -1
- 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/Sdk.d.ts +4 -0
- package/build/src/runtime/store/Sdk.js +4 -0
- 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 +21 -7
- package/build/src/runtime/store/SharedSdk.js.map +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 +3 -4
- package/src/models/Backend.ts +7 -9
- package/src/models/HttpHistory.ts +2 -2
- package/src/models/Project.ts +2 -2
- package/src/models/RevisionInfo.ts +2 -2
- package/src/models/SerializableError.ts +1 -0
- package/src/runtime/store/Errors.ts +100 -0
- package/src/runtime/store/FilesSdk.ts +120 -65
- package/src/runtime/store/HistorySdk.ts +42 -17
- package/src/runtime/store/Sdk.ts +5 -0
- package/src/runtime/store/SdkBase.ts +63 -9
- package/src/runtime/store/SharedSdk.ts +26 -9
- package/src/runtime/store/StoreSdkWeb.ts +1 -1
- package/src/runtime/store/UsersSdk.ts +14 -8
- package/json8-patch.d.ts +0 -270
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SdkBase.js","sourceRoot":"","sources":["../../../../src/runtime/store/SdkBase.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SdkBase.js","sourceRoot":"","sources":["../../../../src/runtime/store/SdkBase.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAa,MAAM,aAAa,CAAC;AAmClD,MAAM,CAAC,MAAM,cAAc,GAAG,mCAAmC,CAAC;AAClE,MAAM,CAAC,MAAM,mBAAmB,GAAG,4BAA4B,CAAC;AAChE,MAAM,CAAC,MAAM,iBAAiB,GAAG,2BAA2B,CAAC;AAC7D,MAAM,CAAC,MAAM,kBAAkB,GAAG,kCAAkC,CAAC;AACrE,MAAM,CAAC,MAAM,mBAAmB,GAAG,wCAAwC,CAAC;AAG5E,MAAM,OAAO,OAAO;IACC;IAAnB,YAAmB,GAAQ;QAAR,QAAG,GAAH,GAAG,CAAK;IAAG,CAAC;IAErB,kBAAkB,CAAC,QAAwB;QACnD,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE;YACnB,OAAO;SACR;QACD,IAAI,QAAQ,CAAC,IAAI,EAAE;YACjB,IAAI;gBACF,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;gBACvC,IAAI,IAAI,CAAC,OAAO,EAAE;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AAC,CAAC;SACzB;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,SAAS,CAAC;SAClB;QACD,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,OAAO,EAAE;YAC9B,OAAO,IAAiB,CAAC;SAC1B;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAES,qBAAqB,CAAC,IAAa;QAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAC1C,IAAI,CAAC,IAAI,EAAE;YACT,OAAO,SAAS,CAAC;SAClB;QACD,MAAM,CAAC,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAChD,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QACvB,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAC;QAClB,OAAO,CAAC,CAAC;IACX,CAAC;CACF"}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import { SdkBase } from './SdkBase.js';
|
|
1
|
+
import { SdkBase, ISdkRequestOptions } from './SdkBase.js';
|
|
2
2
|
import { IListOptions, IListResponse } from '../../models/Backend.js';
|
|
3
|
+
import { Kind as ProjectKind } from '../../models/Project.js';
|
|
4
|
+
import { Kind as WorkspaceKind } from '../../models/Workspace.js';
|
|
5
|
+
import { IFile } from '../../models/store/File.js';
|
|
3
6
|
export declare class SharedSdk extends SdkBase {
|
|
4
7
|
/**
|
|
5
8
|
* Lists shared with the user spaces.
|
|
9
|
+
*
|
|
10
|
+
* @param kinds the list of kinds to list. Spaces are always included.
|
|
6
11
|
* @param options Optional query options.
|
|
12
|
+
* @param request Optional request options.
|
|
7
13
|
*/
|
|
8
|
-
list(options?: IListOptions): Promise<IListResponse
|
|
14
|
+
list(kinds: (typeof ProjectKind | typeof WorkspaceKind)[], options?: IListOptions, request?: ISdkRequestOptions): Promise<IListResponse<IFile>>;
|
|
9
15
|
}
|
|
@@ -1,33 +1,47 @@
|
|
|
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 { SdkError } from './Errors.js';
|
|
3
4
|
export class SharedSdk extends SdkBase {
|
|
4
5
|
/**
|
|
5
6
|
* Lists shared with the user spaces.
|
|
7
|
+
*
|
|
8
|
+
* @param kinds the list of kinds to list. Spaces are always included.
|
|
6
9
|
* @param options Optional query options.
|
|
10
|
+
* @param request Optional request options.
|
|
7
11
|
*/
|
|
8
|
-
async list(options) {
|
|
9
|
-
const
|
|
12
|
+
async list(kinds, options, request = {}) {
|
|
13
|
+
const token = request.token || this.sdk.token;
|
|
10
14
|
const url = this.sdk.getUrl(RouteBuilder.shared());
|
|
11
15
|
this.sdk.appendListOptions(url, options);
|
|
16
|
+
kinds.forEach(k => url.searchParams.append('kind', k));
|
|
12
17
|
const result = await this.sdk.http.get(url.toString(), { token });
|
|
13
|
-
this.inspectCommonStatusCodes(result.status);
|
|
18
|
+
this.inspectCommonStatusCodes(result.status, result.body);
|
|
14
19
|
const E_PREFIX = 'Unable to list spaces. ';
|
|
15
20
|
if (result.status !== 200) {
|
|
16
21
|
this.logInvalidResponse(result);
|
|
17
|
-
|
|
22
|
+
let e = this.createGenericSdkError(result.body);
|
|
23
|
+
if (!e) {
|
|
24
|
+
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
25
|
+
e.response = result.body;
|
|
26
|
+
}
|
|
27
|
+
throw e;
|
|
18
28
|
}
|
|
19
29
|
if (!result.body) {
|
|
20
|
-
throw new
|
|
30
|
+
throw new SdkError(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, 0);
|
|
21
31
|
}
|
|
22
32
|
let data;
|
|
23
33
|
try {
|
|
24
34
|
data = JSON.parse(result.body);
|
|
25
35
|
}
|
|
26
36
|
catch (e) {
|
|
27
|
-
|
|
37
|
+
const err = new SdkError(`${E_PREFIX}${E_INVALID_JSON}.`, 0);
|
|
38
|
+
err.response = result.body;
|
|
39
|
+
throw err;
|
|
28
40
|
}
|
|
29
41
|
if (!Array.isArray(data.data)) {
|
|
30
|
-
|
|
42
|
+
const err = new SdkError(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`, 0);
|
|
43
|
+
err.response = result.body;
|
|
44
|
+
throw err;
|
|
31
45
|
}
|
|
32
46
|
return data;
|
|
33
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SharedSdk.js","sourceRoot":"","sources":["../../../../src/runtime/store/SharedSdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,cAAc,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"SharedSdk.js","sourceRoot":"","sources":["../../../../src/runtime/store/SharedSdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,cAAc,EAAE,kBAAkB,EAAsB,MAAM,cAAc,CAAC;AACvI,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAKjD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,OAAO,SAAU,SAAQ,OAAO;IACpC;;;;;;OAMG;IACH,KAAK,CAAC,IAAI,CAAC,KAAoD,EAAE,OAAsB,EAAE,UAA8B,EAAE;QACvH,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;QAC9C,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,KAAK,CAAC,OAAO,CAAC,CAAC,CA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GAAG,CAAC;SACX;QACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YAC7B,MAAM,GAAG,GAAG,IAAI,QAAQ,CAAC,GAAG,QAAQ,GAAG,kBAAkB,GAAG,EAAE,CAAC,CAAC,CAAC;YACjE,GAAG,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC;YAC3B,MAAM,GAAG,CAAC;SACX;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -2,7 +2,7 @@ import { Sdk } from './Sdk.js';
|
|
|
2
2
|
import { Http } from './Http.js';
|
|
3
3
|
import { WsClient } from './WsClient.js';
|
|
4
4
|
export { IStoreTokenInfo, IStoreResponse, IStoreRequestOptions } from './SdkBase.js';
|
|
5
|
-
export { IFileCreateOptions
|
|
5
|
+
export { IFileCreateOptions } from './FilesSdk.js';
|
|
6
6
|
/**
|
|
7
7
|
* NodeJS API for API Client's net-store module.
|
|
8
8
|
*/
|
|
@@ -1,18 +1,24 @@
|
|
|
1
|
-
import { SdkBase } from './SdkBase.js';
|
|
1
|
+
import { SdkBase, ISdkRequestOptions } from './SdkBase.js';
|
|
2
2
|
import { IListOptions, IListResponse } from '../../models/Backend.js';
|
|
3
3
|
import { IUser } from '../../models/store/User.js';
|
|
4
4
|
export declare class UsersSdk extends SdkBase {
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Reads the current user.
|
|
7
|
+
* @param request Optional request options.
|
|
8
|
+
*/
|
|
9
|
+
me(request?: ISdkRequestOptions): Promise<IUser>;
|
|
6
10
|
/**
|
|
7
11
|
* Lists users in the store
|
|
8
12
|
*
|
|
9
13
|
* @param options Optional query options.
|
|
14
|
+
* @param request Optional request options.
|
|
10
15
|
*/
|
|
11
|
-
list(options?: IListOptions): Promise<IListResponse
|
|
16
|
+
list(options?: IListOptions, request?: ISdkRequestOptions): Promise<IListResponse<IUser>>;
|
|
12
17
|
/**
|
|
13
18
|
* Reads a user information from the store.
|
|
14
19
|
* @param key The user key.
|
|
20
|
+
* @param request Optional request options.
|
|
15
21
|
* @returns The user object
|
|
16
22
|
*/
|
|
17
|
-
read(key: string): Promise<IUser>;
|
|
23
|
+
read(key: string, request?: ISdkRequestOptions): Promise<IUser>;
|
|
18
24
|
}
|
|
@@ -1,8 +1,12 @@
|
|
|
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
|
export class UsersSdk extends SdkBase {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Reads the current user.
|
|
6
|
+
* @param request Optional request options.
|
|
7
|
+
*/
|
|
8
|
+
async me(request = {}) {
|
|
9
|
+
const token = request.token || this.sdk.token;
|
|
6
10
|
const url = this.sdk.getUrl(RouteBuilder.usersMe());
|
|
7
11
|
const result = await this.sdk.http.get(url.toString(), { token });
|
|
8
12
|
this.inspectCommonStatusCodes(result.status);
|
|
@@ -30,9 +34,10 @@ export class UsersSdk extends SdkBase {
|
|
|
30
34
|
* Lists users in the store
|
|
31
35
|
*
|
|
32
36
|
* @param options Optional query options.
|
|
37
|
+
* @param request Optional request options.
|
|
33
38
|
*/
|
|
34
|
-
async list(options) {
|
|
35
|
-
const
|
|
39
|
+
async list(options, request = {}) {
|
|
40
|
+
const token = request.token || this.sdk.token;
|
|
36
41
|
const url = this.sdk.getUrl(RouteBuilder.users());
|
|
37
42
|
this.sdk.appendListOptions(url, options);
|
|
38
43
|
const result = await this.sdk.http.get(url.toString(), { token });
|
|
@@ -60,10 +65,11 @@ export class UsersSdk extends SdkBase {
|
|
|
60
65
|
/**
|
|
61
66
|
* Reads a user information from the store.
|
|
62
67
|
* @param key The user key.
|
|
68
|
+
* @param request Optional request options.
|
|
63
69
|
* @returns The user object
|
|
64
70
|
*/
|
|
65
|
-
async read(key) {
|
|
66
|
-
const
|
|
71
|
+
async read(key, request = {}) {
|
|
72
|
+
const token = request.token || this.sdk.token;
|
|
67
73
|
const url = this.sdk.getUrl(RouteBuilder.user(key));
|
|
68
74
|
const result = await this.sdk.http.get(url.toString(), { token });
|
|
69
75
|
this.inspectCommonStatusCodes(result.status);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UsersSdk.js","sourceRoot":"","sources":["../../../../src/runtime/store/UsersSdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,cAAc,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"UsersSdk.js","sourceRoot":"","sources":["../../../../src/runtime/store/UsersSdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,cAAc,EAAE,kBAAkB,EAAsB,MAAM,cAAc,CAAC;AACvI,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAIjD,MAAM,OAAO,QAAS,SAAQ,OAAO;IACnC;;;OAGG;IACH,KAAK,CAAC,EAAE,CAAC,UAA8B,EAAE;QACvC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;QAC9C,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC,CAAC;QACpD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAClE,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC7C,MAAM,QAAQ,GAAG,yBAAyB,CAAC;QAC3C,IAAI,MAAM,CAAC,MAAM,KAAK,GAAG,EAAE;YACzB,IAAI,CAAC,kBAAkB,CAAC,M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G,EAAE;YACzB,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,GAAG,QAAQ,GAAG,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;SACpE;QACD,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,GAAG,QAAQ,GAAG,mBAAmB,EAAE,CAAC,CAAC;SACtD;QACD,IAAI,IAAW,CAAC;QAChB,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,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@api-client/core",
|
|
3
3
|
"description": "The API Client's core client library. Works in NodeJS and in a ES enabled browser.",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.7",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "build/index.js",
|
|
7
7
|
"module": "build/index.js",
|
|
@@ -31,13 +31,12 @@
|
|
|
31
31
|
"@types/cors": "^2.8.12",
|
|
32
32
|
"@types/express-ntlm": "^2.3.3",
|
|
33
33
|
"@types/fs-extra": "^9.0.13",
|
|
34
|
-
"@types/json8-patch": "^1.0.0",
|
|
35
34
|
"@types/mocha": "^9.0.0",
|
|
36
35
|
"@types/node": "^17.0.18",
|
|
37
36
|
"@types/sinon": "^10.0.11",
|
|
38
37
|
"@typescript-eslint/eslint-plugin": "^5.12.0",
|
|
39
38
|
"@typescript-eslint/parser": "^5.12.0",
|
|
40
|
-
"@web/dev-server-esbuild": "^0.
|
|
39
|
+
"@web/dev-server-esbuild": "^0.3.0",
|
|
41
40
|
"@web/test-runner": "^0.13.21",
|
|
42
41
|
"@web/test-runner-playwright": "^0.8.8",
|
|
43
42
|
"chai": "^4.3.4",
|
|
@@ -83,13 +82,13 @@
|
|
|
83
82
|
]
|
|
84
83
|
},
|
|
85
84
|
"dependencies": {
|
|
85
|
+
"@api-client/json": "^0.1.0",
|
|
86
86
|
"@metrichor/jmespath": "^0.3.1",
|
|
87
87
|
"@pawel-up/data-mock": "^0.2.0",
|
|
88
88
|
"@pawel-up/jexl": "^3.0.0",
|
|
89
89
|
"@xmldom/xmldom": "^0.8.1",
|
|
90
90
|
"console-table-printer": "^2.10.0",
|
|
91
91
|
"form-data": "^4.0.0",
|
|
92
|
-
"json8-patch": "^1.0.6",
|
|
93
92
|
"ws": "^8.5.0",
|
|
94
93
|
"xpath": "^0.0.32"
|
|
95
94
|
},
|
package/src/models/Backend.ts
CHANGED
|
@@ -61,7 +61,7 @@ export interface IBackendEvent extends IBackendMessage {
|
|
|
61
61
|
* Note, `updated` is when the entire object must be revalidated in the opposite
|
|
62
62
|
* to `patch` where the patch should be applied to the object.
|
|
63
63
|
*/
|
|
64
|
-
operation: 'created' | '
|
|
64
|
+
operation: 'created' | 'patch' | 'deleted' | 'access-granted' | 'access-removed';
|
|
65
65
|
/**
|
|
66
66
|
* The kind of data that has been changed.
|
|
67
67
|
*/
|
|
@@ -70,6 +70,10 @@ export interface IBackendEvent extends IBackendMessage {
|
|
|
70
70
|
* For update events it is the key of the updated object.
|
|
71
71
|
*/
|
|
72
72
|
id?: string;
|
|
73
|
+
/**
|
|
74
|
+
* When relevant, the parent of the changed object.
|
|
75
|
+
*/
|
|
76
|
+
parent?: string;
|
|
73
77
|
}
|
|
74
78
|
|
|
75
79
|
export interface IListResponse<T = unknown> {
|
|
@@ -151,11 +155,6 @@ export interface IHistorySpaceListOptions extends IListOptions {
|
|
|
151
155
|
*/
|
|
152
156
|
export interface IHistoryProjectListOptions extends IListOptions {
|
|
153
157
|
type: 'project';
|
|
154
|
-
/**
|
|
155
|
-
* The id of the space containing the project.
|
|
156
|
-
* The access to the history records for the project is tested against the user space.
|
|
157
|
-
*/
|
|
158
|
-
space: string;
|
|
159
158
|
/**
|
|
160
159
|
* The id of the project.
|
|
161
160
|
*/
|
|
@@ -173,10 +172,9 @@ export interface IHistoryProjectListOptions extends IListOptions {
|
|
|
173
172
|
export interface IHistoryRequestListOptions extends IListOptions {
|
|
174
173
|
type: 'request';
|
|
175
174
|
/**
|
|
176
|
-
* The id of the
|
|
177
|
-
* The access to the history records for the request is tested against the user space.
|
|
175
|
+
* The id of the project that contains the request.
|
|
178
176
|
*/
|
|
179
|
-
|
|
177
|
+
project: string;
|
|
180
178
|
/**
|
|
181
179
|
* The id of the request.
|
|
182
180
|
*/
|
|
@@ -14,11 +14,11 @@ export interface IHttpHistory {
|
|
|
14
14
|
*/
|
|
15
15
|
key?: string;
|
|
16
16
|
/**
|
|
17
|
-
* Optional user space id.
|
|
17
|
+
* Optional user space id. When set the history will become available to all space users.
|
|
18
18
|
*/
|
|
19
19
|
space?: string;
|
|
20
20
|
/**
|
|
21
|
-
* Optional project id.
|
|
21
|
+
* Optional project id. When set the history will become available to all project users.
|
|
22
22
|
*/
|
|
23
23
|
project?: string;
|
|
24
24
|
/**
|
package/src/models/Project.ts
CHANGED
|
@@ -82,7 +82,7 @@ export class Project extends File {
|
|
|
82
82
|
* Note, this throws an error when the environment is not a space.
|
|
83
83
|
*/
|
|
84
84
|
new(init: IProject): void {
|
|
85
|
-
if (!Project.
|
|
85
|
+
if (!Project.isProject(init)) {
|
|
86
86
|
throw new Error(`Not a space.`);
|
|
87
87
|
}
|
|
88
88
|
super.new(init);
|
|
@@ -92,7 +92,7 @@ export class Project extends File {
|
|
|
92
92
|
/**
|
|
93
93
|
* Checks whether the input is a definition of an user space.
|
|
94
94
|
*/
|
|
95
|
-
static
|
|
95
|
+
static isProject(input: unknown): boolean {
|
|
96
96
|
const typed = input as IProject;
|
|
97
97
|
if (!input || typed.kind !== Kind) {
|
|
98
98
|
return false;
|
|
@@ -4,7 +4,7 @@ export const Kind = 'Core#Revision';
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The definition of a patch revision.
|
|
7
|
-
* The revision is created with the
|
|
7
|
+
* The revision is created with the `@api-client/json` library.
|
|
8
8
|
*/
|
|
9
9
|
export interface IRevisionInfo {
|
|
10
10
|
/**
|
|
@@ -33,7 +33,7 @@ export interface IRevisionInfo {
|
|
|
33
33
|
*/
|
|
34
34
|
deleted?: boolean;
|
|
35
35
|
/**
|
|
36
|
-
* The
|
|
36
|
+
* The `@api-client/json` revisions object used to restore the previous state.
|
|
37
37
|
*/
|
|
38
38
|
patch: any[];
|
|
39
39
|
/**
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { SerializableError, ISerializedError } from '../../models/SerializableError.js';
|
|
2
|
+
|
|
3
|
+
export interface IApiError {
|
|
4
|
+
/**
|
|
5
|
+
* Indicates the response is an error.
|
|
6
|
+
*/
|
|
7
|
+
error: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* The same as the status code but returned with the body.
|
|
10
|
+
*/
|
|
11
|
+
code: number;
|
|
12
|
+
/**
|
|
13
|
+
* The human-readable error message
|
|
14
|
+
*/
|
|
15
|
+
message: string;
|
|
16
|
+
/**
|
|
17
|
+
* The detailed message about the error, if any.
|
|
18
|
+
*/
|
|
19
|
+
detail?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class ApiError {
|
|
23
|
+
get name(): string {
|
|
24
|
+
return 'ApiError';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
code: number;
|
|
28
|
+
message: string;
|
|
29
|
+
detail?: string;
|
|
30
|
+
|
|
31
|
+
constructor(message: string, code: number);
|
|
32
|
+
constructor(init: IApiError);
|
|
33
|
+
|
|
34
|
+
constructor(messageOrInit: string | IApiError, code?: number) {
|
|
35
|
+
if (typeof messageOrInit === 'string') {
|
|
36
|
+
if (typeof code === 'number') {
|
|
37
|
+
this.code = code;
|
|
38
|
+
} else {
|
|
39
|
+
this.code = 0;
|
|
40
|
+
}
|
|
41
|
+
this.message = messageOrInit;
|
|
42
|
+
} else {
|
|
43
|
+
this.message = messageOrInit.message;
|
|
44
|
+
this.code = messageOrInit.code;
|
|
45
|
+
if (messageOrInit.detail) {
|
|
46
|
+
this.detail = messageOrInit.detail;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
toJSON(): IApiError {
|
|
52
|
+
const { message, code, detail } = this;
|
|
53
|
+
const result: IApiError = {
|
|
54
|
+
error: true,
|
|
55
|
+
message,
|
|
56
|
+
code,
|
|
57
|
+
};
|
|
58
|
+
if (detail) {
|
|
59
|
+
result.detail = detail;
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
toString(): string {
|
|
65
|
+
return this.message;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface ISdkError extends ISerializedError {
|
|
70
|
+
/**
|
|
71
|
+
* The raw response from the server.
|
|
72
|
+
*/
|
|
73
|
+
response?: string;
|
|
74
|
+
/**
|
|
75
|
+
* Optional detailed message returned by the server.
|
|
76
|
+
*/
|
|
77
|
+
detail?: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export class SdkError extends SerializableError {
|
|
81
|
+
/**
|
|
82
|
+
* The raw response from the server.
|
|
83
|
+
*/
|
|
84
|
+
response?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Optional detailed message returned by the server.
|
|
87
|
+
*/
|
|
88
|
+
detail?: string;
|
|
89
|
+
|
|
90
|
+
toJSON(): ISdkError {
|
|
91
|
+
const result = super.toJSON();
|
|
92
|
+
if (this.response) {
|
|
93
|
+
result.response = this.response;
|
|
94
|
+
}
|
|
95
|
+
if (this.detail) {
|
|
96
|
+
result.detail = this.detail;
|
|
97
|
+
}
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
}
|