@geekmidas/constructs 10.0.0-alpha.154 → 10.0.0-alpha.156

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 (220) hide show
  1. package/README.md +23 -0
  2. package/dist/{Construct-DorKS0Ua.cjs → Construct-B8yWxGlR.cjs} +2 -2
  3. package/dist/{Construct-DorKS0Ua.cjs.map → Construct-B8yWxGlR.cjs.map} +1 -1
  4. package/dist/{Construct-DySlwh8o.d.mts → Construct-BMk_CRSD.d.mts} +2 -2
  5. package/dist/{Construct-DySlwh8o.d.mts.map → Construct-BMk_CRSD.d.mts.map} +1 -1
  6. package/dist/{Construct-CGuc_Ijk.mjs → Construct-CRV3RN2U.mjs} +11 -2
  7. package/dist/{Construct-CGuc_Ijk.mjs.map → Construct-CRV3RN2U.mjs.map} +1 -1
  8. package/dist/{Cron-D8mB_cPX.d.mts → Cron-D6Y7BBt3.d.mts} +5 -5
  9. package/dist/{Cron-D8mB_cPX.d.mts.map → Cron-D6Y7BBt3.d.mts.map} +1 -1
  10. package/dist/{CronBuilder-Cmajva3g.d.mts → CronBuilder-4BZhkChG.d.mts} +5 -5
  11. package/dist/{CronBuilder-Cmajva3g.d.mts.map → CronBuilder-4BZhkChG.d.mts.map} +1 -1
  12. package/dist/{CronBuilder-B_NSP-Y5.cjs → CronBuilder-B4DYaEjl.cjs} +4 -4
  13. package/dist/{CronBuilder-B_NSP-Y5.cjs.map → CronBuilder-B4DYaEjl.cjs.map} +1 -1
  14. package/dist/{CronBuilder-BJ5LoadF.mjs → CronBuilder-CukJuL3b.mjs} +3 -3
  15. package/dist/{CronBuilder-BJ5LoadF.mjs.map → CronBuilder-CukJuL3b.mjs.map} +1 -1
  16. package/dist/{Endpoint-BbHh3Qoc.d.mts → Endpoint-BUoDD96P.d.mts} +5 -5
  17. package/dist/{Endpoint-BbHh3Qoc.d.mts.map → Endpoint-BUoDD96P.d.mts.map} +1 -1
  18. package/dist/{Endpoint-sUOU7uLx.mjs → Endpoint-BuKHHVZc.mjs} +3 -3
  19. package/dist/{Endpoint-sUOU7uLx.mjs.map → Endpoint-BuKHHVZc.mjs.map} +1 -1
  20. package/dist/{Endpoint-52z1P0Ue.cjs → Endpoint-D2ckHqIx.cjs} +3 -3
  21. package/dist/{Endpoint-52z1P0Ue.cjs.map → Endpoint-D2ckHqIx.cjs.map} +1 -1
  22. package/dist/{EndpointFactory-qcLzi4f-.d.mts → EndpointFactory-BbVOeryo.d.mts} +5 -5
  23. package/dist/{EndpointFactory-qcLzi4f-.d.mts.map → EndpointFactory-BbVOeryo.d.mts.map} +1 -1
  24. package/dist/{EndpointFactory-Bzi9Sl7r.mjs → EndpointFactory-BsJUlUyL.mjs} +4 -4
  25. package/dist/{EndpointFactory-Bzi9Sl7r.mjs.map → EndpointFactory-BsJUlUyL.mjs.map} +1 -1
  26. package/dist/{EndpointFactory-Cf_Cs1ym.cjs → EndpointFactory-c4tHjQKM.cjs} +5 -5
  27. package/dist/{EndpointFactory-Cf_Cs1ym.cjs.map → EndpointFactory-c4tHjQKM.cjs.map} +1 -1
  28. package/dist/{Function-DfMzTGS4.d.mts → Function-BKReud5p.d.mts} +3 -3
  29. package/dist/{Function-DfMzTGS4.d.mts.map → Function-BKReud5p.d.mts.map} +1 -1
  30. package/dist/{HonoEndpointAdaptor-DR3j7S35.mjs → HonoEndpointAdaptor-BC7CZ7Cr.mjs} +7 -6
  31. package/dist/HonoEndpointAdaptor-BC7CZ7Cr.mjs.map +1 -0
  32. package/dist/{HonoEndpointAdaptor-BXBdb2Bt.cjs → HonoEndpointAdaptor-BGEW1Tu8.cjs} +9 -8
  33. package/dist/HonoEndpointAdaptor-BGEW1Tu8.cjs.map +1 -0
  34. package/dist/{ObjectSubscriberBuilder-Cv8C7yS1.d.mts → ObjectSubscriberBuilder-DfzXQEKW.d.mts} +4 -4
  35. package/dist/{ObjectSubscriberBuilder-Cv8C7yS1.d.mts.map → ObjectSubscriberBuilder-DfzXQEKW.d.mts.map} +1 -1
  36. package/dist/ObjectSubscriberBuilder-LWkey_oq.d.cts.map +1 -1
  37. package/dist/{ProcessorBuilder-CwfP-M33.d.mts → ProcessorBuilder-D4oYvZeG.d.mts} +2 -2
  38. package/dist/{ProcessorBuilder-CwfP-M33.d.mts.map → ProcessorBuilder-D4oYvZeG.d.mts.map} +1 -1
  39. package/dist/{Queue-u8w8_HpE.mjs → Queue-0FpvxdOa.mjs} +2 -2
  40. package/dist/{Queue-u8w8_HpE.mjs.map → Queue-0FpvxdOa.mjs.map} +1 -1
  41. package/dist/{Queue-BnK3UH8r.d.mts → Queue-B8HGg439.d.mts} +3 -3
  42. package/dist/{Queue-BnK3UH8r.d.mts.map → Queue-B8HGg439.d.mts.map} +1 -1
  43. package/dist/{Queue-D4Iaidrs.cjs → Queue-DZpV13LN.cjs} +2 -2
  44. package/dist/{Queue-D4Iaidrs.cjs.map → Queue-DZpV13LN.cjs.map} +1 -1
  45. package/dist/{QueueBuilder-2wP5lEC8.mjs → QueueBuilder-Bmyay_Di.mjs} +2 -2
  46. package/dist/{QueueBuilder-2wP5lEC8.mjs.map → QueueBuilder-Bmyay_Di.mjs.map} +1 -1
  47. package/dist/{QueueBuilder-DmwFtLzQ.d.mts → QueueBuilder-CVS_qPuo.d.mts} +2 -2
  48. package/dist/{QueueBuilder-DmwFtLzQ.d.mts.map → QueueBuilder-CVS_qPuo.d.mts.map} +1 -1
  49. package/dist/{QueueBuilder-BxsZ9o5z.cjs → QueueBuilder-FXkSDah1.cjs} +2 -2
  50. package/dist/{QueueBuilder-BxsZ9o5z.cjs.map → QueueBuilder-FXkSDah1.cjs.map} +1 -1
  51. package/dist/{Subscriber-CW_Dl-YR.d.mts → Subscriber-CtQXhcL7.d.mts} +3 -3
  52. package/dist/{Subscriber-CW_Dl-YR.d.mts.map → Subscriber-CtQXhcL7.d.mts.map} +1 -1
  53. package/dist/{SubscriberBuilder-CWzKwX1p.cjs → SubscriberBuilder-Bfn-iDSk.cjs} +4 -3
  54. package/dist/SubscriberBuilder-Bfn-iDSk.cjs.map +1 -0
  55. package/dist/{SubscriberBuilder-BL_GTcwh.mjs → SubscriberBuilder-CxG1OOug.mjs} +4 -3
  56. package/dist/SubscriberBuilder-CxG1OOug.mjs.map +1 -0
  57. package/dist/{Topic-DN2gYJ-p.mjs → Topic-DoEdDgh7.mjs} +2 -2
  58. package/dist/{Topic-DN2gYJ-p.mjs.map → Topic-DoEdDgh7.mjs.map} +1 -1
  59. package/dist/{Topic-Dp9Q7Lj2.cjs → Topic-t5GhqaeT.cjs} +2 -2
  60. package/dist/{Topic-Dp9Q7Lj2.cjs.map → Topic-t5GhqaeT.cjs.map} +1 -1
  61. package/dist/adaptors/aws.cjs +28 -16
  62. package/dist/adaptors/aws.cjs.map +1 -1
  63. package/dist/adaptors/aws.d.cts +141 -0
  64. package/dist/adaptors/aws.d.cts.map +1 -1
  65. package/dist/adaptors/aws.d.mts +147 -6
  66. package/dist/adaptors/aws.d.mts.map +1 -1
  67. package/dist/adaptors/aws.mjs +21 -15
  68. package/dist/adaptors/aws.mjs.map +1 -1
  69. package/dist/adaptors/hono.cjs +1 -1
  70. package/dist/adaptors/hono.d.mts +2 -2
  71. package/dist/adaptors/hono.mjs +1 -1
  72. package/dist/adaptors/testing.cjs +230 -14
  73. package/dist/adaptors/testing.cjs.map +1 -1
  74. package/dist/adaptors/testing.d.cts +81 -2
  75. package/dist/adaptors/testing.d.cts.map +1 -1
  76. package/dist/adaptors/testing.d.mts +89 -10
  77. package/dist/adaptors/testing.d.mts.map +1 -1
  78. package/dist/adaptors/testing.mjs +221 -12
  79. package/dist/adaptors/testing.mjs.map +1 -1
  80. package/dist/apigateway-Dyjy_JwI.mjs +329 -0
  81. package/dist/apigateway-Dyjy_JwI.mjs.map +1 -0
  82. package/dist/apigateway-zHDoMwlI.cjs +370 -0
  83. package/dist/apigateway-zHDoMwlI.cjs.map +1 -0
  84. package/dist/auth-BqWz2JxC.d.cts.map +1 -1
  85. package/dist/auth-DnB9H9KL.d.mts.map +1 -1
  86. package/dist/auth.cjs +7 -21
  87. package/dist/auth.cjs.map +1 -1
  88. package/dist/auth.mjs +6 -20
  89. package/dist/auth.mjs.map +1 -1
  90. package/dist/{cache-e3tfMQ9g.d.mts → cache-CCHcO9Oo.d.mts} +2 -2
  91. package/dist/cache-CCHcO9Oo.d.mts.map +1 -0
  92. package/dist/cache-CQjMNPrC.d.cts.map +1 -1
  93. package/dist/cache.cjs +3 -19
  94. package/dist/cache.cjs.map +1 -1
  95. package/dist/cache.d.mts +1 -1
  96. package/dist/cache.mjs +2 -18
  97. package/dist/cache.mjs.map +1 -1
  98. package/dist/crons/index.cjs +4 -3
  99. package/dist/crons/index.cjs.map +1 -1
  100. package/dist/crons/index.d.cts.map +1 -1
  101. package/dist/crons/index.d.mts +2 -2
  102. package/dist/crons/index.d.mts.map +1 -1
  103. package/dist/crons/index.mjs +4 -3
  104. package/dist/crons/index.mjs.map +1 -1
  105. package/dist/database/kysely.cjs +1 -1
  106. package/dist/database/kysely.d.mts +1 -1
  107. package/dist/email.cjs +4 -16
  108. package/dist/email.cjs.map +1 -1
  109. package/dist/email.d.cts.map +1 -1
  110. package/dist/email.d.mts.map +1 -1
  111. package/dist/email.mjs +2 -14
  112. package/dist/email.mjs.map +1 -1
  113. package/dist/endpoints/index.cjs +4 -4
  114. package/dist/endpoints/index.d.cts +1 -1
  115. package/dist/endpoints/index.d.cts.map +1 -1
  116. package/dist/endpoints/index.d.mts +4 -4
  117. package/dist/endpoints/index.d.mts.map +1 -1
  118. package/dist/endpoints/index.mjs +4 -4
  119. package/dist/file-server.cjs +1 -1
  120. package/dist/file-server.d.mts +1 -1
  121. package/dist/file-server.mjs +1 -1
  122. package/dist/functions/index.cjs +1 -1
  123. package/dist/functions/index.d.mts +2 -2
  124. package/dist/functions/index.mjs +1 -1
  125. package/dist/{functions-BvIDQKAA.mjs → functions-BF039DT8.mjs} +2 -2
  126. package/dist/{functions-BvIDQKAA.mjs.map → functions-BF039DT8.mjs.map} +1 -1
  127. package/dist/{functions-DLF6-IK8.cjs → functions-BqAq_0xQ.cjs} +3 -3
  128. package/dist/{functions-DLF6-IK8.cjs.map → functions-BqAq_0xQ.cjs.map} +1 -1
  129. package/dist/{inbox-CjxpLVkH.d.mts → inbox-YOdxlyfj.d.mts} +2 -2
  130. package/dist/{inbox-CjxpLVkH.d.mts.map → inbox-YOdxlyfj.d.mts.map} +1 -1
  131. package/dist/inbox.cjs +1 -1
  132. package/dist/inbox.d.mts +1 -1
  133. package/dist/inbox.mjs +1 -1
  134. package/dist/{index-DCkDQkwj.d.mts → index-BoQ3-M-K.d.mts} +4 -4
  135. package/dist/{index-DCkDQkwj.d.mts.map → index-BoQ3-M-K.d.mts.map} +1 -1
  136. package/dist/index.cjs +1 -1
  137. package/dist/index.d.mts +1 -1
  138. package/dist/index.mjs +1 -1
  139. package/dist/{kysely-CukArHJ0.cjs → kysely-CeoQdAkg.cjs} +2 -2
  140. package/dist/{kysely-CukArHJ0.cjs.map → kysely-CeoQdAkg.cjs.map} +1 -1
  141. package/dist/{kysely-DE4kADWD.d.mts → kysely-De5rAC-E.d.mts} +2 -2
  142. package/dist/{kysely-DE4kADWD.d.mts.map → kysely-De5rAC-E.d.mts.map} +1 -1
  143. package/dist/optionalPeers-D7Wt6dnF.mjs +140 -0
  144. package/dist/optionalPeers-D7Wt6dnF.mjs.map +1 -0
  145. package/dist/optionalPeers-DuNQXXe1.cjs +223 -0
  146. package/dist/optionalPeers-DuNQXXe1.cjs.map +1 -0
  147. package/dist/origins-C7T9covD.cjs +24 -0
  148. package/dist/origins-C7T9covD.cjs.map +1 -0
  149. package/dist/origins-CX6Ot7ax.mjs +19 -0
  150. package/dist/origins-CX6Ot7ax.mjs.map +1 -0
  151. package/dist/{pattern-QFaUIr77.cjs → pattern-HnNOPhE2.cjs} +2 -2
  152. package/dist/{pattern-QFaUIr77.cjs.map → pattern-HnNOPhE2.cjs.map} +1 -1
  153. package/dist/{pattern-C1CEcglD.mjs → pattern-YSqfAhXm.mjs} +2 -2
  154. package/dist/{pattern-C1CEcglD.mjs.map → pattern-YSqfAhXm.mjs.map} +1 -1
  155. package/dist/privateAddress-Bg5fUsbp.mjs +21 -0
  156. package/dist/privateAddress-Bg5fUsbp.mjs.map +1 -0
  157. package/dist/privateAddress-CqGyuFHn.cjs +26 -0
  158. package/dist/privateAddress-CqGyuFHn.cjs.map +1 -0
  159. package/dist/processors/index.cjs +1 -1
  160. package/dist/processors/index.d.mts +1 -1
  161. package/dist/processors/index.mjs +1 -1
  162. package/dist/queue/index.cjs +2 -2
  163. package/dist/queue/index.d.mts +2 -2
  164. package/dist/queue/index.mjs +2 -2
  165. package/dist/{readRequestBody-BTIl3k-D.mjs → readRequestBody-BmKnPl0a.mjs} +26 -4
  166. package/dist/readRequestBody-BmKnPl0a.mjs.map +1 -0
  167. package/dist/{readRequestBody-Dej_L3c4.cjs → readRequestBody-CN9GVdeE.cjs} +26 -4
  168. package/dist/readRequestBody-CN9GVdeE.cjs.map +1 -0
  169. package/dist/{requestLogger-BZcXwdBs.cjs → requestLogger-CnoYd-Ah.cjs} +4 -63
  170. package/dist/requestLogger-CnoYd-Ah.cjs.map +1 -0
  171. package/dist/{requestLogger-pA4gi3E1.mjs → requestLogger-D2JS7pPM.mjs} +3 -56
  172. package/dist/requestLogger-D2JS7pPM.mjs.map +1 -0
  173. package/dist/rest-api.cjs +1 -1
  174. package/dist/rest-api.d.mts +2 -2
  175. package/dist/rest-api.mjs +1 -1
  176. package/dist/{rolldown-runtime-y5ARvAq5.cjs → rolldown-runtime-Ctb5zv51.cjs} +15 -0
  177. package/dist/{runSubscriber-DyHWp_Lf.mjs → runSubscriber-HEqXkin1.mjs} +3 -2
  178. package/dist/runSubscriber-HEqXkin1.mjs.map +1 -0
  179. package/dist/{runSubscriber-CC_2C9F2.cjs → runSubscriber-sVJfLA0-.cjs} +3 -2
  180. package/dist/runSubscriber-sVJfLA0-.cjs.map +1 -0
  181. package/dist/subscribers/index.cjs +6 -6
  182. package/dist/subscribers/index.cjs.map +1 -1
  183. package/dist/subscribers/index.d.cts +1 -1
  184. package/dist/subscribers/index.d.mts +3 -3
  185. package/dist/subscribers/index.mjs +3 -3
  186. package/dist/subscribers/index.mjs.map +1 -1
  187. package/dist/topic/index.cjs +1 -1
  188. package/dist/topic/index.d.mts +1 -1
  189. package/dist/topic/index.mjs +1 -1
  190. package/dist/websocket-api-BvKS9x-l.mjs +1711 -0
  191. package/dist/websocket-api-BvKS9x-l.mjs.map +1 -0
  192. package/dist/websocket-api-C3dWKNxO.d.cts +1181 -0
  193. package/dist/websocket-api-C3dWKNxO.d.cts.map +1 -0
  194. package/dist/websocket-api-CAQA_QOE.cjs +1890 -0
  195. package/dist/websocket-api-CAQA_QOE.cjs.map +1 -0
  196. package/dist/websocket-api-CDAxOTQZ.d.mts +1181 -0
  197. package/dist/websocket-api-CDAxOTQZ.d.mts.map +1 -0
  198. package/dist/websocket-api.cjs +31 -1121
  199. package/dist/websocket-api.d.cts +2 -699
  200. package/dist/websocket-api.d.mts +2 -699
  201. package/dist/websocket-api.mjs +2 -1102
  202. package/dist/worker.cjs +4 -4
  203. package/dist/worker.d.mts +9 -9
  204. package/dist/worker.mjs +4 -4
  205. package/package.json +41 -31
  206. package/dist/HonoEndpointAdaptor-BXBdb2Bt.cjs.map +0 -1
  207. package/dist/HonoEndpointAdaptor-DR3j7S35.mjs.map +0 -1
  208. package/dist/SubscriberBuilder-BL_GTcwh.mjs.map +0 -1
  209. package/dist/SubscriberBuilder-CWzKwX1p.cjs.map +0 -1
  210. package/dist/cache-e3tfMQ9g.d.mts.map +0 -1
  211. package/dist/readRequestBody-BTIl3k-D.mjs.map +0 -1
  212. package/dist/readRequestBody-Dej_L3c4.cjs.map +0 -1
  213. package/dist/requestLogger-BZcXwdBs.cjs.map +0 -1
  214. package/dist/requestLogger-pA4gi3E1.mjs.map +0 -1
  215. package/dist/runSubscriber-CC_2C9F2.cjs.map +0 -1
  216. package/dist/runSubscriber-DyHWp_Lf.mjs.map +0 -1
  217. package/dist/websocket-api.cjs.map +0 -1
  218. package/dist/websocket-api.d.cts.map +0 -1
  219. package/dist/websocket-api.d.mts.map +0 -1
  220. package/dist/websocket-api.mjs.map +0 -1
