@botpress/webchat 1.1.1 → 1.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 (99) hide show
  1. package/dist/client/MessagingClient/client.d.ts +8 -19
  2. package/dist/client/{ChatClient → PushpinClient}/index.d.ts +7 -5
  3. package/dist/client/PushpinClient/inner-client/event-emitter.d.ts +10 -0
  4. package/dist/client/PushpinClient/inner-client/eventsource.d.ts +22 -0
  5. package/dist/client/PushpinClient/inner-client/index.d.ts +41 -0
  6. package/dist/client/PushpinClient/inner-client/signal-listener.d.ts +47 -0
  7. package/dist/client/{ChatClient → PushpinClient}/state-machine.d.ts +13 -13
  8. package/dist/client/index.d.ts +1 -1
  9. package/dist/client/types.d.ts +8 -2
  10. package/dist/components/Avatar.d.ts +2 -3
  11. package/dist/components/Block.d.ts +3 -2
  12. package/dist/components/CloseWindow.d.ts +5 -0
  13. package/dist/components/Composer.d.ts +2 -2
  14. package/dist/components/Header.d.ts +1 -1
  15. package/dist/components/LoadingIndicator.d.ts +1 -1
  16. package/dist/components/MessageList.d.ts +1 -1
  17. package/dist/components/Modal.d.ts +2 -2
  18. package/dist/components/RestartConversation.d.ts +1 -1
  19. package/dist/components/Webchat.d.ts +1 -1
  20. package/dist/components/renderers/Audio.d.ts +1 -1
  21. package/dist/components/renderers/Button.d.ts +1 -1
  22. package/dist/components/renderers/Carousel.d.ts +1 -1
  23. package/dist/components/renderers/Dropdown.d.ts +1 -1
  24. package/dist/components/renderers/File.d.ts +1 -1
  25. package/dist/components/renderers/Image.d.ts +1 -1
  26. package/dist/components/renderers/Location.d.ts +1 -1
  27. package/dist/components/renderers/Text.d.ts +1 -1
  28. package/dist/components/renderers/Video.d.ts +1 -1
  29. package/dist/contexts/WebchatContext.d.ts +6 -6
  30. package/dist/gen/client/api.d.ts +2012 -0
  31. package/dist/gen/client/base.d.ts +54 -0
  32. package/dist/gen/client/client.d.ts +61 -0
  33. package/dist/gen/client/common.d.ts +65 -0
  34. package/dist/gen/client/configuration.d.ts +83 -0
  35. package/dist/gen/client/errors.d.ts +204 -0
  36. package/dist/gen/client/index.d.ts +13 -0
  37. package/dist/gen/models/conversation.j.d.ts +20 -0
  38. package/dist/gen/models/conversation.t.d.ts +10 -0
  39. package/dist/gen/models/conversation.z.d.ts +15 -0
  40. package/dist/gen/models/index.d.ts +1014 -0
  41. package/dist/gen/models/message.j.d.ts +490 -0
  42. package/dist/gen/models/message.t.d.ts +122 -0
  43. package/dist/gen/models/message.z.d.ts +439 -0
  44. package/dist/gen/models/user.j.d.ts +26 -0
  45. package/dist/gen/models/user.t.d.ts +12 -0
  46. package/dist/gen/models/user.z.d.ts +21 -0
  47. package/dist/gen/signals/customSignal.j.d.ts +24 -0
  48. package/dist/gen/signals/customSignal.t.d.ts +13 -0
  49. package/dist/gen/signals/customSignal.z.d.ts +22 -0
  50. package/dist/gen/signals/index.d.ts +1249 -0
  51. package/dist/gen/signals/messageCreatedSignal.j.d.ts +501 -0
  52. package/dist/gen/signals/messageCreatedSignal.t.d.ts +125 -0
  53. package/dist/gen/signals/messageCreatedSignal.z.d.ts +608 -0
  54. package/dist/gen/signals/webchatConfigSignal.j.d.ts +24 -0
  55. package/dist/gen/signals/webchatConfigSignal.t.d.ts +13 -0
  56. package/dist/gen/signals/webchatConfigSignal.z.d.ts +22 -0
  57. package/dist/gen/signals/webchatVisibilitySignal.j.d.ts +24 -0
  58. package/dist/gen/signals/webchatVisibilitySignal.t.d.ts +11 -0
  59. package/dist/gen/signals/webchatVisibilitySignal.z.d.ts +22 -0
  60. package/dist/get-client.d.ts +8 -0
  61. package/dist/hooks/useClient.d.ts +3 -3
  62. package/dist/hooks/useWebchatStore.d.ts +3 -0
  63. package/dist/index.d.ts +3 -4
  64. package/dist/index.js +31976 -85703
  65. package/dist/index.umd.cjs +117 -187
  66. package/dist/providers/ModalProvider.d.ts +1 -1
  67. package/dist/providers/WebchatProvider.d.ts +6 -5
  68. package/dist/schemas/configuration.d.ts +117 -0
  69. package/dist/schemas/index.d.ts +2 -0
  70. package/dist/schemas/init.d.ts +3844 -0
  71. package/dist/schemas/theme.d.ts +231 -232
  72. package/dist/types/block-type.d.ts +3 -6
  73. package/dist/types/configuration.d.ts +4 -16
  74. package/dist/types/index.d.ts +2 -0
  75. package/dist/types/init.d.ts +6 -0
  76. package/dist/types/theme.d.ts +7 -0
  77. package/dist/utils/index.d.ts +0 -2
  78. package/openapi/index.ts +31 -0
  79. package/openapi/package.json +5 -0
  80. package/openapi/readme.md +1 -0
  81. package/package.json +18 -38
  82. package/dist/App.d.ts +0 -11
  83. package/dist/client/MessagingClient/adapters/Trigger.d.ts +0 -33
  84. package/dist/components/dev-tools/DevTools.d.ts +0 -1
  85. package/dist/components/dev-tools/configuration.d.ts +0 -2
  86. package/dist/components/dev-tools/helpers.d.ts +0 -5
  87. package/dist/main.d.ts +0 -0
  88. package/dist/options.d.ts +0 -11
  89. package/dist/themes/base.d.ts +0 -3
  90. package/dist/themes/baseColors.d.ts +0 -736
  91. package/dist/themes/dawn.d.ts +0 -4
  92. package/dist/themes/eggplant.d.ts +0 -4
  93. package/dist/themes/index.d.ts +0 -3
  94. package/dist/themes/prism.d.ts +0 -4
  95. package/dist/themes/themeBuilder.d.ts +0 -27
  96. package/dist/twind.config.d.ts +0 -9
  97. package/dist/twind.d.ts +0 -16
  98. package/dist/utils/mergeThemes.d.ts +0 -2
  99. package/dist/utils/withBaseTheme.d.ts +0 -384
