@hahnpro/flow-sdk 2025.2.0-beta.1 → 2025.2.0-beta.3
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/package.json +4 -4
- package/src/{index.ts → index.d.ts} +0 -3
- package/src/index.js +18 -0
- package/src/lib/ContextManager.d.ts +40 -0
- package/src/lib/ContextManager.js +105 -0
- package/src/lib/FlowApplication.d.ts +85 -0
- package/src/lib/FlowApplication.js +528 -0
- package/src/lib/FlowElement.d.ts +67 -0
- package/src/lib/FlowElement.js +178 -0
- package/src/lib/FlowEvent.d.ts +25 -0
- package/src/lib/FlowEvent.js +72 -0
- package/src/lib/FlowLogger.d.ts +44 -0
- package/src/lib/FlowLogger.js +110 -0
- package/src/lib/FlowModule.d.ts +7 -0
- package/src/lib/FlowModule.js +14 -0
- package/src/lib/RpcClient.d.ts +13 -0
- package/src/lib/RpcClient.js +88 -0
- package/src/lib/TestModule.d.ts +2 -0
- package/src/lib/TestModule.js +27 -0
- package/src/lib/amqp.d.ts +14 -0
- package/src/lib/amqp.js +12 -0
- package/src/lib/extra-validators.d.ts +1 -0
- package/src/lib/extra-validators.js +53 -0
- package/src/lib/flow.interface.d.ts +48 -0
- package/src/lib/flow.interface.js +9 -0
- package/src/lib/{index.ts → index.d.ts} +0 -3
- package/src/lib/index.js +18 -0
- package/src/lib/nats.d.ts +12 -0
- package/src/lib/nats.js +115 -0
- package/src/lib/unit-decorators.d.ts +39 -0
- package/src/lib/unit-decorators.js +156 -0
- package/src/lib/unit-utils.d.ts +8 -0
- package/src/lib/unit-utils.js +144 -0
- package/src/lib/units.d.ts +31 -0
- package/src/lib/units.js +572 -0
- package/src/lib/utils.d.ts +51 -0
- package/src/lib/utils.js +178 -0
- package/jest.config.ts +0 -10
- package/project.json +0 -41
- package/src/lib/ContextManager.ts +0 -111
- package/src/lib/FlowApplication.ts +0 -659
- package/src/lib/FlowElement.ts +0 -220
- package/src/lib/FlowEvent.ts +0 -73
- package/src/lib/FlowLogger.ts +0 -131
- package/src/lib/FlowModule.ts +0 -18
- package/src/lib/RpcClient.ts +0 -99
- package/src/lib/TestModule.ts +0 -14
- package/src/lib/__pycache__/rpc_server.cpython-310.pyc +0 -0
- package/src/lib/amqp.ts +0 -32
- package/src/lib/extra-validators.ts +0 -62
- package/src/lib/flow.interface.ts +0 -56
- package/src/lib/nats.ts +0 -140
- package/src/lib/unit-decorators.ts +0 -156
- package/src/lib/unit-utils.ts +0 -163
- package/src/lib/units.ts +0 -587
- package/src/lib/utils.ts +0 -176
- package/test/context-manager-purpose.spec.ts +0 -248
- package/test/context-manager.spec.ts +0 -55
- package/test/context.spec.ts +0 -180
- package/test/event.spec.ts +0 -155
- package/test/extra-validators.spec.ts +0 -84
- package/test/flow-logger.spec.ts +0 -104
- package/test/flow.spec.ts +0 -508
- package/test/input-stream.decorator.spec.ts +0 -379
- package/test/long-rpc.test.py +0 -14
- package/test/long-running-rpc.spec.ts +0 -60
- package/test/message.spec.ts +0 -57
- package/test/mocks/logger.mock.ts +0 -7
- package/test/mocks/nats-connection.mock.ts +0 -135
- package/test/mocks/nats-prepare.reals-nats.ts +0 -15
- package/test/rpc.spec.ts +0 -198
- package/test/rpc.test.py +0 -45
- package/test/rx.spec.ts +0 -92
- package/test/unit-decorator.spec.ts +0 -57
- package/test/utils.spec.ts +0 -210
- package/test/validation.spec.ts +0 -174
- package/tsconfig.json +0 -13
- package/tsconfig.lib.json +0 -22
- package/tsconfig.spec.json +0 -8
package/test/validation.spec.ts
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
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
DELETED
package/tsconfig.lib.json
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
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
|
-
}
|