@@ -1,4 +1,4 @@
1
- import { c as Topic } from "./Construct-DySlwh8o.mjs";
1
+ import { c as Topic } from "./Construct-BMk_CRSD.mjs";
2
2
  import { n as Construct } from "./construct-interface-CSA9VeWM.mjs";
3
3
  import { ConstructName, Declaration, InboxAddressing, InboxRecipient } from "@geekmidas/manifest";
4
4
  import { Service } from "@geekmidas/services";
@@ -192,4 +192,4 @@ declare function receiveMail(message: ArrivedMessage, inboxes: readonly Receivin
192
192
  declare function isInbox(value: unknown): value is Inbox;
193
193
  //#endregion
194
194
  export { InboxHasNoAddresses as a, RawMessageUnreadable as c, ReceivingInbox as d, Verdict as f, unjudgedReceipt as g, receiveMail as h, InboxClient as i, ReceiptNotification as l, isInbox as m, Inbox as n, InboxMessage as o, Verdicts as p, InboxAddressInvalid as r, InboxOptions as s, ArrivedMessage as t, ReceiptNotificationMalformed as u };
195
- //# sourceMappingURL=inbox-CjxpLVkH.d.mts.map
195
+ //# sourceMappingURL=inbox-YOdxlyfj.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"inbox-CjxpLVkH.d.mts","names":[],"sources":["../src/inbox.ts"],"mappings":";;;;;;UAsDiB;;;;;EAKhB;;;;;EAKA;;;cAIY,4BAA4B;WACnB;EAArB,YAAqB;;;cAUT,4BAA4B;WAE9B;WACA;EAFV,YACU,eACA;;;;;;cAeE,qCAAqC;WAEvC;WACA;EAFV,YACU,eACA;;;;;;;;KAgBC;;UAGK;EAChB,KAAK;EACL,MAAM;EACN,OAAO;EACP,MAAM;EACN,OAAO;;;;;;;;;;UAWS,qBACR,KAAK,6BACZ,KAAK;EACN,WAAW;;;;;EAKX;IAAO;IAAgB;;EACvB,UAAU;;;UAID;EACT;;;;;;;;UASgB;EAChB;EACA;IACC;IACA;;IAEA;IAC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;IACf,aAAa;IACb,cAAc;IACd,eAAe;IACf;MACC;MACA;MACA;MACA;;;;;UAMc;;WAEP;;EAET,IAAI,cAAc,QAAQ;;;;;;EAM1B,SAAS,cAAc,sBAAsB,QAAQ;;KAYjD,aAAa;cAEL,MAAM,0CACP,UAAU,OAAO;WAEnB,IAAI;WACJ,SAAS,QAAQ,aAAa,QAAQ;;WAEtC,OAAO;;WAGP,YAAY;mBACJ;mBACA;mBACA;EAEjB,YAAY,MAAM,cAAc,QAAQ,SAAS;EAgCjD,WAAW;UAcG;;;cAmEF,6BAA6B;WAE/B;WACA;WACA;EAHV,YACU,eACA,aACA;;;;;;iBA2DK,gBAAgB;EAC/B;EACA;EACA;EACA;EACA;EACA,WAAW,QAAQ;EACnB,YAAY;IACT;;UA+Ba;EAChB;EACA,YAAY;;EAEZ;;EAEA,QAAQ,cAAc,sBAAsB;;;UAI5B;;EAEhB;;EAEA;;EAEA;;EAEA;;EAEA,WAAW,QAAQ;;;;;;;;;;;;iBAaE,YACrB,SAAS,gBACT,kBAAkB,mBAChB;;iBAuBa,QAAQ,iBAAiB,SAAS"}
package/dist/inbox.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_Topic = require("./Topic-Dp9Q7Lj2.cjs");
2
+ const require_Topic = require("./Topic-t5GhqaeT.cjs");
3
3
  let _geekmidas_manifest = require("@geekmidas/manifest");
4
4
  let _geekmidas_storage = require("@geekmidas/storage");
5
5
  let _geekmidas_emailkit_inbound = require("@geekmidas/emailkit/inbound");
package/dist/inbox.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as InboxHasNoAddresses, c as RawMessageUnreadable, d as ReceivingInbox, f as Verdict, g as unjudgedReceipt, h as receiveMail, i as InboxClient, l as ReceiptNotification, m as isInbox, n as Inbox, o as InboxMessage, p as Verdicts, r as InboxAddressInvalid, s as InboxOptions, t as ArrivedMessage, u as ReceiptNotificationMalformed } from "./inbox-CjxpLVkH.mjs";
1
+ import { a as InboxHasNoAddresses, c as RawMessageUnreadable, d as ReceivingInbox, f as Verdict, g as unjudgedReceipt, h as receiveMail, i as InboxClient, l as ReceiptNotification, m as isInbox, n as Inbox, o as InboxMessage, p as Verdicts, r as InboxAddressInvalid, s as InboxOptions, t as ArrivedMessage, u as ReceiptNotificationMalformed } from "./inbox-YOdxlyfj.mjs";
2
2
  export { ArrivedMessage, Inbox, InboxAddressInvalid, InboxClient, InboxHasNoAddresses, InboxMessage, InboxOptions, RawMessageUnreadable, ReceiptNotification, ReceiptNotificationMalformed, ReceivingInbox, Verdict, Verdicts, isInbox, receiveMail, unjudgedReceipt };
