/** * Typed event wrappers for RELAY calling events. * * These are convenience classes over raw event dicts. All Call event handlers * also accept the raw dict, so these are optional. */ /** * Base class for all typed RELAY events. * * Raw events arrive as `signalwire.event` JSON-RPC notifications; the client * looks up the correct subclass in {@link EVENT_CLASS_MAP} and invokes * {@link RelayEvent.fromPayload} to build a typed wrapper. Handlers receive * this wrapper; they can always read the original dict from `params`. */ export declare class RelayEvent { /** Fully-qualified event type (e.g. `"calling.call.state"`). */ readonly eventType: string; /** Raw params dict from the RELAY notification. */ readonly params: Record; /** Call ID associated with the event, or `""` for non-call events. */ readonly callId: string; /** Server timestamp (epoch seconds) at which the event was emitted. */ readonly timestamp: number; /** * @param eventType - Fully-qualified event type. * @param params - Raw event params dict. * @param callId - Call ID (if applicable). * @param timestamp - Server-side event timestamp. */ constructor(eventType: string, params: Record, callId?: string, timestamp?: number); /** * Factory that builds a typed event from a raw `signalwire.event` payload. * Subclasses override this to populate their specialised fields; the base * implementation returns a minimal `RelayEvent` used as the fallback for * unrecognised event types. */ static fromPayload(payload: Record): RelayEvent; } /** `calling.call.state` — fires on every lifecycle transition (created, ringing, answered, ending, ended). */ export declare class CallStateEvent extends RelayEvent { readonly callState: string; readonly endReason: string; readonly direction: string; readonly device: Record; constructor(eventType: string, params: Record, callId: string, timestamp: number, callState: string, endReason: string, direction: string, device: Record); static fromPayload(payload: Record): CallStateEvent; } /** `calling.call.receive` — fires when an inbound call arrives on a subscribed context. */ export declare class CallReceiveEvent extends RelayEvent { readonly callState: string; readonly direction: string; readonly device: Record; readonly nodeId: string; readonly projectId: string; readonly context: string; readonly segmentId: string; readonly tag: string; constructor(eventType: string, params: Record, callId: string, timestamp: number, callState: string, direction: string, device: Record, nodeId: string, projectId: string, context: string, segmentId: string, tag: string); static fromPayload(payload: Record): CallReceiveEvent; } /** `calling.call.play` — play-media action state change (`playing`, `paused`, `finished`, `error`). */ export declare class PlayEvent extends RelayEvent { readonly controlId: string; readonly state: string; constructor(eventType: string, params: Record, callId: string, timestamp: number, controlId: string, state: string); static fromPayload(payload: Record): PlayEvent; } /** `calling.call.record` — recording state change with final URL, duration, and size when finished. */ export declare class RecordEvent extends RelayEvent { readonly controlId: string; readonly state: string; readonly url: string; readonly duration: number; readonly size: number; readonly record: Record; constructor(eventType: string, params: Record, callId: string, timestamp: number, controlId: string, state: string, url: string, duration: number, size: number, record: Record); static fromPayload(payload: Record): RecordEvent; } /** `calling.call.collect` — caller input (DTMF or speech) collected by a collect action. */ export declare class CollectEvent extends RelayEvent { readonly controlId: string; readonly state: string; readonly result: Record; readonly final: boolean | undefined; constructor(eventType: string, params: Record, callId: string, timestamp: number, controlId?: string, state?: string, result?: Record, final_?: boolean | undefined); static fromPayload(payload: Record): CollectEvent; } /** `calling.call.connect` — state transition when one call connects to another (dialplan/bridge). */ export declare class ConnectEvent extends RelayEvent { readonly connectState: string; readonly peer: Record; constructor(eventType: string, params: Record, callId: string, timestamp: number, connectState: string, peer: Record); static fromPayload(payload: Record): ConnectEvent; } /** `calling.call.detect` — answering-machine / fax / DTMF detection result. */ export declare class DetectEvent extends RelayEvent { readonly controlId: string; readonly detect: Record; constructor(eventType: string, params: Record, callId: string, timestamp: number, controlId: string, detect: Record); static fromPayload(payload: Record): DetectEvent; } /** `calling.call.fax` — fax send/receive progress update. */ export declare class FaxEvent extends RelayEvent { readonly controlId: string; readonly fax: Record; constructor(eventType: string, params: Record, callId: string, timestamp: number, controlId: string, fax: Record); static fromPayload(payload: Record): FaxEvent; } /** `calling.call.tap` — media tap state change (audio mirror to an external endpoint). */ export declare class TapEvent extends RelayEvent { readonly controlId: string; readonly state: string; readonly tap: Record; readonly device: Record; constructor(eventType: string, params: Record, callId: string, timestamp: number, controlId: string, state: string, tap: Record, device: Record); static fromPayload(payload: Record): TapEvent; } /** `calling.call.stream` — outbound media stream state change (e.g. RTMP/WebSocket streaming). */ export declare class StreamEvent extends RelayEvent { readonly controlId: string; readonly state: string; readonly url: string; readonly name: string; constructor(eventType: string, params: Record, callId: string, timestamp: number, controlId: string, state: string, url: string, name: string); static fromPayload(payload: Record): StreamEvent; } /** `calling.call.send_digits` — progress update for DTMF digits sent out on a call. */ export declare class SendDigitsEvent extends RelayEvent { readonly controlId: string; readonly state: string; constructor(eventType: string, params: Record, callId: string, timestamp: number, controlId: string, state: string); static fromPayload(payload: Record): SendDigitsEvent; } /** `calling.call.dial` — outbound dial progress (answered, failed, no-answer, etc.). */ export declare class DialEvent extends RelayEvent { readonly tag: string; readonly dialState: string; readonly call: Record; constructor(eventType: string, params: Record, callId: string, timestamp: number, tag: string, dialState: string, call: Record); static fromPayload(payload: Record): DialEvent; } /** `calling.call.refer` — SIP REFER result (off-platform transfer response codes). */ export declare class ReferEvent extends RelayEvent { readonly state: string; readonly sipReferTo: string; readonly sipReferResponseCode: string; readonly sipNotifyResponseCode: string; constructor(eventType: string, params: Record, callId: string, timestamp: number, state: string, sipReferTo: string, sipReferResponseCode: string, sipNotifyResponseCode: string); static fromPayload(payload: Record): ReferEvent; } /** `calling.call.denoise` — noise-reduction on/off confirmation. */ export declare class DenoiseEvent extends RelayEvent { readonly denoised: boolean; constructor(eventType: string, params: Record, callId: string, timestamp: number, denoised: boolean); static fromPayload(payload: Record): DenoiseEvent; } /** `calling.call.pay` — PCI-compliant payment collection progress update. */ export declare class PayEvent extends RelayEvent { readonly controlId: string; readonly state: string; constructor(eventType: string, params: Record, callId: string, timestamp: number, controlId: string, state: string); static fromPayload(payload: Record): PayEvent; } /** `calling.call.queue` — call-queue position update (queued, waiting, member answered, timed out). */ export declare class QueueEvent extends RelayEvent { readonly controlId: string; readonly status: string; readonly queueId: string; readonly queueName: string; readonly position: number; readonly size: number; constructor(eventType: string, params: Record, callId: string, timestamp: number, controlId: string, status: string, queueId: string, queueName: string, position: number, size: number); static fromPayload(payload: Record): QueueEvent; } /** `calling.call.echo` — test/diagnostic echo reflection from the server. */ export declare class EchoEvent extends RelayEvent { readonly state: string; constructor(eventType: string, params: Record, callId: string, timestamp: number, state: string); static fromPayload(payload: Record): EchoEvent; } /** `calling.call.transcribe` — transcription state change and final URL/duration when finished. */ export declare class TranscribeEvent extends RelayEvent { readonly controlId: string; readonly state: string; readonly url: string; readonly recordingId: string; readonly duration: number; readonly size: number; constructor(eventType: string, params: Record, callId: string, timestamp: number, controlId: string, state: string, url: string, recordingId: string, duration: number, size: number); static fromPayload(payload: Record): TranscribeEvent; } /** `calling.call.hold` — hold/unhold state change on the call. */ export declare class HoldEvent extends RelayEvent { readonly state: string; constructor(eventType: string, params: Record, callId: string, timestamp: number, state: string); static fromPayload(payload: Record): HoldEvent; } /** `calling.conference` — conference lifecycle change (created, active, ended). */ export declare class ConferenceEvent extends RelayEvent { readonly conferenceId: string; readonly name: string; readonly status: string; constructor(eventType: string, params: Record, callId: string, timestamp: number, conferenceId: string, name: string, status: string); static fromPayload(payload: Record): ConferenceEvent; } /** `calling.error` — platform-emitted error against the calling namespace. */ export declare class CallingErrorEvent extends RelayEvent { readonly code: string; readonly message: string; constructor(eventType: string, params: Record, callId: string, timestamp: number, code: string, message: string); static fromPayload(payload: Record): CallingErrorEvent; } /** `messaging.receive` — inbound SMS/MMS received on a subscribed context. */ export declare class MessageReceiveEvent extends RelayEvent { readonly messageId: string; readonly context: string; readonly direction: string; readonly fromNumber: string; readonly toNumber: string; readonly body: string; readonly media: string[]; readonly segments: number; readonly messageState: string; readonly tags: string[]; constructor(eventType: string, params: Record, callId: string, timestamp: number, messageId: string, context: string, direction: string, fromNumber: string, toNumber: string, body: string, media: string[], segments: number, messageState: string, tags: string[]); static fromPayload(payload: Record): MessageReceiveEvent; } /** `messaging.state` — state change for an outbound message (queued → sent → delivered/failed). */ export declare class MessageStateEvent extends RelayEvent { readonly messageId: string; readonly context: string; readonly direction: string; readonly fromNumber: string; readonly toNumber: string; readonly body: string; readonly media: string[]; readonly segments: number; readonly messageState: string; readonly reason: string; readonly tags: string[]; constructor(eventType: string, params: Record, callId: string, timestamp: number, messageId: string, context: string, direction: string, fromNumber: string, toNumber: string, body: string, media: string[], segments: number, messageState: string, reason: string, tags: string[]); static fromPayload(payload: Record): MessageStateEvent; } /** Structural type for an event class that exposes a `fromPayload` factory. */ export type EventClass = { fromPayload(payload: Record): RelayEvent; }; /** * Maps RELAY `event_type` strings to the typed event subclass that builds * its wrapper. Used by {@link parseEvent} to dispatch raw payloads. */ export declare const EVENT_CLASS_MAP: Record; /** Parse a raw signalwire.event params dict into a typed event object. */ export declare function parseEvent(payload: Record): RelayEvent;