diff --git a/src/assistantSdk/assistant.ts b/src/assistantSdk/assistant.ts index 751874d..c1e3138 100644 --- a/src/assistantSdk/assistant.ts +++ b/src/assistantSdk/assistant.ts @@ -279,6 +279,8 @@ export const createAssistant = ({ getMeta, ...configuration }: VpsConfiguration // обработка входящих команд, и событий аппа subscriptions.push( client.on('systemMessage', (systemMessage: SystemMessageDataType, originalMessage: OriginalMessageType) => { + console.log('systemMessage', systemMessage); + if (originalMessage.messageName === 'ANSWER_TO_USER') { const { activate_app_info, items, app_info: mesAppInfo, character } = systemMessage; @@ -408,6 +410,7 @@ export const createAssistant = ({ getMeta, ...configuration }: VpsConfiguration closeApp, listen: voice.listen, sendServerAction, + getChatHistory: protocol.getChatHistory, sendText, start, stop: () => { diff --git a/src/assistantSdk/client/client.ts b/src/assistantSdk/client/client.ts index 524f48d..590b39e 100644 --- a/src/assistantSdk/client/client.ts +++ b/src/assistantSdk/client/client.ts @@ -159,6 +159,8 @@ export const createClient = ( }); const off = protocol.on('incoming', (message: OriginalMessageType) => { + console.log('protocol.on incoming', message); + if (message.voice) { emit('voice', message.voice.data || new Uint8Array(), message); } diff --git a/src/assistantSdk/client/methods.ts b/src/assistantSdk/client/methods.ts index 358330a..7e1c506 100644 --- a/src/assistantSdk/client/methods.ts +++ b/src/assistantSdk/client/methods.ts @@ -13,6 +13,9 @@ import { Cancel, ICancel, IMessage, + IGetHistoryRequest, + IChatHistoryRequest, + ChatHistoryRequest, } from '../../proto'; import { VpsVersion } from '../../typings'; @@ -73,6 +76,7 @@ export const createClientMethods = ({ | { legacyDevice: LegacyDevice } | { initialSettings: InitialSettings } | { cancel: Cancel } + | IChatHistoryRequest ) & { last: 1 | -1; messageName?: string; @@ -114,6 +118,27 @@ export const createClientMethods = ({ }); }; + const getChatHistory = ( + data: Omit & { historyParams?: IGetHistoryRequest }, + last = true, + messageId = getMessageId(), + ) => { + const { uuid, device, historyParams } = data; + + return send({ + payload: { + ...ChatHistoryRequest.create({ + uuid, + device, + getHistoryRequest: historyParams, + }), + messageName: 'GET_HISTORY', + last: last ? 1 : -1, + }, + messageId, + }); + }; + const sendCancel = (data: ICancel, last = true, messageId = getMessageId()) => { return send({ payload: { @@ -278,6 +303,7 @@ export const createClientMethods = ({ return { sendDevice, sendInitialSettings, + getChatHistory, sendCancel, sendLegacyDevice, sendSettings, diff --git a/src/assistantSdk/client/protocol.ts b/src/assistantSdk/client/protocol.ts index 1ab2740..987a2ef 100644 --- a/src/assistantSdk/client/protocol.ts +++ b/src/assistantSdk/client/protocol.ts @@ -1,5 +1,5 @@ import { createNanoEvents } from '../../nanoevents'; -import { IDevice, IInitialSettings, ILegacyDevice, IMessage, Message } from '../../proto'; +import { IDevice, IInitialSettings, ILegacyDevice, IMessage, Message, IGetHistoryRequest, IDevice } from '../../proto'; import { VpsConfiguration, OriginalMessageType, VpsVersion } from '../../typings'; import { createClientMethods } from './methods'; @@ -143,6 +143,7 @@ export const createProtocol = ( const { sendDevice: sendDeviceOriginal, sendInitialSettings: sendInitialSettingsOriginal, + getChatHistory: getChatHistoryOriginal, sendCancel, sendLegacyDevice: sendLegacyDeviceOriginal, sendSettings: sendSettingsOriginal, @@ -171,6 +172,22 @@ export const createProtocol = ( return sendInitialSettingsOriginal(data, ...args); }) as typeof sendInitialSettingsOriginal; + const getChatHistory = (data?: { + userId?: string; + userChannel?: string; + device?: IDevice; + historyParams?: IGetHistoryRequest; + }) => { + return getChatHistoryOriginal({ + uuid: { + userId: data?.userId || userId, + userChannel: data?.userChannel || userChannel, + }, + device: data?.device || device, + historyParams: data?.historyParams, + }); + }; + const sendLegacyDevice = ((data: ILegacyDevice, ...args: never[]) => { currentSettings = { ...currentSettings, legacyDevice: data }; @@ -300,6 +317,7 @@ export const createProtocol = ( subscriptions.splice(0, subscriptions.length).map((unsubscribe) => unsubscribe()); }, on, + getChatHistory, getMessageId, sendCancel, sendText, diff --git a/src/proto/index.d.ts b/src/proto/index.d.ts index f660341..855c5df 100644 --- a/src/proto/index.d.ts +++ b/src/proto/index.d.ts @@ -59,6 +59,9 @@ export interface IMessage { /** Message cancel */ cancel?: (ICancel|null); + /** Message getHistoryRequest */ + getHistoryRequest?: (IGetHistoryRequest|null); + /** Message timestamp */ timestamp?: (number|Long|null); @@ -132,6 +135,9 @@ export class Message implements IMessage { /** Message cancel. */ public cancel?: (ICancel|null); + /** Message getHistoryRequest. */ + public getHistoryRequest?: (IGetHistoryRequest|null); + /** Message timestamp. */ public timestamp: (number|Long); @@ -139,7 +145,7 @@ export class Message implements IMessage { public meta: { [k: string]: string }; /** Message content. */ - public content?: ("voice"|"text"|"systemMessage"|"legacyDevice"|"settings"|"status"|"device"|"bytes"|"initialSettings"|"cancel"); + public content?: ("voice"|"text"|"systemMessage"|"legacyDevice"|"settings"|"status"|"device"|"bytes"|"initialSettings"|"cancel"|"getHistoryRequest"); /** * Creates a new Message instance using the specified properties. @@ -1393,3 +1399,744 @@ export class Cancel implements ICancel { */ public toJSON(): { [k: string]: any }; } + +/** Properties of an App. */ +export interface IApp { + + /** App type */ + type?: (string|null); + + /** App projectId */ + projectId?: (string|null); + + /** App systemName */ + systemName?: (string|null); +} + +/** Represents an App. */ +export class App implements IApp { + + /** + * Constructs a new App. + * @param [properties] Properties to set + */ + constructor(properties?: IApp); + + /** App type. */ + public type: string; + + /** App projectId. */ + public projectId: string; + + /** App systemName. */ + public systemName: string; + + /** + * Creates a new App instance using the specified properties. + * @param [properties] Properties to set + * @returns App instance + */ + public static create(properties?: IApp): App; + + /** + * Encodes the specified App message. Does not implicitly {@link App.verify|verify} messages. + * @param message App message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: IApp, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified App message, length delimited. Does not implicitly {@link App.verify|verify} messages. + * @param message App message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: IApp, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an App message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns App + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): App; + + /** + * Decodes an App message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns App + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): App; + + /** + * Verifies an App message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an App message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns App + */ + public static fromObject(object: { [k: string]: any }): App; + + /** + * Creates a plain object from an App message. Also converts values to other types if specified. + * @param message App + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: App, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this App to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; +} + +/** Properties of an Offset. */ +export interface IOffset { + + /** Offset limit */ + limit?: (string|null); + + /** Offset contentId */ + contentId?: (string|null); +} + +/** Represents an Offset. */ +export class Offset implements IOffset { + + /** + * Constructs a new Offset. + * @param [properties] Properties to set + */ + constructor(properties?: IOffset); + + /** Offset limit. */ + public limit: string; + + /** Offset contentId. */ + public contentId: string; + + /** + * Creates a new Offset instance using the specified properties. + * @param [properties] Properties to set + * @returns Offset instance + */ + public static create(properties?: IOffset): Offset; + + /** + * Encodes the specified Offset message. Does not implicitly {@link Offset.verify|verify} messages. + * @param message Offset message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: IOffset, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Offset message, length delimited. Does not implicitly {@link Offset.verify|verify} messages. + * @param message Offset message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: IOffset, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an Offset message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Offset + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): Offset; + + /** + * Decodes an Offset message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Offset + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): Offset; + + /** + * Verifies an Offset message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an Offset message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Offset + */ + public static fromObject(object: { [k: string]: any }): Offset; + + /** + * Creates a plain object from an Offset message. Also converts values to other types if specified. + * @param message Offset + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: Offset, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Offset to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; +} + +/** Properties of a GetHistoryRequest. */ +export interface IGetHistoryRequest { + + /** GetHistoryRequest messageTypes */ + messageTypes?: (string[]|null); + + /** GetHistoryRequest app */ + app?: (IApp|null); + + /** GetHistoryRequest offset */ + offset?: (IOffset|null); +} + +/** Represents a GetHistoryRequest. */ +export class GetHistoryRequest implements IGetHistoryRequest { + + /** + * Constructs a new GetHistoryRequest. + * @param [properties] Properties to set + */ + constructor(properties?: IGetHistoryRequest); + + /** GetHistoryRequest messageTypes. */ + public messageTypes: string[]; + + /** GetHistoryRequest app. */ + public app?: (IApp|null); + + /** GetHistoryRequest offset. */ + public offset?: (IOffset|null); + + /** + * Creates a new GetHistoryRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetHistoryRequest instance + */ + public static create(properties?: IGetHistoryRequest): GetHistoryRequest; + + /** + * Encodes the specified GetHistoryRequest message. Does not implicitly {@link GetHistoryRequest.verify|verify} messages. + * @param message GetHistoryRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: IGetHistoryRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetHistoryRequest message, length delimited. Does not implicitly {@link GetHistoryRequest.verify|verify} messages. + * @param message GetHistoryRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: IGetHistoryRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetHistoryRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetHistoryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): GetHistoryRequest; + + /** + * Decodes a GetHistoryRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetHistoryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): GetHistoryRequest; + + /** + * Verifies a GetHistoryRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a GetHistoryRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetHistoryRequest + */ + public static fromObject(object: { [k: string]: any }): GetHistoryRequest; + + /** + * Creates a plain object from a GetHistoryRequest message. Also converts values to other types if specified. + * @param message GetHistoryRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: GetHistoryRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetHistoryRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; +} + +/** Properties of an Uuid. */ +export interface IUuid { + + /** Uuid userId */ + userId?: (string|null); + + /** Uuid userChannel */ + userChannel?: (string|null); + + /** Uuid sub */ + sub?: (string|null); +} + +/** Represents an Uuid. */ +export class Uuid implements IUuid { + + /** + * Constructs a new Uuid. + * @param [properties] Properties to set + */ + constructor(properties?: IUuid); + + /** Uuid userId. */ + public userId: string; + + /** Uuid userChannel. */ + public userChannel: string; + + /** Uuid sub. */ + public sub: string; + + /** + * Creates a new Uuid instance using the specified properties. + * @param [properties] Properties to set + * @returns Uuid instance + */ + public static create(properties?: IUuid): Uuid; + + /** + * Encodes the specified Uuid message. Does not implicitly {@link Uuid.verify|verify} messages. + * @param message Uuid message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: IUuid, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Uuid message, length delimited. Does not implicitly {@link Uuid.verify|verify} messages. + * @param message Uuid message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: IUuid, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an Uuid message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Uuid + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): Uuid; + + /** + * Decodes an Uuid message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Uuid + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): Uuid; + + /** + * Verifies an Uuid message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an Uuid message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Uuid + */ + public static fromObject(object: { [k: string]: any }): Uuid; + + /** + * Creates a plain object from an Uuid message. Also converts values to other types if specified. + * @param message Uuid + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: Uuid, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Uuid to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; +} + +/** Properties of a HistoryMessages. */ +export interface IHistoryMessages { + + /** HistoryMessages content */ + content?: (string|null); + + /** HistoryMessages contentId */ + contentId?: (string|null); + + /** HistoryMessages timeCreated */ + timeCreated?: (string|null); +} + +/** Represents a HistoryMessages. */ +export class HistoryMessages implements IHistoryMessages { + + /** + * Constructs a new HistoryMessages. + * @param [properties] Properties to set + */ + constructor(properties?: IHistoryMessages); + + /** HistoryMessages content. */ + public content: string; + + /** HistoryMessages contentId. */ + public contentId: string; + + /** HistoryMessages timeCreated. */ + public timeCreated: string; + + /** + * Creates a new HistoryMessages instance using the specified properties. + * @param [properties] Properties to set + * @returns HistoryMessages instance + */ + public static create(properties?: IHistoryMessages): HistoryMessages; + + /** + * Encodes the specified HistoryMessages message. Does not implicitly {@link HistoryMessages.verify|verify} messages. + * @param message HistoryMessages message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: IHistoryMessages, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified HistoryMessages message, length delimited. Does not implicitly {@link HistoryMessages.verify|verify} messages. + * @param message HistoryMessages message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: IHistoryMessages, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a HistoryMessages message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns HistoryMessages + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): HistoryMessages; + + /** + * Decodes a HistoryMessages message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns HistoryMessages + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): HistoryMessages; + + /** + * Verifies a HistoryMessages message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a HistoryMessages message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns HistoryMessages + */ + public static fromObject(object: { [k: string]: any }): HistoryMessages; + + /** + * Creates a plain object from a HistoryMessages message. Also converts values to other types if specified. + * @param message HistoryMessages + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: HistoryMessages, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this HistoryMessages to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; +} + +/** Properties of a ChatHistoryRequest. */ +export interface IChatHistoryRequest { + + /** ChatHistoryRequest uuid */ + uuid?: (IUuid|null); + + /** ChatHistoryRequest device */ + device?: (IDevice|null); + + /** ChatHistoryRequest getHistoryRequest */ + getHistoryRequest?: (IGetHistoryRequest|null); +} + +/** Represents a ChatHistoryRequest. */ +export class ChatHistoryRequest implements IChatHistoryRequest { + + /** + * Constructs a new ChatHistoryRequest. + * @param [properties] Properties to set + */ + constructor(properties?: IChatHistoryRequest); + + /** ChatHistoryRequest uuid. */ + public uuid?: (IUuid|null); + + /** ChatHistoryRequest device. */ + public device?: (IDevice|null); + + /** ChatHistoryRequest getHistoryRequest. */ + public getHistoryRequest?: (IGetHistoryRequest|null); + + /** + * Creates a new ChatHistoryRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ChatHistoryRequest instance + */ + public static create(properties?: IChatHistoryRequest): ChatHistoryRequest; + + /** + * Encodes the specified ChatHistoryRequest message. Does not implicitly {@link ChatHistoryRequest.verify|verify} messages. + * @param message ChatHistoryRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: IChatHistoryRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ChatHistoryRequest message, length delimited. Does not implicitly {@link ChatHistoryRequest.verify|verify} messages. + * @param message ChatHistoryRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: IChatHistoryRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ChatHistoryRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ChatHistoryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): ChatHistoryRequest; + + /** + * Decodes a ChatHistoryRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ChatHistoryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): ChatHistoryRequest; + + /** + * Verifies a ChatHistoryRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ChatHistoryRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ChatHistoryRequest + */ + public static fromObject(object: { [k: string]: any }): ChatHistoryRequest; + + /** + * Creates a plain object from a ChatHistoryRequest message. Also converts values to other types if specified. + * @param message ChatHistoryRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: ChatHistoryRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ChatHistoryRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; +} + +/** Properties of a GetHistoryResponse. */ +export interface IGetHistoryResponse { + + /** GetHistoryResponse historyMessages */ + historyMessages?: (IHistoryMessages[]|null); +} + +/** Represents a GetHistoryResponse. */ +export class GetHistoryResponse implements IGetHistoryResponse { + + /** + * Constructs a new GetHistoryResponse. + * @param [properties] Properties to set + */ + constructor(properties?: IGetHistoryResponse); + + /** GetHistoryResponse historyMessages. */ + public historyMessages: IHistoryMessages[]; + + /** + * Creates a new GetHistoryResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns GetHistoryResponse instance + */ + public static create(properties?: IGetHistoryResponse): GetHistoryResponse; + + /** + * Encodes the specified GetHistoryResponse message. Does not implicitly {@link GetHistoryResponse.verify|verify} messages. + * @param message GetHistoryResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: IGetHistoryResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetHistoryResponse message, length delimited. Does not implicitly {@link GetHistoryResponse.verify|verify} messages. + * @param message GetHistoryResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: IGetHistoryResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetHistoryResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetHistoryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): GetHistoryResponse; + + /** + * Decodes a GetHistoryResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetHistoryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): GetHistoryResponse; + + /** + * Verifies a GetHistoryResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a GetHistoryResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetHistoryResponse + */ + public static fromObject(object: { [k: string]: any }): GetHistoryResponse; + + /** + * Creates a plain object from a GetHistoryResponse message. Also converts values to other types if specified. + * @param message GetHistoryResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: GetHistoryResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetHistoryResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; +} + +/** Represents a ChatHistorySearchService */ +export class ChatHistorySearchService extends $protobuf.rpc.Service { + + /** + * Constructs a new ChatHistorySearchService service. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + */ + constructor(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean); + + /** + * Creates new ChatHistorySearchService service using the specified rpc implementation. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + * @returns RPC service. Useful where requests and/or responses are streamed. + */ + public static create(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean): ChatHistorySearchService; + + /** + * Calls GetMessageHistory. + * @param request ChatHistoryRequest message or plain object + * @param callback Node-style callback called with the error, if any, and GetHistoryResponse + */ + public getMessageHistory(request: IChatHistoryRequest, callback: ChatHistorySearchService.GetMessageHistoryCallback): void; + + /** + * Calls GetMessageHistory. + * @param request ChatHistoryRequest message or plain object + * @returns Promise + */ + public getMessageHistory(request: IChatHistoryRequest): Promise; +} + +export namespace ChatHistorySearchService { + + /** + * Callback as used by {@link ChatHistorySearchService#getMessageHistory}. + * @param error Error, if any + * @param [response] GetHistoryResponse + */ + type GetMessageHistoryCallback = (error: (Error|null), response?: GetHistoryResponse) => void; +} diff --git a/src/proto/index.js b/src/proto/index.js index 707ebfb..d30999c 100644 --- a/src/proto/index.js +++ b/src/proto/index.js @@ -41,6 +41,7 @@ * @property {IBytes|null} [bytes] Message bytes * @property {IInitialSettings|null} [initialSettings] Message initialSettings * @property {ICancel|null} [cancel] Message cancel + * @property {IGetHistoryRequest|null} [getHistoryRequest] Message getHistoryRequest * @property {number|Long|null} [timestamp] Message timestamp * @property {Object.|null} [meta] Message meta */ @@ -214,6 +215,14 @@ */ Message.prototype.cancel = null; + /** + * Message getHistoryRequest. + * @member {IGetHistoryRequest|null|undefined} getHistoryRequest + * @memberof Message + * @instance + */ + Message.prototype.getHistoryRequest = null; + /** * Message timestamp. * @member {number|Long} timestamp @@ -235,12 +244,12 @@ /** * Message content. - * @member {"voice"|"text"|"systemMessage"|"legacyDevice"|"settings"|"status"|"device"|"bytes"|"initialSettings"|"cancel"|undefined} content + * @member {"voice"|"text"|"systemMessage"|"legacyDevice"|"settings"|"status"|"device"|"bytes"|"initialSettings"|"cancel"|"getHistoryRequest"|undefined} content * @memberof Message * @instance */ Object.defineProperty(Message.prototype, "content", { - get: $util.oneOfGetter($oneOfFields = ["voice", "text", "systemMessage", "legacyDevice", "settings", "status", "device", "bytes", "initialSettings", "cancel"]), + get: $util.oneOfGetter($oneOfFields = ["voice", "text", "systemMessage", "legacyDevice", "settings", "status", "device", "bytes", "initialSettings", "cancel", "getHistoryRequest"]), set: $util.oneOfSetter($oneOfFields) }); @@ -312,6 +321,8 @@ writer.uint32(/* id 20, wireType 2 =*/162).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.meta[keys[i]]).ldelim(); if (message.cancel != null && Object.hasOwnProperty.call(message, "cancel")) $root.Cancel.encode(message.cancel, writer.uint32(/* id 21, wireType 2 =*/170).fork()).ldelim(); + if (message.getHistoryRequest != null && Object.hasOwnProperty.call(message, "getHistoryRequest")) + $root.GetHistoryRequest.encode(message.getHistoryRequest, writer.uint32(/* id 22, wireType 2 =*/178).fork()).ldelim(); return writer; }; @@ -405,6 +416,9 @@ case 21: message.cancel = $root.Cancel.decode(reader, reader.uint32()); break; + case 22: + message.getHistoryRequest = $root.GetHistoryRequest.decode(reader, reader.uint32()); + break; case 19: message.timestamp = reader.int64(); break; @@ -597,6 +611,16 @@ return "cancel." + error; } } + if (message.getHistoryRequest != null && message.hasOwnProperty("getHistoryRequest")) { + if (properties.content === 1) + return "content: multiple values"; + properties.content = 1; + { + var error = $root.GetHistoryRequest.verify(message.getHistoryRequest); + if (error) + return "getHistoryRequest." + error; + } + } if (message.timestamp != null && message.hasOwnProperty("timestamp")) if (!$util.isInteger(message.timestamp) && !(message.timestamp && $util.isInteger(message.timestamp.low) && $util.isInteger(message.timestamp.high))) return "timestamp: integer|Long expected"; @@ -706,6 +730,11 @@ throw TypeError(".Message.cancel: object expected"); message.cancel = $root.Cancel.fromObject(object.cancel); } + if (object.getHistoryRequest != null) { + if (typeof object.getHistoryRequest !== "object") + throw TypeError(".Message.getHistoryRequest: object expected"); + message.getHistoryRequest = $root.GetHistoryRequest.fromObject(object.getHistoryRequest); + } if (object.timestamp != null) if ($util.Long) (message.timestamp = $util.Long.fromValue(object.timestamp)).unsigned = false; @@ -846,6 +875,11 @@ if (options.oneofs) object.content = "cancel"; } + if (message.getHistoryRequest != null && message.hasOwnProperty("getHistoryRequest")) { + object.getHistoryRequest = $root.GetHistoryRequest.toObject(message.getHistoryRequest, options); + if (options.oneofs) + object.content = "getHistoryRequest"; + } return object; }; @@ -3668,6 +3702,1694 @@ return Cancel; })(); + + $root.App = (function() { + + /** + * Properties of an App. + * @exports IApp + * @interface IApp + * @property {string|null} [type] App type + * @property {string|null} [projectId] App projectId + * @property {string|null} [systemName] App systemName + */ + + /** + * Constructs a new App. + * @exports App + * @classdesc Represents an App. + * @implements IApp + * @constructor + * @param {IApp=} [properties] Properties to set + */ + function App(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * App type. + * @member {string} type + * @memberof App + * @instance + */ + App.prototype.type = ""; + + /** + * App projectId. + * @member {string} projectId + * @memberof App + * @instance + */ + App.prototype.projectId = ""; + + /** + * App systemName. + * @member {string} systemName + * @memberof App + * @instance + */ + App.prototype.systemName = ""; + + /** + * Creates a new App instance using the specified properties. + * @function create + * @memberof App + * @static + * @param {IApp=} [properties] Properties to set + * @returns {App} App instance + */ + App.create = function create(properties) { + return new App(properties); + }; + + /** + * Encodes the specified App message. Does not implicitly {@link App.verify|verify} messages. + * @function encode + * @memberof App + * @static + * @param {IApp} message App message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + App.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.type); + if (message.projectId != null && Object.hasOwnProperty.call(message, "projectId")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.projectId); + if (message.systemName != null && Object.hasOwnProperty.call(message, "systemName")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.systemName); + return writer; + }; + + /** + * Encodes the specified App message, length delimited. Does not implicitly {@link App.verify|verify} messages. + * @function encodeDelimited + * @memberof App + * @static + * @param {IApp} message App message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + App.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an App message from the specified reader or buffer. + * @function decode + * @memberof App + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {App} App + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + App.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.App(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.type = reader.string(); + break; + case 2: + message.projectId = reader.string(); + break; + case 3: + message.systemName = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an App message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof App + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {App} App + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + App.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an App message. + * @function verify + * @memberof App + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + App.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.type != null && message.hasOwnProperty("type")) + if (!$util.isString(message.type)) + return "type: string expected"; + if (message.projectId != null && message.hasOwnProperty("projectId")) + if (!$util.isString(message.projectId)) + return "projectId: string expected"; + if (message.systemName != null && message.hasOwnProperty("systemName")) + if (!$util.isString(message.systemName)) + return "systemName: string expected"; + return null; + }; + + /** + * Creates an App message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof App + * @static + * @param {Object.} object Plain object + * @returns {App} App + */ + App.fromObject = function fromObject(object) { + if (object instanceof $root.App) + return object; + var message = new $root.App(); + if (object.type != null) + message.type = String(object.type); + if (object.projectId != null) + message.projectId = String(object.projectId); + if (object.systemName != null) + message.systemName = String(object.systemName); + return message; + }; + + /** + * Creates a plain object from an App message. Also converts values to other types if specified. + * @function toObject + * @memberof App + * @static + * @param {App} message App + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + App.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.type = ""; + object.projectId = ""; + object.systemName = ""; + } + if (message.type != null && message.hasOwnProperty("type")) + object.type = message.type; + if (message.projectId != null && message.hasOwnProperty("projectId")) + object.projectId = message.projectId; + if (message.systemName != null && message.hasOwnProperty("systemName")) + object.systemName = message.systemName; + return object; + }; + + /** + * Converts this App to JSON. + * @function toJSON + * @memberof App + * @instance + * @returns {Object.} JSON object + */ + App.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return App; + })(); + + $root.Offset = (function() { + + /** + * Properties of an Offset. + * @exports IOffset + * @interface IOffset + * @property {string|null} [limit] Offset limit + * @property {string|null} [contentId] Offset contentId + */ + + /** + * Constructs a new Offset. + * @exports Offset + * @classdesc Represents an Offset. + * @implements IOffset + * @constructor + * @param {IOffset=} [properties] Properties to set + */ + function Offset(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Offset limit. + * @member {string} limit + * @memberof Offset + * @instance + */ + Offset.prototype.limit = ""; + + /** + * Offset contentId. + * @member {string} contentId + * @memberof Offset + * @instance + */ + Offset.prototype.contentId = ""; + + /** + * Creates a new Offset instance using the specified properties. + * @function create + * @memberof Offset + * @static + * @param {IOffset=} [properties] Properties to set + * @returns {Offset} Offset instance + */ + Offset.create = function create(properties) { + return new Offset(properties); + }; + + /** + * Encodes the specified Offset message. Does not implicitly {@link Offset.verify|verify} messages. + * @function encode + * @memberof Offset + * @static + * @param {IOffset} message Offset message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Offset.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.limit != null && Object.hasOwnProperty.call(message, "limit")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.limit); + if (message.contentId != null && Object.hasOwnProperty.call(message, "contentId")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.contentId); + return writer; + }; + + /** + * Encodes the specified Offset message, length delimited. Does not implicitly {@link Offset.verify|verify} messages. + * @function encodeDelimited + * @memberof Offset + * @static + * @param {IOffset} message Offset message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Offset.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Offset message from the specified reader or buffer. + * @function decode + * @memberof Offset + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {Offset} Offset + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Offset.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.Offset(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.limit = reader.string(); + break; + case 2: + message.contentId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Offset message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof Offset + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {Offset} Offset + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Offset.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Offset message. + * @function verify + * @memberof Offset + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Offset.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.limit != null && message.hasOwnProperty("limit")) + if (!$util.isString(message.limit)) + return "limit: string expected"; + if (message.contentId != null && message.hasOwnProperty("contentId")) + if (!$util.isString(message.contentId)) + return "contentId: string expected"; + return null; + }; + + /** + * Creates an Offset message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof Offset + * @static + * @param {Object.} object Plain object + * @returns {Offset} Offset + */ + Offset.fromObject = function fromObject(object) { + if (object instanceof $root.Offset) + return object; + var message = new $root.Offset(); + if (object.limit != null) + message.limit = String(object.limit); + if (object.contentId != null) + message.contentId = String(object.contentId); + return message; + }; + + /** + * Creates a plain object from an Offset message. Also converts values to other types if specified. + * @function toObject + * @memberof Offset + * @static + * @param {Offset} message Offset + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Offset.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.limit = ""; + object.contentId = ""; + } + if (message.limit != null && message.hasOwnProperty("limit")) + object.limit = message.limit; + if (message.contentId != null && message.hasOwnProperty("contentId")) + object.contentId = message.contentId; + return object; + }; + + /** + * Converts this Offset to JSON. + * @function toJSON + * @memberof Offset + * @instance + * @returns {Object.} JSON object + */ + Offset.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Offset; + })(); + + $root.GetHistoryRequest = (function() { + + /** + * Properties of a GetHistoryRequest. + * @exports IGetHistoryRequest + * @interface IGetHistoryRequest + * @property {Array.|null} [messageTypes] GetHistoryRequest messageTypes + * @property {IApp|null} [app] GetHistoryRequest app + * @property {IOffset|null} [offset] GetHistoryRequest offset + */ + + /** + * Constructs a new GetHistoryRequest. + * @exports GetHistoryRequest + * @classdesc Represents a GetHistoryRequest. + * @implements IGetHistoryRequest + * @constructor + * @param {IGetHistoryRequest=} [properties] Properties to set + */ + function GetHistoryRequest(properties) { + this.messageTypes = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetHistoryRequest messageTypes. + * @member {Array.} messageTypes + * @memberof GetHistoryRequest + * @instance + */ + GetHistoryRequest.prototype.messageTypes = $util.emptyArray; + + /** + * GetHistoryRequest app. + * @member {IApp|null|undefined} app + * @memberof GetHistoryRequest + * @instance + */ + GetHistoryRequest.prototype.app = null; + + /** + * GetHistoryRequest offset. + * @member {IOffset|null|undefined} offset + * @memberof GetHistoryRequest + * @instance + */ + GetHistoryRequest.prototype.offset = null; + + /** + * Creates a new GetHistoryRequest instance using the specified properties. + * @function create + * @memberof GetHistoryRequest + * @static + * @param {IGetHistoryRequest=} [properties] Properties to set + * @returns {GetHistoryRequest} GetHistoryRequest instance + */ + GetHistoryRequest.create = function create(properties) { + return new GetHistoryRequest(properties); + }; + + /** + * Encodes the specified GetHistoryRequest message. Does not implicitly {@link GetHistoryRequest.verify|verify} messages. + * @function encode + * @memberof GetHistoryRequest + * @static + * @param {IGetHistoryRequest} message GetHistoryRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetHistoryRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.messageTypes != null && message.messageTypes.length) + for (var i = 0; i < message.messageTypes.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.messageTypes[i]); + if (message.app != null && Object.hasOwnProperty.call(message, "app")) + $root.App.encode(message.app, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.offset != null && Object.hasOwnProperty.call(message, "offset")) + $root.Offset.encode(message.offset, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified GetHistoryRequest message, length delimited. Does not implicitly {@link GetHistoryRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof GetHistoryRequest + * @static + * @param {IGetHistoryRequest} message GetHistoryRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetHistoryRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetHistoryRequest message from the specified reader or buffer. + * @function decode + * @memberof GetHistoryRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {GetHistoryRequest} GetHistoryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetHistoryRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.GetHistoryRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.messageTypes && message.messageTypes.length)) + message.messageTypes = []; + message.messageTypes.push(reader.string()); + break; + case 2: + message.app = $root.App.decode(reader, reader.uint32()); + break; + case 3: + message.offset = $root.Offset.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetHistoryRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof GetHistoryRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {GetHistoryRequest} GetHistoryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetHistoryRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetHistoryRequest message. + * @function verify + * @memberof GetHistoryRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetHistoryRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.messageTypes != null && message.hasOwnProperty("messageTypes")) { + if (!Array.isArray(message.messageTypes)) + return "messageTypes: array expected"; + for (var i = 0; i < message.messageTypes.length; ++i) + if (!$util.isString(message.messageTypes[i])) + return "messageTypes: string[] expected"; + } + if (message.app != null && message.hasOwnProperty("app")) { + var error = $root.App.verify(message.app); + if (error) + return "app." + error; + } + if (message.offset != null && message.hasOwnProperty("offset")) { + var error = $root.Offset.verify(message.offset); + if (error) + return "offset." + error; + } + return null; + }; + + /** + * Creates a GetHistoryRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof GetHistoryRequest + * @static + * @param {Object.} object Plain object + * @returns {GetHistoryRequest} GetHistoryRequest + */ + GetHistoryRequest.fromObject = function fromObject(object) { + if (object instanceof $root.GetHistoryRequest) + return object; + var message = new $root.GetHistoryRequest(); + if (object.messageTypes) { + if (!Array.isArray(object.messageTypes)) + throw TypeError(".GetHistoryRequest.messageTypes: array expected"); + message.messageTypes = []; + for (var i = 0; i < object.messageTypes.length; ++i) + message.messageTypes[i] = String(object.messageTypes[i]); + } + if (object.app != null) { + if (typeof object.app !== "object") + throw TypeError(".GetHistoryRequest.app: object expected"); + message.app = $root.App.fromObject(object.app); + } + if (object.offset != null) { + if (typeof object.offset !== "object") + throw TypeError(".GetHistoryRequest.offset: object expected"); + message.offset = $root.Offset.fromObject(object.offset); + } + return message; + }; + + /** + * Creates a plain object from a GetHistoryRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof GetHistoryRequest + * @static + * @param {GetHistoryRequest} message GetHistoryRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetHistoryRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.messageTypes = []; + if (options.defaults) { + object.app = null; + object.offset = null; + } + if (message.messageTypes && message.messageTypes.length) { + object.messageTypes = []; + for (var j = 0; j < message.messageTypes.length; ++j) + object.messageTypes[j] = message.messageTypes[j]; + } + if (message.app != null && message.hasOwnProperty("app")) + object.app = $root.App.toObject(message.app, options); + if (message.offset != null && message.hasOwnProperty("offset")) + object.offset = $root.Offset.toObject(message.offset, options); + return object; + }; + + /** + * Converts this GetHistoryRequest to JSON. + * @function toJSON + * @memberof GetHistoryRequest + * @instance + * @returns {Object.} JSON object + */ + GetHistoryRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return GetHistoryRequest; + })(); + + $root.Uuid = (function() { + + /** + * Properties of an Uuid. + * @exports IUuid + * @interface IUuid + * @property {string|null} [userId] Uuid userId + * @property {string|null} [userChannel] Uuid userChannel + * @property {string|null} [sub] Uuid sub + */ + + /** + * Constructs a new Uuid. + * @exports Uuid + * @classdesc Represents an Uuid. + * @implements IUuid + * @constructor + * @param {IUuid=} [properties] Properties to set + */ + function Uuid(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Uuid userId. + * @member {string} userId + * @memberof Uuid + * @instance + */ + Uuid.prototype.userId = ""; + + /** + * Uuid userChannel. + * @member {string} userChannel + * @memberof Uuid + * @instance + */ + Uuid.prototype.userChannel = ""; + + /** + * Uuid sub. + * @member {string} sub + * @memberof Uuid + * @instance + */ + Uuid.prototype.sub = ""; + + /** + * Creates a new Uuid instance using the specified properties. + * @function create + * @memberof Uuid + * @static + * @param {IUuid=} [properties] Properties to set + * @returns {Uuid} Uuid instance + */ + Uuid.create = function create(properties) { + return new Uuid(properties); + }; + + /** + * Encodes the specified Uuid message. Does not implicitly {@link Uuid.verify|verify} messages. + * @function encode + * @memberof Uuid + * @static + * @param {IUuid} message Uuid message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Uuid.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.userId != null && Object.hasOwnProperty.call(message, "userId")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.userId); + if (message.userChannel != null && Object.hasOwnProperty.call(message, "userChannel")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.userChannel); + if (message.sub != null && Object.hasOwnProperty.call(message, "sub")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.sub); + return writer; + }; + + /** + * Encodes the specified Uuid message, length delimited. Does not implicitly {@link Uuid.verify|verify} messages. + * @function encodeDelimited + * @memberof Uuid + * @static + * @param {IUuid} message Uuid message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Uuid.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Uuid message from the specified reader or buffer. + * @function decode + * @memberof Uuid + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {Uuid} Uuid + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Uuid.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.Uuid(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.userId = reader.string(); + break; + case 2: + message.userChannel = reader.string(); + break; + case 3: + message.sub = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Uuid message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof Uuid + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {Uuid} Uuid + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Uuid.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Uuid message. + * @function verify + * @memberof Uuid + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Uuid.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.userId != null && message.hasOwnProperty("userId")) + if (!$util.isString(message.userId)) + return "userId: string expected"; + if (message.userChannel != null && message.hasOwnProperty("userChannel")) + if (!$util.isString(message.userChannel)) + return "userChannel: string expected"; + if (message.sub != null && message.hasOwnProperty("sub")) + if (!$util.isString(message.sub)) + return "sub: string expected"; + return null; + }; + + /** + * Creates an Uuid message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof Uuid + * @static + * @param {Object.} object Plain object + * @returns {Uuid} Uuid + */ + Uuid.fromObject = function fromObject(object) { + if (object instanceof $root.Uuid) + return object; + var message = new $root.Uuid(); + if (object.userId != null) + message.userId = String(object.userId); + if (object.userChannel != null) + message.userChannel = String(object.userChannel); + if (object.sub != null) + message.sub = String(object.sub); + return message; + }; + + /** + * Creates a plain object from an Uuid message. Also converts values to other types if specified. + * @function toObject + * @memberof Uuid + * @static + * @param {Uuid} message Uuid + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Uuid.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.userId = ""; + object.userChannel = ""; + object.sub = ""; + } + if (message.userId != null && message.hasOwnProperty("userId")) + object.userId = message.userId; + if (message.userChannel != null && message.hasOwnProperty("userChannel")) + object.userChannel = message.userChannel; + if (message.sub != null && message.hasOwnProperty("sub")) + object.sub = message.sub; + return object; + }; + + /** + * Converts this Uuid to JSON. + * @function toJSON + * @memberof Uuid + * @instance + * @returns {Object.} JSON object + */ + Uuid.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Uuid; + })(); + + $root.HistoryMessages = (function() { + + /** + * Properties of a HistoryMessages. + * @exports IHistoryMessages + * @interface IHistoryMessages + * @property {string|null} [content] HistoryMessages content + * @property {string|null} [contentId] HistoryMessages contentId + * @property {string|null} [timeCreated] HistoryMessages timeCreated + */ + + /** + * Constructs a new HistoryMessages. + * @exports HistoryMessages + * @classdesc Represents a HistoryMessages. + * @implements IHistoryMessages + * @constructor + * @param {IHistoryMessages=} [properties] Properties to set + */ + function HistoryMessages(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * HistoryMessages content. + * @member {string} content + * @memberof HistoryMessages + * @instance + */ + HistoryMessages.prototype.content = ""; + + /** + * HistoryMessages contentId. + * @member {string} contentId + * @memberof HistoryMessages + * @instance + */ + HistoryMessages.prototype.contentId = ""; + + /** + * HistoryMessages timeCreated. + * @member {string} timeCreated + * @memberof HistoryMessages + * @instance + */ + HistoryMessages.prototype.timeCreated = ""; + + /** + * Creates a new HistoryMessages instance using the specified properties. + * @function create + * @memberof HistoryMessages + * @static + * @param {IHistoryMessages=} [properties] Properties to set + * @returns {HistoryMessages} HistoryMessages instance + */ + HistoryMessages.create = function create(properties) { + return new HistoryMessages(properties); + }; + + /** + * Encodes the specified HistoryMessages message. Does not implicitly {@link HistoryMessages.verify|verify} messages. + * @function encode + * @memberof HistoryMessages + * @static + * @param {IHistoryMessages} message HistoryMessages message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + HistoryMessages.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.content != null && Object.hasOwnProperty.call(message, "content")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.content); + if (message.contentId != null && Object.hasOwnProperty.call(message, "contentId")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.contentId); + if (message.timeCreated != null && Object.hasOwnProperty.call(message, "timeCreated")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.timeCreated); + return writer; + }; + + /** + * Encodes the specified HistoryMessages message, length delimited. Does not implicitly {@link HistoryMessages.verify|verify} messages. + * @function encodeDelimited + * @memberof HistoryMessages + * @static + * @param {IHistoryMessages} message HistoryMessages message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + HistoryMessages.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a HistoryMessages message from the specified reader or buffer. + * @function decode + * @memberof HistoryMessages + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {HistoryMessages} HistoryMessages + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + HistoryMessages.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.HistoryMessages(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.content = reader.string(); + break; + case 2: + message.contentId = reader.string(); + break; + case 3: + message.timeCreated = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a HistoryMessages message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof HistoryMessages + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {HistoryMessages} HistoryMessages + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + HistoryMessages.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a HistoryMessages message. + * @function verify + * @memberof HistoryMessages + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + HistoryMessages.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.content != null && message.hasOwnProperty("content")) + if (!$util.isString(message.content)) + return "content: string expected"; + if (message.contentId != null && message.hasOwnProperty("contentId")) + if (!$util.isString(message.contentId)) + return "contentId: string expected"; + if (message.timeCreated != null && message.hasOwnProperty("timeCreated")) + if (!$util.isString(message.timeCreated)) + return "timeCreated: string expected"; + return null; + }; + + /** + * Creates a HistoryMessages message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof HistoryMessages + * @static + * @param {Object.} object Plain object + * @returns {HistoryMessages} HistoryMessages + */ + HistoryMessages.fromObject = function fromObject(object) { + if (object instanceof $root.HistoryMessages) + return object; + var message = new $root.HistoryMessages(); + if (object.content != null) + message.content = String(object.content); + if (object.contentId != null) + message.contentId = String(object.contentId); + if (object.timeCreated != null) + message.timeCreated = String(object.timeCreated); + return message; + }; + + /** + * Creates a plain object from a HistoryMessages message. Also converts values to other types if specified. + * @function toObject + * @memberof HistoryMessages + * @static + * @param {HistoryMessages} message HistoryMessages + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + HistoryMessages.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.content = ""; + object.contentId = ""; + object.timeCreated = ""; + } + if (message.content != null && message.hasOwnProperty("content")) + object.content = message.content; + if (message.contentId != null && message.hasOwnProperty("contentId")) + object.contentId = message.contentId; + if (message.timeCreated != null && message.hasOwnProperty("timeCreated")) + object.timeCreated = message.timeCreated; + return object; + }; + + /** + * Converts this HistoryMessages to JSON. + * @function toJSON + * @memberof HistoryMessages + * @instance + * @returns {Object.} JSON object + */ + HistoryMessages.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return HistoryMessages; + })(); + + $root.ChatHistoryRequest = (function() { + + /** + * Properties of a ChatHistoryRequest. + * @exports IChatHistoryRequest + * @interface IChatHistoryRequest + * @property {IUuid|null} [uuid] ChatHistoryRequest uuid + * @property {IDevice|null} [device] ChatHistoryRequest device + * @property {IGetHistoryRequest|null} [getHistoryRequest] ChatHistoryRequest getHistoryRequest + */ + + /** + * Constructs a new ChatHistoryRequest. + * @exports ChatHistoryRequest + * @classdesc Represents a ChatHistoryRequest. + * @implements IChatHistoryRequest + * @constructor + * @param {IChatHistoryRequest=} [properties] Properties to set + */ + function ChatHistoryRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ChatHistoryRequest uuid. + * @member {IUuid|null|undefined} uuid + * @memberof ChatHistoryRequest + * @instance + */ + ChatHistoryRequest.prototype.uuid = null; + + /** + * ChatHistoryRequest device. + * @member {IDevice|null|undefined} device + * @memberof ChatHistoryRequest + * @instance + */ + ChatHistoryRequest.prototype.device = null; + + /** + * ChatHistoryRequest getHistoryRequest. + * @member {IGetHistoryRequest|null|undefined} getHistoryRequest + * @memberof ChatHistoryRequest + * @instance + */ + ChatHistoryRequest.prototype.getHistoryRequest = null; + + /** + * Creates a new ChatHistoryRequest instance using the specified properties. + * @function create + * @memberof ChatHistoryRequest + * @static + * @param {IChatHistoryRequest=} [properties] Properties to set + * @returns {ChatHistoryRequest} ChatHistoryRequest instance + */ + ChatHistoryRequest.create = function create(properties) { + return new ChatHistoryRequest(properties); + }; + + /** + * Encodes the specified ChatHistoryRequest message. Does not implicitly {@link ChatHistoryRequest.verify|verify} messages. + * @function encode + * @memberof ChatHistoryRequest + * @static + * @param {IChatHistoryRequest} message ChatHistoryRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ChatHistoryRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.uuid != null && Object.hasOwnProperty.call(message, "uuid")) + $root.Uuid.encode(message.uuid, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.device != null && Object.hasOwnProperty.call(message, "device")) + $root.Device.encode(message.device, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.getHistoryRequest != null && Object.hasOwnProperty.call(message, "getHistoryRequest")) + $root.GetHistoryRequest.encode(message.getHistoryRequest, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ChatHistoryRequest message, length delimited. Does not implicitly {@link ChatHistoryRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof ChatHistoryRequest + * @static + * @param {IChatHistoryRequest} message ChatHistoryRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ChatHistoryRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ChatHistoryRequest message from the specified reader or buffer. + * @function decode + * @memberof ChatHistoryRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {ChatHistoryRequest} ChatHistoryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ChatHistoryRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.ChatHistoryRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.uuid = $root.Uuid.decode(reader, reader.uint32()); + break; + case 2: + message.device = $root.Device.decode(reader, reader.uint32()); + break; + case 4: + message.getHistoryRequest = $root.GetHistoryRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ChatHistoryRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof ChatHistoryRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {ChatHistoryRequest} ChatHistoryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ChatHistoryRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ChatHistoryRequest message. + * @function verify + * @memberof ChatHistoryRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ChatHistoryRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.uuid != null && message.hasOwnProperty("uuid")) { + var error = $root.Uuid.verify(message.uuid); + if (error) + return "uuid." + error; + } + if (message.device != null && message.hasOwnProperty("device")) { + var error = $root.Device.verify(message.device); + if (error) + return "device." + error; + } + if (message.getHistoryRequest != null && message.hasOwnProperty("getHistoryRequest")) { + var error = $root.GetHistoryRequest.verify(message.getHistoryRequest); + if (error) + return "getHistoryRequest." + error; + } + return null; + }; + + /** + * Creates a ChatHistoryRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof ChatHistoryRequest + * @static + * @param {Object.} object Plain object + * @returns {ChatHistoryRequest} ChatHistoryRequest + */ + ChatHistoryRequest.fromObject = function fromObject(object) { + if (object instanceof $root.ChatHistoryRequest) + return object; + var message = new $root.ChatHistoryRequest(); + if (object.uuid != null) { + if (typeof object.uuid !== "object") + throw TypeError(".ChatHistoryRequest.uuid: object expected"); + message.uuid = $root.Uuid.fromObject(object.uuid); + } + if (object.device != null) { + if (typeof object.device !== "object") + throw TypeError(".ChatHistoryRequest.device: object expected"); + message.device = $root.Device.fromObject(object.device); + } + if (object.getHistoryRequest != null) { + if (typeof object.getHistoryRequest !== "object") + throw TypeError(".ChatHistoryRequest.getHistoryRequest: object expected"); + message.getHistoryRequest = $root.GetHistoryRequest.fromObject(object.getHistoryRequest); + } + return message; + }; + + /** + * Creates a plain object from a ChatHistoryRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof ChatHistoryRequest + * @static + * @param {ChatHistoryRequest} message ChatHistoryRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ChatHistoryRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.uuid = null; + object.device = null; + object.getHistoryRequest = null; + } + if (message.uuid != null && message.hasOwnProperty("uuid")) + object.uuid = $root.Uuid.toObject(message.uuid, options); + if (message.device != null && message.hasOwnProperty("device")) + object.device = $root.Device.toObject(message.device, options); + if (message.getHistoryRequest != null && message.hasOwnProperty("getHistoryRequest")) + object.getHistoryRequest = $root.GetHistoryRequest.toObject(message.getHistoryRequest, options); + return object; + }; + + /** + * Converts this ChatHistoryRequest to JSON. + * @function toJSON + * @memberof ChatHistoryRequest + * @instance + * @returns {Object.} JSON object + */ + ChatHistoryRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ChatHistoryRequest; + })(); + + $root.GetHistoryResponse = (function() { + + /** + * Properties of a GetHistoryResponse. + * @exports IGetHistoryResponse + * @interface IGetHistoryResponse + * @property {Array.|null} [historyMessages] GetHistoryResponse historyMessages + */ + + /** + * Constructs a new GetHistoryResponse. + * @exports GetHistoryResponse + * @classdesc Represents a GetHistoryResponse. + * @implements IGetHistoryResponse + * @constructor + * @param {IGetHistoryResponse=} [properties] Properties to set + */ + function GetHistoryResponse(properties) { + this.historyMessages = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetHistoryResponse historyMessages. + * @member {Array.} historyMessages + * @memberof GetHistoryResponse + * @instance + */ + GetHistoryResponse.prototype.historyMessages = $util.emptyArray; + + /** + * Creates a new GetHistoryResponse instance using the specified properties. + * @function create + * @memberof GetHistoryResponse + * @static + * @param {IGetHistoryResponse=} [properties] Properties to set + * @returns {GetHistoryResponse} GetHistoryResponse instance + */ + GetHistoryResponse.create = function create(properties) { + return new GetHistoryResponse(properties); + }; + + /** + * Encodes the specified GetHistoryResponse message. Does not implicitly {@link GetHistoryResponse.verify|verify} messages. + * @function encode + * @memberof GetHistoryResponse + * @static + * @param {IGetHistoryResponse} message GetHistoryResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetHistoryResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.historyMessages != null && message.historyMessages.length) + for (var i = 0; i < message.historyMessages.length; ++i) + $root.HistoryMessages.encode(message.historyMessages[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified GetHistoryResponse message, length delimited. Does not implicitly {@link GetHistoryResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof GetHistoryResponse + * @static + * @param {IGetHistoryResponse} message GetHistoryResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetHistoryResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetHistoryResponse message from the specified reader or buffer. + * @function decode + * @memberof GetHistoryResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {GetHistoryResponse} GetHistoryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetHistoryResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.GetHistoryResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.historyMessages && message.historyMessages.length)) + message.historyMessages = []; + message.historyMessages.push($root.HistoryMessages.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetHistoryResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof GetHistoryResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {GetHistoryResponse} GetHistoryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetHistoryResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetHistoryResponse message. + * @function verify + * @memberof GetHistoryResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetHistoryResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.historyMessages != null && message.hasOwnProperty("historyMessages")) { + if (!Array.isArray(message.historyMessages)) + return "historyMessages: array expected"; + for (var i = 0; i < message.historyMessages.length; ++i) { + var error = $root.HistoryMessages.verify(message.historyMessages[i]); + if (error) + return "historyMessages." + error; + } + } + return null; + }; + + /** + * Creates a GetHistoryResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof GetHistoryResponse + * @static + * @param {Object.} object Plain object + * @returns {GetHistoryResponse} GetHistoryResponse + */ + GetHistoryResponse.fromObject = function fromObject(object) { + if (object instanceof $root.GetHistoryResponse) + return object; + var message = new $root.GetHistoryResponse(); + if (object.historyMessages) { + if (!Array.isArray(object.historyMessages)) + throw TypeError(".GetHistoryResponse.historyMessages: array expected"); + message.historyMessages = []; + for (var i = 0; i < object.historyMessages.length; ++i) { + if (typeof object.historyMessages[i] !== "object") + throw TypeError(".GetHistoryResponse.historyMessages: object expected"); + message.historyMessages[i] = $root.HistoryMessages.fromObject(object.historyMessages[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a GetHistoryResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof GetHistoryResponse + * @static + * @param {GetHistoryResponse} message GetHistoryResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetHistoryResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.historyMessages = []; + if (message.historyMessages && message.historyMessages.length) { + object.historyMessages = []; + for (var j = 0; j < message.historyMessages.length; ++j) + object.historyMessages[j] = $root.HistoryMessages.toObject(message.historyMessages[j], options); + } + return object; + }; + + /** + * Converts this GetHistoryResponse to JSON. + * @function toJSON + * @memberof GetHistoryResponse + * @instance + * @returns {Object.} JSON object + */ + GetHistoryResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return GetHistoryResponse; + })(); + + $root.ChatHistorySearchService = (function() { + + /** + * Constructs a new ChatHistorySearchService service. + * @exports ChatHistorySearchService + * @classdesc Represents a ChatHistorySearchService + * @extends $protobuf.rpc.Service + * @constructor + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + */ + function ChatHistorySearchService(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (ChatHistorySearchService.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = ChatHistorySearchService; + + /** + * Creates new ChatHistorySearchService service using the specified rpc implementation. + * @function create + * @memberof ChatHistorySearchService + * @static + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + * @returns {ChatHistorySearchService} RPC service. Useful where requests and/or responses are streamed. + */ + ChatHistorySearchService.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link ChatHistorySearchService#getMessageHistory}. + * @memberof ChatHistorySearchService + * @typedef GetMessageHistoryCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {GetHistoryResponse} [response] GetHistoryResponse + */ + + /** + * Calls GetMessageHistory. + * @function getMessageHistory + * @memberof ChatHistorySearchService + * @instance + * @param {IChatHistoryRequest} request ChatHistoryRequest message or plain object + * @param {ChatHistorySearchService.GetMessageHistoryCallback} callback Node-style callback called with the error, if any, and GetHistoryResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(ChatHistorySearchService.prototype.getMessageHistory = function getMessageHistory(request, callback) { + return this.rpcCall(getMessageHistory, $root.ChatHistoryRequest, $root.GetHistoryResponse, request, callback); + }, "name", { value: "GetMessageHistory" }); + + /** + * Calls GetMessageHistory. + * @function getMessageHistory + * @memberof ChatHistorySearchService + * @instance + * @param {IChatHistoryRequest} request ChatHistoryRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return ChatHistorySearchService; + })(); return $root; }); diff --git a/src/proto/index.proto b/src/proto/index.proto index 5adf2c8..213f3cb 100644 --- a/src/proto/index.proto +++ b/src/proto/index.proto @@ -21,6 +21,7 @@ message Message { Bytes bytes = 17;//Массив данных для передачи сервису потребителю, в виде байтов InitialSettings initial_settings = 18;// Присылается первым сообщением после открытии сессии, они определяют контекст сессии, если не будет прислано будет ошибка Cancel cancel = 21; + GetHistoryRequest get_history_request = 22; } int64 timestamp = 19; // время создания чанка map meta = 20; // для ufsInfo и т.д. @@ -103,3 +104,46 @@ message DevContext { } message Cancel {} + +// +// ChatHistory +// + +message GetHistoryRequest { + repeated string message_types = 1; // Опционально. Список типов сообщений, которые нужно отобрать. По умолчанию: VOICE_FROM_USER, MESSAGE_FROM_USER, ANSWER_TO_USER + App app = 2; //Опционально. + Offset offset = 3; //Опционально. Параметры для получения порции сообщений +} + +message App { + google.protobuf.StringValue type = 1; // Опционально. Тип аппа, по умолчанию DIALOG - если нужна история переписки с ассистентом + google.protobuf.StringValue project_id = 2; //Опционально. Если требуется история переписки в конкретном приложении, например ChatApp'е + google.protobuf.StringValue system_name = 3; //Опционально. Если требуется история переписки в конкретном приложении, например ChatApp'е +} + +message Offset { + google.protobuf.StringValue limit = 1; // Опционально. Количество запрашиваемых сообщений, по умолчанию 10. Максимальное значение 30 + google.protobuf.StringValue content_id = 2; //Опционально. Идентификатор записи в History (content_id из ответа) +} + +message ChatHistoryRequest { + Uuid uuid = 1; //Обязательно + proto.vps.Device device = 2;//Обязательно + proto.vps.GetHistoryRequest get_history_request = 4; +} + +message Uuid { + string user_id = 1;//Обязательно (max 36 символов) + string user_channel = 2;//Обязательно. Пример, SBOL, B2C и т д + string sub = 3;//Обязательно +} + +message GetHistoryResponse { + repeated HistoryMessages history_messages = 1; // Коллекция сообщений +} + +message HistoryMessages { + string content = 1; // JSON as String. + string content_id = 2; //Идентификатор записи в History + string time_created = 3; //Дата вставки в БД, для отображения на фронте +}