@fincity/kirun-js 2.3.2 → 2.4.0

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.
@@ -0,0 +1,115 @@
1
+ import { FunctionExecutionParameters, KIRunFunctionRepository, KIRunSchemaRepository, Namespaces } from "../../../../../src";
2
+ import { AbstractDateFunction } from "../../../../../src/engine/function/system/date/AbstractDateFunction";
3
+ import { DateFunctionRepository } from "../../../../../src/engine/function/system/date/DateFunctionRepository";
4
+
5
+
6
+ const dfr : DateFunctionRepository = new DateFunctionRepository();
7
+
8
+ const fep : FunctionExecutionParameters = new FunctionExecutionParameters(
9
+ new KIRunFunctionRepository(),
10
+ new KIRunSchemaRepository());
11
+
12
+ test('check for invalid dates', async () => {
13
+
14
+ const addTimeFunction = await dfr.find(Namespaces.DATE, 'AddTime');
15
+
16
+ if (!addTimeFunction) {
17
+ throw new Error("Function not found");
18
+ }
19
+
20
+ fep.setArguments(new Map<string, any>([
21
+ [AbstractDateFunction.PARAMETER_DATE_NAME, '2029-15-05T06:04:18.073Z'],
22
+ [AbstractDateFunction.PARAMETER_INT_NAME, 10],
23
+ [AbstractDateFunction.PARAMETER_UNIT_NAME, 'SECOND']
24
+ ]));
25
+
26
+ await expect( () => addTimeFunction.execute(fep)).rejects.toThrow();
27
+ });
28
+
29
+ test('Add Time 1', async () => {
30
+
31
+ const addTimeFunction = await dfr.find(Namespaces.DATE, 'AddTime');
32
+
33
+ if (!addTimeFunction) {
34
+ throw new Error("Function not found");
35
+ }
36
+
37
+ fep.setArguments(new Map<string, any>([
38
+ [AbstractDateFunction.PARAMETER_DATE_NAME, '2024-09-13T23:52:34.633-05:30'],
39
+ [AbstractDateFunction.PARAMETER_INT_NAME, 10],
40
+ [AbstractDateFunction.PARAMETER_UNIT_NAME, 'MINUTE']
41
+ ]));
42
+
43
+ expect((await addTimeFunction.execute(fep)).allResults()[0].getResult().get('result')).toBe('2024-09-14T00:02:34.633-05:30');
44
+ })
45
+
46
+ test('Add Time 2', async () => {
47
+
48
+ const addTimeFunction = await dfr.find(Namespaces.DATE, 'AddTime');
49
+
50
+ if (!addTimeFunction) {
51
+ throw new Error("Function not found");
52
+ }
53
+
54
+ fep.setArguments(new Map<string, any>([
55
+ [AbstractDateFunction.PARAMETER_DATE_NAME, '2024-09-13T23:52:34.633-05:30'],
56
+ [AbstractDateFunction.PARAMETER_INT_NAME, 13],
57
+ [AbstractDateFunction.PARAMETER_UNIT_NAME, 'MONTH']
58
+ ]));
59
+
60
+ expect((await addTimeFunction.execute(fep)).allResults()[0].getResult().get('result')).toBe('2025-10-13T23:52:34.633-05:30');
61
+ })
62
+
63
+
64
+ test('Add Time 2', async () => {
65
+
66
+ const addTimeFunction = await dfr.find(Namespaces.DATE, 'AddTime');
67
+
68
+ if (!addTimeFunction) {
69
+ throw new Error("Function not found");
70
+ }
71
+
72
+ fep.setArguments(new Map<string, any>([
73
+ [AbstractDateFunction.PARAMETER_DATE_NAME, '2024-09-13T23:52:34.633-05:30'],
74
+ [AbstractDateFunction.PARAMETER_INT_NAME, 3],
75
+ [AbstractDateFunction.PARAMETER_UNIT_NAME, 'MONTH']
76
+ ]));
77
+
78
+ expect((await addTimeFunction.execute(fep)).allResults()[0].getResult().get('result')).toBe('2024-12-13T23:52:34.633-05:30');
79
+ })
80
+
81
+ test('Add Time 3', async () => {
82
+
83
+ const addTimeFunction = await dfr.find(Namespaces.DATE, 'AddTime');
84
+
85
+ if (!addTimeFunction) {
86
+ throw new Error("Function not found");
87
+ }
88
+
89
+ fep.setArguments(new Map<string, any>([
90
+ [AbstractDateFunction.PARAMETER_DATE_NAME, '2024-09-13T23:52:34.633-05:30'],
91
+ [AbstractDateFunction.PARAMETER_INT_NAME, 10],
92
+ [AbstractDateFunction.PARAMETER_UNIT_NAME, 'SECOND']
93
+ ]));
94
+
95
+ expect((await addTimeFunction.execute(fep)).allResults()[0].getResult().get('result')).toBe('2024-09-13T23:52:44.633-05:30');
96
+
97
+ })
98
+
99
+
100
+ test('Add Time 4', async () => {
101
+
102
+ const addTimeFunction = await dfr.find(Namespaces.DATE, 'AddTime');
103
+
104
+ if (!addTimeFunction) {
105
+ throw new Error("Function not found");
106
+ }
107
+
108
+ fep.setArguments(new Map<string, any>([
109
+ [AbstractDateFunction.PARAMETER_DATE_NAME, '2024-09-13T23:52:34.633-05:30'],
110
+ [AbstractDateFunction.PARAMETER_INT_NAME, 5],
111
+ [AbstractDateFunction.PARAMETER_UNIT_NAME, 'YEAR']
112
+ ]));
113
+
114
+ expect((await addTimeFunction.execute(fep)).allResults()[0].getResult().get('result')).toBe('2029-09-13T23:52:34.633-05:30');
115
+ })
@@ -49,7 +49,7 @@ test('fetching for valid date' , async () => {
49
49
  fep.setArguments(new Map([[AbstractDateFunction.PARAMETER_DATE_NAME, '2024-09-01T23:52:34.633-05:30' ]]));
50
50
 
51
51
 
52
- expect( (await getMonthFunction.execute(fep)).allResults()[0].getResult().get(AbstractDateFunction.EVENT_RESULT_NAME)).toBe(9);
52
+ expect( (await getMonthFunction.execute(fep)).allResults()[0].getResult().get(AbstractDateFunction.EVENT_RESULT_NAME)).toBe(8);
53
53
 
54
54
  })
