@elqnt/chat 2.0.8 → 3.0.0
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/README.md +386 -0
- package/dist/api/index.d.mts +250 -8
- package/dist/api/index.d.ts +250 -8
- package/dist/api/index.js +115 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/index.mjs +109 -0
- package/dist/api/index.mjs.map +1 -1
- package/dist/hooks/index.d.mts +78 -0
- package/dist/hooks/index.d.ts +78 -0
- package/dist/hooks/index.js +709 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/index.mjs +683 -0
- package/dist/hooks/index.mjs.map +1 -0
- package/dist/index.d.mts +4 -109
- package/dist/index.d.ts +4 -109
- package/dist/index.js +699 -2039
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +690 -2016
- package/dist/index.mjs.map +1 -1
- package/dist/models/index.d.mts +76 -6
- package/dist/models/index.d.ts +76 -6
- package/dist/models/index.js +21 -0
- package/dist/models/index.js.map +1 -1
- package/dist/models/index.mjs +14 -0
- package/dist/models/index.mjs.map +1 -1
- package/dist/transport/index.d.mts +243 -0
- package/dist/transport/index.d.ts +243 -0
- package/dist/transport/index.js +875 -0
- package/dist/transport/index.js.map +1 -0
- package/dist/transport/index.mjs +843 -0
- package/dist/transport/index.mjs.map +1 -0
- package/dist/types-BB5nRdZs.d.mts +222 -0
- package/dist/types-CNvuxtcv.d.ts +222 -0
- package/package.json +20 -38
- package/dist/hooks/use-websocket-chat-admin.d.mts +0 -17
- package/dist/hooks/use-websocket-chat-admin.d.ts +0 -17
- package/dist/hooks/use-websocket-chat-admin.js +0 -1196
- package/dist/hooks/use-websocket-chat-admin.js.map +0 -1
- package/dist/hooks/use-websocket-chat-admin.mjs +0 -1172
- package/dist/hooks/use-websocket-chat-admin.mjs.map +0 -1
- package/dist/hooks/use-websocket-chat-base.d.mts +0 -81
- package/dist/hooks/use-websocket-chat-base.d.ts +0 -81
- package/dist/hooks/use-websocket-chat-base.js +0 -1025
- package/dist/hooks/use-websocket-chat-base.js.map +0 -1
- package/dist/hooks/use-websocket-chat-base.mjs +0 -1001
- package/dist/hooks/use-websocket-chat-base.mjs.map +0 -1
- package/dist/hooks/use-websocket-chat-customer.d.mts +0 -24
- package/dist/hooks/use-websocket-chat-customer.d.ts +0 -24
- package/dist/hooks/use-websocket-chat-customer.js +0 -1092
- package/dist/hooks/use-websocket-chat-customer.js.map +0 -1
- package/dist/hooks/use-websocket-chat-customer.mjs +0 -1068
- package/dist/hooks/use-websocket-chat-customer.mjs.map +0 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { ChatEvent, Chat, ChatMessage } from '../models/index.mjs';
|
|
2
|
+
import { C as ChatTransport, e as TransportError, g as TransportState, R as RetryConfig, b as ConnectionMetrics, U as Unsubscribe } from '../types-BB5nRdZs.mjs';
|
|
3
|
+
import '@elqnt/types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Chat hook options
|
|
7
|
+
*/
|
|
8
|
+
interface UseChatOptions {
|
|
9
|
+
/** Base URL for the chat server (e.g., "https://api.example.com/chat") */
|
|
10
|
+
baseUrl: string;
|
|
11
|
+
/** Organization ID */
|
|
12
|
+
orgId: string;
|
|
13
|
+
/** User ID */
|
|
14
|
+
userId: string;
|
|
15
|
+
/** Client type for routing */
|
|
16
|
+
clientType?: "customer" | "humanAgent" | "observer";
|
|
17
|
+
/** Transport instance or type */
|
|
18
|
+
transport?: ChatTransport | "sse" | "sse-fetch";
|
|
19
|
+
/** Callback for all incoming events */
|
|
20
|
+
onMessage?: (event: ChatEvent) => void;
|
|
21
|
+
/** Callback for errors */
|
|
22
|
+
onError?: (error: TransportError) => void;
|
|
23
|
+
/** Callback when connection state changes */
|
|
24
|
+
onConnectionChange?: (state: TransportState) => void;
|
|
25
|
+
/** Auto-connect on mount */
|
|
26
|
+
autoConnect?: boolean;
|
|
27
|
+
/** Retry configuration */
|
|
28
|
+
retryConfig?: RetryConfig;
|
|
29
|
+
/** Enable debug logging */
|
|
30
|
+
debug?: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Chat hook return type
|
|
34
|
+
*/
|
|
35
|
+
interface UseChatReturn {
|
|
36
|
+
/** Connect to the chat server */
|
|
37
|
+
connect: () => Promise<void>;
|
|
38
|
+
/** Disconnect from the server */
|
|
39
|
+
disconnect: () => void;
|
|
40
|
+
/** Current connection state */
|
|
41
|
+
connectionState: TransportState;
|
|
42
|
+
/** Whether currently connected */
|
|
43
|
+
isConnected: boolean;
|
|
44
|
+
/** Start a new chat session */
|
|
45
|
+
startChat: (metadata?: Record<string, unknown>) => Promise<string>;
|
|
46
|
+
/** Load an existing chat */
|
|
47
|
+
loadChat: (chatKey: string) => Promise<void>;
|
|
48
|
+
/** Send a text message */
|
|
49
|
+
sendMessage: (content: string, attachments?: unknown[]) => Promise<void>;
|
|
50
|
+
/** End the current chat */
|
|
51
|
+
endChat: (reason?: string) => Promise<void>;
|
|
52
|
+
/** Signal that user is typing */
|
|
53
|
+
startTyping: () => void;
|
|
54
|
+
/** Signal that user stopped typing */
|
|
55
|
+
stopTyping: () => void;
|
|
56
|
+
/** Current chat object */
|
|
57
|
+
currentChat: Chat | null;
|
|
58
|
+
/** Current chat key */
|
|
59
|
+
chatKey: string | null;
|
|
60
|
+
/** Chat messages */
|
|
61
|
+
messages: ChatMessage[];
|
|
62
|
+
/** Current error */
|
|
63
|
+
error: TransportError | null;
|
|
64
|
+
/** Connection metrics */
|
|
65
|
+
metrics: ConnectionMetrics;
|
|
66
|
+
/** Subscribe to specific event type */
|
|
67
|
+
on: (eventType: string, handler: (event: ChatEvent) => void) => Unsubscribe;
|
|
68
|
+
/** Clear current error */
|
|
69
|
+
clearError: () => void;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* useChat Hook
|
|
73
|
+
*
|
|
74
|
+
* Platform-agnostic chat hook with SSE transport support.
|
|
75
|
+
*/
|
|
76
|
+
declare function useChat(options: UseChatOptions): UseChatReturn;
|
|
77
|
+
|
|
78
|
+
export { type UseChatOptions, type UseChatReturn, useChat };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { ChatEvent, Chat, ChatMessage } from '../models/index.js';
|
|
2
|
+
import { C as ChatTransport, e as TransportError, g as TransportState, R as RetryConfig, b as ConnectionMetrics, U as Unsubscribe } from '../types-CNvuxtcv.js';
|
|
3
|
+
import '@elqnt/types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Chat hook options
|
|
7
|
+
*/
|
|
8
|
+
interface UseChatOptions {
|
|
9
|
+
/** Base URL for the chat server (e.g., "https://api.example.com/chat") */
|
|
10
|
+
baseUrl: string;
|
|
11
|
+
/** Organization ID */
|
|
12
|
+
orgId: string;
|
|
13
|
+
/** User ID */
|
|
14
|
+
userId: string;
|
|
15
|
+
/** Client type for routing */
|
|
16
|
+
clientType?: "customer" | "humanAgent" | "observer";
|
|
17
|
+
/** Transport instance or type */
|
|
18
|
+
transport?: ChatTransport | "sse" | "sse-fetch";
|
|
19
|
+
/** Callback for all incoming events */
|
|
20
|
+
onMessage?: (event: ChatEvent) => void;
|
|
21
|
+
/** Callback for errors */
|
|
22
|
+
onError?: (error: TransportError) => void;
|
|
23
|
+
/** Callback when connection state changes */
|
|
24
|
+
onConnectionChange?: (state: TransportState) => void;
|
|
25
|
+
/** Auto-connect on mount */
|
|
26
|
+
autoConnect?: boolean;
|
|
27
|
+
/** Retry configuration */
|
|
28
|
+
retryConfig?: RetryConfig;
|
|
29
|
+
/** Enable debug logging */
|
|
30
|
+
debug?: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Chat hook return type
|
|
34
|
+
*/
|
|
35
|
+
interface UseChatReturn {
|
|
36
|
+
/** Connect to the chat server */
|
|
37
|
+
connect: () => Promise<void>;
|
|
38
|
+
/** Disconnect from the server */
|
|
39
|
+
disconnect: () => void;
|
|
40
|
+
/** Current connection state */
|
|
41
|
+
connectionState: TransportState;
|
|
42
|
+
/** Whether currently connected */
|
|
43
|
+
isConnected: boolean;
|
|
44
|
+
/** Start a new chat session */
|
|
45
|
+
startChat: (metadata?: Record<string, unknown>) => Promise<string>;
|
|
46
|
+
/** Load an existing chat */
|
|
47
|
+
loadChat: (chatKey: string) => Promise<void>;
|
|
48
|
+
/** Send a text message */
|
|
49
|
+
sendMessage: (content: string, attachments?: unknown[]) => Promise<void>;
|
|
50
|
+
/** End the current chat */
|
|
51
|
+
endChat: (reason?: string) => Promise<void>;
|
|
52
|
+
/** Signal that user is typing */
|
|
53
|
+
startTyping: () => void;
|
|
54
|
+
/** Signal that user stopped typing */
|
|
55
|
+
stopTyping: () => void;
|
|
56
|
+
/** Current chat object */
|
|
57
|
+
currentChat: Chat | null;
|
|
58
|
+
/** Current chat key */
|
|
59
|
+
chatKey: string | null;
|
|
60
|
+
/** Chat messages */
|
|
61
|
+
messages: ChatMessage[];
|
|
62
|
+
/** Current error */
|
|
63
|
+
error: TransportError | null;
|
|
64
|
+
/** Connection metrics */
|
|
65
|
+
metrics: ConnectionMetrics;
|
|
66
|
+
/** Subscribe to specific event type */
|
|
67
|
+
on: (eventType: string, handler: (event: ChatEvent) => void) => Unsubscribe;
|
|
68
|
+
/** Clear current error */
|
|
69
|
+
clearError: () => void;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* useChat Hook
|
|
73
|
+
*
|
|
74
|
+
* Platform-agnostic chat hook with SSE transport support.
|
|
75
|
+
*/
|
|
76
|
+
declare function useChat(options: UseChatOptions): UseChatReturn;
|
|
77
|
+
|
|
78
|
+
export { type UseChatOptions, type UseChatReturn, useChat };
|