@geekmidas/constructs 10.0.0-alpha.6 → 10.0.0-alpha.61

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 (405) hide show
  1. package/README.md +223 -158
  2. package/dist/{Construct-BD5neF7w.mjs → Construct-BO1X-kt9.mjs} +32 -33
  3. package/dist/Construct-BO1X-kt9.mjs.map +1 -0
  4. package/dist/Construct-BQALFCh2.d.cts +230 -0
  5. package/dist/Construct-BQALFCh2.d.cts.map +1 -0
  6. package/dist/{Construct-CyS3RpTL.cjs → Construct-DmvXceVY.cjs} +52 -47
  7. package/dist/Construct-DmvXceVY.cjs.map +1 -0
  8. package/dist/Construct-QXnl3VqT.d.mts +230 -0
  9. package/dist/Construct-QXnl3VqT.d.mts.map +1 -0
  10. package/dist/{Cron-DmQ8vQ4b.d.cts → Cron-DI3nKoic.d.cts} +15 -9
  11. package/dist/Cron-DI3nKoic.d.cts.map +1 -0
  12. package/dist/{Cron-dh4rUgib.d.mts → Cron-uYAHPnp7.d.mts} +15 -9
  13. package/dist/Cron-uYAHPnp7.d.mts.map +1 -0
  14. package/dist/{CronBuilder-Da0C0edR.cjs → CronBuilder-BoHzlWU_.cjs} +47 -31
  15. package/dist/CronBuilder-BoHzlWU_.cjs.map +1 -0
  16. package/dist/{CronBuilder-CYKT5RiO.mjs → CronBuilder-CCgt0wCE.mjs} +37 -21
  17. package/dist/CronBuilder-CCgt0wCE.mjs.map +1 -0
  18. package/dist/CronBuilder-DaSUm2Na.d.mts +47 -0
  19. package/dist/CronBuilder-DaSUm2Na.d.mts.map +1 -0
  20. package/dist/CronBuilder-g1lZLWyG.d.cts +47 -0
  21. package/dist/CronBuilder-g1lZLWyG.d.cts.map +1 -0
  22. package/dist/{Endpoint-BjWKinFA.d.mts → Endpoint-BJDBZBZu.d.mts} +75 -91
  23. package/dist/Endpoint-BJDBZBZu.d.mts.map +1 -0
  24. package/dist/{Endpoint-DCQPMdUX.mjs → Endpoint-CMWWrQ7u.mjs} +140 -109
  25. package/dist/Endpoint-CMWWrQ7u.mjs.map +1 -0
  26. package/dist/{Endpoint-dav89W6-.d.cts → Endpoint-DV3jK5sP.d.cts} +74 -90
  27. package/dist/Endpoint-DV3jK5sP.d.cts.map +1 -0
  28. package/dist/{Endpoint-DcWXE-SZ.cjs → Endpoint-DfiXTm_v.cjs} +168 -131
  29. package/dist/Endpoint-DfiXTm_v.cjs.map +1 -0
  30. package/dist/{EndpointFactory-CjV8F_lJ.mjs → EndpointFactory-7g4Dg6cW.mjs} +41 -75
  31. package/dist/EndpointFactory-7g4Dg6cW.mjs.map +1 -0
  32. package/dist/{EndpointFactory-CdWB7wPw.cjs → EndpointFactory-CLxrcS0O.cjs} +77 -111
  33. package/dist/EndpointFactory-CLxrcS0O.cjs.map +1 -0
  34. package/dist/{index-Bd5FqCoe.d.cts → EndpointFactory-CLzCLkLt.d.cts} +64 -133
  35. package/dist/EndpointFactory-CLzCLkLt.d.cts.map +1 -0
  36. package/dist/{index-lAO9egTb.d.mts → EndpointFactory-gaF4yRpP.d.mts} +65 -134
  37. package/dist/EndpointFactory-gaF4yRpP.d.mts.map +1 -0
  38. package/dist/Function-DuqGcbOI.d.mts +76 -0
  39. package/dist/Function-DuqGcbOI.d.mts.map +1 -0
  40. package/dist/Function-Pu-1kKZz.d.cts +76 -0
  41. package/dist/Function-Pu-1kKZz.d.cts.map +1 -0
  42. package/dist/{HonoEndpointAdaptor-DtL9j19R.cjs → HonoEndpointAdaptor-B22boEAR.cjs} +52 -54
  43. package/dist/HonoEndpointAdaptor-B22boEAR.cjs.map +1 -0
  44. package/dist/{HonoEndpointAdaptor-P1ahhZHu.mjs → HonoEndpointAdaptor-vY4JKG8i.mjs} +42 -47
  45. package/dist/HonoEndpointAdaptor-vY4JKG8i.mjs.map +1 -0
  46. package/dist/Queue-D5jcw0mu.cjs +109 -0
  47. package/dist/Queue-D5jcw0mu.cjs.map +1 -0
  48. package/dist/{Queue-D7ZuwBhy.d.cts → Queue-DlsHRzUp.d.mts} +48 -48
  49. package/dist/Queue-DlsHRzUp.d.mts.map +1 -0
  50. package/dist/{Queue-gVGfi2Yk.d.mts → Queue-HPyi0e1i.d.cts} +49 -49
  51. package/dist/Queue-HPyi0e1i.d.cts.map +1 -0
  52. package/dist/Queue-hwPN-t31.mjs +104 -0
  53. package/dist/Queue-hwPN-t31.mjs.map +1 -0
  54. package/dist/QueueBuilder-BFQn3OzZ.cjs +135 -0
  55. package/dist/QueueBuilder-BFQn3OzZ.cjs.map +1 -0
  56. package/dist/QueueBuilder-DCuYdjMw.mjs +118 -0
  57. package/dist/QueueBuilder-DCuYdjMw.mjs.map +1 -0
  58. package/dist/QueueBuilder-OSi6LkV9.d.cts +75 -0
  59. package/dist/QueueBuilder-OSi6LkV9.d.cts.map +1 -0
  60. package/dist/QueueBuilder-QHsnVt1P.d.mts +75 -0
  61. package/dist/QueueBuilder-QHsnVt1P.d.mts.map +1 -0
  62. package/dist/{Subscriber-2mEi0ImH.d.cts → Subscriber-Bpp02cGr.d.cts} +29 -20
  63. package/dist/Subscriber-Bpp02cGr.d.cts.map +1 -0
  64. package/dist/{Subscriber-xTJ9ayPN.d.mts → Subscriber-CtN9R48-.d.mts} +29 -20
  65. package/dist/Subscriber-CtN9R48-.d.mts.map +1 -0
  66. package/dist/{SubscriberBuilder-4OPehf2R.cjs → SubscriberBuilder-C2PwqwIl.cjs} +61 -36
  67. package/dist/SubscriberBuilder-C2PwqwIl.cjs.map +1 -0
  68. package/dist/SubscriberBuilder-CuCMFpYW.d.mts +67 -0
  69. package/dist/SubscriberBuilder-CuCMFpYW.d.mts.map +1 -0
  70. package/dist/{SubscriberBuilder-BjkbeT9l.mjs → SubscriberBuilder-DMFk_Ap1.mjs} +50 -24
  71. package/dist/SubscriberBuilder-DMFk_Ap1.mjs.map +1 -0
  72. package/dist/SubscriberBuilder-g3fAVWgs.d.cts +67 -0
  73. package/dist/SubscriberBuilder-g3fAVWgs.d.cts.map +1 -0
  74. package/dist/Topic-CkxOTrMv.cjs +104 -0
  75. package/dist/Topic-CkxOTrMv.cjs.map +1 -0
  76. package/dist/Topic-hPffOsot.mjs +99 -0
  77. package/dist/Topic-hPffOsot.mjs.map +1 -0
  78. package/dist/adaptors/aws.cjs +118 -216
  79. package/dist/adaptors/aws.cjs.map +1 -1
  80. package/dist/adaptors/aws.d.cts +34 -53
  81. package/dist/adaptors/aws.d.cts.map +1 -1
  82. package/dist/adaptors/aws.d.mts +35 -54
  83. package/dist/adaptors/aws.d.mts.map +1 -1
  84. package/dist/adaptors/aws.mjs +91 -191
  85. package/dist/adaptors/aws.mjs.map +1 -1
  86. package/dist/adaptors/hono.cjs +3 -10
  87. package/dist/adaptors/hono.d.cts +7 -16
  88. package/dist/adaptors/hono.d.cts.map +1 -1
  89. package/dist/adaptors/hono.d.mts +8 -17
  90. package/dist/adaptors/hono.d.mts.map +1 -1
  91. package/dist/adaptors/hono.mjs +2 -10
  92. package/dist/adaptors/testing.cjs +711 -89
  93. package/dist/adaptors/testing.cjs.map +1 -1
  94. package/dist/adaptors/testing.d.cts +325 -54
  95. package/dist/adaptors/testing.d.cts.map +1 -1
  96. package/dist/adaptors/testing.d.mts +325 -54
  97. package/dist/adaptors/testing.d.mts.map +1 -1
  98. package/dist/adaptors/testing.mjs +676 -70
  99. package/dist/adaptors/testing.mjs.map +1 -1
  100. package/dist/auth-CIFXNuDk.d.cts +194 -0
  101. package/dist/auth-CIFXNuDk.d.cts.map +1 -0
  102. package/dist/auth-CJ9Ff6Lu.d.mts +194 -0
  103. package/dist/auth-CJ9Ff6Lu.d.mts.map +1 -0
  104. package/dist/auth.cjs +172 -31
  105. package/dist/auth.cjs.map +1 -1
  106. package/dist/auth.d.cts +2 -108
  107. package/dist/auth.d.mts +2 -108
  108. package/dist/auth.mjs +161 -24
  109. package/dist/auth.mjs.map +1 -1
  110. package/dist/{cache-BrRz3fEB.d.mts → cache-CXh6GIgb.d.mts} +3 -6
  111. package/dist/cache-CXh6GIgb.d.mts.map +1 -0
  112. package/dist/{cache-BtZY_tHe.d.cts → cache-DnGDGly3.d.cts} +3 -6
  113. package/dist/cache-DnGDGly3.d.cts.map +1 -0
  114. package/dist/cache.cjs +68 -2
  115. package/dist/cache.cjs.map +1 -0
  116. package/dist/cache.d.cts +1 -2
  117. package/dist/cache.d.mts +1 -2
  118. package/dist/cache.mjs +67 -2
  119. package/dist/cache.mjs.map +1 -0
  120. package/dist/cipher-C1lEFX63.mjs +225 -0
  121. package/dist/cipher-C1lEFX63.mjs.map +1 -0
  122. package/dist/cipher-CVxfwLjk.cjs +332 -0
  123. package/dist/cipher-CVxfwLjk.cjs.map +1 -0
  124. package/dist/{clone-DblgEZZa.mjs → clone-EKNovYHu.mjs} +3 -3
  125. package/dist/clone-EKNovYHu.mjs.map +1 -0
  126. package/dist/{clone-Dy0cR2SZ.cjs → clone-UGJpvQnL.cjs} +7 -8
  127. package/dist/clone-UGJpvQnL.cjs.map +1 -0
  128. package/dist/{construct-interface-D9d4Gm4p.d.cts → construct-interface-B1AfqRl4.d.cts} +42 -11
  129. package/dist/construct-interface-B1AfqRl4.d.cts.map +1 -0
  130. package/dist/{construct-interface-g5GM5pwR.d.mts → construct-interface-DluK3_da.d.mts} +42 -11
  131. package/dist/construct-interface-DluK3_da.d.mts.map +1 -0
  132. package/dist/construct-interface.cjs +113 -7
  133. package/dist/construct-interface.cjs.map +1 -0
  134. package/dist/construct-interface.d.cts +2 -2
  135. package/dist/construct-interface.d.mts +2 -2
  136. package/dist/construct-interface.mjs +106 -2
  137. package/dist/construct-interface.mjs.map +1 -0
  138. package/dist/credential.cjs +63 -16
  139. package/dist/credential.cjs.map +1 -1
  140. package/dist/credential.d.cts +16 -9
  141. package/dist/credential.d.cts.map +1 -1
  142. package/dist/credential.d.mts +16 -9
  143. package/dist/credential.d.mts.map +1 -1
  144. package/dist/credential.mjs +58 -12
  145. package/dist/credential.mjs.map +1 -1
  146. package/dist/crons/index.cjs +105 -7
  147. package/dist/crons/index.cjs.map +1 -1
  148. package/dist/crons/index.d.cts +40 -11
  149. package/dist/crons/index.d.cts.map +1 -1
  150. package/dist/crons/index.d.mts +40 -11
  151. package/dist/crons/index.d.mts.map +1 -1
  152. package/dist/crons/index.mjs +103 -8
  153. package/dist/crons/index.mjs.map +1 -1
  154. package/dist/database/kysely.cjs +4 -181
  155. package/dist/database/kysely.d.cts +2 -152
  156. package/dist/database/kysely.d.mts +2 -152
  157. package/dist/database/kysely.mjs +2 -180
  158. package/dist/email.cjs +25 -12
  159. package/dist/email.cjs.map +1 -1
  160. package/dist/email.d.cts +3 -7
  161. package/dist/email.d.cts.map +1 -1
  162. package/dist/email.d.mts +3 -7
  163. package/dist/email.d.mts.map +1 -1
  164. package/dist/email.mjs +16 -3
  165. package/dist/email.mjs.map +1 -1
  166. package/dist/encryption.cjs +96 -0
  167. package/dist/encryption.cjs.map +1 -0
  168. package/dist/encryption.d.cts +117 -0
  169. package/dist/encryption.d.cts.map +1 -0
  170. package/dist/encryption.d.mts +117 -0
  171. package/dist/encryption.d.mts.map +1 -0
  172. package/dist/encryption.mjs +83 -0
  173. package/dist/encryption.mjs.map +1 -0
  174. package/dist/endpoints/index.cjs +8 -10
  175. package/dist/endpoints/index.d.cts +51 -7
  176. package/dist/endpoints/index.d.cts.map +1 -0
  177. package/dist/endpoints/index.d.mts +51 -7
  178. package/dist/endpoints/index.d.mts.map +1 -0
  179. package/dist/endpoints/index.mjs +6 -10
  180. package/dist/external-api-CWY9orcO.d.mts +86 -0
  181. package/dist/external-api-CWY9orcO.d.mts.map +1 -0
  182. package/dist/external-api-D-5WB-sr.d.cts +86 -0
  183. package/dist/external-api-D-5WB-sr.d.cts.map +1 -0
  184. package/dist/external-api.cjs +124 -0
  185. package/dist/external-api.cjs.map +1 -0
  186. package/dist/external-api.d.cts +2 -0
  187. package/dist/external-api.d.mts +2 -0
  188. package/dist/external-api.mjs +121 -0
  189. package/dist/external-api.mjs.map +1 -0
  190. package/dist/file-server.cjs +42 -10
  191. package/dist/file-server.cjs.map +1 -1
  192. package/dist/file-server.d.cts +6 -10
  193. package/dist/file-server.d.cts.map +1 -1
  194. package/dist/file-server.d.mts +6 -10
  195. package/dist/file-server.d.mts.map +1 -1
  196. package/dist/file-server.mjs +34 -2
  197. package/dist/file-server.mjs.map +1 -1
  198. package/dist/functions/index.cjs +3 -6
  199. package/dist/functions/index.d.cts +3 -4
  200. package/dist/functions/index.d.mts +3 -4
  201. package/dist/functions/index.mjs +2 -6
  202. package/dist/{functions-i_la-N5r.cjs → functions-CbP5ZKma.cjs} +414 -264
  203. package/dist/functions-CbP5ZKma.cjs.map +1 -0
  204. package/dist/{functions-14lpEFL4.mjs → functions-Di6n5ltG.mjs} +376 -238
  205. package/dist/{functions-14lpEFL4.mjs.map → functions-Di6n5ltG.mjs.map} +1 -1
  206. package/dist/index-BuzRvKOQ.d.cts +115 -0
  207. package/dist/index-BuzRvKOQ.d.cts.map +1 -0
  208. package/dist/index-CTkKOer4.d.mts +115 -0
  209. package/dist/index-CTkKOer4.d.mts.map +1 -0
  210. package/dist/index-CeEtxDmK.d.cts +79 -0
  211. package/dist/index-CeEtxDmK.d.cts.map +1 -0
  212. package/dist/index-CeEtxDmK.d.mts +79 -0
  213. package/dist/index-CeEtxDmK.d.mts.map +1 -0
  214. package/dist/index.cjs +6 -3
  215. package/dist/index.d.cts +26 -4
  216. package/dist/index.d.cts.map +1 -0
  217. package/dist/index.d.mts +26 -4
  218. package/dist/index.d.mts.map +1 -0
  219. package/dist/index.mjs +3 -3
  220. package/dist/kms-B-Hm3d5r.cjs +85 -0
  221. package/dist/kms-B-Hm3d5r.cjs.map +1 -0
  222. package/dist/kms-BdUlMJEZ.mjs +85 -0
  223. package/dist/kms-BdUlMJEZ.mjs.map +1 -0
  224. package/dist/kysely-BEm5sDlU.d.cts +173 -0
  225. package/dist/kysely-BEm5sDlU.d.cts.map +1 -0
  226. package/dist/kysely-BRzzawr2.cjs +301 -0
  227. package/dist/kysely-BRzzawr2.cjs.map +1 -0
  228. package/dist/kysely-BYfM6Zby.mjs +288 -0
  229. package/dist/kysely-BYfM6Zby.mjs.map +1 -0
  230. package/dist/kysely-CjuvdXEV.d.mts +173 -0
  231. package/dist/kysely-CjuvdXEV.d.mts.map +1 -0
  232. package/dist/{lazyAccessors-BoJN3SMd.mjs → lazyAccessors-CFanua0O.mjs} +20 -60
  233. package/dist/lazyAccessors-CFanua0O.mjs.map +1 -0
  234. package/dist/{lazyAccessors-e3j2oE2m.cjs → lazyAccessors-hJKGv8Ay.cjs} +60 -113
  235. package/dist/lazyAccessors-hJKGv8Ay.cjs.map +1 -0
  236. package/dist/mobile-app.cjs +73 -0
  237. package/dist/mobile-app.cjs.map +1 -0
  238. package/dist/mobile-app.d.cts +61 -0
  239. package/dist/mobile-app.d.cts.map +1 -0
  240. package/dist/mobile-app.d.mts +61 -0
  241. package/dist/mobile-app.d.mts.map +1 -0
  242. package/dist/mobile-app.mjs +72 -0
  243. package/dist/mobile-app.mjs.map +1 -0
  244. package/dist/object-storage.cjs +18 -10
  245. package/dist/object-storage.cjs.map +1 -1
  246. package/dist/object-storage.d.cts +3 -7
  247. package/dist/object-storage.d.cts.map +1 -1
  248. package/dist/object-storage.d.mts +3 -7
  249. package/dist/object-storage.d.mts.map +1 -1
  250. package/dist/object-storage.mjs +11 -3
  251. package/dist/object-storage.mjs.map +1 -1
  252. package/dist/{processAudits-Dmts9H_b.mjs → processAudits-BpRlPQMW.mjs} +16 -19
  253. package/dist/processAudits-BpRlPQMW.mjs.map +1 -0
  254. package/dist/{processAudits-CGqttuXm.cjs → processAudits-D_2W5x8k.cjs} +26 -30
  255. package/dist/processAudits-D_2W5x8k.cjs.map +1 -0
  256. package/dist/queue/index.cjs +6 -189
  257. package/dist/queue/index.d.cts +3 -60
  258. package/dist/queue/index.d.mts +3 -60
  259. package/dist/queue/index.mjs +3 -186
  260. package/dist/rest-api.cjs +88 -63
  261. package/dist/rest-api.cjs.map +1 -1
  262. package/dist/rest-api.d.cts +68 -61
  263. package/dist/rest-api.d.cts.map +1 -1
  264. package/dist/rest-api.d.mts +68 -61
  265. package/dist/rest-api.d.mts.map +1 -1
  266. package/dist/rest-api.mjs +80 -55
  267. package/dist/rest-api.mjs.map +1 -1
  268. package/dist/{chunk-DWy1uDak.cjs → rolldown-runtime-y5ARvAq5.cjs} +14 -18
  269. package/dist/runSubscriber-BRp9a_qi.cjs +126 -0
  270. package/dist/runSubscriber-BRp9a_qi.cjs.map +1 -0
  271. package/dist/runSubscriber-BYEY_bfA.mjs +109 -0
  272. package/dist/runSubscriber-BYEY_bfA.mjs.map +1 -0
  273. package/dist/shutdown-BMJmAhSt.cjs +38 -0
  274. package/dist/shutdown-BMJmAhSt.cjs.map +1 -0
  275. package/dist/shutdown-C7xa8x9S.mjs +27 -0
  276. package/dist/shutdown-C7xa8x9S.mjs.map +1 -0
  277. package/dist/site.cjs +34 -9
  278. package/dist/site.cjs.map +1 -1
  279. package/dist/site.d.cts +17 -22
  280. package/dist/site.d.cts.map +1 -1
  281. package/dist/site.d.mts +17 -22
  282. package/dist/site.d.mts.map +1 -1
  283. package/dist/site.mjs +30 -5
  284. package/dist/site.mjs.map +1 -1
  285. package/dist/subscribers/index.cjs +111 -6
  286. package/dist/subscribers/index.cjs.map +1 -0
  287. package/dist/subscribers/index.d.cts +50 -6
  288. package/dist/subscribers/index.d.cts.map +1 -0
  289. package/dist/subscribers/index.d.mts +50 -6
  290. package/dist/subscribers/index.d.mts.map +1 -0
  291. package/dist/subscribers/index.mjs +108 -5
  292. package/dist/subscribers/index.mjs.map +1 -0
  293. package/dist/surfaceEnv-CNimK76p.cjs +56 -0
  294. package/dist/surfaceEnv-CNimK76p.cjs.map +1 -0
  295. package/dist/surfaceEnv-wMT5QzgZ.mjs +45 -0
  296. package/dist/surfaceEnv-wMT5QzgZ.mjs.map +1 -0
  297. package/dist/{telemetry-C3L0iS28.d.cts → telemetry-DGcFlVpB.d.cts} +2 -5
  298. package/dist/telemetry-DGcFlVpB.d.cts.map +1 -0
  299. package/dist/{telemetry-D7bVFLGi.d.mts → telemetry-DGcFlVpB.d.mts} +2 -5
  300. package/dist/telemetry-DGcFlVpB.d.mts.map +1 -0
  301. package/dist/topic/index.cjs +3 -137
  302. package/dist/topic/index.d.cts +2 -4
  303. package/dist/topic/index.d.mts +2 -4
  304. package/dist/topic/index.mjs +2 -134
  305. package/dist/{types-BlAkSuGI.d.cts → types-DMuSQeLL.d.cts} +3 -5
  306. package/dist/types-DMuSQeLL.d.cts.map +1 -0
  307. package/dist/{types-aKksMEWL.d.mts → types-DMuSQeLL.d.mts} +3 -5
  308. package/dist/types-DMuSQeLL.d.mts.map +1 -0
  309. package/dist/types.d.cts +1 -1
  310. package/dist/types.d.mts +1 -1
  311. package/dist/types.mjs +1 -0
  312. package/dist/worker.cjs +58 -34
  313. package/dist/worker.cjs.map +1 -1
  314. package/dist/worker.d.cts +63 -45
  315. package/dist/worker.d.cts.map +1 -1
  316. package/dist/worker.d.mts +63 -44
  317. package/dist/worker.d.mts.map +1 -1
  318. package/dist/worker.mjs +53 -29
  319. package/dist/worker.mjs.map +1 -1
  320. package/package.json +82 -41
  321. package/dist/Construct-BD5neF7w.mjs.map +0 -1
  322. package/dist/Construct-C0ijr2qp.d.cts +0 -117
  323. package/dist/Construct-C0ijr2qp.d.cts.map +0 -1
  324. package/dist/Construct-Ct8nalEi.d.mts +0 -117
  325. package/dist/Construct-Ct8nalEi.d.mts.map +0 -1
  326. package/dist/Construct-CyS3RpTL.cjs.map +0 -1
  327. package/dist/Cron-DmQ8vQ4b.d.cts.map +0 -1
  328. package/dist/Cron-dh4rUgib.d.mts.map +0 -1
  329. package/dist/CronBuilder-BquXDbDI.d.cts +0 -44
  330. package/dist/CronBuilder-BquXDbDI.d.cts.map +0 -1
  331. package/dist/CronBuilder-CGgY2080.d.mts +0 -44
  332. package/dist/CronBuilder-CGgY2080.d.mts.map +0 -1
  333. package/dist/CronBuilder-CYKT5RiO.mjs.map +0 -1
  334. package/dist/CronBuilder-Da0C0edR.cjs.map +0 -1
  335. package/dist/Endpoint-BjWKinFA.d.mts.map +0 -1
  336. package/dist/Endpoint-DCQPMdUX.mjs.map +0 -1
  337. package/dist/Endpoint-DcWXE-SZ.cjs.map +0 -1
  338. package/dist/Endpoint-dav89W6-.d.cts.map +0 -1
  339. package/dist/EndpointFactory-CdWB7wPw.cjs.map +0 -1
  340. package/dist/EndpointFactory-CjV8F_lJ.mjs.map +0 -1
  341. package/dist/HonoEndpointAdaptor-DtL9j19R.cjs.map +0 -1
  342. package/dist/HonoEndpointAdaptor-P1ahhZHu.mjs.map +0 -1
  343. package/dist/Queue-D7ZuwBhy.d.cts.map +0 -1
  344. package/dist/Queue-gVGfi2Yk.d.mts.map +0 -1
  345. package/dist/Subscriber-2mEi0ImH.d.cts.map +0 -1
  346. package/dist/Subscriber-xTJ9ayPN.d.mts.map +0 -1
  347. package/dist/SubscriberBuilder-4OPehf2R.cjs.map +0 -1
  348. package/dist/SubscriberBuilder-BjkbeT9l.mjs.map +0 -1
  349. package/dist/SubscriberBuilder-Dptmo-1A.d.mts +0 -62
  350. package/dist/SubscriberBuilder-Dptmo-1A.d.mts.map +0 -1
  351. package/dist/SubscriberBuilder-waNhzjSM.d.cts +0 -62
  352. package/dist/SubscriberBuilder-waNhzjSM.d.cts.map +0 -1
  353. package/dist/Topic-19QeHBIR.d.cts +0 -91
  354. package/dist/Topic-19QeHBIR.d.cts.map +0 -1
  355. package/dist/Topic-DuFeqkBh.d.mts +0 -91
  356. package/dist/Topic-DuFeqkBh.d.mts.map +0 -1
  357. package/dist/auth.d.cts.map +0 -1
  358. package/dist/auth.d.mts.map +0 -1
  359. package/dist/cache-0ANvRQnD.mjs +0 -51
  360. package/dist/cache-0ANvRQnD.mjs.map +0 -1
  361. package/dist/cache-3WSvAulx.cjs +0 -57
  362. package/dist/cache-3WSvAulx.cjs.map +0 -1
  363. package/dist/cache-BrRz3fEB.d.mts.map +0 -1
  364. package/dist/cache-BtZY_tHe.d.cts.map +0 -1
  365. package/dist/clone-DblgEZZa.mjs.map +0 -1
  366. package/dist/clone-Dy0cR2SZ.cjs.map +0 -1
  367. package/dist/construct-interface-BfjcOD_E.cjs +0 -117
  368. package/dist/construct-interface-BfjcOD_E.cjs.map +0 -1
  369. package/dist/construct-interface-D9d4Gm4p.d.cts.map +0 -1
  370. package/dist/construct-interface-Z4CpS8tK.mjs +0 -81
  371. package/dist/construct-interface-Z4CpS8tK.mjs.map +0 -1
  372. package/dist/construct-interface-g5GM5pwR.d.mts.map +0 -1
  373. package/dist/database/kysely.cjs.map +0 -1
  374. package/dist/database/kysely.d.cts.map +0 -1
  375. package/dist/database/kysely.d.mts.map +0 -1
  376. package/dist/database/kysely.mjs.map +0 -1
  377. package/dist/functions-i_la-N5r.cjs.map +0 -1
  378. package/dist/index-Bd5FqCoe.d.cts.map +0 -1
  379. package/dist/index-BknhM6Ux.d.mts +0 -31
  380. package/dist/index-BknhM6Ux.d.mts.map +0 -1
  381. package/dist/index-CBSfrowv.d.cts +0 -31
  382. package/dist/index-CBSfrowv.d.cts.map +0 -1
  383. package/dist/index-D24Xm79M.d.cts +0 -171
  384. package/dist/index-D24Xm79M.d.cts.map +0 -1
  385. package/dist/index-_ajboYxK.d.mts +0 -171
  386. package/dist/index-_ajboYxK.d.mts.map +0 -1
  387. package/dist/index-lAO9egTb.d.mts.map +0 -1
  388. package/dist/lazyAccessors-BoJN3SMd.mjs.map +0 -1
  389. package/dist/lazyAccessors-e3j2oE2m.cjs.map +0 -1
  390. package/dist/processAudits-CGqttuXm.cjs.map +0 -1
  391. package/dist/processAudits-Dmts9H_b.mjs.map +0 -1
  392. package/dist/queue/index.cjs.map +0 -1
  393. package/dist/queue/index.d.cts.map +0 -1
  394. package/dist/queue/index.d.mts.map +0 -1
  395. package/dist/queue/index.mjs.map +0 -1
  396. package/dist/surfaceEnv-BFXEms2f.cjs +0 -39
  397. package/dist/surfaceEnv-BFXEms2f.cjs.map +0 -1
  398. package/dist/surfaceEnv-C3Ktahea.mjs +0 -27
  399. package/dist/surfaceEnv-C3Ktahea.mjs.map +0 -1
  400. package/dist/telemetry-C3L0iS28.d.cts.map +0 -1
  401. package/dist/telemetry-D7bVFLGi.d.mts.map +0 -1
  402. package/dist/topic/index.cjs.map +0 -1
  403. package/dist/topic/index.mjs.map +0 -1
  404. package/dist/types-BlAkSuGI.d.cts.map +0 -1
  405. package/dist/types-aKksMEWL.d.mts.map +0 -1