package/dist/inbox.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { t as Topic } from "./Topic-DN2gYJ-p.mjs";
1
+ import { t as Topic } from "./Topic-DoEdDgh7.mjs";
2
2
  import { INBOX_EVENT, canonicalId, inboxRecipient, provideKey, serviceKey } from "@geekmidas/manifest";
3
3
  import { createStorageClient } from "@geekmidas/storage";
4
4
  import { parseEmail } from "@geekmidas/emailkit/inbound";
@@ -1,11 +1,11 @@
1
1
  import { n as StandardSchemaV1 } from "./index-DdRjYhiJ.mjs";
2
- import { a as EventFor, c as Topic, n as ConstructType, o as TopicEvent } from "./Construct-DySlwh8o.mjs";
3
- import { i as FunctionHandler, n as Function } from "./Function-DfMzTGS4.mjs";
2
+ import { a as EventFor, c as Topic, n as ConstructType, o as TopicEvent } from "./Construct-BMk_CRSD.mjs";
3
+ import { i as FunctionHandler, n as Function } from "./Function-BKReud5p.mjs";
4
4
  import { c as ServicesOf, r as Consumable } from "./construct-interface-CSA9VeWM.mjs";
5
5
  import { Service } from "@geekmidas/services";
6
- import { AuditStorage, AuditableAction } from "@geekmidas/audit";
7
6
  import { Logger } from "@geekmidas/logger";
8
7
  import { ComposableStandardSchema, InferComposableStandardSchema, InferStandardSchema } from "@geekmidas/schema";
8
+ import { AuditStorage, AuditableAction } from "@geekmidas/audit";
9
9
  //#region src/functions/BaseFunctionBuilder.d.ts
10
10
  declare abstract class BaseFunctionBuilder<TInput extends ComposableStandardSchema, OutSchema extends StandardSchemaV1 | undefined = undefined, TServices extends Service[] = [], TLogger extends Logger = Logger, TAuditStorage extends AuditStorage | undefined = undefined, TAuditStorageServiceName extends string = string, TDatabase = undefined, TDatabaseServiceName extends string = string> {
11
11
  type: ConstructType;
@@ -112,4 +112,4 @@ declare class FunctionBuilder<TInput extends ComposableStandardSchema, OutSchema
112
112
  }
113
113
  //#endregion
114
114
  export { BaseFunctionBuilder as n, FunctionBuilder as t };
115
- //# sourceMappingURL=index-DCkDQkwj.d.mts.map
115
+ //# sourceMappingURL=index-BoQ3-M-K.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-DCkDQkwj.d.mts","names":[],"sources":["../src/functions/BaseFunctionBuilder.ts","../src/functions/FunctionBuilder.ts"],"mappings":";;;;;;;;;uBAsBsB,oBACrB,eAAe,0BACf,kBAAkB,0CAClB,kBAAkB,gBAClB,gBAAgB,SAAS,QACzB,sBAAsB,sCACtB,kDACA,uBACA;EAoFmB,MAAI;YAlFb,cAAc;YACd,eAAe;YACf;EAEH,WAAW;;;;;;;;;EASX;EACA,SAAS;;;;;;;EAQT;;;;;;;;EASA;;EAGA,SAAS;YACN,kBAAkB,QAAQ,0BAA0B;YACpD,mBAAmB,QAAQ,sBAAsB;;YAEjD;SAEH,mBAAmB,aAAa,KAAK;SAM/B,8BACZ,UAAU,sCACT,eAAe,QAAQ,IAAI,QAAQ,8BAA8B;EAkCnE,YAAmB,OAAI;WAEd,SAAS,UAAU,WAAW,UAAU;WAExC,OAAO,UAAU,QAAQ,QAAQ;EAE1C,QAAQ;WAIC,OAAO,UAAU,kBAAkB,QAAQ;WAE3C,MAAM,UAAU,0BAA0B,QAAQ;;;;;;;YAQjD,UACT,OAAO,iBACP,OAAO,SAAS;EAcjB,QAAQ,UAAU,cAAc,sBAC/B,SAAS,QAAQ,OAAO,KACtB,oBACF,QACA,WACA,WAC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AAO,KAC5C,gBACF,QACA,WACA,WACA,SACA,eACA,0BACA,GACA,OACA;EAkCD,OACC,IAAI,gBACH,QACA,WACA,SACA,WACA,WACA,eACA,gBAEC,SACF,QACA,WACA,SACA,WACA,eACA,0BACA,WACA,sBACA,cACA,gBACC,QACA,WACA,SACA,WACA,WACA,eACA"}
1
+ {"version":3,"file":"index-BoQ3-M-K.d.mts","names":[],"sources":["../src/functions/BaseFunctionBuilder.ts","../src/functions/FunctionBuilder.ts"],"mappings":";;;;;;;;;uBAsBsB,oBACrB,eAAe,0BACf,kBAAkB,0CAClB,kBAAkB,gBAClB,gBAAgB,SAAS,QACzB,sBAAsB,sCACtB,kDACA,uBACA;EAoFmB,MAAI;YAlFb,cAAc;YACd,eAAe;YACf;EAEH,WAAW;;;;;;;;;EASX;EACA,SAAS;;;;;;;EAQT;;;;;;;;EASA;;EAGA,SAAS;YACN,kBAAkB,QAAQ,0BAA0B;YACpD,mBAAmB,QAAQ,sBAAsB;;YAEjD;SAEH,mBAAmB,aAAa,KAAK;SAM/B,8BACZ,UAAU,sCACT,eAAe,QAAQ,IAAI,QAAQ,8BAA8B;EAkCnE,YAAmB,OAAI;WAEd,SAAS,UAAU,WAAW,UAAU;WAExC,OAAO,UAAU,QAAQ,QAAQ;EAE1C,QAAQ;WAIC,OAAO,UAAU,kBAAkB,QAAQ;WAE3C,MAAM,UAAU,0BAA0B,QAAQ;;;;;;;YAQjD,UACT,OAAO,iBACP,OAAO,SAAS;EAcjB,QAAQ,UAAU,cAAc,sBAC/B,SAAS,QAAQ,OAAO,KACtB,oBACF,QACA,WACA,WACA,SACA,GACA,OACA,WACA;;;;;EAuBD,SAAS,GAAG,sBACX,QAAQ,WAAW,OAAO,KAAK,QAAQ,OAAO,KAC5C,oBACF,QACA,WACA,WACA,SACA,eACA,0BACA,GACA;;;;cCzKW,gBACZ,eAAe,0BACf,kBAAkB,0CAClB,kBAAkB,gBAClB,gBAAgB,SAAS,QACzB,sBAAsB,sCACtB,kDACA,uBACA,8CACA,qBAAqB,mCAAmC,0CAI/C,oBACT,QACA,WACA,WACA,SACA,eACA,0BACA,WACA;EAI4B,MAAI;YAFtB;EAEV,YAA4B,OAAI;EAIvB,QAAQ;EAIjB,WAAW;EAIX,OAAO,UAAU,kBAChB,QAAQ,IACN,gBACF,QACA,GACA,WACA,SACA,eACA,0BACA,WACA,sBACA;EAiBD,MAAM,UAAU,0BACf,QAAQ,IACN,gBACF,GACA,WACA,WACA,SACA,eACA,0BACA,WACA,sBACA;;;;;;;;;;;;EA4BD,gBAAgB,mBAAmB,cAClC,YAAY,IACV,gBACF,QACA,eACI,cAAc,WAAW,KAC7B,SACA,eACA,0BACA,WACA,sBACA;EA8BD,SAAS,UAAU,WAClB,UAAU,IACR,gBACF,QACA,eACI,cAAc,IAClB,SACA,eACA,0BACA,WACA,sBACA;EAoBD,OAAO,UAAU,QAChB,QAAQ,IACN,gBACF,QACA,WACA,WACA,GACA,eACA,0BACA,WACA,sBACA;;;;;;;EAuBD,MAAM,eAAe,iBACpB,OAAO,QACP,OAAO,SAAS,QAAQ,oBAAoB,cAC1C,gBACF,QACA,eACI,WAAW,oBACf,SACA,eACA,0BACA,WACA,sBACA;EAeQ,QAAQ,UAAU,cAAc,sBACxC,SAAS,QAAQ,OAAO,KACtB,gBACF,QACA,WACA,WACA,SACA,GACA,OACA,WACA,sBACA;;;;;EAwBD,QAAQ,UAAU,qCAAqC,gBACtD,QACA,WACA,WACA,SACA,eACA,0BACA,WACA,sBACA;;;;;EAmBQ,SAAS,GAAG,sBACpB,QAAQ,WAAW,OAAO,KAAK,QAAQ,OAAO,KAC5C,gBACF,QACA,WACA,WACA,SACA,eACA,0BACA,GACA,OACA;EAkCD,OACC,IAAI,gBACH,QACA,WACA,SACA,WACA,WACA,eACA,gBAEC,SACF,QACA,WACA,SACA,WACA,eACA,0BACA,WACA,sBACA,cACA,gBACC,QACA,WACA,SACA,WACA,WACA,eACA"}
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_Construct = require("./Construct-DorKS0Ua.cjs");
2
+ const require_Construct = require("./Construct-B8yWxGlR.cjs");
3
3
  const require_shutdown = require("./shutdown-BMJmAhSt.cjs");
