@fincity/kirun-js 2.7.0 → 2.8.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.
Files changed (101) hide show
  1. package/__tests__/engine/function/system/WaitTest.ts +1 -1
  2. package/__tests__/engine/function/system/array/AddFirstTest.ts +2 -6
  3. package/__tests__/engine/function/system/array/IndexOfTest.ts +8 -13
  4. package/__tests__/engine/function/system/array/LastIndexOfTest.ts +9 -28
  5. package/__tests__/engine/function/system/date/AddSubtractTimeTest.ts +93 -0
  6. package/__tests__/engine/function/system/date/DateFunctionRepositoryTest.ts +96 -0
  7. package/__tests__/engine/function/system/date/DifferenceTest.ts +93 -0
  8. package/__tests__/engine/function/system/date/EpochToTimestampTest.ts +133 -0
  9. package/__tests__/engine/function/system/date/FromDateStringTest.ts +51 -0
  10. package/__tests__/engine/function/system/date/FromNowTest.ts +71 -0
  11. package/__tests__/engine/function/system/date/GetCurrentTimeStampTest.ts +19 -27
  12. package/__tests__/engine/function/system/date/GetNamesTest.ts +105 -0
  13. package/__tests__/engine/function/system/date/IsBetweenTest.ts +53 -0
  14. package/__tests__/engine/function/system/date/IsValidISODateTest.ts +42 -54
  15. package/__tests__/engine/function/system/date/LastFirstOfTest.ts +64 -0
  16. package/__tests__/engine/function/system/date/SetTimeZoneTest.ts +48 -0
  17. package/__tests__/engine/function/system/date/StartEndOfTest.ts +53 -0
  18. package/__tests__/engine/function/system/date/TimeAsTest.ts +24 -0
  19. package/__tests__/engine/function/system/date/TimestampToEpochTest.ts +45 -0
  20. package/__tests__/engine/function/system/date/ToDateStringTest.ts +48 -0
  21. package/__tests__/engine/function/system/math/RandomFloatTest.ts +21 -22
  22. package/__tests__/engine/function/system/math/RandomIntTest.ts +5 -4
  23. package/__tests__/engine/repository/RepositoryFilterTest.ts +4 -1
  24. package/__tests__/engine/runtime/expression/ExpressionEqualityTest.ts +76 -0
  25. package/dist/index.js +1 -1
  26. package/dist/index.js.map +1 -1
  27. package/dist/module.js +1 -1
  28. package/dist/module.js.map +1 -1
  29. package/dist/types.d.ts +14 -13
  30. package/dist/types.d.ts.map +1 -1
  31. package/generator/generateValidationCSV.ts +51 -42
  32. package/generator/validation-js.csv +0 -0
  33. package/package.json +9 -7
  34. package/src/engine/function/AbstractFunction.ts +1 -1
  35. package/src/engine/function/system/Print.ts +19 -5
  36. package/src/engine/function/system/Wait.ts +1 -1
  37. package/src/engine/function/system/array/AbstractArrayFunction.ts +3 -3
  38. package/src/engine/function/system/array/Fill.ts +1 -1
  39. package/src/engine/function/system/array/Frequency.ts +0 -1
  40. package/src/engine/function/system/array/IndexOf.ts +4 -4
  41. package/src/engine/function/system/array/LastIndexOf.ts +3 -3
  42. package/src/engine/function/system/array/Rotate.ts +1 -1
  43. package/src/engine/function/system/array/Shuffle.ts +1 -1
  44. package/src/engine/function/system/array/Sort.ts +1 -1
  45. package/src/engine/function/system/date/AbstractDateFunction.ts +229 -111
  46. package/src/engine/function/system/date/AddSubtractTime.ts +99 -0
  47. package/src/engine/function/system/date/DateFunctionRepository.ts +228 -122
  48. package/src/engine/function/system/date/EpochToTimestamp.ts +75 -0
  49. package/src/engine/function/system/date/FromDateString.ts +44 -0
  50. package/src/engine/function/system/date/FromNow.ts +77 -0
  51. package/src/engine/function/system/date/GetCurrent.ts +20 -0
  52. package/src/engine/function/system/date/GetNames.ts +74 -0
  53. package/src/engine/function/system/date/IsBetween.ts +62 -0
  54. package/src/engine/function/system/date/IsValidISODate.ts +54 -40
  55. package/src/engine/function/system/date/LastFirstOf.ts +72 -0
  56. package/src/engine/function/system/date/SetTimeZone.ts +43 -0
  57. package/src/engine/function/system/date/StartEndOf.ts +44 -0
  58. package/src/engine/function/system/date/TimeAs.ts +64 -0
  59. package/src/engine/function/system/date/TimestampToEpoch.ts +54 -0
  60. package/src/engine/function/system/date/ToDateString.ts +49 -0
  61. package/src/engine/function/system/date/common.ts +9 -0
  62. package/src/engine/function/system/math/MathFunctionRepository.ts +43 -4
  63. package/src/engine/function/system/math/RandomAny.ts +57 -0
  64. package/src/engine/function/system/object/ObjectConvert.ts +45 -19
  65. package/src/engine/function/system/object/ObjectFunctionRepository.ts +2 -1
  66. package/src/engine/function/system/string/AbstractStringFunction.ts +42 -82
  67. package/src/engine/function/system/string/StringFunctionRepository.ts +39 -20
  68. package/src/engine/json/schema/SchemaUtil.ts +1 -1
  69. package/src/engine/repository/KIRunSchemaRepository.ts +57 -3
  70. package/src/engine/runtime/expression/tokenextractor/TokenValueExtractor.ts +14 -21
  71. package/src/engine/util/string/StringUtil.ts +12 -0
  72. package/tsconfig.json +1 -2
  73. package/__tests__/engine/function/system/date/AddTimeTest.ts +0 -115
  74. package/__tests__/engine/function/system/date/DateToEpochTest.ts +0 -74
  75. package/__tests__/engine/function/system/date/DifferenceOfTimestampsTest.ts +0 -53
  76. package/__tests__/engine/function/system/date/EpochToDateTest.ts +0 -105
  77. package/__tests__/engine/function/system/date/GetDateTest.ts +0 -85
  78. package/__tests__/engine/function/system/date/GetDayTest.ts +0 -85
  79. package/__tests__/engine/function/system/date/GetFullYearTest.ts +0 -85
  80. package/__tests__/engine/function/system/date/GetHoursTest.ts +0 -85
  81. package/__tests__/engine/function/system/date/GetMilliSecondsTest.ts +0 -85
  82. package/__tests__/engine/function/system/date/GetMinutesTest.ts +0 -85
  83. package/__tests__/engine/function/system/date/GetMonthTest.ts +0 -85
  84. package/__tests__/engine/function/system/date/GetSecondsTest.ts +0 -85
  85. package/__tests__/engine/function/system/date/GetTimeAsArrayTest.ts +0 -59
  86. package/__tests__/engine/function/system/date/GetTimeAsObjectTest.ts +0 -83
  87. package/__tests__/engine/function/system/date/GetTimeTest.ts +0 -86
  88. package/__tests__/engine/function/system/date/IsLeapYearTest.ts +0 -85
  89. package/__tests__/engine/function/system/date/MaximumTimestampTest.ts +0 -55
  90. package/__tests__/engine/function/system/date/MinimumTimestampTest.ts +0 -54
  91. package/__tests__/engine/function/system/date/SubtractTimeTest.ts +0 -95
  92. package/src/engine/function/system/date/DateToEpoch.ts +0 -39
  93. package/src/engine/function/system/date/DifferenceOfTimestamps.ts +0 -45
  94. package/src/engine/function/system/date/EpochToDate.ts +0 -76
  95. package/src/engine/function/system/date/GetCurrentTimeStamp.ts +0 -36
  96. package/src/engine/function/system/date/GetTimeAsArray.ts +0 -48
  97. package/src/engine/function/system/date/GetTimeAsObject.ts +0 -66
  98. package/src/engine/function/system/date/MaximumTimestamp.ts +0 -73
  99. package/src/engine/function/system/date/MinimumTimestamp.ts +0 -74
  100. package/src/engine/function/system/math/RandomFloat.ts +0 -56
  101. package/src/engine/function/system/math/RandomInt.ts +0 -56
