UNPKG

anchorbrowser

Version:

The official TypeScript library for the Anchorbrowser API

65 lines 2.14 kB
import { APIResource } from "../core/resource.js"; import * as Shared from "./shared.js"; import { APIPromise } from "../core/api-promise.js"; import { RequestOptions } from "../internal/request-options.js"; export declare class Events extends APIResource { /** * Signals an event with associated data, unblocking any clients waiting for this * event. This enables coordination between different browser sessions, workflows, * or external processes. * * @example * ```ts * const successResponse = await client.events.signal( * 'workflow_completed', * { * data: { * message: 'bar', * result: 'bar', * timestamp: 'bar', * }, * }, * ); * ``` */ signal(eventName: string, body: EventSignalParams, options?: RequestOptions): APIPromise<Shared.SuccessResponse>; /** * Waits for a specific event to be signaled by another process, workflow, or * session. This endpoint blocks until the event is signaled or the timeout is * reached. Useful for coordinating between multiple browser sessions or workflows. * * @example * ```ts * const response = await client.events.waitFor( * 'workflow_completed', * ); * ``` */ waitFor(eventName: string, body?: EventWaitForParams | null | undefined, options?: RequestOptions): APIPromise<EventWaitForResponse>; } export interface EventWaitForResponse { /** * The event data that was signaled */ data?: { [key: string]: unknown; }; } export interface EventSignalParams { /** * Event data to be passed to waiting clients */ data: { [key: string]: unknown; }; } export interface EventWaitForParams { /** * Timeout in milliseconds to wait for the event. Defaults to 60000ms (1 minute). */ timeoutMs?: number; } export declare namespace Events { export { type EventWaitForResponse as EventWaitForResponse, type EventSignalParams as EventSignalParams, type EventWaitForParams as EventWaitForParams, }; } //# sourceMappingURL=events.d.ts.map