@botpress/webchat 0.5.1 → 1.0.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/App.d.ts +10 -0
- package/dist/Utils/colors.d.ts +18 -0
- package/dist/Utils/eventEmitter.d.ts +12 -0
- package/dist/Utils/index.d.ts +2 -0
- package/dist/client/MessagingClient.d.ts +27 -0
- package/dist/client/adapters/Audio.d.ts +19 -0
- package/dist/client/adapters/Card.d.ts +188 -0
- package/dist/client/adapters/Carousel.d.ts +147 -0
- package/dist/client/adapters/Choice.d.ts +45 -0
- package/dist/client/adapters/Dropdown.d.ts +46 -0
- package/dist/client/adapters/File.d.ts +19 -0
- package/dist/client/adapters/Image.d.ts +19 -0
- package/dist/client/adapters/Location.d.ts +27 -0
- package/dist/client/adapters/Message.d.ts +433 -0
- package/dist/client/adapters/Text.d.ts +20 -0
- package/dist/client/adapters/Utils.d.ts +5 -0
- package/dist/client/adapters/Video.d.ts +19 -0
- package/dist/client/adapters/Voice.d.ts +15 -0
- package/dist/client/adapters/index.d.ts +12 -0
- package/dist/client/index.d.ts +2 -0
- package/dist/components/Avatar.d.ts +6 -0
- package/dist/components/Block.d.ts +4 -0
- package/dist/components/Composer.d.ts +12 -14
- package/dist/components/Container.d.ts +2 -12
- package/dist/components/Header.d.ts +36 -26
- package/dist/components/LoadingIndicator.d.ts +2 -0
- package/dist/components/Message.d.ts +7 -0
- package/dist/components/MessageList.d.ts +2 -0
- package/dist/components/Modal.d.ts +17 -0
- package/dist/components/RestartConversation.d.ts +5 -0
- package/dist/components/Webchat.d.ts +6 -0
- package/dist/components/dev-tools/DevTools.d.ts +1 -0
- package/dist/components/dev-tools/configuration.d.ts +2 -0
- package/dist/components/dev-tools/helpers.d.ts +5 -0
- package/dist/components/index.d.ts +12 -0
- package/dist/components/renderers/Audio.d.ts +3 -0
- package/dist/components/renderers/Bubble.d.ts +5 -0
- package/dist/components/renderers/Button.d.ts +4 -0
- package/dist/components/renderers/Carousel.d.ts +3 -0
- package/dist/components/renderers/Column.d.ts +5 -0
- package/dist/components/renderers/Dropdown.d.ts +5 -0
- package/dist/components/renderers/File.d.ts +3 -0
- package/dist/components/renderers/Image.d.ts +3 -0
- package/dist/components/renderers/Location.d.ts +3 -0
- package/dist/components/renderers/Row.d.ts +5 -0
- package/dist/components/renderers/Text.d.ts +4 -0
- package/dist/components/renderers/Video.d.ts +3 -0
- package/dist/components/renderers/index.d.ts +2 -0
- package/dist/contexts/ComposerContext.d.ts +8 -0
- package/dist/contexts/MessageContext.d.ts +8 -0
- package/dist/contexts/ModalContext.d.ts +14 -0
- package/dist/contexts/WebchatContext.d.ts +56 -0
- package/dist/contexts/index.d.ts +4 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/useImageSize.d.ts +2 -0
- package/dist/hooks/useRefresh.d.ts +10 -0
- package/dist/hooks/useWebchatStore.d.ts +30 -0
- package/dist/index.d.ts +3 -17
- package/dist/index.js +43569 -48
- package/dist/index.umd.cjs +702 -0
- package/dist/main.d.ts +11 -13
- package/dist/providers/ModalProvider.d.ts +8 -0
- package/dist/providers/WebchatProvider.d.ts +13 -0
- package/dist/providers/index.d.ts +2 -0
- package/dist/schemas/index.d.ts +1 -0
- package/dist/schemas/theme.d.ts +3371 -0
- package/dist/services/clipboard.d.ts +1 -0
- package/dist/services/images.d.ts +2 -0
- package/dist/services/index.d.ts +3 -0
- package/dist/services/toast.d.ts +17 -0
- package/dist/themes/dawn.d.ts +2 -0
- package/dist/themes/duskTheme.d.ts +2 -0
- package/dist/themes/eggplant.d.ts +2 -0
- package/dist/themes/galaxy.d.ts +2 -0
- package/dist/themes/index.d.ts +6 -0
- package/dist/themes/midnight.d.ts +2 -0
- package/dist/themes/prism.d.ts +2 -0
- package/dist/twind.config.d.ts +9 -0
- package/dist/types/block-type.d.ts +93 -0
- package/dist/types/image.d.ts +11 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/vite.svg +1 -0
- package/index.html +18 -0
- package/package.json +60 -49
- package/public/vite.svg +1 -0
- package/src/App.tsx +41 -0
- package/src/Utils/colors.ts +45 -0
- package/src/Utils/eventEmitter.ts +31 -0
- package/src/Utils/index.ts +2 -0
- package/src/assets/check-circle-bold.svg +5 -0
- package/src/assets/chevron-up.svg +3 -0
- package/src/assets/file-05.svg +6 -0
- package/src/assets/globe-02.svg +6 -0
- package/src/assets/help-circle.svg +3 -0
- package/src/assets/info-circle.svg +3 -0
- package/src/assets/lock-01.svg +4 -0
- package/src/assets/mail-01.svg +6 -0
- package/src/assets/minus-circle.svg +3 -0
- package/src/assets/phone.svg +6 -0
- package/src/assets/send-03.svg +4 -0
- package/src/assets/share-04.svg +5 -0
- package/src/assets/slash-circle-01.svg +3 -0
- package/src/assets/x-circle-bold.svg +5 -0
- package/src/assets/x-close.svg +3 -0
- package/src/assets/x.svg +3 -0
- package/src/client/MessagingClient.ts +87 -0
- package/src/client/adapters/Audio.ts +10 -0
- package/src/client/adapters/Card.ts +104 -0
- package/src/client/adapters/Carousel.ts +11 -0
- package/src/client/adapters/Choice.ts +48 -0
- package/src/client/adapters/Dropdown.ts +39 -0
- package/src/client/adapters/File.ts +10 -0
- package/src/client/adapters/Image.ts +10 -0
- package/src/client/adapters/Location.ts +18 -0
- package/src/client/adapters/Message.ts +26 -0
- package/src/client/adapters/Text.ts +11 -0
- package/src/client/adapters/Utils.ts +11 -0
- package/src/client/adapters/Video.ts +10 -0
- package/src/client/adapters/Voice.ts +9 -0
- package/src/client/adapters/index.ts +12 -0
- package/src/client/index.ts +2 -0
- package/src/components/Avatar.tsx +22 -0
- package/src/components/Block.tsx +17 -0
- package/src/components/Composer.tsx +115 -0
- package/src/components/Container.tsx +17 -0
- package/src/components/Header.tsx +141 -0
- package/src/components/LoadingIndicator.tsx +15 -0
- package/src/components/Message.tsx +52 -0
- package/src/components/MessageList.tsx +75 -0
- package/src/components/Modal.tsx +49 -0
- package/src/components/RestartConversation.tsx +52 -0
- package/src/components/Webchat.tsx +68 -0
- package/src/components/dev-tools/DevTools.tsx +496 -0
- package/src/components/dev-tools/configuration.tsx +27 -0
- package/src/components/dev-tools/helpers.ts +21 -0
- package/src/components/index.ts +12 -0
- package/src/components/renderers/Audio.tsx +11 -0
- package/src/components/renderers/Bubble.tsx +12 -0
- package/src/components/renderers/Button.tsx +59 -0
- package/src/components/renderers/Carousel.tsx +51 -0
- package/src/components/renderers/Column.tsx +22 -0
- package/src/components/renderers/Dropdown.tsx +170 -0
- package/src/components/renderers/File.tsx +13 -0
- package/src/components/renderers/Image.tsx +63 -0
- package/src/components/renderers/Location.tsx +16 -0
- package/src/components/renderers/Row.tsx +22 -0
- package/src/components/renderers/Text.tsx +32 -0
- package/src/components/renderers/Video.tsx +11 -0
- package/src/components/renderers/index.ts +28 -0
- package/src/contexts/ComposerContext.ts +16 -0
- package/src/contexts/MessageContext.ts +16 -0
- package/src/contexts/ModalContext.ts +19 -0
- package/src/contexts/WebchatContext.ts +61 -0
- package/src/contexts/index.ts +4 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/useImageSize.ts +30 -0
- package/src/hooks/useRefresh.ts +33 -0
- package/src/hooks/useWebchatStore.ts +45 -0
- package/src/index.css +18 -0
- package/src/index.ts +3 -0
- package/src/main.tsx +33 -0
- package/src/providers/ModalProvider.tsx +35 -0
- package/src/providers/WebchatProvider.tsx +107 -0
- package/src/providers/index.ts +2 -0
- package/src/schemas/index.ts +1 -0
- package/src/schemas/theme.ts +188 -0
- package/src/services/clipboard.ts +8 -0
- package/src/services/images.ts +39 -0
- package/src/services/index.ts +3 -0
- package/src/services/toast.tsx +71 -0
- package/src/themes/dawn.ts +277 -0
- package/src/themes/duskTheme.ts +349 -0
- package/src/themes/eggplant.ts +353 -0
- package/src/themes/galaxy.ts +323 -0
- package/src/themes/index.ts +6 -0
- package/src/themes/midnight.ts +276 -0
- package/src/themes/prism.ts +349 -0
- package/src/twind.config.ts +31 -0
- package/src/types/block-type.ts +150 -0
- package/src/types/image.ts +10 -0
- package/src/types/index.ts +2 -0
- package/src/vite-env.d.ts +1 -0
- package/tailwind.config.js +0 -0
- package/tsconfig.json +30 -0
- package/tsconfig.node.json +10 -0
- package/vite.config.ts +31 -0
- package/README.md +0 -41
- package/assets/fonts/roboto/roboto.woff2 +0 -0
- package/assets/fonts/roboto/roboto500.woff2 +0 -0
- package/assets/fonts/roboto.css +0 -128
- package/assets/notification.mp3 +0 -0
- package/dist/components/Composer.js +0 -118
- package/dist/components/Container.js +0 -62
- package/dist/components/ConversationList.d.ts +0 -10
- package/dist/components/ConversationList.js +0 -41
- package/dist/components/Footer.d.ts +0 -3
- package/dist/components/Footer.js +0 -21
- package/dist/components/Header.js +0 -181
- package/dist/components/VoiceRecorder.d.ts +0 -10
- package/dist/components/VoiceRecorder.js +0 -137
- package/dist/components/common/Avatar/index.d.ts +0 -9
- package/dist/components/common/Avatar/index.js +0 -13
- package/dist/components/common/BotInfo/index.d.ts +0 -10
- package/dist/components/common/BotInfo/index.js +0 -107
- package/dist/components/common/BotInfo/style.scss +0 -88
- package/dist/components/common/ConfirmDialog/index.d.ts +0 -11
- package/dist/components/common/ConfirmDialog/index.js +0 -78
- package/dist/components/common/ConfirmDialog/style.module.scss +0 -48
- package/dist/components/common/Dialog/index.d.ts +0 -17
- package/dist/components/common/Dialog/index.js +0 -57
- package/dist/components/common/Dialog/style.module.scss +0 -29
- package/dist/components/common/ToolTip/index.d.ts +0 -10
- package/dist/components/common/ToolTip/index.js +0 -163
- package/dist/components/common/ToolTip/style.module.scss +0 -108
- package/dist/components/common/ToolTip/utils.d.ts +0 -15
- package/dist/components/common/ToolTip/utils.js +0 -78
- package/dist/components/common/variables.scss +0 -38
- package/dist/components/messages/InlineFeedback.d.ts +0 -11
- package/dist/components/messages/InlineFeedback.js +0 -56
- package/dist/components/messages/Message.d.ts +0 -11
- package/dist/components/messages/Message.js +0 -106
- package/dist/components/messages/MessageGroup.d.ts +0 -23
- package/dist/components/messages/MessageGroup.js +0 -63
- package/dist/components/messages/MessageList.d.ts +0 -10
- package/dist/components/messages/MessageList.js +0 -148
- package/dist/core/api.d.ts +0 -23
- package/dist/core/api.js +0 -117
- package/dist/core/constants.d.ts +0 -14
- package/dist/core/constants.js +0 -29
- package/dist/core/socket.d.ts +0 -14
- package/dist/core/socket.js +0 -57
- package/dist/declaration.d.ts +0 -2
- package/dist/declaration.js +0 -1
- package/dist/fonts/roboto.d.ts +0 -4
- package/dist/fonts/roboto.js +0 -9
- package/dist/globals.d.ts +0 -7
- package/dist/globals.js +0 -2
- package/dist/icons/Add.d.ts +0 -6
- package/dist/icons/Add.js +0 -10
- package/dist/icons/Cancel.d.ts +0 -5
- package/dist/icons/Cancel.js +0 -10
- package/dist/icons/Chat.d.ts +0 -6
- package/dist/icons/Chat.js +0 -9
- package/dist/icons/Close.d.ts +0 -3
- package/dist/icons/Close.js +0 -10
- package/dist/icons/Delete.d.ts +0 -3
- package/dist/icons/Delete.js +0 -11
- package/dist/icons/Download.d.ts +0 -3
- package/dist/icons/Download.js +0 -10
- package/dist/icons/Email.d.ts +0 -3
- package/dist/icons/Email.js +0 -8
- package/dist/icons/Information.d.ts +0 -3
- package/dist/icons/Information.js +0 -12
- package/dist/icons/List.d.ts +0 -3
- package/dist/icons/List.js +0 -15
- package/dist/icons/Microphone.d.ts +0 -5
- package/dist/icons/Microphone.js +0 -12
- package/dist/icons/Phone.d.ts +0 -3
- package/dist/icons/Phone.js +0 -8
- package/dist/icons/Reload.d.ts +0 -3
- package/dist/icons/Reload.js +0 -10
- package/dist/icons/ThumbsDown.d.ts +0 -3
- package/dist/icons/ThumbsDown.js +0 -11
- package/dist/icons/ThumbsUp.d.ts +0 -3
- package/dist/icons/ThumbsUp.js +0 -11
- package/dist/icons/Website.d.ts +0 -3
- package/dist/icons/Website.js +0 -8
- package/dist/main.js +0 -336
- package/dist/store/composer.d.ts +0 -17
- package/dist/store/composer.js +0 -98
- package/dist/store/index.d.ts +0 -89
- package/dist/store/index.js +0 -604
- package/dist/store/view.d.ts +0 -61
- package/dist/store/view.js +0 -365
- package/dist/translations/ar.json +0 -30
- package/dist/translations/de.json +0 -32
- package/dist/translations/en.json +0 -40
- package/dist/translations/es.json +0 -19
- package/dist/translations/fr.json +0 -40
- package/dist/translations/index.d.ts +0 -9
- package/dist/translations/index.js +0 -95
- package/dist/translations/it.json +0 -38
- package/dist/translations/pt.json +0 -19
- package/dist/translations/ru.json +0 -24
- package/dist/translations/uk.json +0 -24
- package/dist/typings.d.ts +0 -410
- package/dist/typings.js +0 -2
- package/dist/utils/analytics.d.ts +0 -5
- package/dist/utils/analytics.js +0 -37
- package/dist/utils/index.d.ts +0 -3
- package/dist/utils/index.js +0 -27
- package/dist/utils/storage.d.ts +0 -16
- package/dist/utils/storage.js +0 -129
- package/dist/utils/webchatEvents.d.ts +0 -2
- package/dist/utils/webchatEvents.js +0 -14
package/dist/App.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ComponentProps } from 'react';
|
|
2
|
+
import { WebchatClient } from './client';
|
|
3
|
+
import { Container } from './components';
|
|
4
|
+
import { Theme } from './schemas';
|
|
5
|
+
type Props = {
|
|
6
|
+
theme: Theme;
|
|
7
|
+
client: WebchatClient;
|
|
8
|
+
} & ComponentProps<typeof Container>;
|
|
9
|
+
export declare const App: ({ theme, client }: Props) => JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare function buildColorPalette(color: string, theme?: 'light' | 'dark'): {
|
|
2
|
+
primary: string;
|
|
3
|
+
primaryHover: string;
|
|
4
|
+
primaryHoverDark: string;
|
|
5
|
+
onPrimary: string;
|
|
6
|
+
primaryContainer: string;
|
|
7
|
+
primaryContainerHover: string;
|
|
8
|
+
onPrimaryContainer: string;
|
|
9
|
+
secondary: string;
|
|
10
|
+
secondaryHover: string;
|
|
11
|
+
onSecondary: string;
|
|
12
|
+
secondaryContainer: string;
|
|
13
|
+
secondaryContainerHover: string;
|
|
14
|
+
onSecondaryContainer: string;
|
|
15
|
+
};
|
|
16
|
+
type Grays = 'gray' | 'stone' | 'slate' | 'zinc' | 'neutral';
|
|
17
|
+
export declare function selectGrayFromColor(color: string, omit?: Grays[]): Grays;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type CallbackFn<T> = (args: T) => void;
|
|
2
|
+
export declare class EventEmitter<T extends Record<string, any>> {
|
|
3
|
+
private readonly eventMap;
|
|
4
|
+
constructor();
|
|
5
|
+
on<U extends keyof T>(event: U, callback: CallbackFn<T[U]>): () => void;
|
|
6
|
+
emit<U extends keyof T>(event: U, arg?: T[U]): void;
|
|
7
|
+
}
|
|
8
|
+
export type Events = {
|
|
9
|
+
[key: string]: undefined;
|
|
10
|
+
};
|
|
11
|
+
export declare const eventEmitter: EventEmitter<Events>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type MessagingSocketOptions, type UserCredentials, type Message } from '@botpress/messaging-socket';
|
|
2
|
+
import { EventEmitter } from '../Utils';
|
|
3
|
+
type Events = {
|
|
4
|
+
connect: UserCredentials;
|
|
5
|
+
disconnect: undefined;
|
|
6
|
+
user: string | undefined;
|
|
7
|
+
conversation: string | undefined;
|
|
8
|
+
message: Message;
|
|
9
|
+
messageSent: string;
|
|
10
|
+
startTyping: undefined;
|
|
11
|
+
stopTyping: undefined;
|
|
12
|
+
};
|
|
13
|
+
export declare class WebchatClient {
|
|
14
|
+
private socket;
|
|
15
|
+
userId: string | undefined;
|
|
16
|
+
private conversationId;
|
|
17
|
+
private userToken;
|
|
18
|
+
private connected;
|
|
19
|
+
private readonly emitter;
|
|
20
|
+
on: EventEmitter<Events>['on'];
|
|
21
|
+
constructor(options: MessagingSocketOptions);
|
|
22
|
+
connect(creds?: UserCredentials): Promise<UserCredentials | undefined>;
|
|
23
|
+
disconnect(): Promise<void>;
|
|
24
|
+
sendMessage(message: string): Promise<void>;
|
|
25
|
+
newConversation(): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { AudioBlock } from '../../types';
|
|
3
|
+
export declare const AudioSchema: z.ZodEffects<z.ZodObject<{
|
|
4
|
+
type: z.ZodLiteral<"audio">;
|
|
5
|
+
audio: z.ZodString;
|
|
6
|
+
title: z.ZodOptional<z.ZodString>;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
audio: string;
|
|
9
|
+
type: "audio";
|
|
10
|
+
title?: string | undefined;
|
|
11
|
+
}, {
|
|
12
|
+
audio: string;
|
|
13
|
+
type: "audio";
|
|
14
|
+
title?: string | undefined;
|
|
15
|
+
}>, AudioBlock, {
|
|
16
|
+
audio: string;
|
|
17
|
+
type: "audio";
|
|
18
|
+
title?: string | undefined;
|
|
19
|
+
}>;
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ButtonBlock, ColumnBlock, ImageBlock, TextBlock } from '../../types';
|
|
3
|
+
import { WithBubble } from './Utils';
|
|
4
|
+
export type CardBlockType = {
|
|
5
|
+
blocks: CardBlocks;
|
|
6
|
+
} & Omit<ColumnBlock, 'blocks'>;
|
|
7
|
+
type CardBlocks = (ImageBlock | TextBlock | {
|
|
8
|
+
type: 'row';
|
|
9
|
+
blocks: ButtonBlock[];
|
|
10
|
+
})[];
|
|
11
|
+
export declare const BaseCardSchema: z.ZodObject<{
|
|
12
|
+
type: z.ZodLiteral<"card">;
|
|
13
|
+
title: z.ZodOptional<z.ZodString>;
|
|
14
|
+
subtitle: z.ZodOptional<z.ZodString>;
|
|
15
|
+
image: z.ZodOptional<z.ZodString>;
|
|
16
|
+
actions: z.ZodArray<z.ZodUnion<[z.ZodEffects<z.ZodObject<{
|
|
17
|
+
title: z.ZodString;
|
|
18
|
+
action: z.ZodLiteral<"Say something">;
|
|
19
|
+
text: z.ZodString;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
title: string;
|
|
22
|
+
text: string;
|
|
23
|
+
action: "Say something";
|
|
24
|
+
}, {
|
|
25
|
+
title: string;
|
|
26
|
+
text: string;
|
|
27
|
+
action: "Say something";
|
|
28
|
+
}>, ButtonBlock, {
|
|
29
|
+
title: string;
|
|
30
|
+
text: string;
|
|
31
|
+
action: "Say something";
|
|
32
|
+
}>, z.ZodEffects<z.ZodObject<{
|
|
33
|
+
title: z.ZodString;
|
|
34
|
+
action: z.ZodLiteral<"Open URL">;
|
|
35
|
+
url: z.ZodString;
|
|
36
|
+
}, "strip", z.ZodTypeAny, {
|
|
37
|
+
title: string;
|
|
38
|
+
url: string;
|
|
39
|
+
action: "Open URL";
|
|
40
|
+
}, {
|
|
41
|
+
title: string;
|
|
42
|
+
url: string;
|
|
43
|
+
action: "Open URL";
|
|
44
|
+
}>, ButtonBlock, {
|
|
45
|
+
title: string;
|
|
46
|
+
url: string;
|
|
47
|
+
action: "Open URL";
|
|
48
|
+
}>, z.ZodEffects<z.ZodObject<{
|
|
49
|
+
title: z.ZodString;
|
|
50
|
+
action: z.ZodLiteral<"Postback">;
|
|
51
|
+
payload: z.ZodString;
|
|
52
|
+
}, "strip", z.ZodTypeAny, {
|
|
53
|
+
title: string;
|
|
54
|
+
action: "Postback";
|
|
55
|
+
payload: string;
|
|
56
|
+
}, {
|
|
57
|
+
title: string;
|
|
58
|
+
action: "Postback";
|
|
59
|
+
payload: string;
|
|
60
|
+
}>, ButtonBlock, {
|
|
61
|
+
title: string;
|
|
62
|
+
action: "Postback";
|
|
63
|
+
payload: string;
|
|
64
|
+
}>]>, "many">;
|
|
65
|
+
}, "strip", z.ZodTypeAny, {
|
|
66
|
+
type: "card";
|
|
67
|
+
actions: ButtonBlock[];
|
|
68
|
+
title?: string | undefined;
|
|
69
|
+
subtitle?: string | undefined;
|
|
70
|
+
image?: string | undefined;
|
|
71
|
+
}, {
|
|
72
|
+
type: "card";
|
|
73
|
+
actions: ({
|
|
74
|
+
title: string;
|
|
75
|
+
text: string;
|
|
76
|
+
action: "Say something";
|
|
77
|
+
} | {
|
|
78
|
+
title: string;
|
|
79
|
+
url: string;
|
|
80
|
+
action: "Open URL";
|
|
81
|
+
} | {
|
|
82
|
+
title: string;
|
|
83
|
+
action: "Postback";
|
|
84
|
+
payload: string;
|
|
85
|
+
})[];
|
|
86
|
+
title?: string | undefined;
|
|
87
|
+
subtitle?: string | undefined;
|
|
88
|
+
image?: string | undefined;
|
|
89
|
+
}>;
|
|
90
|
+
export declare const CardSchemaTransform: ({ title, image, actions, subtitle, }: Omit<z.infer<typeof BaseCardSchema>, 'type'>) => CardBlockType;
|
|
91
|
+
export declare const CardSchema: z.ZodEffects<z.ZodObject<{
|
|
92
|
+
type: z.ZodLiteral<"card">;
|
|
93
|
+
title: z.ZodOptional<z.ZodString>;
|
|
94
|
+
subtitle: z.ZodOptional<z.ZodString>;
|
|
95
|
+
image: z.ZodOptional<z.ZodString>;
|
|
96
|
+
actions: z.ZodArray<z.ZodUnion<[z.ZodEffects<z.ZodObject<{
|
|
97
|
+
title: z.ZodString;
|
|
98
|
+
action: z.ZodLiteral<"Say something">;
|
|
99
|
+
text: z.ZodString;
|
|
100
|
+
}, "strip", z.ZodTypeAny, {
|
|
101
|
+
title: string;
|
|
102
|
+
text: string;
|
|
103
|
+
action: "Say something";
|
|
104
|
+
}, {
|
|
105
|
+
title: string;
|
|
106
|
+
text: string;
|
|
107
|
+
action: "Say something";
|
|
108
|
+
}>, ButtonBlock, {
|
|
109
|
+
title: string;
|
|
110
|
+
text: string;
|
|
111
|
+
action: "Say something";
|
|
112
|
+
}>, z.ZodEffects<z.ZodObject<{
|
|
113
|
+
title: z.ZodString;
|
|
114
|
+
action: z.ZodLiteral<"Open URL">;
|
|
115
|
+
url: z.ZodString;
|
|
116
|
+
}, "strip", z.ZodTypeAny, {
|
|
117
|
+
title: string;
|
|
118
|
+
url: string;
|
|
119
|
+
action: "Open URL";
|
|
120
|
+
}, {
|
|
121
|
+
title: string;
|
|
122
|
+
url: string;
|
|
123
|
+
action: "Open URL";
|
|
124
|
+
}>, ButtonBlock, {
|
|
125
|
+
title: string;
|
|
126
|
+
url: string;
|
|
127
|
+
action: "Open URL";
|
|
128
|
+
}>, z.ZodEffects<z.ZodObject<{
|
|
129
|
+
title: z.ZodString;
|
|
130
|
+
action: z.ZodLiteral<"Postback">;
|
|
131
|
+
payload: z.ZodString;
|
|
132
|
+
}, "strip", z.ZodTypeAny, {
|
|
133
|
+
title: string;
|
|
134
|
+
action: "Postback";
|
|
135
|
+
payload: string;
|
|
136
|
+
}, {
|
|
137
|
+
title: string;
|
|
138
|
+
action: "Postback";
|
|
139
|
+
payload: string;
|
|
140
|
+
}>, ButtonBlock, {
|
|
141
|
+
title: string;
|
|
142
|
+
action: "Postback";
|
|
143
|
+
payload: string;
|
|
144
|
+
}>]>, "many">;
|
|
145
|
+
}, "strip", z.ZodTypeAny, {
|
|
146
|
+
type: "card";
|
|
147
|
+
actions: ButtonBlock[];
|
|
148
|
+
title?: string | undefined;
|
|
149
|
+
subtitle?: string | undefined;
|
|
150
|
+
image?: string | undefined;
|
|
151
|
+
}, {
|
|
152
|
+
type: "card";
|
|
153
|
+
actions: ({
|
|
154
|
+
title: string;
|
|
155
|
+
text: string;
|
|
156
|
+
action: "Say something";
|
|
157
|
+
} | {
|
|
158
|
+
title: string;
|
|
159
|
+
url: string;
|
|
160
|
+
action: "Open URL";
|
|
161
|
+
} | {
|
|
162
|
+
title: string;
|
|
163
|
+
action: "Postback";
|
|
164
|
+
payload: string;
|
|
165
|
+
})[];
|
|
166
|
+
title?: string | undefined;
|
|
167
|
+
subtitle?: string | undefined;
|
|
168
|
+
image?: string | undefined;
|
|
169
|
+
}>, WithBubble<CardBlockType>, {
|
|
170
|
+
type: "card";
|
|
171
|
+
actions: ({
|
|
172
|
+
title: string;
|
|
173
|
+
text: string;
|
|
174
|
+
action: "Say something";
|
|
175
|
+
} | {
|
|
176
|
+
title: string;
|
|
177
|
+
url: string;
|
|
178
|
+
action: "Open URL";
|
|
179
|
+
} | {
|
|
180
|
+
title: string;
|
|
181
|
+
action: "Postback";
|
|
182
|
+
payload: string;
|
|
183
|
+
})[];
|
|
184
|
+
title?: string | undefined;
|
|
185
|
+
subtitle?: string | undefined;
|
|
186
|
+
image?: string | undefined;
|
|
187
|
+
}>;
|
|
188
|
+
export {};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { CardBlockType } from './Card';
|
|
3
|
+
import { CarouselBlock } from '../../types';
|
|
4
|
+
type CarouselBlockType = {
|
|
5
|
+
blocks: CardBlockType[];
|
|
6
|
+
} & Omit<CarouselBlock, 'blocks'>;
|
|
7
|
+
export declare const CarouselSchema: z.ZodEffects<z.ZodObject<{
|
|
8
|
+
type: z.ZodLiteral<"carousel">;
|
|
9
|
+
items: z.ZodArray<z.ZodEffects<z.ZodObject<Omit<{
|
|
10
|
+
type: z.ZodLiteral<"card">;
|
|
11
|
+
title: z.ZodOptional<z.ZodString>;
|
|
12
|
+
subtitle: z.ZodOptional<z.ZodString>;
|
|
13
|
+
image: z.ZodOptional<z.ZodString>;
|
|
14
|
+
actions: z.ZodArray<z.ZodUnion<[z.ZodEffects<z.ZodObject<{
|
|
15
|
+
title: z.ZodString;
|
|
16
|
+
action: z.ZodLiteral<"Say something">;
|
|
17
|
+
text: z.ZodString;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
title: string;
|
|
20
|
+
text: string;
|
|
21
|
+
action: "Say something";
|
|
22
|
+
}, {
|
|
23
|
+
title: string;
|
|
24
|
+
text: string;
|
|
25
|
+
action: "Say something";
|
|
26
|
+
}>, import("../../types").ButtonBlock, {
|
|
27
|
+
title: string;
|
|
28
|
+
text: string;
|
|
29
|
+
action: "Say something";
|
|
30
|
+
}>, z.ZodEffects<z.ZodObject<{
|
|
31
|
+
title: z.ZodString;
|
|
32
|
+
action: z.ZodLiteral<"Open URL">;
|
|
33
|
+
url: z.ZodString;
|
|
34
|
+
}, "strip", z.ZodTypeAny, {
|
|
35
|
+
title: string;
|
|
36
|
+
url: string;
|
|
37
|
+
action: "Open URL";
|
|
38
|
+
}, {
|
|
39
|
+
title: string;
|
|
40
|
+
url: string;
|
|
41
|
+
action: "Open URL";
|
|
42
|
+
}>, import("../../types").ButtonBlock, {
|
|
43
|
+
title: string;
|
|
44
|
+
url: string;
|
|
45
|
+
action: "Open URL";
|
|
46
|
+
}>, z.ZodEffects<z.ZodObject<{
|
|
47
|
+
title: z.ZodString;
|
|
48
|
+
action: z.ZodLiteral<"Postback">;
|
|
49
|
+
payload: z.ZodString;
|
|
50
|
+
}, "strip", z.ZodTypeAny, {
|
|
51
|
+
title: string;
|
|
52
|
+
action: "Postback";
|
|
53
|
+
payload: string;
|
|
54
|
+
}, {
|
|
55
|
+
title: string;
|
|
56
|
+
action: "Postback";
|
|
57
|
+
payload: string;
|
|
58
|
+
}>, import("../../types").ButtonBlock, {
|
|
59
|
+
title: string;
|
|
60
|
+
action: "Postback";
|
|
61
|
+
payload: string;
|
|
62
|
+
}>]>, "many">;
|
|
63
|
+
}, "type">, "strip", z.ZodTypeAny, {
|
|
64
|
+
actions: import("../../types").ButtonBlock[];
|
|
65
|
+
title?: string | undefined;
|
|
66
|
+
image?: string | undefined;
|
|
67
|
+
subtitle?: string | undefined;
|
|
68
|
+
}, {
|
|
69
|
+
actions: ({
|
|
70
|
+
title: string;
|
|
71
|
+
text: string;
|
|
72
|
+
action: "Say something";
|
|
73
|
+
} | {
|
|
74
|
+
title: string;
|
|
75
|
+
url: string;
|
|
76
|
+
action: "Open URL";
|
|
77
|
+
} | {
|
|
78
|
+
title: string;
|
|
79
|
+
action: "Postback";
|
|
80
|
+
payload: string;
|
|
81
|
+
})[];
|
|
82
|
+
title?: string | undefined;
|
|
83
|
+
image?: string | undefined;
|
|
84
|
+
subtitle?: string | undefined;
|
|
85
|
+
}>, CardBlockType, {
|
|
86
|
+
actions: ({
|
|
87
|
+
title: string;
|
|
88
|
+
text: string;
|
|
89
|
+
action: "Say something";
|
|
90
|
+
} | {
|
|
91
|
+
title: string;
|
|
92
|
+
url: string;
|
|
93
|
+
action: "Open URL";
|
|
94
|
+
} | {
|
|
95
|
+
title: string;
|
|
96
|
+
action: "Postback";
|
|
97
|
+
payload: string;
|
|
98
|
+
})[];
|
|
99
|
+
title?: string | undefined;
|
|
100
|
+
image?: string | undefined;
|
|
101
|
+
subtitle?: string | undefined;
|
|
102
|
+
}>, "many">;
|
|
103
|
+
}, "strip", z.ZodTypeAny, {
|
|
104
|
+
type: "carousel";
|
|
105
|
+
items: CardBlockType[];
|
|
106
|
+
}, {
|
|
107
|
+
type: "carousel";
|
|
108
|
+
items: {
|
|
109
|
+
actions: ({
|
|
110
|
+
title: string;
|
|
111
|
+
text: string;
|
|
112
|
+
action: "Say something";
|
|
113
|
+
} | {
|
|
114
|
+
title: string;
|
|
115
|
+
url: string;
|
|
116
|
+
action: "Open URL";
|
|
117
|
+
} | {
|
|
118
|
+
title: string;
|
|
119
|
+
action: "Postback";
|
|
120
|
+
payload: string;
|
|
121
|
+
})[];
|
|
122
|
+
title?: string | undefined;
|
|
123
|
+
image?: string | undefined;
|
|
124
|
+
subtitle?: string | undefined;
|
|
125
|
+
}[];
|
|
126
|
+
}>, CarouselBlockType, {
|
|
127
|
+
type: "carousel";
|
|
128
|
+
items: {
|
|
129
|
+
actions: ({
|
|
130
|
+
title: string;
|
|
131
|
+
text: string;
|
|
132
|
+
action: "Say something";
|
|
133
|
+
} | {
|
|
134
|
+
title: string;
|
|
135
|
+
url: string;
|
|
136
|
+
action: "Open URL";
|
|
137
|
+
} | {
|
|
138
|
+
title: string;
|
|
139
|
+
action: "Postback";
|
|
140
|
+
payload: string;
|
|
141
|
+
})[];
|
|
142
|
+
title?: string | undefined;
|
|
143
|
+
image?: string | undefined;
|
|
144
|
+
subtitle?: string | undefined;
|
|
145
|
+
}[];
|
|
146
|
+
}>;
|
|
147
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ButtonBlock, ColumnBlock, RowBlock, TextBlock } from '../../types';
|
|
3
|
+
import { WithBubble } from './Utils';
|
|
4
|
+
type ButtonBlocks = {
|
|
5
|
+
blocks: ButtonBlock[];
|
|
6
|
+
} & Omit<RowBlock, 'blocks'>;
|
|
7
|
+
type ChoiceBlockType = {
|
|
8
|
+
blocks: (ButtonBlocks | TextBlock)[];
|
|
9
|
+
} & Omit<ColumnBlock, 'blocks'>;
|
|
10
|
+
export declare const ChoiceSchema: z.ZodEffects<z.ZodObject<{
|
|
11
|
+
type: z.ZodLiteral<"single-choice">;
|
|
12
|
+
text: z.ZodString;
|
|
13
|
+
choices: z.ZodArray<z.ZodObject<{
|
|
14
|
+
title: z.ZodString;
|
|
15
|
+
value: z.ZodString;
|
|
16
|
+
}, "strip", z.ZodTypeAny, {
|
|
17
|
+
title: string;
|
|
18
|
+
value: string;
|
|
19
|
+
}, {
|
|
20
|
+
title: string;
|
|
21
|
+
value: string;
|
|
22
|
+
}>, "many">;
|
|
23
|
+
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
text: string;
|
|
25
|
+
type: "single-choice";
|
|
26
|
+
choices: {
|
|
27
|
+
title: string;
|
|
28
|
+
value: string;
|
|
29
|
+
}[];
|
|
30
|
+
}, {
|
|
31
|
+
text: string;
|
|
32
|
+
type: "single-choice";
|
|
33
|
+
choices: {
|
|
34
|
+
title: string;
|
|
35
|
+
value: string;
|
|
36
|
+
}[];
|
|
37
|
+
}>, WithBubble<ChoiceBlockType>, {
|
|
38
|
+
text: string;
|
|
39
|
+
type: "single-choice";
|
|
40
|
+
choices: {
|
|
41
|
+
title: string;
|
|
42
|
+
value: string;
|
|
43
|
+
}[];
|
|
44
|
+
}>;
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ColumnBlock, DropdownBlock, TextBlock } from '../../types';
|
|
3
|
+
import { WithBubble } from './Utils';
|
|
4
|
+
type DropdownBlockType = {
|
|
5
|
+
blocks: (DropdownBlock | TextBlock)[];
|
|
6
|
+
} & Omit<ColumnBlock, 'blocks'>;
|
|
7
|
+
export declare const DropdownSchema: z.ZodEffects<z.ZodObject<{
|
|
8
|
+
type: z.ZodLiteral<"dropdown">;
|
|
9
|
+
text: z.ZodOptional<z.ZodString>;
|
|
10
|
+
message: z.ZodOptional<z.ZodString>;
|
|
11
|
+
options: z.ZodArray<z.ZodObject<{
|
|
12
|
+
label: z.ZodString;
|
|
13
|
+
value: z.ZodString;
|
|
14
|
+
}, "strip", z.ZodTypeAny, {
|
|
15
|
+
label: string;
|
|
16
|
+
value: string;
|
|
17
|
+
}, {
|
|
18
|
+
label: string;
|
|
19
|
+
value: string;
|
|
20
|
+
}>, "many">;
|
|
21
|
+
}, "strip", z.ZodTypeAny, {
|
|
22
|
+
options: {
|
|
23
|
+
label: string;
|
|
24
|
+
value: string;
|
|
25
|
+
}[];
|
|
26
|
+
type: "dropdown";
|
|
27
|
+
text?: string | undefined;
|
|
28
|
+
message?: string | undefined;
|
|
29
|
+
}, {
|
|
30
|
+
options: {
|
|
31
|
+
label: string;
|
|
32
|
+
value: string;
|
|
33
|
+
}[];
|
|
34
|
+
type: "dropdown";
|
|
35
|
+
text?: string | undefined;
|
|
36
|
+
message?: string | undefined;
|
|
37
|
+
}>, WithBubble<DropdownBlockType>, {
|
|
38
|
+
options: {
|
|
39
|
+
label: string;
|
|
40
|
+
value: string;
|
|
41
|
+
}[];
|
|
42
|
+
type: "dropdown";
|
|
43
|
+
text?: string | undefined;
|
|
44
|
+
message?: string | undefined;
|
|
45
|
+
}>;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { FileBlock } from '../../types';
|
|
3
|
+
export declare const FileSchema: z.ZodEffects<z.ZodObject<{
|
|
4
|
+
type: z.ZodLiteral<"file">;
|
|
5
|
+
file: z.ZodString;
|
|
6
|
+
title: z.ZodOptional<z.ZodString>;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
type: "file";
|
|
9
|
+
file: string;
|
|
10
|
+
title?: string | undefined;
|
|
11
|
+
}, {
|
|
12
|
+
type: "file";
|
|
13
|
+
file: string;
|
|
14
|
+
title?: string | undefined;
|
|
15
|
+
}>, FileBlock, {
|
|
16
|
+
type: "file";
|
|
17
|
+
file: string;
|
|
18
|
+
title?: string | undefined;
|
|
19
|
+
}>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ImageBlock } from '../../types';
|
|
3
|
+
export declare const ImageSchema: z.ZodEffects<z.ZodObject<{
|
|
4
|
+
type: z.ZodLiteral<"image">;
|
|
5
|
+
image: z.ZodString;
|
|
6
|
+
title: z.ZodOptional<z.ZodString>;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
image: string;
|
|
9
|
+
type: "image";
|
|
10
|
+
title?: string | undefined;
|
|
11
|
+
}, {
|
|
12
|
+
image: string;
|
|
13
|
+
type: "image";
|
|
14
|
+
title?: string | undefined;
|
|
15
|
+
}>, ImageBlock, {
|
|
16
|
+
image: string;
|
|
17
|
+
type: "image";
|
|
18
|
+
title?: string | undefined;
|
|
19
|
+
}>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { LocationBlock } from '../../types';
|
|
3
|
+
export declare const LocationSchema: z.ZodEffects<z.ZodObject<{
|
|
4
|
+
type: z.ZodLiteral<"location">;
|
|
5
|
+
latitude: z.ZodNumber;
|
|
6
|
+
longitude: z.ZodNumber;
|
|
7
|
+
address: z.ZodOptional<z.ZodString>;
|
|
8
|
+
title: z.ZodOptional<z.ZodString>;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
type: "location";
|
|
11
|
+
latitude: number;
|
|
12
|
+
longitude: number;
|
|
13
|
+
address?: string | undefined;
|
|
14
|
+
title?: string | undefined;
|
|
15
|
+
}, {
|
|
16
|
+
type: "location";
|
|
17
|
+
latitude: number;
|
|
18
|
+
longitude: number;
|
|
19
|
+
address?: string | undefined;
|
|
20
|
+
title?: string | undefined;
|
|
21
|
+
}>, LocationBlock, {
|
|
22
|
+
type: "location";
|
|
23
|
+
latitude: number;
|
|
24
|
+
longitude: number;
|
|
25
|
+
address?: string | undefined;
|
|
26
|
+
title?: string | undefined;
|
|
27
|
+
}>;
|