@opencx/widget 2.6.3 → 3.0.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/basic.cjs +89 -89
- package/dist/basic.cjs.map +1 -1
- package/dist/basic.d.ts +1 -1
- package/dist/basic.js +34088 -34127
- package/dist/basic.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -22
- package/dist/react.cjs +1 -1
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +20 -10
- package/dist/react.js.map +1 -1
- package/dist/src/designs/react/basic/index.d.ts +10 -0
- package/dist/src/designs/{basic → react/basic}/utils/group-messages-by-type.d.ts +1 -1
- package/dist/src/{@components → designs/react/components}/BotOrAgentMessage.d.ts +1 -1
- package/dist/src/{@components → designs/react/components}/BotOrAgentMessageGroup.d.ts +2 -2
- package/dist/src/designs/react/components/BotOrAgentMessageWrapper.d.ts +7 -0
- package/dist/src/{@components → designs/react/components}/Fallback.component.d.ts +2 -2
- package/dist/src/{components → designs/react/components}/RenderFile.d.ts +2 -2
- package/dist/src/{components/keyboard.d.ts → designs/react/components/SuggestedReplies.d.ts} +2 -2
- package/dist/src/{@components → designs/react/components}/Text.component.d.ts +1 -1
- package/dist/src/{components → designs/react/components}/UserMessageGroup.d.ts +1 -1
- package/dist/src/{components → designs/react/components}/VoteButtons.d.ts +1 -1
- package/dist/src/{components → designs/react/components/lib}/button.d.ts +1 -1
- package/dist/src/{components → designs/react/components/lib}/dialog.d.ts +7 -7
- package/dist/src/{components → designs/react/components/lib}/dropdown-menu.d.ts +2 -2
- package/dist/src/designs/{constants.d.ts → react/constants.d.ts} +2 -4
- package/dist/src/designs/react/hooks/useLocale.d.ts +6 -0
- package/dist/src/{index.d.ts → designs/react/index.d.ts} +2 -2
- package/dist/src/designs/translation/ar.locale.d.ts +2 -0
- package/dist/src/designs/translation/de.locale.d.ts +2 -0
- package/dist/src/designs/translation/en.locale.d.ts +2 -0
- package/dist/src/designs/translation/fr.locale.d.ts +2 -0
- package/dist/src/designs/translation/index.d.ts +14 -0
- package/dist/src/designs/translation/nl.locale.d.ts +2 -0
- package/dist/src/designs/translation/pt.locale.d.ts +2 -0
- package/dist/src/designs/translation/translation.types.d.ts +4 -0
- package/dist/{core/client → src/headless/core}/api.d.ts +49 -103
- package/dist/src/headless/core/context/contact.d.ts +24 -0
- package/dist/src/headless/core/context/message.d.ts +42 -0
- package/dist/src/headless/core/context/session.d.ts +74 -0
- package/dist/src/headless/core/context/widget.d.ts +16 -0
- package/dist/src/headless/core/index.d.ts +10 -0
- package/dist/src/headless/core/types/WidgetConfig.d.ts +34 -0
- package/dist/src/headless/core/types/agent-or-bot.d.ts +6 -0
- package/dist/src/headless/core/types/helpers.d.ts +4 -0
- package/dist/{core → src/headless/core}/types/messages.d.ts +11 -31
- package/dist/src/headless/core/types/schemas.d.ts +9 -0
- package/dist/src/headless/core/utils/Poller.d.ts +12 -0
- package/dist/{core/types/pub-sub.d.ts → src/headless/core/utils/PubSub.d.ts} +6 -9
- package/dist/{react-web/core-integration/components.d.ts → src/headless/react/ComponentRegistry.d.ts} +1 -1
- package/dist/src/headless/react/WidgetProvider.d.ts +17 -0
- package/dist/src/headless/react/hooks/useConfig.d.ts +1 -0
- package/dist/src/headless/react/hooks/useContact.d.ts +10 -0
- package/dist/src/headless/react/hooks/useIsAwaitingBotReply.d.ts +3 -0
- package/dist/src/headless/react/hooks/useMessages.d.ts +8 -0
- package/dist/{react-web/core-integration → src/headless/react}/hooks/usePreludeData.d.ts +2 -2
- package/dist/{react-web/core-integration → src/headless/react}/hooks/usePubsub.d.ts +1 -1
- package/dist/src/headless/react/hooks/useSession.d.ts +6 -0
- package/dist/{react-web/core-integration → src/headless/react}/hooks/useVote.d.ts +2 -2
- package/dist/src/headless/react/index.d.ts +10 -0
- package/dist/{react-web → src/headless/react}/types/components.d.ts +6 -5
- package/dist/style.css +1 -1
- package/dist/useUploadFiles-CEd5c5iE.js +1336 -0
- package/dist/useUploadFiles-CEd5c5iE.js.map +1 -0
- package/dist/useUploadFiles-CNkahO3s.cjs +18 -0
- package/dist/useUploadFiles-CNkahO3s.cjs.map +1 -0
- package/dist/widget-BeNOCqB5.js +517 -0
- package/dist/widget-BeNOCqB5.js.map +1 -0
- package/dist/widget-DlAUwHzU.cjs +2 -0
- package/dist/widget-DlAUwHzU.cjs.map +1 -0
- package/dist-embed/script.js +137 -157
- package/dist-embed/script.js.map +1 -1
- package/package.json +9 -4
- package/dist/api-CAm3rFZk.js +0 -1070
- package/dist/api-CAm3rFZk.js.map +0 -1
- package/dist/api-oIDR-KZx.cjs +0 -2
- package/dist/api-oIDR-KZx.cjs.map +0 -1
- package/dist/core/client/chat.d.ts +0 -101
- package/dist/core/client/config.d.ts +0 -43
- package/dist/core/client/contact.d.ts +0 -29
- package/dist/core/client/index.d.ts +0 -4
- package/dist/core/errors/index.d.ts +0 -27
- package/dist/core/index.d.ts +0 -9
- package/dist/core/platform/audio.d.ts +0 -38
- package/dist/core/platform/index.d.ts +0 -15
- package/dist/core/platform/logger.d.ts +0 -14
- package/dist/core/platform/storage.d.ts +0 -52
- package/dist/core/tests/platform/logger.test.d.ts +0 -1
- package/dist/core/tests/platform/storage.test.d.ts +0 -1
- package/dist/core/tests/test-utils.d.ts +0 -2
- package/dist/core/tests/types/pub-sub.test.d.ts +0 -1
- package/dist/core/types/contact.d.ts +0 -2
- package/dist/core/types/helpers.d.ts +0 -20
- package/dist/core/types/index.d.ts +0 -52
- package/dist/core/types/prelude.d.ts +0 -14
- package/dist/core/types/schemas-v2.d.ts +0 -10
- package/dist/index-CSptf_Dw.cjs +0 -18
- package/dist/index-CSptf_Dw.cjs.map +0 -1
- package/dist/index-cUkS-tdv.js +0 -1232
- package/dist/index-cUkS-tdv.js.map +0 -1
- package/dist/react-web/core-integration/ChatProvider.d.ts +0 -107
- package/dist/react-web/core-integration/hooks/useChatMessages.d.ts +0 -70
- package/dist/react-web/core-integration/hooks/useChatSession.d.ts +0 -83
- package/dist/react-web/core-integration/hooks/useConfig.d.ts +0 -1
- package/dist/react-web/core-integration/hooks/useContact.d.ts +0 -17
- package/dist/react-web/core-integration/hooks/useLocale.d.ts +0 -4
- package/dist/react-web/core-integration/hooks.d.ts +0 -9
- package/dist/react-web/core-integration/index.d.ts +0 -2
- package/dist/react-web/core-integration/locales/ar.locale.d.ts +0 -2
- package/dist/react-web/core-integration/locales/de.locale.d.ts +0 -2
- package/dist/react-web/core-integration/locales/en.locale.d.ts +0 -55
- package/dist/react-web/core-integration/locales/fr.locale.d.ts +0 -2
- package/dist/react-web/core-integration/locales/helper.d.ts +0 -65
- package/dist/react-web/core-integration/locales/index.d.ts +0 -3
- package/dist/react-web/core-integration/locales/nl.locale.d.ts +0 -2
- package/dist/react-web/core-integration/locales/pt.locale.d.ts +0 -2
- package/dist/react-web/hooks/useScrollTo.d.ts +0 -2
- package/dist/react-web/index.d.ts +0 -4
- package/dist/react-web/types/index.d.ts +0 -8
- package/dist/react-web/types/options.d.ts +0 -17
- package/dist/src/@components/BotOrAgentMessageWrapper.d.ts +0 -9
- package/dist/src/@components/ChatEvent.component.d.ts +0 -9
- package/dist/src/@components/index.d.ts +0 -6
- package/dist/src/designs/basic/index.d.ts +0 -8
- /package/dist/src/designs/{basic → react/basic}/WidgetPopoverTrigger.d.ts +0 -0
- /package/dist/src/designs/{basic → react/basic}/screens/chat-screen/ChatFooter.d.ts +0 -0
- /package/dist/src/designs/{basic → react/basic}/screens/chat-screen/ChatHeader.d.ts +0 -0
- /package/dist/src/designs/{basic → react/basic}/screens/chat-screen/ChatMain.d.ts +0 -0
- /package/dist/src/designs/{basic → react/basic}/screens/chat-screen/ChatScreen.d.ts +0 -0
- /package/dist/src/designs/{basic → react/basic}/screens/root-screen.d.ts +0 -0
- /package/dist/src/designs/{basic → react/basic}/screens/welcome-screen/WelcomeScreen.d.ts +0 -0
- /package/dist/{core/tests/client/integration-perisitance.test.d.ts → src/designs/react/basic/widget-interaction-tests/widget.test.d.ts} +0 -0
- /package/dist/src/{@components → designs/react/components}/Loading.component.d.ts +0 -0
- /package/dist/src/{@components → designs/react/components}/OpenLogoSvg.d.ts +0 -0
- /package/dist/src/{components → designs/react/components/lib}/MotionDiv.d.ts +0 -0
- /package/dist/src/{components → designs/react/components/lib}/avatar.d.ts +0 -0
- /package/dist/src/{components → designs/react/components/lib}/input.d.ts +0 -0
- /package/dist/src/{components → designs/react/components/lib}/popover.d.ts +0 -0
- /package/dist/src/{components → designs/react/components/lib}/skeleton.d.ts +0 -0
- /package/dist/src/{components → designs/react/components/lib}/switch.d.ts +0 -0
- /package/dist/src/{components → designs/react/components/lib}/tooltip.d.ts +0 -0
- /package/dist/src/{utils.d.ts → designs/react/components/lib/utils/cn.d.ts} +0 -0
- /package/dist/src/{components → designs/react/components/lib}/wobble.d.ts +0 -0
- /package/dist/src/{@components → designs/react/components}/markdown.d.ts +0 -0
- /package/dist/{react-web → src/designs/react}/hooks/useWidgetContentHeight.d.ts +0 -0
- /package/dist/src/{render.d.ts → designs/react/render.d.ts} +0 -0
- /package/dist/{core → src/headless/core}/sdk/index.d.ts +0 -0
- /package/dist/{core/tests/client/integration.test.d.ts → src/headless/core/utils/PubSub.test.d.ts} +0 -0
- /package/dist/{core/utils/genUuid.d.ts → src/headless/core/utils/uuid.d.ts} +0 -0
- /package/dist/{react-web/core-integration → src/headless/react}/hooks/useUploadFiles.d.ts +0 -0
- /package/dist/{react-web → src/headless/react}/utils/create-safe-context.d.ts +0 -0
- /package/dist/{core/tests/platform/audio.test.d.ts → vitest/setup.d.ts} +0 -0
|
@@ -1,81 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
6
|
-
export interface ApiCallerOptions {
|
|
7
|
-
config: NormalizedConfig;
|
|
8
|
-
}
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
import { Dto } from './sdk';
|
|
3
|
+
import { WidgetConfig } from './types/WidgetConfig';
|
|
4
|
+
import { SendMessageDto, VoteInputDto } from './types/schemas';
|
|
9
5
|
export declare class ApiCaller {
|
|
10
|
-
|
|
11
|
-
private
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
Authorization: string | undefined;
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
createOpenAPIClient: ({ baseUrl, headers, }: ReturnType<typeof this.constructClientOptions>) => import('openapi-fetch').Client<import('../sdk/schema').paths, `${string}/${string}`>;
|
|
24
|
-
createAxiosUploadClient: ({ baseUrl, headers, }: ReturnType<typeof this.constructClientOptions>) => AxiosInstance;
|
|
25
|
-
setUser: (user: User) => void;
|
|
26
|
-
me: () => Promise<import('openapi-fetch').FetchResponse<{
|
|
27
|
-
parameters: {
|
|
28
|
-
query?: never;
|
|
29
|
-
header?: never;
|
|
30
|
-
path?: never;
|
|
31
|
-
cookie?: never;
|
|
32
|
-
};
|
|
33
|
-
requestBody?: never;
|
|
34
|
-
responses: {
|
|
35
|
-
200: {
|
|
36
|
-
headers: {
|
|
37
|
-
[name: string]: unknown;
|
|
38
|
-
};
|
|
39
|
-
content: {
|
|
40
|
-
"application/json": import('../sdk/schema').components["schemas"]["WidgetContactDto"];
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
500: {
|
|
44
|
-
headers: {
|
|
45
|
-
[name: string]: unknown;
|
|
46
|
-
};
|
|
47
|
-
content: {
|
|
48
|
-
"application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
}, import('openapi-fetch').FetchOptions<{
|
|
53
|
-
parameters: {
|
|
54
|
-
query?: never;
|
|
55
|
-
header?: never;
|
|
56
|
-
path?: never;
|
|
57
|
-
cookie?: never;
|
|
58
|
-
};
|
|
59
|
-
requestBody?: never;
|
|
60
|
-
responses: {
|
|
61
|
-
200: {
|
|
62
|
-
headers: {
|
|
63
|
-
[name: string]: unknown;
|
|
64
|
-
};
|
|
65
|
-
content: {
|
|
66
|
-
"application/json": import('../sdk/schema').components["schemas"]["WidgetContactDto"];
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
500: {
|
|
70
|
-
headers: {
|
|
71
|
-
[name: string]: unknown;
|
|
72
|
-
};
|
|
73
|
-
content: {
|
|
74
|
-
"application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
}> | undefined, `${string}/${string}`>>;
|
|
6
|
+
private client;
|
|
7
|
+
private uploadFileClient;
|
|
8
|
+
private config;
|
|
9
|
+
constructor({ config, }: {
|
|
10
|
+
config: WidgetConfig;
|
|
11
|
+
});
|
|
12
|
+
private constructClientOptions;
|
|
13
|
+
private createOpenAPIClient;
|
|
14
|
+
private createAxiosUploadClient;
|
|
15
|
+
setAuthToken: (token: string) => void;
|
|
79
16
|
widgetPrelude: () => Promise<import('openapi-fetch').FetchResponse<{
|
|
80
17
|
parameters: {
|
|
81
18
|
query?: never;
|
|
@@ -92,7 +29,7 @@ export declare class ApiCaller {
|
|
|
92
29
|
[name: string]: unknown;
|
|
93
30
|
};
|
|
94
31
|
content: {
|
|
95
|
-
"application/json": import('
|
|
32
|
+
"application/json": import('./sdk/schema').components["schemas"]["WidgetPreludeDto"];
|
|
96
33
|
};
|
|
97
34
|
};
|
|
98
35
|
500: {
|
|
@@ -100,7 +37,7 @@ export declare class ApiCaller {
|
|
|
100
37
|
[name: string]: unknown;
|
|
101
38
|
};
|
|
102
39
|
content: {
|
|
103
|
-
"application/json": import('
|
|
40
|
+
"application/json": import('./sdk/schema').components["schemas"]["ErrorDto"];
|
|
104
41
|
};
|
|
105
42
|
};
|
|
106
43
|
};
|
|
@@ -111,7 +48,7 @@ export declare class ApiCaller {
|
|
|
111
48
|
};
|
|
112
49
|
};
|
|
113
50
|
}, `${string}/${string}`>>;
|
|
114
|
-
|
|
51
|
+
sendMessage: (body: SendMessageDto, abortSignal?: AbortSignal) => Promise<import('openapi-fetch').FetchResponse<{
|
|
115
52
|
parameters: {
|
|
116
53
|
query?: never;
|
|
117
54
|
header?: never;
|
|
@@ -120,7 +57,7 @@ export declare class ApiCaller {
|
|
|
120
57
|
};
|
|
121
58
|
requestBody: {
|
|
122
59
|
content: {
|
|
123
|
-
"application/json": import('
|
|
60
|
+
"application/json": import('./sdk/schema').components["schemas"]["HttpChatInputDto"];
|
|
124
61
|
};
|
|
125
62
|
};
|
|
126
63
|
responses: {
|
|
@@ -129,7 +66,7 @@ export declare class ApiCaller {
|
|
|
129
66
|
[name: string]: unknown;
|
|
130
67
|
};
|
|
131
68
|
content: {
|
|
132
|
-
"application/json": import('
|
|
69
|
+
"application/json": import('./sdk/schema').components["schemas"]["HandleContactMessageOutputDto"];
|
|
133
70
|
};
|
|
134
71
|
};
|
|
135
72
|
500: {
|
|
@@ -137,7 +74,7 @@ export declare class ApiCaller {
|
|
|
137
74
|
[name: string]: unknown;
|
|
138
75
|
};
|
|
139
76
|
content: {
|
|
140
|
-
"application/json": import('
|
|
77
|
+
"application/json": import('./sdk/schema').components["schemas"]["ErrorDto"];
|
|
141
78
|
};
|
|
142
79
|
};
|
|
143
80
|
};
|
|
@@ -173,7 +110,11 @@ export declare class ApiCaller {
|
|
|
173
110
|
};
|
|
174
111
|
signal: AbortSignal | undefined;
|
|
175
112
|
}, `${string}/${string}`>>;
|
|
176
|
-
getSessionHistory: (sessionId
|
|
113
|
+
getSessionHistory: ({ sessionId, lastMessageTimestamp, abortSignal, }: {
|
|
114
|
+
sessionId: string;
|
|
115
|
+
lastMessageTimestamp?: string;
|
|
116
|
+
abortSignal: AbortSignal;
|
|
117
|
+
}) => Promise<import('openapi-fetch').FetchResponse<{
|
|
177
118
|
parameters: {
|
|
178
119
|
query?: {
|
|
179
120
|
lastMessageTimestamp?: string;
|
|
@@ -191,7 +132,7 @@ export declare class ApiCaller {
|
|
|
191
132
|
[name: string]: unknown;
|
|
192
133
|
};
|
|
193
134
|
content: {
|
|
194
|
-
"application/json": import('
|
|
135
|
+
"application/json": import('./sdk/schema').components["schemas"]["WidgetHistoryDto"][];
|
|
195
136
|
};
|
|
196
137
|
};
|
|
197
138
|
500: {
|
|
@@ -199,7 +140,7 @@ export declare class ApiCaller {
|
|
|
199
140
|
[name: string]: unknown;
|
|
200
141
|
};
|
|
201
142
|
content: {
|
|
202
|
-
"application/json": import('
|
|
143
|
+
"application/json": import('./sdk/schema').components["schemas"]["ErrorDto"];
|
|
203
144
|
};
|
|
204
145
|
};
|
|
205
146
|
};
|
|
@@ -212,8 +153,9 @@ export declare class ApiCaller {
|
|
|
212
153
|
lastMessageTimestamp: string;
|
|
213
154
|
} | undefined;
|
|
214
155
|
};
|
|
156
|
+
signal: AbortSignal;
|
|
215
157
|
}, `${string}/${string}`>>;
|
|
216
|
-
|
|
158
|
+
createUnverifiedContact: (body: Dto["CreateUnverifiedContactDto"]) => Promise<import('openapi-fetch').FetchResponse<{
|
|
217
159
|
parameters: {
|
|
218
160
|
query?: never;
|
|
219
161
|
header: {
|
|
@@ -224,7 +166,7 @@ export declare class ApiCaller {
|
|
|
224
166
|
};
|
|
225
167
|
requestBody: {
|
|
226
168
|
content: {
|
|
227
|
-
"application/json": import('
|
|
169
|
+
"application/json": import('./sdk/schema').components["schemas"]["CreateUnverifiedContactDto"];
|
|
228
170
|
};
|
|
229
171
|
};
|
|
230
172
|
responses: {
|
|
@@ -233,7 +175,7 @@ export declare class ApiCaller {
|
|
|
233
175
|
[name: string]: unknown;
|
|
234
176
|
};
|
|
235
177
|
content: {
|
|
236
|
-
"application/json": import('
|
|
178
|
+
"application/json": import('./sdk/schema').components["schemas"]["WidgetContactTokenResponseDto"];
|
|
237
179
|
};
|
|
238
180
|
};
|
|
239
181
|
500: {
|
|
@@ -241,7 +183,7 @@ export declare class ApiCaller {
|
|
|
241
183
|
[name: string]: unknown;
|
|
242
184
|
};
|
|
243
185
|
content: {
|
|
244
|
-
"application/json": import('
|
|
186
|
+
"application/json": import('./sdk/schema').components["schemas"]["ErrorDto"];
|
|
245
187
|
};
|
|
246
188
|
};
|
|
247
189
|
};
|
|
@@ -252,8 +194,8 @@ export declare class ApiCaller {
|
|
|
252
194
|
};
|
|
253
195
|
};
|
|
254
196
|
body: {
|
|
255
|
-
email
|
|
256
|
-
name
|
|
197
|
+
email?: string;
|
|
198
|
+
name?: string;
|
|
257
199
|
};
|
|
258
200
|
}, `${string}/${string}`>>;
|
|
259
201
|
createSession: () => Promise<import('openapi-fetch').FetchResponse<{
|
|
@@ -270,7 +212,7 @@ export declare class ApiCaller {
|
|
|
270
212
|
[name: string]: unknown;
|
|
271
213
|
};
|
|
272
214
|
content: {
|
|
273
|
-
"application/json": import('
|
|
215
|
+
"application/json": import('./sdk/schema').components["schemas"]["WidgetSessionDto"];
|
|
274
216
|
};
|
|
275
217
|
};
|
|
276
218
|
500: {
|
|
@@ -278,7 +220,7 @@ export declare class ApiCaller {
|
|
|
278
220
|
[name: string]: unknown;
|
|
279
221
|
};
|
|
280
222
|
content: {
|
|
281
|
-
"application/json": import('
|
|
223
|
+
"application/json": import('./sdk/schema').components["schemas"]["ErrorDto"];
|
|
282
224
|
};
|
|
283
225
|
};
|
|
284
226
|
};
|
|
@@ -296,7 +238,7 @@ export declare class ApiCaller {
|
|
|
296
238
|
[name: string]: unknown;
|
|
297
239
|
};
|
|
298
240
|
content: {
|
|
299
|
-
"application/json": import('
|
|
241
|
+
"application/json": import('./sdk/schema').components["schemas"]["WidgetSessionDto"];
|
|
300
242
|
};
|
|
301
243
|
};
|
|
302
244
|
500: {
|
|
@@ -304,12 +246,15 @@ export declare class ApiCaller {
|
|
|
304
246
|
[name: string]: unknown;
|
|
305
247
|
};
|
|
306
248
|
content: {
|
|
307
|
-
"application/json": import('
|
|
249
|
+
"application/json": import('./sdk/schema').components["schemas"]["ErrorDto"];
|
|
308
250
|
};
|
|
309
251
|
};
|
|
310
252
|
};
|
|
311
253
|
}> | undefined, `${string}/${string}`>>;
|
|
312
|
-
getSession: (sessionId
|
|
254
|
+
getSession: ({ sessionId, abortSignal, }: {
|
|
255
|
+
sessionId: string;
|
|
256
|
+
abortSignal: AbortSignal;
|
|
257
|
+
}) => Promise<import('openapi-fetch').FetchResponse<{
|
|
313
258
|
parameters: {
|
|
314
259
|
query?: never;
|
|
315
260
|
header?: never;
|
|
@@ -325,7 +270,7 @@ export declare class ApiCaller {
|
|
|
325
270
|
[name: string]: unknown;
|
|
326
271
|
};
|
|
327
272
|
content: {
|
|
328
|
-
"application/json": import('
|
|
273
|
+
"application/json": import('./sdk/schema').components["schemas"]["WidgetSessionDto"];
|
|
329
274
|
};
|
|
330
275
|
};
|
|
331
276
|
500: {
|
|
@@ -333,7 +278,7 @@ export declare class ApiCaller {
|
|
|
333
278
|
[name: string]: unknown;
|
|
334
279
|
};
|
|
335
280
|
content: {
|
|
336
|
-
"application/json": import('
|
|
281
|
+
"application/json": import('./sdk/schema').components["schemas"]["ErrorDto"];
|
|
337
282
|
};
|
|
338
283
|
};
|
|
339
284
|
};
|
|
@@ -343,6 +288,7 @@ export declare class ApiCaller {
|
|
|
343
288
|
sessionId: string;
|
|
344
289
|
};
|
|
345
290
|
};
|
|
291
|
+
signal: AbortSignal;
|
|
346
292
|
}, `${string}/${string}`>>;
|
|
347
293
|
uploadFile: (file: {
|
|
348
294
|
id: string;
|
|
@@ -351,7 +297,7 @@ export declare class ApiCaller {
|
|
|
351
297
|
fileName: string;
|
|
352
298
|
fileUrl: string;
|
|
353
299
|
}>;
|
|
354
|
-
vote: (body:
|
|
300
|
+
vote: (body: VoteInputDto) => Promise<import('openapi-fetch').FetchResponse<{
|
|
355
301
|
parameters: {
|
|
356
302
|
query?: never;
|
|
357
303
|
header?: never;
|
|
@@ -360,7 +306,7 @@ export declare class ApiCaller {
|
|
|
360
306
|
};
|
|
361
307
|
requestBody: {
|
|
362
308
|
content: {
|
|
363
|
-
"application/json": import('
|
|
309
|
+
"application/json": import('./sdk/schema').components["schemas"]["WidgetVoteDto"];
|
|
364
310
|
};
|
|
365
311
|
};
|
|
366
312
|
responses: {
|
|
@@ -369,7 +315,7 @@ export declare class ApiCaller {
|
|
|
369
315
|
[name: string]: unknown;
|
|
370
316
|
};
|
|
371
317
|
content: {
|
|
372
|
-
"application/json": import('
|
|
318
|
+
"application/json": import('./sdk/schema').components["schemas"]["WidgetVoteResponseDto"];
|
|
373
319
|
};
|
|
374
320
|
};
|
|
375
321
|
500: {
|
|
@@ -377,7 +323,7 @@ export declare class ApiCaller {
|
|
|
377
323
|
[name: string]: unknown;
|
|
378
324
|
};
|
|
379
325
|
content: {
|
|
380
|
-
"application/json": import('
|
|
326
|
+
"application/json": import('./sdk/schema').components["schemas"]["ErrorDto"];
|
|
381
327
|
};
|
|
382
328
|
};
|
|
383
329
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { PubSub } from '../utils/PubSub';
|
|
2
|
+
import { ApiCaller } from '../api';
|
|
3
|
+
import { WidgetConfig } from '../types/WidgetConfig';
|
|
4
|
+
import { Dto } from '../sdk';
|
|
5
|
+
type ContactState = {
|
|
6
|
+
contact: {
|
|
7
|
+
token: string;
|
|
8
|
+
} | null;
|
|
9
|
+
isCreatingUnverifiedContact: boolean;
|
|
10
|
+
isErrorCreatingUnverifiedContact: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare class ContactCtx {
|
|
13
|
+
private config;
|
|
14
|
+
private api;
|
|
15
|
+
state: PubSub<ContactState>;
|
|
16
|
+
constructor({ config, api, }: {
|
|
17
|
+
api: ApiCaller;
|
|
18
|
+
config: WidgetConfig;
|
|
19
|
+
});
|
|
20
|
+
shouldCollectData: () => boolean;
|
|
21
|
+
autoCreateUnverifiedUser: () => Promise<void>;
|
|
22
|
+
createUnverifiedContact: (payload: Dto["CreateUnverifiedContactDto"]) => Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ApiCaller } from '../api';
|
|
2
|
+
import { WidgetConfig } from '../types/WidgetConfig';
|
|
3
|
+
import { SafeOmit, SomeOptional } from '../types/helpers';
|
|
4
|
+
import { BotMessageType, MessageType, UserMessageType } from '../types/messages';
|
|
5
|
+
import { MessageAttachmentType, MessageDto, SendMessageDto, SendMessageOutputDto } from '../types/schemas';
|
|
6
|
+
import { PubSub } from '../utils/PubSub';
|
|
7
|
+
import { SessionCtx } from './session';
|
|
8
|
+
export declare class MessageCtx {
|
|
9
|
+
private config;
|
|
10
|
+
private api;
|
|
11
|
+
private sessionCtx;
|
|
12
|
+
private poller;
|
|
13
|
+
state: PubSub<{
|
|
14
|
+
messages: MessageType[];
|
|
15
|
+
isSendingMessage: boolean;
|
|
16
|
+
suggestedReplies: string[] | null;
|
|
17
|
+
}>;
|
|
18
|
+
private sendMessageAbortController;
|
|
19
|
+
constructor({ config, api, sessionCtx, }: {
|
|
20
|
+
config: WidgetConfig;
|
|
21
|
+
api: ApiCaller;
|
|
22
|
+
sessionCtx: SessionCtx;
|
|
23
|
+
});
|
|
24
|
+
reset: () => void;
|
|
25
|
+
registerPolling: () => void;
|
|
26
|
+
sendMessage: (input: SomeOptional<SafeOmit<SendMessageDto, "bot_token" | "uuid">, "session_id" | "user">) => Promise<void>;
|
|
27
|
+
fetchAndSetHistory: (sessionId: string, abortSignal: AbortSignal) => Promise<void>;
|
|
28
|
+
/** Not the best name but whatever */
|
|
29
|
+
static mapHistoryToMessage(history: MessageDto): MessageType;
|
|
30
|
+
static toUserMessage(content: string, attachments?: MessageAttachmentType[]): UserMessageType;
|
|
31
|
+
static toBotMessage(response: SendMessageOutputDto): BotMessageType | null;
|
|
32
|
+
static toErrorMessage(message: string): {
|
|
33
|
+
type: "FROM_BOT";
|
|
34
|
+
id: string;
|
|
35
|
+
timestamp: string;
|
|
36
|
+
component: string;
|
|
37
|
+
data: {
|
|
38
|
+
message: string;
|
|
39
|
+
variant: string;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ApiCaller } from '../api';
|
|
2
|
+
import { SessionDto } from '../types/schemas';
|
|
3
|
+
import { PubSub } from '../utils/PubSub';
|
|
4
|
+
export declare class SessionCtx {
|
|
5
|
+
private api;
|
|
6
|
+
private poller;
|
|
7
|
+
state: PubSub<{
|
|
8
|
+
session: SessionDto | null;
|
|
9
|
+
isCreatingSession: boolean;
|
|
10
|
+
}>;
|
|
11
|
+
constructor(api: ApiCaller);
|
|
12
|
+
/** Clears the session and stops polling */
|
|
13
|
+
reset: () => Promise<void>;
|
|
14
|
+
registerPolling: () => void;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new session
|
|
17
|
+
* @returns The session
|
|
18
|
+
*/
|
|
19
|
+
createSession: () => Promise<{
|
|
20
|
+
id: string;
|
|
21
|
+
createdAt: string;
|
|
22
|
+
updatedAt: string;
|
|
23
|
+
isHandedOff: boolean;
|
|
24
|
+
isOpened: boolean;
|
|
25
|
+
assignee: {
|
|
26
|
+
kind: "human" | "ai" | "none" | "unknown";
|
|
27
|
+
name: string | null;
|
|
28
|
+
avatarUrl: string | null;
|
|
29
|
+
};
|
|
30
|
+
channel: string;
|
|
31
|
+
isVerified: boolean;
|
|
32
|
+
} | null>;
|
|
33
|
+
/**
|
|
34
|
+
* Fetches the session from the API
|
|
35
|
+
* @param id - The ID of the session to fetch
|
|
36
|
+
* @returns The session
|
|
37
|
+
*/
|
|
38
|
+
fetch: (sessionId: string, abortSignal: AbortSignal) => Promise<import('openapi-fetch').FetchResponse<{
|
|
39
|
+
parameters: {
|
|
40
|
+
query?: never;
|
|
41
|
+
header?: never;
|
|
42
|
+
path: {
|
|
43
|
+
sessionId: string;
|
|
44
|
+
};
|
|
45
|
+
cookie?: never;
|
|
46
|
+
};
|
|
47
|
+
requestBody?: never;
|
|
48
|
+
responses: {
|
|
49
|
+
200: {
|
|
50
|
+
headers: {
|
|
51
|
+
[name: string]: unknown;
|
|
52
|
+
};
|
|
53
|
+
content: {
|
|
54
|
+
"application/json": import('../sdk/schema').components["schemas"]["WidgetSessionDto"];
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
500: {
|
|
58
|
+
headers: {
|
|
59
|
+
[name: string]: unknown;
|
|
60
|
+
};
|
|
61
|
+
content: {
|
|
62
|
+
"application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
}, {
|
|
67
|
+
params: {
|
|
68
|
+
path: {
|
|
69
|
+
sessionId: string;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
signal: AbortSignal;
|
|
73
|
+
}, `${string}/${string}`>>;
|
|
74
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ApiCaller } from '../api';
|
|
2
|
+
import { WidgetConfig } from '../types/WidgetConfig';
|
|
3
|
+
import { ContactCtx } from './contact';
|
|
4
|
+
import { MessageCtx } from './message';
|
|
5
|
+
import { SessionCtx } from './session';
|
|
6
|
+
export declare class WidgetCtx {
|
|
7
|
+
config: WidgetConfig;
|
|
8
|
+
api: ApiCaller;
|
|
9
|
+
contactCtx: ContactCtx;
|
|
10
|
+
sessionCtx: SessionCtx;
|
|
11
|
+
messageCtx: MessageCtx;
|
|
12
|
+
constructor({ config }: {
|
|
13
|
+
config: WidgetConfig;
|
|
14
|
+
});
|
|
15
|
+
resetChat: () => void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type { AgentOrBotType } from './types/agent-or-bot';
|
|
2
|
+
export type { SafeExtract, SafeOmit, SomeOptional, StringOrLiteral, } from './types/helpers';
|
|
3
|
+
export type { AgentMessageType, BotMessageType, MessageType, UserMessageType, } from './types/messages';
|
|
4
|
+
export type { MessageAttachmentType, MessageDto, PreludeDto, SendMessageDto, SendMessageOutputDto, SessionDto, VoteInputDto, VoteOutputDto, } from './types/schemas';
|
|
5
|
+
export type { WidgetConfig } from './types/WidgetConfig';
|
|
6
|
+
export { WidgetCtx } from './context/widget';
|
|
7
|
+
export type { ContactCtx } from './context/contact';
|
|
8
|
+
export type { SessionCtx } from './context/session';
|
|
9
|
+
export type { MessageCtx } from './context/message';
|
|
10
|
+
export { PubSub } from './utils/PubSub';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { AgentOrBotType } from './agent-or-bot';
|
|
2
|
+
export interface WidgetConfig {
|
|
3
|
+
token: string;
|
|
4
|
+
apiUrl?: string;
|
|
5
|
+
headers?: Record<string, string>;
|
|
6
|
+
queryParams?: Record<string, string>;
|
|
7
|
+
collectUserData?: boolean;
|
|
8
|
+
debug?: boolean;
|
|
9
|
+
initialMessages?: string[];
|
|
10
|
+
language?: string;
|
|
11
|
+
user?: {
|
|
12
|
+
external_id?: string;
|
|
13
|
+
name?: string;
|
|
14
|
+
email?: string;
|
|
15
|
+
phone?: string;
|
|
16
|
+
customData?: Record<string, string>;
|
|
17
|
+
avatarUrl?: string;
|
|
18
|
+
};
|
|
19
|
+
contactToken?: string;
|
|
20
|
+
bot?: AgentOrBotType;
|
|
21
|
+
soundEffectsUrls?: {
|
|
22
|
+
messageArrived?: string;
|
|
23
|
+
};
|
|
24
|
+
theme?: {
|
|
25
|
+
primaryColor?: string;
|
|
26
|
+
};
|
|
27
|
+
settings?: {
|
|
28
|
+
persistSession?: boolean;
|
|
29
|
+
playSoundEffects?: boolean;
|
|
30
|
+
};
|
|
31
|
+
assets?: {
|
|
32
|
+
organizationLogo?: string;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ChatAttachmentType, WidgetHistoryDto } from './schemas-v2';
|
|
1
|
+
import { MessageAttachmentType, MessageDto } from './schemas';
|
|
3
2
|
import { SafeExtract, StringOrLiteral } from './helpers';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
id: string | null;
|
|
7
|
-
name: string;
|
|
8
|
-
avatar: string | null;
|
|
9
|
-
};
|
|
3
|
+
import { AgentOrBotType } from './agent-or-bot';
|
|
4
|
+
import { DefaultTextComponentBaseProps, WidgetLiteralComponentKey } from '../../react/types/components';
|
|
10
5
|
export type UserMessageType = {
|
|
11
6
|
id: string;
|
|
12
7
|
type: "FROM_USER";
|
|
13
8
|
content: string;
|
|
14
9
|
deliveredAt: string | null;
|
|
15
|
-
attachments?:
|
|
10
|
+
attachments?: MessageAttachmentType[] | null;
|
|
16
11
|
timestamp: string;
|
|
17
12
|
user?: {
|
|
18
13
|
name?: string;
|
|
@@ -31,9 +26,9 @@ export type BotMessageType<TData = DefaultTextComponentBaseProps | unknown> = {
|
|
|
31
26
|
component: StringOrLiteral<SafeExtract<WidgetLiteralComponentKey, "bot_message">>;
|
|
32
27
|
data: TData;
|
|
33
28
|
timestamp: string;
|
|
34
|
-
original?:
|
|
35
|
-
agent?:
|
|
36
|
-
attachments?:
|
|
29
|
+
original?: MessageDto;
|
|
30
|
+
agent?: AgentOrBotType;
|
|
31
|
+
attachments?: MessageAttachmentType[];
|
|
37
32
|
};
|
|
38
33
|
export type AgentMessageType = {
|
|
39
34
|
id: string;
|
|
@@ -41,24 +36,9 @@ export type AgentMessageType = {
|
|
|
41
36
|
component: SafeExtract<WidgetLiteralComponentKey, "agent_message">;
|
|
42
37
|
data: DefaultTextComponentBaseProps;
|
|
43
38
|
timestamp?: string;
|
|
44
|
-
original?:
|
|
45
|
-
agent?:
|
|
46
|
-
attachments?:
|
|
39
|
+
original?: MessageDto;
|
|
40
|
+
agent?: AgentOrBotType;
|
|
41
|
+
attachments?: MessageAttachmentType[];
|
|
47
42
|
};
|
|
43
|
+
/** Find a better name for this thing */
|
|
48
44
|
export type MessageType = UserMessageType | BotMessageType | AgentMessageType;
|
|
49
|
-
export interface SendMessageInput {
|
|
50
|
-
content: {
|
|
51
|
-
text: string;
|
|
52
|
-
};
|
|
53
|
-
attachments?: ChatAttachmentType[];
|
|
54
|
-
id?: string;
|
|
55
|
-
language?: string;
|
|
56
|
-
user?: {
|
|
57
|
-
external_id?: string;
|
|
58
|
-
name?: string;
|
|
59
|
-
email?: string;
|
|
60
|
-
phone?: string;
|
|
61
|
-
customData?: Record<string, string>;
|
|
62
|
-
avatarUrl?: string;
|
|
63
|
-
};
|
|
64
|
-
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Dto } from '../sdk';
|
|
2
|
+
export type VoteInputDto = Dto["WidgetVoteDto"];
|
|
3
|
+
export type VoteOutputDto = Dto["WidgetVoteResponseDto"];
|
|
4
|
+
export type SendMessageDto = Dto["HttpChatInputDto"];
|
|
5
|
+
export type SendMessageOutputDto = Dto["HandleContactMessageOutputDto"];
|
|
6
|
+
export type SessionDto = Dto["WidgetSessionDto"];
|
|
7
|
+
export type MessageDto = Dto["WidgetHistoryDto"];
|
|
8
|
+
export type PreludeDto = Dto["WidgetPreludeDto"];
|
|
9
|
+
export type MessageAttachmentType = NonNullable<Dto["WidgetHistoryDto"]["attachments"]>[number];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PubSub } from './PubSub';
|
|
2
|
+
export type PollingState = {
|
|
3
|
+
isPolling: boolean;
|
|
4
|
+
isError: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare class Poller {
|
|
7
|
+
state: PubSub<PollingState>;
|
|
8
|
+
private abortController;
|
|
9
|
+
reset: () => void;
|
|
10
|
+
stopPolling: (() => void) | null;
|
|
11
|
+
startPolling: (cb: (abortSignal: AbortSignal) => Promise<void>, interval: number) => void;
|
|
12
|
+
}
|
|
@@ -25,18 +25,16 @@ export declare class PubSub<S> {
|
|
|
25
25
|
* @param callback Function to call when state changes
|
|
26
26
|
* @returns Unsubscribe function
|
|
27
27
|
*/
|
|
28
|
-
subscribe: (callback: Subscriber<S>) => () => void;
|
|
29
|
-
onLifecycle: (event: LifecycleEvent, listener: LifecycleListener) => () => void;
|
|
30
|
-
/**
|
|
31
|
-
|
|
32
|
-
*/
|
|
33
|
-
getState: () => S;
|
|
28
|
+
subscribe: (callback: Subscriber<S>) => (() => void);
|
|
29
|
+
onLifecycle: (event: LifecycleEvent, listener: LifecycleListener) => (() => void);
|
|
30
|
+
/** Get the current state */
|
|
31
|
+
get: () => S;
|
|
34
32
|
/**
|
|
35
33
|
* Set the state and notify subscribers if the state changes
|
|
36
34
|
* @param newState The new state to set
|
|
37
35
|
*/
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
set: (newState: S) => void;
|
|
37
|
+
setPartial: (_s: Partial<S>) => void;
|
|
40
38
|
/**
|
|
41
39
|
* Clear all subscriptions
|
|
42
40
|
*/
|
|
@@ -44,5 +42,4 @@ export declare class PubSub<S> {
|
|
|
44
42
|
reset: () => void;
|
|
45
43
|
lastUpdated: () => number | null;
|
|
46
44
|
}
|
|
47
|
-
export declare function createPubSub<S>(state: S): PubSub<S>;
|
|
48
45
|
export {};
|