@geekmidas/constructs 10.0.0-alpha.10 → 10.0.0-alpha.100

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 (425) hide show
  1. package/README.md +222 -158
  2. package/dist/{Construct-BD5neF7w.mjs → Construct-B1vGBPme.mjs} +33 -34
  3. package/dist/Construct-B1vGBPme.mjs.map +1 -0
  4. package/dist/Construct-BQALFCh2.d.cts +230 -0
  5. package/dist/Construct-BQALFCh2.d.cts.map +1 -0
  6. package/dist/{Construct-CyS3RpTL.cjs → Construct-DUSXuTHP.cjs} +53 -48
  7. package/dist/Construct-DUSXuTHP.cjs.map +1 -0
  8. package/dist/Construct-QXnl3VqT.d.mts +230 -0
  9. package/dist/Construct-QXnl3VqT.d.mts.map +1 -0
  10. package/dist/{Cron-DmQ8vQ4b.d.cts → Cron-DI3nKoic.d.cts} +15 -9
  11. package/dist/Cron-DI3nKoic.d.cts.map +1 -0
  12. package/dist/{Cron-dh4rUgib.d.mts → Cron-uYAHPnp7.d.mts} +15 -9
  13. package/dist/Cron-uYAHPnp7.d.mts.map +1 -0
  14. package/dist/{CronBuilder-Da0C0edR.cjs → CronBuilder-C0Ek1-RA.cjs} +47 -31
  15. package/dist/CronBuilder-C0Ek1-RA.cjs.map +1 -0
  16. package/dist/CronBuilder-DaSUm2Na.d.mts +47 -0
  17. package/dist/CronBuilder-DaSUm2Na.d.mts.map +1 -0
  18. package/dist/{CronBuilder-CYKT5RiO.mjs → CronBuilder-Dmix_Pen.mjs} +37 -21
  19. package/dist/CronBuilder-Dmix_Pen.mjs.map +1 -0
  20. package/dist/CronBuilder-g1lZLWyG.d.cts +47 -0
  21. package/dist/CronBuilder-g1lZLWyG.d.cts.map +1 -0
  22. package/dist/{Endpoint-DCQPMdUX.mjs → Endpoint-BG4UJ9oA.mjs} +146 -109
  23. package/dist/Endpoint-BG4UJ9oA.mjs.map +1 -0
  24. package/dist/{Endpoint-DcWXE-SZ.cjs → Endpoint-BoUg8ocM.cjs} +174 -131
  25. package/dist/Endpoint-BoUg8ocM.cjs.map +1 -0
  26. package/dist/{Endpoint-BjWKinFA.d.mts → Endpoint-Du-NwPX2.d.mts} +83 -91
  27. package/dist/Endpoint-Du-NwPX2.d.mts.map +1 -0
  28. package/dist/{Endpoint-dav89W6-.d.cts → Endpoint-aCvBMPoH.d.cts} +82 -90
  29. package/dist/Endpoint-aCvBMPoH.d.cts.map +1 -0
  30. package/dist/{EndpointFactory-CjV8F_lJ.mjs → EndpointFactory-BDtsrEvJ.mjs} +57 -76
  31. package/dist/EndpointFactory-BDtsrEvJ.mjs.map +1 -0
  32. package/dist/{EndpointFactory-CdWB7wPw.cjs → EndpointFactory-DJ7gXLpR.cjs} +93 -112
  33. package/dist/EndpointFactory-DJ7gXLpR.cjs.map +1 -0
  34. package/dist/{index-lAO9egTb.d.mts → EndpointFactory-DMYdJCOj.d.mts} +78 -134
  35. package/dist/EndpointFactory-DMYdJCOj.d.mts.map +1 -0
  36. package/dist/{index-Bd5FqCoe.d.cts → EndpointFactory-I7s1co3Y.d.cts} +77 -133
  37. package/dist/EndpointFactory-I7s1co3Y.d.cts.map +1 -0
  38. package/dist/Function-DuqGcbOI.d.mts +76 -0
  39. package/dist/Function-DuqGcbOI.d.mts.map +1 -0
  40. package/dist/Function-Pu-1kKZz.d.cts +76 -0
  41. package/dist/Function-Pu-1kKZz.d.cts.map +1 -0
  42. package/dist/{HonoEndpointAdaptor-P1ahhZHu.mjs → HonoEndpointAdaptor-PtPlbeKY.mjs} +75 -56
  43. package/dist/HonoEndpointAdaptor-PtPlbeKY.mjs.map +1 -0
  44. package/dist/{HonoEndpointAdaptor-DtL9j19R.cjs → HonoEndpointAdaptor-zVzVLJEO.cjs} +83 -61
  45. package/dist/HonoEndpointAdaptor-zVzVLJEO.cjs.map +1 -0
  46. package/dist/Queue-A3wfD0it.cjs +109 -0
  47. package/dist/Queue-A3wfD0it.cjs.map +1 -0
  48. package/dist/Queue-D6USGS4q.mjs +104 -0
  49. package/dist/Queue-D6USGS4q.mjs.map +1 -0
  50. package/dist/{Queue-D7ZuwBhy.d.cts → Queue-DlsHRzUp.d.mts} +48 -48
  51. package/dist/Queue-DlsHRzUp.d.mts.map +1 -0
  52. package/dist/{Queue-gVGfi2Yk.d.mts → Queue-HPyi0e1i.d.cts} +49 -49
  53. package/dist/Queue-HPyi0e1i.d.cts.map +1 -0
  54. package/dist/QueueBuilder-BjuF0UBl.cjs +135 -0
  55. package/dist/QueueBuilder-BjuF0UBl.cjs.map +1 -0
  56. package/dist/QueueBuilder-Cue73M4t.mjs +118 -0
  57. package/dist/QueueBuilder-Cue73M4t.mjs.map +1 -0
  58. package/dist/QueueBuilder-OSi6LkV9.d.cts +75 -0
  59. package/dist/QueueBuilder-OSi6LkV9.d.cts.map +1 -0
  60. package/dist/QueueBuilder-QHsnVt1P.d.mts +75 -0
  61. package/dist/QueueBuilder-QHsnVt1P.d.mts.map +1 -0
  62. package/dist/{Subscriber-2mEi0ImH.d.cts → Subscriber-Bpp02cGr.d.cts} +29 -20
  63. package/dist/Subscriber-Bpp02cGr.d.cts.map +1 -0
  64. package/dist/{Subscriber-xTJ9ayPN.d.mts → Subscriber-CtN9R48-.d.mts} +29 -20
  65. package/dist/Subscriber-CtN9R48-.d.mts.map +1 -0
  66. package/dist/{SubscriberBuilder-BjkbeT9l.mjs → SubscriberBuilder-CDy4nHCz.mjs} +50 -24
  67. package/dist/SubscriberBuilder-CDy4nHCz.mjs.map +1 -0
  68. package/dist/SubscriberBuilder-CuCMFpYW.d.mts +67 -0
  69. package/dist/SubscriberBuilder-CuCMFpYW.d.mts.map +1 -0
  70. package/dist/{SubscriberBuilder-4OPehf2R.cjs → SubscriberBuilder-D_owVoHo.cjs} +61 -36
  71. package/dist/SubscriberBuilder-D_owVoHo.cjs.map +1 -0
  72. package/dist/SubscriberBuilder-g3fAVWgs.d.cts +67 -0
  73. package/dist/SubscriberBuilder-g3fAVWgs.d.cts.map +1 -0
  74. package/dist/Topic-D74b5cgs.mjs +99 -0
  75. package/dist/Topic-D74b5cgs.mjs.map +1 -0
  76. package/dist/Topic-GHxcU8AG.cjs +104 -0
  77. package/dist/Topic-GHxcU8AG.cjs.map +1 -0
  78. package/dist/adaptors/aws.cjs +131 -220
  79. package/dist/adaptors/aws.cjs.map +1 -1
  80. package/dist/adaptors/aws.d.cts +34 -53
  81. package/dist/adaptors/aws.d.cts.map +1 -1
  82. package/dist/adaptors/aws.d.mts +34 -53
  83. package/dist/adaptors/aws.d.mts.map +1 -1
  84. package/dist/adaptors/aws.mjs +102 -193
  85. package/dist/adaptors/aws.mjs.map +1 -1
  86. package/dist/adaptors/hono.cjs +3 -10
  87. package/dist/adaptors/hono.d.cts +7 -16
  88. package/dist/adaptors/hono.d.cts.map +1 -1
  89. package/dist/adaptors/hono.d.mts +8 -17
  90. package/dist/adaptors/hono.d.mts.map +1 -1
  91. package/dist/adaptors/hono.mjs +2 -10
  92. package/dist/adaptors/testing.cjs +743 -89
  93. package/dist/adaptors/testing.cjs.map +1 -1
  94. package/dist/adaptors/testing.d.cts +351 -54
  95. package/dist/adaptors/testing.d.cts.map +1 -1
  96. package/dist/adaptors/testing.d.mts +351 -54
  97. package/dist/adaptors/testing.d.mts.map +1 -1
  98. package/dist/adaptors/testing.mjs +706 -70
  99. package/dist/adaptors/testing.mjs.map +1 -1
  100. package/dist/auth-BMCJN30Y.d.cts +268 -0
  101. package/dist/auth-BMCJN30Y.d.cts.map +1 -0
  102. package/dist/auth-CcuceLYo.d.mts +268 -0
  103. package/dist/auth-CcuceLYo.d.mts.map +1 -0
  104. package/dist/auth.cjs +301 -33
  105. package/dist/auth.cjs.map +1 -1
  106. package/dist/auth.d.cts +2 -108
  107. package/dist/auth.d.mts +2 -108
  108. package/dist/auth.mjs +289 -27
  109. package/dist/auth.mjs.map +1 -1
  110. package/dist/{cache-BrRz3fEB.d.mts → cache-CXh6GIgb.d.mts} +3 -6
  111. package/dist/cache-CXh6GIgb.d.mts.map +1 -0
  112. package/dist/{cache-BtZY_tHe.d.cts → cache-DnGDGly3.d.cts} +3 -6
  113. package/dist/cache-DnGDGly3.d.cts.map +1 -0
  114. package/dist/cache.cjs +68 -2
  115. package/dist/cache.cjs.map +1 -0
  116. package/dist/cache.d.cts +1 -2
  117. package/dist/cache.d.mts +1 -2
  118. package/dist/cache.mjs +67 -2
  119. package/dist/cache.mjs.map +1 -0
  120. package/dist/cipher-C1lEFX63.mjs +225 -0
  121. package/dist/cipher-C1lEFX63.mjs.map +1 -0
  122. package/dist/cipher-CVxfwLjk.cjs +332 -0
  123. package/dist/cipher-CVxfwLjk.cjs.map +1 -0
  124. package/dist/{clone-DblgEZZa.mjs → clone-EKNovYHu.mjs} +3 -3
  125. package/dist/clone-EKNovYHu.mjs.map +1 -0
  126. package/dist/{clone-Dy0cR2SZ.cjs → clone-UGJpvQnL.cjs} +7 -8
  127. package/dist/clone-UGJpvQnL.cjs.map +1 -0
  128. package/dist/{construct-interface-D9d4Gm4p.d.cts → construct-interface-B1AfqRl4.d.cts} +42 -11
  129. package/dist/construct-interface-B1AfqRl4.d.cts.map +1 -0
  130. package/dist/{construct-interface-g5GM5pwR.d.mts → construct-interface-DluK3_da.d.mts} +42 -11
  131. package/dist/construct-interface-DluK3_da.d.mts.map +1 -0
  132. package/dist/construct-interface.cjs +113 -7
  133. package/dist/construct-interface.cjs.map +1 -0
  134. package/dist/construct-interface.d.cts +2 -2
  135. package/dist/construct-interface.d.mts +2 -2
  136. package/dist/construct-interface.mjs +106 -2
  137. package/dist/construct-interface.mjs.map +1 -0
  138. package/dist/credential.cjs +77 -17
  139. package/dist/credential.cjs.map +1 -1
  140. package/dist/credential.d.cts +34 -9
  141. package/dist/credential.d.cts.map +1 -1
  142. package/dist/credential.d.mts +34 -9
  143. package/dist/credential.d.mts.map +1 -1
  144. package/dist/credential.mjs +71 -13
  145. package/dist/credential.mjs.map +1 -1
  146. package/dist/crons/index.cjs +129 -7
  147. package/dist/crons/index.cjs.map +1 -1
  148. package/dist/crons/index.d.cts +45 -11
  149. package/dist/crons/index.d.cts.map +1 -1
  150. package/dist/crons/index.d.mts +45 -11
  151. package/dist/crons/index.d.mts.map +1 -1
  152. package/dist/crons/index.mjs +127 -8
  153. package/dist/crons/index.mjs.map +1 -1
  154. package/dist/database/kysely.cjs +4 -181
  155. package/dist/database/kysely.d.cts +2 -152
  156. package/dist/database/kysely.d.mts +2 -152
  157. package/dist/database/kysely.mjs +2 -180
  158. package/dist/email.cjs +25 -12
  159. package/dist/email.cjs.map +1 -1
  160. package/dist/email.d.cts +3 -7
  161. package/dist/email.d.cts.map +1 -1
  162. package/dist/email.d.mts +3 -7
  163. package/dist/email.d.mts.map +1 -1
  164. package/dist/email.mjs +16 -3
  165. package/dist/email.mjs.map +1 -1
  166. package/dist/encryption.cjs +96 -0
  167. package/dist/encryption.cjs.map +1 -0
  168. package/dist/encryption.d.cts +117 -0
  169. package/dist/encryption.d.cts.map +1 -0
  170. package/dist/encryption.d.mts +117 -0
  171. package/dist/encryption.d.mts.map +1 -0
  172. package/dist/encryption.mjs +83 -0
  173. package/dist/encryption.mjs.map +1 -0
  174. package/dist/endpoints/index.cjs +8 -10
  175. package/dist/endpoints/index.d.cts +51 -7
  176. package/dist/endpoints/index.d.cts.map +1 -0
  177. package/dist/endpoints/index.d.mts +51 -7
  178. package/dist/endpoints/index.d.mts.map +1 -0
  179. package/dist/endpoints/index.mjs +6 -10
  180. package/dist/external-api-MJ8id87V.d.mts +105 -0
  181. package/dist/external-api-MJ8id87V.d.mts.map +1 -0
  182. package/dist/external-api-O107yzZJ.d.cts +105 -0
  183. package/dist/external-api-O107yzZJ.d.cts.map +1 -0
  184. package/dist/external-api.cjs +142 -0
  185. package/dist/external-api.cjs.map +1 -0
  186. package/dist/external-api.d.cts +2 -0
  187. package/dist/external-api.d.mts +2 -0
  188. package/dist/external-api.mjs +139 -0
  189. package/dist/external-api.mjs.map +1 -0
  190. package/dist/file-server.cjs +42 -10
  191. package/dist/file-server.cjs.map +1 -1
  192. package/dist/file-server.d.cts +6 -10
  193. package/dist/file-server.d.cts.map +1 -1
  194. package/dist/file-server.d.mts +6 -10
  195. package/dist/file-server.d.mts.map +1 -1
  196. package/dist/file-server.mjs +34 -2
  197. package/dist/file-server.mjs.map +1 -1
  198. package/dist/functions/index.cjs +3 -6
  199. package/dist/functions/index.d.cts +3 -4
  200. package/dist/functions/index.d.mts +3 -4
  201. package/dist/functions/index.mjs +2 -6
  202. package/dist/{functions-14lpEFL4.mjs → functions-BFizikJU.mjs} +376 -238
  203. package/dist/{functions-14lpEFL4.mjs.map → functions-BFizikJU.mjs.map} +1 -1
  204. package/dist/{functions-i_la-N5r.cjs → functions-CfzJG9hK.cjs} +414 -264
  205. package/dist/functions-CfzJG9hK.cjs.map +1 -0
  206. package/dist/index-BuzRvKOQ.d.cts +115 -0
  207. package/dist/index-BuzRvKOQ.d.cts.map +1 -0
  208. package/dist/index-CTkKOer4.d.mts +115 -0
  209. package/dist/index-CTkKOer4.d.mts.map +1 -0
  210. package/dist/index-CeEtxDmK.d.cts +79 -0
  211. package/dist/index-CeEtxDmK.d.cts.map +1 -0
  212. package/dist/index-CeEtxDmK.d.mts +79 -0
  213. package/dist/index-CeEtxDmK.d.mts.map +1 -0
  214. package/dist/index.cjs +6 -3
  215. package/dist/index.d.cts +27 -4
  216. package/dist/index.d.cts.map +1 -0
  217. package/dist/index.d.mts +27 -4
  218. package/dist/index.d.mts.map +1 -0
  219. package/dist/index.mjs +3 -3
  220. package/dist/kms-B-Hm3d5r.cjs +85 -0
  221. package/dist/kms-B-Hm3d5r.cjs.map +1 -0
  222. package/dist/kms-BdUlMJEZ.mjs +85 -0
  223. package/dist/kms-BdUlMJEZ.mjs.map +1 -0
  224. package/dist/kysely-Bii4l6eP.mjs +370 -0
  225. package/dist/kysely-Bii4l6eP.mjs.map +1 -0
  226. package/dist/kysely-CO_Dk43W.cjs +383 -0
  227. package/dist/kysely-CO_Dk43W.cjs.map +1 -0
  228. package/dist/kysely-D0bpzgPs.d.cts +175 -0
  229. package/dist/kysely-D0bpzgPs.d.cts.map +1 -0
  230. package/dist/kysely-DUqC3Ie0.d.mts +175 -0
  231. package/dist/kysely-DUqC3Ie0.d.mts.map +1 -0
  232. package/dist/{telemetry-C3L0iS28.d.cts → lambdaTelemetry-8vnmVZQ5.d.cts} +3 -6
  233. package/dist/lambdaTelemetry-8vnmVZQ5.d.cts.map +1 -0
  234. package/dist/{telemetry-D7bVFLGi.d.mts → lambdaTelemetry-8vnmVZQ5.d.mts} +3 -6
  235. package/dist/lambdaTelemetry-8vnmVZQ5.d.mts.map +1 -0
  236. package/dist/{lazyAccessors-BoJN3SMd.mjs → lazyAccessors-CFanua0O.mjs} +20 -60
  237. package/dist/lazyAccessors-CFanua0O.mjs.map +1 -0
  238. package/dist/{lazyAccessors-e3j2oE2m.cjs → lazyAccessors-hJKGv8Ay.cjs} +60 -113
  239. package/dist/lazyAccessors-hJKGv8Ay.cjs.map +1 -0
  240. package/dist/mobile-app.cjs +73 -0
  241. package/dist/mobile-app.cjs.map +1 -0
  242. package/dist/mobile-app.d.cts +61 -0
  243. package/dist/mobile-app.d.cts.map +1 -0
  244. package/dist/mobile-app.d.mts +61 -0
  245. package/dist/mobile-app.d.mts.map +1 -0
  246. package/dist/mobile-app.mjs +72 -0
  247. package/dist/mobile-app.mjs.map +1 -0
  248. package/dist/object-storage.cjs +18 -10
  249. package/dist/object-storage.cjs.map +1 -1
  250. package/dist/object-storage.d.cts +3 -7
  251. package/dist/object-storage.d.cts.map +1 -1
  252. package/dist/object-storage.d.mts +3 -7
  253. package/dist/object-storage.d.mts.map +1 -1
  254. package/dist/object-storage.mjs +11 -3
  255. package/dist/object-storage.mjs.map +1 -1
  256. package/dist/processAudits-BRRVVHUB.mjs +131 -0
  257. package/dist/processAudits-BRRVVHUB.mjs.map +1 -0
  258. package/dist/processAudits-DasOZjPl.cjs +154 -0
  259. package/dist/processAudits-DasOZjPl.cjs.map +1 -0
  260. package/dist/queue/index.cjs +6 -189
  261. package/dist/queue/index.d.cts +3 -60
  262. package/dist/queue/index.d.mts +3 -60
  263. package/dist/queue/index.mjs +3 -186
  264. package/dist/rest-api.cjs +90 -59
  265. package/dist/rest-api.cjs.map +1 -1
  266. package/dist/rest-api.d.cts +70 -42
  267. package/dist/rest-api.d.cts.map +1 -1
  268. package/dist/rest-api.d.mts +70 -42
  269. package/dist/rest-api.d.mts.map +1 -1
  270. package/dist/rest-api.mjs +82 -51
  271. package/dist/rest-api.mjs.map +1 -1
  272. package/dist/{chunk-DWy1uDak.cjs → rolldown-runtime-y5ARvAq5.cjs} +14 -18
  273. package/dist/runSubscriber-BHvJ8POr.mjs +109 -0
  274. package/dist/runSubscriber-BHvJ8POr.mjs.map +1 -0
  275. package/dist/runSubscriber-D8nLXIv1.cjs +126 -0
  276. package/dist/runSubscriber-D8nLXIv1.cjs.map +1 -0
  277. package/dist/shutdown-BMJmAhSt.cjs +38 -0
  278. package/dist/shutdown-BMJmAhSt.cjs.map +1 -0
  279. package/dist/shutdown-C7xa8x9S.mjs +27 -0
  280. package/dist/shutdown-C7xa8x9S.mjs.map +1 -0
  281. package/dist/site.cjs +33 -7
  282. package/dist/site.cjs.map +1 -1
  283. package/dist/site.d.cts +17 -7
  284. package/dist/site.d.cts.map +1 -1
  285. package/dist/site.d.mts +17 -7
  286. package/dist/site.d.mts.map +1 -1
  287. package/dist/site.mjs +29 -3
  288. package/dist/site.mjs.map +1 -1
  289. package/dist/stages-BSCF19o2.d.cts +56 -0
  290. package/dist/stages-BSCF19o2.d.cts.map +1 -0
  291. package/dist/stages-BSCF19o2.d.mts +56 -0
  292. package/dist/stages-BSCF19o2.d.mts.map +1 -0
  293. package/dist/subscribers/index.cjs +118 -6
  294. package/dist/subscribers/index.cjs.map +1 -0
  295. package/dist/subscribers/index.d.cts +51 -6
  296. package/dist/subscribers/index.d.cts.map +1 -0
  297. package/dist/subscribers/index.d.mts +51 -6
  298. package/dist/subscribers/index.d.mts.map +1 -0
  299. package/dist/subscribers/index.mjs +115 -5
  300. package/dist/subscribers/index.mjs.map +1 -0
  301. package/dist/surfaceEnv-CNimK76p.cjs +56 -0
  302. package/dist/surfaceEnv-CNimK76p.cjs.map +1 -0
  303. package/dist/surfaceEnv-wMT5QzgZ.mjs +45 -0
  304. package/dist/surfaceEnv-wMT5QzgZ.mjs.map +1 -0
  305. package/dist/telemetry-B48RLjyk.d.cts +40 -0
  306. package/dist/telemetry-B48RLjyk.d.cts.map +1 -0
  307. package/dist/telemetry-DRtT1_0A.d.mts +40 -0
  308. package/dist/telemetry-DRtT1_0A.d.mts.map +1 -0
  309. package/dist/telemetry.cjs +56 -0
  310. package/dist/telemetry.cjs.map +1 -0
  311. package/dist/telemetry.d.cts +2 -0
  312. package/dist/telemetry.d.mts +2 -0
  313. package/dist/telemetry.mjs +55 -0
  314. package/dist/telemetry.mjs.map +1 -0
  315. package/dist/topic/index.cjs +3 -137
  316. package/dist/topic/index.d.cts +2 -4
  317. package/dist/topic/index.d.mts +2 -4
  318. package/dist/topic/index.mjs +2 -134
  319. package/dist/tracing-CxaZ98IB.mjs +110 -0
  320. package/dist/tracing-CxaZ98IB.mjs.map +1 -0
  321. package/dist/tracing-DPMidF_r.cjs +127 -0
  322. package/dist/tracing-DPMidF_r.cjs.map +1 -0
  323. package/dist/{types-BlAkSuGI.d.cts → types-DMuSQeLL.d.cts} +3 -5
  324. package/dist/types-DMuSQeLL.d.cts.map +1 -0
  325. package/dist/{types-aKksMEWL.d.mts → types-DMuSQeLL.d.mts} +3 -5
  326. package/dist/types-DMuSQeLL.d.mts.map +1 -0
  327. package/dist/types.d.cts +1 -1
  328. package/dist/types.d.mts +1 -1
  329. package/dist/types.mjs +1 -0
  330. package/dist/worker.cjs +59 -34
  331. package/dist/worker.cjs.map +1 -1
  332. package/dist/worker.d.cts +70 -45
  333. package/dist/worker.d.cts.map +1 -1
  334. package/dist/worker.d.mts +70 -44
  335. package/dist/worker.d.mts.map +1 -1
  336. package/dist/worker.mjs +54 -29
  337. package/dist/worker.mjs.map +1 -1
  338. package/package.json +96 -42
  339. package/dist/Construct-BD5neF7w.mjs.map +0 -1
  340. package/dist/Construct-C0ijr2qp.d.cts +0 -117
  341. package/dist/Construct-C0ijr2qp.d.cts.map +0 -1
  342. package/dist/Construct-Ct8nalEi.d.mts +0 -117
  343. package/dist/Construct-Ct8nalEi.d.mts.map +0 -1
  344. package/dist/Construct-CyS3RpTL.cjs.map +0 -1
  345. package/dist/Cron-DmQ8vQ4b.d.cts.map +0 -1
  346. package/dist/Cron-dh4rUgib.d.mts.map +0 -1
  347. package/dist/CronBuilder-BquXDbDI.d.cts +0 -44
  348. package/dist/CronBuilder-BquXDbDI.d.cts.map +0 -1
  349. package/dist/CronBuilder-CGgY2080.d.mts +0 -44
  350. package/dist/CronBuilder-CGgY2080.d.mts.map +0 -1
  351. package/dist/CronBuilder-CYKT5RiO.mjs.map +0 -1
  352. package/dist/CronBuilder-Da0C0edR.cjs.map +0 -1
  353. package/dist/Endpoint-BjWKinFA.d.mts.map +0 -1
  354. package/dist/Endpoint-DCQPMdUX.mjs.map +0 -1
  355. package/dist/Endpoint-DcWXE-SZ.cjs.map +0 -1
  356. package/dist/Endpoint-dav89W6-.d.cts.map +0 -1
  357. package/dist/EndpointFactory-CdWB7wPw.cjs.map +0 -1
  358. package/dist/EndpointFactory-CjV8F_lJ.mjs.map +0 -1
  359. package/dist/HonoEndpointAdaptor-DtL9j19R.cjs.map +0 -1
  360. package/dist/HonoEndpointAdaptor-P1ahhZHu.mjs.map +0 -1
  361. package/dist/Queue-D7ZuwBhy.d.cts.map +0 -1
  362. package/dist/Queue-gVGfi2Yk.d.mts.map +0 -1
  363. package/dist/Subscriber-2mEi0ImH.d.cts.map +0 -1
  364. package/dist/Subscriber-xTJ9ayPN.d.mts.map +0 -1
  365. package/dist/SubscriberBuilder-4OPehf2R.cjs.map +0 -1
  366. package/dist/SubscriberBuilder-BjkbeT9l.mjs.map +0 -1
  367. package/dist/SubscriberBuilder-Dptmo-1A.d.mts +0 -62
  368. package/dist/SubscriberBuilder-Dptmo-1A.d.mts.map +0 -1
  369. package/dist/SubscriberBuilder-waNhzjSM.d.cts +0 -62
  370. package/dist/SubscriberBuilder-waNhzjSM.d.cts.map +0 -1
  371. package/dist/Topic-19QeHBIR.d.cts +0 -91
  372. package/dist/Topic-19QeHBIR.d.cts.map +0 -1
  373. package/dist/Topic-DuFeqkBh.d.mts +0 -91
  374. package/dist/Topic-DuFeqkBh.d.mts.map +0 -1
  375. package/dist/auth.d.cts.map +0 -1
  376. package/dist/auth.d.mts.map +0 -1
  377. package/dist/cache-0ANvRQnD.mjs +0 -51
  378. package/dist/cache-0ANvRQnD.mjs.map +0 -1
  379. package/dist/cache-3WSvAulx.cjs +0 -57
  380. package/dist/cache-3WSvAulx.cjs.map +0 -1
  381. package/dist/cache-BrRz3fEB.d.mts.map +0 -1
  382. package/dist/cache-BtZY_tHe.d.cts.map +0 -1
  383. package/dist/clone-DblgEZZa.mjs.map +0 -1
  384. package/dist/clone-Dy0cR2SZ.cjs.map +0 -1
  385. package/dist/construct-interface-BfjcOD_E.cjs +0 -117
  386. package/dist/construct-interface-BfjcOD_E.cjs.map +0 -1
  387. package/dist/construct-interface-D9d4Gm4p.d.cts.map +0 -1
  388. package/dist/construct-interface-Z4CpS8tK.mjs +0 -81
  389. package/dist/construct-interface-Z4CpS8tK.mjs.map +0 -1
  390. package/dist/construct-interface-g5GM5pwR.d.mts.map +0 -1
  391. package/dist/database/kysely.cjs.map +0 -1
  392. package/dist/database/kysely.d.cts.map +0 -1
  393. package/dist/database/kysely.d.mts.map +0 -1
  394. package/dist/database/kysely.mjs.map +0 -1
  395. package/dist/functions-i_la-N5r.cjs.map +0 -1
  396. package/dist/index-Bd5FqCoe.d.cts.map +0 -1
  397. package/dist/index-BknhM6Ux.d.mts +0 -31
  398. package/dist/index-BknhM6Ux.d.mts.map +0 -1
  399. package/dist/index-CBSfrowv.d.cts +0 -31
  400. package/dist/index-CBSfrowv.d.cts.map +0 -1
  401. package/dist/index-D24Xm79M.d.cts +0 -171
  402. package/dist/index-D24Xm79M.d.cts.map +0 -1
  403. package/dist/index-_ajboYxK.d.mts +0 -171
  404. package/dist/index-_ajboYxK.d.mts.map +0 -1
  405. package/dist/index-lAO9egTb.d.mts.map +0 -1
  406. package/dist/lazyAccessors-BoJN3SMd.mjs.map +0 -1
  407. package/dist/lazyAccessors-e3j2oE2m.cjs.map +0 -1
  408. package/dist/processAudits-CGqttuXm.cjs +0 -92
  409. package/dist/processAudits-CGqttuXm.cjs.map +0 -1
  410. package/dist/processAudits-Dmts9H_b.mjs +0 -80
  411. package/dist/processAudits-Dmts9H_b.mjs.map +0 -1
  412. package/dist/queue/index.cjs.map +0 -1
  413. package/dist/queue/index.d.cts.map +0 -1
  414. package/dist/queue/index.d.mts.map +0 -1
  415. package/dist/queue/index.mjs.map +0 -1
  416. package/dist/surfaceEnv-BFXEms2f.cjs +0 -39
  417. package/dist/surfaceEnv-BFXEms2f.cjs.map +0 -1
  418. package/dist/surfaceEnv-C3Ktahea.mjs +0 -27
  419. package/dist/surfaceEnv-C3Ktahea.mjs.map +0 -1
  420. package/dist/telemetry-C3L0iS28.d.cts.map +0 -1
  421. package/dist/telemetry-D7bVFLGi.d.mts.map +0 -1
  422. package/dist/topic/index.cjs.map +0 -1
  423. package/dist/topic/index.mjs.map +0 -1
  424. package/dist/types-BlAkSuGI.d.cts.map +0 -1
  425. package/dist/types-aKksMEWL.d.mts.map +0 -1
