typia 7.0.0-dev.20240923 → 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 (57) 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 +7 -3
  10. package/lib/programmers/FeatureProgrammer.js +17 -17
  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 +71 -38
  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 +504 -406
  23. package/lib/programmers/misc/MiscCloneProgrammer.js.map +1 -1
  24. package/lib/programmers/misc/MiscLiteralsProgrammer.js +3 -3
  25. package/lib/programmers/misc/MiscLiteralsProgrammer.js.map +1 -1
  26. package/lib/programmers/misc/MiscPruneProgrammer.js +365 -301
  27. package/lib/programmers/misc/MiscPruneProgrammer.js.map +1 -1
  28. package/lib/programmers/notations/NotationGeneralProgrammer.js +62 -15
  29. package/lib/programmers/notations/NotationGeneralProgrammer.js.map +1 -1
  30. package/lib/programmers/protobuf/ProtobufEncodeProgrammer.js +17 -3
  31. package/lib/programmers/protobuf/ProtobufEncodeProgrammer.js.map +1 -1
  32. package/lib/tags/Example.d.ts +14 -0
  33. package/lib/tags/Example.js +3 -0
  34. package/lib/tags/Example.js.map +1 -0
  35. package/lib/tags/Examples.d.ts +10 -0
  36. package/lib/tags/Examples.js +3 -0
  37. package/lib/tags/Examples.js.map +1 -0
  38. package/lib/tags/index.d.ts +2 -0
  39. package/lib/tags/index.js +2 -0
  40. package/lib/tags/index.js.map +1 -1
  41. package/package.json +2 -2
  42. package/src/programmers/AssertProgrammer.ts +185 -143
  43. package/src/programmers/CheckerProgrammer.ts +1380 -998
  44. package/src/programmers/FeatureProgrammer.ts +40 -34
  45. package/src/programmers/IsProgrammer.ts +94 -66
  46. package/src/programmers/ValidateProgrammer.ts +149 -137
  47. package/src/programmers/helpers/UnionExplorer.ts +1 -1
  48. package/src/programmers/json/JsonStringifyProgrammer.ts +60 -38
  49. package/src/programmers/llm/LlmApplicationProgrammer.ts +51 -32
  50. package/src/programmers/misc/MiscCloneProgrammer.ts +775 -600
  51. package/src/programmers/misc/MiscLiteralsProgrammer.ts +4 -4
  52. package/src/programmers/misc/MiscPruneProgrammer.ts +532 -415
  53. package/src/programmers/notations/NotationGeneralProgrammer.ts +64 -26
  54. package/src/programmers/protobuf/ProtobufEncodeProgrammer.ts +16 -9
  55. package/src/tags/Example.ts +17 -0
  56. package/src/tags/Examples.ts +16 -0
  57. package/src/tags/index.ts +20 -18
