@api-client/core 0.5.0 → 0.5.3

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 (65) hide show
  1. package/build/browser.d.ts +4 -5
  2. package/build/browser.js +4 -4
  3. package/build/browser.js.map +1 -1
  4. package/build/index.d.ts +4 -5
  5. package/build/index.js +4 -4
  6. package/build/index.js.map +1 -1
  7. package/build/src/models/Backend.d.ts +2 -1
  8. package/build/src/models/Project.d.ts +41 -0
  9. package/build/src/models/Project.js +94 -0
  10. package/build/src/models/Project.js.map +1 -0
  11. package/build/src/models/RevisionInfo.d.ts +5 -0
  12. package/build/src/models/RevisionInfo.js.map +1 -1
  13. package/build/src/models/Thing.js +1 -1
  14. package/build/src/models/Thing.js.map +1 -1
  15. package/build/src/models/Workspace.d.ts +0 -28
  16. package/build/src/models/Workspace.js +4 -29
  17. package/build/src/models/Workspace.js.map +1 -1
  18. package/build/src/models/store/Deletion.d.ts +24 -0
  19. package/build/src/models/store/Deletion.js +2 -0
  20. package/build/src/models/store/Deletion.js.map +1 -0
  21. package/build/src/models/store/File.d.ts +81 -8
  22. package/build/src/models/store/File.js +126 -16
  23. package/build/src/models/store/File.js.map +1 -1
  24. package/build/src/models/store/Modification.d.ts +24 -0
  25. package/build/src/models/store/Modification.js +2 -0
  26. package/build/src/models/store/Modification.js.map +1 -0
  27. package/build/src/models/store/Permission.d.ts +17 -10
  28. package/build/src/models/store/Permission.js +10 -0
  29. package/build/src/models/store/Permission.js.map +1 -1
  30. package/build/src/runtime/store/RouteBuilder.d.ts +1 -0
  31. package/build/src/runtime/store/RouteBuilder.js +3 -0
  32. package/build/src/runtime/store/RouteBuilder.js.map +1 -1
  33. package/build/src/runtime/store/Sdk.d.ts +5 -0
  34. package/build/src/runtime/store/Sdk.js +8 -0
  35. package/build/src/runtime/store/Sdk.js.map +1 -1
  36. package/build/src/runtime/store/SharedSdk.d.ts +9 -0
  37. package/build/src/runtime/store/SharedSdk.js +35 -0
  38. package/build/src/runtime/store/SharedSdk.js.map +1 -0
  39. package/build/src/runtime/store/SpacesSdk.d.ts +13 -1
  40. package/build/src/runtime/store/SpacesSdk.js +11 -2
  41. package/build/src/runtime/store/SpacesSdk.js.map +1 -1
  42. package/build/src/runtime/store/StoreSdkNode.d.ts +2 -0
  43. package/build/src/runtime/store/StoreSdkNode.js.map +1 -1
  44. package/build/src/runtime/store/StoreSdkWeb.d.ts +2 -0
  45. package/build/src/runtime/store/StoreSdkWeb.js.map +1 -1
  46. package/package.json +1 -1
  47. package/src/models/Backend.ts +2 -1
  48. package/src/models/Project.ts +110 -0
  49. package/src/models/RevisionInfo.ts +6 -0
  50. package/src/models/Thing.ts +1 -1
  51. package/src/models/Workspace.ts +6 -44
  52. package/src/models/store/Deletion.ts +24 -0
  53. package/src/models/store/File.ts +155 -21
  54. package/src/models/store/Modification.ts +24 -0
  55. package/src/models/store/Permission.ts +24 -10
  56. package/src/runtime/store/RouteBuilder.ts +4 -0
  57. package/src/runtime/store/Sdk.ts +8 -0
  58. package/src/runtime/store/SharedSdk.ts +35 -0
  59. package/src/runtime/store/SpacesSdk.ts +21 -2
  60. package/src/runtime/store/StoreSdkNode.ts +3 -0
  61. package/src/runtime/store/StoreSdkWeb.ts +3 -0
  62. package/build/src/models/HttpProjectListItem.d.ts +0 -23
  63. package/build/src/models/HttpProjectListItem.js +0 -2
  64. package/build/src/models/HttpProjectListItem.js.map +0 -1
  65. package/src/models/HttpProjectListItem.ts +0 -23
