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

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 (121) 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-BC7CZ7Cr.mjs → HonoEndpointAdaptor-2xHA3bvn.mjs} +3 -3
  19. package/dist/{HonoEndpointAdaptor-BC7CZ7Cr.mjs.map → HonoEndpointAdaptor-2xHA3bvn.mjs.map} +1 -1
  20. package/dist/{HonoEndpointAdaptor-BGEW1Tu8.cjs → HonoEndpointAdaptor-CZ1TooUu.cjs} +4 -4
  21. package/dist/{HonoEndpointAdaptor-BGEW1Tu8.cjs.map → HonoEndpointAdaptor-CZ1TooUu.cjs.map} +1 -1
  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.mjs +1 -1
  56. package/dist/adaptors/testing.cjs +8 -8
  57. package/dist/adaptors/testing.d.cts +1 -1
  58. package/dist/adaptors/testing.d.mts +1 -1
  59. package/dist/adaptors/testing.mjs +6 -6
  60. package/dist/crons/index.cjs +2 -2
  61. package/dist/crons/index.mjs +2 -2
  62. package/dist/database/kysely.cjs +1 -1
  63. package/dist/endpoints/index.cjs +3 -3
  64. package/dist/endpoints/index.mjs +3 -3
  65. package/dist/file-server.cjs +1 -1
  66. package/dist/file-server.mjs +1 -1
  67. package/dist/functions/index.cjs +1 -1
  68. package/dist/functions/index.mjs +1 -1
  69. package/dist/{functions-BF039DT8.mjs → functions-BvIDQKAA.mjs} +2 -2
  70. package/dist/{functions-BF039DT8.mjs.map → functions-BvIDQKAA.mjs.map} +1 -1
  71. package/dist/{functions-BqAq_0xQ.cjs → functions-DLF6-IK8.cjs} +3 -3
  72. package/dist/{functions-BqAq_0xQ.cjs.map → functions-DLF6-IK8.cjs.map} +1 -1
  73. package/dist/inbox.cjs +1 -1
  74. package/dist/inbox.mjs +1 -1
  75. package/dist/index.cjs +1 -1
  76. package/dist/index.mjs +1 -1
  77. package/dist/{kysely-CeoQdAkg.cjs → kysely-CukArHJ0.cjs} +2 -2
  78. package/dist/{kysely-CeoQdAkg.cjs.map → kysely-CukArHJ0.cjs.map} +1 -1
  79. package/dist/origins-BjxYht13.cjs +96 -0
  80. package/dist/origins-BjxYht13.cjs.map +1 -0
  81. package/dist/origins-Boc9qbo-.mjs +73 -0
  82. package/dist/origins-Boc9qbo-.mjs.map +1 -0
  83. package/dist/{pattern-YSqfAhXm.mjs → pattern-C1CEcglD.mjs} +2 -2
  84. package/dist/{pattern-YSqfAhXm.mjs.map → pattern-C1CEcglD.mjs.map} +1 -1
  85. package/dist/{pattern-HnNOPhE2.cjs → pattern-QFaUIr77.cjs} +2 -2
  86. package/dist/{pattern-HnNOPhE2.cjs.map → pattern-QFaUIr77.cjs.map} +1 -1
  87. package/dist/processors/index.cjs +1 -1
  88. package/dist/processors/index.mjs +1 -1
  89. package/dist/queue/index.cjs +2 -2
  90. package/dist/queue/index.mjs +2 -2
  91. package/dist/rest-api.cjs +1 -1
  92. package/dist/rest-api.mjs +1 -1
  93. package/dist/{rolldown-runtime-Ctb5zv51.cjs → rolldown-runtime-y5ARvAq5.cjs} +0 -15
  94. package/dist/subscribers/index.cjs +1 -1
  95. package/dist/subscribers/index.mjs +1 -1
  96. package/dist/topic/index.cjs +1 -1
  97. package/dist/topic/index.mjs +1 -1
  98. package/dist/{websocket-api-BvKS9x-l.mjs → websocket-api-Bg9SowJ5.mjs} +12 -13
  99. package/dist/{websocket-api-BvKS9x-l.mjs.map → websocket-api-Bg9SowJ5.mjs.map} +1 -1
  100. package/dist/{websocket-api-CDAxOTQZ.d.mts → websocket-api-CPEzJyDt.d.mts} +22 -2
  101. package/dist/websocket-api-CPEzJyDt.d.mts.map +1 -0
  102. package/dist/{websocket-api-C3dWKNxO.d.cts → websocket-api-DkF8Hva-.d.cts} +22 -2
  103. package/dist/websocket-api-DkF8Hva-.d.cts.map +1 -0
  104. package/dist/{websocket-api-CAQA_QOE.cjs → websocket-api-czxhekGG.cjs} +12 -13
  105. package/dist/websocket-api-czxhekGG.cjs.map +1 -0
  106. package/dist/websocket-api.cjs +4 -1
  107. package/dist/websocket-api.d.cts +2 -2
  108. package/dist/websocket-api.d.mts +2 -2
  109. package/dist/websocket-api.mjs +3 -2
  110. package/dist/worker.cjs +4 -4
  111. package/dist/worker.mjs +4 -4
  112. package/package.json +47 -31
  113. package/dist/apigateway-Dyjy_JwI.mjs.map +0 -1
  114. package/dist/apigateway-zHDoMwlI.cjs.map +0 -1
  115. package/dist/origins-C7T9covD.cjs +0 -24
  116. package/dist/origins-C7T9covD.cjs.map +0 -1
  117. package/dist/origins-CX6Ot7ax.mjs +0 -19
  118. package/dist/origins-CX6Ot7ax.mjs.map +0 -1
  119. package/dist/websocket-api-C3dWKNxO.d.cts.map +0 -1
  120. package/dist/websocket-api-CAQA_QOE.cjs.map +0 -1
  121. package/dist/websocket-api-CDAxOTQZ.d.mts.map +0 -1
