typia 7.0.0-dev.20240930 → 7.0.0-dev.20241001

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 (169) hide show
  1. package/lib/index.mjs +25 -25
  2. package/lib/index.mjs.map +1 -1
  3. package/lib/programmers/AssertProgrammer.js +20 -17
  4. package/lib/programmers/AssertProgrammer.js.map +1 -1
  5. package/lib/programmers/CheckerProgrammer.js +274 -216
  6. package/lib/programmers/CheckerProgrammer.js.map +1 -1
  7. package/lib/programmers/FeatureProgrammer.js +16 -8
  8. package/lib/programmers/FeatureProgrammer.js.map +1 -1
  9. package/lib/programmers/IsProgrammer.js +38 -20
  10. package/lib/programmers/IsProgrammer.js.map +1 -1
  11. package/lib/programmers/RandomProgrammer.js +83 -68
  12. package/lib/programmers/RandomProgrammer.js.map +1 -1
  13. package/lib/programmers/TypiaProgrammer.d.ts +2 -2
  14. package/lib/programmers/TypiaProgrammer.js +79 -75
  15. package/lib/programmers/TypiaProgrammer.js.map +1 -1
  16. package/lib/programmers/ValidateProgrammer.js +39 -17
  17. package/lib/programmers/ValidateProgrammer.js.map +1 -1
  18. package/lib/programmers/helpers/CloneJoiner.js +4 -1
  19. package/lib/programmers/helpers/CloneJoiner.js.map +1 -1
  20. package/lib/programmers/helpers/NotationJoiner.d.ts +2 -1
  21. package/lib/programmers/helpers/NotationJoiner.js +34 -33
  22. package/lib/programmers/helpers/NotationJoiner.js.map +1 -1
  23. package/lib/programmers/helpers/PruneJoiner.js +4 -1
  24. package/lib/programmers/helpers/PruneJoiner.js.map +1 -1
  25. package/lib/programmers/helpers/RandomJoiner.d.ts +1 -1
  26. package/lib/programmers/helpers/RandomJoiner.js.map +1 -1
  27. package/lib/programmers/helpers/RandomRanger.js.map +1 -1
  28. package/lib/programmers/helpers/StringifyJoinder.js +4 -1
  29. package/lib/programmers/helpers/StringifyJoinder.js.map +1 -1
  30. package/lib/programmers/helpers/StringifyPredicator.d.ts +1 -1
  31. package/lib/programmers/helpers/StringifyPredicator.js +4 -3
  32. package/lib/programmers/helpers/StringifyPredicator.js.map +1 -1
  33. package/lib/programmers/helpers/UnionExplorer.d.ts +52 -12
  34. package/lib/programmers/helpers/UnionExplorer.js +183 -144
  35. package/lib/programmers/helpers/UnionExplorer.js.map +1 -1
  36. package/lib/programmers/helpers/UnionPredicator.d.ts +1 -1
  37. package/lib/programmers/helpers/UnionPredicator.js +7 -7
  38. package/lib/programmers/http/HttpFormDataProgrammer.js +77 -70
  39. package/lib/programmers/http/HttpFormDataProgrammer.js.map +1 -1
  40. package/lib/programmers/http/HttpHeadersProgrammer.js +69 -68
  41. package/lib/programmers/http/HttpHeadersProgrammer.js.map +1 -1
  42. package/lib/programmers/http/HttpQueryProgrammer.js +69 -62
  43. package/lib/programmers/http/HttpQueryProgrammer.js.map +1 -1
  44. package/lib/programmers/internal/application_escaped.js +4 -4
  45. package/lib/programmers/internal/application_escaped.js.map +1 -1
  46. package/lib/programmers/internal/application_templates.js +8 -2
  47. package/lib/programmers/internal/application_templates.js.map +1 -1
  48. package/lib/programmers/internal/application_union_discriminator.d.ts +1 -1
  49. package/lib/programmers/internal/application_union_discriminator.js +6 -6
  50. package/lib/programmers/internal/application_union_discriminator.js.map +1 -1
  51. package/lib/programmers/internal/application_v30_object.js +6 -3
  52. package/lib/programmers/internal/application_v30_object.js.map +1 -1
  53. package/lib/programmers/internal/application_v31_object.js +4 -1
  54. package/lib/programmers/internal/application_v31_object.js.map +1 -1
  55. package/lib/programmers/internal/check_array_length.js +21 -26
  56. package/lib/programmers/internal/check_array_length.js.map +1 -1
  57. package/lib/programmers/internal/check_bigint.js +18 -26
  58. package/lib/programmers/internal/check_bigint.js.map +1 -1
  59. package/lib/programmers/internal/check_dynamic_key.d.ts +1 -5
  60. package/lib/programmers/internal/check_dynamic_key.js +109 -91
  61. package/lib/programmers/internal/check_dynamic_key.js.map +1 -1
  62. package/lib/programmers/internal/check_dynamic_properties.js +88 -90
  63. package/lib/programmers/internal/check_dynamic_properties.js.map +1 -1
  64. package/lib/programmers/internal/check_native.js +8 -5
  65. package/lib/programmers/internal/check_native.js.map +1 -1
  66. package/lib/programmers/internal/check_number.js +59 -65
  67. package/lib/programmers/internal/check_number.js.map +1 -1
  68. package/lib/programmers/internal/check_object.js +31 -22
  69. package/lib/programmers/internal/check_object.js.map +1 -1
  70. package/lib/programmers/internal/check_string.js +18 -26
  71. package/lib/programmers/internal/check_string.js.map +1 -1
  72. package/lib/programmers/internal/check_template.js +20 -21
  73. package/lib/programmers/internal/check_template.js.map +1 -1
  74. package/lib/programmers/internal/check_union_array_like.js +68 -53
  75. package/lib/programmers/internal/check_union_array_like.js.map +1 -1
  76. package/lib/programmers/internal/decode_union_object.js +59 -49
  77. package/lib/programmers/internal/decode_union_object.js.map +1 -1
  78. package/lib/programmers/internal/feature_object_entries.js +31 -37
  79. package/lib/programmers/internal/feature_object_entries.js.map +1 -1
  80. package/lib/programmers/internal/llm_schema_escaped.js +29 -11
  81. package/lib/programmers/internal/llm_schema_escaped.js.map +1 -1
  82. package/lib/programmers/internal/llm_schema_object.js +4 -1
  83. package/lib/programmers/internal/llm_schema_object.js.map +1 -1
  84. package/lib/programmers/internal/metadata_to_pattern.js +44 -41
  85. package/lib/programmers/internal/metadata_to_pattern.js.map +1 -1
  86. package/lib/programmers/internal/postfix_of_tuple.d.ts +1 -1
  87. package/lib/programmers/internal/postfix_of_tuple.js +3 -0
  88. package/lib/programmers/internal/postfix_of_tuple.js.map +1 -1
  89. package/lib/programmers/internal/prune_object_properties.js +6 -3
  90. package/lib/programmers/internal/prune_object_properties.js.map +1 -1
  91. package/lib/programmers/internal/random_custom.js +8 -14
  92. package/lib/programmers/internal/random_custom.js.map +1 -1
  93. package/lib/programmers/internal/stringify_dynamic_properties.js +4 -1
  94. package/lib/programmers/internal/stringify_dynamic_properties.js.map +1 -1
  95. package/lib/programmers/internal/stringify_regular_properties.js +4 -4
  96. package/lib/programmers/internal/stringify_regular_properties.js.map +1 -1
  97. package/lib/programmers/internal/template_to_pattern.js +10 -5
  98. package/lib/programmers/internal/template_to_pattern.js.map +1 -1
  99. package/lib/programmers/internal/wrap_metadata_rest_tuple.d.ts +1 -2
  100. package/lib/programmers/internal/wrap_metadata_rest_tuple.js +3 -0
  101. package/lib/programmers/internal/wrap_metadata_rest_tuple.js.map +1 -1
  102. package/lib/programmers/json/JsonStringifyProgrammer.js +76 -52
  103. package/lib/programmers/json/JsonStringifyProgrammer.js.map +1 -1
  104. package/lib/programmers/misc/MiscCloneProgrammer.js +143 -115
  105. package/lib/programmers/misc/MiscCloneProgrammer.js.map +1 -1
  106. package/lib/programmers/misc/MiscPruneProgrammer.js +65 -50
  107. package/lib/programmers/misc/MiscPruneProgrammer.js.map +1 -1
  108. package/lib/programmers/notations/NotationGeneralProgrammer.d.ts +4 -1
  109. package/lib/programmers/notations/NotationGeneralProgrammer.js +166 -115
  110. package/lib/programmers/notations/NotationGeneralProgrammer.js.map +1 -1
  111. package/lib/programmers/protobuf/ProtobufEncodeProgrammer.js +32 -24
  112. package/lib/programmers/protobuf/ProtobufEncodeProgrammer.js.map +1 -1
  113. package/lib/utils/NamingConvention/NamingConvention.js +41 -47
  114. package/lib/utils/NamingConvention/NamingConvention.js.map +1 -1
  115. package/package.json +1 -1
  116. package/src/programmers/AssertProgrammer.ts +30 -27
  117. package/src/programmers/CheckerProgrammer.ts +279 -248
  118. package/src/programmers/FeatureProgrammer.ts +17 -15
  119. package/src/programmers/IsProgrammer.ts +34 -20
  120. package/src/programmers/RandomProgrammer.ts +18 -9
  121. package/src/programmers/TypiaProgrammer.ts +48 -34
  122. package/src/programmers/ValidateProgrammer.ts +50 -27
  123. package/src/programmers/helpers/CloneJoiner.ts +4 -1
  124. package/src/programmers/helpers/NotationJoiner.ts +85 -83
  125. package/src/programmers/helpers/ProtobufUtil.ts +2 -2
  126. package/src/programmers/helpers/PruneJoiner.ts +4 -1
  127. package/src/programmers/helpers/RandomJoiner.ts +5 -2
  128. package/src/programmers/helpers/RandomRanger.ts +8 -1
  129. package/src/programmers/helpers/StringifyJoinder.ts +4 -1
  130. package/src/programmers/helpers/StringifyPredicator.ts +4 -3
  131. package/src/programmers/helpers/UnionExplorer.ts +279 -202
  132. package/src/programmers/helpers/UnionPredicator.ts +5 -5
  133. package/src/programmers/http/HttpFormDataProgrammer.ts +135 -114
  134. package/src/programmers/http/HttpHeadersProgrammer.ts +145 -120
  135. package/src/programmers/http/HttpQueryProgrammer.ts +137 -116
  136. package/src/programmers/internal/application_escaped.ts +6 -6
  137. package/src/programmers/internal/application_templates.ts +8 -6
  138. package/src/programmers/internal/application_union_discriminator.ts +6 -6
  139. package/src/programmers/internal/application_v30_object.ts +6 -3
  140. package/src/programmers/internal/application_v31_object.ts +4 -1
  141. package/src/programmers/internal/application_v31_tuple.ts +1 -1
  142. package/src/programmers/internal/check_array_length.ts +31 -30
  143. package/src/programmers/internal/check_bigint.ts +31 -31
  144. package/src/programmers/internal/check_dynamic_key.ts +155 -126
  145. package/src/programmers/internal/check_dynamic_properties.ts +152 -154
  146. package/src/programmers/internal/check_native.ts +11 -5
  147. package/src/programmers/internal/check_number.ts +88 -84
  148. package/src/programmers/internal/check_object.ts +45 -31
  149. package/src/programmers/internal/check_string.ts +31 -30
  150. package/src/programmers/internal/check_template.ts +34 -32
  151. package/src/programmers/internal/check_union_array_like.ts +245 -228
  152. package/src/programmers/internal/decode_union_object.ts +92 -75
  153. package/src/programmers/internal/feature_object_entries.ts +43 -46
  154. package/src/programmers/internal/llm_schema_escaped.ts +36 -13
  155. package/src/programmers/internal/llm_schema_object.ts +4 -1
  156. package/src/programmers/internal/metadata_to_pattern.ts +31 -23
  157. package/src/programmers/internal/postfix_of_tuple.ts +3 -0
  158. package/src/programmers/internal/prune_object_properties.ts +6 -3
  159. package/src/programmers/internal/random_custom.ts +24 -23
  160. package/src/programmers/internal/stringify_dynamic_properties.ts +4 -1
  161. package/src/programmers/internal/stringify_regular_properties.ts +7 -7
  162. package/src/programmers/internal/template_to_pattern.ts +12 -4
  163. package/src/programmers/internal/wrap_metadata_rest_tuple.ts +3 -0
  164. package/src/programmers/json/JsonStringifyProgrammer.ts +71 -51
  165. package/src/programmers/misc/MiscCloneProgrammer.ts +156 -132
  166. package/src/programmers/misc/MiscPruneProgrammer.ts +61 -49
  167. package/src/programmers/notations/NotationGeneralProgrammer.ts +193 -144
  168. package/src/programmers/protobuf/ProtobufEncodeProgrammer.ts +25 -21
  169. package/src/utils/NamingConvention/NamingConvention.ts +40 -42