55
55
 
@@ -64,7 +64,7 @@ test('fetching for valid date' , async () => {
64
64
  fep.setArguments(new Map([[AbstractDateFunction.PARAMETER_DATE_NAME, '2019-11-13T23:52:34.633Z' ]]));
65
65
 
66
66
 
67
- expect( (await getMonthFunction.execute(fep)).allResults()[0].getResult().get(AbstractDateFunction.EVENT_RESULT_NAME)).toBe(11);
67
+ expect( (await getMonthFunction.execute(fep)).allResults()[0].getResult().get(AbstractDateFunction.EVENT_RESULT_NAME)).toBe(10);
68
68
 
69
69
  })
70
70
 
@@ -80,6 +80,6 @@ test('fetching for valid date' , async () => {
80
80
  fep.setArguments(new Map([[AbstractDateFunction.PARAMETER_DATE_NAME, '2023-12-31T07:35:17.000-12:00' ]]));
81
81
 
82
82
 
83
- expect( (await getMonthFunction.execute(fep)).allResults()[0].getResult().get(AbstractDateFunction.EVENT_RESULT_NAME)).toBe(12);
83
+ expect( (await getMonthFunction.execute(fep)).allResults()[0].getResult().get(AbstractDateFunction.EVENT_RESULT_NAME)).toBe(11);
84
84
 
85
85
  })