@@ -0,0 +1,156 @@
1
+ import { L as Connection, _t as WebSocketSink, a as WebSocketSinkDriver, ht as WebSocketMessages, n as WebSocketApi, pt as NoMessages } from "../websocket-api-CPEzJyDt.mjs";
2
+ import { ApiGatewayWebSocketTarget } from "@geekmidas/manifest";
3
+ import { EnvironmentParser } from "@geekmidas/envkit";
4
+ import { ApiGatewayManagementApiClient } from "@aws-sdk/client-apigatewaymanagementapi";
5
+ import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
6
+ //#region src/websocket/apigateway.d.ts
7
+ /**
8
+ * How long a row outlives its connection's start. API Gateway closes every
9
+ * connection after two hours, so a row the `$disconnect` never deleted — a
10
+ * Lambda that timed out — expires a little after that.
11
+ */
12
+ export declare const CONNECTION_TTL_SECONDS: number;
13
+ /**
14
+ * Where a surface's open connections are kept on API Gateway, by id: the
15
+ * `data` its connect handler returned, which every later invocation hands
16
+ * to its route, and the list a broadcast goes to.
17
+ */
18
+ interface ConnectionTable {
19
+ put(connection: Connection): Promise<void>;
20
+ get(id: string): Promise<Connection | undefined>;
21
+ delete(ids: readonly string[]): Promise<void>;
22
+ /** Every open connection's id. */
23
+ ids(): Promise<string[]>;
24
+ }
25
+ /**
26
+ * The connection table in DynamoDB: one item per connection, keyed by
27
+ * `connectionId`, with its `data` as JSON and an `expiresAt` the table's TTL
28
+ * reads. Provisioned beside the API by `@geekmidas/cloud`, so a surface on
29
+ * AWS needs nothing declared for it.
30
+ */
31
+ export declare class DynamoConnectionTable implements ConnectionTable {
32
+ readonly table: string;
33
+ private readonly options;
34
+ private readonly connections;
35
+ /** A table on a client of DynamoDB at `region` (or an emulator's `endpoint`). */
36
+ static create(table: string, options: {
37
+ region: string;
38
+ /** An emulator's address; AWS's own when absent. */
39
+ endpoint?: string;
40
+ /** Seconds a row is kept. Default {@link CONNECTION_TTL_SECONDS}. */
41
+ ttl?: number;
42
+ }): DynamoConnectionTable;
43
+ constructor(table: string, client: DynamoDBClient, options?: {
44
+ /** Seconds a row is kept. Default {@link CONNECTION_TTL_SECONDS}. */
45
+ ttl?: number;
46
+ });
47
+ put(connection: Connection): Promise<void>;
48
+ get(id: string): Promise<Connection | undefined>;
49
+ delete(ids: readonly string[]): Promise<void>;
50
+ ids(): Promise<string[]>;
51
+ }
52
+ /**
53
+ * A publisher's sink on API Gateway: each send a `postToConnection`, each
54
+ * close a `deleteConnection`, a broadcast every id in the table. A connection
55
+ * that has gone answers 410; it is dropped from the table, and the send to
56
+ * the rest goes on.
57
+ *
58
+ * API Gateway closes a connection with a code of its own: `close(ids, code,
59
+ * reason)` ends the connections, but its client does not see `code` or
60
+ * `reason`.
61
+ */
62
+ export declare class ApiGatewaySink implements WebSocketSink {
63
+ private readonly client;
64
+ private readonly table;
65
+ /** A sink on a client of the management API at `target`. */
66
+ static create(target: Pick<ApiGatewayWebSocketTarget, 'endpoint' | 'region'>, table: ConnectionTable): ApiGatewaySink;
67
+ constructor(client: ApiGatewayManagementApiClient, table: ConnectionTable);
68
+ send(ids: readonly string[], payload: string): Promise<void>;
69
+ broadcast(payload: string, except?: readonly string[]): Promise<void>;
70
+ close(ids: readonly string[]): Promise<void>;
71
+ /** Call `fn` for each id; the ids that had gone. Anything else throws. */
72
+ private each;
73
+ }
74
+ /**
75
+ * `services.<surface>` on an AWS stage: the management API's sink for an
76
+ * `apigateway://` publisher string. An AWS build's entry registers it with
77
+ * `registerWebSocketSinkDriver`, and {@link AmazonApiGatewayWebSocket} does
78
+ * for its own Lambda.
79
+ */
80
+ export declare const apiGatewayWebSocketDriver: WebSocketSinkDriver;
81
+ /** A table and a sink from an `apigateway://` publisher string. */
82
+ export declare function apiGatewayFromConnectionString(connectionString: string): {
83
+ target: ApiGatewayWebSocketTarget;
84
+ table: DynamoConnectionTable;
85
+ sink: ApiGatewaySink;
86
+ };
87
+ /**
88
+ * What API Gateway invokes a WebSocket route's Lambda with — the fields this
89
+ * adaptor reads. `headers` and the query arrive on `$connect` only.
90
+ */
91
+ interface ApiGatewayWebSocketEvent {
92
+ requestContext: {
93
+ connectionId: string;
94
+ eventType: 'CONNECT' | 'MESSAGE' | 'DISCONNECT';
95
+ routeKey: string;
96
+ disconnectStatusCode?: number;
97
+ disconnectReason?: string;
98
+ };
99
+ headers?: Record<string, string | undefined> | null;
100
+ multiValueHeaders?: Record<string, string[] | undefined> | null;
101
+ queryStringParameters?: Record<string, string | undefined> | null;
102
+ multiValueQueryStringParameters?: Record<string, string[] | undefined> | null;
103
+ body?: string | null;
104
+ isBase64Encoded?: boolean;
105
+ }
106
+ /** What the Lambda answers: a non-2xx on `$connect` refuses the socket. */
107
+ interface ApiGatewayWebSocketResult {
108
+ statusCode: number;
109
+ body?: string;
110
+ }
111
+ interface AmazonApiGatewayWebSocketOptions {
112
+ /**
113
+ * Files exporting the routes this Lambda serves — the generated handler
114
+ * hands in the one route API Gateway invokes it for.
115
+ */
116
+ modules?: readonly object[];
117
+ /** Where the surface's keys are read. Absent, the surface's own parser. */
118
+ envParser?: EnvironmentParser<{}>;
119
+ /**
120
+ * The connection table and the sink, in place of the ones the
121
+ * `apigateway://` publisher string names.
122
+ */
123
+ table?: ConnectionTable;
124
+ sink?: WebSocketSink;
125
+ }
126
+ /**
127
+ * A WebSocket surface served by API Gateway: `handler` is the Lambda for one
128
+ * or more of its routes.
129
+ *
130
+ * ```ts
131
+ * // .gkm/aws/websocket/routes/send.ts, as `gkm build --provider aws` writes it
132
+ * const adaptor = new AmazonApiGatewayWebSocket(realtime, { modules: [{ send }] });
133
+ * export const handler = adaptor.handler;
134
+ * ```
135
+ */
136
+ export declare class AmazonApiGatewayWebSocket<TMessages extends WebSocketMessages = NoMessages> {
137
+ private readonly surface;
138
+ private readonly options;
139
+ private ready?;
140
+ constructor(surface: WebSocketApi<string, TMessages>, options?: AmazonApiGatewayWebSocketOptions);
141
+ /** The Lambda handler. */
142
+ readonly handler: (event: ApiGatewayWebSocketEvent) => Promise<ApiGatewayWebSocketResult>;
143
+ private get logger();
144
+ /** Read the keys and build the core once per container. */
145
+ private setup;
146
+ handle(event: ApiGatewayWebSocketEvent): Promise<ApiGatewayWebSocketResult>;
147
+ }
148
+ /** A Lambda of the surface was started without its publisher string. */
149
+ export declare class WebSocketPublisherNotConfigured extends Error {
150
+ readonly surface: string;
151
+ readonly key: string;
152
+ constructor(surface: string, key: string);
153
+ }
154
+ //#endregion
155
+ export type { AmazonApiGatewayWebSocketOptions, ApiGatewayWebSocketEvent, ApiGatewayWebSocketResult, ConnectionTable };
156
+ //# sourceMappingURL=awsWebsocket.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"awsWebsocket.d.mts","names":[],"sources":["../../src/websocket/apigateway.ts"],"mappings":";;;;;;;;;;;qBAuDa;;;;;;UAOI;EAChB,IAAI,YAAY,aAAa;EAC7B,IAAI,aAAa,QAAQ;EACzB,OAAO,yBAAyB;;EAEhC,OAAO;;;;;;;;qBASK,iCAAiC;WAsBnC;mBAEQ;mBAvBD;;SAGV,OACN,eACA;IACC;;IAEA;;IAEA;MAEC;EAQH,YACU,eACT,QAAQ,gBACS;;IAEhB;;EAMI,IAAI,YAAY,aAAa;EAW7B,IAAI,aAAa,QAAQ;EASzB,OAAO,yBAAyB;EAOhC,OAAO;;;;;;;;;;;;qBAoDD,0BAA0B;mBAcpB;mBACA;;SAbX,OACN,QAAQ,KAAK,mDACb,OAAO,kBACL;EAQH,YACkB,QAAQ,+BACR,OAAO;EAGnB,KAAK,wBAAwB,kBAAkB;EAc/C,UAAU,iBAAiB,6BAA6B;EAMxD,MAAM,yBAAyB;;UAWvB;;;;;;;;qBAyBF,2BAA2B;;wBAOxB,+BAA+B;EAC9C,QAAQ;EACR,OAAO;EACP,MAAM;;;;;;UAcU;EAChB;IACC;IACA;IACA;IACA;IACA;;EAED,UAAU;EACV,oBAAoB;EACpB,wBAAwB;EACxB,kCAAkC;EAClC;EACA;;;UAIgB;EAChB;EACA;;UAGgB;;;;;EAKhB;;EAEA,YAAY;;;;;EAKZ,QAAQ;EACR,OAAO;;;;;;;;;;;;qBAaK,0BACZ,kBAAkB,oBAAoB;mBAUpB;mBACA;UATV;EAOR,YACkB,SAAS,qBAAqB,YAC9B,UAAS;;WAOlB,UAAO,OACR,6BACL,QAAQ;cAEC;;UAKJ;EAoDF,OACL,OAAO,2BACL,QAAQ;;;qBAgEC,wCAAwC;WAE1C;WACA;EAFV,YACU,iBACA"}
@@ -1,110 +1,126 @@
1
- import { o as __exportAll } from "./Construct-CRV3RN2U.mjs";
2
- import { t as OptionalPeerMissing } from "./optionalPeers-D7Wt6dnF.mjs";
3
- import { t as ownOrigins } from "./origins-CX6Ot7ax.mjs";
4
- import { parseApiGatewayWebSocketUrl, trustsOrigin } from "@geekmidas/manifest";
1
+ import { r as registerWebSocketSinkDriver, t as ownOrigins } from "../origins-Boc9qbo-.mjs";
2
+ import { API_GATEWAY_WEBSOCKET_SCHEME, parseApiGatewayWebSocketUrl, trustsOrigin } from "@geekmidas/manifest";
3
+ import { ApiGatewayManagementApiClient, DeleteConnectionCommand, PostToConnectionCommand } from "@aws-sdk/client-apigatewaymanagementapi";
4
+ import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
5
+ import { Entity } from "electrodb";
5
6
  //#region src/websocket/apigateway.ts
