typia 3.8.9 → 3.9.0-dev.20230603
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/IRandomGenerator.d.ts +1 -0
- package/lib/factories/IdentifierFactory.js +2 -1
- package/lib/factories/IdentifierFactory.js.map +1 -1
- package/lib/factories/MetadataCollection.d.ts +22 -4
- package/lib/factories/MetadataCollection.js +121 -28
- package/lib/factories/MetadataCollection.js.map +1 -1
- package/lib/factories/MetadataFactory.d.ts +1 -0
- package/lib/factories/MetadataFactory.js +6 -48
- package/lib/factories/MetadataFactory.js.map +1 -1
- package/lib/factories/MetadataTagFactory.js +5 -3
- package/lib/factories/MetadataTagFactory.js.map +1 -1
- package/lib/factories/internal/metadata/emplace_metadata_array.d.ts +5 -0
- package/lib/factories/internal/metadata/emplace_metadata_array.js +38 -0
- package/lib/factories/internal/metadata/emplace_metadata_array.js.map +1 -0
- package/lib/factories/internal/metadata/emplace_metadata_definition.d.ts +5 -0
- package/lib/factories/internal/metadata/emplace_metadata_definition.js +38 -0
- package/lib/factories/internal/metadata/emplace_metadata_definition.js.map +1 -0
- package/lib/factories/internal/metadata/emplace_metadata_object.js +4 -4
- package/lib/factories/internal/metadata/emplace_metadata_object.js.map +1 -1
- package/lib/factories/internal/metadata/emplace_metadata_tuple.d.ts +5 -0
- package/lib/factories/internal/metadata/emplace_metadata_tuple.js +58 -0
- package/lib/factories/internal/metadata/emplace_metadata_tuple.js.map +1 -0
- package/lib/factories/internal/metadata/explore_metadata.d.ts +1 -1
- package/lib/factories/internal/metadata/explore_metadata.js +11 -34
- package/lib/factories/internal/metadata/explore_metadata.js.map +1 -1
- package/lib/factories/internal/metadata/iterate_metadata.d.ts +1 -1
- package/lib/factories/internal/metadata/iterate_metadata.js +5 -2
- package/lib/factories/internal/metadata/iterate_metadata.js.map +1 -1
- package/lib/factories/internal/metadata/iterate_metadata_array.js +4 -5
- package/lib/factories/internal/metadata/iterate_metadata_array.js.map +1 -1
- package/lib/factories/internal/metadata/iterate_metadata_collection.d.ts +2 -0
- package/lib/factories/internal/metadata/iterate_metadata_collection.js +151 -0
- package/lib/factories/internal/metadata/iterate_metadata_collection.js.map +1 -0
- package/lib/factories/internal/metadata/iterate_metadata_definition.d.ts +5 -0
- package/lib/factories/internal/metadata/iterate_metadata_definition.js +24 -0
- package/lib/factories/internal/metadata/iterate_metadata_definition.js.map +1 -0
- package/lib/factories/internal/metadata/iterate_metadata_object.js +1 -1
- package/lib/factories/internal/metadata/iterate_metadata_object.js.map +1 -1
- package/lib/factories/internal/metadata/iterate_metadata_sort.d.ts +3 -0
- package/lib/factories/internal/metadata/iterate_metadata_sort.js +156 -0
- package/lib/factories/internal/metadata/iterate_metadata_sort.js.map +1 -0
- package/lib/factories/internal/metadata/iterate_metadata_tuple.js +3 -26
- package/lib/factories/internal/metadata/iterate_metadata_tuple.js.map +1 -1
- package/lib/factories/internal/metadata/iterate_metadata_union.js +3 -3
- package/lib/factories/internal/metadata/iterate_metadata_union.js.map +1 -1
- package/lib/metadata/IMetadata.d.ts +3 -2
- package/lib/metadata/IMetadataApplication.d.ts +2 -2
- package/lib/metadata/IMetadataArray.d.ts +8 -0
- package/lib/metadata/IMetadataArray.js +3 -0
- package/lib/metadata/IMetadataArray.js.map +1 -0
- package/lib/metadata/IMetadataCollection.d.ts +10 -0
- package/lib/metadata/IMetadataCollection.js +3 -0
- package/lib/metadata/IMetadataCollection.js.map +1 -0
- package/lib/metadata/IMetadataDefinition.d.ts +10 -0
- package/lib/metadata/IMetadataDefinition.js +3 -0
- package/lib/metadata/IMetadataDefinition.js.map +1 -0
- package/lib/metadata/IMetadataDictionary.js +3 -0
- package/lib/metadata/IMetadataDictionary.js.map +1 -0
- package/lib/metadata/IMetadataObject.d.ts +3 -0
- package/lib/metadata/IMetadataProperty.d.ts +1 -1
- package/lib/metadata/IMetadataTuple.d.ts +8 -0
- package/lib/metadata/IMetadataTuple.js +3 -0
- package/lib/metadata/IMetadataTuple.js.map +1 -0
- package/lib/metadata/Metadata.d.ts +24 -21
- package/lib/metadata/Metadata.js +323 -262
- package/lib/metadata/Metadata.js.map +1 -1
- package/lib/metadata/MetadataArray.d.ts +12 -0
- package/lib/metadata/MetadataArray.js +36 -0
- package/lib/metadata/MetadataArray.js.map +1 -0
- package/lib/metadata/MetadataDefinition.d.ts +16 -0
- package/lib/metadata/MetadataDefinition.js +39 -0
- package/lib/metadata/MetadataDefinition.js.map +1 -0
- package/lib/metadata/MetadataObject.d.ts +4 -0
- package/lib/metadata/MetadataObject.js +3 -5
- package/lib/metadata/MetadataObject.js.map +1 -1
- package/lib/metadata/MetadataProperty.d.ts +1 -1
- package/lib/metadata/MetadataProperty.js +3 -3
- package/lib/metadata/MetadataProperty.js.map +1 -1
- package/lib/metadata/MetadataTuple.d.ts +12 -0
- package/lib/metadata/MetadataTuple.js +36 -0
- package/lib/metadata/MetadataTuple.js.map +1 -0
- package/lib/programmers/ApplicationProgrammer.js +3 -3
- package/lib/programmers/ApplicationProgrammer.js.map +1 -1
- package/lib/programmers/AssertProgrammer.js +13 -21
- package/lib/programmers/AssertProgrammer.js.map +1 -1
- package/lib/programmers/CheckerProgrammer.d.ts +6 -7
- package/lib/programmers/CheckerProgrammer.js +276 -185
- package/lib/programmers/CheckerProgrammer.js.map +1 -1
- package/lib/programmers/CloneProgrammer.js +312 -204
- package/lib/programmers/CloneProgrammer.js.map +1 -1
- package/lib/programmers/FeatureProgrammer.d.ts +21 -27
- package/lib/programmers/FeatureProgrammer.js +60 -63
- package/lib/programmers/FeatureProgrammer.js.map +1 -1
- package/lib/programmers/IsProgrammer.d.ts +3 -3
- package/lib/programmers/IsProgrammer.js +43 -28
- package/lib/programmers/IsProgrammer.js.map +1 -1
- package/lib/programmers/LiteralsProgrammer.js +1 -0
- package/lib/programmers/LiteralsProgrammer.js.map +1 -1
- package/lib/programmers/PruneProgrammer.js +270 -176
- package/lib/programmers/PruneProgrammer.js.map +1 -1
- package/lib/programmers/RandomProgrammer.js +124 -32
- package/lib/programmers/RandomProgrammer.js.map +1 -1
- package/lib/programmers/StringifyProgrammer.js +462 -356
- package/lib/programmers/StringifyProgrammer.js.map +1 -1
- package/lib/programmers/ValidateProgrammer.js +9 -9
- package/lib/programmers/ValidateProgrammer.js.map +1 -1
- package/lib/programmers/helpers/FunctionImporeter.d.ts +2 -0
- package/lib/programmers/helpers/FunctionImporeter.js +17 -2
- package/lib/programmers/helpers/FunctionImporeter.js.map +1 -1
- package/lib/programmers/helpers/RandomJoiner.d.ts +6 -1
- package/lib/programmers/helpers/RandomJoiner.js +11 -14
- package/lib/programmers/helpers/RandomJoiner.js.map +1 -1
- package/lib/programmers/helpers/UnionExplorer.d.ts +12 -10
- package/lib/programmers/helpers/UnionExplorer.js +47 -12
- package/lib/programmers/helpers/UnionExplorer.js.map +1 -1
- package/lib/programmers/helpers/UnionPredicator.js +1 -1
- package/lib/programmers/helpers/UnionPredicator.js.map +1 -1
- package/lib/programmers/helpers/disable_function_importer_declare.js +1 -0
- package/lib/programmers/helpers/disable_function_importer_declare.js.map +1 -1
- package/lib/programmers/internal/JSON_SCHEMA_PREFIX.d.ts +1 -1
- package/lib/programmers/internal/JSON_SCHEMA_PREFIX.js +2 -2
- package/lib/programmers/internal/JSON_SCHEMA_PREFIX.js.map +1 -1
- package/lib/programmers/internal/application_array.js +41 -21
- package/lib/programmers/internal/application_array.js.map +1 -1
- package/lib/programmers/internal/application_definition.d.ts +5 -0
- package/lib/programmers/internal/application_definition.js +45 -0
- package/lib/programmers/internal/application_definition.js.map +1 -0
- package/lib/programmers/internal/application_native.js +14 -11
- package/lib/programmers/internal/application_native.js.map +1 -1
- package/lib/programmers/internal/application_object.js +19 -14
- package/lib/programmers/internal/application_object.js.map +1 -1
- package/lib/programmers/internal/application_schema.js +28 -31
- package/lib/programmers/internal/application_schema.js.map +1 -1
- package/lib/programmers/internal/application_tuple.js +34 -5
- package/lib/programmers/internal/application_tuple.js.map +1 -1
- package/lib/programmers/internal/check_union_array_like.js +54 -63
- package/lib/programmers/internal/check_union_array_like.js.map +1 -1
- package/lib/programmers/internal/feature_object_entries.js +2 -2
- package/lib/programmers/internal/feature_object_entries.js.map +1 -1
- package/lib/programmers/internal/wrap_metadata_rest_tuple.d.ts +2 -0
- package/lib/programmers/internal/wrap_metadata_rest_tuple.js +18 -0
- package/lib/programmers/internal/wrap_metadata_rest_tuple.js.map +1 -0
- package/lib/schemas/IJsonApplication.d.ts +0 -4
- package/lib/schemas/IJsonComponents.d.ts +16 -4
- package/lib/schemas/IJsonSchema.d.ts +1 -1
- package/lib/transformers/CallExpressionTransformer.js.map +1 -1
- package/lib/transformers/FileTransformer.js +3 -3
- package/lib/transformers/FileTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/ApplicationTransformer.js +1 -0
- package/lib/transformers/features/miscellaneous/ApplicationTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/MetadataTransformer.js +2 -1
- package/lib/transformers/features/miscellaneous/MetadataTransformer.js.map +1 -1
- package/lib/utils/ArrayUtil.d.ts +1 -1
- package/lib/utils/ArrayUtil.js +2 -1
- package/lib/utils/ArrayUtil.js.map +1 -1
- package/lib/utils/RandomGenerator.js +2 -3
- package/lib/utils/RandomGenerator.js.map +1 -1
- package/package.json +6 -1
- package/src/IRandomGenerator.ts +1 -0
- package/src/factories/IdentifierFactory.ts +3 -1
- package/src/factories/MetadataCollection.ts +173 -34
- package/src/factories/MetadataFactory.ts +7 -29
- package/src/factories/MetadataTagFactory.ts +6 -3
- package/src/factories/internal/metadata/emplace_metadata_array.ts +34 -0
- package/src/factories/internal/metadata/emplace_metadata_definition.ts +35 -0
- package/src/factories/internal/metadata/emplace_metadata_object.ts +4 -4
- package/src/factories/internal/metadata/emplace_metadata_tuple.ts +50 -0
- package/src/factories/internal/metadata/explore_metadata.ts +18 -44
- package/src/factories/internal/metadata/iterate_metadata.ts +13 -3
- package/src/factories/internal/metadata/iterate_metadata_array.ts +7 -11
- package/src/factories/internal/metadata/iterate_metadata_collection.ts +130 -0
- package/src/factories/internal/metadata/iterate_metadata_definition.ts +34 -0
- package/src/factories/internal/metadata/iterate_metadata_object.ts +1 -0
- package/src/factories/internal/metadata/iterate_metadata_sort.ts +68 -0
- package/src/factories/internal/metadata/iterate_metadata_tuple.ts +7 -31
- package/src/factories/internal/metadata/iterate_metadata_union.ts +13 -2
- package/src/metadata/IMetadata.ts +3 -2
- package/src/metadata/IMetadataApplication.ts +2 -2
- package/src/metadata/IMetadataArray.ts +10 -0
- package/src/metadata/IMetadataCollection.ts +11 -0
- package/src/metadata/IMetadataDefinition.ts +12 -0
- package/src/metadata/IMetadataDictionary.ts +14 -0
- package/src/metadata/IMetadataObject.ts +2 -13
- package/src/metadata/IMetadataProperty.ts +1 -1
- package/src/metadata/IMetadataTuple.ts +10 -0
- package/src/metadata/Metadata.ts +473 -134
- package/src/metadata/MetadataArray.ts +52 -0
- package/src/metadata/MetadataDefinition.ts +65 -0
- package/src/metadata/MetadataObject.ts +7 -20
- package/src/metadata/MetadataProperty.ts +5 -5
- package/src/metadata/MetadataTuple.ts +53 -0
- package/src/programmers/ApplicationProgrammer.ts +1 -2
- package/src/programmers/AssertProgrammer.ts +45 -39
- package/src/programmers/CheckerProgrammer.ts +612 -331
- package/src/programmers/CloneProgrammer.ts +344 -138
- package/src/programmers/FeatureProgrammer.ts +110 -115
- package/src/programmers/IsProgrammer.ts +86 -52
- package/src/programmers/LiteralsProgrammer.ts +1 -0
- package/src/programmers/PruneProgrammer.ts +304 -101
- package/src/programmers/RandomProgrammer.ts +227 -61
- package/src/programmers/StringifyProgrammer.ts +374 -182
- package/src/programmers/ValidateProgrammer.ts +41 -44
- package/src/programmers/helpers/FunctionImporeter.ts +35 -11
- package/src/programmers/helpers/RandomJoiner.ts +25 -13
- package/src/programmers/helpers/UnionExplorer.ts +76 -50
- package/src/programmers/helpers/UnionPredicator.ts +1 -1
- package/src/programmers/helpers/disable_function_importer_declare.ts +5 -0
- package/src/programmers/internal/JSON_SCHEMA_PREFIX.ts +1 -1
- package/src/programmers/internal/application_array.ts +48 -16
- package/src/programmers/internal/application_definition.ts +45 -0
- package/src/programmers/internal/application_native.ts +15 -12
- package/src/programmers/internal/application_object.ts +17 -12
- package/src/programmers/internal/application_schema.ts +31 -65
- package/src/programmers/internal/application_tuple.ts +63 -13
- package/src/programmers/internal/check_union_array_like.ts +249 -191
- package/src/programmers/internal/feature_object_entries.ts +2 -2
- package/src/programmers/internal/wrap_metadata_rest_tuple.ts +16 -0
- package/src/schemas/IJsonApplication.ts +0 -5
- package/src/schemas/IJsonComponents.ts +17 -5
- package/src/schemas/IJsonSchema.ts +1 -1
- package/src/transformers/CallExpressionTransformer.ts +2 -0
- package/src/transformers/FileTransformer.ts +8 -8
- package/src/transformers/features/miscellaneous/ApplicationTransformer.ts +1 -0
- package/src/transformers/features/miscellaneous/MetadataTransformer.ts +2 -1
- package/src/utils/ArrayUtil.ts +3 -2
- package/src/utils/RandomGenerator.ts +3 -3
- package/lib/programmers/internal/check_union_tuple.js +0 -15
- package/lib/programmers/internal/check_union_tuple.js.map +0 -1
- package/src/programmers/internal/check_union_tuple.ts +0 -33
- /package/lib/{programmers/internal/check_union_tuple.d.ts → metadata/IMetadataDictionary.d.ts} +0 -0
|
@@ -32,41 +32,48 @@ export namespace ValidateProgrammer {
|
|
|
32
32
|
(equals: boolean) =>
|
|
33
33
|
(type: ts.Type, name?: string) => {
|
|
34
34
|
const importer: FunctionImporter = new FunctionImporter();
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
35
|
+
|
|
36
|
+
const is = IsProgrammer.write(project)(modulo, true)(equals)(
|
|
37
|
+
type,
|
|
38
|
+
name ?? TypeFactory.getFullName(project.checker)(type),
|
|
39
|
+
);
|
|
40
|
+
const validate: ts.ArrowFunction = CheckerProgrammer.write(project)(
|
|
41
|
+
{
|
|
42
|
+
prefix: "$v",
|
|
43
|
+
path: true,
|
|
44
|
+
trace: true,
|
|
45
|
+
numeric: OptionPredicator.numeric(project.options),
|
|
46
|
+
equals,
|
|
47
|
+
atomist: (explore) => (tuple) => (input) =>
|
|
48
|
+
[
|
|
49
|
+
tuple.expression,
|
|
50
|
+
...tuple.tags.map((tag) =>
|
|
51
|
+
ts.factory.createLogicalOr(
|
|
52
|
+
tag.expression,
|
|
53
|
+
create_report_call(
|
|
54
|
+
explore.from === "top"
|
|
55
|
+
? ts.factory.createTrue()
|
|
56
|
+
: ts.factory.createIdentifier(
|
|
57
|
+
"_exceptionable",
|
|
58
|
+
),
|
|
59
|
+
)(
|
|
60
|
+
ts.factory.createIdentifier(
|
|
61
|
+
explore.postfix
|
|
62
|
+
? `_path + ${explore.postfix}`
|
|
63
|
+
: "_path",
|
|
64
|
+
),
|
|
65
|
+
tag.expected,
|
|
66
|
+
input,
|
|
59
67
|
),
|
|
60
|
-
tag.expected,
|
|
61
|
-
input,
|
|
62
68
|
),
|
|
63
69
|
),
|
|
64
|
-
),
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
].reduce((x, y) => ts.factory.createLogicalAnd(x, y)),
|
|
71
|
+
combiner: combine(equals)(importer),
|
|
72
|
+
joiner: joiner(equals)(importer),
|
|
73
|
+
success: ts.factory.createTrue(),
|
|
74
|
+
addition: () => importer.declare(modulo),
|
|
75
|
+
},
|
|
76
|
+
)(importer)(type, name);
|
|
70
77
|
|
|
71
78
|
return ts.factory.createArrowFunction(
|
|
72
79
|
undefined,
|
|
@@ -85,16 +92,6 @@ export namespace ValidateProgrammer {
|
|
|
85
92
|
undefined,
|
|
86
93
|
ts.factory.createBlock(
|
|
87
94
|
[
|
|
88
|
-
StatementFactory.constant(
|
|
89
|
-
"__is",
|
|
90
|
-
IsProgrammer.write(project)(modulo, true)(equals)(
|
|
91
|
-
type,
|
|
92
|
-
name ??
|
|
93
|
-
TypeFactory.getFullName(project.checker)(
|
|
94
|
-
type,
|
|
95
|
-
),
|
|
96
|
-
),
|
|
97
|
-
),
|
|
98
95
|
StatementFactory.constant(
|
|
99
96
|
"errors",
|
|
100
97
|
ts.factory.createAsExpression(
|
|
@@ -119,7 +116,7 @@ export namespace ValidateProgrammer {
|
|
|
119
116
|
[ts.factory.createIdentifier("errors")],
|
|
120
117
|
),
|
|
121
118
|
),
|
|
122
|
-
|
|
119
|
+
StatementFactory.constant("__is", is),
|
|
123
120
|
ts.factory.createIfStatement(
|
|
124
121
|
ts.factory.createStrictEquality(
|
|
125
122
|
ts.factory.createFalse(),
|
|
@@ -131,7 +128,7 @@ export namespace ValidateProgrammer {
|
|
|
131
128
|
),
|
|
132
129
|
ts.factory.createExpressionStatement(
|
|
133
130
|
ts.factory.createCallExpression(
|
|
134
|
-
|
|
131
|
+
validate,
|
|
135
132
|
undefined,
|
|
136
133
|
[
|
|
137
134
|
ts.factory.createIdentifier("input"),
|
|
@@ -7,6 +7,8 @@ import { TypeFactory } from "../../factories/TypeFactory";
|
|
|
7
7
|
export class FunctionImporter {
|
|
8
8
|
private readonly used_: Set<string> = new Set();
|
|
9
9
|
private readonly local_: Set<string> = new Set();
|
|
10
|
+
private readonly unions_: Map<string, [string, ts.ArrowFunction]> =
|
|
11
|
+
new Map();
|
|
10
12
|
private sequence_: number = 0;
|
|
11
13
|
|
|
12
14
|
public empty(): boolean {
|
|
@@ -28,25 +30,47 @@ export class FunctionImporter {
|
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
public declare(modulo: ts.LeftHandSideExpression): ts.Statement[] {
|
|
31
|
-
return [
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
ts.factory.
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
return [
|
|
34
|
+
...[...this.used_].map((name) =>
|
|
35
|
+
StatementFactory.constant(
|
|
36
|
+
"$" + name,
|
|
37
|
+
IdentifierFactory.access(
|
|
38
|
+
ts.factory.createParenthesizedExpression(
|
|
39
|
+
ts.factory.createAsExpression(
|
|
40
|
+
modulo,
|
|
41
|
+
TypeFactory.keyword("any"),
|
|
42
|
+
),
|
|
39
43
|
),
|
|
40
|
-
),
|
|
41
|
-
)
|
|
44
|
+
)(name),
|
|
45
|
+
),
|
|
42
46
|
),
|
|
43
|
-
|
|
47
|
+
...[...this.unions_.values()].map(([key, arrow]) =>
|
|
48
|
+
StatementFactory.constant(key, arrow),
|
|
49
|
+
),
|
|
50
|
+
];
|
|
44
51
|
}
|
|
45
52
|
|
|
46
53
|
public increment(): number {
|
|
47
54
|
return ++this.sequence_;
|
|
48
55
|
}
|
|
49
56
|
|
|
57
|
+
public emplaceUnion(
|
|
58
|
+
prefix: string,
|
|
59
|
+
name: string,
|
|
60
|
+
factory: () => ts.ArrowFunction,
|
|
61
|
+
): string {
|
|
62
|
+
const oldbie = this.unions_.get(name);
|
|
63
|
+
if (oldbie) return oldbie[0];
|
|
64
|
+
|
|
65
|
+
const index: number = this.unions_.size;
|
|
66
|
+
const accessor: string = `${prefix}p${index}`;
|
|
67
|
+
|
|
68
|
+
const tuple: [string, ReturnType<typeof factory>] = [accessor, null!];
|
|
69
|
+
this.unions_.set(name, tuple);
|
|
70
|
+
tuple[1] = factory();
|
|
71
|
+
return accessor;
|
|
72
|
+
}
|
|
73
|
+
|
|
50
74
|
public trace(): void {
|
|
51
75
|
console.log(...this.used_);
|
|
52
76
|
console.log(...this.local_);
|
|
@@ -12,7 +12,6 @@ import { MetadataProperty } from "../../metadata/MetadataProperty";
|
|
|
12
12
|
import { Escaper } from "../../utils/Escaper";
|
|
13
13
|
|
|
14
14
|
import { get_comment_tags } from "../internal/get_comment_tags";
|
|
15
|
-
import { RandomRanger } from "./RandomRanger";
|
|
16
15
|
|
|
17
16
|
export namespace RandomJoiner {
|
|
18
17
|
export type Decoder = (
|
|
@@ -24,17 +23,14 @@ export namespace RandomJoiner {
|
|
|
24
23
|
export const array =
|
|
25
24
|
(coalesce: (method: string) => ts.Expression) =>
|
|
26
25
|
(decoder: Decoder) =>
|
|
27
|
-
(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
maximum: "maxItems",
|
|
36
|
-
})(tags);
|
|
37
|
-
return ts.factory.createCallExpression(
|
|
26
|
+
(explore: IExplore) =>
|
|
27
|
+
(length: ts.Expression | undefined) =>
|
|
28
|
+
(
|
|
29
|
+
item: Metadata,
|
|
30
|
+
tags: IMetadataTag[],
|
|
31
|
+
comments: ICommentTag[],
|
|
32
|
+
): ts.Expression => {
|
|
33
|
+
const generator: ts.Expression = ts.factory.createCallExpression(
|
|
38
34
|
coalesce("array"),
|
|
39
35
|
undefined,
|
|
40
36
|
[
|
|
@@ -46,9 +42,20 @@ export namespace RandomJoiner {
|
|
|
46
42
|
undefined,
|
|
47
43
|
decoder(item, tags, comments),
|
|
48
44
|
),
|
|
49
|
-
...(
|
|
45
|
+
...(length ? [length] : []),
|
|
50
46
|
],
|
|
51
47
|
);
|
|
48
|
+
if (explore.recursive === false) return generator;
|
|
49
|
+
return ts.factory.createConditionalExpression(
|
|
50
|
+
ts.factory.createGreaterThanEquals(
|
|
51
|
+
ts.factory.createNumericLiteral(5),
|
|
52
|
+
ts.factory.createIdentifier("_depth"),
|
|
53
|
+
),
|
|
54
|
+
undefined,
|
|
55
|
+
generator,
|
|
56
|
+
undefined,
|
|
57
|
+
ts.factory.createArrayLiteralExpression([]),
|
|
58
|
+
);
|
|
52
59
|
};
|
|
53
60
|
|
|
54
61
|
export const tuple =
|
|
@@ -159,3 +166,8 @@ export namespace RandomJoiner {
|
|
|
159
166
|
),
|
|
160
167
|
]);
|
|
161
168
|
}
|
|
169
|
+
|
|
170
|
+
interface IExplore {
|
|
171
|
+
function: boolean;
|
|
172
|
+
recursive: boolean;
|
|
173
|
+
}
|
|
@@ -5,7 +5,9 @@ import { IdentifierFactory } from "../../factories/IdentifierFactory";
|
|
|
5
5
|
|
|
6
6
|
import { IMetadataTag } from "../../metadata/IMetadataTag";
|
|
7
7
|
import { Metadata } from "../../metadata/Metadata";
|
|
8
|
+
import { MetadataArray } from "../../metadata/MetadataArray";
|
|
8
9
|
import { MetadataObject } from "../../metadata/MetadataObject";
|
|
10
|
+
import { MetadataTuple } from "../../metadata/MetadataTuple";
|
|
9
11
|
|
|
10
12
|
import { FeatureProgrammer } from "../FeatureProgrammer";
|
|
11
13
|
import { check_union_array_like } from "../internal/check_union_array_like";
|
|
@@ -37,7 +39,7 @@ export namespace UnionExplorer {
|
|
|
37
39
|
): ts.Expression => {
|
|
38
40
|
// BREAKER
|
|
39
41
|
if (targets.length === 1)
|
|
40
|
-
return config.objector.decoder(
|
|
42
|
+
return config.objector.decoder()(
|
|
41
43
|
input,
|
|
42
44
|
targets[0]!,
|
|
43
45
|
explore,
|
|
@@ -78,7 +80,7 @@ export namespace UnionExplorer {
|
|
|
78
80
|
const accessor: ts.Expression =
|
|
79
81
|
IdentifierFactory.access(input)(key);
|
|
80
82
|
const pred: ts.Expression = spec.neighbour
|
|
81
|
-
? config.objector.checker(
|
|
83
|
+
? config.objector.checker()(
|
|
82
84
|
accessor,
|
|
83
85
|
spec.property.value,
|
|
84
86
|
{
|
|
@@ -95,7 +97,7 @@ export namespace UnionExplorer {
|
|
|
95
97
|
return ts.factory.createIfStatement(
|
|
96
98
|
(config.objector.is || ((exp) => exp))(pred),
|
|
97
99
|
ts.factory.createReturnStatement(
|
|
98
|
-
config.objector.decoder(
|
|
100
|
+
config.objector.decoder()(
|
|
99
101
|
input,
|
|
100
102
|
spec.object,
|
|
101
103
|
explore,
|
|
@@ -144,50 +146,73 @@ export namespace UnionExplorer {
|
|
|
144
146
|
/* -----------------------------------------------------------
|
|
145
147
|
ARRAY LIKE
|
|
146
148
|
----------------------------------------------------------- */
|
|
147
|
-
export const tuple = (
|
|
148
|
-
check_union_array_like<
|
|
149
|
-
|
|
149
|
+
export const tuple = (
|
|
150
|
+
props: check_union_array_like.IProps<MetadataTuple, MetadataTuple>,
|
|
151
|
+
) =>
|
|
152
|
+
check_union_array_like<MetadataTuple, MetadataTuple, MetadataTuple>({
|
|
153
|
+
transform: (x) => x,
|
|
154
|
+
element: (x) => x,
|
|
155
|
+
size: null!,
|
|
150
156
|
front: (input) => input,
|
|
151
157
|
array: (input) => input,
|
|
152
|
-
name: (
|
|
158
|
+
name: (t) => t.name,
|
|
153
159
|
})(props);
|
|
154
160
|
export namespace tuple {
|
|
155
161
|
export type IProps = check_union_array_like.IProps<
|
|
156
|
-
|
|
162
|
+
MetadataTuple,
|
|
163
|
+
MetadataTuple
|
|
157
164
|
>;
|
|
158
165
|
}
|
|
159
166
|
|
|
160
167
|
export const array = (props: array.IProps) =>
|
|
161
|
-
check_union_array_like<Metadata>({
|
|
168
|
+
check_union_array_like<MetadataArray, MetadataArray, Metadata>({
|
|
169
|
+
transform: (x) => x,
|
|
170
|
+
element: (x) => x.value,
|
|
162
171
|
size: (input) => IdentifierFactory.access(input)("length"),
|
|
163
172
|
front: (input) =>
|
|
164
173
|
ts.factory.createElementAccessExpression(input, 0),
|
|
165
174
|
array: (input) => input,
|
|
166
|
-
name: (t) =>
|
|
175
|
+
name: (t) => t.name,
|
|
167
176
|
})(props);
|
|
168
177
|
export namespace array {
|
|
169
|
-
export type IProps = check_union_array_like.IProps<
|
|
178
|
+
export type IProps = check_union_array_like.IProps<
|
|
179
|
+
MetadataArray,
|
|
180
|
+
Metadata
|
|
181
|
+
>;
|
|
170
182
|
}
|
|
171
183
|
|
|
172
184
|
export const array_or_tuple = (props: array_or_tuple.IProps) =>
|
|
173
|
-
check_union_array_like<
|
|
185
|
+
check_union_array_like<
|
|
186
|
+
MetadataArray | MetadataTuple,
|
|
187
|
+
MetadataArray | MetadataTuple,
|
|
188
|
+
Metadata | MetadataTuple
|
|
189
|
+
>({
|
|
190
|
+
transform: (x) => x,
|
|
191
|
+
element: (x) => (x instanceof MetadataArray ? x.value : x),
|
|
174
192
|
size: (input) => IdentifierFactory.access(input)("length"),
|
|
175
193
|
front: (input) =>
|
|
176
194
|
ts.factory.createElementAccessExpression(input, 0),
|
|
177
195
|
array: (input) => input,
|
|
178
|
-
name: (
|
|
179
|
-
Array.isArray(t)
|
|
180
|
-
? `[${t.map((e) => e.getName()).join(", ")}]`
|
|
181
|
-
: `Array<${t.getName()}>`,
|
|
196
|
+
name: (m) => m.name,
|
|
182
197
|
})(props);
|
|
183
198
|
export namespace array_or_tuple {
|
|
184
199
|
export type IProps = check_union_array_like.IProps<
|
|
185
|
-
|
|
200
|
+
MetadataArray | MetadataTuple,
|
|
201
|
+
Metadata
|
|
186
202
|
>;
|
|
187
203
|
}
|
|
188
204
|
|
|
189
205
|
export const set = (props: set.IProps) =>
|
|
190
|
-
check_union_array_like<Metadata>({
|
|
206
|
+
check_union_array_like<Metadata, MetadataArray, Metadata>({
|
|
207
|
+
transform: (value: Metadata) =>
|
|
208
|
+
MetadataArray.create({
|
|
209
|
+
name: `Set<${value.getName()}>`,
|
|
210
|
+
index: null,
|
|
211
|
+
recursive: false,
|
|
212
|
+
nullables: [],
|
|
213
|
+
value,
|
|
214
|
+
}),
|
|
215
|
+
element: (array) => array.value,
|
|
191
216
|
size: (input) => IdentifierFactory.access(input)("size"),
|
|
192
217
|
front: (input) =>
|
|
193
218
|
IdentifierFactory.access(
|
|
@@ -208,14 +233,23 @@ export namespace UnionExplorer {
|
|
|
208
233
|
[ts.factory.createSpreadElement(input)],
|
|
209
234
|
false,
|
|
210
235
|
),
|
|
211
|
-
name: (
|
|
236
|
+
name: (_m, e) => `Set<${e.getName()}>`,
|
|
212
237
|
})(props);
|
|
213
238
|
export namespace set {
|
|
214
|
-
export type IProps = check_union_array_like.IProps<
|
|
239
|
+
export type IProps = check_union_array_like.IProps<
|
|
240
|
+
MetadataArray,
|
|
241
|
+
Metadata
|
|
242
|
+
>;
|
|
215
243
|
}
|
|
216
244
|
|
|
217
245
|
export const map = (props: map.IProps) =>
|
|
218
|
-
check_union_array_like<
|
|
246
|
+
check_union_array_like<
|
|
247
|
+
Metadata.Entry,
|
|
248
|
+
MetadataArray,
|
|
249
|
+
[Metadata, Metadata]
|
|
250
|
+
>({
|
|
251
|
+
element: (array) =>
|
|
252
|
+
array.value.tuples[0]!.elements as [Metadata, Metadata],
|
|
219
253
|
size: (input) => IdentifierFactory.access(input)("size"),
|
|
220
254
|
front: (input) =>
|
|
221
255
|
IdentifierFactory.access(
|
|
@@ -236,40 +270,32 @@ export namespace UnionExplorer {
|
|
|
236
270
|
[ts.factory.createSpreadElement(input)],
|
|
237
271
|
false,
|
|
238
272
|
),
|
|
239
|
-
name: ([k, v]) => `Map<${k.getName()}, ${v.getName()}>`,
|
|
273
|
+
name: (_m, [k, v]) => `Map<${k.getName()}, ${v.getName()}>`,
|
|
274
|
+
transform: (m: Metadata.Entry) =>
|
|
275
|
+
MetadataArray.create({
|
|
276
|
+
name: `Map<${m.key.getName()}, ${m.value.getName()}>`,
|
|
277
|
+
index: null,
|
|
278
|
+
recursive: false,
|
|
279
|
+
nullables: [],
|
|
280
|
+
value: Metadata.create({
|
|
281
|
+
...Metadata.initialize(),
|
|
282
|
+
tuples: [
|
|
283
|
+
MetadataTuple.create({
|
|
284
|
+
name: `[${m.key.getName()}, ${m.value.getName()}]`,
|
|
285
|
+
index: null,
|
|
286
|
+
recursive: false,
|
|
287
|
+
nullables: [],
|
|
288
|
+
elements: [m.key, m.value],
|
|
289
|
+
}),
|
|
290
|
+
],
|
|
291
|
+
}),
|
|
292
|
+
}),
|
|
240
293
|
})(props);
|
|
241
294
|
|
|
242
295
|
export namespace map {
|
|
243
296
|
export type IProps = check_union_array_like.IProps<
|
|
297
|
+
MetadataArray,
|
|
244
298
|
[Metadata, Metadata]
|
|
245
299
|
>;
|
|
246
300
|
}
|
|
247
|
-
|
|
248
|
-
// const transform = <T>(
|
|
249
|
-
// props: check_union_array_like.IProps<T>,
|
|
250
|
-
// ): check_union_array_like.IProps<T> => ({
|
|
251
|
-
// ...props,
|
|
252
|
-
// checker: (top, targets, explore, tags, array) =>
|
|
253
|
-
// props.checker(
|
|
254
|
-
// top,
|
|
255
|
-
// targets,
|
|
256
|
-
// {
|
|
257
|
-
// ...explore,
|
|
258
|
-
// tracable: false,
|
|
259
|
-
// postfix: `"[0]"`,
|
|
260
|
-
// },
|
|
261
|
-
// tags,
|
|
262
|
-
// array,
|
|
263
|
-
// ),
|
|
264
|
-
// decoder: (input, targets, explore, tags) =>
|
|
265
|
-
// props.decoder(
|
|
266
|
-
// input,
|
|
267
|
-
// targets,
|
|
268
|
-
// {
|
|
269
|
-
// ...explore,
|
|
270
|
-
// tracable: true,
|
|
271
|
-
// },
|
|
272
|
-
// tags,
|
|
273
|
-
// ),
|
|
274
|
-
// });
|
|
275
301
|
}
|
|
@@ -52,7 +52,7 @@ export namespace UnionPredicator {
|
|
|
52
52
|
const unique: boolean =
|
|
53
53
|
neighbors.length === 0 ||
|
|
54
54
|
neighbors.every(
|
|
55
|
-
(n) => !Metadata.intersects(prop.value, n.value
|
|
55
|
+
(n) => !Metadata.intersects(prop.value, n.value),
|
|
56
56
|
);
|
|
57
57
|
if (unique === true)
|
|
58
58
|
children.push({
|
|
@@ -13,6 +13,11 @@ const disable = (importer: FunctionImporter): MethodOnly<FunctionImporter> => ({
|
|
|
13
13
|
hasLocal: (name: string): boolean => importer.hasLocal(name),
|
|
14
14
|
declare: (_modulo: ts.LeftHandSideExpression): ts.Statement[] => [],
|
|
15
15
|
increment: (): number => importer.increment(),
|
|
16
|
+
emplaceUnion: (
|
|
17
|
+
prefix: string,
|
|
18
|
+
name: string,
|
|
19
|
+
factory: () => ts.ArrowFunction,
|
|
20
|
+
): string => importer.emplaceUnion(prefix, name, factory),
|
|
16
21
|
trace: (): void => importer.trace(),
|
|
17
22
|
});
|
|
18
23
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const
|
|
1
|
+
export const JSON_COMPONENTS_PREFIX = "#/components";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MetadataArray } from "../../metadata/MetadataArray";
|
|
2
2
|
import { IJsonComponents } from "../../schemas/IJsonComponents";
|
|
3
3
|
import { IJsonSchema } from "../../schemas/IJsonSchema";
|
|
4
4
|
|
|
5
5
|
import { ApplicationProgrammer } from "../ApplicationProgrammer";
|
|
6
|
+
import { JSON_COMPONENTS_PREFIX } from "./JSON_SCHEMA_PREFIX";
|
|
6
7
|
import { application_schema } from "./application_schema";
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -11,22 +12,53 @@ import { application_schema } from "./application_schema";
|
|
|
11
12
|
export const application_array =
|
|
12
13
|
(options: ApplicationProgrammer.IOptions) =>
|
|
13
14
|
(components: IJsonComponents) =>
|
|
14
|
-
(
|
|
15
|
-
(
|
|
16
|
-
(
|
|
15
|
+
(array: MetadataArray) =>
|
|
16
|
+
(attribute: IJsonSchema.IAttribute) =>
|
|
17
|
+
(
|
|
18
|
+
nullable: boolean,
|
|
19
|
+
):
|
|
20
|
+
| IJsonSchema.IArray
|
|
21
|
+
| IJsonSchema.IReference
|
|
22
|
+
| IJsonSchema.IRecursiveReference => {
|
|
17
23
|
// SCHEMA
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
const generator = () => {
|
|
25
|
+
const schema: IJsonSchema.IArray = {
|
|
26
|
+
...attribute,
|
|
27
|
+
type: "array",
|
|
28
|
+
items: application_schema(options)(false)(components)(
|
|
29
|
+
array.value,
|
|
30
|
+
)(array.recursive ? {} : attribute),
|
|
31
|
+
};
|
|
32
|
+
if (array.recursive === false) {
|
|
33
|
+
for (const tag of attribute["x-typia-metaTags"] ?? [])
|
|
34
|
+
if (tag.kind === "minItems") schema.minItems = tag.value;
|
|
35
|
+
else if (tag.kind === "maxItems")
|
|
36
|
+
schema.maxItems = tag.value;
|
|
37
|
+
}
|
|
38
|
+
return schema;
|
|
25
39
|
};
|
|
40
|
+
if (array.recursive === false) return generator();
|
|
26
41
|
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
42
|
+
// KEY
|
|
43
|
+
const key: string =
|
|
44
|
+
options.purpose === "ajv"
|
|
45
|
+
? array.name
|
|
46
|
+
: `${array.name}${nullable ? ".Nullable" : ""}`;
|
|
47
|
+
const $id: string = `${JSON_COMPONENTS_PREFIX}/arrays/${key}`;
|
|
48
|
+
|
|
49
|
+
// REFERENCE
|
|
50
|
+
if (components.arrays?.[key] === undefined) {
|
|
51
|
+
components.arrays ??= {};
|
|
52
|
+
components.arrays[key] = {} as any;
|
|
53
|
+
|
|
54
|
+
const repeated: IJsonComponents.IArray = {
|
|
55
|
+
...generator(),
|
|
56
|
+
$id: options.purpose === "ajv" ? $id : undefined,
|
|
57
|
+
$recursiveAnchor: options.purpose === "ajv" || undefined,
|
|
58
|
+
};
|
|
59
|
+
components.arrays[key] = repeated;
|
|
60
|
+
}
|
|
61
|
+
return options.purpose === "ajv" && array.recursive
|
|
62
|
+
? { ...attribute, $recursiveRef: $id }
|
|
63
|
+
: { ...attribute, $ref: $id };
|
|
32
64
|
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { MetadataDefinition } from "../../metadata/MetadataDefinition";
|
|
2
|
+
import { IJsonComponents } from "../../schemas/IJsonComponents";
|
|
3
|
+
|
|
4
|
+
import { IJsonSchema } from "../../module";
|
|
5
|
+
import { ApplicationProgrammer } from "../ApplicationProgrammer";
|
|
6
|
+
import { JSON_COMPONENTS_PREFIX } from "./JSON_SCHEMA_PREFIX";
|
|
7
|
+
import { application_schema } from "./application_schema";
|
|
8
|
+
|
|
9
|
+
export const application_definition =
|
|
10
|
+
(options: ApplicationProgrammer.IOptions) =>
|
|
11
|
+
<BlockNever extends boolean>(blockNever: BlockNever) =>
|
|
12
|
+
(components: IJsonComponents) =>
|
|
13
|
+
(def: MetadataDefinition) =>
|
|
14
|
+
(
|
|
15
|
+
nullable: boolean,
|
|
16
|
+
): IJsonSchema.IReference | IJsonSchema.IRecursiveReference => {
|
|
17
|
+
const key: string =
|
|
18
|
+
options.purpose === "ajv"
|
|
19
|
+
? def.name
|
|
20
|
+
: `${def.name}${nullable ? ".Nullable" : ""}`;
|
|
21
|
+
const $id: string = `${JSON_COMPONENTS_PREFIX}/definitions/${key}`;
|
|
22
|
+
|
|
23
|
+
// TEMPORARY ASSIGNMENT
|
|
24
|
+
if (components.definitions?.[key] === undefined) {
|
|
25
|
+
components.definitions ??= {};
|
|
26
|
+
components.definitions[key] = {
|
|
27
|
+
$id: key,
|
|
28
|
+
} as any;
|
|
29
|
+
|
|
30
|
+
// GENERATE SCHEM
|
|
31
|
+
const schema: IJsonSchema = application_schema(options)(blockNever)(
|
|
32
|
+
components,
|
|
33
|
+
)(def.value)({})!;
|
|
34
|
+
components.definitions ??= {};
|
|
35
|
+
components.definitions[key] = {
|
|
36
|
+
$id: options.purpose === "ajv" ? $id : undefined,
|
|
37
|
+
$recursiveAnchor:
|
|
38
|
+
(options.purpose === "ajv" && def.recursive) || undefined,
|
|
39
|
+
...schema,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return options.purpose === "ajv" && def.recursive
|
|
43
|
+
? { $recursiveRef: $id }
|
|
44
|
+
: { $ref: $id };
|
|
45
|
+
};
|
|
@@ -2,7 +2,7 @@ import { IJsonComponents } from "../../schemas/IJsonComponents";
|
|
|
2
2
|
|
|
3
3
|
import { IJsonSchema } from "../../module";
|
|
4
4
|
import { ApplicationProgrammer } from "../ApplicationProgrammer";
|
|
5
|
-
import {
|
|
5
|
+
import { JSON_COMPONENTS_PREFIX } from "./JSON_SCHEMA_PREFIX";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @internal
|
|
@@ -19,18 +19,21 @@ export const application_native =
|
|
|
19
19
|
options.purpose === "ajv"
|
|
20
20
|
? name
|
|
21
21
|
: `${name}${props.nullable ? ".Nullable" : ""}`;
|
|
22
|
-
components.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
if (components.objects?.[key] === undefined) {
|
|
23
|
+
components.objects ??= {};
|
|
24
|
+
components.objects[key] ??= {
|
|
25
|
+
type: "object",
|
|
26
|
+
$id:
|
|
27
|
+
options.purpose === "ajv"
|
|
28
|
+
? `${JSON_COMPONENTS_PREFIX}/objects/${key}`
|
|
29
|
+
: undefined,
|
|
30
|
+
properties: {},
|
|
31
|
+
nullable:
|
|
32
|
+
options.purpose === "swagger" ? props.nullable : undefined,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
32
35
|
return {
|
|
33
36
|
...props.attribute,
|
|
34
|
-
$ref: `${
|
|
37
|
+
$ref: `${JSON_COMPONENTS_PREFIX}/objects/${key}`,
|
|
35
38
|
};
|
|
36
39
|
};
|