analytica-frontend-lib
Version:
Repositório público dos componentes utilizados nas plataformas da Analytica Ensino
40 lines • 1.79 kB
TypeScript
import type { ChatbotApiClient, ChatbotConversation, ChatbotMessage, ChatbotCurrentContext } from '../types/chatbot';
/**
* Data and actions exposed by `useChatbot`
*/
export interface UseChatbotReturn {
isOpen: boolean;
isSending: boolean;
isLoadingHistory: boolean;
isLoadingMessages: boolean;
errorMessage: string | null;
conversations: ChatbotConversation[];
activeConversationId: string | null;
messages: ChatbotMessage[];
openPanel: () => void;
closePanel: () => void;
togglePanel: () => void;
selectConversation: (id: string | null) => void;
startNewConversation: () => void;
sendMessage: (text: string, currentContext?: ChatbotCurrentContext) => Promise<void>;
deleteConversation: (id: string) => Promise<void>;
reloadConversations: () => Promise<void>;
}
/**
* Resolver for the current `ChatbotApiClient`. Accepts either a concrete
* client (captured once) or a getter invoked on every call so consumers
* can swap clients over time without recreating the hook.
*/
export type ChatbotApiClientResolver = ChatbotApiClient | (() => ChatbotApiClient);
/**
* Factory that wires the hook to a concrete API client. Returned hook
* owns the chatbot UI state (open/close, messages, conversations).
*
* Implemented as a factory so consumer apps can bind a typed client once
* (usually near composition root) and keep the hook implementation free
* of app-specific transport concerns. The factory also accepts a **getter**
* — pass `() => apiClientRef.current` to let the hook always see the
* latest client even if the parent swaps references between renders.
*/
export declare function createUseChatbot(resolver: ChatbotApiClientResolver): () => UseChatbotReturn;
//# sourceMappingURL=useChatbot.d.ts.map