@fincity/kirun-js 1.4.9 → 1.4.11
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/function/system/string/ToStringTest.ts +14 -1
- package/__tests__/engine/repository/KIRunFunctionRepositoryTest.ts +29 -0
- package/__tests__/engine/runtime/KIRuntimeFunctionInFunction.ts +163 -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 +31 -31
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/engine/function/system/array/ArrayFunctionRepository.ts +68 -0
- package/src/engine/function/system/math/MathFunctionRepository.ts +4 -0
- package/src/engine/function/system/math/RandomFloat.ts +1 -1
- package/src/engine/function/system/math/RandomInt.ts +1 -1
- package/src/engine/function/system/string/ReplaceAtGivenPosition.ts +8 -2
- package/src/engine/function/system/string/StringFunctionRepository.ts +23 -0
- package/src/engine/repository/KIRunFunctionRepository.ts +8 -7
- package/src/engine/runtime/FunctionExecutionParameters.ts +1 -2
- package/src/engine/runtime/KIRuntime.ts +37 -14
- package/src/engine/util/mapEntry.ts +5 -0
|
@@ -38,7 +38,20 @@ test('toString test2', async () => {
|
|
|
38
38
|
fep.setArguments(MapUtil.of('anytype', array));
|
|
39
39
|
|
|
40
40
|
expect((await toString.execute(fep)).allResults()[0].getResult().get('result')).toBe(
|
|
41
|
-
|
|
41
|
+
`[
|
|
42
|
+
"I",
|
|
43
|
+
"am",
|
|
44
|
+
"using",
|
|
45
|
+
"eclipse",
|
|
46
|
+
"to",
|
|
47
|
+
"test",
|
|
48
|
+
"the",
|
|
49
|
+
"changes",
|
|
50
|
+
"with",
|
|
51
|
+
"test",
|
|
52
|
+
"Driven",
|
|
53
|
+
"developement"
|
|
54
|
+
]`,
|
|
42
55
|
);
|
|
43
56
|
});
|
|
44
57
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { KIRunFunctionRepository, Namespaces } from '../../../src';
|
|
2
|
+
|
|
3
|
+
test('KIRunFunctionRepository Test', () => {
|
|
4
|
+
const repo = new KIRunFunctionRepository();
|
|
5
|
+
|
|
6
|
+
let fun = repo.find(Namespaces.STRING, 'ToString');
|
|
7
|
+
expect(fun).toBeTruthy();
|
|
8
|
+
expect(fun?.getSignature().getName()).toBe('ToString');
|
|
9
|
+
|
|
10
|
+
fun = repo.find(Namespaces.STRING, 'IndexOfWithStartPoint');
|
|
11
|
+
expect(fun).toBeTruthy();
|
|
12
|
+
expect(fun?.getSignature().getName()).toBe('IndexOfWithStartPoint');
|
|
13
|
+
|
|
14
|
+
fun = repo.find(Namespaces.SYSTEM_ARRAY, 'Compare');
|
|
15
|
+
expect(fun).toBeTruthy();
|
|
16
|
+
expect(fun?.getSignature().getName()).toBe('Compare');
|
|
17
|
+
|
|
18
|
+
fun = repo.find(Namespaces.MATH, 'RandomInt');
|
|
19
|
+
expect(fun).toBeTruthy();
|
|
20
|
+
expect(fun?.getSignature().getName()).toBe('RandomInt');
|
|
21
|
+
|
|
22
|
+
fun = repo.find(Namespaces.MATH, 'Exponential');
|
|
23
|
+
expect(fun).toBeTruthy();
|
|
24
|
+
expect(fun?.getSignature().getName()).toBe('Exponential');
|
|
25
|
+
|
|
26
|
+
fun = repo.find(Namespaces.SYSTEM, 'If');
|
|
27
|
+
expect(fun).toBeTruthy();
|
|
28
|
+
expect(fun?.getSignature().getName()).toBe('If');
|
|
29
|
+
});
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Function,
|
|
3
|
+
FunctionDefinition,
|
|
4
|
+
HybridRepository,
|
|
5
|
+
KIRunFunctionRepository,
|
|
6
|
+
Repository,
|
|
7
|
+
KIRuntime,
|
|
8
|
+
FunctionExecutionParameters,
|
|
9
|
+
KIRunSchemaRepository,
|
|
10
|
+
} from '../../../src';
|
|
11
|
+
|
|
12
|
+
test('KIRuntime Function in Function', async () => {
|
|
13
|
+
const first = new KIRuntime(
|
|
14
|
+
FunctionDefinition.from(
|
|
15
|
+
JSON.parse(`{
|
|
16
|
+
"name": "First",
|
|
17
|
+
"namespace": "Internal",
|
|
18
|
+
"events": {
|
|
19
|
+
"output": {
|
|
20
|
+
"name": "output",
|
|
21
|
+
"parameters": { "aresult": { "name": "aresult", "type": "INTEGER" } }
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"steps": {
|
|
25
|
+
"exSecond": {
|
|
26
|
+
"statementName": "exSecond",
|
|
27
|
+
"name": "Second",
|
|
28
|
+
"namespace": "Internal",
|
|
29
|
+
"parameterMap": {
|
|
30
|
+
"value" : { "one" : { "key": "one", "type": "VALUE", "value": 2 } }
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"exThird": {
|
|
34
|
+
"statementName": "exThird",
|
|
35
|
+
"name": "Third",
|
|
36
|
+
"namespace": "Internal",
|
|
37
|
+
"parameterMap": {
|
|
38
|
+
"value" : { "one" : { "key": "one", "type": "VALUE", "value": 3 } }
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"genOutput": {
|
|
42
|
+
"statementName": "genOutput",
|
|
43
|
+
"namespace": "System",
|
|
44
|
+
"name": "GenerateEvent",
|
|
45
|
+
"dependentStatements": {
|
|
46
|
+
"Steps.exSecond.output": true,
|
|
47
|
+
"Steps.exThird.output": true
|
|
48
|
+
},
|
|
49
|
+
"parameterMap": {
|
|
50
|
+
"eventName": { "one": { "key": "one", "type": "VALUE", "value": "output" } },
|
|
51
|
+
"results": {
|
|
52
|
+
"one": {
|
|
53
|
+
"key": "one",
|
|
54
|
+
"type": "VALUE",
|
|
55
|
+
"value": {
|
|
56
|
+
"name": "aresult",
|
|
57
|
+
"value": { "isExpression": true, "value": "Steps.exThird.output.result" }
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}`),
|
|
65
|
+
),
|
|
66
|
+
true,
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
const second = new KIRuntime(
|
|
70
|
+
FunctionDefinition.from(
|
|
71
|
+
JSON.parse(`{
|
|
72
|
+
"name": "Second",
|
|
73
|
+
"namespace": "Internal",
|
|
74
|
+
"parameters": {
|
|
75
|
+
"value": { "parameterName": "value", "schema": { "name": "INTEGER", "type": "INTEGER" } } },
|
|
76
|
+
"events": {
|
|
77
|
+
"output": {
|
|
78
|
+
"name": "output",
|
|
79
|
+
"parameters": { "result": { "name": "result", "type": "INTEGER" } }
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"steps": {
|
|
83
|
+
"genOutput": {
|
|
84
|
+
"statementName": "genOutput",
|
|
85
|
+
"namespace": "System",
|
|
86
|
+
"name": "GenerateEvent",
|
|
87
|
+
"parameterMap": {
|
|
88
|
+
"eventName": { "one": { "key": "one", "type": "VALUE", "value": "output" } },
|
|
89
|
+
"results": {
|
|
90
|
+
"one": {
|
|
91
|
+
"key": "one",
|
|
92
|
+
"type": "VALUE",
|
|
93
|
+
"value": {
|
|
94
|
+
"name": "result",
|
|
95
|
+
"value": { "isExpression": true, "value": "Arguments.value * 2" }
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}`),
|
|
103
|
+
),
|
|
104
|
+
true,
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
const third = new KIRuntime(
|
|
108
|
+
FunctionDefinition.from(
|
|
109
|
+
JSON.parse(`{
|
|
110
|
+
"name": "Third",
|
|
111
|
+
"namespace": "Internal",
|
|
112
|
+
"parameters": {
|
|
113
|
+
"value": { "parameterName": "value", "schema": { "name": "INTEGER", "type": "INTEGER" } } },
|
|
114
|
+
"events": {
|
|
115
|
+
"output": {
|
|
116
|
+
"name": "output",
|
|
117
|
+
"parameters": { "result": { "name": "result", "type": "INTEGER" } }
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
"steps": {
|
|
121
|
+
"genOutput": {
|
|
122
|
+
"statementName": "genOutput",
|
|
123
|
+
"namespace": "System",
|
|
124
|
+
"name": "GenerateEvent",
|
|
125
|
+
"parameterMap": {
|
|
126
|
+
"eventName": { "one": { "key": "one", "type": "VALUE", "value": "output" } },
|
|
127
|
+
"results": {
|
|
128
|
+
"one": {
|
|
129
|
+
"key": "one",
|
|
130
|
+
"type": "VALUE",
|
|
131
|
+
"value": {
|
|
132
|
+
"name": "result",
|
|
133
|
+
"value": { "isExpression": true, "value": "Arguments.value * 3" }
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}`),
|
|
141
|
+
),
|
|
142
|
+
true,
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
class InternalRepository implements Repository<Function> {
|
|
146
|
+
find(namespace: string, name: string): Function | undefined {
|
|
147
|
+
if (namespace !== 'Internal') return;
|
|
148
|
+
|
|
149
|
+
if (name === 'Third') return third;
|
|
150
|
+
if (name === 'Second') return second;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const repo = new HybridRepository(new KIRunFunctionRepository(), new InternalRepository());
|
|
155
|
+
|
|
156
|
+
const results = (
|
|
157
|
+
await first.execute(
|
|
158
|
+
new FunctionExecutionParameters(repo, new KIRunSchemaRepository(), 'Testing'),
|
|
159
|
+
)
|
|
160
|
+
).next();
|
|
161
|
+
|
|
162
|
+
expect(results?.getResult().get('aresult')).toBe(9);
|
|
163
|
+
});
|