@nestia/sdk 14.0.1 → 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/assets/bundle/distribute/build-sdk.cjs +28 -0
- package/assets/bundle/distribute/package.json +6 -2
- package/lib/INestiaConfig.d.ts +55 -24
- package/lib/NestiaSdkApplication.d.ts +60 -0
- package/lib/NestiaSdkApplication.js +63 -5
- package/lib/NestiaSdkApplication.js.map +1 -1
- package/lib/NestiaSwaggerComposer.d.ts +21 -0
- package/lib/NestiaSwaggerComposer.js +21 -3
- 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 +48 -73
- 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 +24 -0
- package/lib/analyses/ParameterNameAnalyzer.js +15 -0
- package/lib/analyses/ParameterNameAnalyzer.js.map +1 -1
- package/lib/analyses/PathAnalyzer.d.ts +63 -1
- package/lib/analyses/PathAnalyzer.js +54 -9
- package/lib/analyses/PathAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectControllerAnalyzer.d.ts +32 -0
- package/lib/analyses/ReflectControllerAnalyzer.js +22 -0
- package/lib/analyses/ReflectControllerAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationAnalyzer.d.ts +29 -0
- package/lib/analyses/ReflectHttpOperationAnalyzer.js +28 -17
- 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 +21 -0
- package/lib/analyses/ReflectHttpOperationParameterAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.d.ts +32 -0
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.js +22 -0
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectMcpOperationAnalyzer.d.ts +29 -0
- package/lib/analyses/ReflectMcpOperationAnalyzer.js +30 -9
- 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 +21 -2
- package/lib/analyses/ReflectWebSocketOperationAnalyzer.js.map +1 -1
- package/lib/analyses/SecurityAnalyzer.d.ts +15 -0
- package/lib/analyses/SecurityAnalyzer.js +15 -0
- package/lib/analyses/SecurityAnalyzer.js.map +1 -1
- package/lib/analyses/SwaggerExampleAnalyzer.d.ts +16 -0
- package/lib/analyses/SwaggerExampleAnalyzer.js +16 -0
- package/lib/analyses/SwaggerExampleAnalyzer.js.map +1 -1
- package/lib/analyses/TypedHttpRouteAnalyzer.d.ts +41 -3
- package/lib/analyses/TypedHttpRouteAnalyzer.js +172 -157
- 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 +19 -0
- 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 +122 -38
- 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/factories/ExpressionFactory.d.ts +17 -2
- package/lib/factories/ExpressionFactory.js +17 -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 +30 -10
- 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 +40 -2
- package/lib/generates/SdkGenerator.js.map +1 -1
- package/lib/generates/SwaggerGenerator.d.ts +36 -6
- package/lib/generates/SwaggerGenerator.js +55 -13
- 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 +43 -0
- package/lib/generates/internal/FilePrinter.js +43 -0
- package/lib/generates/internal/FilePrinter.js.map +1 -1
- package/lib/generates/internal/ImportDictionary.d.ts +92 -2
- package/lib/generates/internal/ImportDictionary.js +91 -3
- package/lib/generates/internal/ImportDictionary.js.map +1 -1
- package/lib/generates/internal/SdkAliasCollection.d.ts +119 -0
- package/lib/generates/internal/SdkAliasCollection.js +124 -7
- package/lib/generates/internal/SdkAliasCollection.js.map +1 -1
- package/lib/generates/internal/SdkDistributionComposer.d.ts +19 -0
- package/lib/generates/internal/SdkDistributionComposer.js +98 -59
- package/lib/generates/internal/SdkDistributionComposer.js.map +1 -1
- package/lib/generates/internal/SdkFileProgrammer.d.ts +18 -0
- package/lib/generates/internal/SdkFileProgrammer.js +18 -0
- 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 +19 -0
- package/lib/generates/internal/SdkHttpFunctionProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.d.ts +19 -0
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.js +19 -0
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpParameterProgrammer.d.ts +104 -2
- package/lib/generates/internal/SdkHttpParameterProgrammer.js +70 -0
- package/lib/generates/internal/SdkHttpParameterProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpRouteProgrammer.d.ts +20 -0
- package/lib/generates/internal/SdkHttpRouteProgrammer.js +20 -0
- package/lib/generates/internal/SdkHttpRouteProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpSimulationProgrammer.d.ts +38 -0
- package/lib/generates/internal/SdkHttpSimulationProgrammer.js +49 -5
- 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 +33 -13
- package/lib/generates/internal/SdkMcpRouteProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkPathTemplate.d.ts +15 -0
- package/lib/generates/internal/SdkPathTemplate.js +15 -0
- package/lib/generates/internal/SdkPathTemplate.js.map +1 -1
- 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 +96 -12
- package/lib/generates/internal/SdkTypeProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkTypeTagProgrammer.d.ts +36 -3
- package/lib/generates/internal/SdkTypeTagProgrammer.js +28 -7
- 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 +19 -0
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketParameterProgrammer.d.ts +81 -2
- package/lib/generates/internal/SdkWebSocketParameterProgrammer.js +48 -0
- package/lib/generates/internal/SdkWebSocketParameterProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.d.ts +18 -0
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.js +18 -0
- 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 +18 -0
- package/lib/generates/internal/SwaggerOperationComposer.js.map +1 -1
- package/lib/generates/internal/SwaggerOperationParameterComposer.d.ts +39 -0
- package/lib/generates/internal/SwaggerOperationParameterComposer.js +31 -8
- package/lib/generates/internal/SwaggerOperationParameterComposer.js.map +1 -1
- package/lib/generates/internal/SwaggerOperationResponseComposer.d.ts +19 -0
- package/lib/generates/internal/SwaggerOperationResponseComposer.js +19 -0
- package/lib/generates/internal/SwaggerOperationResponseComposer.js.map +1 -1
- package/lib/internal/legacy.d.ts +296 -16
- package/lib/internal/legacy.js +127 -10
- 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 +55 -0
- package/lib/structures/IReflectController.d.ts +10 -0
- package/lib/structures/IReflectHttpOperation.d.ts +10 -0
- package/lib/structures/IReflectHttpOperationException.d.ts +10 -0
- package/lib/structures/IReflectHttpOperationParameter.d.ts +47 -0
- package/lib/structures/IReflectHttpOperationSuccess.d.ts +11 -0
- 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 +10 -0
- package/lib/structures/ITypedHttpRouteException.d.ts +10 -0
- package/lib/structures/ITypedHttpRouteParameter.d.ts +45 -0
- package/lib/structures/ITypedHttpRouteSuccess.d.ts +10 -0
- package/lib/structures/ITypedMcpRoute.d.ts +11 -0
- package/lib/structures/ITypedWebSocketRoute.d.ts +10 -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 +35 -0
- package/lib/utils/SourceFinder.js +47 -12
- 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 +26 -1
- package/lib/utils/VersioningStrategy.js +30 -9
- 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_metadata_json.go +6 -1
- package/native/sdk/sdk_transform.go +388 -397
- package/package.json +7 -5
- package/src/INestiaConfig.ts +55 -24
- package/src/NestiaSdkApplication.ts +66 -7
- package/src/NestiaSwaggerComposer.ts +21 -6
- package/src/analyses/AccessorAnalyzer.ts +26 -0
- package/src/analyses/ConfigAnalyzer.ts +49 -87
- package/src/analyses/ImportAnalyzer.ts +25 -0
- package/src/analyses/ParameterNameAnalyzer.ts +24 -0
- package/src/analyses/PathAnalyzer.ts +63 -11
- package/src/analyses/ReflectControllerAnalyzer.ts +32 -0
- package/src/analyses/ReflectHttpOperationAnalyzer.ts +32 -10
- package/src/analyses/ReflectHttpOperationExceptionAnalyzer.ts +31 -0
- package/src/analyses/ReflectHttpOperationParameterAnalyzer.ts +31 -0
- package/src/analyses/ReflectHttpOperationResponseAnalyzer.ts +32 -0
- package/src/analyses/ReflectMcpOperationAnalyzer.ts +32 -1
- package/src/analyses/ReflectMetadataAnalyzer.ts +47 -0
- package/src/analyses/ReflectWebSocketOperationAnalyzer.ts +33 -4
- package/src/analyses/SecurityAnalyzer.ts +15 -0
- package/src/analyses/SwaggerExampleAnalyzer.ts +16 -0
- package/src/analyses/TypedHttpRouteAnalyzer.ts +240 -184
- package/src/analyses/TypedMcpRouteAnalyzer.ts +180 -20
- package/src/analyses/TypedWebSocketRouteAnalyzer.ts +19 -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 +169 -41
- package/src/executable/internal/NestiaSwaggerWatch.ts +359 -0
- package/src/factories/ExpressionFactory.ts +17 -2
- package/src/factories/IdentifierFactory.ts +24 -0
- package/src/factories/LiteralFactory.ts +44 -11
- 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 +40 -9
- package/src/generates/SwaggerGenerator.ts +56 -14
- package/src/generates/internal/E2eFileProgrammer.ts +20 -0
- package/src/generates/internal/FilePrinter.ts +43 -0
- package/src/generates/internal/ImportDictionary.ts +110 -3
- package/src/generates/internal/SdkAliasCollection.ts +133 -11
- package/src/generates/internal/SdkDistributionComposer.ts +117 -66
- package/src/generates/internal/SdkFileProgrammer.ts +18 -0
- package/src/generates/internal/SdkHttpCloneProgrammer.ts +55 -0
- package/src/generates/internal/SdkHttpCloneReferencer.ts +97 -23
- package/src/generates/internal/SdkHttpFunctionProgrammer.ts +19 -0
- package/src/generates/internal/SdkHttpNamespaceProgrammer.ts +19 -0
- package/src/generates/internal/SdkHttpParameterProgrammer.ts +104 -2
- package/src/generates/internal/SdkHttpRouteProgrammer.ts +20 -0
- package/src/generates/internal/SdkHttpSimulationProgrammer.ts +72 -5
- package/src/generates/internal/SdkImportWizard.ts +63 -0
- package/src/generates/internal/SdkMcpRouteProgrammer.ts +38 -18
- package/src/generates/internal/SdkPathTemplate.ts +15 -0
- package/src/generates/internal/SdkRouteDirectory.ts +10 -0
- package/src/generates/internal/SdkTypeProgrammer.ts +118 -14
- package/src/generates/internal/SdkTypeTagProgrammer.ts +37 -7
- package/src/generates/internal/SdkWebSocketCloneProgrammer.ts +185 -142
- package/src/generates/internal/SdkWebSocketNamespaceProgrammer.ts +19 -0
- package/src/generates/internal/SdkWebSocketParameterProgrammer.ts +81 -2
- package/src/generates/internal/SdkWebSocketRouteProgrammer.ts +18 -0
- package/src/generates/internal/SwaggerDescriptionComposer.ts +47 -1
- package/src/generates/internal/SwaggerOperationComposer.ts +18 -0
- package/src/generates/internal/SwaggerOperationParameterComposer.ts +41 -8
- package/src/generates/internal/SwaggerOperationResponseComposer.ts +19 -0
- package/src/internal/legacy-augmentation.d.ts +16 -0
- package/src/internal/legacy.ts +296 -26
- package/src/structures/INestiaProject.ts +10 -0
- package/src/structures/INestiaSdkInput.ts +30 -0
- package/src/structures/IOperationMetadata.ts +55 -0
- package/src/structures/IReflectController.ts +10 -0
- package/src/structures/IReflectHttpOperation.ts +10 -0
- package/src/structures/IReflectHttpOperationException.ts +10 -0
- package/src/structures/IReflectHttpOperationParameter.ts +47 -0
- package/src/structures/IReflectHttpOperationSuccess.ts +11 -0
- 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 +10 -0
- package/src/structures/ITypedHttpRouteException.ts +10 -0
- package/src/structures/ITypedHttpRouteParameter.ts +45 -0
- package/src/structures/ITypedHttpRouteSuccess.ts +10 -0
- package/src/structures/ITypedMcpRoute.ts +12 -0
- package/src/structures/ITypedWebSocketRoute.ts +10 -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 +51 -14
- 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 +33 -13
- 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/src/generates/internal/SwaggerReadonlyArrayEmender.ts +0 -264
|
@@ -11,6 +11,16 @@ import { ImportAnalyzer } from "../../analyses/ImportAnalyzer";
|
|
|
11
11
|
import { IReflectImport } from "../../structures/IReflectImport";
|
|
12
12
|
import { FilePrinter } from "./FilePrinter";
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* The imports of one generated file, merged by module and kind, and printed as
|
|
16
|
+
* import declarations.
|
|
17
|
+
*
|
|
18
|
+
* @evidence contracts/common.md#principled-implementation An import is keyed by its module, its type-only flag, and its default or namespace name, so the same import is one declaration whose named bindings are collected in order.
|
|
19
|
+
* @evidence contracts/common.md#clear-and-simple-design One class with a hash map of components, and private helpers for the paths.
|
|
20
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The keys are equal exactly when the declarations can be merged.
|
|
21
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
22
|
+
* @evidence contracts/portability.md#os-neutral-implementation Source path spelling uses Node path.resolve and relative imports use path.relative followed by native-separator conversion to forward slashes. Package registration uses a node_modules marker; normalization is lexical, not symlink or filesystem-case canonicalization.
|
|
23
|
+
*/
|
|
14
24
|
export class ImportDictionary {
|
|
15
25
|
private readonly components_: HashMap<ICompositeKey, ICompositeValue> =
|
|
16
26
|
new HashMap(
|
|
@@ -24,10 +34,32 @@ export class ImportDictionary {
|
|
|
24
34
|
|
|
25
35
|
public constructor(public readonly file: string) {}
|
|
26
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Reports whether the file has no import.
|
|
39
|
+
*
|
|
40
|
+
* @evidence contracts/common.md#principled-implementation The dictionary is empty exactly when no component was registered.
|
|
41
|
+
* @evidence contracts/common.md#clear-and-simple-design One call.
|
|
42
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It reads the map.
|
|
43
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
44
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation ImportDictionary.prototype.empty 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.
|
|
45
|
+
*/
|
|
27
46
|
public empty(): boolean {
|
|
28
47
|
return this.components_.empty();
|
|
29
48
|
}
|
|
30
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Registers the imports a route's declarations need, merged by file, as
|
|
52
|
+
* type-only imports.
|
|
53
|
+
*
|
|
54
|
+
* The `WebSocketAcceptor` element is skipped, because the SDK refers to it
|
|
55
|
+
* through `tgrid`.
|
|
56
|
+
*
|
|
57
|
+
* @evidence contracts/common.md#principled-implementation Each namespace, default, and named import is registered under its alias so a name resolves to the same local binding.
|
|
58
|
+
* @evidence contracts/common.md#clear-and-simple-design One loop over the merged imports.
|
|
59
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The skipped element is the one binding that the generated code supplies itself.
|
|
60
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
61
|
+
* @evidence contracts/portability.md#os-neutral-implementation Source path spelling uses Node path.resolve and relative imports use path.relative followed by native-separator conversion to forward slashes. Package registration uses a node_modules marker; normalization is lexical, not symlink or filesystem-case canonicalization.
|
|
62
|
+
*/
|
|
31
63
|
public declarations(imports: IReflectImport[]): void {
|
|
32
64
|
imports = ImportAnalyzer.merge(imports);
|
|
33
65
|
for (const imp of imports) {
|
|
@@ -59,7 +91,15 @@ export class ImportDictionary {
|
|
|
59
91
|
}
|
|
60
92
|
}
|
|
61
93
|
|
|
62
|
-
/**
|
|
94
|
+
/**
|
|
95
|
+
* Every identifier the imports bind in the file.
|
|
96
|
+
*
|
|
97
|
+
* @evidence contracts/common.md#principled-implementation The namespace, the default, and each named local are collected, so a caller can see what a route name would shadow.
|
|
98
|
+
* @evidence contracts/common.md#clear-and-simple-design One loop.
|
|
99
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It reads the components without changing them.
|
|
100
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
101
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation ImportDictionary.prototype.locals 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.
|
|
102
|
+
*/
|
|
63
103
|
public locals(): string[] {
|
|
64
104
|
const output: string[] = [];
|
|
65
105
|
for (const { second: c } of this.components_) {
|
|
@@ -70,6 +110,44 @@ export class ImportDictionary {
|
|
|
70
110
|
return output;
|
|
71
111
|
}
|
|
72
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Returns registered bindings in the route import representation, retaining
|
|
115
|
+
* normalized module paths and local-to-exported aliases. The route emitter
|
|
116
|
+
* consumes these as type-only declarations.
|
|
117
|
+
*
|
|
118
|
+
* @evidence contracts/common.md#principled-implementation The projection reads the same normalized module keys and local-to-exported binding map used by toStatements, so a structural type writer and its route retain the same imports.
|
|
119
|
+
* @evidence contracts/common.md#clear-and-simple-design One projection over existing registrations.
|
|
120
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts No AST parsing or second import policy reconstructs the bindings.
|
|
121
|
+
* @evidence contracts/common.md#meaningful-documentation Documents normalized paths, alias direction and the route's type-only consumption.
|
|
122
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation ImportDictionary.prototype.toImports 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.
|
|
123
|
+
*/
|
|
124
|
+
public toImports(): IReflectImport[] {
|
|
125
|
+
return Array.from(this.components_).map(({ second: component }) => {
|
|
126
|
+
const bindings = Array.from(component.elements);
|
|
127
|
+
const aliases = Object.fromEntries(
|
|
128
|
+
bindings
|
|
129
|
+
.filter(({ first, second }) => first !== second)
|
|
130
|
+
.map(({ first, second }) => [first, second]),
|
|
131
|
+
);
|
|
132
|
+
return {
|
|
133
|
+
file: component.file,
|
|
134
|
+
asterisk: component.asterisk,
|
|
135
|
+
default: component.default,
|
|
136
|
+
elements: bindings.map(({ first }) => first),
|
|
137
|
+
...(Object.keys(aliases).length ? { elementAliases: aliases } : {}),
|
|
138
|
+
};
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Registers an import of a package and returns the local name it binds.
|
|
144
|
+
*
|
|
145
|
+
* @evidence contracts/common.md#principled-implementation The file is placed under `node_modules`, so the printer emits the bare package specifier.
|
|
146
|
+
* @evidence contracts/common.md#clear-and-simple-design One delegation.
|
|
147
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It shares the registration of `internal`.
|
|
148
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
149
|
+
* @evidence contracts/portability.md#os-neutral-implementation Source path spelling uses Node path.resolve and relative imports use path.relative followed by native-separator conversion to forward slashes. Package registration uses a node_modules marker; normalization is lexical, not symlink or filesystem-case canonicalization.
|
|
150
|
+
*/
|
|
73
151
|
public external(props: ImportDictionary.IProps): string {
|
|
74
152
|
const file: string = `node_modules/${props.file}`;
|
|
75
153
|
return this.internal({
|
|
@@ -78,6 +156,15 @@ export class ImportDictionary {
|
|
|
78
156
|
});
|
|
79
157
|
}
|
|
80
158
|
|
|
159
|
+
/**
|
|
160
|
+
* Registers an import of a source file and returns the local name it binds.
|
|
161
|
+
*
|
|
162
|
+
* @evidence contracts/common.md#principled-implementation The path is normalized and its source extension removed, so equal normalized module spellings share a component, and a named binding is stored under its local name. Symlink and filesystem-case identity are not canonicalized.
|
|
163
|
+
* @evidence contracts/common.md#clear-and-simple-design One function.
|
|
164
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The result is the alias when there is one.
|
|
165
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
166
|
+
* @evidence contracts/portability.md#os-neutral-implementation Source path spelling uses Node path.resolve and relative imports use path.relative followed by native-separator conversion to forward slashes. Package registration uses a node_modules marker; normalization is lexical, not symlink or filesystem-case canonicalization.
|
|
167
|
+
*/
|
|
81
168
|
public internal(props: ImportDictionary.IProps): string {
|
|
82
169
|
const file: string = normalize(trimSourceExtension(props.file));
|
|
83
170
|
const key: ICompositeKey = {
|
|
@@ -97,6 +184,16 @@ export class ImportDictionary {
|
|
|
97
184
|
return props.type === "element" ? (props.alias ?? props.name) : props.name;
|
|
98
185
|
}
|
|
99
186
|
|
|
187
|
+
/**
|
|
188
|
+
* Returns the import declarations, packages first and files after them,
|
|
189
|
+
* sorted by module, with paths relative to the output directory.
|
|
190
|
+
*
|
|
191
|
+
* @evidence contracts/common.md#principled-implementation The package paths are cut at their last `node_modules`, and a file path is made relative with forward slashes, so the output does not depend on the platform.
|
|
192
|
+
* @evidence contracts/common.md#clear-and-simple-design One function over one filter helper.
|
|
193
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Both groups are sorted and separated by one empty line.
|
|
194
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
195
|
+
* @evidence contracts/portability.md#os-neutral-implementation Source path spelling uses Node path.resolve and relative imports use path.relative followed by native-separator conversion to forward slashes. Package registration uses a node_modules marker; normalization is lexical, not symlink or filesystem-case canonicalization.
|
|
196
|
+
*/
|
|
100
197
|
public toStatements(outDir: string): Node[] {
|
|
101
198
|
outDir = path.resolve(outDir);
|
|
102
199
|
|
|
@@ -131,7 +228,7 @@ export class ImportDictionary {
|
|
|
131
228
|
container.push(
|
|
132
229
|
factory.createImportDeclaration(
|
|
133
230
|
undefined,
|
|
134
|
-
this.
|
|
231
|
+
this.toImportClause(c),
|
|
135
232
|
factory.createStringLiteral(c.file),
|
|
136
233
|
),
|
|
137
234
|
);
|
|
@@ -146,7 +243,7 @@ export class ImportDictionary {
|
|
|
146
243
|
];
|
|
147
244
|
}
|
|
148
245
|
|
|
149
|
-
private
|
|
246
|
+
private toImportClause(c: ICompositeValue): ImportClause {
|
|
150
247
|
// A namespace binding cannot carry a per-binding `type` modifier, so the
|
|
151
248
|
// type-only flag goes on the clause itself (`import type * as X`) —
|
|
152
249
|
// generated SDK code references DTO namespaces only in type positions.
|
|
@@ -178,6 +275,16 @@ export class ImportDictionary {
|
|
|
178
275
|
}
|
|
179
276
|
}
|
|
180
277
|
export namespace ImportDictionary {
|
|
278
|
+
/**
|
|
279
|
+
* One import to register: its kind, its module, its name, an optional alias,
|
|
280
|
+
* and whether it is type-only.
|
|
281
|
+
*
|
|
282
|
+
* @evidence contracts/common.md#principled-implementation The record is the argument of both registrations.
|
|
283
|
+
* @evidence contracts/common.md#clear-and-simple-design A flat record.
|
|
284
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
|
|
285
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
286
|
+
* @evidence contracts/portability.md#os-neutral-implementation Source path spelling uses Node path.resolve and relative imports use path.relative followed by native-separator conversion to forward slashes. Package registration uses a node_modules marker; normalization is lexical, not symlink or filesystem-case canonicalization.
|
|
287
|
+
*/
|
|
181
288
|
export interface IProps {
|
|
182
289
|
type: "default" | "element" | "asterisk";
|
|
183
290
|
file: string;
|
|
@@ -18,7 +18,26 @@ import { SdkHttpParameterProgrammer } from "./SdkHttpParameterProgrammer";
|
|
|
18
18
|
import { SdkTypeProgrammer } from "./SdkTypeProgrammer";
|
|
19
19
|
import type { SdkWebSocketParameterProgrammer } from "./SdkWebSocketParameterProgrammer";
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Type nodes of the SDK: the named types of routes, and the request and
|
|
23
|
+
* response aliases.
|
|
24
|
+
*
|
|
25
|
+
* @evidence contracts/common.md#principled-implementation The namespace builds each type as the syntax tree that the printer writes, from the reflected names or from the metadata when `clone` is on.
|
|
26
|
+
* @evidence contracts/common.md#clear-and-simple-design Several small builders.
|
|
27
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The builders depend on the project configuration for the choice of source.
|
|
28
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
29
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkAliasCollection 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.
|
|
30
|
+
*/
|
|
21
31
|
export namespace SdkAliasCollection {
|
|
32
|
+
/**
|
|
33
|
+
* Returns the type reference of a reflected type, with its type arguments.
|
|
34
|
+
*
|
|
35
|
+
* @evidence contracts/common.md#principled-implementation The arguments are built recursively.
|
|
36
|
+
* @evidence contracts/common.md#clear-and-simple-design One recursion.
|
|
37
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It writes the name as reflected.
|
|
38
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
39
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkAliasCollection.name 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.
|
|
40
|
+
*/
|
|
22
41
|
export const name = ({ type }: { type: IReflectType }): TypeNode =>
|
|
23
42
|
factory.createTypeReferenceNode(
|
|
24
43
|
type.name,
|
|
@@ -27,20 +46,58 @@ export namespace SdkAliasCollection {
|
|
|
27
46
|
: undefined,
|
|
28
47
|
);
|
|
29
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Returns the type of one chunk of a binary response:
|
|
51
|
+
* `Uint8Array<ArrayBufferLike>`.
|
|
52
|
+
*
|
|
53
|
+
* @evidence contracts/common.md#principled-implementation The chunk type of the platform stream is a byte array.
|
|
54
|
+
* @evidence contracts/common.md#clear-and-simple-design One node.
|
|
55
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The type is fixed.
|
|
56
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
57
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkAliasCollection.binaryChunk 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.
|
|
58
|
+
*/
|
|
30
59
|
export const binaryChunk = (): TypeNode =>
|
|
31
60
|
factory.createTypeReferenceNode("Uint8Array", [
|
|
32
61
|
factory.createTypeReferenceNode("ArrayBufferLike"),
|
|
33
62
|
]);
|
|
34
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Returns the type of a binary response: `ReadableStream` of its chunks.
|
|
66
|
+
*
|
|
67
|
+
* @evidence contracts/common.md#principled-implementation A binary response is streamed, not read into memory.
|
|
68
|
+
* @evidence contracts/common.md#clear-and-simple-design One node.
|
|
69
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The chunk type is shared.
|
|
70
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
71
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkAliasCollection.binaryResponse 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.
|
|
72
|
+
*/
|
|
35
73
|
export const binaryResponse = (): TypeNode =>
|
|
36
74
|
factory.createTypeReferenceNode("ReadableStream", [binaryChunk()]);
|
|
37
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Returns the type node of a metadata.
|
|
78
|
+
*
|
|
79
|
+
* @evidence contracts/common.md#principled-implementation The metadata is written by the type programmer, so the result is the DTO the clone declares.
|
|
80
|
+
* @evidence contracts/common.md#clear-and-simple-design One delegation.
|
|
81
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It shares the type writer.
|
|
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 SdkAliasCollection.from 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
|
+
*/
|
|
38
85
|
export const from =
|
|
39
86
|
(project: INestiaProject) =>
|
|
40
87
|
(importer: ImportDictionary) =>
|
|
41
88
|
(metadata: MetadataSchema): TypeNode =>
|
|
42
89
|
SdkTypeProgrammer.write(project)(importer)(metadata) as TypeNode;
|
|
43
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Returns the object type of a route's keyword parameters, each with the
|
|
93
|
+
* description of its parameter or its `@param` tag.
|
|
94
|
+
*
|
|
95
|
+
* @evidence contracts/common.md#principled-implementation The entries are the route's path, query, and body parameters, optional where the metadata is, without prefix.
|
|
96
|
+
* @evidence contracts/common.md#clear-and-simple-design One map over the entries.
|
|
97
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts A parameter with a description carries it as a comment.
|
|
98
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
99
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkAliasCollection.httpProps 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.
|
|
100
|
+
*/
|
|
44
101
|
export const httpProps =
|
|
45
102
|
(project: INestiaProject) =>
|
|
46
103
|
(importer: ImportDictionary) =>
|
|
@@ -83,6 +140,16 @@ export namespace SdkAliasCollection {
|
|
|
83
140
|
.flat(),
|
|
84
141
|
);
|
|
85
142
|
|
|
143
|
+
/**
|
|
144
|
+
* Returns the object type of a WebSocket route's keyword parameters: its path
|
|
145
|
+
* parameters, its query, and its provider.
|
|
146
|
+
*
|
|
147
|
+
* @evidence contracts/common.md#principled-implementation The keys are the names decided by the parameter programmer, so the type and the function agree.
|
|
148
|
+
* @evidence contracts/common.md#clear-and-simple-design One literal.
|
|
149
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The names are shared.
|
|
150
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
151
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkAliasCollection.websocketProps 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.
|
|
152
|
+
*/
|
|
86
153
|
export const websocketProps = (
|
|
87
154
|
route: ITypedWebSocketRoute,
|
|
88
155
|
names: SdkWebSocketParameterProgrammer.INames,
|
|
@@ -114,6 +181,16 @@ export namespace SdkAliasCollection {
|
|
|
114
181
|
),
|
|
115
182
|
]);
|
|
116
183
|
|
|
184
|
+
/**
|
|
185
|
+
* Returns the type of a route's headers: its reflected name, or the
|
|
186
|
+
* metadata's type under `clone`.
|
|
187
|
+
*
|
|
188
|
+
* @evidence contracts/common.md#principled-implementation The source follows the `clone` setting.
|
|
189
|
+
* @evidence contracts/common.md#clear-and-simple-design One conditional.
|
|
190
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The choice is made on one flag.
|
|
191
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
192
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkAliasCollection.headers 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.
|
|
193
|
+
*/
|
|
117
194
|
export const headers =
|
|
118
195
|
(project: INestiaProject) =>
|
|
119
196
|
(importer: ImportDictionary) =>
|
|
@@ -133,6 +210,16 @@ export namespace SdkAliasCollection {
|
|
|
133
210
|
);
|
|
134
211
|
};
|
|
135
212
|
|
|
213
|
+
/**
|
|
214
|
+
* Returns the type of a route's query: its metadata under `clone`, otherwise
|
|
215
|
+
* its reflected type wrapped in Resolved unless primitive conversion is off.
|
|
216
|
+
*
|
|
217
|
+
* @evidence contracts/common.md#principled-implementation Clone mode uses the resolved metadata graph; source mode uses the declared type with the configured Resolved conversion.
|
|
218
|
+
* @evidence contracts/common.md#clear-and-simple-design One conditional.
|
|
219
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The choice is made on one flag.
|
|
220
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
221
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkAliasCollection.query 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.
|
|
222
|
+
*/
|
|
136
223
|
export const query =
|
|
137
224
|
(project: INestiaProject) =>
|
|
138
225
|
(importer: ImportDictionary) =>
|
|
@@ -152,6 +239,16 @@ export namespace SdkAliasCollection {
|
|
|
152
239
|
);
|
|
153
240
|
};
|
|
154
241
|
|
|
242
|
+
/**
|
|
243
|
+
* Returns the type of a route's body: a form data input for a multipart body,
|
|
244
|
+
* and otherwise the reflected name or the metadata's type under `clone`.
|
|
245
|
+
*
|
|
246
|
+
* @evidence contracts/common.md#principled-implementation The multipart body is an input of files and fields, not the declared class.
|
|
247
|
+
* @evidence contracts/common.md#clear-and-simple-design One conditional.
|
|
248
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The cases are the content types.
|
|
249
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
250
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkAliasCollection.body 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.
|
|
251
|
+
*/
|
|
155
252
|
export const body =
|
|
156
253
|
(project: INestiaProject) =>
|
|
157
254
|
(importer: ImportDictionary) =>
|
|
@@ -180,14 +277,28 @@ export namespace SdkAliasCollection {
|
|
|
180
277
|
);
|
|
181
278
|
};
|
|
182
279
|
|
|
280
|
+
/**
|
|
281
|
+
* Returns the type of a route's output: the success and every exception as a
|
|
282
|
+
* union of `IPropagation` members, or the success body alone when propagation
|
|
283
|
+
* is off.
|
|
284
|
+
*
|
|
285
|
+
* @evidence contracts/common.md#principled-implementation Status keys retain their declared numeric or range spelling for IPropagation to expand. Source success types follow their content type, while declared exceptions use JSON Primitive conversion independently of the success media type; primitive:false preserves declared source types.
|
|
286
|
+
* @evidence contracts/common.md#clear-and-simple-design One function of two branches.
|
|
287
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The exceptions are the declared ones.
|
|
288
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
289
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkAliasCollection.response 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.
|
|
290
|
+
*/
|
|
183
291
|
export const response =
|
|
184
292
|
(project: INestiaProject) =>
|
|
185
293
|
(importer: ImportDictionary) =>
|
|
186
294
|
(route: ITypedHttpRoute): TypeNode => {
|
|
187
|
-
const schema = (
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
295
|
+
const schema = (
|
|
296
|
+
p: {
|
|
297
|
+
metadata: MetadataSchema;
|
|
298
|
+
type: IReflectType;
|
|
299
|
+
},
|
|
300
|
+
json: boolean,
|
|
301
|
+
): TypeNode =>
|
|
191
302
|
sizeOf(p.metadata) === 0
|
|
192
303
|
? TypeFactory.keyword("void")
|
|
193
304
|
: project.config.clone === true
|
|
@@ -198,11 +309,7 @@ export namespace SdkAliasCollection {
|
|
|
198
309
|
file: "typia",
|
|
199
310
|
declaration: true,
|
|
200
311
|
type: "element",
|
|
201
|
-
name:
|
|
202
|
-
route.success.contentType === "application/json" ||
|
|
203
|
-
route.success.encrypted === true
|
|
204
|
-
? "Primitive"
|
|
205
|
-
: "Resolved",
|
|
312
|
+
name: json ? "Primitive" : "Resolved",
|
|
206
313
|
}),
|
|
207
314
|
[name(p)],
|
|
208
315
|
)
|
|
@@ -210,7 +317,11 @@ export namespace SdkAliasCollection {
|
|
|
210
317
|
const success: TypeNode =
|
|
211
318
|
route.success.binary === true
|
|
212
319
|
? binaryResponse()
|
|
213
|
-
: schema(
|
|
320
|
+
: schema(
|
|
321
|
+
route.success,
|
|
322
|
+
route.success.contentType === "application/json" ||
|
|
323
|
+
route.success.encrypted === true,
|
|
324
|
+
);
|
|
214
325
|
if (project.config.propagate !== true) return success;
|
|
215
326
|
|
|
216
327
|
const branches: IBranch[] = [
|
|
@@ -222,7 +333,7 @@ export namespace SdkAliasCollection {
|
|
|
222
333
|
},
|
|
223
334
|
...Object.entries(route.exceptions).map(([status, value]) => ({
|
|
224
335
|
status,
|
|
225
|
-
type: schema(value),
|
|
336
|
+
type: schema(value, true),
|
|
226
337
|
})),
|
|
227
338
|
];
|
|
228
339
|
return factory.createTypeReferenceNode(
|
|
@@ -257,6 +368,17 @@ export namespace SdkAliasCollection {
|
|
|
257
368
|
);
|
|
258
369
|
};
|
|
259
370
|
|
|
371
|
+
/**
|
|
372
|
+
* Returns the type of the success body: a stream for a binary response, the
|
|
373
|
+
* reflected type for a plain one, and its primitive form for a JSON
|
|
374
|
+
* response.
|
|
375
|
+
*
|
|
376
|
+
* @evidence contracts/common.md#principled-implementation The route's metadata decides between the branches.
|
|
377
|
+
* @evidence contracts/common.md#clear-and-simple-design One function.
|
|
378
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The branches are the response kinds.
|
|
379
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
380
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkAliasCollection.responseBody 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.
|
|
381
|
+
*/
|
|
260
382
|
export const responseBody =
|
|
261
383
|
(project: INestiaProject) =>
|
|
262
384
|
(importer: ImportDictionary) =>
|
|
@@ -4,97 +4,148 @@ import path from "path";
|
|
|
4
4
|
|
|
5
5
|
import { INestiaConfig } from "../../INestiaConfig";
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Composes the npm package of the SDK in the distribution directory.
|
|
9
|
+
*
|
|
10
|
+
* @evidence contracts/common.md#principled-implementation The namespace copies the bundle, fills its paths in, and installs the dependencies at the versions the project uses.
|
|
11
|
+
* @evidence contracts/common.md#clear-and-simple-design One public function and the private steps.
|
|
12
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Each filesystem step resolves against the distribution directory; no process-global directory or foreign method is changed.
|
|
13
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
14
|
+
* @evidence contracts/portability.md#os-neutral-implementation Native paths use path.relative/path.join and generated paths use slash separators. npm receives an argument vector and an explicit cwd. POSIX launches npm directly; Windows launches the npm-cli.js shipped beside the first npm.cmd on PATH through Node because a cmd shim itself requires shell interpretation. A nonstandard Windows npm shim lacking that adjacent npm installation is rejected explicitly.
|
|
15
|
+
*/
|
|
7
16
|
export namespace SdkDistributionComposer {
|
|
17
|
+
/**
|
|
18
|
+
* Prepares the distribution package once: files, paths, and dependencies, and
|
|
19
|
+
* does nothing when the package is already configured.
|
|
20
|
+
*
|
|
21
|
+
* @evidence contracts/common.md#principled-implementation The package counts as configured when it holds `@nestia/fetcher`, which is installed last with its peers, so an interrupted setup runs again. The caller directory is captured once, and every output path and package-manager cwd is explicit.
|
|
22
|
+
* @evidence contracts/common.md#clear-and-simple-design One function of sequential steps.
|
|
23
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts No process-global directory is changed, so independent compositions retain their own destinations.
|
|
24
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
25
|
+
* @evidence contracts/portability.md#os-neutral-implementation Existence of the two package files is the filesystem's own answer, and the bundle files are copied over any file of the same name in a distribution directory that is not yet configured, so an interrupted setup repeats the copy.
|
|
26
|
+
*/
|
|
8
27
|
export const compose = async (props: {
|
|
9
28
|
config: INestiaConfig;
|
|
10
29
|
mcp: boolean;
|
|
11
30
|
websocket: boolean;
|
|
12
31
|
}) => {
|
|
13
|
-
if (!fs.existsSync(props.config.distribute!))
|
|
14
|
-
await fs.promises.mkdir(props.config.distribute!, { recursive: true });
|
|
15
|
-
|
|
16
32
|
const root: string = process.cwd();
|
|
33
|
+
const directory: string = path.resolve(props.config.distribute!);
|
|
17
34
|
const output: string = path.resolve(props.config.output!);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (await configured()) return;
|
|
21
|
-
|
|
22
|
-
// COPY FILES
|
|
23
|
-
console.log("Composing SDK distribution environments...");
|
|
24
|
-
for (const file of await fs.promises.readdir(BUNDLE))
|
|
25
|
-
await fs.promises.copyFile(`${BUNDLE}/${file}`, file);
|
|
26
|
-
|
|
27
|
-
// CONFIGURE PATHS
|
|
28
|
-
for (const file of ["package.json", "tsconfig.json"])
|
|
29
|
-
await replace({ root, output })(file);
|
|
35
|
+
await fs.promises.mkdir(directory, { recursive: true });
|
|
36
|
+
if (await configured(directory)) return;
|
|
30
37
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const v: IDependencies = await dependencies({
|
|
37
|
-
root,
|
|
38
|
-
websocket: props.websocket,
|
|
39
|
-
});
|
|
40
|
-
// one install per dependency kind: each npm run resolves and reifies the
|
|
41
|
-
// whole tree again, and the runtime set lands together or not at all, so
|
|
42
|
-
// an interrupted setup never leaves @nestia/fetcher, which marks the
|
|
43
|
-
// package configured, without its peers
|
|
44
|
-
execute(
|
|
45
|
-
`npm install --save-dev rimraf ttsc@${v.ttsc} typescript@${v.typescript}`,
|
|
46
|
-
);
|
|
47
|
-
execute(
|
|
48
|
-
[
|
|
49
|
-
"npm install --save",
|
|
50
|
-
`@nestia/fetcher@${v.version}`,
|
|
51
|
-
`typia@${v.typia}`,
|
|
52
|
-
...(props.mcp && v.mcp !== undefined
|
|
53
|
-
? [`@modelcontextprotocol/sdk@${v.mcp}`]
|
|
54
|
-
: []),
|
|
55
|
-
...(props.websocket && v.tgrid !== undefined
|
|
56
|
-
? [`tgrid@${v.tgrid}`]
|
|
57
|
-
: []),
|
|
58
|
-
].join(" "),
|
|
38
|
+
console.log("Composing SDK distribution environments...");
|
|
39
|
+
for (const file of await fs.promises.readdir(BUNDLE))
|
|
40
|
+
await fs.promises.copyFile(
|
|
41
|
+
path.join(BUNDLE, file),
|
|
42
|
+
path.join(directory, file),
|
|
59
43
|
);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
44
|
+
for (const file of ["package.json", "tsconfig.json"])
|
|
45
|
+
await replace({ root, output, directory })(file);
|
|
46
|
+
|
|
47
|
+
// Compile with ttsc, which applies typia's transform; typia no longer has
|
|
48
|
+
// a setup command. Install each dependency kind together so an interrupted
|
|
49
|
+
// setup cannot mark @nestia/fetcher configured before its runtime peers.
|
|
50
|
+
const v: IDependencies = await dependencies({
|
|
51
|
+
root,
|
|
52
|
+
websocket: props.websocket,
|
|
53
|
+
});
|
|
54
|
+
execute(directory, [
|
|
55
|
+
"install",
|
|
56
|
+
"--save-dev",
|
|
57
|
+
"rimraf",
|
|
58
|
+
`ttsc@${v.ttsc}`,
|
|
59
|
+
`typescript@${v.typescript}`,
|
|
60
|
+
]);
|
|
61
|
+
execute(directory, [
|
|
62
|
+
"install",
|
|
63
|
+
"--save",
|
|
64
|
+
`@nestia/fetcher@${v.version}`,
|
|
65
|
+
`typia@${v.typia}`,
|
|
66
|
+
...(props.mcp && v.mcp !== undefined
|
|
67
|
+
? [`@modelcontextprotocol/sdk@${v.mcp}`]
|
|
68
|
+
: []),
|
|
69
|
+
...(props.websocket && v.tgrid !== undefined ? [`tgrid@${v.tgrid}`] : []),
|
|
70
|
+
]);
|
|
63
71
|
};
|
|
64
72
|
|
|
65
|
-
const configured = async (): Promise<boolean> =>
|
|
66
|
-
["package.json", "tsconfig.json"].every(
|
|
73
|
+
const configured = async (directory: string): Promise<boolean> =>
|
|
74
|
+
["package.json", "tsconfig.json"].every((file) =>
|
|
75
|
+
fs.existsSync(path.join(directory, file)),
|
|
76
|
+
) &&
|
|
67
77
|
(await (async () => {
|
|
68
78
|
const content = JSON.parse(
|
|
69
|
-
await fs.promises.readFile(
|
|
79
|
+
await fs.promises.readFile(
|
|
80
|
+
path.join(directory, "package.json"),
|
|
81
|
+
"utf8",
|
|
82
|
+
),
|
|
70
83
|
);
|
|
71
84
|
return !!content.dependencies?.["@nestia/fetcher"];
|
|
72
85
|
})());
|
|
73
86
|
|
|
74
|
-
const execute = (
|
|
75
|
-
console.log(` - ${
|
|
76
|
-
|
|
87
|
+
const execute = (cwd: string, args: string[]): void => {
|
|
88
|
+
console.log(` - npm ${args.join(" ")}`);
|
|
89
|
+
if (process.platform !== "win32")
|
|
90
|
+
cp.execFileSync("npm", args, { cwd, stdio: "ignore" });
|
|
91
|
+
else {
|
|
92
|
+
// Windows cannot execute npm.cmd without cmd.exe. Launch the JavaScript
|
|
93
|
+
// entry point installed beside that shim instead, so dependency ranges
|
|
94
|
+
// and paths never pass through a shell's metacharacter interpretation.
|
|
95
|
+
const directories = (process.env.PATH ?? "").split(path.delimiter);
|
|
96
|
+
const directory = directories.find((entry) =>
|
|
97
|
+
fs.existsSync(path.join(entry, "npm.cmd")),
|
|
98
|
+
);
|
|
99
|
+
const cli =
|
|
100
|
+
directory === undefined
|
|
101
|
+
? undefined
|
|
102
|
+
: [
|
|
103
|
+
path.join(directory, "node_modules/npm/bin/npm-cli.js"),
|
|
104
|
+
path.resolve(directory, "../npm/bin/npm-cli.js"),
|
|
105
|
+
].find((entry) => fs.existsSync(entry));
|
|
106
|
+
if (cli === undefined)
|
|
107
|
+
throw new Error(
|
|
108
|
+
"Unable to locate npm's JavaScript entry point beside npm.cmd on PATH.",
|
|
109
|
+
);
|
|
110
|
+
cp.execFileSync(process.execPath, [cli, ...args], {
|
|
111
|
+
cwd,
|
|
112
|
+
stdio: "ignore",
|
|
113
|
+
});
|
|
114
|
+
}
|
|
77
115
|
};
|
|
78
116
|
|
|
79
117
|
const replace =
|
|
80
|
-
(props: { root: string; output: string }) =>
|
|
118
|
+
(props: { root: string; output: string; directory: string }) =>
|
|
81
119
|
async (file: string): Promise<void> => {
|
|
82
120
|
const relative = (from: string) => (to: string) =>
|
|
83
121
|
path.relative(from, to).split("\\").join("/");
|
|
84
|
-
const root: string = relative(
|
|
85
|
-
const output: string = relative(
|
|
86
|
-
const current: string = relative(props.root)(
|
|
87
|
-
|
|
88
|
-
const
|
|
122
|
+
const root: string = relative(props.directory)(props.root);
|
|
123
|
+
const output: string = relative(props.directory)(props.output);
|
|
124
|
+
const current: string = relative(props.root)(props.directory);
|
|
125
|
+
const replacements: Record<string, string> = { root, output, current };
|
|
126
|
+
const location: string = path.join(props.directory, file);
|
|
127
|
+
const content: unknown = JSON.parse(
|
|
128
|
+
await fs.promises.readFile(location, "utf8"),
|
|
129
|
+
);
|
|
130
|
+
const substitute = (value: unknown): unknown => {
|
|
131
|
+
if (typeof value === "string")
|
|
132
|
+
return value.replace(
|
|
133
|
+
/\$\{(root|output|current)\}/g,
|
|
134
|
+
(_match, key: string) => replacements[key]!,
|
|
135
|
+
);
|
|
136
|
+
if (Array.isArray(value)) return value.map(substitute);
|
|
137
|
+
if (value !== null && typeof value === "object")
|
|
138
|
+
return Object.fromEntries(
|
|
139
|
+
Object.entries(value).map(([key, element]) => [
|
|
140
|
+
key,
|
|
141
|
+
substitute(element),
|
|
142
|
+
]),
|
|
143
|
+
);
|
|
144
|
+
return value;
|
|
145
|
+
};
|
|
89
146
|
await fs.promises.writeFile(
|
|
90
|
-
|
|
91
|
-
content
|
|
92
|
-
.split("${root}")
|
|
93
|
-
.join(root)
|
|
94
|
-
.split("${output}")
|
|
95
|
-
.join(output)
|
|
96
|
-
.split("${current}")
|
|
97
|
-
.join(current),
|
|
147
|
+
location,
|
|
148
|
+
JSON.stringify(substitute(content), null, 2) + "\n",
|
|
98
149
|
"utf8",
|
|
99
150
|
);
|
|
100
151
|
};
|
|
@@ -15,10 +15,28 @@ import { SdkMcpRouteProgrammer } from "./SdkMcpRouteProgrammer";
|
|
|
15
15
|
import { SdkRouteDirectory } from "./SdkRouteDirectory";
|
|
16
16
|
import { SdkWebSocketRouteProgrammer } from "./SdkWebSocketRouteProgrammer";
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Writes the functional part of the SDK.
|
|
20
|
+
*
|
|
21
|
+
* @evidence contracts/common.md#principled-implementation The namespace builds the directory tree of the routes by accessor and prints one `index.ts` per directory.
|
|
22
|
+
* @evidence contracts/common.md#clear-and-simple-design One public function and two private helpers.
|
|
23
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The tree follows the accessors of the routes.
|
|
24
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
25
|
+
* @evidence contracts/portability.md#os-neutral-implementation Node mkdir creates native directories from the configured output and analyzed identifier accessors; ImportDictionary separately renders relative module specifiers with forward slashes. No filesystem case equivalence is inferred from route names.
|
|
26
|
+
*/
|
|
18
27
|
export namespace SdkFileProgrammer {
|
|
19
28
|
/* ---------------------------------------------------------
|
|
20
29
|
CONSTRUCTOR
|
|
21
30
|
--------------------------------------------------------- */
|
|
31
|
+
/**
|
|
32
|
+
* Writes the `functional` tree of the SDK from the routes' accessors.
|
|
33
|
+
*
|
|
34
|
+
* @evidence contracts/common.md#principled-implementation A route lands in the directory of its accessor without the last segment, and each directory exports its children as namespaces.
|
|
35
|
+
* @evidence contracts/common.md#clear-and-simple-design One tree build and one recursive writer.
|
|
36
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The order of routes is the analysis order.
|
|
37
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
38
|
+
* @evidence contracts/portability.md#os-neutral-implementation The recursive writer passes output paths to Node fs and FilePrinter, which accept the slash suffixes on Windows and POSIX. Accessor analysis supplies valid namespace names; module specifier spelling remains the importer’s separate responsibility.
|
|
39
|
+
*/
|
|
22
40
|
export const generate = async (app: ITypedApplication): Promise<void> => {
|
|
23
41
|
// CONSTRUCT FOLDER TREE
|
|
24
42
|
const root: SdkRouteDirectory = new SdkRouteDirectory(null, "functional");
|