Skip to content

Calls helpers

Helpers exported by @morevoice/sdk from src/lib/calls.ts.

Exported from @morevoice/sdk (source: packages/sdk-ts/src/lib/calls.ts).

interface

The call fields the helper reads. The facade returns the full generated Call type.

interface CallLike {
id: string;
status?: string | null;
ended_at?: string | null;
summary?: unknown;
[field: string]: unknown;
}
constant

Statuses after which a call never changes again (besides its post-call analysis).

const FINAL_CALL_STATUSES: readonly string[];
function

True when the call is over: a final status, or an ended_at.

function isCallEnded(call: CallLike): boolean;
interface
interface WaitUntilEndedOptions {
/** Give up after this long (default 10 minutes), with a WaitTimeoutError. */
timeoutMs?: number;
/** Stops waiting; the promise rejects with the signal's reason. */
signal?: AbortSignal;
/** After the call ends, wait up to this long for its summary (`call.analyzed`). Default 0: resolve at once. */
waitForAnalysisMs?: number;
/** First polling interval (default 1000 ms); it grows ×1.5 per poll up to `maxPollIntervalMs`. */
pollIntervalMs?: number;
/** Longest polling interval (default 10 000 ms). */
maxPollIntervalMs?: number;
/** Called with every state the helper sees (each poll, and the final one). */
onUpdate?: (call: CallLike) => void;
}
interface

A stream event the helper reacts to (the C9 envelope; only type is read).

interface CallStreamEventLike {
type?: string;
}
interface

What waitUntilEnded needs from the client.

interface WaitDeps<C extends CallLike> {
/** GET /v1/calls/{id}. */
retrieve(callId: string, options: { signal: AbortSignal }): Promise<C>;
/** The call's event stream, when the API offers one; it should end after `call.ended`. */
stream?: (callId: string, options: { signal: AbortSignal; types: string[] }) => AsyncIterable<CallStreamEventLike>;
}
constant
const DEFAULT_WAIT_TIMEOUT_MS = 600_000;
function

Wait for a call to end. See the file header.

function waitUntilEnded<C extends CallLike>(deps: WaitDeps<C>, callId: string, options: WaitUntilEndedOptions = {}): Promise<C>;