@fincity/kirun-js 1.1.2 → 1.1.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/function/system/array/AddFirstTest.ts +29 -7
- package/__tests__/engine/function/system/array/AddTest.ts +21 -5
- package/__tests__/engine/function/system/array/BinarySearchTest.ts +26 -7
- package/__tests__/engine/function/system/array/CompareTest.ts +5 -1
- package/__tests__/engine/function/system/array/CopyTest.ts +22 -7
- package/__tests__/engine/function/system/array/DeleteFirstTest.ts +21 -5
- package/__tests__/engine/function/system/array/DeleteFromTest.ts +17 -4
- package/__tests__/engine/function/system/array/DeleteLastTest.ts +21 -5
- package/__tests__/engine/function/system/array/DeleteTest.ts +25 -6
- package/__tests__/engine/function/system/array/DisjointTest.ts +13 -3
- package/__tests__/engine/function/system/array/Equals.ts +13 -3
- package/__tests__/engine/function/system/array/FillTest.ts +5 -1
- package/__tests__/engine/function/system/array/FrequencyTest.ts +13 -3
- package/__tests__/engine/function/system/array/IndexOfArrayTest.ts +29 -7
- package/__tests__/engine/function/system/array/IndexOfTest.ts +21 -5
- package/__tests__/engine/function/system/array/InsertTest.ts +25 -6
- package/__tests__/engine/function/system/array/LastIndexOfArrayTest.ts +21 -5
- package/__tests__/engine/function/system/array/LastIndexOfTest.ts +25 -6
- package/__tests__/engine/function/system/array/MaxTest.ts +33 -24
- package/__tests__/engine/function/system/array/MinTest.ts +33 -24
- package/__tests__/engine/function/system/array/MisMatchTest.ts +17 -4
- package/__tests__/engine/function/system/array/ReverseTest.ts +21 -5
- package/__tests__/engine/function/system/array/RotateTest.ts +13 -3
- package/__tests__/engine/function/system/array/ShuffleTest.ts +9 -2
- package/__tests__/engine/function/system/array/SortTest.ts +21 -5
- package/__tests__/engine/function/system/array/SubArrayTest.ts +21 -5
- package/__tests__/engine/function/system/context/SetFunctionTest.ts +13 -3
- package/__tests__/engine/function/system/math/AddTest.ts +5 -3
- package/__tests__/engine/function/system/math/RandomIntTest.ts +13 -5
- package/__tests__/engine/function/system/string/ConcatenateTest.ts +9 -2
- package/__tests__/engine/function/system/string/DeleteForGivenLengthTest.ts +9 -2
- package/__tests__/engine/function/system/string/InsertAtGivenPositionTest.ts +13 -3
- package/__tests__/engine/function/system/string/PostPadTest.ts +13 -3
- package/__tests__/engine/function/system/string/PrePadTest.ts +13 -3
- package/__tests__/engine/function/system/string/RegionMatchesTest.ts +13 -3
- package/__tests__/engine/function/system/string/ReverseTest.ts +10 -3
- package/__tests__/engine/function/system/string/SplitTest.ts +9 -2
- package/__tests__/engine/function/system/string/StringFunctionRepoTest2.ts +13 -3
- package/__tests__/engine/function/system/string/StringFunctionRepoTest3.ts +9 -2
- package/__tests__/engine/function/system/string/StringFunctionRepositoryTest.ts +33 -8
- package/__tests__/engine/function/system/string/ToStringTest.ts +10 -3
- package/__tests__/engine/function/system/string/TrimToTest.ts +9 -2
- package/__tests__/engine/json/schema/SchemaUtil.ts +3 -0
- package/__tests__/engine/json/schema/type/TypeUtilTest.ts +10 -0
- package/__tests__/engine/json/schema/validator/SchemaValidatorTest.ts +29 -0
- package/__tests__/engine/runtime/KIRuntimeTest.ts +23 -12
- package/__tests__/engine/runtime/KIRuntimeWithDefinitionTest.ts +9 -10
- package/__tests__/engine/runtime/expression/ExpressionEvaluationTest.ts +5 -1
- 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 +7 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/engine/function/AbstractFunction.ts +14 -5
- package/src/engine/json/schema/Schema.ts +3 -3
- package/src/engine/json/schema/SchemaUtil.ts +4 -4
- package/src/engine/json/schema/type/TypeUtil.ts +3 -5
- package/src/engine/json/schema/validator/SchemaValidator.ts +4 -1
- package/src/engine/runtime/FunctionExecutionParameters.ts +30 -0
- package/src/engine/runtime/KIRuntime.ts +37 -24
|
@@ -2,11 +2,15 @@ import { Reverse } from '../../../../../src/engine/function/system/string/Revers
|
|
|
2
2
|
import { SchemaValidationException } from '../../../../../src/engine/json/schema/validator/exception/SchemaValidationException';
|
|
3
3
|
import { FunctionExecutionParameters } from '../../../../../src/engine/runtime/FunctionExecutionParameters';
|
|
4
4
|
import { MapUtil } from '../../../../../src/engine/util/MapUtil';
|
|
5
|
+
import { KIRunFunctionRepository, KIRunSchemaRepository } from '../../../../../src';
|
|
5
6
|
|
|
6
7
|
const reve: Reverse = new Reverse();
|
|
7
8
|
|
|
8
9
|
test('reverse test1', async () => {
|
|
9
|
-
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
10
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
11
|
+
new KIRunFunctionRepository(),
|
|
12
|
+
new KIRunSchemaRepository(),
|
|
13
|
+
);
|
|
10
14
|
|
|
11
15
|
fep.setArguments(MapUtil.of('value', ' mr"ofta"lp edoc on a si sihT'));
|
|
12
16
|
|
|
@@ -16,7 +20,10 @@ test('reverse test1', async () => {
|
|
|
16
20
|
});
|
|
17
21
|
|
|
18
22
|
test('reverse test2', async () => {
|
|
19
|
-
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
23
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
24
|
+
new KIRunFunctionRepository(),
|
|
25
|
+
new KIRunSchemaRepository(),
|
|
26
|
+
);
|
|
20
27
|
|
|
21
28
|
fep.setArguments(MapUtil.of('value', ' '));
|
|
22
29
|
|
|
@@ -26,7 +33,7 @@ test('reverse test2', async () => {
|
|
|
26
33
|
});
|
|
27
34
|
|
|
28
35
|
// test('reverse test3', async () => {
|
|
29
|
-
// let fep: FunctionExecutionParameters = new FunctionExecutionParameters();
|
|
36
|
+
// let fep: FunctionExecutionParameters = new FunctionExecutionParameters(new KIRunFunctionRepository(), new KIRunSchemaRepository());
|
|
30
37
|
|
|
31
38
|
// fep.setArguments(MapUtil.of('value', null));
|
|
32
39
|
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { Split } from '../../../../../src/engine/function/system/string/Split';
|
|
2
2
|
import { FunctionExecutionParameters } from '../../../../../src/engine/runtime/FunctionExecutionParameters';
|
|
3
3
|
import { MapUtil } from '../../../../../src/engine/util/MapUtil';
|
|
4
|
+
import { KIRunFunctionRepository, KIRunSchemaRepository } from '../../../../../src';
|
|
4
5
|
|
|
5
6
|
const Spli: Split = new Split();
|
|
6
7
|
|
|
7
8
|
test('split test1', async () => {
|
|
8
|
-
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
9
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
10
|
+
new KIRunFunctionRepository(),
|
|
11
|
+
new KIRunSchemaRepository(),
|
|
12
|
+
);
|
|
9
13
|
fep.setArguments(
|
|
10
14
|
MapUtil.of(
|
|
11
15
|
'string',
|
|
@@ -35,7 +39,10 @@ test('split test1', async () => {
|
|
|
35
39
|
});
|
|
36
40
|
|
|
37
41
|
test('split test2', async () => {
|
|
38
|
-
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
42
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
43
|
+
new KIRunFunctionRepository(),
|
|
44
|
+
new KIRunSchemaRepository(),
|
|
45
|
+
);
|
|
39
46
|
fep.setArguments(
|
|
40
47
|
MapUtil.of(
|
|
41
48
|
'string',
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { KIRunFunctionRepository, KIRunSchemaRepository } from '../../../../../src';
|
|
1
2
|
import { AbstractStringFunction } from '../../../../../src/engine/function/system/string/AbstractStringFunction';
|
|
2
3
|
import { StringFunctionRepository } from '../../../../../src/engine/function/system/string/StringFunctionRepository';
|
|
3
4
|
import { Namespaces } from '../../../../../src/engine/namespaces/Namespaces';
|
|
@@ -8,7 +9,10 @@ const stringRepo = new StringFunctionRepository();
|
|
|
8
9
|
|
|
9
10
|
test('StringRepo - contains', async () => {
|
|
10
11
|
let fun = stringRepo.find(Namespaces.STRING, 'Contains');
|
|
11
|
-
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
12
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
13
|
+
new KIRunFunctionRepository(),
|
|
14
|
+
new KIRunSchemaRepository(),
|
|
15
|
+
);
|
|
12
16
|
|
|
13
17
|
if (!fun) {
|
|
14
18
|
throw new Error('Function not available');
|
|
@@ -84,7 +88,10 @@ test('string function repo 2', async () => {
|
|
|
84
88
|
throw new Error('Function not available');
|
|
85
89
|
}
|
|
86
90
|
|
|
87
|
-
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
91
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
92
|
+
new KIRunFunctionRepository(),
|
|
93
|
+
new KIRunSchemaRepository(),
|
|
94
|
+
);
|
|
88
95
|
fep.setArguments(
|
|
89
96
|
MapUtil.of(
|
|
90
97
|
AbstractStringFunction.PARAMETER_STRING_NAME,
|
|
@@ -140,7 +147,10 @@ test('string function repo 3', async () => {
|
|
|
140
147
|
throw new Error('Function not available');
|
|
141
148
|
}
|
|
142
149
|
|
|
143
|
-
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
150
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
151
|
+
new KIRunFunctionRepository(),
|
|
152
|
+
new KIRunSchemaRepository(),
|
|
153
|
+
);
|
|
144
154
|
|
|
145
155
|
fep.setArguments(
|
|
146
156
|
MapUtil.of(
|
|
@@ -3,12 +3,16 @@ import { StringFunctionRepository } from '../../../../../src/engine/function/sys
|
|
|
3
3
|
import { Namespaces } from '../../../../../src/engine/namespaces/Namespaces';
|
|
4
4
|
import { FunctionExecutionParameters } from '../../../../../src/engine/runtime/FunctionExecutionParameters';
|
|
5
5
|
import { MapUtil } from '../../../../../src/engine/util/MapUtil';
|
|
6
|
+
import { KIRunFunctionRepository, KIRunSchemaRepository } from '../../../../../src';
|
|
6
7
|
|
|
7
8
|
const stringRepo = new StringFunctionRepository();
|
|
8
9
|
|
|
9
10
|
test('StringRepo3 - EqualsIgnoreCase', async () => {
|
|
10
11
|
let fun = stringRepo.find(Namespaces.STRING, 'EqualsIgnoreCase');
|
|
11
|
-
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
12
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
13
|
+
new KIRunFunctionRepository(),
|
|
14
|
+
new KIRunSchemaRepository(),
|
|
15
|
+
);
|
|
12
16
|
|
|
13
17
|
if (!fun) {
|
|
14
18
|
throw new Error('Function not available');
|
|
@@ -48,7 +52,10 @@ test('StringRepo3 - EqualsIgnoreCase', async () => {
|
|
|
48
52
|
|
|
49
53
|
test('StringRepo3 - EqualsIgnoreCase', async () => {
|
|
50
54
|
let fun = stringRepo.find(Namespaces.STRING, 'EqualsIgnoreCase');
|
|
51
|
-
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
55
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
56
|
+
new KIRunFunctionRepository(),
|
|
57
|
+
new KIRunSchemaRepository(),
|
|
58
|
+
).setArguments(
|
|
52
59
|
new Map([
|
|
53
60
|
[AbstractStringFunction.PARAMETER_STRING_NAME, ' no code Kirun PLATform '],
|
|
54
61
|
[
|
|
@@ -3,6 +3,7 @@ import { StringFunctionRepository } from '../../../../../src/engine/function/sys
|
|
|
3
3
|
import { Namespaces } from '../../../../../src/engine/namespaces/Namespaces';
|
|
4
4
|
import { FunctionExecutionParameters } from '../../../../../src/engine/runtime/FunctionExecutionParameters';
|
|
5
5
|
import { MapUtil } from '../../../../../src/engine/util/MapUtil';
|
|
6
|
+
import { KIRunFunctionRepository, KIRunSchemaRepository } from '../../../../../src';
|
|
6
7
|
|
|
7
8
|
const repo = new StringFunctionRepository();
|
|
8
9
|
|
|
@@ -11,7 +12,10 @@ test('StringFunctionRepository - Trim', async () => {
|
|
|
11
12
|
if (!fun) {
|
|
12
13
|
throw new Error('Function not available');
|
|
13
14
|
}
|
|
14
|
-
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
15
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
16
|
+
new KIRunFunctionRepository(),
|
|
17
|
+
new KIRunSchemaRepository(),
|
|
18
|
+
);
|
|
15
19
|
fep.setArguments(MapUtil.of(AbstractStringFunction.PARAMETER_STRING_NAME, ' Kiran '));
|
|
16
20
|
expect(
|
|
17
21
|
(await fun.execute(fep))
|
|
@@ -26,7 +30,10 @@ test('StringFunctionRepo -Repeat', async () => {
|
|
|
26
30
|
if (!fun) {
|
|
27
31
|
throw new Error('Function not available');
|
|
28
32
|
}
|
|
29
|
-
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
33
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
34
|
+
new KIRunFunctionRepository(),
|
|
35
|
+
new KIRunSchemaRepository(),
|
|
36
|
+
);
|
|
30
37
|
|
|
31
38
|
fep.setArguments(
|
|
32
39
|
MapUtil.of<string, string | number>(
|
|
@@ -51,7 +58,10 @@ test('StringFunctionRepo -Lowercase', async () => {
|
|
|
51
58
|
throw new Error('Function not available');
|
|
52
59
|
}
|
|
53
60
|
|
|
54
|
-
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
61
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
62
|
+
new KIRunFunctionRepository(),
|
|
63
|
+
new KIRunSchemaRepository(),
|
|
64
|
+
);
|
|
55
65
|
|
|
56
66
|
fep.setArguments(
|
|
57
67
|
MapUtil.of<string, string | number>(
|
|
@@ -73,7 +83,10 @@ test('StringFunctionRepo -UpperCase', async () => {
|
|
|
73
83
|
if (!fun) {
|
|
74
84
|
throw new Error('Function not available');
|
|
75
85
|
}
|
|
76
|
-
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
86
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
87
|
+
new KIRunFunctionRepository(),
|
|
88
|
+
new KIRunSchemaRepository(),
|
|
89
|
+
);
|
|
77
90
|
|
|
78
91
|
fep.setArguments(
|
|
79
92
|
MapUtil.of<string, string | number>(
|
|
@@ -95,7 +108,10 @@ test('StringFunctionRepo -Blank1', async () => {
|
|
|
95
108
|
if (!fun) {
|
|
96
109
|
throw new Error('Function not available');
|
|
97
110
|
}
|
|
98
|
-
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
111
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
112
|
+
new KIRunFunctionRepository(),
|
|
113
|
+
new KIRunSchemaRepository(),
|
|
114
|
+
);
|
|
99
115
|
|
|
100
116
|
fep.setArguments(MapUtil.of<string, string>(AbstractStringFunction.PARAMETER_STRING_NAME, ''));
|
|
101
117
|
|
|
@@ -112,7 +128,10 @@ test('StringFunctionRepo -Blank2', async () => {
|
|
|
112
128
|
if (!fun) {
|
|
113
129
|
throw new Error('Function not available');
|
|
114
130
|
}
|
|
115
|
-
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
131
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
132
|
+
new KIRunFunctionRepository(),
|
|
133
|
+
new KIRunSchemaRepository(),
|
|
134
|
+
);
|
|
116
135
|
|
|
117
136
|
fep.setArguments(
|
|
118
137
|
MapUtil.of<string, string | number>(
|
|
@@ -134,7 +153,10 @@ test('StringFunctionRepo -Empty1', async () => {
|
|
|
134
153
|
if (!fun) {
|
|
135
154
|
throw new Error('Function not available');
|
|
136
155
|
}
|
|
137
|
-
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
156
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
157
|
+
new KIRunFunctionRepository(),
|
|
158
|
+
new KIRunSchemaRepository(),
|
|
159
|
+
);
|
|
138
160
|
|
|
139
161
|
fep.setArguments(
|
|
140
162
|
MapUtil.of<string, string | number>(AbstractStringFunction.PARAMETER_STRING_NAME, ''),
|
|
@@ -153,7 +175,10 @@ test('StringFunctionRepo -Empty2', async () => {
|
|
|
153
175
|
if (!fun) {
|
|
154
176
|
throw new Error('Function not available');
|
|
155
177
|
}
|
|
156
|
-
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
178
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
179
|
+
new KIRunFunctionRepository(),
|
|
180
|
+
new KIRunSchemaRepository(),
|
|
181
|
+
);
|
|
157
182
|
|
|
158
183
|
fep.setArguments(
|
|
159
184
|
MapUtil.of<string, string | number>(AbstractStringFunction.PARAMETER_STRING_NAME, ' '),
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import { ToString } from '../../../../../src/engine/function/system/string/ToString';
|
|
2
2
|
import { FunctionExecutionParameters } from '../../../../../src/engine/runtime/FunctionExecutionParameters';
|
|
3
3
|
import { MapUtil } from '../../../../../src/engine/util/MapUtil';
|
|
4
|
+
import { KIRunFunctionRepository, KIRunSchemaRepository } from '../../../../../src';
|
|
4
5
|
|
|
5
6
|
const toString: ToString = new ToString();
|
|
6
7
|
|
|
7
8
|
test('toString test1', async () => {
|
|
8
|
-
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
9
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
10
|
+
new KIRunFunctionRepository(),
|
|
11
|
+
new KIRunSchemaRepository(),
|
|
12
|
+
);
|
|
9
13
|
fep.setArguments(MapUtil.of('anytype', 123));
|
|
10
14
|
|
|
11
15
|
expect((await toString.execute(fep)).allResults()[0].getResult().get('result')).toBe('123');
|
|
12
16
|
});
|
|
13
17
|
|
|
14
18
|
// test('toString test2', async () => {
|
|
15
|
-
// let fep: FunctionExecutionParameters = new FunctionExecutionParameters();
|
|
19
|
+
// let fep: FunctionExecutionParameters = new FunctionExecutionParameters(new KIRunFunctionRepository(), new KIRunSchemaRepository());
|
|
16
20
|
|
|
17
21
|
// let array: string[] = [];
|
|
18
22
|
// array.push('I');
|
|
@@ -36,7 +40,10 @@ test('toString test1', async () => {
|
|
|
36
40
|
// });
|
|
37
41
|
|
|
38
42
|
test('toString test2 ', async () => {
|
|
39
|
-
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
43
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
44
|
+
new KIRunFunctionRepository(),
|
|
45
|
+
new KIRunSchemaRepository(),
|
|
46
|
+
);
|
|
40
47
|
fep.setArguments(MapUtil.of('anytype', true));
|
|
41
48
|
|
|
42
49
|
expect((await toString.execute(fep)).allResults()[0].getResult().get('result')).toBe('true');
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { TrimTo } from '../../../../../src/engine/function/system/string/TrimTo';
|
|
2
2
|
import { FunctionExecutionParameters } from '../../../../../src/engine/runtime/FunctionExecutionParameters';
|
|
3
|
+
import { KIRunFunctionRepository, KIRunSchemaRepository } from '../../../../../src';
|
|
3
4
|
|
|
4
5
|
const trim: TrimTo = new TrimTo();
|
|
5
6
|
|
|
6
7
|
test('Trim to test1 ', async () => {
|
|
7
|
-
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
8
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
9
|
+
new KIRunFunctionRepository(),
|
|
10
|
+
new KIRunSchemaRepository(),
|
|
11
|
+
).setArguments(
|
|
8
12
|
new Map<string, string | number>([
|
|
9
13
|
[TrimTo.PARAMETER_STRING_NAME, ' THIScompatY IS A NOcoDE plATFNORM'],
|
|
10
14
|
[TrimTo.PARAMETER_LENGTH_NAME, 14],
|
|
@@ -17,7 +21,10 @@ test('Trim to test1 ', async () => {
|
|
|
17
21
|
});
|
|
18
22
|
|
|
19
23
|
test('Trim to test2 ', async () => {
|
|
20
|
-
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
24
|
+
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
25
|
+
new KIRunFunctionRepository(),
|
|
26
|
+
new KIRunSchemaRepository(),
|
|
27
|
+
).setArguments(
|
|
21
28
|
new Map<string, string | number>([
|
|
22
29
|
[TrimTo.PARAMETER_STRING_NAME, ' THIScompatY IS A NOcoDE plATFNORM'],
|
|
23
30
|
[TrimTo.PARAMETER_LENGTH_NAME, 0],
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SchemaType, TypeUtil } from '../../../../../src';
|
|
2
|
+
|
|
3
|
+
test('TypeUtilTest', () => {
|
|
4
|
+
expect(TypeUtil.from('Object')?.contains(SchemaType.OBJECT)).toBeTruthy();
|
|
5
|
+
|
|
6
|
+
let type = TypeUtil.from(['Object', 'String']);
|
|
7
|
+
|
|
8
|
+
expect(type?.contains(SchemaType.STRING)).toBeTruthy();
|
|
9
|
+
expect(type?.contains(SchemaType.OBJECT)).toBeTruthy();
|
|
10
|
+
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { HybridRepository } from '../../../../../src';
|
|
1
2
|
import { Schema } from '../../../../../src/engine/json/schema/Schema';
|
|
2
3
|
import { SchemaType } from '../../../../../src/engine/json/schema/type/SchemaType';
|
|
3
4
|
import { TypeUtil } from '../../../../../src/engine/json/schema/type/TypeUtil';
|
|
@@ -24,3 +25,31 @@ test('Schema Validator Test 1', () => {
|
|
|
24
25
|
|
|
25
26
|
// expect(SchemaValidator.validate([], schema, repo, 2.5)).toThrowError(new SchemaValidationException('', '2.5 is not a number of type Integer'));
|
|
26
27
|
});
|
|
28
|
+
|
|
29
|
+
test('Schema Validator Test 2', () => {
|
|
30
|
+
const locationSchema = Schema.from({
|
|
31
|
+
name: 'Location',
|
|
32
|
+
namespace: 'Test',
|
|
33
|
+
type: 'Object',
|
|
34
|
+
properties: {
|
|
35
|
+
url: { name: 'url', type: 'String' },
|
|
36
|
+
},
|
|
37
|
+
required: ['url'],
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const repo = new HybridRepository<Schema>(
|
|
41
|
+
{
|
|
42
|
+
find(namespace, name): Schema | undefined {
|
|
43
|
+
if (namespace === 'Test' && name === 'Location') {
|
|
44
|
+
return locationSchema;
|
|
45
|
+
}
|
|
46
|
+
return undefined;
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
new KIRunSchemaRepository(),
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const obj = { url: 'http://xxxx.com' };
|
|
53
|
+
|
|
54
|
+
expect(SchemaValidator.validate(undefined, Schema.ofRef('Test.Location'), repo, obj)).toBe(obj);
|
|
55
|
+
});
|
|
@@ -147,9 +147,12 @@ test('KIRuntime Test 1', async () => {
|
|
|
147
147
|
.setParameters(
|
|
148
148
|
new Map([['Count', new Parameter('Count', Schema.ofInteger('Count'))]]),
|
|
149
149
|
) as FunctionDefinition,
|
|
150
|
-
|
|
151
|
-
new
|
|
152
|
-
|
|
150
|
+
).execute(
|
|
151
|
+
new FunctionExecutionParameters(
|
|
152
|
+
new KIRunFunctionRepository(),
|
|
153
|
+
new KIRunSchemaRepository(),
|
|
154
|
+
).setArguments(new Map([['Count', num]])),
|
|
155
|
+
)
|
|
153
156
|
).allResults();
|
|
154
157
|
console.log('KIRunt Logic : ' + (new Date().getTime() - start));
|
|
155
158
|
expect(out[0].getResult().get('result')).toStrictEqual(array);
|
|
@@ -193,9 +196,12 @@ test('KIRuntime Test 2', async () => {
|
|
|
193
196
|
),
|
|
194
197
|
]),
|
|
195
198
|
),
|
|
196
|
-
|
|
197
|
-
new
|
|
198
|
-
|
|
199
|
+
).execute(
|
|
200
|
+
new FunctionExecutionParameters(
|
|
201
|
+
new KIRunFunctionRepository(),
|
|
202
|
+
new KIRunSchemaRepository(),
|
|
203
|
+
).setArguments(new Map([['Value', -10]])),
|
|
204
|
+
)
|
|
199
205
|
).allResults();
|
|
200
206
|
|
|
201
207
|
expect(out[0].getResult().get('result')).toBe(10);
|
|
@@ -238,9 +244,12 @@ test('KIRuntime Test 3', async () => {
|
|
|
238
244
|
),
|
|
239
245
|
]),
|
|
240
246
|
),
|
|
241
|
-
|
|
242
|
-
new
|
|
243
|
-
|
|
247
|
+
).execute(
|
|
248
|
+
new FunctionExecutionParameters(
|
|
249
|
+
new KIRunFunctionRepository(),
|
|
250
|
+
new KIRunSchemaRepository(),
|
|
251
|
+
).setArguments(new Map([['Value', 27]])),
|
|
252
|
+
)
|
|
244
253
|
).allResults();
|
|
245
254
|
|
|
246
255
|
expect(out[0].getResult().get('result')).toBe(3);
|
|
@@ -335,9 +344,11 @@ test('KIRuntime Test 4', async () => {
|
|
|
335
344
|
),
|
|
336
345
|
]),
|
|
337
346
|
),
|
|
338
|
-
|
|
339
|
-
new KIRunSchemaRepository()
|
|
340
|
-
|
|
347
|
+
).execute(
|
|
348
|
+
new FunctionExecutionParameters(hybrid, new KIRunSchemaRepository()).setArguments(
|
|
349
|
+
new Map([['Value', num]]),
|
|
350
|
+
),
|
|
351
|
+
)
|
|
341
352
|
).allResults();
|
|
342
353
|
console.log('KIRun Logic : ' + (new Date().getTime() - start));
|
|
343
354
|
expect(out[0].getResult().get('result')).toStrictEqual(array);
|
|
@@ -26,14 +26,14 @@ test('KIRuntime With Definition 1', async () => {
|
|
|
26
26
|
name: 'getAppData',
|
|
27
27
|
namespace: 'UIApp',
|
|
28
28
|
parameters: {
|
|
29
|
-
a: { parameterName: 'a', schema: { name: 'integer', type: '
|
|
30
|
-
b: { parameterName: 'b', schema: { name: 'integer', type: '
|
|
31
|
-
c: { parameterName: 'c', schema: { name: 'integer', type: '
|
|
29
|
+
a: { parameterName: 'a', schema: { name: 'integer', type: 'Integer' } },
|
|
30
|
+
b: { parameterName: 'b', schema: { name: 'integer', type: 'Integer' } },
|
|
31
|
+
c: { parameterName: 'c', schema: { name: 'integer', type: 'Integer' } },
|
|
32
32
|
},
|
|
33
33
|
events: {
|
|
34
34
|
output: {
|
|
35
35
|
name: 'output',
|
|
36
|
-
parameters: { additionResult: { name: 'additionResult', type: '
|
|
36
|
+
parameters: { additionResult: { name: 'additionResult', type: 'Integer' } },
|
|
37
37
|
},
|
|
38
38
|
},
|
|
39
39
|
steps: {
|
|
@@ -71,12 +71,11 @@ test('KIRuntime With Definition 1', async () => {
|
|
|
71
71
|
|
|
72
72
|
const fd = FunctionDefinition.from(def);
|
|
73
73
|
|
|
74
|
-
let result = await new KIRuntime(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
new FunctionExecutionParameters().setArguments(
|
|
74
|
+
let result = await new KIRuntime(fd).execute(
|
|
75
|
+
new FunctionExecutionParameters(
|
|
76
|
+
new KIRunFunctionRepository(),
|
|
77
|
+
new KIRunSchemaRepository(),
|
|
78
|
+
).setArguments(
|
|
80
79
|
new Map([
|
|
81
80
|
['a', 7],
|
|
82
81
|
['b', 11],
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { KIRunFunctionRepository, KIRunSchemaRepository } from '../../../../src';
|
|
1
2
|
import { Schema } from '../../../../src/engine/json/schema/Schema';
|
|
2
3
|
import { ContextElement } from '../../../../src/engine/runtime/ContextElement';
|
|
3
4
|
import { ExpressionEvaluator } from '../../../../src/engine/runtime/expression/ExpressionEvaluator';
|
|
@@ -34,7 +35,10 @@ test('Expression Test', () => {
|
|
|
34
35
|
['loop', new Map([['iteration', new Map([['index', 2]])]])],
|
|
35
36
|
]);
|
|
36
37
|
|
|
37
|
-
let parameters: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
38
|
+
let parameters: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
39
|
+
new KIRunFunctionRepository(),
|
|
40
|
+
new KIRunSchemaRepository(),
|
|
41
|
+
)
|
|
38
42
|
.setArguments(new Map())
|
|
39
43
|
.setContext(
|
|
40
44
|
new Map([
|