@botpress/webchat 2.2.19 → 2.3.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.
Files changed (52) hide show
  1. package/.turbo/turbo-build.log +8 -8
  2. package/dist/adapters/adapters/webchat-to-target.d.ts +46 -0
  3. package/dist/adapters/webchat.d.ts +816 -0
  4. package/dist/client/{PushpinClient/index.d.ts → client.d.ts} +6 -5
  5. package/dist/client/index.d.ts +1 -2
  6. package/dist/client/{PushpinClient/inner-client → inner-client}/index.d.ts +3 -3
  7. package/dist/client/{PushpinClient/inner-client → inner-client}/signal-listener.d.ts +1 -1
  8. package/dist/client/types.d.ts +3 -26
  9. package/dist/components/Block.d.ts +2 -2
  10. package/dist/components/Message/Message.d.ts +4 -2
  11. package/dist/components/renderers/Audio/Audio.d.ts +3 -1
  12. package/dist/components/renderers/Bubble/Bubble.d.ts +2 -2
  13. package/dist/components/renderers/Button/Button.d.ts +2 -2
  14. package/dist/components/renderers/Carousel/Carousel.d.ts +3 -1
  15. package/dist/components/renderers/Column/Column.d.ts +2 -2
  16. package/dist/components/renderers/Dropdown/Dropdown.d.ts +2 -2
  17. package/dist/components/renderers/File/File.d.ts +3 -1
  18. package/dist/components/renderers/Image/Image.d.ts +3 -1
  19. package/dist/components/renderers/Location/Location.d.ts +3 -1
  20. package/dist/components/renderers/Row/Row.d.ts +2 -2
  21. package/dist/components/renderers/Text/Text.d.ts +2 -2
  22. package/dist/components/renderers/Video/Video.d.ts +3 -1
  23. package/dist/gen/client/models.d.ts +61 -0
  24. package/dist/gen/client/operations/createMessage.d.ts +122 -0
  25. package/dist/gen/client/operations/getMessage.d.ts +61 -0
  26. package/dist/gen/client/operations/listConversationMessages.d.ts +61 -0
  27. package/dist/gen/signals/index.d.ts +416 -8
  28. package/dist/gen/signals/messageCreated.t.d.ts +61 -0
  29. package/dist/gen/signals/messageCreated.z.d.ts +415 -0
  30. package/dist/get-client.d.ts +1 -2
  31. package/dist/hooks/useClient.d.ts +1 -2
  32. package/dist/index.js +12119 -14476
  33. package/dist/index.umd.cjs +88 -88
  34. package/dist/schemas/init.d.ts +0 -7
  35. package/dist/stores/offlineStore.d.ts +1 -1
  36. package/dist/stores/webchatStore.d.ts +1 -0
  37. package/dist/style.css +1 -1
  38. package/dist/types/block-type.d.ts +3 -0
  39. package/dist/types/init.d.ts +0 -1
  40. package/openapi.ts +1 -1
  41. package/package.json +3 -2
  42. package/dist/client/MessagingClient/client.d.ts +0 -35
  43. package/dist/client/MessagingClient/index.d.ts +0 -1
  44. package/dist/gen/signals/custom.j.d.ts +0 -3
  45. package/dist/gen/signals/messageCreated.j.d.ts +0 -3
  46. package/dist/gen/signals/typingStarted.j.d.ts +0 -3
  47. package/dist/gen/signals/typingStopped.j.d.ts +0 -3
  48. package/dist/gen/signals/webchatConfig.j.d.ts +0 -3
  49. package/dist/gen/signals/webchatVisibility.j.d.ts +0 -3
  50. /package/dist/client/{PushpinClient/inner-client → inner-client}/event-emitter.d.ts +0 -0
  51. /package/dist/client/{PushpinClient/inner-client → inner-client}/eventsource.d.ts +0 -0
  52. /package/dist/client/{PushpinClient/state-machine.d.ts → state-machine.d.ts} +0 -0
