@geekmidas/constructs 10.0.0-alpha.15 → 10.0.0-alpha.150

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 (454) hide show
  1. package/README.md +222 -158
  2. package/dist/Construct-127M7yrl.d.cts +231 -0
  3. package/dist/Construct-127M7yrl.d.cts.map +1 -0
  4. package/dist/{Construct-BeYVu_QF.mjs → Construct-CGuc_Ijk.mjs} +8 -9
  5. package/dist/Construct-CGuc_Ijk.mjs.map +1 -0
  6. package/dist/{Construct-DqdlARxq.cjs → Construct-DorKS0Ua.cjs} +8 -9
  7. package/dist/Construct-DorKS0Ua.cjs.map +1 -0
  8. package/dist/Construct-DySlwh8o.d.mts +231 -0
  9. package/dist/Construct-DySlwh8o.d.mts.map +1 -0
  10. package/dist/{Cron-DKqnnTdH.d.cts → Cron-D8mB_cPX.d.mts} +16 -9
  11. package/dist/Cron-D8mB_cPX.d.mts.map +1 -0
  12. package/dist/{Cron-SyqS5oWJ.d.mts → Cron-D_sfaMGz.d.cts} +16 -9
  13. package/dist/Cron-D_sfaMGz.d.cts.map +1 -0
  14. package/dist/{CronBuilder-D_0HNBTr.mjs → CronBuilder-BJ5LoadF.mjs} +28 -11
  15. package/dist/CronBuilder-BJ5LoadF.mjs.map +1 -0
  16. package/dist/{CronBuilder-BdnI6lxF.cjs → CronBuilder-B_NSP-Y5.cjs} +27 -10
  17. package/dist/CronBuilder-B_NSP-Y5.cjs.map +1 -0
  18. package/dist/CronBuilder-C91MVLSr.d.cts +47 -0
  19. package/dist/CronBuilder-C91MVLSr.d.cts.map +1 -0
  20. package/dist/CronBuilder-Cmajva3g.d.mts +47 -0
  21. package/dist/CronBuilder-Cmajva3g.d.mts.map +1 -0
  22. package/dist/Endpoint-52z1P0Ue.cjs +581 -0
  23. package/dist/Endpoint-52z1P0Ue.cjs.map +1 -0
  24. package/dist/{Endpoint-DuT4TEEq.d.mts → Endpoint-BbHh3Qoc.d.mts} +124 -43
  25. package/dist/Endpoint-BbHh3Qoc.d.mts.map +1 -0
  26. package/dist/{Endpoint-C6yyHpRS.d.cts → Endpoint-YYwjqtS1.d.cts} +122 -41
  27. package/dist/Endpoint-YYwjqtS1.d.cts.map +1 -0
  28. package/dist/Endpoint-sUOU7uLx.mjs +552 -0
  29. package/dist/Endpoint-sUOU7uLx.mjs.map +1 -0
  30. package/dist/{EndpointFactory-Bm3aKRdV.mjs → EndpointFactory-Bzi9Sl7r.mjs} +269 -53
  31. package/dist/EndpointFactory-Bzi9Sl7r.mjs.map +1 -0
  32. package/dist/{EndpointFactory-CLvWuHyt.cjs → EndpointFactory-Cf_Cs1ym.cjs} +309 -51
  33. package/dist/EndpointFactory-Cf_Cs1ym.cjs.map +1 -0
  34. package/dist/{index-BPSZ_Lp_.d.cts → EndpointFactory-Hh1r6J_C.d.cts} +187 -104
  35. package/dist/EndpointFactory-Hh1r6J_C.d.cts.map +1 -0
  36. package/dist/{index-BoZ-iisU.d.mts → EndpointFactory-qcLzi4f-.d.mts} +188 -105
  37. package/dist/EndpointFactory-qcLzi4f-.d.mts.map +1 -0
  38. package/dist/Function-BIEsY0Hm.d.cts +76 -0
  39. package/dist/Function-BIEsY0Hm.d.cts.map +1 -0
  40. package/dist/Function-DfMzTGS4.d.mts +76 -0
  41. package/dist/Function-DfMzTGS4.d.mts.map +1 -0
  42. package/dist/{HonoEndpointAdaptor-92zavCsV.cjs → HonoEndpointAdaptor-BXBdb2Bt.cjs} +79 -31
  43. package/dist/HonoEndpointAdaptor-BXBdb2Bt.cjs.map +1 -0
  44. package/dist/{HonoEndpointAdaptor-yYaU7jVJ.mjs → HonoEndpointAdaptor-DR3j7S35.mjs} +76 -28
  45. package/dist/HonoEndpointAdaptor-DR3j7S35.mjs.map +1 -0
  46. package/dist/ObjectSubscriberBuilder-Cv8C7yS1.d.mts +129 -0
  47. package/dist/ObjectSubscriberBuilder-Cv8C7yS1.d.mts.map +1 -0
  48. package/dist/ObjectSubscriberBuilder-LWkey_oq.d.cts +129 -0
  49. package/dist/ObjectSubscriberBuilder-LWkey_oq.d.cts.map +1 -0
  50. package/dist/ProcessorBuilder-CwfP-M33.d.mts +216 -0
  51. package/dist/ProcessorBuilder-CwfP-M33.d.mts.map +1 -0
  52. package/dist/ProcessorBuilder-_jdZlbfW.d.cts +216 -0
  53. package/dist/ProcessorBuilder-_jdZlbfW.d.cts.map +1 -0
  54. package/dist/{Queue-D9X6OoON.d.mts → Queue-BnK3UH8r.d.mts} +42 -41
  55. package/dist/Queue-BnK3UH8r.d.mts.map +1 -0
  56. package/dist/{Queue-DYPB2KWL.d.cts → Queue-C4rijiM7.d.cts} +43 -42
  57. package/dist/Queue-C4rijiM7.d.cts.map +1 -0
  58. package/dist/Queue-D4Iaidrs.cjs +109 -0
  59. package/dist/Queue-D4Iaidrs.cjs.map +1 -0
  60. package/dist/Queue-u8w8_HpE.mjs +104 -0
  61. package/dist/Queue-u8w8_HpE.mjs.map +1 -0
  62. package/dist/QueueBuilder-2wP5lEC8.mjs +118 -0
  63. package/dist/QueueBuilder-2wP5lEC8.mjs.map +1 -0
  64. package/dist/QueueBuilder-BxsZ9o5z.cjs +135 -0
  65. package/dist/QueueBuilder-BxsZ9o5z.cjs.map +1 -0
  66. package/dist/QueueBuilder-DmwFtLzQ.d.mts +75 -0
  67. package/dist/QueueBuilder-DmwFtLzQ.d.mts.map +1 -0
  68. package/dist/QueueBuilder-SQli59An.d.cts +75 -0
  69. package/dist/QueueBuilder-SQli59An.d.cts.map +1 -0
  70. package/dist/Subscriber-5rCX1Nph.d.cts +83 -0
  71. package/dist/Subscriber-5rCX1Nph.d.cts.map +1 -0
  72. package/dist/Subscriber-CW_Dl-YR.d.mts +83 -0
  73. package/dist/Subscriber-CW_Dl-YR.d.mts.map +1 -0
  74. package/dist/SubscriberBuilder-BL_GTcwh.mjs +237 -0
  75. package/dist/SubscriberBuilder-BL_GTcwh.mjs.map +1 -0
  76. package/dist/SubscriberBuilder-CWzKwX1p.cjs +260 -0
  77. package/dist/SubscriberBuilder-CWzKwX1p.cjs.map +1 -0
  78. package/dist/Topic-DN2gYJ-p.mjs +99 -0
  79. package/dist/Topic-DN2gYJ-p.mjs.map +1 -0
  80. package/dist/Topic-Dp9Q7Lj2.cjs +104 -0
  81. package/dist/Topic-Dp9Q7Lj2.cjs.map +1 -0
  82. package/dist/adaptors/aws.cjs +134 -160
  83. package/dist/adaptors/aws.cjs.map +1 -1
  84. package/dist/adaptors/aws.d.cts +57 -48
  85. package/dist/adaptors/aws.d.cts.map +1 -1
  86. package/dist/adaptors/aws.d.mts +58 -49
  87. package/dist/adaptors/aws.d.mts.map +1 -1
  88. package/dist/adaptors/aws.mjs +130 -157
  89. package/dist/adaptors/aws.mjs.map +1 -1
  90. package/dist/adaptors/hono.cjs +1 -1
  91. package/dist/adaptors/hono.d.cts +5 -6
  92. package/dist/adaptors/hono.d.cts.map +1 -1
  93. package/dist/adaptors/hono.d.mts +6 -7
  94. package/dist/adaptors/hono.d.mts.map +1 -1
  95. package/dist/adaptors/hono.mjs +1 -1
  96. package/dist/adaptors/testing.cjs +955 -38
  97. package/dist/adaptors/testing.cjs.map +1 -1
  98. package/dist/adaptors/testing.d.cts +437 -39
  99. package/dist/adaptors/testing.d.cts.map +1 -1
  100. package/dist/adaptors/testing.d.mts +436 -38
  101. package/dist/adaptors/testing.d.mts.map +1 -1
  102. package/dist/adaptors/testing.mjs +929 -34
  103. package/dist/adaptors/testing.mjs.map +1 -1
  104. package/dist/auth-BqWz2JxC.d.cts +274 -0
  105. package/dist/auth-BqWz2JxC.d.cts.map +1 -0
  106. package/dist/auth-DnB9H9KL.d.mts +274 -0
  107. package/dist/auth-DnB9H9KL.d.mts.map +1 -0
  108. package/dist/auth.cjs +320 -21
  109. package/dist/auth.cjs.map +1 -1
  110. package/dist/auth.d.cts +2 -104
  111. package/dist/auth.d.mts +2 -104
  112. package/dist/auth.mjs +316 -23
  113. package/dist/auth.mjs.map +1 -1
  114. package/dist/cache-CQjMNPrC.d.cts +44 -0
  115. package/dist/cache-CQjMNPrC.d.cts.map +1 -0
  116. package/dist/cache-e3tfMQ9g.d.mts +44 -0
  117. package/dist/cache-e3tfMQ9g.d.mts.map +1 -0
  118. package/dist/cache.d.cts +2 -43
  119. package/dist/cache.d.mts +2 -43
  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/cipher-DSDxPRIp.d.cts +106 -0
  125. package/dist/cipher-DSDxPRIp.d.cts.map +1 -0
  126. package/dist/cipher-DSDxPRIp.d.mts +106 -0
  127. package/dist/cipher-DSDxPRIp.d.mts.map +1 -0
  128. package/dist/{construct-interface-DPlxfpoS.d.mts → construct-interface-CSA9VeWM.d.mts} +47 -8
  129. package/dist/construct-interface-CSA9VeWM.d.mts.map +1 -0
  130. package/dist/{construct-interface-DgXTJcOD.d.cts → construct-interface-DugP0E5q.d.cts} +47 -8
  131. package/dist/construct-interface-DugP0E5q.d.cts.map +1 -0
  132. package/dist/construct-interface.cjs +38 -4
  133. package/dist/construct-interface.cjs.map +1 -1
  134. package/dist/construct-interface.d.cts +2 -2
  135. package/dist/construct-interface.d.mts +2 -2
  136. package/dist/construct-interface.mjs +37 -5
  137. package/dist/construct-interface.mjs.map +1 -1
  138. package/dist/credential-DYymbp_7.cjs +257 -0
  139. package/dist/credential-DYymbp_7.cjs.map +1 -0
  140. package/dist/credential-DfSAOOdY.mjs +222 -0
  141. package/dist/credential-DfSAOOdY.mjs.map +1 -0
  142. package/dist/credential.cjs +7 -129
  143. package/dist/credential.d.cts +2 -58
  144. package/dist/credential.d.mts +2 -58
  145. package/dist/credential.mjs +2 -128
  146. package/dist/crons/index.cjs +126 -1
  147. package/dist/crons/index.cjs.map +1 -1
  148. package/dist/crons/index.d.cts +43 -3
  149. package/dist/crons/index.d.cts.map +1 -1
  150. package/dist/crons/index.d.mts +43 -3
  151. package/dist/crons/index.d.mts.map +1 -1
  152. package/dist/crons/index.mjs +125 -2
  153. package/dist/crons/index.mjs.map +1 -1
  154. package/dist/database/kysely.cjs +3 -194
  155. package/dist/database/kysely.d.cts +2 -149
  156. package/dist/database/kysely.d.mts +2 -149
  157. package/dist/database/kysely.mjs +2 -192
  158. package/dist/email.d.cts +1 -1
  159. package/dist/email.d.cts.map +1 -1
  160. package/dist/email.d.mts +2 -2
  161. package/dist/email.d.mts.map +1 -1
  162. package/dist/encryption/kms.cjs +95 -0
  163. package/dist/encryption/kms.cjs.map +1 -0
  164. package/dist/encryption/kms.d.cts +7 -0
  165. package/dist/encryption/kms.d.cts.map +1 -0
  166. package/dist/encryption/kms.d.mts +7 -0
  167. package/dist/encryption/kms.d.mts.map +1 -0
  168. package/dist/encryption/kms.mjs +93 -0
  169. package/dist/encryption/kms.mjs.map +1 -0
  170. package/dist/encryption.cjs +116 -0
  171. package/dist/encryption.cjs.map +1 -0
  172. package/dist/encryption.d.cts +37 -0
  173. package/dist/encryption.d.cts.map +1 -0
  174. package/dist/encryption.d.mts +37 -0
  175. package/dist/encryption.d.mts.map +1 -0
  176. package/dist/encryption.mjs +101 -0
  177. package/dist/encryption.mjs.map +1 -0
  178. package/dist/endpoints/index.cjs +32 -10
  179. package/dist/endpoints/index.d.cts +106 -3
  180. package/dist/endpoints/index.d.cts.map +1 -0
  181. package/dist/endpoints/index.d.mts +106 -3
  182. package/dist/endpoints/index.d.mts.map +1 -0
  183. package/dist/endpoints/index.mjs +6 -4
  184. package/dist/expire-C586zznE.d.cts +38 -0
  185. package/dist/expire-C586zznE.d.cts.map +1 -0
  186. package/dist/expire-C586zznE.d.mts +38 -0
  187. package/dist/expire-C586zznE.d.mts.map +1 -0
  188. package/dist/expire-CieftS01.cjs +67 -0
  189. package/dist/expire-CieftS01.cjs.map +1 -0
  190. package/dist/expire-CpzUAfr9.mjs +50 -0
  191. package/dist/expire-CpzUAfr9.mjs.map +1 -0
  192. package/dist/external-api.cjs +106 -0
  193. package/dist/external-api.cjs.map +1 -0
  194. package/dist/external-api.d.cts +2 -0
  195. package/dist/external-api.d.mts +2 -0
  196. package/dist/external-api.mjs +103 -0
  197. package/dist/external-api.mjs.map +1 -0
  198. package/dist/fake-BqhP8RRQ.d.mts +201 -0
  199. package/dist/fake-BqhP8RRQ.d.mts.map +1 -0
  200. package/dist/fake-DqieDYYA.d.cts +201 -0
  201. package/dist/fake-DqieDYYA.d.cts.map +1 -0
  202. package/dist/file-server.cjs +123 -30
  203. package/dist/file-server.cjs.map +1 -1
  204. package/dist/file-server.d.cts +115 -1
  205. package/dist/file-server.d.cts.map +1 -1
  206. package/dist/file-server.d.mts +115 -1
  207. package/dist/file-server.d.mts.map +1 -1
  208. package/dist/file-server.mjs +122 -32
  209. package/dist/file-server.mjs.map +1 -1
  210. package/dist/functions/index.cjs +1 -1
  211. package/dist/functions/index.d.cts +2 -1
  212. package/dist/functions/index.d.mts +2 -1
  213. package/dist/functions/index.mjs +1 -1
  214. package/dist/{functions-C53GW2eQ.mjs → functions-BvIDQKAA.mjs} +117 -22
  215. package/dist/functions-BvIDQKAA.mjs.map +1 -0
  216. package/dist/{functions-B6qCvfmy.cjs → functions-DLF6-IK8.cjs} +122 -18
  217. package/dist/functions-DLF6-IK8.cjs.map +1 -0
  218. package/dist/inbox-CR3L1fOI.d.cts +195 -0
  219. package/dist/inbox-CR3L1fOI.d.cts.map +1 -0
  220. package/dist/inbox-CjxpLVkH.d.mts +195 -0
  221. package/dist/inbox-CjxpLVkH.d.mts.map +1 -0
  222. package/dist/inbox.cjs +291 -0
  223. package/dist/inbox.cjs.map +1 -0
  224. package/dist/inbox.d.cts +2 -0
  225. package/dist/inbox.d.mts +2 -0
  226. package/dist/inbox.mjs +283 -0
  227. package/dist/inbox.mjs.map +1 -0
  228. package/dist/index-DCkDQkwj.d.mts +115 -0
  229. package/dist/index-DCkDQkwj.d.mts.map +1 -0
  230. package/dist/index-DPTHa6Ud.d.cts +115 -0
  231. package/dist/index-DPTHa6Ud.d.cts.map +1 -0
  232. package/dist/{index-CeEtxDmK.d.cts → index-DdRjYhiJ.d.cts} +42 -2
  233. package/dist/{index-CeEtxDmK.d.cts.map → index-DdRjYhiJ.d.cts.map} +1 -1
  234. package/dist/{index-CeEtxDmK.d.mts → index-DdRjYhiJ.d.mts} +42 -2
  235. package/dist/{index-CeEtxDmK.d.mts.map → index-DdRjYhiJ.d.mts.map} +1 -1
  236. package/dist/index.cjs +4 -1
  237. package/dist/index.d.cts +26 -3
  238. package/dist/index.d.cts.map +1 -0
  239. package/dist/index.d.mts +26 -3
  240. package/dist/index.d.mts.map +1 -0
  241. package/dist/index.mjs +3 -2
  242. package/dist/kysely-CebjCWTl.d.cts +216 -0
  243. package/dist/kysely-CebjCWTl.d.cts.map +1 -0
  244. package/dist/kysely-Cs4uPO8k.mjs +371 -0
  245. package/dist/kysely-Cs4uPO8k.mjs.map +1 -0
  246. package/dist/kysely-CukArHJ0.cjs +384 -0
  247. package/dist/kysely-CukArHJ0.cjs.map +1 -0
  248. package/dist/kysely-DE4kADWD.d.mts +216 -0
  249. package/dist/kysely-DE4kADWD.d.mts.map +1 -0
  250. package/dist/{telemetry-DGcFlVpB.d.cts → lambdaTelemetry-8vnmVZQ5.d.cts} +2 -2
  251. package/dist/lambdaTelemetry-8vnmVZQ5.d.cts.map +1 -0
  252. package/dist/{telemetry-DGcFlVpB.d.mts → lambdaTelemetry-8vnmVZQ5.d.mts} +2 -2
  253. package/dist/lambdaTelemetry-8vnmVZQ5.d.mts.map +1 -0
  254. package/dist/mobile-app.cjs +74 -0
  255. package/dist/mobile-app.cjs.map +1 -0
  256. package/dist/mobile-app.d.cts +73 -0
  257. package/dist/mobile-app.d.cts.map +1 -0
  258. package/dist/mobile-app.d.mts +73 -0
  259. package/dist/mobile-app.d.mts.map +1 -0
  260. package/dist/mobile-app.mjs +73 -0
  261. package/dist/mobile-app.mjs.map +1 -0
  262. package/dist/object-storage.cjs +8 -1
  263. package/dist/object-storage.cjs.map +1 -1
  264. package/dist/object-storage.d.cts +10 -1
  265. package/dist/object-storage.d.cts.map +1 -1
  266. package/dist/object-storage.d.mts +10 -1
  267. package/dist/object-storage.d.mts.map +1 -1
  268. package/dist/object-storage.mjs +7 -2
  269. package/dist/object-storage.mjs.map +1 -1
  270. package/dist/pattern-C1CEcglD.mjs +241 -0
  271. package/dist/pattern-C1CEcglD.mjs.map +1 -0
  272. package/dist/pattern-QFaUIr77.cjs +288 -0
  273. package/dist/pattern-QFaUIr77.cjs.map +1 -0
  274. package/dist/processors/index.cjs +214 -0
  275. package/dist/processors/index.cjs.map +1 -0
  276. package/dist/processors/index.d.cts +78 -0
  277. package/dist/processors/index.d.cts.map +1 -0
  278. package/dist/processors/index.d.mts +78 -0
  279. package/dist/processors/index.d.mts.map +1 -0
  280. package/dist/processors/index.mjs +193 -0
  281. package/dist/processors/index.mjs.map +1 -0
  282. package/dist/queue/index.cjs +5 -192
  283. package/dist/queue/index.d.cts +3 -53
  284. package/dist/queue/index.d.mts +3 -53
  285. package/dist/queue/index.mjs +3 -190
  286. package/dist/random-password.cjs +86 -0
  287. package/dist/random-password.cjs.map +1 -0
  288. package/dist/random-password.d.cts +30 -0
  289. package/dist/random-password.d.cts.map +1 -0
  290. package/dist/random-password.d.mts +30 -0
  291. package/dist/random-password.d.mts.map +1 -0
  292. package/dist/random-password.mjs +84 -0
  293. package/dist/random-password.mjs.map +1 -0
  294. package/dist/{lazyAccessors-BHtcqgz2.mjs → readRequestBody-BTIl3k-D.mjs} +99 -39
  295. package/dist/readRequestBody-BTIl3k-D.mjs.map +1 -0
  296. package/dist/{lazyAccessors-Dx9NLwJZ.cjs → readRequestBody-Dej_L3c4.cjs} +118 -46
  297. package/dist/readRequestBody-Dej_L3c4.cjs.map +1 -0
  298. package/dist/requestLogger-BZcXwdBs.cjs +207 -0
  299. package/dist/requestLogger-BZcXwdBs.cjs.map +1 -0
  300. package/dist/requestLogger-pA4gi3E1.mjs +178 -0
  301. package/dist/requestLogger-pA4gi3E1.mjs.map +1 -0
  302. package/dist/rest-api.cjs +85 -70
  303. package/dist/rest-api.cjs.map +1 -1
  304. package/dist/rest-api.d.cts +77 -59
  305. package/dist/rest-api.d.cts.map +1 -1
  306. package/dist/rest-api.d.mts +77 -59
  307. package/dist/rest-api.d.mts.map +1 -1
  308. package/dist/rest-api.mjs +87 -72
  309. package/dist/rest-api.mjs.map +1 -1
  310. package/dist/runSubscriber-CC_2C9F2.cjs +133 -0
  311. package/dist/runSubscriber-CC_2C9F2.cjs.map +1 -0
  312. package/dist/runSubscriber-DyHWp_Lf.mjs +116 -0
  313. package/dist/runSubscriber-DyHWp_Lf.mjs.map +1 -0
  314. package/dist/shutdown-BMJmAhSt.cjs +38 -0
  315. package/dist/shutdown-BMJmAhSt.cjs.map +1 -0
  316. package/dist/shutdown-C7xa8x9S.mjs +27 -0
  317. package/dist/shutdown-C7xa8x9S.mjs.map +1 -0
  318. package/dist/site.cjs +85 -8
  319. package/dist/site.cjs.map +1 -1
  320. package/dist/site.d.cts +98 -2
  321. package/dist/site.d.cts.map +1 -1
  322. package/dist/site.d.mts +98 -2
  323. package/dist/site.d.mts.map +1 -1
  324. package/dist/site.mjs +84 -11
  325. package/dist/site.mjs.map +1 -1
  326. package/dist/stages-DaTaoQei.d.cts +73 -0
  327. package/dist/stages-DaTaoQei.d.cts.map +1 -0
  328. package/dist/stages-DaTaoQei.d.mts +73 -0
  329. package/dist/stages-DaTaoQei.d.mts.map +1 -0
  330. package/dist/subscribers/index.cjs +134 -1
  331. package/dist/subscribers/index.cjs.map +1 -0
  332. package/dist/subscribers/index.d.cts +74 -3
  333. package/dist/subscribers/index.d.cts.map +1 -0
  334. package/dist/subscribers/index.d.mts +74 -3
  335. package/dist/subscribers/index.d.mts.map +1 -0
  336. package/dist/subscribers/index.mjs +132 -2
  337. package/dist/subscribers/index.mjs.map +1 -0
  338. package/dist/telemetry-C1oqncFY.d.cts +40 -0
  339. package/dist/telemetry-C1oqncFY.d.cts.map +1 -0
  340. package/dist/telemetry-CObow3Dn.d.mts +40 -0
  341. package/dist/telemetry-CObow3Dn.d.mts.map +1 -0
  342. package/dist/telemetry.cjs +56 -0
  343. package/dist/telemetry.cjs.map +1 -0
  344. package/dist/telemetry.d.cts +2 -0
  345. package/dist/telemetry.d.mts +2 -0
  346. package/dist/telemetry.mjs +55 -0
  347. package/dist/telemetry.mjs.map +1 -0
  348. package/dist/topic/index.cjs +2 -134
  349. package/dist/topic/index.d.cts +2 -3
  350. package/dist/topic/index.d.mts +2 -3
  351. package/dist/topic/index.mjs +2 -132
  352. package/dist/tracing-Bbj1uoFJ.mjs +127 -0
  353. package/dist/tracing-Bbj1uoFJ.mjs.map +1 -0
  354. package/dist/tracing-C0ooU0V2.cjs +150 -0
  355. package/dist/tracing-C0ooU0V2.cjs.map +1 -0
  356. package/dist/websocket-api.cjs +951 -0
  357. package/dist/websocket-api.cjs.map +1 -0
  358. package/dist/websocket-api.d.cts +556 -0
  359. package/dist/websocket-api.d.cts.map +1 -0
  360. package/dist/websocket-api.d.mts +556 -0
  361. package/dist/websocket-api.d.mts.map +1 -0
  362. package/dist/websocket-api.mjs +933 -0
  363. package/dist/websocket-api.mjs.map +1 -0
  364. package/dist/worker.cjs +174 -32
  365. package/dist/worker.cjs.map +1 -1
  366. package/dist/worker.d.cts +147 -47
  367. package/dist/worker.d.cts.map +1 -1
  368. package/dist/worker.d.mts +147 -47
  369. package/dist/worker.d.mts.map +1 -1
  370. package/dist/worker.mjs +175 -33
  371. package/dist/worker.mjs.map +1 -1
  372. package/package.json +155 -44
  373. package/dist/Construct-BeYVu_QF.mjs.map +0 -1
  374. package/dist/Construct-DfbwIntp.d.cts +0 -115
  375. package/dist/Construct-DfbwIntp.d.cts.map +0 -1
  376. package/dist/Construct-DqdlARxq.cjs.map +0 -1
  377. package/dist/Construct-l5aOn_jv.d.mts +0 -115
  378. package/dist/Construct-l5aOn_jv.d.mts.map +0 -1
  379. package/dist/Cron-DKqnnTdH.d.cts.map +0 -1
  380. package/dist/Cron-SyqS5oWJ.d.mts.map +0 -1
  381. package/dist/CronBuilder-BdnI6lxF.cjs.map +0 -1
  382. package/dist/CronBuilder-CRGnDfTq.d.mts +0 -41
  383. package/dist/CronBuilder-CRGnDfTq.d.mts.map +0 -1
  384. package/dist/CronBuilder-D_0HNBTr.mjs.map +0 -1
  385. package/dist/CronBuilder-Df1q9PNy.d.cts +0 -41
  386. package/dist/CronBuilder-Df1q9PNy.d.cts.map +0 -1
  387. package/dist/Endpoint-BpZHtJ2W.cjs +0 -1689
  388. package/dist/Endpoint-BpZHtJ2W.cjs.map +0 -1
  389. package/dist/Endpoint-C6yyHpRS.d.cts.map +0 -1
  390. package/dist/Endpoint-DuT4TEEq.d.mts.map +0 -1
  391. package/dist/Endpoint-ONsly_dq.mjs +0 -1671
  392. package/dist/Endpoint-ONsly_dq.mjs.map +0 -1
  393. package/dist/EndpointFactory-Bm3aKRdV.mjs.map +0 -1
  394. package/dist/EndpointFactory-CLvWuHyt.cjs.map +0 -1
  395. package/dist/HonoEndpointAdaptor-92zavCsV.cjs.map +0 -1
  396. package/dist/HonoEndpointAdaptor-yYaU7jVJ.mjs.map +0 -1
  397. package/dist/Queue-D9X6OoON.d.mts.map +0 -1
  398. package/dist/Queue-DYPB2KWL.d.cts.map +0 -1
  399. package/dist/Subscriber-C4heaAyO.d.mts +0 -51
  400. package/dist/Subscriber-C4heaAyO.d.mts.map +0 -1
  401. package/dist/Subscriber-CotDUELC.d.cts +0 -51
  402. package/dist/Subscriber-CotDUELC.d.cts.map +0 -1
  403. package/dist/SubscriberBuilder-BEv0eoHy.d.cts +0 -59
  404. package/dist/SubscriberBuilder-BEv0eoHy.d.cts.map +0 -1
  405. package/dist/SubscriberBuilder-C0ZEtGDI.cjs +0 -125
  406. package/dist/SubscriberBuilder-C0ZEtGDI.cjs.map +0 -1
  407. package/dist/SubscriberBuilder-h7B_cHMr.mjs +0 -114
  408. package/dist/SubscriberBuilder-h7B_cHMr.mjs.map +0 -1
  409. package/dist/SubscriberBuilder-tyH5yTk5.d.mts +0 -59
  410. package/dist/SubscriberBuilder-tyH5yTk5.d.mts.map +0 -1
  411. package/dist/Topic-DEVGo0Dm.d.cts +0 -89
  412. package/dist/Topic-DEVGo0Dm.d.cts.map +0 -1
  413. package/dist/Topic-zk_6Gthr.d.mts +0 -89
  414. package/dist/Topic-zk_6Gthr.d.mts.map +0 -1
  415. package/dist/auth.d.cts.map +0 -1
  416. package/dist/auth.d.mts.map +0 -1
  417. package/dist/cache.d.cts.map +0 -1
  418. package/dist/cache.d.mts.map +0 -1
  419. package/dist/construct-interface-DPlxfpoS.d.mts.map +0 -1
  420. package/dist/construct-interface-DgXTJcOD.d.cts.map +0 -1
  421. package/dist/credential.cjs.map +0 -1
  422. package/dist/credential.d.cts.map +0 -1
  423. package/dist/credential.d.mts.map +0 -1
  424. package/dist/credential.mjs.map +0 -1
  425. package/dist/database/kysely.cjs.map +0 -1
  426. package/dist/database/kysely.d.cts.map +0 -1
  427. package/dist/database/kysely.d.mts.map +0 -1
  428. package/dist/database/kysely.mjs.map +0 -1
  429. package/dist/functions-B6qCvfmy.cjs.map +0 -1
  430. package/dist/functions-C53GW2eQ.mjs.map +0 -1
  431. package/dist/index-B2urf3YI.d.cts +0 -26
  432. package/dist/index-B2urf3YI.d.cts.map +0 -1
  433. package/dist/index-BPSZ_Lp_.d.cts.map +0 -1
  434. package/dist/index-BoZ-iisU.d.mts.map +0 -1
  435. package/dist/index-CdaU--_B.d.cts +0 -165
  436. package/dist/index-CdaU--_B.d.cts.map +0 -1
  437. package/dist/index-DMCDvnsM.d.mts +0 -26
  438. package/dist/index-DMCDvnsM.d.mts.map +0 -1
  439. package/dist/index-PQRWOQj4.d.mts +0 -165
  440. package/dist/index-PQRWOQj4.d.mts.map +0 -1
  441. package/dist/lazyAccessors-BHtcqgz2.mjs.map +0 -1
  442. package/dist/lazyAccessors-Dx9NLwJZ.cjs.map +0 -1
  443. package/dist/processAudits-BpRlPQMW.mjs +0 -77
  444. package/dist/processAudits-BpRlPQMW.mjs.map +0 -1
  445. package/dist/processAudits-D_2W5x8k.cjs +0 -88
  446. package/dist/processAudits-D_2W5x8k.cjs.map +0 -1
  447. package/dist/queue/index.cjs.map +0 -1
  448. package/dist/queue/index.d.cts.map +0 -1
  449. package/dist/queue/index.d.mts.map +0 -1
  450. package/dist/queue/index.mjs.map +0 -1
  451. package/dist/telemetry-DGcFlVpB.d.cts.map +0 -1
  452. package/dist/telemetry-DGcFlVpB.d.mts.map +0 -1
  453. package/dist/topic/index.cjs.map +0 -1
  454. package/dist/topic/index.mjs.map +0 -1
