@eloquentai/chat-sdk 0.26.1-dev → 0.27.0-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/chat/chat.hook.d.ts +2 -2
- package/dist/components/chat/message-events.hook.d.ts +9 -9
- package/dist/components/chat/persistence.hook.d.ts +5 -5
- package/dist/components/chat/realtime-socket.hook.d.ts +21 -0
- package/dist/components/chat/sdk-initialization.hook.d.ts +1 -1
- package/dist/components/chat/validations.d.ts +6 -6
- package/dist/components/chat-interface/index.d.ts +2 -2
- package/dist/components/index.d.ts +4 -1
- package/dist/{index-C0lXr3_t.js → index-BNfbku_H.js} +2 -2
- package/dist/{index-C0lXr3_t.js.map → index-BNfbku_H.js.map} +1 -1
- package/dist/{index-Dqos2v0b.js → index-E1fBXAzl.js} +3272 -3381
- package/dist/index-E1fBXAzl.js.map +1 -0
- package/dist/index.mjs +6 -5
- package/package.json +1 -1
- package/dist/components/chat/background-poller.hook.d.ts +0 -20
- package/dist/components/chat/background-poller.hook.test.d.ts +0 -1
- package/dist/components/chat/real-time-events.hook.d.ts +0 -16
- package/dist/index-Dqos2v0b.js.map +0 -1
|
@@ -31,8 +31,8 @@ export interface UseChatReturn {
|
|
|
31
31
|
autoHideDelay: number;
|
|
32
32
|
};
|
|
33
33
|
hideProactiveMessage: () => void;
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
isChatClosed: boolean;
|
|
35
|
+
onStartNewChat: () => void;
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
38
|
* The primary chat hook, responsible for managing the chat state and operations.
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { Message, MessageData } from '../../type';
|
|
3
3
|
import { BootResponse, EloquentAiApiClient } from '../../lib/eloquent-ai-api-client';
|
|
4
|
-
export interface Conversation {
|
|
5
|
-
id: string;
|
|
6
|
-
}
|
|
7
4
|
export interface UseMessageEventsProps {
|
|
8
5
|
appId: string;
|
|
9
6
|
userId: string;
|
|
@@ -15,11 +12,14 @@ export interface UseMessageEventsProps {
|
|
|
15
12
|
chatSettings: BootResponse["chat_settings"] | null;
|
|
16
13
|
messages: Message[];
|
|
17
14
|
setMessages: React.Dispatch<React.SetStateAction<Message[]>>;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
currentChat: {
|
|
16
|
+
id: string;
|
|
17
|
+
} | null;
|
|
18
|
+
setCurrentChat: React.Dispatch<React.SetStateAction<{
|
|
19
|
+
id: string;
|
|
20
|
+
} | null>>;
|
|
21
|
+
onChatClosed?: () => void;
|
|
22
|
+
isChatClosed?: boolean;
|
|
23
23
|
}
|
|
24
24
|
export interface UseMessageEventsReturn {
|
|
25
25
|
onCleanMessages: () => void;
|
|
@@ -28,4 +28,4 @@ export interface UseMessageEventsReturn {
|
|
|
28
28
|
/**
|
|
29
29
|
* Hook to handle message events like sending and cleaning
|
|
30
30
|
*/
|
|
31
|
-
export declare function useMessageEvents({ appId, userId, userName, userData, externalId, deviceId, apiClient, chatSettings, messages, setMessages,
|
|
31
|
+
export declare function useMessageEvents({ appId, userId, userName, userData, externalId, deviceId, apiClient, chatSettings, messages, setMessages, currentChat, setCurrentChat, onChatClosed, isChatClosed, }: UseMessageEventsProps): UseMessageEventsReturn;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Message } from '../../type';
|
|
2
|
-
export interface
|
|
2
|
+
export interface ChatData {
|
|
3
3
|
conversationId: string | null;
|
|
4
4
|
userId: string | null;
|
|
5
5
|
externalId?: string | null;
|
|
@@ -14,9 +14,9 @@ export interface ConversationData {
|
|
|
14
14
|
export declare function usePersistence({ appId }: {
|
|
15
15
|
appId: string;
|
|
16
16
|
}): {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
isChatExpired: () => boolean;
|
|
18
|
+
saveChatData: (conversationId: string, userId: string, messages: Message[], deviceId: string) => void;
|
|
19
|
+
clearChatData: () => void;
|
|
20
|
+
getSavedChatData: () => ChatData;
|
|
21
21
|
updateLastActivity: () => void;
|
|
22
22
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BootResponse, MessageResponse } from '../../lib/eloquent-ai-api-client';
|
|
2
|
+
import { Message } from '../../type';
|
|
3
|
+
import { ChatResponse } from './validations';
|
|
4
|
+
export type UseRealtimeSocketOptions = {
|
|
5
|
+
chatSettings: BootResponse["chat_settings"] | null;
|
|
6
|
+
chatId: string | null;
|
|
7
|
+
messages: Message[];
|
|
8
|
+
onMessage: (response: ChatResponse, chatId: string) => void;
|
|
9
|
+
onCognition: (content: string) => void;
|
|
10
|
+
onCognitionComplete: () => void;
|
|
11
|
+
onError?: () => void;
|
|
12
|
+
onChatClosed?: () => void;
|
|
13
|
+
fetchHistory: (chatId: string) => Promise<MessageResponse[]>;
|
|
14
|
+
backupPollingInterval?: number;
|
|
15
|
+
};
|
|
16
|
+
export type UseRealtimeSocketReturn = {
|
|
17
|
+
connect: (chatId: string) => Promise<void>;
|
|
18
|
+
disconnect: () => void;
|
|
19
|
+
clearProcessedIds: () => void;
|
|
20
|
+
};
|
|
21
|
+
export declare function useRealtimeSocket({ chatSettings, chatId, messages, onMessage, onCognition, onCognitionComplete, onError, onChatClosed, fetchHistory, backupPollingInterval, }: UseRealtimeSocketOptions): UseRealtimeSocketReturn;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const chatResponseApiSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
3
3
|
message_id: z.ZodNullable<z.ZodString>;
|
|
4
4
|
created_at: z.ZodString;
|
|
5
5
|
data: z.ZodObject<{
|
|
@@ -27,10 +27,10 @@ export declare const conversationResponseApiSchema: z.ZodUnion<readonly [z.ZodOb
|
|
|
27
27
|
content: z.ZodString;
|
|
28
28
|
}, z.core.$strip>;
|
|
29
29
|
}, z.core.$strip>]>;
|
|
30
|
-
export type
|
|
31
|
-
type NotificationData =
|
|
30
|
+
export type ChatResponseApi = z.infer<typeof chatResponseApiSchema>;
|
|
31
|
+
type NotificationData = ChatResponseApi["data"];
|
|
32
32
|
export type UtteranceNotification = {
|
|
33
|
-
message_id: string;
|
|
33
|
+
message_id: string | null;
|
|
34
34
|
created_at: string;
|
|
35
35
|
data: Extract<NotificationData, {
|
|
36
36
|
type: "utterance";
|
|
@@ -55,7 +55,7 @@ export type ChatClosedExpiredNotification = {
|
|
|
55
55
|
type: "chat_closed_expired";
|
|
56
56
|
}>;
|
|
57
57
|
};
|
|
58
|
-
export declare const
|
|
58
|
+
export declare const chatResponseSchema: z.ZodObject<{
|
|
59
59
|
message_id: z.ZodString;
|
|
60
60
|
response: z.ZodObject<{
|
|
61
61
|
id: z.ZodString;
|
|
@@ -63,5 +63,5 @@ export declare const conversationResponseSchema: z.ZodObject<{
|
|
|
63
63
|
content: z.ZodString;
|
|
64
64
|
}, z.core.$strip>;
|
|
65
65
|
}, z.core.$strip>;
|
|
66
|
-
export type
|
|
66
|
+
export type ChatResponse = z.infer<typeof chatResponseSchema>;
|
|
67
67
|
export {};
|
|
@@ -19,7 +19,7 @@ export interface ChatInterfaceProps {
|
|
|
19
19
|
onMessageClick?: (message: MessageData) => void;
|
|
20
20
|
onClose?: () => void;
|
|
21
21
|
onCleanChat?: () => void;
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
isChatClosed?: boolean;
|
|
23
|
+
onStartNewChat?: () => void;
|
|
24
24
|
}
|
|
25
25
|
export declare function ChatInterface(props: ChatInterfaceProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { Chat, ChatProps } from './chat';
|
|
2
2
|
import { renderChat } from './render-chat';
|
|
3
3
|
import { ChatInterface, ChatInterfaceProps } from './chat-interface';
|
|
4
|
-
|
|
4
|
+
import { useRealtimeSocket, UseRealtimeSocketOptions, UseRealtimeSocketReturn } from './chat/realtime-socket.hook';
|
|
5
|
+
import { ChatResponse } from './chat/validations';
|
|
6
|
+
import { BootResponse, MessageResponse } from '../lib/eloquent-ai-api-client';
|
|
7
|
+
export { Chat, type ChatProps, ChatInterface, type ChatInterfaceProps, renderChat, useRealtimeSocket, type UseRealtimeSocketOptions, type UseRealtimeSocketReturn, type ChatResponse, type BootResponse, type MessageResponse, };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Oe from "react";
|
|
2
2
|
import { version as Zu } from "react";
|
|
3
|
-
import { g as Rp } from "./index-
|
|
3
|
+
import { g as Rp } from "./index-E1fBXAzl.js";
|
|
4
4
|
try {
|
|
5
5
|
let e = typeof window < "u" ? window : typeof global < "u" ? global : typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : {}, t = new e.Error().stack;
|
|
6
6
|
t && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[t] = "e912b1ab-8839-4e6c-90b8-c20d1854ba0f", e._sentryDebugIdIdentifier = "sentry-dbid-e912b1ab-8839-4e6c-90b8-c20d1854ba0f");
|
|
@@ -18790,4 +18790,4 @@ export {
|
|
|
18790
18790
|
iR as wrapUseRoutesV7,
|
|
18791
18791
|
ik as zodErrorsIntegration
|
|
18792
18792
|
};
|
|
18793
|
-
//# sourceMappingURL=index-
|
|
18793
|
+
//# sourceMappingURL=index-BNfbku_H.js.map
|