@mark1russell7/service 0.5.11 → 0.5.13

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"websocket.js","names":["knob","t"],"sources":["../src/websocket/connection.ts","../src/websocket/meets.ts","../src/websocket/client.ts","../src/websocket/machine.ts","../src/websocket/starting.ts"],"sourcesContent":["import type { ClientSocket, Factory } from \"../client/core.ts\";\n\n/**\n * These are the listeners of one connection. The connection holds each event until the client\n * listens. Thus an event that comes between the creation and the listen does not go away.\n */\nexport interface WsListeners {\n /** This event tells that the upgrade ended with 101, and the connection can send. */\n open(): void;\n /** This event gives one message of the server. A text message is UTF-8 in the buffer. */\n message(data: Buffer, binary: boolean): void;\n /** This event gives the payload of one pong frame. */\n pong(data: Buffer): void;\n /** This event tells that the connection closed, with the code and the reason of the close frame. Code 1006 tells that no close frame came. */\n close(code: number, reason: string): void;\n /** This event gives an error of the connection. A close follows it. */\n error(error: Error): void;\n}\n\n/**\n * A connection is the part of a `WebSocket` of ws 8 that the wrapper uses. A fake for tests has\n * each part too. Thus the package depends on no type of ws.\n */\nexport interface WsConnection {\n /** This method gives the listeners of the connection. The connection then gives each event that it holds. */\n listen(listeners: WsListeners): void;\n /** This method writes one message. The callback gets an error when the write fails. It throws while the connection is not open. */\n send(data: string | Buffer, callback: (error?: Error) => void): void;\n /** This method writes one ping frame with this payload. It throws while the connection is not open. */\n ping(data: Buffer): void;\n /** This method writes a close frame, and waits for the close frame of the server. It destroys nothing. */\n close(code: number, reason: string): void;\n /** This method destroys the socket at once. The cells measured 0.3 ms to 1 ms from the call to the close of the socket. */\n terminate(): void;\n /** This field holds the socket after the upgrade, or undefined before it. The join reads its addresses. */\n readonly socket: ClientSocket | undefined;\n /** This text is the subprotocol that the server chose, or \"\" when it chose none. */\n readonly protocol: string;\n}\n\n/**\n * These are the options that the wrapper gives `new WebSocket(url, protocols, options)` of ws. Each\n * time comes from the declaration. ws gives the options that it does not read to `net.connect`.\n */\nexport interface WsDriverOptions {\n /** This time bounds the TCP connect and the upgrade, in milliseconds. */\n readonly handshakeTimeout: number;\n /** ws answers each ping of the server with a pong. The heartbeat of the server then finds the client alive. */\n readonly autoPong: true;\n /** This time bounds the close handshake of ws, in milliseconds. The wrapper gives its own bound, `close_bound`. */\n readonly closeTimeout: number;\n /** ws sets no keepalive on its socket. The wrapper turns it on only when the declaration gives an idle time. */\n readonly keepAlive: boolean;\n /** This time is the idle time of TCP keepalive, in milliseconds. Node truncates it to whole seconds. */\n readonly keepAliveInitialDelay?: number | undefined;\n /** These headers go with the upgrade request, for example `authorization`. */\n readonly headers?: Readonly<Record<string, string>> | undefined;\n}\n\n/** These are the arguments of `new WebSocket(url, protocols, options)`. */\nexport interface WsConnectOptions {\n readonly url: string;\n readonly protocols: readonly string[];\n readonly options: WsDriverOptions;\n}\n\n/** A connection factory makes one connection from its options. The connection opens later, and tells it with the event `open`. */\nexport type WsFactory = Factory<WsConnectOptions, WsConnection>;\n\n/** This type is the part of a `WebSocket` of ws 8 that the adapter uses. */\ninterface WsDriver {\n on(event: string, listener: (...args: never[]) => void): unknown;\n send(data: string | Buffer, callback: (error?: Error | null) => void): void;\n ping(data: Buffer): void;\n close(code: number, reason: string): void;\n terminate(): void;\n readonly protocol: string;\n}\n\n/** This function gives a message of ws as one buffer. At the default `binaryType` of ws, a message is a buffer already. */\nconst asBuffer = (data: unknown): Buffer => {\n if (Buffer.isBuffer(data)) return data;\n if (Array.isArray(data)) return Buffer.concat(data as Buffer[]);\n return Buffer.from(data as ArrayBuffer);\n};\n\n/**\n * This function adapts a `WebSocket` of ws to a connection. It listens to `error` at once, because\n * in Node an error with no listener throws. It takes the socket from the event `upgrade`.\n */\nexport const adaptWs = (ws: WsDriver): WsConnection => {\n let socket: ClientSocket | undefined;\n let listeners: WsListeners | null = null;\n const held: Array<(given: WsListeners) => void> = [];\n const deliver = (event: (given: WsListeners) => void): void => {\n if (listeners === null) held.push(event);\n else event(listeners);\n };\n ws.on(\"upgrade\", (response: { readonly socket?: ClientSocket }) => {\n socket = response.socket;\n });\n ws.on(\"open\", () => deliver((given) => given.open()));\n ws.on(\"message\", (data: unknown, binary: boolean) => deliver((given) => given.message(asBuffer(data), binary)));\n ws.on(\"pong\", (data: Buffer) => deliver((given) => given.pong(data)));\n ws.on(\"close\", (code: number, reason: Buffer) => deliver((given) => given.close(code, reason.toString(\"utf8\"))));\n ws.on(\"error\", (error: Error) => deliver((given) => given.error(error)));\n return {\n listen(given) {\n listeners = given;\n for (const event of held.splice(0)) event(given);\n },\n send: (data, callback) => ws.send(data, (error) => callback(error ?? undefined)),\n ping: (data) => ws.ping(data),\n close: (code, reason) => ws.close(code, reason),\n terminate: () => ws.terminate(),\n get socket() {\n return socket;\n },\n get protocol() {\n return ws.protocol;\n },\n };\n};\n\n/**\n * This factory makes a `WebSocket` of ws. It loads ws only when a client connects, thus a service\n * that does not use WebSocket does not need it. The specifier is a value, thus the package needs no types of ws.\n */\nexport const nodeWs: WsFactory = async ({ url, protocols, options }) => {\n const specifier = \"ws\";\n type Constructor = new (url: string, protocols: string[], options: WsDriverOptions) => WsDriver;\n const loaded = (await import(specifier)) as { readonly WebSocket?: Constructor; readonly default?: Constructor };\n const WebSocket = loaded.WebSocket ?? loaded.default;\n if (WebSocket === undefined) throw new Error(\"ws gives no WebSocket class\");\n return adaptWs(new WebSocket(url, [...protocols], options));\n};\n","import type { Detector, Meeting, Situation } from \"../client/meets.ts\";\nimport { NEVER, WHAT, immediate, keepaliveAnswered, keepaliveReset, keepaliveSilent, kernelGiveUp } from \"../client/meets.ts\";\nimport { finiteMs } from \"../client/core.ts\";\nimport { heartbeatDetection } from \"../timing.ts\";\nimport type { WsKnobs } from \"./client.ts\";\n\n/**\n * This function gives the manifestations that a WebSocket client can meet, and the detectors of\n * each, from its knobs. The WS cells measured them on ws 8:\n * - At a heartbeat of 2 s, a timeout of 1 s and 1 miss, the drop came 0.999 s to 1.0035 s after the\n * ping that got no pong. The slowest of 495 runs took 1.003761 s.\n * - `terminate()` closes the socket 0.3 ms to 1 ms after the drop. The close of the global WebSocket\n * only writes a close frame, and its socket stayed ESTABLISHED.\n * - The kernel of a frozen server acknowledges each ping, thus only the heartbeat finds it.\n * - At `tcp_retries2 = 3`, the kernel gave up before a pong timeout of 10 s.\n * - Without a heartbeat, the client waited for the keepalive of undici: 70 s. ws sets no keepalive.\n */\nexport const wsMeetings = (name: string, knobs: WsKnobs, misses: number): Meeting[] => {\n const interval = finiteMs(knobs.heartbeat_interval);\n const detection = heartbeatDetection(knobs.heartbeat_interval, knobs.heartbeat_timeout, misses);\n const heartbeat = (situation: Situation): Detector => ({\n by: \"heartbeat_detection_time\",\n within: detection,\n situation,\n effect: `the heartbeat destroys the socket with terminate(), each call in flight fails as indeterminate, and ${name} connects again`,\n });\n const call: Detector = {\n by: \"request_timeout\",\n within: knobs.request_timeout,\n situation: \"in flight\",\n effect: \"the timer of the wrapper ends the call as indeterminate, and the connection stays\",\n };\n const giveUp = kernelGiveUp(knobs.retrans_giveup_time, \"each call in flight fails as indeterminate\");\n const silent = (manifestation: \"blackhole\" | \"freeze-host\"): Meeting => ({\n manifestation,\n what: WHAT[manifestation],\n detectors: [call, heartbeat(\"in flight\"), giveUp, heartbeat(\"idle\"), keepaliveSilent(knobs.keepalive_idle)],\n });\n return [\n {\n manifestation: \"rst\",\n what: WHAT.rst,\n detectors: [\n immediate(\"in flight\", \"ws closes with code 1006, the call fails as indeterminate, and the client connects again\"),\n {\n by: \"heartbeat_interval\",\n within: interval === undefined ? NEVER : knobs.heartbeat_interval,\n situation: \"idle\",\n effect: \"the next ping frame gets a reset, and the client connects again\",\n },\n keepaliveReset(knobs.keepalive_idle),\n ],\n },\n {\n manifestation: \"fin\",\n what: WHAT.fin,\n detectors: [\n immediate(\"in flight\", \"the FIN arrives, ws closes with code 1006, and the call fails as indeterminate\"),\n immediate(\"idle\", \"the FIN arrives, ws closes with code 1006, and the client connects again\"),\n ],\n },\n silent(\"blackhole\"),\n silent(\"freeze-host\"),\n {\n manifestation: \"freeze-process\",\n what: WHAT[\"freeze-process\"],\n detectors: [call, heartbeat(\"in flight\"), heartbeat(\"idle\"), keepaliveAnswered()],\n },\n {\n manifestation: \"app-stall\",\n what: \"the server holds its reply, for example in a slow handler, and its library still answers each ping\",\n detectors: [call, { ...heartbeat(\"idle\"), within: NEVER, effect: \"the library of the server still answers each ping with a pong\" }, keepaliveAnswered()],\n },\n ];\n};\n","import type { Extent, Quantity } from \"@mark1russell7/quantity\";\nimport { realClock } from \"../clock.ts\";\nimport type {\n Attempt,\n CheckOptions,\n Client,\n ClientJoin,\n ClientKnobs,\n ClientOptions,\n ClientSpec,\n ClientStep,\n DialFn,\n RetryKnobs,\n SendOptions,\n Sent,\n Settle,\n} from \"../client/core.ts\";\nimport {\n ageProblems,\n attachClient,\n clientBounds,\n clientProblems,\n clientRecorder,\n dialCheck,\n finiteMs,\n inFlight,\n localStateCheck,\n message,\n missesProblems,\n ms,\n notSent,\n operationTable,\n readyWait,\n retryBackoff,\n retryProblems,\n retrySchedule,\n roundTripCheck,\n sendWithReissue,\n socketEnds,\n stepChecks,\n timeProblems,\n trackWithTimer,\n wholeProblems,\n withinBound,\n wrapperTimerProblems,\n zeroProblems,\n} from \"../client/core.ts\";\nimport type { Judge } from \"../client/dial.ts\";\nimport { authority, helloDial, statusLineJudge } from \"../client/dial.ts\";\nimport type { Dependency } from \"../description.ts\";\nimport type { Heartbeat } from \"../heartbeat.ts\";\nimport { heartbeat } from \"../heartbeat.ts\";\nimport type { DependencyHandle } from \"../lifecycle.ts\";\nimport type { Operation } from \"../operation.ts\";\nimport { heartbeatDetection } from \"../timing.ts\";\nimport type { WsConnectOptions, WsConnection, WsFactory } from \"./connection.ts\";\nimport { nodeWs } from \"./connection.ts\";\nimport { wsMeetings } from \"./meets.ts\";\n\n/**\n * These are the knobs of the client, each a time, by the names of the ordering law. The runtime has\n * no defaults, thus each knob is necessary. A bound that nobody gives is \"infinite\", not zero. The\n * constant `WS_CLIENT_STARTING_KNOBS` gives a declaration from the WS cells. The knobs that each client has come from the core.\n */\nexport interface WsKnobs extends ClientKnobs, RetryKnobs {\n /** This time bounds the TCP connect and the upgrade (`handshakeTimeout` of ws). The wrapper also bounds the open with it. */\n readonly connect_bound: Quantity;\n /** This time bounds each call: a request until its reply, and a ping until its pong. The wrapper has this timer, because ws has none. */\n readonly request_timeout: Quantity;\n /** This time is the interval of the ping frames of the heartbeat, from the start of one to the start of the next. \"infinite\" sends no ping. */\n readonly heartbeat_interval: Extent;\n /** This time bounds each ping of the heartbeat. A ping with no pong in this time is a miss. */\n readonly heartbeat_timeout: Quantity;\n /** This time is the first delay before a new try to connect. The delay doubles after each try. */\n readonly retry_base: Quantity;\n /** This time is the most that one delay can be, before its jitter. */\n readonly retry_cap: Quantity;\n /** This time is the idle time of TCP keepalive (`keepAliveInitialDelay`), in whole seconds. \"infinite\" keeps keepalive off, as ws does. */\n readonly keepalive_idle: Extent;\n /** The client does not replace its connection at an age, thus this knob must be \"infinite\". */\n readonly max_connection_age: Extent;\n /** This time bounds the close at the shutdown: the calls in flight, then the close handshake. At the bound, `terminate()` destroys the socket. */\n readonly close_bound: Quantity;\n}\n\n/** A reply is the id of the request that a message answers, and the error of the server when the reply tells one. */\nexport interface WsReply {\n readonly id: string;\n readonly error?: string | undefined;\n}\n\n/**\n * The replies of a protocol tell which message of the server answers which request. WebSocket has no\n * reply of its own: each application protocol puts an id in its messages, for example JSON-RPC 2.0.\n */\nexport interface WsReplies {\n /** This function reads one message of the server. It gives its reply, or null for a message that answers no request. */\n reply(data: Buffer, binary: boolean): WsReply | null;\n}\n\n/** A WebSocket client spec is the declaration of one WebSocket client: where it connects, and its knobs. */\nexport interface WsClientSpec extends ClientSpec<WsKnobs> {\n /** This path is the path of the upgrade request. The default is \"/\". */\n readonly path?: string | undefined;\n /** These names are the subprotocols that the client offers (`Sec-WebSocket-Protocol`). */\n readonly protocols?: readonly string[] | undefined;\n /** These headers go with the upgrade request and with the dial, for example `authorization`. */\n readonly headers?: Readonly<Record<string, string>> | undefined;\n /** This count is the number of heartbeat misses in sequence that end the connection. The cells used 1. */\n readonly heartbeatMisses: number;\n /** These replies match a message of the server to its request. Without them, the client sends no request. */\n readonly replies?: WsReplies | undefined;\n /**\n * These operations are the calls of the service, by name, with their idempotency. A message does\n * not tell if the server removes its duplicates. Thus the client sends again only a call that this table names, and a ping.\n */\n readonly operations?: ClientSpec<WsKnobs>[\"operations\"];\n}\n\n/** These options make a client. Without them, it uses ws, the real clock, `Math.random`, and a dial with the upgrade request. */\nexport interface WsClientOptions extends ClientOptions<WsFactory> {\n readonly random?: (() => number) | undefined;\n /**\n * This function waits one turn of the event loop. The heartbeat waits it before it counts a miss,\n * thus a pong that is in the socket counts first. The default is `setImmediate`.\n */\n readonly turn?: (() => Promise<void>) | undefined;\n}\n\n/** A join is one generation of the client: one connection, when its upgrade ended with 101 (D1, D2). WebSocket gives no id of a connection. */\nexport interface WsJoin extends ClientJoin {\n /** This URL is the URL of the connection. */\n readonly url: string;\n /** This text is the subprotocol that the server chose, or \"\" when it chose none. */\n readonly protocol: string;\n}\n\n/** A request is one message to the server, with the id that its reply gives back. */\nexport interface WsRequest {\n readonly id: string;\n /** This data goes as one message. A string goes as a text message, and a buffer as a binary message. */\n readonly data: string | Buffer;\n}\n\n/** A response is the message of the server that answered a request. */\nexport interface WsResponse {\n readonly data: Buffer;\n readonly binary: boolean;\n}\n\n/** A message listener receives each message of the server that answers no request. */\nexport type WsMessageListener = (data: Buffer, binary: boolean) => void;\n\n/** A WebSocket client is a dependency of a service: its declaration, its handle, its checks and its calls. */\nexport interface WsClient extends Client<ClientStep, WsJoin> {\n /** This text is the state of the client, as `WS_CLIENT_MACHINE` names it. */\n readonly status: string;\n /**\n * This method sends a request, and waits for its reply. A reply is `ok`, or a certain error when it\n * tells one. The client sends again only an idempotent operation, one time at most, after an outcome that is not certain.\n */\n request(operation: string, call: WsRequest, options?: SendOptions): Promise<Sent<WsResponse>>;\n /** This method sends a ping frame, and waits for a pong. A pong is `ok`. A ping is idempotent, thus the client can send it again. */\n ping(options?: SendOptions): Promise<Sent<void>>;\n /** This method sends one message with no reply. It gives true when ws took the message, and false when the client is not ready. */\n send(data: string | Buffer): boolean;\n /** This method adds a listener of the messages that answer no request. It gives the function that removes it. */\n onMessage(listener: WsMessageListener): () => void;\n}\n\n/** These operations are in each table: a ping frame is idempotent (RFC 6455 §5.5.2). */\nexport const WS_OPERATIONS: Readonly<Record<string, Operation>> = { ping: { idempotent: true } };\n\n/** This function gives the problems of a spec: the knobs that the client cannot use. */\nexport const specProblems = (name: string, spec: WsClientSpec): string[] => {\n const { knobs } = spec;\n const problems = [\n ...timeProblems(name, knobs),\n // ws has no timer of a call. The open and the pings have a timer of the wrapper too\n ...wrapperTimerProblems(name, knobs, { connect_bound: \"an open\", request_timeout: \"a call\", heartbeat_timeout: \"a ping of the heartbeat\" }),\n ...zeroProblems(name, \"the client\", knobs, { open: [\"heartbeat_interval\", \"keepalive_idle\"] }),\n // Node truncates the keepalive delay to whole seconds\n ...wholeProblems(name, knobs, { seconds: [\"keepalive_idle\"] }),\n ...retryProblems(name, knobs),\n ...missesProblems(name, spec.heartbeatMisses, \"heartbeat\"),\n ...ageProblems(name, knobs, \"the client does not replace its connection at an age\"),\n ];\n // one ping at a time: the time of detection holds only when each tick sends a ping\n const interval = finiteMs(knobs.heartbeat_interval);\n const timeout = finiteMs(knobs.heartbeat_timeout);\n if (interval !== undefined && interval > 0 && timeout !== undefined && spec.heartbeatMisses > 1 && timeout >= interval)\n problems.push(`${name}'s heartbeat_timeout is not below its heartbeat_interval: with one ping at a time, a tick sends no ping while a ping waits`);\n if (spec.path !== undefined && !spec.path.startsWith(\"/\")) problems.push(`${name}'s path does not start with \"/\"`);\n if (spec.password !== undefined) problems.push(`${name} takes no password: give the credentials in headers, for example authorization`);\n return problems;\n};\n\n/** This function gives the URL of a spec. The client speaks ws:// only. */\nexport const wsUrl = (spec: WsClientSpec): string => `ws://${authority(spec.host, spec.port)}${spec.path ?? \"/\"}`;\n\n/** This function gives the arguments of `new WebSocket` from a spec. Each timer of ws comes from the declaration. */\nexport const wsOptions = (spec: WsClientSpec): WsConnectOptions => {\n const { knobs } = spec;\n const keepalive = finiteMs(knobs.keepalive_idle);\n return {\n url: wsUrl(spec),\n protocols: spec.protocols ?? [],\n options: {\n handshakeTimeout: ms(knobs.connect_bound),\n autoPong: true,\n closeTimeout: ms(knobs.close_bound),\n keepAlive: keepalive !== undefined,\n ...(keepalive === undefined ? {} : { keepAliveInitialDelay: keepalive }),\n ...(spec.headers === undefined ? {} : { headers: spec.headers }),\n },\n };\n};\n\n/** The key of the dial. RFC 6455 §1.3 gives it as its example. The dial does not read the accept of the server. */\nconst DIAL_KEY = \"dGhlIHNhbXBsZSBub25jZQ==\";\n\n/** This function gives the bytes of the dial: the upgrade request of RFC 6455 §4.1, with the subprotocols and the headers of the spec. */\nexport const upgradeRequest = (spec: Pick<WsClientSpec, \"host\" | \"port\" | \"path\" | \"protocols\" | \"headers\">): string => {\n const lines = [\n `GET ${spec.path ?? \"/\"} HTTP/1.1`,\n `Host: ${authority(spec.host, spec.port)}`,\n \"Upgrade: websocket\",\n \"Connection: Upgrade\",\n `Sec-WebSocket-Key: ${DIAL_KEY}`,\n \"Sec-WebSocket-Version: 13\",\n ...(spec.protocols === undefined || spec.protocols.length === 0 ? [] : [`Sec-WebSocket-Protocol: ${spec.protocols.join(\", \")}`]),\n ...Object.entries(spec.headers ?? {}).map(([header, value]) => `${header}: ${value}`),\n ];\n return `${lines.join(\"\\r\\n\")}\\r\\n\\r\\n`;\n};\n\n/** This judge reads the status line of the answer to the upgrade. Only 101 passes: a WebSocket server takes the upgrade. */\nexport const upgradeJudge: Judge = statusLineJudge((status, line) =>\n status === 101 ? null : new Error(`the server answered ${JSON.stringify(line)} to the upgrade, not 101`),\n);\n\n/** This function makes the dial of a spec: a new TCP connection, the upgrade request, and a wait for 101. The dial then destroys its socket. */\nexport const wsDial =\n (spec: Pick<WsClientSpec, \"path\" | \"protocols\" | \"headers\">): DialFn =>\n (host, port, signal) =>\n helloDial(upgradeRequest({ ...spec, host, port }), upgradeJudge)(host, port, signal);\n\n/** This function gives the payload of a ping: its sequence number as text. */\nconst payload = (sequence: number): Buffer => Buffer.from(String(sequence), \"latin1\");\n\n/**\n * This function makes a WebSocket client, a dependency of a service over ws 8.\n * - It has one connection as one generation. The end of the connection ends the generation. The\n * client then connects again by itself, after a backoff.\n * - Its calls are a request until its reply, and a ping until its pong. Each call has a timer of\n * the wrapper, because ws has none.\n * - Its heartbeat sends a ping frame each interval, one at a time. A ping with no pong in its timeout\n * is a miss. At the last miss, `terminate()` destroys the socket at once, and the client connects again.\n * - It tells the outcome of a call in three values, and it settles each call in flight at the end of its generation (C8, C10).\n * - It records the URL and the ends of the socket of each connection at its open (D1).\n *\n * These parts come from the core of the clients: the outcomes, the second try and the wait for a ready\n * client. The backoff and its schedule, the calls in flight, the bounded close and the checks come from\n * the core too. The heartbeat is the heartbeat of the package. This entry gives what ws does in its own way.\n */\nexport const wsClient = (name: string, spec: WsClientSpec, options: WsClientOptions = {}): WsClient => {\n const problems = specProblems(name, spec);\n if (problems.length > 0) throw new Error(problems.join(\"; \"));\n const { knobs } = spec;\n const clock = options.clock ?? realClock;\n const random = options.random ?? Math.random;\n const create = options.create ?? nodeWs;\n const dial = options.dial ?? wsDial(spec);\n const turn = options.turn ?? (() => new Promise<void>((resolve) => setImmediate(resolve)));\n const operations = operationTable(WS_OPERATIONS, spec.operations);\n const requestTimeout = ms(knobs.request_timeout);\n const url = wsUrl(spec);\n\n let status = \"none\";\n let connection: WsConnection | null = null;\n // the token of the open that is current, and the sequence of the ping frames\n let token = 0;\n let sequence = 0;\n let beat: Heartbeat | null = null;\n // this function ends the wait of the close for the close frame of the server\n let closed: (() => void) | null = null;\n const retries = retrySchedule(clock, retryBackoff(knobs), random);\n const joins: WsJoin[] = [];\n const flight = inFlight();\n const readied = readyWait(clock, () => status === \"ready\");\n const replies = new Map<string, Settle<WsResponse>>();\n const pings = new Map<number, Settle<void>>();\n const listeners = new Set<WsMessageListener>();\n\n const emit = clientRecorder(options.record, clock, name);\n const record = (on: string, to: string = status, detail?: string): void => {\n const from = status;\n status = to;\n emit(from, to, on, detail);\n };\n const closing = (): boolean => status === \"closing\" || status === \"end\";\n\n /** This function waits for the backoff of the next try, then opens a new generation. */\n const scheduleRetry = (): void =>\n retries.schedule(() => {\n if (closing()) return;\n record(\"retry.connect\", \"connecting\", `try ${retries.tries}, ${url}`);\n void open();\n });\n\n /** This function ends the generation that is open. It destroys the socket, because a close frame to a silent server gets no answer. */\n const lose = (on: string, detail: string): void => {\n const c = connection;\n if (c === null) return;\n connection = null;\n beat?.stop();\n beat = null;\n if (closing()) return;\n record(on, \"failing\", detail);\n flight.settleAll(`the generation ended with the call in flight (${detail})`);\n c.terminate();\n scheduleRetry();\n };\n\n /** This function gives a message of the server to the call that waits for it, or to the listeners. A late reply goes to nobody. */\n const receive = (data: Buffer, binary: boolean): void => {\n let matched: WsReply | null = null;\n try {\n matched = spec.replies?.reply(data, binary) ?? null;\n } catch {\n // a message that the replies cannot read answers no request\n }\n if (matched !== null) {\n replies.get(matched.id)?.(\n matched.error === undefined ? { outcome: \"ok\", value: { data, binary } } : { outcome: \"error\", error: matched.error, reply: true },\n );\n return;\n }\n for (const listener of [...listeners]) listener(data, binary);\n };\n\n /** This function counts a pong. Each pong answers the heartbeat. A pong for a ping answers each earlier ping too, as RFC 6455 §5.5.3 lets it. */\n const pong = (data: Buffer): void => {\n beat?.answer();\n const text = data.toString(\"latin1\");\n if (!/^\\d{1,15}$/.test(text)) return;\n const upTo = Number(text);\n for (const [at, settle] of [...pings]) if (at <= upTo) settle({ outcome: \"ok\", value: undefined });\n };\n\n /** This function starts the heartbeat of a generation: one ping at a time, while the client is ready. */\n const startBeat = (): Heartbeat =>\n heartbeat({\n interval: ms(knobs.heartbeat_interval),\n timeout: ms(knobs.heartbeat_timeout),\n misses: spec.heartbeatMisses,\n clock,\n turn,\n due: () => status === \"ready\",\n live: () => status === \"ready\",\n ping: () => {\n if (connection === null) throw new Error(`${name} has no connection`);\n connection.ping(payload((sequence += 1)));\n },\n onMiss: (misses) => record(\"heartbeat.miss\", status, `${misses} of ${spec.heartbeatMisses}`),\n onDead: () => lose(\"heartbeat.dead\", `no pong in heartbeat_timeout, ${spec.heartbeatMisses} times in sequence`),\n });\n\n const join = (c: WsConnection): void => {\n connection = c;\n retries.reset();\n const generation = joins.length + 1;\n joins.push({ generation, at: clock.now(), url, protocol: c.protocol, ...socketEnds(c.socket) });\n record(\"join\", \"ready\", `generation ${generation}, ${url}`);\n beat = startBeat();\n readied.wake();\n };\n\n /**\n * This function opens one generation in `connect_bound`. A failure goes to `failing`, and the\n * backoff starts. A connection that opens after its bound or after the close is destroyed at once.\n * The promise resolves when this try ends.\n */\n const open = (): Promise<void> => {\n const mine = (token += 1);\n let opened: WsConnection | null = null;\n let joined = false;\n let finish: () => void = () => {};\n const ended = new Promise<void>((resolve) => (finish = resolve));\n const stale = (): boolean => mine !== token || closing();\n const fail = (detail: string): void => {\n bound();\n finish();\n if (stale()) return;\n token += 1;\n opened?.terminate();\n record(\"connect.failed\", \"failing\", detail);\n scheduleRetry();\n };\n const bound = clock.after(ms(knobs.connect_bound), () => fail(\"no open connection in connect_bound\"));\n void (async () => {\n const c = await create(wsOptions(spec));\n opened = c;\n if (stale()) {\n c.terminate();\n return;\n }\n c.listen({\n open: () => {\n if (stale()) {\n c.terminate();\n return;\n }\n bound();\n joined = true;\n join(c);\n finish();\n },\n message: (data, binary) => {\n if (c === connection) receive(data, binary);\n },\n pong: (data) => {\n if (c === connection) pong(data);\n },\n close: (code, reason) => {\n if (c === connection) closed?.();\n if (joined) {\n if (c === connection) lose(\"connection.end\", `code ${code}${reason === \"\" ? \"\" : `, ${reason}`}`);\n } else if (!stale()) fail(`the connection closed before its open, with code ${code}`);\n },\n error: (error) => {\n if (joined) {\n if (c === connection) record(\"connection.error\", status, message(error));\n } else if (!stale()) fail(message(error));\n },\n });\n })().catch((error: unknown) => fail(message(error)));\n return ended;\n };\n\n /** This function gives the connection for a call, or the reason that the call does not leave the client. */\n const usable = (signal: AbortSignal | undefined): WsConnection | Attempt<never> => {\n if (status === \"none\") return notSent(`${name} has not connected`);\n if (status !== \"ready\" || connection === null) return notSent(`${name} is ${status}, not ready: the call did not leave the client`);\n if (signal?.aborted) return notSent(\"the caller aborted the call before it left the client\");\n return connection;\n };\n\n /** This function makes one try of a request: the write, then the reply, in `request_timeout`. */\n const requestAttempt = (call: WsRequest, signal: AbortSignal | undefined): Promise<Attempt<WsResponse>> => {\n const c = usable(signal);\n if (\"outcome\" in c) return Promise.resolve(c);\n if (spec.replies === undefined) return Promise.resolve(notSent(`${name} has no replies in its spec: no message can answer a request`));\n if (replies.has(call.id)) return Promise.resolve(notSent(`${name} has a request with the id ${call.id} in flight`));\n return trackWithTimer<WsResponse>(\n flight,\n clock,\n requestTimeout,\n signal,\n \"the caller abandoned the request after it was written\",\n \"no reply in request_timeout: the server can have applied the request\",\n (settle) => {\n replies.set(call.id, settle);\n try {\n c.send(call.data, (error) => {\n if (error !== undefined) settle({ outcome: \"indeterminate\", error: `the write failed: ${message(error)}` });\n });\n } catch (error) {\n settle(notSent(message(error)));\n }\n },\n () => {\n replies.delete(call.id);\n },\n );\n };\n\n /** This function makes one try of a ping: the ping frame, then a pong, in `request_timeout`. */\n const pingAttempt = (signal: AbortSignal | undefined): Promise<Attempt<void>> => {\n const c = usable(signal);\n if (\"outcome\" in c) return Promise.resolve(c);\n const at = (sequence += 1);\n return trackWithTimer<void>(\n flight,\n clock,\n requestTimeout,\n signal,\n \"the caller abandoned the ping after it was written\",\n \"no pong in request_timeout\",\n (settle) => {\n pings.set(at, settle);\n try {\n c.ping(payload(at));\n } catch (error) {\n settle(notSent(message(error)));\n }\n },\n () => {\n pings.delete(at);\n },\n );\n };\n\n const request = (operation: string, call: WsRequest, sendOptions: SendOptions = {}): Promise<Sent<WsResponse>> =>\n sendWithReissue({\n clock,\n bound: requestTimeout,\n operation: operations[operation],\n options: sendOptions,\n attempt: (signal) => requestAttempt(call, signal),\n // the client connects again by itself: the second try waits for a ready client, in the time that is left\n beforeAgain: (left, signal) => readied.wait(left, signal),\n onReissue: () => record(\"command.reissue\", status, operation),\n });\n\n const ping = (sendOptions: SendOptions = {}): Promise<Sent<void>> =>\n sendWithReissue({\n clock,\n bound: requestTimeout,\n operation: operations[\"ping\"],\n options: sendOptions,\n attempt: (signal) => pingAttempt(signal),\n beforeAgain: (left, signal) => readied.wait(left, signal),\n onReissue: () => record(\"command.reissue\", status, \"ping\"),\n });\n\n const send = (data: string | Buffer): boolean => {\n const c = usable(undefined);\n if (\"outcome\" in c) return false;\n try {\n c.send(data, () => {});\n return true;\n } catch {\n return false;\n }\n };\n\n const handle: DependencyHandle = {\n async connect(signal) {\n if (signal.aborted) throw new Error(`${name}: the service stopped before the connect`);\n record(\"status.connecting\", \"connecting\");\n // a server that is down does not stop the startup: the client connects again in the background,\n // and its checks keep readiness tripped until it is ready (readiness is earned)\n await open();\n },\n async close() {\n if (status === \"none\" || closing()) return;\n record(\"close.request\", \"closing\");\n retries.cancel();\n // an open in flight is stale now: its connection is destroyed when it opens\n token += 1;\n beat?.stop();\n beat = null;\n const c = connection;\n if (c !== null) {\n // the calls in flight end first, then the close handshake. A silent server answers neither: the bound destroys the socket\n const handshake = flight.idle().then(\n () =>\n new Promise<void>((resolve) => {\n closed = resolve;\n c.close(1000, \"the client closed\");\n }),\n );\n if (!(await withinBound(clock, ms(knobs.close_bound), handshake))) {\n record(\"close.bound\", \"closing\");\n record(\"close.destroy\", \"closing\");\n c.terminate();\n }\n closed = null;\n }\n connection = null;\n flight.settleAll(\"the client closed with the call in flight\");\n record(\"status.end\", \"end\");\n },\n };\n\n const interval = finiteMs(knobs.heartbeat_interval);\n const declaration: Omit<Dependency, \"name\"> = {\n system: spec.system,\n knobs: {\n connect_bound: knobs.connect_bound,\n request_timeout: knobs.request_timeout,\n heartbeat_interval: knobs.heartbeat_interval,\n heartbeat_timeout: knobs.heartbeat_timeout,\n // the last of the misses in sequence fails at its timeout: misses × interval + timeout\n heartbeat_detection_time: heartbeatDetection(knobs.heartbeat_interval, knobs.heartbeat_timeout, spec.heartbeatMisses),\n retry_base: knobs.retry_base,\n retry_cap: knobs.retry_cap,\n keepalive_idle: knobs.keepalive_idle,\n // a ping frame each interval refreshes an idle flow (O03). With no heartbeat, keepalive does\n idle_refresh_interval: interval === undefined ? knobs.keepalive_idle : knobs.heartbeat_interval,\n max_connection_age: knobs.max_connection_age,\n close_bound: knobs.close_bound,\n retrans_giveup_time: knobs.retrans_giveup_time,\n },\n operations,\n };\n\n const checks = (checkOptions: CheckOptions) =>\n stepChecks<ClientStep>(name, checkOptions, {\n // the state of the client, without a round trip\n \"local-state\": localStateCheck(() => status === \"ready\"),\n // a ping frame on the connection of the application, until its pong\n \"round-trip\": roundTripCheck((sendOptions) => ping(sendOptions)),\n // a new connection each time, with the upgrade request\n dial: dialCheck(dial, spec.host, spec.port),\n });\n\n return {\n name,\n declaration,\n handle,\n meets: wsMeetings(name, knobs, spec.heartbeatMisses),\n get status() {\n return status;\n },\n joins,\n request,\n ping,\n send,\n onMessage(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n checks,\n attach: (svc, checkOptions) => attachClient(svc, name, declaration, handle, checks(checkOptions)),\n problems: (description) => clientProblems(name, description, clientBounds(knobs)),\n };\n};\n","import type { Machine } from \"@mark1russell7/algebra\";\nimport { clientKnob as knob, closeTimer, transition as t } from \"../client/machine.ts\";\n\n/** The states where the client can close, and the states where a call can start its second try. */\nconst SERVING = [\"connecting\", \"ready\", \"failing\"] as const;\nconst LIVE = [...SERVING, \"closing\"] as const;\n\n/**\n * The WebSocket client of the service as a `mark1russell7.machine/1` document. It is one generation\n * at a time: one `WebSocket` of ws 8. The states:\n * - `ready`: the upgrade ended with 101, and the client sends each call. Its heartbeat sends a ping frame each interval.\n * - `failing`: no generation is open. The client connects again after its backoff.\n * - `closing`: the calls in flight, then the close handshake, in `close_bound`. At the bound, `terminate()`.\n *\n * The end of the connection and the last miss of the heartbeat end the generation. A test records\n * the transitions of the client and replays them against this document.\n */\nexport const WS_CLIENT_MACHINE: Machine = {\n format: \"mark1russell7.machine/1\",\n id: \"service.machine.websocket-client\",\n title: \"The WebSocket client of the service, over ws 8\",\n layer: \"driver\",\n version: \"0.1.0\",\n sources: [{ ref: \"packages/service/src/websocket (the client implements this document)\", rung: \"implemented\" }],\n states: {\n none: { initial: true, note: \"the client exists, and its first connection does not\" },\n connecting: { note: \"the TCP connect and the upgrade, in connect_bound\" },\n ready: { note: \"the connection is open. The heartbeat finds a silent server, and the timer of a call ends a call that waits\" },\n failing: { note: \"no generation is open. The client connects again after its backoff\" },\n closing: { note: \"the calls in flight, then the close handshake, in close_bound. At the bound, terminate() destroys the socket\" },\n end: { final: true, note: \"the service closed the client\" },\n },\n events: {\n \"status.connecting\": { kind: \"local\" },\n join: { kind: \"rx\", note: \"the upgrade ended with 101: a new generation (D1)\" },\n \"connect.failed\": { kind: \"local\", note: \"the connect or the upgrade failed, or did not end in connect_bound\" },\n \"retry.connect\": { kind: \"timer\", note: \"the backoff ended: a new try\" },\n \"connection.error\": { kind: \"rx\", note: \"an error event of the connection. Its close follows\" },\n \"connection.end\": { kind: \"rx\", note: \"the connection closed: a reset, a FIN, a close frame of the server, or the kernel\" },\n \"heartbeat.miss\": { kind: \"timer\", note: \"a ping frame got no pong in heartbeat_timeout\" },\n \"heartbeat.dead\": { kind: \"local\", note: \"the last miss in sequence: terminate() destroys the socket at once\" },\n \"command.reissue\": { kind: \"local\" },\n \"close.request\": { kind: \"local\" },\n \"close.bound\": { kind: \"timer\", note: \"the calls in flight or the close handshake did not end in close_bound\" },\n \"close.destroy\": { kind: \"local\", note: \"terminate() destroys a socket that a silent server does not close\" },\n \"status.end\": { kind: \"local\" },\n },\n knobs: {\n connect_bound: knob(\"handshakeTimeout\"),\n heartbeat_interval: knob(\"heartbeat.interval\"),\n heartbeat_timeout: knob(\"heartbeat.timeout\"),\n retry_base: knob(\"retry.base\"),\n retry_cap: knob(\"retry.cap\"),\n close_bound: knob(\"close.bound\"),\n },\n timers: {\n connect_timeout: {\n duration: { knob: \"connect_bound\", unit: \"s\" },\n arms: [\"enter:connecting\"],\n cancels: [\"join\", \"connect.failed\"],\n fires: \"connect.failed\",\n note: \"the bound of the wrapper on the open. ws bounds the connect and the upgrade with the same time\",\n },\n heartbeat: {\n duration: { expr: \"heartbeat_interval + heartbeat_timeout\", unit: \"s\" },\n arms: [\"join\", \"heartbeat.miss\"],\n cancels: [\"connection.end\", \"heartbeat.dead\", \"close.request\"],\n fires: \"heartbeat.miss\",\n note: \"one ping at a time: a ping frame each interval, and a miss at its timeout with no pong. Each pong starts it again\",\n },\n retry: {\n duration: { expr: \"min(retry_cap, retry_base * pow(2, fired)) + retry_base\", unit: \"s\" },\n arms: [\"connect.failed\", \"connection.end\", \"heartbeat.dead\"],\n cancels: [\"close.request\"],\n fires: \"retry.connect\",\n backoff: { resets: [\"join\"] },\n note: \"the most delay: the backoff doubles from retry_base to retry_cap, with a jitter up to retry_base\",\n },\n close: closeTimer(),\n },\n transitions: [\n t(\"connect\", \"none\", \"status.connecting\", \"connecting\"),\n t(\"join\", \"connecting\", \"join\", \"ready\"),\n t(\"connect-failed\", \"connecting\", \"connect.failed\", \"failing\", { timer: \"connect_timeout\" }),\n t(\"retry\", \"failing\", \"retry.connect\", \"connecting\", { timer: \"retry\" }),\n t(\"connection-end\", \"ready\", \"connection.end\", \"failing\"),\n t(\"heartbeat-miss\", \"ready\", \"heartbeat.miss\", \"ready\", { timer: \"heartbeat\" }),\n t(\"heartbeat-dead\", \"ready\", \"heartbeat.dead\", \"failing\"),\n t(\"connection-error-ready\", \"ready\", \"connection.error\", \"ready\"),\n t(\"connection-error-closing\", \"closing\", \"connection.error\", \"closing\"),\n ...LIVE.map((state) => t(`reissue-${state}`, state, \"command.reissue\", state)),\n t(\"close\", [...SERVING], \"close.request\", \"closing\"),\n t(\"close-bound\", \"closing\", \"close.bound\", \"closing\", { timer: \"close\" }),\n t(\"close-destroy\", \"closing\", \"close.destroy\", \"closing\"),\n t(\"end\", \"closing\", \"status.end\", \"end\"),\n ],\n};\n","import { STARTING_POLL } from \"../client/core.ts\";\nimport type { Poll } from \"../timing.ts\";\nimport type { WsKnobs } from \"./client.ts\";\n\n/**\n * This poll is the poll of the checks that `WS_CLIENT_STARTING_KNOBS` fits. It is `STARTING_POLL` of\n * the core: each 5 s with a jitter of 20 %, and a timeout of 4 s (B6, O12). The poll does not depend on the driver.\n */\nexport const WS_CLIENT_STARTING_POLL: Poll = STARTING_POLL;\n\n/** This count is the heartbeat misses to start from: 1, as in the WS cells. The drop came 0.999 s to 1.0035 s after the ping with no pong. */\nexport const WS_CLIENT_STARTING_MISSES = 1;\n\n/**\n * These knobs are a declaration to start from, from what the WS cells measured on ws 8. The runtime\n * has no defaults: a service gives these knobs, or its own. Each value holds the borders that the cells measured:\n * - `connect_bound` 5 s: the connect timeout of DP44. ws sets no handshake timeout by default.\n * - `request_timeout` 9.5 s: in the slowest poll of 10 s (O13).\n * - `heartbeat_interval` 4 s: in the WST cells, a ping each 4 s kept a flow through a router that\n * forgets it at 5 s. A ping each 6 s did not (O03).\n * - `heartbeat_timeout` 3 s: a stall of 1 s with a pong timeout of 3 s dropped nothing. The detection is 4 s + 3 s = 7 s.\n * - `retry_base` 0.5 s and `retry_cap` 4 s: the reconnect of the cells, from 500 ms, doubling to 4 s.\n * The client adds a jitter up to the base. Thus the most delay is 4.5 s, in the slowest poll of 10 s.\n * - `keepalive_idle` \"infinite\": ws sets no keepalive, and the heartbeat refreshes an idle flow.\n * - `max_connection_age` \"infinite\": the client does not replace its connection at an age.\n * - `close_bound` 2 s: a close frame to a silent server gets no answer. The `closeTimeout` of ws is 30 s.\n * - `retrans_giveup_time` 924.6 s: the give-up of Linux at `tcp_retries2 = 15`.\n */\nexport const WS_CLIENT_STARTING_KNOBS: WsKnobs = {\n connect_bound: { value: 5, unit: \"s\" },\n request_timeout: { value: 9.5, unit: \"s\" },\n heartbeat_interval: { value: 4, unit: \"s\" },\n heartbeat_timeout: { value: 3, unit: \"s\" },\n retry_base: { value: 0.5, unit: \"s\" },\n retry_cap: { value: 4, unit: \"s\" },\n keepalive_idle: { value: \"infinite\", unit: \"s\" },\n max_connection_age: { value: \"infinite\", unit: \"s\" },\n close_bound: { value: 2, unit: \"s\" },\n retrans_giveup_time: { value: 924.6, unit: \"s\" },\n};\n"],"mappings":";;;;;;AAgFA,MAAM,YAAY,SAA0B;CAC1C,IAAI,OAAO,SAAS,IAAI,GAAG,OAAO;CAClC,IAAI,MAAM,QAAQ,IAAI,GAAG,OAAO,OAAO,OAAO,IAAgB;CAC9D,OAAO,OAAO,KAAK,IAAmB;AACxC;;;;;AAMA,MAAa,WAAW,OAA+B;CACrD,IAAI;CACJ,IAAI,YAAgC;CACpC,MAAM,OAA4C,CAAC;CACnD,MAAM,WAAW,UAA8C;EAC7D,IAAI,cAAc,MAAM,KAAK,KAAK,KAAK;OAClC,MAAM,SAAS;CACtB;CACA,GAAG,GAAG,YAAY,aAAiD;EACjE,SAAS,SAAS;CACpB,CAAC;CACD,GAAG,GAAG,cAAc,SAAS,UAAU,MAAM,KAAK,CAAC,CAAC;CACpD,GAAG,GAAG,YAAY,MAAe,WAAoB,SAAS,UAAU,MAAM,QAAQ,SAAS,IAAI,GAAG,MAAM,CAAC,CAAC;CAC9G,GAAG,GAAG,SAAS,SAAiB,SAAS,UAAU,MAAM,KAAK,IAAI,CAAC,CAAC;CACpE,GAAG,GAAG,UAAU,MAAc,WAAmB,SAAS,UAAU,MAAM,MAAM,MAAM,OAAO,SAAS,MAAM,CAAC,CAAC,CAAC;CAC/G,GAAG,GAAG,UAAU,UAAiB,SAAS,UAAU,MAAM,MAAM,KAAK,CAAC,CAAC;CACvE,OAAO;EACL,OAAO,OAAO;GACZ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
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@mark1russell7/service",
4
- "version": "0.5.11",
4
+ "version": "0.5.13",
5
5
  "description": "A service declared as data before it starts, and its runtime: checks on jittered loops, a latch for each policy, probes from the cache, the startup in its sequence, and a staged, capped drain. The timer-ordering law checks the declaration. Its clock, heartbeat and backoff also work alone, in a browser too.",
