@api-client/core 0.12.10 → 0.12.12
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 +0 -1
- 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 +0 -1
- 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/models/store/Backend.d.ts +15 -2
- package/build/src/models/store/Backend.d.ts.map +1 -1
- package/build/src/models/store/Backend.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.map +1 -1
- package/build/src/runtime/store/OrganizationsSdk.js +46 -50
- 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/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.map +1 -1
- package/build/src/runtime/store/UsersSdk.js +12 -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/models/store/Backend.ts +16 -2
- 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 +46 -50
- package/src/runtime/store/RevisionsSdk.ts +5 -10
- 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 +12 -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,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 TrashSdk extends SdkBase {
|
|
5
5
|
/**
|
|
6
6
|
* Lists trashed entires.
|
|
@@ -15,25 +15,20 @@ export class TrashSdk extends SdkBase {
|
|
|
15
15
|
const E_PREFIX = 'Unable to list trash. ';
|
|
16
16
|
if (result.status !== 200) {
|
|
17
17
|
this.logInvalidResponse(result);
|
|
18
|
-
|
|
19
|
-
if (!e) {
|
|
20
|
-
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
21
|
-
e.response = result.body;
|
|
22
|
-
}
|
|
23
|
-
throw e;
|
|
18
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
24
19
|
}
|
|
25
20
|
if (!result.body) {
|
|
26
|
-
throw new
|
|
21
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status });
|
|
27
22
|
}
|
|
28
23
|
let data;
|
|
29
24
|
try {
|
|
30
25
|
data = JSON.parse(result.body);
|
|
31
26
|
}
|
|
32
27
|
catch {
|
|
33
|
-
throw new
|
|
28
|
+
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status });
|
|
34
29
|
}
|
|
35
30
|
if (!Array.isArray(data.items)) {
|
|
36
|
-
throw new
|
|
31
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status });
|
|
37
32
|
}
|
|
38
33
|
return data;
|
|
39
34
|
}
|
|
@@ -53,12 +48,7 @@ export class TrashSdk extends SdkBase {
|
|
|
53
48
|
const E_PREFIX = 'Unable to delete trash. ';
|
|
54
49
|
if (result.status !== 204) {
|
|
55
50
|
this.logInvalidResponse(result);
|
|
56
|
-
|
|
57
|
-
if (!e) {
|
|
58
|
-
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
59
|
-
e.response = result.body;
|
|
60
|
-
}
|
|
61
|
-
throw e;
|
|
51
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
62
52
|
}
|
|
63
53
|
}
|
|
64
54
|
async restore(oid, keys, request = {}) {
|
|
@@ -69,12 +59,7 @@ export class TrashSdk extends SdkBase {
|
|
|
69
59
|
const E_PREFIX = 'Unable to restore from trash. ';
|
|
70
60
|
if (result.status !== 204) {
|
|
71
61
|
this.logInvalidResponse(result);
|
|
72
|
-
|
|
73
|
-
if (!e) {
|
|
74
|
-
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
75
|
-
e.response = result.body;
|
|
76
|
-
}
|
|
77
|
-
throw e;
|
|
62
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
78
63
|
}
|
|
79
64
|
}
|
|
80
65
|
/**
|
|
@@ -89,12 +74,7 @@ export class TrashSdk extends SdkBase {
|
|
|
89
74
|
const E_PREFIX = 'Unable to empty trash. ';
|
|
90
75
|
if (result.status !== 204) {
|
|
91
76
|
this.logInvalidResponse(result);
|
|
92
|
-
|
|
93
|
-
if (!e) {
|
|
94
|
-
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status);
|
|
95
|
-
e.response = result.body;
|
|
96
|
-
}
|
|
97
|
-
throw e;
|
|
77
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
98
78
|
}
|
|
99
79
|
}
|
|
100
80
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TrashSdk.js","sourceRoot":"","sources":["../../../../src/runtime/store/TrashSdk.ts"],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QAC3F,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,KAAK,CAAC,YAAoB,EAAE,UAAsB,EAAE;QACxD,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAA;QACzB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAA;QAClE,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,yBAAyB,CAAA;QAC1C,IAAI,MAAM,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YAC1B,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAA;YAC/B,MAAM,IAAI,CAAC,cAAc,CAAC,GAAG,QAAQ,GAAG,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QAC3F,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 type SdkOptions,\n} from './SdkBase.js'\nimport { RouteBuilder } from './RouteBuilder.js'\nimport type { ContextListOptions, ContextListResult } from '../../events/BaseEvents.js'\nimport type { TrashEntry } from '../../models/TrashEntry.js'\nimport { Exception } from '../../exceptions/exception.js'\n\nexport class TrashSdk extends SdkBase {\n /**\n * Lists trashed entires.\n * @param options The list query options.\n */\n async list(\n oid: string,\n options: ContextListOptions,\n request: SdkOptions = {}\n ): Promise<ContextListResult<TrashEntry>> {\n const { token } = request\n const url = this.sdk.getUrl(RouteBuilder.trash(oid))\n this.sdk.appendListOptions(url, options)\n const result = await this.sdk.http.get(url.toString(), { token })\n this.inspectCommonStatusCodes(result)\n const E_PREFIX = 'Unable to list trash. '\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<TrashEntry>\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 * Permanently deletes a number of files in a batch operation.\n *\n * @param oid The parent organization\n * @param keys The list of trash entry keys to delete.\n * @param request Optional request options.\n */\n async delete(oid: string, keys: string[], request: SdkOptions = {}): Promise<void> {\n const path = RouteBuilder.trashBatchDelete(oid)\n const url = this.sdk.getUrl(path)\n const { token } = request\n const result = await this.sdk.http.delete(url.toString(), { token, body: JSON.stringify({ ids: keys }) })\n this.inspectCommonStatusCodes(result)\n const E_PREFIX = 'Unable to delete trash. '\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 restore(oid: string, keys: string[], request: SdkOptions = {}): Promise<void> {\n const url = this.sdk.getUrl(RouteBuilder.trashBatchRestore(oid))\n const { token } = request\n const result = await this.sdk.http.post(url.toString(), { token, body: JSON.stringify({ ids: keys }) })\n this.inspectCommonStatusCodes(result)\n const E_PREFIX = 'Unable to restore from trash. '\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 * Empties the trash for the user in the given organization.\n * @param organization The organization key to remove trash for.\n */\n async empty(organization: string, request: SdkOptions = {}): Promise<void> {\n const { token } = request\n const url = this.sdk.getUrl(RouteBuilder.trashEmpty(organization))\n const result = await this.sdk.http.delete(url.toString(), { token })\n this.inspectCommonStatusCodes(result)\n const E_PREFIX = 'Unable to empty trash. '\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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UsersSdk.d.ts","sourceRoot":"","sources":["../../../../src/runtime/store/UsersSdk.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAKP,UAAU,EACX,MAAM,cAAc,CAAA;AAErB,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"UsersSdk.d.ts","sourceRoot":"","sources":["../../../../src/runtime/store/UsersSdk.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAKP,UAAU,EACX,MAAM,cAAc,CAAA;AAErB,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAGlF,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,IAAI,EAAE,QAAQ,CAAA;IACd;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAA;IACV;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,cAAc,EAAE,OAAO,CAAA;IACvB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,CAAA;CACZ;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,kBAAkB,GAAG,uBAAuB,CAAA;IACpD;;;OAGG;IACH,IAAI,EAAE,QAAQ,CAAA;CACf;AAED,MAAM,WAAW,6BAA8B,SAAQ,iBAAiB;IACtE,MAAM,EAAE,kBAAkB,CAAA;IAC1B;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAA;CACzB;AAED,MAAM,WAAW,wBAAyB,SAAQ,iBAAiB;IACjE,MAAM,EAAE,uBAAuB,CAAA;IAC/B;;OAEG;IACH,cAAc,EAAE,MAAM,CAAA;IACtB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,qBAAa,QAAS,SAAQ,OAAO;IACnC;;;OAGG;IACG,EAAE,CAAC,OAAO,GAAE,UAAe,GAAG,OAAO,CAAC,KAAK,CAAC;IAyBlD;;;;;;;OAOG;IACG,IAAI,CACR,cAAc,EAAE,MAAM,EACtB,OAAO,CAAC,EAAE,kBAAkB,EAC5B,OAAO,GAAE,UAAe,GACvB,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IA4BpC;;;;;;;;OAQG;IACG,IAAI,CAAC,cAAc,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,UAAe,GAAG,OAAO,CAAC,KAAK,CAAC;CAuB1F"}
|
|
@@ -1,5 +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 { Exception } from '../../exceptions/exception.js';
|
|
3
4
|
export class UsersSdk extends SdkBase {
|
|
4
5
|
/**
|
|
5
6
|
* Reads the current user.
|
|
@@ -13,20 +14,20 @@ export class UsersSdk extends SdkBase {
|
|
|
13
14
|
const E_PREFIX = 'Unable to read a user. ';
|
|
14
15
|
if (result.status !== 200) {
|
|
15
16
|
this.logInvalidResponse(result);
|
|
16
|
-
throw
|
|
17
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
17
18
|
}
|
|
18
19
|
if (!result.body) {
|
|
19
|
-
throw new
|
|
20
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status });
|
|
20
21
|
}
|
|
21
22
|
let data;
|
|
22
23
|
try {
|
|
23
24
|
data = JSON.parse(result.body);
|
|
24
25
|
}
|
|
25
26
|
catch {
|
|
26
|
-
throw new
|
|
27
|
+
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status });
|
|
27
28
|
}
|
|
28
29
|
if (!data.key) {
|
|
29
|
-
throw new
|
|
30
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status });
|
|
30
31
|
}
|
|
31
32
|
return data;
|
|
32
33
|
}
|
|
@@ -49,20 +50,20 @@ export class UsersSdk extends SdkBase {
|
|
|
49
50
|
const E_PREFIX = 'Unable to list projects. ';
|
|
50
51
|
if (result.status !== 200) {
|
|
51
52
|
this.logInvalidResponse(result);
|
|
52
|
-
throw
|
|
53
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
53
54
|
}
|
|
54
55
|
if (!result.body) {
|
|
55
|
-
throw new
|
|
56
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status });
|
|
56
57
|
}
|
|
57
58
|
let data;
|
|
58
59
|
try {
|
|
59
60
|
data = JSON.parse(result.body);
|
|
60
61
|
}
|
|
61
62
|
catch {
|
|
62
|
-
throw new
|
|
63
|
+
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status });
|
|
63
64
|
}
|
|
64
65
|
if (!Array.isArray(data.items)) {
|
|
65
|
-
throw new
|
|
66
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status });
|
|
66
67
|
}
|
|
67
68
|
return data;
|
|
68
69
|
}
|
|
@@ -85,17 +86,17 @@ export class UsersSdk extends SdkBase {
|
|
|
85
86
|
const E_PREFIX = 'Unable to read the user info. ';
|
|
86
87
|
if (result.status !== 200) {
|
|
87
88
|
this.logInvalidResponse(result);
|
|
88
|
-
throw
|
|
89
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
89
90
|
}
|
|
90
91
|
if (!result.body) {
|
|
91
|
-
throw new
|
|
92
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status });
|
|
92
93
|
}
|
|
93
94
|
let data;
|
|
94
95
|
try {
|
|
95
96
|
data = JSON.parse(result.body);
|
|
96
97
|
}
|
|
97
98
|
catch {
|
|
98
|
-
throw new
|
|
99
|
+
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status });
|
|
99
100
|
}
|
|
100
101
|
return data;
|
|
101
102
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UsersSdk.js","sourceRoot":"","sources":["../../../../src/runtime/store/UsersSdk.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;AA0EhD,MAAM,OAAO,QAAS,SAAQ,OAAO;IACnC;;;OAGG;IACH,KAAK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I,CAAA;IACb,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 { IUser } from '../../models/store/User.js'\nimport { ContextListResult, ContextListOptions } from '../../events/BaseEvents.js'\n\nexport interface IJwtInfo {\n /**\n * The information about the user that is read from the JWT.\n */\n data: IJwtUser\n /**\n * The name of the provider.\n */\n provider: string\n}\n\nexport interface IJwtUser {\n /**\n * The provider's unique ID.\n */\n id: string\n /**\n * The user's email address.\n */\n email: string\n /**\n * true, if the provider has verified the email address.\n */\n email_verified: boolean\n /**\n * The user's full name.\n */\n name: string\n /**\n * If present, a URL to user's profile picture\n */\n picture?: string\n given_name?: string\n family_name?: string\n /**\n * If present, the host domain of the user's GSuite email address.\n * Google specific.\n */\n hd?: string\n}\n\nexport interface IRegistrationInfo {\n reason: 'new-organization' | 'existing-organization'\n /**\n * The decoded JWT user information.\n * Used to create a user account.\n */\n user: IJwtInfo\n}\n\nexport interface IOrganizationRegistrationInfo extends IRegistrationInfo {\n reason: 'new-organization'\n /**\n * The name of the organization to create for the user.\n */\n organizationName: string\n}\n\nexport interface IOrganizationAddUserInfo extends IRegistrationInfo {\n reason: 'existing-organization'\n /**\n * Set when adding a user to an existing organization.\n */\n organizationId: string\n /**\n * The invitation code used to invite the user.\n */\n invitation: string\n}\n\nexport class UsersSdk extends SdkBase {\n /**\n * Reads the current user.\n * @param request Optional request options.\n */\n async me(request: SdkOptions = {}): Promise<IUser> {\n const { token } = request\n const url = this.sdk.getUrl(RouteBuilder.usersMe())\n const result = await this.sdk.http.get(url.toString(), { token })\n this.inspectCommonStatusCodes(result)\n const E_PREFIX = 'Unable to read a user. '\n if (result.status !== 200) {\n this.logInvalidResponse(result)\n throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`)\n }\n if (!result.body) {\n throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`)\n }\n let data: IUser\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 * Lists users in the store\n *\n * @param organizationId The key of the organization we want to read the user from.\n * @param options Optional query options.\n * @param request Optional request options.\n * @deprecated Use `organizations.listUsers()` instead.\n */\n async list(\n organizationId: string,\n options?: ContextListOptions,\n request: SdkOptions = {}\n ): Promise<ContextListResult<IUser>> {\n // eslint-disable-next-line no-console\n console.warn('The `users.list` method is deprecated. Use `organizations.listUsers()` instead.')\n const { token } = request\n const url = this.sdk.getUrl(RouteBuilder.users(organizationId))\n this.sdk.appendListOptions(url, options)\n const result = await this.sdk.http.get(url.toString(), { token })\n this.inspectCommonStatusCodes(result)\n const E_PREFIX = 'Unable to list projects. '\n if (result.status !== 200) {\n this.logInvalidResponse(result)\n throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`)\n }\n if (!result.body) {\n throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`)\n }\n let data: ContextListResult<IUser>\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 user information from the store.\n *\n * @param organizationId The key of the organization we want to read the user from.\n * @param key The user key.\n * @param request Optional request options.\n * @returns The user object\n * @deprecated Use `organizations.getUser()` instead.\n */\n async read(organizationId: string, key: string, request: SdkOptions = {}): Promise<IUser> {\n // eslint-disable-next-line no-console\n console.warn('The `users.read` method is deprecated. Use `organizations.getUser()` instead.')\n const { token } = request\n const url = this.sdk.getUrl(RouteBuilder.user(organizationId, key))\n const result = await this.sdk.http.get(url.toString(), { token })\n this.inspectCommonStatusCodes(result)\n const E_PREFIX = 'Unable to read the user info. '\n if (result.status !== 200) {\n this.logInvalidResponse(result)\n throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`)\n }\n if (!result.body) {\n throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`)\n }\n let data: IUser\n try {\n data = JSON.parse(result.body)\n } catch {\n throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`)\n }\n return data\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"UsersSdk.js","sourceRoot":"","sources":["../../../../src/runtime/store/UsersSdk.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;AAGhD,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AAwEzD,MAAM,OAAO,QAAS,SAAQ,OAAO;IACnC;;;OAGG;IACH,KAAK,CAAC,EAAE,CAAC,UAAsB,EAAE;QAC/B,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,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;QACjE,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAA;QACrC,MAAM,QAAQ,GAAG,yBAAyB,CAAA;QAC1C,IAAI,MAAM,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YAC1B,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAA;YAC/B,MAAM,IAAI,CAAC,cAAc,CAAC,GAAG,QAAQ,GAAG,iBAA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,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAA;QACxG,CAAC;QACD,OAAO,IAAI,CAAA;IACb,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 { IUser } from '../../models/store/User.js'\nimport { ContextListResult, ContextListOptions } from '../../events/BaseEvents.js'\nimport { Exception } from '../../exceptions/exception.js'\n\nexport interface IJwtInfo {\n /**\n * The information about the user that is read from the JWT.\n */\n data: IJwtUser\n /**\n * The name of the provider.\n */\n provider: string\n}\n\nexport interface IJwtUser {\n /**\n * The provider's unique ID.\n */\n id: string\n /**\n * The user's email address.\n */\n email: string\n /**\n * true, if the provider has verified the email address.\n */\n email_verified: boolean\n /**\n * The user's full name.\n */\n name: string\n /**\n * If present, a URL to user's profile picture\n */\n picture?: string\n given_name?: string\n family_name?: string\n /**\n * If present, the host domain of the user's GSuite email address.\n * Google specific.\n */\n hd?: string\n}\n\nexport interface IRegistrationInfo {\n reason: 'new-organization' | 'existing-organization'\n /**\n * The decoded JWT user information.\n * Used to create a user account.\n */\n user: IJwtInfo\n}\n\nexport interface IOrganizationRegistrationInfo extends IRegistrationInfo {\n reason: 'new-organization'\n /**\n * The name of the organization to create for the user.\n */\n organizationName: string\n}\n\nexport interface IOrganizationAddUserInfo extends IRegistrationInfo {\n reason: 'existing-organization'\n /**\n * Set when adding a user to an existing organization.\n */\n organizationId: string\n /**\n * The invitation code used to invite the user.\n */\n invitation: string\n}\n\nexport class UsersSdk extends SdkBase {\n /**\n * Reads the current user.\n * @param request Optional request options.\n */\n async me(request: SdkOptions = {}): Promise<IUser> {\n const { token } = request\n const url = this.sdk.getUrl(RouteBuilder.usersMe())\n const result = await this.sdk.http.get(url.toString(), { token })\n this.inspectCommonStatusCodes(result)\n const E_PREFIX = 'Unable to read a user. '\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: IUser\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 * Lists users in the store\n *\n * @param organizationId The key of the organization we want to read the user from.\n * @param options Optional query options.\n * @param request Optional request options.\n * @deprecated Use `organizations.listUsers()` instead.\n */\n async list(\n organizationId: string,\n options?: ContextListOptions,\n request: SdkOptions = {}\n ): Promise<ContextListResult<IUser>> {\n // eslint-disable-next-line no-console\n console.warn('The `users.list` method is deprecated. Use `organizations.listUsers()` instead.')\n const { token } = request\n const url = this.sdk.getUrl(RouteBuilder.users(organizationId))\n this.sdk.appendListOptions(url, options)\n const result = await this.sdk.http.get(url.toString(), { token })\n this.inspectCommonStatusCodes(result)\n const E_PREFIX = 'Unable to list projects. '\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<IUser>\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 user information from the store.\n *\n * @param organizationId The key of the organization we want to read the user from.\n * @param key The user key.\n * @param request Optional request options.\n * @returns The user object\n * @deprecated Use `organizations.getUser()` instead.\n */\n async read(organizationId: string, key: string, request: SdkOptions = {}): Promise<IUser> {\n // eslint-disable-next-line no-console\n console.warn('The `users.read` method is deprecated. Use `organizations.getUser()` instead.')\n const { token } = request\n const url = this.sdk.getUrl(RouteBuilder.user(organizationId, key))\n const result = await this.sdk.http.get(url.toString(), { token })\n this.inspectCommonStatusCodes(result)\n const E_PREFIX = 'Unable to read the user info. '\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: IUser\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 return data\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
export interface ExceptionSchema {
|
|
2
|
+
name: string
|
|
3
|
+
message: string
|
|
4
|
+
status?: number
|
|
5
|
+
code?: string
|
|
6
|
+
help?: string
|
|
7
|
+
stack?: string
|
|
8
|
+
[key: string]: string | number | undefined
|
|
9
|
+
}
|
|
10
|
+
|
|
1
11
|
/**
|
|
2
12
|
* Create a custom error class with the ability to define the error
|
|
3
13
|
* code, status, and the help text.
|
|
@@ -46,7 +56,44 @@ export class Exception extends Error {
|
|
|
46
56
|
*/
|
|
47
57
|
status: number
|
|
48
58
|
|
|
49
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Create a new exception instance.
|
|
61
|
+
* It tries to extract the error code and status from the
|
|
62
|
+
* `init` object. If not found, it uses the default message.
|
|
63
|
+
* @param init - An object containing error details
|
|
64
|
+
* @param defaultMessage - A default message to use if `init.message` is not provided
|
|
65
|
+
* @returns An instance of the Exception class
|
|
66
|
+
* @example
|
|
67
|
+
* ```js
|
|
68
|
+
* const error = Exception.fromApiError({
|
|
69
|
+
* code: 'E_FILE_NOT_FOUND',
|
|
70
|
+
* status: 404,
|
|
71
|
+
* message: 'File not found',
|
|
72
|
+
* help: 'Please check the file path and try again'
|
|
73
|
+
* }, 'An error occurred while processing your request')
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
static fromRawException(init: object, defaultMessage: string): Exception {
|
|
77
|
+
const typed = init as Record<string, string | number>
|
|
78
|
+
const options: ErrorOptions & { code?: string; status?: number } = {}
|
|
79
|
+
if (typed.code) {
|
|
80
|
+
options.code = typed.code as string
|
|
81
|
+
}
|
|
82
|
+
if (typed.status) {
|
|
83
|
+
options.status = Number(typed.status)
|
|
84
|
+
}
|
|
85
|
+
const message = typed.message ?? defaultMessage
|
|
86
|
+
const result = new this(message as string, options)
|
|
87
|
+
if (typed.help) {
|
|
88
|
+
result.setHelp(typed.help as string)
|
|
89
|
+
}
|
|
90
|
+
if (typed.name) {
|
|
91
|
+
result.name = typed.name as string
|
|
92
|
+
}
|
|
93
|
+
return result
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
constructor(message?: string, options?: ErrorOptions & { code?: string; status?: number; help?: string }) {
|
|
50
97
|
super(message, options)
|
|
51
98
|
|
|
52
99
|
const ErrorConstructor = this.constructor as typeof Exception
|
|
@@ -60,7 +107,7 @@ export class Exception extends Error {
|
|
|
60
107
|
this.code = code
|
|
61
108
|
}
|
|
62
109
|
|
|
63
|
-
const help = ErrorConstructor.help
|
|
110
|
+
const help = options?.help || ErrorConstructor.help
|
|
64
111
|
if (help !== undefined) {
|
|
65
112
|
this.help = help
|
|
66
113
|
}
|
|
@@ -94,8 +141,8 @@ export class Exception extends Error {
|
|
|
94
141
|
return `${this.name}: ${this.message}`
|
|
95
142
|
}
|
|
96
143
|
|
|
97
|
-
toJSON() {
|
|
98
|
-
const result:
|
|
144
|
+
toJSON(): ExceptionSchema {
|
|
145
|
+
const result: ExceptionSchema = {
|
|
99
146
|
name: this.name,
|
|
100
147
|
message: this.message,
|
|
101
148
|
}
|
|
@@ -181,7 +181,7 @@ export interface ServerEvent {
|
|
|
181
181
|
}
|
|
182
182
|
|
|
183
183
|
/**
|
|
184
|
-
* A broadcast event dispatched by the server when
|
|
184
|
+
* A broadcast event dispatched by the server when an object was patched.
|
|
185
185
|
*/
|
|
186
186
|
export interface ServerPatchEvent extends ServerEvent {
|
|
187
187
|
/**
|
|
@@ -189,7 +189,7 @@ export interface ServerPatchEvent extends ServerEvent {
|
|
|
189
189
|
*/
|
|
190
190
|
kind: 'patch'
|
|
191
191
|
/**
|
|
192
|
-
* Whether the
|
|
192
|
+
* Whether the object meta data were patched or the media (the content).
|
|
193
193
|
* Note, folders are always meta.
|
|
194
194
|
*/
|
|
195
195
|
type: 'media' | 'meta'
|
|
@@ -202,3 +202,17 @@ export interface ServerPatchEvent extends ServerEvent {
|
|
|
202
202
|
*/
|
|
203
203
|
uid: string
|
|
204
204
|
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* A broadcast event dispatched by the server when an object was deleted.
|
|
208
|
+
*/
|
|
209
|
+
export interface ServerDeleteEvent extends ServerEvent {
|
|
210
|
+
/**
|
|
211
|
+
* Describes this event.
|
|
212
|
+
*/
|
|
213
|
+
kind: 'delete'
|
|
214
|
+
/**
|
|
215
|
+
* The id of the user deleting the object.
|
|
216
|
+
*/
|
|
217
|
+
uid: string
|
|
218
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { IProjectRunnerOptions } from '../runtime/node/InteropInterfaces.js'
|
|
2
2
|
import { Kind as HttpProjectKind, HttpProject, IHttpProject } from '../models/HttpProject.js'
|
|
3
|
-
import { ApiError } from '../runtime/store/Errors.js'
|
|
4
3
|
import { StoreSdk } from '../runtime/store/StoreSdkNode.js'
|
|
5
4
|
import { ProjectSerialRunner } from '../runtime/node/ProjectSerialRunner.js'
|
|
6
5
|
import { ProjectParallelRunner } from '../runtime/node/ProjectParallelRunner.js'
|
|
7
6
|
import Proxy, { IProxyResult } from './Proxy.js'
|
|
8
7
|
import { IProjectExecutionLog } from '../models/ProjectExecution.js'
|
|
8
|
+
import { Exception } from '../exceptions/exception.js'
|
|
9
9
|
|
|
10
10
|
interface ProxyInit {
|
|
11
11
|
kind: typeof HttpProjectKind
|
|
@@ -44,52 +44,48 @@ export default class HttpProjectProxy extends Proxy {
|
|
|
44
44
|
|
|
45
45
|
protected async configureStore(init: IHttpProjectStoreProxyInit, token: string, baseUri: string): Promise<void> {
|
|
46
46
|
const { pid, options, organization } = init
|
|
47
|
+
const INVALID_REQUEST = 'Invalid request'
|
|
48
|
+
const code = 'E_INVALID_REQUEST'
|
|
47
49
|
if (!pid) {
|
|
48
|
-
throw new
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
code: 400,
|
|
50
|
+
throw new Exception(INVALID_REQUEST, {
|
|
51
|
+
help: 'The "pid" parameter is required.',
|
|
52
|
+
status: 400,
|
|
53
|
+
code,
|
|
53
54
|
})
|
|
54
55
|
}
|
|
55
56
|
if (!organization) {
|
|
56
|
-
throw new
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
code: 400,
|
|
57
|
+
throw new Exception(INVALID_REQUEST, {
|
|
58
|
+
help: 'The "organization" parameter is required.',
|
|
59
|
+
status: 400,
|
|
60
|
+
code,
|
|
61
61
|
})
|
|
62
62
|
}
|
|
63
63
|
if (!options) {
|
|
64
|
-
throw new
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
code: 400,
|
|
64
|
+
throw new Exception(INVALID_REQUEST, {
|
|
65
|
+
help: 'The "options" parameter is required.',
|
|
66
|
+
status: 400,
|
|
67
|
+
code,
|
|
69
68
|
})
|
|
70
69
|
}
|
|
71
70
|
if (!token) {
|
|
72
|
-
throw new
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
code: 400,
|
|
71
|
+
throw new Exception(INVALID_REQUEST, {
|
|
72
|
+
help: 'Set the authentication credentials.',
|
|
73
|
+
status: 400,
|
|
74
|
+
code,
|
|
77
75
|
})
|
|
78
76
|
}
|
|
79
77
|
if (!baseUri) {
|
|
80
|
-
throw new
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
code: 400,
|
|
78
|
+
throw new Exception(INVALID_REQUEST, {
|
|
79
|
+
help: 'The store uri is missing.',
|
|
80
|
+
status: 400,
|
|
81
|
+
code,
|
|
85
82
|
})
|
|
86
83
|
}
|
|
87
84
|
if (!baseUri.startsWith('http')) {
|
|
88
|
-
throw new
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
code: 400,
|
|
85
|
+
throw new Exception(INVALID_REQUEST, {
|
|
86
|
+
help: 'The store uri is invalid.',
|
|
87
|
+
status: 400,
|
|
88
|
+
code,
|
|
93
89
|
})
|
|
94
90
|
}
|
|
95
91
|
const sdk = new StoreSdk(baseUri)
|
|
@@ -100,10 +96,10 @@ export default class HttpProjectProxy extends Proxy {
|
|
|
100
96
|
project = data.media as IHttpProject
|
|
101
97
|
} catch (cause) {
|
|
102
98
|
const e = cause as Error
|
|
103
|
-
throw new
|
|
99
|
+
throw new Exception(e.message, { status: 400 })
|
|
104
100
|
}
|
|
105
101
|
if (project.key !== pid) {
|
|
106
|
-
throw new
|
|
102
|
+
throw new Exception(`Unable to read the project.`, { status: 500 })
|
|
107
103
|
}
|
|
108
104
|
this.options = options
|
|
109
105
|
this.project = new HttpProject(project)
|
|
@@ -111,20 +107,20 @@ export default class HttpProjectProxy extends Proxy {
|
|
|
111
107
|
|
|
112
108
|
protected async configureProject(init: IHttpProjectProxyInit): Promise<void> {
|
|
113
109
|
const { project, options } = init
|
|
110
|
+
const INVALID_REQUEST = 'Invalid request'
|
|
111
|
+
const code = 'E_INVALID_REQUEST'
|
|
114
112
|
if (!options) {
|
|
115
|
-
throw new
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
code: 400,
|
|
113
|
+
throw new Exception(INVALID_REQUEST, {
|
|
114
|
+
help: 'The "options" parameter is required.',
|
|
115
|
+
status: 400,
|
|
116
|
+
code,
|
|
120
117
|
})
|
|
121
118
|
}
|
|
122
119
|
if (!project) {
|
|
123
|
-
throw new
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
code: 400,
|
|
120
|
+
throw new Exception(INVALID_REQUEST, {
|
|
121
|
+
help: 'The "project" parameter is required.',
|
|
122
|
+
status: 400,
|
|
123
|
+
code,
|
|
128
124
|
})
|
|
129
125
|
}
|
|
130
126
|
this.options = options
|
|
@@ -3,12 +3,12 @@ import { IRequestAuthorization } from '../models/RequestAuthorization.js'
|
|
|
3
3
|
import { IRequestConfig } from '../models/RequestConfig.js'
|
|
4
4
|
import Proxy, { IProxyResult } from './Proxy.js'
|
|
5
5
|
import { HttpCertificate } from '../models/ClientCertificate.js'
|
|
6
|
-
import { ApiError } from '../runtime/store/Errors.js'
|
|
7
6
|
import { DummyLogger } from '../lib/logging/DummyLogger.js'
|
|
8
7
|
import { HttpRequestRunner } from '../runtime/http-runner/HttpRequestRunner.js'
|
|
9
8
|
import { IRequestLog } from '../models/RequestLog.js'
|
|
10
9
|
import { IHttpFlow } from '../models/http-flows/HttpFlows.js'
|
|
11
10
|
import { IHttpAssertion } from '../models/http-flows/HttpAssertion.js'
|
|
11
|
+
import { Exception } from '../exceptions/exception.js'
|
|
12
12
|
|
|
13
13
|
export interface IRequestProxyInit {
|
|
14
14
|
kind: typeof HttpRequestKind
|
|
@@ -54,20 +54,20 @@ export default class RequestProxy extends Proxy {
|
|
|
54
54
|
|
|
55
55
|
async configure(init: IRequestProxyInit): Promise<void> {
|
|
56
56
|
const { request } = init
|
|
57
|
+
const INVALID_REQUEST = 'Invalid request'
|
|
58
|
+
const code = 'E_INVALID_REQUEST'
|
|
57
59
|
if (!request) {
|
|
58
|
-
throw new
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
code: 400,
|
|
60
|
+
throw new Exception(INVALID_REQUEST, {
|
|
61
|
+
help: 'The "request" parameter is required.',
|
|
62
|
+
status: 400,
|
|
63
|
+
code,
|
|
63
64
|
})
|
|
64
65
|
}
|
|
65
66
|
if (!request.url) {
|
|
66
|
-
throw new
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
code: 400,
|
|
67
|
+
throw new Exception(INVALID_REQUEST, {
|
|
68
|
+
help: 'The "request.url" parameter is required.',
|
|
69
|
+
status: 400,
|
|
70
|
+
code,
|
|
71
71
|
})
|
|
72
72
|
}
|
|
73
73
|
this.init = init
|