@hahnpro/flow-sdk 5.0.0-0 → 5.0.1

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.
Files changed (98) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -1
  3. package/dist/FlowApplication.d.ts +53 -14
  4. package/dist/FlowApplication.js +266 -85
  5. package/dist/FlowElement.d.ts +12 -4
  6. package/dist/FlowElement.js +47 -48
  7. package/dist/FlowEvent.d.ts +7 -1
  8. package/dist/FlowEvent.js +5 -5
  9. package/dist/FlowLogger.d.ts +9 -6
  10. package/dist/FlowLogger.js +17 -18
  11. package/dist/FlowModule.d.ts +1 -1
  12. package/dist/FlowModule.js +3 -3
  13. package/dist/RpcClient.d.ts +5 -3
  14. package/dist/RpcClient.js +23 -9
  15. package/dist/TestModule.js +6 -6
  16. package/dist/amqp.d.ts +14 -0
  17. package/dist/amqp.js +13 -0
  18. package/dist/extra-validators.js +15 -8
  19. package/dist/flow.interface.d.ts +7 -1
  20. package/dist/flow.interface.js +7 -0
  21. package/dist/index.d.ts +2 -1
  22. package/dist/index.js +2 -1
  23. package/dist/rpc_server.py +89 -77
  24. package/dist/unit-decorators.d.ts +39 -0
  25. package/dist/unit-decorators.js +157 -0
  26. package/dist/unit-utils.d.ts +8 -0
  27. package/dist/unit-utils.js +144 -0
  28. package/dist/units.d.ts +31 -0
  29. package/dist/units.js +570 -0
  30. package/dist/utils.d.ts +5 -1
  31. package/dist/utils.js +40 -7
  32. package/package.json +35 -33
  33. package/dist/api/Queue.d.ts +0 -15
  34. package/dist/api/Queue.js +0 -25
  35. package/dist/api/api.d.ts +0 -22
  36. package/dist/api/api.interface.d.ts +0 -14
  37. package/dist/api/api.interface.js +0 -2
  38. package/dist/api/api.js +0 -38
  39. package/dist/api/asset.interface.d.ts +0 -45
  40. package/dist/api/asset.interface.js +0 -2
  41. package/dist/api/asset.service.d.ts +0 -8
  42. package/dist/api/asset.service.js +0 -18
  43. package/dist/api/content.interface.d.ts +0 -33
  44. package/dist/api/content.interface.js +0 -2
  45. package/dist/api/content.service.d.ts +0 -9
  46. package/dist/api/content.service.js +0 -22
  47. package/dist/api/data.interface.d.ts +0 -29
  48. package/dist/api/data.interface.js +0 -2
  49. package/dist/api/data.service.d.ts +0 -15
  50. package/dist/api/data.service.js +0 -50
  51. package/dist/api/endpoint.interface.d.ts +0 -18
  52. package/dist/api/endpoint.interface.js +0 -2
  53. package/dist/api/endpoint.service.d.ts +0 -7
  54. package/dist/api/endpoint.service.js +0 -14
  55. package/dist/api/http.service.d.ts +0 -29
  56. package/dist/api/http.service.js +0 -96
  57. package/dist/api/index.d.ts +0 -11
  58. package/dist/api/index.js +0 -15
  59. package/dist/api/mock/api.mock.d.ts +0 -102
  60. package/dist/api/mock/api.mock.js +0 -81
  61. package/dist/api/mock/asset.mock.service.d.ts +0 -9
  62. package/dist/api/mock/asset.mock.service.js +0 -18
  63. package/dist/api/mock/content.mock.service.d.ts +0 -9
  64. package/dist/api/mock/content.mock.service.js +0 -21
  65. package/dist/api/mock/data.mock.service.d.ts +0 -11
  66. package/dist/api/mock/data.mock.service.js +0 -53
  67. package/dist/api/mock/endpoint.mock.service.d.ts +0 -10
  68. package/dist/api/mock/endpoint.mock.service.js +0 -15
  69. package/dist/api/mock/index.d.ts +0 -7
  70. package/dist/api/mock/index.js +0 -10
  71. package/dist/api/mock/secret.mock.service.d.ts +0 -5
  72. package/dist/api/mock/secret.mock.service.js +0 -11
  73. package/dist/api/mock/task.mock.service.d.ts +0 -8
  74. package/dist/api/mock/task.mock.service.js +0 -16
  75. package/dist/api/mock/timeseries.mock.service.d.ts +0 -18
  76. package/dist/api/mock/timeseries.mock.service.js +0 -70
  77. package/dist/api/mock/user.mock.service.d.ts +0 -7
  78. package/dist/api/mock/user.mock.service.js +0 -12
  79. package/dist/api/secret.interface.d.ts +0 -9
  80. package/dist/api/secret.interface.js +0 -2
  81. package/dist/api/secret.service.d.ts +0 -6
  82. package/dist/api/secret.service.js +0 -10
  83. package/dist/api/sidriveiq.interface.d.ts +0 -104
  84. package/dist/api/sidriveiq.interface.js +0 -2
  85. package/dist/api/sidriveiq.service.d.ts +0 -31
  86. package/dist/api/sidriveiq.service.js +0 -97
  87. package/dist/api/task.interface.d.ts +0 -26
  88. package/dist/api/task.interface.js +0 -2
  89. package/dist/api/task.service.d.ts +0 -7
  90. package/dist/api/task.service.js +0 -13
  91. package/dist/api/timeseries.interface.d.ts +0 -51
  92. package/dist/api/timeseries.interface.js +0 -2
  93. package/dist/api/timeseries.service.d.ts +0 -17
  94. package/dist/api/timeseries.service.js +0 -38
  95. package/dist/api/user.interface.d.ts +0 -3
  96. package/dist/api/user.interface.js +0 -2
  97. package/dist/api/user.service.d.ts +0 -7
  98. package/dist/api/user.service.js +0 -21
