@geekmidas/constructs 10.0.0-alpha.17 → 10.0.0-alpha.170

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-Ca_qHQu2.d.cts} +16 -9
  11. package/dist/Cron-Ca_qHQu2.d.cts.map +1 -0
  12. package/dist/{Cron-zsoSAwZo.d.cts → Cron-DPJiR7Lt.d.mts} +15 -8
  13. package/dist/Cron-DPJiR7Lt.d.mts.map +1 -0
  14. package/dist/CronBuilder-BC4za5Bx.d.mts +47 -0
  15. package/dist/CronBuilder-BC4za5Bx.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-C3RrAF1-.d.cts +47 -0
  21. package/dist/CronBuilder-C3RrAF1-.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-DBflWAe4.d.cts → Endpoint-BlIZLsBQ.d.cts} +101 -20
  25. package/dist/Endpoint-BlIZLsBQ.d.cts.map +1 -0
  26. package/dist/{Endpoint-oS-Fe3d_.d.mts → Endpoint-DC7mreOr.d.mts} +104 -23
  27. package/dist/Endpoint-DC7mreOr.d.mts.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-Cc4kKPag.d.mts → EndpointFactory-DCmnCmkX.d.mts} +189 -106
  35. package/dist/EndpointFactory-DCmnCmkX.d.mts.map +1 -0
  36. package/dist/{index-C1ZwNOOk.d.cts → EndpointFactory-cVTb8kCc.d.cts} +187 -104
  37. package/dist/EndpointFactory-cVTb8kCc.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-AwGKoUKy.d.mts +129 -0
  47. package/dist/ObjectSubscriberBuilder-AwGKoUKy.d.mts.map +1 -0
  48. package/dist/ObjectSubscriberBuilder-CB6imsX4.d.cts +129 -0
  49. package/dist/ObjectSubscriberBuilder-CB6imsX4.d.cts.map +1 -0
  50. package/dist/ProcessorBuilder-CeEZ2vCx.d.cts +216 -0
  51. package/dist/ProcessorBuilder-CeEZ2vCx.d.cts.map +1 -0
  52. package/dist/ProcessorBuilder-CwIlm75W.d.mts +216 -0
  53. package/dist/ProcessorBuilder-CwIlm75W.d.mts.map +1 -0
  54. package/dist/Queue-9Hh20ZCk.mjs +104 -0
  55. package/dist/Queue-9Hh20ZCk.mjs.map +1 -0
  56. package/dist/{Queue-D9X6OoON.d.mts → Queue-B8HGg439.d.mts} +42 -41
  57. package/dist/Queue-B8HGg439.d.mts.map +1 -0
  58. package/dist/{Queue-DYPB2KWL.d.cts → Queue-C4rijiM7.d.cts} +43 -42
  59. package/dist/Queue-C4rijiM7.d.cts.map +1 -0
  60. package/dist/Queue-W1wueijP.cjs +109 -0
  61. package/dist/Queue-W1wueijP.cjs.map +1 -0
  62. package/dist/QueueBuilder-BDcv9B71.cjs +135 -0
  63. package/dist/QueueBuilder-BDcv9B71.cjs.map +1 -0
  64. package/dist/QueueBuilder-CUERv8jt.d.mts +75 -0
  65. package/dist/QueueBuilder-CUERv8jt.d.mts.map +1 -0
  66. package/dist/QueueBuilder-CmB1vOgn.d.cts +75 -0
  67. package/dist/QueueBuilder-CmB1vOgn.d.cts.map +1 -0
  68. package/dist/QueueBuilder-CrZL8HHs.mjs +118 -0
  69. package/dist/QueueBuilder-CrZL8HHs.mjs.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-BGoOeCT6.mjs +99 -0
  79. package/dist/Topic-BGoOeCT6.mjs.map +1 -0
  80. package/dist/Topic-DLCZBNwK.cjs +104 -0
  81. package/dist/Topic-DLCZBNwK.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-1yI2wR-4.d.cts +274 -0
  113. package/dist/auth-1yI2wR-4.d.cts.map +1 -0
  114. package/dist/auth-D4NMXgLt.d.mts +274 -0
  115. package/dist/auth-D4NMXgLt.d.mts.map +1 -0
  116. package/dist/auth.cjs +311 -26
  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 +307 -28
  121. package/dist/auth.mjs.map +1 -1
  122. package/dist/cache-0VoeOTF9.d.mts +44 -0
  123. package/dist/cache-0VoeOTF9.d.mts.map +1 -0
  124. package/dist/cache-CW-sArzS.d.cts +44 -0
  125. package/dist/cache-CW-sArzS.d.cts.map +1 -0
  126. package/dist/cache.cjs +4 -20
  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 +4 -20
  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-DhbaONW2.d.cts} +63 -8
  141. package/dist/construct-interface-DhbaONW2.d.cts.map +1 -0
  142. package/dist/{construct-interface-DgXTJcOD.d.cts → construct-interface-DxfkFxkl.d.mts} +63 -8
  143. package/dist/construct-interface-DxfkFxkl.d.mts.map +1 -0
  144. package/dist/construct-interface.cjs +47 -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 +45 -5
  149. package/dist/construct-interface.mjs.map +1 -1
  150. package/dist/credential-B80mOxwT.mjs +222 -0
  151. package/dist/credential-B80mOxwT.mjs.map +1 -0
  152. package/dist/credential-RlgbzZAc.cjs +257 -0
  153. package/dist/credential-RlgbzZAc.cjs.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 +24 -17
  171. package/dist/email.cjs.map +1 -1
  172. package/dist/email.d.cts +15 -5
  173. package/dist/email.d.cts.map +1 -1
  174. package/dist/email.d.mts +16 -6
  175. package/dist/email.d.mts.map +1 -1
  176. package/dist/email.mjs +23 -17
  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-BvOXkZmj.d.mts +201 -0
  215. package/dist/fake-BvOXkZmj.d.mts.map +1 -0
  216. package/dist/fake-Djx8E0o1.d.cts +201 -0
  217. package/dist/fake-Djx8E0o1.d.cts.map +1 -0
  218. package/dist/file-server.cjs +200 -48
  219. package/dist/file-server.cjs.map +1 -1
  220. package/dist/file-server.d.cts +147 -15
  221. package/dist/file-server.d.cts.map +1 -1
  222. package/dist/file-server.d.mts +147 -15
  223. package/dist/file-server.d.mts.map +1 -1
  224. package/dist/file-server.mjs +198 -50
  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-BjvMs7EJ.d.cts +195 -0
  235. package/dist/inbox-BjvMs7EJ.d.cts.map +1 -0
  236. package/dist/inbox-C8bOR9UL.d.mts +195 -0
  237. package/dist/inbox-C8bOR9UL.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-DaK-C7N3.d.cts +115 -0
  245. package/dist/index-DaK-C7N3.d.cts.map +1 -0
  246. package/dist/{index-CeEtxDmK.d.cts → index-DdRjYhiJ.d.cts} +42 -2
  247. package/dist/{index-CeEtxDmK.d.cts.map → index-DdRjYhiJ.d.cts.map} +1 -1
  248. package/dist/{index-CeEtxDmK.d.mts → index-DdRjYhiJ.d.mts} +42 -2
  249. package/dist/{index-CeEtxDmK.d.mts.map → index-DdRjYhiJ.d.mts.map} +1 -1
  250. package/dist/index-vCS4HBEG.d.mts +115 -0
  251. package/dist/index-vCS4HBEG.d.mts.map +1 -0
  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-2HqIQ2fC.d.cts +216 -0
  259. package/dist/kysely-2HqIQ2fC.d.cts.map +1 -0
  260. package/dist/kysely-BGvpd_ZH.d.mts +216 -0
  261. package/dist/kysely-BGvpd_ZH.d.mts.map +1 -0
  262. package/dist/kysely-Bc9xzaik.mjs +371 -0
  263. package/dist/kysely-Bc9xzaik.mjs.map +1 -0
  264. package/dist/kysely-D7f6J2lh.cjs +384 -0
  265. package/dist/kysely-D7f6J2lh.cjs.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 +78 -0
  271. package/dist/mobile-app.cjs.map +1 -0
  272. package/dist/mobile-app.d.cts +77 -0
  273. package/dist/mobile-app.d.cts.map +1 -0
  274. package/dist/mobile-app.d.mts +77 -0
  275. package/dist/mobile-app.d.mts.map +1 -0
  276. package/dist/mobile-app.mjs +77 -0
  277. package/dist/mobile-app.mjs.map +1 -0
  278. package/dist/object-storage.cjs +14 -7
  279. package/dist/object-storage.cjs.map +1 -1
  280. package/dist/object-storage.d.cts +12 -3
  281. package/dist/object-storage.d.cts.map +1 -1
  282. package/dist/object-storage.d.mts +12 -3
  283. package/dist/object-storage.d.mts.map +1 -1
  284. package/dist/object-storage.mjs +14 -9
  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 +100 -73
  331. package/dist/rest-api.cjs.map +1 -1
  332. package/dist/rest-api.d.cts +83 -59
  333. package/dist/rest-api.d.cts.map +1 -1
  334. package/dist/rest-api.d.mts +83 -59
  335. package/dist/rest-api.d.mts.map +1 -1
  336. package/dist/rest-api.mjs +97 -76
  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 +137 -10
  347. package/dist/site.cjs.map +1 -1
  348. package/dist/site.d.cts +153 -3
  349. package/dist/site.d.cts.map +1 -1
  350. package/dist/site.d.mts +153 -3
  351. package/dist/site.d.mts.map +1 -1
  352. package/dist/site.mjs +117 -13
  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-BirKau0X.d.mts +40 -0
  367. package/dist/telemetry-BirKau0X.d.mts.map +1 -0
  368. package/dist/telemetry-DjJgtQ_N.d.cts +40 -0
  369. package/dist/telemetry-DjJgtQ_N.d.cts.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-C6LGg9-D.mjs +1716 -0
  385. package/dist/websocket-api-C6LGg9-D.mjs.map +1 -0
  386. package/dist/websocket-api-CD-E5Ogr.d.cts +1207 -0
  387. package/dist/websocket-api-CD-E5Ogr.d.cts.map +1 -0
  388. package/dist/websocket-api-CoKPJJRl.cjs +1895 -0
  389. package/dist/websocket-api-CoKPJJRl.cjs.map +1 -0
  390. package/dist/websocket-api-pJJfeTcm.d.mts +1207 -0
  391. package/dist/websocket-api-pJJfeTcm.d.mts.map +1 -0
  392. package/dist/websocket-api.cjs +42 -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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["DERIVED_PREFIX","fillPattern","matchPattern","runWithRequestContext","defaultEnvParser","ServiceDiscovery","defaultEnvParser"],"sources":["../../src/processors/runProcessor.ts","../../src/processors/AWSLambdaProcessor.ts"],"sourcesContent":["import type { EnvironmentParser } from '@geekmidas/envkit';\nimport type { Logger } from '@geekmidas/logger';\nimport { runWithRequestContext, ServiceDiscovery } from '@geekmidas/services';\nimport type { StorageClient } from '@geekmidas/storage';\nimport { defaultEnvParser } from '../endpoints/surfaceEnv';\nimport {\n\tDERIVED_PREFIX,\n\ttype Processor,\n\ttype ProcessorCache,\n\ttype SourceObject,\n} from './Processor';\nimport { fillPattern, matchPattern } from './pattern';\n\n/** What a processor answers, for whichever server or function carries it. */\nexport interface ProcessorResponse {\n\tstatus: number;\n\theaders: Record<string, string>;\n\tbody?: Uint8Array | string;\n}\n\n/** The object a request addressed is not in the bucket. */\nexport class ProcessorSourceMissing extends Error {\n\tconstructor(readonly key: string) {\n\t\tsuper(`'${key}' is not in the bucket, so there is nothing to process.`);\n\t\tthis.name = 'ProcessorSourceMissing';\n\t}\n}\n\n/** What a refusal or a miss may be kept for: long enough to absorb a burst. */\nconst SHORT = 'public, max-age=60';\n\n/** The header a response carries, by how long it may be kept. */\nexport function cacheControl(cache: ProcessorCache | undefined): string {\n\tif (cache === 'immutable') return 'public, max-age=31536000, immutable';\n\tif (cache === 'none') return 'no-store';\n\treturn `public, max-age=${cache?.maxAge ?? 3600}`;\n}\n\n/** Where a processor keeps the derivative for one request. */\nexport function derivedKey(\n\tprocessor: Processor<string, any, any, any>,\n\tparams: Readonly<Record<string, string>>,\n\tkey: string,\n): string {\n\treturn `${DERIVED_PREFIX}${fillPattern(processor.parsed, params, key).slice(1)}`;\n}\n\nexport interface ProcessorRequestOptions {\n\tserviceDiscovery: ServiceDiscovery<any>;\n\t/** How the bucket is read through a presigned address. */\n\tfetch?: typeof fetch;\n}\n\n/**\n * Answer one request with the first processor whose pattern matches it, or\n * `undefined` when none does.\n *\n * In order: the parameters are parsed by the processor's schema (400 when it\n * refuses them); the key must be one of the file server's open paths (404\n * otherwise, as an unsigned read of it would be); a derivative already in the\n * bucket is answered without running anything; and only then is the handler\n * run, its `immutable` result written through for next time.\n */\nexport async function handleProcessorRequest(\n\tprocessors: readonly Processor<string, any, any, any>[],\n\trequest: { method: string; path: string },\n\toptions: ProcessorRequestOptions,\n): Promise<ProcessorResponse | undefined> {\n\tconst method = request.method.toUpperCase();\n\n\tfor (const processor of processors) {\n\t\tconst match = matchPattern(processor.parsed, request.path);\n\t\tif (!match) continue;\n\n\t\tif (method !== 'GET' && method !== 'HEAD') {\n\t\t\treturn text(405, 'Method Not Allowed', 'no-store', {\n\t\t\t\tallow: 'GET, HEAD',\n\t\t\t});\n\t\t}\n\n\t\treturn runWithRequestContext(\n\t\t\t{\n\t\t\t\tlogger: processor.logger,\n\t\t\t\trequestId: `processor-${Date.now()}`,\n\t\t\t\tstartTime: Date.now(),\n\t\t\t\toperation: `processor ${processor.pattern}`,\n\t\t\t},\n\t\t\t() => run(processor, match, options),\n\t\t);\n\t}\n\n\treturn undefined;\n}\n\n/**\n * A request handler for a set of processors — what a generated entry serves\n * — with its services discovered from the default environment parser: the\n * process's environment and the credentials `gkm` injected.\n */\nexport function processorServer(\n\tprocessors: readonly Processor<string, any, any, any>[],\n\tenvParser: EnvironmentParser<{}> = defaultEnvParser(),\n): (request: {\n\tmethod: string;\n\tpath: string;\n}) => Promise<ProcessorResponse | undefined> {\n\tconst serviceDiscovery = ServiceDiscovery.getInstance(envParser);\n\treturn (request) =>\n\t\thandleProcessorRequest(processors, request, { serviceDiscovery });\n}\n\nasync function run(\n\tprocessor: Processor<string, any, any, any>,\n\tmatch: { params: Record<string, string>; key: string },\n\toptions: ProcessorRequestOptions,\n): Promise<ProcessorResponse> {\n\tconst logger = processor.logger as Logger;\n\tconst fetcher = options.fetch ?? fetch;\n\tconst { key } = match;\n\n\tconst schema = processor.options.paramsSchema;\n\tlet params: unknown = match.params;\n\tif (schema) {\n\t\tconst parsed = await schema['~standard'].validate(match.params);\n\t\tif (parsed.issues) return text(400, 'Bad Request', SHORT);\n\t\tparams = parsed.value;\n\t}\n\n\t// A derivative is never itself a source, and a private object is never\n\t// processed: a processor serves exactly what an unsigned read would.\n\tif (key.startsWith(DERIVED_PREFIX) || !processor.options.serves(key)) {\n\t\treturn text(404, 'Not Found', SHORT);\n\t}\n\n\tconst services: Record<string, unknown> =\n\t\tawait options.serviceDiscovery.register(processor.services);\n\tconst storage = services[\n\t\tprocessor.options.origin.serviceName\n\t] as StorageClient;\n\n\tconst derived = derivedKey(processor, match.params, key);\n\tconst kept = await read(storage, derived, fetcher);\n\tif (kept) {\n\t\treturn {\n\t\t\tstatus: 200,\n\t\t\theaders: {\n\t\t\t\t'content-type': kept.contentType ?? 'application/octet-stream',\n\t\t\t\t'cache-control': cacheControl('immutable'),\n\t\t\t\t'x-gkm-processor': 'kept',\n\t\t\t},\n\t\t\tbody: new Uint8Array(await kept.response.arrayBuffer()),\n\t\t};\n\t}\n\n\tlet source: Response | undefined;\n\tconst load = async (): Promise<Response> => {\n\t\tif (source) return source;\n\t\tconst found = await read(storage, key, fetcher);\n\t\tif (!found) throw new ProcessorSourceMissing(key);\n\t\tsource = found.response;\n\t\treturn source;\n\t};\n\tconst object: SourceObject = {\n\t\tkey,\n\t\tbytes: async () => new Uint8Array(await (await load()).arrayBuffer()),\n\t\tstream: async () => {\n\t\t\tconst body = (await load()).body;\n\t\t\tif (!body) throw new ProcessorSourceMissing(key);\n\t\t\treturn body;\n\t\t},\n\t\tcontentType: async () =>\n\t\t\t(await load()).headers.get('content-type') ?? undefined,\n\t};\n\n\tlet result: Awaited<ReturnType<typeof processor.handler>>;\n\ttry {\n\t\tresult = await processor.handler({\n\t\t\tparams,\n\t\t\tkey,\n\t\t\tobject,\n\t\t\tlogger,\n\t\t\tservices,\n\t\t} as never);\n\t} catch (error) {\n\t\tif (error instanceof ProcessorSourceMissing) {\n\t\t\treturn text(404, 'Not Found', SHORT);\n\t\t}\n\t\tlogger.error({ err: error, key }, 'Processor failed');\n\t\treturn text(500, 'Internal Server Error', 'no-store');\n\t}\n\n\tconst body =\n\t\ttypeof result.body === 'string'\n\t\t\t? new TextEncoder().encode(result.body)\n\t\t\t: result.body;\n\n\t// Kept only when it can never change: anything else would be served from\n\t// the bucket long after its handler would have answered differently.\n\tif (result.cache === 'immutable') {\n\t\tawait storage\n\t\t\t.upload(derived, Buffer.from(body), result.contentType)\n\t\t\t.catch((error: unknown) =>\n\t\t\t\tlogger.warn({ err: error, key: derived }, 'Could not keep derivative'),\n\t\t\t);\n\t}\n\n\treturn {\n\t\tstatus: 200,\n\t\theaders: {\n\t\t\t'content-type': result.contentType,\n\t\t\t'cache-control': cacheControl(result.cache),\n\t\t\t'x-gkm-processor': 'made',\n\t\t},\n\t\tbody,\n\t};\n}\n\n/** An object through a presigned address, or nothing when it is not there. */\nasync function read(\n\tstorage: StorageClient,\n\tkey: string,\n\tfetcher: typeof fetch,\n): Promise<{ response: Response; contentType?: string } | undefined> {\n\tconst url = await storage.getDownloadURL({ path: key });\n\tconst response = await fetcher(url);\n\tif (!response.ok) {\n\t\tawait response.body?.cancel().catch(() => undefined);\n\t\treturn undefined;\n\t}\n\tconst contentType = response.headers.get('content-type') ?? undefined;\n\treturn { response, ...(contentType ? { contentType } : {}) };\n}\n\nfunction text(\n\tstatus: number,\n\tbody: string,\n\tcache: string,\n\textra: Record<string, string> = {},\n): ProcessorResponse {\n\treturn {\n\t\tstatus,\n\t\theaders: {\n\t\t\t'content-type': 'text/plain; charset=utf-8',\n\t\t\t'cache-control': cache,\n\t\t\t...extra,\n\t\t},\n\t\tbody,\n\t};\n}\n","import type { EnvironmentParser } from '@geekmidas/envkit';\nimport { defaultEnvParser } from '../endpoints/surfaceEnv';\nimport type { Processor } from './Processor';\nimport { processorServer } from './runProcessor';\n\n/** The parts of a Lambda function URL event a processor reads. */\nexport interface FunctionUrlEvent {\n\trawPath: string;\n\trequestContext: { http: { method: string } };\n}\n\n/** What a function URL answers with. */\nexport interface FunctionUrlResult {\n\tstatusCode: number;\n\theaders: Record<string, string>;\n\tbody: string;\n\tisBase64Encoded: boolean;\n}\n\n/**\n * A processor as a Lambda behind a function URL — the CDN's origin for its\n * pattern on AWS. The URL takes IAM auth and the CDN signs each request, so\n * the function cannot be called around the cache.\n */\nexport class AWSLambdaProcessor {\n\tprivate readonly serve: ReturnType<typeof processorServer>;\n\n\tconstructor(\n\t\tprocessor: Processor<string, any, any, any>,\n\t\tenvParser: EnvironmentParser<{}> = defaultEnvParser(),\n\t) {\n\t\tthis.serve = processorServer([processor], envParser);\n\t}\n\n\thandler = async (event: FunctionUrlEvent): Promise<FunctionUrlResult> => {\n\t\tconst response = await this.serve({\n\t\t\tmethod: event.requestContext.http.method,\n\t\t\tpath: event.rawPath,\n\t\t});\n\t\tif (!response) {\n\t\t\treturn {\n\t\t\t\tstatusCode: 404,\n\t\t\t\theaders: { 'cache-control': 'public, max-age=60' },\n\t\t\t\tbody: '',\n\t\t\t\tisBase64Encoded: false,\n\t\t\t};\n\t\t}\n\t\tconst body = response.body ?? '';\n\t\treturn {\n\t\t\tstatusCode: response.status,\n\t\t\theaders: response.headers,\n\t\t\tbody:\n\t\t\t\ttypeof body === 'string' ? body : Buffer.from(body).toString('base64'),\n\t\t\tisBase64Encoded: typeof body !== 'string',\n\t\t};\n\t};\n}\n"],"mappings":";;;;;;;AAqBA,IA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ACpD;CAEA,UAAU,OAAO,UAAwD;EACxE,MAAM,WAAW,MAAM,KAAK,MAAM;GACjC,QAAQ,MAAM,eAAe,KAAK;GAClC,MAAM,MAAM;EACb,CAAC;EACD,IAAI,CAAC,UACJ,OAAO;GACN,YAAY;GACZ,SAAS,EAAE,iBAAiB,qBAAqB;GACjD,MAAM;GACN,iBAAiB;EAClB;EAED,MAAM,OAAO,SAAS,QAAQ;EAC9B,OAAO;GACN,YAAY,SAAS;GACrB,SAAS,SAAS;GAClB,MACC,OAAO,SAAS,WAAW,OAAO,OAAO,KAAK,IAAI,CAAC,CAAC,SAAS,QAAQ;GACtE,iBAAiB,OAAO,SAAS;EAClC;CACD;AACD"}
