@fincity/kirun-js 2.8.5 → 2.9.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.
- package/__tests__/engine/function/system/date/FromDateStringTest.ts +9 -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 +3 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/engine/function/system/GenerateEvent.ts +23 -21
- package/src/engine/function/system/If.ts +2 -3
- package/src/engine/function/system/Print.ts +2 -3
- package/src/engine/function/system/Wait.ts +2 -3
- package/src/engine/function/system/array/ArrayFunctionRepository.ts +7 -9
- package/src/engine/function/system/array/Join.ts +29 -28
- package/src/engine/function/system/context/Create.ts +20 -22
- package/src/engine/function/system/context/Get.ts +19 -19
- package/src/engine/function/system/context/SetFunction.ts +17 -14
- package/src/engine/function/system/date/DateFunctionRepository.ts +6 -8
- package/src/engine/function/system/date/EpochToTimestamp.ts +1 -1
- package/src/engine/function/system/date/IsValidISODate.ts +4 -6
- package/src/engine/function/system/loop/Break.ts +7 -7
- package/src/engine/function/system/loop/CountLoop.ts +13 -14
- package/src/engine/function/system/loop/ForEachLoop.ts +18 -19
- package/src/engine/function/system/loop/RangeLoop.ts +68 -69
- package/src/engine/function/system/math/Add.ts +11 -9
- package/src/engine/function/system/math/GenericMathFunction.ts +13 -13
- package/src/engine/function/system/math/Hypotenuse.ts +2 -2
- package/src/engine/function/system/math/MathFunctionRepository.ts +107 -90
- package/src/engine/function/system/math/Maximum.ts +12 -11
- package/src/engine/function/system/math/Minimum.ts +12 -11
- package/src/engine/function/system/math/Random.ts +2 -2
- package/src/engine/function/system/object/AbstractObjectFunction.ts +1 -2
- package/src/engine/function/system/object/ObjectConvert.ts +26 -26
- package/src/engine/function/system/object/ObjectDeleteKey.ts +1 -2
- package/src/engine/function/system/object/ObjectFunctionRepository.ts +18 -14
- package/src/engine/function/system/string/Concatenate.ts +8 -7
- package/src/engine/function/system/string/Matches.ts +2 -2
- package/src/engine/function/system/string/Reverse.ts +2 -2
- package/src/engine/function/system/string/Split.ts +16 -15
- package/src/engine/function/system/string/StringFunctionRepository.ts +6 -8
- package/src/engine/function/system/string/ToString.ts +9 -8
- package/src/engine/json/schema/Schema.ts +17 -0
- package/src/engine/repository/KIRunFunctionRepository.ts +47 -39
- package/src/engine/repository/KIRunSchemaRepository.ts +75 -70
- package/src/engine/util/duplicate.ts +1 -1
- package/tsconfig.json +4 -2
|
@@ -205,6 +205,7 @@ export class Schema {
|
|
|
205
205
|
],
|
|
206
206
|
|
|
207
207
|
['permission', Schema.ofString('permission')],
|
|
208
|
+
['details', Schema.ofObject('details')],
|
|
208
209
|
]),
|
|
209
210
|
)
|
|
210
211
|
.setRequired([]);
|
|
@@ -386,6 +387,8 @@ export class Schema {
|
|
|
386
387
|
schema.$defs = Schema.fromMapOfSchemas(obj.$defs);
|
|
387
388
|
schema.permission = obj.permission;
|
|
388
389
|
|
|
390
|
+
schema.details = obj.details ? new Map(Object.entries(obj.details)) : undefined;
|
|
391
|
+
|
|
389
392
|
return schema;
|
|
390
393
|
}
|
|
391
394
|
|
|
@@ -444,6 +447,8 @@ export class Schema {
|
|
|
444
447
|
private $defs?: Map<string, Schema>;
|
|
445
448
|
private permission?: string;
|
|
446
449
|
|
|
450
|
+
private details?: Map<string, any>;
|
|
451
|
+
|
|
447
452
|
public constructor(schema?: Schema) {
|
|
448
453
|
if (!schema) return;
|
|
449
454
|
|
|
@@ -528,6 +533,9 @@ export class Schema {
|
|
|
528
533
|
: undefined;
|
|
529
534
|
|
|
530
535
|
this.permission = schema.permission;
|
|
536
|
+
this.details = schema.details
|
|
537
|
+
? new Map(JSON.parse(JSON.stringify(Array.from(schema.details.values()))))
|
|
538
|
+
: undefined;
|
|
531
539
|
}
|
|
532
540
|
|
|
533
541
|
public getTitle(): string | undefined {
|
|
@@ -837,4 +845,13 @@ export class Schema {
|
|
|
837
845
|
this.permission = permission;
|
|
838
846
|
return this;
|
|
839
847
|
}
|
|
848
|
+
|
|
849
|
+
public getDetails(): Map<string, any> | undefined {
|
|
850
|
+
return this.details;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
public setDetails(details: Map<string, any>): Schema {
|
|
854
|
+
this.details = details;
|
|
855
|
+
return this;
|
|
856
|
+
}
|
|
840
857
|
}
|
|
@@ -19,51 +19,59 @@ import { Wait } from '../function/system/Wait';
|
|
|
19
19
|
import { HybridRepository } from '../HybridRepository';
|
|
20
20
|
import { Namespaces } from '../namespaces/Namespaces';
|
|
21
21
|
import mapEntry from '../util/mapEntry';
|
|
22
|
+
import { Repository } from '../Repository';
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
new Map([mapEntry(new Create()), mapEntry(new Get()), mapEntry(new SetFunction())]),
|
|
27
|
-
],
|
|
28
|
-
[
|
|
29
|
-
Namespaces.SYSTEM_LOOP,
|
|
30
|
-
new Map([
|
|
31
|
-
mapEntry(new RangeLoop()),
|
|
32
|
-
mapEntry(new CountLoop()),
|
|
33
|
-
mapEntry(new Break()),
|
|
34
|
-
mapEntry(new ForEachLoop()),
|
|
35
|
-
]),
|
|
36
|
-
],
|
|
37
|
-
[
|
|
38
|
-
Namespaces.SYSTEM,
|
|
39
|
-
new Map([
|
|
40
|
-
mapEntry(new If()),
|
|
41
|
-
mapEntry(new GenerateEvent()),
|
|
42
|
-
mapEntry(new Print()),
|
|
43
|
-
mapEntry(new Wait()),
|
|
44
|
-
mapEntry(new Join()),
|
|
45
|
-
]),
|
|
46
|
-
],
|
|
47
|
-
]);
|
|
24
|
+
class SystemFunctionRepository implements Repository<Function> {
|
|
25
|
+
private readonly map: Map<string, Map<string, Function>>;
|
|
26
|
+
private readonly filterableNames: string[];
|
|
48
27
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
28
|
+
public constructor() {
|
|
29
|
+
this.map = new Map([
|
|
30
|
+
[
|
|
31
|
+
Namespaces.SYSTEM_CTX,
|
|
32
|
+
new Map([mapEntry(new Create()), mapEntry(new Get()), mapEntry(new SetFunction())]),
|
|
33
|
+
],
|
|
34
|
+
[
|
|
35
|
+
Namespaces.SYSTEM_LOOP,
|
|
36
|
+
new Map([
|
|
37
|
+
mapEntry(new RangeLoop()),
|
|
38
|
+
mapEntry(new CountLoop()),
|
|
39
|
+
mapEntry(new Break()),
|
|
40
|
+
mapEntry(new ForEachLoop()),
|
|
41
|
+
]),
|
|
42
|
+
],
|
|
43
|
+
[
|
|
44
|
+
Namespaces.SYSTEM,
|
|
45
|
+
new Map([
|
|
46
|
+
mapEntry(new If()),
|
|
47
|
+
mapEntry(new GenerateEvent()),
|
|
48
|
+
mapEntry(new Print()),
|
|
49
|
+
mapEntry(new Wait()),
|
|
50
|
+
mapEntry(new Join()),
|
|
51
|
+
]),
|
|
52
|
+
],
|
|
53
|
+
]);
|
|
54
|
+
|
|
55
|
+
this.filterableNames = Array.from(this.map.values())
|
|
56
|
+
.flatMap((e) => Array.from(e.values()))
|
|
57
|
+
.map((e) => e.getSignature().getFullName());
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async find(namespace: string, name: string): Promise<Function | undefined> {
|
|
61
|
+
return this.map.get(namespace)?.get(name);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async filter(name: string): Promise<string[]> {
|
|
65
|
+
return Array.from(this.filterableNames).filter(
|
|
66
|
+
(e) => e.toLowerCase().indexOf(name.toLowerCase()) !== -1,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
52
70
|
|
|
53
71
|
export class KIRunFunctionRepository extends HybridRepository<Function> {
|
|
54
72
|
public constructor() {
|
|
55
73
|
super(
|
|
56
|
-
|
|
57
|
-
async find(namespace: string, name: string): Promise<Function | undefined> {
|
|
58
|
-
return map.get(namespace)?.get(name);
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
async filter(name: string): Promise<string[]> {
|
|
62
|
-
return Array.from(filterableNames).filter(
|
|
63
|
-
(e) => e.toLowerCase().indexOf(name.toLowerCase()) !== -1,
|
|
64
|
-
);
|
|
65
|
-
},
|
|
66
|
-
},
|
|
74
|
+
new SystemFunctionRepository(),
|
|
67
75
|
new MathFunctionRepository(),
|
|
68
76
|
new StringFunctionRepository(),
|
|
69
77
|
new ArrayFunctionRepository(),
|
|
@@ -4,86 +4,91 @@ import { Namespaces } from '../namespaces/Namespaces';
|
|
|
4
4
|
import { Repository } from '../Repository';
|
|
5
5
|
import { MapUtil } from '../util/MapUtil';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
[
|
|
10
|
-
['double', Schema.ofDouble('double').setNamespace(Namespaces.SYSTEM)],
|
|
11
|
-
['float', Schema.ofFloat('float').setNamespace(Namespaces.SYSTEM)],
|
|
12
|
-
['integer', Schema.ofInteger('integer').setNamespace(Namespaces.SYSTEM)],
|
|
13
|
-
['long', Schema.ofLong('long').setNamespace(Namespaces.SYSTEM)],
|
|
14
|
-
['number', Schema.ofNumber('number').setNamespace(Namespaces.SYSTEM)],
|
|
15
|
-
['string', Schema.ofString('string').setNamespace(Namespaces.SYSTEM)],
|
|
16
|
-
['Timestamp', Schema.ofString('Timestamp').setNamespace(Namespaces.DATE)],
|
|
17
|
-
[
|
|
18
|
-
'Timeunit',
|
|
19
|
-
Schema.ofString('Timeunit')
|
|
20
|
-
.setNamespace(Namespaces.DATE)
|
|
21
|
-
.setEnums([
|
|
22
|
-
'YEARS',
|
|
23
|
-
'QUARTERS',
|
|
24
|
-
'MONTHS',
|
|
25
|
-
'WEEKS',
|
|
26
|
-
'DAYS',
|
|
27
|
-
'HOURS',
|
|
28
|
-
'MINUTES',
|
|
29
|
-
'SECONDS',
|
|
30
|
-
'MILLISECONDS',
|
|
31
|
-
]),
|
|
32
|
-
],
|
|
33
|
-
[
|
|
34
|
-
'Duration',
|
|
35
|
-
Schema.ofObject('Duration')
|
|
36
|
-
.setNamespace(Namespaces.DATE)
|
|
37
|
-
.setProperties(
|
|
38
|
-
MapUtil.ofArrayEntries(
|
|
39
|
-
['years', Schema.ofNumber('years')],
|
|
40
|
-
['quarters', Schema.ofNumber('quarters')],
|
|
41
|
-
['months', Schema.ofNumber('months')],
|
|
42
|
-
['weeks', Schema.ofNumber('weeks')],
|
|
43
|
-
['days', Schema.ofNumber('days')],
|
|
44
|
-
['hours', Schema.ofNumber('hours')],
|
|
45
|
-
['minutes', Schema.ofNumber('minutes')],
|
|
46
|
-
['seconds', Schema.ofNumber('seconds')],
|
|
47
|
-
['milliseconds', Schema.ofNumber('milliseconds')],
|
|
48
|
-
),
|
|
49
|
-
)
|
|
50
|
-
.setAdditionalItems(AdditionalType.from(false)!),
|
|
51
|
-
],
|
|
52
|
-
[
|
|
53
|
-
'TimeObject',
|
|
54
|
-
Schema.ofObject('TimeObject')
|
|
55
|
-
.setNamespace(Namespaces.DATE)
|
|
56
|
-
.setProperties(
|
|
57
|
-
MapUtil.ofArrayEntries(
|
|
58
|
-
['year', Schema.ofNumber('year')],
|
|
59
|
-
['month', Schema.ofNumber('month')],
|
|
60
|
-
['day', Schema.ofNumber('day')],
|
|
61
|
-
['hour', Schema.ofNumber('hour')],
|
|
62
|
-
['minute', Schema.ofNumber('minute')],
|
|
63
|
-
['second', Schema.ofNumber('second')],
|
|
64
|
-
['millisecond', Schema.ofNumber('millisecond')],
|
|
65
|
-
),
|
|
66
|
-
)
|
|
67
|
-
.setAdditionalItems(AdditionalType.from(false)!),
|
|
68
|
-
],
|
|
69
|
-
[Parameter.EXPRESSION.getName()!, Parameter.EXPRESSION],
|
|
70
|
-
[Schema.NULL.getName()!, Schema.NULL],
|
|
71
|
-
[Schema.SCHEMA.getName()!, Schema.SCHEMA],
|
|
72
|
-
]);
|
|
7
|
+
export class KIRunSchemaRepository implements Repository<Schema> {
|
|
8
|
+
private readonly map: Map<string, Schema>;
|
|
9
|
+
private readonly filterableNames: string[];
|
|
73
10
|
|
|
74
|
-
|
|
11
|
+
public constructor() {
|
|
12
|
+
this.map = new Map([
|
|
13
|
+
['any', Schema.ofAny('any').setNamespace(Namespaces.SYSTEM)],
|
|
14
|
+
['boolean', Schema.ofBoolean('boolean').setNamespace(Namespaces.SYSTEM)],
|
|
15
|
+
['double', Schema.ofDouble('double').setNamespace(Namespaces.SYSTEM)],
|
|
16
|
+
['float', Schema.ofFloat('float').setNamespace(Namespaces.SYSTEM)],
|
|
17
|
+
['integer', Schema.ofInteger('integer').setNamespace(Namespaces.SYSTEM)],
|
|
18
|
+
['long', Schema.ofLong('long').setNamespace(Namespaces.SYSTEM)],
|
|
19
|
+
['number', Schema.ofNumber('number').setNamespace(Namespaces.SYSTEM)],
|
|
20
|
+
['string', Schema.ofString('string').setNamespace(Namespaces.SYSTEM)],
|
|
21
|
+
['Timestamp', Schema.ofString('Timestamp').setNamespace(Namespaces.DATE)],
|
|
22
|
+
[
|
|
23
|
+
'Timeunit',
|
|
24
|
+
Schema.ofString('Timeunit')
|
|
25
|
+
.setNamespace(Namespaces.DATE)
|
|
26
|
+
.setEnums([
|
|
27
|
+
'YEARS',
|
|
28
|
+
'QUARTERS',
|
|
29
|
+
'MONTHS',
|
|
30
|
+
'WEEKS',
|
|
31
|
+
'DAYS',
|
|
32
|
+
'HOURS',
|
|
33
|
+
'MINUTES',
|
|
34
|
+
'SECONDS',
|
|
35
|
+
'MILLISECONDS',
|
|
36
|
+
]),
|
|
37
|
+
],
|
|
38
|
+
[
|
|
39
|
+
'Duration',
|
|
40
|
+
Schema.ofObject('Duration')
|
|
41
|
+
.setNamespace(Namespaces.DATE)
|
|
42
|
+
.setProperties(
|
|
43
|
+
MapUtil.ofArrayEntries(
|
|
44
|
+
['years', Schema.ofNumber('years')],
|
|
45
|
+
['quarters', Schema.ofNumber('quarters')],
|
|
46
|
+
['months', Schema.ofNumber('months')],
|
|
47
|
+
['weeks', Schema.ofNumber('weeks')],
|
|
48
|
+
['days', Schema.ofNumber('days')],
|
|
49
|
+
['hours', Schema.ofNumber('hours')],
|
|
50
|
+
['minutes', Schema.ofNumber('minutes')],
|
|
51
|
+
['seconds', Schema.ofNumber('seconds')],
|
|
52
|
+
['milliseconds', Schema.ofNumber('milliseconds')],
|
|
53
|
+
),
|
|
54
|
+
)
|
|
55
|
+
.setAdditionalItems(AdditionalType.from(false)!),
|
|
56
|
+
],
|
|
57
|
+
[
|
|
58
|
+
'TimeObject',
|
|
59
|
+
Schema.ofObject('TimeObject')
|
|
60
|
+
.setNamespace(Namespaces.DATE)
|
|
61
|
+
.setProperties(
|
|
62
|
+
MapUtil.ofArrayEntries(
|
|
63
|
+
['year', Schema.ofNumber('year')],
|
|
64
|
+
['month', Schema.ofNumber('month')],
|
|
65
|
+
['day', Schema.ofNumber('day')],
|
|
66
|
+
['hour', Schema.ofNumber('hour')],
|
|
67
|
+
['minute', Schema.ofNumber('minute')],
|
|
68
|
+
['second', Schema.ofNumber('second')],
|
|
69
|
+
['millisecond', Schema.ofNumber('millisecond')],
|
|
70
|
+
),
|
|
71
|
+
)
|
|
72
|
+
.setAdditionalItems(AdditionalType.from(false)!),
|
|
73
|
+
],
|
|
74
|
+
[Parameter.EXPRESSION.getName()!, Parameter.EXPRESSION],
|
|
75
|
+
[Schema.NULL.getName()!, Schema.NULL],
|
|
76
|
+
[Schema.SCHEMA.getName()!, Schema.SCHEMA],
|
|
77
|
+
]);
|
|
78
|
+
|
|
79
|
+
this.filterableNames = Array.from(this.map.values()).map((e) => e.getFullName());
|
|
80
|
+
}
|
|
75
81
|
|
|
76
|
-
export class KIRunSchemaRepository implements Repository<Schema> {
|
|
77
82
|
public async find(namespace: string, name: string): Promise<Schema | undefined> {
|
|
78
83
|
if (Namespaces.SYSTEM != namespace && Namespaces.DATE != namespace)
|
|
79
84
|
return Promise.resolve(undefined);
|
|
80
85
|
|
|
81
|
-
return Promise.resolve(map.get(name));
|
|
86
|
+
return Promise.resolve(this.map.get(name));
|
|
82
87
|
}
|
|
83
88
|
|
|
84
89
|
public async filter(name: string): Promise<string[]> {
|
|
85
90
|
return Promise.resolve(
|
|
86
|
-
filterableNames.filter((e) => e.toLowerCase().indexOf(name.toLowerCase()) !== -1),
|
|
91
|
+
this.filterableNames.filter((e) => e.toLowerCase().indexOf(name.toLowerCase()) !== -1),
|
|
87
92
|
);
|
|
88
93
|
}
|
|
89
94
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export function duplicate(obj: any): any {
|
|
2
2
|
if (!obj) return obj;
|
|
3
|
-
if (globalThis.structuredClone) return globalThis.structuredClone(obj);
|
|
3
|
+
if (typeof globalThis.structuredClone === 'function') return globalThis.structuredClone(obj);
|
|
4
4
|
return JSON.parse(JSON.stringify(obj));
|
|
5
5
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"module": "
|
|
3
|
+
"module": "ESNext",
|
|
4
|
+
"target": "ESNext",
|
|
4
5
|
"strict": true,
|
|
5
6
|
"esModuleInterop": true,
|
|
6
7
|
"skipLibCheck": true,
|
|
7
8
|
"forceConsistentCasingInFileNames": true,
|
|
8
|
-
"lib": ["ES2022"]
|
|
9
|
+
"lib": ["ES2022"],
|
|
10
|
+
"moduleResolution": "node"
|
|
9
11
|
}
|
|
10
12
|
}
|