typia 7.0.0-dev.20241011 → 7.0.0-dev.20241011-2
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/factories/ProtobufFactory.js +0 -10
- package/lib/factories/ProtobufFactory.js.map +1 -1
- package/lib/internal/$ProtobufSizer.js +1 -8
- package/lib/internal/$ProtobufSizer.js.map +1 -1
- package/lib/json.d.ts +1 -1
- package/lib/module.d.ts +1 -1
- package/lib/module.js +1 -1
- package/lib/module.js.map +1 -1
- package/lib/programmers/internal/llm_schema_object.js +1 -1
- package/lib/programmers/internal/llm_schema_object.js.map +1 -1
- package/lib/programmers/json/JsonSchemasProgrammer.d.ts +1 -1
- package/lib/schemas/json/{IJsonSchemaList.js → IJsonSchemaCollection.js} +1 -1
- package/lib/schemas/json/IJsonSchemaCollection.js.map +1 -0
- package/package.json +2 -2
- package/src/executable/TypiaGenerateWizard.ts +83 -83
- package/src/executable/TypiaSetupWizard.ts +174 -174
- package/src/executable/setup/ArgumentParser.ts +42 -42
- package/src/executable/setup/FileRetriever.ts +19 -19
- package/src/executable/setup/PackageManager.ts +87 -87
- package/src/factories/IdentifierFactory.ts +89 -89
- package/src/factories/MetadataCollection.ts +278 -278
- package/src/factories/MetadataTypeTagFactory.ts +385 -385
- package/src/factories/MetadataTypeTagSchemaFactory.ts +82 -82
- package/src/factories/NumericRangeFactory.ts +72 -72
- package/src/factories/ProtobufFactory.ts +0 -14
- package/src/factories/StatementFactory.ts +90 -90
- package/src/factories/TemplateFactory.ts +64 -64
- package/src/factories/TypeFactory.ts +140 -140
- package/src/factories/internal/metadata/emplace_metadata_alias.ts +32 -32
- package/src/factories/internal/metadata/emplace_metadata_array_type.ts +39 -39
- package/src/factories/internal/metadata/emplace_metadata_tuple.ts +56 -56
- package/src/factories/internal/metadata/explore_metadata.ts +30 -30
- package/src/factories/internal/metadata/iterate_metadata.ts +54 -54
- package/src/factories/internal/metadata/iterate_metadata_alias.ts +28 -28
- package/src/factories/internal/metadata/iterate_metadata_array.ts +63 -63
- package/src/factories/internal/metadata/iterate_metadata_atomic.ts +62 -62
- package/src/factories/internal/metadata/iterate_metadata_coalesce.ts +28 -28
- package/src/factories/internal/metadata/iterate_metadata_constant.ts +76 -76
- package/src/factories/internal/metadata/iterate_metadata_escape.ts +49 -49
- package/src/factories/internal/metadata/iterate_metadata_intersection.ts +216 -216
- package/src/factories/internal/metadata/iterate_metadata_map.ts +52 -52
- package/src/factories/internal/metadata/iterate_metadata_native.ts +236 -236
- package/src/factories/internal/metadata/iterate_metadata_object.ts +27 -27
- package/src/factories/internal/metadata/iterate_metadata_set.ts +39 -39
- package/src/factories/internal/metadata/iterate_metadata_sort.ts +83 -83
- package/src/factories/internal/metadata/iterate_metadata_template.ts +42 -42
- package/src/factories/internal/metadata/iterate_metadata_tuple.ts +26 -26
- package/src/factories/internal/metadata/iterate_metadata_union.ts +19 -19
- package/src/internal/$ProtobufSizer.ts +1 -7
- package/src/json.ts +1 -1
- package/src/module.ts +1 -1
- package/src/programmers/functional/FunctionalIsFunctionProgrammer.ts +72 -72
- package/src/programmers/functional/FunctionalIsParametersProgrammer.ts +113 -113
- package/src/programmers/functional/FunctionalIsReturnProgrammer.ts +116 -116
- package/src/programmers/functional/internal/FunctionalGeneralProgrammer.ts +34 -34
- package/src/programmers/helpers/AtomicPredicator.ts +35 -35
- package/src/programmers/helpers/CloneJoiner.ts +143 -143
- package/src/programmers/helpers/HttpMetadataUtil.ts +21 -21
- package/src/programmers/helpers/NotationJoiner.ts +144 -144
- package/src/programmers/helpers/ProtobufUtil.ts +125 -125
- package/src/programmers/helpers/PruneJoiner.ts +148 -148
- package/src/programmers/helpers/StringifyPredicator.ts +13 -13
- package/src/programmers/helpers/UnionExplorer.ts +372 -372
- package/src/programmers/helpers/UnionPredicator.ts +77 -77
- package/src/programmers/internal/application_array.ts +56 -56
- package/src/programmers/internal/application_bigint.ts +25 -25
- package/src/programmers/internal/application_boolean.ts +25 -25
- package/src/programmers/internal/application_escaped.ts +96 -96
- package/src/programmers/internal/application_number.ts +25 -25
- package/src/programmers/internal/application_plugin.ts +19 -19
- package/src/programmers/internal/application_string.ts +25 -25
- package/src/programmers/internal/application_templates.ts +64 -64
- package/src/programmers/internal/application_union_discriminator.ts +35 -35
- package/src/programmers/internal/application_v30_alias.ts +59 -59
- package/src/programmers/internal/application_v30_native.ts +29 -29
- package/src/programmers/internal/application_v30_object.ts +165 -165
- package/src/programmers/internal/application_v30_schema.ts +220 -220
- package/src/programmers/internal/application_v30_tuple.ts +33 -33
- package/src/programmers/internal/application_v31_alias.ts +47 -47
- package/src/programmers/internal/application_v31_constant.ts +29 -29
- package/src/programmers/internal/application_v31_native.ts +25 -25
- package/src/programmers/internal/application_v31_object.ts +147 -147
- package/src/programmers/internal/application_v31_schema.ts +215 -215
- package/src/programmers/internal/application_v31_tuple.ts +22 -22
- package/src/programmers/internal/check_array_length.ts +46 -46
- package/src/programmers/internal/check_bigint.ts +49 -49
- package/src/programmers/internal/check_everything.ts +23 -23
- package/src/programmers/internal/check_native.ts +27 -27
- package/src/programmers/internal/check_number.ts +111 -111
- package/src/programmers/internal/check_string.ts +49 -49
- package/src/programmers/internal/check_template.ts +48 -48
- package/src/programmers/internal/check_union_array_like.ts +334 -334
- package/src/programmers/internal/decode_union_object.ts +116 -116
- package/src/programmers/internal/llm_schema_array.ts +22 -22
- package/src/programmers/internal/llm_schema_escaped.ts +84 -84
- package/src/programmers/internal/llm_schema_object.ts +132 -132
- package/src/programmers/internal/llm_schema_station.ts +190 -190
- package/src/programmers/internal/metadata_to_pattern.ts +42 -42
- package/src/programmers/internal/postfix_of_tuple.ts +5 -5
- package/src/programmers/internal/stringify_dynamic_properties.ts +162 -162
- package/src/programmers/internal/stringify_regular_properties.ts +81 -81
- package/src/programmers/internal/template_to_pattern.ts +23 -23
- package/src/programmers/internal/wrap_metadata_rest_tuple.ts +23 -23
- package/src/programmers/json/JsonSchemasProgrammer.ts +1 -1
- package/src/programmers/protobuf/ProtobufMessageProgrammer.ts +201 -201
- package/src/schemas/json/{IJsonSchemaList.ts → IJsonSchemaCollection.ts} +22 -22
- package/src/schemas/metadata/IMetadataDictionary.ts +11 -11
- package/src/schemas/metadata/Metadata.ts +616 -616
- package/src/schemas/metadata/MetadataComponents.ts +98 -98
- package/src/schemas/metadata/MetadataObject.ts +139 -139
- package/src/transformers/features/json/JsonSchemasTransformer.ts +1 -1
- package/src/utils/MapUtil.ts +14 -14
- package/src/utils/NameEncoder.ts +32 -32
- package/lib/schemas/json/IJsonSchemaList.js.map +0 -1
- /package/lib/schemas/json/{IJsonSchemaList.d.ts → IJsonSchemaCollection.d.ts} +0 -0
|
@@ -1,140 +1,140 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
export namespace TypeFactory {
|
|
4
|
-
export const isFunction = (type: ts.Type): boolean =>
|
|
5
|
-
getFunction(type) !== null;
|
|
6
|
-
|
|
7
|
-
export const getFunction = (type: ts.Type) => {
|
|
8
|
-
const node = type.symbol?.declarations?.[0];
|
|
9
|
-
if (node === undefined) return null;
|
|
10
|
-
|
|
11
|
-
return ts.isFunctionLike(node)
|
|
12
|
-
? node
|
|
13
|
-
: ts.isPropertyAssignment(node) || ts.isPropertyDeclaration(node)
|
|
14
|
-
? ts.isFunctionLike(node.initializer)
|
|
15
|
-
? node.initializer
|
|
16
|
-
: null
|
|
17
|
-
: null;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export const getReturnTypeOfClassMethod = (props: {
|
|
21
|
-
checker: ts.TypeChecker;
|
|
22
|
-
class: ts.Type;
|
|
23
|
-
function: string;
|
|
24
|
-
}): ts.Type | null => {
|
|
25
|
-
// FIND TO-JSON METHOD
|
|
26
|
-
const symbol: ts.Symbol | undefined = props.class.getProperty(
|
|
27
|
-
props.function,
|
|
28
|
-
);
|
|
29
|
-
if (!symbol) return null;
|
|
30
|
-
else if (!symbol.valueDeclaration) return null;
|
|
31
|
-
|
|
32
|
-
// GET FUNCTION DECLARATION
|
|
33
|
-
const functor: ts.Type = props.checker.getTypeOfSymbolAtLocation(
|
|
34
|
-
symbol,
|
|
35
|
-
symbol.valueDeclaration,
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
// RETURNS THE RETURN-TYPE
|
|
39
|
-
const signature: ts.Signature | undefined =
|
|
40
|
-
props.checker.getSignaturesOfType(functor, ts.SignatureKind.Call)[0];
|
|
41
|
-
return signature ? signature.getReturnType() : null;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export const getFullName = (props: {
|
|
45
|
-
checker: ts.TypeChecker;
|
|
46
|
-
type: ts.Type;
|
|
47
|
-
symbol?: ts.Symbol;
|
|
48
|
-
}): string => {
|
|
49
|
-
// PRIMITIVE
|
|
50
|
-
const symbol =
|
|
51
|
-
props.symbol ?? props.type.aliasSymbol ?? props.type.getSymbol();
|
|
52
|
-
if (symbol === undefined) return props.checker.typeToString(props.type);
|
|
53
|
-
|
|
54
|
-
// UNION OR INTERSECT
|
|
55
|
-
if (
|
|
56
|
-
props.type.aliasSymbol === undefined &&
|
|
57
|
-
props.type.isUnionOrIntersection()
|
|
58
|
-
) {
|
|
59
|
-
const joiner: string = props.type.isIntersection() ? " & " : " | ";
|
|
60
|
-
return props.type.types
|
|
61
|
-
.map((child) =>
|
|
62
|
-
getFullName({
|
|
63
|
-
checker: props.checker,
|
|
64
|
-
type: child,
|
|
65
|
-
}),
|
|
66
|
-
)
|
|
67
|
-
.join(joiner);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
//----
|
|
71
|
-
// SPECIALIZATION
|
|
72
|
-
//----
|
|
73
|
-
const name: string = get_name(symbol);
|
|
74
|
-
|
|
75
|
-
// CHECK GENERIC
|
|
76
|
-
const generic: readonly ts.Type[] = props.type.aliasSymbol
|
|
77
|
-
? (props.type.aliasTypeArguments ?? [])
|
|
78
|
-
: props.checker.getTypeArguments(props.type as ts.TypeReference);
|
|
79
|
-
return generic.length
|
|
80
|
-
? name === "Promise"
|
|
81
|
-
? getFullName({
|
|
82
|
-
checker: props.checker,
|
|
83
|
-
type: generic[0]!,
|
|
84
|
-
})
|
|
85
|
-
: `${name}<${generic
|
|
86
|
-
.map((child) =>
|
|
87
|
-
getFullName({
|
|
88
|
-
checker: props.checker,
|
|
89
|
-
type: child,
|
|
90
|
-
}),
|
|
91
|
-
)
|
|
92
|
-
.join(", ")}>`
|
|
93
|
-
: name;
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const explore_name = (props: { node: ts.Node; name: string }): string =>
|
|
97
|
-
ts.isModuleBlock(props.node)
|
|
98
|
-
? explore_name({
|
|
99
|
-
node: props.node.parent.parent,
|
|
100
|
-
name: `${props.node.parent.name.getFullText().trim()}.${props.name}`,
|
|
101
|
-
})
|
|
102
|
-
: props.name;
|
|
103
|
-
|
|
104
|
-
const get_name = (symbol: ts.Symbol): string => {
|
|
105
|
-
const parent = symbol.getDeclarations()?.[0]?.parent;
|
|
106
|
-
return parent
|
|
107
|
-
? explore_name({
|
|
108
|
-
node: parent,
|
|
109
|
-
name: symbol.escapedName.toString(),
|
|
110
|
-
})
|
|
111
|
-
: "__type";
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
export const keyword = (
|
|
115
|
-
type:
|
|
116
|
-
| "void"
|
|
117
|
-
| "any"
|
|
118
|
-
| "unknown"
|
|
119
|
-
| "boolean"
|
|
120
|
-
| "number"
|
|
121
|
-
| "bigint"
|
|
122
|
-
| "string",
|
|
123
|
-
) => {
|
|
124
|
-
return ts.factory.createKeywordTypeNode(
|
|
125
|
-
type === "void"
|
|
126
|
-
? ts.SyntaxKind.VoidKeyword
|
|
127
|
-
: type === "any"
|
|
128
|
-
? ts.SyntaxKind.AnyKeyword
|
|
129
|
-
: type === "unknown"
|
|
130
|
-
? ts.SyntaxKind.UnknownKeyword
|
|
131
|
-
: type === "boolean"
|
|
132
|
-
? ts.SyntaxKind.BooleanKeyword
|
|
133
|
-
: type === "number"
|
|
134
|
-
? ts.SyntaxKind.NumberKeyword
|
|
135
|
-
: type === "bigint"
|
|
136
|
-
? ts.SyntaxKind.BigIntKeyword
|
|
137
|
-
: ts.SyntaxKind.StringKeyword,
|
|
138
|
-
);
|
|
139
|
-
};
|
|
140
|
-
}
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
export namespace TypeFactory {
|
|
4
|
+
export const isFunction = (type: ts.Type): boolean =>
|
|
5
|
+
getFunction(type) !== null;
|
|
6
|
+
|
|
7
|
+
export const getFunction = (type: ts.Type) => {
|
|
8
|
+
const node = type.symbol?.declarations?.[0];
|
|
9
|
+
if (node === undefined) return null;
|
|
10
|
+
|
|
11
|
+
return ts.isFunctionLike(node)
|
|
12
|
+
? node
|
|
13
|
+
: ts.isPropertyAssignment(node) || ts.isPropertyDeclaration(node)
|
|
14
|
+
? ts.isFunctionLike(node.initializer)
|
|
15
|
+
? node.initializer
|
|
16
|
+
: null
|
|
17
|
+
: null;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const getReturnTypeOfClassMethod = (props: {
|
|
21
|
+
checker: ts.TypeChecker;
|
|
22
|
+
class: ts.Type;
|
|
23
|
+
function: string;
|
|
24
|
+
}): ts.Type | null => {
|
|
25
|
+
// FIND TO-JSON METHOD
|
|
26
|
+
const symbol: ts.Symbol | undefined = props.class.getProperty(
|
|
27
|
+
props.function,
|
|
28
|
+
);
|
|
29
|
+
if (!symbol) return null;
|
|
30
|
+
else if (!symbol.valueDeclaration) return null;
|
|
31
|
+
|
|
32
|
+
// GET FUNCTION DECLARATION
|
|
33
|
+
const functor: ts.Type = props.checker.getTypeOfSymbolAtLocation(
|
|
34
|
+
symbol,
|
|
35
|
+
symbol.valueDeclaration,
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
// RETURNS THE RETURN-TYPE
|
|
39
|
+
const signature: ts.Signature | undefined =
|
|
40
|
+
props.checker.getSignaturesOfType(functor, ts.SignatureKind.Call)[0];
|
|
41
|
+
return signature ? signature.getReturnType() : null;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const getFullName = (props: {
|
|
45
|
+
checker: ts.TypeChecker;
|
|
46
|
+
type: ts.Type;
|
|
47
|
+
symbol?: ts.Symbol;
|
|
48
|
+
}): string => {
|
|
49
|
+
// PRIMITIVE
|
|
50
|
+
const symbol =
|
|
51
|
+
props.symbol ?? props.type.aliasSymbol ?? props.type.getSymbol();
|
|
52
|
+
if (symbol === undefined) return props.checker.typeToString(props.type);
|
|
53
|
+
|
|
54
|
+
// UNION OR INTERSECT
|
|
55
|
+
if (
|
|
56
|
+
props.type.aliasSymbol === undefined &&
|
|
57
|
+
props.type.isUnionOrIntersection()
|
|
58
|
+
) {
|
|
59
|
+
const joiner: string = props.type.isIntersection() ? " & " : " | ";
|
|
60
|
+
return props.type.types
|
|
61
|
+
.map((child) =>
|
|
62
|
+
getFullName({
|
|
63
|
+
checker: props.checker,
|
|
64
|
+
type: child,
|
|
65
|
+
}),
|
|
66
|
+
)
|
|
67
|
+
.join(joiner);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
//----
|
|
71
|
+
// SPECIALIZATION
|
|
72
|
+
//----
|
|
73
|
+
const name: string = get_name(symbol);
|
|
74
|
+
|
|
75
|
+
// CHECK GENERIC
|
|
76
|
+
const generic: readonly ts.Type[] = props.type.aliasSymbol
|
|
77
|
+
? (props.type.aliasTypeArguments ?? [])
|
|
78
|
+
: props.checker.getTypeArguments(props.type as ts.TypeReference);
|
|
79
|
+
return generic.length
|
|
80
|
+
? name === "Promise"
|
|
81
|
+
? getFullName({
|
|
82
|
+
checker: props.checker,
|
|
83
|
+
type: generic[0]!,
|
|
84
|
+
})
|
|
85
|
+
: `${name}<${generic
|
|
86
|
+
.map((child) =>
|
|
87
|
+
getFullName({
|
|
88
|
+
checker: props.checker,
|
|
89
|
+
type: child,
|
|
90
|
+
}),
|
|
91
|
+
)
|
|
92
|
+
.join(", ")}>`
|
|
93
|
+
: name;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const explore_name = (props: { node: ts.Node; name: string }): string =>
|
|
97
|
+
ts.isModuleBlock(props.node)
|
|
98
|
+
? explore_name({
|
|
99
|
+
node: props.node.parent.parent,
|
|
100
|
+
name: `${props.node.parent.name.getFullText().trim()}.${props.name}`,
|
|
101
|
+
})
|
|
102
|
+
: props.name;
|
|
103
|
+
|
|
104
|
+
const get_name = (symbol: ts.Symbol): string => {
|
|
105
|
+
const parent = symbol.getDeclarations()?.[0]?.parent;
|
|
106
|
+
return parent
|
|
107
|
+
? explore_name({
|
|
108
|
+
node: parent,
|
|
109
|
+
name: symbol.escapedName.toString(),
|
|
110
|
+
})
|
|
111
|
+
: "__type";
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export const keyword = (
|
|
115
|
+
type:
|
|
116
|
+
| "void"
|
|
117
|
+
| "any"
|
|
118
|
+
| "unknown"
|
|
119
|
+
| "boolean"
|
|
120
|
+
| "number"
|
|
121
|
+
| "bigint"
|
|
122
|
+
| "string",
|
|
123
|
+
) => {
|
|
124
|
+
return ts.factory.createKeywordTypeNode(
|
|
125
|
+
type === "void"
|
|
126
|
+
? ts.SyntaxKind.VoidKeyword
|
|
127
|
+
: type === "any"
|
|
128
|
+
? ts.SyntaxKind.AnyKeyword
|
|
129
|
+
: type === "unknown"
|
|
130
|
+
? ts.SyntaxKind.UnknownKeyword
|
|
131
|
+
: type === "boolean"
|
|
132
|
+
? ts.SyntaxKind.BooleanKeyword
|
|
133
|
+
: type === "number"
|
|
134
|
+
? ts.SyntaxKind.NumberKeyword
|
|
135
|
+
: type === "bigint"
|
|
136
|
+
? ts.SyntaxKind.BigIntKeyword
|
|
137
|
+
: ts.SyntaxKind.StringKeyword,
|
|
138
|
+
);
|
|
139
|
+
};
|
|
140
|
+
}
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
2
|
-
import { MetadataAlias } from "../../../schemas/metadata/MetadataAlias";
|
|
3
|
-
|
|
4
|
-
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
5
|
-
|
|
6
|
-
import { IMetadataIteratorProps } from "./IMetadataIteratorProps";
|
|
7
|
-
import { explore_metadata } from "./explore_metadata";
|
|
8
|
-
|
|
9
|
-
export const emplace_metadata_alias = (
|
|
10
|
-
props: IMetadataIteratorProps,
|
|
11
|
-
): MetadataAlias => {
|
|
12
|
-
// CHECK EXISTENCE
|
|
13
|
-
const [alias, newbie, closure] = props.collection.emplaceAlias(
|
|
14
|
-
props.checker,
|
|
15
|
-
props.type,
|
|
16
|
-
props.type.aliasSymbol!,
|
|
17
|
-
);
|
|
18
|
-
ArrayUtil.add(alias.nullables, props.metadata.nullable);
|
|
19
|
-
if (newbie === false) return alias;
|
|
20
|
-
|
|
21
|
-
// CONSTRUCT VALUE TYPE
|
|
22
|
-
const value: Metadata = explore_metadata({
|
|
23
|
-
...props,
|
|
24
|
-
explore: {
|
|
25
|
-
...props.explore,
|
|
26
|
-
escaped: false,
|
|
27
|
-
aliased: true,
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
closure(value);
|
|
31
|
-
return alias;
|
|
32
|
-
};
|
|
1
|
+
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
2
|
+
import { MetadataAlias } from "../../../schemas/metadata/MetadataAlias";
|
|
3
|
+
|
|
4
|
+
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
5
|
+
|
|
6
|
+
import { IMetadataIteratorProps } from "./IMetadataIteratorProps";
|
|
7
|
+
import { explore_metadata } from "./explore_metadata";
|
|
8
|
+
|
|
9
|
+
export const emplace_metadata_alias = (
|
|
10
|
+
props: IMetadataIteratorProps,
|
|
11
|
+
): MetadataAlias => {
|
|
12
|
+
// CHECK EXISTENCE
|
|
13
|
+
const [alias, newbie, closure] = props.collection.emplaceAlias(
|
|
14
|
+
props.checker,
|
|
15
|
+
props.type,
|
|
16
|
+
props.type.aliasSymbol!,
|
|
17
|
+
);
|
|
18
|
+
ArrayUtil.add(alias.nullables, props.metadata.nullable);
|
|
19
|
+
if (newbie === false) return alias;
|
|
20
|
+
|
|
21
|
+
// CONSTRUCT VALUE TYPE
|
|
22
|
+
const value: Metadata = explore_metadata({
|
|
23
|
+
...props,
|
|
24
|
+
explore: {
|
|
25
|
+
...props.explore,
|
|
26
|
+
escaped: false,
|
|
27
|
+
aliased: true,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
closure(value);
|
|
31
|
+
return alias;
|
|
32
|
+
};
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
-
import { MetadataArrayType } from "../../../schemas/metadata/MetadataArrayType";
|
|
5
|
-
|
|
6
|
-
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
7
|
-
|
|
8
|
-
import { IMetadataIteratorProps } from "./IMetadataIteratorProps";
|
|
9
|
-
import { explore_metadata } from "./explore_metadata";
|
|
10
|
-
|
|
11
|
-
interface IProps extends IMetadataIteratorProps {
|
|
12
|
-
array: ts.Type;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const emplace_metadata_array_type = (
|
|
16
|
-
props: IProps,
|
|
17
|
-
): MetadataArrayType => {
|
|
18
|
-
// CHECK EXISTENCE
|
|
19
|
-
const [array, newbie, setValue] = props.collection.emplaceArray(
|
|
20
|
-
props.checker,
|
|
21
|
-
props.type,
|
|
22
|
-
);
|
|
23
|
-
ArrayUtil.add(array.nullables, props.metadata.nullable);
|
|
24
|
-
if (newbie === false) return array;
|
|
25
|
-
|
|
26
|
-
// CONSTRUCT VALUE TYPE
|
|
27
|
-
const value: Metadata = explore_metadata({
|
|
28
|
-
...props,
|
|
29
|
-
type: props.array.getNumberIndexType()!,
|
|
30
|
-
explore: {
|
|
31
|
-
...props.explore,
|
|
32
|
-
escaped: false,
|
|
33
|
-
aliased: false,
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
setValue(value);
|
|
37
|
-
|
|
38
|
-
return array;
|
|
39
|
-
};
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
+
import { MetadataArrayType } from "../../../schemas/metadata/MetadataArrayType";
|
|
5
|
+
|
|
6
|
+
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
7
|
+
|
|
8
|
+
import { IMetadataIteratorProps } from "./IMetadataIteratorProps";
|
|
9
|
+
import { explore_metadata } from "./explore_metadata";
|
|
10
|
+
|
|
11
|
+
interface IProps extends IMetadataIteratorProps {
|
|
12
|
+
array: ts.Type;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const emplace_metadata_array_type = (
|
|
16
|
+
props: IProps,
|
|
17
|
+
): MetadataArrayType => {
|
|
18
|
+
// CHECK EXISTENCE
|
|
19
|
+
const [array, newbie, setValue] = props.collection.emplaceArray(
|
|
20
|
+
props.checker,
|
|
21
|
+
props.type,
|
|
22
|
+
);
|
|
23
|
+
ArrayUtil.add(array.nullables, props.metadata.nullable);
|
|
24
|
+
if (newbie === false) return array;
|
|
25
|
+
|
|
26
|
+
// CONSTRUCT VALUE TYPE
|
|
27
|
+
const value: Metadata = explore_metadata({
|
|
28
|
+
...props,
|
|
29
|
+
type: props.array.getNumberIndexType()!,
|
|
30
|
+
explore: {
|
|
31
|
+
...props.explore,
|
|
32
|
+
escaped: false,
|
|
33
|
+
aliased: false,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
setValue(value);
|
|
37
|
+
|
|
38
|
+
return array;
|
|
39
|
+
};
|
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
-
import { MetadataTupleType } from "../../../schemas/metadata/MetadataTupleType";
|
|
5
|
-
|
|
6
|
-
import { Writable } from "../../../typings/Writable";
|
|
7
|
-
|
|
8
|
-
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
9
|
-
|
|
10
|
-
import { IMetadataIteratorProps } from "./IMetadataIteratorProps";
|
|
11
|
-
import { explore_metadata } from "./explore_metadata";
|
|
12
|
-
|
|
13
|
-
export const emplace_metadata_tuple = (
|
|
14
|
-
props: IMetadataIteratorProps<ts.TupleType>,
|
|
15
|
-
): MetadataTupleType => {
|
|
16
|
-
// CHECK EXISTENCE
|
|
17
|
-
const [tuple, newbie, closure] = props.collection.emplaceTuple(
|
|
18
|
-
props.checker,
|
|
19
|
-
props.type,
|
|
20
|
-
);
|
|
21
|
-
ArrayUtil.add(tuple.nullables, props.metadata.nullable);
|
|
22
|
-
if (newbie === false) return tuple;
|
|
23
|
-
|
|
24
|
-
// CONSTRUCT ELEMENT TYPES
|
|
25
|
-
const flagList: readonly ts.ElementFlags[] =
|
|
26
|
-
props.type.elementFlags ??
|
|
27
|
-
(props.type.target as ts.TupleType)?.elementFlags ??
|
|
28
|
-
[];
|
|
29
|
-
const elements: Metadata[] = props.checker
|
|
30
|
-
.getTypeArguments(props.type as ts.TypeReference)
|
|
31
|
-
.map((elem, i) => {
|
|
32
|
-
const child: Metadata = explore_metadata({
|
|
33
|
-
...props,
|
|
34
|
-
type: elem,
|
|
35
|
-
explore: {
|
|
36
|
-
...props.explore,
|
|
37
|
-
nested: tuple,
|
|
38
|
-
aliased: false,
|
|
39
|
-
escaped: false,
|
|
40
|
-
},
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
// CHECK OPTIONAL
|
|
44
|
-
const flag: ts.ElementFlags | undefined = flagList[i];
|
|
45
|
-
if (flag === ts.ElementFlags.Optional) Writable(child).optional = true;
|
|
46
|
-
|
|
47
|
-
// REST TYPE
|
|
48
|
-
if (flag !== ts.ElementFlags.Rest) return child;
|
|
49
|
-
const wrapper: Metadata = Metadata.initialize();
|
|
50
|
-
Writable(wrapper).rest = child;
|
|
51
|
-
return wrapper;
|
|
52
|
-
});
|
|
53
|
-
closure(elements);
|
|
54
|
-
|
|
55
|
-
return tuple;
|
|
56
|
-
};
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
+
import { MetadataTupleType } from "../../../schemas/metadata/MetadataTupleType";
|
|
5
|
+
|
|
6
|
+
import { Writable } from "../../../typings/Writable";
|
|
7
|
+
|
|
8
|
+
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
9
|
+
|
|
10
|
+
import { IMetadataIteratorProps } from "./IMetadataIteratorProps";
|
|
11
|
+
import { explore_metadata } from "./explore_metadata";
|
|
12
|
+
|
|
13
|
+
export const emplace_metadata_tuple = (
|
|
14
|
+
props: IMetadataIteratorProps<ts.TupleType>,
|
|
15
|
+
): MetadataTupleType => {
|
|
16
|
+
// CHECK EXISTENCE
|
|
17
|
+
const [tuple, newbie, closure] = props.collection.emplaceTuple(
|
|
18
|
+
props.checker,
|
|
19
|
+
props.type,
|
|
20
|
+
);
|
|
21
|
+
ArrayUtil.add(tuple.nullables, props.metadata.nullable);
|
|
22
|
+
if (newbie === false) return tuple;
|
|
23
|
+
|
|
24
|
+
// CONSTRUCT ELEMENT TYPES
|
|
25
|
+
const flagList: readonly ts.ElementFlags[] =
|
|
26
|
+
props.type.elementFlags ??
|
|
27
|
+
(props.type.target as ts.TupleType)?.elementFlags ??
|
|
28
|
+
[];
|
|
29
|
+
const elements: Metadata[] = props.checker
|
|
30
|
+
.getTypeArguments(props.type as ts.TypeReference)
|
|
31
|
+
.map((elem, i) => {
|
|
32
|
+
const child: Metadata = explore_metadata({
|
|
33
|
+
...props,
|
|
34
|
+
type: elem,
|
|
35
|
+
explore: {
|
|
36
|
+
...props.explore,
|
|
37
|
+
nested: tuple,
|
|
38
|
+
aliased: false,
|
|
39
|
+
escaped: false,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// CHECK OPTIONAL
|
|
44
|
+
const flag: ts.ElementFlags | undefined = flagList[i];
|
|
45
|
+
if (flag === ts.ElementFlags.Optional) Writable(child).optional = true;
|
|
46
|
+
|
|
47
|
+
// REST TYPE
|
|
48
|
+
if (flag !== ts.ElementFlags.Rest) return child;
|
|
49
|
+
const wrapper: Metadata = Metadata.initialize();
|
|
50
|
+
Writable(wrapper).rest = child;
|
|
51
|
+
return wrapper;
|
|
52
|
+
});
|
|
53
|
+
closure(elements);
|
|
54
|
+
|
|
55
|
+
return tuple;
|
|
56
|
+
};
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
-
|
|
5
|
-
import { IMetadataIteratorProps } from "./IMetadataIteratorProps";
|
|
6
|
-
import { emend_metadata_atomics } from "./emend_metadata_atomics";
|
|
7
|
-
import { iterate_metadata } from "./iterate_metadata";
|
|
8
|
-
|
|
9
|
-
export const explore_metadata = (props: IProps): Metadata => {
|
|
10
|
-
// CONSTRUCT METADATA
|
|
11
|
-
const metadata: Metadata = Metadata.initialize(props.explore.escaped);
|
|
12
|
-
if (props.type === null) return metadata;
|
|
13
|
-
|
|
14
|
-
// ITERATE TYPESCRIPT TYPES
|
|
15
|
-
iterate_metadata({
|
|
16
|
-
...props,
|
|
17
|
-
metadata,
|
|
18
|
-
type: props.type,
|
|
19
|
-
});
|
|
20
|
-
emend_metadata_atomics(metadata);
|
|
21
|
-
if (metadata.escaped) {
|
|
22
|
-
emend_metadata_atomics(metadata.escaped.original);
|
|
23
|
-
emend_metadata_atomics(metadata.escaped.returns);
|
|
24
|
-
}
|
|
25
|
-
return metadata;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
interface IProps extends Omit<IMetadataIteratorProps, "metadata" | "type"> {
|
|
29
|
-
type: ts.Type | null;
|
|
30
|
-
}
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { Metadata } from "../../../schemas/metadata/Metadata";
|
|
4
|
+
|
|
5
|
+
import { IMetadataIteratorProps } from "./IMetadataIteratorProps";
|
|
6
|
+
import { emend_metadata_atomics } from "./emend_metadata_atomics";
|
|
7
|
+
import { iterate_metadata } from "./iterate_metadata";
|
|
8
|
+
|
|
9
|
+
export const explore_metadata = (props: IProps): Metadata => {
|
|
10
|
+
// CONSTRUCT METADATA
|
|
11
|
+
const metadata: Metadata = Metadata.initialize(props.explore.escaped);
|
|
12
|
+
if (props.type === null) return metadata;
|
|
13
|
+
|
|
14
|
+
// ITERATE TYPESCRIPT TYPES
|
|
15
|
+
iterate_metadata({
|
|
16
|
+
...props,
|
|
17
|
+
metadata,
|
|
18
|
+
type: props.type,
|
|
19
|
+
});
|
|
20
|
+
emend_metadata_atomics(metadata);
|
|
21
|
+
if (metadata.escaped) {
|
|
22
|
+
emend_metadata_atomics(metadata.escaped.original);
|
|
23
|
+
emend_metadata_atomics(metadata.escaped.returns);
|
|
24
|
+
}
|
|
25
|
+
return metadata;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
interface IProps extends Omit<IMetadataIteratorProps, "metadata" | "type"> {
|
|
29
|
+
type: ts.Type | null;
|
|
30
|
+
}
|