@iai-lib/any-chat-widget 0.1.0-alpha.6 → 0.1.0-alpha.61
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/any-chat-widget.es.js +2 -6025
- package/dist/any-chat-widget.umd.js +1127 -165
- package/dist/browser-BnZrIpUb.js +28883 -0
- package/dist/main-cD9cg5Yl.js +16654 -0
- package/dist/types/components/contactForm.d.ts +19 -0
- package/dist/types/components/transferConfirmation.d.ts +8 -0
- package/dist/types/main.d.ts +1 -1
- package/dist/types/modules/five9/five9.ws.d.ts +4 -4
- package/dist/types/modules/five9/five9Manager.d.ts +6 -5
- package/dist/types/modules/iaiChatWidget/enhancedContentHandlers/photoViewer.d.ts +4 -0
- package/dist/types/modules/iaiChatWidget/enhancedContentHandlers/unitList.d.ts +4 -0
- package/dist/types/modules/iaiChatWidget/functionCallHandlers/tourScheduler.d.ts +3 -2
- package/dist/types/modules/iaiChatWidget/functionCallHandlers/transferToLiveAgent.d.ts +5 -4
- package/dist/types/modules/iaiChatWidget/functionCallHandlers/transferToTwilio.d.ts +8 -0
- package/dist/types/modules/iaiChatWidget/iaiChatWidget.d.ts +7 -3
- package/dist/types/modules/twilio/twilio.types.d.ts +326 -0
- package/dist/types/modules/twilio/twilioManager.d.ts +247 -0
- package/dist/types/types/sdk.d.ts +1 -2
- package/dist/types/types/vite-env.d.ts +11 -1
- package/package.json +18 -7
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { TwilioTypes } from './twilio.types';
|
|
2
|
+
import { Client as TwilioClient, Conversation as TwilioConversation } from '@twilio/conversations';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Main manager class for Twilio Conversations
|
|
6
|
+
*
|
|
7
|
+
* Provides a high-level API for chat functionality that mirrors Five9Manager
|
|
8
|
+
*/
|
|
9
|
+
export declare class TwilioManager {
|
|
10
|
+
/**
|
|
11
|
+
* Event emitter for manager events
|
|
12
|
+
*/
|
|
13
|
+
private readonly _emitter;
|
|
14
|
+
/**
|
|
15
|
+
* Public event listener registration
|
|
16
|
+
*/
|
|
17
|
+
readonly on: {
|
|
18
|
+
<Key extends string | number | symbol>(type: Key, handler: import('mitt').Handler<any>): void;
|
|
19
|
+
(type: "*", handler: import('mitt').WildcardHandler<any>): void;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Public event listener removal
|
|
23
|
+
*/
|
|
24
|
+
readonly off: {
|
|
25
|
+
<Key extends string | number | symbol>(type: Key, handler?: import('mitt').Handler<any> | undefined): void;
|
|
26
|
+
(type: "*", handler: import('mitt').WildcardHandler<any>): void;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Twilio Conversations client instance
|
|
30
|
+
*/
|
|
31
|
+
private client;
|
|
32
|
+
/**
|
|
33
|
+
* Current active conversation
|
|
34
|
+
*/
|
|
35
|
+
private conversation;
|
|
36
|
+
/**
|
|
37
|
+
* Current access token
|
|
38
|
+
*/
|
|
39
|
+
private accessToken;
|
|
40
|
+
/**
|
|
41
|
+
* User identity
|
|
42
|
+
*/
|
|
43
|
+
private identity;
|
|
44
|
+
/**
|
|
45
|
+
* Current conversation SID
|
|
46
|
+
*/
|
|
47
|
+
private conversationSid;
|
|
48
|
+
/**
|
|
49
|
+
* Flag indicating if conversation has started
|
|
50
|
+
*/
|
|
51
|
+
conversationStarted: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Current connection state
|
|
54
|
+
*/
|
|
55
|
+
private connectionState;
|
|
56
|
+
/**
|
|
57
|
+
* Current conversation status
|
|
58
|
+
*/
|
|
59
|
+
private conversationStatus;
|
|
60
|
+
/**
|
|
61
|
+
* Configuration
|
|
62
|
+
*/
|
|
63
|
+
private config;
|
|
64
|
+
/**
|
|
65
|
+
* Token refresh URL
|
|
66
|
+
*/
|
|
67
|
+
private tokenRefreshUrl?;
|
|
68
|
+
/**
|
|
69
|
+
* Token refresh timeout handle
|
|
70
|
+
*/
|
|
71
|
+
private tokenRefreshTimeout?;
|
|
72
|
+
/**
|
|
73
|
+
* Message queue for offline scenarios
|
|
74
|
+
*/
|
|
75
|
+
private messageQueue;
|
|
76
|
+
/**
|
|
77
|
+
* Typing timeout handle
|
|
78
|
+
*/
|
|
79
|
+
private typingTimeout?;
|
|
80
|
+
/**
|
|
81
|
+
* Serializes the manager state for persistence
|
|
82
|
+
*
|
|
83
|
+
* @returns Serialized state as JSON string
|
|
84
|
+
*/
|
|
85
|
+
serialize(): string;
|
|
86
|
+
/**
|
|
87
|
+
* Deserializes and restores manager state
|
|
88
|
+
*
|
|
89
|
+
* @param rawData - Serialized state JSON string
|
|
90
|
+
* @returns Restored TwilioManager instance
|
|
91
|
+
*/
|
|
92
|
+
static deserialize(rawData: string): TwilioManager;
|
|
93
|
+
/**
|
|
94
|
+
* Sets up event listeners for the Twilio client
|
|
95
|
+
*/
|
|
96
|
+
private setupClientListeners;
|
|
97
|
+
/**
|
|
98
|
+
* Initializes the Twilio Conversations client
|
|
99
|
+
*
|
|
100
|
+
* @param config - Twilio configuration
|
|
101
|
+
* @throws Error if initialization fails
|
|
102
|
+
*/
|
|
103
|
+
initialize(config: TwilioTypes.TwilioConfig): Promise<void>;
|
|
104
|
+
/**
|
|
105
|
+
* Waits for the Twilio client to be ready
|
|
106
|
+
*/
|
|
107
|
+
private waitForClientReady;
|
|
108
|
+
/**
|
|
109
|
+
* Maps Twilio SDK connection state to our ConnectionState enum
|
|
110
|
+
*
|
|
111
|
+
* @param state - Twilio SDK state string
|
|
112
|
+
* @returns Mapped ConnectionState
|
|
113
|
+
*/
|
|
114
|
+
private mapConnectionState;
|
|
115
|
+
/**
|
|
116
|
+
* Refreshes the access token
|
|
117
|
+
*
|
|
118
|
+
* @throws Error if token refresh fails
|
|
119
|
+
*/
|
|
120
|
+
private refreshToken;
|
|
121
|
+
/**
|
|
122
|
+
* Creates a new conversation
|
|
123
|
+
*
|
|
124
|
+
* @param params - Conversation parameters
|
|
125
|
+
* @returns Conversation information
|
|
126
|
+
* @throws Error if conversation creation fails
|
|
127
|
+
*/
|
|
128
|
+
createConversation(params: TwilioTypes.ConversationParams): Promise<TwilioTypes.ConversationInfo>;
|
|
129
|
+
/**
|
|
130
|
+
* Joins an existing conversation
|
|
131
|
+
*
|
|
132
|
+
* @param conversationSid - Conversation SID to join
|
|
133
|
+
*/
|
|
134
|
+
private joinConversation;
|
|
135
|
+
/**
|
|
136
|
+
* Initializes a conversation (mirrors Five9Manager API)
|
|
137
|
+
*
|
|
138
|
+
* This method provides compatibility with Five9Manager's API
|
|
139
|
+
*
|
|
140
|
+
* @param params - Conversation parameters
|
|
141
|
+
* @returns Conversation information
|
|
142
|
+
*/
|
|
143
|
+
initializeConversation(params: TwilioTypes.ConversationParams): Promise<TwilioTypes.ConversationInfo>;
|
|
144
|
+
/**
|
|
145
|
+
* Sets up event listeners for a conversation
|
|
146
|
+
*
|
|
147
|
+
* @param conversation - Twilio Conversation instance
|
|
148
|
+
*/
|
|
149
|
+
private setupConversationListeners;
|
|
150
|
+
/**
|
|
151
|
+
* Sends a message to the current conversation
|
|
152
|
+
*
|
|
153
|
+
* @param content - Message text content or options object
|
|
154
|
+
* @param attributes - Optional message attributes for Twilio Flex/Studio Flow context
|
|
155
|
+
* @throws Error if conversation is not started or message sending fails
|
|
156
|
+
*/
|
|
157
|
+
sendMessage(content: string | {
|
|
158
|
+
body: string;
|
|
159
|
+
attributes?: Record<string, any>;
|
|
160
|
+
}, attributes?: Record<string, any>): Promise<void>;
|
|
161
|
+
/**
|
|
162
|
+
* Sends typing indicator to the conversation
|
|
163
|
+
*
|
|
164
|
+
* @throws Error if conversation is not started
|
|
165
|
+
*/
|
|
166
|
+
sendTyping(): Promise<void>;
|
|
167
|
+
/**
|
|
168
|
+
* Acknowledges/marks messages as read
|
|
169
|
+
*
|
|
170
|
+
* @param messageId - Message index or SID to acknowledge
|
|
171
|
+
* @throws Error if conversation is not started
|
|
172
|
+
*/
|
|
173
|
+
acknowledgeMessage(messageId: string): Promise<void>;
|
|
174
|
+
/**
|
|
175
|
+
* Processes queued messages after reconnection
|
|
176
|
+
*/
|
|
177
|
+
private processMessageQueue;
|
|
178
|
+
/**
|
|
179
|
+
* Terminates the current conversation
|
|
180
|
+
*
|
|
181
|
+
* @throws Error if conversation is not started
|
|
182
|
+
*/
|
|
183
|
+
terminateConversation(): Promise<void>;
|
|
184
|
+
/**
|
|
185
|
+
* Connects to Twilio (mirrors Five9Manager API)
|
|
186
|
+
*/
|
|
187
|
+
connect(): Promise<void>;
|
|
188
|
+
/**
|
|
189
|
+
* Reconnects the client after disconnection
|
|
190
|
+
*/
|
|
191
|
+
private reconnectClient;
|
|
192
|
+
/**
|
|
193
|
+
* Disconnects from Twilio
|
|
194
|
+
*/
|
|
195
|
+
disconnect(): Promise<void>;
|
|
196
|
+
/**
|
|
197
|
+
* Manually triggers reconnection
|
|
198
|
+
*/
|
|
199
|
+
reconnect(): Promise<void>;
|
|
200
|
+
/**
|
|
201
|
+
* Destroys the manager and cleans up all resources
|
|
202
|
+
*/
|
|
203
|
+
destroy(): void;
|
|
204
|
+
/**
|
|
205
|
+
* Handles errors and emits error events
|
|
206
|
+
*
|
|
207
|
+
* @param message - Error message
|
|
208
|
+
* @param error - Error object
|
|
209
|
+
*/
|
|
210
|
+
private handleError;
|
|
211
|
+
/**
|
|
212
|
+
* Gets the current access token
|
|
213
|
+
*/
|
|
214
|
+
get token(): string | null;
|
|
215
|
+
/**
|
|
216
|
+
* Gets the user identity
|
|
217
|
+
*/
|
|
218
|
+
get userIdentity(): string | null;
|
|
219
|
+
/**
|
|
220
|
+
* Gets the current conversation SID
|
|
221
|
+
*/
|
|
222
|
+
get currentConversationSid(): string | null;
|
|
223
|
+
/**
|
|
224
|
+
* Gets the current connection status
|
|
225
|
+
*/
|
|
226
|
+
getConnectionStatus(): TwilioTypes.ConnectionState;
|
|
227
|
+
/**
|
|
228
|
+
* Gets the current conversation state
|
|
229
|
+
*/
|
|
230
|
+
getConversationState(): TwilioTypes.ConversationStatus;
|
|
231
|
+
/**
|
|
232
|
+
* Checks if currently connected
|
|
233
|
+
*/
|
|
234
|
+
isConnected(): boolean;
|
|
235
|
+
/**
|
|
236
|
+
* Gets the Twilio client instance (for advanced usage)
|
|
237
|
+
*/
|
|
238
|
+
getClient(): TwilioClient | null;
|
|
239
|
+
/**
|
|
240
|
+
* Gets the current conversation instance (for advanced usage)
|
|
241
|
+
*/
|
|
242
|
+
getConversation(): TwilioConversation | null;
|
|
243
|
+
/**
|
|
244
|
+
* Gets the current state for serialization/persistence
|
|
245
|
+
*/
|
|
246
|
+
getState(): Record<string, any>;
|
|
247
|
+
}
|
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
interface ImportMeta {
|
|
2
|
-
env:
|
|
2
|
+
env: {
|
|
3
|
+
// Chat system selection
|
|
4
|
+
VITE_ENABLE_TWILIO_CHAT?: string;
|
|
5
|
+
|
|
6
|
+
// Twilio configuration
|
|
7
|
+
VITE_FIVE9_BACKEND_URL?: string;
|
|
8
|
+
VITE_TWILIO_STUDIO_FLOW_SID?: string;
|
|
9
|
+
|
|
10
|
+
// Generic catch-all for other env vars
|
|
11
|
+
[key: string]: string | undefined;
|
|
12
|
+
};
|
|
3
13
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iai-lib/any-chat-widget",
|
|
3
3
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
4
|
-
"version": "0.1.0-alpha.
|
|
4
|
+
"version": "0.1.0-alpha.61",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -9,10 +9,9 @@
|
|
|
9
9
|
"scripts": {
|
|
10
10
|
"dev": "vite",
|
|
11
11
|
"dev:build": "vite build --watch",
|
|
12
|
-
"dev:build:delayed": "delay 10 && yarn dev:build",
|
|
13
12
|
"build": "vite build",
|
|
14
|
-
"lint": "eslint
|
|
15
|
-
"lint:fix": "
|
|
13
|
+
"lint": "eslint . --ignore-path .gitignore",
|
|
14
|
+
"lint:fix": "yarn lint --fix"
|
|
16
15
|
},
|
|
17
16
|
"main": "./dist/any-chat-widget.umd.js",
|
|
18
17
|
"module": "./dist/any-chat-widget.es.js",
|
|
@@ -27,15 +26,27 @@
|
|
|
27
26
|
"dist"
|
|
28
27
|
],
|
|
29
28
|
"devDependencies": {
|
|
29
|
+
"autoprefixer": "^10.4.17",
|
|
30
30
|
"delay-cli": "^2.0.0",
|
|
31
|
+
"postcss": "^8.4.35",
|
|
32
|
+
"rollup-plugin-visualizer": "^5.12.0",
|
|
33
|
+
"tailwindcss": "^3.4.1",
|
|
31
34
|
"typescript": "^5.3.3",
|
|
32
35
|
"vite": "^5.1.0",
|
|
33
36
|
"vite-plugin-dts": "^3.7.2",
|
|
37
|
+
"vite-plugin-lit-css": "^1.0.2",
|
|
34
38
|
"vite-plugin-static-copy": "^1.0.1"
|
|
35
39
|
},
|
|
36
40
|
"dependencies": {
|
|
37
|
-
"@iai-lib/chat-widget": "^1.0.0-alpha.
|
|
38
|
-
"
|
|
41
|
+
"@iai-lib/chat-widget": "^1.0.0-alpha.51",
|
|
42
|
+
"@iai-lib/sdk": "^1.0.0-alpha.32",
|
|
43
|
+
"@twilio/conversations": "^2.6.5",
|
|
44
|
+
"cleave.js": "^1.6.0",
|
|
45
|
+
"dayjs": "^1.11.11",
|
|
46
|
+
"lit": "^3.1.3",
|
|
47
|
+
"lit-html": "^3.1.3",
|
|
48
|
+
"mitt": "^3.0.1",
|
|
49
|
+
"zod": "^3.23.8"
|
|
39
50
|
},
|
|
40
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "c8efef205949283fd80346c6f1cfc494b5391907"
|
|
41
52
|
}
|