@geekmidas/constructs 10.0.0-alpha.2 → 10.0.0-alpha.21

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 (333) hide show
  1. package/README.md +46 -3
  2. package/dist/{Construct-Ct8nalEi.d.mts → Construct-DTqYvkPG.d.cts} +11 -13
  3. package/dist/Construct-DTqYvkPG.d.cts.map +1 -0
  4. package/dist/{Construct-BD5neF7w.mjs → Construct-Detz65RA.mjs} +31 -29
  5. package/dist/Construct-Detz65RA.mjs.map +1 -0
  6. package/dist/{Construct-C0ijr2qp.d.cts → Construct-pVadmURD.d.mts} +10 -12
  7. package/dist/Construct-pVadmURD.d.mts.map +1 -0
  8. package/dist/{Construct-CyS3RpTL.cjs → Construct-yG9Sw-5p.cjs} +51 -43
  9. package/dist/Construct-yG9Sw-5p.cjs.map +1 -0
  10. package/dist/{Cron-ByxdOfpE.d.mts → Cron-AYpQq725.d.mts} +13 -6
  11. package/dist/Cron-AYpQq725.d.mts.map +1 -0
  12. package/dist/{Cron-Wqh464aO.d.cts → Cron-Bdcg9OAL.d.cts} +12 -5
  13. package/dist/Cron-Bdcg9OAL.d.cts.map +1 -0
  14. package/dist/{CronBuilder-BL0AP6fs.d.mts → CronBuilder-DR21m9h2.d.cts} +7 -10
  15. package/dist/CronBuilder-DR21m9h2.d.cts.map +1 -0
  16. package/dist/{CronBuilder-BqpEzMPQ.d.cts → CronBuilder-DeBnPVIT.d.mts} +7 -10
  17. package/dist/CronBuilder-DeBnPVIT.d.mts.map +1 -0
  18. package/dist/{CronBuilder-BmABazzH.mjs → CronBuilder-vkjuo1UP.mjs} +23 -15
  19. package/dist/CronBuilder-vkjuo1UP.mjs.map +1 -0
  20. package/dist/{CronBuilder-CkXPJiGO.cjs → CronBuilder-zdTdaT-e.cjs} +33 -25
  21. package/dist/CronBuilder-zdTdaT-e.cjs.map +1 -0
  22. package/dist/{Endpoint-2Wg7T7Cq.d.mts → Endpoint-BxkRWQ8G.d.mts} +63 -84
  23. package/dist/Endpoint-BxkRWQ8G.d.mts.map +1 -0
  24. package/dist/{Endpoint-BiaaMEn_.cjs → Endpoint-CtiPUpRX.cjs} +145 -131
  25. package/dist/Endpoint-CtiPUpRX.cjs.map +1 -0
  26. package/dist/{Endpoint-VIOpSo0S.mjs → Endpoint-DCr5tlbJ.mjs} +117 -109
  27. package/dist/Endpoint-DCr5tlbJ.mjs.map +1 -0
  28. package/dist/{Endpoint-CH9Fn1AD.d.cts → Endpoint-DbYQJgb-.d.cts} +61 -82
  29. package/dist/Endpoint-DbYQJgb-.d.cts.map +1 -0
  30. package/dist/{EndpointFactory-DTTCkGEL.mjs → EndpointFactory-Bs8pu-yY.mjs} +20 -29
  31. package/dist/EndpointFactory-Bs8pu-yY.mjs.map +1 -0
  32. package/dist/{index-BxHDdy6a.d.mts → EndpointFactory-DE6nKtFZ.d.cts} +12 -92
  33. package/dist/EndpointFactory-DE6nKtFZ.d.cts.map +1 -0
  34. package/dist/{index-V2nksZIJ.d.cts → EndpointFactory-T06kTFHg.d.mts} +12 -92
  35. package/dist/EndpointFactory-T06kTFHg.d.mts.map +1 -0
  36. package/dist/{EndpointFactory-ChxLZllA.cjs → EndpointFactory-vE2C1NG1.cjs} +57 -66
  37. package/dist/EndpointFactory-vE2C1NG1.cjs.map +1 -0
  38. package/dist/{HonoEndpointAdaptor-NKQQQbBY.mjs → HonoEndpointAdaptor-Be6UdK0r.mjs} +40 -47
  39. package/dist/{HonoEndpointAdaptor-D233Jvpk.cjs.map → HonoEndpointAdaptor-Be6UdK0r.mjs.map} +1 -1
  40. package/dist/{HonoEndpointAdaptor-D233Jvpk.cjs → HonoEndpointAdaptor-C9aivwKl.cjs} +48 -52
  41. package/dist/HonoEndpointAdaptor-C9aivwKl.cjs.map +1 -0
  42. package/dist/{Queue-D7ZuwBhy.d.cts → Queue-Bhzi2WQC.d.cts} +8 -9
  43. package/dist/Queue-Bhzi2WQC.d.cts.map +1 -0
  44. package/dist/{Queue-gVGfi2Yk.d.mts → Queue-BoUA-e83.d.mts} +9 -10
  45. package/dist/Queue-BoUA-e83.d.mts.map +1 -0
  46. package/dist/{Subscriber-2mEi0ImH.d.cts → Subscriber-CIO3pwji.d.mts} +7 -8
  47. package/dist/Subscriber-CIO3pwji.d.mts.map +1 -0
  48. package/dist/{Subscriber-xTJ9ayPN.d.mts → Subscriber-DQCaiOXF.d.cts} +7 -8
  49. package/dist/Subscriber-DQCaiOXF.d.cts.map +1 -0
  50. package/dist/{SubscriberBuilder-BjkbeT9l.mjs → SubscriberBuilder-B4YRTBng.mjs} +16 -10
  51. package/dist/SubscriberBuilder-B4YRTBng.mjs.map +1 -0
  52. package/dist/{SubscriberBuilder-4OPehf2R.cjs → SubscriberBuilder-C2bCOuPT.cjs} +28 -23
  53. package/dist/SubscriberBuilder-C2bCOuPT.cjs.map +1 -0
  54. package/dist/{SubscriberBuilder-Dptmo-1A.d.mts → SubscriberBuilder-ChX5v948.d.cts} +8 -11
  55. package/dist/SubscriberBuilder-ChX5v948.d.cts.map +1 -0
  56. package/dist/{SubscriberBuilder-waNhzjSM.d.cts → SubscriberBuilder-Dbiaskfi.d.mts} +8 -11
  57. package/dist/SubscriberBuilder-Dbiaskfi.d.mts.map +1 -0
  58. package/dist/{Topic-19QeHBIR.d.cts → Topic-D6blllEn.d.cts} +5 -7
  59. package/dist/Topic-D6blllEn.d.cts.map +1 -0
  60. package/dist/{Topic-DuFeqkBh.d.mts → Topic-DVvheJ_-.d.mts} +6 -8
  61. package/dist/Topic-DVvheJ_-.d.mts.map +1 -0
  62. package/dist/adaptors/aws.cjs +87 -106
  63. package/dist/adaptors/aws.cjs.map +1 -1
  64. package/dist/adaptors/aws.d.cts +14 -27
  65. package/dist/adaptors/aws.d.cts.map +1 -1
  66. package/dist/adaptors/aws.d.mts +16 -29
  67. package/dist/adaptors/aws.d.mts.map +1 -1
  68. package/dist/adaptors/aws.mjs +60 -81
  69. package/dist/adaptors/aws.mjs.map +1 -1
  70. package/dist/adaptors/hono.cjs +3 -10
  71. package/dist/adaptors/hono.d.cts +5 -13
  72. package/dist/adaptors/hono.d.cts.map +1 -1
  73. package/dist/adaptors/hono.d.mts +7 -15
  74. package/dist/adaptors/hono.d.mts.map +1 -1
  75. package/dist/adaptors/hono.mjs +2 -10
  76. package/dist/adaptors/testing.cjs +271 -82
  77. package/dist/adaptors/testing.cjs.map +1 -1
  78. package/dist/adaptors/testing.d.cts +62 -33
  79. package/dist/adaptors/testing.d.cts.map +1 -1
  80. package/dist/adaptors/testing.d.mts +63 -34
  81. package/dist/adaptors/testing.d.mts.map +1 -1
  82. package/dist/adaptors/testing.mjs +249 -63
  83. package/dist/adaptors/testing.mjs.map +1 -1
  84. package/dist/auth-BlO8MUkR.d.cts +123 -0
  85. package/dist/auth-BlO8MUkR.d.cts.map +1 -0
  86. package/dist/auth-CHWIdcQO.d.mts +123 -0
  87. package/dist/auth-CHWIdcQO.d.mts.map +1 -0
  88. package/dist/auth.cjs +41 -16
  89. package/dist/auth.cjs.map +1 -1
  90. package/dist/auth.d.cts +2 -108
  91. package/dist/auth.d.mts +2 -108
  92. package/dist/auth.mjs +32 -8
  93. package/dist/auth.mjs.map +1 -1
  94. package/dist/{cache-BrRz3fEB.d.mts → cache-AgQUMma6.d.mts} +3 -6
  95. package/dist/cache-AgQUMma6.d.mts.map +1 -0
  96. package/dist/{cache-BtZY_tHe.d.cts → cache-obq0fOIM.d.cts} +3 -6
  97. package/dist/cache-obq0fOIM.d.cts.map +1 -0
  98. package/dist/cache.cjs +68 -2
  99. package/dist/cache.cjs.map +1 -0
  100. package/dist/cache.d.cts +1 -2
  101. package/dist/cache.d.mts +1 -2
  102. package/dist/cache.mjs +67 -2
  103. package/dist/cache.mjs.map +1 -0
  104. package/dist/{clone-DblgEZZa.mjs → clone-EKNovYHu.mjs} +3 -3
  105. package/dist/clone-EKNovYHu.mjs.map +1 -0
  106. package/dist/{clone-Dy0cR2SZ.cjs → clone-UGJpvQnL.cjs} +7 -8
  107. package/dist/clone-UGJpvQnL.cjs.map +1 -0
  108. package/dist/{construct-interface-g5GM5pwR.d.mts → construct-interface-Clz7_BwB.d.mts} +15 -6
  109. package/dist/construct-interface-Clz7_BwB.d.mts.map +1 -0
  110. package/dist/{construct-interface-D9d4Gm4p.d.cts → construct-interface-DIaTNKax.d.cts} +15 -6
  111. package/dist/construct-interface-DIaTNKax.d.cts.map +1 -0
  112. package/dist/construct-interface.cjs +87 -7
  113. package/dist/construct-interface.cjs.map +1 -0
  114. package/dist/construct-interface.d.cts +2 -2
  115. package/dist/construct-interface.d.mts +2 -2
  116. package/dist/construct-interface.mjs +81 -2
  117. package/dist/construct-interface.mjs.map +1 -0
  118. package/dist/credential.cjs +43 -9
  119. package/dist/credential.cjs.map +1 -1
  120. package/dist/credential.d.cts +5 -8
  121. package/dist/credential.d.cts.map +1 -1
  122. package/dist/credential.d.mts +5 -8
  123. package/dist/credential.d.mts.map +1 -1
  124. package/dist/credential.mjs +36 -2
  125. package/dist/credential.mjs.map +1 -1
  126. package/dist/crons/index.cjs +68 -10
  127. package/dist/crons/index.cjs.map +1 -1
  128. package/dist/crons/index.d.cts +32 -14
  129. package/dist/crons/index.d.cts.map +1 -1
  130. package/dist/crons/index.d.mts +32 -14
  131. package/dist/crons/index.d.mts.map +1 -1
  132. package/dist/crons/index.mjs +66 -10
  133. package/dist/crons/index.mjs.map +1 -1
  134. package/dist/database/kysely.cjs +28 -14
  135. package/dist/database/kysely.cjs.map +1 -1
  136. package/dist/database/kysely.d.cts +2 -152
  137. package/dist/database/kysely.d.mts +2 -152
  138. package/dist/database/kysely.mjs +16 -4
  139. package/dist/database/kysely.mjs.map +1 -1
  140. package/dist/email.cjs +25 -12
  141. package/dist/email.cjs.map +1 -1
  142. package/dist/email.d.cts +3 -7
  143. package/dist/email.d.cts.map +1 -1
  144. package/dist/email.d.mts +3 -7
  145. package/dist/email.d.mts.map +1 -1
  146. package/dist/email.mjs +16 -3
  147. package/dist/email.mjs.map +1 -1
  148. package/dist/endpoints/index.cjs +7 -10
  149. package/dist/endpoints/index.d.cts +60 -7
  150. package/dist/endpoints/index.d.cts.map +1 -0
  151. package/dist/endpoints/index.d.mts +60 -7
  152. package/dist/endpoints/index.d.mts.map +1 -0
  153. package/dist/endpoints/index.mjs +5 -10
  154. package/dist/file-server.cjs +42 -10
  155. package/dist/file-server.cjs.map +1 -1
  156. package/dist/file-server.d.cts +6 -10
  157. package/dist/file-server.d.cts.map +1 -1
  158. package/dist/file-server.d.mts +6 -10
  159. package/dist/file-server.d.mts.map +1 -1
  160. package/dist/file-server.mjs +34 -2
  161. package/dist/file-server.mjs.map +1 -1
  162. package/dist/functions/index.cjs +2 -6
  163. package/dist/functions/index.d.cts +2 -4
  164. package/dist/functions/index.d.mts +2 -4
  165. package/dist/functions/index.mjs +2 -6
  166. package/dist/{functions-Bd3TPxid.cjs → functions-VnOTEp74.cjs} +309 -264
  167. package/dist/functions-VnOTEp74.cjs.map +1 -0
  168. package/dist/{functions-Cxbo-pEd.mjs → functions-faoJOUmr.mjs} +282 -234
  169. package/dist/functions-faoJOUmr.mjs.map +1 -0
  170. package/dist/index-CeEtxDmK.d.cts +79 -0
  171. package/dist/index-CeEtxDmK.d.cts.map +1 -0
  172. package/dist/index-CeEtxDmK.d.mts +79 -0
  173. package/dist/index-CeEtxDmK.d.mts.map +1 -0
  174. package/dist/{index-JSf9xNIJ.d.cts → index-DU3Twmwh.d.mts} +19 -24
  175. package/dist/index-DU3Twmwh.d.mts.map +1 -0
  176. package/dist/index-fnpjXiA-.d.mts +26 -0
  177. package/dist/index-fnpjXiA-.d.mts.map +1 -0
  178. package/dist/{index-CubPzHd9.d.mts → index-nBQT1tAh.d.cts} +19 -24
  179. package/dist/index-nBQT1tAh.d.cts.map +1 -0
  180. package/dist/index-tE_119SX.d.cts +26 -0
  181. package/dist/index-tE_119SX.d.cts.map +1 -0
  182. package/dist/index.cjs +3 -3
  183. package/dist/index.d.cts +4 -4
  184. package/dist/index.d.mts +4 -4
  185. package/dist/index.mjs +2 -3
  186. package/dist/kysely-CXi49zc2.d.cts +150 -0
  187. package/dist/kysely-CXi49zc2.d.cts.map +1 -0
  188. package/dist/kysely-D3-G5b0j.d.mts +150 -0
  189. package/dist/kysely-D3-G5b0j.d.mts.map +1 -0
  190. package/dist/{lazyAccessors-BoJN3SMd.mjs → lazyAccessors-BHtcqgz2.mjs} +22 -25
  191. package/dist/lazyAccessors-BHtcqgz2.mjs.map +1 -0
  192. package/dist/{lazyAccessors-e3j2oE2m.cjs → lazyAccessors-Dx9NLwJZ.cjs} +72 -76
  193. package/dist/lazyAccessors-Dx9NLwJZ.cjs.map +1 -0
  194. package/dist/object-storage.cjs +18 -10
  195. package/dist/object-storage.cjs.map +1 -1
  196. package/dist/object-storage.d.cts +3 -7
  197. package/dist/object-storage.d.cts.map +1 -1
  198. package/dist/object-storage.d.mts +3 -7
  199. package/dist/object-storage.d.mts.map +1 -1
  200. package/dist/object-storage.mjs +11 -3
  201. package/dist/object-storage.mjs.map +1 -1
  202. package/dist/{processAudits-Dmts9H_b.mjs → processAudits-BpRlPQMW.mjs} +16 -19
  203. package/dist/processAudits-BpRlPQMW.mjs.map +1 -0
  204. package/dist/{processAudits-CGqttuXm.cjs → processAudits-D_2W5x8k.cjs} +26 -30
  205. package/dist/processAudits-D_2W5x8k.cjs.map +1 -0
  206. package/dist/queue/index.cjs +25 -21
  207. package/dist/queue/index.cjs.map +1 -1
  208. package/dist/queue/index.d.cts +8 -15
  209. package/dist/queue/index.d.cts.map +1 -1
  210. package/dist/queue/index.d.mts +8 -15
  211. package/dist/queue/index.d.mts.map +1 -1
  212. package/dist/queue/index.mjs +15 -11
  213. package/dist/queue/index.mjs.map +1 -1
  214. package/dist/rest-api.cjs +88 -62
  215. package/dist/rest-api.cjs.map +1 -1
  216. package/dist/rest-api.d.cts +62 -60
  217. package/dist/rest-api.d.cts.map +1 -1
  218. package/dist/rest-api.d.mts +62 -60
  219. package/dist/rest-api.d.mts.map +1 -1
  220. package/dist/rest-api.mjs +80 -54
  221. package/dist/rest-api.mjs.map +1 -1
  222. package/dist/{chunk-DWy1uDak.cjs → rolldown-runtime-y5ARvAq5.cjs} +14 -18
  223. package/dist/site.cjs +33 -9
  224. package/dist/site.cjs.map +1 -1
  225. package/dist/site.d.cts +11 -22
  226. package/dist/site.d.cts.map +1 -1
  227. package/dist/site.d.mts +11 -22
  228. package/dist/site.d.mts.map +1 -1
  229. package/dist/site.mjs +29 -5
  230. package/dist/site.mjs.map +1 -1
  231. package/dist/subscribers/index.cjs +2 -11
  232. package/dist/subscribers/index.d.cts +3 -14
  233. package/dist/subscribers/index.d.mts +3 -14
  234. package/dist/subscribers/index.mjs +2 -11
  235. package/dist/surfaceEnv-CNimK76p.cjs +56 -0
  236. package/dist/surfaceEnv-CNimK76p.cjs.map +1 -0
  237. package/dist/surfaceEnv-wMT5QzgZ.mjs +45 -0
  238. package/dist/surfaceEnv-wMT5QzgZ.mjs.map +1 -0
  239. package/dist/{telemetry-C3L0iS28.d.cts → telemetry-DGcFlVpB.d.cts} +2 -5
  240. package/dist/telemetry-DGcFlVpB.d.cts.map +1 -0
  241. package/dist/{telemetry-D7bVFLGi.d.mts → telemetry-DGcFlVpB.d.mts} +2 -5
  242. package/dist/telemetry-DGcFlVpB.d.mts.map +1 -0
  243. package/dist/topic/index.cjs +18 -20
  244. package/dist/topic/index.cjs.map +1 -1
  245. package/dist/topic/index.d.cts +3 -32
  246. package/dist/topic/index.d.mts +3 -32
  247. package/dist/topic/index.mjs +8 -10
  248. package/dist/topic/index.mjs.map +1 -1
  249. package/dist/{types-BlAkSuGI.d.cts → types-DMuSQeLL.d.cts} +3 -5
  250. package/dist/types-DMuSQeLL.d.cts.map +1 -0
  251. package/dist/{types-aKksMEWL.d.mts → types-DMuSQeLL.d.mts} +3 -5
  252. package/dist/types-DMuSQeLL.d.mts.map +1 -0
  253. package/dist/types.d.cts +1 -1
  254. package/dist/types.d.mts +1 -1
  255. package/dist/types.mjs +1 -0
  256. package/dist/worker.cjs +109 -35
  257. package/dist/worker.cjs.map +1 -1
  258. package/dist/worker.d.cts +87 -42
  259. package/dist/worker.d.cts.map +1 -1
  260. package/dist/worker.d.mts +87 -42
  261. package/dist/worker.d.mts.map +1 -1
  262. package/dist/worker.mjs +104 -30
  263. package/dist/worker.mjs.map +1 -1
  264. package/package.json +59 -55
  265. package/dist/Construct-BD5neF7w.mjs.map +0 -1
  266. package/dist/Construct-C0ijr2qp.d.cts.map +0 -1
  267. package/dist/Construct-Ct8nalEi.d.mts.map +0 -1
  268. package/dist/Construct-CyS3RpTL.cjs.map +0 -1
  269. package/dist/Cron-ByxdOfpE.d.mts.map +0 -1
  270. package/dist/Cron-Wqh464aO.d.cts.map +0 -1
  271. package/dist/CronBuilder-BL0AP6fs.d.mts.map +0 -1
  272. package/dist/CronBuilder-BmABazzH.mjs.map +0 -1
  273. package/dist/CronBuilder-BqpEzMPQ.d.cts.map +0 -1
  274. package/dist/CronBuilder-CkXPJiGO.cjs.map +0 -1
  275. package/dist/Endpoint-2Wg7T7Cq.d.mts.map +0 -1
  276. package/dist/Endpoint-BiaaMEn_.cjs.map +0 -1
  277. package/dist/Endpoint-CH9Fn1AD.d.cts.map +0 -1
  278. package/dist/Endpoint-VIOpSo0S.mjs.map +0 -1
  279. package/dist/EndpointFactory-ChxLZllA.cjs.map +0 -1
  280. package/dist/EndpointFactory-DTTCkGEL.mjs.map +0 -1
  281. package/dist/HonoEndpointAdaptor-NKQQQbBY.mjs.map +0 -1
  282. package/dist/Queue-D7ZuwBhy.d.cts.map +0 -1
  283. package/dist/Queue-gVGfi2Yk.d.mts.map +0 -1
  284. package/dist/Subscriber-2mEi0ImH.d.cts.map +0 -1
  285. package/dist/Subscriber-xTJ9ayPN.d.mts.map +0 -1
  286. package/dist/SubscriberBuilder-4OPehf2R.cjs.map +0 -1
  287. package/dist/SubscriberBuilder-BjkbeT9l.mjs.map +0 -1
  288. package/dist/SubscriberBuilder-Dptmo-1A.d.mts.map +0 -1
  289. package/dist/SubscriberBuilder-waNhzjSM.d.cts.map +0 -1
  290. package/dist/Topic-19QeHBIR.d.cts.map +0 -1
  291. package/dist/Topic-DuFeqkBh.d.mts.map +0 -1
  292. package/dist/auth.d.cts.map +0 -1
  293. package/dist/auth.d.mts.map +0 -1
  294. package/dist/cache-0ANvRQnD.mjs +0 -51
  295. package/dist/cache-0ANvRQnD.mjs.map +0 -1
  296. package/dist/cache-3WSvAulx.cjs +0 -57
  297. package/dist/cache-3WSvAulx.cjs.map +0 -1
  298. package/dist/cache-BrRz3fEB.d.mts.map +0 -1
  299. package/dist/cache-BtZY_tHe.d.cts.map +0 -1
  300. package/dist/clone-DblgEZZa.mjs.map +0 -1
  301. package/dist/clone-Dy0cR2SZ.cjs.map +0 -1
  302. package/dist/construct-interface-BfjcOD_E.cjs +0 -117
  303. package/dist/construct-interface-BfjcOD_E.cjs.map +0 -1
  304. package/dist/construct-interface-D9d4Gm4p.d.cts.map +0 -1
  305. package/dist/construct-interface-Z4CpS8tK.mjs +0 -81
  306. package/dist/construct-interface-Z4CpS8tK.mjs.map +0 -1
  307. package/dist/construct-interface-g5GM5pwR.d.mts.map +0 -1
  308. package/dist/database/kysely.d.cts.map +0 -1
  309. package/dist/database/kysely.d.mts.map +0 -1
  310. package/dist/functions-Bd3TPxid.cjs.map +0 -1
  311. package/dist/functions-Cxbo-pEd.mjs.map +0 -1
  312. package/dist/index-BxHDdy6a.d.mts.map +0 -1
  313. package/dist/index-CubPzHd9.d.mts.map +0 -1
  314. package/dist/index-JSf9xNIJ.d.cts.map +0 -1
  315. package/dist/index-V2nksZIJ.d.cts.map +0 -1
  316. package/dist/lazyAccessors-BoJN3SMd.mjs.map +0 -1
  317. package/dist/lazyAccessors-e3j2oE2m.cjs.map +0 -1
  318. package/dist/processAudits-CGqttuXm.cjs.map +0 -1
  319. package/dist/processAudits-Dmts9H_b.mjs.map +0 -1
  320. package/dist/subscribers/index.cjs.map +0 -1
  321. package/dist/subscribers/index.d.cts.map +0 -1
  322. package/dist/subscribers/index.d.mts.map +0 -1
  323. package/dist/subscribers/index.mjs.map +0 -1
  324. package/dist/surfaceEnv-BFXEms2f.cjs +0 -39
  325. package/dist/surfaceEnv-BFXEms2f.cjs.map +0 -1
  326. package/dist/surfaceEnv-C3Ktahea.mjs +0 -27
  327. package/dist/surfaceEnv-C3Ktahea.mjs.map +0 -1
  328. package/dist/telemetry-C3L0iS28.d.cts.map +0 -1
  329. package/dist/telemetry-D7bVFLGi.d.mts.map +0 -1
  330. package/dist/topic/index.d.cts.map +0 -1
  331. package/dist/topic/index.d.mts.map +0 -1
  332. package/dist/types-BlAkSuGI.d.cts.map +0 -1
  333. package/dist/types-aKksMEWL.d.mts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"object-storage.mjs","names":["id: ConstructName<TName>","options: ObjectStorageOptions","options"],"sources":["../src/object-storage.ts"],"sourcesContent":["/**\n * `ObjectStorage` — a declared bucket.\n *\n * Where the three packages meet: it implements the construct contract, derives\n * its env key through `@geekmidas/manifest`, and hands back a\n * `@geekmidas/storage` client. It names no cloud — `--target=aws` fills the\n * injected URL with S3's values, local dev with MinIO's.\n */\n\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\nimport { createStorageClient, type StorageClient } from '@geekmidas/storage';\nimport type { Construct } from './construct-interface';\n\nexport interface ObjectStorageOptions {\n\t/** Keep previous versions of an object. */\n\tversioned?: boolean;\n}\n\nexport class ObjectStorage<TName extends string = string>\n\timplements Construct<TName, StorageClient>\n{\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, StorageClient>;\n\n\t/**\n\t * Declared once and read by both `declare()` and `connect()`, so the key the\n\t * build publishes and the key the client reads cannot drift — the whole point\n\t * of the construct owning both faces.\n\t */\n\tprivate readonly keys: { url: string };\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly options: ObjectStorageOptions = {},\n\t) {\n\t\t// Canonicalises, so `uploads` and `Uploads` are one construct rather than\n\t\t// two that collide. Throws on anything that cannot become a valid id.\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.keys = { url: provideKey(canonical, 'url') };\n\n\t\t// A field, not a getter: consumers cache services by object identity.\n\t\tthis.service = {\n\t\t\tserviceName: serviceKey(canonical) as Uncapitalize<TName>,\n\t\t\tregister: (options) => this.connect(options),\n\t\t};\n\t}\n\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'objects',\n\t\t\t\tid: this.id,\n\t\t\t\tprovides: [this.keys.url],\n\t\t\t\t...(this.options.versioned ? { versioned: true } : {}),\n\t\t\t},\n\t\t];\n\t}\n\n\t/**\n\t * Builds the client from the single URL the adapter supplied.\n\t *\n\t * The URL's scheme selects the driver, so this construct imports no provider\n\t * and an app that never touches S3 never resolves the AWS SDK. Whoever\n\t * assembles the application registers the drivers its target needs.\n\t */\n\tprivate async connect({\n\t\tenvParser,\n\t}: ServiceRegisterOptions): Promise<StorageClient> {\n\t\tconst { url } = envParser\n\t\t\t.create((get) => ({ url: get(this.keys.url).string() }))\n\t\t\t.parse();\n\n\t\treturn createStorageClient(url);\n\t}\n}\n"],"mappings":";;;;AAyBA,IAAa,gBAAb,MAEA;CACC,AAAS;CACT,AAAS;;;;;;CAOT,AAAiB;CAEjB,YACCA,IACiBC,UAAgC,CAAE,GAClD;EADgB;EAIjB,MAAM,YAAY,YAAY,GAAa;AAE3C,OAAK,KAAK;AACV,OAAK,OAAO,EAAE,KAAK,WAAW,WAAW,MAAM,CAAE;AAGjD,OAAK,UAAU;GACd,aAAa,WAAW,UAAU;GAClC,UAAU,CAACC,cAAY,KAAK,QAAQA,UAAQ;EAC5C;CACD;CAED,UAAyB;AACxB,SAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,UAAU,CAAC,KAAK,KAAK,GAAI;GACzB,GAAI,KAAK,QAAQ,YAAY,EAAE,WAAW,KAAM,IAAG,CAAE;EACrD,CACD;CACD;;;;;;;;CASD,MAAc,QAAQ,EACrB,WACwB,EAA0B;EAClD,MAAM,EAAE,KAAK,GAAG,UACd,OAAO,CAAC,SAAS,EAAE,KAAK,IAAI,KAAK,KAAK,IAAI,CAAC,QAAQ,CAAE,GAAE,CACvD,OAAO;AAET,SAAO,oBAAoB,IAAI;CAC/B;AACD"}
