@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
|
@@ -4,6 +4,16 @@ import { MetadataSchema } from "../internal/legacy";
|
|
|
4
4
|
import { HttpResponseContentTypeUtil } from "../utils/HttpResponseContentTypeUtil";
|
|
5
5
|
import { IReflectType } from "./IReflectType";
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* A typed success response: its type, status, content type, binary and
|
|
9
|
+
* encrypted flags, metadata, examples, and header directives.
|
|
10
|
+
*
|
|
11
|
+
* @evidence contracts/common.md#principled-implementation The header directives are the `@setHeader` and `@assignHeaders` tags, which the SDK function applies to the connection.
|
|
12
|
+
* @evidence contracts/common.md#clear-and-simple-design A flat record with no behavior.
|
|
13
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
|
|
14
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the type describes; its members are named for their meaning.
|
|
15
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation ITypedHttpRouteSuccess describes protocol or type metadata; any embedded import/source record preserves the identity supplied by its owner. This declaration defines no native path conversion or process boundary.
|
|
16
|
+
*/
|
|
7
17
|
export interface ITypedHttpRouteSuccess {
|
|
8
18
|
type: IReflectType;
|
|
9
19
|
status: number | null;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IJsDocTagInfo } from "typia";
|
|
2
2
|
|
|
3
|
+
import { MetadataSchema } from "../internal/legacy";
|
|
3
4
|
import { IReflectController } from "./IReflectController";
|
|
4
5
|
import { IReflectImport } from "./IReflectImport";
|
|
5
6
|
import { IReflectMcpOperation } from "./IReflectMcpOperation";
|
|
@@ -12,6 +13,12 @@ import { IReflectType } from "./IReflectType";
|
|
|
12
13
|
* Carries everything the SDK generator needs to emit a typed client function:
|
|
13
14
|
* the controller reference, accessor path, typia-derived input schema, and
|
|
14
15
|
* input/output type info.
|
|
16
|
+
*
|
|
17
|
+
* @evidence contracts/common.md#principled-implementation The record is the tool operation in the form the SDK generator reads.
|
|
18
|
+
* @evidence contracts/common.md#clear-and-simple-design A flat record with no behavior.
|
|
19
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
|
|
20
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the type describes; its members are named for their meaning.
|
|
21
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation ITypedMcpRoute describes protocol or type metadata; any embedded import/source record preserves the identity supplied by its owner. This declaration defines no native path conversion or process boundary.
|
|
15
22
|
*/
|
|
16
23
|
export interface ITypedMcpRoute {
|
|
17
24
|
protocol: "mcp";
|
|
@@ -24,6 +31,11 @@ export interface ITypedMcpRoute {
|
|
|
24
31
|
function: Function;
|
|
25
32
|
input: IReflectMcpOperationParameter | null;
|
|
26
33
|
returnType: IReflectType | null;
|
|
34
|
+
/** Resolved JSON wire graphs used by structural DTO cloning. */
|
|
35
|
+
inputMetadata?: MetadataSchema;
|
|
36
|
+
|
|
37
|
+
/** Absent when source-only analysis was requested without cloning. */
|
|
38
|
+
outputMetadata?: MetadataSchema;
|
|
27
39
|
inputSchema: object;
|
|
28
40
|
outputSchema: object | null;
|
|
29
41
|
annotations: IReflectMcpOperation.IAnnotations | null;
|
|
@@ -5,6 +5,16 @@ import { IReflectController } from "./IReflectController";
|
|
|
5
5
|
import { IReflectImport } from "./IReflectImport";
|
|
6
6
|
import { ITypedWebSocketRouteParameter } from "./ITypedWebSocketRouteParameter";
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* A typed WebSocket route: one path with its acceptor, header, path parameters,
|
|
10
|
+
* query, and driver separated.
|
|
11
|
+
*
|
|
12
|
+
* @evidence contracts/common.md#principled-implementation The reflected operation is expanded per path and its parameters are classified.
|
|
13
|
+
* @evidence contracts/common.md#clear-and-simple-design A flat record with no behavior.
|
|
14
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
|
|
15
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the type describes; its members are named for their meaning.
|
|
16
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation ITypedWebSocketRoute describes protocol or type metadata; any embedded import/source record preserves the identity supplied by its owner. This declaration defines no native path conversion or process boundary.
|
|
17
|
+
*/
|
|
8
18
|
export interface ITypedWebSocketRoute {
|
|
9
19
|
protocol: "websocket";
|
|
10
20
|
controller: IReflectController;
|
package/src/transform.ts
CHANGED
|
@@ -11,6 +11,12 @@ import type { ITtscPlugin, ITtscPluginFactoryContext } from "ttsc";
|
|
|
11
11
|
* contributor — but only for projects that actually depend on `@nestia/sdk`. A
|
|
12
12
|
* project depending on `@nestia/core` alone never links, compiles, or ships any
|
|
13
13
|
* of this SDK transform code.
|
|
14
|
+
*
|
|
15
|
+
* @evidence contracts/common.md#principled-implementation The package root is resolved through `@nestia/sdk/package.json` from the consumer's project, so the source path is the installed package's, not a workspace layout, and the descriptor returns only a name and a source directory.
|
|
16
|
+
* @evidence contracts/common.md#clear-and-simple-design One function returning two properties; the transform itself is native.
|
|
17
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The resolution goes through the package manifest, as the development rules require, and nothing is patched.
|
|
18
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the descriptor returns.
|
|
19
|
+
* @evidence contracts/portability.md#os-neutral-implementation createRequire anchors package resolution to the consumer project's package.json; Node resolution yields the installed manifest's native pathname and path.dirname/path.resolve derive the contributor source without a workspace-specific separator or shell lookup.
|
|
14
20
|
*/
|
|
15
21
|
export default function createTtscPlugin(
|
|
16
22
|
context: ITtscPluginFactoryContext,
|
package/src/utils/ArrayUtil.ts
CHANGED
|
@@ -1,10 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Array helpers of the SDK generator.
|
|
3
|
+
*
|
|
4
|
+
* @evidence contracts/common.md#principled-implementation The namespace holds a membership test and a sequential asynchronous map.
|
|
5
|
+
* @evidence contracts/common.md#clear-and-simple-design Two functions.
|
|
6
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts They are plain helpers.
|
|
7
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
8
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation ArrayUtil operates on caller-supplied arrays and promises without resolving file identity or launching a process; callback boundaries remain the caller's responsibility.
|
|
9
|
+
*/
|
|
1
10
|
export namespace ArrayUtil {
|
|
11
|
+
/**
|
|
12
|
+
* Reports whether the array contains every one of the items.
|
|
13
|
+
*
|
|
14
|
+
* Membership uses `includes`, so an `undefined` or `NaN` item is found when
|
|
15
|
+
* the array holds it.
|
|
16
|
+
*
|
|
17
|
+
* @evidence contracts/common.md#principled-implementation `Array.prototype.includes` compares by SameValueZero and the result is the conjunction over the items.
|
|
18
|
+
* @evidence contracts/common.md#clear-and-simple-design One `every` over `includes`.
|
|
19
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts No item is special-cased.
|
|
20
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the conjunction and the comparison.
|
|
21
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation ArrayUtil.has operates on caller-supplied arrays and promises without resolving file identity or launching a process; callback boundaries remain the caller's responsibility.
|
|
22
|
+
*/
|
|
2
23
|
export function has<T>(array: T[], ...items: T[]): boolean {
|
|
3
|
-
return items.every(
|
|
4
|
-
(elem) => array.find((org) => org === elem) !== undefined,
|
|
5
|
-
);
|
|
24
|
+
return items.every((item) => array.includes(item));
|
|
6
25
|
}
|
|
7
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Maps the elements with an asynchronous function, one after another, and
|
|
29
|
+
* returns the results in order.
|
|
30
|
+
*
|
|
31
|
+
* @evidence contracts/common.md#principled-implementation Each call is awaited before the next starts, so the order of the results is the order of the elements and a rejection stops the mapping.
|
|
32
|
+
* @evidence contracts/common.md#clear-and-simple-design One loop.
|
|
33
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts No element is skipped or retried.
|
|
34
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the sequential order.
|
|
35
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation ArrayUtil.asyncMap operates on caller-supplied arrays and promises without resolving file identity or launching a process; callback boundaries remain the caller's responsibility.
|
|
36
|
+
*/
|
|
8
37
|
export async function asyncMap<X, Y>(
|
|
9
38
|
array: X[],
|
|
10
39
|
closure: (input: X) => Promise<Y>,
|
|
@@ -13,14 +42,4 @@ export namespace ArrayUtil {
|
|
|
13
42
|
for (const elem of array) ret.push(await closure(elem));
|
|
14
43
|
return ret;
|
|
15
44
|
}
|
|
16
|
-
|
|
17
|
-
export async function asyncFilter<T>(
|
|
18
|
-
array: T[],
|
|
19
|
-
closure: (input: T) => Promise<boolean>,
|
|
20
|
-
): Promise<T[]> {
|
|
21
|
-
const ret: T[] = [];
|
|
22
|
-
for (const elem of array)
|
|
23
|
-
if ((await closure(elem)) === true) ret.push(elem);
|
|
24
|
-
return ret;
|
|
25
|
-
}
|
|
26
45
|
}
|
|
@@ -1,14 +1,34 @@
|
|
|
1
|
+
import { parse } from "@babel/parser";
|
|
1
2
|
import fs from "fs";
|
|
2
3
|
import path from "path";
|
|
3
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Patches JavaScript emitted into a temporary directory so that it loads as
|
|
7
|
+
* CommonJS.
|
|
8
|
+
*
|
|
9
|
+
* @evidence contracts/common.md#principled-implementation A compiler can keep `import.meta.url` in CommonJS output, and Node then detects the file as ESM before `require()` loads it, so the token is replaced by an expression that gives the same URL.
|
|
10
|
+
* @evidence contracts/common.md#clear-and-simple-design One public function collects emitted files and a JavaScript parser identifies import.meta.url expressions by their syntax nodes; source slices retain all unrelated text.
|
|
11
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The patch changes only the temporary emit. The parser reads JavaScript grammar, so regular expressions after control-flow statements and property names resembling import.meta.url remain untouched; no previous-token approximation substitutes for parsing.
|
|
12
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
13
|
+
* @evidence contracts/portability.md#os-neutral-implementation Entries are listed with `readdir` and joined with `path.join`; only regular `.js` and `.cjs` files, named case-insensitively, are read and rewritten as UTF-8, and symbolic links and other entry kinds are left alone. The replacement derives the file URL with `url.pathToFileURL(__filename)`, the platform's own conversion, so drive letters, UNC paths and percent-encoding follow the rules of `import.meta.url`. The text outside the token, line endings included, is preserved.
|
|
14
|
+
*/
|
|
4
15
|
export namespace EmittedJavaScriptPatcher {
|
|
16
|
+
/**
|
|
17
|
+
* Replaces every `import.meta.url` in the `.js` and `.cjs` files under a
|
|
18
|
+
* directory with `require("url").pathToFileURL(__filename).href`.
|
|
19
|
+
*
|
|
20
|
+
* @evidence contracts/common.md#principled-implementation The parser selects only a non-computed url property whose object is the import.meta meta-property, including spaced expressions and template substitutions. Literal and comment text is never an expression node, and the replacement derives the executing CommonJS file URL.
|
|
21
|
+
* @evidence contracts/common.md#clear-and-simple-design One function collects files and delegates expression detection to the JavaScript grammar parser.
|
|
22
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It patches only files that contain the token.
|
|
23
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the replacement and the scope.
|
|
24
|
+
* @evidence contracts/portability.md#os-neutral-implementation Files are read and rewritten concurrently without locking, one pending operation per file, so the caller must be the only writer of the directory, as it is for its own temporary emit.
|
|
25
|
+
*/
|
|
5
26
|
export const importMetaUrl = async (root: string): Promise<void> => {
|
|
6
27
|
const files: string[] = await collect(root);
|
|
7
28
|
await Promise.all(files.map(patch));
|
|
8
29
|
};
|
|
9
30
|
}
|
|
10
31
|
|
|
11
|
-
const TARGET = "import.meta.url";
|
|
12
32
|
// TypeScript can preserve this token even in CommonJS output. Node 24 then
|
|
13
33
|
// syntax-detects the temporary `.js` file as ESM before require() can load it.
|
|
14
34
|
const REPLACEMENT = 'require("url").pathToFileURL(__filename).href';
|
|
@@ -30,59 +50,62 @@ const collect = async (location: string): Promise<string[]> => {
|
|
|
30
50
|
|
|
31
51
|
const patch = async (file: string): Promise<void> => {
|
|
32
52
|
const before: string = await fs.promises.readFile(file, "utf8");
|
|
33
|
-
if (before.includes(
|
|
53
|
+
if (before.includes("import") === false) return;
|
|
34
54
|
|
|
35
55
|
const after: string = replaceImportMetaUrl(before);
|
|
36
56
|
if (after !== before) await fs.promises.writeFile(file, after, "utf8");
|
|
37
57
|
};
|
|
38
58
|
|
|
59
|
+
// Parse module expressions without imposing module strictness: TypeScript may preserve
|
|
60
|
+
// import.meta in otherwise CommonJS output. Top-level return is valid inside
|
|
61
|
+
// Node's CommonJS wrapper. The parser, rather than token context guesses, owns
|
|
62
|
+
// the distinction between regular expressions, divisions and property names.
|
|
39
63
|
const replaceImportMetaUrl = (input: string): string => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
64
|
+
const root = parse(input, {
|
|
65
|
+
sourceType: "module",
|
|
66
|
+
strictMode: false,
|
|
67
|
+
attachComment: false,
|
|
68
|
+
allowImportExportEverywhere: true,
|
|
69
|
+
allowReturnOutsideFunction: true,
|
|
70
|
+
allowAwaitOutsideFunction: true,
|
|
71
|
+
});
|
|
72
|
+
const spans: Array<{ start: number; end: number }> = [];
|
|
73
|
+
const pending: Array<{
|
|
74
|
+
type: string;
|
|
75
|
+
start?: number | null;
|
|
76
|
+
end?: number | null;
|
|
77
|
+
}> = [root];
|
|
78
|
+
while (pending.length !== 0) {
|
|
79
|
+
const node = pending.pop()! as Record<string, any>;
|
|
80
|
+
if (
|
|
81
|
+
node.type === "MemberExpression" &&
|
|
82
|
+
node.computed === false &&
|
|
83
|
+
node.property?.type === "Identifier" &&
|
|
84
|
+
node.property.name === "url" &&
|
|
85
|
+
node.object?.type === "MetaProperty" &&
|
|
86
|
+
node.object.meta.name === "import" &&
|
|
87
|
+
node.object.property.name === "meta"
|
|
88
|
+
)
|
|
89
|
+
spans.push({ start: node.start, end: node.end });
|
|
90
|
+
for (const value of Object.values(node)) {
|
|
91
|
+
if (Array.isArray(value)) {
|
|
92
|
+
for (const child of value)
|
|
93
|
+
if (child && typeof child.type === "string") pending.push(child);
|
|
94
|
+
} else if (
|
|
95
|
+
value &&
|
|
96
|
+
typeof value === "object" &&
|
|
97
|
+
typeof value.type === "string"
|
|
98
|
+
)
|
|
99
|
+
pending.push(value);
|
|
49
100
|
}
|
|
50
|
-
|
|
51
|
-
const ch: string = input[i]!;
|
|
52
|
-
const next: string | undefined = input[i + 1];
|
|
53
|
-
if (ch === '"' || ch === "'") i = skipQuoted(input, i, ch);
|
|
54
|
-
else if (ch === "/" && next === "/") i = skipLineComment(input, i);
|
|
55
|
-
else if (ch === "/" && next === "*") i = skipBlockComment(input, i);
|
|
56
|
-
else ++i;
|
|
57
101
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
isBoundary(input[index + TARGET.length]);
|
|
65
|
-
|
|
66
|
-
const isBoundary = (ch: string | undefined): boolean =>
|
|
67
|
-
ch === undefined || /[^A-Za-z0-9_$]/.test(ch);
|
|
68
|
-
|
|
69
|
-
const skipQuoted = (input: string, index: number, quote: string): number => {
|
|
70
|
-
let escaped: boolean = false;
|
|
71
|
-
for (let i = index + 1; i < input.length; ++i) {
|
|
72
|
-
const ch: string = input[i]!;
|
|
73
|
-
if (escaped) escaped = false;
|
|
74
|
-
else if (ch === "\\") escaped = true;
|
|
75
|
-
else if (ch === quote) return i + 1;
|
|
102
|
+
spans.sort((a, b) => a.start - b.start);
|
|
103
|
+
const pieces: string[] = [];
|
|
104
|
+
let cursor = 0;
|
|
105
|
+
for (const span of spans) {
|
|
106
|
+
pieces.push(input.slice(cursor, span.start), REPLACEMENT);
|
|
107
|
+
cursor = span.end;
|
|
76
108
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const skipLineComment = (input: string, index: number): number => {
|
|
81
|
-
const found: number = input.indexOf("\n", index + 2);
|
|
82
|
-
return found === -1 ? input.length : found + 1;
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
const skipBlockComment = (input: string, index: number): number => {
|
|
86
|
-
const found: number = input.indexOf("*/", index + 2);
|
|
87
|
-
return found === -1 ? input.length : found + 2;
|
|
109
|
+
pieces.push(input.slice(cursor));
|
|
110
|
+
return pieces.join("");
|
|
88
111
|
};
|
|
@@ -1,7 +1,26 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Finds a file or a directory by name, in a directory and up to three parents.
|
|
6
|
+
*
|
|
7
|
+
* @evidence contracts/common.md#principled-implementation The search checks a directory and then goes to its parent, at most three levels up, which is where a project's own files are expected.
|
|
8
|
+
* @evidence contracts/common.md#clear-and-simple-design Two curried functions with the same recursion.
|
|
9
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The limit is a fixed search depth, not a file name.
|
|
10
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
11
|
+
* @evidence contracts/portability.md#os-neutral-implementation Names are joined to directories with `path.join` and tested with `existsSync`, so the volume decides what a name matches and under which case policy. The parent is `path.join(dir, "..")`, which stays at a filesystem root, and the depth counter bounds the climb, so no drive letter or separator test is needed. Directories are returned as joined, not canonicalized, so equal locations reached through links or a different case may compare unequal.
|
|
12
|
+
*/
|
|
4
13
|
export namespace FileRetriever {
|
|
14
|
+
/**
|
|
15
|
+
* Returns the nearest directory, from the given one up to three parents, that
|
|
16
|
+
* contains an entry with the name, or `null`.
|
|
17
|
+
*
|
|
18
|
+
* @evidence contracts/common.md#principled-implementation The recursion is bounded by the depth counter, so it terminates at the filesystem root as well.
|
|
19
|
+
* @evidence contracts/common.md#clear-and-simple-design One function.
|
|
20
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The bound is explicit.
|
|
21
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the result.
|
|
22
|
+
* @evidence contracts/portability.md#os-neutral-implementation The result is the directory as the caller spelled it joined with `..` steps; the existence test of the named entry alone decides, under the filesystem's own case policy.
|
|
23
|
+
*/
|
|
5
24
|
export const directory =
|
|
6
25
|
(name: string) =>
|
|
7
26
|
(dir: string, depth: number = 0): string | null => {
|
|
@@ -11,6 +30,16 @@ export namespace FileRetriever {
|
|
|
11
30
|
return directory(name)(path.join(dir, ".."), depth + 1);
|
|
12
31
|
};
|
|
13
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Returns the path of the nearest existing entry with the name, from the
|
|
35
|
+
* given directory up to three parents, or `null`.
|
|
36
|
+
*
|
|
37
|
+
* @evidence contracts/common.md#principled-implementation The recursion is bounded by the depth counter.
|
|
38
|
+
* @evidence contracts/common.md#clear-and-simple-design One function.
|
|
39
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The bound is explicit.
|
|
40
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the result.
|
|
41
|
+
* @evidence contracts/portability.md#os-neutral-implementation The result is the native path of the entry as joined, found by the filesystem's own existence test and not canonicalized.
|
|
42
|
+
*/
|
|
14
43
|
export const file =
|
|
15
44
|
(name: string) =>
|
|
16
45
|
(directory: string, depth: number = 0): string | null => {
|
|
@@ -1,4 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Classifies the content type of a response.
|
|
3
|
+
*
|
|
4
|
+
* @evidence contracts/common.md#principled-implementation The namespace decides which content types the SDK supports and which are binary.
|
|
5
|
+
* @evidence contracts/common.md#clear-and-simple-design One type and two predicates.
|
|
6
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The list is media types, not routes.
|
|
7
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
8
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation HttpResponseContentTypeUtil classifies HTTP response metadata and MIME types, which have protocol semantics independent of the native filesystem.
|
|
9
|
+
*/
|
|
1
10
|
export namespace HttpResponseContentTypeUtil {
|
|
11
|
+
/**
|
|
12
|
+
* A response content type: JSON, text, urlencoded, another string, or `null`
|
|
13
|
+
* for no body.
|
|
14
|
+
*
|
|
15
|
+
* @evidence contracts/common.md#principled-implementation The union keeps the common types visible while allowing any other string.
|
|
16
|
+
* @evidence contracts/common.md#clear-and-simple-design One union.
|
|
17
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
|
|
18
|
+
* @evidence contracts/common.md#meaningful-documentation The comment names the cases.
|
|
19
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation HttpResponseContentTypeUtil.Response classifies HTTP response metadata and MIME types, which have protocol semantics independent of the native filesystem.
|
|
20
|
+
*/
|
|
2
21
|
export type Response =
|
|
3
22
|
| "application/json"
|
|
4
23
|
| "text/plain"
|
|
@@ -6,6 +25,16 @@ export namespace HttpResponseContentTypeUtil {
|
|
|
6
25
|
| (string & {})
|
|
7
26
|
| null;
|
|
8
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Reports whether the SDK supports the content type: none, JSON, plain text,
|
|
30
|
+
* urlencoded, or a binary type.
|
|
31
|
+
*
|
|
32
|
+
* @evidence contracts/common.md#principled-implementation The content type is compared exactly for the three text types and by the binary rule otherwise.
|
|
33
|
+
* @evidence contracts/common.md#clear-and-simple-design One expression.
|
|
34
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The list is the supported set.
|
|
35
|
+
* @evidence contracts/common.md#meaningful-documentation The comment lists the supported types.
|
|
36
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation HttpResponseContentTypeUtil.isSupported classifies HTTP response metadata and MIME types, which have protocol semantics independent of the native filesystem.
|
|
37
|
+
*/
|
|
9
38
|
export const isSupported = (input: string | null): input is Response =>
|
|
10
39
|
input === null ||
|
|
11
40
|
input === "application/json" ||
|
|
@@ -13,6 +42,18 @@ export namespace HttpResponseContentTypeUtil {
|
|
|
13
42
|
input === "application/x-www-form-urlencoded" ||
|
|
14
43
|
isBinary(input);
|
|
15
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Reports whether the content type is binary: an image, video, or audio type,
|
|
47
|
+
* an octet stream, or a PDF.
|
|
48
|
+
*
|
|
49
|
+
* Parameters and case are ignored.
|
|
50
|
+
*
|
|
51
|
+
* @evidence contracts/common.md#principled-implementation The type is the text before the first `;`, trimmed and lower-cased, as HTTP defines a media type.
|
|
52
|
+
* @evidence contracts/common.md#clear-and-simple-design One predicate.
|
|
53
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The rule is a list of media types.
|
|
54
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the binary types and the normalization.
|
|
55
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation HttpResponseContentTypeUtil.isBinary classifies HTTP response metadata and MIME types, which have protocol semantics independent of the native filesystem.
|
|
56
|
+
*/
|
|
16
57
|
export const isBinary = (
|
|
17
58
|
input: string | null | undefined,
|
|
18
59
|
): input is string => {
|
package/src/utils/MapUtil.ts
CHANGED
|
@@ -1,14 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for maps.
|
|
3
|
+
*
|
|
4
|
+
* @evidence contracts/common.md#principled-implementation The namespace holds the get-or-create helper.
|
|
5
|
+
* @evidence contracts/common.md#clear-and-simple-design One function.
|
|
6
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is a plain helper.
|
|
7
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
8
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation MapUtil reads or initializes caller-supplied map entries; it neither interprets keys as native path identities nor owns a process boundary.
|
|
9
|
+
*/
|
|
1
10
|
export namespace MapUtil {
|
|
11
|
+
/**
|
|
12
|
+
* Returns the value of a key, creating and storing it when the key is absent.
|
|
13
|
+
*
|
|
14
|
+
* Presence is tested with `has`, so a stored falsy value is not created
|
|
15
|
+
* again. The dictionary may be a `Map` or a `WeakMap`, so a cache keyed by
|
|
16
|
+
* object identity can leave its entries to the garbage collector.
|
|
17
|
+
*
|
|
18
|
+
* @evidence contracts/common.md#principled-implementation The generator runs once per key and its result is stored as it is, in any dictionary with the three members it uses, so the retention of the entries stays the choice of the caller's dictionary.
|
|
19
|
+
* @evidence contracts/common.md#clear-and-simple-design One check, one call, and one store.
|
|
20
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The stored value is returned unchanged.
|
|
21
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the presence rule.
|
|
22
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation MapUtil.take reads or initializes caller-supplied map entries; it neither interprets keys as native path identities nor owns a process boundary.
|
|
23
|
+
*/
|
|
2
24
|
export function take<Key, T>(
|
|
3
|
-
dict:
|
|
25
|
+
dict: IDictionary<Key, T>,
|
|
4
26
|
key: Key,
|
|
5
27
|
generator: () => T,
|
|
6
28
|
): T {
|
|
7
|
-
|
|
8
|
-
if (oldbie) return oldbie;
|
|
29
|
+
if (dict.has(key)) return dict.get(key) as T;
|
|
9
30
|
|
|
10
31
|
const value: T = generator();
|
|
11
32
|
dict.set(key, value);
|
|
12
33
|
return value;
|
|
13
34
|
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The members of a `Map` or a `WeakMap` that {@link take} reads and writes.
|
|
38
|
+
*
|
|
39
|
+
* @evidence contracts/common.md#principled-implementation The three members are the presence test, the read and the store that the get-or-create rule needs, and both `Map` and `WeakMap` provide them with these signatures.
|
|
40
|
+
* @evidence contracts/common.md#clear-and-simple-design A structural type of three members, so no wrapper or second helper is needed for a weakly keyed cache.
|
|
41
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
|
|
42
|
+
* @evidence contracts/common.md#meaningful-documentation The comment names the two dictionaries it admits and the operations it needs.
|
|
43
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation MapUtil.IDictionary reads or initializes caller-supplied map entries; it neither interprets keys as native path identities nor owns a process boundary.
|
|
44
|
+
*/
|
|
45
|
+
export interface IDictionary<Key, T> {
|
|
46
|
+
/**
|
|
47
|
+
* Whether the key is present, including a key whose value is `undefined`.
|
|
48
|
+
*
|
|
49
|
+
* @evidence contracts/common.md#principled-implementation Presence is a separate question from the stored value, which is what lets a stored falsy value count as present.
|
|
50
|
+
* @evidence contracts/common.md#clear-and-simple-design One member with the signature that `Map` and `WeakMap` share.
|
|
51
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is a signature and adds no runtime behavior.
|
|
52
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the member answers or does for {@link take}.
|
|
53
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation MapUtil.IDictionary.has reads or initializes caller-supplied map entries; it neither interprets keys as native path identities nor owns a process boundary.
|
|
54
|
+
*/
|
|
55
|
+
has(key: Key): boolean;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The value stored for the key, or `undefined` when it is absent.
|
|
59
|
+
*
|
|
60
|
+
* @evidence contracts/common.md#principled-implementation The read is only made after a presence test, so `undefined` here always means a stored value.
|
|
61
|
+
* @evidence contracts/common.md#clear-and-simple-design One member with the signature that `Map` and `WeakMap` share.
|
|
62
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is a signature and adds no runtime behavior.
|
|
63
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the member answers or does for {@link take}.
|
|
64
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation MapUtil.IDictionary.get reads or initializes caller-supplied map entries; it neither interprets keys as native path identities nor owns a process boundary.
|
|
65
|
+
*/
|
|
66
|
+
get(key: Key): T | undefined;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Stores the value for the key; the result is ignored.
|
|
70
|
+
*
|
|
71
|
+
* @evidence contracts/common.md#principled-implementation The store is the one effect of the get-or-create rule, and the return type is not read because `Map.set` and `WeakMap.set` return different receivers.
|
|
72
|
+
* @evidence contracts/common.md#clear-and-simple-design One member with the signature that `Map` and `WeakMap` share.
|
|
73
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is a signature and adds no runtime behavior.
|
|
74
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the member answers or does for {@link take}.
|
|
75
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation MapUtil.IDictionary.set reads or initializes caller-supplied map entries; it neither interprets keys as native path identities nor owns a process boundary.
|
|
76
|
+
*/
|
|
77
|
+
set(key: Key, value: T): unknown;
|
|
78
|
+
}
|
|
14
79
|
}
|
package/src/utils/PathUtil.ts
CHANGED
|
@@ -1,10 +1,48 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { fileURLToPath } from "url";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Helpers for route paths used as accessors, and for source file locations.
|
|
6
|
+
*
|
|
7
|
+
* @evidence contracts/common.md#principled-implementation The namespace turns a path into accessor names and a source location into a plain path.
|
|
8
|
+
* @evidence contracts/common.md#clear-and-simple-design Two functions.
|
|
9
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts They are plain helpers.
|
|
10
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
11
|
+
* @evidence contracts/portability.md#os-neutral-implementation Route accessor spelling uses protocol slashes, while source file URLs are decoded with Node fileURLToPath before native separators are rendered as forward slashes. These operations do not infer filesystem identity or case policy from spelling.
|
|
12
|
+
*/
|
|
1
13
|
export namespace PathUtil {
|
|
14
|
+
/**
|
|
15
|
+
* Returns the accessor segments of a path: the segments that are not empty
|
|
16
|
+
* and not parameters, with dashes and dots replaced by underscores.
|
|
17
|
+
*
|
|
18
|
+
* @evidence contracts/common.md#principled-implementation Parameters do not name a namespace and the replaced characters are not valid in an identifier.
|
|
19
|
+
* @evidence contracts/common.md#clear-and-simple-design One pipeline.
|
|
20
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The rule applies to every path.
|
|
21
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the result.
|
|
22
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation This function processes route URL segments rather than native filesystem paths or identities.
|
|
23
|
+
*/
|
|
2
24
|
export const accessors = (path: string) =>
|
|
3
25
|
path
|
|
4
26
|
.split("/")
|
|
5
27
|
.filter((str) => str.length && str[0] !== ":")
|
|
6
28
|
.map(normalize);
|
|
7
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Returns the plain path of a source location: a `file:` URL is decoded to
|
|
32
|
+
* the path it names, with forward slashes, and any other text is returned as
|
|
33
|
+
* it is.
|
|
34
|
+
*
|
|
35
|
+
* @evidence contracts/common.md#principled-implementation A file URL is percent-encoded, so a path with a space or a non-ASCII character reads back only through the URL decoder, and the platform separator is replaced so the result is the same on every platform.
|
|
36
|
+
* @evidence contracts/common.md#clear-and-simple-design One conditional over the standard decoder.
|
|
37
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Only a `file:` location is decoded; a plain path is never altered.
|
|
38
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states both inputs and the separator.
|
|
39
|
+
* @evidence contracts/portability.md#os-neutral-implementation Node fileURLToPath handles platform-specific drive and UNC URL forms and percent decoding. The resulting native separators are rendered as forward slashes for source-location metadata; plain paths keep their original spelling and no filesystem identity comparison is attempted.
|
|
40
|
+
*/
|
|
41
|
+
export const location = (str: string): string =>
|
|
42
|
+
str.startsWith("file:")
|
|
43
|
+
? fileURLToPath(str).split(path.sep).join("/")
|
|
44
|
+
: str;
|
|
45
|
+
|
|
8
46
|
const normalize = (str: string) =>
|
|
9
47
|
str.split("-").join("_").split(".").join("_");
|
|
10
48
|
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
import { SDK_BUNDLE_PATH } from "./SdkBundlePath";
|
|
5
|
+
import { SourceFinder } from "./SourceFinder";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Separates authored TypeScript inputs from files owned by SDK generation.
|
|
9
|
+
*
|
|
10
|
+
* Each filter owns one output directory. Installed bundle metadata is shared;
|
|
11
|
+
* output-specific native paths are never stored in the process-wide cache.
|
|
12
|
+
*
|
|
13
|
+
* @evidence contracts/common.md#principled-implementation Source extensions are checked before generated functional descendants and exact bundled output files are excluded. Native identities and path.relative distinguish descendants from prefix-sharing siblings.
|
|
14
|
+
* @evidence contracts/common.md#clear-and-simple-design One filter factory separates source selection from controller compilation; its private helpers own bundle metadata and filesystem identity.
|
|
15
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Exclusions come from the actual installed bundle and the generated functional directory, without fixture names or a cached caller output.
|
|
16
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states filter ownership and the cache's output-independent content.
|
|
17
|
+
* @evidence contracts/portability.md#os-neutral-implementation Native real paths resolve existing ancestors and path.relative judges directory containment; neither OS names nor lowercasing assume a volume's case or link policy.
|
|
18
|
+
* efficient algorithms: Successful installed bundle entries are scanned once and each filter builds its exclusion roots once; a candidate resolves one identity and compares at most the bundle entry count plus functional root, with no recursive source scan here.
|
|
19
|
+
* reuse equivalent work: Concurrent filters share installed bundle names and kinds; a failed metadata read clears the promise so a later request can retry. Output-specific resolved roots belong to each factory call, so another output cannot reuse the first caller's paths.
|
|
20
|
+
* bound retention and release resources: The one metadata promise retains only the fixed installed bundle population. Output roots live in the returned filter closure and are released with its source-discovery call; there is no growing per-output registry.
|
|
21
|
+
*/
|
|
22
|
+
export namespace SdkInputFilter {
|
|
23
|
+
/**
|
|
24
|
+
* Creates the source predicate for one configuration's output, or an
|
|
25
|
+
* extension-only predicate when no SDK output is configured.
|
|
26
|
+
*
|
|
27
|
+
* @evidence contracts/common.md#principled-implementation The predicate accepts regular TypeScript source names, excludes descendants of this output's functional directory and the bundle's exact file/directory identities, and leaves same-named authored files outside that output eligible.
|
|
28
|
+
* @evidence contracts/common.md#clear-and-simple-design Output roots are prepared before discovery and captured in one returned predicate, so compilation never owns these path-selection rules.
|
|
29
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Every configuration resolves its own output; no first-call output, substring containment or operating-system case guess substitutes for filesystem identity.
|
|
30
|
+
* @evidence contracts/common.md#meaningful-documentation The comment documents both output-bound and extension-only modes.
|
|
31
|
+
* @evidence contracts/portability.md#os-neutral-implementation The nearest existing ancestor carries actual case/link identity and nonexistent suffixes retain their native spelling; path.relative rejects sibling and cross-root locations without protocol-path comparisons.
|
|
32
|
+
* efficient algorithms: Factory preparation is linear in installed bundle entries and each predicate call scans those prepared roots after one candidate identity resolution. It reuses the discovery traversal rather than walking inputs again.
|
|
33
|
+
* reuse equivalent work: Output-independent metadata comes from one shared in-flight or successful promise; rejection clears it for retry, while each output-specific root array is computed for its own factory call and is not shared across incompatible configurations.
|
|
34
|
+
* bound retention and release resources: The predicate retains only this configuration's fixed exclusion roots and no candidate history; once SourceFinder finishes, that closure has no persistent owner.
|
|
35
|
+
*/
|
|
36
|
+
export const create = async (
|
|
37
|
+
output: string | undefined,
|
|
38
|
+
): Promise<(location: string) => Promise<boolean>> => {
|
|
39
|
+
if (output === undefined)
|
|
40
|
+
return async (location) => SourceFinder.isTypeScriptSource(location);
|
|
41
|
+
const excluded = [
|
|
42
|
+
{
|
|
43
|
+
location: identity(path.resolve(output, "functional")),
|
|
44
|
+
directory: true,
|
|
45
|
+
},
|
|
46
|
+
...(await bundle()).map((asset) => ({
|
|
47
|
+
location: identity(path.resolve(output, asset.name)),
|
|
48
|
+
directory: asset.directory,
|
|
49
|
+
})),
|
|
50
|
+
];
|
|
51
|
+
return async (location) => {
|
|
52
|
+
if (SourceFinder.isTypeScriptSource(location) === false) return false;
|
|
53
|
+
const file = identity(location);
|
|
54
|
+
return excluded.every((entry) =>
|
|
55
|
+
entry.directory
|
|
56
|
+
? within(entry.location, file) === false
|
|
57
|
+
: entry.location !== file,
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
let bundlePromise: Promise<{ name: string; directory: boolean }[]> | undefined;
|
|
64
|
+
const bundle = (): Promise<{ name: string; directory: boolean }[]> => {
|
|
65
|
+
if (bundlePromise === undefined)
|
|
66
|
+
bundlePromise = (async () =>
|
|
67
|
+
Promise.all(
|
|
68
|
+
(
|
|
69
|
+
await fs.promises.readdir(SDK_BUNDLE_PATH, { withFileTypes: true })
|
|
70
|
+
).map(async (entry) => ({
|
|
71
|
+
name: entry.name,
|
|
72
|
+
directory: entry.isSymbolicLink()
|
|
73
|
+
? (
|
|
74
|
+
await fs.promises.stat(path.join(SDK_BUNDLE_PATH, entry.name))
|
|
75
|
+
).isDirectory()
|
|
76
|
+
: entry.isDirectory(),
|
|
77
|
+
})),
|
|
78
|
+
))().catch((error) => {
|
|
79
|
+
bundlePromise = undefined;
|
|
80
|
+
throw error;
|
|
81
|
+
});
|
|
82
|
+
return bundlePromise;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const within = (directory: string, location: string): boolean => {
|
|
86
|
+
const relative = path.relative(directory, location);
|
|
87
|
+
return (
|
|
88
|
+
relative === "" ||
|
|
89
|
+
(path.isAbsolute(relative) === false &&
|
|
90
|
+
relative !== ".." &&
|
|
91
|
+
relative.startsWith(`..${path.sep}`) === false)
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const identity = (location: string): string => {
|
|
96
|
+
const rest: string[] = [];
|
|
97
|
+
for (let current = path.resolve(location); ; ) {
|
|
98
|
+
try {
|
|
99
|
+
return path.join(fs.realpathSync.native(current), ...rest.reverse());
|
|
100
|
+
} catch (error) {
|
|
101
|
+
if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error;
|
|
102
|
+
const parent = path.dirname(current);
|
|
103
|
+
if (parent === current) throw error;
|
|
104
|
+
rest.push(path.basename(current));
|
|
105
|
+
current = parent;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
};
|