gemi 0.56.0 → 0.58.0

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 (257) hide show
  1. package/dist/app/index.js +1 -1
  2. package/dist/broadcasting/index.js +1 -1
  3. package/dist/bun/plugin.js +1 -1
  4. package/dist/bun/preload.js +1 -1
  5. package/dist/{chunk-jdj7k3r9.js → chunk-0a2xgcj3.js} +2 -2
  6. package/dist/{chunk-jdj7k3r9.js.map → chunk-0a2xgcj3.js.map} +1 -1
  7. package/dist/{chunk-3e88tyee.js → chunk-3337e5g0.js} +2 -2
  8. package/dist/{chunk-3e88tyee.js.map → chunk-3337e5g0.js.map} +1 -1
  9. package/dist/chunk-3aa287k7.js +6 -0
  10. package/dist/{chunk-cv9w5cmb.js.map → chunk-3aa287k7.js.map} +2 -2
  11. package/dist/{chunk-01am9k5v.js → chunk-3g5bjvdf.js} +2 -2
  12. package/dist/{chunk-01am9k5v.js.map → chunk-3g5bjvdf.js.map} +1 -1
  13. package/dist/{chunk-w9k9s4wh.js → chunk-3xadx444.js} +2 -2
  14. package/dist/{chunk-w9k9s4wh.js.map → chunk-3xadx444.js.map} +1 -1
  15. package/dist/{chunk-npg72mez.js → chunk-3zxwscmf.js} +2 -2
  16. package/dist/{chunk-kgmr9qxx.js.map → chunk-3zxwscmf.js.map} +1 -1
  17. package/dist/{chunk-64s1pzz1.js → chunk-437085pe.js} +2 -2
  18. package/dist/{chunk-64s1pzz1.js.map → chunk-437085pe.js.map} +1 -1
  19. package/dist/{chunk-eqrd31ye.js → chunk-4yt5x8s2.js} +2 -2
  20. package/dist/{chunk-eqrd31ye.js.map → chunk-4yt5x8s2.js.map} +1 -1
  21. package/dist/{chunk-9r0sb4zn.js → chunk-5athahgr.js} +2 -2
  22. package/dist/{chunk-9r0sb4zn.js.map → chunk-5athahgr.js.map} +1 -1
  23. package/dist/{chunk-g30q4n5y.js → chunk-5n2rvfh3.js} +2 -2
  24. package/dist/{chunk-g30q4n5y.js.map → chunk-5n2rvfh3.js.map} +1 -1
  25. package/dist/{chunk-1zfsgffv.js → chunk-6235kb30.js} +3 -3
  26. package/dist/{chunk-1zfsgffv.js.map → chunk-6235kb30.js.map} +1 -1
  27. package/dist/{chunk-javjeayw.js → chunk-7b0x860b.js} +2 -2
  28. package/dist/{chunk-javjeayw.js.map → chunk-7b0x860b.js.map} +1 -1
  29. package/dist/{chunk-4qwwy968.js → chunk-7ef5n8k2.js} +2 -2
  30. package/dist/{chunk-4qwwy968.js.map → chunk-7ef5n8k2.js.map} +1 -1
  31. package/dist/{chunk-q0waxxz5.js → chunk-7j6wbv12.js} +2 -2
  32. package/dist/{chunk-q0waxxz5.js.map → chunk-7j6wbv12.js.map} +1 -1
  33. package/dist/chunk-86jebsm4.js +9 -0
  34. package/dist/{chunk-kry5vwam.js.map → chunk-86jebsm4.js.map} +3 -3
  35. package/dist/chunk-87qab82w.js +5 -0
  36. package/dist/chunk-87qab82w.js.map +37 -0
  37. package/dist/{chunk-36pg61vt.js → chunk-8gew8b9a.js} +2 -2
  38. package/dist/{chunk-36pg61vt.js.map → chunk-8gew8b9a.js.map} +1 -1
  39. package/dist/{chunk-v6v6sem5.js → chunk-9m2tbf3n.js} +2 -2
  40. package/dist/{chunk-v6v6sem5.js.map → chunk-9m2tbf3n.js.map} +1 -1
  41. package/dist/{chunk-gzdf2025.js → chunk-a2sgjpvq.js} +2 -2
  42. package/dist/{chunk-gzdf2025.js.map → chunk-a2sgjpvq.js.map} +1 -1
  43. package/dist/chunk-b35e128b.js +5 -0
  44. package/dist/{chunk-b50zmz3t.js.map → chunk-b35e128b.js.map} +1 -1
  45. package/dist/{chunk-ct274qts.js → chunk-cyaz97p5.js} +2 -2
  46. package/dist/{chunk-ct274qts.js.map → chunk-cyaz97p5.js.map} +1 -1
  47. package/dist/{chunk-v06qcyj5.js → chunk-d125j8t0.js} +3 -3
  48. package/dist/{chunk-v06qcyj5.js.map → chunk-d125j8t0.js.map} +1 -1
  49. package/dist/{chunk-hs5v3eqj.js → chunk-dgsgjg53.js} +2 -2
  50. package/dist/{chunk-hs5v3eqj.js.map → chunk-dgsgjg53.js.map} +1 -1
  51. package/dist/{chunk-xjy5apyr.js → chunk-eejmhtnc.js} +2 -2
  52. package/dist/{chunk-xjy5apyr.js.map → chunk-eejmhtnc.js.map} +1 -1
  53. package/dist/{chunk-3y75q5a2.js → chunk-fjm4y8bn.js} +2 -2
  54. package/dist/{chunk-3y75q5a2.js.map → chunk-fjm4y8bn.js.map} +1 -1
  55. package/dist/{chunk-9c89q2mz.js → chunk-grdahng8.js} +2 -2
  56. package/dist/{chunk-9c89q2mz.js.map → chunk-grdahng8.js.map} +1 -1
  57. package/dist/{chunk-699z6d8y.js → chunk-gw6agevz.js} +3 -3
  58. package/dist/{chunk-699z6d8y.js.map → chunk-gw6agevz.js.map} +1 -1
  59. package/dist/{chunk-62ke19q4.js → chunk-hppagzz4.js} +4 -4
  60. package/dist/{chunk-62ke19q4.js.map → chunk-hppagzz4.js.map} +1 -1
  61. package/dist/chunk-hwa5sqw5.js +19 -0
  62. package/dist/{chunk-tmnhkphv.js.map → chunk-hwa5sqw5.js.map} +12 -6
  63. package/dist/chunk-hxf1re93.js +4 -0
  64. package/dist/{chunk-vkngcrzq.js.map → chunk-hxf1re93.js.map} +6 -5
  65. package/dist/{chunk-d36dfqxw.js → chunk-j0c6ytkj.js} +3 -3
  66. package/dist/{chunk-d36dfqxw.js.map → chunk-j0c6ytkj.js.map} +1 -1
  67. package/dist/{chunk-kgmr9qxx.js → chunk-jhkjz9jr.js} +2 -2
  68. package/dist/{chunk-npg72mez.js.map → chunk-jhkjz9jr.js.map} +1 -1
  69. package/dist/{chunk-62723jyy.js → chunk-k0fvsyeh.js} +1 -1
  70. package/dist/{chunk-31kcf7dq.js → chunk-keehyx51.js} +2 -2
  71. package/dist/{chunk-31kcf7dq.js.map → chunk-keehyx51.js.map} +1 -1
  72. package/dist/{chunk-enhkf60v.js → chunk-m3xy5xyf.js} +2 -2
  73. package/dist/{chunk-enhkf60v.js.map → chunk-m3xy5xyf.js.map} +1 -1
  74. package/dist/{chunk-c75mymmq.js → chunk-mkfpnymy.js} +1 -1
  75. package/dist/{chunk-rgb69nh1.js → chunk-mwpdp09e.js} +2 -2
  76. package/dist/{chunk-rgb69nh1.js.map → chunk-mwpdp09e.js.map} +1 -1
  77. package/dist/chunk-pmhd6zfc.js +37 -0
  78. package/dist/chunk-pmhd6zfc.js.map +20 -0
  79. package/dist/chunk-qb5mv6pj.js +5 -0
  80. package/dist/chunk-qb5mv6pj.js.map +12 -0
  81. package/dist/{chunk-1pwwrpa3.js → chunk-qgxr0g36.js} +2 -2
  82. package/dist/{chunk-1pwwrpa3.js.map → chunk-qgxr0g36.js.map} +1 -1
  83. package/dist/{chunk-4yafsffx.js → chunk-sy7jbdeb.js} +2 -2
  84. package/dist/{chunk-4yafsffx.js.map → chunk-sy7jbdeb.js.map} +1 -1
  85. package/dist/{chunk-gasdfwva.js → chunk-szss069z.js} +2 -2
  86. package/dist/{chunk-gasdfwva.js.map → chunk-szss069z.js.map} +1 -1
  87. package/dist/{chunk-m0ggfy1m.js → chunk-tss5svjr.js} +2 -2
  88. package/dist/{chunk-m0ggfy1m.js.map → chunk-tss5svjr.js.map} +1 -1
  89. package/dist/{chunk-dzzmqv0j.js → chunk-vr90r27j.js} +2 -2
  90. package/dist/{chunk-dzzmqv0j.js.map → chunk-vr90r27j.js.map} +1 -1
  91. package/dist/{chunk-pvdbrt4z.js → chunk-w62m5f0n.js} +3 -3
  92. package/dist/{chunk-pvdbrt4z.js.map → chunk-w62m5f0n.js.map} +1 -1
  93. package/dist/{chunk-cn2r5jfj.js → chunk-w7rf99w6.js} +2 -2
  94. package/dist/{chunk-cn2r5jfj.js.map → chunk-w7rf99w6.js.map} +1 -1
  95. package/dist/{chunk-tja0c815.js → chunk-wbrj0gya.js} +2 -2
  96. package/dist/{chunk-tja0c815.js.map → chunk-wbrj0gya.js.map} +1 -1
  97. package/dist/{chunk-rsdg619q.js → chunk-xdv1b8mr.js} +2 -2
  98. package/dist/{chunk-rsdg619q.js.map → chunk-xdv1b8mr.js.map} +1 -1
  99. package/dist/{chunk-h3mwgbg7.js → chunk-xey9cbap.js} +2 -2
  100. package/dist/{chunk-h3mwgbg7.js.map → chunk-xey9cbap.js.map} +1 -1
  101. package/dist/{chunk-wgpa04jb.js → chunk-xzk827r3.js} +2 -2
  102. package/dist/{chunk-wgpa04jb.js.map → chunk-xzk827r3.js.map} +1 -1
  103. package/dist/{chunk-x14sk95v.js → chunk-y6a8r2bn.js} +3 -3
  104. package/dist/{chunk-x14sk95v.js.map → chunk-y6a8r2bn.js.map} +1 -1
  105. package/dist/{chunk-33wjsw4r.js → chunk-yed5whgs.js} +3 -3
  106. package/dist/{chunk-33wjsw4r.js.map → chunk-yed5whgs.js.map} +1 -1
  107. package/dist/{chunk-02gdzs5t.js → chunk-yf7vz71n.js} +1 -1
  108. package/dist/{chunk-y9fp58bg.js → chunk-yjzs247s.js} +2 -2
  109. package/dist/{chunk-y9fp58bg.js.map → chunk-yjzs247s.js.map} +1 -1
  110. package/dist/{chunk-kgg1eqne.js → chunk-yy0eb9wn.js} +2 -2
  111. package/dist/{chunk-kgg1eqne.js.map → chunk-yy0eb9wn.js.map} +1 -1
  112. package/dist/{chunk-4xx78ba9.js → chunk-zbxgbr12.js} +2 -2
  113. package/dist/{chunk-4xx78ba9.js.map → chunk-zbxgbr12.js.map} +1 -1
  114. package/dist/{chunk-8k1zqrvh.js → chunk-zh2egcyb.js} +2 -2
  115. package/dist/{chunk-8k1zqrvh.js.map → chunk-zh2egcyb.js.map} +1 -1
  116. package/dist/chunks/ThemeProvider-li1J_igh.js.map +1 -1
  117. package/dist/client/ClientRouter.d.ts.map +1 -1
  118. package/dist/client/ProgressManager.d.ts +1 -1
  119. package/dist/client/RouteStateContext.d.ts +9 -0
  120. package/dist/client/RouteStateContext.d.ts.map +1 -1
  121. package/dist/client/ServerDataProvider.d.ts +7 -0
  122. package/dist/client/ServerDataProvider.d.ts.map +1 -1
  123. package/dist/client/index.d.ts +2 -1
  124. package/dist/client/index.d.ts.map +1 -1
  125. package/dist/client/index.js +68 -10
  126. package/dist/client/index.js.map +1 -1
  127. package/dist/client/rpc.d.ts +42 -0
  128. package/dist/client/rpc.d.ts.map +1 -1
  129. package/dist/client/useFeature.d.ts +40 -0
  130. package/dist/client/useFeature.d.ts.map +1 -0
  131. package/dist/config/index.js +1 -1
  132. package/dist/console/run.js +2 -2
  133. package/dist/console/run.js.map +1 -1
  134. package/dist/container/index.js +2 -2
  135. package/dist/container/index.js.map +1 -1
  136. package/dist/database/index.js +2 -2
  137. package/dist/database/index.js.map +1 -1
  138. package/dist/email/index.js +2 -2
  139. package/dist/email/index.js.map +1 -1
  140. package/dist/facades/Features.d.ts +57 -0
  141. package/dist/facades/Features.d.ts.map +1 -0
  142. package/dist/facades/index.d.ts +1 -0
  143. package/dist/facades/index.d.ts.map +1 -1
  144. package/dist/facades/index.js +2 -2
  145. package/dist/facades/index.js.map +1 -1
  146. package/dist/foundation/index.js +2 -2
  147. package/dist/foundation/index.js.map +1 -1
  148. package/dist/gemi.d.ts +13 -5
  149. package/dist/http/ApiRouter.d.ts +3 -2
  150. package/dist/http/ApiRouter.d.ts.map +1 -1
  151. package/dist/http/HttpRequest.d.ts +4 -0
  152. package/dist/http/HttpRequest.d.ts.map +1 -1
  153. package/dist/http/ViewRouter.d.ts +127 -4
  154. package/dist/http/ViewRouter.d.ts.map +1 -1
  155. package/dist/http/index.d.ts +1 -0
  156. package/dist/http/index.d.ts.map +1 -1
  157. package/dist/http/index.js +2 -2
  158. package/dist/http/index.js.map +1 -1
  159. package/dist/http/middlewareList.d.ts +25 -0
  160. package/dist/http/middlewareList.d.ts.map +1 -0
  161. package/dist/http/requestContext.d.ts +57 -0
  162. package/dist/http/requestContext.d.ts.map +1 -1
  163. package/dist/i18n/dictionaryRuntime.js +2 -2
  164. package/dist/i18n/dictionaryRuntime.js.map +1 -1
  165. package/dist/i18n/index.js +2 -2
  166. package/dist/i18n/index.js.map +1 -1
  167. package/dist/ide/typescript-plugin/index.js +1206 -0
  168. package/dist/ide/typescript-plugin/index.js.map +17 -0
  169. package/dist/kernel/index.js +3 -3
  170. package/dist/kernel/index.js.map +3 -3
  171. package/dist/kernel/providers.d.ts +16 -4
  172. package/dist/kernel/providers.d.ts.map +1 -1
  173. package/dist/orm/context.d.ts +65 -0
  174. package/dist/orm/context.d.ts.map +1 -1
  175. package/dist/orm/index.js +2 -2
  176. package/dist/orm/index.js.map +1 -1
  177. package/dist/server/index.js +2 -2
  178. package/dist/server/index.js.map +1 -1
  179. package/dist/services/discovery.d.ts +27 -0
  180. package/dist/services/discovery.d.ts.map +1 -1
  181. package/dist/services/events/Event.d.ts +208 -0
  182. package/dist/services/events/Event.d.ts.map +1 -0
  183. package/dist/services/events/EventManager.d.ts +285 -0
  184. package/dist/services/events/EventManager.d.ts.map +1 -0
  185. package/dist/services/events/EventServiceProvider.d.ts +46 -0
  186. package/dist/services/events/EventServiceProvider.d.ts.map +1 -0
  187. package/dist/services/events/FakeEventManager.d.ts +155 -0
  188. package/dist/services/events/FakeEventManager.d.ts.map +1 -0
  189. package/dist/services/events/FakeEventManager.test-d.d.ts +2 -0
  190. package/dist/services/events/FakeEventManager.test-d.d.ts.map +1 -0
  191. package/dist/services/events/Listener.d.ts +189 -0
  192. package/dist/services/events/Listener.d.ts.map +1 -0
  193. package/dist/services/events/Listener.test-d.d.ts +2 -0
  194. package/dist/services/events/Listener.test-d.d.ts.map +1 -0
  195. package/dist/services/events/config.d.ts +55 -0
  196. package/dist/services/events/config.d.ts.map +1 -0
  197. package/dist/services/events/listenerJob.d.ts +43 -0
  198. package/dist/services/events/listenerJob.d.ts.map +1 -0
  199. package/dist/services/features/FeatureFlagStore.d.ts +60 -0
  200. package/dist/services/features/FeatureFlagStore.d.ts.map +1 -0
  201. package/dist/services/features/FeatureManager.d.ts +82 -0
  202. package/dist/services/features/FeatureManager.d.ts.map +1 -0
  203. package/dist/services/features/FeaturesServiceProvider.d.ts +6 -0
  204. package/dist/services/features/FeaturesServiceProvider.d.ts.map +1 -0
  205. package/dist/services/features/bucket.d.ts +57 -0
  206. package/dist/services/features/bucket.d.ts.map +1 -0
  207. package/dist/services/features/config.d.ts +57 -0
  208. package/dist/services/features/config.d.ts.map +1 -0
  209. package/dist/services/features/context.d.ts +31 -0
  210. package/dist/services/features/context.d.ts.map +1 -0
  211. package/dist/services/features/defineFeature.d.ts +145 -0
  212. package/dist/services/features/defineFeature.d.ts.map +1 -0
  213. package/dist/services/features/evaluate.d.ts +74 -0
  214. package/dist/services/features/evaluate.d.ts.map +1 -0
  215. package/dist/services/features/sources/DatabaseFeatureFlagSource.d.ts +19 -0
  216. package/dist/services/features/sources/DatabaseFeatureFlagSource.d.ts.map +1 -0
  217. package/dist/services/features/sources/FeatureFlagSource.d.ts +30 -0
  218. package/dist/services/features/sources/FeatureFlagSource.d.ts.map +1 -0
  219. package/dist/services/features/sources/StaticFeatureFlagSource.d.ts +24 -0
  220. package/dist/services/features/sources/StaticFeatureFlagSource.d.ts.map +1 -0
  221. package/dist/services/features/types.d.ts +63 -0
  222. package/dist/services/features/types.d.ts.map +1 -0
  223. package/dist/services/index.d.ts +18 -1
  224. package/dist/services/index.d.ts.map +1 -1
  225. package/dist/services/index.js +8 -8
  226. package/dist/services/index.js.map +8 -4
  227. package/dist/services/queue/QueueManager.d.ts +31 -0
  228. package/dist/services/queue/QueueManager.d.ts.map +1 -1
  229. package/dist/services/router/ViewRouteDispatcher.d.ts +8 -0
  230. package/dist/services/router/ViewRouteDispatcher.d.ts.map +1 -1
  231. package/dist/services/router/createFlatViewRoutes.d.ts +14 -0
  232. package/dist/services/router/createFlatViewRoutes.d.ts.map +1 -1
  233. package/dist/services/router/streamQueryInjection.d.ts.map +1 -1
  234. package/dist/support/index.js +2 -2
  235. package/dist/support/index.js.map +1 -1
  236. package/dist/testing/Page.d.ts +12 -0
  237. package/dist/testing/Page.d.ts.map +1 -1
  238. package/dist/testing/index.d.ts +24 -0
  239. package/dist/testing/index.d.ts.map +1 -1
  240. package/dist/testing/index.js +7 -3
  241. package/dist/testing/index.js.map +1 -1
  242. package/ide/typescript-plugin/package.json +5 -0
  243. package/package.json +4 -2
  244. package/dist/chunk-4t80js0n.js +0 -33
  245. package/dist/chunk-4t80js0n.js.map +0 -18
  246. package/dist/chunk-98a576s9.js +0 -5
  247. package/dist/chunk-98a576s9.js.map +0 -30
  248. package/dist/chunk-b50zmz3t.js +0 -5
  249. package/dist/chunk-cv9w5cmb.js +0 -6
  250. package/dist/chunk-f9mfw82d.js +0 -5
  251. package/dist/chunk-f9mfw82d.js.map +0 -12
  252. package/dist/chunk-kry5vwam.js +0 -9
  253. package/dist/chunk-tmnhkphv.js +0 -19
  254. package/dist/chunk-vkngcrzq.js +0 -4
  255. /package/dist/{chunk-62723jyy.js.map → chunk-k0fvsyeh.js.map} +0 -0
  256. /package/dist/{chunk-c75mymmq.js.map → chunk-mkfpnymy.js.map} +0 -0
  257. /package/dist/{chunk-02gdzs5t.js.map → chunk-yf7vz71n.js.map} +0 -0
