@buenojs/bueno 0.8.9 → 0.8.11

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 (708) hide show
  1. package/README.md +1 -1
  2. package/dist/cache/index.d.ts +187 -0
  3. package/dist/cache/index.d.ts.map +1 -0
  4. package/dist/cache/index.js +595 -0
  5. package/dist/cache/index.js.map +1 -0
  6. package/dist/cli/bin.d.ts +8 -0
  7. package/dist/cli/bin.d.ts.map +1 -0
  8. package/dist/cli/bin.js +9 -9
  9. package/dist/cli/bin.js.map +1 -0
  10. package/dist/cli/commands/add-frontend.d.ts +7 -0
  11. package/dist/cli/commands/add-frontend.d.ts.map +1 -0
  12. package/dist/cli/commands/add-frontend.js +376 -0
  13. package/dist/cli/commands/add-frontend.js.map +1 -0
  14. package/dist/cli/commands/build.d.ts +7 -0
  15. package/dist/cli/commands/build.d.ts.map +1 -0
  16. package/dist/cli/commands/build.js +347 -0
  17. package/dist/cli/commands/build.js.map +1 -0
  18. package/dist/cli/commands/dev.d.ts +7 -0
  19. package/dist/cli/commands/dev.d.ts.map +1 -0
  20. package/dist/cli/commands/dev.js +205 -0
  21. package/dist/cli/commands/dev.js.map +1 -0
  22. package/dist/cli/commands/generate.d.ts +7 -0
  23. package/dist/cli/commands/generate.d.ts.map +1 -0
  24. package/dist/cli/commands/generate.js +491 -0
  25. package/dist/cli/commands/generate.js.map +1 -0
  26. package/dist/cli/commands/help.d.ts +7 -0
  27. package/dist/cli/commands/help.d.ts.map +1 -0
  28. package/dist/cli/commands/help.js +51 -0
  29. package/dist/cli/commands/help.js.map +1 -0
  30. package/dist/cli/commands/index.d.ts +59 -0
  31. package/dist/cli/commands/index.d.ts.map +1 -0
  32. package/dist/cli/commands/index.js +77 -0
  33. package/dist/cli/commands/index.js.map +1 -0
  34. package/dist/cli/commands/migration.d.ts +7 -0
  35. package/dist/cli/commands/migration.d.ts.map +1 -0
  36. package/dist/cli/commands/migration.js +295 -0
  37. package/dist/cli/commands/migration.js.map +1 -0
  38. package/dist/cli/commands/new.d.ts +7 -0
  39. package/dist/cli/commands/new.d.ts.map +1 -0
  40. package/dist/cli/commands/new.js +641 -0
  41. package/dist/cli/commands/new.js.map +1 -0
  42. package/dist/cli/commands/start.d.ts +7 -0
  43. package/dist/cli/commands/start.d.ts.map +1 -0
  44. package/dist/cli/commands/start.js +171 -0
  45. package/dist/cli/commands/start.js.map +1 -0
  46. package/dist/cli/core/args.d.ts +61 -0
  47. package/dist/cli/core/args.d.ts.map +1 -0
  48. package/dist/cli/core/args.js +224 -0
  49. package/dist/cli/core/args.js.map +1 -0
  50. package/dist/cli/core/console.d.ts +135 -0
  51. package/dist/cli/core/console.d.ts.map +1 -0
  52. package/dist/cli/core/console.js +268 -0
  53. package/dist/cli/core/console.js.map +1 -0
  54. package/dist/cli/core/index.d.ts +10 -0
  55. package/dist/cli/core/index.d.ts.map +1 -0
  56. package/dist/cli/core/index.js +10 -0
  57. package/dist/cli/core/index.js.map +1 -0
  58. package/dist/cli/core/prompt.d.ts +63 -0
  59. package/dist/cli/core/prompt.d.ts.map +1 -0
  60. package/dist/cli/core/prompt.js +338 -0
  61. package/dist/cli/core/prompt.js.map +1 -0
  62. package/dist/cli/core/spinner.d.ts +111 -0
  63. package/dist/cli/core/spinner.d.ts.map +1 -0
  64. package/dist/cli/core/spinner.js +208 -0
  65. package/dist/cli/core/spinner.js.map +1 -0
  66. package/dist/cli/index.d.ts +47 -0
  67. package/dist/cli/index.d.ts.map +1 -0
  68. package/dist/cli/index.js +127 -0
  69. package/dist/cli/index.js.map +1 -0
  70. package/dist/cli/templates/database/index.d.ts +24 -0
  71. package/dist/cli/templates/database/index.d.ts.map +1 -0
  72. package/dist/cli/templates/database/index.js +49 -0
  73. package/dist/cli/templates/database/index.js.map +1 -0
  74. package/dist/cli/templates/database/mysql.d.ts +6 -0
  75. package/dist/cli/templates/database/mysql.d.ts.map +1 -0
  76. package/dist/cli/templates/database/mysql.js +12 -0
  77. package/dist/cli/templates/database/mysql.js.map +1 -0
  78. package/dist/cli/templates/database/none.d.ts +8 -0
  79. package/dist/cli/templates/database/none.d.ts.map +1 -0
  80. package/dist/cli/templates/database/none.js +14 -0
  81. package/dist/cli/templates/database/none.js.map +1 -0
  82. package/dist/cli/templates/database/postgresql.d.ts +6 -0
  83. package/dist/cli/templates/database/postgresql.d.ts.map +1 -0
  84. package/dist/cli/templates/database/postgresql.js +12 -0
  85. package/dist/cli/templates/database/postgresql.js.map +1 -0
  86. package/dist/cli/templates/database/sqlite.d.ts +6 -0
  87. package/dist/cli/templates/database/sqlite.d.ts.map +1 -0
  88. package/dist/cli/templates/database/sqlite.js +12 -0
  89. package/dist/cli/templates/database/sqlite.js.map +1 -0
  90. package/dist/cli/templates/deploy.d.ts +41 -0
  91. package/dist/cli/templates/deploy.d.ts.map +1 -0
  92. package/dist/cli/templates/deploy.js +278 -0
  93. package/dist/cli/templates/deploy.js.map +1 -0
  94. package/dist/cli/templates/docker.d.ts +30 -0
  95. package/dist/cli/templates/docker.d.ts.map +1 -0
  96. package/dist/cli/templates/docker.js +298 -0
  97. package/dist/cli/templates/docker.js.map +1 -0
  98. package/dist/cli/templates/frontend/index.d.ts +25 -0
  99. package/dist/cli/templates/frontend/index.d.ts.map +1 -0
  100. package/dist/cli/templates/frontend/index.js +40 -0
  101. package/dist/cli/templates/frontend/index.js.map +1 -0
  102. package/dist/cli/templates/frontend/none.d.ts +8 -0
  103. package/dist/cli/templates/frontend/none.d.ts.map +1 -0
  104. package/dist/cli/templates/frontend/none.js +15 -0
  105. package/dist/cli/templates/frontend/none.js.map +1 -0
  106. package/dist/cli/templates/frontend/react.d.ts +6 -0
  107. package/dist/cli/templates/frontend/react.d.ts.map +1 -0
  108. package/dist/cli/templates/frontend/react.js +139 -0
  109. package/dist/cli/templates/frontend/react.js.map +1 -0
  110. package/dist/cli/templates/frontend/solid.d.ts +6 -0
  111. package/dist/cli/templates/frontend/solid.d.ts.map +1 -0
  112. package/dist/cli/templates/frontend/solid.js +133 -0
  113. package/dist/cli/templates/frontend/solid.js.map +1 -0
  114. package/dist/cli/templates/frontend/svelte.d.ts +6 -0
  115. package/dist/cli/templates/frontend/svelte.d.ts.map +1 -0
  116. package/dist/cli/templates/frontend/svelte.js +130 -0
  117. package/dist/cli/templates/frontend/svelte.js.map +1 -0
  118. package/dist/cli/templates/frontend/vue.d.ts +6 -0
  119. package/dist/cli/templates/frontend/vue.d.ts.map +1 -0
  120. package/dist/cli/templates/frontend/vue.js +129 -0
  121. package/dist/cli/templates/frontend/vue.js.map +1 -0
  122. package/dist/cli/templates/generators/index.d.ts +29 -0
  123. package/dist/cli/templates/generators/index.d.ts.map +1 -0
  124. package/dist/cli/templates/generators/index.js +308 -0
  125. package/dist/cli/templates/generators/index.js.map +1 -0
  126. package/dist/cli/templates/generators/types.d.ts +32 -0
  127. package/dist/cli/templates/generators/types.d.ts.map +1 -0
  128. package/dist/cli/templates/generators/types.js +21 -0
  129. package/dist/cli/templates/generators/types.js.map +1 -0
  130. package/dist/cli/templates/index.d.ts +12 -0
  131. package/dist/cli/templates/index.d.ts.map +1 -0
  132. package/dist/cli/templates/index.js +18 -0
  133. package/dist/cli/templates/index.js.map +1 -0
  134. package/dist/cli/templates/project/api.d.ts +6 -0
  135. package/dist/cli/templates/project/api.d.ts.map +1 -0
  136. package/dist/cli/templates/project/api.js +79 -0
  137. package/dist/cli/templates/project/api.js.map +1 -0
  138. package/dist/cli/templates/project/default.d.ts +6 -0
  139. package/dist/cli/templates/project/default.d.ts.map +1 -0
  140. package/dist/cli/templates/project/default.js +136 -0
  141. package/dist/cli/templates/project/default.js.map +1 -0
  142. package/dist/cli/templates/project/fullstack.d.ts +14 -0
  143. package/dist/cli/templates/project/fullstack.d.ts.map +1 -0
  144. package/dist/cli/templates/project/fullstack.js +19 -0
  145. package/dist/cli/templates/project/fullstack.js.map +1 -0
  146. package/dist/cli/templates/project/index.d.ts +26 -0
  147. package/dist/cli/templates/project/index.d.ts.map +1 -0
  148. package/dist/cli/templates/project/index.js +60 -0
  149. package/dist/cli/templates/project/index.js.map +1 -0
  150. package/dist/cli/templates/project/minimal.d.ts +6 -0
  151. package/dist/cli/templates/project/minimal.d.ts.map +1 -0
  152. package/dist/cli/templates/project/minimal.js +43 -0
  153. package/dist/cli/templates/project/minimal.js.map +1 -0
  154. package/dist/cli/templates/project/types.d.ts +80 -0
  155. package/dist/cli/templates/project/types.d.ts.map +1 -0
  156. package/dist/cli/templates/project/types.js +7 -0
  157. package/dist/cli/templates/project/types.js.map +1 -0
  158. package/dist/cli/templates/project/website.d.ts +8 -0
  159. package/dist/cli/templates/project/website.d.ts.map +1 -0
  160. package/dist/cli/templates/project/website.js +312 -0
  161. package/dist/cli/templates/project/website.js.map +1 -0
  162. package/dist/cli/utils/fs.d.ts +137 -0
  163. package/dist/cli/utils/fs.d.ts.map +1 -0
  164. package/dist/cli/utils/fs.js +350 -0
  165. package/dist/cli/utils/fs.js.map +1 -0
  166. package/dist/cli/utils/index.d.ts +9 -0
  167. package/dist/cli/utils/index.d.ts.map +1 -0
  168. package/dist/cli/utils/index.js +9 -0
  169. package/dist/cli/utils/index.js.map +1 -0
  170. package/dist/cli/utils/strings.d.ts +86 -0
  171. package/dist/cli/utils/strings.d.ts.map +1 -0
  172. package/dist/cli/utils/strings.js +190 -0
  173. package/dist/cli/utils/strings.js.map +1 -0
  174. package/dist/cli/utils/version.d.ts +15 -0
  175. package/dist/cli/utils/version.d.ts.map +1 -0
  176. package/dist/cli/utils/version.js +38 -0
  177. package/dist/cli/utils/version.js.map +1 -0
  178. package/dist/config/env-validation.d.ts +49 -0
  179. package/dist/config/env-validation.d.ts.map +1 -0
  180. package/dist/config/env-validation.js +77 -0
  181. package/dist/config/env-validation.js.map +1 -0
  182. package/dist/config/env.d.ts +167 -0
  183. package/dist/config/env.d.ts.map +1 -0
  184. package/dist/config/env.js +392 -0
  185. package/dist/config/env.js.map +1 -0
  186. package/dist/config/index.d.ts +168 -0
  187. package/dist/config/index.d.ts.map +1 -0
  188. package/dist/config/index.js +329 -0
  189. package/dist/config/index.js.map +1 -0
  190. package/dist/config/loader.d.ts +81 -0
  191. package/dist/config/loader.d.ts.map +1 -0
  192. package/dist/config/loader.js +242 -0
  193. package/dist/config/loader.js.map +1 -0
  194. package/dist/config/merge.d.ts +66 -0
  195. package/dist/config/merge.d.ts.map +1 -0
  196. package/dist/config/merge.js +226 -0
  197. package/dist/config/merge.js.map +1 -0
  198. package/dist/config/types.d.ts +322 -0
  199. package/dist/config/types.d.ts.map +1 -0
  200. package/dist/config/types.js +443 -0
  201. package/dist/config/types.js.map +1 -0
  202. package/dist/config/validation.d.ts +100 -0
  203. package/dist/config/validation.d.ts.map +1 -0
  204. package/dist/config/validation.js +548 -0
  205. package/dist/config/validation.js.map +1 -0
  206. package/dist/container/forward-ref.d.ts +116 -0
  207. package/dist/container/forward-ref.d.ts.map +1 -0
  208. package/dist/container/forward-ref.js +105 -0
  209. package/dist/container/forward-ref.js.map +1 -0
  210. package/dist/container/index.d.ts +95 -0
  211. package/dist/container/index.d.ts.map +1 -0
  212. package/dist/container/index.js.map +1 -0
  213. package/dist/context/index.d.ts +143 -0
  214. package/dist/context/index.d.ts.map +1 -0
  215. package/dist/context/index.js.map +1 -0
  216. package/dist/database/index.d.ts +219 -0
  217. package/dist/database/index.d.ts.map +1 -0
  218. package/dist/database/index.js.map +1 -0
  219. package/dist/database/migrations/index.d.ts +151 -0
  220. package/dist/database/migrations/index.d.ts.map +1 -0
  221. package/dist/database/migrations/index.js +258 -0
  222. package/dist/database/migrations/index.js.map +1 -0
  223. package/dist/database/orm/builder.d.ts +122 -0
  224. package/dist/database/orm/builder.d.ts.map +1 -0
  225. package/dist/database/orm/builder.js +355 -0
  226. package/dist/database/orm/builder.js.map +1 -0
  227. package/dist/database/orm/casts/index.d.ts +16 -0
  228. package/dist/database/orm/casts/index.d.ts.map +1 -0
  229. package/dist/database/orm/casts/index.js +131 -0
  230. package/dist/database/orm/casts/index.js.map +1 -0
  231. package/dist/database/orm/casts/types.d.ts +16 -0
  232. package/dist/database/orm/casts/types.d.ts.map +1 -0
  233. package/dist/database/orm/casts/types.js +5 -0
  234. package/dist/database/orm/casts/types.js.map +1 -0
  235. package/dist/database/orm/compiler.d.ts +90 -0
  236. package/dist/database/orm/compiler.d.ts.map +1 -0
  237. package/dist/database/orm/compiler.js +218 -0
  238. package/dist/database/orm/compiler.js.map +1 -0
  239. package/dist/database/orm/hooks/index.d.ts +53 -0
  240. package/dist/database/orm/hooks/index.d.ts.map +1 -0
  241. package/dist/database/orm/hooks/index.js +81 -0
  242. package/dist/database/orm/hooks/index.js.map +1 -0
  243. package/dist/database/orm/index.d.ts +21 -0
  244. package/dist/database/orm/index.d.ts.map +1 -0
  245. package/dist/database/orm/index.js +23 -0
  246. package/dist/database/orm/index.js.map +1 -0
  247. package/dist/database/orm/model-registry.d.ts +33 -0
  248. package/dist/database/orm/model-registry.d.ts.map +1 -0
  249. package/dist/database/orm/model-registry.js +49 -0
  250. package/dist/database/orm/model-registry.js.map +1 -0
  251. package/dist/database/orm/model.d.ts +245 -0
  252. package/dist/database/orm/model.d.ts.map +1 -0
  253. package/dist/database/orm/model.js +599 -0
  254. package/dist/database/orm/model.js.map +1 -0
  255. package/dist/database/orm/relationships/base.d.ts +69 -0
  256. package/dist/database/orm/relationships/base.d.ts.map +1 -0
  257. package/dist/database/orm/relationships/base.js +84 -0
  258. package/dist/database/orm/relationships/base.js.map +1 -0
  259. package/dist/database/orm/relationships/belongs-to-many.d.ts +47 -0
  260. package/dist/database/orm/relationships/belongs-to-many.d.ts.map +1 -0
  261. package/dist/database/orm/relationships/belongs-to-many.js +136 -0
  262. package/dist/database/orm/relationships/belongs-to-many.js.map +1 -0
  263. package/dist/database/orm/relationships/belongs-to.d.ts +17 -0
  264. package/dist/database/orm/relationships/belongs-to.d.ts.map +1 -0
  265. package/dist/database/orm/relationships/belongs-to.js +38 -0
  266. package/dist/database/orm/relationships/belongs-to.js.map +1 -0
  267. package/dist/database/orm/relationships/has-many.d.ts +14 -0
  268. package/dist/database/orm/relationships/has-many.d.ts.map +1 -0
  269. package/dist/database/orm/relationships/has-many.js +35 -0
  270. package/dist/database/orm/relationships/has-many.js.map +1 -0
  271. package/dist/database/orm/relationships/has-one.d.ts +14 -0
  272. package/dist/database/orm/relationships/has-one.d.ts.map +1 -0
  273. package/dist/database/orm/relationships/has-one.js +32 -0
  274. package/dist/database/orm/relationships/has-one.js.map +1 -0
  275. package/dist/database/orm/relationships/index.d.ts +10 -0
  276. package/dist/database/orm/relationships/index.d.ts.map +1 -0
  277. package/dist/database/orm/relationships/index.js +9 -0
  278. package/dist/database/orm/relationships/index.js.map +1 -0
  279. package/dist/database/orm/scopes/index.d.ts +36 -0
  280. package/dist/database/orm/scopes/index.d.ts.map +1 -0
  281. package/dist/database/orm/scopes/index.js +47 -0
  282. package/dist/database/orm/scopes/index.js.map +1 -0
  283. package/dist/database/schema/index.d.ts +155 -0
  284. package/dist/database/schema/index.d.ts.map +1 -0
  285. package/dist/database/schema/index.js +401 -0
  286. package/dist/database/schema/index.js.map +1 -0
  287. package/dist/frontend/api-routes.d.ts +189 -0
  288. package/dist/frontend/api-routes.d.ts.map +1 -0
  289. package/dist/frontend/api-routes.js +548 -0
  290. package/dist/frontend/api-routes.js.map +1 -0
  291. package/dist/frontend/bundler.d.ts +99 -0
  292. package/dist/frontend/bundler.d.ts.map +1 -0
  293. package/dist/frontend/bundler.js +555 -0
  294. package/dist/frontend/bundler.js.map +1 -0
  295. package/dist/frontend/console-client.d.ts +11 -0
  296. package/dist/frontend/console-client.d.ts.map +1 -0
  297. package/dist/frontend/console-client.js +414 -0
  298. package/dist/frontend/console-client.js.map +1 -0
  299. package/dist/frontend/console-stream.d.ts +138 -0
  300. package/dist/frontend/console-stream.d.ts.map +1 -0
  301. package/dist/frontend/console-stream.js +535 -0
  302. package/dist/frontend/console-stream.js.map +1 -0
  303. package/dist/frontend/dev-server.d.ts +174 -0
  304. package/dist/frontend/dev-server.d.ts.map +1 -0
  305. package/dist/frontend/dev-server.js +735 -0
  306. package/dist/frontend/dev-server.js.map +1 -0
  307. package/dist/frontend/file-router.d.ts +170 -0
  308. package/dist/frontend/file-router.d.ts.map +1 -0
  309. package/dist/frontend/file-router.js +531 -0
  310. package/dist/frontend/file-router.js.map +1 -0
  311. package/dist/frontend/frameworks/index.d.ts +41 -0
  312. package/dist/frontend/frameworks/index.d.ts.map +1 -0
  313. package/dist/frontend/frameworks/index.js +87 -0
  314. package/dist/frontend/frameworks/index.js.map +1 -0
  315. package/dist/frontend/frameworks/react.d.ts +32 -0
  316. package/dist/frontend/frameworks/react.d.ts.map +1 -0
  317. package/dist/frontend/frameworks/react.js +66 -0
  318. package/dist/frontend/frameworks/react.js.map +1 -0
  319. package/dist/frontend/frameworks/solid.d.ts +42 -0
  320. package/dist/frontend/frameworks/solid.d.ts.map +1 -0
  321. package/dist/frontend/frameworks/solid.js +84 -0
  322. package/dist/frontend/frameworks/solid.js.map +1 -0
  323. package/dist/frontend/frameworks/svelte.d.ts +57 -0
  324. package/dist/frontend/frameworks/svelte.d.ts.map +1 -0
  325. package/dist/frontend/frameworks/svelte.js +90 -0
  326. package/dist/frontend/frameworks/svelte.js.map +1 -0
  327. package/dist/frontend/frameworks/vue.d.ts +36 -0
  328. package/dist/frontend/frameworks/vue.d.ts.map +1 -0
  329. package/dist/frontend/frameworks/vue.js +72 -0
  330. package/dist/frontend/frameworks/vue.js.map +1 -0
  331. package/dist/frontend/hmr-client.d.ts +22 -0
  332. package/dist/frontend/hmr-client.d.ts.map +1 -0
  333. package/dist/frontend/hmr-client.js +654 -0
  334. package/dist/frontend/hmr-client.js.map +1 -0
  335. package/dist/frontend/hmr.d.ts +185 -0
  336. package/dist/frontend/hmr.d.ts.map +1 -0
  337. package/dist/frontend/hmr.js +619 -0
  338. package/dist/frontend/hmr.js.map +1 -0
  339. package/dist/frontend/index.d.ts +34 -0
  340. package/dist/frontend/index.d.ts.map +1 -0
  341. package/dist/frontend/index.js.map +1 -0
  342. package/dist/frontend/islands.d.ts +135 -0
  343. package/dist/frontend/islands.d.ts.map +1 -0
  344. package/dist/frontend/islands.js +455 -0
  345. package/dist/frontend/islands.js.map +1 -0
  346. package/dist/frontend/isr.d.ts +143 -0
  347. package/dist/frontend/isr.d.ts.map +1 -0
  348. package/dist/frontend/isr.js +440 -0
  349. package/dist/frontend/isr.js.map +1 -0
  350. package/dist/frontend/layout.d.ts +140 -0
  351. package/dist/frontend/layout.d.ts.map +1 -0
  352. package/dist/frontend/layout.js +392 -0
  353. package/dist/frontend/layout.js.map +1 -0
  354. package/dist/frontend/ssr/react.d.ts +118 -0
  355. package/dist/frontend/ssr/react.d.ts.map +1 -0
  356. package/dist/frontend/ssr/react.js +373 -0
  357. package/dist/frontend/ssr/react.js.map +1 -0
  358. package/dist/frontend/ssr/solid.d.ts +141 -0
  359. package/dist/frontend/ssr/solid.d.ts.map +1 -0
  360. package/dist/frontend/ssr/solid.js +440 -0
  361. package/dist/frontend/ssr/solid.js.map +1 -0
  362. package/dist/frontend/ssr/svelte.d.ts +158 -0
  363. package/dist/frontend/ssr/svelte.d.ts.map +1 -0
  364. package/dist/frontend/ssr/svelte.js +439 -0
  365. package/dist/frontend/ssr/svelte.js.map +1 -0
  366. package/dist/frontend/ssr/vue.d.ts +161 -0
  367. package/dist/frontend/ssr/vue.d.ts.map +1 -0
  368. package/dist/frontend/ssr/vue.js +385 -0
  369. package/dist/frontend/ssr/vue.js.map +1 -0
  370. package/dist/frontend/ssr.d.ts +147 -0
  371. package/dist/frontend/ssr.d.ts.map +1 -0
  372. package/dist/frontend/ssr.js +609 -0
  373. package/dist/frontend/ssr.js.map +1 -0
  374. package/dist/frontend/types.d.ts +1902 -0
  375. package/dist/frontend/types.d.ts.map +1 -0
  376. package/dist/frontend/types.js +8 -0
  377. package/dist/frontend/types.js.map +1 -0
  378. package/dist/graphql/built-in-engine.d.ts +36 -0
  379. package/dist/graphql/built-in-engine.d.ts.map +1 -0
  380. package/dist/graphql/built-in-engine.js +443 -0
  381. package/dist/graphql/built-in-engine.js.map +1 -0
  382. package/dist/graphql/context-builder.d.ts +44 -0
  383. package/dist/graphql/context-builder.d.ts.map +1 -0
  384. package/dist/graphql/context-builder.js +91 -0
  385. package/dist/graphql/context-builder.js.map +1 -0
  386. package/dist/graphql/decorators.d.ts +162 -0
  387. package/dist/graphql/decorators.d.ts.map +1 -0
  388. package/dist/graphql/decorators.js +291 -0
  389. package/dist/graphql/decorators.js.map +1 -0
  390. package/dist/graphql/execution-pipeline.d.ts +67 -0
  391. package/dist/graphql/execution-pipeline.d.ts.map +1 -0
  392. package/dist/graphql/execution-pipeline.js +127 -0
  393. package/dist/graphql/execution-pipeline.js.map +1 -0
  394. package/dist/graphql/graphql-module.d.ts +70 -0
  395. package/dist/graphql/graphql-module.d.ts.map +1 -0
  396. package/dist/graphql/graphql-module.js +442 -0
  397. package/dist/graphql/graphql-module.js.map +1 -0
  398. package/dist/graphql/index.d.ts +48 -0
  399. package/dist/graphql/index.d.ts.map +1 -0
  400. package/dist/graphql/index.js.map +1 -0
  401. package/dist/graphql/metadata.d.ts +37 -0
  402. package/dist/graphql/metadata.d.ts.map +1 -0
  403. package/dist/graphql/metadata.js +130 -0
  404. package/dist/graphql/metadata.js.map +1 -0
  405. package/dist/graphql/schema-builder.d.ts +34 -0
  406. package/dist/graphql/schema-builder.d.ts.map +1 -0
  407. package/dist/graphql/schema-builder.js +251 -0
  408. package/dist/graphql/schema-builder.js.map +1 -0
  409. package/dist/graphql/subscription-handler.d.ts +47 -0
  410. package/dist/graphql/subscription-handler.d.ts.map +1 -0
  411. package/dist/graphql/subscription-handler.js +201 -0
  412. package/dist/graphql/subscription-handler.js.map +1 -0
  413. package/dist/graphql/types.d.ts +252 -0
  414. package/dist/graphql/types.d.ts.map +1 -0
  415. package/dist/graphql/types.js +28 -0
  416. package/dist/graphql/types.js.map +1 -0
  417. package/dist/health/index.d.ts +176 -0
  418. package/dist/health/index.d.ts.map +1 -0
  419. package/dist/health/index.js.map +1 -0
  420. package/dist/i18n/engine.d.ts +105 -0
  421. package/dist/i18n/engine.d.ts.map +1 -0
  422. package/dist/i18n/engine.js +248 -0
  423. package/dist/i18n/engine.js.map +1 -0
  424. package/dist/i18n/index.d.ts +13 -0
  425. package/dist/i18n/index.d.ts.map +1 -0
  426. package/dist/i18n/index.js.map +1 -0
  427. package/dist/i18n/loader.d.ts +79 -0
  428. package/dist/i18n/loader.d.ts.map +1 -0
  429. package/dist/i18n/loader.js +192 -0
  430. package/dist/i18n/loader.js.map +1 -0
  431. package/dist/i18n/middleware.d.ts +96 -0
  432. package/dist/i18n/middleware.d.ts.map +1 -0
  433. package/dist/i18n/middleware.js +126 -0
  434. package/dist/i18n/middleware.js.map +1 -0
  435. package/dist/i18n/negotiator.d.ts +84 -0
  436. package/dist/i18n/negotiator.d.ts.map +1 -0
  437. package/dist/i18n/negotiator.js +139 -0
  438. package/dist/i18n/negotiator.js.map +1 -0
  439. package/dist/i18n/types.d.ts +129 -0
  440. package/dist/i18n/types.d.ts.map +1 -0
  441. package/dist/i18n/types.js +8 -0
  442. package/dist/i18n/types.js.map +1 -0
  443. package/dist/index.d.ts +48 -0
  444. package/dist/index.d.ts.map +1 -0
  445. package/dist/index.js.map +1 -0
  446. package/dist/jobs/drivers/memory.d.ts +38 -0
  447. package/dist/jobs/drivers/memory.d.ts.map +1 -0
  448. package/dist/jobs/drivers/memory.js +246 -0
  449. package/dist/jobs/drivers/memory.js.map +1 -0
  450. package/dist/jobs/drivers/redis.d.ts +34 -0
  451. package/dist/jobs/drivers/redis.d.ts.map +1 -0
  452. package/dist/jobs/drivers/redis.js +355 -0
  453. package/dist/jobs/drivers/redis.js.map +1 -0
  454. package/dist/jobs/index.d.ts +12 -0
  455. package/dist/jobs/index.d.ts.map +1 -0
  456. package/dist/jobs/index.js.map +1 -0
  457. package/dist/jobs/queue.d.ts +93 -0
  458. package/dist/jobs/queue.d.ts.map +1 -0
  459. package/dist/jobs/queue.js +233 -0
  460. package/dist/jobs/queue.js.map +1 -0
  461. package/dist/jobs/types.d.ts +193 -0
  462. package/dist/jobs/types.d.ts.map +1 -0
  463. package/dist/jobs/types.js +8 -0
  464. package/dist/jobs/types.js.map +1 -0
  465. package/dist/jobs/worker.d.ts +91 -0
  466. package/dist/jobs/worker.d.ts.map +1 -0
  467. package/dist/jobs/worker.js +300 -0
  468. package/dist/jobs/worker.js.map +1 -0
  469. package/dist/lock/index.d.ts +141 -0
  470. package/dist/lock/index.d.ts.map +1 -0
  471. package/dist/lock/index.js.map +1 -0
  472. package/dist/logger/index.d.ts +156 -0
  473. package/dist/logger/index.d.ts.map +1 -0
  474. package/dist/logger/index.js.map +1 -0
  475. package/dist/logger/transports/index.d.ts +371 -0
  476. package/dist/logger/transports/index.d.ts.map +1 -0
  477. package/dist/logger/transports/index.js +740 -0
  478. package/dist/logger/transports/index.js.map +1 -0
  479. package/dist/metrics/index.d.ts +163 -0
  480. package/dist/metrics/index.d.ts.map +1 -0
  481. package/dist/metrics/index.js.map +1 -0
  482. package/dist/middleware/built-in.d.ts +50 -0
  483. package/dist/middleware/built-in.d.ts.map +1 -0
  484. package/dist/middleware/built-in.js +220 -0
  485. package/dist/middleware/built-in.js.map +1 -0
  486. package/dist/middleware/index.d.ts +40 -0
  487. package/dist/middleware/index.d.ts.map +1 -0
  488. package/dist/middleware/index.js.map +1 -0
  489. package/dist/migrations/index.d.ts +48 -0
  490. package/dist/migrations/index.d.ts.map +1 -0
  491. package/dist/migrations/index.js +3 -0
  492. package/dist/migrations/index.js.map +1 -0
  493. package/dist/modules/filters.d.ts +150 -0
  494. package/dist/modules/filters.d.ts.map +1 -0
  495. package/dist/modules/filters.js +338 -0
  496. package/dist/modules/filters.js.map +1 -0
  497. package/dist/modules/guards.d.ts +188 -0
  498. package/dist/modules/guards.d.ts.map +1 -0
  499. package/dist/modules/guards.js +278 -0
  500. package/dist/modules/guards.js.map +1 -0
  501. package/dist/modules/index.d.ts +266 -0
  502. package/dist/modules/index.d.ts.map +1 -0
  503. package/dist/modules/index.js.map +1 -0
  504. package/dist/modules/interceptors.d.ts +242 -0
  505. package/dist/modules/interceptors.d.ts.map +1 -0
  506. package/dist/modules/interceptors.js +407 -0
  507. package/dist/modules/interceptors.js.map +1 -0
  508. package/dist/modules/lazy.d.ts +187 -0
  509. package/dist/modules/lazy.d.ts.map +1 -0
  510. package/dist/modules/lazy.js +305 -0
  511. package/dist/modules/lazy.js.map +1 -0
  512. package/dist/modules/lifecycle.d.ts +221 -0
  513. package/dist/modules/lifecycle.d.ts.map +1 -0
  514. package/dist/modules/lifecycle.js +314 -0
  515. package/dist/modules/lifecycle.js.map +1 -0
  516. package/dist/modules/metadata.d.ts +32 -0
  517. package/dist/modules/metadata.d.ts.map +1 -0
  518. package/dist/modules/metadata.js +59 -0
  519. package/dist/modules/metadata.js.map +1 -0
  520. package/dist/modules/pipes.d.ts +287 -0
  521. package/dist/modules/pipes.d.ts.map +1 -0
  522. package/dist/modules/pipes.js +443 -0
  523. package/dist/modules/pipes.js.map +1 -0
  524. package/dist/notification/channels/base.d.ts +32 -0
  525. package/dist/notification/channels/base.d.ts.map +1 -0
  526. package/dist/notification/channels/base.js +37 -0
  527. package/dist/notification/channels/base.js.map +1 -0
  528. package/dist/notification/channels/email.d.ts +37 -0
  529. package/dist/notification/channels/email.d.ts.map +1 -0
  530. package/dist/notification/channels/email.js +85 -0
  531. package/dist/notification/channels/email.js.map +1 -0
  532. package/dist/notification/channels/push.d.ts +37 -0
  533. package/dist/notification/channels/push.d.ts.map +1 -0
  534. package/dist/notification/channels/push.js +84 -0
  535. package/dist/notification/channels/push.js.map +1 -0
  536. package/dist/notification/channels/sms.d.ts +37 -0
  537. package/dist/notification/channels/sms.d.ts.map +1 -0
  538. package/dist/notification/channels/sms.js +83 -0
  539. package/dist/notification/channels/sms.js.map +1 -0
  540. package/dist/notification/channels/whatsapp.d.ts +37 -0
  541. package/dist/notification/channels/whatsapp.d.ts.map +1 -0
  542. package/dist/notification/channels/whatsapp.js +81 -0
  543. package/dist/notification/channels/whatsapp.js.map +1 -0
  544. package/dist/notification/index.d.ts +15 -0
  545. package/dist/notification/index.d.ts.map +1 -0
  546. package/dist/notification/index.js.map +1 -0
  547. package/dist/notification/service.d.ts +100 -0
  548. package/dist/notification/service.d.ts.map +1 -0
  549. package/dist/notification/service.js +279 -0
  550. package/dist/notification/service.js.map +1 -0
  551. package/dist/notification/types.d.ts +253 -0
  552. package/dist/notification/types.d.ts.map +1 -0
  553. package/dist/notification/types.js +14 -0
  554. package/dist/notification/types.js.map +1 -0
  555. package/dist/observability/__tests__/observability.test.d.ts +2 -0
  556. package/dist/observability/__tests__/observability.test.d.ts.map +1 -0
  557. package/dist/observability/__tests__/observability.test.js +404 -0
  558. package/dist/observability/__tests__/observability.test.js.map +1 -0
  559. package/dist/observability/breadcrumbs.d.ts +48 -0
  560. package/dist/observability/breadcrumbs.d.ts.map +1 -0
  561. package/dist/observability/breadcrumbs.js +97 -0
  562. package/dist/observability/breadcrumbs.js.map +1 -0
  563. package/dist/observability/index.d.ts +95 -0
  564. package/dist/observability/index.d.ts.map +1 -0
  565. package/dist/observability/index.js.map +1 -0
  566. package/dist/observability/interceptor.d.ts +19 -0
  567. package/dist/observability/interceptor.d.ts.map +1 -0
  568. package/dist/observability/interceptor.js +67 -0
  569. package/dist/observability/interceptor.js.map +1 -0
  570. package/dist/observability/service.d.ts +101 -0
  571. package/dist/observability/service.d.ts.map +1 -0
  572. package/dist/observability/service.js +249 -0
  573. package/dist/observability/service.js.map +1 -0
  574. package/dist/observability/trace.d.ts +21 -0
  575. package/dist/observability/trace.d.ts.map +1 -0
  576. package/dist/observability/trace.js +35 -0
  577. package/dist/observability/trace.js.map +1 -0
  578. package/dist/observability/types.d.ts +172 -0
  579. package/dist/observability/types.d.ts.map +1 -0
  580. package/dist/observability/types.js +8 -0
  581. package/dist/observability/types.js.map +1 -0
  582. package/dist/openapi/decorators.d.ts +173 -0
  583. package/dist/openapi/decorators.d.ts.map +1 -0
  584. package/dist/openapi/decorators.js +276 -0
  585. package/dist/openapi/decorators.js.map +1 -0
  586. package/dist/openapi/document-builder.d.ts +82 -0
  587. package/dist/openapi/document-builder.d.ts.map +1 -0
  588. package/dist/openapi/document-builder.js +228 -0
  589. package/dist/openapi/document-builder.js.map +1 -0
  590. package/dist/openapi/index.d.ts +48 -0
  591. package/dist/openapi/index.d.ts.map +1 -0
  592. package/dist/openapi/index.js.map +1 -0
  593. package/dist/openapi/metadata.d.ts +36 -0
  594. package/dist/openapi/metadata.d.ts.map +1 -0
  595. package/dist/openapi/metadata.js +78 -0
  596. package/dist/openapi/metadata.js.map +1 -0
  597. package/dist/openapi/route-scanner.d.ts +34 -0
  598. package/dist/openapi/route-scanner.d.ts.map +1 -0
  599. package/dist/openapi/route-scanner.js +174 -0
  600. package/dist/openapi/route-scanner.js.map +1 -0
  601. package/dist/openapi/schema-generator.d.ts +53 -0
  602. package/dist/openapi/schema-generator.d.ts.map +1 -0
  603. package/dist/openapi/schema-generator.js +236 -0
  604. package/dist/openapi/schema-generator.js.map +1 -0
  605. package/dist/openapi/swagger-module.d.ts +57 -0
  606. package/dist/openapi/swagger-module.d.ts.map +1 -0
  607. package/dist/openapi/swagger-module.js +143 -0
  608. package/dist/openapi/swagger-module.js.map +1 -0
  609. package/dist/openapi/types.d.ts +344 -0
  610. package/dist/openapi/types.d.ts.map +1 -0
  611. package/dist/openapi/types.js +7 -0
  612. package/dist/openapi/types.js.map +1 -0
  613. package/dist/orm/index.d.ts +10 -0
  614. package/dist/orm/index.d.ts.map +1 -0
  615. package/dist/orm/index.js.map +1 -0
  616. package/dist/router/index.d.ts +73 -0
  617. package/dist/router/index.d.ts.map +1 -0
  618. package/dist/router/index.js.map +1 -0
  619. package/dist/router/linear.d.ts +54 -0
  620. package/dist/router/linear.d.ts.map +1 -0
  621. package/dist/router/linear.js +261 -0
  622. package/dist/router/linear.js.map +1 -0
  623. package/dist/router/regex.d.ts +49 -0
  624. package/dist/router/regex.d.ts.map +1 -0
  625. package/dist/router/regex.js +201 -0
  626. package/dist/router/regex.js.map +1 -0
  627. package/dist/router/tree.d.ts +112 -0
  628. package/dist/router/tree.d.ts.map +1 -0
  629. package/dist/router/tree.js +360 -0
  630. package/dist/router/tree.js.map +1 -0
  631. package/dist/rpc/index.d.ts +321 -0
  632. package/dist/rpc/index.d.ts.map +1 -0
  633. package/dist/rpc/index.js.map +1 -0
  634. package/dist/schema/index.d.ts +10 -0
  635. package/dist/schema/index.d.ts.map +1 -0
  636. package/dist/schema/index.js.map +1 -0
  637. package/dist/security/index.d.ts +126 -0
  638. package/dist/security/index.d.ts.map +1 -0
  639. package/dist/security/index.js +309 -0
  640. package/dist/security/index.js.map +1 -0
  641. package/dist/ssg/index.d.ts +73 -0
  642. package/dist/ssg/index.d.ts.map +1 -0
  643. package/dist/ssg/index.js +464 -0
  644. package/dist/ssg/index.js.map +1 -0
  645. package/dist/storage/index.d.ts +99 -0
  646. package/dist/storage/index.d.ts.map +1 -0
  647. package/dist/storage/index.js +338 -0
  648. package/dist/storage/index.js.map +1 -0
  649. package/dist/telemetry/index.d.ts +376 -0
  650. package/dist/telemetry/index.d.ts.map +1 -0
  651. package/dist/telemetry/index.js.map +1 -0
  652. package/dist/template/index.d.ts +7 -0
  653. package/dist/template/index.d.ts.map +1 -0
  654. package/dist/template/index.js.map +1 -0
  655. package/dist/templates/engine.d.ts +60 -0
  656. package/dist/templates/engine.d.ts.map +1 -0
  657. package/dist/templates/engine.js +177 -0
  658. package/dist/templates/engine.js.map +1 -0
  659. package/dist/templates/index.d.ts +9 -0
  660. package/dist/templates/index.d.ts.map +1 -0
  661. package/dist/templates/index.js.map +1 -0
  662. package/dist/templates/loader.d.ts +45 -0
  663. package/dist/templates/loader.d.ts.map +1 -0
  664. package/dist/templates/loader.js +274 -0
  665. package/dist/templates/loader.js.map +1 -0
  666. package/dist/templates/renderers/markdown.d.ts +46 -0
  667. package/dist/templates/renderers/markdown.d.ts.map +1 -0
  668. package/dist/templates/renderers/markdown.js +181 -0
  669. package/dist/templates/renderers/markdown.js.map +1 -0
  670. package/dist/templates/renderers/simple.d.ts +35 -0
  671. package/dist/templates/renderers/simple.d.ts.map +1 -0
  672. package/dist/templates/renderers/simple.js +245 -0
  673. package/dist/templates/renderers/simple.js.map +1 -0
  674. package/dist/templates/types.d.ts +138 -0
  675. package/dist/templates/types.d.ts.map +1 -0
  676. package/dist/templates/types.js +8 -0
  677. package/dist/templates/types.js.map +1 -0
  678. package/dist/testing/index.d.ts +539 -0
  679. package/dist/testing/index.d.ts.map +1 -0
  680. package/dist/testing/index.js.map +1 -0
  681. package/dist/types/index.d.ts +116 -0
  682. package/dist/types/index.d.ts.map +1 -0
  683. package/dist/types/index.js.map +1 -0
  684. package/dist/validation/index.d.ts +89 -0
  685. package/dist/validation/index.d.ts.map +1 -0
  686. package/dist/validation/index.js +276 -0
  687. package/dist/validation/index.js.map +1 -0
  688. package/dist/validation/schemas.d.ts +283 -0
  689. package/dist/validation/schemas.d.ts.map +1 -0
  690. package/dist/validation/schemas.js +407 -0
  691. package/dist/validation/schemas.js.map +1 -0
  692. package/dist/websocket/index.d.ts +252 -0
  693. package/dist/websocket/index.d.ts.map +1 -0
  694. package/dist/websocket/index.js +749 -0
  695. package/dist/websocket/index.js.map +1 -0
  696. package/llms.txt +1 -1
  697. package/package.json +3 -3
  698. package/src/cli/commands/new.ts +1 -1
  699. package/src/cli/templates/frontend/react.ts +1 -1
  700. package/src/cli/templates/frontend/solid.ts +1 -1
  701. package/src/cli/templates/frontend/svelte.ts +1 -1
  702. package/src/cli/templates/frontend/vue.ts +1 -1
  703. package/src/cli/templates/project/default.ts +1 -1
  704. package/src/cli/templates/project/website.ts +3 -3
  705. package/src/database/migrations/index.ts +8 -0
  706. package/src/migrations/index.ts +40 -1
  707. package/src/types/index.ts +1 -1
  708. package/tsconfig.json +2 -6
