@nestia/sdk 14.0.1 → 14.0.3

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 +57 -80
  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 +22 -5
  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 +31 -1
  195. package/lib/structures/IOperationMetadata.d.ts +55 -0
  196. package/lib/structures/IReflectController.d.ts +11 -1
  197. package/lib/structures/IReflectHttpOperation.d.ts +11 -1
  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 +27 -2
  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 +393 -403
  270. package/package.json +9 -7
  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 +59 -96
  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 +48 -1
  286. package/src/analyses/ReflectWebSocketOperationAnalyzer.ts +34 -14
  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 +31 -1
  338. package/src/structures/IOperationMetadata.ts +55 -0
  339. package/src/structures/IReflectController.ts +11 -1
  340. package/src/structures/IReflectHttpOperation.ts +11 -1
  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 +37 -14
  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,31 +1,191 @@
1
+ import {
2
+ MetadataAliasType,
3
+ MetadataArrayType,
4
+ MetadataComponents,
5
+ MetadataObjectType,
6
+ MetadataSchema,
7
+ MetadataTupleType,
8
+ } from "../internal/legacy";
9
+ import { IOperationMetadata } from "../structures/IOperationMetadata";
1
10
  import { IReflectController } from "../structures/IReflectController";
2
11
  import { IReflectMcpOperation } from "../structures/IReflectMcpOperation";
12
+ import { IReflectOperationError } from "../structures/IReflectOperationError";
3
13
  import { ITypedMcpRoute } from "../structures/ITypedMcpRoute";
4
14
 
