@hahnpro/hpc-api 6.0.0 → 2024.4.0-0
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/package.json +8 -24
- package/src/index.d.ts +20 -0
- package/src/index.js +20 -0
- package/{dist → src/lib}/Queue.js +2 -7
- package/src/lib/api-base.js +6 -0
- package/src/lib/api.js +60 -0
- package/src/lib/asset.interface.js +1 -0
- package/{dist → src/lib}/asset.service.js +21 -17
- package/src/lib/assettypes.service.js +24 -0
- package/{dist → src/lib}/content.interface.js +2 -5
- package/src/lib/content.service.js +49 -0
- package/src/lib/data.interface.js +3 -0
- package/{dist → src/lib}/data.service.js +18 -11
- package/src/lib/endpoint.interface.js +1 -0
- package/{dist → src/lib}/endpoint.service.d.ts +2 -2
- package/{dist → src/lib}/endpoint.service.js +2 -6
- package/src/lib/events.interface.js +1 -0
- package/src/lib/events.service.js +9 -0
- package/src/lib/flow-deployment.interface.js +1 -0
- package/src/lib/flow-deployment.service.js +68 -0
- package/src/lib/flow-function.interface.js +1 -0
- package/{dist → src/lib}/flow-function.service.js +3 -6
- package/src/lib/flow-module.interface.js +1 -0
- package/{dist → src/lib}/flow-module.service.js +8 -7
- package/src/lib/flow.interface.js +1 -0
- package/{dist → src/lib}/flow.service.js +15 -20
- package/src/lib/http.service.js +179 -0
- package/src/lib/label.interface.js +1 -0
- package/{dist → src/lib}/label.service.js +2 -6
- package/src/lib/mock/api-base.mock.js +7 -0
- package/src/lib/mock/api.mock.js +199 -0
- package/{dist → src/lib}/mock/asset.mock.service.js +30 -41
- package/{dist → src/lib}/mock/assetTypes.mock.service.js +19 -27
- package/{dist → src/lib}/mock/content.mock.service.js +21 -24
- package/src/lib/mock/data.mock.service.js +93 -0
- package/{dist → src/lib}/mock/endpoint.mock.service.js +2 -6
- package/src/lib/mock/events.mock.service.js +10 -0
- package/src/lib/mock/flow-deployment.mock.service.js +118 -0
- package/{dist → src/lib}/mock/flow-functions.mock.service.js +12 -21
- package/src/lib/mock/flow-modules.mock.service.js +20 -0
- package/src/lib/mock/flow.mock.service.js +81 -0
- package/src/lib/mock/index.js +11 -0
- package/src/lib/mock/label.mock.service.js +13 -0
- package/src/lib/mock/notification.mock.service.js +7 -0
- package/src/lib/mock/secret.mock.service.js +28 -0
- package/src/lib/mock/task.mock.service.js +32 -0
- package/{dist → src/lib}/mock/timeseries.mock.service.js +40 -49
- package/{dist → src/lib}/mock/trash.mock.service.js +8 -15
- package/src/lib/mock/user.mock.service.js +10 -0
- package/{dist → src/lib}/mock/vault.mock.service.js +2 -6
- package/src/lib/notification.interface.js +1 -0
- package/src/lib/notification.service.js +6 -0
- package/{dist → src/lib}/proxy.service.js +1 -5
- package/src/lib/resource.interface.js +1 -0
- package/src/lib/schema.interface.js +1 -0
- package/src/lib/secret.interface.js +1 -0
- package/src/lib/secret.service.js +15 -0
- package/src/lib/storage.interface.js +1 -0
- package/src/lib/task.interface.js +1 -0
- package/src/lib/task.service.js +19 -0
- package/src/lib/timeseries.interface.js +1 -0
- package/src/lib/timeseries.service.js +92 -0
- package/{dist → src/lib}/token-set.js +3 -7
- package/{dist → src/lib}/trash.service.js +2 -6
- package/src/lib/user-settings.interface.js +1 -0
- package/src/lib/user.service.js +26 -0
- package/src/lib/vault.interface.js +1 -0
- package/src/lib/vault.service.js +10 -0
- package/LICENSE +0 -21
- package/dist/api-base.js +0 -10
- package/dist/api.js +0 -62
- package/dist/asset.interface.js +0 -2
- package/dist/assettypes.service.js +0 -28
- package/dist/content.service.js +0 -50
- package/dist/data.interface.js +0 -6
- package/dist/endpoint.interface.js +0 -2
- package/dist/events.interface.js +0 -2
- package/dist/events.service.js +0 -13
- package/dist/flow-deployment.interface.js +0 -2
- package/dist/flow-deployment.service.js +0 -74
- package/dist/flow-function.interface.js +0 -2
- package/dist/flow-module.interface.js +0 -2
- package/dist/flow.interface.js +0 -2
- package/dist/http.service.js +0 -182
- package/dist/index.d.ts +0 -20
- package/dist/index.js +0 -23
- package/dist/label.interface.js +0 -2
- package/dist/mock/api-base.mock.js +0 -11
- package/dist/mock/api.mock.js +0 -128
- package/dist/mock/data.mock.service.js +0 -96
- package/dist/mock/events.mock.service.js +0 -14
- package/dist/mock/flow-deployment.mock.service.js +0 -142
- package/dist/mock/flow-modules.mock.service.js +0 -27
- package/dist/mock/flow.mock.service.js +0 -93
- package/dist/mock/index.js +0 -14
- package/dist/mock/label.mock.service.js +0 -17
- package/dist/mock/notification.mock.service.js +0 -11
- package/dist/mock/secret.mock.service.js +0 -31
- package/dist/mock/task.mock.service.js +0 -37
- package/dist/mock/user.mock.service.js +0 -14
- package/dist/notification.interface.js +0 -2
- package/dist/notification.service.js +0 -10
- package/dist/resource.interface.js +0 -2
- package/dist/schema.interface.js +0 -2
- package/dist/secret.interface.js +0 -2
- package/dist/secret.service.js +0 -19
- package/dist/storage.interface.js +0 -2
- package/dist/task.interface.js +0 -2
- package/dist/task.service.js +0 -22
- package/dist/timeseries.interface.js +0 -2
- package/dist/timeseries.service.js +0 -56
- package/dist/user-settings.interface.js +0 -2
- package/dist/user.service.js +0 -33
- package/dist/vault.interface.js +0 -2
- package/dist/vault.service.js +0 -14
- package/{dist → src/lib}/Queue.d.ts +0 -0
- package/{dist → src/lib}/api-base.d.ts +0 -0
- package/{dist → src/lib}/api.d.ts +6 -6
- package/{dist → src/lib}/asset.interface.d.ts +0 -0
- package/{dist → src/lib}/asset.service.d.ts +0 -0
- package/{dist → src/lib}/assettypes.service.d.ts +0 -0
- package/{dist → src/lib}/content.interface.d.ts +0 -0
- package/{dist → src/lib}/content.service.d.ts +1 -1
- package/{dist → src/lib}/data.interface.d.ts +0 -0
- package/{dist → src/lib}/data.service.d.ts +0 -0
- package/{dist → src/lib}/endpoint.interface.d.ts +0 -0
- package/{dist → src/lib}/events.interface.d.ts +0 -0
- package/{dist → src/lib}/events.service.d.ts +0 -0
- package/{dist → src/lib}/flow-deployment.interface.d.ts +1 -1
- package/{dist → src/lib}/flow-deployment.service.d.ts +0 -0
- package/{dist → src/lib}/flow-function.interface.d.ts +0 -0
- package/{dist → src/lib}/flow-function.service.d.ts +1 -1
- package/{dist → src/lib}/flow-module.interface.d.ts +0 -0
- package/{dist → src/lib}/flow-module.service.d.ts +1 -1
- package/{dist → src/lib}/flow.interface.d.ts +1 -1
- package/{dist → src/lib}/flow.service.d.ts +1 -1
- package/{dist → src/lib}/http.service.d.ts +0 -0
- package/{dist → src/lib}/label.interface.d.ts +0 -0
- package/{dist → src/lib}/label.service.d.ts +0 -0
- package/{dist → src/lib}/mock/api-base.mock.d.ts +0 -0
- package/{dist → src/lib}/mock/api.mock.d.ts +18 -18
- package/{dist → src/lib}/mock/asset.mock.service.d.ts +1 -1
- package/{dist → src/lib}/mock/assetTypes.mock.service.d.ts +0 -0
- package/{dist → src/lib}/mock/content.mock.service.d.ts +1 -1
- package/{dist → src/lib}/mock/data.mock.service.d.ts +0 -0
- package/{dist → src/lib}/mock/endpoint.mock.service.d.ts +0 -0
- package/{dist → src/lib}/mock/events.mock.service.d.ts +0 -0
- package/{dist → src/lib}/mock/flow-deployment.mock.service.d.ts +2 -2
- package/{dist → src/lib}/mock/flow-functions.mock.service.d.ts +1 -1
- package/{dist → src/lib}/mock/flow-modules.mock.service.d.ts +2 -2
- package/{dist → src/lib}/mock/flow.mock.service.d.ts +1 -1
- package/{dist → src/lib}/mock/index.d.ts +0 -0
- package/{dist → src/lib}/mock/label.mock.service.d.ts +1 -1
- package/{dist → src/lib}/mock/notification.mock.service.d.ts +1 -1
- package/{dist → src/lib}/mock/secret.mock.service.d.ts +1 -1
- package/{dist → src/lib}/mock/task.mock.service.d.ts +0 -0
- package/{dist → src/lib}/mock/timeseries.mock.service.d.ts +0 -0
- package/{dist → src/lib}/mock/trash.mock.service.d.ts +1 -1
- package/{dist → src/lib}/mock/user.mock.service.d.ts +0 -0
- package/{dist → src/lib}/mock/vault.mock.service.d.ts +1 -1
- package/{dist → src/lib}/notification.interface.d.ts +0 -0
- package/{dist → src/lib}/notification.service.d.ts +1 -1
- package/{dist → src/lib}/proxy.service.d.ts +0 -0
- package/{dist → src/lib}/resource.interface.d.ts +0 -0
- package/{dist → src/lib}/schema.interface.d.ts +0 -0
- package/{dist → src/lib}/secret.interface.d.ts +0 -0
- package/{dist → src/lib}/secret.service.d.ts +0 -0
- package/{dist → src/lib}/storage.interface.d.ts +0 -0
- package/{dist → src/lib}/task.interface.d.ts +0 -0
- package/{dist → src/lib}/task.service.d.ts +0 -0
- package/{dist → src/lib}/timeseries.interface.d.ts +0 -0
- package/{dist → src/lib}/timeseries.service.d.ts +0 -0
- package/{dist → src/lib}/token-set.d.ts +0 -0
- package/{dist → src/lib}/trash.service.d.ts +0 -0
- package/{dist → src/lib}/user-settings.interface.d.ts +0 -0
- package/{dist → src/lib}/user.service.d.ts +0 -0
- package/{dist → src/lib}/vault.interface.d.ts +0 -0
- package/{dist → src/lib}/vault.service.d.ts +1 -1
package/package.json
CHANGED
|
@@ -1,28 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hahnpro/hpc-api",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Module for easy access to the HahnPRO API",
|
|
3
|
+
"version": "2024.4.0-0",
|
|
4
|
+
"description": "Module for easy access to the HahnPRO Cloud API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Hahn Projects GmbH",
|
|
8
8
|
"url": "https://hahnpro.com"
|
|
9
9
|
},
|
|
10
|
-
"repository": {
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": "git@github.com:hahnprojects/flow.git"
|
|
13
|
-
},
|
|
14
|
-
"directories": {
|
|
15
|
-
"lib": "lib",
|
|
16
|
-
"test": "test"
|
|
17
|
-
},
|
|
18
|
-
"files": [
|
|
19
|
-
"dist"
|
|
20
|
-
],
|
|
21
|
-
"main": "./dist/index.js",
|
|
22
|
-
"types": "./dist/index.d.ts",
|
|
23
|
-
"publishConfig": {
|
|
24
|
-
"access": "public"
|
|
25
|
-
},
|
|
26
10
|
"dependencies": {
|
|
27
11
|
"axios": "1.7.9",
|
|
28
12
|
"eventsource": "2.0.2",
|
|
@@ -31,17 +15,17 @@
|
|
|
31
15
|
"jwt-decode": "4.0.0",
|
|
32
16
|
"p-queue": "6.6.2",
|
|
33
17
|
"ts-mixer": "6.0.4",
|
|
34
|
-
"
|
|
18
|
+
"tslib": "2.8.1"
|
|
35
19
|
},
|
|
36
20
|
"devDependencies": {
|
|
37
21
|
"@types/eventsource": "1.1.15",
|
|
38
22
|
"axios-mock-adapter": "2.1.0"
|
|
39
23
|
},
|
|
40
24
|
"engines": {
|
|
41
|
-
"node": ">=
|
|
25
|
+
"node": ">=v20"
|
|
42
26
|
},
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
27
|
+
"main": "./src/index.js",
|
|
28
|
+
"types": "./src/index.d.ts",
|
|
29
|
+
"module": "./lib/hpc-api/src/index.js",
|
|
30
|
+
"type": "module"
|
|
47
31
|
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export * from './lib/api';
|
|
2
|
+
export * from './lib/asset.interface';
|
|
3
|
+
export * from './lib/content.interface';
|
|
4
|
+
export * from './lib/data.interface';
|
|
5
|
+
export * from './lib/data.service';
|
|
6
|
+
export * from './lib/endpoint.interface';
|
|
7
|
+
export * from './lib/events.interface';
|
|
8
|
+
export * from './lib/flow.interface';
|
|
9
|
+
export * from './lib/flow-deployment.interface';
|
|
10
|
+
export * from './lib/flow-function.interface';
|
|
11
|
+
export * from './lib/http.service';
|
|
12
|
+
export * from './lib/label.interface';
|
|
13
|
+
export * from './lib/mock';
|
|
14
|
+
export * from './lib/notification.interface';
|
|
15
|
+
export * from './lib/resource.interface';
|
|
16
|
+
export * from './lib/schema.interface';
|
|
17
|
+
export * from './lib/secret.interface';
|
|
18
|
+
export * from './lib/task.interface';
|
|
19
|
+
export * from './lib/timeseries.interface';
|
|
20
|
+
export * from './lib/vault.interface';
|
package/src/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export * from './lib/api';
|
|
2
|
+
export * from './lib/asset.interface';
|
|
3
|
+
export * from './lib/content.interface';
|
|
4
|
+
export * from './lib/data.interface';
|
|
5
|
+
export * from './lib/data.service';
|
|
6
|
+
export * from './lib/endpoint.interface';
|
|
7
|
+
export * from './lib/events.interface';
|
|
8
|
+
export * from './lib/flow.interface';
|
|
9
|
+
export * from './lib/flow-deployment.interface';
|
|
10
|
+
export * from './lib/flow-function.interface';
|
|
11
|
+
export * from './lib/http.service';
|
|
12
|
+
export * from './lib/label.interface';
|
|
13
|
+
export * from './lib/mock';
|
|
14
|
+
export * from './lib/notification.interface';
|
|
15
|
+
export * from './lib/resource.interface';
|
|
16
|
+
export * from './lib/schema.interface';
|
|
17
|
+
export * from './lib/secret.interface';
|
|
18
|
+
export * from './lib/task.interface';
|
|
19
|
+
export * from './lib/timeseries.interface';
|
|
20
|
+
export * from './lib/vault.interface';
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Queue = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const p_queue_1 = tslib_1.__importDefault(require("p-queue"));
|
|
6
|
-
class Queue extends p_queue_1.default {
|
|
1
|
+
import PQueue from 'p-queue';
|
|
2
|
+
export class Queue extends PQueue {
|
|
7
3
|
constructor(options) {
|
|
8
4
|
super(options);
|
|
9
5
|
this.peak = 0;
|
|
@@ -24,4 +20,3 @@ class Queue extends p_queue_1.default {
|
|
|
24
20
|
};
|
|
25
21
|
}
|
|
26
22
|
}
|
|
27
|
-
exports.Queue = Queue;
|
package/src/lib/api.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { AssetService } from './asset.service';
|
|
2
|
+
import { AssetTypesService } from './assettypes.service';
|
|
3
|
+
import { ContentService } from './content.service';
|
|
4
|
+
import { EndpointService } from './endpoint.service';
|
|
5
|
+
import { EventsService } from './events.service';
|
|
6
|
+
import { FlowDeploymentService } from './flow-deployment.service';
|
|
7
|
+
import { FlowFunctionService } from './flow-function.service';
|
|
8
|
+
import { FlowModuleService } from './flow-module.service';
|
|
9
|
+
import { FlowService } from './flow.service';
|
|
10
|
+
import { HttpClient } from './http.service';
|
|
11
|
+
import { LabelService } from './label.service';
|
|
12
|
+
import { NotificationService } from './notification.service';
|
|
13
|
+
import { ProxyService } from './proxy.service';
|
|
14
|
+
import { SecretService } from './secret.service';
|
|
15
|
+
import { TaskService } from './task.service';
|
|
16
|
+
import { TimeSeriesService } from './timeseries.service';
|
|
17
|
+
import { UserService } from './user.service';
|
|
18
|
+
import { VaultService } from './vault.service';
|
|
19
|
+
export class API {
|
|
20
|
+
constructor(httpClient, context) {
|
|
21
|
+
this.httpClient = httpClient;
|
|
22
|
+
if (!httpClient) {
|
|
23
|
+
// remove leading and trailing slashes
|
|
24
|
+
const normalizePath = (value = '', defaultValue = '') => value.replace(/(?:^\/+)|(?:\/+$)/g, '') || defaultValue;
|
|
25
|
+
let apiBaseUrl = process.env.API_BASE_URL || 'https://testing.hahnpro.com';
|
|
26
|
+
if (!apiBaseUrl.startsWith('https') && !apiBaseUrl.startsWith('http')) {
|
|
27
|
+
/* eslint-disable-next-line no-console */
|
|
28
|
+
console.info('no protocol specified - using HTTPS');
|
|
29
|
+
apiBaseUrl = `https://${apiBaseUrl}`;
|
|
30
|
+
}
|
|
31
|
+
const apiUrl = apiBaseUrl + '/' + normalizePath(process.env.API_BASE_PATH, 'api');
|
|
32
|
+
const authBaseUrl = process.env.AUTH_BASE_URL || apiBaseUrl;
|
|
33
|
+
const authUrl = authBaseUrl + '/' + normalizePath(process.env.AUTH_BASE_PATH, 'auth');
|
|
34
|
+
const realm = process.env.AUTH_REALM || 'hpc';
|
|
35
|
+
const client = process.env.API_USER || 'flow-executor-service';
|
|
36
|
+
const secret = process.env.AUTH_SECRET;
|
|
37
|
+
if (!secret) {
|
|
38
|
+
throw new Error('"API_BASE_URL", "API_USER", "AUTH_REALM" and "AUTH_SECRET" environment variables must be set');
|
|
39
|
+
}
|
|
40
|
+
this.httpClient = new HttpClient(apiUrl, authUrl, realm, client, secret, context?.tokenSubject);
|
|
41
|
+
}
|
|
42
|
+
this.assets = new AssetService(this.httpClient);
|
|
43
|
+
this.assetTypes = new AssetTypesService(this.httpClient);
|
|
44
|
+
this.contents = new ContentService(this.httpClient);
|
|
45
|
+
this.endpoints = new EndpointService(this.httpClient);
|
|
46
|
+
this.events = new EventsService(this.httpClient);
|
|
47
|
+
this.flows = new FlowService(this.httpClient);
|
|
48
|
+
this.flowDeployments = new FlowDeploymentService(this.httpClient);
|
|
49
|
+
this.flowFunctions = new FlowFunctionService(this.httpClient);
|
|
50
|
+
this.flowModules = new FlowModuleService(this.httpClient);
|
|
51
|
+
this.labels = new LabelService(this.httpClient);
|
|
52
|
+
this.proxy = new ProxyService(this.httpClient);
|
|
53
|
+
this.secrets = new SecretService(this.httpClient);
|
|
54
|
+
this.tasks = new TaskService(this.httpClient);
|
|
55
|
+
this.timeSeries = new TimeSeriesService(this.httpClient);
|
|
56
|
+
this.users = new UserService(this.httpClient);
|
|
57
|
+
this.vault = new VaultService(this.httpClient);
|
|
58
|
+
this.notifications = new NotificationService(this.httpClient);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,26 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const data_service_1 = require("./data.service");
|
|
8
|
-
const trash_service_1 = require("./trash.service");
|
|
9
|
-
let BaseService = class BaseService extends api_base_1.APIBase {
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { mix } from 'ts-mixer';
|
|
3
|
+
import { APIBase } from './api-base';
|
|
4
|
+
import { DataService } from './data.service';
|
|
5
|
+
import { TrashService } from './trash.service';
|
|
6
|
+
let BaseService = class BaseService extends APIBase {
|
|
10
7
|
};
|
|
11
|
-
BaseService =
|
|
12
|
-
|
|
8
|
+
BaseService = __decorate([
|
|
9
|
+
mix(DataService, TrashService)
|
|
13
10
|
], BaseService);
|
|
14
|
-
class AssetService extends BaseService {
|
|
11
|
+
export class AssetService extends BaseService {
|
|
15
12
|
constructor(httpClient) {
|
|
16
13
|
super(httpClient, '/assets');
|
|
17
14
|
this.addAttachment = (id, form, options = {}) => {
|
|
18
|
-
const headers =
|
|
19
|
-
return this.httpClient.post(`${this.basePath}/${id}/attachment`, form,
|
|
15
|
+
const headers = { ...form.getHeaders() };
|
|
16
|
+
return this.httpClient.post(`${this.basePath}/${id}/attachment`, form, {
|
|
17
|
+
headers,
|
|
18
|
+
maxBodyLength: Infinity,
|
|
19
|
+
maxContentLength: Infinity,
|
|
20
|
+
...options,
|
|
21
|
+
});
|
|
20
22
|
};
|
|
21
23
|
}
|
|
22
24
|
deleteOne(id, force = false, options = {}) {
|
|
23
|
-
return this.httpClient.delete(`${this.basePath}/${id}`,
|
|
25
|
+
return this.httpClient.delete(`${this.basePath}/${id}`, { params: { force }, ...options });
|
|
24
26
|
}
|
|
25
27
|
getChildren(assetId, params = {}, options = {}) {
|
|
26
28
|
return this.getManyFiltered({ parent: assetId }, params, options);
|
|
@@ -29,7 +31,10 @@ class AssetService extends BaseService {
|
|
|
29
31
|
return this.httpClient.get(`${this.basePath}/${assetId}/attachments`, options);
|
|
30
32
|
}
|
|
31
33
|
getEventLevelOverride(ids, causes, options = {}) {
|
|
32
|
-
return this.httpClient.get(`${this.basePath}/eventcauses`,
|
|
34
|
+
return this.httpClient.get(`${this.basePath}/eventcauses`, {
|
|
35
|
+
params: { ids: ids.join(','), causes: causes.join(',') },
|
|
36
|
+
...options,
|
|
37
|
+
});
|
|
33
38
|
}
|
|
34
39
|
updateEventCausesAsset(id, dto, options = {}) {
|
|
35
40
|
return this.httpClient.put(`${this.basePath}/${id}/eventcauses`, dto, options);
|
|
@@ -44,4 +49,3 @@ class AssetService extends BaseService {
|
|
|
44
49
|
return this.httpClient.delete(`${this.basePath}/${assetId}/revisions/${revisionId}`, options);
|
|
45
50
|
}
|
|
46
51
|
}
|
|
47
|
-
exports.AssetService = AssetService;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { mix } from 'ts-mixer';
|
|
3
|
+
import { APIBase } from './api-base';
|
|
4
|
+
import { DataService } from './data.service';
|
|
5
|
+
import { TrashService } from './trash.service';
|
|
6
|
+
let BaseService = class BaseService extends APIBase {
|
|
7
|
+
};
|
|
8
|
+
BaseService = __decorate([
|
|
9
|
+
mix(DataService, TrashService)
|
|
10
|
+
], BaseService);
|
|
11
|
+
export class AssetTypesService extends BaseService {
|
|
12
|
+
constructor(httpClient) {
|
|
13
|
+
super(httpClient, '/assettypes');
|
|
14
|
+
}
|
|
15
|
+
getRevisions(id, options = {}) {
|
|
16
|
+
return this.httpClient.get(`${this.basePath}/${id}/revisions`, options);
|
|
17
|
+
}
|
|
18
|
+
rollback(id, revisionId, options = {}) {
|
|
19
|
+
return this.httpClient.put(`${this.basePath}/${id}/rollback`, { revisionId }, options);
|
|
20
|
+
}
|
|
21
|
+
deleteRevision(id, revisionId, options = {}) {
|
|
22
|
+
return this.httpClient.delete(`${this.basePath}/${id}/revisions/${revisionId}`, options);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ReturnType = void 0;
|
|
4
|
-
var ReturnType;
|
|
1
|
+
export var ReturnType;
|
|
5
2
|
(function (ReturnType) {
|
|
6
3
|
ReturnType[ReturnType["TEXT"] = 0] = "TEXT";
|
|
7
4
|
ReturnType[ReturnType["JSON"] = 1] = "JSON";
|
|
@@ -9,4 +6,4 @@ var ReturnType;
|
|
|
9
6
|
ReturnType[ReturnType["BLOB"] = 3] = "BLOB";
|
|
10
7
|
ReturnType[ReturnType["ARRAYBUFFER"] = 4] = "ARRAYBUFFER";
|
|
11
8
|
ReturnType[ReturnType["NODESTREAM"] = 5] = "NODESTREAM";
|
|
12
|
-
})(ReturnType || (
|
|
9
|
+
})(ReturnType || (ReturnType = {}));
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { mix } from 'ts-mixer';
|
|
3
|
+
import { APIBase } from './api-base';
|
|
4
|
+
import { ReturnType } from './content.interface';
|
|
5
|
+
import { DataService } from './data.service';
|
|
6
|
+
import { TrashService } from './trash.service';
|
|
7
|
+
let BaseService = class BaseService extends APIBase {
|
|
8
|
+
};
|
|
9
|
+
BaseService = __decorate([
|
|
10
|
+
mix(DataService, TrashService)
|
|
11
|
+
], BaseService);
|
|
12
|
+
export class ContentService extends BaseService {
|
|
13
|
+
constructor(httpClient) {
|
|
14
|
+
super(httpClient, '/contents');
|
|
15
|
+
this.upload = (form, options = {}) => {
|
|
16
|
+
const headers = { ...form.getHeaders() };
|
|
17
|
+
return this.httpClient.post(`${this.basePath}`, form, {
|
|
18
|
+
headers,
|
|
19
|
+
maxBodyLength: Infinity,
|
|
20
|
+
maxContentLength: Infinity,
|
|
21
|
+
...options,
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
async download(id, second, options = {}) {
|
|
26
|
+
let returnType;
|
|
27
|
+
if (typeof second === 'boolean' || second == null) {
|
|
28
|
+
returnType = second ? ReturnType.ARRAYBUFFER : ReturnType.BLOB;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
returnType = second;
|
|
32
|
+
}
|
|
33
|
+
const url = `${this.basePath}/${id}/download`;
|
|
34
|
+
switch (returnType) {
|
|
35
|
+
case ReturnType.TEXT:
|
|
36
|
+
return this.httpClient.get(url, { responseType: 'text', ...options });
|
|
37
|
+
case ReturnType.JSON:
|
|
38
|
+
return this.httpClient.get(url, { responseType: 'json', ...options });
|
|
39
|
+
case ReturnType.NODEBUFFER:
|
|
40
|
+
return Buffer.from(new Uint8Array(await this.httpClient.get(url, { responseType: 'arraybuffer', ...options })));
|
|
41
|
+
case ReturnType.BLOB:
|
|
42
|
+
return this.httpClient.get(url, { responseType: 'blob', ...options });
|
|
43
|
+
case ReturnType.ARRAYBUFFER:
|
|
44
|
+
return this.httpClient.get(url, { responseType: 'arraybuffer', ...options });
|
|
45
|
+
case ReturnType.NODESTREAM:
|
|
46
|
+
return this.httpClient.get(url, { responseType: 'stream', ...options });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const api_base_1 = require("./api-base");
|
|
5
|
-
const data_interface_1 = require("./data.interface");
|
|
6
|
-
class DataService extends api_base_1.APIBase {
|
|
1
|
+
import { APIBase } from './api-base';
|
|
2
|
+
import { instanceOfTimePeriod } from './data.interface';
|
|
3
|
+
export class DataService extends APIBase {
|
|
7
4
|
addOne(dto, options = {}) {
|
|
8
5
|
return this.httpClient.post(this.basePath, dto, options);
|
|
9
6
|
}
|
|
@@ -17,8 +14,18 @@ class DataService extends api_base_1.APIBase {
|
|
|
17
14
|
getMany(params = {}, options = {}) {
|
|
18
15
|
params.limit = params.limit || 0;
|
|
19
16
|
params.page = params.page || 1;
|
|
20
|
-
return this.httpClient.get(`${this.basePath}`,
|
|
21
|
-
}
|
|
17
|
+
return this.httpClient.get(`${this.basePath}`, { params, ...options });
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Filters the elements by the passed properties. The object with these properties has to be of the form:
|
|
21
|
+
* {
|
|
22
|
+
* propertyName: string | string[] | { from: Date, to: Date },
|
|
23
|
+
* ...
|
|
24
|
+
* }.
|
|
25
|
+
* @param filter The Object with the properties to filter by.
|
|
26
|
+
* @param params Other request parameters.
|
|
27
|
+
* @param options Parameters for authentication
|
|
28
|
+
*/
|
|
22
29
|
getManyFiltered(filter, params = {}, options = {}) {
|
|
23
30
|
params.filter = this.getFilterString(filter);
|
|
24
31
|
return this.getMany(params, options);
|
|
@@ -27,13 +34,14 @@ class DataService extends api_base_1.APIBase {
|
|
|
27
34
|
return this.httpClient.put(`${this.basePath}/${id}`, dto, options);
|
|
28
35
|
}
|
|
29
36
|
deleteOne(id, force = false, options = {}) {
|
|
30
|
-
return this.httpClient.delete(`${this.basePath}/${id}`,
|
|
37
|
+
return this.httpClient.delete(`${this.basePath}/${id}`, { params: { force }, ...options });
|
|
31
38
|
}
|
|
32
39
|
getFilterString(filter) {
|
|
33
40
|
const filters = [];
|
|
34
41
|
for (const [key, value] of Object.entries(filter)) {
|
|
35
42
|
if (value != null && value !== '') {
|
|
36
|
-
|
|
43
|
+
// filter out null and undefined values and empty strings
|
|
44
|
+
if (typeof value === 'object' && instanceOfTimePeriod(value)) {
|
|
37
45
|
filters.push(`${key}>=${value.from.toISOString()};${key}<=${value.to.toISOString()}`);
|
|
38
46
|
}
|
|
39
47
|
else if (Array.isArray(value)) {
|
|
@@ -47,4 +55,3 @@ class DataService extends api_base_1.APIBase {
|
|
|
47
55
|
return filters.join(';');
|
|
48
56
|
}
|
|
49
57
|
}
|
|
50
|
-
exports.DataService = DataService;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { HttpClient, TokenOption } from './http.service';
|
|
2
1
|
import { DataService } from './data.service';
|
|
3
|
-
import { Endpoint,
|
|
2
|
+
import { Endpoint, EndpointLog, NotificationPayload } from './endpoint.interface';
|
|
3
|
+
import { HttpClient, TokenOption } from './http.service';
|
|
4
4
|
export declare class EndpointService extends DataService<Endpoint> {
|
|
5
5
|
constructor(httpClient: HttpClient);
|
|
6
6
|
sendNotification(endpointId: string, payload: NotificationPayload, options?: TokenOption): Promise<void>;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.EndpointService = void 0;
|
|
4
|
-
const data_service_1 = require("./data.service");
|
|
5
|
-
class EndpointService extends data_service_1.DataService {
|
|
1
|
+
import { DataService } from './data.service';
|
|
2
|
+
export class EndpointService extends DataService {
|
|
6
3
|
constructor(httpClient) {
|
|
7
4
|
super(httpClient, '/notification/endpoints');
|
|
8
5
|
}
|
|
@@ -13,4 +10,3 @@ class EndpointService extends data_service_1.DataService {
|
|
|
13
10
|
return this.httpClient.get(`${this.basePath}/${endpointId}/logs/${group}/last`, options);
|
|
14
11
|
}
|
|
15
12
|
}
|
|
16
|
-
exports.EndpointService = EndpointService;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DataService } from './data.service';
|
|
2
|
+
export class EventsService extends DataService {
|
|
3
|
+
constructor(httpClient) {
|
|
4
|
+
super(httpClient, '/events');
|
|
5
|
+
}
|
|
6
|
+
getLastEventByAssetAndGroup(assetId, group, options = {}) {
|
|
7
|
+
return this.httpClient.get(`${this.basePath}/last/${assetId}/${group}`, options);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { mix } from 'ts-mixer';
|
|
3
|
+
import { APIBase } from './api-base';
|
|
4
|
+
import { DataService } from './data.service';
|
|
5
|
+
import { TrashService } from './trash.service';
|
|
6
|
+
let BaseService = class BaseService extends APIBase {
|
|
7
|
+
};
|
|
8
|
+
BaseService = __decorate([
|
|
9
|
+
mix(DataService, TrashService)
|
|
10
|
+
], BaseService);
|
|
11
|
+
export class FlowDeploymentService extends BaseService {
|
|
12
|
+
constructor(httpClient) {
|
|
13
|
+
super(httpClient, '/flow/deployments');
|
|
14
|
+
}
|
|
15
|
+
// workaround as flow-deployment-service does not have a POST /many endpoint
|
|
16
|
+
addMany(dto, options = {}) {
|
|
17
|
+
const reqs = dto.map((v) => this.addOne(v, options));
|
|
18
|
+
return Promise.all(reqs);
|
|
19
|
+
}
|
|
20
|
+
updateOne(id, dto, options = { force: false }) {
|
|
21
|
+
return super.updateOne(id, dto, options);
|
|
22
|
+
}
|
|
23
|
+
getDeploymentStatistics(id, options = {}) {
|
|
24
|
+
return this.httpClient.get(`${this.basePath}/${id}/statistics`, options);
|
|
25
|
+
}
|
|
26
|
+
getDeploymentMetrics(id, range = '12h', interval = '5m', options = {}) {
|
|
27
|
+
const params = { range, interval };
|
|
28
|
+
return this.httpClient.get(`${this.basePath}/${id}/metrics`, { params, ...options });
|
|
29
|
+
}
|
|
30
|
+
getDeploymentLogs(id, options = {}) {
|
|
31
|
+
return this.httpClient.get(`${this.basePath}/${id}/logs`, options);
|
|
32
|
+
}
|
|
33
|
+
resolveReferences(id, recursive = true, types, options = {}) {
|
|
34
|
+
const params = { recursive, types: types?.join(',') ?? undefined };
|
|
35
|
+
return this.httpClient.get(`${this.basePath}/${id}/references`, { params, ...options });
|
|
36
|
+
}
|
|
37
|
+
updateStatus(id, desiredStatus, options = {}) {
|
|
38
|
+
return this.httpClient.put(`${this.basePath}/${id}/status`, { desiredStatus }, options);
|
|
39
|
+
}
|
|
40
|
+
deleteOne(id, _force, options = {}) {
|
|
41
|
+
return this.updateStatus(id, 'deleted', options);
|
|
42
|
+
}
|
|
43
|
+
async waitForRunningStatus(id, options = {}) {
|
|
44
|
+
return new Promise(async (resolve, reject) => {
|
|
45
|
+
const esId = await this.subscribeToStatus(id, (event) => {
|
|
46
|
+
if (event.type === 'message' &&
|
|
47
|
+
['running', 'deployment failed', 'deleted', 'generating failed', 'updating failed', 'upgrading failed'].includes(event.data)) {
|
|
48
|
+
this.httpClient.destroyEventSource(esId);
|
|
49
|
+
if (event.data === 'running') {
|
|
50
|
+
resolve();
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
reject(`Deployment in failed status: ${event.data}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}, (event) => reject(event), options);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
addOne(dto, options = {}) {
|
|
60
|
+
return super.addOne(dto, options);
|
|
61
|
+
}
|
|
62
|
+
subscribeToStatus(id, listener, errorListener, options = {}) {
|
|
63
|
+
return this.httpClient.addEventSource(`${this.basePath}/${id}/status`, listener, errorListener, options);
|
|
64
|
+
}
|
|
65
|
+
subscribeToLogs(id, listener, errorListener, options = {}) {
|
|
66
|
+
return this.httpClient.addEventSource(`${this.basePath}/${id}/logs/subscribe`, listener, errorListener, options);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.FlowFunctionService = void 0;
|
|
4
|
-
const data_service_1 = require("./data.service");
|
|
5
|
-
class FlowFunctionService extends data_service_1.DataService {
|
|
1
|
+
import { DataService } from './data.service';
|
|
2
|
+
export class FlowFunctionService extends DataService {
|
|
6
3
|
constructor(httpClient) {
|
|
7
4
|
super(httpClient, '/flow/functions');
|
|
8
5
|
}
|
|
6
|
+
// workaround as flow-functions-service does not have a POST /many endpoint
|
|
9
7
|
addMany(dto, options = {}) {
|
|
10
8
|
const reqs = dto.map((v) => this.addOne(v, options));
|
|
11
9
|
return Promise.all(reqs);
|
|
@@ -20,4 +18,3 @@ class FlowFunctionService extends data_service_1.DataService {
|
|
|
20
18
|
return this.httpClient.delete(`${this.basePath}/${fqn}/revisions/${revisionId}`, options);
|
|
21
19
|
}
|
|
22
20
|
}
|
|
23
|
-
exports.FlowFunctionService = FlowFunctionService;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.FlowModuleService = void 0;
|
|
4
|
-
const data_service_1 = require("./data.service");
|
|
5
|
-
class FlowModuleService extends data_service_1.DataService {
|
|
1
|
+
import { DataService } from './data.service';
|
|
2
|
+
export class FlowModuleService extends DataService {
|
|
6
3
|
constructor(httpClient) {
|
|
7
4
|
super(httpClient, '/flow/modules');
|
|
8
5
|
}
|
|
@@ -10,7 +7,12 @@ class FlowModuleService extends data_service_1.DataService {
|
|
|
10
7
|
return this.httpClient.delete(`${this.basePath}/${name}/${version}`, options);
|
|
11
8
|
}
|
|
12
9
|
publish(form, options = {}) {
|
|
13
|
-
const config =
|
|
10
|
+
const config = {
|
|
11
|
+
headers: { ...form.getHeaders() },
|
|
12
|
+
maxBodyLength: Infinity,
|
|
13
|
+
maxContentLength: Infinity,
|
|
14
|
+
...options,
|
|
15
|
+
};
|
|
14
16
|
return this.httpClient.post(`${this.basePath}`, form, config);
|
|
15
17
|
}
|
|
16
18
|
addOne(_dto) {
|
|
@@ -20,4 +22,3 @@ class FlowModuleService extends data_service_1.DataService {
|
|
|
20
22
|
throw new Error('not allowed: use publish instead');
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
|
-
exports.FlowModuleService = FlowModuleService;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const data_service_1 = require("./data.service");
|
|
8
|
-
const trash_service_1 = require("./trash.service");
|
|
9
|
-
let BaseService = class BaseService extends api_base_1.APIBase {
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { mix } from 'ts-mixer';
|
|
3
|
+
import { APIBase } from './api-base';
|
|
4
|
+
import { DataService } from './data.service';
|
|
5
|
+
import { TrashService } from './trash.service';
|
|
6
|
+
let BaseService = class BaseService extends APIBase {
|
|
10
7
|
};
|
|
11
|
-
BaseService =
|
|
12
|
-
|
|
8
|
+
BaseService = __decorate([
|
|
9
|
+
mix(DataService, TrashService)
|
|
13
10
|
], BaseService);
|
|
14
|
-
class FlowService extends BaseService {
|
|
11
|
+
export class FlowService extends BaseService {
|
|
15
12
|
constructor(httpClient) {
|
|
16
13
|
super(httpClient, '/flows');
|
|
17
14
|
}
|
|
15
|
+
// workaround as flow-service does not have a POST /many endpoint
|
|
18
16
|
addMany(dto, options = {}) {
|
|
19
17
|
const reqs = dto.map((v) => this.addOne(v, options));
|
|
20
18
|
return Promise.all(reqs);
|
|
@@ -33,13 +31,11 @@ class FlowService extends BaseService {
|
|
|
33
31
|
getDiagramRevisions(id, options = {}) {
|
|
34
32
|
return this.httpClient.get(`${this.basePath}/${id}/diagram/revisions`, options);
|
|
35
33
|
}
|
|
36
|
-
isDeploymentOnLatestDiagramVersion(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return revisions[revisions.length - 1].id === diagramId;
|
|
42
|
-
});
|
|
34
|
+
async isDeploymentOnLatestDiagramVersion(depl, options = {}) {
|
|
35
|
+
const flowId = typeof depl.flow === 'string' ? depl.flow : depl.flow.id;
|
|
36
|
+
const diagramId = typeof depl.diagram === 'string' ? depl.diagram : depl.diagram.id;
|
|
37
|
+
const revisions = await this.getDiagramRevisions(flowId, options);
|
|
38
|
+
return revisions[revisions.length - 1].id === diagramId;
|
|
43
39
|
}
|
|
44
40
|
getRevisions(id, options = {}) {
|
|
45
41
|
return this.httpClient.get(`${this.basePath}/${id}/revisions`, options);
|
|
@@ -51,4 +47,3 @@ class FlowService extends BaseService {
|
|
|
51
47
|
return this.httpClient.delete(`${this.basePath}/${id}/revisions/${revisionId}`, options);
|
|
52
48
|
}
|
|
53
49
|
}
|
|
54
|
-
exports.FlowService = FlowService;
|