@salutejs/client
Version:
Модуль взаимодействия с виртуальным ассистентом
88 lines • 3.73 kB
TypeScript
import { IDevice, ILegacyDevice, IMessage, IChatHistoryRequest } from '../../proto';
import { VpsConfiguration, OriginalMessageType, VpsVersion, GetHistoryRequestClient, Mid } from '../../typings';
import { MetaStringified } from './methods';
import { Transport } from './types';
export { BatchableMethods } from './methods';
export declare const appendHeader: (uint8Array: Uint8Array) => Uint8Array;
export declare const removeHeader: (uint8Array: Uint8Array) => Uint8Array;
export interface ProtocolError {
type: 'GET_TOKEN_ERROR';
message?: string;
}
export interface ProtocolEvents {
incoming: (message: OriginalMessageType) => void;
outcoming: (message: OriginalMessageType) => void;
ready: () => void;
error: (error: ProtocolError) => void;
}
export declare const createProtocol: (transport: Transport, { logger, getToken, getInitialMeta, ...params }: VpsConfiguration & {
getInitialMeta?: (() => Promise<Record<string, string>>) | undefined;
}) => {
clearQueue: () => void;
destroy: () => void;
on: <K extends keyof ProtocolEvents>(event: K, cb: ProtocolEvents[K]) => () => void;
getHistoryRequest: (data?: IChatHistoryRequest & {
history?: GetHistoryRequestClient;
}) => void;
getMessageId: () => Mid;
sendCancel: (data: import("../../proto").ICancel, last?: boolean, messageId?: Mid) => void;
sendMute: (data: import("../../proto").IMute, last?: boolean, messageId?: Mid) => void;
sendText: (data: string, params?: {
messageId?: number | undefined;
last?: 1 | -1 | undefined;
messageName?: string | undefined;
vpsToken?: string | undefined;
userId?: string | undefined;
token?: string | undefined;
userChannel?: string | undefined;
version?: VpsVersion | undefined;
meta?: MetaStringified | undefined;
}, type?: string, messageId?: Mid) => void;
sendSystemMessage: ({ data, messageName: mesName }: {
data: Record<string, unknown>;
messageName?: string | undefined;
}, last?: boolean, messageId?: Mid, params?: {
meta?: MetaStringified | undefined;
}) => void;
sendVoice: (data: Uint8Array, last?: boolean, messageId?: Mid, mesName?: string | undefined, params?: {
meta?: MetaStringified | undefined;
}) => void;
send: (message: IMessage) => void;
batch: <T>(cb: (methods: import("./methods").BatchableMethods) => T) => T;
changeConfiguration: (obj: Omit<Partial<{
userId: string;
token: string;
userChannel: string;
messageName: string | undefined;
vpsToken: string | undefined;
version: VpsVersion;
} | {
token: string;
messageName: string | undefined;
version: VpsVersion;
userId?: undefined;
userChannel?: undefined;
vpsToken?: undefined;
}>, "token">) => void;
changeDevice: (obj: Partial<VpsConfiguration['device']>) => void;
changeSettings: (obj: Partial<VpsConfiguration['settings']>) => void;
reconnect: () => void;
init: () => Promise<void>;
readonly currentMessageId: number;
readonly configuration: {
token: string;
url: string;
userId: string;
userChannel: string;
locale?: string | undefined;
device?: IDevice | undefined;
settings: import("../../proto").ISettings;
fakeVps?: import("../../typings").FakeVpsParams | undefined;
legacyDevice?: ILegacyDevice | undefined;
version: VpsVersion;
messageName?: string | undefined;
vpsToken?: string | undefined;
};
readonly status: "ready" | "connecting" | "connected" | "closed";
};
//# sourceMappingURL=protocol.d.ts.map