@@ -411,9 +411,12 @@ export namespace FeatureProgrammer {
411
411
  undefined,
412
412
  props.config.objector.joiner({
413
413
  input: ts.factory.createIdentifier("input"),
414
- entries: feature_object_entries(props.config)(props.importer)(
414
+ entries: feature_object_entries({
415
+ config: props.config,
416
+ importer: props.importer,
417
+ input: ts.factory.createIdentifier("input"),
415
418
  object,
416
- )(ts.factory.createIdentifier("input")),
419
+ }),
417
420
  object,
418
421
  }),
419
422
  ),
@@ -434,13 +437,8 @@ export namespace FeatureProgrammer {
434
437
  ),
435
438
  );
436
439
 
437
- const write_union = (props: {
438
- config: IConfig;
439
- objects: MetadataObject[];
440
- }) => {
441
- const explorer = UnionExplorer.object(props.config);
442
- const input = ValueFactory.INPUT();
443
- return ts.factory.createArrowFunction(
440
+ const write_union = (props: { config: IConfig; objects: MetadataObject[] }) =>
441
+ ts.factory.createArrowFunction(
444
442
  undefined,
445
443
  undefined,
446
444
  parameterDeclarations({
@@ -450,14 +448,18 @@ export namespace FeatureProgrammer {
450
448
  }),
451
449
  TypeFactory.keyword("any"),
452
450
  undefined,
453
- explorer(input, props.objects, {
454
- tracable: props.config.path || props.config.trace,
455
- source: "function",
456
- from: "object",
457
- postfix: "",
451
+ UnionExplorer.object({
452
+ config: props.config,
453
+ objects: props.objects,
454
+ input: ValueFactory.INPUT(),
455
+ explore: {
456
+ tracable: props.config.path || props.config.trace,
457
+ source: "function",
458
+ from: "object",
459
+ postfix: "",
460
+ },
458
461
  }),
459
462
  );
460
- };
461
463
 
462
464
  /* -----------------------------------------------------------
463
465
  DECODERS
@@ -60,18 +60,25 @@ export namespace IsProgrammer {
60
60
  : initial;
61
61
  },
62
62
  joiner: {
63
- object:
64
- props.options?.object ||
65
- check_object({
66
- equals: !!props.options?.object,
67
- undefined: OptionPredicator.undefined({
68
- undefined: props.options?.undefined,
69
- }),
70
- assert: true,
71
- reduce: ts.factory.createLogicalAnd,
72
- positive: ts.factory.createTrue(),
73
- superfluous: () => ts.factory.createFalse(),
74
- })(props.context)(props.importer),
63
+ object: props.options?.object
64
+ ? (v) => props.options!.object!(v)
65
+ : (v) =>
66
+ check_object({
67
+ config: {
68
+ equals: !!props.options?.object,
69
+ undefined: OptionPredicator.undefined({
70
+ undefined: props.options?.undefined,
71
+ }),
72
+ assert: true,
73
+ reduce: ts.factory.createLogicalAnd,
74
+ positive: ts.factory.createTrue(),
75
+ superfluous: () => ts.factory.createFalse(),
76
+ },
77
+ context: props.context,
78
+ importer: props.importer,
79
+ entries: v.entries,
80
+ input: v.input,
81
+ }),
75
82
  array: (props) =>
76
83
  ts.factory.createCallExpression(
77
84
  IdentifierFactory.access(props.input)("every"),
@@ -115,14 +122,21 @@ export namespace IsProgrammer {
115
122
  const config: CheckerProgrammer.IConfig = {
116
123
  ...configure({
117
124
  options: {
118
- object: check_object({
119
- equals: props.config.equals,
120
- undefined: OptionPredicator.undefined(props.context.options),
121
- assert: true,
122
- reduce: ts.factory.createLogicalAnd,
123
- positive: ts.factory.createTrue(),
124
- superfluous: () => ts.factory.createFalse(),
125
- })(props.context)(props.importer),
125
+ object: (v) =>
126
+ check_object({
127
+ config: {
128
+ equals: props.config.equals,
129
+ undefined: OptionPredicator.undefined(props.context.options),
130
+ assert: true,
131
+ reduce: ts.factory.createLogicalAnd,
132
+ positive: ts.factory.createTrue(),
133
+ superfluous: () => ts.factory.createFalse(),
134
+ },
135
+ context: props.context,
136
+ importer: props.importer,
137
+ entries: v.entries,
138
+ input: v.input,
139
+ }),
126
140
  numeric: OptionPredicator.numeric(props.context.options),
127
141
  },
128
142
  context: props.context,
@@ -481,8 +481,11 @@ export namespace RandomProgrammer {
481
481
  ? "uint"
482
482
  : "double";
483
483
  const multiply = tags.find((t) => t.kind === "multipleOf");
484
- return random_custom(coalesce(props.importer))("number")(tags)(
485
- RandomRanger.number({
484
+ return random_custom({
485
+ accessor: coalesce(props.importer),
486
+ type: "number",
487
+ tags,
488
+ expression: RandomRanger.number({
486
489
  config: {
487
490
  type,
488
491
  transform: (value) => ExpressionFactory.number(value),
@@ -502,7 +505,7 @@ export namespace RandomProgrammer {
502
505
  },
503
506
  tags,
504
507
  }),
505
- );
508
+ });
506
509
  });
507
510
 
508
511
  const decode_bigint = (props: {
@@ -510,8 +513,11 @@ export namespace RandomProgrammer {
510
513
  atomic: MetadataAtomic;
511
514
  }): ts.Expression[] =>
512
515
  (props.atomic.tags.length ? props.atomic.tags : [[]]).map((tags) =>
513
- random_custom(coalesce(props.importer))("bigint")(tags)(
514
- RandomRanger.number({
516
+ random_custom({
517
+ accessor: coalesce(props.importer),
518
+ type: "bigint",
519
+ tags,
520
+ expression: RandomRanger.number({
515
521
  config: {
516
522
  type: tags.find(
517
523
  (t) =>
@@ -535,7 +541,7 @@ export namespace RandomProgrammer {
535
541
  },
536
542
  tags,
537
543
  }),
538
- ),
544
+ }),
539
545
  );
540
546
 
541
547
  const decode_string = (props: {
@@ -543,8 +549,11 @@ export namespace RandomProgrammer {
543
549
  atomic: MetadataAtomic;
544
550
  }): ts.Expression[] =>
545
551
  (props.atomic.tags.length ? props.atomic.tags : [[]]).map((tags) =>
546
- random_custom(coalesce(props.importer))("string")(tags)(
547
- (() => {
552
+ random_custom({
553
+ accessor: coalesce(props.importer),
554
+ type: "string",
555
+ tags,
556
+ expression: (() => {
548
557
  for (const t of tags)
549
558
  if (t.kind === "format")
550
559
  return ts.factory.createCallExpression(
@@ -582,7 +591,7 @@ export namespace RandomProgrammer {
582
591
  tail ? [tail] : undefined,
583
592
  );
584
593
  })(),
585
- ),
594
+ }),
586
595
  );
587
596
 
588
597
  const decode_array = (props: {
@@ -7,47 +7,54 @@ import { ImportTransformer } from "../transformers/ImportTransformer";
7
7
  import transform from "../transform";
8
8
 
9
9
  export namespace TypiaProgrammer {
10
- export interface IProps {
10
+ export interface ILocation {
11
11
  input: string;
12
12
  output: string;
13
13
  project: string;
14
14
  }
15
15
 
16
- export const build = async (props: TypiaProgrammer.IProps): Promise<void> => {
17
- props.input = path.resolve(props.input);
18
- props.output = path.resolve(props.output);
16
+ export const build = async (
17
+ location: TypiaProgrammer.ILocation,
18
+ ): Promise<void> => {
19
+ location.input = path.resolve(location.input);
20
+ location.output = path.resolve(location.output);
19
21
 
20
- if ((await is_directory(props.input)) === false)
22
+ if ((await is_directory(location.input)) === false)
21
23
  throw new URIError(
22
24
  "Error on TypiaGenerator.generate(): input path is not a directory.",
23
25
  );
24
- else if (fs.existsSync(props.output) === false)
25
- await fs.promises.mkdir(props.output, { recursive: true });
26
- else if ((await is_directory(props.output)) === false) {
27
- const parent: string = path.join(props.output, "..");
26
+ else if (fs.existsSync(location.output) === false)
27
+ await fs.promises.mkdir(location.output, { recursive: true });
28
+ else if ((await is_directory(location.output)) === false) {
29
+ const parent: string = path.join(location.output, "..");
28
30
  if ((await is_directory(parent)) === false)
29
31
  throw new URIError(
30
32
  "Error on TypiaGenerator.generate(): output path is not a directory.",
31
33
  );
32
- await fs.promises.mkdir(props.output);
34
+ await fs.promises.mkdir(location.output);
33
35
  }
34
36
 
35
37
  // CREATE PROGRAM
36
38
  const { options: compilerOptions } = ts.parseJsonConfigFileContent(
37
- ts.readConfigFile(props.project, ts.sys.readFile).config,
39
+ ts.readConfigFile(location.project, ts.sys.readFile).config,
38
40
  {
39
41
  fileExists: ts.sys.fileExists,
40
42
  readFile: ts.sys.readFile,
41
43
  readDirectory: ts.sys.readDirectory,
42
44
  useCaseSensitiveFileNames: ts.sys.useCaseSensitiveFileNames,
43
45
  },
44
- path.dirname(props.project),
46
+ path.dirname(location.project),
45
47
  );
46
48
 
47
49
  const program: ts.Program = ts.createProgram(
48
50
  await (async () => {
49
51
  const container: string[] = [];
50
- await gather(props)(container)(props.input)(props.output);
52
+ await gather({
53
+ location,
54
+ container,
55
+ from: location.input,
56
+ to: location.output,
57
+ });
51
58
  return container;
52
59
  })(),
53
60
  compilerOptions,
@@ -61,10 +68,10 @@ export namespace TypiaProgrammer {
61
68
  .filter(
62
69
  (file) =>
63
70
  !file.isDeclarationFile &&
64
- path.resolve(file.fileName).indexOf(props.input) !== -1,
71
+ path.resolve(file.fileName).indexOf(location.input) !== -1,
65
72
  ),
66
73
  [
67
- ImportTransformer.transform(props.input)(props.output),
74
+ ImportTransformer.transform(location.input)(location.output),
68
75
  transform(
69
76
  program,
70
77
  ((compilerOptions.plugins as any[]) ?? []).find(
@@ -117,7 +124,7 @@ export namespace TypiaProgrammer {
117
124
  for (const file of result.transformed) {
118
125
  const to: string = path
119
126
  .resolve(file.fileName)
120
- .replace(props.input, props.output);
127
+ .replace(location.input, location.output);
121
128
 
122
129
  const content: string = printer.printFile(file);
123
130
  await fs.promises.writeFile(to, content, "utf8");
@@ -129,24 +136,31 @@ export namespace TypiaProgrammer {
129
136
  return stat.isDirectory();
130
137
  };
131
138
 
132
- const gather =
133
- (props: IProps) =>
134
- (container: string[]) =>
135
- (from: string) =>
136
- async (to: string) => {
137
- if (from === props.output) return;
138
- else if (fs.existsSync(to) === false) await fs.promises.mkdir(to);
139
-
140
- for (const file of await fs.promises.readdir(from)) {
141
- const next: string = path.join(from, file);
142
- const stat: fs.Stats = await fs.promises.stat(next);
143
-
144
- if (stat.isDirectory()) {
145
- await gather(props)(container)(next)(path.join(to, file));
146
- continue;
147
- } else if (is_supported_extension(file)) container.push(next);
148
- }
149
- };
139
+ const gather = async (props: {
140
+ location: ILocation;
141
+ container: string[];
142
+ from: string;
143
+ to: string;
144
+ }) => {
145
+ if (props.from === props.location.output) return;
146
+ else if (fs.existsSync(props.to) === false)
147
+ await fs.promises.mkdir(props.to);
148
+
149
+ for (const file of await fs.promises.readdir(props.from)) {
150
+ const next: string = path.join(props.from, file);
151
+ const stat: fs.Stats = await fs.promises.stat(next);
152
+
153
+ if (stat.isDirectory()) {
154
+ await gather({
155
+ location: props.location,
156
+ container: props.container,
157
+ from: next,
158
+ to: path.join(props.to, file),
159
+ });
160
+ continue;
161
+ } else if (is_supported_extension(file)) props.container.push(next);
162
+ }
163
+ };
150
164
 
151
165
  const is_supported_extension = (filename: string): boolean => {
152
166
  return (
@@ -12,6 +12,7 @@ import { CheckerProgrammer } from "./CheckerProgrammer";
12
12
  import { FeatureProgrammer } from "./FeatureProgrammer";
13
13
  import { IsProgrammer } from "./IsProgrammer";
14
14
  import { FunctionImporter } from "./helpers/FunctionImporter";
15
+ import { IExpressionEntry } from "./helpers/IExpressionEntry";
15
16
  import { OptionPredicator } from "./helpers/OptionPredicator";
16
17
  import { check_everything } from "./internal/check_everything";
17
18
  import { check_object } from "./internal/check_object";
@@ -252,7 +253,14 @@ const combine =
252
253
  if (next.explore.tracable === false)
253
254
  return IsProgrammer.configure({
254
255
  options: {
255
- object: validate_object(props),
256
+ object: (v) =>
257
+ validate_object({
258
+ context: props.context,
259
+ importer: props.importer,
260
+ config: props.config,
261
+ entries: v.entries,
262
+ input: v.input,
263
+ }),
256
264
  numeric: true,
257
265
  },
258
266
  context: props.context,
@@ -301,42 +309,57 @@ const validate_object = (props: {
301
309
  config: ValidateProgrammer.IConfig;
302
310
  context: ITypiaContext;
303
311
  importer: FunctionImporter;
312
+ entries: IExpressionEntry<ts.Expression>[];
313
+ input: ts.Expression;
304
314
  }) =>
305
315
  check_object({
306
- equals: props.config.equals,
307
- undefined: true,
308
- assert: false,
309
- reduce: ts.factory.createLogicalAnd,
310
- positive: ts.factory.createTrue(),
311
- superfluous: (input) =>
312
- create_report_call({
313
- path: ts.factory.createAdd(
314
- ts.factory.createIdentifier("_path"),
315
- ts.factory.createCallExpression(
316
- props.importer.use("join"),
317
- undefined,
318
- [ts.factory.createIdentifier("key")],
316
+ config: {
317
+ equals: props.config.equals,
318
+ undefined: true,
319
+ assert: false,
320
+ reduce: ts.factory.createLogicalAnd,
321
+ positive: ts.factory.createTrue(),
322
+ superfluous: (input) =>
323
+ create_report_call({
324
+ path: ts.factory.createAdd(
325
+ ts.factory.createIdentifier("_path"),
326
+ ts.factory.createCallExpression(
327
+ props.importer.use("join"),
328
+ undefined,
329
+ [ts.factory.createIdentifier("key")],
330
+ ),
319
331
  ),
332
+ expected: "undefined",
333
+ input,
334
+ }),
335
+ halt: (expr) =>
336
+ ts.factory.createLogicalOr(
337
+ ts.factory.createStrictEquality(
338
+ ts.factory.createFalse(),
339
+ ts.factory.createIdentifier("_exceptionable"),
340
+ ),
341
+ expr,
320
342
  ),
321
- expected: "undefined",
322
- input,
323
- }),
324
- halt: (expr) =>
325
- ts.factory.createLogicalOr(
326
- ts.factory.createStrictEquality(
327
- ts.factory.createFalse(),
328
- ts.factory.createIdentifier("_exceptionable"),
329
- ),
330
- expr,
331
- ),
332
- })(props.context)(props.importer);
343
+ },
344
+ context: props.context,
345
+ importer: props.importer,
346
+ entries: props.entries,
347
+ input: props.input,
348
+ });
333
349
 
334
350
  const joiner = (props: {
335
351
  config: ValidateProgrammer.IConfig;
336
352
  context: ITypiaContext;
337
353
  importer: FunctionImporter;
338
354
  }): CheckerProgrammer.IConfig.IJoiner => ({
339
- object: validate_object(props),
355
+ object: (v) =>
356
+ validate_object({
357
+ context: props.context,
358
+ importer: props.importer,
359
+ config: props.config,
360
+ entries: v.entries,
361
+ input: v.input,
362
+ }),
340
363
  array: (props) =>
341
364
  check_everything(
342
365
  ts.factory.createCallExpression(
@@ -68,7 +68,10 @@ export namespace CloneJoiner {
68
68
  ts.factory.createIfStatement(
69
69
  ts.factory.createCallExpression(
70
70
  ts.factory.createIdentifier(
71
- `RegExp(/${metadata_to_pattern(true)(entry.key)}/).test`,
71
+ `RegExp(/${metadata_to_pattern({
72
+ top: true,
73
+ metadata: entry.key,
74
+ })}/).test`,
72
75
  ),
73
76
  undefined,
74
77
  [key],
@@ -10,103 +10,105 @@ import { metadata_to_pattern } from "../internal/metadata_to_pattern";
10
10
  import { IExpressionEntry } from "./IExpressionEntry";
11
11
 
12
12
  export namespace NotationJoiner {
13
- export const object =
14
- (rename: (str: string) => string) =>
15
- (props: {
16
- input: ts.Expression;
17
- entries: IExpressionEntry<ts.Expression>[];
18
- }): ts.ConciseBody => {
19
- if (props.entries.length === 0) return ts.factory.createIdentifier("{}");
13
+ export const object = (props: {
14
+ rename: (str: string) => string;
15
+ input: ts.Expression;
16
+ entries: IExpressionEntry<ts.Expression>[];
17
+ }): ts.ConciseBody => {
18
+ if (props.entries.length === 0) return ts.factory.createIdentifier("{}");
20
19
 
21
- const regular = props.entries.filter((e) => e.key.isSoleLiteral());
22
- const dynamic = props.entries.filter((e) => !e.key.isSoleLiteral());
23
- const literal = ts.factory.createObjectLiteralExpression(
24
- regular.map((entry) => {
25
- const str: string = rename(entry.key.getSoleLiteral()!);
26
- return ts.factory.createPropertyAssignment(
27
- Escaper.variable(str) ? str : ts.factory.createStringLiteral(str),
28
- entry.expression,
29
- );
30
- }),
31
- true,
32
- );
33
- if (dynamic.length === 0) return literal;
20
+ const regular = props.entries.filter((e) => e.key.isSoleLiteral());
21
+ const dynamic = props.entries.filter((e) => !e.key.isSoleLiteral());
22
+ const literal = ts.factory.createObjectLiteralExpression(
23
+ regular.map((entry) => {
24
+ const str: string = props.rename(entry.key.getSoleLiteral()!);
25
+ return ts.factory.createPropertyAssignment(
26
+ Escaper.variable(str) ? str : ts.factory.createStringLiteral(str),
27
+ entry.expression,
28
+ );
29
+ }),
30
+ true,
31
+ );
32
+ if (dynamic.length === 0) return literal;
34
33
 
35
- const key = ts.factory.createIdentifier("key");
36
- const output = ts.factory.createIdentifier("output");
34
+ const key = ts.factory.createIdentifier("key");
35
+ const output = ts.factory.createIdentifier("output");
37
36
 
38
- const statements: ts.Statement[] = [];
39
- if (regular.length !== 0)
40
- statements.push(
41
- ts.factory.createIfStatement(
42
- ts.factory.createCallExpression(
43
- IdentifierFactory.access(
44
- ts.factory.createArrayLiteralExpression(
45
- regular.map((r) =>
46
- ts.factory.createStringLiteral(r.key.getSoleLiteral()!),
47
- ),
48
- ),
49
- )("some"),
50
- undefined,
51
- [
52
- ts.factory.createArrowFunction(
53
- undefined,
54
- undefined,
55
- [IdentifierFactory.parameter("regular")],
56
- undefined,
57
- undefined,
58
- ts.factory.createStrictEquality(
59
- ts.factory.createIdentifier("regular"),
60
- ts.factory.createIdentifier("key"),
61
- ),
62
- ),
63
- ],
64
- ),
65
- ts.factory.createContinueStatement(),
66
- ),
67
- );
37
+ const statements: ts.Statement[] = [];
38
+ if (regular.length !== 0)
68
39
  statements.push(
69
- ...dynamic.map((entry) =>
70
- ts.factory.createIfStatement(
71
- ts.factory.createCallExpression(
72
- ts.factory.createIdentifier(
73
- `RegExp(/${metadata_to_pattern(true)(entry.key)}/).test`,
40
+ ts.factory.createIfStatement(
41
+ ts.factory.createCallExpression(
42
+ IdentifierFactory.access(
43
+ ts.factory.createArrayLiteralExpression(
44
+ regular.map((r) =>
45
+ ts.factory.createStringLiteral(r.key.getSoleLiteral()!),
46
+ ),
74
47
  ),
75
- undefined,
76
- [key],
77
- ),
78
- ts.factory.createBlock([
79
- ts.factory.createExpressionStatement(
80
- ts.factory.createBinaryExpression(
81
- ts.factory.createElementAccessExpression(output, key),
82
- ts.factory.createToken(ts.SyntaxKind.EqualsToken),
83
- entry.expression,
48
+ )("some"),
49
+ undefined,
50
+ [
51
+ ts.factory.createArrowFunction(
52
+ undefined,
53
+ undefined,
54
+ [IdentifierFactory.parameter("regular")],
55
+ undefined,
56
+ undefined,
57
+ ts.factory.createStrictEquality(
58
+ ts.factory.createIdentifier("regular"),
59
+ ts.factory.createIdentifier("key"),
84
60
  ),
85
61
  ),
86
- ts.factory.createContinueStatement(),
87
- ]),
62
+ ],
88
63
  ),
64
+ ts.factory.createContinueStatement(),
89
65
  ),
90
66
  );
91
-
92
- return ts.factory.createBlock([
93
- StatementFactory.constant(
94
- "output",
95
- ts.factory.createAsExpression(literal, TypeFactory.keyword("any")),
96
- ),
97
- ts.factory.createForOfStatement(
98
- undefined,
99
- StatementFactory.entry("key")("value"),
67
+ statements.push(
68
+ ...dynamic.map((entry) =>
69
+ ts.factory.createIfStatement(
100
70
  ts.factory.createCallExpression(
101
- ts.factory.createIdentifier("Object.entries"),
71
+ ts.factory.createIdentifier(
72
+ `RegExp(/${metadata_to_pattern({
73
+ top: true,
74
+ metadata: entry.key,
75
+ })}/).test`,
76
+ ),
102
77
  undefined,
103
- [props.input],
78
+ [key],
104
79
  ),
105
- ts.factory.createBlock(statements),
80
+ ts.factory.createBlock([
81
+ ts.factory.createExpressionStatement(
82
+ ts.factory.createBinaryExpression(
83
+ ts.factory.createElementAccessExpression(output, key),
84
+ ts.factory.createToken(ts.SyntaxKind.EqualsToken),
85
+ entry.expression,
86
+ ),
87
+ ),
88
+ ts.factory.createContinueStatement(),
89
+ ]),
106
90
  ),
107
- ts.factory.createReturnStatement(output),
108
- ]);
109
- };
91
+ ),
92
+ );
93
+
94
+ return ts.factory.createBlock([
95
+ StatementFactory.constant(
96
+ "output",
97
+ ts.factory.createAsExpression(literal, TypeFactory.keyword("any")),
98
+ ),
99
+ ts.factory.createForOfStatement(
100
+ undefined,
101
+ StatementFactory.entry("key")("value"),
102
+ ts.factory.createCallExpression(
103
+ ts.factory.createIdentifier("Object.entries"),
104
+ undefined,
105
+ [props.input],
106
+ ),
107
+ ts.factory.createBlock(statements),
108
+ ),
109
+ ts.factory.createReturnStatement(output),
110
+ ]);
111
+ };
110
112
 
111
113
  export const tuple = (props: {
112
114
  elements: ts.Expression[];
@@ -39,7 +39,7 @@ export namespace ProtobufUtil {
39
39
  return [...set].sort(compare);
40
40
  };
41
41
 
42
- export const getNumbers = (meta: Metadata) => {
42
+ export const getNumbers = (meta: Metadata): ProtobufAtomic.Numeric[] => {
43
43
  const set: Set<ProtobufAtomic.Numeric> = new Set();
44
44
  for (const c of meta.constants)
45
45
  if (c.type === "number")
@@ -50,7 +50,7 @@ export namespace ProtobufUtil {
50
50
  return [...set].sort(compare);
51
51
  };
52
52
 
53
- export const getBigints = (meta: Metadata) => {
53
+ export const getBigints = (meta: Metadata): ProtobufAtomic.BigNumeric[] => {
54
54
  const set: Set<ProtobufAtomic.BigNumeric> = new Set();
55
55
  for (const c of meta.constants) if (c.type === "bigint") set.add("uint64");
56
56
  for (const atomic of meta.atomics)
@@ -124,7 +124,10 @@ const iterate_dynamic_properties = (props: {
124
124
  ts.factory.createIfStatement(
125
125
  ts.factory.createCallExpression(
126
126
  ts.factory.createIdentifier(
127
- `RegExp(/${metadata_to_pattern(true)(dynamic.key)}/).test`,
127
+ `RegExp(/${metadata_to_pattern({
128
+ top: true,
129
+ metadata: dynamic.key,
130
+ })}/).test`,
128
131
  ),
129
132
  undefined,
130
133
  [ts.factory.createIdentifier("key")],