6
- var apigateway_exports = /* @__PURE__ */ __exportAll({
7
- AmazonApiGatewayWebSocket: () => AmazonApiGatewayWebSocket,
8
- ApiGatewaySink: () => ApiGatewaySink,
9
- CONNECTION_TTL_SECONDS: () => CONNECTION_TTL_SECONDS,
10
- DynamoConnectionTable: () => DynamoConnectionTable,
11
- WebSocketPublisherNotConfigured: () => WebSocketPublisherNotConfigured,
12
- apiGatewayFromConnectionString: () => apiGatewayFromConnectionString
13
- });
7
+ /**
8
+ * The API Gateway (v2, WebSocket) adaptor: a Lambda per route, over the
9
+ * surface's `WebSocketCore`.
10
+ *
11
+ * API Gateway holds the sockets. A Lambda only sees events — `$connect`, a
12
+ * frame on a route, `$disconnect` — so this owns what the gateway does not:
13
+ *
14
+ * - **the Origin check** in `$connect`, against the same origins the Node
15
+ * adaptor trusts;
16
+ * - **the connection table**, where a connection's `data` (what the connect
17
+ * handler returned) is kept between invocations, and the ids a broadcast
18
+ * goes to are read from;
19
+ * - **the sink**, `postToConnection` and `deleteConnection` on the management
20
+ * API, with a connection that has gone (410) dropped from the table rather
21
+ * than reported — as a Redis publisher drops a socket nobody holds.
22
+ *
23
+ * Both are reached through the surface's `<ID>_PUBLISHER_CONNECTION_STRING`,
24
+ * an `apigateway://` string on an AWS stage, which is also what
25
+ * `services.<surface>` reads in any other Lambda.
26
+ *
27
+ * This is the AWS adaptor, `@geekmidas/constructs/aws-websocket`: it imports
28
+ * the AWS SDK clients it is built on, so they are needed only by a project
29
+ * that serves a surface from API Gateway.
30
+ */
14
31
  /**
15
32
  * How long a row outlives its connection's start. API Gateway closes every
16
33
  * connection after two hours, so a row the `$disconnect` never deleted — a
17
34
  * Lambda that timed out — expires a little after that.
18
35
  */
19
36
  const CONNECTION_TTL_SECONDS = 7800;
20
- async function loadDynamo() {
21
- try {
22
- return await import("@aws-sdk/client-dynamodb");
23
- } catch (cause) {
24
- throw new OptionalPeerMissing("@aws-sdk/client-dynamodb", "A WebSocketApi served by API Gateway", cause);
25
- }
26
- }
27
- async function loadManagement() {
28
- try {
29
- return await import("@aws-sdk/client-apigatewaymanagementapi");
30
- } catch (cause) {
31
- throw new OptionalPeerMissing("@aws-sdk/client-apigatewaymanagementapi", "A WebSocketApi served by API Gateway", cause);
32
- }
33
- }
34
37
  /**
35
38
  * The connection table in DynamoDB: one item per connection, keyed by
36
39
  * `connectionId`, with its `data` as JSON and an `expiresAt` the table's TTL
37
40
  * reads. Provisioned beside the API by `@geekmidas/cloud`, so a surface on
38
41
  * AWS needs nothing declared for it.
39
42
  */
