@geekmidas/constructs 10.0.0-alpha.154 → 10.0.0-alpha.156

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 (220) hide show
  1. package/README.md +23 -0
  2. package/dist/{Construct-DorKS0Ua.cjs → Construct-B8yWxGlR.cjs} +2 -2
  3. package/dist/{Construct-DorKS0Ua.cjs.map → Construct-B8yWxGlR.cjs.map} +1 -1
  4. package/dist/{Construct-DySlwh8o.d.mts → Construct-BMk_CRSD.d.mts} +2 -2
  5. package/dist/{Construct-DySlwh8o.d.mts.map → Construct-BMk_CRSD.d.mts.map} +1 -1
  6. package/dist/{Construct-CGuc_Ijk.mjs → Construct-CRV3RN2U.mjs} +11 -2
  7. package/dist/{Construct-CGuc_Ijk.mjs.map → Construct-CRV3RN2U.mjs.map} +1 -1
  8. package/dist/{Cron-D8mB_cPX.d.mts → Cron-D6Y7BBt3.d.mts} +5 -5
  9. package/dist/{Cron-D8mB_cPX.d.mts.map → Cron-D6Y7BBt3.d.mts.map} +1 -1
  10. package/dist/{CronBuilder-Cmajva3g.d.mts → CronBuilder-4BZhkChG.d.mts} +5 -5
  11. package/dist/{CronBuilder-Cmajva3g.d.mts.map → CronBuilder-4BZhkChG.d.mts.map} +1 -1
  12. package/dist/{CronBuilder-B_NSP-Y5.cjs → CronBuilder-B4DYaEjl.cjs} +4 -4
  13. package/dist/{CronBuilder-B_NSP-Y5.cjs.map → CronBuilder-B4DYaEjl.cjs.map} +1 -1
  14. package/dist/{CronBuilder-BJ5LoadF.mjs → CronBuilder-CukJuL3b.mjs} +3 -3
  15. package/dist/{CronBuilder-BJ5LoadF.mjs.map → CronBuilder-CukJuL3b.mjs.map} +1 -1
  16. package/dist/{Endpoint-BbHh3Qoc.d.mts → Endpoint-BUoDD96P.d.mts} +5 -5
  17. package/dist/{Endpoint-BbHh3Qoc.d.mts.map → Endpoint-BUoDD96P.d.mts.map} +1 -1
  18. package/dist/{Endpoint-sUOU7uLx.mjs → Endpoint-BuKHHVZc.mjs} +3 -3
  19. package/dist/{Endpoint-sUOU7uLx.mjs.map → Endpoint-BuKHHVZc.mjs.map} +1 -1
  20. package/dist/{Endpoint-52z1P0Ue.cjs → Endpoint-D2ckHqIx.cjs} +3 -3
  21. package/dist/{Endpoint-52z1P0Ue.cjs.map → Endpoint-D2ckHqIx.cjs.map} +1 -1
  22. package/dist/{EndpointFactory-qcLzi4f-.d.mts → EndpointFactory-BbVOeryo.d.mts} +5 -5
  23. package/dist/{EndpointFactory-qcLzi4f-.d.mts.map → EndpointFactory-BbVOeryo.d.mts.map} +1 -1
  24. package/dist/{EndpointFactory-Bzi9Sl7r.mjs → EndpointFactory-BsJUlUyL.mjs} +4 -4
  25. package/dist/{EndpointFactory-Bzi9Sl7r.mjs.map → EndpointFactory-BsJUlUyL.mjs.map} +1 -1
  26. package/dist/{EndpointFactory-Cf_Cs1ym.cjs → EndpointFactory-c4tHjQKM.cjs} +5 -5
  27. package/dist/{EndpointFactory-Cf_Cs1ym.cjs.map → EndpointFactory-c4tHjQKM.cjs.map} +1 -1
  28. package/dist/{Function-DfMzTGS4.d.mts → Function-BKReud5p.d.mts} +3 -3
  29. package/dist/{Function-DfMzTGS4.d.mts.map → Function-BKReud5p.d.mts.map} +1 -1
  30. package/dist/{HonoEndpointAdaptor-DR3j7S35.mjs → HonoEndpointAdaptor-BC7CZ7Cr.mjs} +7 -6
  31. package/dist/HonoEndpointAdaptor-BC7CZ7Cr.mjs.map +1 -0
  32. package/dist/{HonoEndpointAdaptor-BXBdb2Bt.cjs → HonoEndpointAdaptor-BGEW1Tu8.cjs} +9 -8
  33. package/dist/HonoEndpointAdaptor-BGEW1Tu8.cjs.map +1 -0
  34. package/dist/{ObjectSubscriberBuilder-Cv8C7yS1.d.mts → ObjectSubscriberBuilder-DfzXQEKW.d.mts} +4 -4
  35. package/dist/{ObjectSubscriberBuilder-Cv8C7yS1.d.mts.map → ObjectSubscriberBuilder-DfzXQEKW.d.mts.map} +1 -1
  36. package/dist/ObjectSubscriberBuilder-LWkey_oq.d.cts.map +1 -1
  37. package/dist/{ProcessorBuilder-CwfP-M33.d.mts → ProcessorBuilder-D4oYvZeG.d.mts} +2 -2
  38. package/dist/{ProcessorBuilder-CwfP-M33.d.mts.map → ProcessorBuilder-D4oYvZeG.d.mts.map} +1 -1
  39. package/dist/{Queue-u8w8_HpE.mjs → Queue-0FpvxdOa.mjs} +2 -2
  40. package/dist/{Queue-u8w8_HpE.mjs.map → Queue-0FpvxdOa.mjs.map} +1 -1
  41. package/dist/{Queue-BnK3UH8r.d.mts → Queue-B8HGg439.d.mts} +3 -3
  42. package/dist/{Queue-BnK3UH8r.d.mts.map → Queue-B8HGg439.d.mts.map} +1 -1
  43. package/dist/{Queue-D4Iaidrs.cjs → Queue-DZpV13LN.cjs} +2 -2
  44. package/dist/{Queue-D4Iaidrs.cjs.map → Queue-DZpV13LN.cjs.map} +1 -1
  45. package/dist/{QueueBuilder-2wP5lEC8.mjs → QueueBuilder-Bmyay_Di.mjs} +2 -2
  46. package/dist/{QueueBuilder-2wP5lEC8.mjs.map → QueueBuilder-Bmyay_Di.mjs.map} +1 -1
  47. package/dist/{QueueBuilder-DmwFtLzQ.d.mts → QueueBuilder-CVS_qPuo.d.mts} +2 -2
  48. package/dist/{QueueBuilder-DmwFtLzQ.d.mts.map → QueueBuilder-CVS_qPuo.d.mts.map} +1 -1
  49. package/dist/{QueueBuilder-BxsZ9o5z.cjs → QueueBuilder-FXkSDah1.cjs} +2 -2
  50. package/dist/{QueueBuilder-BxsZ9o5z.cjs.map → QueueBuilder-FXkSDah1.cjs.map} +1 -1
  51. package/dist/{Subscriber-CW_Dl-YR.d.mts → Subscriber-CtQXhcL7.d.mts} +3 -3
  52. package/dist/{Subscriber-CW_Dl-YR.d.mts.map → Subscriber-CtQXhcL7.d.mts.map} +1 -1
  53. package/dist/{SubscriberBuilder-CWzKwX1p.cjs → SubscriberBuilder-Bfn-iDSk.cjs} +4 -3
  54. package/dist/SubscriberBuilder-Bfn-iDSk.cjs.map +1 -0
  55. package/dist/{SubscriberBuilder-BL_GTcwh.mjs → SubscriberBuilder-CxG1OOug.mjs} +4 -3
  56. package/dist/SubscriberBuilder-CxG1OOug.mjs.map +1 -0
  57. package/dist/{Topic-DN2gYJ-p.mjs → Topic-DoEdDgh7.mjs} +2 -2
  58. package/dist/{Topic-DN2gYJ-p.mjs.map → Topic-DoEdDgh7.mjs.map} +1 -1
  59. package/dist/{Topic-Dp9Q7Lj2.cjs → Topic-t5GhqaeT.cjs} +2 -2
  60. package/dist/{Topic-Dp9Q7Lj2.cjs.map → Topic-t5GhqaeT.cjs.map} +1 -1
  61. package/dist/adaptors/aws.cjs +28 -16
  62. package/dist/adaptors/aws.cjs.map +1 -1
  63. package/dist/adaptors/aws.d.cts +141 -0
  64. package/dist/adaptors/aws.d.cts.map +1 -1
  65. package/dist/adaptors/aws.d.mts +147 -6
  66. package/dist/adaptors/aws.d.mts.map +1 -1
  67. package/dist/adaptors/aws.mjs +21 -15
  68. package/dist/adaptors/aws.mjs.map +1 -1
  69. package/dist/adaptors/hono.cjs +1 -1
  70. package/dist/adaptors/hono.d.mts +2 -2
  71. package/dist/adaptors/hono.mjs +1 -1
  72. package/dist/adaptors/testing.cjs +230 -14
  73. package/dist/adaptors/testing.cjs.map +1 -1
  74. package/dist/adaptors/testing.d.cts +81 -2
  75. package/dist/adaptors/testing.d.cts.map +1 -1
  76. package/dist/adaptors/testing.d.mts +89 -10
  77. package/dist/adaptors/testing.d.mts.map +1 -1
  78. package/dist/adaptors/testing.mjs +221 -12
  79. package/dist/adaptors/testing.mjs.map +1 -1
  80. package/dist/apigateway-Dyjy_JwI.mjs +329 -0
  81. package/dist/apigateway-Dyjy_JwI.mjs.map +1 -0
  82. package/dist/apigateway-zHDoMwlI.cjs +370 -0
  83. package/dist/apigateway-zHDoMwlI.cjs.map +1 -0
  84. package/dist/auth-BqWz2JxC.d.cts.map +1 -1
  85. package/dist/auth-DnB9H9KL.d.mts.map +1 -1
  86. package/dist/auth.cjs +7 -21
  87. package/dist/auth.cjs.map +1 -1
  88. package/dist/auth.mjs +6 -20
  89. package/dist/auth.mjs.map +1 -1
  90. package/dist/{cache-e3tfMQ9g.d.mts → cache-CCHcO9Oo.d.mts} +2 -2
  91. package/dist/cache-CCHcO9Oo.d.mts.map +1 -0
  92. package/dist/cache-CQjMNPrC.d.cts.map +1 -1
  93. package/dist/cache.cjs +3 -19
  94. package/dist/cache.cjs.map +1 -1
  95. package/dist/cache.d.mts +1 -1
  96. package/dist/cache.mjs +2 -18
  97. package/dist/cache.mjs.map +1 -1
  98. package/dist/crons/index.cjs +4 -3
  99. package/dist/crons/index.cjs.map +1 -1
  100. package/dist/crons/index.d.cts.map +1 -1
  101. package/dist/crons/index.d.mts +2 -2
  102. package/dist/crons/index.d.mts.map +1 -1
  103. package/dist/crons/index.mjs +4 -3
  104. package/dist/crons/index.mjs.map +1 -1
  105. package/dist/database/kysely.cjs +1 -1
  106. package/dist/database/kysely.d.mts +1 -1
  107. package/dist/email.cjs +4 -16
  108. package/dist/email.cjs.map +1 -1
  109. package/dist/email.d.cts.map +1 -1
  110. package/dist/email.d.mts.map +1 -1
  111. package/dist/email.mjs +2 -14
  112. package/dist/email.mjs.map +1 -1
  113. package/dist/endpoints/index.cjs +4 -4
  114. package/dist/endpoints/index.d.cts +1 -1
  115. package/dist/endpoints/index.d.cts.map +1 -1
  116. package/dist/endpoints/index.d.mts +4 -4
  117. package/dist/endpoints/index.d.mts.map +1 -1
  118. package/dist/endpoints/index.mjs +4 -4
  119. package/dist/file-server.cjs +1 -1
  120. package/dist/file-server.d.mts +1 -1
  121. package/dist/file-server.mjs +1 -1
  122. package/dist/functions/index.cjs +1 -1
  123. package/dist/functions/index.d.mts +2 -2
  124. package/dist/functions/index.mjs +1 -1
  125. package/dist/{functions-BvIDQKAA.mjs → functions-BF039DT8.mjs} +2 -2
  126. package/dist/{functions-BvIDQKAA.mjs.map → functions-BF039DT8.mjs.map} +1 -1
  127. package/dist/{functions-DLF6-IK8.cjs → functions-BqAq_0xQ.cjs} +3 -3
  128. package/dist/{functions-DLF6-IK8.cjs.map → functions-BqAq_0xQ.cjs.map} +1 -1
  129. package/dist/{inbox-CjxpLVkH.d.mts → inbox-YOdxlyfj.d.mts} +2 -2
  130. package/dist/{inbox-CjxpLVkH.d.mts.map → inbox-YOdxlyfj.d.mts.map} +1 -1
  131. package/dist/inbox.cjs +1 -1
  132. package/dist/inbox.d.mts +1 -1
  133. package/dist/inbox.mjs +1 -1
  134. package/dist/{index-DCkDQkwj.d.mts → index-BoQ3-M-K.d.mts} +4 -4
  135. package/dist/{index-DCkDQkwj.d.mts.map → index-BoQ3-M-K.d.mts.map} +1 -1
  136. package/dist/index.cjs +1 -1
  137. package/dist/index.d.mts +1 -1
  138. package/dist/index.mjs +1 -1
  139. package/dist/{kysely-CukArHJ0.cjs → kysely-CeoQdAkg.cjs} +2 -2
  140. package/dist/{kysely-CukArHJ0.cjs.map → kysely-CeoQdAkg.cjs.map} +1 -1
  141. package/dist/{kysely-DE4kADWD.d.mts → kysely-De5rAC-E.d.mts} +2 -2
  142. package/dist/{kysely-DE4kADWD.d.mts.map → kysely-De5rAC-E.d.mts.map} +1 -1
  143. package/dist/optionalPeers-D7Wt6dnF.mjs +140 -0
  144. package/dist/optionalPeers-D7Wt6dnF.mjs.map +1 -0
  145. package/dist/optionalPeers-DuNQXXe1.cjs +223 -0
  146. package/dist/optionalPeers-DuNQXXe1.cjs.map +1 -0
  147. package/dist/origins-C7T9covD.cjs +24 -0
  148. package/dist/origins-C7T9covD.cjs.map +1 -0
  149. package/dist/origins-CX6Ot7ax.mjs +19 -0
  150. package/dist/origins-CX6Ot7ax.mjs.map +1 -0
  151. package/dist/{pattern-QFaUIr77.cjs → pattern-HnNOPhE2.cjs} +2 -2
  152. package/dist/{pattern-QFaUIr77.cjs.map → pattern-HnNOPhE2.cjs.map} +1 -1
  153. package/dist/{pattern-C1CEcglD.mjs → pattern-YSqfAhXm.mjs} +2 -2
  154. package/dist/{pattern-C1CEcglD.mjs.map → pattern-YSqfAhXm.mjs.map} +1 -1
  155. package/dist/privateAddress-Bg5fUsbp.mjs +21 -0
  156. package/dist/privateAddress-Bg5fUsbp.mjs.map +1 -0
  157. package/dist/privateAddress-CqGyuFHn.cjs +26 -0
  158. package/dist/privateAddress-CqGyuFHn.cjs.map +1 -0
  159. package/dist/processors/index.cjs +1 -1
  160. package/dist/processors/index.d.mts +1 -1
  161. package/dist/processors/index.mjs +1 -1
  162. package/dist/queue/index.cjs +2 -2
  163. package/dist/queue/index.d.mts +2 -2
  164. package/dist/queue/index.mjs +2 -2
  165. package/dist/{readRequestBody-BTIl3k-D.mjs → readRequestBody-BmKnPl0a.mjs} +26 -4
  166. package/dist/readRequestBody-BmKnPl0a.mjs.map +1 -0
  167. package/dist/{readRequestBody-Dej_L3c4.cjs → readRequestBody-CN9GVdeE.cjs} +26 -4
  168. package/dist/readRequestBody-CN9GVdeE.cjs.map +1 -0
  169. package/dist/{requestLogger-BZcXwdBs.cjs → requestLogger-CnoYd-Ah.cjs} +4 -63
  170. package/dist/requestLogger-CnoYd-Ah.cjs.map +1 -0
  171. package/dist/{requestLogger-pA4gi3E1.mjs → requestLogger-D2JS7pPM.mjs} +3 -56
  172. package/dist/requestLogger-D2JS7pPM.mjs.map +1 -0
  173. package/dist/rest-api.cjs +1 -1
  174. package/dist/rest-api.d.mts +2 -2
  175. package/dist/rest-api.mjs +1 -1
  176. package/dist/{rolldown-runtime-y5ARvAq5.cjs → rolldown-runtime-Ctb5zv51.cjs} +15 -0
  177. package/dist/{runSubscriber-DyHWp_Lf.mjs → runSubscriber-HEqXkin1.mjs} +3 -2
  178. package/dist/runSubscriber-HEqXkin1.mjs.map +1 -0
  179. package/dist/{runSubscriber-CC_2C9F2.cjs → runSubscriber-sVJfLA0-.cjs} +3 -2
  180. package/dist/runSubscriber-sVJfLA0-.cjs.map +1 -0
  181. package/dist/subscribers/index.cjs +6 -6
  182. package/dist/subscribers/index.cjs.map +1 -1
  183. package/dist/subscribers/index.d.cts +1 -1
  184. package/dist/subscribers/index.d.mts +3 -3
  185. package/dist/subscribers/index.mjs +3 -3
  186. package/dist/subscribers/index.mjs.map +1 -1
  187. package/dist/topic/index.cjs +1 -1
  188. package/dist/topic/index.d.mts +1 -1
  189. package/dist/topic/index.mjs +1 -1
  190. package/dist/websocket-api-BvKS9x-l.mjs +1711 -0
  191. package/dist/websocket-api-BvKS9x-l.mjs.map +1 -0
  192. package/dist/websocket-api-C3dWKNxO.d.cts +1181 -0
  193. package/dist/websocket-api-C3dWKNxO.d.cts.map +1 -0
  194. package/dist/websocket-api-CAQA_QOE.cjs +1890 -0
  195. package/dist/websocket-api-CAQA_QOE.cjs.map +1 -0
  196. package/dist/websocket-api-CDAxOTQZ.d.mts +1181 -0
  197. package/dist/websocket-api-CDAxOTQZ.d.mts.map +1 -0
  198. package/dist/websocket-api.cjs +31 -1121
  199. package/dist/websocket-api.d.cts +2 -699
  200. package/dist/websocket-api.d.mts +2 -699
  201. package/dist/websocket-api.mjs +2 -1102
  202. package/dist/worker.cjs +4 -4
  203. package/dist/worker.d.mts +9 -9
  204. package/dist/worker.mjs +4 -4
  205. package/package.json +41 -31
  206. package/dist/HonoEndpointAdaptor-BXBdb2Bt.cjs.map +0 -1
  207. package/dist/HonoEndpointAdaptor-DR3j7S35.mjs.map +0 -1
  208. package/dist/SubscriberBuilder-BL_GTcwh.mjs.map +0 -1
  209. package/dist/SubscriberBuilder-CWzKwX1p.cjs.map +0 -1
  210. package/dist/cache-e3tfMQ9g.d.mts.map +0 -1
  211. package/dist/readRequestBody-BTIl3k-D.mjs.map +0 -1
  212. package/dist/readRequestBody-Dej_L3c4.cjs.map +0 -1
  213. package/dist/requestLogger-BZcXwdBs.cjs.map +0 -1
  214. package/dist/requestLogger-pA4gi3E1.mjs.map +0 -1
  215. package/dist/runSubscriber-CC_2C9F2.cjs.map +0 -1
  216. package/dist/runSubscriber-DyHWp_Lf.mjs.map +0 -1
  217. package/dist/websocket-api.cjs.map +0 -1
  218. package/dist/websocket-api.d.cts.map +0 -1
  219. package/dist/websocket-api.d.mts.map +0 -1
  220. package/dist/websocket-api.mjs.map +0 -1