@@ -0,0 +1,95 @@
1
+ import { FunctionExecutionParameters, KIRunFunctionRepository, KIRunSchemaRepository, Namespaces } from "../../../../../src";
2
+ import { AbstractDateFunction } from "../../../../../src/engine/function/system/date/AbstractDateFunction";
3
+ import { DateFunctionRepository } from "../../../../../src/engine/function/system/date/DateFunctionRepository";
4
+
5
+
6
+ const dfr : DateFunctionRepository = new DateFunctionRepository();
7
+
8
+ const fep : FunctionExecutionParameters = new FunctionExecutionParameters(
9
+ new KIRunFunctionRepository(),
10
+ new KIRunSchemaRepository());
11
+
12
+ test('check for invalid dates', async () => {
13
+
14
+ const subtractTimeFunction = await dfr.find(Namespaces.DATE, 'SubtractTime');
15
+
16
+ if (!subtractTimeFunction) {
17
+ throw new Error("Function not found");
18
+ }
19
+
20
+ fep.setArguments(new Map<string, any>([
21
+ [AbstractDateFunction.PARAMETER_DATE_NAME, '2029-15-05T06:04:18.073Z'],
22
+ [AbstractDateFunction.PARAMETER_INT_NAME, 10],
23
+ [AbstractDateFunction.PARAMETER_UNIT_NAME, 'SECOND']
24
+ ]));
25
+
26
+ await expect( () => subtractTimeFunction.execute(fep)).rejects.toThrow();
27
+ });
28
+
29
+ test('Subtract Time 1', async () => {
30
+
31
+ const subtractTimeFunction = await dfr.find(Namespaces.DATE, 'SubtractTime');
32
+
33
+ if (!subtractTimeFunction) {
34
+ throw new Error("Function not found");
35
+ }
36
+
37
+ fep.setArguments(new Map<string, any>([
38
+ [AbstractDateFunction.PARAMETER_DATE_NAME, '2024-09-13T23:52:34.633-05:30'],
39
+ [AbstractDateFunction.PARAMETER_INT_NAME, 10],
40
+ [AbstractDateFunction.PARAMETER_UNIT_NAME, 'MINUTE']
41
+ ]));
42
+
43
+ expect((await subtractTimeFunction.execute(fep)).allResults()[0].getResult().get('result')).toBe('2024-09-13T23:42:34.633-05:30');
44
+ });
45
+
46
+ test('Subtract Time 2', async () => {
47
+
48
+ const subtractTimeFunction = await dfr.find(Namespaces.DATE, 'SubtractTime');
49
+
50
+ if (!subtractTimeFunction) {
51
+ throw new Error("Function not found");
52
+ }
53
+
54
+ fep.setArguments(new Map<string, any>([
55
+ [AbstractDateFunction.PARAMETER_DATE_NAME, '2024-09-13T23:52:34.633-05:30'],
56
+ [AbstractDateFunction.PARAMETER_INT_NAME, 13],
57
+ [AbstractDateFunction.PARAMETER_UNIT_NAME, 'MONTH']
58
+ ]));
59
+
60
+ expect((await subtractTimeFunction.execute(fep)).allResults()[0].getResult().get('result')).toBe('2023-08-13T23:52:34.633-05:30');
61
+ });
62
+
63
+ test('Subtract Time 3', async () => {
64
+
65
+ const subtractTimeFunction = await dfr.find(Namespaces.DATE, 'SubtractTime');
66
+
67
+ if (!subtractTimeFunction) {
68
+ throw new Error("Function not found");
69
+ }
70
+
71
+ fep.setArguments(new Map<string, any>([
72
+ [AbstractDateFunction.PARAMETER_DATE_NAME, '2024-09-13T23:52:34.633-05:30'],
73
+ [AbstractDateFunction.PARAMETER_INT_NAME, 70],
74
+ [AbstractDateFunction.PARAMETER_UNIT_NAME, 'SECOND']
75
+ ]));
76
+
77
+ expect((await subtractTimeFunction.execute(fep)).allResults()[0].getResult().get('result')).toBe('2024-09-13T23:51:24.633-05:30');
78
+ });
79
+
80
+ test('Subtract Time 4', async () => {
81
+
82
+ const subtractTimeFunction = await dfr.find(Namespaces.DATE, 'SubtractTime');
83
+
84
+ if (!subtractTimeFunction) {
85
+ throw new Error("Function not found");
86
+ }
87
+
88
+ fep.setArguments(new Map<string, any>([
89
+ [AbstractDateFunction.PARAMETER_DATE_NAME, '2024-09-13T23:52:34.633-05:30'],
90
+ [AbstractDateFunction.PARAMETER_INT_NAME, 5],
91
+ [AbstractDateFunction.PARAMETER_UNIT_NAME, 'YEAR']
92
+ ]));
93
+
94
+ expect((await subtractTimeFunction.execute(fep)).allResults()[0].getResult().get('result')).toBe('2019-09-13T23:52:34.633-05:30');
95
+ });
@@ -23,7 +23,11 @@ test('Repository Filter Test', async () => {
23
23
 
24
24
  expect(await schemaRepo.filter('ny')).toStrictEqual(['System.any']);
25
25
 
26
- expect(await schemaRepo.filter('')).toStrictEqual([
26
+ expect((await schemaRepo.filter('')).sort()).toStrictEqual([
27
+ 'System.Date.timeStamp',
28
+ 'System.Null',
29
+ 'System.ParameterExpression',
30
+ 'System.Schema',
27
31
  'System.any',
28
32
  'System.boolean',
29
33
  'System.double',
@@ -32,8 +36,5 @@ test('Repository Filter Test', async () => {
32
36
  'System.long',
33
37
  'System.number',
34
38
  'System.string',
35
- 'System.ParameterExpression',
36
- 'System.Null',
37
- 'System.Schema',
38
39
  ]);
39
40
  });