6
6
  "keywords": [
7
7
  "service",
@@ -42,6 +42,30 @@
42
42
  "types": "./build/redis.d.ts",
43
43
  "default": "./build/redis.js"
44
44
  },
45
+ "./pg": {
46
+ "types": "./build/pg.d.ts",
47
+ "default": "./build/pg.js"
48
+ },
49
+ "./mongodb": {
50
+ "types": "./build/mongodb.d.ts",
51
+ "default": "./build/mongodb.js"
52
+ },
53
+ "./rabbitmq": {
54
+ "types": "./build/rabbitmq.d.ts",
55
+ "default": "./build/rabbitmq.js"
56
+ },
57
+ "./http-client": {
58
+ "types": "./build/http-client.d.ts",
59
+ "default": "./build/http-client.js"
60
+ },
61
+ "./websocket": {
62
+ "types": "./build/websocket.d.ts",
63
+ "default": "./build/websocket.js"
64
+ },
65
+ "./grpc": {
66
+ "types": "./build/grpc.d.ts",
67
+ "default": "./build/grpc.js"
68
+ },
45
69
  "./clock": {
46
70
  "types": "./build/clock.d.ts",
47
71
  "default": "./build/clock.js"
@@ -77,18 +101,39 @@
77
101
  "@mark1russell7/quantity": "^0.2.0"
78
102
  },
79
103
  "peerDependencies": {
104
+ "@grpc/grpc-js": "^1.14.6",
105
+ "amqplib": "^2.2.0",
80
106
  "ioredis": "^6.0.0",
107
+ "mongodb": "^7.7.0",
108
+ "pg": "^8.23.1",
109
+ "ws": "^8.22.0",
81
110
  "zod": "^4.1.0"
82
111
  },
83
112
  "peerDependenciesMeta": {
113
+ "@grpc/grpc-js": {
114
+ "optional": true
115
+ },
116
+ "amqplib": {
117
+ "optional": true
118
+ },
84
119
  "ioredis": {
85
120
  "optional": true
86
121
  },
122
+ "mongodb": {
123
+ "optional": true
124
+ },
125
+ "pg": {
126
+ "optional": true
127
+ },
128
+ "ws": {
129
+ "optional": true
130
+ },
87
131
  "zod": {
88
132
  "optional": true
89
133
  }
90
134
  },
91
135
  "devDependencies": {
136
+ "@grpc/grpc-js": "1.14.6",
92
137
  "@mark1russell7/cue": "github:mark1russell7/cue",
93
138
  "@mark1russell7/harness": "^0.12.4",
94
139
  "@types/node": "^26.6.4",