@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.
Files changed (70) hide show
  1. package/build/src/browser.d.ts +0 -1
  2. package/build/src/browser.d.ts.map +1 -1
  3. package/build/src/browser.js +0 -1
  4. package/build/src/browser.js.map +1 -1
  5. package/build/src/exceptions/exception.d.ts +29 -1
  6. package/build/src/exceptions/exception.d.ts.map +1 -1
  7. package/build/src/exceptions/exception.js +37 -1
  8. package/build/src/exceptions/exception.js.map +1 -1
  9. package/build/src/index.d.ts +0 -1
  10. package/build/src/index.d.ts.map +1 -1
  11. package/build/src/index.js +0 -1
  12. package/build/src/index.js.map +1 -1
  13. package/build/src/models/store/Backend.d.ts +15 -2
  14. package/build/src/models/store/Backend.d.ts.map +1 -1
  15. package/build/src/models/store/Backend.js.map +1 -1
  16. package/build/src/proxy/HttpProjectProxy.d.ts.map +1 -1
  17. package/build/src/proxy/HttpProjectProxy.js +39 -43
  18. package/build/src/proxy/HttpProjectProxy.js.map +1 -1
  19. package/build/src/proxy/RequestProxy.d.ts.map +1 -1
  20. package/build/src/proxy/RequestProxy.js +11 -11
  21. package/build/src/proxy/RequestProxy.js.map +1 -1
  22. package/build/src/runtime/store/DataCatalogSdk.d.ts.map +1 -1
  23. package/build/src/runtime/store/DataCatalogSdk.js +49 -109
  24. package/build/src/runtime/store/DataCatalogSdk.js.map +1 -1
  25. package/build/src/runtime/store/FilesSdk.d.ts.map +1 -1
  26. package/build/src/runtime/store/FilesSdk.js +51 -115
  27. package/build/src/runtime/store/FilesSdk.js.map +1 -1
  28. package/build/src/runtime/store/HistorySdk.d.ts.map +1 -1
  29. package/build/src/runtime/store/HistorySdk.js +25 -70
  30. package/build/src/runtime/store/HistorySdk.js.map +1 -1
  31. package/build/src/runtime/store/OrganizationsSdk.d.ts.map +1 -1
  32. package/build/src/runtime/store/OrganizationsSdk.js +46 -50
  33. package/build/src/runtime/store/OrganizationsSdk.js.map +1 -1
  34. package/build/src/runtime/store/RevisionsSdk.d.ts.map +1 -1
  35. package/build/src/runtime/store/RevisionsSdk.js +5 -10
  36. package/build/src/runtime/store/RevisionsSdk.js.map +1 -1
  37. package/build/src/runtime/store/SdkBase.d.ts +7 -5
  38. package/build/src/runtime/store/SdkBase.d.ts.map +1 -1
  39. package/build/src/runtime/store/SdkBase.js +45 -63
  40. package/build/src/runtime/store/SdkBase.js.map +1 -1
  41. package/build/src/runtime/store/SharedSdk.d.ts.map +1 -1
  42. package/build/src/runtime/store/SharedSdk.js +5 -14
  43. package/build/src/runtime/store/SharedSdk.js.map +1 -1
  44. package/build/src/runtime/store/TrashSdk.d.ts.map +1 -1
  45. package/build/src/runtime/store/TrashSdk.js +8 -28
  46. package/build/src/runtime/store/TrashSdk.js.map +1 -1
  47. package/build/src/runtime/store/UsersSdk.d.ts.map +1 -1
  48. package/build/src/runtime/store/UsersSdk.js +12 -11
  49. package/build/src/runtime/store/UsersSdk.js.map +1 -1
  50. package/package.json +1 -1
  51. package/src/exceptions/exception.ts +51 -4
  52. package/src/models/store/Backend.ts +16 -2
  53. package/src/proxy/HttpProjectProxy.ts +39 -43
  54. package/src/proxy/RequestProxy.ts +11 -11
  55. package/src/runtime/store/DataCatalogSdk.ts +49 -109
  56. package/src/runtime/store/FilesSdk.ts +51 -115
  57. package/src/runtime/store/HistorySdk.ts +25 -70
  58. package/src/runtime/store/OrganizationsSdk.ts +46 -50
  59. package/src/runtime/store/RevisionsSdk.ts +5 -10
  60. package/src/runtime/store/SdkBase.ts +46 -65
  61. package/src/runtime/store/SharedSdk.ts +5 -14
  62. package/src/runtime/store/TrashSdk.ts +8 -28
  63. package/src/runtime/store/UsersSdk.ts +12 -11
  64. package/tests/unit/runtime/proxy/HttpProjectProxy.spec.ts +42 -40
  65. package/tests/unit/runtime/proxy/RequestProxy.spec.ts +11 -11
  66. package/build/src/runtime/store/Errors.d.ts +0 -51
  67. package/build/src/runtime/store/Errors.d.ts.map +0 -1
  68. package/build/src/runtime/store/Errors.js +0 -61
  69. package/build/src/runtime/store/Errors.js.map +0 -1
  70. 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 { SdkError } from './Errors.js';
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
- let e = this.createGenericSdkError(result.body);
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 Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
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 Error(`${E_PREFIX}${E_INVALID_JSON}.`);
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 Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
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
- let e = this.createGenericSdkError(result.body);
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
- let e = this.createGenericSdkError(result.body);
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
- let e = this.createGenericSdkError(result.body);
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"],"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;AAEhD,OA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H,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,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 type SdkOptions,\n} from './SdkBase.js'\nimport { RouteBuilder } from './RouteBuilder.js'\nimport type { ContextListOptions, ContextListResult } from '../../events/BaseEvents.js'\nimport { SdkError } from './Errors.js'\nimport type { TrashEntry } from '../../models/TrashEntry.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 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<TrashEntry>\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 * 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 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 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 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 * 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 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":"TrashSdk.js","sourceRoot":"","sources":["../../../../src/runtime/store/TrashSdk.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;AAEzD,MAAM,OAAO,QAAS,SAAQ,OAAO;IACnC;;;OAGG;IACH,KAAK,CAAC,IAAI,CACR,GAAW,EACX,OAA2B,EAC3B,UAAsB,EAAE;QAExB,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAA;QACzB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAA;QACpD,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;QAC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_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;AAElF,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,EA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C,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 new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
17
+ throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
17
18
  }