@@ -1,18 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../services/queue/config.ts", "../services/queue/QueueManager.ts", "../console/Command.ts", "../console/config.ts", "../console/builder.ts", "../services/cron/CronJob.ts", "../services/cron/config.ts", "../services/queue/Job.ts", "../services/discovery.ts"],
4
- "sourcesContent": [
5
- "import type { Job } from \"./Job\";\n\n// Config key: `queue`. Derived from `QueueServiceProvider`.\nexport interface QueueConfig {\n /**\n * The `Job` subclasses this application dispatches, or nothing.\n *\n * ### Why \"or nothing\" is the point\n *\n * A dispatch that names a job the `QueueManager` has never heard of does not\n * fail — `next()` looks the name up in this list, and what is not there is\n * dropped with a line on stderr and nothing else. `Job.dispatch` has already\n * returned by then, so nothing upstream can be told. The list is therefore a\n * second spelling of `app/jobs`, kept in step by hand, and the cost of the\n * two disagreeing is paid by whatever was supposed to happen after the\n * dispatch.\n *\n * Leaving this out spells it once: the jobs are the classes under `jobsDir`.\n *\n * ### The rule, exactly\n *\n * **Declared wins, and `[]` is declared.** A `jobs` that is present is used\n * verbatim and no directory is read — that is the escape hatch for an app\n * whose jobs live somewhere this cannot walk, for one that deliberately\n * registers a subset, and for a deploy that ships no source. An empty array\n * means an app with no jobs and says so; it does not mean \"find some\".\n *\n * **Absent or `undefined` discovers.** `undefined` counts as absent for the\n * same reason `withDefaults` treats it that way everywhere else: a key spread\n * in from an optional value is an omission, not an instruction.\n */\n jobs?: Array<new () => Job>;\n\n /**\n * Where to look when `jobs` was not declared. Relative to the project root,\n * or absolute.\n *\n * Every `.ts`/`.tsx` file underneath it is imported at boot and every exported\n * class extending `Job` is registered, so this wants to be a directory of job\n * declarations rather than a directory that merely contains some. Moving the\n * jobs is what this field is for; pointing it at `app/` is not.\n */\n jobsDir?: string;\n\n concurrency?: number;\n}\n\nexport function defineQueueConfig(config: QueueConfig): QueueConfig {\n return config;\n}\n\nexport function queueConfigDefaults(): Required<QueueConfig> {\n return {\n jobs: [],\n jobsDir: \"app/jobs\",\n concurrency: 1,\n };\n}\n",
6
- "import { Job } from \"./Job\";\nimport { queueConfigDefaults, type QueueConfig } from \"./config\";\nimport { withDefaults } from \"../../support/withDefaults\";\n\nfunction createWorker() {\n const APP_DIR = process.env.APP_DIR;\n const ROOT_DIR = process.env.ROOT_DIR;\n\n const appPath =\n process.env.NODE_ENV === \"production\"\n ? `${ROOT_DIR}/dist/server/bootstrap.mjs`\n : `${APP_DIR}/bootstrap.ts`;\n\n const file = new File(\n [\n `\n import { app } from \"${appPath}\"\n self.onmessage = async (event) => {\n const clone = app.clone()\n let result = null;\n let error = null;\n try {\n result = clone.dispatchJob(event.data.jobName, event.data.args)\n } catch (err) {\n error = err\n }\n clone.destroy()\n if(error) {\n self.postMessage({error});\n } else {\n self.postMessage({result});\n }\n };\n `,\n ],\n \"worker.ts\",\n );\n const url = URL.createObjectURL(file);\n return new Worker(url);\n}\n\n// TODO: terminate worker after the job is done\nasync function runInWorker(jobName: string, args: string) {\n const worker = createWorker();\n worker.postMessage({ jobName, args });\n return await new Promise((resolve, reject) => {\n worker.onmessage = (e) => {\n const data = e.data;\n if (\"error\" in data) {\n reject(data.error);\n } else {\n resolve(data.result);\n }\n };\n });\n}\n\ntype JobDefinition = {\n class: string;\n args: string;\n createdAt: number;\n retries: number;\n};\n\nexport class QueueManager {\n static token = \"queue\";\n\n queue: Set<JobDefinition> = new Set();\n activeRunningJobsCount = 0;\n isRunning = false;\n jobs: Record<string, new () => Job> = {};\n\n readonly config: Required<QueueConfig>;\n\n constructor(config: QueueConfig = {}) {\n this.config = withDefaults(queueConfigDefaults(), config);\n this.useJobs(this.config.jobs);\n }\n\n /**\n * Replaces the registered set, for the provider to hand over what it found\n * under `app/jobs`.\n *\n * This exists because the two phases disagree about when the answer is\n * knowable. The manager is constructed in `register()`, which is synchronous\n * and must resolve nothing; reading a directory and importing what is in it is\n * neither. So the manager is built from whatever the config slice declared —\n * nothing, when the app left `jobs` out — and the discovered set arrives in\n * `boot()`.\n *\n * The consequence worth knowing: anything that constructs an application and\n * skips phase two sees an empty registry, and every dispatch against an empty\n * registry is dropped — loudly on stderr, but after `Job.dispatch` has already\n * returned, so no caller finds out. An app that lists its jobs explicitly is\n * unaffected, because that list is already in place by the end of `register()`.\n */\n useJobs(jobs: Array<new () => Job>) {\n this.config.jobs = jobs;\n\n // Built one at a time rather than by `Object.fromEntries`, which resolves a\n // repeated key by keeping the last and saying nothing.\n //\n // Two classes with one name is the worst failure in this subsystem, and it\n // is worse than the dropped dispatch the rest of this file is about: the\n // registry is keyed by class name, a dispatch carries a class name, so\n // `SendEmail.dispatch(...)` on the one under `app/jobs/auth` would run the\n // body of the one under `app/jobs/billing`. Nothing is dropped and nothing\n // errors — the wrong work happens and reports success.\n //\n // Discovery is what makes it ordinary. A hand-written list forces an import\n // alias in one visible file the moment two names clash; a directory walk\n // does not, and `auth/SendEmail.ts` beside `billing/SendEmail.ts` is a\n // perfectly natural thing to write. So the first claim wins and the second\n // is refused out loud — the same rule `Scheduler.start` applies to a cron\n // name, and the reverse of the silent last-wins this replaces.\n this.jobs = {};\n for (const job of jobs) {\n const taken = this.jobs[job.name];\n if (taken) {\n console.error(\n `Two queued jobs are named \"${job.name}\" — the first is registered ` +\n `and this one is not, so dispatching either would have run one of ` +\n `them. A class name is the queue's key, so only one job can hold ` +\n `it. Rename one.`,\n );\n continue;\n }\n this.jobs[job.name] = job;\n }\n }\n\n /**\n * What the manager was handed, discovered or declared.\n *\n * The registry is keyed by name, and a name is exactly what a dispatch\n * carries, so \"is this job registered?\" is a question with a silent wrong\n * answer — `next()` drops an unknown name long after the caller moved on.\n * This is where a test asks it out loud.\n *\n * It reports what came in, not what the registry accepted, so a name claimed\n * twice appears twice here — deliberately, the same way `Scheduler.jobs`\n * does. A test walking this should see the collision rather than have it\n * tidied away. A copy, so that walk cannot edit the registry underneath it.\n */\n get registeredJobs(): ReadonlyArray<new () => Job> {\n return [...this.config.jobs];\n }\n\n dispatchJob(jobName: string, args: string) {\n if (this.jobs[jobName]) {\n const job = new this.jobs[jobName]();\n return job.run(JSON.parse(args));\n }\n }\n\n async next() {\n if (!this.isRunning) {\n this.isRunning = true;\n }\n\n if (this.activeRunningJobsCount >= this.config.concurrency) {\n await new Promise((resolve) => setTimeout(resolve, 1000));\n return this.next();\n }\n\n const jobDefinition = this.queue.values().next().value as\n | JobDefinition\n | undefined;\n\n if (jobDefinition) {\n // Taken off the queue before anything decides what to do with it. The\n // delete used to live inside the `if` below, so a name the registry could\n // not resolve left the head in place, the `size === 0` check below was\n // never reached, and `next()` recursed on the same entry until the stack\n // gave out. An unregistered dispatch is meant to be a dropped job, not a\n // crash — and discovery makes an empty registry newly reachable (a deploy\n // that ships no source finds nothing to register), so the difference\n // stopped being theoretical.\n this.queue.delete(jobDefinition);\n\n if (this.jobs[jobDefinition.class]) {\n this.run(jobDefinition);\n } else {\n // The one place this is observable. A dispatch carries a name, the\n // registry is keyed by name, and a name nobody registered matches\n // nothing — which is exactly the silence #322 is about, except here it\n // has already happened and the work is gone. Saying so is all that is\n // left to do about it.\n console.error(\n `Dropped a queued job: nothing is registered under the name ` +\n `\"${jobDefinition.class}\". If the class exists, it was not ` +\n `discovered — check that it is under the queue slice's jobsDir ` +\n `(app/jobs by default), or list it in app/config/queue.ts.`,\n );\n }\n }\n\n if (this.queue.size === 0) {\n this.isRunning = false;\n return;\n }\n\n await this.next();\n }\n\n private async run(jobDefinition: JobDefinition) {\n const Job = this.jobs[jobDefinition.class];\n const jobInstance = new Job();\n const args: any[] = JSON.parse(jobDefinition.args);\n\n this.activeRunningJobsCount++;\n\n try {\n const result = await (jobInstance.worker\n ? runInWorker(jobDefinition.class, jobDefinition.args)\n : jobInstance.run(...args));\n\n jobInstance.onSuccess(result, ...args);\n } catch (err) {\n jobInstance.onFail(err, ...args);\n if (jobDefinition.retries >= jobInstance.maxAttempts - 1) {\n jobInstance.onDeadletter(err, ...args);\n } else {\n this.push(Job, jobDefinition.args, jobDefinition.retries + 1);\n }\n }\n\n this.activeRunningJobsCount--;\n }\n\n push(job: new () => Job, args: string, retries = 0) {\n this.queue.add({\n class: job.name,\n args,\n createdAt: Date.now(),\n retries,\n });\n if (!this.isRunning) {\n this.next();\n }\n }\n}\n",
7
- "/**\n * A command an operator runs by hand: `gemi run backfill-avatars --dry-run`.\n *\n * This file is the *runtime* shape — the base class discovery walks the\n * prototype chain for, and the statics the runner reads. It is not the\n * authoring surface. Applications write commands with `defineCommand` in\n * `./builder`, which produces one of these; see that file for why the authoring\n * surface is a builder and not a class body.\n *\n * ### Why the schema is descriptors and not a signature string\n *\n * Laravel spells this `protected $signature = 'mail:send {user} {--queue}'`, and\n * the string is the whole schema. It reads beautifully and TypeScript cannot see\n * a word of it: a brace in the wrong place is a parse error the first time\n * somebody runs the command, months after it was written, and the parser is a\n * piece of framework surface with its own failure modes. The descriptors below\n * say the same thing in a shape the compiler checks — and, through the builder,\n * in a shape that types the handler's own body.\n *\n * ### Why the name is declared and never falls back to the class name\n *\n * `Job` keys off `static name`, which shadows `Function.name`. That is the right\n * trade there: a job's name *is* its class name, and the shadow is what makes it\n * a string literal that survives minification. Here it is the wrong one twice\n * over. A command's name is a CLI token (`backfill-avatars`, `db:seed`) with no\n * relationship to the class name, so an implicit fallback would only ever be\n * wrong; and shadowing `Function.name` costs the one error anybody will actually\n * hit — \"two commands claim `db:seed`\" — the ability to say *which two*.\n *\n * ### The minification hazard does not reach here\n *\n * `services/discovery.ts` warns about a job that never declared `static name`,\n * because two halves have to agree on one string across a bundler: the\n * dispatcher, minified into `dist/server/server.mjs`, and discovery, reading the\n * source. A command has one half — a human types the name and it is matched\n * against discovery-on-source. Nothing in the server bundle names a command, and\n * `gemi build` keeps `app/commands` out of the bundle anyway. So there is no\n * `warnIfNameWillNotSurviveTheBuild` equivalent below, and adding one by analogy\n * would be noise.\n *\n * If a `Command.call(\"db:seed\")` reachable from a controller is ever added, that\n * changes — and `commandName` being a declared string literal already covers it,\n * which is one more reason not to fall back to the class binding.\n */\n\n/** A positional argument. `variadic` collects the rest and must come last. */\nexport interface ArgSpec {\n description?: string;\n /**\n * Missing it is a usage error rather than an `undefined` in the handler.\n * Mutually exclusive with `default` — an argument that is supplied when absent\n * cannot also be absent, and declaring both is refused rather than silently\n * resolved in one direction.\n */\n required?: boolean;\n /** Collects every remaining positional. Only legal on the last argument. */\n variadic?: boolean;\n /** Supplied when the argument is absent, which makes it always present. */\n default?: string;\n}\n\n/**\n * A flag. The `type` decides both how the value is parsed and what the handler\n * sees, which is why it is required rather than defaulted to `string`: a\n * `--dry-run` declared without a type would arrive as the string `\"\"`, and every\n * `if (options.dryRun)` over it would be wrong in the one direction nobody\n * tests.\n */\nexport type OptionSpec =\n | {\n type: \"boolean\";\n description?: string;\n /** Single character, without the dash. */\n alias?: string;\n default?: boolean;\n }\n | {\n type: \"string\";\n description?: string;\n alias?: string;\n default?: string;\n required?: boolean;\n }\n | {\n type: \"number\";\n description?: string;\n alias?: string;\n default?: number;\n required?: boolean;\n };\n\n/** An argument as stored on the class: the spec, plus the name it was given. */\nexport type CommandArgument = ArgSpec & { name: string };\n\n/** An option as stored on the class: the spec, plus the name it was given. */\nexport type CommandOption = OptionSpec & { name: string };\n\n/** What a handler may return. `void` and `0` mean the same thing. */\nexport type CommandResult = Promise<number | void> | number | void;\n\n/**\n * A command that failed on purpose.\n *\n * The distinction `bin/check-models.ts` draws between `CheckModelsError` and\n * everything else, in the one place an application can reach it: this is a\n * sentence written for the terminal and is printed without a stack, while\n * anything else that escapes a handler is a bug and keeps its stack.\n */\nexport class CommandFailed extends Error {\n constructor(\n message: string,\n readonly code: number = 1,\n ) {\n super(message);\n this.name = \"CommandFailed\";\n }\n}\n\n/**\n * The base class. Discovery finds subclasses of this; the runner reads the\n * statics and calls `run`.\n *\n * Subclassing it by hand works and is what `defineCommand` does under the hood,\n * but it gives up the typing that is the whole point of the builder — `run`'s\n * parameter cannot be inferred from statics declared on the subclass, because\n * TypeScript does not contextually type an overriding method's parameters. Write\n * commands with `defineCommand`.\n */\nexport class Command {\n /**\n * The name typed on the command line. Mandatory: there is no sensible default\n * and the class name is not one.\n */\n static commandName = \"unset\";\n\n /** One line, printed by `gemi run` with no name and at the top of `--help`. */\n static description = \"\";\n\n /** Positional arguments, in order. A variadic one must be last. */\n static args: CommandArgument[] = [];\n\n /** Flags. Declared in camelCase; `dryRun` is spelled `--dry-run` on the CLI. */\n static options: CommandOption[] = [];\n\n /**\n * The body.\n *\n * Runs inside `kernel.run()`, so `app(MailManager)` and a model read resolve\n * exactly as they do in a request handler. Resolve services *here* rather than\n * at module load: a command file is imported by discovery before the container\n * has finished booting, and a service captured at the top of the file is\n * captured from a container that is not ready.\n */\n run(_ctx: any): CommandResult {}\n}\n\n/** The type of a class `defineCommand(...).handle(...)` produces. */\nexport type CommandClass = typeof Command;\n",
8
- "import type { CommandClass } from \"./Command\";\n\n// Config key: `command`. Consumed by `gemi run`, and by nothing at boot.\n//\n// Named `command` rather than `console` on purpose. An app declares its slices\n// by importing them into `app/kernel/Kernel.ts`, and a file called\n// `app/config/console.ts` arrives there as `import console from\n// \"../config/console\"` — which shadows the global `console` for the rest of that\n// module. Every application would inherit that, silently. `command` also matches\n// the singular slice names already in use: `route`, `queue`, `schedule`, `log`.\nexport interface CommandConfig {\n /**\n * The `Command` classes this application can run, or nothing.\n *\n * ### The rule, exactly\n *\n * **Declared wins, and `[]` is declared.** A `commands` that is present is\n * used verbatim and no directory is read — the escape hatch for an app whose\n * commands live somewhere the walk cannot reach, and for a deploy that ships\n * no source. An empty array means an app with no commands and says so; it does\n * not mean \"find some\".\n *\n * **Absent or `undefined` discovers.** `undefined` counts as absent for the\n * same reason `withDefaults` treats it that way everywhere else: a key spread\n * in from an optional value is an omission, not an instruction.\n *\n * ### One way this differs from `queue` and `schedule`\n *\n * There, the cost of the list and the directory disagreeing is silence — a\n * dispatch dropped with a line on stderr nobody reads, a report that stops\n * arriving. Here it is a person typing `gemi run thing` and being told, in\n * those words, that there is no command called `thing`. The rule is kept for\n * consistency and for the source-less-deploy case, not because the stakes are\n * the same.\n */\n commands?: CommandClass[];\n\n /**\n * Where to look when `commands` was not declared. Relative to the project\n * root, or absolute.\n *\n * Every `.ts`/`.tsx` file underneath is imported when a command is run, so\n * this wants to be a directory of command declarations rather than a directory\n * that merely contains some.\n */\n commandsDir?: string;\n}\n\nexport function defineCommandConfig(config: CommandConfig): CommandConfig {\n return config;\n}\n\nexport function commandConfigDefaults(): Required<CommandConfig> {\n return {\n commands: [],\n commandsDir: \"app/commands\",\n };\n}\n",
9
- "import {\n Command,\n type ArgSpec,\n type CommandArgument,\n type CommandClass,\n type CommandOption,\n type CommandResult,\n type OptionSpec,\n} from \"./Command\";\nimport type { CommandContext } from \"./context\";\n\n/**\n * Declaring a command, in the one shape that can type its own body.\n *\n * ### Why a builder and not a class\n *\n * The point of declaring arguments and options at all is that the handler then\n * knows what it has. A class body cannot deliver that, and the reason is a hard\n * TypeScript rule rather than a matter of arrangement: **TypeScript does not\n * contextually type a method's parameters from the base-class method it\n * overrides.** So both class-shaped designs fail in the same place:\n *\n * ```ts\n * class Backfill extends Command {\n * static args = [{ name: \"since\", required: true }];\n * async run(ctx) {} // implicit any\n * }\n *\n * class Backfill extends Command.define({ since: { required: true } }) {\n * async run(ctx) {} // still implicit any — the\n * } // configured base's signature does\n * // not flow into the override\n * ```\n *\n * The author's only way out is to restate the type by hand, which is the\n * ceremony the descriptors existed to remove — and which nothing enforces, so a\n * wrong restatement compiles.\n *\n * A **function expression passed as an argument is contextually typed**. That is\n * the entire mechanism here, and it is why this is a builder rather than sugar:\n * `.handle(fn)` carries the accumulated argument and option types into `fn`'s\n * parameter with nothing written by hand and nothing to keep in step.\n *\n * ### What it produces\n *\n * A `Command` subclass, so nothing downstream knows the difference: discovery\n * finds it by prototype chain, and the registry, parser and `--help` read the\n * same statics they would read off a hand-written class. The builder is an\n * authoring surface over one runtime shape, not a second mechanism.\n */\n\n/**\n * Marks a builder that was never finished. `discoverCommands` looks for this on\n * the exports it is about to discard — see the note on `handle` below.\n */\nexport const BUILDER_BRAND: unique symbol = Symbol.for(\"gemi.console.builder\");\n\n/** Flattens an accumulated intersection so editor hovers stay readable. */\ntype Simplify<T> = { [K in keyof T]: T[K] } & {};\n\n/**\n * What the handler sees for one argument.\n *\n * The order matters: `variadic` first because it wins over everything, then the\n * two ways an argument is guaranteed present. Anything else can be absent and\n * says so.\n */\nexport type ArgValue<S> = S extends { variadic: true }\n ? string[]\n : S extends { required: true }\n ? string\n : S extends { default: string }\n ? string\n : string | undefined;\n\n/** What the handler sees for one option. */\nexport type OptionValue<S> = S extends { type: \"boolean\" }\n ? boolean\n : S extends { type: \"number\" }\n ? S extends { default: number }\n ? number\n : S extends { required: true }\n ? number\n : number | undefined\n : S extends { default: string }\n ? string\n : S extends { required: true }\n ? string\n : string | undefined;\n\nexport interface CommandBuilder<\n A extends Record<string, unknown>,\n O extends Record<string, unknown>,\n> {\n /** One line, shown in the listing and at the top of `--help`. */\n describe(text: string): CommandBuilder<A, O>;\n\n /**\n * A positional argument. Declared in the order it is read from the command\n * line; a `variadic` one must be last.\n */\n arg<N extends string, const S extends ArgSpec = {}>(\n name: N,\n spec?: S,\n ): CommandBuilder<A & { [K in N]: ArgValue<S> }, O>;\n\n /**\n * A flag. Declared in camelCase and spelled in kebab-case on the command line,\n * so `.option(\"dryRun\", …)` is `--dry-run` for the operator and\n * `options.dryRun` in the handler — no string key nobody can autocomplete, and\n * no CLI flag with a capital letter in it.\n */\n option<N extends string, const S extends OptionSpec>(\n name: N,\n spec: S,\n ): CommandBuilder<A, O & { [K in N]: OptionValue<S> }>;\n\n /**\n * The body, and the terminal of the chain.\n *\n * A builder that never reaches here is not a class, so discovery would skip it\n * and the command would simply vanish from `gemi run` with nothing raised —\n * the silence #322 and #323 exist to remove, reintroduced by a new authoring\n * surface. `discoverCommands` therefore looks for `BUILDER_BRAND` among the\n * exports it discards and refuses the file by name.\n */\n handle(\n fn: (ctx: CommandContext<Simplify<A>, Simplify<O>>) => CommandResult,\n ): CommandClass;\n}\n\n/**\n * Refused early, where the author is looking.\n *\n * The whitespace and brace checks are aimed at one specific reader: somebody who\n * knows Laravel and reaches for `defineCommand(\"mail:send {user} {--queue}\")`.\n * Without this they get a command registered under a name containing a space,\n * which can never be typed and never runs, and no explanation.\n */\nfunction assertUsableName(name: string): void {\n if (name.trim() === \"\") {\n throw new Error(\"A command name cannot be empty.\");\n }\n\n if (/[{}]/.test(name) || /\\s/.test(name)) {\n throw new Error(\n `Invalid command name ${JSON.stringify(name)}. gemi does not parse a ` +\n `signature string; the name is the whole of it. Declare arguments ` +\n `with .arg() and flags with .option():\\n\\n` +\n ` defineCommand(\"mail:send\")\\n` +\n ` .arg(\"user\", { required: true })\\n` +\n ` .option(\"queue\", { type: \"boolean\" })\\n` +\n ` .handle(async ({ args, options }) => { ... })`,\n );\n }\n}\n\nexport function defineCommand(name: string): CommandBuilder<{}, {}> {\n assertUsableName(name);\n\n const args: CommandArgument[] = [];\n const options: CommandOption[] = [];\n let description = \"\";\n\n const builder = {\n [BUILDER_BRAND]: name,\n\n describe(text: string) {\n description = text;\n return builder;\n },\n\n arg(argName: string, spec: ArgSpec = {}) {\n // Checked here rather than at parse time because both of these are\n // mistakes in the declaration, and the declaration is what the author is\n // looking at right now. At parse time they would surface as a confusing\n // usage error in front of an operator who cannot fix them.\n if (spec.required && spec.default !== undefined) {\n throw new Error(\n `Argument \"${argName}\" of command \"${name}\" is both required and has ` +\n `a default. An argument that is supplied when absent cannot also be ` +\n `absent — drop one.`,\n );\n }\n\n // A variadic collects whatever is left, so there is no \"absent\" for a\n // default to fill — the empty list is the answer. Refused rather than\n // ignored, for the same reason as the pair above: a declaration the parser\n // silently drops reads, to whoever wrote it, exactly like one it honours.\n if (spec.variadic && spec.default !== undefined) {\n throw new Error(\n `Argument \"${argName}\" of command \"${name}\" is variadic and has a ` +\n `default. A variadic argument collects the remaining values and is ` +\n `an empty list when there are none, so the default could never ` +\n `apply — drop it, or drop \\`variadic\\`.`,\n );\n }\n\n const variadic = args.find((existing) => existing.variadic);\n if (variadic) {\n throw new Error(\n `Argument \"${argName}\" of command \"${name}\" is declared after the ` +\n `variadic argument \"${variadic.name}\", which collects everything ` +\n `that follows, so \"${argName}\" could never receive a value. A ` +\n `variadic argument must be declared last.`,\n );\n }\n\n if (args.some((existing) => existing.name === argName)) {\n throw new Error(\n `Command \"${name}\" declares the argument \"${argName}\" twice.`,\n );\n }\n\n args.push({ ...spec, name: argName });\n return builder;\n },\n\n option(optionName: string, spec: OptionSpec) {\n if (options.some((existing) => existing.name === optionName)) {\n throw new Error(\n `Command \"${name}\" declares the option \"${optionName}\" twice.`,\n );\n }\n\n const alias = \"alias\" in spec ? spec.alias : undefined;\n const clash =\n alias === undefined\n ? undefined\n : options.find(\n (existing) => \"alias\" in existing && existing.alias === alias,\n );\n if (clash) {\n throw new Error(\n `Options \"${clash.name}\" and \"${optionName}\" of command \"${name}\" ` +\n `both use the alias \"-${alias}\".`,\n );\n }\n\n options.push({ ...spec, name: optionName });\n return builder;\n },\n\n handle(fn: (ctx: any) => CommandResult) {\n const commandName = name;\n const commandDescription = description;\n\n const cls = class extends Command {\n static commandName = commandName;\n static description = commandDescription;\n // Copied, not aliased. The builder goes on owning `args`/`options` and\n // mutating them on every subsequent `.arg()`/`.option()`, so storing the\n // instances themselves let a chain reach back into a class it had\n // already produced — and `--help` and the parser both read these\n // statics, so the printed usage and the accepted arguments would change\n // under a command that was finished.\n static args = [...args];\n static options = [...options];\n\n run(ctx: any) {\n return fn(ctx);\n }\n };\n\n // This chain produced a command, so it is no longer unfinished. The brand\n // exists to catch a file that exports a builder and never calls `.handle()`\n // — see `refuseUnfinishedBuilders` in `services/discovery.ts`. Leaving it\n // set meant the natural way to share declarations,\n //\n // export const base = defineCommand(\"reindex\").option(\"verbose\", ...);\n // export default base.handle(async () => {});\n //\n // left a branded object among the file's exports and aborted the whole of\n // `gemi run` — every command in the project unrunnable, under a message\n // that was untrue for that file.\n delete (builder as Record<PropertyKey, unknown>)[BUILDER_BRAND];\n\n // An anonymous class expression reports `name === \"\"`, and the duplicate-\n // name error's whole job is to say *which two*. Give it the one name it\n // has.\n Object.defineProperty(cls, \"name\", {\n value: commandName,\n configurable: true,\n });\n\n return cls;\n },\n };\n\n return builder as unknown as CommandBuilder<{}, {}>;\n}\n\n/** True for a builder that never called `.handle()`. */\nexport function isUnfinishedBuilder(\n value: unknown,\n): value is { [BUILDER_BRAND]: string } {\n return (\n typeof value === \"object\" &&\n value !== null &&\n typeof (value as Record<PropertyKey, unknown>)[BUILDER_BRAND] === \"string\"\n );\n}\n",
10
- "// A cron expression accepted by `Bun.cron`: a 5-field expression\n// (`minute hour day-of-month month day-of-week`, interpreted in UTC) or one of\n// the nicknames below. The `string & {}` member keeps arbitrary expressions\n// assignable while still surfacing the nicknames in editor autocomplete.\nexport type CronExpression =\n | \"@yearly\"\n | \"@annually\"\n | \"@monthly\"\n | \"@weekly\"\n | \"@daily\"\n | \"@midnight\"\n | \"@hourly\"\n | (string & {});\n\nexport class CronJob {\n name: string;\n cron: CronExpression;\n\n /**\n * Decides whether this tick happens at all. Evaluated once per tick, before\n * anything else; returning `false` skips `onTick`, `callback` and\n * `onComplete` alike.\n *\n * ### Why this is a member and not a line the job writes for itself\n *\n * A job that reports outward — mails a digest, opens a Sentry issue, pings a\n * channel — must not fire from a laptop, and the guard for that has to cover\n * the whole tick. There was nowhere to write it. gemi calls `onTick` and\n * `onComplete` *outside* `callback`, so a guard placed in a lifecycle hook\n * only stops the hook it lives in: an early `return` at the top of `callback`\n * leaves the job still announcing that it started and still announcing that\n * it finished, which for an outward-reporting job is most of the damage.\n *\n * The only construct that covered every hook was an abstract base class that\n * shadowed `callback` with the guard and renamed the real body to `run()` —\n * and that costs the app the framework's own vocabulary. A job then reads\n * `async run()` while every page of the documentation reads `async\n * callback()`, so the next person to follow the docs writes a `callback` the\n * base class never calls: no error, no output, a job that silently does\n * nothing. Forgetting *this* member fails the other way round — the job runs,\n * which is what it did before anyone asked for a gate.\n *\n * ### What it gates\n *\n * Work, not registration. A job whose gate returns `false` is still\n * scheduled, still holds its `Bun.cron` handle, and still appears in\n * `app(Scheduler).jobs` — \"is it scheduled\" and \"will it do anything\" are\n * different questions and the second one is answered per tick. That is also\n * why this is a method: a field would be read once, when the scheduler\n * constructs the job at boot, and would freeze whatever it saw then.\n *\n * A gate that throws is logged and treated as `false`. Cron work recurs, so\n * a skipped tick is recovered by the next one, while an email sent from the\n * wrong machine is not recovered at all.\n *\n * ### Composing with a base class\n *\n * Nothing here calls `super` for you. A subclass that overrides `shouldRun`\n * for its own reason silently replaces whatever its base was gating on, so\n * narrow rather than redefine:\n *\n * ```typescript\n * async shouldRun() {\n * return (await super.shouldRun()) && this.hasSubscribers();\n * }\n * ```\n *\n * A shared base should annotate its return type as written here rather than\n * let it be inferred: a base returning a plain `boolean` narrows the\n * signature its subclasses inherit, and the `await super` above then does not\n * typecheck against it.\n */\n shouldRun(): Promise<boolean> | boolean {\n return true;\n }\n\n callback(): Promise<void> | void {}\n onTick(): Promise<void> | void {}\n onComplete(): Promise<void> | void {}\n\n static exp(expression: CronExpression) {\n return expression;\n }\n}\n",
11
- "import type { CronJob } from \"./CronJob\";\n\n// Config key: `schedule`. Consumed by `ScheduleServiceProvider`.\nexport interface ScheduleConfig {\n /**\n * The `CronJob` subclasses this application runs on a schedule, or nothing.\n *\n * ### Why \"or nothing\" is the point\n *\n * A cron job that is written and not listed here never fires, and unlike a\n * dropped dispatch there is no caller left waiting to notice: nothing is\n * downstream of a tick that did not happen. The report is simply not sent,\n * for as long as it takes somebody to ask why they stopped seeing it. That is\n * the whole failure — the file exists, the expression is right, and the class\n * was never in the module graph.\n *\n * Leaving this out spells the schedule once: the jobs are the classes under\n * `jobsDir`.\n *\n * ### The rule, exactly\n *\n * **Declared wins, and `[]` is declared.** A `jobs` that is present is used\n * verbatim and no directory is read — the escape hatch for an app whose jobs\n * live somewhere this cannot walk, for one that runs a deliberate subset, and\n * for a deploy that ships no source. An empty array means an app with nothing\n * scheduled and says so; it does not mean \"find some\".\n *\n * **Absent or `undefined` discovers.** `undefined` counts as absent for the\n * same reason `withDefaults` treats it that way everywhere else: a key spread\n * in from an optional value is an omission, not an instruction.\n *\n * Either way the set the scheduler ended up with is readable afterwards, as\n * `app(Scheduler).jobs` — an app that used to import this array to assert\n * something about its own schedule asks the scheduler instead.\n */\n jobs?: Array<new () => CronJob>;\n\n /**\n * Where to look when `jobs` was not declared. Relative to the project root,\n * or absolute.\n *\n * Every `.ts`/`.tsx` file underneath it is imported at boot and every exported\n * class extending `CronJob` is scheduled, so this wants to be a directory of\n * cron declarations rather than a directory that merely contains some. Moving\n * the jobs is what this field is for; pointing it at `app/` is not.\n */\n jobsDir?: string;\n}\n\nexport function defineScheduleConfig(config: ScheduleConfig): ScheduleConfig {\n return config;\n}\n\nexport function scheduleConfigDefaults(): Required<ScheduleConfig> {\n return {\n jobs: [],\n jobsDir: \"app/cron\",\n };\n}\n",
12
- "import { app } from \"../../foundation/app\";\nimport { QueueManager } from \"./QueueManager\";\n\nexport class Job {\n static name = \"unset\";\n worker = false;\n maxAttempts = 3;\n\n run(..._args: any[]): Promise<any> | any {}\n\n onFail(_error: Error, ..._args: any[]): void {}\n onSuccess(_result: any, ..._args: any[]): void {}\n onDeadletter(_error: Error, ..._args: any[]): void {}\n\n static dispatch<T extends Job>(\n this: new () => T,\n ...args: Parameters<T[\"run\"]>\n ): void {\n if (this.name === \"unset\") {\n throw new Error(\"Cannot dispatch a job with no name\");\n }\n\n app(QueueManager).push(this, JSON.stringify(args));\n }\n}\n",
13
- "import { existsSync } from \"node:fs\";\nimport { dirname, isAbsolute, join } from \"node:path\";\n\nimport {\n discoverClasses,\n DiscoveryError,\n projectRoot,\n} from \"../support/discover\";\nimport { Command, type CommandClass } from \"../console/Command\";\nimport { commandConfigDefaults } from \"../console/config\";\nimport { isUnfinishedBuilder } from \"../console/builder\";\nimport { CronJob } from \"./cron/CronJob\";\nimport { scheduleConfigDefaults } from \"./cron/config\";\nimport { Job } from \"./queue/Job\";\nimport { queueConfigDefaults } from \"./queue/config\";\n\n/**\n * Reading an application's jobs off the filesystem, for the two subsystems that\n * were asking every app to write its job list twice.\n *\n * Both functions here are the same call to `discoverClasses` with a different\n * base class, which is deliberate: one walk, one set of skip rules, one answer\n * to \"what does this app have\". They are exported from `gemi/services` rather\n * than kept private to the providers because the list stopped being something\n * an app could import — a test that used to walk the exported `jobs` array\n * needs somewhere to ask the same question, and so does a script.\n *\n * What the providers add on top of these is the decision of *whether* to ask,\n * which is the config's to make and not this file's.\n */\n\n/**\n * A directory the app named, resolved the way the app meant it.\n *\n * Relative paths hang off the project root rather than `process.cwd()` at the\n * moment of the call, because a config slice saying `app/jobs` means the app's\n * `app/jobs` and not whatever directory somebody happened to launch a script\n * from. Absolute paths are taken as given, which is what makes these callable\n * from a test that has no project around it.\n */\nfunction resolveDir(dir: string): string {\n return isAbsolute(dir) ? dir : join(projectRoot(), dir);\n}\n\n/**\n * Says something when the directory is missing *and so is the tree it lives in*.\n *\n * A missing directory has two readings and they want opposite responses. An app\n * that has never written a cron job has no `app/cron`, and warning about that on\n * every boot for the rest of its life is noise — the answer \"you have no cron\n * jobs\" is correct and uninteresting. But a deploy that ships `dist/` and\n * `node_modules/` without the source has no `app/cron` *and no `app/`*, and\n * there discovery quietly returns nothing while the app very much does have\n * jobs: the exact silence #322 and #323 exist to remove, reintroduced one layer\n * down and in production only.\n *\n * The parent directory is what tells them apart. If neither the directory nor\n * the one above it is there, the tree this was pointed into is not there\n * either, and that is worth a sentence.\n */\nfunction warnIfSourceIsMissing(\n resolved: string,\n subject: string,\n slice: string,\n) {\n if (existsSync(resolved) || existsSync(dirname(resolved))) return;\n\n console.warn(\n `No ${subject} were discovered: neither ${resolved} nor the directory ` +\n `above it exists, so this process cannot see the application's source. ` +\n `If this is a deploy that ships only the build output, list the classes ` +\n `explicitly in app/config/${slice}.ts so they travel with it.`,\n );\n}\n\n/**\n * The `Job` subclasses under `dir`, defaulting to the config slice's `app/jobs`.\n *\n * This is what a `queue` config slice with no `jobs` key resolves to. Call it\n * directly to ask the question a test used to answer by importing the array:\n * every job this application would register, in the order it would register\n * them.\n *\n * Every file underneath is imported, so calling this runs the app's job modules\n * — the cost `discoverClasses` documents at length, paid once per call.\n */\nexport async function discoverJobs(\n dir: string = queueConfigDefaults().jobsDir,\n): Promise<Array<new () => Job>> {\n const resolved = resolveDir(dir);\n warnIfSourceIsMissing(resolved, \"queue jobs\", \"queue\");\n const jobs = await discoverClasses(resolved, Job);\n warnIfNameWillNotSurviveTheBuild(jobs);\n return jobs;\n}\n\n/**\n * Says something about a discovered job that never declared `static name`.\n *\n * This is the one hazard discovery introduces rather than removes, and it is\n * production-only. `gemi build` minifies the server entry, and app code\n * reachable from it — a controller, and every job class that controller\n * imports to dispatch — is bundled and minified with it. Minification renames\n * the class binding, and a class's implicit `.name` is that binding: a\n * `TestJob` in the bundle reports `\"D\"`. Discovery, meanwhile, imports\n * `app/jobs/TestJob.ts` from source at runtime, where it is still `\"TestJob\"`.\n * The queue is keyed by that name, so the two halves stop agreeing and the\n * dispatch is dropped — in production, and only there.\n *\n * A declared `static name = \"TestJob\"` is a string literal, which survives\n * minification intact, and the two halves agree again. `docs/jobs-and-queues.md`\n * has always called it required; before discovery an app could get away without\n * it, because the explicit `jobs` array was bundled too and both sides were\n * wrong in the same way.\n *\n * The check is exact rather than a guess: a `static name = \"...\"` class field\n * defines a *writable* own property, while the implicit class name is\n * non-writable. Cron is unaffected — `CronJob.name` is an instance field\n * holding a string literal, not the class binding.\n */\nfunction warnIfNameWillNotSurviveTheBuild(jobs: Array<new () => Job>) {\n for (const job of jobs) {\n if (Object.getOwnPropertyDescriptor(job, \"name\")?.writable) continue;\n\n console.warn(\n `Queued job ${job.name} does not declare \\`static name\\`, so it is ` +\n `registered under its class name. A production build minifies the ` +\n `class that dispatches it and renames it, while discovery reads this ` +\n `file from source and does not — so the dispatch would be dropped in ` +\n `production and nowhere else. Add: static name = \"${job.name}\";`,\n );\n }\n}\n\n/**\n * The `CronJob` subclasses under `dir`, defaulting to the config slice's\n * `app/cron`.\n *\n * This is what a `schedule` config slice with no `jobs` key resolves to. Call it\n * directly to ask the question a test used to answer by importing the array —\n * though after boot `app(Scheduler).jobs` is the better one, because it is what\n * the scheduler actually took rather than what this would find if asked again.\n *\n * Every file underneath is imported, so calling this runs the app's cron\n * modules — the cost `discoverClasses` documents at length, paid once per call.\n */\nexport async function discoverCronJobs(\n dir: string = scheduleConfigDefaults().jobsDir,\n): Promise<Array<new () => CronJob>> {\n const resolved = resolveDir(dir);\n warnIfSourceIsMissing(resolved, \"cron jobs\", \"schedule\");\n return await discoverClasses(resolved, CronJob);\n}\n\n/**\n * The `Command` subclasses under `dir`, defaulting to the config slice's\n * `app/commands`.\n *\n * This is what a `commands`-less `command` slice resolves to, and what\n * `gemi run` lists. Unlike the two above it is not called during boot — a\n * command registry has one consumer, and importing every file under\n * `app/commands` into every server process would be a cost paid on every start\n * for code no request reaches.\n *\n * Every file underneath is imported, so calling this runs the app's command\n * modules — the cost `discoverClasses` documents at length, paid once per call.\n */\nexport async function discoverCommands(\n dir: string = commandConfigDefaults().commandsDir,\n): Promise<CommandClass[]> {\n const resolved = resolveDir(dir);\n warnIfSourceIsMissing(resolved, \"commands\", \"command\");\n\n const unfinished: string[] = [];\n\n const commands = await discoverClasses(\n resolved,\n Command,\n [],\n (value, file) => {\n if (isUnfinishedBuilder(value)) unfinished.push(file);\n },\n );\n\n refuseUnfinishedBuilders(unfinished);\n\n return commands as CommandClass[];\n}\n\n/**\n * Stops the walk for a builder chain that was never finished.\n *\n * This is the one silence the builder introduces, and it is the exact shape\n * #322 and #323 exist to remove. `defineCommand(...).arg(...)` without a\n * trailing `.handle(...)` is a plain object rather than a class, so\n * `discoverClasses` discards it along with every constant and helper a command\n * file happens to export — and the command disappears from `gemi run` with\n * nothing raised. The author sees a listing containing every command except the\n * one they just wrote.\n *\n * A throw rather than a warning, because there is no reading of an unfinished\n * builder under which the author meant it: the chain builds a description of a\n * command and then discards it.\n *\n * \"Unfinished\" is decided by `.handle()` clearing the brand, not by the export\n * still being a builder object. Those differ for the natural way to share\n * declarations —\n *\n * export const base = defineCommand(\"reindex\").option(\"verbose\", …);\n * export default base.handle(async () => {});\n *\n * — where `base` is a builder that *did* produce a command. Keying off the shape\n * alone made that file abort the whole of `gemi run`, taking every other command\n * in the project down with it, under a message that was untrue for it.\n */\nfunction refuseUnfinishedBuilders(files: string[]): void {\n if (files.length === 0) return;\n\n const subject =\n files.length === 1\n ? `${files[0]} exports a command builder that never called \\`.handle()\\``\n : `${files.length} files export a command builder that never called ` +\n `\\`.handle()\\`:\\n ${files.join(\"\\n \")}`;\n\n throw new DiscoveryError(\n `${subject}, so there is no command to run. \\`.handle()\\` is what turns ` +\n `the chain into a command — finish it:\\n\\n` +\n ` export default defineCommand(\"my-command\")\\n` +\n ` .handle(async ({ line }) => { line(\"hello\") })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,CAAG,EAC/B,EAAsB,EAAU,WAAY,SAAS,EAErD,IAAM,EAAuB,CAAC,EAExB,EAAW,MAAM,EACrB,EACA,EACA,CAAC,EACD,CAAC,EAAO,IAAS,CACf,GAAI,EAAoB,CAAK,EAAG,EAAW,KAAK,CAAI,EAExD,EAIA,OAFA,EAAyB,CAAU,EAE5B,EA6BT,SAAS,CAAwB,CAAC,EAAuB,CACvD,GAAI,EAAM,SAAW,EAAG,OAExB,IAAM,EACJ,EAAM,SAAW,EACb,GAAG,EAAM,+DACT,GAAG,EAAM;AAAA,MACc,EAAM,KAAK;AAAA,KAAQ,IAEhD,MAAM,IAAI,EACR,GAAG,iEACD;AAAA;AAAA,EACA;AAAA,qDAEJ",
16
- "debugId": "F95D282318D44A8864756E2164756E21",
17
- "names": []
18
- }
@@ -1,5 +0,0 @@
1
- // @bun
2
- import{Bb as U,Db as j,Eb as g,sb as y,tb as N}from"./chunk-4t80js0n.js";import{Mb as F}from"./chunk-eqrd31ye.js";import{Ob as J,Wb as Q,ac as V,bc as $,cc as q,ic as I,kc as z,lc as O,qc as R}from"./chunk-tmnhkphv.js";import{be as p,ge as K,ke as f}from"./chunk-vkngcrzq.js";import{Te as B}from"./chunk-4yafsffx.js";import{Ye as A}from"./chunk-pvdbrt4z.js";import{_e as S}from"./chunk-v06qcyj5.js";async function u(m){try{if(!await m.shouldRun.call(m))return}catch(x){console.error(`Error evaluating shouldRun for cron job ${m.name}:`,x);return}try{await m.onTick.call(m)}catch(x){console.error(`Error executing cron job ${m.name}:`,x)}try{await m.callback.call(m)}catch(x){console.error(`Error in cron job ${m.name}:`,x)}try{await m.onComplete.call(m)}catch(x){console.error(`Error completing cron job ${m.name}:`,x)}}class _{static token="scheduler";handles=[];resolved;constructor(m){this.resolved=m.jobs}get jobs(){return[...this.resolved]}useJobs(m){this.resolved=m}start(m=(x)=>x()){if(this.resolved.length===0)return;let x=globalThis.__gemiCronJobs??=new Map,P=new Map;for(let C of this.resolved){let M=new C;if(!M.name){console.error(`Cron job must have a name \u2014 ${C.name||"an anonymous class"} has none, so it is not scheduled. If this is a base class that other jobs extend, move it out of the discovered directory: \`abstract\` does not survive to runtime, so a class under app/cron is indistinguishable from a job.`);continue}if(!M.cron){console.error(`Cron job must have an expression. Job: ${M.name}`);continue}let E=P.get(M.name);if(E!==void 0){console.error(`Two cron jobs claim the name "${M.name}" \u2014 ${E} is scheduled and ${C.name||"an anonymous class"} is not. A name is the scheduler's key, so only one job can hold it. Rename one.`);continue}P.set(M.name,C.name||"an anonymous class"),x.get(M.name)?.stop();let X=Bun.cron(M.cron,()=>m(()=>u(M)));x.set(M.name,X),this.handles.push(X)}}stop(){for(let m of this.handles)m.stop();this.handles=[]}}class w extends F{register(){this.app.singleton(K,()=>new K(this.app.config.get("auth",{})))}}class d extends F{register(){this.app.singleton(_,()=>new _(B(U(),this.app.config.get("schedule",{}))))}async boot(){let m=this.app.make(_),x=this.app.config.get("schedule",{});if(x.jobs===void 0){let{jobsDir:C}=B(U(),x);m.useJobs(await g(C))}if(process.env.GEMI_NO_SCHEDULE==="1")return;let P=this.app;m.start((C)=>S.run(P,C))}}class s extends F{register(){this.app.singleton(A,()=>new A(this.app.config.get("mail",{})))}}class i extends F{register(){this.app.singleton(Q,()=>new Q(this.app.config.get("filesystem",{})))}}class r extends F{register(){this.app.singleton(V,()=>new V(this.app.config.get("image",{})))}}class a extends F{register(){this.app.instance(I,new I)}}function Wm(m){return m}function D(){return{maxFileSize:10485760,onLogFileClosed:()=>{},onLogCreated:()=>{}}}class n extends F{register(){this.app.singleton($,()=>new $(B(D(),this.app.config.get("log",{}))))}async boot(){await this.app.make($).boot()}}class o extends F{register(){this.app.singleton(q,()=>new q(B(p(),this.app.config.get("middleware",{}))))}}function hm(m){return m}function v(){return{channels:{}}}class t extends F{register(){this.app.singleton(J,()=>new J(B(v(),this.app.config.get("broadcast",{}))))}}class e extends F{register(){this.app.singleton(N,()=>new N(this.app.config.get("queue",{})))}async boot(){let m=this.app.config.get("queue",{});if(m.jobs!==void 0)return;let{jobsDir:x}=B(y(),m);this.app.make(N).useJobs(await j(x))}}class L{}function k(m,x){return Math.floor(m/x)*x}function mm(m,x){if(x<=0)return 0;return Math.min(1,Math.max(0,(x-m)/x))}function T(m,x,P,C){return x*mm(P,C)+m}function xm(m){let{current:x,previous:P,elapsed:C,window:M,limit:E,cost:X}=m,G=E-X;if(G<0)return M;let H=Math.max(0,M-C);if(P>0){let Y=M*(1-(G-x)/P);if(Y<=M)return Math.max(0,Math.ceil(Y-C))}if(x<=G)return H;if(x<=0)return H;let Z=M*(1-G/x);return H+Math.max(0,Math.ceil(Z))}function l(m){let{allowed:x,current:P,previous:C,now:M,elapsed:E,window:X,limit:G,cost:H}=m;if(x){let Y=T(P,C,E,X);return{allowed:!0,limit:G,remaining:Math.max(0,Math.floor(G-Y)),resetAt:M-E+X,retryAfter:0}}let Z=xm({current:P,previous:C,elapsed:E,window:X,limit:G,cost:H});return{allowed:!1,limit:G,remaining:0,resetAt:M+Z,retryAfter:Z}}class W extends L{buckets=new Map;maxKeys;constructor(m={}){super();this.maxKeys=Math.max(1,m.maxKeys??1e5)}consume(m){let{key:x,limit:P,window:C}=m,M=m.cost??1,E=Date.now(),X=k(E,C),G=E-X,H=this.roll(x,C,X),Y=T(H.current,H.previous,G,C)+M<=P;if(Y)H.current+=M;if(this.buckets.delete(x),this.buckets.set(x,H),this.buckets.size>this.maxKeys)this.evict(E);return l({allowed:Y,current:H.current,previous:H.previous,now:E,elapsed:G,window:C,limit:P,cost:M})}clear(){this.buckets.clear()}get size(){return this.buckets.size}roll(m,x,P){let C=this.buckets.get(m);if(!C||C.window!==x)return{window:x,windowStart:P,current:0,previous:0};if(C.windowStart===P)return C;if(C.windowStart+x===P)return C.previous=C.current,C.current=0,C.windowStart=P,C;return C.previous=0,C.current=0,C.windowStart=P,C}evict(m){for(let[x,P]of this.buckets)if(m-P.windowStart>=P.window*2)this.buckets.delete(x);for(let x of this.buckets.keys()){if(this.buckets.size<=this.maxKeys)break;this.buckets.delete(x)}}}function Mx(m){return m}function h(){return{driver:new W,limit:1000,window:60}}class Cm extends F{register(){this.app.singleton(f,()=>new f(B(h(),this.app.config.get("ratelimiter",{}))))}}function Zx(m){return m}function b(){return{url:process.env.REDIS_URL,options:void 0}}class Pm extends F{register(){this.app.singleton(R,()=>new R(B(b(),this.app.config.get("redis",{}))))}}function c(m,x){let P=m.get(x);if(!P)throw Error(`Missing "${x}" configuration. Route dispatching needs a root router \u2014 declare it in "app/config/route.ts".`);return P}class Fm extends F{register(){this.app.singleton(O,()=>new O(c(this.app.config,"route.api"))),this.app.singleton(z,()=>new z(c(this.app.config,"route.view")))}boot(){this.app.make(O),this.app.make(z)}}
3
- export{_ as Ta,w as Ua,d as Va,s as Wa,i as Xa,r as Ya,a as Za,Wm as _a,D as $a,n as ab,o as bb,hm as cb,v as db,t as eb,e as fb,k as gb,l as hb,L as ib,W as jb,Mx as kb,h as lb,Cm as mb,Zx as nb,b as ob,Pm as pb,Fm as qb};
4
-
5
- //# debugId=9281D90411127C3764756E2164756E21
@@ -1,30 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../services/cron/Scheduler.ts", "../auth/AuthServiceProvider.ts", "../services/cron/ScheduleServiceProvider.ts", "../services/email/MailServiceProvider.ts", "../services/file-storage/FilesystemServiceProvider.ts", "../services/image-optimization/ImageServiceProvider.ts", "../services/kernel-id/KernelIdServiceProvider.ts", "../services/logging/config.ts", "../services/logging/LogServiceProvider.ts", "../services/middleware/MiddlewareServiceProvider.ts", "../services/pubsub/config.ts", "../services/pubsub/BroadcastServiceProvider.ts", "../services/queue/QueueServiceProvider.ts", "../services/rate-limiter/drivers/RateLimiterDriver.ts", "../services/rate-limiter/slidingWindow.ts", "../services/rate-limiter/drivers/InMemoryRateLimiterDriver.ts", "../services/rate-limiter/config.ts", "../services/rate-limiter/RateLimiterServiceProvider.ts", "../services/redis/config.ts", "../services/redis/RedisServiceProvider.ts", "../services/router/RouteServiceProvider.ts"],
4
- "sourcesContent": [
5
- "import type { CronJob } from \"./CronJob\";\nimport type { ScheduleConfig } from \"./config\";\n\n// The handle the in-process `Bun.cron(schedule, callback)` overload returns\n// (has `.stop()`). `ReturnType<typeof Bun.cron>` can't be used — it resolves to\n// the module-path overload's `Promise<void>` instead.\ntype BunCronHandle = Bun.CronJob;\n\n// Runs a tick inside whatever async context the framework needs, so a job body\n// can resolve services exactly like a request handler can.\nexport type ScheduleRunner = <T>(cb: () => T | Promise<T>) => Promise<T> | T;\n\ndeclare global {\n // Registered cron jobs keyed by name, kept on `globalThis` so it survives\n // `bun --hot` reloads. Re-registering a name stops the previous schedule\n // first, so a reload *updates* the job in place instead of stacking a\n // duplicate. (Bun also stops all in-process cron jobs before re-evaluating on\n // hot reload; this makes the intent explicit and covers any re-construction.)\n var __gemiCronJobs: Map<string, BunCronHandle> | undefined;\n}\n\n/**\n * One tick of one job: the gate, then the three hooks in order.\n *\n * Named and exported rather than left inline in `start()` because otherwise the\n * only way to reach it is to wait — the tightest schedule `Bun.cron` accepts is\n * once a minute, which is not a thing a test can honestly sit through. What a\n * caller gives up by calling this directly is Bun's clock; what it keeps is\n * everything the scheduler puts between the clock and the job, which is the\n * part that has behaviour.\n *\n * The three hooks each catch and log, so one throwing does not stop the next —\n * `onComplete` in particular runs whether `callback` returned or threw, closer\n * to a `finally` than to a success handler.\n */\nexport async function runTick(job: CronJob): Promise<void> {\n try {\n // Plain truthiness, not `!== false`. The sloppy gate an app writes is\n // `if (!isProduction) return false;`, which returns `undefined` on the path\n // that was meant to run — and between the two readings of that, the one\n // that skips a recurring tick is recoverable and the one that mails a\n // customer from a developer's laptop is not. The declared return type makes\n // that method a compile error anyway, so the type system catches it while\n // it is still being written and the runtime stays on the safe side.\n if (!(await job.shouldRun.call(job))) {\n return;\n }\n } catch (error) {\n // Fail closed, for the same reason. A gate that throws has told us nothing\n // about whether the job may run, and the framework already refuses to\n // schedule a job whose name or expression it cannot read rather than run\n // something half-declared. The throw is logged, so this is loud; the missed\n // tick comes back on the next one.\n console.error(\n `Error evaluating shouldRun for cron job ${job.name}:`,\n error,\n );\n return;\n }\n\n try {\n await job.onTick.call(job);\n } catch (error) {\n console.error(`Error executing cron job ${job.name}:`, error);\n }\n try {\n await job.callback.call(job);\n } catch (error) {\n console.error(`Error in cron job ${job.name}:`, error);\n }\n try {\n await job.onComplete.call(job);\n } catch (error) {\n console.error(`Error completing cron job ${job.name}:`, error);\n }\n}\n\nexport class Scheduler {\n static token = \"scheduler\";\n\n private handles: BunCronHandle[] = [];\n private resolved: Array<new () => CronJob>;\n\n constructor(config: Required<ScheduleConfig>) {\n this.resolved = config.jobs;\n }\n\n /**\n * The jobs this scheduler will run, or ran — declared in the config slice or\n * discovered under `app/cron`, whichever the slice asked for.\n *\n * #323 turned an application's schedule from an array it could import into a\n * directory it cannot, and an app that had a test walking that array —\n * asserting every report has an owner, that no two share an expression — was\n * about to lose it. This is where that test goes instead, and it is the\n * better question anyway: the config slice says what was asked for, this says\n * what the scheduler took.\n *\n * It lists what `start()` iterates, not what `Bun.cron` accepted. A job with\n * no name, no expression, or a name another job already claimed is logged and\n * skipped, and still appears here — a test walking this should see the\n * problem rather than have it tidied away.\n *\n * A copy, so that walk cannot edit the set the scheduler is running from.\n */\n get jobs(): ReadonlyArray<new () => CronJob> {\n return [...this.resolved];\n }\n\n /**\n * Replaces the job set, for the provider to hand over what it found under\n * `app/cron` before it calls `start()`.\n *\n * The scheduler is constructed in `register()`, where reading a directory and\n * importing what is in it is not allowed to happen — that phase is\n * synchronous and resolves nothing. So it is built from whatever the slice\n * declared and corrected in `boot()`, one line before it starts. Calling this\n * after `start()` changes what `jobs` reports and nothing else; the schedules\n * are already registered.\n */\n useJobs(jobs: Array<new () => CronJob>) {\n this.resolved = jobs;\n }\n\n /**\n * Schedules every configured job. Called from `ScheduleServiceProvider.boot()`\n * — never from the constructor — so a job body may resolve any service the\n * container holds by the time it first ticks. That ordering is what replaced\n * the old `kernel.waitForBoot()` handshake.\n */\n start(run: ScheduleRunner = (cb) => cb()) {\n if (this.resolved.length === 0) {\n return;\n }\n\n const registry = (globalThis.__gemiCronJobs ??= new Map());\n\n // Names claimed during *this* pass, which is a different question from what\n // `registry` holds. `registry` spans hot reloads and is supposed to already\n // contain the previous reload's handle under the same name; this starts\n // empty every time and is how a name claimed twice in one schedule is told\n // apart from the same job coming back after an edit.\n const claimed = new Map<string, string>();\n\n for (const Job of this.resolved) {\n const job = new Job();\n if (!job.name) {\n // Named by its class, because under discovery nobody wrote this job\n // down anywhere and `JSON.stringify(job)` on a nameless one prints\n // `{}`. The overwhelmingly common cause is the second sentence: a\n // shared base class sitting in the walked directory. `abstract` is\n // erased before this code runs, so there is nothing here that could\n // tell a base class from a job — only the message can.\n console.error(\n `Cron job must have a name — ${Job.name || \"an anonymous class\"} ` +\n `has none, so it is not scheduled. If this is a base class that ` +\n `other jobs extend, move it out of the discovered directory: ` +\n `\\`abstract\\` does not survive to runtime, so a class under ` +\n `app/cron is indistinguishable from a job.`,\n );\n continue;\n }\n if (!job.cron) {\n console.error(`Cron job must have an expression. Job: ${job.name}`);\n continue;\n }\n const taken = claimed.get(job.name);\n if (taken !== undefined) {\n // Refusing the second one, rather than letting it through to the\n // `registry.get(...).stop()` below — which is what used to happen, and\n // it stopped the *first* job's schedule while leaving both classes in\n // `jobs`. That is the failure #323 exists to remove wearing a disguise:\n // a report that silently stops arriving, and a test walking `jobs` that\n // sees two healthy entries and passes.\n console.error(\n `Two cron jobs claim the name \"${job.name}\" — ${taken} is ` +\n `scheduled and ${Job.name || \"an anonymous class\"} is not. A name ` +\n `is the scheduler's key, so only one job can hold it. Rename one.`,\n );\n continue;\n }\n claimed.set(job.name, Job.name || \"an anonymous class\");\n\n // Update in place: stop any schedule previously registered under this name\n // before re-registering, so a hot reload replaces rather than duplicates.\n registry.get(job.name)?.stop();\n\n // Inside `run`, gate included: a `shouldRun` that resolves a service to\n // decide is the ordinary case, and evaluating it out here would leave it\n // without the application context every other line of the tick has.\n const handle = Bun.cron(job.cron, () => run(() => runTick(job)));\n\n registry.set(job.name, handle);\n this.handles.push(handle);\n }\n }\n\n stop() {\n for (const handle of this.handles) {\n handle.stop();\n }\n this.handles = [];\n }\n}\n",
6
- "import { ServiceProvider } from \"../support/ServiceProvider\";\nimport type { AuthConfig } from \"./config\";\nimport { AuthManager } from \"./AuthManager\";\n\nexport class AuthServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n AuthManager,\n () => new AuthManager(this.app.config.get<AuthConfig>(\"auth\", {})),\n );\n }\n}\n",
7
- "import { kernelContext } from \"../../kernel/context\";\nimport { ServiceProvider } from \"../../support/ServiceProvider\";\nimport { withDefaults } from \"../../support/withDefaults\";\nimport { discoverCronJobs } from \"../discovery\";\nimport { scheduleConfigDefaults, type ScheduleConfig } from \"./config\";\nimport { Scheduler } from \"./Scheduler\";\n\nexport class ScheduleServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n Scheduler,\n () =>\n new Scheduler(\n withDefaults(\n scheduleConfigDefaults(),\n this.app.config.get<ScheduleConfig>(\"schedule\", {}),\n ),\n ),\n );\n }\n\n /**\n * Resolves the schedule, then starts it.\n *\n * Cron jobs are scheduled in phase two, not in `register()`: a job body is\n * free to resolve any service, and by the time `boot()` runs every provider\n * has registered. Each tick re-enters the application context so the job sees\n * the same container a request handler would.\n *\n * ### Why the raw slice and not the scheduler's config\n *\n * The decision here is whether the app said anything, and by the time the\n * scheduler holds a config it can no longer tell: `withDefaults` treats an\n * absent key and an `undefined` one alike and substitutes the default `[]`,\n * which is the same value an app writes when it means \"nothing scheduled, and\n * I mean it\". Reading the slice before defaults are applied is the only place\n * that difference still exists.\n *\n * So: `jobs` present, including `jobs: []`, is used verbatim and no directory\n * is read. Absent or `undefined` — which includes an app with no `schedule`\n * slice at all — the classes under `jobsDir` are, which is the case #323 is\n * about: a cron job that is written and never listed fires never, and nothing\n * downstream is waiting to notice.\n */\n async boot() {\n const scheduler = this.app.make(Scheduler);\n const slice = this.app.config.get<ScheduleConfig>(\"schedule\", {});\n\n if (slice.jobs === undefined) {\n const { jobsDir } = withDefaults(scheduleConfigDefaults(), slice);\n scheduler.useJobs(await discoverCronJobs(jobsDir));\n }\n\n // Resolved, listed, and not started.\n //\n // `gemi run` sets this on the process it spawns. Booting the application is\n // how a console command reaches the container, and starting the schedule is\n // a side effect of that which nobody asked for: a `gemi run backfill` that\n // takes four minutes would otherwise fire the application's whole cron\n // schedule in a process no operator is watching, and `Bun.cron` handles hold\n // the loop open besides.\n //\n // Deliberately above `start` and below `useJobs`, so `app(Scheduler).jobs`\n // still answers honestly — a command that wants to fire a tick by hand can,\n // and a test asking what this application schedules gets the same answer\n // either way.\n //\n // An environment variable rather than a config field, because this is a\n // property of *this process* and not of the application: the same variable\n // is how a deploy runs one cron dyno beside several web ones, and a config\n // slice would have to know which command started it.\n if (process.env.GEMI_NO_SCHEDULE === \"1\") return;\n\n const app = this.app;\n scheduler.start((cb) => kernelContext.run(app, cb));\n }\n}\n",
8
- "import { ServiceProvider } from \"../../support/ServiceProvider\";\nimport type { MailConfig } from \"./config\";\nimport { MailManager } from \"./MailManager\";\n\nexport class MailServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n MailManager,\n () => new MailManager(this.app.config.get<MailConfig>(\"mail\", {})),\n );\n }\n}\n",
9
- "import { ServiceProvider } from \"../../support/ServiceProvider\";\nimport type { FilesystemConfig } from \"./config\";\nimport { FilesystemManager } from \"./FilesystemManager\";\n\nexport class FilesystemServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n FilesystemManager,\n () =>\n new FilesystemManager(\n this.app.config.get<FilesystemConfig>(\"filesystem\", {}),\n ),\n );\n }\n}\n",
10
- "import { ServiceProvider } from \"../../support/ServiceProvider\";\nimport type { ImageConfig } from \"./config\";\nimport { ImageManager } from \"./ImageManager\";\n\nexport class ImageServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n ImageManager,\n () => new ImageManager(this.app.config.get<ImageConfig>(\"image\", {})),\n );\n }\n}\n",
11
- "import { ServiceProvider } from \"../../support/ServiceProvider\";\nimport { KernelId } from \"./KernelId\";\n\n// Config-less by nature: the id is generated per process, never declared.\nexport class KernelIdServiceProvider extends ServiceProvider {\n register() {\n this.app.instance(KernelId, new KernelId());\n }\n}\n",
12
- "import type { LogEntry } from \"./types\";\n\n// Config key: `log`. Derived from `LoggingServiceProvider`.\nexport interface LogConfig {\n maxFileSize?: number;\n\n onLogFileClosed?: (file: File) => void | Promise<void>;\n onLogCreated?: (logEntry: LogEntry) => void | Promise<void>;\n}\n\nexport function defineLogConfig(config: LogConfig): LogConfig {\n return config;\n}\n\nexport function logConfigDefaults(): Required<LogConfig> {\n return {\n maxFileSize: 1024 * 1024 * 10, // 10MB\n onLogFileClosed: () => {},\n onLogCreated: () => {},\n };\n}\n",
13
- "import { ServiceProvider } from \"../../support/ServiceProvider\";\nimport { withDefaults } from \"../../support/withDefaults\";\nimport { LogManager } from \"./LogManager\";\nimport { logConfigDefaults, type LogConfig } from \"./config\";\n\nexport class LogServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n LogManager,\n () =>\n new LogManager(\n withDefaults(\n logConfigDefaults(),\n this.app.config.get<LogConfig>(\"log\", {}),\n ),\n ),\n );\n }\n\n /**\n * The log directory is created once at kernel boot rather than on the first\n * `Log.info()`, which is what the old eagerly-constructed container did.\n * Resolving here is deliberate: it is the one service whose readiness is a\n * boot-time side effect, and paying for it lazily mid-request would add file\n * IO to whichever handler happened to log first.\n */\n async boot() {\n await this.app.make(LogManager).boot();\n }\n}\n",
14
- "import {\n middlewareConfigDefaults,\n type MiddlewareConfig,\n} from \"../../http/middleware-config\";\nimport { ServiceProvider } from \"../../support/ServiceProvider\";\nimport { withDefaults } from \"../../support/withDefaults\";\nimport { MiddlewareRegistry } from \"./MiddlewareRegistry\";\n\nexport class MiddlewareServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n MiddlewareRegistry,\n () =>\n new MiddlewareRegistry(\n withDefaults(\n middlewareConfigDefaults(),\n this.app.config.get<MiddlewareConfig>(\"middleware\", {}),\n ),\n ),\n );\n }\n}\n",
15
- "import type { BroadcastingChannel } from \"../../broadcasting/BroadcastingChannel\";\n\n// Config key: `broadcast`. Derived from `BroadcastingServiceProvider`.\nexport interface BroadcastConfig {\n channels?: Record<string, new () => BroadcastingChannel>;\n}\n\nexport function defineBroadcastConfig(\n config: BroadcastConfig,\n): BroadcastConfig {\n return config;\n}\n\nexport function broadcastConfigDefaults(): Required<BroadcastConfig> {\n return {\n channels: {},\n };\n}\n",
16
- "import { ServiceProvider } from \"../../support/ServiceProvider\";\nimport { withDefaults } from \"../../support/withDefaults\";\nimport { BroadcastManager } from \"./BroadcastManager\";\nimport { broadcastConfigDefaults, type BroadcastConfig } from \"./config\";\n\nexport class BroadcastServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n BroadcastManager,\n () =>\n new BroadcastManager(\n withDefaults(\n broadcastConfigDefaults(),\n this.app.config.get<BroadcastConfig>(\"broadcast\", {}),\n ),\n ),\n );\n }\n}\n",
17
- "import { ServiceProvider } from \"../../support/ServiceProvider\";\nimport { discoverJobs } from \"../discovery\";\nimport { withDefaults } from \"../../support/withDefaults\";\nimport { queueConfigDefaults, type QueueConfig } from \"./config\";\nimport { QueueManager } from \"./QueueManager\";\n\nexport class QueueServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n QueueManager,\n () => new QueueManager(this.app.config.get<QueueConfig>(\"queue\", {})),\n );\n }\n\n /**\n * Fills in the job registry when the app did not declare one.\n *\n * ### Why the raw slice and not the manager's config\n *\n * The decision here is whether the app said anything, and by the time the\n * manager holds a config it can no longer tell: `withDefaults` treats an\n * absent key and an `undefined` one alike and substitutes the default `[]`,\n * which is the same value an app writes when it means \"no jobs, and I mean\n * it\". Reading the slice before defaults are applied is the only place the\n * difference still exists.\n *\n * So: `jobs` present, including `jobs: []`, is used verbatim and no directory\n * is read. Absent or `undefined`, the classes under `jobsDir` are.\n *\n * ### Why phase two\n *\n * Discovery imports every file it walks, which is asynchronous, and\n * `register()` is not. It also has to happen before the first dispatch rather\n * than before the first tick — there is no equivalent of the scheduler's\n * `start()` to hang it off, so the registry has to be complete by the end of\n * boot.\n */\n async boot() {\n const slice = this.app.config.get<QueueConfig>(\"queue\", {});\n if (slice.jobs !== undefined) return;\n\n const { jobsDir } = withDefaults(queueConfigDefaults(), slice);\n this.app.make(QueueManager).useJobs(await discoverJobs(jobsDir));\n }\n}\n",
18
- "import type { ConsumeParams, RateLimitResult } from \"../types\";\n\nexport abstract class RateLimiterDriver {\n /**\n * Records one request against `params.key` and reports whether it fits.\n *\n * Implementations must decide *and* record atomically — two concurrent calls\n * for the same key may never both be told they were the last one that fit.\n *\n * May be sync or async: the in-memory driver answers immediately, a network\n * backed driver returns a promise. Callers always `await` the result.\n */\n abstract consume(\n params: ConsumeParams,\n ): Promise<RateLimitResult> | RateLimitResult;\n}\n",
19
- "import type { RateLimitResult } from \"./types\";\n\n/**\n * The sliding-window-counter algorithm, shared by every driver.\n *\n * A fixed window is cheap but lets a client spend its whole budget at the end\n * of one window and again at the start of the next — twice the limit across a\n * window's worth of time. A true sliding log fixes that but has to keep a\n * timestamp per request.\n *\n * The counter variant keeps two integers per key (this window and the one\n * before it) and estimates usage by weighting the previous window by how much\n * of it still overlaps the trailing window:\n *\n * usage = previous * (window - elapsed) / window + current\n *\n * That is a ~0.003% error on real traffic and costs two integers per key, so\n * it is what the in-memory and Redis drivers both implement.\n */\n\n/** Epoch ms of the start of the window `now` falls into. */\nexport function windowStartFor(now: number, window: number) {\n return Math.floor(now / window) * window;\n}\n\n/** Weight of the previous window's count, from `1` down to `0`. */\nexport function previousWeight(elapsed: number, window: number) {\n if (window <= 0) return 0;\n return Math.min(1, Math.max(0, (window - elapsed) / window));\n}\n\n/** Estimated usage of the trailing `window` ending at `now`. */\nexport function estimateUsage(\n current: number,\n previous: number,\n elapsed: number,\n window: number,\n) {\n return previous * previousWeight(elapsed, window) + current;\n}\n\n/**\n * How long until a request costing `cost` would be admitted, in milliseconds.\n *\n * Solves the usage equation for `elapsed` instead of guessing: the caller gets\n * a `Retry-After` that lands the moment capacity actually frees up rather than\n * at the end of the window, which for a sliding window is usually far too late.\n */\nexport function timeUntilAllowed(params: {\n current: number;\n previous: number;\n elapsed: number;\n window: number;\n limit: number;\n cost: number;\n}) {\n const { current, previous, elapsed, window, limit, cost } = params;\n // Usage the bucket may sit at for this request to still fit.\n const budget = limit - cost;\n\n // The request can never fit, no matter how long the caller waits. Report a\n // full window rather than `Infinity` so a `Retry-After` header stays usable.\n if (budget < 0) return window;\n\n const remainingWindow = Math.max(0, window - elapsed);\n\n // Phase 1 — capacity frees up inside the current window as `previous` decays.\n if (previous > 0) {\n // previous * (window - e) / window + current = budget => solve for e\n const target = window * (1 - (budget - current) / previous);\n if (target <= window) {\n return Math.max(0, Math.ceil(target - elapsed));\n }\n }\n\n // Phase 2 — `current` alone is already over budget, so nothing frees up until\n // the window rolls and `current` becomes the decaying `previous`.\n if (current <= budget) return remainingWindow;\n if (current <= 0) return remainingWindow;\n\n const target = window * (1 - budget / current);\n return remainingWindow + Math.max(0, Math.ceil(target));\n}\n\n/**\n * Turns a driver's post-operation counters into the result the caller sees.\n * `current` and `previous` are the counts *after* an allowed request has been\n * recorded, so every driver reports the same numbers for the same state.\n */\nexport function buildResult(params: {\n allowed: boolean;\n current: number;\n previous: number;\n now: number;\n elapsed: number;\n window: number;\n limit: number;\n cost: number;\n}): RateLimitResult {\n const { allowed, current, previous, now, elapsed, window, limit, cost } =\n params;\n\n if (allowed) {\n const usage = estimateUsage(current, previous, elapsed, window);\n return {\n allowed: true,\n limit,\n remaining: Math.max(0, Math.floor(limit - usage)),\n resetAt: now - elapsed + window,\n retryAfter: 0,\n };\n }\n\n const retryAfter = timeUntilAllowed({\n current,\n previous,\n elapsed,\n window,\n limit,\n cost,\n });\n\n return {\n allowed: false,\n limit,\n remaining: 0,\n resetAt: now + retryAfter,\n retryAfter,\n };\n}\n",
20
- "import { buildResult, estimateUsage, windowStartFor } from \"../slidingWindow\";\nimport type { ConsumeParams, RateLimitResult } from \"../types\";\nimport { RateLimiterDriver } from \"./RateLimiterDriver\";\n\ninterface Bucket {\n /** Window length this bucket was counted with, so config changes reset it. */\n window: number;\n windowStart: number;\n current: number;\n previous: number;\n}\n\nexport interface InMemoryRateLimiterOptions {\n /**\n * Hard cap on tracked keys. Reached only by traffic that never repeats a key\n * (spoofed `x-forwarded-for`, for instance); the map is swept of dead buckets\n * first and only then evicts live ones, oldest touched first.\n *\n * Defaults to 100k keys — a few MB, and far more than a single instance\n * legitimately sees inside one window.\n */\n maxKeys?: number;\n}\n\n/**\n * Per-process rate limiter. The default driver, and the right one for a single\n * instance or for development.\n *\n * State lives in this process only: with N instances behind a load balancer the\n * effective limit is N × the configured limit, and it resets on deploy. Point\n * the service provider at `RedisRateLimiter` once you run more than one.\n */\nexport class InMemoryRateLimiter extends RateLimiterDriver {\n private buckets = new Map<string, Bucket>();\n private maxKeys: number;\n\n constructor(options: InMemoryRateLimiterOptions = {}) {\n super();\n this.maxKeys = Math.max(1, options.maxKeys ?? 100_000);\n }\n\n consume(params: ConsumeParams): RateLimitResult {\n const { key, limit, window } = params;\n const cost = params.cost ?? 1;\n const now = Date.now();\n const windowStart = windowStartFor(now, window);\n const elapsed = now - windowStart;\n\n const bucket = this.roll(key, window, windowStart);\n const usage = estimateUsage(\n bucket.current,\n bucket.previous,\n elapsed,\n window,\n );\n const allowed = usage + cost <= limit;\n\n if (allowed) {\n bucket.current += cost;\n }\n\n // Re-inserting moves the key to the end of the iteration order, which is\n // what makes eviction least-recently-used rather than arbitrary.\n this.buckets.delete(key);\n this.buckets.set(key, bucket);\n if (this.buckets.size > this.maxKeys) {\n this.evict(now);\n }\n\n return buildResult({\n allowed,\n current: bucket.current,\n previous: bucket.previous,\n now,\n elapsed,\n window,\n limit,\n cost,\n });\n }\n\n /** Drops all counters. Mainly useful in tests. */\n clear() {\n this.buckets.clear();\n }\n\n /** Number of tracked keys. Exposed for tests and diagnostics. */\n get size() {\n return this.buckets.size;\n }\n\n /** Advances a bucket to `windowStart`, creating it when absent or stale. */\n private roll(key: string, window: number, windowStart: number): Bucket {\n const bucket = this.buckets.get(key);\n\n if (!bucket || bucket.window !== window) {\n return { window, windowStart, current: 0, previous: 0 };\n }\n\n if (bucket.windowStart === windowStart) {\n return bucket;\n }\n\n if (bucket.windowStart + window === windowStart) {\n bucket.previous = bucket.current;\n bucket.current = 0;\n bucket.windowStart = windowStart;\n return bucket;\n }\n\n // Idle for more than a full window: everything it held has decayed away.\n bucket.previous = 0;\n bucket.current = 0;\n bucket.windowStart = windowStart;\n return bucket;\n }\n\n private evict(now: number) {\n for (const [key, bucket] of this.buckets) {\n // Fully decayed — it would be reset on the next read anyway.\n if (now - bucket.windowStart >= bucket.window * 2) {\n this.buckets.delete(key);\n }\n }\n\n // Still over the cap, so the traffic is live rather than stale. Drop the\n // least recently touched keys; the worst case is that a client whose bucket\n // was dropped gets a fresh budget, which beats growing without bound.\n for (const key of this.buckets.keys()) {\n if (this.buckets.size <= this.maxKeys) break;\n this.buckets.delete(key);\n }\n }\n}\n",
21
- "import { InMemoryRateLimiter } from \"./drivers/InMemoryRateLimiterDriver\";\nimport type { RateLimiterDriver } from \"./drivers/RateLimiterDriver\";\n\n// Config key: `ratelimiter`. Derived from `RateLimiterServiceProvider`.\nexport interface RateLimiterConfig {\n /**\n * Where counters live. In-process by default; swap in `RedisRateLimiter` once\n * the app runs on more than one instance.\n */\n driver?: RateLimiterDriver;\n\n /** Requests allowed per window when the `rate-limit` DSL omits a limit. */\n limit?: number;\n\n /** Window length in **seconds** when the `rate-limit` DSL omits one. */\n window?: number;\n}\n\nexport function defineRateLimiterConfig(\n config: RateLimiterConfig,\n): RateLimiterConfig {\n return config;\n}\n\nexport function rateLimiterConfigDefaults(): Required<RateLimiterConfig> {\n return {\n driver: new InMemoryRateLimiter(),\n limit: 1000,\n window: 60,\n };\n}\n",
22
- "import { ServiceProvider } from \"../../support/ServiceProvider\";\nimport { withDefaults } from \"../../support/withDefaults\";\nimport { RateLimiter } from \"./RateLimiter\";\nimport { rateLimiterConfigDefaults, type RateLimiterConfig } from \"./config\";\n\nexport class RateLimiterServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n RateLimiter,\n () =>\n new RateLimiter(\n withDefaults(\n rateLimiterConfigDefaults(),\n this.app.config.get<RateLimiterConfig>(\"ratelimiter\", {}),\n ),\n ),\n );\n }\n}\n",
23
- "import type { RedisOptions } from \"bun\";\n\n// Config key: `redis`. Derived from `RedisServiceProvider`.\nexport interface RedisConfig {\n // Connection URL for Bun's Redis client. Defaults to the `REDIS_URL`\n // environment variable (Bun itself falls back to `redis://localhost:6379`\n // when unset).\n url?: string;\n\n // Optional Bun Redis client options (TLS, timeouts, auto-reconnect, ...).\n options?: RedisOptions;\n}\n\nexport function defineRedisConfig(config: RedisConfig): RedisConfig {\n return config;\n}\n\nexport function redisConfigDefaults(): RedisConfig {\n return {\n url: process.env.REDIS_URL,\n options: undefined,\n };\n}\n",
24
- "import { ServiceProvider } from \"../../support/ServiceProvider\";\nimport { withDefaults } from \"../../support/withDefaults\";\nimport { redisConfigDefaults, type RedisConfig } from \"./config\";\nimport { RedisManager } from \"./RedisManager\";\n\nexport class RedisServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n RedisManager,\n () =>\n new RedisManager(\n withDefaults(\n redisConfigDefaults(),\n this.app.config.get<RedisConfig>(\"redis\", {}),\n ),\n ),\n );\n }\n}\n",
25
- "import { ServiceProvider } from \"../../support/ServiceProvider\";\nimport { ApiRouteDispatcher } from \"./ApiRouteDispatcher\";\nimport { ViewRouteDispatcher } from \"./ViewRouteDispatcher\";\nimport type { ApiRouteConfig, ViewRouteConfig } from \"./config\";\nimport type { Repository } from \"../../support/Repository\";\n\nfunction readConfig<T>(config: Repository, key: string): T {\n const slice = config.get<T>(key);\n if (!slice) {\n throw new Error(\n `Missing \"${key}\" configuration. Route dispatching needs a root router — declare it in \"app/config/route.ts\".`,\n );\n }\n return slice;\n}\n\n/**\n * Owns both route dispatchers. Laravel ships a single RouteServiceProvider for\n * every route file it loads; the api/view split is a config slice, not a\n * separate provider.\n */\nexport class RouteServiceProvider extends ServiceProvider {\n register() {\n this.app.singleton(\n ApiRouteDispatcher,\n () =>\n new ApiRouteDispatcher(\n readConfig<ApiRouteConfig>(this.app.config, \"route.api\"),\n ),\n );\n\n this.app.singleton(\n ViewRouteDispatcher,\n () =>\n new ViewRouteDispatcher(\n readConfig<ViewRouteConfig>(this.app.config, \"route.view\"),\n ),\n );\n }\n\n /**\n * The two dispatchers are the one pair of services that must not be built\n * lazily: constructing them flattens the route tables and runs\n * `assertNoReservedRoutePaths`, so a missing `route` config or a route under\n * a reserved prefix has to fail the boot rather than the first request that\n * happens to hit it.\n */\n boot() {\n this.app.make(ApiRouteDispatcher);\n this.app.make(ViewRouteDispatcher);\n }\n}\n"
26
- ],
27
- "mappings": ";mbAmCA,SAAsB,LAAO,LAAC,JAA6B,LACzD,HAAI,CAQF,GAAI,CAAE,MAAM,EAAI,UAAU,KAAK,CAAG,EAChC,OAEF,MAAO,EAAO,CAMd,QAAQ,MACN,2CAA2C,EAAI,QAC/C,CACF,EACA,OAGF,GAAI,CACF,MAAM,EAAI,OAAO,KAAK,CAAG,EACzB,MAAO,EAAO,CACd,QAAQ,MAAM,4BAA4B,EAAI,QAAS,CAAK,EAE9D,GAAI,CACF,MAAM,EAAI,SAAS,KAAK,CAAG,EAC3B,MAAO,EAAO,CACd,QAAQ,MAAM,qBAAqB,EAAI,QAAS,CAAK,EAEvD,GAAI,CACF,MAAM,EAAI,WAAW,KAAK,CAAG,EAC7B,MAAO,EAAO,CACd,QAAQ,MAAM,6BAA6B,EAAI,QAAS,CAAK,GAI1D,MAAM,CAAU,OACd,OAAQ,YAEP,QAA2B,CAAC,EAC5B,SAER,WAAW,CAAC,EAAkC,CAC5C,KAAK,SAAW,EAAO,QAqBrB,KAAI,EAAqC,CAC3C,M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BK,MAAM,WAAmC,CAAgB,CAC9D,QAAQ,EAAG,CACT,KAAK,IAAI,UACP,EACA,IACE,IAAI,EACF,EACE,EAA0B,EAC1B,KAAK,IAAI,OAAO,IAAuB,cAAe,CAAC,CAAC,CAC1D,CACF,CACJ,EAEJ,CCLO,SAAS,EAAiB,CAAC,EAAkC,CAClE,OAAO,EAGF,SAAS,CAAmB,EAAgB,CACjD,MAAO,CACL,IAAK,QAAQ,IAAI,UACjB,QAAS,MACX,EChBK,MAAM,WAA6B,CAAgB,CACxD,QAAQ,EAAG,CACT,KAAK,IAAI,UACP,EACA,IACE,IAAI,EACF,EACE,EAAoB,EACpB,KAAK,IAAI,OAAO,IAAiB,QAAS,CAAC,CAAC,CAC9C,CACF,CACJ,EAEJ,CCZA,SAAS,CAAa,CAAC,EAAoB,EAAgB,CACzD,IAAM,EAAQ,EAAO,IAAO,CAAG,EAC/B,GAAI,CAAC,EACH,MAAU,MACR,YAAY,qGACd,EAEF,OAAO,EAQF,MAAM,WAA6B,CAAgB,CACxD,QAAQ,EAAG,CACT,KAAK,IAAI,UACP,EACA,IACE,IAAI,EACF,EAA2B,KAAK,IAAI,OAAQ,WAAW,CACzD,CACJ,EAEA,KAAK,IAAI,UACP,EACA,IACE,IAAI,EACF,EAA4B,KAAK,IAAI,OAAQ,YAAY,CAC3D,CACJ,EAUF,IAAI,EAAG,CACL,KAAK,IAAI,KAAK,CAAkB,EAChC,KAAK,IAAI,KAAK,CAAmB,EAErC",
28
- "debugId": "9281D90411127C3764756E2164756E21",
29
- "names": []
30
- }
@@ -1,5 +0,0 @@
1
- // @bun
2
- import{Lb as o}from"./chunk-64s1pzz1.js";import{Mb as i}from"./chunk-eqrd31ye.js";import{Te as t}from"./chunk-4yafsffx.js";import{Ze as r}from"./chunk-ct274qts.js";class n extends i{register(){this.app.singleton(r,()=>new r(t(o(),this.app.config.get("translation",{}))))}}
3
- export{n as Qa};
4
-
5
- //# debugId=456612EFA619479A64756E2164756E21
@@ -1,6 +0,0 @@
1
- // @bun
2
- import{pa as j}from"./chunk-tkdxv6cq.js";import{createElement as x}from"react";function m(i,n){let s=Object.keys(n).sort((u,b)=>b.length-u.length).map((u)=>u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),r=new RegExp(s.join("|"),"g");return i.replace(r,(u)=>n[u])}async function J(i,n,s=[]){let r=[...s.map((t)=>`${i}/views/${t}.tsx`),`${i}/views/RootLayout.tsx`],u=new Set;for(let t of r){let e=n.moduleGraph.getModulesByFile(t);if(e)for(let d of e)u.add(d)}let b=[],p=[],c={};for(let t of u)if(t)for(let e of t.importedModules){if(e.file.includes("module.css"))c[e.file]=e.ssrTransformResult.map.sourcesContent.join("");if(e.file.includes(".css"))p.push(e.file)}for(let t of p){let e=await n.transformRequest(t+"?direct"),d=t.includes("module.css"),o="";if(d)o=m(c[t],e.default);b.push({isDev:!0,id:t,content:d?o:e.code})}return b.map((t,e)=>{return x("style",{key:e,type:"text/css","data-vite-dev-id":t.id,dangerouslySetInnerHTML:{__html:t.content}})})}async function L(i=[]){return i.map((n,s)=>{return x("style",{key:s,id:n?.id,type:"text/css",dangerouslySetInnerHTML:{__html:n.content}})})}import{existsSync as v}from"fs";import{basename as f}from"path";import{networkInterfaces as k}from"os";var h={name:"gemi",version:"0.56.0",private:!1,license:"MIT",author:"Enes Tufekci <enes@gemijs.dev>",repository:{type:"git",url:"git+https://github.com/nstfkc/gemi.git",directory:"packages/gemi"},bin:{gemi:"./dist/bin/gemi.js","gemi-orm-generator":"./dist/bin/orm-generator.js"},files:["dist/**/*"],module:!0,exports:{"./http":"./http/index.ts","./client":"./client/index.ts","./testing":"./testing/index.ts","./app":"./app/index.ts","./facades":"./facades/index.ts","./email":"./email/index.ts","./vite":"./dist/vite/index.mjs","./kernel":"./kernel/index.ts","./services":"./services/index.ts","./broadcasting":"./broadcasting/index.ts","./i18n":"./i18n/index.ts","./dictionary":"./i18n/dictionaryRuntime.ts","./server":"./server/index.ts","./config":"./config/index.ts","./container":"./container/index.ts","./foundation":"./foundation/index.ts","./database":"./database/index.ts","./orm":"./orm/index.ts","./support":"./support/index.ts","./console/run":"./console/run.ts","./bun/preload":"./bun/preload.ts","./bun/plugin":"./bun/plugin.ts"},scripts:{lint:"oxlint",typecheck:"tsc --noEmit -p tsconfig.json",build:"NODE_ENV=production bun run build:core && bun run build:bin && bun run build:types && bun run build:client && bun run build:plugin && bun run build:client-types && bun run build:augmentation","build:core":"bun ./scripts/build.ts","build:bin":"bun build --outdir=./dist/bin --target=bun --external=vite --external=react-dom --external=react/jsx-runtime --external=bun --external=sharp --external=@azure/storage-blob --sourcemap ./bin/gemi.ts ./bin/orm-generator.ts && bun ./scripts/prepare-bin.ts","build:client":"rm -rf dist/client dist/testing dist/chunks && vite build -c vite.client.config.mts","build:plugin":"vite build -c vite.plugin.config.mts","build:types":"tsc","build:client-types":"tsc -p tsconfig.browser.json",test:"bun --bun vitest","test:types":"vitest run --typecheck.only","test:packaging":"bun --bun vitest run --config vitest.packaging.config.ts","build:publish":"bun scripts/build-publish.ts",prepublishOnly:"echo 'Do not publish from this directory \u2014 its exports point at TS source. Run: bun run build:publish, then publish from .publish/' && exit 1","build:augmentation":"bun ./scripts/wire-augmentation.ts"},dependencies:{"@aws-sdk/client-s3":"^3.629.0","@aws-sdk/s3-request-presigner":"^3.629.0","ast-types":"^0.14.2",commander:"^12.1.0",history:"^5.3.0","jsx-email":"2.0.0-rc2.1","magic-string":"^0.30.17",open:"^10.1.0","react-error-boundary":"^6.0.0",recast:"^0.23.9",resend:"^6.12.3",satori:"^0.12.2","temporal-polyfill":"^0.2.5","twitter-api-v2":"^1.20.2","urlpattern-polyfill":"^10.0.0",uuid:"^9.0.1"},devDependencies:{"@babel/parser":"^7.25.4","@prisma/generator-helper":"^6.5.0","@repo/typescript-config":"*","@testing-library/react":"^16.3.2","@types/bun":"^1.3.14","@types/eslint":"^8.56.5","@types/node":"^20.11.24","@types/react":"^19.0.2","@types/react-dom":"^19.0.2",eslint:"^8.57.0",jsdom:"^30.0.1",oxlint:"^1.39.0",react:"19.2.3","react-dom":"19.2.3",typescript:"^5.7.3",vitest:"^4.0.0"},peerDependencies:{"@azure/storage-blob":"^12.28.0",react:">=19","react-dom":">=19",sharp:"^0.34.2",vite:"^8.0.0"},peerDependenciesMeta:{"@azure/storage-blob":{optional:!0}}};var z=[" \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557\u2588\u2588\u2557","\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551","\u2588\u2588\u2551 \u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2554\u2588\u2588\u2588\u2588\u2554\u2588\u2588\u2551\u2588\u2588\u2551","\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u255D \u2588\u2588\u2551\u255A\u2588\u2588\u2554\u255D\u2588\u2588\u2551\u2588\u2588\u2551","\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u255A\u2550\u255D \u2588\u2588\u2551\u2588\u2588\u2551"," \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D"],O=Boolean(process.stdout.isTTY)&&!process.env.NO_COLOR,g=(i,n)=>O?`\x1B[${i}m${n}\x1B[0m`:n,T=(i)=>g("1",i),l=(i)=>g("2",i),a=(i)=>g("36",i),q=(i)=>g("32",i),R=(i)=>g("35",i);function _(){return h.version??"?"}function E(i){for(let n of Object.values(k()))for(let s of n??[])if((s.family==="IPv4"||s.family===4)&&!s.internal)return`http://${s.address}:${i}`;return null}function G(i){return j(i).filter((n)=>v(n)).map((n)=>f(n))}function A(i){let{port:n,rootDir:s}=i,r=`http://localhost:${n}`,u=E(n),b=G(s),p=(t,e)=>` ${q("\u279C")} ${T(t.padEnd(9))}${e}`,c=["",...z.map((t)=>R(t)),"",` ${l("gemi")} ${a(`v${_()}`)}`,"",p("Local:",a(r)),p("Network:",u?a(u):l("unavailable")),p("Env:",b.length?b.join(", "):l("none")),""];console.log(c.join(`
3
- `))}
4
- export{J as Z,L as _,A as $};
5
-
6
- //# debugId=CDC122966F412D5464756E2164756E21
@@ -1,5 +0,0 @@
1
- // @bun
2
- import{Re as O}from"./chunk-01am9k5v.js";import{gf as M}from"./chunk-kgmr9qxx.js";var x={};M(x,{registeredNames:()=>S,register:()=>R,has:()=>_,get:()=>C,clearRegistry:()=>b});var D=new Map;function R(j,B){D.set(j,B)}function _(j){return D.has(j)}function C(j){let B=D.get(j);if(B===void 0)throw new O(j,[...D.keys()]);return B}function S(){return[...D.keys()]}function b(){D.clear()}import{AsyncLocalStorage as H}from"async_hooks";class K{content={title:"Gemi App",description:null,openGraph:null};touched=!1;render(){return{title:this.content.title,description:this.content.description,openGraph:this.content.openGraph}}title(j){this.touched=!0,this.content.title=j}description(j){this.touched=!0,this.content.description=j}openGraph({title:j,description:B,type:z,url:J,image:F,imageAlt:Q,imageWidth:V,imageHeight:X,twitterImage:Y=F,twitterImageAlt:N=Q,twitterImageWidth:P=V,twitterImageHeight:U=X}){this.touched=!0;let Z=F,$=Y;if(F&&!F.startsWith("http"))Z=`${process.env.HOST_NAME}${F}`,$=`${process.env.HOST_NAME}${Y}`;this.content.openGraph=Object.fromEntries(Object.entries({title:j,description:B,type:z,url:J,image:Z,imageAlt:Q,imageWidth:V,imageHeight:X,twitterImage:$,twitterImageAlt:N,twitterImageWidth:P,twitterImageHeight:U}).filter(([A,T])=>T!==void 0))}}function E(j,B,z={}){return[`${j}=${B}`,z.maxAge?`Max-Age=${z.maxAge}`:"",z.httpOnly?"HttpOnly":"",z.secure?"Secure":"",z.sameSite?`SameSite=${z.sameSite}`:"SameSite=Strict",z.path?`Path=${z.path}`:"Path=/",z.domain?`Domain=${z.domain}`:"",z.expires?`Expires=${z.expires.toUTCString()}`:"",z.partitioned?"Partitioned":""].filter((J)=>J!=="").join("; ")}var G=new H;class L{req;cookies=new Set;headers=new Headers;serverQueries=null;user=null;csrfHmac=null;locale=null;metadata=new K;rangeRequest=null;constructor(j){this.req=j}setLocale(j){this.locale=j}renderMeta(){return this.metadata.render()}setCSRFHmac(j){this.csrfHmac=j}setCookie(j,B,z={}){this.cookies.add(E(j,B,z))}deleteCookie(j){this.cookies.add(E(j,"",{maxAge:-1}))}setHeaders(j,B){this.headers.set(j,B)}setUser(j){this.user=j}setRequest(j){this.req=j}destroy(){delete this.cookies,delete this.headers,this.serverQueries=null,delete this.user}}class W{static getStore(){return G.getStore()}static setRequest(j){G.getStore().req=j}static run(j,B){return G.run(new L(j),B)}static runWith(j,B){return G.run(j,B)}}
3
- export{W as re,R as se,_ as te,C as ue,S as ve,x as we};
4
-
5
- //# debugId=E7EC0D69CEAAA9D364756E2164756E21
@@ -1,12 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../orm/registry.ts", "../http/requestContext.ts", "../http/Metadata.ts"],
4
- "sourcesContent": [
5
- "import { ModelNotRegisteredError } from \"./errors\";\n\n/**\n * Name-keyed, resolved at call time, never at module load.\n *\n * The generated schema refers to a relation's target by model *name*, not by\n * importing the class. Without that indirection `User.ts` imports `Post.ts`\n * imports `User.ts` and, under ESM, one of them is `undefined` while the other\n * is still evaluating. It is the classic ORM bootstrap failure and it shows up\n * the moment two models reference each other — which, in any real schema, is\n * immediately.\n *\n * It also keeps the generated files free of an import graph: they hold data and\n * strings only.\n */\nconst models = new Map<string, unknown>();\n\nexport function register(name: string, model: unknown): void {\n models.set(name, model);\n}\n\nexport function has(name: string): boolean {\n return models.has(name);\n}\n\nexport function get<T = unknown>(name: string): T {\n const model = models.get(name);\n if (model === undefined) {\n throw new ModelNotRegisteredError(name, [...models.keys()]);\n }\n return model as T;\n}\n\nexport function registeredNames(): string[] {\n return [...models.keys()];\n}\n\nexport function clearRegistry(): void {\n models.clear();\n}\n",
6
- "import { AsyncLocalStorage } from \"node:async_hooks\";\nimport type { HttpRequest } from \"./HttpRequest\";\nimport { Metadata } from \"./Metadata\";\nimport type { ByteRange } from \"./range\";\n// Type-only: `services/router` imports from `http`, so a runtime import here\n// would be circular.\nimport type { ServerQueryStore } from \"../services/router/ServerQueryStore\";\n\nexport interface CreateCookieOptions {\n maxAge?: number;\n expires?: Date;\n httpOnly?: boolean;\n secure?: boolean;\n sameSite?: \"Strict\" | \"Lax\";\n path?: string;\n domain?: string;\n partitioned?: boolean;\n}\n\nexport function createCookie(\n name: string,\n value: string,\n options: CreateCookieOptions = {},\n) {\n return [\n `${name}=${value}`,\n options.maxAge ? `Max-Age=${options.maxAge}` : \"\",\n options.httpOnly ? \"HttpOnly\" : \"\",\n options.secure ? \"Secure\" : \"\",\n options.sameSite ? `SameSite=${options.sameSite}` : \"SameSite=Strict\",\n options.path ? `Path=${options.path}` : \"Path=/\",\n options.domain ? `Domain=${options.domain}` : \"\",\n options.expires ? `Expires=${options.expires.toUTCString()}` : \"\",\n options.partitioned ? \"Partitioned\" : \"\",\n ]\n .filter((i) => i !== \"\")\n .join(\"; \");\n}\n\nconst requestContext = new AsyncLocalStorage<Store>();\n\nclass Store {\n cookies: Set<string> = new Set();\n headers: Headers = new Headers();\n /**\n * Every server-side query of this request — prefetched or discovered during\n * the streaming render. Assigned by the view router (or lazily by the\n * `Query` facade); `null` for api requests, which must not query themselves.\n */\n serverQueries: ServerQueryStore | null = null;\n user: any = null;\n csrfHmac: string | null = null;\n locale: string | null = null;\n metadata = new Metadata();\n /**\n * The parsed `Range` of the in-flight request, picked up by\n * `FileStorage.read()` so a range reaches the storage backend without every\n * handler having to thread it through by hand.\n *\n * Only populated inside a `this.stream()` route, and cleared once that route\n * returns: a `FileStorage.read()` in an ordinary handler must never start\n * silently returning partial bytes.\n */\n rangeRequest: ByteRange | null = null;\n\n constructor(public req: HttpRequest) {}\n\n setLocale(locale: string) {\n this.locale = locale;\n }\n\n renderMeta() {\n return this.metadata.render();\n }\n\n setCSRFHmac(hmac: string) {\n this.csrfHmac = hmac;\n }\n\n setCookie(name: string, value: string, options: CreateCookieOptions = {}) {\n this.cookies.add(createCookie(name, value, options));\n }\n\n deleteCookie(name: string) {\n this.cookies.add(createCookie(name, \"\", { maxAge: -1 }));\n }\n\n setHeaders(name: string, value: string) {\n this.headers.set(name, value);\n }\n\n setUser(user: any) {\n this.user = user;\n }\n\n setRequest(req: HttpRequest<any, any>) {\n this.req = req;\n }\n\n destroy() {\n delete this.cookies;\n delete this.headers;\n this.serverQueries = null;\n delete this.user;\n }\n}\n\nexport class RequestContext {\n static getStore() {\n return requestContext.getStore()!;\n }\n\n static setRequest(req: HttpRequest<any, any>) {\n requestContext.getStore().req = req;\n }\n\n static run<T>(httpRequest: HttpRequest, fn: () => T): T {\n return requestContext.run(new Store(httpRequest), fn);\n }\n\n /**\n * Re-enters an *existing* request scope. Stream lifecycle callbacks fire\n * after the HTTP server has taken over the response body — outside the\n * AsyncLocalStorage scope the request ran in — so the view router captures\n * the live store and re-enters it around user-facing hooks, keeping\n * `req.ctx()` (and everything context-backed) working inside them.\n */\n static runWith<T>(store: Store, fn: () => T): T {\n return requestContext.run(store, fn);\n }\n}\n",
7
- "export type OpenGraphParams = {\n title: string;\n description?: string;\n type: string;\n url: string;\n image: string;\n imageAlt?: string;\n imageWidth?: number;\n imageHeight?: number;\n twitterImage?: string;\n twitterImageAlt?: string;\n twitterImageWidth?: number;\n twitterImageHeight?: number;\n};\nexport class Metadata {\n content: any = {\n title: \"Gemi App\",\n description: null,\n openGraph: null,\n };\n\n /**\n * Whether a handler set anything, as opposed to `content` still being the\n * defaults. A partially rendered response that touched no metadata sends\n * none, so the client keeps what the skipped segments put there.\n */\n touched = false;\n\n render() {\n return {\n title: this.content.title,\n description: this.content.description,\n openGraph: this.content.openGraph,\n };\n }\n\n title(title: string) {\n this.touched = true;\n this.content.title = title;\n }\n\n description(description: string) {\n this.touched = true;\n this.content.description = description;\n }\n\n openGraph({\n title,\n description,\n type,\n url,\n image,\n imageAlt,\n imageWidth,\n imageHeight,\n twitterImage = image,\n twitterImageAlt = imageAlt,\n twitterImageWidth = imageWidth,\n twitterImageHeight = imageHeight,\n }: OpenGraphParams) {\n this.touched = true;\n let _image = image;\n let _twitterImage = twitterImage;\n if (image && !image.startsWith(\"http\")) {\n _image = `${process.env.HOST_NAME}${image}`;\n _twitterImage = `${process.env.HOST_NAME}${twitterImage}`;\n }\n this.content.openGraph = Object.fromEntries(\n Object.entries({\n title,\n description,\n type,\n url,\n image: _image,\n imageAlt,\n imageWidth,\n imageHeight,\n twitterImage: _twitterImage,\n twitterImageAlt,\n twitterImageWidth,\n twitterImageHeight,\n }).filter(([_, value]) => value !== undefined),\n );\n }\n}\n"
8
- ],
9
- "mappings": ";qLAeA,FAAM,EAAS,IAAI,IAEZ,SAAS,CAAQ,CAAC,EAAc,EAAsB,CAC3D,EAAO,IAAI,EAAM,CAAK,EAGjB,SAAS,CAAG,CAAC,EAAuB,CACzC,OAAO,EAAO,IAAI,CAAI,EAGjB,SAAS,CAAgB,CAAC,EAAiB,CAChD,IAAM,EAAQ,EAAO,IAAI,CAAI,EAC7B,GAAI,IAAU,OACZ,MAAM,IAAI,EAAwB,EAAM,CAAC,GAAG,EAAO,KAAK,CAAC,CAAC,EAE5D,OAAO,EAGF,SAAS,CAAe,EAAa,CAC1C,MAAO,CAAC,GAAG,EAAO,KAAK,CAAC,EAGnB,SAAS,CAAa,EAAS,CACpC,EAAO,MAAM,ECtCf,4BAAS,oBCcF,MAAM,CAAS,CACpB,QAAe,CACb,MAAO,WACP,YAAa,KACb,UAAW,IACb,EAOA,QAAU,GAEV,MAAM,EAAG,CACP,MAAO,CACL,MAAO,KAAK,QAAQ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KAC1B,OAAwB,KACxB,SAAW,IAAI,EAUf,aAAiC,KAEjC,WAAW,CAAQ,EAAkB,CAAlB,WAEnB,SAAS,CAAC,EAAgB,CACxB,KAAK,OAAS,EAGhB,UAAU,EAAG,CACX,OAAO,KAAK,SAAS,OAAO,EAG9B,WAAW,CAAC,EAAc,CACxB,KAAK,SAAW,EAGlB,SAAS,CAAC,EAAc,EAAe,EAA+B,CAAC,EAAG,CACxE,KAAK,QAAQ,IAAI,EAAa,EAAM,EAAO,CAAO,CAAC,EAGrD,YAAY,CAAC,EAAc,CACzB,KAAK,QAAQ,IAAI,EAAa,EAAM,GAAI,CAAE,OAAQ,EAAG,CAAC,CAAC,EAGzD,UAAU,CAAC,EAAc,EAAe,CACtC,KAAK,QAAQ,IAAI,EAAM,CAAK,EAG9B,OAAO,CAAC,EAAW,CACjB,KAAK,KAAO,EAGd,UAAU,CAAC,EAA4B,CACrC,KAAK,IAAM,EAGb,OAAO,EAAG,CACR,OAAO,KAAK,QACZ,OAAO,KAAK,QACZ,KAAK,cAAgB,KACrB,OAAO,KAAK,KAEhB,CAEO,MAAM,CAAe,OACnB,SAAQ,EAAG,CAChB,OAAO,EAAe,SAAS,QAG1B,WAAU,CAAC,EAA4B,CAC5C,EAAe,SAAS,EAAE,IAAM,QAG3B,IAAM,CAAC,EAA0B,EAAgB,CACtD,OAAO,EAAe,IAAI,IAAI,EAAM,CAAW,EAAG,CAAE,QAU/C,QAAU,CAAC,EAAc,EAAgB,CAC9C,OAAO,EAAe,IAAI,EAAO,CAAE,EAEvC",
10
- "debugId": "E7EC0D69CEAAA9D364756E2164756E21",
11
- "names": []
12
- }
@@ -1,9 +0,0 @@
1
- // @bun
2
- import{$c as K,Qc as k,Tc as R,Yc as H,_c as I,ad as S,bd as P,cd as U,dd as W,ed as b,fd as w,ld as j}from"./chunk-x14sk95v.js";import{xe as _,ye as V}from"./chunk-01am9k5v.js";import{AsyncLocalStorage as h}from"async_hooks";var J=new h;function l(){return J.getStore()?.tx}function N(){return J.getStore()?.connection??k}function i(q,z){let B=J.getStore();if(N()===q)return z();return y(q),J.run({...B,depth:B?.depth??0,connection:q===k?void 0:q},z)}function y(q){let z=J.getStore();if(z?.tx===void 0)return;let B=z.connection??k;if(B===q)return;throw new R(B,q)}function s(){let q=J.getStore();return q?.tx===void 0?null:q.depth}function o(){return J.getStore()?.system===!0}function n(q){let z=J.getStore();return J.run({...z,depth:z?.depth??0,system:!0},q)}function t(){return J.getStore()?.actor}function a(q,z){let B=J.getStore();return J.run({...B,depth:B?.depth??0,system:!1,actor:{user:q??null}},z)}function E(q){if(Bun.env.NODE_ENV!=="development")return null;if(q===!1)return null;if(q===void 0)return H;if(!Number.isFinite(q)||q<=0)return H;return q}function T(q){let z=E(q);if(z===null)return()=>{};let B=Error("transaction opened here"),X=setTimeout(()=>{let Z=B.stack?.split(`
3
- `).slice(1).join(`
4
- `)??"";console.warn(`[gemi] A database transaction has not settled after ${z}ms. It `+"reserves a pooled connection until it does \u2014 check for network or "+`filesystem I/O inside the callback, and move it outside the transaction if you find any.
5
- ${Z}
6
- (development only; set database.slowTransactionThreshold to change the threshold, or false to switch this off)`)},z);return X.unref?.(),()=>clearTimeout(X)}function r(q,z,B){let X=J.getStore(),Z=B?.connection??k;if(y(Z),X?.tx)return X.tx.savepoint((Q)=>{let Y=Q;return J.run({...X,tx:Y,depth:X.depth+1},()=>z(Y))});let $=T(B?.slowTransactionThreshold);try{return q.begin((Q)=>J.run({...X,tx:Q,depth:0,connection:Z===k?void 0:Z},()=>z(Q))).finally($)}catch(Q){throw $(),Q}}var x=/^\s*::\s*(?:text\s*::\s*)?(jsonb|json)\b(?!\s*\[)/i,C=/^\s*as\s+(jsonb|json)\s*\)/i,f=/\bcast\s*\(\s*$/i,v=new Set;function L(q,z){if(!z.typesParametersFromStatement)return{fragment:q,jsonParameters:v};let B=P(q),X=new Set,Z;for(let $=0;$<B.length-1;$++){let Q=B[$+1],Y=x.exec(Q);if(Y){Z??=[...B],Z[$+1]=`::text::${Y[1]}${Q.slice(Y[0].length)}`,X.add($);continue}let G=C.exec(Q);if(G&&f.test((Z??B)[$]))Z??=[...B],Z[$+1]=` as text)::${G[1]}${Q.slice(G[0].length)}`,X.add($)}if(!Z)return{fragment:q,jsonParameters:X};return{fragment:U(Z,q.binders),jsonParameters:X}}function F(q,z){if(q===null||q===void 0)return null;let B=j(q);if(B==="db")return null;if(B==="json")return"null";if(B==="any")throw new V(z,"DB",z,"Prisma.AnyNull is a filter operand \u2014 it asks for a SQL NULL *or* a JSON "+"null \u2014 so it has no single value to bind. Write the one you mean: "+"Prisma.DbNull for the column being NULL, Prisma.JsonNull for the JSON value.");if(typeof q==="string")return q;let X;try{X=JSON.stringify(q)}catch(Z){throw new V(z,"DB",z,`A parameter cast to json could not be serialised: ${Z instanceof Error?Z.message:String(Z)}. `+"Bind text you have serialised yourself if the value is not JSON \u2014 a "+"bigint has no JSON form, and neither does a cycle.")}if(X===void 0)throw new V(z,"DB",z,`A ${typeof q} was bound to a parameter cast to json, and has no JSON form. Bind the value it stands for.`);return X}var O=new WeakSet;function M(q){return O.add(q),q}function D(q){return typeof q==="object"&&q!==null&&O.has(q)}function Qq(q,...z){if(!Array.isArray(q)||!("raw"in q))throw new _("sql","DB","sql","'sql' is a tagged template \u2014 write sql`select 1`, not sql(\"select 1\"). "+"To put text that is not a value into a statement, use 'unsafeSql', and read what it says first.");let B=[];for(let X=0;X<q.length;X++)if(B.push(K(q[X])),X<z.length)B.push(A(z[X]));return M(W(...B))}function Vq(q,z=", "){if(!Array.isArray(q))throw new V("join","DB","sql",`Expected an array of fragments or values, got ${typeof q}.`);if(q.length===0)return g;let B=q.map(A);if(D(z)){let X=[];for(let Z=0;Z<B.length;Z++){if(Z>0)X.push(z);X.push(B[Z])}return M(W(...X))}return d(z),M(b(B,z))}var c=/^[\s,]*$|^\s*(?:and|or)\s*$/i;function d(q){if(typeof q==="string"&&c.test(q))return;throw new V("join","DB","sql",typeof q==="string"?`A separator is written into the SQL text, so it may only be glue: whitespace, commas, or 'and' / 'or'. Got ${JSON.stringify(q)}. If that is deliberate, say so with `+"unsafeSql(...) \u2014 and never build one from anything that came from "+"outside the program.":`Expected a separator string or a fragment, got ${q===null?"null":typeof q}.`)}var g=M(Object.freeze({text:"",binders:Object.freeze([])}));function Yq(q){if(typeof q!=="string")throw new V("unsafeSql","DB","sql",`Expected a string literal, got ${Array.isArray(q)?"an array":typeof q}. 'unsafeSql' is a plain call, not a tagged template \u2014 a template would `+"interpolate values into the SQL text, which is the one thing it must never do.");return M(K(q))}function kq(q,z,B="query"){if(!D(q))throw new V(B,"DB",B,`Expected a fragment built with 'sql', got ${q===null?"null":typeof q}. A plain string is not accepted here on purpose \u2014 it would be the one `+"path into the SQL text that nobody had to think about.");let X=L(q,z),Z=w(X.fragment,z,{model:"DB",operation:B});return{text:Z.text,values:I(Z.binders)(void 0).map(($,Q)=>X.jsonParameters.has(Q)?F($,B):$===null||$===void 0?$??null:z.encodeUntyped($))}}function A(q){if(D(q))return q;return S(()=>q)}
7
- export{J as vc,l as wc,N as xc,i as yc,y as zc,s as Ac,o as Bc,n as Cc,t as Dc,a as Ec,r as Fc,Qq as Gc,Vq as Hc,g as Ic,Yq as Jc,kq as Kc};
8
-
9
- //# debugId=BDA2A70D6C00BA3864756E2164756E21