@@ -1,9 +1,6 @@
1
- import type { Theme } from '../schemas';
2
- import { target } from 'message-adapters';
3
- export declare const blockTypes: readonly ["button", "text", "image", "audio", "video", "file", "location", "column", "row", "bubble", "carousel", "dropdown"];
4
- export declare const markdownTypes: readonly ["heading1", "heading2", "heading3", "text", "horizontalRule", "link", "italic", "bold", "orderedList", "unorderedList", "listItem", "lineBreak", "pre"];
5
- export type MarkdownTypes = (typeof markdownTypes)[number];
6
- export type BlockTypes = (typeof blockTypes)[number];
1
+ import { Theme } from './theme';
2
+ import { target } from 'webchat-adapters';
3
+ export type BlockTypes = 'button' | 'text' | 'image' | 'audio' | 'video' | 'file' | 'location' | 'column' | 'row' | 'bubble' | 'carousel' | 'dropdown';
7
4
  export type BlockStyles = NonNullable<Theme['message']>['blocks'];
8
5
  export type AudioBlock = target.AudioMessage;
9
6
  export type BubbleBlock = target.BubbleMessage;
@@ -1,16 +1,4 @@
1
- type DescriptionItem = {
2
- title: string;
3
- link?: string;
4
- };
5
- export type Configuration = {
6
- composerPlaceholder?: string;
7
- botName?: string;
8
- botAvatar?: string;
9
- botDescription?: string;
10
- website?: DescriptionItem;
11
- email?: DescriptionItem;
12
- phone?: DescriptionItem;
13
- privacyPolicy?: DescriptionItem;
14
- termsOfService?: DescriptionItem;
15
- };
16
- export {};
1
+ import { z } from 'zod';
2
+ import * as schemas from '../schemas';
3
+ export type DescriptionItem = z.infer<typeof schemas.descriptionItemSchema>;
4
+ export type Configuration = z.infer<typeof schemas.configurationSchema>;
@@ -1,3 +1,5 @@
1
1
  export * from './block-type';
2
2
  export * from './image';
3
3
  export * from './configuration';