@@ -46,7 +46,7 @@ export namespace FeatureProgrammer {
46
46
  * Initializer of metadata.
47
47
  */
48
48
  initializer: (
49
- project: ITypiaContext,
49
+ context: ITypiaContext,
50
50
  ) => (
51
51
  importer: FunctionImporter,
52
52
  ) => (type: ts.Type) => [MetadataCollection, Metadata];
@@ -234,9 +234,12 @@ export namespace FeatureProgrammer {
234
234
  functions: {
235
235
  ...Object.fromEntries(
236
236
  (
237
- props.config.generator.objects?.() ??
238
- write_object_functions(props.config)(props.importer)
239
- )(collection).map((v, i) => [`${props.config.prefix}o${i}`, v]),
237
+ props.config.generator.objects?.()(collection) ??
238
+ write_object_functions({
239
+ ...props,
240
+ collection,
241
+ })
242
+ ).map((v, i) => [`${props.config.prefix}o${i}`, v]),
240
243
  ),
241
244
  ...Object.fromEntries(
242
245
  (
@@ -288,11 +291,11 @@ export namespace FeatureProgrammer {
288
291
  );
289
292
 
290
293
  export const write =
291
- (project: ITypiaContext) =>
294
+ (context: ITypiaContext) =>
292
295
  (config: IConfig) =>
293
296
  (importer: FunctionImporter) =>
294
297
  (type: ts.Type, name?: string): ts.ArrowFunction => {
295
- const [collection, meta] = config.initializer(project)(importer)(type);
298
+ const [collection, meta] = config.initializer(context)(importer)(type);
296
299
 
297
300
  // ITERATE OVER ALL METADATA
298
301
  const output: ts.ConciseBody = config.decoder()(
@@ -308,10 +311,13 @@ export namespace FeatureProgrammer {
308
311
 
309
312
  // RETURNS THE OPTIMAL ARROW FUNCTION
310
313
  const functions = {
311
- objects: (
312
- config.generator.objects?.() ??
313
- write_object_functions(config)(importer)
314
- )(collection),
314
+ objects:
315
+ config.generator.objects?.()(collection) ??
316
+ write_object_functions({
317
+ config,
318
+ importer,
319
+ collection,
320
+ }),
315
321
  unions: (config.generator.unions?.() ?? write_union_functions(config))(
316
322
  collection,
317
323
  ),
@@ -352,31 +358,32 @@ export namespace FeatureProgrammer {
352
358
  );
353
359
  };
354
360
 
355
- export const write_object_functions =
356
- (config: IConfig) =>
357
- (importer: FunctionImporter) =>
358
- (collection: MetadataCollection) =>
359
- collection.objects().map((object) =>
360
- StatementFactory.constant(
361
- `${config.prefix}o${object.index}`,
362
- ts.factory.createArrowFunction(
363
- undefined,
364
- undefined,
365
- parameterDeclarations(config)(TypeFactory.keyword("any"))(
366
- ValueFactory.INPUT(),
367
- ),
368
- config.objector.type ?? TypeFactory.keyword("any"),
369
- undefined,
370
- config.objector.joiner({
371
- input: ts.factory.createIdentifier("input"),
372
- entries: feature_object_entries(config)(importer)(object)(
373
- ts.factory.createIdentifier("input"),
374
- ),
375
- object,
376
- }),
361
+ export const write_object_functions = (props: {
362
+ config: IConfig;
363
+ importer: FunctionImporter;
364
+ collection: MetadataCollection;
365
+ }) =>
366
+ props.collection.objects().map((object) =>
367
+ StatementFactory.constant(
368
+ `${props.config.prefix}o${object.index}`,
369
+ ts.factory.createArrowFunction(
370
+ undefined,
371
+ undefined,
372
+ parameterDeclarations(props.config)(TypeFactory.keyword("any"))(
373
+ ValueFactory.INPUT(),
377
374
  ),
375
+ props.config.objector.type ?? TypeFactory.keyword("any"),
376
+ undefined,
377
+ props.config.objector.joiner({
378
+ input: ts.factory.createIdentifier("input"),
379
+ entries: feature_object_entries(props.config)(props.importer)(
380
+ object,
381
+ )(ts.factory.createIdentifier("input")),
382
+ object,
383
+ }),
378
384
  ),
379
- );
385
+ ),
386
+ );
380
387
 
381
388
  export const write_union_functions =
382
389
  (config: IConfig) => (collection: MetadataCollection) =>
@@ -433,7 +440,6 @@ export namespace FeatureProgrammer {
433
440
  ),
434
441
  ]
435
442
  : [];
436
-
437
443
  return (
438
444
  input: ts.Expression,
439
445
  array: MetadataArray,
@@ -5,6 +5,9 @@ import { IdentifierFactory } from "../factories/IdentifierFactory";
5
5
  import { MetadataCollection } from "../factories/MetadataCollection";
6
6
  import { ValueFactory } from "../factories/ValueFactory";
7
7
 
8
+ import { Metadata } from "../schemas/metadata/Metadata";
9
+ import { MetadataObject } from "../schemas/metadata/MetadataObject";
10
+
8
11
  import { IProgrammerProps } from "../transformers/IProgrammerProps";
9
12
  import { ITypiaContext } from "../transformers/ITypiaContext";
10
13
 
@@ -27,7 +30,7 @@ export namespace IsProgrammer {
27
30
  numeric: OptionPredicator.numeric({
28
31
  numeric: options?.numeric,
29
32
  }),
30
- atomist: () => (entry) => () =>
33
+ atomist: ({ entry }) =>
31
34
  [
32
35
  ...(entry.expression ? [entry.expression] : []),
33
36
  ...(entry.conditions.length === 0
@@ -42,22 +45,18 @@ export namespace IsProgrammer {
42
45
  .reduce((a, b) => ts.factory.createLogicalOr(a, b)),
43
46
  ]),
44
47
  ].reduce((x, y) => ts.factory.createLogicalAnd(x, y)),
45
- combiner: () => (type: "and" | "or") => {
48
+ combiner: (next) => {
46
49
  const initial: ts.TrueLiteral | ts.FalseLiteral =
47
- type === "and" ? ts.factory.createTrue() : ts.factory.createFalse();
50
+ next.logic === "and"
51
+ ? ts.factory.createTrue()
52
+ : ts.factory.createFalse();
48
53
  const binder =
49
- type === "and"
54
+ next.logic === "and"
50
55
  ? ts.factory.createLogicalAnd
51
56
  : ts.factory.createLogicalOr;
52
- return (
53
- _input: ts.Expression,
54
- binaries: CheckerProgrammer.IBinary[],
55
- ) =>
56
- binaries.length
57
- ? binaries
58
- .map((binary) => binary.expression)
59
- .reduce((x, y) => binder(x, y))
60
- : initial;
57
+ return next.binaries.length
58
+ ? next.binaries.map((binary) => binary.expression).reduce(binder)
59
+ : initial;
61
60
  },
62
61
  joiner: {
63
62
  object:
@@ -164,62 +163,91 @@ export namespace IsProgrammer {
164
163
  });
165
164
  };
166
165
 
167
- export const write_function_statements =
168
- (project: ITypiaContext) =>
169
- (importer: FunctionImporter) =>
170
- (collection: MetadataCollection) => {
171
- const config = configure()(project)(importer);
172
- const objects =
173
- CheckerProgrammer.write_object_functions(project)(config)(importer)(
174
- collection,
175
- );
176
- const unions =
177
- CheckerProgrammer.write_union_functions(project)(config)(importer)(
178
- collection,
179
- );
180
- const arrays =
181
- CheckerProgrammer.write_array_functions(project)(config)(importer)(
182
- collection,
183
- );
184
- const tuples =
185
- CheckerProgrammer.write_tuple_functions(project)(config)(importer)(
186
- collection,
187
- );
188
-
189
- return [
190
- ...objects.filter((_, i) => importer.hasLocal(`${config.prefix}o${i}`)),
191
- ...unions.filter((_, i) => importer.hasLocal(`${config.prefix}u${i}`)),
192
- ...arrays.filter((_, i) => importer.hasLocal(`${config.prefix}a${i}`)),
193
- ...tuples.filter((_, i) => importer.hasLocal(`${config.prefix}t${i}`)),
194
- ];
166
+ export const write_function_statements = (props: {
167
+ context: ITypiaContext;
168
+ importer: FunctionImporter;
169
+ collection: MetadataCollection;
170
+ }) => {
171
+ const config: CheckerProgrammer.IConfig = configure()(props.context)(
172
+ props.importer,
173
+ );
174
+ const next = {
175
+ ...props,
176
+ config,
195
177
  };
178
+ const objects: ts.VariableStatement[] =
179
+ CheckerProgrammer.write_object_functions(next);
180
+ const unions: ts.VariableStatement[] =
181
+ CheckerProgrammer.write_union_functions(next);
182
+ const arrays: ts.VariableStatement[] =
183
+ CheckerProgrammer.write_array_functions(next);
184
+ const tuples: ts.VariableStatement[] =
185
+ CheckerProgrammer.write_tuple_functions(next);
186
+
187
+ return [
188
+ ...objects.filter((_, i) =>
189
+ props.importer.hasLocal(`${config.prefix}o${i}`),
190
+ ),
191
+ ...unions.filter((_, i) =>
192
+ props.importer.hasLocal(`${config.prefix}u${i}`),
193
+ ),
194
+ ...arrays.filter((_, i) =>
195
+ props.importer.hasLocal(`${config.prefix}a${i}`),
196
+ ),
197
+ ...tuples.filter((_, i) =>
198
+ props.importer.hasLocal(`${config.prefix}t${i}`),
199
+ ),
200
+ ];
201
+ };
196
202
 
197
203
  /* -----------------------------------------------------------
198
- DECODERS
199
- ----------------------------------------------------------- */
200
- export const decode =
201
- (project: ITypiaContext) => (importer: FunctionImporter) =>
202
- CheckerProgrammer.decode(project)(configure()(project)(importer))(
203
- importer,
204
- );
205
-
206
- export const decode_object =
207
- (project: ITypiaContext) => (importer: FunctionImporter) =>
208
- CheckerProgrammer.decode_object(configure()(project)(importer))(importer);
209
-
210
- export const decode_to_json =
211
- (checkNull: boolean) =>
212
- (input: ts.Expression): ts.Expression =>
213
- ts.factory.createLogicalAnd(
214
- ExpressionFactory.isObject({
215
- checkArray: false,
216
- checkNull,
217
- })(input),
218
- ts.factory.createStrictEquality(
219
- ts.factory.createStringLiteral("function"),
220
- ValueFactory.TYPEOF(IdentifierFactory.access(input)("toJSON")),
221
- ),
222
- );
204
+ DECODERS
205
+ ----------------------------------------------------------- */
206
+ export const decode = (props: {
207
+ context: ITypiaContext;
208
+ importer: FunctionImporter;
209
+ metadata: Metadata;
210
+ input: ts.Expression;
211
+ explore: CheckerProgrammer.IExplore;
212
+ }) =>
213
+ CheckerProgrammer.decode({
214
+ context: props.context,
215
+ config: configure()(props.context)(props.importer),
216
+ importer: props.importer,
217
+ metadata: props.metadata,
218
+ input: props.input,
219
+ explore: props.explore,
220
+ });
221
+
222
+ export const decode_object = (props: {
223
+ context: ITypiaContext;
224
+ importer: FunctionImporter;
225
+ object: MetadataObject;
226
+ input: ts.Expression;
227
+ explore: FeatureProgrammer.IExplore;
228
+ }) =>
229
+ CheckerProgrammer.decode_object({
230
+ config: configure()(props.context)(props.importer),
231
+ importer: props.importer,
232
+ object: props.object,
233
+ input: props.input,
234
+ explore: props.explore,
235
+ });
236
+
237
+ export const decode_to_json = (props: {
238
+ input: ts.Expression;
239
+ checkNull: boolean;
240
+ }): ts.Expression =>
241
+ ts.factory.createLogicalAnd(
242
+ ExpressionFactory.isObject({
243
+ checkArray: false,
244
+ checkNull: props.checkNull,
245
+ })(props.input),
246
+ ts.factory.createStrictEquality(
247
+ ts.factory.createStringLiteral("function"),
248
+ ValueFactory.TYPEOF(IdentifierFactory.access(props.input)("toJSON")),
249
+ ),
250
+ );
223
251
 
224
252
  export const decode_functional = (input: ts.Expression) =>
225
253
  ts.factory.createStrictEquality(
@@ -41,33 +41,33 @@ export namespace ValidateProgrammer {
41
41
  trace: true,
42
42
  numeric: OptionPredicator.numeric(props.context.options),
43
43
  equals: props.config.equals,
44
- atomist: (explore) => (entry) => (input) =>
44
+ atomist: (next) =>
45
45
  [
46
- ...(entry.expression ? [entry.expression] : []),
47
- ...(entry.conditions.length === 0
46
+ ...(next.entry.expression ? [next.entry.expression] : []),
47
+ ...(next.entry.conditions.length === 0
48
48
  ? []
49
- : entry.conditions.length === 1
50
- ? entry.conditions[0]!.map((cond) =>
49
+ : next.entry.conditions.length === 1
50
+ ? next.entry.conditions[0]!.map((cond) =>
51
51
  ts.factory.createLogicalOr(
52
52
  cond.expression,
53
- create_report_call(
54
- explore.from === "top"
55
- ? ts.factory.createTrue()
56
- : ts.factory.createIdentifier("_exceptionable"),
57
- )(
58
- ts.factory.createIdentifier(
59
- explore.postfix
60
- ? `_path + ${explore.postfix}`
53
+ create_report_call({
54
+ exceptionable:
55
+ next.explore.from === "top"
56
+ ? ts.factory.createTrue()
57
+ : ts.factory.createIdentifier("_exceptionable"),
58
+ path: ts.factory.createIdentifier(
59
+ next.explore.postfix
60
+ ? `_path + ${next.explore.postfix}`
61
61
  : "_path",
62
62
  ),
63
- cond.expected,
64
- input,
65
- ),
63
+ expected: cond.expected,
64
+ input: next.input,
65
+ }),
66
66
  ),
67
67
  )
68
68
  : [
69
69
  ts.factory.createLogicalOr(
70
- entry.conditions
70
+ next.entry.conditions
71
71
  .map((set) =>
72
72
  set
73
73
  .map((s) => s.expression)
@@ -76,24 +76,24 @@ export namespace ValidateProgrammer {
76
76
  ),
77
77
  )
78
78
  .reduce((a, b) => ts.factory.createLogicalOr(a, b)),
79
- create_report_call(
80
- explore.from === "top"
81
- ? ts.factory.createTrue()
82
- : ts.factory.createIdentifier("_exceptionable"),
83
- )(
84
- ts.factory.createIdentifier(
85
- explore.postfix
86
- ? `_path + ${explore.postfix}`
79
+ create_report_call({
80
+ exceptionable:
81
+ next.explore.from === "top"
82
+ ? ts.factory.createTrue()
83
+ : ts.factory.createIdentifier("_exceptionable"),
84
+ path: ts.factory.createIdentifier(
85
+ next.explore.postfix
86
+ ? `_path + ${next.explore.postfix}`
87
87
  : "_path",
88
88
  ),
89
- entry.expected,
90
- input,
91
- ),
89
+ expected: next.entry.expected,
90
+ input: next.input,
91
+ }),
92
92
  ),
93
93
  ]),
94
94
  ].reduce((x, y) => ts.factory.createLogicalAnd(x, y)),
95
- combiner: combine(props.config.equals)(props.context)(props.importer),
96
- joiner: joiner(props.config.equals)(props.context)(props.importer),
95
+ combiner: combine(props),
96
+ joiner: joiner(props),
97
97
  success: ts.factory.createTrue(),
98
98
  },
99
99
  });
@@ -243,106 +243,119 @@ export namespace ValidateProgrammer {
243
243
  }
244
244
 
245
245
  const combine =
246
- (equals: boolean) =>
247
- (project: ITypiaContext) =>
248
- (importer: FunctionImporter): CheckerProgrammer.IConfig.Combiner =>
249
- (explore: CheckerProgrammer.IExplore) => {
250
- if (explore.tracable === false)
246
+ (props: {
247
+ config: ValidateProgrammer.IConfig;
248
+ context: ITypiaContext;
249
+ importer: FunctionImporter;
250
+ }): CheckerProgrammer.IConfig.Combiner =>
251
+ (next) => {
252
+ if (next.explore.tracable === false)
251
253
  return IsProgrammer.configure({
252
- object: validate_object(equals)(project)(importer),
254
+ object: validate_object(props),
253
255
  numeric: true,
254
- })(project)(importer).combiner(explore);
256
+ })(props.context)(props.importer).combiner(next);
255
257
 
256
- const path: string = explore.postfix
257
- ? `_path + ${explore.postfix}`
258
+ const path: string = next.explore.postfix
259
+ ? `_path + ${next.explore.postfix}`
258
260
  : "_path";
259
- return (logic) => (input, binaries, expected) =>
260
- logic === "and"
261
- ? binaries
262
- .map((binary) =>
263
- binary.combined
264
- ? binary.expression
265
- : ts.factory.createLogicalOr(
266
- binary.expression,
267
- create_report_call(
268
- explore.source === "top"
261
+ return next.logic === "and"
262
+ ? next.binaries
263
+ .map((binary) =>
264
+ binary.combined
265
+ ? binary.expression
266
+ : ts.factory.createLogicalOr(
267
+ binary.expression,
268
+ create_report_call({
269
+ exceptionable:
270
+ next.explore.source === "top"
269
271
  ? ts.factory.createTrue()
270
272
  : ts.factory.createIdentifier("_exceptionable"),
271
- )(ts.factory.createIdentifier(path), expected, input),
272
- ),
273
- )
274
- .reduce(ts.factory.createLogicalAnd)
275
- : ts.factory.createLogicalOr(
276
- binaries
277
- .map((binary) => binary.expression)
278
- .reduce(ts.factory.createLogicalOr),
279
- create_report_call(
280
- explore.source === "top"
273
+ path: ts.factory.createIdentifier(path),
274
+ expected: next.expected,
275
+ input: next.input,
276
+ }),
277
+ ),
278
+ )
279
+ .reduce(ts.factory.createLogicalAnd)
280
+ : ts.factory.createLogicalOr(
281
+ next.binaries
282
+ .map((binary) => binary.expression)
283
+ .reduce(ts.factory.createLogicalOr),
284
+ create_report_call({
285
+ exceptionable:
286
+ next.explore.source === "top"
281
287
  ? ts.factory.createTrue()
282
288
  : ts.factory.createIdentifier("_exceptionable"),
283
- )(ts.factory.createIdentifier(path), expected, input),
284
- );
289
+ path: ts.factory.createIdentifier(path),
290
+ expected: next.expected,
291
+ input: next.input,
292
+ }),
293
+ );
285
294
  };
286
295
 
287
- const validate_object =
288
- (equals: boolean) =>
289
- (project: ITypiaContext) =>
290
- (importer: FunctionImporter) =>
291
- check_object({
292
- equals,
293
- undefined: true,
294
- assert: false,
295
- reduce: ts.factory.createLogicalAnd,
296
- positive: ts.factory.createTrue(),
297
- superfluous: (value) =>
298
- create_report_call()(
299
- ts.factory.createAdd(
300
- ts.factory.createIdentifier("_path"),
301
- ts.factory.createCallExpression(importer.use("join"), undefined, [
302
- ts.factory.createIdentifier("key"),
303
- ]),
296
+ const validate_object = (props: {
297
+ config: ValidateProgrammer.IConfig;
298
+ context: ITypiaContext;
299
+ importer: FunctionImporter;
300
+ }) =>
301
+ check_object({
302
+ equals: props.config.equals,
303
+ undefined: true,
304
+ assert: false,
305
+ reduce: ts.factory.createLogicalAnd,
306
+ positive: ts.factory.createTrue(),
307
+ superfluous: (input) =>
308
+ create_report_call({
309
+ path: ts.factory.createAdd(
310
+ ts.factory.createIdentifier("_path"),
311
+ ts.factory.createCallExpression(
312
+ props.importer.use("join"),
313
+ undefined,
314
+ [ts.factory.createIdentifier("key")],
304
315
  ),
305
- "undefined",
306
- value,
307
316
  ),
308
- halt: (expr) =>
309
- ts.factory.createLogicalOr(
310
- ts.factory.createStrictEquality(
311
- ts.factory.createFalse(),
312
- ts.factory.createIdentifier("_exceptionable"),
313
- ),
314
- expr,
317
+ expected: "undefined",
318
+ input,
319
+ }),
320
+ halt: (expr) =>
321
+ ts.factory.createLogicalOr(
322
+ ts.factory.createStrictEquality(
323
+ ts.factory.createFalse(),
324
+ ts.factory.createIdentifier("_exceptionable"),
315
325
  ),
316
- })(project)(importer);
326
+ expr,
327
+ ),
328
+ })(props.context)(props.importer);
317
329
 
318
- const joiner =
319
- (equals: boolean) =>
320
- (project: ITypiaContext) =>
321
- (importer: FunctionImporter): CheckerProgrammer.IConfig.IJoiner => ({
322
- object: validate_object(equals)(project)(importer),
323
- array: (props) =>
324
- check_everything(
325
- ts.factory.createCallExpression(
326
- IdentifierFactory.access(props.input)("map"),
327
- undefined,
328
- [props.arrow],
329
- ),
330
+ const joiner = (props: {
331
+ config: ValidateProgrammer.IConfig;
332
+ context: ITypiaContext;
333
+ importer: FunctionImporter;
334
+ }): CheckerProgrammer.IConfig.IJoiner => ({
335
+ object: validate_object(props),
336
+ array: (props) =>
337
+ check_everything(
338
+ ts.factory.createCallExpression(
339
+ IdentifierFactory.access(props.input)("map"),
340
+ undefined,
341
+ [props.arrow],
330
342
  ),
331
- failure: (value, expected, explore) =>
332
- create_report_call(
333
- explore?.from === "top"
343
+ ),
344
+ failure: (next) =>
345
+ create_report_call({
346
+ exceptionable:
347
+ next.explore?.from === "top"
334
348
  ? ts.factory.createTrue()
335
349
  : ts.factory.createIdentifier("_exceptionable"),
336
- )(
337
- ts.factory.createIdentifier(
338
- explore?.postfix ? `_path + ${explore.postfix}` : "_path",
339
- ),
340
- expected,
341
- value,
350
+ path: ts.factory.createIdentifier(
351
+ next.explore?.postfix ? `_path + ${next.explore.postfix}` : "_path",
342
352
  ),
343
- tuple: (binaries) =>
344
- check_everything(ts.factory.createArrayLiteralExpression(binaries, true)),
345
- });
353
+ expected: next.expected,
354
+ input: next.input,
355
+ }),
356
+ tuple: (binaries) =>
357
+ check_everything(ts.factory.createArrayLiteralExpression(binaries, true)),
358
+ });
346
359
 
347
360
  const create_output = () =>
348
361
  ts.factory.createObjectLiteralExpression(
@@ -363,28 +376,27 @@ const create_output = () =>
363
376
  true,
364
377
  );
365
378
 
366
- const create_report_call =
367
- (exceptionable?: ts.Expression) =>
368
- (
369
- path: ts.Expression,
370
- expected: string,
371
- value: ts.Expression,
372
- ): ts.Expression =>
373
- ts.factory.createCallExpression(
374
- ts.factory.createIdentifier("$report"),
375
- undefined,
376
- [
377
- exceptionable ?? ts.factory.createIdentifier("_exceptionable"),
378
- ts.factory.createObjectLiteralExpression(
379
- [
380
- ts.factory.createPropertyAssignment("path", path),
381
- ts.factory.createPropertyAssignment(
382
- "expected",
383
- ts.factory.createStringLiteral(expected),
384
- ),
385
- ts.factory.createPropertyAssignment("value", value),
386
- ],
387
- true,
388
- ),
389
- ],
390
- );
379
+ const create_report_call = (props: {
380
+ exceptionable?: ts.Expression;
381
+ path: ts.Expression;
382
+ expected: string;
383
+ input: ts.Expression;
384
+ }): ts.Expression =>
385
+ ts.factory.createCallExpression(
386
+ ts.factory.createIdentifier("$report"),
387
+ undefined,
388
+ [
389
+ props.exceptionable ?? ts.factory.createIdentifier("_exceptionable"),
390
+ ts.factory.createObjectLiteralExpression(
391
+ [
392
+ ts.factory.createPropertyAssignment("path", props.path),
393
+ ts.factory.createPropertyAssignment(
394
+ "expected",
395
+ ts.factory.createStringLiteral(props.expected),
396
+ ),
397
+ ts.factory.createPropertyAssignment("value", props.input),
398
+ ],
399
+ true,
400
+ ),
401
+ ],
402
+ );
@@ -158,7 +158,7 @@ export namespace UnionExplorer {
158
158
  export namespace array_or_tuple {
159
159
  export type IProps = check_union_array_like.IProps<
160
160
  MetadataArray | MetadataTuple,
161
- Metadata
161
+ Metadata | MetadataTuple
162
162
  >;
163
163
  }
164
164