@api-client/core 0.5.2 → 0.5.5

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 (88) hide show
  1. package/build/browser.d.ts +2 -1
  2. package/build/browser.js +2 -1
  3. package/build/browser.js.map +1 -1
  4. package/build/index.d.ts +2 -1
  5. package/build/index.js +2 -1
  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 +41 -0
  10. package/build/src/models/Project.js +94 -0
  11. package/build/src/models/Project.js.map +1 -0
  12. package/build/src/models/RevisionInfo.d.ts +5 -0
  13. package/build/src/models/RevisionInfo.js.map +1 -1
  14. package/build/src/models/SerializableError.d.ts +1 -0
  15. package/build/src/models/SerializableError.js.map +1 -1
  16. package/build/src/models/Thing.js +1 -1
  17. package/build/src/models/Thing.js.map +1 -1
  18. package/build/src/models/Workspace.d.ts +0 -17
  19. package/build/src/models/Workspace.js +3 -19
  20. package/build/src/models/Workspace.js.map +1 -1
  21. package/build/src/models/store/Deletion.d.ts +24 -0
  22. package/build/src/models/store/Deletion.js +2 -0
  23. package/build/src/models/store/Deletion.js.map +1 -0
  24. package/build/src/models/store/File.d.ts +75 -12
  25. package/build/src/models/store/File.js +120 -19
  26. package/build/src/models/store/File.js.map +1 -1
  27. package/build/src/models/store/Modification.d.ts +24 -0
  28. package/build/src/models/store/Modification.js +2 -0
  29. package/build/src/models/store/Modification.js.map +1 -0
  30. package/build/src/runtime/store/Errors.d.ts +50 -0
  31. package/build/src/runtime/store/Errors.js +63 -0
  32. package/build/src/runtime/store/Errors.js.map +1 -0
  33. package/build/src/runtime/store/FilesSdk.d.ts +94 -0
  34. package/build/src/runtime/store/FilesSdk.js +247 -0
  35. package/build/src/runtime/store/FilesSdk.js.map +1 -0
  36. package/build/src/runtime/store/HistorySdk.d.ts +14 -7
  37. package/build/src/runtime/store/HistorySdk.js +34 -12
  38. package/build/src/runtime/store/HistorySdk.js.map +1 -1
  39. package/build/src/runtime/store/RouteBuilder.d.ts +9 -17
  40. package/build/src/runtime/store/RouteBuilder.js +14 -26
  41. package/build/src/runtime/store/RouteBuilder.js.map +1 -1
  42. package/build/src/runtime/store/Sdk.d.ts +6 -7
  43. package/build/src/runtime/store/Sdk.js +6 -7
  44. package/build/src/runtime/store/Sdk.js.map +1 -1
  45. package/build/src/runtime/store/SdkBase.d.ts +16 -6
  46. package/build/src/runtime/store/SdkBase.js +54 -4
  47. package/build/src/runtime/store/SdkBase.js.map +1 -1
  48. package/build/src/runtime/store/SharedSdk.d.ts +8 -2
  49. package/build/src/runtime/store/SharedSdk.js +22 -8
  50. package/build/src/runtime/store/SharedSdk.js.map +1 -1
  51. package/build/src/runtime/store/StoreSdkNode.d.ts +1 -1
  52. package/build/src/runtime/store/StoreSdkWeb.d.ts +1 -1
  53. package/build/src/runtime/store/UsersSdk.d.ts +10 -4
  54. package/build/src/runtime/store/UsersSdk.js +12 -6
  55. package/build/src/runtime/store/UsersSdk.js.map +1 -1
  56. package/package.json +2 -2
  57. package/src/models/Backend.ts +7 -9
  58. package/src/models/HttpHistory.ts +2 -2
  59. package/src/models/Project.ts +110 -0
  60. package/src/models/RevisionInfo.ts +6 -0
  61. package/src/models/SerializableError.ts +1 -0
  62. package/src/models/Thing.ts +1 -1
  63. package/src/models/Workspace.ts +4 -29
  64. package/src/models/store/Deletion.ts +24 -0
  65. package/src/models/store/File.ts +146 -26
  66. package/src/models/store/Modification.ts +24 -0
  67. package/src/runtime/store/Errors.ts +100 -0
  68. package/src/runtime/store/FilesSdk.ts +302 -0
  69. package/src/runtime/store/HistorySdk.ts +42 -17
  70. package/src/runtime/store/RouteBuilder.ts +14 -28
  71. package/src/runtime/store/Sdk.ts +7 -7
  72. package/src/runtime/store/SdkBase.ts +63 -9
  73. package/src/runtime/store/SharedSdk.ts +27 -10
  74. package/src/runtime/store/StoreSdkNode.ts +1 -1
  75. package/src/runtime/store/StoreSdkWeb.ts +1 -1
  76. package/src/runtime/store/UsersSdk.ts +14 -8
  77. package/build/src/models/HttpProjectListItem.d.ts +0 -23
  78. package/build/src/models/HttpProjectListItem.js +0 -2
  79. package/build/src/models/HttpProjectListItem.js.map +0 -1
  80. package/build/src/runtime/store/ProjectsSdk.d.ts +0 -43
  81. package/build/src/runtime/store/ProjectsSdk.js +0 -144
  82. package/build/src/runtime/store/ProjectsSdk.js.map +0 -1
  83. package/build/src/runtime/store/SpacesSdk.d.ts +0 -62
  84. package/build/src/runtime/store/SpacesSdk.js +0 -194
  85. package/build/src/runtime/store/SpacesSdk.js.map +0 -1
  86. package/src/models/HttpProjectListItem.ts +0 -23
  87. package/src/runtime/store/ProjectsSdk.ts +0 -147
  88. 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,MAAM,OAAO,OAAO;IACC;IAAnB,YAAmB,GAAQ;QAAR,QAAG,GAAH,GAAG,CAAK;IAAG,CAAC;IAErB,kBAAkB,CAAC,QAAwB;QACnD,IAAI,QAAQ,CAAC,IAAI,EAAE;YACjB,IAAI;gBACF,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;gBACvC,IAAI,IAAI,CAAC,OAAO,EAAE;oBAChB,OAAO,CAAC,IAAI,CAAC,oBAAoB,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;iBAClD;aACF;YAAC,OAAO,CAAC,EAAE;gBACV,IAAI;aACL;SACF;IACH,CAAC;IAED;;;OAGG;IACO,wBAAwB,CAAC,MAAc;QAC/C,IAAI,MAAM,KAAK,GAAG,EAAE;YAClB,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;SAC/B;QACD,IAAI,MAAM,KAAK,GAAG,EAAE;YAClB,MAAM,IAAI,KAAK,C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C;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;;;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B,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;YAC/C,IAAI,CAAC,CAAC,EAAE;gBACN,CAAC,GAAG,IAAI,QAAQ,CAAC,GAAG,QAAQ,GAAG,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;gBACnF,CAAC,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC;aAC1B;YACD,MAAM,CAAC,CAAC;SACT;QACD,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE;YAChB,MAAM,IAAI,QAAQ,CAAC,GAAG,QAAQ,GAAG,mBAAmB,EAAE,EAAE,CAAC,CAAC,CAAC;SAC5D;QACD,IAAI,IAA0B,CAAC;QAC/B,IAAI;YACF,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;SAChC;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,GAAG,GAAG,IAAI,QAAQ,CAAC,GAAG,QAAQ,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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GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,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,gCAAgC,CAAC;QAClD,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,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.2",
