@nestia/sdk 11.2.1 → 12.0.0-dev.20260521.1
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/assets/bundle/distribute/package.json +1 -1
- package/lib/NestiaSdkApplication.js +5 -4
- package/lib/NestiaSdkApplication.js.map +1 -1
- package/lib/NestiaSwaggerComposer.js +2 -2
- package/lib/NestiaSwaggerComposer.js.map +1 -1
- package/lib/analyses/AccessorAnalyzer.js.map +1 -1
- package/lib/analyses/ConfigAnalyzer.js +133 -7
- package/lib/analyses/ConfigAnalyzer.js.map +1 -1
- package/lib/analyses/ImportAnalyzer.d.ts +9 -2
- package/lib/analyses/ImportAnalyzer.js +13 -50
- package/lib/analyses/ImportAnalyzer.js.map +1 -1
- package/lib/analyses/PathAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectControllerAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationAnalyzer.d.ts +1 -1
- package/lib/analyses/ReflectHttpOperationAnalyzer.js +5 -4
- package/lib/analyses/ReflectHttpOperationAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationExceptionAnalyzer.d.ts +1 -1
- package/lib/analyses/ReflectHttpOperationExceptionAnalyzer.js +22 -5
- package/lib/analyses/ReflectHttpOperationExceptionAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationParameterAnalyzer.d.ts +1 -1
- package/lib/analyses/ReflectHttpOperationParameterAnalyzer.js +8 -8
- package/lib/analyses/ReflectHttpOperationParameterAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.d.ts +1 -1
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.js +15 -15
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectMetadataAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectWebSocketOperationAnalyzer.d.ts +1 -1
- package/lib/analyses/ReflectWebSocketOperationAnalyzer.js +1 -1
- package/lib/analyses/ReflectWebSocketOperationAnalyzer.js.map +1 -1
- package/lib/analyses/SecurityAnalyzer.js.map +1 -1
- package/lib/analyses/TypedHttpRouteAnalyzer.d.ts +2 -1
- package/lib/analyses/TypedHttpRouteAnalyzer.js +296 -39
- package/lib/analyses/TypedHttpRouteAnalyzer.js.map +1 -1
- package/lib/analyses/TypedWebSocketRouteAnalyzer.js +1 -4
- package/lib/analyses/TypedWebSocketRouteAnalyzer.js.map +1 -1
- package/lib/decorators/OperationMetadata.d.ts +12 -2
- package/lib/decorators/OperationMetadata.js +14 -1
- package/lib/decorators/OperationMetadata.js.map +1 -1
- package/lib/executable/internal/CommandParser.js.map +1 -1
- package/lib/executable/internal/NestiaConfigLoader.d.ts +6 -2
- package/lib/executable/internal/NestiaConfigLoader.js +285 -793
- package/lib/executable/internal/NestiaConfigLoader.js.map +1 -1
- package/lib/executable/internal/NestiaSdkCommand.js +6 -4
- package/lib/executable/internal/NestiaSdkCommand.js.map +1 -1
- package/lib/executable/sdk.js +17 -5
- package/lib/executable/sdk.js.map +1 -1
- package/lib/generates/CloneGenerator.js +2 -2
- package/lib/generates/CloneGenerator.js.map +1 -1
- package/lib/generates/E2eGenerator.js.map +1 -1
- package/lib/generates/SdkGenerator.js +6 -9
- package/lib/generates/SdkGenerator.js.map +1 -1
- package/lib/generates/SwaggerGenerator.js +20 -107
- package/lib/generates/SwaggerGenerator.js.map +1 -1
- package/lib/generates/internal/E2eFileProgrammer.js +44 -28
- package/lib/generates/internal/E2eFileProgrammer.js.map +1 -1
- package/lib/generates/internal/FilePrinter.d.ts +4 -4
- package/lib/generates/internal/FilePrinter.js +25 -16
- package/lib/generates/internal/FilePrinter.js.map +1 -1
- package/lib/generates/internal/ImportDictionary.d.ts +2 -2
- package/lib/generates/internal/ImportDictionary.js +7 -5
- package/lib/generates/internal/ImportDictionary.js.map +1 -1
- package/lib/generates/internal/SdkAliasCollection.d.ts +11 -11
- package/lib/generates/internal/SdkAliasCollection.js +27 -31
- package/lib/generates/internal/SdkAliasCollection.js.map +1 -1
- package/lib/generates/internal/SdkDistributionComposer.js +15 -70
- package/lib/generates/internal/SdkDistributionComposer.js.map +1 -1
- package/lib/generates/internal/SdkFileProgrammer.js +2 -2
- package/lib/generates/internal/SdkFileProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpCloneProgrammer.d.ts +2 -2
- package/lib/generates/internal/SdkHttpCloneProgrammer.js +6 -12
- package/lib/generates/internal/SdkHttpCloneProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpCloneReferencer.js +2 -1
- package/lib/generates/internal/SdkHttpCloneReferencer.js.map +1 -1
- package/lib/generates/internal/SdkHttpFunctionProgrammer.d.ts +2 -2
- package/lib/generates/internal/SdkHttpFunctionProgrammer.js +73 -77
- package/lib/generates/internal/SdkHttpFunctionProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.d.ts +2 -2
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.js +64 -66
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpParameterProgrammer.d.ts +4 -10
- package/lib/generates/internal/SdkHttpParameterProgrammer.js +15 -22
- package/lib/generates/internal/SdkHttpParameterProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpRouteProgrammer.d.ts +2 -2
- package/lib/generates/internal/SdkHttpRouteProgrammer.js +18 -20
- package/lib/generates/internal/SdkHttpRouteProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpSimulationProgrammer.d.ts +3 -3
- package/lib/generates/internal/SdkHttpSimulationProgrammer.js +47 -49
- package/lib/generates/internal/SdkHttpSimulationProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkImportWizard.js.map +1 -1
- package/lib/generates/internal/SdkRouteDirectory.js.map +1 -1
- package/lib/generates/internal/SdkTypeProgrammer.d.ts +4 -4
- package/lib/generates/internal/SdkTypeProgrammer.js +66 -67
- package/lib/generates/internal/SdkTypeProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkTypeTagProgrammer.d.ts +1 -2
- package/lib/generates/internal/SdkTypeTagProgrammer.js +29 -11
- package/lib/generates/internal/SdkTypeTagProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.d.ts +2 -2
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js +55 -55
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketParameterProgrammer.d.ts +3 -3
- package/lib/generates/internal/SdkWebSocketParameterProgrammer.js +9 -12
- package/lib/generates/internal/SdkWebSocketParameterProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.d.ts +2 -2
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.js +43 -45
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.js.map +1 -1
- package/lib/generates/internal/SwaggerDescriptionComposer.js.map +1 -1
- package/lib/generates/internal/SwaggerOperationComposer.d.ts +1 -1
- package/lib/generates/internal/SwaggerOperationComposer.js +5 -4
- package/lib/generates/internal/SwaggerOperationComposer.js.map +1 -1
- package/lib/generates/internal/SwaggerOperationParameterComposer.d.ts +0 -3
- package/lib/generates/internal/SwaggerOperationParameterComposer.js +19 -20
- package/lib/generates/internal/SwaggerOperationParameterComposer.js.map +1 -1
- package/lib/generates/internal/SwaggerOperationResponseComposer.d.ts +1 -1
- package/lib/generates/internal/SwaggerOperationResponseComposer.js +4 -3
- package/lib/generates/internal/SwaggerOperationResponseComposer.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/internal/legacy.d.ts +180 -0
- package/lib/internal/legacy.js +361 -0
- package/lib/internal/legacy.js.map +1 -0
- package/lib/structures/INestiaProject.d.ts +0 -2
- package/lib/{transformers → structures}/IOperationMetadata.d.ts +2 -7
- package/lib/structures/IOperationMetadata.js.map +1 -0
- package/lib/structures/IReflectHttpOperationException.d.ts +1 -1
- package/lib/structures/IReflectHttpOperationParameter.d.ts +1 -1
- package/lib/structures/IReflectHttpOperationSuccess.d.ts +1 -1
- package/lib/structures/IReflectOperationError.d.ts +1 -1
- package/lib/structures/IReflectOperationError.js.map +1 -1
- package/lib/structures/IReflectWebSocketOperation.d.ts +2 -2
- package/lib/structures/ITypedApplication.d.ts +1 -1
- package/lib/structures/ITypedHttpRouteException.d.ts +1 -1
- package/lib/structures/ITypedHttpRouteParameter.d.ts +1 -1
- package/lib/structures/ITypedHttpRouteSuccess.d.ts +1 -1
- package/lib/structures/ITypedWebSocketRoute.d.ts +2 -2
- package/lib/transform.d.ts +16 -3
- package/lib/transform.js +47 -5
- package/lib/transform.js.map +1 -1
- package/lib/utils/ArrayUtil.js.map +1 -1
- package/lib/utils/FileRetriever.js.map +1 -1
- package/lib/utils/MapUtil.js.map +1 -1
- package/lib/utils/PathUtil.js.map +1 -1
- package/lib/utils/SourceFinder.js.map +1 -1
- package/lib/utils/StringUtil.js.map +1 -1
- package/lib/utils/TsConfigReader.d.ts +7 -0
- package/lib/utils/TsConfigReader.js +102 -0
- package/lib/utils/TsConfigReader.js.map +1 -0
- package/lib/utils/TtscExecutor.d.ts +8 -0
- package/lib/utils/TtscExecutor.js +58 -0
- package/lib/utils/TtscExecutor.js.map +1 -0
- package/lib/utils/VersioningStrategy.js.map +1 -1
- package/lib/validators/HttpHeadersValidator.d.ts +8 -5
- package/lib/validators/HttpHeadersValidator.js +7 -26
- package/lib/validators/HttpHeadersValidator.js.map +1 -1
- package/lib/validators/HttpQueryValidator.d.ts +8 -5
- package/lib/validators/HttpQueryValidator.js +7 -26
- package/lib/validators/HttpQueryValidator.js.map +1 -1
- package/lib/{transformers → validators}/TextPlainValidator.d.ts +1 -1
- package/lib/{transformers → validators}/TextPlainValidator.js +2 -1
- package/lib/validators/TextPlainValidator.js.map +1 -0
- package/native/go.mod +52 -0
- package/native/go.sum +54 -0
- package/native/sdk/register.go +130 -0
- package/native/sdk/sdk.go +17 -0
- package/native/sdk/sdk_metadata_json.go +327 -0
- package/native/sdk/sdk_transform.go +1542 -0
- package/package.json +19 -19
- package/src/NestiaSdkApplication.ts +9 -5
- package/src/NestiaSwaggerComposer.ts +2 -3
- package/src/analyses/ConfigAnalyzer.ts +175 -1
- package/src/analyses/ImportAnalyzer.ts +15 -49
- package/src/analyses/ReflectControllerAnalyzer.ts +1 -1
- package/src/analyses/ReflectHttpOperationAnalyzer.ts +1 -1
- package/src/analyses/ReflectHttpOperationExceptionAnalyzer.ts +24 -6
- package/src/analyses/ReflectHttpOperationParameterAnalyzer.ts +3 -3
- package/src/analyses/ReflectHttpOperationResponseAnalyzer.ts +14 -10
- package/src/analyses/ReflectWebSocketOperationAnalyzer.ts +2 -2
- package/src/analyses/TypedHttpRouteAnalyzer.ts +354 -22
- package/src/decorators/OperationMetadata.ts +17 -3
- package/src/executable/internal/NestiaConfigLoader.ts +419 -53
- package/src/executable/internal/NestiaSdkCommand.ts +9 -10
- package/src/executable/sdk.ts +15 -4
- package/src/generates/CloneGenerator.ts +10 -10
- package/src/generates/SwaggerGenerator.ts +28 -9
- package/src/generates/internal/E2eFileProgrammer.ts +80 -43
- package/src/generates/internal/FilePrinter.ts +38 -37
- package/src/generates/internal/ImportDictionary.ts +18 -16
- package/src/generates/internal/SdkAliasCollection.ts +41 -40
- package/src/generates/internal/SdkDistributionComposer.ts +21 -8
- package/src/generates/internal/SdkFileProgrammer.ts +7 -5
- package/src/generates/internal/SdkHttpCloneProgrammer.ts +10 -10
- package/src/generates/internal/SdkHttpCloneReferencer.ts +6 -6
- package/src/generates/internal/SdkHttpFunctionProgrammer.ts +101 -78
- package/src/generates/internal/SdkHttpNamespaceProgrammer.ts +153 -145
- package/src/generates/internal/SdkHttpParameterProgrammer.ts +20 -33
- package/src/generates/internal/SdkHttpRouteProgrammer.ts +2 -2
- package/src/generates/internal/SdkHttpSimulationProgrammer.ts +88 -86
- package/src/generates/internal/SdkTypeProgrammer.ts +93 -99
- package/src/generates/internal/SdkTypeTagProgrammer.ts +12 -12
- package/src/generates/internal/SdkWebSocketNamespaceProgrammer.ts +128 -118
- package/src/generates/internal/SdkWebSocketParameterProgrammer.ts +15 -13
- package/src/generates/internal/SdkWebSocketRouteProgrammer.ts +133 -112
- package/src/generates/internal/SwaggerOperationComposer.ts +1 -1
- package/src/generates/internal/SwaggerOperationParameterComposer.ts +10 -9
- package/src/generates/internal/SwaggerOperationResponseComposer.ts +1 -1
- package/src/internal/legacy.ts +492 -0
- package/src/structures/INestiaProject.ts +0 -3
- package/src/{transformers → structures}/IOperationMetadata.ts +2 -7
- package/src/structures/IReflectHttpOperationException.ts +1 -1
- package/src/structures/IReflectHttpOperationParameter.ts +1 -1
- package/src/structures/IReflectHttpOperationSuccess.ts +1 -1
- package/src/structures/IReflectOperationError.ts +1 -1
- package/src/structures/IReflectWebSocketOperation.ts +2 -2
- package/src/structures/ITypedApplication.ts +1 -1
- package/src/structures/ITypedHttpRouteException.ts +1 -1
- package/src/structures/ITypedHttpRouteParameter.ts +1 -1
- package/src/structures/ITypedHttpRouteSuccess.ts +1 -1
- package/src/structures/ITypedWebSocketRoute.ts +2 -2
- package/src/transform.ts +57 -7
- package/src/utils/TsConfigReader.ts +108 -0
- package/src/utils/TtscExecutor.ts +63 -0
- package/src/validators/HttpHeadersValidator.ts +8 -37
- package/src/validators/HttpQueryValidator.ts +8 -37
- package/src/{transformers → validators}/TextPlainValidator.ts +2 -2
- package/lib/analyses/DtoAnalyzer.d.ts +0 -21
- package/lib/analyses/DtoAnalyzer.js +0 -219
- package/lib/analyses/DtoAnalyzer.js.map +0 -1
- package/lib/analyses/ExceptionAnalyzer.d.ts +0 -0
- package/lib/analyses/ExceptionAnalyzer.js +0 -2
- package/lib/analyses/ExceptionAnalyzer.js.map +0 -1
- package/lib/analyses/GenericAnalyzer.d.ts +0 -4
- package/lib/analyses/GenericAnalyzer.js +0 -42
- package/lib/analyses/GenericAnalyzer.js.map +0 -1
- package/lib/structures/IReflectApplication.d.ts +0 -6
- package/lib/structures/IReflectApplication.js +0 -3
- package/lib/structures/IReflectApplication.js.map +0 -1
- package/lib/structures/MethodType.d.ts +0 -4
- package/lib/structures/MethodType.js +0 -8
- package/lib/structures/MethodType.js.map +0 -1
- package/lib/structures/ParamCategory.d.ts +0 -1
- package/lib/structures/ParamCategory.js +0 -3
- package/lib/structures/ParamCategory.js.map +0 -1
- package/lib/structures/TypeEntry.d.ts +0 -9
- package/lib/structures/TypeEntry.js +0 -21
- package/lib/structures/TypeEntry.js.map +0 -1
- package/lib/transformers/IOperationMetadata.js.map +0 -1
- package/lib/transformers/ISdkOperationTransformerContext.d.ts +0 -7
- package/lib/transformers/ISdkOperationTransformerContext.js +0 -3
- package/lib/transformers/ISdkOperationTransformerContext.js.map +0 -1
- package/lib/transformers/SdkOperationProgrammer.d.ts +0 -15
- package/lib/transformers/SdkOperationProgrammer.js +0 -186
- package/lib/transformers/SdkOperationProgrammer.js.map +0 -1
- package/lib/transformers/SdkOperationTransformer.d.ts +0 -4
- package/lib/transformers/SdkOperationTransformer.js +0 -128
- package/lib/transformers/SdkOperationTransformer.js.map +0 -1
- package/lib/transformers/TextPlainValidator.js.map +0 -1
- package/lib/utils/MetadataUtil.d.ts +0 -4
- package/lib/utils/MetadataUtil.js +0 -34
- package/lib/utils/MetadataUtil.js.map +0 -1
- package/lib/utils/StripEnums.d.ts +0 -3
- package/lib/utils/StripEnums.js +0 -3
- package/lib/utils/StripEnums.js.map +0 -1
- package/lib/utils/TypeLiteralExpression.d.ts +0 -0
- package/lib/utils/TypeLiteralExpression.js +0 -2
- package/lib/utils/TypeLiteralExpression.js.map +0 -1
- package/src/analyses/DtoAnalyzer.ts +0 -260
- package/src/analyses/ExceptionAnalyzer.ts +0 -154
- package/src/analyses/GenericAnalyzer.ts +0 -49
- package/src/structures/IReflectApplication.ts +0 -8
- package/src/structures/MethodType.ts +0 -5
- package/src/structures/ParamCategory.ts +0 -1
- package/src/structures/TypeEntry.ts +0 -22
- package/src/transformers/ISdkOperationTransformerContext.ts +0 -8
- package/src/transformers/SdkOperationProgrammer.ts +0 -240
- package/src/transformers/SdkOperationTransformer.ts +0 -248
- package/src/utils/MetadataUtil.ts +0 -26
- package/src/utils/StripEnums.ts +0 -5
- package/src/utils/TypeLiteralExpression.ts +0 -0
- /package/lib/{transformers → structures}/IOperationMetadata.js +0 -0
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestia/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.0-dev.20260521.1",
|
|
4
4
|
"description": "Nestia SDK and Swagger generator",
|
|
5
|
+
"types": "lib/index.d.ts",
|
|
5
6
|
"main": "lib/index.js",
|
|
6
7
|
"exports": {
|
|
7
8
|
".": {
|
|
@@ -45,37 +46,36 @@
|
|
|
45
46
|
},
|
|
46
47
|
"homepage": "https://nestia.io",
|
|
47
48
|
"dependencies": {
|
|
48
|
-
"@typia/
|
|
49
|
-
"@typia/
|
|
50
|
-
"@typia/utils": "12.1.0",
|
|
51
|
-
"cli": "^1.0.1",
|
|
49
|
+
"@typia/interface": "13.0.0-dev.20260521.1",
|
|
50
|
+
"@typia/utils": "13.0.0-dev.20260521.1",
|
|
52
51
|
"get-function-location": "^2.0.0",
|
|
53
52
|
"glob": "^11.0.3",
|
|
54
53
|
"path-to-regexp": "^6.2.1",
|
|
55
54
|
"prettier": "^3.8.1",
|
|
56
|
-
"
|
|
57
|
-
"tsconfck": "^2.1.2",
|
|
58
|
-
"tsconfig-paths": "^4.1.1",
|
|
55
|
+
"ttsc": "^0.12.3",
|
|
59
56
|
"tstl": "^3.0.0",
|
|
60
|
-
"typia": "
|
|
61
|
-
"@nestia/core": "^
|
|
62
|
-
"@nestia/
|
|
57
|
+
"typia": "13.0.0-dev.20260521.1",
|
|
58
|
+
"@nestia/core": "^12.0.0-dev.20260521.1",
|
|
59
|
+
"@nestia/factory": "^12.0.0-dev.20260521.1",
|
|
60
|
+
"@nestia/fetcher": "^12.0.0-dev.20260521.1"
|
|
63
61
|
},
|
|
64
62
|
"peerDependencies": {
|
|
65
|
-
"@nestia/core": "^
|
|
63
|
+
"@nestia/core": "^12.0.0-dev.20260521.1"
|
|
66
64
|
},
|
|
67
65
|
"devDependencies": {
|
|
68
66
|
"@nestjs/common": "^11.1.6",
|
|
69
67
|
"@nestjs/core": "^11.1.6",
|
|
70
|
-
"@
|
|
68
|
+
"@typescript/native-preview": "7.0.0-dev.20260518.1",
|
|
71
69
|
"@types/express": "^4.17.15",
|
|
72
70
|
"@types/node": "^25.3.3",
|
|
73
|
-
"rimraf": "^6.1.3"
|
|
74
|
-
"typescript": "~6.0.3"
|
|
71
|
+
"rimraf": "^6.1.3"
|
|
75
72
|
},
|
|
76
73
|
"files": [
|
|
77
74
|
"assets",
|
|
78
75
|
"lib",
|
|
76
|
+
"native/go.mod",
|
|
77
|
+
"native/go.sum",
|
|
78
|
+
"native/sdk",
|
|
79
79
|
"src",
|
|
80
80
|
"README.md",
|
|
81
81
|
"LICENSE",
|
|
@@ -85,8 +85,8 @@
|
|
|
85
85
|
"access": "public"
|
|
86
86
|
},
|
|
87
87
|
"scripts": {
|
|
88
|
-
"build": "rimraf lib &&
|
|
89
|
-
"dev": "
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
"build": "rimraf lib && ttsc",
|
|
89
|
+
"dev": "ttsc --watch",
|
|
90
|
+
"test:go": "cd test && go test ./..."
|
|
91
|
+
}
|
|
92
92
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IMetadataDictionary } from "
|
|
1
|
+
import { IMetadataDictionary } from "./internal/legacy";
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import { HashSet, Pair, TreeMap } from "tstl";
|
|
@@ -19,7 +19,7 @@ import { IReflectOperationError } from "./structures/IReflectOperationError";
|
|
|
19
19
|
import { ITypedApplication } from "./structures/ITypedApplication";
|
|
20
20
|
import { ITypedHttpRoute } from "./structures/ITypedHttpRoute";
|
|
21
21
|
import { ITypedWebSocketRoute } from "./structures/ITypedWebSocketRoute";
|
|
22
|
-
import { IOperationMetadata } from "./
|
|
22
|
+
import { IOperationMetadata } from "./structures/IOperationMetadata";
|
|
23
23
|
import { StringUtil } from "./utils/StringUtil";
|
|
24
24
|
import { VersioningStrategy } from "./utils/VersioningStrategy";
|
|
25
25
|
|
|
@@ -135,7 +135,6 @@ export class NestiaSdkApplication {
|
|
|
135
135
|
const project: INestiaProject = {
|
|
136
136
|
config: this.config,
|
|
137
137
|
input: await ConfigAnalyzer.input(this.config),
|
|
138
|
-
checker: null!,
|
|
139
138
|
errors: [],
|
|
140
139
|
warnings: [],
|
|
141
140
|
};
|
|
@@ -191,7 +190,7 @@ export class NestiaSdkApplication {
|
|
|
191
190
|
console.log("Analyzing source codes");
|
|
192
191
|
|
|
193
192
|
// METADATA COMPONENTS
|
|
194
|
-
const
|
|
193
|
+
const sourceCollection: IMetadataDictionary =
|
|
195
194
|
TypedHttpRouteAnalyzer.dictionary(controllers);
|
|
196
195
|
|
|
197
196
|
// CONVERT TO TYPED OPERATIONS
|
|
@@ -216,7 +215,7 @@ export class NestiaSdkApplication {
|
|
|
216
215
|
...TypedHttpRouteAnalyzer.analyze({
|
|
217
216
|
controller: c,
|
|
218
217
|
errors: project.errors,
|
|
219
|
-
dictionary:
|
|
218
|
+
dictionary: sourceCollection,
|
|
220
219
|
operation: o,
|
|
221
220
|
paths: Array.from(pathList),
|
|
222
221
|
}),
|
|
@@ -232,6 +231,11 @@ export class NestiaSdkApplication {
|
|
|
232
231
|
}
|
|
233
232
|
AccessorAnalyzer.analyze(routes);
|
|
234
233
|
|
|
234
|
+
const collection: IMetadataDictionary =
|
|
235
|
+
TypedHttpRouteAnalyzer.routeDictionary(
|
|
236
|
+
routes.filter((r): r is ITypedHttpRoute => r.protocol === "http"),
|
|
237
|
+
);
|
|
238
|
+
|
|
235
239
|
if (props.validate !== undefined)
|
|
236
240
|
project.errors.push(
|
|
237
241
|
...props.validate({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { INestApplication } from "@nestjs/common";
|
|
2
|
-
import { IMetadataDictionary } from "
|
|
2
|
+
import { IMetadataDictionary } from "./internal/legacy";
|
|
3
3
|
import { OpenApiV3, OpenApiV3_1, SwaggerV2 } from "@typia/interface";
|
|
4
4
|
import { OpenApiConverter } from "@typia/utils";
|
|
5
5
|
import path from "path";
|
|
@@ -18,7 +18,7 @@ import { INestiaSdkInput } from "./structures/INestiaSdkInput";
|
|
|
18
18
|
import { IReflectController } from "./structures/IReflectController";
|
|
19
19
|
import { IReflectOperationError } from "./structures/IReflectOperationError";
|
|
20
20
|
import { ITypedHttpRoute } from "./structures/ITypedHttpRoute";
|
|
21
|
-
import { IOperationMetadata } from "./
|
|
21
|
+
import { IOperationMetadata } from "./structures/IOperationMetadata";
|
|
22
22
|
import { VersioningStrategy } from "./utils/VersioningStrategy";
|
|
23
23
|
|
|
24
24
|
export namespace NestiaSwaggerComposer {
|
|
@@ -47,7 +47,6 @@ export namespace NestiaSwaggerComposer {
|
|
|
47
47
|
const unique: WeakSet<any> = new WeakSet();
|
|
48
48
|
const project: Omit<INestiaProject, "config"> = {
|
|
49
49
|
input,
|
|
50
|
-
checker: null!,
|
|
51
50
|
errors: [],
|
|
52
51
|
warnings: [],
|
|
53
52
|
};
|
|
@@ -14,6 +14,8 @@ import { INestiaSdkInput } from "../structures/INestiaSdkInput";
|
|
|
14
14
|
import { ArrayUtil } from "../utils/ArrayUtil";
|
|
15
15
|
import { MapUtil } from "../utils/MapUtil";
|
|
16
16
|
import { SourceFinder } from "../utils/SourceFinder";
|
|
17
|
+
import { TsConfigReader } from "../utils/TsConfigReader";
|
|
18
|
+
import { TtscExecutor } from "../utils/TtscExecutor";
|
|
17
19
|
|
|
18
20
|
export namespace ConfigAnalyzer {
|
|
19
21
|
export const input = async (
|
|
@@ -35,9 +37,10 @@ export namespace ConfigAnalyzer {
|
|
|
35
37
|
: [],
|
|
36
38
|
filter: filter(config),
|
|
37
39
|
});
|
|
40
|
+
const runtime: RuntimeCompiler = await RuntimeCompiler.compile(sources);
|
|
38
41
|
const controllers: INestiaSdkInput.IController[] = [];
|
|
39
42
|
for (const file of sources) {
|
|
40
|
-
const external: any[] = await import(file);
|
|
43
|
+
const external: any[] = await import(runtime.output(file));
|
|
41
44
|
for (const key in external) {
|
|
42
45
|
const instance: Function = external[key];
|
|
43
46
|
if (Reflect.getMetadata("path", instance) !== undefined)
|
|
@@ -113,6 +116,177 @@ export namespace ConfigAnalyzer {
|
|
|
113
116
|
};
|
|
114
117
|
}
|
|
115
118
|
const memory = new Map<INestiaConfig, Promise<INestiaSdkInput>>();
|
|
119
|
+
class RuntimeCompiler {
|
|
120
|
+
private constructor(
|
|
121
|
+
private readonly cwd: string,
|
|
122
|
+
private readonly outDir: string,
|
|
123
|
+
) {}
|
|
124
|
+
|
|
125
|
+
public static async compile(sources: string[]): Promise<RuntimeCompiler> {
|
|
126
|
+
const cwd: string = process.cwd();
|
|
127
|
+
const runtimeRoot: string = path.join(
|
|
128
|
+
cwd,
|
|
129
|
+
"node_modules",
|
|
130
|
+
".nestia",
|
|
131
|
+
"runtime",
|
|
132
|
+
);
|
|
133
|
+
await fs.promises.mkdir(runtimeRoot, { recursive: true });
|
|
134
|
+
ensureRuntimeCleanup(runtimeRoot);
|
|
135
|
+
const outDir: string = await fs.promises.mkdtemp(
|
|
136
|
+
path.join(runtimeRoot, "run-"),
|
|
137
|
+
);
|
|
138
|
+
const project: string = path.join(
|
|
139
|
+
cwd,
|
|
140
|
+
`.nestia.runtime.${process.pid}.${Date.now()}.json`,
|
|
141
|
+
);
|
|
142
|
+
const relative = (file: string): string =>
|
|
143
|
+
path.relative(cwd, file).split("\\").join("/");
|
|
144
|
+
await fs.promises.writeFile(
|
|
145
|
+
project,
|
|
146
|
+
JSON.stringify(
|
|
147
|
+
{
|
|
148
|
+
extends: normalizeProjectPath(process.env.NESTIA_PROJECT),
|
|
149
|
+
compilerOptions: {
|
|
150
|
+
noEmit: false,
|
|
151
|
+
noUnusedLocals: false,
|
|
152
|
+
noUnusedParameters: false,
|
|
153
|
+
outDir,
|
|
154
|
+
plugins: await runtimePlugins(cwd),
|
|
155
|
+
rootDir: ".",
|
|
156
|
+
},
|
|
157
|
+
include: sources.map(relative),
|
|
158
|
+
},
|
|
159
|
+
null,
|
|
160
|
+
2,
|
|
161
|
+
),
|
|
162
|
+
"utf8",
|
|
163
|
+
);
|
|
164
|
+
try {
|
|
165
|
+
TtscExecutor.run({
|
|
166
|
+
cwd,
|
|
167
|
+
project,
|
|
168
|
+
});
|
|
169
|
+
} catch (error) {
|
|
170
|
+
const output =
|
|
171
|
+
error instanceof Error && "stderr" in error
|
|
172
|
+
? String((error as Error & { stderr?: Buffer }).stderr ?? "")
|
|
173
|
+
: "";
|
|
174
|
+
throw new Error(output || `Failed to compile Nestia runtime inputs.`);
|
|
175
|
+
} finally {
|
|
176
|
+
await fs.promises.rm(project, { force: true });
|
|
177
|
+
}
|
|
178
|
+
return new RuntimeCompiler(cwd, outDir);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
public output(source: string): string {
|
|
182
|
+
const relative: string = path.relative(this.cwd, source);
|
|
183
|
+
const emitted: string = path.join(
|
|
184
|
+
this.outDir,
|
|
185
|
+
replaceExtension(relative, ".js"),
|
|
186
|
+
);
|
|
187
|
+
return emitted;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const RUNTIME_ROOTS: Set<string> = new Set();
|
|
192
|
+
let RUNTIME_CLEANUP_REGISTERED: boolean = false;
|
|
193
|
+
|
|
194
|
+
const ensureRuntimeCleanup = (runtimeRoot: string): void => {
|
|
195
|
+
RUNTIME_ROOTS.add(runtimeRoot);
|
|
196
|
+
if (RUNTIME_CLEANUP_REGISTERED === true) return;
|
|
197
|
+
RUNTIME_CLEANUP_REGISTERED = true;
|
|
198
|
+
const sweep = (): void => {
|
|
199
|
+
for (const location of RUNTIME_ROOTS)
|
|
200
|
+
fs.rmSync(location, { force: true, recursive: true });
|
|
201
|
+
};
|
|
202
|
+
process.once("exit", sweep);
|
|
203
|
+
// process.once("exit", …) does not fire on SIGINT/SIGTERM. Without these
|
|
204
|
+
// handlers a Ctrl-C during codegen leaves `run-*` mkdtemp directories
|
|
205
|
+
// behind under node_modules/.nestia/runtime/ until a subsequent clean exit.
|
|
206
|
+
// The module-level RUNTIME_CLEANUP_REGISTERED flag above guards against
|
|
207
|
+
// re-entrancy within this module; we deliberately do NOT gate on
|
|
208
|
+
// `process.listenerCount(signal) > 0` because NestiaConfigLoader's parallel
|
|
209
|
+
// sweep registers first, and that gate would skip our registration —
|
|
210
|
+
// leaving RUNTIME_ROOTS unswept on Ctrl-C while config-loader cleans up.
|
|
211
|
+
// Windows note: `process.kill(pid, "SIGINT")` calls TerminateProcess
|
|
212
|
+
// rather than re-raising through the listener queue, so the handler
|
|
213
|
+
// cascade documented above only holds on POSIX. On Windows, whichever
|
|
214
|
+
// module registers FIRST runs its sweep and the second is skipped —
|
|
215
|
+
// RUNTIME_ROOTS cleanup is best-effort there. SIGHUP is a no-op for
|
|
216
|
+
// most common code paths on Windows (Node fires it on console-close
|
|
217
|
+
// and exits within seconds).
|
|
218
|
+
const onSignal = (signal: NodeJS.Signals): void => {
|
|
219
|
+
sweep();
|
|
220
|
+
process.kill(process.pid, signal);
|
|
221
|
+
};
|
|
222
|
+
for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"] as const) {
|
|
223
|
+
process.once(signal, onSignal);
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
type RuntimePlugin = Record<string, unknown> & { transform?: unknown };
|
|
228
|
+
|
|
229
|
+
const runtimePlugins = async (cwd: string): Promise<RuntimePlugin[]> => {
|
|
230
|
+
const plugins: RuntimePlugin[] = await readProjectPlugins(cwd);
|
|
231
|
+
const typia: RuntimePlugin | undefined = plugins.find((p) =>
|
|
232
|
+
isTransform(p, "typia"),
|
|
233
|
+
);
|
|
234
|
+
const sdk: RuntimePlugin | undefined = plugins.find((p) =>
|
|
235
|
+
isTransform(p, "@nestia/sdk"),
|
|
236
|
+
);
|
|
237
|
+
const core: RuntimePlugin | undefined = plugins.find((p) =>
|
|
238
|
+
isTransform(p, "@nestia/core"),
|
|
239
|
+
);
|
|
240
|
+
return [
|
|
241
|
+
{
|
|
242
|
+
...(typia ?? {}),
|
|
243
|
+
transform: "typia/lib/transform",
|
|
244
|
+
enabled: false,
|
|
245
|
+
},
|
|
246
|
+
normalizeRuntimePlugin({
|
|
247
|
+
...(sdk ?? {}),
|
|
248
|
+
transform: "@nestia/sdk/lib/transform",
|
|
249
|
+
}),
|
|
250
|
+
normalizeRuntimePlugin({
|
|
251
|
+
...(core ?? {}),
|
|
252
|
+
transform: "@nestia/core/native/transform.cjs",
|
|
253
|
+
}),
|
|
254
|
+
];
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
const readProjectPlugins = async (cwd: string): Promise<RuntimePlugin[]> => {
|
|
258
|
+
const project: string = normalizeProjectPath(process.env.NESTIA_PROJECT);
|
|
259
|
+
const file: string = path.isAbsolute(project)
|
|
260
|
+
? project
|
|
261
|
+
: path.join(cwd, project);
|
|
262
|
+
const config = await TsConfigReader.read(file);
|
|
263
|
+
const options = config.compilerOptions as
|
|
264
|
+
| { plugins?: RuntimePlugin[] }
|
|
265
|
+
| undefined;
|
|
266
|
+
return Array.isArray(options?.plugins)
|
|
267
|
+
? options.plugins
|
|
268
|
+
.filter((p) => typeof p === "object" && p !== null)
|
|
269
|
+
.map((p) => ({ ...(p as unknown as RuntimePlugin) }))
|
|
270
|
+
: [];
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
const normalizeRuntimePlugin = (plugin: RuntimePlugin): RuntimePlugin => {
|
|
274
|
+
const output: RuntimePlugin = { ...plugin };
|
|
275
|
+
if (output.enabled === false) delete output.enabled;
|
|
276
|
+
return output;
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
const isTransform = (plugin: RuntimePlugin, name: string): boolean =>
|
|
280
|
+
typeof plugin.transform === "string" && plugin.transform.includes(name);
|
|
281
|
+
|
|
282
|
+
const replaceExtension = (file: string, extension: string): string =>
|
|
283
|
+
file.replace(/\.[cm]?tsx?$/i, extension);
|
|
284
|
+
|
|
285
|
+
const normalizeProjectPath = (project: string | undefined): string => {
|
|
286
|
+
const next: string = project ?? "tsconfig.json";
|
|
287
|
+
return path.isAbsolute(next) || next.startsWith(".") ? next : `./${next}`;
|
|
288
|
+
};
|
|
289
|
+
|
|
116
290
|
const normalize_file = (str: string) =>
|
|
117
291
|
str.substring(
|
|
118
292
|
str.startsWith("file:///")
|
|
@@ -1,46 +1,22 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import ts from "typescript";
|
|
3
|
-
|
|
4
1
|
import { IReflectImport } from "../structures/IReflectImport";
|
|
5
2
|
import { MapUtil } from "../utils/MapUtil";
|
|
6
3
|
|
|
7
4
|
export namespace ImportAnalyzer {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
file: normalizePath(
|
|
24
|
-
path.dirname(file.fileName),
|
|
25
|
-
ts.isStringLiteral(imp.moduleSpecifier)
|
|
26
|
-
? imp.moduleSpecifier.text
|
|
27
|
-
: escapeQuotes(imp.moduleSpecifier.getText()),
|
|
28
|
-
),
|
|
29
|
-
elements: [],
|
|
30
|
-
default: null,
|
|
31
|
-
asterisk: null,
|
|
32
|
-
};
|
|
33
|
-
if (clause.name) reflect.default = clause.name.getText();
|
|
34
|
-
if (clause.namedBindings === undefined) return reflect;
|
|
35
|
-
else if (ts.isNamedImports(clause.namedBindings))
|
|
36
|
-
reflect.elements = clause.namedBindings.elements.map((e) =>
|
|
37
|
-
e.name.getText(),
|
|
38
|
-
);
|
|
39
|
-
else if (ts.isNamespaceImport(clause.namedBindings))
|
|
40
|
-
reflect.asterisk = clause.namedBindings.name.getText();
|
|
41
|
-
return reflect;
|
|
42
|
-
})
|
|
43
|
-
.filter((r) => r !== null);
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Removed in the Go-migration cycle. Import metadata is now
|
|
7
|
+
* attached by the native transformer in `packages/core/native/cmd/ttsc-nestia`
|
|
8
|
+
* and consumed via `IOperationMetadata.imports`. Call sites that previously
|
|
9
|
+
* walked a `ts.SourceFile` to derive imports should read the metadata
|
|
10
|
+
* delivered through `Reflect.getMetadata("nestia/OperationMetadata", …)`
|
|
11
|
+
* instead. See `packages/core/MIGRATION.md`.
|
|
12
|
+
*/
|
|
13
|
+
export const analyze = (): never => {
|
|
14
|
+
throw new Error(
|
|
15
|
+
"ImportAnalyzer.analyze was removed in @nestia/sdk@next. " +
|
|
16
|
+
"Imports are now attached by the native transformer; read them from " +
|
|
17
|
+
"IOperationMetadata.imports (see packages/core/MIGRATION.md).",
|
|
18
|
+
);
|
|
19
|
+
};
|
|
44
20
|
|
|
45
21
|
export const merge = (imports: IReflectImport[]): IReflectImport[] => {
|
|
46
22
|
// group by files
|
|
@@ -113,14 +89,4 @@ export namespace ImportAnalyzer {
|
|
|
113
89
|
return [...allStarImports, ...defaultImports];
|
|
114
90
|
}
|
|
115
91
|
|
|
116
|
-
function escapeQuotes(str: string): string {
|
|
117
|
-
if (str.startsWith("'") && str.endsWith("'")) return str.slice(1, -1);
|
|
118
|
-
else if (str.startsWith('"') && str.endsWith('"')) return str.slice(1, -1);
|
|
119
|
-
return str;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function normalizePath(root: string, str: string): string {
|
|
123
|
-
if (str.startsWith(".")) return path.resolve(root, str);
|
|
124
|
-
return `node_modules/${str}`;
|
|
125
|
-
}
|
|
126
92
|
}
|
|
@@ -9,7 +9,7 @@ import { INestiaSdkInput } from "../structures/INestiaSdkInput";
|
|
|
9
9
|
import { IReflectController } from "../structures/IReflectController";
|
|
10
10
|
import { IReflectHttpOperation } from "../structures/IReflectHttpOperation";
|
|
11
11
|
import { IReflectWebSocketOperation } from "../structures/IReflectWebSocketOperation";
|
|
12
|
-
import { IOperationMetadata } from "../
|
|
12
|
+
import { IOperationMetadata } from "../structures/IOperationMetadata";
|
|
13
13
|
import { ArrayUtil } from "../utils/ArrayUtil";
|
|
14
14
|
import { ReflectHttpOperationAnalyzer } from "./ReflectHttpOperationAnalyzer";
|
|
15
15
|
import { ReflectMetadataAnalyzer } from "./ReflectMetadataAnalyzer";
|
|
@@ -7,7 +7,7 @@ import { IReflectHttpOperation } from "../structures/IReflectHttpOperation";
|
|
|
7
7
|
import { IReflectHttpOperationParameter } from "../structures/IReflectHttpOperationParameter";
|
|
8
8
|
import { IReflectHttpOperationSuccess } from "../structures/IReflectHttpOperationSuccess";
|
|
9
9
|
import { IReflectOperationError } from "../structures/IReflectOperationError";
|
|
10
|
-
import { IOperationMetadata } from "../
|
|
10
|
+
import { IOperationMetadata } from "../structures/IOperationMetadata";
|
|
11
11
|
import { ArrayUtil } from "../utils/ArrayUtil";
|
|
12
12
|
import { ImportAnalyzer } from "./ImportAnalyzer";
|
|
13
13
|
import { PathAnalyzer } from "./PathAnalyzer";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { TypedException } from "@nestia/core";
|
|
2
|
-
import { JsonMetadataFactory } from "
|
|
2
|
+
import { JsonMetadataFactory } from "../internal/legacy";
|
|
3
3
|
|
|
4
4
|
import { IReflectController } from "../structures/IReflectController";
|
|
5
5
|
import { IReflectHttpOperationException } from "../structures/IReflectHttpOperationException";
|
|
6
6
|
import { IReflectOperationError } from "../structures/IReflectOperationError";
|
|
7
|
-
import { IOperationMetadata } from "../
|
|
7
|
+
import { IOperationMetadata } from "../structures/IOperationMetadata";
|
|
8
8
|
|
|
9
9
|
export namespace ReflectHttpOperationExceptionAnalyzer {
|
|
10
10
|
export interface IContext {
|
|
@@ -18,6 +18,12 @@ export namespace ReflectHttpOperationExceptionAnalyzer {
|
|
|
18
18
|
export const analyze = (
|
|
19
19
|
ctx: IContext,
|
|
20
20
|
): Record<string, IReflectHttpOperationException> => {
|
|
21
|
+
// TypeScript applies decorators bottom-up, so Reflect's metadata array
|
|
22
|
+
// is the reverse of declaration order. Reverse it once here so the
|
|
23
|
+
// resulting status-code → exception map iterates in declaration order
|
|
24
|
+
// and lines up with the Go transformer's metadata.exceptions[], which
|
|
25
|
+
// is emitted in AST/declaration order (see
|
|
26
|
+
// packages/core/native/cmd/ttsc-nestia/sdk_transform.go).
|
|
21
27
|
const preconfigured: TypedException.IProps<any>[] = analyzePreconfigured(
|
|
22
28
|
ctx.function,
|
|
23
29
|
)
|
|
@@ -26,10 +32,9 @@ export namespace ReflectHttpOperationExceptionAnalyzer {
|
|
|
26
32
|
const errors: IReflectOperationError[] = [];
|
|
27
33
|
const exceptions: IReflectHttpOperationException[] = preconfigured
|
|
28
34
|
.map((pre, i) => {
|
|
29
|
-
const matched: IOperationMetadata.
|
|
30
|
-
ctx.metadata.exceptions[i]
|
|
35
|
+
const matched: IOperationMetadata.IResponse | undefined =
|
|
36
|
+
ctx.metadata.exceptions[i];
|
|
31
37
|
if (matched === undefined) {
|
|
32
|
-
if (ctx.functionName === "getOauthProfile") console.log(ctx.metadata);
|
|
33
38
|
errors.push({
|
|
34
39
|
file: ctx.controller.file,
|
|
35
40
|
class: ctx.controller.class.name,
|
|
@@ -51,7 +56,20 @@ export namespace ReflectHttpOperationExceptionAnalyzer {
|
|
|
51
56
|
.success
|
|
52
57
|
? matched.primitive.data
|
|
53
58
|
: null;
|
|
54
|
-
if (
|
|
59
|
+
if (matched.primitive.success === false) {
|
|
60
|
+
errors.push({
|
|
61
|
+
file: ctx.controller.file,
|
|
62
|
+
class: ctx.controller.class.name,
|
|
63
|
+
function: ctx.functionName,
|
|
64
|
+
from: `exception (status: ${pre.status})`,
|
|
65
|
+
contents: matched.primitive.errors.map((e) => ({
|
|
66
|
+
name: e.name,
|
|
67
|
+
accessor: e.accessor,
|
|
68
|
+
messages: e.messages,
|
|
69
|
+
})),
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
if (schema === null || matched.type === null) return null;
|
|
55
73
|
return {
|
|
56
74
|
status: pre.status,
|
|
57
75
|
description: pre.description ?? null,
|
|
@@ -7,13 +7,13 @@ import {
|
|
|
7
7
|
HttpParameterProgrammer,
|
|
8
8
|
HttpQueryProgrammer,
|
|
9
9
|
JsonMetadataFactory,
|
|
10
|
-
} from "
|
|
10
|
+
} from "../internal/legacy";
|
|
11
11
|
|
|
12
12
|
import { IReflectController } from "../structures/IReflectController";
|
|
13
13
|
import { IReflectHttpOperationParameter } from "../structures/IReflectHttpOperationParameter";
|
|
14
14
|
import { IReflectOperationError } from "../structures/IReflectOperationError";
|
|
15
|
-
import { IOperationMetadata } from "../
|
|
16
|
-
import { TextPlainValidator } from "../
|
|
15
|
+
import { IOperationMetadata } from "../structures/IOperationMetadata";
|
|
16
|
+
import { TextPlainValidator } from "../validators/TextPlainValidator";
|
|
17
17
|
import { HttpHeadersValidator } from "../validators/HttpHeadersValidator";
|
|
18
18
|
import { HttpQueryValidator } from "../validators/HttpQueryValidator";
|
|
19
19
|
|
|
@@ -4,14 +4,13 @@ import {
|
|
|
4
4
|
HTTP_CODE_METADATA,
|
|
5
5
|
INTERCEPTORS_METADATA,
|
|
6
6
|
} from "@nestjs/common/constants";
|
|
7
|
-
import { HttpQueryProgrammer, JsonMetadataFactory } from "
|
|
8
|
-
import typia from "typia";
|
|
7
|
+
import { HttpQueryProgrammer, JsonMetadataFactory, sizeOf } from "../internal/legacy";
|
|
9
8
|
|
|
10
9
|
import { IReflectController } from "../structures/IReflectController";
|
|
11
10
|
import { IReflectHttpOperationSuccess } from "../structures/IReflectHttpOperationSuccess";
|
|
12
11
|
import { IReflectOperationError } from "../structures/IReflectOperationError";
|
|
13
|
-
import { IOperationMetadata } from "../
|
|
14
|
-
import { TextPlainValidator } from "../
|
|
12
|
+
import { IOperationMetadata } from "../structures/IOperationMetadata";
|
|
13
|
+
import { TextPlainValidator } from "../validators/TextPlainValidator";
|
|
15
14
|
|
|
16
15
|
export namespace ReflectHttpOperationResponseAnalyzer {
|
|
17
16
|
export interface IContext {
|
|
@@ -65,10 +64,7 @@ export namespace ReflectHttpOperationResponseAnalyzer {
|
|
|
65
64
|
if (schema.success === false) errors.push(...schema.errors);
|
|
66
65
|
if (ctx.httpMethod === "HEAD" && contentType !== null)
|
|
67
66
|
errors.push(`HEAD method must not have a content type.`);
|
|
68
|
-
if (
|
|
69
|
-
typia.is<IReflectHttpOperationSuccess["contentType"]>(contentType) ===
|
|
70
|
-
false
|
|
71
|
-
)
|
|
67
|
+
if (isContentType(contentType) === false)
|
|
72
68
|
errors.push(
|
|
73
69
|
`@nestia/sdk does not support ${JSON.stringify(contentType)} content type.`,
|
|
74
70
|
);
|
|
@@ -77,7 +73,7 @@ export namespace ReflectHttpOperationResponseAnalyzer {
|
|
|
77
73
|
else if (
|
|
78
74
|
ctx.metadata.success.type === null ||
|
|
79
75
|
schema.success === false ||
|
|
80
|
-
!
|
|
76
|
+
!isContentType(contentType)
|
|
81
77
|
)
|
|
82
78
|
return null;
|
|
83
79
|
|
|
@@ -100,7 +96,7 @@ export namespace ReflectHttpOperationResponseAnalyzer {
|
|
|
100
96
|
: contentType === "text/plain"
|
|
101
97
|
? TextPlainValidator.validate
|
|
102
98
|
: (next) =>
|
|
103
|
-
next.metadata
|
|
99
|
+
sizeOf(next.metadata) !== 0
|
|
104
100
|
? ["HEAD method must not have any return value."]
|
|
105
101
|
: [],
|
|
106
102
|
example: example?.example,
|
|
@@ -123,4 +119,12 @@ export namespace ReflectHttpOperationResponseAnalyzer {
|
|
|
123
119
|
if (Array.isArray(meta) === false) return false;
|
|
124
120
|
return meta.some((elem) => elem?.constructor?.name === props.name);
|
|
125
121
|
};
|
|
122
|
+
|
|
123
|
+
const isContentType = (
|
|
124
|
+
input: string | null,
|
|
125
|
+
): input is IReflectHttpOperationSuccess["contentType"] =>
|
|
126
|
+
input === null ||
|
|
127
|
+
input === "application/json" ||
|
|
128
|
+
input === "text/plain" ||
|
|
129
|
+
input === "application/x-www-form-urlencoded";
|
|
126
130
|
}
|
|
@@ -5,7 +5,7 @@ import { IReflectController } from "../structures/IReflectController";
|
|
|
5
5
|
import { IReflectImport } from "../structures/IReflectImport";
|
|
6
6
|
import { IReflectWebSocketOperation } from "../structures/IReflectWebSocketOperation";
|
|
7
7
|
import { IReflectWebSocketOperationParameter } from "../structures/IReflectWebSocketOperationParameter";
|
|
8
|
-
import { IOperationMetadata } from "../
|
|
8
|
+
import { IOperationMetadata } from "../structures/IOperationMetadata";
|
|
9
9
|
import { StringUtil } from "../utils/StringUtil";
|
|
10
10
|
import { ImportAnalyzer } from "./ImportAnalyzer";
|
|
11
11
|
import { PathAnalyzer } from "./PathAnalyzer";
|
|
@@ -36,7 +36,7 @@ export namespace ReflectWebSocketOperationAnalyzer {
|
|
|
36
36
|
ctx.name,
|
|
37
37
|
) ?? []) as IReflectWebSocketOperationParameter[]
|
|
38
38
|
).sort((a, b) => a.index - b.index);
|
|
39
|
-
if (preconfigured.find((p) =>
|
|
39
|
+
if (preconfigured.find((p) => p.category === "acceptor") === undefined)
|
|
40
40
|
errors.push("@WebSocketRoute.Acceptor() is essentially required");
|
|
41
41
|
if (preconfigured.length !== ctx.function.length)
|
|
42
42
|
errors.push(
|