UNPKG

@prass/botpress-native

Version:

A simple and powerful SDK for integrating Botpress Chat API with React Native,

71 lines (70 loc) 2.85 kB
/** * Type definitions for Botpress API responses and resources. * This module provides strongly-typed interfaces for interacting with Botpress entities such as users, conversations, messages, and participants. * * @module botpress-types */ import EventEmitter from "eventemitter3"; import { ReturnMessage } from "../serializers/message"; import { UserResponse as UserResponseType, CreateUserResponse, Conversation, Participant, ListConversationsResponse as BotpressListConversationsResponse, ListParticipantsResponse as BotpressListParticipantsResponse, ListMessagesResponse as BotpressListMessagesResponse, MessageResponse, EventResponse } from "./botpress.response"; /** * Represents the response received from the Botpress API when creating a new user. * This type is typically returned upon successful user creation. */ export type UserResponse = CreateUserResponse; /** * Defines the structure of a user resource as returned by the Botpress API. */ export type UserResource = UserResponseType["user"]; /** * Defines the structure of a conversation resource in the Botpress API. */ export type ConversationResource = Conversation; /** * Represents the response structure for listing conversations in the Botpress API. */ export type ListConversationsResponse = BotpressListConversationsResponse; /** * Defines the structure of a message resource in the Botpress API. */ export type MessageResource = ReturnMessage; /** * Represents the raw response structure for a message from the Botpress API. */ export type MessageRaw = MessageResponse; /** * Represents the response structure for listing messages in a conversation via the Botpress API. */ export type ListMessagesResponse = BotpressListMessagesResponse; /** * Defines the structure of a participant resource in the Botpress API. */ export type ParticipantResource = Participant; /** * Represents the response structure for listing participants in a conversation via the Botpress API. */ export type ListParticipantsResponse = BotpressListParticipantsResponse; /** * Represents the type of the `ListenConversation` class. * This type is used to ensure that the `ListenConversation` class is properly instantiated. */ export interface ListenConversationType extends EventEmitter { /** * Starts listening to the conversation. * @returns {Promise<void>} A promise that resolves when the conversation is listening. */ start: () => Promise<void>; /** * Stops listening to the conversation. */ stop: () => void; /** * Reconnects to the conversation. * @returns {Promise<void>} A promise that resolves when the conversation is reconnected. */ reconnect: () => Promise<void>; } /** * Represents the response structure for an event from the Botpress API. */ export type EventResource = EventResponse;