@geekmidas/constructs 10.0.0-alpha.4 → 10.0.0-alpha.40

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 (370) 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-CMEGfRs8.d.cts} +21 -8
  11. package/dist/Cron-CMEGfRs8.d.cts.map +1 -0
  12. package/dist/{Cron-ByxdOfpE.d.mts → Cron-D6X4-xjB.d.mts} +21 -8
  13. package/dist/Cron-D6X4-xjB.d.mts.map +1 -0
  14. package/dist/CronBuilder-CEK7aOqD.d.cts +46 -0
  15. package/dist/CronBuilder-CEK7aOqD.d.cts.map +1 -0
  16. package/dist/CronBuilder-DB35T5dL.cjs +116 -0
  17. package/dist/CronBuilder-DB35T5dL.cjs.map +1 -0
  18. package/dist/CronBuilder-Dv0IlZs0.mjs +104 -0
  19. package/dist/CronBuilder-Dv0IlZs0.mjs.map +1 -0
  20. package/dist/CronBuilder-O_gvButp.d.mts +46 -0
  21. package/dist/CronBuilder-O_gvButp.d.mts.map +1 -0
  22. package/dist/{Endpoint-Dij_wOcc.mjs → Endpoint-CQAeh1Rh.mjs} +117 -109
  23. package/dist/Endpoint-CQAeh1Rh.mjs.map +1 -0
  24. package/dist/{Endpoint-DODn1RhN.cjs → Endpoint-D1L9qu5C.cjs} +145 -131
  25. package/dist/Endpoint-D1L9qu5C.cjs.map +1 -0
  26. package/dist/{Endpoint-2Wg7T7Cq.d.mts → Endpoint-Dp5AKIXl.d.cts} +69 -93
  27. package/dist/Endpoint-Dp5AKIXl.d.cts.map +1 -0
  28. package/dist/{Endpoint-DrD8a1yH.d.cts → Endpoint-DtI7heFm.d.mts} +70 -94
  29. package/dist/Endpoint-DtI7heFm.d.mts.map +1 -0
  30. package/dist/{EndpointFactory-b4ituq-s.mjs → EndpointFactory-BBdNeaGJ.mjs} +39 -74
  31. package/dist/EndpointFactory-BBdNeaGJ.mjs.map +1 -0
  32. package/dist/{EndpointFactory-BHFMmFkV.cjs → EndpointFactory-BZOCOaK6.cjs} +75 -110
  33. package/dist/EndpointFactory-BZOCOaK6.cjs.map +1 -0
  34. package/dist/{index-BxHDdy6a.d.mts → EndpointFactory-CgMDvERK.d.mts} +63 -133
  35. package/dist/EndpointFactory-CgMDvERK.d.mts.map +1 -0
  36. package/dist/{index-B8g8POkr.d.cts → EndpointFactory-FeFRmlDZ.d.cts} +62 -132
  37. package/dist/EndpointFactory-FeFRmlDZ.d.cts.map +1 -0
  38. package/dist/{HonoEndpointAdaptor-BM2jbWht.mjs → HonoEndpointAdaptor-Aui-x9Lg.mjs} +41 -47
  39. package/dist/HonoEndpointAdaptor-Aui-x9Lg.mjs.map +1 -0
  40. package/dist/{HonoEndpointAdaptor-De6IlBZe.cjs → HonoEndpointAdaptor-Cq99r9H7.cjs} +50 -53
  41. package/dist/HonoEndpointAdaptor-Cq99r9H7.cjs.map +1 -0
  42. package/dist/Queue-C1uDgjxt.mjs +100 -0
  43. package/dist/Queue-C1uDgjxt.mjs.map +1 -0
  44. package/dist/Queue-Ckmudcm8.cjs +105 -0
  45. package/dist/Queue-Ckmudcm8.cjs.map +1 -0
  46. package/dist/{Queue-D7ZuwBhy.d.cts → Queue-CpQIGB_2.d.cts} +28 -40
  47. package/dist/Queue-CpQIGB_2.d.cts.map +1 -0
  48. package/dist/{Queue-gVGfi2Yk.d.mts → Queue-YmvN2vEP.d.mts} +28 -40
  49. package/dist/Queue-YmvN2vEP.d.mts.map +1 -0
  50. package/dist/QueueBuilder-CJNcv4dy.cjs +112 -0
  51. package/dist/QueueBuilder-CJNcv4dy.cjs.map +1 -0
  52. package/dist/QueueBuilder-CM0WUxfw.d.mts +62 -0
  53. package/dist/QueueBuilder-CM0WUxfw.d.mts.map +1 -0
  54. package/dist/QueueBuilder-XEnnOWGe.d.cts +62 -0
  55. package/dist/QueueBuilder-XEnnOWGe.d.cts.map +1 -0
  56. package/dist/QueueBuilder-XuPKZwKH.mjs +95 -0
  57. package/dist/QueueBuilder-XuPKZwKH.mjs.map +1 -0
  58. package/dist/{Subscriber-2mEi0ImH.d.cts → Subscriber-B91YSkZt.d.cts} +14 -16
  59. package/dist/Subscriber-B91YSkZt.d.cts.map +1 -0
  60. package/dist/{Subscriber-xTJ9ayPN.d.mts → Subscriber-BjHYe5hK.d.mts} +14 -16
  61. package/dist/Subscriber-BjHYe5hK.d.mts.map +1 -0
  62. package/dist/SubscriberBuilder-BSpQX1JT.d.cts +55 -0
  63. package/dist/SubscriberBuilder-BSpQX1JT.d.cts.map +1 -0
  64. package/dist/SubscriberBuilder-BhMphk4z.d.mts +55 -0
  65. package/dist/SubscriberBuilder-BhMphk4z.d.mts.map +1 -0
  66. package/dist/{SubscriberBuilder-4OPehf2R.cjs → SubscriberBuilder-Duk028pD.cjs} +34 -37
  67. package/dist/SubscriberBuilder-Duk028pD.cjs.map +1 -0
  68. package/dist/{SubscriberBuilder-BjkbeT9l.mjs → SubscriberBuilder-DzQUWE08.mjs} +23 -25
  69. package/dist/SubscriberBuilder-DzQUWE08.mjs.map +1 -0
  70. package/dist/Topic-CkxOTrMv.cjs +104 -0
  71. package/dist/Topic-CkxOTrMv.cjs.map +1 -0
  72. package/dist/Topic-hPffOsot.mjs +99 -0
  73. package/dist/Topic-hPffOsot.mjs.map +1 -0
  74. package/dist/adaptors/aws.cjs +171 -108
  75. package/dist/adaptors/aws.cjs.map +1 -1
  76. package/dist/adaptors/aws.d.cts +75 -43
  77. package/dist/adaptors/aws.d.cts.map +1 -1
  78. package/dist/adaptors/aws.d.mts +76 -44
  79. package/dist/adaptors/aws.d.mts.map +1 -1
  80. package/dist/adaptors/aws.mjs +143 -83
  81. package/dist/adaptors/aws.mjs.map +1 -1
  82. package/dist/adaptors/hono.cjs +3 -10
  83. package/dist/adaptors/hono.d.cts +7 -16
  84. package/dist/adaptors/hono.d.cts.map +1 -1
  85. package/dist/adaptors/hono.d.mts +8 -17
  86. package/dist/adaptors/hono.d.mts.map +1 -1
  87. package/dist/adaptors/hono.mjs +2 -10
  88. package/dist/adaptors/testing.cjs +515 -87
  89. package/dist/adaptors/testing.cjs.map +1 -1
  90. package/dist/adaptors/testing.d.cts +250 -48
  91. package/dist/adaptors/testing.d.cts.map +1 -1
  92. package/dist/adaptors/testing.d.mts +250 -48
  93. package/dist/adaptors/testing.d.mts.map +1 -1
  94. package/dist/adaptors/testing.mjs +484 -68
  95. package/dist/adaptors/testing.mjs.map +1 -1
  96. package/dist/auth-CMwml9QN.d.mts +188 -0
  97. package/dist/auth-CMwml9QN.d.mts.map +1 -0
  98. package/dist/auth-rVRDjIw_.d.cts +188 -0
  99. package/dist/auth-rVRDjIw_.d.cts.map +1 -0
  100. package/dist/auth.cjs +171 -31
  101. package/dist/auth.cjs.map +1 -1
  102. package/dist/auth.d.cts +2 -108
  103. package/dist/auth.d.mts +2 -108
  104. package/dist/auth.mjs +160 -24
  105. package/dist/auth.mjs.map +1 -1
  106. package/dist/{cache-BrRz3fEB.d.mts → cache-C9a_hVCc.d.cts} +4 -7
  107. package/dist/cache-C9a_hVCc.d.cts.map +1 -0
  108. package/dist/{cache-BtZY_tHe.d.cts → cache-CeTMI8LR.d.mts} +4 -7
  109. package/dist/cache-CeTMI8LR.d.mts.map +1 -0
  110. package/dist/cache.cjs +68 -2
  111. package/dist/cache.cjs.map +1 -0
  112. package/dist/cache.d.cts +1 -2
  113. package/dist/cache.d.mts +1 -2
  114. package/dist/cache.mjs +67 -2
  115. package/dist/cache.mjs.map +1 -0
  116. package/dist/{clone-DblgEZZa.mjs → clone-EKNovYHu.mjs} +3 -3
  117. package/dist/clone-EKNovYHu.mjs.map +1 -0
  118. package/dist/{clone-Dy0cR2SZ.cjs → clone-UGJpvQnL.cjs} +7 -8
  119. package/dist/clone-UGJpvQnL.cjs.map +1 -0
  120. package/dist/{construct-interface-g5GM5pwR.d.mts → construct-interface-_3zgxzXl.d.mts} +20 -11
  121. package/dist/construct-interface-_3zgxzXl.d.mts.map +1 -0
  122. package/dist/{construct-interface-D9d4Gm4p.d.cts → construct-interface-_xi4BPN8.d.cts} +20 -11
  123. package/dist/construct-interface-_xi4BPN8.d.cts.map +1 -0
  124. package/dist/construct-interface.cjs +87 -7
  125. package/dist/construct-interface.cjs.map +1 -0
  126. package/dist/construct-interface.d.cts +2 -2
  127. package/dist/construct-interface.d.mts +2 -2
  128. package/dist/construct-interface.mjs +81 -2
  129. package/dist/construct-interface.mjs.map +1 -0
  130. package/dist/credential.cjs +63 -16
  131. package/dist/credential.cjs.map +1 -1
  132. package/dist/credential.d.cts +16 -9
  133. package/dist/credential.d.cts.map +1 -1
  134. package/dist/credential.d.mts +16 -9
  135. package/dist/credential.d.mts.map +1 -1
  136. package/dist/credential.mjs +58 -12
  137. package/dist/credential.mjs.map +1 -1
  138. package/dist/crons/index.cjs +68 -10
  139. package/dist/crons/index.cjs.map +1 -1
  140. package/dist/crons/index.d.cts +32 -14
  141. package/dist/crons/index.d.cts.map +1 -1
  142. package/dist/crons/index.d.mts +32 -14
  143. package/dist/crons/index.d.mts.map +1 -1
  144. package/dist/crons/index.mjs +66 -10
  145. package/dist/crons/index.mjs.map +1 -1
  146. package/dist/database/kysely.cjs +40 -15
  147. package/dist/database/kysely.cjs.map +1 -1
  148. package/dist/database/kysely.d.cts +2 -152
  149. package/dist/database/kysely.d.mts +2 -152
  150. package/dist/database/kysely.mjs +28 -5
  151. package/dist/database/kysely.mjs.map +1 -1
  152. package/dist/email.cjs +25 -12
  153. package/dist/email.cjs.map +1 -1
  154. package/dist/email.d.cts +3 -7
  155. package/dist/email.d.cts.map +1 -1
  156. package/dist/email.d.mts +3 -7
  157. package/dist/email.d.mts.map +1 -1
  158. package/dist/email.mjs +16 -3
  159. package/dist/email.mjs.map +1 -1
  160. package/dist/endpoints/index.cjs +8 -10
  161. package/dist/endpoints/index.d.cts +51 -7
  162. package/dist/endpoints/index.d.cts.map +1 -0
  163. package/dist/endpoints/index.d.mts +51 -7
  164. package/dist/endpoints/index.d.mts.map +1 -0
  165. package/dist/endpoints/index.mjs +6 -10
  166. package/dist/external-api-DS3mujT5.d.mts +86 -0
  167. package/dist/external-api-DS3mujT5.d.mts.map +1 -0
  168. package/dist/external-api-LBfE-q3g.d.cts +86 -0
  169. package/dist/external-api-LBfE-q3g.d.cts.map +1 -0
  170. package/dist/external-api.cjs +124 -0
  171. package/dist/external-api.cjs.map +1 -0
  172. package/dist/external-api.d.cts +2 -0
  173. package/dist/external-api.d.mts +2 -0
  174. package/dist/external-api.mjs +121 -0
  175. package/dist/external-api.mjs.map +1 -0
  176. package/dist/file-server.cjs +42 -10
  177. package/dist/file-server.cjs.map +1 -1
  178. package/dist/file-server.d.cts +6 -10
  179. package/dist/file-server.d.cts.map +1 -1
  180. package/dist/file-server.d.mts +6 -10
  181. package/dist/file-server.d.mts.map +1 -1
  182. package/dist/file-server.mjs +34 -2
  183. package/dist/file-server.mjs.map +1 -1
  184. package/dist/functions/index.cjs +2 -6
  185. package/dist/functions/index.d.cts +2 -4
  186. package/dist/functions/index.d.mts +2 -4
  187. package/dist/functions/index.mjs +2 -6
  188. package/dist/{functions-Ck21Uyq0.mjs → functions-DCIfCRR-.mjs} +371 -241
  189. package/dist/functions-DCIfCRR-.mjs.map +1 -0
  190. package/dist/{functions-DJJA7VGc.cjs → functions-ZH60FE7H.cjs} +409 -273
  191. package/dist/functions-ZH60FE7H.cjs.map +1 -0
  192. package/dist/{index-AIfVzkhi.d.cts → index-B0kxstwf.d.cts} +49 -42
  193. package/dist/index-B0kxstwf.d.cts.map +1 -0
  194. package/dist/index-CeEtxDmK.d.cts +79 -0
  195. package/dist/index-CeEtxDmK.d.cts.map +1 -0
  196. package/dist/index-CeEtxDmK.d.mts +79 -0
  197. package/dist/index-CeEtxDmK.d.mts.map +1 -0
  198. package/dist/{index-CubPzHd9.d.mts → index-CjVEjOw0.d.mts} +49 -42
  199. package/dist/index-CjVEjOw0.d.mts.map +1 -0
  200. package/dist/index.cjs +3 -3
  201. package/dist/index.d.cts +4 -4
  202. package/dist/index.d.mts +4 -4
  203. package/dist/index.mjs +2 -3
  204. package/dist/kysely-BJ8IQ_1P.d.mts +159 -0
  205. package/dist/kysely-BJ8IQ_1P.d.mts.map +1 -0
  206. package/dist/kysely-DVF8wOT4.d.cts +159 -0
  207. package/dist/kysely-DVF8wOT4.d.cts.map +1 -0
  208. package/dist/{lazyAccessors-BoJN3SMd.mjs → lazyAccessors-CFanua0O.mjs} +20 -60
  209. package/dist/lazyAccessors-CFanua0O.mjs.map +1 -0
  210. package/dist/{lazyAccessors-e3j2oE2m.cjs → lazyAccessors-hJKGv8Ay.cjs} +60 -113
  211. package/dist/lazyAccessors-hJKGv8Ay.cjs.map +1 -0
  212. package/dist/mobile-app.cjs +70 -0
  213. package/dist/mobile-app.cjs.map +1 -0
  214. package/dist/mobile-app.d.cts +61 -0
  215. package/dist/mobile-app.d.cts.map +1 -0
  216. package/dist/mobile-app.d.mts +61 -0
  217. package/dist/mobile-app.d.mts.map +1 -0
  218. package/dist/mobile-app.mjs +69 -0
  219. package/dist/mobile-app.mjs.map +1 -0
  220. package/dist/object-storage.cjs +18 -10
  221. package/dist/object-storage.cjs.map +1 -1
  222. package/dist/object-storage.d.cts +3 -7
  223. package/dist/object-storage.d.cts.map +1 -1
  224. package/dist/object-storage.d.mts +3 -7
  225. package/dist/object-storage.d.mts.map +1 -1
  226. package/dist/object-storage.mjs +11 -3
  227. package/dist/object-storage.mjs.map +1 -1
  228. package/dist/{processAudits-Dmts9H_b.mjs → processAudits-BpRlPQMW.mjs} +16 -19
  229. package/dist/processAudits-BpRlPQMW.mjs.map +1 -0
  230. package/dist/{processAudits-CGqttuXm.cjs → processAudits-D_2W5x8k.cjs} +26 -30
  231. package/dist/processAudits-D_2W5x8k.cjs.map +1 -0
  232. package/dist/queue/index.cjs +6 -189
  233. package/dist/queue/index.d.cts +3 -60
  234. package/dist/queue/index.d.mts +3 -60
  235. package/dist/queue/index.mjs +3 -186
  236. package/dist/rest-api.cjs +87 -63
  237. package/dist/rest-api.cjs.map +1 -1
  238. package/dist/rest-api.d.cts +62 -61
  239. package/dist/rest-api.d.cts.map +1 -1
  240. package/dist/rest-api.d.mts +62 -61
  241. package/dist/rest-api.d.mts.map +1 -1
  242. package/dist/rest-api.mjs +79 -55
  243. package/dist/rest-api.mjs.map +1 -1
  244. package/dist/{chunk-DWy1uDak.cjs → rolldown-runtime-y5ARvAq5.cjs} +14 -18
  245. package/dist/site.cjs +33 -9
  246. package/dist/site.cjs.map +1 -1
  247. package/dist/site.d.cts +11 -22
  248. package/dist/site.d.cts.map +1 -1
  249. package/dist/site.d.mts +11 -22
  250. package/dist/site.d.mts.map +1 -1
  251. package/dist/site.mjs +29 -5
  252. package/dist/site.mjs.map +1 -1
  253. package/dist/subscribers/index.cjs +2 -11
  254. package/dist/subscribers/index.d.cts +3 -14
  255. package/dist/subscribers/index.d.mts +3 -14
  256. package/dist/subscribers/index.mjs +2 -11
  257. package/dist/surfaceEnv-CNimK76p.cjs +56 -0
  258. package/dist/surfaceEnv-CNimK76p.cjs.map +1 -0
  259. package/dist/surfaceEnv-wMT5QzgZ.mjs +45 -0
  260. package/dist/surfaceEnv-wMT5QzgZ.mjs.map +1 -0
  261. package/dist/{telemetry-C3L0iS28.d.cts → telemetry-DGcFlVpB.d.cts} +2 -5
  262. package/dist/telemetry-DGcFlVpB.d.cts.map +1 -0
  263. package/dist/{telemetry-D7bVFLGi.d.mts → telemetry-DGcFlVpB.d.mts} +2 -5
  264. package/dist/telemetry-DGcFlVpB.d.mts.map +1 -0
  265. package/dist/topic/index.cjs +3 -137
  266. package/dist/topic/index.d.cts +2 -32
  267. package/dist/topic/index.d.mts +2 -32
  268. package/dist/topic/index.mjs +2 -134
  269. package/dist/{types-BlAkSuGI.d.cts → types-DMuSQeLL.d.cts} +3 -5
  270. package/dist/types-DMuSQeLL.d.cts.map +1 -0
  271. package/dist/{types-aKksMEWL.d.mts → types-DMuSQeLL.d.mts} +3 -5
  272. package/dist/types-DMuSQeLL.d.mts.map +1 -0
  273. package/dist/types.d.cts +1 -1
  274. package/dist/types.d.mts +1 -1
  275. package/dist/types.mjs +1 -0
  276. package/dist/worker.cjs +118 -35
  277. package/dist/worker.cjs.map +1 -1
  278. package/dist/worker.d.cts +95 -42
  279. package/dist/worker.d.cts.map +1 -1
  280. package/dist/worker.d.mts +95 -42
  281. package/dist/worker.d.mts.map +1 -1
  282. package/dist/worker.mjs +113 -30
  283. package/dist/worker.mjs.map +1 -1
  284. package/package.json +66 -41
  285. package/dist/Construct-BD5neF7w.mjs.map +0 -1
  286. package/dist/Construct-C0ijr2qp.d.cts +0 -117
  287. package/dist/Construct-C0ijr2qp.d.cts.map +0 -1
  288. package/dist/Construct-Ct8nalEi.d.mts +0 -117
  289. package/dist/Construct-Ct8nalEi.d.mts.map +0 -1
  290. package/dist/Construct-CyS3RpTL.cjs.map +0 -1
  291. package/dist/Cron-B2OFsfDM.d.cts.map +0 -1
  292. package/dist/Cron-ByxdOfpE.d.mts.map +0 -1
  293. package/dist/CronBuilder-BL0AP6fs.d.mts +0 -44
  294. package/dist/CronBuilder-BL0AP6fs.d.mts.map +0 -1
  295. package/dist/CronBuilder-CdibiHNB.mjs +0 -84
  296. package/dist/CronBuilder-CdibiHNB.mjs.map +0 -1
  297. package/dist/CronBuilder-DyUr6nYz.cjs +0 -96
  298. package/dist/CronBuilder-DyUr6nYz.cjs.map +0 -1
  299. package/dist/CronBuilder-LSJMfqnq.d.cts +0 -44
  300. package/dist/CronBuilder-LSJMfqnq.d.cts.map +0 -1
  301. package/dist/Endpoint-2Wg7T7Cq.d.mts.map +0 -1
  302. package/dist/Endpoint-DODn1RhN.cjs.map +0 -1
  303. package/dist/Endpoint-Dij_wOcc.mjs.map +0 -1
  304. package/dist/Endpoint-DrD8a1yH.d.cts.map +0 -1
  305. package/dist/EndpointFactory-BHFMmFkV.cjs.map +0 -1
  306. package/dist/EndpointFactory-b4ituq-s.mjs.map +0 -1
  307. package/dist/HonoEndpointAdaptor-BM2jbWht.mjs.map +0 -1
  308. package/dist/HonoEndpointAdaptor-De6IlBZe.cjs.map +0 -1
  309. package/dist/Queue-D7ZuwBhy.d.cts.map +0 -1
  310. package/dist/Queue-gVGfi2Yk.d.mts.map +0 -1
  311. package/dist/Subscriber-2mEi0ImH.d.cts.map +0 -1
  312. package/dist/Subscriber-xTJ9ayPN.d.mts.map +0 -1
  313. package/dist/SubscriberBuilder-4OPehf2R.cjs.map +0 -1
  314. package/dist/SubscriberBuilder-BjkbeT9l.mjs.map +0 -1
  315. package/dist/SubscriberBuilder-Dptmo-1A.d.mts +0 -62
  316. package/dist/SubscriberBuilder-Dptmo-1A.d.mts.map +0 -1
  317. package/dist/SubscriberBuilder-waNhzjSM.d.cts +0 -62
  318. package/dist/SubscriberBuilder-waNhzjSM.d.cts.map +0 -1
  319. package/dist/Topic-19QeHBIR.d.cts +0 -91
  320. package/dist/Topic-19QeHBIR.d.cts.map +0 -1
  321. package/dist/Topic-DuFeqkBh.d.mts +0 -91
  322. package/dist/Topic-DuFeqkBh.d.mts.map +0 -1
  323. package/dist/auth.d.cts.map +0 -1
  324. package/dist/auth.d.mts.map +0 -1
  325. package/dist/cache-0ANvRQnD.mjs +0 -51
  326. package/dist/cache-0ANvRQnD.mjs.map +0 -1
  327. package/dist/cache-3WSvAulx.cjs +0 -57
  328. package/dist/cache-3WSvAulx.cjs.map +0 -1
  329. package/dist/cache-BrRz3fEB.d.mts.map +0 -1
  330. package/dist/cache-BtZY_tHe.d.cts.map +0 -1
  331. package/dist/clone-DblgEZZa.mjs.map +0 -1
  332. package/dist/clone-Dy0cR2SZ.cjs.map +0 -1
  333. package/dist/construct-interface-BfjcOD_E.cjs +0 -117
  334. package/dist/construct-interface-BfjcOD_E.cjs.map +0 -1
  335. package/dist/construct-interface-D9d4Gm4p.d.cts.map +0 -1
  336. package/dist/construct-interface-Z4CpS8tK.mjs +0 -81
  337. package/dist/construct-interface-Z4CpS8tK.mjs.map +0 -1
  338. package/dist/construct-interface-g5GM5pwR.d.mts.map +0 -1
  339. package/dist/database/kysely.d.cts.map +0 -1
  340. package/dist/database/kysely.d.mts.map +0 -1
  341. package/dist/functions-Ck21Uyq0.mjs.map +0 -1
  342. package/dist/functions-DJJA7VGc.cjs.map +0 -1
  343. package/dist/index-AIfVzkhi.d.cts.map +0 -1
  344. package/dist/index-B8g8POkr.d.cts.map +0 -1
  345. package/dist/index-BxHDdy6a.d.mts.map +0 -1
  346. package/dist/index-CubPzHd9.d.mts.map +0 -1
  347. package/dist/lazyAccessors-BoJN3SMd.mjs.map +0 -1
  348. package/dist/lazyAccessors-e3j2oE2m.cjs.map +0 -1
  349. package/dist/processAudits-CGqttuXm.cjs.map +0 -1
  350. package/dist/processAudits-Dmts9H_b.mjs.map +0 -1
  351. package/dist/queue/index.cjs.map +0 -1
  352. package/dist/queue/index.d.cts.map +0 -1
  353. package/dist/queue/index.d.mts.map +0 -1
  354. package/dist/queue/index.mjs.map +0 -1
  355. package/dist/subscribers/index.cjs.map +0 -1
  356. package/dist/subscribers/index.d.cts.map +0 -1
  357. package/dist/subscribers/index.d.mts.map +0 -1
  358. package/dist/subscribers/index.mjs.map +0 -1
  359. package/dist/surfaceEnv-BFXEms2f.cjs +0 -39
  360. package/dist/surfaceEnv-BFXEms2f.cjs.map +0 -1
  361. package/dist/surfaceEnv-C3Ktahea.mjs +0 -27
  362. package/dist/surfaceEnv-C3Ktahea.mjs.map +0 -1
  363. package/dist/telemetry-C3L0iS28.d.cts.map +0 -1
  364. package/dist/telemetry-D7bVFLGi.d.mts.map +0 -1
  365. package/dist/topic/index.cjs.map +0 -1
  366. package/dist/topic/index.d.cts.map +0 -1
  367. package/dist/topic/index.d.mts.map +0 -1
  368. package/dist/topic/index.mjs.map +0 -1
  369. package/dist/types-BlAkSuGI.d.cts.map +0 -1
  370. package/dist/types-aKksMEWL.d.mts.map +0 -1
