@geekmidas/constructs 10.0.0-alpha.16 → 10.0.0-alpha.161

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 (485) hide show
  1. package/README.md +246 -158
  2. package/dist/Construct-127M7yrl.d.cts +231 -0
  3. package/dist/Construct-127M7yrl.d.cts.map +1 -0
  4. package/dist/Construct-BMk_CRSD.d.mts +231 -0
  5. package/dist/Construct-BMk_CRSD.d.mts.map +1 -0
  6. package/dist/{Construct-BeYVu_QF.mjs → Construct-CGuc_Ijk.mjs} +8 -9
  7. package/dist/Construct-CGuc_Ijk.mjs.map +1 -0
  8. package/dist/{Construct-DqdlARxq.cjs → Construct-DorKS0Ua.cjs} +8 -9
  9. package/dist/Construct-DorKS0Ua.cjs.map +1 -0
  10. package/dist/{Cron-l4Wlz6G9.d.mts → Cron-D6Y7BBt3.d.mts} +15 -8
  11. package/dist/Cron-D6Y7BBt3.d.mts.map +1 -0
  12. package/dist/{Cron-zsoSAwZo.d.cts → Cron-D_sfaMGz.d.cts} +14 -7
  13. package/dist/Cron-D_sfaMGz.d.cts.map +1 -0
  14. package/dist/CronBuilder-4BZhkChG.d.mts +47 -0
  15. package/dist/CronBuilder-4BZhkChG.d.mts.map +1 -0
  16. package/dist/{CronBuilder-D_0HNBTr.mjs → CronBuilder-BJ5LoadF.mjs} +28 -11
  17. package/dist/CronBuilder-BJ5LoadF.mjs.map +1 -0
  18. package/dist/{CronBuilder-BdnI6lxF.cjs → CronBuilder-B_NSP-Y5.cjs} +27 -10
  19. package/dist/CronBuilder-B_NSP-Y5.cjs.map +1 -0
  20. package/dist/CronBuilder-C91MVLSr.d.cts +47 -0
  21. package/dist/CronBuilder-C91MVLSr.d.cts.map +1 -0
  22. package/dist/Endpoint-52z1P0Ue.cjs +581 -0
  23. package/dist/Endpoint-52z1P0Ue.cjs.map +1 -0
  24. package/dist/{Endpoint-oS-Fe3d_.d.mts → Endpoint-BUoDD96P.d.mts} +104 -23
  25. package/dist/Endpoint-BUoDD96P.d.mts.map +1 -0
  26. package/dist/{Endpoint-DBflWAe4.d.cts → Endpoint-YYwjqtS1.d.cts} +101 -20
  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/{index-Cc4kKPag.d.mts → EndpointFactory-BbVOeryo.d.mts} +189 -106
  31. package/dist/EndpointFactory-BbVOeryo.d.mts.map +1 -0
  32. package/dist/{EndpointFactory-Bm3aKRdV.mjs → EndpointFactory-Bzi9Sl7r.mjs} +269 -53
  33. package/dist/EndpointFactory-Bzi9Sl7r.mjs.map +1 -0
  34. package/dist/{EndpointFactory-CLvWuHyt.cjs → EndpointFactory-Cf_Cs1ym.cjs} +309 -51
  35. package/dist/EndpointFactory-Cf_Cs1ym.cjs.map +1 -0
  36. package/dist/{index-C1ZwNOOk.d.cts → EndpointFactory-Hh1r6J_C.d.cts} +187 -104
  37. package/dist/EndpointFactory-Hh1r6J_C.d.cts.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-BKReud5p.d.mts +76 -0
  41. package/dist/Function-BKReud5p.d.mts.map +1 -0
  42. package/dist/{HonoEndpointAdaptor-92zavCsV.cjs → HonoEndpointAdaptor-BTbqfSaa.cjs} +115 -41
  43. package/dist/HonoEndpointAdaptor-BTbqfSaa.cjs.map +1 -0
  44. package/dist/{HonoEndpointAdaptor-yYaU7jVJ.mjs → HonoEndpointAdaptor-CBVey2cY.mjs} +112 -38
  45. package/dist/HonoEndpointAdaptor-CBVey2cY.mjs.map +1 -0
  46. package/dist/ObjectSubscriberBuilder-DfzXQEKW.d.mts +129 -0
  47. package/dist/ObjectSubscriberBuilder-DfzXQEKW.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-D4oYvZeG.d.mts +216 -0
  51. package/dist/ProcessorBuilder-D4oYvZeG.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-B8HGg439.d.mts} +42 -41
  55. package/dist/Queue-B8HGg439.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-CVS_qPuo.d.mts +75 -0
  67. package/dist/QueueBuilder-CVS_qPuo.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-CtQXhcL7.d.mts +83 -0
  73. package/dist/Subscriber-CtQXhcL7.d.mts.map +1 -0
  74. package/dist/SubscriberBuilder-CpFhShTJ.mjs +238 -0
  75. package/dist/SubscriberBuilder-CpFhShTJ.mjs.map +1 -0
  76. package/dist/SubscriberBuilder-DJEvNRdD.cjs +261 -0
  77. package/dist/SubscriberBuilder-DJEvNRdD.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 +147 -168
  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 +142 -164
  89. package/dist/adaptors/aws.mjs.map +1 -1
  90. package/dist/adaptors/awsWebsocket.cjs +354 -0
  91. package/dist/adaptors/awsWebsocket.cjs.map +1 -0
  92. package/dist/adaptors/awsWebsocket.d.cts +156 -0
  93. package/dist/adaptors/awsWebsocket.d.cts.map +1 -0
  94. package/dist/adaptors/awsWebsocket.d.mts +156 -0
  95. package/dist/adaptors/awsWebsocket.d.mts.map +1 -0
  96. package/dist/adaptors/awsWebsocket.mjs +347 -0
  97. package/dist/adaptors/awsWebsocket.mjs.map +1 -0
  98. package/dist/adaptors/hono.cjs +1 -1
  99. package/dist/adaptors/hono.d.cts +8 -7
  100. package/dist/adaptors/hono.d.cts.map +1 -1
  101. package/dist/adaptors/hono.d.mts +10 -9
  102. package/dist/adaptors/hono.d.mts.map +1 -1
  103. package/dist/adaptors/hono.mjs +1 -1
  104. package/dist/adaptors/testing.cjs +1174 -41
  105. package/dist/adaptors/testing.cjs.map +1 -1
  106. package/dist/adaptors/testing.d.cts +517 -40
  107. package/dist/adaptors/testing.d.cts.map +1 -1
  108. package/dist/adaptors/testing.d.mts +517 -40
  109. package/dist/adaptors/testing.d.mts.map +1 -1
  110. package/dist/adaptors/testing.mjs +1140 -36
  111. package/dist/adaptors/testing.mjs.map +1 -1
  112. package/dist/auth-BqWz2JxC.d.cts +274 -0
  113. package/dist/auth-BqWz2JxC.d.cts.map +1 -0
  114. package/dist/auth-DnB9H9KL.d.mts +274 -0
  115. package/dist/auth-DnB9H9KL.d.mts.map +1 -0
  116. package/dist/auth.cjs +308 -23
  117. package/dist/auth.cjs.map +1 -1
  118. package/dist/auth.d.cts +2 -104
  119. package/dist/auth.d.mts +2 -104
  120. package/dist/auth.mjs +304 -25
  121. package/dist/auth.mjs.map +1 -1
  122. package/dist/cache-CCHcO9Oo.d.mts +44 -0
  123. package/dist/cache-CCHcO9Oo.d.mts.map +1 -0
  124. package/dist/cache-CQjMNPrC.d.cts +44 -0
  125. package/dist/cache-CQjMNPrC.d.cts.map +1 -0
  126. package/dist/cache.cjs +3 -19
  127. package/dist/cache.cjs.map +1 -1
  128. package/dist/cache.d.cts +2 -43
  129. package/dist/cache.d.mts +2 -43
  130. package/dist/cache.mjs +2 -18
  131. package/dist/cache.mjs.map +1 -1
  132. package/dist/cipher-C1lEFX63.mjs +225 -0
  133. package/dist/cipher-C1lEFX63.mjs.map +1 -0
  134. package/dist/cipher-CVxfwLjk.cjs +332 -0
  135. package/dist/cipher-CVxfwLjk.cjs.map +1 -0
  136. package/dist/cipher-DSDxPRIp.d.cts +106 -0
  137. package/dist/cipher-DSDxPRIp.d.cts.map +1 -0
  138. package/dist/cipher-DSDxPRIp.d.mts +106 -0
  139. package/dist/cipher-DSDxPRIp.d.mts.map +1 -0
  140. package/dist/{construct-interface-DPlxfpoS.d.mts → construct-interface-CSA9VeWM.d.mts} +47 -8
  141. package/dist/construct-interface-CSA9VeWM.d.mts.map +1 -0
  142. package/dist/{construct-interface-DgXTJcOD.d.cts → construct-interface-DugP0E5q.d.cts} +47 -8
  143. package/dist/construct-interface-DugP0E5q.d.cts.map +1 -0
  144. package/dist/construct-interface.cjs +38 -4
  145. package/dist/construct-interface.cjs.map +1 -1
  146. package/dist/construct-interface.d.cts +2 -2
  147. package/dist/construct-interface.d.mts +2 -2
  148. package/dist/construct-interface.mjs +37 -5
  149. package/dist/construct-interface.mjs.map +1 -1
  150. package/dist/credential-DYymbp_7.cjs +257 -0
  151. package/dist/credential-DYymbp_7.cjs.map +1 -0
  152. package/dist/credential-DfSAOOdY.mjs +222 -0
  153. package/dist/credential-DfSAOOdY.mjs.map +1 -0
  154. package/dist/credential.cjs +7 -129
  155. package/dist/credential.d.cts +2 -58
  156. package/dist/credential.d.mts +2 -58
  157. package/dist/credential.mjs +2 -128
  158. package/dist/crons/index.cjs +127 -1
  159. package/dist/crons/index.cjs.map +1 -1
  160. package/dist/crons/index.d.cts +43 -3
  161. package/dist/crons/index.d.cts.map +1 -1
  162. package/dist/crons/index.d.mts +43 -3
  163. package/dist/crons/index.d.mts.map +1 -1
  164. package/dist/crons/index.mjs +126 -2
  165. package/dist/crons/index.mjs.map +1 -1
  166. package/dist/database/kysely.cjs +3 -194
  167. package/dist/database/kysely.d.cts +2 -149
  168. package/dist/database/kysely.d.mts +2 -149
  169. package/dist/database/kysely.mjs +2 -192
  170. package/dist/email.cjs +4 -16
  171. package/dist/email.cjs.map +1 -1
  172. package/dist/email.d.cts +1 -1
  173. package/dist/email.d.cts.map +1 -1
  174. package/dist/email.d.mts +2 -2
  175. package/dist/email.d.mts.map +1 -1
  176. package/dist/email.mjs +2 -14
  177. package/dist/email.mjs.map +1 -1
  178. package/dist/encryption/kms.cjs +95 -0
  179. package/dist/encryption/kms.cjs.map +1 -0
  180. package/dist/encryption/kms.d.cts +7 -0
  181. package/dist/encryption/kms.d.cts.map +1 -0
  182. package/dist/encryption/kms.d.mts +7 -0
  183. package/dist/encryption/kms.d.mts.map +1 -0
  184. package/dist/encryption/kms.mjs +93 -0
  185. package/dist/encryption/kms.mjs.map +1 -0
  186. package/dist/encryption.cjs +116 -0
  187. package/dist/encryption.cjs.map +1 -0
  188. package/dist/encryption.d.cts +37 -0
  189. package/dist/encryption.d.cts.map +1 -0
  190. package/dist/encryption.d.mts +37 -0
  191. package/dist/encryption.d.mts.map +1 -0
  192. package/dist/encryption.mjs +101 -0
  193. package/dist/encryption.mjs.map +1 -0
  194. package/dist/endpoints/index.cjs +32 -10
  195. package/dist/endpoints/index.d.cts +106 -3
  196. package/dist/endpoints/index.d.cts.map +1 -0
  197. package/dist/endpoints/index.d.mts +106 -3
  198. package/dist/endpoints/index.d.mts.map +1 -0
  199. package/dist/endpoints/index.mjs +6 -4
  200. package/dist/expire-C586zznE.d.cts +38 -0
  201. package/dist/expire-C586zznE.d.cts.map +1 -0
  202. package/dist/expire-C586zznE.d.mts +38 -0
  203. package/dist/expire-C586zznE.d.mts.map +1 -0
  204. package/dist/expire-CieftS01.cjs +67 -0
  205. package/dist/expire-CieftS01.cjs.map +1 -0
  206. package/dist/expire-CpzUAfr9.mjs +50 -0
  207. package/dist/expire-CpzUAfr9.mjs.map +1 -0
  208. package/dist/external-api.cjs +106 -0
  209. package/dist/external-api.cjs.map +1 -0
  210. package/dist/external-api.d.cts +2 -0
  211. package/dist/external-api.d.mts +2 -0
  212. package/dist/external-api.mjs +103 -0
  213. package/dist/external-api.mjs.map +1 -0
  214. package/dist/fake-BqhP8RRQ.d.mts +201 -0
  215. package/dist/fake-BqhP8RRQ.d.mts.map +1 -0
  216. package/dist/fake-DqieDYYA.d.cts +201 -0
  217. package/dist/fake-DqieDYYA.d.cts.map +1 -0
  218. package/dist/file-server.cjs +123 -30
  219. package/dist/file-server.cjs.map +1 -1
  220. package/dist/file-server.d.cts +115 -1
  221. package/dist/file-server.d.cts.map +1 -1
  222. package/dist/file-server.d.mts +115 -1
  223. package/dist/file-server.d.mts.map +1 -1
  224. package/dist/file-server.mjs +122 -32
  225. package/dist/file-server.mjs.map +1 -1
  226. package/dist/functions/index.cjs +1 -1
  227. package/dist/functions/index.d.cts +2 -1
  228. package/dist/functions/index.d.mts +2 -1
  229. package/dist/functions/index.mjs +1 -1
  230. package/dist/{functions-C53GW2eQ.mjs → functions-BvIDQKAA.mjs} +117 -22
  231. package/dist/functions-BvIDQKAA.mjs.map +1 -0
  232. package/dist/{functions-B6qCvfmy.cjs → functions-DLF6-IK8.cjs} +122 -18
  233. package/dist/functions-DLF6-IK8.cjs.map +1 -0
  234. package/dist/inbox-CR3L1fOI.d.cts +195 -0
  235. package/dist/inbox-CR3L1fOI.d.cts.map +1 -0
  236. package/dist/inbox-YOdxlyfj.d.mts +195 -0
  237. package/dist/inbox-YOdxlyfj.d.mts.map +1 -0
  238. package/dist/inbox.cjs +291 -0
  239. package/dist/inbox.cjs.map +1 -0
  240. package/dist/inbox.d.cts +2 -0
  241. package/dist/inbox.d.mts +2 -0
  242. package/dist/inbox.mjs +283 -0
  243. package/dist/inbox.mjs.map +1 -0
  244. package/dist/index-BoQ3-M-K.d.mts +115 -0
  245. package/dist/index-BoQ3-M-K.d.mts.map +1 -0
  246. package/dist/index-DPTHa6Ud.d.cts +115 -0
  247. package/dist/index-DPTHa6Ud.d.cts.map +1 -0
  248. package/dist/{index-CeEtxDmK.d.cts → index-DdRjYhiJ.d.cts} +42 -2
  249. package/dist/{index-CeEtxDmK.d.cts.map → index-DdRjYhiJ.d.cts.map} +1 -1
  250. package/dist/{index-CeEtxDmK.d.mts → index-DdRjYhiJ.d.mts} +42 -2
  251. package/dist/{index-CeEtxDmK.d.mts.map → index-DdRjYhiJ.d.mts.map} +1 -1
  252. package/dist/index.cjs +4 -1
  253. package/dist/index.d.cts +26 -3
  254. package/dist/index.d.cts.map +1 -0
  255. package/dist/index.d.mts +26 -3
  256. package/dist/index.d.mts.map +1 -0
  257. package/dist/index.mjs +3 -2
  258. package/dist/kysely-CebjCWTl.d.cts +216 -0
  259. package/dist/kysely-CebjCWTl.d.cts.map +1 -0
  260. package/dist/kysely-Cs4uPO8k.mjs +371 -0
  261. package/dist/kysely-Cs4uPO8k.mjs.map +1 -0
  262. package/dist/kysely-CukArHJ0.cjs +384 -0
  263. package/dist/kysely-CukArHJ0.cjs.map +1 -0
  264. package/dist/kysely-De5rAC-E.d.mts +216 -0
  265. package/dist/kysely-De5rAC-E.d.mts.map +1 -0
  266. package/dist/{telemetry-DGcFlVpB.d.cts → lambdaTelemetry-8vnmVZQ5.d.cts} +2 -2
  267. package/dist/lambdaTelemetry-8vnmVZQ5.d.cts.map +1 -0
  268. package/dist/{telemetry-DGcFlVpB.d.mts → lambdaTelemetry-8vnmVZQ5.d.mts} +2 -2
  269. package/dist/lambdaTelemetry-8vnmVZQ5.d.mts.map +1 -0
  270. package/dist/mobile-app.cjs +74 -0
  271. package/dist/mobile-app.cjs.map +1 -0
  272. package/dist/mobile-app.d.cts +73 -0
  273. package/dist/mobile-app.d.cts.map +1 -0
  274. package/dist/mobile-app.d.mts +73 -0
  275. package/dist/mobile-app.d.mts.map +1 -0
  276. package/dist/mobile-app.mjs +73 -0
  277. package/dist/mobile-app.mjs.map +1 -0
  278. package/dist/object-storage.cjs +8 -1
  279. package/dist/object-storage.cjs.map +1 -1
  280. package/dist/object-storage.d.cts +10 -1
  281. package/dist/object-storage.d.cts.map +1 -1
  282. package/dist/object-storage.d.mts +10 -1
  283. package/dist/object-storage.d.mts.map +1 -1
  284. package/dist/object-storage.mjs +7 -2
  285. package/dist/object-storage.mjs.map +1 -1
  286. package/dist/optionalPeers-D7Wt6dnF.mjs +140 -0
  287. package/dist/optionalPeers-D7Wt6dnF.mjs.map +1 -0
  288. package/dist/optionalPeers-DuNQXXe1.cjs +223 -0
  289. package/dist/optionalPeers-DuNQXXe1.cjs.map +1 -0
  290. package/dist/origins-BjxYht13.cjs +96 -0
  291. package/dist/origins-BjxYht13.cjs.map +1 -0
  292. package/dist/origins-Boc9qbo-.mjs +73 -0
  293. package/dist/origins-Boc9qbo-.mjs.map +1 -0
  294. package/dist/pattern-C1CEcglD.mjs +241 -0
  295. package/dist/pattern-C1CEcglD.mjs.map +1 -0
  296. package/dist/pattern-QFaUIr77.cjs +288 -0
  297. package/dist/pattern-QFaUIr77.cjs.map +1 -0
  298. package/dist/privateAddress-Bg5fUsbp.mjs +21 -0
  299. package/dist/privateAddress-Bg5fUsbp.mjs.map +1 -0
  300. package/dist/privateAddress-CqGyuFHn.cjs +26 -0
  301. package/dist/privateAddress-CqGyuFHn.cjs.map +1 -0
  302. package/dist/processors/index.cjs +214 -0
  303. package/dist/processors/index.cjs.map +1 -0
  304. package/dist/processors/index.d.cts +78 -0
  305. package/dist/processors/index.d.cts.map +1 -0
  306. package/dist/processors/index.d.mts +78 -0
  307. package/dist/processors/index.d.mts.map +1 -0
  308. package/dist/processors/index.mjs +193 -0
  309. package/dist/processors/index.mjs.map +1 -0
  310. package/dist/queue/index.cjs +5 -192
  311. package/dist/queue/index.d.cts +3 -53
  312. package/dist/queue/index.d.mts +3 -53
  313. package/dist/queue/index.mjs +3 -190
  314. package/dist/random-password.cjs +86 -0
  315. package/dist/random-password.cjs.map +1 -0
  316. package/dist/random-password.d.cts +30 -0
  317. package/dist/random-password.d.cts.map +1 -0
  318. package/dist/random-password.d.mts +30 -0
  319. package/dist/random-password.d.mts.map +1 -0
  320. package/dist/random-password.mjs +84 -0
  321. package/dist/random-password.mjs.map +1 -0
  322. package/dist/readRequestBody-BmKnPl0a.mjs +293 -0
  323. package/dist/readRequestBody-BmKnPl0a.mjs.map +1 -0
  324. package/dist/{lazyAccessors-Dx9NLwJZ.cjs → readRequestBody-CN9GVdeE.cjs} +141 -47
  325. package/dist/readRequestBody-CN9GVdeE.cjs.map +1 -0
  326. package/dist/{processAudits-D_2W5x8k.cjs → requestLogger-CnoYd-Ah.cjs} +63 -3
  327. package/dist/requestLogger-CnoYd-Ah.cjs.map +1 -0
  328. package/dist/{processAudits-BpRlPQMW.mjs → requestLogger-D2JS7pPM.mjs} +51 -3
  329. package/dist/requestLogger-D2JS7pPM.mjs.map +1 -0
  330. package/dist/rest-api.cjs +85 -70
  331. package/dist/rest-api.cjs.map +1 -1
  332. package/dist/rest-api.d.cts +77 -59
  333. package/dist/rest-api.d.cts.map +1 -1
  334. package/dist/rest-api.d.mts +77 -59
  335. package/dist/rest-api.d.mts.map +1 -1
  336. package/dist/rest-api.mjs +87 -72
  337. package/dist/rest-api.mjs.map +1 -1
  338. package/dist/runSubscriber-HEqXkin1.mjs +117 -0
  339. package/dist/runSubscriber-HEqXkin1.mjs.map +1 -0
  340. package/dist/runSubscriber-sVJfLA0-.cjs +134 -0
  341. package/dist/runSubscriber-sVJfLA0-.cjs.map +1 -0
  342. package/dist/shutdown-BMJmAhSt.cjs +38 -0
  343. package/dist/shutdown-BMJmAhSt.cjs.map +1 -0
  344. package/dist/shutdown-C7xa8x9S.mjs +27 -0
  345. package/dist/shutdown-C7xa8x9S.mjs.map +1 -0
  346. package/dist/site.cjs +104 -8
  347. package/dist/site.cjs.map +1 -1
  348. package/dist/site.d.cts +132 -2
  349. package/dist/site.d.cts.map +1 -1
  350. package/dist/site.d.mts +132 -2
  351. package/dist/site.d.mts.map +1 -1
  352. package/dist/site.mjs +102 -11
  353. package/dist/site.mjs.map +1 -1
  354. package/dist/stages-DaTaoQei.d.cts +73 -0
  355. package/dist/stages-DaTaoQei.d.cts.map +1 -0
  356. package/dist/stages-DaTaoQei.d.mts +73 -0
  357. package/dist/stages-DaTaoQei.d.mts.map +1 -0
  358. package/dist/subscribers/index.cjs +134 -1
  359. package/dist/subscribers/index.cjs.map +1 -0
  360. package/dist/subscribers/index.d.cts +74 -3
  361. package/dist/subscribers/index.d.cts.map +1 -0
  362. package/dist/subscribers/index.d.mts +74 -3
  363. package/dist/subscribers/index.d.mts.map +1 -0
  364. package/dist/subscribers/index.mjs +132 -2
  365. package/dist/subscribers/index.mjs.map +1 -0
  366. package/dist/telemetry-C1oqncFY.d.cts +40 -0
  367. package/dist/telemetry-C1oqncFY.d.cts.map +1 -0
  368. package/dist/telemetry-CObow3Dn.d.mts +40 -0
  369. package/dist/telemetry-CObow3Dn.d.mts.map +1 -0
  370. package/dist/telemetry.cjs +56 -0
  371. package/dist/telemetry.cjs.map +1 -0
  372. package/dist/telemetry.d.cts +2 -0
  373. package/dist/telemetry.d.mts +2 -0
  374. package/dist/telemetry.mjs +55 -0
  375. package/dist/telemetry.mjs.map +1 -0
  376. package/dist/topic/index.cjs +2 -134
  377. package/dist/topic/index.d.cts +2 -3
  378. package/dist/topic/index.d.mts +2 -3
  379. package/dist/topic/index.mjs +2 -132
  380. package/dist/tracing-Bbj1uoFJ.mjs +127 -0
  381. package/dist/tracing-Bbj1uoFJ.mjs.map +1 -0
  382. package/dist/tracing-C0ooU0V2.cjs +150 -0
  383. package/dist/tracing-C0ooU0V2.cjs.map +1 -0
  384. package/dist/websocket-api-Bg9SowJ5.mjs +1710 -0
  385. package/dist/websocket-api-Bg9SowJ5.mjs.map +1 -0
  386. package/dist/websocket-api-CPEzJyDt.d.mts +1201 -0
  387. package/dist/websocket-api-CPEzJyDt.d.mts.map +1 -0
  388. package/dist/websocket-api-DkF8Hva-.d.cts +1201 -0
  389. package/dist/websocket-api-DkF8Hva-.d.cts.map +1 -0
  390. package/dist/websocket-api-czxhekGG.cjs +1889 -0
  391. package/dist/websocket-api-czxhekGG.cjs.map +1 -0
  392. package/dist/websocket-api.cjs +35 -0
  393. package/dist/websocket-api.d.cts +2 -0
  394. package/dist/websocket-api.d.mts +2 -0
  395. package/dist/websocket-api.mjs +3 -0
  396. package/dist/worker.cjs +174 -32
  397. package/dist/worker.cjs.map +1 -1
  398. package/dist/worker.d.cts +147 -47
  399. package/dist/worker.d.cts.map +1 -1
  400. package/dist/worker.d.mts +147 -47
  401. package/dist/worker.d.mts.map +1 -1
  402. package/dist/worker.mjs +175 -33
  403. package/dist/worker.mjs.map +1 -1
  404. package/package.json +180 -43
  405. package/dist/Construct-BeYVu_QF.mjs.map +0 -1
  406. package/dist/Construct-DfbwIntp.d.cts +0 -115
  407. package/dist/Construct-DfbwIntp.d.cts.map +0 -1
  408. package/dist/Construct-DqdlARxq.cjs.map +0 -1
  409. package/dist/Construct-l5aOn_jv.d.mts +0 -115
  410. package/dist/Construct-l5aOn_jv.d.mts.map +0 -1
  411. package/dist/Cron-l4Wlz6G9.d.mts.map +0 -1
  412. package/dist/Cron-zsoSAwZo.d.cts.map +0 -1
  413. package/dist/CronBuilder-BdnI6lxF.cjs.map +0 -1
  414. package/dist/CronBuilder-CyT71Nzg.d.cts +0 -41
  415. package/dist/CronBuilder-CyT71Nzg.d.cts.map +0 -1
  416. package/dist/CronBuilder-D_0HNBTr.mjs.map +0 -1
  417. package/dist/CronBuilder-UoNgFe8S.d.mts +0 -41
  418. package/dist/CronBuilder-UoNgFe8S.d.mts.map +0 -1
  419. package/dist/Endpoint-BpZHtJ2W.cjs +0 -1689
  420. package/dist/Endpoint-BpZHtJ2W.cjs.map +0 -1
  421. package/dist/Endpoint-DBflWAe4.d.cts.map +0 -1
  422. package/dist/Endpoint-ONsly_dq.mjs +0 -1671
  423. package/dist/Endpoint-ONsly_dq.mjs.map +0 -1
  424. package/dist/Endpoint-oS-Fe3d_.d.mts.map +0 -1
  425. package/dist/EndpointFactory-Bm3aKRdV.mjs.map +0 -1
  426. package/dist/EndpointFactory-CLvWuHyt.cjs.map +0 -1
  427. package/dist/HonoEndpointAdaptor-92zavCsV.cjs.map +0 -1
  428. package/dist/HonoEndpointAdaptor-yYaU7jVJ.mjs.map +0 -1
  429. package/dist/Queue-D9X6OoON.d.mts.map +0 -1
  430. package/dist/Queue-DYPB2KWL.d.cts.map +0 -1
  431. package/dist/Subscriber-C4heaAyO.d.mts +0 -51
  432. package/dist/Subscriber-C4heaAyO.d.mts.map +0 -1
  433. package/dist/Subscriber-CotDUELC.d.cts +0 -51
  434. package/dist/Subscriber-CotDUELC.d.cts.map +0 -1
  435. package/dist/SubscriberBuilder-BEv0eoHy.d.cts +0 -59
  436. package/dist/SubscriberBuilder-BEv0eoHy.d.cts.map +0 -1
  437. package/dist/SubscriberBuilder-C0ZEtGDI.cjs +0 -125
  438. package/dist/SubscriberBuilder-C0ZEtGDI.cjs.map +0 -1
  439. package/dist/SubscriberBuilder-h7B_cHMr.mjs +0 -114
  440. package/dist/SubscriberBuilder-h7B_cHMr.mjs.map +0 -1
  441. package/dist/SubscriberBuilder-tyH5yTk5.d.mts +0 -59
  442. package/dist/SubscriberBuilder-tyH5yTk5.d.mts.map +0 -1
  443. package/dist/Topic-DEVGo0Dm.d.cts +0 -89
  444. package/dist/Topic-DEVGo0Dm.d.cts.map +0 -1
  445. package/dist/Topic-zk_6Gthr.d.mts +0 -89
  446. package/dist/Topic-zk_6Gthr.d.mts.map +0 -1
  447. package/dist/auth.d.cts.map +0 -1
  448. package/dist/auth.d.mts.map +0 -1
  449. package/dist/cache.d.cts.map +0 -1
  450. package/dist/cache.d.mts.map +0 -1
  451. package/dist/construct-interface-DPlxfpoS.d.mts.map +0 -1
  452. package/dist/construct-interface-DgXTJcOD.d.cts.map +0 -1
  453. package/dist/credential.cjs.map +0 -1
  454. package/dist/credential.d.cts.map +0 -1
  455. package/dist/credential.d.mts.map +0 -1
  456. package/dist/credential.mjs.map +0 -1
  457. package/dist/database/kysely.cjs.map +0 -1
  458. package/dist/database/kysely.d.cts.map +0 -1
  459. package/dist/database/kysely.d.mts.map +0 -1
  460. package/dist/database/kysely.mjs.map +0 -1
  461. package/dist/functions-B6qCvfmy.cjs.map +0 -1
  462. package/dist/functions-C53GW2eQ.mjs.map +0 -1
  463. package/dist/index-B2urf3YI.d.cts +0 -26
  464. package/dist/index-B2urf3YI.d.cts.map +0 -1
  465. package/dist/index-C1ZwNOOk.d.cts.map +0 -1
  466. package/dist/index-Cc4kKPag.d.mts.map +0 -1
  467. package/dist/index-DMCDvnsM.d.mts +0 -26
  468. package/dist/index-DMCDvnsM.d.mts.map +0 -1
  469. package/dist/index-D_frT6MP.d.cts +0 -165
  470. package/dist/index-D_frT6MP.d.cts.map +0 -1
  471. package/dist/index-DcyIYbDS.d.mts +0 -165
  472. package/dist/index-DcyIYbDS.d.mts.map +0 -1
  473. package/dist/lazyAccessors-BHtcqgz2.mjs +0 -211
  474. package/dist/lazyAccessors-BHtcqgz2.mjs.map +0 -1
  475. package/dist/lazyAccessors-Dx9NLwJZ.cjs.map +0 -1
  476. package/dist/processAudits-BpRlPQMW.mjs.map +0 -1
  477. package/dist/processAudits-D_2W5x8k.cjs.map +0 -1
  478. package/dist/queue/index.cjs.map +0 -1
  479. package/dist/queue/index.d.cts.map +0 -1
  480. package/dist/queue/index.d.mts.map +0 -1
  481. package/dist/queue/index.mjs.map +0 -1
  482. package/dist/telemetry-DGcFlVpB.d.cts.map +0 -1
  483. package/dist/telemetry-DGcFlVpB.d.mts.map +0 -1
  484. package/dist/topic/index.cjs.map +0 -1
  485. package/dist/topic/index.mjs.map +0 -1
