@geekmidas/constructs 10.0.0-alpha.124 → 10.0.0-alpha.126

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 (157) hide show
  1. package/dist/{Construct-CFW0zjdD.d.cts → Construct-127M7yrl.d.cts} +3 -2
  2. package/dist/{Construct-B7AXn0xH.d.mts.map → Construct-127M7yrl.d.cts.map} +1 -1
  3. package/dist/{Construct-CKUA-CTA.mjs → Construct-CGuc_Ijk.mjs} +2 -1
  4. package/dist/{Construct-CKUA-CTA.mjs.map → Construct-CGuc_Ijk.mjs.map} +1 -1
  5. package/dist/{Construct-DEOVauyA.cjs → Construct-DorKS0Ua.cjs} +2 -1
  6. package/dist/{Construct-DEOVauyA.cjs.map → Construct-DorKS0Ua.cjs.map} +1 -1
  7. package/dist/{Construct-B7AXn0xH.d.mts → Construct-DySlwh8o.d.mts} +3 -2
  8. package/dist/{Construct-CFW0zjdD.d.cts.map → Construct-DySlwh8o.d.mts.map} +1 -1
  9. package/dist/{Cron-bdGRSROY.d.cts → Cron-CFkpEys6.d.cts} +4 -4
  10. package/dist/{Cron-bdGRSROY.d.cts.map → Cron-CFkpEys6.d.cts.map} +1 -1
  11. package/dist/{Cron-i4Uetezh.d.mts → Cron-CQoDSu-n.d.mts} +4 -4
  12. package/dist/{Cron-i4Uetezh.d.mts.map → Cron-CQoDSu-n.d.mts.map} +1 -1
  13. package/dist/{CronBuilder-9H4BnD6W.d.mts → CronBuilder-1W-G_i15.d.mts} +5 -5
  14. package/dist/{CronBuilder-9H4BnD6W.d.mts.map → CronBuilder-1W-G_i15.d.mts.map} +1 -1
  15. package/dist/{CronBuilder-D3sF9tS_.mjs → CronBuilder-BJ5LoadF.mjs} +3 -3
  16. package/dist/{CronBuilder-D3sF9tS_.mjs.map → CronBuilder-BJ5LoadF.mjs.map} +1 -1
  17. package/dist/{CronBuilder-BXTG10u5.cjs → CronBuilder-B_NSP-Y5.cjs} +3 -3
  18. package/dist/{CronBuilder-BXTG10u5.cjs.map → CronBuilder-B_NSP-Y5.cjs.map} +1 -1
  19. package/dist/{CronBuilder-B_24LZpn.d.cts → CronBuilder-OaCRRFVk.d.cts} +5 -5
  20. package/dist/{CronBuilder-B_24LZpn.d.cts.map → CronBuilder-OaCRRFVk.d.cts.map} +1 -1
  21. package/dist/{Endpoint-DgrpG15P.d.cts → Endpoint-BEh-jW-f.d.cts} +4 -4
  22. package/dist/{Endpoint-CeFkSwh5.d.mts.map → Endpoint-BEh-jW-f.d.cts.map} +1 -1
  23. package/dist/{Endpoint-yhR2T2Wt.cjs → Endpoint-BuGFNFSB.cjs} +3 -3
  24. package/dist/{Endpoint-yhR2T2Wt.cjs.map → Endpoint-BuGFNFSB.cjs.map} +1 -1
  25. package/dist/{Endpoint-CeFkSwh5.d.mts → Endpoint-DTXDggNl.d.mts} +4 -4
  26. package/dist/{Endpoint-DgrpG15P.d.cts.map → Endpoint-DTXDggNl.d.mts.map} +1 -1
  27. package/dist/{Endpoint-gPXhHKhJ.mjs → Endpoint-VdaYKc2g.mjs} +3 -3
  28. package/dist/{Endpoint-gPXhHKhJ.mjs.map → Endpoint-VdaYKc2g.mjs.map} +1 -1
  29. package/dist/{EndpointFactory-Cc863XJS.d.cts → EndpointFactory-B2dCS9dy.d.cts} +4 -4
  30. package/dist/{EndpointFactory-Dbw9ugkX.d.mts.map → EndpointFactory-B2dCS9dy.d.cts.map} +1 -1
  31. package/dist/{EndpointFactory-CSrAyazj.cjs → EndpointFactory-C6pVda4y.cjs} +4 -4
  32. package/dist/{EndpointFactory-CSrAyazj.cjs.map → EndpointFactory-C6pVda4y.cjs.map} +1 -1
  33. package/dist/{EndpointFactory-c2ZugGig.mjs → EndpointFactory-CUpqgtaH.mjs} +4 -4
  34. package/dist/{EndpointFactory-c2ZugGig.mjs.map → EndpointFactory-CUpqgtaH.mjs.map} +1 -1
  35. package/dist/{EndpointFactory-Dbw9ugkX.d.mts → EndpointFactory-D2HXcUrJ.d.mts} +4 -4
  36. package/dist/{EndpointFactory-Cc863XJS.d.cts.map → EndpointFactory-D2HXcUrJ.d.mts.map} +1 -1
  37. package/dist/{Function-B0uZhZnU.d.cts → Function-BIEsY0Hm.d.cts} +2 -2
  38. package/dist/{Function-B0uZhZnU.d.cts.map → Function-BIEsY0Hm.d.cts.map} +1 -1
  39. package/dist/{Function-B_9R7Zy1.d.mts → Function-DfMzTGS4.d.mts} +2 -2
  40. package/dist/{Function-B_9R7Zy1.d.mts.map → Function-DfMzTGS4.d.mts.map} +1 -1
  41. package/dist/{HonoEndpointAdaptor-CN1jjUBJ.cjs → HonoEndpointAdaptor-BBTzbP38.cjs} +3 -3
  42. package/dist/{HonoEndpointAdaptor-CN1jjUBJ.cjs.map → HonoEndpointAdaptor-BBTzbP38.cjs.map} +1 -1
  43. package/dist/{HonoEndpointAdaptor-euH1oSdY.mjs → HonoEndpointAdaptor-BR_LyaFE.mjs} +3 -3
  44. package/dist/{HonoEndpointAdaptor-euH1oSdY.mjs.map → HonoEndpointAdaptor-BR_LyaFE.mjs.map} +1 -1
  45. package/dist/{ObjectSubscriberBuilder-C0WUU-ov.d.mts → ObjectSubscriberBuilder-HmBwFn2o.d.mts} +4 -4
  46. package/dist/{ObjectSubscriberBuilder-B4j3zgCZ.d.cts.map → ObjectSubscriberBuilder-HmBwFn2o.d.mts.map} +1 -1
  47. package/dist/{ObjectSubscriberBuilder-B4j3zgCZ.d.cts → ObjectSubscriberBuilder-l-64yUiF.d.cts} +4 -4
  48. package/dist/{ObjectSubscriberBuilder-C0WUU-ov.d.mts.map → ObjectSubscriberBuilder-l-64yUiF.d.cts.map} +1 -1
  49. package/dist/ProcessorBuilder-B2_stA8f.d.mts +216 -0
  50. package/dist/ProcessorBuilder-B2_stA8f.d.mts.map +1 -0
  51. package/dist/ProcessorBuilder-C62bIOwj.d.cts +216 -0
  52. package/dist/ProcessorBuilder-C62bIOwj.d.cts.map +1 -0
  53. package/dist/{Queue-B-dDXyjF.d.mts → Queue-BnK3UH8r.d.mts} +3 -3
  54. package/dist/{Queue-B-dDXyjF.d.mts.map → Queue-BnK3UH8r.d.mts.map} +1 -1
  55. package/dist/{Queue-JbIjVtTf.d.cts → Queue-C4rijiM7.d.cts} +3 -3
  56. package/dist/{Queue-JbIjVtTf.d.cts.map → Queue-C4rijiM7.d.cts.map} +1 -1
  57. package/dist/{Queue-BhuofM3k.cjs → Queue-D4Iaidrs.cjs} +3 -3
  58. package/dist/{Queue-BhuofM3k.cjs.map → Queue-D4Iaidrs.cjs.map} +1 -1
  59. package/dist/{Queue-cmhqEBOB.mjs → Queue-u8w8_HpE.mjs} +3 -3
  60. package/dist/{Queue-cmhqEBOB.mjs.map → Queue-u8w8_HpE.mjs.map} +1 -1
  61. package/dist/{QueueBuilder-DXu1qxT1.mjs → QueueBuilder-2wP5lEC8.mjs} +2 -2
  62. package/dist/{QueueBuilder-DXu1qxT1.mjs.map → QueueBuilder-2wP5lEC8.mjs.map} +1 -1
  63. package/dist/{QueueBuilder-48W-q8In.d.mts → QueueBuilder-B3vL1ED2.d.mts} +2 -2
  64. package/dist/{QueueBuilder-48W-q8In.d.mts.map → QueueBuilder-B3vL1ED2.d.mts.map} +1 -1
  65. package/dist/{QueueBuilder-MfpkJ3R9.d.cts → QueueBuilder-BcPBQSSX.d.cts} +2 -2
  66. package/dist/{QueueBuilder-MfpkJ3R9.d.cts.map → QueueBuilder-BcPBQSSX.d.cts.map} +1 -1
  67. package/dist/{QueueBuilder-DdU2klPu.cjs → QueueBuilder-BxsZ9o5z.cjs} +2 -2
  68. package/dist/{QueueBuilder-DdU2klPu.cjs.map → QueueBuilder-BxsZ9o5z.cjs.map} +1 -1
  69. package/dist/{Subscriber-Bfw5cqzz.d.cts → Subscriber-BdCtfFXL.d.cts} +3 -3
  70. package/dist/{Subscriber-Bfw5cqzz.d.cts.map → Subscriber-BdCtfFXL.d.cts.map} +1 -1
  71. package/dist/{Subscriber-Czs77h-H.d.mts → Subscriber-DDo4HFNn.d.mts} +3 -3
  72. package/dist/{Subscriber-Czs77h-H.d.mts.map → Subscriber-DDo4HFNn.d.mts.map} +1 -1
  73. package/dist/{SubscriberBuilder-DUMXzjbR.mjs → SubscriberBuilder-3msj1U2w.mjs} +2 -2
  74. package/dist/{SubscriberBuilder-DUMXzjbR.mjs.map → SubscriberBuilder-3msj1U2w.mjs.map} +1 -1
  75. package/dist/{SubscriberBuilder-CYluzubx.cjs → SubscriberBuilder-CQst6Iz3.cjs} +2 -2
  76. package/dist/{SubscriberBuilder-CYluzubx.cjs.map → SubscriberBuilder-CQst6Iz3.cjs.map} +1 -1
  77. package/dist/{Topic-D2R0r24C.mjs → Topic-DN2gYJ-p.mjs} +3 -3
  78. package/dist/{Topic-D2R0r24C.mjs.map → Topic-DN2gYJ-p.mjs.map} +1 -1
  79. package/dist/{Topic-DwS3QO0m.cjs → Topic-Dp9Q7Lj2.cjs} +3 -3
  80. package/dist/{Topic-DwS3QO0m.cjs.map → Topic-Dp9Q7Lj2.cjs.map} +1 -1
  81. package/dist/adaptors/aws.cjs +2 -2
  82. package/dist/adaptors/aws.d.cts +5 -5
  83. package/dist/adaptors/aws.d.mts +5 -5
  84. package/dist/adaptors/aws.mjs +3 -3
  85. package/dist/adaptors/hono.cjs +1 -1
  86. package/dist/adaptors/hono.d.cts +1 -1
  87. package/dist/adaptors/hono.d.mts +1 -1
  88. package/dist/adaptors/hono.mjs +1 -1
  89. package/dist/adaptors/testing.cjs +5 -5
  90. package/dist/adaptors/testing.d.cts +4 -4
  91. package/dist/adaptors/testing.d.mts +4 -4
  92. package/dist/adaptors/testing.mjs +5 -5
  93. package/dist/crons/index.cjs +2 -2
  94. package/dist/crons/index.d.cts +2 -2
  95. package/dist/crons/index.d.mts +2 -2
  96. package/dist/crons/index.mjs +2 -2
  97. package/dist/endpoints/index.cjs +3 -3
  98. package/dist/endpoints/index.d.cts +3 -3
  99. package/dist/endpoints/index.d.mts +3 -3
  100. package/dist/endpoints/index.mjs +3 -3
  101. package/dist/file-server.cjs +101 -31
  102. package/dist/file-server.cjs.map +1 -1
  103. package/dist/file-server.d.cts +95 -0
  104. package/dist/file-server.d.cts.map +1 -1
  105. package/dist/file-server.d.mts +95 -0
  106. package/dist/file-server.d.mts.map +1 -1
  107. package/dist/file-server.mjs +101 -33
  108. package/dist/file-server.mjs.map +1 -1
  109. package/dist/functions/index.cjs +1 -1
  110. package/dist/functions/index.d.cts +2 -2
  111. package/dist/functions/index.d.mts +2 -2
  112. package/dist/functions/index.mjs +1 -1
  113. package/dist/{functions-CTI-hDem.mjs → functions-BvIDQKAA.mjs} +3 -3
  114. package/dist/{functions-CTI-hDem.mjs.map → functions-BvIDQKAA.mjs.map} +1 -1
  115. package/dist/{functions-D7O5SGVc.cjs → functions-DLF6-IK8.cjs} +3 -3
  116. package/dist/{functions-D7O5SGVc.cjs.map → functions-DLF6-IK8.cjs.map} +1 -1
  117. package/dist/{index-Cd2w-DRL.d.cts → index-BtzMzhMA.d.cts} +3 -3
  118. package/dist/{index-Cd2w-DRL.d.cts.map → index-BtzMzhMA.d.cts.map} +1 -1
  119. package/dist/{index-aBIcAiH5.d.mts → index-DuriFjYD.d.mts} +3 -3
  120. package/dist/{index-aBIcAiH5.d.mts.map → index-DuriFjYD.d.mts.map} +1 -1
  121. package/dist/index.cjs +1 -1
  122. package/dist/index.d.cts +1 -1
  123. package/dist/index.d.mts +1 -1
  124. package/dist/index.mjs +1 -1
  125. package/dist/pattern-C1CEcglD.mjs +241 -0
  126. package/dist/pattern-C1CEcglD.mjs.map +1 -0
  127. package/dist/pattern-QFaUIr77.cjs +288 -0
  128. package/dist/pattern-QFaUIr77.cjs.map +1 -0
  129. package/dist/processors/index.cjs +214 -0
  130. package/dist/processors/index.cjs.map +1 -0
  131. package/dist/processors/index.d.cts +78 -0
  132. package/dist/processors/index.d.cts.map +1 -0
  133. package/dist/processors/index.d.mts +78 -0
  134. package/dist/processors/index.d.mts.map +1 -0
  135. package/dist/processors/index.mjs +193 -0
  136. package/dist/processors/index.mjs.map +1 -0
  137. package/dist/queue/index.cjs +2 -2
  138. package/dist/queue/index.d.cts +2 -2
  139. package/dist/queue/index.d.mts +2 -2
  140. package/dist/queue/index.mjs +2 -2
  141. package/dist/rest-api.cjs +1 -1
  142. package/dist/rest-api.d.cts +2 -2
  143. package/dist/rest-api.d.mts +2 -2
  144. package/dist/rest-api.mjs +1 -1
  145. package/dist/subscribers/index.cjs +1 -1
  146. package/dist/subscribers/index.d.cts +2 -2
  147. package/dist/subscribers/index.d.mts +2 -2
  148. package/dist/subscribers/index.mjs +1 -1
  149. package/dist/topic/index.cjs +1 -1
  150. package/dist/topic/index.d.cts +1 -1
  151. package/dist/topic/index.d.mts +1 -1
  152. package/dist/topic/index.mjs +1 -1
  153. package/dist/worker.cjs +4 -4
  154. package/dist/worker.d.cts +7 -7
  155. package/dist/worker.d.mts +7 -7
  156. package/dist/worker.mjs +4 -4
  157. package/package.json +41 -31