1
+ {"version":3,"file":"object-storage.mjs","names":[],"sources":["../src/object-storage.ts"],"sourcesContent":["/**\n * `ObjectStorage` — a declared bucket.\n *\n * Where the three packages meet: it implements the construct contract, derives\n * its env key through `@geekmidas/manifest`, and hands back a\n * `@geekmidas/storage` client. It names no cloud — `--target=aws` fills the\n * injected URL with S3's values, local dev with MinIO's.\n */\n\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\nimport { createStorageClient, type StorageClient } from '@geekmidas/storage';\nimport type { Construct } from './construct-interface';\n\nexport interface ObjectStorageOptions {\n\t/** Keep previous versions of an object. */\n\tversioned?: boolean;\n}\n\nexport class ObjectStorage<TName extends string = string>\n\timplements Construct<TName, StorageClient>\n{\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, StorageClient>;\n\n\t/**\n\t * Declared once and read by both `declare()` and `connect()`, so the key the\n\t * build publishes and the key the client reads cannot drift — the whole point\n\t * of the construct owning both faces.\n\t */\n\tprivate readonly keys: { url: string };\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly options: ObjectStorageOptions = {},\n\t) {\n\t\t// Canonicalises, so `uploads` and `Uploads` are one construct rather than\n\t\t// two that collide. Throws on anything that cannot become a valid id.\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.keys = { url: provideKey(canonical, 'url') };\n\n\t\t// A field, not a getter: consumers cache services by object identity.\n\t\tthis.service = {\n\t\t\tserviceName: serviceKey(canonical) as Uncapitalize<TName>,\n\t\t\tregister: (options) => this.connect(options),\n\t\t};\n\t}\n\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'objects',\n\t\t\t\tid: this.id,\n\t\t\t\tprovides: [this.keys.url],\n\t\t\t\t...(this.options.versioned ? { versioned: true } : {}),\n\t\t\t},\n\t\t];\n\t}\n\n\t/**\n\t * Builds the client from the single URL the adapter supplied.\n\t *\n\t * The URL's scheme selects the driver, so this construct imports no provider\n\t * and an app that never touches S3 never resolves the AWS SDK. Whoever\n\t * assembles the application registers the drivers its target needs.\n\t */\n\tprivate async connect({\n\t\tenvParser,\n\t}: ServiceRegisterOptions): Promise<StorageClient> {\n\t\tconst { url } = envParser\n\t\t\t.create((get) => ({ url: get(this.keys.url).string() }))\n\t\t\t.parse();\n\n\t\treturn createStorageClient(url);\n\t}\n}\n"],"mappings":";;;;;;;;;;;AAyBA,IAAa,gBAAb,MAEA;CAamB;CAZlB;CACA;;;;;;CAOA;CAEA,YACC,IACA,UAAiD,CAAC,GACjD;EADgB,KAAA,UAAA;EAIjB,MAAM,YAAY,YAAY,EAAY;EAE1C,KAAK,KAAK;EACV,KAAK,OAAO,EAAE,KAAK,WAAW,WAAW,KAAK,EAAE;EAGhD,KAAK,UAAU;GACd,aAAa,WAAW,SAAS;GACjC,WAAW,YAAY,KAAK,QAAQ,OAAO;EAC5C;CACD;CAEA,UAAyB;EACxB,OAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,UAAU,CAAC,KAAK,KAAK,GAAG;GACxB,GAAI,KAAK,QAAQ,YAAY,EAAE,WAAW,KAAK,IAAI,CAAC;EACrD,CACD;CACD;;;;;;;;CASA,MAAc,QAAQ,EACrB,aACkD;EAClD,MAAM,EAAE,QAAQ,UACd,QAAQ,SAAS,EAAE,KAAK,IAAI,KAAK,KAAK,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CACvD,MAAM;EAER,OAAO,oBAAoB,GAAG;CAC/B;AACD"}
@@ -1,5 +1,4 @@
1
1
  import { DefaultAuditor } from "@geekmidas/audit";
