@api-client/core 0.4.0 → 0.4.1
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.
- package/build/browser.d.ts +5 -2
- package/build/browser.js +7 -2
- package/build/browser.js.map +1 -1
- package/build/index.d.ts +6 -4
- package/build/index.js +4 -3
- package/build/index.js.map +1 -1
- package/build/src/models/HttpHistory.d.ts +29 -0
- package/build/src/models/HttpHistory.js.map +1 -1
- package/build/src/models/RequestLog.d.ts +8 -0
- package/build/src/models/RequestLog.js +14 -1
- package/build/src/models/RequestLog.js.map +1 -1
- package/build/src/runtime/node/InteropInterfaces.d.ts +115 -0
- package/build/src/runtime/node/InteropInterfaces.js +2 -0
- package/build/src/runtime/node/InteropInterfaces.js.map +1 -0
- package/build/src/runtime/node/ProjectParallelRunner.d.ts +2 -7
- package/build/src/runtime/node/ProjectParallelRunner.js.map +1 -1
- package/build/src/runtime/node/ProjectRequestRunner.d.ts +17 -49
- package/build/src/runtime/node/ProjectRequestRunner.js +39 -10
- package/build/src/runtime/node/ProjectRequestRunner.js.map +1 -1
- package/build/src/runtime/node/ProjectRunner.d.ts +1 -59
- package/build/src/runtime/node/ProjectRunner.js.map +1 -1
- package/build/src/runtime/node/ProjectRunnerWorker.js.map +1 -1
- package/build/src/runtime/store/AuthSdk.d.ts +28 -0
- package/build/src/runtime/store/AuthSdk.js +123 -0
- package/build/src/runtime/store/AuthSdk.js.map +1 -0
- package/build/src/runtime/store/BackendSdk.d.ts +8 -0
- package/build/src/runtime/store/BackendSdk.js +25 -0
- package/build/src/runtime/store/BackendSdk.js.map +1 -0
- package/build/src/runtime/store/HistorySdk.d.ts +48 -0
- package/build/src/runtime/store/HistorySdk.js +142 -0
- package/build/src/runtime/store/HistorySdk.js.map +1 -0
- package/build/src/runtime/store/Http.d.ts +14 -0
- package/build/src/runtime/store/Http.js +4 -0
- package/build/src/runtime/store/Http.js.map +1 -0
- package/build/src/runtime/store/HttpNode.d.ts +16 -0
- package/build/src/runtime/store/HttpNode.js +95 -0
- package/build/src/runtime/store/HttpNode.js.map +1 -0
- package/build/src/runtime/store/HttpWeb.d.ts +15 -0
- package/build/src/runtime/store/HttpWeb.js +83 -0
- package/build/src/runtime/store/HttpWeb.js.map +1 -0
- package/build/src/runtime/store/ProjectsSdk.d.ts +43 -0
- package/build/src/runtime/store/ProjectsSdk.js +144 -0
- package/build/src/runtime/store/ProjectsSdk.js.map +1 -0
- package/build/src/runtime/store/RouteBuilder.d.ts +42 -0
- package/build/src/runtime/store/RouteBuilder.js +75 -0
- package/build/src/runtime/store/RouteBuilder.js.map +1 -0
- package/build/src/runtime/store/Sdk.d.ts +79 -0
- package/build/src/runtime/store/Sdk.js +117 -0
- package/build/src/runtime/store/Sdk.js.map +1 -0
- package/build/src/runtime/store/SdkBase.d.ts +45 -0
- package/build/src/runtime/store/SdkBase.js +40 -0
- package/build/src/runtime/store/SdkBase.js.map +1 -0
- package/build/src/runtime/store/SpacesSdk.d.ts +50 -0
- package/build/src/runtime/store/SpacesSdk.js +185 -0
- package/build/src/runtime/store/SpacesSdk.js.map +1 -0
- package/build/src/runtime/store/StoreSdkNode.d.ts +10 -0
- package/build/src/runtime/store/StoreSdkNode.js +11 -0
- package/build/src/runtime/store/StoreSdkNode.js.map +1 -0
- package/build/src/runtime/store/StoreSdkWeb.d.ts +10 -0
- package/build/src/runtime/store/StoreSdkWeb.js +11 -0
- package/build/src/runtime/store/StoreSdkWeb.js.map +1 -0
- package/build/src/runtime/store/UsersSdk.d.ts +18 -0
- package/build/src/runtime/store/UsersSdk.js +88 -0
- package/build/src/runtime/store/UsersSdk.js.map +1 -0
- package/build/src/runtime/store/WsClient.d.ts +24 -0
- package/build/src/runtime/store/WsClient.js +4 -0
- package/build/src/runtime/store/WsClient.js.map +1 -0
- package/build/src/runtime/store/WsClientNode.d.ts +24 -0
- package/build/src/runtime/store/WsClientNode.js +66 -0
- package/build/src/runtime/store/WsClientNode.js.map +1 -0
- package/build/src/runtime/store/WsClientWeb.d.ts +23 -0
- package/build/src/runtime/store/WsClientWeb.js +73 -0
- package/build/src/runtime/store/WsClientWeb.js.map +1 -0
- package/package.json +4 -6
- package/src/models/HttpHistory.ts +30 -0
- package/src/models/RequestLog.ts +17 -1
- package/src/runtime/node/InteropInterfaces.ts +121 -0
- package/src/runtime/node/ProjectParallelRunner.ts +2 -9
- package/src/runtime/node/ProjectRequestRunner.ts +42 -61
- package/src/runtime/node/ProjectRunner.ts +1 -60
- package/src/runtime/node/ProjectRunnerWorker.ts +2 -1
- package/src/runtime/store/AuthSdk.ts +126 -0
- package/src/runtime/store/BackendSdk.ts +25 -0
- package/src/runtime/store/HistorySdk.ts +157 -0
- package/src/runtime/store/Http.ts +18 -0
- package/src/runtime/store/HttpNode.ts +100 -0
- package/src/runtime/store/HttpWeb.ts +89 -0
- package/src/runtime/store/ProjectsSdk.ts +147 -0
- package/src/runtime/store/RouteBuilder.ts +89 -0
- package/src/runtime/store/Sdk.ts +131 -0
- package/src/runtime/store/SdkBase.ts +72 -0
- package/src/runtime/store/SpacesSdk.ts +190 -0
- package/src/runtime/store/StoreSdkNode.ts +13 -0
- package/src/runtime/store/StoreSdkWeb.ts +13 -0
- package/src/runtime/store/UsersSdk.ts +89 -0
- package/src/runtime/store/WsClient.ts +28 -0
- package/src/runtime/store/WsClientNode.ts +68 -0
- package/src/runtime/store/WsClientWeb.ts +75 -0
- package/build/src/models/HistoryIndex.d.ts +0 -45
- package/build/src/models/HistoryIndex.js +0 -56
- package/build/src/models/HistoryIndex.js.map +0 -1
- package/build/src/runtime/store/StoreSdk.d.ts +0 -279
- package/build/src/runtime/store/StoreSdk.js +0 -842
- package/build/src/runtime/store/StoreSdk.js.map +0 -1
- package/src/models/HistoryIndex.ts +0 -81
- package/src/runtime/store/StoreSdk.ts +0 -895
|
@@ -0,0 +1,89 @@
|
|
|
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
|
+
import { IUser } from '../../models/User.js';
|
|
5
|
+
|
|
6
|
+
export class UsersSdk extends SdkBase {
|
|
7
|
+
async me(): Promise<IUser> {
|
|
8
|
+
const { token } = this.sdk;
|
|
9
|
+
const url = this.sdk.getUrl(RouteBuilder.usersMe());
|
|
10
|
+
const result = await this.sdk.http.get(url.toString(), { token });
|
|
11
|
+
this.inspectCommonStatusCodes(result.status);
|
|
12
|
+
const E_PREFIX = 'Unable to read a user. ';
|
|
13
|
+
if (result.status !== 200) {
|
|
14
|
+
this.logInvalidResponse(result);
|
|
15
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
|
|
16
|
+
}
|
|
17
|
+
if (!result.body) {
|
|
18
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
19
|
+
}
|
|
20
|
+
let data: IUser;
|
|
21
|
+
try {
|
|
22
|
+
data = JSON.parse(result.body);
|
|
23
|
+
} catch (e) {
|
|
24
|
+
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
25
|
+
}
|
|
26
|
+
if (!data.key) {
|
|
27
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
|
|
28
|
+
}
|
|
29
|
+
return data;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Lists users in the store
|
|
34
|
+
*
|
|
35
|
+
* @param options Optional query options.
|
|
36
|
+
*/
|
|
37
|
+
async list(options?: IListOptions): Promise<IListResponse> {
|
|
38
|
+
const { token } = this.sdk;
|
|
39
|
+
const url = this.sdk.getUrl(RouteBuilder.users());
|
|
40
|
+
this.sdk.appendListOptions(url, options);
|
|
41
|
+
const result = await this.sdk.http.get(url.toString(), { token });
|
|
42
|
+
this.inspectCommonStatusCodes(result.status);
|
|
43
|
+
const E_PREFIX = 'Unable to list projects. ';
|
|
44
|
+
if (result.status !== 200) {
|
|
45
|
+
this.logInvalidResponse(result);
|
|
46
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
|
|
47
|
+
}
|
|
48
|
+
if (!result.body) {
|
|
49
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
50
|
+
}
|
|
51
|
+
let data: IListResponse;
|
|
52
|
+
try {
|
|
53
|
+
data = JSON.parse(result.body);
|
|
54
|
+
} catch (e) {
|
|
55
|
+
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
56
|
+
}
|
|
57
|
+
if (!Array.isArray(data.data)) {
|
|
58
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_UNKNOWN}.`);
|
|
59
|
+
}
|
|
60
|
+
return data;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Reads a user information from the store.
|
|
65
|
+
* @param key The user key.
|
|
66
|
+
* @returns The user object
|
|
67
|
+
*/
|
|
68
|
+
async read(key: string): Promise<IUser> {
|
|
69
|
+
const { token } = this.sdk;
|
|
70
|
+
const url = this.sdk.getUrl(RouteBuilder.user(key));
|
|
71
|
+
const result = await this.sdk.http.get(url.toString(), { token });
|
|
72
|
+
this.inspectCommonStatusCodes(result.status);
|
|
73
|
+
const E_PREFIX = 'Unable to read the user info. ';
|
|
74
|
+
if (result.status !== 200) {
|
|
75
|
+
this.logInvalidResponse(result);
|
|
76
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`);
|
|
77
|
+
}
|
|
78
|
+
if (!result.body) {
|
|
79
|
+
throw new Error(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`);
|
|
80
|
+
}
|
|
81
|
+
let data: IUser;
|
|
82
|
+
try {
|
|
83
|
+
data = JSON.parse(result.body);
|
|
84
|
+
} catch (e) {
|
|
85
|
+
throw new Error(`${E_PREFIX}${E_INVALID_JSON}.`);
|
|
86
|
+
}
|
|
87
|
+
return data;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import WebSocketNode from 'ws';
|
|
2
|
+
import { SdkBase } from './SdkBase.js';
|
|
3
|
+
|
|
4
|
+
export abstract class WsClient extends SdkBase {
|
|
5
|
+
/**
|
|
6
|
+
* Creates a WS client with optional token
|
|
7
|
+
* @param addr The ws:// address
|
|
8
|
+
* @param token Optional token to add.
|
|
9
|
+
*/
|
|
10
|
+
abstract getClient(addr: string, token?: string): WebSocket | WebSocketNode;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Connect to the WS server
|
|
14
|
+
*
|
|
15
|
+
* @param client The client to wait for connection.
|
|
16
|
+
*/
|
|
17
|
+
abstract connect(client: WebSocket | WebSocketNode): Promise<void>;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Disconnects from the WS server.
|
|
21
|
+
*/
|
|
22
|
+
abstract disconnect(client: WebSocket | WebSocketNode): Promise<void>;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The combination of `getClient()` and `connect()`.
|
|
26
|
+
*/
|
|
27
|
+
abstract createAndConnect(addr: string, token?: string): Promise<WebSocket | WebSocketNode>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import WebSocket from 'ws';
|
|
2
|
+
import { WsClient } from './WsClient.js';
|
|
3
|
+
|
|
4
|
+
export class WsClientNode extends WsClient {
|
|
5
|
+
/**
|
|
6
|
+
* Creates a WS client with optional token
|
|
7
|
+
* @param addr The ws:// address
|
|
8
|
+
* @param token Optional token to add.
|
|
9
|
+
*/
|
|
10
|
+
getClient(addr: string, token = this.sdk.token): WebSocket {
|
|
11
|
+
let url = addr;
|
|
12
|
+
if (token) {
|
|
13
|
+
url += url.includes('?') ? '&' : '?';
|
|
14
|
+
url += 'token=';
|
|
15
|
+
url += token;
|
|
16
|
+
}
|
|
17
|
+
if (url.startsWith('http:')) {
|
|
18
|
+
url = `ws:${url.substring(5)}`;
|
|
19
|
+
} else if (url.startsWith('https:')) {
|
|
20
|
+
url = `wss:${url.substring(6)}`;
|
|
21
|
+
}
|
|
22
|
+
return new WebSocket(url);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Connect to the WS server
|
|
27
|
+
*
|
|
28
|
+
* @param client The client to wait for connection.
|
|
29
|
+
*/
|
|
30
|
+
connect(client: WebSocket): Promise<void> {
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
client.once('open', () => {
|
|
33
|
+
client.removeAllListeners('error');
|
|
34
|
+
resolve();
|
|
35
|
+
});
|
|
36
|
+
client.once('error', (err) => {
|
|
37
|
+
client.removeAllListeners('open');
|
|
38
|
+
reject(err);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Disconnects from the WS server.
|
|
45
|
+
*/
|
|
46
|
+
disconnect(client: WebSocket): Promise<void> {
|
|
47
|
+
return new Promise((resolve, reject) => {
|
|
48
|
+
client.once('close', () => {
|
|
49
|
+
client.removeAllListeners('error');
|
|
50
|
+
resolve();
|
|
51
|
+
});
|
|
52
|
+
client.once('error', (err) => {
|
|
53
|
+
client.removeAllListeners('close');
|
|
54
|
+
reject(err);
|
|
55
|
+
});
|
|
56
|
+
client.close();
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The combination of `getClient()` and `connect()`.
|
|
62
|
+
*/
|
|
63
|
+
async createAndConnect(addr: string, token?: string): Promise<WebSocket> {
|
|
64
|
+
const client = this.getClient(addr, token);
|
|
65
|
+
await this.connect(client);
|
|
66
|
+
return client;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { WsClient } from './WsClient.js';
|
|
2
|
+
|
|
3
|
+
export class WsClientWeb extends WsClient {
|
|
4
|
+
/**
|
|
5
|
+
* Creates a WS client with optional token
|
|
6
|
+
* @param addr The ws:// address
|
|
7
|
+
* @param token Optional token to add.
|
|
8
|
+
*/
|
|
9
|
+
getClient(addr: string, token = this.sdk.token): WebSocket {
|
|
10
|
+
let url = addr;
|
|
11
|
+
if (token) {
|
|
12
|
+
url += url.includes('?') ? '&' : '?';
|
|
13
|
+
url += 'token=';
|
|
14
|
+
url += token;
|
|
15
|
+
}
|
|
16
|
+
if (url.startsWith('http:')) {
|
|
17
|
+
url = `ws:${url.substring(5)}`;
|
|
18
|
+
} else if (url.startsWith('https:')) {
|
|
19
|
+
url = `wss:${url.substring(6)}`;
|
|
20
|
+
}
|
|
21
|
+
return new WebSocket(url);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Connect to the WS server
|
|
26
|
+
*
|
|
27
|
+
* @param client The client to wait for connection.
|
|
28
|
+
*/
|
|
29
|
+
connect(client: WebSocket): Promise<void> {
|
|
30
|
+
return new Promise((resolve, reject) => {
|
|
31
|
+
function opened(): void {
|
|
32
|
+
client.removeEventListener('open', opened);
|
|
33
|
+
client.removeEventListener('error', errored);
|
|
34
|
+
resolve();
|
|
35
|
+
}
|
|
36
|
+
function errored(): void {
|
|
37
|
+
client.removeEventListener('open', opened);
|
|
38
|
+
client.removeEventListener('error', errored);
|
|
39
|
+
reject(new Error(`Unable to connect to: ${client.url}`));
|
|
40
|
+
}
|
|
41
|
+
client.addEventListener('open', opened);
|
|
42
|
+
client.addEventListener('error', errored);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Disconnects from the WS server.
|
|
48
|
+
*/
|
|
49
|
+
disconnect(client: WebSocket): Promise<void> {
|
|
50
|
+
return new Promise((resolve, reject) => {
|
|
51
|
+
function closed(): void {
|
|
52
|
+
client.removeEventListener('close', closed);
|
|
53
|
+
client.removeEventListener('error', errored);
|
|
54
|
+
resolve();
|
|
55
|
+
}
|
|
56
|
+
function errored(): void {
|
|
57
|
+
client.removeEventListener('close', closed);
|
|
58
|
+
client.removeEventListener('error', errored);
|
|
59
|
+
reject(new Error(`Unable to connect to: ${client.url}`));
|
|
60
|
+
}
|
|
61
|
+
client.addEventListener('close', closed);
|
|
62
|
+
client.addEventListener('error', errored);
|
|
63
|
+
client.close();
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The combination of `getClient()` and `connect()`.
|
|
69
|
+
*/
|
|
70
|
+
async createAndConnect(addr: string, token?: string): Promise<WebSocket> {
|
|
71
|
+
const client = this.getClient(addr, token);
|
|
72
|
+
await this.connect(client);
|
|
73
|
+
return client;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -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 {};
|