@@ -0,0 +1,195 @@
1
+ import { c as Topic } from "./Construct-DySlwh8o.mjs";
2
+ import { n as Construct } from "./construct-interface-CSA9VeWM.mjs";
3
+ import { ConstructName, Declaration, InboxAddressing, InboxRecipient } from "@geekmidas/manifest";
4
+ import { Service } from "@geekmidas/services";
5
+ import { ParsedEmail } from "@geekmidas/emailkit/inbound";
6
+ //#region src/inbox.d.ts
7
+ interface InboxOptions {
8
+ /**
9
+ * The local parts it receives at: `['requests']`. Each also takes a
10
+ * `+tag` — `requests+t_8f3k@` — handed to the handler as `recipient.tag`.
11
+ */
12
+ addresses: readonly string[];
13
+ /**
14
+ * Receive at `<address>@<label>.<domain>` — one label, a tenant's — rather
15
+ * than at the stage's domain itself.
16
+ */
17
+ subdomains?: boolean;
18
+ }
19
+ /** An inbox declared with no address receives nothing. */
20
+ declare class InboxHasNoAddresses extends Error {
21
+ readonly inbox: string;
22
+ constructor(inbox: string);
23
+ }
24
+ /** An address that is not a bare local part: `requests@x`, `a+b`, `''`. */
25
+ declare class InboxAddressInvalid extends Error {
26
+ readonly inbox: string;
27
+ readonly address: string;
28
+ constructor(inbox: string, address: string);
29
+ }
30
+ /**
31
+ * A receipt notification the inbox cannot read: not SES's shape, or an action
32
+ * other than the S3 one that stores the message where the decoder reads it.
33
+ */
34
+ declare class ReceiptNotificationMalformed extends Error {
35
+ readonly inbox: string;
36
+ readonly reason: string;
37
+ constructor(inbox: string, reason: string);
38
+ }
39
+ /**
40
+ * A provider's verdict on a message.
41
+ *
42
+ * `'unavailable'` where nothing judged it — locally, always — and never a
43
+ * faked `'pass'`.
44
+ */
45
+ type Verdict = 'pass' | 'fail' | 'gray' | 'unavailable';
46
+ /** What the provider judged of a message, which the message cannot say of itself. */
47
+ interface Verdicts {
48
+ spf: Verdict;
49
+ dkim: Verdict;
50
+ dmarc: Verdict;
51
+ spam: Verdict;
52
+ virus: Verdict;
53
+ }
54
+ /**
55
+ * One received message, for one recipient it was delivered to.
56
+ *
57
+ * `recipient` is the envelope's; every other address is a header, written by
58
+ * the sender. Inbound mail is untrusted input: route on `recipient`, treat
59
+ * `from` as a claim until `verdicts.dmarc` passes *and* the address is known,
60
+ * sanitise `html`, and never use an attachment's filename as a key or path.
61
+ */
62
+ interface InboxMessage extends Omit<ParsedEmail, 'attachments'>, Pick<ParsedEmail, 'attachments'> {
63
+ recipient: InboxRecipient;
64
+ /**
65
+ * Where the raw message is kept: the bucket SES stored it in (`mailpit`
66
+ * locally), and its key there.
67
+ */
68
+ raw: {
69
+ bucket: string;
70
+ key: string;
71
+ };
72
+ verdicts: Verdicts;
73
+ }
74
+ /** A status as SES writes one: `PASS`, `FAIL`, `GRAY`, `PROCESSING_FAILED`, `DISABLED`. */
75
+ interface ReceiptVerdict {
76
+ status: string;
77
+ }
78
+ /**
79
+ * SES's receipt notification — the part an inbox reads.
80
+ *
81
+ * `gkm dev` and the test mailbox publish the same shape, with every verdict
82
+ * `UNAVAILABLE`, so one decoder serves all three.
83
+ */
84
+ interface ReceiptNotification {
85
+ notificationType: 'Received';
86
+ mail: {
87
+ messageId: string;
88
+ timestamp: string;
89
+ /** The envelope sender (`MAIL FROM`). */
90
+ source: string;
91
+ destination: string[];
92
+ };
93
+ receipt: {
94
+ timestamp: string;
95
+ /** The envelope recipients this receipt rule matched. */
96
+ recipients: string[];
97
+ spamVerdict?: ReceiptVerdict;
98
+ virusVerdict?: ReceiptVerdict;
99
+ spfVerdict?: ReceiptVerdict;
100
+ dkimVerdict?: ReceiptVerdict;
101
+ dmarcVerdict?: ReceiptVerdict;
102
+ action: {
103
+ type: string;
104
+ bucketName?: string;
105
+ objectKey?: string;
106
+ topicArn?: string;
107
+ };
108
+ };
109
+ }
110
+ /** What the handler's inbox is: its domain, its raw messages, the decoder. */
111
+ interface InboxClient {
112
+ /** The stage's domain it receives on. */
113
+ readonly domain: string;
114
+ /** A raw message's bytes, by its key in the bucket. */
115
+ raw(key: string): Promise<Uint8Array>;
116
+ /**
117
+ * The messages a notification announces: one per envelope recipient this
118
+ * inbox receives at, parsed. Empty when none is — a receipt rule that takes
119
+ * a whole domain stores mail for addresses no inbox declared.
120
+ */
121
+ messages(notification: ReceiptNotification): Promise<InboxMessage[]>;
122
+ }
123
+ type InboxTopic = Topic<string, {}>;
124
+ declare class Inbox<TName extends string = string> implements Construct<TName, InboxClient> {
125
+ readonly id: TName;
126
+ readonly service: Service<Uncapitalize<TName>, InboxClient>;
127
+ /** Where each received message is announced. Published to by the provider only. */
128
+ readonly topic: InboxTopic;
129
+ /** The local parts it receives at, and whether on a tenant's subdomain. */
130
+ readonly addressing: InboxAddressing;
131
+ private readonly addresses;
132
+ private readonly subdomains;
133
+ private readonly keys;
134
+ constructor(name: ConstructName<TName>, options: InboxOptions);
135
+ declare(): Declaration[];
136
+ private connect;
137
+ }
138
+ /** The raw message a notification names could not be read from its store. */
139
+ declare class RawMessageUnreadable extends Error {
140
+ readonly inbox: string;
141
+ readonly key: string;
142
+ readonly status: number;
143
+ constructor(inbox: string, key: string, status: number);
144
+ }
145
+ /**
146
+ * The receipt notification a provider that judges nothing publishes —
147
+ * `gkm dev` and the test mailbox — for a message stored at `objectKey`.
148
+ */
149
+ declare function unjudgedReceipt(options: {
150
+ messageId: string;
151
+ source: string;
152
+ recipients: readonly string[];
153
+ bucketName: string;
154
+ objectKey: string;
155
+ verdicts?: Partial<Verdicts>;
156
+ timestamp?: Date;
157
+ }): ReceiptNotification;
158
+ /** An inbox, as the receiver routes to it. */
159
+ interface ReceivingInbox {
160
+ id: string;
161
+ addressing: InboxAddressing;
162
+ /** The stage's domain it receives on. */
163
+ domain: string;
164
+ /** Announce a received message on the inbox's topic. */
165
+ publish(notification: ReceiptNotification): Promise<void>;
166
+ }
167
+ /** A message that arrived where a provider that judges nothing stores mail. */
168
+ interface ArrivedMessage {
169
+ /** Its key in that store — Mailpit's message id locally. */
170
+ key: string;
171
+ /** Where the store is, as a notification names it: `mailpit`. */
172
+ store: string;
173
+ /** The envelope sender. */
174
+ from: string;
175
+ /** The envelope recipients — never `To:`. */
176
+ recipients: readonly string[];
177
+ /** What a test says the provider judged; `'unavailable'` otherwise. */
178
+ verdicts?: Partial<Verdicts>;
179
+ }
180
+ /**
181
+ * Receive a message the way a receipt rule does: for each inbox one of its
182
+ * envelope recipients is addressed to, publish the receipt notification for
183
+ * those recipients on the inbox's topic. What no inbox receives at goes
184
+ * nowhere — mail the app sent to anyone else included.
185
+ *
186
+ * The one receiver for every local path: Mailpit's webhook under `gkm dev`
187
+ * and a local compose stack, and `mailbox.receive` in a feature test. SES is
188
+ * the receiver deployed. Returns the ids of the inboxes it announced to.
189
+ */
190
+ declare function receiveMail(message: ArrivedMessage, inboxes: readonly ReceivingInbox[]): Promise<string[]>;
191
+ /** Whether `value` is an {@link Inbox}. */
192
+ declare function isInbox(value: unknown): value is Inbox;
193
+ //#endregion
194
+ export { InboxHasNoAddresses as a, RawMessageUnreadable as c, ReceivingInbox as d, Verdict as f, unjudgedReceipt as g, receiveMail as h, InboxClient as i, ReceiptNotification as l, isInbox as m, Inbox as n, InboxMessage as o, Verdicts as p, InboxAddressInvalid as r, InboxOptions as s, ArrivedMessage as t, ReceiptNotificationMalformed as u };
195
+ //# sourceMappingURL=inbox-CjxpLVkH.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inbox-CjxpLVkH.d.mts","names":[],"sources":["../src/inbox.ts"],"mappings":";;;;;;UAsDiB;;;;;EAKhB;;;;;EAKA;;;cAIY,4BAA4B;WACnB;EAArB,YAAqB;;;cAUT,4BAA4B;WAE9B;WACA;EAFV,YACU,eACA;;;;;;cAeE,qCAAqC;WAEvC;WACA;EAFV,YACU,eACA;;;;;;;;KAgBC;;UAGK;EAChB,KAAK;EACL,MAAM;EACN,OAAO;EACP,MAAM;EACN,OAAO;;;;;;;;;;UAWS,qBACR,KAAK,6BACZ,KAAK;EACN,WAAW;;;;;EAKX;IAAO;IAAgB;;EACvB,UAAU;;;UAID;EACT;;;;;;;;UASgB;EAChB;EACA;IACC;IACA;;IAEA;IACA;;EAED;IACC;;IAEA;IACA,cAAc;IACd,eAAe;IACf,aAAa;IACb,cAAc;IACd,eAAe;IACf;MACC;MACA;MACA;MACA;;;;;UAMc;;WAEP;;EAET,IAAI,cAAc,QAAQ;;;;;;EAM1B,SAAS,cAAc,sBAAsB,QAAQ;;KAYjD,aAAa;cAEL,MAAM,0CACP,UAAU,OAAO;WAEnB,IAAI;WACJ,SAAS,QAAQ,aAAa,QAAQ;;WAEtC,OAAO;;WAGP,YAAY;mBACJ;mBACA;mBACA;EAEjB,YAAY,MAAM,cAAc,QAAQ,SAAS;EAgCjD,WAAW;UAcG;;;cAmEF,6BAA6B;WAE/B;WACA;WACA;EAHV,YACU,eACA,aACA;;;;;;iBA2DK,gBAAgB;EAC/B;EACA;EACA;EACA;EACA;EACA,WAAW,QAAQ;EACnB,YAAY;IACT;;UA+Ba;EAChB;EACA,YAAY;;EAEZ;;EAEA,QAAQ,cAAc,sBAAsB;;;UAI5B;;EAEhB;;EAEA;;EAEA;;EAEA;;EAEA,WAAW,QAAQ;;;;;;;;;;;;iBAaE,YACrB,SAAS,gBACT,kBAAkB,mBAChB;;iBAuBa,QAAQ,iBAAiB,SAAS"}
package/dist/inbox.cjs ADDED
@@ -0,0 +1,291 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_Topic = require("./Topic-Dp9Q7Lj2.cjs");
3
+ let _geekmidas_manifest = require("@geekmidas/manifest");
4
+ let _geekmidas_storage = require("@geekmidas/storage");
5
+ let _geekmidas_emailkit_inbound = require("@geekmidas/emailkit/inbound");
6
+ //#region src/inbox.ts
7
+ /**
8
+ * `Inbox` — mail received at addresses on the stage's domain, each message
9
+ * handled in a worker.
10
+ *
11
+ * ```ts
12
+ * export const requests = new Inbox('Requests', {
13
+ * addresses: ['requests'], // local parts: structural
14
+ * subdomains: true, // requests@<tenant>.<stage domain>
15
+ * });
16
+ *
17
+ * export const onRequest = worker
18
+ * .inbox(requests)
19
+ * .handle(async ({ messages }) => {
20
+ * for (const message of messages) {
21
+ * message.recipient.subdomain; // the tenant, from the envelope
22
+ * message.recipient.tag; // requests+<tag>@
23
+ * }
24
+ * });
25
+ * ```
26
+ *
27
+ * **Its own bucket, and a topic.** An inbox owns the bucket its raw messages
28
+ * are kept in — each target creates it for the inbox, never one the stack
29
+ * already runs — and provides its URL itself, so the bucket is no `objects`
30
+ * node and no object subscriber can be bound to it. It declares the topic
31
+ * each message is announced on, which only the provider publishes to.
32
+ *
33
+ * **One decoder.** Deployed, SES's receipt rule stores the raw message and
34
+ * publishes its receipt notification on the topic. Locally `gkm dev` brings a
35
+ * message in from Mailpit and publishes the same notification; in a feature
36
+ * test `mailbox.receive` does. The handler is handed what {@link InboxClient}
37
+ * makes of that notification, wherever it came from.
38
+ *
39
+ * **The envelope routes.** Which inbox, which tenant and which tag come from
40
+ * the envelope recipient, never from `From:` or `To:`, which the sender wrote.
41
+ */
42
+ /** An inbox declared with no address receives nothing. */
43
+ var InboxHasNoAddresses = class extends Error {
44
+ inbox;
45
+ constructor(inbox) {
46
+ super(`The inbox '${inbox}' names no address, so it would receive nothing. Name the local parts it receives at: addresses: ['requests'].`);
47
+ this.inbox = inbox;
48
+ this.name = "InboxHasNoAddresses";
49
+ }
50
+ };
51
+ /** An address that is not a bare local part: `requests@x`, `a+b`, `''`. */
52
+ var InboxAddressInvalid = class extends Error {
53
+ inbox;
54
+ address;
55
+ constructor(inbox, address) {
56
+ super(`The inbox '${inbox}' names '${address}', which is not a local part. Name only what goes before the @ — the domain is the stage's — and no '+': every address takes a +tag already.`);
57
+ this.inbox = inbox;
58
+ this.address = address;
59
+ this.name = "InboxAddressInvalid";
60
+ }
61
+ };
62
+ /**
63
+ * A receipt notification the inbox cannot read: not SES's shape, or an action
64
+ * other than the S3 one that stores the message where the decoder reads it.
65
+ */
66
+ var ReceiptNotificationMalformed = class extends Error {
67
+ inbox;
68
+ reason;
69
+ constructor(inbox, reason) {
70
+ super(`The inbox '${inbox}' was handed a notification it cannot read: ${reason}. It reads SES receipt notifications whose action stored the message in S3.`);
71
+ this.inbox = inbox;
72
+ this.reason = reason;
73
+ this.name = "ReceiptNotificationMalformed";
74
+ }
75
+ };
76
+ /** A schema that takes a receipt notification as it is — SES wrote it, not the app. */
77
+ const RECEIPT_NOTIFICATION = { "~standard": {
78
+ version: 1,
79
+ vendor: "geekmidas",
80
+ validate: (value) => ({ value })
81
+ } };
82
+ var Inbox = class {
83
+ id;
84
+ service;
85
+ /** Where each received message is announced. Published to by the provider only. */
86
+ topic;
87
+ /** The local parts it receives at, and whether on a tenant's subdomain. */
88
+ addressing;
89
+ addresses;
90
+ subdomains;
91
+ keys;
92
+ constructor(name, options) {
93
+ const canonical = (0, _geekmidas_manifest.canonicalId)(name);
94
+ if (options.addresses.length === 0) throw new InboxHasNoAddresses(canonical);
95
+ for (const address of options.addresses) if (!/^[a-z0-9][a-z0-9._-]*$/i.test(address)) throw new InboxAddressInvalid(canonical, address);
96
+ this.id = canonical;
97
+ this.addresses = options.addresses.map((a) => a.toLowerCase());
98
+ this.subdomains = options.subdomains === true;
99
+ this.addressing = {
100
+ addresses: this.addresses,
101
+ ...this.subdomains ? { subdomains: true } : {}
102
+ };
103
+ this.keys = {
104
+ url: (0, _geekmidas_manifest.provideKey)(canonical, "url"),
105
+ domain: (0, _geekmidas_manifest.provideKey)(canonical, "domain")
106
+ };
107
+ this.topic = new require_Topic.Topic(`${canonical}Mail`, { events: { [_geekmidas_manifest.INBOX_EVENT]: RECEIPT_NOTIFICATION } });
108
+ this.service = {
109
+ serviceName: (0, _geekmidas_manifest.serviceKey)(canonical),
110
+ register: (register) => this.connect(register)
111
+ };
112
+ }
113
+ declare() {
114
+ return [...this.topic.declare(), {
115
+ kind: "inbox",
116
+ id: this.id,
117
+ provides: [this.keys.url, this.keys.domain],
118
+ addresses: this.addresses,
119
+ ...this.subdomains ? { subdomains: true } : {},
120
+ topic: this.topic.id
121
+ }];
122
+ }
123
+ async connect(register) {
124
+ const { url, domain } = register.envParser.create((get) => ({
125
+ url: get(this.keys.url).string(),
126
+ domain: get(this.keys.domain).string()
127
+ })).parse();
128
+ const read = rawReader(url);
129
+ const addressing = {
130
+ addresses: this.addresses,
131
+ subdomains: this.subdomains
132
+ };
133
+ const inbox = this.id;
134
+ const raw = async (key) => {
135
+ const response = await fetch(await read(key));
136
+ if (!response.ok) throw new RawMessageUnreadable(inbox, key, response.status);
137
+ return new Uint8Array(await response.arrayBuffer());
138
+ };
139
+ return {
140
+ domain,
141
+ raw,
142
+ async messages(notification) {
143
+ const { receipt } = assertReceipt(inbox, notification);
144
+ const recipients = receipt.recipients.flatMap((address) => {
145
+ const recipient = (0, _geekmidas_manifest.inboxRecipient)(address, addressing, domain);
146
+ return recipient ? [recipient] : [];
147
+ });
148
+ if (recipients.length === 0) return [];
149
+ const key = receipt.action.objectKey;
150
+ const parsed = await (0, _geekmidas_emailkit_inbound.parseEmail)(await raw(key));
151
+ const verdicts = verdictsOf(receipt);
152
+ return recipients.map((recipient) => ({
153
+ ...parsed,
154
+ recipient,
155
+ raw: {
156
+ bucket: receipt.action.bucketName,
157
+ key
158
+ },
159
+ verdicts
160
+ }));
161
+ }
162
+ };
163
+ }
164
+ };
165
+ /**
166
+ * Where a raw message is read from, by its key, for the store `url` names:
167
+ * an `s3://` bucket deployed — SES stored it at `messages/<id>` — or, locally,
168
+ * Mailpit's API, which keeps every message it receives under its own id.
169
+ *
170
+ * The one place local and deployed differ; everything that reads a message
171
+ * goes through it.
172
+ */
173
+ function rawReader(url) {
174
+ if (url.startsWith("s3:")) {
175
+ const bucket = (0, _geekmidas_storage.createStorageClient)(url);
176
+ return async (key) => (await bucket).getDownloadURL({ path: key });
177
+ }
178
+ const base = url.replace(/\/+$/, "");
179
+ return async (key) => `${base}/api/v1/message/${encodeURIComponent(key)}/raw`;
180
+ }
181
+ /** The raw message a notification names could not be read from its store. */
182
+ var RawMessageUnreadable = class extends Error {
183
+ inbox;
184
+ key;
185
+ status;
186
+ constructor(inbox, key, status) {
187
+ super(`The inbox '${inbox}' could not read its raw message '${key}' (HTTP ${status}). It is written by the receipt rule before the notification is sent; check the bucket's policy lets the process that runs the handler read it.`);
188
+ this.inbox = inbox;
189
+ this.key = key;
190
+ this.status = status;
191
+ this.name = "RawMessageUnreadable";
192
+ }
193
+ };
194
+ function assertReceipt(inbox, value) {
195
+ const notification = value;
196
+ if (notification?.notificationType !== "Received") throw new ReceiptNotificationMalformed(inbox, `its notificationType is '${String(notification?.notificationType)}', not 'Received'`);
197
+ const action = notification.receipt?.action;
198
+ if (action?.type !== "S3" || !action.objectKey || !action.bucketName) throw new ReceiptNotificationMalformed(inbox, `its action is '${String(action?.type)}' without an S3 object`);
199
+ if (!Array.isArray(notification.receipt?.recipients)) throw new ReceiptNotificationMalformed(inbox, "it names no recipients");
200
+ return notification;
201
+ }
202
+ function verdict(status) {
203
+ switch (status?.status) {
204
+ case "PASS": return "pass";
205
+ case "FAIL": return "fail";
206
+ case "GRAY": return "gray";
207
+ default: return "unavailable";
208
+ }
209
+ }
210
+ function verdictsOf(receipt) {
211
+ return {
212
+ spf: verdict(receipt.spfVerdict),
213
+ dkim: verdict(receipt.dkimVerdict),
214
+ dmarc: verdict(receipt.dmarcVerdict),
215
+ spam: verdict(receipt.spamVerdict),
216
+ virus: verdict(receipt.virusVerdict)
217
+ };
218
+ }
219
+ /**
220
+ * The receipt notification a provider that judges nothing publishes —
221
+ * `gkm dev` and the test mailbox — for a message stored at `objectKey`.
222
+ */
223
+ function unjudgedReceipt(options) {
224
+ const at = (options.timestamp ?? /* @__PURE__ */ new Date()).toISOString();
225
+ const status = (v) => ({ status: v ? v.toUpperCase() : "UNAVAILABLE" });
226
+ return {
227
+ notificationType: "Received",
228
+ mail: {
229
+ messageId: options.messageId,
230
+ timestamp: at,
231
+ source: options.source,
232
+ destination: [...options.recipients]
233
+ },
234
+ receipt: {
235
+ timestamp: at,
236
+ recipients: [...options.recipients],
237
+ spfVerdict: status(options.verdicts?.spf),
238
+ dkimVerdict: status(options.verdicts?.dkim),
239
+ dmarcVerdict: status(options.verdicts?.dmarc),
240
+ spamVerdict: status(options.verdicts?.spam),
241
+ virusVerdict: status(options.verdicts?.virus),
242
+ action: {
243
+ type: "S3",
244
+ bucketName: options.bucketName,
245
+ objectKey: options.objectKey
246
+ }
247
+ }
248
+ };
249
+ }
250
+ /**
251
+ * Receive a message the way a receipt rule does: for each inbox one of its
252
+ * envelope recipients is addressed to, publish the receipt notification for
253
+ * those recipients on the inbox's topic. What no inbox receives at goes
254
+ * nowhere — mail the app sent to anyone else included.
255
+ *
256
+ * The one receiver for every local path: Mailpit's webhook under `gkm dev`
257
+ * and a local compose stack, and `mailbox.receive` in a feature test. SES is
258
+ * the receiver deployed. Returns the ids of the inboxes it announced to.
259
+ */
260
+ async function receiveMail(message, inboxes) {
261
+ const received = [];
262
+ for (const inbox of inboxes) {
263
+ const recipients = message.recipients.filter((address) => (0, _geekmidas_manifest.inboxRecipient)(address, inbox.addressing, inbox.domain));
264
+ if (recipients.length === 0) continue;
265
+ await inbox.publish(unjudgedReceipt({
266
+ messageId: message.key,
267
+ source: message.from,
268
+ recipients,
269
+ bucketName: message.store,
270
+ objectKey: message.key,
271
+ ...message.verdicts ? { verdicts: message.verdicts } : {}
272
+ }));
273
+ received.push(inbox.id);
274
+ }
275
+ return received;
276
+ }
277
+ /** Whether `value` is an {@link Inbox}. */
278
+ function isInbox(value) {
279
+ return value instanceof Inbox;
280
+ }
281
+ //#endregion
282
+ exports.Inbox = Inbox;
283
+ exports.InboxAddressInvalid = InboxAddressInvalid;
284
+ exports.InboxHasNoAddresses = InboxHasNoAddresses;
285
+ exports.RawMessageUnreadable = RawMessageUnreadable;
286
+ exports.ReceiptNotificationMalformed = ReceiptNotificationMalformed;
287
+ exports.isInbox = isInbox;
288
+ exports.receiveMail = receiveMail;
289
+ exports.unjudgedReceipt = unjudgedReceipt;
290
+
291
+ //# sourceMappingURL=inbox.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inbox.cjs","names":["canonicalId","provideKey","Topic","INBOX_EVENT","serviceKey","inboxRecipient","parseEmail","createStorageClient"],"sources":["../src/inbox.ts"],"sourcesContent":["/**\n * `Inbox` — mail received at addresses on the stage's domain, each message\n * handled in a worker.\n *\n * ```ts\n * export const requests = new Inbox('Requests', {\n * addresses: ['requests'], // local parts: structural\n * subdomains: true, // requests@<tenant>.<stage domain>\n * });\n *\n * export const onRequest = worker\n * .inbox(requests)\n * .handle(async ({ messages }) => {\n * for (const message of messages) {\n * message.recipient.subdomain; // the tenant, from the envelope\n * message.recipient.tag; // requests+<tag>@\n * }\n * });\n * ```\n *\n * **Its own bucket, and a topic.** An inbox owns the bucket its raw messages\n * are kept in — each target creates it for the inbox, never one the stack\n * already runs — and provides its URL itself, so the bucket is no `objects`\n * node and no object subscriber can be bound to it. It declares the topic\n * each message is announced on, which only the provider publishes to.\n *\n * **One decoder.** Deployed, SES's receipt rule stores the raw message and\n * publishes its receipt notification on the topic. Locally `gkm dev` brings a\n * message in from Mailpit and publishes the same notification; in a feature\n * test `mailbox.receive` does. The handler is handed what {@link InboxClient}\n * makes of that notification, wherever it came from.\n *\n * **The envelope routes.** Which inbox, which tenant and which tag come from\n * the envelope recipient, never from `From:` or `To:`, which the sender wrote.\n */\n\nimport { type ParsedEmail, parseEmail } from '@geekmidas/emailkit/inbound';\nimport {\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\tINBOX_EVENT,\n\ttype InboxAddressing,\n\ttype InboxRecipient,\n\tinboxRecipient,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\nimport { createStorageClient } from '@geekmidas/storage';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { Construct } from './construct-interface';\nimport { Topic } from './topic/Topic';\n\nexport interface InboxOptions {\n\t/**\n\t * The local parts it receives at: `['requests']`. Each also takes a\n\t * `+tag` — `requests+t_8f3k@` — handed to the handler as `recipient.tag`.\n\t */\n\taddresses: readonly string[];\n\t/**\n\t * Receive at `<address>@<label>.<domain>` — one label, a tenant's — rather\n\t * than at the stage's domain itself.\n\t */\n\tsubdomains?: boolean;\n}\n\n/** An inbox declared with no address receives nothing. */\nexport class InboxHasNoAddresses extends Error {\n\tconstructor(readonly inbox: string) {\n\t\tsuper(\n\t\t\t`The inbox '${inbox}' names no address, so it would receive nothing. ` +\n\t\t\t\t`Name the local parts it receives at: addresses: ['requests'].`,\n\t\t);\n\t\tthis.name = 'InboxHasNoAddresses';\n\t}\n}\n\n/** An address that is not a bare local part: `requests@x`, `a+b`, `''`. */\nexport class InboxAddressInvalid extends Error {\n\tconstructor(\n\t\treadonly inbox: string,\n\t\treadonly address: string,\n\t) {\n\t\tsuper(\n\t\t\t`The inbox '${inbox}' names '${address}', which is not a local part. ` +\n\t\t\t\t`Name only what goes before the @ — the domain is the stage's — ` +\n\t\t\t\t`and no '+': every address takes a +tag already.`,\n\t\t);\n\t\tthis.name = 'InboxAddressInvalid';\n\t}\n}\n\n/**\n * A receipt notification the inbox cannot read: not SES's shape, or an action\n * other than the S3 one that stores the message where the decoder reads it.\n */\nexport class ReceiptNotificationMalformed extends Error {\n\tconstructor(\n\t\treadonly inbox: string,\n\t\treadonly reason: string,\n\t) {\n\t\tsuper(\n\t\t\t`The inbox '${inbox}' was handed a notification it cannot read: ${reason}. ` +\n\t\t\t\t`It reads SES receipt notifications whose action stored the message in S3.`,\n\t\t);\n\t\tthis.name = 'ReceiptNotificationMalformed';\n\t}\n}\n\n/**\n * A provider's verdict on a message.\n *\n * `'unavailable'` where nothing judged it — locally, always — and never a\n * faked `'pass'`.\n */\nexport type Verdict = 'pass' | 'fail' | 'gray' | 'unavailable';\n\n/** What the provider judged of a message, which the message cannot say of itself. */\nexport interface Verdicts {\n\tspf: Verdict;\n\tdkim: Verdict;\n\tdmarc: Verdict;\n\tspam: Verdict;\n\tvirus: Verdict;\n}\n\n/**\n * One received message, for one recipient it was delivered to.\n *\n * `recipient` is the envelope's; every other address is a header, written by\n * the sender. Inbound mail is untrusted input: route on `recipient`, treat\n * `from` as a claim until `verdicts.dmarc` passes *and* the address is known,\n * sanitise `html`, and never use an attachment's filename as a key or path.\n */\nexport interface InboxMessage\n\textends Omit<ParsedEmail, 'attachments'>,\n\t\tPick<ParsedEmail, 'attachments'> {\n\trecipient: InboxRecipient;\n\t/**\n\t * Where the raw message is kept: the bucket SES stored it in (`mailpit`\n\t * locally), and its key there.\n\t */\n\traw: { bucket: string; key: string };\n\tverdicts: Verdicts;\n}\n\n/** A status as SES writes one: `PASS`, `FAIL`, `GRAY`, `PROCESSING_FAILED`, `DISABLED`. */\ninterface ReceiptVerdict {\n\tstatus: string;\n}\n\n/**\n * SES's receipt notification — the part an inbox reads.\n *\n * `gkm dev` and the test mailbox publish the same shape, with every verdict\n * `UNAVAILABLE`, so one decoder serves all three.\n */\nexport interface ReceiptNotification {\n\tnotificationType: 'Received';\n\tmail: {\n\t\tmessageId: string;\n\t\ttimestamp: string;\n\t\t/** The envelope sender (`MAIL FROM`). */\n\t\tsource: string;\n\t\tdestination: string[];\n\t};\n\treceipt: {\n\t\ttimestamp: string;\n\t\t/** The envelope recipients this receipt rule matched. */\n\t\trecipients: string[];\n\t\tspamVerdict?: ReceiptVerdict;\n\t\tvirusVerdict?: ReceiptVerdict;\n\t\tspfVerdict?: ReceiptVerdict;\n\t\tdkimVerdict?: ReceiptVerdict;\n\t\tdmarcVerdict?: ReceiptVerdict;\n\t\taction: {\n\t\t\ttype: string;\n\t\t\tbucketName?: string;\n\t\t\tobjectKey?: string;\n\t\t\ttopicArn?: string;\n\t\t};\n\t};\n}\n\n/** What the handler's inbox is: its domain, its raw messages, the decoder. */\nexport interface InboxClient {\n\t/** The stage's domain it receives on. */\n\treadonly domain: string;\n\t/** A raw message's bytes, by its key in the bucket. */\n\traw(key: string): Promise<Uint8Array>;\n\t/**\n\t * The messages a notification announces: one per envelope recipient this\n\t * inbox receives at, parsed. Empty when none is — a receipt rule that takes\n\t * a whole domain stores mail for addresses no inbox declared.\n\t */\n\tmessages(notification: ReceiptNotification): Promise<InboxMessage[]>;\n}\n\n/** A schema that takes a receipt notification as it is — SES wrote it, not the app. */\nconst RECEIPT_NOTIFICATION: StandardSchemaV1<ReceiptNotification> = {\n\t'~standard': {\n\t\tversion: 1,\n\t\tvendor: 'geekmidas',\n\t\tvalidate: (value) => ({ value: value as ReceiptNotification }),\n\t},\n};\n\ntype InboxTopic = Topic<string, { [INBOX_EVENT]: typeof RECEIPT_NOTIFICATION }>;\n\nexport class Inbox<TName extends string = string>\n\timplements Construct<TName, InboxClient>\n{\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, InboxClient>;\n\t/** Where each received message is announced. Published to by the provider only. */\n\treadonly topic: InboxTopic;\n\n\t/** The local parts it receives at, and whether on a tenant's subdomain. */\n\treadonly addressing: InboxAddressing;\n\tprivate readonly addresses: readonly string[];\n\tprivate readonly subdomains: boolean;\n\tprivate readonly keys: { url: string; domain: string };\n\n\tconstructor(name: ConstructName<TName>, options: InboxOptions) {\n\t\tconst canonical = canonicalId(name as string);\n\t\tif (options.addresses.length === 0) {\n\t\t\tthrow new InboxHasNoAddresses(canonical);\n\t\t}\n\t\tfor (const address of options.addresses) {\n\t\t\tif (!/^[a-z0-9][a-z0-9._-]*$/i.test(address)) {\n\t\t\t\tthrow new InboxAddressInvalid(canonical, address);\n\t\t\t}\n\t\t}\n\n\t\tthis.id = canonical as TName;\n\t\tthis.addresses = options.addresses.map((a) => a.toLowerCase());\n\t\tthis.subdomains = options.subdomains === true;\n\t\tthis.addressing = {\n\t\t\taddresses: this.addresses,\n\t\t\t...(this.subdomains ? { subdomains: true } : {}),\n\t\t};\n\t\tthis.keys = {\n\t\t\turl: provideKey(canonical, 'url'),\n\t\t\tdomain: provideKey(canonical, 'domain'),\n\t\t};\n\t\tthis.topic = new Topic(`${canonical}Mail`, {\n\t\t\tevents: { [INBOX_EVENT]: RECEIPT_NOTIFICATION },\n\t\t}) as InboxTopic;\n\n\t\tthis.service = {\n\t\t\tserviceName: serviceKey(canonical) as Uncapitalize<TName>,\n\t\t\tregister: (register) => this.connect(register),\n\t\t};\n\t}\n\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t...this.topic.declare(),\n\t\t\t{\n\t\t\t\tkind: 'inbox',\n\t\t\t\tid: this.id,\n\t\t\t\tprovides: [this.keys.url, this.keys.domain],\n\t\t\t\taddresses: this.addresses,\n\t\t\t\t...(this.subdomains ? { subdomains: true } : {}),\n\t\t\t\ttopic: this.topic.id,\n\t\t\t},\n\t\t];\n\t}\n\n\tprivate async connect(\n\t\tregister: ServiceRegisterOptions,\n\t): Promise<InboxClient> {\n\t\tconst { url, domain } = register.envParser\n\t\t\t.create((get) => ({\n\t\t\t\turl: get(this.keys.url).string(),\n\t\t\t\tdomain: get(this.keys.domain).string(),\n\t\t\t}))\n\t\t\t.parse();\n\t\tconst read = rawReader(url);\n\t\tconst addressing = {\n\t\t\taddresses: this.addresses,\n\t\t\tsubdomains: this.subdomains,\n\t\t};\n\t\tconst inbox = this.id;\n\n\t\tconst raw = async (key: string): Promise<Uint8Array> => {\n\t\t\tconst response = await fetch(await read(key));\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow new RawMessageUnreadable(inbox, key, response.status);\n\t\t\t}\n\t\t\treturn new Uint8Array(await response.arrayBuffer());\n\t\t};\n\n\t\treturn {\n\t\t\tdomain,\n\t\t\traw,\n\t\t\tasync messages(notification) {\n\t\t\t\tconst { receipt } = assertReceipt(inbox, notification);\n\t\t\t\tconst recipients = receipt.recipients.flatMap((address) => {\n\t\t\t\t\tconst recipient = inboxRecipient(address, addressing, domain);\n\t\t\t\t\treturn recipient ? [recipient] : [];\n\t\t\t\t});\n\t\t\t\tif (recipients.length === 0) return [];\n\n\t\t\t\tconst key = receipt.action.objectKey!;\n\t\t\t\tconst parsed = await parseEmail(await raw(key));\n\t\t\t\tconst verdicts = verdictsOf(receipt);\n\t\t\t\treturn recipients.map((recipient) => ({\n\t\t\t\t\t...parsed,\n\t\t\t\t\trecipient,\n\t\t\t\t\traw: { bucket: receipt.action.bucketName!, key },\n\t\t\t\t\tverdicts,\n\t\t\t\t}));\n\t\t\t},\n\t\t};\n\t}\n}\n\n/**\n * Where a raw message is read from, by its key, for the store `url` names:\n * an `s3://` bucket deployed — SES stored it at `messages/<id>` — or, locally,\n * Mailpit's API, which keeps every message it receives under its own id.\n *\n * The one place local and deployed differ; everything that reads a message\n * goes through it.\n */\nfunction rawReader(url: string): (key: string) => Promise<string> {\n\tif (url.startsWith('s3:')) {\n\t\tconst bucket = createStorageClient(url);\n\t\treturn async (key) => (await bucket).getDownloadURL({ path: key });\n\t}\n\tconst base = url.replace(/\\/+$/, '');\n\treturn async (key) => `${base}/api/v1/message/${encodeURIComponent(key)}/raw`;\n}\n\n/** The raw message a notification names could not be read from its store. */\nexport class RawMessageUnreadable extends Error {\n\tconstructor(\n\t\treadonly inbox: string,\n\t\treadonly key: string,\n\t\treadonly status: number,\n\t) {\n\t\tsuper(\n\t\t\t`The inbox '${inbox}' could not read its raw message '${key}' (HTTP ${status}). ` +\n\t\t\t\t`It is written by the receipt rule before the notification is sent; ` +\n\t\t\t\t`check the bucket's policy lets the process that runs the handler read it.`,\n\t\t);\n\t\tthis.name = 'RawMessageUnreadable';\n\t}\n}\n\nfunction assertReceipt(inbox: string, value: unknown): ReceiptNotification {\n\tconst notification = value as Partial<ReceiptNotification> | undefined;\n\tif (notification?.notificationType !== 'Received') {\n\t\tthrow new ReceiptNotificationMalformed(\n\t\t\tinbox,\n\t\t\t`its notificationType is '${String(notification?.notificationType)}', not 'Received'`,\n\t\t);\n\t}\n\tconst action = notification.receipt?.action;\n\tif (action?.type !== 'S3' || !action.objectKey || !action.bucketName) {\n\t\tthrow new ReceiptNotificationMalformed(\n\t\t\tinbox,\n\t\t\t`its action is '${String(action?.type)}' without an S3 object`,\n\t\t);\n\t}\n\tif (!Array.isArray(notification.receipt?.recipients)) {\n\t\tthrow new ReceiptNotificationMalformed(inbox, 'it names no recipients');\n\t}\n\treturn notification as ReceiptNotification;\n}\n\nfunction verdict(status: ReceiptVerdict | undefined): Verdict {\n\tswitch (status?.status) {\n\t\tcase 'PASS':\n\t\t\treturn 'pass';\n\t\tcase 'FAIL':\n\t\t\treturn 'fail';\n\t\tcase 'GRAY':\n\t\t\treturn 'gray';\n\t\tdefault:\n\t\t\treturn 'unavailable';\n\t}\n}\n\nfunction verdictsOf(receipt: ReceiptNotification['receipt']): Verdicts {\n\treturn {\n\t\tspf: verdict(receipt.spfVerdict),\n\t\tdkim: verdict(receipt.dkimVerdict),\n\t\tdmarc: verdict(receipt.dmarcVerdict),\n\t\tspam: verdict(receipt.spamVerdict),\n\t\tvirus: verdict(receipt.virusVerdict),\n\t};\n}\n\n/**\n * The receipt notification a provider that judges nothing publishes —\n * `gkm dev` and the test mailbox — for a message stored at `objectKey`.\n */\nexport function unjudgedReceipt(options: {\n\tmessageId: string;\n\tsource: string;\n\trecipients: readonly string[];\n\tbucketName: string;\n\tobjectKey: string;\n\tverdicts?: Partial<Verdicts>;\n\ttimestamp?: Date;\n}): ReceiptNotification {\n\tconst at = (options.timestamp ?? new Date()).toISOString();\n\tconst status = (v: Verdict | undefined): ReceiptVerdict => ({\n\t\tstatus: v ? v.toUpperCase() : 'UNAVAILABLE',\n\t});\n\treturn {\n\t\tnotificationType: 'Received',\n\t\tmail: {\n\t\t\tmessageId: options.messageId,\n\t\t\ttimestamp: at,\n\t\t\tsource: options.source,\n\t\t\tdestination: [...options.recipients],\n\t\t},\n\t\treceipt: {\n\t\t\ttimestamp: at,\n\t\t\trecipients: [...options.recipients],\n\t\t\tspfVerdict: status(options.verdicts?.spf),\n\t\t\tdkimVerdict: status(options.verdicts?.dkim),\n\t\t\tdmarcVerdict: status(options.verdicts?.dmarc),\n\t\t\tspamVerdict: status(options.verdicts?.spam),\n\t\t\tvirusVerdict: status(options.verdicts?.virus),\n\t\t\taction: {\n\t\t\t\ttype: 'S3',\n\t\t\t\tbucketName: options.bucketName,\n\t\t\t\tobjectKey: options.objectKey,\n\t\t\t},\n\t\t},\n\t};\n}\n\n/** An inbox, as the receiver routes to it. */\nexport interface ReceivingInbox {\n\tid: string;\n\taddressing: InboxAddressing;\n\t/** The stage's domain it receives on. */\n\tdomain: string;\n\t/** Announce a received message on the inbox's topic. */\n\tpublish(notification: ReceiptNotification): Promise<void>;\n}\n\n/** A message that arrived where a provider that judges nothing stores mail. */\nexport interface ArrivedMessage {\n\t/** Its key in that store — Mailpit's message id locally. */\n\tkey: string;\n\t/** Where the store is, as a notification names it: `mailpit`. */\n\tstore: string;\n\t/** The envelope sender. */\n\tfrom: string;\n\t/** The envelope recipients — never `To:`. */\n\trecipients: readonly string[];\n\t/** What a test says the provider judged; `'unavailable'` otherwise. */\n\tverdicts?: Partial<Verdicts>;\n}\n\n/**\n * Receive a message the way a receipt rule does: for each inbox one of its\n * envelope recipients is addressed to, publish the receipt notification for\n * those recipients on the inbox's topic. What no inbox receives at goes\n * nowhere — mail the app sent to anyone else included.\n *\n * The one receiver for every local path: Mailpit's webhook under `gkm dev`\n * and a local compose stack, and `mailbox.receive` in a feature test. SES is\n * the receiver deployed. Returns the ids of the inboxes it announced to.\n */\nexport async function receiveMail(\n\tmessage: ArrivedMessage,\n\tinboxes: readonly ReceivingInbox[],\n): Promise<string[]> {\n\tconst received: string[] = [];\n\tfor (const inbox of inboxes) {\n\t\tconst recipients = message.recipients.filter((address) =>\n\t\t\tinboxRecipient(address, inbox.addressing, inbox.domain),\n\t\t);\n\t\tif (recipients.length === 0) continue;\n\t\tawait inbox.publish(\n\t\t\tunjudgedReceipt({\n\t\t\t\tmessageId: message.key,\n\t\t\t\tsource: message.from,\n\t\t\t\trecipients,\n\t\t\t\tbucketName: message.store,\n\t\t\t\tobjectKey: message.key,\n\t\t\t\t...(message.verdicts ? { verdicts: message.verdicts } : {}),\n\t\t\t}),\n\t\t);\n\t\treceived.push(inbox.id);\n\t}\n\treturn received;\n}\n\n/** Whether `value` is an {@link Inbox}. */\nexport function isInbox(value: unknown): value is Inbox {\n\treturn value instanceof Inbox;\n}\n"],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+ import { a as InboxHasNoAddresses, c as RawMessageUnreadable, d as ReceivingInbox, f as Verdict, g as unjudgedReceipt, h as receiveMail, i as InboxClient, l as ReceiptNotification, m as isInbox, n as Inbox, o as InboxMessage, p as Verdicts, r as InboxAddressInvalid, s as InboxOptions, t as ArrivedMessage, u as ReceiptNotificationMalformed } from "./inbox-CR3L1fOI.cjs";
2
+ export { ArrivedMessage, Inbox, InboxAddressInvalid, InboxClient, InboxHasNoAddresses, InboxMessage, InboxOptions, RawMessageUnreadable, ReceiptNotification, ReceiptNotificationMalformed, ReceivingInbox, Verdict, Verdicts, isInbox, receiveMail, unjudgedReceipt };
@@ -0,0 +1,2 @@
1
+ import { a as InboxHasNoAddresses, c as RawMessageUnreadable, d as ReceivingInbox, f as Verdict, g as unjudgedReceipt, h as receiveMail, i as InboxClient, l as ReceiptNotification, m as isInbox, n as Inbox, o as InboxMessage, p as Verdicts, r as InboxAddressInvalid, s as InboxOptions, t as ArrivedMessage, u as ReceiptNotificationMalformed } from "./inbox-CjxpLVkH.mjs";
2
+ export { ArrivedMessage, Inbox, InboxAddressInvalid, InboxClient, InboxHasNoAddresses, InboxMessage, InboxOptions, RawMessageUnreadable, ReceiptNotification, ReceiptNotificationMalformed, ReceivingInbox, Verdict, Verdicts, isInbox, receiveMail, unjudgedReceipt };