@@ -1,26 +1,35 @@
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_auth = require("../auth.cjs");
4
+ const require_functions = require("../functions-ZH60FE7H.cjs");
5
+ const require_Endpoint = require("../Endpoint-D1L9qu5C.cjs");
6
+ const require_Queue = require("../Queue-Ckmudcm8.cjs");
7
+ const require_email = require("../email.cjs");
8
+ const require_database_kysely = require("../database/kysely.cjs");
9
+ const require_lazyAccessors = require("../lazyAccessors-hJKGv8Ay.cjs");
10
+ const require_Topic = require("../Topic-CkxOTrMv.cjs");
11
+ const require_HonoEndpointAdaptor = require("../HonoEndpointAdaptor-Cq99r9H7.cjs");
12
+ const require_processAudits = require("../processAudits-D_2W5x8k.cjs");
13
+ let _geekmidas_manifest = require("@geekmidas/manifest");
14
+ let _geekmidas_errors = require("@geekmidas/errors");
15
+ let _geekmidas_envkit = require("@geekmidas/envkit");
16
+ let _geekmidas_services = require("@geekmidas/services");
17
+ let hono = require("hono");
18
+ let _geekmidas_audit = require("@geekmidas/audit");
19
+ let _geekmidas_testkit_context = require("@geekmidas/testkit/context");
20
+ let msw = require("msw");
21
+ let node_crypto = require("node:crypto");
22
+ let _geekmidas_testkit_browser = require("@geekmidas/testkit/browser");
23
+ let _geekmidas_testkit_faker = require("@geekmidas/testkit/faker");
24
+ let _geekmidas_testkit_mailbox = require("@geekmidas/testkit/mailbox");
25
+ let _geekmidas_testkit_transactions = require("@geekmidas/testkit/transactions");
26
+ let msw_node = require("msw/node");
27
+ let vitest = require("vitest");
28
+ let node_fs = require("node:fs");
29
+ let node_tls = require("node:tls");
30
+ node_tls = require_rolldown_runtime.__toESM(node_tls, 1);
31
+ let node_url = require("node:url");
17
32
  //#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