@@ -7,6 +7,7 @@ import { SpacesSdk } from './SpacesSdk.js';
7
7
  import { ProjectsSdk } from './ProjectsSdk.js';
8
8
  import { UsersSdk } from './UsersSdk.js';
9
9
  import { HistorySdk } from './HistorySdk.js';
10
+ import { SharedSdk } from './SharedSdk.js';
10
11
 
11
12
  const baseUriSymbol = Symbol('baseUri');
12
13
 
@@ -50,6 +51,10 @@ export abstract class Sdk {
50
51
  * The history data.
51
52
  */
52
53
  history = new HistorySdk(this);
54
+ /**
55
+ * The shared data.
56
+ */
57
+ shared = new SharedSdk(this);
53
58
 
54
59
 
55
60
  [baseUriSymbol] = '';
@@ -126,6 +131,9 @@ export abstract class Sdk {
126
131
  searchParams.append('queryField', field);
127
132
  });
128
133
  }
134
+ if (options.parent) {
135
+ searchParams.set('parent', options.parent);
136
+ }
129
137
  }
130
138
  }
131
139
  }
@@ -0,0 +1,35 @@
1
+ import { SdkBase, E_RESPONSE_STATUS, E_RESPONSE_NO_VALUE, E_INVALID_JSON, E_RESPONSE_UNKNOWN } from './SdkBase.js';
2
+ import { RouteBuilder } from './RouteBuilder.js';
3
+ import { IListOptions, IListResponse } from '../../models/Backend.js';
4
+
5
+ export class SharedSdk extends SdkBase {
6
+ /**
7
+ * Lists shared with the user spaces.
8
+ * @param options Optional query options.
9
+ */
10
+ async list(options?: IListOptions): Promise<IListResponse> {
11
+ const { token } = this.sdk;
12
+ const url = this.sdk.getUrl(RouteBuilder.sharedSpaces());
13
+ this.sdk.appendListOptions(url, options);
14
+ const result = await this.sdk.http.get(url.toString(), { token });
15
+ this.inspectCommonStatusCodes(result.status);
16
+ const E_PREFIX = 'Unable to list spaces. ';
17
+ if (result.status !== 200) {
18
+ this.logInvalidResponse(result);
19
+ throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
20
+ }
21
+ if (!result.body) {
22
+ throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
23
+ }
24
+ let data: IListResponse;
25
+ try {
26
+ data = JSON.parse(result.body);
27
+ } catch (e) {
28
+ throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
29
+ }
30
+ if (!Array.isArray(data.data)) {
31
+ throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
32
+ }
33
+ return data;
34
+ }
35
+ }
@@ -4,6 +4,15 @@ import { RouteBuilder } from './RouteBuilder.js';
4
4
  import { IListOptions, IListResponse } from '../../models/Backend.js';
5
5
  import { IWorkspace, Workspace, Kind as WorkspaceKind } from '../../models/Workspace.js';
6
6
  import { AccessOperation } from '../../models/store/Permission.js';
7
+ import WebSocketNode from 'ws';
8
+
9
+ export interface ISpaceCreateOptions {
10
+ /**
11
+ * Optional parent space id.
12
+ * When set it creates a space under this parent.
13
+ */
14
+ parent?: string;
15
+ }
7
16
 
