@ujet/websdk-headless 3.0.3
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 +757 -0
- package/dist/index.cjs +563 -0
- package/dist/index.d.ts +409 -0
- package/dist/index.js +41274 -0
- package/package.json +24 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v8.0.1
|
|
2
|
+
|
|
3
|
+
export interface RequestReturn {
|
|
4
|
+
headers: Record<string, string>;
|
|
5
|
+
data: any;
|
|
6
|
+
}
|
|
7
|
+
export interface LogData {
|
|
8
|
+
loglevel: string;
|
|
9
|
+
timestamp: string;
|
|
10
|
+
application: string;
|
|
11
|
+
version: string;
|
|
12
|
+
device: string;
|
|
13
|
+
tenant: string;
|
|
14
|
+
company_id: string;
|
|
15
|
+
location_url: string;
|
|
16
|
+
channel: string;
|
|
17
|
+
message: string;
|
|
18
|
+
data: any;
|
|
19
|
+
tracker_id?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface MessageRequest {
|
|
22
|
+
type: string;
|
|
23
|
+
content?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface ChatRequest {
|
|
26
|
+
lang?: string;
|
|
27
|
+
trigger_id?: string;
|
|
28
|
+
ticket_id?: string;
|
|
29
|
+
email?: string;
|
|
30
|
+
greeting?: string;
|
|
31
|
+
cobrowsable?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface EscalateRequest {
|
|
34
|
+
force_escalate: boolean;
|
|
35
|
+
menu_id: number;
|
|
36
|
+
lang: string;
|
|
37
|
+
}
|
|
38
|
+
export interface RateRequest {
|
|
39
|
+
rating: number;
|
|
40
|
+
feedback: string;
|
|
41
|
+
}
|
|
42
|
+
export interface SurveyAnswers {
|
|
43
|
+
[id: string]: number | string;
|
|
44
|
+
}
|
|
45
|
+
export interface CallRequest {
|
|
46
|
+
phone_number: string;
|
|
47
|
+
lang?: string;
|
|
48
|
+
scheduled_at?: string;
|
|
49
|
+
ticket_id?: string;
|
|
50
|
+
email?: string;
|
|
51
|
+
recording_permission?: boolean;
|
|
52
|
+
}
|
|
53
|
+
export interface EmailRequest {
|
|
54
|
+
name?: string;
|
|
55
|
+
email: string;
|
|
56
|
+
content: string;
|
|
57
|
+
lang?: string;
|
|
58
|
+
files?: File[];
|
|
59
|
+
recaptcha?: string;
|
|
60
|
+
}
|
|
61
|
+
export type RequestMethod = (url: string, options: RequestInit | Record<string, any>) => Promise<RequestReturn>;
|
|
62
|
+
export type EventHandler = (data: any) => void;
|
|
63
|
+
export type IssueChatTokenMethod = () => Promise<{
|
|
64
|
+
identity: string;
|
|
65
|
+
token: string;
|
|
66
|
+
}>;
|
|
67
|
+
export type ProgressMethod = (loaded: number) => void;
|
|
68
|
+
export type LoggerHandler = (channel: string, level: string, ...args: any[]) => void;
|
|
69
|
+
export interface TokenResponse {
|
|
70
|
+
token: string;
|
|
71
|
+
}
|
|
72
|
+
export interface ClientOption {
|
|
73
|
+
companyId: string;
|
|
74
|
+
authenticate: () => Promise<TokenResponse>;
|
|
75
|
+
tenant?: string;
|
|
76
|
+
host?: string;
|
|
77
|
+
lang?: string;
|
|
78
|
+
bridge?: string;
|
|
79
|
+
cobrowse?: {
|
|
80
|
+
enabled: boolean;
|
|
81
|
+
messages?: CobrowseMessages;
|
|
82
|
+
api?: string;
|
|
83
|
+
license?: string;
|
|
84
|
+
trustedOrigins?: string[];
|
|
85
|
+
capabilities?: string[];
|
|
86
|
+
registration?: boolean;
|
|
87
|
+
redactedViews?: string[];
|
|
88
|
+
unredactedViews?: string[];
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
export interface CobrowseMessages {
|
|
92
|
+
confirmSessionTitle: string;
|
|
93
|
+
confirmSessionContent: string;
|
|
94
|
+
confirmRemoteControlTitle: string;
|
|
95
|
+
confirmRemoteControlContent: string;
|
|
96
|
+
confirmFullDeviceTitle: string;
|
|
97
|
+
confirmFullDeviceContent: string;
|
|
98
|
+
allowText: string;
|
|
99
|
+
denyText: string;
|
|
100
|
+
endSessionText: string;
|
|
101
|
+
}
|
|
102
|
+
export interface CobrowseOption {
|
|
103
|
+
lang: string;
|
|
104
|
+
messages: CobrowseMessages;
|
|
105
|
+
enabled?: boolean;
|
|
106
|
+
api?: string;
|
|
107
|
+
license?: string;
|
|
108
|
+
trustedOrigins?: string[];
|
|
109
|
+
capabilities?: string[];
|
|
110
|
+
registration?: boolean;
|
|
111
|
+
redactedViews?: string[];
|
|
112
|
+
unredactedViews?: string[];
|
|
113
|
+
}
|
|
114
|
+
export interface LanguageOption {
|
|
115
|
+
lang: string;
|
|
116
|
+
name: string;
|
|
117
|
+
localeName?: string;
|
|
118
|
+
}
|
|
119
|
+
export interface CompanyResponse {
|
|
120
|
+
name: string;
|
|
121
|
+
subdomain: string;
|
|
122
|
+
support_email: string;
|
|
123
|
+
languages: LanguageOption[];
|
|
124
|
+
action_tracking: boolean;
|
|
125
|
+
email_transcripts: boolean;
|
|
126
|
+
message_preview: boolean;
|
|
127
|
+
email_enhancement: boolean;
|
|
128
|
+
}
|
|
129
|
+
export interface MenuChannel {
|
|
130
|
+
enabled: boolean;
|
|
131
|
+
type: string;
|
|
132
|
+
[key: string]: unknown;
|
|
133
|
+
}
|
|
134
|
+
export interface MenuItem {
|
|
135
|
+
id: number;
|
|
136
|
+
name?: string;
|
|
137
|
+
enabled: boolean;
|
|
138
|
+
redirection?: {
|
|
139
|
+
option: string;
|
|
140
|
+
data: string;
|
|
141
|
+
};
|
|
142
|
+
children?: MenuItem[];
|
|
143
|
+
channels: MenuChannel[];
|
|
144
|
+
deflection?: {
|
|
145
|
+
enabled: boolean;
|
|
146
|
+
type: string;
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
export interface MenuResponse {
|
|
150
|
+
menus: MenuItem[];
|
|
151
|
+
direct: {
|
|
152
|
+
key: boolean;
|
|
153
|
+
user: boolean;
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
export interface HumanAgent {
|
|
157
|
+
id: number;
|
|
158
|
+
name: string;
|
|
159
|
+
avatar_url: string;
|
|
160
|
+
first_name: string;
|
|
161
|
+
last_name: string;
|
|
162
|
+
status?: string;
|
|
163
|
+
}
|
|
164
|
+
export interface VirtualAgent {
|
|
165
|
+
id: number;
|
|
166
|
+
name: string;
|
|
167
|
+
avatar_url: string;
|
|
168
|
+
status?: string;
|
|
169
|
+
}
|
|
170
|
+
export interface ChatResponse {
|
|
171
|
+
id: number;
|
|
172
|
+
lang: string;
|
|
173
|
+
status: string;
|
|
174
|
+
status_text: string;
|
|
175
|
+
created_at: string;
|
|
176
|
+
features: string[];
|
|
177
|
+
menus: {
|
|
178
|
+
id: number;
|
|
179
|
+
name: string;
|
|
180
|
+
}[];
|
|
181
|
+
provider_type: string;
|
|
182
|
+
csat_settings: {
|
|
183
|
+
enabled: boolean;
|
|
184
|
+
};
|
|
185
|
+
survey_enabled: boolean;
|
|
186
|
+
region?: string;
|
|
187
|
+
provider_channel_id?: string;
|
|
188
|
+
transcript_requested_count?: number;
|
|
189
|
+
agent?: HumanAgent;
|
|
190
|
+
virtual_agent: VirtualAgent;
|
|
191
|
+
all_agents: HumanAgent[];
|
|
192
|
+
all_virtual_agents: VirtualAgent[];
|
|
193
|
+
}
|
|
194
|
+
export interface MessageResponse {
|
|
195
|
+
$index: number;
|
|
196
|
+
$sid: string;
|
|
197
|
+
$timestamp: Date;
|
|
198
|
+
$userType: string;
|
|
199
|
+
$userId: number;
|
|
200
|
+
type: string;
|
|
201
|
+
content?: string;
|
|
202
|
+
event?: string;
|
|
203
|
+
file?: File;
|
|
204
|
+
[key: string]: unknown;
|
|
205
|
+
}
|
|
206
|
+
export interface CallResponse {
|
|
207
|
+
id: number;
|
|
208
|
+
lang: string;
|
|
209
|
+
menu_id: number;
|
|
210
|
+
status: string;
|
|
211
|
+
type: string;
|
|
212
|
+
scheduled_at?: string;
|
|
213
|
+
recording_permitted: boolean;
|
|
214
|
+
survey_enabled: boolean;
|
|
215
|
+
created_at: string;
|
|
216
|
+
}
|
|
217
|
+
export interface QuestionItem {
|
|
218
|
+
id: number;
|
|
219
|
+
type: string;
|
|
220
|
+
display_text: string;
|
|
221
|
+
valid_answers?: {
|
|
222
|
+
key: string;
|
|
223
|
+
value: string;
|
|
224
|
+
}[];
|
|
225
|
+
}
|
|
226
|
+
export interface ChatSurveyResponse {
|
|
227
|
+
sign_off_display_text: string;
|
|
228
|
+
questions: QuestionItem[];
|
|
229
|
+
}
|
|
230
|
+
export interface UserProfile {
|
|
231
|
+
identity?: string;
|
|
232
|
+
name?: string;
|
|
233
|
+
email?: string;
|
|
234
|
+
}
|
|
235
|
+
export interface TriggerMessage {
|
|
236
|
+
lang: string;
|
|
237
|
+
text: string;
|
|
238
|
+
}
|
|
239
|
+
export interface TriggerItem {
|
|
240
|
+
id: number;
|
|
241
|
+
stay_time: number;
|
|
242
|
+
messages: TriggerMessage[];
|
|
243
|
+
visitor_type: string;
|
|
244
|
+
page_visit_count: number;
|
|
245
|
+
keywords_included?: string[];
|
|
246
|
+
keywords_excluded?: string[];
|
|
247
|
+
}
|
|
248
|
+
export declare class EventManager {
|
|
249
|
+
private handlers;
|
|
250
|
+
addEventListener(eventName: string, handler: EventHandler): void;
|
|
251
|
+
triggerEvent(eventName: string, data?: any): void;
|
|
252
|
+
removeEventListener(eventName: string, handler: EventHandler): void;
|
|
253
|
+
destroy(): void;
|
|
254
|
+
}
|
|
255
|
+
export declare class Chat {
|
|
256
|
+
private provider;
|
|
257
|
+
private state;
|
|
258
|
+
private store;
|
|
259
|
+
private globalEvents;
|
|
260
|
+
connected: boolean;
|
|
261
|
+
allowSkipVirtualAgent: boolean;
|
|
262
|
+
constructor(state: ChatResponse, issueChatToken: IssueChatTokenMethod);
|
|
263
|
+
_setGlobalEvents(events: EventManager): void;
|
|
264
|
+
get id(): number;
|
|
265
|
+
get menuId(): number;
|
|
266
|
+
get channelId(): string;
|
|
267
|
+
get lang(): string;
|
|
268
|
+
get userIdentity(): string;
|
|
269
|
+
get status(): string;
|
|
270
|
+
get statusText(): string;
|
|
271
|
+
get cobrowsable(): boolean;
|
|
272
|
+
get ongoing(): boolean;
|
|
273
|
+
get dismissed(): boolean;
|
|
274
|
+
get ended(): boolean;
|
|
275
|
+
get transcriptCount(): number;
|
|
276
|
+
get createdAt(): string;
|
|
277
|
+
get feedbackType(): string;
|
|
278
|
+
update(state: ChatResponse): void;
|
|
279
|
+
on(eventName: string, handler: EventHandler): void;
|
|
280
|
+
off(eventName: string, handler: EventHandler): void;
|
|
281
|
+
connect(): Promise<boolean>;
|
|
282
|
+
disconnect(): Promise<void>;
|
|
283
|
+
sendMessage(message: MessageRequest, file?: File): Promise<number>;
|
|
284
|
+
preview(text: string): Promise<void>;
|
|
285
|
+
fetchMessages(): Promise<MessageResponse[]>;
|
|
286
|
+
startTyping(): void;
|
|
287
|
+
stopTyping(): void;
|
|
288
|
+
destroy(): Promise<void>;
|
|
289
|
+
clearMediaStore(): Promise<void>;
|
|
290
|
+
private triggerEvent;
|
|
291
|
+
private registerMessageEvents;
|
|
292
|
+
}
|
|
293
|
+
declare class Cobrowse {
|
|
294
|
+
private lang;
|
|
295
|
+
private messages;
|
|
296
|
+
private _cobrowse;
|
|
297
|
+
private _started;
|
|
298
|
+
constructor(instance: any, messages: CobrowseMessages, lang: string);
|
|
299
|
+
static create(options: CobrowseOption): Promise<Cobrowse>;
|
|
300
|
+
setCustomData(data: any): void;
|
|
301
|
+
on(eventName: string, eventHandler: EventHandler): void;
|
|
302
|
+
start(): Promise<void>;
|
|
303
|
+
stop(): Promise<void>;
|
|
304
|
+
endSession(): Promise<void>;
|
|
305
|
+
createSessionCode(): Promise<string>;
|
|
306
|
+
}
|
|
307
|
+
export declare class Client {
|
|
308
|
+
private options;
|
|
309
|
+
private communicator;
|
|
310
|
+
private methods;
|
|
311
|
+
private events;
|
|
312
|
+
request: RequestMethod;
|
|
313
|
+
chat: Chat;
|
|
314
|
+
cobrowse: Cobrowse;
|
|
315
|
+
constructor(options: ClientOption);
|
|
316
|
+
get deviceId(): string;
|
|
317
|
+
get user(): UserProfile;
|
|
318
|
+
get lang(): string;
|
|
319
|
+
set lang(lang: string);
|
|
320
|
+
on(eventName: string, handler: EventHandler): void;
|
|
321
|
+
off(eventName: string, handler: EventHandler): void;
|
|
322
|
+
getCompany(): Promise<CompanyResponse>;
|
|
323
|
+
getTrigger(lang?: string): Promise<TriggerItem>;
|
|
324
|
+
getMenus(key?: string, lang?: string): Promise<MenuResponse>;
|
|
325
|
+
getTimeSlots(menuId: number | string, lang?: string): Promise<string[]>;
|
|
326
|
+
createCall(menuId: number | string, data: CallRequest): Promise<CallResponse>;
|
|
327
|
+
loadCall(callId: number | string): Promise<CallResponse>;
|
|
328
|
+
cancelCall(callId: number | string): Promise<CallResponse>;
|
|
329
|
+
createEmail(menuId: number | string, data: EmailRequest): Promise<RequestReturn>;
|
|
330
|
+
createChat(menuId: number | string, data?: ChatRequest, customData?: string | object): Promise<Chat>;
|
|
331
|
+
loadChat(chatId: number | string): Promise<Chat>;
|
|
332
|
+
resumeChat(chatId: number | string): Promise<Chat>;
|
|
333
|
+
loadOngoingChat(): Promise<Chat>;
|
|
334
|
+
finishChat(): Promise<void>;
|
|
335
|
+
destroyChat(): Promise<void>;
|
|
336
|
+
sendChatTranscript(emails: string[]): Promise<RequestReturn>;
|
|
337
|
+
getChatSurvey(): Promise<ChatSurveyResponse>;
|
|
338
|
+
sendChatSurvey(answers: SurveyAnswers): Promise<RequestReturn>;
|
|
339
|
+
sendChatRate(data: RateRequest): Promise<RequestReturn>;
|
|
340
|
+
escalateChat(data?: EscalateRequest): Promise<RequestReturn>;
|
|
341
|
+
sendFileMessage(file: File, progress?: ProgressMethod): Promise<number>;
|
|
342
|
+
sendTextMessage(content: string): Promise<number>;
|
|
343
|
+
createCobrowseCode(lang?: string, customData?: Record<string, string>): Promise<string>;
|
|
344
|
+
startCobrowse(from?: string): Promise<void>;
|
|
345
|
+
private initializeCobrowse;
|
|
346
|
+
private registerOngoingChat;
|
|
347
|
+
}
|
|
348
|
+
declare abstract class BaseProvider {
|
|
349
|
+
static type: string;
|
|
350
|
+
private audio;
|
|
351
|
+
issueChatToken: IssueChatTokenMethod;
|
|
352
|
+
identity: string;
|
|
353
|
+
channelId: string;
|
|
354
|
+
region?: string;
|
|
355
|
+
events: EventManager;
|
|
356
|
+
constructor(state: ChatResponse, issueChatToken: IssueChatTokenMethod);
|
|
357
|
+
ping(): void;
|
|
358
|
+
on(eventName: string, handler: EventHandler): void;
|
|
359
|
+
off(eventName: string, handler: EventHandler): void;
|
|
360
|
+
abstract create(): Promise<void>;
|
|
361
|
+
abstract destroy(): Promise<void>;
|
|
362
|
+
abstract join(sid: string): Promise<void>;
|
|
363
|
+
abstract preview(text: string): Promise<void>;
|
|
364
|
+
abstract fetchMessages(files: {
|
|
365
|
+
[index: number]: File;
|
|
366
|
+
}): Promise<MessageResponse[]>;
|
|
367
|
+
abstract sendMessage(message: MessageRequest): Promise<number>;
|
|
368
|
+
abstract startTyping(): void;
|
|
369
|
+
abstract stopTyping(): void;
|
|
370
|
+
}
|
|
371
|
+
export declare function addProviderType(Provider: typeof BaseProvider): void;
|
|
372
|
+
export declare class MediaStore {
|
|
373
|
+
private db;
|
|
374
|
+
private store;
|
|
375
|
+
save(index: number, file: File): Promise<void>;
|
|
376
|
+
getAll(): Promise<{
|
|
377
|
+
index: number;
|
|
378
|
+
file: File;
|
|
379
|
+
}[]>;
|
|
380
|
+
getAllFiles(): Promise<{
|
|
381
|
+
[index: number]: File;
|
|
382
|
+
}>;
|
|
383
|
+
clear(): Promise<void>;
|
|
384
|
+
}
|
|
385
|
+
export declare class Logger {
|
|
386
|
+
channel: string;
|
|
387
|
+
constructor(channel: string);
|
|
388
|
+
static addHandler(handler: LoggerHandler): void;
|
|
389
|
+
debug(...args: any[]): void;
|
|
390
|
+
info(...args: any[]): void;
|
|
391
|
+
warn(...args: any[]): void;
|
|
392
|
+
error(...args: any[]): void;
|
|
393
|
+
private _log;
|
|
394
|
+
}
|
|
395
|
+
export declare const consoleLoggerHandler: LoggerHandler;
|
|
396
|
+
export declare function newrelicLoggerHandler(apiKey: string): LoggerHandler;
|
|
397
|
+
export declare function formatLogData(channel: string, level: string, ...args: any[]): LogData;
|
|
398
|
+
export declare const ENVIRONMENT: string;
|
|
399
|
+
export declare const VERSION: string;
|
|
400
|
+
export declare const OPTIONS: {
|
|
401
|
+
companyId: string;
|
|
402
|
+
tenant: string;
|
|
403
|
+
trackerId: string;
|
|
404
|
+
deviceId: string;
|
|
405
|
+
application: string;
|
|
406
|
+
version: string;
|
|
407
|
+
};
|
|
408
|
+
|
|
409
|
+
export {};
|