33
  const MSW_HTTP_METHODS = [
25
34
  "get",
26
35
  "post",
@@ -52,8 +61,8 @@ function createMswHandlers(endpoints, options) {
52
61
  * Creates a fresh ServiceDiscovery and pre-registers all provided services.
53
62
  */
54
63
  function registerContext(id, ctxOptions) {
55
- const envParser = new __geekmidas_envkit.EnvironmentParser({});
56
- const serviceDiscovery = new __geekmidas_services.ServiceDiscovery(envParser);
64
+ const envParser = new _geekmidas_envkit.EnvironmentParser({});
65
+ const serviceDiscovery = new _geekmidas_services.ServiceDiscovery(envParser);
57
66
  const serviceDefs = [];
58
67
  if (ctxOptions.services) for (const [name, instance] of Object.entries(ctxOptions.services)) serviceDefs.push({
59
68
  serviceName: name,
@@ -68,7 +77,6 @@ function createMswHandlers(endpoints, options) {
68
77
  break;
69
78
  }
70
79
  }
71
- if (ctxOptions.publisher) serviceDefs.push(ctxOptions.publisher);
72
80
  if (ctxOptions.auditorStorage !== void 0) {
73
81
  for (const endpoint of endpoints) if (endpoint.auditorStorageService) {
74
82
  serviceDefs.push({
@@ -88,11 +96,11 @@ function createMswHandlers(endpoints, options) {
88
96
  const mswUrl = `${baseURL}${endpoint.route}`;
89
97
  const mswMethod = msw.http[method];
90
98
  handlers.push(mswMethod(mswUrl, async ({ request }) => {
91
- const contextId = request.headers.get(TEST_CONTEXT_HEADER);
99
+ const contextId = request.headers.get(_geekmidas_testkit_context.TEST_CONTEXT_HEADER);
92
100
  const ctx = contextId ? contexts.get(contextId) : void 0;
93
101
  if (!ctx) return new Response(JSON.stringify({
94
102
  error: "Missing or unknown test context ID",
95
- hint: `Set the '${TEST_CONTEXT_HEADER}' header to a registered context ID`
103
+ hint: `Set the '${_geekmidas_testkit_context.TEST_CONTEXT_HEADER}' header to a registered context ID`
96
104
  }), {
97
105
  status: 500,
98
106
  headers: { "content-type": "application/json" }
@@ -112,7 +120,6 @@ function createMswHandlers(endpoints, options) {
112
120
  registerContext
113
121
  };
114
122
  }
115
-
116
123
  //#endregion
117
124
  //#region src/endpoints/TestEndpointAdaptor.ts
118
125
  /**
@@ -132,8 +139,10 @@ function serializeCookie(name, value, options) {
132
139
  return cookieString;
133
140
  }
134
141
  var TestEndpointAdaptor = class TestEndpointAdaptor {
142
+ endpoint;
143
+ serviceDiscovery;
135
144
  static getDefaultServiceDiscover(_endpoint) {
136
- return __geekmidas_services.ServiceDiscovery.getInstance(new __geekmidas_envkit.EnvironmentParser({}));
145
+ return _geekmidas_services.ServiceDiscovery.getInstance(new _geekmidas_envkit.EnvironmentParser({}));
137
146
  }
138
147
  constructor(endpoint, serviceDiscovery = TestEndpointAdaptor.getDefaultServiceDiscover(endpoint)) {
139
148
  this.endpoint = endpoint;
@@ -154,7 +163,7 @@ var TestEndpointAdaptor = class TestEndpointAdaptor {
154
163
  method: this.endpoint.method
155
164
  });
156
165
  const rawDb = ctx.database;
157
- return (0, __geekmidas_services.runWithRequestContext)({
166
+ return (0, _geekmidas_services.runWithRequestContext)({
158
167
  logger,
159
168
  requestId,
160
169
  startTime
@@ -166,7 +175,7 @@ var TestEndpointAdaptor = class TestEndpointAdaptor {
166
175
  cookie,
167
176
  ...rawDb !== void 0 && { db: rawDb }
168
177
  });
169
- const isAuthorized = await this.endpoint.authorize({
178
+ if (!await this.endpoint.authorize({
170
179
  header,
171
180
  cookie,
172
181
  services: ctx.services,
@@ -176,10 +185,9 @@ var TestEndpointAdaptor = class TestEndpointAdaptor {
176
185
  body,
177
186
  query,
178
187
  params
179
- });
180
- if (!isAuthorized) {
188
+ })) {
181
189
  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.");
190
+ throw new _geekmidas_errors.ForbiddenError("Forbidden access to the endpoint", "You do not have permission to access this resource.");
183
191
  }
184
192
  const auditorStorage = ctx.auditorStorage;
185
193
  let auditContext;
@@ -199,24 +207,22 @@ var TestEndpointAdaptor = class TestEndpointAdaptor {
199
207
  } catch (error) {
200
208
  logger.error(error, "Failed to extract actor for audits");
201
209
  }
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
210
  auditContext = {
211
- auditor,
211
+ auditor: new _geekmidas_audit.DefaultAuditor({
212
+ actor,
213
+ storage: auditorStorage,
214
+ metadata: {
215
+ endpoint: this.endpoint.route,
216
+ method: this.endpoint.method
217
+ }
218
+ }),
212
219
  storage: auditorStorage
213
220
  };
214
221
  }
215
222
  const audits = this.endpoint.audits;
216
223
  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;
224
+ const { output, metadata } = await require_processAudits.executeWithAuditTransaction(auditContext, async (auditor) => {
225
+ const db = auditor?.getTransaction?.() ?? rawDb;
220
226
  const responseBuilder = new require_Endpoint.ResponseBuilder();
221
227
  const response = await this.endpoint.handler({
222
228
  body,
@@ -231,36 +237,33 @@ var TestEndpointAdaptor = class TestEndpointAdaptor {
231
237
  db
232
238
  }, responseBuilder);
233
239
  let data = response;
234
- let metadata$1 = responseBuilder.getMetadata();
240
+ let metadata = responseBuilder.getMetadata();
235
241
  if (require_Endpoint.Endpoint.hasMetadata(response)) {
236
242
  data = response.data;
237
- metadata$1 = response.metadata;
243
+ metadata = response.metadata;
238
244
  }
239
- const output$1 = await this.endpoint.parseOutput(data);
240
245
  return {
241
- output: output$1,
242
- metadata: metadata$1,
246
+ output: await this.endpoint.parseOutput(data),
247
+ metadata,
243
248
  responseBuilder
244
249
  };
245
- }, async (result$1, auditor) => {
250
+ }, async (result, auditor) => {
246
251
  if (!audits?.length) return;
247
252
  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);
253
+ if (audit.when && !audit.when(result.output)) continue;
254
+ const payload = audit.payload(result.output);
255
+ const entityId = audit.entityId?.(result.output);
251
256
  auditor.audit(audit.type, payload, {
252
257
  table: audit.table,
253
258
  entityId
254
259
  });
255
260
  }
256
261
  }, { 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);
262
+ await require_functions.publishConstructEvents(this.endpoint, output, this.serviceDiscovery, this.endpoint.logger, ctx.services);
260
263
  const headers = { ...metadata.headers || {} };
261
264
  if (metadata.cookies && metadata.cookies.size > 0) {
262
265
  const setCookieValues = [];
263
- for (const [name, cookie$1] of metadata.cookies.entries()) setCookieValues.push(serializeCookie(name, cookie$1.value, cookie$1.options));
266
+ for (const [name, cookie] of metadata.cookies.entries()) setCookieValues.push(serializeCookie(name, cookie.value, cookie.options));
264
267
  headers["set-cookie"] = setCookieValues;
265
268
  }
266
269
  return {
@@ -271,16 +274,16 @@ var TestEndpointAdaptor = class TestEndpointAdaptor {
271
274
  });
272
275
  }
273
276
  async request(ctx) {
274
- const response = await this.fullRequest(ctx);
275
- return response.body;
277
+ return (await this.fullRequest(ctx)).body;
276
278
  }
277
279
  };
278
-
279
280
  //#endregion
280
281
  //#region src/functions/TestFunctionAdaptor.ts
281
282
  var TestFunctionAdaptor = class TestFunctionAdaptor {
283
+ fn;
284
+ serviceDiscovery;
282
285
  static getDefaultServiceDiscovery(_fn) {
283
- return __geekmidas_services.ServiceDiscovery.getInstance(new __geekmidas_envkit.EnvironmentParser({}));
286
+ return _geekmidas_services.ServiceDiscovery.getInstance(new _geekmidas_envkit.EnvironmentParser({}));
284
287
  }
285
288
  constructor(fn, serviceDiscovery = TestFunctionAdaptor.getDefaultServiceDiscovery(fn)) {
286
289
  this.fn = fn;
@@ -294,16 +297,12 @@ var TestFunctionAdaptor = class TestFunctionAdaptor {
294
297
  else services = await this.serviceDiscovery.register(this.fn.services);
295
298
  let db;
296
299
  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
- }
300
+ else if (this.fn.databaseService) db = (await this.serviceDiscovery.register([this.fn.databaseService]))[this.fn.databaseService.serviceName];
301
301
  let auditor;
302
302
  if ("auditor" in ctx && ctx.auditor !== void 0) auditor = ctx.auditor;
303
303
  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({
304
+ const storage = (await this.serviceDiscovery.register([this.fn.auditorStorageService]))[this.fn.auditorStorageService.serviceName];
305
+ auditor = new _geekmidas_audit.DefaultAuditor({
307
306
  actor: {
308
307
  id: "system",
309
308
  type: "system"
@@ -316,11 +315,10 @@ var TestFunctionAdaptor = class TestFunctionAdaptor {
316
315
  });
317
316
  }
318
317
  const requestId = `test-${Date.now()}`;
319
- const startTime = Date.now();
320
- return (0, __geekmidas_services.runWithRequestContext)({
318
+ return (0, _geekmidas_services.runWithRequestContext)({
321
319
  logger,
322
320
  requestId,
323
- startTime
321
+ startTime: Date.now()
324
322
  }, async () => {
325
323
  const response = await this.fn.fn({
326
324
  input: parsedInput,
@@ -337,12 +335,11 @@ var TestFunctionAdaptor = class TestFunctionAdaptor {
337
335
  await auditor.flush();
338
336
  }
339
337
  }
340
- await require_lazyAccessors.publishEvents(logger, this.serviceDiscovery, this.fn.events, output, this.fn.publisherService);
338
+ await require_functions.publishEvents(logger, this.serviceDiscovery, this.fn.events, output, services);
341
339
  return output;
342
340
  });
343
341
  }
344
342
  };
345
-
346
343
  //#endregion
347
344
  //#region src/queue/TestQueueAdaptor.ts
348
345
  /**
@@ -355,8 +352,10 @@ var TestFunctionAdaptor = class TestFunctionAdaptor {
355
352
  * await adapter.invoke({ messages: [{ orderId: '123' }] });
356
353
  */
357
354
  var TestQueueAdaptor = class TestQueueAdaptor {
355
+ queue;
356
+ serviceDiscovery;
358
357
  static getDefaultServiceDiscovery() {
359
- return __geekmidas_services.ServiceDiscovery.getInstance(new __geekmidas_envkit.EnvironmentParser({}));
358
+ return _geekmidas_services.ServiceDiscovery.getInstance(new _geekmidas_envkit.EnvironmentParser({}));
360
359
  }
361
360
  constructor(queue, serviceDiscovery = TestQueueAdaptor.getDefaultServiceDiscovery()) {
362
361
  this.queue = queue;
@@ -366,11 +365,10 @@ var TestQueueAdaptor = class TestQueueAdaptor {
366
365
  const logger = this.queue.logger.child({ test: true });
367
366
  const services = request.services ?? await this.serviceDiscovery.register(this.queue.services);
368
367
  const requestId = `test-${Date.now()}`;
369
- const startTime = Date.now();
370
- return (0, __geekmidas_services.runWithRequestContext)({
368
+ return (0, _geekmidas_services.runWithRequestContext)({
371
369
  logger,
372
370
  requestId,
373
- startTime
371
+ startTime: Date.now()
374
372
  }, () => this.queue.handler({
375
373
  messages: request.messages,
376
374
  services,
@@ -378,12 +376,13 @@ var TestQueueAdaptor = class TestQueueAdaptor {
378
376
  }));
379
377
  }
380
378
  };
381
-
382
379
  //#endregion
383
380
  //#region src/subscribers/TestSubscriberAdaptor.ts
384
381
  var TestSubscriberAdaptor = class TestSubscriberAdaptor {
382
+ subscriber;
383
+ serviceDiscovery;
385
384
  static getDefaultServiceDiscovery() {
386
- return __geekmidas_services.ServiceDiscovery.getInstance(new __geekmidas_envkit.EnvironmentParser({}));
385
+ return _geekmidas_services.ServiceDiscovery.getInstance(new _geekmidas_envkit.EnvironmentParser({}));
387
386
  }
388
387
  constructor(subscriber, serviceDiscovery = TestSubscriberAdaptor.getDefaultServiceDiscovery()) {
389
388
  this.subscriber = subscriber;
@@ -397,11 +396,10 @@ var TestSubscriberAdaptor = class TestSubscriberAdaptor {
397
396
  const filteredEvents = this.filterEvents(request.events);
398
397
  if (filteredEvents.length === 0) return { batchItemFailures: [] };
399
398
  const requestId = `test-${Date.now()}`;
400
- const startTime = Date.now();
401
- return (0, __geekmidas_services.runWithRequestContext)({
399
+ return (0, _geekmidas_services.runWithRequestContext)({
402
400
  logger,
403
401
  requestId,
404
- startTime
402
+ startTime: Date.now()
405
403
  }, async () => {
406
404
  const result = await this.subscriber.handler({
407
405
  events: filteredEvents,
@@ -414,7 +412,6 @@ var TestSubscriberAdaptor = class TestSubscriberAdaptor {
414
412
  if (validationResult.issues) throw new Error("Subscriber output validation failed");
415
413
  output = validationResult.value;
416
414
  }
417
- await require_lazyAccessors.publishEvents(logger, this.serviceDiscovery, this.subscriber.events, output, this.subscriber.publisherService);
418
415
  return output;
419
416
  });
420
417
  }
@@ -423,12 +420,443 @@ var TestSubscriberAdaptor = class TestSubscriberAdaptor {
423
420
  return events.filter((event) => this.subscriber.subscribedEvents.includes(event.type));
424
421
  }
425
422
  };
426
-
427
423
  //#endregion
428
- exports.TEST_CONTEXT_HEADER = TEST_CONTEXT_HEADER;
424
+ //#region src/testing/manifest.ts
425
+ /**
426
+ * The test manifest: what `gkm test` knows about an app, written down for the
427
+ * suite it starts.
428
+ *
429
+ * `gkm test` discovers the constructs, reconciles the test stage and resolves
430
+ * its environment — then, until this existed, threw all of it away and left a
431
+ * test to declare it again by hand. The manifest keeps it: which construct and
432
+ * endpoint is exported where, and the environment the test stage resolved,
433
+ * under the keys the constructs themselves derive. A feature test is built from
434
+ * it, so nothing a test says can drift from what the app declares.
435
+ */
436
+ /** The environment variable `gkm test` names the manifest in. */
437
+ const TEST_MANIFEST_ENV = "GKM_TEST_MANIFEST";
438
+ /**
439
+ * Read a test manifest: from a path, a `file:` URL, or — given nothing — the
440
+ * one `gkm test` named in `GKM_TEST_MANIFEST`.
441
+ */
442
+ function loadTestManifest(from) {
443
+ const location = from ?? process.env["GKM_TEST_MANIFEST"];
444
+ if (!location) throw new NoTestManifest();
445
+ trustLocalEdge();
446
+ const path = location instanceof URL || location.startsWith("file:") ? (0, node_url.fileURLToPath)(location) : location;
447
+ return JSON.parse((0, node_fs.readFileSync)(path, "utf-8"));
448
+ }
449
+ let trusted = false;
450
+ /**
451
+ * Trust the local edge's certificate authority in this thread.
452
+ *
453
+ * `NODE_EXTRA_CA_CERTS` does it for a process started with it — which a
454
+ * suite started by `gkm test` is, and one started by plain `vitest` or an
455
+ * editor is not: its setup only learns the path once Vitest is running, and a
456
+ * worker *thread* shares that process and keeps a TLS store of its own. Every
457
+ * feature test loads the manifest, so this is the one place each worker passes
458
+ * through.
459
+ */
460
+ function trustLocalEdge() {
461
+ const certificate = process.env.NODE_EXTRA_CA_CERTS;
462
+ if (trusted || !certificate || !(0, node_fs.existsSync)(certificate)) return;
463
+ trusted = true;
464
+ node_tls.default.setDefaultCACertificates([...node_tls.default.getCACertificates("default"), (0, node_fs.readFileSync)(certificate, "utf-8")]);
465
+ }
466
+ /** A feature test ran without a manifest to build itself from. */
467
+ var NoTestManifest = class extends Error {
468
+ constructor() {
469
+ 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}.`);
470
+ this.name = "NoTestManifest";
471
+ }
472
+ };
473
+ //#endregion
474
+ //#region src/testing/featureTest.ts
475
+ /**
476
+ * `featureTest`: an app, driven the way it runs deployed.
477
+ *
478
+ * A browser signs in and calls the API; the API calls the auth server; each
479
+ * over its URL, each database in its own transaction. Nothing runs as a server:
480
+ * every URL an app's constructs answer on is served in-process through MSW,
481
+ * from the real handler, for the test that made the request. Everything else
482
+ * with a real local equivalent — Postgres, Mailpit, MinIO — is used directly.
483
+ *
484
+ * It is built from the test manifest `gkm test` writes — the constructs and
485
+ * endpoints the app exports, and the environment the test stage resolved — so
486
+ * a test declares none of it. `gkm test` also generates the configured `it`
487
+ * and a `Browser` with a typed client per surface:
488
+ *
489
+ * ```ts
490
+ * import { it } from '#test';
491
+ *
492
+ * it('shows the signed-in user their profile', async ({ browser, mailbox }) => {
493
+ * await browser.auth.signIn.magicLink({ email: 'ada@shop.test' });
494
+ * await browser.visit((await mailbox('ada@shop.test').last()).link!);
495
+ * expect(await browser.api.get('/profile')).toMatchObject({ email: 'ada@shop.test' });
496
+ * });
497
+ * ```
498
+ */
499
+ /** Every test in flight in this process, by id. */
500
+ const contexts = /* @__PURE__ */ new Map();
501
+ /** Databases already resolving to test transactions — patched once each. */
502
+ const bound = /* @__PURE__ */ new WeakSet();
503
+ function featureTest(options = {}) {
504
+ const manifest = options.manifest ?? loadTestManifest();
505
+ const BrowserClass = options.browser ?? _geekmidas_testkit_browser.Browser;
506
+ let app;
507
+ let factoryDatabases = [];
508
+ let owned = [];
509
+ let network;
510
+ let restoreFetch = () => {};
511
+ (0, vitest.beforeAll)(async () => {
512
+ app = await load(manifest, options.modules ?? {});
513
+ owned = ownDatabases(app, manifest);
514
+ factoryDatabases = databasesFor(options.factories ?? {}, owned);
515
+ for (const database of app.databases) bindToTests(database);
516
+ 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)));
517
+ network.listen({ onUnhandledRequest(request, print) {
518
+ if (isLocal(new URL(request.url))) return;
519
+ print.error();
520
+ } });
521
+ restoreFetch = (0, _geekmidas_testkit_context.installContextFetch)();
522
+ });
523
+ (0, vitest.afterAll)(() => {
524
+ restoreFetch();
525
+ network?.close();
526
+ });
527
+ const run = (name, fn) => async () => {
528
+ const id = (0, node_crypto.randomUUID)();
529
+ _geekmidas_testkit_faker.faker.seed(seedOf(name));
530
+ const state = {
531
+ transactions: new _geekmidas_testkit_transactions.TransactionRegistry(),
532
+ discovery: new _geekmidas_services.ServiceDiscovery(app.envParser),
533
+ surfaces: /* @__PURE__ */ new Map(),
534
+ auth: /* @__PURE__ */ new Map(),
535
+ addresses: /* @__PURE__ */ new Set(),
536
+ published: /* @__PURE__ */ new Map()
537
+ };
538
+ const readMail = app.readMail;
539
+ if (readMail) state.mailbox = (address) => {
540
+ state.addresses.add(address);
541
+ return readMail(address);
542
+ };
543
+ contexts.set(id, state);
544
+ await state.discovery.register(recorders(app.channels, state));
545
+ try {
546
+ await (0, _geekmidas_testkit_context.runInTestContext)(id, async () => {
547
+ const browser = new BrowserClass();
548
+ const restore = browser.install();
549
+ try {
550
+ const transaction = (database) => state.transactions.get(database.id, urlOf(database, app.envParser), database.clientConfig);
551
+ const db = { get: (name) => {
552
+ const database = owned.find((candidate) => candidate.service.serviceName === name);
553
+ if (!database) throw new UnknownDatabase(name, owned.map((candidate) => candidate.service.serviceName));
554
+ return transaction(database);
555
+ } };
556
+ const built = /* @__PURE__ */ new Map();
557
+ await fn({
558
+ browser,
559
+ db,
560
+ factories: { get: (name) => {
561
+ const database = factoryDatabases.find(([candidate]) => candidate === name)?.[1];
562
+ if (!database) throw new UnknownFactory(name, factoryDatabases.map(([candidate]) => candidate));
563
+ let factory = built.get(name);
564
+ if (!factory) {
565
+ factory = transaction(database).then(options.factories[name]);
566
+ built.set(name, factory);
567
+ }
568
+ return factory;
569
+ } },
570
+ faker: _geekmidas_testkit_faker.faker,
571
+ mailbox: (address) => {
572
+ if (!state.mailbox) throw new NoInbox();
573
+ return state.mailbox(address);
574
+ },
575
+ published: (channel) => [...state.published.get(channel.id) ?? []],
576
+ subscriber: (subscriber) => new TestSubscriberAdaptor(subscriber, state.discovery),
577
+ queue: (queue) => new TestQueueAdaptor(queue, state.discovery)
578
+ });
579
+ } finally {
580
+ restore();
581
+ }
582
+ });
583
+ } finally {
584
+ contexts.delete(id);
585
+ await Promise.all([state.transactions.rollbackAll(), ...[...state.addresses].map((address) => app.readMail?.(address).clear())]);
586
+ }
587
+ };
588
+ const it = ((name, fn, timeout) => (0, vitest.test)(name, run(name, fn), timeout));
589
+ it.only = (name, fn, timeout) => vitest.test.only(name, run(name, fn), timeout);
590
+ it.skip = (name, fn, timeout) => vitest.test.skip(name, run(name, fn), timeout);
591
+ return it;
592
+ }
593
+ /**
594
+ * A test's faker seed, from its name: the same test draws the same data on
595
+ * every run, and two tests draw different data.
596
+ */
597
+ function seedOf(name) {
598
+ let hash = 0;
599
+ for (const char of name) hash = Math.imul(hash, 31) + char.charCodeAt(0) | 0;
600
+ return hash >>> 0;
601
+ }
602
+ /**
603
+ * Import what the manifest points at.
604
+ *
605
+ * The same modules the app runs, so a construct here *is* the app's construct —
606
+ * the one its endpoints were built from — never a copy declared again.
607
+ */
608
+ async function load(manifest, modules) {
609
+ const envParser = new _geekmidas_envkit.EnvironmentParser({ ...manifest.env });
610
+ const imported = async ({ file, export: name }) => (modules[file] ?? await import(file))[name];
611
+ const constructs = await Promise.all(Object.values(manifest.constructs).map(({ source }) => imported(source)));
612
+ const endpoints = (await Promise.all(manifest.endpoints.map(({ source }) => imported(source)))).filter((value) => require_Endpoint.Endpoint.isEndpoint(value));
613
+ const unique = (values) => [...new Set(values)];
614
+ const databases = unique(constructs.filter((value) => value instanceof require_database_kysely.KyselyDatabase));
615
+ const auths = unique(constructs.filter((value) => value instanceof require_auth.BetterAuth));
616
+ const emails = unique(constructs.filter((value) => value instanceof require_email.Email));
617
+ const channels = unique(constructs.filter((value) => value instanceof require_Topic.Topic || value instanceof require_Queue.Queue));
618
+ const inbox = emails.map((email) => manifest.env[(0, _geekmidas_manifest.provideKey)(email.id, "inboxUrl")]).find(Boolean);
619
+ return {
620
+ envParser,
621
+ endpoints,
622
+ databases,
623
+ auths,
624
+ emails,
625
+ channels,
626
+ ...inbox ? { readMail: (0, _geekmidas_testkit_mailbox.createMailbox)({ inbox }) } : {}
627
+ };
628
+ }
629
+ /**
630
+ * A publisher that records rather than sends, under the name a topic or queue
631
+ * is injected by — `services.users` — which is also the one `.event(users, …)`
632
+ * publishes through.
633
+ */
634
+ function recorders(channels, state) {
635
+ return channels.map((channel) => {
636
+ const publisher = { async publish(messages) {
637
+ state.published.set(channel.id, [...state.published.get(channel.id) ?? [], ...messages.map(({ type, payload }) => ({
638
+ type,
639
+ payload
640
+ }))]);
641
+ } };
642
+ return {
643
+ serviceName: channel.service.serviceName,
644
+ register: () => publisher
645
+ };
646
+ });
647
+ }
648
+ /**
649
+ * The databases a test is handed: the app's own. A schema tenant an auth server
650
+ * owns is reached through that server, as the app reaches it, and a reader is
651
+ * the same database through a read-only role — neither is another database to
652
+ * test against.
653
+ */
654
+ function ownDatabases(app, manifest) {
655
+ const owners = new Set(app.auths.map((auth) => auth.databaseId));
656
+ return app.databases.filter((database) => !owners.has(database.id) && manifest.constructs[database.id]?.kind !== "database-reader");
657
+ }
658
+ /** Each factory's database, found by the service name it is keyed by. */
659
+ function databasesFor(factories, databases) {
660
+ return Object.keys(factories).map((name) => {
661
+ const database = databases.find((candidate) => candidate.service.serviceName === name);
662
+ if (!database) throw new UnknownFactory(name, databases.map((candidate) => candidate.service.serviceName));
663
+ return [name, database];
664
+ });
665
+ }
666
+ /**
667
+ * Make a database resolve, inside a test, to that test's transaction.
668
+ *
669
+ * Everything reaches a database through its service — an endpoint through
670
+ * service discovery, the auth server through its tenant directly — so this is
671
+ * the one place a test's connection can be handed over. Outside a test it is
672
+ * the database it always was.
673
+ */
674
+ function bindToTests(database) {
675
+ if (bound.has(database)) return;
676
+ bound.add(database);
677
+ const service = database.service;
678
+ const register = service.register;
679
+ service.register = (options) => {
680
+ const context = (0, _geekmidas_testkit_context.currentTestContext)();
681
+ const state = context && contexts.get(context.id);
682
+ if (!state) return register(options);
683
+ return state.transactions.get(database.id, urlOf(database, options.envParser), database.clientConfig);
684
+ };
685
+ }
686
+ function urlOf(database, envParser) {
687
+ return envParser.create((get) => ({ url: get((0, _geekmidas_manifest.provideKey)(database.id, "url")).string() })).parse().url;
688
+ }
689
+ /** Each surface's endpoints, served at its URL for the test that asked. */
690
+ function surfaceHandlers(endpoints, env) {
691
+ const bySurface = /* @__PURE__ */ new Map();
692
+ for (const endpoint of endpoints) {
693
+ const surface = endpoint.surface?.id;
694
+ if (!surface) continue;
695
+ bySurface.set(surface, [...bySurface.get(surface) ?? [], endpoint]);
696
+ }
697
+ return [...bySurface].flatMap(([surface, served]) => {
698
+ const base = env[(0, _geekmidas_manifest.provideKey)(surface, "url")];
699
+ if (!base) return [];
700
+ return msw.http.all(`${trim(base)}/*`, ({ request }) => serve(request, async (state) => {
701
+ let app = state.surfaces.get(surface);
702
+ if (!app) {
703
+ app = Promise.resolve().then(() => {
704
+ const hono$1 = new hono.Hono();
705
+ require_HonoEndpointAdaptor.HonoEndpoint.addRoutes(served, state.discovery, hono$1);
706
+ return hono$1;
707
+ });
708
+ state.surfaces.set(surface, app);
709
+ }
710
+ return (await app).fetch(request);
711
+ }));
712
+ });
713
+ }
714
+ /**
715
+ * An external API's app fake, answering at the URL the test stage resolved for
716
+ * it — so a handler that calls Polar calls the fake, and the test sets up
717
+ * nothing.
718
+ *
719
+ * Not per test, unlike a surface: a fake stands in for somebody else's server,
720
+ * which no test's transaction reaches. An image fake has no handler here — its
721
+ * container answers on localhost, which is let through.
722
+ */
723
+ function fakeHandler(id, fake, env) {
724
+ const base = env[(0, _geekmidas_manifest.provideKey)(id, "url")];
725
+ if (fake.kind !== "app" || !base) return [];
726
+ return [msw.http.all(`${trim(base)}/*`, ({ request }) => fake.handler.fetch(request))];
727
+ }
728
+ /** An auth server, served at its URL, on the transaction of the test that asked. */
729
+ function authHandler(auth, env, envParser) {
730
+ const base = trim(env[(0, _geekmidas_manifest.provideKey)(auth.id, "url")] ?? "");
731
+ return msw.http.all(`${base}/*`, ({ request }) => serve(request, async (state) => {
732
+ let app = state.auth.get(auth);
733
+ if (!app) {
734
+ app = auth.server({
735
+ envParser,
736
+ context: _geekmidas_services.serviceContext
737
+ }).then(({ app }) => app);
738
+ state.auth.set(auth, app);
739
+ }
740
+ return (await app).fetch(request);
741
+ }));
742
+ }
743
+ /** Handle a request as the server side of the test it was made for. */
744
+ async function serve(request, handle) {
745
+ const id = (0, _geekmidas_testkit_context.testContextOf)(request);
746
+ const state = id ? contexts.get(id) : void 0;
747
+ if (!id || !state) throw new UnknownTestContext(request.url, id);
748
+ return (0, _geekmidas_testkit_context.runAsServer)(id, () => handle(state));
749
+ }
750
+ function trim(url) {
751
+ return url.replace(/\/$/, "");
752
+ }
753
+ function isLocal(url) {
754
+ return url.hostname === "localhost" || url.hostname === "127.0.0.1" || url.hostname.endsWith(".localhost");
755
+ }
756
+ /**
757
+ * Sign a test's browser in the way a person does: ask the auth server for a
758
+ * magic link, open the email it sent, follow the link.
759
+ *
760
+ * What the generated `browser.signIn(email)` calls. The address's mail is
761
+ * cleared first — so the link is this request's, not one an earlier test left
762
+ * — and cleared again after the test, like any address a test reads. Returns
763
+ * the session the auth server then reports, as better-auth hands it back.
764
+ */
765
+ async function signInWithMagicLink(browser, auth, email = freshAddress()) {
766
+ const context = (0, _geekmidas_testkit_context.currentTestContext)();
767
+ const state = context && contexts.get(context.id);
768
+ if (!state) throw new UnknownTestContext("signIn", context?.id);
769
+ if (!state.mailbox) throw new NoInbox();
770
+ const inbox = state.mailbox(email);
771
+ await inbox.clear();
772
+ const requested = await auth.signIn.magicLink({ email });
773
+ if (requested.error) throw new SignInFailed(email, `the auth server refused the magic link: ${requested.error.message ?? "no reason given"}`);
774
+ const mail = await inbox.last();
775
+ if (!mail.link) throw new SignInFailed(email, "its email held no link");
776
+ await browser.visit(mail.link);
777
+ const { data } = await auth.getSession();
778
+ if (!data) throw new SignInFailed(email, "the auth server reported no session after the link was opened");
779
+ return data;
780
+ }
781
+ /**
782
+ * An address nobody else signs in as — what `browser.signIn()` uses when the
783
+ * test does not care who it is.
784
+ *
785
+ * Unique rather than only seeded: tests in other files run at the same time,
786
+ * against the same Mailpit and the same unique columns, and a seeded address
787
+ * repeats wherever two tests share a name. The readable half is the seeded
788
+ * faker's, so a failure still names somebody.
789
+ */
790
+ function freshAddress() {
791
+ return `${_geekmidas_testkit_faker.faker.internet.username().toLowerCase().replace(/[^a-z0-9]/g, "")}.${(0, node_crypto.randomUUID)().slice(0, 8)}@example.test`;
792
+ }
793
+ /** `browser.signIn` finished without a session. */
794
+ var SignInFailed = class extends Error {
795
+ email;
796
+ reason;
797
+ constructor(email, reason) {
798
+ super(`Signing ${email} in failed: ${reason}.`);
799
+ this.email = email;
800
+ this.reason = reason;
801
+ this.name = "SignInFailed";
802
+ }
803
+ };
804
+ /** A request reached an in-process server without a test to belong to. */
805
+ var UnknownTestContext = class extends Error {
806
+ url;
807
+ id;
808
+ constructor(url, id) {
809
+ 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.`);
810
+ this.url = url;
811
+ this.id = id;
812
+ this.name = "UnknownTestContext";
813
+ }
814
+ };
815
+ /** `mailbox` was used in an app that declares no Email construct. */
816
+ var NoInbox = class extends Error {
817
+ constructor() {
818
+ 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.");
819
+ this.name = "NoInbox";
820
+ }
821
+ };
822
+ /** `db.get(name)` named no database the test is handed. */
823
+ var UnknownDatabase = class extends Error {
824
+ database;
825
+ known;
826
+ constructor(database, known) {
827
+ 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.");
828
+ this.database = database;
829
+ this.known = known;
830
+ this.name = "UnknownDatabase";
831
+ }
832
+ };
833
+ /** A factory keyed by a service name no database the app declares has. */
834
+ var UnknownFactory = class extends Error {
835
+ factory;
836
+ known;
837
+ constructor(factory, known) {
838
+ 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.`);
839
+ this.factory = factory;
840
+ this.known = known;
841
+ this.name = "UnknownFactory";
842
+ }
843
+ };
844
+ //#endregion
845
+ exports.NoInbox = NoInbox;
846
+ exports.NoTestManifest = NoTestManifest;
847
+ exports.SignInFailed = SignInFailed;
848
+ exports.TEST_CONTEXT_HEADER = _geekmidas_testkit_context.TEST_CONTEXT_HEADER;
849
+ exports.TEST_MANIFEST_ENV = TEST_MANIFEST_ENV;
429
850
  exports.TestEndpointAdaptor = TestEndpointAdaptor;
430
851
  exports.TestFunctionAdaptor = TestFunctionAdaptor;
431
852
  exports.TestQueueAdaptor = TestQueueAdaptor;
432
853
  exports.TestSubscriberAdaptor = TestSubscriberAdaptor;
854
+ exports.UnknownDatabase = UnknownDatabase;
855
+ exports.UnknownFactory = UnknownFactory;
856
+ exports.UnknownTestContext = UnknownTestContext;
433
857
  exports.createMswHandlers = createMswHandlers;
858
+ exports.featureTest = featureTest;
859
+ exports.loadTestManifest = loadTestManifest;
860
+ exports.signInWithMagicLink = signInWithMagicLink;
861
+
434
862
  //# sourceMappingURL=testing.cjs.map