@@ -0,0 +1,288 @@
1
+ import { t as onShutdown } from "./shutdown-C7xa8x9S.mjs";
2
+ import { Cache } from "./cache.mjs";
3
+ import { DEFAULT_POSTGRES_VERSION, canonicalId, provideKey, serviceKey } from "@geekmidas/manifest";
4
+ import { Kysely, PostgresDialect } from "kysely";
5
+ import { currentRequestContext } from "@geekmidas/services";
6
+ import pg from "pg";
7
+ //#region src/database/pool.ts
8
+ /**
9
+ * The `pg` pools a database construct opens, and what every one of them gets:
10
+ *
11
+ * - **A name.** `application_name` is what `pg_stat_activity` shows beside a
12
+ * connection. Without one, a database at `max_connections` cannot say who
13
+ * holds them. It is a *fallback*, so `PGAPPNAME` or `?application_name=` in
14
+ * the URL still win.
15
+ * - **Tagged queries.** Inside a request, each query ends in a comment naming
16
+ * what ran it — `/*operation='POST /orders',request_id='…'*\/` — in the
17
+ * sqlcommenter form. It shows in `pg_stat_activity.query`, in the server's
18
+ * slow-query and `auto_explain` logs, and costs no round trip;
19
+ * `pg_stat_statements` ignores comments, so its grouping is unchanged.
20
+ * - **A listener for idle-client errors.** When the server ends an idle
21
+ * connection (`idle_session_timeout`, a failover, an admin), the pool emits
22
+ * `'error'`. With no listener that is an uncaught exception that kills the
23
+ * process — for a client the pool has already discarded.
24
+ * - **A way to close.** {@link closeDatabasePools} ends every pool opened, so a
25
+ * server shutting down releases its connections instead of holding them
26
+ * until the process dies.
27
+ */
28
+ /** Every pool opened and not yet closed, so a shutdown can end them all. */
29
+ const open = /* @__PURE__ */ new Set();
30
+ onShutdown(() => closeDatabasePools());
31
+ /**
32
+ * A pool for one URL, with its schema actually on the search path.
33
+ *
34
+ * `?search_path=` is not a libpq parameter — a URL carrying it connects
35
+ * happily and then resolves every unqualified name against `public`, which is
36
+ * how a schema tenant silently writes its tables into the database it was
37
+ * separated from. Postgres takes it as a startup option instead, so the URL
38
+ * keeps the readable form the target derives and this turns it into the thing
39
+ * the server understands.
40
+ */
41
+ function openPool(url, options = {}) {
42
+ const parsed = new URL(url);
43
+ const searchPath = parsed.searchParams.get("search_path");
44
+ parsed.searchParams.delete("search_path");
45
+ const pool = new pg.Pool({
46
+ connectionString: parsed.toString(),
47
+ ...searchPath ? { options: `-c search_path=${searchPath}` } : {},
48
+ fallback_application_name: applicationName()
49
+ });
50
+ pool.on("error", (error) => {
51
+ const logger = currentRequestContext()?.logger;
52
+ if (logger) logger.warn({ error }, "Idle database connection lost");
53
+ else console.warn("Idle database connection lost:", error.message);
54
+ });
55
+ if (options.queryTags !== false) pool.on("connect", (client) => tagQueries(client));
56
+ open.add(pool);
57
+ const end = pool.end.bind(pool);
58
+ pool.end = (async () => {
59
+ open.delete(pool);
60
+ await end();
61
+ });
62
+ return pool;
63
+ }
64
+ /**
65
+ * End every pool opened, waiting for checked-out connections to come back.
66
+ * For a server's shutdown, after it has stopped taking requests.
67
+ */
68
+ async function closeDatabasePools() {
69
+ await Promise.all([...open].map((pool) => pool.end()));
70
+ }
71
+ /**
72
+ * Who this process is, as Postgres will show it: the Lambda function, else the
73
+ * app — `GKM_APP_NAME` where an entry sets it, `gkm dev`'s app tag otherwise.
74
+ * Postgres keeps 63 bytes of it.
75
+ */
76
+ function applicationName(env = process.env) {
77
+ return env.AWS_LAMBDA_FUNCTION_NAME || env.GKM_APP_NAME || env.GKM_DEV_APP?.split("#").pop() || void 0;
78
+ }
79
+ /**
80
+ * The comment that says what ran a query, or '' outside a request.
81
+ *
82
+ * Values keep only characters that cannot end a comment or a quoted value —
83
+ * `*` and `'` among those dropped — so a route cannot inject SQL through it.
84
+ */
85
+ function queryTag() {
86
+ const request = currentRequestContext();
87
+ if (!request) return "";
88
+ const tags = [["operation", request.operation], ["request_id", request.requestId]].filter((tag) => Boolean(tag[1]));
89
+ if (tags.length === 0) return "";
90
+ const clean = (value) => value.replace(/[^\w ./:{}@-]/g, "");
91
+ return ` /*${tags.map(([key, value]) => `${key}='${clean(value)}'`).join(",")}*/`;
92
+ }
93
+ /**
94
+ * Append {@link queryTag} to everything `client` runs: a SQL string — what
95
+ * Kysely sends — or a query object such as a cursor's.
96
+ */
97
+ function tagQueries(client) {
98
+ const query = client.query.bind(client);
99
+ client.query = ((first, ...rest) => {
100
+ const tag = queryTag();
101
+ if (tag && typeof first === "string") return query(first + tag, ...rest);
102
+ if (tag && first && typeof first === "object" && typeof first.text === "string") {
103
+ const config = first;
104
+ config.text += tag;
105
+ }
106
+ return query(first, ...rest);
107
+ });
108
+ }
109
+ //#endregion
110
+ //#region src/database/kysely.ts
111
+ /**
112
+ * `KyselyDatabase` — a declared Postgres database, typed by its schema.
113
+ *
114
+ * It declares a logical database, a schema, and the roles that reach it, and
115
+ * hands back a Kysely client built from the one URL the adapter supplied. It
116
+ * names no cloud: `--target=aws` fills that URL from RDS, local dev from the
117
+ * Postgres container.
118
+ *
119
+ * Transactions and RLS context are the execution wrapper's job — it opens the
120
+ * transaction and puts it in `ctx.db`. This construct does not resolve
121
+ * connections per request.
122
+ */
123
+ /** The schema a database uses when it does not say otherwise. */
124
+ const DEFAULT_SCHEMA = "app";
125
+ /**
126
+ * @typeParam DB - the database's schema.
127
+ * @typeParam TName - the canonical id. TypeScript has no partial
128
+ * type-argument inference, so `new KyselyDatabase<OrdersDB>('orders')` leaves
129
+ * this at its default and the service key widens to `string`. `db` still types
130
+ * through `.database()`, which infers from the service.
131
+ */
132
+ var KyselyDatabase = class KyselyDatabase {
133
+ options;
134
+ id;
135
+ service;
136
+ /**
137
+ * Declared once and read by both `declare()` and `connect()`, so the key the
138
+ * build publishes and the key the client reads cannot drift.
139
+ */
140
+ config;
141
+ schemaName;
142
+ roles;
143
+ version;
144
+ derivedFrom;
145
+ constructor(id, options = {}, derivedFrom) {
146
+ this.options = options;
147
+ const canonical = canonicalId(id);
148
+ this.id = canonical;
149
+ this.config = {
150
+ url: provideKey(canonical, "url"),
151
+ ownerUrl: provideKey(canonical, "ownerUrl")
152
+ };
153
+ this.schemaName = options.schema ?? DEFAULT_SCHEMA;
154
+ this.roles = options.roles ?? true;
155
+ this.version = options.version ?? DEFAULT_POSTGRES_VERSION;
156
+ this.derivedFrom = derivedFrom;
157
+ this.service = {
158
+ serviceName: serviceKey(canonical),
159
+ register: (registerOptions) => this.connect(registerOptions)
160
+ };
161
+ }
162
+ declare() {
163
+ if (this.derivedFrom) {
164
+ const { kind, of, schema } = this.derivedFrom;
165
+ return [kind === "database-schema" ? {
166
+ kind,
167
+ id: this.id,
168
+ of,
169
+ schema: schema ?? this.schemaName,
170
+ provides: [this.config.url]
171
+ } : {
172
+ kind,
173
+ id: this.id,
174
+ of,
175
+ provides: [this.config.url]
176
+ }];
177
+ }
178
+ return [{
179
+ kind: "database",
180
+ id: this.id,
181
+ engine: "postgres",
182
+ schema: this.schemaName,
183
+ version: this.version,
184
+ provides: [this.config.url],
185
+ ...this.roles ? {} : { roles: false }
186
+ }];
187
+ }
188
+ /**
189
+ * A read-only endpoint on this database.
190
+ *
191
+ * Read-only is enforced by the reader role's grants rather than by which
192
+ * endpoint it resolves to, so falling back to the writer where no replica
193
+ * exists is safe rather than a silently writable connection behind a name
194
+ * that says reader. There is no `writer()`: the database *is* the writer, so
195
+ * a replica can never be reached by accident.
196
+ *
197
+ * The return type is narrower than this class on purpose — see
198
+ * {@link ReadOnlyDatabase}.
199
+ */
200
+ reader() {
201
+ return new KyselyDatabase(`${this.id}Reader`, this.options, {
202
+ kind: "database-reader",
203
+ of: this.id
204
+ });
205
+ }
206
+ /**
207
+ * A cache that lives in this database.
208
+ *
209
+ * The same strengthening `schema()` is over a second database: `new
210
+ * Cache('Sessions')` says the app caches and leaves where to the deployment,
211
+ * while this says it caches *here* — which is a fact about the application
212
+ * and so belongs in its code.
213
+ *
214
+ * What it buys beyond being explicit: the table's schema and the role that
215
+ * reaches it come from this database rather than from a second convention,
216
+ * and the backend no longer has to guess which database "the database" meant
217
+ * when an app declares two.
218
+ *
219
+ * A cache is not a `KyselyDatabase`, so this returns a `Cache` — the client
220
+ * is a key/value store, not a query builder, and typing it as the parent
221
+ * would be a convenience that lies.
222
+ */
223
+ cache(id = `${this.id}Cache`, options = {}) {
224
+ return new Cache(id, {
225
+ of: this.id,
226
+ ...options.table ? { table: options.table } : {}
227
+ });
228
+ }
229
+ /**
230
+ * A second schema in this database, with its own role(s) and its own URL —
231
+ * so this database's role holds no grant on those tables at all.
232
+ *
233
+ * Typed separately because a tenant has its own tables: the point is that
234
+ * `auth.selectFrom('sessions')` type-checks and
235
+ * `orders.selectFrom('sessions')` does not.
236
+ */
237
+ schema(id, options = {}) {
238
+ return new KyselyDatabase(id, options, {
239
+ kind: "database-schema",
240
+ of: this.id,
241
+ schema: options.schema ?? id.toLowerCase()
242
+ });
243
+ }
244
+ /**
245
+ * A connection as the *owner* role — the one that may create, alter and drop.
246
+ *
247
+ * A `Service` rather than part of the construct, and deliberately so: a
248
+ * construct is what `.dependsOn()` accepts, and nothing should be able to
249
+ * depend on this. A migrator asks for it by name; a handler cannot ask at
250
+ * all, which is the security property the role split exists for.
251
+ *
252
+ * Falls back to the runtime URL where no owner URL was published — the
253
+ * `roles: false` downgrade, where there is only one credential and it is the
254
+ * cluster master's.
255
+ */
256
+ get owner() {
257
+ return {
258
+ serviceName: `${serviceKey(this.id)}Owner`,
259
+ register: (options) => this.connect(options, { owner: true })
260
+ };
261
+ }
262
+ /**
263
+ * What this database's clients are built with besides a dialect — the
264
+ * plugins and logging it was declared with.
265
+ *
266
+ * Public so that whatever opens a connection to it outside \`connect()\` —
267
+ * a test's transaction — builds the same client. A test that dropped the
268
+ * plugins would write \`createdAt\` where production writes \`created_at\`.
269
+ */
270
+ get clientConfig() {
271
+ const { schema: _schema, roles: _roles, version: _version, queryTags: _queryTags, ...kysely } = this.options;
272
+ return kysely;
273
+ }
274
+ async connect(options, as = {}) {
275
+ const { url, ownerUrl } = options.envParser.create((get) => ({
276
+ url: get(this.config.url).string(),
277
+ ownerUrl: get(this.config.ownerUrl).string().optional()
278
+ })).parse();
279
+ return new Kysely({
280
+ ...this.clientConfig,
281
+ dialect: new PostgresDialect({ pool: openPool(as.owner ? ownerUrl ?? url : url, { queryTags: this.options.queryTags }) })
282
+ });
283
+ }
284
+ };
285
+ //#endregion
286
+ export { closeDatabasePools as n, KyselyDatabase as t };
287
+
288
+ //# sourceMappingURL=kysely-BYfM6Zby.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kysely-BYfM6Zby.mjs","names":[],"sources":["../src/database/pool.ts","../src/database/kysely.ts"],"sourcesContent":["/**\n * The `pg` pools a database construct opens, and what every one of them gets:\n *\n * - **A name.** `application_name` is what `pg_stat_activity` shows beside a\n * connection. Without one, a database at `max_connections` cannot say who\n * holds them. It is a *fallback*, so `PGAPPNAME` or `?application_name=` in\n * the URL still win.\n * - **Tagged queries.** Inside a request, each query ends in a comment naming\n * what ran it — `/*operation='POST /orders',request_id='…'*\\/` — in the\n * sqlcommenter form. It shows in `pg_stat_activity.query`, in the server's\n * slow-query and `auto_explain` logs, and costs no round trip;\n * `pg_stat_statements` ignores comments, so its grouping is unchanged.\n * - **A listener for idle-client errors.** When the server ends an idle\n * connection (`idle_session_timeout`, a failover, an admin), the pool emits\n * `'error'`. With no listener that is an uncaught exception that kills the\n * process — for a client the pool has already discarded.\n * - **A way to close.** {@link closeDatabasePools} ends every pool opened, so a\n * server shutting down releases its connections instead of holding them\n * until the process dies.\n */\n\nimport { currentRequestContext } from '@geekmidas/services';\nimport pg from 'pg';\nimport { onShutdown } from '../shutdown';\n\nexport interface DatabasePoolOptions {\n\t/** Tag queries run inside a request with what ran them. Default true. */\n\tqueryTags?: boolean;\n}\n\n/** Every pool opened and not yet closed, so a shutdown can end them all. */\nconst open = new Set<pg.Pool>();\nonShutdown(() => closeDatabasePools());\n\n/**\n * A pool for one URL, with its schema actually on the search path.\n *\n * `?search_path=` is not a libpq parameter — a URL carrying it connects\n * happily and then resolves every unqualified name against `public`, which is\n * how a schema tenant silently writes its tables into the database it was\n * separated from. Postgres takes it as a startup option instead, so the URL\n * keeps the readable form the target derives and this turns it into the thing\n * the server understands.\n */\nexport function openPool(\n\turl: string,\n\toptions: DatabasePoolOptions = {},\n): pg.Pool {\n\tconst parsed = new URL(url);\n\tconst searchPath = parsed.searchParams.get('search_path');\n\tparsed.searchParams.delete('search_path');\n\n\tconst pool = new pg.Pool({\n\t\tconnectionString: parsed.toString(),\n\t\t...(searchPath ? { options: `-c search_path=${searchPath}` } : {}),\n\t\tfallback_application_name: applicationName(),\n\t});\n\n\tpool.on('error', (error) => {\n\t\tconst logger = currentRequestContext()?.logger;\n\t\tif (logger) logger.warn({ error }, 'Idle database connection lost');\n\t\telse console.warn('Idle database connection lost:', error.message);\n\t});\n\tif (options.queryTags !== false) {\n\t\tpool.on('connect', (client) => tagQueries(client));\n\t}\n\n\topen.add(pool);\n\tconst end = pool.end.bind(pool);\n\tpool.end = (async () => {\n\t\topen.delete(pool);\n\t\tawait end();\n\t}) as typeof pool.end;\n\n\treturn pool;\n}\n\n/**\n * End every pool opened, waiting for checked-out connections to come back.\n * For a server's shutdown, after it has stopped taking requests.\n */\nexport async function closeDatabasePools(): Promise<void> {\n\tawait Promise.all([...open].map((pool) => pool.end()));\n}\n\n/**\n * Who this process is, as Postgres will show it: the Lambda function, else the\n * app — `GKM_APP_NAME` where an entry sets it, `gkm dev`'s app tag otherwise.\n * Postgres keeps 63 bytes of it.\n */\nexport function applicationName(\n\tenv: NodeJS.ProcessEnv = process.env,\n): string | undefined {\n\treturn (\n\t\tenv.AWS_LAMBDA_FUNCTION_NAME ||\n\t\tenv.GKM_APP_NAME ||\n\t\tenv.GKM_DEV_APP?.split('#').pop() ||\n\t\tundefined\n\t);\n}\n\n/**\n * The comment that says what ran a query, or '' outside a request.\n *\n * Values keep only characters that cannot end a comment or a quoted value —\n * `*` and `'` among those dropped — so a route cannot inject SQL through it.\n */\nexport function queryTag(): string {\n\tconst request = currentRequestContext();\n\tif (!request) return '';\n\n\tconst tags = [\n\t\t['operation', request.operation],\n\t\t['request_id', request.requestId],\n\t].filter((tag): tag is [string, string] => Boolean(tag[1]));\n\tif (tags.length === 0) return '';\n\n\tconst clean = (value: string) => value.replace(/[^\\w ./:{}@-]/g, '');\n\treturn ` /*${tags.map(([key, value]) => `${key}='${clean(value)}'`).join(',')}*/`;\n}\n\n/**\n * Append {@link queryTag} to everything `client` runs: a SQL string — what\n * Kysely sends — or a query object such as a cursor's.\n */\nfunction tagQueries(client: pg.PoolClient): void {\n\tconst query = client.query.bind(client) as (...args: unknown[]) => unknown;\n\tclient.query = ((first: unknown, ...rest: unknown[]) => {\n\t\tconst tag = queryTag();\n\t\tif (tag && typeof first === 'string') return query(first + tag, ...rest);\n\t\tif (\n\t\t\ttag &&\n\t\t\tfirst &&\n\t\t\ttypeof first === 'object' &&\n\t\t\ttypeof (first as { text?: unknown }).text === 'string'\n\t\t) {\n\t\t\tconst config = first as { text: string };\n\t\t\tconfig.text += tag;\n\t\t}\n\t\treturn query(first, ...rest);\n\t}) as typeof client.query;\n}\n","/**\n * `KyselyDatabase` — a declared Postgres database, typed by its schema.\n *\n * It declares a logical database, a schema, and the roles that reach it, and\n * hands back a Kysely client built from the one URL the adapter supplied. It\n * names no cloud: `--target=aws` fills that URL from RDS, local dev from the\n * Postgres container.\n *\n * Transactions and RLS context are the execution wrapper's job — it opens the\n * transaction and puts it in `ctx.db`. This construct does not resolve\n * connections per request.\n */\n\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\tDEFAULT_POSTGRES_VERSION,\n\ttype Declaration,\n\ttype PostgresVersion,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\nimport { Kysely, type KyselyConfig, PostgresDialect } from 'kysely';\nimport { Cache } from '../cache';\nimport type { Construct } from '../construct-interface';\nimport { openPool } from './pool';\n\n/** The schema a database uses when it does not say otherwise. */\nconst DEFAULT_SCHEMA = 'app';\n\n/**\n * Everything Kysely takes, plus what this construct declares.\n *\n * `dialect` is omitted because the construct owns it — it is built from the one\n * URL the adapter supplied, which is the whole point of the construct. The rest\n * of `KyselyConfig` (`plugins`, `log`) is the app's business and passes\n * straight through, so anything Kysely adds later arrives without being\n * tracked here.\n */\nexport interface KyselyDatabaseOptions extends Omit<KyselyConfig, 'dialect'> {\n\t/**\n\t * The schema, pinned on both roles' `search_path`.\n\t *\n\t * Defaults to `app` — the role the schema plays, rather than a restatement\n\t * of the database's own name, which reads correctly beside `auth` and\n\t * `pgboss` and keeps the application off `public`.\n\t */\n\tschema?: string;\n\t/**\n\t * Provision the owner/runtime role split. Defaults to on.\n\t *\n\t * Off falls back to the cluster's master credential in both URLs, giving up\n\t * the DDL/DML split and putting credentials that can drop a table into the\n\t * function's environment. A deliberate downgrade, not a default.\n\t */\n\troles?: boolean;\n\t/**\n\t * The Postgres major version to provision.\n\t *\n\t * Declared here so one statement reaches both targets. It was previously\n\t * set in two unrelated places — a container tag locally, nothing at all on\n\t * AWS (so Aurora chose) — which is how local came to run 18 while deployed\n\t * ran 17.7 with nothing recording the difference.\n\t *\n\t * Defaults to {@link DEFAULT_POSTGRES_VERSION}.\n\t */\n\tversion?: PostgresVersion;\n\t/**\n\t * End each query run inside a request with a comment naming what ran it —\n\t * `/*operation='POST /orders',request_id='…'*\\/` — so `pg_stat_activity`\n\t * and the server's logs can tie a query to its endpoint. Defaults to on.\n\t */\n\tqueryTags?: boolean;\n}\n\n/** What makes a construct derived rather than a database in its own right. */\ninterface DerivedFrom {\n\tkind: 'database-reader' | 'database-schema';\n\tof: string;\n\tschema?: string;\n}\n\n/**\n * @typeParam DB - the database's schema.\n * @typeParam TName - the canonical id. TypeScript has no partial\n * type-argument inference, so `new KyselyDatabase<OrdersDB>('orders')` leaves\n * this at its default and the service key widens to `string`. `db` still types\n * through `.database()`, which infers from the service.\n */\nexport class KyselyDatabase<DB = unknown, TName extends string = string>\n\timplements Construct<TName, Kysely<DB>>\n{\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, Kysely<DB>>;\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.\n\t */\n\tprivate readonly config: { url: string; ownerUrl: string };\n\tprivate readonly schemaName: string;\n\tprivate readonly roles: boolean;\n\tprivate readonly version: PostgresVersion;\n\tprivate readonly derivedFrom?: DerivedFrom;\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly options: KyselyDatabaseOptions = {},\n\t\tderivedFrom?: DerivedFrom,\n\t) {\n\t\t// Canonicalises, so `orders` and `Orders` 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.config = {\n\t\t\turl: provideKey(canonical, 'url'),\n\t\t\townerUrl: provideKey(canonical, 'ownerUrl'),\n\t\t};\n\t\tthis.schemaName = options.schema ?? DEFAULT_SCHEMA;\n\t\tthis.roles = options.roles ?? true;\n\t\tthis.version = options.version ?? DEFAULT_POSTGRES_VERSION;\n\t\tthis.derivedFrom = derivedFrom;\n\n\t\t// A field, not a getter: service discovery caches by object identity.\n\t\tthis.service = {\n\t\t\tserviceName: serviceKey(canonical) as Uncapitalize<TName>,\n\t\t\t// Forwards the whole options object — cherry-picking `envParser` strips\n\t\t\t// `context` and with it the request-scoped logger.\n\t\t\tregister: (registerOptions) => this.connect(registerOptions),\n\t\t};\n\t}\n\n\tdeclare(): Declaration[] {\n\t\tif (this.derivedFrom) {\n\t\t\tconst { kind, of, schema } = this.derivedFrom;\n\n\t\t\treturn [\n\t\t\t\tkind === 'database-schema'\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\tid: this.id,\n\t\t\t\t\t\t\tof,\n\t\t\t\t\t\t\tschema: schema ?? this.schemaName,\n\t\t\t\t\t\t\t// The runtime key alone — see the note below on the parent.\n\t\t\t\t\t\t\tprovides: [this.config.url],\n\t\t\t\t\t\t}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\tid: this.id,\n\t\t\t\t\t\t\tof,\n\t\t\t\t\t\t\t// A reader has no owner URL of its own — nothing migrates\n\t\t\t\t\t\t\t// through a read-only endpoint — so this is the one key.\n\t\t\t\t\t\t\tprovides: [this.config.url],\n\t\t\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'database',\n\t\t\t\tid: this.id,\n\t\t\t\tengine: 'postgres',\n\t\t\t\tschema: this.schemaName,\n\t\t\t\tversion: this.version,\n\t\t\t\t// One key, the runtime role's. `config` also holds the owner key and\n\t\t\t\t// it is deliberately absent here: a key in `provides` is a key an\n\t\t\t\t// edge can name, and nothing should be able to depend on DDL rights.\n\t\t\t\tprovides: [this.config.url],\n\t\t\t\t...(this.roles ? {} : { roles: false }),\n\t\t\t},\n\t\t];\n\t}\n\n\t/**\n\t * A read-only endpoint on this database.\n\t *\n\t * Read-only is enforced by the reader role's grants rather than by which\n\t * endpoint it resolves to, so falling back to the writer where no replica\n\t * exists is safe rather than a silently writable connection behind a name\n\t * that says reader. There is no `writer()`: the database *is* the writer, so\n\t * a replica can never be reached by accident.\n\t *\n\t * The return type is narrower than this class on purpose — see\n\t * {@link ReadOnlyDatabase}.\n\t */\n\treader(): ReadOnlyDatabase<DB, `${TName}Reader`> {\n\t\treturn new KyselyDatabase<DB, `${TName}Reader`>(\n\t\t\t`${this.id}Reader` as ConstructName<`${TName}Reader`>,\n\t\t\tthis.options,\n\t\t\t{ kind: 'database-reader', of: this.id },\n\t\t);\n\t}\n\n\t/**\n\t * A cache that lives in this database.\n\t *\n\t * The same strengthening `schema()` is over a second database: `new\n\t * Cache('Sessions')` says the app caches and leaves where to the deployment,\n\t * while this says it caches *here* — which is a fact about the application\n\t * and so belongs in its code.\n\t *\n\t * What it buys beyond being explicit: the table's schema and the role that\n\t * reaches it come from this database rather than from a second convention,\n\t * and the backend no longer has to guess which database \"the database\" meant\n\t * when an app declares two.\n\t *\n\t * A cache is not a `KyselyDatabase`, so this returns a `Cache` — the client\n\t * is a key/value store, not a query builder, and typing it as the parent\n\t * would be a convenience that lies.\n\t */\n\tcache<TCache extends string = `${TName}Cache`>(\n\t\tid: ConstructName<TCache> = `${this.id}Cache` as ConstructName<TCache>,\n\t\toptions: { table?: string } = {},\n\t): Cache<TCache> {\n\t\treturn new Cache<TCache>(id, {\n\t\t\tof: this.id,\n\t\t\t...(options.table ? { table: options.table } : {}),\n\t\t});\n\t}\n\n\t/**\n\t * A second schema in this database, with its own role(s) and its own URL —\n\t * so this database's role holds no grant on those tables at all.\n\t *\n\t * Typed separately because a tenant has its own tables: the point is that\n\t * `auth.selectFrom('sessions')` type-checks and\n\t * `orders.selectFrom('sessions')` does not.\n\t */\n\tschema<TenantDB, TTenant extends string>(\n\t\tid: ConstructName<TTenant>,\n\t\toptions: KyselyDatabaseOptions = {},\n\t): KyselyDatabase<TenantDB, TTenant> {\n\t\treturn new KyselyDatabase<TenantDB, TTenant>(id, options, {\n\t\t\tkind: 'database-schema',\n\t\t\tof: this.id,\n\t\t\tschema: options.schema ?? (id as string).toLowerCase(),\n\t\t});\n\t}\n\n\t/**\n\t * A connection as the *owner* role — the one that may create, alter and drop.\n\t *\n\t * A `Service` rather than part of the construct, and deliberately so: a\n\t * construct is what `.dependsOn()` accepts, and nothing should be able to\n\t * depend on this. A migrator asks for it by name; a handler cannot ask at\n\t * all, which is the security property the role split exists for.\n\t *\n\t * Falls back to the runtime URL where no owner URL was published — the\n\t * `roles: false` downgrade, where there is only one credential and it is the\n\t * cluster master's.\n\t */\n\tget owner(): Service<`${Uncapitalize<TName>}Owner`, Kysely<DB>> {\n\t\treturn {\n\t\t\tserviceName:\n\t\t\t\t`${serviceKey(this.id)}Owner` as `${Uncapitalize<TName>}Owner`,\n\t\t\tregister: (options) => this.connect(options, { owner: true }),\n\t\t};\n\t}\n\n\t/**\n\t * What this database's clients are built with besides a dialect — the\n\t * plugins and logging it was declared with.\n\t *\n\t * Public so that whatever opens a connection to it outside \\`connect()\\` —\n\t * a test's transaction — builds the same client. A test that dropped the\n\t * plugins would write \\`createdAt\\` where production writes \\`created_at\\`.\n\t */\n\tget clientConfig(): Omit<KyselyConfig, 'dialect'> {\n\t\t// Split what the manifest declared from what Kysely takes, so neither\n\t\t// leaks into the other: \\`schema\\`, \\`roles\\` and \\`version\\` describe\n\t\t// infrastructure and mean nothing to a client.\n\t\tconst {\n\t\t\tschema: _schema,\n\t\t\troles: _roles,\n\t\t\tversion: _version,\n\t\t\tqueryTags: _queryTags,\n\t\t\t...kysely\n\t\t} = this.options;\n\t\treturn kysely;\n\t}\n\n\tprivate async connect(\n\t\toptions: ServiceRegisterOptions,\n\t\tas: { owner?: boolean } = {},\n\t): Promise<Kysely<DB>> {\n\t\tconst { url, ownerUrl } = options.envParser\n\t\t\t.create((get) => ({\n\t\t\t\turl: get(this.config.url).string(),\n\t\t\t\townerUrl: get(this.config.ownerUrl).string().optional(),\n\t\t\t}))\n\t\t\t.parse();\n\n\t\treturn new Kysely<DB>({\n\t\t\t...this.clientConfig,\n\t\t\tdialect: new PostgresDialect({\n\t\t\t\tpool: openPool(as.owner ? (ownerUrl ?? url) : url, {\n\t\t\t\t\tqueryTags: this.options.queryTags,\n\t\t\t\t}),\n\t\t\t}),\n\t\t});\n\t}\n}\n\n/**\n * A database you may read through, and derive nothing from.\n *\n * A reader is terminal in the graph, and this is that fact in the type system.\n * `DERIVES_FROM` gives `cache` and `database-schema` no `database-reader`\n * parent, and there is no reader of a reader — so `orders.reader().cache(…)`\n * has always been illegal, but it type-checked and failed later at\n * `assertDerivations`. That is a long way round to learn that a read-only\n * endpoint cannot own a table something writes to.\n *\n * Omitting the three deriving methods rather than making them throw keeps the\n * failure where it costs least: the editor, on the line that wrote it.\n *\n * The result is deliberately not assignable back to `KyselyDatabase` — a\n * reader is not one, and anything that genuinely needs the writer should say\n * so.\n */\nexport type ReadOnlyDatabase<DB, TName extends string> = Omit<\n\tKyselyDatabase<DB, TName>,\n\t'reader' | 'cache' | 'schema'\n>;\nexport { closeDatabasePools } from './pool';\n"],"mappings":"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"}
@@ -0,0 +1,173 @@
1
+ import { n as Construct } from "./construct-interface-DluK3_da.mjs";
2
+ import { t as Cache } from "./cache-CXh6GIgb.mjs";
3
+ import { ConstructName, Declaration, PostgresVersion } from "@geekmidas/manifest";
4
+ import { Kysely, KyselyConfig } from "kysely";
5
+ import { Service } from "@geekmidas/services";
6
+ import pg from "pg";
7
+ //#region src/database/pool.d.ts
8
+ /**
9
+ * End every pool opened, waiting for checked-out connections to come back.
10
+ * For a server's shutdown, after it has stopped taking requests.
11
+ */
12
+ declare function closeDatabasePools(): Promise<void>;
13
+ //#endregion
14
+ //#region src/database/kysely.d.ts
15
+ /**
16
+ * Everything Kysely takes, plus what this construct declares.
17
+ *
18
+ * `dialect` is omitted because the construct owns it — it is built from the one
19
+ * URL the adapter supplied, which is the whole point of the construct. The rest
20
+ * of `KyselyConfig` (`plugins`, `log`) is the app's business and passes
21
+ * straight through, so anything Kysely adds later arrives without being
22
+ * tracked here.
23
+ */
24
+ interface KyselyDatabaseOptions extends Omit<KyselyConfig, 'dialect'> {
25
+ /**
26
+ * The schema, pinned on both roles' `search_path`.
27
+ *
28
+ * Defaults to `app` — the role the schema plays, rather than a restatement
29
+ * of the database's own name, which reads correctly beside `auth` and
30
+ * `pgboss` and keeps the application off `public`.
31
+ */
32
+ schema?: string;
33
+ /**
34
+ * Provision the owner/runtime role split. Defaults to on.
35
+ *
36
+ * Off falls back to the cluster's master credential in both URLs, giving up
37
+ * the DDL/DML split and putting credentials that can drop a table into the
38
+ * function's environment. A deliberate downgrade, not a default.
39
+ */
40
+ roles?: boolean;
41
+ /**
42
+ * The Postgres major version to provision.
43
+ *
44
+ * Declared here so one statement reaches both targets. It was previously
45
+ * set in two unrelated places — a container tag locally, nothing at all on
46
+ * AWS (so Aurora chose) — which is how local came to run 18 while deployed
47
+ * ran 17.7 with nothing recording the difference.
48
+ *
49
+ * Defaults to {@link DEFAULT_POSTGRES_VERSION}.
50
+ */
51
+ version?: PostgresVersion;
52
+ /**
53
+ * End each query run inside a request with a comment naming what ran it —
54
+ * `/*operation='POST /orders',request_id='…'*\/` — so `pg_stat_activity`
55
+ * and the server's logs can tie a query to its endpoint. Defaults to on.
56
+ */
57
+ queryTags?: boolean;
58
+ }
59
+ /** What makes a construct derived rather than a database in its own right. */
60
+ interface DerivedFrom {
61
+ kind: 'database-reader' | 'database-schema';
62
+ of: string;
63
+ schema?: string;
64
+ }
65
+ /**
66
+ * @typeParam DB - the database's schema.
67
+ * @typeParam TName - the canonical id. TypeScript has no partial
68
+ * type-argument inference, so `new KyselyDatabase<OrdersDB>('orders')` leaves
69
+ * this at its default and the service key widens to `string`. `db` still types
70
+ * through `.database()`, which infers from the service.
71
+ */
72
+ declare class KyselyDatabase<DB = unknown, TName extends string = string> implements Construct<TName, Kysely<DB>> {
73
+ private readonly options;
74
+ readonly id: TName;
75
+ readonly service: Service<Uncapitalize<TName>, Kysely<DB>>;
76
+ /**
77
+ * Declared once and read by both `declare()` and `connect()`, so the key the
78
+ * build publishes and the key the client reads cannot drift.
79
+ */
80
+ private readonly config;
81
+ private readonly schemaName;
82
+ private readonly roles;
83
+ private readonly version;
84
+ private readonly derivedFrom?;
85
+ constructor(id: ConstructName<TName>, options?: KyselyDatabaseOptions, derivedFrom?: DerivedFrom);
86
+ declare(): Declaration[];
87
+ /**
88
+ * A read-only endpoint on this database.
89
+ *
90
+ * Read-only is enforced by the reader role's grants rather than by which
91
+ * endpoint it resolves to, so falling back to the writer where no replica
92
+ * exists is safe rather than a silently writable connection behind a name
93
+ * that says reader. There is no `writer()`: the database *is* the writer, so
94
+ * a replica can never be reached by accident.
95
+ *
96
+ * The return type is narrower than this class on purpose — see
97
+ * {@link ReadOnlyDatabase}.
98
+ */
99
+ reader(): ReadOnlyDatabase<DB, `${TName}Reader`>;
100
+ /**
101
+ * A cache that lives in this database.
102
+ *
103
+ * The same strengthening `schema()` is over a second database: `new
104
+ * Cache('Sessions')` says the app caches and leaves where to the deployment,
105
+ * while this says it caches *here* — which is a fact about the application
106
+ * and so belongs in its code.
107
+ *
108
+ * What it buys beyond being explicit: the table's schema and the role that
109
+ * reaches it come from this database rather than from a second convention,
110
+ * and the backend no longer has to guess which database "the database" meant
111
+ * when an app declares two.
112
+ *
113
+ * A cache is not a `KyselyDatabase`, so this returns a `Cache` — the client
114
+ * is a key/value store, not a query builder, and typing it as the parent
115
+ * would be a convenience that lies.
116
+ */
117
+ cache<TCache extends string = `${TName}Cache`>(id?: ConstructName<TCache>, options?: {
118
+ table?: string;
119
+ }): Cache<TCache>;
120
+ /**
121
+ * A second schema in this database, with its own role(s) and its own URL —
122
+ * so this database's role holds no grant on those tables at all.
123
+ *
124
+ * Typed separately because a tenant has its own tables: the point is that
125
+ * `auth.selectFrom('sessions')` type-checks and
126
+ * `orders.selectFrom('sessions')` does not.
127
+ */
128
+ schema<TenantDB, TTenant extends string>(id: ConstructName<TTenant>, options?: KyselyDatabaseOptions): KyselyDatabase<TenantDB, TTenant>;
129
+ /**
130
+ * A connection as the *owner* role — the one that may create, alter and drop.
131
+ *
132
+ * A `Service` rather than part of the construct, and deliberately so: a
133
+ * construct is what `.dependsOn()` accepts, and nothing should be able to
134
+ * depend on this. A migrator asks for it by name; a handler cannot ask at
135
+ * all, which is the security property the role split exists for.
136
+ *
137
+ * Falls back to the runtime URL where no owner URL was published — the
138
+ * `roles: false` downgrade, where there is only one credential and it is the
139
+ * cluster master's.
140
+ */
141
+ get owner(): Service<`${Uncapitalize<TName>}Owner`, Kysely<DB>>;
142
+ /**
143
+ * What this database's clients are built with besides a dialect — the
144
+ * plugins and logging it was declared with.
145
+ *
146
+ * Public so that whatever opens a connection to it outside \`connect()\` —
147
+ * a test's transaction — builds the same client. A test that dropped the
148
+ * plugins would write \`createdAt\` where production writes \`created_at\`.
149
+ */
150
+ get clientConfig(): Omit<KyselyConfig, 'dialect'>;
151
+ private connect;
152
+ }
153
+ /**
154
+ * A database you may read through, and derive nothing from.
155
+ *
156
+ * A reader is terminal in the graph, and this is that fact in the type system.
157
+ * `DERIVES_FROM` gives `cache` and `database-schema` no `database-reader`
158
+ * parent, and there is no reader of a reader — so `orders.reader().cache(…)`
159
+ * has always been illegal, but it type-checked and failed later at
160
+ * `assertDerivations`. That is a long way round to learn that a read-only
161
+ * endpoint cannot own a table something writes to.
162
+ *
163
+ * Omitting the three deriving methods rather than making them throw keeps the
164
+ * failure where it costs least: the editor, on the line that wrote it.
165
+ *
166
+ * The result is deliberately not assignable back to `KyselyDatabase` — a
167
+ * reader is not one, and anything that genuinely needs the writer should say
168
+ * so.
169
+ */
170
+ type ReadOnlyDatabase<DB, TName extends string> = Omit<KyselyDatabase<DB, TName>, 'reader' | 'cache' | 'schema'>;
171
+ //#endregion
172
+ export { closeDatabasePools as i, KyselyDatabaseOptions as n, ReadOnlyDatabase as r, KyselyDatabase as t };
173
+ //# sourceMappingURL=kysely-CjuvdXEV.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kysely-CjuvdXEV.d.mts","names":[],"sources":["../src/database/pool.ts","../src/database/kysely.ts"],"mappings":";;;;;;;;;;;iBAiFsB,sBAAsB;;;;;;;;;;;;UCzC3B,8BAA8B,KAAK;;;;;;;;EAQnD;;;;;;;;EAQA;;;;;;;;;;;EAWA,UAAU;;;;;;EAMV;;;UAIS;EACT;EACA;EACA;;;;;;;;;cAUY,eAAe,cAAc,0CAC9B,UAAU,OAAO,OAAO;mBAiBjB;WAfT,IAAI;WACJ,SAAS,QAAQ,aAAa,QAAQ,OAAO;;;;;mBAMrC;mBACA;mBACA;mBACA;mBACA;EAEjB,YACC,IAAI,cAAc,QACD,UAAS,uBAC1B,cAAc;EAyBf,WAAW;;;;;;;;;;;;;EAqDX,UAAU,iBAAiB,OAAO;;;;;;;;;;;;;;;;;;EAyBlC,MAAM,2BAA2B,cAChC,KAAI,cAAc,SAClB;IAAW;MACT,MAAM;;;;;;;;;EAeT,OAAO,UAAU,wBAChB,IAAI,cAAc,UAClB,UAAS,wBACP,eAAe,UAAU;;;;;;;;;;;;;MAoBxB,SAAS,WAAW,aAAa,eAAe,OAAO;;;;;;;;;MAgBvD,gBAAgB,KAAK;UAcX;;;;;;;;;;;;;;;;;;;KAuCH,iBAAiB,IAAI,wBAAwB,KACxD,eAAe,IAAI"}
@@ -1,44 +1,4 @@
1
1
  import { getCookie } from "hono/cookie";
