UNPKG

@signalwire/core

Version:
43 lines 1.93 kB
import { BaseComponentOptions, JSONRPCSubscribeMethod, EventEmitter, BaseConsumer } from '..'; import type { PubSubChannel, InternalPubSubChannel, PubSubPublishParams, PubSubMessageEventName } from '../types/pubSub'; import { PubSubMessage } from './PubSubMessage'; export type BasePubSubApiEventsHandlerMapping = Record<PubSubMessageEventName, (message: PubSubMessage) => void>; /** * @privateRemarks * * Each package will have the option to either extend this * type or provide their own event mapping. */ export type BasePubSubApiEvents<T = BasePubSubApiEventsHandlerMapping> = { [k in keyof T]: T[k]; }; export declare class BasePubSubConsumer<EventTypes extends EventEmitter.ValidEventTypes = BasePubSubApiEvents> extends BaseConsumer<EventTypes> { protected subscribeMethod: JSONRPCSubscribeMethod; constructor(options: BaseComponentOptions); protected initWorker(): void; private _getChannelsParam; /** @internal */ protected _setSubscribeParams(params: Record<string, any>): void; /** @internal */ protected _getSubscribeParams({ channels }: { channels?: PubSubChannel; }): { channels: InternalPubSubChannel[]; }; /** @internal */ protected _getUnsubscribeParams({ channels }: { channels?: PubSubChannel; }): { channels: InternalPubSubChannel[]; }; private _checkMissingSubscriptions; /** @internal */ protected getSubscriptions(): EventEmitter.EventNames<EventTypes>[]; subscribe(channels?: PubSubChannel): Promise<unknown>; unsubscribe(channels: PubSubChannel): Promise<void>; updateToken(token: string): Promise<void>; publish(params: PubSubPublishParams): Promise<unknown>; getAllowedChannels(): Promise<import("..").ChatAuthorizationChannels>; } export declare const createBasePubSubObject: <PubSubType>(params: BaseComponentOptions) => PubSubType; //# sourceMappingURL=BasePubSub.d.ts.map