@fincity/kirun-js 2.7.0 → 2.8.2
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/WaitTest.ts +1 -1
- package/__tests__/engine/function/system/array/AddFirstTest.ts +2 -6
- package/__tests__/engine/function/system/array/IndexOfTest.ts +8 -13
- package/__tests__/engine/function/system/array/LastIndexOfTest.ts +9 -28
- package/__tests__/engine/function/system/date/AddSubtractTimeTest.ts +93 -0
- package/__tests__/engine/function/system/date/DateFunctionRepositoryTest.ts +96 -0
- package/__tests__/engine/function/system/date/DifferenceTest.ts +93 -0
- package/__tests__/engine/function/system/date/EpochToTimestampTest.ts +133 -0
- package/__tests__/engine/function/system/date/FromDateStringTest.ts +51 -0
- package/__tests__/engine/function/system/date/FromNowTest.ts +71 -0
- package/__tests__/engine/function/system/date/GetCurrentTimeStampTest.ts +19 -27
- package/__tests__/engine/function/system/date/GetNamesTest.ts +105 -0
- package/__tests__/engine/function/system/date/IsBetweenTest.ts +53 -0
- package/__tests__/engine/function/system/date/IsValidISODateTest.ts +42 -54
- package/__tests__/engine/function/system/date/LastFirstOfTest.ts +64 -0
- package/__tests__/engine/function/system/date/SetTimeZoneTest.ts +48 -0
- package/__tests__/engine/function/system/date/StartEndOfTest.ts +53 -0
- package/__tests__/engine/function/system/date/TimeAsTest.ts +24 -0
- package/__tests__/engine/function/system/date/TimestampToEpochTest.ts +45 -0
- package/__tests__/engine/function/system/date/ToDateStringTest.ts +48 -0
- package/__tests__/engine/function/system/math/RandomFloatTest.ts +21 -22
- package/__tests__/engine/function/system/math/RandomIntTest.ts +5 -4
- package/__tests__/engine/repository/RepositoryFilterTest.ts +4 -1
- package/__tests__/engine/runtime/expression/ExpressionEqualityTest.ts +76 -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 +14 -13
- package/dist/types.d.ts.map +1 -1
- package/generator/generateValidationCSV.ts +51 -42
- package/generator/validation-js.csv +0 -0
- package/package.json +9 -7
- package/src/engine/function/AbstractFunction.ts +1 -1
- package/src/engine/function/system/Print.ts +19 -5
- package/src/engine/function/system/Wait.ts +1 -1
- package/src/engine/function/system/array/AbstractArrayFunction.ts +3 -3
- package/src/engine/function/system/array/Fill.ts +1 -1
- package/src/engine/function/system/array/Frequency.ts +0 -1
- package/src/engine/function/system/array/IndexOf.ts +4 -4
- package/src/engine/function/system/array/LastIndexOf.ts +3 -3
- package/src/engine/function/system/array/Rotate.ts +1 -1
- package/src/engine/function/system/array/Shuffle.ts +1 -1
- package/src/engine/function/system/array/Sort.ts +1 -1
- package/src/engine/function/system/date/AbstractDateFunction.ts +229 -111
- package/src/engine/function/system/date/AddSubtractTime.ts +99 -0
- package/src/engine/function/system/date/DateFunctionRepository.ts +228 -122
- package/src/engine/function/system/date/EpochToTimestamp.ts +75 -0
- package/src/engine/function/system/date/FromDateString.ts +44 -0
- package/src/engine/function/system/date/FromNow.ts +77 -0
- package/src/engine/function/system/date/GetCurrent.ts +20 -0
- package/src/engine/function/system/date/GetNames.ts +74 -0
- package/src/engine/function/system/date/IsBetween.ts +62 -0
- package/src/engine/function/system/date/IsValidISODate.ts +54 -40
- package/src/engine/function/system/date/LastFirstOf.ts +72 -0
- package/src/engine/function/system/date/SetTimeZone.ts +43 -0
- package/src/engine/function/system/date/StartEndOf.ts +44 -0
- package/src/engine/function/system/date/TimeAs.ts +64 -0
- package/src/engine/function/system/date/TimestampToEpoch.ts +54 -0
- package/src/engine/function/system/date/ToDateString.ts +49 -0
- package/src/engine/function/system/date/common.ts +9 -0
- package/src/engine/function/system/math/MathFunctionRepository.ts +43 -4
- package/src/engine/function/system/math/RandomAny.ts +57 -0
- package/src/engine/function/system/object/ObjectConvert.ts +45 -19
- package/src/engine/function/system/object/ObjectFunctionRepository.ts +2 -1
- package/src/engine/function/system/string/AbstractStringFunction.ts +42 -82
- package/src/engine/function/system/string/StringFunctionRepository.ts +39 -20
- package/src/engine/json/schema/SchemaUtil.ts +1 -1
- package/src/engine/repository/KIRunSchemaRepository.ts +57 -3
- package/src/engine/util/string/StringUtil.ts +12 -0
- package/tsconfig.json +1 -2
- package/__tests__/engine/function/system/date/AddTimeTest.ts +0 -115
- package/__tests__/engine/function/system/date/DateToEpochTest.ts +0 -74
- package/__tests__/engine/function/system/date/DifferenceOfTimestampsTest.ts +0 -53
- package/__tests__/engine/function/system/date/EpochToDateTest.ts +0 -105
- package/__tests__/engine/function/system/date/GetDateTest.ts +0 -85
- package/__tests__/engine/function/system/date/GetDayTest.ts +0 -85
- package/__tests__/engine/function/system/date/GetFullYearTest.ts +0 -85
- package/__tests__/engine/function/system/date/GetHoursTest.ts +0 -85
- package/__tests__/engine/function/system/date/GetMilliSecondsTest.ts +0 -85
- package/__tests__/engine/function/system/date/GetMinutesTest.ts +0 -85
- package/__tests__/engine/function/system/date/GetMonthTest.ts +0 -85
- package/__tests__/engine/function/system/date/GetSecondsTest.ts +0 -85
- package/__tests__/engine/function/system/date/GetTimeAsArrayTest.ts +0 -59
- package/__tests__/engine/function/system/date/GetTimeAsObjectTest.ts +0 -83
- package/__tests__/engine/function/system/date/GetTimeTest.ts +0 -86
- package/__tests__/engine/function/system/date/IsLeapYearTest.ts +0 -85
- package/__tests__/engine/function/system/date/MaximumTimestampTest.ts +0 -55
- package/__tests__/engine/function/system/date/MinimumTimestampTest.ts +0 -54
- package/__tests__/engine/function/system/date/SubtractTimeTest.ts +0 -95
- package/src/engine/function/system/date/DateToEpoch.ts +0 -39
- package/src/engine/function/system/date/DifferenceOfTimestamps.ts +0 -45
- package/src/engine/function/system/date/EpochToDate.ts +0 -76
- package/src/engine/function/system/date/GetCurrentTimeStamp.ts +0 -36
- package/src/engine/function/system/date/GetTimeAsArray.ts +0 -48
- package/src/engine/function/system/date/GetTimeAsObject.ts +0 -66
- package/src/engine/function/system/date/MaximumTimestamp.ts +0 -73
- package/src/engine/function/system/date/MinimumTimestamp.ts +0 -74
- package/src/engine/function/system/math/RandomFloat.ts +0 -56
- package/src/engine/function/system/math/RandomInt.ts +0 -56
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { FunctionExecutionParameters } from '../../../../../src';
|
|
2
|
+
import { KIRunFunctionRepository } from '../../../../../src/engine/repository/KIRunFunctionRepository';
|
|
3
|
+
import { KIRunSchemaRepository } from '../../../../../src';
|
|
4
|
+
import { ToDateString } from '../../../../../src/engine/function/system/date/ToDateString';
|
|
5
|
+
import { AbstractDateFunction } from '../../../../../src/engine/function/system/date/AbstractDateFunction';
|
|
6
|
+
|
|
7
|
+
import { Settings } from 'luxon';
|
|
8
|
+
|
|
9
|
+
Settings.defaultZone = 'Asia/Kolkata';
|
|
10
|
+
|
|
11
|
+
describe('ToDateString', () => {
|
|
12
|
+
test('should return the date string in the given format', async () => {
|
|
13
|
+
const fep = new FunctionExecutionParameters(
|
|
14
|
+
new KIRunFunctionRepository(),
|
|
15
|
+
new KIRunSchemaRepository(),
|
|
16
|
+
).setArguments(
|
|
17
|
+
new Map([
|
|
18
|
+
[ToDateString.PARAMETER_TIMESTAMP_NAME, '2024-01-01T00:00:00.000+05:30'],
|
|
19
|
+
[ToDateString.PARAMETER_FORMAT_NAME, 'yyyy-MM-dd'],
|
|
20
|
+
]),
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
const result = await (await new ToDateString().execute(fep))
|
|
24
|
+
.allResults()[0]
|
|
25
|
+
.getResult()
|
|
26
|
+
.get(AbstractDateFunction.EVENT_RESULT_NAME);
|
|
27
|
+
expect(result).toBe('2024-01-01');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('should return the date string in the given format with locale', async () => {
|
|
31
|
+
const fep = new FunctionExecutionParameters(
|
|
32
|
+
new KIRunFunctionRepository(),
|
|
33
|
+
new KIRunSchemaRepository(),
|
|
34
|
+
).setArguments(
|
|
35
|
+
new Map([
|
|
36
|
+
[ToDateString.PARAMETER_TIMESTAMP_NAME, '2024-01-01T00:00:00.000+05:30'],
|
|
37
|
+
[ToDateString.PARAMETER_FORMAT_NAME, 'DDD'],
|
|
38
|
+
[ToDateString.PARAMETER_LOCALE_NAME, 'fr-CA'],
|
|
39
|
+
]),
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const result = await (await new ToDateString().execute(fep))
|
|
43
|
+
.allResults()[0]
|
|
44
|
+
.getResult()
|
|
45
|
+
.get(AbstractDateFunction.EVENT_RESULT_NAME);
|
|
46
|
+
expect(result).toBe('1 janvier 2024');
|
|
47
|
+
});
|
|
48
|
+
});
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { RandomFloat } from "../../../../../src/engine/function/system/math/RandomFloat";
|
|
2
1
|
import { FunctionExecutionParameters } from '../../../../../src/engine/runtime/FunctionExecutionParameters';
|
|
3
|
-
import { KIRunFunctionRepository, KIRunSchemaRepository } from '../../../../../src';
|
|
4
|
-
|
|
5
|
-
const rand = new RandomFloat();
|
|
2
|
+
import { KIRunFunctionRepository, KIRunSchemaRepository, Namespaces } from '../../../../../src';
|
|
3
|
+
import { MathFunctionRepository } from '../../../../../src/engine/function/system/math/MathFunctionRepository';
|
|
6
4
|
|
|
7
5
|
test('rand Float 1', async () => {
|
|
6
|
+
const rand = (await new MathFunctionRepository().find(Namespaces.MATH, 'RandomFloat'))!;
|
|
8
7
|
let min = 1,
|
|
9
8
|
max = 10;
|
|
10
9
|
|
|
11
10
|
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
12
|
-
new KIRunFunctionRepository,
|
|
13
|
-
new KIRunSchemaRepository
|
|
11
|
+
new KIRunFunctionRepository(),
|
|
12
|
+
new KIRunSchemaRepository(),
|
|
14
13
|
).setArguments(
|
|
15
14
|
new Map([
|
|
16
15
|
['minValue', min],
|
|
@@ -22,15 +21,16 @@ test('rand Float 1', async () => {
|
|
|
22
21
|
|
|
23
22
|
expect(num).toBeLessThanOrEqual(max);
|
|
24
23
|
expect(num).toBeGreaterThanOrEqual(min);
|
|
25
|
-
})
|
|
24
|
+
});
|
|
26
25
|
|
|
27
26
|
test('rand Float 2', async () => {
|
|
27
|
+
const rand = (await new MathFunctionRepository().find(Namespaces.MATH, 'RandomFloat'))!;
|
|
28
28
|
let min = 0.1,
|
|
29
29
|
max = 0.9;
|
|
30
30
|
|
|
31
31
|
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
32
|
-
new KIRunFunctionRepository,
|
|
33
|
-
new KIRunSchemaRepository
|
|
32
|
+
new KIRunFunctionRepository(),
|
|
33
|
+
new KIRunSchemaRepository(),
|
|
34
34
|
).setArguments(
|
|
35
35
|
new Map([
|
|
36
36
|
['minValue', min],
|
|
@@ -42,33 +42,32 @@ test('rand Float 2', async () => {
|
|
|
42
42
|
|
|
43
43
|
expect(num).toBeLessThanOrEqual(max);
|
|
44
44
|
expect(num).toBeGreaterThanOrEqual(min);
|
|
45
|
-
})
|
|
45
|
+
});
|
|
46
46
|
|
|
47
47
|
test('rand Float 3', async () => {
|
|
48
|
-
|
|
48
|
+
const rand = (await new MathFunctionRepository().find(Namespaces.MATH, 'RandomFloat'))!;
|
|
49
|
+
let min = 1,
|
|
50
|
+
max = 2147483647;
|
|
49
51
|
|
|
50
52
|
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
51
|
-
new KIRunFunctionRepository,
|
|
52
|
-
new KIRunSchemaRepository
|
|
53
|
-
).setArguments(
|
|
54
|
-
new Map([
|
|
55
|
-
['minValue', min],
|
|
56
|
-
]),
|
|
57
|
-
);
|
|
53
|
+
new KIRunFunctionRepository(),
|
|
54
|
+
new KIRunSchemaRepository(),
|
|
55
|
+
).setArguments(new Map([['minValue', min]]));
|
|
58
56
|
|
|
59
57
|
let num: number = (await rand.execute(fep)).allResults()[0].getResult().get('value');
|
|
60
58
|
|
|
61
59
|
expect(num).toBeLessThanOrEqual(max);
|
|
62
60
|
expect(num).toBeGreaterThanOrEqual(min);
|
|
63
|
-
})
|
|
61
|
+
});
|
|
64
62
|
|
|
65
63
|
test('rand Float 4', async () => {
|
|
64
|
+
const rand = (await new MathFunctionRepository().find(Namespaces.MATH, 'RandomFloat'))!;
|
|
66
65
|
let min = 1.1,
|
|
67
66
|
max = 1.2;
|
|
68
67
|
|
|
69
68
|
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
70
|
-
new KIRunFunctionRepository,
|
|
71
|
-
new KIRunSchemaRepository
|
|
69
|
+
new KIRunFunctionRepository(),
|
|
70
|
+
new KIRunSchemaRepository(),
|
|
72
71
|
).setArguments(
|
|
73
72
|
new Map([
|
|
74
73
|
['minValue', min],
|
|
@@ -80,4 +79,4 @@ test('rand Float 4', async () => {
|
|
|
80
79
|
|
|
81
80
|
expect(num).toBeLessThanOrEqual(max);
|
|
82
81
|
expect(num).toBeGreaterThanOrEqual(min);
|
|
83
|
-
})
|
|
82
|
+
});
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { RandomInt } from '../../../../../src/engine/function/system/math/RandomInt';
|
|
2
1
|
import { FunctionExecutionParameters } from '../../../../../src/engine/runtime/FunctionExecutionParameters';
|
|
3
|
-
import { KIRunFunctionRepository, KIRunSchemaRepository } from '../../../../../src';
|
|
4
|
-
|
|
5
|
-
const rand = new RandomInt();
|
|
2
|
+
import { KIRunFunctionRepository, KIRunSchemaRepository, Namespaces } from '../../../../../src';
|
|
3
|
+
import { MathFunctionRepository } from '../../../../../src/engine/function/system/math/MathFunctionRepository';
|
|
6
4
|
|
|
7
5
|
test(' rand int 1', async () => {
|
|
6
|
+
const rand = (await new MathFunctionRepository().find(Namespaces.MATH, 'RandomInt'))!;
|
|
8
7
|
let min = 100,
|
|
9
8
|
max = 1000123;
|
|
10
9
|
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
@@ -23,6 +22,7 @@ test(' rand int 1', async () => {
|
|
|
23
22
|
});
|
|
24
23
|
|
|
25
24
|
test(' rand int 2', async () => {
|
|
25
|
+
const rand = (await new MathFunctionRepository().find(Namespaces.MATH, 'RandomInt'))!;
|
|
26
26
|
let min = 100;
|
|
27
27
|
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
28
28
|
new KIRunFunctionRepository(),
|
|
@@ -35,6 +35,7 @@ test(' rand int 2', async () => {
|
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
test(' rand int 3', async () => {
|
|
38
|
+
const rand = (await new MathFunctionRepository().find(Namespaces.MATH, 'RandomInt'))!;
|
|
38
39
|
let min = 100,
|
|
39
40
|
max = 101;
|
|
40
41
|
let fep: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
@@ -24,7 +24,10 @@ test('Repository Filter Test', async () => {
|
|
|
24
24
|
expect(await schemaRepo.filter('ny')).toStrictEqual(['System.any']);
|
|
25
25
|
|
|
26
26
|
expect((await schemaRepo.filter('')).sort()).toStrictEqual([
|
|
27
|
-
'System.Date.
|
|
27
|
+
'System.Date.Duration',
|
|
28
|
+
'System.Date.TimeObject',
|
|
29
|
+
'System.Date.Timestamp',
|
|
30
|
+
'System.Date.Timeunit',
|
|
28
31
|
'System.Null',
|
|
29
32
|
'System.ParameterExpression',
|
|
30
33
|
'System.Schema',
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ExpressionEvaluator,
|
|
3
|
+
KIRunSchemaRepository,
|
|
4
|
+
FunctionExecutionParameters,
|
|
5
|
+
KIRunFunctionRepository,
|
|
6
|
+
} from '../../../../src';
|
|
7
|
+
|
|
8
|
+
let obj = {
|
|
9
|
+
number: 20,
|
|
10
|
+
zero: 0,
|
|
11
|
+
booleanTrue: true,
|
|
12
|
+
booleanFalse: false,
|
|
13
|
+
string: 'Hello',
|
|
14
|
+
emptyString: '',
|
|
15
|
+
nullValue: null,
|
|
16
|
+
undefinedValue: undefined,
|
|
17
|
+
emptyObject: {},
|
|
18
|
+
emptyArray: [],
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
let inMap: Map<string, any> = new Map();
|
|
22
|
+
inMap.set('name', 'Kiran');
|
|
23
|
+
inMap.set('obj', obj);
|
|
24
|
+
|
|
25
|
+
let output: Map<string, Map<string, Map<string, any>>> = new Map([
|
|
26
|
+
['step1', new Map([['output', inMap]])],
|
|
27
|
+
]);
|
|
28
|
+
|
|
29
|
+
let parameters: FunctionExecutionParameters = new FunctionExecutionParameters(
|
|
30
|
+
new KIRunFunctionRepository(),
|
|
31
|
+
new KIRunSchemaRepository(),
|
|
32
|
+
)
|
|
33
|
+
.setArguments(new Map())
|
|
34
|
+
.setSteps(output);
|
|
35
|
+
|
|
36
|
+
test('Expression Equality Test', () => {
|
|
37
|
+
let exp = new ExpressionEvaluator(
|
|
38
|
+
'Steps.step1.output.obj.number = Steps.step1.output.obj.zero',
|
|
39
|
+
);
|
|
40
|
+
let result = exp.evaluate(parameters.getValuesMap());
|
|
41
|
+
expect(result).toBe(false);
|
|
42
|
+
|
|
43
|
+
exp = new ExpressionEvaluator(
|
|
44
|
+
'Steps.step1.output.obj.booleanFalse = (not Steps.step1.output.obj.number)',
|
|
45
|
+
);
|
|
46
|
+
result = exp.evaluate(parameters.getValuesMap());
|
|
47
|
+
expect(result).toBe(true);
|
|
48
|
+
|
|
49
|
+
exp = new ExpressionEvaluator(
|
|
50
|
+
'Steps.step1.output.obj.booleanFalse = (not Steps.step1.output.obj.emptyString)',
|
|
51
|
+
);
|
|
52
|
+
result = exp.evaluate(parameters.getValuesMap());
|
|
53
|
+
expect(result).toBe(true);
|
|
54
|
+
|
|
55
|
+
exp = new ExpressionEvaluator(
|
|
56
|
+
'Steps.step1.output.obj.booleanTrue = (not Steps.step1.output.obj.zero)',
|
|
57
|
+
);
|
|
58
|
+
result = exp.evaluate(parameters.getValuesMap());
|
|
59
|
+
expect(result).toBe(true);
|
|
60
|
+
|
|
61
|
+
exp = new ExpressionEvaluator("Steps.step1.output.obj.emptyString = ''");
|
|
62
|
+
result = exp.evaluate(parameters.getValuesMap());
|
|
63
|
+
expect(result).toBe(true);
|
|
64
|
+
|
|
65
|
+
exp = new ExpressionEvaluator("Steps.step1.output.obj.emptyString != ''");
|
|
66
|
+
result = exp.evaluate(parameters.getValuesMap());
|
|
67
|
+
expect(result).toBe(false);
|
|
68
|
+
|
|
69
|
+
exp = new ExpressionEvaluator("Steps.step1.output.obj.string != ''");
|
|
70
|
+
result = exp.evaluate(parameters.getValuesMap());
|
|
71
|
+
expect(result).toBe(true);
|
|
72
|
+
|
|
73
|
+
exp = new ExpressionEvaluator("Steps.step1.output.obj.string = ''");
|
|
74
|
+
result = exp.evaluate(parameters.getValuesMap());
|
|
75
|
+
expect(result).toBe(false);
|
|
76
|
+
});
|