2
-
3
- //#region src/publisher.ts
4
- async function publishEvents(logger, serviceDiscovery, ev = [], response, publisherService) {
5
- try {
6
- if (!ev?.length) {
7
- logger.debug("No events to publish");
8
- return;
9
- }
10
- if (!publisherService) {
11
- logger.warn("No publisher service available");
12
- return;
13
- }
14
- const services = await serviceDiscovery.register([publisherService]);
15
- const publisher = services[publisherService.serviceName];
16
- const events = [];
17
- for (const { when, payload, type,...e } of ev) {
18
- logger.debug({ event: type }, "Processing event");
19
- const resolvedPayload = await payload(response);
20
- const event = {
21
- ...e,
22
- type,
23
- payload: resolvedPayload
24
- };
25
- if (!when || when(response)) events.push(event);
26
- }
27
- if (events.length) {
28
- logger.debug({ eventCount: ev.length }, "Publishing events");
29
- await publisher.publish(events).catch((err) => {
30
- logger.error(err, "Failed to publish events");
31
- });
32
- }
33
- } catch (error) {
34
- logger.error(error, "Something went wrong publishing events");
35
- }
36
- }
37
- async function publishConstructEvents(construct, response, serviceDiscovery, logger = construct.logger) {
38
- return publishEvents(logger, serviceDiscovery, construct.events, response, construct.publisherService);
39
- }
40
-
41
- //#endregion
42
2
  //#region src/endpoints/lazyAccessors.ts
