@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
|
@@ -23,7 +23,32 @@ import { SdkAliasCollection } from "./SdkAliasCollection";
|
|
|
23
23
|
import { SdkHttpParameterProgrammer } from "./SdkHttpParameterProgrammer";
|
|
24
24
|
import { SdkImportWizard } from "./SdkImportWizard";
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Writes the mockup functions of an HTTP route.
|
|
28
|
+
*
|
|
29
|
+
* @evidence contracts/common.md#principled-implementation The namespace prints random for the response type and simulate for structural parameter assertions followed by random response creation. Simulation operates on typed SDK arguments rather than parsing HTTP transport values.
|
|
30
|
+
* @evidence contracts/common.md#clear-and-simple-design Two public functions and their helpers.
|
|
31
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Generated validation calls typia.assert through NestiaSimulator's error adapter. It does not reproduce arbitrary server pipes or the server transform's prune and equality modes; simulation rejects structural type violations without contacting a server.
|
|
32
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
33
|
+
* efficient algorithms: Response construction has a fixed AST skeleton; request assertion emission visits significant parameters once and allocates one validator expression per parameter. Type and parameter projection costs belong to the called programmers.
|
|
34
|
+
* reuse equivalent work: These writers construct route-specific mutable AST nodes and coordinate no completed or in-flight generation across requests.
|
|
35
|
+
* bound retention and release resources: Returned ASTs transfer to the file writer. The emitted binary random function closes its empty stream during construction; the programmer itself retains no stream or producer task.
|
|
36
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkHttpSimulationProgrammer 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
|
+
*/
|
|
26
38
|
export namespace SdkHttpSimulationProgrammer {
|
|
39
|
+
/**
|
|
40
|
+
* Returns `random`: it makes a value of the response, a closed empty stream
|
|
41
|
+
* for a binary one. Binary readers receive EOF without waiting for payload.
|
|
42
|
+
*
|
|
43
|
+
* @evidence contracts/common.md#principled-implementation Ordinary responses call typia.random of the output type. Binary responses construct a stream with the existing binary chunk type and a start callback that closes its own controller synchronously; no bytes are enqueued, so the first read reports EOF under Streams semantics.
|
|
44
|
+
* @evidence contracts/common.md#clear-and-simple-design The existing binary versus ordinary expression branch owns response generation. Its inline stream source supplies closure without another runtime helper, import or transport.
|
|
45
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The binary case has no random content.
|
|
46
|
+
* @evidence contracts/common.md#meaningful-documentation The prose states that binary random output is closed and readers receive EOF without waiting for payload.
|
|
47
|
+
* bound retention and release resources: The emitted binary source queues no bytes or producer task and closes each empty stream during construction. The writer returns its AST without retaining stream handles; runtime readers belong to the generated SDK caller.
|
|
48
|
+
* efficient algorithms: After response-type projection, either branch allocates a fixed AST skeleton; the binary branch emits one empty stream constructor without traversing or generating payload bytes.
|
|
49
|
+
* reuse equivalent work: The returned AST belongs to this route and importer. Each generated runtime call needs its own random value or stream, so neither mutable syntax nor runtime response identity is shared.
|
|
50
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkHttpSimulationProgrammer.random 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.
|
|
51
|
+
*/
|
|
27
52
|
export const random =
|
|
28
53
|
(project: INestiaProject) =>
|
|
29
54
|
(importer: ImportDictionary) =>
|
|
@@ -47,7 +72,34 @@ export namespace SdkHttpSimulationProgrammer {
|
|
|
47
72
|
? factory.createNewExpression(
|
|
48
73
|
factory.createIdentifier("ReadableStream"),
|
|
49
74
|
[SdkAliasCollection.binaryChunk() as TypeNode],
|
|
50
|
-
[
|
|
75
|
+
[
|
|
76
|
+
factory.createObjectLiteralExpression([
|
|
77
|
+
factory.createPropertyAssignment(
|
|
78
|
+
"start",
|
|
79
|
+
factory.createArrowFunction(
|
|
80
|
+
undefined,
|
|
81
|
+
undefined,
|
|
82
|
+
[
|
|
83
|
+
factory.createParameterDeclaration(
|
|
84
|
+
undefined,
|
|
85
|
+
undefined,
|
|
86
|
+
"controller",
|
|
87
|
+
),
|
|
88
|
+
],
|
|
89
|
+
undefined,
|
|
90
|
+
undefined,
|
|
91
|
+
factory.createCallExpression(
|
|
92
|
+
IdentifierFactory.access(
|
|
93
|
+
factory.createIdentifier("controller"),
|
|
94
|
+
"close",
|
|
95
|
+
),
|
|
96
|
+
undefined,
|
|
97
|
+
[],
|
|
98
|
+
),
|
|
99
|
+
),
|
|
100
|
+
),
|
|
101
|
+
]),
|
|
102
|
+
],
|
|
51
103
|
)
|
|
52
104
|
: factory.createCallExpression(
|
|
53
105
|
IdentifierFactory.access(
|
|
@@ -61,10 +113,25 @@ export namespace SdkHttpSimulationProgrammer {
|
|
|
61
113
|
);
|
|
62
114
|
};
|
|
63
115
|
|
|
116
|
+
/**
|
|
117
|
+
* Returns `simulate`: it asserts the parameters and returns a random output,
|
|
118
|
+
* wrapped as a propagation when configured.
|
|
119
|
+
*
|
|
120
|
+
* @evidence contracts/common.md#principled-implementation The status of the wrapper is the declared one or the method's default. A response without a content type has no Content-Type entry; a declared media type supplies a string header, preserving the propagation header contract.
|
|
121
|
+
* @evidence contracts/common.md#clear-and-simple-design One function.
|
|
122
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The parameters are validated before a response is made.
|
|
123
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
124
|
+
* efficient algorithms: Parameter declarations and assertion nodes grow linearly with significant route parameters; propagation adds a fixed response wrapper and one catch block. The private assertion writer handles the connection headers separately rather than duplicating every parameter validation.
|
|
125
|
+
* reuse equivalent work: Simulation syntax contains this route's names, arguments, output type and importer aliases; this operation coordinates no reusable result across generation requests.
|
|
126
|
+
* bound retention and release resources: This function returns an AST to its caller and owns no retained cache, stream, handle or background task; runtime random response creation is documented by random.
|
|
127
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkHttpSimulationProgrammer.simulate 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.
|
|
128
|
+
*/
|
|
64
129
|
export const simulate =
|
|
65
130
|
(project: INestiaProject) =>
|
|
66
131
|
(importer: ImportDictionary) =>
|
|
67
132
|
(route: ITypedHttpRoute): Node => {
|
|
133
|
+
const names: SdkHttpParameterProgrammer.INames =
|
|
134
|
+
SdkHttpParameterProgrammer.getNames({ project, route });
|
|
68
135
|
const output: boolean =
|
|
69
136
|
project.config.propagate === true ||
|
|
70
137
|
route.success.binary === true ||
|
|
@@ -82,9 +149,9 @@ export namespace SdkHttpSimulationProgrammer {
|
|
|
82
149
|
[
|
|
83
150
|
IdentifierFactory.parameter(
|
|
84
151
|
SdkHttpParameterProgrammer.getSignificant(route, true).length !==
|
|
85
|
-
0
|
|
86
|
-
?
|
|
87
|
-
:
|
|
152
|
+
0 || route.headerObject !== null
|
|
153
|
+
? names.connection
|
|
154
|
+
: `_${names.connection}`,
|
|
88
155
|
factory.createTypeReferenceNode(
|
|
89
156
|
SdkImportWizard.IConnection(importer),
|
|
90
157
|
route.headerObject
|
|
@@ -104,7 +171,7 @@ export namespace SdkHttpSimulationProgrammer {
|
|
|
104
171
|
undefined,
|
|
105
172
|
factory.createBlock(
|
|
106
173
|
[
|
|
107
|
-
...assert(project)(importer)(route),
|
|
174
|
+
...assert(project)(importer)(route)(names),
|
|
108
175
|
factory.createReturnStatement(
|
|
109
176
|
project.config.propagate
|
|
110
177
|
? factory.createAsExpression(
|
|
@@ -123,9 +190,11 @@ export namespace SdkHttpSimulationProgrammer {
|
|
|
123
190
|
),
|
|
124
191
|
factory.createPropertyAssignment(
|
|
125
192
|
"headers",
|
|
126
|
-
LiteralFactory.write(
|
|
127
|
-
|
|
128
|
-
|
|
193
|
+
LiteralFactory.write(
|
|
194
|
+
route.success.contentType === null
|
|
195
|
+
? {}
|
|
196
|
+
: { "Content-Type": route.success.contentType },
|
|
197
|
+
),
|
|
129
198
|
),
|
|
130
199
|
factory.createPropertyAssignment("data", caller()),
|
|
131
200
|
],
|
|
@@ -145,13 +214,14 @@ export namespace SdkHttpSimulationProgrammer {
|
|
|
145
214
|
const assert =
|
|
146
215
|
(project: INestiaProject) =>
|
|
147
216
|
(importer: ImportDictionary) =>
|
|
148
|
-
(route: ITypedHttpRoute)
|
|
217
|
+
(route: ITypedHttpRoute) =>
|
|
218
|
+
(names: SdkHttpParameterProgrammer.INames): Statement[] => {
|
|
149
219
|
const parameters = SdkHttpParameterProgrammer.getSignificant(route, true);
|
|
150
|
-
if (parameters.length === 0) return [];
|
|
220
|
+
if (parameters.length === 0 && route.headerObject === null) return [];
|
|
151
221
|
|
|
152
222
|
const typia = SdkImportWizard.typia(importer);
|
|
153
223
|
const validator = StatementFactory.constant({
|
|
154
|
-
name:
|
|
224
|
+
name: names.assert,
|
|
155
225
|
value: factory.createCallExpression(
|
|
156
226
|
IdentifierFactory.access(
|
|
157
227
|
factory.createIdentifier(
|
|
@@ -174,7 +244,10 @@ export namespace SdkHttpSimulationProgrammer {
|
|
|
174
244
|
),
|
|
175
245
|
factory.createPropertyAssignment(
|
|
176
246
|
"host",
|
|
177
|
-
|
|
247
|
+
IdentifierFactory.access(
|
|
248
|
+
factory.createIdentifier(names.connection),
|
|
249
|
+
"host",
|
|
250
|
+
),
|
|
178
251
|
),
|
|
179
252
|
factory.createPropertyAssignment(
|
|
180
253
|
"path",
|
|
@@ -205,7 +278,7 @@ export namespace SdkHttpSimulationProgrammer {
|
|
|
205
278
|
factory.createCallExpression(
|
|
206
279
|
(() => {
|
|
207
280
|
const base = IdentifierFactory.access(
|
|
208
|
-
factory.createIdentifier(
|
|
281
|
+
factory.createIdentifier(names.assert),
|
|
209
282
|
p.category,
|
|
210
283
|
);
|
|
211
284
|
if (p.category !== "param") return base;
|
|
@@ -227,17 +300,48 @@ export namespace SdkHttpSimulationProgrammer {
|
|
|
227
300
|
"assert",
|
|
228
301
|
),
|
|
229
302
|
undefined,
|
|
230
|
-
[
|
|
231
|
-
project.config.keyword === true
|
|
232
|
-
? factory.createIdentifier(`props.${p.name}`)
|
|
233
|
-
: factory.createIdentifier(p.name),
|
|
234
|
-
],
|
|
303
|
+
[names.access(p)],
|
|
235
304
|
),
|
|
236
305
|
),
|
|
237
306
|
],
|
|
238
307
|
),
|
|
239
308
|
)
|
|
240
309
|
.map(factory.createExpressionStatement);
|
|
310
|
+
// Headers travel in the connection and receive a structural assertion.
|
|
311
|
+
if (route.headerObject !== null)
|
|
312
|
+
individual.push(
|
|
313
|
+
factory.createExpressionStatement(
|
|
314
|
+
factory.createCallExpression(
|
|
315
|
+
IdentifierFactory.access(
|
|
316
|
+
factory.createIdentifier(names.assert),
|
|
317
|
+
"headers",
|
|
318
|
+
),
|
|
319
|
+
undefined,
|
|
320
|
+
[
|
|
321
|
+
factory.createArrowFunction(
|
|
322
|
+
undefined,
|
|
323
|
+
undefined,
|
|
324
|
+
[],
|
|
325
|
+
undefined,
|
|
326
|
+
undefined,
|
|
327
|
+
factory.createCallExpression(
|
|
328
|
+
IdentifierFactory.access(
|
|
329
|
+
factory.createIdentifier(typia),
|
|
330
|
+
"assert",
|
|
331
|
+
),
|
|
332
|
+
[factory.createTypeReferenceNode(`${route.name}.Headers`)],
|
|
333
|
+
[
|
|
334
|
+
IdentifierFactory.access(
|
|
335
|
+
factory.createIdentifier(names.connection),
|
|
336
|
+
"headers",
|
|
337
|
+
),
|
|
338
|
+
],
|
|
339
|
+
),
|
|
340
|
+
),
|
|
341
|
+
],
|
|
342
|
+
),
|
|
343
|
+
),
|
|
344
|
+
);
|
|
241
345
|
return [
|
|
242
346
|
validator,
|
|
243
347
|
...(project.config.propagate !== true
|
|
@@ -1,9 +1,36 @@
|
|
|
1
1
|
import { ImportDictionary } from "./ImportDictionary";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* The imports of the SDK's runtime dependencies.
|
|
5
|
+
*
|
|
6
|
+
* @evidence contracts/common.md#principled-implementation The namespace names each dependency once so every generator registers it the same way.
|
|
7
|
+
* @evidence contracts/common.md#clear-and-simple-design Six one-call helpers.
|
|
8
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Each helper registers one fixed import.
|
|
9
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
10
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkImportWizard 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.
|
|
11
|
+
*/
|
|
3
12
|
export namespace SdkImportWizard {
|
|
13
|
+
/**
|
|
14
|
+
* Returns the import of the fetcher: the encrypted one or the plain one.
|
|
15
|
+
*
|
|
16
|
+
* @evidence contracts/common.md#principled-implementation The choice follows the route.
|
|
17
|
+
* @evidence contracts/common.md#clear-and-simple-design One conditional.
|
|
18
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It returns the registering function.
|
|
19
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
20
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkImportWizard.Fetcher 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.
|
|
21
|
+
*/
|
|
4
22
|
export const Fetcher = (encrypted: boolean) =>
|
|
5
23
|
encrypted ? EncryptedFetcher : PlainFetcher;
|
|
6
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Registers `HttpError` of `@nestia/fetcher`.
|
|
27
|
+
*
|
|
28
|
+
* @evidence contracts/common.md#principled-implementation It is a type import.
|
|
29
|
+
* @evidence contracts/common.md#clear-and-simple-design One call.
|
|
30
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The import is fixed.
|
|
31
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
32
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkImportWizard.HttpError 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.
|
|
33
|
+
*/
|
|
7
34
|
export const HttpError = (importer: ImportDictionary) =>
|
|
8
35
|
importer.external({
|
|
9
36
|
declaration: true,
|
|
@@ -12,6 +39,15 @@ export namespace SdkImportWizard {
|
|
|
12
39
|
name: "HttpError",
|
|
13
40
|
});
|
|
14
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Registers `IConnection` of `@nestia/fetcher`.
|
|
44
|
+
*
|
|
45
|
+
* @evidence contracts/common.md#principled-implementation It is a type import.
|
|
46
|
+
* @evidence contracts/common.md#clear-and-simple-design One call.
|
|
47
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The import is fixed.
|
|
48
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
49
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkImportWizard.IConnection 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.
|
|
50
|
+
*/
|
|
15
51
|
export const IConnection = (importer: ImportDictionary) =>
|
|
16
52
|
importer.external({
|
|
17
53
|
declaration: true,
|
|
@@ -20,6 +56,15 @@ export namespace SdkImportWizard {
|
|
|
20
56
|
name: "IConnection",
|
|
21
57
|
});
|
|
22
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Registers `Primitive` of `typia`.
|
|
61
|
+
*
|
|
62
|
+
* @evidence contracts/common.md#principled-implementation It is a type import.
|
|
63
|
+
* @evidence contracts/common.md#clear-and-simple-design One call.
|
|
64
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The import is fixed.
|
|
65
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
66
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkImportWizard.Primitive 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.
|
|
67
|
+
*/
|
|
23
68
|
export const Primitive = (importer: ImportDictionary) =>
|
|
24
69
|
importer.external({
|
|
25
70
|
declaration: true,
|
|
@@ -28,6 +73,15 @@ export namespace SdkImportWizard {
|
|
|
28
73
|
name: "Primitive",
|
|
29
74
|
});
|
|
30
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Registers `Resolved` of `typia`.
|
|
78
|
+
*
|
|
79
|
+
* @evidence contracts/common.md#principled-implementation It is a type import.
|
|
80
|
+
* @evidence contracts/common.md#clear-and-simple-design One call.
|
|
81
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The import is fixed.
|
|
82
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
83
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkImportWizard.Resolved 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.
|
|
84
|
+
*/
|
|
31
85
|
export const Resolved = (importer: ImportDictionary) =>
|
|
32
86
|
importer.external({
|
|
33
87
|
declaration: true,
|
|
@@ -36,6 +90,15 @@ export namespace SdkImportWizard {
|
|
|
36
90
|
name: "Resolved",
|
|
37
91
|
});
|
|
38
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Registers the default import of `typia`.
|
|
95
|
+
*
|
|
96
|
+
* @evidence contracts/common.md#principled-implementation It is a value import.
|
|
97
|
+
* @evidence contracts/common.md#clear-and-simple-design One call.
|
|
98
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The import is fixed.
|
|
99
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
100
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkImportWizard.typia 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.
|
|
101
|
+
*/
|
|
39
102
|
export const typia = (importer: ImportDictionary) =>
|
|
40
103
|
importer.external({
|
|
41
104
|
declaration: false,
|
|
@@ -12,18 +12,35 @@ import {
|
|
|
12
12
|
import { IdentifierFactory } from "../../factories/IdentifierFactory";
|
|
13
13
|
import { INestiaProject } from "../../structures/INestiaProject";
|
|
14
14
|
import { ITypedMcpRoute } from "../../structures/ITypedMcpRoute";
|
|
15
|
+
import { StringUtil } from "../../utils/StringUtil";
|
|
15
16
|
import { FilePrinter } from "./FilePrinter";
|
|
16
17
|
import { ImportDictionary } from "./ImportDictionary";
|
|
18
|
+
import { SdkTypeProgrammer } from "./SdkTypeProgrammer";
|
|
17
19
|
|
|
18
20
|
/**
|
|
19
21
|
* Emits a typed client wrapper for an MCP tool.
|
|
20
22
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
+
* Cloned input and output declarations use the native JSON wire graph.
|
|
24
|
+
* Source-reference output types use `Primitive<T>` for the same JSON
|
|
25
|
+
* round-trip. Void MCP tools return `Promise<void>`.
|
|
23
26
|
*
|
|
24
27
|
* @author wildduck - https://github.com/wildduck2
|
|
28
|
+
* @evidence contracts/common.md#principled-implementation The namespace prints the wrapper that calls the tool and its metadata, and turns a tool error into an exception.
|
|
29
|
+
* @evidence contracts/common.md#clear-and-simple-design One public function and the writers.
|
|
30
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The function's identifiers yield to the tool's own name.
|
|
31
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
32
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkMcpRouteProgrammer 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.
|
|
25
33
|
*/
|
|
26
34
|
export namespace SdkMcpRouteProgrammer {
|
|
35
|
+
/**
|
|
36
|
+
* Returns the function and the namespace of an MCP tool.
|
|
37
|
+
*
|
|
38
|
+
* @evidence contracts/common.md#principled-implementation The two nodes are composed together so they share names.
|
|
39
|
+
* @evidence contracts/common.md#clear-and-simple-design One function.
|
|
40
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The shape follows the tool metadata.
|
|
41
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
42
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkMcpRouteProgrammer.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.
|
|
43
|
+
*/
|
|
27
44
|
export const write =
|
|
28
45
|
(project: INestiaProject) =>
|
|
29
46
|
(importer: ImportDictionary) =>
|
|
@@ -39,6 +56,16 @@ export namespace SdkMcpRouteProgrammer {
|
|
|
39
56
|
(_project: INestiaProject) =>
|
|
40
57
|
(importer: ImportDictionary) =>
|
|
41
58
|
(route: ITypedMcpRoute): Node => {
|
|
59
|
+
// The body reads `<route>.METADATA` next to these, so they yield to a
|
|
60
|
+
// tool of the same name, as the HTTP and WebSocket SDKs' own do.
|
|
61
|
+
const own = StringUtil.escapeDuplicate([route.name]);
|
|
62
|
+
const names = {
|
|
63
|
+
client: own("client"),
|
|
64
|
+
args: own("args"),
|
|
65
|
+
raw: own("raw"),
|
|
66
|
+
result: own("result"),
|
|
67
|
+
first: own("first"),
|
|
68
|
+
};
|
|
42
69
|
const clientType = factory.createTypeReferenceNode(
|
|
43
70
|
importer.external({
|
|
44
71
|
declaration: true,
|
|
@@ -56,7 +83,7 @@ export namespace SdkMcpRouteProgrammer {
|
|
|
56
83
|
alias: "McpCallToolResult",
|
|
57
84
|
});
|
|
58
85
|
const isVoid = isVoidReturn(route);
|
|
59
|
-
if (!isVoid)
|
|
86
|
+
if (!isVoid && _project.config.clone !== true)
|
|
60
87
|
importer.external({
|
|
61
88
|
declaration: true,
|
|
62
89
|
file: "typia",
|
|
@@ -75,7 +102,7 @@ export namespace SdkMcpRouteProgrammer {
|
|
|
75
102
|
factory.createParameterDeclaration(
|
|
76
103
|
undefined,
|
|
77
104
|
undefined,
|
|
78
|
-
|
|
105
|
+
names.client,
|
|
79
106
|
undefined,
|
|
80
107
|
clientType,
|
|
81
108
|
undefined,
|
|
@@ -86,7 +113,7 @@ export namespace SdkMcpRouteProgrammer {
|
|
|
86
113
|
factory.createParameterDeclaration(
|
|
87
114
|
undefined,
|
|
88
115
|
undefined,
|
|
89
|
-
|
|
116
|
+
names.args,
|
|
90
117
|
undefined,
|
|
91
118
|
inputRef,
|
|
92
119
|
undefined,
|
|
@@ -110,7 +137,7 @@ export namespace SdkMcpRouteProgrammer {
|
|
|
110
137
|
"arguments",
|
|
111
138
|
factory.createAsExpression(
|
|
112
139
|
factory.createAsExpression(
|
|
113
|
-
factory.createIdentifier(
|
|
140
|
+
factory.createIdentifier(names.args),
|
|
114
141
|
factory.createKeywordTypeNode(SyntaxKind.AnyKeyword),
|
|
115
142
|
),
|
|
116
143
|
factory.createTypeReferenceNode("Record", [
|
|
@@ -128,13 +155,13 @@ export namespace SdkMcpRouteProgrammer {
|
|
|
128
155
|
factory.createVariableDeclarationList(
|
|
129
156
|
[
|
|
130
157
|
factory.createVariableDeclaration(
|
|
131
|
-
|
|
158
|
+
names.raw,
|
|
132
159
|
undefined,
|
|
133
160
|
undefined,
|
|
134
161
|
factory.createAwaitExpression(
|
|
135
162
|
factory.createCallExpression(
|
|
136
163
|
factory.createPropertyAccessExpression(
|
|
137
|
-
factory.createIdentifier(
|
|
164
|
+
factory.createIdentifier(names.client),
|
|
138
165
|
"callTool",
|
|
139
166
|
),
|
|
140
167
|
undefined,
|
|
@@ -165,7 +192,7 @@ export namespace SdkMcpRouteProgrammer {
|
|
|
165
192
|
),
|
|
166
193
|
undefined,
|
|
167
194
|
[
|
|
168
|
-
factory.createIdentifier(
|
|
195
|
+
factory.createIdentifier(names.raw),
|
|
169
196
|
factory.createStringLiteral("toolResult"),
|
|
170
197
|
],
|
|
171
198
|
),
|
|
@@ -179,11 +206,11 @@ export namespace SdkMcpRouteProgrammer {
|
|
|
179
206
|
factory.createVariableDeclarationList(
|
|
180
207
|
[
|
|
181
208
|
factory.createVariableDeclaration(
|
|
182
|
-
|
|
209
|
+
names.result,
|
|
183
210
|
undefined,
|
|
184
211
|
factory.createTypeReferenceNode(callToolResultTypeName),
|
|
185
212
|
factory.createAsExpression(
|
|
186
|
-
factory.createIdentifier(
|
|
213
|
+
factory.createIdentifier(names.raw),
|
|
187
214
|
factory.createTypeReferenceNode(callToolResultTypeName),
|
|
188
215
|
),
|
|
189
216
|
),
|
|
@@ -194,13 +221,13 @@ export namespace SdkMcpRouteProgrammer {
|
|
|
194
221
|
factory.createIfStatement(
|
|
195
222
|
factory.createBinaryExpression(
|
|
196
223
|
factory.createPropertyAccessExpression(
|
|
197
|
-
factory.createIdentifier(
|
|
224
|
+
factory.createIdentifier(names.result),
|
|
198
225
|
"isError",
|
|
199
226
|
),
|
|
200
227
|
factory.createToken(SyntaxKind.EqualsEqualsEqualsToken),
|
|
201
228
|
factory.createTrue(),
|
|
202
229
|
),
|
|
203
|
-
|
|
230
|
+
throwToolErrorWithText(toolNameExpr, names.result),
|
|
204
231
|
),
|
|
205
232
|
...(isVoid
|
|
206
233
|
? [factory.createReturnStatement()]
|
|
@@ -210,13 +237,13 @@ export namespace SdkMcpRouteProgrammer {
|
|
|
210
237
|
factory.createVariableDeclarationList(
|
|
211
238
|
[
|
|
212
239
|
factory.createVariableDeclaration(
|
|
213
|
-
|
|
240
|
+
names.first,
|
|
214
241
|
undefined,
|
|
215
242
|
undefined,
|
|
216
243
|
factory.createCallExpression(
|
|
217
244
|
factory.createPropertyAccessExpression(
|
|
218
245
|
factory.createPropertyAccessExpression(
|
|
219
|
-
factory.createIdentifier(
|
|
246
|
+
factory.createIdentifier(names.result),
|
|
220
247
|
"content",
|
|
221
248
|
),
|
|
222
249
|
"find",
|
|
@@ -249,7 +276,7 @@ export namespace SdkMcpRouteProgrammer {
|
|
|
249
276
|
),
|
|
250
277
|
factory.createIfStatement(
|
|
251
278
|
factory.createBinaryExpression(
|
|
252
|
-
factory.createIdentifier(
|
|
279
|
+
factory.createIdentifier(names.first),
|
|
253
280
|
factory.createToken(SyntaxKind.EqualsEqualsEqualsToken),
|
|
254
281
|
factory.createIdentifier("undefined"),
|
|
255
282
|
),
|
|
@@ -258,7 +285,7 @@ export namespace SdkMcpRouteProgrammer {
|
|
|
258
285
|
factory.createIfStatement(
|
|
259
286
|
factory.createBinaryExpression(
|
|
260
287
|
factory.createPropertyAccessExpression(
|
|
261
|
-
factory.createIdentifier(
|
|
288
|
+
factory.createIdentifier(names.first),
|
|
262
289
|
"type",
|
|
263
290
|
),
|
|
264
291
|
factory.createToken(SyntaxKind.EqualsEqualsEqualsToken),
|
|
@@ -274,7 +301,7 @@ export namespace SdkMcpRouteProgrammer {
|
|
|
274
301
|
undefined,
|
|
275
302
|
[
|
|
276
303
|
factory.createPropertyAccessExpression(
|
|
277
|
-
factory.createIdentifier(
|
|
304
|
+
factory.createIdentifier(names.first),
|
|
278
305
|
"text",
|
|
279
306
|
),
|
|
280
307
|
],
|
|
@@ -304,7 +331,7 @@ export namespace SdkMcpRouteProgrammer {
|
|
|
304
331
|
};
|
|
305
332
|
|
|
306
333
|
const writeNamespace =
|
|
307
|
-
(
|
|
334
|
+
(project: INestiaProject) =>
|
|
308
335
|
(importer: ImportDictionary) =>
|
|
309
336
|
(route: ITypedMcpRoute): Node => {
|
|
310
337
|
const statements: Statement[] = [];
|
|
@@ -315,25 +342,29 @@ export namespace SdkMcpRouteProgrammer {
|
|
|
315
342
|
[factory.createModifier(SyntaxKind.ExportKeyword)],
|
|
316
343
|
"Input",
|
|
317
344
|
undefined,
|
|
318
|
-
|
|
345
|
+
project.config.clone === true && route.inputMetadata
|
|
346
|
+
? SdkTypeProgrammer.write(project)(importer)(route.inputMetadata)
|
|
347
|
+
: factory.createTypeReferenceNode(route.input.type.name),
|
|
319
348
|
),
|
|
320
349
|
);
|
|
321
350
|
|
|
322
351
|
const outputType: Node =
|
|
323
352
|
!isVoidReturn(route) && route.returnType !== null
|
|
324
|
-
?
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
353
|
+
? project.config.clone === true && route.outputMetadata
|
|
354
|
+
? SdkTypeProgrammer.write(project)(importer)(route.outputMetadata)
|
|
355
|
+
: factory.createTypeReferenceNode(
|
|
356
|
+
importer.external({
|
|
357
|
+
declaration: true,
|
|
358
|
+
file: "typia",
|
|
359
|
+
type: "element",
|
|
360
|
+
name: "Primitive",
|
|
361
|
+
}),
|
|
362
|
+
[
|
|
363
|
+
factory.createTypeReferenceNode(
|
|
364
|
+
unwrapPromise(route.returnType.name),
|
|
365
|
+
),
|
|
366
|
+
],
|
|
367
|
+
)
|
|
337
368
|
: factory.createKeywordTypeNode(SyntaxKind.VoidKeyword);
|
|
338
369
|
statements.push(
|
|
339
370
|
factory.createTypeAliasDeclaration(
|
|
@@ -423,6 +454,92 @@ export namespace SdkMcpRouteProgrammer {
|
|
|
423
454
|
const isVoidName = (name: string): boolean =>
|
|
424
455
|
name === "void" || name === "undefined";
|
|
425
456
|
|
|
457
|
+
/**
|
|
458
|
+
* The error of a tool that answered `isError`, carrying the text content the
|
|
459
|
+
* tool put its reason in, as `McpAdaptor` does an `HttpException`'s message.
|
|
460
|
+
*/
|
|
461
|
+
const throwToolErrorWithText = (
|
|
462
|
+
toolNameExpr: Expression,
|
|
463
|
+
result: string,
|
|
464
|
+
): Statement => {
|
|
465
|
+
const entry = (): Expression => factory.createIdentifier("entry");
|
|
466
|
+
return factory.createThrowStatement(
|
|
467
|
+
factory.createNewExpression(
|
|
468
|
+
factory.createIdentifier("Error"),
|
|
469
|
+
undefined,
|
|
470
|
+
[
|
|
471
|
+
factory.createTemplateExpression(
|
|
472
|
+
factory.createTemplateHead('MCP tool "'),
|
|
473
|
+
[
|
|
474
|
+
factory.createTemplateSpan(
|
|
475
|
+
toolNameExpr,
|
|
476
|
+
factory.createTemplateMiddle('" returned isError: '),
|
|
477
|
+
),
|
|
478
|
+
factory.createTemplateSpan(
|
|
479
|
+
factory.createCallExpression(
|
|
480
|
+
factory.createPropertyAccessExpression(
|
|
481
|
+
factory.createCallExpression(
|
|
482
|
+
factory.createPropertyAccessExpression(
|
|
483
|
+
factory.createCallExpression(
|
|
484
|
+
factory.createPropertyAccessExpression(
|
|
485
|
+
factory.createPropertyAccessExpression(
|
|
486
|
+
factory.createIdentifier(result),
|
|
487
|
+
"content",
|
|
488
|
+
),
|
|
489
|
+
"filter",
|
|
490
|
+
),
|
|
491
|
+
undefined,
|
|
492
|
+
[
|
|
493
|
+
factory.createArrowFunction(
|
|
494
|
+
undefined,
|
|
495
|
+
undefined,
|
|
496
|
+
[IdentifierFactory.parameter("entry")],
|
|
497
|
+
undefined,
|
|
498
|
+
undefined,
|
|
499
|
+
factory.createBinaryExpression(
|
|
500
|
+
factory.createPropertyAccessExpression(
|
|
501
|
+
entry(),
|
|
502
|
+
"type",
|
|
503
|
+
),
|
|
504
|
+
factory.createToken(
|
|
505
|
+
SyntaxKind.EqualsEqualsEqualsToken,
|
|
506
|
+
),
|
|
507
|
+
factory.createStringLiteral("text"),
|
|
508
|
+
),
|
|
509
|
+
),
|
|
510
|
+
],
|
|
511
|
+
),
|
|
512
|
+
"map",
|
|
513
|
+
),
|
|
514
|
+
undefined,
|
|
515
|
+
[
|
|
516
|
+
factory.createArrowFunction(
|
|
517
|
+
undefined,
|
|
518
|
+
undefined,
|
|
519
|
+
[IdentifierFactory.parameter("entry")],
|
|
520
|
+
undefined,
|
|
521
|
+
undefined,
|
|
522
|
+
factory.createPropertyAccessExpression(
|
|
523
|
+
entry(),
|
|
524
|
+
"text",
|
|
525
|
+
),
|
|
526
|
+
),
|
|
527
|
+
],
|
|
528
|
+
),
|
|
529
|
+
"join",
|
|
530
|
+
),
|
|
531
|
+
undefined,
|
|
532
|
+
[factory.createStringLiteral("\n")],
|
|
533
|
+
),
|
|
534
|
+
factory.createTemplateTail(""),
|
|
535
|
+
),
|
|
536
|
+
],
|
|
537
|
+
),
|
|
538
|
+
],
|
|
539
|
+
),
|
|
540
|
+
);
|
|
541
|
+
};
|
|
542
|
+
|
|
426
543
|
const throwToolError = (
|
|
427
544
|
toolNameExpr: Expression,
|
|
428
545
|
suffix: string,
|