@nestia/sdk 14.0.1 → 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 (377) hide show
  1. package/assets/bundle/distribute/build-sdk.cjs +28 -0
  2. package/assets/bundle/distribute/package.json +6 -2
  3. package/lib/INestiaConfig.d.ts +55 -24
  4. package/lib/NestiaSdkApplication.d.ts +60 -0
  5. package/lib/NestiaSdkApplication.js +63 -5
  6. package/lib/NestiaSdkApplication.js.map +1 -1
  7. package/lib/NestiaSwaggerComposer.d.ts +21 -0
  8. package/lib/NestiaSwaggerComposer.js +21 -3
  9. package/lib/NestiaSwaggerComposer.js.map +1 -1
  10. package/lib/analyses/AccessorAnalyzer.d.ts +26 -0
  11. package/lib/analyses/AccessorAnalyzer.js +26 -0
  12. package/lib/analyses/AccessorAnalyzer.js.map +1 -1
  13. package/lib/analyses/ConfigAnalyzer.d.ts +41 -0
  14. package/lib/analyses/ConfigAnalyzer.js +48 -73
  15. package/lib/analyses/ConfigAnalyzer.js.map +1 -1
  16. package/lib/analyses/ImportAnalyzer.d.ts +25 -0
  17. package/lib/analyses/ImportAnalyzer.js +25 -0
  18. package/lib/analyses/ImportAnalyzer.js.map +1 -1
  19. package/lib/analyses/ParameterNameAnalyzer.d.ts +24 -0
  20. package/lib/analyses/ParameterNameAnalyzer.js +15 -0
  21. package/lib/analyses/ParameterNameAnalyzer.js.map +1 -1
  22. package/lib/analyses/PathAnalyzer.d.ts +63 -1
  23. package/lib/analyses/PathAnalyzer.js +54 -9
  24. package/lib/analyses/PathAnalyzer.js.map +1 -1
  25. package/lib/analyses/ReflectControllerAnalyzer.d.ts +32 -0
  26. package/lib/analyses/ReflectControllerAnalyzer.js +22 -0
  27. package/lib/analyses/ReflectControllerAnalyzer.js.map +1 -1
  28. package/lib/analyses/ReflectHttpOperationAnalyzer.d.ts +29 -0
  29. package/lib/analyses/ReflectHttpOperationAnalyzer.js +28 -17
  30. package/lib/analyses/ReflectHttpOperationAnalyzer.js.map +1 -1
  31. package/lib/analyses/ReflectHttpOperationExceptionAnalyzer.d.ts +31 -0
  32. package/lib/analyses/ReflectHttpOperationExceptionAnalyzer.js +21 -0
  33. package/lib/analyses/ReflectHttpOperationExceptionAnalyzer.js.map +1 -1
  34. package/lib/analyses/ReflectHttpOperationParameterAnalyzer.d.ts +31 -0
  35. package/lib/analyses/ReflectHttpOperationParameterAnalyzer.js +21 -0
  36. package/lib/analyses/ReflectHttpOperationParameterAnalyzer.js.map +1 -1
  37. package/lib/analyses/ReflectHttpOperationResponseAnalyzer.d.ts +32 -0
  38. package/lib/analyses/ReflectHttpOperationResponseAnalyzer.js +22 -0
  39. package/lib/analyses/ReflectHttpOperationResponseAnalyzer.js.map +1 -1
  40. package/lib/analyses/ReflectMcpOperationAnalyzer.d.ts +29 -0
  41. package/lib/analyses/ReflectMcpOperationAnalyzer.js +30 -9
  42. package/lib/analyses/ReflectMcpOperationAnalyzer.js.map +1 -1
  43. package/lib/analyses/ReflectMetadataAnalyzer.d.ts +47 -0
  44. package/lib/analyses/ReflectMetadataAnalyzer.js +47 -0
  45. package/lib/analyses/ReflectMetadataAnalyzer.js.map +1 -1
  46. package/lib/analyses/ReflectWebSocketOperationAnalyzer.d.ts +29 -0
  47. package/lib/analyses/ReflectWebSocketOperationAnalyzer.js +21 -2
  48. package/lib/analyses/ReflectWebSocketOperationAnalyzer.js.map +1 -1
  49. package/lib/analyses/SecurityAnalyzer.d.ts +15 -0
  50. package/lib/analyses/SecurityAnalyzer.js +15 -0
  51. package/lib/analyses/SecurityAnalyzer.js.map +1 -1
  52. package/lib/analyses/SwaggerExampleAnalyzer.d.ts +16 -0
  53. package/lib/analyses/SwaggerExampleAnalyzer.js +16 -0
  54. package/lib/analyses/SwaggerExampleAnalyzer.js.map +1 -1
  55. package/lib/analyses/TypedHttpRouteAnalyzer.d.ts +41 -3
  56. package/lib/analyses/TypedHttpRouteAnalyzer.js +172 -157
  57. package/lib/analyses/TypedHttpRouteAnalyzer.js.map +1 -1
  58. package/lib/analyses/TypedMcpRouteAnalyzer.d.ts +29 -0
  59. package/lib/analyses/TypedMcpRouteAnalyzer.js +152 -20
  60. package/lib/analyses/TypedMcpRouteAnalyzer.js.map +1 -1
  61. package/lib/analyses/TypedWebSocketRouteAnalyzer.d.ts +19 -0
  62. package/lib/analyses/TypedWebSocketRouteAnalyzer.js +19 -0
  63. package/lib/analyses/TypedWebSocketRouteAnalyzer.js.map +1 -1
  64. package/lib/decorators/OperationMetadata.d.ts +6 -0
  65. package/lib/decorators/OperationMetadata.js +6 -0
  66. package/lib/decorators/OperationMetadata.js.map +1 -1
  67. package/lib/executable/internal/CommandParser.d.ts +19 -0
  68. package/lib/executable/internal/CommandParser.js +19 -0
  69. package/lib/executable/internal/CommandParser.js.map +1 -1
  70. package/lib/executable/internal/NestiaConfigLoader.d.ts +56 -0
  71. package/lib/executable/internal/NestiaConfigLoader.js +48 -42
  72. package/lib/executable/internal/NestiaConfigLoader.js.map +1 -1
  73. package/lib/executable/internal/NestiaSdkCommand.d.ts +60 -0
  74. package/lib/executable/internal/NestiaSdkCommand.js +95 -3
  75. package/lib/executable/internal/NestiaSdkCommand.js.map +1 -1
  76. package/lib/executable/internal/NestiaSdkWatcher.d.ts +81 -0
  77. package/lib/executable/internal/NestiaSdkWatcher.js +122 -38
  78. package/lib/executable/internal/NestiaSdkWatcher.js.map +1 -1
  79. package/lib/executable/internal/NestiaSwaggerWatch.d.ts +80 -0
  80. package/lib/executable/internal/NestiaSwaggerWatch.js +308 -0
  81. package/lib/executable/internal/NestiaSwaggerWatch.js.map +1 -0
  82. package/lib/factories/ExpressionFactory.d.ts +17 -2
  83. package/lib/factories/ExpressionFactory.js +17 -2
  84. package/lib/factories/ExpressionFactory.js.map +1 -1
  85. package/lib/factories/IdentifierFactory.d.ts +24 -0
  86. package/lib/factories/IdentifierFactory.js +24 -0
  87. package/lib/factories/IdentifierFactory.js.map +1 -1
  88. package/lib/factories/LiteralFactory.d.ts +22 -4
  89. package/lib/factories/LiteralFactory.js +30 -10
  90. package/lib/factories/LiteralFactory.js.map +1 -1
  91. package/lib/factories/StatementFactory.d.ts +28 -1
  92. package/lib/factories/StatementFactory.js +28 -1
  93. package/lib/factories/StatementFactory.js.map +1 -1
  94. package/lib/factories/TypeFactory.d.ts +24 -0
  95. package/lib/factories/TypeFactory.js +15 -0
  96. package/lib/factories/TypeFactory.js.map +1 -1
  97. package/lib/generates/CloneGenerator.d.ts +22 -0
  98. package/lib/generates/CloneGenerator.js +26 -5
  99. package/lib/generates/CloneGenerator.js.map +1 -1
  100. package/lib/generates/E2eGenerator.d.ts +19 -0
  101. package/lib/generates/E2eGenerator.js +19 -0
  102. package/lib/generates/E2eGenerator.js.map +1 -1
  103. package/lib/generates/SdkGenerator.d.ts +38 -0
  104. package/lib/generates/SdkGenerator.js +40 -2
  105. package/lib/generates/SdkGenerator.js.map +1 -1
  106. package/lib/generates/SwaggerGenerator.d.ts +36 -6
  107. package/lib/generates/SwaggerGenerator.js +55 -13
  108. package/lib/generates/SwaggerGenerator.js.map +1 -1
  109. package/lib/generates/internal/E2eFileProgrammer.d.ts +19 -0
  110. package/lib/generates/internal/E2eFileProgrammer.js +20 -1
  111. package/lib/generates/internal/E2eFileProgrammer.js.map +1 -1
  112. package/lib/generates/internal/FilePrinter.d.ts +43 -0
  113. package/lib/generates/internal/FilePrinter.js +43 -0
  114. package/lib/generates/internal/FilePrinter.js.map +1 -1
  115. package/lib/generates/internal/ImportDictionary.d.ts +92 -2
  116. package/lib/generates/internal/ImportDictionary.js +91 -3
  117. package/lib/generates/internal/ImportDictionary.js.map +1 -1
  118. package/lib/generates/internal/SdkAliasCollection.d.ts +119 -0
  119. package/lib/generates/internal/SdkAliasCollection.js +124 -7
  120. package/lib/generates/internal/SdkAliasCollection.js.map +1 -1
  121. package/lib/generates/internal/SdkDistributionComposer.d.ts +19 -0
  122. package/lib/generates/internal/SdkDistributionComposer.js +98 -59
  123. package/lib/generates/internal/SdkDistributionComposer.js.map +1 -1
  124. package/lib/generates/internal/SdkFileProgrammer.d.ts +18 -0
  125. package/lib/generates/internal/SdkFileProgrammer.js +18 -0
  126. package/lib/generates/internal/SdkFileProgrammer.js.map +1 -1
  127. package/lib/generates/internal/SdkHttpCloneProgrammer.d.ts +29 -0
  128. package/lib/generates/internal/SdkHttpCloneProgrammer.js +33 -0
  129. package/lib/generates/internal/SdkHttpCloneProgrammer.js.map +1 -1
  130. package/lib/generates/internal/SdkHttpCloneReferencer.d.ts +19 -0
  131. package/lib/generates/internal/SdkHttpCloneReferencer.js +78 -25
  132. package/lib/generates/internal/SdkHttpCloneReferencer.js.map +1 -1
  133. package/lib/generates/internal/SdkHttpFunctionProgrammer.d.ts +19 -0
  134. package/lib/generates/internal/SdkHttpFunctionProgrammer.js +19 -0
  135. package/lib/generates/internal/SdkHttpFunctionProgrammer.js.map +1 -1
  136. package/lib/generates/internal/SdkHttpNamespaceProgrammer.d.ts +19 -0
  137. package/lib/generates/internal/SdkHttpNamespaceProgrammer.js +19 -0
  138. package/lib/generates/internal/SdkHttpNamespaceProgrammer.js.map +1 -1
  139. package/lib/generates/internal/SdkHttpParameterProgrammer.d.ts +104 -2
  140. package/lib/generates/internal/SdkHttpParameterProgrammer.js +70 -0
  141. package/lib/generates/internal/SdkHttpParameterProgrammer.js.map +1 -1
  142. package/lib/generates/internal/SdkHttpRouteProgrammer.d.ts +20 -0
  143. package/lib/generates/internal/SdkHttpRouteProgrammer.js +20 -0
  144. package/lib/generates/internal/SdkHttpRouteProgrammer.js.map +1 -1
  145. package/lib/generates/internal/SdkHttpSimulationProgrammer.d.ts +38 -0
  146. package/lib/generates/internal/SdkHttpSimulationProgrammer.js +49 -5
  147. package/lib/generates/internal/SdkHttpSimulationProgrammer.js.map +1 -1
  148. package/lib/generates/internal/SdkImportWizard.d.ts +63 -0
  149. package/lib/generates/internal/SdkImportWizard.js +63 -0
  150. package/lib/generates/internal/SdkImportWizard.js.map +1 -1
  151. package/lib/generates/internal/SdkMcpRouteProgrammer.d.ts +17 -2
  152. package/lib/generates/internal/SdkMcpRouteProgrammer.js +33 -13
  153. package/lib/generates/internal/SdkMcpRouteProgrammer.js.map +1 -1
  154. package/lib/generates/internal/SdkPathTemplate.d.ts +15 -0
  155. package/lib/generates/internal/SdkPathTemplate.js +15 -0
  156. package/lib/generates/internal/SdkPathTemplate.js.map +1 -1
  157. package/lib/generates/internal/SdkRouteDirectory.d.ts +10 -0
  158. package/lib/generates/internal/SdkRouteDirectory.js +10 -0
  159. package/lib/generates/internal/SdkRouteDirectory.js.map +1 -1
  160. package/lib/generates/internal/SdkTypeProgrammer.d.ts +54 -1
  161. package/lib/generates/internal/SdkTypeProgrammer.js +96 -12
  162. package/lib/generates/internal/SdkTypeProgrammer.js.map +1 -1
  163. package/lib/generates/internal/SdkTypeTagProgrammer.d.ts +36 -3
  164. package/lib/generates/internal/SdkTypeTagProgrammer.js +28 -7
  165. package/lib/generates/internal/SdkTypeTagProgrammer.js.map +1 -1
  166. package/lib/generates/internal/SdkWebSocketCloneProgrammer.d.ts +40 -0
  167. package/lib/generates/internal/SdkWebSocketCloneProgrammer.js +149 -142
  168. package/lib/generates/internal/SdkWebSocketCloneProgrammer.js.map +1 -1
  169. package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.d.ts +19 -0
  170. package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js +19 -0
  171. package/lib/generates/internal/SdkWebSocketNamespaceProgrammer.js.map +1 -1
  172. package/lib/generates/internal/SdkWebSocketParameterProgrammer.d.ts +81 -2
  173. package/lib/generates/internal/SdkWebSocketParameterProgrammer.js +48 -0
  174. package/lib/generates/internal/SdkWebSocketParameterProgrammer.js.map +1 -1
  175. package/lib/generates/internal/SdkWebSocketRouteProgrammer.d.ts +18 -0
  176. package/lib/generates/internal/SdkWebSocketRouteProgrammer.js +18 -0
  177. package/lib/generates/internal/SdkWebSocketRouteProgrammer.js.map +1 -1
  178. package/lib/generates/internal/SwaggerDescriptionComposer.d.ts +42 -0
  179. package/lib/generates/internal/SwaggerDescriptionComposer.js +44 -1
  180. package/lib/generates/internal/SwaggerDescriptionComposer.js.map +1 -1
  181. package/lib/generates/internal/SwaggerOperationComposer.d.ts +18 -0
  182. package/lib/generates/internal/SwaggerOperationComposer.js +18 -0
  183. package/lib/generates/internal/SwaggerOperationComposer.js.map +1 -1
  184. package/lib/generates/internal/SwaggerOperationParameterComposer.d.ts +39 -0
  185. package/lib/generates/internal/SwaggerOperationParameterComposer.js +31 -8
  186. package/lib/generates/internal/SwaggerOperationParameterComposer.js.map +1 -1
  187. package/lib/generates/internal/SwaggerOperationResponseComposer.d.ts +19 -0
  188. package/lib/generates/internal/SwaggerOperationResponseComposer.js +19 -0
  189. package/lib/generates/internal/SwaggerOperationResponseComposer.js.map +1 -1
  190. package/lib/internal/legacy.d.ts +296 -16
  191. package/lib/internal/legacy.js +127 -10
  192. package/lib/internal/legacy.js.map +1 -1
  193. package/lib/structures/INestiaProject.d.ts +10 -0
  194. package/lib/structures/INestiaSdkInput.d.ts +30 -0
  195. package/lib/structures/IOperationMetadata.d.ts +55 -0
  196. package/lib/structures/IReflectController.d.ts +10 -0
  197. package/lib/structures/IReflectHttpOperation.d.ts +10 -0
  198. package/lib/structures/IReflectHttpOperationException.d.ts +10 -0
  199. package/lib/structures/IReflectHttpOperationParameter.d.ts +47 -0
  200. package/lib/structures/IReflectHttpOperationSuccess.d.ts +11 -0
  201. package/lib/structures/IReflectImport.d.ts +10 -0
  202. package/lib/structures/IReflectMcpOperation.d.ts +19 -0
  203. package/lib/structures/IReflectMcpOperationParameter.d.ts +9 -0
  204. package/lib/structures/IReflectOperationError.d.ts +28 -0
  205. package/lib/structures/IReflectOperationError.js +22 -2
  206. package/lib/structures/IReflectOperationError.js.map +1 -1
  207. package/lib/structures/IReflectType.d.ts +9 -0
  208. package/lib/structures/IReflectWebSocketOperation.d.ts +10 -0
  209. package/lib/structures/IReflectWebSocketOperationParameter.d.ts +55 -0
  210. package/lib/structures/ITypedApplication.d.ts +10 -0
  211. package/lib/structures/ITypedHttpRoute.d.ts +10 -0
  212. package/lib/structures/ITypedHttpRouteException.d.ts +10 -0
  213. package/lib/structures/ITypedHttpRouteParameter.d.ts +45 -0
  214. package/lib/structures/ITypedHttpRouteSuccess.d.ts +10 -0
  215. package/lib/structures/ITypedMcpRoute.d.ts +11 -0
  216. package/lib/structures/ITypedWebSocketRoute.d.ts +10 -0
  217. package/lib/transform.d.ts +6 -0
  218. package/lib/transform.js +6 -0
  219. package/lib/transform.js.map +1 -1
  220. package/lib/utils/ArrayUtil.d.ts +31 -1
  221. package/lib/utils/ArrayUtil.js +32 -11
  222. package/lib/utils/ArrayUtil.js.map +1 -1
  223. package/lib/utils/EmittedJavaScriptPatcher.d.ts +20 -0
  224. package/lib/utils/EmittedJavaScriptPatcher.js +65 -46
  225. package/lib/utils/EmittedJavaScriptPatcher.js.map +1 -1
  226. package/lib/utils/FileRetriever.d.ts +29 -0
  227. package/lib/utils/FileRetriever.js +29 -0
  228. package/lib/utils/FileRetriever.js.map +1 -1
  229. package/lib/utils/HttpResponseContentTypeUtil.d.ts +41 -0
  230. package/lib/utils/HttpResponseContentTypeUtil.js +31 -0
  231. package/lib/utils/HttpResponseContentTypeUtil.js.map +1 -1
  232. package/lib/utils/MapUtil.d.ts +64 -1
  233. package/lib/utils/MapUtil.js +24 -3
  234. package/lib/utils/MapUtil.js.map +1 -1
  235. package/lib/utils/PathUtil.d.ts +31 -0
  236. package/lib/utils/PathUtil.js +38 -0
  237. package/lib/utils/PathUtil.js.map +1 -1
  238. package/lib/utils/SdkBundlePath.d.ts +2 -0
  239. package/lib/utils/SdkBundlePath.js +10 -0
  240. package/lib/utils/SdkBundlePath.js.map +1 -0
  241. package/lib/utils/SdkInputFilter.d.ts +31 -0
  242. package/lib/utils/SdkInputFilter.js +115 -0
  243. package/lib/utils/SdkInputFilter.js.map +1 -0
  244. package/lib/utils/SourceFinder.d.ts +35 -0
  245. package/lib/utils/SourceFinder.js +47 -12
  246. package/lib/utils/SourceFinder.js.map +1 -1
  247. package/lib/utils/StringUtil.d.ts +77 -2
  248. package/lib/utils/StringUtil.js +166 -4
  249. package/lib/utils/StringUtil.js.map +1 -1
  250. package/lib/utils/TemporaryDirectory.d.ts +60 -0
  251. package/lib/utils/TemporaryDirectory.js +112 -0
  252. package/lib/utils/TemporaryDirectory.js.map +1 -0
  253. package/lib/utils/TsConfigReader.d.ts +42 -0
  254. package/lib/utils/TsConfigReader.js +98 -14
  255. package/lib/utils/TsConfigReader.js.map +1 -1
  256. package/lib/utils/TtscExecutor.d.ts +23 -1
  257. package/lib/utils/TtscExecutor.js +22 -0
  258. package/lib/utils/TtscExecutor.js.map +1 -1
  259. package/lib/utils/VersioningStrategy.d.ts +26 -1
  260. package/lib/utils/VersioningStrategy.js +30 -9
  261. package/lib/utils/VersioningStrategy.js.map +1 -1
  262. package/lib/validators/TextPlainValidator.d.ts +19 -0
  263. package/lib/validators/TextPlainValidator.js +19 -0
  264. package/lib/validators/TextPlainValidator.js.map +1 -1
  265. package/native/go.mod +1 -1
  266. package/native/go.sum +2 -2
  267. package/native/sdk/register.go +12 -2
  268. package/native/sdk/sdk_metadata_json.go +6 -1
  269. package/native/sdk/sdk_transform.go +388 -397
  270. package/package.json +7 -5
  271. package/src/INestiaConfig.ts +55 -24
  272. package/src/NestiaSdkApplication.ts +66 -7
  273. package/src/NestiaSwaggerComposer.ts +21 -6
  274. package/src/analyses/AccessorAnalyzer.ts +26 -0
  275. package/src/analyses/ConfigAnalyzer.ts +49 -87
  276. package/src/analyses/ImportAnalyzer.ts +25 -0
  277. package/src/analyses/ParameterNameAnalyzer.ts +24 -0
  278. package/src/analyses/PathAnalyzer.ts +63 -11
  279. package/src/analyses/ReflectControllerAnalyzer.ts +32 -0
  280. package/src/analyses/ReflectHttpOperationAnalyzer.ts +32 -10
  281. package/src/analyses/ReflectHttpOperationExceptionAnalyzer.ts +31 -0
  282. package/src/analyses/ReflectHttpOperationParameterAnalyzer.ts +31 -0
  283. package/src/analyses/ReflectHttpOperationResponseAnalyzer.ts +32 -0
  284. package/src/analyses/ReflectMcpOperationAnalyzer.ts +32 -1
  285. package/src/analyses/ReflectMetadataAnalyzer.ts +47 -0
  286. package/src/analyses/ReflectWebSocketOperationAnalyzer.ts +33 -4
  287. package/src/analyses/SecurityAnalyzer.ts +15 -0
  288. package/src/analyses/SwaggerExampleAnalyzer.ts +16 -0
  289. package/src/analyses/TypedHttpRouteAnalyzer.ts +240 -184
  290. package/src/analyses/TypedMcpRouteAnalyzer.ts +180 -20
  291. package/src/analyses/TypedWebSocketRouteAnalyzer.ts +19 -0
  292. package/src/decorators/OperationMetadata.ts +6 -0
  293. package/src/executable/internal/CommandParser.ts +19 -0
  294. package/src/executable/internal/NestiaConfigLoader.ts +66 -50
  295. package/src/executable/internal/NestiaSdkCommand.ts +96 -3
  296. package/src/executable/internal/NestiaSdkWatcher.ts +169 -41
  297. package/src/executable/internal/NestiaSwaggerWatch.ts +359 -0
  298. package/src/factories/ExpressionFactory.ts +17 -2
  299. package/src/factories/IdentifierFactory.ts +24 -0
  300. package/src/factories/LiteralFactory.ts +44 -11
  301. package/src/factories/StatementFactory.ts +28 -1
  302. package/src/factories/TypeFactory.ts +24 -0
  303. package/src/generates/CloneGenerator.ts +26 -5
  304. package/src/generates/E2eGenerator.ts +19 -0
  305. package/src/generates/SdkGenerator.ts +40 -9
  306. package/src/generates/SwaggerGenerator.ts +56 -14
  307. package/src/generates/internal/E2eFileProgrammer.ts +20 -0
  308. package/src/generates/internal/FilePrinter.ts +43 -0
  309. package/src/generates/internal/ImportDictionary.ts +110 -3
  310. package/src/generates/internal/SdkAliasCollection.ts +133 -11
  311. package/src/generates/internal/SdkDistributionComposer.ts +117 -66
  312. package/src/generates/internal/SdkFileProgrammer.ts +18 -0
  313. package/src/generates/internal/SdkHttpCloneProgrammer.ts +55 -0
  314. package/src/generates/internal/SdkHttpCloneReferencer.ts +97 -23
  315. package/src/generates/internal/SdkHttpFunctionProgrammer.ts +19 -0
  316. package/src/generates/internal/SdkHttpNamespaceProgrammer.ts +19 -0
  317. package/src/generates/internal/SdkHttpParameterProgrammer.ts +104 -2
  318. package/src/generates/internal/SdkHttpRouteProgrammer.ts +20 -0
  319. package/src/generates/internal/SdkHttpSimulationProgrammer.ts +72 -5
  320. package/src/generates/internal/SdkImportWizard.ts +63 -0
  321. package/src/generates/internal/SdkMcpRouteProgrammer.ts +38 -18
  322. package/src/generates/internal/SdkPathTemplate.ts +15 -0
  323. package/src/generates/internal/SdkRouteDirectory.ts +10 -0
  324. package/src/generates/internal/SdkTypeProgrammer.ts +118 -14
  325. package/src/generates/internal/SdkTypeTagProgrammer.ts +37 -7
  326. package/src/generates/internal/SdkWebSocketCloneProgrammer.ts +185 -142
  327. package/src/generates/internal/SdkWebSocketNamespaceProgrammer.ts +19 -0
  328. package/src/generates/internal/SdkWebSocketParameterProgrammer.ts +81 -2
  329. package/src/generates/internal/SdkWebSocketRouteProgrammer.ts +18 -0
  330. package/src/generates/internal/SwaggerDescriptionComposer.ts +47 -1
  331. package/src/generates/internal/SwaggerOperationComposer.ts +18 -0
  332. package/src/generates/internal/SwaggerOperationParameterComposer.ts +41 -8
  333. package/src/generates/internal/SwaggerOperationResponseComposer.ts +19 -0
  334. package/src/internal/legacy-augmentation.d.ts +16 -0
  335. package/src/internal/legacy.ts +296 -26
  336. package/src/structures/INestiaProject.ts +10 -0
  337. package/src/structures/INestiaSdkInput.ts +30 -0
  338. package/src/structures/IOperationMetadata.ts +55 -0
  339. package/src/structures/IReflectController.ts +10 -0
  340. package/src/structures/IReflectHttpOperation.ts +10 -0
  341. package/src/structures/IReflectHttpOperationException.ts +10 -0
  342. package/src/structures/IReflectHttpOperationParameter.ts +47 -0
  343. package/src/structures/IReflectHttpOperationSuccess.ts +11 -0
  344. package/src/structures/IReflectImport.ts +10 -0
  345. package/src/structures/IReflectMcpOperation.ts +19 -0
  346. package/src/structures/IReflectMcpOperationParameter.ts +9 -0
  347. package/src/structures/IReflectOperationError.ts +31 -2
  348. package/src/structures/IReflectType.ts +9 -0
  349. package/src/structures/IReflectWebSocketOperation.ts +10 -0
  350. package/src/structures/IReflectWebSocketOperationParameter.ts +55 -0
  351. package/src/structures/ITypedApplication.ts +10 -0
  352. package/src/structures/ITypedHttpRoute.ts +10 -0
  353. package/src/structures/ITypedHttpRouteException.ts +10 -0
  354. package/src/structures/ITypedHttpRouteParameter.ts +45 -0
  355. package/src/structures/ITypedHttpRouteSuccess.ts +10 -0
  356. package/src/structures/ITypedMcpRoute.ts +12 -0
  357. package/src/structures/ITypedWebSocketRoute.ts +10 -0
  358. package/src/transform.ts +6 -0
  359. package/src/utils/ArrayUtil.ts +32 -13
  360. package/src/utils/EmittedJavaScriptPatcher.ts +70 -47
  361. package/src/utils/FileRetriever.ts +29 -0
  362. package/src/utils/HttpResponseContentTypeUtil.ts +41 -0
  363. package/src/utils/MapUtil.ts +68 -3
  364. package/src/utils/PathUtil.ts +38 -0
  365. package/src/utils/SdkBundlePath.ts +11 -0
  366. package/src/utils/SdkInputFilter.ts +108 -0
  367. package/src/utils/SourceFinder.ts +51 -14
  368. package/src/utils/StringUtil.ts +182 -5
  369. package/src/utils/TemporaryDirectory.ts +108 -0
  370. package/src/utils/TsConfigReader.ts +124 -26
  371. package/src/utils/TtscExecutor.ts +23 -1
  372. package/src/utils/VersioningStrategy.ts +33 -13
  373. package/src/validators/TextPlainValidator.ts +19 -0
  374. package/lib/generates/internal/SwaggerReadonlyArrayEmender.d.ts +0 -9
  375. package/lib/generates/internal/SwaggerReadonlyArrayEmender.js +0 -178
  376. package/lib/generates/internal/SwaggerReadonlyArrayEmender.js.map +0 -1
  377. package/src/generates/internal/SwaggerReadonlyArrayEmender.ts +0 -264
