@nestia/sdk 3.10.0 → 3.11.0-dev.20240812
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 -3
- package/lib/NestiaSdkApplication.js +138 -136
- package/lib/NestiaSdkApplication.js.map +1 -1
- package/lib/analyses/ConfigAnalyzer.d.ts +2 -2
- package/lib/analyses/ConfigAnalyzer.js +39 -80
- package/lib/analyses/ConfigAnalyzer.js.map +1 -1
- package/lib/analyses/ExceptionAnalyzer.d.ts +0 -16
- package/lib/analyses/ExceptionAnalyzer.js +142 -105
- package/lib/analyses/ExceptionAnalyzer.js.map +1 -1
- package/lib/analyses/GenericAnalyzer.d.ts +1 -2
- package/lib/analyses/GenericAnalyzer.js.map +1 -1
- package/lib/analyses/ImportAnalyzer.d.ts +6 -11
- package/lib/analyses/ImportAnalyzer.js +70 -42
- package/lib/analyses/ImportAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectControllerAnalyzer.d.ts +7 -1
- package/lib/analyses/ReflectControllerAnalyzer.js +28 -99
- package/lib/analyses/ReflectControllerAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationAnalyzer.d.ts +6 -2
- package/lib/analyses/ReflectHttpOperationAnalyzer.js +72 -152
- package/lib/analyses/ReflectHttpOperationAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationParameterAnalyzer.d.ts +15 -0
- package/lib/analyses/ReflectHttpOperationParameterAnalyzer.js +215 -0
- package/lib/analyses/ReflectHttpOperationParameterAnalyzer.js.map +1 -0
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.d.ts +15 -0
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.js +81 -0
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.js.map +1 -0
- package/lib/analyses/ReflectMetadataAnalyzer.d.ts +1 -3
- package/lib/analyses/ReflectMetadataAnalyzer.js +0 -4
- package/lib/analyses/ReflectMetadataAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectWebSocketOperationAnalyzer.d.ts +6 -2
- package/lib/analyses/ReflectWebSocketOperationAnalyzer.js +72 -48
- package/lib/analyses/ReflectWebSocketOperationAnalyzer.js.map +1 -1
- package/lib/analyses/TypedHttpRouteAnalyzer.d.ts +15 -0
- package/lib/analyses/TypedHttpRouteAnalyzer.js +111 -0
- package/lib/analyses/TypedHttpRouteAnalyzer.js.map +1 -0
- package/lib/analyses/TypedWebSocketRouteAnalyzer.d.ts +10 -0
- package/lib/analyses/TypedWebSocketRouteAnalyzer.js +9 -0
- package/lib/analyses/TypedWebSocketRouteAnalyzer.js.map +1 -0
- package/lib/decorators/OperationMetadata.d.ts +2 -0
- package/lib/decorators/OperationMetadata.js +10 -0
- package/lib/decorators/OperationMetadata.js.map +1 -0
- package/lib/executable/internal/NestiaConfigLoader.d.ts +1 -1
- package/lib/executable/internal/NestiaConfigLoader.js +33 -3
- package/lib/executable/internal/NestiaConfigLoader.js.map +1 -1
- package/lib/executable/internal/NestiaSdkCommand.js +1 -1
- package/lib/executable/internal/NestiaSdkCommand.js.map +1 -1
- package/lib/generates/CloneGenerator.d.ts +0 -5
- package/lib/generates/CloneGenerator.js +60 -60
- package/lib/generates/CloneGenerator.js.map +1 -1
- package/lib/generates/E2eGenerator.d.ts +2 -3
- package/lib/generates/E2eGenerator.js +9 -8
- package/lib/generates/E2eGenerator.js.map +1 -1
- package/lib/generates/OpenAiGenerator.d.ts +2 -4
- package/lib/generates/OpenAiGenerator.js +13 -3
- package/lib/generates/OpenAiGenerator.js.map +1 -1
- package/lib/generates/SdkGenerator.d.ts +4 -4
- package/lib/generates/SdkGenerator.js +63 -73
- package/lib/generates/SdkGenerator.js.map +1 -1
- package/lib/generates/SwaggerGenerator.d.ts +6 -18
- package/lib/generates/SwaggerGenerator.js +60 -235
- package/lib/generates/SwaggerGenerator.js.map +1 -1
- package/lib/generates/internal/E2eFileProgrammer.js +5 -9
- package/lib/generates/internal/E2eFileProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkAliasCollection.d.ts +6 -4
- package/lib/generates/internal/SdkAliasCollection.js +33 -31
- package/lib/generates/internal/SdkAliasCollection.js.map +1 -1
- package/lib/generates/internal/SdkDistributionComposer.d.ts +4 -1
- package/lib/generates/internal/SdkDistributionComposer.js +6 -6
- package/lib/generates/internal/SdkDistributionComposer.js.map +1 -1
- package/lib/generates/internal/SdkFileProgrammer.d.ts +2 -4
- package/lib/generates/internal/SdkFileProgrammer.js +6 -6
- package/lib/generates/internal/SdkFileProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpCloneProgrammer.d.ts +0 -12
- package/lib/generates/internal/SdkHttpCloneProgrammer.js +142 -97
- package/lib/generates/internal/SdkHttpCloneProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpFunctionProgrammer.d.ts +4 -3
- package/lib/generates/internal/SdkHttpFunctionProgrammer.js +37 -59
- package/lib/generates/internal/SdkHttpFunctionProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.d.ts +4 -3
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.js +31 -48
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpRouteProgrammer.js +7 -3
- package/lib/generates/internal/SdkHttpRouteProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpSimulationProgrammer.d.ts +4 -3
- package/lib/generates/internal/SdkHttpSimulationProgrammer.js +7 -13
- package/lib/generates/internal/SdkHttpSimulationProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.d.ts +1 -2
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js +11 -16
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.d.ts +1 -2
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.js +7 -10
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.js.map +1 -1
- package/lib/generates/internal/SwaggerDescriptionComposer.d.ts +23 -0
- package/lib/generates/internal/SwaggerDescriptionComposer.js +44 -0
- package/lib/generates/internal/SwaggerDescriptionComposer.js.map +1 -0
- package/lib/generates/internal/SwaggerOperationComposer.d.ts +12 -0
- package/lib/generates/internal/SwaggerOperationComposer.js +68 -0
- package/lib/generates/internal/SwaggerOperationComposer.js.map +1 -0
- package/lib/generates/internal/SwaggerOperationParameterComposer.d.ts +18 -0
- package/lib/generates/internal/SwaggerOperationParameterComposer.js +99 -0
- package/lib/generates/internal/SwaggerOperationParameterComposer.js.map +1 -0
- package/lib/generates/internal/SwaggerOperationResponseComposer.d.ts +9 -0
- package/lib/generates/internal/SwaggerOperationResponseComposer.js +91 -0
- package/lib/generates/internal/SwaggerOperationResponseComposer.js.map +1 -0
- package/lib/structures/INestiaProject.d.ts +5 -5
- package/lib/structures/INestiaSdkInput.d.ts +20 -0
- package/lib/structures/{ISwaggerError.js → INestiaSdkInput.js} +1 -1
- package/lib/structures/INestiaSdkInput.js.map +1 -0
- package/lib/structures/IReflectApplication.d.ts +6 -0
- package/lib/structures/IReflectApplication.js +3 -0
- package/lib/structures/IReflectApplication.js.map +1 -0
- package/lib/structures/IReflectController.d.ts +3 -5
- package/lib/structures/IReflectHttpOperation.d.ts +13 -65
- package/lib/structures/IReflectHttpOperationException.d.ts +14 -0
- package/lib/structures/IReflectHttpOperationException.js +3 -0
- package/lib/structures/IReflectHttpOperationException.js.map +1 -0
- package/lib/structures/IReflectHttpOperationParameter.d.ts +35 -0
- package/lib/structures/IReflectHttpOperationParameter.js +3 -0
- package/lib/structures/IReflectHttpOperationParameter.js.map +1 -0
- package/lib/structures/IReflectHttpOperationSuccess.d.ts +15 -0
- package/lib/structures/IReflectHttpOperationSuccess.js +3 -0
- package/lib/structures/IReflectHttpOperationSuccess.js.map +1 -0
- package/lib/structures/IReflectOperationError.d.ts +16 -0
- package/lib/structures/IReflectOperationError.js +23 -0
- package/lib/structures/IReflectOperationError.js.map +1 -0
- package/lib/structures/IReflectType.d.ts +4 -0
- package/lib/structures/{IErrorReport.js → IReflectType.js} +1 -1
- package/lib/structures/IReflectType.js.map +1 -0
- package/lib/structures/IReflectTypeImport.d.ts +4 -0
- package/lib/structures/{ISwaggerLazySchema.js → IReflectTypeImport.js} +1 -1
- package/lib/structures/IReflectTypeImport.js.map +1 -0
- package/lib/structures/IReflectWebSocketOperation.d.ts +8 -9
- package/lib/structures/IReflectWebSocketOperationParameter.d.ts +23 -0
- package/lib/structures/IReflectWebSocketOperationParameter.js +3 -0
- package/lib/structures/IReflectWebSocketOperationParameter.js.map +1 -0
- package/lib/structures/ITypedApplication.d.ts +7 -0
- package/lib/structures/{INormalizedInput.js → ITypedApplication.js} +1 -1
- package/lib/structures/ITypedApplication.js.map +1 -0
- package/lib/structures/ITypedHttpRoute.d.ts +14 -42
- package/lib/structures/ITypedHttpRouteException.d.ts +10 -0
- package/lib/structures/ITypedHttpRouteException.js +3 -0
- package/lib/structures/ITypedHttpRouteException.js.map +1 -0
- package/lib/structures/ITypedHttpRouteParameter.d.ts +31 -0
- package/lib/structures/ITypedHttpRouteParameter.js +3 -0
- package/lib/structures/ITypedHttpRouteParameter.js.map +1 -0
- package/lib/structures/ITypedHttpRouteSuccess.d.ts +19 -0
- package/lib/structures/{ISwaggerLazyProperty.js → ITypedHttpRouteSuccess.js} +1 -1
- package/lib/structures/ITypedHttpRouteSuccess.js.map +1 -0
- package/lib/structures/ITypedWebSocketRoute.d.ts +8 -44
- package/lib/structures/ITypedWebSocketRouteParameter.d.ts +2 -0
- package/lib/structures/ITypedWebSocketRouteParameter.js +3 -0
- package/lib/structures/ITypedWebSocketRouteParameter.js.map +1 -0
- package/lib/transform.d.ts +3 -0
- package/lib/transform.js +8 -0
- package/lib/transform.js.map +1 -0
- package/lib/transformers/IOperationMetadata.d.ts +36 -0
- package/lib/transformers/IOperationMetadata.js +3 -0
- package/lib/transformers/IOperationMetadata.js.map +1 -0
- package/lib/transformers/ISdkTransformerContext.d.ts +7 -0
- package/lib/transformers/ISdkTransformerContext.js +3 -0
- package/lib/transformers/ISdkTransformerContext.js.map +1 -0
- package/lib/transformers/SdkMetadataProgrammer.d.ts +11 -0
- package/lib/transformers/SdkMetadataProgrammer.js +159 -0
- package/lib/transformers/SdkMetadataProgrammer.js.map +1 -0
- package/lib/transformers/SdkTransformer.d.ts +4 -0
- package/lib/transformers/SdkTransformer.js +88 -0
- package/lib/transformers/SdkTransformer.js.map +1 -0
- package/lib/transformers/TextPlainValidator.d.ts +4 -0
- package/lib/transformers/TextPlainValidator.js +19 -0
- package/lib/transformers/TextPlainValidator.js.map +1 -0
- package/lib/utils/StringUtil.d.ts +1 -0
- package/lib/utils/StringUtil.js +1 -0
- package/lib/utils/StringUtil.js.map +1 -1
- package/package.json +8 -8
- package/src/NestiaSdkApplication.ts +173 -160
- package/src/analyses/ConfigAnalyzer.ts +50 -98
- package/src/analyses/ExceptionAnalyzer.ts +142 -142
- package/src/analyses/GenericAnalyzer.ts +3 -5
- package/src/analyses/ImportAnalyzer.ts +130 -115
- package/src/analyses/ReflectControllerAnalyzer.ts +63 -115
- package/src/analyses/ReflectHttpOperationAnalyzer.ts +142 -278
- package/src/analyses/ReflectHttpOperationParameterAnalyzer.ts +319 -0
- package/src/analyses/ReflectHttpOperationResponseAnalyzer.ts +117 -0
- package/src/analyses/ReflectMetadataAnalyzer.ts +1 -18
- package/src/analyses/ReflectWebSocketOperationAnalyzer.ts +143 -78
- package/src/analyses/TypedHttpRouteAnalyzer.ts +178 -0
- package/src/analyses/TypedWebSocketRouteAnalyzer.ts +18 -0
- package/src/decorators/OperationMetadata.ts +15 -0
- package/src/executable/internal/NestiaConfigLoader.ts +17 -3
- package/src/executable/internal/NestiaSdkCommand.ts +1 -4
- package/src/generates/CloneGenerator.ts +60 -59
- package/src/generates/E2eGenerator.ts +20 -21
- package/src/generates/OpenAiGenerator.ts +44 -45
- package/src/generates/SdkGenerator.ts +97 -125
- package/src/generates/SwaggerGenerator.ts +114 -416
- package/src/generates/internal/E2eFileProgrammer.ts +5 -14
- package/src/generates/internal/SdkAliasCollection.ts +33 -41
- package/src/generates/internal/SdkDistributionComposer.ts +9 -6
- package/src/generates/internal/SdkFileProgrammer.ts +11 -14
- package/src/generates/internal/SdkHttpCloneProgrammer.ts +142 -142
- package/src/generates/internal/SdkHttpFunctionProgrammer.ts +20 -47
- package/src/generates/internal/SdkHttpNamespaceProgrammer.ts +245 -275
- package/src/generates/internal/SdkHttpRouteProgrammer.ts +7 -7
- package/src/generates/internal/SdkHttpSimulationProgrammer.ts +11 -23
- package/src/generates/internal/SdkWebSocketNamespaceProgrammer.ts +197 -233
- package/src/generates/internal/SdkWebSocketRouteProgrammer.ts +5 -15
- package/src/generates/internal/{SwaggerDescriptionGenerator.ts → SwaggerDescriptionComposer.ts} +25 -5
- package/src/generates/internal/SwaggerOperationComposer.ts +90 -0
- package/src/generates/internal/SwaggerOperationParameterComposer.ts +173 -0
- package/src/generates/internal/SwaggerOperationResponseComposer.ts +110 -0
- package/src/structures/INestiaProject.ts +5 -5
- package/src/structures/INestiaSdkInput.ts +25 -0
- package/src/structures/IReflectApplication.ts +8 -0
- package/src/structures/IReflectController.ts +3 -5
- package/src/structures/IReflectHttpOperation.ts +14 -76
- package/src/structures/IReflectHttpOperationException.ts +19 -0
- package/src/structures/IReflectHttpOperationParameter.ts +81 -0
- package/src/structures/IReflectHttpOperationSuccess.ts +22 -0
- package/src/structures/IReflectOperationError.ts +26 -0
- package/src/structures/IReflectType.ts +4 -0
- package/src/structures/IReflectTypeImport.ts +4 -0
- package/src/structures/IReflectWebSocketOperation.ts +9 -9
- package/src/structures/IReflectWebSocketOperationParameter.ts +38 -0
- package/src/structures/ITypedApplication.ts +8 -0
- package/src/structures/ITypedHttpRoute.ts +15 -45
- package/src/structures/ITypedHttpRouteException.ts +15 -0
- package/src/structures/ITypedHttpRouteParameter.ts +41 -0
- package/src/structures/ITypedHttpRouteSuccess.ts +22 -0
- package/src/structures/ITypedWebSocketRoute.ts +8 -56
- package/src/structures/ITypedWebSocketRouteParameter.ts +3 -0
- package/src/transform.ts +9 -0
- package/src/transformers/IOperationMetadata.ts +38 -0
- package/src/transformers/ISdkTransformerContext.ts +8 -0
- package/src/transformers/SdkMetadataProgrammer.ts +227 -0
- package/src/transformers/SdkTransformer.ts +168 -0
- package/src/transformers/TextPlainValidator.ts +17 -0
- package/src/utils/StringUtil.ts +3 -0
- package/lib/analyses/TypedControllerAnalyzer.d.ts +0 -8
- package/lib/analyses/TypedControllerAnalyzer.js +0 -77
- package/lib/analyses/TypedControllerAnalyzer.js.map +0 -1
- package/lib/analyses/TypedHttpOperationAnalyzer.d.ts +0 -15
- package/lib/analyses/TypedHttpOperationAnalyzer.js +0 -263
- package/lib/analyses/TypedHttpOperationAnalyzer.js.map +0 -1
- package/lib/analyses/TypedWebSocketOperationAnalyzer.d.ts +0 -15
- package/lib/analyses/TypedWebSocketOperationAnalyzer.js +0 -226
- package/lib/analyses/TypedWebSocketOperationAnalyzer.js.map +0 -1
- package/lib/generates/internal/SwaggerDescriptionGenerator.d.ts +0 -14
- package/lib/generates/internal/SwaggerDescriptionGenerator.js +0 -33
- package/lib/generates/internal/SwaggerDescriptionGenerator.js.map +0 -1
- package/lib/generates/internal/SwaggerSchemaGenerator.d.ts +0 -21
- package/lib/generates/internal/SwaggerSchemaGenerator.js +0 -289
- package/lib/generates/internal/SwaggerSchemaGenerator.js.map +0 -1
- package/lib/generates/internal/SwaggerSchemaValidator.d.ts +0 -7
- package/lib/generates/internal/SwaggerSchemaValidator.js +0 -191
- package/lib/generates/internal/SwaggerSchemaValidator.js.map +0 -1
- package/lib/structures/IErrorReport.d.ts +0 -6
- package/lib/structures/IErrorReport.js.map +0 -1
- package/lib/structures/INormalizedInput.d.ts +0 -19
- package/lib/structures/INormalizedInput.js.map +0 -1
- package/lib/structures/ISwaggerError.d.ts +0 -6
- package/lib/structures/ISwaggerError.js.map +0 -1
- package/lib/structures/ISwaggerLazyProperty.d.ts +0 -6
- package/lib/structures/ISwaggerLazyProperty.js.map +0 -1
- package/lib/structures/ISwaggerLazySchema.d.ts +0 -6
- package/lib/structures/ISwaggerLazySchema.js.map +0 -1
- package/lib/structures/ITypeTuple.d.ts +0 -5
- package/lib/structures/ITypeTuple.js +0 -3
- package/lib/structures/ITypeTuple.js.map +0 -1
- package/src/analyses/TypedControllerAnalyzer.ts +0 -92
- package/src/analyses/TypedHttpOperationAnalyzer.ts +0 -365
- package/src/analyses/TypedWebSocketOperationAnalyzer.ts +0 -375
- package/src/generates/internal/SwaggerSchemaGenerator.ts +0 -473
- package/src/generates/internal/SwaggerSchemaValidator.ts +0 -206
- package/src/structures/IErrorReport.ts +0 -6
- package/src/structures/INormalizedInput.ts +0 -20
- package/src/structures/ISwaggerError.ts +0 -8
- package/src/structures/ISwaggerLazyProperty.ts +0 -7
- package/src/structures/ISwaggerLazySchema.ts +0 -7
- package/src/structures/ITypeTuple.ts +0 -6
|
@@ -2,25 +2,24 @@ import ts from "typescript";
|
|
|
2
2
|
import typia from "typia";
|
|
3
3
|
|
|
4
4
|
import { INestiaProject } from "../../structures/INestiaProject";
|
|
5
|
-
import {
|
|
5
|
+
import { IReflectHttpOperationParameter } from "../../structures/IReflectHttpOperationParameter";
|
|
6
|
+
import { IReflectType } from "../../structures/IReflectType";
|
|
6
7
|
import { ITypedHttpRoute } from "../../structures/ITypedHttpRoute";
|
|
8
|
+
import { ITypedHttpRouteParameter } from "../../structures/ITypedHttpRouteParameter";
|
|
7
9
|
import { ImportDictionary } from "./ImportDictionary";
|
|
8
|
-
import { SdkTypeProgrammer } from "./SdkTypeProgrammer";
|
|
9
10
|
|
|
10
11
|
export namespace SdkAliasCollection {
|
|
11
|
-
export const name =
|
|
12
|
-
(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
? SdkTypeProgrammer.write(project)(importer)(p.metadata)
|
|
17
|
-
: ts.factory.createTypeReferenceNode(p.typeName);
|
|
12
|
+
export const name = (type: IReflectType): ts.TypeNode =>
|
|
13
|
+
ts.factory.createTypeReferenceNode(
|
|
14
|
+
type.name,
|
|
15
|
+
type.typeArguments ? type.typeArguments.map(name) : undefined,
|
|
16
|
+
);
|
|
18
17
|
|
|
19
18
|
export const headers =
|
|
20
19
|
(project: INestiaProject) =>
|
|
21
20
|
(importer: ImportDictionary) =>
|
|
22
|
-
(param:
|
|
23
|
-
const type: ts.TypeNode = name(
|
|
21
|
+
(param: ITypedHttpRouteParameter.IHeaders): ts.TypeNode => {
|
|
22
|
+
const type: ts.TypeNode = name(param);
|
|
24
23
|
if (project.config.primitive === false) return type;
|
|
25
24
|
return ts.factory.createTypeReferenceNode(
|
|
26
25
|
importer.external({
|
|
@@ -35,8 +34,8 @@ export namespace SdkAliasCollection {
|
|
|
35
34
|
export const query =
|
|
36
35
|
(project: INestiaProject) =>
|
|
37
36
|
(importer: ImportDictionary) =>
|
|
38
|
-
(param:
|
|
39
|
-
const type: ts.TypeNode = name(
|
|
37
|
+
(param: ITypedHttpRouteParameter.IQuery): ts.TypeNode => {
|
|
38
|
+
const type: ts.TypeNode = name(param);
|
|
40
39
|
if (project.config.primitive === false) return type;
|
|
41
40
|
return ts.factory.createTypeReferenceNode(
|
|
42
41
|
importer.external({
|
|
@@ -51,8 +50,8 @@ export namespace SdkAliasCollection {
|
|
|
51
50
|
export const input =
|
|
52
51
|
(project: INestiaProject) =>
|
|
53
52
|
(importer: ImportDictionary) =>
|
|
54
|
-
(param:
|
|
55
|
-
const type: ts.TypeNode = name(
|
|
53
|
+
(param: ITypedHttpRouteParameter): ts.TypeNode => {
|
|
54
|
+
const type: ts.TypeNode = name(param.type);
|
|
56
55
|
if (project.config.clone === true || project.config.primitive === false)
|
|
57
56
|
return type;
|
|
58
57
|
return ts.factory.createTypeReferenceNode(
|
|
@@ -60,10 +59,11 @@ export namespace SdkAliasCollection {
|
|
|
60
59
|
type: true,
|
|
61
60
|
library: "@nestia/fetcher",
|
|
62
61
|
instance:
|
|
63
|
-
typia.is<
|
|
64
|
-
param.contentType === "
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
typia.is<IReflectHttpOperationParameter.IBody>(param) &&
|
|
63
|
+
(param.contentType === "application/json" ||
|
|
64
|
+
param.encrypted === true)
|
|
65
|
+
? "Primitive"
|
|
66
|
+
: "Resolved",
|
|
67
67
|
}),
|
|
68
68
|
[type],
|
|
69
69
|
);
|
|
@@ -74,40 +74,32 @@ export namespace SdkAliasCollection {
|
|
|
74
74
|
(importer: ImportDictionary) =>
|
|
75
75
|
(route: ITypedHttpRoute): ts.TypeNode => {
|
|
76
76
|
if (project.config.propagate !== true) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const filter = (flag: ts.TypeFlags) => (type.getFlags() & flag) !== 0;
|
|
80
|
-
|
|
81
|
-
if (
|
|
82
|
-
project.config.clone === true ||
|
|
83
|
-
project.config.primitive === false ||
|
|
84
|
-
filter(ts.TypeFlags.Undefined) ||
|
|
85
|
-
filter(ts.TypeFlags.Never) ||
|
|
86
|
-
filter(ts.TypeFlags.Void) ||
|
|
87
|
-
filter(ts.TypeFlags.VoidLike)
|
|
88
|
-
)
|
|
89
|
-
return node;
|
|
77
|
+
if (project.config.clone === true || project.config.primitive === false)
|
|
78
|
+
return name(route.success.type);
|
|
90
79
|
return ts.factory.createTypeReferenceNode(
|
|
91
80
|
importer.external({
|
|
92
81
|
type: true,
|
|
93
82
|
library: "@nestia/fetcher",
|
|
94
83
|
instance:
|
|
95
|
-
route.
|
|
96
|
-
|
|
97
|
-
|
|
84
|
+
route.success.contentType === "application/json" ||
|
|
85
|
+
route.success.encrypted === true
|
|
86
|
+
? "Primitive"
|
|
87
|
+
: "Resolved",
|
|
98
88
|
}),
|
|
99
|
-
[
|
|
89
|
+
[name(route.success.type)],
|
|
100
90
|
);
|
|
101
91
|
}
|
|
102
92
|
|
|
103
93
|
const branches: IBranch[] = [
|
|
104
94
|
{
|
|
105
|
-
status: String(
|
|
106
|
-
|
|
95
|
+
status: String(
|
|
96
|
+
route.success.status ?? (route.method === "POST" ? 201 : 200),
|
|
97
|
+
),
|
|
98
|
+
type: name(route.success.type),
|
|
107
99
|
},
|
|
108
100
|
...Object.entries(route.exceptions).map(([status, value]) => ({
|
|
109
101
|
status,
|
|
110
|
-
type: name(
|
|
102
|
+
type: name(value.type),
|
|
111
103
|
})),
|
|
112
104
|
];
|
|
113
105
|
return ts.factory.createTypeReferenceNode(
|
|
@@ -127,10 +119,10 @@ export namespace SdkAliasCollection {
|
|
|
127
119
|
),
|
|
128
120
|
),
|
|
129
121
|
),
|
|
130
|
-
...(route.status
|
|
122
|
+
...(route.success.status
|
|
131
123
|
? [
|
|
132
124
|
ts.factory.createLiteralTypeNode(
|
|
133
|
-
ts.factory.createNumericLiteral(route.status),
|
|
125
|
+
ts.factory.createNumericLiteral(route.success.status),
|
|
134
126
|
),
|
|
135
127
|
]
|
|
136
128
|
: []),
|
|
@@ -6,13 +6,16 @@ import typia from "typia";
|
|
|
6
6
|
import { INestiaConfig } from "../../INestiaConfig";
|
|
7
7
|
|
|
8
8
|
export namespace SdkDistributionComposer {
|
|
9
|
-
export const compose = async (
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
export const compose = async (props: {
|
|
10
|
+
config: INestiaConfig;
|
|
11
|
+
websocket: boolean;
|
|
12
|
+
}) => {
|
|
13
|
+
if (!fs.existsSync(props.config.distribute!))
|
|
14
|
+
await fs.promises.mkdir(props.config.distribute!);
|
|
12
15
|
|
|
13
16
|
const root: string = process.cwd();
|
|
14
|
-
const output: string = path.resolve(config.output!);
|
|
15
|
-
process.chdir(config.distribute!);
|
|
17
|
+
const output: string = path.resolve(props.config.output!);
|
|
18
|
+
process.chdir(props.config.distribute!);
|
|
16
19
|
|
|
17
20
|
const exit = () => process.chdir(root);
|
|
18
21
|
if (await configured()) return exit();
|
|
@@ -31,7 +34,7 @@ export namespace SdkDistributionComposer {
|
|
|
31
34
|
execute("npm install --save-dev rimraf");
|
|
32
35
|
execute(`npm install --save @nestia/fetcher@${v.version}`);
|
|
33
36
|
execute(`npm install --save typia@${v.typia}`);
|
|
34
|
-
if (websocket) execute(`npm install --save tgrid@${v.tgrid}`);
|
|
37
|
+
if (props.websocket) execute(`npm install --save tgrid@${v.tgrid}`);
|
|
35
38
|
execute("npx typia setup --manager npm");
|
|
36
39
|
|
|
37
40
|
exit();
|
|
@@ -2,6 +2,7 @@ import fs from "fs";
|
|
|
2
2
|
import ts from "typescript";
|
|
3
3
|
|
|
4
4
|
import { INestiaProject } from "../../structures/INestiaProject";
|
|
5
|
+
import { ITypedApplication } from "../../structures/ITypedApplication";
|
|
5
6
|
import { ITypedHttpRoute } from "../../structures/ITypedHttpRoute";
|
|
6
7
|
import { ITypedWebSocketRoute } from "../../structures/ITypedWebSocketRoute";
|
|
7
8
|
import { MapUtil } from "../../utils/MapUtil";
|
|
@@ -15,18 +16,14 @@ export namespace SdkFileProgrammer {
|
|
|
15
16
|
/* ---------------------------------------------------------
|
|
16
17
|
CONSTRUCTOR
|
|
17
18
|
--------------------------------------------------------- */
|
|
18
|
-
export const generate =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
): Promise<void> => {
|
|
23
|
-
// CONSTRUCT FOLDER TREE
|
|
24
|
-
const root: SdkRouteDirectory = new SdkRouteDirectory(null, "functional");
|
|
25
|
-
for (const route of routeList) emplace(root)(route);
|
|
19
|
+
export const generate = async (app: ITypedApplication): Promise<void> => {
|
|
20
|
+
// CONSTRUCT FOLDER TREE
|
|
21
|
+
const root: SdkRouteDirectory = new SdkRouteDirectory(null, "functional");
|
|
22
|
+
for (const route of app.routes) emplace(root)(route);
|
|
26
23
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
// ITERATE FILES
|
|
25
|
+
await iterate(app.project)(root)(`${app.project.config.output}/functional`);
|
|
26
|
+
};
|
|
30
27
|
|
|
31
28
|
const emplace =
|
|
32
29
|
(directory: SdkRouteDirectory) =>
|
|
@@ -80,16 +77,16 @@ export namespace SdkFileProgrammer {
|
|
|
80
77
|
directory.routes.forEach((route, i) => {
|
|
81
78
|
if (project.config.clone !== true || route.protocol === "websocket")
|
|
82
79
|
for (const tuple of route.imports)
|
|
83
|
-
for (const instance of tuple
|
|
80
|
+
for (const instance of tuple.instances)
|
|
84
81
|
importer.internal({
|
|
85
|
-
file: tuple
|
|
82
|
+
file: tuple.file,
|
|
86
83
|
instance,
|
|
87
84
|
type: true,
|
|
88
85
|
});
|
|
89
86
|
statements.push(
|
|
90
87
|
...(route.protocol === "http"
|
|
91
88
|
? SdkHttpRouteProgrammer.write(project)(importer)(route)
|
|
92
|
-
: SdkWebSocketRouteProgrammer.write(
|
|
89
|
+
: SdkWebSocketRouteProgrammer.write(importer)(route)),
|
|
93
90
|
);
|
|
94
91
|
if (i !== directory.routes.length - 1)
|
|
95
92
|
statements.push(FilePrinter.enter());
|
|
@@ -1,154 +1,154 @@
|
|
|
1
|
-
import { IPointer } from "tstl";
|
|
2
|
-
import ts from "typescript";
|
|
3
|
-
import { IJsDocTagInfo } from "typia";
|
|
4
|
-
import { MetadataCollection } from "typia/lib/factories/MetadataCollection";
|
|
5
|
-
import { MetadataFactory } from "typia/lib/factories/MetadataFactory";
|
|
6
|
-
import { MetadataAlias } from "typia/lib/schemas/metadata/MetadataAlias";
|
|
7
|
-
import { MetadataAtomic } from "typia/lib/schemas/metadata/MetadataAtomic";
|
|
8
|
-
import { MetadataObject } from "typia/lib/schemas/metadata/MetadataObject";
|
|
1
|
+
// import { IPointer } from "tstl";
|
|
2
|
+
// import ts from "typescript";
|
|
3
|
+
// import { IJsDocTagInfo } from "typia";
|
|
4
|
+
// import { MetadataCollection } from "typia/lib/factories/MetadataCollection";
|
|
5
|
+
// import { MetadataFactory } from "typia/lib/factories/MetadataFactory";
|
|
6
|
+
// import { MetadataAlias } from "typia/lib/schemas/metadata/MetadataAlias";
|
|
7
|
+
// import { MetadataAtomic } from "typia/lib/schemas/metadata/MetadataAtomic";
|
|
8
|
+
// import { MetadataObject } from "typia/lib/schemas/metadata/MetadataObject";
|
|
9
9
|
|
|
10
|
-
import { INestiaProject } from "../../structures/INestiaProject";
|
|
11
|
-
import { ITypedHttpRoute } from "../../structures/ITypedHttpRoute";
|
|
12
|
-
import { MapUtil } from "../../utils/MapUtil";
|
|
13
|
-
import { FilePrinter } from "./FilePrinter";
|
|
14
|
-
import { ImportDictionary } from "./ImportDictionary";
|
|
15
|
-
import { SdkTypeProgrammer } from "./SdkTypeProgrammer";
|
|
10
|
+
// import { INestiaProject } from "../../structures/INestiaProject";
|
|
11
|
+
// import { ITypedHttpRoute } from "../../structures/ITypedHttpRoute";
|
|
12
|
+
// import { MapUtil } from "../../utils/MapUtil";
|
|
13
|
+
// import { FilePrinter } from "./FilePrinter";
|
|
14
|
+
// import { ImportDictionary } from "./ImportDictionary";
|
|
15
|
+
// import { SdkTypeProgrammer } from "./SdkTypeProgrammer";
|
|
16
16
|
|
|
17
|
-
export namespace SdkHttpCloneProgrammer {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
// export namespace SdkHttpCloneProgrammer {
|
|
18
|
+
// export interface IModule {
|
|
19
|
+
// name: string;
|
|
20
|
+
// children: Map<string, IModule>;
|
|
21
|
+
// programmer:
|
|
22
|
+
// | null
|
|
23
|
+
// | ((importer: ImportDictionary) => ts.TypeAliasDeclaration);
|
|
24
|
+
// }
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
26
|
+
// export const write =
|
|
27
|
+
// (project: INestiaProject) =>
|
|
28
|
+
// (routes: ITypedHttpRoute[]): Map<string, IModule> => {
|
|
29
|
+
// const collection = new MetadataCollection({
|
|
30
|
+
// replace: MetadataCollection.replace,
|
|
31
|
+
// });
|
|
32
|
+
// for (const r of routes) {
|
|
33
|
+
// for (const p of r.parameters) {
|
|
34
|
+
// const res = MetadataFactory.analyze(project.checker)({
|
|
35
|
+
// escape: false,
|
|
36
|
+
// constant: true,
|
|
37
|
+
// absorb: false,
|
|
38
|
+
// })(collection)(p.type);
|
|
39
|
+
// if (res.success) p.metadata = res.data;
|
|
40
|
+
// }
|
|
41
|
+
// for (const e of Object.values(r.exceptions)) {
|
|
42
|
+
// const res = MetadataFactory.analyze(project.checker)({
|
|
43
|
+
// escape: true,
|
|
44
|
+
// constant: true,
|
|
45
|
+
// absorb: false,
|
|
46
|
+
// })(collection)(e.type);
|
|
47
|
+
// if (res.success) e.metadata = res.data;
|
|
48
|
+
// }
|
|
49
|
+
// const res = MetadataFactory.analyze(project.checker)({
|
|
50
|
+
// escape: true,
|
|
51
|
+
// constant: true,
|
|
52
|
+
// absorb: false,
|
|
53
|
+
// })(collection)(r.output.type);
|
|
54
|
+
// if (res.success) r.success.metadata = res.data;
|
|
55
|
+
// }
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
57
|
+
// const dict: Map<string, IModule> = new Map();
|
|
58
|
+
// for (const alias of collection.aliases())
|
|
59
|
+
// if (isNamedDeclaration(alias.name))
|
|
60
|
+
// prepare(dict)(alias.name)((importer) =>
|
|
61
|
+
// write_alias(project)(importer)(alias),
|
|
62
|
+
// );
|
|
63
|
+
// for (const object of collection.objects())
|
|
64
|
+
// if (isNamedDeclaration(object.name))
|
|
65
|
+
// prepare(dict)(object.name)((importer) =>
|
|
66
|
+
// write_object(project)(importer)(object),
|
|
67
|
+
// );
|
|
68
|
+
// return dict;
|
|
69
|
+
// };
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
71
|
+
// const prepare =
|
|
72
|
+
// (dict: Map<string, IModule>) =>
|
|
73
|
+
// (name: string) =>
|
|
74
|
+
// (programmer: (importer: ImportDictionary) => ts.TypeAliasDeclaration) => {
|
|
75
|
+
// const accessors: string[] = name.split(".");
|
|
76
|
+
// const modulo: IPointer<IModule> = { value: null! };
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
78
|
+
// accessors.forEach((acc, i) => {
|
|
79
|
+
// modulo.value = MapUtil.take(dict, acc, () => ({
|
|
80
|
+
// name: acc,
|
|
81
|
+
// children: new Map(),
|
|
82
|
+
// programmer: null,
|
|
83
|
+
// }));
|
|
84
|
+
// if (i === accessors.length - 1) modulo.value.programmer = programmer;
|
|
85
|
+
// dict = modulo.value.children;
|
|
86
|
+
// });
|
|
87
|
+
// return modulo!;
|
|
88
|
+
// };
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
90
|
+
// const write_alias =
|
|
91
|
+
// (project: INestiaProject) =>
|
|
92
|
+
// (importer: ImportDictionary) =>
|
|
93
|
+
// (alias: MetadataAlias): ts.TypeAliasDeclaration =>
|
|
94
|
+
// FilePrinter.description(
|
|
95
|
+
// ts.factory.createTypeAliasDeclaration(
|
|
96
|
+
// [ts.factory.createToken(ts.SyntaxKind.ExportKeyword)],
|
|
97
|
+
// alias.name.split(".").at(-1)!,
|
|
98
|
+
// [],
|
|
99
|
+
// SdkTypeProgrammer.write(project)(importer)(alias.value),
|
|
100
|
+
// ),
|
|
101
|
+
// writeComment([])(alias.description, alias.jsDocTags),
|
|
102
|
+
// );
|
|
103
103
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
104
|
+
// const write_object =
|
|
105
|
+
// (project: INestiaProject) =>
|
|
106
|
+
// (importer: ImportDictionary) =>
|
|
107
|
+
// (object: MetadataObject): ts.TypeAliasDeclaration => {
|
|
108
|
+
// return FilePrinter.description(
|
|
109
|
+
// ts.factory.createTypeAliasDeclaration(
|
|
110
|
+
// [ts.factory.createToken(ts.SyntaxKind.ExportKeyword)],
|
|
111
|
+
// object.name.split(".").at(-1)!,
|
|
112
|
+
// [],
|
|
113
|
+
// SdkTypeProgrammer.write_object(project)(importer)(object),
|
|
114
|
+
// ),
|
|
115
|
+
// writeComment([])(object.description ?? null, object.jsDocTags),
|
|
116
|
+
// );
|
|
117
|
+
// };
|
|
118
|
+
// }
|
|
119
119
|
|
|
120
|
-
const isNamedDeclaration = (name: string) =>
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
120
|
+
// const isNamedDeclaration = (name: string) =>
|
|
121
|
+
// name !== "object" &&
|
|
122
|
+
// name !== "__type" &&
|
|
123
|
+
// !name.startsWith("__type.") &&
|
|
124
|
+
// name !== "__object" &&
|
|
125
|
+
// !name.startsWith("__object.");
|
|
126
126
|
|
|
127
|
-
const writeComment =
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
127
|
+
// const writeComment =
|
|
128
|
+
// (atomics: MetadataAtomic[]) =>
|
|
129
|
+
// (description: string | null, jsDocTags: IJsDocTagInfo[]): string => {
|
|
130
|
+
// const lines: string[] = [];
|
|
131
|
+
// if (description?.length)
|
|
132
|
+
// lines.push(...description.split("\n").map((s) => `${s}`));
|
|
133
133
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
134
|
+
// const filtered: IJsDocTagInfo[] =
|
|
135
|
+
// !!atomics.length && !!jsDocTags?.length
|
|
136
|
+
// ? jsDocTags.filter(
|
|
137
|
+
// (tag) =>
|
|
138
|
+
// !atomics.some((a) =>
|
|
139
|
+
// a.tags.some((r) => r.some((t) => t.kind === tag.name)),
|
|
140
|
+
// ),
|
|
141
|
+
// )
|
|
142
|
+
// : jsDocTags ?? [];
|
|
143
143
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
144
|
+
// if (description?.length && filtered.length) lines.push("");
|
|
145
|
+
// if (filtered.length)
|
|
146
|
+
// lines.push(
|
|
147
|
+
// ...filtered.map((t) =>
|
|
148
|
+
// t.text?.length
|
|
149
|
+
// ? `@${t.name} ${t.text.map((e) => e.text).join("")}`
|
|
150
|
+
// : `@${t.name}`,
|
|
151
|
+
// ),
|
|
152
|
+
// );
|
|
153
|
+
// return lines.join("\n");
|
|
154
|
+
// };
|