@ujet/websdk-headless 6.32.0 → 6.34.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 CHANGED
@@ -661,6 +661,38 @@ interface CobrowseOption {
661
661
  hideSessionControls?: () => void;
662
662
  }
663
663
 
664
+ type SendStatus = 'sending' | 'sent' | 'failed' | 'discarded';
665
+ type SendFailureReason = 'timeout' | 'disconnected' | 'chat_ended' | 'rejected' | 'upload_failed';
666
+ interface SendFailure {
667
+ readonly reason: SendFailureReason;
668
+ /**
669
+ * Whether the SDK resends on its own; always false once the message is `failed`. A manual retry is allowed
670
+ * for every reason but chat_ended.
671
+ */
672
+ readonly retryable: boolean;
673
+ }
674
+ interface OutgoingMessageStatusBase {
675
+ readonly client_message_id: string;
676
+ readonly status: SendStatus;
677
+ /** When the user pressed send, or Retry. */
678
+ readonly $timestamp: Date;
679
+ /** 1 for the first send, +1 for every automatic or manual resend. */
680
+ readonly attempt: number;
681
+ readonly error?: SendFailure | undefined;
682
+ }
683
+ interface OutgoingTextStatus extends OutgoingMessageStatusBase {
684
+ readonly type: 'text';
685
+ readonly content: string;
686
+ }
687
+ interface OutgoingFileStatus extends OutgoingMessageStatusBase {
688
+ readonly type: 'photo' | 'video' | 'document' | 'file';
689
+ /** The File passed to sendFileMessage; pairs the status with the preview shown for it. */
690
+ readonly file: File;
691
+ /** Set once the upload is done; an automatic resend publishes it again without uploading. */
692
+ readonly media_id?: number | undefined;
693
+ }
694
+ type OutgoingMessageStatus = OutgoingTextStatus | OutgoingFileStatus;
695
+
664
696
  declare class EventManager {
665
697
  private handlers;
666
698
  addEventListener(eventName: string, handler: EventHandler): void;
@@ -743,6 +775,18 @@ declare abstract class BaseProvider {
743
775
  protected cleanupAudio(): void;
744
776
  on(eventName: string, handler: EventHandler): void;
745
777
  off(eventName: string, handler: EventHandler): void;
778
+ /**
779
+ * Whether sends can go through the outbox: the echo carries the sent `client_message_id` back, and
780
+ * publishTracked() rejects with errors classifySendError() can tell apart. A provider that has it also
781
+ * emits SEND_READY_EVENT whenever the transport comes back.
782
+ */
783
+ get tracksSends(): boolean;
784
+ /** Whether a publish can go out right now; only read when tracksSends. */
785
+ get canPublish(): boolean;
786
+ /** One publish attempt for the outbox, rejecting when the message does not go out; only called when tracksSends. */
787
+ publishTracked(_message: MessageRequest): Promise<void>;
788
+ /** The key a file send's echo carries as `$index`, for pairing its File; '' when there is none. */
789
+ attachmentKeyOf(_message: MessageRequest): AttachmentKey;
746
790
  trackInTask(message: MessageResponse): void;
747
791
  abstract create(): Promise<void>;
748
792
  abstract destroy(): Promise<void>;
@@ -785,6 +829,11 @@ declare class Chat {
785
829
  private beaconAttempted;
786
830
  private connecting;
787
831
  private connectEnd;
832
+ private outbox;
833
+ private sendTrackingReleased;
834
+ private newestSid;
835
+ private sendFloors;
836
+ private sentFiles;
788
837
  constructor(state: ChatResponse, issueChatToken: IssueChatTokenMethod, hooks?: ChatHooks, providerContext?: ProviderContext);
789
838
  private handleConnectionEnded;
790
839
  private endConnection;
@@ -841,6 +890,26 @@ declare class Chat {
841
890
  * `chat` is public too. Pairing still uses the provider's wide key.
842
891
  */
843
892
  sendMessage(message: MessageRequest, file?: File): Promise<number>;
893
+ /** Messages sent through the outbox and not confirmed yet, oldest first; empty when nothing is tracked. */
894
+ get outgoingMessages(): readonly OutgoingMessageStatus[];
895
+ private saveSentFile;
896
+ private statusOf;
897
+ /**
898
+ * The File of the tracked send an own media echo answers — by client_message_id, or by media_id for an echo
899
+ * without it — saved under the echo's key, so the live path and a later history page show the same preview.
900
+ */
901
+ private pairSentFile;
902
+ private sentFileByMediaId;
903
+ /**
904
+ * Confirms the tracked send an echo answers. An own text or media echo that matches a held message but
905
+ * carries no client_message_id means echoes cannot be paired on this chat: the oldest match that was handed
906
+ * to the transport is confirmed, and tracking stops instead of failing a message the agent may already have.
907
+ * The echo is given that send's client_message_id, so listeners pair it by id as the SDK did.
908
+ */
909
+ private settleOwnEcho;
910
+ /** Whether the message was published after this send was queued. With nothing seen before the send, any is. */
911
+ private isAfterSend;
912
+ private noteSid;
844
913
  preview(text: string | undefined): Promise<void>;
845
914
  fetchMessages(): Promise<MessageResponse[]>;
846
915
  /**
@@ -859,6 +928,7 @@ declare class Chat {
859
928
  private surfacesSubscriptionEnd;
860
929
  private settleEndedConnect;
861
930
  private localOriginalCacheEnabled;
931
+ private sanitizesInboundPaths;
862
932
  /**
863
933
  * Joins the original onto `message.unredacted` for the end user's own
864
934
  * redacted text: local cache → in-band `unredacted` → (returns true) a
@@ -1217,6 +1287,7 @@ declare class Client {
1217
1287
  private _voiceTabLock;
1218
1288
  private redactionSendQueue;
1219
1289
  private fileSendQueue;
1290
+ private noCryptoLogged;
1220
1291
  private _rehydratePromise;
1221
1292
  private onPageHide?;
1222
1293
  private onPageShow?;
@@ -1385,8 +1456,23 @@ declare class Client {
1385
1456
  trackChatEndUserEvent(data: ChatEndUserEventRequest): Promise<void>;
1386
1457
  getChatHistory(page?: number): Promise<ChatHistoryResponse | null>;
1387
1458
  fetchMessages(): Promise<MessageResponse[]>;
1459
+ private sanitizeFetchedMessages;
1460
+ /**
1461
+ * On a chat that tracks sends, the upload is done once and its response goes through the outbox: status
1462
+ * events follow, carrying this `file`, and a resend or retry publishes the same response without uploading
1463
+ * again. An upload failure is unchanged.
1464
+ */
1388
1465
  sendFileMessage(file: File): Promise<number>;
1389
- sendTextMessage(rawContent: string): Promise<void>;
1466
+ /**
1467
+ * Resolves with the message's client_message_id when the SDK tracks it: status events follow for that id.
1468
+ * `undefined` means the SDK isn't tracking the message; it is not a failure.
1469
+ */
1470
+ sendTextMessage(rawContent: string): Promise<string | undefined>;
1471
+ private warnNoCrypto;
1472
+ /** Sends a `failed` message again with the same id. False for an unknown id, a message not `failed`, or an ended chat. */
1473
+ retryMessage(clientMessageId: string): boolean;
1474
+ /** Removes a `failed` message; its last status is `discarded`. False when there is no such message. */
1475
+ discardMessage(clientMessageId: string): boolean;
1390
1476
  sendPreviewMessage(content: string): Promise<void>;
1391
1477
  private isRedactionAgentEnabled;
1392
1478
  createCobrowseCode(lang?: string, customData?: Record<string, string>): Promise<string>;
@@ -1542,4 +1628,4 @@ declare const COBROWSE_EVENTS: {
1542
1628
  };
1543
1629
  type CobrowseEvent = (typeof COBROWSE_EVENTS)[keyof typeof COBROWSE_EVENTS];
1544
1630
 
1545
- export { AnotherTabVoiceCallError, type AttachmentKey, 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 ChatMessageOriginalResponse, 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 MediaIndex, type MediaRef, MediaStore, type MenuChannel, type MenuItem, type MenuResponse, type MenusRoutingInputs, type MessageRequest, type MessageResponse, MessageType, MicPermissionDeniedError, type MicPermissionState, NoActiveVoiceCallError, NotiEvent, OPTIONS, OperationHoursError, type PdfStatusResponse, PostSessionStatus, type ProviderContext, ProviderError, ProviderType, type QuestionItem, RISK_FLAG_EVENTS, type RateRequest, type RecordingOption, type RecordingPermission, type RefusedBy, type RequestMethod, type RequestReturn, type ServerAuthResponse, type ServerVoiceCallStatus, SmartActionError, type SmartActionMediaType, type SmartActionResponse, type SmartActionType, type SurveyAnswers, type TokenResponse, type TriggerItem, type TriggerMessage, type UjetConversationHistoryQuery, type UjetConversationHistoryResponse, type UjetConversationMessageItem, UnauthorizedError, UnknownVoiceError, type UserProfile, UserType, 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, toIdentity };
1631
+ export { AnotherTabVoiceCallError, type AttachmentKey, 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 ChatMessageOriginalResponse, 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 MediaIndex, type MediaRef, MediaStore, type MenuChannel, type MenuItem, type MenuResponse, type MenusRoutingInputs, type MessageRequest, type MessageResponse, MessageType, MicPermissionDeniedError, type MicPermissionState, NoActiveVoiceCallError, NotiEvent, OPTIONS, OperationHoursError, type OutgoingFileStatus, type OutgoingMessageStatus, type OutgoingTextStatus, type PdfStatusResponse, PostSessionStatus, type ProviderContext, ProviderError, ProviderType, type QuestionItem, RISK_FLAG_EVENTS, type RateRequest, type RecordingOption, type RecordingPermission, type RefusedBy, type RequestMethod, type RequestReturn, type SendFailure, type SendFailureReason, type SendStatus, type ServerAuthResponse, type ServerVoiceCallStatus, SmartActionError, type SmartActionMediaType, type SmartActionResponse, type SmartActionType, type SurveyAnswers, type TokenResponse, type TriggerItem, type TriggerMessage, type UjetConversationHistoryQuery, type UjetConversationHistoryResponse, type UjetConversationMessageItem, UnauthorizedError, UnknownVoiceError, type UserProfile, UserType, 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, toIdentity };