15
+ /**
16
+ * Turns a reflected MCP operation into a typed route.
17
+ *
18
+ * @evidence contracts/common.md#principled-implementation An MCP tool is one route whose accessor is `mcp` and the tool name with non-identifier characters replaced.
19
+ * @evidence contracts/common.md#clear-and-simple-design One function.
20
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The accessor rule is generic.
21
+ * @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
22
+ * efficient algorithms: The namespace groups declarations; analyze owns graph conversion.
23
+ * reuse equivalent work: The namespace coordinates no computation.
24
+ * bound retention and release resources: The namespace owns no retained state or handles.
25
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation TypedMcpRouteAnalyzer 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
+ */
5
27
  export namespace TypedMcpRouteAnalyzer {
28
+ /**
29
+ * Returns the typed route of an MCP tool: its names, schemas, input
30
+ * parameter, return type, and imports. Clone mode resolves a private copy of
31
+ * the native JSON graph and reports missing or unresolved components.
32
+ *
33
+ * @evidence contracts/common.md#principled-implementation Native primitive pipes describe the same JSON wire values the MCP adaptor serializes. Clone requests require these graphs; source-only routes preserve their declared types and imports.
34
+ * @evidence contracts/common.md#clear-and-simple-design One conversion resolves the input and output against their own components and reports clone metadata failures at the route.
35
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Native JSON pipes are resolved through the shared metadata adapter; source binding names never select a clone exception and native records remain unchanged.
36
+ * @evidence contracts/common.md#meaningful-documentation The comment states the result.
37
+ * efficient algorithms: Clone mode copies each supplied graph payload once, indexes its components and visits each schema and component target once to check reference closure. Work scales with graph vertices, edges and annotation payload; no compiler or type analysis is repeated.
38
+ * reuse equivalent work: Input and output pipes have independent native component identities, and this operation retains no completed or in-flight request to share across analyses.
39
+ * bound retention and release resources: Resolution copies and visited sets belong to one synchronous conversion; the returned route retains its reachable graphs, and no global cache, process or handle is created.
40
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation TypedMcpRouteAnalyzer.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.
41
+ */
6
42
  export const analyze = (props: {
7
43
  controller: IReflectController;
8
44
  operation: IReflectMcpOperation;
9
- }): ITypedMcpRoute[] => [
10
- {
11
- protocol: "mcp",
12
- controller: props.controller,
13
- name: props.operation.name,
14
- toolName: props.operation.toolName,
15
- title: props.operation.title,
16
- toolDescription: props.operation.toolDescription,
17
- accessor: accessor(props.operation.toolName),
18
- function: props.operation.function,
19
- input: props.operation.parameters[0] ?? null,
20
- returnType: props.operation.returnType,
21
- inputSchema: props.operation.inputSchema,
22
- outputSchema: props.operation.outputSchema,
23
- annotations: props.operation.annotations,
24
- imports: props.operation.imports,
25
- description: props.operation.description,
26
- jsDocTags: props.operation.jsDocTags,
27
- },
28
- ];
45
+ clone?: boolean;
46
+ errors?: IReflectOperationError[];
47
+ }): ITypedMcpRoute[] => {
48
+ const errors: Array<string | IOperationMetadata.IError> = [];
49
+ const cast = (
50
+ pipe: IOperationMetadata.IResponse["primitive"] | undefined,
51
+ position: string,
52
+ ): MetadataSchema | undefined => {
53
+ if (props.clone !== true) return undefined;
54
+ if (pipe === undefined) {
55
+ errors.push(`Missing native JSON metadata for MCP ${position}.`);
56
+ return undefined;
57
+ }
58
+ if (pipe.success === false) {
59
+ errors.push(...pipe.errors);
60
+ return undefined;
61
+ }
62
+ try {
63
+ const data = structuredClone(pipe.data);
64
+ const components = MetadataComponents.from(data.components);
65
+ const metadata = MetadataSchema.from(
66
+ data.metadata,
67
+ components.dictionary,
68
+ );
69
+ const visited = new WeakSet<object>();
70
+ const inspect = (value: MetadataSchema): void => {
71
+ if (visited.has(value)) return;
72
+ visited.add(value);
73
+ for (const kind of [
74
+ "objects",
75
+ "aliases",
76
+ "arrays",
77
+ "tuples",
78
+ ] as const) {
79
+ if (!Array.isArray(value[kind]))
80
+ throw new Error(`Missing ${kind} metadata.`);
81
+ for (const reference of value[kind]) {
82
+ const target = (
83
+ reference as typeof reference & {
84
+ type?:
85
+ | MetadataObjectType
86
+ | MetadataAliasType
87
+ | MetadataArrayType
88
+ | MetadataTupleType;
89
+ }
90
+ ).type;
91
+ if (target === undefined)
92
+ throw new Error(
93
+ `Unresolved ${kind} component ${reference.name}.`,
94
+ );
95
+ if (visited.has(target)) continue;
96
+ visited.add(target);
97
+ if (kind === "objects")
98
+ for (const property of (target as MetadataObjectType)
99
+ .properties) {
100
+ inspect(property.key);
101
+ inspect(property.value);
102
+ }
103
+ else if (kind === "tuples")
104
+ for (const element of (target as MetadataTupleType).elements)
105
+ inspect(element);
106
+ else
107
+ inspect(
108
+ (target as MetadataAliasType | MetadataArrayType).value,
109
+ );
110
+ }
111
+ }
112
+ if (value.rest) inspect(value.rest);
113
+ if (value.escaped) {
114
+ inspect(value.escaped.original);
115
+ inspect(value.escaped.returns);
116
+ }
117
+ for (const template of value.templates)
118
+ for (const element of template.row ?? template) inspect(element);
119
+ for (const set of value.sets) inspect(set.value);
120
+ for (const map of value.maps) {
121
+ inspect(map.key);
122
+ inspect(map.value);
123
+ }
124
+ for (const fn of value.functions) {
125
+ for (const parameter of fn.parameters) inspect(parameter.type);
126
+ inspect(fn.output);
127
+ }
128
+ };
129
+ if (!Array.isArray(metadata.objects))
130
+ throw new Error("Missing schema metadata.");
131
+ inspect(metadata);
132
+ return metadata;
133
+ } catch (error) {
134
+ errors.push(
135
+ `Invalid native JSON metadata for MCP ${position}: ${String(error)}`,
136
+ );
137
+ return undefined;
138
+ }
139
+ };
140
+ const inputMetadata = props.operation.parameters[0]
141
+ ? cast(props.operation.parameters[0].metadata, "input")
142
+ : undefined;
143
+ const outputMetadata = cast(props.operation.returnMetadata, "output");
144
+ if (errors.length) {
145
+ const failure: IReflectOperationError = {
146
+ file: props.controller.file,
147
+ class: props.controller.class.name,
148
+ function: props.operation.name,
149
+ from: props.operation.name,
150
+ contents: errors,
151
+ };
152
+ if (props.errors === undefined)
153
+ throw new Error(
154
+ errors
155
+ .map((e) => (typeof e === "string" ? e : e.messages.join("; ")))
156
+ .join("\n"),
157
+ );
158
+ props.errors.push(failure);
159
+ return [];
160
+ }
161
+ return [
162
+ {
163
+ protocol: "mcp",
164
+ controller: props.controller,
165
+ name: props.operation.name,
166
+ toolName: props.operation.toolName,
167
+ title: props.operation.title,
168
+ toolDescription: props.operation.toolDescription,
169
+ accessor: accessor(props.operation.toolName),
170
+ function: props.operation.function,
171
+ input: props.operation.parameters[0]
172
+ ? {
173
+ ...props.operation.parameters[0],
174
+ type: { ...props.operation.parameters[0].type },
175
+ }
176
+ : null,
177
+ returnType: props.operation.returnType,
178
+ inputMetadata,
179
+ outputMetadata,
180
+ inputSchema: props.operation.inputSchema,
181
+ outputSchema: props.operation.outputSchema,
182
+ annotations: props.operation.annotations,
183
+ imports: props.operation.imports,
184
+ description: props.operation.description,
185
+ jsDocTags: props.operation.jsDocTags,
186
+ },
187
+ ];
188
+ };
29
189
 
