@ujet/websdk-headless 6.5.1 → 6.8.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 +91 -10
- package/dist/index.js +60 -60
- package/dist/index.mjs +5938 -5818
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -170,8 +170,12 @@ interface ChatDocumentItem {
|
|
|
170
170
|
media_id: number;
|
|
171
171
|
url: string;
|
|
172
172
|
}
|
|
173
|
+
/** Attachment pairing key: a provider-assigned sequence number, or a `{type}-{media_id}` string. */
|
|
174
|
+
type AttachmentKey = number | string;
|
|
175
|
+
/** @deprecated Renamed — use {@link AttachmentKey}. */
|
|
176
|
+
type MediaIndex = AttachmentKey;
|
|
173
177
|
interface MessageResponse {
|
|
174
|
-
$index:
|
|
178
|
+
$index: AttachmentKey;
|
|
175
179
|
$sid: string;
|
|
176
180
|
$timestamp: Date;
|
|
177
181
|
$userId: number;
|
|
@@ -612,6 +616,50 @@ declare class EventManager {
|
|
|
612
616
|
destroy(): void;
|
|
613
617
|
}
|
|
614
618
|
|
|
619
|
+
/** A page of stored conversation messages, newest first. */
|
|
620
|
+
interface UjetConversationMessageItem {
|
|
621
|
+
message_id: string;
|
|
622
|
+
data: Record<string, any>;
|
|
623
|
+
user: string;
|
|
624
|
+
published_at: string;
|
|
625
|
+
}
|
|
626
|
+
interface UjetConversationHistoryQuery {
|
|
627
|
+
limit?: number;
|
|
628
|
+
/** `next_cursor` from the previous page, or the oldest `message_id` seen. */
|
|
629
|
+
before?: string;
|
|
630
|
+
}
|
|
631
|
+
interface UjetConversationHistoryResponse {
|
|
632
|
+
messages: UjetConversationMessageItem[];
|
|
633
|
+
next_cursor: string | null;
|
|
634
|
+
has_more: boolean;
|
|
635
|
+
last_published_at: string | null;
|
|
636
|
+
last_persisted_at: string | null;
|
|
637
|
+
/** Set when a publish has not been persisted yet; re-query after this delay. */
|
|
638
|
+
retry_after_ms: number | null;
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Backend-derived capabilities a provider cannot obtain on its own. Twilio's
|
|
642
|
+
* vendor SDK supplied all of these itself and needed only `issueChatToken`;
|
|
643
|
+
* a generic pub/sub client needs the address, the credential and the history
|
|
644
|
+
* endpoint handed to it.
|
|
645
|
+
*
|
|
646
|
+
* The channel id is deliberately absent: it is assigned asynchronously after
|
|
647
|
+
* the chat is created, so keeping it out lets a context be built before one
|
|
648
|
+
* exists — it arrives later as the `join(sid)` argument instead. Everything
|
|
649
|
+
* else is per-chat, `fetchHistory` included; it reads the history of the chat
|
|
650
|
+
* the context was built for.
|
|
651
|
+
*/
|
|
652
|
+
interface ProviderContext {
|
|
653
|
+
/**
|
|
654
|
+
* A token that will still be valid at the far end of the caller's next hop.
|
|
655
|
+
* Pass `forceRefresh` after a rejected connection so a token that merely
|
|
656
|
+
* looks fresh is not offered again.
|
|
657
|
+
*/
|
|
658
|
+
getAuthToken: (forceRefresh?: boolean) => Promise<string>;
|
|
659
|
+
wsUrl: string;
|
|
660
|
+
fetchHistory: (query: UjetConversationHistoryQuery) => Promise<UjetConversationHistoryResponse>;
|
|
661
|
+
}
|
|
662
|
+
|
|
615
663
|
declare abstract class BaseProvider {
|
|
616
664
|
static type: string;
|
|
617
665
|
private audio;
|
|
@@ -621,8 +669,15 @@ declare abstract class BaseProvider {
|
|
|
621
669
|
region?: string;
|
|
622
670
|
inTask: boolean;
|
|
623
671
|
muted: boolean;
|
|
672
|
+
/** Undefined for providers whose backend needs supply no context. */
|
|
673
|
+
providerContext?: ProviderContext;
|
|
624
674
|
events: EventManager;
|
|
625
|
-
constructor(events: EventManager, state: ChatResponse, issueChatToken: IssueChatTokenMethod);
|
|
675
|
+
constructor(events: EventManager, state: ChatResponse, issueChatToken: IssueChatTokenMethod, providerContext?: ProviderContext);
|
|
676
|
+
/**
|
|
677
|
+
* Re-establish a connection the transport could not recover by itself.
|
|
678
|
+
* Providers whose vendor SDK owns reconnection leave this alone.
|
|
679
|
+
*/
|
|
680
|
+
reconnect(): Promise<void>;
|
|
626
681
|
ping(): void;
|
|
627
682
|
/**
|
|
628
683
|
* Cleanup audio resources by removing event listeners.
|
|
@@ -637,9 +692,9 @@ declare abstract class BaseProvider {
|
|
|
637
692
|
abstract join(sid: string): Promise<void>;
|
|
638
693
|
abstract preview(text: string): Promise<void>;
|
|
639
694
|
abstract fetchMessages(files: {
|
|
640
|
-
[index:
|
|
695
|
+
[index: AttachmentKey]: File;
|
|
641
696
|
}): Promise<MessageResponse[]>;
|
|
642
|
-
abstract sendMessage(message: MessageRequest): Promise<
|
|
697
|
+
abstract sendMessage(message: MessageRequest): Promise<AttachmentKey>;
|
|
643
698
|
abstract startTyping(): void;
|
|
644
699
|
abstract stopTyping(): void;
|
|
645
700
|
abstract registerConversationEvents(): void;
|
|
@@ -663,7 +718,7 @@ declare class Chat {
|
|
|
663
718
|
private hooks;
|
|
664
719
|
private leaveSent;
|
|
665
720
|
private beaconAttempted;
|
|
666
|
-
constructor(state: ChatResponse, issueChatToken: IssueChatTokenMethod, hooks?: ChatHooks);
|
|
721
|
+
constructor(state: ChatResponse, issueChatToken: IssueChatTokenMethod, hooks?: ChatHooks, providerContext?: ProviderContext);
|
|
667
722
|
get id(): number;
|
|
668
723
|
get menuId(): number;
|
|
669
724
|
get channelId(): string;
|
|
@@ -702,12 +757,16 @@ declare class Chat {
|
|
|
702
757
|
private sendLeave;
|
|
703
758
|
leaveBeacon(): void;
|
|
704
759
|
resetBeaconState(): void;
|
|
760
|
+
/**
|
|
761
|
+
* Narrowed on the way out for the same reason as `Client.sendFileMessage`;
|
|
762
|
+
* `chat` is public too. Pairing still uses the provider's wide key.
|
|
763
|
+
*/
|
|
705
764
|
sendMessage(message: MessageRequest, file?: File): Promise<number>;
|
|
706
765
|
preview(text: string): Promise<void>;
|
|
707
766
|
fetchMessages(): Promise<MessageResponse[]>;
|
|
708
767
|
startTyping(): void;
|
|
709
768
|
stopTyping(): void;
|
|
710
|
-
saveMedia(index:
|
|
769
|
+
saveMedia(index: AttachmentKey, file: File): void;
|
|
711
770
|
destroy(): Promise<void>;
|
|
712
771
|
clearMediaStore(): Promise<void>;
|
|
713
772
|
private triggerEvent;
|
|
@@ -724,6 +783,28 @@ declare class ChatEndedError extends Error {
|
|
|
724
783
|
constructor(status?: string);
|
|
725
784
|
}
|
|
726
785
|
|
|
786
|
+
/** Which side turned the authentication down. */
|
|
787
|
+
type RefusedBy = 'client' | 'server';
|
|
788
|
+
/**
|
|
789
|
+
* Thrown when authentication was refused rather than merely failing in
|
|
790
|
+
* passing. Retrying with the same credentials will not succeed, so callers
|
|
791
|
+
* should surface the failure instead of backing off. Transient failures
|
|
792
|
+
* (network, bridge round-trip) reject with their original error.
|
|
793
|
+
*/
|
|
794
|
+
declare class UnauthorizedError extends Error {
|
|
795
|
+
static readonly CODE = "UNAUTHORIZED";
|
|
796
|
+
readonly code = "UNAUTHORIZED";
|
|
797
|
+
/**
|
|
798
|
+
* `client` — the integrator's `authenticate()` callback rejected, which is
|
|
799
|
+
* how a signed-out end user reaches us. `server` — UJET declined the token
|
|
800
|
+
* the callback produced.
|
|
801
|
+
*/
|
|
802
|
+
readonly refusedBy: RefusedBy;
|
|
803
|
+
constructor(message: string, refusedBy: RefusedBy, options?: {
|
|
804
|
+
cause?: unknown;
|
|
805
|
+
});
|
|
806
|
+
}
|
|
807
|
+
|
|
727
808
|
declare global {
|
|
728
809
|
interface Window {
|
|
729
810
|
webkitIndexedDB: IDBFactory;
|
|
@@ -735,13 +816,13 @@ declare global {
|
|
|
735
816
|
declare class MediaStore {
|
|
736
817
|
private db;
|
|
737
818
|
private store;
|
|
738
|
-
save(index:
|
|
819
|
+
save(index: AttachmentKey, file: File): Promise<void>;
|
|
739
820
|
getAll(): Promise<{
|
|
740
|
-
index:
|
|
821
|
+
index: AttachmentKey;
|
|
741
822
|
file: File;
|
|
742
823
|
}[]>;
|
|
743
824
|
getAllFiles(): Promise<{
|
|
744
|
-
[index:
|
|
825
|
+
[index: AttachmentKey]: File;
|
|
745
826
|
}>;
|
|
746
827
|
clear(): Promise<void>;
|
|
747
828
|
}
|
|
@@ -1348,4 +1429,4 @@ declare const COBROWSE_EVENTS: {
|
|
|
1348
1429
|
};
|
|
1349
1430
|
type CobrowseEvent = (typeof COBROWSE_EVENTS)[keyof typeof COBROWSE_EVENTS];
|
|
1350
1431
|
|
|
1351
|
-
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, RISK_FLAG_EVENTS, 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 };
|
|
1432
|
+
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 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, MicPermissionDeniedError, type MicPermissionState, NoActiveVoiceCallError, 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, 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 };
|