@@ -1,73 +0,0 @@
1
- import { Schema } from "../../../json/schema/Schema";
2
- import { FunctionOutput } from "../../../model/FunctionOutput";
3
- import { FunctionSignature } from "../../../model/FunctionSignature";
4
- import { Parameter } from "../../../model/Parameter";
5
- import { Namespaces } from "../../../namespaces/Namespaces";
6
- import { FunctionExecutionParameters } from "../../../runtime/FunctionExecutionParameters";
7
- import { AbstractFunction } from "../../AbstractFunction";
8
- import { Event } from "../../../model/Event";
9
- import { KIRuntimeException } from "../../../exception/KIRuntimeException";
10
- import { ValidDateTimeUtil } from "../../../util/ValidDateTimeUtil";
11
- import { EventResult } from "../../../model/EventResult";
12
-
13
- const VALUE = "isoDates";
14
-
15
- const OUTPUT = "result";
16
-
17
- const ERROR_MESSAGE = "Please provide a valid date";
18
-
19
-
20
-
21
- const SIGNATURE : FunctionSignature = new FunctionSignature('MaximumTimestamp')
22
- .setNamespace(Namespaces.DATE)
23
- .setParameters(new Map([[VALUE, Parameter.of(VALUE, Schema.ofString(VALUE).setRef(Namespaces.DATE + ".timeStamp")).setVariableArgument(true)]]))
24
- .setEvents(new Map([[OUTPUT, new Event(OUTPUT, new Map([[OUTPUT, Schema.ofString(OUTPUT).setRef(Namespaces.DATE + ".timeStamp")]]))]]));
25
-
26
- export class MaximumTimestamp extends AbstractFunction {
27
-
28
- public getSignature(): FunctionSignature {
29
- return SIGNATURE;
30
- }
31
-
32
- protected async internalExecute(context: FunctionExecutionParameters): Promise<FunctionOutput> {
33
-
34
- const dates = context?.getArguments()?.get(VALUE);
35
-
36
- const size = dates.length;
37
-
38
- if(size === 0){
39
- throw new KIRuntimeException(ERROR_MESSAGE)
40
- }
41
-
42
- else if (size == 1) {
43
-
44
- const firstDate: string = dates[0];
45
-
46
- if (!ValidDateTimeUtil.validate(firstDate))
47
-
48
- throw new KIRuntimeException(ERROR_MESSAGE);
49
-
50
- return new FunctionOutput([EventResult.outputOf(new Map([[OUTPUT, firstDate]]))]);
51
- }
52
-
53
- let maxIndex: number = 0;
54
- let max : number = new Date(dates[0]).getTime();
55
-
56
- for(let i=1;i<size;i++){
57
-
58
- const date: string = dates[i];
59
-
60
- if(!ValidDateTimeUtil.validate(date))
61
- throw new KIRuntimeException(ERROR_MESSAGE);
62
-
63
- const current: number = new Date(date).getTime();
64
-
65
- if(current > max){
66
- max = current;
67
- maxIndex = i;
68
- }
69
- }
70
-
71
- return new FunctionOutput([EventResult.outputOf(new Map([[OUTPUT, dates[maxIndex]]]))]);
72
- }
73
- }
@@ -1,74 +0,0 @@
1
- import { KIRuntimeException } from "../../../exception/KIRuntimeException";
2
- import { Schema } from "../../../json/schema/Schema";
3
- import { FunctionOutput } from "../../../model/FunctionOutput";
4
- import { FunctionSignature } from "../../../model/FunctionSignature";
5
- import { Parameter } from "../../../model/Parameter";
6
- import { Namespaces } from "../../../namespaces/Namespaces";
7
- import { FunctionExecutionParameters } from "../../../runtime/FunctionExecutionParameters";
8
- import { ValidDateTimeUtil } from "../../../util/ValidDateTimeUtil";
9
- import { AbstractFunction } from "../../AbstractFunction";
10
- import { EventResult } from "../../../model/EventResult";
11
- import { Event } from "../../../model/Event";
12
-
13
-
14
-
15
- const VALUE: string = "isoDates";
16
-
17
- const OUTPUT: string = "result";
18
-
19
- const ERROR_MESSAGE: string = "Please provide a valid date";
20
-
21
- const SIGNATURE : FunctionSignature = new FunctionSignature('MinimumTimestamp')
22
- .setNamespace(Namespaces.DATE)
23
- .setParameters(new Map([[VALUE, Parameter.of(VALUE, Schema.ofString(VALUE).setRef(Namespaces.DATE + ".timeStamp")).setVariableArgument(true)]]))
24
- .setEvents(new Map([[OUTPUT , new Event(OUTPUT, new Map([[OUTPUT, Schema.ofString(OUTPUT).setRef(Namespaces.DATE + ".timeStamp")]]))]]));
25
-
26
- export class MinimumTimestamp extends AbstractFunction{
27
-
28
- public getSignature(): FunctionSignature {
29
- return SIGNATURE;
30
- }
31
-
32
- protected async internalExecute(context: FunctionExecutionParameters): Promise<FunctionOutput> {
33
-
34
- const dates = context?.getArguments()?.get(VALUE);
35
-
36
- const size = dates.length;
37
-
38
- if(size === 0){
39
- throw new KIRuntimeException(ERROR_MESSAGE)
40
- }
41
-
42
- else if (size == 1) {
43
-
44
- const firstDate: string = dates[0];
45
-
46
- if (!ValidDateTimeUtil.validate(firstDate))
47
-
48
- throw new KIRuntimeException(ERROR_MESSAGE);
49
-
50
- return new FunctionOutput([EventResult.outputOf(new Map([[OUTPUT, firstDate]]))]);
51
- }
52
-
53
- let minIndex: number = 0;
54
- let min : number = new Date(dates[0]).getTime();
55
-
56
- for(let i=1;i<size;i++){
57
-
58
- const date: string = dates[i];
59
-
60
- if(!ValidDateTimeUtil.validate(date))
61
- throw new KIRuntimeException(ERROR_MESSAGE);
62
-
63
- const current: number = new Date(date).getTime();
64
-
65
- if(current < min){
66
- min = current;
67
- minIndex = i;
68
- }
69
- }
70
-
71
- return new FunctionOutput([EventResult.outputOf(new Map([[OUTPUT, dates[minIndex]]]))]);
72
- }
73
-
74
- }
@@ -1,56 +0,0 @@
1
- import { Schema } from '../../../json/schema/Schema';
2
- import { Event } from '../../../model/Event';
3
- import { EventResult } from '../../../model/EventResult';
4
- import { FunctionOutput } from '../../../model/FunctionOutput';
5
- import { FunctionSignature } from '../../../model/FunctionSignature';
6
- import { Parameter } from '../../../model/Parameter';
7
- import { Namespaces } from '../../../namespaces/Namespaces';
8
- import { FunctionExecutionParameters } from '../../../runtime/FunctionExecutionParameters';
9
- import { MapUtil } from '../../../util/MapUtil';
10
- import { AbstractFunction } from '../../AbstractFunction';
11
-
12
- export class RandomFloat extends AbstractFunction {
13
- public static readonly MIN_VALUE = 'minValue';
14
-
15
- public static readonly MAX_VALUE = 'maxValue';
16
-
17
- public static readonly VALUE = 'value';
18
-
19
- private static readonly SIGNATURE: FunctionSignature = new FunctionSignature('RandomFloat')
20
- .setParameters(
21
- MapUtil.of(
22
- RandomFloat.MIN_VALUE,
23
- Parameter.of(
24
- RandomFloat.MIN_VALUE,
25
- Schema.ofFloat(RandomFloat.MIN_VALUE).setDefaultValue(0),
26
- ),
27
- RandomFloat.MAX_VALUE,
28
- Parameter.of(
29
- RandomFloat.MAX_VALUE,
30
- Schema.ofFloat(RandomFloat.MAX_VALUE).setDefaultValue(2147483647),
31
- ),
32
- ),
33
- )
34
- .setNamespace(Namespaces.MATH)
35
- .setEvents(
36
- new Map<string, Event>([
37
- Event.outputEventMapEntry(
38
- MapUtil.of(RandomFloat.VALUE, Schema.ofFloat(RandomFloat.VALUE)),
39
- ),
40
- ]),
41
- );
42
-
43
- public getSignature(): FunctionSignature {
44
- return RandomFloat.SIGNATURE;
45
- }
46
-
47
- protected async internalExecute(context: FunctionExecutionParameters): Promise<FunctionOutput> {
48
- let min: number = context.getArguments()?.get(RandomFloat.MIN_VALUE);
49
-
50
- let max: number = context.getArguments()?.get(RandomFloat.MAX_VALUE);
51
-
52
- let num: number = Math.random() * (max - min) + min;
53
-
54
- return new FunctionOutput([EventResult.outputOf(new Map([[RandomFloat.VALUE, num]]))]);
55
- }
56
- }
@@ -1,56 +0,0 @@
1
- import { Schema } from '../../../json/schema/Schema';
2
- import { Event } from '../../../model/Event';
3
- import { EventResult } from '../../../model/EventResult';
4
- import { FunctionOutput } from '../../../model/FunctionOutput';
5
- import { FunctionSignature } from '../../../model/FunctionSignature';
6
- import { Parameter } from '../../../model/Parameter';
7
- import { Namespaces } from '../../../namespaces/Namespaces';
8
- import { FunctionExecutionParameters } from '../../../runtime/FunctionExecutionParameters';
9
- import { MapUtil } from '../../../util/MapUtil';
10
- import { AbstractFunction } from '../../AbstractFunction';
11
-
12
- export class RandomInt extends AbstractFunction {
13
- public static readonly MIN_VALUE = 'minValue';
14
-
15
- public static readonly MAX_VALUE = 'maxValue';
16
-
17
- public static readonly VALUE = 'value';
18
-
19
- private static readonly SIGNATURE: FunctionSignature = new FunctionSignature('RandomInt')
20
- .setParameters(
21
- MapUtil.of(
22
- RandomInt.MIN_VALUE,
23
- Parameter.of(
24
- RandomInt.MIN_VALUE,
25
- Schema.ofInteger(RandomInt.MIN_VALUE).setDefaultValue(0),
26
- ),
27
- RandomInt.MAX_VALUE,
28
- Parameter.of(
29
- RandomInt.MAX_VALUE,
30
- Schema.ofInteger(RandomInt.MAX_VALUE).setDefaultValue(2147483647),
31
- ),
32
- ),
33
- )
34
- .setNamespace(Namespaces.MATH)
35
- .setEvents(
36
- new Map<string, Event>([
37
- Event.outputEventMapEntry(
38
- MapUtil.of(RandomInt.VALUE, Schema.ofInteger(RandomInt.VALUE)),
39
- ),
40
- ]),
41
- );
42
-
43
- public getSignature(): FunctionSignature {
44
- return RandomInt.SIGNATURE;
45
- }
46
-
47
- protected async internalExecute(context: FunctionExecutionParameters): Promise<FunctionOutput> {
48
- let min: number = context.getArguments()?.get(RandomInt.MIN_VALUE);
49
-
50
- let max: number = context.getArguments()?.get(RandomInt.MAX_VALUE);
51
-
52
- let num: number = Math.floor(Math.random() * (max - min) + min);
53
-
54
- return new FunctionOutput([EventResult.outputOf(new Map([[RandomInt.VALUE, num]]))]);
55
- }
56
- }