43
3
  /**
44
4
  * Create a lazy header accessor for Hono.
@@ -47,11 +7,11 @@ async function publishConstructEvents(construct, response, serviceDiscovery, log
47
7
  */
48
8
  function createHonoHeaders(c) {
49
9
  let allHeaders = null;
50
- return (key) => {
10
+ return ((key) => {
51
11
  if (key !== void 0) return c.req.header(key);
52
12
  if (!allHeaders) allHeaders = c.req.header();
53
13
  return allHeaders;
54
- };
14
+ });
55
15
  }
56
16
  /**
57
17
  * Create a lazy cookie accessor for Hono.
@@ -60,7 +20,7 @@ function createHonoHeaders(c) {
60
20
  */
61
21
  function createHonoCookies(c) {
62
22
  let allCookies = null;
63
- return (name) => {
23
+ return ((name) => {
64
24
  if (name !== void 0) return getCookie(c, name);
65
25
  if (!allCookies) {
66
26
  allCookies = {};
@@ -76,7 +36,7 @@ function createHonoCookies(c) {
76
36
  }
77
37
  }
78
38
  return allCookies;
79
- };
39
+ });
80
40
  }
81
41
  /**
82
42
  * Create a lazy header accessor for API Gateway events.
@@ -93,17 +53,17 @@ function createApiGatewayHeaders(headers) {
93
53
  }
94
54
  return normalizedHeaders;
95
55
  };
96
- return (key) => {
56
+ return ((key) => {
97
57
  if (key !== void 0) {
98
58
  if (headers) {
99
59
  const direct = headers[key] ?? headers[key.toLowerCase()];
100
60
  if (direct !== void 0) return direct;
101
61
  return normalize()[key.toLowerCase()];
102
62
  }
103
- return void 0;
63
+ return;
104
64
  }
105
65
  return normalize();
106
- };
66
+ });
107
67
  }
108
68
  /**
109
69
  * Create a lazy cookie accessor for API Gateway events.
@@ -134,10 +94,10 @@ function createApiGatewayCookies(cookies, cookieHeader) {
134
94
  }
135
95
  return parsed;
136
96
  };
137
- return (name) => {
97
+ return ((name) => {
138
98
  if (name !== void 0) return parse()[name];
139
99
  return parse();
140
- };
100
+ });
141
101
  }
142
102
  /**
143
103
  * Create a lazy header accessor for plain object headers (test adaptor, etc).
@@ -145,7 +105,7 @@ function createApiGatewayCookies(cookies, cookieHeader) {
145
105
  */
