typia 4.1.6 → 4.1.7-dev.20230716
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/MetadataCollection.js +1 -0
- package/lib/factories/MetadataCollection.js.map +1 -1
- package/lib/factories/internal/metadata/{emplace_metadata_definition.d.ts → emplace_metadata_alias.d.ts} +1 -1
- package/lib/factories/internal/metadata/{emplace_metadata_definition.js → emplace_metadata_alias.js} +17 -5
- package/lib/factories/internal/metadata/emplace_metadata_alias.js.map +1 -0
- package/lib/factories/internal/metadata/iterate_metadata_alias.js +2 -2
- package/lib/factories/internal/metadata/iterate_metadata_alias.js.map +1 -1
- package/lib/factories/internal/metadata/iterate_metadata_collection.js +4 -4
- package/lib/factories/internal/metadata/iterate_metadata_collection.js.map +1 -1
- package/lib/metadata/IMetadataAlias.d.ts +3 -1
- package/lib/metadata/MetadataAlias.d.ts +2 -0
- package/lib/metadata/MetadataAlias.js +4 -1
- package/lib/metadata/MetadataAlias.js.map +1 -1
- package/lib/programmers/LiteralsProgrammer.js +3 -2
- package/lib/programmers/LiteralsProgrammer.js.map +1 -1
- package/lib/programmers/internal/application_alias.js +19 -3
- package/lib/programmers/internal/application_alias.js.map +1 -1
- package/lib/programmers/internal/application_object.js +1 -1
- package/lib/programmers/internal/application_object.js.map +1 -1
- package/package.json +1 -1
- package/src/factories/MetadataCollection.ts +1 -0
- package/src/factories/MetadataTagFactory.ts +355 -355
- package/src/factories/internal/metadata/{emplace_metadata_definition.ts → emplace_metadata_alias.ts} +7 -2
- package/src/factories/internal/metadata/iterate_metadata_alias.ts +4 -4
- package/src/factories/internal/metadata/iterate_metadata_collection.ts +4 -4
- package/src/metadata/IMetadataAlias.ts +3 -1
- package/src/metadata/IMetadataTag.ts +105 -105
- package/src/metadata/Metadata.ts +603 -603
- package/src/metadata/MetadataAlias.ts +6 -1
- package/src/module.ts +2038 -2038
- package/src/programmers/LiteralsProgrammer.ts +63 -62
- package/src/programmers/internal/application_alias.ts +20 -1
- package/src/programmers/internal/application_number.ts +74 -74
- package/src/programmers/internal/application_object.ts +1 -1
- package/src/transformers/CallExpressionTransformer.ts +179 -179
- package/src/transformers/features/miscellaneous/ApplicationTransformer.ts +104 -104
- package/lib/factories/internal/metadata/emplace_metadata_definition.js.map +0 -1
|
@@ -1,179 +1,179 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import ts from "typescript";
|
|
3
|
-
|
|
4
|
-
import { IProject } from "./IProject";
|
|
5
|
-
import { ApplicationTransformer } from "./features/miscellaneous/ApplicationTransformer";
|
|
6
|
-
import { AssertCloneTransformer } from "./features/miscellaneous/AssertCloneTransformer";
|
|
7
|
-
import { AssertPruneTransformer } from "./features/miscellaneous/AssertPruneTransformer";
|
|
8
|
-
import { CloneTransformer } from "./features/miscellaneous/CloneTransformer";
|
|
9
|
-
import { CreateAssertCloneTransformer } from "./features/miscellaneous/CreateAssertCloneTransformer";
|
|
10
|
-
import { CreateAssertPruneTransformer } from "./features/miscellaneous/CreateAssertPruneTransformer";
|
|
11
|
-
import { CreateCloneTransformer } from "./features/miscellaneous/CreateCloneTransformer";
|
|
12
|
-
import { CreateIsCloneTransformer } from "./features/miscellaneous/CreateIsCloneTransformer";
|
|
13
|
-
import { CreateIsPruneTransformer } from "./features/miscellaneous/CreateIsPruneTransformer";
|
|
14
|
-
import { CreatePruneTransformer } from "./features/miscellaneous/CreatePruneTransformer";
|
|
15
|
-
import { CreateRandomTransformer } from "./features/miscellaneous/CreateRandomTransformer";
|
|
16
|
-
import { CreateValidateCloneTransformer } from "./features/miscellaneous/CreateValidateCloneTransformer";
|
|
17
|
-
import { CreateValidatePruneTransformer } from "./features/miscellaneous/CreateValidatePruneTransformer";
|
|
18
|
-
import { IsCloneTransformer } from "./features/miscellaneous/IsCloneTransformer";
|
|
19
|
-
import { IsPruneTransformer } from "./features/miscellaneous/IsPruneTransformer";
|
|
20
|
-
import { LiteralsTransformer } from "./features/miscellaneous/LiteralsTransformer";
|
|
21
|
-
import { MetadataTransformer } from "./features/miscellaneous/MetadataTransformer";
|
|
22
|
-
import { PruneTransformer } from "./features/miscellaneous/PruneTransformer";
|
|
23
|
-
import { RandomTransformer } from "./features/miscellaneous/RandomTransformer";
|
|
24
|
-
import { ValidateCloneTransformer } from "./features/miscellaneous/ValidateCloneTransformer";
|
|
25
|
-
import { ValidatePruneTransformer } from "./features/miscellaneous/ValidatePruneTransformer";
|
|
26
|
-
import { AssertParseTransformer } from "./features/parsers/AssertParseTransformer";
|
|
27
|
-
import { CreateAssertParseTransformer } from "./features/parsers/CreateAssertParseTransformer";
|
|
28
|
-
import { CreateIsParseTransformer } from "./features/parsers/CreateIsParseTransformer";
|
|
29
|
-
import { CreateValidateParseTransformer } from "./features/parsers/CreateValidateParseTransformer";
|
|
30
|
-
import { IsParseTransformer } from "./features/parsers/IsParseTransformer";
|
|
31
|
-
import { ValidateParseTransformer } from "./features/parsers/ValidateParseTransformer";
|
|
32
|
-
import { AssertStringifyTransformer } from "./features/stringifiers/AssertStringifyTransformer";
|
|
33
|
-
import { CreateAssertStringifyTransformer } from "./features/stringifiers/CreateAssertStringifyTransformer";
|
|
34
|
-
import { CreateIsStringifyTransformer } from "./features/stringifiers/CreateIsStringifyTransformer";
|
|
35
|
-
import { CreateStringifyTransformer } from "./features/stringifiers/CreateStringifyTransformer";
|
|
36
|
-
import { CreateValidateStringifyTransformer } from "./features/stringifiers/CreateValidateStringifyProgrammer";
|
|
37
|
-
import { IsStringifyTransformer } from "./features/stringifiers/IsStringifyTransformer";
|
|
38
|
-
import { StringifyTransformer } from "./features/stringifiers/StringifyTransformer";
|
|
39
|
-
import { ValidateStringifyTransformer } from "./features/stringifiers/ValidateStringifyTransformer";
|
|
40
|
-
import { AssertTransformer } from "./features/validators/AssertTransformer";
|
|
41
|
-
import { CreateAssertTransformer } from "./features/validators/CreateAssertTransformer";
|
|
42
|
-
import { CreateIsTransformer } from "./features/validators/CreateIsTransformer";
|
|
43
|
-
import { CreateValidateTransformer } from "./features/validators/CreateValidateTransformer";
|
|
44
|
-
import { IsTransformer } from "./features/validators/IsTransformer";
|
|
45
|
-
import { ValidateTransformer } from "./features/validators/ValidateTransformer";
|
|
46
|
-
|
|
47
|
-
export namespace CallExpressionTransformer {
|
|
48
|
-
export const transform =
|
|
49
|
-
(project: IProject) =>
|
|
50
|
-
(expression: ts.CallExpression): ts.Expression => {
|
|
51
|
-
//----
|
|
52
|
-
// VALIDATIONS
|
|
53
|
-
//----
|
|
54
|
-
// SIGNATURE DECLARATION
|
|
55
|
-
const declaration: ts.Declaration | undefined =
|
|
56
|
-
project.checker.getResolvedSignature(expression)?.declaration;
|
|
57
|
-
if (!declaration) return expression;
|
|
58
|
-
|
|
59
|
-
// FILE PATH
|
|
60
|
-
const file: string = path.resolve(
|
|
61
|
-
declaration.getSourceFile().fileName,
|
|
62
|
-
);
|
|
63
|
-
if (
|
|
64
|
-
file.indexOf(LIB_PATH) === -1 &&
|
|
65
|
-
file !== SRC_PATH &&
|
|
66
|
-
file !== CLI_PATH
|
|
67
|
-
)
|
|
68
|
-
return expression;
|
|
69
|
-
|
|
70
|
-
//----
|
|
71
|
-
// TRANSFORMATION
|
|
72
|
-
//----
|
|
73
|
-
// FUNCTION NAME
|
|
74
|
-
const { name } =
|
|
75
|
-
project.checker.getTypeAtLocation(declaration).symbol;
|
|
76
|
-
|
|
77
|
-
// FIND TRANSFORMER
|
|
78
|
-
const functor: (() => Task) | undefined = FUNCTORS[name];
|
|
79
|
-
if (functor === undefined) return expression;
|
|
80
|
-
|
|
81
|
-
// console.log(expression.getSourceFile().fileName);
|
|
82
|
-
|
|
83
|
-
// RETURNS WITH TRANSFORMATION
|
|
84
|
-
return functor()(project)(expression.expression)(expression);
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
type Task = (
|
|
89
|
-
project: IProject,
|
|
90
|
-
) => (
|
|
91
|
-
modulo: ts.LeftHandSideExpression,
|
|
92
|
-
) => (expression: ts.CallExpression) => ts.Expression;
|
|
93
|
-
|
|
94
|
-
const LIB_PATH = path.join("node_modules", "typia", "lib", "module.d.ts");
|
|
95
|
-
const SRC_PATH = path.resolve(path.join(__dirname, "..", "module.ts"));
|
|
96
|
-
const CLI_PATH = path.resolve(
|
|
97
|
-
path.join(__dirname, "..", "..", "..", "src", "module.ts"),
|
|
98
|
-
);
|
|
99
|
-
|
|
100
|
-
const FUNCTORS: Record<string, () => Task> = {
|
|
101
|
-
//----
|
|
102
|
-
// SINGLE FUNCTIONS
|
|
103
|
-
//----
|
|
104
|
-
// BASIC VALIDATORS
|
|
105
|
-
assert: () => AssertTransformer.transform(false),
|
|
106
|
-
assertType: () => AssertTransformer.transform(false),
|
|
107
|
-
is: () => IsTransformer.transform(false),
|
|
108
|
-
validate: () => ValidateTransformer.transform(false),
|
|
109
|
-
|
|
110
|
-
// STRICT VALIDATORS
|
|
111
|
-
assertEquals: () => AssertTransformer.transform(true),
|
|
112
|
-
equals: () => IsTransformer.transform(true),
|
|
113
|
-
validateEquals: () => ValidateTransformer.transform(true),
|
|
114
|
-
|
|
115
|
-
// PARSE FUNCTIONS
|
|
116
|
-
isParse: () => IsParseTransformer.transform,
|
|
117
|
-
assertParse: () => AssertParseTransformer.transform,
|
|
118
|
-
validateParse: () => ValidateParseTransformer.transform,
|
|
119
|
-
|
|
120
|
-
// STRINGIFY FUNCTIONS
|
|
121
|
-
application: () => (project) => () =>
|
|
122
|
-
ApplicationTransformer.transform(project),
|
|
123
|
-
stringify: () => StringifyTransformer.transform,
|
|
124
|
-
assertStringify: () => AssertStringifyTransformer.transform,
|
|
125
|
-
isStringify: () => IsStringifyTransformer.transform,
|
|
126
|
-
validateStringify: () => ValidateStringifyTransformer.transform,
|
|
127
|
-
|
|
128
|
-
// MISC
|
|
129
|
-
metadata: () => (project) => () => MetadataTransformer.transform(project),
|
|
130
|
-
random: () => RandomTransformer.transform,
|
|
131
|
-
literals: () => (project) => () => LiteralsTransformer.transform(project),
|
|
132
|
-
|
|
133
|
-
clone: () => CloneTransformer.transform,
|
|
134
|
-
assertClone: () => AssertCloneTransformer.transform,
|
|
135
|
-
isClone: () => IsCloneTransformer.transform,
|
|
136
|
-
validateClone: () => ValidateCloneTransformer.transform,
|
|
137
|
-
|
|
138
|
-
prune: () => PruneTransformer.transform,
|
|
139
|
-
assertPrune: () => AssertPruneTransformer.transform,
|
|
140
|
-
isPrune: () => IsPruneTransformer.transform,
|
|
141
|
-
validatePrune: () => ValidatePruneTransformer.transform,
|
|
142
|
-
|
|
143
|
-
//----
|
|
144
|
-
// FACTORY FUNCTIONS
|
|
145
|
-
//----
|
|
146
|
-
// BASIC VALIDATORS
|
|
147
|
-
createAssert: () => CreateAssertTransformer.transform(false),
|
|
148
|
-
createAssertType: () => CreateAssertTransformer.transform(false),
|
|
149
|
-
createIs: () => CreateIsTransformer.transform(false),
|
|
150
|
-
createValidate: () => CreateValidateTransformer.transform(false),
|
|
151
|
-
|
|
152
|
-
// STRICT VALIDATORS
|
|
153
|
-
createAssertEquals: () => CreateAssertTransformer.transform(true),
|
|
154
|
-
createEquals: () => CreateIsTransformer.transform(true),
|
|
155
|
-
createValidateEquals: () => CreateValidateTransformer.transform(true),
|
|
156
|
-
|
|
157
|
-
// PARSE FUNCTIONS
|
|
158
|
-
createIsParse: () => CreateIsParseTransformer.transform,
|
|
159
|
-
createAssertParse: () => CreateAssertParseTransformer.transform,
|
|
160
|
-
createValidateParse: () => CreateValidateParseTransformer.transform,
|
|
161
|
-
|
|
162
|
-
// STRINGIFY FUNCTIONS
|
|
163
|
-
createStringify: () => CreateStringifyTransformer.transform,
|
|
164
|
-
createAssertStringify: () => CreateAssertStringifyTransformer.transform,
|
|
165
|
-
createIsStringify: () => CreateIsStringifyTransformer.transform,
|
|
166
|
-
createValidateStringify: () => CreateValidateStringifyTransformer.transform,
|
|
167
|
-
|
|
168
|
-
// MISC
|
|
169
|
-
createRandom: () => CreateRandomTransformer.transform,
|
|
170
|
-
createClone: () => CreateCloneTransformer.transform,
|
|
171
|
-
createAssertClone: () => CreateAssertCloneTransformer.transform,
|
|
172
|
-
createIsClone: () => CreateIsCloneTransformer.transform,
|
|
173
|
-
createValidateClone: () => CreateValidateCloneTransformer.transform,
|
|
174
|
-
|
|
175
|
-
createPrune: () => CreatePruneTransformer.transform,
|
|
176
|
-
createAssertPrune: () => CreateAssertPruneTransformer.transform,
|
|
177
|
-
createIsPrune: () => CreateIsPruneTransformer.transform,
|
|
178
|
-
createValidatePrune: () => CreateValidatePruneTransformer.transform,
|
|
179
|
-
};
|
|
1
|
+
import path from "path";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
|
|
4
|
+
import { IProject } from "./IProject";
|
|
5
|
+
import { ApplicationTransformer } from "./features/miscellaneous/ApplicationTransformer";
|
|
6
|
+
import { AssertCloneTransformer } from "./features/miscellaneous/AssertCloneTransformer";
|
|
7
|
+
import { AssertPruneTransformer } from "./features/miscellaneous/AssertPruneTransformer";
|
|
8
|
+
import { CloneTransformer } from "./features/miscellaneous/CloneTransformer";
|
|
9
|
+
import { CreateAssertCloneTransformer } from "./features/miscellaneous/CreateAssertCloneTransformer";
|
|
10
|
+
import { CreateAssertPruneTransformer } from "./features/miscellaneous/CreateAssertPruneTransformer";
|
|
11
|
+
import { CreateCloneTransformer } from "./features/miscellaneous/CreateCloneTransformer";
|
|
12
|
+
import { CreateIsCloneTransformer } from "./features/miscellaneous/CreateIsCloneTransformer";
|
|
13
|
+
import { CreateIsPruneTransformer } from "./features/miscellaneous/CreateIsPruneTransformer";
|
|
14
|
+
import { CreatePruneTransformer } from "./features/miscellaneous/CreatePruneTransformer";
|
|
15
|
+
import { CreateRandomTransformer } from "./features/miscellaneous/CreateRandomTransformer";
|
|
16
|
+
import { CreateValidateCloneTransformer } from "./features/miscellaneous/CreateValidateCloneTransformer";
|
|
17
|
+
import { CreateValidatePruneTransformer } from "./features/miscellaneous/CreateValidatePruneTransformer";
|
|
18
|
+
import { IsCloneTransformer } from "./features/miscellaneous/IsCloneTransformer";
|
|
19
|
+
import { IsPruneTransformer } from "./features/miscellaneous/IsPruneTransformer";
|
|
20
|
+
import { LiteralsTransformer } from "./features/miscellaneous/LiteralsTransformer";
|
|
21
|
+
import { MetadataTransformer } from "./features/miscellaneous/MetadataTransformer";
|
|
22
|
+
import { PruneTransformer } from "./features/miscellaneous/PruneTransformer";
|
|
23
|
+
import { RandomTransformer } from "./features/miscellaneous/RandomTransformer";
|
|
24
|
+
import { ValidateCloneTransformer } from "./features/miscellaneous/ValidateCloneTransformer";
|
|
25
|
+
import { ValidatePruneTransformer } from "./features/miscellaneous/ValidatePruneTransformer";
|
|
26
|
+
import { AssertParseTransformer } from "./features/parsers/AssertParseTransformer";
|
|
27
|
+
import { CreateAssertParseTransformer } from "./features/parsers/CreateAssertParseTransformer";
|
|
28
|
+
import { CreateIsParseTransformer } from "./features/parsers/CreateIsParseTransformer";
|
|
29
|
+
import { CreateValidateParseTransformer } from "./features/parsers/CreateValidateParseTransformer";
|
|
30
|
+
import { IsParseTransformer } from "./features/parsers/IsParseTransformer";
|
|
31
|
+
import { ValidateParseTransformer } from "./features/parsers/ValidateParseTransformer";
|
|
32
|
+
import { AssertStringifyTransformer } from "./features/stringifiers/AssertStringifyTransformer";
|
|
33
|
+
import { CreateAssertStringifyTransformer } from "./features/stringifiers/CreateAssertStringifyTransformer";
|
|
34
|
+
import { CreateIsStringifyTransformer } from "./features/stringifiers/CreateIsStringifyTransformer";
|
|
35
|
+
import { CreateStringifyTransformer } from "./features/stringifiers/CreateStringifyTransformer";
|
|
36
|
+
import { CreateValidateStringifyTransformer } from "./features/stringifiers/CreateValidateStringifyProgrammer";
|
|
37
|
+
import { IsStringifyTransformer } from "./features/stringifiers/IsStringifyTransformer";
|
|
38
|
+
import { StringifyTransformer } from "./features/stringifiers/StringifyTransformer";
|
|
39
|
+
import { ValidateStringifyTransformer } from "./features/stringifiers/ValidateStringifyTransformer";
|
|
40
|
+
import { AssertTransformer } from "./features/validators/AssertTransformer";
|
|
41
|
+
import { CreateAssertTransformer } from "./features/validators/CreateAssertTransformer";
|
|
42
|
+
import { CreateIsTransformer } from "./features/validators/CreateIsTransformer";
|
|
43
|
+
import { CreateValidateTransformer } from "./features/validators/CreateValidateTransformer";
|
|
44
|
+
import { IsTransformer } from "./features/validators/IsTransformer";
|
|
45
|
+
import { ValidateTransformer } from "./features/validators/ValidateTransformer";
|
|
46
|
+
|
|
47
|
+
export namespace CallExpressionTransformer {
|
|
48
|
+
export const transform =
|
|
49
|
+
(project: IProject) =>
|
|
50
|
+
(expression: ts.CallExpression): ts.Expression => {
|
|
51
|
+
//----
|
|
52
|
+
// VALIDATIONS
|
|
53
|
+
//----
|
|
54
|
+
// SIGNATURE DECLARATION
|
|
55
|
+
const declaration: ts.Declaration | undefined =
|
|
56
|
+
project.checker.getResolvedSignature(expression)?.declaration;
|
|
57
|
+
if (!declaration) return expression;
|
|
58
|
+
|
|
59
|
+
// FILE PATH
|
|
60
|
+
const file: string = path.resolve(
|
|
61
|
+
declaration.getSourceFile().fileName,
|
|
62
|
+
);
|
|
63
|
+
if (
|
|
64
|
+
file.indexOf(LIB_PATH) === -1 &&
|
|
65
|
+
file !== SRC_PATH &&
|
|
66
|
+
file !== CLI_PATH
|
|
67
|
+
)
|
|
68
|
+
return expression;
|
|
69
|
+
|
|
70
|
+
//----
|
|
71
|
+
// TRANSFORMATION
|
|
72
|
+
//----
|
|
73
|
+
// FUNCTION NAME
|
|
74
|
+
const { name } =
|
|
75
|
+
project.checker.getTypeAtLocation(declaration).symbol;
|
|
76
|
+
|
|
77
|
+
// FIND TRANSFORMER
|
|
78
|
+
const functor: (() => Task) | undefined = FUNCTORS[name];
|
|
79
|
+
if (functor === undefined) return expression;
|
|
80
|
+
|
|
81
|
+
// console.log(expression.getSourceFile().fileName);
|
|
82
|
+
|
|
83
|
+
// RETURNS WITH TRANSFORMATION
|
|
84
|
+
return functor()(project)(expression.expression)(expression);
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
type Task = (
|
|
89
|
+
project: IProject,
|
|
90
|
+
) => (
|
|
91
|
+
modulo: ts.LeftHandSideExpression,
|
|
92
|
+
) => (expression: ts.CallExpression) => ts.Expression;
|
|
93
|
+
|
|
94
|
+
const LIB_PATH = path.join("node_modules", "typia", "lib", "module.d.ts");
|
|
95
|
+
const SRC_PATH = path.resolve(path.join(__dirname, "..", "module.ts"));
|
|
96
|
+
const CLI_PATH = path.resolve(
|
|
97
|
+
path.join(__dirname, "..", "..", "..", "src", "module.ts"),
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
const FUNCTORS: Record<string, () => Task> = {
|
|
101
|
+
//----
|
|
102
|
+
// SINGLE FUNCTIONS
|
|
103
|
+
//----
|
|
104
|
+
// BASIC VALIDATORS
|
|
105
|
+
assert: () => AssertTransformer.transform(false),
|
|
106
|
+
assertType: () => AssertTransformer.transform(false),
|
|
107
|
+
is: () => IsTransformer.transform(false),
|
|
108
|
+
validate: () => ValidateTransformer.transform(false),
|
|
109
|
+
|
|
110
|
+
// STRICT VALIDATORS
|
|
111
|
+
assertEquals: () => AssertTransformer.transform(true),
|
|
112
|
+
equals: () => IsTransformer.transform(true),
|
|
113
|
+
validateEquals: () => ValidateTransformer.transform(true),
|
|
114
|
+
|
|
115
|
+
// PARSE FUNCTIONS
|
|
116
|
+
isParse: () => IsParseTransformer.transform,
|
|
117
|
+
assertParse: () => AssertParseTransformer.transform,
|
|
118
|
+
validateParse: () => ValidateParseTransformer.transform,
|
|
119
|
+
|
|
120
|
+
// STRINGIFY FUNCTIONS
|
|
121
|
+
application: () => (project) => () =>
|
|
122
|
+
ApplicationTransformer.transform(project),
|
|
123
|
+
stringify: () => StringifyTransformer.transform,
|
|
124
|
+
assertStringify: () => AssertStringifyTransformer.transform,
|
|
125
|
+
isStringify: () => IsStringifyTransformer.transform,
|
|
126
|
+
validateStringify: () => ValidateStringifyTransformer.transform,
|
|
127
|
+
|
|
128
|
+
// MISC
|
|
129
|
+
metadata: () => (project) => () => MetadataTransformer.transform(project),
|
|
130
|
+
random: () => RandomTransformer.transform,
|
|
131
|
+
literals: () => (project) => () => LiteralsTransformer.transform(project),
|
|
132
|
+
|
|
133
|
+
clone: () => CloneTransformer.transform,
|
|
134
|
+
assertClone: () => AssertCloneTransformer.transform,
|
|
135
|
+
isClone: () => IsCloneTransformer.transform,
|
|
136
|
+
validateClone: () => ValidateCloneTransformer.transform,
|
|
137
|
+
|
|
138
|
+
prune: () => PruneTransformer.transform,
|
|
139
|
+
assertPrune: () => AssertPruneTransformer.transform,
|
|
140
|
+
isPrune: () => IsPruneTransformer.transform,
|
|
141
|
+
validatePrune: () => ValidatePruneTransformer.transform,
|
|
142
|
+
|
|
143
|
+
//----
|
|
144
|
+
// FACTORY FUNCTIONS
|
|
145
|
+
//----
|
|
146
|
+
// BASIC VALIDATORS
|
|
147
|
+
createAssert: () => CreateAssertTransformer.transform(false),
|
|
148
|
+
createAssertType: () => CreateAssertTransformer.transform(false),
|
|
149
|
+
createIs: () => CreateIsTransformer.transform(false),
|
|
150
|
+
createValidate: () => CreateValidateTransformer.transform(false),
|
|
151
|
+
|
|
152
|
+
// STRICT VALIDATORS
|
|
153
|
+
createAssertEquals: () => CreateAssertTransformer.transform(true),
|
|
154
|
+
createEquals: () => CreateIsTransformer.transform(true),
|
|
155
|
+
createValidateEquals: () => CreateValidateTransformer.transform(true),
|
|
156
|
+
|
|
157
|
+
// PARSE FUNCTIONS
|
|
158
|
+
createIsParse: () => CreateIsParseTransformer.transform,
|
|
159
|
+
createAssertParse: () => CreateAssertParseTransformer.transform,
|
|
160
|
+
createValidateParse: () => CreateValidateParseTransformer.transform,
|
|
161
|
+
|
|
162
|
+
// STRINGIFY FUNCTIONS
|
|
163
|
+
createStringify: () => CreateStringifyTransformer.transform,
|
|
164
|
+
createAssertStringify: () => CreateAssertStringifyTransformer.transform,
|
|
165
|
+
createIsStringify: () => CreateIsStringifyTransformer.transform,
|
|
166
|
+
createValidateStringify: () => CreateValidateStringifyTransformer.transform,
|
|
167
|
+
|
|
168
|
+
// MISC
|
|
169
|
+
createRandom: () => CreateRandomTransformer.transform,
|
|
170
|
+
createClone: () => CreateCloneTransformer.transform,
|
|
171
|
+
createAssertClone: () => CreateAssertCloneTransformer.transform,
|
|
172
|
+
createIsClone: () => CreateIsCloneTransformer.transform,
|
|
173
|
+
createValidateClone: () => CreateValidateCloneTransformer.transform,
|
|
174
|
+
|
|
175
|
+
createPrune: () => CreatePruneTransformer.transform,
|
|
176
|
+
createAssertPrune: () => CreateAssertPruneTransformer.transform,
|
|
177
|
+
createIsPrune: () => CreateIsPruneTransformer.transform,
|
|
178
|
+
createValidatePrune: () => CreateValidatePruneTransformer.transform,
|
|
179
|
+
};
|
|
@@ -1,104 +1,104 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { LiteralFactory } from "../../../factories/LiteralFactory";
|
|
4
|
-
import { MetadataCollection } from "../../../factories/MetadataCollection";
|
|
5
|
-
import { MetadataFactory } from "../../../factories/MetadataFactory";
|
|
6
|
-
|
|
7
|
-
import { Metadata } from "../../../metadata/Metadata";
|
|
8
|
-
import { IJsonApplication } from "../../../schemas/IJsonApplication";
|
|
9
|
-
|
|
10
|
-
import { ApplicationProgrammer } from "../../../programmers/ApplicationProgrammer";
|
|
11
|
-
|
|
12
|
-
import { IProject } from "../../IProject";
|
|
13
|
-
|
|
14
|
-
export namespace ApplicationTransformer {
|
|
15
|
-
export const transform =
|
|
16
|
-
({ checker }: IProject) =>
|
|
17
|
-
(expression: ts.CallExpression): ts.Expression => {
|
|
18
|
-
if (!expression.typeArguments?.length)
|
|
19
|
-
throw new Error(NO_GENERIC_ARGUMENT);
|
|
20
|
-
|
|
21
|
-
//----
|
|
22
|
-
// GET ARGUMENTS
|
|
23
|
-
//----
|
|
24
|
-
// VALIDATE TUPLE ARGUMENTS
|
|
25
|
-
const top: ts.Node = expression.typeArguments[0]!;
|
|
26
|
-
if (!ts.isTupleTypeNode(top)) return expression;
|
|
27
|
-
else if (top.elements.some((child) => !ts.isTypeNode(child)))
|
|
28
|
-
return expression;
|
|
29
|
-
|
|
30
|
-
// GET TYPES
|
|
31
|
-
const types: ts.Type[] = top.elements.map((child) =>
|
|
32
|
-
checker.getTypeFromTypeNode(child as ts.TypeNode),
|
|
33
|
-
);
|
|
34
|
-
if (types.some((t) => t.isTypeParameter()))
|
|
35
|
-
throw new Error(GENERIC_ARGUMENT);
|
|
36
|
-
|
|
37
|
-
// ADDITIONAL PARAMETERS
|
|
38
|
-
const purpose: "swagger" | "ajv" = get_parameter(
|
|
39
|
-
checker,
|
|
40
|
-
"Purpose",
|
|
41
|
-
expression.typeArguments[1],
|
|
42
|
-
(str) => str === "swagger" || str === "ajv",
|
|
43
|
-
() => "swagger",
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
//----
|
|
47
|
-
// GENERATORS
|
|
48
|
-
//----
|
|
49
|
-
// METADATA
|
|
50
|
-
const collection: MetadataCollection = new MetadataCollection({
|
|
51
|
-
replace: MetadataCollection.replace,
|
|
52
|
-
});
|
|
53
|
-
const metadatas: Array<Metadata> = types.map((type) =>
|
|
54
|
-
MetadataFactory.analyze(checker)({
|
|
55
|
-
resolve: true,
|
|
56
|
-
constant: true,
|
|
57
|
-
absorb: false,
|
|
58
|
-
validate: (meta) => {
|
|
59
|
-
if (meta.atomics.find((str) => str === "bigint"))
|
|
60
|
-
throw new Error(NO_BIGIT);
|
|
61
|
-
},
|
|
62
|
-
})(collection)(type),
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
// APPLICATION
|
|
66
|
-
const app: IJsonApplication = ApplicationProgrammer.write({
|
|
67
|
-
purpose,
|
|
68
|
-
})(metadatas);
|
|
69
|
-
|
|
70
|
-
// RETURNS WITH LITERAL EXPRESSION
|
|
71
|
-
return LiteralFactory.generate(app);
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const get_parameter = <T extends string>(
|
|
75
|
-
checker: ts.TypeChecker,
|
|
76
|
-
name: string,
|
|
77
|
-
node: ts.TypeNode | undefined,
|
|
78
|
-
predicator: (value: string) => boolean,
|
|
79
|
-
defaulter: () => T,
|
|
80
|
-
): T => {
|
|
81
|
-
if (!node) return defaulter();
|
|
82
|
-
|
|
83
|
-
// CHECK LITERAL TYPE
|
|
84
|
-
const type: ts.Type = checker.getTypeFromTypeNode(node);
|
|
85
|
-
if (!type.isLiteral())
|
|
86
|
-
throw new Error(
|
|
87
|
-
`Error on typia.application(): generic argument "${name}" must be constant.`,
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
// GET VALUE AND VALIDATE IT
|
|
91
|
-
const value = type.value;
|
|
92
|
-
if (typeof value !== "string" || predicator(value) === false)
|
|
93
|
-
throw new Error(
|
|
94
|
-
`Error on typia.application(): invalid value on generic argument "${name}".`,
|
|
95
|
-
);
|
|
96
|
-
return value as T;
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const NO_GENERIC_ARGUMENT =
|
|
101
|
-
"Error on typia.application(): no generic argument.";
|
|
102
|
-
const GENERIC_ARGUMENT =
|
|
103
|
-
"Error on typia.application(): non-specified generic argument(s).";
|
|
104
|
-
const NO_BIGIT = "Error on typia.application(): does not allow bigint type.";
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { LiteralFactory } from "../../../factories/LiteralFactory";
|
|
4
|
+
import { MetadataCollection } from "../../../factories/MetadataCollection";
|
|
5
|
+
import { MetadataFactory } from "../../../factories/MetadataFactory";
|
|
6
|
+
|
|
7
|
+
import { Metadata } from "../../../metadata/Metadata";
|
|
8
|
+
import { IJsonApplication } from "../../../schemas/IJsonApplication";
|
|
9
|
+
|
|
10
|
+
import { ApplicationProgrammer } from "../../../programmers/ApplicationProgrammer";
|
|
11
|
+
|
|
12
|
+
import { IProject } from "../../IProject";
|
|
13
|
+
|
|
14
|
+
export namespace ApplicationTransformer {
|
|
15
|
+
export const transform =
|
|
16
|
+
({ checker }: IProject) =>
|
|
17
|
+
(expression: ts.CallExpression): ts.Expression => {
|
|
18
|
+
if (!expression.typeArguments?.length)
|
|
19
|
+
throw new Error(NO_GENERIC_ARGUMENT);
|
|
20
|
+
|
|
21
|
+
//----
|
|
22
|
+
// GET ARGUMENTS
|
|
23
|
+
//----
|
|
24
|
+
// VALIDATE TUPLE ARGUMENTS
|
|
25
|
+
const top: ts.Node = expression.typeArguments[0]!;
|
|
26
|
+
if (!ts.isTupleTypeNode(top)) return expression;
|
|
27
|
+
else if (top.elements.some((child) => !ts.isTypeNode(child)))
|
|
28
|
+
return expression;
|
|
29
|
+
|
|
30
|
+
// GET TYPES
|
|
31
|
+
const types: ts.Type[] = top.elements.map((child) =>
|
|
32
|
+
checker.getTypeFromTypeNode(child as ts.TypeNode),
|
|
33
|
+
);
|
|
34
|
+
if (types.some((t) => t.isTypeParameter()))
|
|
35
|
+
throw new Error(GENERIC_ARGUMENT);
|
|
36
|
+
|
|
37
|
+
// ADDITIONAL PARAMETERS
|
|
38
|
+
const purpose: "swagger" | "ajv" = get_parameter(
|
|
39
|
+
checker,
|
|
40
|
+
"Purpose",
|
|
41
|
+
expression.typeArguments[1],
|
|
42
|
+
(str) => str === "swagger" || str === "ajv",
|
|
43
|
+
() => "swagger",
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
//----
|
|
47
|
+
// GENERATORS
|
|
48
|
+
//----
|
|
49
|
+
// METADATA
|
|
50
|
+
const collection: MetadataCollection = new MetadataCollection({
|
|
51
|
+
replace: MetadataCollection.replace,
|
|
52
|
+
});
|
|
53
|
+
const metadatas: Array<Metadata> = types.map((type) =>
|
|
54
|
+
MetadataFactory.analyze(checker)({
|
|
55
|
+
resolve: true,
|
|
56
|
+
constant: true,
|
|
57
|
+
absorb: false,
|
|
58
|
+
validate: (meta) => {
|
|
59
|
+
if (meta.atomics.find((str) => str === "bigint"))
|
|
60
|
+
throw new Error(NO_BIGIT);
|
|
61
|
+
},
|
|
62
|
+
})(collection)(type),
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
// APPLICATION
|
|
66
|
+
const app: IJsonApplication = ApplicationProgrammer.write({
|
|
67
|
+
purpose,
|
|
68
|
+
})(metadatas);
|
|
69
|
+
|
|
70
|
+
// RETURNS WITH LITERAL EXPRESSION
|
|
71
|
+
return LiteralFactory.generate(app);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const get_parameter = <T extends string>(
|
|
75
|
+
checker: ts.TypeChecker,
|
|
76
|
+
name: string,
|
|
77
|
+
node: ts.TypeNode | undefined,
|
|
78
|
+
predicator: (value: string) => boolean,
|
|
79
|
+
defaulter: () => T,
|
|
80
|
+
): T => {
|
|
81
|
+
if (!node) return defaulter();
|
|
82
|
+
|
|
83
|
+
// CHECK LITERAL TYPE
|
|
84
|
+
const type: ts.Type = checker.getTypeFromTypeNode(node);
|
|
85
|
+
if (!type.isLiteral())
|
|
86
|
+
throw new Error(
|
|
87
|
+
`Error on typia.application(): generic argument "${name}" must be constant.`,
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
// GET VALUE AND VALIDATE IT
|
|
91
|
+
const value = type.value;
|
|
92
|
+
if (typeof value !== "string" || predicator(value) === false)
|
|
93
|
+
throw new Error(
|
|
94
|
+
`Error on typia.application(): invalid value on generic argument "${name}".`,
|
|
95
|
+
);
|
|
96
|
+
return value as T;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const NO_GENERIC_ARGUMENT =
|
|
101
|
+
"Error on typia.application(): no generic argument.";
|
|
102
|
+
const GENERIC_ARGUMENT =
|
|
103
|
+
"Error on typia.application(): non-specified generic argument(s).";
|
|
104
|
+
const NO_BIGIT = "Error on typia.application(): does not allow bigint type.";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"emplace_metadata_definition.js","sourceRoot":"","sources":["../../../../src/factories/internal/metadata/emplace_metadata_definition.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAKA,sDAAqD;AAIrD,uDAAsD;AAE/C,IAAM,2BAA2B,GACpC,UAAC,OAAuB;IACxB,OAAA,UAAC,OAAiC;QAClC,OAAA,UAAC,UAA8B;YAC/B,OAAA,UAAC,IAAa,EAAE,QAAiB;gBAEvB,IAAA,KAAA,OAA2B,UAAU,CAAC,YAAY,CACpD,OAAO,EACP,IAAI,EACJ,IAAI,CAAC,WAAY,CACpB,IAAA,EAJM,KAAK,QAAA,EAAE,MAAM,QAAA,EAAE,OAAO,QAI5B,CAAC;gBACF,qBAAS,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;gBACzC,IAAI,MAAM,KAAK,KAAK;oBAAE,OAAO,KAAK,CAAC;gBAGnC,IAAM,KAAK,GAAa,IAAA,mCAAgB,EAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC,CAClE,IAAI,EACJ,KAAK,EACL,IAAI,CACP,CAAC;gBACF,OAAO,CAAC,KAAK,CAAC,CAAC;gBAEf,OAAO,KAAK,CAAC;YACjB,CAAC;QAnBD,CAmBC;IApBD,CAoBC;AArBD,CAqBC,CAAC;AAvBO,QAAA,2BAA2B,+BAuBlC"}
|