@ujet/websdk-headless 4.39.0 → 5.4.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/dist/index.d.ts +94 -17
- package/dist/index.js +109 -109
- package/dist/index.mjs +13473 -13132
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -24,7 +24,8 @@ declare enum ProviderType {
|
|
|
24
24
|
* Use these constants rather than raw string literals so renames are safe.
|
|
25
25
|
*/
|
|
26
26
|
declare enum ChannelType {
|
|
27
|
-
INBOUND_CALL = "inbound_call"
|
|
27
|
+
INBOUND_CALL = "inbound_call",
|
|
28
|
+
VOICEMAIL = "voicemail"
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
interface LanguageOption {
|
|
@@ -77,6 +78,7 @@ interface MenuResponse {
|
|
|
77
78
|
direct: {
|
|
78
79
|
key: boolean;
|
|
79
80
|
user: boolean;
|
|
81
|
+
key_id: number | null;
|
|
80
82
|
};
|
|
81
83
|
}
|
|
82
84
|
interface WaitTimeResponse {
|
|
@@ -204,6 +206,7 @@ interface MessageResponse {
|
|
|
204
206
|
image: string;
|
|
205
207
|
};
|
|
206
208
|
visible?: boolean;
|
|
209
|
+
reason?: string;
|
|
207
210
|
[key: string]: unknown;
|
|
208
211
|
}
|
|
209
212
|
interface PdfStatusResponse {
|
|
@@ -420,6 +423,11 @@ interface ChatRequest {
|
|
|
420
423
|
unsigned?: Record<string, any>;
|
|
421
424
|
};
|
|
422
425
|
}
|
|
426
|
+
interface MenusRoutingInputs {
|
|
427
|
+
initialMessage?: string | undefined;
|
|
428
|
+
customData?: Record<string, any> | undefined;
|
|
429
|
+
signedCustomData?: string | undefined;
|
|
430
|
+
}
|
|
423
431
|
interface EscalateRequest {
|
|
424
432
|
force_escalate: boolean;
|
|
425
433
|
menu_id: number;
|
|
@@ -507,6 +515,7 @@ interface VoiceCallRequest {
|
|
|
507
515
|
unsigned?: Record<string, any>;
|
|
508
516
|
};
|
|
509
517
|
cobrowsable?: boolean;
|
|
518
|
+
voicemail_reason?: string;
|
|
510
519
|
}
|
|
511
520
|
|
|
512
521
|
type RequestMethod = (url: string, options: RequestInit | Record<string, any>) => Promise<RequestReturn>;
|
|
@@ -706,6 +715,15 @@ declare class Chat {
|
|
|
706
715
|
private registerMessageEvents;
|
|
707
716
|
}
|
|
708
717
|
|
|
718
|
+
/** Thrown when a message send is attempted after the chat has already ended. */
|
|
719
|
+
declare class ChatEndedError extends Error {
|
|
720
|
+
static readonly CODE = "CHAT_ENDED";
|
|
721
|
+
readonly code = "CHAT_ENDED";
|
|
722
|
+
/** Chat status at the time of the rejected send (e.g. 'finished', 'timeout'). */
|
|
723
|
+
readonly status?: string;
|
|
724
|
+
constructor(status?: string);
|
|
725
|
+
}
|
|
726
|
+
|
|
709
727
|
declare global {
|
|
710
728
|
interface Window {
|
|
711
729
|
webkitIndexedDB: IDBFactory;
|
|
@@ -730,6 +748,16 @@ declare class MediaStore {
|
|
|
730
748
|
|
|
731
749
|
/** Return type of `VoiceCall.feedbackType` — which post-call UX (if any) to show. */
|
|
732
750
|
type VoiceFeedbackType = 'survey' | 'rate' | 'none';
|
|
751
|
+
/**
|
|
752
|
+
* Opaque server-side reference returned by {@link VoiceCall.prepareMediaUpload}
|
|
753
|
+
* and consumed by {@link VoiceCall.submitMediaRefsForSmartAction}. `kind`
|
|
754
|
+
* carries the originating media type so submit can reject cross-type misuse
|
|
755
|
+
* (e.g. submitting a video ref under a photo SmartAction).
|
|
756
|
+
*/
|
|
757
|
+
type MediaRef = {
|
|
758
|
+
readonly ref: string;
|
|
759
|
+
readonly kind: SmartActionMediaType;
|
|
760
|
+
};
|
|
733
761
|
declare class VoiceCall {
|
|
734
762
|
/** Backing field for the read-only `state` accessor; mutated by the SDK. */
|
|
735
763
|
protected _state: VoiceCallResponse;
|
|
@@ -822,6 +850,24 @@ declare class VoiceCall {
|
|
|
822
850
|
cancelSmartAction(smartActionId: number): Promise<void>;
|
|
823
851
|
/** Upload media files (photo / screenshot / video) for a SmartAction. */
|
|
824
852
|
uploadMediaForSmartAction(smartActionId: number, files: File[], type: 'photo' | 'screenshot' | 'video'): Promise<void>;
|
|
853
|
+
/**
|
|
854
|
+
* Upload one media file in advance (used by the widget's mobile background-upload
|
|
855
|
+
* path). Returns an opaque server-side reference. Caller passes the references
|
|
856
|
+
* collected this way into {@link submitMediaRefsForSmartAction}. Pass an
|
|
857
|
+
* AbortSignal to cancel an in-flight upload (e.g. user closed the picker
|
|
858
|
+
* dialog mid-transfer).
|
|
859
|
+
*/
|
|
860
|
+
prepareMediaUpload(file: File, type: SmartActionMediaType, signal?: AbortSignal): Promise<MediaRef>;
|
|
861
|
+
/**
|
|
862
|
+
* Register pre-uploaded media refs (from {@link prepareMediaUpload}) against an
|
|
863
|
+
* active SmartAction. Used by the mobile background-upload path; desktop continues
|
|
864
|
+
* to use {@link uploadMediaForSmartAction}.
|
|
865
|
+
*
|
|
866
|
+
* Each {@link MediaRef} carries its `kind` so callers cannot accidentally
|
|
867
|
+
* submit a video ref under a photo SmartAction. The method throws
|
|
868
|
+
* {@link SmartActionError} if any ref's `kind` doesn't match `type`.
|
|
869
|
+
*/
|
|
870
|
+
submitMediaRefsForSmartAction(smartActionId: number, type: SmartActionMediaType, refs: readonly MediaRef[]): Promise<void>;
|
|
825
871
|
protected registerProviderEvents(): void;
|
|
826
872
|
protected fetchAndUpdateState(): Promise<void>;
|
|
827
873
|
private handleProviderMessage;
|
|
@@ -833,6 +879,20 @@ declare class VoiceCall {
|
|
|
833
879
|
private resolveSmartAction;
|
|
834
880
|
}
|
|
835
881
|
|
|
882
|
+
declare const VOICE_EVENTS: {
|
|
883
|
+
readonly STATUS_CHANGED: "voice.statusChanged";
|
|
884
|
+
readonly RECONNECTING: "voice.reconnecting";
|
|
885
|
+
readonly RECONNECTED: "voice.reconnected";
|
|
886
|
+
readonly ERROR: "voice.error";
|
|
887
|
+
readonly SMART_ACTION_REQUESTED: "voice.smartActionRequested";
|
|
888
|
+
readonly SMART_ACTION_RESOLVED: "voice.smartActionResolved";
|
|
889
|
+
readonly COBROWSE_REQUESTED: "voice.cobrowseRequested";
|
|
890
|
+
readonly COBROWSE_RESOLVED: "voice.cobrowseResolved";
|
|
891
|
+
readonly RECORDING_PERMISSION_REQUIRED: "voice.recordingPermissionRequired";
|
|
892
|
+
readonly MIC_PERMISSION_REQUIRED: "voice.micPermissionRequired";
|
|
893
|
+
readonly CONNECTION_QUALITY: "voice.connectionQuality";
|
|
894
|
+
};
|
|
895
|
+
|
|
836
896
|
/** Extract a human-readable message from an `unknown` caught value. */
|
|
837
897
|
declare const getErrorMessage: (err: unknown) => string;
|
|
838
898
|
/** Cross-realm-safe fallback for `err instanceof VoiceCallError` checks. */
|
|
@@ -864,10 +924,10 @@ declare class FeatureNotEnabledError extends VoiceCallError {
|
|
|
864
924
|
static readonly CODE = "FEATURE_NOT_ENABLED";
|
|
865
925
|
constructor(message?: string);
|
|
866
926
|
}
|
|
867
|
-
/**
|
|
927
|
+
/** Mic unavailable at call start — wraps any getUserMedia rejection; inspect `cause` to distinguish. */
|
|
868
928
|
declare class MicPermissionDeniedError extends VoiceCallError {
|
|
869
929
|
static readonly CODE = "MIC_PERMISSION_DENIED";
|
|
870
|
-
constructor(message?: string);
|
|
930
|
+
constructor(message?: string, cause?: unknown);
|
|
871
931
|
}
|
|
872
932
|
/** Caller invoked a method that requires an active voice call but none exists. */
|
|
873
933
|
declare class NoActiveVoiceCallError extends VoiceCallError {
|
|
@@ -938,18 +998,17 @@ interface VoiceCobrowseResolvedEvent {
|
|
|
938
998
|
interface VoiceRecordingPermissionRequiredEvent {
|
|
939
999
|
id: number;
|
|
940
1000
|
}
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
};
|
|
1001
|
+
/** Result of `client.checkMicPermission()`. `'unknown'` when the Permissions
|
|
1002
|
+
* API or the `microphone` descriptor is unsupported (e.g. iOS Safari). */
|
|
1003
|
+
type MicPermissionState = 'granted' | 'denied' | 'prompt' | 'unknown';
|
|
1004
|
+
type ConnectionQualityLevel = 'good' | 'degraded';
|
|
1005
|
+
/** Normalized, provider-agnostic quality issues. Twilio warning names are
|
|
1006
|
+
* mapped to these inside TwilioVoiceProvider — raw Twilio names never leak. */
|
|
1007
|
+
type ConnectionQualityWarning = 'high-latency' | 'jitter' | 'packet-loss' | 'low-quality';
|
|
1008
|
+
interface VoiceConnectionQualityEvent {
|
|
1009
|
+
level: ConnectionQualityLevel;
|
|
1010
|
+
warnings: ConnectionQualityWarning[];
|
|
1011
|
+
}
|
|
953
1012
|
|
|
954
1013
|
declare class Client {
|
|
955
1014
|
VERSION: string;
|
|
@@ -963,6 +1022,8 @@ declare class Client {
|
|
|
963
1022
|
private _voiceCall;
|
|
964
1023
|
private _voiceTabLock;
|
|
965
1024
|
private redactionSendQueue;
|
|
1025
|
+
private fileSendQueue;
|
|
1026
|
+
private _rehydratePromise;
|
|
966
1027
|
private onPageHide?;
|
|
967
1028
|
private onPageShow?;
|
|
968
1029
|
constructor(options: ClientOption);
|
|
@@ -986,6 +1047,8 @@ declare class Client {
|
|
|
986
1047
|
on(event: typeof VOICE_EVENTS.COBROWSE_REQUESTED, handler: (payload: VoiceCobrowseRequestedEvent) => void): void;
|
|
987
1048
|
on(event: typeof VOICE_EVENTS.COBROWSE_RESOLVED, handler: (payload: VoiceCobrowseResolvedEvent) => void): void;
|
|
988
1049
|
on(event: typeof VOICE_EVENTS.RECORDING_PERMISSION_REQUIRED, handler: (payload: VoiceRecordingPermissionRequiredEvent) => void): void;
|
|
1050
|
+
on(event: typeof VOICE_EVENTS.MIC_PERMISSION_REQUIRED, handler: () => void): void;
|
|
1051
|
+
on(event: typeof VOICE_EVENTS.CONNECTION_QUALITY, handler: (payload: VoiceConnectionQualityEvent) => void): void;
|
|
989
1052
|
on(eventName: string, handler: EventHandler): void;
|
|
990
1053
|
off(event: typeof VOICE_EVENTS.STATUS_CHANGED, handler: (payload: VoiceStatusChangedEvent) => void): void;
|
|
991
1054
|
off(event: typeof VOICE_EVENTS.RECONNECTING, handler: () => void): void;
|
|
@@ -996,13 +1059,24 @@ declare class Client {
|
|
|
996
1059
|
off(event: typeof VOICE_EVENTS.COBROWSE_REQUESTED, handler: (payload: VoiceCobrowseRequestedEvent) => void): void;
|
|
997
1060
|
off(event: typeof VOICE_EVENTS.COBROWSE_RESOLVED, handler: (payload: VoiceCobrowseResolvedEvent) => void): void;
|
|
998
1061
|
off(event: typeof VOICE_EVENTS.RECORDING_PERMISSION_REQUIRED, handler: (payload: VoiceRecordingPermissionRequiredEvent) => void): void;
|
|
1062
|
+
off(event: typeof VOICE_EVENTS.MIC_PERMISSION_REQUIRED, handler: () => void): void;
|
|
1063
|
+
off(event: typeof VOICE_EVENTS.CONNECTION_QUALITY, handler: (payload: VoiceConnectionQualityEvent) => void): void;
|
|
999
1064
|
off(eventName: string, handler: EventHandler): void;
|
|
1065
|
+
/**
|
|
1066
|
+
* Non-prompting read of the microphone permission state. Never calls
|
|
1067
|
+
* getUserMedia, so it does NOT trigger the browser permission dialog.
|
|
1068
|
+
* Returns 'unknown' when the Permissions API / 'microphone' descriptor is
|
|
1069
|
+
* unsupported (iOS Safari, older browsers) — callers should then rely on the
|
|
1070
|
+
* `voice.micPermissionRequired` event / the thrown MicPermissionDeniedError.
|
|
1071
|
+
*/
|
|
1072
|
+
checkMicPermission(): Promise<MicPermissionState>;
|
|
1000
1073
|
getCompany(): Promise<CompanyResponse>;
|
|
1001
1074
|
getFeatureFlags(): Promise<FeatureFlagsResponse>;
|
|
1002
1075
|
runTrigger(cb: (trigger: TriggerItem) => void): Promise<void>;
|
|
1003
1076
|
trackClientEvents(events: ClientEvent[]): Promise<void>;
|
|
1004
1077
|
getProhibitedFileTypes(): Promise<FileTypeItem[]>;
|
|
1005
|
-
getMenus(key?: string, lang?: string): Promise<MenuResponse>;
|
|
1078
|
+
getMenus(key?: string, lang?: string, routing?: MenusRoutingInputs): Promise<MenuResponse>;
|
|
1079
|
+
cancelMenuPolling(): void;
|
|
1006
1080
|
getCustomFormData(formId: string): Promise<RequestReturn>;
|
|
1007
1081
|
submitCustomForm(payload: CustomFormPayload): Promise<RequestReturn>;
|
|
1008
1082
|
getAfterHourMessage(lang?: string): Promise<string>;
|
|
@@ -1022,6 +1096,7 @@ declare class Client {
|
|
|
1022
1096
|
loadChat(chatId: number | string): Promise<Chat>;
|
|
1023
1097
|
resumeChat(chatId: number | string): Promise<Chat>;
|
|
1024
1098
|
loadOngoingChat(): Promise<Chat | null>;
|
|
1099
|
+
private _doLoadOngoingChat;
|
|
1025
1100
|
restoreCobrowseSession(): Promise<void>;
|
|
1026
1101
|
finishChat(): Promise<void>;
|
|
1027
1102
|
updatePostSession(postSessionStatus: PostSessionStatus, optInSelection?: boolean): Promise<void>;
|
|
@@ -1157,6 +1232,8 @@ declare class Logger {
|
|
|
1157
1232
|
private log;
|
|
1158
1233
|
}
|
|
1159
1234
|
|
|
1235
|
+
declare const isMobilePlatform: () => boolean;
|
|
1236
|
+
|
|
1160
1237
|
declare const ENVIRONMENT: string;
|
|
1161
1238
|
declare const VERSION: string;
|
|
1162
1239
|
declare const OPTIONS: {
|
|
@@ -1260,4 +1337,4 @@ declare const COBROWSE_EVENTS: {
|
|
|
1260
1337
|
};
|
|
1261
1338
|
type CobrowseEvent = (typeof COBROWSE_EVENTS)[keyof typeof COBROWSE_EVENTS];
|
|
1262
1339
|
|
|
1263
|
-
export { AnotherTabVoiceCallError, BaseProvider, BaseVoiceProvider, COBROWSE_EVENTS, type CallApiResponse, CallInProgressError, type CallRequest, type CallResponse, ChannelType, 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 CobrowseEvent, 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, FeatureNotEnabledError, type FileTypeItem, type FormData, type GenerateTranscriptResponse, type GetServerMessage, type GetTimeSlotsRequest, type HumanAgent, InboundDisabledError, type IssueChatTokenMethod, type IssueVoiceTokenMethod, type LanguageOption, type LogData, type LogHistoryData, Logger, type LoggerHandler, MediaStore, type MenuChannel, type MenuItem, type MenuResponse, type MessageRequest, type MessageResponse, MicPermissionDeniedError, NoActiveVoiceCallError, OPTIONS, OperationHoursError, type PdfStatusResponse, PostSessionStatus, ProviderError, ProviderType, type QuestionItem, type RateRequest, type RecordingOption, type RecordingPermission, type RequestMethod, type RequestReturn, type ServerAuthResponse, type ServerVoiceCallStatus, SmartActionError, type SmartActionMediaType, type SmartActionResponse, type SmartActionType, type SurveyAnswers, type TokenResponse, type TriggerItem, type TriggerMessage, UnknownVoiceError, type UserProfile, VERSION, VOICE_EVENTS, type VirtualAgent, VoiceCall, VoiceCallError, type VoiceCallRequest, type VoiceCallResponse, type VoiceCallStatus, type VoiceCobrowseRequestedEvent, type VoiceCobrowseResolvedEvent, type VoiceErrorCode, type VoiceErrorEvent, type VoiceFeedbackType, type VoiceProviderConstructor, type VoiceProviderMessage, type VoiceProviderMessageType, type VoiceRecordingPermissionRequiredEvent, type VoiceSmartActionRequestedEvent, type VoiceSmartActionResolvedEvent, type VoiceStatusChangedEvent, type WaitTimeResponse, addProviderType, addVoiceProviderType, getErrorMessage, getErrorStatus, getVoiceProviderType, hasErrorCode, isAfterHoursError };
|
|
1340
|
+
export { AnotherTabVoiceCallError, BaseProvider, BaseVoiceProvider, COBROWSE_EVENTS, type CallApiResponse, CallInProgressError, type CallRequest, type CallResponse, ChannelType, Chat, type ChatDeflectionResponse, type ChatDocumentItem, type ChatEndUserEventRequest, ChatEndedError, 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 CobrowseEvent, type CobrowseMessages, type CobrowseOption, type CobrowseRequest, type CompanyResponse, type ConnectCallback, type ConnectOption, type ConnectRequest, type ConnectResult, type ConnectionQualityLevel, type ConnectionQualityWarning, type CustomFormPayload, ENVIRONMENT, type EmailRequest, type EmailResponse, type EscalateRequest, type EventHandler, EventManager, type FeatureFlagsResponse, FeatureNotEnabledError, type FileTypeItem, type FormData, type GenerateTranscriptResponse, type GetServerMessage, type GetTimeSlotsRequest, type HumanAgent, InboundDisabledError, type IssueChatTokenMethod, type IssueVoiceTokenMethod, type LanguageOption, type LogData, type LogHistoryData, Logger, type LoggerHandler, type MediaRef, MediaStore, type MenuChannel, type MenuItem, type MenuResponse, type MenusRoutingInputs, type MessageRequest, type MessageResponse, MicPermissionDeniedError, type MicPermissionState, NoActiveVoiceCallError, OPTIONS, OperationHoursError, type PdfStatusResponse, PostSessionStatus, ProviderError, ProviderType, type QuestionItem, type RateRequest, type RecordingOption, type RecordingPermission, type RequestMethod, type RequestReturn, type ServerAuthResponse, type ServerVoiceCallStatus, SmartActionError, type SmartActionMediaType, type SmartActionResponse, type SmartActionType, type SurveyAnswers, type TokenResponse, type TriggerItem, type TriggerMessage, UnknownVoiceError, type UserProfile, VERSION, VOICE_EVENTS, type VirtualAgent, VoiceCall, VoiceCallError, type VoiceCallRequest, type VoiceCallResponse, type VoiceCallStatus, type VoiceCobrowseRequestedEvent, type VoiceCobrowseResolvedEvent, type VoiceConnectionQualityEvent, type VoiceErrorCode, type VoiceErrorEvent, type VoiceFeedbackType, type VoiceProviderConstructor, type VoiceProviderMessage, type VoiceProviderMessageType, type VoiceRecordingPermissionRequiredEvent, type VoiceSmartActionRequestedEvent, type VoiceSmartActionResolvedEvent, type VoiceStatusChangedEvent, type WaitTimeResponse, addProviderType, addVoiceProviderType, getErrorMessage, getErrorStatus, getVoiceProviderType, hasErrorCode, isAfterHoursError, isMobilePlatform };
|