@fincity/kirun-js 1.9.1 → 2.0.1

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 (53) hide show
  1. package/__tests__/engine/function/system/math/MathFunctionRepositoryTest.ts +118 -75
  2. package/__tests__/engine/function/system/string/StringFunctionRepoTest2.ts +3 -3
  3. package/__tests__/engine/function/system/string/StringFunctionRepoTest3.ts +2 -2
  4. package/__tests__/engine/function/system/string/StringFunctionRepositoryTest.ts +8 -8
  5. package/__tests__/engine/json/schema/SchemaUtil.ts +1 -1
  6. package/__tests__/engine/json/schema/type/TypeUtilTest.ts +1 -1
  7. package/__tests__/engine/json/schema/validator/AnyOfAllOfOneOfValidatorTest.ts +24 -19
  8. package/__tests__/engine/json/schema/validator/ArrayContainsValidatorTest.ts +22 -22
  9. package/__tests__/engine/json/schema/validator/ArraySchemaAdapterTypeTest.ts +10 -10
  10. package/__tests__/engine/json/schema/validator/ArraySchemaTypeTest.ts +22 -22
  11. package/__tests__/engine/json/schema/validator/ArrayValidatorTest.ts +13 -13
  12. package/__tests__/engine/json/schema/validator/NotValidatorTest.ts +10 -9
  13. package/__tests__/engine/json/schema/validator/NullValidatorTest.ts +6 -6
  14. package/__tests__/engine/json/schema/validator/ObjectPropertiesTest.ts +4 -4
  15. package/__tests__/engine/json/schema/validator/ObjectValidatorTest.ts +32 -28
  16. package/__tests__/engine/json/schema/validator/SchemaAnyOfValidatorTest.ts +184 -182
  17. package/__tests__/engine/json/schema/validator/SchemaValidatorTest.ts +43 -32
  18. package/__tests__/engine/json/schema/validator/StringFormatSchemaValidatorTest.ts +24 -24
  19. package/__tests__/engine/json/schema/validator/StringValidatorTest.ts +14 -14
  20. package/__tests__/engine/repository/KIRunFunctionRepositoryTest.ts +7 -7
  21. package/__tests__/engine/repository/RepositoryFilterTest.ts +7 -7
  22. package/__tests__/engine/runtime/KIRuntimeFunctionInFunction.ts +11 -7
  23. package/__tests__/engine/runtime/KIRuntimeNoParamMapTest.ts +2 -2
  24. package/__tests__/engine/runtime/KIRuntimeNoValuesTest.ts +2 -2
  25. package/__tests__/engine/runtime/KIRuntimeTest.ts +8 -6
  26. package/__tests__/engine/runtime/KIRuntimeTestWithoutGenEvent.ts +4 -1
  27. package/__tests__/engine/runtime/KIRuntimeUndefinedParamTest.ts +23 -26
  28. package/__tests__/engine/runtime/KIRuntimeValuesEmptyTest.ts +6 -6
  29. package/__tests__/indexTest.ts +10 -10
  30. package/dist/index.js +1 -1
  31. package/dist/index.js.map +1 -1
  32. package/dist/module.js +1 -1
  33. package/dist/module.js.map +1 -1
  34. package/dist/types.d.ts +17 -17
  35. package/dist/types.d.ts.map +1 -1
  36. package/package.json +4 -4
  37. package/src/engine/HybridRepository.ts +5 -5
  38. package/src/engine/Repository.ts +2 -2
  39. package/src/engine/function/AbstractFunction.ts +35 -31
  40. package/src/engine/function/system/array/ArrayFunctionRepository.ts +8 -6
  41. package/src/engine/function/system/math/MathFunctionRepository.ts +7 -5
  42. package/src/engine/function/system/object/ObjectFunctionRepository.ts +7 -5
  43. package/src/engine/function/system/string/StringFunctionRepository.ts +8 -6
  44. package/src/engine/json/schema/SchemaUtil.ts +33 -30
  45. package/src/engine/json/schema/validator/ArrayValidator.ts +25 -20
  46. package/src/engine/json/schema/validator/ObjectValidator.ts +32 -14
  47. package/src/engine/json/schema/validator/SchemaValidator.ts +15 -11
  48. package/src/engine/json/schema/validator/TypeValidator.ts +5 -5
  49. package/src/engine/repository/KIRunFunctionRepository.ts +3 -2
  50. package/src/engine/repository/KIRunSchemaRepository.ts +7 -5
  51. package/src/engine/runtime/KIRuntime.ts +14 -14
  52. package/src/engine/util/duplicate.ts +1 -1
  53. package/tsconfig.json +6 -2
