@api-client/core 0.4.0 → 0.4.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 (110) hide show
  1. package/build/browser.d.ts +6 -3
  2. package/build/browser.js +7 -2
  3. package/build/browser.js.map +1 -1
  4. package/build/index.d.ts +7 -5
  5. package/build/index.js +4 -3
  6. package/build/index.js.map +1 -1
  7. package/build/src/models/HttpHistory.d.ts +29 -0
  8. package/build/src/models/HttpHistory.js.map +1 -1
  9. package/build/src/models/HttpProject.d.ts +37 -1
  10. package/build/src/models/HttpProject.js +49 -1
  11. package/build/src/models/HttpProject.js.map +1 -1
  12. package/build/src/models/RequestLog.d.ts +8 -0
  13. package/build/src/models/RequestLog.js +14 -1
  14. package/build/src/models/RequestLog.js.map +1 -1
  15. package/build/src/runtime/node/InteropInterfaces.d.ts +115 -0
  16. package/build/src/runtime/node/InteropInterfaces.js +2 -0
  17. package/build/src/runtime/node/InteropInterfaces.js.map +1 -0
  18. package/build/src/runtime/node/ProjectParallelRunner.d.ts +2 -7
  19. package/build/src/runtime/node/ProjectParallelRunner.js.map +1 -1
  20. package/build/src/runtime/node/ProjectRequestRunner.d.ts +17 -49
  21. package/build/src/runtime/node/ProjectRequestRunner.js +39 -10
  22. package/build/src/runtime/node/ProjectRequestRunner.js.map +1 -1
  23. package/build/src/runtime/node/ProjectRunner.d.ts +1 -59
  24. package/build/src/runtime/node/ProjectRunner.js.map +1 -1
  25. package/build/src/runtime/node/ProjectRunnerWorker.js.map +1 -1
  26. package/build/src/runtime/store/AuthSdk.d.ts +28 -0
  27. package/build/src/runtime/store/AuthSdk.js +123 -0
  28. package/build/src/runtime/store/AuthSdk.js.map +1 -0
  29. package/build/src/runtime/store/BackendSdk.d.ts +8 -0
  30. package/build/src/runtime/store/BackendSdk.js +25 -0
  31. package/build/src/runtime/store/BackendSdk.js.map +1 -0
  32. package/build/src/runtime/store/HistorySdk.d.ts +48 -0
  33. package/build/src/runtime/store/HistorySdk.js +142 -0
  34. package/build/src/runtime/store/HistorySdk.js.map +1 -0
  35. package/build/src/runtime/store/Http.d.ts +14 -0
  36. package/build/src/runtime/store/Http.js +4 -0
  37. package/build/src/runtime/store/Http.js.map +1 -0
  38. package/build/src/runtime/store/HttpNode.d.ts +16 -0
  39. package/build/src/runtime/store/HttpNode.js +95 -0
  40. package/build/src/runtime/store/HttpNode.js.map +1 -0
  41. package/build/src/runtime/store/HttpWeb.d.ts +15 -0
  42. package/build/src/runtime/store/HttpWeb.js +83 -0
  43. package/build/src/runtime/store/HttpWeb.js.map +1 -0
  44. package/build/src/runtime/store/ProjectsSdk.d.ts +43 -0
  45. package/build/src/runtime/store/ProjectsSdk.js +144 -0
  46. package/build/src/runtime/store/ProjectsSdk.js.map +1 -0
  47. package/build/src/runtime/store/RouteBuilder.d.ts +42 -0
  48. package/build/src/runtime/store/RouteBuilder.js +75 -0
  49. package/build/src/runtime/store/RouteBuilder.js.map +1 -0
  50. package/build/src/runtime/store/Sdk.d.ts +79 -0
  51. package/build/src/runtime/store/Sdk.js +117 -0
  52. package/build/src/runtime/store/Sdk.js.map +1 -0
  53. package/build/src/runtime/store/SdkBase.d.ts +45 -0
  54. package/build/src/runtime/store/SdkBase.js +40 -0
  55. package/build/src/runtime/store/SdkBase.js.map +1 -0
  56. package/build/src/runtime/store/SpacesSdk.d.ts +50 -0
  57. package/build/src/runtime/store/SpacesSdk.js +185 -0
  58. package/build/src/runtime/store/SpacesSdk.js.map +1 -0
  59. package/build/src/runtime/store/StoreSdkNode.d.ts +10 -0
  60. package/build/src/runtime/store/StoreSdkNode.js +11 -0
  61. package/build/src/runtime/store/StoreSdkNode.js.map +1 -0
  62. package/build/src/runtime/store/StoreSdkWeb.d.ts +10 -0
  63. package/build/src/runtime/store/StoreSdkWeb.js +11 -0
  64. package/build/src/runtime/store/StoreSdkWeb.js.map +1 -0
  65. package/build/src/runtime/store/UsersSdk.d.ts +18 -0
  66. package/build/src/runtime/store/UsersSdk.js +88 -0
  67. package/build/src/runtime/store/UsersSdk.js.map +1 -0
  68. package/build/src/runtime/store/WsClient.d.ts +24 -0
  69. package/build/src/runtime/store/WsClient.js +4 -0
  70. package/build/src/runtime/store/WsClient.js.map +1 -0
  71. package/build/src/runtime/store/WsClientNode.d.ts +24 -0
  72. package/build/src/runtime/store/WsClientNode.js +66 -0
  73. package/build/src/runtime/store/WsClientNode.js.map +1 -0
  74. package/build/src/runtime/store/WsClientWeb.d.ts +23 -0
  75. package/build/src/runtime/store/WsClientWeb.js +73 -0
  76. package/build/src/runtime/store/WsClientWeb.js.map +1 -0
  77. package/package.json +4 -6
  78. package/src/models/HttpHistory.ts +30 -0
  79. package/src/models/HttpProject.ts +82 -1
  80. package/src/models/RequestLog.ts +17 -1
  81. package/src/runtime/node/InteropInterfaces.ts +121 -0
  82. package/src/runtime/node/ProjectParallelRunner.ts +2 -9
  83. package/src/runtime/node/ProjectRequestRunner.ts +42 -61
  84. package/src/runtime/node/ProjectRunner.ts +1 -60
  85. package/src/runtime/node/ProjectRunnerWorker.ts +2 -1
  86. package/src/runtime/store/AuthSdk.ts +126 -0
  87. package/src/runtime/store/BackendSdk.ts +25 -0
  88. package/src/runtime/store/HistorySdk.ts +157 -0
  89. package/src/runtime/store/Http.ts +18 -0
  90. package/src/runtime/store/HttpNode.ts +100 -0
  91. package/src/runtime/store/HttpWeb.ts +89 -0
  92. package/src/runtime/store/ProjectsSdk.ts +147 -0
  93. package/src/runtime/store/RouteBuilder.ts +89 -0
  94. package/src/runtime/store/Sdk.ts +131 -0
  95. package/src/runtime/store/SdkBase.ts +72 -0
  96. package/src/runtime/store/SpacesSdk.ts +190 -0
  97. package/src/runtime/store/StoreSdkNode.ts +13 -0
  98. package/src/runtime/store/StoreSdkWeb.ts +13 -0
  99. package/src/runtime/store/UsersSdk.ts +89 -0
  100. package/src/runtime/store/WsClient.ts +28 -0
  101. package/src/runtime/store/WsClientNode.ts +68 -0
  102. package/src/runtime/store/WsClientWeb.ts +75 -0
  103. package/build/src/models/HistoryIndex.d.ts +0 -45
  104. package/build/src/models/HistoryIndex.js +0 -56
  105. package/build/src/models/HistoryIndex.js.map +0 -1
  106. package/build/src/runtime/store/StoreSdk.d.ts +0 -279
  107. package/build/src/runtime/store/StoreSdk.js +0 -842
  108. package/build/src/runtime/store/StoreSdk.js.map +0 -1
  109. package/src/models/HistoryIndex.ts +0 -81
  110. package/src/runtime/store/StoreSdk.ts +0 -895