4
+ export * from './theme';
5
+ export * from './init';
@@ -0,0 +1,6 @@
1
+ import { z } from 'zod';
2
+ import * as schemas from '../schemas';
3
+ export type StateProps = z.infer<typeof schemas.statePropsSchema>;
4
+ export type UserProps = z.infer<typeof schemas.userPropsSchema>;
5
+ export type ClientModeProps = z.infer<typeof schemas.clientModePropsSchema>;
6
+ export type InitProps = z.infer<typeof schemas.initPropsSchema>;
@@ -0,0 +1,7 @@
1
+ import { z } from 'zod';
2
+ import * as schemas from '../schemas';
3
+ export type MarkdownType = z.infer<typeof schemas.markdownTypeSchema>;
4
+ export type StyleOption = z.infer<typeof schemas.styleOptionSchema>;
5
+ export type AvatarTheme = z.infer<typeof schemas.avatarThemeSchema>;
6
+ export type BlocksTheme = z.infer<typeof schemas.blockThemeSchema>;
7
+ export type Theme = z.infer<typeof schemas.themeSchema>;
@@ -1,4 +1,2 @@
1
1
  export * from './eventEmitter';
2
2
  export * from './hashStringToInt';
3
- export * from './mergeThemes';
4
- export * from './withBaseTheme';
@@ -0,0 +1,31 @@
1
+ import yargs, { parseEnv, YargsSchema } from '@bpinternal/yargs-extra'
2
+ import { api } from 'webchat-api'
3
+ import pathlib from 'path'
4
+
5
+ const DEFAULT_OPENAPI_GEN_ENDPOINT = 'http://api.openapi-generator.tech'
6
+
7
+ const configSchema = {
8
+ outDir: {
9
+ type: 'string',
10
+ demandOption: true,
11
+ },
12
+ openapiEndpoint: {
13
+ type: 'string',
14
+ default: DEFAULT_OPENAPI_GEN_ENDPOINT,
15
+ },
16
+ } satisfies YargsSchema
17
+
18
+ const description = 'Generate OpenAPI client'
19
+ void yargs
20
+ .command('$0', description, configSchema, async (argv) => {
21
+ const args = { ...argv, ...parseEnv(configSchema) }
22
+
23
+ const clientDir = pathlib.join(args.outDir, 'client')
24
+ const signalsDir = pathlib.join(args.outDir, 'signals')
25
+ const modelsDir = pathlib.join(args.outDir, 'models')
26
+ await api.exportClient(clientDir, args.openapiEndpoint)
27
+ await api.signals.exportSchemas(signalsDir)
28
+ await api.models.exportSchemas(modelsDir)
29
+ })
30
+ .help()
31
+ .parse()
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "openapi.ts",
3
+ "description": "script to generate client",
4
+ "type": "commonjs"
5
+ }
@@ -0,0 +1 @@
1
+ this script must have its own dedicated package.json and tsconfig.json to run properly with ts-node
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botpress/webchat",
3
- "version": "1.1.1",
3
+ "version": "1.3.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.umd.cjs",
@@ -14,66 +14,46 @@
14
14
  },
15
15
  "scripts": {
16
16
  "type:check": "tsc --noEmit",
17
- "dev": "vite --debug --log-level info",
18
- "build": "pnpm type:check && vite build",
19
- "inspect-build": "vite build --sourcemap && npx source-map-explorer dist/index.js --no-border-checks",
20
- "bundle": "vite build",
21
- "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
22
- "preview": "vite preview",
23
- "test": "vitest run"
17
+ "build": "vite build",
18
+ "test": "vitest run",
19
+ "gen:client": "ts-node -T ./openapi --out-dir ./src/gen"
24
20
  },
25
21
  "dependencies": {
26
- "@botpress/chat": "0.2.4",
27
- "@botpress/messaging-socket": "^1.2.0",
22
+ "@botpress/messaging-socket": "^1.3.0",
28
23
  "@floating-ui/react": "^0.25.4",
29
24
  "@headlessui/react": "1.7.11",
30
25
  "@heroicons/react": "^2.0.18",
31
- "@radix-ui/colors": "^3.0.0",
32
26
  "@radix-ui/react-avatar": "^1.0.3",
33
27
  "@radix-ui/react-collapsible": "^1.0.3",
34
28
  "@radix-ui/react-dialog": "^1.0.4",
35
- "@radix-ui/react-icons": "^1.3.0",
36
- "@tailwindcss/container-queries": "^0.1.1",
37
- "@types/culori": "^2.0.4",
38
- "@types/react-color": "^3.0.10",
39
- "classnames": "^2.3.2",
29
+ "axios": "1.2.5",
40
30
  "clsx": "^2.0.0",
41
- "culori": "^3.3.0",
42
31
  "dayjs": "^1.11.10",
43
32
  "embla-carousel-react": "8.0.0-rc11",
44
- "lodash": "^4.17.21",
33
+ "event-source-polyfill": "^1.0.31",
45
34
  "react": "^18.2.0",
46
- "react-color": "^2.19.3",
47
35
  "react-dom": "^18.2.0",
48
36
  "react-hot-toast": "^2.4.1",
49
- "react-markdown": "^8.0.7",
37
+ "react-markdown": "^9.0.1",
50
38
  "react-use": "^17.4.0",
51
- "tailwind-merge": "^1.14.0",
52
- "tailwind-scrollbar": "^3.0.4",
53
- "uuid": "^9.0.0",
54
- "vite-plugin-svgr": "^3.2.0",
39
+ "remark-breaks": "^4.0.0",
40
+ "remark-gfm": "^4.0.0",
55
41
  "zod": "^3.21.4",
56
42
  "zustand": "^4.4.1"
57
43
  },
