@opencx/widget 2.6.0 → 2.6.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/api-BwKgAJ6p.cjs +2 -0
- package/dist/api-BwKgAJ6p.cjs.map +1 -0
- package/dist/api-DRZ9vPwy.js +1360 -0
- package/dist/api-DRZ9vPwy.js.map +1 -0
- package/dist/basic.cjs +85 -85
- package/dist/basic.cjs.map +1 -1
- package/dist/basic.js +13350 -12831
- package/dist/basic.js.map +1 -1
- package/dist/core/client/api.d.ts +368 -40
- package/dist/core/client/chat.d.ts +27 -19
- package/dist/core/client/config.d.ts +13 -3
- package/dist/core/client/contact.d.ts +2 -12
- package/dist/core/sdk/index.d.ts +11 -0
- package/dist/core/types/helpers.d.ts +3 -0
- package/dist/core/types/index.d.ts +6 -6
- package/dist/core/types/messages.d.ts +20 -9
- package/dist/core/types/schemas-v2.d.ts +10 -713
- package/dist/index-B5YLfjom.cjs +18 -0
- package/dist/index-B5YLfjom.cjs.map +1 -0
- package/dist/index-EZN9_jan.js +1219 -0
- package/dist/index-EZN9_jan.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +22 -1071
- package/dist/index.js.map +1 -1
- package/dist/react-web/core-integration/ChatProvider.d.ts +101 -0
- package/dist/react-web/core-integration/components.d.ts +11 -0
- package/dist/react-web/core-integration/hooks/useChatMessages.d.ts +64 -0
- package/dist/react-web/core-integration/hooks/useChatSession.d.ts +77 -0
- package/dist/react-web/core-integration/hooks/useConfig.d.ts +1 -0
- package/dist/react-web/core-integration/hooks/useContact.d.ts +11 -0
- package/dist/react-web/core-integration/hooks/useLocale.d.ts +4 -0
- package/dist/react-web/core-integration/hooks/usePreludeData.d.ts +36 -0
- package/dist/react-web/core-integration/hooks/usePubsub.d.ts +2 -0
- package/dist/react-web/{hooks → core-integration/hooks}/useUploadFiles.d.ts +2 -2
- package/dist/react-web/{hooks → core-integration/hooks}/useVote.d.ts +2 -2
- package/dist/react-web/core-integration/hooks.d.ts +9 -0
- package/dist/react-web/core-integration/index.d.ts +2 -0
- package/dist/react-web/index.d.ts +4 -10
- package/dist/react-web/types/components.d.ts +6 -3
- package/dist/react-web/types/index.d.ts +3 -2
- package/dist/react-web/types/options.d.ts +4 -30
- package/dist/react.cjs +1 -1
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +10 -46
- package/dist/react.js.map +1 -1
- package/dist/src/@components/BotOrAgentMessageGroup.d.ts +1 -2
- package/dist/src/@components/BotOrAgentMessageWrapper.d.ts +2 -2
- package/dist/src/@components/ChatEvent.component.d.ts +3 -3
- package/dist/src/@components/Text.component.d.ts +1 -1
- package/dist/src/components/button.d.ts +1 -1
- package/dist/src/components/dialog.d.ts +9 -9
- package/dist/src/designs/basic/index.d.ts +1 -1
- package/dist/style.css +1 -1
- package/dist-embed/script.js +119 -124
- package/dist-embed/script.js.map +1 -1
- package/package.json +7 -4
- package/dist/core/tests/utils/create-fetch.test.d.ts +0 -1
- package/dist/core/types/schemas.d.ts +0 -543
- package/dist/core/utils/create-fetch.d.ts +0 -25
- package/dist/core/utils/genId.d.ts +0 -2
- package/dist/core/utils/history-to-widget-messages.d.ts +0 -4
- package/dist/genUuid-C12yFv3j.js +0 -137
- package/dist/genUuid-C12yFv3j.js.map +0 -1
- package/dist/genUuid-DdeSE04H.cjs +0 -2
- package/dist/genUuid-DdeSE04H.cjs.map +0 -1
- package/dist/index-C87obATS.js +0 -2616
- package/dist/index-C87obATS.js.map +0 -1
- package/dist/index-ChwS_h0D.cjs +0 -18
- package/dist/index-ChwS_h0D.cjs.map +0 -1
- package/dist/package.json.d.ts +0 -158
- package/dist/react-web/Root.d.ts +0 -6
- package/dist/react-web/hooks/index.d.ts +0 -6
- package/dist/react-web/hooks/use-sound.d.ts +0 -13
- package/dist/react-web/hooks/use-sound.test.d.ts +0 -1
- package/dist/react-web/hooks/use-sync-state.test.d.ts +0 -1
- package/dist/react-web/hooks/useAbstractChat.d.ts +0 -157
- package/dist/react-web/hooks/useAxiosInstance.d.ts +0 -190
- package/dist/react-web/hooks/useSyncState.d.ts +0 -4
- package/dist/react-web/hooks/useTimeoutState.d.ts +0 -3
- package/dist/react-web/providers/ChatProvider.d.ts +0 -143
- package/dist/react-web/providers/ConfigDataProvider.d.ts +0 -62
- package/dist/react-web/providers/ContactProvider.d.ts +0 -58
- package/dist/react-web/providers/LocalesProvider.d.ts +0 -11
- package/dist/react-web/providers/componentRegistry.d.ts +0 -13
- package/dist/react-web/providers/use-widget-sfx.d.ts +0 -7
- package/dist/react-web/providers/usePreludeData.d.ts +0 -2
- package/dist/react-web/utils/debug.d.ts +0 -2
- package/dist/react-web/utils/getters.d.ts +0 -24
- package/dist/react-web/utils/index.d.ts +0 -1
- package/dist/src/hooks/useShouldCollectData.d.ts +0 -3
- /package/dist/react-web/{locales → core-integration/locales}/ar.locale.d.ts +0 -0
- /package/dist/react-web/{locales → core-integration/locales}/de.locale.d.ts +0 -0
- /package/dist/react-web/{locales → core-integration/locales}/en.locale.d.ts +0 -0
- /package/dist/react-web/{locales → core-integration/locales}/fr.locale.d.ts +0 -0
- /package/dist/react-web/{locales → core-integration/locales}/helper.d.ts +0 -0
- /package/dist/react-web/{locales → core-integration/locales}/index.d.ts +0 -0
- /package/dist/react-web/{locales → core-integration/locales}/nl.locale.d.ts +0 -0
- /package/dist/react-web/{locales → core-integration/locales}/pt.locale.d.ts +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SendChatDto, WidgetVoteDto } from '../types/schemas-v2';
|
|
2
2
|
import { NormalizedConfig } from './config';
|
|
3
|
+
import { Dto } from '../sdk';
|
|
3
4
|
export interface ApiCallerOptions {
|
|
4
5
|
config: NormalizedConfig;
|
|
5
6
|
}
|
|
@@ -7,44 +8,371 @@ export declare class ApiCaller {
|
|
|
7
8
|
#private;
|
|
8
9
|
private readonly options;
|
|
9
10
|
constructor(options: ApiCallerOptions);
|
|
10
|
-
me()
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
11
|
+
me: () => Promise<import('openapi-fetch').FetchResponse<{
|
|
12
|
+
parameters: {
|
|
13
|
+
query?: never;
|
|
14
|
+
header?: never;
|
|
15
|
+
path?: never;
|
|
16
|
+
cookie?: never;
|
|
17
|
+
};
|
|
18
|
+
requestBody?: never;
|
|
19
|
+
responses: {
|
|
20
|
+
200: {
|
|
21
|
+
headers: {
|
|
22
|
+
[name: string]: unknown;
|
|
23
|
+
};
|
|
24
|
+
content: {
|
|
25
|
+
"application/json": import('../sdk/schema').components["schemas"]["WidgetContactDto"];
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
500: {
|
|
29
|
+
headers: {
|
|
30
|
+
[name: string]: unknown;
|
|
31
|
+
};
|
|
32
|
+
content: {
|
|
33
|
+
"application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
}, import('openapi-fetch').FetchOptions<{
|
|
38
|
+
parameters: {
|
|
39
|
+
query?: never;
|
|
40
|
+
header?: never;
|
|
41
|
+
path?: never;
|
|
42
|
+
cookie?: never;
|
|
43
|
+
};
|
|
44
|
+
requestBody?: never;
|
|
45
|
+
responses: {
|
|
46
|
+
200: {
|
|
47
|
+
headers: {
|
|
48
|
+
[name: string]: unknown;
|
|
49
|
+
};
|
|
50
|
+
content: {
|
|
51
|
+
"application/json": import('../sdk/schema').components["schemas"]["WidgetContactDto"];
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
500: {
|
|
55
|
+
headers: {
|
|
56
|
+
[name: string]: unknown;
|
|
57
|
+
};
|
|
58
|
+
content: {
|
|
59
|
+
"application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
}> | undefined, `${string}/${string}`>>;
|
|
64
|
+
widgetPrelude: () => Promise<import('openapi-fetch').FetchResponse<{
|
|
65
|
+
parameters: {
|
|
66
|
+
query?: never;
|
|
67
|
+
header: {
|
|
68
|
+
"X-Bot-Token": string;
|
|
69
|
+
};
|
|
70
|
+
path?: never;
|
|
71
|
+
cookie?: never;
|
|
72
|
+
};
|
|
73
|
+
requestBody?: never;
|
|
74
|
+
responses: {
|
|
75
|
+
200: {
|
|
76
|
+
headers: {
|
|
77
|
+
[name: string]: unknown;
|
|
78
|
+
};
|
|
79
|
+
content: {
|
|
80
|
+
"application/json": import('../sdk/schema').components["schemas"]["WidgetPreludeDto"];
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
500: {
|
|
84
|
+
headers: {
|
|
85
|
+
[name: string]: unknown;
|
|
86
|
+
};
|
|
87
|
+
content: {
|
|
88
|
+
"application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
}, {
|
|
93
|
+
params: {
|
|
94
|
+
header: {
|
|
95
|
+
'X-Bot-Token': string;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
}, `${string}/${string}`>>;
|
|
99
|
+
handleMessage: (body: SendChatDto, abortSignal?: AbortSignal) => Promise<import('openapi-fetch').FetchResponse<{
|
|
100
|
+
parameters: {
|
|
101
|
+
query?: never;
|
|
102
|
+
header?: never;
|
|
103
|
+
path?: never;
|
|
104
|
+
cookie?: never;
|
|
105
|
+
};
|
|
106
|
+
requestBody: {
|
|
107
|
+
content: {
|
|
108
|
+
"application/json": import('../sdk/schema').components["schemas"]["HttpChatInputDto"];
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
responses: {
|
|
112
|
+
200: {
|
|
113
|
+
headers: {
|
|
114
|
+
[name: string]: unknown;
|
|
115
|
+
};
|
|
116
|
+
content: {
|
|
117
|
+
"application/json": import('../sdk/schema').components["schemas"]["HandleContactMessageOutputDto"];
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
500: {
|
|
121
|
+
headers: {
|
|
122
|
+
[name: string]: unknown;
|
|
123
|
+
};
|
|
124
|
+
content: {
|
|
125
|
+
"application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
}, {
|
|
130
|
+
body: {
|
|
131
|
+
uuid: string;
|
|
132
|
+
content: string;
|
|
133
|
+
session_id: string;
|
|
134
|
+
headers?: {
|
|
135
|
+
[key: string]: string;
|
|
136
|
+
} | null;
|
|
137
|
+
bot_token: string;
|
|
138
|
+
query_params?: {
|
|
139
|
+
[key: string]: string;
|
|
140
|
+
} | null;
|
|
141
|
+
user?: {
|
|
142
|
+
email?: string;
|
|
143
|
+
name?: string;
|
|
144
|
+
phone?: string;
|
|
145
|
+
avatar?: string;
|
|
146
|
+
customData?: {
|
|
147
|
+
[key: string]: string;
|
|
148
|
+
};
|
|
149
|
+
} | null;
|
|
150
|
+
language?: string | null;
|
|
151
|
+
attachments?: {
|
|
152
|
+
id: string;
|
|
34
153
|
name: string;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
154
|
+
size: number;
|
|
155
|
+
type: string;
|
|
156
|
+
url: string;
|
|
157
|
+
}[] | null;
|
|
158
|
+
};
|
|
159
|
+
signal: AbortSignal | undefined;
|
|
160
|
+
}, `${string}/${string}`>>;
|
|
161
|
+
getSessionHistory: (sessionId: string, lastMessageTimestamp?: string) => Promise<import('openapi-fetch').FetchResponse<{
|
|
162
|
+
parameters: {
|
|
163
|
+
query?: {
|
|
164
|
+
lastMessageTimestamp?: string;
|
|
165
|
+
};
|
|
166
|
+
header?: never;
|
|
167
|
+
path: {
|
|
168
|
+
sessionId: string;
|
|
169
|
+
};
|
|
170
|
+
cookie?: never;
|
|
171
|
+
};
|
|
172
|
+
requestBody?: never;
|
|
173
|
+
responses: {
|
|
174
|
+
200: {
|
|
175
|
+
headers: {
|
|
176
|
+
[name: string]: unknown;
|
|
177
|
+
};
|
|
178
|
+
content: {
|
|
179
|
+
"application/json": import('../sdk/schema').components["schemas"]["WidgetHistoryDto"][];
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
500: {
|
|
183
|
+
headers: {
|
|
184
|
+
[name: string]: unknown;
|
|
185
|
+
};
|
|
186
|
+
content: {
|
|
187
|
+
"application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
}, {
|
|
192
|
+
params: {
|
|
193
|
+
path: {
|
|
194
|
+
sessionId: string;
|
|
195
|
+
};
|
|
196
|
+
query: {
|
|
197
|
+
lastMessageTimestamp: string;
|
|
198
|
+
} | undefined;
|
|
199
|
+
};
|
|
200
|
+
}, `${string}/${string}`>>;
|
|
201
|
+
createSession: () => Promise<import('openapi-fetch').FetchResponse<{
|
|
202
|
+
parameters: {
|
|
203
|
+
query?: never;
|
|
204
|
+
header?: never;
|
|
205
|
+
path?: never;
|
|
206
|
+
cookie?: never;
|
|
207
|
+
};
|
|
208
|
+
requestBody?: never;
|
|
209
|
+
responses: {
|
|
210
|
+
200: {
|
|
211
|
+
headers: {
|
|
212
|
+
[name: string]: unknown;
|
|
213
|
+
};
|
|
214
|
+
content: {
|
|
215
|
+
"application/json": import('../sdk/schema').components["schemas"]["WidgetSessionDto"];
|
|
216
|
+
};
|
|
217
|
+
};
|
|
218
|
+
500: {
|
|
219
|
+
headers: {
|
|
220
|
+
[name: string]: unknown;
|
|
221
|
+
};
|
|
222
|
+
content: {
|
|
223
|
+
"application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
|
|
224
|
+
};
|
|
225
|
+
};
|
|
226
|
+
};
|
|
227
|
+
}, import('openapi-fetch').FetchOptions<{
|
|
228
|
+
parameters: {
|
|
229
|
+
query?: never;
|
|
230
|
+
header?: never;
|
|
231
|
+
path?: never;
|
|
232
|
+
cookie?: never;
|
|
233
|
+
};
|
|
234
|
+
requestBody?: never;
|
|
235
|
+
responses: {
|
|
236
|
+
200: {
|
|
237
|
+
headers: {
|
|
238
|
+
[name: string]: unknown;
|
|
239
|
+
};
|
|
240
|
+
content: {
|
|
241
|
+
"application/json": import('../sdk/schema').components["schemas"]["WidgetSessionDto"];
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
500: {
|
|
245
|
+
headers: {
|
|
246
|
+
[name: string]: unknown;
|
|
247
|
+
};
|
|
248
|
+
content: {
|
|
249
|
+
"application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
|
|
250
|
+
};
|
|
251
|
+
};
|
|
252
|
+
};
|
|
253
|
+
}> | undefined, `${string}/${string}`>>;
|
|
254
|
+
getSession: (sessionId: string) => Promise<import('openapi-fetch').FetchResponse<{
|
|
255
|
+
parameters: {
|
|
256
|
+
query?: never;
|
|
257
|
+
header?: never;
|
|
258
|
+
path: {
|
|
259
|
+
sessionId: string;
|
|
260
|
+
};
|
|
261
|
+
cookie?: never;
|
|
262
|
+
};
|
|
263
|
+
requestBody?: never;
|
|
264
|
+
responses: {
|
|
265
|
+
200: {
|
|
266
|
+
headers: {
|
|
267
|
+
[name: string]: unknown;
|
|
268
|
+
};
|
|
269
|
+
content: {
|
|
270
|
+
"application/json": import('../sdk/schema').components["schemas"]["WidgetSessionDto"];
|
|
271
|
+
};
|
|
272
|
+
};
|
|
273
|
+
500: {
|
|
274
|
+
headers: {
|
|
275
|
+
[name: string]: unknown;
|
|
276
|
+
};
|
|
277
|
+
content: {
|
|
278
|
+
"application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
|
|
279
|
+
};
|
|
280
|
+
};
|
|
281
|
+
};
|
|
282
|
+
}, {
|
|
283
|
+
params: {
|
|
284
|
+
path: {
|
|
285
|
+
sessionId: string;
|
|
286
|
+
};
|
|
287
|
+
};
|
|
288
|
+
}, `${string}/${string}`>>;
|
|
289
|
+
uploadFile: ({ file, abortSignal }: {
|
|
290
|
+
file: {
|
|
291
|
+
id: string;
|
|
292
|
+
file: File;
|
|
293
|
+
};
|
|
294
|
+
abortSignal?: AbortSignal;
|
|
295
|
+
}) => Promise<import('openapi-fetch').FetchResponse<{
|
|
296
|
+
parameters: {
|
|
297
|
+
query: {
|
|
298
|
+
fileId: string;
|
|
299
|
+
sessionId: string;
|
|
300
|
+
};
|
|
301
|
+
header?: never;
|
|
302
|
+
path?: never;
|
|
303
|
+
cookie?: never;
|
|
304
|
+
};
|
|
305
|
+
requestBody: {
|
|
306
|
+
content: {
|
|
307
|
+
"multipart/form-data": import('../sdk/schema').components["schemas"]["FileUploadDto"];
|
|
308
|
+
};
|
|
309
|
+
};
|
|
310
|
+
responses: {
|
|
311
|
+
200: {
|
|
312
|
+
headers: {
|
|
313
|
+
[name: string]: unknown;
|
|
314
|
+
};
|
|
315
|
+
content: {
|
|
316
|
+
"application/json": import('../sdk/schema').components["schemas"]["UploadWidgetFileDto"];
|
|
317
|
+
};
|
|
318
|
+
};
|
|
319
|
+
500: {
|
|
320
|
+
headers: {
|
|
321
|
+
[name: string]: unknown;
|
|
322
|
+
};
|
|
323
|
+
content: {
|
|
324
|
+
"application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
|
|
325
|
+
};
|
|
326
|
+
};
|
|
327
|
+
};
|
|
328
|
+
}, {
|
|
329
|
+
params: {
|
|
330
|
+
query: {
|
|
331
|
+
fileId: string;
|
|
332
|
+
sessionId: string;
|
|
333
|
+
};
|
|
334
|
+
};
|
|
335
|
+
body: Dto["FileUploadDto"];
|
|
336
|
+
signal: AbortSignal | undefined;
|
|
337
|
+
headers: {
|
|
338
|
+
'Content-Type': string;
|
|
339
|
+
};
|
|
340
|
+
}, `${string}/${string}`>>;
|
|
341
|
+
vote: (body: WidgetVoteDto) => Promise<import('openapi-fetch').FetchResponse<{
|
|
342
|
+
parameters: {
|
|
343
|
+
query?: never;
|
|
344
|
+
header?: never;
|
|
345
|
+
path?: never;
|
|
346
|
+
cookie?: never;
|
|
347
|
+
};
|
|
348
|
+
requestBody: {
|
|
349
|
+
content: {
|
|
350
|
+
"application/json": import('../sdk/schema').components["schemas"]["WidgetVoteDto"];
|
|
351
|
+
};
|
|
352
|
+
};
|
|
353
|
+
responses: {
|
|
354
|
+
200: {
|
|
355
|
+
headers: {
|
|
356
|
+
[name: string]: unknown;
|
|
357
|
+
};
|
|
358
|
+
content: {
|
|
359
|
+
"application/json": import('../sdk/schema').components["schemas"]["WidgetVoteResponseDto"];
|
|
360
|
+
};
|
|
361
|
+
};
|
|
362
|
+
500: {
|
|
363
|
+
headers: {
|
|
364
|
+
[name: string]: unknown;
|
|
365
|
+
};
|
|
366
|
+
content: {
|
|
367
|
+
"application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
|
|
368
|
+
};
|
|
369
|
+
};
|
|
370
|
+
};
|
|
371
|
+
}, {
|
|
372
|
+
body: {
|
|
373
|
+
action: "upvote" | "downvote";
|
|
374
|
+
sessionId: string;
|
|
375
|
+
messagePublicId: string;
|
|
376
|
+
};
|
|
377
|
+
}, `${string}/${string}`>>;
|
|
50
378
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { PubSub } from '../types/pub-sub';
|
|
2
|
-
import { MessageType } from '../types';
|
|
2
|
+
import { BotMessageType, MessageType } from '../types';
|
|
3
3
|
import { ApiCaller } from './api';
|
|
4
|
-
import {
|
|
5
|
-
import { LoadingState, ErrorState, SomeOptional } from '../types/helpers';
|
|
4
|
+
import { SendChatDto } from '../types/schemas-v2';
|
|
5
|
+
import { LoadingState, ErrorState, SomeOptional, SafeOmit } from '../types/helpers';
|
|
6
6
|
import { ConfigInstance } from './config';
|
|
7
7
|
import { Platform } from '../platform';
|
|
8
|
-
export type PollingType =
|
|
8
|
+
export type PollingType = "session" | "messages";
|
|
9
9
|
export type PollingState = {
|
|
10
10
|
isPolling: boolean;
|
|
11
11
|
lastPollTime: string | null;
|
|
@@ -30,20 +30,22 @@ type ChatOptions = {
|
|
|
30
30
|
onSessionDestroy?: () => void;
|
|
31
31
|
platform: Platform;
|
|
32
32
|
};
|
|
33
|
-
export type SendMessageInput = SomeOptional<
|
|
33
|
+
export type SendMessageInput = SomeOptional<SafeOmit<SendChatDto, "bot_token" | "uuid">, "session_id" | "user">;
|
|
34
34
|
export declare function createChat(options: ChatOptions): {
|
|
35
35
|
chatState: PubSub<ChatState>;
|
|
36
36
|
sessionState: PubSub<{
|
|
37
37
|
id: string;
|
|
38
|
-
createdAt:
|
|
39
|
-
updatedAt:
|
|
38
|
+
createdAt: string;
|
|
39
|
+
updatedAt: string;
|
|
40
40
|
isHandedOff: boolean;
|
|
41
41
|
isOpened: boolean;
|
|
42
42
|
assignee: {
|
|
43
|
+
kind: "human" | "ai" | "none" | "unknown";
|
|
43
44
|
name: string | null;
|
|
44
|
-
|
|
45
|
+
avatarUrl: string | null;
|
|
45
46
|
};
|
|
46
47
|
channel: string;
|
|
48
|
+
isVerified: boolean;
|
|
47
49
|
} | null>;
|
|
48
50
|
sendMessage: (input: SendMessageInput, abort?: AbortSignal) => Promise<{
|
|
49
51
|
success: boolean;
|
|
@@ -53,13 +55,7 @@ export declare function createChat(options: ChatOptions): {
|
|
|
53
55
|
} | {
|
|
54
56
|
success: boolean;
|
|
55
57
|
createdSession: boolean;
|
|
56
|
-
botMessage:
|
|
57
|
-
type: "FROM_BOT";
|
|
58
|
-
id: string;
|
|
59
|
-
timestamp: string;
|
|
60
|
-
component: string;
|
|
61
|
-
data: unknown;
|
|
62
|
-
} | null;
|
|
58
|
+
botMessage: BotMessageType | null;
|
|
63
59
|
error?: undefined;
|
|
64
60
|
} | {
|
|
65
61
|
success: boolean;
|
|
@@ -69,19 +65,31 @@ export declare function createChat(options: ChatOptions): {
|
|
|
69
65
|
}>;
|
|
70
66
|
createSession: () => Promise<{
|
|
71
67
|
id: string;
|
|
72
|
-
createdAt:
|
|
73
|
-
updatedAt:
|
|
68
|
+
createdAt: string;
|
|
69
|
+
updatedAt: string;
|
|
74
70
|
isHandedOff: boolean;
|
|
75
71
|
isOpened: boolean;
|
|
76
72
|
assignee: {
|
|
73
|
+
kind: "human" | "ai" | "none" | "unknown";
|
|
77
74
|
name: string | null;
|
|
78
|
-
|
|
75
|
+
avatarUrl: string | null;
|
|
79
76
|
};
|
|
80
77
|
channel: string;
|
|
78
|
+
isVerified: boolean;
|
|
81
79
|
} | null>;
|
|
82
80
|
clearSession: () => Promise<void>;
|
|
83
|
-
cleanup: (
|
|
81
|
+
cleanup: () => void;
|
|
84
82
|
initialState: ChatState;
|
|
85
83
|
sessionStorageKey: string;
|
|
84
|
+
recreateSession: () => Promise<void>;
|
|
85
|
+
contactState: PubSub<{
|
|
86
|
+
contact: any | null;
|
|
87
|
+
loading: LoadingState;
|
|
88
|
+
error: ErrorState;
|
|
89
|
+
}>;
|
|
90
|
+
shouldCollectData: () => {
|
|
91
|
+
should: boolean;
|
|
92
|
+
reason?: string;
|
|
93
|
+
};
|
|
86
94
|
};
|
|
87
95
|
export {};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { Platform } from '../platform';
|
|
1
2
|
import { CoreOptions } from '../types';
|
|
2
|
-
export type NormalizedConfig = Required<Omit<CoreOptions, 'contactToken'>> & {
|
|
3
|
+
export type NormalizedConfig = Required<Omit<CoreOptions, 'contactToken' | 'initialMessages'>> & {
|
|
3
4
|
contactToken: string | undefined | null;
|
|
5
|
+
initialMessages: string[];
|
|
4
6
|
soundEffectFiles: {
|
|
5
7
|
messageArrived: string;
|
|
6
8
|
};
|
|
@@ -12,8 +14,13 @@ export type NormalizedConfig = Required<Omit<CoreOptions, 'contactToken'>> & {
|
|
|
12
14
|
persistSession: boolean;
|
|
13
15
|
useSoundEffects: boolean;
|
|
14
16
|
};
|
|
17
|
+
assets: {
|
|
18
|
+
organizationLogo: string;
|
|
19
|
+
};
|
|
15
20
|
};
|
|
16
21
|
export type ConfigInstance = {
|
|
22
|
+
config: NormalizedConfig;
|
|
23
|
+
updateSettings: (newSettings: Partial<WidgetSettings>) => void;
|
|
17
24
|
getConfig: () => NormalizedConfig;
|
|
18
25
|
getApiConfig: () => {
|
|
19
26
|
apiUrl: string;
|
|
@@ -24,10 +31,13 @@ export type ConfigInstance = {
|
|
|
24
31
|
};
|
|
25
32
|
getBotConfig: () => NormalizedConfig['bot'];
|
|
26
33
|
getThemeConfig: () => NormalizedConfig['theme'];
|
|
27
|
-
getSettings: () => NormalizedConfig['settings'];
|
|
28
34
|
getSoundEffects: () => NormalizedConfig['soundEffectFiles'];
|
|
29
35
|
getUser: () => NormalizedConfig['user'];
|
|
30
36
|
getLanguage: () => string;
|
|
31
37
|
getDebugMode: () => boolean;
|
|
32
38
|
};
|
|
33
|
-
export
|
|
39
|
+
export type WidgetSettings = {
|
|
40
|
+
persistSession: boolean;
|
|
41
|
+
useSoundEffects: boolean;
|
|
42
|
+
};
|
|
43
|
+
export declare function createConfig(options: CoreOptions, platform: Platform): ConfigInstance;
|
|
@@ -3,31 +3,21 @@ import { ApiCaller } from './api';
|
|
|
3
3
|
import { Platform } from '../platform';
|
|
4
4
|
import { LoadingState, ErrorState } from '../types/helpers';
|
|
5
5
|
import { ConfigInstance } from './config';
|
|
6
|
-
import { ConsumerType } from '@core/types/schemas';
|
|
7
6
|
type ContactState = {
|
|
8
|
-
contact:
|
|
7
|
+
contact: any | null;
|
|
9
8
|
loading: LoadingState;
|
|
10
9
|
error: ErrorState;
|
|
11
10
|
};
|
|
12
11
|
export type CreateContactOptions = {
|
|
13
12
|
api: ApiCaller;
|
|
14
|
-
platform: Platform;
|
|
15
13
|
config: ConfigInstance;
|
|
16
14
|
};
|
|
17
|
-
export declare function createContact(
|
|
15
|
+
export declare function createContact({ config }: CreateContactOptions, platform: Platform): {
|
|
18
16
|
contactState: PubSub<ContactState>;
|
|
19
17
|
shouldCollectData: () => {
|
|
20
18
|
should: boolean;
|
|
21
19
|
reason?: string;
|
|
22
20
|
};
|
|
23
|
-
loadContact: () => Promise<any>;
|
|
24
|
-
saveContact: (contactData: Partial<ConsumerType>) => Promise<{
|
|
25
|
-
id: string;
|
|
26
|
-
name: string | null;
|
|
27
|
-
email: string | null;
|
|
28
|
-
avatar_url: string | null;
|
|
29
|
-
created_at: string;
|
|
30
|
-
} | null>;
|
|
31
21
|
cleanup: () => Promise<void>;
|
|
32
22
|
};
|
|
33
23
|
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Middleware } from 'openapi-fetch';
|
|
2
|
+
import { paths, components } from './schema';
|
|
3
|
+
type Options = {
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
onRequest?: Middleware['onRequest'];
|
|
6
|
+
onResponse?: Middleware['onResponse'];
|
|
7
|
+
onError?: Middleware['onError'];
|
|
8
|
+
};
|
|
9
|
+
export declare const basicClient: (options: Options) => import('openapi-fetch').Client<paths, `${string}/${string}`>;
|
|
10
|
+
export type Dto = components['schemas'];
|
|
11
|
+
export {};
|
|
@@ -15,3 +15,6 @@ export type ErrorState = {
|
|
|
15
15
|
code?: ErrorCode;
|
|
16
16
|
};
|
|
17
17
|
export type SomeOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
18
|
+
export type SafeOmit<T, K extends keyof T> = Omit<T, K>;
|
|
19
|
+
export type SafeExtract<T, K extends T> = Extract<T, K>;
|
|
20
|
+
export type StringOrLiteral<T extends string> = T | (string & {});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AgentType } from './messages';
|
|
1
2
|
import { ChatAttachmentType } from './schemas-v2';
|
|
2
3
|
export * from './messages';
|
|
3
4
|
export * from './schemas-v2';
|
|
@@ -28,15 +29,11 @@ export interface CoreOptions {
|
|
|
28
29
|
pathParams?: Record<string, string>;
|
|
29
30
|
collectUserData?: boolean;
|
|
30
31
|
debug?: boolean;
|
|
32
|
+
initialMessages?: string[];
|
|
31
33
|
language?: string;
|
|
32
34
|
user?: User;
|
|
33
35
|
contactToken?: string;
|
|
34
|
-
bot?:
|
|
35
|
-
name?: string;
|
|
36
|
-
avatarUrl?: string;
|
|
37
|
-
id?: number | null;
|
|
38
|
-
is_ai?: boolean;
|
|
39
|
-
};
|
|
36
|
+
bot?: AgentType;
|
|
40
37
|
pollingInterval?: number;
|
|
41
38
|
soundEffectFiles?: {
|
|
42
39
|
messageArrived?: string;
|
|
@@ -49,4 +46,7 @@ export interface CoreOptions {
|
|
|
49
46
|
persistSession?: boolean;
|
|
50
47
|
useSoundEffects?: boolean;
|
|
51
48
|
};
|
|
49
|
+
assets?: {
|
|
50
|
+
organizationLogo?: string;
|
|
51
|
+
};
|
|
52
52
|
}
|