8
17
  export class SpacesSdk extends SdkBase {
9
18
  /**
@@ -41,9 +50,10 @@ export class SpacesSdk extends SdkBase {
41
50
  * @param space The workspace definition.
42
51
  * @returns The key of the creates space.
43
52
  */
44
- async create(space: IWorkspace | Workspace): Promise<string> {
53
+ async create(space: IWorkspace | Workspace, opts: ISpaceCreateOptions = {}): Promise<string> {
45
54
  const { token } = this.sdk;
46
- const url = this.sdk.getUrl(RouteBuilder.spaces());
55
+ const path = opts.parent ? RouteBuilder.space(opts.parent) : RouteBuilder.spaces();
56
+ const url = this.sdk.getUrl(path);
47
57
  const body = JSON.stringify(space);
48
58
  const result = await this.sdk.http.post(url.toString(), { token, body });
49
59
  this.inspectCommonStatusCodes(result.status);
@@ -187,4 +197,13 @@ export class SpacesSdk extends SdkBase {
187
197
  }
188
198
  return data;
189
199
  }
200
+
201
+ /**
202
+ * Creates a WS client that listens to the spaces events.
203
+ */
204
+ async observeSpaces(): Promise<WebSocketNode | WebSocket> {
205
+ const { token } = this.sdk;
206
+ const url = this.sdk.getUrl(RouteBuilder.spaces());
207
+ return this.sdk.ws.createAndConnect(url.toString(), token);
208
+ }
190
209
  }
@@ -4,6 +4,9 @@ import { Sdk } from './Sdk.js';
4
4
  import { Http } from './Http.js';
5
5
  import { WsClient } from './WsClient.js';
6
6
 
7
+ export { IStoreTokenInfo, IStoreResponse, IStoreRequestOptions } from './SdkBase.js';
8
+ export { ISpaceCreateOptions } from './SpacesSdk.js';
9
+
7
10
  /**
8
11
  * NodeJS API for API Client's net-store module.
9
12
  */
@@ -4,6 +4,9 @@ import { Sdk } from './Sdk.js';
4
4
  import { Http } from './Http.js';
5
5
  import { WsClient } from './WsClient.js';
6
6
 
7
+ export { IStoreTokenInfo, IStoreResponse, IStoreRequestOptions } from './SdkBase.js';
8
+ export { ISpaceCreateOptions } from './SpacesSdk.js';
9
+
7
10
  /**
8
11
  * NodeJS API for API Client's net-store module.
9
12
  */
@@ -1,23 +0,0 @@
1
- export declare const Kind = "Core#HttpProjectListItem";
2
- /**
3
- * The HTTP Project definition to be used in lists.
4
- */
5
- export interface IHttpProjectListItem {
6
- /**
7
- * The data store key of the project.
8
- */
9
- key: string;
10
- /**
11
- * Project's name
12
- */
13
- name: string;
14
- /**
15
- * Whether the project is one of the favourites.
16
- * May be used by an UI to add projects to favourites.
17
- */
18
- favourite?: boolean;
19
- /**
20
- * The timestamp when the project was last updated.
21
- */
22
- updated: number;
23
- }
@@ -1,2 +0,0 @@
1
- export const Kind = 'Core#HttpProjectListItem';
2
- //# sourceMappingURL=HttpProjectListItem.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HttpProjectListItem.js","sourceRoot":"","sources":["../../../src/models/HttpProjectListItem.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,IAAI,GAAG,0BAA0B,CAAC"}
@@ -1,23 +0,0 @@
1
- export const Kind = 'Core#HttpProjectListItem';
2
- /**
3
- * The HTTP Project definition to be used in lists.
4
- */
5
- export interface IHttpProjectListItem {
6
- /**
7
- * The data store key of the project.
8
- */
9
- key: string;
10
- /**
11
- * Project's name
12
- */
13
- name: string;
14
- /**
15
- * Whether the project is one of the favourites.
16
- * May be used by an UI to add projects to favourites.
17
- */
18
- favourite?: boolean;
19
- /**
20
- * The timestamp when the project was last updated.
21
- */
22
- updated: number;
23
- }