40
- var DynamoConnectionTable = class {
43
+ var DynamoConnectionTable = class DynamoConnectionTable {
41
44
  table;
42
45
  options;
43
- client;
44
- constructor(table, options) {
46
+ connections;
47
+ /** A table on a client of DynamoDB at `region` (or an emulator's `endpoint`). */
48
+ static create(table, options) {
49
+ const client = new DynamoDBClient({
50
+ region: options.region,
51
+ ...options.endpoint ? { endpoint: options.endpoint } : {}
52
+ });
53
+ return new DynamoConnectionTable(table, client, { ttl: options.ttl });
54
+ }
55
+ constructor(table, client, options = {}) {
45
56
  this.table = table;
46
57
  this.options = options;
47
- }
48
- connect() {
49
- this.client ??= loadDynamo().then((dynamo) => ({
50
- dynamo,
51
- client: new dynamo.DynamoDBClient({
52
- region: this.options.region,
53
- ...this.options.endpoint ? { endpoint: this.options.endpoint } : {}
54
- })
55
- }));
56
- return this.client;
58
+ this.connections = connectionEntity(table, client);
57
59
  }
58
60
  async put(connection) {
59
- const { dynamo, client } = await this.connect();
60
61
  const ttl = this.options.ttl ?? 7800;
61
- await client.send(new dynamo.PutItemCommand({
62
- TableName: this.table,
63
- Item: {
64
- connectionId: { S: connection.id },
65
- data: { S: JSON.stringify(connection.data) },
66
- expiresAt: { N: String(nowSeconds() + ttl) }
67
- }
68
- }));
62
+ await this.connections.put({
63
+ connectionId: connection.id,
64
+ data: JSON.stringify(connection.data),
65
+ expiresAt: nowSeconds() + ttl
66
+ }).go();
69
67
  }
70
68
  async get(id) {
71
- const { dynamo, client } = await this.connect();
72
- const { Item: item } = await client.send(new dynamo.GetItemCommand({
73
- TableName: this.table,
74
- Key: { connectionId: { S: id } },
75
- ConsistentRead: true
76
- }));
77
- if (!item || expired(item)) return void 0;
69
+ const { data: item } = await this.connections.get({ connectionId: id }).go({ consistent: true });
70
+ if (!item || item.expiresAt <= nowSeconds()) return void 0;
78
71
  return {
79
72
  id,
80
- data: JSON.parse(item.data?.S ?? "{}")
73
+ data: JSON.parse(item.data)
81
74
  };
82
75
  }
83
76
  async delete(ids) {
84
77
  if (ids.length === 0) return;
85
- const { dynamo, client } = await this.connect();
86
- await Promise.all(ids.map((id) => client.send(new dynamo.DeleteItemCommand({
87
- TableName: this.table,
88
- Key: { connectionId: { S: id } }
89
- }))));
78
+ await this.connections.delete(ids.map((connectionId) => ({ connectionId }))).go();
90
79
  }
91
80
  async ids() {
92
- const { dynamo, client } = await this.connect();
93
- const ids = [];
94
- let start;
95
- do {
96
- const page = await client.send(new dynamo.ScanCommand({
97
- TableName: this.table,
98
- ProjectionExpression: "connectionId, expiresAt",
99
- ...start ? { ExclusiveStartKey: start } : {}
100
- }));
101
- for (const item of page.Items ?? []) if (item.connectionId?.S && !expired(item)) ids.push(item.connectionId.S);
102
- start = page.LastEvaluatedKey;
103
- } while (start);
104
- return ids;
81
+ const { data: items } = await this.connections.scan.where(({ expiresAt }, { gt }) => gt(expiresAt, nowSeconds())).go({
82
+ pages: "all",
83
+ attributes: ["connectionId", "expiresAt"]
84
+ });
85
+ return items.map((item) => item.connectionId);
105
86
  }
106
87
  };
107
88
  /**
89
+ * One connection's row. The table's hash key is the `connectionId` attribute
90
+ * itself, as `@geekmidas/cloud` provisions it, and `expiresAt` is its TTL.
91
+ */
92
+ function connectionEntity(table, client) {
93
+ return new Entity({
94
+ model: {
95
+ entity: "connection",
96
+ service: "gkm-websocket",
97
+ version: "1"
98
+ },
99
+ attributes: {
100
+ connectionId: {
101
+ type: "string",
102
+ required: true
103
+ },
104
+ data: {
105
+ type: "string",
106
+ required: true
107
+ },
108
+ expiresAt: {
109
+ type: "number",
110
+ required: true
111
+ }
112
+ },
113
+ indexes: { primary: { pk: {
114
+ field: "connectionId",
115
+ composite: ["connectionId"],
116
+ casing: "none"
117
+ } } }
118
+ }, {
119
+ table,
120
+ client
121
+ });
122
+ }
123
+ /**
108
124
  * A publisher's sink on API Gateway: each send a `postToConnection`, each
109
125
  * close a `deleteConnection`, a broadcast every id in the table. A connection
110
126
  * that has gone answers 410; it is dropped from the table, and the send to
@@ -114,29 +130,25 @@ var DynamoConnectionTable = class {
114
130
  * reason)` ends the connections, but its client does not see `code` or
115
131
  * `reason`.
116
132
  */
117
- var ApiGatewaySink = class {
118
- target;
119
- table;
133
+ var ApiGatewaySink = class ApiGatewaySink {
120
134
  client;
121
- constructor(target, table) {
122
- this.target = target;
123
- this.table = table;
135
+ table;
136
+ /** A sink on a client of the management API at `target`. */
137
+ static create(target, table) {
138
+ const client = new ApiGatewayManagementApiClient({
139
+ region: target.region,
140
+ endpoint: target.endpoint
141
+ });
142
+ return new ApiGatewaySink(client, table);
124
143
  }
125
- connect() {
126
- this.client ??= loadManagement().then((management) => ({
127
- management,
128
- client: new management.ApiGatewayManagementApiClient({
129
- region: this.target.region,
130
- endpoint: this.target.endpoint
131
- })
132
- }));
133
- return this.client;
144
+ constructor(client, table) {
145
+ this.client = client;
146
+ this.table = table;
134
147
  }
135
148
  async send(ids, payload) {
136
149
  if (ids.length === 0) return;
137
- const { management, client } = await this.connect();
138
150
  const data = new TextEncoder().encode(payload);
139
- const gone = await this.each(ids, (id) => client.send(new management.PostToConnectionCommand({
151
+ const gone = await this.each(ids, (id) => this.client.send(new PostToConnectionCommand({
140
152
  ConnectionId: id,
141
153
  Data: data
142
154
  })));
@@ -149,8 +161,7 @@ var ApiGatewaySink = class {
149
161
  }
150
162
  async close(ids) {
151
163
  if (ids.length === 0) return;
152
- const { management, client } = await this.connect();
153
- await this.each(ids, (id) => client.send(new management.DeleteConnectionCommand({ ConnectionId: id })));
164
+ await this.each(ids, (id) => this.client.send(new DeleteConnectionCommand({ ConnectionId: id })));
154
165
  await this.table.delete(ids);
155
166
  }
156
167
  /** Call `fn` for each id; the ids that had gone. Anything else throws. */
@@ -167,17 +178,27 @@ var ApiGatewaySink = class {
167
178
  return gone;
168
179
  }
169
180
  };
181
+ /**
182
+ * `services.<surface>` on an AWS stage: the management API's sink for an
183
+ * `apigateway://` publisher string. An AWS build's entry registers it with
184
+ * `registerWebSocketSinkDriver`, and {@link AmazonApiGatewayWebSocket} does
185
+ * for its own Lambda.
186
+ */
187
+ const apiGatewayWebSocketDriver = {
188
+ scheme: API_GATEWAY_WEBSOCKET_SCHEME,
189
+ sink: (connectionString) => apiGatewayFromConnectionString(connectionString).sink
190
+ };
170
191
  /** A table and a sink from an `apigateway://` publisher string. */
171
192
  function apiGatewayFromConnectionString(connectionString) {
172
193
  const target = parseApiGatewayWebSocketUrl(connectionString);
173
- const table = new DynamoConnectionTable(target.table, {
194
+ const table = DynamoConnectionTable.create(target.table, {
174
195
  region: target.region,
175
196
  ...target.tableEndpoint ? { endpoint: target.tableEndpoint } : {}
176
197
  });
177
198
  return {
178
199
  target,
179
200
  table,
180
- sink: new ApiGatewaySink(target, table)
201
+ sink: ApiGatewaySink.create(target, table)
181
202
  };
182
203
  }
183
204
  /**
@@ -197,6 +218,7 @@ var AmazonApiGatewayWebSocket = class {
197
218
  constructor(surface, options = {}) {
198
219
  this.surface = surface;
199
220
  this.options = options;
221
+ registerWebSocketSinkDriver(apiGatewayWebSocketDriver);
200
222
  }
201
223
  /** The Lambda handler. */
202
224
  handler = (event) => this.handle(event);
@@ -319,11 +341,7 @@ function isGone(error) {
319
341
  function nowSeconds() {
320
342
  return Math.floor(Date.now() / 1e3);
321
343
  }
322
- function expired(item) {
323
- const at = Number(item.expiresAt?.N);
324
- return Number.isFinite(at) && at > 0 && at <= nowSeconds();
325
- }
326
344
  //#endregion
327
- export { WebSocketPublisherNotConfigured as a, DynamoConnectionTable as i, ApiGatewaySink as n, apiGatewayFromConnectionString as o, CONNECTION_TTL_SECONDS as r, apigateway_exports as s, AmazonApiGatewayWebSocket as t };
345
+ export { AmazonApiGatewayWebSocket, ApiGatewaySink, CONNECTION_TTL_SECONDS, DynamoConnectionTable, WebSocketPublisherNotConfigured, apiGatewayFromConnectionString, apiGatewayWebSocketDriver };
328
346
 
329
- //# sourceMappingURL=apigateway-Dyjy_JwI.mjs.map
347
+ //# sourceMappingURL=awsWebsocket.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"awsWebsocket.mjs","names":[],"sources":["../../src/websocket/apigateway.ts"],"sourcesContent":["/**\n * The API Gateway (v2, WebSocket) adaptor: a Lambda per route, over the\n * surface's `WebSocketCore`.\n *\n * API Gateway holds the sockets. A Lambda only sees events — `$connect`, a\n * frame on a route, `$disconnect` — so this owns what the gateway does not:\n *\n * - **the Origin check** in `$connect`, against the same origins the Node\n * adaptor trusts;\n * - **the connection table**, where a connection's `data` (what the connect\n * handler returned) is kept between invocations, and the ids a broadcast\n * goes to are read from;\n * - **the sink**, `postToConnection` and `deleteConnection` on the management\n * API, with a connection that has gone (410) dropped from the table rather\n * than reported — as a Redis publisher drops a socket nobody holds.\n *\n * Both are reached through the surface's `<ID>_PUBLISHER_CONNECTION_STRING`,\n * an `apigateway://` string on an AWS stage, which is also what\n * `services.<surface>` reads in any other Lambda.\n *\n * This is the AWS adaptor, `@geekmidas/constructs/aws-websocket`: it imports\n * the AWS SDK clients it is built on, so they are needed only by a project\n * that serves a surface from API Gateway.\n */\n\nimport {\n\tApiGatewayManagementApiClient,\n\tDeleteConnectionCommand,\n\tPostToConnectionCommand,\n} from '@aws-sdk/client-apigatewaymanagementapi';\nimport { DynamoDBClient } from '@aws-sdk/client-dynamodb';\nimport type { EnvironmentParser } from '@geekmidas/envkit';\nimport type { Logger } from '@geekmidas/logger';\nimport {\n\tAPI_GATEWAY_WEBSOCKET_SCHEME,\n\ttype ApiGatewayWebSocketTarget,\n\tparseApiGatewayWebSocketUrl,\n\ttrustsOrigin,\n} from '@geekmidas/manifest';\nimport { Entity } from 'electrodb';\nimport type { WebSocketApi } from '../websocket-api';\nimport type { WebSocketCore } from './core';\nimport {\n\tregisterWebSocketSinkDriver,\n\ttype WebSocketSinkDriver,\n} from './drivers';\nimport { ownOrigins } from './origins';\nimport type { NoMessages, WebSocketMessages, WebSocketSink } from './publisher';\nimport type { Connection } from './route';\n\n/**\n * How long a row outlives its connection's start. API Gateway closes every\n * connection after two hours, so a row the `$disconnect` never deleted — a\n * Lambda that timed out — expires a little after that.\n */\nexport const CONNECTION_TTL_SECONDS = 2 * 60 * 60 + 10 * 60;\n\n/**\n * Where a surface's open connections are kept on API Gateway, by id: the\n * `data` its connect handler returned, which every later invocation hands\n * to its route, and the list a broadcast goes to.\n */\nexport interface ConnectionTable {\n\tput(connection: Connection): Promise<void>;\n\tget(id: string): Promise<Connection | undefined>;\n\tdelete(ids: readonly string[]): Promise<void>;\n\t/** Every open connection's id. */\n\tids(): Promise<string[]>;\n}\n\n/**\n * The connection table in DynamoDB: one item per connection, keyed by\n * `connectionId`, with its `data` as JSON and an `expiresAt` the table's TTL\n * reads. Provisioned beside the API by `@geekmidas/cloud`, so a surface on\n * AWS needs nothing declared for it.\n */\nexport class DynamoConnectionTable implements ConnectionTable {\n\tprivate readonly connections: ReturnType<typeof connectionEntity>;\n\n\t/** A table on a client of DynamoDB at `region` (or an emulator's `endpoint`). */\n\tstatic create(\n\t\ttable: string,\n\t\toptions: {\n\t\t\tregion: string;\n\t\t\t/** An emulator's address; AWS's own when absent. */\n\t\t\tendpoint?: string;\n\t\t\t/** Seconds a row is kept. Default {@link CONNECTION_TTL_SECONDS}. */\n\t\t\tttl?: number;\n\t\t},\n\t): DynamoConnectionTable {\n\t\tconst client = new DynamoDBClient({\n\t\t\tregion: options.region,\n\t\t\t...(options.endpoint ? { endpoint: options.endpoint } : {}),\n\t\t});\n\t\treturn new DynamoConnectionTable(table, client, { ttl: options.ttl });\n\t}\n\n\tconstructor(\n\t\treadonly table: string,\n\t\tclient: DynamoDBClient,\n\t\tprivate readonly options: {\n\t\t\t/** Seconds a row is kept. Default {@link CONNECTION_TTL_SECONDS}. */\n\t\t\tttl?: number;\n\t\t} = {},\n\t) {\n\t\tthis.connections = connectionEntity(table, client);\n\t}\n\n\tasync put(connection: Connection): Promise<void> {\n\t\tconst ttl = this.options.ttl ?? CONNECTION_TTL_SECONDS;\n\t\tawait this.connections\n\t\t\t.put({\n\t\t\t\tconnectionId: connection.id,\n\t\t\t\tdata: JSON.stringify(connection.data),\n\t\t\t\texpiresAt: nowSeconds() + ttl,\n\t\t\t})\n\t\t\t.go();\n\t}\n\n\tasync get(id: string): Promise<Connection | undefined> {\n\t\t// `$connect` wrote it a moment ago; the first frame must see it.\n\t\tconst { data: item } = await this.connections\n\t\t\t.get({ connectionId: id })\n\t\t\t.go({ consistent: true });\n\t\tif (!item || item.expiresAt <= nowSeconds()) return undefined;\n\t\treturn { id, data: JSON.parse(item.data) };\n\t}\n\n\tasync delete(ids: readonly string[]): Promise<void> {\n\t\tif (ids.length === 0) return;\n\t\tawait this.connections\n\t\t\t.delete(ids.map((connectionId) => ({ connectionId })))\n\t\t\t.go();\n\t}\n\n\tasync ids(): Promise<string[]> {\n\t\tconst { data: items } = await this.connections.scan\n\t\t\t.where(({ expiresAt }, { gt }) => gt(expiresAt, nowSeconds()))\n\t\t\t.go({ pages: 'all', attributes: ['connectionId', 'expiresAt'] });\n\t\t// DynamoDB deletes an expired item eventually, not on time.\n\t\treturn items.map((item) => item.connectionId);\n\t}\n}\n\n/**\n * One connection's row. The table's hash key is the `connectionId` attribute\n * itself, as `@geekmidas/cloud` provisions it, and `expiresAt` is its TTL.\n */\nfunction connectionEntity(table: string, client: DynamoDBClient) {\n\treturn new Entity(\n\t\t{\n\t\t\tmodel: {\n\t\t\t\tentity: 'connection',\n\t\t\t\tservice: 'gkm-websocket',\n\t\t\t\tversion: '1',\n\t\t\t},\n\t\t\tattributes: {\n\t\t\t\tconnectionId: { type: 'string', required: true },\n\t\t\t\tdata: { type: 'string', required: true },\n\t\t\t\texpiresAt: { type: 'number', required: true },\n\t\t\t},\n\t\t\tindexes: {\n\t\t\t\tprimary: {\n\t\t\t\t\t// A connection id is case-sensitive; ElectroDB lowercases keys\n\t\t\t\t\t// unless told not to, and a lowered id is a 410 on every post.\n\t\t\t\t\tpk: {\n\t\t\t\t\t\tfield: 'connectionId',\n\t\t\t\t\t\tcomposite: ['connectionId'],\n\t\t\t\t\t\tcasing: 'none',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{ table, client },\n\t);\n}\n\n/**\n * A publisher's sink on API Gateway: each send a `postToConnection`, each\n * close a `deleteConnection`, a broadcast every id in the table. A connection\n * that has gone answers 410; it is dropped from the table, and the send to\n * the rest goes on.\n *\n * API Gateway closes a connection with a code of its own: `close(ids, code,\n * reason)` ends the connections, but its client does not see `code` or\n * `reason`.\n */\nexport class ApiGatewaySink implements WebSocketSink {\n\t/** A sink on a client of the management API at `target`. */\n\tstatic create(\n\t\ttarget: Pick<ApiGatewayWebSocketTarget, 'endpoint' | 'region'>,\n\t\ttable: ConnectionTable,\n\t): ApiGatewaySink {\n\t\tconst client = new ApiGatewayManagementApiClient({\n\t\t\tregion: target.region,\n\t\t\tendpoint: target.endpoint,\n\t\t});\n\t\treturn new ApiGatewaySink(client, table);\n\t}\n\n\tconstructor(\n\t\tprivate readonly client: ApiGatewayManagementApiClient,\n\t\tprivate readonly table: ConnectionTable,\n\t) {}\n\n\tasync send(ids: readonly string[], payload: string): Promise<void> {\n\t\tif (ids.length === 0) return;\n\t\tconst data = new TextEncoder().encode(payload);\n\t\tconst gone = await this.each(ids, (id) =>\n\t\t\tthis.client.send(\n\t\t\t\tnew PostToConnectionCommand({\n\t\t\t\t\tConnectionId: id,\n\t\t\t\t\tData: data,\n\t\t\t\t}),\n\t\t\t),\n\t\t);\n\t\tawait this.table.delete(gone);\n\t}\n\n\tasync broadcast(payload: string, except?: readonly string[]): Promise<void> {\n\t\tconst skip = new Set(except ?? []);\n\t\tconst ids = (await this.table.ids()).filter((id) => !skip.has(id));\n\t\tawait this.send(ids, payload);\n\t}\n\n\tasync close(ids: readonly string[]): Promise<void> {\n\t\tif (ids.length === 0) return;\n\t\tawait this.each(ids, (id) =>\n\t\t\tthis.client.send(new DeleteConnectionCommand({ ConnectionId: id })),\n\t\t);\n\t\t// Its `$disconnect` deletes the row too; a connection that was already\n\t\t// gone has no `$disconnect` left to run.\n\t\tawait this.table.delete(ids);\n\t}\n\n\t/** Call `fn` for each id; the ids that had gone. Anything else throws. */\n\tprivate async each(\n\t\tids: readonly string[],\n\t\tfn: (id: string) => Promise<unknown>,\n\t): Promise<string[]> {\n\t\tconst gone: string[] = [];\n\t\tawait Promise.all(\n\t\t\tids.map(async (id) => {\n\t\t\t\ttry {\n\t\t\t\t\tawait fn(id);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (!isGone(error)) throw error;\n\t\t\t\t\tgone.push(id);\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\t\treturn gone;\n\t}\n}\n\n/**\n * `services.<surface>` on an AWS stage: the management API's sink for an\n * `apigateway://` publisher string. An AWS build's entry registers it with\n * `registerWebSocketSinkDriver`, and {@link AmazonApiGatewayWebSocket} does\n * for its own Lambda.\n */\nexport const apiGatewayWebSocketDriver: WebSocketSinkDriver = {\n\tscheme: API_GATEWAY_WEBSOCKET_SCHEME,\n\tsink: (connectionString) =>\n\t\tapiGatewayFromConnectionString(connectionString).sink,\n};\n\n/** A table and a sink from an `apigateway://` publisher string. */\nexport function apiGatewayFromConnectionString(connectionString: string): {\n\ttarget: ApiGatewayWebSocketTarget;\n\ttable: DynamoConnectionTable;\n\tsink: ApiGatewaySink;\n} {\n\tconst target = parseApiGatewayWebSocketUrl(connectionString);\n\tconst table = DynamoConnectionTable.create(target.table, {\n\t\tregion: target.region,\n\t\t...(target.tableEndpoint ? { endpoint: target.tableEndpoint } : {}),\n\t});\n\treturn { target, table, sink: ApiGatewaySink.create(target, table) };\n}\n\n/**\n * What API Gateway invokes a WebSocket route's Lambda with — the fields this\n * adaptor reads. `headers` and the query arrive on `$connect` only.\n */\nexport interface ApiGatewayWebSocketEvent {\n\trequestContext: {\n\t\tconnectionId: string;\n\t\teventType: 'CONNECT' | 'MESSAGE' | 'DISCONNECT';\n\t\trouteKey: string;\n\t\tdisconnectStatusCode?: number;\n\t\tdisconnectReason?: string;\n\t};\n\theaders?: Record<string, string | undefined> | null;\n\tmultiValueHeaders?: Record<string, string[] | undefined> | null;\n\tqueryStringParameters?: Record<string, string | undefined> | null;\n\tmultiValueQueryStringParameters?: Record<string, string[] | undefined> | null;\n\tbody?: string | null;\n\tisBase64Encoded?: boolean;\n}\n\n/** What the Lambda answers: a non-2xx on `$connect` refuses the socket. */\nexport interface ApiGatewayWebSocketResult {\n\tstatusCode: number;\n\tbody?: string;\n}\n\nexport interface AmazonApiGatewayWebSocketOptions {\n\t/**\n\t * Files exporting the routes this Lambda serves — the generated handler\n\t * hands in the one route API Gateway invokes it for.\n\t */\n\tmodules?: readonly object[];\n\t/** Where the surface's keys are read. Absent, the surface's own parser. */\n\tenvParser?: EnvironmentParser<{}>;\n\t/**\n\t * The connection table and the sink, in place of the ones the\n\t * `apigateway://` publisher string names.\n\t */\n\ttable?: ConnectionTable;\n\tsink?: WebSocketSink;\n}\n\n/**\n * A WebSocket surface served by API Gateway: `handler` is the Lambda for one\n * or more of its routes.\n *\n * ```ts\n * // .gkm/aws/websocket/routes/send.ts, as `gkm build --provider aws` writes it\n * const adaptor = new AmazonApiGatewayWebSocket(realtime, { modules: [{ send }] });\n * export const handler = adaptor.handler;\n * ```\n */\nexport class AmazonApiGatewayWebSocket<\n\tTMessages extends WebSocketMessages = NoMessages,\n> {\n\tprivate ready?: Promise<{\n\t\tcore: WebSocketCore<TMessages>;\n\t\ttable: ConnectionTable;\n\t\tsink: WebSocketSink;\n\t\ttrusted: string[];\n\t}>;\n\n\tconstructor(\n\t\tprivate readonly surface: WebSocketApi<string, TMessages>,\n\t\tprivate readonly options: AmazonApiGatewayWebSocketOptions = {},\n\t) {\n\t\t// A route's own `services.<surface>` publishes through API Gateway too.\n\t\tregisterWebSocketSinkDriver(apiGatewayWebSocketDriver);\n\t}\n\n\t/** The Lambda handler. */\n\treadonly handler = (\n\t\tevent: ApiGatewayWebSocketEvent,\n\t): Promise<ApiGatewayWebSocketResult> => this.handle(event);\n\n\tprivate get logger(): Logger {\n\t\treturn this.surface.logger;\n\t}\n\n\t/** Read the keys and build the core once per container. */\n\tprivate setup() {\n\t\tthis.ready ??= Promise.resolve().then(() => {\n\t\t\tconst envParser = this.options.envParser ?? this.surface.envParser;\n\t\t\tconst { keys } = this.surface;\n\t\t\tconst config = envParser\n\t\t\t\t.create((get) => ({\n\t\t\t\t\tconnectionString: get(keys.publisherConnectionString)\n\t\t\t\t\t\t.string()\n\t\t\t\t\t\t.optional(),\n\t\t\t\t\torigins: get(keys.trustedOrigins)\n\t\t\t\t\t\t.string()\n\t\t\t\t\t\t.default('')\n\t\t\t\t\t\t.transform((value: string) =>\n\t\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\t\t.split(',')\n\t\t\t\t\t\t\t\t.map((origin) => origin.trim())\n\t\t\t\t\t\t\t\t.filter(Boolean),\n\t\t\t\t\t\t),\n\t\t\t\t\turl: get(keys.url).string().optional(),\n\t\t\t\t}))\n\t\t\t\t.parse();\n\n\t\t\tlet { table, sink } = this.options;\n\t\t\tif (!table || !sink) {\n\t\t\t\tif (!config.connectionString) {\n\t\t\t\t\tthrow new WebSocketPublisherNotConfigured(\n\t\t\t\t\t\tthis.surface.id,\n\t\t\t\t\t\tkeys.publisherConnectionString,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst fromString = apiGatewayFromConnectionString(\n\t\t\t\t\tconfig.connectionString,\n\t\t\t\t);\n\t\t\t\ttable ??= fromString.table;\n\t\t\t\tsink ??= fromString.sink;\n\t\t\t}\n\n\t\t\tconst core = this.surface.core({\n\t\t\t\tenvParser,\n\t\t\t\tsink,\n\t\t\t\t...(this.options.modules ? { modules: this.options.modules } : {}),\n\t\t\t});\n\t\t\treturn {\n\t\t\t\tcore,\n\t\t\t\ttable,\n\t\t\t\tsink,\n\t\t\t\ttrusted: [...config.origins, ...ownOrigins(config.url)],\n\t\t\t};\n\t\t});\n\t\treturn this.ready;\n\t}\n\n\tasync handle(\n\t\tevent: ApiGatewayWebSocketEvent,\n\t): Promise<ApiGatewayWebSocketResult> {\n\t\tconst { connectionId, eventType } = event.requestContext;\n\t\tconst { core, table, sink, trusted } = await this.setup();\n\n\t\tif (eventType === 'CONNECT') {\n\t\t\tconst headers = headersOf(event);\n\t\t\tconst origin = headers.get('origin');\n\t\t\tif (origin && !trustsOrigin(origin, trusted)) {\n\t\t\t\treturn { statusCode: 403, body: 'Forbidden' };\n\t\t\t}\n\n\t\t\tconst outcome = await core.connect({\n\t\t\t\tconnectionId,\n\t\t\t\theaders,\n\t\t\t\tquery: queryOf(event),\n\t\t\t});\n\t\t\tif (!outcome.accepted) {\n\t\t\t\treturn { statusCode: outcome.status, body: outcome.statusText };\n\t\t\t}\n\t\t\tawait table.put(outcome.connection);\n\t\t\treturn { statusCode: 200 };\n\t\t}\n\n\t\t// A connection the table no longer has — a row that expired early, or\n\t\t// one written by a `$connect` that failed after accepting — is still\n\t\t// served, with nothing its connect handler said about it.\n\t\tconst connection = (await table.get(connectionId)) ?? {\n\t\t\tid: connectionId,\n\t\t\tdata: {},\n\t\t};\n\n\t\tif (eventType === 'DISCONNECT') {\n\t\t\tawait core.disconnect(connection, {\n\t\t\t\tcode: event.requestContext.disconnectStatusCode ?? 1005,\n\t\t\t\treason: event.requestContext.disconnectReason ?? '',\n\t\t\t});\n\t\t\tawait table.delete([connectionId]);\n\t\t\treturn { statusCode: 200 };\n\t\t}\n\n\t\t// What the route writes back — its reply, `reply()`, an `$error` — is\n\t\t// posted to the caller, and waited for before the Lambda returns: a\n\t\t// frozen container sends nothing.\n\t\tconst writes: Promise<void>[] = [];\n\t\tconst write = (payload: string) => {\n\t\t\twrites.push(\n\t\t\t\tsink.send([connectionId], payload).catch((error) => {\n\t\t\t\t\tthis.logger.error(\n\t\t\t\t\t\t{ err: error, connectionId },\n\t\t\t\t\t\t'WebSocket reply could not be posted',\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\t\tconst raw = event.isBase64Encoded\n\t\t\t? Uint8Array.from(Buffer.from(event.body ?? '', 'base64'))\n\t\t\t: (event.body ?? '');\n\t\tawait core.message(connection, raw, write);\n\t\tawait Promise.all(writes);\n\t\treturn { statusCode: 200 };\n\t}\n}\n\n/** A Lambda of the surface was started without its publisher string. */\nexport class WebSocketPublisherNotConfigured extends Error {\n\tconstructor(\n\t\treadonly surface: string,\n\t\treadonly key: string,\n\t) {\n\t\tsuper(\n\t\t\t`${surface}'s Lambda has no ${key}, so it cannot reach its connections. Link the route to its surface — gkm build and @geekmidas/cloud's fromManifest do — or pass a table and a sink to AmazonApiGatewayWebSocket.`,\n\t\t);\n\t\tthis.name = 'WebSocketPublisherNotConfigured';\n\t}\n}\n\nfunction headersOf(event: ApiGatewayWebSocketEvent): Headers {\n\tconst headers = new Headers();\n\tif (event.multiValueHeaders) {\n\t\tfor (const [name, values] of Object.entries(event.multiValueHeaders)) {\n\t\t\tfor (const value of values ?? []) headers.append(name, value);\n\t\t}\n\t\treturn headers;\n\t}\n\tfor (const [name, value] of Object.entries(event.headers ?? {})) {\n\t\tif (value !== undefined) headers.append(name, value);\n\t}\n\treturn headers;\n}\n\nfunction queryOf(event: ApiGatewayWebSocketEvent): URLSearchParams {\n\tconst query = new URLSearchParams();\n\tif (event.multiValueQueryStringParameters) {\n\t\tfor (const [name, values] of Object.entries(\n\t\t\tevent.multiValueQueryStringParameters,\n\t\t)) {\n\t\t\tfor (const value of values ?? []) query.append(name, value);\n\t\t}\n\t\treturn query;\n\t}\n\tfor (const [name, value] of Object.entries(\n\t\tevent.queryStringParameters ?? {},\n\t)) {\n\t\tif (value !== undefined) query.append(name, value);\n\t}\n\treturn query;\n}\n\n/** A management API answer for a connection that has gone. */\nfunction isGone(error: unknown): boolean {\n\tconst e = error as {\n\t\tname?: string;\n\t\t$metadata?: { httpStatusCode?: number };\n\t} | null;\n\treturn e?.name === 'GoneException' || e?.$metadata?.httpStatusCode === 410;\n}\n\nfunction nowSeconds(): number {\n\treturn Math.floor(Date.now() / 1000);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA,MAAa,yBAAyB;;;;;;;AAqBtC,IAAa,wBAAb,MAAa,sBAAiD;CAsBnD;CAEQ;CAvBlB;;CAGA,OAAO,OACN,OACA,SAOwB;EACxB,MAAM,SAAS,IAAI,eAAe;GACjC,QAAQ,QAAQ;GAChB,GAAI,QAAQ,WAAW,EAAE,UAAU,QAAQ,SAAS,IAAI,CAAC;EAC1D,CAAC;EACD,OAAO,IAAI,sBAAsB,OAAO,QAAQ,EAAE,KAAK,QAAQ,IAAI,CAAC;CACrE;CAEA,YACC,OACA,QACA,UAGI,CAAC,GACJ;EANQ,KAAA,QAAA;EAEQ,KAAA,UAAA;EAKjB,KAAK,cAAc,iBAAiB,OAAO,MAAM;CAClD;CAEA,MAAM,IAAI,YAAuC;EAChD,MAAM,MAAM,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O;CACR;CACA,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAClC,MAAM,yBAAyB,CAAC,CACjC,GACC,IAAI,UAAU,KAAA,GAAW,MAAM,OAAO,MAAM,KAAK;CAElD,OAAO;AACR;;AAGA,SAAS,OAAO,OAAyB;CACxC,MAAM,IAAI;CAIV,OAAO,GAAG,SAAS,mBAAmB,GAAG,WAAW,mBAAmB;AACxE;AAEA,SAAS,aAAqB;CAC7B,OAAO,KAAK,MAAM,KAAK,IAAI,IAAI,GAAI;AACpC"}
@@ -1,3 +1,3 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_HonoEndpointAdaptor = require("../HonoEndpointAdaptor-BGEW1Tu8.cjs");
2
+ const require_HonoEndpointAdaptor = require("../HonoEndpointAdaptor-CZ1TooUu.cjs");
3
3
  exports.HonoEndpoint = require_HonoEndpointAdaptor.HonoEndpoint;
@@ -1,2 +1,2 @@
1
- import { t as HonoEndpoint } from "../HonoEndpointAdaptor-BC7CZ7Cr.mjs";
1
+ import { t as HonoEndpoint } from "../HonoEndpointAdaptor-2xHA3bvn.mjs";
2
2
  export { HonoEndpoint };
@@ -1,17 +1,17 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_rolldown_runtime = require("../rolldown-runtime-Ctb5zv51.cjs");
2
+ const require_rolldown_runtime = require("../rolldown-runtime-y5ARvAq5.cjs");
3
3
  const require_construct_interface = require("../construct-interface.cjs");
4
4
  const require_optionalPeers = require("../optionalPeers-DuNQXXe1.cjs");
5
5
  const require_auth = require("../auth.cjs");
6
- const require_functions = require("../functions-BqAq_0xQ.cjs");
7
- const require_Endpoint = require("../Endpoint-D2ckHqIx.cjs");
8
- const require_websocket_api = require("../websocket-api-CAQA_QOE.cjs");
9
- const require_Queue = require("../Queue-DZpV13LN.cjs");
6
+ const require_functions = require("../functions-DLF6-IK8.cjs");
7
+ const require_Endpoint = require("../Endpoint-52z1P0Ue.cjs");
8
+ const require_websocket_api = require("../websocket-api-czxhekGG.cjs");
9
+ const require_Queue = require("../Queue-D4Iaidrs.cjs");
10
10
  const require_email = require("../email.cjs");
11
- const require_Topic = require("../Topic-t5GhqaeT.cjs");
12
- const require_kysely = require("../kysely-CeoQdAkg.cjs");
11
+ const require_Topic = require("../Topic-Dp9Q7Lj2.cjs");
12
+ const require_kysely = require("../kysely-CukArHJ0.cjs");
13
13
  const require_readRequestBody = require("../readRequestBody-CN9GVdeE.cjs");
14
- const require_HonoEndpointAdaptor = require("../HonoEndpointAdaptor-BGEW1Tu8.cjs");
14
+ const require_HonoEndpointAdaptor = require("../HonoEndpointAdaptor-CZ1TooUu.cjs");
15
15
  const require_requestLogger = require("../requestLogger-CnoYd-Ah.cjs");
16
16
  let _geekmidas_manifest = require("@geekmidas/manifest");
17
17
  let node_crypto = require("node:crypto");
@@ -5,7 +5,7 @@ import { t as HttpMethod } from "../types-DMuSQeLL.cjs";
5
5
  import { c as EndpointSchemas, i as Endpoint } from "../Endpoint-YYwjqtS1.cjs";
6
6
  import { t as Queue } from "../Queue-C4rijiM7.cjs";
7
7
  import { t as Subscriber } from "../Subscriber-5rCX1Nph.cjs";
8
- import { G as RecordedClose, P as Connection, U as InvalidWebSocketRequest, W as RecordedBroadcast, et as TestWebSocketPublisher, ft as WebSocketMessages, n as WebSocketApi, pt as WebSocketPublisher, q as RecordedSend, ut as NoMessages } from "../websocket-api-C3dWKNxO.cjs";
8
+ import { J as RecordedClose, K as InvalidWebSocketRequest, L as Connection, X as RecordedSend, gt as WebSocketPublisher, ht as WebSocketMessages, n as WebSocketApi, pt as NoMessages, q as RecordedBroadcast, rt as TestWebSocketPublisher } from "../websocket-api-DkF8Hva-.cjs";
9
9
  import { t as KyselyDatabase } from "../kysely-CebjCWTl.cjs";
10
10
  import { t as Fake } from "../fake-DqieDYYA.cjs";
11
11
  import { o as TestStage } from "../stages-DaTaoQei.cjs";
@@ -5,7 +5,7 @@ import { t as HttpMethod } from "../types-DMuSQeLL.mjs";
5
5
  import { c as EndpointSchemas, i as Endpoint } from "../Endpoint-BUoDD96P.mjs";
6
6
  import { t as Queue } from "../Queue-B8HGg439.mjs";
7
7
  import { t as Subscriber } from "../Subscriber-CtQXhcL7.mjs";
8
- import { G as RecordedClose, P as Connection, U as InvalidWebSocketRequest, W as RecordedBroadcast, et as TestWebSocketPublisher, ft as WebSocketMessages, n as WebSocketApi, pt as WebSocketPublisher, q as RecordedSend, ut as NoMessages } from "../websocket-api-CDAxOTQZ.mjs";
8
+ import { J as RecordedClose, K as InvalidWebSocketRequest, L as Connection, X as RecordedSend, gt as WebSocketPublisher, ht as WebSocketMessages, n as WebSocketApi, pt as NoMessages, q as RecordedBroadcast, rt as TestWebSocketPublisher } from "../websocket-api-CPEzJyDt.mjs";
9
9
  import { t as KyselyDatabase } from "../kysely-De5rAC-E.mjs";
10
10
  import { t as Fake } from "../fake-BqhP8RRQ.mjs";
11
11
  import { o as TestStage } from "../stages-DaTaoQei.mjs";
@@ -1,15 +1,15 @@
1
1
  import { isConsumable } from "../construct-interface.mjs";
2
2
  import { n as loadAudit, t as OptionalPeerMissing } from "../optionalPeers-D7Wt6dnF.mjs";
3
3
  import { BetterAuth } from "../auth.mjs";
4
- import { a as publishEvents, i as publishConstructEvents, t as FunctionBuilder } from "../functions-BF039DT8.mjs";
5
- import { r as ResponseBuilder, t as Endpoint } from "../Endpoint-BuKHHVZc.mjs";
6
- import { a as MemoryTransport, f as InvalidWebSocketRequest, m as TestWebSocketPublisher, n as WebSocketApi, s as TransportSink } from "../websocket-api-BvKS9x-l.mjs";
7
- import { t as Queue } from "../Queue-0FpvxdOa.mjs";
4
+ import { a as publishEvents, i as publishConstructEvents, t as FunctionBuilder } from "../functions-BvIDQKAA.mjs";
5
+ import { r as ResponseBuilder, t as Endpoint } from "../Endpoint-sUOU7uLx.mjs";
6
+ import { a as MemoryTransport, f as InvalidWebSocketRequest, m as TestWebSocketPublisher, n as WebSocketApi, s as TransportSink } from "../websocket-api-Bg9SowJ5.mjs";
7
+ import { t as Queue } from "../Queue-u8w8_HpE.mjs";
8
8
  import { Email } from "../email.mjs";
9
- import { t as Topic } from "../Topic-DoEdDgh7.mjs";
9
+ import { t as Topic } from "../Topic-DN2gYJ-p.mjs";
10
10
  import { t as KyselyDatabase } from "../kysely-Cs4uPO8k.mjs";
11
11
  import { f as createObjectHeaders, s as createCookieHeaderAccessor } from "../readRequestBody-BmKnPl0a.mjs";
12
- import { t as HonoEndpoint } from "../HonoEndpointAdaptor-BC7CZ7Cr.mjs";
12
+ import { t as HonoEndpoint } from "../HonoEndpointAdaptor-2xHA3bvn.mjs";
13
13
  import { i as executeWithAuditTransaction, n as enforceRateLimit, t as requestLogger } from "../requestLogger-D2JS7pPM.mjs";
14
14
  import { INBOX_EVENT, WILDCARD_SUBDOMAIN, inboxRecipient, provideKey } from "@geekmidas/manifest";
15
15
  import { randomUUID } from "node:crypto";
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_optionalPeers = require("../optionalPeers-DuNQXXe1.cjs");
3
- const require_functions = require("../functions-BqAq_0xQ.cjs");
4
- const require_CronBuilder = require("../CronBuilder-B4DYaEjl.cjs");
3
+ const require_functions = require("../functions-DLF6-IK8.cjs");
4
+ const require_CronBuilder = require("../CronBuilder-B_NSP-Y5.cjs");
5
5
  let _geekmidas_services = require("@geekmidas/services");
6
6
  let _opentelemetry_api = require("@opentelemetry/api");
7
7
  let cron_parser = require("cron-parser");
@@ -1,6 +1,6 @@
1
1
  import { n as loadAudit } from "../optionalPeers-D7Wt6dnF.mjs";
2
- import { a as publishEvents } from "../functions-BF039DT8.mjs";
3
- import { n as Cron, t as CronBuilder } from "../CronBuilder-CukJuL3b.mjs";
2
+ import { a as publishEvents } from "../functions-BvIDQKAA.mjs";
3
+ import { n as Cron, t as CronBuilder } from "../CronBuilder-BJ5LoadF.mjs";
4
4
  import { runWithRequestContext } from "@geekmidas/services";
5
5
  import { ROOT_CONTEXT, SpanKind, SpanStatusCode, context, trace } from "@opentelemetry/api";
6
6
  import { CronExpressionParser } from "cron-parser";
@@ -1,4 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_kysely = require("../kysely-CeoQdAkg.cjs");
2
+ const require_kysely = require("../kysely-CukArHJ0.cjs");
3
3
  exports.KyselyDatabase = require_kysely.KyselyDatabase;
4
4
  exports.closeDatabasePools = require_kysely.closeDatabasePools;