@botpress/webchat 4.3.2 → 4.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/.storybook/main.ts +10 -27
- package/.storybook/preview.tsx +2 -2
- package/.turbo/turbo-build.log +8 -8
- package/ARCHITECTURE.md +737 -0
- package/dist/index.d.ts +247 -38
- package/dist/index.js +15362 -9400
- package/dist/index.umd.cjs +122 -113
- package/dist/style.css +1 -1
- package/package.json +13 -14
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { ComponentProps as ComponentProps_2 } from '../../node_modules/@types/re
|
|
|
6
6
|
import { ComponentPropsWithRef } from '../../node_modules/@types/react';
|
|
7
7
|
import { LatestWebchatConfig as Configuration } from '@bpinternal/shared';
|
|
8
8
|
import { Context } from '../../node_modules/@types/react';
|
|
9
|
+
import { createEventEmitter } from '@bpinternal/shared';
|
|
9
10
|
import { CSSProperties } from '../../node_modules/@types/react';
|
|
10
11
|
import * as Dialog from '@radix-ui/react-dialog';
|
|
11
12
|
import { Dispatch } from '../../node_modules/@types/react';
|
|
@@ -19,6 +20,7 @@ import { IntegrationError } from '@botpress/webchat-client';
|
|
|
19
20
|
import { JSX } from '../../node_modules/@types/react';
|
|
20
21
|
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
21
22
|
import { LatestWebchatTheme } from '@bpinternal/shared';
|
|
23
|
+
import { ListConversationsResponse } from '@botpress/webchat-client';
|
|
22
24
|
import { MemoExoticComponent } from '../../../node_modules/@types/react';
|
|
23
25
|
import { Message as Message_2 } from '@botpress/webchat-client';
|
|
24
26
|
import { NamedExoticComponent } from '../../../node_modules/@types/react';
|
|
@@ -140,7 +142,7 @@ export declare type CarouselBlock = {
|
|
|
140
142
|
blocks: GenericBlock[];
|
|
141
143
|
};
|
|
142
144
|
|
|
143
|
-
export declare const Chat: ({ connected, configuration, isTyping, messages, user, isLoading, renderers, isReadOnly, disableComposer,
|
|
145
|
+
export declare const Chat: ({ connected, configuration, isTyping, messages, user, isLoading, renderers, isReadOnly, disableComposer, error, participants, closeWindow, sendMessage, uploadFile, addMessageFeedback, listConversations, restartConversation, clientId, storageKey, soundOn, toggleSound, disableSendButton, conversationId, ...props }: Props) => JSX_2.Element;
|
|
144
146
|
|
|
145
147
|
declare type ChatSoundStore = {
|
|
146
148
|
soundOn: boolean;
|
|
@@ -148,6 +150,10 @@ declare type ChatSoundStore = {
|
|
|
148
150
|
toggleSound: () => void;
|
|
149
151
|
};
|
|
150
152
|
|
|
153
|
+
export declare type ClientStates = 'connecting' | 'connected' | 'error' | 'disconnected';
|
|
154
|
+
|
|
155
|
+
declare type ClientStates_2 = 'connecting' | 'connected' | 'error' | 'disconnected';
|
|
156
|
+
|
|
151
157
|
export declare type ColumnBlock = {
|
|
152
158
|
type: 'column';
|
|
153
159
|
blocks: GenericBlock[];
|
|
@@ -172,6 +178,17 @@ export declare type CommonBlockProps = Pick<RichBlockMessage, 'direction' | 'sen
|
|
|
172
178
|
addMessageFeedback?: (messageId: string, feedback: Feedback) => void;
|
|
173
179
|
};
|
|
174
180
|
|
|
181
|
+
declare type CommonWebchatProps = {
|
|
182
|
+
on: EventEmitter<Events>['on'];
|
|
183
|
+
messages: BlockMessage[];
|
|
184
|
+
newConversation: (conversationId?: string) => void;
|
|
185
|
+
participants: User[];
|
|
186
|
+
soundOn: boolean;
|
|
187
|
+
toggleSound: () => void;
|
|
188
|
+
disableSendButton: boolean;
|
|
189
|
+
error?: WebchatError;
|
|
190
|
+
};
|
|
191
|
+
|
|
175
192
|
export declare type ComposableIntegrationMessagePayload = Extract<IntegrationMessage['payload'], ToPayloadType<ComposableIntegrationMessageTypes>>;
|
|
176
193
|
|
|
177
194
|
declare type ComposableIntegrationMessageTypes = 'audio' | 'bloc' | 'file' | 'image' | 'location' | 'markdown' | 'text' | 'video';
|
|
@@ -183,10 +200,36 @@ export declare const CONFIG_ACCESS_DENIED = "Access denied to configuration file
|
|
|
183
200
|
export { Configuration }
|
|
184
201
|
|
|
185
202
|
export declare const Container: {
|
|
186
|
-
({ children, className, uploadFile, allowFileUpload, storageKey, ...props }: Props_4): JSX_2.Element;
|
|
203
|
+
({ children, className, uploadFile, allowFileUpload, storageKey, conversationId, ...props }: Props_4): JSX_2.Element;
|
|
204
|
+
displayName: string;
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
export declare const ConversationHistory: {
|
|
208
|
+
({ className, onConversationClick, onNewConversation, onClose, currentConversationId, isLoading, conversations, botAvatar, botName, ...props }: ComponentProps<"div"> & ConversationHistoryProps): JSX_2.Element;
|
|
187
209
|
displayName: string;
|
|
188
210
|
};
|
|
189
211
|
|
|
212
|
+
declare type ConversationHistoryProps = {
|
|
213
|
+
onConversationClick?: (conversationId: string) => void;
|
|
214
|
+
onNewConversation?: () => void;
|
|
215
|
+
onClose?: () => void;
|
|
216
|
+
currentConversationId?: string;
|
|
217
|
+
isLoading?: boolean;
|
|
218
|
+
conversations: Conversations;
|
|
219
|
+
botAvatar?: string;
|
|
220
|
+
botName?: string;
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
declare type Conversations = ConversationWithLastMessage[];
|
|
224
|
+
|
|
225
|
+
declare type ConversationWithLastMessage = ListConversationsResponse['conversations'][number] & {
|
|
226
|
+
lastMessage: NonNullable<ListConversationsResponse['conversations'][number]['lastMessage']> & {
|
|
227
|
+
author: {
|
|
228
|
+
type: 'bot' | 'user';
|
|
229
|
+
};
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
|
|
190
233
|
declare const createChatSoundStore: (storeName: string) => UseBoundStore<Omit<Omit<StoreApi<ChatSoundStore>, "setState"> & {
|
|
191
234
|
setState<A extends string | {
|
|
192
235
|
type: unknown;
|
|
@@ -288,12 +331,13 @@ export declare const getUseChatSoundStore: (name?: string) => BoundChatSoundStor
|
|
|
288
331
|
|
|
289
332
|
export declare const getUseWebchatClientStore: (name?: string, storageLocation?: StorageLocation) => BoundWebchatClientStore;
|
|
290
333
|
|
|
291
|
-
export declare const Header: ({ defaultOpen, closeWindow, configuration, restartConversation, disabled, soundOn, toggleSound, clientId, ...props }: HeaderProps) => JSX_2.Element;
|
|
334
|
+
export declare const Header: ({ defaultOpen, closeWindow, configuration, restartConversation, showConversationHistory, disabled, soundOn, toggleSound, clientId, ...props }: HeaderProps) => JSX_2.Element;
|
|
292
335
|
|
|
293
336
|
declare type HeaderProps = {
|
|
294
337
|
defaultOpen?: boolean;
|
|
295
338
|
open?: boolean;
|
|
296
339
|
disabled?: boolean;
|
|
340
|
+
showConversationHistory?: () => void;
|
|
297
341
|
onOpenChange?(open: boolean): void;
|
|
298
342
|
restartConversation?: () => void;
|
|
299
343
|
closeWindow?: () => void;
|
|
@@ -472,22 +516,20 @@ export declare type Props = {
|
|
|
472
516
|
isReadOnly?: boolean;
|
|
473
517
|
isLoading?: boolean;
|
|
474
518
|
isTyping?: boolean;
|
|
475
|
-
lastTypingHeartbeat?: Date | null;
|
|
476
|
-
allowFileUpload?: boolean;
|
|
477
519
|
clientId?: string;
|
|
478
520
|
closeWindow?: () => void;
|
|
479
|
-
restartConversation?: () => void;
|
|
480
|
-
user?:
|
|
481
|
-
id: string;
|
|
482
|
-
} & Record<string, unknown>;
|
|
521
|
+
restartConversation?: (conversationid?: string) => void;
|
|
522
|
+
user?: UserCredentials;
|
|
483
523
|
sendMessage?: ScopedClient['sendMessage'];
|
|
484
524
|
uploadFile?: ScopedClient['uploadFile'];
|
|
485
525
|
addMessageFeedback?: ScopedClient['addMessageFeedback'];
|
|
526
|
+
listConversations?: ScopedClient['listConversations'];
|
|
486
527
|
error?: WebchatError;
|
|
487
528
|
soundOn?: boolean;
|
|
488
529
|
toggleSound?: () => void;
|
|
489
|
-
disableSendButton?: boolean;
|
|
490
530
|
storageKey?: string;
|
|
531
|
+
disableSendButton?: boolean;
|
|
532
|
+
conversationId?: string;
|
|
491
533
|
};
|
|
492
534
|
|
|
493
535
|
declare type Props_2 = {
|
|
@@ -500,6 +542,7 @@ declare type Props_2 = {
|
|
|
500
542
|
storageKey?: string;
|
|
501
543
|
storageLocation?: StorageLocation;
|
|
502
544
|
soundEnabled?: boolean;
|
|
545
|
+
clientHeaders?: Record<string, string>;
|
|
503
546
|
};
|
|
504
547
|
|
|
505
548
|
declare type Props_3 = ComponentProps<'div'> & {
|
|
@@ -512,6 +555,7 @@ declare type Props_3 = ComponentProps<'div'> & {
|
|
|
512
555
|
sendMessage?: ScopedClient['sendMessage'];
|
|
513
556
|
uploadFile?: ScopedClient['uploadFile'];
|
|
514
557
|
storageKey?: string;
|
|
558
|
+
conversationId?: string;
|
|
515
559
|
} & Pick<Configuration, 'composerPlaceholder' | 'footer'>;
|
|
516
560
|
|
|
517
561
|
declare type Props_4 = ComponentProps<'div'> & {
|
|
@@ -519,6 +563,7 @@ declare type Props_4 = ComponentProps<'div'> & {
|
|
|
519
563
|
uploadFile?: ScopedClient['uploadFile'];
|
|
520
564
|
allowFileUpload?: boolean;
|
|
521
565
|
storageKey?: string;
|
|
566
|
+
conversationId?: string;
|
|
522
567
|
};
|
|
523
568
|
|
|
524
569
|
declare type Props_5 = {
|
|
@@ -534,7 +579,10 @@ declare type Props_6 = {
|
|
|
534
579
|
configuration?: Configuration;
|
|
535
580
|
soundOn?: boolean;
|
|
536
581
|
toggleSound?: () => void;
|
|
537
|
-
|
|
582
|
+
/** @deprecated This prop is no longer used, pass the allowFileUpload via the configuration object */
|
|
583
|
+
allowFileUpload?: boolean;
|
|
584
|
+
renderers?: Partial<Renderers>;
|
|
585
|
+
} & ComponentProps_2<'div'>;
|
|
538
586
|
|
|
539
587
|
declare type Props_7 = Partial<LatestWebchatTheme>;
|
|
540
588
|
|
|
@@ -569,7 +617,7 @@ export declare type RowOf<T extends GenericBlock> = Omit<RowBlock, 'blocks'> & {
|
|
|
569
617
|
blocks: T[];
|
|
570
618
|
};
|
|
571
619
|
|
|
572
|
-
declare type ScopedClient = {
|
|
620
|
+
export declare type ScopedClient = {
|
|
573
621
|
sendMessage: (payload: IntegrationMessage['payload']) => Promise<void>;
|
|
574
622
|
sendEvent: (event: Record<string, any>, options?: {
|
|
575
623
|
bindConversation?: boolean;
|
|
@@ -584,15 +632,20 @@ declare type ScopedClient = {
|
|
|
584
632
|
addMessageFeedback: (messageId: string, feedback: Feedback) => Promise<void>;
|
|
585
633
|
getUser: () => Promise<UserResponse>;
|
|
586
634
|
updateUser: (user: UserProfile) => Promise<User>;
|
|
635
|
+
listConversations: () => ReturnType<Client['listConversations']>;
|
|
587
636
|
};
|
|
588
637
|
|
|
638
|
+
export declare const _setDebugEnabled: (enabled: boolean) => void;
|
|
639
|
+
|
|
640
|
+
export declare const _setTrackFn: (fn: typeof _trackFn) => void;
|
|
641
|
+
|
|
589
642
|
export declare const SOUND_EFFECTS: {
|
|
590
643
|
readonly chatMessageNotification: string;
|
|
591
644
|
};
|
|
592
645
|
|
|
593
646
|
export declare const SSE_DISCONNECTED_ERROR = "You've been disconnected from the conversation.\nPlease refresh the page.";
|
|
594
647
|
|
|
595
|
-
declare type StorageLocation = 'sessionStorage' | 'localStorage';
|
|
648
|
+
export declare type StorageLocation = 'sessionStorage' | 'localStorage';
|
|
596
649
|
|
|
597
650
|
export declare type StyleOptions = {
|
|
598
651
|
className?: string;
|
|
@@ -616,8 +669,57 @@ declare type ToPayloadType<T extends IntegrationMessageTypes> = {
|
|
|
616
669
|
};
|
|
617
670
|
}[T];
|
|
618
671
|
|
|
672
|
+
declare let _trackFn: ((event: string, properties?: Record<string, unknown>) => void) | null;
|
|
673
|
+
|
|
619
674
|
export declare const TypingIndicator: MemoExoticComponent<({ ...props }: ComponentProps<"div">) => JSX_2.Element>;
|
|
620
675
|
|
|
676
|
+
export declare function useActiveConversation(): UseActiveConversationReturn;
|
|
677
|
+
|
|
678
|
+
declare type UseActiveConversationReturn = {
|
|
679
|
+
conversationId?: string;
|
|
680
|
+
messages: BlockMessage[];
|
|
681
|
+
participants: User[];
|
|
682
|
+
sendMessage: (payload: IntegrationMessage['payload']) => Promise<void>;
|
|
683
|
+
saveMessageFeedback: (messageId: string, feedback: Feedback) => Promise<void>;
|
|
684
|
+
sendEvent: (event: Record<string, unknown>, options?: {
|
|
685
|
+
bindConversation?: boolean;
|
|
686
|
+
bindUser?: boolean;
|
|
687
|
+
}) => Promise<void>;
|
|
688
|
+
uploadFile: (file: File) => Promise<{
|
|
689
|
+
fileUrl: string;
|
|
690
|
+
name: string;
|
|
691
|
+
type: FileType;
|
|
692
|
+
fileId: string;
|
|
693
|
+
}>;
|
|
694
|
+
status: ClientStates;
|
|
695
|
+
on: ReturnType<typeof createEventEmitter<Events>>['on'];
|
|
696
|
+
error?: WebchatError;
|
|
697
|
+
isTyping: boolean;
|
|
698
|
+
isAwaitingResponse: boolean;
|
|
699
|
+
};
|
|
700
|
+
|
|
701
|
+
export declare function useConversationList({ userCredentials, listConversations, clientId, }: UseConversationListParams): UseConversationListReturn;
|
|
702
|
+
|
|
703
|
+
declare type UseConversationListParams = {
|
|
704
|
+
userCredentials?: UserCredentials;
|
|
705
|
+
listConversations?: Client['listConversations'];
|
|
706
|
+
clientId?: string;
|
|
707
|
+
};
|
|
708
|
+
|
|
709
|
+
declare type UseConversationListReturn = {
|
|
710
|
+
conversations: Conversations;
|
|
711
|
+
isLoading: boolean;
|
|
712
|
+
error?: WebchatError;
|
|
713
|
+
refresh: () => Promise<Conversations | undefined>;
|
|
714
|
+
};
|
|
715
|
+
|
|
716
|
+
export declare function useConversations(): UseConversationsReturn;
|
|
717
|
+
|
|
718
|
+
declare type UseConversationsReturn = {
|
|
719
|
+
listConversations?: () => Promise<ListConversationsResponse>;
|
|
720
|
+
openConversation: (conversationId?: string) => void;
|
|
721
|
+
};
|
|
722
|
+
|
|
621
723
|
export declare type UseImageSizeResult = [Dimensions | null, {
|
|
622
724
|
loading: boolean;
|
|
623
725
|
error: string | null;
|
|
@@ -627,41 +729,56 @@ export declare function useMessageContext(): MessageContextVaue;
|
|
|
627
729
|
|
|
628
730
|
export declare function useModalContext(): ModalContextValue;
|
|
629
731
|
|
|
630
|
-
|
|
732
|
+
export { User }
|
|
733
|
+
|
|
734
|
+
export declare type UserProfile = Omit<User, 'id' | 'createdAt' | 'updatedAt'>;
|
|
735
|
+
|
|
736
|
+
export declare type UserResponse = Awaited<ReturnType<Client['getUser']>>['user'];
|
|
737
|
+
|
|
738
|
+
export declare const useUser: () => UseUserReturn;
|
|
631
739
|
|
|
632
|
-
declare type
|
|
740
|
+
declare type UseUserReturn = {
|
|
741
|
+
getUser?: () => Promise<UserResponse>;
|
|
742
|
+
updateUser?: (user: UserProfile) => Promise<User>;
|
|
743
|
+
userCredentials?: UserCredentials;
|
|
744
|
+
};
|
|
633
745
|
|
|
634
|
-
|
|
746
|
+
/**
|
|
747
|
+
* @deprecated This hook is deprecated. Use WebchatProvider with useActiveConversation, useConversations, and useUser instead.
|
|
748
|
+
*
|
|
749
|
+
* Migration guide:
|
|
750
|
+
* ```typescript
|
|
751
|
+
* // Old:
|
|
752
|
+
* const { messages, sendMessage, client } = useWebchat({ clientId, ... })
|
|
753
|
+
*
|
|
754
|
+
* // New:
|
|
755
|
+
* <WebchatProvider clientId={clientId} ...>
|
|
756
|
+
* const { messages, sendMessage } = useActiveConversation()
|
|
757
|
+
* const { listConversations, openConversation } = useConversations()
|
|
758
|
+
* const { getUser, updateUser } = useUser()
|
|
759
|
+
* </WebchatProvider>
|
|
760
|
+
* ```
|
|
761
|
+
*/
|
|
762
|
+
export declare function useWebchat({ apiUrl, clientId, storageKey, storageLocation, adminSecret, soundEnabled, clientHeaders, ...props }: Props_2): UseWebchatReturn;
|
|
635
763
|
|
|
636
|
-
declare
|
|
764
|
+
export declare function useWebchatContext(): WebchatContextValue;
|
|
765
|
+
|
|
766
|
+
/**
|
|
767
|
+
* @deprecated Use WebchatProvider with useActiveConversation, useConversations, and useUser instead
|
|
768
|
+
*/
|
|
769
|
+
declare type UseWebchatReturn = (CommonWebchatProps & {
|
|
637
770
|
clientState: 'connected';
|
|
638
|
-
on: EventEmitter<Events>['on'];
|
|
639
771
|
client: ScopedClient;
|
|
640
|
-
messages: BlockMessage[];
|
|
641
772
|
conversationId: string;
|
|
642
|
-
newConversation: () => Promise<void>;
|
|
643
773
|
user?: UserCredentials;
|
|
644
774
|
isTyping: boolean;
|
|
645
|
-
|
|
646
|
-
soundOn: boolean;
|
|
647
|
-
toggleSound: () => void;
|
|
648
|
-
disableSendButton: boolean;
|
|
649
|
-
error?: WebchatError;
|
|
650
|
-
} | {
|
|
775
|
+
}) | (CommonWebchatProps & {
|
|
651
776
|
clientState: 'connecting' | 'error' | 'disconnected';
|
|
652
|
-
on: EventEmitter<Events>['on'];
|
|
653
777
|
client: undefined;
|
|
654
|
-
messages: BlockMessage[];
|
|
655
778
|
conversationId: undefined;
|
|
656
|
-
newConversation: () => Promise<void>;
|
|
657
779
|
user: undefined;
|
|
658
780
|
isTyping: undefined;
|
|
659
|
-
|
|
660
|
-
soundOn: boolean;
|
|
661
|
-
toggleSound: () => void;
|
|
662
|
-
disableSendButton: boolean;
|
|
663
|
-
error?: WebchatError;
|
|
664
|
-
};
|
|
781
|
+
});
|
|
665
782
|
|
|
666
783
|
export declare const useWebchatStore: UseBoundStore<Omit<StoreApi<WebchatStore>, "setState"> & {
|
|
667
784
|
setState<A extends string | {
|
|
@@ -676,7 +793,7 @@ export declare type VideoBlock = {
|
|
|
676
793
|
url: string;
|
|
677
794
|
};
|
|
678
795
|
|
|
679
|
-
export declare const Webchat: ({ clientId, storageKey, configuration,
|
|
796
|
+
export declare const Webchat: ({ clientId, storageKey, configuration, apiUrl, user: userCredentials, conversationId, ...props }: Props_6) => JSX_2.Element;
|
|
680
797
|
|
|
681
798
|
export declare const webchatClasses: {
|
|
682
799
|
readonly container: {
|
|
@@ -786,6 +903,9 @@ export declare const webchatClasses: {
|
|
|
786
903
|
readonly container: {
|
|
787
904
|
readonly className: "bpReset bpHeaderContentContainer";
|
|
788
905
|
};
|
|
906
|
+
readonly conversationHistory: {
|
|
907
|
+
readonly className: "bpHeaderConversationHistoryButton";
|
|
908
|
+
};
|
|
789
909
|
readonly title: {
|
|
790
910
|
readonly className: "bpHeaderContentTitle";
|
|
791
911
|
};
|
|
@@ -1202,12 +1322,69 @@ export declare const webchatClasses: {
|
|
|
1202
1322
|
readonly className: "bpProactiveBubbleArrow";
|
|
1203
1323
|
};
|
|
1204
1324
|
};
|
|
1325
|
+
readonly conversationHistory: {
|
|
1326
|
+
readonly container: {
|
|
1327
|
+
readonly className: "bpReset bpConversationHistoryContainer bpFont";
|
|
1328
|
+
};
|
|
1329
|
+
readonly header: {
|
|
1330
|
+
readonly className: "bpConversationHistoryHeader";
|
|
1331
|
+
};
|
|
1332
|
+
readonly closeButton: {
|
|
1333
|
+
readonly className: "bpConversationHistoryCloseButton";
|
|
1334
|
+
};
|
|
1335
|
+
readonly scrollContainer: {
|
|
1336
|
+
readonly className: "bpConversationHistoryScrollContainer";
|
|
1337
|
+
};
|
|
1338
|
+
readonly loaderContainer: {
|
|
1339
|
+
readonly className: "bpConversationHistoryLoaderContainer";
|
|
1340
|
+
};
|
|
1341
|
+
readonly conversation: {
|
|
1342
|
+
readonly container: {
|
|
1343
|
+
readonly className: "bpConversationHistoryConversationContainer";
|
|
1344
|
+
};
|
|
1345
|
+
readonly chevron: {
|
|
1346
|
+
readonly className: "bpConversationHistoryConversationChevron";
|
|
1347
|
+
};
|
|
1348
|
+
readonly userAvatar: {
|
|
1349
|
+
readonly className: {
|
|
1350
|
+
readonly className: "bpConversationHistoryConversationUserAvatarFallback";
|
|
1351
|
+
};
|
|
1352
|
+
};
|
|
1353
|
+
readonly avatar: {
|
|
1354
|
+
readonly container: {
|
|
1355
|
+
readonly className: "bpReset bpConversationHistoryConversationAvatarContainer";
|
|
1356
|
+
};
|
|
1357
|
+
readonly image: {
|
|
1358
|
+
readonly className: "bpConversationHistoryConversationAvatarImage";
|
|
1359
|
+
};
|
|
1360
|
+
readonly fallback: {
|
|
1361
|
+
readonly className: "bpConversationHistoryConversationAvatarFallback";
|
|
1362
|
+
};
|
|
1363
|
+
};
|
|
1364
|
+
readonly content: {
|
|
1365
|
+
readonly className: "bpConversationHistoryConversationContent";
|
|
1366
|
+
};
|
|
1367
|
+
readonly name: {
|
|
1368
|
+
readonly className: "bpConversationHistoryConversationName";
|
|
1369
|
+
};
|
|
1370
|
+
readonly timestamp: {
|
|
1371
|
+
readonly className: "bpConversationHistoryConversationTimestamp";
|
|
1372
|
+
};
|
|
1373
|
+
};
|
|
1374
|
+
readonly newConversation: {
|
|
1375
|
+
readonly button: {
|
|
1376
|
+
readonly className: "bpConversationHistoryNewConversationButton";
|
|
1377
|
+
};
|
|
1378
|
+
readonly icon: {
|
|
1379
|
+
readonly className: "bpConversationHistoryNewConversationButtonIcon";
|
|
1380
|
+
};
|
|
1381
|
+
};
|
|
1382
|
+
};
|
|
1205
1383
|
};
|
|
1206
1384
|
|
|
1207
1385
|
declare type WebchatClientActions = {
|
|
1208
1386
|
setUser: (userId?: UserCredentials) => void;
|
|
1209
|
-
setConversationId: (conversationId
|
|
1210
|
-
clearConversationId: () => void;
|
|
1387
|
+
setConversationId: (conversationId?: string) => void;
|
|
1211
1388
|
clearAll: () => void;
|
|
1212
1389
|
};
|
|
1213
1390
|
|
|
@@ -1218,6 +1395,24 @@ export declare type WebchatClientState = {
|
|
|
1218
1395
|
|
|
1219
1396
|
declare type WebchatClientStore = WebchatClientState & WebchatClientActions;
|
|
1220
1397
|
|
|
1398
|
+
export declare type WebchatContextValue = {
|
|
1399
|
+
client: Client | undefined;
|
|
1400
|
+
userCredentials: UserCredentials | undefined;
|
|
1401
|
+
conversationId: string | undefined;
|
|
1402
|
+
openConversation: (params: {
|
|
1403
|
+
conversationId?: string;
|
|
1404
|
+
userToken?: string;
|
|
1405
|
+
}) => Promise<void>;
|
|
1406
|
+
clientState: ClientStates_2;
|
|
1407
|
+
setClientState: (state: ClientStates_2) => void;
|
|
1408
|
+
error: WebchatError | undefined;
|
|
1409
|
+
setError: (error?: WebchatError) => void;
|
|
1410
|
+
isTyping: boolean;
|
|
1411
|
+
isAwaitingResponse: boolean;
|
|
1412
|
+
setAwaitingResponse: (state: boolean, timeout?: number) => void;
|
|
1413
|
+
emitter: ReturnType<typeof createEventEmitter<Events>>;
|
|
1414
|
+
};
|
|
1415
|
+
|
|
1221
1416
|
export declare type WebchatError = ({
|
|
1222
1417
|
type: 'configuration';
|
|
1223
1418
|
message: typeof MISSING_CLIENT_ID | typeof MISSING_API_URL | typeof MISSING_BOT_ID | typeof INVALID_CLIENT_ID | typeof INVALID_CONFIGURATION | typeof MISSING_CONFIG_URL;
|
|
@@ -1250,6 +1445,20 @@ export declare type WebchatEvents = {
|
|
|
1250
1445
|
participantRemoved: string;
|
|
1251
1446
|
};
|
|
1252
1447
|
|
|
1448
|
+
export declare function WebchatProvider({ clientId, apiUrl, storageKey, storageLocation, adminSecret, clientHeaders, children, ...props }: WebchatProviderProps): JSX_2.Element;
|
|
1449
|
+
|
|
1450
|
+
declare type WebchatProviderProps = {
|
|
1451
|
+
clientId: string;
|
|
1452
|
+
apiUrl?: string;
|
|
1453
|
+
userCredentials?: UserCredentials;
|
|
1454
|
+
conversationId?: string;
|
|
1455
|
+
adminSecret?: string;
|
|
1456
|
+
storageKey?: string;
|
|
1457
|
+
storageLocation?: StorageLocation;
|
|
1458
|
+
clientHeaders?: Record<string, string>;
|
|
1459
|
+
children: ReactNode_2;
|
|
1460
|
+
};
|
|
1461
|
+
|
|
1253
1462
|
declare type WebchatStore = {
|
|
1254
1463
|
messageContainerRef: RefObject<HTMLDivElement | null>;
|
|
1255
1464
|
setMessageContainerRef: (ref: RefObject<HTMLDivElement | null>) => void;
|