@botpress/webchat 3.0.0 → 3.1.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/.turbo/turbo-build.log +8 -8
- package/dist/index.d.ts +105 -17
- package/dist/index.js +6926 -6724
- package/dist/index.umd.cjs +105 -90
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
|
|
2
|
-
> @botpress/webchat@3.
|
|
2
|
+
> @botpress/webchat@3.1.0 build /home/runner/work/genisys/genisys/packages/webchat-components
|
|
3
3
|
> vite build
|
|
4
4
|
|
|
5
5
|
[36mvite v5.4.8 [32mbuilding for production...[36m[39m
|
|
6
6
|
transforming...
|
|
7
|
-
[32m✓[39m
|
|
7
|
+
[32m✓[39m 3087 modules transformed.
|
|
8
8
|
rendering chunks...
|
|
9
9
|
|
|
10
10
|
[vite:dts] Start generate declaration files...
|
|
11
11
|
computing gzip size...
|
|
12
|
-
[2mdist/[22m[35mstyle.css [39m[1m[2m
|
|
13
|
-
[2mdist/[22m[36mindex.js [39m[1m[
|
|
12
|
+
[2mdist/[22m[35mstyle.css [39m[1m[2m 46.51 kB[22m[1m[22m[2m │ gzip: 8.57 kB[22m
|
|
13
|
+
[2mdist/[22m[36mindex.js [39m[1m[33m785.47 kB[39m[22m[2m │ gzip: 215.42 kB[22m
|
|
14
14
|
[vite:dts] Start rollup declaration files...
|
|
15
15
|
Analysis will use the bundled TypeScript version 5.4.2
|
|
16
16
|
*** The target project appears to use TypeScript 5.6.2 which is newer than the bundled compiler engine; consider upgrading API Extractor.
|
|
17
|
-
[vite:dts] Declaration files built in
|
|
17
|
+
[vite:dts] Declaration files built in 21718ms.
|
|
18
18
|
|
|
19
|
-
[2mdist/[22m[35mstyle.css [39m[1m[2m
|
|
20
|
-
[2mdist/[22m[36mindex.umd.cjs [39m[1m[
|
|
21
|
-
[32m✓ built in
|
|
19
|
+
[2mdist/[22m[35mstyle.css [39m[1m[2m 46.51 kB[22m[1m[22m[2m │ gzip: 8.57 kB[22m
|
|
20
|
+
[2mdist/[22m[36mindex.umd.cjs [39m[1m[33m524.32 kB[39m[22m[2m │ gzip: 176.34 kB[22m
|
|
21
|
+
[32m✓ built in 29.23s[39m
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { ComponentProps } from 'react';
|
|
|
5
5
|
import { ComponentPropsWithRef } from 'react';
|
|
6
6
|
import { CSSProperties } from 'react';
|
|
7
7
|
import * as Dialog from '@radix-ui/react-dialog';
|
|
8
|
+
import { EventEmitter } from '@bpinternal/shared';
|
|
8
9
|
import type { FC } from 'react';
|
|
9
10
|
import { ForwardRefExoticComponent } from 'react';
|
|
10
11
|
import { HTMLAttributes } from 'react';
|
|
@@ -22,8 +23,8 @@ import { RefObject } from 'react';
|
|
|
22
23
|
import { RotateCcw } from 'lucide-react';
|
|
23
24
|
import { StoreApi } from 'zustand';
|
|
24
25
|
import { UseBoundStore } from 'zustand';
|
|
26
|
+
import { User } from '@botpress/webchat-client';
|
|
25
27
|
import { UserCredentials } from '@botpress/webchat-client';
|
|
26
|
-
import { UserProps } from '@bpinternal/shared';
|
|
27
28
|
|
|
28
29
|
declare type AnyEvent = ValueOf<{
|
|
29
30
|
[K in keyof WebchatEvents]: {
|
|
@@ -66,6 +67,7 @@ export declare type BlockMessage<T = GenericBlock> = {
|
|
|
66
67
|
conversationId?: string;
|
|
67
68
|
authorId?: string;
|
|
68
69
|
disableInput?: boolean;
|
|
70
|
+
status?: 'pending' | 'processing' | 'processed' | 'failed' | 'skipped';
|
|
69
71
|
metadata?: {
|
|
70
72
|
clientMessageId?: string;
|
|
71
73
|
delivered?: boolean;
|
|
@@ -90,6 +92,8 @@ declare type BlockProps<T extends GenericBlock['type']> = {
|
|
|
90
92
|
renderers?: Partial<Renderers>;
|
|
91
93
|
};
|
|
92
94
|
|
|
95
|
+
export declare const BOT_IS_BLOCKED = "This bot is currently blocked or disabled.";
|
|
96
|
+
|
|
93
97
|
declare type BoundWebchatClientStore = ReturnType<typeof createWebchatClientStore>;
|
|
94
98
|
|
|
95
99
|
export declare type BubbleBlock = {
|
|
@@ -118,14 +122,12 @@ declare type ByType<M extends {
|
|
|
118
122
|
}>;
|
|
119
123
|
};
|
|
120
124
|
|
|
121
|
-
declare type CallbackFn<T> = (args: T) => void;
|
|
122
|
-
|
|
123
125
|
export declare type CarouselBlock = {
|
|
124
126
|
type: 'carousel';
|
|
125
127
|
blocks: GenericBlock[];
|
|
126
128
|
};
|
|
127
129
|
|
|
128
|
-
export declare const Chat: ({ connected, configuration,
|
|
130
|
+
export declare const Chat: ({ connected, configuration, isTyping, messages, user, isLoading, renderers, isReadOnly, disableComposer, allowFileUpload, error, participants, closeWindow, sendMessage, uploadFile, addMessageFeedback, restartConversation, ...props }: Props) => JSX_3.Element;
|
|
129
131
|
|
|
130
132
|
export declare type ColumnBlock = {
|
|
131
133
|
type: 'column';
|
|
@@ -142,6 +144,7 @@ export declare type CommonBlockProps = Pick<RichBlockMessage, 'direction' | 'sen
|
|
|
142
144
|
messageId: string;
|
|
143
145
|
metadata?: Record<string, any>;
|
|
144
146
|
isReadOnly?: boolean;
|
|
147
|
+
status?: BlockMessage['status'];
|
|
145
148
|
sendMessage?: (payload: IntegrationMessage['payload']) => void;
|
|
146
149
|
addMessageFeedback?: (messageId: string, feedback: Feedback) => void;
|
|
147
150
|
};
|
|
@@ -152,6 +155,8 @@ declare type ComposableIntegrationMessageTypes = 'audio' | 'bloc' | 'file' | 'im
|
|
|
152
155
|
|
|
153
156
|
export declare const Composer: MemoExoticComponent<ForwardRefExoticComponent<Omit<Props_3, "ref"> & RefAttributes<HTMLDivElement>>>;
|
|
154
157
|
|
|
158
|
+
export declare const CONFIG_ACCESS_DENIED = "Access denied to configuration file. Please check your credentials or your configuration URL and try again.";
|
|
159
|
+
|
|
155
160
|
declare type configuration = ComponentProps<typeof Chat>['configuration'];
|
|
156
161
|
|
|
157
162
|
export declare const Container: {
|
|
@@ -196,19 +201,20 @@ export declare type DropdownBlock = {
|
|
|
196
201
|
}[];
|
|
197
202
|
};
|
|
198
203
|
|
|
199
|
-
declare
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
204
|
+
export declare function enrichMessage(messages: BlockMessage[], participants: User[], currentUserId: string, botName?: string, botAvatar?: string): RichBlockMessage[];
|
|
205
|
+
|
|
206
|
+
declare type ErrorProps = {
|
|
207
|
+
error: WebchatError;
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
export declare function ErrorState({ error }: ErrorProps): JSX_3.Element;
|
|
205
211
|
|
|
206
212
|
declare type Events = WebchatEvents & {
|
|
207
213
|
'*': AnyEvent;
|
|
208
214
|
};
|
|
209
215
|
|
|
210
216
|
declare type Events_2 = {
|
|
211
|
-
[key: string]:
|
|
217
|
+
[key: string]: string;
|
|
212
218
|
};
|
|
213
219
|
|
|
214
220
|
export declare const Fab: ForwardRefExoticComponent<Omit<ClassAttributes<HTMLDivElement> & HTMLAttributes<HTMLDivElement> & {
|
|
@@ -233,6 +239,8 @@ export declare type GenericBlock = AudioBlock | BubbleBlock | ButtonBlock | Caro
|
|
|
233
239
|
|
|
234
240
|
export declare const getUseWebchatClientStore: typeof WebchatClientStores.getInstance;
|
|
235
241
|
|
|
242
|
+
export declare const handleIntegrationError: (error: unknown) => WebchatError;
|
|
243
|
+
|
|
236
244
|
export declare const Header: ({ defaultOpen, closeWindow, configuration, restartConversation, ...props }: HeaderProps) => JSX_3.Element;
|
|
237
245
|
|
|
238
246
|
declare type HeaderProps = {
|
|
@@ -245,6 +253,12 @@ declare type HeaderProps = {
|
|
|
245
253
|
configuration: Pick<LatestWebchatConfig, 'email' | 'phone' | 'privacyPolicy' | 'website' | 'termsOfService' | 'botAvatar' | 'botDescription' | 'botName'>;
|
|
246
254
|
};
|
|
247
255
|
|
|
256
|
+
export declare type HookResult<T> = {
|
|
257
|
+
data: Simplify<T> | undefined;
|
|
258
|
+
isLoading: boolean;
|
|
259
|
+
error: WebchatError | undefined;
|
|
260
|
+
};
|
|
261
|
+
|
|
248
262
|
export declare type ImageBlock = {
|
|
249
263
|
type: 'image';
|
|
250
264
|
orientation?: 'portrait' | 'landscape' | 'square' | 'auto';
|
|
@@ -261,6 +275,16 @@ export declare function integrationMessageToBlockMessage(message: IntegrationMes
|
|
|
261
275
|
|
|
262
276
|
declare type IntegrationMessageTypes = IntegrationMessage['payload']['type'];
|
|
263
277
|
|
|
278
|
+
export declare const INVALID_API_URL = "Invalid API URL. Please use a valid API URL.";
|
|
279
|
+
|
|
280
|
+
export declare const INVALID_BOTPRESS_URL = "Invalid URL. Please make sure your client ID and API URL are valid";
|
|
281
|
+
|
|
282
|
+
export declare const INVALID_CLIENT_ID = "Invalid Client ID. Please use a valid Botpress Client ID.";
|
|
283
|
+
|
|
284
|
+
export declare const INVALID_CONFIG_URL = "Invalid config URL. Please make sure your config URL is valid";
|
|
285
|
+
|
|
286
|
+
export declare const INVALID_CONFIGURATION = "Invalid webchat configuration, please make sure your config file is valid";
|
|
287
|
+
|
|
264
288
|
export declare const isFileType: (type: string) => type is FileType;
|
|
265
289
|
|
|
266
290
|
export declare type LocationBlock = {
|
|
@@ -276,6 +300,7 @@ export declare const Message: MemoExoticComponent<ForwardRefExoticComponent<{
|
|
|
276
300
|
sendMessage?: (payload: IntegrationMessage["payload"]) => void;
|
|
277
301
|
addMessageFeedback?: (messageId: string, feedback: Feedback) => void;
|
|
278
302
|
isReadOnly?: boolean;
|
|
303
|
+
isLastDeliveredMessage?: boolean;
|
|
279
304
|
} & BlockMessage<GenericBlock> & {
|
|
280
305
|
direction: "incoming" | "outgoing" | "system";
|
|
281
306
|
sender: {
|
|
@@ -299,6 +324,14 @@ declare type MessageListProps = {
|
|
|
299
324
|
showMarquee?: boolean;
|
|
300
325
|
};
|
|
301
326
|
|
|
327
|
+
export declare const MISSING_API_URL = "The API url is required to initialize the webchat.";
|
|
328
|
+
|
|
329
|
+
export declare const MISSING_BOT_ID = "The Bot ID is required to initialize the webchat.";
|
|
330
|
+
|
|
331
|
+
export declare const MISSING_CLIENT_ID = "The Client ID is required to initialize the webchat.";
|
|
332
|
+
|
|
333
|
+
export declare const MISSING_CONFIG_URL = "No config URL provided.";
|
|
334
|
+
|
|
302
335
|
export declare function Modal({ open, onOpenChange, children, }: {
|
|
303
336
|
open?: boolean;
|
|
304
337
|
onOpenChange?: (open: boolean) => void;
|
|
@@ -330,6 +363,10 @@ export declare const ModalProvider: ({ children }: {
|
|
|
330
363
|
children: ReactNode;
|
|
331
364
|
}) => JSX_3.Element;
|
|
332
365
|
|
|
366
|
+
export declare const NETWORK_ERROR = "Please check your internet connection and refresh the page.";
|
|
367
|
+
|
|
368
|
+
export declare const NOT_A_PARTICIPANT = "You are not a participant of this conversation, please clear your local storage.";
|
|
369
|
+
|
|
333
370
|
export declare type Options = {
|
|
334
371
|
timeout?: number;
|
|
335
372
|
};
|
|
@@ -339,6 +376,7 @@ export declare type Props = {
|
|
|
339
376
|
renderers?: Partial<Renderers>;
|
|
340
377
|
configuration: LatestWebchatConfig;
|
|
341
378
|
messages: BlockMessage[];
|
|
379
|
+
participants: User[];
|
|
342
380
|
connected?: boolean;
|
|
343
381
|
disableComposer?: boolean;
|
|
344
382
|
isReadOnly?: boolean;
|
|
@@ -352,13 +390,14 @@ export declare type Props = {
|
|
|
352
390
|
user?: {
|
|
353
391
|
id: string;
|
|
354
392
|
} & Record<string, unknown>;
|
|
355
|
-
sendMessage?: (payload: IntegrationMessage['payload']) => void
|
|
393
|
+
sendMessage?: (payload: IntegrationMessage['payload']) => Promise<void>;
|
|
356
394
|
uploadFile?: (file: File) => Promise<{
|
|
357
395
|
fileUrl: string;
|
|
358
396
|
name: string;
|
|
359
397
|
type: FileType;
|
|
360
398
|
}>;
|
|
361
399
|
addMessageFeedback?: (messageId: string, feedback: Feedback) => void;
|
|
400
|
+
error?: WebchatError;
|
|
362
401
|
};
|
|
363
402
|
|
|
364
403
|
declare type Props_2 = {
|
|
@@ -368,7 +407,7 @@ declare type Props_2 = {
|
|
|
368
407
|
apiUrl?: string;
|
|
369
408
|
sseTimeout?: number;
|
|
370
409
|
storageKey?: string;
|
|
371
|
-
storageLocation?:
|
|
410
|
+
storageLocation?: StorageLocation;
|
|
372
411
|
};
|
|
373
412
|
|
|
374
413
|
declare type Props_3 = ComponentProps<'div'> & {
|
|
@@ -410,6 +449,8 @@ declare type Props_6 = {
|
|
|
410
449
|
|
|
411
450
|
declare type Props_7 = Partial<LatestWebchatTheme>;
|
|
412
451
|
|
|
452
|
+
export declare const QUOTA_EXCEEDED = "This bot has temporarily paused. Please check back later.";
|
|
453
|
+
|
|
413
454
|
export declare type Renderers = {
|
|
414
455
|
[T in GenericBlock['type']]: FC<BlockObjects[T]>;
|
|
415
456
|
};
|
|
@@ -447,9 +488,13 @@ declare type ScopedClient = {
|
|
|
447
488
|
}>;
|
|
448
489
|
addMessageFeedback: (messageId: string, feedback: Feedback) => Promise<void>;
|
|
449
490
|
getUser: () => Promise<UserResponse>;
|
|
450
|
-
updateUser: (user:
|
|
491
|
+
updateUser: (user: UserProfile) => Promise<User>;
|
|
451
492
|
};
|
|
452
493
|
|
|
494
|
+
export declare type Simplify<T> = {
|
|
495
|
+
[KeyType in keyof T]: T[KeyType];
|
|
496
|
+
} & {};
|
|
497
|
+
|
|
453
498
|
declare type StorageLocation = 'sessionStorage' | 'localStorage';
|
|
454
499
|
|
|
455
500
|
export declare type StyleOptions = {
|
|
@@ -478,7 +523,7 @@ export declare type UseImageSizeResult = [Dimensions | null, {
|
|
|
478
523
|
error: string | null;
|
|
479
524
|
}];
|
|
480
525
|
|
|
481
|
-
declare type
|
|
526
|
+
declare type UserProfile = Omit<User, 'id' | 'createdAt' | 'updatedAt'>;
|
|
482
527
|
|
|
483
528
|
declare type UserResponse = Awaited<ReturnType<Client['getUser']>>['user'];
|
|
484
529
|
|
|
@@ -494,8 +539,10 @@ declare type UseWebchatReturn = {
|
|
|
494
539
|
isFetchingMessages: boolean;
|
|
495
540
|
user?: UserCredentials;
|
|
496
541
|
isTyping: boolean;
|
|
542
|
+
error?: WebchatError;
|
|
543
|
+
participants: User[];
|
|
497
544
|
} | {
|
|
498
|
-
clientState: 'connecting';
|
|
545
|
+
clientState: 'connecting' | 'error';
|
|
499
546
|
on: EventEmitter<Events>['on'];
|
|
500
547
|
client: undefined;
|
|
501
548
|
messages: BlockMessage[];
|
|
@@ -504,6 +551,8 @@ declare type UseWebchatReturn = {
|
|
|
504
551
|
isFetchingMessages: boolean;
|
|
505
552
|
user: undefined;
|
|
506
553
|
isTyping: undefined;
|
|
554
|
+
error?: WebchatError;
|
|
555
|
+
participants: User[];
|
|
507
556
|
};
|
|
508
557
|
|
|
509
558
|
export declare const useWebchatStore: UseBoundStore<Omit<StoreApi<WebchatStore>, "setState"> & {
|
|
@@ -778,6 +827,9 @@ export declare const webchatClasses: {
|
|
|
778
827
|
readonly className: "bpMessageAvatarFallback";
|
|
779
828
|
};
|
|
780
829
|
};
|
|
830
|
+
readonly deliveryStatus: {
|
|
831
|
+
readonly className: "bpMessageDeliveryStatus";
|
|
832
|
+
};
|
|
781
833
|
readonly blocks: {
|
|
782
834
|
readonly text: {
|
|
783
835
|
readonly heading1: {
|
|
@@ -949,6 +1001,26 @@ export declare const webchatClasses: {
|
|
|
949
1001
|
};
|
|
950
1002
|
};
|
|
951
1003
|
};
|
|
1004
|
+
readonly error: {
|
|
1005
|
+
readonly container: {
|
|
1006
|
+
readonly className: "bpReset bpErrorContainer";
|
|
1007
|
+
};
|
|
1008
|
+
readonly header: {
|
|
1009
|
+
readonly className: "bpErrorHeader";
|
|
1010
|
+
};
|
|
1011
|
+
readonly content: {
|
|
1012
|
+
readonly className: "bpErrorContent";
|
|
1013
|
+
};
|
|
1014
|
+
readonly errorTitle: {
|
|
1015
|
+
readonly className: "bpErrorTitle";
|
|
1016
|
+
};
|
|
1017
|
+
readonly errorMessage: {
|
|
1018
|
+
readonly className: "bpErrorMessage";
|
|
1019
|
+
};
|
|
1020
|
+
readonly icon: {
|
|
1021
|
+
readonly className: "bpErrorIcon";
|
|
1022
|
+
};
|
|
1023
|
+
};
|
|
952
1024
|
readonly typingIndicator: {
|
|
953
1025
|
readonly container: {
|
|
954
1026
|
readonly className: "bpTypingIndicatorContainer";
|
|
@@ -963,7 +1035,7 @@ declare type WebchatClientStore = {
|
|
|
963
1035
|
user?: UserCredentials;
|
|
964
1036
|
conversationId?: string;
|
|
965
1037
|
setUser: (userId?: UserCredentials) => void;
|
|
966
|
-
setConversationId: (conversationId
|
|
1038
|
+
setConversationId: (conversationId: string) => void;
|
|
967
1039
|
clearAll: () => void;
|
|
968
1040
|
};
|
|
969
1041
|
|
|
@@ -973,6 +1045,20 @@ declare class WebchatClientStores {
|
|
|
973
1045
|
static getInstance(name?: string, storageLocation?: StorageLocation): BoundWebchatClientStore;
|
|
974
1046
|
}
|
|
975
1047
|
|
|
1048
|
+
export declare type WebchatError = {
|
|
1049
|
+
type: 'configuration';
|
|
1050
|
+
message: typeof MISSING_CLIENT_ID | typeof MISSING_API_URL | typeof MISSING_BOT_ID | typeof INVALID_CLIENT_ID | typeof INVALID_CONFIGURATION | typeof MISSING_CONFIG_URL;
|
|
1051
|
+
} | {
|
|
1052
|
+
type: 'bot';
|
|
1053
|
+
message: typeof BOT_IS_BLOCKED | typeof QUOTA_EXCEEDED | typeof NOT_A_PARTICIPANT;
|
|
1054
|
+
} | {
|
|
1055
|
+
type: 'network';
|
|
1056
|
+
message: typeof NETWORK_ERROR;
|
|
1057
|
+
} | {
|
|
1058
|
+
type: string;
|
|
1059
|
+
message: string;
|
|
1060
|
+
};
|
|
1061
|
+
|
|
976
1062
|
export declare type WebchatEvents = {
|
|
977
1063
|
conversation: string | undefined;
|
|
978
1064
|
message: BlockMessage;
|
|
@@ -985,6 +1071,8 @@ export declare type WebchatEvents = {
|
|
|
985
1071
|
isTyping: boolean;
|
|
986
1072
|
timeout: number;
|
|
987
1073
|
};
|
|
1074
|
+
participantAdded: User;
|
|
1075
|
+
participantRemoved: User;
|
|
988
1076
|
};
|
|
989
1077
|
|
|
990
1078
|
declare type WebchatStore = {
|