@nestia/sdk 14.0.0 → 14.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/assets/bundle/distribute/build-sdk.cjs +28 -0
- package/assets/bundle/distribute/package.json +7 -3
- package/assets/bundle/distribute/tsconfig.json +15 -105
- package/lib/INestiaConfig.d.ts +74 -34
- package/lib/NestiaSdkApplication.d.ts +60 -0
- package/lib/NestiaSdkApplication.js +121 -32
- package/lib/NestiaSdkApplication.js.map +1 -1
- package/lib/NestiaSwaggerComposer.d.ts +21 -0
- package/lib/NestiaSwaggerComposer.js +32 -13
- package/lib/NestiaSwaggerComposer.js.map +1 -1
- package/lib/analyses/AccessorAnalyzer.d.ts +26 -0
- package/lib/analyses/AccessorAnalyzer.js +26 -0
- package/lib/analyses/AccessorAnalyzer.js.map +1 -1
- package/lib/analyses/ConfigAnalyzer.d.ts +41 -0
- package/lib/analyses/ConfigAnalyzer.js +52 -77
- package/lib/analyses/ConfigAnalyzer.js.map +1 -1
- package/lib/analyses/ImportAnalyzer.d.ts +25 -0
- package/lib/analyses/ImportAnalyzer.js +25 -0
- package/lib/analyses/ImportAnalyzer.js.map +1 -1
- package/lib/analyses/ParameterNameAnalyzer.d.ts +44 -0
- package/lib/analyses/ParameterNameAnalyzer.js +63 -0
- package/lib/analyses/ParameterNameAnalyzer.js.map +1 -0
- package/lib/analyses/PathAnalyzer.d.ts +93 -1
- package/lib/analyses/PathAnalyzer.js +160 -23
- package/lib/analyses/PathAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectControllerAnalyzer.d.ts +32 -0
- package/lib/analyses/ReflectControllerAnalyzer.js +24 -1
- package/lib/analyses/ReflectControllerAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationAnalyzer.d.ts +29 -0
- package/lib/analyses/ReflectHttpOperationAnalyzer.js +35 -24
- package/lib/analyses/ReflectHttpOperationAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationExceptionAnalyzer.d.ts +31 -0
- package/lib/analyses/ReflectHttpOperationExceptionAnalyzer.js +21 -0
- package/lib/analyses/ReflectHttpOperationExceptionAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationParameterAnalyzer.d.ts +31 -0
- package/lib/analyses/ReflectHttpOperationParameterAnalyzer.js +143 -23
- package/lib/analyses/ReflectHttpOperationParameterAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.d.ts +32 -0
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.js +27 -2
- package/lib/analyses/ReflectHttpOperationResponseAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectMcpOperationAnalyzer.d.ts +29 -0
- package/lib/analyses/ReflectMcpOperationAnalyzer.js +35 -11
- package/lib/analyses/ReflectMcpOperationAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectMetadataAnalyzer.d.ts +47 -0
- package/lib/analyses/ReflectMetadataAnalyzer.js +47 -0
- package/lib/analyses/ReflectMetadataAnalyzer.js.map +1 -1
- package/lib/analyses/ReflectWebSocketOperationAnalyzer.d.ts +29 -0
- package/lib/analyses/ReflectWebSocketOperationAnalyzer.js +27 -5
- package/lib/analyses/ReflectWebSocketOperationAnalyzer.js.map +1 -1
- package/lib/analyses/SecurityAnalyzer.d.ts +25 -0
- package/lib/analyses/SecurityAnalyzer.js +39 -19
- package/lib/analyses/SecurityAnalyzer.js.map +1 -1
- package/lib/analyses/SwaggerExampleAnalyzer.d.ts +31 -0
- package/lib/analyses/SwaggerExampleAnalyzer.js +36 -0
- package/lib/analyses/SwaggerExampleAnalyzer.js.map +1 -0
- package/lib/analyses/TypedHttpRouteAnalyzer.d.ts +41 -3
- package/lib/analyses/TypedHttpRouteAnalyzer.js +196 -172
- package/lib/analyses/TypedHttpRouteAnalyzer.js.map +1 -1
- package/lib/analyses/TypedMcpRouteAnalyzer.d.ts +29 -0
- package/lib/analyses/TypedMcpRouteAnalyzer.js +152 -20
- package/lib/analyses/TypedMcpRouteAnalyzer.js.map +1 -1
- package/lib/analyses/TypedWebSocketRouteAnalyzer.d.ts +19 -0
- package/lib/analyses/TypedWebSocketRouteAnalyzer.js +20 -1
- package/lib/analyses/TypedWebSocketRouteAnalyzer.js.map +1 -1
- package/lib/decorators/OperationMetadata.d.ts +6 -0
- package/lib/decorators/OperationMetadata.js +6 -0
- package/lib/decorators/OperationMetadata.js.map +1 -1
- package/lib/executable/internal/CommandParser.d.ts +19 -0
- package/lib/executable/internal/CommandParser.js +19 -0
- package/lib/executable/internal/CommandParser.js.map +1 -1
- package/lib/executable/internal/NestiaConfigLoader.d.ts +56 -0
- package/lib/executable/internal/NestiaConfigLoader.js +48 -42
- package/lib/executable/internal/NestiaConfigLoader.js.map +1 -1
- package/lib/executable/internal/NestiaSdkCommand.d.ts +60 -0
- package/lib/executable/internal/NestiaSdkCommand.js +95 -3
- package/lib/executable/internal/NestiaSdkCommand.js.map +1 -1
- package/lib/executable/internal/NestiaSdkWatcher.d.ts +81 -0
- package/lib/executable/internal/NestiaSdkWatcher.js +125 -41
- package/lib/executable/internal/NestiaSdkWatcher.js.map +1 -1
- package/lib/executable/internal/NestiaSwaggerWatch.d.ts +80 -0
- package/lib/executable/internal/NestiaSwaggerWatch.js +308 -0
- package/lib/executable/internal/NestiaSwaggerWatch.js.map +1 -0
- package/lib/executable/sdk.js +16 -1
- package/lib/executable/sdk.js.map +1 -1
- package/lib/factories/ExpressionFactory.d.ts +18 -0
- package/lib/factories/ExpressionFactory.js +21 -2
- package/lib/factories/ExpressionFactory.js.map +1 -1
- package/lib/factories/IdentifierFactory.d.ts +24 -0
- package/lib/factories/IdentifierFactory.js +24 -0
- package/lib/factories/IdentifierFactory.js.map +1 -1
- package/lib/factories/LiteralFactory.d.ts +22 -4
- package/lib/factories/LiteralFactory.js +33 -11
- package/lib/factories/LiteralFactory.js.map +1 -1
- package/lib/factories/StatementFactory.d.ts +28 -1
- package/lib/factories/StatementFactory.js +28 -1
- package/lib/factories/StatementFactory.js.map +1 -1
- package/lib/factories/TypeFactory.d.ts +24 -0
- package/lib/factories/TypeFactory.js +15 -0
- package/lib/factories/TypeFactory.js.map +1 -1
- package/lib/generates/CloneGenerator.d.ts +22 -0
- package/lib/generates/CloneGenerator.js +26 -5
- package/lib/generates/CloneGenerator.js.map +1 -1
- package/lib/generates/E2eGenerator.d.ts +19 -0
- package/lib/generates/E2eGenerator.js +19 -0
- package/lib/generates/E2eGenerator.js.map +1 -1
- package/lib/generates/SdkGenerator.d.ts +38 -0
- package/lib/generates/SdkGenerator.js +43 -5
- package/lib/generates/SdkGenerator.js.map +1 -1
- package/lib/generates/SwaggerGenerator.d.ts +36 -6
- package/lib/generates/SwaggerGenerator.js +190 -40
- package/lib/generates/SwaggerGenerator.js.map +1 -1
- package/lib/generates/internal/E2eFileProgrammer.d.ts +19 -0
- package/lib/generates/internal/E2eFileProgrammer.js +20 -1
- package/lib/generates/internal/E2eFileProgrammer.js.map +1 -1
- package/lib/generates/internal/FilePrinter.d.ts +57 -0
- package/lib/generates/internal/FilePrinter.js +74 -0
- package/lib/generates/internal/FilePrinter.js.map +1 -1
- package/lib/generates/internal/ImportDictionary.d.ts +93 -1
- package/lib/generates/internal/ImportDictionary.js +103 -2
- package/lib/generates/internal/ImportDictionary.js.map +1 -1
- package/lib/generates/internal/SdkAliasCollection.d.ts +121 -1
- package/lib/generates/internal/SdkAliasCollection.js +132 -11
- package/lib/generates/internal/SdkAliasCollection.js.map +1 -1
- package/lib/generates/internal/SdkDistributionComposer.d.ts +19 -0
- package/lib/generates/internal/SdkDistributionComposer.js +149 -52
- package/lib/generates/internal/SdkDistributionComposer.js.map +1 -1
- package/lib/generates/internal/SdkFileProgrammer.d.ts +18 -0
- package/lib/generates/internal/SdkFileProgrammer.js +101 -12
- package/lib/generates/internal/SdkFileProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpCloneProgrammer.d.ts +29 -0
- package/lib/generates/internal/SdkHttpCloneProgrammer.js +33 -0
- package/lib/generates/internal/SdkHttpCloneProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpCloneReferencer.d.ts +19 -0
- package/lib/generates/internal/SdkHttpCloneReferencer.js +78 -25
- package/lib/generates/internal/SdkHttpCloneReferencer.js.map +1 -1
- package/lib/generates/internal/SdkHttpFunctionProgrammer.d.ts +19 -0
- package/lib/generates/internal/SdkHttpFunctionProgrammer.js +40 -23
- package/lib/generates/internal/SdkHttpFunctionProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.d.ts +19 -0
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.js +46 -34
- package/lib/generates/internal/SdkHttpNamespaceProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpParameterProgrammer.d.ts +142 -1
- package/lib/generates/internal/SdkHttpParameterProgrammer.js +175 -6
- package/lib/generates/internal/SdkHttpParameterProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpRouteProgrammer.d.ts +20 -0
- package/lib/generates/internal/SdkHttpRouteProgrammer.js +36 -32
- package/lib/generates/internal/SdkHttpRouteProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkHttpSimulationProgrammer.d.ts +38 -0
- package/lib/generates/internal/SdkHttpSimulationProgrammer.js +66 -18
- package/lib/generates/internal/SdkHttpSimulationProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkImportWizard.d.ts +63 -0
- package/lib/generates/internal/SdkImportWizard.js +63 -0
- package/lib/generates/internal/SdkImportWizard.js.map +1 -1
- package/lib/generates/internal/SdkMcpRouteProgrammer.d.ts +17 -2
- package/lib/generates/internal/SdkMcpRouteProgrammer.js +72 -24
- package/lib/generates/internal/SdkMcpRouteProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkPathTemplate.d.ts +36 -0
- package/lib/generates/internal/SdkPathTemplate.js +65 -0
- package/lib/generates/internal/SdkPathTemplate.js.map +1 -0
- package/lib/generates/internal/SdkRouteDirectory.d.ts +10 -0
- package/lib/generates/internal/SdkRouteDirectory.js +10 -0
- package/lib/generates/internal/SdkRouteDirectory.js.map +1 -1
- package/lib/generates/internal/SdkTypeProgrammer.d.ts +54 -1
- package/lib/generates/internal/SdkTypeProgrammer.js +111 -27
- package/lib/generates/internal/SdkTypeProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkTypeTagProgrammer.d.ts +53 -1
- package/lib/generates/internal/SdkTypeTagProgrammer.js +407 -67
- package/lib/generates/internal/SdkTypeTagProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketCloneProgrammer.d.ts +40 -0
- package/lib/generates/internal/SdkWebSocketCloneProgrammer.js +149 -142
- package/lib/generates/internal/SdkWebSocketCloneProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.d.ts +19 -0
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js +46 -36
- package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketParameterProgrammer.d.ts +114 -1
- package/lib/generates/internal/SdkWebSocketParameterProgrammer.js +120 -5
- package/lib/generates/internal/SdkWebSocketParameterProgrammer.js.map +1 -1
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.d.ts +18 -0
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.js +75 -33
- package/lib/generates/internal/SdkWebSocketRouteProgrammer.js.map +1 -1
- package/lib/generates/internal/SwaggerDescriptionComposer.d.ts +42 -0
- package/lib/generates/internal/SwaggerDescriptionComposer.js +44 -1
- package/lib/generates/internal/SwaggerDescriptionComposer.js.map +1 -1
- package/lib/generates/internal/SwaggerOperationComposer.d.ts +18 -0
- package/lib/generates/internal/SwaggerOperationComposer.js +37 -8
- package/lib/generates/internal/SwaggerOperationComposer.js.map +1 -1
- package/lib/generates/internal/SwaggerOperationParameterComposer.d.ts +40 -1
- package/lib/generates/internal/SwaggerOperationParameterComposer.js +230 -25
- package/lib/generates/internal/SwaggerOperationParameterComposer.js.map +1 -1
- package/lib/generates/internal/SwaggerOperationResponseComposer.d.ts +21 -0
- package/lib/generates/internal/SwaggerOperationResponseComposer.js +58 -7
- package/lib/generates/internal/SwaggerOperationResponseComposer.js.map +1 -1
- package/lib/internal/legacy.d.ts +342 -31
- package/lib/internal/legacy.js +207 -31
- package/lib/internal/legacy.js.map +1 -1
- package/lib/structures/INestiaProject.d.ts +10 -0
- package/lib/structures/INestiaSdkInput.d.ts +30 -0
- package/lib/structures/IOperationMetadata.d.ts +77 -0
- package/lib/structures/IReflectController.d.ts +10 -0
- package/lib/structures/IReflectHttpOperation.d.ts +10 -0
- package/lib/structures/IReflectHttpOperationException.d.ts +13 -2
- package/lib/structures/IReflectHttpOperationParameter.d.ts +55 -3
- package/lib/structures/IReflectHttpOperationSuccess.d.ts +15 -3
- package/lib/structures/IReflectImport.d.ts +10 -0
- package/lib/structures/IReflectMcpOperation.d.ts +19 -0
- package/lib/structures/IReflectMcpOperationParameter.d.ts +9 -0
- package/lib/structures/IReflectOperationError.d.ts +28 -0
- package/lib/structures/IReflectOperationError.js +22 -2
- package/lib/structures/IReflectOperationError.js.map +1 -1
- package/lib/structures/IReflectType.d.ts +9 -0
- package/lib/structures/IReflectWebSocketOperation.d.ts +10 -0
- package/lib/structures/IReflectWebSocketOperationParameter.d.ts +55 -0
- package/lib/structures/ITypedApplication.d.ts +10 -0
- package/lib/structures/ITypedHttpRoute.d.ts +18 -0
- package/lib/structures/ITypedHttpRouteException.d.ts +13 -1
- package/lib/structures/ITypedHttpRouteParameter.d.ts +48 -1
- package/lib/structures/ITypedHttpRouteSuccess.d.ts +13 -1
- package/lib/structures/ITypedMcpRoute.d.ts +11 -0
- package/lib/structures/ITypedWebSocketRoute.d.ts +18 -0
- package/lib/transform.d.ts +6 -0
- package/lib/transform.js +6 -0
- package/lib/transform.js.map +1 -1
- package/lib/utils/ArrayUtil.d.ts +31 -1
- package/lib/utils/ArrayUtil.js +32 -11
- package/lib/utils/ArrayUtil.js.map +1 -1
- package/lib/utils/EmittedJavaScriptPatcher.d.ts +20 -0
- package/lib/utils/EmittedJavaScriptPatcher.js +65 -46
- package/lib/utils/EmittedJavaScriptPatcher.js.map +1 -1
- package/lib/utils/FileRetriever.d.ts +29 -0
- package/lib/utils/FileRetriever.js +29 -0
- package/lib/utils/FileRetriever.js.map +1 -1
- package/lib/utils/HttpResponseContentTypeUtil.d.ts +41 -0
- package/lib/utils/HttpResponseContentTypeUtil.js +31 -0
- package/lib/utils/HttpResponseContentTypeUtil.js.map +1 -1
- package/lib/utils/MapUtil.d.ts +64 -1
- package/lib/utils/MapUtil.js +24 -3
- package/lib/utils/MapUtil.js.map +1 -1
- package/lib/utils/PathUtil.d.ts +31 -0
- package/lib/utils/PathUtil.js +38 -0
- package/lib/utils/PathUtil.js.map +1 -1
- package/lib/utils/SdkBundlePath.d.ts +2 -0
- package/lib/utils/SdkBundlePath.js +10 -0
- package/lib/utils/SdkBundlePath.js.map +1 -0
- package/lib/utils/SdkInputFilter.d.ts +31 -0
- package/lib/utils/SdkInputFilter.js +115 -0
- package/lib/utils/SdkInputFilter.js.map +1 -0
- package/lib/utils/SourceFinder.d.ts +45 -0
- package/lib/utils/SourceFinder.js +74 -16
- package/lib/utils/SourceFinder.js.map +1 -1
- package/lib/utils/StringUtil.d.ts +77 -2
- package/lib/utils/StringUtil.js +166 -4
- package/lib/utils/StringUtil.js.map +1 -1
- package/lib/utils/TemporaryDirectory.d.ts +60 -0
- package/lib/utils/TemporaryDirectory.js +112 -0
- package/lib/utils/TemporaryDirectory.js.map +1 -0
- package/lib/utils/TsConfigReader.d.ts +42 -0
- package/lib/utils/TsConfigReader.js +98 -14
- package/lib/utils/TsConfigReader.js.map +1 -1
- package/lib/utils/TtscExecutor.d.ts +23 -1
- package/lib/utils/TtscExecutor.js +22 -0
- package/lib/utils/TtscExecutor.js.map +1 -1
- package/lib/utils/VersioningStrategy.d.ts +39 -2
- package/lib/utils/VersioningStrategy.js +46 -13
- package/lib/utils/VersioningStrategy.js.map +1 -1
- package/lib/validators/TextPlainValidator.d.ts +19 -0
- package/lib/validators/TextPlainValidator.js +19 -0
- package/lib/validators/TextPlainValidator.js.map +1 -1
- package/native/go.mod +1 -1
- package/native/go.sum +2 -2
- package/native/sdk/register.go +12 -2
- package/native/sdk/sdk_http_rules.go +210 -0
- package/native/sdk/sdk_metadata_json.go +79 -4
- package/native/sdk/sdk_transform.go +1157 -414
- package/package.json +8 -6
- package/src/INestiaConfig.ts +74 -34
- package/src/NestiaSdkApplication.ts +129 -41
- package/src/NestiaSwaggerComposer.ts +32 -14
- package/src/analyses/AccessorAnalyzer.ts +26 -0
- package/src/analyses/ConfigAnalyzer.ts +52 -90
- package/src/analyses/ImportAnalyzer.ts +25 -0
- package/src/analyses/ParameterNameAnalyzer.ts +75 -0
- package/src/analyses/PathAnalyzer.ts +167 -23
- package/src/analyses/ReflectControllerAnalyzer.ts +34 -1
- package/src/analyses/ReflectHttpOperationAnalyzer.ts +36 -14
- package/src/analyses/ReflectHttpOperationExceptionAnalyzer.ts +31 -0
- package/src/analyses/ReflectHttpOperationParameterAnalyzer.ts +153 -39
- package/src/analyses/ReflectHttpOperationResponseAnalyzer.ts +38 -7
- package/src/analyses/ReflectMcpOperationAnalyzer.ts +38 -3
- package/src/analyses/ReflectMetadataAnalyzer.ts +47 -0
- package/src/analyses/ReflectWebSocketOperationAnalyzer.ts +40 -7
- package/src/analyses/SecurityAnalyzer.ts +45 -20
- package/src/analyses/SwaggerExampleAnalyzer.ts +39 -0
- package/src/analyses/TypedHttpRouteAnalyzer.ts +263 -198
- package/src/analyses/TypedMcpRouteAnalyzer.ts +180 -20
- package/src/analyses/TypedWebSocketRouteAnalyzer.ts +20 -0
- package/src/decorators/OperationMetadata.ts +6 -0
- package/src/executable/internal/CommandParser.ts +19 -0
- package/src/executable/internal/NestiaConfigLoader.ts +66 -50
- package/src/executable/internal/NestiaSdkCommand.ts +96 -3
- package/src/executable/internal/NestiaSdkWatcher.ts +172 -44
- package/src/executable/internal/NestiaSwaggerWatch.ts +359 -0
- package/src/executable/sdk.ts +24 -1
- package/src/factories/ExpressionFactory.ts +23 -2
- package/src/factories/IdentifierFactory.ts +24 -0
- package/src/factories/LiteralFactory.ts +51 -13
- package/src/factories/StatementFactory.ts +28 -1
- package/src/factories/TypeFactory.ts +24 -0
- package/src/generates/CloneGenerator.ts +26 -5
- package/src/generates/E2eGenerator.ts +19 -0
- package/src/generates/SdkGenerator.ts +43 -12
- package/src/generates/SwaggerGenerator.ts +229 -46
- package/src/generates/internal/E2eFileProgrammer.ts +20 -0
- package/src/generates/internal/FilePrinter.ts +71 -0
- package/src/generates/internal/ImportDictionary.ts +120 -2
- package/src/generates/internal/SdkAliasCollection.ts +144 -15
- package/src/generates/internal/SdkDistributionComposer.ts +181 -56
- package/src/generates/internal/SdkFileProgrammer.ts +126 -16
- package/src/generates/internal/SdkHttpCloneProgrammer.ts +55 -0
- package/src/generates/internal/SdkHttpCloneReferencer.ts +97 -23
- package/src/generates/internal/SdkHttpFunctionProgrammer.ts +47 -30
- package/src/generates/internal/SdkHttpNamespaceProgrammer.ts +53 -64
- package/src/generates/internal/SdkHttpParameterProgrammer.ts +295 -13
- package/src/generates/internal/SdkHttpRouteProgrammer.ts +37 -31
- package/src/generates/internal/SdkHttpSimulationProgrammer.ts +122 -18
- package/src/generates/internal/SdkImportWizard.ts +63 -0
- package/src/generates/internal/SdkMcpRouteProgrammer.ts +150 -33
- package/src/generates/internal/SdkPathTemplate.ts +88 -0
- package/src/generates/internal/SdkRouteDirectory.ts +10 -0
- package/src/generates/internal/SdkTypeProgrammer.ts +137 -36
- package/src/generates/internal/SdkTypeTagProgrammer.ts +536 -78
- package/src/generates/internal/SdkWebSocketCloneProgrammer.ts +185 -142
- package/src/generates/internal/SdkWebSocketNamespaceProgrammer.ts +62 -68
- package/src/generates/internal/SdkWebSocketParameterProgrammer.ts +205 -5
- package/src/generates/internal/SdkWebSocketRouteProgrammer.ts +89 -48
- package/src/generates/internal/SwaggerDescriptionComposer.ts +47 -1
- package/src/generates/internal/SwaggerOperationComposer.ts +38 -6
- package/src/generates/internal/SwaggerOperationParameterComposer.ts +318 -36
- package/src/generates/internal/SwaggerOperationResponseComposer.ts +74 -11
- package/src/internal/legacy-augmentation.d.ts +16 -0
- package/src/internal/legacy.ts +407 -49
- package/src/structures/INestiaProject.ts +10 -0
- package/src/structures/INestiaSdkInput.ts +30 -0
- package/src/structures/IOperationMetadata.ts +83 -0
- package/src/structures/IReflectController.ts +10 -0
- package/src/structures/IReflectHttpOperation.ts +10 -0
- package/src/structures/IReflectHttpOperationException.ts +17 -2
- package/src/structures/IReflectHttpOperationParameter.ts +56 -2
- package/src/structures/IReflectHttpOperationSuccess.ts +19 -3
- package/src/structures/IReflectImport.ts +10 -0
- package/src/structures/IReflectMcpOperation.ts +19 -0
- package/src/structures/IReflectMcpOperationParameter.ts +9 -0
- package/src/structures/IReflectOperationError.ts +31 -2
- package/src/structures/IReflectType.ts +9 -0
- package/src/structures/IReflectWebSocketOperation.ts +10 -0
- package/src/structures/IReflectWebSocketOperationParameter.ts +55 -0
- package/src/structures/ITypedApplication.ts +10 -0
- package/src/structures/ITypedHttpRoute.ts +18 -0
- package/src/structures/ITypedHttpRouteException.ts +14 -1
- package/src/structures/ITypedHttpRouteParameter.ts +48 -1
- package/src/structures/ITypedHttpRouteSuccess.ts +14 -1
- package/src/structures/ITypedMcpRoute.ts +12 -0
- package/src/structures/ITypedWebSocketRoute.ts +18 -0
- package/src/transform.ts +6 -0
- package/src/utils/ArrayUtil.ts +32 -13
- package/src/utils/EmittedJavaScriptPatcher.ts +70 -47
- package/src/utils/FileRetriever.ts +29 -0
- package/src/utils/HttpResponseContentTypeUtil.ts +41 -0
- package/src/utils/MapUtil.ts +68 -3
- package/src/utils/PathUtil.ts +38 -0
- package/src/utils/SdkBundlePath.ts +11 -0
- package/src/utils/SdkInputFilter.ts +108 -0
- package/src/utils/SourceFinder.ts +76 -18
- package/src/utils/StringUtil.ts +182 -5
- package/src/utils/TemporaryDirectory.ts +108 -0
- package/src/utils/TsConfigReader.ts +124 -26
- package/src/utils/TtscExecutor.ts +23 -1
- package/src/utils/VersioningStrategy.ts +51 -16
- package/src/validators/TextPlainValidator.ts +19 -0
- package/lib/generates/internal/SwaggerReadonlyArrayEmender.d.ts +0 -9
- package/lib/generates/internal/SwaggerReadonlyArrayEmender.js +0 -178
- package/lib/generates/internal/SwaggerReadonlyArrayEmender.js.map +0 -1
- package/lib/validators/HttpHeadersValidator.d.ts +0 -11
- package/lib/validators/HttpHeadersValidator.js +0 -15
- package/lib/validators/HttpHeadersValidator.js.map +0 -1
- package/lib/validators/HttpQueryValidator.d.ts +0 -10
- package/lib/validators/HttpQueryValidator.js +0 -14
- package/lib/validators/HttpQueryValidator.js.map +0 -1
- package/src/generates/internal/SwaggerReadonlyArrayEmender.ts +0 -264
- package/src/validators/HttpHeadersValidator.ts +0 -12
- package/src/validators/HttpQueryValidator.ts +0 -11
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
type Expression,
|
|
2
3
|
type ParameterDeclaration,
|
|
3
4
|
type TypeNode,
|
|
4
5
|
factory,
|
|
@@ -6,30 +7,208 @@ import {
|
|
|
6
7
|
|
|
7
8
|
import { INestiaProject } from "../../structures/INestiaProject";
|
|
8
9
|
import { ITypedWebSocketRoute } from "../../structures/ITypedWebSocketRoute";
|
|
10
|
+
import { ITypedWebSocketRouteParameter } from "../../structures/ITypedWebSocketRouteParameter";
|
|
11
|
+
import { StringUtil } from "../../utils/StringUtil";
|
|
9
12
|
import { SdkAliasCollection } from "./SdkAliasCollection";
|
|
10
13
|
|
|
14
|
+
/**
|
|
15
|
+
* The parameters of a WebSocket route's SDK function.
|
|
16
|
+
*
|
|
17
|
+
* @evidence contracts/common.md#principled-implementation The namespace decides the identifiers, lists the entries, and writes the declarations, as the HTTP one does.
|
|
18
|
+
* @evidence contracts/common.md#clear-and-simple-design Several small functions.
|
|
19
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The identifiers are decided once.
|
|
20
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
21
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkWebSocketParameterProgrammer 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.
|
|
22
|
+
*/
|
|
11
23
|
export namespace SdkWebSocketParameterProgrammer {
|
|
24
|
+
/**
|
|
25
|
+
* One parameter of a WebSocket route: its key and its type.
|
|
26
|
+
*
|
|
27
|
+
* @evidence contracts/common.md#principled-implementation The record is what a declaration needs.
|
|
28
|
+
* @evidence contracts/common.md#clear-and-simple-design A two-member record.
|
|
29
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
|
|
30
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
31
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkWebSocketParameterProgrammer.IEntry 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.
|
|
32
|
+
*/
|
|
12
33
|
export interface IEntry {
|
|
13
34
|
key: string;
|
|
14
35
|
type: TypeNode;
|
|
15
36
|
}
|
|
16
37
|
|
|
38
|
+
/**
|
|
39
|
+
* The identifiers one WebSocket route's SDK function and `path()` use,
|
|
40
|
+
* decided once so the two cannot disagree; the HTTP counterpart,
|
|
41
|
+
* `SdkHttpParameterProgrammer.INames`, gives the rules.
|
|
42
|
+
*
|
|
43
|
+
* Path parameters are the user's names. `query` and `provider` are the SDK's
|
|
44
|
+
* own: the positional parameters, or the `props` keys in keyword mode, that
|
|
45
|
+
* carry the query object and the provider, so they yield to a path parameter
|
|
46
|
+
* of the same name instead of repeating it. A `props` key shadows nothing, so
|
|
47
|
+
* it yields to nothing else.
|
|
48
|
+
*
|
|
49
|
+
* @evidence contracts/common.md#principled-implementation One decision serves the two scopes.
|
|
50
|
+
* @evidence contracts/common.md#clear-and-simple-design A record of names and two lookups.
|
|
51
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
|
|
52
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
53
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkWebSocketParameterProgrammer.INames 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.
|
|
54
|
+
*/
|
|
55
|
+
export interface INames {
|
|
56
|
+
connection: string;
|
|
57
|
+
props: string;
|
|
58
|
+
query: string;
|
|
59
|
+
provider: string;
|
|
60
|
+
url: string;
|
|
61
|
+
connector: string;
|
|
62
|
+
driver: string;
|
|
63
|
+
variables: string;
|
|
64
|
+
location: string;
|
|
65
|
+
key: string;
|
|
66
|
+
value: string;
|
|
67
|
+
elem: string;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Local identifier of a path parameter in positional mode.
|
|
71
|
+
*
|
|
72
|
+
* @evidence contracts/common.md#principled-implementation A path parameter keeps its name unless the SDK cannot change the name it collides with.
|
|
73
|
+
* @evidence contracts/common.md#clear-and-simple-design One lookup.
|
|
74
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It reads the decision.
|
|
75
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
76
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkWebSocketParameterProgrammer.INames.parameter 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.
|
|
77
|
+
*/
|
|
78
|
+
parameter: (p: ITypedWebSocketRouteParameter.IParam) => string;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Reads a parameter, or one of `query` and `provider`, by its key.
|
|
82
|
+
*
|
|
83
|
+
* @evidence contracts/common.md#principled-implementation The read follows the mode of the function.
|
|
84
|
+
* @evidence contracts/common.md#clear-and-simple-design One lookup.
|
|
85
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It reads the decision.
|
|
86
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
87
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkWebSocketParameterProgrammer.INames.access 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.
|
|
88
|
+
*/
|
|
89
|
+
access: (key: string) => Expression;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Decides the identifiers of a WebSocket route's function and `path()` once.
|
|
94
|
+
*
|
|
95
|
+
* @evidence contracts/common.md#principled-implementation The fixed names each scope references are collected, and `query` and `provider` yield to a path parameter of the same name.
|
|
96
|
+
* @evidence contracts/common.md#clear-and-simple-design One function over the scope sets.
|
|
97
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Only shadowed names are renamed.
|
|
98
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
99
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkWebSocketParameterProgrammer.getNames 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.
|
|
100
|
+
*/
|
|
101
|
+
export const getNames = (props: {
|
|
102
|
+
project: INestiaProject;
|
|
103
|
+
route: ITypedWebSocketRoute;
|
|
104
|
+
}): INames => {
|
|
105
|
+
const { project, route } = props;
|
|
106
|
+
// names each scope references and the SDK cannot change
|
|
107
|
+
const functional: string[] = [route.name, "WebSocketConnector"];
|
|
108
|
+
const path: string[] = [
|
|
109
|
+
...(route.pathParameters.length !== 0 ? ["PathParameter"] : []),
|
|
110
|
+
...(route.query !== null
|
|
111
|
+
? ["URLSearchParams", "Object", "Array", "String", "undefined"]
|
|
112
|
+
: []),
|
|
113
|
+
];
|
|
114
|
+
const locals: Map<ITypedWebSocketRouteParameter.IParam, string> = new Map();
|
|
115
|
+
if (project.config.keyword !== true)
|
|
116
|
+
for (const p of route.pathParameters)
|
|
117
|
+
locals.set(
|
|
118
|
+
p,
|
|
119
|
+
StringUtil.escapeDuplicate([
|
|
120
|
+
...functional,
|
|
121
|
+
...path,
|
|
122
|
+
...route.pathParameters.filter((q) => q !== p).map((q) => q.name),
|
|
123
|
+
...locals.values(),
|
|
124
|
+
])(p.name),
|
|
125
|
+
);
|
|
126
|
+
// `query` and `provider` sit beside the path parameters, as parameters or
|
|
127
|
+
// as `props` keys. Every other own identifier avoids the positional
|
|
128
|
+
// path parameters its scope reads where it is visible: all of them for
|
|
129
|
+
// the function's locals, `variables`, and `location`, none for the
|
|
130
|
+
// loop's `key` and `value`, whose header reads only the query, and for
|
|
131
|
+
// `elem`.
|
|
132
|
+
const keys: string[] = route.pathParameters.map(
|
|
133
|
+
(p) => locals.get(p) ?? p.name,
|
|
134
|
+
);
|
|
135
|
+
const positional: string[] = [...locals.values()];
|
|
136
|
+
const own =
|
|
137
|
+
(fixed: string[], reads: string[], taken: string[]) =>
|
|
138
|
+
(name: string): string => {
|
|
139
|
+
const escaped: string = StringUtil.escapeDuplicate([
|
|
140
|
+
...fixed,
|
|
141
|
+
...reads,
|
|
142
|
+
...taken,
|
|
143
|
+
])(name);
|
|
144
|
+
taken.push(escaped);
|
|
145
|
+
return escaped;
|
|
146
|
+
};
|
|
147
|
+
const shared: string[] = [];
|
|
148
|
+
const $props: string = own([...functional, ...path], [], shared)("props");
|
|
149
|
+
// Positional `query` and `provider` also yield to the names their scopes
|
|
150
|
+
// reference; as `props` keys they shadow nothing, so a route named
|
|
151
|
+
// `query` keeps its `query` key.
|
|
152
|
+
const beside = (fixed: string[]) =>
|
|
153
|
+
own(project.config.keyword === true ? [] : fixed, keys, shared);
|
|
154
|
+
const $query: string = beside([...functional, ...path])("query");
|
|
155
|
+
const $provider: string = beside(functional)("provider");
|
|
156
|
+
const inFunction: string[] = [...shared];
|
|
157
|
+
const inPath: string[] = [...shared];
|
|
158
|
+
const names: Omit<INames, "parameter" | "access"> = {
|
|
159
|
+
props: $props,
|
|
160
|
+
query: $query,
|
|
161
|
+
provider: $provider,
|
|
162
|
+
connection: own(functional, positional, inFunction)("connection"),
|
|
163
|
+
url: own(functional, positional, inFunction)("url"),
|
|
164
|
+
connector: own(functional, positional, inFunction)("connector"),
|
|
165
|
+
driver: own(functional, positional, inFunction)("driver"),
|
|
166
|
+
variables: own(path, positional, inPath)("variables"),
|
|
167
|
+
location: own(path, positional, inPath)("location"),
|
|
168
|
+
key: own(path, [], inPath)("key"),
|
|
169
|
+
value: own(path, [], inPath)("value"),
|
|
170
|
+
elem: own(path, [], inPath)("elem"),
|
|
171
|
+
};
|
|
172
|
+
return {
|
|
173
|
+
...names,
|
|
174
|
+
parameter: (p) => locals.get(p) ?? p.name,
|
|
175
|
+
access: (key) =>
|
|
176
|
+
project.config.keyword === true
|
|
177
|
+
? factory.createPropertyAccessExpression(
|
|
178
|
+
factory.createIdentifier(names.props),
|
|
179
|
+
key,
|
|
180
|
+
)
|
|
181
|
+
: factory.createIdentifier(key),
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Returns the entries of a WebSocket route: its path parameters, its query,
|
|
187
|
+
* and its provider.
|
|
188
|
+
*
|
|
189
|
+
* @evidence contracts/common.md#principled-implementation The query exists only when the route has one, and the provider is included only when the caller requests it.
|
|
190
|
+
* @evidence contracts/common.md#clear-and-simple-design One list.
|
|
191
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The order is the call order.
|
|
192
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
193
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkWebSocketParameterProgrammer.getEntries 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.
|
|
194
|
+
*/
|
|
17
195
|
export const getEntries = (props: {
|
|
18
196
|
project: INestiaProject;
|
|
19
197
|
route: ITypedWebSocketRoute;
|
|
20
198
|
provider: boolean;
|
|
21
199
|
prefix: boolean;
|
|
22
200
|
}): IEntry[] => {
|
|
201
|
+
const names: INames = getNames(props);
|
|
23
202
|
const prefix: string = props.prefix ? `${props.route.name}.` : "";
|
|
24
203
|
return [
|
|
25
204
|
...props.route.pathParameters.map((p) => ({
|
|
26
|
-
key: p
|
|
205
|
+
key: names.parameter(p),
|
|
27
206
|
type: SdkAliasCollection.name(p),
|
|
28
207
|
})),
|
|
29
208
|
...(props.route.query
|
|
30
209
|
? [
|
|
31
210
|
{
|
|
32
|
-
key:
|
|
211
|
+
key: names.query,
|
|
33
212
|
type: factory.createTypeReferenceNode(`${prefix}Query`),
|
|
34
213
|
},
|
|
35
214
|
]
|
|
@@ -37,7 +216,7 @@ export namespace SdkWebSocketParameterProgrammer {
|
|
|
37
216
|
...(props.provider
|
|
38
217
|
? [
|
|
39
218
|
{
|
|
40
|
-
key:
|
|
219
|
+
key: names.provider,
|
|
41
220
|
type: factory.createTypeReferenceNode(`${prefix}Provider`),
|
|
42
221
|
},
|
|
43
222
|
]
|
|
@@ -45,6 +224,16 @@ export namespace SdkWebSocketParameterProgrammer {
|
|
|
45
224
|
];
|
|
46
225
|
};
|
|
47
226
|
|
|
227
|
+
/**
|
|
228
|
+
* Returns the parameter declarations of a WebSocket route's function: `props`
|
|
229
|
+
* in keyword mode, and one positional parameter per entry otherwise.
|
|
230
|
+
*
|
|
231
|
+
* @evidence contracts/common.md#principled-implementation The names come from `getNames`.
|
|
232
|
+
* @evidence contracts/common.md#clear-and-simple-design One function of two modes.
|
|
233
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The two modes share the entries.
|
|
234
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
235
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkWebSocketParameterProgrammer.getParameterDeclarations 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.
|
|
236
|
+
*/
|
|
48
237
|
export const getParameterDeclarations = (props: {
|
|
49
238
|
project: INestiaProject;
|
|
50
239
|
route: ITypedWebSocketRoute;
|
|
@@ -54,6 +243,7 @@ export namespace SdkWebSocketParameterProgrammer {
|
|
|
54
243
|
const entries: IEntry[] = getEntries(props);
|
|
55
244
|
if (entries.length === 0) return [];
|
|
56
245
|
else if (props.project.config.keyword === true) {
|
|
246
|
+
const names: INames = getNames(props);
|
|
57
247
|
const typeName: string = props.prefix
|
|
58
248
|
? `${props.route.name}.Props`
|
|
59
249
|
: "Props";
|
|
@@ -62,14 +252,14 @@ export namespace SdkWebSocketParameterProgrammer {
|
|
|
62
252
|
: factory.createTypeReferenceNode("Omit", [
|
|
63
253
|
factory.createTypeReferenceNode(typeName),
|
|
64
254
|
factory.createLiteralTypeNode(
|
|
65
|
-
factory.createStringLiteral(
|
|
255
|
+
factory.createStringLiteral(names.provider),
|
|
66
256
|
),
|
|
67
257
|
]);
|
|
68
258
|
return [
|
|
69
259
|
factory.createParameterDeclaration(
|
|
70
260
|
undefined,
|
|
71
261
|
undefined,
|
|
72
|
-
|
|
262
|
+
names.props,
|
|
73
263
|
undefined,
|
|
74
264
|
node,
|
|
75
265
|
),
|
|
@@ -86,6 +276,16 @@ export namespace SdkWebSocketParameterProgrammer {
|
|
|
86
276
|
);
|
|
87
277
|
};
|
|
88
278
|
|
|
279
|
+
/**
|
|
280
|
+
* Reports whether the route's path holds no parameter, so `path()` takes
|
|
281
|
+
* none.
|
|
282
|
+
*
|
|
283
|
+
* @evidence contracts/common.md#principled-implementation The route has no path parameter and no query.
|
|
284
|
+
* @evidence contracts/common.md#clear-and-simple-design One expression.
|
|
285
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It reads the route.
|
|
286
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
287
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkWebSocketParameterProgrammer.isPathEmpty 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.
|
|
288
|
+
*/
|
|
89
289
|
export const isPathEmpty = (route: ITypedWebSocketRoute): boolean =>
|
|
90
290
|
route.pathParameters.length === 0 && route.query === null;
|
|
91
291
|
}
|
|
@@ -6,57 +6,100 @@ import {
|
|
|
6
6
|
type TypeNode,
|
|
7
7
|
factory,
|
|
8
8
|
} from "@ttsc/factory";
|
|
9
|
-
import { IJsDocTagInfo } from "typia";
|
|
10
9
|
|
|
11
10
|
import { IdentifierFactory } from "../../factories/IdentifierFactory";
|
|
12
11
|
import { INestiaProject } from "../../structures/INestiaProject";
|
|
13
12
|
import { ITypedWebSocketRoute } from "../../structures/ITypedWebSocketRoute";
|
|
14
|
-
import { StringUtil } from "../../utils/StringUtil";
|
|
15
13
|
import { FilePrinter } from "./FilePrinter";
|
|
16
14
|
import { ImportDictionary } from "./ImportDictionary";
|
|
17
15
|
import { SdkImportWizard } from "./SdkImportWizard";
|
|
18
16
|
import { SdkWebSocketNamespaceProgrammer } from "./SdkWebSocketNamespaceProgrammer";
|
|
19
17
|
import { SdkWebSocketParameterProgrammer } from "./SdkWebSocketParameterProgrammer";
|
|
20
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Writes a WebSocket route into the SDK: its function and its namespace.
|
|
21
|
+
*
|
|
22
|
+
* @evidence contracts/common.md#principled-implementation The namespace prints the async function that opens the connection with `tgrid`.
|
|
23
|
+
* @evidence contracts/common.md#clear-and-simple-design One public function and the writers.
|
|
24
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The identifiers are decided by the parameter programmer.
|
|
25
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
26
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkWebSocketRouteProgrammer 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.
|
|
27
|
+
*/
|
|
21
28
|
export namespace SdkWebSocketRouteProgrammer {
|
|
29
|
+
/**
|
|
30
|
+
* Returns the function and the namespace of a WebSocket route.
|
|
31
|
+
*
|
|
32
|
+
* @evidence contracts/common.md#principled-implementation The two nodes are composed together so they share names.
|
|
33
|
+
* @evidence contracts/common.md#clear-and-simple-design One function.
|
|
34
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The shape follows the route.
|
|
35
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
36
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SdkWebSocketRouteProgrammer.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.
|
|
37
|
+
*/
|
|
22
38
|
export const write =
|
|
23
39
|
(project: INestiaProject) =>
|
|
24
40
|
(importer: ImportDictionary) =>
|
|
25
41
|
(route: ITypedWebSocketRoute): Statement[] => [
|
|
26
42
|
FilePrinter.description(
|
|
27
43
|
writeFunction(project)(importer)(route),
|
|
28
|
-
writeDescription(route),
|
|
44
|
+
writeDescription(project, route),
|
|
29
45
|
),
|
|
30
46
|
SdkWebSocketNamespaceProgrammer.write(project)(importer)(route),
|
|
31
47
|
];
|
|
32
48
|
|
|
33
|
-
const writeDescription = (
|
|
49
|
+
const writeDescription = (
|
|
50
|
+
project: INestiaProject,
|
|
51
|
+
route: ITypedWebSocketRoute,
|
|
52
|
+
): string => {
|
|
34
53
|
// MAIN DESCRIPTION
|
|
35
54
|
const comments: string[] = route.description
|
|
36
55
|
? route.description.split("\n")
|
|
37
56
|
: [];
|
|
38
57
|
|
|
39
|
-
// COMMENT TAGS
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
58
|
+
// COMMENT TAGS, each `@param` naming what the SDK function declares,
|
|
59
|
+
// which yields on a collision
|
|
60
|
+
const names: SdkWebSocketParameterProgrammer.INames =
|
|
61
|
+
SdkWebSocketParameterProgrammer.getNames({ project, route });
|
|
62
|
+
const declared = (name: string | undefined): string | null => {
|
|
63
|
+
const path = route.pathParameters.find((p) => p.name === name);
|
|
64
|
+
const key: string | null =
|
|
65
|
+
path !== undefined
|
|
66
|
+
? project.config.keyword === true
|
|
67
|
+
? path.name
|
|
68
|
+
: names.parameter(path)
|
|
69
|
+
: route.query !== null && route.query.name === name
|
|
70
|
+
? names.query
|
|
71
|
+
: null;
|
|
72
|
+
return key === null
|
|
73
|
+
? null
|
|
74
|
+
: project.config.keyword === true
|
|
75
|
+
? `${names.props}.${key}`
|
|
76
|
+
: key;
|
|
77
|
+
};
|
|
78
|
+
const tags: string[] = route.jsDocTags
|
|
79
|
+
.map((tag): string | null => {
|
|
80
|
+
if (tag.name !== "param")
|
|
81
|
+
return FilePrinter.jsDocTag(
|
|
82
|
+
tag.name,
|
|
83
|
+
tag.text?.map((e) => e.text).join("") ?? "",
|
|
84
|
+
);
|
|
85
|
+
const name: string | null = declared(tag.text?.[0]?.text);
|
|
86
|
+
return name === null
|
|
87
|
+
? null
|
|
88
|
+
: FilePrinter.jsDocTag(
|
|
89
|
+
`param ${name}`,
|
|
90
|
+
tag.text?.find((e) => e.kind === "text")?.text ?? "",
|
|
91
|
+
);
|
|
92
|
+
})
|
|
93
|
+
.filter((tag): tag is string => tag !== null);
|
|
94
|
+
// apart from the description, when there is one
|
|
95
|
+
if (tags.length !== 0)
|
|
96
|
+
comments.push(...(comments.length !== 0 ? [""] : []), ...new Set(tags));
|
|
55
97
|
|
|
56
98
|
// POSTFIX
|
|
57
99
|
if (!!comments.length) comments.push("");
|
|
58
100
|
comments.push(
|
|
59
|
-
|
|
101
|
+
// the public name, kept by a route declared under a local one
|
|
102
|
+
`@controller ${route.controller.class.name}.${route.key}`,
|
|
60
103
|
`@path ${route.path}`,
|
|
61
104
|
`@nestia Generated by Nestia - https://github.com/samchon/nestia`,
|
|
62
105
|
);
|
|
@@ -67,9 +110,8 @@ export namespace SdkWebSocketRouteProgrammer {
|
|
|
67
110
|
(project: INestiaProject) =>
|
|
68
111
|
(importer: ImportDictionary) =>
|
|
69
112
|
(route: ITypedWebSocketRoute): Statement => {
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
);
|
|
113
|
+
const names: SdkWebSocketParameterProgrammer.INames =
|
|
114
|
+
SdkWebSocketParameterProgrammer.getNames({ project, route });
|
|
73
115
|
return factory.createFunctionDeclaration(
|
|
74
116
|
[
|
|
75
117
|
factory.createModifier(SyntaxKind.ExportKeyword),
|
|
@@ -80,7 +122,7 @@ export namespace SdkWebSocketRouteProgrammer {
|
|
|
80
122
|
undefined,
|
|
81
123
|
[
|
|
82
124
|
IdentifierFactory.parameter(
|
|
83
|
-
connection,
|
|
125
|
+
names.connection,
|
|
84
126
|
factory.createTypeReferenceNode(
|
|
85
127
|
SdkImportWizard.IConnection(importer),
|
|
86
128
|
[factory.createTypeReferenceNode(`${route.name}.Header`)],
|
|
@@ -97,7 +139,7 @@ export namespace SdkWebSocketRouteProgrammer {
|
|
|
97
139
|
factory.createTypeReferenceNode(`${route.name}.Output`),
|
|
98
140
|
]),
|
|
99
141
|
factory.createBlock(
|
|
100
|
-
writeFunctionBody(project)(importer)(route)(
|
|
142
|
+
writeFunctionBody(project)(importer)(route)(names),
|
|
101
143
|
true,
|
|
102
144
|
),
|
|
103
145
|
);
|
|
@@ -107,18 +149,11 @@ export namespace SdkWebSocketRouteProgrammer {
|
|
|
107
149
|
(project: INestiaProject) =>
|
|
108
150
|
(importer: ImportDictionary) =>
|
|
109
151
|
(route: ITypedWebSocketRoute) =>
|
|
110
|
-
(
|
|
111
|
-
const access = (key: string) =>
|
|
112
|
-
project.config.keyword === true
|
|
113
|
-
? factory.createPropertyAccessExpression(
|
|
114
|
-
factory.createIdentifier("props"),
|
|
115
|
-
key,
|
|
116
|
-
)
|
|
117
|
-
: factory.createIdentifier(key);
|
|
152
|
+
(names: SdkWebSocketParameterProgrammer.INames): Statement[] => {
|
|
118
153
|
return [
|
|
119
|
-
local(
|
|
154
|
+
local(names.url)(factory.createTypeReferenceNode("string"))(
|
|
120
155
|
joinPath(
|
|
121
|
-
connection,
|
|
156
|
+
names.connection,
|
|
122
157
|
factory.createCallExpression(
|
|
123
158
|
factory.createPropertyAccessExpression(
|
|
124
159
|
factory.createIdentifier(route.name),
|
|
@@ -127,7 +162,7 @@ export namespace SdkWebSocketRouteProgrammer {
|
|
|
127
162
|
[],
|
|
128
163
|
project.config.keyword === true &&
|
|
129
164
|
SdkWebSocketParameterProgrammer.isPathEmpty(route) === false
|
|
130
|
-
? [factory.createIdentifier(
|
|
165
|
+
? [factory.createIdentifier(names.props)]
|
|
131
166
|
: SdkWebSocketParameterProgrammer.getEntries({
|
|
132
167
|
project,
|
|
133
168
|
route,
|
|
@@ -137,7 +172,7 @@ export namespace SdkWebSocketRouteProgrammer {
|
|
|
137
172
|
),
|
|
138
173
|
),
|
|
139
174
|
),
|
|
140
|
-
local(
|
|
175
|
+
local(names.connector)(
|
|
141
176
|
factory.createTypeReferenceNode(
|
|
142
177
|
importer.external({
|
|
143
178
|
declaration: false,
|
|
@@ -166,7 +201,7 @@ export namespace SdkWebSocketRouteProgrammer {
|
|
|
166
201
|
factory.createAsExpression(
|
|
167
202
|
factory.createBinaryExpression(
|
|
168
203
|
factory.createPropertyAccessExpression(
|
|
169
|
-
factory.createIdentifier(connection),
|
|
204
|
+
factory.createIdentifier(names.connection),
|
|
170
205
|
"headers",
|
|
171
206
|
),
|
|
172
207
|
factory.createToken(SyntaxKind.QuestionQuestionToken),
|
|
@@ -174,7 +209,7 @@ export namespace SdkWebSocketRouteProgrammer {
|
|
|
174
209
|
),
|
|
175
210
|
factory.createKeywordTypeNode(SyntaxKind.AnyKeyword),
|
|
176
211
|
),
|
|
177
|
-
access(
|
|
212
|
+
names.access(names.provider),
|
|
178
213
|
],
|
|
179
214
|
),
|
|
180
215
|
),
|
|
@@ -182,15 +217,15 @@ export namespace SdkWebSocketRouteProgrammer {
|
|
|
182
217
|
factory.createAwaitExpression(
|
|
183
218
|
factory.createCallExpression(
|
|
184
219
|
factory.createPropertyAccessExpression(
|
|
185
|
-
factory.createIdentifier(
|
|
220
|
+
factory.createIdentifier(names.connector),
|
|
186
221
|
"connect",
|
|
187
222
|
),
|
|
188
223
|
undefined,
|
|
189
|
-
[factory.createIdentifier(
|
|
224
|
+
[factory.createIdentifier(names.url)],
|
|
190
225
|
),
|
|
191
226
|
),
|
|
192
227
|
),
|
|
193
|
-
local(
|
|
228
|
+
local(names.driver)(
|
|
194
229
|
factory.createTypeReferenceNode(
|
|
195
230
|
importer.external({
|
|
196
231
|
declaration: true,
|
|
@@ -203,7 +238,7 @@ export namespace SdkWebSocketRouteProgrammer {
|
|
|
203
238
|
)(
|
|
204
239
|
factory.createCallExpression(
|
|
205
240
|
factory.createPropertyAccessExpression(
|
|
206
|
-
factory.createIdentifier(
|
|
241
|
+
factory.createIdentifier(names.connector),
|
|
207
242
|
"getDriver",
|
|
208
243
|
),
|
|
209
244
|
undefined,
|
|
@@ -213,8 +248,8 @@ export namespace SdkWebSocketRouteProgrammer {
|
|
|
213
248
|
factory.createReturnStatement(
|
|
214
249
|
factory.createObjectLiteralExpression(
|
|
215
250
|
[
|
|
216
|
-
|
|
217
|
-
|
|
251
|
+
writeOutputMember("connector", names.connector),
|
|
252
|
+
writeOutputMember("driver", names.driver),
|
|
218
253
|
factory.createPropertyAssignment(
|
|
219
254
|
factory.createIdentifier("reconnect"),
|
|
220
255
|
factory.createArrowFunction(
|
|
@@ -226,11 +261,11 @@ export namespace SdkWebSocketRouteProgrammer {
|
|
|
226
261
|
factory.createAwaitExpression(
|
|
227
262
|
factory.createCallExpression(
|
|
228
263
|
factory.createPropertyAccessExpression(
|
|
229
|
-
factory.createIdentifier(
|
|
264
|
+
factory.createIdentifier(names.connector),
|
|
230
265
|
factory.createIdentifier("connect"),
|
|
231
266
|
),
|
|
232
267
|
undefined,
|
|
233
|
-
[factory.createIdentifier(
|
|
268
|
+
[factory.createIdentifier(names.url)],
|
|
234
269
|
),
|
|
235
270
|
),
|
|
236
271
|
),
|
|
@@ -243,6 +278,12 @@ export namespace SdkWebSocketRouteProgrammer {
|
|
|
243
278
|
};
|
|
244
279
|
}
|
|
245
280
|
|
|
281
|
+
/** A member of the returned `Output`, shorthand when its local has its name. */
|
|
282
|
+
const writeOutputMember = (key: string, local: string) =>
|
|
283
|
+
key === local
|
|
284
|
+
? factory.createShorthandPropertyAssignment(key)
|
|
285
|
+
: factory.createPropertyAssignment(key, factory.createIdentifier(local));
|
|
286
|
+
|
|
246
287
|
const local = (name: string) => (type: TypeNode) => (expression: Expression) =>
|
|
247
288
|
factory.createVariableStatement(
|
|
248
289
|
[],
|
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
import { IJsDocTagInfo } from "typia";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Composes the title or summary and the description of a document member from
|
|
5
|
+
* its comment.
|
|
6
|
+
*
|
|
7
|
+
* @evidence contracts/common.md#principled-implementation The namespace reads the explicit tag, and otherwise takes the first line of the description when it is a sentence.
|
|
8
|
+
* @evidence contracts/common.md#clear-and-simple-design Three functions.
|
|
9
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The tag has priority over the derived text.
|
|
10
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
11
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SwaggerDescriptionComposer composes OpenAPI data; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
|
|
12
|
+
*/
|
|
3
13
|
export namespace SwaggerDescriptionComposer {
|
|
14
|
+
/**
|
|
15
|
+
* Returns the `summary` or `title` and the `description` of a member.
|
|
16
|
+
*
|
|
17
|
+
* The explicit tag is the summary; otherwise the description's first line,
|
|
18
|
+
* without its final period, when that line ends with one.
|
|
19
|
+
*
|
|
20
|
+
* @evidence contracts/common.md#principled-implementation The derived summary is only ever a whole sentence, and a description that is not a sentence has none.
|
|
21
|
+
* @evidence contracts/common.md#clear-and-simple-design One function.
|
|
22
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The kind is the caller's choice.
|
|
23
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
24
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SwaggerDescriptionComposer.compose composes OpenAPI data; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
|
|
25
|
+
*/
|
|
4
26
|
export const compose = <Kind extends "summary" | "title">(props: {
|
|
5
27
|
description: string | null;
|
|
6
28
|
jsDocTags: IJsDocTagInfo[];
|
|
@@ -28,6 +50,17 @@ export namespace SwaggerDescriptionComposer {
|
|
|
28
50
|
} as any;
|
|
29
51
|
};
|
|
30
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Returns the first text part of the first JSDoc tag with the name and a text
|
|
55
|
+
* array, matching the parameter name when one is given. Returns undefined
|
|
56
|
+
* when that selected tag has no text part.
|
|
57
|
+
*
|
|
58
|
+
* @evidence contracts/common.md#principled-implementation A matching tag with a text array is selected, then its first text part is returned if present.
|
|
59
|
+
* @evidence contracts/common.md#clear-and-simple-design One search.
|
|
60
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It reads the tags.
|
|
61
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
62
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SwaggerDescriptionComposer.descriptionFromJsDocTag composes OpenAPI data; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
|
|
63
|
+
*/
|
|
31
64
|
export const descriptionFromJsDocTag = (props: {
|
|
32
65
|
jsDocTags: IJsDocTagInfo[];
|
|
33
66
|
tag: string;
|
|
@@ -48,6 +81,15 @@ export namespace SwaggerDescriptionComposer {
|
|
|
48
81
|
: undefined;
|
|
49
82
|
};
|
|
50
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Returns the text of every JSDoc tag with the name and a non-empty text.
|
|
86
|
+
*
|
|
87
|
+
* @evidence contracts/common.md#principled-implementation The tags are filtered, then read.
|
|
88
|
+
* @evidence contracts/common.md#clear-and-simple-design One filter and one map.
|
|
89
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts An empty text is not returned.
|
|
90
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the declaration produces and its result.
|
|
91
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation SwaggerDescriptionComposer.getJsDocTexts composes OpenAPI data; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
|
|
92
|
+
*/
|
|
51
93
|
export const getJsDocTexts = (props: {
|
|
52
94
|
jsDocTags: IJsDocTagInfo[];
|
|
53
95
|
name: string;
|
|
@@ -60,5 +102,9 @@ export namespace SwaggerDescriptionComposer {
|
|
|
60
102
|
tag.text.find((elem) => elem.kind === "text" && elem.text.length) !==
|
|
61
103
|
undefined,
|
|
62
104
|
)
|
|
63
|
-
.map(
|
|
105
|
+
.map(
|
|
106
|
+
(tag) =>
|
|
107
|
+
tag.text!.find((elem) => elem.kind === "text" && elem.text.length)!
|
|
108
|
+
.text,
|
|
109
|
+
);
|
|
64
110
|
}
|