@hahnpro/flow-sdk 9.6.5 → 2025.2.0-beta.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.
- package/CHANGELOG.md +904 -0
- package/jest.config.ts +10 -0
- package/package.json +7 -20
- package/project.json +41 -0
- package/src/index.ts +15 -0
- package/src/lib/ContextManager.ts +111 -0
- package/src/lib/FlowApplication.ts +659 -0
- package/src/lib/FlowElement.ts +220 -0
- package/src/lib/FlowEvent.ts +73 -0
- package/src/lib/FlowLogger.ts +131 -0
- package/src/lib/FlowModule.ts +18 -0
- package/src/lib/RpcClient.ts +99 -0
- package/src/lib/TestModule.ts +14 -0
- package/src/lib/__pycache__/rpc_server.cpython-310.pyc +0 -0
- package/src/lib/amqp.ts +32 -0
- package/src/lib/extra-validators.ts +62 -0
- package/src/lib/flow.interface.ts +56 -0
- package/{dist/index.d.ts → src/lib/index.ts} +3 -0
- package/src/lib/nats.ts +140 -0
- package/src/lib/unit-decorators.ts +156 -0
- package/src/lib/unit-utils.ts +163 -0
- package/src/lib/units.ts +587 -0
- package/src/lib/utils.ts +176 -0
- package/test/context-manager-purpose.spec.ts +248 -0
- package/test/context-manager.spec.ts +55 -0
- package/test/context.spec.ts +180 -0
- package/test/event.spec.ts +155 -0
- package/test/extra-validators.spec.ts +84 -0
- package/test/flow-logger.spec.ts +104 -0
- package/test/flow.spec.ts +508 -0
- package/test/input-stream.decorator.spec.ts +379 -0
- package/test/long-rpc.test.py +14 -0
- package/test/long-running-rpc.spec.ts +60 -0
- package/test/message.spec.ts +57 -0
- package/test/mocks/logger.mock.ts +7 -0
- package/test/mocks/nats-connection.mock.ts +135 -0
- package/test/mocks/nats-prepare.reals-nats.ts +15 -0
- package/test/rpc.spec.ts +198 -0
- package/test/rpc.test.py +45 -0
- package/test/rx.spec.ts +92 -0
- package/test/unit-decorator.spec.ts +57 -0
- package/test/utils.spec.ts +210 -0
- package/test/validation.spec.ts +174 -0
- package/tsconfig.json +13 -0
- package/tsconfig.lib.json +22 -0
- package/tsconfig.spec.json +8 -0
- package/LICENSE +0 -21
- package/dist/ContextManager.d.ts +0 -40
- package/dist/ContextManager.js +0 -77
- package/dist/FlowApplication.d.ts +0 -85
- package/dist/FlowApplication.js +0 -500
- package/dist/FlowElement.d.ts +0 -67
- package/dist/FlowElement.js +0 -163
- package/dist/FlowEvent.d.ts +0 -25
- package/dist/FlowEvent.js +0 -71
- package/dist/FlowLogger.d.ts +0 -44
- package/dist/FlowLogger.js +0 -94
- package/dist/FlowModule.d.ts +0 -7
- package/dist/FlowModule.js +0 -13
- package/dist/RpcClient.d.ts +0 -13
- package/dist/RpcClient.js +0 -84
- package/dist/TestModule.d.ts +0 -2
- package/dist/TestModule.js +0 -27
- package/dist/amqp.d.ts +0 -14
- package/dist/amqp.js +0 -12
- package/dist/extra-validators.d.ts +0 -1
- package/dist/extra-validators.js +0 -51
- package/dist/flow.interface.d.ts +0 -48
- package/dist/flow.interface.js +0 -9
- package/dist/index.js +0 -18
- package/dist/nats.d.ts +0 -12
- package/dist/nats.js +0 -109
- package/dist/unit-decorators.d.ts +0 -39
- package/dist/unit-decorators.js +0 -156
- package/dist/unit-utils.d.ts +0 -8
- package/dist/unit-utils.js +0 -143
- package/dist/units.d.ts +0 -31
- package/dist/units.js +0 -570
- package/dist/utils.d.ts +0 -51
- package/dist/utils.js +0 -137
- /package/{dist → src/lib}/rpc_server.py +0 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { Type } from 'class-transformer';
|
|
2
|
+
import { IsArray, IsNumber, IsString, ValidateNested } from 'class-validator';
|
|
3
|
+
|
|
4
|
+
import { FlowFunction, FlowTask } from '../src';
|
|
5
|
+
import { loggerMock } from './mocks/logger.mock';
|
|
6
|
+
|
|
7
|
+
describe('Property Validation', () => {
|
|
8
|
+
afterEach(() => {
|
|
9
|
+
loggerMock.log.mockReset();
|
|
10
|
+
loggerMock.warn.mockReset();
|
|
11
|
+
loggerMock.error.mockReset();
|
|
12
|
+
jest.restoreAllMocks();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('PCKG.FLW.SDK.VLDTN.1 should handle simple validation', () => {
|
|
16
|
+
@FlowFunction('test')
|
|
17
|
+
class Task extends FlowTask<Properties> {
|
|
18
|
+
constructor(context, properties) {
|
|
19
|
+
super(context, properties, Properties);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
class Properties {
|
|
24
|
+
@IsNumber()
|
|
25
|
+
aNumber: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
expect(() => new Task({ logger: loggerMock }, { aNumber: 42 })).not.toThrow('Properties Validation failed');
|
|
29
|
+
|
|
30
|
+
expect(() => new Task({ logger: loggerMock }, {})).toThrow('Properties Validation failed');
|
|
31
|
+
expect(loggerMock.error).toHaveBeenLastCalledWith(
|
|
32
|
+
expect.stringContaining(
|
|
33
|
+
'Validation for property "aNumber" failed:\n{"isNumber":"aNumber must be a number conforming to the specified constraints"}\nvalue: undefined',
|
|
34
|
+
),
|
|
35
|
+
{ functionFqn: 'test' },
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
expect(() => new Task({ logger: loggerMock }, { aNumber: 'a string' })).toThrow('Properties Validation failed');
|
|
39
|
+
expect(loggerMock.error).toHaveBeenLastCalledWith(
|
|
40
|
+
expect.stringContaining(
|
|
41
|
+
'Validation for property "aNumber" failed:\n{"isNumber":"aNumber must be a number conforming to the specified constraints"}\nvalue: a string',
|
|
42
|
+
),
|
|
43
|
+
{ functionFqn: 'test' },
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('PCKG.FLW.SDK.VLDTN.2 should handle array validation', () => {
|
|
48
|
+
@FlowFunction('test')
|
|
49
|
+
class Task extends FlowTask<Properties> {
|
|
50
|
+
constructor(context, properties) {
|
|
51
|
+
super(context, properties, Properties);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
class Properties {
|
|
56
|
+
@IsArray()
|
|
57
|
+
@IsString({ each: true })
|
|
58
|
+
aStringArray: string[];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
expect(() => new Task({ logger: loggerMock }, { aStringArray: [] })).not.toThrow('Properties Validation failed');
|
|
62
|
+
expect(() => new Task({ logger: loggerMock }, { aStringArray: ['foo'] })).not.toThrow('Properties Validation failed');
|
|
63
|
+
expect(() => new Task({ logger: loggerMock }, { aStringArray: ['foo', 'bar'] })).not.toThrow('Properties Validation failed');
|
|
64
|
+
|
|
65
|
+
expect(() => new Task({ logger: loggerMock }, {})).toThrow('Properties Validation failed');
|
|
66
|
+
expect(loggerMock.error).toHaveBeenLastCalledWith(
|
|
67
|
+
expect.stringContaining(
|
|
68
|
+
'Validation for property "aStringArray" failed:\n{"isString":"each value in aStringArray must be a string","isArray":"aStringArray must be an array"}\nvalue: undefined',
|
|
69
|
+
),
|
|
70
|
+
{ functionFqn: 'test' },
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
expect(() => new Task({ logger: loggerMock }, { aStringArray: 'foo' })).toThrow('Properties Validation failed');
|
|
74
|
+
expect(loggerMock.error).toHaveBeenLastCalledWith(
|
|
75
|
+
expect.stringContaining('Validation for property "aStringArray" failed:\n{"isArray":"aStringArray must be an array"}\nvalue: foo'),
|
|
76
|
+
{ functionFqn: 'test' },
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
expect(() => new Task({ logger: loggerMock }, { aStringArray: ['foo', 42] })).toThrow('Properties Validation failed');
|
|
80
|
+
expect(loggerMock.error).toHaveBeenLastCalledWith(
|
|
81
|
+
expect.stringContaining(
|
|
82
|
+
'Validation for property "aStringArray" failed:\n{"isString":"each value in aStringArray must be a string"}\nvalue: foo,42',
|
|
83
|
+
),
|
|
84
|
+
{ functionFqn: 'test' },
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('PCKG.FLW.SDK.VLDTN.3 should handle nested validation', () => {
|
|
89
|
+
@FlowFunction('test')
|
|
90
|
+
class Task extends FlowTask<Properties> {
|
|
91
|
+
constructor(context, properties) {
|
|
92
|
+
super(context, properties, Properties);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
class Nested {
|
|
97
|
+
@IsString()
|
|
98
|
+
aString: string;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
class Properties {
|
|
102
|
+
@Type(() => Nested)
|
|
103
|
+
@ValidateNested()
|
|
104
|
+
nested: Nested;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
expect(() => new Task({ logger: loggerMock }, { nested: { aString: 'foo' } })).not.toThrow('Properties Validation failed');
|
|
108
|
+
|
|
109
|
+
expect(() => new Task({ logger: loggerMock }, { nested: {} })).toThrow('Properties Validation failed');
|
|
110
|
+
expect(loggerMock.error).toHaveBeenLastCalledWith(
|
|
111
|
+
expect.stringContaining(
|
|
112
|
+
'Validation for property "nested.aString" failed:\n{"isString":"aString must be a string"}\nvalue: undefined',
|
|
113
|
+
),
|
|
114
|
+
{ functionFqn: 'test' },
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
expect(() => new Task({ logger: loggerMock }, { nested: { aString: 42 } })).toThrow('Properties Validation failed');
|
|
118
|
+
expect(loggerMock.error).toHaveBeenLastCalledWith(
|
|
119
|
+
expect.stringContaining('Validation for property "nested.aString" failed:\n{"isString":"aString must be a string"}\nvalue: 42'),
|
|
120
|
+
{ functionFqn: 'test' },
|
|
121
|
+
);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('PCKG.FLW.SDK.VLDTN.4 should handle arrays with nested validation', () => {
|
|
125
|
+
@FlowFunction('test')
|
|
126
|
+
class Task extends FlowTask<Properties> {
|
|
127
|
+
constructor(context, properties) {
|
|
128
|
+
super(context, properties, Properties);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
class Nested {
|
|
133
|
+
@IsString()
|
|
134
|
+
aString: string;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
class Properties {
|
|
138
|
+
@IsArray()
|
|
139
|
+
@Type(() => Nested)
|
|
140
|
+
@ValidateNested({ each: true })
|
|
141
|
+
nested: Nested[];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
expect(() => new Task({ logger: loggerMock }, { nested: [] })).not.toThrow('Properties Validation failed');
|
|
145
|
+
expect(() => new Task({ logger: loggerMock }, { nested: [{ aString: 'foo' }] })).not.toThrow('Properties Validation failed');
|
|
146
|
+
|
|
147
|
+
expect(() => new Task({ logger: loggerMock }, { nested: [{}] })).toThrow('Properties Validation failed');
|
|
148
|
+
expect(loggerMock.error).toHaveBeenLastCalledWith(
|
|
149
|
+
expect.stringContaining(
|
|
150
|
+
'Validation for property "nested.0.aString" failed:\n{"isString":"aString must be a string"}\nvalue: undefined',
|
|
151
|
+
),
|
|
152
|
+
{ functionFqn: 'test' },
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
expect(() => new Task({ logger: loggerMock }, { nested: 42 })).toThrow('Properties Validation failed');
|
|
156
|
+
expect(loggerMock.error).toHaveBeenLastCalledWith(
|
|
157
|
+
expect.stringContaining(
|
|
158
|
+
'Validation for property "nested" failed:\n{"isArray":"nested must be an array","nestedValidation":"each value in nested property nested must be either object or array"}\nvalue: 42',
|
|
159
|
+
),
|
|
160
|
+
{ functionFqn: 'test' },
|
|
161
|
+
);
|
|
162
|
+
expect(() => new Task({ logger: loggerMock }, {})).toThrow('Properties Validation failed');
|
|
163
|
+
expect(loggerMock.error).toHaveBeenLastCalledWith(
|
|
164
|
+
expect.stringContaining('Validation for property "nested" failed:\n{"isArray":"nested must be an array"}\nvalue: undefined'),
|
|
165
|
+
{ functionFqn: 'test' },
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
expect(() => new Task({ logger: loggerMock }, { nested: [{ aString: 42 }] })).toThrow('Properties Validation failed');
|
|
169
|
+
expect(loggerMock.error).toHaveBeenLastCalledWith(
|
|
170
|
+
expect.stringContaining('Validation for property "nested.0.aString" failed:\n{"isString":"aString must be a string"}\nvalue: 42'),
|
|
171
|
+
{ functionFqn: 'test' },
|
|
172
|
+
);
|
|
173
|
+
});
|
|
174
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"baseUrl": ".",
|
|
5
|
+
"rootDir": "src",
|
|
6
|
+
"outDir": "dist",
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"emitDeclarationOnly": false,
|
|
9
|
+
"forceConsistentCasingInFileNames": true,
|
|
10
|
+
"isolatedModules": true,
|
|
11
|
+
"moduleResolution": "Node16",
|
|
12
|
+
"module": "Node16",
|
|
13
|
+
"noImplicitOverride": false,
|
|
14
|
+
"noImplicitReturns": true,
|
|
15
|
+
"noFallthroughCasesInSwitch": true,
|
|
16
|
+
"noPropertyAccessFromIndexSignature": false,
|
|
17
|
+
"types": ["node"]
|
|
18
|
+
},
|
|
19
|
+
"include": ["src/**/*.ts"],
|
|
20
|
+
"references": [],
|
|
21
|
+
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
|
|
22
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2021 Hahn PRO
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/dist/ContextManager.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Logger } from './FlowLogger';
|
|
2
|
-
/**
|
|
3
|
-
* Class representing a context manager for handling properties.
|
|
4
|
-
*/
|
|
5
|
-
export declare class ContextManager {
|
|
6
|
-
protected logger: Logger;
|
|
7
|
-
private properties;
|
|
8
|
-
/**
|
|
9
|
-
* Constructor of the ContextManager.
|
|
10
|
-
* @param {Logger} logger - The logger instance for logging messages.
|
|
11
|
-
* @param {Record<string, any>} [flowProperties={}] - Initial properties to set.
|
|
12
|
-
*/
|
|
13
|
-
constructor(logger: Logger, flowProperties?: Record<string, any>);
|
|
14
|
-
/**
|
|
15
|
-
* Init or overwrite all properties.
|
|
16
|
-
* @param properties
|
|
17
|
-
*/
|
|
18
|
-
overwriteAllProperties(properties?: Record<string, any>): void;
|
|
19
|
-
updateFlowProperties(properties?: Record<string, any>): void;
|
|
20
|
-
/**
|
|
21
|
-
* Get a copy of the current properties.
|
|
22
|
-
* @returns {Record<string, any>} A copy of the properties.
|
|
23
|
-
*/
|
|
24
|
-
getProperties(): Record<string, any>;
|
|
25
|
-
/**
|
|
26
|
-
* Set a property.
|
|
27
|
-
* A property key starting with "flow." is reserved for the properties set by in UI and so it is not allowed to be set.
|
|
28
|
-
* @param {string} keyOrPath - The key or the path of the property.
|
|
29
|
-
* @param {any} value - The value of the property.
|
|
30
|
-
*/
|
|
31
|
-
set(keyOrPath: string, value: any): void;
|
|
32
|
-
/**
|
|
33
|
-
* Get a property value by key.
|
|
34
|
-
* @param {string} keyOrPath - The key or the path of the property.
|
|
35
|
-
* @returns {any} The value of the property.
|
|
36
|
-
*/
|
|
37
|
-
get(keyOrPath: string): any;
|
|
38
|
-
replaceAllPlaceholderProperties(properties: any): any;
|
|
39
|
-
}
|
|
40
|
-
export declare function flowInterpolate(value: any, properties: Record<string, any>): any;
|
package/dist/ContextManager.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ContextManager = void 0;
|
|
4
|
-
exports.flowInterpolate = flowInterpolate;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
|
-
const lodash_1 = require("lodash");
|
|
7
|
-
const string_interp_1 = tslib_1.__importDefault(require("string-interp"));
|
|
8
|
-
class ContextManager {
|
|
9
|
-
constructor(logger, flowProperties = {}) {
|
|
10
|
-
this.logger = logger;
|
|
11
|
-
this.properties = { flow: flowProperties };
|
|
12
|
-
}
|
|
13
|
-
overwriteAllProperties(properties = {}) {
|
|
14
|
-
this.properties = { flow: properties };
|
|
15
|
-
}
|
|
16
|
-
updateFlowProperties(properties = {}) {
|
|
17
|
-
this.properties.flow = properties;
|
|
18
|
-
}
|
|
19
|
-
getProperties() {
|
|
20
|
-
return { ...this.properties };
|
|
21
|
-
}
|
|
22
|
-
set(keyOrPath, value) {
|
|
23
|
-
if (keyOrPath.startsWith('flow.')) {
|
|
24
|
-
this.logger.error(`Set property of "${keyOrPath}" is not allowed, because it starts with "flow.", so it is reserved for the properties set by in UI.`);
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
(0, lodash_1.set)(this.properties, keyOrPath, value);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
get(keyOrPath) {
|
|
31
|
-
return (0, lodash_1.get)(this.properties, keyOrPath, undefined);
|
|
32
|
-
}
|
|
33
|
-
replaceAllPlaceholderProperties(properties) {
|
|
34
|
-
return flowInterpolate((0, lodash_1.cloneDeep)(properties), this.properties);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
exports.ContextManager = ContextManager;
|
|
38
|
-
function flowInterpolate(value, properties) {
|
|
39
|
-
if (!properties) {
|
|
40
|
-
return value;
|
|
41
|
-
}
|
|
42
|
-
if ((0, lodash_1.isPlainObject)(value)) {
|
|
43
|
-
for (const key of Object.keys(value)) {
|
|
44
|
-
value[key] = flowInterpolate(value[key], properties);
|
|
45
|
-
}
|
|
46
|
-
return value;
|
|
47
|
-
}
|
|
48
|
-
else if (Array.isArray(value) && value.length > 0) {
|
|
49
|
-
value.forEach(function (v, index) {
|
|
50
|
-
this[index] = flowInterpolate(v, properties);
|
|
51
|
-
}, value);
|
|
52
|
-
return value;
|
|
53
|
-
}
|
|
54
|
-
else if (value != null && typeof value === 'string' && value.startsWith('${')) {
|
|
55
|
-
const blockRegEx = /\$\{\s*(\S+)\s*}/g;
|
|
56
|
-
let newValue = value;
|
|
57
|
-
let m;
|
|
58
|
-
do {
|
|
59
|
-
m = blockRegEx.exec(value);
|
|
60
|
-
if (m?.[1].startsWith('flow.')) {
|
|
61
|
-
newValue = newValue.replace(m[0], interpolate(m[0], { flow: properties.flow }));
|
|
62
|
-
}
|
|
63
|
-
} while (m);
|
|
64
|
-
return newValue;
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
return value;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
function interpolate(text, templateVariables) {
|
|
71
|
-
try {
|
|
72
|
-
return (0, string_interp_1.default)(text, templateVariables) ?? text;
|
|
73
|
-
}
|
|
74
|
-
catch (err) {
|
|
75
|
-
return text;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import 'reflect-metadata';
|
|
2
|
-
import { API, HttpClientService, MockAPI } from '@hahnpro/hpc-api';
|
|
3
|
-
import { NatsConnection, ConnectionOptions as NatsConnectionOptions } from '@nats-io/nats-core';
|
|
4
|
-
import { AmqpConnectionManager } from 'amqp-connection-manager';
|
|
5
|
-
import { CloudEvent } from 'cloudevents';
|
|
6
|
-
import { PartialObserver } from 'rxjs';
|
|
7
|
-
import { AmqpConnection, AmqpConnectionConfig } from './amqp';
|
|
8
|
-
import { ClassType, Flow, FlowElementContext } from './flow.interface';
|
|
9
|
-
import { FlowEvent } from './FlowEvent';
|
|
10
|
-
import { Logger } from './FlowLogger';
|
|
11
|
-
import { RpcClient } from './RpcClient';
|
|
12
|
-
import { ContextManager } from './ContextManager';
|
|
13
|
-
interface FlowAppConfig {
|
|
14
|
-
logger?: Logger;
|
|
15
|
-
amqpConfig?: AmqpConnectionConfig;
|
|
16
|
-
amqpConnection?: AmqpConnectionManager;
|
|
17
|
-
natsConfig?: NatsConnectionOptions;
|
|
18
|
-
natsConnection?: NatsConnection;
|
|
19
|
-
apiClient?: HttpClientService;
|
|
20
|
-
skipApi?: boolean;
|
|
21
|
-
explicitInit?: boolean;
|
|
22
|
-
mockApi?: MockAPI;
|
|
23
|
-
}
|
|
24
|
-
export declare class FlowApplication {
|
|
25
|
-
private modules;
|
|
26
|
-
private flow;
|
|
27
|
-
private _api;
|
|
28
|
-
private _rpcClient;
|
|
29
|
-
private amqpChannel;
|
|
30
|
-
private readonly amqpConnection;
|
|
31
|
-
private readonly natsConnectionConfig?;
|
|
32
|
-
private _natsConnection?;
|
|
33
|
-
private readonly baseLogger;
|
|
34
|
-
private context;
|
|
35
|
-
private declarations;
|
|
36
|
-
private elements;
|
|
37
|
-
private initialized;
|
|
38
|
-
private readonly logger;
|
|
39
|
-
private outputStreamMap;
|
|
40
|
-
private outputQueueMetrics;
|
|
41
|
-
private performanceMap;
|
|
42
|
-
private readonly skipApi;
|
|
43
|
-
private readonly apiClient?;
|
|
44
|
-
private readonly contextManager;
|
|
45
|
-
private natsMessageIterator;
|
|
46
|
-
constructor(modules: ClassType<any>[], flow: Flow, config?: FlowAppConfig);
|
|
47
|
-
constructor(modules: ClassType<any>[], flow: Flow, baseLogger?: Logger, amqpConnection?: AmqpConnection, natsConnection?: NatsConnection, skipApi?: boolean, explicitInit?: boolean);
|
|
48
|
-
get rpcClient(): RpcClient;
|
|
49
|
-
get api(): API;
|
|
50
|
-
get natsConnection(): NatsConnection;
|
|
51
|
-
getContextManager(): ContextManager;
|
|
52
|
-
getProperties(): Record<string, any>;
|
|
53
|
-
private consumeNatsMessagesOfConsumer;
|
|
54
|
-
init(): Promise<void>;
|
|
55
|
-
private publishLifecycleEvent;
|
|
56
|
-
private setQueueMetrics;
|
|
57
|
-
private updateMetrics;
|
|
58
|
-
subscribe: (streamId: string, observer: PartialObserver<FlowEvent>) => import("rxjs").Subscription;
|
|
59
|
-
emit: (event: FlowEvent) => void;
|
|
60
|
-
emitPartial: (completeEvent: FlowEvent, partialEvent: FlowEvent) => void;
|
|
61
|
-
onMessage: (cloudEvent: CloudEvent) => Promise<void>;
|
|
62
|
-
/**
|
|
63
|
-
* Publish a flow event to the amqp flowlogs exchange.
|
|
64
|
-
* If the event size exceeds the limit it will be truncated
|
|
65
|
-
*
|
|
66
|
-
* TODO warum darf hier nicht false zurückgegeben werden? -> erzeugt loop
|
|
67
|
-
*/
|
|
68
|
-
publishNatsEventFlowlogs: (event: FlowEvent) => Promise<boolean>;
|
|
69
|
-
/**
|
|
70
|
-
* Calls onDestroy lifecycle method on all flow elements,
|
|
71
|
-
* closes amqp connection after allowing logs to be processed and published
|
|
72
|
-
* then exits process
|
|
73
|
-
*/
|
|
74
|
-
destroy(exitCode?: number): Promise<void>;
|
|
75
|
-
/**
|
|
76
|
-
* Returns rxjs subject for the specified stream id.
|
|
77
|
-
* A new subject will be created if one doesn't exist yet.
|
|
78
|
-
*/
|
|
79
|
-
private getOutputStream;
|
|
80
|
-
}
|
|
81
|
-
export interface Context extends FlowElementContext {
|
|
82
|
-
app?: FlowApplication;
|
|
83
|
-
logger?: Logger;
|
|
84
|
-
}
|
|
85
|
-
export {};
|