@fincity/kirun-js 1.1.2 → 1.1.5
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/MathFunctionRepositoryTest.ts +108 -0
- package/__tests__/engine/function/system/math/MaximumTest.ts +38 -0
- package/__tests__/engine/function/system/math/MinimumTest.ts +38 -0
- package/__tests__/engine/function/system/math/RandomFloatTest.ts +83 -0
- 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/AnyOfAllOfOneOfValidatorTest.ts +38 -0
- package/__tests__/engine/json/schema/validator/SchemaValidatorTest.ts +67 -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 +11 -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/function/system/math/Maximum.ts +1 -1
- package/src/engine/function/system/math/Minimum.ts +1 -1
- package/src/engine/function/system/math/RandomFloat.ts +2 -2
- 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/model/AbstractStatement.ts +10 -0
- package/src/engine/runtime/FunctionExecutionParameters.ts +48 -0
- package/src/engine/runtime/KIRuntime.ts +38 -24
|
@@ -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,69 @@ 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
|
+
});
|
|
56
|
+
|
|
57
|
+
test('Schema Validator Test 3', () => {
|
|
58
|
+
const obj = { url: 'http://xxxx.com' };
|
|
59
|
+
|
|
60
|
+
const locationSchema = Schema.from({
|
|
61
|
+
name: 'Location',
|
|
62
|
+
namespace: 'Test',
|
|
63
|
+
type: 'Object',
|
|
64
|
+
properties: {
|
|
65
|
+
url: { name: 'url', type: 'String' },
|
|
66
|
+
},
|
|
67
|
+
required: ['url'],
|
|
68
|
+
defaultValue: obj,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const repo = new HybridRepository<Schema>(
|
|
72
|
+
{
|
|
73
|
+
find(namespace, name): Schema | undefined {
|
|
74
|
+
if (namespace === 'Test' && name === 'Location') {
|
|
75
|
+
return locationSchema;
|
|
76
|
+
}
|
|
77
|
+
return undefined;
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
new KIRunSchemaRepository(),
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
const obj1 = { url: 'http://yyyy.com' };
|
|
84
|
+
|
|
85
|
+
expect(
|
|
86
|
+
SchemaValidator.validate(
|
|
87
|
+
undefined,
|
|
88
|
+
Schema.ofRef('Test.Location').setDefaultValue(obj1),
|
|
89
|
+
repo,
|
|
90
|
+
undefined,
|
|
91
|
+
),
|
|
92
|
+
).toMatchObject(obj1);
|
|
93
|
+
});
|
|
@@ -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([
|