@supalive/core 1.15.0 → 1.16.0

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 (84) hide show
  1. package/dist/index-B4UxN1ZL.d.ts +2365 -0
  2. package/dist/index-B4UxN1ZL.d.ts.map +1 -0
  3. package/dist/index-B8JFAyw4.d.ts +2377 -0
  4. package/dist/index-B8JFAyw4.d.ts.map +1 -0
  5. package/dist/index-CfcrWLLm.d.ts +2377 -0
  6. package/dist/index-CfcrWLLm.d.ts.map +1 -0
  7. package/dist/index-ggi1DrSG.d.ts +2336 -0
  8. package/dist/index-ggi1DrSG.d.ts.map +1 -0
  9. package/dist/mysql-07ROfbBZ.d.ts +114 -0
  10. package/dist/mysql-07ROfbBZ.d.ts.map +1 -0
  11. package/dist/mysql-BTigT6mP.d.ts +114 -0
  12. package/dist/mysql-BTigT6mP.d.ts.map +1 -0
  13. package/dist/mysql-CXymz1Eu.d.ts +114 -0
  14. package/dist/mysql-CXymz1Eu.d.ts.map +1 -0
  15. package/dist/mysql-ClUK7S2j.js +623 -0
  16. package/dist/mysql-ClUK7S2j.js.map +1 -0
  17. package/dist/mysql-CtpWqOhO.d.ts +114 -0
  18. package/dist/mysql-CtpWqOhO.d.ts.map +1 -0
  19. package/dist/mysql-fTKZ1zaF.js +623 -0
  20. package/dist/mysql-fTKZ1zaF.js.map +1 -0
  21. package/dist/overlap-checker-1TwhkAwy.js +259 -0
  22. package/dist/overlap-checker-1TwhkAwy.js.map +1 -0
  23. package/dist/overlap-checker-CGlxWcyb.js +259 -0
  24. package/dist/overlap-checker-CGlxWcyb.js.map +1 -0
  25. package/dist/postgres-B5-5vgLJ.d.ts +118 -0
  26. package/dist/postgres-B5-5vgLJ.d.ts.map +1 -0
  27. package/dist/postgres-CN03Espg.js +868 -0
  28. package/dist/postgres-CN03Espg.js.map +1 -0
  29. package/dist/postgres-CRPJdZx2.js +868 -0
  30. package/dist/postgres-CRPJdZx2.js.map +1 -0
  31. package/dist/postgres-DCXnKaJr.d.ts +118 -0
  32. package/dist/postgres-DCXnKaJr.d.ts.map +1 -0
  33. package/dist/postgres-DgCYPf0j.d.ts +118 -0
  34. package/dist/postgres-DgCYPf0j.d.ts.map +1 -0
  35. package/dist/postgres-Dnshux6k.d.ts +118 -0
  36. package/dist/postgres-Dnshux6k.d.ts.map +1 -0
  37. package/dist/query-LJranz0c.js +795 -0
  38. package/dist/query-LJranz0c.js.map +1 -0
  39. package/dist/query-q1ZvKrZO.js +762 -0
  40. package/dist/query-q1ZvKrZO.js.map +1 -0
  41. package/dist/realtime_db-B0Tin87E.js +312 -0
  42. package/dist/realtime_db-B0Tin87E.js.map +1 -0
  43. package/dist/realtime_db-DVhhasJj.js +312 -0
  44. package/dist/realtime_db-DVhhasJj.js.map +1 -0
  45. package/dist/router-DP2ThAwh.js.map +1 -1
  46. package/dist/src/client/index.d.ts +2 -2
  47. package/dist/src/client/index.js +78 -16
  48. package/dist/src/client/index.js.map +1 -1
  49. package/dist/src/exports/mysql.d.ts +1 -1
  50. package/dist/src/exports/mysql.js +1 -1
  51. package/dist/src/exports/postgres.d.ts +1 -1
  52. package/dist/src/exports/postgres.js +1 -1
  53. package/dist/src/exports/procedure.d.ts +2 -2
  54. package/dist/src/exports/procedure.js +1 -1
  55. package/dist/src/exports/schema-sql.d.ts +1 -1
  56. package/dist/src/exports/server.d.ts +12 -6
  57. package/dist/src/exports/server.d.ts.map +1 -1
  58. package/dist/src/exports/server.js +792 -252
  59. package/dist/src/exports/server.js.map +1 -1
  60. package/dist/src/exports/sub-manager-worker-entry.js +1 -1
  61. package/dist/src/exports/types.d.ts +2 -2
  62. package/dist/src/exports/types.js +1 -1
  63. package/dist/sub-worker-dispatch-D7jfw6ys.js +826 -0
  64. package/dist/sub-worker-dispatch-D7jfw6ys.js.map +1 -0
  65. package/dist/sub-worker-dispatch-qiSs5Xkm.js +826 -0
  66. package/dist/sub-worker-dispatch-qiSs5Xkm.js.map +1 -0
  67. package/dist/types_client_rpc-CWZmlWmM.js +145 -0
  68. package/dist/types_client_rpc-CWZmlWmM.js.map +1 -0
  69. package/dist/types_client_rpc-D4td5W0Y.js +141 -0
  70. package/dist/types_client_rpc-D4td5W0Y.js.map +1 -0
  71. package/dist/types_server-BhC19R2a.js.map +1 -1
  72. package/dist/types_server-BmIgDd8d.d.ts +614 -0
  73. package/dist/types_server-BmIgDd8d.d.ts.map +1 -0
  74. package/dist/types_server-C6B9_b1R.d.ts +662 -0
  75. package/dist/types_server-C6B9_b1R.d.ts.map +1 -0
  76. package/dist/types_server-DRr5yKy1.d.ts +655 -0
  77. package/dist/types_server-DRr5yKy1.d.ts.map +1 -0
  78. package/dist/types_server-DmCbve3w.d.ts +684 -0
  79. package/dist/types_server-DmCbve3w.d.ts.map +1 -0
  80. package/dist/types_server-Gs_vSVaS.d.ts +655 -0
  81. package/dist/types_server-Gs_vSVaS.d.ts.map +1 -0
  82. package/dist/types_server-ILUmPFvk.d.ts +614 -0
  83. package/dist/types_server-ILUmPFvk.d.ts.map +1 -0
  84. package/package.json +2 -1