@@ -0,0 +1,749 @@
1
+ /**
2
+ * WebSocket Helpers
3
+ *
4
+ * Utilities for WebSocket connections, pub/sub patterns,
5
+ * and real-time communication in Bueno applications.
6
+ */
7
+ export class WebSocketServer {
8
+ options;
9
+ connections = new Map();
10
+ rooms = new Map();
11
+ messageHandlers = new Map();
12
+ constructor(options = {}) {
13
+ this.options = {
14
+ idleTimeout: 255,
15
+ maxPayloadLength: 1024 * 1024, // 1MB
16
+ perMessageDeflate: true,
17
+ ...options,
18
+ };
19
+ }
20
+ /**
21
+ * Get Bun WebSocket configuration
22
+ */
23
+ getWebSocketConfig() {
24
+ return {
25
+ idleTimeout: this.options.idleTimeout,
26
+ maxPayloadLength: this.options.maxPayloadLength,
27
+ perMessageDeflate: this.options.perMessageDeflate,
28
+ open: (ws) => {
29
+ this.connections.set(ws.data.id, ws);
30
+ this.options.onOpen?.(ws);
31
+ },
32
+ message: (ws, message) => {
33
+ let parsed;
34
+ if (typeof message === "string") {
35
+ try {
36
+ parsed = JSON.parse(message);
37
+ }
38
+ catch {
39
+ parsed = { type: "raw", payload: message, timestamp: Date.now() };
40
+ }
41
+ }
42
+ else {
43
+ parsed = { type: "binary", payload: message, timestamp: Date.now() };
44
+ }
45
+ // Call global handler
46
+ this.options.onMessage?.(ws, parsed);
47
+ // Call type-specific handlers
48
+ const handlers = this.messageHandlers.get(parsed.type);
49
+ if (handlers) {
50
+ for (const handler of handlers) {
51
+ handler(ws, parsed);
52
+ }
53
+ }
54
+ },
55
+ close: (ws, code, reason) => {
56
+ this.connections.delete(ws.data.id);
57
+ // Remove from all rooms
58
+ for (const [room, members] of this.rooms) {
59
+ members.delete(ws.data.id);
60
+ }
61
+ this.options.onClose?.(ws, code, reason);
62
+ },
63
+ };
64
+ }
65
+ /**
66
+ * Register a message type handler
67
+ */
68
+ on(type, handler) {
69
+ const handlers = this.messageHandlers.get(type) ?? [];
70
+ handlers.push(handler);
71
+ this.messageHandlers.set(type, handlers);
72
+ return this;
73
+ }
74
+ /**
75
+ * Broadcast to all connections
76
+ */
77
+ broadcast(type, payload) {
78
+ const message = { type, payload, timestamp: Date.now() };
79
+ const data = JSON.stringify(message);
80
+ for (const ws of this.connections.values()) {
81
+ ws.send(data);
82
+ }
83
+ }
84
+ /**
85
+ * Send to specific connection
86
+ */
87
+ send(connectionId, type, payload) {
88
+ const ws = this.connections.get(connectionId);
89
+ if (!ws)
90
+ return false;
91
+ const message = { type, payload, timestamp: Date.now() };
92
+ ws.send(JSON.stringify(message));
93
+ return true;
94
+ }
95
+ /**
96
+ * Broadcast to a room
97
+ */
98
+ broadcastToRoom(room, type, payload) {
99
+ const members = this.rooms.get(room);
100
+ if (!members)
101
+ return;
102
+ const message = { type, payload, timestamp: Date.now() };
103
+ const data = JSON.stringify(message);
104
+ for (const id of members) {
105
+ const ws = this.connections.get(id);
106
+ if (ws) {
107
+ ws.send(data);
108
+ }
109
+ }
110
+ }
111
+ /**
112
+ * Join a room
113
+ */
114
+ joinRoom(connectionId, room) {
115
+ if (!this.rooms.has(room)) {
116
+ this.rooms.set(room, new Set());
117
+ }
118
+ this.rooms.get(room)?.add(connectionId);
119
+ }
120
+ /**
121
+ * Leave a room
122
+ */
123
+ leaveRoom(connectionId, room) {
124
+ this.rooms.get(room)?.delete(connectionId);
125
+ }
126
+ /**
127
+ * Get room members
128
+ */
129
+ getRoomMembers(room) {
130
+ return Array.from(this.rooms.get(room) ?? []);
131
+ }
132
+ /**
133
+ * Get all connection IDs
134
+ */
135
+ getConnectionIds() {
136
+ return Array.from(this.connections.keys());
137
+ }
138
+ /**
139
+ * Get connection count
140
+ */
141
+ get connectionCount() {
142
+ return this.connections.size;
143
+ }
144
+ /**
145
+ * Check if connection exists
146
+ */
147
+ hasConnection(connectionId) {
148
+ return this.connections.has(connectionId);
149
+ }
150
+ /**
151
+ * Close a connection
152
+ */
153
+ closeConnection(connectionId, code = 1000, reason = "Closed by server") {
154
+ const ws = this.connections.get(connectionId);
155
+ if (!ws)
156
+ return false;
157
+ ws.close(code, reason);
158
+ return true;
159
+ }
160
+ /**
161
+ * Close all connections
162
+ */
163
+ closeAll(code = 1000, reason = "Server shutting down") {
164
+ for (const ws of this.connections.values()) {
165
+ ws.close(code, reason);
166
+ }
167
+ }
168
+ }
169
+ export class WebSocketClient {
170
+ ws = null;
171
+ options;
172
+ reconnectAttempts = 0;
173
+ shouldReconnect = true;
174
+ messageQueue = [];
175
+ constructor(options) {
176
+ this.options = {
177
+ reconnect: true,
178
+ reconnectInterval: 1000,
179
+ maxReconnectAttempts: 5,
180
+ ...options,
181
+ };
182
+ }
183
+ /**
184
+ * Connect to WebSocket server
185
+ */
186
+ connect() {
187
+ return new Promise((resolve, reject) => {
188
+ try {
189
+ this.ws = new WebSocket(this.options.url, this.options.protocols);
190
+ this.shouldReconnect = true;
191
+ this.ws.onopen = () => {
192
+ this.reconnectAttempts = 0;
193
+ // Send queued messages
194
+ while (this.messageQueue.length > 0) {
195
+ const message = this.messageQueue.shift();
196
+ this.ws?.send(message);
197
+ }
198
+ this.options.onOpen?.();
199
+ resolve();
200
+ };
201
+ this.ws.onclose = (event) => {
202
+ this.options.onClose?.(event);
203
+ if (this.shouldReconnect && this.options.reconnect) {
204
+ this.attemptReconnect();
205
+ }
206
+ };
207
+ this.ws.onmessage = (event) => {
208
+ let message;
209
+ try {
210
+ message = JSON.parse(event.data);
211
+ }
212
+ catch {
213
+ message = {
214
+ type: "raw",
215
+ payload: event.data,
216
+ timestamp: Date.now(),
217
+ };
218
+ }
219
+ this.options.onMessage?.(message);
220
+ };
221
+ this.ws.onerror = (event) => {
222
+ this.options.onError?.(event);
223
+ reject(event);
224
+ };
225
+ }
226
+ catch (error) {
227
+ reject(error);
228
+ }
229
+ });
230
+ }
231
+ /**
232
+ * Attempt to reconnect
233
+ */
234
+ attemptReconnect() {
235
+ if (this.reconnectAttempts >= (this.options.maxReconnectAttempts ?? 5)) {
236
+ return;
237
+ }
238
+ this.reconnectAttempts++;
239
+ setTimeout(() => {
240
+ this.connect().catch(() => {
241
+ // Reconnect failed, will try again if attempts remaining
242
+ });
243
+ }, this.options.reconnectInterval);
244
+ }
245
+ /**
246
+ * Send a message
247
+ */
248
+ send(type, payload) {
249
+ const message = { type, payload, timestamp: Date.now() };
250
+ const data = JSON.stringify(message);
251
+ if (this.ws?.readyState === WebSocket.OPEN) {
252
+ this.ws.send(data);
253
+ }
254
+ else {
255
+ // Queue message for when connection is ready
256
+ this.messageQueue.push(data);
257
+ }
258
+ }
259
+ /**
260
+ * Send raw data
261
+ */
262
+ async sendRaw(data) {
263
+ if (this.ws?.readyState === WebSocket.OPEN) {
264
+ if (data instanceof Blob) {
265
+ this.ws.send(await data.arrayBuffer());
266
+ }
267
+ else {
268
+ this.ws.send(data);
269
+ }
270
+ }
271
+ }
272
+ /**
273
+ * Close the connection
274
+ */
275
+ close(code = 1000, reason = "Client closing") {
276
+ this.shouldReconnect = false;
277
+ this.ws?.close(code, reason);
278
+ }
279
+ /**
280
+ * Check if connected
281
+ */
282
+ get isConnected() {
283
+ return this.ws?.readyState === WebSocket.OPEN;
284
+ }
285
+ /**
286
+ * Get ready state
287
+ */
288
+ get readyState() {
289
+ return this.ws?.readyState ?? WebSocket.CLOSED;
290
+ }
291
+ }
292
+ // ============= In-Memory Pub/Sub (Fallback) =============
293
+ class InMemoryPubSub {
294
+ channels = new Map();
295
+ patterns = new Map();
296
+ async publish(channel, data) {
297
+ const message = {
298
+ channel,
299
+ data,
300
+ timestamp: Date.now(),
301
+ };
302
+ let deliveredCount = 0;
303
+ // Direct channel subscribers
304
+ const subscribers = this.channels.get(channel);
305
+ if (subscribers) {
306
+ for (const callback of subscribers) {
307
+ await callback(message);
308
+ deliveredCount++;
309
+ }
310
+ }
311
+ // Pattern subscribers
312
+ for (const [pattern, callbacks] of this.patterns) {
313
+ if (this.matchPattern(pattern, channel)) {
314
+ const patternMessage = { ...message, pattern };
315
+ for (const callback of callbacks) {
316
+ await callback(patternMessage);
317
+ deliveredCount++;
318
+ }
319
+ }
320
+ }
321
+ return deliveredCount;
322
+ }
323
+ async subscribe(channel, callback) {
324
+ if (!this.channels.has(channel)) {
325
+ this.channels.set(channel, new Set());
326
+ }
327
+ this.channels.get(channel)?.add(callback);
328
+ return () => {
329
+ this.channels.get(channel)?.delete(callback);
330
+ };
331
+ }
332
+ async psubscribe(pattern, callback) {
333
+ if (!this.patterns.has(pattern)) {
334
+ this.patterns.set(pattern, new Set());
335
+ }
336
+ this.patterns.get(pattern)?.add(callback);
337
+ return () => {
338
+ this.patterns.get(pattern)?.delete(callback);
339
+ };
340
+ }
341
+ async unsubscribe(channel) {
342
+ this.channels.delete(channel);
343
+ }
344
+ async punsubscribe(pattern) {
345
+ this.patterns.delete(pattern);
346
+ }
347
+ getChannelSubscribers(channel) {
348
+ return this.channels.get(channel)?.size ?? 0;
349
+ }
350
+ getPatternSubscribers(pattern) {
351
+ return this.patterns.get(pattern)?.size ?? 0;
352
+ }
353
+ getTotalSubscribers() {
354
+ let total = 0;
355
+ for (const subscribers of this.channels.values()) {
356
+ total += subscribers.size;
357
+ }
358
+ for (const subscribers of this.patterns.values()) {
359
+ total += subscribers.size;
360
+ }
361
+ return total;
362
+ }
363
+ async clear() {
364
+ this.channels.clear();
365
+ this.patterns.clear();
366
+ }
367
+ destroy() {
368
+ this.channels.clear();
369
+ this.patterns.clear();
370
+ }
371
+ /**
372
+ * Match a pattern against a channel name
373
+ * Supports * (match any characters) and ? (match single character)
374
+ */
375
+ matchPattern(pattern, channel) {
376
+ const regex = new RegExp(`^${pattern
377
+ .replace(/[.+^${}()|[\]\\]/g, "\\$&") // Escape special regex chars except * and ?
378
+ .replace(/\*/g, ".*") // * matches any characters
379
+ .replace(/\?/g, ".")}$`);
380
+ return regex.test(channel);
381
+ }
382
+ }
383
+ // ============= Redis Pub/Sub (Bun.redis Native) =============
384
+ class RedisPubSub {
385
+ publisher = null;
386
+ subscriber = null;
387
+ url;
388
+ keyPrefix;
389
+ channelCallbacks = new Map();
390
+ patternCallbacks = new Map();
391
+ _isConnected = false;
392
+ reconnect;
393
+ reconnectInterval;
394
+ maxReconnectAttempts;
395
+ reconnectAttempts = 0;
396
+ constructor(config) {
397
+ this.url = config.url ?? "redis://localhost:6379";
398
+ this.keyPrefix = config.keyPrefix ?? "";
399
+ this.reconnect = config.reconnect ?? true;
400
+ this.reconnectInterval = config.reconnectInterval ?? 1000;
401
+ this.maxReconnectAttempts = config.maxReconnectAttempts ?? 5;
402
+ }
403
+ async connect() {
404
+ try {
405
+ // Use Bun's native Redis client
406
+ const { RedisClient } = await import("bun");
407
+ // Create separate connections for pub and sub
408
+ // (Subscriber connections enter a special mode and can't run other commands)
409
+ this.publisher = new RedisClient(this.url);
410
+ this.subscriber = new RedisClient(this.url);
411
+ this._isConnected = true;
412
+ this.reconnectAttempts = 0;
413
+ }
414
+ catch (error) {
415
+ throw new Error(`Failed to connect to Redis: ${error instanceof Error ? error.message : String(error)}`);
416
+ }
417
+ }
418
+ async disconnect() {
419
+ const pub = this.publisher;
420
+ const sub = this.subscriber;
421
+ if (pub?.close)
422
+ await pub.close();
423
+ if (sub?.close)
424
+ await sub.close();
425
+ this._isConnected = false;
426
+ this.publisher = null;
427
+ this.subscriber = null;
428
+ }
429
+ get isConnected() {
430
+ return this._isConnected;
431
+ }
432
+ async publish(channel, data) {
433
+ if (!this._isConnected) {
434
+ throw new Error("Redis Pub/Sub not connected");
435
+ }
436
+ const fullChannel = this.keyPrefix + channel;
437
+ const message = JSON.stringify({
438
+ channel,
439
+ data,
440
+ timestamp: Date.now(),
441
+ });
442
+ const client = this.publisher;
443
+ return client.publish(fullChannel, message);
444
+ }
445
+ async subscribe(channel, callback) {
446
+ if (!this._isConnected) {
447
+ throw new Error("Redis Pub/Sub not connected");
448
+ }
449
+ const fullChannel = this.keyPrefix + channel;
450
+ // Store callback
451
+ if (!this.channelCallbacks.has(channel)) {
452
+ this.channelCallbacks.set(channel, new Set());
453
+ }
454
+ this.channelCallbacks.get(channel)?.add(callback);
455
+ // Subscribe to Redis channel
456
+ const client = this.subscriber;
457
+ // Create wrapper callback for Redis
458
+ const wrappedCallback = (message, redisChannel) => {
459
+ try {
460
+ const parsed = JSON.parse(message);
461
+ callback({
462
+ channel: parsed.channel ?? channel,
463
+ data: parsed.data,
464
+ timestamp: parsed.timestamp ?? Date.now(),
465
+ });
466
+ }
467
+ catch {
468
+ // Handle raw string messages
469
+ callback({
470
+ channel,
471
+ data: message,
472
+ timestamp: Date.now(),
473
+ });
474
+ }
475
+ };
476
+ await client.subscribe(fullChannel, wrappedCallback);
477
+ // Return unsubscribe function
478
+ return async () => {
479
+ this.channelCallbacks.get(channel)?.delete(callback);
480
+ // If no more callbacks for this channel, unsubscribe from Redis
481
+ if (this.channelCallbacks.get(channel)?.size === 0) {
482
+ this.channelCallbacks.delete(channel);
483
+ const unsubClient = this.subscriber;
484
+ await unsubClient.unsubscribe(fullChannel);
485
+ }
486
+ };
487
+ }
488
+ async psubscribe(pattern, callback) {
489
+ if (!this._isConnected) {
490
+ throw new Error("Redis Pub/Sub not connected");
491
+ }
492
+ const fullPattern = this.keyPrefix + pattern;
493
+ // Store callback
494
+ if (!this.patternCallbacks.has(pattern)) {
495
+ this.patternCallbacks.set(pattern, new Set());
496
+ }
497
+ this.patternCallbacks.get(pattern)?.add(callback);
498
+ // Subscribe to Redis pattern
499
+ const client = this.subscriber;
500
+ // Create wrapper callback for Redis
501
+ const wrappedCallback = (message, redisChannel, redisPattern) => {
502
+ try {
503
+ const parsed = JSON.parse(message);
504
+ callback({
505
+ channel: parsed.channel ?? redisChannel.replace(this.keyPrefix, ""),
506
+ pattern: pattern,
507
+ data: parsed.data,
508
+ timestamp: parsed.timestamp ?? Date.now(),
509
+ });
510
+ }
511
+ catch {
512
+ callback({
513
+ channel: redisChannel.replace(this.keyPrefix, ""),
514
+ pattern: pattern,
515
+ data: message,
516
+ timestamp: Date.now(),
517
+ });
518
+ }
519
+ };
520
+ await client.psubscribe(fullPattern, wrappedCallback);
521
+ // Return unsubscribe function
522
+ return async () => {
523
+ this.patternCallbacks.get(pattern)?.delete(callback);
524
+ // If no more callbacks for this pattern, unsubscribe from Redis
525
+ if (this.patternCallbacks.get(pattern)?.size === 0) {
526
+ this.patternCallbacks.delete(pattern);
527
+ const unsubClient = this.subscriber;
528
+ await unsubClient.punsubscribe(fullPattern);
529
+ }
530
+ };
531
+ }
532
+ async unsubscribe(channel) {
533
+ if (!this._isConnected)
534
+ return;
535
+ const fullChannel = this.keyPrefix + channel;
536
+ this.channelCallbacks.delete(channel);
537
+ const client = this.subscriber;
538
+ await client.unsubscribe(fullChannel);
539
+ }
540
+ async punsubscribe(pattern) {
541
+ if (!this._isConnected)
542
+ return;
543
+ const fullPattern = this.keyPrefix + pattern;
544
+ this.patternCallbacks.delete(pattern);
545
+ const client = this.subscriber;
546
+ await client.punsubscribe(fullPattern);
547
+ }
548
+ getChannelSubscribers(channel) {
549
+ return this.channelCallbacks.get(channel)?.size ?? 0;
550
+ }
551
+ getPatternSubscribers(pattern) {
552
+ return this.patternCallbacks.get(pattern)?.size ?? 0;
553
+ }
554
+ getTotalSubscribers() {
555
+ let total = 0;
556
+ for (const subscribers of this.channelCallbacks.values()) {
557
+ total += subscribers.size;
558
+ }
559
+ for (const subscribers of this.patternCallbacks.values()) {
560
+ total += subscribers.size;
561
+ }
562
+ return total;
563
+ }
564
+ async clear() {
565
+ // Unsubscribe from all channels
566
+ for (const channel of this.channelCallbacks.keys()) {
567
+ await this.unsubscribe(channel);
568
+ }
569
+ // Unsubscribe from all patterns
570
+ for (const pattern of this.patternCallbacks.keys()) {
571
+ await this.punsubscribe(pattern);
572
+ }
573
+ }
574
+ destroy() {
575
+ this.disconnect().catch(() => { });
576
+ this.channelCallbacks.clear();
577
+ this.patternCallbacks.clear();
578
+ }
579
+ }
580
+ // ============= Pub/Sub Class (Unified Interface) =============
581
+ export class PubSub {
582
+ driver;
583
+ driverType;
584
+ _isConnected = false;
585
+ constructor(config = {}) {
586
+ this.driverType = config.driver ?? "memory";
587
+ if (this.driverType === "redis" && config.url) {
588
+ this.driver = new RedisPubSub(config);
589
+ }
590
+ else {
591
+ this.driver = new InMemoryPubSub();
592
+ // Memory driver is always "connected"
593
+ this._isConnected = true;
594
+ }
595
+ }
596
+ /**
597
+ * Connect to the pub/sub backend (Redis only)
598
+ */
599
+ async connect() {
600
+ if (this.driver instanceof RedisPubSub) {
601
+ await this.driver.connect();
602
+ }
603
+ this._isConnected = true;
604
+ }
605
+ /**
606
+ * Disconnect from the pub/sub backend
607
+ */
608
+ async disconnect() {
609
+ if (this.driver instanceof RedisPubSub) {
610
+ await this.driver.disconnect();
611
+ }
612
+ else {
613
+ this.driver.destroy();
614
+ }
615
+ this._isConnected = false;
616
+ }
617
+ /**
618
+ * Check if connected
619
+ */
620
+ get isConnected() {
621
+ return this._isConnected;
622
+ }
623
+ /**
624
+ * Get the driver type
625
+ */
626
+ getDriverType() {
627
+ return this.driverType;
628
+ }
629
+ /**
630
+ * Publish a message to a channel
631
+ * Returns the number of subscribers that received the message
632
+ */
633
+ async publish(channel, data) {
634
+ return this.driver.publish(channel, data);
635
+ }
636
+ /**
637
+ * Subscribe to a channel
638
+ * Returns an unsubscribe function
639
+ */
640
+ async subscribe(channel, callback) {
641
+ return this.driver.subscribe(channel, callback);
642
+ }
643
+ /**
644
+ * Subscribe to channels matching a pattern
645
+ * Supports * (any characters) and ? (single character)
646
+ * Returns an unsubscribe function
647
+ */
648
+ async psubscribe(pattern, callback) {
649
+ return this.driver.psubscribe(pattern, callback);
650
+ }
651
+ /**
652
+ * Unsubscribe all callbacks from a channel
653
+ */
654
+ async unsubscribe(channel) {
655
+ return this.driver.unsubscribe(channel);
656
+ }
657
+ /**
658
+ * Unsubscribe all callbacks from a pattern
659
+ */
660
+ async punsubscribe(pattern) {
661
+ return this.driver.punsubscribe(pattern);
662
+ }
663
+ /**
664
+ * Get subscriber count for a specific channel
665
+ */
666
+ getChannelSubscribers(channel) {
667
+ return this.driver.getChannelSubscribers(channel);
668
+ }
669
+ /**
670
+ * Get subscriber count for a specific pattern
671
+ */
672
+ getPatternSubscribers(pattern) {
673
+ return this.driver.getPatternSubscribers(pattern);
674
+ }
675
+ /**
676
+ * Get total subscriber count across all channels and patterns
677
+ */
678
+ getTotalSubscribers() {
679
+ return this.driver.getTotalSubscribers();
680
+ }
681
+ /**
682
+ * Clear all subscriptions
683
+ */
684
+ async clear() {
685
+ return this.driver.clear();
686
+ }
687
+ /**
688
+ * Destroy the pub/sub instance and release resources
689
+ */
690
+ destroy() {
691
+ this.driver.destroy();
692
+ this._isConnected = false;
693
+ }
694
+ }
695
+ // ============= Factory Functions =============
696
+ /**
697
+ * Create a WebSocket server
698
+ */
699
+ export function createWebSocketServer(options) {
700
+ return new WebSocketServer(options);
701
+ }
702
+ /**
703
+ * Create a WebSocket client
704
+ */
705
+ export function createWebSocketClient(options) {
706
+ return new WebSocketClient(options);
707
+ }
708
+ /**
709
+ * Create a pub/sub instance
710
+ * @param config Configuration options including driver type and Redis URL
711
+ */
712
+ export function createPubSub(config) {
713
+ return new PubSub(config);
714
+ }
715
+ /**
716
+ * Create a Redis pub/sub instance (convenience function)
717
+ */
718
+ export function createRedisPubSub(url, options) {
719
+ return new PubSub({ driver: "redis", url, ...options });
720
+ }
721
+ /**
722
+ * Create an in-memory pub/sub instance (convenience function)
723
+ */
724
+ export function createMemoryPubSub() {
725
+ return new PubSub({ driver: "memory" });
726
+ }
727
+ // ============= Upgrade Helper =============
728
+ /**
729
+ * Check if request is a WebSocket upgrade request
730
+ */
731
+ export function isWebSocketRequest(request) {
732
+ return request.headers.get("upgrade")?.toLowerCase() === "websocket";
733
+ }
734
+ /**
735
+ * Generate WebSocket connection ID
736
+ */
737
+ export function generateConnectionId() {
738
+ return crypto.randomUUID();
739
+ }
740
+ /**
741
+ * Create WebSocket data for new connection
742
+ */
743
+ export function createWebSocketData(data) {
744
+ return {
745
+ id: generateConnectionId(),
746
+ ...data,
747
+ };
748
+ }
749
+ //# sourceMappingURL=index.js.map