@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.
Files changed (391) hide show
  1. package/README.md +1 -1
  2. package/assets/bundle/distribute/build-sdk.cjs +28 -0
  3. package/assets/bundle/distribute/package.json +7 -3
  4. package/assets/bundle/distribute/tsconfig.json +15 -105
  5. package/lib/INestiaConfig.d.ts +74 -34
  6. package/lib/NestiaSdkApplication.d.ts +60 -0
  7. package/lib/NestiaSdkApplication.js +121 -32
  8. package/lib/NestiaSdkApplication.js.map +1 -1
  9. package/lib/NestiaSwaggerComposer.d.ts +21 -0
  10. package/lib/NestiaSwaggerComposer.js +32 -13
  11. package/lib/NestiaSwaggerComposer.js.map +1 -1
  12. package/lib/analyses/AccessorAnalyzer.d.ts +26 -0
  13. package/lib/analyses/AccessorAnalyzer.js +26 -0
  14. package/lib/analyses/AccessorAnalyzer.js.map +1 -1
  15. package/lib/analyses/ConfigAnalyzer.d.ts +41 -0
  16. package/lib/analyses/ConfigAnalyzer.js +52 -77
  17. package/lib/analyses/ConfigAnalyzer.js.map +1 -1
  18. package/lib/analyses/ImportAnalyzer.d.ts +25 -0
  19. package/lib/analyses/ImportAnalyzer.js +25 -0
  20. package/lib/analyses/ImportAnalyzer.js.map +1 -1
  21. package/lib/analyses/ParameterNameAnalyzer.d.ts +44 -0
  22. package/lib/analyses/ParameterNameAnalyzer.js +63 -0
  23. package/lib/analyses/ParameterNameAnalyzer.js.map +1 -0
  24. package/lib/analyses/PathAnalyzer.d.ts +93 -1
  25. package/lib/analyses/PathAnalyzer.js +160 -23
  26. package/lib/analyses/PathAnalyzer.js.map +1 -1
  27. package/lib/analyses/ReflectControllerAnalyzer.d.ts +32 -0
  28. package/lib/analyses/ReflectControllerAnalyzer.js +24 -1
  29. package/lib/analyses/ReflectControllerAnalyzer.js.map +1 -1
  30. package/lib/analyses/ReflectHttpOperationAnalyzer.d.ts +29 -0
  31. package/lib/analyses/ReflectHttpOperationAnalyzer.js +35 -24
  32. package/lib/analyses/ReflectHttpOperationAnalyzer.js.map +1 -1
  33. package/lib/analyses/ReflectHttpOperationExceptionAnalyzer.d.ts +31 -0
  34. package/lib/analyses/ReflectHttpOperationExceptionAnalyzer.js +21 -0
  35. package/lib/analyses/ReflectHttpOperationExceptionAnalyzer.js.map +1 -1
  36. package/lib/analyses/ReflectHttpOperationParameterAnalyzer.d.ts +31 -0
  37. package/lib/analyses/ReflectHttpOperationParameterAnalyzer.js +143 -23
  38. package/lib/analyses/ReflectHttpOperationParameterAnalyzer.js.map +1 -1
  39. package/lib/analyses/ReflectHttpOperationResponseAnalyzer.d.ts +32 -0
  40. package/lib/analyses/ReflectHttpOperationResponseAnalyzer.js +27 -2
  41. package/lib/analyses/ReflectHttpOperationResponseAnalyzer.js.map +1 -1
  42. package/lib/analyses/ReflectMcpOperationAnalyzer.d.ts +29 -0
  43. package/lib/analyses/ReflectMcpOperationAnalyzer.js +35 -11
  44. package/lib/analyses/ReflectMcpOperationAnalyzer.js.map +1 -1
  45. package/lib/analyses/ReflectMetadataAnalyzer.d.ts +47 -0
  46. package/lib/analyses/ReflectMetadataAnalyzer.js +47 -0
  47. package/lib/analyses/ReflectMetadataAnalyzer.js.map +1 -1
  48. package/lib/analyses/ReflectWebSocketOperationAnalyzer.d.ts +29 -0
  49. package/lib/analyses/ReflectWebSocketOperationAnalyzer.js +27 -5
  50. package/lib/analyses/ReflectWebSocketOperationAnalyzer.js.map +1 -1
  51. package/lib/analyses/SecurityAnalyzer.d.ts +25 -0
  52. package/lib/analyses/SecurityAnalyzer.js +39 -19
  53. package/lib/analyses/SecurityAnalyzer.js.map +1 -1
  54. package/lib/analyses/SwaggerExampleAnalyzer.d.ts +31 -0
  55. package/lib/analyses/SwaggerExampleAnalyzer.js +36 -0
  56. package/lib/analyses/SwaggerExampleAnalyzer.js.map +1 -0
  57. package/lib/analyses/TypedHttpRouteAnalyzer.d.ts +41 -3
  58. package/lib/analyses/TypedHttpRouteAnalyzer.js +196 -172
  59. package/lib/analyses/TypedHttpRouteAnalyzer.js.map +1 -1
  60. package/lib/analyses/TypedMcpRouteAnalyzer.d.ts +29 -0
  61. package/lib/analyses/TypedMcpRouteAnalyzer.js +152 -20
  62. package/lib/analyses/TypedMcpRouteAnalyzer.js.map +1 -1
  63. package/lib/analyses/TypedWebSocketRouteAnalyzer.d.ts +19 -0
  64. package/lib/analyses/TypedWebSocketRouteAnalyzer.js +20 -1
  65. package/lib/analyses/TypedWebSocketRouteAnalyzer.js.map +1 -1
  66. package/lib/decorators/OperationMetadata.d.ts +6 -0
  67. package/lib/decorators/OperationMetadata.js +6 -0
  68. package/lib/decorators/OperationMetadata.js.map +1 -1
  69. package/lib/executable/internal/CommandParser.d.ts +19 -0
  70. package/lib/executable/internal/CommandParser.js +19 -0
  71. package/lib/executable/internal/CommandParser.js.map +1 -1
  72. package/lib/executable/internal/NestiaConfigLoader.d.ts +56 -0
  73. package/lib/executable/internal/NestiaConfigLoader.js +48 -42
  74. package/lib/executable/internal/NestiaConfigLoader.js.map +1 -1
  75. package/lib/executable/internal/NestiaSdkCommand.d.ts +60 -0
  76. package/lib/executable/internal/NestiaSdkCommand.js +95 -3
  77. package/lib/executable/internal/NestiaSdkCommand.js.map +1 -1
  78. package/lib/executable/internal/NestiaSdkWatcher.d.ts +81 -0
  79. package/lib/executable/internal/NestiaSdkWatcher.js +125 -41
  80. package/lib/executable/internal/NestiaSdkWatcher.js.map +1 -1
  81. package/lib/executable/internal/NestiaSwaggerWatch.d.ts +80 -0
  82. package/lib/executable/internal/NestiaSwaggerWatch.js +308 -0
  83. package/lib/executable/internal/NestiaSwaggerWatch.js.map +1 -0
  84. package/lib/executable/sdk.js +16 -1
  85. package/lib/executable/sdk.js.map +1 -1
  86. package/lib/factories/ExpressionFactory.d.ts +18 -0
  87. package/lib/factories/ExpressionFactory.js +21 -2
  88. package/lib/factories/ExpressionFactory.js.map +1 -1
  89. package/lib/factories/IdentifierFactory.d.ts +24 -0
  90. package/lib/factories/IdentifierFactory.js +24 -0
  91. package/lib/factories/IdentifierFactory.js.map +1 -1
  92. package/lib/factories/LiteralFactory.d.ts +22 -4
  93. package/lib/factories/LiteralFactory.js +33 -11
  94. package/lib/factories/LiteralFactory.js.map +1 -1
  95. package/lib/factories/StatementFactory.d.ts +28 -1
  96. package/lib/factories/StatementFactory.js +28 -1
  97. package/lib/factories/StatementFactory.js.map +1 -1
  98. package/lib/factories/TypeFactory.d.ts +24 -0
  99. package/lib/factories/TypeFactory.js +15 -0
  100. package/lib/factories/TypeFactory.js.map +1 -1
  101. package/lib/generates/CloneGenerator.d.ts +22 -0
  102. package/lib/generates/CloneGenerator.js +26 -5
  103. package/lib/generates/CloneGenerator.js.map +1 -1
  104. package/lib/generates/E2eGenerator.d.ts +19 -0
  105. package/lib/generates/E2eGenerator.js +19 -0
  106. package/lib/generates/E2eGenerator.js.map +1 -1
  107. package/lib/generates/SdkGenerator.d.ts +38 -0
  108. package/lib/generates/SdkGenerator.js +43 -5
  109. package/lib/generates/SdkGenerator.js.map +1 -1
  110. package/lib/generates/SwaggerGenerator.d.ts +36 -6
  111. package/lib/generates/SwaggerGenerator.js +190 -40
  112. package/lib/generates/SwaggerGenerator.js.map +1 -1
  113. package/lib/generates/internal/E2eFileProgrammer.d.ts +19 -0
  114. package/lib/generates/internal/E2eFileProgrammer.js +20 -1
  115. package/lib/generates/internal/E2eFileProgrammer.js.map +1 -1
  116. package/lib/generates/internal/FilePrinter.d.ts +57 -0
  117. package/lib/generates/internal/FilePrinter.js +74 -0
  118. package/lib/generates/internal/FilePrinter.js.map +1 -1
  119. package/lib/generates/internal/ImportDictionary.d.ts +93 -1
  120. package/lib/generates/internal/ImportDictionary.js +103 -2
  121. package/lib/generates/internal/ImportDictionary.js.map +1 -1
  122. package/lib/generates/internal/SdkAliasCollection.d.ts +121 -1
  123. package/lib/generates/internal/SdkAliasCollection.js +132 -11
  124. package/lib/generates/internal/SdkAliasCollection.js.map +1 -1
  125. package/lib/generates/internal/SdkDistributionComposer.d.ts +19 -0
  126. package/lib/generates/internal/SdkDistributionComposer.js +149 -52
  127. package/lib/generates/internal/SdkDistributionComposer.js.map +1 -1
  128. package/lib/generates/internal/SdkFileProgrammer.d.ts +18 -0
  129. package/lib/generates/internal/SdkFileProgrammer.js +101 -12
  130. package/lib/generates/internal/SdkFileProgrammer.js.map +1 -1
  131. package/lib/generates/internal/SdkHttpCloneProgrammer.d.ts +29 -0
  132. package/lib/generates/internal/SdkHttpCloneProgrammer.js +33 -0
  133. package/lib/generates/internal/SdkHttpCloneProgrammer.js.map +1 -1
  134. package/lib/generates/internal/SdkHttpCloneReferencer.d.ts +19 -0
  135. package/lib/generates/internal/SdkHttpCloneReferencer.js +78 -25
  136. package/lib/generates/internal/SdkHttpCloneReferencer.js.map +1 -1
  137. package/lib/generates/internal/SdkHttpFunctionProgrammer.d.ts +19 -0
  138. package/lib/generates/internal/SdkHttpFunctionProgrammer.js +40 -23
  139. package/lib/generates/internal/SdkHttpFunctionProgrammer.js.map +1 -1
  140. package/lib/generates/internal/SdkHttpNamespaceProgrammer.d.ts +19 -0
  141. package/lib/generates/internal/SdkHttpNamespaceProgrammer.js +46 -34
  142. package/lib/generates/internal/SdkHttpNamespaceProgrammer.js.map +1 -1
  143. package/lib/generates/internal/SdkHttpParameterProgrammer.d.ts +142 -1
  144. package/lib/generates/internal/SdkHttpParameterProgrammer.js +175 -6
  145. package/lib/generates/internal/SdkHttpParameterProgrammer.js.map +1 -1
  146. package/lib/generates/internal/SdkHttpRouteProgrammer.d.ts +20 -0
  147. package/lib/generates/internal/SdkHttpRouteProgrammer.js +36 -32
  148. package/lib/generates/internal/SdkHttpRouteProgrammer.js.map +1 -1
  149. package/lib/generates/internal/SdkHttpSimulationProgrammer.d.ts +38 -0
  150. package/lib/generates/internal/SdkHttpSimulationProgrammer.js +66 -18
  151. package/lib/generates/internal/SdkHttpSimulationProgrammer.js.map +1 -1
  152. package/lib/generates/internal/SdkImportWizard.d.ts +63 -0
  153. package/lib/generates/internal/SdkImportWizard.js +63 -0
  154. package/lib/generates/internal/SdkImportWizard.js.map +1 -1
  155. package/lib/generates/internal/SdkMcpRouteProgrammer.d.ts +17 -2
  156. package/lib/generates/internal/SdkMcpRouteProgrammer.js +72 -24
  157. package/lib/generates/internal/SdkMcpRouteProgrammer.js.map +1 -1
  158. package/lib/generates/internal/SdkPathTemplate.d.ts +36 -0
  159. package/lib/generates/internal/SdkPathTemplate.js +65 -0
  160. package/lib/generates/internal/SdkPathTemplate.js.map +1 -0
  161. package/lib/generates/internal/SdkRouteDirectory.d.ts +10 -0
  162. package/lib/generates/internal/SdkRouteDirectory.js +10 -0
  163. package/lib/generates/internal/SdkRouteDirectory.js.map +1 -1
  164. package/lib/generates/internal/SdkTypeProgrammer.d.ts +54 -1
  165. package/lib/generates/internal/SdkTypeProgrammer.js +111 -27
  166. package/lib/generates/internal/SdkTypeProgrammer.js.map +1 -1
  167. package/lib/generates/internal/SdkTypeTagProgrammer.d.ts +53 -1
  168. package/lib/generates/internal/SdkTypeTagProgrammer.js +407 -67
  169. package/lib/generates/internal/SdkTypeTagProgrammer.js.map +1 -1
  170. package/lib/generates/internal/SdkWebSocketCloneProgrammer.d.ts +40 -0
  171. package/lib/generates/internal/SdkWebSocketCloneProgrammer.js +149 -142
  172. package/lib/generates/internal/SdkWebSocketCloneProgrammer.js.map +1 -1
  173. package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.d.ts +19 -0
  174. package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js +46 -36
  175. package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js.map +1 -1
  176. package/lib/generates/internal/SdkWebSocketParameterProgrammer.d.ts +114 -1
  177. package/lib/generates/internal/SdkWebSocketParameterProgrammer.js +120 -5
  178. package/lib/generates/internal/SdkWebSocketParameterProgrammer.js.map +1 -1
  179. package/lib/generates/internal/SdkWebSocketRouteProgrammer.d.ts +18 -0
  180. package/lib/generates/internal/SdkWebSocketRouteProgrammer.js +75 -33
  181. package/lib/generates/internal/SdkWebSocketRouteProgrammer.js.map +1 -1
  182. package/lib/generates/internal/SwaggerDescriptionComposer.d.ts +42 -0
  183. package/lib/generates/internal/SwaggerDescriptionComposer.js +44 -1
  184. package/lib/generates/internal/SwaggerDescriptionComposer.js.map +1 -1
  185. package/lib/generates/internal/SwaggerOperationComposer.d.ts +18 -0
  186. package/lib/generates/internal/SwaggerOperationComposer.js +37 -8
  187. package/lib/generates/internal/SwaggerOperationComposer.js.map +1 -1
  188. package/lib/generates/internal/SwaggerOperationParameterComposer.d.ts +40 -1
  189. package/lib/generates/internal/SwaggerOperationParameterComposer.js +230 -25
  190. package/lib/generates/internal/SwaggerOperationParameterComposer.js.map +1 -1
  191. package/lib/generates/internal/SwaggerOperationResponseComposer.d.ts +21 -0
  192. package/lib/generates/internal/SwaggerOperationResponseComposer.js +58 -7
  193. package/lib/generates/internal/SwaggerOperationResponseComposer.js.map +1 -1
  194. package/lib/internal/legacy.d.ts +342 -31
  195. package/lib/internal/legacy.js +207 -31
  196. package/lib/internal/legacy.js.map +1 -1
  197. package/lib/structures/INestiaProject.d.ts +10 -0
  198. package/lib/structures/INestiaSdkInput.d.ts +30 -0
  199. package/lib/structures/IOperationMetadata.d.ts +77 -0
  200. package/lib/structures/IReflectController.d.ts +10 -0
  201. package/lib/structures/IReflectHttpOperation.d.ts +10 -0
  202. package/lib/structures/IReflectHttpOperationException.d.ts +13 -2
  203. package/lib/structures/IReflectHttpOperationParameter.d.ts +55 -3
  204. package/lib/structures/IReflectHttpOperationSuccess.d.ts +15 -3
  205. package/lib/structures/IReflectImport.d.ts +10 -0
  206. package/lib/structures/IReflectMcpOperation.d.ts +19 -0
  207. package/lib/structures/IReflectMcpOperationParameter.d.ts +9 -0
  208. package/lib/structures/IReflectOperationError.d.ts +28 -0
  209. package/lib/structures/IReflectOperationError.js +22 -2
  210. package/lib/structures/IReflectOperationError.js.map +1 -1
  211. package/lib/structures/IReflectType.d.ts +9 -0
  212. package/lib/structures/IReflectWebSocketOperation.d.ts +10 -0
  213. package/lib/structures/IReflectWebSocketOperationParameter.d.ts +55 -0
  214. package/lib/structures/ITypedApplication.d.ts +10 -0
  215. package/lib/structures/ITypedHttpRoute.d.ts +18 -0
  216. package/lib/structures/ITypedHttpRouteException.d.ts +13 -1
  217. package/lib/structures/ITypedHttpRouteParameter.d.ts +48 -1
  218. package/lib/structures/ITypedHttpRouteSuccess.d.ts +13 -1
  219. package/lib/structures/ITypedMcpRoute.d.ts +11 -0
  220. package/lib/structures/ITypedWebSocketRoute.d.ts +18 -0
  221. package/lib/transform.d.ts +6 -0
  222. package/lib/transform.js +6 -0
  223. package/lib/transform.js.map +1 -1
  224. package/lib/utils/ArrayUtil.d.ts +31 -1
  225. package/lib/utils/ArrayUtil.js +32 -11
  226. package/lib/utils/ArrayUtil.js.map +1 -1
  227. package/lib/utils/EmittedJavaScriptPatcher.d.ts +20 -0
  228. package/lib/utils/EmittedJavaScriptPatcher.js +65 -46
  229. package/lib/utils/EmittedJavaScriptPatcher.js.map +1 -1
  230. package/lib/utils/FileRetriever.d.ts +29 -0
  231. package/lib/utils/FileRetriever.js +29 -0
  232. package/lib/utils/FileRetriever.js.map +1 -1
  233. package/lib/utils/HttpResponseContentTypeUtil.d.ts +41 -0
  234. package/lib/utils/HttpResponseContentTypeUtil.js +31 -0
  235. package/lib/utils/HttpResponseContentTypeUtil.js.map +1 -1
  236. package/lib/utils/MapUtil.d.ts +64 -1
  237. package/lib/utils/MapUtil.js +24 -3
  238. package/lib/utils/MapUtil.js.map +1 -1
  239. package/lib/utils/PathUtil.d.ts +31 -0
  240. package/lib/utils/PathUtil.js +38 -0
  241. package/lib/utils/PathUtil.js.map +1 -1
  242. package/lib/utils/SdkBundlePath.d.ts +2 -0
  243. package/lib/utils/SdkBundlePath.js +10 -0
  244. package/lib/utils/SdkBundlePath.js.map +1 -0
  245. package/lib/utils/SdkInputFilter.d.ts +31 -0
  246. package/lib/utils/SdkInputFilter.js +115 -0
  247. package/lib/utils/SdkInputFilter.js.map +1 -0
  248. package/lib/utils/SourceFinder.d.ts +45 -0
  249. package/lib/utils/SourceFinder.js +74 -16
  250. package/lib/utils/SourceFinder.js.map +1 -1
  251. package/lib/utils/StringUtil.d.ts +77 -2
  252. package/lib/utils/StringUtil.js +166 -4
  253. package/lib/utils/StringUtil.js.map +1 -1
  254. package/lib/utils/TemporaryDirectory.d.ts +60 -0
  255. package/lib/utils/TemporaryDirectory.js +112 -0
  256. package/lib/utils/TemporaryDirectory.js.map +1 -0
  257. package/lib/utils/TsConfigReader.d.ts +42 -0
  258. package/lib/utils/TsConfigReader.js +98 -14
  259. package/lib/utils/TsConfigReader.js.map +1 -1
  260. package/lib/utils/TtscExecutor.d.ts +23 -1
  261. package/lib/utils/TtscExecutor.js +22 -0
  262. package/lib/utils/TtscExecutor.js.map +1 -1
  263. package/lib/utils/VersioningStrategy.d.ts +39 -2
  264. package/lib/utils/VersioningStrategy.js +46 -13
  265. package/lib/utils/VersioningStrategy.js.map +1 -1
  266. package/lib/validators/TextPlainValidator.d.ts +19 -0
  267. package/lib/validators/TextPlainValidator.js +19 -0
  268. package/lib/validators/TextPlainValidator.js.map +1 -1
  269. package/native/go.mod +1 -1
  270. package/native/go.sum +2 -2
  271. package/native/sdk/register.go +12 -2
  272. package/native/sdk/sdk_http_rules.go +210 -0
  273. package/native/sdk/sdk_metadata_json.go +79 -4
  274. package/native/sdk/sdk_transform.go +1157 -414
  275. package/package.json +8 -6
  276. package/src/INestiaConfig.ts +74 -34
  277. package/src/NestiaSdkApplication.ts +129 -41
  278. package/src/NestiaSwaggerComposer.ts +32 -14
  279. package/src/analyses/AccessorAnalyzer.ts +26 -0
  280. package/src/analyses/ConfigAnalyzer.ts +52 -90
  281. package/src/analyses/ImportAnalyzer.ts +25 -0
  282. package/src/analyses/ParameterNameAnalyzer.ts +75 -0
  283. package/src/analyses/PathAnalyzer.ts +167 -23
  284. package/src/analyses/ReflectControllerAnalyzer.ts +34 -1
  285. package/src/analyses/ReflectHttpOperationAnalyzer.ts +36 -14
  286. package/src/analyses/ReflectHttpOperationExceptionAnalyzer.ts +31 -0
  287. package/src/analyses/ReflectHttpOperationParameterAnalyzer.ts +153 -39
  288. package/src/analyses/ReflectHttpOperationResponseAnalyzer.ts +38 -7
  289. package/src/analyses/ReflectMcpOperationAnalyzer.ts +38 -3
  290. package/src/analyses/ReflectMetadataAnalyzer.ts +47 -0
  291. package/src/analyses/ReflectWebSocketOperationAnalyzer.ts +40 -7
  292. package/src/analyses/SecurityAnalyzer.ts +45 -20
  293. package/src/analyses/SwaggerExampleAnalyzer.ts +39 -0
  294. package/src/analyses/TypedHttpRouteAnalyzer.ts +263 -198
  295. package/src/analyses/TypedMcpRouteAnalyzer.ts +180 -20
  296. package/src/analyses/TypedWebSocketRouteAnalyzer.ts +20 -0
  297. package/src/decorators/OperationMetadata.ts +6 -0
  298. package/src/executable/internal/CommandParser.ts +19 -0
  299. package/src/executable/internal/NestiaConfigLoader.ts +66 -50
  300. package/src/executable/internal/NestiaSdkCommand.ts +96 -3
  301. package/src/executable/internal/NestiaSdkWatcher.ts +172 -44
  302. package/src/executable/internal/NestiaSwaggerWatch.ts +359 -0
  303. package/src/executable/sdk.ts +24 -1
  304. package/src/factories/ExpressionFactory.ts +23 -2
  305. package/src/factories/IdentifierFactory.ts +24 -0
  306. package/src/factories/LiteralFactory.ts +51 -13
  307. package/src/factories/StatementFactory.ts +28 -1
  308. package/src/factories/TypeFactory.ts +24 -0
  309. package/src/generates/CloneGenerator.ts +26 -5
  310. package/src/generates/E2eGenerator.ts +19 -0
  311. package/src/generates/SdkGenerator.ts +43 -12
  312. package/src/generates/SwaggerGenerator.ts +229 -46
  313. package/src/generates/internal/E2eFileProgrammer.ts +20 -0
  314. package/src/generates/internal/FilePrinter.ts +71 -0
  315. package/src/generates/internal/ImportDictionary.ts +120 -2
  316. package/src/generates/internal/SdkAliasCollection.ts +144 -15
  317. package/src/generates/internal/SdkDistributionComposer.ts +181 -56
  318. package/src/generates/internal/SdkFileProgrammer.ts +126 -16
  319. package/src/generates/internal/SdkHttpCloneProgrammer.ts +55 -0
  320. package/src/generates/internal/SdkHttpCloneReferencer.ts +97 -23
  321. package/src/generates/internal/SdkHttpFunctionProgrammer.ts +47 -30
  322. package/src/generates/internal/SdkHttpNamespaceProgrammer.ts +53 -64
  323. package/src/generates/internal/SdkHttpParameterProgrammer.ts +295 -13
  324. package/src/generates/internal/SdkHttpRouteProgrammer.ts +37 -31
  325. package/src/generates/internal/SdkHttpSimulationProgrammer.ts +122 -18
  326. package/src/generates/internal/SdkImportWizard.ts +63 -0
  327. package/src/generates/internal/SdkMcpRouteProgrammer.ts +150 -33
  328. package/src/generates/internal/SdkPathTemplate.ts +88 -0
  329. package/src/generates/internal/SdkRouteDirectory.ts +10 -0
  330. package/src/generates/internal/SdkTypeProgrammer.ts +137 -36
  331. package/src/generates/internal/SdkTypeTagProgrammer.ts +536 -78
  332. package/src/generates/internal/SdkWebSocketCloneProgrammer.ts +185 -142
  333. package/src/generates/internal/SdkWebSocketNamespaceProgrammer.ts +62 -68
  334. package/src/generates/internal/SdkWebSocketParameterProgrammer.ts +205 -5
  335. package/src/generates/internal/SdkWebSocketRouteProgrammer.ts +89 -48
  336. package/src/generates/internal/SwaggerDescriptionComposer.ts +47 -1
  337. package/src/generates/internal/SwaggerOperationComposer.ts +38 -6
  338. package/src/generates/internal/SwaggerOperationParameterComposer.ts +318 -36
  339. package/src/generates/internal/SwaggerOperationResponseComposer.ts +74 -11
  340. package/src/internal/legacy-augmentation.d.ts +16 -0
  341. package/src/internal/legacy.ts +407 -49
  342. package/src/structures/INestiaProject.ts +10 -0
  343. package/src/structures/INestiaSdkInput.ts +30 -0
  344. package/src/structures/IOperationMetadata.ts +83 -0
  345. package/src/structures/IReflectController.ts +10 -0
  346. package/src/structures/IReflectHttpOperation.ts +10 -0
  347. package/src/structures/IReflectHttpOperationException.ts +17 -2
  348. package/src/structures/IReflectHttpOperationParameter.ts +56 -2
  349. package/src/structures/IReflectHttpOperationSuccess.ts +19 -3
  350. package/src/structures/IReflectImport.ts +10 -0
  351. package/src/structures/IReflectMcpOperation.ts +19 -0
  352. package/src/structures/IReflectMcpOperationParameter.ts +9 -0
  353. package/src/structures/IReflectOperationError.ts +31 -2
  354. package/src/structures/IReflectType.ts +9 -0
  355. package/src/structures/IReflectWebSocketOperation.ts +10 -0
  356. package/src/structures/IReflectWebSocketOperationParameter.ts +55 -0
  357. package/src/structures/ITypedApplication.ts +10 -0
  358. package/src/structures/ITypedHttpRoute.ts +18 -0
  359. package/src/structures/ITypedHttpRouteException.ts +14 -1
  360. package/src/structures/ITypedHttpRouteParameter.ts +48 -1
  361. package/src/structures/ITypedHttpRouteSuccess.ts +14 -1
  362. package/src/structures/ITypedMcpRoute.ts +12 -0
  363. package/src/structures/ITypedWebSocketRoute.ts +18 -0
  364. package/src/transform.ts +6 -0
  365. package/src/utils/ArrayUtil.ts +32 -13
  366. package/src/utils/EmittedJavaScriptPatcher.ts +70 -47
  367. package/src/utils/FileRetriever.ts +29 -0
  368. package/src/utils/HttpResponseContentTypeUtil.ts +41 -0
  369. package/src/utils/MapUtil.ts +68 -3
  370. package/src/utils/PathUtil.ts +38 -0
  371. package/src/utils/SdkBundlePath.ts +11 -0
  372. package/src/utils/SdkInputFilter.ts +108 -0
  373. package/src/utils/SourceFinder.ts +76 -18
  374. package/src/utils/StringUtil.ts +182 -5
  375. package/src/utils/TemporaryDirectory.ts +108 -0
  376. package/src/utils/TsConfigReader.ts +124 -26
  377. package/src/utils/TtscExecutor.ts +23 -1
  378. package/src/utils/VersioningStrategy.ts +51 -16
  379. package/src/validators/TextPlainValidator.ts +19 -0
  380. package/lib/generates/internal/SwaggerReadonlyArrayEmender.d.ts +0 -9
  381. package/lib/generates/internal/SwaggerReadonlyArrayEmender.js +0 -178
  382. package/lib/generates/internal/SwaggerReadonlyArrayEmender.js.map +0 -1
  383. package/lib/validators/HttpHeadersValidator.d.ts +0 -11
  384. package/lib/validators/HttpHeadersValidator.js +0 -15
  385. package/lib/validators/HttpHeadersValidator.js.map +0 -1
  386. package/lib/validators/HttpQueryValidator.d.ts +0 -10
  387. package/lib/validators/HttpQueryValidator.js +0 -14
  388. package/lib/validators/HttpQueryValidator.js.map +0 -1
  389. package/src/generates/internal/SwaggerReadonlyArrayEmender.ts +0 -264
  390. package/src/validators/HttpHeadersValidator.ts +0 -12
  391. package/src/validators/HttpQueryValidator.ts +0 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestia/sdk",
