@nestia/sdk 4.0.3 → 4.0.5-dev.20241207-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/analyses/ExceptionAnalyzer.js +0 -142
- package/lib/analyses/ExceptionAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.js +2 -2
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.js.map +1 -1
- package/lib/executable/internal/NestiaConfigLoader.js +668 -5
- package/lib/executable/internal/NestiaConfigLoader.js.map +1 -1
- package/lib/generates/SwaggerGenerator.js +96 -1
- package/lib/generates/SwaggerGenerator.js.map +1 -1
- package/lib/generates/internal/SdkAliasCollection.js +17 -1
- package/lib/generates/internal/SdkAliasCollection.js.map +1 -1
- package/lib/generates/internal/SdkDistributionComposer.js +66 -1
- package/lib/generates/internal/SdkDistributionComposer.js.map +1 -1
- package/lib/transformers/SdkOperationTransformer.js +4 -2
- package/lib/transformers/SdkOperationTransformer.js.map +1 -1
- package/package.json +6 -6
- package/src/transformers/SdkOperationTransformer.ts +15 -2
|
@@ -1,144 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// import path from "path";
|
|
3
|
-
// import ts from "typescript";
|
|
4
|
-
// import { MetadataCollection } from "typia/lib/factories/MetadataCollection";
|
|
5
|
-
// import { MetadataFactory } from "typia/lib/factories/MetadataFactory";
|
|
6
|
-
// import { Metadata } from "typia/lib/schemas/metadata/Metadata";
|
|
7
|
-
// import { INestiaProject } from "../structures/INestiaProject";
|
|
8
|
-
// import { IReflectController } from "../structures/IReflectController";
|
|
9
|
-
// import { IReflectHttpOperation } from "../structures/IReflectHttpOperation";
|
|
10
|
-
// import { ITypeTuple } from "../structures/ITypeTuple";
|
|
11
|
-
// import { ITypedHttpRoute } from "../structures/ITypedHttpRoute";
|
|
12
|
-
// import { GenericAnalyzer } from "./GenericAnalyzer";
|
|
13
|
-
// import { ImportAnalyzer } from "./ImportAnalyzer";
|
|
14
|
-
// export namespace ExceptionAnalyzer {
|
|
15
|
-
// export const analyze =
|
|
16
|
-
// (project: INestiaProject) =>
|
|
17
|
-
// (props: {
|
|
18
|
-
// generics: GenericAnalyzer.Dictionary;
|
|
19
|
-
// imports: ImportAnalyzer.Dictionary;
|
|
20
|
-
// controller: IReflectController;
|
|
21
|
-
// operation: IReflectHttpOperation;
|
|
22
|
-
// declaration: ts.MethodDeclaration;
|
|
23
|
-
// }): Record<
|
|
24
|
-
// number | "2XX" | "3XX" | "4XX" | "5XX",
|
|
25
|
-
// ITypedHttpRoute.IOutput
|
|
26
|
-
// > => {
|
|
27
|
-
// const output: Record<
|
|
28
|
-
// number | "2XX" | "3XX" | "4XX" | "5XX",
|
|
29
|
-
// ITypedHttpRoute.IOutput
|
|
30
|
-
// > = {} as any;
|
|
31
|
-
// for (const decorator of props.declaration.modifiers ?? [])
|
|
32
|
-
// if (ts.isDecorator(decorator))
|
|
33
|
-
// analyzeTyped(project)({
|
|
34
|
-
// ...props,
|
|
35
|
-
// output,
|
|
36
|
-
// decorator,
|
|
37
|
-
// });
|
|
38
|
-
// return output;
|
|
39
|
-
// };
|
|
40
|
-
// const analyzeTyped =
|
|
41
|
-
// (project: INestiaProject) =>
|
|
42
|
-
// (props: {
|
|
43
|
-
// generics: GenericAnalyzer.Dictionary;
|
|
44
|
-
// imports: ImportAnalyzer.Dictionary;
|
|
45
|
-
// controller: IReflectController;
|
|
46
|
-
// operation: IReflectHttpOperation;
|
|
47
|
-
// output: Record<
|
|
48
|
-
// number | "2XX" | "3XX" | "4XX" | "5XX",
|
|
49
|
-
// ITypedHttpRoute.IOutput
|
|
50
|
-
// >;
|
|
51
|
-
// decorator: ts.Decorator;
|
|
52
|
-
// }): boolean => {
|
|
53
|
-
// // CHECK DECORATOR
|
|
54
|
-
// if (!ts.isCallExpression(props.decorator.expression)) return false;
|
|
55
|
-
// else if ((props.decorator.expression.typeArguments ?? []).length !== 1)
|
|
56
|
-
// return false;
|
|
57
|
-
// // CHECK SIGNATURE
|
|
58
|
-
// const signature: ts.Signature | undefined =
|
|
59
|
-
// project.checker.getResolvedSignature(props.decorator.expression);
|
|
60
|
-
// if (!signature || !signature.declaration) return false;
|
|
61
|
-
// else if (
|
|
62
|
-
// path
|
|
63
|
-
// .resolve(signature.declaration.getSourceFile().fileName)
|
|
64
|
-
// .indexOf(TYPED_EXCEPTION_PATH) === -1
|
|
65
|
-
// )
|
|
66
|
-
// return false;
|
|
67
|
-
// // GET TYPE INFO
|
|
68
|
-
// const status: string | null = getStatus(project.checker)(
|
|
69
|
-
// props.decorator.expression.arguments[0] ?? null,
|
|
70
|
-
// );
|
|
71
|
-
// if (status === null) return false;
|
|
72
|
-
// const node: ts.TypeNode = props.decorator.expression.typeArguments![0];
|
|
73
|
-
// const type: ts.Type = project.checker.getTypeFromTypeNode(node);
|
|
74
|
-
// if (type.isTypeParameter()) {
|
|
75
|
-
// project.errors.push({
|
|
76
|
-
// file: props.controller.file,
|
|
77
|
-
// controller: props.controller.name,
|
|
78
|
-
// function: props.operation.name,
|
|
79
|
-
// message: "TypedException() without generic argument specification.",
|
|
80
|
-
// });
|
|
81
|
-
// return false;
|
|
82
|
-
// }
|
|
83
|
-
// const tuple: ITypeTuple | null = ImportAnalyzer.analyze(project.checker)({
|
|
84
|
-
// generics: props.generics,
|
|
85
|
-
// imports: props.imports,
|
|
86
|
-
// type,
|
|
87
|
-
// });
|
|
88
|
-
// if (tuple === null) {
|
|
89
|
-
// project.errors.push({
|
|
90
|
-
// file: props.controller.file,
|
|
91
|
-
// controller: props.controller.name,
|
|
92
|
-
// function: props.operation.name,
|
|
93
|
-
// message: `TypeException() with unknown type on ${status} status.`,
|
|
94
|
-
// });
|
|
95
|
-
// return false;
|
|
96
|
-
// }
|
|
97
|
-
// // DO ASSIGN
|
|
98
|
-
// const matched: IReflectHttpOperation.IException[] = Object.entries(
|
|
99
|
-
// props.operation.exceptions,
|
|
100
|
-
// )
|
|
101
|
-
// .filter(([key]) => status === key)
|
|
102
|
-
// .map(([_key, value]) => value);
|
|
103
|
-
// for (const m of matched)
|
|
104
|
-
// props.output[m.status] = {
|
|
105
|
-
// type: tuple.type,
|
|
106
|
-
// typeName: tuple.typeName,
|
|
107
|
-
// contentType: "application/json",
|
|
108
|
-
// description: m.description,
|
|
109
|
-
// };
|
|
110
|
-
// return true;
|
|
111
|
-
// };
|
|
112
|
-
// const getStatus =
|
|
113
|
-
// (checker: ts.TypeChecker) =>
|
|
114
|
-
// (expression: ts.Expression | null): string | null => {
|
|
115
|
-
// if (expression === null) return null;
|
|
116
|
-
// const type: ts.Type = checker.getTypeAtLocation(expression);
|
|
117
|
-
// const result = MetadataFactory.analyze(checker)({
|
|
118
|
-
// escape: true,
|
|
119
|
-
// constant: true,
|
|
120
|
-
// absorb: true,
|
|
121
|
-
// })(new MetadataCollection())(type);
|
|
122
|
-
// if (false === result.success) return null;
|
|
123
|
-
// const meta: Metadata = result.data;
|
|
124
|
-
// if (meta.constants.length === 1)
|
|
125
|
-
// return meta.constants[0].values[0].value.toString();
|
|
126
|
-
// else if (meta.escaped && meta.escaped.returns.constants.length === 1)
|
|
127
|
-
// return meta.escaped.returns.constants[0].values[0].value.toString();
|
|
128
|
-
// else if (ts.isStringLiteral(expression)) return expression.text;
|
|
129
|
-
// else if (ts.isNumericLiteral(expression)) {
|
|
130
|
-
// const value: number = Number(expression.text.split("_").join(""));
|
|
131
|
-
// if (false === isNaN(value)) return value.toString();
|
|
132
|
-
// }
|
|
133
|
-
// return null;
|
|
134
|
-
// };
|
|
135
|
-
// }
|
|
136
|
-
// const TYPED_EXCEPTION_PATH = path.join(
|
|
137
|
-
// "node_modules",
|
|
138
|
-
// "@nestia",
|
|
139
|
-
// "core",
|
|
140
|
-
// "lib",
|
|
141
|
-
// "decorators",
|
|
142
|
-
// "TypedException.d.ts",
|
|
143
|
-
// );
|
|
144
2
|
//# sourceMappingURL=ExceptionAnalyzer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExceptionAnalyzer.js","sourceRoot":"","sources":["../../src/analyses/ExceptionAnalyzer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ExceptionAnalyzer.js","sourceRoot":"","sources":["../../src/analyses/ExceptionAnalyzer.ts"],"names":[],"mappings":""}
|
|
@@ -45,14 +45,14 @@ var ReflectHttpOperationResponseAnalyzer;
|
|
|
45
45
|
errors.push(...schema.errors);
|
|
46
46
|
if (ctx.httpMethod === "HEAD" && contentType !== null)
|
|
47
47
|
errors.push(`HEAD method must not have a content type.`);
|
|
48
|
-
if (
|
|
48
|
+
if ((() => { return input => null === input || "application/json" === input || "application/x-www-form-urlencoded" === input || "text/plain" === input; })()(contentType) ===
|
|
49
49
|
false)
|
|
50
50
|
errors.push(`@nestia/sdk does not support ${JSON.stringify(contentType)} content type.`);
|
|
51
51
|
if (errors.length)
|
|
52
52
|
return report();
|
|
53
53
|
else if (ctx.metadata.success.type === null ||
|
|
54
54
|
schema.success === false ||
|
|
55
|
-
!
|
|
55
|
+
!(() => { return input => null === input || "application/json" === input || "application/x-www-form-urlencoded" === input || "text/plain" === input; })()(contentType))
|
|
56
56
|
return null;
|
|
57
57
|
const example = Reflect.getMetadata("nestia/SwaggerExample/Response", ctx.function);
|
|
58
58
|
return Object.assign(Object.assign({ contentType: contentType, encrypted, status: (_f = getStatus(ctx.function)) !== null && _f !== void 0 ? _f : (ctx.httpMethod === "POST" ? 201 : 200), type: ctx.metadata.success.type }, schema.data), { validate: contentType === "application/json" || encrypted === true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReflectHttpOperationResponseAnalyzer.js","sourceRoot":"","sources":["../../src/analyses/ReflectHttpOperationResponseAnalyzer.ts"],"names":[],"mappings":";;;;;;AACA,wDAIkC;AAClC,kDAA0B;AAC1B,iFAA8E;AAC9E,wFAAqF;AAMrF,2EAAwE;AAExE,IAAiB,oCAAoC,CA8GpD;AA9GD,WAAiB,oCAAoC;IAUtC,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