actions/transports.ts

Transport abstraction for action communication.

Provides the Transport interface and Transports registry for managing multiple transports with fallback behavior.

view source

Declarations
#

7 declarations

Transport
#

actions/transports.ts view source

Transport import type {Transport} from '@fuzdev/fuz_app/actions/transports.js';

transport_name

type TransportName

send

type (message: { [x: string]: unknown; jsonrpc: "2.0"; id: string | number; method: string; params?: { [x: string]: unknown; } | undefined; }, options?: TransportSendOptions | undefined): Promise<...>

message

type { [x: string]: unknown; jsonrpc: "2.0"; id: string | number; method: string; params?: { [x: string]: unknown; } | undefined; }

options?

type TransportSendOptions | undefined
optional
returns Promise<{ [x: string]: unknown; jsonrpc: "2.0"; id: string | number; result: JSONType; } | { [x: string]: unknown; jsonrpc: "2.0"; id: string | number | null; error: { [x: string]: unknown; code: -32700 | -32600 | -32601 | -32602 | -32603 | (number & $brand<...>); message: string; data?: unknown; }; }>

is_ready

type () => boolean

dispose?

type () => void

TransportName
#

Transports
#

actions/transports.ts view source

import {Transports} from '@fuzdev/fuz_app/actions/transports.js';

allow_fallback

Whether to allow fallback to other transports if the current one is not available.

type boolean

default true

register_transport

Registers a transport. The first transport registered also becomes the current.

type (transport: Transport): void

transport

returns void

set_current_transport

Switch the current transport selection by name.

type (transport_name: string): void

transport_name

type string
returns void

throws

  • Error - if no transport with `transport_name` has been registered

get_transport

Resolve a transport. With allow_fallback, walks specified → current → any-ready; without, returns the named transport (or current) only when it's ready.

type (transport_name?: string | undefined): Transport | null

transport_name?

type string | undefined
optional
returns Transport | null

the resolved transport, or null when none is ready

is_ready

type (): boolean | null

returns boolean | null

get_current_transport

type (): Transport | null

returns Transport | null

get_current_transport_name

type (): string | null

returns string | null

get_transport_by_name

type (transport_name: string): Transport | null

transport_name

type string
returns Transport | null

TransportSendOptions
#

actions/transports.ts view source

TransportSendOptions import type {TransportSendOptions} from '@fuzdev/fuz_app/actions/transports.js';

Per-call options accepted by every transport's send. Optional and extensible — adding a field is non-breaking. Source of truth for the shared option shape; ActionDispatcherSendOptions and RpcClientCallOptions extend it.

signal?

Per-call cancellation. Bottoms out at FrontendWebsocketClient.request({signal}) on the WS path (sends the shared cancel notification on abort) and at fetch({signal}) on HTTP. Backend transport has no per-call abort surface to honor.

type AbortSignal

queue?

Per-call durable-queue opt-in. Names the client-authoritative vs server-authoritative distinction — server-authoritative consumers (e.g. zzz completion calls) fail fast with service_unavailable when the transport is down; client-authoritative consumers (games, real-time apps) buffer and replay on reconnect because the user already committed to the action at click time. Honored only by FrontendWebsocketTransport on the request_response path (default false). HTTP and backend transports ignore it; WS notifications also ignore it and always fail-fast when disconnected (fire-and-forget connection.send has no queue semantic).

type boolean

WS_CLOSE_CLIENT_HEARTBEAT_TIMEOUT
#

actions/transports.ts view source

4002 import {WS_CLOSE_CLIENT_HEARTBEAT_TIMEOUT} from '@fuzdev/fuz_app/actions/transports.js';

WebSocket close code — client timed out waiting for a response.

WS_CLOSE_SERVER_HEARTBEAT_TIMEOUT
#

actions/transports.ts view source

4003 import {WS_CLOSE_SERVER_HEARTBEAT_TIMEOUT} from '@fuzdev/fuz_app/actions/transports.js';

WebSocket close code — server timed out with no incoming activity.

WS_CLOSE_SESSION_REVOKED
#

actions/transports.ts view source

4001 import {WS_CLOSE_SESSION_REVOKED} from '@fuzdev/fuz_app/actions/transports.js';

WebSocket close code for session revocation.

Depends on
#

Imported by
#