@@ -1,104 +0,0 @@
1
- export interface Asset {
2
- id: string;
3
- type_id: string;
4
- name: string;
5
- description: string;
6
- tag: string;
7
- agent_id: string;
8
- is_active: boolean;
9
- }
10
- export interface File {
11
- id: string;
12
- name: string;
13
- status: string;
14
- content_type: string;
15
- created_at: string;
16
- length: number;
17
- }
18
- export interface List<T> {
19
- cursor: string;
20
- values: T[];
21
- }
22
- export interface Log {
23
- ref_id: string;
24
- ref_type: RefType;
25
- severity: Severity;
26
- created_at: string;
27
- text: string;
28
- actor: string;
29
- category: string;
30
- item_type: string;
31
- gone_at: string;
32
- }
33
- export interface Mail {
34
- from: string;
35
- to: string;
36
- cc?: string;
37
- subject: string;
38
- body: string;
39
- is_html: boolean;
40
- }
41
- export interface Property {
42
- path: string;
43
- name: string;
44
- unit: string;
45
- data_type: string;
46
- is_mandatory: boolean;
47
- }
48
- export declare type RefType = 'Unknown' | 'Asset' | 'AssetType' | 'Container' | 'ContainerType' | 'Action' | 'AssetReport' | 'ReportType';
49
- export declare type Severity = 'Info' | 'Warning' | 'Error' | 'All';
50
- export interface Subset {
51
- id: string;
52
- name: string;
53
- }
54
- export interface TimeSeries {
55
- ts: string;
56
- v: any;
57
- }
58
- export interface RangeParams {
59
- from?: string | Date;
60
- to?: string | Date;
61
- }
62
- export interface CursorParams {
63
- limit?: number;
64
- cursor?: string;
65
- }
66
- export interface PaginationParams {
67
- page?: number;
68
- page_size?: number;
69
- sort?: string;
70
- }
71
- export interface AssetsParams extends CursorParams {
72
- name_filter?: string;
73
- type_filter?: string;
74
- tag_filter?: string;
75
- agent_filter?: string;
76
- }
77
- export interface PropertiesParams extends CursorParams {
78
- path_filter?: string;
79
- subset_filter?: string;
80
- only_assigned?: boolean;
81
- only_mandatory?: boolean;
82
- }
83
- export interface TimeSeriesParams extends CursorParams, RangeParams {
84
- }
85
- export interface FilesCountParams extends RangeParams {
86
- name_filter?: string;
87
- status_filter?: 'Imported' | 'Scanned' | 'ScannedButEmpty';
88
- exclude?: string;
89
- }
90
- export interface FilesParams extends FilesCountParams, PaginationParams {
91
- }
92
- export interface LogsParams extends PaginationParams, RangeParams {
93
- categories: string[];
94
- severity?: Severity;
95
- filter?: string;
96
- }
97
- export interface LogDto {
98
- text: string;
99
- severity: Severity;
100
- created_at: string;
101
- actor: string;
102
- category: string;
103
- gone_at: string;
104
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,31 +0,0 @@
1
- import FormData from 'form-data';
2
- import { HttpClient } from './http.service';
3
- import { Asset, AssetsParams, File, FilesParams, FilesCountParams, List, Log, LogsParams, LogDto, Mail, Property, PropertiesParams, RangeParams, Subset, TimeSeries, TimeSeriesParams } from './sidriveiq.interface';
4
- export declare class SiDriveIqService {
5
- private readonly httpClient;
6
- private basePath;
7
- constructor(httpClient: HttpClient);
8
- getAssets(params?: AssetsParams): Promise<List<Asset>>;
9
- getAssetCount(params?: AssetsParams): Promise<number>;
10
- getAsset(assetId: string | number): Promise<Asset>;
11
- getProperties(assetId: string | number, params?: PropertiesParams): Promise<List<Property>>;
12
- getProperty(assetId: string | number, path: string): Promise<Property>;
13
- getSubsets(assetId: string | number): Promise<List<TimeSeries>>;
14
- getSubset(assetId: string | number, subsetId: string): Promise<Subset>;
15
- getSubsetProperties(assetId: string | number, subsetId: string, pathFilter?: string): Promise<List<Property>>;
16
- getTimeSeries(assetId: string | number, path: string, params?: TimeSeriesParams): Promise<List<TimeSeries>>;
17
- getTimeSeriesCount(assetId: string | number, path: string, params?: RangeParams): Promise<number>;
18
- getRecentTimeSeries(assetId: string | number, path: string, timestamp?: Date): Promise<TimeSeries>;
19
- addTimeSeries(assetId: string | number, path: string, values: TimeSeries[]): Promise<void>;
20
- getFiles(assetId: string | number, params?: FilesParams): Promise<File[]>;
21
- getFileCount(assetId: string | number, params?: FilesCountParams): Promise<number>;
22
- getFile(assetId: string | number, fileId: string): Promise<File>;
23
- downloadFile(assetId: string | number, fileId: string): Promise<ArrayBuffer>;
24
- uploadFile(assetId: string | number, form: FormData): Promise<string>;
25
- deleteFile(assetId: string | number, fileId: string): Promise<void>;
26
- getLogs(assetId: string | number, params: LogsParams): Promise<List<Log>>;
27
- getLogCount(assetId: string | number, params: LogsParams): Promise<number>;
28
- addLog(assetId: string | number, item: LogDto): Promise<void>;
29
- sendMail(mail: Mail): Promise<string>;
30
- private convertDates;
31
- }
@@ -1,97 +0,0 @@
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;
@@ -1,26 +0,0 @@
1
- import { DataInterface } from './data.interface';
2
- export interface Task {
3
- id: string;
4
- name: string;
5
- desc?: string;
6
- tags?: string[];
7
- author?: string;
8
- readPermissions: string[];
9
- readWritePermissions: string[];
10
- assetRef?: string;
11
- eventRef?: string;
12
- expiryDate?: Date;
13
- parent?: string;
14
- subTasks?: string[];
15
- assignedTo: string[];
16
- status?: string;
17
- acceptedBy?: string;
18
- rejectReason?: string;
19
- statusHistoryLog?: string[];
20
- weight?: number;
21
- createdAt?: string;
22
- updatedAt?: string;
23
- }
24
- export interface TaskInterface extends DataInterface<Task> {
25
- createTaskAttachedToAsset(dto: any): any;
26
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,7 +0,0 @@
1
- import { DataService } from './data.service';
2
- import { HttpClient } from './http.service';
3
- import { Task, TaskInterface } from './task.interface';
4
- export declare class TaskService extends DataService<Task> implements TaskInterface {
5
- constructor(httpClient: HttpClient);
6
- createTaskAttachedToAsset(dto: any): Promise<Task>;
7
- }
@@ -1,13 +0,0 @@
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;
@@ -1,51 +0,0 @@
1
- import { DataInterface, Paginated } from './data.interface';
2
- export interface TimeSeries {
3
- id?: string;
4
- name: string;
5
- description: string;
6
- readPermissions: string[];
7
- readWritePermissions: string[];
8
- assetRef?: string;
9
- assetTsId?: string;
10
- minDate: Date;
11
- maxBucketTimeRange: number;
12
- tsRef?: [string];
13
- condition: TimeSeriesCondition;
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';
40
- export interface TimeseriesInterface extends DataInterface<TimeSeries> {
41
- addValue(id: string, value: {
42
- [values: string]: any;
43
- }): any;
44
- addAssetTimeSeriesValues(assetId: string, name: string, readPermissions: string[], readWritePermissions: string[], values: {
45
- [timestamp: string]: any;
46
- }): any;
47
- getMostRecentValue(id: string, before: Date): Promise<TimeSeriesValue>;
48
- getValues(id: string, from: number, limit?: number, group?: TS_GROUPS): any;
49
- getValuesOfPeriod(id: string, from: number, to: number, group?: TS_GROUPS): any;
50
- getManyByAsset(assetId: string, names?: string[]): Promise<Paginated<TimeSeries[]>>;
51
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,17 +0,0 @@
1
- import { Paginated } from './data.interface';
2
- import { DataService } from './data.service';
3
- import { HttpClient } from './http.service';
4
- import { TS_GROUPS, TimeSeries, TimeSeriesValue, TimeseriesInterface } from './timeseries.interface';
5
- export declare class TimeSeriesService extends DataService<TimeSeries> implements TimeseriesInterface {
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
- }
@@ -1,38 +0,0 @@
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;
@@ -1,3 +0,0 @@
1
- export interface UserInterface {
2
- getCurrentUserRoles(): Promise<string[]>;
3
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,7 +0,0 @@
1
- import { HttpClient } from './http.service';
2
- import { UserInterface } from './user.interface';
3
- export declare class UserService implements UserInterface {
4
- private httpClient;
5
- constructor(httpClient: HttpClient);
6
- getCurrentUserRoles(): Promise<string[]>;
7
- }
@@ -1,21 +0,0 @@
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 = 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 = 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;