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