@hahnpro/flow-sdk 4.14.4
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/LICENSE +21 -0
- package/README.md +3 -0
- package/dist/FlowApplication.d.ts +35 -0
- package/dist/FlowApplication.js +270 -0
- package/dist/FlowElement.d.ts +50 -0
- package/dist/FlowElement.js +143 -0
- package/dist/FlowEvent.d.ts +19 -0
- package/dist/FlowEvent.js +71 -0
- package/dist/FlowLogger.d.ts +23 -0
- package/dist/FlowLogger.js +57 -0
- package/dist/FlowModule.d.ts +7 -0
- package/dist/FlowModule.js +14 -0
- package/dist/RpcClient.d.ts +11 -0
- package/dist/RpcClient.js +70 -0
- package/dist/TestModule.d.ts +2 -0
- package/dist/TestModule.js +27 -0
- package/dist/amqp.d.ts +33 -0
- package/dist/amqp.js +12 -0
- package/dist/api/Queue.d.ts +15 -0
- package/dist/api/Queue.js +27 -0
- package/dist/api/api.d.ts +62 -0
- package/dist/api/api.js +52 -0
- package/dist/api/asset.interface.d.ts +54 -0
- package/dist/api/asset.interface.js +2 -0
- package/dist/api/asset.service.d.ts +10 -0
- package/dist/api/asset.service.js +21 -0
- package/dist/api/assettypes.service.d.ts +6 -0
- package/dist/api/assettypes.service.js +10 -0
- package/dist/api/content.interface.d.ts +35 -0
- package/dist/api/content.interface.js +12 -0
- package/dist/api/content.service.d.ts +17 -0
- package/dist/api/content.service.js +39 -0
- package/dist/api/data.interface.d.ts +29 -0
- package/dist/api/data.interface.js +2 -0
- package/dist/api/data.service.d.ts +15 -0
- package/dist/api/data.service.js +49 -0
- package/dist/api/endpoint.interface.d.ts +22 -0
- package/dist/api/endpoint.interface.js +2 -0
- package/dist/api/endpoint.service.d.ts +8 -0
- package/dist/api/endpoint.service.js +17 -0
- package/dist/api/events.interface.d.ts +16 -0
- package/dist/api/events.interface.js +2 -0
- package/dist/api/events.service.d.ts +7 -0
- package/dist/api/events.service.js +13 -0
- package/dist/api/http.service.d.ts +26 -0
- package/dist/api/http.service.js +74 -0
- package/dist/api/index.d.ts +12 -0
- package/dist/api/index.js +16 -0
- package/dist/api/mock/api.mock.d.ts +158 -0
- package/dist/api/mock/api.mock.js +111 -0
- package/dist/api/mock/asset.mock.service.d.ts +12 -0
- package/dist/api/mock/asset.mock.service.js +21 -0
- package/dist/api/mock/assetTypes.mock.service.d.ts +6 -0
- package/dist/api/mock/assetTypes.mock.service.js +11 -0
- package/dist/api/mock/content.mock.service.d.ts +18 -0
- package/dist/api/mock/content.mock.service.js +64 -0
- package/dist/api/mock/data.mock.service.d.ts +13 -0
- package/dist/api/mock/data.mock.service.js +52 -0
- package/dist/api/mock/endpoint.mock.service.d.ts +15 -0
- package/dist/api/mock/endpoint.mock.service.js +24 -0
- package/dist/api/mock/events.mock.service.d.ts +7 -0
- package/dist/api/mock/events.mock.service.js +14 -0
- package/dist/api/mock/index.d.ts +9 -0
- package/dist/api/mock/index.js +12 -0
- package/dist/api/mock/secret.mock.service.d.ts +6 -0
- package/dist/api/mock/secret.mock.service.js +11 -0
- package/dist/api/mock/task.mock.service.d.ts +7 -0
- package/dist/api/mock/task.mock.service.js +15 -0
- package/dist/api/mock/timeseries.mock.service.d.ts +19 -0
- package/dist/api/mock/timeseries.mock.service.js +69 -0
- package/dist/api/mock/user.mock.service.d.ts +7 -0
- package/dist/api/mock/user.mock.service.js +14 -0
- package/dist/api/proxy.service.d.ts +11 -0
- package/dist/api/proxy.service.js +17 -0
- package/dist/api/secret.interface.d.ts +7 -0
- package/dist/api/secret.interface.js +2 -0
- package/dist/api/secret.service.d.ts +6 -0
- package/dist/api/secret.service.js +10 -0
- package/dist/api/sidriveiq.interface.d.ts +104 -0
- package/dist/api/sidriveiq.interface.js +2 -0
- package/dist/api/sidriveiq.service.d.ts +97 -0
- package/dist/api/sidriveiq.service.js +97 -0
- package/dist/api/task.interface.d.ts +22 -0
- package/dist/api/task.interface.js +2 -0
- package/dist/api/task.service.d.ts +7 -0
- package/dist/api/task.service.js +13 -0
- package/dist/api/timeseries.interface.d.ts +39 -0
- package/dist/api/timeseries.interface.js +2 -0
- package/dist/api/timeseries.service.d.ts +17 -0
- package/dist/api/timeseries.service.js +38 -0
- package/dist/api/user.service.d.ts +6 -0
- package/dist/api/user.service.js +21 -0
- package/dist/extra-validators.d.ts +1 -0
- package/dist/extra-validators.js +52 -0
- package/dist/flow.interface.d.ts +41 -0
- package/dist/flow.interface.js +2 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +16 -0
- package/dist/rpc_server.py +115 -0
- package/dist/unit-decorators.d.ts +39 -0
- package/dist/unit-decorators.js +157 -0
- package/dist/unit-utils.d.ts +8 -0
- package/dist/unit-utils.js +143 -0
- package/dist/units.d.ts +31 -0
- package/dist/units.js +570 -0
- package/dist/utils.d.ts +8 -0
- package/dist/utils.js +106 -0
- package/package.json +64 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SiDriveIqService = void 0;
|
|
4
|
+
class SiDriveIqService {
|
|
5
|
+
constructor(httpClient) {
|
|
6
|
+
this.httpClient = httpClient;
|
|
7
|
+
this.basePath = 'api/sidrive/api/v0';
|
|
8
|
+
}
|
|
9
|
+
getAssets(params = {}) {
|
|
10
|
+
return this.httpClient.get(`${this.basePath}/assets`, { params });
|
|
11
|
+
}
|
|
12
|
+
getAssetCount(params = {}) {
|
|
13
|
+
return this.httpClient.get(`${this.basePath}/assets/count`, { params });
|
|
14
|
+
}
|
|
15
|
+
getAsset(assetId) {
|
|
16
|
+
return this.httpClient.get(`${this.basePath}/assets/${assetId}`);
|
|
17
|
+
}
|
|
18
|
+
getProperties(assetId, params = {}) {
|
|
19
|
+
return this.httpClient.get(`${this.basePath}/assets/${assetId}/properties`, { params });
|
|
20
|
+
}
|
|
21
|
+
getProperty(assetId, path) {
|
|
22
|
+
return this.httpClient.get(`${this.basePath}/assets/${assetId}/properties/${path}`);
|
|
23
|
+
}
|
|
24
|
+
getSubsets(assetId) {
|
|
25
|
+
return this.httpClient.get(`${this.basePath}/assets/${assetId}/subsets`);
|
|
26
|
+
}
|
|
27
|
+
getSubset(assetId, subsetId) {
|
|
28
|
+
return this.httpClient.get(`${this.basePath}/assets/${assetId}/subsets/${subsetId}`);
|
|
29
|
+
}
|
|
30
|
+
getSubsetProperties(assetId, subsetId, pathFilter) {
|
|
31
|
+
const params = Object.assign({}, (pathFilter && { path_filter: pathFilter }));
|
|
32
|
+
return this.httpClient.get(`${this.basePath}/assets/${assetId}/subsets/${subsetId}/properties`, { params });
|
|
33
|
+
}
|
|
34
|
+
getTimeSeries(assetId, path, params = {}) {
|
|
35
|
+
params = this.convertDates(params);
|
|
36
|
+
return this.httpClient.get(`${this.basePath}/assets/${assetId}/properties/${path}/timeseries`, { params });
|
|
37
|
+
}
|
|
38
|
+
getTimeSeriesCount(assetId, path, params = {}) {
|
|
39
|
+
params = this.convertDates(params);
|
|
40
|
+
return this.httpClient.get(`${this.basePath}/assets/${assetId}/properties/${path}/timeseries/count`, { params });
|
|
41
|
+
}
|
|
42
|
+
getRecentTimeSeries(assetId, path, timestamp) {
|
|
43
|
+
const params = Object.assign({}, (timestamp && { timestamp: timestamp.toISOString() }));
|
|
44
|
+
return this.httpClient.get(`${this.basePath}/assets/${assetId}/properties/${path}/timeseries/recent`, { params });
|
|
45
|
+
}
|
|
46
|
+
addTimeSeries(assetId, path, values) {
|
|
47
|
+
return this.httpClient.post(`${this.basePath}/assets/${assetId}/properties/${path}/timeseries`, values);
|
|
48
|
+
}
|
|
49
|
+
getFiles(assetId, params = {}) {
|
|
50
|
+
params = this.convertDates(params);
|
|
51
|
+
return this.httpClient.get(`${this.basePath}/assets/${assetId}/files/import`, { params });
|
|
52
|
+
}
|
|
53
|
+
getFileCount(assetId, params = {}) {
|
|
54
|
+
params = this.convertDates(params);
|
|
55
|
+
return this.httpClient.get(`${this.basePath}/assets/${assetId}/files/import/count`, { params });
|
|
56
|
+
}
|
|
57
|
+
getFile(assetId, fileId) {
|
|
58
|
+
return this.httpClient.get(`${this.basePath}/assets/${assetId}/files/import/${fileId}`);
|
|
59
|
+
}
|
|
60
|
+
downloadFile(assetId, fileId) {
|
|
61
|
+
return this.httpClient.get(`${this.basePath}/assets/${assetId}/files/import/${fileId}/download`, {
|
|
62
|
+
headers: { 'response-type': 'arraybuffer' },
|
|
63
|
+
responseType: 'arraybuffer',
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
uploadFile(assetId, form) {
|
|
67
|
+
const headers = Object.assign({}, form.getHeaders());
|
|
68
|
+
return this.httpClient.post(`${this.basePath}/assets/${assetId}/files/import`, form, { headers });
|
|
69
|
+
}
|
|
70
|
+
deleteFile(assetId, fileId) {
|
|
71
|
+
return this.httpClient.delete(`${this.basePath}/assets/${assetId}/files/import/${fileId}`);
|
|
72
|
+
}
|
|
73
|
+
getLogs(assetId, params) {
|
|
74
|
+
params = this.convertDates(params);
|
|
75
|
+
return this.httpClient.get(`${this.basePath}/assets/${assetId}/logs`, { params });
|
|
76
|
+
}
|
|
77
|
+
getLogCount(assetId, params) {
|
|
78
|
+
params = this.convertDates(params);
|
|
79
|
+
return this.httpClient.get(`${this.basePath}/assets/${assetId}/logs/count`, { params });
|
|
80
|
+
}
|
|
81
|
+
addLog(assetId, item) {
|
|
82
|
+
return this.httpClient.post(`${this.basePath}/assets/${assetId}/logs`, item);
|
|
83
|
+
}
|
|
84
|
+
sendMail(mail) {
|
|
85
|
+
return this.httpClient.post(`${this.basePath}/mails`, mail);
|
|
86
|
+
}
|
|
87
|
+
convertDates(params) {
|
|
88
|
+
if (params.from) {
|
|
89
|
+
params.from = new Date(params.from).toISOString();
|
|
90
|
+
}
|
|
91
|
+
if (params.to) {
|
|
92
|
+
params.to = new Date(params.to).toISOString();
|
|
93
|
+
}
|
|
94
|
+
return params;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.SiDriveIqService = SiDriveIqService;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface Task {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
desc?: string;
|
|
5
|
+
tags?: string[];
|
|
6
|
+
author?: string;
|
|
7
|
+
readPermissions: string[];
|
|
8
|
+
readWritePermissions: string[];
|
|
9
|
+
assetRef?: string;
|
|
10
|
+
eventRef?: string;
|
|
11
|
+
expiryDate?: Date;
|
|
12
|
+
parent?: string;
|
|
13
|
+
subTasks?: string[];
|
|
14
|
+
assignedTo: string[];
|
|
15
|
+
status?: string;
|
|
16
|
+
acceptedBy?: string;
|
|
17
|
+
rejectReason?: string;
|
|
18
|
+
statusHistoryLog?: string[];
|
|
19
|
+
weight?: number;
|
|
20
|
+
createdAt?: string;
|
|
21
|
+
updatedAt?: string;
|
|
22
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DataService } from './data.service';
|
|
2
|
+
import { HttpClient } from './http.service';
|
|
3
|
+
import { Task } from './task.interface';
|
|
4
|
+
export declare class TaskService extends DataService<Task> {
|
|
5
|
+
constructor(httpClient: HttpClient);
|
|
6
|
+
createTaskAttachedToAsset(dto: any): Promise<Task>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TaskService = void 0;
|
|
4
|
+
const data_service_1 = require("./data.service");
|
|
5
|
+
class TaskService extends data_service_1.DataService {
|
|
6
|
+
constructor(httpClient) {
|
|
7
|
+
super(httpClient, process.env.DEBUG_TSK_URL || 'api/tasks');
|
|
8
|
+
}
|
|
9
|
+
createTaskAttachedToAsset(dto) {
|
|
10
|
+
return this.httpClient.post(this.basePath, dto);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.TaskService = TaskService;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export interface TimeSeries {
|
|
2
|
+
id?: string;
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
readPermissions: string[];
|
|
6
|
+
readWritePermissions: string[];
|
|
7
|
+
assetRef?: string;
|
|
8
|
+
assetRef$name?: string;
|
|
9
|
+
assetTsId?: string;
|
|
10
|
+
minDate: Date;
|
|
11
|
+
metrics?: string[];
|
|
12
|
+
maxBucketTimeRange: number;
|
|
13
|
+
tsRef?: [string];
|
|
14
|
+
autoDelData: Date;
|
|
15
|
+
autoDelBucket: Date;
|
|
16
|
+
}
|
|
17
|
+
export interface TimeSeriesCondition {
|
|
18
|
+
operator: string;
|
|
19
|
+
values: number[];
|
|
20
|
+
}
|
|
21
|
+
export interface TimeSeriesValue {
|
|
22
|
+
timestamp: number;
|
|
23
|
+
value: number | string | any;
|
|
24
|
+
[key: string]: any;
|
|
25
|
+
}
|
|
26
|
+
export interface TimeSeriesBucket {
|
|
27
|
+
id?: string;
|
|
28
|
+
ts: TimeSeries;
|
|
29
|
+
prev: TimeSeriesBucket;
|
|
30
|
+
next: TimeSeriesBucket;
|
|
31
|
+
prevHash: string;
|
|
32
|
+
from: Date;
|
|
33
|
+
to: Date;
|
|
34
|
+
bucketSize: number;
|
|
35
|
+
data: TimeSeriesValue[];
|
|
36
|
+
meta: any;
|
|
37
|
+
final: boolean;
|
|
38
|
+
}
|
|
39
|
+
export declare type TS_GROUPS = 'none' | '10s' | '1m' | '5m' | '15m' | '30m' | '1h' | '3h' | '6h' | '12h' | '1d' | '7d';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Paginated } from './data.interface';
|
|
2
|
+
import { DataService } from './data.service';
|
|
3
|
+
import { HttpClient } from './http.service';
|
|
4
|
+
import { TS_GROUPS, TimeSeries, TimeSeriesValue } from './timeseries.interface';
|
|
5
|
+
export declare class TimeSeriesService extends DataService<TimeSeries> {
|
|
6
|
+
constructor(httpClient: HttpClient);
|
|
7
|
+
addValue(id: string, value: {
|
|
8
|
+
[values: string]: any;
|
|
9
|
+
}): Promise<void>;
|
|
10
|
+
addAssetTimeSeriesValues(assetId: string, name: string, readPermissions: string[], readWritePermissions: string[], values: {
|
|
11
|
+
[timestamp: string]: any;
|
|
12
|
+
}): Promise<TimeSeries>;
|
|
13
|
+
getMostRecentValue(id: string, before: Date): Promise<TimeSeriesValue>;
|
|
14
|
+
getValues(id: string, from: number, limit?: number, group?: TS_GROUPS): Promise<TimeSeriesValue[]>;
|
|
15
|
+
getValuesOfPeriod(id: string, from: number, to: number, group?: TS_GROUPS): Promise<TimeSeriesValue[]>;
|
|
16
|
+
getManyByAsset(assetId: string, names?: string[]): Promise<Paginated<TimeSeries[]>>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TimeSeriesService = void 0;
|
|
4
|
+
const data_service_1 = require("./data.service");
|
|
5
|
+
class TimeSeriesService extends data_service_1.DataService {
|
|
6
|
+
constructor(httpClient) {
|
|
7
|
+
super(httpClient, process.env.DEBUG_TSM_URL || 'api/tsm');
|
|
8
|
+
}
|
|
9
|
+
addValue(id, value) {
|
|
10
|
+
return this.httpClient.post(`${this.basePath}/${id}`, value);
|
|
11
|
+
}
|
|
12
|
+
addAssetTimeSeriesValues(assetId, name, readPermissions, readWritePermissions, values) {
|
|
13
|
+
const dto = {
|
|
14
|
+
name,
|
|
15
|
+
readPermissions,
|
|
16
|
+
readWritePermissions,
|
|
17
|
+
values,
|
|
18
|
+
};
|
|
19
|
+
return this.httpClient.post(`${this.basePath}/assets/${assetId}`, dto);
|
|
20
|
+
}
|
|
21
|
+
getMostRecentValue(id, before) {
|
|
22
|
+
const params = before ? { before: before.toISOString() } : {};
|
|
23
|
+
return this.httpClient.get(`${this.basePath}/${id}/recent`, { params });
|
|
24
|
+
}
|
|
25
|
+
getValues(id, from, limit, group) {
|
|
26
|
+
const params = { limit, group };
|
|
27
|
+
return this.httpClient.get(`${this.basePath}/${id}/${from}`, { params });
|
|
28
|
+
}
|
|
29
|
+
getValuesOfPeriod(id, from, to, group) {
|
|
30
|
+
const params = { group };
|
|
31
|
+
return this.httpClient.get(`${this.basePath}/${id}/${from}/${to}`, { params });
|
|
32
|
+
}
|
|
33
|
+
getManyByAsset(assetId, names) {
|
|
34
|
+
const params = Array.isArray(names) ? { names: names.join() } : {};
|
|
35
|
+
return this.httpClient.get(`${this.basePath}/asset/${assetId}`, { params });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.TimeSeriesService = TimeSeriesService;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserService = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jwt_decode_1 = (0, tslib_1.__importDefault)(require("jwt-decode"));
|
|
6
|
+
class UserService {
|
|
7
|
+
constructor(httpClient) {
|
|
8
|
+
this.httpClient = httpClient;
|
|
9
|
+
}
|
|
10
|
+
async getCurrentUserRoles() {
|
|
11
|
+
try {
|
|
12
|
+
const token = await this.httpClient.getAccessToken();
|
|
13
|
+
const decode = (0, jwt_decode_1.default)(token);
|
|
14
|
+
return decode.realm_access.roles;
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.UserService = UserService;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function IncompatableWith(incompatibleSiblings: string[]): (target: any, key: string) => void;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IncompatableWith = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const class_validator_1 = require("class-validator");
|
|
6
|
+
let IsNotSiblingOfConstraint = class IsNotSiblingOfConstraint {
|
|
7
|
+
validate(value, args) {
|
|
8
|
+
if ((0, class_validator_1.isDefined)(value)) {
|
|
9
|
+
return this.getFailedConstraints(args).length === 0;
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
return !args.constraints.every((prop) => !(0, class_validator_1.isDefined)(args.object[prop]));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
defaultMessage(args) {
|
|
16
|
+
if (args.value) {
|
|
17
|
+
return `${args.property} cannot exist alongside the following defined properties: ${this.getFailedConstraints(args).join(', ')}`;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
return `at least one of the properties must be defined`;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
getFailedConstraints(args) {
|
|
24
|
+
return args.constraints.filter((prop) => (0, class_validator_1.isDefined)(args.object[prop]));
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
IsNotSiblingOfConstraint = (0, tslib_1.__decorate)([
|
|
28
|
+
(0, class_validator_1.ValidatorConstraint)({ async: false })
|
|
29
|
+
], IsNotSiblingOfConstraint);
|
|
30
|
+
function IsNotSiblingOf(props, validationOptions) {
|
|
31
|
+
return (object, propertyName) => {
|
|
32
|
+
(0, class_validator_1.registerDecorator)({
|
|
33
|
+
target: object.constructor,
|
|
34
|
+
propertyName,
|
|
35
|
+
options: validationOptions,
|
|
36
|
+
constraints: props,
|
|
37
|
+
validator: IsNotSiblingOfConstraint,
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function incompatibleSiblingsNotPresent(incompatibleSiblings) {
|
|
42
|
+
return (o, v) => Boolean((0, class_validator_1.isDefined)(v) || incompatibleSiblings.every((prop) => !(0, class_validator_1.isDefined)(o[prop])));
|
|
43
|
+
}
|
|
44
|
+
function IncompatableWith(incompatibleSiblings) {
|
|
45
|
+
const notSibling = IsNotSiblingOf(incompatibleSiblings);
|
|
46
|
+
const validateIf = (0, class_validator_1.ValidateIf)(incompatibleSiblingsNotPresent(incompatibleSiblings));
|
|
47
|
+
return (target, key) => {
|
|
48
|
+
notSibling(target, key);
|
|
49
|
+
validateIf(target, key);
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
exports.IncompatableWith = IncompatableWith;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface FlowContext {
|
|
2
|
+
deploymentId?: string;
|
|
3
|
+
diagramId?: string;
|
|
4
|
+
flowId?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface FlowElementContext extends FlowContext {
|
|
7
|
+
id: string;
|
|
8
|
+
name?: string;
|
|
9
|
+
functionFqn?: string;
|
|
10
|
+
inputStreamId?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface DeploymentMessage extends Record<string, any> {
|
|
13
|
+
elementId?: string;
|
|
14
|
+
}
|
|
15
|
+
interface FlowElement {
|
|
16
|
+
id: string;
|
|
17
|
+
name?: string;
|
|
18
|
+
properties?: Record<string, any>;
|
|
19
|
+
module: string;
|
|
20
|
+
functionFqn: string;
|
|
21
|
+
}
|
|
22
|
+
interface FlowConnection {
|
|
23
|
+
id: string;
|
|
24
|
+
name?: string;
|
|
25
|
+
source: string;
|
|
26
|
+
target: string;
|
|
27
|
+
sourceStream?: string;
|
|
28
|
+
targetStream?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface Flow {
|
|
31
|
+
elements: FlowElement[];
|
|
32
|
+
connections: FlowConnection[];
|
|
33
|
+
modules?: string[];
|
|
34
|
+
properties?: Record<string, any>;
|
|
35
|
+
context?: FlowContext;
|
|
36
|
+
}
|
|
37
|
+
export interface StreamOptions {
|
|
38
|
+
concurrent?: number;
|
|
39
|
+
}
|
|
40
|
+
export declare type ClassType<T> = new (...args: any[]) => T;
|
|
41
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './api';
|
|
2
|
+
export * from './flow.interface';
|
|
3
|
+
export * from './utils';
|
|
4
|
+
export * from './FlowApplication';
|
|
5
|
+
export * from './FlowElement';
|
|
6
|
+
export * from './FlowEvent';
|
|
7
|
+
export * from './FlowLogger';
|
|
8
|
+
export * from './FlowModule';
|
|
9
|
+
export * from './TestModule';
|
|
10
|
+
export * from './unit-decorators';
|
|
11
|
+
export { IncompatableWith } from './extra-validators';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IncompatableWith = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
(0, tslib_1.__exportStar)(require("./api"), exports);
|
|
6
|
+
(0, tslib_1.__exportStar)(require("./flow.interface"), exports);
|
|
7
|
+
(0, tslib_1.__exportStar)(require("./utils"), exports);
|
|
8
|
+
(0, tslib_1.__exportStar)(require("./FlowApplication"), exports);
|
|
9
|
+
(0, tslib_1.__exportStar)(require("./FlowElement"), exports);
|
|
10
|
+
(0, tslib_1.__exportStar)(require("./FlowEvent"), exports);
|
|
11
|
+
(0, tslib_1.__exportStar)(require("./FlowLogger"), exports);
|
|
12
|
+
(0, tslib_1.__exportStar)(require("./FlowModule"), exports);
|
|
13
|
+
(0, tslib_1.__exportStar)(require("./TestModule"), exports);
|
|
14
|
+
(0, tslib_1.__exportStar)(require("./unit-decorators"), exports);
|
|
15
|
+
var extra_validators_1 = require("./extra-validators");
|
|
16
|
+
Object.defineProperty(exports, "IncompatableWith", { enumerable: true, get: function () { return extra_validators_1.IncompatableWith; } });
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import json
|
|
3
|
+
from asyncio import Future
|
|
4
|
+
from functools import partial, wraps
|
|
5
|
+
from aio_pika import IncomingMessage, Exchange, Message, connect_robust, ExchangeType
|
|
6
|
+
import os
|
|
7
|
+
|
|
8
|
+
user = ""
|
|
9
|
+
try:
|
|
10
|
+
user = os.environ["RABBIT_USER"]
|
|
11
|
+
except:
|
|
12
|
+
user = "guest"
|
|
13
|
+
|
|
14
|
+
password = ""
|
|
15
|
+
try:
|
|
16
|
+
password = os.environ["RABBIT_PASSWORD"]
|
|
17
|
+
except:
|
|
18
|
+
password = "guest"
|
|
19
|
+
|
|
20
|
+
host = ""
|
|
21
|
+
try:
|
|
22
|
+
host = os.environ["RABBIT_HOST"]
|
|
23
|
+
except:
|
|
24
|
+
host = "localhost"
|
|
25
|
+
|
|
26
|
+
port = ""
|
|
27
|
+
try:
|
|
28
|
+
port = os.environ["RABBIT_PORT"]
|
|
29
|
+
except:
|
|
30
|
+
port = "5672"
|
|
31
|
+
|
|
32
|
+
routingKey = ""
|
|
33
|
+
try:
|
|
34
|
+
routingKey = os.environ["RPC_ROUTING_KEY"]
|
|
35
|
+
except:
|
|
36
|
+
routingKey = "rpc"
|
|
37
|
+
|
|
38
|
+
remoteProcedures = {}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def RemoteProcedure(func):
|
|
42
|
+
global remoteProcedures
|
|
43
|
+
|
|
44
|
+
@wraps(func)
|
|
45
|
+
def function_wrapper(*args, **kwargs):
|
|
46
|
+
return func(*args, **kwargs)
|
|
47
|
+
|
|
48
|
+
remoteProcedures[func.__name__] = func
|
|
49
|
+
|
|
50
|
+
return function_wrapper
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
loop = asyncio.get_event_loop()
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
async def on_message(exchange: Exchange, message: IncomingMessage):
|
|
57
|
+
def callback(future: Future):
|
|
58
|
+
try:
|
|
59
|
+
res = future.result()
|
|
60
|
+
reply1 = {"type": "reply", "value": res}
|
|
61
|
+
except Exception as err:
|
|
62
|
+
# print(traceback.format_list(traceback.extract_stack(err)))
|
|
63
|
+
reply1 = {"type": "error", "message": str(err), "stack": "failed"}
|
|
64
|
+
|
|
65
|
+
asyncio.ensure_future(sendReply(exchange, reply1, message), loop=loop)
|
|
66
|
+
|
|
67
|
+
with message.process():
|
|
68
|
+
request = json.loads(message.body.decode())
|
|
69
|
+
|
|
70
|
+
# call function
|
|
71
|
+
if remoteProcedures.keys().__contains__(request["functionName"]):
|
|
72
|
+
func = remoteProcedures.get(request["functionName"])
|
|
73
|
+
future = loop.run_in_executor(None, func, *request["arguments"])
|
|
74
|
+
future.add_done_callback(callback)
|
|
75
|
+
|
|
76
|
+
else:
|
|
77
|
+
reply = {
|
|
78
|
+
"type": "error",
|
|
79
|
+
"message": request["functionName"] + " is not a function",
|
|
80
|
+
}
|
|
81
|
+
await sendReply(exchange, reply, originalMessage=message)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
async def sendReply(exchange: Exchange, reply, originalMessage: Message):
|
|
85
|
+
await exchange.publish(
|
|
86
|
+
Message(
|
|
87
|
+
body=json.dumps(reply).encode("utf-8"),
|
|
88
|
+
correlation_id=originalMessage.correlation_id
|
|
89
|
+
),
|
|
90
|
+
routing_key=originalMessage.reply_to,
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
async def main(loop, routing_key):
|
|
95
|
+
url = "amqp://%s:%s@%s:%s/" % (user, password, host, port)
|
|
96
|
+
connection = await connect_robust(
|
|
97
|
+
url, loop=loop
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
channel = await connection.channel()
|
|
101
|
+
|
|
102
|
+
dest_exchange = await channel.declare_exchange(name="rpc_direct_exchange", type=ExchangeType.DIRECT)
|
|
103
|
+
|
|
104
|
+
queue = await channel.declare_queue("", exclusive=True)
|
|
105
|
+
|
|
106
|
+
await queue.bind(dest_exchange, routing_key)
|
|
107
|
+
|
|
108
|
+
await queue.consume(partial(
|
|
109
|
+
on_message, channel.default_exchange)
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def start_consumer(routing_key=routingKey):
|
|
114
|
+
loop.create_task(main(loop, routing_key))
|
|
115
|
+
loop.run_forever()
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ValidationOptions } from 'class-validator';
|
|
2
|
+
export declare function IsTime(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
3
|
+
export declare function IsLength(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
4
|
+
export declare function IsMass(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
5
|
+
export declare function IsElectricCurrent(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
6
|
+
export declare function IsThermodynamicTemperature(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
7
|
+
export declare function IsAmountOfSubstance(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
8
|
+
export declare function IsLuminousIntensity(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
9
|
+
export declare function IsVoltage(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
10
|
+
export declare function IsForce(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
11
|
+
export declare function IsEnergy(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
12
|
+
export declare function IsPower(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
13
|
+
export declare function IsPressure(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
14
|
+
export declare function IsFrequency(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
15
|
+
export declare function IsArea(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
16
|
+
export declare function IsVolume(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
17
|
+
export declare function IsAngle(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
18
|
+
export declare function IsTranslationalAcceleration(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
19
|
+
export declare function IsTranslationalVelocity(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
20
|
+
export declare function IsTranslationalDisplacement(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
21
|
+
export declare function IsSpringConstant(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
22
|
+
export declare function IsRotationalAcceleration(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
23
|
+
export declare function IsRotationalVelocity(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
24
|
+
export declare function IsRotationalDisplacement(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
25
|
+
export declare function IsTorque(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
26
|
+
export declare function IsMomentOfInertia(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
27
|
+
export declare function IsRotatingUnbalance(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
28
|
+
export declare function IsMechanicalPower(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
29
|
+
export declare function IsMechanicalEnergy(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
30
|
+
export declare function IsDynamicViscosity(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
31
|
+
export declare function IsVolumeFlow(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
32
|
+
export declare function IsMassFlow(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
33
|
+
export declare function IsHeatFlux(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
34
|
+
export declare function IsThermalEnergy(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
35
|
+
export declare function IsSpecificHeatCapacity(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
36
|
+
export declare function IsThermalTransmittance(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
37
|
+
export declare function IsElectricalPower(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
38
|
+
export declare function IsElectricalEnergy(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|
|
39
|
+
export declare function IsElectricalFrequency(unit?: string, validationOptions?: ValidationOptions): (object: any, propertyName: string) => void;
|