@hahnpro/hpc-api 2.3.1 → 3.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/api.d.ts +2 -0
- package/dist/api.js +2 -0
- package/dist/asset.interface.d.ts +19 -12
- package/dist/asset.service.d.ts +11 -1
- package/dist/asset.service.js +24 -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.interface.d.ts +3 -0
- package/dist/flow.service.d.ts +4 -1
- package/dist/flow.service.js +11 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/label.interface.d.ts +8 -0
- package/dist/label.interface.js +2 -0
- package/dist/label.service.d.ts +9 -0
- package/dist/label.service.js +19 -0
- package/dist/mock/api.mock.d.ts +14 -7
- package/dist/mock/api.mock.js +11 -20
- package/dist/mock/asset.mock.service.d.ts +15 -1
- package/dist/mock/asset.mock.service.js +73 -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/data.mock.service.js +2 -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.mock.service.d.ts +10 -3
- package/dist/mock/flow.mock.service.js +42 -3
- package/dist/mock/label.mock.service.d.ts +8 -0
- package/dist/mock/label.mock.service.js +17 -0
- package/dist/resource.interface.d.ts +1 -0
- package/package.json +4 -4
package/dist/api.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { FlowService } from './flow.service';
|
|
|
14
14
|
import { FlowFunctionService } from './flow-function.service';
|
|
15
15
|
import { FlowModuleService } from './flow-module.service';
|
|
16
16
|
import { FlowDeploymentService } from './flow-deployment.service';
|
|
17
|
+
import { LabelService } from './label.service';
|
|
17
18
|
export declare class API {
|
|
18
19
|
httpClient: HttpClient;
|
|
19
20
|
assets: AssetService;
|
|
@@ -25,6 +26,7 @@ export declare class API {
|
|
|
25
26
|
flowDeployments: FlowDeploymentService;
|
|
26
27
|
flowFunctions: FlowFunctionService;
|
|
27
28
|
flowModules: FlowModuleService;
|
|
29
|
+
labels: LabelService;
|
|
28
30
|
proxy: ProxyService;
|
|
29
31
|
secrets: SecretService;
|
|
30
32
|
tasks: TaskService;
|
package/dist/api.js
CHANGED
|
@@ -17,6 +17,7 @@ const flow_service_1 = require("./flow.service");
|
|
|
17
17
|
const flow_function_service_1 = require("./flow-function.service");
|
|
18
18
|
const flow_module_service_1 = require("./flow-module.service");
|
|
19
19
|
const flow_deployment_service_1 = require("./flow-deployment.service");
|
|
20
|
+
const label_service_1 = require("./label.service");
|
|
20
21
|
class API {
|
|
21
22
|
constructor() {
|
|
22
23
|
const normalizePath = (value = '', defaultValue = '') => value.replace(/^\/+|\/+$/g, '') || defaultValue;
|
|
@@ -44,6 +45,7 @@ class API {
|
|
|
44
45
|
this.flowDeployments = new flow_deployment_service_1.FlowDeploymentService(this.httpClient);
|
|
45
46
|
this.flowFunctions = new flow_function_service_1.FlowFunctionService(this.httpClient);
|
|
46
47
|
this.flowModules = new flow_module_service_1.FlowModuleService(this.httpClient);
|
|
48
|
+
this.labels = new label_service_1.LabelService(this.httpClient);
|
|
47
49
|
this.proxy = new proxy_service_1.ProxyService(this.httpClient);
|
|
48
50
|
this.secrets = new secret_service_1.SecretService(this.httpClient);
|
|
49
51
|
this.tasks = new task_service_1.TaskService(this.httpClient);
|
|
@@ -13,34 +13,36 @@ 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;
|
|
41
|
+
deletedAt?: string;
|
|
38
42
|
}
|
|
39
|
-
export
|
|
40
|
-
originalId
|
|
41
|
-
|
|
42
|
-
updatedAt?: string;
|
|
43
|
-
}
|
|
43
|
+
export declare type AssetRevision = Asset & {
|
|
44
|
+
originalId: string;
|
|
45
|
+
};
|
|
44
46
|
export interface Attachment {
|
|
45
47
|
id?: string;
|
|
46
48
|
filename: string;
|
|
@@ -61,4 +63,9 @@ export interface Action {
|
|
|
61
63
|
responseType?: string;
|
|
62
64
|
readPermissions: string[];
|
|
63
65
|
readWritePermissions: string[];
|
|
66
|
+
author?: string;
|
|
67
|
+
revision?: number;
|
|
64
68
|
}
|
|
69
|
+
export declare type ActionRevision = Action & {
|
|
70
|
+
originalId: string;
|
|
71
|
+
};
|
package/dist/asset.service.d.ts
CHANGED
|
@@ -5,7 +5,17 @@ import { DataService } from './data.service';
|
|
|
5
5
|
import { HttpClient } from './http.service';
|
|
6
6
|
export declare class AssetService extends DataService<Asset> {
|
|
7
7
|
constructor(httpClient: HttpClient);
|
|
8
|
+
paperBinRestoreAll(): Promise<Asset[]>;
|
|
9
|
+
paperBinRestoreOne(id: string): Promise<Asset>;
|
|
10
|
+
emptyTrash(offset: number): Promise<{
|
|
11
|
+
acknowledged: boolean;
|
|
12
|
+
deletedCount: number;
|
|
13
|
+
}>;
|
|
14
|
+
getPaperBin(params?: RequestParameter): Promise<Paginated<Asset[]>>;
|
|
15
|
+
deleteOne(id: string, force?: boolean): Promise<any>;
|
|
8
16
|
addAttachment: (id: string, form: FormData) => Promise<Asset>;
|
|
9
17
|
getChildren(assetId: string, params?: RequestParameter): Promise<Paginated<Asset[]>>;
|
|
10
|
-
|
|
18
|
+
getRevisions(assetId: string): Promise<Paginated<AssetRevision[]>>;
|
|
19
|
+
rollback(assetId: string, revisionId: string): Promise<Asset>;
|
|
20
|
+
deleteRevision(assetId: string, revisionId: string): Promise<any>;
|
|
11
21
|
}
|
package/dist/asset.service.js
CHANGED
|
@@ -14,11 +14,34 @@ class AssetService extends data_service_1.DataService {
|
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
+
paperBinRestoreAll() {
|
|
18
|
+
return this.httpClient.put(`${this.basePath}/paperbin/restore`, {});
|
|
19
|
+
}
|
|
20
|
+
paperBinRestoreOne(id) {
|
|
21
|
+
return this.httpClient.put(`${this.basePath}/paperbin/restore/${id}`, {});
|
|
22
|
+
}
|
|
23
|
+
emptyTrash(offset) {
|
|
24
|
+
return this.httpClient.delete(`${this.basePath}/paperbin/clean`, { params: { offset } });
|
|
25
|
+
}
|
|
26
|
+
getPaperBin(params = {}) {
|
|
27
|
+
params.limit = params.limit || 0;
|
|
28
|
+
params.page = params.page || 1;
|
|
29
|
+
return this.httpClient.get(`${this.basePath}/paperbin`, { params });
|
|
30
|
+
}
|
|
31
|
+
deleteOne(id, force = false) {
|
|
32
|
+
return this.httpClient.delete(`${this.basePath}/${id}`, { params: { force } });
|
|
33
|
+
}
|
|
17
34
|
getChildren(assetId, params = {}) {
|
|
18
35
|
return this.getManyFiltered({ parent: assetId }, params);
|
|
19
36
|
}
|
|
20
|
-
|
|
37
|
+
getRevisions(assetId) {
|
|
21
38
|
return this.httpClient.get(`${this.basePath}/${assetId}/revisions`);
|
|
22
39
|
}
|
|
40
|
+
rollback(assetId, revisionId) {
|
|
41
|
+
return this.httpClient.put(`${this.basePath}/${assetId}/rollback`, { revisionId });
|
|
42
|
+
}
|
|
43
|
+
deleteRevision(assetId, revisionId) {
|
|
44
|
+
return this.httpClient.delete(`${this.basePath}/${assetId}/revisions/${revisionId}`);
|
|
45
|
+
}
|
|
23
46
|
}
|
|
24
47
|
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;
|
package/dist/flow.interface.d.ts
CHANGED
package/dist/flow.service.d.ts
CHANGED
|
@@ -9,6 +9,9 @@ export declare class FlowService extends DataService<FlowDto> {
|
|
|
9
9
|
getMany(params?: RequestParameter): Promise<Paginated<FlowDto[]>>;
|
|
10
10
|
getOne(id: string, options?: any): Promise<FlowDto>;
|
|
11
11
|
getFlowWithDiagram(diagramId: string): Promise<FlowDto>;
|
|
12
|
-
|
|
12
|
+
getDiagramRevisions(id: string): Promise<FlowDiagram[]>;
|
|
13
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>;
|
|
14
17
|
}
|
package/dist/flow.service.js
CHANGED
|
@@ -21,14 +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
|
-
|
|
24
|
+
getDiagramRevisions(id) {
|
|
25
25
|
return this.httpClient.get(`${this.basePath}/${id}/revisions`);
|
|
26
26
|
}
|
|
27
27
|
async isDeploymentOnLatestDiagramVersion(depl) {
|
|
28
28
|
const flowId = typeof depl.flow === 'string' ? depl.flow : depl.flow.id;
|
|
29
29
|
const diagramId = typeof depl.diagram === 'string' ? depl.diagram : depl.diagram.id;
|
|
30
|
-
const revisions = await this.
|
|
30
|
+
const revisions = await this.getDiagramRevisions(flowId);
|
|
31
31
|
return revisions.reverse()[0].id === diagramId;
|
|
32
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
|
+
}
|
|
33
42
|
}
|
|
34
43
|
exports.FlowService = FlowService;
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from './data.interface';
|
|
|
5
5
|
export * from './data.service';
|
|
6
6
|
export * from './endpoint.interface';
|
|
7
7
|
export * from './http.service';
|
|
8
|
+
export * from './label.interface';
|
|
8
9
|
export * from './secret.interface';
|
|
9
10
|
export * from './timeseries.interface';
|
|
10
11
|
export * from './task.interface';
|
package/dist/index.js
CHANGED
|
@@ -9,6 +9,7 @@ tslib_1.__exportStar(require("./data.interface"), exports);
|
|
|
9
9
|
tslib_1.__exportStar(require("./data.service"), exports);
|
|
10
10
|
tslib_1.__exportStar(require("./endpoint.interface"), exports);
|
|
11
11
|
tslib_1.__exportStar(require("./http.service"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./label.interface"), exports);
|
|
12
13
|
tslib_1.__exportStar(require("./secret.interface"), exports);
|
|
13
14
|
tslib_1.__exportStar(require("./timeseries.interface"), exports);
|
|
14
15
|
tslib_1.__exportStar(require("./task.interface"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DataService } from './data.service';
|
|
2
|
+
import { HttpClient } from './http.service';
|
|
3
|
+
import { Label } from './label.interface';
|
|
4
|
+
export declare class LabelService extends DataService<Label> {
|
|
5
|
+
constructor(httpClient: HttpClient);
|
|
6
|
+
addMany(dtos: Label[]): Promise<Label[]>;
|
|
7
|
+
getOneByName(name: string): Promise<Label>;
|
|
8
|
+
count(): Promise<number>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LabelService = void 0;
|
|
4
|
+
const data_service_1 = require("./data.service");
|
|
5
|
+
class LabelService extends data_service_1.DataService {
|
|
6
|
+
constructor(httpClient) {
|
|
7
|
+
super(httpClient, '/labels');
|
|
8
|
+
}
|
|
9
|
+
addMany(dtos) {
|
|
10
|
+
return Promise.all(dtos.map((dto) => this.addOne(dto)));
|
|
11
|
+
}
|
|
12
|
+
getOneByName(name) {
|
|
13
|
+
return this.httpClient.get(`${this.basePath}/name/${name}`);
|
|
14
|
+
}
|
|
15
|
+
count() {
|
|
16
|
+
return this.httpClient.get(`${this.basePath}/count`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.LabelService = LabelService;
|
package/dist/mock/api.mock.d.ts
CHANGED
|
@@ -19,11 +19,13 @@ 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
|
+
import { LabelMockService } from './label.mock.service';
|
|
28
|
+
import { Label } from '../label.interface';
|
|
27
29
|
export declare class MockAPI implements API {
|
|
28
30
|
httpClient: any;
|
|
29
31
|
assets: AssetMockService;
|
|
@@ -35,6 +37,7 @@ export declare class MockAPI implements API {
|
|
|
35
37
|
flowDeployments: FlowDeploymentService;
|
|
36
38
|
flowFunctions: FlowFunctionService;
|
|
37
39
|
flowModules: FlowModuleService;
|
|
40
|
+
labels: LabelMockService;
|
|
38
41
|
proxy: any;
|
|
39
42
|
secrets: SecretMockService;
|
|
40
43
|
tasks: TaskMockService;
|
|
@@ -51,7 +54,7 @@ export declare class MockAPI implements API {
|
|
|
51
54
|
userManager: UserMockService;
|
|
52
55
|
constructor(initData: {
|
|
53
56
|
assets?: AssetInit[];
|
|
54
|
-
|
|
57
|
+
assetRevisions?: AssetRevisionInit[];
|
|
55
58
|
contents?: ContentInit[];
|
|
56
59
|
endpoints?: EndpointInit[];
|
|
57
60
|
secrets?: SecretInit[];
|
|
@@ -60,10 +63,13 @@ export declare class MockAPI implements API {
|
|
|
60
63
|
events?: EventInit[];
|
|
61
64
|
users?: UserInit;
|
|
62
65
|
flows?: FlowInit[];
|
|
66
|
+
flowRevisions?: FlowRevisionInit[];
|
|
63
67
|
deployments?: FlowDeploymentInit[];
|
|
64
68
|
functions?: FlowFunctionInit[];
|
|
69
|
+
functionRevisions?: FlowFunctionRevisionInit[];
|
|
65
70
|
modules?: FlowModuleInit[];
|
|
66
71
|
diagrams?: FlowDiagramInit[];
|
|
72
|
+
labels?: LabelInit[];
|
|
67
73
|
});
|
|
68
74
|
}
|
|
69
75
|
export declare type Identity<T> = {
|
|
@@ -74,7 +80,7 @@ export declare type Replace<T, K extends keyof T, TReplace> = Identity<Pick<T, E
|
|
|
74
80
|
[P in K]: TReplace;
|
|
75
81
|
}>;
|
|
76
82
|
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>;
|
|
83
|
+
export declare type AssetRevisionInit = Replace<AtLeast<AssetRevision, 'id' | 'name' | 'type' | 'originalId'>, 'type', AssetTypeInit | string>;
|
|
78
84
|
export declare type AssetTypeInit = AtLeast<AssetType, 'id' | 'name'>;
|
|
79
85
|
export declare type ContentInit = Identity<AtLeast<Content, 'id' | 'filename'> & {
|
|
80
86
|
filePath?: string;
|
|
@@ -88,15 +94,16 @@ export declare type TimeSeriesInit = Identity<AtLeast<TimeSeries, 'id' | 'name'>
|
|
|
88
94
|
export declare type TaskInit = AtLeast<Task, 'name' | 'assignedTo'>;
|
|
89
95
|
export declare type EventInit = AtLeast<Event, 'name'>;
|
|
90
96
|
export declare type FlowInit = AtLeast<FlowDto, 'id'>;
|
|
97
|
+
export declare type FlowRevisionInit = AtLeast<FlowRevision, 'id' | 'originalId'>;
|
|
91
98
|
export declare type FlowDeploymentInit = AtLeast<FlowDeployment, 'id' | 'flow'>;
|
|
92
|
-
export declare type FlowFunctionInit = AtLeast<
|
|
93
|
-
|
|
94
|
-
}>, 'fqn' | 'id'>;
|
|
99
|
+
export declare type FlowFunctionInit = AtLeast<FlowFunctionDto, 'fqn'>;
|
|
100
|
+
export declare type FlowFunctionRevisionInit = AtLeast<FlowFunctionRevision, 'fqn' | 'id' | 'originalId'>;
|
|
95
101
|
export declare type FlowModuleInit = Replace<AtLeast<FlowModule, 'name'>, 'artifacts', ArtifactInit[]>;
|
|
96
102
|
export declare type ArtifactInit = AtLeast<Artifact & {
|
|
97
103
|
path: string;
|
|
98
104
|
}, 'filename' | 'path'>;
|
|
99
105
|
export declare type FlowDiagramInit = AtLeast<FlowDiagram, 'id' | 'flow'>;
|
|
106
|
+
export declare type LabelInit = AtLeast<Label, 'id' | 'name'>;
|
|
100
107
|
export interface UserInit {
|
|
101
108
|
roles: string[];
|
|
102
109
|
}
|
package/dist/mock/api.mock.js
CHANGED
|
@@ -16,12 +16,13 @@ const flow_deployment_mock_service_1 = require("./flow-deployment.mock.service")
|
|
|
16
16
|
const flow_functions_mock_service_1 = require("./flow-functions.mock.service");
|
|
17
17
|
const flow_modules_mock_service_1 = require("./flow-modules.mock.service");
|
|
18
18
|
const crypto_1 = require("crypto");
|
|
19
|
+
const label_mock_service_1 = require("./label.mock.service");
|
|
19
20
|
class MockAPI {
|
|
20
21
|
constructor(initData) {
|
|
21
22
|
this.httpClient = null;
|
|
22
23
|
this.proxy = null;
|
|
23
24
|
this.siDrive = null;
|
|
24
|
-
const { assets = [],
|
|
25
|
+
const { assets = [], assetRevisions = [], contents = [], endpoints = [], secrets = [], timeSeries = [], tasks = [], events = [], users, flows = [], flowRevisions = [], deployments = [], functions = [], functionRevisions = [], modules = [], diagrams = [], labels = [], } = initData;
|
|
25
26
|
const assetTypes = assets
|
|
26
27
|
.map((v) => v.type)
|
|
27
28
|
.map((v) => {
|
|
@@ -37,7 +38,7 @@ class MockAPI {
|
|
|
37
38
|
};
|
|
38
39
|
});
|
|
39
40
|
const assets1 = assets.map((v, index) => (Object.assign(Object.assign({}, v), { readPermissions: [], readWritePermissions: [], type: assetTypes[index] })));
|
|
40
|
-
const
|
|
41
|
+
const assetRevisions1 = assetRevisions.map((v, index) => (Object.assign(Object.assign({}, v), { readPermissions: [], readWritePermissions: [], type: assetTypes[index] })));
|
|
41
42
|
const contents1 = contents.map((v) => (Object.assign(Object.assign({}, v), { readPermissions: [], readWritePermissions: [], size: 0, fileId: '', mimetype: v.mimetype || '' })));
|
|
42
43
|
const contentData = contents.map((v) => {
|
|
43
44
|
return v.data ? v.data : (0, fs_1.readFileSync)((0, path_1.join)(v.filePath, v.filename));
|
|
@@ -98,30 +99,19 @@ class MockAPI {
|
|
|
98
99
|
const timeseriesValues = timeSeries.map((v) => v.values);
|
|
99
100
|
const diagrams1 = diagrams.map((v) => (Object.assign(Object.assign({}, v), { json: '', author: 'nobody' })));
|
|
100
101
|
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: [] })));
|
|
102
|
+
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
103
|
const deployments1 = deployments.map((v) => {
|
|
102
104
|
var _a;
|
|
103
105
|
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
106
|
});
|
|
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
|
-
});
|
|
107
|
+
const functions1 = functions.map((v) => (Object.assign(Object.assign({}, v), { category: 'task', readPermissions: [], readWritePermissions: [], author: 'nobody' })));
|
|
108
|
+
const functionRevisions1 = functionRevisions.map((v) => (Object.assign(Object.assign({}, v), { category: 'task', readPermissions: [], readWritePermissions: [], author: 'nobody' })));
|
|
120
109
|
const modules1 = modules.map((v, index) => {
|
|
121
110
|
var _a;
|
|
122
111
|
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
112
|
});
|
|
124
|
-
|
|
113
|
+
const labels1 = labels.map((label) => (Object.assign(Object.assign({}, label), { color: '', description: '', readPermissions: [], readWritePermissions: [] })));
|
|
114
|
+
this.assets = new asset_mock_service_1.AssetMockService(this, assets1, assetRevisions1);
|
|
125
115
|
this.contents = new content_mock_service_1.ContentMockService(contents1, contentData);
|
|
126
116
|
this.endpoints = new endpoint_mock_service_1.EndpointMockService(endpoint1);
|
|
127
117
|
this.secrets = new secret_mock_service_1.SecretMockService(secrets1);
|
|
@@ -129,10 +119,11 @@ class MockAPI {
|
|
|
129
119
|
this.tasks = new task_mock_service_1.TaskMockService(tasks1);
|
|
130
120
|
this.events = new events_mock_service_1.EventsMockService(events1);
|
|
131
121
|
this.users = new user_mock_service_1.UserMockService(users);
|
|
132
|
-
this.flows = new flow_mock_service_1.FlowMockService(flows1, diagrams1);
|
|
122
|
+
this.flows = new flow_mock_service_1.FlowMockService(flows1, diagrams1, flowRevisions1);
|
|
133
123
|
this.flowDeployments = new flow_deployment_mock_service_1.FlowDeploymentMockService(deployments1, this);
|
|
134
|
-
this.flowFunctions = new flow_functions_mock_service_1.FlowFunctionsMockService(functions1,
|
|
124
|
+
this.flowFunctions = new flow_functions_mock_service_1.FlowFunctionsMockService(functions1, functionRevisions1);
|
|
135
125
|
this.flowModules = new flow_modules_mock_service_1.FlowModulesMockService(modules1);
|
|
126
|
+
this.labels = new label_mock_service_1.LabelMockService(labels1);
|
|
136
127
|
this.assetManager = this.assets;
|
|
137
128
|
this.contentManager = this.contents;
|
|
138
129
|
this.endpointManager = this.endpoints;
|
|
@@ -8,7 +8,21 @@ 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
|
+
paperBinRestoreAll(): Promise<Asset[]>;
|
|
12
|
+
paperBinRestoreOne(id: string): Promise<Asset>;
|
|
13
|
+
emptyTrash(offset: number): Promise<{
|
|
14
|
+
acknowledged: boolean;
|
|
15
|
+
deletedCount: number;
|
|
16
|
+
}>;
|
|
17
|
+
getPaperBin(params?: RequestParameter): Promise<Paginated<Asset[]>>;
|
|
18
|
+
private getAssets;
|
|
19
|
+
addOne(dto: Asset): Promise<Asset>;
|
|
20
|
+
deleteOne(assetId: string, force?: boolean): Promise<Asset>;
|
|
21
|
+
getMany(params?: RequestParameter): Promise<Paginated<Asset[]>>;
|
|
22
|
+
updateOne(assetId: string, dto: Asset): Promise<Asset>;
|
|
11
23
|
addAttachment(id: string, form: FormData): Promise<Asset>;
|
|
12
24
|
getChildren(assetId: string, params?: RequestParameter): Promise<Paginated<Asset[]>>;
|
|
13
|
-
|
|
25
|
+
getRevisions(assetId: string): Promise<Paginated<AssetRevision[]>>;
|
|
26
|
+
rollback(assetId: string, revisionId: string): Promise<Asset>;
|
|
27
|
+
deleteRevision(assetId: string, revisionId: string): Promise<any>;
|
|
14
28
|
}
|
|
@@ -6,9 +6,67 @@ class AssetMockService extends data_mock_service_1.DataMockService {
|
|
|
6
6
|
constructor(api, assets, revisions) {
|
|
7
7
|
super();
|
|
8
8
|
this.api = api;
|
|
9
|
-
this.revisions = [];
|
|
10
|
-
this.data = assets;
|
|
11
9
|
this.revisions = revisions;
|
|
10
|
+
this.data = assets;
|
|
11
|
+
}
|
|
12
|
+
paperBinRestoreAll() {
|
|
13
|
+
const deleted = this.data.filter((v) => v.deletedAt);
|
|
14
|
+
for (const asset of deleted) {
|
|
15
|
+
delete asset.deletedAt;
|
|
16
|
+
}
|
|
17
|
+
return Promise.resolve(deleted);
|
|
18
|
+
}
|
|
19
|
+
paperBinRestoreOne(id) {
|
|
20
|
+
const deleted = this.data.find((v) => v.id === id);
|
|
21
|
+
delete deleted.deletedAt;
|
|
22
|
+
return Promise.resolve(deleted);
|
|
23
|
+
}
|
|
24
|
+
emptyTrash(offset) {
|
|
25
|
+
const dateOffsSeconds = Math.round(new Date().getTime() / 1000) - offset;
|
|
26
|
+
const date = new Date(dateOffsSeconds * 1000);
|
|
27
|
+
const trash = this.data.filter((v) => new Date(v.deletedAt) < date);
|
|
28
|
+
trash.map((v) => this.deleteOne(v.id));
|
|
29
|
+
return Promise.resolve({ acknowledged: true, deletedCount: trash.length });
|
|
30
|
+
}
|
|
31
|
+
getPaperBin(params) {
|
|
32
|
+
const page = this.getAssets(params, true);
|
|
33
|
+
return Promise.resolve(page);
|
|
34
|
+
}
|
|
35
|
+
getAssets(params, deleted = false) {
|
|
36
|
+
const data = this.data.filter((asset) => !!asset.deletedAt === deleted);
|
|
37
|
+
const page = {
|
|
38
|
+
docs: data,
|
|
39
|
+
limit: params && params.limit ? params.limit : Number.MAX_SAFE_INTEGER,
|
|
40
|
+
total: data.length,
|
|
41
|
+
};
|
|
42
|
+
return page;
|
|
43
|
+
}
|
|
44
|
+
addOne(dto) {
|
|
45
|
+
this.revisions.push(Object.assign(Object.assign({}, dto), { originalId: dto.id }));
|
|
46
|
+
return super.addOne(dto);
|
|
47
|
+
}
|
|
48
|
+
deleteOne(assetId, force = false) {
|
|
49
|
+
const asset = this.data.find((v) => v.id === assetId);
|
|
50
|
+
if (!(asset === null || asset === void 0 ? void 0 : asset.deletedAt) && !force) {
|
|
51
|
+
asset.deletedAt = new Date().toISOString();
|
|
52
|
+
return Promise.resolve(asset);
|
|
53
|
+
}
|
|
54
|
+
this.revisions
|
|
55
|
+
.filter((revision) => revision.originalId === assetId)
|
|
56
|
+
.forEach((revision) => {
|
|
57
|
+
const index = this.revisions.indexOf(revision);
|
|
58
|
+
this.revisions.splice(index, 1);
|
|
59
|
+
});
|
|
60
|
+
return super.deleteOne(assetId);
|
|
61
|
+
}
|
|
62
|
+
getMany(params) {
|
|
63
|
+
const page = this.getAssets(params, false);
|
|
64
|
+
return Promise.resolve(page);
|
|
65
|
+
}
|
|
66
|
+
async updateOne(assetId, dto) {
|
|
67
|
+
await super.deleteOne(assetId);
|
|
68
|
+
const asset = await this.addOne(dto);
|
|
69
|
+
return Promise.resolve(asset);
|
|
12
70
|
}
|
|
13
71
|
async addAttachment(id, form) {
|
|
14
72
|
const asset = this.data.find((v) => v.id === id);
|
|
@@ -19,14 +77,23 @@ class AssetMockService extends data_mock_service_1.DataMockService {
|
|
|
19
77
|
getChildren(assetId, params = {}) {
|
|
20
78
|
return this.getManyFiltered({ parent: assetId }, params);
|
|
21
79
|
}
|
|
22
|
-
|
|
23
|
-
const
|
|
80
|
+
getRevisions(assetId) {
|
|
81
|
+
const revisions = this.revisions.filter((revision) => revision.originalId === assetId);
|
|
24
82
|
const page = {
|
|
25
|
-
docs:
|
|
83
|
+
docs: revisions,
|
|
26
84
|
limit: Number.MAX_SAFE_INTEGER,
|
|
27
|
-
total:
|
|
85
|
+
total: revisions.length,
|
|
28
86
|
};
|
|
29
87
|
return Promise.resolve(page);
|
|
30
88
|
}
|
|
89
|
+
rollback(assetId, revisionId) {
|
|
90
|
+
const asset = this.revisions.find((revision) => revision.id === revisionId);
|
|
91
|
+
return Promise.resolve(asset);
|
|
92
|
+
}
|
|
93
|
+
deleteRevision(assetId, revisionId) {
|
|
94
|
+
const index = this.revisions.findIndex((revision) => revision.id === revisionId);
|
|
95
|
+
this.revisions.splice(index, 1);
|
|
96
|
+
return Promise.resolve(revisionId);
|
|
97
|
+
}
|
|
31
98
|
}
|
|
32
99
|
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 {
|
|
@@ -17,8 +17,9 @@ class DataMockService extends data_service_1.DataService {
|
|
|
17
17
|
}
|
|
18
18
|
deleteOne(id) {
|
|
19
19
|
const index = this.data.findIndex((v) => v.id === id);
|
|
20
|
+
const obj = this.data[index];
|
|
20
21
|
this.data.splice(index, 1);
|
|
21
|
-
return Promise.resolve(
|
|
22
|
+
return Promise.resolve(obj);
|
|
22
23
|
}
|
|
23
24
|
getMany(params) {
|
|
24
25
|
const data = this.data;
|
|
@@ -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,13 +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
5
|
import { FlowDeployment } from '../flow-deployment.interface';
|
|
6
6
|
export declare class FlowMockService extends DataMockService<FlowDto> implements FlowService {
|
|
7
7
|
private diagrams;
|
|
8
|
-
|
|
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>;
|
|
9
13
|
isDeploymentOnLatestDiagramVersion(depl: FlowDeployment): Promise<boolean>;
|
|
10
|
-
|
|
14
|
+
getDiagramRevisions(id: string): Promise<FlowDiagram[]>;
|
|
11
15
|
getFlowWithDiagram(diagramId: string): Promise<FlowDto>;
|
|
12
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>;
|
|
13
20
|
}
|
|
@@ -2,19 +2,40 @@
|
|
|
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
|
+
}
|
|
11
32
|
async isDeploymentOnLatestDiagramVersion(depl) {
|
|
12
33
|
const flowId = typeof depl.flow === 'string' ? depl.flow : depl.flow.id;
|
|
13
34
|
const diagramId = typeof depl.diagram === 'string' ? depl.diagram : depl.diagram.id;
|
|
14
|
-
const revisions = await this.
|
|
35
|
+
const revisions = await this.getDiagramRevisions(flowId);
|
|
15
36
|
return revisions.reverse()[0].id === diagramId;
|
|
16
37
|
}
|
|
17
|
-
|
|
38
|
+
getDiagramRevisions(id) {
|
|
18
39
|
return Promise.resolve(this.diagrams.filter((v) => v.flow === id));
|
|
19
40
|
}
|
|
20
41
|
getFlowWithDiagram(diagramId) {
|
|
@@ -28,5 +49,23 @@ class FlowMockService extends data_mock_service_1.DataMockService {
|
|
|
28
49
|
limit: 0,
|
|
29
50
|
};
|
|
30
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
|
+
}
|
|
31
70
|
}
|
|
32
71
|
exports.FlowMockService = FlowMockService;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DataMockService } from './data.mock.service';
|
|
2
|
+
import { Label } from '../label.interface';
|
|
3
|
+
import { LabelService } from '../label.service';
|
|
4
|
+
export declare class LabelMockService extends DataMockService<Label> implements LabelService {
|
|
5
|
+
constructor(labels: Label[]);
|
|
6
|
+
count(): Promise<number>;
|
|
7
|
+
getOneByName(name: string): Promise<Label>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LabelMockService = void 0;
|
|
4
|
+
const data_mock_service_1 = require("./data.mock.service");
|
|
5
|
+
class LabelMockService extends data_mock_service_1.DataMockService {
|
|
6
|
+
constructor(labels) {
|
|
7
|
+
super();
|
|
8
|
+
this.data = labels;
|
|
9
|
+
}
|
|
10
|
+
count() {
|
|
11
|
+
return Promise.resolve(this.data.length);
|
|
12
|
+
}
|
|
13
|
+
getOneByName(name) {
|
|
14
|
+
return Promise.resolve(this.data.find((label) => label.name === name));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.LabelMockService = LabelMockService;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hahnpro/hpc-api",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "3.2.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": "~0.
|
|
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
34
|
"@types/eventsource": "^1.1.8",
|
|
35
|
-
"axios-mock-adapter": "^1.
|
|
35
|
+
"axios-mock-adapter": "^1.21.1"
|
|
36
36
|
},
|
|
37
37
|
"engines": {
|
|
38
38
|
"node": ">=v14.13"
|