@botpress/webchat 2.2.20 → 2.3.1

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 (53) 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 +1 -1
  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 +57 -48
  24. package/dist/gen/client/operations/createMessage.d.ts +114 -96
  25. package/dist/gen/client/operations/getMessage.d.ts +57 -48
  26. package/dist/gen/client/operations/listConversationMessages.d.ts +57 -48
  27. package/dist/gen/signals/index.d.ts +409 -94
  28. package/dist/gen/signals/messageCreated.t.d.ts +57 -48
  29. package/dist/gen/signals/messageCreated.z.d.ts +408 -86
  30. package/dist/get-client.d.ts +1 -2
  31. package/dist/hooks/useClient.d.ts +1 -2
  32. package/dist/index.js +12137 -14521
  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/styles/classes.d.ts +22 -22
  39. package/dist/types/block-type.d.ts +16 -14
  40. package/dist/types/init.d.ts +0 -1
  41. package/openapi.ts +1 -1
  42. package/package.json +3 -2
  43. package/dist/client/MessagingClient/client.d.ts +0 -35
  44. package/dist/client/MessagingClient/index.d.ts +0 -1
  45. package/dist/gen/signals/custom.j.d.ts +0 -3
  46. package/dist/gen/signals/messageCreated.j.d.ts +0 -3
  47. package/dist/gen/signals/typingStarted.j.d.ts +0 -3
  48. package/dist/gen/signals/typingStopped.j.d.ts +0 -3
  49. package/dist/gen/signals/webchatConfig.j.d.ts +0 -3
  50. package/dist/gen/signals/webchatVisibility.j.d.ts +0 -3
  51. /package/dist/client/{PushpinClient/inner-client → inner-client}/event-emitter.d.ts +0 -0
  52. /package/dist/client/{PushpinClient/inner-client → inner-client}/eventsource.d.ts +0 -0
  53. /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 {};
@@ -2,6 +2,6 @@ import { JSX } from 'react';
2
2
  import { BlockObjects, BlockType, type CommonBlockProps } from '../types';
3
3
  type BlockProps<T extends BlockType> = {
4
4
  block: BlockObjects[T];
5
- } & CommonBlockProps;
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
- } & 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("../../..").CommonBlockProps & 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("../../..").CommonBlockProps & 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("../../..").CommonBlockProps & 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("../../..").CommonBlockProps & 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("../../..").CommonBlockProps & 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("../../..").CommonBlockProps & 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>>;
@@ -60,10 +60,6 @@ export interface Message {
60
60
  */
61
61
  payload: {
62
62
  audioUrl: string;
63
- /**
64
- * CSS className to apply to the message
65
- */
66
- className?: string;
67
63
  type: "audio";
68
64
  [k: string]: any;
69
65
  } | {
@@ -77,10 +73,6 @@ export interface Message {
77
73
  [k: string]: any;
78
74
  }[];
79
75
  type: "card";
80
- /**
81
- * CSS className to apply to the message
82
- */
83
- className?: string;
84
76
  [k: string]: any;
85
77
  } | {
86
78
  items: {
@@ -93,16 +85,8 @@ export interface Message {
93
85
  value: string;
94
86
  [k: string]: any;
95
87
  }[];
96
- /**
97
- * CSS className to apply to the message
98
- */
99
- className?: string;
100
88
  [k: string]: any;
101
89
  }[];
102
- /**
103
- * CSS className to apply to the message
104
- */
105
- className?: string;
106
90
  type: "carousel";
107
91
  [k: string]: any;
108
92
  } | {
@@ -112,10 +96,6 @@ export interface Message {
112
96
  value: string;
113
97
  [k: string]: any;
114
98
  }[];
115
- /**
116
- * CSS className to apply to the message
117
- */
118
- className?: string;
119
99
  type: "choice";
120
100
  disableFreeText?: boolean;
121
101
  [k: string]: any;
@@ -126,27 +106,15 @@ export interface Message {
126
106
  value: string;
127
107
  [k: string]: any;
128
108
  }[];
129
- /**
130
- * CSS className to apply to the message
131
- */
132
- className?: string;
133
109
  type: "dropdown";
134
110
  [k: string]: any;
135
111
  } | {
136
112
  fileUrl: string;
137
113
  title?: string;
138
- /**
139
- * CSS className to apply to the message
140
- */
141
- className?: string;
142
114
  type: "file";
143
115
  [k: string]: any;
144
116
  } | {
145
117
  imageUrl: string;
146
- /**
147
- * CSS className to apply to the message
148
- */
149
- className?: string;
150
118
  type: "image";
151
119
  [k: string]: any;
152
120
  } | {
@@ -154,36 +122,77 @@ export interface Message {
154
122
  longitude: number;
155
123
  address?: string;
156
124
  title?: string;
157
- /**
158
- * CSS className to apply to the message
159
- */
160
- className?: string;
161
125
  type: "location";
162
126
  [k: string]: any;
163
127
  } | {
164
128
  markdown: string;
165
- /**
166
- * CSS className to apply to the message
167
- */
168
- className?: string;
169
129
  type: "markdown";
170
130
  [k: string]: any;
171
131
  } | {
172
132
  text: string;
173
- /**
174
- * CSS className to apply to the message
175
- */
176
- className?: string;
177
133
  type: "text";
178
134
  [k: string]: any;
179
135
  } | {
180
136
  videoUrl: string;
181
- /**
182
- * CSS className to apply to the message
183
- */
184
- className?: string;
185
137
  type: "video";
186
138
  [k: string]: any;
139
+ } | {
140
+ items: ({
141
+ type: "text";
142
+ payload: {
143
+ text: string;
144
+ [k: string]: any;
145
+ };
146
+ [k: string]: any;
147
+ } | {
148
+ type: "markdown";
149
+ payload: {
150
+ markdown: string;
151
+ [k: string]: any;
152
+ };
153
+ [k: string]: any;
154
+ } | {
155
+ type: "image";
156
+ payload: {
157
+ imageUrl: string;
158
+ [k: string]: any;
159
+ };
160
+ [k: string]: any;
161
+ } | {
162
+ type: "audio";
163
+ payload: {
164
+ audioUrl: string;
165
+ [k: string]: any;
166
+ };
167
+ [k: string]: any;
168
+ } | {
169
+ type: "video";
170
+ payload: {
171
+ videoUrl: string;
172
+ [k: string]: any;
173
+ };
174
+ [k: string]: any;
175
+ } | {
176
+ type: "file";
177
+ payload: {
178
+ fileUrl: string;
179
+ title?: string;
180
+ [k: string]: any;
181
+ };
182
+ [k: string]: any;
183
+ } | {
184
+ type: "location";
185
+ payload: {
186
+ latitude: number;
187
+ longitude: number;
188
+ address?: string;
189
+ title?: string;
190
+ [k: string]: any;
191
+ };
192
+ [k: string]: any;
193
+ })[];
194
+ type: "bloc";
195
+ [k: string]: any;
187
196
  };
188
197
  /**
189
198
  * ID of the [User](#schema_user)