@@ -0,0 +1,223 @@
1
+ //#region src/optionalPeers.ts
2
+ /**
3
+ * The optional peers a construct needs only for a feature it opted into.
4
+ *
5
+ * `@geekmidas/audit`, `@geekmidas/rate-limit`, `@geekmidas/db`,
6
+ * `@geekmidas/cache`, `@geekmidas/emailkit`, `@geekmidas/storage`, `hono`,
7
+ * `ws`, `ioredis` and `better-auth` are optional peers of this package: an app
8
+ * that audits nothing, limits nothing, sends no mail and serves no WebSocket
9
+ * need not install them. Entries that every app loads (`./endpoints`,
10
+ * `./crons`, `./worker`, `./testing`, the CLI's discovery) used to import them
11
+ * at the top, so loading any of them needed them all — and a production bundle
12
+ * of an app without them failed to build. They are loaded here instead, when
13
+ * the construct that uses one runs, which is also when the app declaring that
14
+ * construct has installed it.
15
+ *
16
+ * The `try` around each `import()` is load-bearing beyond the error it names:
17
+ * a bundler leaves an import it cannot resolve to run time when the import is
18
+ * guarded, and fails the build when it is not. `scripts/check-optional-peers.mjs`
19
+ * holds every entry to that: an optional peer is reached from its own adaptor
20
+ * subpath, or through a guarded `import()` like these.
21
+ */
22
+ /** A construct uses a feature whose optional peer is not installed. */
23
+ var OptionalPeerMissing = class extends Error {
24
+ packageName;
25
+ feature;
26
+ constructor(packageName, feature, cause) {
27
+ super(`${feature} needs '${packageName}', which could not be loaded. Add it to the dependencies of the app that declares it.`, { cause });
28
+ this.packageName = packageName;
29
+ this.feature = feature;
30
+ this.name = "OptionalPeerMissing";
31
+ }
32
+ };
33
+ /** `@geekmidas/audit`, for an endpoint, function or cron with an auditor. */
34
+ async function loadAudit() {
35
+ try {
36
+ return await import("@geekmidas/audit");
37
+ } catch (cause) {
38
+ throw new OptionalPeerMissing("@geekmidas/audit", "An auditor", cause);
39
+ }
40
+ }
41
+ /** `@geekmidas/audit/kysely`, for audits written in the handler's transaction. */
42
+ async function loadAuditKysely() {
43
+ try {
44
+ return await import("@geekmidas/audit/kysely");
45
+ } catch (cause) {
46
+ throw new OptionalPeerMissing("@geekmidas/audit", "An auditor that stores in the database", cause);
47
+ }
48
+ }
49
+ /** `@geekmidas/rate-limit`, for an endpoint with a rate limit. */
50
+ async function loadRateLimit() {
51
+ try {
52
+ return await import("@geekmidas/rate-limit");
53
+ } catch (cause) {
54
+ throw new OptionalPeerMissing("@geekmidas/rate-limit", "An endpoint with a rate limit", cause);
55
+ }
56
+ }
57
+ /** `@geekmidas/db/rls`, for an endpoint with row-level security. */
58
+ async function loadRls() {
59
+ try {
60
+ return await import("@geekmidas/db/rls");
61
+ } catch (cause) {
62
+ throw new OptionalPeerMissing("@geekmidas/db", "An endpoint with row-level security", cause);
63
+ }
64
+ }
65
+ /** `@geekmidas/cache`, for a `Cache` construct's client. */
66
+ async function loadCache() {
67
+ try {
68
+ return await import("@geekmidas/cache");
69
+ } catch (cause) {
70
+ throw new OptionalPeerMissing("@geekmidas/cache", "A Cache", cause);
71
+ }
72
+ }
73
+ /** `@geekmidas/emailkit`, for an `Email` construct's client. */
74
+ async function loadEmailkit() {
75
+ try {
76
+ return await import("@geekmidas/emailkit");
77
+ } catch (cause) {
78
+ throw new OptionalPeerMissing("@geekmidas/emailkit", "An Email", cause);
79
+ }
80
+ }
81
+ /** `@geekmidas/storage/events`, for a subscriber to a bucket's objects. */
82
+ async function loadStorageEvents() {
83
+ try {
84
+ return await import("@geekmidas/storage/events");
85
+ } catch (cause) {
86
+ throw new OptionalPeerMissing("@geekmidas/storage", "A subscriber to a bucket's objects", cause);
87
+ }
88
+ }
89
+ /** `hono`, for a surface that serves HTTP itself. */
90
+ async function loadHono(feature) {
91
+ try {
92
+ return await import("hono");
93
+ } catch (cause) {
94
+ throw new OptionalPeerMissing("hono", feature, cause);
95
+ }
96
+ }
97
+ /** `hono/cors`, beside {@link loadHono}. */
98
+ async function loadHonoCors(feature) {
99
+ try {
100
+ return await import("hono/cors");
101
+ } catch (cause) {
102
+ throw new OptionalPeerMissing("hono", feature, cause);
103
+ }
104
+ }
105
+ /** `ws`, for a `WebSocketApi`'s server. */
106
+ async function loadWs() {
107
+ try {
108
+ return await import("ws");
109
+ } catch (cause) {
110
+ throw new OptionalPeerMissing("ws", "A WebSocketApi", cause);
111
+ }
112
+ }
113
+ /** `ioredis`, for a `WebSocketApi` that fans out through Redis. */
114
+ async function loadIoredis() {
115
+ try {
116
+ return await import("ioredis");
117
+ } catch (cause) {
118
+ throw new OptionalPeerMissing("ioredis", "A WebSocketApi with a redis:// transport", cause);
119
+ }
120
+ }
121
+ /** `better-auth`, for an `Auth` construct's server. */
122
+ async function loadBetterAuth() {
123
+ try {
124
+ return await import("better-auth");
125
+ } catch (cause) {
126
+ throw new OptionalPeerMissing("better-auth", "An Auth", cause);
127
+ }
128
+ }
129
+ /** `better-auth/db/migration`, for migrating an `Auth` construct's tables. */
130
+ async function loadBetterAuthMigration() {
131
+ try {
132
+ return await import("better-auth/db/migration");
133
+ } catch (cause) {
134
+ throw new OptionalPeerMissing("better-auth", "An Auth", cause);
135
+ }
136
+ }
137
+ //#endregion
138
+ Object.defineProperty(exports, "OptionalPeerMissing", {
139
+ enumerable: true,
140
+ get: function() {
141
+ return OptionalPeerMissing;
142
+ }
143
+ });
144
+ Object.defineProperty(exports, "loadAudit", {
145
+ enumerable: true,
146
+ get: function() {
147
+ return loadAudit;
148
+ }
149
+ });
150
+ Object.defineProperty(exports, "loadAuditKysely", {
151
+ enumerable: true,
152
+ get: function() {
153
+ return loadAuditKysely;
154
+ }
155
+ });
156
+ Object.defineProperty(exports, "loadBetterAuth", {
157
+ enumerable: true,
158
+ get: function() {
159
+ return loadBetterAuth;
160
+ }
161
+ });
162
+ Object.defineProperty(exports, "loadBetterAuthMigration", {
163
+ enumerable: true,
164
+ get: function() {
165
+ return loadBetterAuthMigration;
166
+ }
167
+ });
168
+ Object.defineProperty(exports, "loadCache", {
169
+ enumerable: true,
170
+ get: function() {
171
+ return loadCache;
172
+ }
173
+ });
174
+ Object.defineProperty(exports, "loadEmailkit", {
175
+ enumerable: true,
176
+ get: function() {
177
+ return loadEmailkit;
178
+ }
179
+ });
180
+ Object.defineProperty(exports, "loadHono", {
181
+ enumerable: true,
182
+ get: function() {
183
+ return loadHono;
184
+ }
185
+ });
186
+ Object.defineProperty(exports, "loadHonoCors", {
187
+ enumerable: true,
188
+ get: function() {
189
+ return loadHonoCors;
190
+ }
191
+ });
192
+ Object.defineProperty(exports, "loadIoredis", {
193
+ enumerable: true,
194
+ get: function() {
195
+ return loadIoredis;
196
+ }
197
+ });
198
+ Object.defineProperty(exports, "loadRateLimit", {
199
+ enumerable: true,
200
+ get: function() {
201
+ return loadRateLimit;
202
+ }
203
+ });
204
+ Object.defineProperty(exports, "loadRls", {
205
+ enumerable: true,
206
+ get: function() {
207
+ return loadRls;
208
+ }
209
+ });
210
+ Object.defineProperty(exports, "loadStorageEvents", {
211
+ enumerable: true,
212
+ get: function() {
213
+ return loadStorageEvents;
214
+ }
215
+ });
216
+ Object.defineProperty(exports, "loadWs", {
217
+ enumerable: true,
218
+ get: function() {
219
+ return loadWs;
220
+ }
221
+ });
222
+
223
+ //# sourceMappingURL=optionalPeers-DuNQXXe1.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optionalPeers-DuNQXXe1.cjs","names":[],"sources":["../src/optionalPeers.ts"],"sourcesContent":["/**\n * The optional peers a construct needs only for a feature it opted into.\n *\n * `@geekmidas/audit`, `@geekmidas/rate-limit`, `@geekmidas/db`,\n * `@geekmidas/cache`, `@geekmidas/emailkit`, `@geekmidas/storage`, `hono`,\n * `ws`, `ioredis` and `better-auth` are optional peers of this package: an app\n * that audits nothing, limits nothing, sends no mail and serves no WebSocket\n * need not install them. Entries that every app loads (`./endpoints`,\n * `./crons`, `./worker`, `./testing`, the CLI's discovery) used to import them\n * at the top, so loading any of them needed them all — and a production bundle\n * of an app without them failed to build. They are loaded here instead, when\n * the construct that uses one runs, which is also when the app declaring that\n * construct has installed it.\n *\n * The `try` around each `import()` is load-bearing beyond the error it names:\n * a bundler leaves an import it cannot resolve to run time when the import is\n * guarded, and fails the build when it is not. `scripts/check-optional-peers.mjs`\n * holds every entry to that: an optional peer is reached from its own adaptor\n * subpath, or through a guarded `import()` like these.\n */\n\n/** A construct uses a feature whose optional peer is not installed. */\nexport class OptionalPeerMissing extends Error {\n\tconstructor(\n\t\treadonly packageName: string,\n\t\treadonly feature: string,\n\t\tcause: unknown,\n\t) {\n\t\tsuper(\n\t\t\t`${feature} needs '${packageName}', which could not be loaded. ` +\n\t\t\t\t`Add it to the dependencies of the app that declares it.`,\n\t\t\t{ cause },\n\t\t);\n\t\tthis.name = 'OptionalPeerMissing';\n\t}\n}\n\n/** `@geekmidas/audit`, for an endpoint, function or cron with an auditor. */\nexport async function loadAudit(): Promise<typeof import('@geekmidas/audit')> {\n\ttry {\n\t\treturn await import('@geekmidas/audit');\n\t} catch (cause) {\n\t\tthrow new OptionalPeerMissing('@geekmidas/audit', 'An auditor', cause);\n\t}\n}\n\n/** `@geekmidas/audit/kysely`, for audits written in the handler's transaction. */\nexport async function loadAuditKysely(): Promise<\n\ttypeof import('@geekmidas/audit/kysely')\n> {\n\ttry {\n\t\treturn await import('@geekmidas/audit/kysely');\n\t} catch (cause) {\n\t\tthrow new OptionalPeerMissing(\n\t\t\t'@geekmidas/audit',\n\t\t\t'An auditor that stores in the database',\n\t\t\tcause,\n\t\t);\n\t}\n}\n\n/** `@geekmidas/rate-limit`, for an endpoint with a rate limit. */\nexport async function loadRateLimit(): Promise<\n\ttypeof import('@geekmidas/rate-limit')\n> {\n\ttry {\n\t\treturn await import('@geekmidas/rate-limit');\n\t} catch (cause) {\n\t\tthrow new OptionalPeerMissing(\n\t\t\t'@geekmidas/rate-limit',\n\t\t\t'An endpoint with a rate limit',\n\t\t\tcause,\n\t\t);\n\t}\n}\n\n/** `@geekmidas/db/rls`, for an endpoint with row-level security. */\nexport async function loadRls(): Promise<typeof import('@geekmidas/db/rls')> {\n\ttry {\n\t\treturn await import('@geekmidas/db/rls');\n\t} catch (cause) {\n\t\tthrow new OptionalPeerMissing(\n\t\t\t'@geekmidas/db',\n\t\t\t'An endpoint with row-level security',\n\t\t\tcause,\n\t\t);\n\t}\n}\n\n/** `@geekmidas/cache`, for a `Cache` construct's client. */\nexport async function loadCache(): Promise<typeof import('@geekmidas/cache')> {\n\ttry {\n\t\treturn await import('@geekmidas/cache');\n\t} catch (cause) {\n\t\tthrow new OptionalPeerMissing('@geekmidas/cache', 'A Cache', cause);\n\t}\n}\n\n/** `@geekmidas/emailkit`, for an `Email` construct's client. */\nexport async function loadEmailkit(): Promise<\n\ttypeof import('@geekmidas/emailkit')\n> {\n\ttry {\n\t\treturn await import('@geekmidas/emailkit');\n\t} catch (cause) {\n\t\tthrow new OptionalPeerMissing('@geekmidas/emailkit', 'An Email', cause);\n\t}\n}\n\n/** `@geekmidas/emailkit/autoSubmitted`, for a subscriber to an `Inbox`. */\nexport async function loadAutoSubmitted(): Promise<\n\ttypeof import('@geekmidas/emailkit/autoSubmitted')\n> {\n\ttry {\n\t\treturn await import('@geekmidas/emailkit/autoSubmitted');\n\t} catch (cause) {\n\t\tthrow new OptionalPeerMissing(\n\t\t\t'@geekmidas/emailkit',\n\t\t\t'A subscriber to an Inbox',\n\t\t\tcause,\n\t\t);\n\t}\n}\n\n/** `@geekmidas/storage/events`, for a subscriber to a bucket's objects. */\nexport async function loadStorageEvents(): Promise<\n\ttypeof import('@geekmidas/storage/events')\n> {\n\ttry {\n\t\treturn await import('@geekmidas/storage/events');\n\t} catch (cause) {\n\t\tthrow new OptionalPeerMissing(\n\t\t\t'@geekmidas/storage',\n\t\t\t\"A subscriber to a bucket's objects\",\n\t\t\tcause,\n\t\t);\n\t}\n}\n\n/** `hono`, for a surface that serves HTTP itself. */\nexport async function loadHono(\n\tfeature: string,\n): Promise<typeof import('hono')> {\n\ttry {\n\t\treturn await import('hono');\n\t} catch (cause) {\n\t\tthrow new OptionalPeerMissing('hono', feature, cause);\n\t}\n}\n\n/** `hono/cors`, beside {@link loadHono}. */\nexport async function loadHonoCors(\n\tfeature: string,\n): Promise<typeof import('hono/cors')> {\n\ttry {\n\t\treturn await import('hono/cors');\n\t} catch (cause) {\n\t\tthrow new OptionalPeerMissing('hono', feature, cause);\n\t}\n}\n\n/** `ws`, for a `WebSocketApi`'s server. */\nexport async function loadWs(): Promise<typeof import('ws')> {\n\ttry {\n\t\treturn await import('ws');\n\t} catch (cause) {\n\t\tthrow new OptionalPeerMissing('ws', 'A WebSocketApi', cause);\n\t}\n}\n\n/** `ioredis`, for a `WebSocketApi` that fans out through Redis. */\nexport async function loadIoredis(): Promise<typeof import('ioredis')> {\n\ttry {\n\t\treturn await import('ioredis');\n\t} catch (cause) {\n\t\tthrow new OptionalPeerMissing(\n\t\t\t'ioredis',\n\t\t\t'A WebSocketApi with a redis:// transport',\n\t\t\tcause,\n\t\t);\n\t}\n}\n\n/** `better-auth`, for an `Auth` construct's server. */\nexport async function loadBetterAuth(): Promise<typeof import('better-auth')> {\n\ttry {\n\t\treturn await import('better-auth');\n\t} catch (cause) {\n\t\tthrow new OptionalPeerMissing('better-auth', 'An Auth', cause);\n\t}\n}\n\n/** `better-auth/db/migration`, for migrating an `Auth` construct's tables. */\nexport async function loadBetterAuthMigration(): Promise<\n\ttypeof import('better-auth/db/migration')\n> {\n\ttry {\n\t\treturn await import('better-auth/db/migration');\n\t} catch (cause) {\n\t\tthrow new OptionalPeerMissing('better-auth', 'An Auth', cause);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBA,IAAa,sBAAb,cAAyC,MAAM;CAEpC;CACA;CAFV,YACC,aACA,SACA,OACC;EACD,MACC,GAAG,QAAQ,UAAU,YAAY,wFAEjC,EAAE,MAAM,CACT;EARS,KAAA,cAAA;EACA,KAAA,UAAA;EAQT,KAAK,OAAO;CACb;AACD;;AAGA,eAAsB,YAAwD;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,oBAAoB,MAAM,kBAAkB,KAAK;CAC5D;AACD;;AAGA,eAAsB,cAAiD;CACtE,IAAI;EACH,OAAO,MAAM,OAAO;CACrB,SAAS,OAAO;EACf,MAAM,IAAI,oBACT,WACA,4CACA,KACD;CACD;AACD;;AAGA,eAAsB,iBAAwD;CAC7E,IAAI;EACH,OAAO,MAAM,OAAO;CACrB,SAAS,OAAO;EACf,MAAM,IAAI,oBAAoB,eAAe,WAAW,KAAK;CAC9D;AACD;;AAGA,eAAsB,0BAEpB;CACD,IAAI;EACH,OAAO,MAAM,OAAO;CACrB,SAAS,OAAO;EACf,MAAM,IAAI,oBAAoB,eAAe,WAAW,KAAK;CAC9D;AACD"}
@@ -0,0 +1,24 @@
1
+ //#region src/websocket/origins.ts
2
+ /**
3
+ * The origins a client of the surface's own address sends: the `https://`
4
+ * one a native socket derives from `wss://`, and the address's own.
5
+ *
6
+ * Shared by every adaptor that checks a handshake's `Origin` — the Node
7
+ * server and the API Gateway `$connect` handler — so the two trust the same
8
+ * origins for the same address.
9
+ */
10
+ function ownOrigins(url) {
11
+ if (!url || !URL.canParse(url)) return [];
12
+ const own = new URL(url);
13
+ const web = new URL(url.replace(/^ws(s?):/i, "http$1:"));
14
+ return [.../* @__PURE__ */ new Set([`${own.protocol}//${own.host}`, web.origin])];
15
+ }
16
+ //#endregion
17
+ Object.defineProperty(exports, "ownOrigins", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return ownOrigins;
21
+ }
22
+ });
23
+
24
+ //# sourceMappingURL=origins-C7T9covD.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"origins-C7T9covD.cjs","names":[],"sources":["../src/websocket/origins.ts"],"sourcesContent":["/**\n * The origins a client of the surface's own address sends: the `https://`\n * one a native socket derives from `wss://`, and the address's own.\n *\n * Shared by every adaptor that checks a handshake's `Origin` — the Node\n * server and the API Gateway `$connect` handler — so the two trust the same\n * origins for the same address.\n */\nexport function ownOrigins(url: string | undefined): string[] {\n\tif (!url || !URL.canParse(url)) return [];\n\tconst own = new URL(url);\n\tconst web = new URL(url.replace(/^ws(s?):/i, 'http$1:'));\n\treturn [...new Set([`${own.protocol}//${own.host}`, web.origin])];\n}\n"],"mappings":";;;;;;;;;AAQA,SAAgB,WAAW,KAAmC;CAC7D,IAAI,CAAC,OAAO,CAAC,IAAI,SAAS,GAAG,GAAG,OAAO,CAAC;CACxC,MAAM,MAAM,IAAI,IAAI,GAAG;CACvB,MAAM,MAAM,IAAI,IAAI,IAAI,QAAQ,aAAa,SAAS,CAAC;CACvD,OAAO,CAAC,mBAAG,IAAI,IAAI,CAAC,GAAG,IAAI,SAAS,IAAI,IAAI,QAAQ,IAAI,MAAM,CAAC,CAAC;AACjE"}
@@ -0,0 +1,19 @@
1
+ //#region src/websocket/origins.ts
2
+ /**
3
+ * The origins a client of the surface's own address sends: the `https://`
4
+ * one a native socket derives from `wss://`, and the address's own.
5
+ *
6
+ * Shared by every adaptor that checks a handshake's `Origin` — the Node
7
+ * server and the API Gateway `$connect` handler — so the two trust the same
8
+ * origins for the same address.
9
+ */
10
+ function ownOrigins(url) {
11
+ if (!url || !URL.canParse(url)) return [];
12
+ const own = new URL(url);
13
+ const web = new URL(url.replace(/^ws(s?):/i, "http$1:"));
14
+ return [.../* @__PURE__ */ new Set([`${own.protocol}//${own.host}`, web.origin])];
15
+ }
16
+ //#endregion
17
+ export { ownOrigins as t };
18
+
19
+ //# sourceMappingURL=origins-CX6Ot7ax.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"origins-CX6Ot7ax.mjs","names":[],"sources":["../src/websocket/origins.ts"],"sourcesContent":["/**\n * The origins a client of the surface's own address sends: the `https://`\n * one a native socket derives from `wss://`, and the address's own.\n *\n * Shared by every adaptor that checks a handshake's `Origin` — the Node\n * server and the API Gateway `$connect` handler — so the two trust the same\n * origins for the same address.\n */\nexport function ownOrigins(url: string | undefined): string[] {\n\tif (!url || !URL.canParse(url)) return [];\n\tconst own = new URL(url);\n\tconst web = new URL(url.replace(/^ws(s?):/i, 'http$1:'));\n\treturn [...new Set([`${own.protocol}//${own.host}`, web.origin])];\n}\n"],"mappings":";;;;;;;;;AAQA,SAAgB,WAAW,KAAmC;CAC7D,IAAI,CAAC,OAAO,CAAC,IAAI,SAAS,GAAG,GAAG,OAAO,CAAC;CACxC,MAAM,MAAM,IAAI,IAAI,GAAG;CACvB,MAAM,MAAM,IAAI,IAAI,IAAI,QAAQ,aAAa,SAAS,CAAC;CACvD,OAAO,CAAC,mBAAG,IAAI,IAAI,CAAC,GAAG,IAAI,SAAS,IAAI,IAAI,QAAQ,IAAI,MAAM,CAAC,CAAC;AACjE"}
@@ -1,4 +1,4 @@
1
- const require_Construct = require("./Construct-DorKS0Ua.cjs");
1
+ const require_Construct = require("./Construct-B8yWxGlR.cjs");
2
2
  const require_construct_interface = require("./construct-interface.cjs");
