@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,13 +1,37 @@
|
|
|
1
|
+
import { TsPrinter } from "@ttsc/factory";
|
|
2
|
+
|
|
1
3
|
import { MetadataSchema, nameOf } from "../../internal/legacy";
|
|
4
|
+
import { INestiaProject } from "../../structures/INestiaProject";
|
|
2
5
|
import { IReflectType } from "../../structures/IReflectType";
|
|
3
6
|
import { ITypedApplication } from "../../structures/ITypedApplication";
|
|
4
7
|
import { ITypedHttpRoute } from "../../structures/ITypedHttpRoute";
|
|
8
|
+
import { ITypedMcpRoute } from "../../structures/ITypedMcpRoute";
|
|
5
9
|
import { ITypedWebSocketRoute } from "../../structures/ITypedWebSocketRoute";
|
|
6
|
-
import {
|
|
10
|
+
import { ImportDictionary } from "./ImportDictionary";
|
|
7
11
|
import { SdkHttpParameterProgrammer } from "./SdkHttpParameterProgrammer";
|
|
12
|
+
import { SdkTypeProgrammer } from "./SdkTypeProgrammer";
|
|
8
13
|
import { SdkWebSocketCloneProgrammer } from "./SdkWebSocketCloneProgrammer";
|
|
9
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Rewrites the routes to refer to the cloned DTOs.
|
|
17
|
+
*
|
|
18
|
+
* @evidence contracts/common.md#principled-implementation HTTP and MCP JSON types and their namespace/tag imports are emitted together from resolved metadata by the cloned declaration writer; WebSocket declarations retain their source types and redirect only cloned imports.
|
|
19
|
+
* @evidence contracts/common.md#clear-and-simple-design One public function and three visitors.
|
|
20
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The routes are rewritten in place, once.
|
|
21
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
22
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkHttpCloneReferencer 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.
|
|
23
|
+
*/
|
|
10
24
|
export namespace SdkHttpCloneReferencer {
|
|
25
|
+
/**
|
|
26
|
+
* Rewrites the HTTP, MCP and WebSocket routes so their types and imports
|
|
27
|
+
* refer to the `structures` files.
|
|
28
|
+
*
|
|
29
|
+
* @evidence contracts/common.md#principled-implementation HTTP and MCP JSON routes use structural TypeNodes and the writer's registered imports. Empty and any/unknown forms retain their baked keyword distinction because they require no cloned component binding; WebSocket source types only redirect imports actually cloned.
|
|
30
|
+
* @evidence contracts/common.md#clear-and-simple-design One loop.
|
|
31
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The routes are edited in place, as the generation owns them.
|
|
32
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
33
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkHttpCloneReferencer.replace 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.
|
|
34
|
+
*/
|
|
11
35
|
export const replace = (
|
|
12
36
|
app: ITypedApplication,
|
|
13
37
|
websocket: Set<string> = new Set(),
|
|
@@ -16,7 +40,7 @@ export namespace SdkHttpCloneReferencer {
|
|
|
16
40
|
for (const route of app.routes)
|
|
17
41
|
if (route.protocol === "http")
|
|
18
42
|
visitHttpRoute({
|
|
19
|
-
|
|
43
|
+
project: app.project,
|
|
20
44
|
route,
|
|
21
45
|
});
|
|
22
46
|
else if (route.protocol === "websocket")
|
|
@@ -25,43 +49,70 @@ export namespace SdkHttpCloneReferencer {
|
|
|
25
49
|
directory,
|
|
26
50
|
route,
|
|
27
51
|
});
|
|
52
|
+
else if (route.protocol === "mcp") visitMcpRoute(app.project, route);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const visitMcpRoute = (
|
|
56
|
+
project: INestiaProject,
|
|
57
|
+
route: ITypedMcpRoute,
|
|
58
|
+
): void => {
|
|
59
|
+
const importer = new ImportDictionary(
|
|
60
|
+
`${project.config.output}/functional/${route.accessor.join("/")}/index.ts`,
|
|
61
|
+
);
|
|
62
|
+
if (route.input && route.inputMetadata)
|
|
63
|
+
visitType({
|
|
64
|
+
importer,
|
|
65
|
+
project,
|
|
66
|
+
metadata: route.inputMetadata,
|
|
67
|
+
type: route.input.type,
|
|
68
|
+
name: (name) => (route.input!.type = { name }),
|
|
69
|
+
});
|
|
70
|
+
if (route.returnType && route.outputMetadata)
|
|
71
|
+
visitType({
|
|
72
|
+
importer,
|
|
73
|
+
project,
|
|
74
|
+
metadata: route.outputMetadata,
|
|
75
|
+
type: route.returnType,
|
|
76
|
+
name: (name) => (route.returnType = { name }),
|
|
77
|
+
});
|
|
78
|
+
route.imports = importer.toImports();
|
|
28
79
|
};
|
|
29
80
|
|
|
30
81
|
const visitHttpRoute = (props: {
|
|
31
|
-
|
|
82
|
+
project: INestiaProject;
|
|
32
83
|
route: ITypedHttpRoute;
|
|
33
84
|
}): void => {
|
|
34
|
-
const
|
|
85
|
+
const importer = new ImportDictionary(
|
|
86
|
+
`${props.project.config.output}/functional/${props.route.accessor.join("/")}/index.ts`,
|
|
87
|
+
);
|
|
35
88
|
for (const p of SdkHttpParameterProgrammer.getSignificant(
|
|
36
89
|
props.route,
|
|
37
90
|
true,
|
|
38
91
|
))
|
|
39
92
|
visitType({
|
|
40
|
-
|
|
93
|
+
importer,
|
|
94
|
+
project: props.project,
|
|
41
95
|
metadata: p.metadata,
|
|
42
96
|
type: p.type,
|
|
43
97
|
name: (name) => (p.type = { name }),
|
|
44
98
|
});
|
|
45
99
|
for (const v of Object.values(props.route.exceptions))
|
|
46
100
|
visitType({
|
|
47
|
-
|
|
101
|
+
importer,
|
|
102
|
+
project: props.project,
|
|
48
103
|
metadata: v.metadata,
|
|
49
104
|
type: v.type,
|
|
50
105
|
name: (name) => (v.type = { name }),
|
|
51
106
|
});
|
|
52
107
|
if (props.route.success.binary === false)
|
|
53
108
|
visitType({
|
|
54
|
-
|
|
109
|
+
importer,
|
|
110
|
+
project: props.project,
|
|
55
111
|
metadata: props.route.success.metadata,
|
|
56
112
|
type: props.route.success.type,
|
|
57
113
|
name: (name) => (props.route.success.type = { name }),
|
|
58
114
|
});
|
|
59
|
-
props.route.imports =
|
|
60
|
-
file: `${props.directory}/${str}`,
|
|
61
|
-
asterisk: null,
|
|
62
|
-
default: null,
|
|
63
|
-
elements: [str],
|
|
64
|
-
}));
|
|
115
|
+
props.route.imports = importer.toImports();
|
|
65
116
|
};
|
|
66
117
|
|
|
67
118
|
const visitWebSocketRoute = (props: {
|
|
@@ -113,20 +164,43 @@ export namespace SdkHttpCloneReferencer {
|
|
|
113
164
|
};
|
|
114
165
|
|
|
115
166
|
const visitType = (p: {
|
|
116
|
-
|
|
167
|
+
importer: ImportDictionary;
|
|
168
|
+
project: INestiaProject;
|
|
117
169
|
metadata: MetadataSchema;
|
|
118
170
|
type: IReflectType;
|
|
119
171
|
name: (key: string) => void;
|
|
120
172
|
}): void => {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
173
|
+
// Empty and any/unknown metadata carries no structural declaration from
|
|
174
|
+
// which to recover its source-level keyword distinction. These forms require
|
|
175
|
+
// no cloned component binding; retain the producer's baked name (or declared
|
|
176
|
+
// route type for authored metadata without a bake).
|
|
177
|
+
if (
|
|
178
|
+
p.metadata.any ||
|
|
179
|
+
(p.metadata.nullable === false &&
|
|
180
|
+
p.metadata.escaped === null &&
|
|
181
|
+
p.metadata.rest === null &&
|
|
182
|
+
[
|
|
183
|
+
p.metadata.atomics,
|
|
184
|
+
p.metadata.constants,
|
|
185
|
+
p.metadata.templates,
|
|
186
|
+
p.metadata.arrays,
|
|
187
|
+
p.metadata.tuples,
|
|
188
|
+
p.metadata.objects,
|
|
189
|
+
p.metadata.aliases,
|
|
190
|
+
p.metadata.natives,
|
|
191
|
+
p.metadata.sets,
|
|
192
|
+
p.metadata.maps,
|
|
193
|
+
p.metadata.functions,
|
|
194
|
+
].every((members) => members.length === 0))
|
|
195
|
+
) {
|
|
196
|
+
p.name(nameOf(p.metadata) || getFullText(p.type));
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
p.name(
|
|
200
|
+
new TsPrinter().print(
|
|
201
|
+
SdkTypeProgrammer.write(p.project)(p.importer)(p.metadata),
|
|
202
|
+
),
|
|
203
|
+
);
|
|
130
204
|
};
|
|
131
205
|
}
|
|
132
206
|
|
|
@@ -15,17 +15,37 @@ import { TypeFactory } from "../../factories/TypeFactory";
|
|
|
15
15
|
import { sizeOf } from "../../internal/legacy";
|
|
16
16
|
import { INestiaProject } from "../../structures/INestiaProject";
|
|
17
17
|
import { ITypedHttpRoute } from "../../structures/ITypedHttpRoute";
|
|
18
|
-
import { StringUtil } from "../../utils/StringUtil";
|
|
19
18
|
import { ImportDictionary } from "./ImportDictionary";
|
|
20
19
|
import { SdkAliasCollection } from "./SdkAliasCollection";
|
|
21
20
|
import { SdkHttpParameterProgrammer } from "./SdkHttpParameterProgrammer";
|
|
22
21
|
import { SdkImportWizard } from "./SdkImportWizard";
|
|
23
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Writes the function of an HTTP route.
|
|
25
|
+
*
|
|
26
|
+
* @evidence contracts/common.md#principled-implementation The namespace prints the exported async function with its parameters and the fetcher call and its headers.
|
|
27
|
+
* @evidence contracts/common.md#clear-and-simple-design One public function and the body writers.
|
|
28
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The names come from the parameter programmer.
|
|
29
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
30
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkHttpFunctionProgrammer 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.
|
|
31
|
+
*/
|
|
24
32
|
export namespace SdkHttpFunctionProgrammer {
|
|
33
|
+
/**
|
|
34
|
+
* Returns the exported async function of a route: `connection`, then the
|
|
35
|
+
* parameters, returning the output or `void`.
|
|
36
|
+
*
|
|
37
|
+
* @evidence contracts/common.md#principled-implementation The identifiers were decided once by the parameter programmer, and the body calls the plain or the encrypted fetcher.
|
|
38
|
+
* @evidence contracts/common.md#clear-and-simple-design One declaration built from the parameter and body helpers.
|
|
39
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The function uses the route's assigned name; SdkFileProgrammer may assign a private binding and export it under the public accessor when the module scope collides.
|
|
40
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
41
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkHttpFunctionProgrammer.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.
|
|
42
|
+
*/
|
|
25
43
|
export const write =
|
|
26
44
|
(project: INestiaProject) =>
|
|
27
45
|
(importer: ImportDictionary) =>
|
|
28
46
|
(route: ITypedHttpRoute): Node => {
|
|
47
|
+
const names: SdkHttpParameterProgrammer.INames =
|
|
48
|
+
SdkHttpParameterProgrammer.getNames({ project, route });
|
|
29
49
|
return factory.createFunctionDeclaration(
|
|
30
50
|
[
|
|
31
51
|
factory.createModifier(SyntaxKind.ExportKeyword),
|
|
@@ -36,7 +56,7 @@ export namespace SdkHttpFunctionProgrammer {
|
|
|
36
56
|
undefined,
|
|
37
57
|
[
|
|
38
58
|
IdentifierFactory.parameter(
|
|
39
|
-
|
|
59
|
+
names.connection,
|
|
40
60
|
factory.createTypeReferenceNode(
|
|
41
61
|
SdkImportWizard.IConnection(importer),
|
|
42
62
|
route.headerObject !== null
|
|
@@ -59,21 +79,15 @@ export namespace SdkHttpFunctionProgrammer {
|
|
|
59
79
|
? factory.createTypeReferenceNode(`${route.name}.Output`)
|
|
60
80
|
: factory.createTypeReferenceNode("void"),
|
|
61
81
|
]),
|
|
62
|
-
factory.createBlock(writeBody(project)(importer)(route), true),
|
|
82
|
+
factory.createBlock(writeBody(project)(importer)(route)(names), true),
|
|
63
83
|
);
|
|
64
84
|
};
|
|
65
85
|
|
|
66
86
|
const writeBody =
|
|
67
87
|
(project: INestiaProject) =>
|
|
68
88
|
(importer: ImportDictionary) =>
|
|
69
|
-
(route: ITypedHttpRoute)
|
|
70
|
-
|
|
71
|
-
project.config.keyword === true
|
|
72
|
-
? factory.createPropertyAccessExpression(
|
|
73
|
-
factory.createIdentifier("props"),
|
|
74
|
-
name,
|
|
75
|
-
)
|
|
76
|
-
: factory.createIdentifier(name);
|
|
89
|
+
(route: ITypedHttpRoute) =>
|
|
90
|
+
(names: SdkHttpParameterProgrammer.INames): Statement[] => {
|
|
77
91
|
const fetch = () =>
|
|
78
92
|
factory.createCallExpression(
|
|
79
93
|
IdentifierFactory.access(
|
|
@@ -95,7 +109,7 @@ export namespace SdkHttpFunctionProgrammer {
|
|
|
95
109
|
? factory.createObjectLiteralExpression(
|
|
96
110
|
[
|
|
97
111
|
factory.createSpreadAssignment(
|
|
98
|
-
factory.createIdentifier(
|
|
112
|
+
factory.createIdentifier(names.connection),
|
|
99
113
|
),
|
|
100
114
|
factory.createPropertyAssignment(
|
|
101
115
|
"headers",
|
|
@@ -103,7 +117,7 @@ export namespace SdkHttpFunctionProgrammer {
|
|
|
103
117
|
[
|
|
104
118
|
factory.createSpreadAssignment(
|
|
105
119
|
IdentifierFactory.access(
|
|
106
|
-
factory.createIdentifier(
|
|
120
|
+
factory.createIdentifier(names.connection),
|
|
107
121
|
"headers",
|
|
108
122
|
),
|
|
109
123
|
),
|
|
@@ -120,7 +134,7 @@ export namespace SdkHttpFunctionProgrammer {
|
|
|
120
134
|
],
|
|
121
135
|
true,
|
|
122
136
|
)
|
|
123
|
-
: factory.createIdentifier(
|
|
137
|
+
: factory.createIdentifier(names.connection),
|
|
124
138
|
factory.createObjectLiteralExpression(
|
|
125
139
|
[
|
|
126
140
|
factory.createSpreadAssignment(
|
|
@@ -157,7 +171,7 @@ export namespace SdkHttpFunctionProgrammer {
|
|
|
157
171
|
],
|
|
158
172
|
true,
|
|
159
173
|
),
|
|
160
|
-
...(route.body ? [access(route.body
|
|
174
|
+
...(route.body ? [names.access(route.body)] : []),
|
|
161
175
|
...(project.config.json &&
|
|
162
176
|
route.body !== null &&
|
|
163
177
|
(route.body.contentType === "application/json" ||
|
|
@@ -171,14 +185,17 @@ export namespace SdkHttpFunctionProgrammer {
|
|
|
171
185
|
? factory.createConditionalExpression(
|
|
172
186
|
factory.createStrictEquality(
|
|
173
187
|
factory.createTrue(),
|
|
174
|
-
|
|
188
|
+
IdentifierFactory.access(
|
|
189
|
+
factory.createIdentifier(names.connection),
|
|
190
|
+
"simulate",
|
|
191
|
+
),
|
|
175
192
|
),
|
|
176
193
|
undefined,
|
|
177
194
|
factory.createCallExpression(
|
|
178
195
|
factory.createIdentifier(`${route.name}.simulate`),
|
|
179
196
|
[],
|
|
180
197
|
[
|
|
181
|
-
factory.createIdentifier(
|
|
198
|
+
factory.createIdentifier(names.connection),
|
|
182
199
|
...(SdkHttpParameterProgrammer.getArguments({
|
|
183
200
|
project,
|
|
184
201
|
route,
|
|
@@ -201,15 +218,15 @@ export namespace SdkHttpFunctionProgrammer {
|
|
|
201
218
|
factory.createIdentifier(SdkImportWizard.typia(importer)),
|
|
202
219
|
"assert",
|
|
203
220
|
),
|
|
204
|
-
[factory.createTypeQueryNode(access(p
|
|
205
|
-
[access(p
|
|
221
|
+
[factory.createTypeQueryNode(names.access(p) as EntityName)],
|
|
222
|
+
[names.access(p)],
|
|
206
223
|
),
|
|
207
224
|
),
|
|
208
225
|
)
|
|
209
226
|
: []),
|
|
210
227
|
...(route.success.setHeaders.length === 0
|
|
211
228
|
? [factory.createReturnStatement(output(false))]
|
|
212
|
-
: writeSetHeaders(project)(importer)(route)(output(true))),
|
|
229
|
+
: writeSetHeaders(project)(importer)(route)(names)(output(true))),
|
|
213
230
|
];
|
|
214
231
|
};
|
|
215
232
|
|
|
@@ -217,16 +234,12 @@ export namespace SdkHttpFunctionProgrammer {
|
|
|
217
234
|
(project: INestiaProject) =>
|
|
218
235
|
(importer: ImportDictionary) =>
|
|
219
236
|
(route: ITypedHttpRoute) =>
|
|
237
|
+
(names: SdkHttpParameterProgrammer.INames) =>
|
|
220
238
|
(condition: Expression): Statement[] => {
|
|
221
239
|
const accessor = (x: string) => (y: string) =>
|
|
222
240
|
x[0] === "[" ? `${x}${y}` : `${x}.${y}`;
|
|
223
|
-
const output: string =
|
|
224
|
-
|
|
225
|
-
...SdkHttpParameterProgrammer.getSignificant(route, true).map(
|
|
226
|
-
(p) => p.name,
|
|
227
|
-
),
|
|
228
|
-
])("output");
|
|
229
|
-
const headers: string = accessor("connection")("headers");
|
|
241
|
+
const output: string = names.output;
|
|
242
|
+
const headers: string = accessor(names.connection)("headers");
|
|
230
243
|
const data: string = project.config.propagate
|
|
231
244
|
? accessor(output)("data")
|
|
232
245
|
: output;
|
|
@@ -248,9 +261,13 @@ export namespace SdkHttpFunctionProgrammer {
|
|
|
248
261
|
],
|
|
249
262
|
)
|
|
250
263
|
: factory.createBinaryExpression(
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
264
|
+
// a target is a header name, which usually is no identifier
|
|
265
|
+
tuple.target !== undefined
|
|
266
|
+
? IdentifierFactory.access(
|
|
267
|
+
factory.createIdentifier(headers),
|
|
268
|
+
tuple.target,
|
|
269
|
+
)
|
|
270
|
+
: factory.createIdentifier(accessor(headers)(tuple.source)),
|
|
254
271
|
factory.createToken(SyntaxKind.EqualsToken),
|
|
255
272
|
factory.createIdentifier(accessor(data)(tuple.source)),
|
|
256
273
|
),
|
|
@@ -24,8 +24,28 @@ import { SdkAliasCollection } from "./SdkAliasCollection";
|
|
|
24
24
|
import { SdkHttpParameterProgrammer } from "./SdkHttpParameterProgrammer";
|
|
25
25
|
import { SdkHttpSimulationProgrammer } from "./SdkHttpSimulationProgrammer";
|
|
26
26
|
import { SdkImportWizard } from "./SdkImportWizard";
|
|
27
|
+
import { SdkPathTemplate } from "./SdkPathTemplate";
|
|
27
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Writes the namespace of an HTTP route.
|
|
31
|
+
*
|
|
32
|
+
* @evidence contracts/common.md#principled-implementation The namespace holds the route's types, its metadata, its path builder, and, when configured, its random, simulate, and stringify functions.
|
|
33
|
+
* @evidence contracts/common.md#clear-and-simple-design One public function and four writers.
|
|
34
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The parts follow the configuration.
|
|
35
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
36
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkHttpNamespaceProgrammer 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.
|
|
37
|
+
*/
|
|
28
38
|
export namespace SdkHttpNamespaceProgrammer {
|
|
39
|
+
/**
|
|
40
|
+
* Returns the namespace of a route: its types, `METADATA`, `path`, and, by
|
|
41
|
+
* configuration, `random`, `simulate`, and `stringify`.
|
|
42
|
+
*
|
|
43
|
+
* @evidence contracts/common.md#principled-implementation `stringify` exists only for a JSON or encrypted body when `json` is on, and the simulator only when `simulate` is on.
|
|
44
|
+
* @evidence contracts/common.md#clear-and-simple-design One declaration composed of the writers.
|
|
45
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The optional members follow the flags.
|
|
46
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
47
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkHttpNamespaceProgrammer.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.
|
|
48
|
+
*/
|
|
29
49
|
export const write =
|
|
30
50
|
(project: INestiaProject) =>
|
|
31
51
|
(importer: ImportDictionary) =>
|
|
@@ -210,59 +230,28 @@ export namespace SdkHttpNamespaceProgrammer {
|
|
|
210
230
|
false,
|
|
211
231
|
);
|
|
212
232
|
if (parameters.length === 0)
|
|
213
|
-
return out(
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
const split: string[] = route.path.split(":");
|
|
219
|
-
if (split.length === 1) return factory.createStringLiteral(route.path);
|
|
220
|
-
return factory.createTemplateExpression(
|
|
221
|
-
factory.createTemplateHead(split[0]!),
|
|
222
|
-
split.slice(1).map((s, i, arr) => {
|
|
223
|
-
const name: string = s.split("/")[0]!;
|
|
224
|
-
return factory.createTemplateSpan(
|
|
225
|
-
factory.createCallExpression(
|
|
226
|
-
factory.createIdentifier("encodeURIComponent"),
|
|
227
|
-
undefined,
|
|
228
|
-
[
|
|
229
|
-
factory.createBinaryExpression(
|
|
230
|
-
factory.createCallChain(
|
|
231
|
-
factory.createPropertyAccessChain(
|
|
232
|
-
factory.createIdentifier(
|
|
233
|
-
access(
|
|
234
|
-
route.pathParameters.find((p) => p.field === name)!
|
|
235
|
-
.name,
|
|
236
|
-
),
|
|
237
|
-
),
|
|
238
|
-
factory.createToken(SyntaxKind.QuestionDotToken),
|
|
239
|
-
"toString",
|
|
240
|
-
),
|
|
241
|
-
undefined,
|
|
242
|
-
undefined,
|
|
243
|
-
[],
|
|
244
|
-
),
|
|
245
|
-
factory.createToken(SyntaxKind.QuestionQuestionToken),
|
|
246
|
-
factory.createStringLiteral("null"),
|
|
247
|
-
),
|
|
248
|
-
],
|
|
249
|
-
),
|
|
250
|
-
(i !== arr.length - 1
|
|
251
|
-
? factory.createTemplateMiddle
|
|
252
|
-
: factory.createTemplateTail)(s.substring(name.length)),
|
|
253
|
-
);
|
|
233
|
+
return out(
|
|
234
|
+
SdkPathTemplate.compose({
|
|
235
|
+
importer,
|
|
236
|
+
path: route.path,
|
|
237
|
+
argument: () => factory.createIdentifier("undefined"),
|
|
254
238
|
}),
|
|
255
239
|
);
|
|
256
|
-
|
|
240
|
+
|
|
241
|
+
const names: SdkHttpParameterProgrammer.INames =
|
|
242
|
+
SdkHttpParameterProgrammer.getNames({ project, route });
|
|
243
|
+
const template = () =>
|
|
244
|
+
SdkPathTemplate.compose({
|
|
245
|
+
importer,
|
|
246
|
+
path: route.path,
|
|
247
|
+
argument: (name) =>
|
|
248
|
+
names.access(route.pathParameters.find((p) => p.field === name)!),
|
|
249
|
+
});
|
|
257
250
|
if (route.queryObject === null && route.queryParameters.length === 0)
|
|
258
251
|
return out(template());
|
|
259
252
|
|
|
260
253
|
const block = (expr: Expression) => {
|
|
261
|
-
const
|
|
262
|
-
parameters.find((p) => p.name === str) !== undefined
|
|
263
|
-
? computeName("_" + str)
|
|
264
|
-
: str;
|
|
265
|
-
const variables: string = computeName("variables");
|
|
254
|
+
const variables: string = names.variables;
|
|
266
255
|
return factory.createBlock(
|
|
267
256
|
[
|
|
268
257
|
local(variables)("URLSearchParams")(
|
|
@@ -281,13 +270,13 @@ export namespace SdkHttpNamespaceProgrammer {
|
|
|
281
270
|
factory.createBindingElement(
|
|
282
271
|
undefined,
|
|
283
272
|
undefined,
|
|
284
|
-
factory.createIdentifier(
|
|
273
|
+
factory.createIdentifier(names.key),
|
|
285
274
|
undefined,
|
|
286
275
|
),
|
|
287
276
|
factory.createBindingElement(
|
|
288
277
|
undefined,
|
|
289
278
|
undefined,
|
|
290
|
-
factory.createIdentifier(
|
|
279
|
+
factory.createIdentifier(names.value),
|
|
291
280
|
undefined,
|
|
292
281
|
),
|
|
293
282
|
]),
|
|
@@ -306,19 +295,19 @@ export namespace SdkHttpNamespaceProgrammer {
|
|
|
306
295
|
factory.createIfStatement(
|
|
307
296
|
factory.createStrictEquality(
|
|
308
297
|
factory.createIdentifier("undefined"),
|
|
309
|
-
factory.createIdentifier(
|
|
298
|
+
factory.createIdentifier(names.value),
|
|
310
299
|
),
|
|
311
300
|
factory.createContinueStatement(),
|
|
312
301
|
factory.createIfStatement(
|
|
313
302
|
factory.createCallExpression(
|
|
314
303
|
factory.createIdentifier("Array.isArray"),
|
|
315
304
|
undefined,
|
|
316
|
-
[factory.createIdentifier(
|
|
305
|
+
[factory.createIdentifier(names.value)],
|
|
317
306
|
),
|
|
318
307
|
factory.createExpressionStatement(
|
|
319
308
|
factory.createCallExpression(
|
|
320
309
|
factory.createPropertyAccessExpression(
|
|
321
|
-
factory.createIdentifier(
|
|
310
|
+
factory.createIdentifier(names.value),
|
|
322
311
|
factory.createIdentifier("forEach"),
|
|
323
312
|
),
|
|
324
313
|
undefined,
|
|
@@ -326,7 +315,7 @@ export namespace SdkHttpNamespaceProgrammer {
|
|
|
326
315
|
factory.createArrowFunction(
|
|
327
316
|
undefined,
|
|
328
317
|
undefined,
|
|
329
|
-
[IdentifierFactory.parameter(
|
|
318
|
+
[IdentifierFactory.parameter(names.elem)],
|
|
330
319
|
undefined,
|
|
331
320
|
undefined,
|
|
332
321
|
factory.createCallExpression(
|
|
@@ -336,11 +325,11 @@ export namespace SdkHttpNamespaceProgrammer {
|
|
|
336
325
|
),
|
|
337
326
|
undefined,
|
|
338
327
|
[
|
|
339
|
-
factory.createIdentifier(
|
|
328
|
+
factory.createIdentifier(names.key),
|
|
340
329
|
factory.createCallExpression(
|
|
341
330
|
factory.createIdentifier("String"),
|
|
342
331
|
undefined,
|
|
343
|
-
[factory.createIdentifier(
|
|
332
|
+
[factory.createIdentifier(names.elem)],
|
|
344
333
|
),
|
|
345
334
|
],
|
|
346
335
|
),
|
|
@@ -356,11 +345,11 @@ export namespace SdkHttpNamespaceProgrammer {
|
|
|
356
345
|
),
|
|
357
346
|
undefined,
|
|
358
347
|
[
|
|
359
|
-
factory.createIdentifier(
|
|
348
|
+
factory.createIdentifier(names.key),
|
|
360
349
|
factory.createCallExpression(
|
|
361
350
|
factory.createIdentifier("String"),
|
|
362
351
|
undefined,
|
|
363
|
-
[factory.createIdentifier(
|
|
352
|
+
[factory.createIdentifier(names.value)],
|
|
364
353
|
),
|
|
365
354
|
],
|
|
366
355
|
),
|
|
@@ -368,7 +357,7 @@ export namespace SdkHttpNamespaceProgrammer {
|
|
|
368
357
|
),
|
|
369
358
|
),
|
|
370
359
|
),
|
|
371
|
-
local(
|
|
360
|
+
local(names.location)("string")(template()),
|
|
372
361
|
factory.createReturnStatement(
|
|
373
362
|
factory.createConditionalExpression(
|
|
374
363
|
factory.createStrictEquality(
|
|
@@ -379,13 +368,13 @@ export namespace SdkHttpNamespaceProgrammer {
|
|
|
379
368
|
),
|
|
380
369
|
),
|
|
381
370
|
undefined,
|
|
382
|
-
factory.createIdentifier(
|
|
371
|
+
factory.createIdentifier(names.location),
|
|
383
372
|
undefined,
|
|
384
373
|
factory.createTemplateExpression(
|
|
385
374
|
factory.createTemplateHead(""),
|
|
386
375
|
[
|
|
387
376
|
factory.createTemplateSpan(
|
|
388
|
-
factory.createIdentifier(
|
|
377
|
+
factory.createIdentifier(names.location),
|
|
389
378
|
factory.createTemplateMiddle("?"),
|
|
390
379
|
),
|
|
391
380
|
factory.createTemplateSpan(
|
|
@@ -412,11 +401,11 @@ export namespace SdkHttpNamespaceProgrammer {
|
|
|
412
401
|
block(
|
|
413
402
|
route.queryObject.metadata.required === false
|
|
414
403
|
? factory.createBinaryExpression(
|
|
415
|
-
|
|
404
|
+
names.access(route.queryObject),
|
|
416
405
|
factory.createToken(SyntaxKind.QuestionQuestionToken),
|
|
417
406
|
factory.createObjectLiteralExpression([], false),
|
|
418
407
|
)
|
|
419
|
-
:
|
|
408
|
+
: names.access(route.queryObject),
|
|
420
409
|
),
|
|
421
410
|
);
|
|
422
411
|
return out(
|
|
@@ -426,7 +415,7 @@ export namespace SdkHttpNamespaceProgrammer {
|
|
|
426
415
|
...(route.queryObject
|
|
427
416
|
? [
|
|
428
417
|
factory.createSpreadAssignment(
|
|
429
|
-
|
|
418
|
+
names.access(route.queryObject),
|
|
430
419
|
),
|
|
431
420
|
]
|
|
432
421
|
: []),
|
|
@@ -435,7 +424,7 @@ export namespace SdkHttpNamespaceProgrammer {
|
|
|
435
424
|
NamingConvention.variable(q.field!)
|
|
436
425
|
? q.field!
|
|
437
426
|
: factory.createStringLiteral(q.field!),
|
|
438
|
-
|
|
427
|
+
names.access(q),
|
|
439
428
|
),
|
|
440
429
|
),
|
|
441
430
|
],
|