UNPKG

@sprucelabs/mercury-client

Version:

The simple way to interact with the Spruce Experience Platform

33 lines (32 loc) 1.24 kB
import { EventContract, MercuryEventEmitter, SkillEventContract, SpruceSchemas } from '@sprucelabs/mercury-types'; import { Log } from '@sprucelabs/spruce-skill-utils'; export interface ConnectionOptions { host?: string; allowSelfSignedCrt?: boolean; contracts?: EventContract[]; emitTimeoutMs?: number; reconnectDelayMs?: number; shouldReconnect?: boolean; maxEmitRetries?: number; connectionRetries?: number; log?: Log; } export type MercuryConnectFactory = (options?: ConnectionOptions) => Promise<MercuryClient>; export type MercuryClient<Contract extends EventContract = SkillEventContract> = MercuryEventEmitter<Contract> & { disconnect: () => Promise<void>; isConnected: () => boolean; getProxyToken: () => string | null; setProxyToken: (token: string) => void; registerProxyToken: () => Promise<string>; setShouldAutoRegisterListeners: (should: boolean) => void; isAuthenticated(): boolean; getIsTestClient(): boolean; authenticate(options: { skillId?: string; apiKey?: string; token?: string; }): Promise<{ skill?: SpruceSchemas.Spruce.v2020_07_22.Skill; person?: SpruceSchemas.Spruce.v2020_07_22.Person; }>; };