4
4
  exports.Construct = require_Construct.Construct;
5
5
  exports.ConstructType = require_Construct.ConstructType;
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { i as snifferContext, n as ConstructType, r as sniffService, t as Construct } from "./Construct-DySlwh8o.mjs";
1
+ import { i as snifferContext, n as ConstructType, r as sniffService, t as Construct } from "./Construct-BMk_CRSD.mjs";
2
2
  import { n as LowerHttpMethod, r as RemoveUndefined, t as HttpMethod } from "./types-DMuSQeLL.mjs";
3
3
  import { i as TelemetryResponse, n as TelemetryContext, r as TelemetryRequest, t as Telemetry } from "./lambdaTelemetry-8vnmVZQ5.mjs";
4
4
  import { a as Stages, i as SeedContext, n as DeployedStage, o as TestStage, r as LocalStage, t as AnyStage } from "./stages-DaTaoQei.mjs";
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { i as snifferContext, n as ConstructType, r as sniffService, t as Construct } from "./Construct-CGuc_Ijk.mjs";
1
+ import { i as snifferContext, n as ConstructType, r as sniffService, t as Construct } from "./Construct-CRV3RN2U.mjs";
2
2
  import { n as runShutdownHooks, t as onShutdown } from "./shutdown-C7xa8x9S.mjs";
3
3
  export { Construct, ConstructType, onShutdown, runShutdownHooks, sniffService, snifferContext };
@@ -1,4 +1,4 @@
1
- const require_rolldown_runtime = require("./rolldown-runtime-y5ARvAq5.cjs");
1
+ const require_rolldown_runtime = require("./rolldown-runtime-Ctb5zv51.cjs");
2
2
  const require_shutdown = require("./shutdown-BMJmAhSt.cjs");
3
3
  const require_cache = require("./cache.cjs");
4
4
  let _geekmidas_manifest = require("@geekmidas/manifest");
@@ -381,4 +381,4 @@ Object.defineProperty(exports, "closeDatabasePools", {
381
381
  }
382
382
  });
383
383
 
