@fincity/kirun-js 1.8.1 → 1.9.0
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/runtime/KIRuntimeDependencyTest.ts +65 -0
- package/__tests__/engine/runtime/expression/tokenextractor/OutputMapTokenValueExtractorTest.ts +2 -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 +2 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/engine/model/Statement.ts +13 -0
- package/src/engine/repository/KIRunFunctionRepository.ts +7 -1
- package/src/engine/runtime/KIRuntime.ts +13 -0
- package/src/engine/runtime/tokenextractor/OutputMapTokenValueExtractor.ts +2 -2
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { FunctionDefinition } from '../../../src/engine/model/FunctionDefinition';
|
|
2
|
+
import { Namespaces } from '../../../src/engine/namespaces/Namespaces';
|
|
3
|
+
import { KIRunFunctionRepository } from '../../../src/engine/repository/KIRunFunctionRepository';
|
|
4
|
+
import { KIRunSchemaRepository } from '../../../src/engine/repository/KIRunSchemaRepository';
|
|
5
|
+
import { FunctionExecutionParameters } from '../../../src/engine/runtime/FunctionExecutionParameters';
|
|
6
|
+
import { KIRuntime } from '../../../src/engine/runtime/KIRuntime';
|
|
7
|
+
|
|
8
|
+
test('KIRuntime With Definition 1', async () => {
|
|
9
|
+
var def = {
|
|
10
|
+
name: 'getAppData',
|
|
11
|
+
namespace: 'UIApp',
|
|
12
|
+
parameters: {
|
|
13
|
+
a: {
|
|
14
|
+
parameterName: 'a',
|
|
15
|
+
schema: { name: 'INTEGER', type: ['ARRAY'], items: { type: ['OBJECT', 'NULL'] } },
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
steps: {
|
|
20
|
+
forEach: {
|
|
21
|
+
statementName: 'forEach',
|
|
22
|
+
namespace: 'System.Loop',
|
|
23
|
+
name: 'ForEachLoop',
|
|
24
|
+
parameterMap: {
|
|
25
|
+
source: {
|
|
26
|
+
one: { key: 'one', type: 'EXPRESSION', expression: 'Arguments.a' },
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
print: {
|
|
31
|
+
statementName: 'print',
|
|
32
|
+
namespace: 'System',
|
|
33
|
+
name: 'Print',
|
|
34
|
+
parameterMap: {
|
|
35
|
+
values: {
|
|
36
|
+
one: {
|
|
37
|
+
key: 'one',
|
|
38
|
+
type: 'EXPRESSION',
|
|
39
|
+
expression: 'Steps.forEach.iteration.each.name',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
executeIftrue: {
|
|
44
|
+
'Steps.forEach.iteration.each.name': true,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const fd = FunctionDefinition.from(def);
|
|
51
|
+
const oldLog = console.log;
|
|
52
|
+
|
|
53
|
+
const mock = jest.spyOn(global.console, 'log').mockImplementation(oldLog);
|
|
54
|
+
|
|
55
|
+
let result = await new KIRuntime(fd, false).execute(
|
|
56
|
+
new FunctionExecutionParameters(
|
|
57
|
+
new KIRunFunctionRepository(),
|
|
58
|
+
new KIRunSchemaRepository(),
|
|
59
|
+
).setArguments(
|
|
60
|
+
new Map([['a', [{ name: 'Kiran', age: 40 }, null, { name: 'Kumar', age: 39 }]]]),
|
|
61
|
+
),
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
expect(mock).toBeCalledTimes(2);
|
|
65
|
+
});
|
package/__tests__/engine/runtime/expression/tokenextractor/OutputMapTokenValueExtractorTest.ts
CHANGED
|
@@ -46,9 +46,11 @@ test('OutputMapTokenValueExtractor Test', () => {
|
|
|
46
46
|
test('OutputMapTokenValueExtractor Test 2', () => {
|
|
47
47
|
let output: Map<string, Map<string, Map<string, any>>> = new Map([
|
|
48
48
|
['step1', new Map([['output', new Map([['arr', ['a', 'b', 'c']]])]])],
|
|
49
|
+
['step2', new Map([['output', new Map()]])],
|
|
49
50
|
]);
|
|
50
51
|
|
|
51
52
|
var omtv = new OutputMapTokenValueExtractor(output);
|
|
52
53
|
expect(omtv.getValue('Steps.step1.output.arr[1]')).toBe('b');
|
|
53
54
|
expect(omtv.getValue('Steps.step1.output.arr1[1]')).toBeUndefined();
|
|
55
|
+
expect(omtv.getValue('Steps.step2.output')).toBeDefined();
|
|
54
56
|
});
|