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

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 (127) hide show
  1. package/README.md +2 -1
  2. package/dist/{Construct-CRV3RN2U.mjs → Construct-CGuc_Ijk.mjs} +2 -11
  3. package/dist/{Construct-CRV3RN2U.mjs.map → Construct-CGuc_Ijk.mjs.map} +1 -1
  4. package/dist/{Construct-B8yWxGlR.cjs → Construct-DorKS0Ua.cjs} +2 -2
  5. package/dist/{Construct-B8yWxGlR.cjs.map → Construct-DorKS0Ua.cjs.map} +1 -1
  6. package/dist/{CronBuilder-CukJuL3b.mjs → CronBuilder-BJ5LoadF.mjs} +3 -3
  7. package/dist/{CronBuilder-CukJuL3b.mjs.map → CronBuilder-BJ5LoadF.mjs.map} +1 -1
  8. package/dist/{CronBuilder-B4DYaEjl.cjs → CronBuilder-B_NSP-Y5.cjs} +4 -4
  9. package/dist/{CronBuilder-B4DYaEjl.cjs.map → CronBuilder-B_NSP-Y5.cjs.map} +1 -1
  10. package/dist/{Endpoint-D2ckHqIx.cjs → Endpoint-52z1P0Ue.cjs} +3 -3
  11. package/dist/{Endpoint-D2ckHqIx.cjs.map → Endpoint-52z1P0Ue.cjs.map} +1 -1
  12. package/dist/{Endpoint-BuKHHVZc.mjs → Endpoint-sUOU7uLx.mjs} +3 -3
  13. package/dist/{Endpoint-BuKHHVZc.mjs.map → Endpoint-sUOU7uLx.mjs.map} +1 -1
  14. package/dist/{EndpointFactory-BsJUlUyL.mjs → EndpointFactory-Bzi9Sl7r.mjs} +4 -4
  15. package/dist/{EndpointFactory-BsJUlUyL.mjs.map → EndpointFactory-Bzi9Sl7r.mjs.map} +1 -1
  16. package/dist/{EndpointFactory-c4tHjQKM.cjs → EndpointFactory-Cf_Cs1ym.cjs} +5 -5
  17. package/dist/{EndpointFactory-c4tHjQKM.cjs.map → EndpointFactory-Cf_Cs1ym.cjs.map} +1 -1
  18. package/dist/{HonoEndpointAdaptor-BGEW1Tu8.cjs → HonoEndpointAdaptor-BTbqfSaa.cjs} +40 -15
  19. package/dist/HonoEndpointAdaptor-BTbqfSaa.cjs.map +1 -0
  20. package/dist/{HonoEndpointAdaptor-BC7CZ7Cr.mjs → HonoEndpointAdaptor-CBVey2cY.mjs} +40 -15
  21. package/dist/HonoEndpointAdaptor-CBVey2cY.mjs.map +1 -0
  22. package/dist/{Queue-DZpV13LN.cjs → Queue-D4Iaidrs.cjs} +2 -2
  23. package/dist/{Queue-DZpV13LN.cjs.map → Queue-D4Iaidrs.cjs.map} +1 -1
  24. package/dist/{Queue-0FpvxdOa.mjs → Queue-u8w8_HpE.mjs} +2 -2
  25. package/dist/{Queue-0FpvxdOa.mjs.map → Queue-u8w8_HpE.mjs.map} +1 -1
  26. package/dist/{QueueBuilder-Bmyay_Di.mjs → QueueBuilder-2wP5lEC8.mjs} +2 -2
  27. package/dist/{QueueBuilder-Bmyay_Di.mjs.map → QueueBuilder-2wP5lEC8.mjs.map} +1 -1
  28. package/dist/{QueueBuilder-FXkSDah1.cjs → QueueBuilder-BxsZ9o5z.cjs} +2 -2
  29. package/dist/{QueueBuilder-FXkSDah1.cjs.map → QueueBuilder-BxsZ9o5z.cjs.map} +1 -1
  30. package/dist/{SubscriberBuilder-CxG1OOug.mjs → SubscriberBuilder-CpFhShTJ.mjs} +2 -2
  31. package/dist/{SubscriberBuilder-CxG1OOug.mjs.map → SubscriberBuilder-CpFhShTJ.mjs.map} +1 -1
  32. package/dist/{SubscriberBuilder-Bfn-iDSk.cjs → SubscriberBuilder-DJEvNRdD.cjs} +2 -2
  33. package/dist/{SubscriberBuilder-Bfn-iDSk.cjs.map → SubscriberBuilder-DJEvNRdD.cjs.map} +1 -1
  34. package/dist/{Topic-DoEdDgh7.mjs → Topic-DN2gYJ-p.mjs} +2 -2
  35. package/dist/{Topic-DoEdDgh7.mjs.map → Topic-DN2gYJ-p.mjs.map} +1 -1
  36. package/dist/{Topic-t5GhqaeT.cjs → Topic-Dp9Q7Lj2.cjs} +2 -2
  37. package/dist/{Topic-t5GhqaeT.cjs.map → Topic-Dp9Q7Lj2.cjs.map} +1 -1
  38. package/dist/adaptors/aws.cjs +3 -10
  39. package/dist/adaptors/aws.cjs.map +1 -1
  40. package/dist/adaptors/aws.d.cts +0 -141
  41. package/dist/adaptors/aws.d.cts.map +1 -1
  42. package/dist/adaptors/aws.d.mts +0 -141
  43. package/dist/adaptors/aws.d.mts.map +1 -1
  44. package/dist/adaptors/aws.mjs +3 -4
  45. package/dist/adaptors/aws.mjs.map +1 -1
  46. package/dist/{apigateway-zHDoMwlI.cjs → adaptors/awsWebsocket.cjs} +125 -141
  47. package/dist/adaptors/awsWebsocket.cjs.map +1 -0
  48. package/dist/adaptors/awsWebsocket.d.cts +156 -0
  49. package/dist/adaptors/awsWebsocket.d.cts.map +1 -0
  50. package/dist/adaptors/awsWebsocket.d.mts +156 -0
  51. package/dist/adaptors/awsWebsocket.d.mts.map +1 -0
  52. package/dist/{apigateway-Dyjy_JwI.mjs → adaptors/awsWebsocket.mjs} +119 -101
  53. package/dist/adaptors/awsWebsocket.mjs.map +1 -0
  54. package/dist/adaptors/hono.cjs +1 -1
  55. package/dist/adaptors/hono.d.cts +3 -1
  56. package/dist/adaptors/hono.d.cts.map +1 -1
  57. package/dist/adaptors/hono.d.mts +3 -1
  58. package/dist/adaptors/hono.d.mts.map +1 -1
  59. package/dist/adaptors/hono.mjs +1 -1
  60. package/dist/adaptors/testing.cjs +8 -8
  61. package/dist/adaptors/testing.d.cts +1 -1
  62. package/dist/adaptors/testing.d.mts +1 -1
  63. package/dist/adaptors/testing.mjs +6 -6
  64. package/dist/crons/index.cjs +2 -2
  65. package/dist/crons/index.mjs +2 -2
  66. package/dist/database/kysely.cjs +1 -1
  67. package/dist/endpoints/index.cjs +3 -3
  68. package/dist/endpoints/index.mjs +3 -3
  69. package/dist/file-server.cjs +1 -1
  70. package/dist/file-server.mjs +1 -1
  71. package/dist/functions/index.cjs +1 -1
  72. package/dist/functions/index.mjs +1 -1
  73. package/dist/{functions-BF039DT8.mjs → functions-BvIDQKAA.mjs} +2 -2
  74. package/dist/{functions-BF039DT8.mjs.map → functions-BvIDQKAA.mjs.map} +1 -1
  75. package/dist/{functions-BqAq_0xQ.cjs → functions-DLF6-IK8.cjs} +3 -3
  76. package/dist/{functions-BqAq_0xQ.cjs.map → functions-DLF6-IK8.cjs.map} +1 -1
  77. package/dist/inbox.cjs +1 -1
  78. package/dist/inbox.mjs +1 -1
  79. package/dist/index.cjs +1 -1
  80. package/dist/index.mjs +1 -1
  81. package/dist/{kysely-CeoQdAkg.cjs → kysely-CukArHJ0.cjs} +2 -2
  82. package/dist/{kysely-CeoQdAkg.cjs.map → kysely-CukArHJ0.cjs.map} +1 -1
  83. package/dist/origins-BjxYht13.cjs +96 -0
  84. package/dist/origins-BjxYht13.cjs.map +1 -0
  85. package/dist/origins-Boc9qbo-.mjs +73 -0
  86. package/dist/origins-Boc9qbo-.mjs.map +1 -0
  87. package/dist/{pattern-YSqfAhXm.mjs → pattern-C1CEcglD.mjs} +2 -2
  88. package/dist/{pattern-YSqfAhXm.mjs.map → pattern-C1CEcglD.mjs.map} +1 -1
  89. package/dist/{pattern-HnNOPhE2.cjs → pattern-QFaUIr77.cjs} +2 -2
  90. package/dist/{pattern-HnNOPhE2.cjs.map → pattern-QFaUIr77.cjs.map} +1 -1
  91. package/dist/processors/index.cjs +1 -1
  92. package/dist/processors/index.mjs +1 -1
  93. package/dist/queue/index.cjs +2 -2
  94. package/dist/queue/index.mjs +2 -2
  95. package/dist/rest-api.cjs +1 -1
  96. package/dist/rest-api.mjs +1 -1
  97. package/dist/{rolldown-runtime-Ctb5zv51.cjs → rolldown-runtime-y5ARvAq5.cjs} +0 -15
  98. package/dist/subscribers/index.cjs +1 -1
  99. package/dist/subscribers/index.mjs +1 -1
  100. package/dist/topic/index.cjs +1 -1
  101. package/dist/topic/index.mjs +1 -1
  102. package/dist/{websocket-api-BvKS9x-l.mjs → websocket-api-Bg9SowJ5.mjs} +12 -13
  103. package/dist/{websocket-api-BvKS9x-l.mjs.map → websocket-api-Bg9SowJ5.mjs.map} +1 -1
  104. package/dist/{websocket-api-CDAxOTQZ.d.mts → websocket-api-CPEzJyDt.d.mts} +22 -2
  105. package/dist/websocket-api-CPEzJyDt.d.mts.map +1 -0
  106. package/dist/{websocket-api-C3dWKNxO.d.cts → websocket-api-DkF8Hva-.d.cts} +22 -2
  107. package/dist/websocket-api-DkF8Hva-.d.cts.map +1 -0
  108. package/dist/{websocket-api-CAQA_QOE.cjs → websocket-api-czxhekGG.cjs} +12 -13
  109. package/dist/websocket-api-czxhekGG.cjs.map +1 -0
  110. package/dist/websocket-api.cjs +4 -1
  111. package/dist/websocket-api.d.cts +2 -2
  112. package/dist/websocket-api.d.mts +2 -2
  113. package/dist/websocket-api.mjs +3 -2
  114. package/dist/worker.cjs +4 -4
  115. package/dist/worker.mjs +4 -4
  116. package/package.json +47 -31
  117. package/dist/HonoEndpointAdaptor-BC7CZ7Cr.mjs.map +0 -1
  118. package/dist/HonoEndpointAdaptor-BGEW1Tu8.cjs.map +0 -1
  119. package/dist/apigateway-Dyjy_JwI.mjs.map +0 -1
  120. package/dist/apigateway-zHDoMwlI.cjs.map +0 -1
  121. package/dist/origins-C7T9covD.cjs +0 -24
  122. package/dist/origins-C7T9covD.cjs.map +0 -1
  123. package/dist/origins-CX6Ot7ax.mjs +0 -19
  124. package/dist/origins-CX6Ot7ax.mjs.map +0 -1
  125. package/dist/websocket-api-C3dWKNxO.d.cts.map +0 -1
  126. package/dist/websocket-api-CAQA_QOE.cjs.map +0 -1
  127. package/dist/websocket-api-CDAxOTQZ.d.mts.map +0 -1
