typia 3.7.0-dev.20230310 → 3.7.0-dev.20230331
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/README.md +16 -45
- package/lib/IRandomGenerator.d.ts +2 -1
- package/lib/executable/TypiaSetupWizard.js +12 -2
- package/lib/executable/TypiaSetupWizard.js.map +1 -1
- package/lib/factories/MetadataCollection.d.ts +9 -1
- package/lib/factories/MetadataCollection.js +75 -2
- package/lib/factories/MetadataCollection.js.map +1 -1
- package/lib/factories/MetadataTagFactory.js +151 -132
- package/lib/factories/MetadataTagFactory.js.map +1 -1
- package/lib/factories/TypeFactory.js +1 -1
- package/lib/factories/TypeFactory.js.map +1 -1
- package/lib/factories/TypiaFileFactory.js +61 -54
- package/lib/factories/TypiaFileFactory.js.map +1 -1
- package/lib/functional/$dictionary.d.ts +1 -0
- package/lib/functional/$dictionary.js +14 -0
- package/lib/functional/$dictionary.js.map +1 -0
- package/lib/functional/$is_custom.d.ts +2 -0
- package/lib/functional/$is_custom.js +12 -0
- package/lib/functional/$is_custom.js.map +1 -0
- package/lib/functional/$is_date.d.ts +1 -0
- package/lib/functional/$is_date.js +9 -0
- package/lib/functional/$is_date.js.map +1 -0
- package/lib/functional/$is_datetime.d.ts +1 -0
- package/lib/functional/$is_datetime.js +8 -0
- package/lib/functional/$is_datetime.js.map +1 -0
- package/lib/functional/Namespace.js +6 -0
- package/lib/functional/Namespace.js.map +1 -1
- package/lib/metadata/IMetadataTag.d.ts +30 -38
- package/lib/metadata/Metadata.js +2 -2
- package/lib/metadata/Metadata.js.map +1 -1
- package/lib/module.d.ts +25 -2
- package/lib/module.js +12 -5
- package/lib/module.js.map +1 -1
- package/lib/programmers/CheckerProgrammer.d.ts +2 -2
- package/lib/programmers/CheckerProgrammer.js +22 -22
- package/lib/programmers/CheckerProgrammer.js.map +1 -1
- package/lib/programmers/CloneProgrammer.js +2 -2
- package/lib/programmers/CloneProgrammer.js.map +1 -1
- package/lib/programmers/FeatureProgrammer.d.ts +3 -2
- package/lib/programmers/FeatureProgrammer.js +5 -5
- package/lib/programmers/FeatureProgrammer.js.map +1 -1
- package/lib/programmers/IsProgrammer.d.ts +1 -1
- package/lib/programmers/IsProgrammer.js +2 -2
- package/lib/programmers/IsProgrammer.js.map +1 -1
- package/lib/programmers/PruneProgrammer.js +2 -2
- package/lib/programmers/PruneProgrammer.js.map +1 -1
- package/lib/programmers/RandomProgrammer.js +1 -2
- package/lib/programmers/RandomProgrammer.js.map +1 -1
- package/lib/programmers/StringifyProgrammer.js +6 -6
- package/lib/programmers/StringifyProgrammer.js.map +1 -1
- package/lib/programmers/helpers/UnionExplorer.d.ts +7 -7
- package/lib/programmers/helpers/UnionExplorer.js +6 -6
- package/lib/programmers/helpers/UnionExplorer.js.map +1 -1
- package/lib/programmers/internal/application_object.js +11 -11
- package/lib/programmers/internal/application_object.js.map +1 -1
- package/lib/programmers/internal/application_schema.js +3 -5
- package/lib/programmers/internal/application_schema.js.map +1 -1
- package/lib/programmers/internal/application_string.js +8 -5
- package/lib/programmers/internal/application_string.js.map +1 -1
- package/lib/programmers/internal/check_array.js +36 -7
- package/lib/programmers/internal/check_array.js.map +1 -1
- package/lib/programmers/internal/check_bigint.d.ts +3 -1
- package/lib/programmers/internal/check_bigint.js +90 -61
- package/lib/programmers/internal/check_bigint.js.map +1 -1
- package/lib/programmers/internal/check_custom.d.ts +4 -0
- package/lib/programmers/internal/check_custom.js +30 -0
- package/lib/programmers/internal/check_custom.js.map +1 -0
- package/lib/programmers/internal/check_number.js +104 -75
- package/lib/programmers/internal/check_number.js.map +1 -1
- package/lib/programmers/internal/check_string.js +4 -3
- package/lib/programmers/internal/check_string.js.map +1 -1
- package/lib/programmers/internal/check_union_array_like.d.ts +2 -2
- package/lib/programmers/internal/check_union_array_like.js +4 -4
- package/lib/programmers/internal/check_union_array_like.js.map +1 -1
- package/lib/programmers/internal/check_union_tuple.js +2 -2
- package/lib/programmers/internal/check_union_tuple.js.map +1 -1
- package/lib/programmers/internal/feature_object_entries.js +1 -1
- package/lib/programmers/internal/feature_object_entries.js.map +1 -1
- package/lib/transformers/CallExpressionTransformer.js +1 -3
- package/lib/transformers/CallExpressionTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/ApplicationTransformer.js +3 -1
- package/lib/transformers/features/miscellaneous/ApplicationTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/CreateRandomGenerator.js +1 -1
- package/lib/transformers/features/miscellaneous/CreateRandomGenerator.js.map +1 -1
- package/lib/transformers/features/miscellaneous/RandomTransformer.js +1 -1
- package/lib/transformers/features/miscellaneous/RandomTransformer.js.map +1 -1
- package/lib/transformers/internal/GenericTransformer.js +2 -2
- package/lib/transformers/internal/GenericTransformer.js.map +1 -1
- package/lib/typings/Customizable.d.ts +7 -0
- package/lib/{messages/IProtocolMap.js → typings/Customizable.js} +1 -1
- package/lib/typings/Customizable.js.map +1 -0
- package/lib/utils/RandomGenerator.js +8 -2
- package/lib/utils/RandomGenerator.js.map +1 -1
- package/package.json +10 -9
- package/src/IRandomGenerator.ts +2 -1
- package/src/executable/TypiaSetupWizard.ts +16 -6
- package/src/factories/MetadataCollection.ts +41 -2
- package/src/factories/MetadataTagFactory.ts +186 -149
- package/src/factories/TypeFactory.ts +1 -1
- package/src/factories/TypiaFileFactory.ts +10 -7
- package/src/functional/$dictionary.ts +17 -0
- package/src/functional/$is_custom.ts +14 -0
- package/src/functional/$is_date.ts +4 -0
- package/src/functional/$is_datetime.ts +3 -0
- package/src/functional/Namespace.ts +6 -0
- package/src/metadata/IMetadataTag.ts +46 -70
- package/src/metadata/Metadata.ts +3 -6
- package/src/module.ts +39 -10
- package/src/programmers/CheckerProgrammer.ts +44 -14
- package/src/programmers/CloneProgrammer.ts +2 -0
- package/src/programmers/FeatureProgrammer.ts +12 -5
- package/src/programmers/IsProgrammer.ts +2 -1
- package/src/programmers/PruneProgrammer.ts +2 -0
- package/src/programmers/RandomProgrammer.ts +1 -4
- package/src/programmers/StringifyProgrammer.ts +6 -0
- package/src/programmers/helpers/UnionExplorer.ts +7 -0
- package/src/programmers/internal/application_object.ts +5 -5
- package/src/programmers/internal/application_schema.ts +3 -7
- package/src/programmers/internal/application_string.ts +6 -2
- package/src/programmers/internal/check_array.ts +19 -10
- package/src/programmers/internal/check_bigint.ts +77 -57
- package/src/programmers/internal/check_custom.ts +32 -0
- package/src/programmers/internal/check_number.ts +16 -6
- package/src/programmers/internal/check_string.ts +8 -2
- package/src/programmers/internal/check_union_array_like.ts +5 -0
- package/src/programmers/internal/check_union_tuple.ts +2 -0
- package/src/programmers/internal/feature_object_entries.ts +1 -0
- package/src/transformers/CallExpressionTransformer.ts +9 -16
- package/src/transformers/features/miscellaneous/ApplicationTransformer.ts +3 -1
- package/src/transformers/features/miscellaneous/CreateRandomGenerator.ts +1 -1
- package/src/transformers/features/miscellaneous/RandomTransformer.ts +1 -1
- package/src/transformers/internal/GenericTransformer.ts +2 -2
- package/src/typings/Customizable.ts +7 -0
- package/src/utils/RandomGenerator.ts +8 -2
- package/lib/factories/ProtocolFactory.d.ts +0 -8
- package/lib/factories/ProtocolFactory.js +0 -112
- package/lib/factories/ProtocolFactory.js.map +0 -1
- package/lib/factories/internal/protocols/ProtocolMetadataUtil.d.ts +0 -16
- package/lib/factories/internal/protocols/ProtocolMetadataUtil.js +0 -156
- package/lib/factories/internal/protocols/ProtocolMetadataUtil.js.map +0 -1
- package/lib/factories/internal/protocols/emplace_protocol_object.d.ts +0 -3
- package/lib/factories/internal/protocols/emplace_protocol_object.js +0 -47
- package/lib/factories/internal/protocols/emplace_protocol_object.js.map +0 -1
- package/lib/factories/internal/protocols/emplace_protocol_property.d.ts +0 -4
- package/lib/factories/internal/protocols/emplace_protocol_property.js +0 -20
- package/lib/factories/internal/protocols/emplace_protocol_property.js.map +0 -1
- package/lib/factories/internal/protocols/iterate_protocol_atomic.d.ts +0 -3
- package/lib/factories/internal/protocols/iterate_protocol_atomic.js +0 -69
- package/lib/factories/internal/protocols/iterate_protocol_atomic.js.map +0 -1
- package/lib/factories/internal/protocols/iterate_protocol_constant.d.ts +0 -2
- package/lib/factories/internal/protocols/iterate_protocol_constant.js +0 -30
- package/lib/factories/internal/protocols/iterate_protocol_constant.js.map +0 -1
- package/lib/factories/internal/protocols/iterate_protocol_main.d.ts +0 -3
- package/lib/factories/internal/protocols/iterate_protocol_main.js +0 -17
- package/lib/factories/internal/protocols/iterate_protocol_main.js.map +0 -1
- package/lib/factories/internal/protocols/iterate_protocol_map.d.ts +0 -4
- package/lib/factories/internal/protocols/iterate_protocol_map.js +0 -75
- package/lib/factories/internal/protocols/iterate_protocol_map.js.map +0 -1
- package/lib/factories/internal/protocols/iterate_protocol_metadata.d.ts +0 -5
- package/lib/factories/internal/protocols/iterate_protocol_metadata.js +0 -190
- package/lib/factories/internal/protocols/iterate_protocol_metadata.js.map +0 -1
- package/lib/factories/internal/protocols/iterate_protocol_native.d.ts +0 -2
- package/lib/factories/internal/protocols/iterate_protocol_native.js +0 -33
- package/lib/factories/internal/protocols/iterate_protocol_native.js.map +0 -1
- package/lib/factories/internal/protocols/iterate_protocol_never.d.ts +0 -1
- package/lib/factories/internal/protocols/iterate_protocol_never.js +0 -6
- package/lib/factories/internal/protocols/iterate_protocol_never.js.map +0 -1
- package/lib/factories/internal/protocols/iterate_protocol_object.d.ts +0 -4
- package/lib/factories/internal/protocols/iterate_protocol_object.js +0 -157
- package/lib/factories/internal/protocols/iterate_protocol_object.js.map +0 -1
- package/lib/factories/internal/protocols/iterate_protocol_repeated.d.ts +0 -5
- package/lib/factories/internal/protocols/iterate_protocol_repeated.js +0 -25
- package/lib/factories/internal/protocols/iterate_protocol_repeated.js.map +0 -1
- package/lib/factories/internal/protocols/iterate_protocol_tuple.d.ts +0 -3
- package/lib/factories/internal/protocols/iterate_protocol_tuple.js +0 -46
- package/lib/factories/internal/protocols/iterate_protocol_tuple.js.map +0 -1
- package/lib/functional/$proto_bytes.d.ts +0 -2
- package/lib/functional/$proto_bytes.js +0 -37
- package/lib/functional/$proto_bytes.js.map +0 -1
- package/lib/functional/$proto_field.d.ts +0 -10
- package/lib/functional/$proto_field.js +0 -42
- package/lib/functional/$proto_field.js.map +0 -1
- package/lib/functional/$proto_float.d.ts +0 -4
- package/lib/functional/$proto_float.js +0 -28
- package/lib/functional/$proto_float.js.map +0 -1
- package/lib/functional/$proto_i32.d.ts +0 -2
- package/lib/functional/$proto_i32.js +0 -23
- package/lib/functional/$proto_i32.js.map +0 -1
- package/lib/functional/$proto_i64.d.ts +0 -2
- package/lib/functional/$proto_i64.js +0 -31
- package/lib/functional/$proto_i64.js.map +0 -1
- package/lib/functional/$proto_size.d.ts +0 -6
- package/lib/functional/$proto_size.js +0 -76
- package/lib/functional/$proto_size.js.map +0 -1
- package/lib/functional/$proto_string.d.ts +0 -2
- package/lib/functional/$proto_string.js +0 -34
- package/lib/functional/$proto_string.js.map +0 -1
- package/lib/functional/$varint.d.ts +0 -6
- package/lib/functional/$varint.js +0 -99
- package/lib/functional/$varint.js.map +0 -1
- package/lib/functional/$zigzag.d.ts +0 -4
- package/lib/functional/$zigzag.js +0 -34
- package/lib/functional/$zigzag.js.map +0 -1
- package/lib/messages/IProtocolMap.d.ts +0 -5
- package/lib/messages/IProtocolMap.js.map +0 -1
- package/lib/messages/IProtocolMessage.d.ts +0 -5
- package/lib/messages/IProtocolMessage.js +0 -3
- package/lib/messages/IProtocolMessage.js.map +0 -1
- package/lib/messages/IProtocolProperty.d.ts +0 -12
- package/lib/messages/IProtocolProperty.js +0 -3
- package/lib/messages/IProtocolProperty.js.map +0 -1
- package/lib/programmers/MessageProgrammer.d.ts +0 -5
- package/lib/programmers/MessageProgrammer.js +0 -141
- package/lib/programmers/MessageProgrammer.js.map +0 -1
- package/lib/transformers/features/protocols/MessageTransformer.d.ts +0 -5
- package/lib/transformers/features/protocols/MessageTransformer.js +0 -17
- package/lib/transformers/features/protocols/MessageTransformer.js.map +0 -1
- package/lib/utils/NameEncoder.d.ts +0 -4
- package/lib/utils/NameEncoder.js +0 -89
- package/lib/utils/NameEncoder.js.map +0 -1
- package/src/factories/ProtocolFactory.ts +0 -79
- package/src/factories/internal/protocols/ProtocolMetadataUtil.ts +0 -163
- package/src/factories/internal/protocols/emplace_protocol_object.ts +0 -25
- package/src/factories/internal/protocols/emplace_protocol_property.ts +0 -12
- package/src/factories/internal/protocols/iterate_protocol_atomic.ts +0 -34
- package/src/factories/internal/protocols/iterate_protocol_constant.ts +0 -27
- package/src/factories/internal/protocols/iterate_protocol_main.ts +0 -19
- package/src/factories/internal/protocols/iterate_protocol_map.ts +0 -58
- package/src/factories/internal/protocols/iterate_protocol_metadata.ts +0 -96
- package/src/factories/internal/protocols/iterate_protocol_native.ts +0 -34
- package/src/factories/internal/protocols/iterate_protocol_never.ts +0 -1
- package/src/factories/internal/protocols/iterate_protocol_object.ts +0 -110
- package/src/factories/internal/protocols/iterate_protocol_repeated.ts +0 -34
- package/src/factories/internal/protocols/iterate_protocol_tuple.ts +0 -29
- package/src/functional/$proto_bytes.ts +0 -25
- package/src/functional/$proto_field.ts +0 -30
- package/src/functional/$proto_float.ts +0 -37
- package/src/functional/$proto_i32.ts +0 -29
- package/src/functional/$proto_i64.ts +0 -37
- package/src/functional/$proto_size.ts +0 -82
- package/src/functional/$proto_string.ts +0 -24
- package/src/functional/$varint.ts +0 -130
- package/src/functional/$zigzag.ts +0 -39
- package/src/messages/IProtocolMap.ts +0 -5
- package/src/messages/IProtocolMessage.ts +0 -6
- package/src/messages/IProtocolProperty.ts +0 -13
- package/src/programmers/MessageProgrammer.ts +0 -126
- package/src/transformers/features/protocols/MessageTransformer.ts +0 -32
- package/src/utils/NameEncoder.ts +0 -32
package/src/metadata/Metadata.ts
CHANGED
|
@@ -205,7 +205,6 @@ export class Metadata {
|
|
|
205
205
|
public empty(): boolean {
|
|
206
206
|
return this.bucket() === 0 || this.size() === 0;
|
|
207
207
|
}
|
|
208
|
-
|
|
209
208
|
public size(): number {
|
|
210
209
|
return (
|
|
211
210
|
(this.resolved ? 1 : 0) +
|
|
@@ -224,7 +223,6 @@ export class Metadata {
|
|
|
224
223
|
this.maps.length
|
|
225
224
|
);
|
|
226
225
|
}
|
|
227
|
-
|
|
228
226
|
public bucket(): number {
|
|
229
227
|
return (
|
|
230
228
|
(this.resolved ? 1 : 0) +
|
|
@@ -241,7 +239,6 @@ export class Metadata {
|
|
|
241
239
|
(this.maps.length ? 1 : 0)
|
|
242
240
|
);
|
|
243
241
|
}
|
|
244
|
-
|
|
245
242
|
public isConstant(): boolean {
|
|
246
243
|
return this.bucket() === (this.constants.length ? 1 : 0);
|
|
247
244
|
}
|
|
@@ -511,15 +508,15 @@ function getName(metadata: Metadata): string {
|
|
|
511
508
|
elements.push(`Map<${map.key.getName()}, ${map.value.getName()}>`);
|
|
512
509
|
|
|
513
510
|
// ARRAY
|
|
514
|
-
if (metadata.rest !== null)
|
|
515
|
-
elements.push(`Rest<${metadata.rest.getName()}>`);
|
|
511
|
+
if (metadata.rest !== null) elements.push(`...${metadata.rest.getName()}`);
|
|
516
512
|
for (const tuple of metadata.tuples)
|
|
517
513
|
elements.push(`[${tuple.map((elem) => elem.getName()).join(", ")}]`);
|
|
518
514
|
for (const array of metadata.arrays)
|
|
519
515
|
elements.push(`Array<${array.getName()}>`);
|
|
520
516
|
|
|
521
517
|
// OBJECT
|
|
522
|
-
for (const object of metadata.objects)
|
|
518
|
+
for (const object of metadata.objects)
|
|
519
|
+
elements.push(`Resolve<${object.name}>`);
|
|
523
520
|
if (metadata.resolved !== null) elements.push(metadata.resolved.getName());
|
|
524
521
|
|
|
525
522
|
// RETURNS
|
package/src/module.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { $dictionary } from "./functional/$dictionary";
|
|
1
2
|
import { Namespace } from "./functional/Namespace";
|
|
2
3
|
|
|
3
4
|
import { IMetadataApplication } from "./metadata/IMetadataApplication";
|
|
4
5
|
import { IJsonApplication } from "./schemas/IJsonApplication";
|
|
5
6
|
|
|
7
|
+
import { Customizable } from "./typings/Customizable";
|
|
8
|
+
|
|
6
9
|
import { IRandomGenerator } from "./IRandomGenerator";
|
|
7
10
|
import { IValidation } from "./IValidation";
|
|
8
11
|
import { Primitive } from "./Primitive";
|
|
@@ -20,7 +23,6 @@ export * from "./TypeGuardError";
|
|
|
20
23
|
SINGLE FUNCTIONS
|
|
21
24
|
- BASIC VALIDATORS
|
|
22
25
|
- STRICT VALIDATORS
|
|
23
|
-
- PROTOCOL BUFFER FUNCTIONS
|
|
24
26
|
- JSON FUNCTIONS
|
|
25
27
|
- MISCELLANEOUS
|
|
26
28
|
==============================================================
|
|
@@ -411,15 +413,42 @@ export function validateEquals(): never {
|
|
|
411
413
|
}
|
|
412
414
|
Object.assign(validateEquals, Namespace.validate());
|
|
413
415
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
416
|
+
/**
|
|
417
|
+
* Add validation tag.
|
|
418
|
+
*
|
|
419
|
+
* If you want to add a custom validation logic, you can use this function.
|
|
420
|
+
*
|
|
421
|
+
* ```ts
|
|
422
|
+
* typia.addValidationTag("powerOf")("number")(
|
|
423
|
+
* (text: string) => {
|
|
424
|
+
* const denominator: number = Math.log(Number(text));
|
|
425
|
+
* return (value: number) => {
|
|
426
|
+
* value = Math.log(value) / denominator;
|
|
427
|
+
* return value === Math.floor(value);
|
|
428
|
+
* };
|
|
429
|
+
* }
|
|
430
|
+
* );
|
|
431
|
+
* typia.addValidationTag("dollar")("string")(
|
|
432
|
+
* () => (value: string) => value.startsWith("$"),
|
|
433
|
+
* );
|
|
434
|
+
* ```
|
|
435
|
+
*
|
|
436
|
+
* @param name Name of tag (`@name`)
|
|
437
|
+
* @returns Currying function
|
|
438
|
+
*/
|
|
439
|
+
export const addValidationTag =
|
|
440
|
+
(name: string) =>
|
|
441
|
+
/**
|
|
442
|
+
* @param type Type of target value
|
|
443
|
+
*/
|
|
444
|
+
<Type extends keyof Customizable>(type: Type) =>
|
|
445
|
+
/**
|
|
446
|
+
* @param closure Closure function for custom validation
|
|
447
|
+
*/
|
|
448
|
+
(closure: (text: string) => (value: Customizable[Type]) => boolean) => {
|
|
449
|
+
const key = `${name}:${type}` as const;
|
|
450
|
+
if (!$dictionary.has(key)) $dictionary.set(key, closure);
|
|
451
|
+
};
|
|
423
452
|
|
|
424
453
|
/* -----------------------------------------------------------
|
|
425
454
|
JSON FUNCTIONS
|
|
@@ -217,6 +217,7 @@ export namespace CheckerProgrammer {
|
|
|
217
217
|
meta: Metadata,
|
|
218
218
|
explore: IExplore,
|
|
219
219
|
tags: IMetadataTag[],
|
|
220
|
+
jsDocTags: ts.JSDocTagInfo[],
|
|
220
221
|
) => ts.Expression;
|
|
221
222
|
|
|
222
223
|
/**
|
|
@@ -232,6 +233,7 @@ export namespace CheckerProgrammer {
|
|
|
232
233
|
meta: Metadata,
|
|
233
234
|
explore: IExplore,
|
|
234
235
|
tags: IMetadataTag[],
|
|
236
|
+
jsDocTags: ts.JSDocTagInfo[],
|
|
235
237
|
) => ts.Expression;
|
|
236
238
|
|
|
237
239
|
/**
|
|
@@ -246,7 +248,8 @@ export namespace CheckerProgrammer {
|
|
|
246
248
|
input: ts.Expression,
|
|
247
249
|
meta: Metadata,
|
|
248
250
|
explore: IExplore,
|
|
249
|
-
|
|
251
|
+
metaTags: IMetadataTag[],
|
|
252
|
+
jsDocTags: ts.JSDocTagInfo[],
|
|
250
253
|
): ts.Expression {
|
|
251
254
|
if (meta.any) return config.success;
|
|
252
255
|
|
|
@@ -315,20 +318,28 @@ export namespace CheckerProgrammer {
|
|
|
315
318
|
if (AtomicPredicator.atomic(meta)(type) === false) continue;
|
|
316
319
|
else if (type === "number")
|
|
317
320
|
binaries.push({
|
|
318
|
-
expression: check_number(
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
),
|
|
321
|
+
expression: check_number(
|
|
322
|
+
project,
|
|
323
|
+
config.numeric,
|
|
324
|
+
)(importer)(input, metaTags, jsDocTags),
|
|
322
325
|
combined: false,
|
|
323
326
|
});
|
|
324
327
|
else if (type === "bigint")
|
|
325
328
|
binaries.push({
|
|
326
|
-
expression: check_bigint(
|
|
329
|
+
expression: check_bigint(importer)(
|
|
330
|
+
input,
|
|
331
|
+
metaTags,
|
|
332
|
+
jsDocTags,
|
|
333
|
+
),
|
|
327
334
|
combined: false,
|
|
328
335
|
});
|
|
329
336
|
else if (type === "string")
|
|
330
337
|
binaries.push({
|
|
331
|
-
expression: check_string(importer)(
|
|
338
|
+
expression: check_string(importer)(
|
|
339
|
+
input,
|
|
340
|
+
metaTags,
|
|
341
|
+
jsDocTags,
|
|
342
|
+
),
|
|
332
343
|
combined: false,
|
|
333
344
|
});
|
|
334
345
|
else
|
|
@@ -345,7 +356,7 @@ export namespace CheckerProgrammer {
|
|
|
345
356
|
expression: check_template(importer)(
|
|
346
357
|
input,
|
|
347
358
|
meta.templates,
|
|
348
|
-
|
|
359
|
+
metaTags,
|
|
349
360
|
),
|
|
350
361
|
combined: false,
|
|
351
362
|
});
|
|
@@ -394,6 +405,7 @@ export namespace CheckerProgrammer {
|
|
|
394
405
|
from: "array",
|
|
395
406
|
},
|
|
396
407
|
[],
|
|
408
|
+
[],
|
|
397
409
|
),
|
|
398
410
|
);
|
|
399
411
|
}
|
|
@@ -418,6 +430,7 @@ export namespace CheckerProgrammer {
|
|
|
418
430
|
from: "array",
|
|
419
431
|
},
|
|
420
432
|
[],
|
|
433
|
+
[],
|
|
421
434
|
),
|
|
422
435
|
);
|
|
423
436
|
}
|
|
@@ -425,7 +438,11 @@ export namespace CheckerProgrammer {
|
|
|
425
438
|
// ARRAYS AND TUPLES
|
|
426
439
|
if (meta.tuples.length + meta.arrays.length > 0) {
|
|
427
440
|
const install = prepare(
|
|
428
|
-
check_array(
|
|
441
|
+
check_array(importer)(
|
|
442
|
+
input,
|
|
443
|
+
meta.tuples.length === 0 ? metaTags : [],
|
|
444
|
+
jsDocTags,
|
|
445
|
+
),
|
|
429
446
|
[...meta.tuples, ...meta.arrays]
|
|
430
447
|
.map((elem) =>
|
|
431
448
|
Array.isArray(elem)
|
|
@@ -445,7 +462,8 @@ export namespace CheckerProgrammer {
|
|
|
445
462
|
...explore,
|
|
446
463
|
from: "array",
|
|
447
464
|
},
|
|
448
|
-
|
|
465
|
+
metaTags,
|
|
466
|
+
jsDocTags,
|
|
449
467
|
),
|
|
450
468
|
);
|
|
451
469
|
else if (meta.arrays.some((elem) => elem.any)) install(null);
|
|
@@ -459,7 +477,8 @@ export namespace CheckerProgrammer {
|
|
|
459
477
|
...explore,
|
|
460
478
|
from: "array",
|
|
461
479
|
},
|
|
462
|
-
|
|
480
|
+
metaTags,
|
|
481
|
+
jsDocTags,
|
|
463
482
|
),
|
|
464
483
|
);
|
|
465
484
|
else
|
|
@@ -468,7 +487,8 @@ export namespace CheckerProgrammer {
|
|
|
468
487
|
input,
|
|
469
488
|
[...meta.tuples, ...meta.arrays],
|
|
470
489
|
explore,
|
|
471
|
-
|
|
490
|
+
metaTags,
|
|
491
|
+
jsDocTags,
|
|
472
492
|
),
|
|
473
493
|
);
|
|
474
494
|
}
|
|
@@ -580,6 +600,7 @@ export namespace CheckerProgrammer {
|
|
|
580
600
|
tuple: Array<Metadata>,
|
|
581
601
|
explore: IExplore,
|
|
582
602
|
tagList: IMetadataTag[],
|
|
603
|
+
jsDocTags: ts.JSDocTagInfo[],
|
|
583
604
|
): ts.Expression {
|
|
584
605
|
const binaries: ts.Expression[] = tuple
|
|
585
606
|
.filter((meta) => meta.rest === null)
|
|
@@ -595,6 +616,7 @@ export namespace CheckerProgrammer {
|
|
|
595
616
|
: `[${index}]`,
|
|
596
617
|
},
|
|
597
618
|
tagList,
|
|
619
|
+
jsDocTags,
|
|
598
620
|
),
|
|
599
621
|
);
|
|
600
622
|
const rest: ts.Expression | null =
|
|
@@ -621,6 +643,7 @@ export namespace CheckerProgrammer {
|
|
|
621
643
|
start: tuple.length - 1,
|
|
622
644
|
},
|
|
623
645
|
tagList,
|
|
646
|
+
jsDocTags,
|
|
624
647
|
)
|
|
625
648
|
: null;
|
|
626
649
|
|
|
@@ -728,12 +751,14 @@ export namespace CheckerProgrammer {
|
|
|
728
751
|
entry[0],
|
|
729
752
|
{ ...explore, postfix: `${explore.postfix}[0]` },
|
|
730
753
|
[],
|
|
754
|
+
[],
|
|
731
755
|
),
|
|
732
756
|
func(
|
|
733
757
|
ts.factory.createElementAccessExpression(input, 1),
|
|
734
758
|
entry[1],
|
|
735
759
|
{ ...explore, postfix: `${explore.postfix}[1]` },
|
|
736
760
|
[],
|
|
761
|
+
[],
|
|
737
762
|
),
|
|
738
763
|
);
|
|
739
764
|
},
|
|
@@ -759,6 +784,7 @@ export namespace CheckerProgrammer {
|
|
|
759
784
|
}),
|
|
760
785
|
explore,
|
|
761
786
|
[],
|
|
787
|
+
[],
|
|
762
788
|
),
|
|
763
789
|
empty: config.success,
|
|
764
790
|
success: config.success,
|
|
@@ -806,13 +832,14 @@ export namespace CheckerProgrammer {
|
|
|
806
832
|
importer: FunctionImporter,
|
|
807
833
|
) =>
|
|
808
834
|
UnionExplorer.array_or_tuple({
|
|
809
|
-
checker: (front, target, explore, tags, array) => {
|
|
835
|
+
checker: (front, target, explore, tags, jsDocTags, array) => {
|
|
810
836
|
if (Array.isArray(target))
|
|
811
837
|
return check_union_tuple(project, config, importer)(
|
|
812
838
|
front,
|
|
813
839
|
target,
|
|
814
840
|
explore,
|
|
815
841
|
tags,
|
|
842
|
+
jsDocTags,
|
|
816
843
|
array,
|
|
817
844
|
);
|
|
818
845
|
const condition = decode(project, config, importer)(
|
|
@@ -820,25 +847,28 @@ export namespace CheckerProgrammer {
|
|
|
820
847
|
target,
|
|
821
848
|
explore,
|
|
822
849
|
tags,
|
|
850
|
+
jsDocTags,
|
|
823
851
|
);
|
|
824
852
|
const length = check_array_length(array, tags);
|
|
825
853
|
return length !== null
|
|
826
854
|
? ts.factory.createBitwiseAnd(condition, length)
|
|
827
855
|
: condition;
|
|
828
856
|
},
|
|
829
|
-
decoder: (input, target, explore, tags) =>
|
|
857
|
+
decoder: (input, target, explore, tags, jsDocTags) =>
|
|
830
858
|
Array.isArray(target)
|
|
831
859
|
? decode_tuple(project, config, importer, true)(
|
|
832
860
|
input,
|
|
833
861
|
target,
|
|
834
862
|
explore,
|
|
835
863
|
tags,
|
|
864
|
+
jsDocTags,
|
|
836
865
|
)
|
|
837
866
|
: decode_array(project, config, importer, true)(
|
|
838
867
|
input,
|
|
839
868
|
target,
|
|
840
869
|
explore,
|
|
841
870
|
tags,
|
|
871
|
+
jsDocTags,
|
|
842
872
|
),
|
|
843
873
|
empty: config.success,
|
|
844
874
|
success: config.success,
|
|
@@ -109,6 +109,7 @@ export namespace CloneProgrammer {
|
|
|
109
109
|
})(),
|
|
110
110
|
explore,
|
|
111
111
|
[],
|
|
112
|
+
[],
|
|
112
113
|
),
|
|
113
114
|
value: () =>
|
|
114
115
|
decode_tuple(project, importer)(input, tuple, explore),
|
|
@@ -128,6 +129,7 @@ export namespace CloneProgrammer {
|
|
|
128
129
|
from: "array",
|
|
129
130
|
},
|
|
130
131
|
[],
|
|
132
|
+
[],
|
|
131
133
|
),
|
|
132
134
|
});
|
|
133
135
|
|
|
@@ -6,6 +6,7 @@ import { StatementFactory } from "../factories/StatementFactory";
|
|
|
6
6
|
import { TypeFactory } from "../factories/TypeFactory";
|
|
7
7
|
import { ValueFactory } from "../factories/ValueFactory";
|
|
8
8
|
|
|
9
|
+
import { IJsDocTagInfo } from "../metadata/IJsDocTagInfo";
|
|
9
10
|
import { IMetadataTag } from "../metadata/IMetadataTag";
|
|
10
11
|
import { Metadata } from "../metadata/Metadata";
|
|
11
12
|
import { MetadataObject } from "../metadata/MetadataObject";
|
|
@@ -202,7 +203,8 @@ export namespace FeatureProgrammer {
|
|
|
202
203
|
input: ts.Expression,
|
|
203
204
|
target: T,
|
|
204
205
|
explore: IExplore,
|
|
205
|
-
|
|
206
|
+
metaTags: IMetadataTag[],
|
|
207
|
+
jsDocTags: ts.JSDocTagInfo[],
|
|
206
208
|
): Output;
|
|
207
209
|
}
|
|
208
210
|
|
|
@@ -241,6 +243,7 @@ export namespace FeatureProgrammer {
|
|
|
241
243
|
postfix: '""',
|
|
242
244
|
},
|
|
243
245
|
[],
|
|
246
|
+
[],
|
|
244
247
|
);
|
|
245
248
|
|
|
246
249
|
// RETURNS THE OPTIMAL ARROW FUNCTION
|
|
@@ -350,6 +353,7 @@ export namespace FeatureProgrammer {
|
|
|
350
353
|
postfix: "",
|
|
351
354
|
},
|
|
352
355
|
[],
|
|
356
|
+
[],
|
|
353
357
|
),
|
|
354
358
|
);
|
|
355
359
|
}
|
|
@@ -363,7 +367,8 @@ export namespace FeatureProgrammer {
|
|
|
363
367
|
combiner: (
|
|
364
368
|
input: ts.Expression,
|
|
365
369
|
arrow: ts.ArrowFunction,
|
|
366
|
-
|
|
370
|
+
metaTags: IMetadataTag[],
|
|
371
|
+
jsDocTags: ts.JSDocTagInfo[],
|
|
367
372
|
) => ts.Expression,
|
|
368
373
|
) {
|
|
369
374
|
const rand: string = importer.increment().toString();
|
|
@@ -381,7 +386,8 @@ export namespace FeatureProgrammer {
|
|
|
381
386
|
input: ts.Expression,
|
|
382
387
|
meta: Metadata,
|
|
383
388
|
explore: IExplore,
|
|
384
|
-
|
|
389
|
+
metaTags: IMetadataTag[],
|
|
390
|
+
jsDocTags: IJsDocTagInfo[],
|
|
385
391
|
) => {
|
|
386
392
|
const arrow: ts.ArrowFunction = ts.factory.createArrowFunction(
|
|
387
393
|
undefined,
|
|
@@ -406,10 +412,11 @@ export namespace FeatureProgrammer {
|
|
|
406
412
|
explore.postfix,
|
|
407
413
|
)(rand),
|
|
408
414
|
},
|
|
409
|
-
|
|
415
|
+
metaTags,
|
|
416
|
+
jsDocTags,
|
|
410
417
|
),
|
|
411
418
|
);
|
|
412
|
-
return combiner(input, arrow,
|
|
419
|
+
return combiner(input, arrow, metaTags, jsDocTags);
|
|
413
420
|
};
|
|
414
421
|
}
|
|
415
422
|
|
|
@@ -105,7 +105,7 @@ export namespace IsProgrammer {
|
|
|
105
105
|
})(importer);
|
|
106
106
|
config.trace = equals;
|
|
107
107
|
|
|
108
|
-
config.decoder = (input, target, explore, tags) => {
|
|
108
|
+
config.decoder = (input, target, explore, tags, jsDocTags) => {
|
|
109
109
|
if (
|
|
110
110
|
target.size() === 1 &&
|
|
111
111
|
target.objects.length === 1 &&
|
|
@@ -137,6 +137,7 @@ export namespace IsProgrammer {
|
|
|
137
137
|
target,
|
|
138
138
|
explore,
|
|
139
139
|
tags,
|
|
140
|
+
jsDocTags,
|
|
140
141
|
);
|
|
141
142
|
};
|
|
142
143
|
|
|
@@ -88,6 +88,7 @@ export namespace PruneProgrammer {
|
|
|
88
88
|
})(),
|
|
89
89
|
explore,
|
|
90
90
|
[],
|
|
91
|
+
[],
|
|
91
92
|
),
|
|
92
93
|
value: () =>
|
|
93
94
|
decode_tuple(project, importer)(input, tuple, explore),
|
|
@@ -107,6 +108,7 @@ export namespace PruneProgrammer {
|
|
|
107
108
|
from: "array",
|
|
108
109
|
},
|
|
109
110
|
[],
|
|
111
|
+
[],
|
|
110
112
|
),
|
|
111
113
|
});
|
|
112
114
|
|
|
@@ -344,10 +344,7 @@ export namespace RandomProgrammer {
|
|
|
344
344
|
(importer: FunctionImporter) =>
|
|
345
345
|
(tags: IMetadataTag[]): ts.Expression => {
|
|
346
346
|
for (const t of tags)
|
|
347
|
-
if (
|
|
348
|
-
t.kind === "format" &&
|
|
349
|
-
["uuid", "email", "url", "ipv4", "ipv6"].includes(t.value)
|
|
350
|
-
)
|
|
347
|
+
if (t.kind === "format")
|
|
351
348
|
return ts.factory.createCallExpression(
|
|
352
349
|
COALESCE(importer)(t.value),
|
|
353
350
|
undefined,
|
|
@@ -172,6 +172,7 @@ export namespace StringifyProgrammer {
|
|
|
172
172
|
partial,
|
|
173
173
|
explore,
|
|
174
174
|
[],
|
|
175
|
+
[],
|
|
175
176
|
),
|
|
176
177
|
value: () =>
|
|
177
178
|
decode_atomic(project, importer)(
|
|
@@ -200,6 +201,7 @@ export namespace StringifyProgrammer {
|
|
|
200
201
|
})(),
|
|
201
202
|
explore,
|
|
202
203
|
[],
|
|
204
|
+
[],
|
|
203
205
|
),
|
|
204
206
|
value: () =>
|
|
205
207
|
decode_atomic(project, importer)(
|
|
@@ -222,6 +224,7 @@ export namespace StringifyProgrammer {
|
|
|
222
224
|
})(),
|
|
223
225
|
explore,
|
|
224
226
|
[],
|
|
227
|
+
[],
|
|
225
228
|
),
|
|
226
229
|
value: () =>
|
|
227
230
|
decode_constant_string(project, importer)(
|
|
@@ -246,6 +249,7 @@ export namespace StringifyProgrammer {
|
|
|
246
249
|
})(),
|
|
247
250
|
explore,
|
|
248
251
|
[],
|
|
252
|
+
[],
|
|
249
253
|
),
|
|
250
254
|
value: () =>
|
|
251
255
|
decode_atomic(project, importer)(
|
|
@@ -275,6 +279,7 @@ export namespace StringifyProgrammer {
|
|
|
275
279
|
})(),
|
|
276
280
|
explore,
|
|
277
281
|
[],
|
|
282
|
+
[],
|
|
278
283
|
),
|
|
279
284
|
value: () =>
|
|
280
285
|
decode_tuple(project, importer)(
|
|
@@ -311,6 +316,7 @@ export namespace StringifyProgrammer {
|
|
|
311
316
|
from: "array",
|
|
312
317
|
},
|
|
313
318
|
[],
|
|
319
|
+
[],
|
|
314
320
|
);
|
|
315
321
|
|
|
316
322
|
unions.push({
|
|
@@ -18,6 +18,7 @@ export namespace UnionExplorer {
|
|
|
18
18
|
target: T,
|
|
19
19
|
explore: FeatureProgrammer.IExplore,
|
|
20
20
|
tags: IMetadataTag[],
|
|
21
|
+
jsDocTags: ts.JSDocTagInfo[],
|
|
21
22
|
): ts.Expression;
|
|
22
23
|
}
|
|
23
24
|
export type ObjectCombiner = Decoder<MetadataObject[]>;
|
|
@@ -32,6 +33,7 @@ export namespace UnionExplorer {
|
|
|
32
33
|
targets: MetadataObject[],
|
|
33
34
|
explore: FeatureProgrammer.IExplore,
|
|
34
35
|
tags: IMetadataTag[],
|
|
36
|
+
jsDocTags: ts.JSDocTagInfo[],
|
|
35
37
|
): ts.Expression => {
|
|
36
38
|
// BREAKER
|
|
37
39
|
if (targets.length === 1)
|
|
@@ -40,6 +42,7 @@ export namespace UnionExplorer {
|
|
|
40
42
|
targets[0]!,
|
|
41
43
|
explore,
|
|
42
44
|
tags,
|
|
45
|
+
jsDocTags,
|
|
43
46
|
);
|
|
44
47
|
|
|
45
48
|
const expected: string = `(${targets
|
|
@@ -57,6 +60,7 @@ export namespace UnionExplorer {
|
|
|
57
60
|
tracable: false,
|
|
58
61
|
},
|
|
59
62
|
tags,
|
|
63
|
+
jsDocTags,
|
|
60
64
|
);
|
|
61
65
|
return config.objector.full
|
|
62
66
|
? config.objector.full(condition)(input, expected, explore)
|
|
@@ -85,6 +89,7 @@ export namespace UnionExplorer {
|
|
|
85
89
|
postfix: IdentifierFactory.postfix(key),
|
|
86
90
|
},
|
|
87
91
|
tags,
|
|
92
|
+
jsDocTags,
|
|
88
93
|
)
|
|
89
94
|
: (config.objector.required || ((exp) => exp))(
|
|
90
95
|
ExpressionFactory.isRequired(accessor),
|
|
@@ -97,6 +102,7 @@ export namespace UnionExplorer {
|
|
|
97
102
|
spec.object,
|
|
98
103
|
explore,
|
|
99
104
|
tags,
|
|
105
|
+
jsDocTags,
|
|
100
106
|
),
|
|
101
107
|
),
|
|
102
108
|
);
|
|
@@ -120,6 +126,7 @@ export namespace UnionExplorer {
|
|
|
120
126
|
remained,
|
|
121
127
|
explore,
|
|
122
128
|
tags,
|
|
129
|
+
jsDocTags,
|
|
123
130
|
),
|
|
124
131
|
)
|
|
125
132
|
: config.objector.failure(
|
|
@@ -18,10 +18,10 @@ import { metadata_to_pattern } from "./metadata_to_pattern";
|
|
|
18
18
|
export const application_object =
|
|
19
19
|
(options: ApplicationProgrammer.IOptions) =>
|
|
20
20
|
(components: IJsonComponents) =>
|
|
21
|
-
(
|
|
21
|
+
(key: string, obj: MetadataObject, nullable: boolean): void => {
|
|
22
22
|
// TEMPORARY ASSIGNMENT
|
|
23
|
-
if (components.schemas[
|
|
24
|
-
components.schemas[
|
|
23
|
+
if (components.schemas[key] !== undefined) return;
|
|
24
|
+
components.schemas[key] = {} as any;
|
|
25
25
|
|
|
26
26
|
// ITERATE PROPERTIES
|
|
27
27
|
const properties: Record<string, any> = {};
|
|
@@ -97,7 +97,7 @@ export const application_object =
|
|
|
97
97
|
const schema: IJsonComponents.IObject = {
|
|
98
98
|
$id:
|
|
99
99
|
options.purpose === "ajv"
|
|
100
|
-
? options.prefix + "/" +
|
|
100
|
+
? options.prefix + "/" + key
|
|
101
101
|
: undefined,
|
|
102
102
|
$recursiveAnchor:
|
|
103
103
|
(options.purpose === "ajv" && obj.recursive) || undefined,
|
|
@@ -118,7 +118,7 @@ export const application_object =
|
|
|
118
118
|
join(options)(components)(extraMeta),
|
|
119
119
|
}),
|
|
120
120
|
};
|
|
121
|
-
components.schemas[
|
|
121
|
+
components.schemas[key] = schema;
|
|
122
122
|
};
|
|
123
123
|
|
|
124
124
|
const join =
|
|
@@ -2,8 +2,6 @@ import { Metadata } from "../../metadata/Metadata";
|
|
|
2
2
|
import { IJsonComponents } from "../../schemas/IJsonComponents";
|
|
3
3
|
import { IJsonSchema } from "../../schemas/IJsonSchema";
|
|
4
4
|
|
|
5
|
-
import { NameEncoder } from "../../utils/NameEncoder";
|
|
6
|
-
|
|
7
5
|
import { ApplicationProgrammer } from "../ApplicationProgrammer";
|
|
8
6
|
import { AtomicPredicator } from "../helpers/AtomicPredicator";
|
|
9
7
|
import { application_array } from "./application_array";
|
|
@@ -144,14 +142,12 @@ export const application_schema =
|
|
|
144
142
|
|
|
145
143
|
// OBJECT
|
|
146
144
|
for (const obj of meta.objects) {
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
(meta.nullable ? ".Nullable" : "");
|
|
150
|
-
application_object(options)(components)(id, obj, meta.nullable);
|
|
145
|
+
const key: string = obj.name + (meta.nullable ? ".Nullable" : "");
|
|
146
|
+
application_object(options)(components)(key, obj, meta.nullable);
|
|
151
147
|
union.push(
|
|
152
148
|
(options.purpose === "ajv" && obj.recursive
|
|
153
149
|
? recursive
|
|
154
|
-
: reference)(`${options.prefix}/${
|
|
150
|
+
: reference)(`${options.prefix}/${key}`, attribute),
|
|
155
151
|
);
|
|
156
152
|
}
|
|
157
153
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IMetadataTag } from "../../metadata/IMetadataTag";
|
|
1
2
|
import { Metadata } from "../../metadata/Metadata";
|
|
2
3
|
import { IJsonSchema } from "../../schemas/IJsonSchema";
|
|
3
4
|
|
|
@@ -24,12 +25,12 @@ export const application_string = (
|
|
|
24
25
|
output.format = formatJsdocTag?.text.map((t) => t.text).join(" ");
|
|
25
26
|
|
|
26
27
|
// REGULAR TAGS COMPATIBLE WITH JSON-SCHEMA
|
|
27
|
-
for (const tag of attribute["x-typia-metaTags"]
|
|
28
|
+
for (const tag of attribute["x-typia-metaTags"] ?? []) {
|
|
28
29
|
// RANGE
|
|
29
30
|
if (tag.kind === "minLength") output.minLength = tag.value;
|
|
30
31
|
else if (tag.kind === "maxLength") output.maxLength = tag.value;
|
|
31
32
|
// FORMAT AND PATTERN
|
|
32
|
-
else if (tag.kind === "format") output.format = tag.value;
|
|
33
|
+
else if (tag.kind === "format") output.format = emendFormat(tag.value);
|
|
33
34
|
else if (tag.kind === "pattern") output.pattern = tag.value;
|
|
34
35
|
}
|
|
35
36
|
|
|
@@ -39,3 +40,6 @@ export const application_string = (
|
|
|
39
40
|
// RETURNS
|
|
40
41
|
return output;
|
|
41
42
|
};
|
|
43
|
+
|
|
44
|
+
const emendFormat = (tag: IMetadataTag.IFormat["value"]) =>
|
|
45
|
+
tag === "datetime" ? "date-time" : tag;
|