@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.
- package/dist/{Construct-CFW0zjdD.d.cts → Construct-127M7yrl.d.cts} +3 -2
- package/dist/{Construct-B7AXn0xH.d.mts.map → Construct-127M7yrl.d.cts.map} +1 -1
- package/dist/{Construct-CKUA-CTA.mjs → Construct-CGuc_Ijk.mjs} +2 -1
- package/dist/{Construct-CKUA-CTA.mjs.map → Construct-CGuc_Ijk.mjs.map} +1 -1
- package/dist/{Construct-DEOVauyA.cjs → Construct-DorKS0Ua.cjs} +2 -1
- package/dist/{Construct-DEOVauyA.cjs.map → Construct-DorKS0Ua.cjs.map} +1 -1
- package/dist/{Construct-B7AXn0xH.d.mts → Construct-DySlwh8o.d.mts} +3 -2
- package/dist/{Construct-CFW0zjdD.d.cts.map → Construct-DySlwh8o.d.mts.map} +1 -1
- package/dist/{Cron-bdGRSROY.d.cts → Cron-CFkpEys6.d.cts} +4 -4
- package/dist/{Cron-bdGRSROY.d.cts.map → Cron-CFkpEys6.d.cts.map} +1 -1
- package/dist/{Cron-i4Uetezh.d.mts → Cron-CQoDSu-n.d.mts} +4 -4
- package/dist/{Cron-i4Uetezh.d.mts.map → Cron-CQoDSu-n.d.mts.map} +1 -1
- package/dist/{CronBuilder-9H4BnD6W.d.mts → CronBuilder-1W-G_i15.d.mts} +5 -5
- package/dist/{CronBuilder-9H4BnD6W.d.mts.map → CronBuilder-1W-G_i15.d.mts.map} +1 -1
- package/dist/{CronBuilder-D3sF9tS_.mjs → CronBuilder-BJ5LoadF.mjs} +3 -3
- package/dist/{CronBuilder-D3sF9tS_.mjs.map → CronBuilder-BJ5LoadF.mjs.map} +1 -1
- package/dist/{CronBuilder-BXTG10u5.cjs → CronBuilder-B_NSP-Y5.cjs} +3 -3
- package/dist/{CronBuilder-BXTG10u5.cjs.map → CronBuilder-B_NSP-Y5.cjs.map} +1 -1
- package/dist/{CronBuilder-B_24LZpn.d.cts → CronBuilder-OaCRRFVk.d.cts} +5 -5
- package/dist/{CronBuilder-B_24LZpn.d.cts.map → CronBuilder-OaCRRFVk.d.cts.map} +1 -1
- package/dist/{Endpoint-DgrpG15P.d.cts → Endpoint-BEh-jW-f.d.cts} +4 -4
- package/dist/{Endpoint-CeFkSwh5.d.mts.map → Endpoint-BEh-jW-f.d.cts.map} +1 -1
- package/dist/{Endpoint-yhR2T2Wt.cjs → Endpoint-BuGFNFSB.cjs} +3 -3
- package/dist/{Endpoint-yhR2T2Wt.cjs.map → Endpoint-BuGFNFSB.cjs.map} +1 -1
- package/dist/{Endpoint-CeFkSwh5.d.mts → Endpoint-DTXDggNl.d.mts} +4 -4
- package/dist/{Endpoint-DgrpG15P.d.cts.map → Endpoint-DTXDggNl.d.mts.map} +1 -1
- package/dist/{Endpoint-gPXhHKhJ.mjs → Endpoint-VdaYKc2g.mjs} +3 -3
- package/dist/{Endpoint-gPXhHKhJ.mjs.map → Endpoint-VdaYKc2g.mjs.map} +1 -1
- package/dist/{EndpointFactory-Cc863XJS.d.cts → EndpointFactory-B2dCS9dy.d.cts} +4 -4
- package/dist/{EndpointFactory-Dbw9ugkX.d.mts.map → EndpointFactory-B2dCS9dy.d.cts.map} +1 -1
- package/dist/{EndpointFactory-CSrAyazj.cjs → EndpointFactory-C6pVda4y.cjs} +4 -4
- package/dist/{EndpointFactory-CSrAyazj.cjs.map → EndpointFactory-C6pVda4y.cjs.map} +1 -1
- package/dist/{EndpointFactory-c2ZugGig.mjs → EndpointFactory-CUpqgtaH.mjs} +4 -4
- package/dist/{EndpointFactory-c2ZugGig.mjs.map → EndpointFactory-CUpqgtaH.mjs.map} +1 -1
- package/dist/{EndpointFactory-Dbw9ugkX.d.mts → EndpointFactory-D2HXcUrJ.d.mts} +4 -4
- package/dist/{EndpointFactory-Cc863XJS.d.cts.map → EndpointFactory-D2HXcUrJ.d.mts.map} +1 -1
- package/dist/{Function-B0uZhZnU.d.cts → Function-BIEsY0Hm.d.cts} +2 -2
- package/dist/{Function-B0uZhZnU.d.cts.map → Function-BIEsY0Hm.d.cts.map} +1 -1
- package/dist/{Function-B_9R7Zy1.d.mts → Function-DfMzTGS4.d.mts} +2 -2
- package/dist/{Function-B_9R7Zy1.d.mts.map → Function-DfMzTGS4.d.mts.map} +1 -1
- package/dist/{HonoEndpointAdaptor-CN1jjUBJ.cjs → HonoEndpointAdaptor-BBTzbP38.cjs} +3 -3
- package/dist/{HonoEndpointAdaptor-CN1jjUBJ.cjs.map → HonoEndpointAdaptor-BBTzbP38.cjs.map} +1 -1
- package/dist/{HonoEndpointAdaptor-euH1oSdY.mjs → HonoEndpointAdaptor-BR_LyaFE.mjs} +3 -3
- package/dist/{HonoEndpointAdaptor-euH1oSdY.mjs.map → HonoEndpointAdaptor-BR_LyaFE.mjs.map} +1 -1
- package/dist/{ObjectSubscriberBuilder-C0WUU-ov.d.mts → ObjectSubscriberBuilder-HmBwFn2o.d.mts} +4 -4
- package/dist/{ObjectSubscriberBuilder-B4j3zgCZ.d.cts.map → ObjectSubscriberBuilder-HmBwFn2o.d.mts.map} +1 -1
- package/dist/{ObjectSubscriberBuilder-B4j3zgCZ.d.cts → ObjectSubscriberBuilder-l-64yUiF.d.cts} +4 -4
- package/dist/{ObjectSubscriberBuilder-C0WUU-ov.d.mts.map → ObjectSubscriberBuilder-l-64yUiF.d.cts.map} +1 -1
- package/dist/ProcessorBuilder-B2_stA8f.d.mts +216 -0
- package/dist/ProcessorBuilder-B2_stA8f.d.mts.map +1 -0
- package/dist/ProcessorBuilder-C62bIOwj.d.cts +216 -0
- package/dist/ProcessorBuilder-C62bIOwj.d.cts.map +1 -0
- package/dist/{Queue-B-dDXyjF.d.mts → Queue-BnK3UH8r.d.mts} +3 -3
- package/dist/{Queue-B-dDXyjF.d.mts.map → Queue-BnK3UH8r.d.mts.map} +1 -1
- package/dist/{Queue-JbIjVtTf.d.cts → Queue-C4rijiM7.d.cts} +3 -3
- package/dist/{Queue-JbIjVtTf.d.cts.map → Queue-C4rijiM7.d.cts.map} +1 -1
- package/dist/{Queue-BhuofM3k.cjs → Queue-D4Iaidrs.cjs} +3 -3
- package/dist/{Queue-BhuofM3k.cjs.map → Queue-D4Iaidrs.cjs.map} +1 -1
- package/dist/{Queue-cmhqEBOB.mjs → Queue-u8w8_HpE.mjs} +3 -3
- package/dist/{Queue-cmhqEBOB.mjs.map → Queue-u8w8_HpE.mjs.map} +1 -1
- package/dist/{QueueBuilder-DXu1qxT1.mjs → QueueBuilder-2wP5lEC8.mjs} +2 -2
- package/dist/{QueueBuilder-DXu1qxT1.mjs.map → QueueBuilder-2wP5lEC8.mjs.map} +1 -1
- package/dist/{QueueBuilder-48W-q8In.d.mts → QueueBuilder-B3vL1ED2.d.mts} +2 -2
- package/dist/{QueueBuilder-48W-q8In.d.mts.map → QueueBuilder-B3vL1ED2.d.mts.map} +1 -1
- package/dist/{QueueBuilder-MfpkJ3R9.d.cts → QueueBuilder-BcPBQSSX.d.cts} +2 -2
- package/dist/{QueueBuilder-MfpkJ3R9.d.cts.map → QueueBuilder-BcPBQSSX.d.cts.map} +1 -1
- package/dist/{QueueBuilder-DdU2klPu.cjs → QueueBuilder-BxsZ9o5z.cjs} +2 -2
- package/dist/{QueueBuilder-DdU2klPu.cjs.map → QueueBuilder-BxsZ9o5z.cjs.map} +1 -1
- package/dist/{Subscriber-Bfw5cqzz.d.cts → Subscriber-BdCtfFXL.d.cts} +3 -3
- package/dist/{Subscriber-Bfw5cqzz.d.cts.map → Subscriber-BdCtfFXL.d.cts.map} +1 -1
- package/dist/{Subscriber-Czs77h-H.d.mts → Subscriber-DDo4HFNn.d.mts} +3 -3
- package/dist/{Subscriber-Czs77h-H.d.mts.map → Subscriber-DDo4HFNn.d.mts.map} +1 -1
- package/dist/{SubscriberBuilder-DUMXzjbR.mjs → SubscriberBuilder-3msj1U2w.mjs} +2 -2
- package/dist/{SubscriberBuilder-DUMXzjbR.mjs.map → SubscriberBuilder-3msj1U2w.mjs.map} +1 -1
- package/dist/{SubscriberBuilder-CYluzubx.cjs → SubscriberBuilder-CQst6Iz3.cjs} +2 -2
- package/dist/{SubscriberBuilder-CYluzubx.cjs.map → SubscriberBuilder-CQst6Iz3.cjs.map} +1 -1
- package/dist/{Topic-D2R0r24C.mjs → Topic-DN2gYJ-p.mjs} +3 -3
- package/dist/{Topic-D2R0r24C.mjs.map → Topic-DN2gYJ-p.mjs.map} +1 -1
- package/dist/{Topic-DwS3QO0m.cjs → Topic-Dp9Q7Lj2.cjs} +3 -3
- package/dist/{Topic-DwS3QO0m.cjs.map → Topic-Dp9Q7Lj2.cjs.map} +1 -1
- package/dist/adaptors/aws.cjs +2 -2
- package/dist/adaptors/aws.d.cts +5 -5
- package/dist/adaptors/aws.d.mts +5 -5
- package/dist/adaptors/aws.mjs +3 -3
- package/dist/adaptors/hono.cjs +1 -1
- package/dist/adaptors/hono.d.cts +1 -1
- package/dist/adaptors/hono.d.mts +1 -1
- package/dist/adaptors/hono.mjs +1 -1
- package/dist/adaptors/testing.cjs +5 -5
- package/dist/adaptors/testing.d.cts +4 -4
- package/dist/adaptors/testing.d.mts +4 -4
- package/dist/adaptors/testing.mjs +5 -5
- package/dist/crons/index.cjs +2 -2
- package/dist/crons/index.d.cts +2 -2
- package/dist/crons/index.d.mts +2 -2
- package/dist/crons/index.mjs +2 -2
- package/dist/endpoints/index.cjs +3 -3
- package/dist/endpoints/index.d.cts +3 -3
- package/dist/endpoints/index.d.mts +3 -3
- package/dist/endpoints/index.mjs +3 -3
- package/dist/file-server.cjs +101 -31
- package/dist/file-server.cjs.map +1 -1
- package/dist/file-server.d.cts +95 -0
- package/dist/file-server.d.cts.map +1 -1
- package/dist/file-server.d.mts +95 -0
- package/dist/file-server.d.mts.map +1 -1
- package/dist/file-server.mjs +101 -33
- package/dist/file-server.mjs.map +1 -1
- package/dist/functions/index.cjs +1 -1
- package/dist/functions/index.d.cts +2 -2
- package/dist/functions/index.d.mts +2 -2
- package/dist/functions/index.mjs +1 -1
- package/dist/{functions-CTI-hDem.mjs → functions-BvIDQKAA.mjs} +3 -3
- package/dist/{functions-CTI-hDem.mjs.map → functions-BvIDQKAA.mjs.map} +1 -1
- package/dist/{functions-D7O5SGVc.cjs → functions-DLF6-IK8.cjs} +3 -3
- package/dist/{functions-D7O5SGVc.cjs.map → functions-DLF6-IK8.cjs.map} +1 -1
- package/dist/{index-Cd2w-DRL.d.cts → index-BtzMzhMA.d.cts} +3 -3
- package/dist/{index-Cd2w-DRL.d.cts.map → index-BtzMzhMA.d.cts.map} +1 -1
- package/dist/{index-aBIcAiH5.d.mts → index-DuriFjYD.d.mts} +3 -3
- package/dist/{index-aBIcAiH5.d.mts.map → index-DuriFjYD.d.mts.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/pattern-C1CEcglD.mjs +241 -0
- package/dist/pattern-C1CEcglD.mjs.map +1 -0
- package/dist/pattern-QFaUIr77.cjs +288 -0
- package/dist/pattern-QFaUIr77.cjs.map +1 -0
- package/dist/processors/index.cjs +214 -0
- package/dist/processors/index.cjs.map +1 -0
- package/dist/processors/index.d.cts +78 -0
- package/dist/processors/index.d.cts.map +1 -0
- package/dist/processors/index.d.mts +78 -0
- package/dist/processors/index.d.mts.map +1 -0
- package/dist/processors/index.mjs +193 -0
- package/dist/processors/index.mjs.map +1 -0
- package/dist/queue/index.cjs +2 -2
- package/dist/queue/index.d.cts +2 -2
- package/dist/queue/index.d.mts +2 -2
- package/dist/queue/index.mjs +2 -2
- package/dist/rest-api.cjs +1 -1
- package/dist/rest-api.d.cts +2 -2
- package/dist/rest-api.d.mts +2 -2
- package/dist/rest-api.mjs +1 -1
- package/dist/subscribers/index.cjs +1 -1
- package/dist/subscribers/index.d.cts +2 -2
- package/dist/subscribers/index.d.mts +2 -2
- package/dist/subscribers/index.mjs +1 -1
- package/dist/topic/index.cjs +1 -1
- package/dist/topic/index.d.cts +1 -1
- package/dist/topic/index.d.mts +1 -1
- package/dist/topic/index.mjs +1 -1
- package/dist/worker.cjs +4 -4
- package/dist/worker.d.cts +7 -7
- package/dist/worker.d.mts +7 -7
- package/dist/worker.mjs +4 -4
- package/package.json +41 -31
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { n as StandardSchemaV1 } from "./index-DdRjYhiJ.mjs";
|
|
2
|
+
import { t as Construct } from "./Construct-DySlwh8o.mjs";
|
|
3
|
+
import { c as ServicesOf, r as Consumable } from "./construct-interface-ZvYQbivO.mjs";
|
|
4
|
+
import { DERIVED_PREFIX as DERIVED_PREFIX$1 } from "@geekmidas/manifest";
|
|
5
|
+
import { StorageClient } from "@geekmidas/storage";
|
|
6
|
+
import { Service, ServiceRecord } from "@geekmidas/services";
|
|
7
|
+
import { Logger } from "@geekmidas/logger";
|
|
8
|
+
import { InferStandardSchema } from "@geekmidas/schema";
|
|
9
|
+
//#region src/processors/pattern.d.ts
|
|
10
|
+
/**
|
|
11
|
+
* A processor's path pattern: literal segments, `:name` parameters, and a
|
|
12
|
+
* final `*` that is the object's key.
|
|
13
|
+
*
|
|
14
|
+
* ```
|
|
15
|
+
* /i/:width/* → /i/256/avatars/7.png { width: '256' }, 'avatars/7.png'
|
|
16
|
+
* /pdf/:page/:dpi/* → /pdf/1/150/doc.pdf { page: '1', dpi: '150' }, 'doc.pdf'
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* It starts with a literal segment because the edge routes on that prefix: a
|
|
20
|
+
* pattern beginning with a parameter would claim every path on the file
|
|
21
|
+
* server, objects included.
|
|
22
|
+
*/
|
|
23
|
+
/** The parameter names a pattern declares, as a union. */
|
|
24
|
+
type PatternParamNames<P extends string> = P extends `${string}/:${infer Name}/${infer Rest}` ? Name | PatternParamNames<`/${Rest}`> : never;
|
|
25
|
+
/** The raw parameters a pattern matches, before its schema parses them. */
|
|
26
|
+
type PatternParams<P extends string> = { [K in PatternParamNames<P>]: string; };
|
|
27
|
+
/** A pattern a processor cannot be served on. */
|
|
28
|
+
declare class ProcessorPatternInvalid extends Error {
|
|
29
|
+
readonly pattern: string;
|
|
30
|
+
readonly reason: string;
|
|
31
|
+
constructor(pattern: string, reason: string);
|
|
32
|
+
}
|
|
33
|
+
/** A pattern, parsed once. */
|
|
34
|
+
interface ParsedPattern {
|
|
35
|
+
readonly pattern: string;
|
|
36
|
+
/** Each segment before the key: a literal, or a parameter's name. */
|
|
37
|
+
readonly segments: readonly ({
|
|
38
|
+
kind: 'literal';
|
|
39
|
+
value: string;
|
|
40
|
+
} | {
|
|
41
|
+
kind: 'param';
|
|
42
|
+
name: string;
|
|
43
|
+
})[];
|
|
44
|
+
/** The parameter names, in the order they appear. */
|
|
45
|
+
readonly params: readonly string[];
|
|
46
|
+
/** The literal path the edge routes on — `/i/`. */
|
|
47
|
+
readonly prefix: string;
|
|
48
|
+
}
|
|
49
|
+
/** @throws {ProcessorPatternInvalid} */
|
|
50
|
+
declare function parsePattern(pattern: string): ParsedPattern;
|
|
51
|
+
/** A path the pattern matched: its raw parameters and the key. */
|
|
52
|
+
interface PatternMatch {
|
|
53
|
+
params: Record<string, string>;
|
|
54
|
+
key: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Match a request path, decoding each parameter and each key segment. A path
|
|
58
|
+
* with an empty key, or one that decodes to a `..` segment, matches nothing.
|
|
59
|
+
*/
|
|
60
|
+
declare function matchPattern(parsed: ParsedPattern, path: string): PatternMatch | undefined;
|
|
61
|
+
/** The path that addresses `key` through the pattern with these parameters. */
|
|
62
|
+
declare function fillPattern(parsed: ParsedPattern, params: Readonly<Record<string, string | number>>, key: string): string;
|
|
63
|
+
/** A processed URL was asked for without one of the pattern's parameters. */
|
|
64
|
+
declare class ProcessorParamMissing extends Error {
|
|
65
|
+
readonly pattern: string;
|
|
66
|
+
readonly param: string;
|
|
67
|
+
constructor(pattern: string, param: string);
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/processors/Processor.d.ts
|
|
71
|
+
/** How long a response may be kept, by a browser and by the edge. */
|
|
72
|
+
type ProcessorCache =
|
|
73
|
+
/** Never changes for these parameters and this key: kept for a year. */
|
|
74
|
+
'immutable' |
|
|
75
|
+
/** Kept this many seconds. */
|
|
76
|
+
{
|
|
77
|
+
maxAge: number;
|
|
78
|
+
} |
|
|
79
|
+
/** Not kept. */
|
|
80
|
+
'none';
|
|
81
|
+
/** What a processor handler returns. */
|
|
82
|
+
interface ProcessorResult {
|
|
83
|
+
body: Uint8Array | string;
|
|
84
|
+
contentType: string;
|
|
85
|
+
/**
|
|
86
|
+
* `immutable` results are also kept in the bucket, so the next request
|
|
87
|
+
* for them never runs the handler. Defaults to an hour, kept nowhere.
|
|
88
|
+
*/
|
|
89
|
+
cache?: ProcessorCache;
|
|
90
|
+
}
|
|
91
|
+
/** The object a request addresses, read from the bucket on first use. */
|
|
92
|
+
interface SourceObject {
|
|
93
|
+
readonly key: string;
|
|
94
|
+
bytes(): Promise<Uint8Array>;
|
|
95
|
+
stream(): Promise<ReadableStream<Uint8Array>>;
|
|
96
|
+
/** The type it was stored with. */
|
|
97
|
+
contentType(): Promise<string | undefined>;
|
|
98
|
+
}
|
|
99
|
+
interface ProcessorContext<TParams, TServices extends Service[], TLogger extends Logger> {
|
|
100
|
+
params: TParams;
|
|
101
|
+
key: string;
|
|
102
|
+
object: SourceObject;
|
|
103
|
+
logger: TLogger;
|
|
104
|
+
services: ServiceRecord<TServices>;
|
|
105
|
+
}
|
|
106
|
+
type ProcessorHandler<TParams, TServices extends Service[], TLogger extends Logger> = (context: ProcessorContext<TParams, TServices, TLogger>) => Promise<ProcessorResult> | ProcessorResult;
|
|
107
|
+
/** What a processor's parameters parse to: its schema's output, or the raw strings. */
|
|
108
|
+
type ProcessorParams<TPattern extends string, TSchema extends StandardSchemaV1 | undefined> = TSchema extends StandardSchemaV1 ? InferStandardSchema<TSchema> : PatternParams<TPattern>;
|
|
109
|
+
/**
|
|
110
|
+
* A processor — a handler behind one path pattern of a file server, which
|
|
111
|
+
* makes a derivative of an open object on read: a thumbnail, a page of a PDF.
|
|
112
|
+
*
|
|
113
|
+
* Built from the file server (`assets.process('/i/:width/*')`), so it carries
|
|
114
|
+
* the bucket it reads and the open paths it may serve. Its parameters' schema
|
|
115
|
+
* is the allowlist: a request outside it is refused before anything runs, so
|
|
116
|
+
* nobody can mint new work — or new cache entries — by varying a number.
|
|
117
|
+
*/
|
|
118
|
+
declare class Processor<TPattern extends string = string, TSchema extends StandardSchemaV1 | undefined = undefined, TServices extends Service[] = [], TLogger extends Logger = Logger> extends Construct<TLogger, undefined, TServices> {
|
|
119
|
+
readonly parsed: ParsedPattern;
|
|
120
|
+
readonly handler: ProcessorHandler<ProcessorParams<TPattern, TSchema>, TServices, TLogger>;
|
|
121
|
+
readonly options: {
|
|
122
|
+
/** The file server's surface id — the unit that runs it. */
|
|
123
|
+
surfaceId: string;
|
|
124
|
+
/** The bucket it reads from and keeps derivatives in. */
|
|
125
|
+
bucketId: string;
|
|
126
|
+
/** How it reaches that bucket. */
|
|
127
|
+
origin: Service<string, StorageClient>;
|
|
128
|
+
/** Whether a key is one of the file server's open paths. */
|
|
129
|
+
serves: (key: string) => boolean;
|
|
130
|
+
paramsSchema?: TSchema;
|
|
131
|
+
/** Packages with native code, installed for the target. */
|
|
132
|
+
native: readonly string[];
|
|
133
|
+
logger: TLogger;
|
|
134
|
+
services: TServices;
|
|
135
|
+
constructs: string[];
|
|
136
|
+
timeout?: number;
|
|
137
|
+
memorySize?: number;
|
|
138
|
+
};
|
|
139
|
+
__IS_PROCESSOR__: boolean;
|
|
140
|
+
static isProcessor(obj: unknown): obj is Processor<string, any, any, any>;
|
|
141
|
+
constructor(parsed: ParsedPattern, handler: ProcessorHandler<ProcessorParams<TPattern, TSchema>, TServices, TLogger>, options: {
|
|
142
|
+
/** The file server's surface id — the unit that runs it. */
|
|
143
|
+
surfaceId: string;
|
|
144
|
+
/** The bucket it reads from and keeps derivatives in. */
|
|
145
|
+
bucketId: string;
|
|
146
|
+
/** How it reaches that bucket. */
|
|
147
|
+
origin: Service<string, StorageClient>;
|
|
148
|
+
/** Whether a key is one of the file server's open paths. */
|
|
149
|
+
serves: (key: string) => boolean;
|
|
150
|
+
paramsSchema?: TSchema;
|
|
151
|
+
/** Packages with native code, installed for the target. */
|
|
152
|
+
native: readonly string[];
|
|
153
|
+
logger: TLogger;
|
|
154
|
+
services: TServices;
|
|
155
|
+
constructs: string[];
|
|
156
|
+
timeout?: number;
|
|
157
|
+
memorySize?: number;
|
|
158
|
+
});
|
|
159
|
+
/** The pattern it answers, as written. */
|
|
160
|
+
get pattern(): TPattern;
|
|
161
|
+
/** The literal path the edge routes to it — `/i/`. */
|
|
162
|
+
get prefix(): string;
|
|
163
|
+
get native(): readonly string[];
|
|
164
|
+
get surfaceId(): string;
|
|
165
|
+
get bucketId(): string;
|
|
166
|
+
}
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region src/processors/ProcessorBuilder.d.ts
|
|
169
|
+
/** A native package named in a way no installer could resolve. */
|
|
170
|
+
declare class ProcessorNativeInvalid extends Error {
|
|
171
|
+
readonly packageName: string;
|
|
172
|
+
constructor(packageName: string);
|
|
173
|
+
}
|
|
174
|
+
interface ProcessorBuilderState<TLogger extends Logger> {
|
|
175
|
+
parsed: ParsedPattern;
|
|
176
|
+
surfaceId: string;
|
|
177
|
+
bucketId: string;
|
|
178
|
+
origin: Service<string, StorageClient>;
|
|
179
|
+
serves: (key: string) => boolean;
|
|
180
|
+
logger: TLogger;
|
|
181
|
+
paramsSchema?: StandardSchemaV1;
|
|
182
|
+
native: string[];
|
|
183
|
+
services: Service[];
|
|
184
|
+
constructs: string[];
|
|
185
|
+
timeout?: number;
|
|
186
|
+
memorySize?: number;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* What `fileServer.process(pattern)` returns: a processor, built up one
|
|
190
|
+
* immutable step at a time and finished by `.handle()`.
|
|
191
|
+
*/
|
|
192
|
+
declare class ProcessorBuilder<TPattern extends string, TSchema extends StandardSchemaV1 | undefined = undefined, TServices extends Service[] = [], TLogger extends Logger = Logger> {
|
|
193
|
+
private readonly state;
|
|
194
|
+
constructor(state: ProcessorBuilderState<TLogger>);
|
|
195
|
+
/**
|
|
196
|
+
* The parameters' schema — the allowlist. Every request is parsed by it
|
|
197
|
+
* before anything runs, and one it refuses is answered 400.
|
|
198
|
+
*/
|
|
199
|
+
params<T extends StandardSchemaV1>(schema: T): ProcessorBuilder<TPattern, T, TServices, TLogger>;
|
|
200
|
+
/** Constructs its handler reaches, as `services.<id>`. */
|
|
201
|
+
dependsOn<const T extends readonly Consumable[]>(constructs: T): ProcessorBuilder<TPattern, TSchema, [...TServices, ...ServicesOf<T>], TLogger>;
|
|
202
|
+
/**
|
|
203
|
+
* Packages with native code — `sharp` — installed for the target the
|
|
204
|
+
* processor runs on rather than bundled: linux in its image, arm64 on
|
|
205
|
+
* Lambda.
|
|
206
|
+
*/
|
|
207
|
+
native(packages: readonly string[]): this;
|
|
208
|
+
/** Milliseconds a request may take, where the target bounds it. */
|
|
209
|
+
timeout(ms: number): this;
|
|
210
|
+
/** Megabytes of memory, where the target sets it. */
|
|
211
|
+
memorySize(mb: number): this;
|
|
212
|
+
handle(fn: ProcessorHandler<ProcessorParams<TPattern, TSchema>, TServices, TLogger>): Processor<TPattern, TSchema, TServices, TLogger>;
|
|
213
|
+
}
|
|
214
|
+
//#endregion
|
|
215
|
+
export { parsePattern as _, ProcessorCache as a, ProcessorParams as c, ParsedPattern as d, PatternParams as f, matchPattern as g, fillPattern as h, Processor as i, ProcessorResult as l, ProcessorPatternInvalid as m, ProcessorNativeInvalid as n, ProcessorContext as o, ProcessorParamMissing as p, DERIVED_PREFIX$1 as r, ProcessorHandler as s, ProcessorBuilder as t, SourceObject as u };
|
|
216
|
+
//# sourceMappingURL=ProcessorBuilder-B2_stA8f.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProcessorBuilder-B2_stA8f.d.mts","names":[],"sources":["../src/processors/pattern.ts","../src/processors/Processor.ts","../src/processors/ProcessorBuilder.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;KAeY,kBAAkB,oBAC7B,8BAA8B,cAAc,SACzC,OAAO,sBAAsB;;KAIrB,cAAc,uBACxB,KAAK,kBAAkB;;cAIZ,gCAAgC;WAElC;WACA;EAFV,YACU,iBACA;;;UAYM;WACP;;WAEA;IACJ;IAAiB;;IACjB;IAAe;;;WAGX;;WAEA;;;iBAIM,aAAa,kBAAkB;;UAkE9B;EAChB,QAAQ;EACR;;;;;;iBAOe,aACf,QAAQ,eACR,eACE;;iBA0Ba,YACf,QAAQ,eACR,QAAQ,SAAS,kCACjB;;cAmBY,8BAA8B;WAEhC;WACA;EAFV,YACU,iBACA;;;;;KCtKC;;;;;EAIP;;;;;UAKY;EAChB,MAAM;EACN;;;;;EAKA,QAAQ;;;UAIQ;WACP;EACT,SAAS,QAAQ;EACjB,UAAU,QAAQ,eAAe;;EAEjC,eAAe;;UAGC,iBAChB,SACA,kBAAkB,WAClB,gBAAgB;EAEhB,QAAQ;EACR;EACA,QAAQ;EACR,QAAQ;EACR,UAAU,cAAc;;KAGb,iBACX,SACA,kBAAkB,WAClB,gBAAgB,WAEhB,SAAS,iBAAiB,SAAS,WAAW,aAC1C,QAAQ,mBAAmB;;KAGpB,gBACX,yBACA,gBAAgB,gCACb,gBAAgB,mBACjB,oBAAoB,WACpB,cAAc;;;;;;;;;;cAWJ,UACZ,kCACA,gBAAgB,0CAChB,kBAAkB,gBAClB,gBAAgB,SAAS,gBAChB,UAAU,oBAAoB;WAY7B,QAAQ;WACR,SAAS,iBACjB,gBAAgB,UAAU,UAC1B,WACA;WAEQ;;IAER;;IAEA;;IAEA,QAAQ,gBAAgB;;IAExB,SAAS;IACT,eAAe;;IAEf;IACA,QAAQ;IACR,UAAU;IACV;IACA;IACA;;EAjCF;SAEO,YAAY,eAAe,OAAO;EAQzC,YACU,QAAQ,eACR,SAAS,iBACjB,gBAAgB,UAAU,UAC1B,WACA,UAEQ;;IAER;;IAEA;;IAEA,QAAQ,gBAAgB;;IAExB,SAAS;IACT,eAAe;;IAEf;IACA,QAAQ;IACR,UAAU;IACV;IACA;IACA;;;MAsBE,WAAW;;MAKX;MAIA;MAIA;MAIA;;;;;cC/IQ,+BAA+B;WACtB;EAArB,YAAqB;;UAUZ,sBAAsB,gBAAgB;EAC/C,QAAQ;EACR;EACA;EACA,QAAQ,gBAAgB;EACxB,SAAS;EACT,QAAQ;EACR,eAAe;EACf;EACA,UAAU;EACV;EACA;EACA;;;;;;cAOY,iBACZ,yBACA,gBAAgB,0CAChB,kBAAkB,gBAClB,gBAAgB,SAAS;mBAEI;EAA7B,YAA6B,OAAO,sBAAsB;;;;;EAM1D,OAAO,UAAU,kBAChB,QAAQ,IACN,iBAAiB,UAAU,GAAG,WAAW;;EAK5C,gBAAgB,mBAAmB,cAClC,YAAY,IACV,iBACF,UACA,aACI,cAAc,WAAW,KAC7B;;;;;;EAqBD,OAAO;;EAaP,QAAQ;;EAKR,WAAW;EAIX,OACC,IAAI,iBACH,gBAAgB,UAAU,UAC1B,WACA,WAEC,UAAU,UAAU,SAAS,WAAW"}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { n as StandardSchemaV1 } from "./index-DdRjYhiJ.cjs";
|
|
2
|
+
import { t as Construct } from "./Construct-127M7yrl.cjs";
|
|
3
|
+
import { c as ServicesOf, r as Consumable } from "./construct-interface-B1AfqRl4.cjs";
|
|
4
|
+
import { Logger } from "@geekmidas/logger";
|
|
5
|
+
import { InferStandardSchema } from "@geekmidas/schema";
|
|
6
|
+
import { Service, ServiceRecord } from "@geekmidas/services";
|
|
7
|
+
import { DERIVED_PREFIX } from "@geekmidas/manifest";
|
|
8
|
+
import { StorageClient } from "@geekmidas/storage";
|
|
9
|
+
//#region src/processors/pattern.d.ts
|
|
10
|
+
/**
|
|
11
|
+
* A processor's path pattern: literal segments, `:name` parameters, and a
|
|
12
|
+
* final `*` that is the object's key.
|
|
13
|
+
*
|
|
14
|
+
* ```
|
|
15
|
+
* /i/:width/* → /i/256/avatars/7.png { width: '256' }, 'avatars/7.png'
|
|
16
|
+
* /pdf/:page/:dpi/* → /pdf/1/150/doc.pdf { page: '1', dpi: '150' }, 'doc.pdf'
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* It starts with a literal segment because the edge routes on that prefix: a
|
|
20
|
+
* pattern beginning with a parameter would claim every path on the file
|
|
21
|
+
* server, objects included.
|
|
22
|
+
*/
|
|
23
|
+
/** The parameter names a pattern declares, as a union. */
|
|
24
|
+
type PatternParamNames<P extends string> = P extends `${string}/:${infer Name}/${infer Rest}` ? Name | PatternParamNames<`/${Rest}`> : never;
|
|
25
|
+
/** The raw parameters a pattern matches, before its schema parses them. */
|
|
26
|
+
type PatternParams<P extends string> = { [K in PatternParamNames<P>]: string; };
|
|
27
|
+
/** A pattern a processor cannot be served on. */
|
|
28
|
+
declare class ProcessorPatternInvalid extends Error {
|
|
29
|
+
readonly pattern: string;
|
|
30
|
+
readonly reason: string;
|
|
31
|
+
constructor(pattern: string, reason: string);
|
|
32
|
+
}
|
|
33
|
+
/** A pattern, parsed once. */
|
|
34
|
+
interface ParsedPattern {
|
|
35
|
+
readonly pattern: string;
|
|
36
|
+
/** Each segment before the key: a literal, or a parameter's name. */
|
|
37
|
+
readonly segments: readonly ({
|
|
38
|
+
kind: 'literal';
|
|
39
|
+
value: string;
|
|
40
|
+
} | {
|
|
41
|
+
kind: 'param';
|
|
42
|
+
name: string;
|
|
43
|
+
})[];
|
|
44
|
+
/** The parameter names, in the order they appear. */
|
|
45
|
+
readonly params: readonly string[];
|
|
46
|
+
/** The literal path the edge routes on — `/i/`. */
|
|
47
|
+
readonly prefix: string;
|
|
48
|
+
}
|
|
49
|
+
/** @throws {ProcessorPatternInvalid} */
|
|
50
|
+
declare function parsePattern(pattern: string): ParsedPattern;
|
|
51
|
+
/** A path the pattern matched: its raw parameters and the key. */
|
|
52
|
+
interface PatternMatch {
|
|
53
|
+
params: Record<string, string>;
|
|
54
|
+
key: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Match a request path, decoding each parameter and each key segment. A path
|
|
58
|
+
* with an empty key, or one that decodes to a `..` segment, matches nothing.
|
|
59
|
+
*/
|
|
60
|
+
declare function matchPattern(parsed: ParsedPattern, path: string): PatternMatch | undefined;
|
|
61
|
+
/** The path that addresses `key` through the pattern with these parameters. */
|
|
62
|
+
declare function fillPattern(parsed: ParsedPattern, params: Readonly<Record<string, string | number>>, key: string): string;
|
|
63
|
+
/** A processed URL was asked for without one of the pattern's parameters. */
|
|
64
|
+
declare class ProcessorParamMissing extends Error {
|
|
65
|
+
readonly pattern: string;
|
|
66
|
+
readonly param: string;
|
|
67
|
+
constructor(pattern: string, param: string);
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/processors/Processor.d.ts
|
|
71
|
+
/** How long a response may be kept, by a browser and by the edge. */
|
|
72
|
+
type ProcessorCache =
|
|
73
|
+
/** Never changes for these parameters and this key: kept for a year. */
|
|
74
|
+
'immutable' |
|
|
75
|
+
/** Kept this many seconds. */
|
|
76
|
+
{
|
|
77
|
+
maxAge: number;
|
|
78
|
+
} |
|
|
79
|
+
/** Not kept. */
|
|
80
|
+
'none';
|
|
81
|
+
/** What a processor handler returns. */
|
|
82
|
+
interface ProcessorResult {
|
|
83
|
+
body: Uint8Array | string;
|
|
84
|
+
contentType: string;
|
|
85
|
+
/**
|
|
86
|
+
* `immutable` results are also kept in the bucket, so the next request
|
|
87
|
+
* for them never runs the handler. Defaults to an hour, kept nowhere.
|
|
88
|
+
*/
|
|
89
|
+
cache?: ProcessorCache;
|
|
90
|
+
}
|
|
91
|
+
/** The object a request addresses, read from the bucket on first use. */
|
|
92
|
+
interface SourceObject {
|
|
93
|
+
readonly key: string;
|
|
94
|
+
bytes(): Promise<Uint8Array>;
|
|
95
|
+
stream(): Promise<ReadableStream<Uint8Array>>;
|
|
96
|
+
/** The type it was stored with. */
|
|
97
|
+
contentType(): Promise<string | undefined>;
|
|
98
|
+
}
|
|
99
|
+
interface ProcessorContext<TParams, TServices extends Service[], TLogger extends Logger> {
|
|
100
|
+
params: TParams;
|
|
101
|
+
key: string;
|
|
102
|
+
object: SourceObject;
|
|
103
|
+
logger: TLogger;
|
|
104
|
+
services: ServiceRecord<TServices>;
|
|
105
|
+
}
|
|
106
|
+
type ProcessorHandler<TParams, TServices extends Service[], TLogger extends Logger> = (context: ProcessorContext<TParams, TServices, TLogger>) => Promise<ProcessorResult> | ProcessorResult;
|
|
107
|
+
/** What a processor's parameters parse to: its schema's output, or the raw strings. */
|
|
108
|
+
type ProcessorParams<TPattern extends string, TSchema extends StandardSchemaV1 | undefined> = TSchema extends StandardSchemaV1 ? InferStandardSchema<TSchema> : PatternParams<TPattern>;
|
|
109
|
+
/**
|
|
110
|
+
* A processor — a handler behind one path pattern of a file server, which
|
|
111
|
+
* makes a derivative of an open object on read: a thumbnail, a page of a PDF.
|
|
112
|
+
*
|
|
113
|
+
* Built from the file server (`assets.process('/i/:width/*')`), so it carries
|
|
114
|
+
* the bucket it reads and the open paths it may serve. Its parameters' schema
|
|
115
|
+
* is the allowlist: a request outside it is refused before anything runs, so
|
|
116
|
+
* nobody can mint new work — or new cache entries — by varying a number.
|
|
117
|
+
*/
|
|
118
|
+
declare class Processor<TPattern extends string = string, TSchema extends StandardSchemaV1 | undefined = undefined, TServices extends Service[] = [], TLogger extends Logger = Logger> extends Construct<TLogger, undefined, TServices> {
|
|
119
|
+
readonly parsed: ParsedPattern;
|
|
120
|
+
readonly handler: ProcessorHandler<ProcessorParams<TPattern, TSchema>, TServices, TLogger>;
|
|
121
|
+
readonly options: {
|
|
122
|
+
/** The file server's surface id — the unit that runs it. */
|
|
123
|
+
surfaceId: string;
|
|
124
|
+
/** The bucket it reads from and keeps derivatives in. */
|
|
125
|
+
bucketId: string;
|
|
126
|
+
/** How it reaches that bucket. */
|
|
127
|
+
origin: Service<string, StorageClient>;
|
|
128
|
+
/** Whether a key is one of the file server's open paths. */
|
|
129
|
+
serves: (key: string) => boolean;
|
|
130
|
+
paramsSchema?: TSchema;
|
|
131
|
+
/** Packages with native code, installed for the target. */
|
|
132
|
+
native: readonly string[];
|
|
133
|
+
logger: TLogger;
|
|
134
|
+
services: TServices;
|
|
135
|
+
constructs: string[];
|
|
136
|
+
timeout?: number;
|
|
137
|
+
memorySize?: number;
|
|
138
|
+
};
|
|
139
|
+
__IS_PROCESSOR__: boolean;
|
|
140
|
+
static isProcessor(obj: unknown): obj is Processor<string, any, any, any>;
|
|
141
|
+
constructor(parsed: ParsedPattern, handler: ProcessorHandler<ProcessorParams<TPattern, TSchema>, TServices, TLogger>, options: {
|
|
142
|
+
/** The file server's surface id — the unit that runs it. */
|
|
143
|
+
surfaceId: string;
|
|
144
|
+
/** The bucket it reads from and keeps derivatives in. */
|
|
145
|
+
bucketId: string;
|
|
146
|
+
/** How it reaches that bucket. */
|
|
147
|
+
origin: Service<string, StorageClient>;
|
|
148
|
+
/** Whether a key is one of the file server's open paths. */
|
|
149
|
+
serves: (key: string) => boolean;
|
|
150
|
+
paramsSchema?: TSchema;
|
|
151
|
+
/** Packages with native code, installed for the target. */
|
|
152
|
+
native: readonly string[];
|
|
153
|
+
logger: TLogger;
|
|
154
|
+
services: TServices;
|
|
155
|
+
constructs: string[];
|
|
156
|
+
timeout?: number;
|
|
157
|
+
memorySize?: number;
|
|
158
|
+
});
|
|
159
|
+
/** The pattern it answers, as written. */
|
|
160
|
+
get pattern(): TPattern;
|
|
161
|
+
/** The literal path the edge routes to it — `/i/`. */
|
|
162
|
+
get prefix(): string;
|
|
163
|
+
get native(): readonly string[];
|
|
164
|
+
get surfaceId(): string;
|
|
165
|
+
get bucketId(): string;
|
|
166
|
+
}
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region src/processors/ProcessorBuilder.d.ts
|
|
169
|
+
/** A native package named in a way no installer could resolve. */
|
|
170
|
+
declare class ProcessorNativeInvalid extends Error {
|
|
171
|
+
readonly packageName: string;
|
|
172
|
+
constructor(packageName: string);
|
|
173
|
+
}
|
|
174
|
+
interface ProcessorBuilderState<TLogger extends Logger> {
|
|
175
|
+
parsed: ParsedPattern;
|
|
176
|
+
surfaceId: string;
|
|
177
|
+
bucketId: string;
|
|
178
|
+
origin: Service<string, StorageClient>;
|
|
179
|
+
serves: (key: string) => boolean;
|
|
180
|
+
logger: TLogger;
|
|
181
|
+
paramsSchema?: StandardSchemaV1;
|
|
182
|
+
native: string[];
|
|
183
|
+
services: Service[];
|
|
184
|
+
constructs: string[];
|
|
185
|
+
timeout?: number;
|
|
186
|
+
memorySize?: number;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* What `fileServer.process(pattern)` returns: a processor, built up one
|
|
190
|
+
* immutable step at a time and finished by `.handle()`.
|
|
191
|
+
*/
|
|
192
|
+
declare class ProcessorBuilder<TPattern extends string, TSchema extends StandardSchemaV1 | undefined = undefined, TServices extends Service[] = [], TLogger extends Logger = Logger> {
|
|
193
|
+
private readonly state;
|
|
194
|
+
constructor(state: ProcessorBuilderState<TLogger>);
|
|
195
|
+
/**
|
|
196
|
+
* The parameters' schema — the allowlist. Every request is parsed by it
|
|
197
|
+
* before anything runs, and one it refuses is answered 400.
|
|
198
|
+
*/
|
|
199
|
+
params<T extends StandardSchemaV1>(schema: T): ProcessorBuilder<TPattern, T, TServices, TLogger>;
|
|
200
|
+
/** Constructs its handler reaches, as `services.<id>`. */
|
|
201
|
+
dependsOn<const T extends readonly Consumable[]>(constructs: T): ProcessorBuilder<TPattern, TSchema, [...TServices, ...ServicesOf<T>], TLogger>;
|
|
202
|
+
/**
|
|
203
|
+
* Packages with native code — `sharp` — installed for the target the
|
|
204
|
+
* processor runs on rather than bundled: linux in its image, arm64 on
|
|
205
|
+
* Lambda.
|
|
206
|
+
*/
|
|
207
|
+
native(packages: readonly string[]): this;
|
|
208
|
+
/** Milliseconds a request may take, where the target bounds it. */
|
|
209
|
+
timeout(ms: number): this;
|
|
210
|
+
/** Megabytes of memory, where the target sets it. */
|
|
211
|
+
memorySize(mb: number): this;
|
|
212
|
+
handle(fn: ProcessorHandler<ProcessorParams<TPattern, TSchema>, TServices, TLogger>): Processor<TPattern, TSchema, TServices, TLogger>;
|
|
213
|
+
}
|
|
214
|
+
//#endregion
|
|
215
|
+
export { parsePattern as _, ProcessorCache as a, ProcessorParams as c, ParsedPattern as d, PatternParams as f, matchPattern as g, fillPattern as h, Processor as i, ProcessorResult as l, ProcessorPatternInvalid as m, ProcessorNativeInvalid as n, ProcessorContext as o, ProcessorParamMissing as p, DERIVED_PREFIX as r, ProcessorHandler as s, ProcessorBuilder as t, SourceObject as u };
|
|
216
|
+
//# sourceMappingURL=ProcessorBuilder-C62bIOwj.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProcessorBuilder-C62bIOwj.d.cts","names":[],"sources":["../src/processors/pattern.ts","../src/processors/Processor.ts","../src/processors/ProcessorBuilder.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;KAeY,kBAAkB,oBAC7B,8BAA8B,cAAc,SACzC,OAAO,sBAAsB;;KAIrB,cAAc,uBACxB,KAAK,kBAAkB;;cAIZ,gCAAgC;WAElC;WACA;EAFV,YACU,iBACA;;;UAYM;WACP;;WAEA;IACJ;IAAiB;;IACjB;IAAe;;;WAGX;;WAEA;;;iBAIM,aAAa,kBAAkB;;UAkE9B;EAChB,QAAQ;EACR;;;;;;iBAOe,aACf,QAAQ,eACR,eACE;;iBA0Ba,YACf,QAAQ,eACR,QAAQ,SAAS,kCACjB;;cAmBY,8BAA8B;WAEhC;WACA;EAFV,YACU,iBACA;;;;;KCtKC;;;;;EAIP;;;;;UAKY;EAChB,MAAM;EACN;;;;;EAKA,QAAQ;;;UAIQ;WACP;EACT,SAAS,QAAQ;EACjB,UAAU,QAAQ,eAAe;;EAEjC,eAAe;;UAGC,iBAChB,SACA,kBAAkB,WAClB,gBAAgB;EAEhB,QAAQ;EACR;EACA,QAAQ;EACR,QAAQ;EACR,UAAU,cAAc;;KAGb,iBACX,SACA,kBAAkB,WAClB,gBAAgB,WAEhB,SAAS,iBAAiB,SAAS,WAAW,aAC1C,QAAQ,mBAAmB;;KAGpB,gBACX,yBACA,gBAAgB,gCACb,gBAAgB,mBACjB,oBAAoB,WACpB,cAAc;;;;;;;;;;cAWJ,UACZ,kCACA,gBAAgB,0CAChB,kBAAkB,gBAClB,gBAAgB,SAAS,gBAChB,UAAU,oBAAoB;WAY7B,QAAQ;WACR,SAAS,iBACjB,gBAAgB,UAAU,UAC1B,WACA;WAEQ;;IAER;;IAEA;;IAEA,QAAQ,gBAAgB;;IAExB,SAAS;IACT,eAAe;;IAEf;IACA,QAAQ;IACR,UAAU;IACV;IACA;IACA;;EAjCF;SAEO,YAAY,eAAe,OAAO;EAQzC,YACU,QAAQ,eACR,SAAS,iBACjB,gBAAgB,UAAU,UAC1B,WACA,UAEQ;;IAER;;IAEA;;IAEA,QAAQ,gBAAgB;;IAExB,SAAS;IACT,eAAe;;IAEf;IACA,QAAQ;IACR,UAAU;IACV;IACA;IACA;;;MAsBE,WAAW;;MAKX;MAIA;MAIA;MAIA;;;;;cC/IQ,+BAA+B;WACtB;EAArB,YAAqB;;UAUZ,sBAAsB,gBAAgB;EAC/C,QAAQ;EACR;EACA;EACA,QAAQ,gBAAgB;EACxB,SAAS;EACT,QAAQ;EACR,eAAe;EACf;EACA,UAAU;EACV;EACA;EACA;;;;;;cAOY,iBACZ,yBACA,gBAAgB,0CAChB,kBAAkB,gBAClB,gBAAgB,SAAS;mBAEI;EAA7B,YAA6B,OAAO,sBAAsB;;;;;EAM1D,OAAO,UAAU,kBAChB,QAAQ,IACN,iBAAiB,UAAU,GAAG,WAAW;;EAK5C,gBAAgB,mBAAmB,cAClC,YAAY,IACV,iBACF,UACA,aACI,cAAc,WAAW,KAC7B;;;;;;EAqBD,OAAO;;EAaP,QAAQ;;EAKR,WAAW;EAIX,OACC,IAAI,iBACH,gBAAgB,UAAU,UAC1B,WACA,WAEC,UAAU,UAAU,SAAS,WAAW"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as StandardSchemaV1 } from "./index-DdRjYhiJ.mjs";
|
|
2
|
-
import { t as Construct } from "./Construct-
|
|
3
|
-
import { t as DatabaseContext } from "./Function-
|
|
2
|
+
import { t as Construct } from "./Construct-DySlwh8o.mjs";
|
|
3
|
+
import { t as DatabaseContext } from "./Function-DfMzTGS4.mjs";
|
|
4
4
|
import { Declaration } from "@geekmidas/manifest";
|
|
5
5
|
import { EventPublisher, PublishableMessage } from "@geekmidas/events";
|
|
6
6
|
import { Service, ServiceRecord } from "@geekmidas/services";
|
|
@@ -102,4 +102,4 @@ type QueueContext<TMessage extends StandardSchemaV1, TServices extends Service[]
|
|
|
102
102
|
type QueueHandler<TMessage extends StandardSchemaV1, TServices extends Service[] = [], TLogger extends Logger = Logger, TDatabase = undefined> = (ctx: QueueContext<TMessage, TServices, TLogger, TDatabase>) => unknown | Promise<unknown>;
|
|
103
103
|
//#endregion
|
|
104
104
|
export { QueueMessage as i, QueueContext as n, QueueHandler as r, Queue as t };
|
|
105
|
-
//# sourceMappingURL=Queue-
|
|
105
|
+
//# sourceMappingURL=Queue-BnK3UH8r.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Queue-
|
|
1
|
+
{"version":3,"file":"Queue-BnK3UH8r.d.mts","names":[],"sources":["../src/queue/Queue.ts"],"mappings":";;;;;;;;;;;;;;;KA0BY,aACX,sBACA,iBAAiB,oBACd,mBAAmB,OAAO,oBAAoB;;;;;;;;;;;;;;cAerC,MACZ,+BACA,iBAAiB,mBAAmB,kBACpC,kBAAkB,gBAClB,gBAAgB,SAAS,QACzB,uBACA,sDACS,UACT,oBAEA,8BAGA,sBACA;WA8CiB,MAAM;WACN,SAAS,aACxB,UACA,WACA,SACA;WAEe,eAAe;WACN;WACA,UAAU;WACV,QAAQ;;WAEjB;;WAEA;EA1DjB;SAEO,QACN,eACE,OAAO,cAAc,kBAAkB,WAAW;;;;;;;;;WAgB5C;;;;;;;;;;;WAYA,SAAS,QACjB,aAAa,QACb,eAAe,aAAa,OAAO;;;;;mBAOnB;EAEjB,YACiB,MAAM,OACN,SAAS,aACxB,UACA,WACA,SACA,YAEe,eAAe,UACN,kBACA,WAAU,WACV,SAAQ,SAEjB;;EAAA,gCAEA;;EAAA,4BAKhB;;;;;EAAA,uBAKA;;;;;EAAA,kBAAkB,QAAQ,sBAAsB;;;;;;;;;EAyCjD,WAAW;;;;;;KA8BA,aACX,iBAAiB,kBACjB,kBAAkB,gBAClB,gBAAgB,SAAS,QACzB;EAEA,UAAU,oBAAoB;EAC9B,UAAU,cAAc;EACxB,QAAQ;IACL,gBAAgB;KAER,aACX,iBAAiB,kBACjB,kBAAkB,gBAClB,gBAAgB,SAAS,QACzB,0BAEA,KAAK,aAAa,UAAU,WAAW,SAAS,yBAClC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as StandardSchemaV1 } from "./index-DdRjYhiJ.cjs";
|
|
2
|
-
import { t as Construct } from "./Construct-
|
|
3
|
-
import { t as DatabaseContext } from "./Function-
|
|
2
|
+
import { t as Construct } from "./Construct-127M7yrl.cjs";
|
|
3
|
+
import { t as DatabaseContext } from "./Function-BIEsY0Hm.cjs";
|
|
4
4
|
import { Logger } from "@geekmidas/logger";
|
|
5
5
|
import { InferStandardSchema } from "@geekmidas/schema";
|
|
6
6
|
import { Service, ServiceRecord } from "@geekmidas/services";
|
|
@@ -102,4 +102,4 @@ type QueueContext<TMessage extends StandardSchemaV1, TServices extends Service[]
|
|
|
102
102
|
type QueueHandler<TMessage extends StandardSchemaV1, TServices extends Service[] = [], TLogger extends Logger = Logger, TDatabase = undefined> = (ctx: QueueContext<TMessage, TServices, TLogger, TDatabase>) => unknown | Promise<unknown>;
|
|
103
103
|
//#endregion
|
|
104
104
|
export { QueueMessage as i, QueueContext as n, QueueHandler as r, Queue as t };
|
|
105
|
-
//# sourceMappingURL=Queue-
|
|
105
|
+
//# sourceMappingURL=Queue-C4rijiM7.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Queue-
|
|
1
|
+
{"version":3,"file":"Queue-C4rijiM7.d.cts","names":[],"sources":["../src/queue/Queue.ts"],"mappings":";;;;;;;;;;;;;;;KA0BY,aACX,sBACA,iBAAiB,oBACd,mBAAmB,OAAO,oBAAoB;;;;;;;;;;;;;;cAerC,MACZ,+BACA,iBAAiB,mBAAmB,kBACpC,kBAAkB,gBAClB,gBAAgB,SAAS,QACzB,uBACA,sDACS,UACT,oBAEA,8BAGA,sBACA;WA8CiB,MAAM;WACN,SAAS,aACxB,UACA,WACA,SACA;WAEe,eAAe;WACN;WACA,UAAU;WACV,QAAQ;;WAEjB;;WAEA;EA1DjB;SAEO,QACN,eACE,OAAO,cAAc,kBAAkB,WAAW;;;;;;;;;WAgB5C;;;;;;;;;;;WAYA,SAAS,QACjB,aAAa,QACb,eAAe,aAAa,OAAO;;;;;mBAOnB;EAEjB,YACiB,MAAM,OACN,SAAS,aACxB,UACA,WACA,SACA,YAEe,eAAe,UACN,kBACA,WAAU,WACV,SAAQ,SAEjB;;EAAA,gCAEA;;EAAA,4BAKhB;;;;;EAAA,uBAKA;;;;;EAAA,kBAAkB,QAAQ,sBAAsB;;;;;;;;;EAyCjD,WAAW;;;;;;KA8BA,aACX,iBAAiB,kBACjB,kBAAkB,gBAClB,gBAAgB,SAAS,QACzB;EAEA,UAAU,oBAAoB;EAC9B,UAAU,cAAc;EACxB,QAAQ;IACL,gBAAgB;KAER,aACX,iBAAiB,kBACjB,kBAAkB,gBAClB,gBAAgB,SAAS,QACzB,0BAEA,KAAK,aAAa,UAAU,WAAW,SAAS,yBAClC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const require_Construct = require("./Construct-
|
|
1
|
+
const require_Construct = require("./Construct-DorKS0Ua.cjs");
|
|
2
2
|
let _geekmidas_manifest = require("@geekmidas/manifest");
|
|
3
|
-
let _geekmidas_events = require("@geekmidas/events");
|
|
4
3
|
let _geekmidas_logger_console = require("@geekmidas/logger/console");
|
|
4
|
+
let _geekmidas_events = require("@geekmidas/events");
|
|
5
5
|
//#region src/queue/Queue.ts
|
|
6
6
|
/**
|
|
7
7
|
* A queue worker — a point-to-point SQS-style queue and its single consumer.
|
|
@@ -106,4 +106,4 @@ Object.defineProperty(exports, "Queue", {
|
|
|
106
106
|
}
|
|
107
107
|
});
|
|
108
108
|
|
|
109
|
-
//# sourceMappingURL=Queue-
|
|
109
|
+
//# sourceMappingURL=Queue-D4Iaidrs.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Queue-
|
|
1
|
+
{"version":3,"file":"Queue-D4Iaidrs.cjs","names":["Construct","DEFAULT_LOGGER","canonicalId","provideKey","serviceKey","Publisher"],"sources":["../src/queue/Queue.ts"],"sourcesContent":["import {\n\ttype EventPublisher,\n\ttype EventPublisherConnectionString,\n\ttype PublishableMessage,\n\tPublisher,\n} from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport {\n\tcanonicalId,\n\ttype Declaration,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { InferStandardSchema } from '@geekmidas/schema';\nimport type { Service, ServiceRecord } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { Construct, ConstructType } from '../Construct';\nimport type { DatabaseContext } from '../functions/Function';\n\n/**\n * The wire message a queue carries: `{ type: <queue name>, payload: <message> }`.\n * The producer publishes this shape and the worker receives the `payload`s as\n * its `messages`. Typing `type` to the queue name keeps the publisher fully\n * typed and lets pg-boss (local) / SQS (deployed) route by name.\n */\nexport type QueueMessage<\n\tTName extends string,\n\tTMessage extends StandardSchemaV1,\n> = PublishableMessage<TName, InferStandardSchema<TMessage>>;\n\n/**\n * A queue worker — a point-to-point SQS-style queue and its single consumer.\n * Unlike a `Subscriber` (topic fan-out, filtered by `subscribedEvents`), a queue\n * drains every message of its one `message` type. Build one from the worker\n * that runs it — `worker.queue('Emails').message(schema).handle(…)` — and\n * `gkm build` discovers it into the manifest's `queues` field.\n *\n * Producers send to it by depending on it: `.dependsOn([emails])` makes\n * `services.emails` the publisher.\n *\n * Its handler gets `db` when it has a database: the worker's, declared once\n * with `worker.database(db)`, or its own with `.database(other)`.\n */\nexport class Queue<\n\tTName extends string = string,\n\tTMessage extends StandardSchemaV1 = StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tTDatabase = undefined,\n\tTDatabaseServiceName extends string = string,\n> extends Construct<\n\tTLogger,\n\tundefined,\n\tTServices,\n\tstring,\n\tundefined,\n\tTDatabaseServiceName,\n\tTDatabase\n> {\n\t__IS_QUEUE__ = true;\n\n\tstatic isQueue(\n\t\tobj: unknown,\n\t): obj is Queue<string, StandardSchemaV1, Service[], Logger, any> {\n\t\treturn Boolean(\n\t\t\tobj &&\n\t\t\t\t(obj as { __IS_QUEUE__?: boolean }).__IS_QUEUE__ === true &&\n\t\t\t\t(obj as Construct).type === ConstructType.Queue,\n\t\t);\n\t}\n\n\t/**\n\t * The canonical id this queue is declared under.\n\t *\n\t * Derived from the name rather than given separately, so `emails` and\n\t * `Emails` are one queue. The name stays what it was: it is the wire `type`\n\t * a producer sends and the worker subscribes to, and changing that would\n\t * silently orphan in-flight messages.\n\t */\n\treadonly id: string;\n\n\t/**\n\t * The queue as a dependency — what `.dependsOn([emails])` dissolves into,\n\t * reachable as `services.emails`.\n\t *\n\t * The producer: the queue's one consumer is the handler it was built with,\n\t * so the only thing another construct can want from a queue is to send to\n\t * it. It reads `<NAME>_PUBLISHER_CONNECTION_STRING` and picks the transport\n\t * from its protocol — `pgboss://` locally, `sqs://` deployed. A field\n\t * assigned once, not a getter: services are cached by object identity.\n\t */\n\treadonly service: Service<\n\t\tUncapitalize<TName>,\n\t\tEventPublisher<QueueMessage<TName, TMessage>>\n\t>;\n\n\t/**\n\t * The producer's env key. Read by both {@link declare} and the service, so\n\t * what the target publishes and what the producer looks up cannot drift.\n\t */\n\tprivate readonly connectionKey: string;\n\n\tconstructor(\n\t\tpublic readonly name: TName,\n\t\tpublic readonly handler: QueueHandler<\n\t\t\tTMessage,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tTDatabase\n\t\t>,\n\t\tpublic readonly messageSchema: TMessage,\n\t\tpublic override readonly timeout: number = 30000,\n\t\tpublic override readonly services: TServices = [] as unknown as TServices,\n\t\tpublic override readonly logger: TLogger = DEFAULT_LOGGER as TLogger,\n\t\t/** SQS event-source batch size (deployed). */\n\t\tpublic readonly batchSize?: number,\n\t\t/** Whether the queue is FIFO (deployed). */\n\t\tpublic readonly fifo?: boolean,\n\t\t/**\n\t\t * The construct ids the *worker* `.dependsOn()` named — last, so no\n\t\t * existing positional argument moves.\n\t\t */\n\t\tconstructs: string[] = [],\n\t\t/**\n\t\t * What the handler's `db` is registered from — after `constructs`, for\n\t\t * the same reason.\n\t\t */\n\t\tdatabaseService?: Service<TDatabaseServiceName, TDatabase>,\n\t) {\n\t\tsuper(\n\t\t\tConstructType.Queue,\n\t\t\tlogger,\n\t\t\tservices,\n\t\t\t[],\n\t\t\tundefined,\n\t\t\ttimeout,\n\t\t\tundefined, // memorySize\n\t\t\tundefined, // auditorStorageService\n\t\t\tconstructs,\n\t\t);\n\n\t\tthis.databaseService = databaseService;\n\t\tthis.id = canonicalId(name);\n\t\tthis.connectionKey = provideKey(this.id, 'publisherConnectionString');\n\n\t\tconst envVar = this.connectionKey;\n\t\tthis.service = {\n\t\t\tserviceName: serviceKey(this.id) as Uncapitalize<TName>,\n\t\t\tasync register({ envParser }) {\n\t\t\t\tconst { connectionString } = envParser\n\t\t\t\t\t.create((get) => ({ connectionString: get(envVar).string() }))\n\t\t\t\t\t.parse();\n\n\t\t\t\treturn Publisher.fromConnectionString<QueueMessage<TName, TMessage>>(\n\t\t\t\t\tconnectionString as EventPublisherConnectionString,\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * What this queue is in the manifest.\n\t *\n\t * A queue is a resource, not a handler: the worker is reached *through* it,\n\t * so the declaration carries the producer's key and nothing about the code\n\t * that drains it. The local target reads this to know which broker has to be\n\t * running and what connection string to inject.\n\t */\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'queue',\n\t\t\t\tid: this.id,\n\t\t\t\tprovides: [this.connectionKey],\n\t\t\t\t...(this.fifo ? { fifo: true } : {}),\n\t\t\t\t// Nested rather than a sibling node, because position carries the\n\t\t\t\t// trigger: this handler is reached by messages on this queue and\n\t\t\t\t// by nothing else, so there is no `trigger` field to keep in step.\n\t\t\t\t//\n\t\t\t\t// `handler` is the export name; which directory the build wrote it\n\t\t\t\t// to is the target's business, and a path with a cloud in it does\n\t\t\t\t// not belong in a neutral declaration.\n\t\t\t\tworker: {\n\t\t\t\t\tid: `${this.id}Worker`,\n\t\t\t\t\thandler: `${this.id}.handler`,\n\t\t\t\t\t// Filled by the build from what the worker declared. Empty is a\n\t\t\t\t\t// stated gap, not a claim that it reaches nothing.\n\t\t\t\t\tdependencies: [],\n\t\t\t\t},\n\t\t\t},\n\t\t];\n\t}\n}\n\n/**\n * The context a queue handler receives — a batch of typed messages, and `db`\n * when the queue has a database.\n */\nexport type QueueContext<\n\tTMessage extends StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tTDatabase = undefined,\n> = {\n\tmessages: InferStandardSchema<TMessage>[];\n\tservices: ServiceRecord<TServices>;\n\tlogger: TLogger;\n} & DatabaseContext<TDatabase>;\n\nexport type QueueHandler<\n\tTMessage extends StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tTDatabase = undefined,\n> = (\n\tctx: QueueContext<TMessage, TServices, TLogger, TDatabase>,\n) => unknown | Promise<unknown>;\n"],"mappings":";;;;;;;;;;;;;;;;;;AA4CA,IAAa,QAAb,cAOUA,kBAAAA,UAQR;CA6CgB;CACA;CAMA;CACS;CACA;CACA;CAET;CAEA;CA1DjB,eAAe;CAEf,OAAO,QACN,KACiE;EACjE,OAAO,QACN,OACE,IAAmC,iBAAiB,QACpD,IAAkB,SAAA,8BACrB;CACD;;;;;;;;;CAUA;;;;;;;;;;;CAYA;;;;;CASA;CAEA,YACC,MACA,SAMA,eACA,UAA2C,KAC3C,WAA+C,CAAC,GAChD,SAA2CC,0BAAAA,gBAE3C,WAEA,MAKA,aAAuB,CAAC,GAKxB,iBACC;EACD,MAAA,gCAEC,QACA,UACA,CAAC,GACD,KAAA,GACA,SACA,KAAA,GACA,KAAA,GACA,UACD;EApCgB,KAAA,OAAA;EACA,KAAA,UAAA;EAMA,KAAA,gBAAA;EACS,KAAA,UAAA;EACA,KAAA,WAAA;EACA,KAAA,SAAA;EAET,KAAA,YAAA;EAEA,KAAA,OAAA;EAwBhB,KAAK,kBAAkB;EACvB,KAAK,MAAA,GAAKC,oBAAAA,YAAAA,CAAY,IAAI;EAC1B,KAAK,iBAAA,GAAgBC,oBAAAA,WAAAA,CAAW,KAAK,IAAI,2BAA2B;EAEpE,MAAM,SAAS,KAAK;EACpB,KAAK,UAAU;GACd,cAAA,GAAaC,oBAAAA,WAAAA,CAAW,KAAK,EAAE;GAC/B,MAAM,SAAS,EAAE,aAAa;IAC7B,MAAM,EAAE,qBAAqB,UAC3B,QAAQ,SAAS,EAAE,kBAAkB,IAAI,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAC7D,MAAM;IAER,OAAOC,kBAAAA,UAAU,qBAChB,gBACD;GACD;EACD;CACD;;;;;;;;;CAUA,UAAyB;EACxB,OAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,UAAU,CAAC,KAAK,aAAa;GAC7B,GAAI,KAAK,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;GAQlC,QAAQ;IACP,IAAI,GAAG,KAAK,GAAG;IACf,SAAS,GAAG,KAAK,GAAG;IAGpB,cAAc,CAAC;GAChB;EACD,CACD;CACD;AACD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as Construct } from "./Construct-
|
|
1
|
+
import { t as Construct } from "./Construct-CGuc_Ijk.mjs";
|
|
2
2
|
import { canonicalId, provideKey, serviceKey } from "@geekmidas/manifest";
|
|
3
|
-
import { Publisher } from "@geekmidas/events";
|
|
4
3
|
import { DEFAULT_LOGGER } from "@geekmidas/logger/console";
|
|
4
|
+
import { Publisher } from "@geekmidas/events";
|
|
5
5
|
//#region src/queue/Queue.ts
|
|
6
6
|
/**
|
|
7
7
|
* A queue worker — a point-to-point SQS-style queue and its single consumer.
|
|
@@ -101,4 +101,4 @@ var Queue = class extends Construct {
|
|
|
101
101
|
//#endregion
|
|
102
102
|
export { Queue as t };
|
|
103
103
|
|
|
104
|
-
//# sourceMappingURL=Queue-
|
|
104
|
+
//# sourceMappingURL=Queue-u8w8_HpE.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Queue-
|
|
1
|
+
{"version":3,"file":"Queue-u8w8_HpE.mjs","names":[],"sources":["../src/queue/Queue.ts"],"sourcesContent":["import {\n\ttype EventPublisher,\n\ttype EventPublisherConnectionString,\n\ttype PublishableMessage,\n\tPublisher,\n} from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport { DEFAULT_LOGGER } from '@geekmidas/logger/console';\nimport {\n\tcanonicalId,\n\ttype Declaration,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { InferStandardSchema } from '@geekmidas/schema';\nimport type { Service, ServiceRecord } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport { Construct, ConstructType } from '../Construct';\nimport type { DatabaseContext } from '../functions/Function';\n\n/**\n * The wire message a queue carries: `{ type: <queue name>, payload: <message> }`.\n * The producer publishes this shape and the worker receives the `payload`s as\n * its `messages`. Typing `type` to the queue name keeps the publisher fully\n * typed and lets pg-boss (local) / SQS (deployed) route by name.\n */\nexport type QueueMessage<\n\tTName extends string,\n\tTMessage extends StandardSchemaV1,\n> = PublishableMessage<TName, InferStandardSchema<TMessage>>;\n\n/**\n * A queue worker — a point-to-point SQS-style queue and its single consumer.\n * Unlike a `Subscriber` (topic fan-out, filtered by `subscribedEvents`), a queue\n * drains every message of its one `message` type. Build one from the worker\n * that runs it — `worker.queue('Emails').message(schema).handle(…)` — and\n * `gkm build` discovers it into the manifest's `queues` field.\n *\n * Producers send to it by depending on it: `.dependsOn([emails])` makes\n * `services.emails` the publisher.\n *\n * Its handler gets `db` when it has a database: the worker's, declared once\n * with `worker.database(db)`, or its own with `.database(other)`.\n */\nexport class Queue<\n\tTName extends string = string,\n\tTMessage extends StandardSchemaV1 = StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tTDatabase = undefined,\n\tTDatabaseServiceName extends string = string,\n> extends Construct<\n\tTLogger,\n\tundefined,\n\tTServices,\n\tstring,\n\tundefined,\n\tTDatabaseServiceName,\n\tTDatabase\n> {\n\t__IS_QUEUE__ = true;\n\n\tstatic isQueue(\n\t\tobj: unknown,\n\t): obj is Queue<string, StandardSchemaV1, Service[], Logger, any> {\n\t\treturn Boolean(\n\t\t\tobj &&\n\t\t\t\t(obj as { __IS_QUEUE__?: boolean }).__IS_QUEUE__ === true &&\n\t\t\t\t(obj as Construct).type === ConstructType.Queue,\n\t\t);\n\t}\n\n\t/**\n\t * The canonical id this queue is declared under.\n\t *\n\t * Derived from the name rather than given separately, so `emails` and\n\t * `Emails` are one queue. The name stays what it was: it is the wire `type`\n\t * a producer sends and the worker subscribes to, and changing that would\n\t * silently orphan in-flight messages.\n\t */\n\treadonly id: string;\n\n\t/**\n\t * The queue as a dependency — what `.dependsOn([emails])` dissolves into,\n\t * reachable as `services.emails`.\n\t *\n\t * The producer: the queue's one consumer is the handler it was built with,\n\t * so the only thing another construct can want from a queue is to send to\n\t * it. It reads `<NAME>_PUBLISHER_CONNECTION_STRING` and picks the transport\n\t * from its protocol — `pgboss://` locally, `sqs://` deployed. A field\n\t * assigned once, not a getter: services are cached by object identity.\n\t */\n\treadonly service: Service<\n\t\tUncapitalize<TName>,\n\t\tEventPublisher<QueueMessage<TName, TMessage>>\n\t>;\n\n\t/**\n\t * The producer's env key. Read by both {@link declare} and the service, so\n\t * what the target publishes and what the producer looks up cannot drift.\n\t */\n\tprivate readonly connectionKey: string;\n\n\tconstructor(\n\t\tpublic readonly name: TName,\n\t\tpublic readonly handler: QueueHandler<\n\t\t\tTMessage,\n\t\t\tTServices,\n\t\t\tTLogger,\n\t\t\tTDatabase\n\t\t>,\n\t\tpublic readonly messageSchema: TMessage,\n\t\tpublic override readonly timeout: number = 30000,\n\t\tpublic override readonly services: TServices = [] as unknown as TServices,\n\t\tpublic override readonly logger: TLogger = DEFAULT_LOGGER as TLogger,\n\t\t/** SQS event-source batch size (deployed). */\n\t\tpublic readonly batchSize?: number,\n\t\t/** Whether the queue is FIFO (deployed). */\n\t\tpublic readonly fifo?: boolean,\n\t\t/**\n\t\t * The construct ids the *worker* `.dependsOn()` named — last, so no\n\t\t * existing positional argument moves.\n\t\t */\n\t\tconstructs: string[] = [],\n\t\t/**\n\t\t * What the handler's `db` is registered from — after `constructs`, for\n\t\t * the same reason.\n\t\t */\n\t\tdatabaseService?: Service<TDatabaseServiceName, TDatabase>,\n\t) {\n\t\tsuper(\n\t\t\tConstructType.Queue,\n\t\t\tlogger,\n\t\t\tservices,\n\t\t\t[],\n\t\t\tundefined,\n\t\t\ttimeout,\n\t\t\tundefined, // memorySize\n\t\t\tundefined, // auditorStorageService\n\t\t\tconstructs,\n\t\t);\n\n\t\tthis.databaseService = databaseService;\n\t\tthis.id = canonicalId(name);\n\t\tthis.connectionKey = provideKey(this.id, 'publisherConnectionString');\n\n\t\tconst envVar = this.connectionKey;\n\t\tthis.service = {\n\t\t\tserviceName: serviceKey(this.id) as Uncapitalize<TName>,\n\t\t\tasync register({ envParser }) {\n\t\t\t\tconst { connectionString } = envParser\n\t\t\t\t\t.create((get) => ({ connectionString: get(envVar).string() }))\n\t\t\t\t\t.parse();\n\n\t\t\t\treturn Publisher.fromConnectionString<QueueMessage<TName, TMessage>>(\n\t\t\t\t\tconnectionString as EventPublisherConnectionString,\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * What this queue is in the manifest.\n\t *\n\t * A queue is a resource, not a handler: the worker is reached *through* it,\n\t * so the declaration carries the producer's key and nothing about the code\n\t * that drains it. The local target reads this to know which broker has to be\n\t * running and what connection string to inject.\n\t */\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'queue',\n\t\t\t\tid: this.id,\n\t\t\t\tprovides: [this.connectionKey],\n\t\t\t\t...(this.fifo ? { fifo: true } : {}),\n\t\t\t\t// Nested rather than a sibling node, because position carries the\n\t\t\t\t// trigger: this handler is reached by messages on this queue and\n\t\t\t\t// by nothing else, so there is no `trigger` field to keep in step.\n\t\t\t\t//\n\t\t\t\t// `handler` is the export name; which directory the build wrote it\n\t\t\t\t// to is the target's business, and a path with a cloud in it does\n\t\t\t\t// not belong in a neutral declaration.\n\t\t\t\tworker: {\n\t\t\t\t\tid: `${this.id}Worker`,\n\t\t\t\t\thandler: `${this.id}.handler`,\n\t\t\t\t\t// Filled by the build from what the worker declared. Empty is a\n\t\t\t\t\t// stated gap, not a claim that it reaches nothing.\n\t\t\t\t\tdependencies: [],\n\t\t\t\t},\n\t\t\t},\n\t\t];\n\t}\n}\n\n/**\n * The context a queue handler receives — a batch of typed messages, and `db`\n * when the queue has a database.\n */\nexport type QueueContext<\n\tTMessage extends StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tTDatabase = undefined,\n> = {\n\tmessages: InferStandardSchema<TMessage>[];\n\tservices: ServiceRecord<TServices>;\n\tlogger: TLogger;\n} & DatabaseContext<TDatabase>;\n\nexport type QueueHandler<\n\tTMessage extends StandardSchemaV1,\n\tTServices extends Service[] = [],\n\tTLogger extends Logger = Logger,\n\tTDatabase = undefined,\n> = (\n\tctx: QueueContext<TMessage, TServices, TLogger, TDatabase>,\n) => unknown | Promise<unknown>;\n"],"mappings":";;;;;;;;;;;;;;;;;;AA4CA,IAAa,QAAb,cAOU,UAQR;CA6CgB;CACA;CAMA;CACS;CACA;CACA;CAET;CAEA;CA1DjB,eAAe;CAEf,OAAO,QACN,KACiE;EACjE,OAAO,QACN,OACE,IAAmC,iBAAiB,QACpD,IAAkB,SAAA,8BACrB;CACD;;;;;;;;;CAUA;;;;;;;;;;;CAYA;;;;;CASA;CAEA,YACC,MACA,SAMA,eACA,UAA2C,KAC3C,WAA+C,CAAC,GAChD,SAA2C,gBAE3C,WAEA,MAKA,aAAuB,CAAC,GAKxB,iBACC;EACD,MAAA,gCAEC,QACA,UACA,CAAC,GACD,KAAA,GACA,SACA,KAAA,GACA,KAAA,GACA,UACD;EApCgB,KAAA,OAAA;EACA,KAAA,UAAA;EAMA,KAAA,gBAAA;EACS,KAAA,UAAA;EACA,KAAA,WAAA;EACA,KAAA,SAAA;EAET,KAAA,YAAA;EAEA,KAAA,OAAA;EAwBhB,KAAK,kBAAkB;EACvB,KAAK,KAAK,YAAY,IAAI;EAC1B,KAAK,gBAAgB,WAAW,KAAK,IAAI,2BAA2B;EAEpE,MAAM,SAAS,KAAK;EACpB,KAAK,UAAU;GACd,aAAa,WAAW,KAAK,EAAE;GAC/B,MAAM,SAAS,EAAE,aAAa;IAC7B,MAAM,EAAE,qBAAqB,UAC3B,QAAQ,SAAS,EAAE,kBAAkB,IAAI,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAC7D,MAAM;IAER,OAAO,UAAU,qBAChB,gBACD;GACD;EACD;CACD;;;;;;;;;CAUA,UAAyB;EACxB,OAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK;GACT,UAAU,CAAC,KAAK,aAAa;GAC7B,GAAI,KAAK,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;GAQlC,QAAQ;IACP,IAAI,GAAG,KAAK,GAAG;IACf,SAAS,GAAG,KAAK,GAAG;IAGpB,cAAc,CAAC;GAChB;EACD,CACD;CACD;AACD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { databaseEdges, idsOf, serviceOf, servicesOf } from "./construct-interface.mjs";
|
|
2
2
|
import { t as cloneWith } from "./clone-EKNovYHu.mjs";
|
|
3
|
-
import { t as Queue } from "./Queue-
|
|
3
|
+
import { t as Queue } from "./Queue-u8w8_HpE.mjs";
|
|
4
4
|
import { DEFAULT_LOGGER } from "@geekmidas/logger/console";
|
|
5
5
|
//#region src/queue/QueueBuilder.ts
|
|
6
6
|
/**
|
|
@@ -115,4 +115,4 @@ var QueueNeedsMessage = class extends Error {
|
|
|
115
115
|
//#endregion
|
|
116
116
|
export { QueueNeedsMessage as n, QueueNeedsName as r, QueueBuilder as t };
|
|
117
117
|
|
|
118
|
-
//# sourceMappingURL=QueueBuilder-
|
|
118
|
+
//# sourceMappingURL=QueueBuilder-2wP5lEC8.mjs.map
|