@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/mock/api.mock.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { API } from '../api';
|
|
2
|
-
import { Asset, AssetType } from '../asset.interface';
|
|
2
|
+
import { Asset, AssetRevision, AssetType } from '../asset.interface';
|
|
3
3
|
import { Content } from '../content.interface';
|
|
4
4
|
import { Secret } from '../secret.interface';
|
|
5
5
|
import { TimeSeries, TimeSeriesValue } from '../timeseries.interface';
|
|
@@ -15,6 +15,15 @@ import { Task } from '../task.interface';
|
|
|
15
15
|
import { TimeseriesMockService } from './timeseries.mock.service';
|
|
16
16
|
import { TaskMockService } from './task.mock.service';
|
|
17
17
|
import { UserMockService } from './user.mock.service';
|
|
18
|
+
import { FlowDeploymentService } from '../flow-deployment.service';
|
|
19
|
+
import { FlowFunctionService } from '../flow-function.service';
|
|
20
|
+
import { FlowModuleService } from '../flow-module.service';
|
|
21
|
+
import { FlowService } from '../flow.service';
|
|
22
|
+
import { FlowDiagram, FlowDto } from '../flow.interface';
|
|
23
|
+
import { FlowDeployment } from '../flow-deployment.interface';
|
|
24
|
+
import { FlowFunctionDto } from '../flow-function.interface';
|
|
25
|
+
import { FlowModule } from '../flow-module.interface';
|
|
26
|
+
import { Artifact } from '../storage.interface';
|
|
18
27
|
export declare class MockAPI implements API {
|
|
19
28
|
httpClient: any;
|
|
20
29
|
assets: AssetMockService;
|
|
@@ -22,6 +31,10 @@ export declare class MockAPI implements API {
|
|
|
22
31
|
contents: ContentMockService;
|
|
23
32
|
endpoints: EndpointMockService;
|
|
24
33
|
events: EventsMockService;
|
|
34
|
+
flows: FlowService;
|
|
35
|
+
flowDeployments: FlowDeploymentService;
|
|
36
|
+
flowFunctions: FlowFunctionService;
|
|
37
|
+
flowModules: FlowModuleService;
|
|
25
38
|
proxy: any;
|
|
26
39
|
secrets: SecretMockService;
|
|
27
40
|
tasks: TaskMockService;
|
|
@@ -38,6 +51,7 @@ export declare class MockAPI implements API {
|
|
|
38
51
|
userManager: UserMockService;
|
|
39
52
|
constructor(initData: {
|
|
40
53
|
assets?: AssetInit[];
|
|
54
|
+
revisions?: AssetRevisionInit[];
|
|
41
55
|
contents?: ContentInit[];
|
|
42
56
|
endpoints?: EndpointInit[];
|
|
43
57
|
secrets?: SecretInit[];
|
|
@@ -45,6 +59,11 @@ export declare class MockAPI implements API {
|
|
|
45
59
|
tasks?: TaskInit[];
|
|
46
60
|
events?: EventInit[];
|
|
47
61
|
users?: UserInit;
|
|
62
|
+
flows?: FlowInit[];
|
|
63
|
+
deployments?: FlowDeploymentInit[];
|
|
64
|
+
functions?: FlowFunctionInit[];
|
|
65
|
+
modules?: FlowModuleInit[];
|
|
66
|
+
diagrams?: FlowDiagramInit[];
|
|
48
67
|
});
|
|
49
68
|
}
|
|
50
69
|
export declare type Identity<T> = {
|
|
@@ -55,6 +74,7 @@ export declare type Replace<T, K extends keyof T, TReplace> = Identity<Pick<T, E
|
|
|
55
74
|
[P in K]: TReplace;
|
|
56
75
|
}>;
|
|
57
76
|
export declare type AssetInit = Replace<AtLeast<Asset, 'id' | 'name' | 'type'>, 'type', AssetTypeInit | string>;
|
|
77
|
+
export declare type AssetRevisionInit = Replace<AtLeast<AssetRevision, 'id' | 'name' | 'type'>, 'type', AssetTypeInit | string>;
|
|
58
78
|
export declare type AssetTypeInit = AtLeast<AssetType, 'id' | 'name'>;
|
|
59
79
|
export declare type ContentInit = Identity<AtLeast<Content, 'id' | 'filename'> & {
|
|
60
80
|
filePath?: string;
|
|
@@ -67,6 +87,16 @@ export declare type TimeSeriesInit = Identity<AtLeast<TimeSeries, 'id' | 'name'>
|
|
|
67
87
|
}>;
|
|
68
88
|
export declare type TaskInit = AtLeast<Task, 'name' | 'assignedTo'>;
|
|
69
89
|
export declare type EventInit = AtLeast<Event, 'name'>;
|
|
90
|
+
export declare type FlowInit = AtLeast<FlowDto, 'id'>;
|
|
91
|
+
export declare type FlowDeploymentInit = AtLeast<FlowDeployment, 'id' | 'flow'>;
|
|
92
|
+
export declare type FlowFunctionInit = AtLeast<Identity<FlowFunctionDto & {
|
|
93
|
+
id: string;
|
|
94
|
+
}>, 'fqn' | 'id'>;
|
|
95
|
+
export declare type FlowModuleInit = Replace<AtLeast<FlowModule, 'name'>, 'artifacts', ArtifactInit[]>;
|
|
96
|
+
export declare type ArtifactInit = AtLeast<Artifact & {
|
|
97
|
+
path: string;
|
|
98
|
+
}, 'filename' | 'path'>;
|
|
99
|
+
export declare type FlowDiagramInit = AtLeast<FlowDiagram, 'id' | 'flow'>;
|
|
70
100
|
export interface UserInit {
|
|
71
101
|
roles: string[];
|
|
72
102
|
}
|
package/dist/mock/api.mock.js
CHANGED
|
@@ -11,12 +11,17 @@ const secret_mock_service_1 = require("./secret.mock.service");
|
|
|
11
11
|
const timeseries_mock_service_1 = require("./timeseries.mock.service");
|
|
12
12
|
const task_mock_service_1 = require("./task.mock.service");
|
|
13
13
|
const user_mock_service_1 = require("./user.mock.service");
|
|
14
|
+
const flow_mock_service_1 = require("./flow.mock.service");
|
|
15
|
+
const flow_deployment_mock_service_1 = require("./flow-deployment.mock.service");
|
|
16
|
+
const flow_functions_mock_service_1 = require("./flow-functions.mock.service");
|
|
17
|
+
const flow_modules_mock_service_1 = require("./flow-modules.mock.service");
|
|
18
|
+
const crypto_1 = require("crypto");
|
|
14
19
|
class MockAPI {
|
|
15
20
|
constructor(initData) {
|
|
16
21
|
this.httpClient = null;
|
|
17
22
|
this.proxy = null;
|
|
18
23
|
this.siDrive = null;
|
|
19
|
-
const { assets = [], contents = [], endpoints = [], secrets = [], timeSeries = [], tasks = [], events = [], users } = initData;
|
|
24
|
+
const { assets = [], revisions = [], contents = [], endpoints = [], secrets = [], timeSeries = [], tasks = [], events = [], users, flows = [], deployments = [], functions = [], modules = [], diagrams = [], } = initData;
|
|
20
25
|
const assetTypes = assets
|
|
21
26
|
.map((v) => v.type)
|
|
22
27
|
.map((v) => {
|
|
@@ -32,6 +37,7 @@ class MockAPI {
|
|
|
32
37
|
};
|
|
33
38
|
});
|
|
34
39
|
const assets1 = assets.map((v, index) => (Object.assign(Object.assign({}, v), { readPermissions: [], readWritePermissions: [], type: assetTypes[index] })));
|
|
40
|
+
const revisions1 = revisions.map((v, index) => (Object.assign(Object.assign({}, v), { readPermissions: [], readWritePermissions: [], type: assetTypes[index] })));
|
|
35
41
|
const contents1 = contents.map((v) => (Object.assign(Object.assign({}, v), { readPermissions: [], readWritePermissions: [], size: 0, fileId: '', mimetype: v.mimetype || '' })));
|
|
36
42
|
const contentData = contents.map((v) => {
|
|
37
43
|
return v.data ? v.data : (0, fs_1.readFileSync)((0, path_1.join)(v.filePath, v.filename));
|
|
@@ -90,7 +96,32 @@ class MockAPI {
|
|
|
90
96
|
group: v.group,
|
|
91
97
|
}));
|
|
92
98
|
const timeseriesValues = timeSeries.map((v) => v.values);
|
|
93
|
-
|
|
99
|
+
const diagrams1 = diagrams.map((v) => (Object.assign(Object.assign({}, v), { json: '', author: 'nobody' })));
|
|
100
|
+
const flows1 = flows.map((v) => (Object.assign(Object.assign({}, v), { readPermissions: [], readWritePermissions: [], diagram: diagrams.find((v1) => v1.flow === v.id).id, name: `flow-${v.id}`, deployments: [] })));
|
|
101
|
+
const deployments1 = deployments.map((v) => {
|
|
102
|
+
var _a;
|
|
103
|
+
return (Object.assign(Object.assign({}, v), { readPermissions: [], readWritePermissions: [], diagram: (_a = v.diagram) !== null && _a !== void 0 ? _a : '', artifact: null, flowModel: { connections: [], elements: [] }, desiredStatus: 'running', actualStatus: 'generating queued', target: 'executor', name: `deployment-${v.id}` }));
|
|
104
|
+
});
|
|
105
|
+
const functions1 = functions.map((v) => {
|
|
106
|
+
var _a;
|
|
107
|
+
return (Object.assign(Object.assign({}, v), { category: 'task', readPermissions: [], readWritePermissions: [], author: 'nobody', current: v.id, history: [v.id, ...((_a = v === null || v === void 0 ? void 0 : v.history) !== null && _a !== void 0 ? _a : [])] }));
|
|
108
|
+
});
|
|
109
|
+
const historyMap = new Map();
|
|
110
|
+
functions1.forEach((func) => {
|
|
111
|
+
func.history.forEach((hist) => {
|
|
112
|
+
if (historyMap.has(func.fqn)) {
|
|
113
|
+
historyMap.get(func.fqn).push(functions1.find((v) => v.id === hist));
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
historyMap.set(func.fqn, [functions1.find((v) => v.id === hist)]);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
const modules1 = modules.map((v, index) => {
|
|
121
|
+
var _a;
|
|
122
|
+
return (Object.assign(Object.assign({}, v), { artifacts: (_a = modules[index].artifacts.map((art) => (Object.assign(Object.assign({}, art), { version: '0.0.0', id: (0, crypto_1.randomUUID)(), mimetype: '', size: 0, createdAt: '' + Date.now() })))) !== null && _a !== void 0 ? _a : [], author: 'nobody', functions: [], readPermissions: [], readWritePermissions: [] }));
|
|
123
|
+
});
|
|
124
|
+
this.assets = new asset_mock_service_1.AssetMockService(this, assets1, revisions1);
|
|
94
125
|
this.contents = new content_mock_service_1.ContentMockService(contents1, contentData);
|
|
95
126
|
this.endpoints = new endpoint_mock_service_1.EndpointMockService(endpoint1);
|
|
96
127
|
this.secrets = new secret_mock_service_1.SecretMockService(secrets1);
|
|
@@ -98,6 +129,10 @@ class MockAPI {
|
|
|
98
129
|
this.tasks = new task_mock_service_1.TaskMockService(tasks1);
|
|
99
130
|
this.events = new events_mock_service_1.EventsMockService(events1);
|
|
100
131
|
this.users = new user_mock_service_1.UserMockService(users);
|
|
132
|
+
this.flows = new flow_mock_service_1.FlowMockService(flows1, diagrams1);
|
|
133
|
+
this.flowDeployments = new flow_deployment_mock_service_1.FlowDeploymentMockService(deployments1, this);
|
|
134
|
+
this.flowFunctions = new flow_functions_mock_service_1.FlowFunctionsMockService(functions1, historyMap);
|
|
135
|
+
this.flowModules = new flow_modules_mock_service_1.FlowModulesMockService(modules1);
|
|
101
136
|
this.assetManager = this.assets;
|
|
102
137
|
this.contentManager = this.contents;
|
|
103
138
|
this.endpointManager = this.endpoints;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import FormData from 'form-data';
|
|
2
|
-
import { Asset } from '../asset.interface';
|
|
2
|
+
import { Asset, AssetRevision } from '../asset.interface';
|
|
3
3
|
import { AssetService } from '../asset.service';
|
|
4
4
|
import { Paginated, RequestParameter } from '../data.interface';
|
|
5
5
|
import { MockAPI } from './api.mock';
|
|
6
6
|
import { DataMockService } from './data.mock.service';
|
|
7
7
|
export declare class AssetMockService extends DataMockService<Asset> implements AssetService {
|
|
8
8
|
private api;
|
|
9
|
-
|
|
9
|
+
private revisions;
|
|
10
|
+
constructor(api: MockAPI, assets: Asset[], revisions: AssetRevision[]);
|
|
10
11
|
addAttachment(id: string, form: FormData): Promise<Asset>;
|
|
11
12
|
getChildren(assetId: string, params?: RequestParameter): Promise<Paginated<Asset[]>>;
|
|
13
|
+
findRevisions(assetId: string): Promise<Paginated<AssetRevision[]>>;
|
|
12
14
|
}
|
|
@@ -3,10 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AssetMockService = void 0;
|
|
4
4
|
const data_mock_service_1 = require("./data.mock.service");
|
|
5
5
|
class AssetMockService extends data_mock_service_1.DataMockService {
|
|
6
|
-
constructor(api, assets) {
|
|
6
|
+
constructor(api, assets, revisions) {
|
|
7
7
|
super();
|
|
8
8
|
this.api = api;
|
|
9
|
+
this.revisions = [];
|
|
9
10
|
this.data = assets;
|
|
11
|
+
this.revisions = revisions;
|
|
10
12
|
}
|
|
11
13
|
async addAttachment(id, form) {
|
|
12
14
|
const asset = this.data.find((v) => v.id === id);
|
|
@@ -17,5 +19,14 @@ class AssetMockService extends data_mock_service_1.DataMockService {
|
|
|
17
19
|
getChildren(assetId, params = {}) {
|
|
18
20
|
return this.getManyFiltered({ parent: assetId }, params);
|
|
19
21
|
}
|
|
22
|
+
findRevisions(assetId) {
|
|
23
|
+
const newData = this.revisions.filter((revision) => revision.originalId === assetId);
|
|
24
|
+
const page = {
|
|
25
|
+
docs: newData,
|
|
26
|
+
limit: Number.MAX_SAFE_INTEGER,
|
|
27
|
+
total: newData.length,
|
|
28
|
+
};
|
|
29
|
+
return Promise.resolve(page);
|
|
30
|
+
}
|
|
20
31
|
}
|
|
21
32
|
exports.AssetMockService = AssetMockService;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DataMockService } from './data.mock.service';
|
|
2
|
+
import { FlowDeployment, FlowDeploymentMetrics, FlowDeploymentStatistic, FlowLog } from '../flow-deployment.interface';
|
|
3
|
+
import { FlowDeploymentService } from '../flow-deployment.service';
|
|
4
|
+
import { ResourceReference } from '../resource.interface';
|
|
5
|
+
import { MockAPI } from './api.mock';
|
|
6
|
+
export declare class FlowDeploymentMockService extends DataMockService<FlowDeployment> implements FlowDeploymentService {
|
|
7
|
+
private api;
|
|
8
|
+
constructor(deployments: FlowDeployment[], api: MockAPI);
|
|
9
|
+
subscribeToStatus(id: string, listener: (event: MessageEvent<any>) => void, errorListener?: (event: MessageEvent<any>) => void): Promise<string>;
|
|
10
|
+
subscribeToLogs(id: string, listener: (event: MessageEvent<any>) => void, errorListener?: (event: MessageEvent) => void): Promise<string>;
|
|
11
|
+
waitForRunningStatus(id: string): Promise<void>;
|
|
12
|
+
updateStatus(id: string, desiredStatus: 'running' | 'stopped' | 'deleted'): Promise<FlowDeployment>;
|
|
13
|
+
resolveReferences(id: string, recursive?: boolean, types?: string[]): Promise<ResourceReference[]>;
|
|
14
|
+
getDeploymentStatistics(id: string): Promise<FlowDeploymentStatistic>;
|
|
15
|
+
getDeploymentMetrics(id: string, range?: string, interval?: string): Promise<FlowDeploymentMetrics>;
|
|
16
|
+
getDeploymentLogs(id: string): Promise<FlowLog[]>;
|
|
17
|
+
addOne(dto: {
|
|
18
|
+
diagramId: string;
|
|
19
|
+
name: string;
|
|
20
|
+
properties?: Record<string, any>;
|
|
21
|
+
readPermissions?: string[];
|
|
22
|
+
readWritePermissions?: string[];
|
|
23
|
+
tags?: string[];
|
|
24
|
+
}): Promise<FlowDeployment>;
|
|
25
|
+
deleteOne(id: string): Promise<FlowDeployment>;
|
|
26
|
+
private getReferences;
|
|
27
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowDeploymentMockService = void 0;
|
|
4
|
+
const data_mock_service_1 = require("./data.mock.service");
|
|
5
|
+
const crypto_1 = require("crypto");
|
|
6
|
+
class FlowDeploymentMockService extends data_mock_service_1.DataMockService {
|
|
7
|
+
constructor(deployments, api) {
|
|
8
|
+
super();
|
|
9
|
+
this.api = api;
|
|
10
|
+
this.data = deployments;
|
|
11
|
+
}
|
|
12
|
+
subscribeToStatus(id, listener, errorListener) {
|
|
13
|
+
listener(new MessageEvent('message', { data: 'running' }));
|
|
14
|
+
return Promise.resolve((0, crypto_1.randomUUID)());
|
|
15
|
+
}
|
|
16
|
+
subscribeToLogs(id, listener, errorListener) {
|
|
17
|
+
listener(new MessageEvent('message', { data: 'foo' }));
|
|
18
|
+
return Promise.resolve((0, crypto_1.randomUUID)());
|
|
19
|
+
}
|
|
20
|
+
async waitForRunningStatus(id) {
|
|
21
|
+
const flowDeployment = this.data.find((v) => v.id === id);
|
|
22
|
+
flowDeployment.actualStatus = 'running';
|
|
23
|
+
}
|
|
24
|
+
async updateStatus(id, desiredStatus) {
|
|
25
|
+
const deployment = await this.getOne(id);
|
|
26
|
+
deployment.desiredStatus = desiredStatus;
|
|
27
|
+
deployment.actualStatus = desiredStatus;
|
|
28
|
+
return Promise.resolve(deployment);
|
|
29
|
+
}
|
|
30
|
+
async resolveReferences(id, recursive, types) {
|
|
31
|
+
var _a;
|
|
32
|
+
const depl = await this.getOne(id);
|
|
33
|
+
return (_a = depl.refs) !== null && _a !== void 0 ? _a : [];
|
|
34
|
+
}
|
|
35
|
+
getDeploymentStatistics(id) {
|
|
36
|
+
return Promise.resolve({
|
|
37
|
+
totalErrorCount: 0,
|
|
38
|
+
errorCountWeek: 0,
|
|
39
|
+
eventCountWeek: 0,
|
|
40
|
+
errorCounts: [],
|
|
41
|
+
metrics: {
|
|
42
|
+
cpu: 0,
|
|
43
|
+
memory: 97931264,
|
|
44
|
+
ctime: 16770,
|
|
45
|
+
elapsed: 172850950,
|
|
46
|
+
timestamp: 1648199692625,
|
|
47
|
+
deploymentId: id,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
getDeploymentMetrics(id, range, interval) {
|
|
52
|
+
return Promise.resolve({
|
|
53
|
+
metrics: [{ timestamp: Date.now(), cpu: 0, memory: Math.random() * 1000000 }],
|
|
54
|
+
stats: {
|
|
55
|
+
cpu: { count: 123, avg: 0, max: 0, min: 0, sum: 0 },
|
|
56
|
+
memory: { count: 123, avg: 0, max: 0, min: 0, sum: 0 },
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
async getDeploymentLogs(id) {
|
|
61
|
+
const depl = await this.getOne(id);
|
|
62
|
+
return Promise.resolve([
|
|
63
|
+
{
|
|
64
|
+
type: 'flow.log.info',
|
|
65
|
+
deploymentId: id,
|
|
66
|
+
subject: 'FlowApplication',
|
|
67
|
+
data: 'Flow Deployment is running',
|
|
68
|
+
'@timestamp': '2022-03-23T09:14:03.129Z',
|
|
69
|
+
eventId: 'c68b7674-b8da-46c5-85f0-8e4279d74a78',
|
|
70
|
+
datacontenttype: 'text/plain',
|
|
71
|
+
elementId: 'none',
|
|
72
|
+
time: '2022-03-23T09:14:03.129Z',
|
|
73
|
+
flowId: depl.flow,
|
|
74
|
+
},
|
|
75
|
+
]);
|
|
76
|
+
}
|
|
77
|
+
async addOne(dto) {
|
|
78
|
+
const flow = await this.api.flows.getFlowWithDiagram(dto.diagramId);
|
|
79
|
+
const refs = await this.getReferences(dto.properties);
|
|
80
|
+
const id = (0, crypto_1.randomUUID)();
|
|
81
|
+
const newDepl = {
|
|
82
|
+
actualStatus: 'generating queued',
|
|
83
|
+
artifact: undefined,
|
|
84
|
+
desiredStatus: 'running',
|
|
85
|
+
diagram: dto.diagramId,
|
|
86
|
+
flow: flow.id,
|
|
87
|
+
flowModel: { elements: [], connections: [], properties: dto.properties },
|
|
88
|
+
id,
|
|
89
|
+
name: dto.name,
|
|
90
|
+
readPermissions: [],
|
|
91
|
+
readWritePermissions: [],
|
|
92
|
+
target: 'executor',
|
|
93
|
+
refs,
|
|
94
|
+
};
|
|
95
|
+
await this.api.flows.updateOne(flow.id, Object.assign(Object.assign({}, flow), { deployments: [...flow.deployments, id] }));
|
|
96
|
+
return super.addOne(newDepl);
|
|
97
|
+
}
|
|
98
|
+
async deleteOne(id) {
|
|
99
|
+
const depl = await this.getOne(id);
|
|
100
|
+
const flow = await this.api.flows.getOne(depl.flow);
|
|
101
|
+
const index = flow.deployments.findIndex((v) => v === id);
|
|
102
|
+
flow.deployments.splice(index, 1);
|
|
103
|
+
await this.api.flows.updateOne(flow.id, flow);
|
|
104
|
+
return super.deleteOne(id);
|
|
105
|
+
}
|
|
106
|
+
async getReferences(properties) {
|
|
107
|
+
return Promise.all(Object.keys(properties).map(async (prop) => {
|
|
108
|
+
switch (prop) {
|
|
109
|
+
case 'assetId':
|
|
110
|
+
return { id: (await this.api.assets.getOne(properties[prop])).id, resourceType: 'asset' };
|
|
111
|
+
default:
|
|
112
|
+
throw new Error('not implemented');
|
|
113
|
+
}
|
|
114
|
+
}));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.FlowDeploymentMockService = FlowDeploymentMockService;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DataMockService } from './data.mock.service';
|
|
2
|
+
import { FlowFunctionDto } from '../flow-function.interface';
|
|
3
|
+
import { FlowFunctionService } from '../flow-function.service';
|
|
4
|
+
export declare class FlowFunctionsMockService extends DataMockService<FlowFunctionDto> implements FlowFunctionService {
|
|
5
|
+
private history;
|
|
6
|
+
constructor(functions: FlowFunctionDto[], history: Map<string, Array<FlowFunctionDto & {
|
|
7
|
+
id: string;
|
|
8
|
+
}>>);
|
|
9
|
+
getOneWithHistory(fqn: string): Promise<FlowFunctionDto>;
|
|
10
|
+
rollback(fqn: string, historyId: string): Promise<FlowFunctionDto>;
|
|
11
|
+
getOne(fqn: string, options?: any): Promise<FlowFunctionDto>;
|
|
12
|
+
private getOneById;
|
|
13
|
+
updateOne(fqn: string, dto: FlowFunctionDto): Promise<FlowFunctionDto>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowFunctionsMockService = void 0;
|
|
4
|
+
const data_mock_service_1 = require("./data.mock.service");
|
|
5
|
+
const crypto_1 = require("crypto");
|
|
6
|
+
class FlowFunctionsMockService extends data_mock_service_1.DataMockService {
|
|
7
|
+
constructor(functions, history) {
|
|
8
|
+
super();
|
|
9
|
+
this.history = history;
|
|
10
|
+
this.data = functions;
|
|
11
|
+
}
|
|
12
|
+
async getOneWithHistory(fqn) {
|
|
13
|
+
const func = await this.getOne(fqn);
|
|
14
|
+
return Promise.resolve(Object.assign(Object.assign({}, func), { history: await Promise.all(func.history.map(async (v) => {
|
|
15
|
+
const func1 = (await this.getOneById(v));
|
|
16
|
+
return { author: func1.author, createdAt: '', id: func1.id };
|
|
17
|
+
})) }));
|
|
18
|
+
}
|
|
19
|
+
rollback(fqn, historyId) {
|
|
20
|
+
const hist = this.history.get(fqn).find((v) => v.id === historyId);
|
|
21
|
+
const index = this.data.findIndex((v) => v.fqn === fqn);
|
|
22
|
+
hist.current = hist.id;
|
|
23
|
+
this.data[index] = hist;
|
|
24
|
+
return Promise.resolve(hist);
|
|
25
|
+
}
|
|
26
|
+
getOne(fqn, options) {
|
|
27
|
+
const t = this.data.find((v) => v.fqn === fqn);
|
|
28
|
+
return Promise.resolve(t);
|
|
29
|
+
}
|
|
30
|
+
async getOneById(id) {
|
|
31
|
+
return this.data.find((v) => v.id === id);
|
|
32
|
+
}
|
|
33
|
+
async updateOne(fqn, dto) {
|
|
34
|
+
const id = (0, crypto_1.randomUUID)();
|
|
35
|
+
const exDto = Object.assign(Object.assign({}, dto), { id, current: id });
|
|
36
|
+
exDto.history.push(id);
|
|
37
|
+
this.history.get(fqn).push(exDto);
|
|
38
|
+
return exDto;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.FlowFunctionsMockService = FlowFunctionsMockService;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { DataMockService } from './data.mock.service';
|
|
3
|
+
import { FlowModule } from '../flow-module.interface';
|
|
4
|
+
import { FlowModuleService } from '../flow-module.service';
|
|
5
|
+
import { ReadStream } from 'fs';
|
|
6
|
+
import { Artifact } from '../storage.interface';
|
|
7
|
+
import { Replace } from './api.mock';
|
|
8
|
+
declare type ExtendedFlowModule = Replace<FlowModule, 'artifacts', Array<Artifact & {
|
|
9
|
+
path: string;
|
|
10
|
+
}>>;
|
|
11
|
+
export declare class FlowModulesMockService extends DataMockService<ExtendedFlowModule> implements FlowModuleService {
|
|
12
|
+
constructor(modules: ExtendedFlowModule[]);
|
|
13
|
+
deleteArtifact(name: string, version: string): Promise<FlowModule>;
|
|
14
|
+
download(name: string, filePath: string, version?: string): Promise<void>;
|
|
15
|
+
publish(file: ReadStream): Promise<unknown>;
|
|
16
|
+
getOne(name: string, options?: any): Promise<ExtendedFlowModule>;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowModulesMockService = void 0;
|
|
4
|
+
const data_mock_service_1 = require("./data.mock.service");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const promises_1 = require("stream/promises");
|
|
7
|
+
class FlowModulesMockService extends data_mock_service_1.DataMockService {
|
|
8
|
+
constructor(modules) {
|
|
9
|
+
super();
|
|
10
|
+
this.data = modules;
|
|
11
|
+
}
|
|
12
|
+
async deleteArtifact(name, version) {
|
|
13
|
+
const module = await this.getOne(name);
|
|
14
|
+
const index = module.artifacts.findIndex((art) => art.version === version);
|
|
15
|
+
module.artifacts.splice(index, 1);
|
|
16
|
+
return Promise.resolve(module);
|
|
17
|
+
}
|
|
18
|
+
async download(name, filePath, version = 'latest') {
|
|
19
|
+
var _a, _b;
|
|
20
|
+
const module = await this.getOne(name);
|
|
21
|
+
const reader = (0, fs_1.createReadStream)((_b = (_a = module.artifacts.find((art) => art.version === version)) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : module.artifacts[0].path);
|
|
22
|
+
const writer = (0, fs_1.createWriteStream)(filePath);
|
|
23
|
+
reader.pipe(writer);
|
|
24
|
+
return (0, promises_1.finished)(writer);
|
|
25
|
+
}
|
|
26
|
+
publish(file) {
|
|
27
|
+
return Promise.resolve(undefined);
|
|
28
|
+
}
|
|
29
|
+
getOne(name, options = {}) {
|
|
30
|
+
const t = this.data.find((v) => v.name === name);
|
|
31
|
+
return Promise.resolve(t);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.FlowModulesMockService = FlowModulesMockService;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DataMockService } from './data.mock.service';
|
|
2
|
+
import { FlowDiagram, FlowDto } from '../flow.interface';
|
|
3
|
+
import { FlowService } from '../flow.service';
|
|
4
|
+
import { Paginated, RequestParameter } from '../data.interface';
|
|
5
|
+
export declare class FlowMockService extends DataMockService<FlowDto> implements FlowService {
|
|
6
|
+
private diagrams;
|
|
7
|
+
constructor(flows: FlowDto[], diagrams: FlowDiagram[]);
|
|
8
|
+
getFlowWithDiagram(diagramId: string): Promise<FlowDto>;
|
|
9
|
+
getMany(params?: RequestParameter): Promise<Paginated<FlowDto[]>>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowMockService = void 0;
|
|
4
|
+
const data_mock_service_1 = require("./data.mock.service");
|
|
5
|
+
class FlowMockService extends data_mock_service_1.DataMockService {
|
|
6
|
+
constructor(flows, diagrams) {
|
|
7
|
+
super();
|
|
8
|
+
this.diagrams = diagrams;
|
|
9
|
+
this.data = flows;
|
|
10
|
+
}
|
|
11
|
+
getFlowWithDiagram(diagramId) {
|
|
12
|
+
return Promise.resolve(this.data.find((v1) => v1.id === this.diagrams.find((v) => v.id === diagramId).flow));
|
|
13
|
+
}
|
|
14
|
+
async getMany(params) {
|
|
15
|
+
const flows = await super.getMany(params);
|
|
16
|
+
return {
|
|
17
|
+
docs: flows.docs.map((v) => (Object.assign(Object.assign({}, v), { diagram: this.diagrams.find((v1) => v1.id === v.diagram) }))),
|
|
18
|
+
total: 0,
|
|
19
|
+
limit: 0,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.FlowMockService = FlowMockService;
|
package/dist/mock/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
tslib_1.__exportStar(require("./api.mock"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./asset.mock.service"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./assetTypes.mock.service"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./content.mock.service"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./data.mock.service"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./secret.mock.service"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./timeseries.mock.service"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./task.mock.service"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./events.mock.service"), exports);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface ResourceReference {
|
|
2
|
+
id: string;
|
|
3
|
+
resourceType: string;
|
|
4
|
+
dependent?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface Resource {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
readPermissions: string[];
|
|
10
|
+
readWritePermissions: string[];
|
|
11
|
+
description?: string;
|
|
12
|
+
author?: string;
|
|
13
|
+
tags?: string[];
|
|
14
|
+
refs?: ResourceReference[];
|
|
15
|
+
createdAt?: string | Date;
|
|
16
|
+
updatedAt?: string | Date;
|
|
17
|
+
deleteddAt?: string | Date;
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface JsonSchemaForm {
|
|
2
|
+
schema: JsonSchema;
|
|
3
|
+
layout: Record<string, any> | Record<string, any>[];
|
|
4
|
+
}
|
|
5
|
+
export declare type JsonSchemaTypeName = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null';
|
|
6
|
+
export declare type JsonSchemaType = string | number | boolean | {
|
|
7
|
+
[key: string]: JsonSchemaType;
|
|
8
|
+
} | JsonSchemaArray | null;
|
|
9
|
+
export declare type JsonSchemaArray = Array<JsonSchemaType>;
|
|
10
|
+
export interface JsonSchema {
|
|
11
|
+
default?: JsonSchemaType;
|
|
12
|
+
description?: string;
|
|
13
|
+
items?: JsonSchema | JsonSchema[];
|
|
14
|
+
properties?: Record<string, JsonSchema>;
|
|
15
|
+
required?: boolean | string[];
|
|
16
|
+
title?: string;
|
|
17
|
+
type?: JsonSchemaTypeName | JsonSchemaTypeName[];
|
|
18
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare type FileType = 'original' | 'preview-sm' | 'preview-md' | 'preview-lg' | 'preview-xl';
|
|
2
|
+
export 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
|
+
}
|
|
13
|
+
export interface Artifact extends Storage {
|
|
14
|
+
version: string;
|
|
15
|
+
functions?: string[];
|
|
16
|
+
}
|
package/dist/user.service.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UserService = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const jwt_decode_1 =
|
|
5
|
+
const jwt_decode_1 = tslib_1.__importDefault(require("jwt-decode"));
|
|
6
6
|
class UserService {
|
|
7
7
|
constructor(httpClient) {
|
|
8
8
|
this.httpClient = httpClient;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hahnpro/hpc-api",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Module for easy access to the HahnPRO API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -24,13 +24,15 @@
|
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"axios": "^0.
|
|
27
|
+
"axios": "^0.26.1",
|
|
28
|
+
"eventsource": "^2.0.0",
|
|
28
29
|
"form-data": "^4.0.0",
|
|
29
30
|
"jwt-decode": "^3.1.2",
|
|
30
31
|
"p-queue": "^6.6.2"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
|
-
"axios-mock-adapter": "^1.20.0"
|
|
34
|
+
"axios-mock-adapter": "^1.20.0",
|
|
35
|
+
"@types/eventsource": "^1.1.8"
|
|
34
36
|
},
|
|
35
37
|
"engines": {
|
|
36
38
|
"node": ">=v14.13"
|