@nestia/sdk 3.0.5 → 3.1.0-dev.20240426
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/NestiaSdkApplication.d.ts +1 -0
- package/lib/NestiaSdkApplication.js +17 -17
- package/lib/NestiaSdkApplication.js.map +1 -1
- package/lib/analyses/AccessorAnalyzer.d.ts +3 -2
- package/lib/analyses/AccessorAnalyzer.js.map +1 -1
- package/lib/analyses/ExceptionAnalyzer.d.ts +11 -3
- package/lib/analyses/ExceptionAnalyzer.js +23 -18
- package/lib/analyses/ExceptionAnalyzer.js.map +1 -1
- package/lib/analyses/GenericAnalyzer.d.ts +1 -0
- package/lib/analyses/ImportAnalyzer.d.ts +6 -1
- package/lib/analyses/ImportAnalyzer.js +27 -29
- package/lib/analyses/ImportAnalyzer.js.map +1 -1
- package/lib/analyses/PathAnalyzer.d.ts +0 -5
- package/lib/analyses/PathAnalyzer.js +0 -32
- package/lib/analyses/PathAnalyzer.js.map +1 -1
- package/lib/analyses/{ReflectAnalyzer.d.ts → ReflectControllerAnalyzer.d.ts} +3 -4
- package/lib/analyses/ReflectControllerAnalyzer.js +145 -0
- package/lib/analyses/ReflectControllerAnalyzer.js.map +1 -0
- package/lib/analyses/ReflectHttpOperationAnalyzer.d.ts +10 -0
- package/lib/analyses/ReflectHttpOperationAnalyzer.js +224 -0
- package/lib/analyses/ReflectHttpOperationAnalyzer.js.map +1 -0
- package/lib/analyses/ReflectMetadataAnalyzer.d.ts +8 -0
- package/lib/analyses/ReflectMetadataAnalyzer.js +34 -0
- package/lib/analyses/ReflectMetadataAnalyzer.js.map +1 -0
- package/lib/analyses/ReflectWebSocketOperationAnalyzer.d.ts +10 -0
- package/lib/analyses/ReflectWebSocketOperationAnalyzer.js +78 -0
- package/lib/analyses/ReflectWebSocketOperationAnalyzer.js.map +1 -0
- package/lib/analyses/SecurityAnalyzer.js +1 -1
- package/lib/analyses/SecurityAnalyzer.js.map +1 -1
- package/lib/analyses/TypedControllerAnalyzer.d.ts +9 -0
- package/lib/analyses/TypedControllerAnalyzer.js +77 -0
- package/lib/analyses/TypedControllerAnalyzer.js.map +1 -0
- package/lib/analyses/TypedHttpOperationAnalyzer.d.ts +16 -0
- package/lib/analyses/TypedHttpOperationAnalyzer.js +251 -0
- package/lib/analyses/TypedHttpOperationAnalyzer.js.map +1 -0
- package/lib/analyses/TypedWebSocketOperationAnalyzer.d.ts +16 -0
- package/lib/analyses/TypedWebSocketOperationAnalyzer.js +218 -0
- package/lib/analyses/TypedWebSocketOperationAnalyzer.js.map +1 -0
- package/lib/executable/internal/NestiaConfigLoader.d.ts +1 -0
- package/lib/generates/CloneGenerator.d.ts +3 -4
- package/lib/generates/CloneGenerator.js +8 -8
- package/lib/generates/CloneGenerator.js.map +1 -1
- package/lib/generates/E2eGenerator.d.ts +3 -4
- package/lib/generates/E2eGenerator.js +7 -7
- package/lib/generates/E2eGenerator.js.map +1 -1
- package/lib/generates/SdkGenerator.d.ts +4 -4
- package/lib/generates/SdkGenerator.js +8 -8
- package/lib/generates/SdkGenerator.js.map +1 -1
- package/lib/generates/SwaggerGenerator.d.ts +5 -2
- package/lib/generates/SwaggerGenerator.js +15 -13
- package/lib/generates/SwaggerGenerator.js.map +1 -1
- package/lib/generates/internal/E2eFileProgrammer.d.ts +4 -5
- package/lib/generates/internal/E2eFileProgrammer.js +13 -12
- package/lib/generates/internal/E2eFileProgrammer.js.map +1 -1
- package/lib/generates/internal/FilePrinter.d.ts +1 -0
- package/lib/generates/internal/ImportDictionary.d.ts +1 -0
- package/lib/generates/internal/SdkAliasCollection.d.ts +9 -8
- package/lib/generates/internal/SdkAliasCollection.js +20 -20
- package/lib/generates/internal/SdkAliasCollection.js.map +1 -1
- package/lib/generates/internal/SdkDistributionComposer.d.ts +1 -1
- package/lib/generates/internal/SdkDistributionComposer.js +36 -2
- package/lib/generates/internal/SdkDistributionComposer.js.map +1 -1
- package/lib/generates/internal/SdkFileProgrammer.d.ts +4 -4
- package/lib/generates/internal/SdkFileProgrammer.js +10 -7
- package/lib/generates/internal/SdkFileProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpCloneProgrammer.d.ts +13 -0
- package/lib/generates/internal/{SdkCloneProgrammer.js → SdkHttpCloneProgrammer.js} +14 -14
- package/lib/generates/internal/SdkHttpCloneProgrammer.js.map +1 -0
- package/lib/generates/internal/SdkHttpFunctionProgrammer.d.ts +12 -0
- package/lib/generates/internal/{SdkFunctionProgrammer.js → SdkHttpFunctionProgrammer.js} +12 -12
- package/lib/generates/internal/SdkHttpFunctionProgrammer.js.map +1 -0
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.d.ts +12 -0
- package/lib/generates/internal/{SdkNamespaceProgrammer.js → SdkHttpNamespaceProgrammer.js} +26 -26
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.js.map +1 -0
- package/lib/generates/internal/SdkHttpRouteProgrammer.d.ts +8 -0
- package/lib/generates/internal/{SdkRouteProgrammer.js → SdkHttpRouteProgrammer.js} +11 -11
- package/lib/generates/internal/SdkHttpRouteProgrammer.js.map +1 -0
- package/lib/generates/internal/SdkHttpSimulationProgrammer.d.ts +13 -0
- package/lib/generates/internal/{SdkSimulationProgrammer.js → SdkHttpSimulationProgrammer.js} +18 -18
- package/lib/generates/internal/SdkHttpSimulationProgrammer.js.map +1 -0
- package/lib/generates/internal/SdkRouteDirectory.d.ts +3 -2
- package/lib/generates/internal/SdkRouteDirectory.js.map +1 -1
- package/lib/generates/internal/SdkTypeProgrammer.d.ts +4 -3
- package/lib/generates/internal/SdkTypeProgrammer.js +33 -33
- package/lib/generates/internal/SdkTypeProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.d.ts +8 -0
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js +115 -0
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js.map +1 -0
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.d.ts +8 -0
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.js +79 -0
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.js.map +1 -0
- package/lib/generates/internal/SwaggerSchemaGenerator.d.ts +6 -5
- package/lib/generates/internal/SwaggerSchemaGenerator.js +3 -1
- package/lib/generates/internal/SwaggerSchemaGenerator.js.map +1 -1
- package/lib/structures/INestiaProject.d.ts +1 -0
- package/lib/structures/IReflectController.d.ts +15 -0
- package/lib/structures/{IRoute.js → IReflectController.js} +1 -1
- package/lib/structures/IReflectController.js.map +1 -0
- package/lib/structures/{IController.d.ts → IReflectHttpOperation.d.ts} +15 -25
- package/lib/structures/IReflectHttpOperation.js +3 -0
- package/lib/structures/IReflectHttpOperation.js.map +1 -0
- package/lib/structures/IReflectWebSocketOperation.d.ts +16 -0
- package/lib/structures/IReflectWebSocketOperation.js +3 -0
- package/lib/structures/IReflectWebSocketOperation.js.map +1 -0
- package/lib/structures/ISwaggerError.d.ts +2 -2
- package/lib/structures/ITypeTuple.d.ts +1 -0
- package/lib/structures/{IRoute.d.ts → ITypedHttpRoute.d.ts} +12 -12
- package/lib/structures/{IController.js → ITypedHttpRoute.js} +1 -1
- package/lib/structures/ITypedHttpRoute.js.map +1 -0
- package/lib/structures/ITypedWebSocketRoute.d.ts +54 -0
- package/lib/structures/ITypedWebSocketRoute.js +3 -0
- package/lib/structures/ITypedWebSocketRoute.js.map +1 -0
- package/lib/structures/TypeEntry.d.ts +1 -0
- package/lib/utils/VersioningStrategy.d.ts +6 -0
- package/lib/utils/VersioningStrategy.js +22 -0
- package/lib/utils/VersioningStrategy.js.map +1 -0
- package/package.json +8 -6
- package/src/NestiaSdkApplication.ts +36 -34
- package/src/analyses/AccessorAnalyzer.ts +12 -5
- package/src/analyses/ExceptionAnalyzer.ts +49 -39
- package/src/analyses/ImportAnalyzer.ts +123 -104
- package/src/analyses/PathAnalyzer.ts +0 -41
- package/src/analyses/ReflectControllerAnalyzer.ts +155 -0
- package/src/analyses/ReflectHttpOperationAnalyzer.ts +290 -0
- package/src/analyses/ReflectMetadataAnalyzer.ts +53 -0
- package/src/analyses/ReflectWebSocketOperationAnalyzer.ts +96 -0
- package/src/analyses/SecurityAnalyzer.ts +2 -1
- package/src/analyses/TypedControllerAnalyzer.ts +92 -0
- package/src/analyses/TypedHttpOperationAnalyzer.ts +352 -0
- package/src/analyses/TypedWebSocketOperationAnalyzer.ts +368 -0
- package/src/generates/CloneGenerator.ts +17 -15
- package/src/generates/E2eGenerator.ts +10 -12
- package/src/generates/SdkGenerator.ts +19 -12
- package/src/generates/SwaggerGenerator.ts +31 -21
- package/src/generates/internal/E2eFileProgrammer.ts +20 -24
- package/src/generates/internal/SdkAliasCollection.ts +38 -33
- package/src/generates/internal/SdkDistributionComposer.ts +13 -4
- package/src/generates/internal/SdkFileProgrammer.ts +17 -13
- package/src/generates/internal/{SdkCloneProgrammer.ts → SdkHttpCloneProgrammer.ts} +14 -15
- package/src/generates/internal/{SdkFunctionProgrammer.ts → SdkHttpFunctionProgrammer.ts} +24 -23
- package/src/generates/internal/{SdkNamespaceProgrammer.ts → SdkHttpNamespaceProgrammer.ts} +44 -49
- package/src/generates/internal/{SdkRouteProgrammer.ts → SdkHttpRouteProgrammer.ts} +12 -13
- package/src/generates/internal/{SdkSimulationProgrammer.ts → SdkHttpSimulationProgrammer.ts} +23 -25
- package/src/generates/internal/SdkRouteDirectory.ts +3 -2
- package/src/generates/internal/SdkTypeProgrammer.ts +43 -37
- package/src/generates/internal/SdkWebSocketNamespaceProgrammer.ts +378 -0
- package/src/generates/internal/SdkWebSocketRouteProgrammer.ts +248 -0
- package/src/generates/internal/SwaggerSchemaGenerator.ts +26 -21
- package/src/structures/IReflectController.ts +17 -0
- package/src/structures/{IController.ts → IReflectHttpOperation.ts} +78 -94
- package/src/structures/IReflectWebSocketOperation.ts +17 -0
- package/src/structures/ISwaggerError.ts +2 -2
- package/src/structures/{IRoute.ts → ITypedHttpRoute.ts} +14 -12
- package/src/structures/ITypedWebSocketRoute.ts +67 -0
- package/src/utils/VersioningStrategy.ts +28 -0
- package/lib/analyses/ControllerAnalyzer.d.ts +0 -7
- package/lib/analyses/ControllerAnalyzer.js +0 -269
- package/lib/analyses/ControllerAnalyzer.js.map +0 -1
- package/lib/analyses/ReflectAnalyzer.js +0 -377
- package/lib/analyses/ReflectAnalyzer.js.map +0 -1
- package/lib/generates/internal/SdkCloneProgrammer.d.ts +0 -12
- package/lib/generates/internal/SdkCloneProgrammer.js.map +0 -1
- package/lib/generates/internal/SdkFunctionProgrammer.d.ts +0 -11
- package/lib/generates/internal/SdkFunctionProgrammer.js.map +0 -1
- package/lib/generates/internal/SdkNamespaceProgrammer.d.ts +0 -11
- package/lib/generates/internal/SdkNamespaceProgrammer.js.map +0 -1
- package/lib/generates/internal/SdkRouteProgrammer.d.ts +0 -7
- package/lib/generates/internal/SdkRouteProgrammer.js.map +0 -1
- package/lib/generates/internal/SdkSimulationProgrammer.d.ts +0 -12
- package/lib/generates/internal/SdkSimulationProgrammer.js.map +0 -1
- package/lib/structures/IController.js.map +0 -1
- package/lib/structures/IRoute.js.map +0 -1
- package/src/analyses/ControllerAnalyzer.ts +0 -402
- package/src/analyses/ReflectAnalyzer.ts +0 -471
|
@@ -3,23 +3,24 @@ import typia from "typia";
|
|
|
3
3
|
import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
|
|
4
4
|
|
|
5
5
|
import { INestiaConfig } from "../../INestiaConfig";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { INestiaProject } from "../../structures/INestiaProject";
|
|
7
|
+
import { IReflectHttpOperation } from "../../structures/IReflectHttpOperation";
|
|
8
|
+
import { ITypedHttpRoute } from "../../structures/ITypedHttpRoute";
|
|
8
9
|
import { StringUtil } from "../../utils/StringUtil";
|
|
9
10
|
import { ImportDictionary } from "./ImportDictionary";
|
|
10
11
|
import { SdkImportWizard } from "./SdkImportWizard";
|
|
11
12
|
import { SdkTypeProgrammer } from "./SdkTypeProgrammer";
|
|
12
13
|
|
|
13
|
-
export namespace
|
|
14
|
+
export namespace SdkHttpFunctionProgrammer {
|
|
14
15
|
export const write =
|
|
15
|
-
(
|
|
16
|
+
(project: INestiaProject) =>
|
|
16
17
|
(importer: ImportDictionary) =>
|
|
17
18
|
(
|
|
18
|
-
route:
|
|
19
|
+
route: ITypedHttpRoute,
|
|
19
20
|
props: {
|
|
20
|
-
headers:
|
|
21
|
-
query:
|
|
22
|
-
input:
|
|
21
|
+
headers: ITypedHttpRoute.IParameter | undefined;
|
|
22
|
+
query: ITypedHttpRoute.IParameter | undefined;
|
|
23
|
+
input: ITypedHttpRoute.IParameter | undefined;
|
|
23
24
|
},
|
|
24
25
|
): ts.FunctionDeclaration => {
|
|
25
26
|
return ts.factory.createFunctionDeclaration(
|
|
@@ -50,20 +51,20 @@ export namespace SdkFunctionProgrammer {
|
|
|
50
51
|
p.optional
|
|
51
52
|
? ts.factory.createToken(ts.SyntaxKind.QuestionToken)
|
|
52
53
|
: undefined,
|
|
53
|
-
config.primitive !== false &&
|
|
54
|
+
project.config.primitive !== false &&
|
|
54
55
|
(p === props.query || p === props.input)
|
|
55
56
|
? ts.factory.createTypeReferenceNode(
|
|
56
57
|
`${route.name}.${p === props.query ? "Query" : "Input"}`,
|
|
57
58
|
)
|
|
58
|
-
: getTypeName(
|
|
59
|
+
: getTypeName(project)(importer)(p),
|
|
59
60
|
),
|
|
60
61
|
),
|
|
61
62
|
],
|
|
62
63
|
ts.factory.createTypeReferenceNode("Promise", [
|
|
63
|
-
getReturnType(config)(route),
|
|
64
|
+
getReturnType(project.config)(route),
|
|
64
65
|
]),
|
|
65
66
|
ts.factory.createBlock(
|
|
66
|
-
write_body(config)(importer)(route, props),
|
|
67
|
+
write_body(project.config)(importer)(route, props),
|
|
67
68
|
true,
|
|
68
69
|
),
|
|
69
70
|
);
|
|
@@ -73,11 +74,11 @@ export namespace SdkFunctionProgrammer {
|
|
|
73
74
|
(config: INestiaConfig) =>
|
|
74
75
|
(importer: ImportDictionary) =>
|
|
75
76
|
(
|
|
76
|
-
route:
|
|
77
|
+
route: ITypedHttpRoute,
|
|
77
78
|
props: {
|
|
78
|
-
headers:
|
|
79
|
-
query:
|
|
80
|
-
input:
|
|
79
|
+
headers: ITypedHttpRoute.IParameter | undefined;
|
|
80
|
+
query: ITypedHttpRoute.IParameter | undefined;
|
|
81
|
+
input: ITypedHttpRoute.IParameter | undefined;
|
|
81
82
|
},
|
|
82
83
|
): ts.Statement[] => {
|
|
83
84
|
const encrypted: boolean =
|
|
@@ -88,7 +89,7 @@ export namespace SdkFunctionProgrammer {
|
|
|
88
89
|
props.input.encrypted === true);
|
|
89
90
|
const contentType: string | undefined =
|
|
90
91
|
props.input !== undefined
|
|
91
|
-
? typia.is<
|
|
92
|
+
? typia.is<IReflectHttpOperation.IBodyParameter>(props.input)
|
|
92
93
|
? props.input.contentType
|
|
93
94
|
: "application/json"
|
|
94
95
|
: undefined;
|
|
@@ -157,7 +158,7 @@ export namespace SdkFunctionProgrammer {
|
|
|
157
158
|
? [ts.factory.createIdentifier(props.input.name)]
|
|
158
159
|
: []),
|
|
159
160
|
...(config.json &&
|
|
160
|
-
typia.is<
|
|
161
|
+
typia.is<IReflectHttpOperation.IBodyParameter>(props.input) &&
|
|
161
162
|
(props.input.contentType === "application/json" ||
|
|
162
163
|
props.input.encrypted === true)
|
|
163
164
|
? [ts.factory.createIdentifier(`${route.name}.stringify`)]
|
|
@@ -215,7 +216,7 @@ export namespace SdkFunctionProgrammer {
|
|
|
215
216
|
|
|
216
217
|
const write_set_headers =
|
|
217
218
|
(config: INestiaConfig) =>
|
|
218
|
-
(route:
|
|
219
|
+
(route: ITypedHttpRoute) =>
|
|
219
220
|
(condition: ts.Expression): ts.Statement[] => {
|
|
220
221
|
const accessor = (x: string) => (y: string) =>
|
|
221
222
|
x[0] === "[" ? `${x}${y}` : `${x}.${y}`;
|
|
@@ -283,14 +284,14 @@ export namespace SdkFunctionProgrammer {
|
|
|
283
284
|
}
|
|
284
285
|
|
|
285
286
|
const getTypeName =
|
|
286
|
-
(
|
|
287
|
+
(project: INestiaProject) =>
|
|
287
288
|
(importer: ImportDictionary) =>
|
|
288
|
-
(p:
|
|
289
|
+
(p: ITypedHttpRoute.IParameter | ITypedHttpRoute.IOutput) =>
|
|
289
290
|
p.metadata
|
|
290
|
-
? SdkTypeProgrammer.write(
|
|
291
|
+
? SdkTypeProgrammer.write(project)(importer)(p.metadata)
|
|
291
292
|
: ts.factory.createTypeReferenceNode(p.typeName);
|
|
292
293
|
|
|
293
|
-
const getReturnType = (config: INestiaConfig) => (route:
|
|
294
|
+
const getReturnType = (config: INestiaConfig) => (route: ITypedHttpRoute) =>
|
|
294
295
|
ts.factory.createTypeReferenceNode(
|
|
295
296
|
config.propagate !== true && route.output.typeName === "void"
|
|
296
297
|
? "void"
|
|
@@ -6,30 +6,29 @@ import { LiteralFactory } from "typia/lib/factories/LiteralFactory";
|
|
|
6
6
|
import { TypeFactory } from "typia/lib/factories/TypeFactory";
|
|
7
7
|
import { Escaper } from "typia/lib/utils/Escaper";
|
|
8
8
|
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
9
|
+
import { INestiaProject } from "../../structures/INestiaProject";
|
|
10
|
+
import { IReflectHttpOperation } from "../../structures/IReflectHttpOperation";
|
|
11
|
+
import { ITypedHttpRoute } from "../../structures/ITypedHttpRoute";
|
|
12
12
|
import { FilePrinter } from "./FilePrinter";
|
|
13
13
|
import { ImportDictionary } from "./ImportDictionary";
|
|
14
14
|
import { SdkAliasCollection } from "./SdkAliasCollection";
|
|
15
|
+
import { SdkHttpSimulationProgrammer } from "./SdkHttpSimulationProgrammer";
|
|
15
16
|
import { SdkImportWizard } from "./SdkImportWizard";
|
|
16
|
-
import { SdkSimulationProgrammer } from "./SdkSimulationProgrammer";
|
|
17
17
|
import { SdkTypeProgrammer } from "./SdkTypeProgrammer";
|
|
18
18
|
|
|
19
|
-
export namespace
|
|
19
|
+
export namespace SdkHttpNamespaceProgrammer {
|
|
20
20
|
export const write =
|
|
21
|
-
(
|
|
22
|
-
(config: INestiaConfig) =>
|
|
21
|
+
(project: INestiaProject) =>
|
|
23
22
|
(importer: ImportDictionary) =>
|
|
24
23
|
(
|
|
25
|
-
route:
|
|
24
|
+
route: ITypedHttpRoute,
|
|
26
25
|
props: {
|
|
27
|
-
headers:
|
|
28
|
-
query:
|
|
29
|
-
input:
|
|
26
|
+
headers: ITypedHttpRoute.IParameter | undefined;
|
|
27
|
+
query: ITypedHttpRoute.IParameter | undefined;
|
|
28
|
+
input: ITypedHttpRoute.IParameter | undefined;
|
|
30
29
|
},
|
|
31
30
|
): ts.ModuleDeclaration => {
|
|
32
|
-
const types = write_types(
|
|
31
|
+
const types = write_types(project)(importer)(route, props);
|
|
33
32
|
return ts.factory.createModuleDeclaration(
|
|
34
33
|
[ts.factory.createToken(ts.SyntaxKind.ExportKeyword)],
|
|
35
34
|
ts.factory.createIdentifier(route.name),
|
|
@@ -38,23 +37,21 @@ export namespace SdkNamespaceProgrammer {
|
|
|
38
37
|
...(types.length ? [FilePrinter.enter()] : []),
|
|
39
38
|
write_metadata(importer)(route, props),
|
|
40
39
|
FilePrinter.enter(),
|
|
41
|
-
write_path(
|
|
42
|
-
...(config.simulate
|
|
40
|
+
write_path(project)(importer)(route, props),
|
|
41
|
+
...(project.config.simulate
|
|
43
42
|
? [
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
),
|
|
47
|
-
SdkSimulationProgrammer.simulate(config)(importer)(
|
|
43
|
+
SdkHttpSimulationProgrammer.random(project)(importer)(route),
|
|
44
|
+
SdkHttpSimulationProgrammer.simulate(project)(importer)(
|
|
48
45
|
route,
|
|
49
46
|
props,
|
|
50
47
|
),
|
|
51
48
|
]
|
|
52
49
|
: []),
|
|
53
|
-
...(config.json &&
|
|
54
|
-
typia.is<
|
|
50
|
+
...(project.config.json &&
|
|
51
|
+
typia.is<IReflectHttpOperation.IBodyParameter>(props.input) &&
|
|
55
52
|
(props.input.contentType === "application/json" ||
|
|
56
53
|
props.input.encrypted === true)
|
|
57
|
-
? [write_stringify(
|
|
54
|
+
? [write_stringify(project)(importer)]
|
|
58
55
|
: []),
|
|
59
56
|
]),
|
|
60
57
|
ts.NodeFlags.Namespace,
|
|
@@ -62,15 +59,14 @@ export namespace SdkNamespaceProgrammer {
|
|
|
62
59
|
};
|
|
63
60
|
|
|
64
61
|
const write_types =
|
|
65
|
-
(
|
|
66
|
-
(config: INestiaConfig) =>
|
|
62
|
+
(project: INestiaProject) =>
|
|
67
63
|
(importer: ImportDictionary) =>
|
|
68
64
|
(
|
|
69
|
-
route:
|
|
65
|
+
route: ITypedHttpRoute,
|
|
70
66
|
props: {
|
|
71
|
-
headers:
|
|
72
|
-
query:
|
|
73
|
-
input:
|
|
67
|
+
headers: ITypedHttpRoute.IParameter | undefined;
|
|
68
|
+
query: ITypedHttpRoute.IParameter | undefined;
|
|
69
|
+
input: ITypedHttpRoute.IParameter | undefined;
|
|
74
70
|
},
|
|
75
71
|
): ts.TypeAliasDeclaration[] => {
|
|
76
72
|
const array: ts.TypeAliasDeclaration[] = [];
|
|
@@ -86,34 +82,31 @@ export namespace SdkNamespaceProgrammer {
|
|
|
86
82
|
if (props.headers !== undefined)
|
|
87
83
|
declare(
|
|
88
84
|
"Headers",
|
|
89
|
-
SdkAliasCollection.headers(
|
|
85
|
+
SdkAliasCollection.headers(project)(importer)(props.headers),
|
|
90
86
|
);
|
|
91
87
|
if (props.query !== undefined)
|
|
92
88
|
declare(
|
|
93
89
|
"Query",
|
|
94
|
-
SdkAliasCollection.query(
|
|
90
|
+
SdkAliasCollection.query(project)(importer)(props.query),
|
|
95
91
|
);
|
|
96
92
|
if (props.input !== undefined)
|
|
97
93
|
declare(
|
|
98
94
|
"Input",
|
|
99
|
-
SdkAliasCollection.input(
|
|
100
|
-
);
|
|
101
|
-
if (config.propagate === true || route.output.typeName !== "void")
|
|
102
|
-
declare(
|
|
103
|
-
"Output",
|
|
104
|
-
SdkAliasCollection.output(checker)(config)(importer)(route),
|
|
95
|
+
SdkAliasCollection.input(project)(importer)(props.input),
|
|
105
96
|
);
|
|
97
|
+
if (project.config.propagate === true || route.output.typeName !== "void")
|
|
98
|
+
declare("Output", SdkAliasCollection.output(project)(importer)(route));
|
|
106
99
|
return array;
|
|
107
100
|
};
|
|
108
101
|
|
|
109
102
|
const write_metadata =
|
|
110
103
|
(importer: ImportDictionary) =>
|
|
111
104
|
(
|
|
112
|
-
route:
|
|
105
|
+
route: ITypedHttpRoute,
|
|
113
106
|
props: {
|
|
114
|
-
headers:
|
|
115
|
-
query:
|
|
116
|
-
input:
|
|
107
|
+
headers: ITypedHttpRoute.IParameter | undefined;
|
|
108
|
+
query: ITypedHttpRoute.IParameter | undefined;
|
|
109
|
+
input: ITypedHttpRoute.IParameter | undefined;
|
|
117
110
|
},
|
|
118
111
|
): ts.VariableStatement =>
|
|
119
112
|
constant("METADATA")(
|
|
@@ -132,7 +125,9 @@ export namespace SdkNamespaceProgrammer {
|
|
|
132
125
|
"request",
|
|
133
126
|
props.input
|
|
134
127
|
? LiteralFactory.generate(
|
|
135
|
-
typia.is<
|
|
128
|
+
typia.is<IReflectHttpOperation.IBodyParameter>(
|
|
129
|
+
props.input,
|
|
130
|
+
)
|
|
136
131
|
? {
|
|
137
132
|
type: props.input.contentType,
|
|
138
133
|
encrypted: !!props.input.encrypted,
|
|
@@ -188,12 +183,12 @@ export namespace SdkNamespaceProgrammer {
|
|
|
188
183
|
);
|
|
189
184
|
|
|
190
185
|
const write_path =
|
|
191
|
-
(
|
|
186
|
+
(project: INestiaProject) =>
|
|
192
187
|
(importer: ImportDictionary) =>
|
|
193
188
|
(
|
|
194
|
-
route:
|
|
189
|
+
route: ITypedHttpRoute,
|
|
195
190
|
props: {
|
|
196
|
-
query:
|
|
191
|
+
query: ITypedHttpRoute.IParameter | undefined;
|
|
197
192
|
},
|
|
198
193
|
): ts.VariableStatement => {
|
|
199
194
|
const g = {
|
|
@@ -217,7 +212,7 @@ export namespace SdkNamespaceProgrammer {
|
|
|
217
212
|
p.name,
|
|
218
213
|
p === props.query
|
|
219
214
|
? ts.factory.createTypeReferenceNode(`${route.name}.Query`)
|
|
220
|
-
: getType(
|
|
215
|
+
: getType(project)(importer)(p),
|
|
221
216
|
),
|
|
222
217
|
),
|
|
223
218
|
undefined,
|
|
@@ -444,7 +439,7 @@ export namespace SdkNamespaceProgrammer {
|
|
|
444
439
|
};
|
|
445
440
|
|
|
446
441
|
const write_stringify =
|
|
447
|
-
(
|
|
442
|
+
(project: INestiaProject) =>
|
|
448
443
|
(importer: ImportDictionary): ts.VariableStatement =>
|
|
449
444
|
constant("stringify")(
|
|
450
445
|
ts.factory.createArrowFunction(
|
|
@@ -463,7 +458,7 @@ export namespace SdkNamespaceProgrammer {
|
|
|
463
458
|
IdentifierFactory.access(
|
|
464
459
|
ts.factory.createIdentifier(SdkImportWizard.typia(importer)),
|
|
465
460
|
)("json"),
|
|
466
|
-
)(config.assert ? "stringify" : "assertStringify"),
|
|
461
|
+
)(project.config.assert ? "stringify" : "assertStringify"),
|
|
467
462
|
undefined,
|
|
468
463
|
[ts.factory.createIdentifier("input")],
|
|
469
464
|
),
|
|
@@ -502,9 +497,9 @@ const constant = (name: string) => (expression: ts.Expression) =>
|
|
|
502
497
|
),
|
|
503
498
|
);
|
|
504
499
|
const getType =
|
|
505
|
-
(
|
|
500
|
+
(project: INestiaProject) =>
|
|
506
501
|
(importer: ImportDictionary) =>
|
|
507
|
-
(p:
|
|
502
|
+
(p: ITypedHttpRoute.IParameter | ITypedHttpRoute.IOutput) =>
|
|
508
503
|
p.metadata
|
|
509
|
-
? SdkTypeProgrammer.write(
|
|
504
|
+
? SdkTypeProgrammer.write(project)(importer)(p.metadata)
|
|
510
505
|
: ts.factory.createTypeReferenceNode(p.typeName);
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
2
|
import { IJsDocTagInfo } from "typia";
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { INestiaProject } from "../../structures/INestiaProject";
|
|
5
|
+
import { ITypedHttpRoute } from "../../structures/ITypedHttpRoute";
|
|
6
6
|
import { FilePrinter } from "./FilePrinter";
|
|
7
7
|
import { ImportDictionary } from "./ImportDictionary";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { SdkHttpFunctionProgrammer } from "./SdkHttpFunctionProgrammer";
|
|
9
|
+
import { SdkHttpNamespaceProgrammer } from "./SdkHttpNamespaceProgrammer";
|
|
10
10
|
|
|
11
|
-
export namespace
|
|
12
|
-
export const
|
|
13
|
-
(
|
|
14
|
-
(config: INestiaConfig) =>
|
|
11
|
+
export namespace SdkHttpRouteProgrammer {
|
|
12
|
+
export const write =
|
|
13
|
+
(project: INestiaProject) =>
|
|
15
14
|
(importer: ImportDictionary) =>
|
|
16
|
-
(route:
|
|
15
|
+
(route: ITypedHttpRoute): ts.Statement[] => {
|
|
17
16
|
const props = {
|
|
18
17
|
headers: route.parameters.find(
|
|
19
18
|
(p) => p.category === "headers" && p.field === undefined,
|
|
@@ -25,14 +24,14 @@ export namespace SdkRouteProgrammer {
|
|
|
25
24
|
};
|
|
26
25
|
return [
|
|
27
26
|
FilePrinter.description(
|
|
28
|
-
|
|
27
|
+
SdkHttpFunctionProgrammer.write(project)(importer)(route, props),
|
|
29
28
|
describe(route),
|
|
30
29
|
),
|
|
31
|
-
|
|
30
|
+
SdkHttpNamespaceProgrammer.write(project)(importer)(route, props),
|
|
32
31
|
];
|
|
33
32
|
};
|
|
34
33
|
|
|
35
|
-
const describe = (route:
|
|
34
|
+
const describe = (route: ITypedHttpRoute): string => {
|
|
36
35
|
// MAIN DESCRIPTION
|
|
37
36
|
const comments: string[] = route.description
|
|
38
37
|
? route.description.split("\n")
|
|
@@ -74,7 +73,7 @@ export namespace SdkRouteProgrammer {
|
|
|
74
73
|
// POSTFIX
|
|
75
74
|
if (!!comments.length) comments.push("");
|
|
76
75
|
comments.push(
|
|
77
|
-
`@controller ${route.
|
|
76
|
+
`@controller ${route.controller.name}.${route.name}`,
|
|
78
77
|
`@path ${route.method} ${route.path}`,
|
|
79
78
|
`@nestia Generated by Nestia - https://github.com/samchon/nestia`,
|
|
80
79
|
);
|
package/src/generates/internal/{SdkSimulationProgrammer.ts → SdkHttpSimulationProgrammer.ts}
RENAMED
|
@@ -5,21 +5,19 @@ import { LiteralFactory } from "typia/lib/factories/LiteralFactory";
|
|
|
5
5
|
import { StatementFactory } from "typia/lib/factories/StatementFactory";
|
|
6
6
|
import { TypeFactory } from "typia/lib/factories/TypeFactory";
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { INestiaProject } from "../../structures/INestiaProject";
|
|
9
|
+
import { ITypedHttpRoute } from "../../structures/ITypedHttpRoute";
|
|
10
10
|
import { ImportDictionary } from "./ImportDictionary";
|
|
11
11
|
import { SdkAliasCollection } from "./SdkAliasCollection";
|
|
12
12
|
import { SdkImportWizard } from "./SdkImportWizard";
|
|
13
13
|
import { SdkTypeProgrammer } from "./SdkTypeProgrammer";
|
|
14
14
|
|
|
15
|
-
export namespace
|
|
15
|
+
export namespace SdkHttpSimulationProgrammer {
|
|
16
16
|
export const random =
|
|
17
|
-
(
|
|
18
|
-
(config: INestiaConfig) =>
|
|
17
|
+
(project: INestiaProject) =>
|
|
19
18
|
(importer: ImportDictionary) =>
|
|
20
|
-
(route:
|
|
21
|
-
const output =
|
|
22
|
-
SdkAliasCollection.responseBody(checker)(config)(importer)(route);
|
|
19
|
+
(route: ITypedHttpRoute): ts.VariableStatement => {
|
|
20
|
+
const output = SdkAliasCollection.responseBody(project)(importer)(route);
|
|
23
21
|
return constant("random")(
|
|
24
22
|
ts.factory.createArrowFunction(
|
|
25
23
|
undefined,
|
|
@@ -40,7 +38,7 @@ export namespace SdkSimulationProgrammer {
|
|
|
40
38
|
),
|
|
41
39
|
),
|
|
42
40
|
],
|
|
43
|
-
config.primitive === false
|
|
41
|
+
project.config.primitive === false
|
|
44
42
|
? output
|
|
45
43
|
: ts.factory.createTypeReferenceNode(
|
|
46
44
|
SdkImportWizard.Resolved(importer),
|
|
@@ -59,18 +57,18 @@ export namespace SdkSimulationProgrammer {
|
|
|
59
57
|
};
|
|
60
58
|
|
|
61
59
|
export const simulate =
|
|
62
|
-
(
|
|
60
|
+
(project: INestiaProject) =>
|
|
63
61
|
(importer: ImportDictionary) =>
|
|
64
62
|
(
|
|
65
|
-
route:
|
|
63
|
+
route: ITypedHttpRoute,
|
|
66
64
|
props: {
|
|
67
|
-
headers:
|
|
68
|
-
query:
|
|
69
|
-
input:
|
|
65
|
+
headers: ITypedHttpRoute.IParameter | undefined;
|
|
66
|
+
query: ITypedHttpRoute.IParameter | undefined;
|
|
67
|
+
input: ITypedHttpRoute.IParameter | undefined;
|
|
70
68
|
},
|
|
71
69
|
): ts.VariableStatement => {
|
|
72
70
|
const output: boolean =
|
|
73
|
-
config.propagate === true || route.output.typeName !== "void";
|
|
71
|
+
project.config.propagate === true || route.output.typeName !== "void";
|
|
74
72
|
const caller = () =>
|
|
75
73
|
ts.factory.createCallExpression(
|
|
76
74
|
ts.factory.createIdentifier("random"),
|
|
@@ -127,12 +125,12 @@ export namespace SdkSimulationProgrammer {
|
|
|
127
125
|
p.optional
|
|
128
126
|
? ts.factory.createToken(ts.SyntaxKind.QuestionToken)
|
|
129
127
|
: undefined,
|
|
130
|
-
config.primitive !== false &&
|
|
128
|
+
project.config.primitive !== false &&
|
|
131
129
|
(p === props.query || p === props.input)
|
|
132
130
|
? ts.factory.createTypeReferenceNode(
|
|
133
131
|
`${route.name}.${p === props.query ? "Query" : "Input"}`,
|
|
134
132
|
)
|
|
135
|
-
: getTypeName(
|
|
133
|
+
: getTypeName(project)(importer)(p),
|
|
136
134
|
),
|
|
137
135
|
),
|
|
138
136
|
],
|
|
@@ -140,9 +138,9 @@ export namespace SdkSimulationProgrammer {
|
|
|
140
138
|
undefined,
|
|
141
139
|
ts.factory.createBlock(
|
|
142
140
|
[
|
|
143
|
-
...assert(
|
|
141
|
+
...assert(project)(importer)(route),
|
|
144
142
|
ts.factory.createReturnStatement(
|
|
145
|
-
config.propagate
|
|
143
|
+
project.config.propagate
|
|
146
144
|
? ts.factory.createObjectLiteralExpression(
|
|
147
145
|
[
|
|
148
146
|
ts.factory.createPropertyAssignment(
|
|
@@ -176,9 +174,9 @@ export namespace SdkSimulationProgrammer {
|
|
|
176
174
|
};
|
|
177
175
|
|
|
178
176
|
const assert =
|
|
179
|
-
(
|
|
177
|
+
(project: INestiaProject) =>
|
|
180
178
|
(importer: ImportDictionary) =>
|
|
181
|
-
(route:
|
|
179
|
+
(route: ITypedHttpRoute): ts.Statement[] => {
|
|
182
180
|
const parameters = route.parameters.filter(
|
|
183
181
|
(p) => p.category !== "headers",
|
|
184
182
|
);
|
|
@@ -272,7 +270,7 @@ export namespace SdkSimulationProgrammer {
|
|
|
272
270
|
|
|
273
271
|
return [
|
|
274
272
|
validator,
|
|
275
|
-
...(config.propagate !== true
|
|
273
|
+
...(project.config.propagate !== true
|
|
276
274
|
? individual
|
|
277
275
|
: [tryAndCatch(importer)(individual)]),
|
|
278
276
|
];
|
|
@@ -357,9 +355,9 @@ const constant = (name: string) => (expression: ts.Expression) =>
|
|
|
357
355
|
);
|
|
358
356
|
|
|
359
357
|
const getTypeName =
|
|
360
|
-
(
|
|
358
|
+
(project: INestiaProject) =>
|
|
361
359
|
(importer: ImportDictionary) =>
|
|
362
|
-
(p:
|
|
360
|
+
(p: ITypedHttpRoute.IParameter | ITypedHttpRoute.IOutput) =>
|
|
363
361
|
p.metadata
|
|
364
|
-
? SdkTypeProgrammer.write(
|
|
362
|
+
? SdkTypeProgrammer.write(project)(importer)(p.metadata)
|
|
365
363
|
: ts.factory.createTypeReferenceNode(p.typeName);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ITypedHttpRoute } from "../../structures/ITypedHttpRoute";
|
|
2
|
+
import { ITypedWebSocketRoute } from "../../structures/ITypedWebSocketRoute";
|
|
2
3
|
|
|
3
4
|
export class SdkRouteDirectory {
|
|
4
5
|
public readonly module: string;
|
|
5
6
|
public readonly children: Map<string, SdkRouteDirectory>;
|
|
6
|
-
public readonly routes:
|
|
7
|
+
public readonly routes: Array<ITypedHttpRoute | ITypedWebSocketRoute>;
|
|
7
8
|
|
|
8
9
|
public constructor(
|
|
9
10
|
readonly parent: SdkRouteDirectory | null,
|