raiton 6.8.8-beta.24 → 6.10.0-beta.28

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 (387) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/README.md +46 -1
  3. package/benchmarks/README.md +16 -0
  4. package/benchmarks/latest.json +172 -0
  5. package/benchmarks/latest.md +66 -0
  6. package/build/bin/index.mjs +33575 -21723
  7. package/build/types/bin/bootstrapper.d.ts +2 -0
  8. package/build/types/bin/cli-output.d.ts +46 -0
  9. package/build/types/bin/cli-tools.d.ts +13 -0
  10. package/build/types/bin/cli.d.ts +3 -0
  11. package/build/types/bin/commands.registry.d.ts +4 -0
  12. package/build/types/bin/constants.d.ts +3 -0
  13. package/build/types/bin/file-utils.d.ts +21 -0
  14. package/build/types/bin/index.d.ts +2 -0
  15. package/build/types/bin/name-utils.d.ts +4 -0
  16. package/build/types/bin/project-utils.d.ts +12 -0
  17. package/build/types/commands/artifact.command.d.ts +7 -0
  18. package/build/types/commands/build.command.d.ts +8 -0
  19. package/build/types/commands/client.command.d.ts +7 -0
  20. package/build/types/commands/contract.command.d.ts +8 -0
  21. package/build/types/commands/develop.command.d.ts +9 -0
  22. package/build/types/commands/docs.command.d.ts +8 -0
  23. package/build/types/commands/doctor.command.d.ts +9 -0
  24. package/build/types/commands/generate.command.d.ts +7 -0
  25. package/build/types/commands/inspect.command.d.ts +7 -0
  26. package/build/types/commands/mcp.command.d.ts +11 -0
  27. package/build/types/commands/new.command.d.ts +7 -0
  28. package/build/types/commands/openapi.command.d.ts +7 -0
  29. package/build/types/commands/routes.command.d.ts +7 -0
  30. package/build/types/commands/start.command.d.ts +9 -0
  31. package/build/types/commands/why.command.d.ts +7 -0
  32. package/build/types/contracts/decorators.d.ts +41 -0
  33. package/build/types/contracts/errors.d.ts +42 -0
  34. package/build/types/contracts/index.d.ts +4 -0
  35. package/build/types/contracts/schema.d.ts +70 -0
  36. package/build/types/contracts/typebox.d.ts +81 -0
  37. package/build/types/core/application.d.ts +37 -0
  38. package/build/types/core/artifacts/artifact.d.ts +3 -0
  39. package/build/types/core/artifacts/index.d.ts +1 -0
  40. package/build/types/core/artifacts/runner.d.ts +1 -0
  41. package/build/types/core/builder.d.ts +42 -0
  42. package/build/types/core/bytes.util.d.ts +3 -0
  43. package/build/types/core/command.d.ts +13 -0
  44. package/build/types/core/commands.d.ts +10 -0
  45. package/build/types/core/config/config.d.ts +27 -0
  46. package/build/types/core/config/define.d.ts +8 -0
  47. package/build/types/core/config/index.d.ts +3 -0
  48. package/build/types/core/config/schema.d.ts +24 -0
  49. package/build/types/core/context.d.ts +11 -0
  50. package/build/types/core/controller/builder.d.ts +26 -0
  51. package/build/types/core/controller/compiler.d.ts +2 -0
  52. package/build/types/core/controller/index.d.ts +4 -0
  53. package/build/types/core/controller/metadata.d.ts +3 -0
  54. package/build/types/core/controller/tracker.d.ts +9 -0
  55. package/build/types/core/directories.d.ts +10 -0
  56. package/build/types/core/guards.d.ts +11 -0
  57. package/build/types/core/helpers/index.d.ts +1 -0
  58. package/build/types/core/helpers/raiton.d.ts +1 -0
  59. package/build/types/core/hooks.d.ts +14 -0
  60. package/build/types/core/index.d.ts +17 -0
  61. package/build/types/core/injection/index.d.ts +1 -0
  62. package/build/types/core/injection/injection.d.ts +37 -0
  63. package/build/types/core/mcp/builder.d.ts +2 -0
  64. package/build/types/core/mcp/index.d.ts +3 -0
  65. package/build/types/core/mcp/metadata.d.ts +9 -0
  66. package/build/types/core/mcp/tracker.d.ts +9 -0
  67. package/build/types/core/middleware/compose.d.ts +8 -0
  68. package/build/types/core/middleware/index.d.ts +2 -0
  69. package/build/types/core/middleware/pipeline.d.ts +12 -0
  70. package/build/types/core/plugins/index.d.ts +2 -0
  71. package/build/types/core/plugins/plugin.d.ts +2 -0
  72. package/build/types/core/plugins/scope.d.ts +15 -0
  73. package/build/types/core/process.util.d.ts +1 -0
  74. package/build/types/core/raiton.d.ts +15 -0
  75. package/build/types/core/router/handler.d.ts +2 -0
  76. package/build/types/core/router/handler.utils.d.ts +37 -0
  77. package/build/types/core/router/index.d.ts +4 -0
  78. package/build/types/core/router/matcher.d.ts +50 -0
  79. package/build/types/core/router/route.d.ts +52 -0
  80. package/build/types/core/router/router.d.ts +23 -0
  81. package/build/types/core/scheduler/builder.d.ts +2 -0
  82. package/build/types/core/scheduler/cron.d.ts +32 -0
  83. package/build/types/core/scheduler/duration.d.ts +7 -0
  84. package/build/types/core/scheduler/index.d.ts +6 -0
  85. package/build/types/core/scheduler/manager.d.ts +47 -0
  86. package/build/types/core/scheduler/metadata.d.ts +8 -0
  87. package/build/types/core/scheduler/queue/backend.d.ts +42 -0
  88. package/build/types/core/scheduler/queue/index.d.ts +3 -0
  89. package/build/types/core/scheduler/queue/rabbitmq.backend.d.ts +37 -0
  90. package/build/types/core/scheduler/queue/redis.backend.d.ts +38 -0
  91. package/build/types/core/server.d.ts +9 -0
  92. package/build/types/core/socket/builder.d.ts +1 -0
  93. package/build/types/core/socket/index.d.ts +2 -0
  94. package/build/types/core/socket/metadata.d.ts +14 -0
  95. package/build/types/core/thread.d.ts +21 -0
  96. package/build/types/framework/artifacts.d.ts +20 -0
  97. package/build/types/framework/cache/cache.d.ts +84 -0
  98. package/build/types/framework/cache/cache.decorator.d.ts +21 -0
  99. package/build/types/framework/cache/etag.d.ts +62 -0
  100. package/build/types/framework/cache/index.d.ts +4 -0
  101. package/build/types/framework/cache/types.d.ts +89 -0
  102. package/build/types/framework/constants/decorators.constant.d.ts +28 -0
  103. package/build/types/framework/constants/index.d.ts +2 -0
  104. package/build/types/framework/constants/microservices.constant.d.ts +3 -0
  105. package/build/types/framework/controllers.d.ts +2 -0
  106. package/build/types/framework/data-transfer-object.d.ts +5 -0
  107. package/build/types/framework/decorators/access-guard.decorator.d.ts +1 -0
  108. package/build/types/framework/decorators/api-response.decorator.d.ts +66 -0
  109. package/build/types/framework/decorators/api.decorator.d.ts +160 -0
  110. package/build/types/framework/decorators/controllable.decorator.d.ts +3 -0
  111. package/build/types/framework/decorators/csrf-guard.decorator.d.ts +2 -0
  112. package/build/types/framework/decorators/csrf-token.decorator.d.ts +1 -0
  113. package/build/types/framework/decorators/guard.decorator.d.ts +2 -0
  114. package/build/types/framework/decorators/health-check.decorator.d.ts +17 -0
  115. package/build/types/framework/decorators/index.d.ts +15 -0
  116. package/build/types/framework/decorators/injection.decorator.d.ts +5 -0
  117. package/build/types/framework/decorators/mcp.decorator.d.ts +68 -0
  118. package/build/types/framework/decorators/middleware.decorator.d.ts +3 -0
  119. package/build/types/framework/decorators/parametrable.decorator.d.ts +9 -0
  120. package/build/types/framework/decorators/routable.decorator.d.ts +12 -0
  121. package/build/types/framework/decorators/route-interaction.decorator.d.ts +81 -0
  122. package/build/types/framework/decorators/scheduler.decorator.d.ts +54 -0
  123. package/build/types/framework/decorators/socket.decorator.d.ts +5 -0
  124. package/build/types/framework/encryption.d.ts +25 -0
  125. package/build/types/framework/enums/csrf.enum.d.ts +4 -0
  126. package/build/types/framework/enums/encrypted.enum.d.ts +20 -0
  127. package/build/types/framework/enums/event.message.enum.d.ts +4 -0
  128. package/build/types/framework/enums/http-method.enum.d.ts +10 -0
  129. package/build/types/framework/enums/http-parameters.enum.d.ts +11 -0
  130. package/build/types/framework/enums/http-status.enum.d.ts +64 -0
  131. package/build/types/framework/enums/index.d.ts +9 -0
  132. package/build/types/framework/enums/runtime.enum.d.ts +5 -0
  133. package/build/types/framework/enums/scheduler.enum.d.ts +21 -0
  134. package/build/types/framework/enums/timestamp.enum.d.ts +6 -0
  135. package/build/types/framework/env.d.ts +3 -0
  136. package/build/types/framework/errors/catalog.d.ts +42 -0
  137. package/build/types/framework/exceptions/http-exception.d.ts +18 -0
  138. package/build/types/framework/exceptions/index.d.ts +2 -0
  139. package/build/types/framework/exceptions/throwable.d.ts +76 -0
  140. package/build/types/framework/health-check.d.ts +42 -0
  141. package/build/types/framework/index.d.ts +20 -0
  142. package/build/types/framework/mcp/audit.d.ts +12 -0
  143. package/build/types/framework/mcp/conformance.d.ts +31 -0
  144. package/build/types/framework/mcp/handler.d.ts +11 -0
  145. package/build/types/framework/mcp/index.d.ts +5 -0
  146. package/build/types/framework/mcp/protocol.d.ts +17 -0
  147. package/build/types/framework/mcp/rate-limit.d.ts +10 -0
  148. package/build/types/framework/mcp/stdio.d.ts +40 -0
  149. package/build/types/framework/mcp/streamable-http.d.ts +17 -0
  150. package/build/types/framework/observability/index.d.ts +6 -0
  151. package/build/types/framework/observability/metrics.d.ts +23 -0
  152. package/build/types/framework/observability/plugin.d.ts +20 -0
  153. package/build/types/framework/observability/readiness.d.ts +9 -0
  154. package/build/types/framework/observability/request.d.ts +7 -0
  155. package/build/types/framework/observability/shutdown.d.ts +21 -0
  156. package/build/types/framework/observability/trace.d.ts +96 -0
  157. package/build/types/framework/parameter-bag.d.ts +14 -0
  158. package/build/types/framework/plugins/body-parser.plugin.d.ts +3 -0
  159. package/build/types/framework/plugins/dev.plugin.d.ts +12 -0
  160. package/build/types/framework/plugins/index.d.ts +5 -0
  161. package/build/types/framework/plugins/mcp.plugin.d.ts +15 -0
  162. package/build/types/framework/plugins/openapi.plugin.d.ts +58 -0
  163. package/build/types/framework/plugins/security/body-limit.d.ts +1 -0
  164. package/build/types/framework/plugins/security/cors.d.ts +10 -0
  165. package/build/types/framework/plugins/security/csrf.d.ts +2 -0
  166. package/build/types/framework/plugins/security/headers.d.ts +1 -0
  167. package/build/types/framework/plugins/security/index.d.ts +13 -0
  168. package/build/types/framework/plugins/security/method-guard.d.ts +1 -0
  169. package/build/types/framework/plugins/security/rate-limit.d.ts +5 -0
  170. package/build/types/framework/repositories.d.ts +5 -0
  171. package/build/types/framework/responses/error.d.ts +13 -0
  172. package/build/types/framework/responses/helpers.d.ts +7 -0
  173. package/build/types/framework/responses/http-throwable.d.ts +14 -0
  174. package/build/types/framework/responses/http.d.ts +13 -0
  175. package/build/types/framework/responses/index.d.ts +4 -0
  176. package/build/types/framework/runtime/bun/server.d.ts +2 -0
  177. package/build/types/framework/runtime/deno/server.d.ts +2 -0
  178. package/build/types/framework/runtime/index.d.ts +17 -0
  179. package/build/types/framework/runtime/node/reply.d.ts +12 -0
  180. package/build/types/framework/runtime/node/request.d.ts +33 -0
  181. package/build/types/framework/runtime/node/server.d.ts +2 -0
  182. package/build/types/framework/runtime/web/server.d.ts +1 -0
  183. package/build/types/framework/services.d.ts +5 -0
  184. package/build/types/framework/utilities/alias-path.util.d.ts +1 -0
  185. package/build/types/framework/utilities/artifact.util.d.ts +7 -0
  186. package/build/types/framework/utilities/callable.util.d.ts +1 -0
  187. package/build/types/framework/utilities/cookie.util.d.ts +1 -0
  188. package/build/types/framework/utilities/csrf.util.d.ts +26 -0
  189. package/build/types/framework/utilities/https.util.d.ts +49 -0
  190. package/build/types/framework/utilities/index.d.ts +12 -0
  191. package/build/types/framework/utilities/ip.util.d.ts +15 -0
  192. package/build/types/framework/utilities/json.util.d.ts +10 -0
  193. package/build/types/framework/utilities/openapi.utils.d.ts +7 -0
  194. package/build/types/framework/utilities/openapi.utils.impl.d.ts +18 -0
  195. package/build/types/framework/utilities/path.util.d.ts +3 -0
  196. package/build/types/framework/utilities/route-suggestion.util.d.ts +10 -0
  197. package/build/types/framework/utilities/url.util.d.ts +1 -0
  198. package/build/types/framework/utilities/utilities.util.d.ts +3 -0
  199. package/build/types/framework/utilities/validation.util.d.ts +8 -0
  200. package/build/types/framework/view-model.d.ts +4 -0
  201. package/build/types/generators/artifact.templates.d.ts +7 -0
  202. package/build/types/generators/index.d.ts +2 -0
  203. package/build/types/generators/project.templates.d.ts +21 -0
  204. package/build/types/manifest/client.d.ts +12 -0
  205. package/build/types/manifest/contract.d.ts +25 -0
  206. package/build/types/manifest/index.d.ts +5 -0
  207. package/build/types/manifest/introspect.d.ts +18 -0
  208. package/build/types/manifest/manifest.d.ts +18 -0
  209. package/build/types/manifest/schema.d.ts +177 -0
  210. package/build/types/requirements.d.ts +1 -0
  211. package/build/types/types/access-guards.d.ts +4 -0
  212. package/build/types/types/application.d.ts +32 -0
  213. package/build/types/types/artifact.d.ts +8 -0
  214. package/build/types/types/builder.d.ts +37 -0
  215. package/build/types/types/config.d.ts +62 -0
  216. package/build/types/types/controller.d.ts +27 -0
  217. package/build/types/types/contruct.d.ts +1 -0
  218. package/build/types/types/core.d.ts +11 -0
  219. package/build/types/types/csrf.d.ts +33 -0
  220. package/build/types/types/directory.d.ts +6 -0
  221. package/build/types/types/encryption.d.ts +14 -0
  222. package/build/types/types/generic.d.ts +2 -0
  223. package/build/types/types/guard.d.ts +9 -0
  224. package/build/types/types/http-responses.d.ts +7 -0
  225. package/build/types/types/index.d.ts +27 -0
  226. package/build/types/types/injection.d.ts +11 -0
  227. package/build/types/types/lifecycle.d.ts +9 -0
  228. package/build/types/types/mcp.d.ts +148 -0
  229. package/build/types/types/middleware.d.ts +12 -0
  230. package/build/types/types/parseable.d.ts +3 -0
  231. package/build/types/types/plugin.d.ts +6 -0
  232. package/build/types/types/raiton.d.ts +13 -0
  233. package/build/types/types/responses.d.ts +20 -0
  234. package/build/types/types/router.d.ts +13 -0
  235. package/build/types/types/runtime.d.ts +48 -0
  236. package/build/types/types/scheduler.d.ts +140 -0
  237. package/build/types/types/scheme.d.ts +125 -0
  238. package/build/types/types/server.d.ts +10 -0
  239. package/build/types/types/socket.d.ts +11 -0
  240. package/build/types/types/thread.d.ts +25 -0
  241. package/build/types/types/utilities.d.ts +4 -0
  242. package/build/types/types/values.d.ts +2 -0
  243. package/docs/AGENTS.md +55 -0
  244. package/docs/CLAUDE.md +55 -0
  245. package/docs/README.md +5 -0
  246. package/docs/contributors/cli/README.md +17 -3
  247. package/docs/contributors/cli/commands.md +28 -17
  248. package/docs/contributors/framework/plugins/openapi.md +12 -3
  249. package/docs/generated/cli/commands.md +26 -0
  250. package/docs/generated/config-schema.json +150 -0
  251. package/docs/generated/manifest-schema.json +236 -0
  252. package/docs/generated/manifest.json +101 -0
  253. package/docs/llms-full.txt +1271 -0
  254. package/docs/llms.txt +46 -0
  255. package/docs/user-guide/README.md +18 -12
  256. package/docs/user-guide/cli.md +21 -0
  257. package/docs/user-guide/config.md +14 -0
  258. package/docs/user-guide/contracts.md +67 -0
  259. package/docs/user-guide/en/README.md +83 -0
  260. package/docs/user-guide/getting-started.md +13 -1
  261. package/docs/user-guide/mcp.md +45 -2
  262. package/docs/user-guide/observability.md +74 -0
  263. package/docs/user-guide/openapi/plugin.md +10 -0
  264. package/docs/user-guide/recipes/README.md +32 -0
  265. package/docs/user-guide/recipes/contracts.md +52 -0
  266. package/docs/user-guide/recipes/doctor.md +16 -0
  267. package/docs/user-guide/recipes/generate.md +28 -0
  268. package/docs/user-guide/recipes/manifest.md +17 -0
  269. package/docs/user-guide/recipes/mcp-stdio.md +35 -0
  270. package/docs/user-guide/recipes/new-project.md +34 -0
  271. package/docs/user-guide/recipes/observability.md +17 -0
  272. package/package.json +40 -7
  273. package/scripts/bench.ts +586 -0
  274. package/scripts/postinstall.mjs +15 -0
  275. package/source/bin/cli-output.ts +139 -0
  276. package/source/bin/commands.registry.ts +23 -3
  277. package/source/bin/file-utils.ts +95 -0
  278. package/source/bin/name-utils.ts +26 -0
  279. package/source/bin/project-utils.ts +78 -0
  280. package/source/commands/artifact.command.ts +30 -15
  281. package/source/commands/client.command.ts +64 -0
  282. package/source/commands/contract.command.ts +104 -0
  283. package/source/commands/docs.command.ts +263 -0
  284. package/source/commands/doctor.command.ts +226 -0
  285. package/source/commands/generate.command.ts +58 -0
  286. package/source/commands/inspect.command.ts +108 -0
  287. package/source/commands/mcp.command.ts +258 -0
  288. package/source/commands/new.command.ts +135 -0
  289. package/source/commands/openapi.command.ts +95 -0
  290. package/source/commands/routes.command.ts +39 -0
  291. package/source/commands/why.command.ts +61 -0
  292. package/source/contracts/decorators.ts +151 -0
  293. package/source/contracts/errors.ts +76 -0
  294. package/source/contracts/index.ts +4 -0
  295. package/source/contracts/schema.ts +377 -0
  296. package/source/contracts/typebox.ts +193 -0
  297. package/source/core/application.ts +215 -73
  298. package/source/core/builder.ts +6 -2
  299. package/source/core/config/config.ts +144 -26
  300. package/source/core/config/define.ts +35 -8
  301. package/source/core/config/index.ts +2 -1
  302. package/source/core/config/schema.ts +263 -0
  303. package/source/core/controller/builder.ts +38 -13
  304. package/source/core/controller/compiler.ts +14 -7
  305. package/source/core/controller/metadata.ts +1 -1
  306. package/source/core/hooks.ts +13 -1
  307. package/source/core/injection/injection.ts +47 -9
  308. package/source/core/mcp/builder.ts +13 -2
  309. package/source/core/mcp/metadata.ts +2 -1
  310. package/source/core/middleware/compose.ts +48 -0
  311. package/source/core/middleware/pipeline.ts +69 -46
  312. package/source/core/raiton.ts +8 -0
  313. package/source/core/router/handler.ts +91 -31
  314. package/source/core/router/handler.utils.ts +107 -51
  315. package/source/core/router/matcher.ts +195 -24
  316. package/source/core/router/route.ts +100 -31
  317. package/source/core/router/router.ts +27 -2
  318. package/source/core/scheduler/metadata.ts +1 -1
  319. package/source/core/socket/metadata.ts +1 -1
  320. package/source/core/thread.ts +37 -2
  321. package/source/framework/artifacts.ts +92 -19
  322. package/source/framework/cache/cache.ts +48 -3
  323. package/source/framework/constants/decorators.constant.ts +5 -0
  324. package/source/framework/data-transfer-object.ts +4 -3
  325. package/source/framework/decorators/controllable.decorator.ts +3 -3
  326. package/source/framework/decorators/csrf-guard.decorator.ts +3 -2
  327. package/source/framework/decorators/csrf-token.decorator.ts +1 -1
  328. package/source/framework/decorators/guard.decorator.ts +3 -2
  329. package/source/framework/decorators/health-check.decorator.ts +1 -1
  330. package/source/framework/decorators/mcp.decorator.ts +38 -7
  331. package/source/framework/decorators/middleware.decorator.ts +2 -2
  332. package/source/framework/decorators/parametrable.decorator.ts +2 -1
  333. package/source/framework/decorators/routable.decorator.ts +3 -3
  334. package/source/framework/decorators/route-interaction.decorator.ts +2 -2
  335. package/source/framework/decorators/scheduler.decorator.ts +3 -3
  336. package/source/framework/decorators/socket.decorator.ts +3 -3
  337. package/source/framework/encryption.ts +46 -7
  338. package/source/framework/errors/catalog.ts +159 -0
  339. package/source/framework/exceptions/http-exception.ts +1 -1
  340. package/source/framework/health-check.ts +18 -0
  341. package/source/framework/index.ts +2 -0
  342. package/source/framework/mcp/audit.ts +57 -0
  343. package/source/framework/mcp/conformance.ts +195 -0
  344. package/source/framework/mcp/handler.ts +131 -9
  345. package/source/framework/mcp/index.ts +6 -1
  346. package/source/framework/mcp/protocol.ts +6 -0
  347. package/source/framework/mcp/rate-limit.ts +33 -0
  348. package/source/framework/mcp/stdio.ts +150 -0
  349. package/source/framework/mcp/streamable-http.ts +36 -5
  350. package/source/framework/observability/index.ts +6 -0
  351. package/source/framework/observability/metrics.ts +162 -0
  352. package/source/framework/observability/plugin.ts +151 -0
  353. package/source/framework/observability/readiness.ts +22 -0
  354. package/source/framework/observability/request.ts +31 -0
  355. package/source/framework/observability/shutdown.ts +68 -0
  356. package/source/framework/observability/trace.ts +241 -0
  357. package/source/framework/plugins/body-parser.plugin.ts +88 -85
  358. package/source/framework/plugins/dev.plugin.ts +227 -0
  359. package/source/framework/plugins/index.ts +2 -1
  360. package/source/framework/plugins/mcp.plugin.ts +14 -3
  361. package/source/framework/plugins/openapi.plugin.ts +56 -13
  362. package/source/framework/responses/helpers.ts +4 -4
  363. package/source/framework/responses/http-throwable.ts +1 -1
  364. package/source/framework/runtime/bun/server.ts +2 -1
  365. package/source/framework/runtime/deno/server.ts +2 -1
  366. package/source/framework/runtime/index.ts +45 -13
  367. package/source/framework/runtime/node/request.ts +59 -13
  368. package/source/framework/utilities/index.ts +3 -1
  369. package/source/framework/utilities/openapi.utils.impl.ts +705 -0
  370. package/source/framework/utilities/openapi.utils.ts +6 -636
  371. package/source/framework/utilities/route-suggestion.util.ts +59 -0
  372. package/source/framework/utilities/validation.util.ts +20 -0
  373. package/source/generators/artifact.templates.ts +230 -0
  374. package/source/generators/index.ts +2 -0
  375. package/source/generators/project.templates.ts +392 -0
  376. package/source/manifest/client.ts +299 -0
  377. package/source/manifest/contract.ts +138 -0
  378. package/source/manifest/index.ts +5 -0
  379. package/source/manifest/introspect.ts +52 -0
  380. package/source/manifest/manifest.ts +341 -0
  381. package/source/manifest/schema.ts +149 -0
  382. package/source/types/builder.ts +5 -0
  383. package/source/types/config.ts +64 -2
  384. package/source/types/mcp.ts +63 -1
  385. package/tsconfig.build.json +13 -0
  386. package/source/commands/grafts.command.ts +0 -27
  387. package/tests/artifact-resolution.test.ts +0 -60
