typia 7.0.0-dev.20240924 → 7.0.0-dev.20240928

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 (54) hide show
  1. package/lib/index.mjs +1 -0
  2. package/lib/index.mjs.map +1 -1
  3. package/lib/programmers/AssertProgrammer.d.ts +1 -1
  4. package/lib/programmers/AssertProgrammer.js +169 -127
  5. package/lib/programmers/AssertProgrammer.js.map +1 -1
  6. package/lib/programmers/CheckerProgrammer.d.ts +70 -15
  7. package/lib/programmers/CheckerProgrammer.js +998 -638
  8. package/lib/programmers/CheckerProgrammer.js.map +1 -1
  9. package/lib/programmers/FeatureProgrammer.d.ts +5 -1
  10. package/lib/programmers/FeatureProgrammer.js +15 -15
  11. package/lib/programmers/FeatureProgrammer.js.map +1 -1
  12. package/lib/programmers/IsProgrammer.d.ts +25 -4
  13. package/lib/programmers/IsProgrammer.js +54 -39
  14. package/lib/programmers/IsProgrammer.js.map +1 -1
  15. package/lib/programmers/ValidateProgrammer.js +110 -97
  16. package/lib/programmers/ValidateProgrammer.js.map +1 -1
  17. package/lib/programmers/helpers/UnionExplorer.d.ts +1 -1
  18. package/lib/programmers/json/JsonStringifyProgrammer.js +68 -35
  19. package/lib/programmers/json/JsonStringifyProgrammer.js.map +1 -1
  20. package/lib/programmers/llm/LlmApplicationProgrammer.js +16 -2
  21. package/lib/programmers/llm/LlmApplicationProgrammer.js.map +1 -1
  22. package/lib/programmers/misc/MiscCloneProgrammer.js +62 -15
  23. package/lib/programmers/misc/MiscCloneProgrammer.js.map +1 -1
  24. package/lib/programmers/misc/MiscPruneProgrammer.js +39 -11
  25. package/lib/programmers/misc/MiscPruneProgrammer.js.map +1 -1
  26. package/lib/programmers/notations/NotationGeneralProgrammer.js +62 -15
  27. package/lib/programmers/notations/NotationGeneralProgrammer.js.map +1 -1
  28. package/lib/programmers/protobuf/ProtobufEncodeProgrammer.js +17 -3
  29. package/lib/programmers/protobuf/ProtobufEncodeProgrammer.js.map +1 -1
  30. package/lib/tags/Example.d.ts +14 -0
  31. package/lib/tags/Example.js +3 -0
  32. package/lib/tags/Example.js.map +1 -0
  33. package/lib/tags/Examples.d.ts +10 -0
  34. package/lib/tags/Examples.js +3 -0
  35. package/lib/tags/Examples.js.map +1 -0
  36. package/lib/tags/index.d.ts +2 -0
  37. package/lib/tags/index.js +2 -0
  38. package/lib/tags/index.js.map +1 -1
  39. package/package.json +2 -2
  40. package/src/programmers/AssertProgrammer.ts +185 -143
  41. package/src/programmers/CheckerProgrammer.ts +1380 -998
  42. package/src/programmers/FeatureProgrammer.ts +37 -31
  43. package/src/programmers/IsProgrammer.ts +94 -66
  44. package/src/programmers/ValidateProgrammer.ts +149 -137
  45. package/src/programmers/helpers/UnionExplorer.ts +1 -1
  46. package/src/programmers/json/JsonStringifyProgrammer.ts +56 -35
  47. package/src/programmers/llm/LlmApplicationProgrammer.ts +51 -32
  48. package/src/programmers/misc/MiscCloneProgrammer.ts +64 -26
  49. package/src/programmers/misc/MiscPruneProgrammer.ts +34 -13
  50. package/src/programmers/notations/NotationGeneralProgrammer.ts +64 -26
  51. package/src/programmers/protobuf/ProtobufEncodeProgrammer.ts +16 -9
  52. package/src/tags/Example.ts +17 -0
  53. package/src/tags/Examples.ts +16 -0
  54. package/src/tags/index.ts +20 -18
