This version (v0.7) has not been published to npm yet.
Skip to content

Reference / @getenginex/sdk/extension / WireSchema

WireSchema<TWire, TMessage> ​

Schema of a realtime message: a Zod schema (usually wire({...})) that takes the wire payload (TWire, snake_case) and returns the public message (TMessage, camelCase). Typed structurally, so that Zod types do not appear in the realtime API: it requires Zod's safeParse, which realtime uses to validate in the client's mode (warn recovers field by field, as in HTTP responses). A schema that is only Standard Schema (e.g. Valibot) will not do.

Type Parameters ​

TWire ​

TWire

TMessage ​

TMessage

Properties ​

~standard ​

readonly ~standard: object

Standard Schema metadata (only the types are read, to infer TWire).

types? ​

readonly optional types?: object

Input (wire) and output (public message) types.

types.input ​

readonly input: TWire

types.output ​

readonly output: TMessage

vendor ​

readonly vendor: string

Schema library (Zod).

version ​

readonly version: 1

Version of the Standard Schema interface.

Methods ​

safeParse() ​

safeParse(data): { data: TMessage; success: true; } | { error: unknown; success: false; }

Validates and converts a value (Zod's safeParse).

Parameters ​

data ​

unknown

Payload received from the gateway.

Returns ​

{ data: TMessage; success: true; } | { error: unknown; success: false; }