@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,9 +1,32 @@
|
|
|
1
|
+
import { parse } from "@babel/parser";
|
|
1
2
|
import fs from "fs";
|
|
2
3
|
import path from "path";
|
|
3
4
|
|
|
4
5
|
import { ITypedApplication } from "../../structures/ITypedApplication";
|
|
5
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Copies the declarations a WebSocket route's types come from into the
|
|
9
|
+
* `structures` directory.
|
|
10
|
+
*
|
|
11
|
+
* @evidence contracts/common.md#principled-implementation A WebSocket route refers to types by import, so the declaration and the declarations it uses are copied as text from the source files, not rebuilt from metadata.
|
|
12
|
+
* @evidence contracts/common.md#clear-and-simple-design One public function with syntax-tree helpers for declarations and imports.
|
|
13
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The TypeScript syntax parser determines declaration and import boundaries, including automatic semicolon insertion; a package file or a name declared differently in two files is never copied.
|
|
14
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
15
|
+
* @evidence contracts/portability.md#os-neutral-implementation Source candidates use Node path.resolve/join and fs.stat/readFile; outputs use recursive mkdir and UTF-8 writes. Retained relative imports are rebased with native path.relative and rendered with module separators; cross-volume absolute paths remain absolute. Supported source candidates currently include .ts/.tsx/.d.ts rather than .mts/.cts.
|
|
16
|
+
*/
|
|
6
17
|
export namespace SdkWebSocketCloneProgrammer {
|
|
18
|
+
/**
|
|
19
|
+
* Copies named project-local declarations imported by WebSocket routes, and
|
|
20
|
+
* returns the identities successfully cloned. Default and namespace imports
|
|
21
|
+
* remain source imports; a missing source or conflicting output name is not
|
|
22
|
+
* reported as cloned.
|
|
23
|
+
*
|
|
24
|
+
* @evidence contracts/common.md#principled-implementation Named imports are followed by resolved source/name identity; pending entries break recursive dependency cycles, written entries reuse completed copies, and missing or conflicting declarations return false. External, default and namespace bindings remain imports rather than reconstructed declarations.
|
|
25
|
+
* @evidence contracts/common.md#clear-and-simple-design One loop over the routes' imports.
|
|
26
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Only the imports that resolved to a source file are reported.
|
|
27
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
28
|
+
* @evidence contracts/portability.md#os-neutral-implementation Source lookup uses native fs.stat and path operations and rejects dependency paths by a node_modules component. The output uses the configured native directory; cache keys retain resolved pathname spelling rather than claiming canonical case or symlink identity.
|
|
29
|
+
*/
|
|
7
30
|
export const write = async (app: ITypedApplication): Promise<Set<string>> => {
|
|
8
31
|
const ctx: IContext = {
|
|
9
32
|
output: `${app.project.config.output}/structures`,
|
|
@@ -35,7 +58,7 @@ export namespace SdkWebSocketCloneProgrammer {
|
|
|
35
58
|
ctx.visited.set(key, "pending");
|
|
36
59
|
|
|
37
60
|
const text: string = await fs.promises.readFile(location, "utf8");
|
|
38
|
-
const declarations: string[] = getDeclarations(text, name);
|
|
61
|
+
const declarations: string[] = getDeclarations(text, name, location);
|
|
39
62
|
if (declarations.length === 0) {
|
|
40
63
|
ctx.visited.set(key, "missing");
|
|
41
64
|
return false;
|
|
@@ -77,13 +100,14 @@ export namespace SdkWebSocketCloneProgrammer {
|
|
|
77
100
|
if (imports.includes(line) === false) imports.push(line);
|
|
78
101
|
};
|
|
79
102
|
|
|
80
|
-
for (const imp of getImports(props.source)) {
|
|
103
|
+
for (const imp of getImports(props.source, props.location)) {
|
|
81
104
|
const relative: boolean = imp.specifier.startsWith(".");
|
|
105
|
+
const retained: Set<string> = new Set();
|
|
82
106
|
for (const elem of imp.elements) {
|
|
83
|
-
if (uses(props.body, elem.local) === false) continue;
|
|
107
|
+
if (uses(props.body, elem.local, props.location) === false) continue;
|
|
84
108
|
|
|
85
109
|
if (relative === false) {
|
|
86
|
-
add(
|
|
110
|
+
retained.add(elem.local);
|
|
87
111
|
continue;
|
|
88
112
|
}
|
|
89
113
|
|
|
@@ -92,7 +116,7 @@ export namespace SdkWebSocketCloneProgrammer {
|
|
|
92
116
|
imp.specifier,
|
|
93
117
|
);
|
|
94
118
|
if ((await clone(ctx)(sourceFile, elem.imported)) === false) {
|
|
95
|
-
add(
|
|
119
|
+
retained.add(elem.local);
|
|
96
120
|
continue;
|
|
97
121
|
}
|
|
98
122
|
add(
|
|
@@ -100,12 +124,22 @@ export namespace SdkWebSocketCloneProgrammer {
|
|
|
100
124
|
);
|
|
101
125
|
}
|
|
102
126
|
for (const name of [imp.default, imp.namespace])
|
|
103
|
-
if (name !== null && uses(props.body, name
|
|
127
|
+
if (name !== null && uses(props.body, name, props.location))
|
|
128
|
+
retained.add(name);
|
|
129
|
+
if (retained.size !== 0) {
|
|
130
|
+
const specifier: string = relative
|
|
131
|
+
? relativeImport(
|
|
132
|
+
ctx.output,
|
|
133
|
+
path.resolve(path.dirname(props.location), imp.specifier),
|
|
134
|
+
)
|
|
135
|
+
: imp.specifier;
|
|
136
|
+
add(retainedImport(imp, retained, specifier));
|
|
137
|
+
}
|
|
104
138
|
}
|
|
105
139
|
|
|
106
|
-
for (const name of getExportedNames(props.source)) {
|
|
140
|
+
for (const name of getExportedNames(props.source, props.location)) {
|
|
107
141
|
if (name === null || name === props.target) continue;
|
|
108
|
-
if (uses(props.body, name) === false) continue;
|
|
142
|
+
if (uses(props.body, name, props.location) === false) continue;
|
|
109
143
|
if ((await clone(ctx)(props.location, name)) === true)
|
|
110
144
|
add(`import type { ${name} } from "./${name}";`);
|
|
111
145
|
}
|
|
@@ -139,158 +173,163 @@ export namespace SdkWebSocketCloneProgrammer {
|
|
|
139
173
|
return file;
|
|
140
174
|
};
|
|
141
175
|
|
|
142
|
-
const
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
176
|
+
const syntax = (source: string, filename: string) => {
|
|
177
|
+
const options = {
|
|
178
|
+
sourceType: "module",
|
|
179
|
+
sourceFilename: filename,
|
|
180
|
+
} as const;
|
|
181
|
+
const dialect = (decorators: "decorators-legacy" | "decorators") =>
|
|
182
|
+
parse(source, {
|
|
183
|
+
...options,
|
|
184
|
+
plugins: [
|
|
185
|
+
decorators,
|
|
186
|
+
"decoratorAutoAccessors",
|
|
187
|
+
["typescript", { dts: /\.d\.[cm]?ts$/.test(filename) }],
|
|
188
|
+
...(filename.endsWith(".tsx") ? (["jsx"] as const) : []),
|
|
189
|
+
],
|
|
190
|
+
}).program;
|
|
191
|
+
// Nest parameter decorators use the legacy dialect. Standard decorators
|
|
192
|
+
// also permit placement after export; retry that strict grammar without
|
|
193
|
+
// enabling error recovery or accepting a partial syntax tree.
|
|
194
|
+
try {
|
|
195
|
+
return dialect("decorators-legacy");
|
|
196
|
+
} catch {
|
|
197
|
+
return dialect("decorators");
|
|
150
198
|
}
|
|
151
|
-
return output;
|
|
152
199
|
};
|
|
153
200
|
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
201
|
+
const exportedName = (
|
|
202
|
+
statement: ReturnType<typeof syntax>["body"][number],
|
|
203
|
+
): string | null => {
|
|
204
|
+
if (statement.type !== "ExportNamedDeclaration") return null;
|
|
205
|
+
const declaration = statement.declaration;
|
|
206
|
+
if (
|
|
207
|
+
declaration === null ||
|
|
208
|
+
declaration === undefined ||
|
|
209
|
+
!("id" in declaration)
|
|
158
210
|
)
|
|
159
|
-
|
|
160
|
-
|
|
211
|
+
return null;
|
|
212
|
+
return declaration.id?.type === "Identifier" ? declaration.id.name : null;
|
|
161
213
|
};
|
|
162
214
|
|
|
163
|
-
const
|
|
164
|
-
new RegExp(
|
|
165
|
-
`export\\s+(?:declare\\s+)?(interface|type|enum|namespace|class)\\s+(${name})\\b`,
|
|
166
|
-
"g",
|
|
167
|
-
);
|
|
168
|
-
|
|
169
|
-
const declarationEnd = (
|
|
215
|
+
const getDeclarations = (
|
|
170
216
|
source: string,
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
):
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
217
|
+
name: string,
|
|
218
|
+
filename: string,
|
|
219
|
+
): string[] =>
|
|
220
|
+
syntax(source, filename)
|
|
221
|
+
.body.filter((statement) => exportedName(statement) === name)
|
|
222
|
+
.map((statement) => source.slice(statement.start!, statement.end!));
|
|
223
|
+
|
|
224
|
+
const getExportedNames = (source: string, filename: string): string[] =>
|
|
225
|
+
syntax(source, filename)
|
|
226
|
+
.body.map(exportedName)
|
|
227
|
+
.filter((name): name is string => name !== null);
|
|
228
|
+
|
|
229
|
+
const getImports = (source: string, filename: string): IImport[] =>
|
|
230
|
+
syntax(source, filename)
|
|
231
|
+
.body.filter((statement) => statement.type === "ImportDeclaration")
|
|
232
|
+
.map((statement) => ({
|
|
233
|
+
node: statement,
|
|
234
|
+
text: source.slice(statement.start!, statement.end!),
|
|
235
|
+
specifier: statement.source.value,
|
|
236
|
+
default:
|
|
237
|
+
statement.specifiers.find(
|
|
238
|
+
(specifier) => specifier.type === "ImportDefaultSpecifier",
|
|
239
|
+
)?.local.name ?? null,
|
|
240
|
+
namespace:
|
|
241
|
+
statement.specifiers.find(
|
|
242
|
+
(specifier) => specifier.type === "ImportNamespaceSpecifier",
|
|
243
|
+
)?.local.name ?? null,
|
|
244
|
+
elements: statement.specifiers
|
|
245
|
+
.filter((specifier) => specifier.type === "ImportSpecifier")
|
|
246
|
+
.map((specifier) => ({
|
|
247
|
+
imported:
|
|
248
|
+
specifier.imported.type === "Identifier"
|
|
249
|
+
? specifier.imported.name
|
|
250
|
+
: specifier.imported.value,
|
|
251
|
+
local: specifier.local.name,
|
|
252
|
+
})),
|
|
253
|
+
}));
|
|
254
|
+
|
|
255
|
+
/** Rebuilds only retained bindings, preserving their authored type modifiers. */
|
|
256
|
+
const retainedImport = (
|
|
257
|
+
imp: IImport,
|
|
258
|
+
retained: Set<string>,
|
|
259
|
+
specifier: string,
|
|
260
|
+
): string => {
|
|
261
|
+
const clauses: string[] = [];
|
|
262
|
+
const named: string[] = [];
|
|
263
|
+
for (const binding of imp.node.specifiers) {
|
|
264
|
+
if (!retained.has(binding.local.name)) continue;
|
|
265
|
+
if (binding.type === "ImportDefaultSpecifier")
|
|
266
|
+
clauses.push(binding.local.name);
|
|
267
|
+
else if (binding.type === "ImportNamespaceSpecifier")
|
|
268
|
+
clauses.push(`* as ${binding.local.name}`);
|
|
269
|
+
else
|
|
270
|
+
named.push(
|
|
271
|
+
imp.text.slice(
|
|
272
|
+
binding.start! - imp.node.start!,
|
|
273
|
+
binding.end! - imp.node.start!,
|
|
274
|
+
),
|
|
275
|
+
);
|
|
186
276
|
}
|
|
187
|
-
|
|
277
|
+
if (named.length) clauses.push(`{ ${named.join(", ")} }`);
|
|
278
|
+
const suffix: string = imp.text.slice(
|
|
279
|
+
imp.node.source.end! - imp.node.start!,
|
|
280
|
+
);
|
|
281
|
+
return `import${imp.node.importKind === "type" ? " type" : ""} ${clauses.join(", ")} from ${JSON.stringify(specifier)}${suffix}`;
|
|
188
282
|
};
|
|
189
283
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
return depth === 0;
|
|
284
|
+
/** Module spelling from a copied declaration to its original source import. */
|
|
285
|
+
const relativeImport = (output: string, source: string): string => {
|
|
286
|
+
const native: string = path.relative(output, source);
|
|
287
|
+
const relative: string = native.split(path.sep).join("/");
|
|
288
|
+
return path.isAbsolute(native) || relative.startsWith(".")
|
|
289
|
+
? relative
|
|
290
|
+
: `./${relative}`;
|
|
198
291
|
};
|
|
199
292
|
|
|
200
|
-
const
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
if (
|
|
293
|
+
const uses = (body: string, name: string, filename: string): boolean => {
|
|
294
|
+
const visit = (value: unknown): boolean => {
|
|
295
|
+
if (value === null || typeof value !== "object") return false;
|
|
296
|
+
if (Array.isArray(value)) return value.some(visit);
|
|
297
|
+
const node = value as Record<string, unknown>;
|
|
298
|
+
if (node.type === "Identifier" && node.name === name) return true;
|
|
299
|
+
return Object.entries(node).some(
|
|
300
|
+
([key, child]) =>
|
|
301
|
+
key !== "comments" &&
|
|
302
|
+
key !== "leadingComments" &&
|
|
303
|
+
key !== "trailingComments" &&
|
|
304
|
+
key !== "innerComments" &&
|
|
305
|
+
key !== "loc" &&
|
|
306
|
+
visit(child),
|
|
307
|
+
);
|
|
204
308
|
};
|
|
205
|
-
|
|
206
|
-
let quote: string | null = null;
|
|
207
|
-
let escaped: boolean = false;
|
|
208
|
-
for (let i = 0; i < out.length; ++i) {
|
|
209
|
-
const ch: string = source[i]!;
|
|
210
|
-
const next: string | undefined = source[i + 1];
|
|
211
|
-
if (quote !== null) {
|
|
212
|
-
mask(i);
|
|
213
|
-
if (escaped) escaped = false;
|
|
214
|
-
else if (ch === "\\") escaped = true;
|
|
215
|
-
else if (ch === quote) quote = null;
|
|
216
|
-
} else if (ch === "/" && next === "/") {
|
|
217
|
-
mask(i++);
|
|
218
|
-
for (; i < out.length && source[i] !== "\n"; ++i) mask(i);
|
|
219
|
-
--i;
|
|
220
|
-
} else if (ch === "/" && next === "*") {
|
|
221
|
-
mask(i++);
|
|
222
|
-
mask(i);
|
|
223
|
-
for (++i; i < out.length; ++i) {
|
|
224
|
-
const current: string = source[i]!;
|
|
225
|
-
const following: string | undefined = source[i + 1];
|
|
226
|
-
mask(i);
|
|
227
|
-
if (current === "*" && following === "/") {
|
|
228
|
-
mask(++i);
|
|
229
|
-
break;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
} else if (ch === '"' || ch === "'" || ch === "`") {
|
|
233
|
-
quote = ch;
|
|
234
|
-
mask(i);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
return out.join("");
|
|
309
|
+
return visit(syntax(body, filename));
|
|
238
310
|
};
|
|
239
311
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
default: defaultImportName(clause),
|
|
250
|
-
namespace: namespaceImportName(clause),
|
|
251
|
-
elements: namedImportElements(clause),
|
|
252
|
-
};
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
const defaultImportName = (clause: string): string | null => {
|
|
256
|
-
const first: string = clause
|
|
257
|
-
.split(",")[0]!
|
|
258
|
-
.trim()
|
|
259
|
-
.replace(/^type\s+/, "");
|
|
260
|
-
return first.length && first.startsWith("{") === false ? first : null;
|
|
261
|
-
};
|
|
262
|
-
|
|
263
|
-
const namespaceImportName = (clause: string): string | null => {
|
|
264
|
-
const match: RegExpMatchArray | null = clause.match(/\*\s+as\s+(\w+)/);
|
|
265
|
-
return match?.[1] ?? null;
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
const namedImportElements = (clause: string): IImportElement[] => {
|
|
269
|
-
const match: RegExpMatchArray | null = clause.match(/\{([\s\S]*?)\}/);
|
|
270
|
-
if (match === null) return [];
|
|
271
|
-
return match[1]!
|
|
272
|
-
.split(",")
|
|
273
|
-
.map((part) => part.trim().replace(/^type\s+/, ""))
|
|
274
|
-
.filter((part) => part.length)
|
|
275
|
-
.map((part) => {
|
|
276
|
-
const pieces: string[] = part.split(/\s+as\s+/);
|
|
277
|
-
const imported: string = pieces[0]!.trim();
|
|
278
|
-
return {
|
|
279
|
-
imported,
|
|
280
|
-
local: (pieces[1] ?? imported).trim(),
|
|
281
|
-
};
|
|
282
|
-
});
|
|
283
|
-
};
|
|
284
|
-
|
|
285
|
-
const uses = (body: string, name: string): boolean =>
|
|
286
|
-
new RegExp(`\\b${escapeRegExp(name)}\\b`).test(body);
|
|
287
|
-
|
|
288
|
-
const escapeRegExp = (str: string): string =>
|
|
289
|
-
str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
290
|
-
|
|
312
|
+
/**
|
|
313
|
+
* Returns the key of an import: its file and name.
|
|
314
|
+
*
|
|
315
|
+
* @evidence contracts/common.md#principled-implementation The pair identifies one imported declaration.
|
|
316
|
+
* @evidence contracts/common.md#clear-and-simple-design One template.
|
|
317
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The key is the same wherever it is built.
|
|
318
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
319
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation importKey combines the supplied source identity and declaration name without opening a path or resolving filesystem identity; its caller owns source resolution.
|
|
320
|
+
*/
|
|
291
321
|
export const importKey = (file: string, name: string): string =>
|
|
292
322
|
`${file}#${name}`;
|
|
293
323
|
|
|
324
|
+
/**
|
|
325
|
+
* Reports whether a path lies under a `node_modules` directory.
|
|
326
|
+
*
|
|
327
|
+
* @evidence contracts/common.md#principled-implementation The path is resolved and split on both separators, so it holds on every platform.
|
|
328
|
+
* @evidence contracts/common.md#clear-and-simple-design One expression.
|
|
329
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts A package's declaration is never copied.
|
|
330
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
331
|
+
* @evidence contracts/portability.md#os-neutral-implementation path.resolve produces a native absolute spelling and splitting accepts both native separator forms. The literal node_modules component classifies installation layout; it does not inspect symlink targets or assert a volume's case equivalence.
|
|
332
|
+
*/
|
|
294
333
|
export const isNodeModulesPath = (file: string): boolean =>
|
|
295
334
|
path
|
|
296
335
|
.resolve(file)
|
|
@@ -307,6 +346,10 @@ interface IContext {
|
|
|
307
346
|
type CloneStatus = "pending" | "written" | "missing";
|
|
308
347
|
|
|
309
348
|
interface IImport {
|
|
349
|
+
node: Extract<
|
|
350
|
+
ReturnType<typeof parse>["program"]["body"][number],
|
|
351
|
+
{ type: "ImportDeclaration" }
|
|
352
|
+
>;
|
|
310
353
|
text: string;
|
|
311
354
|
specifier: string;
|
|
312
355
|
default: string | null;
|
|
@@ -16,9 +16,29 @@ import { ITypedWebSocketRoute } from "../../structures/ITypedWebSocketRoute";
|
|
|
16
16
|
import { FilePrinter } from "./FilePrinter";
|
|
17
17
|
import { ImportDictionary } from "./ImportDictionary";
|
|
18
18
|
import { SdkAliasCollection } from "./SdkAliasCollection";
|
|
19
|
+
import { SdkPathTemplate } from "./SdkPathTemplate";
|
|
19
20
|
import { SdkWebSocketParameterProgrammer } from "./SdkWebSocketParameterProgrammer";
|
|
20
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Writes the namespace of a WebSocket route.
|
|
24
|
+
*
|
|
25
|
+
* @evidence contracts/common.md#principled-implementation The namespace holds the route's connection types and its path builder.
|
|
26
|
+
* @evidence contracts/common.md#clear-and-simple-design One public function and two writers.
|
|
27
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The parts follow the route.
|
|
28
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
29
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkWebSocketNamespaceProgrammer composes SDK syntax, identifiers or import bindings; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
|
|
30
|
+
*/
|
|
21
31
|
export namespace SdkWebSocketNamespaceProgrammer {
|
|
32
|
+
/**
|
|
33
|
+
* Returns the namespace of a WebSocket route: its `Header`, `Query`,
|
|
34
|
+
* `Provider`, and `Listener` types and its `path`.
|
|
35
|
+
*
|
|
36
|
+
* @evidence contracts/common.md#principled-implementation Output, Header, Provider and Listener are always declared; Query requires a query parameter and Props requires keyword mode. A decorated header or driver supplies its type ahead of the acceptor's corresponding type argument.
|
|
37
|
+
* @evidence contracts/common.md#clear-and-simple-design One declaration composed of the writers.
|
|
38
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The members follow the route.
|
|
39
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
40
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkWebSocketNamespaceProgrammer.write composes SDK syntax, identifiers or import bindings; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
|
|
41
|
+
*/
|
|
22
42
|
export const write =
|
|
23
43
|
(project: INestiaProject) =>
|
|
24
44
|
(importer: ImportDictionary) =>
|
|
@@ -29,7 +49,7 @@ export namespace SdkWebSocketNamespaceProgrammer {
|
|
|
29
49
|
factory.createModuleBlock([
|
|
30
50
|
...writeTypes(project)(importer)(route),
|
|
31
51
|
FilePrinter.enter(),
|
|
32
|
-
writePath(project)(route),
|
|
52
|
+
writePath(project)(importer)(route),
|
|
33
53
|
]),
|
|
34
54
|
NodeFlags.Namespace,
|
|
35
55
|
);
|
|
@@ -50,7 +70,13 @@ export namespace SdkWebSocketNamespaceProgrammer {
|
|
|
50
70
|
);
|
|
51
71
|
|
|
52
72
|
if (project.config.keyword === true)
|
|
53
|
-
declare(
|
|
73
|
+
declare(
|
|
74
|
+
"Props",
|
|
75
|
+
SdkAliasCollection.websocketProps(
|
|
76
|
+
route,
|
|
77
|
+
SdkWebSocketParameterProgrammer.getNames({ project, route }),
|
|
78
|
+
),
|
|
79
|
+
);
|
|
54
80
|
declare(
|
|
55
81
|
"Output",
|
|
56
82
|
factory.createTypeLiteralNode([
|
|
@@ -128,6 +154,7 @@ export namespace SdkWebSocketNamespaceProgrammer {
|
|
|
128
154
|
|
|
129
155
|
const writePath =
|
|
130
156
|
(project: INestiaProject) =>
|
|
157
|
+
(importer: ImportDictionary) =>
|
|
131
158
|
(route: ITypedWebSocketRoute): Statement => {
|
|
132
159
|
const out = (body: Block | Expression) =>
|
|
133
160
|
constant("path")(
|
|
@@ -146,63 +173,30 @@ export namespace SdkWebSocketNamespaceProgrammer {
|
|
|
146
173
|
),
|
|
147
174
|
);
|
|
148
175
|
if (route.pathParameters.length === 0 && route.query === null)
|
|
149
|
-
return out(
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
factory.createIdentifier("props"),
|
|
155
|
-
key,
|
|
156
|
-
)
|
|
157
|
-
: factory.createIdentifier(key);
|
|
158
|
-
const template = () => {
|
|
159
|
-
const split: string[] = route.path.split(":");
|
|
160
|
-
if (split.length === 1) return factory.createStringLiteral(route.path);
|
|
161
|
-
return factory.createTemplateExpression(
|
|
162
|
-
factory.createTemplateHead(split[0]!),
|
|
163
|
-
split.slice(1).map((s, i, arr) => {
|
|
164
|
-
const name: string = s.split("/")[0]!;
|
|
165
|
-
return factory.createTemplateSpan(
|
|
166
|
-
factory.createCallExpression(
|
|
167
|
-
factory.createIdentifier("encodeURIComponent"),
|
|
168
|
-
undefined,
|
|
169
|
-
[
|
|
170
|
-
factory.createBinaryExpression(
|
|
171
|
-
factory.createCallChain(
|
|
172
|
-
factory.createPropertyAccessChain(
|
|
173
|
-
access(
|
|
174
|
-
route.pathParameters.find((p) => p.field === name)!
|
|
175
|
-
.name,
|
|
176
|
-
),
|
|
177
|
-
factory.createToken(SyntaxKind.QuestionDotToken),
|
|
178
|
-
"toString",
|
|
179
|
-
),
|
|
180
|
-
undefined,
|
|
181
|
-
undefined,
|
|
182
|
-
[],
|
|
183
|
-
),
|
|
184
|
-
factory.createToken(SyntaxKind.QuestionQuestionToken),
|
|
185
|
-
factory.createStringLiteral("null"),
|
|
186
|
-
),
|
|
187
|
-
],
|
|
188
|
-
),
|
|
189
|
-
(i !== arr.length - 1
|
|
190
|
-
? factory.createTemplateMiddle
|
|
191
|
-
: factory.createTemplateTail)(s.substring(name.length)),
|
|
192
|
-
);
|
|
176
|
+
return out(
|
|
177
|
+
SdkPathTemplate.compose({
|
|
178
|
+
importer,
|
|
179
|
+
path: route.path,
|
|
180
|
+
argument: () => factory.createIdentifier("undefined"),
|
|
193
181
|
}),
|
|
194
182
|
);
|
|
195
|
-
|
|
183
|
+
const names: SdkWebSocketParameterProgrammer.INames =
|
|
184
|
+
SdkWebSocketParameterProgrammer.getNames({ project, route });
|
|
185
|
+
const template = () =>
|
|
186
|
+
SdkPathTemplate.compose({
|
|
187
|
+
importer,
|
|
188
|
+
path: route.path,
|
|
189
|
+
argument: (name) =>
|
|
190
|
+
names.access(
|
|
191
|
+
names.parameter(
|
|
192
|
+
route.pathParameters.find((p) => p.field === name)!,
|
|
193
|
+
),
|
|
194
|
+
),
|
|
195
|
+
});
|
|
196
196
|
if (route.query === null) return out(template());
|
|
197
197
|
|
|
198
198
|
const block = (expr: Expression) => {
|
|
199
|
-
const
|
|
200
|
-
[...route.pathParameters, ...(route.query ? [route.query] : [])].find(
|
|
201
|
-
(p) => p.name === str,
|
|
202
|
-
) !== undefined
|
|
203
|
-
? computeName("_" + str)
|
|
204
|
-
: str;
|
|
205
|
-
const variables: string = computeName("variables");
|
|
199
|
+
const variables: string = names.variables;
|
|
206
200
|
return factory.createBlock(
|
|
207
201
|
[
|
|
208
202
|
local(variables)("URLSearchParams")(
|
|
@@ -221,13 +215,13 @@ export namespace SdkWebSocketNamespaceProgrammer {
|
|
|
221
215
|
factory.createBindingElement(
|
|
222
216
|
undefined,
|
|
223
217
|
undefined,
|
|
224
|
-
factory.createIdentifier(
|
|
218
|
+
factory.createIdentifier(names.key),
|
|
225
219
|
undefined,
|
|
226
220
|
),
|
|
227
221
|
factory.createBindingElement(
|
|
228
222
|
undefined,
|
|
229
223
|
undefined,
|
|
230
|
-
factory.createIdentifier(
|
|
224
|
+
factory.createIdentifier(names.value),
|
|
231
225
|
undefined,
|
|
232
226
|
),
|
|
233
227
|
]),
|
|
@@ -246,19 +240,19 @@ export namespace SdkWebSocketNamespaceProgrammer {
|
|
|
246
240
|
factory.createIfStatement(
|
|
247
241
|
factory.createStrictEquality(
|
|
248
242
|
factory.createIdentifier("undefined"),
|
|
249
|
-
factory.createIdentifier(
|
|
243
|
+
factory.createIdentifier(names.value),
|
|
250
244
|
),
|
|
251
245
|
factory.createContinueStatement(),
|
|
252
246
|
factory.createIfStatement(
|
|
253
247
|
factory.createCallExpression(
|
|
254
248
|
factory.createIdentifier("Array.isArray"),
|
|
255
249
|
undefined,
|
|
256
|
-
[factory.createIdentifier(
|
|
250
|
+
[factory.createIdentifier(names.value)],
|
|
257
251
|
),
|
|
258
252
|
factory.createExpressionStatement(
|
|
259
253
|
factory.createCallExpression(
|
|
260
254
|
factory.createPropertyAccessExpression(
|
|
261
|
-
factory.createIdentifier(
|
|
255
|
+
factory.createIdentifier(names.value),
|
|
262
256
|
factory.createIdentifier("forEach"),
|
|
263
257
|
),
|
|
264
258
|
undefined,
|
|
@@ -266,7 +260,7 @@ export namespace SdkWebSocketNamespaceProgrammer {
|
|
|
266
260
|
factory.createArrowFunction(
|
|
267
261
|
undefined,
|
|
268
262
|
undefined,
|
|
269
|
-
[IdentifierFactory.parameter(
|
|
263
|
+
[IdentifierFactory.parameter(names.elem)],
|
|
270
264
|
undefined,
|
|
271
265
|
undefined,
|
|
272
266
|
factory.createCallExpression(
|
|
@@ -276,11 +270,11 @@ export namespace SdkWebSocketNamespaceProgrammer {
|
|
|
276
270
|
),
|
|
277
271
|
undefined,
|
|
278
272
|
[
|
|
279
|
-
factory.createIdentifier(
|
|
273
|
+
factory.createIdentifier(names.key),
|
|
280
274
|
factory.createCallExpression(
|
|
281
275
|
factory.createIdentifier("String"),
|
|
282
276
|
undefined,
|
|
283
|
-
[factory.createIdentifier(
|
|
277
|
+
[factory.createIdentifier(names.elem)],
|
|
284
278
|
),
|
|
285
279
|
],
|
|
286
280
|
),
|
|
@@ -296,11 +290,11 @@ export namespace SdkWebSocketNamespaceProgrammer {
|
|
|
296
290
|
),
|
|
297
291
|
undefined,
|
|
298
292
|
[
|
|
299
|
-
factory.createIdentifier(
|
|
293
|
+
factory.createIdentifier(names.key),
|
|
300
294
|
factory.createCallExpression(
|
|
301
295
|
factory.createIdentifier("String"),
|
|
302
296
|
undefined,
|
|
303
|
-
[factory.createIdentifier(
|
|
297
|
+
[factory.createIdentifier(names.value)],
|
|
304
298
|
),
|
|
305
299
|
],
|
|
306
300
|
),
|
|
@@ -308,7 +302,7 @@ export namespace SdkWebSocketNamespaceProgrammer {
|
|
|
308
302
|
),
|
|
309
303
|
),
|
|
310
304
|
),
|
|
311
|
-
local(
|
|
305
|
+
local(names.location)("string")(template()),
|
|
312
306
|
factory.createReturnStatement(
|
|
313
307
|
factory.createConditionalExpression(
|
|
314
308
|
factory.createStrictEquality(
|
|
@@ -319,13 +313,13 @@ export namespace SdkWebSocketNamespaceProgrammer {
|
|
|
319
313
|
),
|
|
320
314
|
),
|
|
321
315
|
undefined,
|
|
322
|
-
factory.createIdentifier(
|
|
316
|
+
factory.createIdentifier(names.location),
|
|
323
317
|
undefined,
|
|
324
318
|
factory.createTemplateExpression(
|
|
325
319
|
factory.createTemplateHead(""),
|
|
326
320
|
[
|
|
327
321
|
factory.createTemplateSpan(
|
|
328
|
-
factory.createIdentifier(
|
|
322
|
+
factory.createIdentifier(names.location),
|
|
329
323
|
factory.createTemplateMiddle("?"),
|
|
330
324
|
),
|
|
331
325
|
factory.createTemplateSpan(
|
|
@@ -347,7 +341,7 @@ export namespace SdkWebSocketNamespaceProgrammer {
|
|
|
347
341
|
true,
|
|
348
342
|
);
|
|
349
343
|
};
|
|
350
|
-
return out(block(access(
|
|
344
|
+
return out(block(names.access(names.query)));
|
|
351
345
|
};
|
|
352
346
|
}
|
|
353
347
|
|