@@ -1,6 +1,6 @@
1
1
  import { n as StandardSchemaV1 } from "./index-DdRjYhiJ.cjs";
2
- import { a as EventFor, c as Topic, n as ConstructType, o as TopicEvent } from "./Construct-CFW0zjdD.cjs";
3
- import { i as FunctionHandler, n as Function } from "./Function-B0uZhZnU.cjs";
2
+ import { a as EventFor, c as Topic, n as ConstructType, o as TopicEvent } from "./Construct-127M7yrl.cjs";
3
+ import { i as FunctionHandler, n as Function } from "./Function-BIEsY0Hm.cjs";
4
4
  import { c as ServicesOf, r as Consumable } from "./construct-interface-B1AfqRl4.cjs";
5
5
  import { Logger } from "@geekmidas/logger";
6
6
  import { ComposableStandardSchema, InferComposableStandardSchema, InferStandardSchema } from "@geekmidas/schema";
@@ -112,4 +112,4 @@ declare class FunctionBuilder<TInput extends ComposableStandardSchema, OutSchema
112
112
  }
113
113
  //#endregion
114
114
  export { BaseFunctionBuilder as n, FunctionBuilder as t };
115
- //# sourceMappingURL=index-Cd2w-DRL.d.cts.map
115
+ //# sourceMappingURL=index-BtzMzhMA.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-Cd2w-DRL.d.cts","names":[],"sources":["../src/functions/BaseFunctionBuilder.ts","../src/functions/FunctionBuilder.ts"],"mappings":";;;;;;;;;uBAsBsB,oBACrB,eAAe,0BACf,kBAAkB,0CAClB,kBAAkB,gBAClB,gBAAgB,SAAS,QACzB,sBAAsB,sCACtB,kDACA,uBACA;EAoFmB,MAAI;YAlFb,cAAc;YACd,eAAe;YACf;EAEH,WAAW;;;;;;;;;EASX;EACA,SAAS;;;;;;;EAQT;;;;;;;;EASA;;EAGA,SAAS;YACN,kBAAkB,QAAQ,0BAA0B;YACpD,mBAAmB,QAAQ,sBAAsB;;YAEjD;SAEH,mBAAmB,aAAa,KAAK;SAM/B,8BACZ,UAAU,sCACT,eAAe,QAAQ,IAAI,QAAQ,8BAA8B;EAkCnE,YAAmB,OAAI;WAEd,SAAS,UAAU,WAAW,UAAU;WAExC,OAAO,UAAU,QAAQ,QAAQ;EAE1C,QAAQ;WAIC,OAAO,UAAU,kBAAkB,QAAQ;WAE3C,MAAM,UAAU,0BAA0B,QAAQ;;;;;;;YAQjD,UACT,OAAO,iBACP,OAAO,SAAS;EAcjB,QAAQ,UAAU,cAAc,sBAC/B,SAAS,QAAQ,OAAO,KACtB,oBACF,QACA,WACA,WACA,SACA,GACA,OACA,WACA;;;;;EAuBD,SAAS,GAAG,sBACX,QAAQ,WAAW,OAAO,KAAK,QAAQ,OAAO,KAC5C,oBACF,QACA,WACA,WACA,SACA,eACA,0BACA,GACA;;;;cCzKW,gBACZ,eAAe,0BACf,kBAAkB,0CAClB,kBAAkB,gBAClB,gBAAgB,SAAS,QACzB,sBAAsB,sCACtB,kDACA,uBACA,8CACA,qBAAqB,mCAAmC,0CAI/C,oBACT,QACA,WACA,WACA,SACA,eACA,0BACA,WACA;EAI4B,MAAI;YAFtB;EAEV,YAA4B,OAAI;EAIvB,QAAQ;EAIjB,WAAW;EAIX,OAAO,UAAU,kBAChB,QAAQ,IACN,gBACF,QACA,GACA,WACA,SACA,eACA,0BACA,WACA,sBACA;EAiBD,MAAM,UAAU,0BACf,QAAQ,IACN,gBACF,GACA,WACA,WACA,SACA,eACA,0BACA,WACA,sBACA;;;;;;;;;;;;EA4BD,gBAAgB,mBAAmB,cAClC,YAAY,IACV,gBACF,QACA,eACI,cAAc,WAAW,KAC7B,SACA,eACA,0BACA,WACA,sBACA;EA8BD,SAAS,UAAU,WAClB,UAAU,IACR,gBACF,QACA,eACI,cAAc,IAClB,SACA,eACA,0BACA,WACA,sBACA;EAoBD,OAAO,UAAU,QAChB,QAAQ,IACN,gBACF,QACA,WACA,WACA,GACA,eACA,0BACA,WACA,sBACA;;;;;;;EAuBD,MAAM,eAAe,iBACpB,OAAO,QACP,OAAO,SAAS,QAAQ,oBAAoB,cAC1C,gBACF,QACA,eACI,WAAW,oBACf,SACA,eACA,0BACA,WACA,sBACA;EAeQ,QAAQ,UAAU,cAAc,sBACxC,SAAS,QAAQ,OAAO,KACtB,gBACF,QACA,WACA,WACA,SACA,GACA,OACA,WACA,sBACA;;;;;EAwBD,QAAQ,UAAU,qCAAqC,gBACtD,QACA,WACA,WACA,SACA,eACA,0BACA,WACA,sBACA;;;;;EAmBQ,SAAS,GAAG,sBACpB,QAAQ,WAAW,OAAO,KAAK,QAAQ,OAAO,KAC5C,gBACF,QACA,WACA,WACA,SACA,eACA,0BACA,GACA,OACA;EAkCD,OACC,IAAI,gBACH,QACA,WACA,SACA,WACA,WACA,eACA,gBAEC,SACF,QACA,WACA,SACA,WACA,eACA,0BACA,WACA,sBACA,cACA,gBACC,QACA,WACA,SACA,WACA,WACA,eACA"}
1
+ {"version":3,"file":"index-BtzMzhMA.d.cts","names":[],"sources":["../src/functions/BaseFunctionBuilder.ts","../src/functions/FunctionBuilder.ts"],"mappings":";;;;;;;;;uBAsBsB,oBACrB,eAAe,0BACf,kBAAkB,0CAClB,kBAAkB,gBAClB,gBAAgB,SAAS,QACzB,sBAAsB,sCACtB,kDACA,uBACA;EAoFmB,MAAI;YAlFb,c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WAClB,UAAU,IACR,gBACF,QACA,eACI,cAAc,IAClB,SACA,eACA,0BACA,WACA,sBACA;EAoBD,OAAO,UAAU,QAChB,QAAQ,IACN,gBACF,QACA,WACA,WACA,GACA,eACA,0BACA,WACA,sBACA;;;;;;;EAuBD,MAAM,eAAe,iBACpB,OAAO,QACP,OAAO,SAAS,QAAQ,oBAAoB,cAC1C,gBACF,QACA,eACI,WAAW,oBACf,SACA,eACA,0BACA,WACA,sBACA;EAeQ,QAAQ,UAAU,cAAc,sBACxC,SAAS,QAAQ,OAAO,KACtB,gBACF,QACA,WACA,WACA,SACA,GACA,OACA,WACA,sBACA;;;;;EAwBD,QAAQ,UAAU,qCAAqC,gBACtD,QACA,WACA,WACA,SACA,eACA,0BACA,WACA,sBACA;;;;;EAmBQ,SAAS,GAAG,sBACpB,QAAQ,WAAW,OAAO,KAAK,QAAQ,OAAO,KAC5C,gBACF,QACA,WACA,WACA,SACA,eACA,0BACA,GACA,OACA;EAkCD,OACC,IAAI,gBACH,QACA,WACA,SACA,WACA,WACA,eACA,gBAEC,SACF,QACA,WACA,SACA,WACA,eACA,0BACA,WACA,sBACA,cACA,gBACC,QACA,WACA,SACA,WACA,WACA,eACA"}
@@ -1,6 +1,6 @@
1
1
  import { n as StandardSchemaV1 } from "./index-DdRjYhiJ.mjs";
