@ujet/websdk-headless 3.43.4 → 4.22.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 CHANGED
@@ -24,10 +24,3 @@ const client = new Client({
24
24
  authenticate: authenticate,
25
25
  })
26
26
  ```
27
-
28
- ## Docs
29
- ### [API/Methods](docs/api.md)
30
- ### [Authentication](docs/authenticate.md)
31
- ### [Screen Share](docs/screen-share.md)
32
- ### [Events](docs/events.md)
33
- ### [Configuration Options](docs/options.md)
package/dist/index.d.ts CHANGED
@@ -6,8 +6,8 @@ interface LogData {
6
6
  loglevel: string;
7
7
  timestamp: string;
8
8
  application: string;
9
- version: string;
10
- device: string;
9
+ sdk_version: string;
10
+ device_uuid: string;
11
11
  tenant: string;
12
12
  company_id: string;
13
13
  location_url: string;
@@ -16,6 +16,12 @@ interface LogData {
16
16
  data: any;
17
17
  tracker_id?: string;
18
18
  }
19
+ interface LogHistoryData {
20
+ date: string;
21
+ channel: string;
22
+ level: string;
23
+ args: any[];
24
+ }
19
25
  interface ClientEvent {
20
26
  name: string;
21
27
  payload: {
@@ -76,6 +82,8 @@ interface CallRequest {
76
82
  signed?: string;
77
83
  unsigned?: Record<string, any>;
78
84
  };
85
+ reschedule_call_id?: number;
86
+ use_advanced_call_scheduling?: boolean;
79
87
  }
80
88
  interface EmailRequest {
81
89
  name?: string;
@@ -106,6 +114,18 @@ interface CheckInVisibilityStateRequest {
106
114
  interface CheckInModalStateRequest {
107
115
  modal_type: 'check_in';
108
116
  }
117
+ interface GetTimeSlotsRequest {
118
+ lang?: string;
119
+ rescheduleCallId?: number;
120
+ useAdvancedCallScheduling?: boolean;
121
+ }
122
+ interface CustomFormPayload {
123
+ smart_action_id: number;
124
+ form_response: {
125
+ question_id: number;
126
+ value: string | string[] | boolean;
127
+ }[];
128
+ }
109
129
 
110
130
  declare enum PostSessionStatus {
111
131
  WAITING = "waiting",
@@ -223,11 +243,13 @@ interface ChatResponse {
223
243
  post_session_transfer_status?: string;
224
244
  check_in_status?: CheckInStatus;
225
245
  }
226
- interface CallResponse {
246
+ interface CallApiResponse {
227
247
  created_at: string;
228
248
  id: number;
229
249
  lang: string;
230
- menu_id: number;
250
+ selected_menu: {
251
+ id: number;
252
+ };
231
253
  menus: {
232
254
  id: number;
233
255
  name: string;
@@ -238,15 +260,8 @@ interface CallResponse {
238
260
  survey_enabled: boolean;
239
261
  type: string;
240
262
  }
241
- interface ChatDeflectionResponse {
242
- email: boolean;
243
- enabled: boolean;
244
- external_deflection_links: {
245
- enabled: boolean;
246
- ids: number[];
247
- };
248
- keep_waiting: boolean;
249
- threshold: number;
263
+ interface CallResponse extends Omit<CallApiResponse, 'selected_menu'> {
264
+ menu_id: number;
250
265
  }
251
266
  interface EmailResponse {
252
267
  attachment_count: number;
@@ -263,6 +278,10 @@ interface GenerateTranscriptResponse {
263
278
  chat_transcript_id: number;
264
279
  status: string;
265
280
  }
281
+ interface ChatDocumentItem {
282
+ media_id: number;
283
+ url: string;
284
+ }
266
285
  interface MessageResponse {
267
286
  $index: number;
268
287
  $sid: string;
@@ -284,8 +303,20 @@ interface MessageResponse {
284
303
  messages: string[];
285
304
  type: any;
286
305
  };
306
+ title?: string;
287
307
  type: string;
288
308
  unredacted?: string;
309
+ signature?: string;
310
+ form?: {
311
+ id: number;
312
+ form_type: string;
313
+ name: string;
314
+ title: string;
315
+ subtitle: string;
316
+ external_form_id: string;
317
+ smart_action_id: number;
318
+ image: string;
319
+ };
289
320
  visible?: boolean;
290
321
  [key: string]: unknown;
291
322
  }
@@ -356,6 +387,26 @@ interface QuestionItem {
356
387
  value: string;
357
388
  }[];
358
389
  }
390
+ interface ChatDeflectionResponse {
391
+ email: boolean;
392
+ enabled: boolean;
393
+ external_deflection_links: {
394
+ enabled: boolean;
395
+ ids: number[];
396
+ };
397
+ keep_waiting: boolean;
398
+ threshold: number;
399
+ }
400
+ interface ChatDeflectionResponse {
401
+ enabled: boolean;
402
+ threshold: number;
403
+ email: boolean;
404
+ keep_waiting: boolean;
405
+ external_deflection_links: {
406
+ enabled: boolean;
407
+ ids: number[];
408
+ };
409
+ }
359
410
  interface CheckInResponse {
360
411
  chat_id: number;
361
412
  check_in_status: CheckInStatus;
@@ -365,6 +416,17 @@ interface ChatMessageResponse {
365
416
  content: string;
366
417
  timestamp: string;
367
418
  }
419
+ interface ServerAuthResponse {
420
+ error?: number;
421
+ message?: any;
422
+ auth_token?: string;
423
+ log_proxy_auth_token?: string;
424
+ log_proxy_url?: string;
425
+ }
426
+ interface FeatureFlagsResponse {
427
+ 'advanced-call-scheduling': boolean;
428
+ 'consumer-agent-pdf'?: boolean;
429
+ }
368
430
 
369
431
  type RequestMethod = (url: string, options: RequestInit | Record<string, any>) => Promise<RequestReturn>;
370
432
  type EventHandler = (data: any) => void;
@@ -386,23 +448,7 @@ interface ClientOption {
386
448
  lang?: string;
387
449
  bridge?: string;
388
450
  version?: string;
389
- cobrowse?: {
390
- enabled: boolean;
391
- template?: string;
392
- confirmSessionTemplate?: string;
393
- confirmRemoteControlTemplate?: string;
394
- confirmFullDeviceTemplate?: string;
395
- sessionControlsTemplate?: string;
396
- root?: Element;
397
- messages?: CobrowseMessages;
398
- api?: string;
399
- license?: string;
400
- trustedOrigins?: string[];
401
- capabilities?: string[];
402
- registration?: boolean;
403
- redactedViews?: string[];
404
- unredactedViews?: string[];
405
- };
451
+ cobrowse?: CobrowseOption;
406
452
  [key: string]: unknown;
407
453
  }
408
454
  interface ConnectOption {
@@ -413,6 +459,8 @@ interface ConnectOption {
413
459
  lang: string;
414
460
  cobrowse: boolean;
415
461
  bridge: string;
462
+ bridgeOrigin: string;
463
+ modules: string[];
416
464
  }
417
465
  interface ConnectRequest {
418
466
  type: string;
@@ -443,8 +491,8 @@ interface CobrowseMessages {
443
491
  }
444
492
  interface CobrowseOption {
445
493
  enabled?: boolean;
446
- lang: string;
447
- messages: CobrowseMessages;
494
+ lang?: string;
495
+ messages?: CobrowseMessages;
448
496
  root?: Element;
449
497
  api?: string;
450
498
  license?: string;
@@ -458,6 +506,12 @@ interface CobrowseOption {
458
506
  registration?: boolean;
459
507
  redactedViews?: string[];
460
508
  unredactedViews?: string[];
509
+ instance?: any;
510
+ confirmSession?: () => Promise<boolean>;
511
+ confirmRemoteControl?: () => Promise<boolean>;
512
+ confirmFullDevice?: () => Promise<boolean>;
513
+ showSessionControls?: () => void;
514
+ hideSessionControls?: () => void;
461
515
  }
462
516
 
463
517
  declare class EventManager {
@@ -480,6 +534,11 @@ declare abstract class BaseProvider {
480
534
  events: EventManager;
481
535
  constructor(events: EventManager, state: ChatResponse, issueChatToken: IssueChatTokenMethod);
482
536
  ping(): void;
537
+ /**
538
+ * Cleanup audio resources by removing event listeners.
539
+ * Should be called by subclasses in their destroy() method.
540
+ */
541
+ protected cleanupAudio(): void;
483
542
  on(eventName: string, handler: EventHandler): void;
484
543
  off(eventName: string, handler: EventHandler): void;
485
544
  trackInTask(message: MessageResponse): void;
@@ -580,28 +639,6 @@ declare class MediaStore {
580
639
  clear(): Promise<void>;
581
640
  }
582
641
 
583
- declare class Cobrowse {
584
- private _cobrowse;
585
- private _options;
586
- private _started;
587
- private focusTrap;
588
- constructor(instance: any, options: CobrowseOption);
589
- private get root();
590
- private get lang();
591
- private get messages();
592
- private get template();
593
- static create(options: CobrowseOption, script: string): Promise<Cobrowse>;
594
- setCustomData(data: any): void;
595
- on(eventName: string, eventHandler: EventHandler): void;
596
- start(): Promise<void>;
597
- stop(): Promise<void>;
598
- endSession(): Promise<void>;
599
- createSessionCode(): Promise<string>;
600
- private createConfirmConsent;
601
- private setupConfirms;
602
- private setupSessionControl;
603
- }
604
-
605
642
  declare class Client {
606
643
  VERSION: string;
607
644
  options: ClientOption;
@@ -610,22 +647,31 @@ declare class Client {
610
647
  private events;
611
648
  request: RequestMethod;
612
649
  chat: Chat;
613
- cobrowse: Cobrowse | null;
650
+ private _cobrowse;
614
651
  constructor(options: ClientOption);
615
652
  get deviceId(): string;
616
653
  get user(): UserProfile;
617
654
  get lang(): string;
618
655
  set lang(lang: string);
656
+ get cobrowse(): any;
619
657
  destroy(): void;
620
658
  on(eventName: string, handler: EventHandler): void;
621
659
  off(eventName: string, handler: EventHandler): void;
622
660
  getCompany(): Promise<CompanyResponse>;
661
+ getFeatureFlags(): Promise<FeatureFlagsResponse>;
623
662
  runTrigger(cb: (trigger: TriggerItem) => void): Promise<void>;
624
663
  trackClientEvents(events: ClientEvent[]): Promise<void>;
625
664
  getProhibitedFileTypes(): Promise<FileTypeItem[]>;
626
665
  getMenus(key?: string, lang?: string): Promise<MenuResponse>;
666
+ getCustomFormData(formId: string): Promise<RequestReturn>;
667
+ submitCustomForm(payload: CustomFormPayload): Promise<RequestReturn>;
627
668
  getAfterHourMessage(lang?: string): Promise<string>;
669
+ getTimeSlots(menuId: number | string, options?: GetTimeSlotsRequest): Promise<string[]>;
670
+ /**
671
+ * @deprecated Use getTimeSlots(menuId, options) instead to avoid parameter ambiguity
672
+ */
628
673
  getTimeSlots(menuId: number | string, lang?: string): Promise<string[]>;
674
+ fetchTimeSlotAvailability(menuId: number | string, lang?: string): Promise<boolean>;
629
675
  getWaitTimes(menuId: number | string, lang?: string): Promise<WaitTimeResponse | null>;
630
676
  verifyForm(data: FormData): Promise<boolean>;
631
677
  createCall(menuId: number | string, data: CallRequest): Promise<CallResponse>;
@@ -636,8 +682,9 @@ declare class Client {
636
682
  loadChat(chatId: number | string): Promise<Chat>;
637
683
  resumeChat(chatId: number | string): Promise<Chat>;
638
684
  loadOngoingChat(): Promise<Chat | null>;
685
+ restoreCobrowseSession(): Promise<void>;
639
686
  finishChat(): Promise<void>;
640
- updatePostSession(postSessionStatus: PostSessionStatus): Promise<void>;
687
+ updatePostSession(postSessionStatus: PostSessionStatus, optInSelection?: boolean): Promise<void>;
641
688
  destroyChat(): Promise<void>;
642
689
  getChatDeflection(): Promise<ChatDeflectionResponse | null>;
643
690
  sendChatTranscripts(emails: string[]): Promise<void>;
@@ -663,24 +710,42 @@ declare class Client {
663
710
  notifyCheckInState(data: CheckInVisibilityStateRequest): Promise<void>;
664
711
  rejoinChat(): Promise<CheckInResponse>;
665
712
  trackCheckInEvent(): Promise<void>;
713
+ getLogs(): Promise<{
714
+ bridgeLogs: LogHistoryData[];
715
+ rootLogs: LogHistoryData[];
716
+ }>;
717
+ printLogs(): Promise<void>;
666
718
  private updateCheckIn;
667
719
  private initializeCobrowse;
668
720
  private registerOngoingChat;
669
- private getCobrowseScript;
670
721
  _triggerEvent(eventName: string, data?: any): void;
671
722
  }
672
723
 
724
+ declare class CircularBuffer<T> {
725
+ private buffer;
726
+ private writeIndex;
727
+ private size;
728
+ private readonly capacity;
729
+ constructor(capacity: number);
730
+ push(item: T): void;
731
+ toArray(): T[];
732
+ clear(): void;
733
+ }
734
+
673
735
  declare class Logger {
674
- channel: string;
675
- constructor(channel: string);
736
+ static logHandlers: LoggerHandler[];
737
+ static logHistory: CircularBuffer<LogHistoryData>;
676
738
  static addHandler(handler: LoggerHandler): void;
739
+ static printLogHistoryData(log: LogHistoryData): void;
740
+ static consoleLog(channel: string, level: string, ...args: any[]): void;
741
+ private channel;
742
+ constructor(channel: string);
677
743
  debug(...args: any[]): void;
678
744
  info(...args: any[]): void;
679
745
  warn(...args: any[]): void;
680
746
  error(...args: any[]): void;
681
- private _log;
747
+ private log;
682
748
  }
683
- declare const consoleLoggerHandler: LoggerHandler;
684
749
 
685
750
  declare const ENVIRONMENT: string;
686
751
  declare const VERSION: string;
@@ -693,4 +758,4 @@ declare const OPTIONS: {
693
758
  version: string;
694
759
  };
695
760
 
696
- export { BaseProvider, type CallRequest, type CallResponse, Chat, type ChatDeflectionResponse, type ChatEndUserEventRequest, type ChatHistoryItem, type ChatHistoryResponse, type ChatMessageRequest, type ChatMessageResponse, type ChatRequest, type ChatResponse, type ChatSurveyResponse, type ChatTaskMessageResponse, type CheckInModalStateRequest, type CheckInResponse, CheckInStatus, type CheckInVisibilityStateRequest, Client, type ClientEvent, type ClientOption, type CobrowseMessages, type CobrowseOption, type CobrowseRequest, type CompanyResponse, type ConnectCallback, type ConnectOption, type ConnectRequest, type ConnectResult, ENVIRONMENT, type EmailRequest, type EmailResponse, type EscalateRequest, type EventHandler, EventManager, type FileTypeItem, type FormData, type GenerateTranscriptResponse, type GetServerMessage, type HumanAgent, type IssueChatTokenMethod, type LanguageOption, type LogData, Logger, type LoggerHandler, MediaStore, type MenuChannel, type MenuItem, type MenuResponse, type MessageRequest, type MessageResponse, OPTIONS, type PdfStatusResponse, PostSessionStatus, type QuestionItem, type RateRequest, type RequestMethod, type RequestReturn, type SurveyAnswers, type TokenResponse, type TriggerItem, type TriggerMessage, type UserProfile, VERSION, type VirtualAgent, type WaitTimeResponse, addProviderType, consoleLoggerHandler };
761
+ export { BaseProvider, type CallApiResponse, type CallRequest, type CallResponse, Chat, type ChatDeflectionResponse, type ChatDocumentItem, type ChatEndUserEventRequest, type ChatHistoryItem, type ChatHistoryResponse, type ChatMessageRequest, type ChatMessageResponse, type ChatRequest, type ChatResponse, type ChatSurveyResponse, type ChatTaskMessageResponse, type CheckInModalStateRequest, type CheckInResponse, CheckInStatus, type CheckInVisibilityStateRequest, Client, type ClientEvent, type ClientOption, type CobrowseMessages, type CobrowseOption, type CobrowseRequest, type CompanyResponse, type ConnectCallback, type ConnectOption, type ConnectRequest, type ConnectResult, type CustomFormPayload, ENVIRONMENT, type EmailRequest, type EmailResponse, type EscalateRequest, type EventHandler, EventManager, type FeatureFlagsResponse, type FileTypeItem, type FormData, type GenerateTranscriptResponse, type GetServerMessage, type GetTimeSlotsRequest, type HumanAgent, type IssueChatTokenMethod, type LanguageOption, type LogData, type LogHistoryData, Logger, type LoggerHandler, MediaStore, type MenuChannel, type MenuItem, type MenuResponse, type MessageRequest, type MessageResponse, OPTIONS, type PdfStatusResponse, PostSessionStatus, type QuestionItem, type RateRequest, type RequestMethod, type RequestReturn, type ServerAuthResponse, type SurveyAnswers, type TokenResponse, type TriggerItem, type TriggerMessage, type UserProfile, VERSION, type VirtualAgent, type WaitTimeResponse, addProviderType };