@nestia/sdk 2.4.5 → 2.4.6
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/analyses/ConfigAnalyzer.js +1 -1
- package/lib/analyses/ConfigAnalyzer.js.map +1 -1
- package/lib/analyses/ControllerAnalyzer.js.map +1 -1
- package/lib/analyses/PathAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectAnalyzer.js.map +1 -1
- package/lib/executable/sdk.js +11 -11
- package/lib/generates/SwaggerGenerator.js.map +1 -1
- package/lib/generates/internal/SdkFunctionProgrammer.js +7 -7
- package/lib/generates/internal/SdkSimulationProgrammer.js.map +1 -1
- package/lib/generates/internal/SwaggerSchemaGenerator.js.map +1 -1
- package/package.json +3 -3
- package/src/INestiaConfig.ts +248 -248
- package/src/NestiaSdkApplication.ts +253 -253
- package/src/analyses/AccessorAnalyzer.ts +60 -60
- package/src/analyses/ConfigAnalyzer.ts +3 -3
- package/src/analyses/ControllerAnalyzer.ts +2 -2
- package/src/analyses/ExceptionAnalyzer.ts +115 -115
- package/src/analyses/GenericAnalyzer.ts +51 -51
- package/src/analyses/ImportAnalyzer.ts +138 -138
- package/src/analyses/PathAnalyzer.ts +14 -14
- package/src/analyses/ReflectAnalyzer.ts +9 -9
- package/src/analyses/SecurityAnalyzer.ts +20 -20
- package/src/executable/internal/CommandParser.ts +15 -15
- package/src/executable/internal/NestiaConfigLoader.ts +67 -67
- package/src/executable/internal/NestiaSdkCommand.ts +60 -60
- package/src/executable/sdk.ts +73 -73
- package/src/generates/E2eGenerator.ts +64 -64
- package/src/generates/SdkGenerator.ts +96 -96
- package/src/generates/SwaggerGenerator.ts +5 -5
- package/src/generates/internal/E2eFileProgrammer.ts +123 -123
- package/src/generates/internal/SdkDistributionComposer.ts +91 -91
- package/src/generates/internal/SdkDtoGenerator.ts +424 -424
- package/src/generates/internal/SdkFileProgrammer.ts +106 -106
- package/src/generates/internal/SdkFunctionProgrammer.ts +518 -518
- package/src/generates/internal/SdkImportWizard.ts +55 -55
- package/src/generates/internal/SdkRouteDirectory.ts +17 -17
- package/src/generates/internal/SdkSimulationProgrammer.ts +4 -4
- package/src/generates/internal/SdkTypeDefiner.ts +119 -119
- package/src/generates/internal/SwaggerSchemaGenerator.ts +16 -16
- package/src/generates/internal/SwaggerSchemaValidator.ts +198 -198
- package/src/index.ts +4 -4
- package/src/module.ts +2 -2
- package/src/structures/IController.ts +91 -91
- package/src/structures/IErrorReport.ts +6 -6
- package/src/structures/INestiaProject.ts +13 -13
- package/src/structures/INormalizedInput.ts +20 -20
- package/src/structures/IRoute.ts +52 -52
- package/src/structures/ISwagger.ts +91 -91
- package/src/structures/ISwaggerComponents.ts +29 -29
- package/src/structures/ISwaggerError.ts +8 -8
- package/src/structures/ISwaggerInfo.ts +80 -80
- package/src/structures/ISwaggerLazyProperty.ts +7 -7
- package/src/structures/ISwaggerLazySchema.ts +7 -7
- package/src/structures/ISwaggerRoute.ts +51 -51
- package/src/structures/ISwaggerSecurityScheme.ts +65 -65
- package/src/structures/ITypeTuple.ts +6 -6
- package/src/structures/MethodType.ts +5 -5
- package/src/structures/ParamCategory.ts +1 -1
- package/src/structures/TypeEntry.ts +22 -22
- package/src/utils/ArrayUtil.ts +26 -26
- package/src/utils/FileRetriever.ts +22 -22
- package/src/utils/ImportDictionary.ts +125 -125
- package/src/utils/MapUtil.ts +14 -14
- package/src/utils/PathUtil.ts +10 -10
- package/src/utils/SourceFinder.ts +66 -66
- package/src/utils/StripEnums.ts +5 -5
|
@@ -1,198 +1,198 @@
|
|
|
1
|
-
import { MetadataFactory } from "typia/lib/factories/MetadataFactory";
|
|
2
|
-
import { Metadata } from "typia/lib/schemas/metadata/Metadata";
|
|
3
|
-
import { MetadataArray } from "typia/lib/schemas/metadata/MetadataArray";
|
|
4
|
-
|
|
5
|
-
export namespace SwaggerSchemaValidator {
|
|
6
|
-
export const path = (meta: Metadata): string[] => {
|
|
7
|
-
const errors: string[] = [];
|
|
8
|
-
const insert = (msg: string) => errors.push(msg);
|
|
9
|
-
|
|
10
|
-
if (meta.any) insert("do not allow any type");
|
|
11
|
-
if (meta.isRequired() === false) insert("do not allow undefindable type");
|
|
12
|
-
|
|
13
|
-
const atomics = CoreMetadataUtil.atomics(meta);
|
|
14
|
-
const expected: number =
|
|
15
|
-
meta.atomics.length +
|
|
16
|
-
meta.templates.length +
|
|
17
|
-
meta.constants.map((c) => c.values.length).reduce((a, b) => a + b, 0);
|
|
18
|
-
if (meta.size() !== expected || atomics.size === 0)
|
|
19
|
-
insert("only atomic or constant types are allowed");
|
|
20
|
-
if (atomics.size > 1) insert("do not allow union type");
|
|
21
|
-
|
|
22
|
-
return errors;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const query = (
|
|
26
|
-
meta: Metadata,
|
|
27
|
-
explore: MetadataFactory.IExplore,
|
|
28
|
-
): string[] => {
|
|
29
|
-
const errors: string[] = [];
|
|
30
|
-
const insert = (msg: string) => errors.push(msg);
|
|
31
|
-
|
|
32
|
-
if (explore.top === true) {
|
|
33
|
-
// TOP MUST BE ONLY OBJECT
|
|
34
|
-
if (meta.objects.length !== 1 || meta.bucket() !== 1)
|
|
35
|
-
insert("only one object type is allowed.");
|
|
36
|
-
if (meta.nullable === true) insert("query parameters cannot be null.");
|
|
37
|
-
if (meta.isRequired() === false)
|
|
38
|
-
insert("query parameters cannot be undefined.");
|
|
39
|
-
} else if (
|
|
40
|
-
explore.nested !== null &&
|
|
41
|
-
explore.nested instanceof MetadataArray
|
|
42
|
-
) {
|
|
43
|
-
const atomics = CoreMetadataUtil.atomics(meta);
|
|
44
|
-
const expected: number =
|
|
45
|
-
meta.atomics.length +
|
|
46
|
-
meta.templates.length +
|
|
47
|
-
meta.constants.map((c) => c.values.length).reduce((a, b) => a + b, 0);
|
|
48
|
-
if (atomics.size > 1) insert("union type is not allowed in array.");
|
|
49
|
-
if (meta.nullable) insert("nullable type is not allowed in array.");
|
|
50
|
-
if (meta.isRequired() === false)
|
|
51
|
-
insert("optional type is not allowed in array.");
|
|
52
|
-
if (meta.size() !== expected)
|
|
53
|
-
insert("only atomic or constant types are allowed in array.");
|
|
54
|
-
} else if (explore.object && explore.property !== null) {
|
|
55
|
-
//----
|
|
56
|
-
// COMMON
|
|
57
|
-
//----
|
|
58
|
-
// PROPERTY MUST BE SOLE
|
|
59
|
-
if (typeof explore.property === "object")
|
|
60
|
-
insert("dynamic property is not allowed.");
|
|
61
|
-
// DO NOT ALLOW TUPLE TYPE
|
|
62
|
-
if (meta.tuples.length) insert("tuple type is not allowed.");
|
|
63
|
-
// DO NOT ALLOW UNION TYPE
|
|
64
|
-
if (CoreMetadataUtil.isUnion(meta)) insert("union type is not allowed.");
|
|
65
|
-
// DO NOT ALLOW NESTED OBJECT
|
|
66
|
-
if (
|
|
67
|
-
meta.objects.length ||
|
|
68
|
-
meta.sets.length ||
|
|
69
|
-
meta.maps.length ||
|
|
70
|
-
meta.natives.length
|
|
71
|
-
)
|
|
72
|
-
insert("nested object type is not allowed.");
|
|
73
|
-
|
|
74
|
-
//----
|
|
75
|
-
// ARRAY CASES
|
|
76
|
-
//----
|
|
77
|
-
const isArray: boolean = meta.arrays.length > 1 || meta.tuples.length > 1;
|
|
78
|
-
// ARRAY TYPE MUST BE REQUIRED
|
|
79
|
-
if (isArray && meta.isRequired() === false)
|
|
80
|
-
insert("optional type is not allowed when array.");
|
|
81
|
-
// SET-COOKIE MUST BE ARRAY
|
|
82
|
-
if (explore.property === "set-cookie" && !isArray)
|
|
83
|
-
insert("set-cookie property must be array.");
|
|
84
|
-
}
|
|
85
|
-
return errors;
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
export const headers = (
|
|
89
|
-
meta: Metadata,
|
|
90
|
-
explore: MetadataFactory.IExplore,
|
|
91
|
-
): string[] => {
|
|
92
|
-
const errors: string[] = [];
|
|
93
|
-
const insert = (msg: string) => errors.push(msg);
|
|
94
|
-
|
|
95
|
-
if (explore.top === true) {
|
|
96
|
-
// TOP MUST BE ONLY OBJECT
|
|
97
|
-
if (meta.objects.length !== 1 || meta.bucket() !== 1)
|
|
98
|
-
insert("only one object type is allowed.");
|
|
99
|
-
if (meta.nullable === true) insert("headers cannot be null.");
|
|
100
|
-
if (meta.isRequired() === false) insert("headers cannot be null.");
|
|
101
|
-
} else if (
|
|
102
|
-
explore.nested !== null &&
|
|
103
|
-
explore.nested instanceof MetadataArray
|
|
104
|
-
) {
|
|
105
|
-
const atomics = CoreMetadataUtil.atomics(meta);
|
|
106
|
-
const expected: number =
|
|
107
|
-
meta.atomics.length +
|
|
108
|
-
meta.templates.length +
|
|
109
|
-
meta.constants.map((c) => c.values.length).reduce((a, b) => a + b, 0);
|
|
110
|
-
if (atomics.size > 1) insert("union type is not allowed in array.");
|
|
111
|
-
if (meta.nullable) insert("nullable type is not allowed in array.");
|
|
112
|
-
if (meta.isRequired() === false) insert("optional type is not allowed.");
|
|
113
|
-
if (meta.size() !== expected)
|
|
114
|
-
insert("only atomic or constant types are allowed in array.");
|
|
115
|
-
} else if (explore.object && explore.property !== null) {
|
|
116
|
-
//----
|
|
117
|
-
// COMMON
|
|
118
|
-
//----
|
|
119
|
-
// PROPERTY MUST BE SOLE
|
|
120
|
-
if (typeof explore.property === "object")
|
|
121
|
-
insert("dynamic property is not allowed.");
|
|
122
|
-
// DO NOT ALLOW TUPLE TYPE
|
|
123
|
-
if (meta.tuples.length) insert("tuple type is not allowed.");
|
|
124
|
-
// DO NOT ALLOW UNION TYPE
|
|
125
|
-
if (CoreMetadataUtil.isUnion(meta)) insert("union type is not allowed.");
|
|
126
|
-
// DO NOT ALLOW NESTED OBJECT
|
|
127
|
-
if (
|
|
128
|
-
meta.objects.length ||
|
|
129
|
-
meta.sets.length ||
|
|
130
|
-
meta.maps.length ||
|
|
131
|
-
meta.natives.length
|
|
132
|
-
)
|
|
133
|
-
insert("nested object type is not allowed.");
|
|
134
|
-
// DO NOT ALLOW NULLABLE
|
|
135
|
-
if (meta.nullable) insert("nullable type is not allowed.");
|
|
136
|
-
|
|
137
|
-
//----
|
|
138
|
-
// ARRAY CASES
|
|
139
|
-
//----
|
|
140
|
-
const isArray: boolean = meta.arrays.length > 1;
|
|
141
|
-
// ARRAY TYPE MUST BE REQUIRED
|
|
142
|
-
if (isArray && meta.isRequired() === false)
|
|
143
|
-
insert("optional type is not allowed when array.");
|
|
144
|
-
// SET-COOKIE MUST BE ARRAY
|
|
145
|
-
if (explore.property === "set-cookie" && !isArray)
|
|
146
|
-
insert("set-cookie property must be array.");
|
|
147
|
-
// MUST BE SINGULAR CASE
|
|
148
|
-
if (
|
|
149
|
-
typeof explore.property === "string" &&
|
|
150
|
-
SINGULAR.has(explore.property) &&
|
|
151
|
-
isArray
|
|
152
|
-
)
|
|
153
|
-
insert("property cannot be array.");
|
|
154
|
-
}
|
|
155
|
-
return errors;
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
namespace CoreMetadataUtil {
|
|
160
|
-
export const atomics = (
|
|
161
|
-
meta: Metadata,
|
|
162
|
-
): Set<"boolean" | "bigint" | "number" | "string"> =>
|
|
163
|
-
new Set([
|
|
164
|
-
...meta.atomics.map((a) => a.type),
|
|
165
|
-
...meta.constants.map((c) => c.type),
|
|
166
|
-
...(meta.templates.length ? (["string"] as const) : []),
|
|
167
|
-
]);
|
|
168
|
-
|
|
169
|
-
export const isUnion = (meta: Metadata): boolean =>
|
|
170
|
-
atomics(meta).size +
|
|
171
|
-
meta.arrays.length +
|
|
172
|
-
meta.tuples.length +
|
|
173
|
-
meta.natives.length +
|
|
174
|
-
meta.maps.length +
|
|
175
|
-
meta.objects.length >
|
|
176
|
-
1;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
const SINGULAR: Set<string> = new Set([
|
|
180
|
-
"age",
|
|
181
|
-
"authorization",
|
|
182
|
-
"content-length",
|
|
183
|
-
"content-type",
|
|
184
|
-
"etag",
|
|
185
|
-
"expires",
|
|
186
|
-
"from",
|
|
187
|
-
"host",
|
|
188
|
-
"if-modified-since",
|
|
189
|
-
"if-unmodified-since",
|
|
190
|
-
"last-modified",
|
|
191
|
-
"location",
|
|
192
|
-
"max-forwards",
|
|
193
|
-
"proxy-authorization",
|
|
194
|
-
"referer",
|
|
195
|
-
"retry-after",
|
|
196
|
-
"server",
|
|
197
|
-
"user-agent",
|
|
198
|
-
]);
|
|
1
|
+
import { MetadataFactory } from "typia/lib/factories/MetadataFactory";
|
|
2
|
+
import { Metadata } from "typia/lib/schemas/metadata/Metadata";
|
|
3
|
+
import { MetadataArray } from "typia/lib/schemas/metadata/MetadataArray";
|
|
4
|
+
|
|
5
|
+
export namespace SwaggerSchemaValidator {
|
|
6
|
+
export const path = (meta: Metadata): string[] => {
|
|
7
|
+
const errors: string[] = [];
|
|
8
|
+
const insert = (msg: string) => errors.push(msg);
|
|
9
|
+
|
|
10
|
+
if (meta.any) insert("do not allow any type");
|
|
11
|
+
if (meta.isRequired() === false) insert("do not allow undefindable type");
|
|
12
|
+
|
|
13
|
+
const atomics = CoreMetadataUtil.atomics(meta);
|
|
14
|
+
const expected: number =
|
|
15
|
+
meta.atomics.length +
|
|
16
|
+
meta.templates.length +
|
|
17
|
+
meta.constants.map((c) => c.values.length).reduce((a, b) => a + b, 0);
|
|
18
|
+
if (meta.size() !== expected || atomics.size === 0)
|
|
19
|
+
insert("only atomic or constant types are allowed");
|
|
20
|
+
if (atomics.size > 1) insert("do not allow union type");
|
|
21
|
+
|
|
22
|
+
return errors;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const query = (
|
|
26
|
+
meta: Metadata,
|
|
27
|
+
explore: MetadataFactory.IExplore,
|
|
28
|
+
): string[] => {
|
|
29
|
+
const errors: string[] = [];
|
|
30
|
+
const insert = (msg: string) => errors.push(msg);
|
|
31
|
+
|
|
32
|
+
if (explore.top === true) {
|
|
33
|
+
// TOP MUST BE ONLY OBJECT
|
|
34
|
+
if (meta.objects.length !== 1 || meta.bucket() !== 1)
|
|
35
|
+
insert("only one object type is allowed.");
|
|
36
|
+
if (meta.nullable === true) insert("query parameters cannot be null.");
|
|
37
|
+
if (meta.isRequired() === false)
|
|
38
|
+
insert("query parameters cannot be undefined.");
|
|
39
|
+
} else if (
|
|
40
|
+
explore.nested !== null &&
|
|
41
|
+
explore.nested instanceof MetadataArray
|
|
42
|
+
) {
|
|
43
|
+
const atomics = CoreMetadataUtil.atomics(meta);
|
|
44
|
+
const expected: number =
|
|
45
|
+
meta.atomics.length +
|
|
46
|
+
meta.templates.length +
|
|
47
|
+
meta.constants.map((c) => c.values.length).reduce((a, b) => a + b, 0);
|
|
48
|
+
if (atomics.size > 1) insert("union type is not allowed in array.");
|
|
49
|
+
if (meta.nullable) insert("nullable type is not allowed in array.");
|
|
50
|
+
if (meta.isRequired() === false)
|
|
51
|
+
insert("optional type is not allowed in array.");
|
|
52
|
+
if (meta.size() !== expected)
|
|
53
|
+
insert("only atomic or constant types are allowed in array.");
|
|
54
|
+
} else if (explore.object && explore.property !== null) {
|
|
55
|
+
//----
|
|
56
|
+
// COMMON
|
|
57
|
+
//----
|
|
58
|
+
// PROPERTY MUST BE SOLE
|
|
59
|
+
if (typeof explore.property === "object")
|
|
60
|
+
insert("dynamic property is not allowed.");
|
|
61
|
+
// DO NOT ALLOW TUPLE TYPE
|
|
62
|
+
if (meta.tuples.length) insert("tuple type is not allowed.");
|
|
63
|
+
// DO NOT ALLOW UNION TYPE
|
|
64
|
+
if (CoreMetadataUtil.isUnion(meta)) insert("union type is not allowed.");
|
|
65
|
+
// DO NOT ALLOW NESTED OBJECT
|
|
66
|
+
if (
|
|
67
|
+
meta.objects.length ||
|
|
68
|
+
meta.sets.length ||
|
|
69
|
+
meta.maps.length ||
|
|
70
|
+
meta.natives.length
|
|
71
|
+
)
|
|
72
|
+
insert("nested object type is not allowed.");
|
|
73
|
+
|
|
74
|
+
//----
|
|
75
|
+
// ARRAY CASES
|
|
76
|
+
//----
|
|
77
|
+
const isArray: boolean = meta.arrays.length > 1 || meta.tuples.length > 1;
|
|
78
|
+
// ARRAY TYPE MUST BE REQUIRED
|
|
79
|
+
if (isArray && meta.isRequired() === false)
|
|
80
|
+
insert("optional type is not allowed when array.");
|
|
81
|
+
// SET-COOKIE MUST BE ARRAY
|
|
82
|
+
if (explore.property === "set-cookie" && !isArray)
|
|
83
|
+
insert("set-cookie property must be array.");
|
|
84
|
+
}
|
|
85
|
+
return errors;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export const headers = (
|
|
89
|
+
meta: Metadata,
|
|
90
|
+
explore: MetadataFactory.IExplore,
|
|
91
|
+
): string[] => {
|
|
92
|
+
const errors: string[] = [];
|
|
93
|
+
const insert = (msg: string) => errors.push(msg);
|
|
94
|
+
|
|
95
|
+
if (explore.top === true) {
|
|
96
|
+
// TOP MUST BE ONLY OBJECT
|
|
97
|
+
if (meta.objects.length !== 1 || meta.bucket() !== 1)
|
|
98
|
+
insert("only one object type is allowed.");
|
|
99
|
+
if (meta.nullable === true) insert("headers cannot be null.");
|
|
100
|
+
if (meta.isRequired() === false) insert("headers cannot be null.");
|
|
101
|
+
} else if (
|
|
102
|
+
explore.nested !== null &&
|
|
103
|
+
explore.nested instanceof MetadataArray
|
|
104
|
+
) {
|
|
105
|
+
const atomics = CoreMetadataUtil.atomics(meta);
|
|
106
|
+
const expected: number =
|
|
107
|
+
meta.atomics.length +
|
|
108
|
+
meta.templates.length +
|
|
109
|
+
meta.constants.map((c) => c.values.length).reduce((a, b) => a + b, 0);
|
|
110
|
+
if (atomics.size > 1) insert("union type is not allowed in array.");
|
|
111
|
+
if (meta.nullable) insert("nullable type is not allowed in array.");
|
|
112
|
+
if (meta.isRequired() === false) insert("optional type is not allowed.");
|
|
113
|
+
if (meta.size() !== expected)
|
|
114
|
+
insert("only atomic or constant types are allowed in array.");
|
|
115
|
+
} else if (explore.object && explore.property !== null) {
|
|
116
|
+
//----
|
|
117
|
+
// COMMON
|
|
118
|
+
//----
|
|
119
|
+
// PROPERTY MUST BE SOLE
|
|
120
|
+
if (typeof explore.property === "object")
|
|
121
|
+
insert("dynamic property is not allowed.");
|
|
122
|
+
// DO NOT ALLOW TUPLE TYPE
|
|
123
|
+
if (meta.tuples.length) insert("tuple type is not allowed.");
|
|
124
|
+
// DO NOT ALLOW UNION TYPE
|
|
125
|
+
if (CoreMetadataUtil.isUnion(meta)) insert("union type is not allowed.");
|
|
126
|
+
// DO NOT ALLOW NESTED OBJECT
|
|
127
|
+
if (
|
|
128
|
+
meta.objects.length ||
|
|
129
|
+
meta.sets.length ||
|
|
130
|
+
meta.maps.length ||
|
|
131
|
+
meta.natives.length
|
|
132
|
+
)
|
|
133
|
+
insert("nested object type is not allowed.");
|
|
134
|
+
// DO NOT ALLOW NULLABLE
|
|
135
|
+
if (meta.nullable) insert("nullable type is not allowed.");
|
|
136
|
+
|
|
137
|
+
//----
|
|
138
|
+
// ARRAY CASES
|
|
139
|
+
//----
|
|
140
|
+
const isArray: boolean = meta.arrays.length > 1;
|
|
141
|
+
// ARRAY TYPE MUST BE REQUIRED
|
|
142
|
+
if (isArray && meta.isRequired() === false)
|
|
143
|
+
insert("optional type is not allowed when array.");
|
|
144
|
+
// SET-COOKIE MUST BE ARRAY
|
|
145
|
+
if (explore.property === "set-cookie" && !isArray)
|
|
146
|
+
insert("set-cookie property must be array.");
|
|
147
|
+
// MUST BE SINGULAR CASE
|
|
148
|
+
if (
|
|
149
|
+
typeof explore.property === "string" &&
|
|
150
|
+
SINGULAR.has(explore.property) &&
|
|
151
|
+
isArray
|
|
152
|
+
)
|
|
153
|
+
insert("property cannot be array.");
|
|
154
|
+
}
|
|
155
|
+
return errors;
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
namespace CoreMetadataUtil {
|
|
160
|
+
export const atomics = (
|
|
161
|
+
meta: Metadata,
|
|
162
|
+
): Set<"boolean" | "bigint" | "number" | "string"> =>
|
|
163
|
+
new Set([
|
|
164
|
+
...meta.atomics.map((a) => a.type),
|
|
165
|
+
...meta.constants.map((c) => c.type),
|
|
166
|
+
...(meta.templates.length ? (["string"] as const) : []),
|
|
167
|
+
]);
|
|
168
|
+
|
|
169
|
+
export const isUnion = (meta: Metadata): boolean =>
|
|
170
|
+
atomics(meta).size +
|
|
171
|
+
meta.arrays.length +
|
|
172
|
+
meta.tuples.length +
|
|
173
|
+
meta.natives.length +
|
|
174
|
+
meta.maps.length +
|
|
175
|
+
meta.objects.length >
|
|
176
|
+
1;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const SINGULAR: Set<string> = new Set([
|
|
180
|
+
"age",
|
|
181
|
+
"authorization",
|
|
182
|
+
"content-length",
|
|
183
|
+
"content-type",
|
|
184
|
+
"etag",
|
|
185
|
+
"expires",
|
|
186
|
+
"from",
|
|
187
|
+
"host",
|
|
188
|
+
"if-modified-since",
|
|
189
|
+
"if-unmodified-since",
|
|
190
|
+
"last-modified",
|
|
191
|
+
"location",
|
|
192
|
+
"max-forwards",
|
|
193
|
+
"proxy-authorization",
|
|
194
|
+
"referer",
|
|
195
|
+
"retry-after",
|
|
196
|
+
"server",
|
|
197
|
+
"user-agent",
|
|
198
|
+
]);
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as nestia from "./module";
|
|
2
|
-
|
|
3
|
-
export * from "./module";
|
|
4
|
-
export default nestia;
|
|
1
|
+
import * as nestia from "./module";
|
|
2
|
+
|
|
3
|
+
export * from "./module";
|
|
4
|
+
export default nestia;
|
package/src/module.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./INestiaConfig";
|
|
2
|
-
export * from "./NestiaSdkApplication";
|
|
1
|
+
export * from "./INestiaConfig";
|
|
2
|
+
export * from "./NestiaSdkApplication";
|
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
import type { VERSION_NEUTRAL, VersionValue } from "@nestjs/common/interfaces";
|
|
2
|
-
|
|
3
|
-
import type { ParamCategory } from "./ParamCategory";
|
|
4
|
-
|
|
5
|
-
export interface IController {
|
|
6
|
-
file: string;
|
|
7
|
-
name: string;
|
|
8
|
-
prefixes: string[];
|
|
9
|
-
paths: string[];
|
|
10
|
-
versions:
|
|
11
|
-
| Array<Exclude<VersionValue, Array<string | typeof VERSION_NEUTRAL>>>
|
|
12
|
-
| undefined;
|
|
13
|
-
functions: IController.IFunction[];
|
|
14
|
-
security: Record<string, string[]>[];
|
|
15
|
-
swaggerTgas: string[];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export namespace IController {
|
|
19
|
-
export interface IFunction {
|
|
20
|
-
name: string;
|
|
21
|
-
method: string;
|
|
22
|
-
paths: string[];
|
|
23
|
-
versions:
|
|
24
|
-
| Array<Exclude<VersionValue, Array<string | typeof VERSION_NEUTRAL>>>
|
|
25
|
-
| undefined;
|
|
26
|
-
encrypted: boolean;
|
|
27
|
-
parameters: IParameter[];
|
|
28
|
-
status?: number;
|
|
29
|
-
type?: string;
|
|
30
|
-
contentType: "application/json" | "text/plain";
|
|
31
|
-
security: Record<string, string[]>[];
|
|
32
|
-
exceptions: Record<
|
|
33
|
-
number | "2XX" | "3XX" | "4XX" | "5XX",
|
|
34
|
-
IController.IException
|
|
35
|
-
>;
|
|
36
|
-
swaggerTags: string[];
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export type IParameter =
|
|
40
|
-
| ICommonParameter
|
|
41
|
-
| IQueryParameter
|
|
42
|
-
| IHeadersParameter
|
|
43
|
-
| IBodyParameter
|
|
44
|
-
| IPathParameter;
|
|
45
|
-
export interface ICommonParameter {
|
|
46
|
-
custom: false;
|
|
47
|
-
category: ParamCategory;
|
|
48
|
-
index: number;
|
|
49
|
-
name: string;
|
|
50
|
-
field: string | undefined;
|
|
51
|
-
}
|
|
52
|
-
export interface IHeadersParameter {
|
|
53
|
-
custom: true;
|
|
54
|
-
category: "headers";
|
|
55
|
-
index: number;
|
|
56
|
-
name: string;
|
|
57
|
-
field: string | undefined;
|
|
58
|
-
}
|
|
59
|
-
export interface IQueryParameter {
|
|
60
|
-
custom: true;
|
|
61
|
-
category: "query";
|
|
62
|
-
index: number;
|
|
63
|
-
name: string;
|
|
64
|
-
field: string | undefined;
|
|
65
|
-
}
|
|
66
|
-
export interface IBodyParameter {
|
|
67
|
-
custom: true;
|
|
68
|
-
category: "body";
|
|
69
|
-
index: number;
|
|
70
|
-
name: string;
|
|
71
|
-
field: string | undefined;
|
|
72
|
-
encrypted: boolean;
|
|
73
|
-
contentType:
|
|
74
|
-
| "application/json"
|
|
75
|
-
| "application/x-www-form-urlencoded"
|
|
76
|
-
| "text/plain";
|
|
77
|
-
}
|
|
78
|
-
export interface IPathParameter {
|
|
79
|
-
custom: true;
|
|
80
|
-
category: "param";
|
|
81
|
-
index: number;
|
|
82
|
-
name: string;
|
|
83
|
-
field: string | undefined;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export interface IException {
|
|
87
|
-
type: string;
|
|
88
|
-
status: number | "2XX" | "3XX" | "4XX" | "5XX";
|
|
89
|
-
description: string | undefined;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
1
|
+
import type { VERSION_NEUTRAL, VersionValue } from "@nestjs/common/interfaces";
|
|
2
|
+
|
|
3
|
+
import type { ParamCategory } from "./ParamCategory";
|
|
4
|
+
|
|
5
|
+
export interface IController {
|
|
6
|
+
file: string;
|
|
7
|
+
name: string;
|
|
8
|
+
prefixes: string[];
|
|
9
|
+
paths: string[];
|
|
10
|
+
versions:
|
|
11
|
+
| Array<Exclude<VersionValue, Array<string | typeof VERSION_NEUTRAL>>>
|
|
12
|
+
| undefined;
|
|
13
|
+
functions: IController.IFunction[];
|
|
14
|
+
security: Record<string, string[]>[];
|
|
15
|
+
swaggerTgas: string[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export namespace IController {
|
|
19
|
+
export interface IFunction {
|
|
20
|
+
name: string;
|
|
21
|
+
method: string;
|
|
22
|
+
paths: string[];
|
|
23
|
+
versions:
|
|
24
|
+
| Array<Exclude<VersionValue, Array<string | typeof VERSION_NEUTRAL>>>
|
|
25
|
+
| undefined;
|
|
26
|
+
encrypted: boolean;
|
|
27
|
+
parameters: IParameter[];
|
|
28
|
+
status?: number;
|
|
29
|
+
type?: string;
|
|
30
|
+
contentType: "application/json" | "text/plain";
|
|
31
|
+
security: Record<string, string[]>[];
|
|
32
|
+
exceptions: Record<
|
|
33
|
+
number | "2XX" | "3XX" | "4XX" | "5XX",
|
|
34
|
+
IController.IException
|
|
35
|
+
>;
|
|
36
|
+
swaggerTags: string[];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type IParameter =
|
|
40
|
+
| ICommonParameter
|
|
41
|
+
| IQueryParameter
|
|
42
|
+
| IHeadersParameter
|
|
43
|
+
| IBodyParameter
|
|
44
|
+
| IPathParameter;
|
|
45
|
+
export interface ICommonParameter {
|
|
46
|
+
custom: false;
|
|
47
|
+
category: ParamCategory;
|
|
48
|
+
index: number;
|
|
49
|
+
name: string;
|
|
50
|
+
field: string | undefined;
|
|
51
|
+
}
|
|
52
|
+
export interface IHeadersParameter {
|
|
53
|
+
custom: true;
|
|
54
|
+
category: "headers";
|
|
55
|
+
index: number;
|
|
56
|
+
name: string;
|
|
57
|
+
field: string | undefined;
|
|
58
|
+
}
|
|
59
|
+
export interface IQueryParameter {
|
|
60
|
+
custom: true;
|
|
61
|
+
category: "query";
|
|
62
|
+
index: number;
|
|
63
|
+
name: string;
|
|
64
|
+
field: string | undefined;
|
|
65
|
+
}
|
|
66
|
+
export interface IBodyParameter {
|
|
67
|
+
custom: true;
|
|
68
|
+
category: "body";
|
|
69
|
+
index: number;
|
|
70
|
+
name: string;
|
|
71
|
+
field: string | undefined;
|
|
72
|
+
encrypted: boolean;
|
|
73
|
+
contentType:
|
|
74
|
+
| "application/json"
|
|
75
|
+
| "application/x-www-form-urlencoded"
|
|
76
|
+
| "text/plain";
|
|
77
|
+
}
|
|
78
|
+
export interface IPathParameter {
|
|
79
|
+
custom: true;
|
|
80
|
+
category: "param";
|
|
81
|
+
index: number;
|
|
82
|
+
name: string;
|
|
83
|
+
field: string | undefined;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface IException {
|
|
87
|
+
type: string;
|
|
88
|
+
status: number | "2XX" | "3XX" | "4XX" | "5XX";
|
|
89
|
+
description: string | undefined;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export interface IErrorReport {
|
|
2
|
-
file: string;
|
|
3
|
-
controller: string;
|
|
4
|
-
function: string | null;
|
|
5
|
-
message: string;
|
|
6
|
-
}
|
|
1
|
+
export interface IErrorReport {
|
|
2
|
+
file: string;
|
|
3
|
+
controller: string;
|
|
4
|
+
function: string | null;
|
|
5
|
+
message: string;
|
|
6
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { INestiaConfig } from "../INestiaConfig";
|
|
4
|
-
import { IErrorReport } from "./IErrorReport";
|
|
5
|
-
import { INormalizedInput } from "./INormalizedInput";
|
|
6
|
-
|
|
7
|
-
export interface INestiaProject {
|
|
8
|
-
config: INestiaConfig;
|
|
9
|
-
input: INormalizedInput;
|
|
10
|
-
checker: ts.TypeChecker;
|
|
11
|
-
errors: IErrorReport[];
|
|
12
|
-
warnings: IErrorReport[];
|
|
13
|
-
}
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { INestiaConfig } from "../INestiaConfig";
|
|
4
|
+
import { IErrorReport } from "./IErrorReport";
|
|
5
|
+
import { INormalizedInput } from "./INormalizedInput";
|
|
6
|
+
|
|
7
|
+
export interface INestiaProject {
|
|
8
|
+
config: INestiaConfig;
|
|
9
|
+
input: INormalizedInput;
|
|
10
|
+
checker: ts.TypeChecker;
|
|
11
|
+
errors: IErrorReport[];
|
|
12
|
+
warnings: IErrorReport[];
|
|
13
|
+
}
|