package/dist/inbox.mjs ADDED
@@ -0,0 +1,283 @@
1
+ import { t as Topic } from "./Topic-DN2gYJ-p.mjs";
2
+ import { INBOX_EVENT, canonicalId, inboxRecipient, provideKey, serviceKey } from "@geekmidas/manifest";
3
+ import { createStorageClient } from "@geekmidas/storage";
4
+ import { parseEmail } from "@geekmidas/emailkit/inbound";
5
+ //#region src/inbox.ts
6
+ /**
7
+ * `Inbox` — mail received at addresses on the stage's domain, each message
8
+ * handled in a worker.
9
+ *
10
+ * ```ts
11
+ * export const requests = new Inbox('Requests', {
12
+ * addresses: ['requests'], // local parts: structural
13
+ * subdomains: true, // requests@<tenant>.<stage domain>
14
+ * });
15
+ *
16
+ * export const onRequest = worker
17
+ * .inbox(requests)
18
+ * .handle(async ({ messages }) => {
19
+ * for (const message of messages) {
20
+ * message.recipient.subdomain; // the tenant, from the envelope
21
+ * message.recipient.tag; // requests+<tag>@
22
+ * }
23
+ * });
24
+ * ```
25
+ *
26
+ * **Its own bucket, and a topic.** An inbox owns the bucket its raw messages
27
+ * are kept in — each target creates it for the inbox, never one the stack
28
+ * already runs — and provides its URL itself, so the bucket is no `objects`
29
+ * node and no object subscriber can be bound to it. It declares the topic
30
+ * each message is announced on, which only the provider publishes to.
31
+ *
32
+ * **One decoder.** Deployed, SES's receipt rule stores the raw message and
33
+ * publishes its receipt notification on the topic. Locally `gkm dev` brings a
34
+ * message in from Mailpit and publishes the same notification; in a feature
35
+ * test `mailbox.receive` does. The handler is handed what {@link InboxClient}
36
+ * makes of that notification, wherever it came from.
37
+ *
38
+ * **The envelope routes.** Which inbox, which tenant and which tag come from
39
+ * the envelope recipient, never from `From:` or `To:`, which the sender wrote.
40
+ */
41
+ /** An inbox declared with no address receives nothing. */
42
+ var InboxHasNoAddresses = class extends Error {
43
+ inbox;
44
+ constructor(inbox) {
45
+ super(`The inbox '${inbox}' names no address, so it would receive nothing. Name the local parts it receives at: addresses: ['requests'].`);
46
+ this.inbox = inbox;
47
+ this.name = "InboxHasNoAddresses";
48
+ }
49
+ };
50
+ /** An address that is not a bare local part: `requests@x`, `a+b`, `''`. */
51
+ var InboxAddressInvalid = class extends Error {
52
+ inbox;
53
+ address;
54
+ constructor(inbox, address) {
55
+ 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.`);
56
+ this.inbox = inbox;
57
+ this.address = address;
58
+ this.name = "InboxAddressInvalid";
59
+ }
60
+ };
61
+ /**
62
+ * A receipt notification the inbox cannot read: not SES's shape, or an action
63
+ * other than the S3 one that stores the message where the decoder reads it.
64
+ */
65
+ var ReceiptNotificationMalformed = class extends Error {
66
+ inbox;
67
+ reason;
68
+ constructor(inbox, reason) {
69
+ super(`The inbox '${inbox}' was handed a notification it cannot read: ${reason}. It reads SES receipt notifications whose action stored the message in S3.`);
70
+ this.inbox = inbox;
71
+ this.reason = reason;
72
+ this.name = "ReceiptNotificationMalformed";
73
+ }
74
+ };
75
+ /** A schema that takes a receipt notification as it is — SES wrote it, not the app. */
76
+ const RECEIPT_NOTIFICATION = { "~standard": {
77
+ version: 1,
78
+ vendor: "geekmidas",
79
+ validate: (value) => ({ value })
80
+ } };
81
+ var Inbox = class {
82
+ id;
83
+ service;
84
+ /** Where each received message is announced. Published to by the provider only. */
85
+ topic;
86
+ /** The local parts it receives at, and whether on a tenant's subdomain. */
87
+ addressing;
88
+ addresses;
89
+ subdomains;
90
+ keys;
91
+ constructor(name, options) {
92
+ const canonical = canonicalId(name);
93
+ if (options.addresses.length === 0) throw new InboxHasNoAddresses(canonical);
94
+ for (const address of options.addresses) if (!/^[a-z0-9][a-z0-9._-]*$/i.test(address)) throw new InboxAddressInvalid(canonical, address);
95
+ this.id = canonical;
96
+ this.addresses = options.addresses.map((a) => a.toLowerCase());
97
+ this.subdomains = options.subdomains === true;
98
+ this.addressing = {
99
+ addresses: this.addresses,
100
+ ...this.subdomains ? { subdomains: true } : {}
101
+ };
102
+ this.keys = {
103
+ url: provideKey(canonical, "url"),
104
+ domain: provideKey(canonical, "domain")
105
+ };
106
+ this.topic = new Topic(`${canonical}Mail`, { events: { [INBOX_EVENT]: RECEIPT_NOTIFICATION } });
107
+ this.service = {
108
+ serviceName: serviceKey(canonical),
109
+ register: (register) => this.connect(register)
110
+ };
111
+ }
112
+ declare() {
113
+ return [...this.topic.declare(), {
114
+ kind: "inbox",
115
+ id: this.id,
116
+ provides: [this.keys.url, this.keys.domain],
117
+ addresses: this.addresses,
118
+ ...this.subdomains ? { subdomains: true } : {},
119
+ topic: this.topic.id
120
+ }];
121
+ }
122
+ async connect(register) {
123
+ const { url, domain } = register.envParser.create((get) => ({
124
+ url: get(this.keys.url).string(),
125
+ domain: get(this.keys.domain).string()
126
+ })).parse();
127
+ const read = rawReader(url);
128
+ const addressing = {
129
+ addresses: this.addresses,
130
+ subdomains: this.subdomains
131
+ };
132
+ const inbox = this.id;
133
+ const raw = async (key) => {
134
+ const response = await fetch(await read(key));
135
+ if (!response.ok) throw new RawMessageUnreadable(inbox, key, response.status);
136
+ return new Uint8Array(await response.arrayBuffer());
137
+ };
138
+ return {
139
+ domain,
140
+ raw,
141
+ async messages(notification) {
142
+ const { receipt } = assertReceipt(inbox, notification);
143
+ const recipients = receipt.recipients.flatMap((address) => {
144
+ const recipient = inboxRecipient(address, addressing, domain);
145
+ return recipient ? [recipient] : [];
146
+ });
147
+ if (recipients.length === 0) return [];
148
+ const key = receipt.action.objectKey;
149
+ const parsed = await parseEmail(await raw(key));
150
+ const verdicts = verdictsOf(receipt);
151
+ return recipients.map((recipient) => ({
152
+ ...parsed,
153
+ recipient,
154
+ raw: {
155
+ bucket: receipt.action.bucketName,
156
+ key
157
+ },
158
+ verdicts
159
+ }));
160
+ }
161
+ };
162
+ }
163
+ };
164
+ /**
165
+ * Where a raw message is read from, by its key, for the store `url` names:
166
+ * an `s3://` bucket deployed — SES stored it at `messages/<id>` — or, locally,
167
+ * Mailpit's API, which keeps every message it receives under its own id.
168
+ *
169
+ * The one place local and deployed differ; everything that reads a message
170
+ * goes through it.
171
+ */
172
+ function rawReader(url) {
173
+ if (url.startsWith("s3:")) {
174
+ const bucket = createStorageClient(url);
175
+ return async (key) => (await bucket).getDownloadURL({ path: key });
176
+ }
177
+ const base = url.replace(/\/+$/, "");
178
+ return async (key) => `${base}/api/v1/message/${encodeURIComponent(key)}/raw`;
179
+ }
180
+ /** The raw message a notification names could not be read from its store. */
181
+ var RawMessageUnreadable = class extends Error {
182
+ inbox;
183
+ key;
184
+ status;
185
+ constructor(inbox, key, status) {
186
+ 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.`);
187
+ this.inbox = inbox;
188
+ this.key = key;
189
+ this.status = status;
190
+ this.name = "RawMessageUnreadable";
191
+ }
192
+ };
193
+ function assertReceipt(inbox, value) {
194
+ const notification = value;
195
+ if (notification?.notificationType !== "Received") throw new ReceiptNotificationMalformed(inbox, `its notificationType is '${String(notification?.notificationType)}', not 'Received'`);
196
+ const action = notification.receipt?.action;
197
+ if (action?.type !== "S3" || !action.objectKey || !action.bucketName) throw new ReceiptNotificationMalformed(inbox, `its action is '${String(action?.type)}' without an S3 object`);
198
+ if (!Array.isArray(notification.receipt?.recipients)) throw new ReceiptNotificationMalformed(inbox, "it names no recipients");
199
+ return notification;
200
+ }
201
+ function verdict(status) {
202
+ switch (status?.status) {
203
+ case "PASS": return "pass";
204
+ case "FAIL": return "fail";
205
+ case "GRAY": return "gray";
206
+ default: return "unavailable";
207
+ }
208
+ }
209
+ function verdictsOf(receipt) {
210
+ return {
211
+ spf: verdict(receipt.spfVerdict),
212
+ dkim: verdict(receipt.dkimVerdict),
213
+ dmarc: verdict(receipt.dmarcVerdict),
214
+ spam: verdict(receipt.spamVerdict),
215
+ virus: verdict(receipt.virusVerdict)
216
+ };
217
+ }
218
+ /**
219
+ * The receipt notification a provider that judges nothing publishes —
220
+ * `gkm dev` and the test mailbox — for a message stored at `objectKey`.
221
+ */
222
+ function unjudgedReceipt(options) {
223
+ const at = (options.timestamp ?? /* @__PURE__ */ new Date()).toISOString();
224
+ const status = (v) => ({ status: v ? v.toUpperCase() : "UNAVAILABLE" });
225
+ return {
226
+ notificationType: "Received",
227
+ mail: {
228
+ messageId: options.messageId,
229
+ timestamp: at,
230
+ source: options.source,
231
+ destination: [...options.recipients]
232
+ },
233
+ receipt: {
234
+ timestamp: at,
235
+ recipients: [...options.recipients],
236
+ spfVerdict: status(options.verdicts?.spf),
237
+ dkimVerdict: status(options.verdicts?.dkim),
238
+ dmarcVerdict: status(options.verdicts?.dmarc),
239
+ spamVerdict: status(options.verdicts?.spam),
240
+ virusVerdict: status(options.verdicts?.virus),
241
+ action: {
242
+ type: "S3",
243
+ bucketName: options.bucketName,
244
+ objectKey: options.objectKey
245
+ }
246
+ }
247
+ };
248
+ }
249
+ /**
250
+ * Receive a message the way a receipt rule does: for each inbox one of its
251
+ * envelope recipients is addressed to, publish the receipt notification for
252
+ * those recipients on the inbox's topic. What no inbox receives at goes
253
+ * nowhere — mail the app sent to anyone else included.
254
+ *
255
+ * The one receiver for every local path: Mailpit's webhook under `gkm dev`
256
+ * and a local compose stack, and `mailbox.receive` in a feature test. SES is
257
+ * the receiver deployed. Returns the ids of the inboxes it announced to.
258
+ */
259
+ async function receiveMail(message, inboxes) {
260
+ const received = [];
261
+ for (const inbox of inboxes) {
262
+ const recipients = message.recipients.filter((address) => inboxRecipient(address, inbox.addressing, inbox.domain));
263
+ if (recipients.length === 0) continue;
264
+ await inbox.publish(unjudgedReceipt({
265
+ messageId: message.key,
266
+ source: message.from,
267
+ recipients,
268
+ bucketName: message.store,
269
+ objectKey: message.key,
270
+ ...message.verdicts ? { verdicts: message.verdicts } : {}
271
+ }));
272
+ received.push(inbox.id);
273
+ }
274
+ return received;
275
+ }
276
+ /** Whether `value` is an {@link Inbox}. */
277
+ function isInbox(value) {
278
+ return value instanceof Inbox;
279
+ }
280
+ //#endregion
281
+ export { Inbox, InboxAddressInvalid, InboxHasNoAddresses, RawMessageUnreadable, ReceiptNotificationMalformed, isInbox, receiveMail, unjudgedReceipt };
282
+
283
+ //# sourceMappingURL=inbox.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inbox.mjs","names":[],"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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoEA,IAAa,sBAAb,cAAyC,MAAM;CACzB;CAArB,YAAY,OAAwB;EACnC,MACC,cAAc,MAAM,+GAErB;EAJoB,KAAA,QAAA;EAKpB,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,sBAAb,cAAyC,MAAM;CAEpC;CACA;CAFV,YACC,OACA,SACC;EACD,MACC,cAAc,MAAM,WAAW,QAAQ,6IAGxC;EAPS,KAAA,QAAA;EACA,KAAA,UAAA;EAOT,KAAK,OAAO;CACb;AACD;;;;;AAMA,IAAa,+BAAb,cAAkD,MAAM;CAE7C;CACA;CAFV,YACC,OACA,QACC;EACD,MACC,cAAc,MAAM,8CAA8C,OAAO,4EAE1E;EANS,KAAA,QAAA;EACA,KAAA,SAAA;EAMT,KAAK,OAAO;CACb;AACD;;AA4FA,MAAM,uBAA8D,EACnE,aAAa;CACZ,SAAS;CACT,QAAQ;CACR,WAAW,WAAW,EAAS,MAA6B;AAC7D,EACD;AAIA,IAAa,QAAb,MAEA;CACC;CACA;;CAEA;;CAGA;CACA;CACA;CACA;CAEA,YAAY,MAA4B,SAAuB;EAC9D,MAAM,YAAY,YAAY,IAA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I;GAC1C,cAAc,OAAO,QAAQ,UAAU,KAAK;GAC5C,aAAa,OAAO,QAAQ,UAAU,IAAI;GAC1C,cAAc,OAAO,QAAQ,UAAU,KAAK;GAC5C,QAAQ;IACP,MAAM;IACN,YAAY,QAAQ;IACpB,WAAW,QAAQ;GACpB;EACD;CACD;AACD;;;;;;;;;;;AAoCA,eAAsB,YACrB,SACA,SACoB;CACpB,MAAM,WAAqB,CAAC;CAC5B,KAAK,MAAM,SAAS,SAAS;EAC5B,MAAM,aAAa,QAAQ,WAAW,QAAQ,YAC7C,eAAe,SAAS,MAAM,YAAY,MAAM,MAAM,CACvD;EACA,IAAI,WAAW,WAAW,GAAG;EAC7B,MAAM,MAAM,QACX,gBAAgB;GACf,WAAW,QAAQ;GACnB,QAAQ,QAAQ;GAChB;GACA,YAAY,QAAQ;GACpB,WAAW,QAAQ;GACnB,GAAI,QAAQ,WAAW,EAAE,UAAU,QAAQ,SAAS,IAAI,CAAC;EAC1D,CAAC,CACF;EACA,SAAS,KAAK,MAAM,EAAE;CACvB;CACA,OAAO;AACR;;AAGA,SAAgB,QAAQ,OAAgC;CACvD,OAAO,iBAAiB;AACzB"}
@@ -0,0 +1,115 @@
1
+ import { n as StandardSchemaV1 } from "./index-DdRjYhiJ.mjs";
2
+ import { a as EventFor, c as Topic, n as ConstructType, o as TopicEvent } from "./Construct-BMk_CRSD.mjs";
3
+ import { i as FunctionHandler, n as Function } from "./Function-BKReud5p.mjs";
4
+ import { c as ServicesOf, r as Consumable } from "./construct-interface-CSA9VeWM.mjs";
5
+ import { Service } from "@geekmidas/services";
6
+ import { Logger } from "@geekmidas/logger";
7
+ import { ComposableStandardSchema, InferComposableStandardSchema, InferStandardSchema } from "@geekmidas/schema";
8
+ import { AuditStorage, AuditableAction } from "@geekmidas/audit";
9
+ //#region src/functions/BaseFunctionBuilder.d.ts
10
+ declare abstract class BaseFunctionBuilder<TInput extends ComposableStandardSchema, OutSchema extends StandardSchemaV1 | undefined = undefined, TServices extends Service[] = [], TLogger extends Logger = Logger, TAuditStorage extends AuditStorage | undefined = undefined, TAuditStorageServiceName extends string = string, TDatabase = undefined, TDatabaseServiceName extends string = string> {
11
+ type: ConstructType;
12
+ protected inputSchema?: TInput;
13
+ protected outputSchema?: OutSchema;
14
+ protected _timeout?: number;
15
+ _services: TServices;
16
+ /**
17
+ * The construct ids `.dependsOn()` was given.
18
+ *
19
+ * Beside the services rather than instead of them: a handler *runs* with
20
+ * clients and the manifest *records* which constructs it reaches, and
21
+ * dissolving one into the other is what lost the edges. Shared by every
22
+ * builder because every one of them can depend on something.
23
+ */
24
+ _constructs: string[];
25
+ _logger: TLogger;
26
+ /**
27
+ * The deploy unit everything built from this builder belongs to.
28
+ *
29
+ * Seeded by the factory a `Worker` or `RestApi` hands out, so a cron knows
30
+ * which process runs it without a directory having to imply it.
31
+ */
32
+ _owner?: string;
33
+ /**
34
+ * Where a cron built from this factory keeps its schedule.
35
+ *
36
+ * Set by the worker that handed the factory out, the same way the logger
37
+ * and the owner are — so a cron file names a schedule and nothing else.
38
+ * Only a server target reads it; on AWS the schedule is an EventBridge rule.
39
+ */
40
+ _scheduleStore?: unknown;
41
+ /** What the built construct publishes, each event bound to its topic. */
42
+ _events: TopicEvent[];
43
+ protected _auditorStorage?: Service<TAuditStorageServiceName, TAuditStorage>;
44
+ protected _databaseService?: Service<TDatabaseServiceName, TDatabase>;
45
+ /** The edge `.database()` added, so the next one can replace it. */
46
+ protected _databaseEdge?: string;
47
+ static isStandardSchemaV1(s: unknown): s is StandardSchemaV1;
48
+ static parseComposableStandardSchema<T extends ComposableStandardSchema | undefined>(data: unknown, schema: T): Promise<InferComposableStandardSchema<T>>;
49
+ constructor(type?: ConstructType);
50
+ abstract services<T extends Service[]>(services: T): any;
51
+ abstract logger<T extends Logger>(logger: T): any;
52
+ timeout(timeout: number): this;
53
+ abstract output<T extends StandardSchemaV1>(schema: T): any;
54
+ abstract input<T extends ComposableStandardSchema>(schema: T): any;
55
+ /**
56
+ * A clone that publishes `event` to `topic` once the handler succeeds, and
57
+ * has the topic as a dependency the way `.dependsOn([topic])` would: in
58
+ * `services`, and an edge in the manifest. Each builder types it as its own
59
+ * `event()`, since only it knows how its services widen.
60
+ */
61
+ protected withEvent(topic: Topic<any, any>, event: EventFor<Topic<any, any>, any>): this;
62
+ auditor<T extends AuditStorage, TName extends string>(storage: Service<TName, T>): BaseFunctionBuilder<TInput, OutSchema, TServices, TLogger, T, TName, TDatabase, TDatabaseServiceName>;
63
+ /**
64
+ * Set the database service for this function.
65
+ * The database will be available in the handler context as `db`.
66
+ */
67
+ database<T, TName extends string>(source: Consumable<TName, T> | Service<TName, T>): BaseFunctionBuilder<TInput, OutSchema, TServices, TLogger, TAuditStorage, TAuditStorageServiceName, T, TName>;
68
+ }
69
+ //#endregion
70
+ //#region src/functions/FunctionBuilder.d.ts
71
+ declare class FunctionBuilder<TInput extends ComposableStandardSchema, OutSchema extends StandardSchemaV1 | undefined = undefined, TServices extends Service[] = [], TLogger extends Logger = Logger, TAuditStorage extends AuditStorage | undefined = undefined, TAuditStorageServiceName extends string = string, TDatabase = undefined, TDatabaseServiceName extends string = string, TAuditAction extends AuditableAction<string, unknown> = AuditableAction<string, unknown>> extends BaseFunctionBuilder<TInput, OutSchema, TServices, TLogger, TAuditStorage, TAuditStorageServiceName, TDatabase, TDatabaseServiceName> {
72
+ type: ConstructType;
73
+ protected _memorySize?: number;
74
+ constructor(type?: ConstructType);
75
+ timeout(timeout: number): this;
76
+ memorySize(memorySize: number): this;
77
+ output<T extends StandardSchemaV1>(schema: T): FunctionBuilder<TInput, T, TServices, TLogger, TAuditStorage, TAuditStorageServiceName, TDatabase, TDatabaseServiceName, TAuditAction>;
78
+ input<T extends ComposableStandardSchema>(schema: T): FunctionBuilder<T, OutSchema, TServices, TLogger, TAuditStorage, TAuditStorageServiceName, TDatabase, TDatabaseServiceName, TAuditAction>;
79
+ /**
80
+ * Depend on constructs — a database, a bucket, a mail sender, a queue, a
81
+ * topic.
82
+ *
83
+ * It records the edge and dissolves each construct's client into the
84
+ * handler's service record under the construct's own id, so
85
+ * `.dependsOn([uploads])` is what makes `services.uploads` exist and type.
86
+ *
87
+ * Constructs only. A `Service` does not match the shape, which is what keeps
88
+ * env sniffing confined to `.services()` and the explicit lift.
89
+ */
90
+ dependsOn<const T extends readonly Consumable[]>(constructs: T): FunctionBuilder<TInput, OutSchema, [...TServices, ...ServicesOf<T>], TLogger, TAuditStorage, TAuditStorageServiceName, TDatabase, TDatabaseServiceName, TAuditAction>;
91
+ services<T extends Service[]>(services: T): FunctionBuilder<TInput, OutSchema, [...TServices, ...T], TLogger, TAuditStorage, TAuditStorageServiceName, TDatabase, TDatabaseServiceName, TAuditAction>;
92
+ logger<T extends Logger>(logger: T): FunctionBuilder<TInput, OutSchema, TServices, T, TAuditStorage, TAuditStorageServiceName, TDatabase, TDatabaseServiceName, TAuditAction>;
93
+ /**
94
+ * Publish `event` to `topic` once the function has succeeded — repeatable,
95
+ * one call per event, to as many topics as it names. The topic becomes a
96
+ * dependency as with `.dependsOn([topic])`, so `services.<topic>` is there
97
+ * for events the handler decides on itself.
98
+ */
99
+ event<TTopic extends Topic<any, any>>(topic: TTopic, event: EventFor<TTopic, InferStandardSchema<OutSchema>>): FunctionBuilder<TInput, OutSchema, [...TServices, TTopic['service']], TLogger, TAuditStorage, TAuditStorageServiceName, TDatabase, TDatabaseServiceName, TAuditAction>;
100
+ auditor<T extends AuditStorage, TName extends string>(storage: Service<TName, T>): FunctionBuilder<TInput, OutSchema, TServices, TLogger, T, TName, TDatabase, TDatabaseServiceName, TAuditAction>;
101
+ /**
102
+ * Set the audit action types for this function.
103
+ * This provides type-safety for the auditor in the handler context.
104
+ */
105
+ actions<T extends AuditableAction<string, unknown>>(): FunctionBuilder<TInput, OutSchema, TServices, TLogger, TAuditStorage, TAuditStorageServiceName, TDatabase, TDatabaseServiceName, T>;
106
+ /**
107
+ * Set the database service for this function.
108
+ * The database will be available in the handler context as `db`.
109
+ */
110
+ database<T, TName extends string>(source: Consumable<TName, T> | Service<TName, T>): FunctionBuilder<TInput, OutSchema, TServices, TLogger, TAuditStorage, TAuditStorageServiceName, T, TName, TAuditAction>;
111
+ handle(fn: FunctionHandler<TInput, TServices, TLogger, OutSchema, TDatabase, TAuditStorage, TAuditAction>): Function<TInput, TServices, TLogger, OutSchema, TAuditStorage, TAuditStorageServiceName, TDatabase, TDatabaseServiceName, TAuditAction, FunctionHandler<TInput, TServices, TLogger, OutSchema, TDatabase, TAuditStorage, TAuditAction>>;
112
+ }
113
+ //#endregion
114
+ export { BaseFunctionBuilder as n, FunctionBuilder as t };
115
+ //# sourceMappingURL=index-BoQ3-M-K.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-BoQ3-M-K.d.mts","names":[],"sources":["../src/functions/BaseFunctionBuilder.ts","../src/functions/FunctionBuilder.ts"],"mappings":";;;;;;;;;uBAsBsB,oBACrB,eAAe,0BACf,kBAAkB,0CAClB,kBAAkB,gBAClB,gBAAgB,SAAS,QACzB,sBAAsB,sCACtB,kDACA,uBACA;EAoFmB,MAAI;YAlFb,cAAc;YACd,eAAe;YACf;EAEH,WAAW;;;;;;;;;EASX;EACA,SAAS;;;;;;;EAQT;;;;;;;;EASA;;EAGA,SAAS;YACN,kBAAkB,QAAQ,0BAA0B;YACpD,mBAAmB,QAAQ,sBAAsB;;YAEjD;SAEH,mBAAmB,aAAa,KAAK;SAM/B,8BACZ,UAAU,sCACT,eAAe,QAAQ,IAAI,QAAQ,8BAA8B;EAkCnE,YAAmB,OAAI;WAEd,SAAS,UAAU,WAAW,UAAU;WAExC,OAAO,UAAU,QAAQ,QAAQ;EAE1C,QAAQ;WAIC,OAAO,UAAU,kBAAkB,QAAQ;WAE3C,MAAM,UAAU,0BAA0B,QAAQ;;;;;;;YAQjD,UACT,OAAO,iBACP,OAAO,SAAS;EAcjB,QAAQ,UAAU,cAAc,sBAC/B,SAAS,QAAQ,OAAO,KACtB,oBACF,QACA,WACA,WACA,SACA,G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5C,gBACF,QACA,WACA,WACA,SACA,eACA,0BACA,GACA,OACA;EAkCD,OACC,IAAI,gBACH,QACA,WACA,SACA,WACA,WACA,eACA,gBAEC,SACF,QACA,WACA,SACA,WACA,eACA,0BACA,WACA,sBACA,cACA,gBACC,QACA,WACA,SACA,WACA,WACA,eACA"}
@@ -0,0 +1,115 @@
1
+ import { n as StandardSchemaV1 } from "./index-DdRjYhiJ.cjs";
2
+ import { a as EventFor, c as Topic, n as ConstructType, o as TopicEvent } from "./Construct-127M7yrl.cjs";
3
+ import { i as FunctionHandler, n as Function } from "./Function-BIEsY0Hm.cjs";
4
+ import { c as ServicesOf, r as Consumable } from "./construct-interface-DugP0E5q.cjs";
5
+ import { Logger } from "@geekmidas/logger";
6
+ import { ComposableStandardSchema, InferComposableStandardSchema, InferStandardSchema } from "@geekmidas/schema";
7
+ import { Service } from "@geekmidas/services";
8
+ import { AuditStorage, AuditableAction } from "@geekmidas/audit";
9
+ //#region src/functions/BaseFunctionBuilder.d.ts
10
+ declare abstract class BaseFunctionBuilder<TInput extends ComposableStandardSchema, OutSchema extends StandardSchemaV1 | undefined = undefined, TServices extends Service[] = [], TLogger extends Logger = Logger, TAuditStorage extends AuditStorage | undefined = undefined, TAuditStorageServiceName extends string = string, TDatabase = undefined, TDatabaseServiceName extends string = string> {
11
+ type: ConstructType;
12
+ protected inputSchema?: TInput;
13
+ protected outputSchema?: OutSchema;
14
+ protected _timeout?: number;
15
+ _services: TServices;
16
+ /**
17
+ * The construct ids `.dependsOn()` was given.
18
+ *
19
+ * Beside the services rather than instead of them: a handler *runs* with
20
+ * clients and the manifest *records* which constructs it reaches, and
21
+ * dissolving one into the other is what lost the edges. Shared by every
22
+ * builder because every one of them can depend on something.
23
+ */
24
+ _constructs: string[];
25
+ _logger: TLogger;
26
+ /**
27
+ * The deploy unit everything built from this builder belongs to.
28
+ *
29
+ * Seeded by the factory a `Worker` or `RestApi` hands out, so a cron knows
30
+ * which process runs it without a directory having to imply it.
31
+ */
32
+ _owner?: string;
33
+ /**
34
+ * Where a cron built from this factory keeps its schedule.
35
+ *
36
+ * Set by the worker that handed the factory out, the same way the logger
37
+ * and the owner are — so a cron file names a schedule and nothing else.
38
+ * Only a server target reads it; on AWS the schedule is an EventBridge rule.
39
+ */
40
+ _scheduleStore?: unknown;
41
+ /** What the built construct publishes, each event bound to its topic. */
42
+ _events: TopicEvent[];
43
+ protected _auditorStorage?: Service<TAuditStorageServiceName, TAuditStorage>;
44
+ protected _databaseService?: Service<TDatabaseServiceName, TDatabase>;
45
+ /** The edge `.database()` added, so the next one can replace it. */
46
+ protected _databaseEdge?: string;
47
+ static isStandardSchemaV1(s: unknown): s is StandardSchemaV1;
48
+ static parseComposableStandardSchema<T extends ComposableStandardSchema | undefined>(data: unknown, schema: T): Promise<InferComposableStandardSchema<T>>;
49
+ constructor(type?: ConstructType);
50
+ abstract services<T extends Service[]>(services: T): any;
51
+ abstract logger<T extends Logger>(logger: T): any;
52
+ timeout(timeout: number): this;
53
+ abstract output<T extends StandardSchemaV1>(schema: T): any;
54
+ abstract input<T extends ComposableStandardSchema>(schema: T): any;
55
+ /**
56
+ * A clone that publishes `event` to `topic` once the handler succeeds, and
57
+ * has the topic as a dependency the way `.dependsOn([topic])` would: in
58
+ * `services`, and an edge in the manifest. Each builder types it as its own
59
+ * `event()`, since only it knows how its services widen.
60
+ */
61
+ protected withEvent(topic: Topic<any, any>, event: EventFor<Topic<any, any>, any>): this;
62
+ auditor<T extends AuditStorage, TName extends string>(storage: Service<TName, T>): BaseFunctionBuilder<TInput, OutSchema, TServices, TLogger, T, TName, TDatabase, TDatabaseServiceName>;
63
+ /**
64
+ * Set the database service for this function.
65
+ * The database will be available in the handler context as `db`.
66
+ */
67
+ database<T, TName extends string>(source: Consumable<TName, T> | Service<TName, T>): BaseFunctionBuilder<TInput, OutSchema, TServices, TLogger, TAuditStorage, TAuditStorageServiceName, T, TName>;
68
+ }
69
+ //#endregion
70
+ //#region src/functions/FunctionBuilder.d.ts
71
+ declare class FunctionBuilder<TInput extends ComposableStandardSchema, OutSchema extends StandardSchemaV1 | undefined = undefined, TServices extends Service[] = [], TLogger extends Logger = Logger, TAuditStorage extends AuditStorage | undefined = undefined, TAuditStorageServiceName extends string = string, TDatabase = undefined, TDatabaseServiceName extends string = string, TAuditAction extends AuditableAction<string, unknown> = AuditableAction<string, unknown>> extends BaseFunctionBuilder<TInput, OutSchema, TServices, TLogger, TAuditStorage, TAuditStorageServiceName, TDatabase, TDatabaseServiceName> {
72
+ type: ConstructType;
73
+ protected _memorySize?: number;
74
+ constructor(type?: ConstructType);
75
+ timeout(timeout: number): this;
76
+ memorySize(memorySize: number): this;
77
+ output<T extends StandardSchemaV1>(schema: T): FunctionBuilder<TInput, T, TServices, TLogger, TAuditStorage, TAuditStorageServiceName, TDatabase, TDatabaseServiceName, TAuditAction>;
78
+ input<T extends ComposableStandardSchema>(schema: T): FunctionBuilder<T, OutSchema, TServices, TLogger, TAuditStorage, TAuditStorageServiceName, TDatabase, TDatabaseServiceName, TAuditAction>;
79
+ /**
80
+ * Depend on constructs — a database, a bucket, a mail sender, a queue, a
81
+ * topic.
82
+ *
83
+ * It records the edge and dissolves each construct's client into the
84
+ * handler's service record under the construct's own id, so
85
+ * `.dependsOn([uploads])` is what makes `services.uploads` exist and type.
86
+ *
87
+ * Constructs only. A `Service` does not match the shape, which is what keeps
88
+ * env sniffing confined to `.services()` and the explicit lift.
89
+ */
90
+ dependsOn<const T extends readonly Consumable[]>(constructs: T): FunctionBuilder<TInput, OutSchema, [...TServices, ...ServicesOf<T>], TLogger, TAuditStorage, TAuditStorageServiceName, TDatabase, TDatabaseServiceName, TAuditAction>;
91
+ services<T extends Service[]>(services: T): FunctionBuilder<TInput, OutSchema, [...TServices, ...T], TLogger, TAuditStorage, TAuditStorageServiceName, TDatabase, TDatabaseServiceName, TAuditAction>;
92
+ logger<T extends Logger>(logger: T): FunctionBuilder<TInput, OutSchema, TServices, T, TAuditStorage, TAuditStorageServiceName, TDatabase, TDatabaseServiceName, TAuditAction>;
93
+ /**
94
+ * Publish `event` to `topic` once the function has succeeded — repeatable,
95
+ * one call per event, to as many topics as it names. The topic becomes a
96
+ * dependency as with `.dependsOn([topic])`, so `services.<topic>` is there
97
+ * for events the handler decides on itself.
98
+ */
99
+ event<TTopic extends Topic<any, any>>(topic: TTopic, event: EventFor<TTopic, InferStandardSchema<OutSchema>>): FunctionBuilder<TInput, OutSchema, [...TServices, TTopic['service']], TLogger, TAuditStorage, TAuditStorageServiceName, TDatabase, TDatabaseServiceName, TAuditAction>;
100
+ auditor<T extends AuditStorage, TName extends string>(storage: Service<TName, T>): FunctionBuilder<TInput, OutSchema, TServices, TLogger, T, TName, TDatabase, TDatabaseServiceName, TAuditAction>;
101
+ /**
102
+ * Set the audit action types for this function.
103
+ * This provides type-safety for the auditor in the handler context.
104
+ */
105
+ actions<T extends AuditableAction<string, unknown>>(): FunctionBuilder<TInput, OutSchema, TServices, TLogger, TAuditStorage, TAuditStorageServiceName, TDatabase, TDatabaseServiceName, T>;
106
+ /**
107
+ * Set the database service for this function.
108
+ * The database will be available in the handler context as `db`.
109
+ */
110
+ database<T, TName extends string>(source: Consumable<TName, T> | Service<TName, T>): FunctionBuilder<TInput, OutSchema, TServices, TLogger, TAuditStorage, TAuditStorageServiceName, T, TName, TAuditAction>;
111
+ handle(fn: FunctionHandler<TInput, TServices, TLogger, OutSchema, TDatabase, TAuditStorage, TAuditAction>): Function<TInput, TServices, TLogger, OutSchema, TAuditStorage, TAuditStorageServiceName, TDatabase, TDatabaseServiceName, TAuditAction, FunctionHandler<TInput, TServices, TLogger, OutSchema, TDatabase, TAuditStorage, TAuditAction>>;
112
+ }
113
+ //#endregion
114
+ export { BaseFunctionBuilder as n, FunctionBuilder as t };
115
+ //# sourceMappingURL=index-DPTHa6Ud.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-DPTHa6Ud.d.cts","names":[],"sources":["../src/functions/BaseFunctionBuilder.ts","../src/functions/FunctionB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,eACA,0BACA,WACA,sBACA;;;;;;;;;;;;EA4BD,gBAAgB,mBAAmB,cAClC,YAAY,IACV,gBACF,QACA,eACI,cAAc,WAAW,KAC7B,SACA,eACA,0BACA,WACA,sBACA;EA8BD,SAAS,UAAU,WAClB,UAAU,IACR,gBACF,QACA,eACI,cAAc,IAClB,SACA,eACA,0BACA,WACA,sBACA;EAoBD,OAAO,UAAU,QAChB,QAAQ,IACN,gBACF,QACA,WACA,WACA,GACA,eACA,0BACA,WACA,sBACA;;;;;;;EAuBD,MAAM,eAAe,iBACpB,OAAO,QACP,OAAO,SAAS,QAAQ,oBAAoB,cAC1C,gBACF,QACA,eACI,WAAW,oBACf,SACA,eACA,0BACA,WACA,sBACA;EAeQ,QAAQ,UAAU,cAAc,sBACxC,SAAS,QAAQ,OAAO,KACtB,gBACF,QACA,WACA,WACA,SACA,GACA,OACA,WACA,sBACA;;;;;EAwBD,QAAQ,UAAU,qCAAqC,gBACtD,QACA,WACA,WACA,SACA,eACA,0BACA,WACA,sBACA;;;;;EAmBQ,SAAS,GAAG,sBACpB,QAAQ,WAAW,OAAO,KAAK,QAAQ,OAAO,KAC5C,gBACF,QACA,WACA,WACA,SACA,eACA,0BACA,GACA,OACA;EAkCD,OACC,IAAI,gBACH,QACA,WACA,SACA,WACA,WACA,eACA,gBAEC,SACF,QACA,WACA,SACA,WACA,eACA,0BACA,WACA,sBACA,cACA,gBACC,QACA,WACA,SACA,WACA,WACA,eACA"}
@@ -74,6 +74,46 @@ declare namespace StandardSchemaV1 {
74
74
  /** Infers the output type of a Standard. */
75
75
  type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
76
76
  }
77
+ /** The Standard JSON Schema interface. */
78
+ interface StandardJSONSchemaV1<Input = unknown, Output = Input> {
79
+ /** The Standard JSON Schema properties. */
80
+ readonly "~standard": StandardJSONSchemaV1.Props<Input, Output>;
81
+ }
82
+ declare namespace StandardJSONSchemaV1 {
83
+ /** The Standard JSON Schema properties interface. */
84
+ interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
85
+ /** Methods for generating the input/output JSON Schema. */
86
+ readonly jsonSchema: StandardJSONSchemaV1.Converter;
87
+ }
88
+ /** The Standard JSON Schema converter interface. */
89
+ interface Converter {
90
+ /** Converts the input type to JSON Schema. May throw if conversion is not supported. */
91
+ readonly input: (options: StandardJSONSchemaV1.Options) => Record<string, unknown>;
92
+ /** Converts the output type to JSON Schema. May throw if conversion is not supported. */
93
+ readonly output: (options: StandardJSONSchemaV1.Options) => Record<string, unknown>;
94
+ }
95
+ /**
96
+ * The target version of the generated JSON Schema.
97
+ *
98
+ * It is *strongly recommended* that implementers support `"draft-2020-12"` and `"draft-07"`, as they are both in wide use. All other targets can be implemented on a best-effort basis. Libraries should throw if they don't support a specified target.
99
+ *
100
+ * The `"openapi-3.0"` target is intended as a standardized specifier for OpenAPI 3.0 which is a superset of JSON Schema `"draft-04"`.
101
+ */
102
+ type Target = "draft-2020-12" | "draft-07" | "openapi-3.0" | ({} & string);
103
+ /** The options for the input/output methods. */
104
+ interface Options {
105
+ /** Specifies the target version of the generated JSON Schema. Support for all versions is on a best-effort basis. If a given version is not supported, the library should throw. */
106
+ readonly target: Target;
107
+ /** Explicit support for additional vendor-specific parameters, if needed. */
108
+ readonly libraryOptions?: Record<string, unknown> | undefined;
109
+ }
110
+ /** The Standard types interface. */
111
+ interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {}
112
+ /** Infers the input type of a Standard. */
113
+ type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
114
+ /** Infers the output type of a Standard. */
115
+ type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
116
+ }
77
117
  //#endregion
78
- export { StandardSchemaV1 as t };
79
- //# sourceMappingURL=index-CeEtxDmK.d.cts.map
118
+ export { StandardSchemaV1 as n, StandardJSONSchemaV1 as t };
119
+ //# sourceMappingURL=index-DdRjYhiJ.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-CeEtxDmK.d.cts","names":[],"sources":["../../../node_modules/.pnpm/@standard-schema+spec@1.1.0/node_modules/@standard-schema/spec/dist/index.d.ts"],"x_google_ignoreList":[0],"mappings":";;UACU,gBAAgB,iBAAiB,SAAS;;WAEvC,aAAa,gBAAgB,MAAM,OAAO;;kBAErC;;YAEJ,MAAM,iBAAiB,SAAS;;aAE7B;;aAEA;;aAEA,QAAQ,MAAM,OAAO;;;YAGxB,MAAM,iBAAiB,SAAS;;aAE7B,OAAO;;aAEP,QAAQ;;;OAGhB,WAAW,eAAe,mBAAmB,YAAY;;OAEzD,YAAY,eAAe,mBAAmB,YAAY;;;UAGzD,iBAAiB,iBAAiB,SAAS;;WAExC,aAAa,iBAAiB,MAAM,OAAO;;kBAEtC;;YAEJ,MAAM,iBAAiB,SAAS,eAAe,gBAAgB,MAAM,OAAO;;aAEzE,WAAW,gBAAgB,UAAU,iBAAiB,wBAAwB,OAAO,UAAU,QAAQ,OAAO;;;OAGtH,OAAO,UAAU,cAAc,UAAU;;YAEpC,cAAc;;aAEX,OAAO;;aAEP;;YAEH;;aAEG,iBAAiB;;;YAGpB;;aAEG,QAAQ,cAAc;;;YAGzB;;aAEG;;aAEA,OAAO,cAAc,cAAc;;;YAGtC;;aAEG,KAAK;;;YAGR,MAAM,iBAAiB,SAAS,eAAe,gBAAgB,MAAM,OAAO;;OAGjF,WAAW,eAAe,mBAAmB,gBAAgB,WAAW;;OAExE,YAAY,eAAe,mBAAmB,gBAAgB,YAAY"}
1
+ {"version":3,"file":"index-DdRjYhiJ.d.cts","names":[],"sources":["../../../node_modules/.pnpm/@standard-schema+spec@1.1.0/node_modules/@standard-schema/spec/dist/index.d.ts"],"x_google_ignoreList":[0],"mappings":";;UACU,gBAAgB,iBAAiB,SAAS;;WAEvC,aAAa,gBAAgB,MAAM,OAAO;;kBAErC;;YAEJ,MAAM,iBAAiB,SAAS;;aAE7B;;aAEA;;aAEA,QAAQ,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