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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (405) hide show
  1. package/README.md +223 -158
  2. package/dist/{Construct-BD5neF7w.mjs → Construct-BO1X-kt9.mjs} +32 -33
  3. package/dist/Construct-BO1X-kt9.mjs.map +1 -0
  4. package/dist/Construct-BQALFCh2.d.cts +230 -0
  5. package/dist/Construct-BQALFCh2.d.cts.map +1 -0
  6. package/dist/{Construct-CyS3RpTL.cjs → Construct-DmvXceVY.cjs} +52 -47
  7. package/dist/Construct-DmvXceVY.cjs.map +1 -0
  8. package/dist/Construct-QXnl3VqT.d.mts +230 -0
  9. package/dist/Construct-QXnl3VqT.d.mts.map +1 -0
  10. package/dist/{Cron-DmQ8vQ4b.d.cts → Cron-DI3nKoic.d.cts} +15 -9
  11. package/dist/Cron-DI3nKoic.d.cts.map +1 -0
  12. package/dist/{Cron-dh4rUgib.d.mts → Cron-uYAHPnp7.d.mts} +15 -9
  13. package/dist/Cron-uYAHPnp7.d.mts.map +1 -0
  14. package/dist/{CronBuilder-Da0C0edR.cjs → CronBuilder-BoHzlWU_.cjs} +47 -31
  15. package/dist/CronBuilder-BoHzlWU_.cjs.map +1 -0
  16. package/dist/{CronBuilder-CYKT5RiO.mjs → CronBuilder-CCgt0wCE.mjs} +37 -21
  17. package/dist/CronBuilder-CCgt0wCE.mjs.map +1 -0
  18. package/dist/CronBuilder-DaSUm2Na.d.mts +47 -0
  19. package/dist/CronBuilder-DaSUm2Na.d.mts.map +1 -0
  20. package/dist/CronBuilder-g1lZLWyG.d.cts +47 -0
  21. package/dist/CronBuilder-g1lZLWyG.d.cts.map +1 -0
  22. package/dist/{Endpoint-BjWKinFA.d.mts → Endpoint-Bm9HjTPc.d.cts} +70 -93
  23. package/dist/Endpoint-Bm9HjTPc.d.cts.map +1 -0
  24. package/dist/{Endpoint-DCQPMdUX.mjs → Endpoint-CQ9RJ7p2.mjs} +130 -109
  25. package/dist/Endpoint-CQ9RJ7p2.mjs.map +1 -0
  26. package/dist/{Endpoint-DcWXE-SZ.cjs → Endpoint-DOi8c_Gy.cjs} +158 -131
  27. package/dist/Endpoint-DOi8c_Gy.cjs.map +1 -0
  28. package/dist/{Endpoint-dav89W6-.d.cts → Endpoint-KyMeR-B-.d.mts} +71 -94
  29. package/dist/Endpoint-KyMeR-B-.d.mts.map +1 -0
  30. package/dist/{index-Bd5FqCoe.d.cts → EndpointFactory-B6eZ3RDd.d.cts} +62 -132
  31. package/dist/EndpointFactory-B6eZ3RDd.d.cts.map +1 -0
  32. package/dist/{EndpointFactory-CdWB7wPw.cjs → EndpointFactory-Bo9lkMqB.cjs} +75 -110
  33. package/dist/EndpointFactory-Bo9lkMqB.cjs.map +1 -0
  34. package/dist/{EndpointFactory-CjV8F_lJ.mjs → EndpointFactory-DR1rebok.mjs} +39 -74
  35. package/dist/EndpointFactory-DR1rebok.mjs.map +1 -0
  36. package/dist/{index-lAO9egTb.d.mts → EndpointFactory-GYkAuG3u.d.mts} +63 -133
  37. package/dist/EndpointFactory-GYkAuG3u.d.mts.map +1 -0
  38. package/dist/Function-DuqGcbOI.d.mts +76 -0
  39. package/dist/Function-DuqGcbOI.d.mts.map +1 -0
  40. package/dist/Function-Pu-1kKZz.d.cts +76 -0
  41. package/dist/Function-Pu-1kKZz.d.cts.map +1 -0
  42. package/dist/{HonoEndpointAdaptor-DtL9j19R.cjs → HonoEndpointAdaptor-XyxwoFnE.cjs} +52 -54
  43. package/dist/HonoEndpointAdaptor-XyxwoFnE.cjs.map +1 -0
  44. package/dist/{HonoEndpointAdaptor-P1ahhZHu.mjs → HonoEndpointAdaptor-ja49poBI.mjs} +42 -47
  45. package/dist/HonoEndpointAdaptor-ja49poBI.mjs.map +1 -0
  46. package/dist/Queue-D5jcw0mu.cjs +109 -0
  47. package/dist/Queue-D5jcw0mu.cjs.map +1 -0
  48. package/dist/{Queue-D7ZuwBhy.d.cts → Queue-DlsHRzUp.d.mts} +48 -48
  49. package/dist/Queue-DlsHRzUp.d.mts.map +1 -0
  50. package/dist/{Queue-gVGfi2Yk.d.mts → Queue-HPyi0e1i.d.cts} +49 -49
  51. package/dist/Queue-HPyi0e1i.d.cts.map +1 -0
  52. package/dist/Queue-hwPN-t31.mjs +104 -0
  53. package/dist/Queue-hwPN-t31.mjs.map +1 -0
  54. package/dist/QueueBuilder-BFQn3OzZ.cjs +135 -0
  55. package/dist/QueueBuilder-BFQn3OzZ.cjs.map +1 -0
  56. package/dist/QueueBuilder-DCuYdjMw.mjs +118 -0
  57. package/dist/QueueBuilder-DCuYdjMw.mjs.map +1 -0
  58. package/dist/QueueBuilder-OSi6LkV9.d.cts +75 -0
  59. package/dist/QueueBuilder-OSi6LkV9.d.cts.map +1 -0
  60. package/dist/QueueBuilder-QHsnVt1P.d.mts +75 -0
  61. package/dist/QueueBuilder-QHsnVt1P.d.mts.map +1 -0
  62. package/dist/{Subscriber-2mEi0ImH.d.cts → Subscriber-Bpp02cGr.d.cts} +29 -20
  63. package/dist/Subscriber-Bpp02cGr.d.cts.map +1 -0
  64. package/dist/{Subscriber-xTJ9ayPN.d.mts → Subscriber-CtN9R48-.d.mts} +29 -20
  65. package/dist/Subscriber-CtN9R48-.d.mts.map +1 -0
  66. package/dist/{SubscriberBuilder-4OPehf2R.cjs → SubscriberBuilder-C2PwqwIl.cjs} +61 -36
  67. package/dist/SubscriberBuilder-C2PwqwIl.cjs.map +1 -0
  68. package/dist/SubscriberBuilder-CuCMFpYW.d.mts +67 -0
  69. package/dist/SubscriberBuilder-CuCMFpYW.d.mts.map +1 -0
  70. package/dist/{SubscriberBuilder-BjkbeT9l.mjs → SubscriberBuilder-DMFk_Ap1.mjs} +50 -24
  71. package/dist/SubscriberBuilder-DMFk_Ap1.mjs.map +1 -0
  72. package/dist/SubscriberBuilder-g3fAVWgs.d.cts +67 -0
  73. package/dist/SubscriberBuilder-g3fAVWgs.d.cts.map +1 -0
  74. package/dist/Topic-CkxOTrMv.cjs +104 -0
  75. package/dist/Topic-CkxOTrMv.cjs.map +1 -0
  76. package/dist/Topic-hPffOsot.mjs +99 -0
  77. package/dist/Topic-hPffOsot.mjs.map +1 -0
  78. package/dist/adaptors/aws.cjs +118 -216
  79. package/dist/adaptors/aws.cjs.map +1 -1
  80. package/dist/adaptors/aws.d.cts +34 -53
  81. package/dist/adaptors/aws.d.cts.map +1 -1
  82. package/dist/adaptors/aws.d.mts +35 -54
  83. package/dist/adaptors/aws.d.mts.map +1 -1
  84. package/dist/adaptors/aws.mjs +91 -191
  85. package/dist/adaptors/aws.mjs.map +1 -1
  86. package/dist/adaptors/hono.cjs +3 -10
  87. package/dist/adaptors/hono.d.cts +7 -16
  88. package/dist/adaptors/hono.d.cts.map +1 -1
  89. package/dist/adaptors/hono.d.mts +8 -17
  90. package/dist/adaptors/hono.d.mts.map +1 -1
  91. package/dist/adaptors/hono.mjs +2 -10
  92. package/dist/adaptors/testing.cjs +711 -89
  93. package/dist/adaptors/testing.cjs.map +1 -1
  94. package/dist/adaptors/testing.d.cts +325 -54
  95. package/dist/adaptors/testing.d.cts.map +1 -1
  96. package/dist/adaptors/testing.d.mts +325 -54
  97. package/dist/adaptors/testing.d.mts.map +1 -1
  98. package/dist/adaptors/testing.mjs +676 -70
  99. package/dist/adaptors/testing.mjs.map +1 -1
  100. package/dist/auth-CIFXNuDk.d.cts +194 -0
  101. package/dist/auth-CIFXNuDk.d.cts.map +1 -0
  102. package/dist/auth-CJ9Ff6Lu.d.mts +194 -0
  103. package/dist/auth-CJ9Ff6Lu.d.mts.map +1 -0
  104. package/dist/auth.cjs +172 -31
  105. package/dist/auth.cjs.map +1 -1
  106. package/dist/auth.d.cts +2 -108
  107. package/dist/auth.d.mts +2 -108
  108. package/dist/auth.mjs +161 -24
  109. package/dist/auth.mjs.map +1 -1
  110. package/dist/{cache-BrRz3fEB.d.mts → cache-CXh6GIgb.d.mts} +3 -6
  111. package/dist/cache-CXh6GIgb.d.mts.map +1 -0
  112. package/dist/{cache-BtZY_tHe.d.cts → cache-DnGDGly3.d.cts} +3 -6
  113. package/dist/cache-DnGDGly3.d.cts.map +1 -0
  114. package/dist/cache.cjs +68 -2
  115. package/dist/cache.cjs.map +1 -0
  116. package/dist/cache.d.cts +1 -2
  117. package/dist/cache.d.mts +1 -2
  118. package/dist/cache.mjs +67 -2
  119. package/dist/cache.mjs.map +1 -0
  120. package/dist/cipher-C1lEFX63.mjs +225 -0
  121. package/dist/cipher-C1lEFX63.mjs.map +1 -0
  122. package/dist/cipher-CVxfwLjk.cjs +332 -0
  123. package/dist/cipher-CVxfwLjk.cjs.map +1 -0
  124. package/dist/{clone-DblgEZZa.mjs → clone-EKNovYHu.mjs} +3 -3
  125. package/dist/clone-EKNovYHu.mjs.map +1 -0
  126. package/dist/{clone-Dy0cR2SZ.cjs → clone-UGJpvQnL.cjs} +7 -8
  127. package/dist/clone-UGJpvQnL.cjs.map +1 -0
  128. package/dist/{construct-interface-D9d4Gm4p.d.cts → construct-interface-B1AfqRl4.d.cts} +42 -11
  129. package/dist/construct-interface-B1AfqRl4.d.cts.map +1 -0
  130. package/dist/{construct-interface-g5GM5pwR.d.mts → construct-interface-DluK3_da.d.mts} +42 -11
  131. package/dist/construct-interface-DluK3_da.d.mts.map +1 -0
  132. package/dist/construct-interface.cjs +113 -7
  133. package/dist/construct-interface.cjs.map +1 -0
  134. package/dist/construct-interface.d.cts +2 -2
  135. package/dist/construct-interface.d.mts +2 -2
  136. package/dist/construct-interface.mjs +106 -2
  137. package/dist/construct-interface.mjs.map +1 -0
  138. package/dist/credential.cjs +63 -16
  139. package/dist/credential.cjs.map +1 -1
  140. package/dist/credential.d.cts +16 -9
  141. package/dist/credential.d.cts.map +1 -1
  142. package/dist/credential.d.mts +16 -9
  143. package/dist/credential.d.mts.map +1 -1
  144. package/dist/credential.mjs +58 -12
  145. package/dist/credential.mjs.map +1 -1
  146. package/dist/crons/index.cjs +105 -7
  147. package/dist/crons/index.cjs.map +1 -1
  148. package/dist/crons/index.d.cts +40 -11
  149. package/dist/crons/index.d.cts.map +1 -1
  150. package/dist/crons/index.d.mts +40 -11
  151. package/dist/crons/index.d.mts.map +1 -1
  152. package/dist/crons/index.mjs +103 -8
  153. package/dist/crons/index.mjs.map +1 -1
  154. package/dist/database/kysely.cjs +4 -181
  155. package/dist/database/kysely.d.cts +2 -152
  156. package/dist/database/kysely.d.mts +2 -152
  157. package/dist/database/kysely.mjs +2 -180
  158. package/dist/email.cjs +25 -12
  159. package/dist/email.cjs.map +1 -1
  160. package/dist/email.d.cts +3 -7
  161. package/dist/email.d.cts.map +1 -1
  162. package/dist/email.d.mts +3 -7
  163. package/dist/email.d.mts.map +1 -1
  164. package/dist/email.mjs +16 -3
  165. package/dist/email.mjs.map +1 -1
  166. package/dist/encryption.cjs +96 -0
  167. package/dist/encryption.cjs.map +1 -0
  168. package/dist/encryption.d.cts +117 -0
  169. package/dist/encryption.d.cts.map +1 -0
  170. package/dist/encryption.d.mts +117 -0
  171. package/dist/encryption.d.mts.map +1 -0
  172. package/dist/encryption.mjs +83 -0
  173. package/dist/encryption.mjs.map +1 -0
  174. package/dist/endpoints/index.cjs +8 -10
  175. package/dist/endpoints/index.d.cts +51 -7
  176. package/dist/endpoints/index.d.cts.map +1 -0
  177. package/dist/endpoints/index.d.mts +51 -7
  178. package/dist/endpoints/index.d.mts.map +1 -0
  179. package/dist/endpoints/index.mjs +6 -10
  180. package/dist/external-api-CWY9orcO.d.mts +86 -0
  181. package/dist/external-api-CWY9orcO.d.mts.map +1 -0
  182. package/dist/external-api-D-5WB-sr.d.cts +86 -0
  183. package/dist/external-api-D-5WB-sr.d.cts.map +1 -0
  184. package/dist/external-api.cjs +124 -0
  185. package/dist/external-api.cjs.map +1 -0
  186. package/dist/external-api.d.cts +2 -0
  187. package/dist/external-api.d.mts +2 -0
  188. package/dist/external-api.mjs +121 -0
  189. package/dist/external-api.mjs.map +1 -0
  190. package/dist/file-server.cjs +42 -10
  191. package/dist/file-server.cjs.map +1 -1
  192. package/dist/file-server.d.cts +6 -10
  193. package/dist/file-server.d.cts.map +1 -1
  194. package/dist/file-server.d.mts +6 -10
  195. package/dist/file-server.d.mts.map +1 -1
  196. package/dist/file-server.mjs +34 -2
  197. package/dist/file-server.mjs.map +1 -1
  198. package/dist/functions/index.cjs +3 -6
  199. package/dist/functions/index.d.cts +3 -4
  200. package/dist/functions/index.d.mts +3 -4
  201. package/dist/functions/index.mjs +2 -6
  202. package/dist/{functions-i_la-N5r.cjs → functions-CbP5ZKma.cjs} +414 -264
  203. package/dist/functions-CbP5ZKma.cjs.map +1 -0
  204. package/dist/{functions-14lpEFL4.mjs → functions-Di6n5ltG.mjs} +376 -238
  205. package/dist/{functions-14lpEFL4.mjs.map → functions-Di6n5ltG.mjs.map} +1 -1
  206. package/dist/index-BuzRvKOQ.d.cts +115 -0
  207. package/dist/index-BuzRvKOQ.d.cts.map +1 -0
  208. package/dist/index-CTkKOer4.d.mts +115 -0
  209. package/dist/index-CTkKOer4.d.mts.map +1 -0
  210. package/dist/index-CeEtxDmK.d.cts +79 -0
  211. package/dist/index-CeEtxDmK.d.cts.map +1 -0
  212. package/dist/index-CeEtxDmK.d.mts +79 -0
  213. package/dist/index-CeEtxDmK.d.mts.map +1 -0
  214. package/dist/index.cjs +6 -3
  215. package/dist/index.d.cts +26 -4
  216. package/dist/index.d.cts.map +1 -0
  217. package/dist/index.d.mts +26 -4
  218. package/dist/index.d.mts.map +1 -0
  219. package/dist/index.mjs +3 -3
  220. package/dist/kms-B-Hm3d5r.cjs +85 -0
  221. package/dist/kms-B-Hm3d5r.cjs.map +1 -0
  222. package/dist/kms-BdUlMJEZ.mjs +85 -0
  223. package/dist/kms-BdUlMJEZ.mjs.map +1 -0
  224. package/dist/kysely-BEm5sDlU.d.cts +173 -0
  225. package/dist/kysely-BEm5sDlU.d.cts.map +1 -0
  226. package/dist/kysely-BRzzawr2.cjs +301 -0
  227. package/dist/kysely-BRzzawr2.cjs.map +1 -0
  228. package/dist/kysely-BYfM6Zby.mjs +288 -0
  229. package/dist/kysely-BYfM6Zby.mjs.map +1 -0
  230. package/dist/kysely-CjuvdXEV.d.mts +173 -0
  231. package/dist/kysely-CjuvdXEV.d.mts.map +1 -0
  232. package/dist/{lazyAccessors-BoJN3SMd.mjs → lazyAccessors-CFanua0O.mjs} +20 -60
  233. package/dist/lazyAccessors-CFanua0O.mjs.map +1 -0
  234. package/dist/{lazyAccessors-e3j2oE2m.cjs → lazyAccessors-hJKGv8Ay.cjs} +60 -113
  235. package/dist/lazyAccessors-hJKGv8Ay.cjs.map +1 -0
  236. package/dist/mobile-app.cjs +73 -0
  237. package/dist/mobile-app.cjs.map +1 -0
  238. package/dist/mobile-app.d.cts +61 -0
  239. package/dist/mobile-app.d.cts.map +1 -0
  240. package/dist/mobile-app.d.mts +61 -0
  241. package/dist/mobile-app.d.mts.map +1 -0
  242. package/dist/mobile-app.mjs +72 -0
  243. package/dist/mobile-app.mjs.map +1 -0
  244. package/dist/object-storage.cjs +18 -10
  245. package/dist/object-storage.cjs.map +1 -1
  246. package/dist/object-storage.d.cts +3 -7
  247. package/dist/object-storage.d.cts.map +1 -1
  248. package/dist/object-storage.d.mts +3 -7
  249. package/dist/object-storage.d.mts.map +1 -1
  250. package/dist/object-storage.mjs +11 -3
  251. package/dist/object-storage.mjs.map +1 -1
  252. package/dist/{processAudits-Dmts9H_b.mjs → processAudits-BpRlPQMW.mjs} +16 -19
  253. package/dist/processAudits-BpRlPQMW.mjs.map +1 -0
  254. package/dist/{processAudits-CGqttuXm.cjs → processAudits-D_2W5x8k.cjs} +26 -30
  255. package/dist/processAudits-D_2W5x8k.cjs.map +1 -0
  256. package/dist/queue/index.cjs +6 -189
  257. package/dist/queue/index.d.cts +3 -60
  258. package/dist/queue/index.d.mts +3 -60
  259. package/dist/queue/index.mjs +3 -186
  260. package/dist/rest-api.cjs +88 -63
  261. package/dist/rest-api.cjs.map +1 -1
  262. package/dist/rest-api.d.cts +68 -61
  263. package/dist/rest-api.d.cts.map +1 -1
  264. package/dist/rest-api.d.mts +68 -61
  265. package/dist/rest-api.d.mts.map +1 -1
  266. package/dist/rest-api.mjs +80 -55
  267. package/dist/rest-api.mjs.map +1 -1
  268. package/dist/{chunk-DWy1uDak.cjs → rolldown-runtime-y5ARvAq5.cjs} +14 -18
  269. package/dist/runSubscriber-BRp9a_qi.cjs +126 -0
  270. package/dist/runSubscriber-BRp9a_qi.cjs.map +1 -0
  271. package/dist/runSubscriber-BYEY_bfA.mjs +109 -0
  272. package/dist/runSubscriber-BYEY_bfA.mjs.map +1 -0
  273. package/dist/shutdown-BMJmAhSt.cjs +38 -0
  274. package/dist/shutdown-BMJmAhSt.cjs.map +1 -0
  275. package/dist/shutdown-C7xa8x9S.mjs +27 -0
  276. package/dist/shutdown-C7xa8x9S.mjs.map +1 -0
  277. package/dist/site.cjs +34 -9
  278. package/dist/site.cjs.map +1 -1
  279. package/dist/site.d.cts +17 -22
  280. package/dist/site.d.cts.map +1 -1
  281. package/dist/site.d.mts +17 -22
  282. package/dist/site.d.mts.map +1 -1
  283. package/dist/site.mjs +30 -5
  284. package/dist/site.mjs.map +1 -1
  285. package/dist/subscribers/index.cjs +111 -6
  286. package/dist/subscribers/index.cjs.map +1 -0
  287. package/dist/subscribers/index.d.cts +50 -6
  288. package/dist/subscribers/index.d.cts.map +1 -0
  289. package/dist/subscribers/index.d.mts +50 -6
  290. package/dist/subscribers/index.d.mts.map +1 -0
  291. package/dist/subscribers/index.mjs +108 -5
  292. package/dist/subscribers/index.mjs.map +1 -0
  293. package/dist/surfaceEnv-CNimK76p.cjs +56 -0
  294. package/dist/surfaceEnv-CNimK76p.cjs.map +1 -0
  295. package/dist/surfaceEnv-wMT5QzgZ.mjs +45 -0
  296. package/dist/surfaceEnv-wMT5QzgZ.mjs.map +1 -0
  297. package/dist/{telemetry-C3L0iS28.d.cts → telemetry-DGcFlVpB.d.cts} +2 -5
  298. package/dist/telemetry-DGcFlVpB.d.cts.map +1 -0
  299. package/dist/{telemetry-D7bVFLGi.d.mts → telemetry-DGcFlVpB.d.mts} +2 -5
  300. package/dist/telemetry-DGcFlVpB.d.mts.map +1 -0
  301. package/dist/topic/index.cjs +3 -137
  302. package/dist/topic/index.d.cts +2 -4
  303. package/dist/topic/index.d.mts +2 -4
  304. package/dist/topic/index.mjs +2 -134
  305. package/dist/{types-BlAkSuGI.d.cts → types-DMuSQeLL.d.cts} +3 -5
  306. package/dist/types-DMuSQeLL.d.cts.map +1 -0
  307. package/dist/{types-aKksMEWL.d.mts → types-DMuSQeLL.d.mts} +3 -5
  308. package/dist/types-DMuSQeLL.d.mts.map +1 -0
  309. package/dist/types.d.cts +1 -1
  310. package/dist/types.d.mts +1 -1
  311. package/dist/types.mjs +1 -0
  312. package/dist/worker.cjs +58 -34
  313. package/dist/worker.cjs.map +1 -1
  314. package/dist/worker.d.cts +63 -45
  315. package/dist/worker.d.cts.map +1 -1
  316. package/dist/worker.d.mts +63 -44
  317. package/dist/worker.d.mts.map +1 -1
  318. package/dist/worker.mjs +53 -29
  319. package/dist/worker.mjs.map +1 -1
  320. package/package.json +82 -41
  321. package/dist/Construct-BD5neF7w.mjs.map +0 -1
  322. package/dist/Construct-C0ijr2qp.d.cts +0 -117
  323. package/dist/Construct-C0ijr2qp.d.cts.map +0 -1
  324. package/dist/Construct-Ct8nalEi.d.mts +0 -117
  325. package/dist/Construct-Ct8nalEi.d.mts.map +0 -1
  326. package/dist/Construct-CyS3RpTL.cjs.map +0 -1
  327. package/dist/Cron-DmQ8vQ4b.d.cts.map +0 -1
  328. package/dist/Cron-dh4rUgib.d.mts.map +0 -1
  329. package/dist/CronBuilder-BquXDbDI.d.cts +0 -44
  330. package/dist/CronBuilder-BquXDbDI.d.cts.map +0 -1
  331. package/dist/CronBuilder-CGgY2080.d.mts +0 -44
  332. package/dist/CronBuilder-CGgY2080.d.mts.map +0 -1
  333. package/dist/CronBuilder-CYKT5RiO.mjs.map +0 -1
  334. package/dist/CronBuilder-Da0C0edR.cjs.map +0 -1
  335. package/dist/Endpoint-BjWKinFA.d.mts.map +0 -1
  336. package/dist/Endpoint-DCQPMdUX.mjs.map +0 -1
  337. package/dist/Endpoint-DcWXE-SZ.cjs.map +0 -1
  338. package/dist/Endpoint-dav89W6-.d.cts.map +0 -1
  339. package/dist/EndpointFactory-CdWB7wPw.cjs.map +0 -1
  340. package/dist/EndpointFactory-CjV8F_lJ.mjs.map +0 -1
  341. package/dist/HonoEndpointAdaptor-DtL9j19R.cjs.map +0 -1
  342. package/dist/HonoEndpointAdaptor-P1ahhZHu.mjs.map +0 -1
  343. package/dist/Queue-D7ZuwBhy.d.cts.map +0 -1
  344. package/dist/Queue-gVGfi2Yk.d.mts.map +0 -1
  345. package/dist/Subscriber-2mEi0ImH.d.cts.map +0 -1
  346. package/dist/Subscriber-xTJ9ayPN.d.mts.map +0 -1
  347. package/dist/SubscriberBuilder-4OPehf2R.cjs.map +0 -1
  348. package/dist/SubscriberBuilder-BjkbeT9l.mjs.map +0 -1
  349. package/dist/SubscriberBuilder-Dptmo-1A.d.mts +0 -62
  350. package/dist/SubscriberBuilder-Dptmo-1A.d.mts.map +0 -1
  351. package/dist/SubscriberBuilder-waNhzjSM.d.cts +0 -62
  352. package/dist/SubscriberBuilder-waNhzjSM.d.cts.map +0 -1
  353. package/dist/Topic-19QeHBIR.d.cts +0 -91
  354. package/dist/Topic-19QeHBIR.d.cts.map +0 -1
  355. package/dist/Topic-DuFeqkBh.d.mts +0 -91
  356. package/dist/Topic-DuFeqkBh.d.mts.map +0 -1
  357. package/dist/auth.d.cts.map +0 -1
  358. package/dist/auth.d.mts.map +0 -1
  359. package/dist/cache-0ANvRQnD.mjs +0 -51
  360. package/dist/cache-0ANvRQnD.mjs.map +0 -1
  361. package/dist/cache-3WSvAulx.cjs +0 -57
  362. package/dist/cache-3WSvAulx.cjs.map +0 -1
  363. package/dist/cache-BrRz3fEB.d.mts.map +0 -1
  364. package/dist/cache-BtZY_tHe.d.cts.map +0 -1
  365. package/dist/clone-DblgEZZa.mjs.map +0 -1
  366. package/dist/clone-Dy0cR2SZ.cjs.map +0 -1
  367. package/dist/construct-interface-BfjcOD_E.cjs +0 -117
  368. package/dist/construct-interface-BfjcOD_E.cjs.map +0 -1
  369. package/dist/construct-interface-D9d4Gm4p.d.cts.map +0 -1
  370. package/dist/construct-interface-Z4CpS8tK.mjs +0 -81
  371. package/dist/construct-interface-Z4CpS8tK.mjs.map +0 -1
  372. package/dist/construct-interface-g5GM5pwR.d.mts.map +0 -1
  373. package/dist/database/kysely.cjs.map +0 -1
  374. package/dist/database/kysely.d.cts.map +0 -1
  375. package/dist/database/kysely.d.mts.map +0 -1
  376. package/dist/database/kysely.mjs.map +0 -1
  377. package/dist/functions-i_la-N5r.cjs.map +0 -1
  378. package/dist/index-Bd5FqCoe.d.cts.map +0 -1
  379. package/dist/index-BknhM6Ux.d.mts +0 -31
  380. package/dist/index-BknhM6Ux.d.mts.map +0 -1
  381. package/dist/index-CBSfrowv.d.cts +0 -31
  382. package/dist/index-CBSfrowv.d.cts.map +0 -1
  383. package/dist/index-D24Xm79M.d.cts +0 -171
  384. package/dist/index-D24Xm79M.d.cts.map +0 -1
  385. package/dist/index-_ajboYxK.d.mts +0 -171
  386. package/dist/index-_ajboYxK.d.mts.map +0 -1
  387. package/dist/index-lAO9egTb.d.mts.map +0 -1
  388. package/dist/lazyAccessors-BoJN3SMd.mjs.map +0 -1
  389. package/dist/lazyAccessors-e3j2oE2m.cjs.map +0 -1
  390. package/dist/processAudits-CGqttuXm.cjs.map +0 -1
  391. package/dist/processAudits-Dmts9H_b.mjs.map +0 -1
  392. package/dist/queue/index.cjs.map +0 -1
  393. package/dist/queue/index.d.cts.map +0 -1
  394. package/dist/queue/index.d.mts.map +0 -1
  395. package/dist/queue/index.mjs.map +0 -1
  396. package/dist/surfaceEnv-BFXEms2f.cjs +0 -39
  397. package/dist/surfaceEnv-BFXEms2f.cjs.map +0 -1
  398. package/dist/surfaceEnv-C3Ktahea.mjs +0 -27
  399. package/dist/surfaceEnv-C3Ktahea.mjs.map +0 -1
  400. package/dist/telemetry-C3L0iS28.d.cts.map +0 -1
  401. package/dist/telemetry-D7bVFLGi.d.mts.map +0 -1
  402. package/dist/topic/index.cjs.map +0 -1
  403. package/dist/topic/index.mjs.map +0 -1
  404. package/dist/types-BlAkSuGI.d.cts.map +0 -1
  405. package/dist/types-aKksMEWL.d.mts.map +0 -1