3
3
  require("@geekmidas/manifest");
4
4
  //#region src/processors/Processor.ts
@@ -285,4 +285,4 @@ Object.defineProperty(exports, "parsePattern", {
285
285
  }
286
286
  });
287
287
 
288
- //# sourceMappingURL=pattern-QFaUIr77.cjs.map
288
+ //# sourceMappingURL=pattern-HnNOPhE2.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"pattern-QFaUIr77.cjs","names":["Construct","servicesOf","idsOf"],"sources":["../src/processors/Processor.ts","../src/processors/ProcessorBuilder.ts","../src/processors/pattern.ts"],"sourcesContent":["import type { Logger } from '@geekmidas/logger';\nimport type { InferStandardSchema } from '@geekmidas/schema';\nimport type { Service, ServiceRecord } from '@geekmidas/services';\nimport type { StorageClient } from '@geekmidas/storage';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { Construct, ConstructType } from '../Construct';\nimport type { ParsedPattern, PatternParams } from './pattern';\n\n/**\n * Where a processor's results are kept, under its file server's bucket.\n *\n * Written through on every result marked `immutable` and read before the\n * handler runs, so a derivative is made once. Exported so the bucket's expiry\n * can name it.\n */\nexport { DERIVED_PREFIX } from '@geekmidas/manifest';\n\n/** How long a response may be kept, by a browser and by the edge. */\nexport type ProcessorCache =\n\t/** Never changes for these parameters and this key: kept for a year. */\n\t| 'immutable'\n\t/** Kept this many seconds. */\n\t| { maxAge: number }\n\t/** Not kept. */\n\t| 'none';\n\n/** What a processor handler returns. */\nexport interface ProcessorResult {\n\tbody: Uint8Array | string;\n\tcontentType: string;\n\t/**\n\t * `immutable` results are also kept in the bucket, so the next request\n\t * for them never runs the handler. Defaults to an hour, kept nowhere.\n\t */\n\tcache?: ProcessorCache;\n}\n\n/** The object a request addresses, read from the bucket on first use. */\nexport interface SourceObject {\n\treadonly key: string;\n\tbytes(): Promise<Uint8Array>;\n\tstream(): Promise<ReadableStream<Uint8Array>>;\n\t/** The type it was stored with. */\n\tcontentType(): Promise<string | undefined>;\n}\n\nexport interface ProcessorContext<\n\tTParams,\n\tTServices extends Service[],\n\tTLogger extends Logger,\n> {\n\tparams: TParams;\n\tkey: string;\n\tobject: SourceObject;\n\tlogger: TLogger;\n\tservices: ServiceRecord<TServices>;\n}\n\nexport type ProcessorHandler<\n\tTParams,\n\tTServices extends Service[],\n\tTLogger extends Logger,\n> = (\n\tcontext: ProcessorContext<TParams, TServices, TLogger>,\n) => Promise<ProcessorResult> | ProcessorResult;\n\n/** What a processor's parameters parse to: its schema's output, or the raw strings. */\nexport type ProcessorParams<\n\tTPattern extends string,\n\tTSchema extends StandardSchemaV1 | undefined,\n> = TSchema extends StandardSchemaV1\n\t? InferStandardSchema<TSchema>\n\t: PatternParams<TPattern>;\n\n/**\n * A processor — a handler behind one path pattern of a file server, which\n * makes a derivative of an open object on read: a thumbnail, a page of a PDF.\n *\n * Built from the file server (`assets.process('/i/:width/*')`), so it carries\n * the bucket it reads and the open paths it may serve. Its parameters' schema\n * is the allowlist: a request outside it is refused before anything runs, so\n * nobody can mint new work — or new cache entries — by varying a number.\n */\nexport class Processor<\n\tTPattern extends string = string,\n\tTSchema extends StandardSchemaV1 | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> extends Construct<TLogger, undefined, TServices> {\n\t__IS_PROCESSOR__ = true;\n\n\tstatic isProcessor(obj: unknown): obj is Processor<string, any, any, any> {\n\t\treturn Boolean(\n\t\t\tobj &&\n\t\t\t\t(obj as { __IS_PROCESSOR__?: boolean }).__IS_PROCESSOR__ === true &&\n\t\t\t\t(obj as Construct).type === ConstructType.Processor,\n\t\t);\n\t}\n\n\tconstructor(\n\t\treadonly parsed: ParsedPattern,\n\t\treadonly handler: ProcessorHandler<\n\t\t\tProcessorParams<TPattern, TSchema>,\n\t\t\tTServices,\n\t\t\tTLogger\n\t\t>,\n\t\treadonly options: {\n\t\t\t/** The file server's surface id — the unit that runs it. */\n\t\t\tsurfaceId: string;\n\t\t\t/** The bucket it reads from and keeps derivatives in. */\n\t\t\tbucketId: string;\n\t\t\t/** How it reaches that bucket. */\n\t\t\torigin: Service<string, StorageClient>;\n\t\t\t/** Whether a key is one of the file server's open paths. */\n\t\t\tserves: (key: string) => boolean;\n\t\t\tparamsSchema?: TSchema;\n\t\t\t/** Packages with native code, installed for the target. */\n\t\t\tnative: readonly string[];\n\t\t\tlogger: TLogger;\n\t\t\tservices: TServices;\n\t\t\tconstructs: string[];\n\t\t\ttimeout?: number;\n\t\t\tmemorySize?: number;\n\t\t},\n\t) {\n\t\tsuper(\n\t\t\tConstructType.Processor,\n\t\t\toptions.logger,\n\t\t\t// The bucket is reached like any service — which is also how its URL\n\t\t\t// is found by the environment sniffer.\n\t\t\t[options.origin, ...options.services] as unknown as TServices,\n\t\t\t[],\n\t\t\tundefined,\n\t\t\toptions.timeout,\n\t\t\toptions.memorySize,\n\t\t\tundefined,\n\t\t\t// The bucket is an edge of its process, so the unit running it is\n\t\t\t// handed the bucket's address.\n\t\t\t[...new Set([options.bucketId, ...options.constructs])],\n\t\t);\n\t\tthis.owner = options.surfaceId;\n\t}\n\n\t/** The pattern it answers, as written. */\n\tget pattern(): TPattern {\n\t\treturn this.parsed.pattern as TPattern;\n\t}\n\n\t/** The literal path the edge routes to it — `/i/`. */\n\tget prefix(): string {\n\t\treturn this.parsed.prefix;\n\t}\n\n\tget native(): readonly string[] {\n\t\treturn this.options.native;\n\t}\n\n\tget surfaceId(): string {\n\t\treturn this.options.surfaceId;\n\t}\n\n\tget bucketId(): string {\n\t\treturn this.options.bucketId;\n\t}\n}\n","import type { Logger } from '@geekmidas/logger';\nimport type { Service } from '@geekmidas/services';\nimport type { StorageClient } from '@geekmidas/storage';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport {\n\ttype Consumable,\n\tidsOf,\n\ttype ServicesOf,\n\tservicesOf,\n} from '../construct-interface';\nimport {\n\tProcessor,\n\ttype ProcessorHandler,\n\ttype ProcessorParams,\n} from './Processor';\nimport type { ParsedPattern } from './pattern';\n\n/** A native package named in a way no installer could resolve. */\nexport class ProcessorNativeInvalid extends Error {\n\tconstructor(readonly packageName: string) {\n\t\tsuper(\n\t\t\t`'${packageName}' is not a package name. Name the package with native code ` +\n\t\t\t\t`as it is installed — 'sharp', '@napi-rs/canvas' — and its version ` +\n\t\t\t\t`is taken from the app's package.json.`,\n\t\t);\n\t\tthis.name = 'ProcessorNativeInvalid';\n\t}\n}\n\ninterface ProcessorBuilderState<TLogger extends Logger> {\n\tparsed: ParsedPattern;\n\tsurfaceId: string;\n\tbucketId: string;\n\torigin: Service<string, StorageClient>;\n\tserves: (key: string) => boolean;\n\tlogger: TLogger;\n\tparamsSchema?: StandardSchemaV1;\n\tnative: string[];\n\tservices: Service[];\n\tconstructs: string[];\n\ttimeout?: number;\n\tmemorySize?: number;\n}\n\n/**\n * What `fileServer.process(pattern)` returns: a processor, built up one\n * immutable step at a time and finished by `.handle()`.\n */\nexport class ProcessorBuilder<\n\tTPattern extends string,\n\tTSchema extends StandardSchemaV1 | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> {\n\tconstructor(private readonly state: ProcessorBuilderState<TLogger>) {}\n\n\t/**\n\t * The parameters' schema — the allowlist. Every request is parsed by it\n\t * before anything runs, and one it refuses is answered 400.\n\t */\n\tparams<T extends StandardSchemaV1>(\n\t\tschema: T,\n\t): ProcessorBuilder<TPattern, T, TServices, TLogger> {\n\t\treturn new ProcessorBuilder({ ...this.state, paramsSchema: schema });\n\t}\n\n\t/** Constructs its handler reaches, as `services.<id>`. */\n\tdependsOn<const T extends readonly Consumable[]>(\n\t\tconstructs: T,\n\t): ProcessorBuilder<\n\t\tTPattern,\n\t\tTSchema,\n\t\t[...TServices, ...ServicesOf<T>],\n\t\tTLogger\n\t> {\n\t\tconst services = servicesOf(constructs) as unknown as Service[];\n\t\treturn new ProcessorBuilder({\n\t\t\t...this.state,\n\t\t\tservices: [\n\t\t\t\t...this.state.services.filter(\n\t\t\t\t\t(service) =>\n\t\t\t\t\t\t!services.some((s) => s.serviceName === service.serviceName),\n\t\t\t\t),\n\t\t\t\t...services,\n\t\t\t],\n\t\t\tconstructs: idsOf(constructs, this.state.constructs),\n\t\t});\n\t}\n\n\t/**\n\t * Packages with native code — `sharp` — installed for the target the\n\t * processor runs on rather than bundled: linux in its image, arm64 on\n\t * Lambda.\n\t */\n\tnative(packages: readonly string[]): this {\n\t\tfor (const name of packages) {\n\t\t\tif (!/^(@[a-z0-9._~-]+\\/)?[a-z0-9._~-]+$/.test(name)) {\n\t\t\t\tthrow new ProcessorNativeInvalid(name);\n\t\t\t}\n\t\t}\n\t\treturn new ProcessorBuilder({\n\t\t\t...this.state,\n\t\t\tnative: [...new Set([...this.state.native, ...packages])],\n\t\t}) as this;\n\t}\n\n\t/** Milliseconds a request may take, where the target bounds it. */\n\ttimeout(ms: number): this {\n\t\treturn new ProcessorBuilder({ ...this.state, timeout: ms }) as this;\n\t}\n\n\t/** Megabytes of memory, where the target sets it. */\n\tmemorySize(mb: number): this {\n\t\treturn new ProcessorBuilder({ ...this.state, memorySize: mb }) as this;\n\t}\n\n\thandle(\n\t\tfn: ProcessorHandler<\n\t\t\tProcessorParams<TPattern, TSchema>,\n\t\t\tTServices,\n\t\t\tTLogger\n\t\t>,\n\t): Processor<TPattern, TSchema, TServices, TLogger> {\n\t\tconst { state } = this;\n\t\treturn new Processor<TPattern, TSchema, TServices, TLogger>(\n\t\t\tstate.parsed,\n\t\t\tfn,\n\t\t\t{\n\t\t\t\tsurfaceId: state.surfaceId,\n\t\t\t\tbucketId: state.bucketId,\n\t\t\t\torigin: state.origin,\n\t\t\t\tserves: state.serves,\n\t\t\t\t...(state.paramsSchema\n\t\t\t\t\t? { paramsSchema: state.paramsSchema as TSchema }\n\t\t\t\t\t: {}),\n\t\t\t\tnative: state.native,\n\t\t\t\tlogger: state.logger,\n\t\t\t\tservices: state.services as TServices,\n\t\t\t\tconstructs: state.constructs,\n\t\t\t\t...(state.timeout !== undefined ? { timeout: state.timeout } : {}),\n\t\t\t\t...(state.memorySize !== undefined\n\t\t\t\t\t? { memorySize: state.memorySize }\n\t\t\t\t\t: {}),\n\t\t\t},\n\t\t);\n\t}\n}\n","/**\n * A processor's path pattern: literal segments, `:name` parameters, and a\n * final `*` that is the object's key.\n *\n * ```\n * /i/:width/* → /i/256/avatars/7.png { width: '256' }, 'avatars/7.png'\n * /pdf/:page/:dpi/* → /pdf/1/150/doc.pdf { page: '1', dpi: '150' }, 'doc.pdf'\n * ```\n *\n * It starts with a literal segment because the edge routes on that prefix: a\n * pattern beginning with a parameter would claim every path on the file\n * server, objects included.\n */\n\n/** The parameter names a pattern declares, as a union. */\nexport type PatternParamNames<P extends string> =\n\tP extends `${string}/:${infer Name}/${infer Rest}`\n\t\t? Name | PatternParamNames<`/${Rest}`>\n\t\t: never;\n\n/** The raw parameters a pattern matches, before its schema parses them. */\nexport type PatternParams<P extends string> = {\n\t[K in PatternParamNames<P>]: string;\n};\n\n/** A pattern a processor cannot be served on. */\nexport class ProcessorPatternInvalid extends Error {\n\tconstructor(\n\t\treadonly pattern: string,\n\t\treadonly reason: string,\n\t) {\n\t\tsuper(\n\t\t\t`'${pattern}' is not a processor pattern: ${reason}. A pattern is a ` +\n\t\t\t\t`literal first segment, then any \\`:name\\` parameters, then \\`*\\` ` +\n\t\t\t\t`for the object's key — '/i/:width/*'.`,\n\t\t);\n\t\tthis.name = 'ProcessorPatternInvalid';\n\t}\n}\n\n/** A pattern, parsed once. */\nexport interface ParsedPattern {\n\treadonly pattern: string;\n\t/** Each segment before the key: a literal, or a parameter's name. */\n\treadonly segments: readonly (\n\t\t| { kind: 'literal'; value: string }\n\t\t| { kind: 'param'; name: string }\n\t)[];\n\t/** The parameter names, in the order they appear. */\n\treadonly params: readonly string[];\n\t/** The literal path the edge routes on — `/i/`. */\n\treadonly prefix: string;\n}\n\n/** @throws {ProcessorPatternInvalid} */\nexport function parsePattern(pattern: string): ParsedPattern {\n\tif (!pattern.startsWith('/')) {\n\t\tthrow new ProcessorPatternInvalid(pattern, 'it does not start with /');\n\t}\n\tif (!pattern.endsWith('/*')) {\n\t\tthrow new ProcessorPatternInvalid(\n\t\t\tpattern,\n\t\t\t'it does not end with /* — the key',\n\t\t);\n\t}\n\n\tconst parts = pattern.slice(1, -2).split('/');\n\tconst segments: ParsedPattern['segments'][number][] = [];\n\tconst params: string[] = [];\n\tfor (const part of parts) {\n\t\tif (part === '') {\n\t\t\tthrow new ProcessorPatternInvalid(pattern, 'it has an empty segment');\n\t\t}\n\t\tif (part.includes('*')) {\n\t\t\tthrow new ProcessorPatternInvalid(\n\t\t\t\tpattern,\n\t\t\t\t'only its last segment may be *',\n\t\t\t);\n\t\t}\n\t\tif (part.startsWith(':')) {\n\t\t\tconst name = part.slice(1);\n\t\t\tif (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name)) {\n\t\t\t\tthrow new ProcessorPatternInvalid(\n\t\t\t\t\tpattern,\n\t\t\t\t\t`'${part}' is not a parameter name`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (params.includes(name)) {\n\t\t\t\tthrow new ProcessorPatternInvalid(pattern, `'${name}' appears twice`);\n\t\t\t}\n\t\t\tparams.push(name);\n\t\t\tsegments.push({ kind: 'param', name });\n\t\t\tcontinue;\n\t\t}\n\t\tif (!/^[A-Za-z0-9._~-]+$/.test(part)) {\n\t\t\tthrow new ProcessorPatternInvalid(\n\t\t\t\tpattern,\n\t\t\t\t`'${part}' has characters a path segment would escape`,\n\t\t\t);\n\t\t}\n\t\tsegments.push({ kind: 'literal', value: part });\n\t}\n\n\tconst first = segments[0];\n\tif (!first || first.kind !== 'literal') {\n\t\tthrow new ProcessorPatternInvalid(\n\t\t\tpattern,\n\t\t\t'its first segment is a parameter, which would claim every path',\n\t\t);\n\t}\n\n\tconst literals: string[] = [];\n\tfor (const segment of segments) {\n\t\tif (segment.kind !== 'literal') break;\n\t\tliterals.push(segment.value);\n\t}\n\n\treturn { pattern, segments, params, prefix: `/${literals.join('/')}/` };\n}\n\n/** A path the pattern matched: its raw parameters and the key. */\nexport interface PatternMatch {\n\tparams: Record<string, string>;\n\tkey: string;\n}\n\n/**\n * Match a request path, decoding each parameter and each key segment. A path\n * with an empty key, or one that decodes to a `..` segment, matches nothing.\n */\nexport function matchPattern(\n\tparsed: ParsedPattern,\n\tpath: string,\n): PatternMatch | undefined {\n\tconst parts = path.replace(/^\\/+/, '').split('/');\n\tif (parts.length <= parsed.segments.length) return undefined;\n\n\tconst params: Record<string, string> = {};\n\tfor (const [index, segment] of parsed.segments.entries()) {\n\t\tconst part = decode(parts[index] ?? '');\n\t\tif (part === undefined || part === '') return undefined;\n\t\tif (segment.kind === 'literal') {\n\t\t\tif (part !== segment.value) return undefined;\n\t\t\tcontinue;\n\t\t}\n\t\tparams[segment.name] = part;\n\t}\n\n\tconst keyParts = parts.slice(parsed.segments.length).map(decode);\n\tif (keyParts.some((part) => part === undefined || part === '..')) {\n\t\treturn undefined;\n\t}\n\tconst key = keyParts.join('/');\n\tif (key === '' || keyParts.includes('')) return undefined;\n\n\treturn { params, key };\n}\n\n/** The path that addresses `key` through the pattern with these parameters. */\nexport function fillPattern(\n\tparsed: ParsedPattern,\n\tparams: Readonly<Record<string, string | number>>,\n\tkey: string,\n): string {\n\tconst head = parsed.segments.map((segment) => {\n\t\tif (segment.kind === 'literal') return segment.value;\n\t\tconst value = params[segment.name];\n\t\tif (value === undefined || `${value}` === '') {\n\t\t\tthrow new ProcessorParamMissing(parsed.pattern, segment.name);\n\t\t}\n\t\treturn encodeURIComponent(`${value}`);\n\t});\n\tconst tail = key\n\t\t.replace(/^\\/+/, '')\n\t\t.split('/')\n\t\t.map((part) => encodeURIComponent(part));\n\n\treturn `/${[...head, ...tail].join('/')}`;\n}\n\n/** A processed URL was asked for without one of the pattern's parameters. */\nexport class ProcessorParamMissing extends Error {\n\tconstructor(\n\t\treadonly pattern: string,\n\t\treadonly param: string,\n\t) {\n\t\tsuper(\n\t\t\t`'${pattern}' needs '${param}' to address an object, and it was not given.`,\n\t\t);\n\t\tthis.name = 'ProcessorParamMissing';\n\t}\n}\n\nfunction decode(part: string): string | undefined {\n\ttry {\n\t\treturn decodeURIComponent(part);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AAmFA,IAAa,YAAb,cAKUA,kBAAAA,UAAyC;CAYxC;CACA;CAKA;CAjBV,mBAAmB;CAEnB,OAAO,YAAY,KAAuD;EACzE,OAAO,QACN,OACE,IAAuC,qBAAqB,QAC5D,IAAkB,SAAA,kCACrB;CACD;CAEA,YACC,QACA,SAKA,SAkBC;EACD,MAAA,oCAEC,QAAQ,QAGR,CAAC,QAAQ,QAAQ,GAAG,QAAQ,QAAQ,GACpC,CAAC,GACD,KAAA,GACA,QAAQ,SACR,QAAQ,YACR,KAAA,GAGA,CAAC,mBAAG,IAAI,IAAI,CAAC,QAAQ,UAAU,GAAG,QAAQ,UAAU,CAAC,CAAC,CACvD;EAvCS,KAAA,SAAA;EACA,KAAA,UAAA;EAKA,KAAA,UAAA;EAkCT,KAAK,QAAQ,QAAQ;CACtB;;CAGA,IAAI,UAAoB;EACvB,OAAO,KAAK,OAAO;CACpB;;CAGA,IAAI,SAAiB;EACpB,O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SAAS,MAAM,SAAS,SAAS,KAAA,KAAa,SAAS,IAAI,GAC9D;CAED,MAAM,MAAM,SAAS,KAAK,GAAG;CAC7B,IAAI,QAAQ,MAAM,SAAS,SAAS,EAAE,GAAG,OAAO,KAAA;CAEhD,OAAO;EAAE;EAAQ;CAAI;AACtB;;AAGA,SAAgB,YACf,QACA,QACA,KACS;CACT,MAAM,OAAO,OAAO,SAAS,KAAK,YAAY;EAC7C,IAAI,QAAQ,SAAS,WAAW,OAAO,QAAQ;EAC/C,MAAM,QAAQ,OAAO,QAAQ;EAC7B,IAAI,UAAU,KAAA,KAAa,GAAG,YAAY,IACzC,MAAM,IAAI,sBAAsB,OAAO,SAAS,QAAQ,IAAI;EAE7D,OAAO,mBAAmB,GAAG,OAAO;CACrC,CAAC;CACD,MAAM,OAAO,IACX,QAAQ,QAAQ,EAAE,CAAC,CACnB,MAAM,GAAG,CAAC,CACV,KAAK,SAAS,mBAAmB,IAAI,CAAC;CAExC,OAAO,IAAI,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC,CAAC,KAAK,GAAG;AACvC;;AAGA,IAAa,wBAAb,cAA2C,MAAM;CAEtC;CACA;CAFV,YACC,SACA,OACC;EACD,MACC,IAAI,QAAQ,WAAW,MAAM,8CAC9B;EALS,KAAA,UAAA;EACA,KAAA,QAAA;EAKT,KAAK,OAAO;CACb;AACD;AAEA,SAAS,OAAO,MAAkC;CACjD,IAAI;EACH,OAAO,mBAAmB,IAAI;CAC/B,QAAQ;EACP;CACD;AACD"}
1
+ {"version":3,"file":"pattern-HnNOPhE2.cjs","names":["Construct","servicesOf","idsOf"],"sources":["../src/processors/Processor.ts","../src/processors/ProcessorBuilder.ts","../src/processors/pattern.ts"],"sourcesContent":["import type { Logger } from '@geekmidas/logger';\nimport type { InferStandardSchema } from '@geekmidas/schema';\nimport type { Service, ServiceRecord } from '@geekmidas/services';\nimport type { StorageClient } from '@geekmidas/storage';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { Construct, ConstructType } from '../Construct';\nimport type { ParsedPattern, PatternParams } from './pattern';\n\n/**\n * Where a processor's results are kept, under its file server's bucket.\n *\n * Written through on every result marked `immutable` and read before the\n * handler runs, so a derivative is made once. Exported so the bucket's expiry\n * can name it.\n */\nexport { DERIVED_PREFIX } from '@geekmidas/manifest';\n\n/** How long a response may be kept, by a browser and by the edge. */\nexport type ProcessorCache =\n\t/** Never changes for these parameters and this key: kept for a year. */\n\t| 'immutable'\n\t/** Kept this many seconds. */\n\t| { maxAge: number }\n\t/** Not kept. */\n\t| 'none';\n\n/** What a processor handler returns. */\nexport interface ProcessorResult {\n\tbody: Uint8Array | string;\n\tcontentType: string;\n\t/**\n\t * `immutable` results are also kept in the bucket, so the next request\n\t * for them never runs the handler. Defaults to an hour, kept nowhere.\n\t */\n\tcache?: ProcessorCache;\n}\n\n/** The object a request addresses, read from the bucket on first use. */\nexport interface SourceObject {\n\treadonly key: string;\n\tbytes(): Promise<Uint8Array>;\n\tstream(): Promise<ReadableStream<Uint8Array>>;\n\t/** The type it was stored with. */\n\tcontentType(): Promise<string | undefined>;\n}\n\nexport interface ProcessorContext<\n\tTParams,\n\tTServices extends Service[],\n\tTLogger extends Logger,\n> {\n\tparams: TParams;\n\tkey: string;\n\tobject: SourceObject;\n\tlogger: TLogger;\n\tservices: ServiceRecord<TServices>;\n}\n\nexport type ProcessorHandler<\n\tTParams,\n\tTServices extends Service[],\n\tTLogger extends Logger,\n> = (\n\tcontext: ProcessorContext<TParams, TServices, TLogger>,\n) => Promise<ProcessorResult> | ProcessorResult;\n\n/** What a processor's parameters parse to: its schema's output, or the raw strings. */\nexport type ProcessorParams<\n\tTPattern extends string,\n\tTSchema extends StandardSchemaV1 | undefined,\n> = TSchema extends StandardSchemaV1\n\t? InferStandardSchema<TSchema>\n\t: PatternParams<TPattern>;\n\n/**\n * A processor — a handler behind one path pattern of a file server, which\n * makes a derivative of an open object on read: a thumbnail, a page of a PDF.\n *\n * Built from the file server (`assets.process('/i/:width/*')`), so it carries\n * the bucket it reads and the open paths it may serve. Its parameters' schema\n * is the allowlist: a request outside it is refused before anything runs, so\n * nobody can mint new work — or new cache entries — by varying a number.\n */\nexport class Processor<\n\tTPattern extends string = string,\n\tTSchema extends StandardSchemaV1 | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> extends Construct<TLogger, undefined, TServices> {\n\t__IS_PROCESSOR__ = true;\n\n\tstatic isProcessor(obj: unknown): obj is Processor<string, any, any, any> {\n\t\treturn Boolean(\n\t\t\tobj &&\n\t\t\t\t(obj as { __IS_PROCESSOR__?: boolean }).__IS_PROCESSOR__ === true &&\n\t\t\t\t(obj as Construct).type === ConstructType.Processor,\n\t\t);\n\t}\n\n\tconstructor(\n\t\treadonly parsed: ParsedPattern,\n\t\treadonly handler: ProcessorHandler<\n\t\t\tProcessorParams<TPattern, TSchema>,\n\t\t\tTServices,\n\t\t\tTLogger\n\t\t>,\n\t\treadonly options: {\n\t\t\t/** The file server's surface id — the unit that runs it. */\n\t\t\tsurfaceId: string;\n\t\t\t/** The bucket it reads from and keeps derivatives in. */\n\t\t\tbucketId: string;\n\t\t\t/** How it reaches that bucket. */\n\t\t\torigin: Service<string, StorageClient>;\n\t\t\t/** Whether a key is one of the file server's open paths. */\n\t\t\tserves: (key: string) => boolean;\n\t\t\tparamsSchema?: TSchema;\n\t\t\t/** Packages with native code, installed for the target. */\n\t\t\tnative: readonly string[];\n\t\t\tlogger: TLogger;\n\t\t\tservices: TServices;\n\t\t\tconstructs: string[];\n\t\t\ttimeout?: number;\n\t\t\tmemorySize?: number;\n\t\t},\n\t) {\n\t\tsuper(\n\t\t\tConstructType.Processor,\n\t\t\toptions.logger,\n\t\t\t// The bucket is reached like any service — which is also how its URL\n\t\t\t// is found by the environment sniffer.\n\t\t\t[options.origin, ...options.services] as unknown as TServices,\n\t\t\t[],\n\t\t\tundefined,\n\t\t\toptions.timeout,\n\t\t\toptions.memorySize,\n\t\t\tundefined,\n\t\t\t// The bucket is an edge of its process, so the unit running it is\n\t\t\t// handed the bucket's address.\n\t\t\t[...new Set([options.bucketId, ...options.constructs])],\n\t\t);\n\t\tthis.owner = options.surfaceId;\n\t}\n\n\t/** The pattern it answers, as written. */\n\tget pattern(): TPattern {\n\t\treturn this.parsed.pattern as TPattern;\n\t}\n\n\t/** The literal path the edge routes to it — `/i/`. */\n\tget prefix(): string {\n\t\treturn this.parsed.prefix;\n\t}\n\n\tget native(): readonly string[] {\n\t\treturn this.options.native;\n\t}\n\n\tget surfaceId(): string {\n\t\treturn this.options.surfaceId;\n\t}\n\n\tget bucketId(): string {\n\t\treturn this.options.bucketId;\n\t}\n}\n","import type { Logger } from '@geekmidas/logger';\nimport type { Service } from '@geekmidas/services';\nimport type { StorageClient } from '@geekmidas/storage';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport {\n\ttype Consumable,\n\tidsOf,\n\ttype ServicesOf,\n\tservicesOf,\n} from '../construct-interface';\nimport {\n\tProcessor,\n\ttype ProcessorHandler,\n\ttype ProcessorParams,\n} from './Processor';\nimport type { ParsedPattern } from './pattern';\n\n/** A native package named in a way no installer could resolve. */\nexport class ProcessorNativeInvalid extends Error {\n\tconstructor(readonly packageName: string) {\n\t\tsuper(\n\t\t\t`'${packageName}' is not a package name. Name the package with native code ` +\n\t\t\t\t`as it is installed — 'sharp', '@napi-rs/canvas' — and its version ` +\n\t\t\t\t`is taken from the app's package.json.`,\n\t\t);\n\t\tthis.name = 'ProcessorNativeInvalid';\n\t}\n}\n\ninterface ProcessorBuilderState<TLogger extends Logger> {\n\tparsed: ParsedPattern;\n\tsurfaceId: string;\n\tbucketId: string;\n\torigin: Service<string, StorageClient>;\n\tserves: (key: string) => boolean;\n\tlogger: TLogger;\n\tparamsSchema?: StandardSchemaV1;\n\tnative: string[];\n\tservices: Service[];\n\tconstructs: string[];\n\ttimeout?: number;\n\tmemorySize?: number;\n}\n\n/**\n * What `fileServer.process(pattern)` returns: a processor, built up one\n * immutable step at a time and finished by `.handle()`.\n */\nexport class ProcessorBuilder<\n\tTPattern extends string,\n\tTSchema extends StandardSchemaV1 | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> {\n\tconstructor(private readonly state: ProcessorBuilderState<TLogger>) {}\n\n\t/**\n\t * The parameters' schema — the allowlist. Every request is parsed by it\n\t * before anything runs, and one it refuses is answered 400.\n\t */\n\tparams<T extends StandardSchemaV1>(\n\t\tschema: T,\n\t): ProcessorBuilder<TPattern, T, TServices, TLogger> {\n\t\treturn new ProcessorBuilder({ ...this.state, paramsSchema: schema });\n\t}\n\n\t/** Constructs its handler reaches, as `services.<id>`. */\n\tdependsOn<const T extends readonly Consumable[]>(\n\t\tconstructs: T,\n\t): ProcessorBuilder<\n\t\tTPattern,\n\t\tTSchema,\n\t\t[...TServices, ...ServicesOf<T>],\n\t\tTLogger\n\t> {\n\t\tconst services = servicesOf(constructs) as unknown as Service[];\n\t\treturn new ProcessorBuilder({\n\t\t\t...this.state,\n\t\t\tservices: [\n\t\t\t\t...this.state.services.filter(\n\t\t\t\t\t(service) =>\n\t\t\t\t\t\t!services.some((s) => s.serviceName === service.serviceName),\n\t\t\t\t),\n\t\t\t\t...services,\n\t\t\t],\n\t\t\tconstructs: idsOf(constructs, this.state.constructs),\n\t\t});\n\t}\n\n\t/**\n\t * Packages with native code — `sharp` — installed for the target the\n\t * processor runs on rather than bundled: linux in its image, arm64 on\n\t * Lambda.\n\t */\n\tnative(packages: readonly string[]): this {\n\t\tfor (const name of packages) {\n\t\t\tif (!/^(@[a-z0-9._~-]+\\/)?[a-z0-9._~-]+$/.test(name)) {\n\t\t\t\tthrow new ProcessorNativeInvalid(name);\n\t\t\t}\n\t\t}\n\t\treturn new ProcessorBuilder({\n\t\t\t...this.state,\n\t\t\tnative: [...new Set([...this.state.native, ...packages])],\n\t\t}) as this;\n\t}\n\n\t/** Milliseconds a request may take, where the target bounds it. */\n\ttimeout(ms: number): this {\n\t\treturn new ProcessorBuilder({ ...this.state, timeout: ms }) as this;\n\t}\n\n\t/** Megabytes of memory, where the target sets it. */\n\tmemorySize(mb: number): this {\n\t\treturn new ProcessorBuilder({ ...this.state, memorySize: mb }) as this;\n\t}\n\n\thandle(\n\t\tfn: ProcessorHandler<\n\t\t\tProcessorParams<TPattern, TSchema>,\n\t\t\tTServices,\n\t\t\tTLogger\n\t\t>,\n\t): Processor<TPattern, TSchema, TServices, TLogger> {\n\t\tconst { state } = this;\n\t\treturn new Processor<TPattern, TSchema, TServices, TLogger>(\n\t\t\tstate.parsed,\n\t\t\tfn,\n\t\t\t{\n\t\t\t\tsurfaceId: state.surfaceId,\n\t\t\t\tbucketId: state.bucketId,\n\t\t\t\torigin: state.origin,\n\t\t\t\tserves: state.serves,\n\t\t\t\t...(state.paramsSchema\n\t\t\t\t\t? { paramsSchema: state.paramsSchema as TSchema }\n\t\t\t\t\t: {}),\n\t\t\t\tnative: state.native,\n\t\t\t\tlogger: state.logger,\n\t\t\t\tservices: state.services as TServices,\n\t\t\t\tconstructs: state.constructs,\n\t\t\t\t...(state.timeout !== undefined ? { timeout: state.timeout } : {}),\n\t\t\t\t...(state.memorySize !== undefined\n\t\t\t\t\t? { memorySize: state.memorySize }\n\t\t\t\t\t: {}),\n\t\t\t},\n\t\t);\n\t}\n}\n","/**\n * A processor's path pattern: literal segments, `:name` parameters, and a\n * final `*` that is the object's key.\n *\n * ```\n * /i/:width/* → /i/256/avatars/7.png { width: '256' }, 'avatars/7.png'\n * /pdf/:page/:dpi/* → /pdf/1/150/doc.pdf { page: '1', dpi: '150' }, 'doc.pdf'\n * ```\n *\n * It starts with a literal segment because the edge routes on that prefix: a\n * pattern beginning with a parameter would claim every path on the file\n * server, objects included.\n */\n\n/** The parameter names a pattern declares, as a union. */\nexport type PatternParamNames<P extends string> =\n\tP extends `${string}/:${infer Name}/${infer Rest}`\n\t\t? Name | PatternParamNames<`/${Rest}`>\n\t\t: never;\n\n/** The raw parameters a pattern matches, before its schema parses them. */\nexport type PatternParams<P extends string> = {\n\t[K in PatternParamNames<P>]: string;\n};\n\n/** A pattern a processor cannot be served on. */\nexport class ProcessorPatternInvalid extends Error {\n\tconstructor(\n\t\treadonly pattern: string,\n\t\treadonly reason: string,\n\t) {\n\t\tsuper(\n\t\t\t`'${pattern}' is not a processor pattern: ${reason}. A pattern is a ` +\n\t\t\t\t`literal first segment, then any \\`:name\\` parameters, then \\`*\\` ` +\n\t\t\t\t`for the object's key — '/i/:width/*'.`,\n\t\t);\n\t\tthis.name = 'ProcessorPatternInvalid';\n\t}\n}\n\n/** A pattern, parsed once. */\nexport interface ParsedPattern {\n\treadonly pattern: string;\n\t/** Each segment before the key: a literal, or a parameter's name. */\n\treadonly segments: readonly (\n\t\t| { kind: 'literal'; value: string }\n\t\t| { kind: 'param'; name: string }\n\t)[];\n\t/** The parameter names, in the order they appear. */\n\treadonly params: readonly string[];\n\t/** The literal path the edge routes on — `/i/`. */\n\treadonly prefix: string;\n}\n\n/** @throws {ProcessorPatternInvalid} */\nexport function parsePattern(pattern: string): ParsedPattern {\n\tif (!pattern.startsWith('/')) {\n\t\tthrow new ProcessorPatternInvalid(pattern, 'it does not start with /');\n\t}\n\tif (!pattern.endsWith('/*')) {\n\t\tthrow new ProcessorPatternInvalid(\n\t\t\tpattern,\n\t\t\t'it does not end with /* — the key',\n\t\t);\n\t}\n\n\tconst parts = pattern.slice(1, -2).split('/');\n\tconst segments: ParsedPattern['segments'][number][] = [];\n\tconst params: string[] = [];\n\tfor (const part of parts) {\n\t\tif (part === '') {\n\t\t\tthrow new ProcessorPatternInvalid(pattern, 'it has an empty segment');\n\t\t}\n\t\tif (part.includes('*')) {\n\t\t\tthrow new ProcessorPatternInvalid(\n\t\t\t\tpattern,\n\t\t\t\t'only its last segment may be *',\n\t\t\t);\n\t\t}\n\t\tif (part.startsWith(':')) {\n\t\t\tconst name = part.slice(1);\n\t\t\tif (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name)) {\n\t\t\t\tthrow new ProcessorPatternInvalid(\n\t\t\t\t\tpattern,\n\t\t\t\t\t`'${part}' is not a parameter name`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (params.includes(name)) {\n\t\t\t\tthrow new ProcessorPatternInvalid(pattern, `'${name}' appears twice`);\n\t\t\t}\n\t\t\tparams.push(name);\n\t\t\tsegments.push({ kind: 'param', name });\n\t\t\tcontinue;\n\t\t}\n\t\tif (!/^[A-Za-z0-9._~-]+$/.test(part)) {\n\t\t\tthrow new ProcessorPatternInvalid(\n\t\t\t\tpattern,\n\t\t\t\t`'${part}' has characters a path segment would escape`,\n\t\t\t);\n\t\t}\n\t\tsegments.push({ kind: 'literal', value: part });\n\t}\n\n\tconst first = segments[0];\n\tif (!first || first.kind !== 'literal') {\n\t\tthrow new ProcessorPatternInvalid(\n\t\t\tpattern,\n\t\t\t'its first segment is a parameter, which would claim every path',\n\t\t);\n\t}\n\n\tconst literals: string[] = [];\n\tfor (const segment of segments) {\n\t\tif (segment.kind !== 'literal') break;\n\t\tliterals.push(segment.value);\n\t}\n\n\treturn { pattern, segments, params, prefix: `/${literals.join('/')}/` };\n}\n\n/** A path the pattern matched: its raw parameters and the key. */\nexport interface PatternMatch {\n\tparams: Record<string, string>;\n\tkey: string;\n}\n\n/**\n * Match a request path, decoding each parameter and each key segment. A path\n * with an empty key, or one that decodes to a `..` segment, matches nothing.\n */\nexport function matchPattern(\n\tparsed: ParsedPattern,\n\tpath: string,\n): PatternMatch | undefined {\n\tconst parts = path.replace(/^\\/+/, '').split('/');\n\tif (parts.length <= parsed.segments.length) return undefined;\n\n\tconst params: Record<string, string> = {};\n\tfor (const [index, segment] of parsed.segments.entries()) {\n\t\tconst part = decode(parts[index] ?? '');\n\t\tif (part === undefined || part === '') return undefined;\n\t\tif (segment.kind === 'literal') {\n\t\t\tif (part !== segment.value) return undefined;\n\t\t\tcontinue;\n\t\t}\n\t\tparams[segment.name] = part;\n\t}\n\n\tconst keyParts = parts.slice(parsed.segments.length).map(decode);\n\tif (keyParts.some((part) => part === undefined || part === '..')) {\n\t\treturn undefined;\n\t}\n\tconst key = keyParts.join('/');\n\tif (key === '' || keyParts.includes('')) return undefined;\n\n\treturn { params, key };\n}\n\n/** The path that addresses `key` through the pattern with these parameters. */\nexport function fillPattern(\n\tparsed: ParsedPattern,\n\tparams: Readonly<Record<string, string | number>>,\n\tkey: string,\n): string {\n\tconst head = parsed.segments.map((segment) => {\n\t\tif (segment.kind === 'literal') return segment.value;\n\t\tconst value = params[segment.name];\n\t\tif (value === undefined || `${value}` === '') {\n\t\t\tthrow new ProcessorParamMissing(parsed.pattern, segment.name);\n\t\t}\n\t\treturn encodeURIComponent(`${value}`);\n\t});\n\tconst tail = key\n\t\t.replace(/^\\/+/, '')\n\t\t.split('/')\n\t\t.map((part) => encodeURIComponent(part));\n\n\treturn `/${[...head, ...tail].join('/')}`;\n}\n\n/** A processed URL was asked for without one of the pattern's parameters. */\nexport class ProcessorParamMissing extends Error {\n\tconstructor(\n\t\treadonly pattern: string,\n\t\treadonly param: string,\n\t) {\n\t\tsuper(\n\t\t\t`'${pattern}' needs '${param}' to address an object, and it was not given.`,\n\t\t);\n\t\tthis.name = 'ProcessorParamMissing';\n\t}\n}\n\nfunction decode(part: string): string | undefined {\n\ttry {\n\t\treturn decodeURIComponent(part);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AAmFA,IAAa,YAAb,cAKUA,kBAAAA,UAAyC;CAYxC;CACA;CAKA;CAjBV,mBAAmB;CAEnB,OAAO,YAAY,KAAuD;EACzE,OAAO,QACN,OACE,IAAuC,qBAAqB,QAC5D,IAAkB,SAAA,kCACrB;CACD;CAEA,YACC,QACA,SAKA,SAkBC;EACD,MAAA,oCAEC,QAAQ,QAGR,CAAC,QAAQ,QAAQ,GAAG,QAAQ,QAAQ,GACpC,CAAC,GACD,KAAA,GACA,QAAQ,SACR,QAAQ,YACR,KAAA,GAGA,CAAC,mBAAG,IAAI,IAAI,CAAC,QAAQ,UAA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N2U.mjs";
2
2
  import { idsOf, servicesOf } from "./construct-interface.mjs";
3
3
  import { DERIVED_PREFIX as DERIVED_PREFIX$1 } from "@geekmidas/manifest";
4
4
  //#region src/processors/Processor.ts
@@ -238,4 +238,4 @@ function decode(part) {
238
238
  //#endregion
239
239
  export { parsePattern as a, DERIVED_PREFIX$1 as c, matchPattern as i, Processor as l, ProcessorPatternInvalid as n, ProcessorBuilder as o, fillPattern as r, ProcessorNativeInvalid as s, ProcessorParamMissing as t };
240
240
 
241
- //# sourceMappingURL=pattern-C1CEcglD.mjs.map
241
+ //# sourceMappingURL=pattern-YSqfAhXm.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"pattern-C1CEcglD.mjs","names":[],"sources":["../src/processors/Processor.ts","../src/processors/ProcessorBuilder.ts","../src/processors/pattern.ts"],"sourcesContent":["import type { Logger } from '@geekmidas/logger';\nimport type { InferStandardSchema } from '@geekmidas/schema';\nimport type { Service, ServiceRecord } from '@geekmidas/services';\nimport type { StorageClient } from '@geekmidas/storage';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { Construct, ConstructType } from '../Construct';\nimport type { ParsedPattern, PatternParams } from './pattern';\n\n/**\n * Where a processor's results are kept, under its file server's bucket.\n *\n * Written through on every result marked `immutable` and read before the\n * handler runs, so a derivative is made once. Exported so the bucket's expiry\n * can name it.\n */\nexport { DERIVED_PREFIX } from '@geekmidas/manifest';\n\n/** How long a response may be kept, by a browser and by the edge. */\nexport type ProcessorCache =\n\t/** Never changes for these parameters and this key: kept for a year. */\n\t| 'immutable'\n\t/** Kept this many seconds. */\n\t| { maxAge: number }\n\t/** Not kept. */\n\t| 'none';\n\n/** What a processor handler returns. */\nexport interface ProcessorResult {\n\tbody: Uint8Array | string;\n\tcontentType: string;\n\t/**\n\t * `immutable` results are also kept in the bucket, so the next request\n\t * for them never runs the handler. Defaults to an hour, kept nowhere.\n\t */\n\tcache?: ProcessorCache;\n}\n\n/** The object a request addresses, read from the bucket on first use. */\nexport interface SourceObject {\n\treadonly key: string;\n\tbytes(): Promise<Uint8Array>;\n\tstream(): Promise<ReadableStream<Uint8Array>>;\n\t/** The type it was stored with. */\n\tcontentType(): Promise<string | undefined>;\n}\n\nexport interface ProcessorContext<\n\tTParams,\n\tTServices extends Service[],\n\tTLogger extends Logger,\n> {\n\tparams: TParams;\n\tkey: string;\n\tobject: SourceObject;\n\tlogger: TLogger;\n\tservices: ServiceRecord<TServices>;\n}\n\nexport type ProcessorHandler<\n\tTParams,\n\tTServices extends Service[],\n\tTLogger extends Logger,\n> = (\n\tcontext: ProcessorContext<TParams, TServices, TLogger>,\n) => Promise<ProcessorResult> | ProcessorResult;\n\n/** What a processor's parameters parse to: its schema's output, or the raw strings. */\nexport type ProcessorParams<\n\tTPattern extends string,\n\tTSchema extends StandardSchemaV1 | undefined,\n> = TSchema extends StandardSchemaV1\n\t? InferStandardSchema<TSchema>\n\t: PatternParams<TPattern>;\n\n/**\n * A processor — a handler behind one path pattern of a file server, which\n * makes a derivative of an open object on read: a thumbnail, a page of a PDF.\n *\n * Built from the file server (`assets.process('/i/:width/*')`), so it carries\n * the bucket it reads and the open paths it may serve. Its parameters' schema\n * is the allowlist: a request outside it is refused before anything runs, so\n * nobody can mint new work — or new cache entries — by varying a number.\n */\nexport class Processor<\n\tTPattern extends string = string,\n\tTSchema extends StandardSchemaV1 | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> extends Construct<TLogger, undefined, TServices> {\n\t__IS_PROCESSOR__ = true;\n\n\tstatic isProcessor(obj: unknown): obj is Processor<string, any, any, any> {\n\t\treturn Boolean(\n\t\t\tobj &&\n\t\t\t\t(obj as { __IS_PROCESSOR__?: boolean }).__IS_PROCESSOR__ === true &&\n\t\t\t\t(obj as Construct).type === ConstructType.Processor,\n\t\t);\n\t}\n\n\tconstructor(\n\t\treadonly parsed: ParsedPattern,\n\t\treadonly handler: ProcessorHandler<\n\t\t\tProcessorParams<TPattern, TSchema>,\n\t\t\tTServices,\n\t\t\tTLogger\n\t\t>,\n\t\treadonly options: {\n\t\t\t/** The file server's surface id — the unit that runs it. */\n\t\t\tsurfaceId: string;\n\t\t\t/** The bucket it reads from and keeps derivatives in. */\n\t\t\tbucketId: string;\n\t\t\t/** How it reaches that bucket. */\n\t\t\torigin: Service<string, StorageClient>;\n\t\t\t/** Whether a key is one of the file server's open paths. */\n\t\t\tserves: (key: string) => boolean;\n\t\t\tparamsSchema?: TSchema;\n\t\t\t/** Packages with native code, installed for the target. */\n\t\t\tnative: readonly string[];\n\t\t\tlogger: TLogger;\n\t\t\tservices: TServices;\n\t\t\tconstructs: string[];\n\t\t\ttimeout?: number;\n\t\t\tmemorySize?: number;\n\t\t},\n\t) {\n\t\tsuper(\n\t\t\tConstructType.Processor,\n\t\t\toptions.logger,\n\t\t\t// The bucket is reached like any service — which is also how its URL\n\t\t\t// is found by the environment sniffer.\n\t\t\t[options.origin, ...options.services] as unknown as TServices,\n\t\t\t[],\n\t\t\tundefined,\n\t\t\toptions.timeout,\n\t\t\toptions.memorySize,\n\t\t\tundefined,\n\t\t\t// The bucket is an edge of its process, so the unit running it is\n\t\t\t// handed the bucket's address.\n\t\t\t[...new Set([options.bucketId, ...options.constructs])],\n\t\t);\n\t\tthis.owner = options.surfaceId;\n\t}\n\n\t/** The pattern it answers, as written. */\n\tget pattern(): TPattern {\n\t\treturn this.parsed.pattern as TPattern;\n\t}\n\n\t/** The literal path the edge routes to it — `/i/`. */\n\tget prefix(): string {\n\t\treturn this.parsed.prefix;\n\t}\n\n\tget native(): readonly string[] {\n\t\treturn this.options.native;\n\t}\n\n\tget surfaceId(): string {\n\t\treturn this.options.surfaceId;\n\t}\n\n\tget bucketId(): string {\n\t\treturn this.options.bucketId;\n\t}\n}\n","import type { Logger } from '@geekmidas/logger';\nimport type { Service } from '@geekmidas/services';\nimport type { StorageClient } from '@geekmidas/storage';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport {\n\ttype Consumable,\n\tidsOf,\n\ttype ServicesOf,\n\tservicesOf,\n} from '../construct-interface';\nimport {\n\tProcessor,\n\ttype ProcessorHandler,\n\ttype ProcessorParams,\n} from './Processor';\nimport type { ParsedPattern } from './pattern';\n\n/** A native package named in a way no installer could resolve. */\nexport class ProcessorNativeInvalid extends Error {\n\tconstructor(readonly packageName: string) {\n\t\tsuper(\n\t\t\t`'${packageName}' is not a package name. Name the package with native code ` +\n\t\t\t\t`as it is installed — 'sharp', '@napi-rs/canvas' — and its version ` +\n\t\t\t\t`is taken from the app's package.json.`,\n\t\t);\n\t\tthis.name = 'ProcessorNativeInvalid';\n\t}\n}\n\ninterface ProcessorBuilderState<TLogger extends Logger> {\n\tparsed: ParsedPattern;\n\tsurfaceId: string;\n\tbucketId: string;\n\torigin: Service<string, StorageClient>;\n\tserves: (key: string) => boolean;\n\tlogger: TLogger;\n\tparamsSchema?: StandardSchemaV1;\n\tnative: string[];\n\tservices: Service[];\n\tconstructs: string[];\n\ttimeout?: number;\n\tmemorySize?: number;\n}\n\n/**\n * What `fileServer.process(pattern)` returns: a processor, built up one\n * immutable step at a time and finished by `.handle()`.\n */\nexport class ProcessorBuilder<\n\tTPattern extends string,\n\tTSchema extends StandardSchemaV1 | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> {\n\tconstructor(private readonly state: ProcessorBuilderState<TLogger>) {}\n\n\t/**\n\t * The parameters' schema — the allowlist. Every request is parsed by it\n\t * before anything runs, and one it refuses is answered 400.\n\t */\n\tparams<T extends StandardSchemaV1>(\n\t\tschema: T,\n\t): ProcessorBuilder<TPattern, T, TServices, TLogger> {\n\t\treturn new ProcessorBuilder({ ...this.state, paramsSchema: schema });\n\t}\n\n\t/** Constructs its handler reaches, as `services.<id>`. */\n\tdependsOn<const T extends readonly Consumable[]>(\n\t\tconstructs: T,\n\t): ProcessorBuilder<\n\t\tTPattern,\n\t\tTSchema,\n\t\t[...TServices, ...ServicesOf<T>],\n\t\tTLogger\n\t> {\n\t\tconst services = servicesOf(constructs) as unknown as Service[];\n\t\treturn new ProcessorBuilder({\n\t\t\t...this.state,\n\t\t\tservices: [\n\t\t\t\t...this.state.services.filter(\n\t\t\t\t\t(service) =>\n\t\t\t\t\t\t!services.some((s) => s.serviceName === service.serviceName),\n\t\t\t\t),\n\t\t\t\t...services,\n\t\t\t],\n\t\t\tconstructs: idsOf(constructs, this.state.constructs),\n\t\t});\n\t}\n\n\t/**\n\t * Packages with native code — `sharp` — installed for the target the\n\t * processor runs on rather than bundled: linux in its image, arm64 on\n\t * Lambda.\n\t */\n\tnative(packages: readonly string[]): this {\n\t\tfor (const name of packages) {\n\t\t\tif (!/^(@[a-z0-9._~-]+\\/)?[a-z0-9._~-]+$/.test(name)) {\n\t\t\t\tthrow new ProcessorNativeInvalid(name);\n\t\t\t}\n\t\t}\n\t\treturn new ProcessorBuilder({\n\t\t\t...this.state,\n\t\t\tnative: [...new Set([...this.state.native, ...packages])],\n\t\t}) as this;\n\t}\n\n\t/** Milliseconds a request may take, where the target bounds it. */\n\ttimeout(ms: number): this {\n\t\treturn new ProcessorBuilder({ ...this.state, timeout: ms }) as this;\n\t}\n\n\t/** Megabytes of memory, where the target sets it. */\n\tmemorySize(mb: number): this {\n\t\treturn new ProcessorBuilder({ ...this.state, memorySize: mb }) as this;\n\t}\n\n\thandle(\n\t\tfn: ProcessorHandler<\n\t\t\tProcessorParams<TPattern, TSchema>,\n\t\t\tTServices,\n\t\t\tTLogger\n\t\t>,\n\t): Processor<TPattern, TSchema, TServices, TLogger> {\n\t\tconst { state } = this;\n\t\treturn new Processor<TPattern, TSchema, TServices, TLogger>(\n\t\t\tstate.parsed,\n\t\t\tfn,\n\t\t\t{\n\t\t\t\tsurfaceId: state.surfaceId,\n\t\t\t\tbucketId: state.bucketId,\n\t\t\t\torigin: state.origin,\n\t\t\t\tserves: state.serves,\n\t\t\t\t...(state.paramsSchema\n\t\t\t\t\t? { paramsSchema: state.paramsSchema as TSchema }\n\t\t\t\t\t: {}),\n\t\t\t\tnative: state.native,\n\t\t\t\tlogger: state.logger,\n\t\t\t\tservices: state.services as TServices,\n\t\t\t\tconstructs: state.constructs,\n\t\t\t\t...(state.timeout !== undefined ? { timeout: state.timeout } : {}),\n\t\t\t\t...(state.memorySize !== undefined\n\t\t\t\t\t? { memorySize: state.memorySize }\n\t\t\t\t\t: {}),\n\t\t\t},\n\t\t);\n\t}\n}\n","/**\n * A processor's path pattern: literal segments, `:name` parameters, and a\n * final `*` that is the object's key.\n *\n * ```\n * /i/:width/* → /i/256/avatars/7.png { width: '256' }, 'avatars/7.png'\n * /pdf/:page/:dpi/* → /pdf/1/150/doc.pdf { page: '1', dpi: '150' }, 'doc.pdf'\n * ```\n *\n * It starts with a literal segment because the edge routes on that prefix: a\n * pattern beginning with a parameter would claim every path on the file\n * server, objects included.\n */\n\n/** The parameter names a pattern declares, as a union. */\nexport type PatternParamNames<P extends string> =\n\tP extends `${string}/:${infer Name}/${infer Rest}`\n\t\t? Name | PatternParamNames<`/${Rest}`>\n\t\t: never;\n\n/** The raw parameters a pattern matches, before its schema parses them. */\nexport type PatternParams<P extends string> = {\n\t[K in PatternParamNames<P>]: string;\n};\n\n/** A pattern a processor cannot be served on. */\nexport class ProcessorPatternInvalid extends Error {\n\tconstructor(\n\t\treadonly pattern: string,\n\t\treadonly reason: string,\n\t) {\n\t\tsuper(\n\t\t\t`'${pattern}' is not a processor pattern: ${reason}. A pattern is a ` +\n\t\t\t\t`literal first segment, then any \\`:name\\` parameters, then \\`*\\` ` +\n\t\t\t\t`for the object's key — '/i/:width/*'.`,\n\t\t);\n\t\tthis.name = 'ProcessorPatternInvalid';\n\t}\n}\n\n/** A pattern, parsed once. */\nexport interface ParsedPattern {\n\treadonly pattern: string;\n\t/** Each segment before the key: a literal, or a parameter's name. */\n\treadonly segments: readonly (\n\t\t| { kind: 'literal'; value: string }\n\t\t| { kind: 'param'; name: string }\n\t)[];\n\t/** The parameter names, in the order they appear. */\n\treadonly params: readonly string[];\n\t/** The literal path the edge routes on — `/i/`. */\n\treadonly prefix: string;\n}\n\n/** @throws {ProcessorPatternInvalid} */\nexport function parsePattern(pattern: string): ParsedPattern {\n\tif (!pattern.startsWith('/')) {\n\t\tthrow new ProcessorPatternInvalid(pattern, 'it does not start with /');\n\t}\n\tif (!pattern.endsWith('/*')) {\n\t\tthrow new ProcessorPatternInvalid(\n\t\t\tpattern,\n\t\t\t'it does not end with /* — the key',\n\t\t);\n\t}\n\n\tconst parts = pattern.slice(1, -2).split('/');\n\tconst segments: ParsedPattern['segments'][number][] = [];\n\tconst params: string[] = [];\n\tfor (const part of parts) {\n\t\tif (part === '') {\n\t\t\tthrow new ProcessorPatternInvalid(pattern, 'it has an empty segment');\n\t\t}\n\t\tif (part.includes('*')) {\n\t\t\tthrow new ProcessorPatternInvalid(\n\t\t\t\tpattern,\n\t\t\t\t'only its last segment may be *',\n\t\t\t);\n\t\t}\n\t\tif (part.startsWith(':')) {\n\t\t\tconst name = part.slice(1);\n\t\t\tif (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name)) {\n\t\t\t\tthrow new ProcessorPatternInvalid(\n\t\t\t\t\tpattern,\n\t\t\t\t\t`'${part}' is not a parameter name`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (params.includes(name)) {\n\t\t\t\tthrow new ProcessorPatternInvalid(pattern, `'${name}' appears twice`);\n\t\t\t}\n\t\t\tparams.push(name);\n\t\t\tsegments.push({ kind: 'param', name });\n\t\t\tcontinue;\n\t\t}\n\t\tif (!/^[A-Za-z0-9._~-]+$/.test(part)) {\n\t\t\tthrow new ProcessorPatternInvalid(\n\t\t\t\tpattern,\n\t\t\t\t`'${part}' has characters a path segment would escape`,\n\t\t\t);\n\t\t}\n\t\tsegments.push({ kind: 'literal', value: part });\n\t}\n\n\tconst first = segments[0];\n\tif (!first || first.kind !== 'literal') {\n\t\tthrow new ProcessorPatternInvalid(\n\t\t\tpattern,\n\t\t\t'its first segment is a parameter, which would claim every path',\n\t\t);\n\t}\n\n\tconst literals: string[] = [];\n\tfor (const segment of segments) {\n\t\tif (segment.kind !== 'literal') break;\n\t\tliterals.push(segment.value);\n\t}\n\n\treturn { pattern, segments, params, prefix: `/${literals.join('/')}/` };\n}\n\n/** A path the pattern matched: its raw parameters and the key. */\nexport interface PatternMatch {\n\tparams: Record<string, string>;\n\tkey: string;\n}\n\n/**\n * Match a request path, decoding each parameter and each key segment. A path\n * with an empty key, or one that decodes to a `..` segment, matches nothing.\n */\nexport function matchPattern(\n\tparsed: ParsedPattern,\n\tpath: string,\n): PatternMatch | undefined {\n\tconst parts = path.replace(/^\\/+/, '').split('/');\n\tif (parts.length <= parsed.segments.length) return undefined;\n\n\tconst params: Record<string, string> = {};\n\tfor (const [index, segment] of parsed.segments.entries()) {\n\t\tconst part = decode(parts[index] ?? '');\n\t\tif (part === undefined || part === '') return undefined;\n\t\tif (segment.kind === 'literal') {\n\t\t\tif (part !== segment.value) return undefined;\n\t\t\tcontinue;\n\t\t}\n\t\tparams[segment.name] = part;\n\t}\n\n\tconst keyParts = parts.slice(parsed.segments.length).map(decode);\n\tif (keyParts.some((part) => part === undefined || part === '..')) {\n\t\treturn undefined;\n\t}\n\tconst key = keyParts.join('/');\n\tif (key === '' || keyParts.includes('')) return undefined;\n\n\treturn { params, key };\n}\n\n/** The path that addresses `key` through the pattern with these parameters. */\nexport function fillPattern(\n\tparsed: ParsedPattern,\n\tparams: Readonly<Record<string, string | number>>,\n\tkey: string,\n): string {\n\tconst head = parsed.segments.map((segment) => {\n\t\tif (segment.kind === 'literal') return segment.value;\n\t\tconst value = params[segment.name];\n\t\tif (value === undefined || `${value}` === '') {\n\t\t\tthrow new ProcessorParamMissing(parsed.pattern, segment.name);\n\t\t}\n\t\treturn encodeURIComponent(`${value}`);\n\t});\n\tconst tail = key\n\t\t.replace(/^\\/+/, '')\n\t\t.split('/')\n\t\t.map((part) => encodeURIComponent(part));\n\n\treturn `/${[...head, ...tail].join('/')}`;\n}\n\n/** A processed URL was asked for without one of the pattern's parameters. */\nexport class ProcessorParamMissing extends Error {\n\tconstructor(\n\t\treadonly pattern: string,\n\t\treadonly param: string,\n\t) {\n\t\tsuper(\n\t\t\t`'${pattern}' needs '${param}' to address an object, and it was not given.`,\n\t\t);\n\t\tthis.name = 'ProcessorParamMissing';\n\t}\n}\n\nfunction decode(part: string): string | undefined {\n\ttry {\n\t\treturn decodeURIComponent(part);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AAmFA,IAAa,YAAb,cAKU,UAAyC;CAYxC;CACA;CAKA;CAjBV,mBAAmB;CAEnB,OAAO,YAAY,KAAuD;EACzE,OAAO,QACN,OACE,IAAuC,qBAAqB,QAC5D,IAAkB,SAAA,kCACrB;CACD;CAEA,YACC,QACA,SAKA,SAkBC;EACD,MAAA,oCAEC,QAAQ,QAGR,CAAC,QAAQ,QAAQ,GAAG,QAAQ,QAAQ,GACpC,CAAC,GACD,KAAA,GACA,QAAQ,SACR,QAAQ,YACR,KAAA,GAGA,CAAC,mBAAG,IAAI,IAAI,CAAC,QAAQ,UAAU,GAAG,QAAQ,UAAU,CAAC,CAAC,CACvD;EAvCS,KAAA,SAAA;EACA,KAAA,UAAA;EAKA,KAAA,UAAA;EAkCT,KAAK,QAAQ,QAAQ;CACtB;;CAGA,IAAI,UAAoB;EACvB,OAAO,KAAK,OAAO;CACpB;;CAGA,IAAI,SAAiB;EACpB,OAAO,KAAK,OAAO;CACpB;CAEA,IAAI,SAA4B;EAC/B,OAAO,KAAK,QAAQ;CACrB;CAEA,IAAI,YAAoB;EACvB,OAAO,KAAK,QAAQ;CACrB;CAEA,IAAI,WAAmB;EACtB,OAAO,KAAK,QAAQ;CACrB;AACD;;;;AClJA,IAAa,yBAAb,cAA4C,MAAM;CAC5B;CAArB,YAAY,aAA8B;EACzC,MACC,IAAI,YAAY,mKAGjB;EALoB,KAAA,cAAA;EAMpB,KAAK,OAAO;CACb;AACD;;;;;AAqBA,IAAa,mBAAb,MAAa,iBA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,GAAG,YAAY,IACzC,MAAM,IAAI,sBAAsB,OAAO,SAAS,QAAQ,IAAI;EAE7D,OAAO,mBAAmB,GAAG,OAAO;CACrC,CAAC;CACD,MAAM,OAAO,IACX,QAAQ,QAAQ,EAAE,CAAC,CACnB,MAAM,GAAG,CAAC,CACV,KAAK,SAAS,mBAAmB,IAAI,CAAC;CAExC,OAAO,IAAI,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC,CAAC,KAAK,GAAG;AACvC;;AAGA,IAAa,wBAAb,cAA2C,MAAM;CAEtC;CACA;CAFV,YACC,SACA,OACC;EACD,MACC,IAAI,QAAQ,WAAW,MAAM,8CAC9B;EALS,KAAA,UAAA;EACA,KAAA,QAAA;EAKT,KAAK,OAAO;CACb;AACD;AAEA,SAAS,OAAO,MAAkC;CACjD,IAAI;EACH,OAAO,mBAAmB,IAAI;CAC/B,QAAQ;EACP;CACD;AACD"}
1
+ {"version":3,"file":"pattern-YSqfAhXm.mjs","names":[],"sources":["../src/processors/Processor.ts","../src/processors/ProcessorBuilder.ts","../src/processors/pattern.ts"],"sourcesContent":["import type { Logger } from '@geekmidas/logger';\nimport type { InferStandardSchema } from '@geekmidas/schema';\nimport type { Service, ServiceRecord } from '@geekmidas/services';\nimport type { StorageClient } from '@geekmidas/storage';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { Construct, ConstructType } from '../Construct';\nimport type { ParsedPattern, PatternParams } from './pattern';\n\n/**\n * Where a processor's results are kept, under its file server's bucket.\n *\n * Written through on every result marked `immutable` and read before the\n * handler runs, so a derivative is made once. Exported so the bucket's expiry\n * can name it.\n */\nexport { DERIVED_PREFIX } from '@geekmidas/manifest';\n\n/** How long a response may be kept, by a browser and by the edge. */\nexport type ProcessorCache =\n\t/** Never changes for these parameters and this key: kept for a year. */\n\t| 'immutable'\n\t/** Kept this many seconds. */\n\t| { maxAge: number }\n\t/** Not kept. */\n\t| 'none';\n\n/** What a processor handler returns. */\nexport interface ProcessorResult {\n\tbody: Uint8Array | string;\n\tcontentType: string;\n\t/**\n\t * `immutable` results are also kept in the bucket, so the next request\n\t * for them never runs the handler. Defaults to an hour, kept nowhere.\n\t */\n\tcache?: ProcessorCache;\n}\n\n/** The object a request addresses, read from the bucket on first use. */\nexport interface SourceObject {\n\treadonly key: string;\n\tbytes(): Promise<Uint8Array>;\n\tstream(): Promise<ReadableStream<Uint8Array>>;\n\t/** The type it was stored with. */\n\tcontentType(): Promise<string | undefined>;\n}\n\nexport interface ProcessorContext<\n\tTParams,\n\tTServices extends Service[],\n\tTLogger extends Logger,\n> {\n\tparams: TParams;\n\tkey: string;\n\tobject: SourceObject;\n\tlogger: TLogger;\n\tservices: ServiceRecord<TServices>;\n}\n\nexport type ProcessorHandler<\n\tTParams,\n\tTServices extends Service[],\n\tTLogger extends Logger,\n> = (\n\tcontext: ProcessorContext<TParams, TServices, TLogger>,\n) => Promise<ProcessorResult> | ProcessorResult;\n\n/** What a processor's parameters parse to: its schema's output, or the raw strings. */\nexport type ProcessorParams<\n\tTPattern extends string,\n\tTSchema extends StandardSchemaV1 | undefined,\n> = TSchema extends StandardSchemaV1\n\t? InferStandardSchema<TSchema>\n\t: PatternParams<TPattern>;\n\n/**\n * A processor — a handler behind one path pattern of a file server, which\n * makes a derivative of an open object on read: a thumbnail, a page of a PDF.\n *\n * Built from the file server (`assets.process('/i/:width/*')`), so it carries\n * the bucket it reads and the open paths it may serve. Its parameters' schema\n * is the allowlist: a request outside it is refused before anything runs, so\n * nobody can mint new work — or new cache entries — by varying a number.\n */\nexport class Processor<\n\tTPattern extends string = string,\n\tTSchema extends StandardSchemaV1 | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> extends Construct<TLogger, undefined, TServices> {\n\t__IS_PROCESSOR__ = true;\n\n\tstatic isProcessor(obj: unknown): obj is Processor<string, any, any, any> {\n\t\treturn Boolean(\n\t\t\tobj &&\n\t\t\t\t(obj as { __IS_PROCESSOR__?: boolean }).__IS_PROCESSOR__ === true &&\n\t\t\t\t(obj as Construct).type === ConstructType.Processor,\n\t\t);\n\t}\n\n\tconstructor(\n\t\treadonly parsed: ParsedPattern,\n\t\treadonly handler: ProcessorHandler<\n\t\t\tProcessorParams<TPattern, TSchema>,\n\t\t\tTServices,\n\t\t\tTLogger\n\t\t>,\n\t\treadonly options: {\n\t\t\t/** The file server's surface id — the unit that runs it. */\n\t\t\tsurfaceId: string;\n\t\t\t/** The bucket it reads from and keeps derivatives in. */\n\t\t\tbucketId: string;\n\t\t\t/** How it reaches that bucket. */\n\t\t\torigin: Service<string, StorageClient>;\n\t\t\t/** Whether a key is one of the file server's open paths. */\n\t\t\tserves: (key: string) => boolean;\n\t\t\tparamsSchema?: TSchema;\n\t\t\t/** Packages with native code, installed for the target. */\n\t\t\tnative: readonly string[];\n\t\t\tlogger: TLogger;\n\t\t\tservices: TServices;\n\t\t\tconstructs: string[];\n\t\t\ttimeout?: number;\n\t\t\tmemorySize?: number;\n\t\t},\n\t) {\n\t\tsuper(\n\t\t\tConstructType.Processor,\n\t\t\toptions.logger,\n\t\t\t// The bucket is reached like any service — which is also how its URL\n\t\t\t// is found by the environment sniffer.\n\t\t\t[options.origin, ...options.services] as unknown as TServices,\n\t\t\t[],\n\t\t\tundefined,\n\t\t\toptions.timeout,\n\t\t\toptions.memorySize,\n\t\t\tundefined,\n\t\t\t// The bucket is an edge of its process, so the unit running it is\n\t\t\t// handed the bucket's address.\n\t\t\t[...new Set([options.bucketId, ...options.constructs])],\n\t\t);\n\t\tthis.owner = options.surfaceId;\n\t}\n\n\t/** The pattern it answers, as written. */\n\tget pattern(): TPattern {\n\t\treturn this.parsed.pattern as TPattern;\n\t}\n\n\t/** The literal path the edge routes to it — `/i/`. */\n\tget prefix(): string {\n\t\treturn this.parsed.prefix;\n\t}\n\n\tget native(): readonly string[] {\n\t\treturn this.options.native;\n\t}\n\n\tget surfaceId(): string {\n\t\treturn this.options.surfaceId;\n\t}\n\n\tget bucketId(): string {\n\t\treturn this.options.bucketId;\n\t}\n}\n","import type { Logger } from '@geekmidas/logger';\nimport type { Service } from '@geekmidas/services';\nimport type { StorageClient } from '@geekmidas/storage';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport {\n\ttype Consumable,\n\tidsOf,\n\ttype ServicesOf,\n\tservicesOf,\n} from '../construct-interface';\nimport {\n\tProcessor,\n\ttype ProcessorHandler,\n\ttype ProcessorParams,\n} from './Processor';\nimport type { ParsedPattern } from './pattern';\n\n/** A native package named in a way no installer could resolve. */\nexport class ProcessorNativeInvalid extends Error {\n\tconstructor(readonly packageName: string) {\n\t\tsuper(\n\t\t\t`'${packageName}' is not a package name. Name the package with native code ` +\n\t\t\t\t`as it is installed — 'sharp', '@napi-rs/canvas' — and its version ` +\n\t\t\t\t`is taken from the app's package.json.`,\n\t\t);\n\t\tthis.name = 'ProcessorNativeInvalid';\n\t}\n}\n\ninterface ProcessorBuilderState<TLogger extends Logger> {\n\tparsed: ParsedPattern;\n\tsurfaceId: string;\n\tbucketId: string;\n\torigin: Service<string, StorageClient>;\n\tserves: (key: string) => boolean;\n\tlogger: TLogger;\n\tparamsSchema?: StandardSchemaV1;\n\tnative: string[];\n\tservices: Service[];\n\tconstructs: string[];\n\ttimeout?: number;\n\tmemorySize?: number;\n}\n\n/**\n * What `fileServer.process(pattern)` returns: a processor, built up one\n * immutable step at a time and finished by `.handle()`.\n */\nexport class ProcessorBuilder<\n\tTPattern extends string,\n\tTSchema extends StandardSchemaV1 | undefined = undefined,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n> {\n\tconstructor(private readonly state: ProcessorBuilderState<TLogger>) {}\n\n\t/**\n\t * The parameters' schema — the allowlist. Every request is parsed by it\n\t * before anything runs, and one it refuses is answered 400.\n\t */\n\tparams<T extends StandardSchemaV1>(\n\t\tschema: T,\n\t): ProcessorBuilder<TPattern, T, TServices, TLogger> {\n\t\treturn new ProcessorBuilder({ ...this.state, paramsSchema: schema });\n\t}\n\n\t/** Constructs its handler reaches, as `services.<id>`. */\n\tdependsOn<const T extends readonly Consumable[]>(\n\t\tconstructs: T,\n\t): ProcessorBuilder<\n\t\tTPattern,\n\t\tTSchema,\n\t\t[...TServices, ...ServicesOf<T>],\n\t\tTLogger\n\t> {\n\t\tconst services = servicesOf(constructs) as unknown as Service[];\n\t\treturn new ProcessorBuilder({\n\t\t\t...this.state,\n\t\t\tservices: [\n\t\t\t\t...this.state.services.filter(\n\t\t\t\t\t(service) =>\n\t\t\t\t\t\t!services.some((s) => s.serviceName === service.serviceName),\n\t\t\t\t),\n\t\t\t\t...services,\n\t\t\t],\n\t\t\tconstructs: idsOf(constructs, this.state.constructs),\n\t\t});\n\t}\n\n\t/**\n\t * Packages with native code — `sharp` — installed for the target the\n\t * processor runs on rather than bundled: linux in its image, arm64 on\n\t * Lambda.\n\t */\n\tnative(packages: readonly string[]): this {\n\t\tfor (const name of packages) {\n\t\t\tif (!/^(@[a-z0-9._~-]+\\/)?[a-z0-9._~-]+$/.test(name)) {\n\t\t\t\tthrow new ProcessorNativeInvalid(name);\n\t\t\t}\n\t\t}\n\t\treturn new ProcessorBuilder({\n\t\t\t...this.state,\n\t\t\tnative: [...new Set([...this.state.native, ...packages])],\n\t\t}) as this;\n\t}\n\n\t/** Milliseconds a request may take, where the target bounds it. */\n\ttimeout(ms: number): this {\n\t\treturn new ProcessorBuilder({ ...this.state, timeout: ms }) as this;\n\t}\n\n\t/** Megabytes of memory, where the target sets it. */\n\tmemorySize(mb: number): this {\n\t\treturn new ProcessorBuilder({ ...this.state, memorySize: mb }) as this;\n\t}\n\n\thandle(\n\t\tfn: ProcessorHandler<\n\t\t\tProcessorParams<TPattern, TSchema>,\n\t\t\tTServices,\n\t\t\tTLogger\n\t\t>,\n\t): Processor<TPattern, TSchema, TServices, TLogger> {\n\t\tconst { state } = this;\n\t\treturn new Processor<TPattern, TSchema, TServices, TLogger>(\n\t\t\tstate.parsed,\n\t\t\tfn,\n\t\t\t{\n\t\t\t\tsurfaceId: state.surfaceId,\n\t\t\t\tbucketId: state.bucketId,\n\t\t\t\torigin: state.origin,\n\t\t\t\tserves: state.serves,\n\t\t\t\t...(state.paramsSchema\n\t\t\t\t\t? { paramsSchema: state.paramsSchema as TSchema }\n\t\t\t\t\t: {}),\n\t\t\t\tnative: state.native,\n\t\t\t\tlogger: state.logger,\n\t\t\t\tservices: state.services as TServices,\n\t\t\t\tconstructs: state.constructs,\n\t\t\t\t...(state.timeout !== undefined ? { timeout: state.timeout } : {}),\n\t\t\t\t...(state.memorySize !== undefined\n\t\t\t\t\t? { memorySize: state.memorySize }\n\t\t\t\t\t: {}),\n\t\t\t},\n\t\t);\n\t}\n}\n","/**\n * A processor's path pattern: literal segments, `:name` parameters, and a\n * final `*` that is the object's key.\n *\n * ```\n * /i/:width/* → /i/256/avatars/7.png { width: '256' }, 'avatars/7.png'\n * /pdf/:page/:dpi/* → /pdf/1/150/doc.pdf { page: '1', dpi: '150' }, 'doc.pdf'\n * ```\n *\n * It starts with a literal segment because the edge routes on that prefix: a\n * pattern beginning with a parameter would claim every path on the file\n * server, objects included.\n */\n\n/** The parameter names a pattern declares, as a union. */\nexport type PatternParamNames<P extends string> =\n\tP extends `${string}/:${infer Name}/${infer Rest}`\n\t\t? Name | PatternParamNames<`/${Rest}`>\n\t\t: never;\n\n/** The raw parameters a pattern matches, before its schema parses them. */\nexport type PatternParams<P extends string> = {\n\t[K in PatternParamNames<P>]: string;\n};\n\n/** A pattern a processor cannot be served on. */\nexport class ProcessorPatternInvalid extends Error {\n\tconstructor(\n\t\treadonly pattern: string,\n\t\treadonly reason: string,\n\t) {\n\t\tsuper(\n\t\t\t`'${pattern}' is not a processor pattern: ${reason}. A pattern is a ` +\n\t\t\t\t`literal first segment, then any \\`:name\\` parameters, then \\`*\\` ` +\n\t\t\t\t`for the object's key — '/i/:width/*'.`,\n\t\t);\n\t\tthis.name = 'ProcessorPatternInvalid';\n\t}\n}\n\n/** A pattern, parsed once. */\nexport interface ParsedPattern {\n\treadonly pattern: string;\n\t/** Each segment before the key: a literal, or a parameter's name. */\n\treadonly segments: readonly (\n\t\t| { kind: 'literal'; value: string }\n\t\t| { kind: 'param'; name: string }\n\t)[];\n\t/** The parameter names, in the order they appear. */\n\treadonly params: readonly string[];\n\t/** The literal path the edge routes on — `/i/`. */\n\treadonly prefix: string;\n}\n\n/** @throws {ProcessorPatternInvalid} */\nexport function parsePattern(pattern: string): ParsedPattern {\n\tif (!pattern.startsWith('/')) {\n\t\tthrow new ProcessorPatternInvalid(pattern, 'it does not start with /');\n\t}\n\tif (!pattern.endsWith('/*')) {\n\t\tthrow new ProcessorPatternInvalid(\n\t\t\tpattern,\n\t\t\t'it does not end with /* — the key',\n\t\t);\n\t}\n\n\tconst parts = pattern.slice(1, -2).split('/');\n\tconst segments: ParsedPattern['segments'][number][] = [];\n\tconst params: string[] = [];\n\tfor (const part of parts) {\n\t\tif (part === '') {\n\t\t\tthrow new ProcessorPatternInvalid(pattern, 'it has an empty segment');\n\t\t}\n\t\tif (part.includes('*')) {\n\t\t\tthrow new ProcessorPatternInvalid(\n\t\t\t\tpattern,\n\t\t\t\t'only its last segment may be *',\n\t\t\t);\n\t\t}\n\t\tif (part.startsWith(':')) {\n\t\t\tconst name = part.slice(1);\n\t\t\tif (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name)) {\n\t\t\t\tthrow new ProcessorPatternInvalid(\n\t\t\t\t\tpattern,\n\t\t\t\t\t`'${part}' is not a parameter name`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (params.includes(name)) {\n\t\t\t\tthrow new ProcessorPatternInvalid(pattern, `'${name}' appears twice`);\n\t\t\t}\n\t\t\tparams.push(name);\n\t\t\tsegments.push({ kind: 'param', name });\n\t\t\tcontinue;\n\t\t}\n\t\tif (!/^[A-Za-z0-9._~-]+$/.test(part)) {\n\t\t\tthrow new ProcessorPatternInvalid(\n\t\t\t\tpattern,\n\t\t\t\t`'${part}' has characters a path segment would escape`,\n\t\t\t);\n\t\t}\n\t\tsegments.push({ kind: 'literal', value: part });\n\t}\n\n\tconst first = segments[0];\n\tif (!first || first.kind !== 'literal') {\n\t\tthrow new ProcessorPatternInvalid(\n\t\t\tpattern,\n\t\t\t'its first segment is a parameter, which would claim every path',\n\t\t);\n\t}\n\n\tconst literals: string[] = [];\n\tfor (const segment of segments) {\n\t\tif (segment.kind !== 'literal') break;\n\t\tliterals.push(segment.value);\n\t}\n\n\treturn { pattern, segments, params, prefix: `/${literals.join('/')}/` };\n}\n\n/** A path the pattern matched: its raw parameters and the key. */\nexport interface PatternMatch {\n\tparams: Record<string, string>;\n\tkey: string;\n}\n\n/**\n * Match a request path, decoding each parameter and each key segment. A path\n * with an empty key, or one that decodes to a `..` segment, matches nothing.\n */\nexport function matchPattern(\n\tparsed: ParsedPattern,\n\tpath: string,\n): PatternMatch | undefined {\n\tconst parts = path.replace(/^\\/+/, '').split('/');\n\tif (parts.length <= parsed.segments.length) return undefined;\n\n\tconst params: Record<string, string> = {};\n\tfor (const [index, segment] of parsed.segments.entries()) {\n\t\tconst part = decode(parts[index] ?? '');\n\t\tif (part === undefined || part === '') return undefined;\n\t\tif (segment.kind === 'literal') {\n\t\t\tif (part !== segment.value) return undefined;\n\t\t\tcontinue;\n\t\t}\n\t\tparams[segment.name] = part;\n\t}\n\n\tconst keyParts = parts.slice(parsed.segments.length).map(decode);\n\tif (keyParts.some((part) => part === undefined || part === '..')) {\n\t\treturn undefined;\n\t}\n\tconst key = keyParts.join('/');\n\tif (key === '' || keyParts.includes('')) return undefined;\n\n\treturn { params, key };\n}\n\n/** The path that addresses `key` through the pattern with these parameters. */\nexport function fillPattern(\n\tparsed: ParsedPattern,\n\tparams: Readonly<Record<string, string | number>>,\n\tkey: string,\n): string {\n\tconst head = parsed.segments.map((segment) => {\n\t\tif (segment.kind === 'literal') return segment.value;\n\t\tconst value = params[segment.name];\n\t\tif (value === undefined || `${value}` === '') {\n\t\t\tthrow new ProcessorParamMissing(parsed.pattern, segment.name);\n\t\t}\n\t\treturn encodeURIComponent(`${value}`);\n\t});\n\tconst tail = key\n\t\t.replace(/^\\/+/, '')\n\t\t.split('/')\n\t\t.map((part) => encodeURIComponent(part));\n\n\treturn `/${[...head, ...tail].join('/')}`;\n}\n\n/** A processed URL was asked for without one of the pattern's parameters. */\nexport class ProcessorParamMissing extends Error {\n\tconstructor(\n\t\treadonly pattern: string,\n\t\treadonly param: string,\n\t) {\n\t\tsuper(\n\t\t\t`'${pattern}' needs '${param}' to address an object, and it was not given.`,\n\t\t);\n\t\tthis.name = 'ProcessorParamMissing';\n\t}\n}\n\nfunction decode(part: string): string | undefined {\n\ttry {\n\t\treturn decodeURIComponent(part);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AAmFA,IAAa,YAAb,cAKU,UAAyC;CAYxC;CACA;CAKA;CAjBV,mBAAmB;CAEnB,OAAO,YAAY,KAAuD;EACzE,OAAO,QACN,OACE,IAAuC,qBAAqB,QAC5D,IAAkB,SAAA,kCACrB;CACD;CAEA,YACC,QACA,SAKA,SAkBC;EACD,MAAA,oCAEC,QAAQ,QAGR,CAAC,QAAQ,QAAQ,GAAG,QAAQ,QAAQ,GACpC,CAAC,GACD,KAAA,GACA,QAAQ,SACR,QAAQ,YACR,KAAA,GAGA,CAAC,mBAAG,IAAI,IAAI,CAAC,QAAQ,UAAU,GAAG,QAAQ,UAAU,CAAC,CAAC,CACvD;EAvCS,KAAA,SAAA;EACA,KAAA,UAAA;EAKA,KAAA,UAAA;EAkCT,KAAK,QAAQ,QAAQ;CACtB;;CAGA,IAAI,UAAoB;EACvB,OAAO,KAAK,OAAO;CACpB;;CAGA,IAAI,SAAiB;EACpB,OAAO,KAAK,OAAO;CACpB;CAEA,IAAI,SAA4B;EAC/B,OAAO,KAAK,QAAQ;CACrB;CAEA,IAAI,YAAoB;EACvB,OAAO,KAAK,QAAQ;CACrB;CAEA,IAAI,WAAmB;EACtB,OAAO,KAAK,QAAQ;CACrB;AACD;;;;AClJA,IAAa,y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ACA,KACS;CACT,MAAM,OAAO,OAAO,SAAS,KAAK,YAAY;EAC7C,IAAI,QAAQ,SAAS,WAAW,OAAO,QAAQ;EAC/C,MAAM,QAAQ,OAAO,QAAQ;EAC7B,IAAI,UAAU,KAAA,KAAa,GAAG,YAAY,IACzC,MAAM,IAAI,sBAAsB,OAAO,SAAS,QAAQ,IAAI;EAE7D,OAAO,mBAAmB,GAAG,OAAO;CACrC,CAAC;CACD,MAAM,OAAO,IACX,QAAQ,QAAQ,EAAE,CAAC,CACnB,MAAM,GAAG,CAAC,CACV,KAAK,SAAS,mBAAmB,IAAI,CAAC;CAExC,OAAO,IAAI,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC,CAAC,KAAK,GAAG;AACvC;;AAGA,IAAa,wBAAb,cAA2C,MAAM;CAEtC;CACA;CAFV,YACC,SACA,OACC;EACD,MACC,IAAI,QAAQ,WAAW,MAAM,8CAC9B;EALS,KAAA,UAAA;EACA,KAAA,QAAA;EAKT,KAAK,OAAO;CACb;AACD;AAEA,SAAS,OAAO,MAAkC;CACjD,IAAI;EACH,OAAO,mBAAmB,IAAI;CAC/B,QAAQ;EACP;CACD;AACD"}
@@ -0,0 +1,21 @@
1
+ //#region src/privateAddress.ts
2
+ /**
3
+ * Whether `address` is loopback or private: 127/8, 10/8, 172.16/12,
4
+ * 192.168/16, 169.254/16, `::1`, `fc00::/7`, `fe80::/10`, and an IPv4 one
5
+ * mapped into IPv6.
6
+ */
7
+ function isPrivateAddress(address) {
8
+ if (!address) return false;
9
+ const ip = address.toLowerCase().replace(/^::ffff:/, "");
10
+ const v4 = ip.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);
11
+ if (v4) {
12
+ const [a, b] = [Number(v4[1]), Number(v4[2])];
13
+ return a === 127 || a === 10 || a === 172 && b >= 16 && b <= 31 || a === 192 && b === 168 || a === 169 && b === 254;
14
+ }
15
+ if (ip === "::1") return true;
16
+ return /^f[cd][0-9a-f]{2}:/.test(ip) || /^fe[89ab][0-9a-f]:/.test(ip);
17
+ }
18
+ //#endregion
19
+ export { isPrivateAddress as t };
20
+
21
+ //# sourceMappingURL=privateAddress-Bg5fUsbp.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"privateAddress-Bg5fUsbp.mjs","names":[],"sources":["../src/privateAddress.ts"],"sourcesContent":["/**\n * Whether `address` is loopback or private: 127/8, 10/8, 172.16/12,\n * 192.168/16, 169.254/16, `::1`, `fc00::/7`, `fe80::/10`, and an IPv4 one\n * mapped into IPv6.\n */\nexport function isPrivateAddress(address: string | undefined): boolean {\n\tif (!address) return false;\n\tconst ip = address.toLowerCase().replace(/^::ffff:/, '');\n\n\tconst v4 = ip.match(/^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$/);\n\tif (v4) {\n\t\tconst [a, b] = [Number(v4[1]), Number(v4[2])];\n\t\treturn (\n\t\t\ta === 127 ||\n\t\t\ta === 10 ||\n\t\t\t(a === 172 && b >= 16 && b <= 31) ||\n\t\t\t(a === 192 && b === 168) ||\n\t\t\t(a === 169 && b === 254)\n\t\t);\n\t}\n\n\tif (ip === '::1') return true;\n\treturn /^f[cd][0-9a-f]{2}:/.test(ip) || /^fe[89ab][0-9a-f]:/.test(ip);\n}\n"],"mappings":";;;;;;AAKA,SAAgB,iBAAiB,SAAsC;CACtE,IAAI,CAAC,SAAS,OAAO;CACrB,MAAM,KAAK,QAAQ,YAAY,CAAC,CAAC,QAAQ,YAAY,EAAE;CAEvD,MAAM,KAAK,GAAG,MAAM,8CAA8C;CAClE,IAAI,IAAI;EACP,MAAM,CAAC,GAAG,KAAK,CAAC,OAAO,GAAG,EAAE,GAAG,OAAO,GAAG,EAAE,CAAC;EAC5C,OACC,MAAM,OACN,MAAM,MACL,MAAM,OAAO,KAAK,MAAM,KAAK,MAC7B,MAAM,OAAO,MAAM,OACnB,MAAM,OAAO,MAAM;CAEtB;CAEA,IAAI,OAAO,OAAO,OAAO;CACzB,OAAO,qBAAqB,KAAK,EAAE,KAAK,qBAAqB,KAAK,EAAE;AACrE"}
@@ -0,0 +1,26 @@
1
+ //#region src/privateAddress.ts
2
+ /**
3
+ * Whether `address` is loopback or private: 127/8, 10/8, 172.16/12,
4
+ * 192.168/16, 169.254/16, `::1`, `fc00::/7`, `fe80::/10`, and an IPv4 one
5
+ * mapped into IPv6.
6
+ */
7
+ function isPrivateAddress(address) {
8
+ if (!address) return false;
9
+ const ip = address.toLowerCase().replace(/^::ffff:/, "");
10
+ const v4 = ip.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);
11
+ if (v4) {
12
+ const [a, b] = [Number(v4[1]), Number(v4[2])];
13
+ return a === 127 || a === 10 || a === 172 && b >= 16 && b <= 31 || a === 192 && b === 168 || a === 169 && b === 254;
14
+ }
15
+ if (ip === "::1") return true;
16
+ return /^f[cd][0-9a-f]{2}:/.test(ip) || /^fe[89ab][0-9a-f]:/.test(ip);
17
+ }
18
+ //#endregion
19
+ Object.defineProperty(exports, "isPrivateAddress", {
20
+ enumerable: true,
21
+ get: function() {
22
+ return isPrivateAddress;
23
+ }
24
+ });
25
+
26
+ //# sourceMappingURL=privateAddress-CqGyuFHn.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"privateAddress-CqGyuFHn.cjs","names":[],"sources":["../src/privateAddress.ts"],"sourcesContent":["/**\n * Whether `address` is loopback or private: 127/8, 10/8, 172.16/12,\n * 192.168/16, 169.254/16, `::1`, `fc00::/7`, `fe80::/10`, and an IPv4 one\n * mapped into IPv6.\n */\nexport function isPrivateAddress(address: string | undefined): boolean {\n\tif (!address) return false;\n\tconst ip = address.toLowerCase().replace(/^::ffff:/, '');\n\n\tconst v4 = ip.match(/^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$/);\n\tif (v4) {\n\t\tconst [a, b] = [Number(v4[1]), Number(v4[2])];\n\t\treturn (\n\t\t\ta === 127 ||\n\t\t\ta === 10 ||\n\t\t\t(a === 172 && b >= 16 && b <= 31) ||\n\t\t\t(a === 192 && b === 168) ||\n\t\t\t(a === 169 && b === 254)\n\t\t);\n\t}\n\n\tif (ip === '::1') return true;\n\treturn /^f[cd][0-9a-f]{2}:/.test(ip) || /^fe[89ab][0-9a-f]:/.test(ip);\n}\n"],"mappings":";;;;;;AAKA,SAAgB,iBAAiB,SAAsC;CACtE,IAAI,CAAC,SAAS,OAAO;CACrB,MAAM,KAAK,QAAQ,YAAY,CAAC,CAAC,QAAQ,YAAY,EAAE;CAEvD,MAAM,KAAK,GAAG,MAAM,8CAA8C;CAClE,IAAI,IAAI;EACP,MAAM,CAAC,GAAG,KAAK,CAAC,OAAO,GAAG,EAAE,GAAG,OAAO,GAAG,EAAE,CAAC;EAC5C,OACC,MAAM,OACN,MAAM,MACL,MAAM,OAAO,KAAK,MAAM,KAAK,MAC7B,MAAM,OAAO,MAAM,OACnB,MAAM,OAAO,MAAM;CAEtB;CAEA,IAAI,OAAO,OAAO,OAAO;CACzB,OAAO,qBAAqB,KAAK,EAAE,KAAK,qBAAqB,KAAK,EAAE;AACrE"}
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_pattern = require("../pattern-QFaUIr77.cjs");
2
+ const require_pattern = require("../pattern-HnNOPhE2.cjs");
3
3
  const require_surfaceEnv = require("../surfaceEnv-CNimK76p.cjs");
4
4
  let _geekmidas_services = require("@geekmidas/services");
5
5
  let _geekmidas_manifest = require("@geekmidas/manifest");
@@ -1,4 +1,4 @@
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-CwfP-M33.mjs";
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-D4oYvZeG.mjs";
2
2
  import { ServiceDiscovery } from "@geekmidas/services";
3
3
  import { EnvironmentParser } from "@geekmidas/envkit";
4
4
  //#region src/processors/AWSLambdaProcessor.d.ts
@@ -1,4 +1,4 @@
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";
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-YSqfAhXm.mjs";
2
2
  import { t as defaultEnvParser } from "../surfaceEnv-wMT5QzgZ.mjs";
3
3
  import { ServiceDiscovery, runWithRequestContext } from "@geekmidas/services";
4
4
  //#region src/processors/runProcessor.ts