@@ -1,13 +1,12 @@
1
- import { Construct } from "./Construct-Ct8nalEi.mjs";
2
- import { Declaration } from "@geekmidas/manifest";
3
- import { Service, ServiceRecord } from "@geekmidas/services";
4
- import { EventPublisher, PublishableMessage } from "@geekmidas/events";
1
+ import { t as StandardSchemaV1 } from "./index-CeEtxDmK.cjs";
2
+ import { t as Construct } from "./Construct-BQALFCh2.cjs";
3
+ import { t as DatabaseContext } from "./Function-Pu-1kKZz.cjs";
5
4
  import { Logger } from "@geekmidas/logger";
6
5
  import { InferStandardSchema } from "@geekmidas/schema";
7
- import { StandardSchemaV1 } from "@standard-schema/spec";
8
-
6
+ import { Service, ServiceRecord } from "@geekmidas/services";
7
+ import { EventPublisher, PublishableMessage } from "@geekmidas/events";
8
+ import { Declaration } from "@geekmidas/manifest";
9
9
  //#region src/queue/Queue.d.ts
10
-
11
10
  /**
12
11
  * The wire message a queue carries: `{ type: <queue name>, payload: <message> }`.
13
12
  * The producer publishes this shape and the worker receives the `payload`s as
@@ -18,15 +17,19 @@ type QueueMessage<TName extends string, TMessage extends StandardSchemaV1> = Pub
18
17
  /**
19
18
  * A queue worker — a point-to-point SQS-style queue and its single consumer.
20
19
  * Unlike a `Subscriber` (topic fan-out, filtered by `subscribedEvents`), a queue
21
- * drains every message of its one `message` type. Build one with `q` (see
22
- * `QueueBuilder`); `gkm build` discovers it into the manifest's `queues` field.
20
+ * drains every message of its one `message` type. Build one from the worker
21
+ * that runs it — `worker.queue('Emails').message(schema).handle(…)` — and
22
+ * `gkm build` discovers it into the manifest's `queues` field.
23
23
  *
24
- * The producer side is {@link Queue.publisher} — a ready-to-inject `Service`
25
- * that any endpoint/function drops into `.services([...])` to send messages.
24
+ * Producers send to it by depending on it: `.dependsOn([emails])` makes
25
+ * `services.emails` the publisher.
26
+ *
27
+ * Its handler gets `db` when it has a database: the worker's, declared once
28
+ * with `worker.database(db)`, or its own with `.database(other)`.
26
29
  */
