@hahnpro/hpc-api 2.0.0 → 2.2.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/dist/Queue.js +1 -1
- package/dist/api.d.ts +8 -0
- package/dist/api.js +8 -0
- package/dist/asset.interface.d.ts +8 -3
- package/dist/asset.service.d.ts +2 -1
- package/dist/asset.service.js +3 -0
- package/dist/content.interface.d.ts +1 -13
- package/dist/flow-deployment.interface.d.ts +76 -0
- package/dist/flow-deployment.interface.js +2 -0
- package/dist/flow-deployment.service.d.ts +26 -0
- package/dist/flow-deployment.service.js +58 -0
- package/dist/flow-function.interface.d.ts +47 -0
- package/dist/flow-function.interface.js +2 -0
- package/dist/flow-function.service.d.ts +9 -0
- package/dist/flow-function.service.js +20 -0
- package/dist/flow-module.interface.d.ts +13 -0
- package/dist/flow-module.interface.js +2 -0
- package/dist/flow-module.service.d.ts +13 -0
- package/dist/flow-module.service.js +40 -0
- package/dist/flow.interface.d.ts +25 -0
- package/dist/flow.interface.js +2 -0
- package/dist/flow.service.d.ts +11 -0
- package/dist/flow.service.js +25 -0
- package/dist/http.service.d.ts +6 -0
- package/dist/http.service.js +34 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +18 -13
- package/dist/mock/api.mock.d.ts +31 -1
- package/dist/mock/api.mock.js +37 -2
- package/dist/mock/asset.mock.service.d.ts +4 -2
- package/dist/mock/asset.mock.service.js +12 -1
- package/dist/mock/flow-deployment.mock.service.d.ts +27 -0
- package/dist/mock/flow-deployment.mock.service.js +117 -0
- package/dist/mock/flow-functions.mock.service.d.ts +14 -0
- package/dist/mock/flow-functions.mock.service.js +41 -0
- package/dist/mock/flow-modules.mock.service.d.ts +18 -0
- package/dist/mock/flow-modules.mock.service.js +34 -0
- package/dist/mock/flow.mock.service.d.ts +10 -0
- package/dist/mock/flow.mock.service.js +23 -0
- package/dist/mock/index.js +9 -9
- package/dist/resource.interface.d.ts +18 -0
- package/dist/resource.interface.js +2 -0
- package/dist/schema.interface.d.ts +18 -0
- package/dist/schema.interface.js +2 -0
- package/dist/storage.interface.d.ts +16 -0
- package/dist/storage.interface.js +2 -0
- package/dist/user.service.js +1 -1
- package/package.json +5 -3
package/dist/Queue.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Queue = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const p_queue_1 =
|
|
5
|
+
const p_queue_1 = tslib_1.__importDefault(require("p-queue"));
|
|
6
6
|
class Queue extends p_queue_1.default {
|
|
7
7
|
constructor(options) {
|
|
8
8
|
super(options);
|
package/dist/api.d.ts
CHANGED
|
@@ -10,6 +10,10 @@ import { SiDriveIqService } from './sidriveiq.service';
|
|
|
10
10
|
import { TaskService } from './task.service';
|
|
11
11
|
import { TimeSeriesService } from './timeseries.service';
|
|
12
12
|
import { UserService } from './user.service';
|
|
13
|
+
import { FlowService } from './flow.service';
|
|
14
|
+
import { FlowFunctionService } from './flow-function.service';
|
|
15
|
+
import { FlowModuleService } from './flow-module.service';
|
|
16
|
+
import { FlowDeploymentService } from './flow-deployment.service';
|
|
13
17
|
export declare class API {
|
|
14
18
|
httpClient: HttpClient;
|
|
15
19
|
assets: AssetService;
|
|
@@ -17,6 +21,10 @@ export declare class API {
|
|
|
17
21
|
contents: ContentService;
|
|
18
22
|
endpoints: EndpointService;
|
|
19
23
|
events: EventsService;
|
|
24
|
+
flows: FlowService;
|
|
25
|
+
flowDeployments: FlowDeploymentService;
|
|
26
|
+
flowFunctions: FlowFunctionService;
|
|
27
|
+
flowModules: FlowModuleService;
|
|
20
28
|
proxy: ProxyService;
|
|
21
29
|
secrets: SecretService;
|
|
22
30
|
tasks: TaskService;
|
package/dist/api.js
CHANGED
|
@@ -13,6 +13,10 @@ const sidriveiq_service_1 = require("./sidriveiq.service");
|
|
|
13
13
|
const task_service_1 = require("./task.service");
|
|
14
14
|
const timeseries_service_1 = require("./timeseries.service");
|
|
15
15
|
const user_service_1 = require("./user.service");
|
|
16
|
+
const flow_service_1 = require("./flow.service");
|
|
17
|
+
const flow_function_service_1 = require("./flow-function.service");
|
|
18
|
+
const flow_module_service_1 = require("./flow-module.service");
|
|
19
|
+
const flow_deployment_service_1 = require("./flow-deployment.service");
|
|
16
20
|
class API {
|
|
17
21
|
constructor() {
|
|
18
22
|
const normalizePath = (value = '', defaultValue = '') => value.replace(/^\/+|\/+$/g, '') || defaultValue;
|
|
@@ -36,6 +40,10 @@ class API {
|
|
|
36
40
|
this.contents = new content_service_1.ContentService(this.httpClient);
|
|
37
41
|
this.endpoints = new endpoint_service_1.EndpointService(this.httpClient);
|
|
38
42
|
this.events = new events_service_1.EventsService(this.httpClient);
|
|
43
|
+
this.flows = new flow_service_1.FlowService(this.httpClient);
|
|
44
|
+
this.flowDeployments = new flow_deployment_service_1.FlowDeploymentService(this.httpClient);
|
|
45
|
+
this.flowFunctions = new flow_function_service_1.FlowFunctionService(this.httpClient);
|
|
46
|
+
this.flowModules = new flow_module_service_1.FlowModuleService(this.httpClient);
|
|
39
47
|
this.proxy = new proxy_service_1.ProxyService(this.httpClient);
|
|
40
48
|
this.secrets = new secret_service_1.SecretService(this.httpClient);
|
|
41
49
|
this.tasks = new task_service_1.TaskService(this.httpClient);
|
|
@@ -14,15 +14,13 @@ export interface AssetType {
|
|
|
14
14
|
createdAt?: string;
|
|
15
15
|
updatedAt?: string;
|
|
16
16
|
}
|
|
17
|
-
export interface
|
|
17
|
+
export interface AssetParent {
|
|
18
18
|
id?: string;
|
|
19
19
|
name: string;
|
|
20
20
|
type: string | AssetType;
|
|
21
|
-
type$name?: string;
|
|
22
21
|
readPermissions: string[];
|
|
23
22
|
readWritePermissions: string[];
|
|
24
23
|
parent?: any | Asset;
|
|
25
|
-
parent$name?: string;
|
|
26
24
|
ancestors?: string[];
|
|
27
25
|
tags?: string[];
|
|
28
26
|
relations?: any[];
|
|
@@ -30,9 +28,16 @@ export interface Asset {
|
|
|
30
28
|
image?: string;
|
|
31
29
|
author?: string;
|
|
32
30
|
revision?: number;
|
|
31
|
+
}
|
|
32
|
+
export interface Asset extends AssetParent {
|
|
33
|
+
type$name?: string;
|
|
34
|
+
parent$name?: string;
|
|
33
35
|
attachments?: string[];
|
|
34
36
|
notificationEndpoints?: string[];
|
|
35
37
|
actions?: string[];
|
|
38
|
+
}
|
|
39
|
+
export interface AssetRevision extends AssetParent {
|
|
40
|
+
originalId?: string;
|
|
36
41
|
createdAt?: string;
|
|
37
42
|
updatedAt?: string;
|
|
38
43
|
}
|
package/dist/asset.service.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import FormData from 'form-data';
|
|
2
|
-
import { Asset } from './asset.interface';
|
|
2
|
+
import { Asset, AssetRevision } from './asset.interface';
|
|
3
3
|
import { Paginated, RequestParameter } from './data.interface';
|
|
4
4
|
import { DataService } from './data.service';
|
|
5
5
|
import { HttpClient } from './http.service';
|
|
@@ -7,4 +7,5 @@ export declare class AssetService extends DataService<Asset> {
|
|
|
7
7
|
constructor(httpClient: HttpClient);
|
|
8
8
|
addAttachment: (id: string, form: FormData) => Promise<Asset>;
|
|
9
9
|
getChildren(assetId: string, params?: RequestParameter): Promise<Paginated<Asset[]>>;
|
|
10
|
+
findRevisions(assetId: string): Promise<Paginated<AssetRevision[]>>;
|
|
10
11
|
}
|
package/dist/asset.service.js
CHANGED
|
@@ -17,5 +17,8 @@ class AssetService extends data_service_1.DataService {
|
|
|
17
17
|
getChildren(assetId, params = {}) {
|
|
18
18
|
return this.getManyFiltered({ parent: assetId }, params);
|
|
19
19
|
}
|
|
20
|
+
findRevisions(assetId) {
|
|
21
|
+
return this.httpClient.get(`${this.basePath}/${assetId}/revisions`);
|
|
22
|
+
}
|
|
20
23
|
}
|
|
21
24
|
exports.AssetService = AssetService;
|
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
declare type StorageProvider = 's3' | 'mongo';
|
|
3
|
-
export interface Storage {
|
|
4
|
-
id: string;
|
|
5
|
-
filename: string;
|
|
6
|
-
mimetype: string;
|
|
7
|
-
size: number;
|
|
8
|
-
createdAt: string;
|
|
9
|
-
provider?: StorageProvider;
|
|
10
|
-
type?: FileType;
|
|
11
|
-
md5?: string;
|
|
12
|
-
}
|
|
1
|
+
import { Storage } from './storage.interface';
|
|
13
2
|
export interface Content {
|
|
14
3
|
id?: string;
|
|
15
4
|
fileId: string;
|
|
@@ -32,4 +21,3 @@ export declare enum ReturnType {
|
|
|
32
21
|
ARRAYBUFFER = 4,
|
|
33
22
|
NODESTREAM = 5
|
|
34
23
|
}
|
|
35
|
-
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Resource } from './resource.interface';
|
|
2
|
+
import { FlowDiagram, FlowDto } from './flow.interface';
|
|
3
|
+
import { Storage } from './storage.interface';
|
|
4
|
+
export interface FlowDeployment extends Resource {
|
|
5
|
+
flow: string | FlowDto;
|
|
6
|
+
diagram: string | FlowDiagram;
|
|
7
|
+
artifact: Storage;
|
|
8
|
+
flowModel: FlowModel;
|
|
9
|
+
desiredStatus: string;
|
|
10
|
+
actualStatus: string;
|
|
11
|
+
target: string;
|
|
12
|
+
statistic?: FlowDeploymentStatistic;
|
|
13
|
+
}
|
|
14
|
+
export interface FlowDeploymentStatistic {
|
|
15
|
+
totalErrorCount: number;
|
|
16
|
+
errorCountWeek: number;
|
|
17
|
+
eventCountWeek: number;
|
|
18
|
+
errorCounts: {
|
|
19
|
+
timestamp: number;
|
|
20
|
+
error: number;
|
|
21
|
+
}[];
|
|
22
|
+
metrics?: Record<string, any>;
|
|
23
|
+
}
|
|
24
|
+
export interface FlowModel {
|
|
25
|
+
elements: FlowModelElement[];
|
|
26
|
+
connections: FlowConnection[];
|
|
27
|
+
modules?: string[];
|
|
28
|
+
properties?: Record<string, any>;
|
|
29
|
+
}
|
|
30
|
+
export interface FlowModelElement {
|
|
31
|
+
id: string;
|
|
32
|
+
name?: string;
|
|
33
|
+
properties?: Record<string, any>;
|
|
34
|
+
module: string;
|
|
35
|
+
functionFqn: string;
|
|
36
|
+
}
|
|
37
|
+
export interface FlowConnection {
|
|
38
|
+
id: string;
|
|
39
|
+
name?: string;
|
|
40
|
+
source: string;
|
|
41
|
+
target: string;
|
|
42
|
+
sourceStream?: string;
|
|
43
|
+
targetStream?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface FlowDeploymentMetrics {
|
|
46
|
+
metrics: Metrics[];
|
|
47
|
+
stats?: Stats;
|
|
48
|
+
}
|
|
49
|
+
export interface Metrics {
|
|
50
|
+
timestamp: number;
|
|
51
|
+
cpu: number;
|
|
52
|
+
memory: number;
|
|
53
|
+
}
|
|
54
|
+
export interface Stats {
|
|
55
|
+
cpu: StatsValues;
|
|
56
|
+
memory: StatsValues;
|
|
57
|
+
}
|
|
58
|
+
export interface StatsValues {
|
|
59
|
+
count: number;
|
|
60
|
+
min: number;
|
|
61
|
+
max: number;
|
|
62
|
+
avg: number;
|
|
63
|
+
sum: number;
|
|
64
|
+
}
|
|
65
|
+
export interface FlowLog {
|
|
66
|
+
data?: any;
|
|
67
|
+
datacontenttype?: string;
|
|
68
|
+
deploymentId?: string;
|
|
69
|
+
elementId?: string;
|
|
70
|
+
eventId?: string;
|
|
71
|
+
flowId?: string;
|
|
72
|
+
subject: string;
|
|
73
|
+
source?: string;
|
|
74
|
+
time: string;
|
|
75
|
+
type: string;
|
|
76
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { DataService } from './data.service';
|
|
2
|
+
import { FlowDeployment, FlowDeploymentMetrics, FlowDeploymentStatistic, FlowLog } from './flow-deployment.interface';
|
|
3
|
+
import { HttpClient } from './http.service';
|
|
4
|
+
import { ResourceReference } from './resource.interface';
|
|
5
|
+
export declare class FlowDeploymentService extends DataService<FlowDeployment> {
|
|
6
|
+
constructor(httpClient: HttpClient);
|
|
7
|
+
addMany(dto: any[]): Promise<FlowDeployment[]>;
|
|
8
|
+
updateOne(id: string, dto: any, force?: boolean): Promise<FlowDeployment>;
|
|
9
|
+
getDeploymentStatistics(id: string): Promise<FlowDeploymentStatistic>;
|
|
10
|
+
getDeploymentMetrics(id: string, range?: string, interval?: string): Promise<FlowDeploymentMetrics>;
|
|
11
|
+
getDeploymentLogs(id: string): Promise<FlowLog[]>;
|
|
12
|
+
resolveReferences(id: string, recursive?: boolean, types?: string[]): Promise<ResourceReference[]>;
|
|
13
|
+
updateStatus(id: string, desiredStatus: 'running' | 'stopped' | 'deleted'): Promise<FlowDeployment>;
|
|
14
|
+
deleteOne(id: string): Promise<FlowDeployment>;
|
|
15
|
+
waitForRunningStatus(id: string): Promise<void>;
|
|
16
|
+
addOne(dto: {
|
|
17
|
+
diagramId: string;
|
|
18
|
+
name: string;
|
|
19
|
+
properties?: Record<string, any>;
|
|
20
|
+
readPermissions?: string[];
|
|
21
|
+
readWritePermissions?: string[];
|
|
22
|
+
tags?: string[];
|
|
23
|
+
}): Promise<FlowDeployment>;
|
|
24
|
+
subscribeToStatus(id: string, listener: (event: MessageEvent<any>) => void, errorListener?: (event: MessageEvent) => void): Promise<string>;
|
|
25
|
+
subscribeToLogs(id: string, listener: (event: MessageEvent<any>) => void, errorListener?: (event: MessageEvent) => void): Promise<string>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowDeploymentService = void 0;
|
|
4
|
+
const data_service_1 = require("./data.service");
|
|
5
|
+
class FlowDeploymentService extends data_service_1.DataService {
|
|
6
|
+
constructor(httpClient) {
|
|
7
|
+
super(httpClient, '/flow/deployments');
|
|
8
|
+
}
|
|
9
|
+
addMany(dto) {
|
|
10
|
+
const reqs = dto.map((v) => this.addOne(v));
|
|
11
|
+
return Promise.all(reqs);
|
|
12
|
+
}
|
|
13
|
+
updateOne(id, dto, force = false) {
|
|
14
|
+
return this.httpClient.put(`${this.basePath}/${id}`, dto, { params: { force } });
|
|
15
|
+
}
|
|
16
|
+
getDeploymentStatistics(id) {
|
|
17
|
+
return this.httpClient.get(`${this.basePath}/${id}/statistics`);
|
|
18
|
+
}
|
|
19
|
+
getDeploymentMetrics(id, range = '12h', interval = '5m') {
|
|
20
|
+
const params = { range, interval };
|
|
21
|
+
return this.httpClient.get(`${this.basePath}/${id}/metrics`, { params });
|
|
22
|
+
}
|
|
23
|
+
getDeploymentLogs(id) {
|
|
24
|
+
return this.httpClient.get(`${this.basePath}/${id}/logs`);
|
|
25
|
+
}
|
|
26
|
+
resolveReferences(id, recursive = true, types) {
|
|
27
|
+
var _a;
|
|
28
|
+
const params = { recursive, types: (_a = types === null || types === void 0 ? void 0 : types.join(',')) !== null && _a !== void 0 ? _a : undefined };
|
|
29
|
+
return this.httpClient.get(`${this.basePath}/${id}/references`, { params });
|
|
30
|
+
}
|
|
31
|
+
updateStatus(id, desiredStatus) {
|
|
32
|
+
return this.httpClient.put(`${this.basePath}/${id}/status`, { desiredStatus });
|
|
33
|
+
}
|
|
34
|
+
deleteOne(id) {
|
|
35
|
+
return this.updateStatus(id, 'deleted');
|
|
36
|
+
}
|
|
37
|
+
async waitForRunningStatus(id) {
|
|
38
|
+
return new Promise(async (resolve, reject) => {
|
|
39
|
+
const esId = await this.subscribeToStatus(id, (event) => {
|
|
40
|
+
if (event.type === 'message' &&
|
|
41
|
+
['running', 'deployment failed', 'deleted', 'generating failed', 'updating failed', 'upgrading failed'].includes(event.data)) {
|
|
42
|
+
this.httpClient.destroyEventSource(esId);
|
|
43
|
+
event.data === 'running' ? resolve() : reject(`Deployment in failed status: ${event.data}`);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
addOne(dto) {
|
|
49
|
+
return super.addOne(dto);
|
|
50
|
+
}
|
|
51
|
+
subscribeToStatus(id, listener, errorListener) {
|
|
52
|
+
return this.httpClient.addEventSource(`${this.basePath}/${id}/status`, listener, errorListener);
|
|
53
|
+
}
|
|
54
|
+
subscribeToLogs(id, listener, errorListener) {
|
|
55
|
+
return this.httpClient.addEventSource(`${this.basePath}/${id}/logs/subscribe`, listener, errorListener);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.FlowDeploymentService = FlowDeploymentService;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export interface FlowFunctionDto {
|
|
2
|
+
fqn: string;
|
|
3
|
+
category: string;
|
|
4
|
+
readPermissions: string[];
|
|
5
|
+
readWritePermissions: string[];
|
|
6
|
+
author: string;
|
|
7
|
+
current: string;
|
|
8
|
+
history: string[] | HistoryEntry[];
|
|
9
|
+
name?: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
icon?: string;
|
|
12
|
+
isAbstract?: boolean;
|
|
13
|
+
supertype?: string;
|
|
14
|
+
propertiesSchema?: Schema;
|
|
15
|
+
inputStreams?: Stream[];
|
|
16
|
+
outputStreams?: Stream[];
|
|
17
|
+
tags?: string[];
|
|
18
|
+
createdAt?: string;
|
|
19
|
+
updatedAt?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface HistoryEntry {
|
|
22
|
+
author: string;
|
|
23
|
+
createdAt: string;
|
|
24
|
+
id: string;
|
|
25
|
+
}
|
|
26
|
+
interface Stream {
|
|
27
|
+
name: string;
|
|
28
|
+
}
|
|
29
|
+
interface Schema {
|
|
30
|
+
schema: {
|
|
31
|
+
type: string;
|
|
32
|
+
properties?: {
|
|
33
|
+
[key: string]: SchemaProperty;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
layout?: any[];
|
|
37
|
+
data?: any;
|
|
38
|
+
}
|
|
39
|
+
declare type SchemaPropertyType = 'array' | 'boolean' | 'number' | 'string';
|
|
40
|
+
interface SchemaProperty {
|
|
41
|
+
type: SchemaPropertyType;
|
|
42
|
+
title?: string;
|
|
43
|
+
description?: string;
|
|
44
|
+
default?: any;
|
|
45
|
+
[key: string]: any;
|
|
46
|
+
}
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DataService } from './data.service';
|
|
2
|
+
import { FlowFunctionDto } from './flow-function.interface';
|
|
3
|
+
import { HttpClient } from './http.service';
|
|
4
|
+
export declare class FlowFunctionService extends DataService<FlowFunctionDto> {
|
|
5
|
+
constructor(httpClient: HttpClient);
|
|
6
|
+
addMany(dto: any[]): Promise<FlowFunctionDto[]>;
|
|
7
|
+
getOneWithHistory(fqn: string): Promise<FlowFunctionDto>;
|
|
8
|
+
rollback(fqn: string, historyId: string): Promise<FlowFunctionDto>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowFunctionService = void 0;
|
|
4
|
+
const data_service_1 = require("./data.service");
|
|
5
|
+
class FlowFunctionService extends data_service_1.DataService {
|
|
6
|
+
constructor(httpClient) {
|
|
7
|
+
super(httpClient, '/flow/functions');
|
|
8
|
+
}
|
|
9
|
+
addMany(dto) {
|
|
10
|
+
const reqs = dto.map((v) => this.addOne(v));
|
|
11
|
+
return Promise.all(reqs);
|
|
12
|
+
}
|
|
13
|
+
getOneWithHistory(fqn) {
|
|
14
|
+
return this.httpClient.get(`${this.basePath}/${fqn}/history`);
|
|
15
|
+
}
|
|
16
|
+
rollback(fqn, historyId) {
|
|
17
|
+
return this.httpClient.put(`${this.basePath}/${fqn}/rollback/${historyId}`, {});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.FlowFunctionService = FlowFunctionService;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Artifact } from './storage.interface';
|
|
2
|
+
export interface FlowModule {
|
|
3
|
+
name: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
artifacts: Artifact[];
|
|
6
|
+
author: string;
|
|
7
|
+
tags?: string[];
|
|
8
|
+
functions: string[];
|
|
9
|
+
readPermissions: string[];
|
|
10
|
+
readWritePermissions: string[];
|
|
11
|
+
createdAt?: string;
|
|
12
|
+
updatedAt?: string;
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { DataService } from './data.service';
|
|
3
|
+
import { FlowModule } from './flow-module.interface';
|
|
4
|
+
import { HttpClient } from './http.service';
|
|
5
|
+
import { ReadStream } from 'fs';
|
|
6
|
+
export declare class FlowModuleService extends DataService<FlowModule> {
|
|
7
|
+
constructor(httpClient: HttpClient);
|
|
8
|
+
deleteArtifact(name: string, version: string): Promise<FlowModule>;
|
|
9
|
+
download(name: string, filePath: string, version?: string): Promise<void>;
|
|
10
|
+
publish(file: ReadStream): Promise<unknown>;
|
|
11
|
+
addOne(dto: any): Promise<FlowModule>;
|
|
12
|
+
addMany(dto: any[]): Promise<FlowModule[]>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowModuleService = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const data_service_1 = require("./data.service");
|
|
6
|
+
const fs_1 = require("fs");
|
|
7
|
+
const form_data_1 = tslib_1.__importDefault(require("form-data"));
|
|
8
|
+
const promises_1 = require("stream/promises");
|
|
9
|
+
class FlowModuleService extends data_service_1.DataService {
|
|
10
|
+
constructor(httpClient) {
|
|
11
|
+
super(httpClient, '/flow/modules');
|
|
12
|
+
}
|
|
13
|
+
deleteArtifact(name, version) {
|
|
14
|
+
return this.httpClient.delete(`${this.basePath}/${name}/${version}`);
|
|
15
|
+
}
|
|
16
|
+
async download(name, filePath, version = 'latest') {
|
|
17
|
+
const writer = (0, fs_1.createWriteStream)(filePath);
|
|
18
|
+
return this.httpClient.get(`${this.basePath}/${name}/${version}`, { responseType: 'stream' }).then(async (response) => {
|
|
19
|
+
response.pipe(writer);
|
|
20
|
+
return (0, promises_1.finished)(writer);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
publish(file) {
|
|
24
|
+
const form = new form_data_1.default();
|
|
25
|
+
form.append('file', file);
|
|
26
|
+
const config = {
|
|
27
|
+
headers: Object.assign({}, form.getHeaders()),
|
|
28
|
+
maxBodyLength: Infinity,
|
|
29
|
+
maxContentLength: Infinity,
|
|
30
|
+
};
|
|
31
|
+
return this.httpClient.post(`${this.basePath}`, form, config);
|
|
32
|
+
}
|
|
33
|
+
addOne(dto) {
|
|
34
|
+
throw new Error('not allowed: use publish instead');
|
|
35
|
+
}
|
|
36
|
+
addMany(dto) {
|
|
37
|
+
throw new Error('not allowed: use publish instead');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.FlowModuleService = FlowModuleService;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Resource } from './resource.interface';
|
|
2
|
+
import { JsonSchemaForm } from './schema.interface';
|
|
3
|
+
import { FlowDeployment } from './flow-deployment.interface';
|
|
4
|
+
export interface FlowDto extends Resource {
|
|
5
|
+
diagram: string | FlowDiagram;
|
|
6
|
+
deployments?: string[] | FlowDeployment[];
|
|
7
|
+
dashboard?: DashboardItem[];
|
|
8
|
+
propertiesSchema?: JsonSchemaForm;
|
|
9
|
+
}
|
|
10
|
+
export interface DashboardItem {
|
|
11
|
+
id: string;
|
|
12
|
+
cols: number;
|
|
13
|
+
rows: number;
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
}
|
|
17
|
+
export interface FlowDiagram {
|
|
18
|
+
id: string;
|
|
19
|
+
flow: string | FlowDto;
|
|
20
|
+
json: string;
|
|
21
|
+
author: string;
|
|
22
|
+
createdAt?: Date | string;
|
|
23
|
+
updatedAt?: Date | string;
|
|
24
|
+
deleteddAt?: Date | string;
|
|
25
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DataService } from './data.service';
|
|
2
|
+
import { FlowDto } from './flow.interface';
|
|
3
|
+
import { HttpClient } from './http.service';
|
|
4
|
+
import { Paginated, RequestParameter } from './data.interface';
|
|
5
|
+
export declare class FlowService extends DataService<FlowDto> {
|
|
6
|
+
constructor(httpClient: HttpClient);
|
|
7
|
+
addMany(dto: any[]): Promise<FlowDto[]>;
|
|
8
|
+
getMany(params?: RequestParameter): Promise<Paginated<FlowDto[]>>;
|
|
9
|
+
getOne(id: string, options?: any): Promise<FlowDto>;
|
|
10
|
+
getFlowWithDiagram(diagramId: string): Promise<FlowDto>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowService = void 0;
|
|
4
|
+
const data_service_1 = require("./data.service");
|
|
5
|
+
class FlowService extends data_service_1.DataService {
|
|
6
|
+
constructor(httpClient) {
|
|
7
|
+
super(httpClient, '/flows');
|
|
8
|
+
}
|
|
9
|
+
addMany(dto) {
|
|
10
|
+
const reqs = dto.map((v) => this.addOne(v));
|
|
11
|
+
return Promise.all(reqs);
|
|
12
|
+
}
|
|
13
|
+
getMany(params = {}) {
|
|
14
|
+
params.populate = params.populate ? params.populate : 'none';
|
|
15
|
+
return super.getMany(params);
|
|
16
|
+
}
|
|
17
|
+
getOne(id, options = {}) {
|
|
18
|
+
options.populate = options.populate ? options.populate : 'none';
|
|
19
|
+
return super.getOne(id, options);
|
|
20
|
+
}
|
|
21
|
+
getFlowWithDiagram(diagramId) {
|
|
22
|
+
return this.httpClient.get(`${this.basePath}/diagram/${diagramId}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.FlowService = FlowService;
|
package/dist/http.service.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
import EventSource from 'eventsource';
|
|
2
3
|
export declare class HttpClient {
|
|
4
|
+
private baseURL;
|
|
3
5
|
private readonly realm;
|
|
4
6
|
private readonly client;
|
|
5
7
|
private readonly secret;
|
|
@@ -8,6 +10,7 @@ export declare class HttpClient {
|
|
|
8
10
|
private readonly requestQueue;
|
|
9
11
|
private accessToken;
|
|
10
12
|
private accessTokenExpiration;
|
|
13
|
+
eventSourcesMap: Map<string, EventSource>;
|
|
11
14
|
constructor(baseURL: string, authbaseURL: string, realm: string, client: string, secret: string);
|
|
12
15
|
getQueueStats: () => {
|
|
13
16
|
peak: number;
|
|
@@ -20,6 +23,9 @@ export declare class HttpClient {
|
|
|
20
23
|
post: <T>(url: string, data: any, config?: AxiosRequestConfig) => Promise<T>;
|
|
21
24
|
put: <T>(url: string, data: any, config?: AxiosRequestConfig) => Promise<T>;
|
|
22
25
|
private request;
|
|
26
|
+
addEventSource(url: string, listener: (event: MessageEvent) => void, errorListener?: (event: MessageEvent) => void): Promise<string>;
|
|
27
|
+
destroyEventSource(id: string): void;
|
|
28
|
+
destroyAllEventSources(): void;
|
|
23
29
|
getAccessToken: () => Promise<string>;
|
|
24
30
|
private isTokenValid;
|
|
25
31
|
private getToken;
|
package/dist/http.service.js
CHANGED
|
@@ -2,15 +2,19 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HttpClient = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const axios_1 =
|
|
5
|
+
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
6
|
+
const eventsource_1 = tslib_1.__importDefault(require("eventsource"));
|
|
6
7
|
const Queue_1 = require("./Queue");
|
|
8
|
+
const crypto_1 = require("crypto");
|
|
7
9
|
const EXPIRATION_BUFFER = 30 * 1000;
|
|
8
10
|
class HttpClient {
|
|
9
11
|
constructor(baseURL, authbaseURL, realm, client, secret) {
|
|
12
|
+
this.baseURL = baseURL;
|
|
10
13
|
this.realm = realm;
|
|
11
14
|
this.client = client;
|
|
12
15
|
this.secret = secret;
|
|
13
16
|
this.accessTokenExpiration = 0;
|
|
17
|
+
this.eventSourcesMap = new Map();
|
|
14
18
|
this.getQueueStats = () => { var _a; return (_a = this.requestQueue) === null || _a === void 0 ? void 0 : _a.getStats(); };
|
|
15
19
|
this.delete = (url, config) => this.request('DELETE', url, config);
|
|
16
20
|
this.get = (url, config) => this.request('GET', url, config);
|
|
@@ -69,5 +73,34 @@ class HttpClient {
|
|
|
69
73
|
this.authAxiosInstance = axios_1.default.create({ baseURL: authbaseURL || baseURL, timeout: 10000 });
|
|
70
74
|
this.requestQueue = new Queue_1.Queue({ concurrency: 1, timeout: 70000, throwOnTimeout: true });
|
|
71
75
|
}
|
|
76
|
+
async addEventSource(url, listener, errorListener) {
|
|
77
|
+
const id = (0, crypto_1.randomUUID)();
|
|
78
|
+
const es = new eventsource_1.default(`${this.baseURL}${url}`, {
|
|
79
|
+
headers: { authorization: 'Bearer ' + (await this.getAccessToken()) },
|
|
80
|
+
});
|
|
81
|
+
es.addEventListener('message', listener);
|
|
82
|
+
es.addEventListener('error', errorListener
|
|
83
|
+
? errorListener
|
|
84
|
+
: (event) => {
|
|
85
|
+
throw new Error(JSON.stringify(event, null, 2));
|
|
86
|
+
});
|
|
87
|
+
this.eventSourcesMap.set(id, es);
|
|
88
|
+
return id;
|
|
89
|
+
}
|
|
90
|
+
destroyEventSource(id) {
|
|
91
|
+
if (!this.eventSourcesMap.has(id)) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const es = this.eventSourcesMap.get(id);
|
|
95
|
+
es.close();
|
|
96
|
+
es.removeEventListener('message', () => { });
|
|
97
|
+
es.removeEventListener('error', () => { });
|
|
98
|
+
this.eventSourcesMap.delete(id);
|
|
99
|
+
}
|
|
100
|
+
destroyAllEventSources() {
|
|
101
|
+
for (const key of this.eventSourcesMap.keys()) {
|
|
102
|
+
this.destroyEventSource(key);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
72
105
|
}
|
|
73
106
|
exports.HttpClient = HttpClient;
|
package/dist/index.d.ts
CHANGED
|
@@ -10,4 +10,9 @@ export * from './timeseries.interface';
|
|
|
10
10
|
export * from './task.interface';
|
|
11
11
|
export * from './events.interface';
|
|
12
12
|
export * from './mock';
|
|
13
|
+
export * from './flow-deployment.interface';
|
|
14
|
+
export * from './flow-function.interface';
|
|
15
|
+
export * from './flow.interface';
|
|
16
|
+
export * from './resource.interface';
|
|
17
|
+
export * from './schema.interface';
|
|
13
18
|
export * as SiDrive from './sidriveiq.interface';
|
package/dist/index.js
CHANGED
|
@@ -2,16 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SiDrive = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
5
|
+
tslib_1.__exportStar(require("./api"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./asset.interface"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./content.interface"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./data.interface"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./data.service"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./endpoint.interface"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./http.service"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./secret.interface"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./timeseries.interface"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("./task.interface"), exports);
|
|
15
|
+
tslib_1.__exportStar(require("./events.interface"), exports);
|
|
16
|
+
tslib_1.__exportStar(require("./mock"), exports);
|
|
17
|
+
tslib_1.__exportStar(require("./flow-deployment.interface"), exports);
|
|
18
|
+
tslib_1.__exportStar(require("./flow-function.interface"), exports);
|
|
19
|
+
tslib_1.__exportStar(require("./flow.interface"), exports);
|
|
20
|
+
tslib_1.__exportStar(require("./resource.interface"), exports);
|
|
21
|
+
tslib_1.__exportStar(require("./schema.interface"), exports);
|
|
22
|
+
exports.SiDrive = tslib_1.__importStar(require("./sidriveiq.interface"));
|