@@ -73,7 +73,7 @@ export class KIRuntime extends AbstractFunction {
73
73
  ): Promise<ExecutionGraph<string, StatementExecution>> {
74
74
  let g: ExecutionGraph<string, StatementExecution> = new ExecutionGraph();
75
75
  for (let s of Array.from(this.fd.getSteps().values()))
76
- g.addVertex(this.prepareStatementExecution(s, fRepo, sRepo));
76
+ g.addVertex(await this.prepareStatementExecution(s, fRepo, sRepo));
77
77
 
78
78
  let unresolved = this.makeEdges(g);
79
79
 
@@ -314,7 +314,7 @@ export class KIRuntime extends AbstractFunction {
314
314
  if (!allTrue) return;
315
315
  }
316
316
 
317
- let fun: Function | undefined = fRepo.find(s.getNamespace(), s.getName());
317
+ let fun: Function | undefined = await fRepo.find(s.getNamespace(), s.getName());
318
318
 
319
319
  if (!fun) {
320
320
  throw new KIRuntimeException(
@@ -550,25 +550,25 @@ export class KIRuntime extends AbstractFunction {
550
550
  return ret;
551
551
  }
552
552
 
553
- private prepareStatementExecution(
553
+ private async prepareStatementExecution(
554
554
  s: Statement,
555
555
  fRepo: Repository<Function>,
556
556
  sRepo: Repository<Schema>,
557
- ): StatementExecution {
557
+ ): Promise<StatementExecution> {
558
558
  let se: StatementExecution = new StatementExecution(s);
559
559
 
560
- let fun: Function | undefined = fRepo.find(s.getNamespace(), s.getName());
560
+ let fun: Function | undefined = await fRepo.find(s.getNamespace(), s.getName());
561
561
 
562
562
  if (!fun) {
563
563
  se.addMessage(
564
564
  StatementMessageType.ERROR,
565
565
  StringFormatter.format('$.$ is not available', s.getNamespace(), s.getName()),
566
566
  );
567
- return se;
567
+ return Promise.resolve(se);
568
568
  }
569
569
 
570
570
  let paramSet: Map<string, Parameter> = new Map(fun.getSignature().getParameters());
571
- if (!s.getParameterMap()) return se;
571
+ if (!s.getParameterMap()) return Promise.resolve(se);
572
572
  for (let param of Array.from(s.getParameterMap().entries())) {
573
573
  let p: Parameter | undefined = paramSet.get(param[0]);
574
574
  if (!p) continue;
@@ -576,7 +576,7 @@ export class KIRuntime extends AbstractFunction {
576
576
  let refList: ParameterReference[] = Array.from(param[1]?.values() ?? []);
577
577
 
578
578
  if (!refList.length && !p.isVariableArgument()) {
579
- if (!SchemaUtil.hasDefaultValueOrNullSchemaType(p.getSchema(), sRepo))
579
+ if (!(await SchemaUtil.hasDefaultValueOrNullSchemaType(p.getSchema(), sRepo)))
580
580
  se.addMessage(
581
581
  StatementMessageType.ERROR,
582
582
  StringFormatter.format(
@@ -612,7 +612,7 @@ export class KIRuntime extends AbstractFunction {
612
612
  if (paramSet.size) {
613
613
  for (let param of Array.from(paramSet.values())) {
614
614
  if (param.isVariableArgument()) continue;
615
- if (!SchemaUtil.hasDefaultValueOrNullSchemaType(param.getSchema(), sRepo))
615
+ if (!(await SchemaUtil.hasDefaultValueOrNullSchemaType(param.getSchema(), sRepo)))
616
616
  se.addMessage(
617
617
  StatementMessageType.ERROR,
618
618
  StringFormatter.format(
@@ -623,19 +623,19 @@ export class KIRuntime extends AbstractFunction {
623
623
  }
624
624
  }
625
625
 
626
- return se;
626
+ return Promise.resolve(se);
627
627
  }
628
628
 
629
- private parameterReferenceValidation(
629
+ private async parameterReferenceValidation(
630
630
  se: StatementExecution,
631
631
  p: Parameter,
632
632
  ref: ParameterReference,
633
633
  sRepo: Repository<Schema>,
634
- ): void {
634
+ ): Promise<void> {
635
635
  // Breaking this execution doesn't make sense.
636
636
 
637
637
  if (!ref) {
638
- if (isNullValue(SchemaUtil.getDefaultValue(p.getSchema(), sRepo)))
638
+ if (isNullValue(await SchemaUtil.getDefaultValue(p.getSchema(), sRepo)))
639
639
  se.addMessage(
640
640
  StatementMessageType.ERROR,
641
641
  StringFormatter.format(KIRuntime.PARAMETER_NEEDS_A_VALUE, p.getParameterName()),
@@ -643,7 +643,7 @@ export class KIRuntime extends AbstractFunction {
643
643
  } else if (ref.getType() == ParameterReferenceType.VALUE) {
644
644
  if (
645
645
  isNullValue(ref.getValue()) &&
646
- !SchemaUtil.hasDefaultValueOrNullSchemaType(p.getSchema(), sRepo)
646
+ !(await SchemaUtil.hasDefaultValueOrNullSchemaType(p.getSchema(), sRepo))
647
647
  )
648
648
  se.addMessage(
649
649
  StatementMessageType.ERROR,
@@ -1,5 +1,5 @@
1
1
  export function duplicate(obj: any): any {
2
2
  if (!obj) return obj;
3
- if (structuredClone) return structuredClone(obj);
3
+ if (globalThis.structuredClone) return globalThis.structuredClone(obj);
4
4
  return JSON.parse(JSON.stringify(obj));
5
5
  }
package/tsconfig.json CHANGED
@@ -1,6 +1,10 @@
1
1
  {
2
- "extends": "@tsconfig/recommended/tsconfig.json",
3
2
  "compilerOptions": {
4
- "lib": ["es2020"]
3
+ "module": "commonjs",
4
+ "strict": true,
5
+ "esModuleInterop": true,
6
+ "skipLibCheck": true,
7
+ "forceConsistentCasingInFileNames": true,
8
+ "lib": ["ES2022"]
5
9
  }
6
10
  }