3
- "version": "14.0.0",
3
+ "version": "14.0.2",
4
4
  "description": "Nestia SDK and Swagger generator",
5
5
  "main": "lib/index.js",
6
6
  "bin": {
@@ -55,12 +55,13 @@
55
55
  "tgrid": "^1.2.1",
56
56
  "ttsc": "^0.28.1",
57
57
  "tstl": "^3.0.0",
58
- "typia": "^15.0.0",
59
- "@nestia/fetcher": "^14.0.0",
60
- "@nestia/core": "^14.0.0"
58
+ "typia": "15.0.0",
59
+ "@babel/parser": "^7.29.8",
60
+ "@nestia/core": "^14.0.2",
61
+ "@nestia/fetcher": "^14.0.2"
61
62
  },
62
63
  "peerDependencies": {
63
- "@nestia/core": "^14.0.0"
64
+ "@nestia/core": "^14.0.2"
64
65
  },
65
66
  "devDependencies": {
66
67
  "@modelcontextprotocol/sdk": "^1.18.0",
@@ -88,7 +89,8 @@
88
89
  "scripts": {
89
90
  "build": "rimraf lib && ttsc",
90
91
  "dev": "ttsc --watch",
91
- "test:go": "cd test && go test ./..."
92
+ "test:go": "cd test && go test -count=1 ./...",
93
+ "evidence": "evidence"
92
94
  },
93
95
  "types": "lib/index.d.ts"
94
96
  }