@@ -47,9 +47,11 @@ export namespace NotationGeneralProgrammer {
47
47
  const config = configure(props);
48
48
  if (props.validated === false)
49
49
  config.addition = (collection) =>
50
- IsProgrammer.write_function_statements(props.context)(props.importer)(
50
+ IsProgrammer.write_function_statements({
51
+ context: props.context,
52
+ importer: props.importer,
51
53
  collection,
52
- );
54
+ });
53
55
  const composed: FeatureProgrammer.IComposed = FeatureProgrammer.compose({
54
56
  ...props,
55
57
  config,
@@ -213,15 +215,14 @@ export namespace NotationGeneralProgrammer {
213
215
  unions.push({
214
216
  type: "tuple",
215
217
  is: () =>
216
- IsProgrammer.decode(props.context)(props.importer)(
217
- props.input,
218
- (() => {
218
+ IsProgrammer.decode({
219
+ ...props,
220
+ metadata: (() => {
219
221
  const partial = Metadata.initialize();
220
222
  partial.tuples.push(tuple);
221
223
  return partial;
222
224
  })(),
223
- props.explore,
224
- ),
225
+ }),
225
226
  value: () =>
226
227
  decode_tuple({
227
228
  ...props,
@@ -484,7 +485,14 @@ export namespace NotationGeneralProgrammer {
484
485
  }): ts.Expression =>
485
486
  ts.factory.createCallExpression(
486
487
  UnionExplorer.set({
487
- checker: IsProgrammer.decode(props.context)(props.importer),
488
+ checker: (input, metadata, explore) =>
489
+ IsProgrammer.decode({
490
+ context: props.context,
491
+ importer: props.importer,
492
+ input,
493
+ metadata,
494
+ explore,
495
+ }),
488
496
  decoder: (input, array, explore) =>
489
497
  ts.factory.createNewExpression(
490
498
  ts.factory.createIdentifier("Set"),
@@ -522,19 +530,29 @@ export namespace NotationGeneralProgrammer {
522
530
  }): ts.Expression =>
523
531
  ts.factory.createCallExpression(
524
532
  UnionExplorer.map({
525
- checker: (top, entry, explore) => {
526
- const func = IsProgrammer.decode(props.context)(props.importer);
527
- return ts.factory.createLogicalAnd(
528
- func(ts.factory.createElementAccessExpression(top, 0), entry[0], {
529
- ...explore,
530
- postfix: `${explore.postfix}[0]`,
533
+ checker: (top, entry, explore) =>
534
+ ts.factory.createLogicalAnd(
535
+ IsProgrammer.decode({
536
+ context: props.context,
537
+ importer: props.importer,
538
+ input: ts.factory.createElementAccessExpression(top, 0),
539
+ metadata: entry[0],
540
+ explore: {
541
+ ...props.explore,
542
+ postfix: `${explore.postfix}[0]`,
543
+ },
531
544
  }),
532
- func(ts.factory.createElementAccessExpression(top, 1), entry[1], {
533
- ...explore,
534
- postfix: `${explore.postfix}[1]`,
545
+ IsProgrammer.decode({
546
+ context: props.context,
547
+ importer: props.importer,
548
+ input: ts.factory.createElementAccessExpression(top, 1),
549
+ metadata: entry[1],
550
+ explore: {
551
+ ...props.explore,
552
+ postfix: `${props.explore.postfix}[1]`,
553
+ },
535
554
  }),
536
- );
537
- },
555
+ ),
538
556
  decoder: (input, array, explore) =>
539
557
  ts.factory.createNewExpression(
540
558
  ts.factory.createIdentifier("Map"),
@@ -597,7 +615,14 @@ export namespace NotationGeneralProgrammer {
597
615
  explore_array_like_union_types({
598
616
  ...props,
599
617
  factory: UnionExplorer.array({
600
- checker: IsProgrammer.decode(props.context)(props.importer),
618
+ checker: (input, metadata, explore) =>
619
+ IsProgrammer.decode({
620
+ context: props.context,
621
+ importer: props.importer,
622
+ input,
623
+ metadata,
624
+ explore,
625
+ }),
601
626
  decoder: (input, array, explore) =>
602
627
  decode_array({
603
628
  config: props.config,
@@ -645,7 +670,7 @@ export namespace NotationGeneralProgrammer {
645
670
  [],
646
671
  );
647
672
 
648
- const explore: FeatureProgrammer.IExplore = {
673
+ const arrayExplore: FeatureProgrammer.IExplore = {
649
674
  ...props.explore,
650
675
  source: "function",
651
676
  from: "array",
@@ -661,13 +686,13 @@ export namespace NotationGeneralProgrammer {
661
686
  TypeFactory.keyword("any"),
662
687
  )(ts.factory.createIdentifier("input")),
663
688
  )({
664
- ...explore,
689
+ ...arrayExplore,
665
690
  postfix: "",
666
691
  })(ts.factory.createIdentifier("input")),
667
692
  ),
668
693
  ),
669
694
  undefined,
670
- FeatureProgrammer.argumentsArray(props.config)(explore)(props.input),
695
+ FeatureProgrammer.argumentsArray(props.config)(arrayExplore)(props.input),
671
696
  );
672
697
  };
673
698
 
@@ -708,11 +733,24 @@ export namespace NotationGeneralProgrammer {
708
733
  input,
709
734
  }),
710
735
  objector: {
711
- checker: () => IsProgrammer.decode(props.context)(props.importer),
736
+ checker: () => (input, metadata, explore) =>
737
+ IsProgrammer.decode({
738
+ context: props.context,
739
+ importer: props.importer,
740
+ input,
741
+ metadata,
742
+ explore,
743
+ }),
712
744
  decoder: () => decode_object(props.importer),
713
745
  joiner: NotationJoiner.object(props.rename),
714
- unionizer: decode_union_object(
715
- IsProgrammer.decode_object(props.context)(props.importer),
746
+ unionizer: decode_union_object((input, object, explore) =>
747
+ IsProgrammer.decode_object({
748
+ context: props.context,
749
+ importer: props.importer,
750
+ object,
751
+ input,
752
+ explore,
753
+ }),
716
754
  )(decode_object(props.importer))((exp) => exp)((input, expected) =>
717
755
  create_throw_error({
718
756
  importer: props.importer,
@@ -179,9 +179,7 @@ export namespace ProtobufEncodeProgrammer {
179
179
  [
180
180
  ...props.importer.declareUnions(),
181
181
  ...functors,
182
- ...IsProgrammer.write_function_statements(props.context)(
183
- props.importer,
184
- )(props.collection),
182
+ ...IsProgrammer.write_function_statements(props),
185
183
  ...main.statements,
186
184
  ts.factory.createReturnStatement(
187
185
  ts.factory.createIdentifier("writer"),
@@ -861,7 +859,14 @@ export namespace ProtobufEncodeProgrammer {
861
859
 
862
860
  if (specList.length === 0) {
863
861
  const condition: ts.Expression = decode_union_object(
864
- IsProgrammer.decode_object(props.context)(props.importer),
862
+ (input, object, explore) =>
863
+ IsProgrammer.decode_object({
864
+ context: props.context,
865
+ importer: props.importer,
866
+ object,
867
+ input,
868
+ explore,
869
+ }),
865
870
  )((input, object, explore) =>
866
871
  ExpressionFactory.selfCall(
867
872
  decode_object({
@@ -895,15 +900,17 @@ export namespace ProtobufEncodeProgrammer {
895
900
  key,
896
901
  );
897
902
  const pred: ts.Expression = spec.neighbour
898
- ? IsProgrammer.decode(props.context)(props.importer)(
899
- accessor,
900
- spec.property.value,
901
- {
903
+ ? IsProgrammer.decode({
904
+ context: props.context,
905
+ importer: props.importer,
906
+ input: accessor,
907
+ metadata: spec.property.value,
908
+ explore: {
902
909
  ...props.explore,
903
910
  tracable: false,
904
911
  postfix: IdentifierFactory.postfix(key),
905
912
  },
906
- )
913
+ })
907
914
  : ExpressionFactory.isRequired(accessor);
908
915
  return ts.factory.createIfStatement(
909
916
  pred,
@@ -0,0 +1,17 @@
1
+ import { TagBase } from "./TagBase";
2
+
3
+ export type Example<
4
+ Value extends boolean | bigint | number | string | Array<unknown> | null,
5
+ > = TagBase<{
6
+ target: "boolean" | "bigint" | "number" | "string" | "array";
7
+ kind: "example";
8
+ value: Value;
9
+ exclusive: true;
10
+ schema: Value extends bigint
11
+ ? { example: Numeric<Value> }
12
+ : { example: Value };
13
+ }>;
14
+
15
+ type Numeric<T extends bigint> = `${T}` extends `${infer N extends number}`
16
+ ? N
17
+ : never;
@@ -0,0 +1,16 @@
1
+ import { TagBase } from "./TagBase";
2
+
3
+ export type Examples<
4
+ Dict extends Record<
5
+ string,
6
+ boolean | bigint | number | string | Array<unknown> | null
7
+ >,
8
+ > = TagBase<{
9
+ target: "boolean" | "bigint" | "number" | "string" | "array";
10
+ kind: "examples";
11
+ value: Dict;
12
+ exclusive: true;
13
+ schema: {
14
+ examples: Dict;
15
+ };
16
+ }>;
package/src/tags/index.ts CHANGED
@@ -1,18 +1,20 @@
1
- export * from "./Constant";
2
- export * from "./ContentMediaType";
3
- export * from "./Default";
4
- export * from "./ExclusiveMaximum";
5
- export * from "./ExclusiveMinimum";
6
- export * from "./Format";
7
- export * from "./JsonSchemaPlugin";
8
- export * from "./Maximum";
9
- export * from "./MaxItems";
10
- export * from "./MaxLength";
11
- export * from "./Minimum";
12
- export * from "./MinItems";
13
- export * from "./MinLength";
14
- export * from "./MultipleOf";
15
- export * from "./Pattern";
16
- export * from "./TagBase";
17
- export * from "./Type";
18
- export * from "./UniqueItems";
1
+ export * from "./Constant";
2
+ export * from "./ContentMediaType";
3
+ export * from "./Default";
4
+ export * from "./Example";
5
+ export * from "./Examples";
6
+ export * from "./ExclusiveMaximum";
7
+ export * from "./ExclusiveMinimum";
8
+ export * from "./Format";
9
+ export * from "./JsonSchemaPlugin";
10
+ export * from "./Maximum";
11
+ export * from "./MaxItems";
12
+ export * from "./MaxLength";
13
+ export * from "./Minimum";
14
+ export * from "./MinItems";
15
+ export * from "./MinLength";
16
+ export * from "./MultipleOf";
17
+ export * from "./Pattern";
18
+ export * from "./TagBase";
19
+ export * from "./Type";
20
+ export * from "./UniqueItems";