@fincity/kirun-js 1.5.2 → 1.6.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/__tests__/engine/json/schema/validator/ArrayContainsValidatorTest.ts +339 -0
- package/__tests__/engine/json/schema/validator/ArraySchemaAdapterTypeTest.ts +142 -0
- package/__tests__/engine/json/schema/validator/ArraySchemaTypeTest.ts +191 -0
- package/__tests__/engine/json/schema/validator/ArrayValidatorTest.ts +152 -0
- package/__tests__/engine/json/schema/validator/ObjectPropertiesTest.ts +23 -0
- package/__tests__/engine/json/schema/validator/ObjectValidatorTest.ts +280 -0
- package/__tests__/engine/json/schema/validator/SchemaAnyOfValidatorTest.ts +20 -3
- package/__tests__/engine/json/schema/validator/SchemaValidatorTest.ts +21 -5
- package/__tests__/engine/json/schema/validator/StringValidatorTest.ts +0 -2
- package/__tests__/engine/repository/RepositoryFilterTest.ts +39 -0
- package/__tests__/engine/runtime/KIRuntimeFunctionInFunction.ts +6 -0
- package/__tests__/engine/runtime/KIRuntimeMessagesTest.ts +179 -0
- package/__tests__/engine/runtime/KIRuntimeTest.ts +6 -0
- package/__tests__/indexTest.ts +12 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/module.js +1 -1
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +23 -12
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/engine/HybridRepository.ts +8 -0
- package/src/engine/Repository.ts +1 -0
- package/src/engine/function/system/Print.ts +1 -1
- package/src/engine/function/system/array/ArrayFunctionRepository.ts +10 -0
- package/src/engine/function/system/math/MathFunctionRepository.ts +10 -1
- package/src/engine/function/system/string/StringFunctionRepository.ts +10 -0
- package/src/engine/json/schema/Schema.ts +82 -32
- package/src/engine/json/schema/SchemaUtil.ts +6 -3
- package/src/engine/json/schema/array/ArraySchemaType.ts +13 -2
- package/src/engine/json/schema/validator/ArrayValidator.ts +135 -24
- package/src/engine/json/schema/validator/ObjectValidator.ts +9 -4
- package/src/engine/model/Event.ts +2 -2
- package/src/engine/model/FunctionDefinition.ts +3 -3
- package/src/engine/model/FunctionSignature.ts +6 -3
- package/src/engine/model/Statement.ts +4 -6
- package/src/engine/repository/KIRunFunctionRepository.ts +9 -0
- package/src/engine/repository/KIRunSchemaRepository.ts +8 -0
- package/src/engine/runtime/KIRuntime.ts +36 -48
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FunctionDefinition,
|
|
3
|
+
FunctionExecutionParameters,
|
|
4
|
+
KIRunFunctionRepository,
|
|
5
|
+
KIRunSchemaRepository,
|
|
6
|
+
KIRuntime,
|
|
7
|
+
Namespaces,
|
|
8
|
+
} from '../../../src';
|
|
9
|
+
|
|
10
|
+
test('Messages Test 1', async () => {
|
|
11
|
+
const func = {
|
|
12
|
+
name: 'loginFunction',
|
|
13
|
+
steps: {
|
|
14
|
+
messageStep: {
|
|
15
|
+
statementName: 'messageStep',
|
|
16
|
+
namespace: 'UIEngine',
|
|
17
|
+
name: 'Message',
|
|
18
|
+
parameterMap: {
|
|
19
|
+
msg: {
|
|
20
|
+
value1: {
|
|
21
|
+
key: 'value1',
|
|
22
|
+
type: 'EXPRESSION',
|
|
23
|
+
expression: 'Steps.loginStep.error.data',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
position: {
|
|
28
|
+
left: 198,
|
|
29
|
+
top: 245,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
genOutput: {
|
|
33
|
+
statementName: 'genOutput',
|
|
34
|
+
namespace: 'System',
|
|
35
|
+
name: 'GenerateEvent',
|
|
36
|
+
dependentStatements: {
|
|
37
|
+
'Steps.loginStep.output': true,
|
|
38
|
+
},
|
|
39
|
+
position: {
|
|
40
|
+
left: 482,
|
|
41
|
+
top: 172,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
loginStep1: {
|
|
45
|
+
name: 'Login',
|
|
46
|
+
namespace: 'UIEngine',
|
|
47
|
+
statementName: 'loginStep1',
|
|
48
|
+
parameterMap: {
|
|
49
|
+
userName: {
|
|
50
|
+
value1: {
|
|
51
|
+
key: 'value1',
|
|
52
|
+
type: 'EXPRESSION',
|
|
53
|
+
expression: 'Page.user.userName',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
password: {
|
|
57
|
+
value1: {
|
|
58
|
+
key: 'value1',
|
|
59
|
+
type: 'EXPRESSION',
|
|
60
|
+
expression: 'Page.user.password',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
rememberMe: {
|
|
64
|
+
value1: {
|
|
65
|
+
key: 'value1',
|
|
66
|
+
type: 'EXPRESSION',
|
|
67
|
+
expression: 'Page.user.rememberMe',
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
position: {
|
|
72
|
+
left: 472,
|
|
73
|
+
top: 333,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const fd = FunctionDefinition.from(func);
|
|
80
|
+
|
|
81
|
+
const graph = await new KIRuntime(fd, false).getExecutionPlan(
|
|
82
|
+
new KIRunFunctionRepository(),
|
|
83
|
+
new KIRunSchemaRepository(),
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
const messages = Array.from(graph.getNodeMap().values()).flatMap((node) => {
|
|
87
|
+
return node
|
|
88
|
+
.getData()
|
|
89
|
+
.getMessages()
|
|
90
|
+
.map((e) => e.getMessage());
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
expect(messages).toStrictEqual([
|
|
94
|
+
'UIEngine.Message is not available',
|
|
95
|
+
'Unable to find the step with name loginStep',
|
|
96
|
+
'UIEngine.Login is not available',
|
|
97
|
+
]);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test('Messages Test 2', async () => {
|
|
101
|
+
var def = {
|
|
102
|
+
name: 'getAppData',
|
|
103
|
+
namespace: 'UIApp',
|
|
104
|
+
parameters: {
|
|
105
|
+
a: { parameterName: 'a', schema: { name: 'INTEGER', type: 'INTEGER' } },
|
|
106
|
+
b: { parameterName: 'b', schema: { name: 'INTEGER', type: 'INTEGER' } },
|
|
107
|
+
c: { parameterName: 'c', schema: { name: 'INTEGER', type: 'INTEGER' } },
|
|
108
|
+
},
|
|
109
|
+
events: {
|
|
110
|
+
output: {
|
|
111
|
+
name: 'output',
|
|
112
|
+
parameters: { additionResult: { name: 'additionResult', type: 'INTEGER' } },
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
steps: {
|
|
116
|
+
add1: {
|
|
117
|
+
statementName: 'add1',
|
|
118
|
+
namespace: Namespaces.MATH,
|
|
119
|
+
name: 'Add',
|
|
120
|
+
parameterMap: {
|
|
121
|
+
value: {
|
|
122
|
+
one: { key: 'one', type: 'EXPRESSION', expression: 'Arguments.a' },
|
|
123
|
+
two: { key: 'two', type: 'EXPRESSION', expression: '10 + 1' },
|
|
124
|
+
three: { key: 'three', type: 'EXPRESSION', expression: 'Arguments.c' },
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
genOutput: {
|
|
129
|
+
statementName: 'genOutput',
|
|
130
|
+
namespace: Namespaces.SYSTEM,
|
|
131
|
+
name: 'GenerateEvent',
|
|
132
|
+
parameterMap: {
|
|
133
|
+
eventName: { one: { key: 'one', type: 'VALUE', value: 'output' } },
|
|
134
|
+
results: {
|
|
135
|
+
one: {
|
|
136
|
+
key: 'one',
|
|
137
|
+
type: 'VALUE',
|
|
138
|
+
value: {
|
|
139
|
+
name: 'additionResult',
|
|
140
|
+
value: { isExpression: true, value: 'Steps.add.output.value' },
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const fd = FunctionDefinition.from(def);
|
|
150
|
+
|
|
151
|
+
const graph = await new KIRuntime(fd, false).getExecutionPlan(
|
|
152
|
+
new KIRunFunctionRepository(),
|
|
153
|
+
new KIRunSchemaRepository(),
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
const messages = Array.from(graph.getNodeMap().values()).flatMap((node) => {
|
|
157
|
+
return node
|
|
158
|
+
.getData()
|
|
159
|
+
.getMessages()
|
|
160
|
+
.map((e) => e.getMessage());
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
expect(messages).toStrictEqual(['Unable to find the step with name add']);
|
|
164
|
+
|
|
165
|
+
await expect(
|
|
166
|
+
new KIRuntime(fd, false).execute(
|
|
167
|
+
new FunctionExecutionParameters(
|
|
168
|
+
new KIRunFunctionRepository(),
|
|
169
|
+
new KIRunSchemaRepository(),
|
|
170
|
+
).setArguments(
|
|
171
|
+
new Map([
|
|
172
|
+
['a', 7],
|
|
173
|
+
['b', 11],
|
|
174
|
+
['c', 13],
|
|
175
|
+
]),
|
|
176
|
+
),
|
|
177
|
+
),
|
|
178
|
+
).rejects.toThrow('Unable to find the step with name add');
|
|
179
|
+
});
|
|
@@ -344,6 +344,12 @@ test('KIRuntime Test 4', async () => {
|
|
|
344
344
|
find(namespace, name): Function {
|
|
345
345
|
return fibFunction;
|
|
346
346
|
},
|
|
347
|
+
|
|
348
|
+
filter(name: string): string[] {
|
|
349
|
+
return [fibFunction.getSignature().getFullName()].filter((e) =>
|
|
350
|
+
e.toLowerCase().includes(name.toLowerCase()),
|
|
351
|
+
);
|
|
352
|
+
},
|
|
347
353
|
});
|
|
348
354
|
|
|
349
355
|
start = new Date().getTime();
|
package/__tests__/indexTest.ts
CHANGED
|
@@ -9,6 +9,12 @@ class TestRepository {
|
|
|
9
9
|
find(namespace: string, name: string): string | undefined {
|
|
10
10
|
return TestRepository.TEST_INDEX.get(name);
|
|
11
11
|
}
|
|
12
|
+
|
|
13
|
+
filter(name: string): string[] {
|
|
14
|
+
return Array.from(TestRepository.TEST_INDEX.keys()).filter(
|
|
15
|
+
(e) => e.toLowerCase().indexOf(name.toLowerCase()) !== -1,
|
|
16
|
+
);
|
|
17
|
+
}
|
|
12
18
|
}
|
|
13
19
|
|
|
14
20
|
class TestRepository2 {
|
|
@@ -20,6 +26,12 @@ class TestRepository2 {
|
|
|
20
26
|
find(namespace: string, name: string): string | undefined {
|
|
21
27
|
return TestRepository2.TEST_INDEX.get(name);
|
|
22
28
|
}
|
|
29
|
+
|
|
30
|
+
filter(name: string): string[] {
|
|
31
|
+
return Array.from(TestRepository.TEST_INDEX.keys()).filter(
|
|
32
|
+
(e) => e.toLowerCase().indexOf(name.toLowerCase()) !== -1,
|
|
33
|
+
);
|
|
34
|
+
}
|
|
23
35
|
}
|
|
24
36
|
|
|
25
37
|
test('Hybrid Repository Test', () => {
|