@geekmidas/constructs 10.0.0-alpha.5 → 10.0.0-alpha.50

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