@hahnpro/hpc-api 2.2.0 → 3.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/dist/asset.interface.d.ts +18 -12
- package/dist/asset.service.d.ts +3 -1
- package/dist/asset.service.js +7 -1
- package/dist/assettypes.service.d.ts +4 -0
- package/dist/assettypes.service.js +9 -0
- package/dist/content.service.d.ts +1 -0
- package/dist/content.service.js +1 -1
- package/dist/flow-function.interface.d.ts +4 -6
- package/dist/flow-function.service.d.ts +4 -2
- package/dist/flow-function.service.js +7 -4
- package/dist/flow-module.service.d.ts +2 -4
- package/dist/flow-module.service.js +1 -14
- package/dist/flow.interface.d.ts +3 -0
- package/dist/flow.service.d.ts +7 -1
- package/dist/flow.service.js +18 -0
- package/dist/mock/api.mock.d.ts +9 -7
- package/dist/mock/api.mock.js +8 -20
- package/dist/mock/asset.mock.service.d.ts +6 -1
- package/dist/mock/asset.mock.service.js +34 -6
- package/dist/mock/assetTypes.mock.service.d.ts +10 -2
- package/dist/mock/assetTypes.mock.service.js +40 -1
- package/dist/mock/content.mock.service.d.ts +1 -0
- package/dist/mock/content.mock.service.js +1 -1
- package/dist/mock/flow-functions.mock.service.d.ts +10 -8
- package/dist/mock/flow-functions.mock.service.js +38 -19
- package/dist/mock/flow-modules.mock.service.d.ts +2 -4
- package/dist/mock/flow-modules.mock.service.js +1 -11
- package/dist/mock/flow.mock.service.d.ts +12 -2
- package/dist/mock/flow.mock.service.js +49 -1
- package/dist/mock/timeseries.mock.service.js +3 -3
- package/dist/resource.interface.d.ts +1 -0
- package/package.json +5 -5
|
@@ -13,34 +13,35 @@ export interface AssetType {
|
|
|
13
13
|
actions?: string[];
|
|
14
14
|
createdAt?: string;
|
|
15
15
|
updatedAt?: string;
|
|
16
|
+
author?: string;
|
|
17
|
+
revision?: number;
|
|
16
18
|
}
|
|
17
|
-
export
|
|
19
|
+
export declare type AssetTypeRevision = AssetType & {
|
|
20
|
+
originalId: string;
|
|
21
|
+
};
|
|
22
|
+
export interface Asset {
|
|
18
23
|
id?: string;
|
|
19
24
|
name: string;
|
|
20
25
|
type: string | AssetType;
|
|
26
|
+
type$name?: string;
|
|
21
27
|
readPermissions: string[];
|
|
22
28
|
readWritePermissions: string[];
|
|
23
29
|
parent?: any | Asset;
|
|
30
|
+
parent$name?: string;
|
|
24
31
|
ancestors?: string[];
|
|
25
32
|
tags?: string[];
|
|
26
33
|
relations?: any[];
|
|
27
34
|
data?: any;
|
|
28
35
|
image?: string;
|
|
29
|
-
author?: string;
|
|
30
|
-
revision?: number;
|
|
31
|
-
}
|
|
32
|
-
export interface Asset extends AssetParent {
|
|
33
|
-
type$name?: string;
|
|
34
|
-
parent$name?: string;
|
|
35
36
|
attachments?: string[];
|
|
36
37
|
notificationEndpoints?: string[];
|
|
37
38
|
actions?: string[];
|
|
39
|
+
author?: string;
|
|
40
|
+
revision?: number;
|
|
38
41
|
}
|
|
39
|
-
export
|
|
40
|
-
originalId
|
|
41
|
-
|
|
42
|
-
updatedAt?: string;
|
|
43
|
-
}
|
|
42
|
+
export declare type AssetRevision = Asset & {
|
|
43
|
+
originalId: string;
|
|
44
|
+
};
|
|
44
45
|
export interface Attachment {
|
|
45
46
|
id?: string;
|
|
46
47
|
filename: string;
|
|
@@ -61,4 +62,9 @@ export interface Action {
|
|
|
61
62
|
responseType?: string;
|
|
62
63
|
readPermissions: string[];
|
|
63
64
|
readWritePermissions: string[];
|
|
65
|
+
author?: string;
|
|
66
|
+
revision?: number;
|
|
64
67
|
}
|
|
68
|
+
export declare type ActionRevision = Action & {
|
|
69
|
+
originalId: string;
|
|
70
|
+
};
|
package/dist/asset.service.d.ts
CHANGED
|
@@ -7,5 +7,7 @@ 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
|
-
|
|
10
|
+
getRevisions(assetId: string): Promise<Paginated<AssetRevision[]>>;
|
|
11
|
+
rollback(assetId: string, revisionId: string): Promise<Asset>;
|
|
12
|
+
deleteRevision(assetId: string, revisionId: string): Promise<any>;
|
|
11
13
|
}
|
package/dist/asset.service.js
CHANGED
|
@@ -17,8 +17,14 @@ class AssetService extends data_service_1.DataService {
|
|
|
17
17
|
getChildren(assetId, params = {}) {
|
|
18
18
|
return this.getManyFiltered({ parent: assetId }, params);
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
getRevisions(assetId) {
|
|
21
21
|
return this.httpClient.get(`${this.basePath}/${assetId}/revisions`);
|
|
22
22
|
}
|
|
23
|
+
rollback(assetId, revisionId) {
|
|
24
|
+
return this.httpClient.put(`${this.basePath}/${assetId}/rollback`, { revisionId });
|
|
25
|
+
}
|
|
26
|
+
deleteRevision(assetId, revisionId) {
|
|
27
|
+
return this.httpClient.delete(`${this.basePath}/${assetId}/revisions/${revisionId}`);
|
|
28
|
+
}
|
|
23
29
|
}
|
|
24
30
|
exports.AssetService = AssetService;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { AssetType } from './asset.interface';
|
|
2
2
|
import { DataService } from './data.service';
|
|
3
3
|
import { HttpClient } from './http.service';
|
|
4
|
+
import { Paginated } from './data.interface';
|
|
4
5
|
export declare class AssetTypesService extends DataService<AssetType> {
|
|
5
6
|
constructor(httpClient: HttpClient);
|
|
7
|
+
getRevisions(id: string): Promise<Paginated<AssetType[]>>;
|
|
8
|
+
rollback(id: string, revisionId: string): Promise<AssetType>;
|
|
9
|
+
deleteRevision(id: string, revisionId: string): Promise<any>;
|
|
6
10
|
}
|
|
@@ -6,5 +6,14 @@ class AssetTypesService extends data_service_1.DataService {
|
|
|
6
6
|
constructor(httpClient) {
|
|
7
7
|
super(httpClient, '/assettypes');
|
|
8
8
|
}
|
|
9
|
+
getRevisions(id) {
|
|
10
|
+
return this.httpClient.get(`${this.basePath}/${id}/revisions`);
|
|
11
|
+
}
|
|
12
|
+
rollback(id, revisionId) {
|
|
13
|
+
return this.httpClient.put(`${this.basePath}/${id}/rollback`, { revisionId });
|
|
14
|
+
}
|
|
15
|
+
deleteRevision(id, revisionId) {
|
|
16
|
+
return this.httpClient.delete(`${this.basePath}/${id}/revisions/${revisionId}`);
|
|
17
|
+
}
|
|
9
18
|
}
|
|
10
19
|
exports.AssetTypesService = AssetTypesService;
|
package/dist/content.service.js
CHANGED
|
@@ -13,7 +13,7 @@ class ContentService extends data_service_1.DataService {
|
|
|
13
13
|
}
|
|
14
14
|
async download(id, second) {
|
|
15
15
|
let returnType;
|
|
16
|
-
if (typeof second === 'boolean' ||
|
|
16
|
+
if (typeof second === 'boolean' || second == null) {
|
|
17
17
|
returnType = second ? content_interface_1.ReturnType.ARRAYBUFFER : content_interface_1.ReturnType.BLOB;
|
|
18
18
|
}
|
|
19
19
|
else {
|
|
@@ -4,8 +4,6 @@ export interface FlowFunctionDto {
|
|
|
4
4
|
readPermissions: string[];
|
|
5
5
|
readWritePermissions: string[];
|
|
6
6
|
author: string;
|
|
7
|
-
current: string;
|
|
8
|
-
history: string[] | HistoryEntry[];
|
|
9
7
|
name?: string;
|
|
10
8
|
description?: string;
|
|
11
9
|
icon?: string;
|
|
@@ -17,12 +15,12 @@ export interface FlowFunctionDto {
|
|
|
17
15
|
tags?: string[];
|
|
18
16
|
createdAt?: string;
|
|
19
17
|
updatedAt?: string;
|
|
18
|
+
revision?: string;
|
|
20
19
|
}
|
|
21
|
-
export
|
|
22
|
-
author: string;
|
|
23
|
-
createdAt: string;
|
|
20
|
+
export declare type FlowFunctionRevision = FlowFunctionDto & {
|
|
24
21
|
id: string;
|
|
25
|
-
|
|
22
|
+
originalId: string;
|
|
23
|
+
};
|
|
26
24
|
interface Stream {
|
|
27
25
|
name: string;
|
|
28
26
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { DataService } from './data.service';
|
|
2
2
|
import { FlowFunctionDto } from './flow-function.interface';
|
|
3
3
|
import { HttpClient } from './http.service';
|
|
4
|
+
import { Paginated } from './data.interface';
|
|
4
5
|
export declare class FlowFunctionService extends DataService<FlowFunctionDto> {
|
|
5
6
|
constructor(httpClient: HttpClient);
|
|
6
7
|
addMany(dto: any[]): Promise<FlowFunctionDto[]>;
|
|
7
|
-
|
|
8
|
-
rollback(fqn: string,
|
|
8
|
+
getRevisions(fqn: string): Promise<Paginated<FlowFunctionDto[]>>;
|
|
9
|
+
rollback(fqn: string, revisionId: string): Promise<FlowFunctionDto>;
|
|
10
|
+
deleteRevision(fqn: string, revisionId: string): Promise<any>;
|
|
9
11
|
}
|
|
@@ -10,11 +10,14 @@ class FlowFunctionService extends data_service_1.DataService {
|
|
|
10
10
|
const reqs = dto.map((v) => this.addOne(v));
|
|
11
11
|
return Promise.all(reqs);
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
return this.httpClient.get(`${this.basePath}/${fqn}/
|
|
13
|
+
getRevisions(fqn) {
|
|
14
|
+
return this.httpClient.get(`${this.basePath}/${fqn}/revisions`);
|
|
15
15
|
}
|
|
16
|
-
rollback(fqn,
|
|
17
|
-
return this.httpClient.put(`${this.basePath}/${fqn}/rollback
|
|
16
|
+
rollback(fqn, revisionId) {
|
|
17
|
+
return this.httpClient.put(`${this.basePath}/${fqn}/rollback`, { revisionId });
|
|
18
|
+
}
|
|
19
|
+
deleteRevision(fqn, revisionId) {
|
|
20
|
+
return this.httpClient.delete(`${this.basePath}/${fqn}/revisions/${revisionId}`);
|
|
18
21
|
}
|
|
19
22
|
}
|
|
20
23
|
exports.FlowFunctionService = FlowFunctionService;
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { DataService } from './data.service';
|
|
3
2
|
import { FlowModule } from './flow-module.interface';
|
|
4
3
|
import { HttpClient } from './http.service';
|
|
5
|
-
import
|
|
4
|
+
import FormData from 'form-data';
|
|
6
5
|
export declare class FlowModuleService extends DataService<FlowModule> {
|
|
7
6
|
constructor(httpClient: HttpClient);
|
|
8
7
|
deleteArtifact(name: string, version: string): Promise<FlowModule>;
|
|
9
|
-
|
|
10
|
-
publish(file: ReadStream): Promise<unknown>;
|
|
8
|
+
publish(form: FormData): Promise<unknown>;
|
|
11
9
|
addOne(dto: any): Promise<FlowModule>;
|
|
12
10
|
addMany(dto: any[]): Promise<FlowModule[]>;
|
|
13
11
|
}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FlowModuleService = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
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
5
|
class FlowModuleService extends data_service_1.DataService {
|
|
10
6
|
constructor(httpClient) {
|
|
11
7
|
super(httpClient, '/flow/modules');
|
|
@@ -13,16 +9,7 @@ class FlowModuleService extends data_service_1.DataService {
|
|
|
13
9
|
deleteArtifact(name, version) {
|
|
14
10
|
return this.httpClient.delete(`${this.basePath}/${name}/${version}`);
|
|
15
11
|
}
|
|
16
|
-
|
|
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);
|
|
12
|
+
publish(form) {
|
|
26
13
|
const config = {
|
|
27
14
|
headers: Object.assign({}, form.getHeaders()),
|
|
28
15
|
maxBodyLength: Infinity,
|
package/dist/flow.interface.d.ts
CHANGED
package/dist/flow.service.d.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { DataService } from './data.service';
|
|
2
|
-
import { FlowDto } from './flow.interface';
|
|
2
|
+
import { FlowDiagram, FlowDto } from './flow.interface';
|
|
3
3
|
import { HttpClient } from './http.service';
|
|
4
4
|
import { Paginated, RequestParameter } from './data.interface';
|
|
5
|
+
import { FlowDeployment } from './flow-deployment.interface';
|
|
5
6
|
export declare class FlowService extends DataService<FlowDto> {
|
|
6
7
|
constructor(httpClient: HttpClient);
|
|
7
8
|
addMany(dto: any[]): Promise<FlowDto[]>;
|
|
8
9
|
getMany(params?: RequestParameter): Promise<Paginated<FlowDto[]>>;
|
|
9
10
|
getOne(id: string, options?: any): Promise<FlowDto>;
|
|
10
11
|
getFlowWithDiagram(diagramId: string): Promise<FlowDto>;
|
|
12
|
+
getDiagramRevisions(id: string): Promise<FlowDiagram[]>;
|
|
13
|
+
isDeploymentOnLatestDiagramVersion(depl: FlowDeployment): Promise<boolean>;
|
|
14
|
+
getRevisions(id: string): Promise<Paginated<FlowDto[]>>;
|
|
15
|
+
rollback(id: string, revisionId: string): Promise<FlowDto>;
|
|
16
|
+
deleteRevision(id: string, revisionId: string): Promise<any>;
|
|
11
17
|
}
|
package/dist/flow.service.js
CHANGED
|
@@ -21,5 +21,23 @@ class FlowService extends data_service_1.DataService {
|
|
|
21
21
|
getFlowWithDiagram(diagramId) {
|
|
22
22
|
return this.httpClient.get(`${this.basePath}/diagram/${diagramId}`);
|
|
23
23
|
}
|
|
24
|
+
getDiagramRevisions(id) {
|
|
25
|
+
return this.httpClient.get(`${this.basePath}/${id}/revisions`);
|
|
26
|
+
}
|
|
27
|
+
async isDeploymentOnLatestDiagramVersion(depl) {
|
|
28
|
+
const flowId = typeof depl.flow === 'string' ? depl.flow : depl.flow.id;
|
|
29
|
+
const diagramId = typeof depl.diagram === 'string' ? depl.diagram : depl.diagram.id;
|
|
30
|
+
const revisions = await this.getDiagramRevisions(flowId);
|
|
31
|
+
return revisions.reverse()[0].id === diagramId;
|
|
32
|
+
}
|
|
33
|
+
getRevisions(id) {
|
|
34
|
+
return this.httpClient.get(`${this.basePath}/${id}/revisions`);
|
|
35
|
+
}
|
|
36
|
+
rollback(id, revisionId) {
|
|
37
|
+
return this.httpClient.put(`${this.basePath}/${id}/rollback`, { revisionId });
|
|
38
|
+
}
|
|
39
|
+
deleteRevision(id, revisionId) {
|
|
40
|
+
return this.httpClient.delete(`${this.basePath}/${id}/revisions/${revisionId}`);
|
|
41
|
+
}
|
|
24
42
|
}
|
|
25
43
|
exports.FlowService = FlowService;
|
package/dist/mock/api.mock.d.ts
CHANGED
|
@@ -19,9 +19,9 @@ import { FlowDeploymentService } from '../flow-deployment.service';
|
|
|
19
19
|
import { FlowFunctionService } from '../flow-function.service';
|
|
20
20
|
import { FlowModuleService } from '../flow-module.service';
|
|
21
21
|
import { FlowService } from '../flow.service';
|
|
22
|
-
import { FlowDiagram, FlowDto } from '../flow.interface';
|
|
22
|
+
import { FlowDiagram, FlowDto, FlowRevision } from '../flow.interface';
|
|
23
23
|
import { FlowDeployment } from '../flow-deployment.interface';
|
|
24
|
-
import { FlowFunctionDto } from '../flow-function.interface';
|
|
24
|
+
import { FlowFunctionDto, FlowFunctionRevision } from '../flow-function.interface';
|
|
25
25
|
import { FlowModule } from '../flow-module.interface';
|
|
26
26
|
import { Artifact } from '../storage.interface';
|
|
27
27
|
export declare class MockAPI implements API {
|
|
@@ -51,7 +51,7 @@ export declare class MockAPI implements API {
|
|
|
51
51
|
userManager: UserMockService;
|
|
52
52
|
constructor(initData: {
|
|
53
53
|
assets?: AssetInit[];
|
|
54
|
-
|
|
54
|
+
assetRevisions?: AssetRevisionInit[];
|
|
55
55
|
contents?: ContentInit[];
|
|
56
56
|
endpoints?: EndpointInit[];
|
|
57
57
|
secrets?: SecretInit[];
|
|
@@ -60,8 +60,10 @@ export declare class MockAPI implements API {
|
|
|
60
60
|
events?: EventInit[];
|
|
61
61
|
users?: UserInit;
|
|
62
62
|
flows?: FlowInit[];
|
|
63
|
+
flowRevisions?: FlowRevisionInit[];
|
|
63
64
|
deployments?: FlowDeploymentInit[];
|
|
64
65
|
functions?: FlowFunctionInit[];
|
|
66
|
+
functionRevisions?: FlowFunctionRevisionInit[];
|
|
65
67
|
modules?: FlowModuleInit[];
|
|
66
68
|
diagrams?: FlowDiagramInit[];
|
|
67
69
|
});
|
|
@@ -74,7 +76,7 @@ export declare type Replace<T, K extends keyof T, TReplace> = Identity<Pick<T, E
|
|
|
74
76
|
[P in K]: TReplace;
|
|
75
77
|
}>;
|
|
76
78
|
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>;
|
|
79
|
+
export declare type AssetRevisionInit = Replace<AtLeast<AssetRevision, 'id' | 'name' | 'type' | 'originalId'>, 'type', AssetTypeInit | string>;
|
|
78
80
|
export declare type AssetTypeInit = AtLeast<AssetType, 'id' | 'name'>;
|
|
79
81
|
export declare type ContentInit = Identity<AtLeast<Content, 'id' | 'filename'> & {
|
|
80
82
|
filePath?: string;
|
|
@@ -88,10 +90,10 @@ export declare type TimeSeriesInit = Identity<AtLeast<TimeSeries, 'id' | 'name'>
|
|
|
88
90
|
export declare type TaskInit = AtLeast<Task, 'name' | 'assignedTo'>;
|
|
89
91
|
export declare type EventInit = AtLeast<Event, 'name'>;
|
|
90
92
|
export declare type FlowInit = AtLeast<FlowDto, 'id'>;
|
|
93
|
+
export declare type FlowRevisionInit = AtLeast<FlowRevision, 'id' | 'originalId'>;
|
|
91
94
|
export declare type FlowDeploymentInit = AtLeast<FlowDeployment, 'id' | 'flow'>;
|
|
92
|
-
export declare type FlowFunctionInit = AtLeast<
|
|
93
|
-
|
|
94
|
-
}>, 'fqn' | 'id'>;
|
|
95
|
+
export declare type FlowFunctionInit = AtLeast<FlowFunctionDto, 'fqn'>;
|
|
96
|
+
export declare type FlowFunctionRevisionInit = AtLeast<FlowFunctionRevision, 'fqn' | 'id' | 'originalId'>;
|
|
95
97
|
export declare type FlowModuleInit = Replace<AtLeast<FlowModule, 'name'>, 'artifacts', ArtifactInit[]>;
|
|
96
98
|
export declare type ArtifactInit = AtLeast<Artifact & {
|
|
97
99
|
path: string;
|
package/dist/mock/api.mock.js
CHANGED
|
@@ -21,7 +21,7 @@ class MockAPI {
|
|
|
21
21
|
this.httpClient = null;
|
|
22
22
|
this.proxy = null;
|
|
23
23
|
this.siDrive = null;
|
|
24
|
-
const { assets = [],
|
|
24
|
+
const { assets = [], assetRevisions = [], contents = [], endpoints = [], secrets = [], timeSeries = [], tasks = [], events = [], users, flows = [], flowRevisions = [], deployments = [], functions = [], functionRevisions = [], modules = [], diagrams = [], } = initData;
|
|
25
25
|
const assetTypes = assets
|
|
26
26
|
.map((v) => v.type)
|
|
27
27
|
.map((v) => {
|
|
@@ -37,7 +37,7 @@ class MockAPI {
|
|
|
37
37
|
};
|
|
38
38
|
});
|
|
39
39
|
const assets1 = assets.map((v, index) => (Object.assign(Object.assign({}, v), { readPermissions: [], readWritePermissions: [], type: assetTypes[index] })));
|
|
40
|
-
const
|
|
40
|
+
const assetRevisions1 = assetRevisions.map((v, index) => (Object.assign(Object.assign({}, v), { readPermissions: [], readWritePermissions: [], type: assetTypes[index] })));
|
|
41
41
|
const contents1 = contents.map((v) => (Object.assign(Object.assign({}, v), { readPermissions: [], readWritePermissions: [], size: 0, fileId: '', mimetype: v.mimetype || '' })));
|
|
42
42
|
const contentData = contents.map((v) => {
|
|
43
43
|
return v.data ? v.data : (0, fs_1.readFileSync)((0, path_1.join)(v.filePath, v.filename));
|
|
@@ -98,30 +98,18 @@ class MockAPI {
|
|
|
98
98
|
const timeseriesValues = timeSeries.map((v) => v.values);
|
|
99
99
|
const diagrams1 = diagrams.map((v) => (Object.assign(Object.assign({}, v), { json: '', author: 'nobody' })));
|
|
100
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 flowRevisions1 = flowRevisions.map((v) => (Object.assign(Object.assign({}, v), { readPermissions: [], readWritePermissions: [], diagram: diagrams.find((v1) => v1.flow === v.originalId).id, name: `flow-${v.id}`, deployments: [] })));
|
|
101
102
|
const deployments1 = deployments.map((v) => {
|
|
102
103
|
var _a;
|
|
103
104
|
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
|
});
|
|
105
|
-
const functions1 = functions.map((v) => {
|
|
106
|
-
|
|
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
|
-
});
|
|
106
|
+
const functions1 = functions.map((v) => (Object.assign(Object.assign({}, v), { category: 'task', readPermissions: [], readWritePermissions: [], author: 'nobody' })));
|
|
107
|
+
const functionRevisions1 = functionRevisions.map((v) => (Object.assign(Object.assign({}, v), { category: 'task', readPermissions: [], readWritePermissions: [], author: 'nobody' })));
|
|
120
108
|
const modules1 = modules.map((v, index) => {
|
|
121
109
|
var _a;
|
|
122
110
|
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
111
|
});
|
|
124
|
-
this.assets = new asset_mock_service_1.AssetMockService(this, assets1,
|
|
112
|
+
this.assets = new asset_mock_service_1.AssetMockService(this, assets1, assetRevisions1);
|
|
125
113
|
this.contents = new content_mock_service_1.ContentMockService(contents1, contentData);
|
|
126
114
|
this.endpoints = new endpoint_mock_service_1.EndpointMockService(endpoint1);
|
|
127
115
|
this.secrets = new secret_mock_service_1.SecretMockService(secrets1);
|
|
@@ -129,9 +117,9 @@ class MockAPI {
|
|
|
129
117
|
this.tasks = new task_mock_service_1.TaskMockService(tasks1);
|
|
130
118
|
this.events = new events_mock_service_1.EventsMockService(events1);
|
|
131
119
|
this.users = new user_mock_service_1.UserMockService(users);
|
|
132
|
-
this.flows = new flow_mock_service_1.FlowMockService(flows1, diagrams1);
|
|
120
|
+
this.flows = new flow_mock_service_1.FlowMockService(flows1, diagrams1, flowRevisions1);
|
|
133
121
|
this.flowDeployments = new flow_deployment_mock_service_1.FlowDeploymentMockService(deployments1, this);
|
|
134
|
-
this.flowFunctions = new flow_functions_mock_service_1.FlowFunctionsMockService(functions1,
|
|
122
|
+
this.flowFunctions = new flow_functions_mock_service_1.FlowFunctionsMockService(functions1, functionRevisions1);
|
|
135
123
|
this.flowModules = new flow_modules_mock_service_1.FlowModulesMockService(modules1);
|
|
136
124
|
this.assetManager = this.assets;
|
|
137
125
|
this.contentManager = this.contents;
|
|
@@ -8,7 +8,12 @@ export declare class AssetMockService extends DataMockService<Asset> implements
|
|
|
8
8
|
private api;
|
|
9
9
|
private revisions;
|
|
10
10
|
constructor(api: MockAPI, assets: Asset[], revisions: AssetRevision[]);
|
|
11
|
+
addOne(dto: Asset): Promise<Asset>;
|
|
12
|
+
deleteOne(assetId: string): Promise<any>;
|
|
13
|
+
updateOne(assetId: string, dto: Asset): Promise<Asset>;
|
|
11
14
|
addAttachment(id: string, form: FormData): Promise<Asset>;
|
|
12
15
|
getChildren(assetId: string, params?: RequestParameter): Promise<Paginated<Asset[]>>;
|
|
13
|
-
|
|
16
|
+
getRevisions(assetId: string): Promise<Paginated<AssetRevision[]>>;
|
|
17
|
+
rollback(assetId: string, revisionId: string): Promise<Asset>;
|
|
18
|
+
deleteRevision(assetId: string, revisionId: string): Promise<any>;
|
|
14
19
|
}
|
|
@@ -2,13 +2,32 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AssetMockService = void 0;
|
|
4
4
|
const data_mock_service_1 = require("./data.mock.service");
|
|
5
|
+
const crypto_1 = require("crypto");
|
|
5
6
|
class AssetMockService extends data_mock_service_1.DataMockService {
|
|
6
7
|
constructor(api, assets, revisions) {
|
|
7
8
|
super();
|
|
8
9
|
this.api = api;
|
|
9
|
-
this.revisions = [];
|
|
10
|
-
this.data = assets;
|
|
11
10
|
this.revisions = revisions;
|
|
11
|
+
this.data = assets;
|
|
12
|
+
}
|
|
13
|
+
addOne(dto) {
|
|
14
|
+
const id = (0, crypto_1.randomUUID)();
|
|
15
|
+
this.revisions.push(Object.assign(Object.assign({}, dto), { originalId: dto.id }));
|
|
16
|
+
return super.addOne(dto);
|
|
17
|
+
}
|
|
18
|
+
deleteOne(assetId) {
|
|
19
|
+
this.revisions
|
|
20
|
+
.filter((revision) => revision.originalId === assetId)
|
|
21
|
+
.forEach((revision) => {
|
|
22
|
+
const index = this.revisions.indexOf(revision);
|
|
23
|
+
this.revisions.splice(index, 1);
|
|
24
|
+
});
|
|
25
|
+
return super.deleteOne(assetId);
|
|
26
|
+
}
|
|
27
|
+
async updateOne(assetId, dto) {
|
|
28
|
+
await super.deleteOne(assetId);
|
|
29
|
+
const asset = await this.addOne(dto);
|
|
30
|
+
return Promise.resolve(asset);
|
|
12
31
|
}
|
|
13
32
|
async addAttachment(id, form) {
|
|
14
33
|
const asset = this.data.find((v) => v.id === id);
|
|
@@ -19,14 +38,23 @@ class AssetMockService extends data_mock_service_1.DataMockService {
|
|
|
19
38
|
getChildren(assetId, params = {}) {
|
|
20
39
|
return this.getManyFiltered({ parent: assetId }, params);
|
|
21
40
|
}
|
|
22
|
-
|
|
23
|
-
const
|
|
41
|
+
getRevisions(assetId) {
|
|
42
|
+
const revisions = this.revisions.filter((revision) => revision.originalId === assetId);
|
|
24
43
|
const page = {
|
|
25
|
-
docs:
|
|
44
|
+
docs: revisions,
|
|
26
45
|
limit: Number.MAX_SAFE_INTEGER,
|
|
27
|
-
total:
|
|
46
|
+
total: revisions.length,
|
|
28
47
|
};
|
|
29
48
|
return Promise.resolve(page);
|
|
30
49
|
}
|
|
50
|
+
rollback(assetId, revisionId) {
|
|
51
|
+
const asset = this.revisions.find((revision) => revision.id === revisionId);
|
|
52
|
+
return Promise.resolve(asset);
|
|
53
|
+
}
|
|
54
|
+
deleteRevision(assetId, revisionId) {
|
|
55
|
+
const index = this.revisions.findIndex((revision) => revision.id === revisionId);
|
|
56
|
+
this.revisions.splice(index, 1);
|
|
57
|
+
return Promise.resolve(revisionId);
|
|
58
|
+
}
|
|
31
59
|
}
|
|
32
60
|
exports.AssetMockService = AssetMockService;
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import { AssetType } from '../asset.interface';
|
|
1
|
+
import { AssetType, AssetTypeRevision } from '../asset.interface';
|
|
2
2
|
import { AssetTypesService } from '../assettypes.service';
|
|
3
3
|
import { DataMockService } from './data.mock.service';
|
|
4
|
+
import { Paginated } from '../data.interface';
|
|
4
5
|
export declare class AssetTypesMockService extends DataMockService<AssetType> implements AssetTypesService {
|
|
5
|
-
|
|
6
|
+
private revisions;
|
|
7
|
+
constructor(assetTypes: AssetType[], revisions: AssetTypeRevision[]);
|
|
8
|
+
addOne(dto: AssetType): Promise<AssetType>;
|
|
9
|
+
deleteOne(id: string): Promise<any>;
|
|
10
|
+
updateOne(id: string, dto: AssetType): Promise<AssetType>;
|
|
11
|
+
getRevisions(id: string): Promise<Paginated<AssetTypeRevision[]>>;
|
|
12
|
+
rollback(id: string, revisionId: string): Promise<AssetType>;
|
|
13
|
+
deleteRevision(assetId: string, revisionId: string): Promise<any>;
|
|
6
14
|
}
|
|
@@ -2,10 +2,49 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AssetTypesMockService = void 0;
|
|
4
4
|
const data_mock_service_1 = require("./data.mock.service");
|
|
5
|
+
const crypto_1 = require("crypto");
|
|
5
6
|
class AssetTypesMockService extends data_mock_service_1.DataMockService {
|
|
6
|
-
constructor(assetTypes) {
|
|
7
|
+
constructor(assetTypes, revisions) {
|
|
7
8
|
super();
|
|
9
|
+
this.revisions = revisions;
|
|
8
10
|
this.data = assetTypes;
|
|
9
11
|
}
|
|
12
|
+
addOne(dto) {
|
|
13
|
+
const id = (0, crypto_1.randomUUID)();
|
|
14
|
+
this.revisions.push(Object.assign(Object.assign({}, dto), { id, originalId: dto.id }));
|
|
15
|
+
return super.addOne(dto);
|
|
16
|
+
}
|
|
17
|
+
deleteOne(id) {
|
|
18
|
+
this.revisions
|
|
19
|
+
.filter((revision) => revision.originalId === id)
|
|
20
|
+
.forEach((revision) => {
|
|
21
|
+
const index = this.revisions.indexOf(revision);
|
|
22
|
+
this.revisions.splice(index, 1);
|
|
23
|
+
});
|
|
24
|
+
return super.deleteOne(id);
|
|
25
|
+
}
|
|
26
|
+
async updateOne(id, dto) {
|
|
27
|
+
await super.deleteOne(id);
|
|
28
|
+
const assetType = await this.addOne(dto);
|
|
29
|
+
return Promise.resolve(assetType);
|
|
30
|
+
}
|
|
31
|
+
getRevisions(id) {
|
|
32
|
+
const revisions = this.revisions.filter((revision) => revision.originalId === id);
|
|
33
|
+
const page = {
|
|
34
|
+
docs: revisions,
|
|
35
|
+
limit: Number.MAX_SAFE_INTEGER,
|
|
36
|
+
total: revisions.length,
|
|
37
|
+
};
|
|
38
|
+
return Promise.resolve(page);
|
|
39
|
+
}
|
|
40
|
+
rollback(id, revisionId) {
|
|
41
|
+
const assetType = this.revisions.find((revision) => revision.id === revisionId);
|
|
42
|
+
return Promise.resolve(assetType);
|
|
43
|
+
}
|
|
44
|
+
deleteRevision(assetId, revisionId) {
|
|
45
|
+
const index = this.revisions.findIndex((revision) => revision.id === revisionId);
|
|
46
|
+
this.revisions.splice(index, 1);
|
|
47
|
+
return Promise.resolve(revisionId);
|
|
48
|
+
}
|
|
10
49
|
}
|
|
11
50
|
exports.AssetTypesMockService = AssetTypesMockService;
|
|
@@ -15,7 +15,7 @@ class ContentMockService extends data_mock_service_1.DataMockService {
|
|
|
15
15
|
}
|
|
16
16
|
download(id, second) {
|
|
17
17
|
let returnType;
|
|
18
|
-
if (typeof second === 'boolean' ||
|
|
18
|
+
if (typeof second === 'boolean' || second == null) {
|
|
19
19
|
returnType = second ? content_interface_1.ReturnType.ARRAYBUFFER : content_interface_1.ReturnType.BLOB;
|
|
20
20
|
}
|
|
21
21
|
else {
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { DataMockService } from './data.mock.service';
|
|
2
|
-
import { FlowFunctionDto } from '../flow-function.interface';
|
|
2
|
+
import { FlowFunctionDto, FlowFunctionRevision } from '../flow-function.interface';
|
|
3
3
|
import { FlowFunctionService } from '../flow-function.service';
|
|
4
|
+
import { Paginated } from '../data.interface';
|
|
4
5
|
export declare class FlowFunctionsMockService extends DataMockService<FlowFunctionDto> implements FlowFunctionService {
|
|
5
|
-
private
|
|
6
|
-
constructor(functions: FlowFunctionDto[],
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
rollback(fqn: string, historyId: string): Promise<FlowFunctionDto>;
|
|
6
|
+
private revisions;
|
|
7
|
+
constructor(functions: FlowFunctionDto[], revisions: FlowFunctionRevision[]);
|
|
8
|
+
addOne(dto: FlowFunctionDto): Promise<FlowFunctionDto>;
|
|
9
|
+
deleteOne(fqn: string): Promise<any>;
|
|
10
|
+
updateOne(fqn: string, dto: FlowFunctionDto): Promise<FlowFunctionDto>;
|
|
11
11
|
getOne(fqn: string, options?: any): Promise<FlowFunctionDto>;
|
|
12
12
|
private getOneById;
|
|
13
|
-
|
|
13
|
+
getRevisions(fqn: string): Promise<Paginated<FlowFunctionRevision[]>>;
|
|
14
|
+
rollback(fqn: string, revisionId: string): Promise<FlowFunctionDto>;
|
|
15
|
+
deleteRevision(fqn: string, revisionId: string): Promise<any>;
|
|
14
16
|
}
|
|
@@ -4,24 +4,32 @@ exports.FlowFunctionsMockService = void 0;
|
|
|
4
4
|
const data_mock_service_1 = require("./data.mock.service");
|
|
5
5
|
const crypto_1 = require("crypto");
|
|
6
6
|
class FlowFunctionsMockService extends data_mock_service_1.DataMockService {
|
|
7
|
-
constructor(functions,
|
|
7
|
+
constructor(functions, revisions) {
|
|
8
8
|
super();
|
|
9
|
-
this.
|
|
9
|
+
this.revisions = revisions;
|
|
10
10
|
this.data = functions;
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
addOne(dto) {
|
|
13
|
+
const id = (0, crypto_1.randomUUID)();
|
|
14
|
+
this.revisions.push(Object.assign(Object.assign({}, dto), { id, originalId: dto.fqn }));
|
|
15
|
+
return super.addOne(dto);
|
|
16
|
+
}
|
|
17
|
+
deleteOne(fqn) {
|
|
18
|
+
const index = this.data.findIndex((v) => v.fqn === fqn);
|
|
19
|
+
this.data.splice(index, 1);
|
|
20
|
+
this.revisions
|
|
21
|
+
.filter((revision) => revision.originalId === fqn)
|
|
22
|
+
.forEach((revision) => {
|
|
23
|
+
const index = this.revisions.indexOf(revision);
|
|
24
|
+
this.revisions.splice(index, 1);
|
|
25
|
+
});
|
|
26
|
+
return Promise.resolve(undefined);
|
|
18
27
|
}
|
|
19
|
-
|
|
20
|
-
const hist = this.history.get(fqn).find((v) => v.id === historyId);
|
|
28
|
+
async updateOne(fqn, dto) {
|
|
21
29
|
const index = this.data.findIndex((v) => v.fqn === fqn);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return Promise.resolve(
|
|
30
|
+
this.data.splice(index, 1);
|
|
31
|
+
const flowFunction = await this.addOne(dto);
|
|
32
|
+
return Promise.resolve(flowFunction);
|
|
25
33
|
}
|
|
26
34
|
getOne(fqn, options) {
|
|
27
35
|
const t = this.data.find((v) => v.fqn === fqn);
|
|
@@ -30,12 +38,23 @@ class FlowFunctionsMockService extends data_mock_service_1.DataMockService {
|
|
|
30
38
|
async getOneById(id) {
|
|
31
39
|
return this.data.find((v) => v.id === id);
|
|
32
40
|
}
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
getRevisions(fqn) {
|
|
42
|
+
const revisions = this.revisions.filter((revision) => revision.originalId === fqn);
|
|
43
|
+
const page = {
|
|
44
|
+
docs: revisions,
|
|
45
|
+
limit: Number.MAX_SAFE_INTEGER,
|
|
46
|
+
total: revisions.length,
|
|
47
|
+
};
|
|
48
|
+
return Promise.resolve(page);
|
|
49
|
+
}
|
|
50
|
+
rollback(fqn, revisionId) {
|
|
51
|
+
const assetType = this.revisions.find((revision) => revision.id === revisionId);
|
|
52
|
+
return Promise.resolve(assetType);
|
|
53
|
+
}
|
|
54
|
+
deleteRevision(fqn, revisionId) {
|
|
55
|
+
const index = this.revisions.findIndex((revision) => revision.id === revisionId);
|
|
56
|
+
this.revisions.splice(index, 1);
|
|
57
|
+
return Promise.resolve(revisionId);
|
|
39
58
|
}
|
|
40
59
|
}
|
|
41
60
|
exports.FlowFunctionsMockService = FlowFunctionsMockService;
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { DataMockService } from './data.mock.service';
|
|
3
2
|
import { FlowModule } from '../flow-module.interface';
|
|
4
3
|
import { FlowModuleService } from '../flow-module.service';
|
|
5
|
-
import { ReadStream } from 'fs';
|
|
6
4
|
import { Artifact } from '../storage.interface';
|
|
7
5
|
import { Replace } from './api.mock';
|
|
6
|
+
import FormData from 'form-data';
|
|
8
7
|
declare type ExtendedFlowModule = Replace<FlowModule, 'artifacts', Array<Artifact & {
|
|
9
8
|
path: string;
|
|
10
9
|
}>>;
|
|
11
10
|
export declare class FlowModulesMockService extends DataMockService<ExtendedFlowModule> implements FlowModuleService {
|
|
12
11
|
constructor(modules: ExtendedFlowModule[]);
|
|
13
12
|
deleteArtifact(name: string, version: string): Promise<FlowModule>;
|
|
14
|
-
|
|
15
|
-
publish(file: ReadStream): Promise<unknown>;
|
|
13
|
+
publish(form: FormData): Promise<unknown>;
|
|
16
14
|
getOne(name: string, options?: any): Promise<ExtendedFlowModule>;
|
|
17
15
|
}
|
|
18
16
|
export {};
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FlowModulesMockService = void 0;
|
|
4
4
|
const data_mock_service_1 = require("./data.mock.service");
|
|
5
|
-
const fs_1 = require("fs");
|
|
6
|
-
const promises_1 = require("stream/promises");
|
|
7
5
|
class FlowModulesMockService extends data_mock_service_1.DataMockService {
|
|
8
6
|
constructor(modules) {
|
|
9
7
|
super();
|
|
@@ -15,15 +13,7 @@ class FlowModulesMockService extends data_mock_service_1.DataMockService {
|
|
|
15
13
|
module.artifacts.splice(index, 1);
|
|
16
14
|
return Promise.resolve(module);
|
|
17
15
|
}
|
|
18
|
-
|
|
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) {
|
|
16
|
+
publish(form) {
|
|
27
17
|
return Promise.resolve(undefined);
|
|
28
18
|
}
|
|
29
19
|
getOne(name, options = {}) {
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import { DataMockService } from './data.mock.service';
|
|
2
|
-
import { FlowDiagram, FlowDto } from '../flow.interface';
|
|
2
|
+
import { FlowDiagram, FlowDto, FlowRevision } from '../flow.interface';
|
|
3
3
|
import { FlowService } from '../flow.service';
|
|
4
4
|
import { Paginated, RequestParameter } from '../data.interface';
|
|
5
|
+
import { FlowDeployment } from '../flow-deployment.interface';
|
|
5
6
|
export declare class FlowMockService extends DataMockService<FlowDto> implements FlowService {
|
|
6
7
|
private diagrams;
|
|
7
|
-
|
|
8
|
+
private revisions;
|
|
9
|
+
constructor(flows: FlowDto[], diagrams: FlowDiagram[], revisions: FlowRevision[]);
|
|
10
|
+
addOne(dto: FlowDto): Promise<FlowDto>;
|
|
11
|
+
deleteOne(id: string): Promise<any>;
|
|
12
|
+
updateOne(id: string, dto: FlowDto): Promise<FlowDto>;
|
|
13
|
+
isDeploymentOnLatestDiagramVersion(depl: FlowDeployment): Promise<boolean>;
|
|
14
|
+
getDiagramRevisions(id: string): Promise<FlowDiagram[]>;
|
|
8
15
|
getFlowWithDiagram(diagramId: string): Promise<FlowDto>;
|
|
9
16
|
getMany(params?: RequestParameter): Promise<Paginated<FlowDto[]>>;
|
|
17
|
+
getRevisions(id: string): Promise<Paginated<FlowRevision[]>>;
|
|
18
|
+
rollback(id: string, revisionId: string): Promise<FlowDto>;
|
|
19
|
+
deleteRevision(id: string, revisionId: string): Promise<any>;
|
|
10
20
|
}
|
|
@@ -2,12 +2,42 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FlowMockService = void 0;
|
|
4
4
|
const data_mock_service_1 = require("./data.mock.service");
|
|
5
|
+
const crypto_1 = require("crypto");
|
|
5
6
|
class FlowMockService extends data_mock_service_1.DataMockService {
|
|
6
|
-
constructor(flows, diagrams) {
|
|
7
|
+
constructor(flows, diagrams, revisions) {
|
|
7
8
|
super();
|
|
8
9
|
this.diagrams = diagrams;
|
|
10
|
+
this.revisions = revisions;
|
|
9
11
|
this.data = flows;
|
|
10
12
|
}
|
|
13
|
+
addOne(dto) {
|
|
14
|
+
const id = (0, crypto_1.randomUUID)();
|
|
15
|
+
this.revisions.push(Object.assign(Object.assign({}, dto), { id, originalId: dto.id }));
|
|
16
|
+
return super.addOne(dto);
|
|
17
|
+
}
|
|
18
|
+
deleteOne(id) {
|
|
19
|
+
this.revisions
|
|
20
|
+
.filter((revision) => revision.originalId === id)
|
|
21
|
+
.forEach((revision) => {
|
|
22
|
+
const index = this.revisions.indexOf(revision);
|
|
23
|
+
this.revisions.splice(index, 1);
|
|
24
|
+
});
|
|
25
|
+
return super.deleteOne(id);
|
|
26
|
+
}
|
|
27
|
+
async updateOne(id, dto) {
|
|
28
|
+
await super.deleteOne(id);
|
|
29
|
+
const flow = await this.addOne(dto);
|
|
30
|
+
return Promise.resolve(flow);
|
|
31
|
+
}
|
|
32
|
+
async isDeploymentOnLatestDiagramVersion(depl) {
|
|
33
|
+
const flowId = typeof depl.flow === 'string' ? depl.flow : depl.flow.id;
|
|
34
|
+
const diagramId = typeof depl.diagram === 'string' ? depl.diagram : depl.diagram.id;
|
|
35
|
+
const revisions = await this.getDiagramRevisions(flowId);
|
|
36
|
+
return revisions.reverse()[0].id === diagramId;
|
|
37
|
+
}
|
|
38
|
+
getDiagramRevisions(id) {
|
|
39
|
+
return Promise.resolve(this.diagrams.filter((v) => v.flow === id));
|
|
40
|
+
}
|
|
11
41
|
getFlowWithDiagram(diagramId) {
|
|
12
42
|
return Promise.resolve(this.data.find((v1) => v1.id === this.diagrams.find((v) => v.id === diagramId).flow));
|
|
13
43
|
}
|
|
@@ -19,5 +49,23 @@ class FlowMockService extends data_mock_service_1.DataMockService {
|
|
|
19
49
|
limit: 0,
|
|
20
50
|
};
|
|
21
51
|
}
|
|
52
|
+
getRevisions(id) {
|
|
53
|
+
const revisions = this.revisions.filter((revision) => revision.originalId === id);
|
|
54
|
+
const page = {
|
|
55
|
+
docs: revisions,
|
|
56
|
+
limit: Number.MAX_SAFE_INTEGER,
|
|
57
|
+
total: revisions.length,
|
|
58
|
+
};
|
|
59
|
+
return Promise.resolve(page);
|
|
60
|
+
}
|
|
61
|
+
rollback(id, revisionId) {
|
|
62
|
+
const flow = this.revisions.find((revision) => revision.id === revisionId);
|
|
63
|
+
return Promise.resolve(flow);
|
|
64
|
+
}
|
|
65
|
+
deleteRevision(id, revisionId) {
|
|
66
|
+
const index = this.revisions.findIndex((revision) => revision.id === revisionId);
|
|
67
|
+
this.revisions.splice(index, 1);
|
|
68
|
+
return Promise.resolve(revisionId);
|
|
69
|
+
}
|
|
22
70
|
}
|
|
23
71
|
exports.FlowMockService = FlowMockService;
|
|
@@ -30,7 +30,7 @@ class TimeseriesMockService extends data_mock_service_1.DataMockService {
|
|
|
30
30
|
}
|
|
31
31
|
async addValue(id, value) {
|
|
32
32
|
const ts = await this.getOne(id, {});
|
|
33
|
-
ts.data.push({ timestamp: new Date().
|
|
33
|
+
ts.data.push({ timestamp: new Date().valueOf(), value });
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
36
|
getManyByAsset(assetId, names) {
|
|
@@ -49,13 +49,13 @@ class TimeseriesMockService extends data_mock_service_1.DataMockService {
|
|
|
49
49
|
async getMostRecentValue(id, before) {
|
|
50
50
|
const ts = await this.getOne(id, {});
|
|
51
51
|
for (const datum of ts.data) {
|
|
52
|
-
if (datum.timestamp < before.
|
|
52
|
+
if (datum.timestamp < before.valueOf()) {
|
|
53
53
|
return datum;
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
async getValues(id, from, limit, group) {
|
|
58
|
-
let timeSeriesValues = await this.getValuesOfPeriod(id, from, new Date().
|
|
58
|
+
let timeSeriesValues = await this.getValuesOfPeriod(id, from, new Date().valueOf(), group);
|
|
59
59
|
if (limit) {
|
|
60
60
|
timeSeriesValues = timeSeriesValues.slice(0, limit);
|
|
61
61
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hahnpro/hpc-api",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Module for easy access to the HahnPRO API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -24,15 +24,15 @@
|
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"axios": "
|
|
28
|
-
"eventsource": "^2.0.
|
|
27
|
+
"axios": "~0.27.2",
|
|
28
|
+
"eventsource": "^2.0.2",
|
|
29
29
|
"form-data": "^4.0.0",
|
|
30
30
|
"jwt-decode": "^3.1.2",
|
|
31
31
|
"p-queue": "^6.6.2"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"
|
|
35
|
-
"
|
|
34
|
+
"@types/eventsource": "^1.1.8",
|
|
35
|
+
"axios-mock-adapter": "^1.20.0"
|
|
36
36
|
},
|
|
37
37
|
"engines": {
|
|
38
38
|
"node": ">=v14.13"
|