2
- import { a as EventFor, c as Topic, n as ConstructType, o as TopicEvent } from "./Construct-B7AXn0xH.mjs";
3
- import { i as FunctionHandler, n as Function } from "./Function-B_9R7Zy1.mjs";
2
+ import { a as EventFor, c as Topic, n as ConstructType, o as TopicEvent } from "./Construct-DySlwh8o.mjs";
3
+ import { i as FunctionHandler, n as Function } from "./Function-DfMzTGS4.mjs";
4
4
  import { c as ServicesOf, r as Consumable } from "./construct-interface-ZvYQbivO.mjs";
5
5
  import { Service } from "@geekmidas/services";
6
6
  import { AuditStorage, AuditableAction } from "@geekmidas/audit";
@@ -112,4 +112,4 @@ declare class FunctionBuilder<TInput extends ComposableStandardSchema, OutSchema
112
112
  }
113
113
  //#endregion
114
114
  export { BaseFunctionBuilder as n, FunctionBuilder as t };
115
- //# sourceMappingURL=index-aBIcAiH5.d.mts.map
115
+ //# sourceMappingURL=index-DuriFjYD.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-aBIcAiH5.d.mts","names":[],"sources":["../src/functions/BaseFunctionBuilder.ts","../src/functions/FunctionBuilder.ts"],"mappings":";;;;;;;;;uBAsBsB,oBACrB,eAAe,0BACf,kBAAkB,0CAClB,kBAAkB,gBAClB,gBAAgB,SAAS,QACzB,sBAAsB,sCACtB,kDACA,uBACA;EAoFmB,MAAI;YAlFb,cAAc;YACd,eAAe;YACf;EAEH,WAAW;;;;;;;;;EASX;EACA,SAAS;;;;;;;EAQT;;;;;;;;EASA;;EAGA,SAAS;YACN,kBAAkB,QAAQ,0BAA0B;YACpD,mBAAmB,QAAQ,sBAAsB;;YAEjD;SAEH,mBAAmB,aAAa,KAAK;SAM/B,8BACZ,UAAU,sCACT,eAAe,QAAQ,IAAI,QAAQ,8BAA8B;EAkCnE,YAAmB,OAAI;WAEd,SAAS,UAAU,WAAW,UAAU;WAExC,OAAO,UAAU,QAAQ,QAAQ;EAE1C,QAAQ;WAIC,OAAO,UAAU,kBAAkB,QAAQ;WAE3C,MAAM,UAAU,0BAA0B,QAAQ;;;;;;;YAQjD,UACT,OAAO,iBACP,OAAO,SAAS;EAcjB,QAAQ,UAAU,cAAc,sBAC/B,SAAS,QAAQ,OAAO,KACtB,oBACF,QACA,WACA,WACA,SACA,GACA,OACA,WACA;;;;;EAuBD,SAAS,GAAG,sBACX,QAAQ,WAAW,OAAO,KAAK,QAAQ,OAAO,KAC5C,oBACF,QACA,WACA,WACA,SACA,eACA,0BACA,GACA;;;;cCzKW,gBACZ,eAAe,0BACf,kBAAkB,0CAClB,kBAAkB,gBAClB,gBAAgB,SAAS,QACzB,sBAAsB,sCACtB,kDACA,uBACA,8CACA,qBAAqB,mCAAmC,0CAI/C,oBACT,QACA,WACA,WACA,SACA,eACA,0BACA,WACA;EAI4B,MAAI;YAFtB;EAEV,YAA4B,OAAI;EAIvB,QAAQ;EAIjB,WAAW;EAIX,OAAO,UAAU,kBAChB,QAAQ,IACN,gBACF,QACA,GACA,WACA,SACA,eACA,0BACA,WACA,sBACA;EAiBD,MAAM,UAAU,0BACf,QAAQ,IACN,gBACF,GACA,WACA,WACA,SACA,eACA,0BACA,WACA,sBACA;;;;;;;;;;;;EA4BD,gBAAgB,mBAAmB,cAClC,YAAY,IACV,gBACF,QACA,eACI,cAAc,WAAW,KAC7B,SACA,eACA,0BACA,WACA,sBACA;EA8BD,SAAS,UAAU,WAClB,UAAU,IACR,gBACF,QACA,eACI,cAAc,IAClB,SACA,eACA,0BACA,WACA,sBACA;EAoBD,OAAO,UAAU,QAChB,QAAQ,IACN,gBACF,QACA,WACA,WACA,GACA,eACA,0BACA,WACA,sBACA;;;;;;;EAuBD,MAAM,eAAe,iBACpB,OAAO,QACP,OAAO,SAAS,QAAQ,oBAAoB,cAC1C,gBACF,QACA,eACI,WAAW,oBACf,SACA,eACA,0BACA,WACA,sBACA;EAeQ,QAAQ,UAAU,cAAc,sBACxC,SAAS,QAAQ,OAAO,KACtB,gBACF,QACA,WACA,WACA,SACA,GACA,OACA,WACA,sBACA;;;;;EAwBD,QAAQ,UAAU,qCAAqC,gBACtD,QACA,WACA,WACA,SACA,eACA,0BACA,WACA,sBACA;;;;;EAmBQ,SAAS,GAAG,sBACpB,QAAQ,WAAW,OAAO,KAAK,QAAQ,OAAO,KAC5C,gBACF,QACA,WACA,WACA,SACA,eACA,0BACA,GACA,OACA;EAkCD,OACC,IAAI,gBACH,QACA,WACA,SACA,WACA,WACA,eACA,gBAEC,SACF,QACA,WACA,SACA,WACA,eACA,0BACA,WACA,sBACA,cACA,gBACC,QACA,WACA,SACA,WACA,WACA,eACA"}
1
+ {"version":3,"file":"index-DuriFjYD.d.mts","names":[],"sources":["../src/functions/BaseFunctionBuilder.ts","../src/functions/FunctionBuilder.ts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BACA,WACA,sBACA;;;;;;;;;;;;EA4BD,gBAAgB,mBAAmB,cAClC,YAAY,IACV,gBACF,QACA,eACI,cAAc,WAAW,KAC7B,SACA,eACA,0BACA,WACA,sBACA;EA8BD,SAAS,UAAU,WAClB,UAAU,IACR,gBACF,QACA,eACI,cAAc,IAClB,SACA,eACA,0BACA,WACA,sBACA;EAoBD,OAAO,UAAU,QAChB,QAAQ,IACN,gBACF,QACA,WACA,WACA,GACA,eACA,0BACA,WACA,sBACA;;;;;;;EAuBD,MAAM,eAAe,iBACpB,OAAO,QACP,OAAO,SAAS,QAAQ,oBAAoB,cAC1C,gBACF,QACA,eACI,WAAW,oBACf,SACA,eACA,0BACA,WACA,sBACA;EAeQ,QAAQ,UAAU,cAAc,sBACxC,SAAS,QAAQ,OAAO,KACtB,gBACF,QACA,WACA,WACA,SACA,GACA,OACA,WACA,sBACA;;;;;EAwBD,QAAQ,UAAU,qCAAqC,gBACtD,QACA,WACA,WACA,SACA,eACA,0BACA,WACA,sBACA;;;;;EAmBQ,SAAS,GAAG,sBACpB,QAAQ,WAAW,OAAO,KAAK,QAAQ,OAAO,KAC5C,gBACF,QACA,WACA,WACA,SACA,eACA,0BACA,GACA,OACA;EAkCD,OACC,IAAI,gBACH,QACA,WACA,SACA,WACA,WACA,eACA,gBAEC,SACF,QACA,WACA,SACA,WACA,eACA,0BACA,WACA,sBACA,cACA,gBACC,QACA,WACA,SACA,WACA,WACA,eACA"}
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_Construct = require("./Construct-DEOVauyA.cjs");
2
+ const require_Construct = require("./Construct-DorKS0Ua.cjs");
3
3
  const require_shutdown = require("./shutdown-BMJmAhSt.cjs");
4
4
  exports.Construct = require_Construct.Construct;
5
5
  exports.ConstructType = require_Construct.ConstructType;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { i as snifferContext, n as ConstructType, r as sniffService, t as Construct } from "./Construct-CFW0zjdD.cjs";
1
+ import { i as snifferContext, n as ConstructType, r as sniffService, t as Construct } from "./Construct-127M7yrl.cjs";
2
2
  import { n as LowerHttpMethod, r as RemoveUndefined, t as HttpMethod } from "./types-DMuSQeLL.cjs";
3
3
  import { i as TelemetryResponse, n as TelemetryContext, r as TelemetryRequest, t as Telemetry } from "./lambdaTelemetry-8vnmVZQ5.cjs";
4
4
  import { a as Stages, i as SeedContext, n as DeployedStage, o as TestStage, r as LocalStage, t as AnyStage } from "./stages-BSCF19o2.cjs";
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { i as snifferContext, n as ConstructType, r as sniffService, t as Construct } from "./Construct-B7AXn0xH.mjs";
1
+ import { i as snifferContext, n as ConstructType, r as sniffService, t as Construct } from "./Construct-DySlwh8o.mjs";
2
2
  import { n as LowerHttpMethod, r as RemoveUndefined, t as HttpMethod } from "./types-DMuSQeLL.mjs";
3
3
  import { i as TelemetryResponse, n as TelemetryContext, r as TelemetryRequest, t as Telemetry } from "./lambdaTelemetry-8vnmVZQ5.mjs";
4
4
  import { a as Stages, i as SeedContext, n as DeployedStage, o as TestStage, r as LocalStage, t as AnyStage } from "./stages-BSCF19o2.mjs";
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { i as snifferContext, n as ConstructType, r as sniffService, t as Construct } from "./Construct-CKUA-CTA.mjs";
1
+ import { i as snifferContext, n as ConstructType, r as sniffService, t as Construct } from "./Construct-CGuc_Ijk.mjs";
2
2
  import { n as runShutdownHooks, t as onShutdown } from "./shutdown-C7xa8x9S.mjs";
3
3
  export { Construct, ConstructType, onShutdown, runShutdownHooks, sniffService, snifferContext };
@@ -0,0 +1,241 @@
1
+ import { t as Construct } from "./Construct-CGuc_Ijk.mjs";
2
+ import { idsOf, servicesOf } from "./construct-interface.mjs";
3
+ import { DERIVED_PREFIX as DERIVED_PREFIX$1 } from "@geekmidas/manifest";
4
+ //#region src/processors/Processor.ts
5
+ /**
6
+ * A processor — a handler behind one path pattern of a file server, which
7
+ * makes a derivative of an open object on read: a thumbnail, a page of a PDF.
8
+ *
9
+ * Built from the file server (`assets.process('/i/:width/*')`), so it carries
10
+ * the bucket it reads and the open paths it may serve. Its parameters' schema
11
+ * is the allowlist: a request outside it is refused before anything runs, so
12
+ * nobody can mint new work — or new cache entries — by varying a number.
13
+ */
14
+ var Processor = class extends Construct {
15
+ parsed;
16
+ handler;
17
+ options;
18
+ __IS_PROCESSOR__ = true;
19
+ static isProcessor(obj) {
20
+ return Boolean(obj && obj.__IS_PROCESSOR__ === true && obj.type === "dev.geekmidas.function.processor");
21
+ }
22
+ constructor(parsed, handler, options) {
23
+ super("dev.geekmidas.function.processor", options.logger, [options.origin, ...options.services], [], void 0, options.timeout, options.memorySize, void 0, [.../* @__PURE__ */ new Set([options.bucketId, ...options.constructs])]);
24
+ this.parsed = parsed;
25
+ this.handler = handler;
26
+ this.options = options;
27
+ this.owner = options.surfaceId;
28
+ }
29
+ /** The pattern it answers, as written. */
30
+ get pattern() {
31
+ return this.parsed.pattern;
32
+ }
33
+ /** The literal path the edge routes to it — `/i/`. */
34
+ get prefix() {
35
+ return this.parsed.prefix;
36
+ }
37
+ get native() {
38
+ return this.options.native;
39
+ }
40
+ get surfaceId() {
41
+ return this.options.surfaceId;
42
+ }
43
+ get bucketId() {
44
+ return this.options.bucketId;
45
+ }
46
+ };
47
+ //#endregion
48
+ //#region src/processors/ProcessorBuilder.ts
49
+ /** A native package named in a way no installer could resolve. */
50
+ var ProcessorNativeInvalid = class extends Error {
51
+ packageName;
52
+ constructor(packageName) {
53
+ super(`'${packageName}' is not a package name. Name the package with native code as it is installed — 'sharp', '@napi-rs/canvas' — and its version is taken from the app's package.json.`);
54
+ this.packageName = packageName;
55
+ this.name = "ProcessorNativeInvalid";
56
+ }
57
+ };
58
+ /**
59
+ * What `fileServer.process(pattern)` returns: a processor, built up one
60
+ * immutable step at a time and finished by `.handle()`.
61
+ */
62
+ var ProcessorBuilder = class ProcessorBuilder {
63
+ state;
64
+ constructor(state) {
65
+ this.state = state;
66
+ }
67
+ /**
68
+ * The parameters' schema — the allowlist. Every request is parsed by it
69
+ * before anything runs, and one it refuses is answered 400.
70
+ */
71
+ params(schema) {
72
+ return new ProcessorBuilder({
73
+ ...this.state,
74
+ paramsSchema: schema
75
+ });
76
+ }
77
+ /** Constructs its handler reaches, as `services.<id>`. */
78
+ dependsOn(constructs) {
79
+ const services = servicesOf(constructs);
80
+ return new ProcessorBuilder({
81
+ ...this.state,
82
+ services: [...this.state.services.filter((service) => !services.some((s) => s.serviceName === service.serviceName)), ...services],
83
+ constructs: idsOf(constructs, this.state.constructs)
84
+ });
85
+ }
86
+ /**
87
+ * Packages with native code — `sharp` — installed for the target the
88
+ * processor runs on rather than bundled: linux in its image, arm64 on
89
+ * Lambda.
90
+ */
91
+ native(packages) {
92
+ for (const name of packages) if (!/^(@[a-z0-9._~-]+\/)?[a-z0-9._~-]+$/.test(name)) throw new ProcessorNativeInvalid(name);
93
+ return new ProcessorBuilder({
94
+ ...this.state,
95
+ native: [.../* @__PURE__ */ new Set([...this.state.native, ...packages])]
96
+ });
97
+ }
98
+ /** Milliseconds a request may take, where the target bounds it. */
99
+ timeout(ms) {
100
+ return new ProcessorBuilder({
101
+ ...this.state,
102
+ timeout: ms
103
+ });
104
+ }
105
+ /** Megabytes of memory, where the target sets it. */
106
+ memorySize(mb) {
107
+ return new ProcessorBuilder({
108
+ ...this.state,
109
+ memorySize: mb
110
+ });
111
+ }
112
+ handle(fn) {
113
+ const { state } = this;
114
+ return new Processor(state.parsed, fn, {
115
+ surfaceId: state.surfaceId,
116
+ bucketId: state.bucketId,
117
+ origin: state.origin,
118
+ serves: state.serves,
119
+ ...state.paramsSchema ? { paramsSchema: state.paramsSchema } : {},
120
+ native: state.native,
121
+ logger: state.logger,
122
+ services: state.services,
123
+ constructs: state.constructs,
124
+ ...state.timeout !== void 0 ? { timeout: state.timeout } : {},
125
+ ...state.memorySize !== void 0 ? { memorySize: state.memorySize } : {}
126
+ });
127
+ }
128
+ };
129
+ //#endregion
130
+ //#region src/processors/pattern.ts
131
+ /** A pattern a processor cannot be served on. */
132
+ var ProcessorPatternInvalid = class extends Error {
133
+ pattern;
134
+ reason;
135
+ constructor(pattern, reason) {
136
+ super(`'${pattern}' is not a processor pattern: ${reason}. A pattern is a literal first segment, then any \`:name\` parameters, then \`*\` for the object's key — '/i/:width/*'.`);
137
+ this.pattern = pattern;
138
+ this.reason = reason;
139
+ this.name = "ProcessorPatternInvalid";
140
+ }
141
+ };
142
+ /** @throws {ProcessorPatternInvalid} */
143
+ function parsePattern(pattern) {
144
+ if (!pattern.startsWith("/")) throw new ProcessorPatternInvalid(pattern, "it does not start with /");
145
+ if (!pattern.endsWith("/*")) throw new ProcessorPatternInvalid(pattern, "it does not end with /* — the key");
146
+ const parts = pattern.slice(1, -2).split("/");
147
+ const segments = [];
148
+ const params = [];
149
+ for (const part of parts) {
150
+ if (part === "") throw new ProcessorPatternInvalid(pattern, "it has an empty segment");
151
+ if (part.includes("*")) throw new ProcessorPatternInvalid(pattern, "only its last segment may be *");
152
+ if (part.startsWith(":")) {
153
+ const name = part.slice(1);
154
+ if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name)) throw new ProcessorPatternInvalid(pattern, `'${part}' is not a parameter name`);
155
+ if (params.includes(name)) throw new ProcessorPatternInvalid(pattern, `'${name}' appears twice`);
156
+ params.push(name);
157
+ segments.push({
158
+ kind: "param",
159
+ name
160
+ });
161
+ continue;
162
+ }
163
+ if (!/^[A-Za-z0-9._~-]+$/.test(part)) throw new ProcessorPatternInvalid(pattern, `'${part}' has characters a path segment would escape`);
164
+ segments.push({
165
+ kind: "literal",
166
+ value: part
167
+ });
168
+ }
169
+ const first = segments[0];
170
+ if (!first || first.kind !== "literal") throw new ProcessorPatternInvalid(pattern, "its first segment is a parameter, which would claim every path");
171
+ const literals = [];
172
+ for (const segment of segments) {
173
+ if (segment.kind !== "literal") break;
174
+ literals.push(segment.value);
175
+ }
176
+ return {
177
+ pattern,
178
+ segments,
179
+ params,
180
+ prefix: `/${literals.join("/")}/`
181
+ };
182
+ }
183
+ /**
184
+ * Match a request path, decoding each parameter and each key segment. A path
185
+ * with an empty key, or one that decodes to a `..` segment, matches nothing.
186
+ */
187
+ function matchPattern(parsed, path) {
188
+ const parts = path.replace(/^\/+/, "").split("/");
189
+ if (parts.length <= parsed.segments.length) return void 0;
190
+ const params = {};
191
+ for (const [index, segment] of parsed.segments.entries()) {
192
+ const part = decode(parts[index] ?? "");
193
+ if (part === void 0 || part === "") return void 0;
194
+ if (segment.kind === "literal") {
195
+ if (part !== segment.value) return void 0;
196
+ continue;
197
+ }
198
+ params[segment.name] = part;
199
+ }
200
+ const keyParts = parts.slice(parsed.segments.length).map(decode);
201
+ if (keyParts.some((part) => part === void 0 || part === "..")) return;
202
+ const key = keyParts.join("/");
203
+ if (key === "" || keyParts.includes("")) return void 0;
204
+ return {
205
+ params,
206
+ key
207
+ };
208
+ }
209
+ /** The path that addresses `key` through the pattern with these parameters. */
210
+ function fillPattern(parsed, params, key) {
211
+ const head = parsed.segments.map((segment) => {
212
+ if (segment.kind === "literal") return segment.value;
213
+ const value = params[segment.name];
214
+ if (value === void 0 || `${value}` === "") throw new ProcessorParamMissing(parsed.pattern, segment.name);
215
+ return encodeURIComponent(`${value}`);
216
+ });
217
+ const tail = key.replace(/^\/+/, "").split("/").map((part) => encodeURIComponent(part));
218
+ return `/${[...head, ...tail].join("/")}`;
219
+ }
220
+ /** A processed URL was asked for without one of the pattern's parameters. */
221
+ var ProcessorParamMissing = class extends Error {
222
+ pattern;
223
+ param;
224
+ constructor(pattern, param) {
225
+ super(`'${pattern}' needs '${param}' to address an object, and it was not given.`);
226
+ this.pattern = pattern;
227
+ this.param = param;
228
+ this.name = "ProcessorParamMissing";
229
+ }
230
+ };
231
+ function decode(part) {
232
+ try {
233
+ return decodeURIComponent(part);
234
+ } catch {
235
+ return;
236
+ }
237
+ }
238
+ //#endregion
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
+
241
+ //# sourceMappingURL=pattern-C1CEcglD.mjs.map
@@ -0,0 +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 {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AAI,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,288 @@
1
+ const require_Construct = require("./Construct-DorKS0Ua.cjs");
2
+ const require_construct_interface = require("./construct-interface.cjs");
3
+ require("@geekmidas/manifest");
4
+ //#region src/processors/Processor.ts
5
+ /**
6
+ * A processor — a handler behind one path pattern of a file server, which
7
+ * makes a derivative of an open object on read: a thumbnail, a page of a PDF.
8
+ *
9
+ * Built from the file server (`assets.process('/i/:width/*')`), so it carries
10
+ * the bucket it reads and the open paths it may serve. Its parameters' schema
11
+ * is the allowlist: a request outside it is refused before anything runs, so
12
+ * nobody can mint new work — or new cache entries — by varying a number.
13
+ */
14
+ var Processor = class extends require_Construct.Construct {
15
+ parsed;
16
+ handler;
17
+ options;
18
+ __IS_PROCESSOR__ = true;
19
+ static isProcessor(obj) {
20
+ return Boolean(obj && obj.__IS_PROCESSOR__ === true && obj.type === "dev.geekmidas.function.processor");
21
+ }
22
+ constructor(parsed, handler, options) {
23
+ super("dev.geekmidas.function.processor", options.logger, [options.origin, ...options.services], [], void 0, options.timeout, options.memorySize, void 0, [.../* @__PURE__ */ new Set([options.bucketId, ...options.constructs])]);
24
+ this.parsed = parsed;
25
+ this.handler = handler;
26
+ this.options = options;
27
+ this.owner = options.surfaceId;
28
+ }
29
+ /** The pattern it answers, as written. */
30
+ get pattern() {
31
+ return this.parsed.pattern;
32
+ }
33
+ /** The literal path the edge routes to it — `/i/`. */
34
+ get prefix() {
35
+ return this.parsed.prefix;
36
+ }
37
+ get native() {
38
+ return this.options.native;
39
+ }
40
+ get surfaceId() {
41
+ return this.options.surfaceId;
42
+ }
43
+ get bucketId() {
44
+ return this.options.bucketId;
45
+ }
46
+ };
47
+ //#endregion
48
+ //#region src/processors/ProcessorBuilder.ts
49
+ /** A native package named in a way no installer could resolve. */
50
+ var ProcessorNativeInvalid = class extends Error {
51
+ packageName;
52
+ constructor(packageName) {
53
+ super(`'${packageName}' is not a package name. Name the package with native code as it is installed — 'sharp', '@napi-rs/canvas' — and its version is taken from the app's package.json.`);
54
+ this.packageName = packageName;
55
+ this.name = "ProcessorNativeInvalid";
56
+ }
57
+ };
58
+ /**
59
+ * What `fileServer.process(pattern)` returns: a processor, built up one
60
+ * immutable step at a time and finished by `.handle()`.
61
+ */
62
+ var ProcessorBuilder = class ProcessorBuilder {
63
+ state;
64
+ constructor(state) {
65
+ this.state = state;
66
+ }
67
+ /**
68
+ * The parameters' schema — the allowlist. Every request is parsed by it
69
+ * before anything runs, and one it refuses is answered 400.
70
+ */
71
+ params(schema) {
72
+ return new ProcessorBuilder({
73
+ ...this.state,
74
+ paramsSchema: schema
75
+ });
76
+ }
77
+ /** Constructs its handler reaches, as `services.<id>`. */
78
+ dependsOn(constructs) {
79
+ const services = require_construct_interface.servicesOf(constructs);
80
+ return new ProcessorBuilder({
81
+ ...this.state,
82
+ services: [...this.state.services.filter((service) => !services.some((s) => s.serviceName === service.serviceName)), ...services],
83
+ constructs: require_construct_interface.idsOf(constructs, this.state.constructs)
84
+ });
85
+ }
86
+ /**
87
+ * Packages with native code — `sharp` — installed for the target the
88
+ * processor runs on rather than bundled: linux in its image, arm64 on
89
+ * Lambda.
90
+ */
91
+ native(packages) {
92
+ for (const name of packages) if (!/^(@[a-z0-9._~-]+\/)?[a-z0-9._~-]+$/.test(name)) throw new ProcessorNativeInvalid(name);
93
+ return new ProcessorBuilder({
94
+ ...this.state,
95
+ native: [.../* @__PURE__ */ new Set([...this.state.native, ...packages])]
96
+ });
97
+ }
98
+ /** Milliseconds a request may take, where the target bounds it. */
99
+ timeout(ms) {
100
+ return new ProcessorBuilder({
101
+ ...this.state,
102
+ timeout: ms
103
+ });
104
+ }
105
+ /** Megabytes of memory, where the target sets it. */
106
+ memorySize(mb) {
107
+ return new ProcessorBuilder({
108
+ ...this.state,
109
+ memorySize: mb
110
+ });
111
+ }
112
+ handle(fn) {
113
+ const { state } = this;
114
+ return new Processor(state.parsed, fn, {
115
+ surfaceId: state.surfaceId,
116
+ bucketId: state.bucketId,
117
+ origin: state.origin,
118
+ serves: state.serves,
119
+ ...state.paramsSchema ? { paramsSchema: state.paramsSchema } : {},
120
+ native: state.native,
121
+ logger: state.logger,
122
+ services: state.services,
123
+ constructs: state.constructs,
124
+ ...state.timeout !== void 0 ? { timeout: state.timeout } : {},
125
+ ...state.memorySize !== void 0 ? { memorySize: state.memorySize } : {}
126
+ });
127
+ }
128
+ };
129
+ //#endregion
130
+ //#region src/processors/pattern.ts
131
+ /** A pattern a processor cannot be served on. */
132
+ var ProcessorPatternInvalid = class extends Error {
133
+ pattern;
134
+ reason;
135
+ constructor(pattern, reason) {
136
+ super(`'${pattern}' is not a processor pattern: ${reason}. A pattern is a literal first segment, then any \`:name\` parameters, then \`*\` for the object's key — '/i/:width/*'.`);
137
+ this.pattern = pattern;
138
+ this.reason = reason;
139
+ this.name = "ProcessorPatternInvalid";
140
+ }
141
+ };
142
+ /** @throws {ProcessorPatternInvalid} */
143
+ function parsePattern(pattern) {
144
+ if (!pattern.startsWith("/")) throw new ProcessorPatternInvalid(pattern, "it does not start with /");
145
+ if (!pattern.endsWith("/*")) throw new ProcessorPatternInvalid(pattern, "it does not end with /* — the key");
146
+ const parts = pattern.slice(1, -2).split("/");
147
+ const segments = [];
148
+ const params = [];
149
+ for (const part of parts) {
150
+ if (part === "") throw new ProcessorPatternInvalid(pattern, "it has an empty segment");
151
+ if (part.includes("*")) throw new ProcessorPatternInvalid(pattern, "only its last segment may be *");
152
+ if (part.startsWith(":")) {
153
+ const name = part.slice(1);
154
+ if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name)) throw new ProcessorPatternInvalid(pattern, `'${part}' is not a parameter name`);
155
+ if (params.includes(name)) throw new ProcessorPatternInvalid(pattern, `'${name}' appears twice`);
156
+ params.push(name);
157
+ segments.push({
158
+ kind: "param",
159
+ name
160
+ });
161
+ continue;
162
+ }
163
+ if (!/^[A-Za-z0-9._~-]+$/.test(part)) throw new ProcessorPatternInvalid(pattern, `'${part}' has characters a path segment would escape`);
164
+ segments.push({
165
+ kind: "literal",
166
+ value: part
167
+ });
168
+ }
169
+ const first = segments[0];
170
+ if (!first || first.kind !== "literal") throw new ProcessorPatternInvalid(pattern, "its first segment is a parameter, which would claim every path");
171
+ const literals = [];
172
+ for (const segment of segments) {
173
+ if (segment.kind !== "literal") break;
174
+ literals.push(segment.value);
175
+ }
176
+ return {
177
+ pattern,
178
+ segments,
179
+ params,
180
+ prefix: `/${literals.join("/")}/`
181
+ };
182
+ }
183
+ /**
184
+ * Match a request path, decoding each parameter and each key segment. A path
185
+ * with an empty key, or one that decodes to a `..` segment, matches nothing.
186
+ */
187
+ function matchPattern(parsed, path) {
188
+ const parts = path.replace(/^\/+/, "").split("/");
189
+ if (parts.length <= parsed.segments.length) return void 0;
190
+ const params = {};
191
+ for (const [index, segment] of parsed.segments.entries()) {
192
+ const part = decode(parts[index] ?? "");
193
+ if (part === void 0 || part === "") return void 0;
194
+ if (segment.kind === "literal") {
195
+ if (part !== segment.value) return void 0;
196
+ continue;
197
+ }
198
+ params[segment.name] = part;
199
+ }
200
+ const keyParts = parts.slice(parsed.segments.length).map(decode);
201
+ if (keyParts.some((part) => part === void 0 || part === "..")) return;
202
+ const key = keyParts.join("/");
203
+ if (key === "" || keyParts.includes("")) return void 0;
204
+ return {
205
+ params,
206
+ key
207
+ };
208
+ }
209
+ /** The path that addresses `key` through the pattern with these parameters. */
210
+ function fillPattern(parsed, params, key) {
211
+ const head = parsed.segments.map((segment) => {
212
+ if (segment.kind === "literal") return segment.value;
213
+ const value = params[segment.name];
214
+ if (value === void 0 || `${value}` === "") throw new ProcessorParamMissing(parsed.pattern, segment.name);
215
+ return encodeURIComponent(`${value}`);
216
+ });
217
+ const tail = key.replace(/^\/+/, "").split("/").map((part) => encodeURIComponent(part));
218
+ return `/${[...head, ...tail].join("/")}`;
219
+ }
220
+ /** A processed URL was asked for without one of the pattern's parameters. */
221
+ var ProcessorParamMissing = class extends Error {
222
+ pattern;
223
+ param;
224
+ constructor(pattern, param) {
225
+ super(`'${pattern}' needs '${param}' to address an object, and it was not given.`);
226
+ this.pattern = pattern;
227
+ this.param = param;
228
+ this.name = "ProcessorParamMissing";
229
+ }
230
+ };
231
+ function decode(part) {
232
+ try {
233
+ return decodeURIComponent(part);
234
+ } catch {
235
+ return;
236
+ }
237
+ }
238
+ //#endregion
239
+ Object.defineProperty(exports, "Processor", {
240
+ enumerable: true,
241
+ get: function() {
242
+ return Processor;
243
+ }
244
+ });
245
+ Object.defineProperty(exports, "ProcessorBuilder", {
246
+ enumerable: true,
247
+ get: function() {
248
+ return ProcessorBuilder;
249
+ }
250
+ });
251
+ Object.defineProperty(exports, "ProcessorNativeInvalid", {
252
+ enumerable: true,
253
+ get: function() {
254
+ return ProcessorNativeInvalid;
255
+ }
256
+ });
257
+ Object.defineProperty(exports, "ProcessorParamMissing", {
258
+ enumerable: true,
259
+ get: function() {
260
+ return ProcessorParamMissing;
261
+ }
262
+ });
263
+ Object.defineProperty(exports, "ProcessorPatternInvalid", {
264
+ enumerable: true,
265
+ get: function() {
266
+ return ProcessorPatternInvalid;
267
+ }
268
+ });
269
+ Object.defineProperty(exports, "fillPattern", {
270
+ enumerable: true,
271
+ get: function() {
272
+ return fillPattern;
273
+ }
274
+ });
275
+ Object.defineProperty(exports, "matchPattern", {
276
+ enumerable: true,
277
+ get: function() {
278
+ return matchPattern;
279
+ }
280
+ });
281
+ Object.defineProperty(exports, "parsePattern", {
282
+ enumerable: true,
283
+ get: function() {
284
+ return parsePattern;
285
+ }
286
+ });
287
+
288
+ //# sourceMappingURL=pattern-QFaUIr77.cjs.map