@@ -1 +1 @@
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,C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;EACH,OAAO,mBAAmB,IAAI;CAC/B,QAAQ;EACP;CACD;AACD"}
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,kB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AGA,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,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_pattern = require("../pattern-HnNOPhE2.cjs");
2
+ const require_pattern = require("../pattern-QFaUIr77.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 { 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";
1
+ import { a as parsePattern, c as DERIVED_PREFIX, i as matchPattern, l as Processor, n as ProcessorPatternInvalid, o as ProcessorBuilder, r as fillPattern, s as ProcessorNativeInvalid, t as ProcessorParamMissing } from "../pattern-C1CEcglD.mjs";
2
2
  import { t as defaultEnvParser } from "../surfaceEnv-wMT5QzgZ.mjs";
3
3
  import { ServiceDiscovery, runWithRequestContext } from "@geekmidas/services";
4
4
  //#region src/processors/runProcessor.ts
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_Queue = require("../Queue-DZpV13LN.cjs");
3
- const require_QueueBuilder = require("../QueueBuilder-FXkSDah1.cjs");
2
+ const require_Queue = require("../Queue-D4Iaidrs.cjs");
3
+ const require_QueueBuilder = require("../QueueBuilder-BxsZ9o5z.cjs");
4
4
  exports.Queue = require_Queue.Queue;
5
5
  exports.QueueNeedsMessage = require_QueueBuilder.QueueNeedsMessage;
6
6
  exports.QueueNeedsName = require_QueueBuilder.QueueNeedsName;
@@ -1,3 +1,3 @@
1
- import { t as Queue } from "../Queue-0FpvxdOa.mjs";
2
- import { n as QueueNeedsMessage, r as QueueNeedsName } from "../QueueBuilder-Bmyay_Di.mjs";
1
+ import { t as Queue } from "../Queue-u8w8_HpE.mjs";
2
+ import { n as QueueNeedsMessage, r as QueueNeedsName } from "../QueueBuilder-2wP5lEC8.mjs";
3
3
  export { Queue, QueueNeedsMessage, QueueNeedsName };
package/dist/rest-api.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_construct_interface = require("./construct-interface.cjs");
3
- const require_EndpointFactory = require("./EndpointFactory-c4tHjQKM.cjs");
3
+ const require_EndpointFactory = require("./EndpointFactory-Cf_Cs1ym.cjs");
4
4
  const require_surfaceEnv = require("./surfaceEnv-CNimK76p.cjs");
5
5
  let _geekmidas_manifest = require("@geekmidas/manifest");
6
6
  let _geekmidas_logger_console = require("@geekmidas/logger/console");
package/dist/rest-api.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { edgeTo, publicUrl } from "./construct-interface.mjs";
2
- import { p as getSecurityScheme, t as EndpointFactory } from "./EndpointFactory-BsJUlUyL.mjs";
2
+ import { p as getSecurityScheme, t as EndpointFactory } from "./EndpointFactory-Bzi9Sl7r.mjs";
3
3
  import { n as envParserFor } from "./surfaceEnv-wMT5QzgZ.mjs";
4
4
  import { canonicalId, provideKey, serviceKey } from "@geekmidas/manifest";
5
5
  import { DEFAULT_LOGGER } from "@geekmidas/logger/console";
@@ -6,15 +6,6 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
8
  var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
9
- var __exportAll = (all, no_symbols) => {
10
- let target = {};
11
- for (var name in all) __defProp(target, name, {
12
- get: all[name],
13
- enumerable: true
14
- });
15
- if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
16
- return target;
17
- };
18
9
  var __copyProps = (to, from, except, desc) => {
19
10
  if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
20
11
  key = keys[i];
@@ -36,12 +27,6 @@ Object.defineProperty(exports, "__commonJSMin", {
36
27
  return __commonJSMin;
37
28
  }
38
29
  });
39
- Object.defineProperty(exports, "__exportAll", {
40
- enumerable: true,
41
- get: function() {
42
- return __exportAll;
43
- }
44
- });
45
30
  Object.defineProperty(exports, "__toESM", {
46
31
  enumerable: true,
47
32
  get: function() {
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_SubscriberBuilder = require("../SubscriberBuilder-Bfn-iDSk.cjs");
2
+ const require_SubscriberBuilder = require("../SubscriberBuilder-DJEvNRdD.cjs");
3
3
  const require_runSubscriber = require("../runSubscriber-sVJfLA0-.cjs");
4
4
  let _geekmidas_events = require("@geekmidas/events");
5
5
  let _geekmidas_services = require("@geekmidas/services");
@@ -1,4 +1,4 @@
1
- import { i as ObjectSubscriberHasNoEvents, n as Subscriber, r as ObjectSubscriberBuilder, t as SubscriberBuilder } from "../SubscriberBuilder-CxG1OOug.mjs";
1
+ import { i as ObjectSubscriberHasNoEvents, n as Subscriber, r as ObjectSubscriberBuilder, t as SubscriberBuilder } from "../SubscriberBuilder-CpFhShTJ.mjs";
2
2
  import { n as subscribedEvents, r as subscriberContext, t as runSubscriber } from "../runSubscriber-HEqXkin1.mjs";
3
3
  import { carrierFromAttributes, consumeTraced } from "@geekmidas/events";
4
4
  import { runWithRequestContext } from "@geekmidas/services";
@@ -1,3 +1,3 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_Topic = require("../Topic-t5GhqaeT.cjs");
2
+ const require_Topic = require("../Topic-Dp9Q7Lj2.cjs");
3
3
  exports.Topic = require_Topic.Topic;
@@ -1,2 +1,2 @@
1
- import { t as Topic } from "../Topic-DoEdDgh7.mjs";
1
+ import { t as Topic } from "../Topic-DN2gYJ-p.mjs";
2
2
  export { Topic };
@@ -3,7 +3,7 @@ import { edgeTo, idsOf, servicesOf } from "./construct-interface.mjs";
3
3
  import { c as loadHono, m as loadWs, u as loadIoredis } from "./optionalPeers-D7Wt6dnF.mjs";
4
4
  import { t as isPrivateAddress } from "./privateAddress-Bg5fUsbp.mjs";
5
5
  import { n as envParserFor } from "./surfaceEnv-wMT5QzgZ.mjs";
6
- import { t as ownOrigins } from "./origins-CX6Ot7ax.mjs";
6
+ import { i as webSocketSinkDriverFor, n as UnregisteredWebSocketScheme, t as ownOrigins } from "./origins-Boc9qbo-.mjs";
7
7
  import { API_GATEWAY_WEBSOCKET_SCHEME, canonicalId, provideKey, serviceKey, trustsOrigin } from "@geekmidas/manifest";
8
8
  import { DEFAULT_LOGGER } from "@geekmidas/logger/console";
9
9
  import { randomBytes } from "node:crypto";
@@ -1524,7 +1524,7 @@ var WebSocketApi = class WebSocketApi {
1524
1524
  serviceName: serviceKey(canonical),
1525
1525
  register: async ({ envParser }) => {
1526
1526
  const { connectionString } = envParser.create((get) => ({ connectionString: get(envVar).string() })).parse();
1527
- return this.publisher(await sinkFromConnectionString(connectionString, channel));
1527
+ return this.publisher(await sinkFromConnectionString(this.id, connectionString, channel));
1528
1528
  }
1529
1529
  };
1530
1530
  }
@@ -1685,18 +1685,17 @@ var WebSocketApi = class WebSocketApi {
1685
1685
  }
1686
1686
  };
1687
1687
  /**
1688
- * Where `services.<surface>` sends, by the publisher string's scheme: on an
1689
- * AWS stage (`apigateway://`) the gateway's management API, which holds every
1690
- * socket; anywhere else (`redis://`, `memory://`) whichever process does.
1688
+ * Where `services.<surface>` sends, by the publisher string's scheme: a
1689
+ * registered driver's sink — API Gateway's management API on an AWS stage,
1690
+ * registered by the build's entry — or else whichever process holds the
1691
+ * sockets (`redis://`, `memory://`).
1691
1692
  *
1692
- * The API Gateway sink is loaded only for its scheme, so a server stage never
1693
- * resolves it — nor the AWS SDK it loads in turn.
1693
+ * @throws {UnregisteredWebSocketScheme} for `apigateway://` with no driver.
1694
1694
  */
1695
- async function sinkFromConnectionString(connectionString, channel) {
1696
- if (connectionString.startsWith(API_GATEWAY_WEBSOCKET_SCHEME)) {
1697
- const { apiGatewayFromConnectionString } = await import("./apigateway-Dyjy_JwI.mjs").then((n) => n.s);
1698
- return apiGatewayFromConnectionString(connectionString).sink;
1699
- }
1695
+ async function sinkFromConnectionString(surface, connectionString, channel) {
1696
+ const driver = webSocketSinkDriverFor(connectionString);
1697
+ if (driver) return driver.sink(connectionString);
1698
+ if (connectionString.startsWith(API_GATEWAY_WEBSOCKET_SCHEME)) throw new UnregisteredWebSocketScheme(surface, API_GATEWAY_WEBSOCKET_SCHEME);
1700
1699
  const transport = await transportFromConnectionString(connectionString, channel);
1701
1700
  onShutdown(() => transport.close());
1702
1701
  return new TransportSink(transport);
@@ -1708,4 +1707,4 @@ function channelOf(id) {
1708
1707
  //#endregion
1709
1708
  export { WebSocketMessageNotAnObject as A, WebSocketCore as C, WebSocketDataHasDiscriminator as D, WebSocketPublisher as E, WebSocketDataNotAnObject as O, DuplicateWebSocketRoute as S, UnknownWebSocketMessage as T, LIMIT_CLOSE as _, MemoryTransport as a, TokenBucket as b, UnsupportedWebSocketTransport as c, WebSocketRouteBuilder as d, InvalidWebSocketRequest as f, InvalidWebSocketLimit as g, DEFAULT_WEBSOCKET_LIMITS as h, WebSocketSurfaceServer as i, WebSocketMessageDeclaresDiscriminator as k, transportFromConnectionString as l, TestWebSocketPublisher as m, WebSocketApi as n, RedisTransport as o, RecordingSink as p, CLOSE as r, TransportSink as s, InvalidReplicaCount as t, WebSocketRoute as u, MemoryLimitStore as v, InvalidWebSocketMessage as w, resolveLimits as x, RedisLimitStore as y };
1710
1709
 
1711
- //# sourceMappingURL=websocket-api-BvKS9x-l.mjs.map
1710
+ //# sourceMappingURL=websocket-api-Bg9SowJ5.mjs.map