@@ -0,0 +1,705 @@
1
+ import type {ParamMetaInterface} from "../../types/index.ts";
2
+ import {METADATA_KEYS} from "../constants/decorators.constant.ts";
3
+ import {Parametrable} from "../enums/http-parameters.enum.ts";
4
+ import type {PluginScope} from "../../core/plugins/scope.ts";
5
+
6
+ /**
7
+ * Generate the OpenAPI specification object
8
+ */
9
+ export async function generateOpenApiSpec(scope: PluginScope, opts: any): Promise<any> {
10
+ // Documentation generation is a development/CLI path: heavy modules are
11
+ // loaded here rather than when the framework entry is imported.
12
+ const [
13
+ {RaitonConfig},
14
+ {getSocketRegistry},
15
+ {getMcpServerRegistry},
16
+ {RaitonThread},
17
+ {contractToOpenApiSchema, isCompositeInput},
18
+ ] = await Promise.all([
19
+ import("../../core/config/config.ts"),
20
+ import("../../core/socket/metadata.ts"),
21
+ import("../../core/mcp/metadata.ts"),
22
+ import("../../core/thread.ts"),
23
+ import("../../contracts/index.ts"),
24
+ ])
25
+
26
+ // Use application config directly (includes HTTPS, port, hostname)
27
+ const appConfig = RaitonThread.current?.application?.config;
28
+ const appHttps = RaitonThread.current?.application?.https;
29
+
30
+ let protocole: string;
31
+ let hostname: string;
32
+ let port: number | undefined;
33
+ let pathname: string;
34
+ let prefix: string;
35
+
36
+ if (appConfig) {
37
+ protocole = appHttps?.enabled ? 'https' : (appConfig.protocole || 'http');
38
+ hostname = appConfig.hostname || 'localhost';
39
+ port = appConfig.port;
40
+ pathname = appConfig.pathname || '/';
41
+ prefix = appConfig.prefix || '';
42
+ } else {
43
+ // Fallback to RaitonConfig
44
+ await RaitonConfig.sync(process.cwd());
45
+ const config: Map<keyof any, any> = RaitonConfig.current as any;
46
+ protocole = (config.get('protocole') as string) ?? 'http';
47
+ hostname = (config.get('hostname') as string) ?? 'localhost';
48
+ port = config.get('port') as number;
49
+ pathname = (config.get('pathname') as string) ?? '/';
50
+ prefix = (config.get('prefix') as string) ?? '';
51
+ }
52
+ const basePath = pathname.endsWith('/') ? pathname : pathname + '/';
53
+
54
+ let baseUrl = `${protocole}://${hostname}`;
55
+ if (port !== undefined && port !== null) {
56
+ baseUrl += `:${port}`;
57
+ }
58
+ baseUrl += basePath;
59
+ if (prefix) {
60
+ baseUrl += prefix.startsWith('/') ? prefix.slice(1) : prefix;
61
+ if (!baseUrl.endsWith('/')) baseUrl += '/';
62
+ }
63
+
64
+ // Initialize OpenAPI document
65
+ const spec: any = {
66
+ openapi: '3.0.0',
67
+ info: {
68
+ title: opts.title,
69
+ version: opts.version,
70
+ description: opts.description,
71
+ ...(opts.termsOfService ? {termsOfService: opts.termsOfService} : {}),
72
+ ...(opts.contact ? {contact: opts.contact} : {}),
73
+ ...(opts.license ? {license: opts.license} : {})
74
+ },
75
+ servers: [
76
+ {
77
+ url: baseUrl
78
+ }
79
+ ],
80
+ paths: {}
81
+ };
82
+
83
+ const routes = scope.router.getRoutes();
84
+
85
+ for (const route of routes) {
86
+ const handler = route.handler as any;
87
+ const meta = handler._raitonMeta as {
88
+ routeMeta: { method: string; path: string; propertyKey: string };
89
+ controllerMeta: any;
90
+ controllerClass: any
91
+ } | undefined;
92
+ if (!meta) {
93
+ continue;
94
+ }
95
+
96
+ const {routeMeta, controllerMeta, controllerClass} = meta;
97
+ const method = routeMeta.method.toLowerCase() as keyof any;
98
+
99
+ let path = route.path;
100
+ if (route.version) {
101
+ path = `/${route.version}${path}`;
102
+ }
103
+ if (!path.startsWith('/')) {
104
+ path = '/' + path;
105
+ }
106
+
107
+ if (!spec.paths[path]) {
108
+ spec.paths[path] = {};
109
+ }
110
+
111
+ const operation: any = {
112
+ parameters: [],
113
+ responses: {}
114
+ };
115
+
116
+ const controllerPrototype = controllerClass?.prototype ?? controllerClass;
117
+
118
+ const operationMetadata = Reflect.getMetadata(METADATA_KEYS.API_OPERATION, controllerPrototype, routeMeta.propertyKey);
119
+ if (operationMetadata) {
120
+ Object.assign(operation, operationMetadata);
121
+ }
122
+
123
+ const methodTags = Reflect.getMetadata(METADATA_KEYS.API_TAGS, controllerPrototype, routeMeta.propertyKey);
124
+ if (methodTags) {
125
+ operation.tags = methodTags;
126
+ }
127
+
128
+ const methodSecurity = Reflect.getMetadata(METADATA_KEYS.API_SECURITY, controllerPrototype, routeMeta.propertyKey);
129
+ if (methodSecurity) {
130
+ operation.security = methodSecurity;
131
+ }
132
+
133
+ const classTags = Reflect.getMetadata(METADATA_KEYS.API_TAGS, controllerClass);
134
+ if (classTags) {
135
+ operation.tags = [...(operation.tags || []), ...classTags];
136
+ }
137
+
138
+ const classSecurity = Reflect.getMetadata(METADATA_KEYS.API_SECURITY, controllerClass);
139
+ if (classSecurity) {
140
+ operation.security = [...(operation.security || []), ...classSecurity];
141
+ }
142
+
143
+ const params: ParamMetaInterface[] = Reflect.getMetadata(METADATA_KEYS.ROUTE_PARAMETERS, controllerPrototype)?.[routeMeta.propertyKey] || [];
144
+
145
+ let bodyParam: ParamMetaInterface | undefined;
146
+ const otherParams = params.filter(p => {
147
+ if (p.type === Parametrable.BODY) {
148
+ bodyParam = p;
149
+ return false;
150
+ }
151
+ return true;
152
+ });
153
+
154
+ const apiParameters = Reflect.getMetadata(METADATA_KEYS.API_PARAMETERS, controllerPrototype, routeMeta.propertyKey)?.[routeMeta.propertyKey] || [];
155
+ for (const param of apiParameters) {
156
+ let inLocation: string;
157
+ switch (param.in) {
158
+ case 'path':
159
+ inLocation = 'path';
160
+ break;
161
+ case 'query':
162
+ inLocation = 'query';
163
+ break;
164
+ case 'header':
165
+ inLocation = 'header';
166
+ break;
167
+ case 'cookie':
168
+ inLocation = 'cookie';
169
+ break;
170
+ default:
171
+ continue; // Skip unknown locations
172
+ }
173
+
174
+ const paramObj: any = {
175
+ name: param.name,
176
+ in: inLocation,
177
+ description: param.description,
178
+ required: param.required ?? true,
179
+ schema: {
180
+ type: 'string'
181
+ }
182
+ };
183
+
184
+ if (param.type) {
185
+ paramObj.schema = getSchemaFromType(param.type);
186
+ if (param.default !== undefined) {
187
+ paramObj.schema.default = param.default;
188
+ }
189
+ }
190
+
191
+ operation.parameters.push(paramObj);
192
+ }
193
+
194
+ // Process standard Parametrable decorators (@Param, @Query, etc.)
195
+ for (const p of otherParams) {
196
+ let inLocation: string | undefined;
197
+ switch (p.type) {
198
+ case Parametrable.PARAM:
199
+ inLocation = 'path';
200
+ break;
201
+ case Parametrable.QUERY:
202
+ inLocation = 'query';
203
+ break;
204
+ case Parametrable.HEADER:
205
+ inLocation = 'header';
206
+ break;
207
+ // Note: COOKIE is not supported as there is no Parametrable.COOKIE in the framework
208
+ default:
209
+ continue;
210
+ }
211
+ if (!inLocation) continue;
212
+
213
+ const paramObj: any = {
214
+ name: p.key ?? '',
215
+ in: inLocation,
216
+ required: true, // We don't have info about required; assume true
217
+ schema: {
218
+ type: 'string' // Default to string; we could try to infer from p.metatype
219
+ }
220
+ };
221
+ // Try to improve schema based on metatype if available
222
+ if (p.metatype) {
223
+ // If metatype is a constructor like String, Number, Boolean, we can map to JSON types
224
+ const typeName = p.metatype.name;
225
+ switch (typeName) {
226
+ case 'String':
227
+ paramObj.schema.type = 'string';
228
+ break;
229
+ case 'Number':
230
+ paramObj.schema.type = 'number';
231
+ break;
232
+ case 'Boolean':
233
+ paramObj.schema.type = 'boolean';
234
+ break;
235
+ case 'Object':
236
+ paramObj.schema.type = 'object';
237
+ break;
238
+ case 'Array':
239
+ paramObj.schema.type = 'array';
240
+ // We don't know item type; leave as generic
241
+ break;
242
+ default:
243
+ // For custom classes (DTOs), we could generate a schema but skip for simplicity
244
+ // Keep as string for now
245
+ break;
246
+ }
247
+ }
248
+ operation.parameters.push(paramObj);
249
+ }
250
+
251
+ // Check for explicit API request body decorator
252
+ const apiRequestBody = Reflect.getMetadata(METADATA_KEYS.API_REQUEST_BODY, controllerPrototype, routeMeta.propertyKey);
253
+ if (apiRequestBody) {
254
+ // Use explicit API request body definition
255
+ const bodyRequired = apiRequestBody.required ?? true;
256
+ let bodySchema = null;
257
+ if (apiRequestBody.type) {
258
+ bodySchema = getSchemaFromType(apiRequestBody.type);
259
+ }
260
+ if (bodySchema !== null) {
261
+ operation.requestBody = {
262
+ required: bodyRequired,
263
+ content: {
264
+ 'application/json': {
265
+ schema: bodySchema
266
+ }
267
+ }
268
+ };
269
+ }
270
+ } else if (bodyParam) {
271
+ // Fallback to automatic body parameter detection
272
+ // Determine if the body param has a metatype that is a class (DTO)
273
+ let bodySchema: any = {type: 'object'}; // default
274
+ if (bodyParam.metatype) {
275
+ bodySchema = getSchemaFromType(bodyParam.metatype);
276
+ }
277
+ operation.requestBody = {
278
+ required: true,
279
+ content: {
280
+ 'application/json': {
281
+ schema: bodySchema
282
+ }
283
+ }
284
+ };
285
+ }
286
+
287
+ // Check for API response decorators first
288
+ const apiResponses = Reflect.getMetadata(METADATA_KEYS.API_RESPONSES, controllerPrototype)?.[routeMeta.propertyKey] || [];
289
+
290
+ if (apiResponses.length > 0) {
291
+ // Use decorator-defined responses
292
+ for (const response of apiResponses) {
293
+ const statusCode = String(response.status);
294
+ let responseContent = undefined;
295
+
296
+ if (response.type) {
297
+ const responseSchema = getSchemaFromType(response.type);
298
+ if (response.isArray) {
299
+ responseContent = {
300
+ type: 'array',
301
+ items: responseSchema
302
+ };
303
+ } else {
304
+ responseContent = responseSchema;
305
+ }
306
+ }
307
+
308
+ operation.responses[statusCode] = {
309
+ description: response.description || '',
310
+ ...(responseContent ? {content: {'application/json': {schema: responseContent}}} : {})
311
+ };
312
+ }
313
+ } else {
314
+ // Fallback to return type detection
315
+ const returnType = Reflect.getMetadata('design:returntype', controllerPrototype, routeMeta.propertyKey);
316
+ if (returnType) {
317
+ // Handle Promise<T> -> T
318
+ let resolvedType = returnType;
319
+ if (typeof returnType === 'function' && returnType.name === 'Promise' && !('length' in (returnType.prototype || {}))) {
320
+ // We can't easily get the generic argument; we'll try to infer from the type string
321
+ // For simplicity, if it's a Promise, we'll still treat the resolved type as unknown.
322
+ // In practice, we could attempt to get the type argument, but it's complex.
323
+ // We'll leave it as object for now.
324
+ resolvedType = Object;
325
+ }
326
+ const responseSchema = getSchemaFromType(resolvedType);
327
+ operation.responses['200'] = {
328
+ description: 'Successful response',
329
+ ...(responseSchema ? {content: {'application/json': {schema: responseSchema}}} : {})
330
+ };
331
+ } else {
332
+ // Default response if we cannot determine return type
333
+ operation.responses['200'] = {
334
+ description: 'Successful response'
335
+ };
336
+ }
337
+ }
338
+
339
+ // Schema-first contracts are the single source for validation, types
340
+ // and documentation. They override heuristics when present.
341
+ const contract = handler._raitonContract as any;
342
+ if (contract?.input) {
343
+ const composite = isCompositeInput(contract.input);
344
+ const contractBody = composite ? contract.input.body : contract.input;
345
+ const schema = contractToOpenApiSchema(contractBody);
346
+ if (schema) {
347
+ operation.requestBody = {
348
+ required: true,
349
+ content: {'application/json': {schema}},
350
+ };
351
+ }
352
+ if (composite) {
353
+ const locations: Array<[string, string]> = [
354
+ ['query', 'query'],
355
+ ['params', 'path'],
356
+ ['headers', 'header'],
357
+ ];
358
+ for (const [part, location] of locations) {
359
+ const partSchema = contractToOpenApiSchema(contract.input[part]);
360
+ if (!partSchema?.properties) continue;
361
+ const required = new Set<string>(Array.isArray(partSchema.required) ? partSchema.required : []);
362
+ for (const [name, property] of Object.entries(partSchema.properties)) {
363
+ operation.parameters.push({
364
+ name,
365
+ in: location,
366
+ required: location === 'path' || required.has(name),
367
+ schema: property,
368
+ });
369
+ }
370
+ }
371
+ }
372
+ }
373
+ if (contract?.output) {
374
+ const schema = contractToOpenApiSchema(contract.output);
375
+ if (schema) {
376
+ operation.responses = {
377
+ ...operation.responses,
378
+ '200': {
379
+ description: 'Successful response',
380
+ content: {'application/json': {schema}},
381
+ },
382
+ };
383
+ }
384
+ }
385
+
386
+ // Assign operation to path item under the method key
387
+ (spec.paths[path] as any)[method] = operation;
388
+ }
389
+
390
+ // Document registered WebSocket sockets as POST operations (one per event)
391
+ const sockets = getSocketRegistry();
392
+
393
+ for (const [, socketEntry] of sockets) {
394
+ const {namespace, construct, metadata} = socketEntry;
395
+ const classTags = Reflect.getMetadata(METADATA_KEYS.API_TAGS, construct) || [];
396
+ const socketPrototype = construct?.prototype ?? construct;
397
+
398
+ for (const event of metadata.events) {
399
+ if (event.type !== 'event' && event.type !== 'message') continue;
400
+ if (!event.name) continue;
401
+
402
+ const channelPath = `${namespace}`.replace(/\/+/g, '/') || '/';
403
+ const eventPath = `${channelPath}/${event.name}`.replace(/\/+/g, '/');
404
+
405
+ if (!spec.paths[eventPath]) {
406
+ spec.paths[eventPath] = {};
407
+ }
408
+
409
+ const operation: any = {
410
+ parameters: [],
411
+ responses: {}
412
+ };
413
+
414
+ const operationMetadata = Reflect.getMetadata(METADATA_KEYS.API_OPERATION, socketPrototype, event.propertyKey);
415
+ if (operationMetadata) {
416
+ Object.assign(operation, operationMetadata);
417
+ }
418
+
419
+ const methodTags = Reflect.getMetadata(METADATA_KEYS.API_TAGS, socketPrototype, event.propertyKey);
420
+ operation.tags = [...(methodTags || []), ...classTags];
421
+
422
+ const apiResponses = Reflect.getMetadata(METADATA_KEYS.API_RESPONSES, socketPrototype)?.[event.propertyKey] || [];
423
+
424
+ if (apiResponses.length > 0) {
425
+ for (const response of apiResponses) {
426
+ const statusCode = String(response.status);
427
+ let responseContent = undefined;
428
+
429
+ if (response.type) {
430
+ const responseSchema = getSchemaFromType(response.type);
431
+ responseContent = response.isArray
432
+ ? {type: 'array', items: responseSchema}
433
+ : responseSchema;
434
+ }
435
+
436
+ operation.responses[statusCode] = {
437
+ description: response.description || '',
438
+ ...(responseContent ? {content: {'application/json': {schema: responseContent}}} : {})
439
+ };
440
+ }
441
+ } else {
442
+ operation.responses['200'] = {
443
+ description: 'Successful response'
444
+ };
445
+ }
446
+
447
+ const apiRequestBody = Reflect.getMetadata(METADATA_KEYS.API_REQUEST_BODY, socketPrototype, event.propertyKey);
448
+ const dataSchema = apiRequestBody?.type
449
+ ? getSchemaFromType(apiRequestBody.type)
450
+ : {type: 'object'};
451
+
452
+ operation.requestBody = {
453
+ required: apiRequestBody?.required ?? true,
454
+ content: {
455
+ 'application/json': {
456
+ schema: {
457
+ type: 'object',
458
+ properties: {
459
+ event: {type: 'string', enum: [event.name], example: event.name},
460
+ data: dataSchema
461
+ },
462
+ required: ['event', 'data']
463
+ }
464
+ }
465
+ }
466
+ };
467
+
468
+ operation['x-websocket'] = {
469
+ channel: channelPath,
470
+ event: event.name
471
+ };
472
+
473
+ (spec.paths[eventPath] as any).post = operation;
474
+ }
475
+ }
476
+
477
+ // Document registered MCP servers as streamable HTTP (POST JSON-RPC) operations
478
+ const mcpServers = getMcpServerRegistry();
479
+
480
+ for (const [, mcpEntry] of mcpServers) {
481
+ const mcpPath = mcpEntry.path;
482
+ if (!spec.paths[mcpPath]) {
483
+ spec.paths[mcpPath] = {};
484
+ }
485
+
486
+ const elements = [
487
+ ...mcpEntry.metadata.tools.map(t => ({kind: 'tool', ...t})),
488
+ ...mcpEntry.metadata.prompts.map(p => ({kind: 'prompt', ...p})),
489
+ ...mcpEntry.metadata.resources.map(r => ({kind: 'resource', ...r})),
490
+ ...mcpEntry.metadata.resourceTemplates.map(r => ({kind: 'resource-template', ...r})),
491
+ ];
492
+
493
+ (spec.paths[mcpPath] as any).post = {
494
+ summary: `MCP server: ${mcpEntry.name} (${mcpEntry.version})`,
495
+ description: mcpEntry.metadata.description
496
+ || `Model Context Protocol server. Exposes ${
497
+ elements.map(e => `${e.kind}s`).filter((v, i, a) => a.indexOf(v) === i).join(', ') || 'no elements'
498
+ }.`,
499
+ parameters: [],
500
+ requestBody: {
501
+ required: true,
502
+ content: {
503
+ 'application/json': {
504
+ schema: {
505
+ type: 'object',
506
+ properties: {
507
+ jsonrpc: {type: 'string', const: '2.0'},
508
+ id: {type: ['number', 'string', 'null']},
509
+ method: {type: 'string', enum: [...new Set(elements.map(e => e.kind === 'tool' ? 'tools/call' : e.kind === 'prompt' ? 'prompts/get' : 'resources/read'))]},
510
+ params: {type: 'object'}
511
+ },
512
+ required: ['jsonrpc', 'method']
513
+ }
514
+ }
515
+ }
516
+ },
517
+ responses: {
518
+ '200': {
519
+ description: 'Successful JSON-RPC response',
520
+ content: {'application/json': {schema: {type: 'object'}}}
521
+ },
522
+ '202': {
523
+ description: 'Request accepted (notification)'
524
+ },
525
+ '406': {
526
+ description: 'Unsupported protocol version'
527
+ }
528
+ },
529
+ 'x-mcp': {
530
+ name: mcpEntry.name,
531
+ version: mcpEntry.version,
532
+ transport: 'streamable-http',
533
+ tools: mcpEntry.metadata.tools.map(t => ({
534
+ name: t.name,
535
+ description: t.description,
536
+ inputSchema: t.inputSchema
537
+ ? contractToOpenApiSchema(t.inputSchema)
538
+ : {
539
+ type: 'object',
540
+ properties: Object.fromEntries(
541
+ t.arguments.map(a => [a.name, {type: a.schema?.type || 'string', description: a.description}])
542
+ ),
543
+ ...(t.arguments.some(a => a.required) ? {required: t.arguments.filter(a => a.required).map(a => a.name)} : {})
544
+ },
545
+ ...(t.outputSchema ? {outputSchema: contractToOpenApiSchema(t.outputSchema)} : {}),
546
+ ...(t.annotations ? {annotations: t.annotations} : {}),
547
+ })),
548
+ prompts: mcpEntry.metadata.prompts.map(p => ({
549
+ name: p.name,
550
+ description: p.description,
551
+ arguments: p.arguments.map(a => ({name: a.name, description: a.description, required: a.required}))
552
+ })),
553
+ resources: [
554
+ ...mcpEntry.metadata.resources.map(r => ({uri: r.uri, name: r.name, mimeType: r.mimeType})),
555
+ ...mcpEntry.metadata.resourceTemplates.map(r => ({uriTemplate: r.uri, name: r.name, mimeType: r.mimeType})),
556
+ ]
557
+ }
558
+ };
559
+ }
560
+
561
+ return spec;
562
+ }
563
+
564
+ /**
565
+ * Attempt to derive a JSON Schema fragment from a TypeScript type.
566
+ * This is a simplified implementation; for production use, consider using
567
+ * a library like @sinclair/typebox or class-transformer to generate schemas.
568
+ */
569
+ export function getSchemaFromType(type: any, visited: Set<any> = new Set()): any {
570
+ if (typeof type !== 'function') {
571
+ // Not a constructor; fallback to basic type detection
572
+ return getPrimitiveTypeSchema(typeof type);
573
+ }
574
+
575
+ if (visited.has(type)) {
576
+ return {type: 'object', description: 'Circular reference'};
577
+ }
578
+
579
+ const typeName = type.name;
580
+ switch (typeName) {
581
+ case 'String':
582
+ return {type: 'string'};
583
+ case 'Number':
584
+ return {type: 'number'};
585
+ case 'Boolean':
586
+ return {type: 'boolean'};
587
+ case 'Object':
588
+ return {type: 'object'};
589
+ case 'Array':
590
+ return {
591
+ type: 'array',
592
+ items: {type: 'string'} // We don't know the item type
593
+ };
594
+ case 'Date':
595
+ return {
596
+ type: 'string',
597
+ format: 'date-time'
598
+ };
599
+ default:
600
+ // For custom classes (DTOs, entities, etc.), check for @ApiProperty
601
+ // We use Reflect.getMetadata to support inheritance of properties
602
+ const properties = Reflect.getMetadata(METADATA_KEYS.API_PROPERTY, type);
603
+
604
+ if (properties) {
605
+ visited.add(type);
606
+ const schema: any = {
607
+ type: 'object',
608
+ properties: {},
609
+ required: []
610
+ };
611
+
612
+ for (const [key, options] of Object.entries(properties) as [string, any][]) {
613
+ let propSchema: any;
614
+ const propType = options.type;
615
+
616
+ if (options.isArray) {
617
+ propSchema = {
618
+ type: 'array',
619
+ items: propType ? getSchemaFromType(propType, new Set(visited)) : {type: 'string'}
620
+ };
621
+ } else if (propType) {
622
+ propSchema = getSchemaFromType(propType, new Set(visited));
623
+ } else {
624
+ propSchema = {type: 'string'};
625
+ }
626
+
627
+ if (options.description) propSchema.description = options.description;
628
+ if (options.example) propSchema.example = options.example;
629
+ if (options.enum) propSchema.enum = options.enum;
630
+
631
+ schema.properties[key] = propSchema;
632
+ if (options.required) {
633
+ schema.required.push(key);
634
+ }
635
+ }
636
+
637
+ if (schema.required.length === 0) {
638
+ delete schema.required;
639
+ }
640
+
641
+ return schema;
642
+ }
643
+
644
+ return {type: 'object'};
645
+ }
646
+ }
647
+
648
+ /**
649
+ * Get schema for primitive types (string, number, boolean, bigint, symbol, undefined, object, function)
650
+ */
651
+ export function getPrimitiveTypeSchema(primitive: string): any {
652
+ switch (primitive) {
653
+ case 'string':
654
+ return {type: 'string'};
655
+ case 'number':
656
+ return {type: 'number'};
657
+ case 'boolean':
658
+ return {type: 'boolean'};
659
+ case 'bigint':
660
+ return {type: 'string'}; // Represent bigint as string in JSON
661
+ case 'undefined':
662
+ return {type: 'null'};
663
+ case 'object':
664
+ return {type: 'object'};
665
+ case 'function':
666
+ return {type: 'string'}; // functions are not serializable; represent as string placeholder
667
+ default:
668
+ return {type: 'string'};
669
+ }
670
+ }
671
+
672
+ /**
673
+ * Generate HTML for Swagger UI using CDN
674
+ */
675
+ // export function generateHtml(title: string, endpoint: string): string {
676
+ // // Ensure endpoint starts with / if not already
677
+ // if (!endpoint.startsWith('/')) {
678
+ // endpoint = '/' + endpoint;
679
+ // }
680
+ // return `<!DOCTYPE html>
681
+ // <html lang="en">
682
+ // <head>
683
+ // <meta charset="UTF-8">
684
+ // <title>${title} - SwaggerUI</title>
685
+ // <link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist@5/swagger-ui.css" />
686
+ // </head>
687
+ // <body>
688
+ // <div id="swagger-ui"></div>
689
+ // <script src="https://unpkg.com/swagger-ui-dist@5/swagger-ui-bundle.js"></script>
690
+ // <script>
691
+ // window.onload = () => {
692
+ // window.ui = SwaggerUIBundle({
693
+ // url: '${endpoint}',
694
+ // domId: '#swagger-ui',
695
+ // presets: [
696
+ // SwaggerUIBundle.presets.forApis,
697
+ // SwaggerUIBundle.SwaggerUIStandalonePreset
698
+ // ],
699
+ // layout: "BaseLayout"
700
+ // });
701
+ // }
702
+ // </script>
703
+ // </body>
704
+ // </html>`;
705
+ // }