@nestia/sdk 14.0.1 → 14.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/bundle/distribute/build-sdk.cjs +28 -0
- package/assets/bundle/distribute/package.json +6 -2
- package/lib/INestiaConfig.d.ts +55 -24
- package/lib/NestiaSdkApplication.d.ts +60 -0
- package/lib/NestiaSdkApplication.js +63 -5
- package/lib/NestiaSdkApplication.js.map +1 -1
- package/lib/NestiaSwaggerComposer.d.ts +21 -0
- package/lib/NestiaSwaggerComposer.js +21 -3
- package/lib/NestiaSwaggerComposer.js.map +1 -1
- package/lib/analyses/AccessorAnalyzer.d.ts +26 -0
- package/lib/analyses/AccessorAnalyzer.js +26 -0
- package/lib/analyses/AccessorAnalyzer.js.map +1 -1
- package/lib/analyses/ConfigAnalyzer.d.ts +41 -0
- package/lib/analyses/ConfigAnalyzer.js +48 -73
- package/lib/analyses/ConfigAnalyzer.js.map +1 -1
- package/lib/analyses/ImportAnalyzer.d.ts +25 -0
- package/lib/analyses/ImportAnalyzer.js +25 -0
- package/lib/analyses/ImportAnalyzer.js.map +1 -1
- package/lib/analyses/ParameterNameAnalyzer.d.ts +24 -0
- package/lib/analyses/ParameterNameAnalyzer.js +15 -0
- package/lib/analyses/ParameterNameAnalyzer.js.map +1 -1
- package/lib/analyses/PathAnalyzer.d.ts +63 -1
- package/lib/analyses/PathAnalyzer.js +54 -9
- package/lib/analyses/PathAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectControllerAnalyzer.d.ts +32 -0
- package/lib/analyses/ReflectControllerAnalyzer.js +22 -0
- package/lib/analyses/ReflectControllerAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationAnalyzer.d.ts +29 -0
- package/lib/analyses/ReflectHttpOperationAnalyzer.js +28 -17
- package/lib/analyses/ReflectHttpOperationAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationExceptionAnalyzer.d.ts +31 -0
- package/lib/analyses/ReflectHttpOperationExceptionAnalyzer.js +21 -0
- package/lib/analyses/ReflectHttpOperationExceptionAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationParameterAnalyzer.d.ts +31 -0
- package/lib/analyses/ReflectHttpOperationParameterAnalyzer.js +21 -0
- package/lib/analyses/ReflectHttpOperationParameterAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.d.ts +32 -0
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.js +22 -0
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectMcpOperationAnalyzer.d.ts +29 -0
- package/lib/analyses/ReflectMcpOperationAnalyzer.js +30 -9
- package/lib/analyses/ReflectMcpOperationAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectMetadataAnalyzer.d.ts +47 -0
- package/lib/analyses/ReflectMetadataAnalyzer.js +47 -0
- package/lib/analyses/ReflectMetadataAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectWebSocketOperationAnalyzer.d.ts +29 -0
- package/lib/analyses/ReflectWebSocketOperationAnalyzer.js +21 -2
- package/lib/analyses/ReflectWebSocketOperationAnalyzer.js.map +1 -1
- package/lib/analyses/SecurityAnalyzer.d.ts +15 -0
- package/lib/analyses/SecurityAnalyzer.js +15 -0
- package/lib/analyses/SecurityAnalyzer.js.map +1 -1
- package/lib/analyses/SwaggerExampleAnalyzer.d.ts +16 -0
- package/lib/analyses/SwaggerExampleAnalyzer.js +16 -0
- package/lib/analyses/SwaggerExampleAnalyzer.js.map +1 -1
- package/lib/analyses/TypedHttpRouteAnalyzer.d.ts +41 -3
- package/lib/analyses/TypedHttpRouteAnalyzer.js +172 -157
- package/lib/analyses/TypedHttpRouteAnalyzer.js.map +1 -1
- package/lib/analyses/TypedMcpRouteAnalyzer.d.ts +29 -0
- package/lib/analyses/TypedMcpRouteAnalyzer.js +152 -20
- package/lib/analyses/TypedMcpRouteAnalyzer.js.map +1 -1
- package/lib/analyses/TypedWebSocketRouteAnalyzer.d.ts +19 -0
- package/lib/analyses/TypedWebSocketRouteAnalyzer.js +19 -0
- package/lib/analyses/TypedWebSocketRouteAnalyzer.js.map +1 -1
- package/lib/decorators/OperationMetadata.d.ts +6 -0
- package/lib/decorators/OperationMetadata.js +6 -0
- package/lib/decorators/OperationMetadata.js.map +1 -1
- package/lib/executable/internal/CommandParser.d.ts +19 -0
- package/lib/executable/internal/CommandParser.js +19 -0
- package/lib/executable/internal/CommandParser.js.map +1 -1
- package/lib/executable/internal/NestiaConfigLoader.d.ts +56 -0
- package/lib/executable/internal/NestiaConfigLoader.js +48 -42
- package/lib/executable/internal/NestiaConfigLoader.js.map +1 -1
- package/lib/executable/internal/NestiaSdkCommand.d.ts +60 -0
- package/lib/executable/internal/NestiaSdkCommand.js +95 -3
- package/lib/executable/internal/NestiaSdkCommand.js.map +1 -1
- package/lib/executable/internal/NestiaSdkWatcher.d.ts +81 -0
- package/lib/executable/internal/NestiaSdkWatcher.js +122 -38
- package/lib/executable/internal/NestiaSdkWatcher.js.map +1 -1
- package/lib/executable/internal/NestiaSwaggerWatch.d.ts +80 -0
- package/lib/executable/internal/NestiaSwaggerWatch.js +308 -0
- package/lib/executable/internal/NestiaSwaggerWatch.js.map +1 -0
- package/lib/factories/ExpressionFactory.d.ts +17 -2
- package/lib/factories/ExpressionFactory.js +17 -2
- package/lib/factories/ExpressionFactory.js.map +1 -1
- package/lib/factories/IdentifierFactory.d.ts +24 -0
- package/lib/factories/IdentifierFactory.js +24 -0
- package/lib/factories/IdentifierFactory.js.map +1 -1
- package/lib/factories/LiteralFactory.d.ts +22 -4
- package/lib/factories/LiteralFactory.js +30 -10
- package/lib/factories/LiteralFactory.js.map +1 -1
- package/lib/factories/StatementFactory.d.ts +28 -1
- package/lib/factories/StatementFactory.js +28 -1
- package/lib/factories/StatementFactory.js.map +1 -1
- package/lib/factories/TypeFactory.d.ts +24 -0
- package/lib/factories/TypeFactory.js +15 -0
- package/lib/factories/TypeFactory.js.map +1 -1
- package/lib/generates/CloneGenerator.d.ts +22 -0
- package/lib/generates/CloneGenerator.js +26 -5
- package/lib/generates/CloneGenerator.js.map +1 -1
- package/lib/generates/E2eGenerator.d.ts +19 -0
- package/lib/generates/E2eGenerator.js +19 -0
- package/lib/generates/E2eGenerator.js.map +1 -1
- package/lib/generates/SdkGenerator.d.ts +38 -0
- package/lib/generates/SdkGenerator.js +40 -2
- package/lib/generates/SdkGenerator.js.map +1 -1
- package/lib/generates/SwaggerGenerator.d.ts +36 -6
- package/lib/generates/SwaggerGenerator.js +55 -13
- package/lib/generates/SwaggerGenerator.js.map +1 -1
- package/lib/generates/internal/E2eFileProgrammer.d.ts +19 -0
- package/lib/generates/internal/E2eFileProgrammer.js +20 -1
- package/lib/generates/internal/E2eFileProgrammer.js.map +1 -1
- package/lib/generates/internal/FilePrinter.d.ts +43 -0
- package/lib/generates/internal/FilePrinter.js +43 -0
- package/lib/generates/internal/FilePrinter.js.map +1 -1
- package/lib/generates/internal/ImportDictionary.d.ts +92 -2
- package/lib/generates/internal/ImportDictionary.js +91 -3
- package/lib/generates/internal/ImportDictionary.js.map +1 -1
- package/lib/generates/internal/SdkAliasCollection.d.ts +119 -0
- package/lib/generates/internal/SdkAliasCollection.js +124 -7
- package/lib/generates/internal/SdkAliasCollection.js.map +1 -1
- package/lib/generates/internal/SdkDistributionComposer.d.ts +19 -0
- package/lib/generates/internal/SdkDistributionComposer.js +98 -59
- package/lib/generates/internal/SdkDistributionComposer.js.map +1 -1
- package/lib/generates/internal/SdkFileProgrammer.d.ts +18 -0
- package/lib/generates/internal/SdkFileProgrammer.js +18 -0
- package/lib/generates/internal/SdkFileProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpCloneProgrammer.d.ts +29 -0
- package/lib/generates/internal/SdkHttpCloneProgrammer.js +33 -0
- package/lib/generates/internal/SdkHttpCloneProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpCloneReferencer.d.ts +19 -0
- package/lib/generates/internal/SdkHttpCloneReferencer.js +78 -25
- package/lib/generates/internal/SdkHttpCloneReferencer.js.map +1 -1
- package/lib/generates/internal/SdkHttpFunctionProgrammer.d.ts +19 -0
- package/lib/generates/internal/SdkHttpFunctionProgrammer.js +19 -0
- package/lib/generates/internal/SdkHttpFunctionProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.d.ts +19 -0
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.js +19 -0
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpParameterProgrammer.d.ts +104 -2
- package/lib/generates/internal/SdkHttpParameterProgrammer.js +70 -0
- package/lib/generates/internal/SdkHttpParameterProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpRouteProgrammer.d.ts +20 -0
- package/lib/generates/internal/SdkHttpRouteProgrammer.js +20 -0
- package/lib/generates/internal/SdkHttpRouteProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpSimulationProgrammer.d.ts +38 -0
- package/lib/generates/internal/SdkHttpSimulationProgrammer.js +49 -5
- package/lib/generates/internal/SdkHttpSimulationProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkImportWizard.d.ts +63 -0
- package/lib/generates/internal/SdkImportWizard.js +63 -0
- package/lib/generates/internal/SdkImportWizard.js.map +1 -1
- package/lib/generates/internal/SdkMcpRouteProgrammer.d.ts +17 -2
- package/lib/generates/internal/SdkMcpRouteProgrammer.js +33 -13
- package/lib/generates/internal/SdkMcpRouteProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkPathTemplate.d.ts +15 -0
- package/lib/generates/internal/SdkPathTemplate.js +15 -0
- package/lib/generates/internal/SdkPathTemplate.js.map +1 -1
- package/lib/generates/internal/SdkRouteDirectory.d.ts +10 -0
- package/lib/generates/internal/SdkRouteDirectory.js +10 -0
- package/lib/generates/internal/SdkRouteDirectory.js.map +1 -1
- package/lib/generates/internal/SdkTypeProgrammer.d.ts +54 -1
- package/lib/generates/internal/SdkTypeProgrammer.js +96 -12
- package/lib/generates/internal/SdkTypeProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkTypeTagProgrammer.d.ts +36 -3
- package/lib/generates/internal/SdkTypeTagProgrammer.js +28 -7
- package/lib/generates/internal/SdkTypeTagProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketCloneProgrammer.d.ts +40 -0
- package/lib/generates/internal/SdkWebSocketCloneProgrammer.js +149 -142
- package/lib/generates/internal/SdkWebSocketCloneProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.d.ts +19 -0
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js +19 -0
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketParameterProgrammer.d.ts +81 -2
- package/lib/generates/internal/SdkWebSocketParameterProgrammer.js +48 -0
- package/lib/generates/internal/SdkWebSocketParameterProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.d.ts +18 -0
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.js +18 -0
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.js.map +1 -1
- package/lib/generates/internal/SwaggerDescriptionComposer.d.ts +42 -0
- package/lib/generates/internal/SwaggerDescriptionComposer.js +44 -1
- package/lib/generates/internal/SwaggerDescriptionComposer.js.map +1 -1
- package/lib/generates/internal/SwaggerOperationComposer.d.ts +18 -0
- package/lib/generates/internal/SwaggerOperationComposer.js +18 -0
- package/lib/generates/internal/SwaggerOperationComposer.js.map +1 -1
- package/lib/generates/internal/SwaggerOperationParameterComposer.d.ts +39 -0
- package/lib/generates/internal/SwaggerOperationParameterComposer.js +31 -8
- package/lib/generates/internal/SwaggerOperationParameterComposer.js.map +1 -1
- package/lib/generates/internal/SwaggerOperationResponseComposer.d.ts +19 -0
- package/lib/generates/internal/SwaggerOperationResponseComposer.js +19 -0
- package/lib/generates/internal/SwaggerOperationResponseComposer.js.map +1 -1
- package/lib/internal/legacy.d.ts +296 -16
- package/lib/internal/legacy.js +127 -10
- package/lib/internal/legacy.js.map +1 -1
- package/lib/structures/INestiaProject.d.ts +10 -0
- package/lib/structures/INestiaSdkInput.d.ts +30 -0
- package/lib/structures/IOperationMetadata.d.ts +55 -0
- package/lib/structures/IReflectController.d.ts +10 -0
- package/lib/structures/IReflectHttpOperation.d.ts +10 -0
- package/lib/structures/IReflectHttpOperationException.d.ts +10 -0
- package/lib/structures/IReflectHttpOperationParameter.d.ts +47 -0
- package/lib/structures/IReflectHttpOperationSuccess.d.ts +11 -0
- package/lib/structures/IReflectImport.d.ts +10 -0
- package/lib/structures/IReflectMcpOperation.d.ts +19 -0
- package/lib/structures/IReflectMcpOperationParameter.d.ts +9 -0
- package/lib/structures/IReflectOperationError.d.ts +28 -0
- package/lib/structures/IReflectOperationError.js +22 -2
- package/lib/structures/IReflectOperationError.js.map +1 -1
- package/lib/structures/IReflectType.d.ts +9 -0
- package/lib/structures/IReflectWebSocketOperation.d.ts +10 -0
- package/lib/structures/IReflectWebSocketOperationParameter.d.ts +55 -0
- package/lib/structures/ITypedApplication.d.ts +10 -0
- package/lib/structures/ITypedHttpRoute.d.ts +10 -0
- package/lib/structures/ITypedHttpRouteException.d.ts +10 -0
- package/lib/structures/ITypedHttpRouteParameter.d.ts +45 -0
- package/lib/structures/ITypedHttpRouteSuccess.d.ts +10 -0
- package/lib/structures/ITypedMcpRoute.d.ts +11 -0
- package/lib/structures/ITypedWebSocketRoute.d.ts +10 -0
- package/lib/transform.d.ts +6 -0
- package/lib/transform.js +6 -0
- package/lib/transform.js.map +1 -1
- package/lib/utils/ArrayUtil.d.ts +31 -1
- package/lib/utils/ArrayUtil.js +32 -11
- package/lib/utils/ArrayUtil.js.map +1 -1
- package/lib/utils/EmittedJavaScriptPatcher.d.ts +20 -0
- package/lib/utils/EmittedJavaScriptPatcher.js +65 -46
- package/lib/utils/EmittedJavaScriptPatcher.js.map +1 -1
- package/lib/utils/FileRetriever.d.ts +29 -0
- package/lib/utils/FileRetriever.js +29 -0
- package/lib/utils/FileRetriever.js.map +1 -1
- package/lib/utils/HttpResponseContentTypeUtil.d.ts +41 -0
- package/lib/utils/HttpResponseContentTypeUtil.js +31 -0
- package/lib/utils/HttpResponseContentTypeUtil.js.map +1 -1
- package/lib/utils/MapUtil.d.ts +64 -1
- package/lib/utils/MapUtil.js +24 -3
- package/lib/utils/MapUtil.js.map +1 -1
- package/lib/utils/PathUtil.d.ts +31 -0
- package/lib/utils/PathUtil.js +38 -0
- package/lib/utils/PathUtil.js.map +1 -1
- package/lib/utils/SdkBundlePath.d.ts +2 -0
- package/lib/utils/SdkBundlePath.js +10 -0
- package/lib/utils/SdkBundlePath.js.map +1 -0
- package/lib/utils/SdkInputFilter.d.ts +31 -0
- package/lib/utils/SdkInputFilter.js +115 -0
- package/lib/utils/SdkInputFilter.js.map +1 -0
- package/lib/utils/SourceFinder.d.ts +35 -0
- package/lib/utils/SourceFinder.js +47 -12
- package/lib/utils/SourceFinder.js.map +1 -1
- package/lib/utils/StringUtil.d.ts +77 -2
- package/lib/utils/StringUtil.js +166 -4
- package/lib/utils/StringUtil.js.map +1 -1
- package/lib/utils/TemporaryDirectory.d.ts +60 -0
- package/lib/utils/TemporaryDirectory.js +112 -0
- package/lib/utils/TemporaryDirectory.js.map +1 -0
- package/lib/utils/TsConfigReader.d.ts +42 -0
- package/lib/utils/TsConfigReader.js +98 -14
- package/lib/utils/TsConfigReader.js.map +1 -1
- package/lib/utils/TtscExecutor.d.ts +23 -1
- package/lib/utils/TtscExecutor.js +22 -0
- package/lib/utils/TtscExecutor.js.map +1 -1
- package/lib/utils/VersioningStrategy.d.ts +26 -1
- package/lib/utils/VersioningStrategy.js +30 -9
- package/lib/utils/VersioningStrategy.js.map +1 -1
- package/lib/validators/TextPlainValidator.d.ts +19 -0
- package/lib/validators/TextPlainValidator.js +19 -0
- package/lib/validators/TextPlainValidator.js.map +1 -1
- package/native/go.mod +1 -1
- package/native/go.sum +2 -2
- package/native/sdk/register.go +12 -2
- package/native/sdk/sdk_metadata_json.go +6 -1
- package/native/sdk/sdk_transform.go +388 -397
- package/package.json +7 -5
- package/src/INestiaConfig.ts +55 -24
- package/src/NestiaSdkApplication.ts +66 -7
- package/src/NestiaSwaggerComposer.ts +21 -6
- package/src/analyses/AccessorAnalyzer.ts +26 -0
- package/src/analyses/ConfigAnalyzer.ts +49 -87
- package/src/analyses/ImportAnalyzer.ts +25 -0
- package/src/analyses/ParameterNameAnalyzer.ts +24 -0
- package/src/analyses/PathAnalyzer.ts +63 -11
- package/src/analyses/ReflectControllerAnalyzer.ts +32 -0
- package/src/analyses/ReflectHttpOperationAnalyzer.ts +32 -10
- package/src/analyses/ReflectHttpOperationExceptionAnalyzer.ts +31 -0
- package/src/analyses/ReflectHttpOperationParameterAnalyzer.ts +31 -0
- package/src/analyses/ReflectHttpOperationResponseAnalyzer.ts +32 -0
- package/src/analyses/ReflectMcpOperationAnalyzer.ts +32 -1
- package/src/analyses/ReflectMetadataAnalyzer.ts +47 -0
- package/src/analyses/ReflectWebSocketOperationAnalyzer.ts +33 -4
- package/src/analyses/SecurityAnalyzer.ts +15 -0
- package/src/analyses/SwaggerExampleAnalyzer.ts +16 -0
- package/src/analyses/TypedHttpRouteAnalyzer.ts +240 -184
- package/src/analyses/TypedMcpRouteAnalyzer.ts +180 -20
- package/src/analyses/TypedWebSocketRouteAnalyzer.ts +19 -0
- package/src/decorators/OperationMetadata.ts +6 -0
- package/src/executable/internal/CommandParser.ts +19 -0
- package/src/executable/internal/NestiaConfigLoader.ts +66 -50
- package/src/executable/internal/NestiaSdkCommand.ts +96 -3
- package/src/executable/internal/NestiaSdkWatcher.ts +169 -41
- package/src/executable/internal/NestiaSwaggerWatch.ts +359 -0
- package/src/factories/ExpressionFactory.ts +17 -2
- package/src/factories/IdentifierFactory.ts +24 -0
- package/src/factories/LiteralFactory.ts +44 -11
- package/src/factories/StatementFactory.ts +28 -1
- package/src/factories/TypeFactory.ts +24 -0
- package/src/generates/CloneGenerator.ts +26 -5
- package/src/generates/E2eGenerator.ts +19 -0
- package/src/generates/SdkGenerator.ts +40 -9
- package/src/generates/SwaggerGenerator.ts +56 -14
- package/src/generates/internal/E2eFileProgrammer.ts +20 -0
- package/src/generates/internal/FilePrinter.ts +43 -0
- package/src/generates/internal/ImportDictionary.ts +110 -3
- package/src/generates/internal/SdkAliasCollection.ts +133 -11
- package/src/generates/internal/SdkDistributionComposer.ts +117 -66
- package/src/generates/internal/SdkFileProgrammer.ts +18 -0
- package/src/generates/internal/SdkHttpCloneProgrammer.ts +55 -0
- package/src/generates/internal/SdkHttpCloneReferencer.ts +97 -23
- package/src/generates/internal/SdkHttpFunctionProgrammer.ts +19 -0
- package/src/generates/internal/SdkHttpNamespaceProgrammer.ts +19 -0
- package/src/generates/internal/SdkHttpParameterProgrammer.ts +104 -2
- package/src/generates/internal/SdkHttpRouteProgrammer.ts +20 -0
- package/src/generates/internal/SdkHttpSimulationProgrammer.ts +72 -5
- package/src/generates/internal/SdkImportWizard.ts +63 -0
- package/src/generates/internal/SdkMcpRouteProgrammer.ts +38 -18
- package/src/generates/internal/SdkPathTemplate.ts +15 -0
- package/src/generates/internal/SdkRouteDirectory.ts +10 -0
- package/src/generates/internal/SdkTypeProgrammer.ts +118 -14
- package/src/generates/internal/SdkTypeTagProgrammer.ts +37 -7
- package/src/generates/internal/SdkWebSocketCloneProgrammer.ts +185 -142
- package/src/generates/internal/SdkWebSocketNamespaceProgrammer.ts +19 -0
- package/src/generates/internal/SdkWebSocketParameterProgrammer.ts +81 -2
- package/src/generates/internal/SdkWebSocketRouteProgrammer.ts +18 -0
- package/src/generates/internal/SwaggerDescriptionComposer.ts +47 -1
- package/src/generates/internal/SwaggerOperationComposer.ts +18 -0
- package/src/generates/internal/SwaggerOperationParameterComposer.ts +41 -8
- package/src/generates/internal/SwaggerOperationResponseComposer.ts +19 -0
- package/src/internal/legacy-augmentation.d.ts +16 -0
- package/src/internal/legacy.ts +296 -26
- package/src/structures/INestiaProject.ts +10 -0
- package/src/structures/INestiaSdkInput.ts +30 -0
- package/src/structures/IOperationMetadata.ts +55 -0
- package/src/structures/IReflectController.ts +10 -0
- package/src/structures/IReflectHttpOperation.ts +10 -0
- package/src/structures/IReflectHttpOperationException.ts +10 -0
- package/src/structures/IReflectHttpOperationParameter.ts +47 -0
- package/src/structures/IReflectHttpOperationSuccess.ts +11 -0
- package/src/structures/IReflectImport.ts +10 -0
- package/src/structures/IReflectMcpOperation.ts +19 -0
- package/src/structures/IReflectMcpOperationParameter.ts +9 -0
- package/src/structures/IReflectOperationError.ts +31 -2
- package/src/structures/IReflectType.ts +9 -0
- package/src/structures/IReflectWebSocketOperation.ts +10 -0
- package/src/structures/IReflectWebSocketOperationParameter.ts +55 -0
- package/src/structures/ITypedApplication.ts +10 -0
- package/src/structures/ITypedHttpRoute.ts +10 -0
- package/src/structures/ITypedHttpRouteException.ts +10 -0
- package/src/structures/ITypedHttpRouteParameter.ts +45 -0
- package/src/structures/ITypedHttpRouteSuccess.ts +10 -0
- package/src/structures/ITypedMcpRoute.ts +12 -0
- package/src/structures/ITypedWebSocketRoute.ts +10 -0
- package/src/transform.ts +6 -0
- package/src/utils/ArrayUtil.ts +32 -13
- package/src/utils/EmittedJavaScriptPatcher.ts +70 -47
- package/src/utils/FileRetriever.ts +29 -0
- package/src/utils/HttpResponseContentTypeUtil.ts +41 -0
- package/src/utils/MapUtil.ts +68 -3
- package/src/utils/PathUtil.ts +38 -0
- package/src/utils/SdkBundlePath.ts +11 -0
- package/src/utils/SdkInputFilter.ts +108 -0
- package/src/utils/SourceFinder.ts +51 -14
- package/src/utils/StringUtil.ts +182 -5
- package/src/utils/TemporaryDirectory.ts +108 -0
- package/src/utils/TsConfigReader.ts +124 -26
- package/src/utils/TtscExecutor.ts +23 -1
- package/src/utils/VersioningStrategy.ts +33 -13
- package/src/validators/TextPlainValidator.ts +19 -0
- package/lib/generates/internal/SwaggerReadonlyArrayEmender.d.ts +0 -9
- package/lib/generates/internal/SwaggerReadonlyArrayEmender.js +0 -178
- package/lib/generates/internal/SwaggerReadonlyArrayEmender.js.map +0 -1
- package/src/generates/internal/SwaggerReadonlyArrayEmender.ts +0 -264
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Patches JavaScript emitted into a temporary directory so that it loads as
|
|
3
|
+
* CommonJS.
|
|
4
|
+
*
|
|
5
|
+
* @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.
|
|
6
|
+
* @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.
|
|
7
|
+
* @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.
|
|
8
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
9
|
+
* @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.
|
|
10
|
+
*/
|
|
1
11
|
export declare namespace EmittedJavaScriptPatcher {
|
|
12
|
+
/**
|
|
13
|
+
* Replaces every `import.meta.url` in the `.js` and `.cjs` files under a
|
|
14
|
+
* directory with `require("url").pathToFileURL(__filename).href`.
|
|
15
|
+
*
|
|
16
|
+
* @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.
|
|
17
|
+
* @evidence contracts/common.md#clear-and-simple-design One function collects files and delegates expression detection to the JavaScript grammar parser.
|
|
18
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It patches only files that contain the token.
|
|
19
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the replacement and the scope.
|
|
20
|
+
* @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.
|
|
21
|
+
*/
|
|
2
22
|
const importMetaUrl: (root: string) => Promise<void>;
|
|
3
23
|
}
|
|
@@ -13,16 +13,36 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.EmittedJavaScriptPatcher = void 0;
|
|
16
|
+
const parser_1 = require("@babel/parser");
|
|
16
17
|
const fs_1 = __importDefault(require("fs"));
|
|
17
18
|
const path_1 = __importDefault(require("path"));
|
|
19
|
+
/**
|
|
20
|
+
* Patches JavaScript emitted into a temporary directory so that it loads as
|
|
21
|
+
* CommonJS.
|
|
22
|
+
*
|
|
23
|
+
* @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.
|
|
24
|
+
* @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.
|
|
25
|
+
* @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.
|
|
26
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
27
|
+
* @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.
|
|
28
|
+
*/
|
|
18
29
|
var EmittedJavaScriptPatcher;
|
|
19
30
|
(function (EmittedJavaScriptPatcher) {
|
|
31
|
+
/**
|
|
32
|
+
* Replaces every `import.meta.url` in the `.js` and `.cjs` files under a
|
|
33
|
+
* directory with `require("url").pathToFileURL(__filename).href`.
|
|
34
|
+
*
|
|
35
|
+
* @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.
|
|
36
|
+
* @evidence contracts/common.md#clear-and-simple-design One function collects files and delegates expression detection to the JavaScript grammar parser.
|
|
37
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It patches only files that contain the token.
|
|
38
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the replacement and the scope.
|
|
39
|
+
* @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.
|
|
40
|
+
*/
|
|
20
41
|
EmittedJavaScriptPatcher.importMetaUrl = (root) => __awaiter(this, void 0, void 0, function* () {
|
|
21
42
|
const files = yield collect(root);
|
|
22
43
|
yield Promise.all(files.map(patch));
|
|
23
44
|
});
|
|
24
45
|
})(EmittedJavaScriptPatcher || (exports.EmittedJavaScriptPatcher = EmittedJavaScriptPatcher = {}));
|
|
25
|
-
const TARGET = "import.meta.url";
|
|
26
46
|
// TypeScript can preserve this token even in CommonJS output. Node 24 then
|
|
27
47
|
// syntax-detects the temporary `.js` file as ESM before require() can load it.
|
|
28
48
|
const REPLACEMENT = 'require("url").pathToFileURL(__filename).href';
|
|
@@ -42,59 +62,58 @@ const collect = (location) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
42
62
|
});
|
|
43
63
|
const patch = (file) => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
64
|
const before = yield fs_1.default.promises.readFile(file, "utf8");
|
|
45
|
-
if (before.includes(
|
|
65
|
+
if (before.includes("import") === false)
|
|
46
66
|
return;
|
|
47
67
|
const after = replaceImportMetaUrl(before);
|
|
48
68
|
if (after !== before)
|
|
49
69
|
yield fs_1.default.promises.writeFile(file, after, "utf8");
|
|
50
70
|
});
|
|
71
|
+
// Parse module expressions without imposing module strictness: TypeScript may preserve
|
|
72
|
+
// import.meta in otherwise CommonJS output. Top-level return is valid inside
|
|
73
|
+
// Node's CommonJS wrapper. The parser, rather than token context guesses, owns
|
|
74
|
+
// the distinction between regular expressions, divisions and property names.
|
|
51
75
|
const replaceImportMetaUrl = (input) => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
76
|
+
var _a, _b;
|
|
77
|
+
const root = (0, parser_1.parse)(input, {
|
|
78
|
+
sourceType: "module",
|
|
79
|
+
strictMode: false,
|
|
80
|
+
attachComment: false,
|
|
81
|
+
allowImportExportEverywhere: true,
|
|
82
|
+
allowReturnOutsideFunction: true,
|
|
83
|
+
allowAwaitOutsideFunction: true,
|
|
84
|
+
});
|
|
85
|
+
const spans = [];
|
|
86
|
+
const pending = [root];
|
|
87
|
+
while (pending.length !== 0) {
|
|
88
|
+
const node = pending.pop();
|
|
89
|
+
if (node.type === "MemberExpression" &&
|
|
90
|
+
node.computed === false &&
|
|
91
|
+
((_a = node.property) === null || _a === void 0 ? void 0 : _a.type) === "Identifier" &&
|
|
92
|
+
node.property.name === "url" &&
|
|
93
|
+
((_b = node.object) === null || _b === void 0 ? void 0 : _b.type) === "MetaProperty" &&
|
|
94
|
+
node.object.meta.name === "import" &&
|
|
95
|
+
node.object.property.name === "meta")
|
|
96
|
+
spans.push({ start: node.start, end: node.end });
|
|
97
|
+
for (const value of Object.values(node)) {
|
|
98
|
+
if (Array.isArray(value)) {
|
|
99
|
+
for (const child of value)
|
|
100
|
+
if (child && typeof child.type === "string")
|
|
101
|
+
pending.push(child);
|
|
102
|
+
}
|
|
103
|
+
else if (value &&
|
|
104
|
+
typeof value === "object" &&
|
|
105
|
+
typeof value.type === "string")
|
|
106
|
+
pending.push(value);
|
|
61
107
|
}
|
|
62
|
-
const ch = input[i];
|
|
63
|
-
const next = input[i + 1];
|
|
64
|
-
if (ch === '"' || ch === "'")
|
|
65
|
-
i = skipQuoted(input, i, ch);
|
|
66
|
-
else if (ch === "/" && next === "/")
|
|
67
|
-
i = skipLineComment(input, i);
|
|
68
|
-
else if (ch === "/" && next === "*")
|
|
69
|
-
i = skipBlockComment(input, i);
|
|
70
|
-
else
|
|
71
|
-
++i;
|
|
72
108
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const skipQuoted = (input, index, quote) => {
|
|
80
|
-
let escaped = false;
|
|
81
|
-
for (let i = index + 1; i < input.length; ++i) {
|
|
82
|
-
const ch = input[i];
|
|
83
|
-
if (escaped)
|
|
84
|
-
escaped = false;
|
|
85
|
-
else if (ch === "\\")
|
|
86
|
-
escaped = true;
|
|
87
|
-
else if (ch === quote)
|
|
88
|
-
return i + 1;
|
|
109
|
+
spans.sort((a, b) => a.start - b.start);
|
|
110
|
+
const pieces = [];
|
|
111
|
+
let cursor = 0;
|
|
112
|
+
for (const span of spans) {
|
|
113
|
+
pieces.push(input.slice(cursor, span.start), REPLACEMENT);
|
|
114
|
+
cursor = span.end;
|
|
89
115
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const skipLineComment = (input, index) => {
|
|
93
|
-
const found = input.indexOf("\n", index + 2);
|
|
94
|
-
return found === -1 ? input.length : found + 1;
|
|
95
|
-
};
|
|
96
|
-
const skipBlockComment = (input, index) => {
|
|
97
|
-
const found = input.indexOf("*/", index + 2);
|
|
98
|
-
return found === -1 ? input.length : found + 2;
|
|
116
|
+
pieces.push(input.slice(cursor));
|
|
117
|
+
return pieces.join("");
|
|
99
118
|
};
|
|
100
119
|
//# sourceMappingURL=EmittedJavaScriptPatcher.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmittedJavaScriptPatcher.js","sourceRoot":"","sources":["../../src/utils/EmittedJavaScriptPatcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AAExB,IAAiB,wBAAwB,
|
|
1
|
+
{"version":3,"file":"EmittedJavaScriptPatcher.js","sourceRoot":"","sources":["../../src/utils/EmittedJavaScriptPatcher.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,4 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finds a file or a directory by name, in a directory and up to three parents.
|
|
3
|
+
*
|
|
4
|
+
* @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.
|
|
5
|
+
* @evidence contracts/common.md#clear-and-simple-design Two curried functions with the same recursion.
|
|
6
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The limit is a fixed search depth, not a file name.
|
|
7
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
8
|
+
* @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.
|
|
9
|
+
*/
|
|
1
10
|
export declare namespace FileRetriever {
|
|
11
|
+
/**
|
|
12
|
+
* Returns the nearest directory, from the given one up to three parents, that
|
|
13
|
+
* contains an entry with the name, or `null`.
|
|
14
|
+
*
|
|
15
|
+
* @evidence contracts/common.md#principled-implementation The recursion is bounded by the depth counter, so it terminates at the filesystem root as well.
|
|
16
|
+
* @evidence contracts/common.md#clear-and-simple-design One function.
|
|
17
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The bound is explicit.
|
|
18
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the result.
|
|
19
|
+
* @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.
|
|
20
|
+
*/
|
|
2
21
|
const directory: (name: string) => (dir: string, depth?: number) => string | null;
|
|
22
|
+
/**
|
|
23
|
+
* Returns the path of the nearest existing entry with the name, from the
|
|
24
|
+
* given directory up to three parents, or `null`.
|
|
25
|
+
*
|
|
26
|
+
* @evidence contracts/common.md#principled-implementation The recursion is bounded by the depth counter.
|
|
27
|
+
* @evidence contracts/common.md#clear-and-simple-design One function.
|
|
28
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The bound is explicit.
|
|
29
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the result.
|
|
30
|
+
* @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.
|
|
31
|
+
*/
|
|
3
32
|
const file: (name: string) => (directory: string, depth?: number) => string | null;
|
|
4
33
|
}
|
|
@@ -6,8 +6,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.FileRetriever = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
+
/**
|
|
10
|
+
* Finds a file or a directory by name, in a directory and up to three parents.
|
|
11
|
+
*
|
|
12
|
+
* @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.
|
|
13
|
+
* @evidence contracts/common.md#clear-and-simple-design Two curried functions with the same recursion.
|
|
14
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The limit is a fixed search depth, not a file name.
|
|
15
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
16
|
+
* @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.
|
|
17
|
+
*/
|
|
9
18
|
var FileRetriever;
|
|
10
19
|
(function (FileRetriever) {
|
|
20
|
+
/**
|
|
21
|
+
* Returns the nearest directory, from the given one up to three parents, that
|
|
22
|
+
* contains an entry with the name, or `null`.
|
|
23
|
+
*
|
|
24
|
+
* @evidence contracts/common.md#principled-implementation The recursion is bounded by the depth counter, so it terminates at the filesystem root as well.
|
|
25
|
+
* @evidence contracts/common.md#clear-and-simple-design One function.
|
|
26
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The bound is explicit.
|
|
27
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the result.
|
|
28
|
+
* @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.
|
|
29
|
+
*/
|
|
11
30
|
FileRetriever.directory = (name) => (dir, depth = 0) => {
|
|
12
31
|
const location = path_1.default.join(dir, name);
|
|
13
32
|
if (fs_1.default.existsSync(location))
|
|
@@ -16,6 +35,16 @@ var FileRetriever;
|
|
|
16
35
|
return null;
|
|
17
36
|
return FileRetriever.directory(name)(path_1.default.join(dir, ".."), depth + 1);
|
|
18
37
|
};
|
|
38
|
+
/**
|
|
39
|
+
* Returns the path of the nearest existing entry with the name, from the
|
|
40
|
+
* given directory up to three parents, or `null`.
|
|
41
|
+
*
|
|
42
|
+
* @evidence contracts/common.md#principled-implementation The recursion is bounded by the depth counter.
|
|
43
|
+
* @evidence contracts/common.md#clear-and-simple-design One function.
|
|
44
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The bound is explicit.
|
|
45
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the result.
|
|
46
|
+
* @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.
|
|
47
|
+
*/
|
|
19
48
|
FileRetriever.file = (name) => (directory, depth = 0) => {
|
|
20
49
|
const location = path_1.default.join(directory, name);
|
|
21
50
|
if (fs_1.default.existsSync(location))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileRetriever.js","sourceRoot":"","sources":["../../src/utils/FileRetriever.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AAExB,IAAiB,aAAa,
|
|
1
|
+
{"version":3,"file":"FileRetriever.js","sourceRoot":"","sources":["../../src/utils/FileRetriever.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AAExB;;;;;;;;GAQG;AACH,IAAiB,aAAa,CAsC7B;AAtCD,WAAiB,aAAa;IAC5B;;;;;;;;;OASG;IACU,uBAAS,GACpB,CAAC,IAAY,EAAE,EAAE,CACjB,CAAC,GAAW,EAAE,KAAK,GAAW,CAAC,EAAiB,EAAE;QAChD,MAAM,QAAQ,GAAW,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC9C,IAAI,YAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;YAAE,OAAO,GAAG,CAAC;aACnC,IAAI,KAAK,GAAG,CAAC;YAAE,OAAO,IAAI,CAAC;QAChC,OAAO,uBAAS,CAAC,IAAI,CAAC,CAAC,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;IAC1D,CAAC,CAAC;IAEJ;;;;;;;;;OASG;IACU,kBAAI,GACf,CAAC,IAAY,EAAE,EAAE,CACjB,CAAC,SAAiB,EAAE,KAAK,GAAW,CAAC,EAAiB,EAAE;QACtD,MAAM,QAAQ,GAAW,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QACpD,IAAI,YAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;YAAE,OAAO,QAAQ,CAAC;aACxC,IAAI,KAAK,GAAG,CAAC;YAAE,OAAO,IAAI,CAAC;QAChC,OAAO,kBAAI,CAAC,IAAI,CAAC,CAAC,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;IAC3D,CAAC,CAAC;AACN,CAAC,EAtCgB,aAAa,aAAb,aAAa,GAAb,aAAa,QAsC7B"}
|
|
@@ -1,5 +1,46 @@
|
|
|
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 declare 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
|
type Response = "application/json" | "text/plain" | "application/x-www-form-urlencoded" | (string & {}) | null;
|
|
22
|
+
/**
|
|
23
|
+
* Reports whether the SDK supports the content type: none, JSON, plain text,
|
|
24
|
+
* urlencoded, or a binary type.
|
|
25
|
+
*
|
|
26
|
+
* @evidence contracts/common.md#principled-implementation The content type is compared exactly for the three text types and by the binary rule otherwise.
|
|
27
|
+
* @evidence contracts/common.md#clear-and-simple-design One expression.
|
|
28
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The list is the supported set.
|
|
29
|
+
* @evidence contracts/common.md#meaningful-documentation The comment lists the supported types.
|
|
30
|
+
* @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.
|
|
31
|
+
*/
|
|
3
32
|
const isSupported: (input: string | null) => input is Response;
|
|
33
|
+
/**
|
|
34
|
+
* Reports whether the content type is binary: an image, video, or audio type,
|
|
35
|
+
* an octet stream, or a PDF.
|
|
36
|
+
*
|
|
37
|
+
* Parameters and case are ignored.
|
|
38
|
+
*
|
|
39
|
+
* @evidence contracts/common.md#principled-implementation The type is the text before the first `;`, trimmed and lower-cased, as HTTP defines a media type.
|
|
40
|
+
* @evidence contracts/common.md#clear-and-simple-design One predicate.
|
|
41
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The rule is a list of media types.
|
|
42
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the binary types and the normalization.
|
|
43
|
+
* @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.
|
|
44
|
+
*/
|
|
4
45
|
const isBinary: (input: string | null | undefined) => input is string;
|
|
5
46
|
}
|
|
@@ -1,13 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HttpResponseContentTypeUtil = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Classifies the content type of a response.
|
|
6
|
+
*
|
|
7
|
+
* @evidence contracts/common.md#principled-implementation The namespace decides which content types the SDK supports and which are binary.
|
|
8
|
+
* @evidence contracts/common.md#clear-and-simple-design One type and two predicates.
|
|
9
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The list is media types, not routes.
|
|
10
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
11
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation HttpResponseContentTypeUtil classifies HTTP response metadata and MIME types, which have protocol semantics independent of the native filesystem.
|
|
12
|
+
*/
|
|
4
13
|
var HttpResponseContentTypeUtil;
|
|
5
14
|
(function (HttpResponseContentTypeUtil) {
|
|
15
|
+
/**
|
|
16
|
+
* Reports whether the SDK supports the content type: none, JSON, plain text,
|
|
17
|
+
* urlencoded, or a binary type.
|
|
18
|
+
*
|
|
19
|
+
* @evidence contracts/common.md#principled-implementation The content type is compared exactly for the three text types and by the binary rule otherwise.
|
|
20
|
+
* @evidence contracts/common.md#clear-and-simple-design One expression.
|
|
21
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The list is the supported set.
|
|
22
|
+
* @evidence contracts/common.md#meaningful-documentation The comment lists the supported types.
|
|
23
|
+
* @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.
|
|
24
|
+
*/
|
|
6
25
|
HttpResponseContentTypeUtil.isSupported = (input) => input === null ||
|
|
7
26
|
input === "application/json" ||
|
|
8
27
|
input === "text/plain" ||
|
|
9
28
|
input === "application/x-www-form-urlencoded" ||
|
|
10
29
|
HttpResponseContentTypeUtil.isBinary(input);
|
|
30
|
+
/**
|
|
31
|
+
* Reports whether the content type is binary: an image, video, or audio type,
|
|
32
|
+
* an octet stream, or a PDF.
|
|
33
|
+
*
|
|
34
|
+
* Parameters and case are ignored.
|
|
35
|
+
*
|
|
36
|
+
* @evidence contracts/common.md#principled-implementation The type is the text before the first `;`, trimmed and lower-cased, as HTTP defines a media type.
|
|
37
|
+
* @evidence contracts/common.md#clear-and-simple-design One predicate.
|
|
38
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The rule is a list of media types.
|
|
39
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the binary types and the normalization.
|
|
40
|
+
* @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.
|
|
41
|
+
*/
|
|
11
42
|
HttpResponseContentTypeUtil.isBinary = (input) => {
|
|
12
43
|
if (typeof input !== "string")
|
|
13
44
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpResponseContentTypeUtil.js","sourceRoot":"","sources":["../../src/utils/HttpResponseContentTypeUtil.ts"],"names":[],"mappings":";;;AAAA,IAAiB,2BAA2B,
|
|
1
|
+
{"version":3,"file":"HttpResponseContentTypeUtil.js","sourceRoot":"","sources":["../../src/utils/HttpResponseContentTypeUtil.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;GAQG;AACH,IAAiB,2BAA2B,CA6D3C;AA7DD,WAAiB,2BAA2B;IAkB1C;;;;;;;;;OASG;IACU,uCAAW,GAAG,CAAC,KAAoB,EAAqB,EAAE,CACrE,KAAK,KAAK,IAAI;QACd,KAAK,KAAK,kBAAkB;QAC5B,KAAK,KAAK,YAAY;QACtB,KAAK,KAAK,mCAAmC;QAC7C,oCAAQ,CAAC,KAAK,CAAC,CAAC;IAElB;;;;;;;;;;;OAWG;IACU,oCAAQ,GAAG,CACtB,KAAgC,EACf,EAAE;QACnB,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;QAE5C,MAAM,KAAK,GAAW,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAChE,OAAO,CACL,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC;YAC1B,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC;YAC1B,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC;YAC1B,KAAK,KAAK,0BAA0B;YACpC,KAAK,KAAK,iBAAiB,CAC5B,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,EA7DgB,2BAA2B,aAA3B,2BAA2B,GAA3B,2BAA2B,QA6D3C"}
|
package/lib/utils/MapUtil.d.ts
CHANGED
|
@@ -1,3 +1,66 @@
|
|
|
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 declare namespace MapUtil {
|
|
2
|
-
|
|
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
|
+
*/
|
|
24
|
+
function take<Key, T>(dict: IDictionary<Key, T>, key: Key, generator: () => T): T;
|
|
25
|
+
/**
|
|
26
|
+
* The members of a `Map` or a `WeakMap` that {@link take} reads and writes.
|
|
27
|
+
*
|
|
28
|
+
* @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.
|
|
29
|
+
* @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.
|
|
30
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
|
|
31
|
+
* @evidence contracts/common.md#meaningful-documentation The comment names the two dictionaries it admits and the operations it needs.
|
|
32
|
+
* @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.
|
|
33
|
+
*/
|
|
34
|
+
interface IDictionary<Key, T> {
|
|
35
|
+
/**
|
|
36
|
+
* Whether the key is present, including a key whose value is `undefined`.
|
|
37
|
+
*
|
|
38
|
+
* @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.
|
|
39
|
+
* @evidence contracts/common.md#clear-and-simple-design One member with the signature that `Map` and `WeakMap` share.
|
|
40
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is a signature and adds no runtime behavior.
|
|
41
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the member answers or does for {@link take}.
|
|
42
|
+
* @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.
|
|
43
|
+
*/
|
|
44
|
+
has(key: Key): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* The value stored for the key, or `undefined` when it is absent.
|
|
47
|
+
*
|
|
48
|
+
* @evidence contracts/common.md#principled-implementation The read is only made after a presence test, so `undefined` here always means a stored value.
|
|
49
|
+
* @evidence contracts/common.md#clear-and-simple-design One member with the signature that `Map` and `WeakMap` share.
|
|
50
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is a signature and adds no runtime behavior.
|
|
51
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the member answers or does for {@link take}.
|
|
52
|
+
* @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.
|
|
53
|
+
*/
|
|
54
|
+
get(key: Key): T | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Stores the value for the key; the result is ignored.
|
|
57
|
+
*
|
|
58
|
+
* @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.
|
|
59
|
+
* @evidence contracts/common.md#clear-and-simple-design One member with the signature that `Map` and `WeakMap` share.
|
|
60
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is a signature and adds no runtime behavior.
|
|
61
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the member answers or does for {@link take}.
|
|
62
|
+
* @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.
|
|
63
|
+
*/
|
|
64
|
+
set(key: Key, value: T): unknown;
|
|
65
|
+
}
|
|
3
66
|
}
|
package/lib/utils/MapUtil.js
CHANGED
|
@@ -1,12 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MapUtil = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Helpers for maps.
|
|
6
|
+
*
|
|
7
|
+
* @evidence contracts/common.md#principled-implementation The namespace holds the get-or-create helper.
|
|
8
|
+
* @evidence contracts/common.md#clear-and-simple-design One function.
|
|
9
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is a plain helper.
|
|
10
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
11
|
+
* @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.
|
|
12
|
+
*/
|
|
4
13
|
var MapUtil;
|
|
5
14
|
(function (MapUtil) {
|
|
15
|
+
/**
|
|
16
|
+
* Returns the value of a key, creating and storing it when the key is absent.
|
|
17
|
+
*
|
|
18
|
+
* Presence is tested with `has`, so a stored falsy value is not created
|
|
19
|
+
* again. The dictionary may be a `Map` or a `WeakMap`, so a cache keyed by
|
|
20
|
+
* object identity can leave its entries to the garbage collector.
|
|
21
|
+
*
|
|
22
|
+
* @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.
|
|
23
|
+
* @evidence contracts/common.md#clear-and-simple-design One check, one call, and one store.
|
|
24
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The stored value is returned unchanged.
|
|
25
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the presence rule.
|
|
26
|
+
* @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.
|
|
27
|
+
*/
|
|
6
28
|
function take(dict, key, generator) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return oldbie;
|
|
29
|
+
if (dict.has(key))
|
|
30
|
+
return dict.get(key);
|
|
10
31
|
const value = generator();
|
|
11
32
|
dict.set(key, value);
|
|
12
33
|
return value;
|
package/lib/utils/MapUtil.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapUtil.js","sourceRoot":"","sources":["../../src/utils/MapUtil.ts"],"names":[],"mappings":";;;AAAA,IAAiB,OAAO,
|
|
1
|
+
{"version":3,"file":"MapUtil.js","sourceRoot":"","sources":["../../src/utils/MapUtil.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;GAQG;AACH,IAAiB,OAAO,CAqEvB;AArED,WAAiB,OAAO;IACtB;;;;;;;;;;;;OAYG;IACH,SAAgB,IAAI,CAClB,IAAyB,EACzB,GAAQ,EACR,SAAkB;QAElB,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAM,CAAC;QAE7C,MAAM,KAAK,GAAM,SAAS,EAAE,CAAC;QAC7B,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACrB,OAAO,KAAK,CAAC;IACf,CAAC;IAVe,QAAA,IAAI,OAUnB,CAAA;AA6CH,CAAC,EArEgB,OAAO,aAAP,OAAO,GAAP,OAAO,QAqEvB"}
|
package/lib/utils/PathUtil.d.ts
CHANGED
|
@@ -1,3 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for route paths used as accessors, and for source file locations.
|
|
3
|
+
*
|
|
4
|
+
* @evidence contracts/common.md#principled-implementation The namespace turns a path into accessor names and a source location into a plain path.
|
|
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
|
+
* @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.
|
|
9
|
+
*/
|
|
1
10
|
export declare namespace PathUtil {
|
|
11
|
+
/**
|
|
12
|
+
* Returns the accessor segments of a path: the segments that are not empty
|
|
13
|
+
* and not parameters, with dashes and dots replaced by underscores.
|
|
14
|
+
*
|
|
15
|
+
* @evidence contracts/common.md#principled-implementation Parameters do not name a namespace and the replaced characters are not valid in an identifier.
|
|
16
|
+
* @evidence contracts/common.md#clear-and-simple-design One pipeline.
|
|
17
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The rule applies to every path.
|
|
18
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the result.
|
|
19
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation This function processes route URL segments rather than native filesystem paths or identities.
|
|
20
|
+
*/
|
|
2
21
|
const accessors: (path: string) => string[];
|
|
22
|
+
/**
|
|
23
|
+
* Returns the plain path of a source location: a `file:` URL is decoded to
|
|
24
|
+
* the path it names, with forward slashes, and any other text is returned as
|
|
25
|
+
* it is.
|
|
26
|
+
*
|
|
27
|
+
* @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.
|
|
28
|
+
* @evidence contracts/common.md#clear-and-simple-design One conditional over the standard decoder.
|
|
29
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Only a `file:` location is decoded; a plain path is never altered.
|
|
30
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states both inputs and the separator.
|
|
31
|
+
* @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.
|
|
32
|
+
*/
|
|
33
|
+
const location: (str: string) => string;
|
|
3
34
|
}
|
package/lib/utils/PathUtil.js
CHANGED
|
@@ -1,12 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.PathUtil = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const url_1 = require("url");
|
|
9
|
+
/**
|
|
10
|
+
* Helpers for route paths used as accessors, and for source file locations.
|
|
11
|
+
*
|
|
12
|
+
* @evidence contracts/common.md#principled-implementation The namespace turns a path into accessor names and a source location into a plain path.
|
|
13
|
+
* @evidence contracts/common.md#clear-and-simple-design Two functions.
|
|
14
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts They are plain helpers.
|
|
15
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
16
|
+
* @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.
|
|
17
|
+
*/
|
|
4
18
|
var PathUtil;
|
|
5
19
|
(function (PathUtil) {
|
|
20
|
+
/**
|
|
21
|
+
* Returns the accessor segments of a path: the segments that are not empty
|
|
22
|
+
* and not parameters, with dashes and dots replaced by underscores.
|
|
23
|
+
*
|
|
24
|
+
* @evidence contracts/common.md#principled-implementation Parameters do not name a namespace and the replaced characters are not valid in an identifier.
|
|
25
|
+
* @evidence contracts/common.md#clear-and-simple-design One pipeline.
|
|
26
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The rule applies to every path.
|
|
27
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the result.
|
|
28
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation This function processes route URL segments rather than native filesystem paths or identities.
|
|
29
|
+
*/
|
|
6
30
|
PathUtil.accessors = (path) => path
|
|
7
31
|
.split("/")
|
|
8
32
|
.filter((str) => str.length && str[0] !== ":")
|
|
9
33
|
.map(normalize);
|
|
34
|
+
/**
|
|
35
|
+
* Returns the plain path of a source location: a `file:` URL is decoded to
|
|
36
|
+
* the path it names, with forward slashes, and any other text is returned as
|
|
37
|
+
* it is.
|
|
38
|
+
*
|
|
39
|
+
* @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.
|
|
40
|
+
* @evidence contracts/common.md#clear-and-simple-design One conditional over the standard decoder.
|
|
41
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Only a `file:` location is decoded; a plain path is never altered.
|
|
42
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states both inputs and the separator.
|
|
43
|
+
* @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.
|
|
44
|
+
*/
|
|
45
|
+
PathUtil.location = (str) => str.startsWith("file:")
|
|
46
|
+
? (0, url_1.fileURLToPath)(str).split(path_1.default.sep).join("/")
|
|
47
|
+
: str;
|
|
10
48
|
const normalize = (str) => str.split("-").join("_").split(".").join("_");
|
|
11
49
|
})(PathUtil || (exports.PathUtil = PathUtil = {}));
|
|
12
50
|
//# sourceMappingURL=PathUtil.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PathUtil.js","sourceRoot":"","sources":["../../src/utils/PathUtil.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PathUtil.js","sourceRoot":"","sources":["../../src/utils/PathUtil.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,6BAAoC;AAEpC;;;;;;;;GAQG;AACH,IAAiB,QAAQ,CAmCxB;AAnCD,WAAiB,QAAQ;IACvB;;;;;;;;;OASG;IACU,kBAAS,GAAG,CAAC,IAAY,EAAE,EAAE,CACxC,IAAI;SACD,KAAK,CAAC,GAAG,CAAC;SACV,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC;SAC7C,GAAG,CAAC,SAAS,CAAC,CAAC;IAEpB;;;;;;;;;;OAUG;IACU,iBAAQ,GAAG,CAAC,GAAW,EAAU,EAAE,CAC9C,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC;QACrB,CAAC,CAAC,IAAA,mBAAa,EAAC,GAAG,CAAC,CAAC,KAAK,CAAC,cAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QAC9C,CAAC,CAAC,GAAG,CAAC;IAEV,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,EAAE,CAChC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,CAAC,EAnCgB,QAAQ,aAAR,QAAQ,GAAR,QAAQ,QAmCxB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SDK_BUNDLE_PATH = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
/** The installed API bundle shared by SDK emission and source exclusion. */
|
|
9
|
+
exports.SDK_BUNDLE_PATH = path_1.default.join(__dirname, "..", "..", "assets", "bundle", "api");
|
|
10
|
+
//# sourceMappingURL=SdkBundlePath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SdkBundlePath.js","sourceRoot":"","sources":["../../src/utils/SdkBundlePath.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAExB,4EAA4E;AAC/D,QAAA,eAAe,GAAW,cAAI,CAAC,IAAI,CAC9C,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,KAAK,CACN,CAAC"}
|