@ujet/websdk-headless 4.39.0 → 5.2.1
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 +87 -16
- package/dist/index.js +109 -109
- package/dist/index.mjs +13476 -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 {
|
|
@@ -507,6 +509,7 @@ interface VoiceCallRequest {
|
|
|
507
509
|
unsigned?: Record<string, any>;
|
|
508
510
|
};
|
|
509
511
|
cobrowsable?: boolean;
|
|
512
|
+
voicemail_reason?: string;
|
|
510
513
|
}
|
|
511
514
|
|
|
512
515
|
type RequestMethod = (url: string, options: RequestInit | Record<string, any>) => Promise<RequestReturn>;
|
|
@@ -706,6 +709,15 @@ declare class Chat {
|
|
|
706
709
|
private registerMessageEvents;
|
|
707
710
|
}
|
|
708
711
|
|
|
712
|
+
/** Thrown when a message send is attempted after the chat has already ended. */
|
|
713
|
+
declare class ChatEndedError extends Error {
|
|
714
|
+
static readonly CODE = "CHAT_ENDED";
|
|
715
|
+
readonly code = "CHAT_ENDED";
|
|
716
|
+
/** Chat status at the time of the rejected send (e.g. 'finished', 'timeout'). */
|
|
717
|
+
readonly status?: string;
|
|
718
|
+
constructor(status?: string);
|
|
719
|
+
}
|
|
720
|
+
|
|
709
721
|
declare global {
|
|
710
722
|
interface Window {
|
|
711
723
|
webkitIndexedDB: IDBFactory;
|
|
@@ -730,6 +742,16 @@ declare class MediaStore {
|
|
|
730
742
|
|
|
731
743
|
/** Return type of `VoiceCall.feedbackType` — which post-call UX (if any) to show. */
|
|
732
744
|
type VoiceFeedbackType = 'survey' | 'rate' | 'none';
|
|
745
|
+
/**
|
|
746
|
+
* Opaque server-side reference returned by {@link VoiceCall.prepareMediaUpload}
|
|
747
|
+
* and consumed by {@link VoiceCall.submitMediaRefsForSmartAction}. `kind`
|
|
748
|
+
* carries the originating media type so submit can reject cross-type misuse
|
|
749
|
+
* (e.g. submitting a video ref under a photo SmartAction).
|
|
750
|
+
*/
|
|
751
|
+
type MediaRef = {
|
|
752
|
+
readonly ref: string;
|
|
753
|
+
readonly kind: SmartActionMediaType;
|
|
754
|
+
};
|
|
733
755
|
declare class VoiceCall {
|
|
734
756
|
/** Backing field for the read-only `state` accessor; mutated by the SDK. */
|
|
735
757
|
protected _state: VoiceCallResponse;
|
|
@@ -822,6 +844,24 @@ declare class VoiceCall {
|
|
|
822
844
|
cancelSmartAction(smartActionId: number): Promise<void>;
|
|
823
845
|
/** Upload media files (photo / screenshot / video) for a SmartAction. */
|
|
824
846
|
uploadMediaForSmartAction(smartActionId: number, files: File[], type: 'photo' | 'screenshot' | 'video'): Promise<void>;
|
|
847
|
+
/**
|
|
848
|
+
* Upload one media file in advance (used by the widget's mobile background-upload
|
|
849
|
+
* path). Returns an opaque server-side reference. Caller passes the references
|
|
850
|
+
* collected this way into {@link submitMediaRefsForSmartAction}. Pass an
|
|
851
|
+
* AbortSignal to cancel an in-flight upload (e.g. user closed the picker
|
|
852
|
+
* dialog mid-transfer).
|
|
853
|
+
*/
|
|
854
|
+
prepareMediaUpload(file: File, type: SmartActionMediaType, signal?: AbortSignal): Promise<MediaRef>;
|
|
855
|
+
/**
|
|
856
|
+
* Register pre-uploaded media refs (from {@link prepareMediaUpload}) against an
|
|
857
|
+
* active SmartAction. Used by the mobile background-upload path; desktop continues
|
|
858
|
+
* to use {@link uploadMediaForSmartAction}.
|
|
859
|
+
*
|
|
860
|
+
* Each {@link MediaRef} carries its `kind` so callers cannot accidentally
|
|
861
|
+
* submit a video ref under a photo SmartAction. The method throws
|
|
862
|
+
* {@link SmartActionError} if any ref's `kind` doesn't match `type`.
|
|
863
|
+
*/
|
|
864
|
+
submitMediaRefsForSmartAction(smartActionId: number, type: SmartActionMediaType, refs: readonly MediaRef[]): Promise<void>;
|
|
825
865
|
protected registerProviderEvents(): void;
|
|
826
866
|
protected fetchAndUpdateState(): Promise<void>;
|
|
827
867
|
private handleProviderMessage;
|
|
@@ -833,6 +873,20 @@ declare class VoiceCall {
|
|
|
833
873
|
private resolveSmartAction;
|
|
834
874
|
}
|
|
835
875
|
|
|
876
|
+
declare const VOICE_EVENTS: {
|
|
877
|
+
readonly STATUS_CHANGED: "voice.statusChanged";
|
|
878
|
+
readonly RECONNECTING: "voice.reconnecting";
|
|
879
|
+
readonly RECONNECTED: "voice.reconnected";
|
|
880
|
+
readonly ERROR: "voice.error";
|
|
881
|
+
readonly SMART_ACTION_REQUESTED: "voice.smartActionRequested";
|
|
882
|
+
readonly SMART_ACTION_RESOLVED: "voice.smartActionResolved";
|
|
883
|
+
readonly COBROWSE_REQUESTED: "voice.cobrowseRequested";
|
|
884
|
+
readonly COBROWSE_RESOLVED: "voice.cobrowseResolved";
|
|
885
|
+
readonly RECORDING_PERMISSION_REQUIRED: "voice.recordingPermissionRequired";
|
|
886
|
+
readonly MIC_PERMISSION_REQUIRED: "voice.micPermissionRequired";
|
|
887
|
+
readonly CONNECTION_QUALITY: "voice.connectionQuality";
|
|
888
|
+
};
|
|
889
|
+
|
|
836
890
|
/** Extract a human-readable message from an `unknown` caught value. */
|
|
837
891
|
declare const getErrorMessage: (err: unknown) => string;
|
|
838
892
|
/** Cross-realm-safe fallback for `err instanceof VoiceCallError` checks. */
|
|
@@ -864,10 +918,10 @@ declare class FeatureNotEnabledError extends VoiceCallError {
|
|
|
864
918
|
static readonly CODE = "FEATURE_NOT_ENABLED";
|
|
865
919
|
constructor(message?: string);
|
|
866
920
|
}
|
|
867
|
-
/**
|
|
921
|
+
/** Mic unavailable at call start — wraps any getUserMedia rejection; inspect `cause` to distinguish. */
|
|
868
922
|
declare class MicPermissionDeniedError extends VoiceCallError {
|
|
869
923
|
static readonly CODE = "MIC_PERMISSION_DENIED";
|
|
870
|
-
constructor(message?: string);
|
|
924
|
+
constructor(message?: string, cause?: unknown);
|
|
871
925
|
}
|
|
872
926
|
/** Caller invoked a method that requires an active voice call but none exists. */
|
|
873
927
|
declare class NoActiveVoiceCallError extends VoiceCallError {
|
|
@@ -938,18 +992,17 @@ interface VoiceCobrowseResolvedEvent {
|
|
|
938
992
|
interface VoiceRecordingPermissionRequiredEvent {
|
|
939
993
|
id: number;
|
|
940
994
|
}
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
};
|
|
995
|
+
/** Result of `client.checkMicPermission()`. `'unknown'` when the Permissions
|
|
996
|
+
* API or the `microphone` descriptor is unsupported (e.g. iOS Safari). */
|
|
997
|
+
type MicPermissionState = 'granted' | 'denied' | 'prompt' | 'unknown';
|
|
998
|
+
type ConnectionQualityLevel = 'good' | 'degraded';
|
|
999
|
+
/** Normalized, provider-agnostic quality issues. Twilio warning names are
|
|
1000
|
+
* mapped to these inside TwilioVoiceProvider — raw Twilio names never leak. */
|
|
1001
|
+
type ConnectionQualityWarning = 'high-latency' | 'jitter' | 'packet-loss' | 'low-quality';
|
|
1002
|
+
interface VoiceConnectionQualityEvent {
|
|
1003
|
+
level: ConnectionQualityLevel;
|
|
1004
|
+
warnings: ConnectionQualityWarning[];
|
|
1005
|
+
}
|
|
953
1006
|
|
|
954
1007
|
declare class Client {
|
|
955
1008
|
VERSION: string;
|
|
@@ -963,6 +1016,8 @@ declare class Client {
|
|
|
963
1016
|
private _voiceCall;
|
|
964
1017
|
private _voiceTabLock;
|
|
965
1018
|
private redactionSendQueue;
|
|
1019
|
+
private fileSendQueue;
|
|
1020
|
+
private _rehydratePromise;
|
|
966
1021
|
private onPageHide?;
|
|
967
1022
|
private onPageShow?;
|
|
968
1023
|
constructor(options: ClientOption);
|
|
@@ -986,6 +1041,8 @@ declare class Client {
|
|
|
986
1041
|
on(event: typeof VOICE_EVENTS.COBROWSE_REQUESTED, handler: (payload: VoiceCobrowseRequestedEvent) => void): void;
|
|
987
1042
|
on(event: typeof VOICE_EVENTS.COBROWSE_RESOLVED, handler: (payload: VoiceCobrowseResolvedEvent) => void): void;
|
|
988
1043
|
on(event: typeof VOICE_EVENTS.RECORDING_PERMISSION_REQUIRED, handler: (payload: VoiceRecordingPermissionRequiredEvent) => void): void;
|
|
1044
|
+
on(event: typeof VOICE_EVENTS.MIC_PERMISSION_REQUIRED, handler: () => void): void;
|
|
1045
|
+
on(event: typeof VOICE_EVENTS.CONNECTION_QUALITY, handler: (payload: VoiceConnectionQualityEvent) => void): void;
|
|
989
1046
|
on(eventName: string, handler: EventHandler): void;
|
|
990
1047
|
off(event: typeof VOICE_EVENTS.STATUS_CHANGED, handler: (payload: VoiceStatusChangedEvent) => void): void;
|
|
991
1048
|
off(event: typeof VOICE_EVENTS.RECONNECTING, handler: () => void): void;
|
|
@@ -996,13 +1053,24 @@ declare class Client {
|
|
|
996
1053
|
off(event: typeof VOICE_EVENTS.COBROWSE_REQUESTED, handler: (payload: VoiceCobrowseRequestedEvent) => void): void;
|
|
997
1054
|
off(event: typeof VOICE_EVENTS.COBROWSE_RESOLVED, handler: (payload: VoiceCobrowseResolvedEvent) => void): void;
|
|
998
1055
|
off(event: typeof VOICE_EVENTS.RECORDING_PERMISSION_REQUIRED, handler: (payload: VoiceRecordingPermissionRequiredEvent) => void): void;
|
|
1056
|
+
off(event: typeof VOICE_EVENTS.MIC_PERMISSION_REQUIRED, handler: () => void): void;
|
|
1057
|
+
off(event: typeof VOICE_EVENTS.CONNECTION_QUALITY, handler: (payload: VoiceConnectionQualityEvent) => void): void;
|
|
999
1058
|
off(eventName: string, handler: EventHandler): void;
|
|
1059
|
+
/**
|
|
1060
|
+
* Non-prompting read of the microphone permission state. Never calls
|
|
1061
|
+
* getUserMedia, so it does NOT trigger the browser permission dialog.
|
|
1062
|
+
* Returns 'unknown' when the Permissions API / 'microphone' descriptor is
|
|
1063
|
+
* unsupported (iOS Safari, older browsers) — callers should then rely on the
|
|
1064
|
+
* `voice.micPermissionRequired` event / the thrown MicPermissionDeniedError.
|
|
1065
|
+
*/
|
|
1066
|
+
checkMicPermission(): Promise<MicPermissionState>;
|
|
1000
1067
|
getCompany(): Promise<CompanyResponse>;
|
|
1001
1068
|
getFeatureFlags(): Promise<FeatureFlagsResponse>;
|
|
1002
1069
|
runTrigger(cb: (trigger: TriggerItem) => void): Promise<void>;
|
|
1003
1070
|
trackClientEvents(events: ClientEvent[]): Promise<void>;
|
|
1004
1071
|
getProhibitedFileTypes(): Promise<FileTypeItem[]>;
|
|
1005
1072
|
getMenus(key?: string, lang?: string): Promise<MenuResponse>;
|
|
1073
|
+
cancelMenuPolling(): void;
|
|
1006
1074
|
getCustomFormData(formId: string): Promise<RequestReturn>;
|
|
1007
1075
|
submitCustomForm(payload: CustomFormPayload): Promise<RequestReturn>;
|
|
1008
1076
|
getAfterHourMessage(lang?: string): Promise<string>;
|
|
@@ -1022,6 +1090,7 @@ declare class Client {
|
|
|
1022
1090
|
loadChat(chatId: number | string): Promise<Chat>;
|
|
1023
1091
|
resumeChat(chatId: number | string): Promise<Chat>;
|
|
1024
1092
|
loadOngoingChat(): Promise<Chat | null>;
|
|
1093
|
+
private _doLoadOngoingChat;
|
|
1025
1094
|
restoreCobrowseSession(): Promise<void>;
|
|
1026
1095
|
finishChat(): Promise<void>;
|
|
1027
1096
|
updatePostSession(postSessionStatus: PostSessionStatus, optInSelection?: boolean): Promise<void>;
|
|
@@ -1157,6 +1226,8 @@ declare class Logger {
|
|
|
1157
1226
|
private log;
|
|
1158
1227
|
}
|
|
1159
1228
|
|
|
1229
|
+
declare const isMobilePlatform: () => boolean;
|
|
1230
|
+
|
|
1160
1231
|
declare const ENVIRONMENT: string;
|
|
1161
1232
|
declare const VERSION: string;
|
|
1162
1233
|
declare const OPTIONS: {
|
|
@@ -1260,4 +1331,4 @@ declare const COBROWSE_EVENTS: {
|
|
|
1260
1331
|
};
|
|
1261
1332
|
type CobrowseEvent = (typeof COBROWSE_EVENTS)[keyof typeof COBROWSE_EVENTS];
|
|
1262
1333
|
|
|
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 };
|
|
1334
|
+
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 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 };
|