@@ -0,0 +1,78 @@
1
+ import { _ as parsePattern, a as ProcessorCache, c as ProcessorParams, d as ParsedPattern, f as PatternParams, g as matchPattern, h as fillPattern, i as Processor, l as ProcessorResult, m as ProcessorPatternInvalid, n as ProcessorNativeInvalid, o as ProcessorContext, p as ProcessorParamMissing, r as DERIVED_PREFIX, s as ProcessorHandler, t as ProcessorBuilder, u as SourceObject } from "../ProcessorBuilder-CeEZ2vCx.cjs";
2
+ import { EnvironmentParser } from "@geekmidas/envkit";
3
+ import { ServiceDiscovery } from "@geekmidas/services";
4
+ //#region src/processors/AWSLambdaProcessor.d.ts
5
+ /** The parts of a Lambda function URL event a processor reads. */
6
+ interface FunctionUrlEvent {
7
+ rawPath: string;
8
+ requestContext: {
9
+ http: {
10
+ method: string;
11
+ };
12
+ };
13
+ }
14
+ /** What a function URL answers with. */
15
+ interface FunctionUrlResult {
16
+ statusCode: number;
17
+ headers: Record<string, string>;
18
+ body: string;
19
+ isBase64Encoded: boolean;
20
+ }
21
+ /**
22
+ * A processor as a Lambda behind a function URL — the CDN's origin for its
23
+ * pattern on AWS. The URL takes IAM auth and the CDN signs each request, so
24
+ * the function cannot be called around the cache.
25
+ */
26
+ export declare class AWSLambdaProcessor {
27
+ private readonly serve;
28
+ constructor(processor: Processor<string, any, any, any>, envParser?: EnvironmentParser<{}>);
29
+ handler: (event: FunctionUrlEvent) => Promise<FunctionUrlResult>;
30
+ }
31
+ //#endregion
32
+ //#region src/processors/runProcessor.d.ts
33
+ /** What a processor answers, for whichever server or function carries it. */
34
+ interface ProcessorResponse {
35
+ status: number;
36
+ headers: Record<string, string>;
37
+ body?: Uint8Array | string;
38
+ }
39
+ /** The object a request addressed is not in the bucket. */
40
+ export declare class ProcessorSourceMissing extends Error {
41
+ readonly key: string;
42
+ constructor(key: string);
43
+ }
44
+ /** The header a response carries, by how long it may be kept. */
45
+ export declare function cacheControl(cache: ProcessorCache | undefined): string;
46
+ /** Where a processor keeps the derivative for one request. */
47
+ export declare function derivedKey(processor: Processor<string, any, any, any>, params: Readonly<Record<string, string>>, key: string): string;
48
+ interface ProcessorRequestOptions {
49
+ serviceDiscovery: ServiceDiscovery<any>;
50
+ /** How the bucket is read through a presigned address. */
51
+ fetch?: typeof fetch;
52
+ }
53
+ /**
54
+ * Answer one request with the first processor whose pattern matches it, or
55
+ * `undefined` when none does.
56
+ *
57
+ * In order: the parameters are parsed by the processor's schema (400 when it
58
+ * refuses them); the key must be one of the file server's open paths (404
59
+ * otherwise, as an unsigned read of it would be); a derivative already in the
60
+ * bucket is answered without running anything; and only then is the handler
61
+ * run, its `immutable` result written through for next time.
62
+ */
63
+ export declare function handleProcessorRequest(processors: readonly Processor<string, any, any, any>[], request: {
64
+ method: string;
65
+ path: string;
66
+ }, options: ProcessorRequestOptions): Promise<ProcessorResponse | undefined>;
67
+ /**
68
+ * A request handler for a set of processors — what a generated entry serves
69
+ * — with its services discovered from the default environment parser: the
70
+ * process's environment and the credentials `gkm` injected.
71
+ */
72
+ export declare function processorServer(processors: readonly Processor<string, any, any, any>[], envParser?: EnvironmentParser<{}>): (request: {
73
+ method: string;
74
+ path: string;
75
+ }) => Promise<ProcessorResponse | undefined>;
76
+ //#endregion
77
+ export { DERIVED_PREFIX, type ParsedPattern, type PatternParams, Processor, ProcessorBuilder, type ProcessorCache, type ProcessorContext, type ProcessorHandler, ProcessorNativeInvalid, ProcessorParamMissing, type ProcessorParams, ProcessorPatternInvalid, type ProcessorRequestOptions, type ProcessorResponse, type ProcessorResult, type SourceObject, fillPattern, matchPattern, parsePattern };
78
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/processors/AWSLambdaProcessor.ts","../../src/processors/runProcessor.ts"],"mappings":";;;;;UAMiB;EAChB;EACA;IAAkB;MAAQ;;;;;UAIV;EAChB;EACA,SAAS;EACT;EACA;;;;;;;qBAQY;mBACK;EAEjB,YACC,WAAW,kCACX,YAAW;EAKZ,UAAO,OAAiB,qBAAmB,QAAQ;;;;;UCpBnC;EAChB;EACA,SAAS;EACT,OAAO;;;qBAIK,+BAA+B;WACtB;EAArB,YAAqB;;;wBAUN,aAAa,OAAO;;wBAOpB,WACf,WAAW,kCACX,QAAQ,SAAS,yBACjB;UAKgB;EAChB,kBAAkB;;EAElB,eAAe;;;;;;;;;;;;wBAaM,uBACrB,qBAAqB,oCACrB;EAAW;EAAgB;GAC3B,SAAS,0BACP,QAAQ;;;;;;wBAgCK,gBACf,qBAAqB,oCACrB,YAAW,yBACR;EACH;EACA;MACK,QAAQ"}
@@ -0,0 +1,78 @@
1
+ import { _ as parsePattern, a as ProcessorCache, c as ProcessorParams, d as ParsedPattern, f as PatternParams, g as matchPattern, h as fillPattern, i as Processor, l as ProcessorResult, m as ProcessorPatternInvalid, n as ProcessorNativeInvalid, o as ProcessorContext, p as ProcessorParamMissing, r as DERIVED_PREFIX, s as ProcessorHandler, t as ProcessorBuilder, u as SourceObject } from "../ProcessorBuilder-CwIlm75W.mjs";
2
+ import { ServiceDiscovery } from "@geekmidas/services";
3
+ import { EnvironmentParser } from "@geekmidas/envkit";
4
+ //#region src/processors/AWSLambdaProcessor.d.ts
5
+ /** The parts of a Lambda function URL event a processor reads. */
6
+ interface FunctionUrlEvent {
7
+ rawPath: string;
8
+ requestContext: {
9
+ http: {
10
+ method: string;
11
+ };
12
+ };
13
+ }
14
+ /** What a function URL answers with. */
15
+ interface FunctionUrlResult {
16
+ statusCode: number;
17
+ headers: Record<string, string>;
18
+ body: string;
19
+ isBase64Encoded: boolean;
20
+ }
21
+ /**
22
+ * A processor as a Lambda behind a function URL — the CDN's origin for its
23
+ * pattern on AWS. The URL takes IAM auth and the CDN signs each request, so
24
+ * the function cannot be called around the cache.
25
+ */
26
+ export declare class AWSLambdaProcessor {
27
+ private readonly serve;
28
+ constructor(processor: Processor<string, any, any, any>, envParser?: EnvironmentParser<{}>);
29
+ handler: (event: FunctionUrlEvent) => Promise<FunctionUrlResult>;
30
+ }
31
+ //#endregion
32
+ //#region src/processors/runProcessor.d.ts
33
+ /** What a processor answers, for whichever server or function carries it. */
34
+ interface ProcessorResponse {
35
+ status: number;
36
+ headers: Record<string, string>;
37
+ body?: Uint8Array | string;
38
+ }
39
+ /** The object a request addressed is not in the bucket. */
40
+ export declare class ProcessorSourceMissing extends Error {
41
+ readonly key: string;
42
+ constructor(key: string);
43
+ }
44
+ /** The header a response carries, by how long it may be kept. */
45
+ export declare function cacheControl(cache: ProcessorCache | undefined): string;
46
+ /** Where a processor keeps the derivative for one request. */
47
+ export declare function derivedKey(processor: Processor<string, any, any, any>, params: Readonly<Record<string, string>>, key: string): string;
48
+ interface ProcessorRequestOptions {
49
+ serviceDiscovery: ServiceDiscovery<any>;
50
+ /** How the bucket is read through a presigned address. */
51
+ fetch?: typeof fetch;
52
+ }
53
+ /**
54
+ * Answer one request with the first processor whose pattern matches it, or
55
+ * `undefined` when none does.
56
+ *
57
+ * In order: the parameters are parsed by the processor's schema (400 when it
58
+ * refuses them); the key must be one of the file server's open paths (404
59
+ * otherwise, as an unsigned read of it would be); a derivative already in the
60
+ * bucket is answered without running anything; and only then is the handler
61
+ * run, its `immutable` result written through for next time.
62
+ */
63
+ export declare function handleProcessorRequest(processors: readonly Processor<string, any, any, any>[], request: {
64
+ method: string;
65
+ path: string;
66
+ }, options: ProcessorRequestOptions): Promise<ProcessorResponse | undefined>;
67
+ /**
68
+ * A request handler for a set of processors — what a generated entry serves
69
+ * — with its services discovered from the default environment parser: the
70
+ * process's environment and the credentials `gkm` injected.
71
+ */
72
+ export declare function processorServer(processors: readonly Processor<string, any, any, any>[], envParser?: EnvironmentParser<{}>): (request: {
73
+ method: string;
74
+ path: string;
75
+ }) => Promise<ProcessorResponse | undefined>;
76
+ //#endregion
77
+ export { DERIVED_PREFIX, type ParsedPattern, type PatternParams, Processor, ProcessorBuilder, type ProcessorCache, type ProcessorContext, type ProcessorHandler, ProcessorNativeInvalid, ProcessorParamMissing, type ProcessorParams, ProcessorPatternInvalid, type ProcessorRequestOptions, type ProcessorResponse, type ProcessorResult, type SourceObject, fillPattern, matchPattern, parsePattern };
78
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/processors/AWSLambdaProcessor.ts","../../src/processors/runProcessor.ts"],"mappings":";;;;;UAMiB;EAChB;EACA;IAAkB;MAAQ;;;;;UAIV;EAChB;EACA,SAAS;EACT;EACA;;;;;;;qBAQY;mBACK;EAEjB,YACC,WAAW,kCACX,YAAW;EAKZ,UAAO,OAAiB,qBAAmB,QAAQ;;;;;UCpBnC;EAChB;EACA,SAAS;EACT,OAAO;;;qBAIK,+BAA+B;WACtB;EAArB,YAAqB;;;wBAUN,aAAa,OAAO;;wBAOpB,WACf,WAAW,kCACX,QAAQ,SAAS,yBACjB;UAKgB;EAChB,kBAAkB;;EAElB,eAAe;;;;;;;;;;;;wBAaM,uBACrB,qBAAqB,oCACrB;EAAW;EAAgB;GAC3B,SAAS,0BACP,QAAQ;;;;;;wBAgCK,gBACf,qBAAqB,oCACrB,YAAW,yBACR;EACH;EACA;MACK,QAAQ"}
@@ -0,0 +1,193 @@
1
+ import { a as parsePattern, c as DERIVED_PREFIX, i as matchPattern, l as Processor, n as ProcessorPatternInvalid, o as ProcessorBuilder, r as fillPattern, s as ProcessorNativeInvalid, t as ProcessorParamMissing } from "../pattern-C1CEcglD.mjs";
2
+ import { t as defaultEnvParser } from "../surfaceEnv-wMT5QzgZ.mjs";
3
+ import { ServiceDiscovery, runWithRequestContext } from "@geekmidas/services";
4
+ //#region src/processors/runProcessor.ts
5
+ /** The object a request addressed is not in the bucket. */
6
+ var ProcessorSourceMissing = class extends Error {
7
+ key;
8
+ constructor(key) {
9
+ super(`'${key}' is not in the bucket, so there is nothing to process.`);
10
+ this.key = key;
11
+ this.name = "ProcessorSourceMissing";
12
+ }
13
+ };
14
+ /** What a refusal or a miss may be kept for: long enough to absorb a burst. */
15
+ const SHORT = "public, max-age=60";
16
+ /** The header a response carries, by how long it may be kept. */
17
+ function cacheControl(cache) {
18
+ if (cache === "immutable") return "public, max-age=31536000, immutable";
19
+ if (cache === "none") return "no-store";
20
+ return `public, max-age=${cache?.maxAge ?? 3600}`;
21
+ }
22
+ /** Where a processor keeps the derivative for one request. */
23
+ function derivedKey(processor, params, key) {
24
+ return `${DERIVED_PREFIX}${fillPattern(processor.parsed, params, key).slice(1)}`;
25
+ }
26
+ /**
27
+ * Answer one request with the first processor whose pattern matches it, or
28
+ * `undefined` when none does.
29
+ *
30
+ * In order: the parameters are parsed by the processor's schema (400 when it
31
+ * refuses them); the key must be one of the file server's open paths (404
32
+ * otherwise, as an unsigned read of it would be); a derivative already in the
33
+ * bucket is answered without running anything; and only then is the handler
34
+ * run, its `immutable` result written through for next time.
35
+ */
36
+ async function handleProcessorRequest(processors, request, options) {
37
+ const method = request.method.toUpperCase();
38
+ for (const processor of processors) {
39
+ const match = matchPattern(processor.parsed, request.path);
40
+ if (!match) continue;
41
+ if (method !== "GET" && method !== "HEAD") return text(405, "Method Not Allowed", "no-store", { allow: "GET, HEAD" });
42
+ return runWithRequestContext({
43
+ logger: processor.logger,
44
+ requestId: `processor-${Date.now()}`,
45
+ startTime: Date.now(),
46
+ operation: `processor ${processor.pattern}`
47
+ }, () => run(processor, match, options));
48
+ }
49
+ }
50
+ /**
51
+ * A request handler for a set of processors — what a generated entry serves
52
+ * — with its services discovered from the default environment parser: the
53
+ * process's environment and the credentials `gkm` injected.
54
+ */
55
+ function processorServer(processors, envParser = defaultEnvParser()) {
56
+ const serviceDiscovery = ServiceDiscovery.getInstance(envParser);
57
+ return (request) => handleProcessorRequest(processors, request, { serviceDiscovery });
58
+ }
59
+ async function run(processor, match, options) {
60
+ const logger = processor.logger;
61
+ const fetcher = options.fetch ?? fetch;
62
+ const { key } = match;
63
+ const schema = processor.options.paramsSchema;
64
+ let params = match.params;
65
+ if (schema) {
66
+ const parsed = await schema["~standard"].validate(match.params);
67
+ if (parsed.issues) return text(400, "Bad Request", SHORT);
68
+ params = parsed.value;
69
+ }
70
+ if (key.startsWith(DERIVED_PREFIX) || !processor.options.serves(key)) return text(404, "Not Found", SHORT);
71
+ const services = await options.serviceDiscovery.register(processor.services);
72
+ const storage = services[processor.options.origin.serviceName];
73
+ const derived = derivedKey(processor, match.params, key);
74
+ const kept = await read(storage, derived, fetcher);
75
+ if (kept) return {
76
+ status: 200,
77
+ headers: {
78
+ "content-type": kept.contentType ?? "application/octet-stream",
79
+ "cache-control": cacheControl("immutable"),
80
+ "x-gkm-processor": "kept"
81
+ },
82
+ body: new Uint8Array(await kept.response.arrayBuffer())
83
+ };
84
+ let source;
85
+ const load = async () => {
86
+ if (source) return source;
87
+ const found = await read(storage, key, fetcher);
88
+ if (!found) throw new ProcessorSourceMissing(key);
89
+ source = found.response;
90
+ return source;
91
+ };
92
+ const object = {
93
+ key,
94
+ bytes: async () => new Uint8Array(await (await load()).arrayBuffer()),
95
+ stream: async () => {
96
+ const body = (await load()).body;
97
+ if (!body) throw new ProcessorSourceMissing(key);
98
+ return body;
99
+ },
100
+ contentType: async () => (await load()).headers.get("content-type") ?? void 0
101
+ };
102
+ let result;
103
+ try {
104
+ result = await processor.handler({
105
+ params,
106
+ key,
107
+ object,
108
+ logger,
109
+ services
110
+ });
111
+ } catch (error) {
112
+ if (error instanceof ProcessorSourceMissing) return text(404, "Not Found", SHORT);
113
+ logger.error({
114
+ err: error,
115
+ key
116
+ }, "Processor failed");
117
+ return text(500, "Internal Server Error", "no-store");
118
+ }
119
+ const body = typeof result.body === "string" ? new TextEncoder().encode(result.body) : result.body;
120
+ if (result.cache === "immutable") await storage.upload(derived, Buffer.from(body), result.contentType).catch((error) => logger.warn({
121
+ err: error,
122
+ key: derived
123
+ }, "Could not keep derivative"));
124
+ return {
125
+ status: 200,
126
+ headers: {
127
+ "content-type": result.contentType,
128
+ "cache-control": cacheControl(result.cache),
129
+ "x-gkm-processor": "made"
130
+ },
131
+ body
132
+ };
133
+ }
134
+ /** An object through a presigned address, or nothing when it is not there. */
135
+ async function read(storage, key, fetcher) {
136
+ const response = await fetcher(await storage.getDownloadURL({ path: key }));
137
+ if (!response.ok) {
138
+ await response.body?.cancel().catch(() => void 0);
139
+ return;
140
+ }
141
+ const contentType = response.headers.get("content-type") ?? void 0;
142
+ return {
143
+ response,
144
+ ...contentType ? { contentType } : {}
145
+ };
146
+ }
147
+ function text(status, body, cache, extra = {}) {
148
+ return {
149
+ status,
150
+ headers: {
151
+ "content-type": "text/plain; charset=utf-8",
152
+ "cache-control": cache,
153
+ ...extra
154
+ },
155
+ body
156
+ };
157
+ }
158
+ //#endregion
159
+ //#region src/processors/AWSLambdaProcessor.ts
160
+ /**
161
+ * A processor as a Lambda behind a function URL — the CDN's origin for its
162
+ * pattern on AWS. The URL takes IAM auth and the CDN signs each request, so
163
+ * the function cannot be called around the cache.
164
+ */
165
+ var AWSLambdaProcessor = class {
166
+ serve;
167
+ constructor(processor, envParser = defaultEnvParser()) {
168
+ this.serve = processorServer([processor], envParser);
169
+ }
170
+ handler = async (event) => {
171
+ const response = await this.serve({
172
+ method: event.requestContext.http.method,
173
+ path: event.rawPath
174
+ });
175
+ if (!response) return {
176
+ statusCode: 404,
177
+ headers: { "cache-control": "public, max-age=60" },
178
+ body: "",
179
+ isBase64Encoded: false
180
+ };
181
+ const body = response.body ?? "";
182
+ return {
183
+ statusCode: response.status,
184
+ headers: response.headers,
185
+ body: typeof body === "string" ? body : Buffer.from(body).toString("base64"),
186
+ isBase64Encoded: typeof body !== "string"
187
+ };
188
+ };
189
+ };
190
+ //#endregion
191
+ export { AWSLambdaProcessor, DERIVED_PREFIX, Processor, ProcessorBuilder, ProcessorNativeInvalid, ProcessorParamMissing, ProcessorPatternInvalid, ProcessorSourceMissing, cacheControl, derivedKey, fillPattern, handleProcessorRequest, matchPattern, parsePattern, processorServer };
192
+
193
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/processors/runProcessor.ts","../../src/processors/AWSLambdaProcessor.ts"],"sourcesContent":["import type { EnvironmentParser } from '@geekmidas/envkit';\nimport type { Logger } from '@geekmidas/logger';\nimport { runWithRequestContext, ServiceDiscovery } from '@geekmidas/services';\nimport type { StorageClient } from '@geekmidas/storage';\nimport { defaultEnvParser } from '../endpoints/surfaceEnv';\nimport {\n\tDERIVED_PREFIX,\n\ttype Processor,\n\ttype ProcessorCache,\n\ttype SourceObject,\n} from './Processor';\nimport { fillPattern, matchPattern } from './pattern';\n\n/** What a processor answers, for whichever server or function carries it. */\nexport interface ProcessorResponse {\n\tstatus: number;\n\theaders: Record<string, string>;\n\tbody?: Uint8Array | string;\n}\n\n/** The object a request addressed is not in the bucket. */\nexport class ProcessorSourceMissing extends Error {\n\tconstructor(readonly key: string) {\n\t\tsuper(`'${key}' is not in the bucket, so there is nothing to process.`);\n\t\tthis.name = 'ProcessorSourceMissing';\n\t}\n}\n\n/** What a refusal or a miss may be kept for: long enough to absorb a burst. */\nconst SHORT = 'public, max-age=60';\n\n/** The header a response carries, by how long it may be kept. */\nexport function cacheControl(cache: ProcessorCache | undefined): string {\n\tif (cache === 'immutable') return 'public, max-age=31536000, immutable';\n\tif (cache === 'none') return 'no-store';\n\treturn `public, max-age=${cache?.maxAge ?? 3600}`;\n}\n\n/** Where a processor keeps the derivative for one request. */\nexport function derivedKey(\n\tprocessor: Processor<string, any, any, any>,\n\tparams: Readonly<Record<string, string>>,\n\tkey: string,\n): string {\n\treturn `${DERIVED_PREFIX}${fillPattern(processor.parsed, params, key).slice(1)}`;\n}\n\nexport interface ProcessorRequestOptions {\n\tserviceDiscovery: ServiceDiscovery<any>;\n\t/** How the bucket is read through a presigned address. */\n\tfetch?: typeof fetch;\n}\n\n/**\n * Answer one request with the first processor whose pattern matches it, or\n * `undefined` when none does.\n *\n * In order: the parameters are parsed by the processor's schema (400 when it\n * refuses them); the key must be one of the file server's open paths (404\n * otherwise, as an unsigned read of it would be); a derivative already in the\n * bucket is answered without running anything; and only then is the handler\n * run, its `immutable` result written through for next time.\n */\nexport async function handleProcessorRequest(\n\tprocessors: readonly Processor<string, any, any, any>[],\n\trequest: { method: string; path: string },\n\toptions: ProcessorRequestOptions,\n): Promise<ProcessorResponse | undefined> {\n\tconst method = request.method.toUpperCase();\n\n\tfor (const processor of processors) {\n\t\tconst match = matchPattern(processor.parsed, request.path);\n\t\tif (!match) continue;\n\n\t\tif (method !== 'GET' && method !== 'HEAD') {\n\t\t\treturn text(405, 'Method Not Allowed', 'no-store', {\n\t\t\t\tallow: 'GET, HEAD',\n\t\t\t});\n\t\t}\n\n\t\treturn runWithRequestContext(\n\t\t\t{\n\t\t\t\tlogger: processor.logger,\n\t\t\t\trequestId: `processor-${Date.now()}`,\n\t\t\t\tstartTime: Date.now(),\n\t\t\t\toperation: `processor ${processor.pattern}`,\n\t\t\t},\n\t\t\t() => run(processor, match, options),\n\t\t);\n\t}\n\n\treturn undefined;\n}\n\n/**\n * A request handler for a set of processors — what a generated entry serves\n * — with its services discovered from the default environment parser: the\n * process's environment and the credentials `gkm` injected.\n */\nexport function processorServer(\n\tprocessors: readonly Processor<string, any, any, any>[],\n\tenvParser: EnvironmentParser<{}> = defaultEnvParser(),\n): (request: {\n\tmethod: string;\n\tpath: string;\n}) => Promise<ProcessorResponse | undefined> {\n\tconst serviceDiscovery = ServiceDiscovery.getInstance(envParser);\n\treturn (request) =>\n\t\thandleProcessorRequest(processors, request, { serviceDiscovery });\n}\n\nasync function run(\n\tprocessor: Processor<string, any, any, any>,\n\tmatch: { params: Record<string, string>; key: string },\n\toptions: ProcessorRequestOptions,\n): Promise<ProcessorResponse> {\n\tconst logger = processor.logger as Logger;\n\tconst fetcher = options.fetch ?? fetch;\n\tconst { key } = match;\n\n\tconst schema = processor.options.paramsSchema;\n\tlet params: unknown = match.params;\n\tif (schema) {\n\t\tconst parsed = await schema['~standard'].validate(match.params);\n\t\tif (parsed.issues) return text(400, 'Bad Request', SHORT);\n\t\tparams = parsed.value;\n\t}\n\n\t// A derivative is never itself a source, and a private object is never\n\t// processed: a processor serves exactly what an unsigned read would.\n\tif (key.startsWith(DERIVED_PREFIX) || !processor.options.serves(key)) {\n\t\treturn text(404, 'Not Found', SHORT);\n\t}\n\n\tconst services: Record<string, unknown> =\n\t\tawait options.serviceDiscovery.register(processor.services);\n\tconst storage = services[\n\t\tprocessor.options.origin.serviceName\n\t] as StorageClient;\n\n\tconst derived = derivedKey(processor, match.params, key);\n\tconst kept = await read(storage, derived, fetcher);\n\tif (kept) {\n\t\treturn {\n\t\t\tstatus: 200,\n\t\t\theaders: {\n\t\t\t\t'content-type': kept.contentType ?? 'application/octet-stream',\n\t\t\t\t'cache-control': cacheControl('immutable'),\n\t\t\t\t'x-gkm-processor': 'kept',\n\t\t\t},\n\t\t\tbody: new Uint8Array(await kept.response.arrayBuffer()),\n\t\t};\n\t}\n\n\tlet source: Response | undefined;\n\tconst load = async (): Promise<Response> => {\n\t\tif (source) return source;\n\t\tconst found = await read(storage, key, fetcher);\n\t\tif (!found) throw new ProcessorSourceMissing(key);\n\t\tsource = found.response;\n\t\treturn source;\n\t};\n\tconst object: SourceObject = {\n\t\tkey,\n\t\tbytes: async () => new Uint8Array(await (await load()).arrayBuffer()),\n\t\tstream: async () => {\n\t\t\tconst body = (await load()).body;\n\t\t\tif (!body) throw new ProcessorSourceMissing(key);\n\t\t\treturn body;\n\t\t},\n\t\tcontentType: async () =>\n\t\t\t(await load()).headers.get('content-type') ?? undefined,\n\t};\n\n\tlet result: Awaited<ReturnType<typeof processor.handler>>;\n\ttry {\n\t\tresult = await processor.handler({\n\t\t\tparams,\n\t\t\tkey,\n\t\t\tobject,\n\t\t\tlogger,\n\t\t\tservices,\n\t\t} as never);\n\t} catch (error) {\n\t\tif (error instanceof ProcessorSourceMissing) {\n\t\t\treturn text(404, 'Not Found', SHORT);\n\t\t}\n\t\tlogger.error({ err: error, key }, 'Processor failed');\n\t\treturn text(500, 'Internal Server Error', 'no-store');\n\t}\n\n\tconst body =\n\t\ttypeof result.body === 'string'\n\t\t\t? new TextEncoder().encode(result.body)\n\t\t\t: result.body;\n\n\t// Kept only when it can never change: anything else would be served from\n\t// the bucket long after its handler would have answered differently.\n\tif (result.cache === 'immutable') {\n\t\tawait storage\n\t\t\t.upload(derived, Buffer.from(body), result.contentType)\n\t\t\t.catch((error: unknown) =>\n\t\t\t\tlogger.warn({ err: error, key: derived }, 'Could not keep derivative'),\n\t\t\t);\n\t}\n\n\treturn {\n\t\tstatus: 200,\n\t\theaders: {\n\t\t\t'content-type': result.contentType,\n\t\t\t'cache-control': cacheControl(result.cache),\n\t\t\t'x-gkm-processor': 'made',\n\t\t},\n\t\tbody,\n\t};\n}\n\n/** An object through a presigned address, or nothing when it is not there. */\nasync function read(\n\tstorage: StorageClient,\n\tkey: string,\n\tfetcher: typeof fetch,\n): Promise<{ response: Response; contentType?: string } | undefined> {\n\tconst url = await storage.getDownloadURL({ path: key });\n\tconst response = await fetcher(url);\n\tif (!response.ok) {\n\t\tawait response.body?.cancel().catch(() => undefined);\n\t\treturn undefined;\n\t}\n\tconst contentType = response.headers.get('content-type') ?? undefined;\n\treturn { response, ...(contentType ? { contentType } : {}) };\n}\n\nfunction text(\n\tstatus: number,\n\tbody: string,\n\tcache: string,\n\textra: Record<string, string> = {},\n): ProcessorResponse {\n\treturn {\n\t\tstatus,\n\t\theaders: {\n\t\t\t'content-type': 'text/plain; charset=utf-8',\n\t\t\t'cache-control': cache,\n\t\t\t...extra,\n\t\t},\n\t\tbody,\n\t};\n}\n","import type { EnvironmentParser } from '@geekmidas/envkit';\nimport { defaultEnvParser } from '../endpoints/surfaceEnv';\nimport type { Processor } from './Processor';\nimport { processorServer } from './runProcessor';\n\n/** The parts of a Lambda function URL event a processor reads. */\nexport interface FunctionUrlEvent {\n\trawPath: string;\n\trequestContext: { http: { method: string } };\n}\n\n/** What a function URL answers with. */\nexport interface FunctionUrlResult {\n\tstatusCode: number;\n\theaders: Record<string, string>;\n\tbody: string;\n\tisBase64Encoded: boolean;\n}\n\n/**\n * A processor as a Lambda behind a function URL — the CDN's origin for its\n * pattern on AWS. The URL takes IAM auth and the CDN signs each request, so\n * the function cannot be called around the cache.\n */\nexport class AWSLambdaProcessor {\n\tprivate readonly serve: ReturnType<typeof processorServer>;\n\n\tconstructor(\n\t\tprocessor: Processor<string, any, any, any>,\n\t\tenvParser: EnvironmentParser<{}> = defaultEnvParser(),\n\t) {\n\t\tthis.serve = processorServer([processor], envParser);\n\t}\n\n\thandler = async (event: FunctionUrlEvent): Promise<FunctionUrlResult> => {\n\t\tconst response = await this.serve({\n\t\t\tmethod: event.requestContext.http.method,\n\t\t\tpath: event.rawPath,\n\t\t});\n\t\tif (!response) {\n\t\t\treturn {\n\t\t\t\tstatusCode: 404,\n\t\t\t\theaders: { 'cache-control': 'public, max-age=60' },\n\t\t\t\tbody: '',\n\t\t\t\tisBase64Encoded: false,\n\t\t\t};\n\t\t}\n\t\tconst body = response.body ?? '';\n\t\treturn {\n\t\t\tstatusCode: response.status,\n\t\t\theaders: response.headers,\n\t\t\tbody:\n\t\t\t\ttypeof body === 'string' ? body : Buffer.from(body).toString('base64'),\n\t\t\tisBase64Encoded: typeof body !== 'string',\n\t\t};\n\t};\n}\n"],"mappings":";;;;;AAqBA,IAAa,yBA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;GAClC,MAAM,MAAM;EACb,CAAC;EACD,IAAI,CAAC,UACJ,OAAO;GACN,YAAY;GACZ,SAAS,EAAE,iBAAiB,qBAAqB;GACjD,MAAM;GACN,iBAAiB;EAClB;EAED,MAAM,OAAO,SAAS,QAAQ;EAC9B,OAAO;GACN,YAAY,SAAS;GACrB,SAAS,SAAS;GAClB,MACC,OAAO,SAAS,WAAW,OAAO,OAAO,KAAK,IAAI,CAAC,CAAC,SAAS,QAAQ;GACtE,iBAAiB,OAAO,SAAS;EAClC;CACD;AACD"}
@@ -1,193 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_Construct = require("../Construct-DqdlARxq.cjs");
3
- const require_construct_interface = require("../construct-interface.cjs");
4
- const require_clone = require("../clone-UGJpvQnL.cjs");
5
- let _geekmidas_manifest = require("@geekmidas/manifest");
6
- let _geekmidas_logger_console = require("@geekmidas/logger/console");
7
- let _geekmidas_events = require("@geekmidas/events");
8
- //#region src/queue/Queue.ts
9
- /**
10
- * A queue worker — a point-to-point SQS-style queue and its single consumer.
11
- * Unlike a `Subscriber` (topic fan-out, filtered by `subscribedEvents`), a queue
12
- * drains every message of its one `message` type. Build one with `q` (see
13
- * `QueueBuilder`); `gkm build` discovers it into the manifest's `queues` field.
14
- *
15
- * The producer side is {@link Queue.publisher} — a ready-to-inject `Service`
16
- * that any endpoint/function drops into `.services([...])` to send messages.
17
- */
18
- var Queue = class extends require_Construct.Construct {
19
- name;
20
- handler;
21
- messageSchema;
22
- timeout;
23
- services;
24
- logger;
25
- batchSize;
26
- fifo;
27
- __IS_QUEUE__ = true;
28
- static isQueue(obj) {
29
- return Boolean(obj && obj.__IS_QUEUE__ === true && obj.type === "dev.geekmidas.function.queue");
30
- }
31
- /**
32
- * The canonical id this queue is declared under.
33
- *
34
- * Derived from the name rather than given separately, so `emails` and
35
- * `Emails` are one queue. The name stays what it was: it is the wire `type`
36
- * a producer sends and the worker subscribes to, and changing that would
37
- * silently orphan in-flight messages.
38
- */
39
- id;
40
- /**
41
- * The producer's env key. Read by both {@link declare} and
42
- * {@link publisher}, so what the target publishes and what the producer
43
- * looks up cannot drift.
44
- */
45
- connectionKey;
46
- constructor(name, handler, messageSchema, timeout = 3e4, services = [], logger = _geekmidas_logger_console.DEFAULT_LOGGER, batchSize, fifo, constructs = []) {
47
- super("dev.geekmidas.function.queue", logger, services, [], void 0, void 0, timeout, void 0, void 0, constructs);
48
- this.name = name;
49
- this.handler = handler;
50
- this.messageSchema = messageSchema;
51
- this.timeout = timeout;
52
- this.services = services;
53
- this.logger = logger;
54
- this.batchSize = batchSize;
55
- this.fifo = fifo;
56
- this.id = (0, _geekmidas_manifest.canonicalId)(name);
57
- this.connectionKey = (0, _geekmidas_manifest.provideKey)(this.id, "publisherConnectionString");
58
- }
59
- /**
60
- * What this queue is in the manifest.
61
- *
62
- * A queue is a resource, not a handler: the worker is reached *through* it,
63
- * so the declaration carries the producer's key and nothing about the code
64
- * that drains it. The local target reads this to know which broker has to be
65
- * running and what connection string to inject.
66
- */
67
- declare() {
68
- return [{
69
- kind: "queue",
70
- id: this.id,
71
- provides: [this.connectionKey],
72
- ...this.fifo ? { fifo: true } : {},
73
- worker: {
74
- id: `${this.id}Worker`,
75
- handler: `${this.id}.handler`,
76
- dependencies: []
77
- }
78
- }];
79
- }
80
- /**
81
- * The producer side — a `Service` exposing an `EventPublisher` typed to this
82
- * queue's message. Inject it via `.services([queue.publisher])`; the handler
83
- * then calls `services.<name>Publisher.publish([{ type, payload }])`.
84
- *
85
- * It reads `<NAME>_PUBLISHER_CONNECTION_STRING` and builds the transport from
86
- * the URL protocol — `pgboss://` locally, `sqs://` deployed — so the same
87
- * code publishes to Postgres in dev and SQS in prod. Because it's a `Service`,
88
- * `Construct.getEnvironment()` sniffs it, so the env requirement flows into
89
- * the manifest and infra links exactly this queue with least privilege.
90
- */
91
- /**
92
- * The queue as a dependency — what `.dependsOn([emailsQueue])` dissolves
93
- * into, reachable as `services.emails`.
94
- *
95
- * It is the producer: a consumer is the worker written right here, so the
96
- * only thing another construct can want from a queue is the ability to send
97
- * to it. {@link publisher} is the same service under its older
98
- * `<name>Publisher` key, kept for `.services([queue.publisher])`.
99
- */
100
- get service() {
101
- const { register } = this.publisher;
102
- return {
103
- serviceName: (0, _geekmidas_manifest.serviceKey)(this.id),
104
- register
105
- };
106
- }
107
- get publisher() {
108
- const envVar = this.connectionKey;
109
- return {
110
- serviceName: `${this.name}Publisher`,
111
- async register({ envParser }) {
112
- const { connectionString } = envParser.create((get) => ({ connectionString: get(envVar).string() })).parse();
113
- return _geekmidas_events.Publisher.fromConnectionString(connectionString);
114
- }
115
- };
116
- }
117
- };
118
- //#endregion
119
- //#region src/queue/QueueBuilder.ts
120
- /**
121
- * Builds a {@link Queue} worker — `q.queue('orders').services([db]).message(schema).handle(fn)`.
122
- * Services are an array (sniffed for required env vars); `message` is the typed
123
- * job payload; `handle` is the single consumer. The queue name is captured as a
124
- * literal so `queue.publisher` is typed to `{ type: '<name>', payload }`.
125
- */
126
- var QueueBuilder = class {
127
- _name;
128
- _messageSchema;
129
- _timeout = 3e4;
130
- _batchSize;
131
- _fifo;
132
- _services = [];
133
- /** The construct ids `.dependsOn()` named — what the manifest records. */
134
- _constructs = [];
135
- _logger = _geekmidas_logger_console.DEFAULT_LOGGER;
136
- /** The queue name — drives the infra queue and its `<NAME>_*` env vars. */
137
- queue(name) {
138
- return require_clone.cloneWith(this, { _name: name });
139
- }
140
- timeout(timeout) {
141
- return require_clone.cloneWith(this, { _timeout: timeout });
142
- }
143
- /** SQS event-source batch size (deployed). */
144
- batchSize(batchSize) {
145
- return require_clone.cloneWith(this, { _batchSize: batchSize });
146
- }
147
- /** Mark the queue as FIFO (deployed). */
148
- fifo(fifo = true) {
149
- return require_clone.cloneWith(this, { _fifo: fifo });
150
- }
151
- /**
152
- * Depend on constructs — a database, a bucket, a mail sender, a queue, a
153
- * topic.
154
- *
155
- * It records the edge and dissolves each construct's client into the
156
- * handler's service record under the construct's own id, so
157
- * `.dependsOn([uploads])` is what makes `services.uploads` exist and type.
158
- *
159
- * Constructs only. A `Service` does not match the shape, which is what keeps
160
- * env sniffing confined to `.services()` and the explicit lift.
161
- */
162
- dependsOn(constructs) {
163
- const services = require_construct_interface.servicesOf(constructs);
164
- return require_clone.cloneWith(this, {
165
- _services: [...this._services, ...services],
166
- _constructs: require_construct_interface.idsOf(constructs, this._constructs)
167
- });
168
- }
169
- services(services) {
170
- return require_clone.cloneWith(this, { _services: [...this._services, ...services] });
171
- }
172
- logger(logger) {
173
- return require_clone.cloneWith(this, { _logger: logger });
174
- }
175
- /** The typed message (job) payload the queue carries. */
176
- message(schema) {
177
- return require_clone.cloneWith(this, { _messageSchema: schema });
178
- }
179
- handle(fn) {
180
- if (!this._name) throw new Error("Queue requires a name — call .queue(name) before .handle().");
181
- if (!this._messageSchema) throw new Error("Queue requires a message schema — call .message(schema) before .handle().");
182
- return new Queue(this._name, fn, this._messageSchema, this._timeout, this._services, this._logger, this._batchSize, this._fifo, this._constructs);
183
- }
184
- };
185
- //#endregion
186
- //#region src/queue/index.ts
187
- const q = new QueueBuilder();
188
- //#endregion
189
- exports.Queue = Queue;
190
- exports.QueueBuilder = QueueBuilder;
191
- exports.q = q;
192
-
193
- //# sourceMappingURL=index.cjs.map
2
+ const require_Queue = require("../Queue-W1wueijP.cjs");
3
+ const require_QueueBuilder = require("../QueueBuilder-BDcv9B71.cjs");
4
+ exports.Queue = require_Queue.Queue;
5
+ exports.QueueNeedsMessage = require_QueueBuilder.QueueNeedsMessage;
6
+ exports.QueueNeedsName = require_QueueBuilder.QueueNeedsName;