@@ -1,26 +1,36 @@
1
- const require_chunk = require('../chunk-DWy1uDak.cjs');
2
- require('../construct-interface-BfjcOD_E.cjs');
3
- require('../Construct-CyS3RpTL.cjs');
4
- const require_functions = require('../functions-i_la-N5r.cjs');
5
- require('../clone-Dy0cR2SZ.cjs');
6
- const require_Endpoint = require('../Endpoint-DcWXE-SZ.cjs');
7
- const require_lazyAccessors = require('../lazyAccessors-e3j2oE2m.cjs');
8
- const require_processAudits = require('../processAudits-CGqttuXm.cjs');
9
- const require_HonoEndpointAdaptor = require('../HonoEndpointAdaptor-DtL9j19R.cjs');
10
- const __geekmidas_errors = require_chunk.__toESM(require("@geekmidas/errors"));
11
- const __geekmidas_envkit = require_chunk.__toESM(require("@geekmidas/envkit"));
12
- const __geekmidas_services = require_chunk.__toESM(require("@geekmidas/services"));
13
- const __geekmidas_audit = require_chunk.__toESM(require("@geekmidas/audit"));
14
- const hono = require_chunk.__toESM(require("hono"));
15
- const msw = require_chunk.__toESM(require("msw"));
16
-
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_rolldown_runtime = require("../rolldown-runtime-y5ARvAq5.cjs");
3
+ const require_construct_interface = require("../construct-interface.cjs");
4
+ const require_auth = require("../auth.cjs");
5
+ const require_functions = require("../functions-CbP5ZKma.cjs");
6
+ const require_Endpoint = require("../Endpoint-DOi8c_Gy.cjs");
7
+ const require_Queue = require("../Queue-D5jcw0mu.cjs");
8
+ const require_email = require("../email.cjs");
9
+ const require_kysely = require("../kysely-BRzzawr2.cjs");
10
+ const require_lazyAccessors = require("../lazyAccessors-hJKGv8Ay.cjs");
11
+ const require_Topic = require("../Topic-CkxOTrMv.cjs");
12
+ const require_HonoEndpointAdaptor = require("../HonoEndpointAdaptor-XyxwoFnE.cjs");
13
+ const require_processAudits = require("../processAudits-D_2W5x8k.cjs");
14
+ let _geekmidas_manifest = require("@geekmidas/manifest");
15
+ let node_crypto = require("node:crypto");
16
+ let _geekmidas_errors = require("@geekmidas/errors");
17
+ let _geekmidas_envkit = require("@geekmidas/envkit");
18
+ let _geekmidas_services = require("@geekmidas/services");
19
+ let hono = require("hono");
20
+ let _geekmidas_audit = require("@geekmidas/audit");
21
+ let _geekmidas_testkit_context = require("@geekmidas/testkit/context");
22
+ let msw = require("msw");
23
+ let _geekmidas_testkit_browser = require("@geekmidas/testkit/browser");
24
+ let _geekmidas_testkit_faker = require("@geekmidas/testkit/faker");
25
+ let _geekmidas_testkit_mailbox = require("@geekmidas/testkit/mailbox");
26
+ let _geekmidas_testkit_transactions = require("@geekmidas/testkit/transactions");
27
+ let msw_node = require("msw/node");
28
+ let vitest = require("vitest");
29
+ let node_fs = require("node:fs");
30
+ let node_tls = require("node:tls");
31
+ node_tls = require_rolldown_runtime.__toESM(node_tls, 1);
32
+ let node_url = require("node:url");
17
33
  //#region src/endpoints/MswEndpointAdaptor.ts