@@ -1,45 +0,0 @@
1
- export declare const Kind = "Core#HistoryIndex";
2
- /**
3
- * An object that is stored in API Client's internal store to build history navigation.
4
- * It does not contain all the history data. Just the ones that are presented in the UI.
5
- */
6
- export interface IHistoryIndex {
7
- kind: typeof Kind;
8
- /**
9
- * Timestamp when the request was last updated.
10
- */
11
- updated: number;
12
- /**
13
- * A timestamp of the midnight when the request object was updated
14
- */
15
- midnight: number;
16
- /**
17
- * The request URL
18
- */
19
- url: string;
20
- /**
21
- * HTTP method name
22
- */
23
- method: string;
24
- }
25
- export declare class HistoryIndex {
26
- /**
27
- * Timestamp when the request was last updated.
28
- */
29
- updated: number;
30
- /**
31
- * A timestamp of the midnight when the request object was updated
32
- */
33
- midnight: number;
34
- /**
35
- * The request URL
36
- */
37
- url: string;
38
- /**
39
- * HTTP method name
40
- */
41
- method: string;
42
- constructor(input?: string | IHistoryIndex);
43
- new(init: IHistoryIndex): void;
44
- toJSON(): IHistoryIndex;
45
- }
@@ -1,56 +0,0 @@
1
- export const Kind = 'Core#HistoryIndex';
2
- export class HistoryIndex {
3
- /**
4
- * Timestamp when the request was last updated.
5
- */
6
- updated = 0;
7
- /**
8
- * A timestamp of the midnight when the request object was updated
9
- */
10
- midnight = 0;
11
- /**
12
- * The request URL
13
- */
14
- url = '';
15
- /**
16
- * HTTP method name
17
- */
18
- method = 'GET';
19
- constructor(input) {
20
- let init;
21
- if (typeof input === 'string') {
22
- init = JSON.parse(input);
23
- }
24
- else if (typeof input === 'object') {
25
- init = input;
26
- }
27
- else {
28
- init = {
29
- kind: Kind,
30
- updated: 0,
31
- midnight: 0,
32
- url: '',
33
- method: 'GET',
34
- };
35
- }
36
- this.new(init);
37
- }
38
- new(init) {
39
- const { updated = 0, midnight = 0, url = '', method = 'GET' } = init;
40
- this.updated = updated;
41
- this.midnight = midnight;
42
- this.url = url;
43
- this.method = method;
44
- }
45
- toJSON() {
46
- const result = {
47
- kind: Kind,
48
- updated: this.updated,
49
- midnight: this.midnight,
50
- url: this.url,
51
- method: this.method,
52
- };
53
- return result;
54
- }
55
- }
56
- //# sourceMappingURL=HistoryIndex.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HistoryIndex.js","sourceRoot":"","sources":["../../../src/models/HistoryIndex.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,IAAI,GAAG,mBAAmB,CAAC;AA0BxC,MAAM,OAAO,YAAY;IACvB;;OAEG;IACH,OAAO,GAAG,CAAC,CAAC;IACZ;;OAEG;IACH,QAAQ,GAAG,CAAC,CAAC;IACb;;OAEG;IACH,GAAG,GAAG,EAAE,CAAC;IACT;;OAEG;IACH,MAAM,GAAG,KAAK,CAAC;IAEf,YAAY,KAA4B;QACtC,IAAI,IAAmB,CAAC;QACxB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SAC1B;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YACpC,IAAI,GAAG,KAAK,CAAC;SACd;aAAM;YACL,IAAI,GAAG;gBACL,IAAI,EAAE,IAAI;gBACV,OAAO,EAAE,CAAC;gBACV,QAAQ,EAAE,CAAC;gBACX,GAAG,EAAE,EAAE;gBACP,MAAM,EAAE,KAAK;aACd,CAAC;SACH;QACD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACjB,CAAC;IAED,GAAG,CAAC,IAAmB;QACrB,MAAM,EAAE,OAAO,GAAC,CAAC,EAAE,QAAQ,GAAC,CAAC,EAAE,GAAG,GAAC,EAAE,EAAE,MAAM,GAAC,KAAK,EAAE,GAAG,IAAI,CAAC;QAC7D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,MAAM;QACJ,MAAM,MAAM,GAAkB;YAC5B,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC;QACF,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
@@ -1,279 +0,0 @@
1
- /// <reference types="node" />
2
- import http from 'http';
3
- import WebSocket from 'ws';
4
- import { URL } from 'url';
5
- import { JsonPatch } from 'json8-patch';
6
- import { IBackendInfo, IListOptions, IListResponse } from '../../models/Backend.js';
7
- import { IWorkspace, IUserWorkspace, Workspace } from '../../models/Workspace.js';
8
- import { UserAccessOperation, IUser } from '../../models/User.js';
9
- import { HttpProject, IHttpProject } from '../../models/HttpProject.js';
10
- export interface IStoreRequestOptions {
11
- method?: 'GET' | 'POST' | 'PATCH' | 'DELETE';
12
- headers?: Record<string, string>;
13
- body?: string | Buffer;
14
- /**
15
- * Adds the token to the headers.
16
- */
17
- token?: string;
18
- }
19
- export interface IStoreResponse {
20
- status: number;
21
- headers: http.IncomingHttpHeaders;
22
- body?: string;
23
- }
24
- export interface IStoreTokenInfo {
25
- /**
26
- * The token to use.
27
- */
28
- token: string;
29
- /**
30
- * The timestamp when the token expires.
31
- * Note, clients may have a different date than the store.
32
- *
33
- * May not be set when the token does not expire.
34
- */
35
- expires?: number;
36
- }
37
- declare const baseUriSymbol: unique symbol;
38
- /**
39
- * NodeJS API for API Client's net-store module.
40
- */
41
- export declare class StoreSdk {
42
- basePath?: string | undefined;
43
- /**
44
- * The token to use with requests. Can be overwritten with each API call.
45
- */
46
- token?: string;
47
- /**
48
- * The user authentication features.
49
- */
50
- auth: AuthSdk;
51
- /**
52
- * The store information features
53
- */
54
- store: BackendSdk;
55
- /**
56
- * The user spaces features.
57
- */
58
- space: SpacesSdk;
59
- /**
60
- * The user projects features.
61
- */
62
- project: ProjectsSdk;
63
- /**
64
- * Reads user information.
65
- */
66
- user: UsersSdk;
67
- /**
68
- * The HTTP(S) requests.
69
- */
70
- http: HttpClient;
71
- /**
72
- * The web socket requests.
73
- */
74
- ws: WsClient;
75
- [baseUriSymbol]: string;
76
- /**
77
- * @returns The base URI to the store.
78
- */
79
- get baseUri(): string;
80
- /**
81
- * @param value The base URI to the store.
82
- */
83
- set baseUri(value: string);
84
- /**
85
- * @param baseUri The base URI to the store.
86
- * @param basePath The base path (the router prefix) for the server.
87
- */
88
- constructor(baseUri: string, basePath?: string | undefined);
89
- /**
90
- * Creates a full URL for a path.
91
- * This adds the server's base path and the passed path to the configured base URL.
92
- * @param path The path to the endpoint, without the base path.
93
- */
94
- getUrl(path?: string): URL;
95
- /**
96
- * Appends list options to the query parameters.
97
- * @param url The URL object to the API endpoint
98
- * @param options The list options, if any
99
- */
100
- appendListOptions(url: URL, options?: IListOptions): void;
101
- }
102
- declare class SdkBase {
103
- sdk: StoreSdk;
104
- constructor(sdk: StoreSdk);
105
- protected logInvalidResponse(response: IStoreResponse): void;
106
- /**
107
- * Throws unified message for a common error status codes.
108
- * It handles 404, 403, and 401 status codes.
109
- */
110
- protected inspectCommonStatusCodes(status: number): void;
111
- }
112
- declare class AuthSdk extends SdkBase {
113
- protected getExpires(headers: http.IncomingHttpHeaders): number | undefined;
114
- /**
115
- * Creates unauthenticated session in the backend.
116
- * @returns The JWT for unauthenticated user.
117
- */
118
- createSession(): Promise<IStoreTokenInfo>;
119
- /**
120
- * Initializes the authentication session.
121
- * @param token The unauthenticated session JWT. Required when not set on the class.
122
- * @returns The location of the authorization endpoint.
123
- */
124
- createAuthSession(token?: string, loginPath?: string): Promise<string>;
125
- /**
126
- * Listens to the first message coming to the client from the auth endpoint.
127
- * @param authPath The authorization path returned by the server info or 401 response.
128
- * @param token Optional token to use.
129
- */
130
- listenAuth(authPath: string, token?: string): Promise<void>;
131
- /**
132
- * Renews authenticated token to a new one when the token expires.
133
- * @param token Optional token to use.
134
- * @returns
135
- */
136
- renewToken(token?: string | undefined): Promise<IStoreTokenInfo>;
137
- }
138
- declare class BackendSdk extends SdkBase {
139
- /**
140
- * @returns Client information about the store configuration.
141
- */
142
- getInfo(): Promise<IBackendInfo>;
143
- }
144
- declare class SpacesSdk extends SdkBase {
145
- /**
146
- * Lists spaces in the store.
147
- * @param options Optional query options.
148
- */
149
- list(options?: IListOptions): Promise<IListResponse>;
150
- /**
151
- * Creates a workspace in the store.
152
- * @param space The workspace definition.
153
- * @returns The key of the creates space.
154
- */
155
- create(space: IWorkspace | Workspace): Promise<string>;
156
- /**
157
- * Reads a user space definition from the store.
158
- * @param key The user space key
159
- * @returns The definition of the user space.
160
- */
161
- read(key: string): Promise<IUserWorkspace>;
162
- /**
163
- * Patches a user space in the store.
164
- * @param key The key of the user space to patch
165
- * @param value The JSON patch to be processed.
166
- * @returns The JSON patch to revert the change using the `json8-patch` library
167
- */
168
- patch(key: string, value: JsonPatch): Promise<JsonPatch>;
169
- /**
170
- * Deletes the space in the store.
171
- *
172
- * @param key The key of the space to delete.
173
- */
174
- delete(key: string): Promise<void>;
175
- /**
176
- * Updates the sharing options of the space.
177
- *
178
- * @param key The user space key
179
- * @param value The patch operation on the space's ACL
180
- */
181
- patchUsers(key: string, value: UserAccessOperation[]): Promise<void>;
182
- /**
183
- * Lists uses having access to the user space.
184
- *
185
- * @param key The user space key
186
- */
187
- listUsers(key: string): Promise<IListResponse>;
188
- }
189
- declare class HttpClient extends SdkBase {
190
- /**
191
- * Performs the GET request.
192
- *
193
- * @param url The request URL
194
- * @param opts The request options
195
- * @returns The response info.
196
- */
197
- get(url: string, opts?: IStoreRequestOptions): Promise<IStoreResponse>;
198
- private _get;
199
- post(url: string, opts?: IStoreRequestOptions): Promise<IStoreResponse>;
200
- patch(url: string, opts?: IStoreRequestOptions): Promise<IStoreResponse>;
201
- delete(url: string, opts?: IStoreRequestOptions): Promise<IStoreResponse>;
202
- }
203
- declare class WsClient extends SdkBase {
204
- /**
205
- * Creates a WS client with optional token
206
- * @param addr The ws:// address
207
- * @param token Optional token to add.
208
- */
209
- getClient(addr: string, token?: string | undefined): WebSocket;
210
- /**
211
- * Connect to the WS server
212
- *
213
- * @param client The client to wait for connection.
214
- */
215
- connect(client: WebSocket): Promise<void>;
216
- /**
217
- * Disconnects from the WS server.
218
- */
219
- disconnect(client: WebSocket): Promise<void>;
220
- /**
221
- * The combination of `getClient()` and `connect()`.
222
- */
223
- createAndConnect(addr: string, token?: string): Promise<WebSocket>;
224
- }
225
- declare class ProjectsSdk extends SdkBase {
226
- /**
227
- * Creates a project in a user space.
228
- *
229
- * @param key The user space key
230
- * @param project THe project to create
231
- * @returns The key of the created project.
232
- */
233
- create(key: string, project: IHttpProject | HttpProject): Promise<string>;
234
- /**
235
- * Reads a project definition from the store.
236
- * @param space The user space key
237
- * @param project The project key
238
- * @returns The definition of the project.
239
- */
240
- read(space: string, project: string): Promise<IHttpProject>;
241
- /**
242
- * Lists projects in the space
243
- *
244
- * @param space The user space key
245
- * @param options Optional query options.
246
- */
247
- list(space: string, options?: IListOptions): Promise<IListResponse>;
248
- /**
249
- * Deletes a project form the store.
250
- *
251
- * @param space The key of the parent space.
252
- * @param project The key of the project to delete.
253
- */
254
- delete(space: string, project: string): Promise<void>;
255
- /**
256
- * Patches a project in the store.
257
- * @param space The key of the parent user space
258
- * @param project The key of project to patch.
259
- * @param value The JSON patch to be processed.
260
- * @returns The JSON patch to revert the change using the `json8-patch` library
261
- */
262
- patch(space: string, project: string, value: JsonPatch): Promise<JsonPatch>;
263
- }
264
- declare class UsersSdk extends SdkBase {
265
- me(): Promise<IUser>;
266
- /**
267
- * Lists users in the store
268
- *
269
- * @param options Optional query options.
270
- */
271
- list(options?: IListOptions): Promise<IListResponse>;
272
- /**
273
- * Reads a user information from the store.
274
- * @param key The user key.
275
- * @returns The user object
276
- */
277
- read(key: string): Promise<IUser>;
278
- }
279
- export {};