Thrown when the circuit breaker for the target origin is open.
Thrown by IHttpClient.request() when the server returns a non-2xx status.
Thrown by generateOpenApiClient() with path/method diagnostics when the
OpenAPI document is malformed or contains unsupported constructs.
Create a request interceptor that sets an API-key header.
Create a request interceptor that sets Authorization: Bearer <token>.
Create a configured HTTP client.
Factory returning the default IClientTiming backed by
performance.now() and setTimeout.
Creates and immediately connects a portable WebSocket realtime client.
Creates and starts a portable SSE client.
Generate TypeScript client source from an OpenAPI 3.1 document. Pure function with zero I/O and deterministic output.
Circuit breaker policy consumed by the ResiliencePlugin's breaker pattern.
-
resetTimeout: number
Cooldown in milliseconds before an open breaker moves to half-open.
-
threshold: number
Failures within the
timeoutwindow that trip the breaker open. -
timeout: number
Rolling failure window in milliseconds; failures older than this (measured by the monotonic clock) are dropped before the threshold check.
Options passed to createClient().
-
baseUrl: string
Required base URL for all requests.
-
circuitBreaker: CircuitBreakerPolicy
Circuit breaker policy.
threshold < 1throws at construction. -
fetch: () => Promise<Response>input: RequestInfo,init?: RequestInit
Injectable fetch seam. Defaults to global
fetch. -
headers: HeadersInit
Default headers cloned into each request.
-
rateLimit: ClientRateLimitPolicy
Rate-limit policy. Non-positive
maxRequestsorwindowMsthrows. -
requestInterceptors: ClientRequestInterceptor[]
Request interceptors executed once before resilient execution.
-
responseInterceptors: ClientResponseInterceptor<unknown>[]
Response interceptors executed after successful parsing.
-
retry: RetryPolicy
Retry policy.
limit < 1throws at construction. -
timing: IClientTiming
Timing abstraction. Defaults to
createDefaultClientTiming().
Per-origin sliding-window rate-limit configuration.
-
maxRequests: number
Maximum requests allowed within the window.
-
windowMs: number
Window size in milliseconds.
An outbound JSON request described by application or generated code.
-
headers: HeadersInit
Additional headers merged on top of the client defaults.
-
json: TBody
JSON body. When present,
Content-Type: application/jsonis set automatically. -
method: string
HTTP method.
-
path: string
Relative path resolved against the client
baseUrl. Must be relative. -
query: Record<>string,string
| number
| boolean
| (string | number | boolean)[]
| null
| undefinedQuery values. Primitives are encoded once; arrays repeat the key. Nullish values are omitted.
-
signal: AbortSignal
Abort signal that cancels fetches and queued waits.
Mutable context passed to a ClientRequestInterceptor so it can
inspect and modify the resolved URL and headers before the request executes.
-
headers: Headers
The mutable header map for the outbound request.
-
url: URL
The fully-resolved request URL.
A successful parsed response returned by IHttpClient.request.
-
data: T | undefined
Parsed JSON body.
undefinedfor 204 or empty responses. -
headers: Headers
Response headers.
-
status: number
HTTP status code (always 2xx).
Monotonic-time and sleep abstraction used by retry, breaker, and rate-limiter.
-
now(): number
Monotonic timestamp in milliseconds (like
performance.now()). -
sleep(): Promise<void>ms: number,signal?: AbortSignal
Sleep for approximately
msmilliseconds, abortable viasignal.
The public HTTP client contract returned by createClient().
-
request<TResponse, TBody = unknown>(request: ClientRequest<TBody>): Promise<ClientResponse<TResponse>>
Execute an outbound JSON request.
A running realtime WebSocket client.
-
close(): voidcode?: number,reason?: string
Stops future reconnect attempts and closes the active socket.
-
send(message: TOutgoing): void
Serializes non-string values as JSON and sends a text frame.
-
state: RealtimeClientState
Current lifecycle state.
A running SSE client returned by createSseClient.
-
close(): void
Stops the active stream and disables every future reconnect attempt.
-
state: SseClientState
Current lifecycle state.
Minimal structural WebSocket surface used by the client.
-
close(): voidcode?: number,reason?: string
Closes the connection.
-
onclose: ((event: CloseEvent) => void) | null
Close callback installed by the client.
-
onerror: ((event: Event) => void) | null
Error callback installed by the client.
-
onmessage: ((event: MessageEvent) => void) | null
Message callback installed by the client.
-
onopen: ((event: Event) => void) | null
Open callback installed by the client.
-
readyState: number
Browser-compatible ready-state number (
0connecting,1open). -
send(data: string): void
Sends one text frame.
Options for generateOpenApiClient.
-
apiTypeName: string
Name of the exported interface describing the generated client, and the factory's return type. Defaults to
'Api'. -
factoryName: string
Name of the exported factory function. Defaults to
'createApi'. -
sdkImport: string
Import specifier for SDK types. Defaults to
'@setu-ts/sdk'.
The source frame given to a custom SSE payload parser.
-
data: string
Joined raw
data:lines. -
event: string
Server-provided event name, or
'message'when omitted. -
id: string
Server event ID, when supplied.
Configuration for createRealtimeClient.
-
heartbeatPayload: string
Application heartbeat text to suppress and send back. Defaults to
'ping'. -
onError: (error: unknown) => void
Receives socket or payload parse errors.
-
onMessage: (message: RealtimeMessage<TIncoming>) => void
Receives parsed application messages in arrival order.
-
onStateChange: (state: RealtimeClientState) => void
Receives lifecycle transitions.
-
parse: (data: string) => TIncoming
Parses a non-heartbeat text frame. Defaults to
JSON.parse. -
reconnect: RealtimeReconnectOptions
Reconnect policy following an unrequested close.
-
room: string
Room name re-applied to the URL on every connection.
-
roomParameter: string
Query-string key for
RealtimeClientOptions.room. Defaults to'room'. -
signal: AbortSignal
Optional external signal that permanently closes the client.
-
timing: IClientTiming
Injectable clock and sleep seam. Defaults to
createDefaultClientTiming(). -
url: string
Absolute WebSocket endpoint URL.
-
webSocket: WebSocketFactory
Injectable constructor seam. Defaults to global WebSocket.
One parsed application message received from the server.
-
data: TData
Parsed text-frame payload.
Bounded reconnect policy for a realtime connection.
-
delayMs: number
Initial reconnect delay in milliseconds. Defaults to 1,000.
-
maxAttempts: number
Maximum reconnect attempts after close. Omit for unlimited attempts.
-
maxDelayMs: number
Maximum exponential reconnect delay in milliseconds. Defaults to 30,000.
Retry policy consumed by the ResiliencePlugin's retry pattern.
-
backoff: BackoffStrategy
Backoff strategy applied to
delay. -
delay: number
Base backoff delay in milliseconds.
-
limit: number
Maximum total attempts (
1= a single attempt, no retry).
Top-level OpenAPI 3.1 document consumed by {@code generateOpenApiClient}.
-
components: { readonly schemas?: Record<string, SdkOpenApiSchema>; }
Optional component definitions (schemas, parameters, etc.).
-
openapi: string
OpenAPI spec version string (expected {@code '3.1.0'}).
-
paths: Record<string, SdkOpenApiPathItem>
API paths keyed by path template.
An HTTP operation (method handler) on a path.
A single operation parameter.
A single path item containing HTTP operation entries.
Operation request body.
A single response description keyed by status code or range.
OpenAPI schema supporting the M21 emitted vocabulary:
- $ref: string
- additionalProperties: boolean | SdkOpenApiSchema
- allOf: SdkOpenApiSchema[]
- anyOf: SdkOpenApiSchema[]
- const: unknown
- description: string
- enum: unknown[]
- format: string
- items: SdkOpenApiSchema
- oneOf: SdkOpenApiSchema[]
- properties: Record<string, SdkOpenApiSchema>
- required: string[]
- type: string | string[]
Configuration for createSseClient.
-
fetch: () => Promise<Response>input: RequestInfo,init?: RequestInit
Injectable streaming transport. Defaults to global
fetch. -
headers: HeadersInit
Headers cloned into every initial and reconnect request.
-
onError: (error: unknown) => void
Receives recoverable transport or parse errors before a reconnect attempt.
-
onEvent: (event: SseEvent<keyof TEvents & string, TEvents[keyof TEvents]>) => void | Promise<void>
Receives every parsed data-bearing event in stream order.
-
onStateChange: (state: SseClientState) => void
Receives each state transition.
-
parse: (event: RawSseEvent) => TEvents[keyof TEvents]
Parses one raw SSE event. Defaults to
JSON.parseand is typed against the event map so applications can refine payloads by event name. -
reconnect: SseReconnectOptions
Reconnect behavior after an ended or failed stream.
-
signal: AbortSignal
External signal that closes the stream and prevents reconnects.
-
timing: IClientTiming
Injectable clock and sleep seam. Defaults to
createDefaultClientTiming(). -
url: string
Absolute SSE endpoint URL.
One parsed SSE event delivered to an application.
-
data: TData
Parsed event payload.
-
event: TName
Server-provided event name, or
'message'when omitted on the wire. -
id: string
Server event ID, when supplied.
Reconnection policy for an SSE stream.
-
delayMs: number
Default reconnect delay in milliseconds. Defaults to 1,000.
-
maxAttempts: number
Maximum reconnect attempts after a stream failure. Omit for unlimited attempts.
-
maxDelayMs: number
Upper bound for exponential reconnect delay. Defaults to 30,000.
Backoff strategy applied to a RetryPolicy's base delay.
A request interceptor called once (before any retry attempt) in registration
order. Receives a mutable ClientRequestContext.
A response interceptor called after a successful JSON parse, in registration order. Skipped entirely when the request throws.
Lifecycle states a realtime client reports.
The lifecycle state of an SSE client.
A map from SSE event names to their parsed payload types.
Injectable constructor seam for the global WebSocket.
Usage
import * as __setu_ts_sdk____Portable__zero_npm_dependency_client_SDK_for_consuming_Setu_TS_APIs___Exports_the_runtime_client_surface__interfaces__factories__error_classes__re_exported_common_policy_types__and__createDefaultClientTiming__ from "sdk/src/index.ts";