@botpress/webchat 1.2.0 → 1.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.
- package/dist/adapters/index.d.ts +4 -0
- package/dist/adapters/messaging-to-target.d.ts +151 -0
- package/dist/adapters/target.d.ts +77 -0
- package/dist/adapters/webchat-to-target.d.ts +126 -0
- package/dist/client/MessagingClient/client.d.ts +7 -4
- package/dist/client/PushpinClient/index.d.ts +4 -2
- package/dist/client/PushpinClient/inner-client/index.d.ts +2 -0
- package/dist/client/types.d.ts +4 -1
- package/dist/components/Avatar.d.ts +2 -3
- package/dist/components/Block.d.ts +3 -2
- package/dist/components/CloseWindow.d.ts +5 -0
- package/dist/components/Composer.d.ts +1 -1
- package/dist/components/renderers/Audio.d.ts +1 -1
- package/dist/components/renderers/Carousel.d.ts +1 -1
- package/dist/components/renderers/File.d.ts +1 -1
- package/dist/components/renderers/Image.d.ts +1 -1
- package/dist/components/renderers/Location.d.ts +1 -1
- package/dist/components/renderers/Video.d.ts +1 -1
- package/dist/contexts/WebchatContext.d.ts +3 -3
- package/dist/gen/client/api.d.ts +349 -31
- package/dist/gen/client/client.d.ts +21 -17
- package/dist/gen/client/errors.d.ts +9 -2
- package/dist/gen/models/index.d.ts +186 -23
- package/dist/gen/models/message.j.d.ts +107 -5
- package/dist/gen/models/message.t.d.ts +49 -0
- package/dist/gen/models/message.z.d.ts +79 -12
- package/dist/gen/models/user.j.d.ts +0 -3
- package/dist/gen/models/user.t.d.ts +0 -1
- package/dist/gen/models/user.z.d.ts +0 -3
- package/dist/gen/signals/index.d.ts +218 -23
- package/dist/gen/signals/messageCreatedSignal.j.d.ts +107 -5
- package/dist/gen/signals/messageCreatedSignal.t.d.ts +49 -0
- package/dist/gen/signals/messageCreatedSignal.z.d.ts +111 -18
- package/dist/get-client.d.ts +8 -0
- package/dist/hooks/useClient.d.ts +2 -2
- package/dist/hooks/useWebchatStore.d.ts +3 -0
- package/dist/index.d.ts +3 -4
- package/dist/index.js +33301 -40913
- package/dist/index.umd.cjs +96 -125
- package/dist/providers/WebchatProvider.d.ts +4 -3
- package/dist/schemas/configuration.d.ts +117 -0
- package/dist/schemas/index.d.ts +2 -0
- package/dist/schemas/init.d.ts +7650 -0
- package/dist/schemas/theme.d.ts +231 -232
- package/dist/types/block-type.d.ts +3 -6
- package/dist/types/configuration.d.ts +4 -16
- package/dist/types/index.d.ts +2 -0
- package/dist/types/init.d.ts +7 -0
- package/dist/types/theme.d.ts +7 -0
- package/dist/utils/index.d.ts +0 -2
- package/openapi.ts +40 -0
- package/package.json +15 -38
- package/dist/App.d.ts +0 -11
- package/dist/components/dev-tools/DevTools.d.ts +0 -1
- package/dist/components/dev-tools/configuration.d.ts +0 -2
- package/dist/components/dev-tools/helpers.d.ts +0 -5
- package/dist/main.d.ts +0 -0
- package/dist/options.d.ts +0 -11
- package/dist/themes/base.d.ts +0 -3
- package/dist/themes/baseColors.d.ts +0 -736
- package/dist/themes/dawn.d.ts +0 -4
- package/dist/themes/eggplant.d.ts +0 -4
- package/dist/themes/index.d.ts +0 -3
- package/dist/themes/prism.d.ts +0 -4
- package/dist/themes/themeBuilder.d.ts +0 -27
- package/dist/twind.config.d.ts +0 -9
- package/dist/twind.d.ts +0 -16
- package/dist/utils/mergeThemes.d.ts +0 -2
- package/dist/utils/withBaseTheme.d.ts +0 -384
- package/openapi/index.ts +0 -31
- package/openapi/package.json +0 -5
- package/openapi/readme.md +0 -1
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import * as adapters from 'webchat-adapters';
|
|
2
|
+
import * as target from './target';
|
|
3
|
+
type WithBubble<T extends target.Message> = target.BubbleOf<T>;
|
|
4
|
+
export type MessagingToTargetAdapters = adapters.Adapter<adapters.messaging.Messages, target.Messages>;
|
|
5
|
+
export declare const audioAdapter: ({ type, audio }: {
|
|
6
|
+
type: "audio";
|
|
7
|
+
audio: string;
|
|
8
|
+
className?: string | undefined;
|
|
9
|
+
avatarUrl?: string | undefined;
|
|
10
|
+
title?: string | undefined;
|
|
11
|
+
}) => {
|
|
12
|
+
type: "audio";
|
|
13
|
+
url: string;
|
|
14
|
+
};
|
|
15
|
+
export declare const cardAdapter: (card: {
|
|
16
|
+
title: string;
|
|
17
|
+
type: "card";
|
|
18
|
+
actions: ({
|
|
19
|
+
title: string;
|
|
20
|
+
text: string;
|
|
21
|
+
action: "Say something";
|
|
22
|
+
} | {
|
|
23
|
+
title: string;
|
|
24
|
+
action: "Open URL";
|
|
25
|
+
url: string;
|
|
26
|
+
} | {
|
|
27
|
+
title: string;
|
|
28
|
+
action: "Postback";
|
|
29
|
+
payload: string;
|
|
30
|
+
})[];
|
|
31
|
+
className?: string | undefined;
|
|
32
|
+
avatarUrl?: string | undefined;
|
|
33
|
+
subtitle?: string | undefined;
|
|
34
|
+
image?: string | undefined;
|
|
35
|
+
}) => WithBubble<target.ColumnMessage>;
|
|
36
|
+
export declare const carouselAdapter: ({ items }: {
|
|
37
|
+
type: "carousel";
|
|
38
|
+
items: {
|
|
39
|
+
title: string;
|
|
40
|
+
type: "card";
|
|
41
|
+
actions: ({
|
|
42
|
+
title: string;
|
|
43
|
+
text: string;
|
|
44
|
+
action: "Say something";
|
|
45
|
+
} | {
|
|
46
|
+
title: string;
|
|
47
|
+
action: "Open URL";
|
|
48
|
+
url: string;
|
|
49
|
+
} | {
|
|
50
|
+
title: string;
|
|
51
|
+
action: "Postback";
|
|
52
|
+
payload: string;
|
|
53
|
+
})[];
|
|
54
|
+
className?: string | undefined;
|
|
55
|
+
avatarUrl?: string | undefined;
|
|
56
|
+
subtitle?: string | undefined;
|
|
57
|
+
image?: string | undefined;
|
|
58
|
+
}[];
|
|
59
|
+
className?: string | undefined;
|
|
60
|
+
avatarUrl?: string | undefined;
|
|
61
|
+
}) => {
|
|
62
|
+
type: "carousel";
|
|
63
|
+
blocks: target.ColumnMessage[];
|
|
64
|
+
};
|
|
65
|
+
export declare const choiceAdapter: (x: {
|
|
66
|
+
type: "single-choice";
|
|
67
|
+
text: string;
|
|
68
|
+
choices: {
|
|
69
|
+
title: string;
|
|
70
|
+
value: string;
|
|
71
|
+
}[];
|
|
72
|
+
className?: string | undefined;
|
|
73
|
+
avatarUrl?: string | undefined;
|
|
74
|
+
disableFreeText?: boolean | undefined;
|
|
75
|
+
}) => target.Message;
|
|
76
|
+
export declare const dropdownAdapter: (x: {
|
|
77
|
+
options: {
|
|
78
|
+
value: string;
|
|
79
|
+
label: string;
|
|
80
|
+
}[];
|
|
81
|
+
type: "dropdown";
|
|
82
|
+
className?: string | undefined;
|
|
83
|
+
avatarUrl?: string | undefined;
|
|
84
|
+
message?: string | undefined;
|
|
85
|
+
allowCreation?: boolean | undefined;
|
|
86
|
+
placeholderText?: string | undefined;
|
|
87
|
+
allowMultiple?: boolean | undefined;
|
|
88
|
+
buttonText?: string | undefined;
|
|
89
|
+
width?: number | undefined;
|
|
90
|
+
displayInKeyboard?: boolean | undefined;
|
|
91
|
+
markdown?: boolean | undefined;
|
|
92
|
+
text?: string | undefined;
|
|
93
|
+
}) => WithBubble<target.ColumnMessage>;
|
|
94
|
+
export declare const fileAdapter: ({ file, ...props }: {
|
|
95
|
+
type: "file";
|
|
96
|
+
file: string;
|
|
97
|
+
className?: string | undefined;
|
|
98
|
+
avatarUrl?: string | undefined;
|
|
99
|
+
title?: string | undefined;
|
|
100
|
+
}) => {
|
|
101
|
+
type: "file";
|
|
102
|
+
className?: string | undefined;
|
|
103
|
+
avatarUrl?: string | undefined;
|
|
104
|
+
title?: string | undefined;
|
|
105
|
+
url: string;
|
|
106
|
+
};
|
|
107
|
+
export declare const imageAdapter: ({ type, image }: {
|
|
108
|
+
type: "image";
|
|
109
|
+
image: string;
|
|
110
|
+
className?: string | undefined;
|
|
111
|
+
avatarUrl?: string | undefined;
|
|
112
|
+
}) => {
|
|
113
|
+
type: "image";
|
|
114
|
+
url: string;
|
|
115
|
+
};
|
|
116
|
+
export declare const locationAdapter: ({ type, latitude, longitude, title, address }: {
|
|
117
|
+
type: "location";
|
|
118
|
+
latitude: number;
|
|
119
|
+
longitude: number;
|
|
120
|
+
className?: string | undefined;
|
|
121
|
+
avatarUrl?: string | undefined;
|
|
122
|
+
address?: string | undefined;
|
|
123
|
+
title?: string | undefined;
|
|
124
|
+
}) => {
|
|
125
|
+
type: "location";
|
|
126
|
+
latitude: number;
|
|
127
|
+
longitude: number;
|
|
128
|
+
title: string;
|
|
129
|
+
};
|
|
130
|
+
export declare const textAdapter: ({ type, text }: {
|
|
131
|
+
type: "text";
|
|
132
|
+
text: string;
|
|
133
|
+
className?: string | undefined;
|
|
134
|
+
avatarUrl?: string | undefined;
|
|
135
|
+
markdown?: boolean | undefined;
|
|
136
|
+
}) => WithBubble<{
|
|
137
|
+
type: "text";
|
|
138
|
+
text: string;
|
|
139
|
+
}>;
|
|
140
|
+
export declare const videoAdapter: ({ type, video }: {
|
|
141
|
+
type: "video";
|
|
142
|
+
video: string;
|
|
143
|
+
className?: string | undefined;
|
|
144
|
+
avatarUrl?: string | undefined;
|
|
145
|
+
title?: string | undefined;
|
|
146
|
+
}) => {
|
|
147
|
+
type: "video";
|
|
148
|
+
url: string;
|
|
149
|
+
};
|
|
150
|
+
export declare const messageAdapter: (message: adapters.messaging.Message) => target.Message;
|
|
151
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import * as adapters from 'webchat-adapters';
|
|
2
|
+
export type AudioMessage = {
|
|
3
|
+
type: 'audio';
|
|
4
|
+
url: string;
|
|
5
|
+
};
|
|
6
|
+
export type BubbleMessage = {
|
|
7
|
+
type: 'bubble';
|
|
8
|
+
block: Message;
|
|
9
|
+
};
|
|
10
|
+
export type ButtonMessage = {
|
|
11
|
+
type: 'button';
|
|
12
|
+
variant: 'action' | 'link';
|
|
13
|
+
reusable?: boolean;
|
|
14
|
+
groupId?: string;
|
|
15
|
+
text: string;
|
|
16
|
+
buttonValue: string;
|
|
17
|
+
};
|
|
18
|
+
export type CarouselMessage = {
|
|
19
|
+
type: 'carousel';
|
|
20
|
+
blocks: Message[];
|
|
21
|
+
};
|
|
22
|
+
export type ColumnMessage = {
|
|
23
|
+
type: 'column';
|
|
24
|
+
blocks: Message[];
|
|
25
|
+
horizontalAlignment?: 'left' | 'center' | 'right';
|
|
26
|
+
verticalAlignment?: 'top' | 'center' | 'bottom' | 'stretch';
|
|
27
|
+
};
|
|
28
|
+
export type DropdownMessage = {
|
|
29
|
+
label?: string;
|
|
30
|
+
type: 'dropdown';
|
|
31
|
+
reusable?: boolean;
|
|
32
|
+
options: {
|
|
33
|
+
label: string;
|
|
34
|
+
value: string;
|
|
35
|
+
}[];
|
|
36
|
+
};
|
|
37
|
+
export type FileMessage = {
|
|
38
|
+
type: 'file';
|
|
39
|
+
url: string;
|
|
40
|
+
title?: string;
|
|
41
|
+
};
|
|
42
|
+
export type ImageMessage = {
|
|
43
|
+
type: 'image';
|
|
44
|
+
orientation?: 'portrait' | 'landscape' | 'square' | 'auto';
|
|
45
|
+
url: string;
|
|
46
|
+
};
|
|
47
|
+
export type LocationMessage = {
|
|
48
|
+
type: 'location';
|
|
49
|
+
latitude: number;
|
|
50
|
+
longitude: number;
|
|
51
|
+
title?: string;
|
|
52
|
+
};
|
|
53
|
+
export type RowMessage = {
|
|
54
|
+
type: 'row';
|
|
55
|
+
blocks: Message[];
|
|
56
|
+
horizontalAlignment?: 'left' | 'center' | 'right' | 'stretch';
|
|
57
|
+
verticalAlignment?: 'top' | 'center' | 'bottom';
|
|
58
|
+
};
|
|
59
|
+
export type TextMessage = {
|
|
60
|
+
type: 'text';
|
|
61
|
+
text: string;
|
|
62
|
+
};
|
|
63
|
+
export type VideoMessage = {
|
|
64
|
+
type: 'video';
|
|
65
|
+
url: string;
|
|
66
|
+
};
|
|
67
|
+
export type Message = AudioMessage | BubbleMessage | ButtonMessage | CarouselMessage | ColumnMessage | DropdownMessage | FileMessage | ImageMessage | LocationMessage | RowMessage | TextMessage | VideoMessage;
|
|
68
|
+
export type BubbleOf<T extends Message> = Omit<BubbleMessage, 'block'> & {
|
|
69
|
+
block: T;
|
|
70
|
+
};
|
|
71
|
+
export type ColumnOf<T extends Message> = Omit<ColumnMessage, 'blocks'> & {
|
|
72
|
+
blocks: T[];
|
|
73
|
+
};
|
|
74
|
+
export type RowOf<T extends Message> = Omit<RowMessage, 'blocks'> & {
|
|
75
|
+
blocks: T[];
|
|
76
|
+
};
|
|
77
|
+
export type Messages = adapters.MessagesOf<Message>;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import * as adapters from 'webchat-adapters';
|
|
2
|
+
import * as target from './target';
|
|
3
|
+
export type WebchatToTargetAdapters = adapters.Adapter<adapters.webchat.Messages, target.Messages>;
|
|
4
|
+
export declare const audioAdapter: (webchatMessage: {
|
|
5
|
+
type: "audio";
|
|
6
|
+
audioUrl: string;
|
|
7
|
+
className?: string | undefined;
|
|
8
|
+
}) => {
|
|
9
|
+
type: "audio";
|
|
10
|
+
url: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const cardAdapter: (webchatMessage: {
|
|
13
|
+
title: string;
|
|
14
|
+
type: "card";
|
|
15
|
+
actions: {
|
|
16
|
+
value: string;
|
|
17
|
+
action: "url" | "postback" | "say";
|
|
18
|
+
label: string;
|
|
19
|
+
}[];
|
|
20
|
+
className?: string | undefined;
|
|
21
|
+
subtitle?: string | undefined;
|
|
22
|
+
imageUrl?: string | undefined;
|
|
23
|
+
}) => Omit<target.BubbleMessage, "block"> & {
|
|
24
|
+
block: target.ColumnMessage;
|
|
25
|
+
};
|
|
26
|
+
export declare const carouselAdapter: (webchatMessage: {
|
|
27
|
+
type: "carousel";
|
|
28
|
+
items: {
|
|
29
|
+
title: string;
|
|
30
|
+
actions: {
|
|
31
|
+
value: string;
|
|
32
|
+
action: "url" | "postback" | "say";
|
|
33
|
+
label: string;
|
|
34
|
+
}[];
|
|
35
|
+
className?: string | undefined;
|
|
36
|
+
subtitle?: string | undefined;
|
|
37
|
+
imageUrl?: string | undefined;
|
|
38
|
+
}[];
|
|
39
|
+
className?: string | undefined;
|
|
40
|
+
}) => {
|
|
41
|
+
type: "carousel";
|
|
42
|
+
blocks: target.ColumnMessage[];
|
|
43
|
+
};
|
|
44
|
+
export declare const choiceAdapter: (webchatMessage: {
|
|
45
|
+
options: {
|
|
46
|
+
value: string;
|
|
47
|
+
label: string;
|
|
48
|
+
}[];
|
|
49
|
+
type: "choice";
|
|
50
|
+
text: string;
|
|
51
|
+
disableFreeText?: boolean | undefined;
|
|
52
|
+
className?: string | undefined;
|
|
53
|
+
}) => target.Message;
|
|
54
|
+
export declare const dropdownAdapter: (webchatMessage: {
|
|
55
|
+
options: {
|
|
56
|
+
value: string;
|
|
57
|
+
label: string;
|
|
58
|
+
}[];
|
|
59
|
+
type: "dropdown";
|
|
60
|
+
text: string;
|
|
61
|
+
className?: string | undefined;
|
|
62
|
+
}) => Omit<target.BubbleMessage, "block"> & {
|
|
63
|
+
block: target.ColumnMessage;
|
|
64
|
+
};
|
|
65
|
+
export declare const fileAdapter: (webchatMessage: {
|
|
66
|
+
type: "file";
|
|
67
|
+
fileUrl: string;
|
|
68
|
+
title?: string | undefined;
|
|
69
|
+
className?: string | undefined;
|
|
70
|
+
}) => {
|
|
71
|
+
type: "file";
|
|
72
|
+
className?: string | undefined;
|
|
73
|
+
avatarUrl?: string | undefined;
|
|
74
|
+
title?: string | undefined;
|
|
75
|
+
url: string;
|
|
76
|
+
};
|
|
77
|
+
export declare const imageAdapter: (webchatMessage: {
|
|
78
|
+
type: "image";
|
|
79
|
+
imageUrl: string;
|
|
80
|
+
className?: string | undefined;
|
|
81
|
+
}) => {
|
|
82
|
+
type: "image";
|
|
83
|
+
url: string;
|
|
84
|
+
};
|
|
85
|
+
export declare const locationAdapter: (webchatMessage: {
|
|
86
|
+
type: "location";
|
|
87
|
+
latitude: number;
|
|
88
|
+
longitude: number;
|
|
89
|
+
title?: string | undefined;
|
|
90
|
+
address?: string | undefined;
|
|
91
|
+
className?: string | undefined;
|
|
92
|
+
}) => {
|
|
93
|
+
type: "location";
|
|
94
|
+
latitude: number;
|
|
95
|
+
longitude: number;
|
|
96
|
+
title: string;
|
|
97
|
+
};
|
|
98
|
+
export declare const markdownAdapter: (webchatMessage: {
|
|
99
|
+
type: "markdown";
|
|
100
|
+
markdown: string;
|
|
101
|
+
className?: string | undefined;
|
|
102
|
+
}) => Omit<target.BubbleMessage, "block"> & {
|
|
103
|
+
block: {
|
|
104
|
+
type: "text";
|
|
105
|
+
text: string;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
export declare const textAdapter: (webchatMessage: {
|
|
109
|
+
type: "text";
|
|
110
|
+
text: string;
|
|
111
|
+
className?: string | undefined;
|
|
112
|
+
}) => Omit<target.BubbleMessage, "block"> & {
|
|
113
|
+
block: {
|
|
114
|
+
type: "text";
|
|
115
|
+
text: string;
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
export declare const videoAdapter: (webchatMessage: {
|
|
119
|
+
type: "video";
|
|
120
|
+
videoUrl: string;
|
|
121
|
+
className?: string | undefined;
|
|
122
|
+
}) => {
|
|
123
|
+
type: "video";
|
|
124
|
+
url: string;
|
|
125
|
+
};
|
|
126
|
+
export declare const messageAdapter: (message: adapters.webchat.Message) => target.Message;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type MessagingSocketOptions, type UserCredentials } from '@botpress/messaging-socket';
|
|
2
2
|
import { EventEmitter } from '../../utils';
|
|
3
|
-
import { Events, WebchatClient } from '../types';
|
|
3
|
+
import { Events, UserData, WebchatClient } from '../types';
|
|
4
|
+
export type MessagingClientProps = MessagingSocketOptions;
|
|
4
5
|
export declare class MessagingClient implements WebchatClient {
|
|
5
6
|
private socket;
|
|
6
7
|
clientId: string | undefined;
|
|
@@ -10,15 +11,17 @@ export declare class MessagingClient implements WebchatClient {
|
|
|
10
11
|
private connected;
|
|
11
12
|
private readonly emitter;
|
|
12
13
|
on: EventEmitter<Events>['on'];
|
|
13
|
-
constructor(options:
|
|
14
|
-
|
|
14
|
+
constructor(options: MessagingClientProps);
|
|
15
|
+
readonly mode = "messaging";
|
|
16
|
+
connect(creds?: UserCredentials, data?: UserData): Promise<UserCredentials | undefined>;
|
|
15
17
|
disconnect(): Promise<void>;
|
|
16
18
|
sendMessage(message: string): Promise<void>;
|
|
19
|
+
sendEvent(event: Record<string, any>): Promise<void>;
|
|
17
20
|
switchConversation(id: string): Promise<void>;
|
|
18
21
|
conversationExists(id: string): Promise<boolean>;
|
|
19
22
|
newConversation(): Promise<void>;
|
|
20
23
|
listMessages(limit?: number): Promise<{
|
|
21
|
-
payload: import("
|
|
24
|
+
payload: import("../../adapters/target").Message;
|
|
22
25
|
id: string;
|
|
23
26
|
conversationId: string;
|
|
24
27
|
authorId: string | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventEmitter } from '../../utils';
|
|
2
|
-
import { Events, Message, UserCredentials, WebchatClient } from '../types';
|
|
2
|
+
import { Events, Message, UserCredentials, UserData, WebchatClient } from '../types';
|
|
3
3
|
export type PushpinClientProps = {
|
|
4
4
|
apiUrl: string;
|
|
5
5
|
clientId: string;
|
|
@@ -9,14 +9,16 @@ export declare class PushpinClient extends EventEmitter<Events> implements Webch
|
|
|
9
9
|
private _webhookId;
|
|
10
10
|
private _state;
|
|
11
11
|
constructor(props: PushpinClientProps);
|
|
12
|
+
readonly mode = "pushpin";
|
|
12
13
|
get clientId(): string;
|
|
13
14
|
get userId(): string | undefined;
|
|
14
15
|
get conversationId(): string | undefined;
|
|
15
|
-
connect(creds?: UserCredentials): Promise<UserCredentials | undefined>;
|
|
16
|
+
connect(creds?: UserCredentials, data?: UserData): Promise<UserCredentials | undefined>;
|
|
16
17
|
private _initialConnect;
|
|
17
18
|
private _reConnect;
|
|
18
19
|
disconnect(): Promise<void>;
|
|
19
20
|
sendMessage(message: string): Promise<void>;
|
|
21
|
+
sendEvent(event: Record<string, any>): Promise<void>;
|
|
20
22
|
switchConversation(id: string): Promise<void>;
|
|
21
23
|
conversationExists(id: string): Promise<boolean>;
|
|
22
24
|
userExists({ userToken }: UserCredentials): Promise<boolean>;
|
|
@@ -35,5 +35,7 @@ export declare class Client implements IClient {
|
|
|
35
35
|
readonly getUser: IAutoClient['getUser'];
|
|
36
36
|
readonly updateUser: IAutoClient['updateUser'];
|
|
37
37
|
readonly deleteUser: IAutoClient['deleteUser'];
|
|
38
|
+
readonly createEvent: IAutoClient['createEvent'];
|
|
39
|
+
readonly getEvent: IAutoClient['getEvent'];
|
|
38
40
|
readonly listenConversation: ({ id, xUserKey }: ListenConversationArgs) => Promise<SignalListener>;
|
|
39
41
|
}
|
package/dist/client/types.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export type UserCredentials = {
|
|
|
4
4
|
userId: string;
|
|
5
5
|
userToken: string;
|
|
6
6
|
};
|
|
7
|
+
export type UserData = Record<string, string>;
|
|
7
8
|
export type Message = {
|
|
8
9
|
id: string;
|
|
9
10
|
conversationId: string;
|
|
@@ -21,13 +22,15 @@ export type Events = {
|
|
|
21
22
|
customEvent: Record<string, any>;
|
|
22
23
|
};
|
|
23
24
|
export type WebchatClient = {
|
|
25
|
+
mode: 'messaging' | 'pushpin';
|
|
24
26
|
clientId: string | undefined;
|
|
25
27
|
userId: string | undefined;
|
|
26
28
|
conversationId: string | undefined;
|
|
27
29
|
on: EventEmitter<Events>['on'];
|
|
28
|
-
connect(creds?: UserCredentials): Promise<UserCredentials | undefined>;
|
|
30
|
+
connect(creds?: UserCredentials, data?: UserData): Promise<UserCredentials | undefined>;
|
|
29
31
|
disconnect(): Promise<void>;
|
|
30
32
|
sendMessage(message: string): Promise<void>;
|
|
33
|
+
sendEvent(event: Record<string, any>): Promise<void>;
|
|
31
34
|
switchConversation(id: string): Promise<void>;
|
|
32
35
|
conversationExists(id: string): Promise<boolean>;
|
|
33
36
|
newConversation(): Promise<void>;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import { AvatarTheme } from '../types';
|
|
1
2
|
import { ComponentPropsWithRef } from 'react';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import * as Themes from '../schemas';
|
|
4
3
|
type AvatarProps = {
|
|
5
4
|
userId?: string;
|
|
6
5
|
src?: string;
|
|
7
|
-
} & Omit<ComponentPropsWithRef<'span'>, 'className' | 'style'> &
|
|
6
|
+
} & Omit<ComponentPropsWithRef<'span'>, 'className' | 'style'> & AvatarTheme;
|
|
8
7
|
export declare const Avatar: import("react").ForwardRefExoticComponent<Omit<AvatarProps, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
|
|
9
8
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { BlockMap, BlockTypes, CommonBlockProps } from '../types';
|
|
3
|
+
export declare const Block: <T extends BlockTypes>({ block, styles, ...props }: {
|
|
3
4
|
block: BlockMap[T];
|
|
4
5
|
} & CommonBlockProps) => JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { Theme } from '../types';
|
|
1
2
|
import { ComponentProps, FC } from 'react';
|
|
2
3
|
import { type StyleOptions } from '../contexts';
|
|
3
|
-
import { Theme } from '../schemas';
|
|
4
4
|
declare const Composer: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>>;
|
|
5
5
|
declare const ComposerInput: import("react").MemoExoticComponent<({ ...props }: ComponentProps<'textarea'>) => import("react/jsx-runtime").JSX.Element>;
|
|
6
6
|
type ComposerButtonStyle = NonNullable<Theme['composer']>['button'];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CommonBlockProps } from '../../types';
|
|
3
|
-
export declare const Audio: import("react").ForwardRefExoticComponent<CommonBlockProps & import("
|
|
3
|
+
export declare const Audio: import("react").ForwardRefExoticComponent<CommonBlockProps & import("../../adapters/target").AudioMessage & import("react").RefAttributes<HTMLAudioElement>>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CommonBlockProps } from '../../types';
|
|
3
|
-
export declare const Carousel: import("react").ForwardRefExoticComponent<CommonBlockProps & import("
|
|
3
|
+
export declare const Carousel: import("react").ForwardRefExoticComponent<CommonBlockProps & import("../../adapters/target").CarouselMessage & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CommonBlockProps } from '../../types';
|
|
3
|
-
export declare const File: import("react").ForwardRefExoticComponent<CommonBlockProps & import("
|
|
3
|
+
export declare const File: import("react").ForwardRefExoticComponent<CommonBlockProps & import("../../adapters/target").FileMessage & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CommonBlockProps } from '../../types';
|
|
3
|
-
export declare const Image: import("react").ForwardRefExoticComponent<CommonBlockProps & import("
|
|
3
|
+
export declare const Image: import("react").ForwardRefExoticComponent<CommonBlockProps & import("../../adapters/target").ImageMessage & import("react").RefAttributes<HTMLImageElement>>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CommonBlockProps } from '../../types';
|
|
3
|
-
export declare const Location: import("react").ForwardRefExoticComponent<CommonBlockProps & import("
|
|
3
|
+
export declare const Location: import("react").ForwardRefExoticComponent<CommonBlockProps & import("../../adapters/target").LocationMessage & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CommonBlockProps } from '../../types';
|
|
3
|
-
export declare const Video: import("react").ForwardRefExoticComponent<CommonBlockProps & import("
|
|
3
|
+
export declare const Video: import("react").ForwardRefExoticComponent<CommonBlockProps & import("../../adapters/target").VideoMessage & import("react").RefAttributes<HTMLVideoElement>>;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { CSSProperties, FC, ReactNode } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { Theme, Configuration, BlockObject, BlockStyles, MessageObject } from '../types';
|
|
3
3
|
import { EventEmitter, Events } from '../utils';
|
|
4
|
-
import {
|
|
5
|
-
import { type WebchatClient } from '../client';
|
|
4
|
+
import { WebchatClient } from '../client';
|
|
6
5
|
export type StyleOptions = {
|
|
7
6
|
className?: string;
|
|
8
7
|
style?: CSSProperties;
|
|
@@ -39,6 +38,7 @@ export type ContextVaue = {
|
|
|
39
38
|
sendMessage: WebchatClient['sendMessage'];
|
|
40
39
|
restartConversation: () => void;
|
|
41
40
|
} & Pick<WebchatClient, 'userId' | 'conversationId' | 'clientId'>;
|
|
41
|
+
closeWindow?: () => void;
|
|
42
42
|
setState: (state: Partial<ContextVaue['state']>) => void;
|
|
43
43
|
setTheme: (styles: Partial<Theme>) => void;
|
|
44
44
|
};
|