18
- /**
19
- * Header used to identify which test context a request belongs to.
20
- * Each concurrent test registers its own context (services, db transaction, etc.)
21
- * and the MSW handler looks it up by this header value.
22
- */
23
- const TEST_CONTEXT_HEADER = "x-test-context-id";
24
34
  const MSW_HTTP_METHODS = [
25
35
  "get",
26
36
  "post",
@@ -52,8 +62,8 @@ function createMswHandlers(endpoints, options) {
52
62
  * Creates a fresh ServiceDiscovery and pre-registers all provided services.
53
63
  */
54
64
  function registerContext(id, ctxOptions) {
55
- const envParser = new __geekmidas_envkit.EnvironmentParser({});
56
- const serviceDiscovery = new __geekmidas_services.ServiceDiscovery(envParser);
65
+ const envParser = new _geekmidas_envkit.EnvironmentParser({});
66
+ const serviceDiscovery = new _geekmidas_services.ServiceDiscovery(envParser);
57
67
  const serviceDefs = [];
58
68
  if (ctxOptions.services) for (const [name, instance] of Object.entries(ctxOptions.services)) serviceDefs.push({
59
69
  serviceName: name,
@@ -68,7 +78,6 @@ function createMswHandlers(endpoints, options) {
68
78
  break;
69
79
  }
70
80
  }
71
- if (ctxOptions.publisher) serviceDefs.push(ctxOptions.publisher);
72
81
  if (ctxOptions.auditorStorage !== void 0) {
73
82
  for (const endpoint of endpoints) if (endpoint.auditorStorageService) {
74
83
  serviceDefs.push({
@@ -88,11 +97,11 @@ function createMswHandlers(endpoints, options) {
88
97
  const mswUrl = `${baseURL}${endpoint.route}`;
89
98
  const mswMethod = msw.http[method];
90
99
  handlers.push(mswMethod(mswUrl, async ({ request }) => {
91
- const contextId = request.headers.get(TEST_CONTEXT_HEADER);
100
+ const contextId = request.headers.get(_geekmidas_testkit_context.TEST_CONTEXT_HEADER);
92
101
  const ctx = contextId ? contexts.get(contextId) : void 0;
93
102
  if (!ctx) return new Response(JSON.stringify({
94
103
  error: "Missing or unknown test context ID",
95
- hint: `Set the '${TEST_CONTEXT_HEADER}' header to a registered context ID`
104
+ hint: `Set the '${_geekmidas_testkit_context.TEST_CONTEXT_HEADER}' header to a registered context ID`
96
105
  }), {
97
106
  status: 500,
98
107
  headers: { "content-type": "application/json" }
@@ -112,7 +121,6 @@ function createMswHandlers(endpoints, options) {
112
121
  registerContext
113
122
  };
114
123
  }
115
-
116
124
  //#endregion
117
125
  //#region src/endpoints/TestEndpointAdaptor.ts
118
126
  /**
@@ -132,8 +140,10 @@ function serializeCookie(name, value, options) {
132
140
  return cookieString;
133
141
  }
134
142
  var TestEndpointAdaptor = class TestEndpointAdaptor {
143
+ endpoint;
144
+ serviceDiscovery;
135
145
  static getDefaultServiceDiscover(_endpoint) {
136
- return __geekmidas_services.ServiceDiscovery.getInstance(new __geekmidas_envkit.EnvironmentParser({}));
146
+ return _geekmidas_services.ServiceDiscovery.getInstance(new _geekmidas_envkit.EnvironmentParser({}));
137
147
  }
138
148
  constructor(endpoint, serviceDiscovery = TestEndpointAdaptor.getDefaultServiceDiscover(endpoint)) {
139
149
  this.endpoint = endpoint;
@@ -154,10 +164,12 @@ var TestEndpointAdaptor = class TestEndpointAdaptor {
154
164
  method: this.endpoint.method
155
165
  });
156
166
  const rawDb = ctx.database;
157
- return (0, __geekmidas_services.runWithRequestContext)({
167
+ const operation = `${this.endpoint.method} ${this.endpoint.route}`;
168
+ return (0, _geekmidas_services.runWithRequestContext)({
158
169
  logger,
159
170
  requestId,
160
- startTime
171
+ startTime,
172
+ operation
161
173
  }, async () => {
162
174
  const session = await this.endpoint.getSession({
163
175
  logger,
@@ -166,7 +178,7 @@ var TestEndpointAdaptor = class TestEndpointAdaptor {
166
178
  cookie,
167
179
  ...rawDb !== void 0 && { db: rawDb }
168
180
  });
169
- const isAuthorized = await this.endpoint.authorize({
181
+ if (!await this.endpoint.authorize({
170
182
  header,
171
183
  cookie,
172
184
  services: ctx.services,
@@ -176,10 +188,9 @@ var TestEndpointAdaptor = class TestEndpointAdaptor {
176
188
  body,
177
189
  query,
178
190
  params
179
- });
180
- if (!isAuthorized) {
191
+ })) {
181
192
  logger.warn("Forbidden access attempt");
182
- throw new __geekmidas_errors.ForbiddenError("Forbidden access to the endpoint", "You do not have permission to access this resource.");
193
+ throw new _geekmidas_errors.ForbiddenError("Forbidden access to the endpoint", "You do not have permission to access this resource.");
183
194
  }
184
195
  const auditorStorage = ctx.auditorStorage;
185
196
  let auditContext;
@@ -199,24 +210,22 @@ var TestEndpointAdaptor = class TestEndpointAdaptor {
199
210
  } catch (error) {
200
211
  logger.error(error, "Failed to extract actor for audits");
201
212
  }
202
- const auditor = new __geekmidas_audit.DefaultAuditor({
203
- actor,
204
- storage: auditorStorage,
205
- metadata: {
206
- endpoint: this.endpoint.route,
207
- method: this.endpoint.method
208
- }
209
- });
210
213
  auditContext = {
211
- auditor,
214
+ auditor: new _geekmidas_audit.DefaultAuditor({
215
+ actor,
216
+ storage: auditorStorage,
217
+ metadata: {
218
+ endpoint: this.endpoint.route,
219
+ method: this.endpoint.method
220
+ }
221
+ }),
212
222
  storage: auditorStorage
213
223
  };
214
224
  }
215
225
  const audits = this.endpoint.audits;
216
226
  if (!auditContext && audits?.length) logger.warn("No auditor storage service available");
217
- const result = await require_processAudits.executeWithAuditTransaction(auditContext, async (auditor) => {
218
- const trx = auditor?.getTransaction?.();
219
- const db = trx ?? rawDb;
227
+ const { output, metadata } = await require_processAudits.executeWithAuditTransaction(auditContext, async (auditor) => {
228
+ const db = auditor?.getTransaction?.() ?? rawDb;
220
229
  const responseBuilder = new require_Endpoint.ResponseBuilder();
221
230
  const response = await this.endpoint.handler({
222
231
  body,
@@ -231,36 +240,33 @@ var TestEndpointAdaptor = class TestEndpointAdaptor {
231
240
  db
232
241
  }, responseBuilder);
233
242
  let data = response;
234
- let metadata$1 = responseBuilder.getMetadata();
243
+ let metadata = responseBuilder.getMetadata();
235
244
  if (require_Endpoint.Endpoint.hasMetadata(response)) {
236
245
  data = response.data;
237
- metadata$1 = response.metadata;
246
+ metadata = response.metadata;
238
247
  }
239
- const output$1 = await this.endpoint.parseOutput(data);
240
248
  return {
241
- output: output$1,
242
- metadata: metadata$1,
249
+ output: await this.endpoint.parseOutput(data),
250
+ metadata,
243
251
  responseBuilder
244
252
  };
245
- }, async (result$1, auditor) => {
253
+ }, async (result, auditor) => {
246
254
  if (!audits?.length) return;
247
255
  for (const audit of audits) {
248
- if (audit.when && !audit.when(result$1.output)) continue;
249
- const payload = audit.payload(result$1.output);
250
- const entityId = audit.entityId?.(result$1.output);
256
+ if (audit.when && !audit.when(result.output)) continue;
257
+ const payload = audit.payload(result.output);
258
+ const entityId = audit.entityId?.(result.output);
251
259
  auditor.audit(audit.type, payload, {
252
260
  table: audit.table,
253
261
  entityId
254
262
  });
255
263
  }
256
264
  }, { db: rawDb });
257
- const { output, metadata } = result;
258
- ctx.publisher && await this.serviceDiscovery.register([ctx.publisher]);
259
- await require_lazyAccessors.publishConstructEvents(this.endpoint, output, this.serviceDiscovery);
265
+ await require_functions.publishConstructEvents(this.endpoint, output, this.serviceDiscovery, this.endpoint.logger, ctx.services);
260
266
  const headers = { ...metadata.headers || {} };
261
267
  if (metadata.cookies && metadata.cookies.size > 0) {
262
268
  const setCookieValues = [];
263
- for (const [name, cookie$1] of metadata.cookies.entries()) setCookieValues.push(serializeCookie(name, cookie$1.value, cookie$1.options));
269
+ for (const [name, cookie] of metadata.cookies.entries()) setCookieValues.push(serializeCookie(name, cookie.value, cookie.options));
264
270
  headers["set-cookie"] = setCookieValues;
265
271
  }
266
272
  return {
@@ -271,16 +277,16 @@ var TestEndpointAdaptor = class TestEndpointAdaptor {
271
277
  });
272
278
  }
273
279
  async request(ctx) {
274
- const response = await this.fullRequest(ctx);
275
- return response.body;
280
+ return (await this.fullRequest(ctx)).body;
276
281
  }
277
282
  };
278
-
279
283
  //#endregion
280
284
  //#region src/functions/TestFunctionAdaptor.ts
281
285
  var TestFunctionAdaptor = class TestFunctionAdaptor {
286
+ fn;
287
+ serviceDiscovery;
282
288
  static getDefaultServiceDiscovery(_fn) {
283
- return __geekmidas_services.ServiceDiscovery.getInstance(new __geekmidas_envkit.EnvironmentParser({}));
289
+ return _geekmidas_services.ServiceDiscovery.getInstance(new _geekmidas_envkit.EnvironmentParser({}));
284
290
  }
285
291
  constructor(fn, serviceDiscovery = TestFunctionAdaptor.getDefaultServiceDiscovery(fn)) {
286
292
  this.fn = fn;
@@ -294,16 +300,12 @@ var TestFunctionAdaptor = class TestFunctionAdaptor {
294
300
  else services = await this.serviceDiscovery.register(this.fn.services);
295
301
  let db;
296
302
  if ("db" in ctx && ctx.db !== void 0) db = ctx.db;
297
- else if (this.fn.databaseService) {
298
- const dbServices = await this.serviceDiscovery.register([this.fn.databaseService]);
299
- db = dbServices[this.fn.databaseService.serviceName];
300
- }
303
+ else if (this.fn.databaseService) db = (await this.serviceDiscovery.register([this.fn.databaseService]))[this.fn.databaseService.serviceName];
301
304
  let auditor;
302
305
  if ("auditor" in ctx && ctx.auditor !== void 0) auditor = ctx.auditor;
303
306
  else if (this.fn.auditorStorageService) {
304
- const auditServices = await this.serviceDiscovery.register([this.fn.auditorStorageService]);
305
- const storage = auditServices[this.fn.auditorStorageService.serviceName];
306
- auditor = new __geekmidas_audit.DefaultAuditor({
307
+ const storage = (await this.serviceDiscovery.register([this.fn.auditorStorageService]))[this.fn.auditorStorageService.serviceName];
308
+ auditor = new _geekmidas_audit.DefaultAuditor({
307
309
  actor: {
308
310
  id: "system",
309
311
  type: "system"
@@ -316,11 +318,10 @@ var TestFunctionAdaptor = class TestFunctionAdaptor {
316
318
  });
317
319
  }
318
320
  const requestId = `test-${Date.now()}`;
319
- const startTime = Date.now();
320
- return (0, __geekmidas_services.runWithRequestContext)({
321
+ return (0, _geekmidas_services.runWithRequestContext)({
321
322
  logger,
322
323
  requestId,
323
- startTime
324
+ startTime: Date.now()
324
325
  }, async () => {
325
326
  const response = await this.fn.fn({
326
327
  input: parsedInput,
@@ -337,26 +338,28 @@ var TestFunctionAdaptor = class TestFunctionAdaptor {
337
338
  await auditor.flush();
338
339
  }
339
340
  }
340
- await require_lazyAccessors.publishEvents(logger, this.serviceDiscovery, this.fn.events, output, this.fn.publisherService);
341
+ await require_functions.publishEvents(logger, this.serviceDiscovery, this.fn.events, output, services);
341
342
  return output;
342
343
  });
343
344
  }
344
345
  };
345
-
346
346
  //#endregion
347
347
  //#region src/queue/TestQueueAdaptor.ts
348
348
  /**
349
349
  * In-memory test driver for a {@link Queue} worker. Hand it a batch of messages
350
350
  * and it registers the queue's services, runs the handler in a request context,
351
- * and returns the handler result — no SQS/pg-boss required.
351
+ * and returns the handler result — no SQS/pg-boss required. A queue with a
352
+ * database gets `db` registered from it, or the one the request passes.
352
353
  *
353
354
  * @example
354
355
  * const adapter = new TestQueueAdaptor(ordersQueue);
355
356
  * await adapter.invoke({ messages: [{ orderId: '123' }] });
356
357
  */
357
358
  var TestQueueAdaptor = class TestQueueAdaptor {
359
+ queue;
360
+ serviceDiscovery;
358
361
  static getDefaultServiceDiscovery() {
359
- return __geekmidas_services.ServiceDiscovery.getInstance(new __geekmidas_envkit.EnvironmentParser({}));
362
+ return _geekmidas_services.ServiceDiscovery.getInstance(new _geekmidas_envkit.EnvironmentParser({}));
360
363
  }
361
364
  constructor(queue, serviceDiscovery = TestQueueAdaptor.getDefaultServiceDiscovery()) {
362
365
  this.queue = queue;
@@ -365,25 +368,35 @@ var TestQueueAdaptor = class TestQueueAdaptor {
365
368
  async invoke(request) {
366
369
  const logger = this.queue.logger.child({ test: true });
367
370
  const services = request.services ?? await this.serviceDiscovery.register(this.queue.services);
371
+ const db = request.db !== void 0 ? request.db : await this.getDatabase();
368
372
  const requestId = `test-${Date.now()}`;
369
373
  const startTime = Date.now();
370
- return (0, __geekmidas_services.runWithRequestContext)({
374
+ const operation = `queue ${this.queue.name}`;
375
+ return (0, _geekmidas_services.runWithRequestContext)({
371
376
  logger,
372
377
  requestId,
373
- startTime
378
+ startTime,
379
+ operation
374
380
  }, () => this.queue.handler({
375
381
  messages: request.messages,
376
382
  services,
377
- logger
383
+ logger,
384
+ db
378
385
  }));
379
386
  }
387
+ async getDatabase() {
388
+ const service = this.queue.databaseService;
389
+ if (!service) return void 0;
390
+ return (await this.serviceDiscovery.register([service]))[service.serviceName];
391
+ }
380
392
  };
381
-
382
393
  //#endregion
383
394
  //#region src/subscribers/TestSubscriberAdaptor.ts
384
395
  var TestSubscriberAdaptor = class TestSubscriberAdaptor {
396
+ subscriber;
397
+ serviceDiscovery;
385
398
  static getDefaultServiceDiscovery() {
386
- return __geekmidas_services.ServiceDiscovery.getInstance(new __geekmidas_envkit.EnvironmentParser({}));
399
+ return _geekmidas_services.ServiceDiscovery.getInstance(new _geekmidas_envkit.EnvironmentParser({}));
387
400
  }
388
401
  constructor(subscriber, serviceDiscovery = TestSubscriberAdaptor.getDefaultServiceDiscovery()) {
389
402
  this.subscriber = subscriber;
@@ -394,19 +407,23 @@ var TestSubscriberAdaptor = class TestSubscriberAdaptor {
394
407
  let services;
395
408
  if (request.services) services = request.services;
396
409
  else services = await this.serviceDiscovery.register(this.subscriber.services);
410
+ const db = request.db !== void 0 ? request.db : await this.getDatabase();
397
411
  const filteredEvents = this.filterEvents(request.events);
398
412
  if (filteredEvents.length === 0) return { batchItemFailures: [] };
399
413
  const requestId = `test-${Date.now()}`;
400
414
  const startTime = Date.now();
401
- return (0, __geekmidas_services.runWithRequestContext)({
415
+ const operation = `subscriber ${this.subscriber.topicName ?? "test"}`;
416
+ return (0, _geekmidas_services.runWithRequestContext)({
402
417
  logger,
403
418
  requestId,
404
- startTime
419
+ startTime,
420
+ operation
405
421
  }, async () => {
406
422
  const result = await this.subscriber.handler({
407
423
  events: filteredEvents,
408
424
  services,
409
- logger
425
+ logger,
426
+ db
410
427
  });
411
428
  let output = result;
412
429
  if (this.subscriber.outputSchema && result) {
@@ -414,21 +431,626 @@ var TestSubscriberAdaptor = class TestSubscriberAdaptor {
414
431
  if (validationResult.issues) throw new Error("Subscriber output validation failed");
415
432
  output = validationResult.value;
416
433
  }
417
- await require_lazyAccessors.publishEvents(logger, this.serviceDiscovery, this.subscriber.events, output, this.subscriber.publisherService);
418
434
  return output;
419
435
  });
420
436
  }
437
+ async getDatabase() {
438
+ const service = this.subscriber.databaseService;
439
+ if (!service) return void 0;
440
+ return (await this.serviceDiscovery.register([service]))[service.serviceName];
441
+ }
421
442
  filterEvents(events) {
422
443
  if (!this.subscriber.subscribedEvents) return events;
423
444
  return events.filter((event) => this.subscriber.subscribedEvents.includes(event.type));
424
445
  }
425
446
  };
426
-
427
447
  //#endregion
428
- exports.TEST_CONTEXT_HEADER = TEST_CONTEXT_HEADER;
448
+ //#region src/testing/manifest.ts
449
+ /**
450
+ * The test manifest: what `gkm test` knows about an app, written down for the
451
+ * suite it starts.
452
+ *
453
+ * `gkm test` discovers the constructs, reconciles the test stage and resolves
454
+ * its environment — then, until this existed, threw all of it away and left a
455
+ * test to declare it again by hand. The manifest keeps it: which construct and
456
+ * endpoint is exported where, and the environment the test stage resolved,
457
+ * under the keys the constructs themselves derive. A feature test is built from
458
+ * it, so nothing a test says can drift from what the app declares.
459
+ */
460
+ /** The environment variable `gkm test` names the manifest in. */
461
+ const TEST_MANIFEST_ENV = "GKM_TEST_MANIFEST";
462
+ /**
463
+ * Read a test manifest: from a path, a `file:` URL, or — given nothing — the
464
+ * one `gkm test` named in `GKM_TEST_MANIFEST`.
465
+ */
466
+ function loadTestManifest(from) {
467
+ const location = from ?? process.env["GKM_TEST_MANIFEST"];
468
+ if (!location) throw new NoTestManifest();
469
+ trustLocalEdge();
470
+ const path = location instanceof URL || location.startsWith("file:") ? (0, node_url.fileURLToPath)(location) : location;
471
+ return JSON.parse((0, node_fs.readFileSync)(path, "utf-8"));
472
+ }
473
+ let trusted = false;
474
+ /**
475
+ * Trust the local edge's certificate authority in this thread.
476
+ *
477
+ * `NODE_EXTRA_CA_CERTS` does it for a process started with it — which a
478
+ * suite started by `gkm test` is, and one started by plain `vitest` or an
479
+ * editor is not: its setup only learns the path once Vitest is running, and a
480
+ * worker *thread* shares that process and keeps a TLS store of its own. Every
481
+ * feature test loads the manifest, so this is the one place each worker passes
482
+ * through.
483
+ */
484
+ function trustLocalEdge() {
485
+ const certificate = process.env.NODE_EXTRA_CA_CERTS;
486
+ if (trusted || !certificate || !(0, node_fs.existsSync)(certificate)) return;
487
+ trusted = true;
488
+ node_tls.default.setDefaultCACertificates([...node_tls.default.getCACertificates("default"), (0, node_fs.readFileSync)(certificate, "utf-8")]);
489
+ }
490
+ /** A feature test ran without a manifest to build itself from. */
491
+ var NoTestManifest = class extends Error {
492
+ constructor() {
493
+ super(`No test manifest: run the suite with \`gkm test\`, or add \`globalSetup: ['@geekmidas/cli/vitest']\` to the root vitest config — either writes one and names it in ${TEST_MANIFEST_ENV}.`);
494
+ this.name = "NoTestManifest";
495
+ }
496
+ };
497
+ //#endregion
498
+ //#region src/testing/featureTest.ts
499
+ /**
500
+ * `featureTest`: an app, driven the way it runs deployed.
501
+ *
502
+ * A browser signs in and calls the API; the API calls the auth server; each
503
+ * over its URL, each database in its own transaction. Nothing runs as a server:
504
+ * every URL an app's constructs answer on is served in-process through MSW,
505
+ * from the real handler, for the test that made the request. Everything else
506
+ * with a real local equivalent — Postgres, Mailpit, MinIO — is used directly.
507
+ *
508
+ * It is built from the test manifest `gkm test` writes — the constructs and
509
+ * endpoints the app exports, and the environment the test stage resolved — so
510
+ * a test declares none of it. `gkm test` also generates the configured `it`
511
+ * and a `Browser` with a typed client per surface:
512
+ *
513
+ * ```ts
514
+ * import { it } from '#test';
515
+ *
516
+ * it('shows the signed-in user their profile', async ({ browser, mailbox }) => {
517
+ * await browser.auth.signIn.magicLink({ email: 'ada@shop.test' });
518
+ * await browser.visit((await mailbox('ada@shop.test').last()).link!);
519
+ * expect(await browser.api.get('/profile')).toMatchObject({ email: 'ada@shop.test' });
520
+ * });
521
+ * ```
522
+ */
523
+ /** Every test in flight in this process, by id. */
524
+ const contexts = /* @__PURE__ */ new Map();
525
+ /** Databases already resolving to test transactions — patched once each. */
526
+ const bound = /* @__PURE__ */ new WeakSet();
527
+ function featureTest(options = {}) {
528
+ const manifest = options.manifest ?? loadTestManifest();
529
+ const BrowserClass = options.browser ?? _geekmidas_testkit_browser.Browser;
530
+ let app;
531
+ let factoryDatabases = [];
532
+ let owned = [];
533
+ let network;
534
+ let restoreFetch = () => {};
535
+ (0, vitest.beforeAll)(async () => {
536
+ app = await load(manifest, options.modules ?? {});
537
+ owned = ownDatabases(app, manifest);
538
+ factoryDatabases = databasesFor(options.factories ?? {}, owned);
539
+ for (const database of app.databases) bindToTests(database);
540
+ network = (0, msw_node.setupServer)(...surfaceHandlers(app.endpoints, manifest.env), ...app.auths.map((auth) => authHandler(auth, manifest.env, app.envParser)), ...Object.entries(options.fakes ?? {}).flatMap(([id, fake]) => fakeHandler(id, fake, manifest.env)));
541
+ network.listen({ onUnhandledRequest(request, print) {
542
+ if (isLocal(new URL(request.url))) return;
543
+ print.error();
544
+ } });
545
+ const restoreStamp = (0, _geekmidas_testkit_context.installContextFetch)();
546
+ const stamped = globalThis.fetch;
547
+ globalThis.fetch = deliveringFetch(stamped, (id) => {
548
+ const state = contexts.get(id);
549
+ return state ? deliver(app, state, id) : Promise.resolve();
550
+ });
551
+ restoreFetch = () => {
552
+ globalThis.fetch = stamped;
553
+ restoreStamp();
554
+ };
555
+ });
556
+ (0, vitest.afterAll)(() => {
557
+ restoreFetch();
558
+ network?.close();
559
+ });
560
+ const run = (name, fn) => async () => {
561
+ const id = (0, node_crypto.randomUUID)();
562
+ _geekmidas_testkit_faker.faker.seed(seedOf(name));
563
+ const state = {
564
+ transactions: new _geekmidas_testkit_transactions.TransactionRegistry(),
565
+ discovery: new _geekmidas_services.ServiceDiscovery(app.envParser),
566
+ surfaces: /* @__PURE__ */ new Map(),
567
+ auth: /* @__PURE__ */ new Map(),
568
+ addresses: /* @__PURE__ */ new Set(),
569
+ published: /* @__PURE__ */ new Map(),
570
+ pending: [],
571
+ delivering: false
572
+ };
573
+ const readMail = app.readMail;
574
+ if (readMail) state.mailbox = (address) => {
575
+ state.addresses.add(address);
576
+ return readMail(address);
577
+ };
578
+ contexts.set(id, state);
579
+ await state.discovery.register(recorders(app.channels, state));
580
+ try {
581
+ await (0, _geekmidas_testkit_context.runInTestContext)(id, async () => {
582
+ const browser = new BrowserClass();
583
+ const restore = browser.install();
584
+ try {
585
+ const transaction = (database) => state.transactions.get(database.id, urlOf(database, app.envParser), database.clientConfig);
586
+ const db = { get: (name) => {
587
+ const database = owned.find((candidate) => candidate.service.serviceName === name);
588
+ if (!database) throw new UnknownDatabase(name, owned.map((candidate) => candidate.service.serviceName));
589
+ return transaction(database);
590
+ } };
591
+ const built = /* @__PURE__ */ new Map();
592
+ await fn({
593
+ browser,
594
+ db,
595
+ factories: { get: (name) => {
596
+ const database = factoryDatabases.find(([candidate]) => candidate === name)?.[1];
597
+ if (!database) throw new UnknownFactory(name, factoryDatabases.map(([candidate]) => candidate));
598
+ let factory = built.get(name);
599
+ if (!factory) {
600
+ factory = transaction(database).then(options.factories[name]);
601
+ built.set(name, factory);
602
+ }
603
+ return factory;
604
+ } },
605
+ faker: _geekmidas_testkit_faker.faker,
606
+ mailbox: (address) => {
607
+ if (!state.mailbox) throw new NoInbox();
608
+ return state.mailbox(address);
609
+ },
610
+ published: (channel) => [...state.published.get(channel.id) ?? []],
611
+ services: { get: (name) => resolveService(app, state, name) },
612
+ subscriber: (subscriber) => thenDeliver(new TestSubscriberAdaptor(subscriber, state.discovery), () => deliver(app, state, id)),
613
+ queue: (queue) => thenDeliver(new TestQueueAdaptor(queue, state.discovery), () => deliver(app, state, id))
614
+ });
615
+ } finally {
616
+ restore();
617
+ }
618
+ });
619
+ } finally {
620
+ contexts.delete(id);
621
+ await Promise.all([state.transactions.rollbackAll(), ...[...state.addresses].map((address) => app.readMail?.(address).clear())]);
622
+ }
623
+ };
624
+ const it = ((name, fn, timeout) => (0, vitest.test)(name, run(name, fn), timeout));
625
+ it.only = (name, fn, timeout) => vitest.test.only(name, run(name, fn), timeout);
626
+ it.skip = (name, fn, timeout) => vitest.test.skip(name, run(name, fn), timeout);
627
+ return it;
628
+ }
629
+ /**
630
+ * A test's faker seed, from its name: the same test draws the same data on
631
+ * every run, and two tests draw different data.
632
+ */
633
+ function seedOf(name) {
634
+ let hash = 0;
635
+ for (const char of name) hash = Math.imul(hash, 31) + char.charCodeAt(0) | 0;
636
+ return hash >>> 0;
637
+ }
638
+ /**
639
+ * Import what the manifest points at.
640
+ *
641
+ * The same modules the app runs, so a construct here *is* the app's construct —
642
+ * the one its endpoints were built from — never a copy declared again.
643
+ */
644
+ async function load(manifest, modules) {
645
+ const envParser = new _geekmidas_envkit.EnvironmentParser({ ...manifest.env });
646
+ const imported = async ({ file, export: name }) => (modules[file] ?? await import(file))[name];
647
+ const constructs = await Promise.all(Object.values(manifest.constructs).map(({ source }) => imported(source)));
648
+ const endpoints = (await Promise.all(manifest.endpoints.map(({ source }) => imported(source)))).filter((value) => require_Endpoint.Endpoint.isEndpoint(value));
649
+ const subscribers = (await Promise.all((manifest.subscribers ?? []).map(async ({ source }) => ({
650
+ name: source.export,
651
+ subscriber: await imported(source)
652
+ })))).filter((entry) => entry.subscriber?.__IS_SUBSCRIBER__ === true);
653
+ const unique = (values) => [...new Set(values)];
654
+ const databases = unique(constructs.filter((value) => value instanceof require_kysely.KyselyDatabase));
655
+ const auths = unique(constructs.filter((value) => value instanceof require_auth.BetterAuth));
656
+ const emails = unique(constructs.filter((value) => value instanceof require_email.Email));
657
+ const consumables = unique(constructs.filter(require_construct_interface.isConsumable));
658
+ const channels = unique(constructs.filter((value) => value instanceof require_Topic.Topic || value instanceof require_Queue.Queue));
659
+ const inbox = emails.map((email) => manifest.env[(0, _geekmidas_manifest.provideKey)(email.id, "inboxUrl")]).find(Boolean);
660
+ return {
661
+ envParser,
662
+ endpoints,
663
+ databases,
664
+ auths,
665
+ emails,
666
+ channels,
667
+ consumables,
668
+ subscribers,
669
+ ...inbox ? { readMail: (0, _geekmidas_testkit_mailbox.createMailbox)({ inbox }) } : {}
670
+ };
671
+ }
672
+ /**
673
+ * A publisher that records rather than sends, under the name a topic or queue
674
+ * is injected by — `services.users` — which is also the one `.event(users, …)`
675
+ * publishes through.
676
+ */
677
+ function recorders(channels, state) {
678
+ return channels.map((channel) => {
679
+ const publisher = { async publish(messages) {
680
+ const sent = messages.map(({ type, payload }) => ({
681
+ type,
682
+ payload
683
+ }));
684
+ state.published.set(channel.id, [...state.published.get(channel.id) ?? [], ...sent]);
685
+ state.pending.push({
686
+ channel,
687
+ messages: sent
688
+ });
689
+ } };
690
+ return {
691
+ serviceName: channel.service.serviceName,
692
+ register: () => publisher
693
+ };
694
+ });
695
+ }
696
+ /**
697
+ * The databases a test is handed: the app's own. A schema tenant an auth server
698
+ * owns is reached through that server, as the app reaches it, and a reader is
699
+ * the same database through a read-only role — neither is another database to
700
+ * test against.
701
+ */
702
+ function ownDatabases(app, manifest) {
703
+ const owners = new Set(app.auths.map((auth) => auth.databaseId));
704
+ return app.databases.filter((database) => !owners.has(database.id) && manifest.constructs[database.id]?.kind !== "database-reader");
705
+ }
706
+ /** Each factory's database, found by the service name it is keyed by. */
707
+ function databasesFor(factories, databases) {
708
+ return Object.keys(factories).map((name) => {
709
+ const database = databases.find((candidate) => candidate.service.serviceName === name);
710
+ if (!database) throw new UnknownFactory(name, databases.map((candidate) => candidate.service.serviceName));
711
+ return [name, database];
712
+ });
713
+ }
714
+ /**
715
+ * Make a database resolve, inside a test, to that test's transaction.
716
+ *
717
+ * Everything reaches a database through its service — an endpoint through
718
+ * service discovery, the auth server through its tenant directly — so this is
719
+ * the one place a test's connection can be handed over. Outside a test it is
720
+ * the database it always was.
721
+ */
722
+ /** Rounds of delivery before a chain of consumers is called a loop. */
723
+ const MAX_DELIVERY_ROUNDS = 25;
724
+ /**
725
+ * Deliver what this test published, in-process, as the broker would — and
726
+ * keep delivering what the consumers publish in turn, until nothing is left.
727
+ *
728
+ * - A queue's messages go to its one consumer, as a batch.
729
+ * - A topic's events go to every subscriber that named their type, and only
730
+ * those: fan-out, as the filter policy (SNS) or the per-subscriber queue
731
+ * (pg-boss) does it.
732
+ * - Each payload is checked against the consumer's schema first. Turning an
733
+ * SNS envelope or an SQS record into `{ type, payload }` is each adaptor's
734
+ * job and tested there; what is tested here is what the handler is handed.
735
+ * - Consumers run as the server side of this test, so their databases are
736
+ * this test's transactions and their writes roll back with it.
737
+ * - A consumer that throws fails the test. Deployed, the message would be
738
+ * retried; here a retry would only hide the bug.
739
+ */
740
+ async function deliver(app, state, id) {
741
+ if (state.delivering) return;
742
+ state.delivering = true;
743
+ try {
744
+ for (let round = 0; state.pending.length > 0; round++) {
745
+ if (round === MAX_DELIVERY_ROUNDS) throw new DeliveryDidNotSettle(MAX_DELIVERY_ROUNDS, [...new Set(state.pending.map(({ channel }) => channel.id))]);
746
+ for (const { channel, messages } of state.pending.splice(0)) if (channel instanceof require_Queue.Queue) await toQueue(channel, messages, state, id);
747
+ else await toSubscribers(channel, messages, app, state, id);
748
+ }
749
+ } finally {
750
+ state.delivering = false;
751
+ }
752
+ }
753
+ async function toQueue(queue, messages, state, id) {
754
+ const payloads = [];
755
+ for (const message of messages) payloads.push(await accepted(queue.messageSchema, message, `queue '${queue.name}'`));
756
+ await (0, _geekmidas_testkit_context.runAsServer)(id, () => new TestQueueAdaptor(queue, state.discovery).invoke({ messages: payloads })).catch((error) => {
757
+ throw new DeliveryFailed(`queue '${queue.name}'`, messages, error);
758
+ });
759
+ }
760
+ async function toSubscribers(topic, messages, app, state, id) {
761
+ for (const { name, subscriber } of app.subscribers) {
762
+ if (subscriber.topicName !== topic.name) continue;
763
+ const named = messages.filter(({ type }) => (subscriber.subscribedEvents ?? []).includes(type));
764
+ if (named.length === 0) continue;
765
+ const consumer = `subscriber '${name}'`;
766
+ const events = [];
767
+ for (const message of named) {
768
+ const schema = topic.eventSchemas[message.type];
769
+ events.push({
770
+ type: message.type,
771
+ payload: await accepted(schema, message, consumer)
772
+ });
773
+ }
774
+ await (0, _geekmidas_testkit_context.runAsServer)(id, () => new TestSubscriberAdaptor(subscriber, state.discovery).invoke({ events })).catch((error) => {
775
+ throw new DeliveryFailed(consumer, named, error);
776
+ });
777
+ }
778
+ }
779
+ /** The payload, if the consumer's schema takes it — what the handler is handed. */
780
+ async function accepted(schema, message, consumer) {
781
+ const standard = schema?.["~standard"];
782
+ if (!standard) return message.payload;
783
+ const result = await standard.validate(message.payload);
784
+ if (result.issues) throw new MessageRejected(consumer, message, result.issues);
785
+ return result.value;
786
+ }
787
+ /** `fetch`, delivering what the test published once each of its requests answers. */
788
+ function deliveringFetch(inner, settle) {
789
+ return async (input, init) => {
790
+ const context = (0, _geekmidas_testkit_context.currentTestContext)();
791
+ const response = await inner(input, init);
792
+ if (context?.side === "client") await settle(context.id);
793
+ return response;
794
+ };
795
+ }
796
+ /** An adaptor whose `invoke` delivers what it published before returning. */
797
+ function thenDeliver(adaptor, settle) {
798
+ const invoke = adaptor.invoke.bind(adaptor);
799
+ adaptor.invoke = (async (...args) => {
800
+ const result = await invoke(...args);
801
+ await settle();
802
+ return result;
803
+ });
804
+ return adaptor;
805
+ }
806
+ function bindToTests(database) {
807
+ if (bound.has(database)) return;
808
+ bound.add(database);
809
+ const service = database.service;
810
+ const register = service.register;
811
+ service.register = (options) => {
812
+ const context = (0, _geekmidas_testkit_context.currentTestContext)();
813
+ const state = context && contexts.get(context.id);
814
+ if (!state) return register(options);
815
+ return state.transactions.get(database.id, urlOf(database, options.envParser), database.clientConfig);
816
+ };
817
+ }
818
+ function urlOf(database, envParser) {
819
+ return envParser.create((get) => ({ url: get((0, _geekmidas_manifest.provideKey)(database.id, "url")).string() })).parse().url;
820
+ }
821
+ /** Each surface's endpoints, served at its URL for the test that asked. */
822
+ function surfaceHandlers(endpoints, env) {
823
+ const bySurface = /* @__PURE__ */ new Map();
824
+ for (const endpoint of endpoints) {
825
+ const surface = endpoint.surface?.id;
826
+ if (!surface) continue;
827
+ bySurface.set(surface, [...bySurface.get(surface) ?? [], endpoint]);
828
+ }
829
+ return [...bySurface].flatMap(([surface, served]) => {
830
+ const base = env[(0, _geekmidas_manifest.provideKey)(surface, "url")];
831
+ if (!base) return [];
832
+ return msw.http.all(`${trim(base)}/*`, ({ request }) => serve(request, async (state) => {
833
+ let app = state.surfaces.get(surface);
834
+ if (!app) {
835
+ app = Promise.resolve().then(() => {
836
+ const hono$1 = new hono.Hono();
837
+ require_HonoEndpointAdaptor.HonoEndpoint.addRoutes(served, state.discovery, hono$1);
838
+ return hono$1;
839
+ });
840
+ state.surfaces.set(surface, app);
841
+ }
842
+ return (await app).fetch(request);
843
+ }));
844
+ });
845
+ }
846
+ /**
847
+ * An external API's app fake, answering at the URL the test stage resolved for
848
+ * it — so a handler that calls Polar calls the fake, and the test sets up
849
+ * nothing.
850
+ *
851
+ * Not per test, unlike a surface: a fake stands in for somebody else's server,
852
+ * which no test's transaction reaches. An image fake has no handler here — its
853
+ * container answers on localhost, which is let through.
854
+ */
855
+ function fakeHandler(id, fake, env) {
856
+ const base = env[(0, _geekmidas_manifest.provideKey)(id, "url")];
857
+ if (fake.kind !== "app" || !base) return [];
858
+ return [msw.http.all(`${trim(base)}/*`, ({ request }) => fake.handler.fetch(request))];
859
+ }
860
+ /**
861
+ * A construct's client for this test, by service name — through the test's own
862
+ * discovery, so a topic or queue is its recorder and a database its
863
+ * transaction, exactly as the test's endpoints get them.
864
+ */
865
+ async function resolveService(app, state, name) {
866
+ const construct = app.consumables.find((candidate) => candidate.service.serviceName === name);
867
+ if (!construct) throw new UnknownService(name, app.consumables.map((candidate) => candidate.service.serviceName));
868
+ return (await state.discovery.register([construct.service]))[name];
869
+ }
870
+ /** An auth server, served at its URL, on the transaction of the test that asked. */
871
+ function authHandler(auth, env, envParser) {
872
+ const base = trim(env[(0, _geekmidas_manifest.provideKey)(auth.id, "url")] ?? "");
873
+ return msw.http.all(`${base}/*`, ({ request }) => serve(request, async (state) => {
874
+ let app = state.auth.get(auth);
875
+ if (!app) {
876
+ app = auth.server({
877
+ envParser,
878
+ context: _geekmidas_services.serviceContext
879
+ }).then(({ app }) => app);
880
+ state.auth.set(auth, app);
881
+ }
882
+ return (await app).fetch(request);
883
+ }));
884
+ }
885
+ /** Handle a request as the server side of the test it was made for. */
886
+ async function serve(request, handle) {
887
+ const id = (0, _geekmidas_testkit_context.testContextOf)(request);
888
+ const state = id ? contexts.get(id) : void 0;
889
+ if (!id || !state) throw new UnknownTestContext(request.url, id);
890
+ return (0, _geekmidas_testkit_context.runAsServer)(id, () => handle(state));
891
+ }
892
+ function trim(url) {
893
+ return url.replace(/\/$/, "");
894
+ }
895
+ function isLocal(url) {
896
+ return url.hostname === "localhost" || url.hostname === "127.0.0.1" || url.hostname.endsWith(".localhost");
897
+ }
898
+ /**
899
+ * Sign a test's browser in the way a person does: ask the auth server for a
900
+ * magic link, open the email it sent, follow the link.
901
+ *
902
+ * What the generated `browser.signIn(email)` calls. The address's mail is
903
+ * cleared first — so the link is this request's, not one an earlier test left
904
+ * — and cleared again after the test, like any address a test reads. Returns
905
+ * the session the auth server then reports, as better-auth hands it back.
906
+ */
907
+ async function signInWithMagicLink(browser, auth, email = freshAddress()) {
908
+ const context = (0, _geekmidas_testkit_context.currentTestContext)();
909
+ const state = context && contexts.get(context.id);
910
+ if (!state) throw new UnknownTestContext("signIn", context?.id);
911
+ if (!state.mailbox) throw new NoInbox();
912
+ const inbox = state.mailbox(email);
913
+ await inbox.clear();
914
+ const requested = await auth.signIn.magicLink({ email });
915
+ if (requested.error) throw new SignInFailed(email, `the auth server refused the magic link: ${requested.error.message ?? "no reason given"}`);
916
+ const mail = await inbox.last();
917
+ if (!mail.link) throw new SignInFailed(email, "its email held no link");
918
+ await browser.visit(mail.link);
919
+ const { data } = await auth.getSession();
920
+ if (!data) throw new SignInFailed(email, "the auth server reported no session after the link was opened");
921
+ return data;
922
+ }
923
+ /**
924
+ * An address nobody else signs in as — what `browser.signIn()` uses when the
925
+ * test does not care who it is.
926
+ *
927
+ * Unique rather than only seeded: tests in other files run at the same time,
928
+ * against the same Mailpit and the same unique columns, and a seeded address
929
+ * repeats wherever two tests share a name. The readable half is the seeded
930
+ * faker's, so a failure still names somebody.
931
+ */
932
+ function freshAddress() {
933
+ return `${_geekmidas_testkit_faker.faker.internet.username().toLowerCase().replace(/[^a-z0-9]/g, "")}.${(0, node_crypto.randomUUID)().slice(0, 8)}@example.test`;
934
+ }
935
+ /** `browser.signIn` finished without a session. */
936
+ var SignInFailed = class extends Error {
937
+ email;
938
+ reason;
939
+ constructor(email, reason) {
940
+ super(`Signing ${email} in failed: ${reason}.`);
941
+ this.email = email;
942
+ this.reason = reason;
943
+ this.name = "SignInFailed";
944
+ }
945
+ };
946
+ /** A request reached an in-process server without a test to belong to. */
947
+ var UnknownTestContext = class extends Error {
948
+ url;
949
+ id;
950
+ constructor(url, id) {
951
+ super(id ? `${url} was requested for test ${id}, which is not running. A request that outlives its test — an un-awaited call — lands here.` : `${url} was requested outside any test. Make the request inside a featureTest, so it reaches that test's transactions.`);
952
+ this.url = url;
953
+ this.id = id;
954
+ this.name = "UnknownTestContext";
955
+ }
956
+ };
957
+ /** `mailbox` was used in an app that declares no Email construct. */
958
+ var NoInbox = class extends Error {
959
+ constructor() {
960
+ super("mailbox() reads the inbox of the app's Email construct, and none was found in featureTest's modules — or `gkm test` did not inject its <ID>_INBOX_URL.");
961
+ this.name = "NoInbox";
962
+ }
963
+ };
964
+ /** `db.get(name)` named no database the test is handed. */
965
+ var UnknownDatabase = class extends Error {
966
+ database;
967
+ known;
968
+ constructor(database, known) {
969
+ super(`db.get('${database}') names no database of this app's. ` + (known.length > 0 ? `Its databases: ${known.join(", ")}. ` : "It declares no database of its own. ") + "A tenant an auth server owns is reached through that server, and a reader through the database it reads.");
970
+ this.database = database;
971
+ this.known = known;
972
+ this.name = "UnknownDatabase";
973
+ }
974
+ };
975
+ /** A factory keyed by a service name no database the app declares has. */
976
+ var UnknownFactory = class extends Error {
977
+ factory;
978
+ known;
979
+ constructor(factory, known) {
980
+ super(`There is a test factory for '${factory}', and no database this app declares is called that. ` + (known.length > 0 ? `Its databases: ${known.join(", ")}. ` : "It declares no database. ") + `Name the file after the database construct: test/factories/<construct>.ts.`);
981
+ this.factory = factory;
982
+ this.known = known;
983
+ this.name = "UnknownFactory";
984
+ }
985
+ };
986
+ /** A published message the consumer's own schema refuses. */
987
+ var MessageRejected = class extends Error {
988
+ consumer;
989
+ published;
990
+ issues;
991
+ constructor(consumer, published, issues) {
992
+ super(`${consumer} refuses '${published.type}': ${issues.map((issue) => issue.message).join("; ")}. What is published must be what the consumer's schema takes — fix the producer, or the schema.`);
993
+ this.consumer = consumer;
994
+ this.published = published;
995
+ this.issues = issues;
996
+ this.name = "MessageRejected";
997
+ }
998
+ };
999
+ /** A consumer that threw while handling what the test published. */
1000
+ var DeliveryFailed = class extends Error {
1001
+ consumer;
1002
+ messages;
1003
+ cause;
1004
+ constructor(consumer, messages, cause) {
1005
+ super(`${consumer} failed handling ${messages.map(({ type }) => `'${type}'`).join(", ")}: ${cause?.message ?? String(cause)}. Deployed, the message would be retried; here the failure is the result.`, { cause });
1006
+ this.consumer = consumer;
1007
+ this.messages = messages;
1008
+ this.cause = cause;
1009
+ this.name = "DeliveryFailed";
1010
+ }
1011
+ };
1012
+ /** Consumers that kept publishing to each other without settling. */
1013
+ var DeliveryDidNotSettle = class extends Error {
1014
+ rounds;
1015
+ channels;
1016
+ constructor(rounds, channels) {
1017
+ super(`Delivery did not settle after ${rounds} rounds — consumers are still publishing to ${channels.join(", ")}. A consumer that publishes to what triggers it loops forever deployed too.`);
1018
+ this.rounds = rounds;
1019
+ this.channels = channels;
1020
+ this.name = "DeliveryDidNotSettle";
1021
+ }
1022
+ };
1023
+ /** `services.get(name)` for a name no construct of the app is served by. */
1024
+ var UnknownService = class extends Error {
1025
+ serviceName;
1026
+ available;
1027
+ constructor(serviceName, available) {
1028
+ super(`The app declares no construct served as '${serviceName}'. Its services are: ${available.join(", ") || "none"}.`);
1029
+ this.serviceName = serviceName;
1030
+ this.available = available;
1031
+ this.name = "UnknownService";
1032
+ }
1033
+ };
1034
+ //#endregion
1035
+ exports.DeliveryDidNotSettle = DeliveryDidNotSettle;
1036
+ exports.DeliveryFailed = DeliveryFailed;
1037
+ exports.MessageRejected = MessageRejected;
1038
+ exports.NoInbox = NoInbox;
1039
+ exports.NoTestManifest = NoTestManifest;
1040
+ exports.SignInFailed = SignInFailed;
1041
+ exports.TEST_CONTEXT_HEADER = _geekmidas_testkit_context.TEST_CONTEXT_HEADER;
1042
+ exports.TEST_MANIFEST_ENV = TEST_MANIFEST_ENV;
429
1043
  exports.TestEndpointAdaptor = TestEndpointAdaptor;
430
1044
  exports.TestFunctionAdaptor = TestFunctionAdaptor;
431
1045
  exports.TestQueueAdaptor = TestQueueAdaptor;
432
1046
  exports.TestSubscriberAdaptor = TestSubscriberAdaptor;
1047
+ exports.UnknownDatabase = UnknownDatabase;
1048
+ exports.UnknownFactory = UnknownFactory;
1049
+ exports.UnknownService = UnknownService;
1050
+ exports.UnknownTestContext = UnknownTestContext;
433
1051
  exports.createMswHandlers = createMswHandlers;
1052
+ exports.featureTest = featureTest;
1053
+ exports.loadTestManifest = loadTestManifest;
1054
+ exports.signInWithMagicLink = signInWithMagicLink;
1055
+
434
1056
  //# sourceMappingURL=testing.cjs.map