@api-client/core 0.5.3 → 0.5.6

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 (68) hide show
  1. package/build/browser.d.ts +1 -0
  2. package/build/browser.js +1 -0
  3. package/build/browser.js.map +1 -1
  4. package/build/index.d.ts +1 -0
  5. package/build/index.js +1 -0
  6. package/build/index.js.map +1 -1
  7. package/build/src/models/Backend.d.ts +7 -9
  8. package/build/src/models/HttpHistory.d.ts +2 -2
  9. package/build/src/models/Project.d.ts +1 -1
  10. package/build/src/models/Project.js +2 -2
  11. package/build/src/models/Project.js.map +1 -1
  12. package/build/src/models/RevisionInfo.d.ts +2 -2
  13. package/build/src/models/SerializableError.d.ts +1 -0
  14. package/build/src/models/SerializableError.js.map +1 -1
  15. package/build/src/models/store/File.js +2 -2
  16. package/build/src/models/store/File.js.map +1 -1
  17. package/build/src/runtime/store/Errors.d.ts +50 -0
  18. package/build/src/runtime/store/Errors.js +63 -0
  19. package/build/src/runtime/store/Errors.js.map +1 -0
  20. package/build/src/runtime/store/FilesSdk.d.ts +94 -0
  21. package/build/src/runtime/store/FilesSdk.js +247 -0
  22. package/build/src/runtime/store/FilesSdk.js.map +1 -0
  23. package/build/src/runtime/store/HistorySdk.d.ts +14 -7
  24. package/build/src/runtime/store/HistorySdk.js +34 -12
  25. package/build/src/runtime/store/HistorySdk.js.map +1 -1
  26. package/build/src/runtime/store/RouteBuilder.d.ts +9 -17
  27. package/build/src/runtime/store/RouteBuilder.js +14 -26
  28. package/build/src/runtime/store/RouteBuilder.js.map +1 -1
  29. package/build/src/runtime/store/Sdk.d.ts +6 -7
  30. package/build/src/runtime/store/Sdk.js +6 -7
  31. package/build/src/runtime/store/Sdk.js.map +1 -1
  32. package/build/src/runtime/store/SdkBase.d.ts +16 -6
  33. package/build/src/runtime/store/SdkBase.js +54 -4
  34. package/build/src/runtime/store/SdkBase.js.map +1 -1
  35. package/build/src/runtime/store/SharedSdk.d.ts +8 -2
  36. package/build/src/runtime/store/SharedSdk.js +22 -8
  37. package/build/src/runtime/store/SharedSdk.js.map +1 -1
  38. package/build/src/runtime/store/StoreSdkNode.d.ts +1 -1
  39. package/build/src/runtime/store/StoreSdkWeb.d.ts +1 -1
  40. package/build/src/runtime/store/UsersSdk.d.ts +10 -4
  41. package/build/src/runtime/store/UsersSdk.js +12 -6
  42. package/build/src/runtime/store/UsersSdk.js.map +1 -1
  43. package/package.json +3 -4
  44. package/src/models/Backend.ts +7 -9
  45. package/src/models/HttpHistory.ts +2 -2
  46. package/src/models/Project.ts +2 -2
  47. package/src/models/RevisionInfo.ts +2 -2
  48. package/src/models/SerializableError.ts +1 -0
  49. package/src/models/store/File.ts +2 -2
  50. package/src/runtime/store/Errors.ts +100 -0
  51. package/src/runtime/store/FilesSdk.ts +302 -0
  52. package/src/runtime/store/HistorySdk.ts +42 -17
  53. package/src/runtime/store/RouteBuilder.ts +14 -28
  54. package/src/runtime/store/Sdk.ts +7 -7
  55. package/src/runtime/store/SdkBase.ts +63 -9
  56. package/src/runtime/store/SharedSdk.ts +27 -10
  57. package/src/runtime/store/StoreSdkNode.ts +1 -1
  58. package/src/runtime/store/StoreSdkWeb.ts +1 -1
  59. package/src/runtime/store/UsersSdk.ts +14 -8
  60. package/build/src/runtime/store/ProjectsSdk.d.ts +0 -43
  61. package/build/src/runtime/store/ProjectsSdk.js +0 -144
  62. package/build/src/runtime/store/ProjectsSdk.js.map +0 -1
  63. package/build/src/runtime/store/SpacesSdk.d.ts +0 -62
  64. package/build/src/runtime/store/SpacesSdk.js +0 -194
  65. package/build/src/runtime/store/SpacesSdk.js.map +0 -1
  66. package/json8-patch.d.ts +0 -270
  67. package/src/runtime/store/ProjectsSdk.ts +0 -147
  68. package/src/runtime/store/SpacesSdk.ts +0 -209
