@nestia/sdk 14.0.1 → 14.0.3
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 +57 -80
- 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 +22 -5
- 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 +31 -1
- package/lib/structures/IOperationMetadata.d.ts +55 -0
- package/lib/structures/IReflectController.d.ts +11 -1
- package/lib/structures/IReflectHttpOperation.d.ts +11 -1
- 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 +27 -2
- 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 +393 -403
- package/package.json +9 -7
- 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 +59 -96
- 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 +48 -1
- package/src/analyses/ReflectWebSocketOperationAnalyzer.ts +34 -14
- 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 +31 -1
- package/src/structures/IOperationMetadata.ts +55 -0
- package/src/structures/IReflectController.ts +11 -1
- package/src/structures/IReflectHttpOperation.ts +11 -1
- 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 +37 -14
- 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
|
@@ -19,11 +19,23 @@ const isVariableName = (str: string): boolean => VARIABLE_REGEX.test(str);
|
|
|
19
19
|
/**
|
|
20
20
|
* Identifier and member-access helpers. The surface kept here is the subset
|
|
21
21
|
* nestia generators actually call (`identifier`, `access`, `parameter`).
|
|
22
|
+
*
|
|
23
|
+
* @evidence contracts/common.md#principled-implementation The functions choose an identifier or a string literal by the syntax of the name, so any string can be a key.
|
|
24
|
+
* @evidence contracts/common.md#clear-and-simple-design Three functions.
|
|
25
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The identifier test is inlined and conservative.
|
|
26
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
27
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation IdentifierFactory constructs TypeScript syntax nodes; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
|
|
22
28
|
*/
|
|
23
29
|
export namespace IdentifierFactory {
|
|
24
30
|
/**
|
|
25
31
|
* Build an identifier or string literal depending on whether `name` is a
|
|
26
32
|
* valid JavaScript identifier.
|
|
33
|
+
*
|
|
34
|
+
* @evidence contracts/common.md#principled-implementation The name is tested against the identifier grammar, and a valid name outside the conservative pattern becomes an equivalent quoted key.
|
|
35
|
+
* @evidence contracts/common.md#clear-and-simple-design One conditional.
|
|
36
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The test applies to every name.
|
|
37
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the two results.
|
|
38
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation IdentifierFactory.identifier constructs TypeScript syntax nodes; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
|
|
27
39
|
*/
|
|
28
40
|
export const identifier = (name: string): Identifier | StringLiteral =>
|
|
29
41
|
isVariableName(name)
|
|
@@ -33,6 +45,12 @@ export namespace IdentifierFactory {
|
|
|
33
45
|
/**
|
|
34
46
|
* Member access on `input` by `key`. Falls back to element access when the
|
|
35
47
|
* key is not a valid identifier.
|
|
48
|
+
*
|
|
49
|
+
* @evidence contracts/common.md#principled-implementation The key becomes a property when it is an identifier and an element access otherwise.
|
|
50
|
+
* @evidence contracts/common.md#clear-and-simple-design One function delegating the naming rule.
|
|
51
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It never concatenates source text.
|
|
52
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the forms.
|
|
53
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation IdentifierFactory.access constructs TypeScript syntax nodes; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
|
|
36
54
|
*/
|
|
37
55
|
export const access = (
|
|
38
56
|
input: Expression,
|
|
@@ -60,6 +78,12 @@ export namespace IdentifierFactory {
|
|
|
60
78
|
/**
|
|
61
79
|
* Parameter declaration with default `any` type when the caller omits one.
|
|
62
80
|
* Passing a `QuestionToken` as `init` marks the parameter optional.
|
|
81
|
+
*
|
|
82
|
+
* @evidence contracts/common.md#principled-implementation The question token becomes the optional marker and any other initializer is passed through.
|
|
83
|
+
* @evidence contracts/common.md#clear-and-simple-design One function.
|
|
84
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It follows the declaration grammar.
|
|
85
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the optional marker.
|
|
86
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation IdentifierFactory.parameter constructs TypeScript syntax nodes; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
|
|
63
87
|
*/
|
|
64
88
|
export const parameter = (
|
|
65
89
|
name: string | Identifier,
|
|
@@ -15,16 +15,43 @@ const isNode = (value: unknown): value is Expression =>
|
|
|
15
15
|
typeof (value as { kind?: unknown }).kind === "string";
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* Recursive value-to-AST-literal builder.
|
|
19
|
-
*
|
|
20
|
-
*
|
|
18
|
+
* Recursive value-to-AST-literal builder. Arrow-function, call-expression and
|
|
19
|
+
* identifier nodes pass through only when the caller explicitly requests
|
|
20
|
+
* expression preservation. Ordinary values may contain the same `kind` names.
|
|
21
|
+
*
|
|
22
|
+
* @evidence contracts/common.md#principled-implementation The namespace maps values to literal nodes by type.
|
|
23
|
+
* @evidence contracts/common.md#clear-and-simple-design One function and two helpers.
|
|
24
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The mapping is by type.
|
|
25
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
26
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation LiteralFactory constructs TypeScript syntax nodes; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
|
|
21
27
|
*/
|
|
22
28
|
export namespace LiteralFactory {
|
|
23
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Builds the expression of a value; arrow function, call, and identifier
|
|
31
|
+
* nodes pass through when `preserveExpressions` is true. Functions become
|
|
32
|
+
* `undefined`; other unsupported types throw, and object properties whose
|
|
33
|
+
* values are undefined are omitted.
|
|
34
|
+
*
|
|
35
|
+
* @evidence contracts/common.md#principled-implementation The value is dispatched by type in a fixed order and containers are written element by element.
|
|
36
|
+
* @evidence contracts/common.md#clear-and-simple-design One function.
|
|
37
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The dispatch is general.
|
|
38
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the mapping.
|
|
39
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation LiteralFactory.write constructs TypeScript syntax nodes; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
|
|
40
|
+
*/
|
|
41
|
+
export const write = (
|
|
42
|
+
input: any,
|
|
43
|
+
preserveExpressions = false,
|
|
44
|
+
): Expression => {
|
|
24
45
|
if (input === null) return factory.createNull();
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
|
|
46
|
+
if (
|
|
47
|
+
preserveExpressions &&
|
|
48
|
+
isNode(input) &&
|
|
49
|
+
PASSTHROUGH_KINDS.has(input.kind)
|
|
50
|
+
)
|
|
51
|
+
return input;
|
|
52
|
+
if (Array.isArray(input)) return writeArray(input, preserveExpressions);
|
|
53
|
+
if (typeof input === "object")
|
|
54
|
+
return writeObject(input as object, preserveExpressions);
|
|
28
55
|
if (typeof input === "boolean")
|
|
29
56
|
return input ? factory.createTrue() : factory.createFalse();
|
|
30
57
|
if (typeof input === "number") return ExpressionFactory.number(input);
|
|
@@ -41,19 +68,25 @@ export namespace LiteralFactory {
|
|
|
41
68
|
throw new TypeError("LiteralFactory.write: unsupported input type.");
|
|
42
69
|
};
|
|
43
70
|
|
|
44
|
-
const writeObject = (obj: object): Expression =>
|
|
71
|
+
const writeObject = (obj: object, preserveExpressions: boolean): Expression =>
|
|
45
72
|
factory.createObjectLiteralExpression(
|
|
46
73
|
Object.entries(obj)
|
|
47
74
|
.filter(([, value]) => value !== undefined)
|
|
48
75
|
.map(([key, value]) =>
|
|
49
76
|
factory.createPropertyAssignment(
|
|
50
77
|
IdentifierFactory.identifier(key),
|
|
51
|
-
write(value),
|
|
78
|
+
write(value, preserveExpressions),
|
|
52
79
|
),
|
|
53
80
|
),
|
|
54
81
|
true,
|
|
55
82
|
);
|
|
56
83
|
|
|
57
|
-
const writeArray = (
|
|
58
|
-
|
|
84
|
+
const writeArray = (
|
|
85
|
+
array: readonly any[],
|
|
86
|
+
preserveExpressions: boolean,
|
|
87
|
+
): Expression =>
|
|
88
|
+
factory.createArrayLiteralExpression(
|
|
89
|
+
array.map((value) => write(value, preserveExpressions)),
|
|
90
|
+
true,
|
|
91
|
+
);
|
|
59
92
|
}
|
|
@@ -8,8 +8,26 @@ import {
|
|
|
8
8
|
|
|
9
9
|
import { TypeFactory } from "./TypeFactory";
|
|
10
10
|
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Variable-statement helpers. `constant` emits `const`, `mut` emits `let`.
|
|
13
|
+
*
|
|
14
|
+
* @evidence contracts/common.md#principled-implementation The namespace builds `let` and `const` statements.
|
|
15
|
+
* @evidence contracts/common.md#clear-and-simple-design Two functions, one for let and one for const.
|
|
16
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It only builds nodes.
|
|
17
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
18
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation StatementFactory constructs TypeScript syntax nodes; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
|
|
19
|
+
*/
|
|
12
20
|
export namespace StatementFactory {
|
|
21
|
+
/**
|
|
22
|
+
* Builds a `let` statement; without a type and an initializer it is typed
|
|
23
|
+
* `any`.
|
|
24
|
+
*
|
|
25
|
+
* @evidence contracts/common.md#principled-implementation A declaration without either would be implicitly any, so the type is stated.
|
|
26
|
+
* @evidence contracts/common.md#clear-and-simple-design One expression.
|
|
27
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It follows the grammar.
|
|
28
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the default type.
|
|
29
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation StatementFactory.mut constructs TypeScript syntax nodes; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
|
|
30
|
+
*/
|
|
13
31
|
export const mut = (props: {
|
|
14
32
|
name: string;
|
|
15
33
|
type?: TypeNode | undefined;
|
|
@@ -34,6 +52,15 @@ export namespace StatementFactory {
|
|
|
34
52
|
),
|
|
35
53
|
);
|
|
36
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Builds a `const` statement from a name, a type, and a value.
|
|
57
|
+
*
|
|
58
|
+
* @evidence contracts/common.md#principled-implementation The declaration list carries the const flag and the given parts.
|
|
59
|
+
* @evidence contracts/common.md#clear-and-simple-design One expression.
|
|
60
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It follows the grammar.
|
|
61
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its inputs.
|
|
62
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation StatementFactory.constant constructs TypeScript syntax nodes; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
|
|
63
|
+
*/
|
|
37
64
|
export const constant = (props: {
|
|
38
65
|
name: string;
|
|
39
66
|
type?: TypeNode | undefined;
|
|
@@ -6,6 +6,12 @@ import { type KeywordTypeNode, SyntaxKind, factory } from "@ttsc/factory";
|
|
|
6
6
|
* Wraps {@link factory.createKeywordTypeNode} with a name-based interface so
|
|
7
7
|
* generator code reads as `TypeFactory.keyword("any")` instead of selecting the
|
|
8
8
|
* `SyntaxKind.AnyKeyword` token by hand.
|
|
9
|
+
*
|
|
10
|
+
* @evidence contracts/common.md#principled-implementation The namespace maps names to the keyword syntax kinds.
|
|
11
|
+
* @evidence contracts/common.md#clear-and-simple-design One table, one type, and one function.
|
|
12
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It only builds nodes.
|
|
13
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
14
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation TypeFactory constructs TypeScript syntax nodes; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
|
|
9
15
|
*/
|
|
10
16
|
export namespace TypeFactory {
|
|
11
17
|
const KEYWORDS = {
|
|
@@ -20,8 +26,26 @@ export namespace TypeFactory {
|
|
|
20
26
|
undefined: SyntaxKind.UndefinedKeyword,
|
|
21
27
|
} as const;
|
|
22
28
|
|
|
29
|
+
/**
|
|
30
|
+
* The names of the supported keyword types.
|
|
31
|
+
*
|
|
32
|
+
* @evidence contracts/common.md#principled-implementation The type is the key set of the table, so a keyword is one table entry.
|
|
33
|
+
* @evidence contracts/common.md#clear-and-simple-design One derived type.
|
|
34
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
|
|
35
|
+
* @evidence contracts/common.md#meaningful-documentation The comment names the set.
|
|
36
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation TypeFactory.Keyword is the key union of the syntax-kind table and defines no native path conversion or process boundary.
|
|
37
|
+
*/
|
|
23
38
|
export type Keyword = keyof typeof KEYWORDS;
|
|
24
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Builds the keyword type node of a name.
|
|
42
|
+
*
|
|
43
|
+
* @evidence contracts/common.md#principled-implementation The name is looked up in the table.
|
|
44
|
+
* @evidence contracts/common.md#clear-and-simple-design One lookup.
|
|
45
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It follows the grammar.
|
|
46
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its input.
|
|
47
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation TypeFactory.keyword constructs TypeScript syntax nodes; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
|
|
48
|
+
*/
|
|
25
49
|
export const keyword = (type: Keyword): KeywordTypeNode =>
|
|
26
50
|
factory.createKeywordTypeNode(KEYWORDS[type]);
|
|
27
51
|
}
|
|
@@ -15,17 +15,38 @@ import { SdkHttpCloneProgrammer } from "./internal/SdkHttpCloneProgrammer";
|
|
|
15
15
|
import { SdkHttpCloneReferencer } from "./internal/SdkHttpCloneReferencer";
|
|
16
16
|
import { SdkWebSocketCloneProgrammer } from "./internal/SdkWebSocketCloneProgrammer";
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Writes the DTO declarations of the SDK: the `structures` files that the
|
|
20
|
+
* functions import when `clone` is on.
|
|
21
|
+
*
|
|
22
|
+
* @evidence contracts/common.md#principled-implementation The namespace composes the declarations from the analyzed types, rewrites the routes to reference them, and prints one file per top-level module.
|
|
23
|
+
* @evidence contracts/common.md#clear-and-simple-design One public function with two private helpers.
|
|
24
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Every declaration goes through the shared printer, and no type is special-cased.
|
|
25
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
26
|
+
* @evidence contracts/portability.md#os-neutral-implementation The writer passes native output locations to Node fs and FilePrinter; module specifiers are produced separately by ImportDictionary. The structures suffix uses forward slashes, which Node accepts on Windows and POSIX, without treating spelling as canonical file identity.
|
|
27
|
+
*/
|
|
18
28
|
export namespace CloneGenerator {
|
|
29
|
+
/**
|
|
30
|
+
* Writes the `structures` directory of the SDK output.
|
|
31
|
+
*
|
|
32
|
+
* Structural route references are updated even when every JSON DTO is inline
|
|
33
|
+
* and no structure file is needed. WebSocket source cloning stays separate.
|
|
34
|
+
*
|
|
35
|
+
* @evidence contracts/common.md#principled-implementation HTTP and MCP JSON declarations share the analyzed collection; WebSocket sources are copied separately. Route references are updated even for inline-only graphs, then named modules are written sequentially so a failure stops at the first file.
|
|
36
|
+
* @evidence contracts/common.md#clear-and-simple-design One function over the two programmers, the referencer, and the file writer.
|
|
37
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The directory is created recursively and its failure is not swallowed.
|
|
38
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
39
|
+
* @evidence contracts/portability.md#os-neutral-implementation Node mkdir creates the output structures directory and FilePrinter writes generated declarations; WebSocket source lookup and copying remain delegated to its source-cloning owner. Filesystem errors propagate rather than being translated into platform-specific shell commands.
|
|
40
|
+
*/
|
|
19
41
|
export const write = async (app: ITypedApplication): Promise<void> => {
|
|
20
42
|
const dict: Map<string, SdkHttpCloneProgrammer.IModule> =
|
|
21
43
|
SdkHttpCloneProgrammer.write(app);
|
|
22
44
|
const websocket: Set<string> = await SdkWebSocketCloneProgrammer.write(app);
|
|
23
|
-
if (dict.size === 0 && websocket.size === 0) return;
|
|
24
|
-
|
|
25
45
|
SdkHttpCloneReferencer.replace(app, websocket);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
46
|
+
if (dict.size === 0 && websocket.size === 0) return;
|
|
47
|
+
await fs.promises.mkdir(`${app.project.config.output}/structures`, {
|
|
48
|
+
recursive: true,
|
|
49
|
+
});
|
|
29
50
|
for (const [key, value] of dict)
|
|
30
51
|
await writeDtoFile(app.project)(key, value);
|
|
31
52
|
};
|
|
@@ -4,7 +4,26 @@ import path from "path";
|
|
|
4
4
|
import { ITypedApplication } from "../structures/ITypedApplication";
|
|
5
5
|
import { E2eFileProgrammer } from "./internal/E2eFileProgrammer";
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Writes the e2e test functions of the SDK.
|
|
9
|
+
*
|
|
10
|
+
* @evidence contracts/common.md#principled-implementation The namespace creates the output directories and writes one test file per HTTP route.
|
|
11
|
+
* @evidence contracts/common.md#clear-and-simple-design One public function and one directory helper.
|
|
12
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Only HTTP routes have a test, and no route is skipped by name.
|
|
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 The output root is resolved with Node path.resolve, descendants use path.join and recursive fs.mkdir creates them. SDK import paths are passed to E2eFileProgrammer independently from native directory paths.
|
|
15
|
+
*/
|
|
7
16
|
export namespace E2eGenerator {
|
|
17
|
+
/**
|
|
18
|
+
* Writes one test function per HTTP route under `features/api/automated` of
|
|
19
|
+
* the e2e output directory, creating the directories as needed.
|
|
20
|
+
*
|
|
21
|
+
* @evidence contracts/common.md#principled-implementation The directories are created recursively, so an existing tree is reused, and each route's file is written in sequence.
|
|
22
|
+
* @evidence contracts/common.md#clear-and-simple-design One loop over the routes.
|
|
23
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts WebSocket and MCP routes are not tests of the HTTP SDK and are left out by protocol.
|
|
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 Native output and SDK roots use path.resolve and path.join before mkdir or file generation. No shell or filesystem case assumption participates; the generated HTTP route names have already passed accessor analysis.
|
|
26
|
+
*/
|
|
8
27
|
export const generate = async (app: ITypedApplication): Promise<void> => {
|
|
9
28
|
console.log("Generating E2E Test Functions");
|
|
10
29
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
|
-
import NodePath from "path";
|
|
3
2
|
|
|
4
3
|
import { INestiaConfig } from "../INestiaConfig";
|
|
5
4
|
import { IReflectOperationError } from "../structures/IReflectOperationError";
|
|
@@ -7,13 +6,34 @@ import { IReflectType } from "../structures/IReflectType";
|
|
|
7
6
|
import { ITypedApplication } from "../structures/ITypedApplication";
|
|
8
7
|
import { ITypedHttpRoute } from "../structures/ITypedHttpRoute";
|
|
9
8
|
import { ITypedMcpRoute } from "../structures/ITypedMcpRoute";
|
|
9
|
+
import { SDK_BUNDLE_PATH } from "../utils/SdkBundlePath";
|
|
10
10
|
import { StringUtil } from "../utils/StringUtil";
|
|
11
11
|
import { CloneGenerator } from "./CloneGenerator";
|
|
12
12
|
import { SdkDistributionComposer } from "./internal/SdkDistributionComposer";
|
|
13
13
|
import { SdkFileProgrammer } from "./internal/SdkFileProgrammer";
|
|
14
14
|
import { SdkHttpParameterProgrammer } from "./internal/SdkHttpParameterProgrammer";
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Generates the SDK library and validates the analyzed routes it needs.
|
|
18
|
+
*
|
|
19
|
+
* @evidence contracts/common.md#principled-implementation The namespace bundles the static files, writes the DTOs and the functions, composes the distribution package, and reports the errors the generation would meet.
|
|
20
|
+
* @evidence contracts/common.md#clear-and-simple-design Two public functions, one public constant, and the private validators.
|
|
21
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Validation and generation share the same route model.
|
|
22
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
23
|
+
* @evidence contracts/portability.md#os-neutral-implementation Static bundle enumeration and output creation use Node fs; declaration/module path conversion and distribution process launching are delegated to ImportDictionary and SdkDistributionComposer. Existing file spelling is checked by the filesystem rather than an OS-name case rule.
|
|
24
|
+
*/
|
|
16
25
|
export namespace SdkGenerator {
|
|
26
|
+
/**
|
|
27
|
+
* Writes the SDK into the configured output directory: the bundled files, the
|
|
28
|
+
* DTOs when `clone` is on, the functions, and the distribution package when
|
|
29
|
+
* `distribute` is set.
|
|
30
|
+
*
|
|
31
|
+
* @evidence contracts/common.md#principled-implementation The steps run in dependency order, the bundle first and the distribution last. An absent output option throws before writing; a configured directory that does not exist is created recursively.
|
|
32
|
+
* @evidence contracts/common.md#clear-and-simple-design One function that delegates each step.
|
|
33
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The steps are sequential and each awaits the previous one.
|
|
34
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
35
|
+
* @evidence contracts/portability.md#os-neutral-implementation Node mkdir and the bundle writer accept the configured native output path; subsequent file and process boundaries belong to their delegated writers. Configuration omission is distinct from a missing on-disk directory.
|
|
36
|
+
*/
|
|
17
37
|
export const generate = async (app: ITypedApplication): Promise<void> => {
|
|
18
38
|
if (app.project.config.output === undefined)
|
|
19
39
|
throw new Error("Output directory is not defined.");
|
|
@@ -40,6 +60,18 @@ export namespace SdkGenerator {
|
|
|
40
60
|
});
|
|
41
61
|
};
|
|
42
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Returns the errors of routes that cannot become an SDK: MCP tools with
|
|
65
|
+
* duplicate names or accessors, and, without `clone`, HTTP routes whose
|
|
66
|
+
* parameter or return types are implicit, plus implicit exception types when
|
|
67
|
+
* propagation is enabled.
|
|
68
|
+
*
|
|
69
|
+
* @evidence contracts/common.md#principled-implementation The MCP checks always apply, and the implicit return check applies only where the SDK would have to name the type, because `clone` writes it as a declaration instead.
|
|
70
|
+
* @evidence contracts/common.md#clear-and-simple-design One function over three checks.
|
|
71
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The list is collected, not thrown, so one run reports every error.
|
|
72
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
73
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation Validation judges analyzed route types and names and performs no native filesystem or process operation.
|
|
74
|
+
*/
|
|
43
75
|
export const validate = (
|
|
44
76
|
app: ITypedApplication,
|
|
45
77
|
): IReflectOperationError[] => {
|
|
@@ -162,6 +194,12 @@ export namespace SdkGenerator {
|
|
|
162
194
|
* Files the user already has are never touched, so that hand-written
|
|
163
195
|
* customizations (e.g. extra re-exports in `module.ts`) survive regeneration.
|
|
164
196
|
* Only missing files are filled in from the bundle.
|
|
197
|
+
*
|
|
198
|
+
* @evidence contracts/common.md#principled-implementation A file that the user has customized is never overwritten, and only files that are missing are filled in from the bundle.
|
|
199
|
+
* @evidence contracts/common.md#clear-and-simple-design One loop with two guards.
|
|
200
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The existing target is checked before the write.
|
|
201
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
202
|
+
* @evidence contracts/portability.md#os-neutral-implementation fs.readdir/stat enumerate the installed bundle and fs.existsSync checks each target under the filesystem's own policy before writing UTF-8. Forward slash suffixes are accepted by Node on supported native platforms; concurrent generation into the same output is not an exclusive ownership guarantee.
|
|
165
203
|
*/
|
|
166
204
|
export const bundle = async (output: string): Promise<void> => {
|
|
167
205
|
const files: string[] = await fs.promises.readdir(BUNDLE_PATH);
|
|
@@ -177,12 +215,5 @@ export namespace SdkGenerator {
|
|
|
177
215
|
}
|
|
178
216
|
};
|
|
179
217
|
|
|
180
|
-
export const BUNDLE_PATH =
|
|
181
|
-
__dirname,
|
|
182
|
-
"..",
|
|
183
|
-
"..",
|
|
184
|
-
"assets",
|
|
185
|
-
"bundle",
|
|
186
|
-
"api",
|
|
187
|
-
);
|
|
218
|
+
export const BUNDLE_PATH = SDK_BUNDLE_PATH;
|
|
188
219
|
}
|
|
@@ -24,9 +24,29 @@ import { ITypedHttpRoute } from "../structures/ITypedHttpRoute";
|
|
|
24
24
|
import { FileRetriever } from "../utils/FileRetriever";
|
|
25
25
|
import { SdkHttpParameterProgrammer } from "./internal/SdkHttpParameterProgrammer";
|
|
26
26
|
import { SwaggerOperationComposer } from "./internal/SwaggerOperationComposer";
|
|
27
|
-
import { SwaggerReadonlyArrayEmender } from "./internal/SwaggerReadonlyArrayEmender";
|
|
28
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Composes and writes the OpenAPI document.
|
|
30
|
+
*
|
|
31
|
+
* @evidence contracts/common.md#principled-implementation The namespace resolves the output location, builds the document from the routes, downgrades it when an older version is configured, and writes it.
|
|
32
|
+
* @evidence contracts/common.md#clear-and-simple-design Three public functions and private helpers for security, customizers, and the copy of the document.
|
|
33
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The composition never edits data it does not own.
|
|
34
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
35
|
+
* @evidence contracts/portability.md#os-neutral-implementation Output locations use Node path.parse/resolve/join and UTF-8 fs writes; package defaults are located through FileRetriever from the current native working directory. HTTP operation paths remain protocol strings handled by PathAnalyzer.
|
|
36
|
+
*/
|
|
29
37
|
export namespace SwaggerGenerator {
|
|
38
|
+
/**
|
|
39
|
+
* Writes the document to the configured location: a `.json` path as it is,
|
|
40
|
+
* and a directory as its `swagger.json`.
|
|
41
|
+
*
|
|
42
|
+
* The document is downgraded when `openapi` names an older version.
|
|
43
|
+
*
|
|
44
|
+
* @evidence contracts/common.md#principled-implementation The directory is created recursively and a failure to create it is reported with its cause; the document is composed, converted, and written in that order.
|
|
45
|
+
* @evidence contracts/common.md#clear-and-simple-design One function.
|
|
46
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The failure to create the directory is not swallowed.
|
|
47
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
48
|
+
* @evidence contracts/portability.md#os-neutral-implementation path.parse classifies an output by its extension, path.resolve and path.dirname obtain native destinations, and fs.mkdir/writeFile own creation and writing without shell interpretation. Any nonempty extension denotes a file; the example .json extension is not an exclusive suffix check.
|
|
49
|
+
*/
|
|
30
50
|
export const generate = async (app: ITypedApplication): Promise<void> => {
|
|
31
51
|
// GET CONFIGURATION
|
|
32
52
|
console.log("Generating Swagger Document");
|
|
@@ -40,14 +60,15 @@ export namespace SwaggerGenerator {
|
|
|
40
60
|
? path.resolve(config.output)
|
|
41
61
|
: path.join(path.resolve(config.output), "swagger.json");
|
|
42
62
|
const directory: string = path.dirname(location);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
} catch {}
|
|
47
|
-
if (fs.existsSync(directory) === false)
|
|
63
|
+
try {
|
|
64
|
+
await fs.promises.mkdir(directory, { recursive: true });
|
|
65
|
+
} catch (error) {
|
|
48
66
|
throw new Error(
|
|
49
|
-
`Error on NestiaApplication.swagger(): failed to create output directory: ${directory}
|
|
67
|
+
`Error on NestiaApplication.swagger(): failed to create output directory: ${directory} (${
|
|
68
|
+
error instanceof Error ? error.message : String(error)
|
|
69
|
+
})`,
|
|
50
70
|
);
|
|
71
|
+
}
|
|
51
72
|
// COMPOSE SWAGGER DOCUMENT
|
|
52
73
|
const document: OpenApi.IDocument = compose({
|
|
53
74
|
config,
|
|
@@ -76,6 +97,19 @@ export namespace SwaggerGenerator {
|
|
|
76
97
|
);
|
|
77
98
|
};
|
|
78
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Composes the document of the HTTP routes into the given document: the
|
|
102
|
+
* components of every schema, and the paths.
|
|
103
|
+
*
|
|
104
|
+
* A route tagged `@internal` or `@hidden`, or excluded by
|
|
105
|
+
* `@ApiExcludeEndpoint`, is left out.
|
|
106
|
+
*
|
|
107
|
+
* @evidence contracts/common.md#principled-implementation The schemas of all routes are composed in one call, so a component shared by routes exists once, and the readonly arrays are emended before the paths refer to them.
|
|
108
|
+
* @evidence contracts/common.md#clear-and-simple-design One function of sequential steps.
|
|
109
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The exclusion is the documented set of tags and decorators.
|
|
110
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
111
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation compose operates on analyzed metadata and OpenAPI protocol paths; it neither opens native files nor launches processes.
|
|
112
|
+
*/
|
|
79
113
|
export const compose = (props: {
|
|
80
114
|
config: Omit<INestiaConfig.ISwaggerConfig, "output">;
|
|
81
115
|
routes: ITypedHttpRoute[];
|
|
@@ -102,13 +136,6 @@ export namespace SwaggerGenerator {
|
|
|
102
136
|
version: "3.1",
|
|
103
137
|
metadatas,
|
|
104
138
|
});
|
|
105
|
-
json.schemas.forEach((schema, i) =>
|
|
106
|
-
SwaggerReadonlyArrayEmender.emend({
|
|
107
|
-
components: json.components,
|
|
108
|
-
schema,
|
|
109
|
-
metadata: metadatas[i]!,
|
|
110
|
-
}),
|
|
111
|
-
);
|
|
112
139
|
const dict: WeakMap<MetadataSchema, OpenApi.IJsonSchema> = new WeakMap();
|
|
113
140
|
json.schemas.forEach((schema, i) => dict.set(metadatas[i]!, schema));
|
|
114
141
|
const schema = (
|
|
@@ -128,6 +155,21 @@ export namespace SwaggerGenerator {
|
|
|
128
155
|
return document;
|
|
129
156
|
};
|
|
130
157
|
|
|
158
|
+
/**
|
|
159
|
+
* Returns the document the composition starts from: the configured info,
|
|
160
|
+
* servers, security schemes, and tags, or the defaults.
|
|
161
|
+
*
|
|
162
|
+
* Tags are copied immediately; configured servers, security schemes and
|
|
163
|
+
* nested info values remain shared until compose detaches the document before
|
|
164
|
+
* customizers run. Callers using initialize alone must preserve those shared
|
|
165
|
+
* values.
|
|
166
|
+
*
|
|
167
|
+
* @evidence contracts/common.md#principled-implementation A per-call lazy Singleton reads package metadata at most once when info defaults need it. Each call allocates a document and copies the tag list; configured servers, security schemes and nested info values are detached later by compose before customization.
|
|
168
|
+
* @evidence contracts/common.md#clear-and-simple-design One function.
|
|
169
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The defaults follow the configuration contract; initialize does not mutate configured values, while compose owns detaching the remaining shared JSON trees.
|
|
170
|
+
* @evidence contracts/common.md#meaningful-documentation The comment identifies defaults and distinguishes the immediate tag copy from values shared until compose, including the restriction on initialize-only callers.
|
|
171
|
+
* @evidence contracts/portability.md#os-neutral-implementation The lazy package-info reader starts from process.cwd and FileRetriever supplies the nearest package.json within its bounded native-parent search. fs.readFile reads UTF-8; unreadable or malformed package metadata yields documented info defaults rather than an OS-specific fallback command.
|
|
172
|
+
*/
|
|
131
173
|
export const initialize = async (
|
|
132
174
|
config: Omit<INestiaConfig.ISwaggerConfig, "output">,
|
|
133
175
|
): Promise<OpenApi.IDocument> => {
|
|
@@ -17,7 +17,26 @@ import { SdkAliasCollection } from "./SdkAliasCollection";
|
|
|
17
17
|
import { SdkHttpParameterProgrammer } from "./SdkHttpParameterProgrammer";
|
|
18
18
|
import { SdkImportWizard } from "./SdkImportWizard";
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Writes the e2e test file of one HTTP route.
|
|
22
|
+
*
|
|
23
|
+
* @evidence contracts/common.md#principled-implementation The namespace prints an exported function that calls the route's SDK function with random arguments and asserts its result.
|
|
24
|
+
* @evidence contracts/common.md#clear-and-simple-design One public function and private helpers.
|
|
25
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The generated file uses the SDK the same way a user does.
|
|
26
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
27
|
+
* @evidence contracts/portability.md#os-neutral-implementation The caller supplies native api/current locations; ImportDictionary converts relative imports to slash-separated language specifiers, and FilePrinter writes the computed test pathname through Node fs with UTF-8. No filename case policy is inferred.
|
|
28
|
+
*/
|
|
20
29
|
export namespace E2eFileProgrammer {
|
|
30
|
+
/**
|
|
31
|
+
* Writes the test file of a route, named after its accessor, with the imports
|
|
32
|
+
* it needs.
|
|
33
|
+
*
|
|
34
|
+
* @evidence contracts/common.md#principled-implementation The imports are collected while the function is built and printed before it.
|
|
35
|
+
* @evidence contracts/common.md#clear-and-simple-design One function.
|
|
36
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The file name is derived from the route accessor.
|
|
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 caller supplies native api/current locations; ImportDictionary converts relative imports to slash-separated language specifiers, and FilePrinter writes the computed test pathname through Node fs with UTF-8. No filename case policy is inferred.
|
|
39
|
+
*/
|
|
21
40
|
export const generate =
|
|
22
41
|
(project: INestiaProject) =>
|
|
23
42
|
(props: { api: string; current: string }) =>
|
|
@@ -142,6 +161,7 @@ export namespace E2eFileProgrammer {
|
|
|
142
161
|
),
|
|
143
162
|
]),
|
|
144
163
|
),
|
|
164
|
+
true,
|
|
145
165
|
),
|
|
146
166
|
]
|
|
147
167
|
: entries.map((e) =>
|
|
@@ -9,7 +9,26 @@ import {
|
|
|
9
9
|
import fs from "fs";
|
|
10
10
|
import { format } from "prettier";
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Prints generated syntax trees to files.
|
|
14
|
+
*
|
|
15
|
+
* @evidence contracts/common.md#principled-implementation The namespace attaches comments, writes tags, prints statements, and formats the result.
|
|
16
|
+
* @evidence contracts/common.md#clear-and-simple-design Four functions and one private formatter.
|
|
17
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Formatting failure keeps the unformatted script.
|
|
18
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
19
|
+
* @evidence contracts/portability.md#os-neutral-implementation Only write crosses the native filesystem boundary, through fs.promises.writeFile with the caller's location and UTF-8. The other helpers construct language comments and syntax independently of native path identity or separators.
|
|
20
|
+
*/
|
|
12
21
|
export namespace FilePrinter {
|
|
22
|
+
/**
|
|
23
|
+
* Attaches a comment to a node as a JSDoc block, escaping every comment
|
|
24
|
+
* terminator in it so the comment cannot end early.
|
|
25
|
+
*
|
|
26
|
+
* @evidence contracts/common.md#principled-implementation Each line of the comment becomes one JSDoc line and an empty comment adds nothing.
|
|
27
|
+
* @evidence contracts/common.md#clear-and-simple-design One function.
|
|
28
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The closing marker is escaped rather than dropped.
|
|
29
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
30
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation description attaches language-level comment text to an AST and performs no native filesystem or process operation.
|
|
31
|
+
*/
|
|
13
32
|
export const description = <T extends Node>(node: T, comment: string): T => {
|
|
14
33
|
if (comment.length === 0) return node;
|
|
15
34
|
return addSyntheticLeadingComment(
|
|
@@ -43,6 +62,11 @@ export namespace FilePrinter {
|
|
|
43
62
|
*
|
|
44
63
|
* @param head The tag's name, followed by a `@param` tag's parameter name
|
|
45
64
|
* @param text The tag's text
|
|
65
|
+
* @evidence contracts/common.md#principled-implementation The margin is the width of the head, and a text whose first line is indented starts on the next line.
|
|
66
|
+
* @evidence contracts/common.md#clear-and-simple-design One function.
|
|
67
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Every line keeps the indentation it has beyond the margin.
|
|
68
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
69
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation jsDocTag formats TypeScript comment text; indentation and line feeds express language syntax rather than native paths or handles.
|
|
46
70
|
*/
|
|
47
71
|
export const jsDocTag = (head: string, text: string): string => {
|
|
48
72
|
const lines: string[] = text.split("\n").map((line) => line.trimEnd());
|
|
@@ -59,9 +83,28 @@ export namespace FilePrinter {
|
|
|
59
83
|
].join("\n");
|
|
60
84
|
};
|
|
61
85
|
|
|
86
|
+
/**
|
|
87
|
+
* Returns a statement that prints as an empty line.
|
|
88
|
+
*
|
|
89
|
+
* @evidence contracts/common.md#principled-implementation A line break is an identifier statement, which the printer emits between its neighbors.
|
|
90
|
+
* @evidence contracts/common.md#clear-and-simple-design One expression.
|
|
91
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The printer places the break where it is used.
|
|
92
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
93
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation enter returns a language AST node and owns no filesystem or process boundary.
|
|
94
|
+
*/
|
|
62
95
|
export const enter = () =>
|
|
63
96
|
factory.createExpressionStatement(factory.createIdentifier("\n"));
|
|
64
97
|
|
|
98
|
+
/**
|
|
99
|
+
* Prints the statements to the location, prefixed by the optional top text,
|
|
100
|
+
* and formats the script.
|
|
101
|
+
*
|
|
102
|
+
* @evidence contracts/common.md#principled-implementation The script is formatted with Prettier, and the unformatted script is written when the formatter throws, so a formatting failure never loses the file.
|
|
103
|
+
* @evidence contracts/common.md#clear-and-simple-design One function.
|
|
104
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The write is awaited and its failure is thrown.
|
|
105
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
106
|
+
* @evidence contracts/portability.md#os-neutral-implementation writeFile receives the native pathname as a separate argument and writes UTF-8 after formatting. Its caller owns parent-directory creation; write failures propagate on every platform without shell quoting or separator rewriting.
|
|
107
|
+
*/
|
|
65
108
|
export const write = async (props: {
|
|
66
109
|
location: string;
|
|
67
110
|
statements: Node[];
|