4
+ "version": "0.5.5",
5
5
  "license": "Apache-2.0",
6
6
  "main": "build/index.js",
7
7
  "module": "build/index.js",
@@ -37,7 +37,7 @@
37
37
  "@types/sinon": "^10.0.11",
38
38
  "@typescript-eslint/eslint-plugin": "^5.12.0",
39
39
  "@typescript-eslint/parser": "^5.12.0",
40
- "@web/dev-server-esbuild": "^0.2.16",
40
+ "@web/dev-server-esbuild": "^0.3.0",
41
41
  "@web/test-runner": "^0.13.21",
42
42
  "@web/test-runner-playwright": "^0.8.8",
43
43
  "chai": "^4.3.4",
@@ -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
  /**
@@ -0,0 +1,110 @@
1
+ import { IFile, File, DefaultOwner } from "./store/File.js";
2
+ import { Kind as ThingKind } from './Thing.js';
3
+ import { HttpProject, IHttpProject } from './HttpProject.js';
4
+ import v4 from '../lib/uuid.js';
5
+
6
+ export const Kind = 'Core#Project';
7
+
8
+ /**
9
+ * This model represents a meta data for an HTTP project stored with the data store.
10
+ * This does not include the HTTP project entity, though, it is referenced through the same key.
11
+ *
12
+ * A concept of a project is similar to a Workspace. It is an object that is rendered in the UIs
13
+ * like a workspace but has a different meaning. On the store side, when listing workspace items,
14
+ * both spaces and projects are returned in a single query.
15
+ */
16
+ export interface IProject extends IFile {
17
+ kind: typeof Kind;
18
+ }
19
+
20
+ /**
21
+ * This model represents a meta data for an HTTP project stored with the data store.
22
+ * This does not include the HTTP project entity, though, it is referenced through the same key.
23
+ *
24
+ * A concept of a project is similar to a Workspace. It is an object that is rendered in the UIs
25
+ * like a workspace but has a different meaning. On the store side, when listing workspace items,
26
+ * both spaces and projects are returned in a single query.
27
+ */
28
+ export class Project extends File {
29
+ kind = Kind;
30
+
31
+ static fromProject(project: HttpProject | IHttpProject): Project {
32
+ let final: IHttpProject;
33
+ if (typeof (project as HttpProject).toJSON === 'function') {
34
+ final = (project as HttpProject).toJSON();
35
+ } else {
36
+ final = project as IHttpProject;
37
+ }
38
+ const init: IProject = {
39
+ kind: Kind,
40
+ key: final.key,
41
+ info: { ...final.info },
42
+ lastModified: { user: '', time: 0, byMe: false },
43
+ owner: DefaultOwner,
44
+ parents: [],
45
+ permissionIds: [],
46
+ permissions: [],
47
+ };
48
+ return new Project(init);
49
+ }
50
+
51
+ /**
52
+ * @param input The environment definition used to restore the state.
53
+ */
54
+ constructor(input?: string | IProject) {
55
+ super();
56
+ let init: IProject;
57
+ if (typeof input === 'string') {
58
+ init = JSON.parse(input);
59
+ } else if (typeof input === 'object') {
60
+ init = input;
61
+ } else {
62
+ init = {
63
+ kind: Kind,
64
+ key: v4(),
65
+ info: {
66
+ kind: ThingKind,
67
+ name: '',
68
+ },
69
+ owner: DefaultOwner,
70
+ parents: [],
71
+ permissionIds: [],
72
+ permissions: [],
73
+ lastModified: { user: '', time: 0, byMe: false },
74
+ };
75
+ }
76
+ this.new(init);
77
+ }
78
+
79
+ /**
80
+ * Creates a new environment clearing anything that is so far defined.
81
+ *
82
+ * Note, this throws an error when the environment is not a space.
83
+ */
84
+ new(init: IProject): void {
85
+ if (!Project.isProject(init)) {
86
+ throw new Error(`Not a space.`);
87
+ }
88
+ super.new(init);
89
+ this.kind = Kind;
90
+ }
91
+
92
+ /**
93
+ * Checks whether the input is a definition of an user space.
94
+ */
95
+ static isProject(input: unknown): boolean {
96
+ const typed = input as IProject;
97
+ if (!input || typed.kind !== Kind) {
98
+ return false;
99
+ }
100
+ return true;
101
+ }
102
+
103
+ toJSON(): IProject {
104
+ const result: IProject = {
105
+ ...super.toJSON(),
106
+ kind: Kind,
107
+ };
108
+ return result;
109
+ }
110
+ }
@@ -1,3 +1,5 @@
1
+ import { IModification } from './store/Modification.js';
2
+
1
3
  export const Kind = 'Core#Revision';
