@squidcloud/client
Version:
A typescript implementation of the Squid client
22 lines (21 loc) • 1 kB
TypeScript
import { TriggerEvent } from '../../internal-common/src/public-types/event.public-types';
/**
* EventsClient provides methods for emitting generic events that are handled by backend functions
* declared with the `@eventHandler` decorator.
* @category Platform
*/
export declare class EventsClient {
private readonly rpcManager;
/**
* Emits a generic event delivered to every subscriber declared with `@eventHandler` for the same
* event type. Events are delivered durably/at-least-once with no ordering guarantee, so handlers
* should be idempotent and order-independent. Resolves once the event is enqueued, not once
* subscribers have handled it.
*
* Requires API key authentication — events are emitted only by trusted server-side code, so calls
* authenticated with a user token are rejected.
*
* @param event The event to emit, with a unique `id`, a `type`, and a `payload`.
*/
emit<T>(event: TriggerEvent<T>): Promise<void>;
}