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
|
@@ -11,6 +11,7 @@ import { CheckerProgrammer } from "./CheckerProgrammer";
|
|
|
11
11
|
import { FeatureProgrammer } from "./FeatureProgrammer";
|
|
12
12
|
import { IsProgrammer } from "./IsProgrammer";
|
|
13
13
|
import { FunctionImporter } from "./helpers/FunctionImporter";
|
|
14
|
+
import { IExpressionEntry } from "./helpers/IExpressionEntry";
|
|
14
15
|
import { OptionPredicator } from "./helpers/OptionPredicator";
|
|
15
16
|
import { check_object } from "./internal/check_object";
|
|
16
17
|
|
|
@@ -24,8 +25,8 @@ export namespace AssertProgrammer {
|
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
export const decompose = (props: {
|
|
27
|
-
context: ITypiaContext;
|
|
28
28
|
config: IConfig;
|
|
29
|
+
context: ITypiaContext;
|
|
29
30
|
importer: FunctionImporter;
|
|
30
31
|
type: ts.Type;
|
|
31
32
|
name: string | undefined;
|
|
@@ -45,33 +46,34 @@ export namespace AssertProgrammer {
|
|
|
45
46
|
trace: true,
|
|
46
47
|
numeric: OptionPredicator.numeric(props.context.options),
|
|
47
48
|
equals: props.config.equals,
|
|
48
|
-
atomist: (
|
|
49
|
+
atomist: (next) =>
|
|
49
50
|
[
|
|
50
|
-
...(entry.expression ? [entry.expression] : []),
|
|
51
|
-
...(entry.conditions.length === 0
|
|
51
|
+
...(next.entry.expression ? [next.entry.expression] : []),
|
|
52
|
+
...(next.entry.conditions.length === 0
|
|
52
53
|
? []
|
|
53
|
-
: entry.conditions.length === 1
|
|
54
|
-
? entry.conditions[0]!.map((cond) =>
|
|
54
|
+
: next.entry.conditions.length === 1
|
|
55
|
+
? next.entry.conditions[0]!.map((cond) =>
|
|
55
56
|
ts.factory.createLogicalOr(
|
|
56
57
|
cond.expression,
|
|
57
|
-
create_guard_call(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
58
|
+
create_guard_call({
|
|
59
|
+
importer: props.importer,
|
|
60
|
+
exceptionable:
|
|
61
|
+
next.explore.from === "top"
|
|
62
|
+
? ts.factory.createTrue()
|
|
63
|
+
: ts.factory.createIdentifier("_exceptionable"),
|
|
64
|
+
path: ts.factory.createIdentifier(
|
|
65
|
+
next.explore.postfix
|
|
66
|
+
? `_path + ${next.explore.postfix}`
|
|
65
67
|
: "_path",
|
|
66
68
|
),
|
|
67
|
-
cond.expected,
|
|
68
|
-
input,
|
|
69
|
-
),
|
|
69
|
+
expected: cond.expected,
|
|
70
|
+
input: next.input,
|
|
71
|
+
}),
|
|
70
72
|
),
|
|
71
73
|
)
|
|
72
74
|
: [
|
|
73
75
|
ts.factory.createLogicalOr(
|
|
74
|
-
entry.conditions
|
|
76
|
+
next.entry.conditions
|
|
75
77
|
.map((set) =>
|
|
76
78
|
set
|
|
77
79
|
.map((s) => s.expression)
|
|
@@ -80,24 +82,25 @@ export namespace AssertProgrammer {
|
|
|
80
82
|
),
|
|
81
83
|
)
|
|
82
84
|
.reduce((a, b) => ts.factory.createLogicalOr(a, b)),
|
|
83
|
-
create_guard_call(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
85
|
+
create_guard_call({
|
|
86
|
+
importer: props.importer,
|
|
87
|
+
exceptionable:
|
|
88
|
+
next.explore.from === "top"
|
|
89
|
+
? ts.factory.createTrue()
|
|
90
|
+
: ts.factory.createIdentifier("_exceptionable"),
|
|
91
|
+
path: ts.factory.createIdentifier(
|
|
92
|
+
next.explore.postfix
|
|
93
|
+
? `_path + ${next.explore.postfix}`
|
|
91
94
|
: "_path",
|
|
92
95
|
),
|
|
93
|
-
entry.expected,
|
|
94
|
-
input,
|
|
95
|
-
),
|
|
96
|
+
expected: next.entry.expected,
|
|
97
|
+
input: next.input,
|
|
98
|
+
}),
|
|
96
99
|
),
|
|
97
100
|
]),
|
|
98
101
|
].reduce((x, y) => ts.factory.createLogicalAnd(x, y)),
|
|
99
|
-
combiner: combiner(props
|
|
100
|
-
joiner: joiner(props
|
|
102
|
+
combiner: combiner(props),
|
|
103
|
+
joiner: joiner(props),
|
|
101
104
|
success: ts.factory.createTrue(),
|
|
102
105
|
},
|
|
103
106
|
});
|
|
@@ -176,7 +179,6 @@ export namespace AssertProgrammer {
|
|
|
176
179
|
true,
|
|
177
180
|
),
|
|
178
181
|
);
|
|
179
|
-
|
|
180
182
|
return {
|
|
181
183
|
functions: {
|
|
182
184
|
...is.functions,
|
|
@@ -208,45 +210,63 @@ export namespace AssertProgrammer {
|
|
|
208
210
|
};
|
|
209
211
|
|
|
210
212
|
const combiner =
|
|
211
|
-
(
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
213
|
+
(props: {
|
|
214
|
+
config: IConfig;
|
|
215
|
+
context: ITypiaContext;
|
|
216
|
+
importer: FunctionImporter;
|
|
217
|
+
}): CheckerProgrammer.IConfig.Combiner =>
|
|
218
|
+
(next) => {
|
|
219
|
+
if (next.explore.tracable === false)
|
|
216
220
|
return IsProgrammer.configure({
|
|
217
|
-
object:
|
|
221
|
+
object: (v) =>
|
|
222
|
+
assert_object({
|
|
223
|
+
config: props.config,
|
|
224
|
+
context: props.context,
|
|
225
|
+
importer: props.importer,
|
|
226
|
+
entries: v.entries,
|
|
227
|
+
input: v.input,
|
|
228
|
+
}),
|
|
218
229
|
numeric: true,
|
|
219
|
-
})(
|
|
230
|
+
})(props.context)(props.importer).combiner(next);
|
|
220
231
|
|
|
221
|
-
const path: string = explore.postfix
|
|
222
|
-
? `_path + ${explore.postfix}`
|
|
232
|
+
const path: string = next.explore.postfix
|
|
233
|
+
? `_path + ${next.explore.postfix}`
|
|
223
234
|
: "_path";
|
|
224
|
-
return
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
.
|
|
228
|
-
binary.
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
235
|
+
return next.logic === "and"
|
|
236
|
+
? next.binaries
|
|
237
|
+
.map((binary) =>
|
|
238
|
+
binary.combined
|
|
239
|
+
? binary.expression
|
|
240
|
+
: ts.factory.createLogicalOr(
|
|
241
|
+
binary.expression,
|
|
242
|
+
create_guard_call({
|
|
243
|
+
importer: props.importer,
|
|
244
|
+
exceptionable:
|
|
245
|
+
next.explore.source === "top"
|
|
234
246
|
? ts.factory.createTrue()
|
|
235
247
|
: ts.factory.createIdentifier("_exceptionable"),
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
248
|
+
path: ts.factory.createIdentifier(path),
|
|
249
|
+
expected: next.expected,
|
|
250
|
+
input: next.input,
|
|
251
|
+
}),
|
|
252
|
+
),
|
|
253
|
+
)
|
|
254
|
+
.reduce(ts.factory.createLogicalAnd)
|
|
255
|
+
: ts.factory.createLogicalOr(
|
|
256
|
+
next.binaries
|
|
257
|
+
.map((binary) => binary.expression)
|
|
258
|
+
.reduce(ts.factory.createLogicalOr),
|
|
259
|
+
create_guard_call({
|
|
260
|
+
importer: props.importer,
|
|
261
|
+
exceptionable:
|
|
262
|
+
next.explore.source === "top"
|
|
246
263
|
? ts.factory.createTrue()
|
|
247
264
|
: ts.factory.createIdentifier("_exceptionable"),
|
|
248
|
-
|
|
249
|
-
|
|
265
|
+
path: ts.factory.createIdentifier(path),
|
|
266
|
+
expected: next.expected,
|
|
267
|
+
input: next.input,
|
|
268
|
+
}),
|
|
269
|
+
);
|
|
250
270
|
// : (() => {
|
|
251
271
|
// const addicted = binaries.slice();
|
|
252
272
|
// if (
|
|
@@ -273,96 +293,118 @@ export namespace AssertProgrammer {
|
|
|
273
293
|
// })();
|
|
274
294
|
};
|
|
275
295
|
|
|
276
|
-
const assert_object =
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
296
|
+
const assert_object = (props: {
|
|
297
|
+
config: IConfig;
|
|
298
|
+
context: ITypiaContext;
|
|
299
|
+
importer: FunctionImporter;
|
|
300
|
+
entries: IExpressionEntry<ts.Expression>[];
|
|
301
|
+
input: ts.Expression;
|
|
302
|
+
}) =>
|
|
303
|
+
check_object({
|
|
304
|
+
equals: props.config.equals,
|
|
305
|
+
assert: true,
|
|
306
|
+
undefined: true,
|
|
307
|
+
reduce: ts.factory.createLogicalAnd,
|
|
308
|
+
positive: ts.factory.createTrue(),
|
|
309
|
+
superfluous: (input) =>
|
|
310
|
+
create_guard_call({
|
|
311
|
+
importer: props.importer,
|
|
312
|
+
path: ts.factory.createAdd(
|
|
313
|
+
ts.factory.createIdentifier("_path"),
|
|
314
|
+
ts.factory.createCallExpression(
|
|
315
|
+
props.importer.use("join"),
|
|
316
|
+
undefined,
|
|
317
|
+
[ts.factory.createIdentifier("key")],
|
|
293
318
|
),
|
|
294
|
-
"undefined",
|
|
295
|
-
value,
|
|
296
319
|
),
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
320
|
+
expected: "undefined",
|
|
321
|
+
input,
|
|
322
|
+
}),
|
|
323
|
+
halt: (expr) =>
|
|
324
|
+
ts.factory.createLogicalOr(
|
|
325
|
+
ts.factory.createStrictEquality(
|
|
326
|
+
ts.factory.createFalse(),
|
|
327
|
+
ts.factory.createIdentifier("_exceptionable"),
|
|
304
328
|
),
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
const joiner =
|
|
308
|
-
(equals: boolean) =>
|
|
309
|
-
(project: ITypiaContext) =>
|
|
310
|
-
(importer: FunctionImporter): CheckerProgrammer.IConfig.IJoiner => ({
|
|
311
|
-
object: assert_object(equals)(project)(importer),
|
|
312
|
-
array: (props) =>
|
|
313
|
-
ts.factory.createCallExpression(
|
|
314
|
-
IdentifierFactory.access(props.input)("every"),
|
|
315
|
-
undefined,
|
|
316
|
-
[props.arrow],
|
|
329
|
+
expr,
|
|
317
330
|
),
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
331
|
+
})(props.context)(props.importer)({
|
|
332
|
+
input: props.input,
|
|
333
|
+
entries: props.entries,
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
const joiner = (props: {
|
|
337
|
+
config: IConfig;
|
|
338
|
+
context: ITypiaContext;
|
|
339
|
+
importer: FunctionImporter;
|
|
340
|
+
}): CheckerProgrammer.IConfig.IJoiner => ({
|
|
341
|
+
object: (next) =>
|
|
342
|
+
assert_object({
|
|
343
|
+
config: props.config,
|
|
344
|
+
context: props.context,
|
|
345
|
+
importer: props.importer,
|
|
346
|
+
entries: next.entries,
|
|
347
|
+
input: next.input,
|
|
348
|
+
}),
|
|
349
|
+
array: (props) =>
|
|
350
|
+
ts.factory.createCallExpression(
|
|
351
|
+
IdentifierFactory.access(props.input)("every"),
|
|
352
|
+
undefined,
|
|
353
|
+
[props.arrow],
|
|
354
|
+
),
|
|
355
|
+
failure: (next) =>
|
|
356
|
+
create_guard_call({
|
|
357
|
+
importer: props.importer,
|
|
358
|
+
exceptionable:
|
|
359
|
+
next.explore?.from === "top"
|
|
321
360
|
? ts.factory.createTrue()
|
|
322
361
|
: ts.factory.createIdentifier("_exceptionable"),
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
explore?.postfix ? `_path + ${explore.postfix}` : "_path",
|
|
326
|
-
),
|
|
327
|
-
expected,
|
|
328
|
-
value,
|
|
362
|
+
path: ts.factory.createIdentifier(
|
|
363
|
+
next.explore?.postfix ? `_path + ${next.explore.postfix}` : "_path",
|
|
329
364
|
),
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
365
|
+
expected: next.expected,
|
|
366
|
+
input: next.input,
|
|
367
|
+
}),
|
|
368
|
+
full: props.config.equals
|
|
369
|
+
? undefined
|
|
370
|
+
: (next) =>
|
|
371
|
+
ts.factory.createLogicalOr(
|
|
372
|
+
next.condition,
|
|
373
|
+
create_guard_call({
|
|
374
|
+
importer: props.importer,
|
|
375
|
+
exceptionable:
|
|
376
|
+
next.explore.from === "top"
|
|
337
377
|
? ts.factory.createTrue()
|
|
338
378
|
: ts.factory.createIdentifier("_exceptionable"),
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
379
|
+
path: ts.factory.createIdentifier("_path"),
|
|
380
|
+
expected: next.expected,
|
|
381
|
+
input: next.input,
|
|
382
|
+
}),
|
|
383
|
+
),
|
|
384
|
+
});
|
|
342
385
|
|
|
343
|
-
const create_guard_call =
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
ts.factory.
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
]);
|
|
386
|
+
const create_guard_call = (props: {
|
|
387
|
+
importer: FunctionImporter;
|
|
388
|
+
expected: string;
|
|
389
|
+
input: ts.Expression;
|
|
390
|
+
path: ts.Expression;
|
|
391
|
+
exceptionable?: ts.Expression;
|
|
392
|
+
}): ts.Expression =>
|
|
393
|
+
ts.factory.createCallExpression(props.importer.use("guard"), undefined, [
|
|
394
|
+
props.exceptionable ?? ts.factory.createIdentifier("_exceptionable"),
|
|
395
|
+
ts.factory.createObjectLiteralExpression(
|
|
396
|
+
[
|
|
397
|
+
ts.factory.createPropertyAssignment("path", props.path),
|
|
398
|
+
ts.factory.createPropertyAssignment(
|
|
399
|
+
"expected",
|
|
400
|
+
ts.factory.createStringLiteral(props.expected),
|
|
401
|
+
),
|
|
402
|
+
ts.factory.createPropertyAssignment("value", props.input),
|
|
403
|
+
],
|
|
404
|
+
true,
|
|
405
|
+
),
|
|
406
|
+
ts.factory.createIdentifier("_errorFactory"),
|
|
407
|
+
]);
|
|
366
408
|
|
|
367
409
|
export namespace Guardian {
|
|
368
410
|
export const identifier = () => ts.factory.createIdentifier("errorFactory");
|