2
4
 
3
5
  /**
@@ -34,4 +36,8 @@ export interface IRevisionInfo {
34
36
  * The `json8-patch` revisions object used to restore the previous state.
35
37
  */
36
38
  patch: any[];
39
+ /**
40
+ * The modification record for this revision.
41
+ */
42
+ modification: IModification;
37
43
  }
@@ -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
  /**
@@ -96,7 +96,7 @@ export class Thing {
96
96
  const result: IThing = {
97
97
  kind: Kind,
98
98
  };
99
- if (this.name) {
99
+ if (typeof this.name === 'string') {
100
100
  result.name = this.name;
101
101
  }
102
102
  if (this.description) {
@@ -1,5 +1,5 @@
1
1
  import { IFile, File, DefaultOwner } from "./store/File.js";
2
- import { IThing, Thing, Kind as ThingKind } from './Thing.js';
2
+ import { Thing, Kind as ThingKind } from './Thing.js';
3
3
  import v4 from '../lib/uuid.js';
4
4
 
5
5
  export const Kind = 'Core#Space';
@@ -11,18 +11,8 @@ export const Kind = 'Core#Space';
11
11
  */
12
12
  export interface IWorkspace extends IFile {
13
13
  kind: typeof Kind;
14
- /**
15
- * The space identifier.
16
- */
17
- key: string;
18
- /**
19
- * The environment's meta info.
20
- */
21
- info: IThing;
22
14
  }
