@nestia/sdk 14.0.0 → 14.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/assets/bundle/distribute/build-sdk.cjs +28 -0
- package/assets/bundle/distribute/package.json +7 -3
- package/assets/bundle/distribute/tsconfig.json +15 -105
- package/lib/INestiaConfig.d.ts +74 -34
- package/lib/NestiaSdkApplication.d.ts +60 -0
- package/lib/NestiaSdkApplication.js +121 -32
- package/lib/NestiaSdkApplication.js.map +1 -1
- package/lib/NestiaSwaggerComposer.d.ts +21 -0
- package/lib/NestiaSwaggerComposer.js +32 -13
- package/lib/NestiaSwaggerComposer.js.map +1 -1
- package/lib/analyses/AccessorAnalyzer.d.ts +26 -0
- package/lib/analyses/AccessorAnalyzer.js +26 -0
- package/lib/analyses/AccessorAnalyzer.js.map +1 -1
- package/lib/analyses/ConfigAnalyzer.d.ts +41 -0
- package/lib/analyses/ConfigAnalyzer.js +52 -77
- package/lib/analyses/ConfigAnalyzer.js.map +1 -1
- package/lib/analyses/ImportAnalyzer.d.ts +25 -0
- package/lib/analyses/ImportAnalyzer.js +25 -0
- package/lib/analyses/ImportAnalyzer.js.map +1 -1
- package/lib/analyses/ParameterNameAnalyzer.d.ts +44 -0
- package/lib/analyses/ParameterNameAnalyzer.js +63 -0
- package/lib/analyses/ParameterNameAnalyzer.js.map +1 -0
- package/lib/analyses/PathAnalyzer.d.ts +93 -1
- package/lib/analyses/PathAnalyzer.js +160 -23
- package/lib/analyses/PathAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectControllerAnalyzer.d.ts +32 -0
- package/lib/analyses/ReflectControllerAnalyzer.js +24 -1
- package/lib/analyses/ReflectControllerAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationAnalyzer.d.ts +29 -0
- package/lib/analyses/ReflectHttpOperationAnalyzer.js +35 -24
- package/lib/analyses/ReflectHttpOperationAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationExceptionAnalyzer.d.ts +31 -0
- package/lib/analyses/ReflectHttpOperationExceptionAnalyzer.js +21 -0
- package/lib/analyses/ReflectHttpOperationExceptionAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationParameterAnalyzer.d.ts +31 -0
- package/lib/analyses/ReflectHttpOperationParameterAnalyzer.js +143 -23
- package/lib/analyses/ReflectHttpOperationParameterAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.d.ts +32 -0
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.js +27 -2
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectMcpOperationAnalyzer.d.ts +29 -0
- package/lib/analyses/ReflectMcpOperationAnalyzer.js +35 -11
- package/lib/analyses/ReflectMcpOperationAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectMetadataAnalyzer.d.ts +47 -0
- package/lib/analyses/ReflectMetadataAnalyzer.js +47 -0
- package/lib/analyses/ReflectMetadataAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectWebSocketOperationAnalyzer.d.ts +29 -0
- package/lib/analyses/ReflectWebSocketOperationAnalyzer.js +27 -5
- package/lib/analyses/ReflectWebSocketOperationAnalyzer.js.map +1 -1
- package/lib/analyses/SecurityAnalyzer.d.ts +25 -0
- package/lib/analyses/SecurityAnalyzer.js +39 -19
- package/lib/analyses/SecurityAnalyzer.js.map +1 -1
- package/lib/analyses/SwaggerExampleAnalyzer.d.ts +31 -0
- package/lib/analyses/SwaggerExampleAnalyzer.js +36 -0
- package/lib/analyses/SwaggerExampleAnalyzer.js.map +1 -0
- package/lib/analyses/TypedHttpRouteAnalyzer.d.ts +41 -3
- package/lib/analyses/TypedHttpRouteAnalyzer.js +196 -172
- package/lib/analyses/TypedHttpRouteAnalyzer.js.map +1 -1
- package/lib/analyses/TypedMcpRouteAnalyzer.d.ts +29 -0
- package/lib/analyses/TypedMcpRouteAnalyzer.js +152 -20
- package/lib/analyses/TypedMcpRouteAnalyzer.js.map +1 -1
- package/lib/analyses/TypedWebSocketRouteAnalyzer.d.ts +19 -0
- package/lib/analyses/TypedWebSocketRouteAnalyzer.js +20 -1
- package/lib/analyses/TypedWebSocketRouteAnalyzer.js.map +1 -1
- package/lib/decorators/OperationMetadata.d.ts +6 -0
- package/lib/decorators/OperationMetadata.js +6 -0
- package/lib/decorators/OperationMetadata.js.map +1 -1
- package/lib/executable/internal/CommandParser.d.ts +19 -0
- package/lib/executable/internal/CommandParser.js +19 -0
- package/lib/executable/internal/CommandParser.js.map +1 -1
- package/lib/executable/internal/NestiaConfigLoader.d.ts +56 -0
- package/lib/executable/internal/NestiaConfigLoader.js +48 -42
- package/lib/executable/internal/NestiaConfigLoader.js.map +1 -1
- package/lib/executable/internal/NestiaSdkCommand.d.ts +60 -0
- package/lib/executable/internal/NestiaSdkCommand.js +95 -3
- package/lib/executable/internal/NestiaSdkCommand.js.map +1 -1
- package/lib/executable/internal/NestiaSdkWatcher.d.ts +81 -0
- package/lib/executable/internal/NestiaSdkWatcher.js +125 -41
- package/lib/executable/internal/NestiaSdkWatcher.js.map +1 -1
- package/lib/executable/internal/NestiaSwaggerWatch.d.ts +80 -0
- package/lib/executable/internal/NestiaSwaggerWatch.js +308 -0
- package/lib/executable/internal/NestiaSwaggerWatch.js.map +1 -0
- package/lib/executable/sdk.js +16 -1
- package/lib/executable/sdk.js.map +1 -1
- package/lib/factories/ExpressionFactory.d.ts +18 -0
- package/lib/factories/ExpressionFactory.js +21 -2
- package/lib/factories/ExpressionFactory.js.map +1 -1
- package/lib/factories/IdentifierFactory.d.ts +24 -0
- package/lib/factories/IdentifierFactory.js +24 -0
- package/lib/factories/IdentifierFactory.js.map +1 -1
- package/lib/factories/LiteralFactory.d.ts +22 -4
- package/lib/factories/LiteralFactory.js +33 -11
- package/lib/factories/LiteralFactory.js.map +1 -1
- package/lib/factories/StatementFactory.d.ts +28 -1
- package/lib/factories/StatementFactory.js +28 -1
- package/lib/factories/StatementFactory.js.map +1 -1
- package/lib/factories/TypeFactory.d.ts +24 -0
- package/lib/factories/TypeFactory.js +15 -0
- package/lib/factories/TypeFactory.js.map +1 -1
- package/lib/generates/CloneGenerator.d.ts +22 -0
- package/lib/generates/CloneGenerator.js +26 -5
- package/lib/generates/CloneGenerator.js.map +1 -1
- package/lib/generates/E2eGenerator.d.ts +19 -0
- package/lib/generates/E2eGenerator.js +19 -0
- package/lib/generates/E2eGenerator.js.map +1 -1
- package/lib/generates/SdkGenerator.d.ts +38 -0
- package/lib/generates/SdkGenerator.js +43 -5
- package/lib/generates/SdkGenerator.js.map +1 -1
- package/lib/generates/SwaggerGenerator.d.ts +36 -6
- package/lib/generates/SwaggerGenerator.js +190 -40
- package/lib/generates/SwaggerGenerator.js.map +1 -1
- package/lib/generates/internal/E2eFileProgrammer.d.ts +19 -0
- package/lib/generates/internal/E2eFileProgrammer.js +20 -1
- package/lib/generates/internal/E2eFileProgrammer.js.map +1 -1
- package/lib/generates/internal/FilePrinter.d.ts +57 -0
- package/lib/generates/internal/FilePrinter.js +74 -0
- package/lib/generates/internal/FilePrinter.js.map +1 -1
- package/lib/generates/internal/ImportDictionary.d.ts +93 -1
- package/lib/generates/internal/ImportDictionary.js +103 -2
- package/lib/generates/internal/ImportDictionary.js.map +1 -1
- package/lib/generates/internal/SdkAliasCollection.d.ts +121 -1
- package/lib/generates/internal/SdkAliasCollection.js +132 -11
- package/lib/generates/internal/SdkAliasCollection.js.map +1 -1
- package/lib/generates/internal/SdkDistributionComposer.d.ts +19 -0
- package/lib/generates/internal/SdkDistributionComposer.js +149 -52
- package/lib/generates/internal/SdkDistributionComposer.js.map +1 -1
- package/lib/generates/internal/SdkFileProgrammer.d.ts +18 -0
- package/lib/generates/internal/SdkFileProgrammer.js +101 -12
- package/lib/generates/internal/SdkFileProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpCloneProgrammer.d.ts +29 -0
- package/lib/generates/internal/SdkHttpCloneProgrammer.js +33 -0
- package/lib/generates/internal/SdkHttpCloneProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpCloneReferencer.d.ts +19 -0
- package/lib/generates/internal/SdkHttpCloneReferencer.js +78 -25
- package/lib/generates/internal/SdkHttpCloneReferencer.js.map +1 -1
- package/lib/generates/internal/SdkHttpFunctionProgrammer.d.ts +19 -0
- package/lib/generates/internal/SdkHttpFunctionProgrammer.js +40 -23
- package/lib/generates/internal/SdkHttpFunctionProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.d.ts +19 -0
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.js +46 -34
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpParameterProgrammer.d.ts +142 -1
- package/lib/generates/internal/SdkHttpParameterProgrammer.js +175 -6
- package/lib/generates/internal/SdkHttpParameterProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpRouteProgrammer.d.ts +20 -0
- package/lib/generates/internal/SdkHttpRouteProgrammer.js +36 -32
- package/lib/generates/internal/SdkHttpRouteProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpSimulationProgrammer.d.ts +38 -0
- package/lib/generates/internal/SdkHttpSimulationProgrammer.js +66 -18
- package/lib/generates/internal/SdkHttpSimulationProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkImportWizard.d.ts +63 -0
- package/lib/generates/internal/SdkImportWizard.js +63 -0
- package/lib/generates/internal/SdkImportWizard.js.map +1 -1
- package/lib/generates/internal/SdkMcpRouteProgrammer.d.ts +17 -2
- package/lib/generates/internal/SdkMcpRouteProgrammer.js +72 -24
- package/lib/generates/internal/SdkMcpRouteProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkPathTemplate.d.ts +36 -0
- package/lib/generates/internal/SdkPathTemplate.js +65 -0
- package/lib/generates/internal/SdkPathTemplate.js.map +1 -0
- package/lib/generates/internal/SdkRouteDirectory.d.ts +10 -0
- package/lib/generates/internal/SdkRouteDirectory.js +10 -0
- package/lib/generates/internal/SdkRouteDirectory.js.map +1 -1
- package/lib/generates/internal/SdkTypeProgrammer.d.ts +54 -1
- package/lib/generates/internal/SdkTypeProgrammer.js +111 -27
- package/lib/generates/internal/SdkTypeProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkTypeTagProgrammer.d.ts +53 -1
- package/lib/generates/internal/SdkTypeTagProgrammer.js +407 -67
- package/lib/generates/internal/SdkTypeTagProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketCloneProgrammer.d.ts +40 -0
- package/lib/generates/internal/SdkWebSocketCloneProgrammer.js +149 -142
- package/lib/generates/internal/SdkWebSocketCloneProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.d.ts +19 -0
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js +46 -36
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketParameterProgrammer.d.ts +114 -1
- package/lib/generates/internal/SdkWebSocketParameterProgrammer.js +120 -5
- package/lib/generates/internal/SdkWebSocketParameterProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.d.ts +18 -0
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.js +75 -33
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.js.map +1 -1
- package/lib/generates/internal/SwaggerDescriptionComposer.d.ts +42 -0
- package/lib/generates/internal/SwaggerDescriptionComposer.js +44 -1
- package/lib/generates/internal/SwaggerDescriptionComposer.js.map +1 -1
- package/lib/generates/internal/SwaggerOperationComposer.d.ts +18 -0
- package/lib/generates/internal/SwaggerOperationComposer.js +37 -8
- package/lib/generates/internal/SwaggerOperationComposer.js.map +1 -1
- package/lib/generates/internal/SwaggerOperationParameterComposer.d.ts +40 -1
- package/lib/generates/internal/SwaggerOperationParameterComposer.js +230 -25
- package/lib/generates/internal/SwaggerOperationParameterComposer.js.map +1 -1
- package/lib/generates/internal/SwaggerOperationResponseComposer.d.ts +21 -0
- package/lib/generates/internal/SwaggerOperationResponseComposer.js +58 -7
- package/lib/generates/internal/SwaggerOperationResponseComposer.js.map +1 -1
- package/lib/internal/legacy.d.ts +342 -31
- package/lib/internal/legacy.js +207 -31
- package/lib/internal/legacy.js.map +1 -1
- package/lib/structures/INestiaProject.d.ts +10 -0
- package/lib/structures/INestiaSdkInput.d.ts +30 -0
- package/lib/structures/IOperationMetadata.d.ts +77 -0
- package/lib/structures/IReflectController.d.ts +10 -0
- package/lib/structures/IReflectHttpOperation.d.ts +10 -0
- package/lib/structures/IReflectHttpOperationException.d.ts +13 -2
- package/lib/structures/IReflectHttpOperationParameter.d.ts +55 -3
- package/lib/structures/IReflectHttpOperationSuccess.d.ts +15 -3
- package/lib/structures/IReflectImport.d.ts +10 -0
- package/lib/structures/IReflectMcpOperation.d.ts +19 -0
- package/lib/structures/IReflectMcpOperationParameter.d.ts +9 -0
- package/lib/structures/IReflectOperationError.d.ts +28 -0
- package/lib/structures/IReflectOperationError.js +22 -2
- package/lib/structures/IReflectOperationError.js.map +1 -1
- package/lib/structures/IReflectType.d.ts +9 -0
- package/lib/structures/IReflectWebSocketOperation.d.ts +10 -0
- package/lib/structures/IReflectWebSocketOperationParameter.d.ts +55 -0
- package/lib/structures/ITypedApplication.d.ts +10 -0
- package/lib/structures/ITypedHttpRoute.d.ts +18 -0
- package/lib/structures/ITypedHttpRouteException.d.ts +13 -1
- package/lib/structures/ITypedHttpRouteParameter.d.ts +48 -1
- package/lib/structures/ITypedHttpRouteSuccess.d.ts +13 -1
- package/lib/structures/ITypedMcpRoute.d.ts +11 -0
- package/lib/structures/ITypedWebSocketRoute.d.ts +18 -0
- package/lib/transform.d.ts +6 -0
- package/lib/transform.js +6 -0
- package/lib/transform.js.map +1 -1
- package/lib/utils/ArrayUtil.d.ts +31 -1
- package/lib/utils/ArrayUtil.js +32 -11
- package/lib/utils/ArrayUtil.js.map +1 -1
- package/lib/utils/EmittedJavaScriptPatcher.d.ts +20 -0
- package/lib/utils/EmittedJavaScriptPatcher.js +65 -46
- package/lib/utils/EmittedJavaScriptPatcher.js.map +1 -1
- package/lib/utils/FileRetriever.d.ts +29 -0
- package/lib/utils/FileRetriever.js +29 -0
- package/lib/utils/FileRetriever.js.map +1 -1
- package/lib/utils/HttpResponseContentTypeUtil.d.ts +41 -0
- package/lib/utils/HttpResponseContentTypeUtil.js +31 -0
- package/lib/utils/HttpResponseContentTypeUtil.js.map +1 -1
- package/lib/utils/MapUtil.d.ts +64 -1
- package/lib/utils/MapUtil.js +24 -3
- package/lib/utils/MapUtil.js.map +1 -1
- package/lib/utils/PathUtil.d.ts +31 -0
- package/lib/utils/PathUtil.js +38 -0
- package/lib/utils/PathUtil.js.map +1 -1
- package/lib/utils/SdkBundlePath.d.ts +2 -0
- package/lib/utils/SdkBundlePath.js +10 -0
- package/lib/utils/SdkBundlePath.js.map +1 -0
- package/lib/utils/SdkInputFilter.d.ts +31 -0
- package/lib/utils/SdkInputFilter.js +115 -0
- package/lib/utils/SdkInputFilter.js.map +1 -0
- package/lib/utils/SourceFinder.d.ts +45 -0
- package/lib/utils/SourceFinder.js +74 -16
- package/lib/utils/SourceFinder.js.map +1 -1
- package/lib/utils/StringUtil.d.ts +77 -2
- package/lib/utils/StringUtil.js +166 -4
- package/lib/utils/StringUtil.js.map +1 -1
- package/lib/utils/TemporaryDirectory.d.ts +60 -0
- package/lib/utils/TemporaryDirectory.js +112 -0
- package/lib/utils/TemporaryDirectory.js.map +1 -0
- package/lib/utils/TsConfigReader.d.ts +42 -0
- package/lib/utils/TsConfigReader.js +98 -14
- package/lib/utils/TsConfigReader.js.map +1 -1
- package/lib/utils/TtscExecutor.d.ts +23 -1
- package/lib/utils/TtscExecutor.js +22 -0
- package/lib/utils/TtscExecutor.js.map +1 -1
- package/lib/utils/VersioningStrategy.d.ts +39 -2
- package/lib/utils/VersioningStrategy.js +46 -13
- package/lib/utils/VersioningStrategy.js.map +1 -1
- package/lib/validators/TextPlainValidator.d.ts +19 -0
- package/lib/validators/TextPlainValidator.js +19 -0
- package/lib/validators/TextPlainValidator.js.map +1 -1
- package/native/go.mod +1 -1
- package/native/go.sum +2 -2
- package/native/sdk/register.go +12 -2
- package/native/sdk/sdk_http_rules.go +210 -0
- package/native/sdk/sdk_metadata_json.go +79 -4
- package/native/sdk/sdk_transform.go +1157 -414
- package/package.json +8 -6
- package/src/INestiaConfig.ts +74 -34
- package/src/NestiaSdkApplication.ts +129 -41
- package/src/NestiaSwaggerComposer.ts +32 -14
- package/src/analyses/AccessorAnalyzer.ts +26 -0
- package/src/analyses/ConfigAnalyzer.ts +52 -90
- package/src/analyses/ImportAnalyzer.ts +25 -0
- package/src/analyses/ParameterNameAnalyzer.ts +75 -0
- package/src/analyses/PathAnalyzer.ts +167 -23
- package/src/analyses/ReflectControllerAnalyzer.ts +34 -1
- package/src/analyses/ReflectHttpOperationAnalyzer.ts +36 -14
- package/src/analyses/ReflectHttpOperationExceptionAnalyzer.ts +31 -0
- package/src/analyses/ReflectHttpOperationParameterAnalyzer.ts +153 -39
- package/src/analyses/ReflectHttpOperationResponseAnalyzer.ts +38 -7
- package/src/analyses/ReflectMcpOperationAnalyzer.ts +38 -3
- package/src/analyses/ReflectMetadataAnalyzer.ts +47 -0
- package/src/analyses/ReflectWebSocketOperationAnalyzer.ts +40 -7
- package/src/analyses/SecurityAnalyzer.ts +45 -20
- package/src/analyses/SwaggerExampleAnalyzer.ts +39 -0
- package/src/analyses/TypedHttpRouteAnalyzer.ts +263 -198
- package/src/analyses/TypedMcpRouteAnalyzer.ts +180 -20
- package/src/analyses/TypedWebSocketRouteAnalyzer.ts +20 -0
- package/src/decorators/OperationMetadata.ts +6 -0
- package/src/executable/internal/CommandParser.ts +19 -0
- package/src/executable/internal/NestiaConfigLoader.ts +66 -50
- package/src/executable/internal/NestiaSdkCommand.ts +96 -3
- package/src/executable/internal/NestiaSdkWatcher.ts +172 -44
- package/src/executable/internal/NestiaSwaggerWatch.ts +359 -0
- package/src/executable/sdk.ts +24 -1
- package/src/factories/ExpressionFactory.ts +23 -2
- package/src/factories/IdentifierFactory.ts +24 -0
- package/src/factories/LiteralFactory.ts +51 -13
- package/src/factories/StatementFactory.ts +28 -1
- package/src/factories/TypeFactory.ts +24 -0
- package/src/generates/CloneGenerator.ts +26 -5
- package/src/generates/E2eGenerator.ts +19 -0
- package/src/generates/SdkGenerator.ts +43 -12
- package/src/generates/SwaggerGenerator.ts +229 -46
- package/src/generates/internal/E2eFileProgrammer.ts +20 -0
- package/src/generates/internal/FilePrinter.ts +71 -0
- package/src/generates/internal/ImportDictionary.ts +120 -2
- package/src/generates/internal/SdkAliasCollection.ts +144 -15
- package/src/generates/internal/SdkDistributionComposer.ts +181 -56
- package/src/generates/internal/SdkFileProgrammer.ts +126 -16
- package/src/generates/internal/SdkHttpCloneProgrammer.ts +55 -0
- package/src/generates/internal/SdkHttpCloneReferencer.ts +97 -23
- package/src/generates/internal/SdkHttpFunctionProgrammer.ts +47 -30
- package/src/generates/internal/SdkHttpNamespaceProgrammer.ts +53 -64
- package/src/generates/internal/SdkHttpParameterProgrammer.ts +295 -13
- package/src/generates/internal/SdkHttpRouteProgrammer.ts +37 -31
- package/src/generates/internal/SdkHttpSimulationProgrammer.ts +122 -18
- package/src/generates/internal/SdkImportWizard.ts +63 -0
- package/src/generates/internal/SdkMcpRouteProgrammer.ts +150 -33
- package/src/generates/internal/SdkPathTemplate.ts +88 -0
- package/src/generates/internal/SdkRouteDirectory.ts +10 -0
- package/src/generates/internal/SdkTypeProgrammer.ts +137 -36
- package/src/generates/internal/SdkTypeTagProgrammer.ts +536 -78
- package/src/generates/internal/SdkWebSocketCloneProgrammer.ts +185 -142
- package/src/generates/internal/SdkWebSocketNamespaceProgrammer.ts +62 -68
- package/src/generates/internal/SdkWebSocketParameterProgrammer.ts +205 -5
- package/src/generates/internal/SdkWebSocketRouteProgrammer.ts +89 -48
- package/src/generates/internal/SwaggerDescriptionComposer.ts +47 -1
- package/src/generates/internal/SwaggerOperationComposer.ts +38 -6
- package/src/generates/internal/SwaggerOperationParameterComposer.ts +318 -36
- package/src/generates/internal/SwaggerOperationResponseComposer.ts +74 -11
- package/src/internal/legacy-augmentation.d.ts +16 -0
- package/src/internal/legacy.ts +407 -49
- package/src/structures/INestiaProject.ts +10 -0
- package/src/structures/INestiaSdkInput.ts +30 -0
- package/src/structures/IOperationMetadata.ts +83 -0
- package/src/structures/IReflectController.ts +10 -0
- package/src/structures/IReflectHttpOperation.ts +10 -0
- package/src/structures/IReflectHttpOperationException.ts +17 -2
- package/src/structures/IReflectHttpOperationParameter.ts +56 -2
- package/src/structures/IReflectHttpOperationSuccess.ts +19 -3
- package/src/structures/IReflectImport.ts +10 -0
- package/src/structures/IReflectMcpOperation.ts +19 -0
- package/src/structures/IReflectMcpOperationParameter.ts +9 -0
- package/src/structures/IReflectOperationError.ts +31 -2
- package/src/structures/IReflectType.ts +9 -0
- package/src/structures/IReflectWebSocketOperation.ts +10 -0
- package/src/structures/IReflectWebSocketOperationParameter.ts +55 -0
- package/src/structures/ITypedApplication.ts +10 -0
- package/src/structures/ITypedHttpRoute.ts +18 -0
- package/src/structures/ITypedHttpRouteException.ts +14 -1
- package/src/structures/ITypedHttpRouteParameter.ts +48 -1
- package/src/structures/ITypedHttpRouteSuccess.ts +14 -1
- package/src/structures/ITypedMcpRoute.ts +12 -0
- package/src/structures/ITypedWebSocketRoute.ts +18 -0
- package/src/transform.ts +6 -0
- package/src/utils/ArrayUtil.ts +32 -13
- package/src/utils/EmittedJavaScriptPatcher.ts +70 -47
- package/src/utils/FileRetriever.ts +29 -0
- package/src/utils/HttpResponseContentTypeUtil.ts +41 -0
- package/src/utils/MapUtil.ts +68 -3
- package/src/utils/PathUtil.ts +38 -0
- package/src/utils/SdkBundlePath.ts +11 -0
- package/src/utils/SdkInputFilter.ts +108 -0
- package/src/utils/SourceFinder.ts +76 -18
- package/src/utils/StringUtil.ts +182 -5
- package/src/utils/TemporaryDirectory.ts +108 -0
- package/src/utils/TsConfigReader.ts +124 -26
- package/src/utils/TtscExecutor.ts +23 -1
- package/src/utils/VersioningStrategy.ts +51 -16
- package/src/validators/TextPlainValidator.ts +19 -0
- package/lib/generates/internal/SwaggerReadonlyArrayEmender.d.ts +0 -9
- package/lib/generates/internal/SwaggerReadonlyArrayEmender.js +0 -178
- package/lib/generates/internal/SwaggerReadonlyArrayEmender.js.map +0 -1
- package/lib/validators/HttpHeadersValidator.d.ts +0 -11
- package/lib/validators/HttpHeadersValidator.js +0 -15
- package/lib/validators/HttpHeadersValidator.js.map +0 -1
- package/lib/validators/HttpQueryValidator.d.ts +0 -10
- package/lib/validators/HttpQueryValidator.js +0 -14
- package/lib/validators/HttpQueryValidator.js.map +0 -1
- package/src/generates/internal/SwaggerReadonlyArrayEmender.ts +0 -264
- package/src/validators/HttpHeadersValidator.ts +0 -12
- package/src/validators/HttpQueryValidator.ts +0 -11
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IJsDocTagInfo } from "typia";
|
|
2
|
+
import { MetadataSchema } from "../internal/legacy";
|
|
2
3
|
import { IReflectController } from "./IReflectController";
|
|
3
4
|
import { IReflectImport } from "./IReflectImport";
|
|
4
5
|
import { IReflectMcpOperation } from "./IReflectMcpOperation";
|
|
@@ -10,6 +11,12 @@ import { IReflectType } from "./IReflectType";
|
|
|
10
11
|
* Carries everything the SDK generator needs to emit a typed client function:
|
|
11
12
|
* the controller reference, accessor path, typia-derived input schema, and
|
|
12
13
|
* input/output type info.
|
|
14
|
+
*
|
|
15
|
+
* @evidence contracts/common.md#principled-implementation The record is the tool operation in the form the SDK generator reads.
|
|
16
|
+
* @evidence contracts/common.md#clear-and-simple-design A flat record with no behavior.
|
|
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 states what the type describes; its members are named for their meaning.
|
|
19
|
+
* @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.
|
|
13
20
|
*/
|
|
14
21
|
export interface ITypedMcpRoute {
|
|
15
22
|
protocol: "mcp";
|
|
@@ -22,6 +29,10 @@ export interface ITypedMcpRoute {
|
|
|
22
29
|
function: Function;
|
|
23
30
|
input: IReflectMcpOperationParameter | null;
|
|
24
31
|
returnType: IReflectType | null;
|
|
32
|
+
/** Resolved JSON wire graphs used by structural DTO cloning. */
|
|
33
|
+
inputMetadata?: MetadataSchema;
|
|
34
|
+
/** Absent when source-only analysis was requested without cloning. */
|
|
35
|
+
outputMetadata?: MetadataSchema;
|
|
25
36
|
inputSchema: object;
|
|
26
37
|
outputSchema: object | null;
|
|
27
38
|
annotations: IReflectMcpOperation.IAnnotations | null;
|
|
@@ -3,9 +3,27 @@ import { IJsDocTagInfo } from "typia";
|
|
|
3
3
|
import { IReflectController } from "./IReflectController";
|
|
4
4
|
import { IReflectImport } from "./IReflectImport";
|
|
5
5
|
import { ITypedWebSocketRouteParameter } from "./ITypedWebSocketRouteParameter";
|
|
6
|
+
/**
|
|
7
|
+
* A typed WebSocket route: one path with its acceptor, header, path parameters,
|
|
8
|
+
* query, and driver separated.
|
|
9
|
+
*
|
|
10
|
+
* @evidence contracts/common.md#principled-implementation The reflected operation is expanded per path and its parameters are classified.
|
|
11
|
+
* @evidence contracts/common.md#clear-and-simple-design A flat record with no behavior.
|
|
12
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
|
|
13
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the type describes; its members are named for their meaning.
|
|
14
|
+
* @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.
|
|
15
|
+
*/
|
|
6
16
|
export interface ITypedWebSocketRoute {
|
|
7
17
|
protocol: "websocket";
|
|
8
18
|
controller: IReflectController;
|
|
19
|
+
/**
|
|
20
|
+
* Property key of the controller method.
|
|
21
|
+
*
|
|
22
|
+
* {@link name} is the SDK function's name, which the accessor analysis
|
|
23
|
+
* renames: a reserved word such as `delete` becomes `_delete`. Metadata the
|
|
24
|
+
* method's decorators define, and what names the method, read this key.
|
|
25
|
+
*/
|
|
26
|
+
key: string;
|
|
9
27
|
name: string;
|
|
10
28
|
path: string;
|
|
11
29
|
accessor: string[];
|
package/lib/transform.d.ts
CHANGED
|
@@ -8,5 +8,11 @@ import type { ITtscPlugin, ITtscPluginFactoryContext } from "ttsc";
|
|
|
8
8
|
* contributor — but only for projects that actually depend on `@nestia/sdk`. A
|
|
9
9
|
* project depending on `@nestia/core` alone never links, compiles, or ships any
|
|
10
10
|
* of this SDK transform code.
|
|
11
|
+
*
|
|
12
|
+
* @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.
|
|
13
|
+
* @evidence contracts/common.md#clear-and-simple-design One function returning two properties; the transform itself is native.
|
|
14
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The resolution goes through the package manifest, as the development rules require, and nothing is patched.
|
|
15
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the descriptor returns.
|
|
16
|
+
* @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.
|
|
11
17
|
*/
|
|
12
18
|
export default function createTtscPlugin(context: ITtscPluginFactoryContext): ITtscPlugin;
|
package/lib/transform.js
CHANGED
|
@@ -15,6 +15,12 @@ const node_path_1 = __importDefault(require("node:path"));
|
|
|
15
15
|
* contributor — but only for projects that actually depend on `@nestia/sdk`. A
|
|
16
16
|
* project depending on `@nestia/core` alone never links, compiles, or ships any
|
|
17
17
|
* of this SDK transform code.
|
|
18
|
+
*
|
|
19
|
+
* @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.
|
|
20
|
+
* @evidence contracts/common.md#clear-and-simple-design One function returning two properties; the transform itself is native.
|
|
21
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The resolution goes through the package manifest, as the development rules require, and nothing is patched.
|
|
22
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the descriptor returns.
|
|
23
|
+
* @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.
|
|
18
24
|
*/
|
|
19
25
|
function createTtscPlugin(context) {
|
|
20
26
|
const requireFrom = (0, node_module_1.createRequire)(node_path_1.default.join(context.projectRoot, "package.json"));
|
package/lib/transform.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../src/transform.ts"],"names":[],"mappings":";;;;;;AAAA,6CAA4C;AAC5C,0DAA6B;AAG7B
|
|
1
|
+
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../src/transform.ts"],"names":[],"mappings":";;;;;;AAAA,6CAA4C;AAC5C,0DAA6B;AAG7B;;;;;;;;;;;;;;;GAeG;AACH,0BACE,OAAkC;IAElC,MAAM,WAAW,GAAG,IAAA,2BAAa,EAC/B,mBAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,cAAc,CAAC,CAC/C,CAAC;IACF,MAAM,IAAI,GAAW,mBAAI,CAAC,OAAO,CAC/B,WAAW,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAChD,CAAC;IACF,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,MAAM,EAAE,mBAAI,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,CAAC;KAC5C,CAAC;AACJ,CAAC"}
|
package/lib/utils/ArrayUtil.d.ts
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
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 declare 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
|
function has<T>(array: T[], ...items: T[]): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Maps the elements with an asynchronous function, one after another, and
|
|
26
|
+
* returns the results in order.
|
|
27
|
+
*
|
|
28
|
+
* @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.
|
|
29
|
+
* @evidence contracts/common.md#clear-and-simple-design One loop.
|
|
30
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts No element is skipped or retried.
|
|
31
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the sequential order.
|
|
32
|
+
* @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.
|
|
33
|
+
*/
|
|
3
34
|
function asyncMap<X, Y>(array: X[], closure: (input: X) => Promise<Y>): Promise<Y[]>;
|
|
4
|
-
function asyncFilter<T>(array: T[], closure: (input: T) => Promise<boolean>): Promise<T[]>;
|
|
5
35
|
}
|
package/lib/utils/ArrayUtil.js
CHANGED
|
@@ -10,12 +10,43 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.ArrayUtil = void 0;
|
|
13
|
+
/**
|
|
14
|
+
* Array helpers of the SDK generator.
|
|
15
|
+
*
|
|
16
|
+
* @evidence contracts/common.md#principled-implementation The namespace holds a membership test and a sequential asynchronous map.
|
|
17
|
+
* @evidence contracts/common.md#clear-and-simple-design Two functions.
|
|
18
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts They are plain helpers.
|
|
19
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
20
|
+
* @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.
|
|
21
|
+
*/
|
|
13
22
|
var ArrayUtil;
|
|
14
23
|
(function (ArrayUtil) {
|
|
24
|
+
/**
|
|
25
|
+
* Reports whether the array contains every one of the items.
|
|
26
|
+
*
|
|
27
|
+
* Membership uses `includes`, so an `undefined` or `NaN` item is found when
|
|
28
|
+
* the array holds it.
|
|
29
|
+
*
|
|
30
|
+
* @evidence contracts/common.md#principled-implementation `Array.prototype.includes` compares by SameValueZero and the result is the conjunction over the items.
|
|
31
|
+
* @evidence contracts/common.md#clear-and-simple-design One `every` over `includes`.
|
|
32
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts No item is special-cased.
|
|
33
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the conjunction and the comparison.
|
|
34
|
+
* @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.
|
|
35
|
+
*/
|
|
15
36
|
function has(array, ...items) {
|
|
16
|
-
return items.every((
|
|
37
|
+
return items.every((item) => array.includes(item));
|
|
17
38
|
}
|
|
18
39
|
ArrayUtil.has = has;
|
|
40
|
+
/**
|
|
41
|
+
* Maps the elements with an asynchronous function, one after another, and
|
|
42
|
+
* returns the results in order.
|
|
43
|
+
*
|
|
44
|
+
* @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.
|
|
45
|
+
* @evidence contracts/common.md#clear-and-simple-design One loop.
|
|
46
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts No element is skipped or retried.
|
|
47
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the sequential order.
|
|
48
|
+
* @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.
|
|
49
|
+
*/
|
|
19
50
|
function asyncMap(array, closure) {
|
|
20
51
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
52
|
const ret = [];
|
|
@@ -25,15 +56,5 @@ var ArrayUtil;
|
|
|
25
56
|
});
|
|
26
57
|
}
|
|
27
58
|
ArrayUtil.asyncMap = asyncMap;
|
|
28
|
-
function asyncFilter(array, closure) {
|
|
29
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
const ret = [];
|
|
31
|
-
for (const elem of array)
|
|
32
|
-
if ((yield closure(elem)) === true)
|
|
33
|
-
ret.push(elem);
|
|
34
|
-
return ret;
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
ArrayUtil.asyncFilter = asyncFilter;
|
|
38
59
|
})(ArrayUtil || (exports.ArrayUtil = ArrayUtil = {}));
|
|
39
60
|
//# sourceMappingURL=ArrayUtil.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArrayUtil.js","sourceRoot":"","sources":["../../src/utils/ArrayUtil.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,IAAiB,SAAS,
|
|
1
|
+
{"version":3,"file":"ArrayUtil.js","sourceRoot":"","sources":["../../src/utils/ArrayUtil.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;GAQG;AACH,IAAiB,SAAS,CAmCzB;AAnCD,WAAiB,SAAS;IACxB;;;;;;;;;;;OAWG;IACH,SAAgB,GAAG,CAAI,KAAU,EAAE,GAAG,KAAU;QAC9C,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IACrD,CAAC;IAFe,UAAA,GAAG,MAElB,CAAA;IAED;;;;;;;;;OASG;IACH,SAAsB,QAAQ,CAC5B,KAAU,EACV,OAAiC;;YAEjC,MAAM,GAAG,GAAQ,EAAE,CAAC;YACpB,KAAK,MAAM,IAAI,IAAI,KAAK;gBAAE,GAAG,CAAC,IAAI,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;YACxD,OAAO,GAAG,CAAC;QACb,CAAC;KAAA;IAPqB,UAAA,QAAQ,WAO7B,CAAA;AACH,CAAC,EAnCgB,SAAS,aAAT,SAAS,GAAT,SAAS,QAmCzB"}
|
|
@@ -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,wBAA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,CAAC,MAAM,CAAC,CAAC,CAAC;IACjC,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACzB,CAAC,CAAC"}
|
|
@@ -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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+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"}
|