@@ -0,0 +1,662 @@
1
+ import { Ar as MutationResult, Kn as Database, Kt as SupaliveDb, Vt as JobScheduler, _t as HandlerObservability, ar as InvalidateWritesetResult, cr as RegisterSubscriptionResult, dr as UnregisterSubscriptionResult, fr as UnregisterSubscriptionsParams, gr as UpdateSubscriptionReadSetResult, lr as UnregisterSubscriptionParams, mr as UpdateSubscriptionReadSetParams, nr as AffectedSubscription, or as RegisterSubscriptionParams, ot as RegisteredProcedure, pr as UnregisterSubscriptionsResult, rr as InvalidateWritesetParams, tr as CacheLayer } from "./index-CfcrWLLm.js";
2
+ import { r as ObjectStorage } from "./object-storage-354KU6Mj.js";
3
+ import z from "zod";
4
+ import { Context, Span } from "@opentelemetry/api";
5
+ import { IncomingMessage } from "http";
6
+ import { WebSocket } from "ws";
7
+ import { Level, Logger } from "pino";
8
+ import { Redis } from "ioredis";
9
+
10
+ //#region src/observability.d.ts
11
+ /** Replace the process-wide root logger. Call once at startup, before creating
12
+ * the server, to route Supalive's request/lifecycle logs through your own pino
13
+ * instance. */
14
+ declare function configureRootLogger(logger: Logger): void;
15
+ /** The current root logger (defaults to the env-configured singleton). */
16
+ declare function getRootLogger(): Logger;
17
+ type OperationTransport = "ws" | "http" | "internal";
18
+ type OperationKind = "query" | "mutation" | "action" | "subscribe" | "unsubscribe" | "job" | "connection";
19
+ type OperationOutcome = "ok" | "error";
20
+ /**
21
+ * A single completed operation. Emitted once per WS call / subscribe / HTTP RPC
22
+ * request / job run, and handed to metrics, the log line, and the `onEvent`
23
+ * hook. High-cardinality fields (`reqId`, `userId`, `sessionId`) are logged/
24
+ * forwarded but NEVER used as metric attributes.
25
+ */
26
+ interface OperationEvent {
27
+ /** Coarse operation family, e.g. "rpc" | "subscribe" | "unsubscribe" | "job" | "connection". */
28
+ op: string;
29
+ transport: OperationTransport;
30
+ procedure?: string;
31
+ kind?: OperationKind;
32
+ outcome: OperationOutcome;
33
+ /** Wall-clock duration in milliseconds. */
34
+ durationMs: number;
35
+ /** Error code for a failed op (e.g. NOT_FOUND, EXECUTION_ERROR, RATE_LIMITED). */
36
+ code?: string;
37
+ userId?: string | null;
38
+ sessionId?: string;
39
+ /** Per-request correlation id (WS request id, or a generated HTTP id). */
40
+ reqId?: string;
41
+ /** The thrown error, when the failure was an unexpected exception (→ error level). */
42
+ error?: unknown;
43
+ /** Extra structured fields to include on the log line only. */
44
+ extra?: Record<string, unknown>;
45
+ /** The operation's OTel span, when one was started. `record()` finalizes and
46
+ * ends it (status + attributes + exception). */
47
+ span?: Span;
48
+ }
49
+ /** Whether to emit a log line per request. Metrics + `onEvent` fire regardless. */
50
+ type RequestLogMode = "all" | "errors" | "off";
51
+ interface ObservabilityOptions {
52
+ /** Base logger for request/lifecycle lines. Defaults to {@link getRootLogger}. */
53
+ logger?: Logger;
54
+ /** Level override applied to the derived request logger. */
55
+ level?: Level;
56
+ /** Per-request log policy. `"all"` logs successes at info + failures; `"errors"`
57
+ * logs only failures; `"off"` logs neither (metrics/onEvent still fire).
58
+ * Default `"all"`. */
59
+ requestLog?: RequestLogMode;
60
+ /** Callback fed every {@link OperationEvent}. Errors thrown by it are swallowed. */
61
+ onEvent?: (e: OperationEvent) => void;
62
+ /** OpenTelemetry meter name. Default `"@supalive/core"`. */
63
+ meterName?: string;
64
+ /** OpenTelemetry meter version. Defaults to the core package version. */
65
+ meterVersion?: string;
66
+ }
67
+ /**
68
+ * The bound observability surface for one server instance: an injectable logger,
69
+ * OTel metric instruments, and the `record()` seam every operation funnels
70
+ * through. Built once in the server constructor and shared with the HTTP RPC
71
+ * handler.
72
+ */
73
+ declare class Observability {
74
+ readonly logger: Logger;
75
+ private readonly requestLog;
76
+ private readonly onEvent?;
77
+ private readonly requestCounter;
78
+ private readonly durationHistogram;
79
+ private readonly activeConnections;
80
+ private readonly activeSubscriptions;
81
+ private readonly tracer;
82
+ constructor(opts?: ObservabilityOptions);
83
+ /** Record one completed operation: metrics + optional onEvent + one log line,
84
+ * and finalize the op's span (status/attributes/exception) when present. */
85
+ record(e: OperationEvent): void;
86
+ /**
87
+ * Start a SERVER span for an operation, as a child of `parent` (or the active
88
+ * context). No-op — returns a non-recording span — until a TracerProvider is
89
+ * registered by the app, so this costs nothing when tracing is disabled.
90
+ * Returns the span plus a context that has it active, for `context.with(...)`
91
+ * wrapping so nested handler work / `ctx.span` children attach correctly.
92
+ */
93
+ startSpan(name: string, opts?: {
94
+ transport?: OperationTransport;
95
+ procedure?: string;
96
+ kind?: OperationKind;
97
+ parent?: Context;
98
+ }): {
99
+ span: Span;
100
+ context: Context;
101
+ };
102
+ /**
103
+ * Continue a trace from an inbound carrier (HTTP headers, or a WS message's
104
+ * `trace` field). Returns a context to pass as `startSpan({ parent })`. When
105
+ * no propagator is registered / no trace context is present, returns the root
106
+ * context (a fresh trace).
107
+ */
108
+ extractContext(carrier: Record<string, string | string[] | undefined>): Context;
109
+ /** Set the span's final status/attributes from the event, then end it.
110
+ * Returns the (valid) trace id for log correlation, or undefined. */
111
+ private finalizeSpan;
112
+ /** A request-scoped child logger for `ctx.log`, bound with the given fields
113
+ * (reqId, procedure, and trace id when tracing is on). */
114
+ childLogger(fields: Record<string, unknown>): Logger;
115
+ /** The span's trace id, or undefined when tracing is off / the span is
116
+ * non-recording. For binding onto `ctx.log`. */
117
+ traceIdOf(span: Span | undefined): string | undefined;
118
+ connectionOpened(): void;
119
+ connectionClosed(): void;
120
+ subscriptionAdded(n?: number): void;
121
+ subscriptionRemoved(n?: number): void;
122
+ }
123
+ /** Start marker for an operation; pass to {@link elapsedMs} to get its duration. */
124
+ declare function startTimer(): number;
125
+ declare function elapsedMs(startedAt: number): number;
126
+ /** What triggered a query execution — a client request/subscribe, or a background
127
+ * reactive recompute (live-query invalidation / sub-manager recovery). */
128
+ type QueryTrigger = "request" | "subscribe" | "recompute" | "recovery";
129
+ /**
130
+ * Run a query handler inside a `query <procedureName>` span, nested under
131
+ * `parentContext` (the operation span) or the active context. The span is handed
132
+ * to `run` so it becomes the query handler's `ctx.span` and the parent of any DB
133
+ * spans. Cache HITs never call this (no execution), so a span appearing means a
134
+ * real recompute — including the otherwise-invisible background reactive path,
135
+ * where `parentContext` is omitted and the span is a root.
136
+ *
137
+ * No-op-cheap when tracing is off: the started span is non-recording, so we skip
138
+ * the `context.with` and just run.
139
+ */
140
+ declare function traceQueryExecution<T>(procedureName: string, trigger: QueryTrigger, parentContext: Context | undefined, run: (span: Span) => Promise<T>): Promise<T>;
141
+ //#endregion
142
+ //#region src/server/sub-manager-client.d.ts
143
+ /**
144
+ * Callback the app server registers to process invalidations that were
145
+ * deferred during a sub-manager outage. When the sub-manager reconnects and
146
+ * the buffered writeSets are flushed in one batched RPC, the resulting
147
+ * `affected[]` is handed to this callback — which is expected to do the
148
+ * same work as the normal per-mutation `reexecuteAffectedQuery` path.
149
+ */
150
+ type AffectedHandler = (affected: AffectedSubscription[]) => Promise<void>;
151
+ /**
152
+ * Callback the app server registers to drive recovery on sub-manager
153
+ * reconnect. Iterates `serverSubscriptions`, reads `sl:reg:<subId>` from
154
+ * Redis, and re-registers each known sub. Resolves when complete; only then
155
+ * does the client's buffer flush and gated calls release.
156
+ */
157
+ type RecoveryDriver = () => Promise<void>;
158
+ /**
159
+ * The transport-agnostic contract the app server uses to talk to the
160
+ * subscription manager. Implemented by:
161
+ *
162
+ * • {@link SubManagerClient} — the WebSocket RPC client, for a sub-manager
163
+ * running in its own process (`subManagerUrl`); and
164
+ * • the object returned by `SubscriptionManager.localLink()` — a direct
165
+ * in-process link when the manager is embedded in the app server (no
166
+ * socket, no port, no serialization).
167
+ *
168
+ * Injecting this into `SupaliveServerConfig.subManager` lets a deployment run
169
+ * combined (one process) now and split the sub-manager out later by switching
170
+ * back to `subManagerUrl`, with no other code changes.
171
+ */
172
+ interface SubManagerLink {
173
+ registerSubscription(params: RegisterSubscriptionParams): Promise<RegisterSubscriptionResult>;
174
+ registerSubscriptionBatch(params: RegisterSubscriptionParams[]): Promise<RegisterSubscriptionResult[]>;
175
+ updateSubscriptionReadSet(params: UpdateSubscriptionReadSetParams): Promise<UpdateSubscriptionReadSetResult>;
176
+ unregisterSubscription(params: UnregisterSubscriptionParams): Promise<UnregisterSubscriptionResult>;
177
+ unregisterSubscriptions(params: UnregisterSubscriptionsParams): Promise<UnregisterSubscriptionsResult>;
178
+ invalidateWriteset(params: InvalidateWritesetParams): Promise<InvalidateWritesetResult>;
179
+ /**
180
+ * Register recovery for the reconnect path. A no-op for the in-process link,
181
+ * which never disconnects.
182
+ */
183
+ setRecoveryDriver(driver: RecoveryDriver): void;
184
+ /**
185
+ * Register the post-recovery batched-invalidate handler. A no-op for the
186
+ * in-process link.
187
+ */
188
+ setAffectedHandler(handler: AffectedHandler): void;
189
+ }
190
+ interface SubManagerClientOptions {
191
+ url: string;
192
+ /**
193
+ * Maximum number of buffered WriteEntry records held during an outage.
194
+ * If exceeded, the buffer is dropped — the commit-log replay path during
195
+ * the next register call will catch up any missed invalidations, at the
196
+ * cost of a brief recompute spike. Default 50_000 entries.
197
+ */
198
+ invalidateBufferLimit?: number;
199
+ }
200
+ /**
201
+ * RPC client for the (single) sub-manager process.
202
+ *
203
+ * Design (Convex-inspired):
204
+ * • The sub-manager is in-memory and ephemeral. There is no version
205
+ * protocol, no client-side registration registry, no OUT_OF_SYNC
206
+ * replay logic. All recovery is driven from the app server using
207
+ * state it already has (`serverSubscriptions`) plus registration
208
+ * records persisted to Redis at `sl:reg:<subId>`.
209
+ *
210
+ * • Out-of-order `updateSubscriptionReadSet` calls are filtered server
211
+ * side using `lastSnapshotTs` (monotonic DB commit timestamp).
212
+ *
213
+ * • On rpc-websockets reconnect, the client:
214
+ * 1. Transitions to `busy` (any in-flight `invalidateWriteset`
215
+ * buffers its writeSet).
216
+ * 2. Invokes the app server's `recoveryDriver` to re-register all
217
+ * known subs.
218
+ * 3. Flushes the buffer as one batched `invalidateWriteset` RPC and
219
+ * hands the resulting `affected[]` to `affectedHandler`.
220
+ * 4. Transitions to `ready`.
221
+ *
222
+ * • During an extended outage, the buffer is bounded; if exceeded, it
223
+ * is dropped and we rely on the commit-log replay built into
224
+ * `SubscriptionWorker.register()` to catch each sub up on the next
225
+ * re-register.
226
+ */
227
+ declare class SubManagerClient implements SubManagerLink {
228
+ private client;
229
+ private state;
230
+ private hasConnectedOnce;
231
+ /** Resolves whenever state transitions to 'ready'. Replaced on each busy→ready cycle. */
232
+ private readyPromise;
233
+ private resolveReady;
234
+ /** Writeset entries accumulated while state === 'busy'. Flushed as one RPC after recovery. */
235
+ private bufferedWriteSets;
236
+ private readonly bufferLimit;
237
+ private bufferDroppedDuringOutage;
238
+ private recoveryDriver?;
239
+ private affectedHandler?;
240
+ constructor(urlOrOptions: string | SubManagerClientOptions);
241
+ /**
242
+ * Wire up the app-server-driven recovery. Must be called before any
243
+ * disconnect/reconnect cycle for buffered writeSets to be flushed and
244
+ * subscriptions re-registered.
245
+ */
246
+ setRecoveryDriver(driver: RecoveryDriver): void;
247
+ /**
248
+ * Wire up the handler invoked when batched invalidate results land
249
+ * after recovery. The handler is expected to drive
250
+ * `reexecuteAffectedQuery` for each entry.
251
+ */
252
+ setAffectedHandler(handler: AffectedHandler): void;
253
+ registerSubscription(params: RegisterSubscriptionParams): Promise<RegisterSubscriptionResult>;
254
+ registerSubscriptionBatch(params: RegisterSubscriptionParams[]): Promise<RegisterSubscriptionResult[]>;
255
+ updateSubscriptionReadSet(params: UpdateSubscriptionReadSetParams): Promise<UpdateSubscriptionReadSetResult>;
256
+ unregisterSubscription(params: UnregisterSubscriptionParams): Promise<UnregisterSubscriptionResult>;
257
+ unregisterSubscriptions(params: UnregisterSubscriptionsParams): Promise<UnregisterSubscriptionsResult>;
258
+ /**
259
+ * Sends the writeSet to the sub-manager for invalidation, OR buffers it
260
+ * if the client is currently disconnected / recovering. Returns
261
+ * `{ affected: [] }` while buffering — the actual `affected` from the
262
+ * buffered batch is delivered via the registered `affectedHandler`
263
+ * after recovery completes.
264
+ */
265
+ invalidateWriteset(params: InvalidateWritesetParams): Promise<InvalidateWritesetResult>;
266
+ /**
267
+ * Single point through which RPCs go. Throws on transport / server error.
268
+ * `registerSubscription`, `updateSubscriptionReadSet`, and
269
+ * `unregisterSubscription` are NOT gated on the ready state: during a
270
+ * disconnect they will fail at the socket layer, and during recovery
271
+ * (which itself uses these methods) gating would deadlock.
272
+ */
273
+ private call;
274
+ private appendToBuffer;
275
+ private flushBuffer;
276
+ private markBusy;
277
+ private markReady;
278
+ private handleClose;
279
+ private handleOpen;
280
+ private runRecovery;
281
+ /**
282
+ * Test/inspection helpers.
283
+ */
284
+ /** @internal */
285
+ isReady(): boolean;
286
+ /** @internal */
287
+ bufferSize(): number;
288
+ }
289
+ //#endregion
290
+ //#region src/config.d.ts
291
+ /** CORS policy for the HTTP RPC endpoint. */
292
+ interface RpcCorsConfig {
293
+ /**
294
+ * Allowed origins. `"*"` sends `Access-Control-Allow-Origin: *`; a list
295
+ * echoes back a request's `Origin` only when it matches (and sets `Vary`).
296
+ * Omit `cors` entirely to send no CORS headers (same-origin only).
297
+ */
298
+ origins: string[] | "*";
299
+ }
300
+ /** Rate-limit policy for the HTTP RPC endpoint (fixed window, per instance). */
301
+ interface RpcRateLimitConfig {
302
+ /** Window length in ms. Default 60000. */
303
+ windowMs?: number;
304
+ /** Max requests per window per key. Default 120. */
305
+ max?: number;
306
+ /**
307
+ * Derive the limiter key from the request. Default: client IP
308
+ * (`X-Forwarded-For` first hop, else socket address). Return a stable string.
309
+ */
310
+ keyBy?: (req: IncomingMessage) => string;
311
+ }
312
+ /**
313
+ * Enables a one-shot HTTP RPC transport for `query`/`mutation`/`action`
314
+ * (no subscriptions — those stay WebSocket-only). Lets clients that don't need
315
+ * live queries call procedures without holding a socket open. Omit to disable
316
+ * the endpoint entirely.
317
+ */
318
+ interface RpcConfig<TContext = unknown> {
319
+ /**
320
+ * The single endpoint path. Default `/_rpc`. Every procedure is called as
321
+ * `POST {path}` with `{ name, input }` in the body — the name is never in the
322
+ * URL. Keep this distinct from `jobPath`.
323
+ */
324
+ path?: string;
325
+ /**
326
+ * Map an HTTP request to the auth `data` handed to `verifyAuth` (the same
327
+ * callback the WebSocket path uses). Default: `Authorization: Bearer <token>`
328
+ * → `{ token }`. Return `undefined` for an anonymous request.
329
+ */
330
+ auth?: (req: IncomingMessage) => Record<string, unknown> | undefined;
331
+ /** CORS policy. Omit for same-origin only (no CORS headers). */
332
+ cors?: RpcCorsConfig;
333
+ /** Rate limiting. Omit for defaults (120/min per IP); set `false` to disable. */
334
+ rateLimit?: RpcRateLimitConfig | false;
335
+ }
336
+ interface UpstashConfig {
337
+ url: string;
338
+ token: string;
339
+ redisUrl: string;
340
+ }
341
+ /** Database configuration for PostgreSQL */
342
+ interface PostgresConfig {
343
+ type: "postgres";
344
+ connectionString: string;
345
+ /** Optional max connections for the Postgres connection pool. Defaults to 10.*/
346
+ maxConnections?: number;
347
+ /** Optional min connections for the Postgres connection pool. Defaults to 1.*/
348
+ minConnections?: number;
349
+ /** Optional idle timeout for Postgres connections in milliseconds. Defaults to 30000 (30 seconds). */
350
+ idleTimeoutMillis?: number;
351
+ /** Optional connection timeout for acquiring Postgres connections in milliseconds. Defaults to 7000 (7 seconds). */
352
+ connectionTimeoutMillis?: number;
353
+ }
354
+ /** Database configuration for MySQL */
355
+ interface MySQLConfig {
356
+ type: "mysql";
357
+ connectionString: string;
358
+ /** Optional max connections for the MySQL connection pool. Defaults to 20.*/
359
+ maxConnections?: number;
360
+ /** Optional min connections for the MySQL connection pool. Defaults to 1.*/
361
+ minConnections?: number;
362
+ /** Optional idle timeout for MySQL connections in milliseconds. Defaults to 30000 (30 seconds). */
363
+ idleTimeoutMillis?: number;
364
+ /** Optional connection timeout for acquiring MySQL connections in milliseconds. Defaults to 7000 (7 seconds). */
365
+ connectionTimeoutMillis?: number;
366
+ /** Optional flag to queue connection requests when pool is exhausted. Defaults to true (queue requests). */
367
+ queueLimit?: number;
368
+ }
369
+ type DatabaseConfig = PostgresConfig | MySQLConfig;
370
+ /**
371
+ * Configuration for the Supalive WebSocket server.
372
+ */
373
+ interface SupaliveServerConfig<TContext = Record<string, unknown>> {
374
+ /** Server port (default: 3000) */
375
+ port?: number;
376
+ /** Server host (default: "0.0.0.0") */
377
+ host?: string;
378
+ cacheLayer: CacheLayer;
379
+ redisSubClient: Redis;
380
+ /**
381
+ * Subscription Manager WebSocket URL for RPC communication.
382
+ * A single sub-manager process owns all subscription state for this
383
+ * deployment. Internally it spawns N logical workers (configured on the
384
+ * sub-manager side) and routes by hash(subId) to spread CPU across them.
385
+ *
386
+ * Provide EITHER this OR {@link subManager} (an in-process link). Exactly
387
+ * one is required.
388
+ */
389
+ subManagerUrl?: string;
390
+ /**
391
+ * In-process subscription-manager link, as an alternative to
392
+ * {@link subManagerUrl}. Use this to embed the sub-manager in the same
393
+ * process as the app server (obtain it from
394
+ * `new SubscriptionManager({ listen: false, inline: true, ... }).localLink()`).
395
+ * The server then talks to the manager via direct method calls — no socket,
396
+ * no port, no serialization. Split the sub-manager into its own process
397
+ * later by switching back to `subManagerUrl` with no other changes.
398
+ */
399
+ subManager?: SubManagerLink;
400
+ /** Database instance */
401
+ database: SupaliveDb;
402
+ /**
403
+ * Optional authentication callback.
404
+ * Called when client sends auth message.
405
+ * Return null to reject authentication.
406
+ */
407
+ verifyAuth?: (data: Record<string, unknown>, sessionId: string) => Promise<TContext | null>;
408
+ /**
409
+ * Server context name for procedure routing.
410
+ * Must match the router's contextName.
411
+ */
412
+ contextName?: string;
413
+ /**
414
+ * Session TTL in seconds (default: 3600 = 1 hour).
415
+ * Sessions are kept alive while connected and expire after disconnect.
416
+ */
417
+ sessionTtlSeconds?: number;
418
+ /**
419
+ * Observability: structured request logging, OpenTelemetry metrics, and an
420
+ * optional per-operation `onEvent` hook (the seam for app-owned metrics /
421
+ * distributed tracing). The OTel API is a no-op until the host app registers
422
+ * an SDK, so leaving this unset costs nothing. See {@link ObservabilityOptions}.
423
+ */
424
+ observability?: ObservabilityOptions;
425
+ /**
426
+ * Extract user ID from context for cache key generation.
427
+ * If not provided, caching is disabled (each sub recomputes independently).
428
+ */
429
+ getUserId?: (ctx: TContext | undefined) => string | null;
430
+ /**
431
+ * Cache TTL in seconds (default: 3600).
432
+ * How long query results are cached in Redis.
433
+ */
434
+ cacheTtlSeconds?: number;
435
+ /**
436
+ * Scheduler backing the job system. When provided, the server exposes an
437
+ * HTTP endpoint (`{jobPath}/<jobName>`) that the scheduler POSTs to, and
438
+ * syncs every registered recurring (cron) job at startup. Omit to disable
439
+ * jobs entirely. Use `DevScheduler` locally and `QStashScheduler` in prod.
440
+ */
441
+ scheduler: JobScheduler;
442
+ /**
443
+ * Builds the system server context handed to a job handler's `serverCtx`.
444
+ * Jobs run without a client, so this is where a deployment injects its
445
+ * "system"/service identity. Called per job invocation.
446
+ */
447
+ jobContext?: () => TContext | Promise<TContext>;
448
+ /**
449
+ * Absolute, externally-reachable base URL of this server (no trailing
450
+ * slash), e.g. `https://api.example.com` in prod or `http://127.0.0.1:3000`
451
+ * in dev. Used to build the job endpoint the scheduler calls.
452
+ */
453
+ publicUrl: string;
454
+ /**
455
+ * URL path prefix for the job webhook endpoint. Default `/_jobs`. The full
456
+ * endpoint for a job is `{publicUrl}{jobPath}/<jobName>`.
457
+ */
458
+ jobPath?: string;
459
+ /**
460
+ * Enable the one-shot HTTP RPC transport (query/mutation/action over a
461
+ * single `POST {rpc.path}` endpoint, with `{ name, input }` in the body).
462
+ * Uses the same `verifyAuth` as the WebSocket path. Omit to disable. See
463
+ * {@link RpcConfig}.
464
+ */
465
+ rpc?: RpcConfig<TContext>;
466
+ /**
467
+ * Object storage, exposed to every procedure as `ctx.storage`. When set,
468
+ * query/mutation/action/job handlers can presign uploads/downloads and
469
+ * resolve public URLs without reaching for a module-level singleton. Omit
470
+ * to leave `ctx.storage` undefined (handlers should treat uploads as
471
+ * unconfigured). Build one with `S3CompatibleStorage` from
472
+ * `@supalive/core/storage`.
473
+ */
474
+ storage: ObjectStorage;
475
+ /**
476
+ * Optional application-level Redis pub/sub for cross-instance app messages
477
+ * that are NOT part of the subscription/cache machinery — e.g. auth-token
478
+ * revocations, feature-flag flips, targeted cache busts.
479
+ *
480
+ * The server subscribes to `channels` on its EXISTING Redis subscribe
481
+ * connection (no extra connection) and hands each received message to
482
+ * `onMessage`. Publish from anywhere with
483
+ * `server.publishAppMessage(channel, message)`, which rides the shared
484
+ * command connection. Messages are opaque strings — the app owns encoding.
485
+ */
486
+ appPubSub?: AppPubSubConfig;
487
+ }
488
+ /**
489
+ * App-level pub/sub wiring (see {@link SupaliveServerConfig.appPubSub}). A thin,
490
+ * generic cross-instance message bus layered on the server's Redis connections.
491
+ */
492
+ interface AppPubSubConfig {
493
+ /** Channels this instance subscribes to. */
494
+ channels: string[];
495
+ /**
496
+ * Handler for a message received on one of `channels`. Errors are caught and
497
+ * logged by the server, so a throwing handler can't crash the subscriber.
498
+ */
499
+ onMessage: (channel: string, message: string) => void | Promise<void>;
500
+ }
501
+ interface SubscriptionManagerConfig {
502
+ /**
503
+ * Port for the rpc-websockets listener. Required unless {@link listen} is
504
+ * `false` (embedded/in-process mode, where no socket is opened).
505
+ */
506
+ port?: number;
507
+ /**
508
+ * Upstash/Redis connection for the worker's own cache layer. Required in
509
+ * the default (own-pool) mode; omit when reusing an existing {@link cache}
510
+ * via {@link inline}.
511
+ */
512
+ upstash?: {
513
+ url: string;
514
+ token: string;
515
+ redisUrl: string;
516
+ };
517
+ /**
518
+ * Database connection the worker builds its own pool from. Required in the
519
+ * default mode; omit when reusing an existing {@link db} via {@link inline}.
520
+ */
521
+ database?: DatabaseConfig;
522
+ cacheTTLSeconds: number;
523
+ /**
524
+ * Open the rpc-websockets listener (default `true`). Set to `false` to
525
+ * embed the manager in another process and drive it via
526
+ * {@link SubscriptionManager.localLink}.
527
+ */
528
+ listen?: boolean;
529
+ /**
530
+ * Run the subscription worker inline on the main event loop instead of a
531
+ * `worker_threads` Worker (default `false`). Eliminates the postMessage /
532
+ * structured-clone hop, at the cost of no cross-core parallelism — always a
533
+ * single worker. Intended for embedded (`listen: false`) deployments with
534
+ * light realtime load. Provide {@link db} + {@link cache} to reuse the host
535
+ * server's pool/cache rather than opening new ones.
536
+ */
537
+ inline?: boolean;
538
+ /** In-process `Database` to reuse in {@link inline} mode (borrowed; not closed on stop). */
539
+ db?: Database;
540
+ /** In-process `CacheLayer` to reuse in {@link inline} mode. */
541
+ cache?: CacheLayer;
542
+ /**
543
+ * Number of logical workers inside the sub-manager process.
544
+ *
545
+ * Subscriptions are routed by FNV-1a(subId) % workers so that all operations
546
+ * for a given subId always land on the same worker (preserving the existing
547
+ * `instances: Set<string>` dedup). Each worker owns an independent
548
+ * subscriptions Map; on invalidate, all workers scan their own slice in
549
+ * parallel (logically — JS still runs one at a time inside one event loop,
550
+ * but per-worker scans are smaller so total work is split N ways).
551
+ *
552
+ * Defaults to `SUPALIVE_SUB_MANAGER_WORKERS` env var if set, else 1.
553
+ */
554
+ workers?: number;
555
+ /**
556
+ * Connection pool size *per worker*. If omitted, falls back to
557
+ * `floor(database.maxConnections / workers)` (min 1) so the total pool
558
+ * size stays close to the legacy single-worker configuration.
559
+ */
560
+ maxConnectionsPerWorker?: number;
561
+ }
562
+ //#endregion
563
+ //#region src/server/types_server.d.ts
564
+ type InstanceId = string;
565
+ type SubId = string;
566
+ /** Local tracking of an active subscription (per-session) */
567
+ interface SubscriptionEntry {
568
+ subId: SubId;
569
+ cacheKey: string;
570
+ subscribedTimes: number;
571
+ }
572
+ /**
573
+ * A mutation that has been validated and parked on the per-session FIFO
574
+ * queue, waiting for the in-flight mutation on this socket to finish. Each
575
+ * `handleCall` for a mutation owns one of these and awaits its own
576
+ * resolve/reject so it can send the response.
577
+ */
578
+ interface PendingMutation<TContext = Record<string, unknown>> {
579
+ procedure: RegisteredProcedure<TContext>;
580
+ validatedInput: unknown;
581
+ resolve: (result: MutationResult<unknown>) => void;
582
+ reject: (err: unknown) => void;
583
+ /** Request-scoped `ctx.log`/`ctx.span`, carried from `handleCall` so the
584
+ * mutation handler (which runs later on the drain loop) still sees them. */
585
+ handlerObs?: HandlerObservability;
586
+ }
587
+ /** WebSocket session (runtime, with WebSocket) */
588
+ interface Session<TContext = Record<string, unknown>> {
589
+ id: string;
590
+ ws: WebSocket;
591
+ /** Auth context from verifyAuth callback */
592
+ serverCtx?: TContext;
593
+ subIds: Set<string>;
594
+ /**
595
+ * Per-socket FIFO mutation queue. at most one mutation
596
+ * drains at a time so a single client cannot saturate the OCC retry
597
+ * loop or fan out concurrent commits that race the same rows.
598
+ */
599
+ mutationQueue: PendingMutation<TContext>[];
600
+ mutationInFlight: boolean;
601
+ /** Per-socket count of currently executing actions. */
602
+ actionInFlight: number;
603
+ /**
604
+ * Wall-clock of the last inbound frame (text message, ws-ping, or ws-pong).
605
+ * Used by the per-session heartbeat to terminate sockets that have gone
606
+ * silent past `CLIENT_TIMEOUT_MS`.
607
+ */
608
+ lastReceivedAt: number;
609
+ /**
610
+ * Wall-clock of the last outbound frame. Gates the idle-only app-level
611
+ * ping so a busy session (frequent sub:updates etc.) doesn't emit a
612
+ * redundant `{type:"ping"}` on every heartbeat tick.
613
+ */
614
+ lastSentAt: number;
615
+ /**
616
+ * Per-session combined heartbeat. Single `setInterval` that handles
617
+ * both dead-TCP detection (ws-ping or terminate) and client-watchdog
618
+ * refresh (idle-only app-level ping) on each tick.
619
+ */
620
+ heartbeatTimer: ReturnType<typeof setInterval> | null;
621
+ }
622
+ declare const RemoteSubscriptionUpdateSchema: z.ZodObject<{
623
+ type: z.ZodLiteral<"update">;
624
+ subId: z.ZodString;
625
+ data: z.ZodUnknown;
626
+ dataHash: z.ZodString;
627
+ originInstance: z.ZodString;
628
+ ts: z.ZodOptional<z.ZodString>;
629
+ }, z.core.$strip>;
630
+ type RemoteSubscriptionUpdate = z.infer<typeof RemoteSubscriptionUpdateSchema>;
631
+ declare const RemoteRecomputeRaceSchema: z.ZodObject<{
632
+ type: z.ZodLiteral<"recompute-race">;
633
+ subId: z.ZodString;
634
+ cacheKey: z.ZodString;
635
+ queryName: z.ZodString;
636
+ args: z.ZodUnknown;
637
+ notifyInstances: z.ZodArray<z.ZodString>;
638
+ commitTs: z.ZodString;
639
+ originInstance: z.ZodString;
640
+ }, z.core.$strip>;
641
+ type RemoteRecomputeRace = z.infer<typeof RemoteRecomputeRaceSchema>;
642
+ declare const RemoteSubscriptionMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
643
+ type: z.ZodLiteral<"update">;
644
+ subId: z.ZodString;
645
+ data: z.ZodUnknown;
646
+ dataHash: z.ZodString;
647
+ originInstance: z.ZodString;
648
+ ts: z.ZodOptional<z.ZodString>;
649
+ }, z.core.$strip>, z.ZodObject<{
650
+ type: z.ZodLiteral<"recompute-race">;
651
+ subId: z.ZodString;
652
+ cacheKey: z.ZodString;
653
+ queryName: z.ZodString;
654
+ args: z.ZodUnknown;
655
+ notifyInstances: z.ZodArray<z.ZodString>;
656
+ commitTs: z.ZodString;
657
+ originInstance: z.ZodString;
658
+ }, z.core.$strip>], "type">;
659
+ type RemoteSubscriptionMessage = z.infer<typeof RemoteSubscriptionMessageSchema>;
660
+ //#endregion
661
+ export { QueryTrigger as A, SubManagerLink as C, OperationKind as D, OperationEvent as E, startTimer as F, traceQueryExecution as I, configureRootLogger as M, elapsedMs as N, OperationOutcome as O, getRootLogger as P, SubManagerClient as S, ObservabilityOptions as T, RpcCorsConfig as _, RemoteSubscriptionMessage as a, SupaliveServerConfig as b, RemoteSubscriptionUpdateSchema as c, SubscriptionEntry as d, AppPubSubConfig as f, RpcConfig as g, PostgresConfig as h, RemoteRecomputeRaceSchema as i, RequestLogMode as j, OperationTransport as k, Session as l, MySQLConfig as m, PendingMutation as n, RemoteSubscriptionMessageSchema as o, DatabaseConfig as p, RemoteRecomputeRace as r, RemoteSubscriptionUpdate as s, InstanceId as t, SubId as u, RpcRateLimitConfig as v, Observability as w, UpstashConfig as x, SubscriptionManagerConfig as y };
662
+ //# sourceMappingURL=types_server-C6B9_b1R.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types_server-C6B9_b1R.d.ts","names":[],"sources":["../src/observability.ts","../src/server/sub-manager-client.ts","../src/config.ts","../src/server/types_server.ts"],"mappings":";;;;;;;;;;;;;iBAqDgB,mBAAA,CAAoB,MAAc,EAAN,MAAM;;iBAKlC,aAAA,IAAiB,MAAM;AAAA,KAM3B,kBAAA;AAAA,KACA,aAAA;AAAA,KAQA,gBAAA;;;;AApBsC;AAKlD;;UAuBiB,cAAA;EAvBsB;EAyBrC,EAAA;EACA,SAAA,EAAW,kBAAA;EACX,SAAA;EACA,IAAA,GAAO,aAAA;EACP,OAAA,EAAS,gBAAA;EAvBmB;EAyB5B,UAAA;EAxBuB;EA0BvB,IAAA;EACA,MAAA;EACA,SAAA;EApBU;EAsBV,KAAA;;EAEA,KAAA;EAxB0B;EA0B1B,KAAA,GAAQ,MAAA;EAlBqB;;EAqB7B,IAAA,GAAO,IAAA;AAAA;;KAIG,cAAA;AAAA,UAEK,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