23
15
 
24
-
25
-
26
16
  /**
27
17
  * A definition of the working space for users.
28
18
  *
@@ -31,14 +21,6 @@ export interface IWorkspace extends IFile {
31
21
  */
32
22
  export class Workspace extends File {
33
23
  kind = Kind;
34
- /**
35
- * The space identifier.
36
- */
37
- key = '';
38
- /**
39
- * The name of the environment.
40
- */
41
- info: Thing = new Thing({ kind: ThingKind });
42
24
 
43
25
  /**
44
26
  * Creates a new Space object from a name.
@@ -57,6 +39,7 @@ export class Workspace extends File {
57
39
  parents: [],
58
40
  permissionIds: [],
59
41
  permissions: [],
42
+ lastModified: { user: '', time: 0, byMe: false },
60
43
  });
61
44
  return definition;
62
45
  }
@@ -83,6 +66,7 @@ export class Workspace extends File {
83
66
  parents: [],
84
67
  permissionIds: [],
85
68
  permissions: [],
69
+ lastModified: { user: '', time: 0, byMe: false },
86
70
  };
87
71
  }
88
72
  this.new(init);
@@ -98,14 +82,7 @@ export class Workspace extends File {
98
82
  throw new Error(`Not a space.`);
99
83
  }
100
84
  super.new(init);
101
- const { key = v4(), info } = init;
102
85
  this.kind = Kind;
103
- this.key = key;
104
- if (info) {
105
- this.info = new Thing(info);
106
- } else {
107
- this.info = new Thing({ kind: ThingKind, name: '' });
108
- }
109
86
  }
110
87
 
111
88
  /**
@@ -121,10 +98,8 @@ export class Workspace extends File {
121
98
 
122
99
  toJSON(): IWorkspace {
123
100
  const result: IWorkspace = {
124
- kind: Kind,
125
- key: this.key,
126
- info: this.info.toJSON(),
127
101
  ...super.toJSON(),
102
+ kind: Kind,
128
103
  };
129
104
  return result;
130
105
  }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * A schema describing the delete action performed on an entity.
3
+ */
4
+ export interface IDeletion {
5
+ /**
6
+ * The timestamp of when the entity was deleted.
7
+ */
8
+ time: number;
9
+ /**
10
+ * The id of the user that has deleted the entity.
11
+ */
12
+ user?: string;
13
+ /**
14
+ * User name deleting the entity. May not be set when there's no actual user.
15
+ */
16
+ name?: string;
17
+ /**
18
+ * Whether the deletion was performed by the requesting the data user.
19
+ *
20
+ * Note for store implementers, this field should not be stored and populated every time the
21
+ * record is requested.
22
+ */
23
+ byMe: boolean;
24
+ }