@@ -1,6 +1,15 @@
1
1
  import { IReflectImport } from "../structures/IReflectImport";
2
2
  import { MapUtil } from "../utils/MapUtil";
3
3
 
4
+ /**
5
+ * Helpers for the import lists of routes.
6
+ *
7
+ * @evidence contracts/common.md#principled-implementation The namespace merges the imports collected for one route and keeps a removal notice for the old analysis entry.
8
+ * @evidence contracts/common.md#clear-and-simple-design Two functions.
9
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The merge is generic.
10
+ * @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
11
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation ImportAnalyzer analyzes reflected route metadata; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
12
+ */
4
13
  export namespace ImportAnalyzer {
5
14
  /**
6
15
  * @deprecated Removed in the Go-migration cycle. Import metadata is now
@@ -10,6 +19,11 @@ export namespace ImportAnalyzer {
10
19
  * `ts.SourceFile` to derive imports should read the metadata delivered
11
20
  * through `Reflect.getMetadata("nestia/OperationMetadata", …)` instead. See
12
21
  * `packages/core/MIGRATION.md`.
22
+ * @evidence contracts/common.md#principled-implementation The function exists only to give an actionable error to a caller of the removed API, and always throws.
23
+ * @evidence contracts/common.md#clear-and-simple-design One statement.
24
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It reports the removal instead of failing later with a missing function.
25
+ * @evidence contracts/common.md#meaningful-documentation The comment names the replacement.
26
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation ImportAnalyzer.analyze analyzes reflected route metadata; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
13
27
  */
14
28
  export const analyze = (): never => {
15
29
  throw new Error(
@@ -19,6 +33,17 @@ export namespace ImportAnalyzer {
19
33
  );
20
34
  };
21
35
 
36
+ /**
37
+ * Merges import records by file: namespace imports and default imports are
38
+ * deduplicated and sorted, and the named elements of every import of a file
39
+ * are combined with their aliases.
40
+ *
41
+ * @evidence contracts/common.md#principled-implementation Imports are grouped by file, each group emits its namespace imports, default imports, and one element list with an alias map for renamed elements, so the same file is imported once per kind.
42
+ * @evidence contracts/common.md#clear-and-simple-design One function over one group merger.
43
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The merge follows the import records, with no file special-cased.
44
+ * @evidence contracts/common.md#meaningful-documentation The comment states the grouping and the merging.
45
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation ImportAnalyzer.merge analyzes reflected route metadata; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
46
+ */
22
47
  export const merge = (imports: IReflectImport[]): IReflectImport[] => {
23
48
  // group by files
24
49
  const fileGroups: Map<string, IReflectImport[]> = new Map();
@@ -2,7 +2,25 @@ import { NamingConvention } from "@typia/utils";
2
2
 
3
3
  import { StringUtil } from "../utils/StringUtil";
4
4
 
5
+ /**
6
+ * Gives names to parameters that declare none, such as destructured ones.
7
+ *
8
+ * @evidence contracts/common.md#principled-implementation A missing name is derived from the field, camel-cased when it is not an identifier, or from the category, and then made unique against the names already taken.
9
+ * @evidence contracts/common.md#clear-and-simple-design One function, one record type, and one private candidate rule.
10
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The rule is generic.
11
+ * @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
12
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation ParameterNameAnalyzer analyzes reflected route metadata; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
13
+ */
5
14
  export namespace ParameterNameAnalyzer {
15
+ /**
16
+ * A parameter to name: its current name, its category, and an optional field.
17
+ *
18
+ * @evidence contracts/common.md#principled-implementation The three members are the inputs of the naming rule.
19
+ * @evidence contracts/common.md#clear-and-simple-design A flat record with no behavior.
20
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
21
+ * @evidence contracts/common.md#meaningful-documentation The comment states what the type describes and the meaning of its members.
22
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation ParameterNameAnalyzer.IParameter analyzes reflected route metadata; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
23
+ */
6
24
  export interface IParameter {
7
25
  name: string;
8
26
  category: string;
@@ -20,6 +38,12 @@ export namespace ParameterNameAnalyzer {
20
38
  * dropped in camel case, otherwise its category, such as `body` or `query`.
21
39
  * The name yields to every other parameter's, which are the user's and are
22
40
  * kept.
41
+ *
42
+ * @evidence contracts/common.md#principled-implementation The names in use are collected first, and each new name is escaped against them with underscores and added, so the result has no duplicates.
43
+ * @evidence contracts/common.md#clear-and-simple-design One function.
44
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Existing names are never changed.
45
+ * @evidence contracts/common.md#meaningful-documentation The comment states the rule.
46
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation ParameterNameAnalyzer.name analyzes reflected route metadata; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
23
47
  */
24
48
  export const name = <T extends IParameter>(parameters: T[]): T[] => {
25
49
  const taken: string[] = parameters
@@ -1,11 +1,27 @@
1
1
  import { RequestMethod } from "@nestjs/common";
2
2
  import { Token, parse } from "path-to-regexp";
3
3
 
4
+ /**
5
+ * Helpers for route paths: joining, prefixing, and reading their parameters the
6
+ * way the router does.
7
+ *
8
+ * @evidence contracts/common.md#principled-implementation Paths are parsed by `path-to-regexp` after Fastify colon escapes are converted, so the parameters and literals are those the server reads.
9
+ * @evidence contracts/common.md#clear-and-simple-design Several small functions over one tokenizer and one parser.
10
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The router's own grammar decides, and no path is special-cased.
11
+ * @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
12
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation PathAnalyzer interprets router protocol paths; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
13
+ */
4
14
  export namespace PathAnalyzer {
5
15
  /**
6
16
  * The route paths joined as the router joins them: one `/` between them, and
7
17
  * none doubled. A route path is router syntax, never a file path, so a
8
18
  * backslash stays the escape of the character after it (`items\\:batchGet`).
19
+ *
20
+ * @evidence contracts/common.md#principled-implementation The parts are joined, split on slashes, and empty segments are dropped, so any number of slashes at the boundaries collapses.
21
+ * @evidence contracts/common.md#clear-and-simple-design One expression.
22
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It applies to every input.
23
+ * @evidence contracts/common.md#meaningful-documentation The comment states the result form.
24
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation PathAnalyzer.join interprets router protocol paths; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
9
25
  */
10
26
  export const join = (...args: string[]) =>
11
27
  "/" +
@@ -15,6 +31,16 @@ export namespace PathAnalyzer {
15
31
  .filter((str) => str.length !== 0)
16
32
  .join("/");
17
33
 
34
+ /**
35
+ * Joins a path with the global prefix, unless the route is excluded from the
36
+ * prefix.
37
+ *
38
+ * @evidence contracts/common.md#principled-implementation The exclusion list is matched by method and by exact path or pattern, as NestJS does, and an excluded route is joined with an empty prefix.
39
+ * @evidence contracts/common.md#clear-and-simple-design One function delegating the exclusion test to a private helper.
40
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The exclusion rule is NestJS's.
41
+ * @evidence contracts/common.md#meaningful-documentation The comment states the exclusion.
42
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation PathAnalyzer.joinWithGlobalPrefix interprets router protocol paths; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
43
+ */
18
44
  export const joinWithGlobalPrefix = (props: {
19
45
  globalPrefix: string;
20
46
  exclude: IGlobalPrefixExclude[] | undefined;
@@ -33,20 +59,15 @@ export namespace PathAnalyzer {
33
59
  props.path,
34
60
  );
35
61
 
36
- export const escape = (str: string): string | null => {
37
- const args = _Parse(str);
38
- if (args === null) return null;
39
- return (
40
- "/" +
41
- args
42
- .map((arg) => (arg.type === "param" ? `:${arg.value}` : arg.value))
43
- .join("/")
44
- );
45
- };
46
-
47
62
  /**
48
63
  * Whether a route path holds a wildcard: a `*` not escaped as the literal
49
64
  * character (`\\*`), which a route path may hold since #1713.
65
+ *
66
+ * @evidence contracts/common.md#principled-implementation A star preceded by a backslash is a literal, so the test looks for a star at the start or after a non-backslash character.
67
+ * @evidence contracts/common.md#clear-and-simple-design One regular expression.
68
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It follows the router's escaping rule.
69
+ * @evidence contracts/common.md#meaningful-documentation The comment states the escaped case.
70
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation PathAnalyzer.wildcard interprets router protocol paths; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
50
71
  */
51
72
  export const wildcard = (str: string): boolean => /(^|[^\\])\*/.test(str);
52
73
 
@@ -56,6 +77,12 @@ export namespace PathAnalyzer {
56
77
  * and `/range/:from-:to` holds two parameters parted by `-`. Every generator
57
78
  * that writes a path with its parameters filled in reads it from here, never
58
79
  * by splitting the text at `:` or `/`. `null` for a path it cannot parse.
80
+ *
81
+ * @evidence contracts/common.md#principled-implementation Tokens come from `path-to-regexp`, so text next to a parameter in one segment, such as `/files/:id.json`, is kept in place, adjacent literals merge, and an unnamed parameter makes the path unreadable.
82
+ * @evidence contracts/common.md#clear-and-simple-design One function over the tokenizer.
83
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The grammar is the router's.
84
+ * @evidence contracts/common.md#meaningful-documentation The comment states the result and why generators use it.
85
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation PathAnalyzer.segments interprets router protocol paths; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
59
86
  */
60
87
  export const segments = (str: string): ISegment[] | null => {
61
88
  const tokens: Token[] | null = _Tokenize(str);
@@ -81,6 +108,12 @@ export namespace PathAnalyzer {
81
108
  /**
82
109
  * The path in OpenAPI's template syntax, each parameter written `{name}`:
83
110
  * `/files/:id.json` is `/files/{id}.json`.
111
+ *
112
+ * @evidence contracts/common.md#principled-implementation The segments are joined with literals verbatim and parameters in braces.
113
+ * @evidence contracts/common.md#clear-and-simple-design One expression over `segments`.
114
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It uses the same segmenter as the SDK generator.
115
+ * @evidence contracts/common.md#meaningful-documentation The comment states the fallback.
116
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation PathAnalyzer.toOpenApi interprets router protocol paths; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
84
117
  */
85
118
  export const toOpenApi = (str: string): string => {
86
119
  const list: ISegment[] | null = segments(str);
@@ -91,10 +124,29 @@ export namespace PathAnalyzer {
91
124
  .join("");
92
125
  };
93
126
 
127
+ /**
128
+ * A segment of a path: literal text or a named parameter.
129
+ *
130
+ * @evidence contracts/common.md#principled-implementation The union is discriminated by `type`, so a consumer handles each case once.
131
+ * @evidence contracts/common.md#clear-and-simple-design A two-member union.
132
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
133
+ * @evidence contracts/common.md#meaningful-documentation The comment names the two cases.
134
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation PathAnalyzer.ISegment interprets router protocol paths; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
135
+ */
94
136
  export type ISegment =
95
137
  | { type: "literal"; value: string }
96
138
  | { type: "param"; name: string };
97
139
 
140
+ /**
141
+ * Returns the names of the parameters of a path, or `null` when the path
142
+ * cannot be parsed.
143
+ *
144
+ * @evidence contracts/common.md#principled-implementation The parsed arguments are filtered to the parameters, and an empty parameter name makes the path unreadable.
145
+ * @evidence contracts/common.md#clear-and-simple-design One filter over the private parser.
146
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The grammar is the router's.
147
+ * @evidence contracts/common.md#meaningful-documentation The comment states the result.
148
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation PathAnalyzer.parameters interprets router protocol paths; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
149
+ */
98
150
  export const parameters = (str: string): string[] | null => {
99
151
  const args = _Parse(str);
100
152
  if (args === null) return null;
@@ -18,7 +18,26 @@ import { ReflectMcpOperationAnalyzer } from "./ReflectMcpOperationAnalyzer";
18
18
  import { ReflectMetadataAnalyzer } from "./ReflectMetadataAnalyzer";
19
19
  import { ReflectWebSocketOperationAnalyzer } from "./ReflectWebSocketOperationAnalyzer";
20
20
 
21
+ /**
22
+ * Reflects a NestJS controller class into an operation list.
23
+ *
24
+ * @evidence contracts/common.md#principled-implementation A controller is recognized by Nest's own path, host, and scope metadata, its methods are visited along the prototype chain with a subclass method hiding an inherited one, and each method is classified as MCP, WebSocket, or HTTP.
25
+ * @evidence contracts/common.md#clear-and-simple-design One public function and one prototype walker.
26
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The recognition uses the metadata Nest writes, and no class name is special-cased.
27
+ * @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
28
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation ReflectControllerAnalyzer analyzes reflected route metadata; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
29
+ */
21
30
  export namespace ReflectControllerAnalyzer {
31
+ /**
32
+ * The input of the controller analysis: the project, the controller, and a
33
+ * set of visited functions.
34
+ *
35
+ * @evidence contracts/common.md#principled-implementation The record holds what one analysis needs and the shared error lists live in the project.
36
+ * @evidence contracts/common.md#clear-and-simple-design A flat record with no behavior.
37
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
38
+ * @evidence contracts/common.md#meaningful-documentation The comment states what the type describes and the meaning of its members.
39
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation ReflectControllerAnalyzer.IProps analyzes reflected route metadata; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
40
+ */
22
41
  export interface IProps {
23
42
  project: Omit<INestiaProject, "config">;
24
43
  controller: INestiaSdkInput.IController;
@@ -27,6 +46,19 @@ export namespace ReflectControllerAnalyzer {
27
46
  /* ---------------------------------------------------------
28
47
  CONTROLLER
29
48
  --------------------------------------------------------- */
49
+ /**
50
+ * Returns the reflected controller with its operations, or `null` for a class
51
+ * that is not a controller.
52
+ *
53
+ * Wildcard controller paths are dropped with a warning, and methods marked
54
+ * `@ignore` are skipped.
55
+ *
56
+ * @evidence contracts/common.md#principled-implementation The metadata keys of the class decide whether it is a controller, every own and inherited method with operation metadata is offered to the MCP, WebSocket, and HTTP analyzers in that order, and the first analyzer that accepts it owns it.
57
+ * @evidence contracts/common.md#clear-and-simple-design One function.
58
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The order of the analyzers is fixed by the mutual exclusion of the decorators.
59
+ * @evidence contracts/common.md#meaningful-documentation The comment states the null result, the warning, and the ignore tag.
60
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation ReflectControllerAnalyzer.analyze analyzes reflected route metadata; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
61
+ */
30
62
  export const analyze = (props: IProps): IReflectController | null => {
31
63
  // MUST BE TYPE OF A CREATOR WHO HAS THE CONSTRUCTOR
32
64
  if (
@@ -16,7 +16,26 @@ import { ReflectHttpOperationParameterAnalyzer } from "./ReflectHttpOperationPar
16
16
  import { ReflectHttpOperationResponseAnalyzer } from "./ReflectHttpOperationResponseAnalyzer";
17
17
  import { ReflectMetadataAnalyzer } from "./ReflectMetadataAnalyzer";
18
18
 
19
+ /**
20
+ * Reflects an HTTP route method into an operation.
21
+ *
22
+ * @evidence contracts/common.md#principled-implementation The method, the path list, the parameters, the success response, the exceptions, the imports, the security, and the extensions are composed from Nest's metadata and the compile-time metadata, and the path parameters of the decorator are checked against the parameter decorators.
23
+ * @evidence contracts/common.md#clear-and-simple-design One public function over the parameter, response, and exception analyzers.
24
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The checks follow the decorators and no route is special-cased.
25
+ * @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
26
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation ReflectHttpOperationAnalyzer analyzes reflected route metadata; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
27
+ */
19
28
  export namespace ReflectHttpOperationAnalyzer {
29
+ /**
30
+ * The input of the HTTP operation analysis: the project, the controller, the
31
+ * method, and its compile-time metadata.
32
+ *
33
+ * @evidence contracts/common.md#principled-implementation The record holds the reflected function and the metadata the transform attached to it.
34
+ * @evidence contracts/common.md#clear-and-simple-design A flat record with no behavior.
35
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
36
+ * @evidence contracts/common.md#meaningful-documentation The comment states what the type describes and the meaning of its members.
37
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation ReflectHttpOperationAnalyzer.IProps analyzes reflected route metadata; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
38
+ */
20
39
  export interface IProps {
21
40
  project: Omit<INestiaProject, "config"> &
22
41
  Partial<Pick<INestiaProject, "config">>;
@@ -25,6 +44,16 @@ export namespace ReflectHttpOperationAnalyzer {
25
44
  name: string;
26
45
  metadata: IOperationMetadata;
27
46
  }
47
+ /**
48
+ * Returns the reflected HTTP operation, or `null` when the method is not a
49
+ * route or has errors, which are pushed to the project.
50
+ *
51
+ * @evidence contracts/common.md#principled-implementation A method is a route when it has Nest's path and method metadata; `ALL` is treated as POST and OPTIONS is skipped; a mismatch between the path parameters and the parameter decorators is an error.
52
+ * @evidence contracts/common.md#clear-and-simple-design One function that collects errors and returns nothing when there is one.
53
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The rules follow the HTTP semantics of the decorators.
54
+ * @evidence contracts/common.md#meaningful-documentation The comment states the null result and the collected errors.
55
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation ReflectHttpOperationAnalyzer.analyze analyzes reflected route metadata; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
56
+ */
28
57
  export const analyze = (props: IProps): IReflectHttpOperation | null => {
29
58
  if (
30
59
  ArrayUtil.has(
@@ -49,9 +78,8 @@ export namespace ReflectHttpOperationAnalyzer {
49
78
  functionName: props.name,
50
79
  errors,
51
80
  });
52
- const success: IReflectHttpOperationSuccess | null = (() => {
53
- const localErrors: IReflectOperationError[] = [];
54
- const success = ReflectHttpOperationResponseAnalyzer.analyze({
81
+ const success: IReflectHttpOperationSuccess | null =
82
+ ReflectHttpOperationResponseAnalyzer.analyze({
55
83
  controller: props.controller,
56
84
  function: props.function,
57
85
  functionName: props.name,
@@ -59,12 +87,6 @@ export namespace ReflectHttpOperationAnalyzer {
59
87
  metadata: props.metadata,
60
88
  errors,
61
89
  });
62
- if (localErrors.length) {
63
- errors.push(...localErrors);
64
- return null;
65
- }
66
- return success;
67
- })();
68
90
  if (errors.length) {
69
91
  props.project.errors.push(...errors);
70
92
  return null;
@@ -135,7 +157,7 @@ export namespace ReflectHttpOperationAnalyzer {
135
157
  // LIST UP PARAMETERS
136
158
  const binded: string[] | null = PathAnalyzer.parameters(location);
137
159
  if (binded === null) {
138
- props.project.errors.push({
160
+ errors.push({
139
161
  file: props.controller.file,
140
162
  class: props.controller.class.name,
141
163
  function: props.name,
@@ -6,7 +6,26 @@ import { IReflectController } from "../structures/IReflectController";
6
6
  import { IReflectHttpOperationException } from "../structures/IReflectHttpOperationException";
7
7
  import { IReflectOperationError } from "../structures/IReflectOperationError";
8
8
 
9
+ /**
10
+ * Reflects the `@TypedException` declarations of a method.
11
+ *
12
+ * @evidence contracts/common.md#principled-implementation The declarations are read in declaration order and matched by position with the exception types the transform recorded.
13
+ * @evidence contracts/common.md#clear-and-simple-design One public function.
14
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The matching is by position because both lists are produced in declaration order.
15
+ * @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
16
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation ReflectHttpOperationExceptionAnalyzer analyzes reflected route metadata; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
17
+ */
9
18
  export namespace ReflectHttpOperationExceptionAnalyzer {
19
+ /**
20
+ * The input of the exception analysis: the controller, the method, its name,
21
+ * the HTTP method, the metadata, and the error list.
22
+ *
23
+ * @evidence contracts/common.md#principled-implementation The record holds what the analysis needs.
24
+ * @evidence contracts/common.md#clear-and-simple-design A flat record with no behavior.
25
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
26
+ * @evidence contracts/common.md#meaningful-documentation The comment states what the type describes and the meaning of its members.
27
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation ReflectHttpOperationExceptionAnalyzer.IContext analyzes reflected route metadata; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
28
+ */
10
29
  export interface IContext {
11
30
  controller: IReflectController;
12
31
  function: Function;
@@ -15,6 +34,18 @@ export namespace ReflectHttpOperationExceptionAnalyzer {
15
34
  metadata: IOperationMetadata;
16
35
  errors: IReflectOperationError[];
17
36
  }
37
+ /**
38
+ * Returns the exceptions of a method by status.
39
+ *
40
+ * A declaration without a matching type, or with an unreadable one, is an
41
+ * error.
42
+ *
43
+ * @evidence contracts/common.md#principled-implementation Decorators apply bottom-up, so the metadata array is reversed to declaration order before it is paired with the transform's exception list, and the result is keyed by status, so the last declaration of a status wins.
44
+ * @evidence contracts/common.md#clear-and-simple-design One function.
45
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The pairing follows the documented order, and every mismatch is reported.
46
+ * @evidence contracts/common.md#meaningful-documentation The comment states the matching and the errors.
47
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation ReflectHttpOperationExceptionAnalyzer.analyze analyzes reflected route metadata; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
48
+ */
18
49
  export const analyze = (
19
50
  ctx: IContext,
20
51
  ): Record<string, IReflectHttpOperationException> => {
@@ -11,7 +11,26 @@ import { TextPlainValidator } from "../validators/TextPlainValidator";
11
11
  import { ParameterNameAnalyzer } from "./ParameterNameAnalyzer";
12
12
  import { SwaggerExampleAnalyzer } from "./SwaggerExampleAnalyzer";
13
13
 
14
+ /**
15
+ * Reflects the parameters of a route method.
16
+ *
17
+ * @evidence contracts/common.md#principled-implementation Nest's route argument metadata gives each parameter's category and position, the nestia decorators are recognized by the name of their factory function, the metadata of the transform gives the type, and the wire rules of the HTTP input are checked against it.
18
+ * @evidence contracts/common.md#clear-and-simple-design One public function with private classification and duplicate checks.
19
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The recognition by factory name couples this package to the function names of `@nestia/core`, a contract between the two packages.
20
+ * @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
21
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation ReflectHttpOperationParameterAnalyzer analyzes reflected route metadata; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
22
+ */
14
23
  export namespace ReflectHttpOperationParameterAnalyzer {
24
+ /**
25
+ * The input of the parameter analysis: the controller, the method, its name,
26
+ * the HTTP method, the metadata, and the error list.
27
+ *
28
+ * @evidence contracts/common.md#principled-implementation The record holds what the analysis needs.
29
+ * @evidence contracts/common.md#clear-and-simple-design A flat record with no behavior.
30
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
31
+ * @evidence contracts/common.md#meaningful-documentation The comment states what the type describes and the meaning of its members.
32
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation ReflectHttpOperationParameterAnalyzer.IContext analyzes reflected route metadata; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
33
+ */
15
34
  export interface IContext {
16
35
  controller: IReflectController;
17
36
  function: Function;
@@ -20,6 +39,18 @@ export namespace ReflectHttpOperationParameterAnalyzer {
20
39
  metadata: IOperationMetadata;
21
40
  errors: IReflectOperationError[];
22
41
  }
42
+ /**
43
+ * Returns the parameters of a route method in position order.
44
+ *
45
+ * Contradictions, such as a body on GET, duplicated bodies or fields,
46
+ * unreadable types, and types the HTTP input cannot carry, are errors.
47
+ *
48
+ * @evidence contracts/common.md#principled-implementation Contradictions are collected first, each parameter is composed with the schema that matches its content type, its wire rules are checked, unnamed parameters are named, and duplicate keys between field parameters and objects are reported.
49
+ * @evidence contracts/common.md#clear-and-simple-design One function that gathers every error before returning.
50
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Every rule follows the HTTP or NestJS contract, and a parameter that cannot be sent is an error, not silently dropped.
51
+ * @evidence contracts/common.md#meaningful-documentation The comment states the errors.
52
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation ReflectHttpOperationParameterAnalyzer.analyze analyzes reflected route metadata; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
53
+ */
23
54
  export const analyze = (ctx: IContext): IReflectHttpOperationParameter[] => {
24
55
  const preconfigured: IReflectHttpOperationParameter.IPreconfigured[] =
25
56
  analyzePreconfigured(ctx);
@@ -14,7 +14,26 @@ import { HttpResponseContentTypeUtil } from "../utils/HttpResponseContentTypeUti
14
14
  import { TextPlainValidator } from "../validators/TextPlainValidator";
15
15
  import { SwaggerExampleAnalyzer } from "./SwaggerExampleAnalyzer";
16
16
 
17
+ /**
18
+ * Reflects the success response of a route method.
19
+ *
20
+ * @evidence contracts/common.md#principled-implementation The content type comes from the encryption and query interceptors, then the headers metadata, then the produces metadata, then the method default; the status comes from the HTTP code metadata or the method default; binary types skip the schema.
21
+ * @evidence contracts/common.md#clear-and-simple-design One public function with small private helpers.
22
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The order follows how NestJS and nestia decorate a route.
23
+ * @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
24
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation ReflectHttpOperationResponseAnalyzer analyzes reflected route metadata; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
25
+ */
17
26
  export namespace ReflectHttpOperationResponseAnalyzer {
27
+ /**
28
+ * The input of the response analysis: the controller, the method, its name,
29
+ * the HTTP method, the metadata, and the error list.
30
+ *
31
+ * @evidence contracts/common.md#principled-implementation The record holds what the analysis needs.
32
+ * @evidence contracts/common.md#clear-and-simple-design A flat record with no behavior.
33
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
34
+ * @evidence contracts/common.md#meaningful-documentation The comment states what the type describes and the meaning of its members.
35
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation ReflectHttpOperationResponseAnalyzer.IContext analyzes reflected route metadata; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
36
+ */
18
37
  export interface IContext {
19
38
  controller: IReflectController;
20
39
  function: Function;
@@ -24,6 +43,19 @@ export namespace ReflectHttpOperationResponseAnalyzer {
24
43
  errors: IReflectOperationError[];
25
44
  }
26
45
 
46
+ /**
47
+ * Returns the success response of a method, or `null` when it cannot be
48
+ * described; the reasons are pushed to the errors.
49
+ *
50
+ * A HEAD method must have no content type, and an unsupported content type is
51
+ * an error.
52
+ *
53
+ * @evidence contracts/common.md#principled-implementation The schema is the primitive form for JSON and the resolved form for other types, the validator depends on the content type, and the status defaults to 201 for POST and 200 otherwise.
54
+ * @evidence contracts/common.md#clear-and-simple-design One function.
55
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The defaults are NestJS's.
56
+ * @evidence contracts/common.md#meaningful-documentation The comment states the null result and the two errors.
57
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation ReflectHttpOperationResponseAnalyzer.analyze analyzes reflected route metadata; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
58
+ */
27
59
  export const analyze = (
28
60
  ctx: IContext,
29
61
  ): IReflectHttpOperationSuccess | null => {
@@ -9,7 +9,26 @@ import { IReflectMcpOperationParameter } from "../structures/IReflectMcpOperatio
9
9
  import { ImportAnalyzer } from "./ImportAnalyzer";
10
10
  import { ParameterNameAnalyzer } from "./ParameterNameAnalyzer";
11
11
 
12
+ /**
13
+ * Reflects an `@McpRoute` method into a tool operation.
14
+ *
15
+ * @evidence contracts/common.md#principled-implementation The tool definition comes from the route metadata, the single params parameter is matched with its compile-time type, and combinations with HTTP or WebSocket decorators and extra parameters are errors.
16
+ * @evidence contracts/common.md#clear-and-simple-design One public function.
17
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The rules follow the decorator contract.
18
+ * @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
19
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation ReflectMcpOperationAnalyzer analyzes reflected route metadata; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
20
+ */
12
21
  export namespace ReflectMcpOperationAnalyzer {
22
+ /**
23
+ * The input of the MCP operation analysis: the project, the controller, the
24
+ * method, and its metadata.
25
+ *
26
+ * @evidence contracts/common.md#principled-implementation The record holds what the analysis needs.
27
+ * @evidence contracts/common.md#clear-and-simple-design A flat record with no behavior.
28
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
29
+ * @evidence contracts/common.md#meaningful-documentation The comment states what the type describes and the meaning of its members.
30
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation ReflectMcpOperationAnalyzer.IProps analyzes reflected route metadata; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
31
+ */
13
32
  export interface IProps {
14
33
  project: Omit<INestiaProject, "config">;
15
34
  controller: IReflectController;
@@ -18,6 +37,16 @@ export namespace ReflectMcpOperationAnalyzer {
18
37
  metadata: IOperationMetadata;
19
38
  }
20
39
 
40
+ /**
41
+ * Returns the tool operation of a method, or `null` when the method is not an
42
+ * MCP route or has errors.
43
+ *
44
+ * @evidence contracts/common.md#principled-implementation The method is an MCP route when it carries the route metadata; at most one params parameter is allowed and the function may have at most one argument; the return type and imports come from the metadata.
45
+ * @evidence contracts/common.md#clear-and-simple-design One function that collects errors once and reports them together.
46
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The rules follow the decorator contract.
47
+ * @evidence contracts/common.md#meaningful-documentation The comment states the null result.
48
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation ReflectMcpOperationAnalyzer.analyze analyzes reflected route metadata; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
49
+ */
21
50
  export const analyze = (ctx: IProps): IReflectMcpOperation | null => {
22
51
  const route:
23
52
  | {
@@ -62,7 +91,7 @@ export namespace ReflectMcpOperationAnalyzer {
62
91
 
63
92
  const imports: IReflectImport[] = [];
64
93
  const declared: IReflectMcpOperationParameter[] = preconfigured
65
- .map((p) => {
94
+ .map((p): IReflectMcpOperationParameter | null => {
66
95
  const matched: IOperationMetadata.IParameter | undefined =
67
96
  ctx.metadata.parameters.find(
68
97
  (m: IOperationMetadata.IParameter) => p.index === m.index,
@@ -85,6 +114,7 @@ export namespace ReflectMcpOperationAnalyzer {
85
114
  name: matched.name,
86
115
  index: p.index,
87
116
  type: matched.type,
117
+ metadata: matched.primitive,
88
118
  imports: matched.imports,
89
119
  description: matched.description,
90
120
  jsDocTags: matched.jsDocTags,
@@ -120,6 +150,7 @@ export namespace ReflectMcpOperationAnalyzer {
120
150
  function: ctx.function,
121
151
  parameters,
122
152
  returnType: ctx.metadata.success?.type ?? null,
153
+ returnMetadata: ctx.metadata.success?.primitive,
123
154
  imports: ImportAnalyzer.merge(imports),
124
155
  description: ctx.metadata.description ?? null,
125
156
  jsDocTags: ctx.metadata.jsDocTags,
@@ -4,7 +4,26 @@ import { VersionValue } from "@nestjs/common/interfaces";
4
4
 
5
5
  import { SecurityAnalyzer } from "./SecurityAnalyzer";
6
6
 
7
+ /**
8
+ * Reads the NestJS and Swagger metadata of a class or method.
9
+ *
10
+ * @evidence contracts/common.md#principled-implementation The functions read the reflect metadata keys that Nest and `@nestjs/swagger` define and normalize them into arrays.
11
+ * @evidence contracts/common.md#clear-and-simple-design Four small readers.
12
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts They read only public metadata keys.
13
+ * @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
14
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation ReflectMetadataAnalyzer analyzes reflected route metadata; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
15
+ */
7
16
  export namespace ReflectMetadataAnalyzer {
17
+ /**
18
+ * Returns the path list of a controller or route: a string is a one-element
19
+ * list and an empty list is one empty path.
20
+ *
21
+ * @evidence contracts/common.md#principled-implementation Nest stores a path as a string or an array, and an empty array means the root path, so the result is never empty.
22
+ * @evidence contracts/common.md#clear-and-simple-design One conditional.
23
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It normalizes without changing paths.
24
+ * @evidence contracts/common.md#meaningful-documentation The comment states the normalization.
25
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation ReflectMetadataAnalyzer.paths analyzes reflected route metadata; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
26
+ */
8
27
  export const paths = (target: Function): string[] => {
9
28
  const value: string | string[] = Reflect.getMetadata(PATH_METADATA, target);
10
29
  if (typeof value === "string") return [value];
@@ -12,6 +31,15 @@ export namespace ReflectMetadataAnalyzer {
12
31
  else return value;
13
32
  };
14
33
 
34
+ /**
35
+ * Returns the `@ApiExtension` values of a target.
36
+ *
37
+ * @evidence contracts/common.md#principled-implementation The metadata is returned as recorded, and an absent value is an empty object.
38
+ * @evidence contracts/common.md#clear-and-simple-design One read.
39
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It reads the Swagger metadata key.
40
+ * @evidence contracts/common.md#meaningful-documentation The comment states the result.
41
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation ReflectMetadataAnalyzer.extensions analyzes reflected route metadata; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
42
+ */
15
43
  export const extensions = (value: any): Record<string, any> => {
16
44
  const entire: Record<string, any>[] | undefined = Reflect.getMetadata(
17
45
  "swagger/apiExtension",
@@ -20,6 +48,15 @@ export namespace ReflectMetadataAnalyzer {
20
48
  return entire ?? {};
21
49
  };
22
50
 
51
+ /**
52
+ * Returns the deduplicated security requirements of a target.
53
+ *
54
+ * @evidence contracts/common.md#principled-implementation The `@ApiSecurity` metadata is merged by `SecurityAnalyzer.merge`, and an absent value is an empty list.
55
+ * @evidence contracts/common.md#clear-and-simple-design One read and one merge.
56
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It reads the Swagger metadata key.
57
+ * @evidence contracts/common.md#meaningful-documentation The comment states the result.
58
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation ReflectMetadataAnalyzer.securities analyzes reflected route metadata; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
59
+ */
23
60
  export const securities = (value: any): Record<string, string[]>[] => {
24
61
  const entire: Record<string, string[]>[] | undefined = Reflect.getMetadata(
25
62
  "swagger/apiSecurity",
@@ -28,6 +65,16 @@ export namespace ReflectMetadataAnalyzer {
28
65
  return entire ? SecurityAnalyzer.merge(...entire) : [];
29
66
  };
30
67
 
68
+ /**
69
+ * Returns the version list of a target, or `undefined` when it is
70
+ * unversioned.
71
+ *
72
+ * @evidence contracts/common.md#principled-implementation A single version becomes a one-element list, and an absent value stays absent so callers can tell unversioned from versioned.
73
+ * @evidence contracts/common.md#clear-and-simple-design One conditional.
74
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It reads Nest's version metadata.
75
+ * @evidence contracts/common.md#meaningful-documentation The comment states the three cases.
76
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation ReflectMetadataAnalyzer.versions analyzes reflected route metadata; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
77
+ */
31
78
  export const versions = (
32
79
  target: any,
33
80
  ): Array<string | typeof VERSION_NEUTRAL> | undefined => {