18
19
  if (!result.body) {
19
- throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
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 Error(`${E_PREFIX}${E_INVALID_JSON}.`);
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 Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
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 new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
53
+ throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
53
54
  }
54
55
  if (!result.body) {
55
- throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
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 Error(`${E_PREFIX}${E_INVALID_JSON}.`);
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 Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
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 new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
89
+ throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
89
90
  }
90
91
  if (!result.body) {
91
- throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
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 Error(`${E_PREFIX}${E_INVALID_JSON}.`);
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,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,KAAK,CAAC,GAAG,QAAQ,GAAG,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAA;QACpE,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,GAAG,QAAQ,GAAG,mBAAmB,EAAE,CAAC,CAAA;QACtD,CAAC;QACD,IAAI,IAAW,CAAA;QACf,IAAI,CAAC;YACH,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAA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AAC;QACD,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,GAAG,QAAQ,GAAG,mBAAmB,EAAE,CAAC,CAAA;QACtD,CAAC;QACD,IAAI,IAAW,CAAA;QACf,IAAI,CAAC;YACH,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAChC,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,KAAK,CAAC,GAAG,QAAQ,GAAG,cAAc,GAAG,CAAC,CAAA;QAClD,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'\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,MA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AE,CAAC;YACjB,MAAM,IAAI,SAAS,CAAC,GAAG,QAAQ,GAAG,mBAAmB,EAAE,EAAE,EAAE,IAAI,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAA;QAClH,CAAC;QACD,IAAI,IAAW,CAAA;QACf,IAAI,CAAC;YACH,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAChC,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,SAAS,CAAC,GAAG,QAAQ,GAAG,cAAc,EAAE,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,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.12.10",
4
+ "version": "0.12.12",
5
5
  "license": "Apache-2.0",
6
6
  "exports": {
7
7
  "./browser.js": {
@@ -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
- constructor(message?: string, options?: ErrorOptions & { code?: string; status?: number }) {
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: Record<string, string | number> = {
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 a file was patched.
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 file meta data were patched or the media (the content).
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 ApiError({
49
- error: true,
50
- message: 'Invalid request',
51
- detail: 'The "pid" parameter is required.',
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 ApiError({
57
- error: true,
58
- message: 'Invalid request',
59
- detail: 'The "organization" parameter is required.',
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 ApiError({
65
- error: true,
66
- message: 'Invalid request',
67
- detail: 'The "options" parameter is required.',
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 ApiError({
73
- error: true,
74
- message: 'Invalid request',
75
- detail: 'Set the authentication credentials.',
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 ApiError({
81
- error: true,
82
- message: 'Invalid request',
83
- detail: 'The store uri is missing.',
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 ApiError({
89
- error: true,
90
- message: 'Invalid request',
91
- detail: 'The store uri is invalid.',
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 ApiError(e.message, 400)
99
+ throw new Exception(e.message, { status: 400 })
104
100
  }
105
101
  if (project.key !== pid) {
106
- throw new ApiError(`Unable to read the project.`, 500)
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 ApiError({
116
- error: true,
117
- message: 'Invalid request',
118
- detail: 'The "options" parameter is required.',
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 ApiError({
124
- error: true,
125
- message: 'Invalid request',
126
- detail: 'The "project" parameter is required.',
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 ApiError({
59
- error: true,
60
- message: 'Invalid request',
61
- detail: 'The "request" parameter is required.',
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 ApiError({
67
- error: true,
68
- message: 'Invalid request',
69
- detail: 'The "request.url" parameter is required.',
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