@nestia/sdk 14.0.0 → 14.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/assets/bundle/distribute/build-sdk.cjs +28 -0
- package/assets/bundle/distribute/package.json +7 -3
- package/assets/bundle/distribute/tsconfig.json +15 -105
- package/lib/INestiaConfig.d.ts +74 -34
- package/lib/NestiaSdkApplication.d.ts +60 -0
- package/lib/NestiaSdkApplication.js +121 -32
- package/lib/NestiaSdkApplication.js.map +1 -1
- package/lib/NestiaSwaggerComposer.d.ts +21 -0
- package/lib/NestiaSwaggerComposer.js +32 -13
- package/lib/NestiaSwaggerComposer.js.map +1 -1
- package/lib/analyses/AccessorAnalyzer.d.ts +26 -0
- package/lib/analyses/AccessorAnalyzer.js +26 -0
- package/lib/analyses/AccessorAnalyzer.js.map +1 -1
- package/lib/analyses/ConfigAnalyzer.d.ts +41 -0
- package/lib/analyses/ConfigAnalyzer.js +52 -77
- package/lib/analyses/ConfigAnalyzer.js.map +1 -1
- package/lib/analyses/ImportAnalyzer.d.ts +25 -0
- package/lib/analyses/ImportAnalyzer.js +25 -0
- package/lib/analyses/ImportAnalyzer.js.map +1 -1
- package/lib/analyses/ParameterNameAnalyzer.d.ts +44 -0
- package/lib/analyses/ParameterNameAnalyzer.js +63 -0
- package/lib/analyses/ParameterNameAnalyzer.js.map +1 -0
- package/lib/analyses/PathAnalyzer.d.ts +93 -1
- package/lib/analyses/PathAnalyzer.js +160 -23
- package/lib/analyses/PathAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectControllerAnalyzer.d.ts +32 -0
- package/lib/analyses/ReflectControllerAnalyzer.js +24 -1
- package/lib/analyses/ReflectControllerAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationAnalyzer.d.ts +29 -0
- package/lib/analyses/ReflectHttpOperationAnalyzer.js +35 -24
- package/lib/analyses/ReflectHttpOperationAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationExceptionAnalyzer.d.ts +31 -0
- package/lib/analyses/ReflectHttpOperationExceptionAnalyzer.js +21 -0
- package/lib/analyses/ReflectHttpOperationExceptionAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationParameterAnalyzer.d.ts +31 -0
- package/lib/analyses/ReflectHttpOperationParameterAnalyzer.js +143 -23
- package/lib/analyses/ReflectHttpOperationParameterAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.d.ts +32 -0
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.js +27 -2
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectMcpOperationAnalyzer.d.ts +29 -0
- package/lib/analyses/ReflectMcpOperationAnalyzer.js +35 -11
- package/lib/analyses/ReflectMcpOperationAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectMetadataAnalyzer.d.ts +47 -0
- package/lib/analyses/ReflectMetadataAnalyzer.js +47 -0
- package/lib/analyses/ReflectMetadataAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectWebSocketOperationAnalyzer.d.ts +29 -0
- package/lib/analyses/ReflectWebSocketOperationAnalyzer.js +27 -5
- package/lib/analyses/ReflectWebSocketOperationAnalyzer.js.map +1 -1
- package/lib/analyses/SecurityAnalyzer.d.ts +25 -0
- package/lib/analyses/SecurityAnalyzer.js +39 -19
- package/lib/analyses/SecurityAnalyzer.js.map +1 -1
- package/lib/analyses/SwaggerExampleAnalyzer.d.ts +31 -0
- package/lib/analyses/SwaggerExampleAnalyzer.js +36 -0
- package/lib/analyses/SwaggerExampleAnalyzer.js.map +1 -0
- package/lib/analyses/TypedHttpRouteAnalyzer.d.ts +41 -3
- package/lib/analyses/TypedHttpRouteAnalyzer.js +196 -172
- package/lib/analyses/TypedHttpRouteAnalyzer.js.map +1 -1
- package/lib/analyses/TypedMcpRouteAnalyzer.d.ts +29 -0
- package/lib/analyses/TypedMcpRouteAnalyzer.js +152 -20
- package/lib/analyses/TypedMcpRouteAnalyzer.js.map +1 -1
- package/lib/analyses/TypedWebSocketRouteAnalyzer.d.ts +19 -0
- package/lib/analyses/TypedWebSocketRouteAnalyzer.js +20 -1
- package/lib/analyses/TypedWebSocketRouteAnalyzer.js.map +1 -1
- package/lib/decorators/OperationMetadata.d.ts +6 -0
- package/lib/decorators/OperationMetadata.js +6 -0
- package/lib/decorators/OperationMetadata.js.map +1 -1
- package/lib/executable/internal/CommandParser.d.ts +19 -0
- package/lib/executable/internal/CommandParser.js +19 -0
- package/lib/executable/internal/CommandParser.js.map +1 -1
- package/lib/executable/internal/NestiaConfigLoader.d.ts +56 -0
- package/lib/executable/internal/NestiaConfigLoader.js +48 -42
- package/lib/executable/internal/NestiaConfigLoader.js.map +1 -1
- package/lib/executable/internal/NestiaSdkCommand.d.ts +60 -0
- package/lib/executable/internal/NestiaSdkCommand.js +95 -3
- package/lib/executable/internal/NestiaSdkCommand.js.map +1 -1
- package/lib/executable/internal/NestiaSdkWatcher.d.ts +81 -0
- package/lib/executable/internal/NestiaSdkWatcher.js +125 -41
- package/lib/executable/internal/NestiaSdkWatcher.js.map +1 -1
- package/lib/executable/internal/NestiaSwaggerWatch.d.ts +80 -0
- package/lib/executable/internal/NestiaSwaggerWatch.js +308 -0
- package/lib/executable/internal/NestiaSwaggerWatch.js.map +1 -0
- package/lib/executable/sdk.js +16 -1
- package/lib/executable/sdk.js.map +1 -1
- package/lib/factories/ExpressionFactory.d.ts +18 -0
- package/lib/factories/ExpressionFactory.js +21 -2
- package/lib/factories/ExpressionFactory.js.map +1 -1
- package/lib/factories/IdentifierFactory.d.ts +24 -0
- package/lib/factories/IdentifierFactory.js +24 -0
- package/lib/factories/IdentifierFactory.js.map +1 -1
- package/lib/factories/LiteralFactory.d.ts +22 -4
- package/lib/factories/LiteralFactory.js +33 -11
- package/lib/factories/LiteralFactory.js.map +1 -1
- package/lib/factories/StatementFactory.d.ts +28 -1
- package/lib/factories/StatementFactory.js +28 -1
- package/lib/factories/StatementFactory.js.map +1 -1
- package/lib/factories/TypeFactory.d.ts +24 -0
- package/lib/factories/TypeFactory.js +15 -0
- package/lib/factories/TypeFactory.js.map +1 -1
- package/lib/generates/CloneGenerator.d.ts +22 -0
- package/lib/generates/CloneGenerator.js +26 -5
- package/lib/generates/CloneGenerator.js.map +1 -1
- package/lib/generates/E2eGenerator.d.ts +19 -0
- package/lib/generates/E2eGenerator.js +19 -0
- package/lib/generates/E2eGenerator.js.map +1 -1
- package/lib/generates/SdkGenerator.d.ts +38 -0
- package/lib/generates/SdkGenerator.js +43 -5
- package/lib/generates/SdkGenerator.js.map +1 -1
- package/lib/generates/SwaggerGenerator.d.ts +36 -6
- package/lib/generates/SwaggerGenerator.js +190 -40
- package/lib/generates/SwaggerGenerator.js.map +1 -1
- package/lib/generates/internal/E2eFileProgrammer.d.ts +19 -0
- package/lib/generates/internal/E2eFileProgrammer.js +20 -1
- package/lib/generates/internal/E2eFileProgrammer.js.map +1 -1
- package/lib/generates/internal/FilePrinter.d.ts +57 -0
- package/lib/generates/internal/FilePrinter.js +74 -0
- package/lib/generates/internal/FilePrinter.js.map +1 -1
- package/lib/generates/internal/ImportDictionary.d.ts +93 -1
- package/lib/generates/internal/ImportDictionary.js +103 -2
- package/lib/generates/internal/ImportDictionary.js.map +1 -1
- package/lib/generates/internal/SdkAliasCollection.d.ts +121 -1
- package/lib/generates/internal/SdkAliasCollection.js +132 -11
- package/lib/generates/internal/SdkAliasCollection.js.map +1 -1
- package/lib/generates/internal/SdkDistributionComposer.d.ts +19 -0
- package/lib/generates/internal/SdkDistributionComposer.js +149 -52
- package/lib/generates/internal/SdkDistributionComposer.js.map +1 -1
- package/lib/generates/internal/SdkFileProgrammer.d.ts +18 -0
- package/lib/generates/internal/SdkFileProgrammer.js +101 -12
- package/lib/generates/internal/SdkFileProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpCloneProgrammer.d.ts +29 -0
- package/lib/generates/internal/SdkHttpCloneProgrammer.js +33 -0
- package/lib/generates/internal/SdkHttpCloneProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpCloneReferencer.d.ts +19 -0
- package/lib/generates/internal/SdkHttpCloneReferencer.js +78 -25
- package/lib/generates/internal/SdkHttpCloneReferencer.js.map +1 -1
- package/lib/generates/internal/SdkHttpFunctionProgrammer.d.ts +19 -0
- package/lib/generates/internal/SdkHttpFunctionProgrammer.js +40 -23
- package/lib/generates/internal/SdkHttpFunctionProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.d.ts +19 -0
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.js +46 -34
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpParameterProgrammer.d.ts +142 -1
- package/lib/generates/internal/SdkHttpParameterProgrammer.js +175 -6
- package/lib/generates/internal/SdkHttpParameterProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpRouteProgrammer.d.ts +20 -0
- package/lib/generates/internal/SdkHttpRouteProgrammer.js +36 -32
- package/lib/generates/internal/SdkHttpRouteProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpSimulationProgrammer.d.ts +38 -0
- package/lib/generates/internal/SdkHttpSimulationProgrammer.js +66 -18
- package/lib/generates/internal/SdkHttpSimulationProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkImportWizard.d.ts +63 -0
- package/lib/generates/internal/SdkImportWizard.js +63 -0
- package/lib/generates/internal/SdkImportWizard.js.map +1 -1
- package/lib/generates/internal/SdkMcpRouteProgrammer.d.ts +17 -2
- package/lib/generates/internal/SdkMcpRouteProgrammer.js +72 -24
- package/lib/generates/internal/SdkMcpRouteProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkPathTemplate.d.ts +36 -0
- package/lib/generates/internal/SdkPathTemplate.js +65 -0
- package/lib/generates/internal/SdkPathTemplate.js.map +1 -0
- package/lib/generates/internal/SdkRouteDirectory.d.ts +10 -0
- package/lib/generates/internal/SdkRouteDirectory.js +10 -0
- package/lib/generates/internal/SdkRouteDirectory.js.map +1 -1
- package/lib/generates/internal/SdkTypeProgrammer.d.ts +54 -1
- package/lib/generates/internal/SdkTypeProgrammer.js +111 -27
- package/lib/generates/internal/SdkTypeProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkTypeTagProgrammer.d.ts +53 -1
- package/lib/generates/internal/SdkTypeTagProgrammer.js +407 -67
- package/lib/generates/internal/SdkTypeTagProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketCloneProgrammer.d.ts +40 -0
- package/lib/generates/internal/SdkWebSocketCloneProgrammer.js +149 -142
- package/lib/generates/internal/SdkWebSocketCloneProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.d.ts +19 -0
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js +46 -36
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketParameterProgrammer.d.ts +114 -1
- package/lib/generates/internal/SdkWebSocketParameterProgrammer.js +120 -5
- package/lib/generates/internal/SdkWebSocketParameterProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.d.ts +18 -0
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.js +75 -33
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.js.map +1 -1
- package/lib/generates/internal/SwaggerDescriptionComposer.d.ts +42 -0
- package/lib/generates/internal/SwaggerDescriptionComposer.js +44 -1
- package/lib/generates/internal/SwaggerDescriptionComposer.js.map +1 -1
- package/lib/generates/internal/SwaggerOperationComposer.d.ts +18 -0
- package/lib/generates/internal/SwaggerOperationComposer.js +37 -8
- package/lib/generates/internal/SwaggerOperationComposer.js.map +1 -1
- package/lib/generates/internal/SwaggerOperationParameterComposer.d.ts +40 -1
- package/lib/generates/internal/SwaggerOperationParameterComposer.js +230 -25
- package/lib/generates/internal/SwaggerOperationParameterComposer.js.map +1 -1
- package/lib/generates/internal/SwaggerOperationResponseComposer.d.ts +21 -0
- package/lib/generates/internal/SwaggerOperationResponseComposer.js +58 -7
- package/lib/generates/internal/SwaggerOperationResponseComposer.js.map +1 -1
- package/lib/internal/legacy.d.ts +342 -31
- package/lib/internal/legacy.js +207 -31
- package/lib/internal/legacy.js.map +1 -1
- package/lib/structures/INestiaProject.d.ts +10 -0
- package/lib/structures/INestiaSdkInput.d.ts +30 -0
- package/lib/structures/IOperationMetadata.d.ts +77 -0
- package/lib/structures/IReflectController.d.ts +10 -0
- package/lib/structures/IReflectHttpOperation.d.ts +10 -0
- package/lib/structures/IReflectHttpOperationException.d.ts +13 -2
- package/lib/structures/IReflectHttpOperationParameter.d.ts +55 -3
- package/lib/structures/IReflectHttpOperationSuccess.d.ts +15 -3
- package/lib/structures/IReflectImport.d.ts +10 -0
- package/lib/structures/IReflectMcpOperation.d.ts +19 -0
- package/lib/structures/IReflectMcpOperationParameter.d.ts +9 -0
- package/lib/structures/IReflectOperationError.d.ts +28 -0
- package/lib/structures/IReflectOperationError.js +22 -2
- package/lib/structures/IReflectOperationError.js.map +1 -1
- package/lib/structures/IReflectType.d.ts +9 -0
- package/lib/structures/IReflectWebSocketOperation.d.ts +10 -0
- package/lib/structures/IReflectWebSocketOperationParameter.d.ts +55 -0
- package/lib/structures/ITypedApplication.d.ts +10 -0
- package/lib/structures/ITypedHttpRoute.d.ts +18 -0
- package/lib/structures/ITypedHttpRouteException.d.ts +13 -1
- package/lib/structures/ITypedHttpRouteParameter.d.ts +48 -1
- package/lib/structures/ITypedHttpRouteSuccess.d.ts +13 -1
- package/lib/structures/ITypedMcpRoute.d.ts +11 -0
- package/lib/structures/ITypedWebSocketRoute.d.ts +18 -0
- package/lib/transform.d.ts +6 -0
- package/lib/transform.js +6 -0
- package/lib/transform.js.map +1 -1
- package/lib/utils/ArrayUtil.d.ts +31 -1
- package/lib/utils/ArrayUtil.js +32 -11
- package/lib/utils/ArrayUtil.js.map +1 -1
- package/lib/utils/EmittedJavaScriptPatcher.d.ts +20 -0
- package/lib/utils/EmittedJavaScriptPatcher.js +65 -46
- package/lib/utils/EmittedJavaScriptPatcher.js.map +1 -1
- package/lib/utils/FileRetriever.d.ts +29 -0
- package/lib/utils/FileRetriever.js +29 -0
- package/lib/utils/FileRetriever.js.map +1 -1
- package/lib/utils/HttpResponseContentTypeUtil.d.ts +41 -0
- package/lib/utils/HttpResponseContentTypeUtil.js +31 -0
- package/lib/utils/HttpResponseContentTypeUtil.js.map +1 -1
- package/lib/utils/MapUtil.d.ts +64 -1
- package/lib/utils/MapUtil.js +24 -3
- package/lib/utils/MapUtil.js.map +1 -1
- package/lib/utils/PathUtil.d.ts +31 -0
- package/lib/utils/PathUtil.js +38 -0
- package/lib/utils/PathUtil.js.map +1 -1
- package/lib/utils/SdkBundlePath.d.ts +2 -0
- package/lib/utils/SdkBundlePath.js +10 -0
- package/lib/utils/SdkBundlePath.js.map +1 -0
- package/lib/utils/SdkInputFilter.d.ts +31 -0
- package/lib/utils/SdkInputFilter.js +115 -0
- package/lib/utils/SdkInputFilter.js.map +1 -0
- package/lib/utils/SourceFinder.d.ts +45 -0
- package/lib/utils/SourceFinder.js +74 -16
- package/lib/utils/SourceFinder.js.map +1 -1
- package/lib/utils/StringUtil.d.ts +77 -2
- package/lib/utils/StringUtil.js +166 -4
- package/lib/utils/StringUtil.js.map +1 -1
- package/lib/utils/TemporaryDirectory.d.ts +60 -0
- package/lib/utils/TemporaryDirectory.js +112 -0
- package/lib/utils/TemporaryDirectory.js.map +1 -0
- package/lib/utils/TsConfigReader.d.ts +42 -0
- package/lib/utils/TsConfigReader.js +98 -14
- package/lib/utils/TsConfigReader.js.map +1 -1
- package/lib/utils/TtscExecutor.d.ts +23 -1
- package/lib/utils/TtscExecutor.js +22 -0
- package/lib/utils/TtscExecutor.js.map +1 -1
- package/lib/utils/VersioningStrategy.d.ts +39 -2
- package/lib/utils/VersioningStrategy.js +46 -13
- package/lib/utils/VersioningStrategy.js.map +1 -1
- package/lib/validators/TextPlainValidator.d.ts +19 -0
- package/lib/validators/TextPlainValidator.js +19 -0
- package/lib/validators/TextPlainValidator.js.map +1 -1
- package/native/go.mod +1 -1
- package/native/go.sum +2 -2
- package/native/sdk/register.go +12 -2
- package/native/sdk/sdk_http_rules.go +210 -0
- package/native/sdk/sdk_metadata_json.go +79 -4
- package/native/sdk/sdk_transform.go +1157 -414
- package/package.json +8 -6
- package/src/INestiaConfig.ts +74 -34
- package/src/NestiaSdkApplication.ts +129 -41
- package/src/NestiaSwaggerComposer.ts +32 -14
- package/src/analyses/AccessorAnalyzer.ts +26 -0
- package/src/analyses/ConfigAnalyzer.ts +52 -90
- package/src/analyses/ImportAnalyzer.ts +25 -0
- package/src/analyses/ParameterNameAnalyzer.ts +75 -0
- package/src/analyses/PathAnalyzer.ts +167 -23
- package/src/analyses/ReflectControllerAnalyzer.ts +34 -1
- package/src/analyses/ReflectHttpOperationAnalyzer.ts +36 -14
- package/src/analyses/ReflectHttpOperationExceptionAnalyzer.ts +31 -0
- package/src/analyses/ReflectHttpOperationParameterAnalyzer.ts +153 -39
- package/src/analyses/ReflectHttpOperationResponseAnalyzer.ts +38 -7
- package/src/analyses/ReflectMcpOperationAnalyzer.ts +38 -3
- package/src/analyses/ReflectMetadataAnalyzer.ts +47 -0
- package/src/analyses/ReflectWebSocketOperationAnalyzer.ts +40 -7
- package/src/analyses/SecurityAnalyzer.ts +45 -20
- package/src/analyses/SwaggerExampleAnalyzer.ts +39 -0
- package/src/analyses/TypedHttpRouteAnalyzer.ts +263 -198
- package/src/analyses/TypedMcpRouteAnalyzer.ts +180 -20
- package/src/analyses/TypedWebSocketRouteAnalyzer.ts +20 -0
- package/src/decorators/OperationMetadata.ts +6 -0
- package/src/executable/internal/CommandParser.ts +19 -0
- package/src/executable/internal/NestiaConfigLoader.ts +66 -50
- package/src/executable/internal/NestiaSdkCommand.ts +96 -3
- package/src/executable/internal/NestiaSdkWatcher.ts +172 -44
- package/src/executable/internal/NestiaSwaggerWatch.ts +359 -0
- package/src/executable/sdk.ts +24 -1
- package/src/factories/ExpressionFactory.ts +23 -2
- package/src/factories/IdentifierFactory.ts +24 -0
- package/src/factories/LiteralFactory.ts +51 -13
- package/src/factories/StatementFactory.ts +28 -1
- package/src/factories/TypeFactory.ts +24 -0
- package/src/generates/CloneGenerator.ts +26 -5
- package/src/generates/E2eGenerator.ts +19 -0
- package/src/generates/SdkGenerator.ts +43 -12
- package/src/generates/SwaggerGenerator.ts +229 -46
- package/src/generates/internal/E2eFileProgrammer.ts +20 -0
- package/src/generates/internal/FilePrinter.ts +71 -0
- package/src/generates/internal/ImportDictionary.ts +120 -2
- package/src/generates/internal/SdkAliasCollection.ts +144 -15
- package/src/generates/internal/SdkDistributionComposer.ts +181 -56
- package/src/generates/internal/SdkFileProgrammer.ts +126 -16
- package/src/generates/internal/SdkHttpCloneProgrammer.ts +55 -0
- package/src/generates/internal/SdkHttpCloneReferencer.ts +97 -23
- package/src/generates/internal/SdkHttpFunctionProgrammer.ts +47 -30
- package/src/generates/internal/SdkHttpNamespaceProgrammer.ts +53 -64
- package/src/generates/internal/SdkHttpParameterProgrammer.ts +295 -13
- package/src/generates/internal/SdkHttpRouteProgrammer.ts +37 -31
- package/src/generates/internal/SdkHttpSimulationProgrammer.ts +122 -18
- package/src/generates/internal/SdkImportWizard.ts +63 -0
- package/src/generates/internal/SdkMcpRouteProgrammer.ts +150 -33
- package/src/generates/internal/SdkPathTemplate.ts +88 -0
- package/src/generates/internal/SdkRouteDirectory.ts +10 -0
- package/src/generates/internal/SdkTypeProgrammer.ts +137 -36
- package/src/generates/internal/SdkTypeTagProgrammer.ts +536 -78
- package/src/generates/internal/SdkWebSocketCloneProgrammer.ts +185 -142
- package/src/generates/internal/SdkWebSocketNamespaceProgrammer.ts +62 -68
- package/src/generates/internal/SdkWebSocketParameterProgrammer.ts +205 -5
- package/src/generates/internal/SdkWebSocketRouteProgrammer.ts +89 -48
- package/src/generates/internal/SwaggerDescriptionComposer.ts +47 -1
- package/src/generates/internal/SwaggerOperationComposer.ts +38 -6
- package/src/generates/internal/SwaggerOperationParameterComposer.ts +318 -36
- package/src/generates/internal/SwaggerOperationResponseComposer.ts +74 -11
- package/src/internal/legacy-augmentation.d.ts +16 -0
- package/src/internal/legacy.ts +407 -49
- package/src/structures/INestiaProject.ts +10 -0
- package/src/structures/INestiaSdkInput.ts +30 -0
- package/src/structures/IOperationMetadata.ts +83 -0
- package/src/structures/IReflectController.ts +10 -0
- package/src/structures/IReflectHttpOperation.ts +10 -0
- package/src/structures/IReflectHttpOperationException.ts +17 -2
- package/src/structures/IReflectHttpOperationParameter.ts +56 -2
- package/src/structures/IReflectHttpOperationSuccess.ts +19 -3
- package/src/structures/IReflectImport.ts +10 -0
- package/src/structures/IReflectMcpOperation.ts +19 -0
- package/src/structures/IReflectMcpOperationParameter.ts +9 -0
- package/src/structures/IReflectOperationError.ts +31 -2
- package/src/structures/IReflectType.ts +9 -0
- package/src/structures/IReflectWebSocketOperation.ts +10 -0
- package/src/structures/IReflectWebSocketOperationParameter.ts +55 -0
- package/src/structures/ITypedApplication.ts +10 -0
- package/src/structures/ITypedHttpRoute.ts +18 -0
- package/src/structures/ITypedHttpRouteException.ts +14 -1
- package/src/structures/ITypedHttpRouteParameter.ts +48 -1
- package/src/structures/ITypedHttpRouteSuccess.ts +14 -1
- package/src/structures/ITypedMcpRoute.ts +12 -0
- package/src/structures/ITypedWebSocketRoute.ts +18 -0
- package/src/transform.ts +6 -0
- package/src/utils/ArrayUtil.ts +32 -13
- package/src/utils/EmittedJavaScriptPatcher.ts +70 -47
- package/src/utils/FileRetriever.ts +29 -0
- package/src/utils/HttpResponseContentTypeUtil.ts +41 -0
- package/src/utils/MapUtil.ts +68 -3
- package/src/utils/PathUtil.ts +38 -0
- package/src/utils/SdkBundlePath.ts +11 -0
- package/src/utils/SdkInputFilter.ts +108 -0
- package/src/utils/SourceFinder.ts +76 -18
- package/src/utils/StringUtil.ts +182 -5
- package/src/utils/TemporaryDirectory.ts +108 -0
- package/src/utils/TsConfigReader.ts +124 -26
- package/src/utils/TtscExecutor.ts +23 -1
- package/src/utils/VersioningStrategy.ts +51 -16
- package/src/validators/TextPlainValidator.ts +19 -0
- package/lib/generates/internal/SwaggerReadonlyArrayEmender.d.ts +0 -9
- package/lib/generates/internal/SwaggerReadonlyArrayEmender.js +0 -178
- package/lib/generates/internal/SwaggerReadonlyArrayEmender.js.map +0 -1
- package/lib/validators/HttpHeadersValidator.d.ts +0 -11
- package/lib/validators/HttpHeadersValidator.js +0 -15
- package/lib/validators/HttpHeadersValidator.js.map +0 -1
- package/lib/validators/HttpQueryValidator.d.ts +0 -10
- package/lib/validators/HttpQueryValidator.js +0 -14
- package/lib/validators/HttpQueryValidator.js.map +0 -1
- package/src/generates/internal/SwaggerReadonlyArrayEmender.ts +0 -264
- package/src/validators/HttpHeadersValidator.ts +0 -12
- package/src/validators/HttpQueryValidator.ts +0 -11
|
@@ -1,12 +1,38 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type Expression,
|
|
3
|
+
type Node,
|
|
4
|
+
SyntaxKind,
|
|
5
|
+
type TypeNode,
|
|
6
|
+
factory,
|
|
7
|
+
} from "@ttsc/factory";
|
|
2
8
|
|
|
3
9
|
import { INestiaProject } from "../../structures/INestiaProject";
|
|
4
10
|
import { ITypedHttpRoute } from "../../structures/ITypedHttpRoute";
|
|
5
11
|
import { ITypedHttpRouteParameter } from "../../structures/ITypedHttpRouteParameter";
|
|
12
|
+
import { StringUtil } from "../../utils/StringUtil";
|
|
6
13
|
import { ImportDictionary } from "./ImportDictionary";
|
|
7
14
|
import { SdkAliasCollection } from "./SdkAliasCollection";
|
|
8
15
|
|
|
16
|
+
/**
|
|
17
|
+
* The parameters of an HTTP route's SDK function.
|
|
18
|
+
*
|
|
19
|
+
* @evidence contracts/common.md#principled-implementation The namespace decides the identifiers, lists the entries, and writes the declarations and the arguments in positional or keyword mode.
|
|
20
|
+
* @evidence contracts/common.md#clear-and-simple-design Several small functions over one entry type.
|
|
21
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The three consumers share one decision.
|
|
22
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
23
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkHttpParameterProgrammer composes SDK syntax, identifiers or import bindings; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
|
|
24
|
+
*/
|
|
9
25
|
export namespace SdkHttpParameterProgrammer {
|
|
26
|
+
/**
|
|
27
|
+
* One parameter of a route: its key, whether it is required, its type, and
|
|
28
|
+
* the reflected parameter.
|
|
29
|
+
*
|
|
30
|
+
* @evidence contracts/common.md#principled-implementation The record is what a declaration or an argument needs.
|
|
31
|
+
* @evidence contracts/common.md#clear-and-simple-design A four-member record.
|
|
32
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
|
|
33
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
34
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkHttpParameterProgrammer.IEntry composes SDK syntax, identifiers or import bindings; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
|
|
35
|
+
*/
|
|
10
36
|
export interface IEntry {
|
|
11
37
|
key: string;
|
|
12
38
|
required: boolean;
|
|
@@ -14,6 +40,199 @@ export namespace SdkHttpParameterProgrammer {
|
|
|
14
40
|
parameter: ITypedHttpRouteParameter;
|
|
15
41
|
}
|
|
16
42
|
|
|
43
|
+
/**
|
|
44
|
+
* The identifiers one route's SDK function, `path()`, and `simulate()` use,
|
|
45
|
+
* decided once so the three cannot disagree.
|
|
46
|
+
*
|
|
47
|
+
* A user parameter shares those scopes with identifiers the SDK writes: its
|
|
48
|
+
* own `connection` and `props` parameters and locals, and names it cannot
|
|
49
|
+
* change — the route's function and namespace, which are public, and the
|
|
50
|
+
* imports, namespace members, and globals the bodies reference. Nothing kept
|
|
51
|
+
* them apart, so a parameter named like its method or `connection` produced
|
|
52
|
+
* an SDK that does not compile (#1647).
|
|
53
|
+
*
|
|
54
|
+
* The SDK's own identifiers are escaped with `_` prefixes, as it already
|
|
55
|
+
* escaped `output` and `variables`. A user parameter keeps its name, which an
|
|
56
|
+
* IDE shows and which is a `props` key in keyword mode, unless the name is
|
|
57
|
+
* one the SDK cannot change; then the positional parameter alone is renamed,
|
|
58
|
+
* which positional callers never see. The fixed names are only those the
|
|
59
|
+
* generated code actually references for this route and configuration, and an
|
|
60
|
+
* own identifier yields only to the names its scope can see, so nothing is
|
|
61
|
+
* renamed where no name is shadowed.
|
|
62
|
+
*
|
|
63
|
+
* @evidence contracts/common.md#principled-implementation One decision serves the three scopes, so they cannot disagree.
|
|
64
|
+
* @evidence contracts/common.md#clear-and-simple-design A record of names and two lookups.
|
|
65
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
|
|
66
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
67
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkHttpParameterProgrammer.INames composes SDK syntax, identifiers or import bindings; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
|
|
68
|
+
*/
|
|
69
|
+
export interface INames {
|
|
70
|
+
connection: string;
|
|
71
|
+
props: string;
|
|
72
|
+
output: string;
|
|
73
|
+
assert: string;
|
|
74
|
+
variables: string;
|
|
75
|
+
location: string;
|
|
76
|
+
key: string;
|
|
77
|
+
value: string;
|
|
78
|
+
elem: string;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Local identifier of a significant parameter in positional mode.
|
|
82
|
+
*
|
|
83
|
+
* @evidence contracts/common.md#principled-implementation A parameter yields to a name the SDK cannot change and keeps its own otherwise.
|
|
84
|
+
* @evidence contracts/common.md#clear-and-simple-design One lookup.
|
|
85
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It reads the decision.
|
|
86
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
87
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkHttpParameterProgrammer.INames.parameter composes SDK syntax, identifiers or import bindings; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
|
|
88
|
+
*/
|
|
89
|
+
parameter: (p: ITypedHttpRouteParameter) => string;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Reads a significant parameter: `props.<name>` or its local.
|
|
93
|
+
*
|
|
94
|
+
* @evidence contracts/common.md#principled-implementation The read follows the mode of the function.
|
|
95
|
+
* @evidence contracts/common.md#clear-and-simple-design One lookup.
|
|
96
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It reads the decision.
|
|
97
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
98
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkHttpParameterProgrammer.INames.access composes SDK syntax, identifiers or import bindings; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
|
|
99
|
+
*/
|
|
100
|
+
access: (p: ITypedHttpRouteParameter) => Expression;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Decides the identifiers of a route's function, `path()`, and `simulate()`
|
|
105
|
+
* once.
|
|
106
|
+
*
|
|
107
|
+
* @evidence contracts/common.md#principled-implementation The fixed names each scope references are collected, and every own identifier avoids them and the other own identifiers it can see.
|
|
108
|
+
* @evidence contracts/common.md#clear-and-simple-design One function over the scope sets.
|
|
109
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Only shadowed names are renamed.
|
|
110
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
111
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkHttpParameterProgrammer.getNames composes SDK syntax, identifiers or import bindings; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
|
|
112
|
+
*/
|
|
113
|
+
export const getNames = (props: {
|
|
114
|
+
project: INestiaProject;
|
|
115
|
+
route: ITypedHttpRoute;
|
|
116
|
+
}): INames => {
|
|
117
|
+
const { project, route } = props;
|
|
118
|
+
const parameters: ITypedHttpRouteParameter[] = getSignificant(route, true);
|
|
119
|
+
const simulate: boolean =
|
|
120
|
+
project.config.simulate === true && parameters.length !== 0;
|
|
121
|
+
|
|
122
|
+
// names each scope references and the SDK cannot change
|
|
123
|
+
const functional: string[] = [
|
|
124
|
+
route.name,
|
|
125
|
+
!!route.body?.encrypted || route.success.encrypted
|
|
126
|
+
? "EncryptedFetcher"
|
|
127
|
+
: "PlainFetcher",
|
|
128
|
+
...(project.config.assert === true ? ["typia"] : []),
|
|
129
|
+
...(route.success.setHeaders.some((h) => h.type === "assigner")
|
|
130
|
+
? ["Object"]
|
|
131
|
+
: []),
|
|
132
|
+
];
|
|
133
|
+
const path: string[] = [
|
|
134
|
+
...(route.pathParameters.length !== 0 ? ["PathParameter"] : []),
|
|
135
|
+
...(route.queryObject !== null || route.queryParameters.length !== 0
|
|
136
|
+
? ["URLSearchParams", "Object", "Array", "String", "undefined"]
|
|
137
|
+
: []),
|
|
138
|
+
];
|
|
139
|
+
const simulation: string[] = simulate
|
|
140
|
+
? ["NestiaSimulator", "METADATA", "path", "random", "typia"]
|
|
141
|
+
: [];
|
|
142
|
+
|
|
143
|
+
const locals: Map<ITypedHttpRouteParameter, string> = new Map();
|
|
144
|
+
if (project.config.keyword !== true)
|
|
145
|
+
for (const p of parameters)
|
|
146
|
+
locals.set(
|
|
147
|
+
p,
|
|
148
|
+
StringUtil.escapeDuplicate([
|
|
149
|
+
...functional,
|
|
150
|
+
...simulation,
|
|
151
|
+
...(p.category !== "body" ? path : []),
|
|
152
|
+
...parameters.filter((q) => q !== p).map((q) => q.name),
|
|
153
|
+
...locals.values(),
|
|
154
|
+
])(p.name),
|
|
155
|
+
);
|
|
156
|
+
// An SDK-own identifier avoids the fixed names and the other own ones of
|
|
157
|
+
// its scope, and the positional parameters whose values its scope reads
|
|
158
|
+
// where it is visible: the SDK function's and simulate()'s parameters and
|
|
159
|
+
// locals see every one; in path(), `variables` and `location` see its
|
|
160
|
+
// parameters, the loop's `key` and `value` the query values its header
|
|
161
|
+
// reads, and `elem` none.
|
|
162
|
+
const declared = (list: ITypedHttpRouteParameter[]): string[] =>
|
|
163
|
+
list
|
|
164
|
+
.map((p) => locals.get(p))
|
|
165
|
+
.filter((name): name is string => name !== undefined);
|
|
166
|
+
const queries: ITypedHttpRouteParameter[] = [
|
|
167
|
+
...route.queryParameters,
|
|
168
|
+
...(route.queryObject ? [route.queryObject] : []),
|
|
169
|
+
];
|
|
170
|
+
const own =
|
|
171
|
+
(fixed: string[], reads: string[], taken: string[]) =>
|
|
172
|
+
(name: string): string => {
|
|
173
|
+
const escaped: string = StringUtil.escapeDuplicate([
|
|
174
|
+
...fixed,
|
|
175
|
+
...reads,
|
|
176
|
+
...taken,
|
|
177
|
+
])(name);
|
|
178
|
+
taken.push(escaped);
|
|
179
|
+
return escaped;
|
|
180
|
+
};
|
|
181
|
+
const every: string[] = declared(parameters);
|
|
182
|
+
const shared: string[] = [];
|
|
183
|
+
const $props: string = own(
|
|
184
|
+
[...functional, ...path, ...simulation],
|
|
185
|
+
every,
|
|
186
|
+
shared,
|
|
187
|
+
)("props");
|
|
188
|
+
const $connection: string = own(
|
|
189
|
+
[...functional, ...simulation],
|
|
190
|
+
every,
|
|
191
|
+
shared,
|
|
192
|
+
)("connection");
|
|
193
|
+
const inPath: string[] = [...shared];
|
|
194
|
+
const names: Omit<INames, "parameter" | "access"> = {
|
|
195
|
+
props: $props,
|
|
196
|
+
connection: $connection,
|
|
197
|
+
output: own(functional, every, [...shared])("output"),
|
|
198
|
+
assert: own(simulation, every, [...shared])("assert"),
|
|
199
|
+
variables: own(
|
|
200
|
+
path,
|
|
201
|
+
declared([...route.pathParameters, ...queries]),
|
|
202
|
+
inPath,
|
|
203
|
+
)("variables"),
|
|
204
|
+
location: own(
|
|
205
|
+
path,
|
|
206
|
+
declared([...route.pathParameters, ...queries]),
|
|
207
|
+
inPath,
|
|
208
|
+
)("location"),
|
|
209
|
+
key: own(path, declared(queries), inPath)("key"),
|
|
210
|
+
value: own(path, declared(queries), inPath)("value"),
|
|
211
|
+
elem: own(path, [], inPath)("elem"),
|
|
212
|
+
};
|
|
213
|
+
return {
|
|
214
|
+
...names,
|
|
215
|
+
parameter: (p) => locals.get(p) ?? p.name,
|
|
216
|
+
access: (p) =>
|
|
217
|
+
project.config.keyword === true
|
|
218
|
+
? factory.createPropertyAccessExpression(
|
|
219
|
+
factory.createIdentifier(names.props),
|
|
220
|
+
p.name,
|
|
221
|
+
)
|
|
222
|
+
: factory.createIdentifier(locals.get(p) ?? p.name),
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Returns every parameter of a route: path, query, header, query object,
|
|
228
|
+
* body, and header object.
|
|
229
|
+
*
|
|
230
|
+
* @evidence contracts/common.md#principled-implementation The list is the concatenation in that order.
|
|
231
|
+
* @evidence contracts/common.md#clear-and-simple-design One list.
|
|
232
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It adds no parameter.
|
|
233
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
234
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkHttpParameterProgrammer.getAll composes SDK syntax, identifiers or import bindings; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
|
|
235
|
+
*/
|
|
17
236
|
export const getAll = (
|
|
18
237
|
route: ITypedHttpRoute,
|
|
19
238
|
): ITypedHttpRouteParameter[] => [
|
|
@@ -25,6 +244,16 @@ export namespace SdkHttpParameterProgrammer {
|
|
|
25
244
|
...(route.headerObject ? [route.headerObject] : []),
|
|
26
245
|
];
|
|
27
246
|
|
|
247
|
+
/**
|
|
248
|
+
* Returns the parameters that make up a call: path, query, the query object,
|
|
249
|
+
* and the body when asked.
|
|
250
|
+
*
|
|
251
|
+
* @evidence contracts/common.md#principled-implementation Headers travel in the connection and are not arguments.
|
|
252
|
+
* @evidence contracts/common.md#clear-and-simple-design One list.
|
|
253
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The body is included by the caller's choice.
|
|
254
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
255
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkHttpParameterProgrammer.getSignificant composes SDK syntax, identifiers or import bindings; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
|
|
256
|
+
*/
|
|
28
257
|
export const getSignificant = (route: ITypedHttpRoute, body: boolean) => [
|
|
29
258
|
...route.pathParameters,
|
|
30
259
|
...route.queryParameters,
|
|
@@ -32,6 +261,17 @@ export namespace SdkHttpParameterProgrammer {
|
|
|
32
261
|
...(body && route.body ? [route.body] : []),
|
|
33
262
|
];
|
|
34
263
|
|
|
264
|
+
/**
|
|
265
|
+
* Returns the entries of a route: path and query parameters, the query
|
|
266
|
+
* object, and the body when asked, with the type each has in the function or
|
|
267
|
+
* in the test.
|
|
268
|
+
*
|
|
269
|
+
* @evidence contracts/common.md#principled-implementation The type is the alias `Query` or `Body` in the function, and the reflected or cloned type in a test.
|
|
270
|
+
* @evidence contracts/common.md#clear-and-simple-design One list of three groups.
|
|
271
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts An empty route has no entries.
|
|
272
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
273
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkHttpParameterProgrammer.getEntries composes SDK syntax, identifiers or import bindings; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
|
|
274
|
+
*/
|
|
35
275
|
export const getEntries = (props: {
|
|
36
276
|
project: INestiaProject;
|
|
37
277
|
importer: ImportDictionary;
|
|
@@ -104,6 +344,16 @@ export namespace SdkHttpParameterProgrammer {
|
|
|
104
344
|
];
|
|
105
345
|
};
|
|
106
346
|
|
|
347
|
+
/**
|
|
348
|
+
* Returns the parameter declarations of a route's function: one `props`
|
|
349
|
+
* object in keyword mode, and one positional parameter per entry otherwise.
|
|
350
|
+
*
|
|
351
|
+
* @evidence contracts/common.md#principled-implementation A required parameter cannot follow an optional one, so an optional one before a required one trades its `?` for `undefined` in its type.
|
|
352
|
+
* @evidence contracts/common.md#clear-and-simple-design One function of two modes.
|
|
353
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The names come from `getNames`.
|
|
354
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
355
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkHttpParameterProgrammer.getParameterDeclarations composes SDK syntax, identifiers or import bindings; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
|
|
356
|
+
*/
|
|
107
357
|
export const getParameterDeclarations = (props: {
|
|
108
358
|
project: INestiaProject;
|
|
109
359
|
importer: ImportDictionary;
|
|
@@ -113,7 +363,8 @@ export namespace SdkHttpParameterProgrammer {
|
|
|
113
363
|
}): Node[] => {
|
|
114
364
|
const entries: IEntry[] = getEntries(props);
|
|
115
365
|
if (entries.length === 0) return [];
|
|
116
|
-
|
|
366
|
+
const names: INames = getNames(props);
|
|
367
|
+
if (props.project.config.keyword === true) {
|
|
117
368
|
const typeName: string = props.prefix
|
|
118
369
|
? `${props.route.name}.Props`
|
|
119
370
|
: "Props";
|
|
@@ -130,25 +381,55 @@ export namespace SdkHttpParameterProgrammer {
|
|
|
130
381
|
factory.createParameterDeclaration(
|
|
131
382
|
undefined,
|
|
132
383
|
undefined,
|
|
133
|
-
|
|
384
|
+
names.props,
|
|
134
385
|
undefined,
|
|
135
386
|
node,
|
|
136
387
|
undefined,
|
|
137
388
|
),
|
|
138
389
|
];
|
|
139
390
|
}
|
|
140
|
-
|
|
141
|
-
|
|
391
|
+
// a required parameter cannot follow an optional one (TS1016), so an
|
|
392
|
+
// optional parameter before a required one trades its `?` for `undefined`
|
|
393
|
+
// in its type
|
|
394
|
+
return entries.map((e, i) => {
|
|
395
|
+
const trailing: boolean =
|
|
396
|
+
e.required === false &&
|
|
397
|
+
entries.slice(i + 1).every((next) => next.required === false);
|
|
398
|
+
return factory.createParameterDeclaration(
|
|
142
399
|
undefined,
|
|
143
400
|
undefined,
|
|
144
|
-
e.
|
|
145
|
-
|
|
146
|
-
e.type,
|
|
401
|
+
names.parameter(e.parameter),
|
|
402
|
+
trailing ? factory.createToken(SyntaxKind.QuestionToken) : undefined,
|
|
403
|
+
e.required || trailing ? e.type : undefinable(props.project, e),
|
|
147
404
|
undefined,
|
|
148
|
-
)
|
|
149
|
-
);
|
|
405
|
+
);
|
|
406
|
+
});
|
|
150
407
|
};
|
|
151
408
|
|
|
409
|
+
// a cloned field's type admits `undefined` when optional, and a reflected
|
|
410
|
+
// field's does when its name says so (`mode: string | undefined`, not
|
|
411
|
+
// `mode?: string`); the `Query` and `Body` aliases are not inspected
|
|
412
|
+
const undefinable = (project: INestiaProject, e: IEntry): TypeNode =>
|
|
413
|
+
e.parameter.category !== "body" &&
|
|
414
|
+
e.parameter.field !== null &&
|
|
415
|
+
(project.config.clone === true ||
|
|
416
|
+
e.parameter.type.name.split("|").some((t) => t.trim() === "undefined"))
|
|
417
|
+
? e.type
|
|
418
|
+
: factory.createUnionTypeNode([
|
|
419
|
+
e.type,
|
|
420
|
+
factory.createKeywordTypeNode(SyntaxKind.UndefinedKeyword),
|
|
421
|
+
]);
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* Returns the arguments to call a route's function with: the `props` object
|
|
425
|
+
* in keyword mode, and the parameters otherwise.
|
|
426
|
+
*
|
|
427
|
+
* @evidence contracts/common.md#principled-implementation The identifiers are those declared by `getNames`.
|
|
428
|
+
* @evidence contracts/common.md#clear-and-simple-design One function of two modes.
|
|
429
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts No argument is invented for an empty route.
|
|
430
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
431
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkHttpParameterProgrammer.getArguments composes SDK syntax, identifiers or import bindings; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
|
|
432
|
+
*/
|
|
152
433
|
export const getArguments = (props: {
|
|
153
434
|
project: INestiaProject;
|
|
154
435
|
route: ITypedHttpRoute;
|
|
@@ -156,8 +437,9 @@ export namespace SdkHttpParameterProgrammer {
|
|
|
156
437
|
}): Node[] => {
|
|
157
438
|
const parameters = getSignificant(props.route, props.body);
|
|
158
439
|
if (parameters.length === 0) return [];
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
440
|
+
const names: INames = getNames(props);
|
|
441
|
+
if (props.project.config.keyword === true)
|
|
442
|
+
return [factory.createIdentifier(names.props)];
|
|
443
|
+
return parameters.map((p) => factory.createIdentifier(names.parameter(p)));
|
|
162
444
|
};
|
|
163
445
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { type Node } from "@ttsc/factory";
|
|
2
2
|
import { IJsDocTagInfo } from "typia";
|
|
3
3
|
|
|
4
|
-
import { INestiaConfig } from "../../INestiaConfig";
|
|
5
4
|
import { INestiaProject } from "../../structures/INestiaProject";
|
|
6
5
|
import { ITypedHttpRoute } from "../../structures/ITypedHttpRoute";
|
|
7
6
|
import { FilePrinter } from "./FilePrinter";
|
|
@@ -10,19 +9,44 @@ import { SdkHttpFunctionProgrammer } from "./SdkHttpFunctionProgrammer";
|
|
|
10
9
|
import { SdkHttpNamespaceProgrammer } from "./SdkHttpNamespaceProgrammer";
|
|
11
10
|
import { SdkHttpParameterProgrammer } from "./SdkHttpParameterProgrammer";
|
|
12
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Writes an HTTP route into the SDK: its function and its namespace.
|
|
14
|
+
*
|
|
15
|
+
* @evidence contracts/common.md#principled-implementation The namespace pairs the two declarations and describes the function.
|
|
16
|
+
* @evidence contracts/common.md#clear-and-simple-design One public function and one description helper.
|
|
17
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The description is from the route's own comment.
|
|
18
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
19
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkHttpRouteProgrammer composes SDK syntax, identifiers or import bindings; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
|
|
20
|
+
*/
|
|
13
21
|
export namespace SdkHttpRouteProgrammer {
|
|
22
|
+
/**
|
|
23
|
+
* Returns the function and the namespace of a route, the function carrying
|
|
24
|
+
* the route's description, `@param`, and exception tags, and a `@nestia`
|
|
25
|
+
* postfix.
|
|
26
|
+
*
|
|
27
|
+
* @evidence contracts/common.md#principled-implementation The two nodes share the identifiers of one decision.
|
|
28
|
+
* @evidence contracts/common.md#clear-and-simple-design One function.
|
|
29
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The description keeps the names the function declares.
|
|
30
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
31
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkHttpRouteProgrammer.write composes SDK syntax, identifiers or import bindings; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
|
|
32
|
+
*/
|
|
14
33
|
export const write =
|
|
15
34
|
(project: INestiaProject) =>
|
|
16
35
|
(importer: ImportDictionary) =>
|
|
17
36
|
(route: ITypedHttpRoute): Node[] => [
|
|
18
37
|
FilePrinter.description(
|
|
19
38
|
SdkHttpFunctionProgrammer.write(project)(importer)(route),
|
|
20
|
-
describe(project
|
|
39
|
+
describe(project, route),
|
|
21
40
|
),
|
|
22
41
|
SdkHttpNamespaceProgrammer.write(project)(importer)(route),
|
|
23
42
|
];
|
|
24
43
|
|
|
25
|
-
const describe = (
|
|
44
|
+
const describe = (
|
|
45
|
+
project: INestiaProject,
|
|
46
|
+
route: ITypedHttpRoute,
|
|
47
|
+
): string => {
|
|
48
|
+
const names: SdkHttpParameterProgrammer.INames =
|
|
49
|
+
SdkHttpParameterProgrammer.getNames({ project, route });
|
|
26
50
|
// MAIN DESCRIPTION
|
|
27
51
|
const descriptionComments: string[] = route.description
|
|
28
52
|
? route.description.split("\n")
|
|
@@ -37,23 +61,15 @@ export namespace SdkHttpRouteProgrammer {
|
|
|
37
61
|
?.text ??
|
|
38
62
|
route.jsDocTags
|
|
39
63
|
.find((tag) => tag.name === "param" && tag.text?.[0]?.text === p.name)
|
|
40
|
-
?.text?.
|
|
41
|
-
.join("")
|
|
42
|
-
.substring(p.name.length);
|
|
64
|
+
?.text?.find((e) => e.kind === "text")?.text;
|
|
43
65
|
if (!description?.length) continue;
|
|
44
66
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (i === 0) return str;
|
|
52
|
-
const rpad: number = p.name.length + 8;
|
|
53
|
-
return `${" ".repeat(rpad)}${str}`;
|
|
54
|
-
})
|
|
55
|
-
.join("\n")}`,
|
|
56
|
-
);
|
|
67
|
+
// the name the SDK function declares, which yields on a collision
|
|
68
|
+
const name: string =
|
|
69
|
+
project.config.keyword === true
|
|
70
|
+
? `${names.props}.${p.name}`
|
|
71
|
+
: names.parameter(p);
|
|
72
|
+
tagComments.push(FilePrinter.jsDocTag(`param ${name}`, description));
|
|
57
73
|
}
|
|
58
74
|
|
|
59
75
|
// COMMENT TAGS
|
|
@@ -62,18 +78,7 @@ export namespace SdkHttpRouteProgrammer {
|
|
|
62
78
|
);
|
|
63
79
|
if (tags.length !== 0) {
|
|
64
80
|
const content: string[] = tags.map((t) =>
|
|
65
|
-
t.text?.
|
|
66
|
-
? `@${t.name} ${t.text
|
|
67
|
-
.map((e) => e.text)
|
|
68
|
-
.join("")
|
|
69
|
-
.split("\n")
|
|
70
|
-
.map((str) => str.trim())
|
|
71
|
-
.map((str, i) => {
|
|
72
|
-
if (i === 0) return str;
|
|
73
|
-
return `${" ".repeat(t.name.length + 1)} ${str}`;
|
|
74
|
-
})
|
|
75
|
-
.join("\n")}`
|
|
76
|
-
: `@${t.name}`,
|
|
81
|
+
FilePrinter.jsDocTag(t.name, t.text?.map((e) => e.text).join("") ?? ""),
|
|
77
82
|
);
|
|
78
83
|
tagComments.push(...new Set(content));
|
|
79
84
|
}
|
|
@@ -100,7 +105,8 @@ export namespace SdkHttpRouteProgrammer {
|
|
|
100
105
|
...(descriptionComments.length && tagComments.length ? [""] : []),
|
|
101
106
|
...tagComments,
|
|
102
107
|
...(descriptionComments.length && tagComments.length ? [""] : []),
|
|
103
|
-
|
|
108
|
+
// the public name, kept by a route declared under a local one
|
|
109
|
+
`@controller ${route.controller.class.name}.${route.key}`,
|
|
104
110
|
`@path ${route.method} ${route.path}`,
|
|
105
111
|
`@accessor api.functional.${route.accessor.join(".")}`,
|
|
106
112
|
`@nestia Generated by Nestia - https://github.com/samchon/nestia`,
|