27
- declare class Queue<TName extends string = string, TMessage extends StandardSchemaV1 = StandardSchemaV1, TServices extends Service[] = [], TLogger extends Logger = Logger> extends Construct<TLogger, string, undefined, undefined, TServices> {
30
+ declare class Queue<TName extends string = string, TMessage extends StandardSchemaV1 = StandardSchemaV1, TServices extends Service[] = [], TLogger extends Logger = Logger, TDatabase = undefined, TDatabaseServiceName extends string = string> extends Construct<TLogger, undefined, TServices, string, undefined, TDatabaseServiceName, TDatabase> {
28
31
  readonly name: TName;
29
- readonly handler: QueueHandler<TMessage, TServices, TLogger>;
32
+ readonly handler: QueueHandler<TMessage, TServices, TLogger, TDatabase>;
30
33
  readonly messageSchema: TMessage;
31
34
  readonly timeout: number;
32
35
  readonly services: TServices;
@@ -36,7 +39,7 @@ declare class Queue<TName extends string = string, TMessage extends StandardSche
36
39
  /** Whether the queue is FIFO (deployed). */
37
40
  readonly fifo?: boolean | undefined;
38
41
  __IS_QUEUE__: boolean;
39
- static isQueue(obj: unknown): obj is Queue<string, StandardSchemaV1, Service[], Logger>;
42
+ static isQueue(obj: unknown): obj is Queue<string, StandardSchemaV1, Service[], Logger, any>;
40
43
  /**
41
44
  * The canonical id this queue is declared under.
42
45
  *
@@ -47,19 +50,36 @@ declare class Queue<TName extends string = string, TMessage extends StandardSche
47
50
  */
48
51
  readonly id: string;
49
52
  /**
50
- * The producer's env key. Read by both {@link declare} and
51
- * {@link publisher}, so what the target publishes and what the producer
52
- * looks up cannot drift.
53
+ * The queue as a dependency — what `.dependsOn([emails])` dissolves into,
54
+ * reachable as `services.emails`.
55
+ *
56
+ * The producer: the queue's one consumer is the handler it was built with,
57
+ * so the only thing another construct can want from a queue is to send to
58
+ * it. It reads `<NAME>_PUBLISHER_CONNECTION_STRING` and picks the transport
59
+ * from its protocol — `pgboss://` locally, `sqs://` deployed. A field
60
+ * assigned once, not a getter: services are cached by object identity.
61
+ */
62
+ readonly service: Service<Uncapitalize<TName>, EventPublisher<QueueMessage<TName, TMessage>>>;
63
+ /**
64
+ * The producer's env key. Read by both {@link declare} and the service, so
65
+ * what the target publishes and what the producer looks up cannot drift.
53
66
  */
54
67
  private readonly connectionKey;
55
- constructor(name: TName, handler: QueueHandler<TMessage, TServices, TLogger>, messageSchema: TMessage, timeout?: number, services?: TServices, logger?: TLogger, /** SQS event-source batch size (deployed). */
56
- batchSize?: number | undefined, /** Whether the queue is FIFO (deployed). */
68
+ constructor(name: TName, handler: QueueHandler<TMessage, TServices, TLogger, TDatabase>, messageSchema: TMessage, timeout?: number, services?: TServices, logger?: TLogger,
69
+ /** SQS event-source batch size (deployed). */
70
+ batchSize?: number | undefined,
71
+ /** Whether the queue is FIFO (deployed). */
57
72
  fifo?: boolean | undefined,
58
73
  /**
59
74
  * The construct ids the *worker* `.dependsOn()` named — last, so no
60
75
  * existing positional argument moves.
61
76
  */
62
- constructs?: string[]);
77
+ constructs?: string[],
78
+ /**
79
+ * What the handler's `db` is registered from — after `constructs`, for
80
+ * the same reason.
81
+ */
82
+ databaseService?: Service<TDatabaseServiceName, TDatabase>);
63
83
  /**
64
84
  * What this queue is in the manifest.
65
85
  *
@@ -69,37 +89,17 @@ declare class Queue<TName extends string = string, TMessage extends StandardSche
69
89
  * running and what connection string to inject.
70
90
  */
71
91
  declare(): Declaration[];
72
- /**
73
- * The producer side — a `Service` exposing an `EventPublisher` typed to this
74
- * queue's message. Inject it via `.services([queue.publisher])`; the handler
75
- * then calls `services.<name>Publisher.publish([{ type, payload }])`.
76
- *
77
- * It reads `<NAME>_PUBLISHER_CONNECTION_STRING` and builds the transport from
78
- * the URL protocol — `pgboss://` locally, `sqs://` deployed — so the same
79
- * code publishes to Postgres in dev and SQS in prod. Because it's a `Service`,
80
- * `Construct.getEnvironment()` sniffs it, so the env requirement flows into
81
- * the manifest and infra links exactly this queue with least privilege.
82
- */
83
- /**
84
- * The queue as a dependency — what `.dependsOn([emailsQueue])` dissolves
85
- * into, reachable as `services.emails`.
86
- *
87
- * It is the producer: a consumer is the worker written right here, so the
88
- * only thing another construct can want from a queue is the ability to send
89
- * to it. {@link publisher} is the same service under its older
90
- * `<name>Publisher` key, kept for `.services([queue.publisher])`.
91
- */
92
- get service(): Service<Uncapitalize<TName>, EventPublisher<QueueMessage<TName, TMessage>>>;
93
- get publisher(): Service<`${TName}Publisher`, EventPublisher<QueueMessage<TName, TMessage>>>;
94
92
  }
95
- /** The context a queue handler receives — a batch of typed messages. */
96
- type QueueContext<TMessage extends StandardSchemaV1, TServices extends Service[] = [], TLogger extends Logger = Logger> = {
93
+ /**
94
+ * The context a queue handler receives — a batch of typed messages, and `db`
95
+ * when the queue has a database.
96
+ */
97
+ type QueueContext<TMessage extends StandardSchemaV1, TServices extends Service[] = [], TLogger extends Logger = Logger, TDatabase = undefined> = {
97
98
  messages: InferStandardSchema<TMessage>[];
98
99
  services: ServiceRecord<TServices>;
99
100
  logger: TLogger;
100
- };
101
- type QueueHandler<TMessage extends StandardSchemaV1, TServices extends Service[] = [], TLogger extends Logger = Logger> = (ctx: QueueContext<TMessage, TServices, TLogger>) => unknown | Promise<unknown>;
102
- //# sourceMappingURL=Queue.d.ts.map
101
+ } & DatabaseContext<TDatabase>;
102
+ type QueueHandler<TMessage extends StandardSchemaV1, TServices extends Service[] = [], TLogger extends Logger = Logger, TDatabase = undefined> = (ctx: QueueContext<TMessage, TServices, TLogger, TDatabase>) => unknown | Promise<unknown>;
103
103
  //#endregion
104
- export { Queue, QueueContext, QueueHandler, QueueMessage };
105
- //# sourceMappingURL=Queue-gVGfi2Yk.d.mts.map
104
+ export { QueueMessage as i, QueueContext as n, QueueHandler as r, Queue as t };
105
+ //# sourceMappingURL=Queue-HPyi0e1i.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Queue-HPyi0e1i.d.cts","names":[],"sources":["../src/queue/Queue.ts"],"mappings":";;;;;;;;;;;;;;;KA0BY,aACX,sBACA,iBAAiB,oBACd,mBAAmB,OAAO,oBAAoB;;;;;;;;;;;;;;cAerC,MACZ,+BACA,iBAAiB,mBAAmB,kBACpC,kBAAkB,gBAClB,gBAAgB,SAAS,QACzB,uBACA,sDACS,UACT,oBAEA,8BAGA,sBACA;WA8CiB,MAAM;WACN,SAAS,aACxB,UACA,WACA,SACA;WAEe,eAAe;WACN;WACA,UAAU;WACV,QAAQ;;WAEjB;;WAEA;EA1DjB;SAEO,QACN,eACE,OAAO,cAAc,kBAAkB,WAAW;;;;;;;;;WAgB5C;;;;;;;;;;;WAYA,SAAS,QACjB,aAAa,QACb,eAAe,aAAa,OAAO;;;;;mBAOnB;EAEjB,YACiB,MAAM,OACN,SAAS,aACxB,UACA,WACA,SACA,YAEe,eAAe,UACN,kBACA,WAAU,WACV,SAAQ,SAEjB;;EAAA,gCAEA;;EAAA,4BAKhB;;;;;EAAA,uBAKA;;;;;EAAA,kBAAkB,QAAQ,sBAAsB;;;;;;;;;EAyCjD,WAAW;;;;;;KA8BA,aACX,iBAAiB,kBACjB,kBAAkB,gBAClB,gBAAgB,SAAS,QACzB;EAEA,UAAU,oBAAoB;EAC9B,UAAU,cAAc;EACxB,QAAQ;IACL,gBAAgB;KAER,aACX,iBAAiB,kBACjB,kBAAkB,gBAClB,gBAAgB,SAAS,QACzB,0BAEA,KAAK,aAAa,UAAU,WAAW,SAAS,yBAClC"}
@@ -0,0 +1,135 @@
1
+ const require_construct_interface = require("./construct-interface.cjs");
2
+ const require_clone = require("./clone-UGJpvQnL.cjs");
3
+ const require_Queue = require("./Queue-A3wfD0it.cjs");
4
+ let _geekmidas_logger_console = require("@geekmidas/logger/console");
5
+ //#region src/queue/QueueBuilder.ts
6
+ /**
7
+ * Builds a {@link Queue} and its one consumer. Reached through
8
+ * `worker.queue('orders')`, never constructed by hand: the worker stamps itself
9
+ * as the owner. `message` is the typed job payload and `handle` the consumer.
10
+ * The queue name is captured as a literal so `queue.service` publishes
11
+ * `{ type: '<name>', payload }`. The handler's `db` is the worker's database
12
+ * unless `.database(other)` names another.
13
+ */
14
+ var QueueBuilder = class {
15
+ _name;
16
+ _messageSchema;
17
+ _timeout = 3e4;
18
+ _batchSize;
19
+ _fifo;
20
+ _services = [];
21
+ /** The construct ids `.dependsOn()` named — what the manifest records. */
22
+ _constructs = [];
23
+ _logger = _geekmidas_logger_console.DEFAULT_LOGGER;
24
+ /** The worker that runs this queue's consumer — stamped by `worker.queue()`. */
25
+ _owner;
26
+ /** What the handler's `db` comes from — the worker's, unless overridden. */
27
+ _databaseService;
28
+ /** The edge `.database()` added, so the next one can replace it. */
29
+ _databaseEdge;
30
+ /** The queue name — drives the infra queue and its `<NAME>_*` env vars. */
31
+ queue(name) {
32
+ return require_clone.cloneWith(this, { _name: name });
33
+ }
34
+ timeout(timeout) {
35
+ return require_clone.cloneWith(this, { _timeout: timeout });
36
+ }
37
+ /** SQS event-source batch size (deployed). */
38
+ batchSize(batchSize) {
39
+ return require_clone.cloneWith(this, { _batchSize: batchSize });
40
+ }
41
+ /** Mark the queue as FIFO (deployed). */
42
+ fifo(fifo = true) {
43
+ return require_clone.cloneWith(this, { _fifo: fifo });
44
+ }
45
+ /**
46
+ * Depend on constructs — a database, a bucket, a mail sender, a queue, a
47
+ * topic.
48
+ *
49
+ * It records the edge and dissolves each construct's client into the
50
+ * handler's service record under the construct's own id, so
51
+ * `.dependsOn([uploads])` is what makes `services.uploads` exist and type.
52
+ *
53
+ * Constructs only. A `Service` does not match the shape, which is what keeps
54
+ * env sniffing confined to `.services()` and the explicit lift.
55
+ */
56
+ dependsOn(constructs) {
57
+ const services = require_construct_interface.servicesOf(constructs);
58
+ return require_clone.cloneWith(this, {
59
+ _services: [...this._services, ...services],
60
+ _constructs: require_construct_interface.idsOf(constructs, this._constructs)
61
+ });
62
+ }
63
+ services(services) {
64
+ return require_clone.cloneWith(this, { _services: [...this._services, ...services] });
65
+ }
66
+ logger(logger) {
67
+ return require_clone.cloneWith(this, { _logger: logger });
68
+ }
69
+ /**
70
+ * The database the handler receives as `db`.
71
+ *
72
+ * A queue built from a worker already has the worker's, when the worker
73
+ * named one with `.database(db)`; this replaces it — the edge as well as
74
+ * the client — for a consumer that works against a different database.
75
+ */
76
+ database(source) {
77
+ return require_clone.cloneWith(this, {
78
+ _databaseService: require_construct_interface.serviceOf(source),
79
+ ...require_construct_interface.databaseEdges({
80
+ constructs: this._constructs,
81
+ edge: this._databaseEdge,
82
+ service: this._databaseService,
83
+ services: this._services
84
+ }, source)
85
+ });
86
+ }
87
+ /** The typed message (job) payload the queue carries. */
88
+ message(schema) {
89
+ return require_clone.cloneWith(this, { _messageSchema: schema });
90
+ }
91
+ handle(fn) {
92
+ if (!this._name) throw new QueueNeedsName();
93
+ if (!this._messageSchema) throw new QueueNeedsMessage(this._name);
94
+ const queue = new require_Queue.Queue(this._name, fn, this._messageSchema, this._timeout, this._services, this._logger, this._batchSize, this._fifo, this._constructs, this._databaseService);
95
+ queue.owner = this._owner;
96
+ return queue;
97
+ }
98
+ };
99
+ /** A queue built without a name — only reachable by building one by hand. */
100
+ var QueueNeedsName = class extends Error {
101
+ constructor() {
102
+ super("A queue needs a name: build it from a worker, worker.queue('Emails').");
103
+ this.name = "QueueNeedsName";
104
+ }
105
+ };
106
+ /** A queue whose message was never described. */
107
+ var QueueNeedsMessage = class extends Error {
108
+ queue;
109
+ constructor(queue) {
110
+ super(`Queue '${queue}' has no message: call .message(schema) before .handle(), so its producers and its consumer agree on what it carries.`);
111
+ this.queue = queue;
112
+ this.name = "QueueNeedsMessage";
113
+ }
114
+ };
115
+ //#endregion
116
+ Object.defineProperty(exports, "QueueBuilder", {
117
+ enumerable: true,
118
+ get: function() {
119
+ return QueueBuilder;
120
+ }
121
+ });
122
+ Object.defineProperty(exports, "QueueNeedsMessage", {
123
+ enumerable: true,
124
+ get: function() {
125
+ return QueueNeedsMessage;
126
+ }
127
+ });
128
+ Object.defineProperty(exports, "QueueNeedsName", {
129
+ enumerable: true,
130
+ get: function() {
131
+ return QueueNeedsName;
132
+ }
133
+ });
134
+
135
+ //# sourceMappingURL=QueueBuilder-BjuF0UBl.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QueueBuilder-BjuF0UBl.cjs","names":["DEFAULT_LOGGER","cloneWith","servicesOf","idsOf","serviceOf","databaseEdges","Queue"],"sources":["../src/queue/QueueBuilder.ts"],"sourcesContent":["import type { Logger } from '@geekmidas/logger';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { cloneWith } from '../clone';\nimport {\n\ttype Consumable,\n\tdatabaseEdges,\n\tidsOf,\n\ttype ServicesOf,\n\tserviceOf,\n\tservicesOf,\n} from '../construct-interface';\nimport { Queue, type QueueHandler } from './Queue';\n\n/**\n * Builds a {@link Queue} and its one consumer. Reached through\n * `worker.queue('orders')`, never constructed by hand: the worker stamps itself\n * as the owner. `message` is the typed job payload and `handle` the consumer.\n * The queue name is captured as a literal so `queue.service` publishes\n * `{ type: '<name>', payload }`. The handler's `db` is the worker's database\n * unless `.database(other)` names another.\n */\nexport class QueueBuilder<\n\tTName extends string = string,\n\tTMessage extends StandardSchemaV1 | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tTDatabase = undefined,\n\tTDatabaseServiceName extends string = string,\n> {\n\tprivate _name?: string;\n\tprivate _messageSchema?: TMessage;\n\tprivate _timeout = 30000;\n\tprivate _batchSize?: number;\n\tprivate _fifo?: boolean;\n\tprivate _services: TServices = [] as Service[] as TServices;\n\t/** The construct ids `.dependsOn()` named — what the manifest records. */\n\tpublic _constructs: string[] = [];\n\tprivate _logger: TLogger = DEFAULT_LOGGER as TLogger;\n\t/** The worker that runs this queue's consumer — stamped by `worker.queue()`. */\n\tpublic _owner?: string;\n\t/** What the handler's `db` comes from — the worker's, unless overridden. */\n\tprivate _databaseService?: Service<TDatabaseServiceName, TDatabase>;\n\t/** The edge `.database()` added, so the next one can replace it. */\n\tprivate _databaseEdge?: string;\n\n\t/** The queue name — drives the infra queue and its `<NAME>_*` env vars. */\n\tqueue<T extends string>(\n\t\tname: T,\n\t): QueueBuilder<\n\t\tT,\n\t\tTMessage,\n\t\tTServices,\n\t\tTLogger,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, { _name: name }) as unknown as QueueBuilder<\n\t\t\tT,\n\t\t\tTMessage,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\ttimeout(timeout: number): this {\n\t\treturn cloneWith(this, { _timeout: timeout });\n\t}\n\n\t/** SQS event-source batch size (deployed). */\n\tbatchSize(batchSize: number): this {\n\t\treturn cloneWith(this, { _batchSize: batchSize });\n\t}\n\n\t/** Mark the queue as FIFO (deployed). */\n\tfifo(fifo = true): this {\n\t\treturn cloneWith(this, { _fifo: fifo });\n\t}\n\n\t/**\n\t * Depend on constructs — a database, a bucket, a mail sender, a queue, a\n\t * topic.\n\t *\n\t * It records the edge and dissolves each construct's client into the\n\t * handler's service record under the construct's own id, so\n\t * `.dependsOn([uploads])` is what makes `services.uploads` exist and type.\n\t *\n\t * Constructs only. A `Service` does not match the shape, which is what keeps\n\t * env sniffing confined to `.services()` and the explicit lift.\n\t */\n\tdependsOn<const T extends readonly Consumable[]>(\n\t\tconstructs: T,\n\t): QueueBuilder<\n\t\tTName,\n\t\tTMessage,\n\t\t[...TServices, ...ServicesOf<T>],\n\t\tTLogger,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\t// Both halves of the edge, from one call and one clone: the services the\n\t\t// handler runs with, and the ids the manifest records. Recording them\n\t\t// separately is what let them drift apart.\n\t\t//\n\t\t// `servicesOf` is the half that validates, so it runs first — recording\n\t\t// ids ahead of it left a caught `NotAConstruct` with `undefined` already\n\t\t// on a `string[]`.\n\t\tconst services = servicesOf(constructs) as unknown as Service[];\n\n\t\treturn cloneWith(this, {\n\t\t\t_services: [...this._services, ...services],\n\t\t\t_constructs: idsOf(constructs, this._constructs),\n\t\t}) as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\t[...TServices, ...ServicesOf<T>],\n\t\t\tTLogger,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\tservices<T extends Service[]>(\n\t\tservices: T,\n\t): QueueBuilder<\n\t\tTName,\n\t\tTMessage,\n\t\t[...TServices, ...T],\n\t\tTLogger,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\t_services: [...this._services, ...services] as unknown as TServices,\n\t\t}) as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\t[...TServices, ...T],\n\t\t\tTLogger,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\tlogger<T extends Logger>(\n\t\tlogger: T,\n\t): QueueBuilder<\n\t\tTName,\n\t\tTMessage,\n\t\tTServices,\n\t\tT,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\t_logger: logger as unknown as TLogger,\n\t\t}) as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\tTServices,\n\t\t\tT,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\t/**\n\t * The database the handler receives as `db`.\n\t *\n\t * A queue built from a worker already has the worker's, when the worker\n\t * named one with `.database(db)`; this replaces it — the edge as well as\n\t * the client — for a consumer that works against a different database.\n\t */\n\tdatabase<T, TDbName extends string>(\n\t\tsource: Consumable<TDbName, T> | Service<TDbName, T>,\n\t): QueueBuilder<TName, TMessage, TServices, TLogger, T, TDbName> {\n\t\treturn cloneWith(this, {\n\t\t\t_databaseService: serviceOf(source),\n\t\t\t...databaseEdges(\n\t\t\t\t{\n\t\t\t\t\tconstructs: this._constructs,\n\t\t\t\t\tedge: this._databaseEdge,\n\t\t\t\t\tservice: this._databaseService as Service | undefined,\n\t\t\t\t\tservices: this._services,\n\t\t\t\t},\n\t\t\t\tsource,\n\t\t\t),\n\t\t}) as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tT,\n\t\t\tTDbName\n\t\t>;\n\t}\n\n\t/** The typed message (job) payload the queue carries. */\n\tmessage<T extends StandardSchemaV1>(\n\t\tschema: T,\n\t): QueueBuilder<\n\t\tTName,\n\t\tT,\n\t\tTServices,\n\t\tTLogger,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\t_messageSchema: schema as unknown as TMessage,\n\t\t}) as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tT,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\thandle(\n\t\tfn: QueueHandler<NonNullable<TMessage>, TServices, TLogger, TDatabase>,\n\t): Queue<\n\t\tTName,\n\t\tNonNullable<TMessage>,\n\t\tTServices,\n\t\tTLogger,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\tif (!this._name) throw new QueueNeedsName();\n\t\tif (!this._messageSchema) throw new QueueNeedsMessage(this._name);\n\n\t\tconst queue = new Queue<\n\t\t\tTName,\n\t\t\tNonNullable<TMessage>,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>(\n\t\t\tthis._name as TName,\n\t\t\tfn,\n\t\t\tthis._messageSchema as NonNullable<TMessage>,\n\t\t\tthis._timeout,\n\t\t\tthis._services,\n\t\t\tthis._logger,\n\t\t\tthis._batchSize,\n\t\t\tthis._fifo,\n\t\t\tthis._constructs,\n\t\t\tthis._databaseService,\n\t\t);\n\t\t// Which process runs the consumer: the worker it was built from.\n\t\tqueue.owner = this._owner;\n\n\t\t// No reset. `.handle()` reads this builder and leaves it alone, so a\n\t\t// configured base — `const fn = f.logger(log).timeout(60_000)` — keeps\n\t\t// its configuration for every construct built from it. The reset that\n\t\t// used to be here wiped the base on first use, which made a base usable\n\t\t// exactly once, and quietly reverted the logger to the default.\n\n\t\treturn queue;\n\t}\n}\n\n/** A queue built without a name — only reachable by building one by hand. */\nexport class QueueNeedsName extends Error {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"A queue needs a name: build it from a worker, worker.queue('Emails').\",\n\t\t);\n\t\tthis.name = 'QueueNeedsName';\n\t}\n}\n\n/** A queue whose message was never described. */\nexport class QueueNeedsMessage extends Error {\n\tconstructor(readonly queue: string) {\n\t\tsuper(\n\t\t\t`Queue '${queue}' has no message: call .message(schema) before .handle(), ` +\n\t\t\t\t'so its producers and its consumer agree on what it carries.',\n\t\t);\n\t\tthis.name = 'QueueNeedsMessage';\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AAuBA,IAAa,eAAb,MAOE;CACD;CACA;CACA,WAAmB;CACnB;CACA;CACA,YAA+B,CAAC;;CAEhC,cAA+B,CAAC;CAChC,UAA2BA,0BAAAA;;CAE3B;;CAEA;;CAEA;;CAGA,MACC,MAQC;EACD,OAAOC,cAAAA,UAAU,MAAM,EAAE,OAAO,KAAK,CAAC;CAQvC;CAEA,QAAQ,SAAuB;EAC9B,OAAOA,cAAAA,UAAU,MAAM,EAAE,UAAU,QAAQ,CAAC;CAC7C;;CAGA,UAAU,WAAyB;EAClC,OAAOA,cAAAA,UAAU,MAAM,EAAE,YAAY,UAAU,CAAC;CACjD;;CAGA,KAAK,OAAO,MAAY;EACvB,OAAOA,cAAAA,UAAU,MAAM,EAAE,OAAO,KAAK,CAAC;CACvC;;;;;;;;;;;;CAaA,UACC,YAQC;EAQD,MAAM,WAAWC,4BAAAA,WAAW,UAAU;EAEtC,OAAOD,cAAAA,UAAU,MAAM;GACtB,WAAW,CAAC,GAAG,KAAK,WAAW,GAAG,QAAQ;GAC1C,aAAaE,4BAAAA,MAAM,YAAY,KAAK,WAAW;EAChD,CAAC;CAQF;CAEA,SACC,UAQC;EACD,OAAOF,cAAAA,UAAU,MAAM,EACtB,WAAW,CAAC,GAAG,KAAK,WAAW,GAAG,QAAQ,EAC3C,CAAC;CAQF;CAEA,OACC,QAQC;EACD,OAAOA,cAAAA,UAAU,MAAM,EACtB,SAAS,OACV,CAAC;CAQF;;;;;;;;CASA,SACC,QACgE;EAChE,OAAOA,cAAAA,UAAU,MAAM;GACtB,kBAAkBG,4BAAAA,UAAU,MAAM;GAClC,GAAGC,4BAAAA,cACF;IACC,YAAY,KAAK;IACjB,MAAM,KAAK;IACX,SAAS,KAAK;IACd,UAAU,KAAK;GAChB,GACA,MACD;EACD,CAAC;CAQF;;CAGA,QACC,QAQC;EACD,OAAOJ,cAAAA,UAAU,MAAM,EACtB,gBAAgB,OACjB,CAAC;CAQF;CAEA,OACC,IAQC;EACD,IAAI,CAAC,KAAK,OAAO,MAAM,IAAI,eAAe;EAC1C,IAAI,CAAC,KAAK,gBAAgB,MAAM,IAAI,kBAAkB,KAAK,KAAK;EAEhE,MAAM,QAAQ,IAAIK,cAAAA,MAQjB,KAAK,OACL,IACA,KAAK,gBACL,KAAK,UACL,KAAK,WACL,KAAK,SACL,KAAK,YACL,KAAK,OACL,KAAK,aACL,KAAK,gBACN;EAEA,MAAM,QAAQ,KAAK;EAQnB,OAAO;CACR;AACD;;AAGA,IAAa,iBAAb,cAAoC,MAAM;CACzC,cAAc;EACb,MACC,uEACD;EACA,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,oBAAb,cAAuC,MAAM;CACvB;CAArB,YAAY,OAAwB;EACnC,MACC,UAAU,MAAM,sHAEjB;EAJoB,KAAA,QAAA;EAKpB,KAAK,OAAO;CACb;AACD"}
@@ -0,0 +1,118 @@
1
+ import { databaseEdges, idsOf, serviceOf, servicesOf } from "./construct-interface.mjs";
2
+ import { t as cloneWith } from "./clone-EKNovYHu.mjs";
3
+ import { t as Queue } from "./Queue-D6USGS4q.mjs";
4
+ import { DEFAULT_LOGGER } from "@geekmidas/logger/console";
5
+ //#region src/queue/QueueBuilder.ts
6
+ /**
7
+ * Builds a {@link Queue} and its one consumer. Reached through
8
+ * `worker.queue('orders')`, never constructed by hand: the worker stamps itself
9
+ * as the owner. `message` is the typed job payload and `handle` the consumer.
10
+ * The queue name is captured as a literal so `queue.service` publishes
11
+ * `{ type: '<name>', payload }`. The handler's `db` is the worker's database
12
+ * unless `.database(other)` names another.
13
+ */
14
+ var QueueBuilder = class {
15
+ _name;
16
+ _messageSchema;
17
+ _timeout = 3e4;
18
+ _batchSize;
19
+ _fifo;
20
+ _services = [];
21
+ /** The construct ids `.dependsOn()` named — what the manifest records. */
22
+ _constructs = [];
23
+ _logger = DEFAULT_LOGGER;
24
+ /** The worker that runs this queue's consumer — stamped by `worker.queue()`. */
25
+ _owner;
26
+ /** What the handler's `db` comes from — the worker's, unless overridden. */
27
+ _databaseService;
28
+ /** The edge `.database()` added, so the next one can replace it. */
29
+ _databaseEdge;
30
+ /** The queue name — drives the infra queue and its `<NAME>_*` env vars. */
31
+ queue(name) {
32
+ return cloneWith(this, { _name: name });
33
+ }
34
+ timeout(timeout) {
35
+ return cloneWith(this, { _timeout: timeout });
36
+ }
37
+ /** SQS event-source batch size (deployed). */
38
+ batchSize(batchSize) {
39
+ return cloneWith(this, { _batchSize: batchSize });
40
+ }
41
+ /** Mark the queue as FIFO (deployed). */
42
+ fifo(fifo = true) {
43
+ return cloneWith(this, { _fifo: fifo });
44
+ }
45
+ /**
46
+ * Depend on constructs — a database, a bucket, a mail sender, a queue, a
47
+ * topic.
48
+ *
49
+ * It records the edge and dissolves each construct's client into the
50
+ * handler's service record under the construct's own id, so
51
+ * `.dependsOn([uploads])` is what makes `services.uploads` exist and type.
52
+ *
53
+ * Constructs only. A `Service` does not match the shape, which is what keeps
54
+ * env sniffing confined to `.services()` and the explicit lift.
55
+ */
56
+ dependsOn(constructs) {
57
+ const services = servicesOf(constructs);
58
+ return cloneWith(this, {
59
+ _services: [...this._services, ...services],
60
+ _constructs: idsOf(constructs, this._constructs)
61
+ });
62
+ }
63
+ services(services) {
64
+ return cloneWith(this, { _services: [...this._services, ...services] });
65
+ }
66
+ logger(logger) {
67
+ return cloneWith(this, { _logger: logger });
68
+ }
69
+ /**
70
+ * The database the handler receives as `db`.
71
+ *
72
+ * A queue built from a worker already has the worker's, when the worker
73
+ * named one with `.database(db)`; this replaces it — the edge as well as
74
+ * the client — for a consumer that works against a different database.
75
+ */
76
+ database(source) {
77
+ return cloneWith(this, {
78
+ _databaseService: serviceOf(source),
79
+ ...databaseEdges({
80
+ constructs: this._constructs,
81
+ edge: this._databaseEdge,
82
+ service: this._databaseService,
83
+ services: this._services
84
+ }, source)
85
+ });
86
+ }
87
+ /** The typed message (job) payload the queue carries. */
88
+ message(schema) {
89
+ return cloneWith(this, { _messageSchema: schema });
90
+ }
91
+ handle(fn) {
92
+ if (!this._name) throw new QueueNeedsName();
93
+ if (!this._messageSchema) throw new QueueNeedsMessage(this._name);
94
+ const queue = new Queue(this._name, fn, this._messageSchema, this._timeout, this._services, this._logger, this._batchSize, this._fifo, this._constructs, this._databaseService);
95
+ queue.owner = this._owner;
96
+ return queue;
97
+ }
98
+ };
99
+ /** A queue built without a name — only reachable by building one by hand. */
100
+ var QueueNeedsName = class extends Error {
101
+ constructor() {
102
+ super("A queue needs a name: build it from a worker, worker.queue('Emails').");
103
+ this.name = "QueueNeedsName";
104
+ }
105
+ };
106
+ /** A queue whose message was never described. */
107
+ var QueueNeedsMessage = class extends Error {
108
+ queue;
109
+ constructor(queue) {
110
+ super(`Queue '${queue}' has no message: call .message(schema) before .handle(), so its producers and its consumer agree on what it carries.`);
111
+ this.queue = queue;
112
+ this.name = "QueueNeedsMessage";
113
+ }
114
+ };
115
+ //#endregion
116
+ export { QueueNeedsMessage as n, QueueNeedsName as r, QueueBuilder as t };
117
+
118
+ //# sourceMappingURL=QueueBuilder-Cue73M4t.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QueueBuilder-Cue73M4t.mjs","names":[],"sources":["../src/queue/QueueBuilder.ts"],"sourcesContent":["import type { Logger } from '@geekmidas/logger';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { cloneWith } from '../clone';\nimport {\n\ttype Consumable,\n\tdatabaseEdges,\n\tidsOf,\n\ttype ServicesOf,\n\tserviceOf,\n\tservicesOf,\n} from '../construct-interface';\nimport { Queue, type QueueHandler } from './Queue';\n\n/**\n * Builds a {@link Queue} and its one consumer. Reached through\n * `worker.queue('orders')`, never constructed by hand: the worker stamps itself\n * as the owner. `message` is the typed job payload and `handle` the consumer.\n * The queue name is captured as a literal so `queue.service` publishes\n * `{ type: '<name>', payload }`. The handler's `db` is the worker's database\n * unless `.database(other)` names another.\n */\nexport class QueueBuilder<\n\tTName extends string = string,\n\tTMessage extends StandardSchemaV1 | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tTDatabase = undefined,\n\tTDatabaseServiceName extends string = string,\n> {\n\tprivate _name?: string;\n\tprivate _messageSchema?: TMessage;\n\tprivate _timeout = 30000;\n\tprivate _batchSize?: number;\n\tprivate _fifo?: boolean;\n\tprivate _services: TServices = [] as Service[] as TServices;\n\t/** The construct ids `.dependsOn()` named — what the manifest records. */\n\tpublic _constructs: string[] = [];\n\tprivate _logger: TLogger = DEFAULT_LOGGER as TLogger;\n\t/** The worker that runs this queue's consumer — stamped by `worker.queue()`. */\n\tpublic _owner?: string;\n\t/** What the handler's `db` comes from — the worker's, unless overridden. */\n\tprivate _databaseService?: Service<TDatabaseServiceName, TDatabase>;\n\t/** The edge `.database()` added, so the next one can replace it. */\n\tprivate _databaseEdge?: string;\n\n\t/** The queue name — drives the infra queue and its `<NAME>_*` env vars. */\n\tqueue<T extends string>(\n\t\tname: T,\n\t): QueueBuilder<\n\t\tT,\n\t\tTMessage,\n\t\tTServices,\n\t\tTLogger,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, { _name: name }) as unknown as QueueBuilder<\n\t\t\tT,\n\t\t\tTMessage,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\ttimeout(timeout: number): this {\n\t\treturn cloneWith(this, { _timeout: timeout });\n\t}\n\n\t/** SQS event-source batch size (deployed). */\n\tbatchSize(batchSize: number): this {\n\t\treturn cloneWith(this, { _batchSize: batchSize });\n\t}\n\n\t/** Mark the queue as FIFO (deployed). */\n\tfifo(fifo = true): this {\n\t\treturn cloneWith(this, { _fifo: fifo });\n\t}\n\n\t/**\n\t * Depend on constructs — a database, a bucket, a mail sender, a queue, a\n\t * topic.\n\t *\n\t * It records the edge and dissolves each construct's client into the\n\t * handler's service record under the construct's own id, so\n\t * `.dependsOn([uploads])` is what makes `services.uploads` exist and type.\n\t *\n\t * Constructs only. A `Service` does not match the shape, which is what keeps\n\t * env sniffing confined to `.services()` and the explicit lift.\n\t */\n\tdependsOn<const T extends readonly Consumable[]>(\n\t\tconstructs: T,\n\t): QueueBuilder<\n\t\tTName,\n\t\tTMessage,\n\t\t[...TServices, ...ServicesOf<T>],\n\t\tTLogger,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\t// Both halves of the edge, from one call and one clone: the services the\n\t\t// handler runs with, and the ids the manifest records. Recording them\n\t\t// separately is what let them drift apart.\n\t\t//\n\t\t// `servicesOf` is the half that validates, so it runs first — recording\n\t\t// ids ahead of it left a caught `NotAConstruct` with `undefined` already\n\t\t// on a `string[]`.\n\t\tconst services = servicesOf(constructs) as unknown as Service[];\n\n\t\treturn cloneWith(this, {\n\t\t\t_services: [...this._services, ...services],\n\t\t\t_constructs: idsOf(constructs, this._constructs),\n\t\t}) as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\t[...TServices, ...ServicesOf<T>],\n\t\t\tTLogger,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\tservices<T extends Service[]>(\n\t\tservices: T,\n\t): QueueBuilder<\n\t\tTName,\n\t\tTMessage,\n\t\t[...TServices, ...T],\n\t\tTLogger,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\t_services: [...this._services, ...services] as unknown as TServices,\n\t\t}) as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\t[...TServices, ...T],\n\t\t\tTLogger,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\tlogger<T extends Logger>(\n\t\tlogger: T,\n\t): QueueBuilder<\n\t\tTName,\n\t\tTMessage,\n\t\tTServices,\n\t\tT,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\t_logger: logger as unknown as TLogger,\n\t\t}) as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\tTServices,\n\t\t\tT,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\t/**\n\t * The database the handler receives as `db`.\n\t *\n\t * A queue built from a worker already has the worker's, when the worker\n\t * named one with `.database(db)`; this replaces it — the edge as well as\n\t * the client — for a consumer that works against a different database.\n\t */\n\tdatabase<T, TDbName extends string>(\n\t\tsource: Consumable<TDbName, T> | Service<TDbName, T>,\n\t): QueueBuilder<TName, TMessage, TServices, TLogger, T, TDbName> {\n\t\treturn cloneWith(this, {\n\t\t\t_databaseService: serviceOf(source),\n\t\t\t...databaseEdges(\n\t\t\t\t{\n\t\t\t\t\tconstructs: this._constructs,\n\t\t\t\t\tedge: this._databaseEdge,\n\t\t\t\t\tservice: this._databaseService as Service | undefined,\n\t\t\t\t\tservices: this._services,\n\t\t\t\t},\n\t\t\t\tsource,\n\t\t\t),\n\t\t}) as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tTMessage,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tT,\n\t\t\tTDbName\n\t\t>;\n\t}\n\n\t/** The typed message (job) payload the queue carries. */\n\tmessage<T extends StandardSchemaV1>(\n\t\tschema: T,\n\t): QueueBuilder<\n\t\tTName,\n\t\tT,\n\t\tTServices,\n\t\tTLogger,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\treturn cloneWith(this, {\n\t\t\t_messageSchema: schema as unknown as TMessage,\n\t\t}) as unknown as QueueBuilder<\n\t\t\tTName,\n\t\t\tT,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>;\n\t}\n\n\thandle(\n\t\tfn: QueueHandler<NonNullable<TMessage>, TServices, TLogger, TDatabase>,\n\t): Queue<\n\t\tTName,\n\t\tNonNullable<TMessage>,\n\t\tTServices,\n\t\tTLogger,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t> {\n\t\tif (!this._name) throw new QueueNeedsName();\n\t\tif (!this._messageSchema) throw new QueueNeedsMessage(this._name);\n\n\t\tconst queue = new Queue<\n\t\t\tTName,\n\t\t\tNonNullable<TMessage>,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tTDatabase,\n\t\t\tTDatabaseServiceName\n\t\t>(\n\t\t\tthis._name as TName,\n\t\t\tfn,\n\t\t\tthis._messageSchema as NonNullable<TMessage>,\n\t\t\tthis._timeout,\n\t\t\tthis._services,\n\t\t\tthis._logger,\n\t\t\tthis._batchSize,\n\t\t\tthis._fifo,\n\t\t\tthis._constructs,\n\t\t\tthis._databaseService,\n\t\t);\n\t\t// Which process runs the consumer: the worker it was built from.\n\t\tqueue.owner = this._owner;\n\n\t\t// No reset. `.handle()` reads this builder and leaves it alone, so a\n\t\t// configured base — `const fn = f.logger(log).timeout(60_000)` — keeps\n\t\t// its configuration for every construct built from it. The reset that\n\t\t// used to be here wiped the base on first use, which made a base usable\n\t\t// exactly once, and quietly reverted the logger to the default.\n\n\t\treturn queue;\n\t}\n}\n\n/** A queue built without a name — only reachable by building one by hand. */\nexport class QueueNeedsName extends Error {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"A queue needs a name: build it from a worker, worker.queue('Emails').\",\n\t\t);\n\t\tthis.name = 'QueueNeedsName';\n\t}\n}\n\n/** A queue whose message was never described. */\nexport class QueueNeedsMessage extends Error {\n\tconstructor(readonly queue: string) {\n\t\tsuper(\n\t\t\t`Queue '${queue}' has no message: call .message(schema) before .handle(), ` +\n\t\t\t\t'so its producers and its consumer agree on what it carries.',\n\t\t);\n\t\tthis.name = 'QueueNeedsMessage';\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AAuBA,IAAa,eAAb,MAOE;CACD;CACA;CACA,WAAmB;CACnB;CACA;CACA,YAA+B,CAAC;;CAEhC,cAA+B,CAAC;CAChC,UAA2B;;CAE3B;;CAEA;;CAEA;;CAGA,MACC,MAQC;EACD,OAAO,UAAU,MAAM,EAAE,OAAO,KAAK,CAAC;CAQvC;CAEA,QAAQ,SAAuB;EAC9B,OAAO,UAAU,MAAM,EAAE,UAAU,QAAQ,CAAC;CAC7C;;CAGA,UAAU,WAAyB;EAClC,OAAO,UAAU,MAAM,EAAE,YAAY,UAAU,CAAC;CACjD;;CAGA,KAAK,OAAO,MAAY;EACvB,OAAO,UAAU,MAAM,EAAE,OAAO,KAAK,CAAC;CACvC;;;;;;;;;;;;CAaA,UACC,YAQC;EAQD,MAAM,WAAW,WAAW,UAAU;EAEtC,OAAO,UAAU,MAAM;GACtB,WAAW,CAAC,GAAG,KAAK,WAAW,GAAG,QAAQ;GAC1C,aAAa,MAAM,YAAY,KAAK,WAAW;EAChD,CAAC;CAQF;CAEA,SACC,UAQC;EACD,OAAO,UAAU,MAAM,EACtB,WAAW,CAAC,GAAG,KAAK,WAAW,GAAG,QAAQ,EAC3C,CAAC;CAQF;CAEA,OACC,QAQC;EACD,OAAO,UAAU,MAAM,EACtB,SAAS,OACV,CAAC;CAQF;;;;;;;;CASA,SACC,QACgE;EAChE,OAAO,UAAU,MAAM;GACtB,kBAAkB,UAAU,MAAM;GAClC,GAAG,cACF;IACC,YAAY,KAAK;IACjB,MAAM,KAAK;IACX,SAAS,KAAK;IACd,UAAU,KAAK;GAChB,GACA,MACD;EACD,CAAC;CAQF;;CAGA,QACC,QAQC;EACD,OAAO,UAAU,MAAM,EACtB,gBAAgB,OACjB,CAAC;CAQF;CAEA,OACC,IAQC;EACD,IAAI,CAAC,KAAK,OAAO,MAAM,IAAI,eAAe;EAC1C,IAAI,CAAC,KAAK,gBAAgB,MAAM,IAAI,kBAAkB,KAAK,KAAK;EAEhE,MAAM,QAAQ,IAAI,MAQjB,KAAK,OACL,IACA,KAAK,gBACL,KAAK,UACL,KAAK,WACL,KAAK,SACL,KAAK,YACL,KAAK,OACL,KAAK,aACL,KAAK,gBACN;EAEA,MAAM,QAAQ,KAAK;EAQnB,OAAO;CACR;AACD;;AAGA,IAAa,iBAAb,cAAoC,MAAM;CACzC,cAAc;EACb,MACC,uEACD;EACA,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,oBAAb,cAAuC,MAAM;CACvB;CAArB,YAAY,OAAwB;EACnC,MACC,UAAU,MAAM,sHAEjB;EAJoB,KAAA,QAAA;EAKpB,KAAK,OAAO;CACb;AACD"}
@@ -0,0 +1,75 @@
1
+ import { t as StandardSchemaV1 } from "./index-CeEtxDmK.cjs";
2
+ import { c as ServicesOf, r as Consumable } from "./construct-interface-B1AfqRl4.cjs";
3
+ import { r as QueueHandler, t as Queue } from "./Queue-HPyi0e1i.cjs";
4
+ import { Logger } from "@geekmidas/logger";
5
+ import { Service } from "@geekmidas/services";
6
+ //#region src/queue/QueueBuilder.d.ts
7
+ /**
8
+ * Builds a {@link Queue} and its one consumer. Reached through
9
+ * `worker.queue('orders')`, never constructed by hand: the worker stamps itself
10
+ * as the owner. `message` is the typed job payload and `handle` the consumer.
11
+ * The queue name is captured as a literal so `queue.service` publishes
12
+ * `{ type: '<name>', payload }`. The handler's `db` is the worker's database
13
+ * unless `.database(other)` names another.
14
+ */
15
+ declare class QueueBuilder<TName extends string = string, TMessage extends StandardSchemaV1 | undefined = undefined, TServices extends Service[] = [], TLogger extends Logger = Logger, TDatabase = undefined, TDatabaseServiceName extends string = string> {
16
+ private _name?;
17
+ private _messageSchema?;
18
+ private _timeout;
19
+ private _batchSize?;
20
+ private _fifo?;
21
+ private _services;
22
+ /** The construct ids `.dependsOn()` named — what the manifest records. */
23
+ _constructs: string[];
24
+ private _logger;
25
+ /** The worker that runs this queue's consumer — stamped by `worker.queue()`. */
26
+ _owner?: string;
27
+ /** What the handler's `db` comes from — the worker's, unless overridden. */
28
+ private _databaseService?;
29
+ /** The edge `.database()` added, so the next one can replace it. */
30
+ private _databaseEdge?;
31
+ /** The queue name — drives the infra queue and its `<NAME>_*` env vars. */
32
+ queue<T extends string>(name: T): QueueBuilder<T, TMessage, TServices, TLogger, TDatabase, TDatabaseServiceName>;
33
+ timeout(timeout: number): this;
34
+ /** SQS event-source batch size (deployed). */
35
+ batchSize(batchSize: number): this;
36
+ /** Mark the queue as FIFO (deployed). */
37
+ fifo(fifo?: boolean): this;
38
+ /**
39
+ * Depend on constructs — a database, a bucket, a mail sender, a queue, a
40
+ * topic.
41
+ *
42
+ * It records the edge and dissolves each construct's client into the
43
+ * handler's service record under the construct's own id, so
44
+ * `.dependsOn([uploads])` is what makes `services.uploads` exist and type.
45
+ *
46
+ * Constructs only. A `Service` does not match the shape, which is what keeps
47
+ * env sniffing confined to `.services()` and the explicit lift.
48
+ */
49
+ dependsOn<const T extends readonly Consumable[]>(constructs: T): QueueBuilder<TName, TMessage, [...TServices, ...ServicesOf<T>], TLogger, TDatabase, TDatabaseServiceName>;
50
+ services<T extends Service[]>(services: T): QueueBuilder<TName, TMessage, [...TServices, ...T], TLogger, TDatabase, TDatabaseServiceName>;
51
+ logger<T extends Logger>(logger: T): QueueBuilder<TName, TMessage, TServices, T, TDatabase, TDatabaseServiceName>;
52
+ /**
53
+ * The database the handler receives as `db`.
54
+ *
55
+ * A queue built from a worker already has the worker's, when the worker
56
+ * named one with `.database(db)`; this replaces it — the edge as well as
57
+ * the client — for a consumer that works against a different database.
58
+ */
59
+ database<T, TDbName extends string>(source: Consumable<TDbName, T> | Service<TDbName, T>): QueueBuilder<TName, TMessage, TServices, TLogger, T, TDbName>;
60
+ /** The typed message (job) payload the queue carries. */
61
+ message<T extends StandardSchemaV1>(schema: T): QueueBuilder<TName, T, TServices, TLogger, TDatabase, TDatabaseServiceName>;
62
+ handle(fn: QueueHandler<NonNullable<TMessage>, TServices, TLogger, TDatabase>): Queue<TName, NonNullable<TMessage>, TServices, TLogger, TDatabase, TDatabaseServiceName>;
63
+ }
64
+ /** A queue built without a name — only reachable by building one by hand. */
65
+ declare class QueueNeedsName extends Error {
66
+ constructor();
67
+ }
68
+ /** A queue whose message was never described. */
69
+ declare class QueueNeedsMessage extends Error {
70
+ readonly queue: string;
71
+ constructor(queue: string);
72
+ }
73
+ //#endregion
74
+ export { QueueNeedsMessage as n, QueueNeedsName as r, QueueBuilder as t };
75
+ //# sourceMappingURL=QueueBuilder-OSi6LkV9.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QueueBuilder-OSi6LkV9.d.cts","names":[],"sources":["../src/queue/QueueBuilder.ts"],"mappings":";;;;;;;;;;;;;;cAuBa,aACZ,+BACA,iBAAiB,0CACjB,kBAAkB,gBAClB,gBAAgB,SAAS,QACzB,uBACA;UAEQ;UACA;UACA;UACA;UACA;UACA;;EAED;UACC;;EAED;;UAEC;;UAEA;;EAGR,MAAM,kBACL,MAAM,IACJ,aACF,GACA,UACA,WACA,SACA,WACA;EAYD,QAAQ;;EAKR,UAAU;;EAKV,KAAK;;;;;;;;;;;;EAeL,gBAAgB,mBAAmB,cAClC,YAAY,IACV,aACF,OACA,cACI,cAAc,WAAW,KAC7B,SACA,WACA;EAwBD,SAAS,UAAU,WAClB,UAAU,IACR,aACF,OACA,cACI,cAAc,IAClB,SACA,WACA;EAcD,OAAO,UAAU,QAChB,QAAQ,IACN,aACF,OACA,UACA,WACA,GACA,WACA;;;;;;;;EAqBD,SAAS,GAAG,wBACX,QAAQ,WAAW,SAAS,KAAK,QAAQ,SAAS,KAChD,aAAa,OAAO,UAAU,WAAW,SAAS,GAAG;;EAuBxD,QAAQ,UAAU,kBACjB,QAAQ,IACN,aACF,OACA,GACA,WACA,SACA,WACA;EAcD,OACC,IAAI,aAAa,YAAY,WAAW,WAAW,SAAS,aAC1D,MACF,OACA,YAAY,WACZ,WACA,SACA,WACA;;;cAsCW,uBAAuB;EACnC;;;cASY,0BAA0B;WACjB;EAArB,YAAqB"}
@@ -0,0 +1,75 @@
1
+ import { t as StandardSchemaV1 } from "./index-CeEtxDmK.mjs";
2
+ import { c as ServicesOf, r as Consumable } from "./construct-interface-DluK3_da.mjs";
3
+ import { r as QueueHandler, t as Queue } from "./Queue-DlsHRzUp.mjs";
4
+ import { Service } from "@geekmidas/services";
5
+ import { Logger } from "@geekmidas/logger";
6
+ //#region src/queue/QueueBuilder.d.ts
7
+ /**
8
+ * Builds a {@link Queue} and its one consumer. Reached through
9
+ * `worker.queue('orders')`, never constructed by hand: the worker stamps itself
10
+ * as the owner. `message` is the typed job payload and `handle` the consumer.
11
+ * The queue name is captured as a literal so `queue.service` publishes
12
+ * `{ type: '<name>', payload }`. The handler's `db` is the worker's database
13
+ * unless `.database(other)` names another.
14
+ */
15
+ declare class QueueBuilder<TName extends string = string, TMessage extends StandardSchemaV1 | undefined = undefined, TServices extends Service[] = [], TLogger extends Logger = Logger, TDatabase = undefined, TDatabaseServiceName extends string = string> {
16
+ private _name?;
17
+ private _messageSchema?;
18
+ private _timeout;
19
+ private _batchSize?;
20
+ private _fifo?;
21
+ private _services;
22
+ /** The construct ids `.dependsOn()` named — what the manifest records. */
23
+ _constructs: string[];
24
+ private _logger;
25
+ /** The worker that runs this queue's consumer — stamped by `worker.queue()`. */
26
+ _owner?: string;
27
+ /** What the handler's `db` comes from — the worker's, unless overridden. */
28
+ private _databaseService?;
29
+ /** The edge `.database()` added, so the next one can replace it. */
30
+ private _databaseEdge?;
31
+ /** The queue name — drives the infra queue and its `<NAME>_*` env vars. */
32
+ queue<T extends string>(name: T): QueueBuilder<T, TMessage, TServices, TLogger, TDatabase, TDatabaseServiceName>;
33
+ timeout(timeout: number): this;
34
+ /** SQS event-source batch size (deployed). */
35
+ batchSize(batchSize: number): this;
36
+ /** Mark the queue as FIFO (deployed). */
37
+ fifo(fifo?: boolean): this;
38
+ /**
39
+ * Depend on constructs — a database, a bucket, a mail sender, a queue, a
40
+ * topic.
41
+ *
42
+ * It records the edge and dissolves each construct's client into the
43
+ * handler's service record under the construct's own id, so
44
+ * `.dependsOn([uploads])` is what makes `services.uploads` exist and type.
45
+ *
46
+ * Constructs only. A `Service` does not match the shape, which is what keeps
47
+ * env sniffing confined to `.services()` and the explicit lift.
48
+ */
49
+ dependsOn<const T extends readonly Consumable[]>(constructs: T): QueueBuilder<TName, TMessage, [...TServices, ...ServicesOf<T>], TLogger, TDatabase, TDatabaseServiceName>;
50
+ services<T extends Service[]>(services: T): QueueBuilder<TName, TMessage, [...TServices, ...T], TLogger, TDatabase, TDatabaseServiceName>;
51
+ logger<T extends Logger>(logger: T): QueueBuilder<TName, TMessage, TServices, T, TDatabase, TDatabaseServiceName>;
52
+ /**
53
+ * The database the handler receives as `db`.
54
+ *
55
+ * A queue built from a worker already has the worker's, when the worker
56
+ * named one with `.database(db)`; this replaces it — the edge as well as
57
+ * the client — for a consumer that works against a different database.
58
+ */
59
+ database<T, TDbName extends string>(source: Consumable<TDbName, T> | Service<TDbName, T>): QueueBuilder<TName, TMessage, TServices, TLogger, T, TDbName>;
60
+ /** The typed message (job) payload the queue carries. */
61
+ message<T extends StandardSchemaV1>(schema: T): QueueBuilder<TName, T, TServices, TLogger, TDatabase, TDatabaseServiceName>;
62
+ handle(fn: QueueHandler<NonNullable<TMessage>, TServices, TLogger, TDatabase>): Queue<TName, NonNullable<TMessage>, TServices, TLogger, TDatabase, TDatabaseServiceName>;
63
+ }
64
+ /** A queue built without a name — only reachable by building one by hand. */
65
+ declare class QueueNeedsName extends Error {
66
+ constructor();
67
+ }
68
+ /** A queue whose message was never described. */
69
+ declare class QueueNeedsMessage extends Error {
70
+ readonly queue: string;
71
+ constructor(queue: string);
72
+ }
73
+ //#endregion
74
+ export { QueueNeedsMessage as n, QueueNeedsName as r, QueueBuilder as t };
75
+ //# sourceMappingURL=QueueBuilder-QHsnVt1P.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QueueBuilder-QHsnVt1P.d.mts","names":[],"sources":["../src/queue/QueueBuilder.ts"],"mappings":";;;;;;;;;;;;;;cAuBa,aACZ,+BACA,iBAAiB,0CACjB,kBAAkB,gBAClB,gBAAgB,SAAS,QACzB,uBACA;UAEQ;UACA;UACA;UACA;UACA;UACA;;EAED;UACC;;EAED;;UAEC;;UAEA;;EAGR,MAAM,kBACL,MAAM,IACJ,aACF,GACA,UACA,WACA,SACA,WACA;EAYD,QAAQ;;EAKR,UAAU;;EAKV,KAAK;;;;;;;;;;;;EAeL,gBAAgB,mBAAmB,cAClC,YAAY,IACV,aACF,OACA,cACI,cAAc,WAAW,KAC7B,SACA,WACA;EAwBD,SAAS,UAAU,WAClB,UAAU,IACR,aACF,OACA,cACI,cAAc,IAClB,SACA,WACA;EAcD,OAAO,UAAU,QAChB,QAAQ,IACN,aACF,OACA,UACA,WACA,GACA,WACA;;;;;;;;EAqBD,SAAS,GAAG,wBACX,QAAQ,WAAW,SAAS,KAAK,QAAQ,SAAS,KAChD,aAAa,OAAO,UAAU,WAAW,SAAS,GAAG;;EAuBxD,QAAQ,UAAU,kBACjB,QAAQ,IACN,aACF,OACA,GACA,WACA,SACA,WACA;EAcD,OACC,IAAI,aAAa,YAAY,WAAW,WAAW,SAAS,aAC1D,MACF,OACA,YAAY,WACZ,WACA,SACA,WACA;;;cAsCW,uBAAuB;EACnC;;;cASY,0BAA0B;WACjB;EAArB,YAAqB"}