30
190
  const accessor = (toolName: string): string[] => {
31
191
  const safe = toolName.replace(/[^A-Za-z0-9_$]/g, "_");
@@ -3,7 +3,26 @@ import { IReflectWebSocketOperation } from "../structures/IReflectWebSocketOpera
3
3
  import { ITypedWebSocketRoute } from "../structures/ITypedWebSocketRoute";
4
4
  import { PathUtil } from "../utils/PathUtil";
5
5
 
6
+ /**
7
+ * Turns a reflected WebSocket operation into typed routes, one per path.
8
+ *
9
+ * @evidence contracts/common.md#principled-implementation Each path gets an accessor from its segments and the method name, and the parameters are split by category.
10
+ * @evidence contracts/common.md#clear-and-simple-design One function.
11
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The accessor rule is generic.
12
+ * @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
13
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation TypedWebSocketRouteAnalyzer 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.
14
+ */
6
15
  export namespace TypedWebSocketRouteAnalyzer {
16
+ /**
17
+ * Returns one typed WebSocket route per path, with the header, path
18
+ * parameters, query, acceptor, and driver separated.
19
+ *
20
+ * @evidence contracts/common.md#principled-implementation The parameters are filtered by category, the acceptor is required by the reflection, and the accessor combines the path segments and the method name.
21
+ * @evidence contracts/common.md#clear-and-simple-design One mapping.
22
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It only reorganizes reflected data.
23
+ * @evidence contracts/common.md#meaningful-documentation The comment states the result.
24
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation TypedWebSocketRouteAnalyzer.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.
25
+ */
7
26
  export const analyze = (props: {
8
27
  controller: IReflectController;
9
28
  operation: IReflectWebSocketOperation;
@@ -9,6 +9,12 @@ import { IOperationMetadata } from "../structures/IOperationMetadata";
9
9
  * object literal — keeping the constructed node tree minimal. The string is
10
10
  * parsed once here at module-evaluation time. A pre-parsed `IOperationMetadata`
11
11
  * object is still accepted for hand-written or test usage.
12
+ *
13
+ * @evidence contracts/common.md#principled-implementation The metadata is defined on the class prototype and property key, from an object or its JSON text, which is the key the reflection analyzers look up.
14
+ * @evidence contracts/common.md#clear-and-simple-design One decorator that parses when given text and defines one metadata entry.
15
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It only records what the transform computed and does not alter the method.
16
+ * @evidence contracts/common.md#meaningful-documentation The comment states who emits and who reads the metadata.
17
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation OperationMetadata attaches metadata through Reflect.defineMetadata; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
12
18
  */
13
19
  export function OperationMetadata(
14
20
  metadata: IOperationMetadata | string,
@@ -1,4 +1,23 @@
1
+ /**
2
+ * Parses the command-line flags of the `nestia` command.
3
+ *
4
+ * @evidence contracts/common.md#principled-implementation The namespace reads `--key value` pairs from an argument list.
5
+ * @evidence contracts/common.md#clear-and-simple-design One function.
6
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a plain parser.
7
+ * @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
8
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation CommandParser parses supplied argument strings; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
9
+ */
1
10
  export namespace CommandParser {
11
+ /**
12
+ * Returns the `--key value` pairs of an argument list as an object; a flag
13
+ * without a value, or followed by another flag, is left out.
14
+ *
15
+ * @evidence contracts/common.md#principled-implementation Each argument that starts with two dashes is a key, and the next argument is its value only when it exists and is not itself a flag.
16
+ * @evidence contracts/common.md#clear-and-simple-design One loop.
17
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It applies to every argument.
18
+ * @evidence contracts/common.md#meaningful-documentation The comment states the omitted flags.
19
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation CommandParser.parse parses supplied argument strings; it does not resolve native file identity or launch a process. Source resolution and file emission belong to their filesystem owners.
20
+ */
2
21
  export function parse(argList: string[]): Record<string, string> {
3
22
  const output: Record<string, string> = {};
4
23
  argList.forEach((arg, i) => {
@@ -5,16 +5,57 @@ import { pathToFileURL } from "url";
5
5
 
6
6
  import { INestiaConfig } from "../../INestiaConfig";
7
7
  import { EmittedJavaScriptPatcher } from "../../utils/EmittedJavaScriptPatcher";
8
+ import { TemporaryDirectory } from "../../utils/TemporaryDirectory";
8
9
  import { TsConfigReader } from "../../utils/TsConfigReader";
9
10
  import { TtscExecutor } from "../../utils/TtscExecutor";
10
11
 
12
+ /**
13
+ * Loads the TypeScript configuration of a project and its `nestia.config.ts`.
14
+ *
15
+ * @evidence contracts/common.md#principled-implementation The project file is found and merged with its `extends` chain, and the configuration is compiled through ttsc with the nestia plugin into a temporary directory, imported, and validated by type checks of the input, the scalar options and the swagger options; the swagger `info`, `servers`, `security` and `tags` values are passed on unchecked.
16
+ * @evidence contracts/common.md#clear-and-simple-design Two public functions with private helpers for the temporary roots, the plugin list, and the validation.
17
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Only this process's unique materializations are removed on exit and handled termination signals; shared cache parents and other processes' children remain, and a compile error is reported with the compiler output.
18
+ * @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
19
+ * efficient algorithms: Project inheritance delegates one per-read traversal to TsConfigReader; configuration loading compiles one wrapper project, patches emitted JavaScript once and validates each returned config.
20
+ * reuse equivalent work: This invocation computes its own result and coordinates no completed or in-flight computation across requests.
21
+ * bound retention and release resources: Wrapper project directories are removed in finally after compilation. Emitted output remains owned by the temporary registry until generation cleanup or process termination; imported module loader entries live in that process. A CLI watch child ends after each generation, whereas direct callers retain loaded exports and have no module-unload guarantee.
22
+ * @evidence contracts/portability.md#os-neutral-implementation Native project and materialization paths use path resolution/joining and Node fs/module resolution. The ttsc executor represents platform-specific executables at its process boundary; emitted ESM imports use pathToFileURL, and filename extensions preserve .mts/.cts module format.
23
+ */
11
24
  export namespace NestiaConfigLoader {
25
+ /**
26
+ * The compiler options of a project as the loader reads them: the raw
27
+ * `compilerOptions` object.
28
+ *
29
+ * @evidence contracts/common.md#principled-implementation The record wraps the raw options so callers can read them without a compiler API.
30
+ * @evidence contracts/common.md#clear-and-simple-design A one-member record.
31
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
32
+ * @evidence contracts/common.md#meaningful-documentation The comment states what the type describes and the meaning of its members.
33
+ * efficient algorithms: The compiler-options record represents parsed values and selects no algorithm.
34
+ * reuse equivalent work: This record coordinates no configuration loads or shared producers.
35
+ * bound retention and release resources: This record owns neither materialization cleanup nor compiler tasks.
36
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation The raw compiler option record performs no native path resolution or process launch; its loader owns those boundaries.
37
+ */
12
38
  export interface ICompilerOptions {
13
39
  raw: {
14
40
  compilerOptions?: Record<string, any>;
15
41
  };
16
42
  }
17
43
 
44
+ /**
45
+ * Returns the merged compiler options of the project file, following its
46
+ * `extends` chain.
47
+ *
48
+ * It throws when the file cannot be found.
49
+ *
50
+ * @evidence contracts/common.md#principled-implementation The file is searched upward from the working directory when the name is relative, and `TsConfigReader` merges the chain, so the options are those the compiler would use.
51
+ * @evidence contracts/common.md#clear-and-simple-design One function delegating the reading.
52
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It reads what the compiler reads.
53
+ * @evidence contracts/common.md#meaningful-documentation The comment states the result and the error.
54
+ * efficient algorithms: Upward project search visits each ancestor directory once, and TsConfigReader shares repeated ancestors inside one read.
55
+ * reuse equivalent work: This invocation computes its own result and coordinates no completed or in-flight computation across requests.
56
+ * bound retention and release resources: This operation owns only invocation-local values, with no retained cache, handle or background task.
57
+ * @evidence contracts/portability.md#os-neutral-implementation Native project and materialization paths use path resolution/joining and Node fs/module resolution. The ttsc executor represents platform-specific executables at its process boundary; emitted ESM imports use pathToFileURL, and filename extensions preserve .mts/.cts module format.
58
+ */
18
59
  export const compilerOptions = async (
19
60
  project: string,
20
61
  ): Promise<ICompilerOptions> => {
@@ -31,6 +72,22 @@ export namespace NestiaConfigLoader {
31
72
  };
32
73
  };
33
74
 
75
+ /**
76
+ * Returns the configurations exported by a `nestia.config.ts`, validated.
77
+ *
78
+ * The file is compiled through ttsc with the nestia plugin into a temporary
79
+ * directory and imported; a missing file, a compile error, or an invalid
80
+ * field is an error.
81
+ *
82
+ * @evidence contracts/common.md#principled-implementation The wrapper project extends the user's project with emit forced on and declarations off, the typia plugin disabled and the nestia one enabled, the emitted file is patched for `import.meta.url`, and the exported value is checked for its input, scalar options and swagger options, so a malformed one is rejected before generation, while the OpenAPI `info`, `servers`, `security` and `tags` values are not inspected here.
83
+ * @evidence contracts/common.md#clear-and-simple-design One function over private helpers for compilation, extraction, and validation.
84
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The shared registry removes only owned children on exit and handled termination signals, and the checks follow the `INestiaConfig` contract.
85
+ * @evidence contracts/common.md#meaningful-documentation The comment states the compile step and the errors.
86
+ * efficient algorithms: Each invocation compiles one wrapper project, traverses its emitted JavaScript once and validates each returned config and option field.
87
+ * reuse equivalent work: This invocation computes its own result and coordinates no completed or in-flight computation across requests.
88
+ * bound retention and release resources: Wrapper project directories are removed in finally after compilation. Emitted output remains owned by the temporary registry until generation cleanup or process termination; imported module loader entries live in that process. A CLI watch child ends after each generation, whereas direct callers retain loaded exports and have no module-unload guarantee.
89
+ * @evidence contracts/portability.md#os-neutral-implementation Native project and materialization paths use path resolution/joining and Node fs/module resolution. The ttsc executor represents platform-specific executables at its process boundary; emitted ESM imports use pathToFileURL, and filename extensions preserve .mts/.cts module format.
90
+ */
34
91
  export const configurations = async (
35
92
  file: string,
36
93
  compilerOptions: Record<string, any>,
@@ -59,9 +116,6 @@ export namespace NestiaConfigLoader {
59
116
  return assertConfigurations(file, configurations);
60
117
  };
61
118
 
62
- const MATERIALIZED_ROOTS: Set<string> = new Set();
63
- let CLEANUP_REGISTERED: boolean = false;
64
-
65
119
  const materializeConfiguration = async (props: {
66
120
  file: string;
67
121
  compilerOptions: Record<string, any>;
@@ -76,11 +130,13 @@ export namespace NestiaConfigLoader {
76
130
  throw new Error(`unable to find "${project}" file.`);
77
131
 
78
132
  const projectRoot: string = path.dirname(path.resolve(projectFile));
79
- const wrapperRoot: string = fs.mkdtempSync(
80
- path.join(ensureMaterializedRoot(projectRoot), "tsconfig-"),
133
+ const wrapperRoot: string = TemporaryDirectory.create(
134
+ materializedRoot(projectRoot),
135
+ "tsconfig-",
81
136
  );
82
- const outputRoot: string = fs.mkdtempSync(
83
- path.join(ensureMaterializedRoot(projectRoot), "run-"),
137
+ const outputRoot: string = TemporaryDirectory.create(
138
+ materializedRoot(projectRoot),
139
+ "run-",
84
140
  );
85
141
  const wrapperFile: string = path.join(wrapperRoot, "tsconfig.json");
86
142
  const wrapperConfig = {
@@ -130,7 +186,7 @@ export namespace NestiaConfigLoader {
130
186
  { cause },
131
187
  );
132
188
  } finally {
133
- fs.rmSync(wrapperRoot, { force: true, recursive: true });
189
+ TemporaryDirectory.remove(wrapperRoot);
134
190
  }
135
191
  await EmittedJavaScriptPatcher.importMetaUrl(outputRoot);
136
192
 
@@ -143,48 +199,8 @@ export namespace NestiaConfigLoader {
143
199
  return next;
144
200
  };
145
201
 
146
- const ensureMaterializedRoot = (projectRoot: string): string => {
147
- const root: string = path.join(
148
- projectRoot,
149
- "node_modules",
150
- ".nestia",
151
- "config-loader",
152
- );
153
- fs.mkdirSync(root, { recursive: true });
154
- MATERIALIZED_ROOTS.add(root);
155
- if (CLEANUP_REGISTERED === false) {
156
- CLEANUP_REGISTERED = true;
157
- const sweep = (): void => {
158
- for (const location of MATERIALIZED_ROOTS)
159
- fs.rmSync(location, { force: true, recursive: true });
160
- };
161
- process.once("exit", sweep);
162
- // process.once("exit", …) does not fire on SIGINT/SIGTERM. Without
163
- // these handlers a Ctrl-C during codegen leaves `run-*` and
164
- // `tsconfig-*` mkdtempSync directories behind under
165
- // node_modules/.nestia/config-loader/ until a subsequent clean exit.
166
- // The module-level CLEANUP_REGISTERED flag above guards against
167
- // re-entrancy within this module; we deliberately do NOT gate on
168
- // `process.listenerCount(signal) > 0` because the parallel sweep in
169
- // `ConfigAnalyzer.ensureRuntimeCleanup` (or any user-app SIGINT
170
- // handler) could register first, and that gate would skip our
171
- // registration — leaving MATERIALIZED_ROOTS unswept on Ctrl-C.
172
- // Windows note: `process.kill(pid, "SIGINT")` calls TerminateProcess
173
- // rather than re-raising; whichever module registers FIRST runs its
174
- // sweep, the second is skipped, RUNTIME/MATERIALIZED cleanup is
175
- // best-effort on Windows. SIGHUP is a no-op for most common code
176
- // paths on Windows (Node fires it on console-close and exits within
177
- // seconds).
178
- const onSignal = (signal: NodeJS.Signals): void => {
179
- sweep();
180
- process.kill(process.pid, signal);
181
- };
182
- for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"] as const) {
183
- process.once(signal, onSignal);
184
- }
185
- }
186
- return root;
187
- };
202
+ const materializedRoot = (projectRoot: string): string =>
203
+ path.join(projectRoot, "node_modules", ".nestia", "config-loader");
188
204
 
189
205
  const emittedJavaScriptKey = (projectRoot: string, file: string): string => {
190
206
  const relative: string = path.relative(projectRoot, file);
@@ -2,8 +2,31 @@ import { INestiaConfig } from "../../INestiaConfig";
2
2
  import { NestiaSdkApplication } from "../../NestiaSdkApplication";
3
3
  import { NestiaConfigLoader } from "./NestiaConfigLoader";
4
4
  import { NestiaSdkWatcher } from "./NestiaSdkWatcher";
5
+ import { NestiaSwaggerWatch } from "./NestiaSwaggerWatch";
5
6
 
7
+ /**
8
+ * The commands of the `nestia` CLI that run the generators: `sdk`, `swagger`,
9
+ * `e2e`, and `all`.
10
+ *
11
+ * @evidence contracts/common.md#principled-implementation Each command loads the configurations, keeps the ones that can generate what it needs, and runs the application; `swagger` can watch.
12
+ * @evidence contracts/common.md#clear-and-simple-design Four commands over one private runner and two argument readers.
13
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The commands differ only by title, validation, and generator.
14
+ * @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
15
+ * @evidence contracts/portability.md#os-neutral-implementation Project and config arguments remain native pathname strings supplied to NestiaConfigLoader and NestiaSdkWatcher. Those owners resolve files and launch compiler processes; dispatch does not rewrite path case or separators.
16
+ */
6
17
  export namespace NestiaSdkCommand {
18
+ /**
19
+ * Runs the generator of the SDK library for every valid configuration.
20
+ *
21
+ * With several configurations, those that cannot generate this output are
22
+ * skipped, and it is an error when none can.
23
+ *
24
+ * @evidence contracts/common.md#principled-implementation The project and configuration files come from the `--project` and `--config` flags with defaults, each flag's value is checked, and the shared runner applies the configurations in order.
25
+ * @evidence contracts/common.md#clear-and-simple-design One binding of the shared runner.
26
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The behavior follows the flags and the configuration.
27
+ * @evidence contracts/common.md#meaningful-documentation The comment states what is generated and the skipping rule.
28
+ * @evidence contracts/portability.md#os-neutral-implementation Project and config arguments remain native pathname strings supplied to NestiaConfigLoader and NestiaSdkWatcher. Those owners resolve files and launch compiler processes; dispatch does not rewrite path case or separators.
29
+ */
7
30
  export const sdk = () =>
8
31
  main({
9
32
  title: "SDK library",
@@ -12,6 +35,19 @@ export namespace NestiaSdkCommand {
12
35
  solution: "configure INestiaConfig.output property.",
13
36
  });
14
37
 
38
+ /**
39
+ * Runs the generator of the Swagger document, optionally in watch mode for
40
+ * every valid configuration.
41
+ *
42
+ * With several configurations, those that cannot generate this output are
43
+ * skipped, and it is an error when none can.
44
+ *
45
+ * @evidence contracts/common.md#principled-implementation The project and configuration files come from the `--project` and `--config` flags with defaults, each flag's value is checked, and the shared runner applies the configurations in order.
46
+ * @evidence contracts/common.md#clear-and-simple-design One binding of the shared runner.
47
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The behavior follows the flags and the configuration.
48
+ * @evidence contracts/common.md#meaningful-documentation The comment states what is generated and the skipping rule.
49
+ * @evidence contracts/portability.md#os-neutral-implementation Project and config arguments remain native pathname strings supplied to NestiaConfigLoader and NestiaSdkWatcher. Those owners resolve files and launch compiler processes; dispatch does not rewrite path case or separators.
50
+ */
15
51
  export const swagger = () =>
16
52
  main({
17
53
  title: "Swagger Document",
@@ -21,6 +57,18 @@ export namespace NestiaSdkCommand {
21
57
  watch: hasFlagArgument("watch"),
22
58
  });
23
59
 
60
+ /**
61
+ * Runs the generator of the e2e test functions for every valid configuration.
62
+ *
63
+ * With several configurations, those that cannot generate this output are
64
+ * skipped, and it is an error when none can.
65
+ *
66
+ * @evidence contracts/common.md#principled-implementation The project and configuration files come from the `--project` and `--config` flags with defaults, each flag's value is checked, and the shared runner applies the configurations in order.
67
+ * @evidence contracts/common.md#clear-and-simple-design One binding of the shared runner.
68
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The behavior follows the flags and the configuration.
69
+ * @evidence contracts/common.md#meaningful-documentation The comment states what is generated and the skipping rule.
70
+ * @evidence contracts/portability.md#os-neutral-implementation Project and config arguments remain native pathname strings supplied to NestiaConfigLoader and NestiaSdkWatcher. Those owners resolve files and launch compiler processes; dispatch does not rewrite path case or separators.
71
+ */
24
72
  export const e2e = () =>
25
73
  main({
26
74
  title: "E2E Functions",
@@ -34,6 +82,19 @@ export namespace NestiaSdkCommand {
34
82
  ].join("\n"),
35
83
  });
36
84
 
85
+ /**
86
+ * Runs the generator of everything the configurations ask for for every valid
87
+ * configuration.
88
+ *
89
+ * With several configurations, those that cannot generate this output are
90
+ * skipped, and it is an error when none can.
91
+ *
92
+ * @evidence contracts/common.md#principled-implementation The project and configuration files come from the `--project` and `--config` flags with defaults, each flag's value is checked, and the shared runner applies the configurations in order.
93
+ * @evidence contracts/common.md#clear-and-simple-design One binding of the shared runner.
94
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The behavior follows the flags and the configuration.
95
+ * @evidence contracts/common.md#meaningful-documentation The comment states what is generated and the skipping rule.
96
+ * @evidence contracts/portability.md#os-neutral-implementation Project and config arguments remain native pathname strings supplied to NestiaConfigLoader and NestiaSdkWatcher. Those owners resolve files and launch compiler processes; dispatch does not rewrite path case or separators.
97
+ */
37
98
  export const all = () =>
38
99
  main({
39
100
  title: "everything",
@@ -90,13 +151,45 @@ export namespace NestiaSdkCommand {
90
151
  }
91
152
  };
92
153
 
93
- if (props.watch === true)
154
+ if (props.watch === true) {
155
+ let generation: NestiaSwaggerWatch.IGeneration | undefined;
156
+ let opening: Promise<NestiaSwaggerWatch.IGeneration> | undefined;
157
+ let cancellation: AbortController | undefined;
94
158
  return NestiaSdkWatcher.watch({
95
159
  configFile,
96
- configurations,
97
- generate,
160
+ configurations: async () => {
161
+ cancellation = new AbortController();
162
+ opening = NestiaSwaggerWatch.open({
163
+ configFile,
164
+ projectFile: project,
165
+ signal: cancellation.signal,
166
+ });
167
+ generation = await opening;
168
+ return generation.configurations;
169
+ },
170
+ generate: async () => {
171
+ if (!generation)
172
+ throw new Error("Swagger watch generation was not prepared.");
173
+ await generation.generate();
174
+ },
175
+ finalize: async () => {
176
+ cancellation?.abort();
177
+ try {
178
+ await opening?.then(
179
+ (prepared) => prepared.close(),
180
+ (error: Error) => {
181
+ if (error.name !== "AbortError") throw error;
182
+ },
183
+ );
184
+ } finally {
185
+ generation = undefined;
186
+ opening = undefined;
187
+ cancellation = undefined;
188
+ }
189
+ },
98
190
  projectFile: project,
99
191
  });
192
+ }
100
193
 
101
194
  await generate(await configurations());
102
195
  };