@@ -1,11 +1,12 @@
1
- import { EventEmitter } from '../../utils';
2
- import { Events, Message, UserCredentials, UserData, UserOptions, WebchatClient, type User } from '../types';
3
- import { type FileType } from '../../types';
1
+ import { EventEmitter } from '../utils';
2
+ import { Events, UserCredentials, UserData, UserOptions, type Message, type User } from './types';
3
+ import { type FileType } from '../types';
4
+ import type { Message as WebchatMessage } from '../adapters/webchat';
4
5
  export type PushpinClientProps = {
5
6
  apiUrl: string;
6
7
  clientId: string;
7
8
  };
8
- export declare class PushpinClient extends EventEmitter<Events> implements WebchatClient {
9
+ export declare class WebchatClient extends EventEmitter<Events> {
9
10
  private _client;
10
11
  private _webhookId;
11
12
  private _apiUrl;
@@ -31,7 +32,7 @@ export declare class PushpinClient extends EventEmitter<Events> implements Webch
31
32
  name: string;
32
33
  type: FileType;
33
34
  }>;
34
- sendMessage(message: string): Promise<void>;
35
+ sendMessage(payload: WebchatMessage): Promise<void>;
35
36
  sendEvent(event: Record<string, any>): Promise<void>;
36
37
  switchConversation(id: string): Promise<void>;
37
38
  conversationExists(id: string): Promise<boolean>;
@@ -1,3 +1,2 @@
1
- export * from './MessagingClient';
2
- export * from './PushpinClient';
1
+ export * from './client';
3
2
  export * from './types';
@@ -1,7 +1,7 @@
1
- import { Client as AutoGeneratedClient } from '../../../gen/client';
1
+ import { Client as AutoGeneratedClient } from '../../gen/client';
2
2
  import { SignalListener } from './signal-listener';
3
- export type { Message, Conversation, User } from '../../../gen/client';
4
- export * from '../../../gen/client/errors';
3
+ export type { Message, Conversation, User } from '../../gen/client';
4
+ export * from '../../gen/client/errors';
5
5
  export type Headers = Record<string, string>;
6
6
  export type ClientProps = {
7
7
  apiUrl: string;
@@ -1,6 +1,6 @@
1
1
  import { EventEmitter } from './event-emitter';
2
2
  import { EvSource } from './eventsource';
3
- import { Types } from '../../../gen/signals';
3
+ import { Types } from '../../gen/signals';
4
4
  type Signals = Types & {
5
5
  unknown: {
6
6
  type: 'unknown';
@@ -1,6 +1,6 @@
1
- import { EventEmitter } from '../utils';
2
- import { BlockObject, type FileType } from '../types/block-type';
1
+ import { BlockObject } from '../types/block-type';
3
2
  import { UserProps } from '../types';
3
+ import type { Message as WebchatMessage } from '../adapters/webchat';
4
4
  type SafeOmit<T, K extends keyof T> = Omit<T, K>;
5
5
  export type UserCredentials = {
6
6
  userId: string;
@@ -20,7 +20,7 @@ export type Message = {
20
20
  export type WebchatEvents = {
21
21
  conversation: string | undefined;
22
22
  message: Message;
23
- messageSent: string;
23
+ messageSent: WebchatMessage;
24
24
  error: Error;
25
25
  webchatVisibility: 'show' | 'hide' | 'toggle';
26
26
  webchatConfig: Record<string, any>;
@@ -40,27 +40,4 @@ type AnyEvent = ValueOf<{
40
40
  export type Events = WebchatEvents & {
41
41
  '*': AnyEvent;
42
42
  };
43
- export type WebchatClient = {
44
- mode: 'messaging' | 'pushpin';
45
- clientId: string;
46
- apiUrl: string;
47
- userId: string | undefined;
48
- conversationId: string | undefined;
49
- on: EventEmitter<Events>['on'];
50
- connect(creds?: UserCredentials, data?: UserData, opts?: UserOptions): Promise<UserCredentials | undefined>;
51
- disconnect(): Promise<void>;
52
- getUser(): Promise<User>;
53
- updateUser(user: User): Promise<User>;
54
- sendMessage(message: string): Promise<void>;
55
- sendFile(file: File): Promise<{
56
- fileUrl: string;
57
- name: string;
58
- type: FileType;
59
- }>;
60
- sendEvent(event: Record<string, any>): Promise<void>;
61
- switchConversation(id: string): Promise<void>;
62
- conversationExists(id: string): Promise<boolean>;
63
- newConversation(): Promise<void>;
64
- listMessages(): Promise<Message[]>;
65
- };
66
43
  export {};
@@ -1,7 +1,7 @@
1
1
  import { JSX } from 'react';
2
- import { BlockObjects, BlockType } from '../types';
2
+ import { BlockObjects, BlockType, type CommonBlockProps } from '../types';
3
3
  type BlockProps<T extends BlockType> = {
4
4
  block: BlockObjects[T];
5
- };
5
+ } & Partial<CommonBlockProps>;
6
6
  export declare const Block: <T extends BlockType>({ block, ...props }: BlockProps<T>) => JSX.Element;
7
7
  export {};
@@ -1,6 +1,8 @@
1
1
  import { type ReactNode } from 'react';
2
2
  import type { MessageObject } from '../../types';
3
- export declare const Message: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<{
3
+ type MessageProps = {
4
4
  scroll: () => void;
5
5
  children?: ReactNode;
6
- } & Partial<MessageObject> & import("react").RefAttributes<HTMLDivElement>>>;
6
+ } & MessageObject;
7
+ export declare const Message: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Partial<MessageProps> & import("react").RefAttributes<HTMLDivElement>>>;
8
+ export {};
@@ -1 +1,3 @@
1
- export declare const Audio: import("react").ForwardRefExoticComponent<import("../../../adapters/target").AudioMessage & import("react").RefAttributes<HTMLAudioElement>>;
1
+ export declare const Audio: import("react").ForwardRefExoticComponent<import("../../../adapters/target").AudioMessage & Partial<Pick<import("../../..").MessageObject<import("../../../adapters/target").Message>, "direction" | "timestamp" | "sender"> & {
2
+ messageId: string;
3
+ }> & import("react").RefAttributes<HTMLAudioElement>>;
@@ -1,5 +1,5 @@
1
1
  import { ComponentProps } from 'react';
2
- import { BubbleBlock } from '../../../types';
3
- type Props = BubbleBlock & ComponentProps<'div'>;
2
+ import { BubbleBlock, type CommonBlockProps } from '../../../types';
3
+ type Props = BubbleBlock & ComponentProps<'div'> & CommonBlockProps;
4
4
  export declare const Bubble: import("react").ForwardRefExoticComponent<Omit<Props, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
5
5
  export {};
@@ -1,4 +1,4 @@
1
- import { ButtonBlock } from '../../../types';
2
- type Props = ButtonBlock;
1
+ import { ButtonBlock, type CommonBlockProps } from '../../../types';
2
+ type Props = ButtonBlock & CommonBlockProps;
3
3
  export declare const Button: ({ text, buttonValue, type, variant, groupId, reusable, ...props }: Props) => import("react/jsx-runtime").JSX.Element;
4
4
  export {};
@@ -1 +1,3 @@
1
- export declare const Carousel: import("react").ForwardRefExoticComponent<import("../../../adapters/target").CarouselMessage & import("react").RefAttributes<HTMLDivElement>>;
1
+ export declare const Carousel: import("react").ForwardRefExoticComponent<import("../../../adapters/target").CarouselMessage & Partial<Pick<import("../../..").MessageObject<import("../../../adapters/target").Message>, "direction" | "timestamp" | "sender"> & {
2
+ messageId: string;
3
+ }> & import("react").RefAttributes<HTMLDivElement>>;
@@ -1,5 +1,5 @@
1
1
  import { ComponentProps } from 'react';
2
- import { ColumnBlock } from '../../../types';
3
- type Props = ColumnBlock & ComponentProps<'div'>;
2
+ import { ColumnBlock, type CommonBlockProps } from '../../../types';
3
+ type Props = ColumnBlock & ComponentProps<'div'> & CommonBlockProps;
4
4
  export declare const Column: import("react").ForwardRefExoticComponent<Omit<Props, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
5
5
  export {};
@@ -1,5 +1,5 @@
1
- import { DropdownBlock } from '../../../types';
1
+ import { DropdownBlock, type CommonBlockProps } from '../../../types';
2
2
  import { ComponentProps } from 'react';
3
- type Props = DropdownBlock & ComponentProps<'div'>;
3
+ type Props = DropdownBlock & ComponentProps<'div'> & CommonBlockProps;
4
4
  export declare const Dropdown: ({ options, label, reusable }: Props) => import("react/jsx-runtime").JSX.Element;
5
5
  export {};
@@ -1 +1,3 @@
1
- export declare const File: import("react").ForwardRefExoticComponent<import("../../../adapters/target").FileMessage & import("react").RefAttributes<HTMLAnchorElement>>;
1
+ export declare const File: import("react").ForwardRefExoticComponent<import("../../../adapters/target").FileMessage & Partial<Pick<import("../../..").MessageObject<import("../../../adapters/target").Message>, "direction" | "timestamp" | "sender"> & {
2
+ messageId: string;
3
+ }> & import("react").RefAttributes<HTMLAnchorElement>>;
@@ -1 +1,3 @@
1
- export declare const Image: import("react").ForwardRefExoticComponent<import("../../../adapters/target").ImageMessage & import("react").RefAttributes<HTMLImageElement>>;
1
+ export declare const Image: import("react").ForwardRefExoticComponent<import("../../../adapters/target").ImageMessage & Partial<Pick<import("../../..").MessageObject<import("../../../adapters/target").Message>, "direction" | "timestamp" | "sender"> & {
2
+ messageId: string;
3
+ }> & import("react").RefAttributes<HTMLImageElement>>;
@@ -1 +1,3 @@
1
- export declare const Location: import("react").ForwardRefExoticComponent<import("../../../adapters/target").LocationMessage & import("react").RefAttributes<HTMLAnchorElement>>;
1
+ export declare const Location: import("react").ForwardRefExoticComponent<import("../../../adapters/target").LocationMessage & Partial<Pick<import("../../..").MessageObject<import("../../../adapters/target").Message>, "direction" | "timestamp" | "sender"> & {
2
+ messageId: string;
3
+ }> & import("react").RefAttributes<HTMLAnchorElement>>;
@@ -1,5 +1,5 @@
1
1
  import { ComponentProps } from 'react';
2
- import { RowBlock } from '../../../types';
3
- type Props = RowBlock & ComponentProps<'div'>;
2
+ import { RowBlock, type CommonBlockProps } from '../../../types';
3
+ type Props = RowBlock & ComponentProps<'div'> & CommonBlockProps;
4
4
  export declare const Row: import("react").ForwardRefExoticComponent<Omit<Props, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
5
5
  export {};
@@ -1,4 +1,4 @@
1
- import { TextBlock } from '../../../types';
2
- type Props = TextBlock;
1
+ import { TextBlock, type CommonBlockProps } from '../../../types';
2
+ type Props = TextBlock & CommonBlockProps;
3
3
  export declare const Text: ({ text }: Props) => import("react/jsx-runtime").JSX.Element;
4
4
  export {};
@@ -1 +1,3 @@
1
- export declare const Video: import("react").ForwardRefExoticComponent<import("../../../adapters/target").VideoMessage & import("react").RefAttributes<HTMLVideoElement>>;
1
+ export declare const Video: import("react").ForwardRefExoticComponent<import("../../../adapters/target").VideoMessage & Partial<Pick<import("../../..").MessageObject<import("../../../adapters/target").Message>, "direction" | "timestamp" | "sender"> & {
2
+ messageId: string;
3
+ }> & import("react").RefAttributes<HTMLVideoElement>>;
@@ -184,6 +184,67 @@ export interface Message {
184
184
  className?: string;
185
185
  type: "video";
186
186
  [k: string]: any;
187
+ } | {
188
+ items: ({
189
+ type: "text";
190
+ payload: {
191
+ text: string;
192
+ [k: string]: any;
193
+ };
194
+ [k: string]: any;
195
+ } | {
196
+ type: "markdown";
197
+ payload: {
198
+ markdown: string;
199
+ [k: string]: any;
200
+ };
201
+ [k: string]: any;
202
+ } | {
203
+ type: "image";
204
+ payload: {
205
+ imageUrl: string;
206
+ [k: string]: any;
207
+ };
208
+ [k: string]: any;
209
+ } | {
210
+ type: "audio";
211
+ payload: {
212
+ audioUrl: string;
213
+ [k: string]: any;
214
+ };
215
+ [k: string]: any;
216
+ } | {
217
+ type: "video";
218
+ payload: {
219
+ videoUrl: string;
220
+ [k: string]: any;
221
+ };
222
+ [k: string]: any;
223
+ } | {
224
+ type: "file";
225
+ payload: {
226
+ fileUrl: string;
227
+ title?: string;
228
+ [k: string]: any;
229
+ };
230
+ [k: string]: any;
231
+ } | {
232
+ type: "location";
233
+ payload: {
234
+ latitude: number;
235
+ longitude: number;
236
+ address?: string;
237
+ title?: string;
238
+ [k: string]: any;
239
+ };
240
+ [k: string]: any;
241
+ })[];
242
+ /**
243
+ * CSS className to apply to the message
244
+ */
245
+ className?: string;
246
+ type: "bloc";
247
+ [k: string]: any;
187
248
  };
188
249
  /**
189
250
  * ID of the [User](#schema_user)
@@ -135,6 +135,67 @@ export interface CreateMessageRequestBody {
135
135
  className?: string;
136
136
  type: "video";
137
137
  [k: string]: any;
138
+ } | {
139
+ items: ({
140
+ type: "text";
141
+ payload: {
142
+ text: string;
143
+ [k: string]: any;
144
+ };
145
+ [k: string]: any;
146
+ } | {
147
+ type: "markdown";
148
+ payload: {
149
+ markdown: string;
150
+ [k: string]: any;
151
+ };
152
+ [k: string]: any;
153
+ } | {
154
+ type: "image";
155
+ payload: {
156
+ imageUrl: string;
157
+ [k: string]: any;
158
+ };
159
+ [k: string]: any;
160
+ } | {
161
+ type: "audio";
162
+ payload: {
163
+ audioUrl: string;
164
+ [k: string]: any;
165
+ };
166
+ [k: string]: any;
167
+ } | {
168
+ type: "video";
169
+ payload: {
170
+ videoUrl: string;
171
+ [k: string]: any;
172
+ };
173
+ [k: string]: any;
174
+ } | {
175
+ type: "file";
176
+ payload: {
177
+ fileUrl: string;
178
+ title?: string;
179
+ [k: string]: any;
180
+ };
181
+ [k: string]: any;
182
+ } | {
183
+ type: "location";
184
+ payload: {
185
+ latitude: number;
186
+ longitude: number;
187
+ address?: string;
188
+ title?: string;
189
+ [k: string]: any;
190
+ };
191
+ [k: string]: any;
192
+ })[];
193
+ /**
194
+ * CSS className to apply to the message
195
+ */
196
+ className?: string;
197
+ type: "bloc";
198
+ [k: string]: any;
138
199
  };
139
200
  /**
140
201
  * ID of the [Conversation](#schema_conversation)
@@ -293,6 +354,67 @@ export interface CreateMessageResponse {
293
354
  className?: string;
294
355
  type: "video";
295
356
  [k: string]: any;
357
+ } | {
358
+ items: ({
359
+ type: "text";
360
+ payload: {
361
+ text: string;
362
+ [k: string]: any;
363
+ };
364
+ [k: string]: any;
365
+ } | {
366
+ type: "markdown";
367
+ payload: {
368
+ markdown: string;
369
+ [k: string]: any;
370
+ };
371
+ [k: string]: any;
372
+ } | {
373
+ type: "image";
374
+ payload: {
375
+ imageUrl: string;
376
+ [k: string]: any;
377
+ };
378
+ [k: string]: any;
379
+ } | {
380
+ type: "audio";
381
+ payload: {
382
+ audioUrl: string;
383
+ [k: string]: any;
384
+ };
385
+ [k: string]: any;
386
+ } | {
387
+ type: "video";
388
+ payload: {
389
+ videoUrl: string;
390
+ [k: string]: any;
391
+ };
392
+ [k: string]: any;
393
+ } | {
394
+ type: "file";
395
+ payload: {
396
+ fileUrl: string;
397
+ title?: string;
398
+ [k: string]: any;
399
+ };
400
+ [k: string]: any;
401
+ } | {
402
+ type: "location";
403
+ payload: {
404
+ latitude: number;
405
+ longitude: number;
406
+ address?: string;
407
+ title?: string;
408
+ [k: string]: any;
409
+ };
410
+ [k: string]: any;
411
+ })[];
412
+ /**
413
+ * CSS className to apply to the message
414
+ */
415
+ className?: string;
416
+ type: "bloc";
417
+ [k: string]: any;
296
418
  };
297
419
  /**
298
420
  * ID of the [User](#schema_user)
@@ -160,6 +160,67 @@ export interface GetMessageResponse {
160
160
  className?: string;
161
161
  type: "video";
162
162
  [k: string]: any;
163
+ } | {
164
+ items: ({
165
+ type: "text";
166
+ payload: {
167
+ text: string;
168
+ [k: string]: any;
169
+ };
170
+ [k: string]: any;
171
+ } | {
172
+ type: "markdown";
173
+ payload: {
174
+ markdown: string;
175
+ [k: string]: any;
176
+ };
177
+ [k: string]: any;
178
+ } | {
179
+ type: "image";
180
+ payload: {
181
+ imageUrl: string;
182
+ [k: string]: any;
183
+ };
184
+ [k: string]: any;
185
+ } | {
186
+ type: "audio";
187
+ payload: {
188
+ audioUrl: string;
189
+ [k: string]: any;
190
+ };
191
+ [k: string]: any;
192
+ } | {
193
+ type: "video";
194
+ payload: {
195
+ videoUrl: string;
196
+ [k: string]: any;
197
+ };
198
+ [k: string]: any;
199
+ } | {
200
+ type: "file";
201
+ payload: {
202
+ fileUrl: string;
203
+ title?: string;
204
+ [k: string]: any;
205
+ };
206
+ [k: string]: any;
207
+ } | {
208
+ type: "location";
209
+ payload: {
210
+ latitude: number;
211
+ longitude: number;
212
+ address?: string;
213
+ title?: string;
214
+ [k: string]: any;
215
+ };
216
+ [k: string]: any;
217
+ })[];
218
+ /**
219
+ * CSS className to apply to the message
220
+ */
221
+ className?: string;
222
+ type: "bloc";
223
+ [k: string]: any;
163
224
  };
164
225
  /**
165
226
  * ID of the [User](#schema_user)
@@ -158,6 +158,67 @@ export interface ListConversationMessagesResponse {
158
158
  className?: string;
159
159
  type: "video";
160
160
  [k: string]: any;
161
+ } | {
162
+ items: ({
163
+ type: "text";
164
+ payload: {
165
+ text: string;
166
+ [k: string]: any;
167
+ };
168
+ [k: string]: any;
169
+ } | {
170
+ type: "markdown";
171
+ payload: {
172
+ markdown: string;
173
+ [k: string]: any;
174
+ };
175
+ [k: string]: any;
176
+ } | {
177
+ type: "image";
178
+ payload: {
179
+ imageUrl: string;
180
+ [k: string]: any;
181
+ };
182
+ [k: string]: any;
183
+ } | {
184
+ type: "audio";
185
+ payload: {
186
+ audioUrl: string;
187
+ [k: string]: any;
188
+ };
189
+ [k: string]: any;
190
+ } | {
191
+ type: "video";
192
+ payload: {
193
+ videoUrl: string;
194
+ [k: string]: any;
195
+ };
196
+ [k: string]: any;
197
+ } | {
198
+ type: "file";
199
+ payload: {
200
+ fileUrl: string;
201
+ title?: string;
202
+ [k: string]: any;
203
+ };
204
+ [k: string]: any;
205
+ } | {
206
+ type: "location";
207
+ payload: {
208
+ latitude: number;
209
+ longitude: number;
210
+ address?: string;
211
+ title?: string;
212
+ [k: string]: any;
213
+ };
214
+ [k: string]: any;
215
+ })[];
216
+ /**
217
+ * CSS className to apply to the message
218
+ */
219
+ className?: string;
220
+ type: "bloc";
221
+ [k: string]: any;
161
222
  };
162
223
  /**
163
224
  * ID of the [User](#schema_user)