@@ -1,15 +1,18 @@
1
1
  /// <reference types="node" />
2
2
  import { Headers } from '../../lib/headers/Headers.js';
3
3
  import { Sdk } from './Sdk.js';
4
- export interface IStoreRequestOptions {
5
- method?: 'GET' | 'POST' | 'PATCH' | 'DELETE';
6
- headers?: Record<string, string>;
7
- body?: string | Buffer;
4
+ import { SdkError, IApiError } from './Errors.js';
5
+ export interface ISdkRequestOptions {
8
6
  /**
9
- * Adds the token to the headers.
7
+ * Uses the provided token for authentication.
10
8
  */
11
9
  token?: string;
12
10
  }
11
+ export interface IStoreRequestOptions extends ISdkRequestOptions {
12
+ method?: 'GET' | 'POST' | 'PATCH' | 'DELETE';
13
+ headers?: Record<string, string>;
14
+ body?: string | Buffer;
15
+ }
13
16
  export interface IStoreResponse {
14
17
  status: number;
15
18
  headers: Headers;
@@ -41,5 +44,12 @@ export declare class SdkBase {
41
44
  * Throws unified message for a common error status codes.
42
45
  * It handles 404, 403, and 401 status codes.
43
46
  */
44
- protected inspectCommonStatusCodes(status: number): void;
47
+ protected inspectCommonStatusCodes(status: number, body?: string): void;
48
+ /**
49
+ * Reads the response as ApiError
50
+ * @param body The message returned by the store.
51
+ * @returns The error schema or undefined when not an error;
52
+ */
53
+ protected readErrorResponse(body?: string): IApiError | undefined;
54
+ protected createGenericSdkError(body?: string): SdkError | undefined;
45
55
  }
@@ -1,3 +1,4 @@
1
+ import { SdkError } from './Errors.js';
1
2
  export const E_INVALID_JSON = 'The response is not a valid JSON.';
2
3
  export const E_RESPONSE_NO_VALUE = 'The response has no value.';
3
4
  export const E_RESPONSE_STATUS = 'Invalid response status: ';
@@ -9,6 +10,9 @@ export class SdkBase {
9
10
  this.sdk = sdk;
10
11
  }
11
12
  logInvalidResponse(response) {
13
+ if (this.sdk.silent) {
14
+ return;
15
+ }
12
16
  if (response.body) {
13
17
  try {
14
18
  const data = JSON.parse(response.body);
@@ -25,16 +29,62 @@ export class SdkBase {
25
29
  * Throws unified message for a common error status codes.
26
30
  * It handles 404, 403, and 401 status codes.
27
31
  */
28
- inspectCommonStatusCodes(status) {
32
+ inspectCommonStatusCodes(status, body) {
29
33
  if (status === 404) {
30
- throw new Error(`Not found.`);
34
+ let e = this.createGenericSdkError(body);
35
+ if (!e) {
36
+ e = new SdkError(`Not found.`, 400);
37
+ e.response = body;
38
+ }
39
+ throw e;
31
40
  }
32
41
  if (status === 403) {
33
- throw new Error(`You have no access to this resource.`);
42
+ let e = this.createGenericSdkError(body);
43
+ if (!e) {
44
+ e = new SdkError(`You have no access to this resource.`, 403);
45
+ e.response = body;
46
+ }
47
+ throw e;
34
48
  }
35
49
  if (status === 401) {
36
- throw new Error(`Not authorized.`);
50
+ let e = this.createGenericSdkError(body);
51
+ if (!e) {
52
+ e = new SdkError(`Not authorized.`, 401);
53
+ e.response = body;
54
+ }
55
+ throw e;
56
+ }
57
+ }
58
+ /**
59
+ * Reads the response as ApiError
60
+ * @param body The message returned by the store.
61
+ * @returns The error schema or undefined when not an error;
62
+ */
63
+ readErrorResponse(body) {
64
+ if (!body) {
65
+ return undefined;
66
+ }
67
+ let data;
68
+ try {
69
+ data = JSON.parse(body);
70
+ }
71
+ catch (e) {
72
+ return undefined;
73
+ }
74
+ if (data.error && data.message) {
75
+ return data;
76
+ }
77
+ return undefined;
78
+ }
79
+ createGenericSdkError(body) {
80
+ const info = this.readErrorResponse(body);
81
+ if (!info) {
82
+ return undefined;
37
83
  }
84
+ const e = new SdkError(info.message, info.code);
85
+ e.detail = info.detail;
86
+ e.response = body;
87
+ return e;
38
88
  }
39
89
  }
40
90
  //# sourceMappingURL=SdkBase.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SdkBase.js","sourceRoot":"","sources":["../../../../src/runtime/store/SdkBase.ts"],"names":[],"mappings":"AAiCA,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,MAA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BACzC,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAC;aACnB;YACD,MAAM,CAAC,CAAC;SACT;IACH,CAAC;IAED;;;;OAIG;IACO,iBAAiB,CAAC,IAAa;QACvC,IAAI,CAAC,IAAI,EAAE;YACT,OAAO,SAAS,CAAC;SAClB;QACD,IAAI,IAAS,CAAC;QACd,IAAI;YACF,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,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 { token } = this.sdk;
10
- const url = this.sdk.getUrl(RouteBuilder.sharedSpaces());
12
+ async list(kinds, options, request = {}) {
13
+ const token = request.token || this.sdk.token;
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
- throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
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 Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
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
- throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
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
- throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
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,EAAE,MAAM,cAAc,CAAC;AACnH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,MAAM,OAAO,SAAU,SAAQ,OAAO;IACpC;;;OAGG;IACH,KAAK,CAAC,IAAI,CAAC,OAAsB;QAC/B,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC;QAC3B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC;QACzD,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QACzC,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,MAAM,CAAC,CAAC;Y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Q,GAAG,cAAc,GAAG,EAAE,CAAC,CAAC,CAAC;YAC7D,GAAG,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC;YAC3B,MAAM,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 { ISpaceCreateOptions } from './SpacesSdk.js';
5
+ export { IFileCreateOptions as ISpaceCreateOptions } from './FilesSdk.js';
6
6
  /**
7
7
  * NodeJS API for API Client's net-store module.
8
8
  */
@@ -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 { ISpaceCreateOptions } from './SpacesSdk.js';
5
+ export { IFileCreateOptions as ISpaceCreateOptions } 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
- me(): Promise<IUser>;
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
- async me() {
5
- const { token } = this.sdk;
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 { token } = this.sdk;
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 { token } = this.sdk;
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,EAAE,MAAM,cAAc,CAAC;AACnH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAIjD,MAAM,OAAO,QAAS,SAAQ,OAAO;IACnC,KAAK,CAAC,EAAE;QACN,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC;QAC3B,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,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,K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,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.3",
4
+ "version": "0.5.6",
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.2.16",
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
  },
@@ -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' | 'updated' | 'patch' | 'deleted' | 'access-granted' | 'access-removed';
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 space containing the project that contains the request.
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
- space: string;
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. Must be set when the originating request belongs to a user space.
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. Must be set when the originating request belongs to a user space.
21
+ * Optional project id. When set the history will become available to all project users.
22
22
  */
23
23
  project?: string;
24
24
  /**
@@ -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.isWorkspace(init)) {
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 isWorkspace(input: unknown): boolean {
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 `json8-patch` library.
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 `json8-patch` revisions object used to restore the previous state.
36
+ * The `@api-client/json` revisions object used to restore the previous state.
37
37
  */
38
38
  patch: any[];
39
39
  /**
@@ -6,6 +6,7 @@ export interface ISerializedError {
6
6
  message: string;
7
7
  stack?: string;
8
8
  code?: string | number;
9
+ [key: PropertyKey]: any;
9
10
  }
10
11
 
11
12
  /**
@@ -138,10 +138,10 @@ export class StoredFile {
138
138
  this.parents = parents;
139
139
  this.permissionIds = permissionIds;
140
140
  this.owner = owner;
141
- this.lastModified = lastModified || { user: '', time: 0, byMe: false };
141
+ this.lastModified = lastModified ? { ...lastModified } : { user: '', time: 0, byMe: false };
142
142
  if (typeof deleted === 'boolean') {
143
143
  this.deleted = deleted;
144
- this.deletedInfo = deletedInfo;
144
+ this.deletedInfo = deletedInfo ? { ...deletedInfo } : undefined;
145
145
  } else {
146
146
  this.deleted = undefined;
147
147
  this.deletedInfo = undefined;
@@ -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
+ }