2
-
3
2
  //#region src/endpoints/processAudits.ts
4
3
  /**
5
4
  * Create audit context for handler execution.
@@ -12,9 +11,8 @@ import { DefaultAuditor } from "@geekmidas/audit";
12
11
  * @returns Audit context with auditor and storage, or undefined if not configured
13
12
  */
14
13
  async function createAuditContext(endpoint, serviceDiscovery, logger, ctx) {
15
- if (!endpoint.auditorStorageService) return void 0;
16
- const services = await serviceDiscovery.register([endpoint.auditorStorageService]);
17
- const storage = services[endpoint.auditorStorageService.serviceName];
14
+ if (!endpoint.auditorStorageService) return;
15
+ const storage = (await serviceDiscovery.register([endpoint.auditorStorageService]))[endpoint.auditorStorageService.serviceName];
18
16
  let actor = {
19
17
  id: "system",
20
18
  type: "system"
@@ -30,16 +28,15 @@ async function createAuditContext(endpoint, serviceDiscovery, logger, ctx) {
30
28
  } catch (error) {
31
29
  logger.error(error, "Failed to extract actor for audits");
32
30
  }
33
- const auditor = new DefaultAuditor({
34
- actor,
35
- storage,
36
- metadata: {
37
- endpoint: endpoint.route,
38
- method: endpoint.method
39
- }
40
- });
41
31
  return {
42
- auditor,
32
+ auditor: new DefaultAuditor({
33
+ actor,
34
+ storage,
35
+ metadata: {
36
+ endpoint: endpoint.route,
37
+ method: endpoint.method
38
+ }
39
+ }),
43
40
  storage
44
41
  };
45
42
  }
@@ -65,16 +62,16 @@ async function executeWithAuditTransaction(auditContext, handler, onComplete, op
65
62
  if (!auditContext) return handler(void 0);
66
63
  const { auditor, storage } = auditContext;
67
64
  if (storage.withTransaction) return storage.withTransaction(auditor, async () => {
68
- const response$1 = await handler(auditor);
69
- if (onComplete) await onComplete(response$1, auditor);
70
- return response$1;
65
+ const response = await handler(auditor);
66
+ if (onComplete) await onComplete(response, auditor);
67
+ return response;
71
68
  }, options?.db);
72
69
  const response = await handler(auditor);
73
70
  if (onComplete) await onComplete(response, auditor);
74
71
  await auditor.flush();
75
72
  return response;
76
73
  }
77
-
78
74
  //#endregion
79
- export { createAuditContext, executeWithAuditTransaction };
80
- //# sourceMappingURL=processAudits-Dmts9H_b.mjs.map
75
+ export { executeWithAuditTransaction as n, createAuditContext as t };
76
+
77
+ //# sourceMappingURL=processAudits-BpRlPQMW.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processAudits-BpRlPQMW.mjs","names":[],"sources":["../src/endpoints/processAudits.ts"],"sourcesContent":["import type {\n\tAuditActor,\n\tAuditableAction,\n\tAuditor,\n\tAuditStorage,\n} from '@geekmidas/audit';\nimport { DefaultAuditor } from '@geekmidas/audit';\nimport type { Logger } from '@geekmidas/logger';\nimport type { InferStandardSchema } from '@geekmidas/schema';\nimport type { Service, ServiceDiscovery } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { ActorExtractor, MappedAudit } from './audit';\nimport type { CookieFn, Endpoint, HeaderFn } from './Endpoint';\n\n/**\n * Process declarative audit definitions after successful endpoint execution.\n * Similar to publishConstructEvents for events.\n *\n * @param endpoint - The endpoint with audit configuration\n * @param response - The handler response to generate audit payloads from\n * @param serviceDiscovery - Service discovery for registering audit storage\n * @param logger - Logger for debug/error messages\n * @param ctx - Request context (session, headers, cookies, services)\n * @param existingAuditor - Optional existing auditor instance (e.g., from handler context).\n * If provided, uses this auditor (with its stored transaction).\n * If not provided, creates a new auditor.\n */\nexport async function processEndpointAudits<\n\tTServices extends Service[] = [],\n\tTSession = unknown,\n\tTLogger extends Logger = Logger,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\n\tTAuditStorage extends AuditStorage | undefined = undefined,\n\tTAuditStorageServiceName extends string = string,\n\tTAuditAction extends AuditableAction<string, unknown> = AuditableAction<\n\t\tstring,\n\t\tunknown\n\t>,\n>(\n\tendpoint: Endpoint<\n\t\tany,\n\t\tany,\n\t\tany,\n\t\tOutSchema,\n\t\tTServices,\n\t\tTLogger,\n\t\tTSession,\n\t\tany,\n\t\tany,\n\t\tTAuditStorage,\n\t\tTAuditStorageServiceName,\n\t\tTAuditAction\n\t>,\n\tresponse: InferStandardSchema<OutSchema>,\n\tserviceDiscovery: ServiceDiscovery<any>,\n\tlogger: TLogger,\n\tctx: {\n\t\tsession: TSession;\n\t\theader: HeaderFn;\n\t\tcookie: CookieFn;\n\t\tservices: Record<string, unknown>;\n\t},\n\texistingAuditor?: Auditor<TAuditAction>,\n): Promise<void> {\n\ttry {\n\t\tconst audits = endpoint.audits as MappedAudit<TAuditAction, OutSchema>[];\n\n\t\t// If we have an existing auditor (from handler context), we need to flush\n\t\t// any manual audits it collected, even if there are no declarative audits\n\t\tconst hasExistingRecords =\n\t\t\texistingAuditor && existingAuditor.getRecords().length > 0;\n\n\t\t// Skip if no declarative audits and no existing records to flush\n\t\tif (!audits?.length && !hasExistingRecords) {\n\t\t\tlogger.debug('No audits to process');\n\t\t\treturn;\n\t\t}\n\n\t\t// If no auditor storage service and we have things to process, warn\n\t\tif (!endpoint.auditorStorageService) {\n\t\t\tif (hasExistingRecords || audits?.length) {\n\t\t\t\tlogger.warn('No auditor storage service available');\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// Get or create auditor\n\t\tlet auditor: Auditor<TAuditAction>;\n\n\t\tif (existingAuditor) {\n\t\t\t// Use existing auditor (preserves stored transaction and manual audits)\n\t\t\tauditor = existingAuditor;\n\t\t\tlogger.debug('Using existing auditor from handler context');\n\t\t} else {\n\t\t\t// Create new auditor (backward compatibility)\n\t\t\tconst services = await serviceDiscovery.register([\n\t\t\t\tendpoint.auditorStorageService,\n\t\t\t]);\n\t\t\tconst storage = services[\n\t\t\t\tendpoint.auditorStorageService.serviceName\n\t\t\t] as AuditStorage;\n\n\t\t\t// Extract actor if configured\n\t\t\tlet actor: AuditActor = { id: 'system', type: 'system' };\n\t\t\tif (endpoint.actorExtractor) {\n\t\t\t\ttry {\n\t\t\t\t\tactor = await (\n\t\t\t\t\t\tendpoint.actorExtractor as ActorExtractor<\n\t\t\t\t\t\t\tTServices,\n\t\t\t\t\t\t\tTSession,\n\t\t\t\t\t\t\tTLogger\n\t\t\t\t\t\t>\n\t\t\t\t\t)({\n\t\t\t\t\t\tservices: ctx.services as any,\n\t\t\t\t\t\tsession: ctx.session,\n\t\t\t\t\t\theader: ctx.header,\n\t\t\t\t\t\tcookie: ctx.cookie,\n\t\t\t\t\t\tlogger,\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tlogger.error(error as Error, 'Failed to extract actor for audits');\n\t\t\t\t\t// Continue with system actor\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tauditor = new DefaultAuditor<TAuditAction>({\n\t\t\t\tactor,\n\t\t\t\tstorage,\n\t\t\t\tmetadata: {\n\t\t\t\t\tendpoint: endpoint.route,\n\t\t\t\t\tmethod: endpoint.method,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\t// Process each declarative audit\n\t\tif (audits?.length) {\n\t\t\tfor (const audit of audits) {\n\t\t\t\tlogger.debug({ audit: audit.type }, 'Processing declarative audit');\n\n\t\t\t\t// Check when condition\n\t\t\t\tif (audit.when && !audit.when(response as any)) {\n\t\t\t\t\tlogger.debug(\n\t\t\t\t\t\t{ audit: audit.type },\n\t\t\t\t\t\t'Audit skipped due to when condition',\n\t\t\t\t\t);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// Extract payload\n\t\t\t\tconst payload = audit.payload(response as any);\n\n\t\t\t\t// Extract entityId if configured\n\t\t\t\tconst entityId = audit.entityId?.(response as any);\n\n\t\t\t\t// Record the audit\n\t\t\t\tauditor.audit(audit.type as any, payload as any, {\n\t\t\t\t\ttable: audit.table,\n\t\t\t\t\tentityId,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// Flush audits to storage\n\t\t// Note: If existingAuditor has a stored transaction (via setTransaction),\n\t\t// flush() will use it automatically\n\t\tconst recordCount = auditor.getRecords().length;\n\t\tif (recordCount > 0) {\n\t\t\t// Check if auditor has a stored transaction (for logging purposes)\n\t\t\tconst trx =\n\t\t\t\t'getTransaction' in auditor\n\t\t\t\t\t? (auditor as { getTransaction(): unknown }).getTransaction()\n\t\t\t\t\t: undefined;\n\t\t\tlogger.debug(\n\t\t\t\t{ auditCount: recordCount, hasTransaction: !!trx },\n\t\t\t\t'Flushing audits',\n\t\t\t);\n\t\t\tawait auditor.flush();\n\t\t}\n\t} catch (error) {\n\t\tlogger.error(error as Error, 'Failed to process audits');\n\t\t// Don't rethrow - audit failures shouldn't fail the request\n\t}\n}\n\n/**\n * Context for audit-aware handler execution.\n */\nexport interface AuditExecutionContext<\n\tTAuditAction extends AuditableAction<string, unknown> = AuditableAction<\n\t\tstring,\n\t\tunknown\n\t>,\n> {\n\t/** The auditor instance for recording audits */\n\tauditor: Auditor<TAuditAction>;\n\t/** The audit storage instance */\n\tstorage: AuditStorage;\n}\n\n/**\n * Create audit context for handler execution.\n * Returns the auditor and storage for use in the handler.\n *\n * @param endpoint - The endpoint with audit configuration\n * @param serviceDiscovery - Service discovery for getting audit storage\n * @param logger - Logger for debug/error messages\n * @param ctx - Request context for actor extraction\n * @returns Audit context with auditor and storage, or undefined if not configured\n */\nexport async function createAuditContext<\n\tTServices extends Service[] = [],\n\tTSession = unknown,\n\tTLogger extends Logger = Logger,\n\tTAuditStorage extends AuditStorage | undefined = undefined,\n\tTAuditStorageServiceName extends string = string,\n\tTAuditAction extends AuditableAction<string, unknown> = AuditableAction<\n\t\tstring,\n\t\tunknown\n\t>,\n\tTDatabase = undefined,\n\tTDatabaseServiceName extends string = string,\n>(\n\tendpoint: Endpoint<\n\t\tany,\n\t\tany,\n\t\tany,\n\t\tany,\n\t\tTServices,\n\t\tTLogger,\n\t\tTSession,\n\t\tany,\n\t\tany,\n\t\tTAuditStorage,\n\t\tTAuditStorageServiceName,\n\t\tTAuditAction,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t>,\n\tserviceDiscovery: ServiceDiscovery<any>,\n\tlogger: TLogger,\n\tctx: {\n\t\tsession: TSession;\n\t\theader: HeaderFn;\n\t\tcookie: CookieFn;\n\t\tservices: Record<string, unknown>;\n\t},\n): Promise<AuditExecutionContext<TAuditAction> | undefined> {\n\tif (!endpoint.auditorStorageService) {\n\t\treturn undefined;\n\t}\n\n\tconst services = await serviceDiscovery.register([\n\t\tendpoint.auditorStorageService,\n\t]);\n\tconst storage = services[\n\t\tendpoint.auditorStorageService.serviceName\n\t] as AuditStorage;\n\n\t// Extract actor if configured\n\tlet actor: AuditActor = { id: 'system', type: 'system' };\n\tif (endpoint.actorExtractor) {\n\t\ttry {\n\t\t\tactor = await (\n\t\t\t\tendpoint.actorExtractor as ActorExtractor<TServices, TSession, TLogger>\n\t\t\t)({\n\t\t\t\tservices: ctx.services as any,\n\t\t\t\tsession: ctx.session,\n\t\t\t\theader: ctx.header,\n\t\t\t\tcookie: ctx.cookie,\n\t\t\t\tlogger,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tlogger.error(error as Error, 'Failed to extract actor for audits');\n\t\t}\n\t}\n\n\tconst auditor = new DefaultAuditor<TAuditAction>({\n\t\tactor,\n\t\tstorage,\n\t\tmetadata: {\n\t\t\tendpoint: endpoint.route,\n\t\t\tmethod: endpoint.method,\n\t\t},\n\t});\n\n\treturn { auditor, storage };\n}\n\n/**\n * Options for executeWithAuditTransaction.\n */\nexport interface ExecuteWithAuditTransactionOptions {\n\t/**\n\t * Database connection to use for the transaction.\n\t * If this is already a transaction, it will be reused instead of creating a nested one.\n\t * If not provided, the storage's internal database is used.\n\t */\n\tdb?: unknown;\n}\n\n/**\n * Execute a handler with automatic audit transaction support.\n * If the audit storage provides a withTransaction method, wraps execution\n * in a transaction so audits are atomic with handler's database operations.\n *\n * This is database-agnostic - each storage implementation provides its own\n * transaction handling based on the underlying database (Kysely, Drizzle, etc.).\n *\n * If the db parameter is provided and is already a transaction, the storage\n * will reuse it instead of creating a nested transaction (similar to\n * packages/db/src/kysely.ts#withTransaction).\n *\n * @param auditContext - The audit context from createAuditContext\n * @param handler - The handler function to execute (receives auditor)\n * @param onComplete - Called after handler with response, to process declarative audits\n * @param options - Optional configuration including database connection\n * @returns The handler result\n */\nexport async function executeWithAuditTransaction<\n\tT,\n\tTAuditAction extends AuditableAction<string, unknown> = AuditableAction<\n\t\tstring,\n\t\tunknown\n\t>,\n>(\n\tauditContext: AuditExecutionContext<TAuditAction> | undefined,\n\thandler: (auditor?: Auditor<TAuditAction>) => Promise<T>,\n\tonComplete?: (response: T, auditor: Auditor<TAuditAction>) => Promise<void>,\n\toptions?: ExecuteWithAuditTransactionOptions,\n): Promise<T> {\n\t// No audit context - just run handler\n\tif (!auditContext) {\n\t\treturn handler(undefined);\n\t}\n\n\tconst { auditor, storage } = auditContext;\n\n\t// Check if storage provides a transaction wrapper\n\tif (storage.withTransaction) {\n\t\t// Wrap in transaction - audits are atomic with handler operations\n\t\t// The storage's withTransaction handles setTransaction and flush\n\t\t// Pass db so existing transactions are reused\n\t\treturn storage.withTransaction(\n\t\t\tauditor,\n\t\t\tasync () => {\n\t\t\t\tconst response = await handler(auditor);\n\n\t\t\t\t// Process declarative audits within the transaction\n\t\t\t\tif (onComplete) {\n\t\t\t\t\tawait onComplete(response, auditor);\n\t\t\t\t}\n\n\t\t\t\treturn response;\n\t\t\t},\n\t\t\toptions?.db,\n\t\t);\n\t}\n\n\t// No transaction support - run handler and flush audits after\n\tconst response = await handler(auditor);\n\n\tif (onComplete) {\n\t\tawait onComplete(response, auditor);\n\t}\n\n\t// Flush audits (no transaction)\n\tawait auditor.flush();\n\n\treturn response;\n}\n"],"mappings":";;;;;;;;;;;;AAkNA,eAAsB,mBAarB,UAgBA,kBACA,QACA,KAM2D;CAC3D,IAAI,CAAC,SAAS,uBACb;CAMD,MAAM,WAAU,MAHO,iBAAiB,SAAS,CAChD,SAAS,qBACV,CAAC,EAAA,CAEA,SAAS,sBAAsB;CAIhC,IAAI,QAAoB;EAAE,IAAI;EAAU,MAAM;CAAS;CACvD,IAAI,SAAS,gBACZ,IAAI;EACH,QAAQ,MACP,SAAS,eACR;GACD,UAAU,IAAI;GACd,SAAS,IAAI;GACb,QAAQ,IAAI;GACZ,QAAQ,IAAI;GACZ;EACD,CAAC;CACF,SAAS,OAAO;EACf,OAAO,MAAM,OAAgB,oCAAoC;CAClE;CAYD,OAAO;EAAE,SAAA,IATW,eAA6B;GAChD;GACA;GACA,UAAU;IACT,UAAU,SAAS;IACnB,QAAQ,SAAS;GAClB;EACD,CAEe;EAAG;CAAQ;AAC3B;;;;;;;;;;;;;;;;;;;AAgCA,eAAsB,4BAOrB,cACA,SACA,YACA,SACa;CAEb,IAAI,CAAC,cACJ,OAAO,QAAQ,KAAA,CAAS;CAGzB,MAAM,EAAE,SAAS,YAAY;CAG7B,IAAI,QAAQ,iBAIX,OAAO,QAAQ,gBACd,SACA,YAAY;EACX,MAAM,WAAW,MAAM,QAAQ,OAAO;EAGtC,IAAI,YACH,MAAM,WAAW,UAAU,OAAO;EAGnC,OAAO;CACR,GACA,SAAS,EACV;CAID,MAAM,WAAW,MAAM,QAAQ,OAAO;CAEtC,IAAI,YACH,MAAM,WAAW,UAAU,OAAO;CAInC,MAAM,QAAQ,MAAM;CAEpB,OAAO;AACR"}
@@ -1,6 +1,4 @@
1
- const require_chunk = require('./chunk-DWy1uDak.cjs');
2
- const __geekmidas_audit = require_chunk.__toESM(require("@geekmidas/audit"));
3
-
1
+ let _geekmidas_audit = require("@geekmidas/audit");
4
2
  //#region src/endpoints/processAudits.ts
5
3
  /**
6
4
  * Create audit context for handler execution.
@@ -13,9 +11,8 @@ const __geekmidas_audit = require_chunk.__toESM(require("@geekmidas/audit"));
13
11
  * @returns Audit context with auditor and storage, or undefined if not configured
14
12
  */
15
13
  async function createAuditContext(endpoint, serviceDiscovery, logger, ctx) {
16
- if (!endpoint.auditorStorageService) return void 0;
17
- const services = await serviceDiscovery.register([endpoint.auditorStorageService]);
18
- const storage = services[endpoint.auditorStorageService.serviceName];
14
+ if (!endpoint.auditorStorageService) return;
15
+ const storage = (await serviceDiscovery.register([endpoint.auditorStorageService]))[endpoint.auditorStorageService.serviceName];
19
16
  let actor = {
20
17
  id: "system",
21
18
  type: "system"
@@ -31,16 +28,15 @@ async function createAuditContext(endpoint, serviceDiscovery, logger, ctx) {
31
28
  } catch (error) {
32
29
  logger.error(error, "Failed to extract actor for audits");
33
30
  }
34
- const auditor = new __geekmidas_audit.DefaultAuditor({
35
- actor,
36
- storage,
37
- metadata: {
38
- endpoint: endpoint.route,
39
- method: endpoint.method
40
- }
41
- });
42
31
  return {
43
- auditor,
32
+ auditor: new _geekmidas_audit.DefaultAuditor({
33
+ actor,
34
+ storage,
35
+ metadata: {
36
+ endpoint: endpoint.route,
37
+ method: endpoint.method
38
+ }
39
+ }),
44
40
  storage
45
41
  };
46
42
  }
@@ -66,27 +62,27 @@ async function executeWithAuditTransaction(auditContext, handler, onComplete, op
66
62
  if (!auditContext) return handler(void 0);
67
63
  const { auditor, storage } = auditContext;
68
64
  if (storage.withTransaction) return storage.withTransaction(auditor, async () => {
69
- const response$1 = await handler(auditor);
70
- if (onComplete) await onComplete(response$1, auditor);
71
- return response$1;
65
+ const response = await handler(auditor);
66
+ if (onComplete) await onComplete(response, auditor);
67
+ return response;
72
68
  }, options?.db);
73
69
  const response = await handler(auditor);
74
70
  if (onComplete) await onComplete(response, auditor);
75
71
  await auditor.flush();
76
72
  return response;
77
73
  }
78
-
79
74
  //#endregion
80
- Object.defineProperty(exports, 'createAuditContext', {
81
- enumerable: true,
82
- get: function () {
83
- return createAuditContext;
84
- }
75
+ Object.defineProperty(exports, "createAuditContext", {
76
+ enumerable: true,
77
+ get: function() {
78
+ return createAuditContext;
79
+ }
85
80
  });
86
- Object.defineProperty(exports, 'executeWithAuditTransaction', {
87
- enumerable: true,
88
- get: function () {
89
- return executeWithAuditTransaction;
90
- }
81
+ Object.defineProperty(exports, "executeWithAuditTransaction", {
82
+ enumerable: true,
83
+ get: function() {
84
+ return executeWithAuditTransaction;
85
+ }
91
86
  });
92
- //# sourceMappingURL=processAudits-CGqttuXm.cjs.map
87
+
88
+ //# sourceMappingURL=processAudits-D_2W5x8k.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processAudits-D_2W5x8k.cjs","names":["DefaultAuditor"],"sources":["../src/endpoints/processAudits.ts"],"sourcesContent":["import type {\n\tAuditActor,\n\tAuditableAction,\n\tAuditor,\n\tAuditStorage,\n} from '@geekmidas/audit';\nimport { DefaultAuditor } from '@geekmidas/audit';\nimport type { Logger } from '@geekmidas/logger';\nimport type { InferStandardSchema } from '@geekmidas/schema';\nimport type { Service, ServiceDiscovery } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { ActorExtractor, MappedAudit } from './audit';\nimport type { CookieFn, Endpoint, HeaderFn } from './Endpoint';\n\n/**\n * Process declarative audit definitions after successful endpoint execution.\n * Similar to publishConstructEvents for events.\n *\n * @param endpoint - The endpoint with audit configuration\n * @param response - The handler response to generate audit payloads from\n * @param serviceDiscovery - Service discovery for registering audit storage\n * @param logger - Logger for debug/error messages\n * @param ctx - Request context (session, headers, cookies, services)\n * @param existingAuditor - Optional existing auditor instance (e.g., from handler context).\n * If provided, uses this auditor (with its stored transaction).\n * If not provided, creates a new auditor.\n */\nexport async function processEndpointAudits<\n\tTServices extends Service[] = [],\n\tTSession = unknown,\n\tTLogger extends Logger = Logger,\n\tOutSchema extends StandardSchemaV1 | undefined = undefined,\n\tTAuditStorage extends AuditStorage | undefined = undefined,\n\tTAuditStorageServiceName extends string = string,\n\tTAuditAction extends AuditableAction<string, unknown> = AuditableAction<\n\t\tstring,\n\t\tunknown\n\t>,\n>(\n\tendpoint: Endpoint<\n\t\tany,\n\t\tany,\n\t\tany,\n\t\tOutSchema,\n\t\tTServices,\n\t\tTLogger,\n\t\tTSession,\n\t\tany,\n\t\tany,\n\t\tTAuditStorage,\n\t\tTAuditStorageServiceName,\n\t\tTAuditAction\n\t>,\n\tresponse: InferStandardSchema<OutSchema>,\n\tserviceDiscovery: ServiceDiscovery<any>,\n\tlogger: TLogger,\n\tctx: {\n\t\tsession: TSession;\n\t\theader: HeaderFn;\n\t\tcookie: CookieFn;\n\t\tservices: Record<string, unknown>;\n\t},\n\texistingAuditor?: Auditor<TAuditAction>,\n): Promise<void> {\n\ttry {\n\t\tconst audits = endpoint.audits as MappedAudit<TAuditAction, OutSchema>[];\n\n\t\t// If we have an existing auditor (from handler context), we need to flush\n\t\t// any manual audits it collected, even if there are no declarative audits\n\t\tconst hasExistingRecords =\n\t\t\texistingAuditor && existingAuditor.getRecords().length > 0;\n\n\t\t// Skip if no declarative audits and no existing records to flush\n\t\tif (!audits?.length && !hasExistingRecords) {\n\t\t\tlogger.debug('No audits to process');\n\t\t\treturn;\n\t\t}\n\n\t\t// If no auditor storage service and we have things to process, warn\n\t\tif (!endpoint.auditorStorageService) {\n\t\t\tif (hasExistingRecords || audits?.length) {\n\t\t\t\tlogger.warn('No auditor storage service available');\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// Get or create auditor\n\t\tlet auditor: Auditor<TAuditAction>;\n\n\t\tif (existingAuditor) {\n\t\t\t// Use existing auditor (preserves stored transaction and manual audits)\n\t\t\tauditor = existingAuditor;\n\t\t\tlogger.debug('Using existing auditor from handler context');\n\t\t} else {\n\t\t\t// Create new auditor (backward compatibility)\n\t\t\tconst services = await serviceDiscovery.register([\n\t\t\t\tendpoint.auditorStorageService,\n\t\t\t]);\n\t\t\tconst storage = services[\n\t\t\t\tendpoint.auditorStorageService.serviceName\n\t\t\t] as AuditStorage;\n\n\t\t\t// Extract actor if configured\n\t\t\tlet actor: AuditActor = { id: 'system', type: 'system' };\n\t\t\tif (endpoint.actorExtractor) {\n\t\t\t\ttry {\n\t\t\t\t\tactor = await (\n\t\t\t\t\t\tendpoint.actorExtractor as ActorExtractor<\n\t\t\t\t\t\t\tTServices,\n\t\t\t\t\t\t\tTSession,\n\t\t\t\t\t\t\tTLogger\n\t\t\t\t\t\t>\n\t\t\t\t\t)({\n\t\t\t\t\t\tservices: ctx.services as any,\n\t\t\t\t\t\tsession: ctx.session,\n\t\t\t\t\t\theader: ctx.header,\n\t\t\t\t\t\tcookie: ctx.cookie,\n\t\t\t\t\t\tlogger,\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tlogger.error(error as Error, 'Failed to extract actor for audits');\n\t\t\t\t\t// Continue with system actor\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tauditor = new DefaultAuditor<TAuditAction>({\n\t\t\t\tactor,\n\t\t\t\tstorage,\n\t\t\t\tmetadata: {\n\t\t\t\t\tendpoint: endpoint.route,\n\t\t\t\t\tmethod: endpoint.method,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\t// Process each declarative audit\n\t\tif (audits?.length) {\n\t\t\tfor (const audit of audits) {\n\t\t\t\tlogger.debug({ audit: audit.type }, 'Processing declarative audit');\n\n\t\t\t\t// Check when condition\n\t\t\t\tif (audit.when && !audit.when(response as any)) {\n\t\t\t\t\tlogger.debug(\n\t\t\t\t\t\t{ audit: audit.type },\n\t\t\t\t\t\t'Audit skipped due to when condition',\n\t\t\t\t\t);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// Extract payload\n\t\t\t\tconst payload = audit.payload(response as any);\n\n\t\t\t\t// Extract entityId if configured\n\t\t\t\tconst entityId = audit.entityId?.(response as any);\n\n\t\t\t\t// Record the audit\n\t\t\t\tauditor.audit(audit.type as any, payload as any, {\n\t\t\t\t\ttable: audit.table,\n\t\t\t\t\tentityId,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// Flush audits to storage\n\t\t// Note: If existingAuditor has a stored transaction (via setTransaction),\n\t\t// flush() will use it automatically\n\t\tconst recordCount = auditor.getRecords().length;\n\t\tif (recordCount > 0) {\n\t\t\t// Check if auditor has a stored transaction (for logging purposes)\n\t\t\tconst trx =\n\t\t\t\t'getTransaction' in auditor\n\t\t\t\t\t? (auditor as { getTransaction(): unknown }).getTransaction()\n\t\t\t\t\t: undefined;\n\t\t\tlogger.debug(\n\t\t\t\t{ auditCount: recordCount, hasTransaction: !!trx },\n\t\t\t\t'Flushing audits',\n\t\t\t);\n\t\t\tawait auditor.flush();\n\t\t}\n\t} catch (error) {\n\t\tlogger.error(error as Error, 'Failed to process audits');\n\t\t// Don't rethrow - audit failures shouldn't fail the request\n\t}\n}\n\n/**\n * Context for audit-aware handler execution.\n */\nexport interface AuditExecutionContext<\n\tTAuditAction extends AuditableAction<string, unknown> = AuditableAction<\n\t\tstring,\n\t\tunknown\n\t>,\n> {\n\t/** The auditor instance for recording audits */\n\tauditor: Auditor<TAuditAction>;\n\t/** The audit storage instance */\n\tstorage: AuditStorage;\n}\n\n/**\n * Create audit context for handler execution.\n * Returns the auditor and storage for use in the handler.\n *\n * @param endpoint - The endpoint with audit configuration\n * @param serviceDiscovery - Service discovery for getting audit storage\n * @param logger - Logger for debug/error messages\n * @param ctx - Request context for actor extraction\n * @returns Audit context with auditor and storage, or undefined if not configured\n */\nexport async function createAuditContext<\n\tTServices extends Service[] = [],\n\tTSession = unknown,\n\tTLogger extends Logger = Logger,\n\tTAuditStorage extends AuditStorage | undefined = undefined,\n\tTAuditStorageServiceName extends string = string,\n\tTAuditAction extends AuditableAction<string, unknown> = AuditableAction<\n\t\tstring,\n\t\tunknown\n\t>,\n\tTDatabase = undefined,\n\tTDatabaseServiceName extends string = string,\n>(\n\tendpoint: Endpoint<\n\t\tany,\n\t\tany,\n\t\tany,\n\t\tany,\n\t\tTServices,\n\t\tTLogger,\n\t\tTSession,\n\t\tany,\n\t\tany,\n\t\tTAuditStorage,\n\t\tTAuditStorageServiceName,\n\t\tTAuditAction,\n\t\tTDatabase,\n\t\tTDatabaseServiceName\n\t>,\n\tserviceDiscovery: ServiceDiscovery<any>,\n\tlogger: TLogger,\n\tctx: {\n\t\tsession: TSession;\n\t\theader: HeaderFn;\n\t\tcookie: CookieFn;\n\t\tservices: Record<string, unknown>;\n\t},\n): Promise<AuditExecutionContext<TAuditAction> | undefined> {\n\tif (!endpoint.auditorStorageService) {\n\t\treturn undefined;\n\t}\n\n\tconst services = await serviceDiscovery.register([\n\t\tendpoint.auditorStorageService,\n\t]);\n\tconst storage = services[\n\t\tendpoint.auditorStorageService.serviceName\n\t] as AuditStorage;\n\n\t// Extract actor if configured\n\tlet actor: AuditActor = { id: 'system', type: 'system' };\n\tif (endpoint.actorExtractor) {\n\t\ttry {\n\t\t\tactor = await (\n\t\t\t\tendpoint.actorExtractor as ActorExtractor<TServices, TSession, TLogger>\n\t\t\t)({\n\t\t\t\tservices: ctx.services as any,\n\t\t\t\tsession: ctx.session,\n\t\t\t\theader: ctx.header,\n\t\t\t\tcookie: ctx.cookie,\n\t\t\t\tlogger,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tlogger.error(error as Error, 'Failed to extract actor for audits');\n\t\t}\n\t}\n\n\tconst auditor = new DefaultAuditor<TAuditAction>({\n\t\tactor,\n\t\tstorage,\n\t\tmetadata: {\n\t\t\tendpoint: endpoint.route,\n\t\t\tmethod: endpoint.method,\n\t\t},\n\t});\n\n\treturn { auditor, storage };\n}\n\n/**\n * Options for executeWithAuditTransaction.\n */\nexport interface ExecuteWithAuditTransactionOptions {\n\t/**\n\t * Database connection to use for the transaction.\n\t * If this is already a transaction, it will be reused instead of creating a nested one.\n\t * If not provided, the storage's internal database is used.\n\t */\n\tdb?: unknown;\n}\n\n/**\n * Execute a handler with automatic audit transaction support.\n * If the audit storage provides a withTransaction method, wraps execution\n * in a transaction so audits are atomic with handler's database operations.\n *\n * This is database-agnostic - each storage implementation provides its own\n * transaction handling based on the underlying database (Kysely, Drizzle, etc.).\n *\n * If the db parameter is provided and is already a transaction, the storage\n * will reuse it instead of creating a nested transaction (similar to\n * packages/db/src/kysely.ts#withTransaction).\n *\n * @param auditContext - The audit context from createAuditContext\n * @param handler - The handler function to execute (receives auditor)\n * @param onComplete - Called after handler with response, to process declarative audits\n * @param options - Optional configuration including database connection\n * @returns The handler result\n */\nexport async function executeWithAuditTransaction<\n\tT,\n\tTAuditAction extends AuditableAction<string, unknown> = AuditableAction<\n\t\tstring,\n\t\tunknown\n\t>,\n>(\n\tauditContext: AuditExecutionContext<TAuditAction> | undefined,\n\thandler: (auditor?: Auditor<TAuditAction>) => Promise<T>,\n\tonComplete?: (response: T, auditor: Auditor<TAuditAction>) => Promise<void>,\n\toptions?: ExecuteWithAuditTransactionOptions,\n): Promise<T> {\n\t// No audit context - just run handler\n\tif (!auditContext) {\n\t\treturn handler(undefined);\n\t}\n\n\tconst { auditor, storage } = auditContext;\n\n\t// Check if storage provides a transaction wrapper\n\tif (storage.withTransaction) {\n\t\t// Wrap in transaction - audits are atomic with handler operations\n\t\t// The storage's withTransaction handles setTransaction and flush\n\t\t// Pass db so existing transactions are reused\n\t\treturn storage.withTransaction(\n\t\t\tauditor,\n\t\t\tasync () => {\n\t\t\t\tconst response = await handler(auditor);\n\n\t\t\t\t// Process declarative audits within the transaction\n\t\t\t\tif (onComplete) {\n\t\t\t\t\tawait onComplete(response, auditor);\n\t\t\t\t}\n\n\t\t\t\treturn response;\n\t\t\t},\n\t\t\toptions?.db,\n\t\t);\n\t}\n\n\t// No transaction support - run handler and flush audits after\n\tconst response = await handler(auditor);\n\n\tif (onComplete) {\n\t\tawait onComplete(response, auditor);\n\t}\n\n\t// Flush audits (no transaction)\n\tawait auditor.flush();\n\n\treturn response;\n}\n"],"mappings":";;;;;;;;;;;;AAkNA,eAAsB,mBAarB,UAgBA,kBACA,QACA,KAM2D;CAC3D,IAAI,CAAC,SAAS,uBACb;CAMD,MAAM,WAAU,MAHO,iBAAiB,SAAS,CAChD,SAAS,qBACV,CAAC,EAAA,CAEA,SAAS,sBAAsB;CAIhC,IAAI,QAAoB;EAAE,IAAI;EAAU,MAAM;CAAS;CACvD,IAAI,SAAS,gBACZ,IAAI;EACH,QAAQ,MACP,SAAS,eACR;GACD,UAAU,IAAI;GACd,SAAS,IAAI;GACb,QAAQ,IAAI;GACZ,QAAQ,IAAI;GACZ;EACD,CAAC;CACF,SAAS,OAAO;EACf,OAAO,MAAM,OAAgB,oCAAoC;CAClE;CAYD,OAAO;EAAE,SAAA,IATWA,iBAAAA,eAA6B;GAChD;GACA;GACA,UAAU;IACT,UAAU,SAAS;IACnB,QAAQ,SAAS;GAClB;EACD,CAEe;EAAG;CAAQ;AAC3B;;;;;;;;;;;;;;;;;;;AAgCA,eAAsB,4BAOrB,cACA,SACA,YACA,SACa;CAEb,IAAI,CAAC,cACJ,OAAO,QAAQ,KAAA,CAAS;CAGzB,MAAM,EAAE,SAAS,YAAY;CAG7B,IAAI,QAAQ,iBAIX,OAAO,QAAQ,gBACd,SACA,YAAY;EACX,MAAM,WAAW,MAAM,QAAQ,OAAO;EAGtC,IAAI,YACH,MAAM,WAAW,UAAU,OAAO;EAGnC,OAAO;CACR,GACA,SAAS,EACV;CAID,MAAM,WAAW,MAAM,QAAQ,OAAO;CAEtC,IAAI,YACH,MAAM,WAAW,UAAU,OAAO;CAInC,MAAM,QAAQ,MAAM;CAEpB,OAAO;AACR"}
@@ -1,11 +1,10 @@
1
- const require_chunk = require('../chunk-DWy1uDak.cjs');
2
- const require_construct_interface = require('../construct-interface-BfjcOD_E.cjs');
3
- const require_Construct = require('../Construct-CyS3RpTL.cjs');
4
- const require_clone = require('../clone-Dy0cR2SZ.cjs');
5
- const __geekmidas_manifest = require_chunk.__toESM(require("@geekmidas/manifest"));
6
- const __geekmidas_logger_console = require_chunk.__toESM(require("@geekmidas/logger/console"));
7
- const __geekmidas_events = require_chunk.__toESM(require("@geekmidas/events"));
8
-
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_Construct = require("../Construct-yG9Sw-5p.cjs");
3
+ const require_construct_interface = require("../construct-interface.cjs");
4
+ const require_clone = require("../clone-UGJpvQnL.cjs");
5
+ let _geekmidas_manifest = require("@geekmidas/manifest");
6
+ let _geekmidas_logger_console = require("@geekmidas/logger/console");
7
+ let _geekmidas_events = require("@geekmidas/events");
9
8
  //#region src/queue/Queue.ts
10
9
  /**
11
10
  * A queue worker — a point-to-point SQS-style queue and its single consumer.
@@ -17,9 +16,17 @@ const __geekmidas_events = require_chunk.__toESM(require("@geekmidas/events"));
17
16
  * that any endpoint/function drops into `.services([...])` to send messages.
18
17
  */
19
18
  var Queue = class extends require_Construct.Construct {
19
+ name;
20
+ handler;
21
+ messageSchema;
22
+ timeout;
23
+ services;
24
+ logger;
25
+ batchSize;
26
+ fifo;
20
27
  __IS_QUEUE__ = true;
21
28
  static isQueue(obj) {
22
- return Boolean(obj && obj.__IS_QUEUE__ === true && obj.type === require_Construct.ConstructType.Queue);
29
+ return Boolean(obj && obj.__IS_QUEUE__ === true && obj.type === "dev.geekmidas.function.queue");
23
30
  }
24
31
  /**
25
32
  * The canonical id this queue is declared under.
@@ -36,8 +43,8 @@ var Queue = class extends require_Construct.Construct {
36
43
  * looks up cannot drift.
37
44
  */
38
45
  connectionKey;
39
- constructor(name, handler, messageSchema, timeout = 3e4, services = [], logger = __geekmidas_logger_console.DEFAULT_LOGGER, batchSize, fifo, constructs = []) {
40
- super(require_Construct.ConstructType.Queue, logger, services, [], void 0, void 0, timeout, void 0, void 0, constructs);
46
+ constructor(name, handler, messageSchema, timeout = 3e4, services = [], logger = _geekmidas_logger_console.DEFAULT_LOGGER, batchSize, fifo, constructs = []) {
47
+ super("dev.geekmidas.function.queue", logger, services, [], void 0, void 0, timeout, void 0, void 0, constructs);
41
48
  this.name = name;
42
49
  this.handler = handler;
43
50
  this.messageSchema = messageSchema;
@@ -46,8 +53,8 @@ var Queue = class extends require_Construct.Construct {
46
53
  this.logger = logger;
47
54
  this.batchSize = batchSize;
48
55
  this.fifo = fifo;
49
- this.id = (0, __geekmidas_manifest.canonicalId)(name);
50
- this.connectionKey = (0, __geekmidas_manifest.provideKey)(this.id, "publisherConnectionString");
56
+ this.id = (0, _geekmidas_manifest.canonicalId)(name);
57
+ this.connectionKey = (0, _geekmidas_manifest.provideKey)(this.id, "publisherConnectionString");
51
58
  }
52
59
  /**
53
60
  * What this queue is in the manifest.
@@ -93,7 +100,7 @@ var Queue = class extends require_Construct.Construct {
93
100
  get service() {
94
101
  const { register } = this.publisher;
95
102
  return {
96
- serviceName: (0, __geekmidas_manifest.serviceKey)(this.id),
103
+ serviceName: (0, _geekmidas_manifest.serviceKey)(this.id),
97
104
  register
98
105
  };
99
106
  }
@@ -103,12 +110,11 @@ var Queue = class extends require_Construct.Construct {
103
110
  serviceName: `${this.name}Publisher`,
104
111
  async register({ envParser }) {
105
112
  const { connectionString } = envParser.create((get) => ({ connectionString: get(envVar).string() })).parse();
106
- return __geekmidas_events.Publisher.fromConnectionString(connectionString);
113
+ return _geekmidas_events.Publisher.fromConnectionString(connectionString);
107
114
  }
108
115
  };
109
116
  }
110
117
  };
111
-
112
118
  //#endregion
113
119
  //#region src/queue/QueueBuilder.ts
114
120
  /**
@@ -126,7 +132,7 @@ var QueueBuilder = class {
126
132
  _services = [];
127
133
  /** The construct ids `.dependsOn()` named — what the manifest records. */
128
134
  _constructs = [];
129
- _logger = __geekmidas_logger_console.DEFAULT_LOGGER;
135
+ _logger = _geekmidas_logger_console.DEFAULT_LOGGER;
130
136
  /** The queue name — drives the infra queue and its `<NAME>_*` env vars. */
131
137
  queue(name) {
132
138
  return require_clone.cloneWith(this, { _name: name });
@@ -173,17 +179,15 @@ var QueueBuilder = class {
173
179
  handle(fn) {
174
180
  if (!this._name) throw new Error("Queue requires a name — call .queue(name) before .handle().");
175
181
  if (!this._messageSchema) throw new Error("Queue requires a message schema — call .message(schema) before .handle().");
176
- const queue = new Queue(this._name, fn, this._messageSchema, this._timeout, this._services, this._logger, this._batchSize, this._fifo, this._constructs);
177
- return queue;
182
+ return new Queue(this._name, fn, this._messageSchema, this._timeout, this._services, this._logger, this._batchSize, this._fifo, this._constructs);
178
183
  }
179
184
  };
180
-
181
185
  //#endregion
182
186
  //#region src/queue/index.ts
183
187
  const q = new QueueBuilder();
184
-
185
188
  //#endregion
186
189
  exports.Queue = Queue;
187
190
  exports.QueueBuilder = QueueBuilder;
188
191
  exports.q = q;
192
+
189
193
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["Construct","obj: unknown","ConstructType","name: TName","handler: QueueHandler<TMessage, TServices, TLogger>","messageSchema: TMessage","timeout: number","services: TServices","logger: TLogger","DEFAULT_LOGGER","batchSize?: number","fifo?: boolean","constructs: string[]","DEFAULT_LOGGER","name: T","timeout: number","batchSize: number","constructs: T","services: T","logger: T","schema: T","fn: QueueHandler<NonNullable<TMessage>, TServices, TLogger>"],"sources":["../../src/queue/Queue.ts","../../src/queue/QueueBuilder.ts","../../src/queue/index.ts"],"sourcesContent":["import {\n\ttype EventPublisher,\n\ttype EventPublisherConnectionString,\n\ttype PublishableMessage,\n\tPublisher,\n} from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport {\n\tcanonicalId,\n\ttype Declaration,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { InferStandardSchema } from '@geekmidas/schema';\nimport type { Service, ServiceRecord } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { Construct, ConstructType } from '../Construct';\n\n/**\n * The wire message a queue carries: `{ type: <queue name>, payload: <message> }`.\n * The producer publishes this shape and the worker receives the `payload`s as\n * its `messages`. Typing `type` to the queue name keeps the publisher fully\n * typed and lets pg-boss (local) / SQS (deployed) route by name.\n */\nexport type QueueMessage<\n\tTName extends string,\n\tTMessage extends StandardSchemaV1,\n> = PublishableMessage<TName, InferStandardSchema<TMessage>>;\n\n/**\n * A queue worker — a point-to-point SQS-style queue and its single consumer.\n * Unlike a `Subscriber` (topic fan-out, filtered by `subscribedEvents`), a queue\n * drains every message of its one `message` type. Build one with `q` (see\n * `QueueBuilder`); `gkm build` discovers it into the manifest's `queues` field.\n *\n * The producer side is {@link Queue.publisher} — a ready-to-inject `Service`\n * that any endpoint/function drops into `.services([...])` to send messages.\n */\nexport class Queue<\n\tTName extends string = string,\n\tTMessage extends StandardSchemaV1 = StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> extends Construct<TLogger, string, undefined, undefined, TServices> {\n\t__IS_QUEUE__ = true;\n\n\tstatic isQueue(\n\t\tobj: unknown,\n\t): obj is Queue<string, StandardSchemaV1, Service[], Logger> {\n\t\treturn Boolean(\n\t\t\tobj &&\n\t\t\t\t(obj as { __IS_QUEUE__?: boolean }).__IS_QUEUE__ === true &&\n\t\t\t\t(obj as Construct).type === ConstructType.Queue,\n\t\t);\n\t}\n\n\t/**\n\t * The canonical id this queue is declared under.\n\t *\n\t * Derived from the name rather than given separately, so `emails` and\n\t * `Emails` are one queue. The name stays what it was: it is the wire `type`\n\t * a producer sends and the worker subscribes to, and changing that would\n\t * silently orphan in-flight messages.\n\t */\n\treadonly id: string;\n\n\t/**\n\t * The producer's env key. Read by both {@link declare} and\n\t * {@link publisher}, so what the target publishes and what the producer\n\t * looks up cannot drift.\n\t */\n\tprivate readonly connectionKey: string;\n\n\tconstructor(\n\t\tpublic readonly name: TName,\n\t\tpublic readonly handler: QueueHandler<TMessage, TServices, TLogger>,\n\t\tpublic readonly messageSchema: TMessage,\n\t\tpublic override readonly timeout: number = 30000,\n\t\tpublic override readonly services: TServices = [] as unknown as TServices,\n\t\tpublic override readonly logger: TLogger = DEFAULT_LOGGER as TLogger,\n\t\t/** SQS event-source batch size (deployed). */\n\t\tpublic readonly batchSize?: number,\n\t\t/** Whether the queue is FIFO (deployed). */\n\t\tpublic readonly fifo?: boolean,\n\t\t/**\n\t\t * The construct ids the *worker* `.dependsOn()` named — last, so no\n\t\t * existing positional argument moves.\n\t\t */\n\t\tconstructs: string[] = [],\n\t) {\n\t\tsuper(\n\t\t\tConstructType.Queue,\n\t\t\tlogger,\n\t\t\tservices,\n\t\t\t[],\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t\ttimeout,\n\t\t\tundefined, // memorySize\n\t\t\tundefined, // auditorStorageService\n\t\t\tconstructs,\n\t\t);\n\n\t\tthis.id = canonicalId(name);\n\t\tthis.connectionKey = provideKey(this.id, 'publisherConnectionString');\n\t}\n\n\t/**\n\t * What this queue is in the manifest.\n\t *\n\t * A queue is a resource, not a handler: the worker is reached *through* it,\n\t * so the declaration carries the producer's key and nothing about the code\n\t * that drains it. The local target reads this to know which broker has to be\n\t * running and what connection string to inject.\n\t */\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'queue',\n\t\t\t\tid: this.id,\n\t\t\t\tprovides: [this.connectionKey],\n\t\t\t\t...(this.fifo ? { fifo: true } : {}),\n\t\t\t\t// Nested rather than a sibling node, because position carries the\n\t\t\t\t// trigger: this handler is reached by messages on this queue and\n\t\t\t\t// by nothing else, so there is no `trigger` field to keep in step.\n\t\t\t\t//\n\t\t\t\t// `handler` is the export name; which directory the build wrote it\n\t\t\t\t// to is the target's business, and a path with a cloud in it does\n\t\t\t\t// not belong in a neutral declaration.\n\t\t\t\tworker: {\n\t\t\t\t\tid: `${this.id}Worker`,\n\t\t\t\t\thandler: `${this.id}.handler`,\n\t\t\t\t\t// Filled by the build from what the worker declared. Empty is a\n\t\t\t\t\t// stated gap, not a claim that it reaches nothing.\n\t\t\t\t\tdependencies: [],\n\t\t\t\t},\n\t\t\t},\n\t\t];\n\t}\n\n\t/**\n\t * The producer side — a `Service` exposing an `EventPublisher` typed to this\n\t * queue's message. Inject it via `.services([queue.publisher])`; the handler\n\t * then calls `services.<name>Publisher.publish([{ type, payload }])`.\n\t *\n\t * It reads `<NAME>_PUBLISHER_CONNECTION_STRING` and builds the transport from\n\t * the URL protocol — `pgboss://` locally, `sqs://` deployed — so the same\n\t * code publishes to Postgres in dev and SQS in prod. Because it's a `Service`,\n\t * `Construct.getEnvironment()` sniffs it, so the env requirement flows into\n\t * the manifest and infra links exactly this queue with least privilege.\n\t */\n\t/**\n\t * The queue as a dependency — what `.dependsOn([emailsQueue])` dissolves\n\t * into, reachable as `services.emails`.\n\t *\n\t * It is the producer: a consumer is the worker written right here, so the\n\t * only thing another construct can want from a queue is the ability to send\n\t * to it. {@link publisher} is the same service under its older\n\t * `<name>Publisher` key, kept for `.services([queue.publisher])`.\n\t */\n\tget service(): Service<\n\t\tUncapitalize<TName>,\n\t\tEventPublisher<QueueMessage<TName, TMessage>>\n\t> {\n\t\tconst { register } = this.publisher;\n\n\t\treturn {\n\t\t\tserviceName: serviceKey(this.id) as Uncapitalize<TName>,\n\t\t\tregister,\n\t\t};\n\t}\n\n\tget publisher(): Service<\n\t\t`${TName}Publisher`,\n\t\tEventPublisher<QueueMessage<TName, TMessage>>\n\t> {\n\t\tconst envVar = this.connectionKey;\n\t\treturn {\n\t\t\tserviceName: `${this.name}Publisher`,\n\t\t\tasync register({ envParser }) {\n\t\t\t\tconst { connectionString } = envParser\n\t\t\t\t\t.create((get) => ({\n\t\t\t\t\t\tconnectionString: get(envVar).string(),\n\t\t\t\t\t}))\n\t\t\t\t\t.parse();\n\n\t\t\t\treturn Publisher.fromConnectionString<QueueMessage<TName, TMessage>>(\n\t\t\t\t\tconnectionString as EventPublisherConnectionString,\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\t}\n}\n\n/** The context a queue handler receives — a batch of typed messages. */\nexport type QueueContext<\n\tTMessage extends StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> = {\n\tmessages: InferStandardSchema<TMessage>[];\n\tservices: ServiceRecord<TServices>;\n\tlogger: TLogger;\n};\n\nexport type QueueHandler<\n\tTMessage extends StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> = (\n\tctx: QueueContext<TMessage, TServices, TLogger>,\n) => unknown | Promise<unknown>;\n","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\tidsOf,\n\ttype ServicesOf,\n\tservicesOf,\n} from '../construct-interface';\nimport { Queue, type QueueHandler } from './Queue';\n\n/**\n * Builds a {@link Queue} worker — `q.queue('orders').services([db]).message(schema).handle(fn)`.\n * Services are an array (sniffed for required env vars); `message` is the typed\n * job payload; `handle` is the single consumer. The queue name is captured as a\n * literal so `queue.publisher` is typed to `{ type: '<name>', payload }`.\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> {\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\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<T, TMessage, TServices, TLogger> {\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>;\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<TName, TMessage, [...TServices, ...ServicesOf<T>], TLogger> {\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>;\n\t}\n\n\tservices<T extends Service[]>(\n\t\tservices: T,\n\t): QueueBuilder<TName, TMessage, [...TServices, ...T], TLogger> {\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>;\n\t}\n\n\tlogger<T extends Logger>(\n\t\tlogger: T,\n\t): QueueBuilder<TName, TMessage, TServices, T> {\n\t\treturn cloneWith(this, {\n\t\t\t_logger: logger as unknown as TLogger,\n\t\t}) as unknown as QueueBuilder<TName, TMessage, TServices, 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<TName, T, TServices, TLogger> {\n\t\treturn cloneWith(this, {\n\t\t\t_messageSchema: schema as unknown as TMessage,\n\t\t}) as unknown as QueueBuilder<TName, T, TServices, TLogger>;\n\t}\n\n\thandle(\n\t\tfn: QueueHandler<NonNullable<TMessage>, TServices, TLogger>,\n\t): Queue<TName, NonNullable<TMessage>, TServices, TLogger> {\n\t\tif (!this._name) {\n\t\t\tthrow new Error(\n\t\t\t\t'Queue requires a name — call .queue(name) before .handle().',\n\t\t\t);\n\t\t}\n\t\tif (!this._messageSchema) {\n\t\t\tthrow new Error(\n\t\t\t\t'Queue requires a message schema — call .message(schema) before .handle().',\n\t\t\t);\n\t\t}\n\n\t\tconst queue = new Queue<TName, NonNullable<TMessage>, TServices, TLogger>(\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);\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","export {\n\tQueue,\n\ttype QueueContext,\n\ttype QueueHandler,\n\ttype QueueMessage,\n} from './Queue';\n\nimport { QueueBuilder } from './QueueBuilder';\n\nexport { QueueBuilder } from './QueueBuilder';\n\nexport const q = new QueueBuilder();\n"],"mappings":"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"}
1
+ {"version":3,"file":"index.cjs","names":["Construct","DEFAULT_LOGGER","canonicalId","provideKey","serviceKey","Publisher","DEFAULT_LOGGER","cloneWith","servicesOf","idsOf"],"sources":["../../src/queue/Queue.ts","../../src/queue/QueueBuilder.ts","../../src/queue/index.ts"],"sourcesContent":["import {\n\ttype EventPublisher,\n\ttype EventPublisherConnectionString,\n\ttype PublishableMessage,\n\tPublisher,\n} from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport {\n\tcanonicalId,\n\ttype Declaration,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { InferStandardSchema } from '@geekmidas/schema';\nimport type { Service, ServiceRecord } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { Construct, ConstructType } from '../Construct';\n\n/**\n * The wire message a queue carries: `{ type: <queue name>, payload: <message> }`.\n * The producer publishes this shape and the worker receives the `payload`s as\n * its `messages`. Typing `type` to the queue name keeps the publisher fully\n * typed and lets pg-boss (local) / SQS (deployed) route by name.\n */\nexport type QueueMessage<\n\tTName extends string,\n\tTMessage extends StandardSchemaV1,\n> = PublishableMessage<TName, InferStandardSchema<TMessage>>;\n\n/**\n * A queue worker — a point-to-point SQS-style queue and its single consumer.\n * Unlike a `Subscriber` (topic fan-out, filtered by `subscribedEvents`), a queue\n * drains every message of its one `message` type. Build one with `q` (see\n * `QueueBuilder`); `gkm build` discovers it into the manifest's `queues` field.\n *\n * The producer side is {@link Queue.publisher} — a ready-to-inject `Service`\n * that any endpoint/function drops into `.services([...])` to send messages.\n */\nexport class Queue<\n\tTName extends string = string,\n\tTMessage extends StandardSchemaV1 = StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> extends Construct<TLogger, string, undefined, undefined, TServices> {\n\t__IS_QUEUE__ = true;\n\n\tstatic isQueue(\n\t\tobj: unknown,\n\t): obj is Queue<string, StandardSchemaV1, Service[], Logger> {\n\t\treturn Boolean(\n\t\t\tobj &&\n\t\t\t\t(obj as { __IS_QUEUE__?: boolean }).__IS_QUEUE__ === true &&\n\t\t\t\t(obj as Construct).type === ConstructType.Queue,\n\t\t);\n\t}\n\n\t/**\n\t * The canonical id this queue is declared under.\n\t *\n\t * Derived from the name rather than given separately, so `emails` and\n\t * `Emails` are one queue. The name stays what it was: it is the wire `type`\n\t * a producer sends and the worker subscribes to, and changing that would\n\t * silently orphan in-flight messages.\n\t */\n\treadonly id: string;\n\n\t/**\n\t * The producer's env key. Read by both {@link declare} and\n\t * {@link publisher}, so what the target publishes and what the producer\n\t * looks up cannot drift.\n\t */\n\tprivate readonly connectionKey: string;\n\n\tconstructor(\n\t\tpublic readonly name: TName,\n\t\tpublic readonly handler: QueueHandler<TMessage, TServices, TLogger>,\n\t\tpublic readonly messageSchema: TMessage,\n\t\tpublic override readonly timeout: number = 30000,\n\t\tpublic override readonly services: TServices = [] as unknown as TServices,\n\t\tpublic override readonly logger: TLogger = DEFAULT_LOGGER as TLogger,\n\t\t/** SQS event-source batch size (deployed). */\n\t\tpublic readonly batchSize?: number,\n\t\t/** Whether the queue is FIFO (deployed). */\n\t\tpublic readonly fifo?: boolean,\n\t\t/**\n\t\t * The construct ids the *worker* `.dependsOn()` named — last, so no\n\t\t * existing positional argument moves.\n\t\t */\n\t\tconstructs: string[] = [],\n\t) {\n\t\tsuper(\n\t\t\tConstructType.Queue,\n\t\t\tlogger,\n\t\t\tservices,\n\t\t\t[],\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t\ttimeout,\n\t\t\tundefined, // memorySize\n\t\t\tundefined, // auditorStorageService\n\t\t\tconstructs,\n\t\t);\n\n\t\tthis.id = canonicalId(name);\n\t\tthis.connectionKey = provideKey(this.id, 'publisherConnectionString');\n\t}\n\n\t/**\n\t * What this queue is in the manifest.\n\t *\n\t * A queue is a resource, not a handler: the worker is reached *through* it,\n\t * so the declaration carries the producer's key and nothing about the code\n\t * that drains it. The local target reads this to know which broker has to be\n\t * running and what connection string to inject.\n\t */\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'queue',\n\t\t\t\tid: this.id,\n\t\t\t\tprovides: [this.connectionKey],\n\t\t\t\t...(this.fifo ? { fifo: true } : {}),\n\t\t\t\t// Nested rather than a sibling node, because position carries the\n\t\t\t\t// trigger: this handler is reached by messages on this queue and\n\t\t\t\t// by nothing else, so there is no `trigger` field to keep in step.\n\t\t\t\t//\n\t\t\t\t// `handler` is the export name; which directory the build wrote it\n\t\t\t\t// to is the target's business, and a path with a cloud in it does\n\t\t\t\t// not belong in a neutral declaration.\n\t\t\t\tworker: {\n\t\t\t\t\tid: `${this.id}Worker`,\n\t\t\t\t\thandler: `${this.id}.handler`,\n\t\t\t\t\t// Filled by the build from what the worker declared. Empty is a\n\t\t\t\t\t// stated gap, not a claim that it reaches nothing.\n\t\t\t\t\tdependencies: [],\n\t\t\t\t},\n\t\t\t},\n\t\t];\n\t}\n\n\t/**\n\t * The producer side — a `Service` exposing an `EventPublisher` typed to this\n\t * queue's message. Inject it via `.services([queue.publisher])`; the handler\n\t * then calls `services.<name>Publisher.publish([{ type, payload }])`.\n\t *\n\t * It reads `<NAME>_PUBLISHER_CONNECTION_STRING` and builds the transport from\n\t * the URL protocol — `pgboss://` locally, `sqs://` deployed — so the same\n\t * code publishes to Postgres in dev and SQS in prod. Because it's a `Service`,\n\t * `Construct.getEnvironment()` sniffs it, so the env requirement flows into\n\t * the manifest and infra links exactly this queue with least privilege.\n\t */\n\t/**\n\t * The queue as a dependency — what `.dependsOn([emailsQueue])` dissolves\n\t * into, reachable as `services.emails`.\n\t *\n\t * It is the producer: a consumer is the worker written right here, so the\n\t * only thing another construct can want from a queue is the ability to send\n\t * to it. {@link publisher} is the same service under its older\n\t * `<name>Publisher` key, kept for `.services([queue.publisher])`.\n\t */\n\tget service(): Service<\n\t\tUncapitalize<TName>,\n\t\tEventPublisher<QueueMessage<TName, TMessage>>\n\t> {\n\t\tconst { register } = this.publisher;\n\n\t\treturn {\n\t\t\tserviceName: serviceKey(this.id) as Uncapitalize<TName>,\n\t\t\tregister,\n\t\t};\n\t}\n\n\tget publisher(): Service<\n\t\t`${TName}Publisher`,\n\t\tEventPublisher<QueueMessage<TName, TMessage>>\n\t> {\n\t\tconst envVar = this.connectionKey;\n\t\treturn {\n\t\t\tserviceName: `${this.name}Publisher`,\n\t\t\tasync register({ envParser }) {\n\t\t\t\tconst { connectionString } = envParser\n\t\t\t\t\t.create((get) => ({\n\t\t\t\t\t\tconnectionString: get(envVar).string(),\n\t\t\t\t\t}))\n\t\t\t\t\t.parse();\n\n\t\t\t\treturn Publisher.fromConnectionString<QueueMessage<TName, TMessage>>(\n\t\t\t\t\tconnectionString as EventPublisherConnectionString,\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\t}\n}\n\n/** The context a queue handler receives — a batch of typed messages. */\nexport type QueueContext<\n\tTMessage extends StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> = {\n\tmessages: InferStandardSchema<TMessage>[];\n\tservices: ServiceRecord<TServices>;\n\tlogger: TLogger;\n};\n\nexport type QueueHandler<\n\tTMessage extends StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> = (\n\tctx: QueueContext<TMessage, TServices, TLogger>,\n) => unknown | Promise<unknown>;\n","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\tidsOf,\n\ttype ServicesOf,\n\tservicesOf,\n} from '../construct-interface';\nimport { Queue, type QueueHandler } from './Queue';\n\n/**\n * Builds a {@link Queue} worker — `q.queue('orders').services([db]).message(schema).handle(fn)`.\n * Services are an array (sniffed for required env vars); `message` is the typed\n * job payload; `handle` is the single consumer. The queue name is captured as a\n * literal so `queue.publisher` is typed to `{ type: '<name>', payload }`.\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> {\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\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<T, TMessage, TServices, TLogger> {\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>;\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<TName, TMessage, [...TServices, ...ServicesOf<T>], TLogger> {\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>;\n\t}\n\n\tservices<T extends Service[]>(\n\t\tservices: T,\n\t): QueueBuilder<TName, TMessage, [...TServices, ...T], TLogger> {\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>;\n\t}\n\n\tlogger<T extends Logger>(\n\t\tlogger: T,\n\t): QueueBuilder<TName, TMessage, TServices, T> {\n\t\treturn cloneWith(this, {\n\t\t\t_logger: logger as unknown as TLogger,\n\t\t}) as unknown as QueueBuilder<TName, TMessage, TServices, 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<TName, T, TServices, TLogger> {\n\t\treturn cloneWith(this, {\n\t\t\t_messageSchema: schema as unknown as TMessage,\n\t\t}) as unknown as QueueBuilder<TName, T, TServices, TLogger>;\n\t}\n\n\thandle(\n\t\tfn: QueueHandler<NonNullable<TMessage>, TServices, TLogger>,\n\t): Queue<TName, NonNullable<TMessage>, TServices, TLogger> {\n\t\tif (!this._name) {\n\t\t\tthrow new Error(\n\t\t\t\t'Queue requires a name — call .queue(name) before .handle().',\n\t\t\t);\n\t\t}\n\t\tif (!this._messageSchema) {\n\t\t\tthrow new Error(\n\t\t\t\t'Queue requires a message schema — call .message(schema) before .handle().',\n\t\t\t);\n\t\t}\n\n\t\tconst queue = new Queue<TName, NonNullable<TMessage>, TServices, TLogger>(\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);\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","export {\n\tQueue,\n\ttype QueueContext,\n\ttype QueueHandler,\n\ttype QueueMessage,\n} from './Queue';\n\nimport { QueueBuilder } from './QueueBuilder';\n\nexport { QueueBuilder } from './QueueBuilder';\n\nexport const q = new QueueBuilder();\n"],"mappings":"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"}
@@ -1,20 +1,16 @@
1
- import "../Construct-C0ijr2qp.cjs";
2
- import { Consumable, ServicesOf } from "../construct-interface-D9d4Gm4p.cjs";
3
- import { Queue, QueueContext, QueueHandler, QueueMessage } from "../Queue-D7ZuwBhy.cjs";
4
- import * as _geekmidas_logger25 from "@geekmidas/logger";
5
- import { Logger } from "@geekmidas/logger";
1
+ import { t as StandardSchemaV1 } from "../index-CeEtxDmK.cjs";
2
+ import { c as ServicesOf, r as Consumable } from "../construct-interface-DIaTNKax.cjs";
3
+ import { i as QueueMessage, n as QueueContext, r as QueueHandler, t as Queue } from "../Queue-Bhzi2WQC.cjs";
4
+ import { Logger as Logger$1 } from "@geekmidas/logger";
6
5
  import { Service } from "@geekmidas/services";
7
- import { StandardSchemaV1 } from "@standard-schema/spec";
8
-
9
6
  //#region src/queue/QueueBuilder.d.ts
10
-
11
7
  /**
12
8
  * Builds a {@link Queue} worker — `q.queue('orders').services([db]).message(schema).handle(fn)`.
13
9
  * Services are an array (sniffed for required env vars); `message` is the typed
14
10
  * job payload; `handle` is the single consumer. The queue name is captured as a
15
11
  * literal so `queue.publisher` is typed to `{ type: '<name>', payload }`.
16
12
  */
17
- declare class QueueBuilder<TName extends string = string, TMessage extends StandardSchemaV1 | undefined = undefined, TServices extends Service[] = [], TLogger extends Logger = Logger> {
13
+ export declare class QueueBuilder<TName extends string = string, TMessage extends StandardSchemaV1 | undefined = undefined, TServices extends Service[] = [], TLogger extends Logger$1 = Logger$1> {
18
14
  private _name?;
19
15
  private _messageSchema?;
20
16
  private _timeout;
@@ -44,17 +40,14 @@ declare class QueueBuilder<TName extends string = string, TMessage extends Stand
44
40
  */
45
41
  dependsOn<const T extends readonly Consumable[]>(constructs: T): QueueBuilder<TName, TMessage, [...TServices, ...ServicesOf<T>], TLogger>;
46
42
  services<T extends Service[]>(services: T): QueueBuilder<TName, TMessage, [...TServices, ...T], TLogger>;
47
- logger<T extends Logger>(logger: T): QueueBuilder<TName, TMessage, TServices, T>;
43
+ logger<T extends Logger$1>(logger: T): QueueBuilder<TName, TMessage, TServices, T>;
48
44
  /** The typed message (job) payload the queue carries. */
49
45
  message<T extends StandardSchemaV1>(schema: T): QueueBuilder<TName, T, TServices, TLogger>;
50
46
  handle(fn: QueueHandler<NonNullable<TMessage>, TServices, TLogger>): Queue<TName, NonNullable<TMessage>, TServices, TLogger>;
51
47
  }
52
- //# sourceMappingURL=QueueBuilder.d.ts.map
53
48
  //#endregion
54
49
  //#region src/queue/index.d.ts
55
- declare const q: QueueBuilder<string, undefined, [], _geekmidas_logger25.Logger>;
56
- //# sourceMappingURL=index.d.ts.map
57
-
50
+ export declare const q: QueueBuilder<string, undefined, [], Logger>;
58
51
  //#endregion
59
- export { Queue, QueueBuilder, QueueContext, QueueHandler, QueueMessage, q };
52
+ export { Queue, type QueueContext, type QueueHandler, type QueueMessage };
60
53
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/queue/QueueBuilder.ts","../../src/queue/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;AAmBA;;AAEkB,cAFL,YAEK,CAAA,cAAA,MAAA,GAAA,MAAA,EAAA,iBAAA,gBAAA,GAAA,SAAA,GAAA,SAAA,EAAA,kBACC,OADD,EAAA,GAAA,EAAA,EAAA,gBAED,MAFC,GAEQ,MAFR,CAAA,CAAA;EAAgB,QACf,KAAA;EAAO,QACT,cAAA;EAAM,QAAG,QAAA;EAAM,QAcxB,UAAA;EAAC,QACQ,KAAA;EAAC,QAAE,SAAA;EAAQ;EAAW,WAAE,EAAA,MAAA,EAAA;EAAO,QAA5C,OAAA;EAAY;EAkC8B,KAChC,CAAA,UAAA,MAAA,CAAA,CAAA,IAAA,EApCN,CAoCM,CAAA,EAnCV,YAmCU,CAnCG,CAmCH,EAnCM,QAmCN,EAnCgB,SAmChB,EAnC2B,OAmC3B,CAAA;EAAC,OACE,CAAA,OAAA,EAAA,MAAA,CAAA,EAAA,IAAA;EAAK;EAAU,SAAM,CAAA,SAAA,EAAA,MAAA,CAAA,EAAA,IAAA;EAAS;EAAiB,IAAZ,CAAA,IAAA,CAAA,EAAA,OAAA,CAAA,EAAA,IAAA;EAAU;;;;;;;;;;;EAkCtC,SACd,CAAA,gBAAA,SArC0B,UAqC1B,EAAA,CAAA,CAAA,UAAA,EApCI,CAoCJ,CAAA,EAnCN,YAmCM,CAnCO,KAmCP,EAnCc,QAmCd,EAAA,CAAA,GAnC4B,SAmC5B,EAAA,GAnC0C,UAmC1C,CAnCqD,CAmCrD,CAAA,CAAA,EAnC0D,OAmC1D,CAAA;EAAC,QACM,CAAA,UAfG,OAeH,EAAA,CAAA,CAAA,QAAA,EAdL,CAcK,CAAA,EAbb,YAaa,CAbA,KAaA,EAbO,QAaP,EAAA,CAAA,GAbqB,SAarB,EAAA,GAbmC,CAanC,CAAA,EAbuC,OAavC,CAAA;EAAK,MAAE,CAAA,UAFN,MAEM,CAAA,CAAA,MAAA,EADd,CACc,CAAA,EAApB,YAAoB,CAAP,KAAO,EAAA,QAAA,EAAU,SAAV,EAAqB,CAArB,CAAA;EAAQ;EAAW,OAAE,CAAA,UAO1B,gBAP0B,CAAA,CAAA,MAAA,EAQnC,CARmC,CAAA,EASzC,YATyC,CAS5B,KAT4B,EASrB,CATqB,EASlB,SATkB,EASP,OATO,CAAA;EAAC,MAA1C,CAAA,EAAA,EAgBE,YAhBF,CAgBe,WAhBf,CAgB2B,QAhB3B,CAAA,EAgBsC,SAhBtC,EAgBiD,OAhBjD,CAAA,CAAA,EAiBA,KAjBA,CAiBM,KAjBN,EAiBa,WAjBb,CAiByB,QAjBzB,CAAA,EAiBoC,SAjBpC,EAiB+C,OAjB/C,CAAA;;;;;cCnGS,GAAC,oCAAqB,mBAAA,CAArB,MAAA"}
1
+ {"version":3,"file":"index.d.cts","names":["Logger"],"sources":["../../src/queue/QueueBuilder.ts","../../src/queue/index.ts"],"mappings":";;;;;;;;;;;;qBAmBa,aACZ,+BACA,iBAAiB,0CACjB,kBAAkB,gBAClB,gBAAgBA,WAASA;UAEjB;UACA;UACA;UACA;UACA;UACA;;EAED;UACC;;EAGR,MAAM,kBACL,MAAM,IACJ,aAAa,GAAG,UAAU,WAAW;EASxC,QAAQ;;EAKR,UAAU;;EAKV,KAAK;;;;;;;;;;;;EAeL,gBAAgB,mBAAmB,cAClC,YAAY,IACV,aAAa,OAAO,cAAc,cAAc,WAAW,KAAK;EAqBnE,SAAS,UAAU,WAClB,UAAU,IACR,aAAa,OAAO,cAAc,cAAc,IAAI;EAWvD,OAAO,UAAUA,UAChB,QAAQ,IACN,aAAa,OAAO,UAAU,WAAW;;EAO5C,QAAQ,UAAU,kBACjB,QAAQ,IACN,aAAa,OAAO,GAAG,WAAW;EAMrC,OACC,IAAI,aAAa,YAAY,WAAW,WAAW,WACjD,MAAM,OAAO,YAAY,WAAW,WAAW;;;;qBCpHtC,GAAC,oCAAA"}
@@ -1,20 +1,16 @@
1
- import "../Construct-Ct8nalEi.mjs";
2
- import { Consumable, ServicesOf } from "../construct-interface-g5GM5pwR.mjs";
3
- import { Queue, QueueContext, QueueHandler, QueueMessage } from "../Queue-gVGfi2Yk.mjs";
1
+ import { t as StandardSchemaV1 } from "../index-CeEtxDmK.mjs";
2
+ import { c as ServicesOf, r as Consumable } from "../construct-interface-Clz7_BwB.mjs";
3
+ import { i as QueueMessage, n as QueueContext, r as QueueHandler, t as Queue } from "../Queue-BoUA-e83.mjs";
4
4
  import { Service } from "@geekmidas/services";
5
- import * as _geekmidas_logger24 from "@geekmidas/logger";
6
- import { Logger } from "@geekmidas/logger";
7
- import { StandardSchemaV1 } from "@standard-schema/spec";
8
-
5
+ import { Logger as Logger$1 } from "@geekmidas/logger";
9
6
  //#region src/queue/QueueBuilder.d.ts
10
-
11
7
  /**
12
8
  * Builds a {@link Queue} worker — `q.queue('orders').services([db]).message(schema).handle(fn)`.
13
9
  * Services are an array (sniffed for required env vars); `message` is the typed
14
10
  * job payload; `handle` is the single consumer. The queue name is captured as a
15
11
  * literal so `queue.publisher` is typed to `{ type: '<name>', payload }`.
16
12
  */
17
- declare class QueueBuilder<TName extends string = string, TMessage extends StandardSchemaV1 | undefined = undefined, TServices extends Service[] = [], TLogger extends Logger = Logger> {
13
+ export declare class QueueBuilder<TName extends string = string, TMessage extends StandardSchemaV1 | undefined = undefined, TServices extends Service[] = [], TLogger extends Logger$1 = Logger$1> {
18
14
  private _name?;
19
15
  private _messageSchema?;
20
16
  private _timeout;
@@ -44,17 +40,14 @@ declare class QueueBuilder<TName extends string = string, TMessage extends Stand
44
40
  */
45
41
  dependsOn<const T extends readonly Consumable[]>(constructs: T): QueueBuilder<TName, TMessage, [...TServices, ...ServicesOf<T>], TLogger>;
46
42
  services<T extends Service[]>(services: T): QueueBuilder<TName, TMessage, [...TServices, ...T], TLogger>;
47
- logger<T extends Logger>(logger: T): QueueBuilder<TName, TMessage, TServices, T>;
43
+ logger<T extends Logger$1>(logger: T): QueueBuilder<TName, TMessage, TServices, T>;
48
44
  /** The typed message (job) payload the queue carries. */
49
45
  message<T extends StandardSchemaV1>(schema: T): QueueBuilder<TName, T, TServices, TLogger>;
50
46
  handle(fn: QueueHandler<NonNullable<TMessage>, TServices, TLogger>): Queue<TName, NonNullable<TMessage>, TServices, TLogger>;
51
47
  }
52
- //# sourceMappingURL=QueueBuilder.d.ts.map
53
48
  //#endregion
54
49
  //#region src/queue/index.d.ts
55
- declare const q: QueueBuilder<string, undefined, [], _geekmidas_logger24.Logger>;
56
- //# sourceMappingURL=index.d.ts.map
57
-
50
+ export declare const q: QueueBuilder<string, undefined, [], Logger>;
58
51
  //#endregion
59
- export { Queue, QueueBuilder, QueueContext, QueueHandler, QueueMessage, q };
52
+ export { Queue, type QueueContext, type QueueHandler, type QueueMessage };
60
53
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/queue/QueueBuilder.ts","../../src/queue/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;AAmBA;;AAEkB,cAFL,YAEK,CAAA,cAAA,MAAA,GAAA,MAAA,EAAA,iBAAA,gBAAA,GAAA,SAAA,GAAA,SAAA,EAAA,kBACC,OADD,EAAA,GAAA,EAAA,EAAA,gBAED,MAFC,GAEQ,MAFR,CAAA,CAAA;EAAgB,QACf,KAAA;EAAO,QACT,cAAA;EAAM,QAAG,QAAA;EAAM,QAcxB,UAAA;EAAC,QACQ,KAAA;EAAC,QAAE,SAAA;EAAQ;EAAW,WAAE,EAAA,MAAA,EAAA;EAAO,QAA5C,OAAA;EAAY;EAkC8B,KAChC,CAAA,UAAA,MAAA,CAAA,CAAA,IAAA,EApCN,CAoCM,CAAA,EAnCV,YAmCU,CAnCG,CAmCH,EAnCM,QAmCN,EAnCgB,SAmChB,EAnC2B,OAmC3B,CAAA;EAAC,OACE,CAAA,OAAA,EAAA,MAAA,CAAA,EAAA,IAAA;EAAK;EAAU,SAAM,CAAA,SAAA,EAAA,MAAA,CAAA,EAAA,IAAA;EAAS;EAAiB,IAAZ,CAAA,IAAA,CAAA,EAAA,OAAA,CAAA,EAAA,IAAA;EAAU;;;;;;;;;;;EAkCtC,SACd,CAAA,gBAAA,SArC0B,UAqC1B,EAAA,CAAA,CAAA,UAAA,EApCI,CAoCJ,CAAA,EAnCN,YAmCM,CAnCO,KAmCP,EAnCc,QAmCd,EAAA,CAAA,GAnC4B,SAmC5B,EAAA,GAnC0C,UAmC1C,CAnCqD,CAmCrD,CAAA,CAAA,EAnC0D,OAmC1D,CAAA;EAAC,QACM,CAAA,UAfG,OAeH,EAAA,CAAA,CAAA,QAAA,EAdL,CAcK,CAAA,EAbb,YAaa,CAbA,KAaA,EAbO,QAaP,EAAA,CAAA,GAbqB,SAarB,EAAA,GAbmC,CAanC,CAAA,EAbuC,OAavC,CAAA;EAAK,MAAE,CAAA,UAFN,MAEM,CAAA,CAAA,MAAA,EADd,CACc,CAAA,EAApB,YAAoB,CAAP,KAAO,EAAA,QAAA,EAAU,SAAV,EAAqB,CAArB,CAAA;EAAQ;EAAW,OAAE,CAAA,UAO1B,gBAP0B,CAAA,CAAA,MAAA,EAQnC,CARmC,CAAA,EASzC,YATyC,CAS5B,KAT4B,EASrB,CATqB,EASlB,SATkB,EASP,OATO,CAAA;EAAC,MAA1C,CAAA,EAAA,EAgBE,YAhBF,CAgBe,WAhBf,CAgB2B,QAhB3B,CAAA,EAgBsC,SAhBtC,EAgBiD,OAhBjD,CAAA,CAAA,EAiBA,KAjBA,CAiBM,KAjBN,EAiBa,WAjBb,CAiByB,QAjBzB,CAAA,EAiBoC,SAjBpC,EAiB+C,OAjB/C,CAAA;;;;;cCnGS,GAAC,oCAAqB,mBAAA,CAArB,MAAA"}
1
+ {"version":3,"file":"index.d.mts","names":["Logger"],"sources":["../../src/queue/QueueBuilder.ts","../../src/queue/index.ts"],"mappings":";;;;;;;;;;;;qBAmBa,aACZ,+BACA,iBAAiB,0CACjB,kBAAkB,gBAClB,gBAAgBA,WAASA;UAEjB;UACA;UACA;UACA;UACA;UACA;;EAED;UACC;;EAGR,MAAM,kBACL,MAAM,IACJ,aAAa,GAAG,UAAU,WAAW;EASxC,QAAQ;;EAKR,UAAU;;EAKV,KAAK;;;;;;;;;;;;EAeL,gBAAgB,mBAAmB,cAClC,YAAY,IACV,aAAa,OAAO,cAAc,cAAc,WAAW,KAAK;EAqBnE,SAAS,UAAU,WAClB,UAAU,IACR,aAAa,OAAO,cAAc,cAAc,IAAI;EAWvD,OAAO,UAAUA,UAChB,QAAQ,IACN,aAAa,OAAO,UAAU,WAAW;;EAO5C,QAAQ,UAAU,kBACjB,QAAQ,IACN,aAAa,OAAO,GAAG,WAAW;EAMrC,OACC,IAAI,aAAa,YAAY,WAAW,WAAW,WACjD,MAAM,OAAO,YAAY,WAAW,WAAW;;;;qBCpHtC,GAAC,oCAAA"}
@@ -1,10 +1,9 @@
1
- import { Construct, ConstructType } from "../Construct-BD5neF7w.mjs";
2
- import { idsOf, servicesOf } from "../construct-interface-Z4CpS8tK.mjs";
3
- import { cloneWith } from "../clone-DblgEZZa.mjs";
1
+ import { t as Construct } from "../Construct-Detz65RA.mjs";
2
+ import { idsOf, servicesOf } from "../construct-interface.mjs";
3
+ import { t as cloneWith } from "../clone-EKNovYHu.mjs";
4
4
  import { canonicalId, provideKey, serviceKey } from "@geekmidas/manifest";
5
5
  import { DEFAULT_LOGGER } from "@geekmidas/logger/console";
6
6
  import { Publisher } from "@geekmidas/events";
7
-
8
7
  //#region src/queue/Queue.ts
9
8
  /**
10
9
  * A queue worker — a point-to-point SQS-style queue and its single consumer.
@@ -16,9 +15,17 @@ import { Publisher } from "@geekmidas/events";
16
15
  * that any endpoint/function drops into `.services([...])` to send messages.
17
16
  */
18
17
  var Queue = class extends Construct {
18
+ name;
19
+ handler;
20
+ messageSchema;
21
+ timeout;
22
+ services;
23
+ logger;
24
+ batchSize;
25
+ fifo;
19
26
  __IS_QUEUE__ = true;
20
27
  static isQueue(obj) {
21
- return Boolean(obj && obj.__IS_QUEUE__ === true && obj.type === ConstructType.Queue);
28
+ return Boolean(obj && obj.__IS_QUEUE__ === true && obj.type === "dev.geekmidas.function.queue");
22
29
  }
23
30
  /**
24
31
  * The canonical id this queue is declared under.
@@ -36,7 +43,7 @@ var Queue = class extends Construct {
36
43
  */
37
44
  connectionKey;
38
45
  constructor(name, handler, messageSchema, timeout = 3e4, services = [], logger = DEFAULT_LOGGER, batchSize, fifo, constructs = []) {
39
- super(ConstructType.Queue, logger, services, [], void 0, void 0, timeout, void 0, void 0, constructs);
46
+ super("dev.geekmidas.function.queue", logger, services, [], void 0, void 0, timeout, void 0, void 0, constructs);
40
47
  this.name = name;
41
48
  this.handler = handler;
42
49
  this.messageSchema = messageSchema;
@@ -107,7 +114,6 @@ var Queue = class extends Construct {
107
114
  };
108
115
  }
109
116
  };
110
-
111
117
  //#endregion
112
118
  //#region src/queue/QueueBuilder.ts
113
119
  /**
@@ -172,15 +178,13 @@ var QueueBuilder = class {
172
178
  handle(fn) {
173
179
  if (!this._name) throw new Error("Queue requires a name — call .queue(name) before .handle().");
174
180
  if (!this._messageSchema) throw new Error("Queue requires a message schema — call .message(schema) before .handle().");
175
- const queue = new Queue(this._name, fn, this._messageSchema, this._timeout, this._services, this._logger, this._batchSize, this._fifo, this._constructs);
176
- return queue;
181
+ return new Queue(this._name, fn, this._messageSchema, this._timeout, this._services, this._logger, this._batchSize, this._fifo, this._constructs);
177
182
  }
178
183
  };
179
-
180
184
  //#endregion
181
185
  //#region src/queue/index.ts
182
186
  const q = new QueueBuilder();
183
-
184
187
  //#endregion
185
188
  export { Queue, QueueBuilder, q };
189
+
186
190
  //# sourceMappingURL=index.mjs.map