@opencx/widget 2.5.1 → 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 +55 -12
- package/dist/core/client/config.d.ts +13 -3
- package/dist/core/client/contact.d.ts +3 -13
- package/dist/core/errors/index.d.ts +6 -0
- package/dist/core/platform/audio.d.ts +38 -0
- package/dist/core/platform/index.d.ts +6 -2
- package/dist/core/platform/storage.d.ts +8 -2
- package/dist/core/sdk/index.d.ts +11 -0
- package/dist/core/tests/platform/logger.test.d.ts +1 -0
- package/dist/core/tests/platform/storage.test.d.ts +1 -0
- package/dist/core/tests/test-utils.d.ts +2 -0
- package/dist/core/tests/types/pub-sub.test.d.ts +1 -0
- package/dist/core/types/helpers.d.ts +5 -2
- package/dist/core/types/index.d.ts +6 -6
- package/dist/core/types/messages.d.ts +20 -9
- package/dist/core/types/pub-sub.d.ts +1 -0
- package/dist/core/types/schemas-v2.d.ts +10 -710
- 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 -874
- 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 +8 -4
- package/dist/core/types/schemas.d.ts +0 -543
- package/dist/core/utils/create-fetch.d.ts +0 -24
- package/dist/core/utils/genId.d.ts +0 -2
- package/dist/core/utils/history-to-widget-messages.d.ts +0 -4
- package/dist/genUuid-BkZtn1k9.cjs +0 -2
- package/dist/genUuid-BkZtn1k9.cjs.map +0 -1
- package/dist/genUuid-CDpI3ugS.js +0 -136
- package/dist/genUuid-CDpI3ugS.js.map +0 -1
- package/dist/index-1bY4_hBw.cjs +0 -18
- package/dist/index-1bY4_hBw.cjs.map +0 -1
- package/dist/index-D84Xc70r.js +0 -2609
- package/dist/index-D84Xc70r.js.map +0 -1
- package/dist/package.json.d.ts +0 -157
- 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/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/core/{utils/genId.test.d.ts → tests/client/integration-perisitance.test.d.ts} +0 -0
- /package/dist/{react-web/hooks/use-sound.test.d.ts → core/tests/client/integration.test.d.ts} +0 -0
- /package/dist/{react-web/hooks/use-sync-state.test.d.ts → core/tests/platform/audio.test.d.ts} +0 -0
- /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,17 +1,28 @@
|
|
|
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
|
-
type
|
|
8
|
+
export type PollingType = "session" | "messages";
|
|
9
|
+
export type PollingState = {
|
|
10
|
+
isPolling: boolean;
|
|
11
|
+
lastPollTime: string | null;
|
|
12
|
+
nextPollTime: string | null;
|
|
13
|
+
error: ErrorState;
|
|
14
|
+
};
|
|
15
|
+
export type PollingStates = {
|
|
16
|
+
[K in PollingType]: PollingState;
|
|
17
|
+
};
|
|
18
|
+
export type ChatState = {
|
|
9
19
|
messages: MessageType[];
|
|
10
20
|
keyboard: {
|
|
11
21
|
options: string[];
|
|
12
22
|
} | null;
|
|
13
23
|
loading: LoadingState;
|
|
14
24
|
error: ErrorState;
|
|
25
|
+
polling: PollingStates;
|
|
15
26
|
};
|
|
16
27
|
type ChatOptions = {
|
|
17
28
|
api: ApiCaller;
|
|
@@ -19,34 +30,66 @@ type ChatOptions = {
|
|
|
19
30
|
onSessionDestroy?: () => void;
|
|
20
31
|
platform: Platform;
|
|
21
32
|
};
|
|
33
|
+
export type SendMessageInput = SomeOptional<SafeOmit<SendChatDto, "bot_token" | "uuid">, "session_id" | "user">;
|
|
22
34
|
export declare function createChat(options: ChatOptions): {
|
|
23
35
|
chatState: PubSub<ChatState>;
|
|
24
36
|
sessionState: PubSub<{
|
|
25
37
|
id: string;
|
|
26
|
-
createdAt:
|
|
27
|
-
updatedAt:
|
|
38
|
+
createdAt: string;
|
|
39
|
+
updatedAt: string;
|
|
28
40
|
isHandedOff: boolean;
|
|
29
41
|
isOpened: boolean;
|
|
30
42
|
assignee: {
|
|
43
|
+
kind: "human" | "ai" | "none" | "unknown";
|
|
31
44
|
name: string | null;
|
|
32
|
-
|
|
45
|
+
avatarUrl: string | null;
|
|
33
46
|
};
|
|
34
47
|
channel: string;
|
|
48
|
+
isVerified: boolean;
|
|
35
49
|
} | null>;
|
|
36
|
-
sendMessage: (input:
|
|
50
|
+
sendMessage: (input: SendMessageInput, abort?: AbortSignal) => Promise<{
|
|
51
|
+
success: boolean;
|
|
52
|
+
createdSession: boolean;
|
|
53
|
+
botMessage?: undefined;
|
|
54
|
+
error?: undefined;
|
|
55
|
+
} | {
|
|
56
|
+
success: boolean;
|
|
57
|
+
createdSession: boolean;
|
|
58
|
+
botMessage: BotMessageType | null;
|
|
59
|
+
error?: undefined;
|
|
60
|
+
} | {
|
|
61
|
+
success: boolean;
|
|
62
|
+
createdSession: boolean;
|
|
63
|
+
error: unknown;
|
|
64
|
+
botMessage?: undefined;
|
|
65
|
+
}>;
|
|
37
66
|
createSession: () => Promise<{
|
|
38
67
|
id: string;
|
|
39
|
-
createdAt:
|
|
40
|
-
updatedAt:
|
|
68
|
+
createdAt: string;
|
|
69
|
+
updatedAt: string;
|
|
41
70
|
isHandedOff: boolean;
|
|
42
71
|
isOpened: boolean;
|
|
43
72
|
assignee: {
|
|
73
|
+
kind: "human" | "ai" | "none" | "unknown";
|
|
44
74
|
name: string | null;
|
|
45
|
-
|
|
75
|
+
avatarUrl: string | null;
|
|
46
76
|
};
|
|
47
77
|
channel: string;
|
|
78
|
+
isVerified: boolean;
|
|
48
79
|
} | null>;
|
|
49
80
|
clearSession: () => Promise<void>;
|
|
50
|
-
cleanup: (
|
|
81
|
+
cleanup: () => void;
|
|
82
|
+
initialState: ChatState;
|
|
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
|
+
};
|
|
51
94
|
};
|
|
52
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
|
-
type
|
|
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 {};
|
|
@@ -19,3 +19,9 @@ export declare class TransportError extends OpenCXError {
|
|
|
19
19
|
export declare class FileUploadError extends OpenCXError {
|
|
20
20
|
constructor(message?: string);
|
|
21
21
|
}
|
|
22
|
+
export declare class StorageNotAvailableError extends OpenCXError {
|
|
23
|
+
constructor(message?: string);
|
|
24
|
+
}
|
|
25
|
+
export declare class ExternalIdNotDefinedError extends OpenCXError {
|
|
26
|
+
constructor(message?: string);
|
|
27
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform-agnostic audio interface that can be implemented
|
|
3
|
+
* for different environments (web, mobile, desktop, etc.)
|
|
4
|
+
*/
|
|
5
|
+
export interface Audio {
|
|
6
|
+
/**
|
|
7
|
+
* Plays a notification sound
|
|
8
|
+
* @returns Promise that resolves when the sound finishes playing or rejects on error
|
|
9
|
+
*/
|
|
10
|
+
playNotification(): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Checks if audio playback is available and working
|
|
13
|
+
* @returns true if audio is available and working
|
|
14
|
+
*/
|
|
15
|
+
isAvailable?(): boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Helper function to check if audio is available and working
|
|
19
|
+
*/
|
|
20
|
+
export declare function isAudioAvailable(audio: Audio | undefined): audio is Audio;
|
|
21
|
+
/**
|
|
22
|
+
* Type for the result of a safe audio operation
|
|
23
|
+
*/
|
|
24
|
+
export type AudioOperationResult = {
|
|
25
|
+
success: true;
|
|
26
|
+
error: null;
|
|
27
|
+
} | {
|
|
28
|
+
success: false;
|
|
29
|
+
error: {
|
|
30
|
+
message: string;
|
|
31
|
+
code: string;
|
|
32
|
+
context: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Helper function to safely perform audio operations
|
|
37
|
+
*/
|
|
38
|
+
export declare function safeAudioOperation(operation: () => Promise<void>, errorContext: string): Promise<AudioOperationResult>;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import { Logger } from './logger';
|
|
2
1
|
import { Storage } from './storage';
|
|
2
|
+
import { Audio } from './audio';
|
|
3
|
+
import { Logger } from './logger';
|
|
3
4
|
export * from './storage';
|
|
4
|
-
export
|
|
5
|
+
export * from './logger';
|
|
6
|
+
export * from './audio';
|
|
7
|
+
export type { Storage, Audio, Logger };
|
|
5
8
|
export interface Platform {
|
|
6
9
|
storage?: Storage;
|
|
7
10
|
logger?: Logger;
|
|
8
11
|
env: {
|
|
9
12
|
platform: string;
|
|
10
13
|
};
|
|
14
|
+
audio?: Audio;
|
|
11
15
|
}
|
|
@@ -36,11 +36,17 @@ export declare function isStorageAvailable(storage: Storage | undefined): storag
|
|
|
36
36
|
export type StorageOperationResult<T> = {
|
|
37
37
|
success: true;
|
|
38
38
|
result: T;
|
|
39
|
+
error: null;
|
|
39
40
|
} | {
|
|
40
41
|
success: false;
|
|
41
|
-
|
|
42
|
+
result: null;
|
|
43
|
+
error: {
|
|
44
|
+
message: string;
|
|
45
|
+
code: string;
|
|
46
|
+
context: string;
|
|
47
|
+
};
|
|
42
48
|
};
|
|
43
49
|
/**
|
|
44
50
|
* Helper function to safely perform storage operations
|
|
45
51
|
*/
|
|
46
|
-
export declare function safeStorageOperation<T>(operation: () => Promise<T>,
|
|
52
|
+
export declare function safeStorageOperation<T>(operation: () => Promise<T>, errorContext: string): Promise<StorageOperationResult<T>>;
|