@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
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"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Separates authored TypeScript inputs from files owned by SDK generation.
|
|
3
|
+
*
|
|
4
|
+
* Each filter owns one output directory. Installed bundle metadata is shared;
|
|
5
|
+
* output-specific native paths are never stored in the process-wide cache.
|
|
6
|
+
*
|
|
7
|
+
* @evidence contracts/common.md#principled-implementation Source extensions are checked before generated functional descendants and exact bundled output files are excluded. Native identities and path.relative distinguish descendants from prefix-sharing siblings.
|
|
8
|
+
* @evidence contracts/common.md#clear-and-simple-design One filter factory separates source selection from controller compilation; its private helpers own bundle metadata and filesystem identity.
|
|
9
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Exclusions come from the actual installed bundle and the generated functional directory, without fixture names or a cached caller output.
|
|
10
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states filter ownership and the cache's output-independent content.
|
|
11
|
+
* @evidence contracts/portability.md#os-neutral-implementation Native real paths resolve existing ancestors and path.relative judges directory containment; neither OS names nor lowercasing assume a volume's case or link policy.
|
|
12
|
+
* efficient algorithms: Successful installed bundle entries are scanned once and each filter builds its exclusion roots once; a candidate resolves one identity and compares at most the bundle entry count plus functional root, with no recursive source scan here.
|
|
13
|
+
* reuse equivalent work: Concurrent filters share installed bundle names and kinds; a failed metadata read clears the promise so a later request can retry. Output-specific resolved roots belong to each factory call, so another output cannot reuse the first caller's paths.
|
|
14
|
+
* bound retention and release resources: The one metadata promise retains only the fixed installed bundle population. Output roots live in the returned filter closure and are released with its source-discovery call; there is no growing per-output registry.
|
|
15
|
+
*/
|
|
16
|
+
export declare namespace SdkInputFilter {
|
|
17
|
+
/**
|
|
18
|
+
* Creates the source predicate for one configuration's output, or an
|
|
19
|
+
* extension-only predicate when no SDK output is configured.
|
|
20
|
+
*
|
|
21
|
+
* @evidence contracts/common.md#principled-implementation The predicate accepts regular TypeScript source names, excludes descendants of this output's functional directory and the bundle's exact file/directory identities, and leaves same-named authored files outside that output eligible.
|
|
22
|
+
* @evidence contracts/common.md#clear-and-simple-design Output roots are prepared before discovery and captured in one returned predicate, so compilation never owns these path-selection rules.
|
|
23
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Every configuration resolves its own output; no first-call output, substring containment or operating-system case guess substitutes for filesystem identity.
|
|
24
|
+
* @evidence contracts/common.md#meaningful-documentation The comment documents both output-bound and extension-only modes.
|
|
25
|
+
* @evidence contracts/portability.md#os-neutral-implementation The nearest existing ancestor carries actual case/link identity and nonexistent suffixes retain their native spelling; path.relative rejects sibling and cross-root locations without protocol-path comparisons.
|
|
26
|
+
* efficient algorithms: Factory preparation is linear in installed bundle entries and each predicate call scans those prepared roots after one candidate identity resolution. It reuses the discovery traversal rather than walking inputs again.
|
|
27
|
+
* reuse equivalent work: Output-independent metadata comes from one shared in-flight or successful promise; rejection clears it for retry, while each output-specific root array is computed for its own factory call and is not shared across incompatible configurations.
|
|
28
|
+
* bound retention and release resources: The predicate retains only this configuration's fixed exclusion roots and no candidate history; once SourceFinder finishes, that closure has no persistent owner.
|
|
29
|
+
*/
|
|
30
|
+
const create: (output: string | undefined) => Promise<(location: string) => Promise<boolean>>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.SdkInputFilter = void 0;
|
|
16
|
+
const fs_1 = __importDefault(require("fs"));
|
|
17
|
+
const path_1 = __importDefault(require("path"));
|
|
18
|
+
const SdkBundlePath_1 = require("./SdkBundlePath");
|
|
19
|
+
const SourceFinder_1 = require("./SourceFinder");
|
|
20
|
+
/**
|
|
21
|
+
* Separates authored TypeScript inputs from files owned by SDK generation.
|
|
22
|
+
*
|
|
23
|
+
* Each filter owns one output directory. Installed bundle metadata is shared;
|
|
24
|
+
* output-specific native paths are never stored in the process-wide cache.
|
|
25
|
+
*
|
|
26
|
+
* @evidence contracts/common.md#principled-implementation Source extensions are checked before generated functional descendants and exact bundled output files are excluded. Native identities and path.relative distinguish descendants from prefix-sharing siblings.
|
|
27
|
+
* @evidence contracts/common.md#clear-and-simple-design One filter factory separates source selection from controller compilation; its private helpers own bundle metadata and filesystem identity.
|
|
28
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Exclusions come from the actual installed bundle and the generated functional directory, without fixture names or a cached caller output.
|
|
29
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states filter ownership and the cache's output-independent content.
|
|
30
|
+
* @evidence contracts/portability.md#os-neutral-implementation Native real paths resolve existing ancestors and path.relative judges directory containment; neither OS names nor lowercasing assume a volume's case or link policy.
|
|
31
|
+
* efficient algorithms: Successful installed bundle entries are scanned once and each filter builds its exclusion roots once; a candidate resolves one identity and compares at most the bundle entry count plus functional root, with no recursive source scan here.
|
|
32
|
+
* reuse equivalent work: Concurrent filters share installed bundle names and kinds; a failed metadata read clears the promise so a later request can retry. Output-specific resolved roots belong to each factory call, so another output cannot reuse the first caller's paths.
|
|
33
|
+
* bound retention and release resources: The one metadata promise retains only the fixed installed bundle population. Output roots live in the returned filter closure and are released with its source-discovery call; there is no growing per-output registry.
|
|
34
|
+
*/
|
|
35
|
+
var SdkInputFilter;
|
|
36
|
+
(function (SdkInputFilter) {
|
|
37
|
+
/**
|
|
38
|
+
* Creates the source predicate for one configuration's output, or an
|
|
39
|
+
* extension-only predicate when no SDK output is configured.
|
|
40
|
+
*
|
|
41
|
+
* @evidence contracts/common.md#principled-implementation The predicate accepts regular TypeScript source names, excludes descendants of this output's functional directory and the bundle's exact file/directory identities, and leaves same-named authored files outside that output eligible.
|
|
42
|
+
* @evidence contracts/common.md#clear-and-simple-design Output roots are prepared before discovery and captured in one returned predicate, so compilation never owns these path-selection rules.
|
|
43
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Every configuration resolves its own output; no first-call output, substring containment or operating-system case guess substitutes for filesystem identity.
|
|
44
|
+
* @evidence contracts/common.md#meaningful-documentation The comment documents both output-bound and extension-only modes.
|
|
45
|
+
* @evidence contracts/portability.md#os-neutral-implementation The nearest existing ancestor carries actual case/link identity and nonexistent suffixes retain their native spelling; path.relative rejects sibling and cross-root locations without protocol-path comparisons.
|
|
46
|
+
* efficient algorithms: Factory preparation is linear in installed bundle entries and each predicate call scans those prepared roots after one candidate identity resolution. It reuses the discovery traversal rather than walking inputs again.
|
|
47
|
+
* reuse equivalent work: Output-independent metadata comes from one shared in-flight or successful promise; rejection clears it for retry, while each output-specific root array is computed for its own factory call and is not shared across incompatible configurations.
|
|
48
|
+
* bound retention and release resources: The predicate retains only this configuration's fixed exclusion roots and no candidate history; once SourceFinder finishes, that closure has no persistent owner.
|
|
49
|
+
*/
|
|
50
|
+
SdkInputFilter.create = (output) => __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
if (output === undefined)
|
|
52
|
+
return (location) => __awaiter(this, void 0, void 0, function* () { return SourceFinder_1.SourceFinder.isTypeScriptSource(location); });
|
|
53
|
+
const excluded = [
|
|
54
|
+
{
|
|
55
|
+
location: identity(path_1.default.resolve(output, "functional")),
|
|
56
|
+
directory: true,
|
|
57
|
+
},
|
|
58
|
+
...(yield bundle()).map((asset) => ({
|
|
59
|
+
location: identity(path_1.default.resolve(output, asset.name)),
|
|
60
|
+
directory: asset.directory,
|
|
61
|
+
})),
|
|
62
|
+
];
|
|
63
|
+
return (location) => __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
if (SourceFinder_1.SourceFinder.isTypeScriptSource(location) === false)
|
|
65
|
+
return false;
|
|
66
|
+
const file = identity(location);
|
|
67
|
+
return excluded.every((entry) => entry.directory
|
|
68
|
+
? within(entry.location, file) === false
|
|
69
|
+
: entry.location !== file);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
})(SdkInputFilter || (exports.SdkInputFilter = SdkInputFilter = {}));
|
|
73
|
+
let bundlePromise;
|
|
74
|
+
const bundle = () => {
|
|
75
|
+
if (bundlePromise === undefined)
|
|
76
|
+
bundlePromise = (() => __awaiter(void 0, void 0, void 0, function* () {
|
|
77
|
+
return Promise.all((yield fs_1.default.promises.readdir(SdkBundlePath_1.SDK_BUNDLE_PATH, { withFileTypes: true })).map((entry) => __awaiter(void 0, void 0, void 0, function* () {
|
|
78
|
+
return ({
|
|
79
|
+
name: entry.name,
|
|
80
|
+
directory: entry.isSymbolicLink()
|
|
81
|
+
? (yield fs_1.default.promises.stat(path_1.default.join(SdkBundlePath_1.SDK_BUNDLE_PATH, entry.name))).isDirectory()
|
|
82
|
+
: entry.isDirectory(),
|
|
83
|
+
});
|
|
84
|
+
})));
|
|
85
|
+
}))().catch((error) => {
|
|
86
|
+
bundlePromise = undefined;
|
|
87
|
+
throw error;
|
|
88
|
+
});
|
|
89
|
+
return bundlePromise;
|
|
90
|
+
};
|
|
91
|
+
const within = (directory, location) => {
|
|
92
|
+
const relative = path_1.default.relative(directory, location);
|
|
93
|
+
return (relative === "" ||
|
|
94
|
+
(path_1.default.isAbsolute(relative) === false &&
|
|
95
|
+
relative !== ".." &&
|
|
96
|
+
relative.startsWith(`..${path_1.default.sep}`) === false));
|
|
97
|
+
};
|
|
98
|
+
const identity = (location) => {
|
|
99
|
+
const rest = [];
|
|
100
|
+
for (let current = path_1.default.resolve(location);;) {
|
|
101
|
+
try {
|
|
102
|
+
return path_1.default.join(fs_1.default.realpathSync.native(current), ...rest.reverse());
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
if (error.code !== "ENOENT")
|
|
106
|
+
throw error;
|
|
107
|
+
const parent = path_1.default.dirname(current);
|
|
108
|
+
if (parent === current)
|
|
109
|
+
throw error;
|
|
110
|
+
rest.push(path_1.default.basename(current));
|
|
111
|
+
current = parent;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
//# sourceMappingURL=SdkInputFilter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SdkInputFilter.js","sourceRoot":"","sources":["../../src/utils/SdkInputFilter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AAExB,mDAAkD;AAClD,iDAA8C;AAE9C;;;;;;;;;;;;;;GAcG;AACH,IAAiB,cAAc,CAuC9B;AAvCD,WAAiB,cAAc;IAC7B;;;;;;;;;;;;OAYG;IACU,qBAAM,GAAG,CACpB,MAA0B,EACuB,EAAE;QACnD,IAAI,MAAM,KAAK,SAAS;YACtB,OAAO,CAAO,QAAQ,EAAE,EAAE,gDAAC,OAAA,2BAAY,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAA,CAAA,CAAC,CAAD,CAAC;QACvE,MAAM,QAAQ,GAAG;YACf;gBACE,QAAQ,EAAE,QAAQ,CAAC,cAAI,CAAC,OAAO,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;gBACtD,SAAS,EAAE,IAAI;aAChB;YACD,GAAG,CAAC,MAAM,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,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,MAAM,KAAK,OAAO;gBAAE,MAAM,KAAK,CAAC;YACpC,IAAI,CAAC,IAAI,CAAC,cAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;YAClC,OAAO,GAAG,MAAM,CAAC;QACnB,CAAC;IACH,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -1,10 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finds source files by path, directory, or glob.
|
|
3
|
+
*
|
|
4
|
+
* @evidence contracts/common.md#principled-implementation Each pattern is resolved to files or directories, directories are walked, the filter is applied to files, and the excluded set is subtracted.
|
|
5
|
+
* @evidence contracts/common.md#clear-and-simple-design Three public functions and private walkers.
|
|
6
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The filter is the caller's.
|
|
7
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
8
|
+
* @evidence contracts/portability.md#os-neutral-implementation The finder turns each pattern into an absolute native path with `path.resolve` and asks the filesystem itself, through `existsSync`, `stat` and `readdir`, whether a path exists and what it is, so the volume's own case policy and links apply. Only the part of a pattern below its longest existing ancestor is globbed, rewritten from the native separator to `/` because glob reads a Windows backslash as an escape. Remaining assumptions: the case policy of wildcard matching is glob's own platform default and not a probe of the volume, and accepted files are keyed by filesystem real path while returned locations retain their discovered spelling, so include and exclude aliases identify the same file.
|
|
9
|
+
*/
|
|
1
10
|
export declare namespace SourceFinder {
|
|
2
11
|
interface IProps {
|
|
3
12
|
exclude?: string[];
|
|
4
13
|
include: string[];
|
|
5
14
|
filter: (location: string) => Promise<boolean>;
|
|
6
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Returns the files matched by the include patterns and not by the exclude
|
|
18
|
+
* patterns and accepted by the filter.
|
|
19
|
+
*
|
|
20
|
+
* @evidence contracts/common.md#principled-implementation Every pattern is expanded, existing paths remain literal, and only regular files accepted by the filter enter either collection; the exclusion runs the same collection removing instead of adding.
|
|
21
|
+
* @evidence contracts/common.md#clear-and-simple-design One function that runs the collection twice.
|
|
22
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The result follows the patterns and the filter.
|
|
23
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the result.
|
|
24
|
+
* @evidence contracts/portability.md#os-neutral-implementation It composes the include and exclude collections over native absolute paths and returns them as `path.resolve` spelled them. A directory is walked through `stat`, which follows links; each include or exclude collection keeps a real-path set, so a linked directory is entered once and a link back to an ancestor is skipped.
|
|
25
|
+
*/
|
|
7
26
|
export const find: (props: IProps) => Promise<string[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Files and directories a path or glob pattern names.
|
|
29
|
+
*
|
|
30
|
+
* An existing path is taken literally, whatever characters it holds, as a
|
|
31
|
+
* directory such as `app [v2]` would otherwise read as a character class. For
|
|
32
|
+
* a pattern, the longest existing ancestor is the literal base and only the
|
|
33
|
+
* rest is globbed, with `/` separators, since glob reads a Windows backslash
|
|
34
|
+
* as an escape.
|
|
35
|
+
*
|
|
36
|
+
* @evidence contracts/common.md#principled-implementation The wildcard part is matched below the part of the path that exists, and a base that does not exist matches nothing.
|
|
37
|
+
* @evidence contracts/common.md#clear-and-simple-design One function.
|
|
38
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It follows the filesystem.
|
|
39
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the two cases.
|
|
40
|
+
* @evidence contracts/portability.md#os-neutral-implementation An existing path is used literally, so no character glob reads specially is interpreted. Otherwise the nearest existing ancestor, found with `existsSync` and `dirname` until the filesystem root, is the glob's working directory, the remainder is rewritten from `path.sep` to `/`, and the matches are resolved against that base, so a drive letter or a UNC root never enters the pattern.
|
|
41
|
+
*/
|
|
42
|
+
export const expand: (pattern: string) => Promise<string[]>;
|
|
43
|
+
/**
|
|
44
|
+
* Reports whether a file is a TypeScript source: an extension of `ts`, `mts`,
|
|
45
|
+
* or `cts` that is not a declaration file.
|
|
46
|
+
*
|
|
47
|
+
* @evidence contracts/common.md#principled-implementation The check is on the lower-cased name, and declaration files are excluded because they hold no runtime code.
|
|
48
|
+
* @evidence contracts/common.md#clear-and-simple-design One expression.
|
|
49
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is by extension.
|
|
50
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the accepted extensions.
|
|
51
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation The function judges the spelling of a name the caller supplies and opens no path, so it owns no filesystem or process decision; extensions are compared lower-cased on every platform by design.
|
|
52
|
+
*/
|
|
8
53
|
export const isTypeScriptSource: (file: string) => boolean;
|
|
9
54
|
export {};
|
|
10
55
|
}
|
|
@@ -16,47 +16,105 @@ exports.SourceFinder = void 0;
|
|
|
16
16
|
const fs_1 = __importDefault(require("fs"));
|
|
17
17
|
const glob_1 = require("glob");
|
|
18
18
|
const path_1 = __importDefault(require("path"));
|
|
19
|
+
/**
|
|
20
|
+
* Finds source files by path, directory, or glob.
|
|
21
|
+
*
|
|
22
|
+
* @evidence contracts/common.md#principled-implementation Each pattern is resolved to files or directories, directories are walked, the filter is applied to files, and the excluded set is subtracted.
|
|
23
|
+
* @evidence contracts/common.md#clear-and-simple-design Three public functions and private walkers.
|
|
24
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The filter is the caller's.
|
|
25
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
26
|
+
* @evidence contracts/portability.md#os-neutral-implementation The finder turns each pattern into an absolute native path with `path.resolve` and asks the filesystem itself, through `existsSync`, `stat` and `readdir`, whether a path exists and what it is, so the volume's own case policy and links apply. Only the part of a pattern below its longest existing ancestor is globbed, rewritten from the native separator to `/` because glob reads a Windows backslash as an escape. Remaining assumptions: the case policy of wildcard matching is glob's own platform default and not a probe of the volume, and accepted files are keyed by filesystem real path while returned locations retain their discovered spelling, so include and exclude aliases identify the same file.
|
|
27
|
+
*/
|
|
19
28
|
var SourceFinder;
|
|
20
29
|
(function (SourceFinder) {
|
|
30
|
+
/**
|
|
31
|
+
* Returns the files matched by the include patterns and not by the exclude
|
|
32
|
+
* patterns and accepted by the filter.
|
|
33
|
+
*
|
|
34
|
+
* @evidence contracts/common.md#principled-implementation Every pattern is expanded, existing paths remain literal, and only regular files accepted by the filter enter either collection; the exclusion runs the same collection removing instead of adding.
|
|
35
|
+
* @evidence contracts/common.md#clear-and-simple-design One function that runs the collection twice.
|
|
36
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The result follows the patterns and the filter.
|
|
37
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the result.
|
|
38
|
+
* @evidence contracts/portability.md#os-neutral-implementation It composes the include and exclude collections over native absolute paths and returns them as `path.resolve` spelled them. A directory is walked through `stat`, which follows links; each include or exclude collection keeps a real-path set, so a linked directory is entered once and a link back to an ancestor is skipped.
|
|
39
|
+
*/
|
|
21
40
|
SourceFinder.find = (props) => __awaiter(this, void 0, void 0, function* () {
|
|
22
41
|
var _a;
|
|
23
|
-
const dict = new
|
|
24
|
-
yield emplace(props.filter)(props.include)((str) => dict.
|
|
42
|
+
const dict = new Map();
|
|
43
|
+
yield emplace(props.filter)(props.include)((str) => dict.set(fs_1.default.realpathSync.native(str), str));
|
|
25
44
|
if ((_a = props.exclude) === null || _a === void 0 ? void 0 : _a.length)
|
|
26
|
-
yield emplace(props.filter)(props.exclude)((str) => dict.delete(str));
|
|
27
|
-
return [...dict];
|
|
45
|
+
yield emplace(props.filter)(props.exclude)((str) => dict.delete(fs_1.default.realpathSync.native(str)));
|
|
46
|
+
return [...dict.values()];
|
|
28
47
|
});
|
|
29
48
|
const emplace = (filter) => (input) => (closure) => __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
const visited = new Set();
|
|
30
50
|
for (const pattern of input) {
|
|
31
|
-
|
|
32
|
-
closure(path_1.default.resolve(pattern));
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
for (const file of yield _Glob(pattern)) {
|
|
51
|
+
for (const file of yield SourceFinder.expand(pattern)) {
|
|
36
52
|
const stats = yield fs_1.default.promises.stat(file);
|
|
37
53
|
if (stats.isDirectory() === true)
|
|
38
|
-
yield iterate(filter)(closure)(file);
|
|
54
|
+
yield iterate(filter)(closure)(file, visited);
|
|
39
55
|
else if (stats.isFile() && (yield filter(file)))
|
|
40
56
|
closure(file);
|
|
41
57
|
}
|
|
42
58
|
}
|
|
43
59
|
});
|
|
44
|
-
const iterate = (filter) => (closure) => (location) => __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
const iterate = (filter) => (closure) => (location, visited) => __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
const identity = yield fs_1.default.promises.realpath(location);
|
|
62
|
+
if (visited.has(identity))
|
|
63
|
+
return;
|
|
64
|
+
visited.add(identity);
|
|
45
65
|
const directory = yield fs_1.default.promises.readdir(location);
|
|
46
66
|
for (const file of directory) {
|
|
47
67
|
const next = path_1.default.resolve(`${location}/${file}`);
|
|
48
68
|
const stats = yield fs_1.default.promises.stat(next);
|
|
49
69
|
if (stats.isDirectory() === true)
|
|
50
|
-
yield iterate(filter)(closure)(next);
|
|
70
|
+
yield iterate(filter)(closure)(next, visited);
|
|
51
71
|
else if (stats.isFile() && (yield filter(next)))
|
|
52
72
|
closure(next);
|
|
53
73
|
}
|
|
54
74
|
});
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
75
|
+
/**
|
|
76
|
+
* Files and directories a path or glob pattern names.
|
|
77
|
+
*
|
|
78
|
+
* An existing path is taken literally, whatever characters it holds, as a
|
|
79
|
+
* directory such as `app [v2]` would otherwise read as a character class. For
|
|
80
|
+
* a pattern, the longest existing ancestor is the literal base and only the
|
|
81
|
+
* rest is globbed, with `/` separators, since glob reads a Windows backslash
|
|
82
|
+
* as an escape.
|
|
83
|
+
*
|
|
84
|
+
* @evidence contracts/common.md#principled-implementation The wildcard part is matched below the part of the path that exists, and a base that does not exist matches nothing.
|
|
85
|
+
* @evidence contracts/common.md#clear-and-simple-design One function.
|
|
86
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It follows the filesystem.
|
|
87
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the two cases.
|
|
88
|
+
* @evidence contracts/portability.md#os-neutral-implementation An existing path is used literally, so no character glob reads specially is interpreted. Otherwise the nearest existing ancestor, found with `existsSync` and `dirname` until the filesystem root, is the glob's working directory, the remainder is rewritten from `path.sep` to `/`, and the matches are resolved against that base, so a drive letter or a UNC root never enters the pattern.
|
|
89
|
+
*/
|
|
90
|
+
SourceFinder.expand = (pattern) => __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
const absolute = path_1.default.resolve(pattern);
|
|
92
|
+
if (fs_1.default.existsSync(absolute))
|
|
93
|
+
return [absolute];
|
|
94
|
+
let base = absolute;
|
|
95
|
+
while (fs_1.default.existsSync(base) === false) {
|
|
96
|
+
const parent = path_1.default.dirname(base);
|
|
97
|
+
if (parent === base)
|
|
98
|
+
return [];
|
|
99
|
+
base = parent;
|
|
100
|
+
}
|
|
101
|
+
const rest = path_1.default
|
|
102
|
+
.relative(base, absolute)
|
|
103
|
+
.split(path_1.default.sep)
|
|
104
|
+
.join("/");
|
|
105
|
+
const matches = yield (0, glob_1.glob)(rest, { cwd: base });
|
|
106
|
+
return matches.map((str) => path_1.default.resolve(base, str));
|
|
58
107
|
});
|
|
59
|
-
|
|
108
|
+
/**
|
|
109
|
+
* Reports whether a file is a TypeScript source: an extension of `ts`, `mts`,
|
|
110
|
+
* or `cts` that is not a declaration file.
|
|
111
|
+
*
|
|
112
|
+
* @evidence contracts/common.md#principled-implementation The check is on the lower-cased name, and declaration files are excluded because they hold no runtime code.
|
|
113
|
+
* @evidence contracts/common.md#clear-and-simple-design One expression.
|
|
114
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is by extension.
|
|
115
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the accepted extensions.
|
|
116
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation The function judges the spelling of a name the caller supplies and opens no path, so it owns no filesystem or process decision; extensions are compared lower-cased on every platform by design.
|
|
117
|
+
*/
|
|
60
118
|
SourceFinder.isTypeScriptSource = (file) => {
|
|
61
119
|
const lower = file.toLowerCase();
|
|
62
120
|
return (/\.(?:[cm]?ts)$/.test(lower) &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SourceFinder.js","sourceRoot":"","sources":["../../src/utils/SourceFinder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4CAAoB;AACpB,+BAA4B;AAC5B,gDAAwB;AAExB,IAAiB,YAAY,
|
|
1
|
+
{"version":3,"file":"SourceFinder.js","sourceRoot":"","sources":["../../src/utils/SourceFinder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4CAAoB;AACpB,+BAA4B;AAC5B,gDAAwB;AAExB;;;;;;;;GAQG;AACH,IAAiB,YAAY,CAiH5B;AAjHD,WAAiB,YAAY;IAO3B;;;;;;;;;OASG;IACU,iBAAI,GAAG,CAAO,KAAa,EAAqB,EAAE;;QAC7D,MAAM,IAAI,GAAwB,IAAI,GAAG,EAAE,CAAC;QAE5C,MAAM,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,CACjD,IAAI,CAAC,GAAG,CAAC,YAAE,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAC3C,CAAC;QACF,IAAI,MAAA,KAAK,CAAC,OAAO,0CAAE,MAAM;YACvB,MAAM,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,CACjD,IAAI,CAAC,MAAM,CAAC,YAAE,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CACzC,CAAC;QAEJ,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAC5B,CAAC,CAAA,CAAC;IAEF,MAAM,OAAO,GACX,CAAC,MAA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