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.
- package/lib/index.mjs +1 -0
- package/lib/index.mjs.map +1 -1
- package/lib/programmers/AssertProgrammer.d.ts +1 -1
- package/lib/programmers/AssertProgrammer.js +169 -127
- package/lib/programmers/AssertProgrammer.js.map +1 -1
- package/lib/programmers/CheckerProgrammer.d.ts +70 -15
- package/lib/programmers/CheckerProgrammer.js +998 -638
- package/lib/programmers/CheckerProgrammer.js.map +1 -1
- package/lib/programmers/FeatureProgrammer.d.ts +7 -3
- package/lib/programmers/FeatureProgrammer.js +17 -17
- package/lib/programmers/FeatureProgrammer.js.map +1 -1
- package/lib/programmers/IsProgrammer.d.ts +25 -4
- package/lib/programmers/IsProgrammer.js +54 -39
- package/lib/programmers/IsProgrammer.js.map +1 -1
- package/lib/programmers/ValidateProgrammer.js +110 -97
- package/lib/programmers/ValidateProgrammer.js.map +1 -1
- package/lib/programmers/helpers/UnionExplorer.d.ts +1 -1
- package/lib/programmers/json/JsonStringifyProgrammer.js +71 -38
- package/lib/programmers/json/JsonStringifyProgrammer.js.map +1 -1
- package/lib/programmers/llm/LlmApplicationProgrammer.js +16 -2
- package/lib/programmers/llm/LlmApplicationProgrammer.js.map +1 -1
- package/lib/programmers/misc/MiscCloneProgrammer.js +504 -406
- package/lib/programmers/misc/MiscCloneProgrammer.js.map +1 -1
- package/lib/programmers/misc/MiscLiteralsProgrammer.js +3 -3
- package/lib/programmers/misc/MiscLiteralsProgrammer.js.map +1 -1
- package/lib/programmers/misc/MiscPruneProgrammer.js +365 -301
- package/lib/programmers/misc/MiscPruneProgrammer.js.map +1 -1
- package/lib/programmers/notations/NotationGeneralProgrammer.js +62 -15
- package/lib/programmers/notations/NotationGeneralProgrammer.js.map +1 -1
- package/lib/programmers/protobuf/ProtobufEncodeProgrammer.js +17 -3
- package/lib/programmers/protobuf/ProtobufEncodeProgrammer.js.map +1 -1
- package/lib/tags/Example.d.ts +14 -0
- package/lib/tags/Example.js +3 -0
- package/lib/tags/Example.js.map +1 -0
- package/lib/tags/Examples.d.ts +10 -0
- package/lib/tags/Examples.js +3 -0
- package/lib/tags/Examples.js.map +1 -0
- package/lib/tags/index.d.ts +2 -0
- package/lib/tags/index.js +2 -0
- package/lib/tags/index.js.map +1 -1
- package/package.json +2 -2
- package/src/programmers/AssertProgrammer.ts +185 -143
- package/src/programmers/CheckerProgrammer.ts +1380 -998
- package/src/programmers/FeatureProgrammer.ts +40 -34
- package/src/programmers/IsProgrammer.ts +94 -66
- package/src/programmers/ValidateProgrammer.ts +149 -137
- package/src/programmers/helpers/UnionExplorer.ts +1 -1
- package/src/programmers/json/JsonStringifyProgrammer.ts +60 -38
- package/src/programmers/llm/LlmApplicationProgrammer.ts +51 -32
- package/src/programmers/misc/MiscCloneProgrammer.ts +775 -600
- package/src/programmers/misc/MiscLiteralsProgrammer.ts +4 -4
- package/src/programmers/misc/MiscPruneProgrammer.ts +532 -415
- package/src/programmers/notations/NotationGeneralProgrammer.ts +64 -26
- package/src/programmers/protobuf/ProtobufEncodeProgrammer.ts +16 -9
- package/src/tags/Example.ts +17 -0
- package/src/tags/Examples.ts +16 -0
- 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
|
-
|
|
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(
|
|
239
|
-
|
|
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
|
-
(
|
|
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(
|
|
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(
|
|
314
|
-
|
|
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
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
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: (
|
|
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: () =>
|
|
48
|
+
combiner: (next) => {
|
|
46
49
|
const initial: ts.TrueLiteral | ts.FalseLiteral =
|
|
47
|
-
|
|
50
|
+
next.logic === "and"
|
|
51
|
+
? ts.factory.createTrue()
|
|
52
|
+
: ts.factory.createFalse();
|
|
48
53
|
const binder =
|
|
49
|
-
|
|
54
|
+
next.logic === "and"
|
|
50
55
|
? ts.factory.createLogicalAnd
|
|
51
56
|
: ts.factory.createLogicalOr;
|
|
52
|
-
return
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
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
|
-
|
|
199
|
-
|
|
200
|
-
export const decode =
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
(
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
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: (
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
|
96
|
-
joiner: joiner(props
|
|
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
|
-
(
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
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(
|
|
254
|
+
object: validate_object(props),
|
|
253
255
|
numeric: true,
|
|
254
|
-
})(
|
|
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
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
.
|
|
263
|
-
binary.
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
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
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
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
|
-
|
|
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
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
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
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
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
|
-
|
|
326
|
+
expr,
|
|
327
|
+
),
|
|
328
|
+
})(props.context)(props.importer);
|
|
317
329
|
|
|
318
|
-
const joiner =
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
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
|
-
|
|
332
|
-
|
|
333
|
-
|
|
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
|
-
|
|
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
|
-
|
|
344
|
-
|
|
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
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
ts.factory.
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
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
|
+
);
|