384
- //# sourceMappingURL=kysely-CukArHJ0.cjs.map
384
+ //# sourceMappingURL=kysely-CeoQdAkg.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"kysely-CukArHJ0.cjs","names":["onShutdown","currentRequestContext","trace","isSpanContextValid","SpanKind","SpanStatusCode","context","canonicalId","provideKey","DEFAULT_POSTGRES_VERSION","serviceKey","Cache","kysely","Kysely","PostgresDialect"],"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, and inside a trace the query's own span as\n * `traceparent='00-<trace>-<span>-<flags>'`. It shows in\n * `pg_stat_activity.query`, in the server's slow-query and `auto_explain`\n * logs, and costs no round trip; `pg_stat_statements` ignores comments, so\n * 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 span per query.** Through the global OpenTelemetry tracer, so a no-op\n * without a provider. `pg` is bundled into a production entry, where no\n * instrumentation can hook its module load — so the client is wrapped here,\n * as the tags are. See {@link traceQueries}.\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 {\n\ttype Attributes,\n\tcontext,\n\tisSpanContextValid,\n\tSpanKind,\n\tSpanStatusCode,\n\ttrace,\n} from '@opentelemetry/api';\nimport pg from 'pg';\nimport { onShutdown } from '../shutdown';\n\nexport interface DatabasePoolOptions {\n\t/** Tag queries with what ran them and the trace they ran in. Default true. */\n\tqueryTags?: boolean;\n}\n\n/** The longest statement text a query span carries. */\nexport const MAX_STATEMENT_LENGTH = 2048;\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({ err: error }, 'Idle database connection lost');\n\t\telse console.warn('Idle database connection lost:', error.message);\n\t});\n\tconst target = connectionAttributes(parsed);\n\tpool.on('connect', (client) => {\n\t\t// Tags first, so the span wraps them: it records the statement as the\n\t\t// application wrote it rather than with the comment on the end, and it\n\t\t// is the active span when the tag is written — so the `traceparent` a\n\t\t// query carries names the query's own span.\n\t\tif (options.queryTags !== false) tagQueries(client);\n\t\ttraceQueries(client, target);\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: the request's operation and id, and\n * the active span as a W3C `traceparent` — the query's own span when it runs\n * through a traced client, since the span wraps the tagging. '' with neither.\n *\n * The keys are in sqlcommenter's sorted order. Values keep only characters\n * that cannot end a comment or a quoted value — `*` and `'` among those\n * dropped — so a route cannot inject SQL through it.\n */\nexport function queryTag(): string {\n\tconst request = currentRequestContext();\n\tconst span = trace.getActiveSpan()?.spanContext();\n\n\tconst tags = [\n\t\t['operation', request?.operation],\n\t\t['request_id', request?.requestId],\n\t\t['traceparent', span && isSpanContextValid(span) ? traceparent(span) : ''],\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/** A span as W3C trace context's `traceparent`, version 00. */\nfunction traceparent(span: {\n\ttraceId: string;\n\tspanId: string;\n\ttraceFlags: number;\n}): string {\n\tconst flags = (span.traceFlags & 0xff).toString(16).padStart(2, '0');\n\treturn `00-${span.traceId}-${span.spanId}-${flags}`;\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/** What every span of one pool says about where it connects. */\nfunction connectionAttributes(url: URL): Attributes {\n\tconst name = decodeURIComponent(url.pathname.slice(1));\n\treturn {\n\t\t'db.system': 'postgresql',\n\t\t...(name && { 'db.name': name }),\n\t\t'server.address': url.hostname,\n\t\t'server.port': Number(url.port || 5432),\n\t};\n}\n\nconst TRACER = '@geekmidas/constructs';\n\n/** `select`, `insert`, … — the first keyword, or `with`'s main statement. */\nconst OPERATION = /^\\s*(?:\\/\\*.*?\\*\\/\\s*)?(\\w+)/s;\n/** The table a statement is about, when it names one where it usually does. */\nconst TABLE =\n\t/\\b(?:from|into|update|join)\\s+((?:\"[^\"]+\"|[\\w$]+)(?:\\.(?:\"[^\"]+\"|[\\w$]+))?)/i;\n\n/**\n * What a statement does and to which table, parsed cheaply from its first\n * characters: `select \"orders\"`, `insert \"public\".\"users\"`. A statement the\n * patterns cannot read leaves `table` unset.\n */\nexport function describeStatement(text: string): {\n\toperation?: string;\n\ttable?: string;\n} {\n\tconst head = text.length > 512 ? text.slice(0, 512) : text;\n\tconst operation = OPERATION.exec(head)?.[1]?.toLowerCase();\n\tconst table = TABLE.exec(head)?.[1]?.replace(/\"/g, '');\n\treturn {\n\t\t...(operation && { operation }),\n\t\t...(table && { table }),\n\t};\n}\n\n/**\n * A span around everything `client` runs — `<operation> <table>`, or\n * `db.query` when the statement does not say.\n *\n * The statement text goes on the span only for a parameterized query — values\n * passed separately, as Kysely always does — and truncated. Parameter values\n * never do. A bare string with no values could hold anything a caller\n * concatenated into it, so it gets no text at all.\n */\nfunction traceQueries(client: pg.PoolClient, connection: Attributes): void {\n\tconst query = client.query.bind(client) as (...args: unknown[]) => unknown;\n\tclient.query = ((first: unknown, ...rest: unknown[]) => {\n\t\tconst config =\n\t\t\tfirst && typeof first === 'object'\n\t\t\t\t? (first as { text?: unknown; values?: unknown })\n\t\t\t\t: undefined;\n\t\tconst text =\n\t\t\ttypeof first === 'string'\n\t\t\t\t? first\n\t\t\t\t: typeof config?.text === 'string'\n\t\t\t\t\t? config.text\n\t\t\t\t\t: undefined;\n\t\tconst values = typeof first === 'string' ? rest[0] : config?.values;\n\t\tconst { operation, table } = text ? describeStatement(text) : {};\n\n\t\tconst span = trace\n\t\t\t.getTracer(TRACER)\n\t\t\t.startSpan(operation && table ? `${operation} ${table}` : 'db.query', {\n\t\t\t\tkind: SpanKind.CLIENT,\n\t\t\t\tattributes: {\n\t\t\t\t\t...connection,\n\t\t\t\t\t...(operation && { 'db.operation': operation }),\n\t\t\t\t\t...(table && { 'db.sql.table': table }),\n\t\t\t\t\t...(text &&\n\t\t\t\t\t\tArray.isArray(values) && {\n\t\t\t\t\t\t\t'db.statement':\n\t\t\t\t\t\t\t\ttext.length > MAX_STATEMENT_LENGTH\n\t\t\t\t\t\t\t\t\t? text.slice(0, MAX_STATEMENT_LENGTH)\n\t\t\t\t\t\t\t\t\t: text,\n\t\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t});\n\t\tconst end = (error?: unknown) => {\n\t\t\tif (error) {\n\t\t\t\tif (error instanceof Error) span.recordException(error);\n\t\t\t\tspan.setStatus({ code: SpanStatusCode.ERROR });\n\t\t\t}\n\t\t\tspan.end();\n\t\t};\n\n\t\t// A callback, as `pg`'s own callback form takes it.\n\t\tconst last = rest[rest.length - 1];\n\t\tif (typeof last === 'function') {\n\t\t\tconst args = [...rest];\n\t\t\targs[args.length - 1] = (error: unknown, ...result: unknown[]) => {\n\t\t\t\tend(error);\n\t\t\t\treturn (last as (...a: unknown[]) => unknown)(error, ...result);\n\t\t\t};\n\t\t\treturn context.with(trace.setSpan(context.active(), span), () =>\n\t\t\t\tquery(first, ...args),\n\t\t\t);\n\t\t}\n\n\t\tlet result: unknown;\n\t\ttry {\n\t\t\tresult = context.with(trace.setSpan(context.active(), span), () =>\n\t\t\t\tquery(first, ...rest),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tend(error);\n\t\t\tthrow error;\n\t\t}\n\n\t\tif (result && typeof (result as Promise<unknown>).then === 'function') {\n\t\t\t(result as Promise<unknown>).then(\n\t\t\t\t() => end(),\n\t\t\t\t(error) => end(error),\n\t\t\t);\n\t\t} else if (\n\t\t\tresult &&\n\t\t\ttypeof (result as { once?: unknown }).once === 'function'\n\t\t) {\n\t\t\t// A submittable — a cursor or a stream — ends when it says so.\n\t\t\tconst emitter = result as {\n\t\t\t\tonce(event: string, fn: (e?: unknown) => void): void;\n\t\t\t};\n\t\t\temitter.once('end', () => end());\n\t\t\temitter.once('error', (error) => end(error));\n\t\t} else {\n\t\t\tend();\n\t\t}\n\t\treturn result;\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 */\ninterface KyselyDatabaseBaseOptions 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 * Extensions to create in this database, as the cluster master, before the\n\t * first migration — for the ones the owner role a migration runs as may not\n\t * create (PostGIS is not a trusted extension). They are created in\n\t * `public`, which joins this database's roles' `search_path`, so their\n\t * types resolve unqualified.\n\t *\n\t * Only attempted: the image has to ship them.\n\t */\n\textensions?: readonly string[];\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 — and, inside a\n\t * trace, with the query span's `traceparent='00-…'` (sqlcommenter), so\n\t * they can tie it to the trace too. Defaults to on.\n\t */\n\tqueryTags?: boolean;\n}\n\n/**\n * Which Postgres the database runs: a major on the stock image, or an image\n * the project names. One or the other, never both — an image's tag already\n * says its major, and a second statement of it is one that can disagree.\n */\nexport type PostgresRuntime =\n\t| {\n\t\t\t/**\n\t\t\t * The Postgres major version to provision, on the stock image.\n\t\t\t *\n\t\t\t * Declared here so one statement reaches every target. It was\n\t\t\t * previously set in two unrelated places — a container tag locally,\n\t\t\t * nothing at all on AWS (so Aurora chose) — which is how local came to\n\t\t\t * run 18 while deployed ran 17.7 with nothing recording the difference.\n\t\t\t *\n\t\t\t * Defaults to {@link DEFAULT_POSTGRES_VERSION}.\n\t\t\t */\n\t\t\tversion?: PostgresVersion;\n\t\t\timage?: never;\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * The container image to run, wherever a target runs one (local,\n\t\t\t * Dokploy), in place of `postgres:<version>`.\n\t\t\t *\n\t\t\t * Yours to choose and used as written: its tag is the major, and it\n\t\t\t * should ship every extension in `extensions`. AWS runs RDS, ignores\n\t\t\t * it, and provisions {@link DEFAULT_POSTGRES_VERSION}.\n\t\t\t *\n\t\t\t * ```ts\n\t\t\t * new KyselyDatabase<GeoDB>('Geo', {\n\t\t\t * image: 'postgis/postgis:18-3.6-alpine',\n\t\t\t * extensions: ['postgis'],\n\t\t\t * });\n\t\t\t * ```\n\t\t\t */\n\t\t\timage: string;\n\t\t\tversion?: never;\n\t };\n\n/**\n * Everything Kysely takes, plus what this construct declares — including\n * which Postgres it runs, as a version or an image.\n */\nexport type KyselyDatabaseOptions = KyselyDatabaseBaseOptions & PostgresRuntime;\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 runtime: { version: PostgresVersion } | { image: string };\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.runtime = options.image\n\t\t\t? { image: options.image }\n\t\t\t: { 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\t// A version, or the image whose tag is one — never both.\n\t\t\t\t...this.runtime,\n\t\t\t\t...(this.options.extensions?.length\n\t\t\t\t\t? { extensions: [...new Set(this.options.extensions)] }\n\t\t\t\t\t: {}),\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\\`, \\`version\\`, \\`image\\`\n\t\t// and \\`extensions\\` describe infrastructure and mean nothing to a\n\t\t// client.\n\t\tconst {\n\t\t\tschema: _schema,\n\t\t\troles: _roles,\n\t\t\tversion: _version,\n\t\t\timage: _image,\n\t\t\textensions: _extensions,\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 './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CAAC,GACf;EAChB,OAAO,IAAIC,cAAAA,MAAc,IAAI;GAC5B,IAAI,KAAK;GACT,GAAI,QAAQ,QAAQ,EAAE,OAAO,QAAQ,MAAM,IAAI,CAAC;EACjD,CAAC;CACF;;;;;;;;;CAUA,OACC,IACA,UAAiC,CAAC,GACE;EACpC,OAAO,IAAI,eAAkC,IAAI,SAAS;GACzD,MAAM;GACN,IAAI,KAAK;GACT,QAAQ,QAAQ,UAAW,GAAc,YAAY;EACtD,CAAC;CACF;;;;;;;;;;;;;CAcA,IAAI,QAA4D;EAC/D,OAAO;GACN,aACC,IAAA,GAAGD,oBAAAA,WAAAA,CAAW,KAAK,EAAE,EAAE;GACxB,WAAW,YAAY,KAAK,QAAQ,SAAS,EAAE,OAAO,KAAK,CAAC;EAC7D;CACD;;;;;;;;;CAUA,IAAI,eAA8C;EAKjD,MAAM,EACL,QAAQ,SACR,OAAO,QACP,SAAS,UACT,OAAO,QACP,YAAY,aACZ,WAAW,YACX,GAAGE,aACA,KAAK;EACT,OAAOA;CACR;CAEA,MAAc,QACb,SACA,KAA0B,CAAC,GACL;EACtB,MAAM,EAAE,KAAK,aAAa,QAAQ,UAChC,QAAQ,SAAS;GACjB,KAAK,IAAI,KAAK,OAAO,GAAG,CAAC,CAAC,OAAO;GACjC,UAAU,IAAI,KAAK,OAAO,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,SAAS;EACvD,EAAE,CAAC,CACF,MAAM;EAER,OAAO,IAAIC,OAAAA,OAAW;GACrB,GAAG,KAAK;GACR,SAAS,IAAIC,OAAAA,gBAAgB,EAC5B,MAAM,SAAS,GAAG,QAAS,YAAY,MAAO,KAAK,EAClD,WAAW,KAAK,QAAQ,UACzB,CAAC,EACF,CAAC;EACF,CAAC;CACF;AACD"}
1
+ {"version":3,"file":"kysely-CeoQdAkg.cjs","names":["onShutdown","currentRequestContext","trace","isSpanContextValid","SpanKind","SpanStatusCode","context","canonicalId","provideKey","DEFAULT_POSTGRES_VERSION","serviceKey","Cache","kysely","Kysely","PostgresDialect"],"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, and inside a trace the query's own span as\n * `traceparent='00-<trace>-<span>-<flags>'`. It shows in\n * `pg_stat_activity.query`, in the server's slow-query and `auto_explain`\n * logs, and costs no round trip; `pg_stat_statements` ignores comments, so\n * 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 span per query.** Through the global OpenTelemetry tracer, so a no-op\n * without a provider. `pg` is bundled into a production entry, where no\n * instrumentation can hook its module load — so the client is wrapped here,\n * as the tags are. See {@link traceQueries}.\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 {\n\ttype Attributes,\n\tcontext,\n\tisSpanContextValid,\n\tSpanKind,\n\tSpanStatusCode,\n\ttrace,\n} from '@opentelemetry/api';\nimport pg from 'pg';\nimport { onShutdown } from '../shutdown';\n\nexport interface DatabasePoolOptions {\n\t/** Tag queries with what ran them and the trace they ran in. Default true. */\n\tqueryTags?: boolean;\n}\n\n/** The longest statement text a query span carries. */\nexport const MAX_STATEMENT_LENGTH = 2048;\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({ err: error }, 'Idle database connection lost');\n\t\telse console.warn('Idle database connection lost:', error.message);\n\t});\n\tconst target = connectionAttributes(parsed);\n\tpool.on('connect', (client) => {\n\t\t// Tags first, so the span wraps them: it records the statement as the\n\t\t// application wrote it rather than with the comment on the end, and it\n\t\t// is the active span when the tag is written — so the `traceparent` a\n\t\t// query carries names the query's own span.\n\t\tif (options.queryTags !== false) tagQueries(client);\n\t\ttraceQueries(client, target);\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: the request's operation and id, and\n * the active span as a W3C `traceparent` — the query's own span when it runs\n * through a traced client, since the span wraps the tagging. '' with neither.\n *\n * The keys are in sqlcommenter's sorted order. Values keep only characters\n * that cannot end a comment or a quoted value — `*` and `'` among those\n * dropped — so a route cannot inject SQL through it.\n */\nexport function queryTag(): string {\n\tconst request = currentRequestContext();\n\tconst span = trace.getActiveSpan()?.spanContext();\n\n\tconst tags = [\n\t\t['operation', request?.operation],\n\t\t['request_id', request?.requestId],\n\t\t['traceparent', span && isSpanContextValid(span) ? traceparent(span) : ''],\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/** A span as W3C trace context's `traceparent`, version 00. */\nfunction traceparent(span: {\n\ttraceId: string;\n\tspanId: string;\n\ttraceFlags: number;\n}): string {\n\tconst flags = (span.traceFlags & 0xff).toString(16).padStart(2, '0');\n\treturn `00-${span.traceId}-${span.spanId}-${flags}`;\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/** What every span of one pool says about where it connects. */\nfunction connectionAttributes(url: URL): Attributes {\n\tconst name = decodeURIComponent(url.pathname.slice(1));\n\treturn {\n\t\t'db.system': 'postgresql',\n\t\t...(name && { 'db.name': name }),\n\t\t'server.address': url.hostname,\n\t\t'server.port': Number(url.port || 5432),\n\t};\n}\n\nconst TRACER = '@geekmidas/constructs';\n\n/** `select`, `insert`, … — the first keyword, or `with`'s main statement. */\nconst OPERATION = /^\\s*(?:\\/\\*.*?\\*\\/\\s*)?(\\w+)/s;\n/** The table a statement is about, when it names one where it usually does. */\nconst TABLE =\n\t/\\b(?:from|into|update|join)\\s+((?:\"[^\"]+\"|[\\w$]+)(?:\\.(?:\"[^\"]+\"|[\\w$]+))?)/i;\n\n/**\n * What a statement does and to which table, parsed cheaply from its first\n * characters: `select \"orders\"`, `insert \"public\".\"users\"`. A statement the\n * patterns cannot read leaves `table` unset.\n */\nexport function describeStatement(text: string): {\n\toperation?: string;\n\ttable?: string;\n} {\n\tconst head = text.length > 512 ? text.slice(0, 512) : text;\n\tconst operation = OPERATION.exec(head)?.[1]?.toLowerCase();\n\tconst table = TABLE.exec(head)?.[1]?.replace(/\"/g, '');\n\treturn {\n\t\t...(operation && { operation }),\n\t\t...(table && { table }),\n\t};\n}\n\n/**\n * A span around everything `client` runs — `<operation> <table>`, or\n * `db.query` when the statement does not say.\n *\n * The statement text goes on the span only for a parameterized query — values\n * passed separately, as Kysely always does — and truncated. Parameter values\n * never do. A bare string with no values could hold anything a caller\n * concatenated into it, so it gets no text at all.\n */\nfunction traceQueries(client: pg.PoolClient, connection: Attributes): void {\n\tconst query = client.query.bind(client) as (...args: unknown[]) => unknown;\n\tclient.query = ((first: unknown, ...rest: unknown[]) => {\n\t\tconst config =\n\t\t\tfirst && typeof first === 'object'\n\t\t\t\t? (first as { text?: unknown; values?: unknown })\n\t\t\t\t: undefined;\n\t\tconst text =\n\t\t\ttypeof first === 'string'\n\t\t\t\t? first\n\t\t\t\t: typeof config?.text === 'string'\n\t\t\t\t\t? config.text\n\t\t\t\t\t: undefined;\n\t\tconst values = typeof first === 'string' ? rest[0] : config?.values;\n\t\tconst { operation, table } = text ? describeStatement(text) : {};\n\n\t\tconst span = trace\n\t\t\t.getTracer(TRACER)\n\t\t\t.startSpan(operation && table ? `${operation} ${table}` : 'db.query', {\n\t\t\t\tkind: SpanKind.CLIENT,\n\t\t\t\tattributes: {\n\t\t\t\t\t...connection,\n\t\t\t\t\t...(operation && { 'db.operation': operation }),\n\t\t\t\t\t...(table && { 'db.sql.table': table }),\n\t\t\t\t\t...(text &&\n\t\t\t\t\t\tArray.isArray(values) && {\n\t\t\t\t\t\t\t'db.statement':\n\t\t\t\t\t\t\t\ttext.length > MAX_STATEMENT_LENGTH\n\t\t\t\t\t\t\t\t\t? text.slice(0, MAX_STATEMENT_LENGTH)\n\t\t\t\t\t\t\t\t\t: text,\n\t\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t});\n\t\tconst end = (error?: unknown) => {\n\t\t\tif (error) {\n\t\t\t\tif (error instanceof Error) span.recordException(error);\n\t\t\t\tspan.setStatus({ code: SpanStatusCode.ERROR });\n\t\t\t}\n\t\t\tspan.end();\n\t\t};\n\n\t\t// A callback, as `pg`'s own callback form takes it.\n\t\tconst last = rest[rest.length - 1];\n\t\tif (typeof last === 'function') {\n\t\t\tconst args = [...rest];\n\t\t\targs[args.length - 1] = (error: unknown, ...result: unknown[]) => {\n\t\t\t\tend(error);\n\t\t\t\treturn (last as (...a: unknown[]) => unknown)(error, ...result);\n\t\t\t};\n\t\t\treturn context.with(trace.setSpan(context.active(), span), () =>\n\t\t\t\tquery(first, ...args),\n\t\t\t);\n\t\t}\n\n\t\tlet result: unknown;\n\t\ttry {\n\t\t\tresult = context.with(trace.setSpan(context.active(), span), () =>\n\t\t\t\tquery(first, ...rest),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tend(error);\n\t\t\tthrow error;\n\t\t}\n\n\t\tif (result && typeof (result as Promise<unknown>).then === 'function') {\n\t\t\t(result as Promise<unknown>).then(\n\t\t\t\t() => end(),\n\t\t\t\t(error) => end(error),\n\t\t\t);\n\t\t} else if (\n\t\t\tresult &&\n\t\t\ttypeof (result as { once?: unknown }).once === 'function'\n\t\t) {\n\t\t\t// A submittable — a cursor or a stream — ends when it says so.\n\t\t\tconst emitter = result as {\n\t\t\t\tonce(event: string, fn: (e?: unknown) => void): void;\n\t\t\t};\n\t\t\temitter.once('end', () => end());\n\t\t\temitter.once('error', (error) => end(error));\n\t\t} else {\n\t\t\tend();\n\t\t}\n\t\treturn result;\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 */\ninterface KyselyDatabaseBaseOptions 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 * Extensions to create in this database, as the cluster master, before the\n\t * first migration — for the ones the owner role a migration runs as may not\n\t * create (PostGIS is not a trusted extension). They are created in\n\t * `public`, which joins this database's roles' `search_path`, so their\n\t * types resolve unqualified.\n\t *\n\t * Only attempted: the image has to ship them.\n\t */\n\textensions?: readonly string[];\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 — and, inside a\n\t * trace, with the query span's `traceparent='00-…'` (sqlcommenter), so\n\t * they can tie it to the trace too. Defaults to on.\n\t */\n\tqueryTags?: boolean;\n}\n\n/**\n * Which Postgres the database runs: a major on the stock image, or an image\n * the project names. One or the other, never both — an image's tag already\n * says its major, and a second statement of it is one that can disagree.\n */\nexport type PostgresRuntime =\n\t| {\n\t\t\t/**\n\t\t\t * The Postgres major version to provision, on the stock image.\n\t\t\t *\n\t\t\t * Declared here so one statement reaches every target. It was\n\t\t\t * previously set in two unrelated places — a container tag locally,\n\t\t\t * nothing at all on AWS (so Aurora chose) — which is how local came to\n\t\t\t * run 18 while deployed ran 17.7 with nothing recording the difference.\n\t\t\t *\n\t\t\t * Defaults to {@link DEFAULT_POSTGRES_VERSION}.\n\t\t\t */\n\t\t\tversion?: PostgresVersion;\n\t\t\timage?: never;\n\t }\n\t| {\n\t\t\t/**\n\t\t\t * The container image to run, wherever a target runs one (local,\n\t\t\t * Dokploy), in place of `postgres:<version>`.\n\t\t\t *\n\t\t\t * Yours to choose and used as written: its tag is the major, and it\n\t\t\t * should ship every extension in `extensions`. AWS runs RDS, ignores\n\t\t\t * it, and provisions {@link DEFAULT_POSTGRES_VERSION}.\n\t\t\t *\n\t\t\t * ```ts\n\t\t\t * new KyselyDatabase<GeoDB>('Geo', {\n\t\t\t * image: 'postgis/postgis:18-3.6-alpine',\n\t\t\t * extensions: ['postgis'],\n\t\t\t * });\n\t\t\t * ```\n\t\t\t */\n\t\t\timage: string;\n\t\t\tversion?: never;\n\t };\n\n/**\n * Everything Kysely takes, plus what this construct declares — including\n * which Postgres it runs, as a version or an image.\n */\nexport type KyselyDatabaseOptions = KyselyDatabaseBaseOptions & PostgresRuntime;\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 runtime: { version: PostgresVersion } | { image: string };\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.runtime = options.image\n\t\t\t? { image: options.image }\n\t\t\t: { 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\t// A version, or the image whose tag is one — never both.\n\t\t\t\t...this.runtime,\n\t\t\t\t...(this.options.extensions?.length\n\t\t\t\t\t? { extensions: [...new Set(this.options.extensions)] }\n\t\t\t\t\t: {}),\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\\`, \\`version\\`, \\`image\\`\n\t\t// and \\`extensions\\` describe infrastructure and mean nothing to a\n\t\t// client.\n\t\tconst {\n\t\t\tschema: _schema,\n\t\t\troles: _roles,\n\t\t\tversion: _version,\n\t\t\timage: _image,\n\t\t\textensions: _extensions,\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":";;;;;;;;;;AAgDA,MAAM,uBAAO,IAAI,IAAa;AAC9BA,iBAAAA,iBAAiB,mBAAmB,CAAC;;;;;;;;;;;AAYrC,SAAgB,SACf,KACA,UAA+B,CAAC,GACtB;CACV,MAAM,SAAS,IAAI,IAAI,GAAG;CAC1B,MAAM,aAAa,OAAO,aAA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AAI,SAAS;GACzD,MAAM;GACN,IAAI,KAAK;GACT,QAAQ,QAAQ,UAAW,GAAc,YAAY;EACtD,CAAC;CACF;;;;;;;;;;;;;CAcA,IAAI,QAA4D;EAC/D,OAAO;GACN,aACC,IAAA,GAAGD,oBAAAA,WAAAA,CAAW,KAAK,EAAE,EAAE;GACxB,WAAW,YAAY,KAAK,QAAQ,SAAS,EAAE,OAAO,KAAK,CAAC;EAC7D;CACD;;;;;;;;;CAUA,IAAI,eAA8C;EAKjD,MAAM,EACL,QAAQ,SACR,OAAO,QACP,SAAS,UACT,OAAO,QACP,YAAY,aACZ,WAAW,YACX,GAAGE,aACA,KAAK;EACT,OAAOA;CACR;CAEA,MAAc,QACb,SACA,KAA0B,CAAC,GACL;EACtB,MAAM,EAAE,KAAK,aAAa,QAAQ,UAChC,QAAQ,SAAS;GACjB,KAAK,IAAI,KAAK,OAAO,GAAG,CAAC,CAAC,OAAO;GACjC,UAAU,IAAI,KAAK,OAAO,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,SAAS;EACvD,EAAE,CAAC,CACF,MAAM;EAER,OAAO,IAAIC,OAAAA,OAAW;GACrB,GAAG,KAAK;GACR,SAAS,IAAIC,OAAAA,gBAAgB,EAC5B,MAAM,SAAS,GAAG,QAAS,YAAY,MAAO,KAAK,EAClD,WAAW,KAAK,QAAQ,UACzB,CAAC,EACF,CAAC;EACF,CAAC;CACF;AACD"}
@@ -1,5 +1,5 @@
1
1
  import { n as Construct } from "./construct-interface-CSA9VeWM.mjs";