58
44
  "devDependencies": {
59
- "message-adapters": "workspace:*",
60
- "@twind/core": "^1.1.3",
61
- "@twind/intellisense": "^1.1.3",
62
- "@twind/preset-autoprefix": "^1.0.7",
63
- "@twind/preset-container-queries": "^1.0.7",
64
- "@twind/preset-tailwind": "^1.1.4",
65
- "@twind/with-react": "^1.1.3",
66
- "@types/color-convert": "^2.0.1",
67
- "@types/lodash": "^4.14.199",
45
+ "@bpinternal/yargs-extra": "^0.0.3",
46
+ "@types/event-source-polyfill": "^1.0.2",
68
47
  "@types/react": "^18.0.37",
69
48
  "@types/react-dom": "^18.0.11",
70
- "@types/uuid": "^9.0.3",
49
+ "@types/web": "^0.0.115",
71
50
  "@vitejs/plugin-react-swc": "^3.0.0",
72
- "autoprefixer": "^10.4.14",
73
- "tailwindcss": "^3.3.2",
74
- "typescript": "^5.0.2",
51
+ "webchat-adapters": "workspace:*",
52
+ "typescript": "^5.4.3",
75
53
  "vite": "^4.3.9",
76
54
  "vite-plugin-dts": "^3.5.4",
77
- "vitest": "^0.34.6"
55
+ "vite-plugin-svgr": "^3.2.0",
56
+ "vitest": "^0.34.6",
57
+ "webchat-api": "workspace:*"
78
58
  }
79
59
  }
package/dist/App.d.ts DELETED
@@ -1,11 +0,0 @@
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 declare function FabSample(props: Props): JSX.Element;
11
- export {};
@@ -1,33 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const TriggerSchema: z.ZodObject<{
3
- trigger: z.ZodUnion<[z.ZodObject<{
4
- type: z.ZodLiteral<"webchat-visibility">;
5
- visibility: z.ZodUnion<[z.ZodLiteral<"show">, z.ZodLiteral<"hide">, z.ZodLiteral<"toggle">]>;
6
- }, "strip", z.ZodTypeAny, {
7
- type: "webchat-visibility";
8
- visibility: "hide" | "show" | "toggle";
9
- }, {
10
- type: "webchat-visibility";
11
- visibility: "hide" | "show" | "toggle";
12
- }>, z.ZodObject<{
13
- type: z.ZodLiteral<"custom-event">;
14
- }, "strip", z.ZodTypeAny, {
15
- type: "custom-event";
16
- }, {
17
- type: "custom-event";
18
- }>]>;
19
- }, "strip", z.ZodTypeAny, {
20
- trigger: {
21
- type: "webchat-visibility";
22
- visibility: "hide" | "show" | "toggle";
23
- } | {
24
- type: "custom-event";
25
- };
26
- }, {
27
- trigger: {
28
- type: "webchat-visibility";
29
- visibility: "hide" | "show" | "toggle";
30
- } | {
31
- type: "custom-event";
32
- };
33
- }>;
@@ -1 +0,0 @@
1
- export declare const DevTools: () => JSX.Element;
@@ -1,2 +0,0 @@
1
- import { Configuration } from '../../types';
2
- export declare const defaultConfiguration: Configuration;
@@ -1,5 +0,0 @@
1
- import { BlockObject, MessageObject } from '../../types';
2
- type Direction = 'incoming' | 'outgoing' | 'system';
3
- export declare function messageInBubble(block: BlockObject, direction?: Direction): MessageObject;
4
- export declare function splitCamelCase(text: string): string;
5
- export {};
package/dist/main.d.ts DELETED
File without changes
package/dist/options.d.ts DELETED
@@ -1,11 +0,0 @@
1
- type ChatOptions = {
2
- backend: 'messaging';
3
- apiUrl: string;
4
- clientId: string;
5
- } | {
6
- backend: 'chat';
7
- apiUrl: string;
8
- clientId: string;
9
- };
10
- export declare const getOptions: () => ChatOptions;
11
- export {};
@@ -1,3 +0,0 @@
1
- import { Theme } from '../schemas';
2
- export declare const fabIcon: (color?: string) => string;
3
- export declare const baseTheme: Theme;