146
106
  function createObjectHeaders(headers) {
147
107
  let normalized = null;
148
- return (key) => {
108
+ return ((key) => {
149
109
  if (key !== void 0) {
150
110
  if (headers) {
151
111
  const direct = headers[key] ?? headers[key.toLowerCase()];
@@ -162,7 +122,7 @@ function createObjectHeaders(headers) {
162
122
  for (const [k, v] of Object.entries(headers)) normalized[k.toLowerCase()] = v;
163
123
  }
164
124
  return normalized ?? {};
165
- };
125
+ });
166
126
  }
167
127
  /**
168
128
  * Create a lazy cookie accessor from a cookie header string.
@@ -185,30 +145,30 @@ function createCookieHeaderAccessor(cookieHeader) {
185
145
  }
186
146
  return parsed;
187
147
  };
188
- return (name) => {
148
+ return ((name) => {
189
149
  if (name !== void 0) return parse()[name];
190
150
  return parse();
191
- };
151
+ });
192
152
  }
193
153
  /**
194
154
  * Create a no-op header accessor (for minimal endpoints that don't use headers).
195
155
  */
196
156
  function createNoopHeaders() {
197
- return (key) => {
157
+ return ((key) => {
198
158
  if (key !== void 0) return void 0;
199
159
  return {};
200
- };
160
+ });
201
161
  }
202
162
  /**
203
163
  * Create a no-op cookie accessor (for minimal endpoints that don't use cookies).
204
164
  */
205
165
  function createNoopCookies() {
206
- return (name) => {
166
+ return ((name) => {
207
167
  if (name !== void 0) return void 0;
208
168
  return {};
209
- };
169
+ });
210
170
  }
211
-
212
171
  //#endregion
213
- export { createApiGatewayCookies, createApiGatewayHeaders, createCookieHeaderAccessor, createHonoCookies, createHonoHeaders, createNoopCookies, createNoopHeaders, createObjectHeaders, publishConstructEvents, publishEvents };
214
- //# sourceMappingURL=lazyAccessors-BoJN3SMd.mjs.map
172
+ export { createHonoHeaders as a, createObjectHeaders as c, createHonoCookies as i, createApiGatewayHeaders as n, createNoopCookies as o, createCookieHeaderAccessor as r, createNoopHeaders as s, createApiGatewayCookies as t };
173
+
174
+ //# sourceMappingURL=lazyAccessors-CFanua0O.mjs.map