2
- import { t as Cache } from "./cache-e3tfMQ9g.mjs";
2
+ import { t as Cache } from "./cache-CCHcO9Oo.mjs";
3
3
  import { ConstructName, Declaration, PostgresVersion } from "@geekmidas/manifest";
4
4
  import { Service } from "@geekmidas/services";
5
5
  import { Kysely, KyselyConfig } from "kysely";
@@ -213,4 +213,4 @@ declare class KyselyDatabase<DB = unknown, TName extends string = string> implem
213
213
  type ReadOnlyDatabase<DB, TName extends string> = Omit<KyselyDatabase<DB, TName>, 'reader' | 'cache' | 'schema'>;
214
214
  //#endregion
215
215
  export { closeDatabasePools as a, ReadOnlyDatabase as i, KyselyDatabaseOptions as n, PostgresRuntime as r, KyselyDatabase as t };
216
- //# sourceMappingURL=kysely-DE4kADWD.d.mts.map
216
+ //# sourceMappingURL=kysely-De5rAC-E.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"kysely-DE4kADWD.d.mts","names":[],"sources":["../src/database/pool.ts","../src/database/kysely.ts"],"mappings":";;;;;;;;;;;iBAwGsB,sBAAsB;;;;;;;;;;;;UChElC,kCAAkC,KAAK;;;;;;;;EAQhD;;;;;;;;EAQA;;;;;;;;;;EAUA;;;;;;;;EAQA;;;;;;;KAQW;;;;;;;;;;;EAYT,UAAU;EACV;;;;;;;;;;;;;;;;;EAkBA;EACA;;;;;;KAOS,wBAAwB,4BAA4B;;UAGtD;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;EA2Bf,WAAW;;;;;;;;;;;;;EAyDX,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;UAiBX;;;;;;;;;;;;;;;;;;;KAuCH,iBAAiB,IAAI,wBAAwB,KACxD,eAAe,IAAI"}
1
+ {"version":3,"file":"kysely-De5rAC-E.d.mts","names":[],"sources":["../src/database/pool.ts","../src/database/kysely.ts"],"mappings":";;;;;;;;;;;iBAwGsB,sBAAsB;;;;;;;;;;;;UChElC,kCAAkC,KAAK;;;;;;;;EAQhD;;;;;;;;EAQA;;;;;;;;;;EAUA;;;;;;;;EAQA;;;;;;;KAQW;;;;;;;;;;;EAYT,UAAU;EACV;;;;;;;;;;;;;;;;;EAkBA;EACA;;;;;;KAOS,wBAAwB,4BAA4B;;UAGtD;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;EA2Bf,WAAW;;;;;;;;;;;;;EAyDX,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;UAiBX;;;;;;;;;;;;;;;;;;;KAuCH,iBAAiB,IAAI,wBAAwB,KACxD,eAAe,IAAI"}
@@ -0,0 +1,140 @@
1
+ //#region src/optionalPeers.ts
2
+ /**
3
+ * The optional peers a construct needs only for a feature it opted into.
4
+ *
5
+ * `@geekmidas/audit`, `@geekmidas/rate-limit`, `@geekmidas/db`,
6
+ * `@geekmidas/cache`, `@geekmidas/emailkit`, `@geekmidas/storage`, `hono`,
7
+ * `ws`, `ioredis` and `better-auth` are optional peers of this package: an app
8
+ * that audits nothing, limits nothing, sends no mail and serves no WebSocket
9
+ * need not install them. Entries that every app loads (`./endpoints`,
10
+ * `./crons`, `./worker`, `./testing`, the CLI's discovery) used to import them
11
+ * at the top, so loading any of them needed them all — and a production bundle
12
+ * of an app without them failed to build. They are loaded here instead, when
13
+ * the construct that uses one runs, which is also when the app declaring that
14
+ * construct has installed it.
15
+ *
16
+ * The `try` around each `import()` is load-bearing beyond the error it names:
17
+ * a bundler leaves an import it cannot resolve to run time when the import is
18
+ * guarded, and fails the build when it is not. `scripts/check-optional-peers.mjs`
19
+ * holds every entry to that: an optional peer is reached from its own adaptor
20
+ * subpath, or through a guarded `import()` like these.
21
+ */
22
+ /** A construct uses a feature whose optional peer is not installed. */
23
+ var OptionalPeerMissing = class extends Error {
24
+ packageName;
25
+ feature;
26
+ constructor(packageName, feature, cause) {
27
+ super(`${feature} needs '${packageName}', which could not be loaded. Add it to the dependencies of the app that declares it.`, { cause });
28
+ this.packageName = packageName;
29
+ this.feature = feature;
30
+ this.name = "OptionalPeerMissing";
31
+ }
32
+ };
33
+ /** `@geekmidas/audit`, for an endpoint, function or cron with an auditor. */
34
+ async function loadAudit() {
35
+ try {
36
+ return await import("@geekmidas/audit");
37
+ } catch (cause) {
38
+ throw new OptionalPeerMissing("@geekmidas/audit", "An auditor", cause);
39
+ }
40
+ }
41
+ /** `@geekmidas/audit/kysely`, for audits written in the handler's transaction. */
42
+ async function loadAuditKysely() {
43
+ try {
44
+ return await import("@geekmidas/audit/kysely");
45
+ } catch (cause) {
46
+ throw new OptionalPeerMissing("@geekmidas/audit", "An auditor that stores in the database", cause);
47
+ }
48
+ }
49
+ /** `@geekmidas/rate-limit`, for an endpoint with a rate limit. */
50
+ async function loadRateLimit() {
51
+ try {
52
+ return await import("@geekmidas/rate-limit");
53
+ } catch (cause) {
54
+ throw new OptionalPeerMissing("@geekmidas/rate-limit", "An endpoint with a rate limit", cause);
55
+ }
56
+ }
57
+ /** `@geekmidas/db/rls`, for an endpoint with row-level security. */
58
+ async function loadRls() {
59
+ try {
60
+ return await import("@geekmidas/db/rls");
61
+ } catch (cause) {
62
+ throw new OptionalPeerMissing("@geekmidas/db", "An endpoint with row-level security", cause);
63
+ }
64
+ }
65
+ /** `@geekmidas/cache`, for a `Cache` construct's client. */
66
+ async function loadCache() {
67
+ try {
68
+ return await import("@geekmidas/cache");
69
+ } catch (cause) {
70
+ throw new OptionalPeerMissing("@geekmidas/cache", "A Cache", cause);
71
+ }
72
+ }
73
+ /** `@geekmidas/emailkit`, for an `Email` construct's client. */
74
+ async function loadEmailkit() {
75
+ try {
76
+ return await import("@geekmidas/emailkit");
77
+ } catch (cause) {
78
+ throw new OptionalPeerMissing("@geekmidas/emailkit", "An Email", cause);
79
+ }
80
+ }
81
+ /** `@geekmidas/storage/events`, for a subscriber to a bucket's objects. */
82
+ async function loadStorageEvents() {
83
+ try {
84
+ return await import("@geekmidas/storage/events");
85
+ } catch (cause) {
86
+ throw new OptionalPeerMissing("@geekmidas/storage", "A subscriber to a bucket's objects", cause);
87
+ }
88
+ }
89
+ /** `hono`, for a surface that serves HTTP itself. */
90
+ async function loadHono(feature) {
91
+ try {
92
+ return await import("hono");
93
+ } catch (cause) {
94
+ throw new OptionalPeerMissing("hono", feature, cause);
95
+ }
96
+ }
97
+ /** `hono/cors`, beside {@link loadHono}. */
98
+ async function loadHonoCors(feature) {
99
+ try {
100
+ return await import("hono/cors");
101
+ } catch (cause) {
102
+ throw new OptionalPeerMissing("hono", feature, cause);
103
+ }
104
+ }
105
+ /** `ws`, for a `WebSocketApi`'s server. */
106
+ async function loadWs() {
107
+ try {
108
+ return await import("ws");
109
+ } catch (cause) {
110
+ throw new OptionalPeerMissing("ws", "A WebSocketApi", cause);
111
+ }
112
+ }
113
+ /** `ioredis`, for a `WebSocketApi` that fans out through Redis. */
114
+ async function loadIoredis() {
115
+ try {
116
+ return await import("ioredis");
117
+ } catch (cause) {
118
+ throw new OptionalPeerMissing("ioredis", "A WebSocketApi with a redis:// transport", cause);
119
+ }
120
+ }
121
+ /** `better-auth`, for an `Auth` construct's server. */
122
+ async function loadBetterAuth() {
123
+ try {
124
+ return await import("better-auth");
125
+ } catch (cause) {
126
+ throw new OptionalPeerMissing("better-auth", "An Auth", cause);
127
+ }
128
+ }
129
+ /** `better-auth/db/migration`, for migrating an `Auth` construct's tables. */
130
+ async function loadBetterAuthMigration() {
131
+ try {
132
+ return await import("better-auth/db/migration");
133
+ } catch (cause) {
134
+ throw new OptionalPeerMissing("better-auth", "An Auth", cause);
135
+ }
136
+ }
137
+ //#endregion
138
+ export { loadBetterAuthMigration as a, loadHono as c, loadRateLimit as d, loadRls as f, loadBetterAuth as i, loadHonoCors as l, loadWs as m, loadAudit as n, loadCache as o, loadStorageEvents as p, loadAuditKysely as r, loadEmailkit as s, OptionalPeerMissing as t, loadIoredis as u };
139
+
140
+ //# sourceMappingURL=optionalPeers-D7Wt6dnF.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optionalPeers-D7Wt6dnF.mjs","names":[],"sources":["../src/optionalPeers.ts"],"sourcesContent":["/**\n * The optional peers a construct needs only for a feature it opted into.\n *\n * `@geekmidas/audit`, `@geekmidas/rate-limit`, `@geekmidas/db`,\n * `@geekmidas/cache`, `@geekmidas/emailkit`, `@geekmidas/storage`, `hono`,\n * `ws`, `ioredis` and `better-auth` are optional peers of this package: an app\n * that audits nothing, limits nothing, sends no mail and serves no WebSocket\n * need not install them. Entries that every app loads (`./endpoints`,\n * `./crons`, `./worker`, `./testing`, the CLI's discovery) used to import them\n * at the top, so loading any of them needed them all — and a production bundle\n * of an app without them failed to build. They are loaded here instead, when\n * the construct that uses one runs, which is also when the app declaring that\n * construct has installed it.\n *\n * The `try` around each `import()` is load-bearing beyond the error it names:\n * a bundler leaves an import it cannot resolve to run time when the import is\n * guarded, and fails the build when it is not. `scripts/check-optional-peers.mjs`\n * holds every entry to that: an optional peer is reached from its own adaptor\n * subpath, or through a guarded `import()` like these.\n */\n\n/** A construct uses a feature whose optional peer is not installed. */\nexport class OptionalPeerMissing extends Error {\n\tconstructor(\n\t\treadonly packageName: string,\n\t\treadonly feature: string,\n\t\tcause: unknown,\n\t) {\n\t\tsuper(\n\t\t\t`${feature} needs '${packageName}', which could not be loaded. ` +\n\t\t\t\t`Add it to the dependencies of the app that declares it.`,\n\t\t\t{ cause },\n\t\t);\n\t\tthis.name = 'OptionalPeerMissing';\n\t}\n}\n\n/** `@geekmidas/audit`, for an endpoint, function or cron with an auditor. */\nexport async function loadAudit(): Promise<typeof import('@geekmidas/audit')> {\n\ttry {\n\t\treturn await import('@geekmidas/audit');\n\t} catch (cause) {\n\t\tthrow new OptionalPeerMissing('@geekmidas/audit', 'An auditor', cause);\n\t}\n}\n\n/** `@geekmidas/audit/kysely`, for audits written in the handler's transaction. */\nexport async function loadAuditKysely(): Promise<\n\ttypeof import('@geekmidas/audit/kysely')\n> {\n\ttry {\n\t\treturn await import('@geekmidas/audit/kysely');\n\t} catch (cause) {\n\t\tthrow new OptionalPeerMissing(\n\t\t\t'@geekmidas/audit',\n\t\t\t'An auditor that stores in the database',\n\t\t\tcause,\n\t\t);\n\t}\n}\n\n/** `@geekmidas/rate-limit`, for an endpoint with a rate limit. */\nexport async function loadRateLimit(): Promise<\n\ttypeof import('@geekmidas/rate-limit')\n> {\n\ttry {\n\t\treturn await import('@geekmidas/rate-limit');\n\t} catch (cause) {\n\t\tthrow new OptionalPeerMissing(\n\t\t\t'@geekmidas/rate-limit',\n\t\t\t'An endpoint with a rate limit',\n\t\t\tcause,\n\t\t);\n\t}\n}\n\n/** `@geekmidas/db/rls`, for an endpoint with row-level security. */\nexport async function loadRls(): Promise<typeof import('@geekmidas/db/rls')> {\n\ttry {\n\t\treturn await import('@geekmidas/db/rls');\n\t} catch (cause) {\n\t\tthrow new OptionalPeerMissing(\n\t\t\t'@geekmidas/db',\n\t\t\t'An endpoint with row-level security',\n\t\t\tcause,\n\t\t);\n\t}\n}\n\n/** `@geekmidas/cache`, for a `Cache` construct's client. */\nexport async function loadCache(): Promise<typeof import('@geekmidas/cache')> {\n\ttry {\n\t\treturn await import('@geekmidas/cache');\n\t} catch (cause) {\n\t\tthrow new OptionalPeerMissing('@geekmidas/cache', 'A Cache', cause);\n\t}\n}\n\n/** `@geekmidas/emailkit`, for an `Email` construct's client. */\nexport async function loadEmailkit(): Promise<\n\ttypeof import('@geekmidas/emailkit')\n> {\n\ttry {\n\t\treturn await import('@geekmidas/emailkit');\n\t} catch (cause) {\n\t\tthrow new OptionalPeerMissing('@geekmidas/emailkit', 'An Email', cause);\n\t}\n}\n\n/** `@geekmidas/emailkit/autoSubmitted`, for a subscriber to an `Inbox`. */\nexport async function loadAutoSubmitted(): Promise<\n\ttypeof import('@geekmidas/emailkit/autoSubmitted')\n> {\n\ttry {\n\t\treturn await import('@geekmidas/emailkit/autoSubmitted');\n\t} catch (cause) {\n\t\tthrow new OptionalPeerMissing(\n\t\t\t'@geekmidas/emailkit',\n\t\t\t'A subscriber to an Inbox',\n\t\t\tcause,\n\t\t);\n\t}\n}\n\n/** `@geekmidas/storage/events`, for a subscriber to a bucket's objects. */\nexport async function loadStorageEvents(): Promise<\n\ttypeof import('@geekmidas/storage/events')\n> {\n\ttry {\n\t\treturn await import('@geekmidas/storage/events');\n\t} catch (cause) {\n\t\tthrow new OptionalPeerMissing(\n\t\t\t'@geekmidas/storage',\n\t\t\t\"A subscriber to a bucket's objects\",\n\t\t\tcause,\n\t\t);\n\t}\n}\n\n/** `hono`, for a surface that serves HTTP itself. */\nexport async function loadHono(\n\tfeature: string,\n): Promise<typeof import('hono')> {\n\ttry {\n\t\treturn await import('hono');\n\t} catch (cause) {\n\t\tthrow new OptionalPeerMissing('hono', feature, cause);\n\t}\n}\n\n/** `hono/cors`, beside {@link loadHono}. */\nexport async function loadHonoCors(\n\tfeature: string,\n): Promise<typeof import('hono/cors')> {\n\ttry {\n\t\treturn await import('hono/cors');\n\t} catch (cause) {\n\t\tthrow new OptionalPeerMissing('hono', feature, cause);\n\t}\n}\n\n/** `ws`, for a `WebSocketApi`'s server. */\nexport async function loadWs(): Promise<typeof import('ws')> {\n\ttry {\n\t\treturn await import('ws');\n\t} catch (cause) {\n\t\tthrow new OptionalPeerMissing('ws', 'A WebSocketApi', cause);\n\t}\n}\n\n/** `ioredis`, for a `WebSocketApi` that fans out through Redis. */\nexport async function loadIoredis(): Promise<typeof import('ioredis')> {\n\ttry {\n\t\treturn await import('ioredis');\n\t} catch (cause) {\n\t\tthrow new OptionalPeerMissing(\n\t\t\t'ioredis',\n\t\t\t'A WebSocketApi with a redis:// transport',\n\t\t\tcause,\n\t\t);\n\t}\n}\n\n/** `better-auth`, for an `Auth` construct's server. */\nexport async function loadBetterAuth(): Promise<typeof import('better-auth')> {\n\ttry {\n\t\treturn await import('better-auth');\n\t} catch (cause) {\n\t\tthrow new OptionalPeerMissing('better-auth', 'An Auth', cause);\n\t}\n}\n\n/** `better-auth/db/migration`, for migrating an `Auth` construct's tables. */\nexport async function loadBetterAuthMigration(): Promise<\n\ttypeof import('better-auth/db/migration')\n> {\n\ttry {\n\t\treturn await import('better-auth/db/migration');\n\t} catch (cause) {\n\t\tthrow new OptionalPeerMissing('better-auth', 'An Auth', cause);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBA,IAAa,sBAAb,cAAyC,MAAM;CAEpC;CACA;CAFV,YACC,aACA,SACA,OACC;EACD,MACC,GAAG,QAAQ,UAAU,YAAY,wFAEjC,EAAE,MAAM,CACT;EARS,KAAA,cAAA;EACA,KAAA,UAAA;EAQT,KAAK,OAAO;CACb;AACD;;AAGA,eAAsB,YAAwD;CAC7E,IAAI;EACH,OAAO,MAAM,OAAO;CACrB,SAAS,OAAO;EACf,MAAM,IAAI,oBAAoB,oBAAoB,cAAc,KAAK;CACtE;AACD;;AAGA,eAAsB,kBAEpB;CACD,IAAI;EACH,OAAO,MAAM,OAAO;CACrB,SAAS,OAAO;EACf,MAAM,IAAI,oBACT,oBACA,0CACA,KACD;CACD;AACD;;AAGA,eAAsB,gBAEpB;CACD,IAAI;EACH,OAAO,MAAM,OAAO;CACrB,SAAS,OAAO;EACf,MAAM,IAAI,oBACT,yBACA,iCACA,KACD;CACD;AACD;;AAGA,eAAsB,UAAuD;CAC5E,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