@@ -5,6 +5,11 @@ import type { OpenApi } from "typia";
5
5
  * Definition for the `nestia.config.ts` file.
6
6
  *
7
7
  * @author Jeongho Nam - https://github.com/samchon
8
+ * @evidence contracts/common.md#principled-implementation The input names the controllers to analyze and every optional property enables or refines one output (SDK, distribution, e2e, Swagger), so one configuration file drives every generator.
9
+ * @evidence contracts/common.md#clear-and-simple-design A flat record whose nested types describe the input and the Swagger options.
10
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
11
+ * @evidence contracts/common.md#meaningful-documentation Every property documents its meaning and default, which are the public contract of the configuration file.
12
+ * @evidence contracts/portability.md#os-neutral-implementation Source inputs and output/distribution/e2e destinations carry native pathname strings interpreted by their owning Node filesystem operations; the application callback bypasses source compilation. Swagger route paths are distinct protocol values, not native file identities.
8
13
  */
9
14
  export interface INestiaConfig {
10
15
  /**
@@ -49,11 +54,16 @@ export interface INestiaConfig {
49
54
  */
50
55
  distribute?: string;
51
56
 
52
- /** @default false */
57
+ /**
58
+ * Groups HTTP and WebSocket SDK call arguments in one props object after the
59
+ * connection. MCP wrappers retain their client and arguments parameters.
60
+ *
61
+ * @default false
62
+ */
53
63
  keyword?: boolean;
54
64
 
55
65
  /**
56
- * Allow simulation mode.
66
+ * Allow simulation mode for HTTP SDK calls.
57
67
  *
58
68
  * If you configure this property to be `true`, the SDK library would be
59
69
  * contain simulation mode. In the simulation mode, the SDK library would not
@@ -72,7 +82,8 @@ export interface INestiaConfig {
72
82
  *
73
83
  * If you configure this property and runs `npx nestia e2e` command,
74
84
  * `@nestia/sdk` will analyze your NestJS backend server code, and generates
75
- * e2e test functions for every API endpoints.
85
+ * e2e test functions for the analyzed HTTP endpoints. WebSocket and MCP
86
+ * operations have no generated HTTP test function.
76
87
  *
77
88
  * If not configured, you can't run `npx nestia e2e` command.
78
89
  */
@@ -82,10 +93,10 @@ export interface INestiaConfig {
82
93
  * Whether to use propagation mode or not.
83
94
  *
84
95
  * If being configured, interaction functions of the SDK library would perform
85
- * the propagation mode. The propagation mode means that never throwing
86
- * exception even when status code is not 200 (or 201), but just returning the
96
+ * propagation mode. HTTP failure statuses are returned through the
87
97
  * {@link IPropagation} typed instance, which can specify its body type through
88
- * discriminated union determined by status code.
98
+ * discriminated union determined by status code. Transport, decoding and
99
+ * configured assertion failures can still throw.
89
100
  *
90
101
  * @default false
91
102
  */
@@ -94,9 +105,10 @@ export interface INestiaConfig {
94
105
  /**
95
106
  * Whether to clone DTO structures or not.
96
107
  *
97
- * If being configured, all of DTOs used in the backend server would be cloned
98
- * into the `structures` directory, and the SDK library would be refer to the
99
- * cloned DTOs instead of the original.
108
+ * If enabled, named DTOs reachable from analyzed routes are emitted into
109
+ * `structures`, with anonymous forms written inline. HTTP and MCP DTOs use
110
+ * their wire metadata; supported WebSocket declarations are copied from local
111
+ * sources, while external or unsupported imports retain source links.
100
112
  *
101
113
  * @default false
102
114
  */
@@ -105,8 +117,10 @@ export interface INestiaConfig {
105
117
  /**
106
118
  * Whether to wrap DTO by primitive type.
107
119
  *
108
- * If you don't configure this property as `false`, all of DTOs in the SDK
109
- * library would be automatically wrapped by {@link Primitive} type.
120
+ * Unless false, source DTO aliases use Primitive for JSON bodies and
121
+ * responses, and Resolved for query, headers and other resolved wire forms.
122
+ * Clone mode writes the analyzed metadata directly; multipart bodies use
123
+ * FormDataInput and binary responses use ReadableStream.
110
124
  *
111
125
  * For refenrece, if a DTO type be capsuled by the {@link Primitive} type, all
112
126
  * of methods in the DTO type would be automatically erased. Also, if the DTO
@@ -120,9 +134,10 @@ export interface INestiaConfig {
120
134
  /**
121
135
  * Whether to assert parameter types or not.
122
136
  *
123
- * If you configure this property to be `true`, all of the function parameters
124
- * of SDK library would be checked through [`typia.assert<T>()`
125
- * function](https://typia.io/docs/validators/assert/).
137
+ * If true, HTTP path, query and body arguments are checked through
138
+ * [`typia.assert<T>()` function](https://typia.io/docs/validators/assert/).
139
+ * The connection, connection headers, WebSocket and MCP arguments are outside
140
+ * this option.
126
141
  *
127
142
  * This option would make your SDK library compilation time a little bit
128
143
  * slower, but would enahcne the type safety even in the runtime level.
@@ -132,16 +147,13 @@ export interface INestiaConfig {
132
147
  assert?: boolean;
133
148
 
134
149
  /**
135
- * Whether to optimize JSON string conversion 10x faster or not.
136
- *
137
- * If you configure this property to be `true`, the SDK library would utilize
138
- * the [`typia.assertStringify<T>()
139
- * function`](https://github.com/samchon/typia#enhanced-json) to boost up JSON
140
- * serialization speed and ensure type safety.
150
+ * Generates specialized JSON serialization for JSON and encrypted request
151
+ * bodies.
141
152
  *
142
- * This option would make your SDK library compilation time a little bit
143
- * slower, but would enhance JSON serialization speed 10x faster. Also, it can
144
- * ensure type safety even in the runtime level.
153
+ * When enabled, the SDK emits a `typia.json.assertStringify` function for the
154
+ * body type. With `assert` enabled, argument validation runs separately and
155
+ * serialization uses `typia.json.stringify` without repeating the assertion.
156
+ * Compilation and runtime costs depend on the body type and workload.
145
157
  *
146
158
  * @default false
147
159
  */
@@ -151,6 +163,12 @@ export namespace INestiaConfig {
151
163
  /**
152
164
  * List of files or directories to include or exclude to specifying the NestJS
153
165
  * controllers.
166
+ *
167
+ * @evidence contracts/common.md#principled-implementation Include lists select controller files or directories and exclude lists remove files from that selection.
168
+ * @evidence contracts/common.md#clear-and-simple-design A two-member record.
169
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
170
+ * @evidence contracts/common.md#meaningful-documentation The comment states what the type describes and the meaning of its members.
171
+ * @evidence contracts/portability.md#os-neutral-implementation Include and exclude strings represent native files, directories or glob patterns. SourceFinder owns resolving them against the current working directory and distinguishing literal existing paths from wildcard suffixes.
154
172
  */
155
173
  export interface IInput {
156
174
  /** List of files or directories containing the NestJS controller classes. */
@@ -160,7 +178,15 @@ export namespace INestiaConfig {
160
178
  exclude?: string[];
161
179
  }
162
180
 
163
- /** Building `swagger.json` is also possible. */
181
+ /**
182
+ * Building `swagger.json` is also possible.
183
+ *
184
+ * @evidence contracts/common.md#principled-implementation The output path is required and every other option refines the composed OpenAPI document before it is written.
185
+ * @evidence contracts/common.md#clear-and-simple-design A flat record of options with one callback.
186
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
187
+ * @evidence contracts/common.md#meaningful-documentation The comment states what the type describes and the meaning of its members.
188
+ * @evidence contracts/portability.md#os-neutral-implementation output is a native destination interpreted by path.parse/resolve in SwaggerGenerator; a nonempty extension denotes a file and otherwise the destination is a directory. Server URLs and operation paths retain protocol spelling independently of that filesystem boundary.
189
+ */
164
190
  export interface ISwaggerConfig {
165
191
  /**
166
192
  * Response path of the `swagger.json`.
@@ -174,12 +200,11 @@ export namespace INestiaConfig {
174
200
  /**
175
201
  * OpenAPI version.
176
202
  *
177
- * If you configure this property to be `2.0` or `3.0`, the newly generated
178
- * `swagger.json` file would follow the specified OpenAPI version. The newly
179
- * generated `swagger.json` file would be downgraded from the OpenAPI v3.1
180
- * specification by {@link OpenApi.downgrade} method.
203
+ * If you configure this property to be `2.0`, `3.0`, or `3.1`, the newly
204
+ * generated `swagger.json` file would follow the specified OpenAPI version,
205
+ * downgraded from the OpenAPI v3.2 specification.
181
206
  *
182
- * @default 3.1
207
+ * @default 3.2
183
208
  */
184
209
  openapi?: "2.0" | "3.0" | "3.1" | "3.2";
185
210
 
@@ -199,10 +224,12 @@ export namespace INestiaConfig {
199
224
  * Whether to include additional information or not.
200
225
  *
201
226
  * If configured to be `true`, those properties would be added into each API
202
- * endpoinnt.
227
+ * endpoint.
203
228
  *
204
- * - `x-nestia-method`
205
- * - `x-nestia-namespace` ` `x-nestia-jsDocTags`
229
+ * - `x-nestia-method`: the HTTP method, such as `"GET"`
230
+ * - `x-nestia-namespace`: the SDK function's accessor, such as
231
+ * `"bbs.articles.index"`
232
+ * - `x-nestia-jsDocTags`: the JSDoc tags of the controller method
206
233
  *
207
234
  * @default false
208
235
  */
@@ -223,7 +250,10 @@ export namespace INestiaConfig {
223
250
  *
224
251
  * When generating `swagger.json` file through `nestia`, if your controllers
225
252
  * or theirs methods have a security key which is not enrolled in here
226
- * property, it would be an error.
253
+ * property, it would be an error. So would an OAuth2 scope none of the
254
+ * scheme's flows declares, and, for an OpenAPI `3.0` or `2.0` document,
255
+ * scopes on a scheme other than OAuth2 or OpenID Connect, which those
256
+ * versions require to be empty; from `3.1` on they list role names.
227
257
  */
228
258
  security?: Record<string, OpenApi.ISecurityScheme>;
229
259
 
@@ -245,7 +275,12 @@ export namespace INestiaConfig {
245
275
  * If you configure this property to be `true`, the query DTO would be
246
276
  * decomposed into individual query parameters per each property. Otherwise
247
277
  * you set it to be `false`, the query DTO would be one object type which
248
- * contains all of query parameters.
278
+ * contains all of query parameters, spread into its keys by `style: form`
279
+ * and `explode: true`.
280
+ *
281
+ * Swagger 2.0 has no object query parameter, and no OpenAPI version can
282
+ * spread an object into headers, so a query DTO of a Swagger 2.0 document
283
+ * and a headers DTO are decomposed regardless of this property.
249
284
  *
250
285
  * @default true
251
286
  */
@@ -256,6 +291,11 @@ export namespace INestiaConfig {
256
291
  *
257
292
  * @param props Properties of the API endpoint.
258
293
  * @returns Operation ID.
294
+ * @evidence contracts/common.md#principled-implementation An explicit @operationId tag takes precedence; otherwise this callback receives the four identifying facts once for the composed operation and supplies its identifier.
295
+ * @evidence contracts/common.md#clear-and-simple-design One optional callback with a single argument object.
296
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a caller-supplied function and nothing about a particular naming scheme is built in.
297
+ * @evidence contracts/common.md#meaningful-documentation The comment documents the arguments and the result.
298
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation This callback receives HTTP endpoint identity and returns an OpenAPI identifier; it owns no native pathname or process boundary.
259
299
  */
260
300
  operationId?(props: {
261
301
  class: string;
@@ -25,9 +25,34 @@ import { ITypedWebSocketRoute } from "./structures/ITypedWebSocketRoute";
25
25
  import { StringUtil } from "./utils/StringUtil";
26
26
  import { VersioningStrategy } from "./utils/VersioningStrategy";
27
27
 
28
+ /**
29
+ * Runs the generators of `@nestia/sdk` over one configuration.
30
+ *
31
+ * Each method validates the configuration for the output it needs, analyzes the
32
+ * controllers and the TypeScript metadata, reports every error at once, and
33
+ * then generates.
34
+ *
35
+ * @evidence contracts/common.md#principled-implementation The shared pipeline reflects controllers, types routes from transform metadata, assigns accessors and rejects collected analysis errors before writing. SDK-specific representability checks are attached by sdk and SDK-producing all; e2e currently invokes the SDK writer without that additional validation callback.
36
+ * @evidence contracts/common.md#clear-and-simple-design One class with four public generators over one private pipeline; directory assertion, title, and error report are module-private helpers.
37
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts No controller or route name is special-cased; the same pipeline serves the CLI and programmatic callers.
38
+ * @evidence contracts/common.md#meaningful-documentation The comment states the four generators and that the errors of an analysis are reported together.
39
+ * @evidence contracts/portability.md#os-neutral-implementation Output checks and diagnostic locations use Node fs.stat and path operations; controller compilation and output writes remain owned by ConfigAnalyzer and the generators. Filesystem errors distinguish missing/non-directory locations from other native failures.
40
+ */
28
41
  export class NestiaSdkApplication {
29
42
  public constructor(private readonly config: INestiaConfig) {}
30
43
 
44
+ /**
45
+ * Generates everything the configuration asks for: the SDK and its e2e tests
46
+ * when `output` is set, and the Swagger document when `swagger` is set.
47
+ *
48
+ * It throws when neither `output` nor `swagger.output` is configured.
49
+ *
50
+ * @evidence contracts/common.md#principled-implementation The SDK validation is attached only when an SDK is generated, so a Swagger-only run does not fail on SDK rules, and the e2e tests are generated after the SDK they import.
51
+ * @evidence contracts/common.md#clear-and-simple-design One method that composes the generators inside the shared pipeline.
52
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The error names the properties a caller can configure; none is stale.
53
+ * @evidence contracts/common.md#meaningful-documentation The comment states what is generated and the failure.
54
+ * @evidence contracts/portability.md#os-neutral-implementation all delegates configured output creation to the native writers and does not apply the explicit parent-directory checks used by sdk/e2e/swagger. Diagnostic source paths are rendered relative to the current native working directory.
55
+ */
31
56
  public async all(): Promise<void> {
32
57
  if (!this.config.output && !this.config.swagger?.output)
33
58
  throw new Error(
@@ -36,7 +61,6 @@ export class NestiaSdkApplication {
36
61
  "",
37
62
  " - INestiaConfig.output",
38
63
  " - INestiaConfig.swagger.output",
39
- " - INestiaConfig.openai.output",
40
64
  ].join("\n"),
41
65
  );
42
66
  print_title("Nestia All Generator");
@@ -52,6 +76,18 @@ export class NestiaSdkApplication {
52
76
  });
53
77
  }
54
78
 
79
+ /**
80
+ * Generates the SDK and the automatic e2e test functions.
81
+ *
82
+ * It throws when `output` or `e2e` is missing, or when the parent directory
83
+ * of either does not exist.
84
+ *
85
+ * @evidence contracts/common.md#principled-implementation The e2e functions import the generated SDK, so the SDK is generated first, and both parent directories are asserted before any analysis runs.
86
+ * @evidence contracts/common.md#clear-and-simple-design One method over the shared pipeline.
87
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The directory check follows the configuration and no path is special-cased.
88
+ * @evidence contracts/common.md#meaningful-documentation The comment states the requirements and the failures.
89
+ * @evidence contracts/portability.md#os-neutral-implementation path.resolve obtains each native parent and fs.stat follows symlinks to verify a directory before analysis. ENOENT/ENOTDIR become configuration diagnostics; permission and other filesystem errors propagate without a platform-specific shell fallback.
90
+ */
55
91
  public async e2e(): Promise<void> {
56
92
  if (!this.config.output)
57
93
  throw new Error(
@@ -62,18 +98,18 @@ export class NestiaSdkApplication {
62
98
  "Error on NestiaApplication.e2e(): configure INestiaConfig.e2e property.",
63
99
  );
64
100
 
65
- const validate =
66
- (title: string) =>
67
- async (location: string): Promise<void> => {
68
- const parent: string = path.resolve(location + "/..");
69
- const stats: fs.Stats = await fs.promises.lstat(parent);
70
- if (stats.isDirectory() === false)
71
- throw new Error(
72
- `Error on NestiaApplication.e2e(): output directory of ${title} does not exists.`,
73
- );
74
- };
75
- await validate("sdk")(this.config.output);
76
- await validate("e2e")(this.config.e2e);
101
+ await assertDirectory({
102
+ method: "e2e",
103
+ property: "output",
104
+ location: this.config.output,
105
+ directory: path.resolve(this.config.output + "/.."),
106
+ });
107
+ await assertDirectory({
108
+ method: "e2e",
109
+ property: "e2e",
110
+ location: this.config.e2e,
111
+ directory: path.resolve(this.config.e2e + "/.."),
112
+ });
77
113
 
78
114
  print_title("Nestia E2E Generator");
79
115
  await this.generate({
@@ -84,18 +120,29 @@ export class NestiaSdkApplication {
84
120
  });
85
121
  }
86
122
 
123
+ /**
124
+ * Generates the SDK library.
125
+ *
126
+ * It throws when `output` is missing or its parent directory does not exist.
127
+ *
128
+ * @evidence contracts/common.md#principled-implementation The SDK validation runs after route typing and before the generator, so a route the SDK cannot express is reported instead of written.
129
+ * @evidence contracts/common.md#clear-and-simple-design One method over the shared pipeline.
130
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The directory check follows the configuration.
131
+ * @evidence contracts/common.md#meaningful-documentation The comment states the requirement and the failures.
132
+ * @evidence contracts/portability.md#os-neutral-implementation The configured output parent is resolved through Node path and verified by fs.stat, including linked directories. Generator writes use their own native boundaries; this entry does not infer case identity from an OS name.
133
+ */
87
134
  public async sdk(): Promise<void> {
88
135
  if (!this.config.output)
89
136
  throw new Error(
90
137
  "Error on NestiaApplication.sdk(): configure INestiaConfig.output property.",
91
138
  );
92
139
 
93
- const parent: string = path.resolve(this.config.output + "/..");
94
- const stats: fs.Stats = await fs.promises.lstat(parent);
95
- if (stats.isDirectory() === false)
96
- throw new Error(
97
- "Error on NestiaApplication.sdk(): output directory does not exists.",
98
- );
140
+ await assertDirectory({
141
+ method: "sdk",
142
+ property: "output",
143
+ location: this.config.output,
144
+ directory: path.resolve(this.config.output + "/.."),
145
+ });
99
146
 
100
147
  print_title("Nestia SDK Generator");
101
148
  await this.generate({
@@ -104,6 +151,18 @@ export class NestiaSdkApplication {
104
151
  });
105
152
  }
106
153
 
154
+ /**
155
+ * Generates the Swagger document.
156
+ *
157
+ * It throws when `swagger.output` is missing or the directory that will hold
158
+ * the document does not exist; the output may be a file or a directory.
159
+ *
160
+ * @evidence contracts/common.md#principled-implementation The directory to check is the parent of a file path with an extension and the path itself otherwise, which is how the generator decides where to write.
161
+ * @evidence contracts/common.md#clear-and-simple-design One method over the shared pipeline.
162
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The rule is the generator's own output rule.
163
+ * @evidence contracts/common.md#meaningful-documentation The comment states the requirement and the two output forms.
164
+ * @evidence contracts/portability.md#os-neutral-implementation path.parse/resolve decide the native containing directory from whether the output has an extension, matching SwaggerGenerator's destination rule. The common directory check distinguishes missing paths from non-directory entries and propagates other filesystem errors.
165
+ */
107
166
  public async swagger(): Promise<void> {
108
167
  if (!this.config.swagger?.output)
109
168
  throw new Error(
@@ -111,14 +170,14 @@ export class NestiaSdkApplication {
111
170
  );
112
171
 
113
172
  const parsed: path.ParsedPath = path.parse(this.config.swagger.output);
114
- const directory: string = !!parsed.ext
115
- ? path.resolve(parsed.dir)
116
- : this.config.swagger.output;
117
- const stats: fs.Stats = await fs.promises.lstat(directory);
118
- if (stats.isDirectory() === false)
119
- throw new Error(
120
- "Error on NestiaApplication.swagger(): output directory does not exists.",
121
- );
173
+ await assertDirectory({
174
+ method: "swagger",
175
+ property: "swagger.output",
176
+ location: this.config.swagger.output,
177
+ directory: !!parsed.ext
178
+ ? path.resolve(parsed.dir)
179
+ : path.resolve(this.config.swagger.output),
180
+ });
122
181
 
123
182
  print_title("Nestia Swagger Generator");
124
183
  await this.generate({
@@ -198,10 +257,6 @@ export class NestiaSdkApplication {
198
257
  //----
199
258
  console.log("Analyzing source codes");
200
259
 
201
- // METADATA COMPONENTS
202
- const sourceCollection: IMetadataDictionary =
203
- TypedHttpRouteAnalyzer.dictionary(controllers);
204
-
205
260
  // CONVERT TO TYPED OPERATIONS
206
261
  const routes: Array<
207
262
  ITypedHttpRoute | ITypedWebSocketRoute | ITypedMcpRoute
@@ -213,15 +268,17 @@ export class NestiaSdkApplication {
213
268
  ...TypedMcpRouteAnalyzer.analyze({
214
269
  controller: c,
215
270
  operation: o,
271
+ clone: project.config.clone,
272
+ errors: project.errors,
216
273
  }),
217
274
  );
218
275
  continue;
219
276
  }
220
277
  const pathList: Set<string> = new Set();
221
- const versions: string[] = VersioningStrategy.merge(project)([
222
- ...(c.versions ?? []),
223
- ...(o.versions ?? []),
224
- ]);
278
+ const versions: string[] = VersioningStrategy.merge(project)({
279
+ controller: c.versions,
280
+ method: o.versions,
281
+ });
225
282
  for (const v of versions)
226
283
  for (const prefix of wrapPaths(c.prefixes))
227
284
  for (const cPath of wrapPaths(c.paths))
@@ -246,7 +303,6 @@ export class NestiaSdkApplication {
246
303
  ...TypedHttpRouteAnalyzer.analyze({
247
304
  controller: c,
248
305
  errors: project.errors,
249
- dictionary: sourceCollection,
250
306
  operation: o,
251
307
  paths: Array.from(pathList),
252
308
  }),
@@ -264,7 +320,10 @@ export class NestiaSdkApplication {
264
320
 
265
321
  const collection: IMetadataDictionary =
266
322
  TypedHttpRouteAnalyzer.routeDictionary(
267
- routes.filter((r): r is ITypedHttpRoute => r.protocol === "http"),
323
+ routes.filter(
324
+ (r): r is ITypedHttpRoute | ITypedMcpRoute =>
325
+ r.protocol !== "websocket",
326
+ ),
268
327
  );
269
328
 
270
329
  if (props.validate !== undefined)
@@ -288,6 +347,30 @@ export class NestiaSdkApplication {
288
347
  }
289
348
  }
290
349
 
350
+ /**
351
+ * Asserts the directory an output is written into exists, naming the configured
352
+ * location. `fs.promises.stat()` itself rejects a missing path, so it is caught
353
+ * rather than left to surface as a bare `ENOENT`; a symbolic link to a
354
+ * directory is followed.
355
+ */
356
+ const assertDirectory = async (props: {
357
+ method: string;
358
+ property: string;
359
+ location: string;
360
+ directory: string;
361
+ }): Promise<void> => {
362
+ const stats: fs.Stats | null = await fs.promises
363
+ .stat(props.directory)
364
+ .catch((error: NodeJS.ErrnoException): null => {
365
+ if (error.code === "ENOENT" || error.code === "ENOTDIR") return null;
366
+ throw error;
367
+ });
368
+ if (stats === null || stats.isDirectory() === false)
369
+ throw new Error(
370
+ `Error on NestiaApplication.${props.method}(): directory ${JSON.stringify(props.directory)} of INestiaConfig.${props.property} ${JSON.stringify(props.location)} ${stats === null ? "does not exist" : "is not a directory"}.`,
371
+ );
372
+ };
373
+
291
374
  const print_title = (str: string): void => {
292
375
  console.log("-----------------------------------------------------------");
293
376
  console.log(` ${str}`);
@@ -308,6 +391,8 @@ const report = (props: {
308
391
  console.log("");
309
392
  print_title(`Nestia ${StringUtil.capitalize(props.type)} Report`);
310
393
 
394
+ // every contradiction at once, not only the first function's
395
+ const messages: string[] = [];
311
396
  for (const {
312
397
  first: { error },
313
398
  second: contents,
@@ -318,24 +403,27 @@ const report = (props: {
318
403
  `${location} - `,
319
404
  error.class,
320
405
  ...(error.function !== null ? [`.${error.function}()`] : [""]),
321
- ...(error.from !== null ? [` from ${error.from}`] : [""]),
406
+ // an empty origin names no part of the function
407
+ ...(error.from ? [` from ${error.from}`] : [""]),
322
408
  ":\n",
323
409
  contents
324
410
  .map((c) => {
325
411
  if (typeof c === "string") return ` - ${c}`;
326
412
  else
327
413
  return [
414
+ // the property the type was found at, when there is one
328
415
  c.accessor
329
- ? ` - ${c.name}: `
330
- : ` - ${c.name} (${c.accessor}): `,
416
+ ? ` - ${c.name} (${c.accessor}): `
417
+ : ` - ${c.name}: `,
331
418
  ...c.messages.map((msg) => ` - ${msg}`),
332
419
  ].join("\n");
333
420
  })
334
421
  .join("\n"),
335
422
  ].join("");
336
- if (props.type === "error") throw new Error(message);
423
+ if (props.type === "error") messages.push(message);
337
424
  else console.log(message);
338
425
  }
426
+ if (messages.length !== 0) throw new Error(messages.join("\n\n"));
339
427
  };
340
428
 
341
429
  const wrapPaths = (paths: string[]): string[] =>
@@ -12,7 +12,6 @@ import { PathAnalyzer } from "./analyses/PathAnalyzer";
12
12
  import { ReflectControllerAnalyzer } from "./analyses/ReflectControllerAnalyzer";
13
13
  import { TypedHttpRouteAnalyzer } from "./analyses/TypedHttpRouteAnalyzer";
14
14
  import { SwaggerGenerator } from "./generates/SwaggerGenerator";
15
- import { IMetadataDictionary } from "./internal/legacy";
16
15
  import { INestiaProject } from "./structures/INestiaProject";
17
16
  import { INestiaSdkInput } from "./structures/INestiaSdkInput";
18
17
  import { IOperationMetadata } from "./structures/IOperationMetadata";
@@ -21,7 +20,28 @@ import { IReflectOperationError } from "./structures/IReflectOperationError";
21
20
  import { ITypedHttpRoute } from "./structures/ITypedHttpRoute";
22
21
  import { VersioningStrategy } from "./utils/VersioningStrategy";
23
22
 
23
+ /**
24
+ * Composes the Swagger document of a running NestJS application, without files.
25
+ *
26
+ * @evidence contracts/common.md#principled-implementation The controllers are taken from the application's module graph and analyzed like the CLI does, and only the HTTP routes are composed.
27
+ * @evidence contracts/common.md#clear-and-simple-design One public function with a private analysis pipeline.
28
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It uses the same analyzers and composer as the CLI, so both produce one document.
29
+ * @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
30
+ * @evidence contracts/portability.md#os-neutral-implementation Controller source lookup is delegated to ConfigAnalyzer.application; diagnostic filenames use Node path.relative from process.cwd. Route paths and versions remain protocol text rather than native filesystem identity.
31
+ */
24
32
  export namespace NestiaSwaggerComposer {
33
+ /**
34
+ * Returns the OpenAPI document of the application in the requested version.
35
+ *
36
+ * The document is composed as OpenAPI 3.2 and converted to the configured
37
+ * older version; every analysis error is collected and thrown together.
38
+ *
39
+ * @evidence contracts/common.md#principled-implementation Composition runs at the newest version and `OpenApiConverter.downgradeDocument` produces the older ones, so version differences live in one converter, and a failure of the analysis throws one error that lists every problem.
40
+ * @evidence contracts/common.md#clear-and-simple-design One function over the shared analyzers and the Swagger generator.
41
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts No route is special-cased; the module graph is read through `ConfigAnalyzer.application`.
42
+ * @evidence contracts/common.md#meaningful-documentation The comment states the returned versions and the error behavior.
43
+ * @evidence contracts/portability.md#os-neutral-implementation The composer receives an existing application and writes no output file. Its delegated controller discovery obtains native source locations, and its report renders those locations through path.relative; initialize may read package metadata for default info.
44
+ */
25
45
  export const document = async (
26
46
  app: INestApplication,
27
47
  config: Omit<INestiaConfig.ISwaggerConfig, "output">,
@@ -58,20 +78,16 @@ export namespace NestiaSwaggerComposer {
58
78
  if (project.errors.length)
59
79
  throw report({ type: "error", errors: project.errors });
60
80
 
61
- // METADATA COMPONENTS
62
- const collection: IMetadataDictionary =
63
- TypedHttpRouteAnalyzer.dictionary(controllers);
64
-
65
81
  // CONVERT TO TYPED OPERATIONS
66
82
  const routes: ITypedHttpRoute[] = [];
67
83
  for (const c of controllers)
68
84
  for (const o of c.operations) {
69
85
  if (o.protocol !== "http") continue;
70
86
  const pathList: Set<string> = new Set();
71
- const versions: string[] = VersioningStrategy.merge(project)([
72
- ...(c.versions ?? []),
73
- ...(o.versions ?? []),
74
- ]);
87
+ const versions: string[] = VersioningStrategy.merge(project)({
88
+ controller: c.versions,
89
+ method: o.versions,
90
+ });
75
91
  for (const v of versions)
76
92
  for (const prefix of wrapPaths(c.prefixes))
77
93
  for (const cPath of wrapPaths(c.paths))
@@ -95,7 +111,6 @@ export namespace NestiaSwaggerComposer {
95
111
  ...TypedHttpRouteAnalyzer.analyze({
96
112
  controller: c,
97
113
  errors: project.errors,
98
- dictionary: collection,
99
114
  operation: o,
100
115
  paths: Array.from(pathList),
101
116
  }),
@@ -131,7 +146,8 @@ const report = (props: {
131
146
  `${location} - `,
132
147
  error.class,
133
148
  ...(error.function !== null ? [`.${error.function}()`] : [""]),
134
- ...(error.from !== null ? [` from ${error.from}`] : [""]),
149
+ // an empty origin names no part of the function
150
+ ...(error.from ? [` from ${error.from}`] : [""]),
135
151
  ":\n",
136
152
  contents
137
153
  .map((c) => {
@@ -139,8 +155,8 @@ const report = (props: {
139
155
  else
140
156
  return [
141
157
  c.accessor
142
- ? ` - ${c.name}: `
143
- : ` - ${c.name} (${c.accessor}): `,
158
+ ? ` - ${c.name} (${c.accessor}): `
159
+ : ` - ${c.name}: `,
144
160
  ...c.messages.map((msg) => ` - ${msg}`),
145
161
  ].join("\n");
146
162
  })
@@ -148,7 +164,9 @@ const report = (props: {
148
164
  ].join(""),
149
165
  );
150
166
  }
151
- throw new Error(`Error on NestiaSwaggerComposer.compose():\n${messages}`);
167
+ throw new Error(
168
+ `Error on NestiaSwaggerComposer.compose():\n${messages.join("\n\n")}`,
169
+ );
152
170
  };
153
171
 
154
172
  const wrapPaths = (paths: string[]): string[] =>