@opencx/widget 2.6.0 → 2.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/dist/api-BEtFfKMB.cjs +2 -0
  2. package/dist/api-BEtFfKMB.cjs.map +1 -0
  3. package/dist/api-Cez5T-se.js +1393 -0
  4. package/dist/api-Cez5T-se.js.map +1 -0
  5. package/dist/basic.cjs +85 -85
  6. package/dist/basic.cjs.map +1 -1
  7. package/dist/basic.js +13159 -12639
  8. package/dist/basic.js.map +1 -1
  9. package/dist/core/client/api.d.ts +414 -40
  10. package/dist/core/client/chat.d.ts +33 -19
  11. package/dist/core/client/config.d.ts +13 -3
  12. package/dist/core/client/contact.d.ts +9 -13
  13. package/dist/core/client/index.d.ts +1 -1
  14. package/dist/core/index.d.ts +1 -1
  15. package/dist/core/sdk/index.d.ts +11 -0
  16. package/dist/core/types/contact.d.ts +2 -0
  17. package/dist/core/types/helpers.d.ts +5 -2
  18. package/dist/core/types/index.d.ts +6 -6
  19. package/dist/core/types/messages.d.ts +20 -9
  20. package/dist/core/types/schemas-v2.d.ts +10 -713
  21. package/dist/index-BzidnDPX.cjs +18 -0
  22. package/dist/index-BzidnDPX.cjs.map +1 -0
  23. package/dist/index-DUlnC30_.js +1219 -0
  24. package/dist/index-DUlnC30_.js.map +1 -0
  25. package/dist/index.cjs +1 -1
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.js +22 -1071
  28. package/dist/index.js.map +1 -1
  29. package/dist/react-web/core-integration/ChatProvider.d.ts +107 -0
  30. package/dist/react-web/core-integration/components.d.ts +11 -0
  31. package/dist/react-web/core-integration/hooks/useChatMessages.d.ts +70 -0
  32. package/dist/react-web/core-integration/hooks/useChatSession.d.ts +83 -0
  33. package/dist/react-web/core-integration/hooks/useConfig.d.ts +1 -0
  34. package/dist/react-web/core-integration/hooks/useContact.d.ts +17 -0
  35. package/dist/react-web/core-integration/hooks/useLocale.d.ts +4 -0
  36. package/dist/react-web/core-integration/hooks/usePreludeData.d.ts +36 -0
  37. package/dist/react-web/core-integration/hooks/usePubsub.d.ts +2 -0
  38. package/dist/react-web/{hooks → core-integration/hooks}/useUploadFiles.d.ts +2 -2
  39. package/dist/react-web/{hooks → core-integration/hooks}/useVote.d.ts +2 -2
  40. package/dist/react-web/core-integration/hooks.d.ts +9 -0
  41. package/dist/react-web/core-integration/index.d.ts +2 -0
  42. package/dist/react-web/index.d.ts +4 -10
  43. package/dist/react-web/types/components.d.ts +6 -3
  44. package/dist/react-web/types/index.d.ts +3 -2
  45. package/dist/react-web/types/options.d.ts +4 -30
  46. package/dist/react.cjs +1 -1
  47. package/dist/react.cjs.map +1 -1
  48. package/dist/react.js +10 -46
  49. package/dist/react.js.map +1 -1
  50. package/dist/src/@components/BotOrAgentMessageGroup.d.ts +1 -2
  51. package/dist/src/@components/BotOrAgentMessageWrapper.d.ts +2 -2
  52. package/dist/src/@components/ChatEvent.component.d.ts +3 -3
  53. package/dist/src/@components/Text.component.d.ts +1 -1
  54. package/dist/src/components/button.d.ts +1 -1
  55. package/dist/src/components/dialog.d.ts +9 -9
  56. package/dist/src/designs/basic/index.d.ts +1 -1
  57. package/dist/style.css +1 -1
  58. package/dist-embed/script.js +119 -124
  59. package/dist-embed/script.js.map +1 -1
  60. package/package.json +7 -4
  61. package/dist/core/tests/utils/create-fetch.test.d.ts +0 -1
  62. package/dist/core/types/schemas.d.ts +0 -543
  63. package/dist/core/utils/create-fetch.d.ts +0 -25
  64. package/dist/core/utils/genId.d.ts +0 -2
  65. package/dist/core/utils/history-to-widget-messages.d.ts +0 -4
  66. package/dist/genUuid-C12yFv3j.js +0 -137
  67. package/dist/genUuid-C12yFv3j.js.map +0 -1
  68. package/dist/genUuid-DdeSE04H.cjs +0 -2
  69. package/dist/genUuid-DdeSE04H.cjs.map +0 -1
  70. package/dist/index-C87obATS.js +0 -2616
  71. package/dist/index-C87obATS.js.map +0 -1
  72. package/dist/index-ChwS_h0D.cjs +0 -18
  73. package/dist/index-ChwS_h0D.cjs.map +0 -1
  74. package/dist/package.json.d.ts +0 -158
  75. package/dist/react-web/Root.d.ts +0 -6
  76. package/dist/react-web/hooks/index.d.ts +0 -6
  77. package/dist/react-web/hooks/use-sound.d.ts +0 -13
  78. package/dist/react-web/hooks/use-sound.test.d.ts +0 -1
  79. package/dist/react-web/hooks/use-sync-state.test.d.ts +0 -1
  80. package/dist/react-web/hooks/useAbstractChat.d.ts +0 -157
  81. package/dist/react-web/hooks/useAxiosInstance.d.ts +0 -190
  82. package/dist/react-web/hooks/useSyncState.d.ts +0 -4
  83. package/dist/react-web/hooks/useTimeoutState.d.ts +0 -3
  84. package/dist/react-web/providers/ChatProvider.d.ts +0 -143
  85. package/dist/react-web/providers/ConfigDataProvider.d.ts +0 -62
  86. package/dist/react-web/providers/ContactProvider.d.ts +0 -58
  87. package/dist/react-web/providers/LocalesProvider.d.ts +0 -11
  88. package/dist/react-web/providers/componentRegistry.d.ts +0 -13
  89. package/dist/react-web/providers/use-widget-sfx.d.ts +0 -7
  90. package/dist/react-web/providers/usePreludeData.d.ts +0 -2
  91. package/dist/react-web/utils/debug.d.ts +0 -2
  92. package/dist/react-web/utils/getters.d.ts +0 -24
  93. package/dist/react-web/utils/index.d.ts +0 -1
  94. package/dist/src/hooks/useShouldCollectData.d.ts +0 -3
  95. /package/dist/react-web/{locales → core-integration/locales}/ar.locale.d.ts +0 -0
  96. /package/dist/react-web/{locales → core-integration/locales}/de.locale.d.ts +0 -0
  97. /package/dist/react-web/{locales → core-integration/locales}/en.locale.d.ts +0 -0
  98. /package/dist/react-web/{locales → core-integration/locales}/fr.locale.d.ts +0 -0
  99. /package/dist/react-web/{locales → core-integration/locales}/helper.d.ts +0 -0
  100. /package/dist/react-web/{locales → core-integration/locales}/index.d.ts +0 -0
  101. /package/dist/react-web/{locales → core-integration/locales}/nl.locale.d.ts +0 -0
  102. /package/dist/react-web/{locales → core-integration/locales}/pt.locale.d.ts +0 -0
@@ -1,5 +1,7 @@
1
- import { HttpChatInputSchema, WidgetHistorySchema, WidgetPreludeSchema, WidgetSessionSchema } from '../types/schemas-v2';
1
+ import { User } from '../types';
2
+ import { SendChatDto, WidgetVoteDto } from '../types/schemas-v2';
2
3
  import { NormalizedConfig } from './config';
4
+ import { Dto } from '../sdk';
3
5
  export interface ApiCallerOptions {
4
6
  config: NormalizedConfig;
5
7
  }
@@ -7,44 +9,416 @@ export declare class ApiCaller {
7
9
  #private;
8
10
  private readonly options;
9
11
  constructor(options: ApiCallerOptions);
10
- me(): Promise<{
11
- contactId: string;
12
- contactName: string;
13
- }>;
14
- widgetPrelude(): Promise<WidgetPreludeSchema>;
15
- handleMessage(message: HttpChatInputSchema, abortSignal?: AbortSignal): Promise<{
16
- success: true;
17
- code?: string | undefined;
18
- options?: {
19
- type: "options";
20
- value: string[];
21
- } | undefined;
22
- autopilotResponse?: {
23
- type: "text";
24
- value: {
25
- content: string;
26
- error: boolean;
27
- };
28
- id?: string | undefined;
29
- } | undefined;
30
- uiResponse?: {
31
- type: "ui";
32
- value: {
33
- type: "ui_component";
12
+ createClient: (user: User) => import('openapi-fetch').Client<import('../sdk/schema').paths, `${string}/${string}`>;
13
+ setUser: (user: User) => void;
14
+ me: () => Promise<import('openapi-fetch').FetchResponse<{
15
+ parameters: {
16
+ query?: never;
17
+ header?: never;
18
+ path?: never;
19
+ cookie?: never;
20
+ };
21
+ requestBody?: never;
22
+ responses: {
23
+ 200: {
24
+ headers: {
25
+ [name: string]: unknown;
26
+ };
27
+ content: {
28
+ "application/json": import('../sdk/schema').components["schemas"]["WidgetContactDto"];
29
+ };
30
+ };
31
+ 500: {
32
+ headers: {
33
+ [name: string]: unknown;
34
+ };
35
+ content: {
36
+ "application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
37
+ };
38
+ };
39
+ };
40
+ }, import('openapi-fetch').FetchOptions<{
41
+ parameters: {
42
+ query?: never;
43
+ header?: never;
44
+ path?: never;
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"]["WidgetContactDto"];
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
+ }> | undefined, `${string}/${string}`>>;
67
+ widgetPrelude: () => Promise<import('openapi-fetch').FetchResponse<{
68
+ parameters: {
69
+ query?: never;
70
+ header: {
71
+ "X-Bot-Token": string;
72
+ };
73
+ path?: never;
74
+ cookie?: never;
75
+ };
76
+ requestBody?: never;
77
+ responses: {
78
+ 200: {
79
+ headers: {
80
+ [name: string]: unknown;
81
+ };
82
+ content: {
83
+ "application/json": import('../sdk/schema').components["schemas"]["WidgetPreludeDto"];
84
+ };
85
+ };
86
+ 500: {
87
+ headers: {
88
+ [name: string]: unknown;
89
+ };
90
+ content: {
91
+ "application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
92
+ };
93
+ };
94
+ };
95
+ }, {
96
+ params: {
97
+ header: {
98
+ "X-Bot-Token": string;
99
+ };
100
+ };
101
+ }, `${string}/${string}`>>;
102
+ handleMessage: (body: SendChatDto, abortSignal?: AbortSignal) => Promise<import('openapi-fetch').FetchResponse<{
103
+ parameters: {
104
+ query?: never;
105
+ header?: never;
106
+ path?: never;
107
+ cookie?: never;
108
+ };
109
+ requestBody: {
110
+ content: {
111
+ "application/json": import('../sdk/schema').components["schemas"]["HttpChatInputDto"];
112
+ };
113
+ };
114
+ responses: {
115
+ 200: {
116
+ headers: {
117
+ [name: string]: unknown;
118
+ };
119
+ content: {
120
+ "application/json": import('../sdk/schema').components["schemas"]["HandleContactMessageOutputDto"];
121
+ };
122
+ };
123
+ 500: {
124
+ headers: {
125
+ [name: string]: unknown;
126
+ };
127
+ content: {
128
+ "application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
129
+ };
130
+ };
131
+ };
132
+ }, {
133
+ body: {
134
+ uuid: string;
135
+ content: string;
136
+ session_id: string;
137
+ headers?: {
138
+ [key: string]: string;
139
+ } | null;
140
+ bot_token: string;
141
+ query_params?: {
142
+ [key: string]: string;
143
+ } | null;
144
+ user?: {
145
+ email?: string;
146
+ name?: string;
147
+ phone?: string;
148
+ avatar?: string;
149
+ customData?: {
150
+ [key: string]: string;
151
+ };
152
+ } | null;
153
+ language?: string | null;
154
+ attachments?: {
155
+ id: string;
34
156
  name: string;
35
- content?: string | undefined;
36
- request_response?: unknown;
37
- };
38
- } | undefined;
39
- sessionIsHandedOff?: boolean | undefined;
40
- } | {
41
- success: false;
42
- error: {
43
- code?: string | undefined;
44
- message?: string | undefined;
45
- };
46
- }>;
47
- getSessionHistory(sessionId: string, lastMessageTimestamp?: string): Promise<WidgetHistorySchema[]>;
48
- createSession(): Promise<WidgetSessionSchema>;
49
- getSession(sessionId: string): Promise<WidgetSessionSchema>;
157
+ size: number;
158
+ type: string;
159
+ url: string;
160
+ }[] | null;
161
+ };
162
+ signal: AbortSignal | undefined;
163
+ }, `${string}/${string}`>>;
164
+ getSessionHistory: (sessionId: string, lastMessageTimestamp?: string) => Promise<import('openapi-fetch').FetchResponse<{
165
+ parameters: {
166
+ query?: {
167
+ lastMessageTimestamp?: string;
168
+ };
169
+ header?: never;
170
+ path: {
171
+ sessionId: string;
172
+ };
173
+ cookie?: never;
174
+ };
175
+ requestBody?: never;
176
+ responses: {
177
+ 200: {
178
+ headers: {
179
+ [name: string]: unknown;
180
+ };
181
+ content: {
182
+ "application/json": import('../sdk/schema').components["schemas"]["WidgetHistoryDto"][];
183
+ };
184
+ };
185
+ 500: {
186
+ headers: {
187
+ [name: string]: unknown;
188
+ };
189
+ content: {
190
+ "application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
191
+ };
192
+ };
193
+ };
194
+ }, {
195
+ params: {
196
+ path: {
197
+ sessionId: string;
198
+ };
199
+ query: {
200
+ lastMessageTimestamp: string;
201
+ } | undefined;
202
+ };
203
+ }, `${string}/${string}`>>;
204
+ createContact: (body: Dto["CreateContactDto"]) => Promise<import('openapi-fetch').FetchResponse<{
205
+ parameters: {
206
+ query?: never;
207
+ header: {
208
+ "x-bot-token": string;
209
+ };
210
+ path?: never;
211
+ cookie?: never;
212
+ };
213
+ requestBody: {
214
+ content: {
215
+ "application/json": import('../sdk/schema').components["schemas"]["CreateContactDto"];
216
+ };
217
+ };
218
+ responses: {
219
+ 200: {
220
+ headers: {
221
+ [name: string]: unknown;
222
+ };
223
+ content: {
224
+ "application/json": import('../sdk/schema').components["schemas"]["WidgetContactDto"];
225
+ };
226
+ };
227
+ 500: {
228
+ headers: {
229
+ [name: string]: unknown;
230
+ };
231
+ content: {
232
+ "application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
233
+ };
234
+ };
235
+ };
236
+ }, {
237
+ params: {
238
+ header: {
239
+ "x-bot-token": string;
240
+ };
241
+ };
242
+ body: {
243
+ email: string;
244
+ name: string;
245
+ };
246
+ }, `${string}/${string}`>>;
247
+ createSession: () => Promise<import('openapi-fetch').FetchResponse<{
248
+ parameters: {
249
+ query?: never;
250
+ header?: never;
251
+ path?: never;
252
+ cookie?: never;
253
+ };
254
+ requestBody?: never;
255
+ responses: {
256
+ 200: {
257
+ headers: {
258
+ [name: string]: unknown;
259
+ };
260
+ content: {
261
+ "application/json": import('../sdk/schema').components["schemas"]["WidgetSessionDto"];
262
+ };
263
+ };
264
+ 500: {
265
+ headers: {
266
+ [name: string]: unknown;
267
+ };
268
+ content: {
269
+ "application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
270
+ };
271
+ };
272
+ };
273
+ }, import('openapi-fetch').FetchOptions<{
274
+ parameters: {
275
+ query?: never;
276
+ header?: never;
277
+ path?: never;
278
+ cookie?: never;
279
+ };
280
+ requestBody?: never;
281
+ responses: {
282
+ 200: {
283
+ headers: {
284
+ [name: string]: unknown;
285
+ };
286
+ content: {
287
+ "application/json": import('../sdk/schema').components["schemas"]["WidgetSessionDto"];
288
+ };
289
+ };
290
+ 500: {
291
+ headers: {
292
+ [name: string]: unknown;
293
+ };
294
+ content: {
295
+ "application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
296
+ };
297
+ };
298
+ };
299
+ }> | undefined, `${string}/${string}`>>;
300
+ getSession: (sessionId: string) => Promise<import('openapi-fetch').FetchResponse<{
301
+ parameters: {
302
+ query?: never;
303
+ header?: never;
304
+ path: {
305
+ sessionId: string;
306
+ };
307
+ cookie?: never;
308
+ };
309
+ requestBody?: never;
310
+ responses: {
311
+ 200: {
312
+ headers: {
313
+ [name: string]: unknown;
314
+ };
315
+ content: {
316
+ "application/json": import('../sdk/schema').components["schemas"]["WidgetSessionDto"];
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
+ path: {
331
+ sessionId: string;
332
+ };
333
+ };
334
+ }, `${string}/${string}`>>;
335
+ uploadFile: ({ file, abortSignal, }: {
336
+ file: {
337
+ id: string;
338
+ file: File;
339
+ };
340
+ abortSignal?: AbortSignal;
341
+ }) => Promise<import('openapi-fetch').FetchResponse<{
342
+ parameters: {
343
+ query: {
344
+ fileId: string;
345
+ sessionId: string;
346
+ };
347
+ header?: never;
348
+ path?: never;
349
+ cookie?: never;
350
+ };
351
+ requestBody: {
352
+ content: {
353
+ "multipart/form-data": import('../sdk/schema').components["schemas"]["FileUploadDto"];
354
+ };
355
+ };
356
+ responses: {
357
+ 200: {
358
+ headers: {
359
+ [name: string]: unknown;
360
+ };
361
+ content: {
362
+ "application/json": import('../sdk/schema').components["schemas"]["UploadWidgetFileDto"];
363
+ };
364
+ };
365
+ 500: {
366
+ headers: {
367
+ [name: string]: unknown;
368
+ };
369
+ content: {
370
+ "application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
371
+ };
372
+ };
373
+ };
374
+ }, {
375
+ params: {
376
+ query: {
377
+ fileId: string;
378
+ sessionId: string;
379
+ };
380
+ };
381
+ body: Dto["FileUploadDto"];
382
+ signal: AbortSignal | undefined;
383
+ headers: {
384
+ "Content-Type": string;
385
+ };
386
+ }, `${string}/${string}`>>;
387
+ vote: (body: WidgetVoteDto) => Promise<import('openapi-fetch').FetchResponse<{
388
+ parameters: {
389
+ query?: never;
390
+ header?: never;
391
+ path?: never;
392
+ cookie?: never;
393
+ };
394
+ requestBody: {
395
+ content: {
396
+ "application/json": import('../sdk/schema').components["schemas"]["WidgetVoteDto"];
397
+ };
398
+ };
399
+ responses: {
400
+ 200: {
401
+ headers: {
402
+ [name: string]: unknown;
403
+ };
404
+ content: {
405
+ "application/json": import('../sdk/schema').components["schemas"]["WidgetVoteResponseDto"];
406
+ };
407
+ };
408
+ 500: {
409
+ headers: {
410
+ [name: string]: unknown;
411
+ };
412
+ content: {
413
+ "application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
414
+ };
415
+ };
416
+ };
417
+ }, {
418
+ body: {
419
+ action: "upvote" | "downvote";
420
+ sessionId: string;
421
+ messagePublicId: string;
422
+ };
423
+ }, `${string}/${string}`>>;
50
424
  }
@@ -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 { HttpChatInputSchema } from '../types/schemas-v2';
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 = 'session' | 'messages';
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<Omit<HttpChatInputSchema, "bot_token">, "session_id" | "user">;
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: Date;
39
- updatedAt: Date;
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
- kind: "unknown" | "ai" | "none" | "human";
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,37 @@ export declare function createChat(options: ChatOptions): {
69
65
  }>;
70
66
  createSession: () => Promise<{
71
67
  id: string;
72
- createdAt: Date;
73
- updatedAt: Date;
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
- kind: "unknown" | "ai" | "none" | "human";
75
+ avatarUrl: string | null;
79
76
  };
80
77
  channel: string;
78
+ isVerified: boolean;
81
79
  } | null>;
82
80
  clearSession: () => Promise<void>;
83
- cleanup: (removeSession?: boolean) => void;
81
+ cleanup: () => void;
84
82
  initialState: ChatState;
85
83
  sessionStorageKey: string;
84
+ recreateSession: () => Promise<void>;
85
+ contactState: PubSub<{
86
+ contact: import('../types/contact').Contact | null;
87
+ loading: LoadingState;
88
+ error: ErrorState;
89
+ }>;
90
+ contactManager: {
91
+ shouldCollectData: () => {
92
+ should: boolean;
93
+ reason: string;
94
+ } | {
95
+ should: boolean;
96
+ reason?: undefined;
97
+ };
98
+ createUnauthenticatedContact: (payload: import('../sdk').Dto["CreateContactDto"]) => Promise<import('../sdk').Dto["WidgetContactDto"] | null>;
99
+ };
86
100
  };
87
101
  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 declare function createConfig(options: CoreOptions): ConfigInstance;
39
+ export type WidgetSettings = {
40
+ persistSession: boolean;
41
+ useSoundEffects: boolean;
42
+ };
43
+ export declare function createConfig(options: CoreOptions, platform: Platform): ConfigInstance;
@@ -3,31 +3,27 @@ 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';
6
+ import { Contact } from '../types/contact';
7
+ import { Dto } from '../sdk';
7
8
  type ContactState = {
8
- contact: ConsumerType | null;
9
+ contact: Contact | null;
9
10
  loading: LoadingState;
10
11
  error: ErrorState;
11
12
  };
12
13
  export type CreateContactOptions = {
13
14
  api: ApiCaller;
14
- platform: Platform;
15
15
  config: ConfigInstance;
16
16
  };
17
- export declare function createContact(options: CreateContactOptions): {
17
+ export declare function createContactHandler({ config, api }: CreateContactOptions, platform: Platform): {
18
18
  contactState: PubSub<ContactState>;
19
19
  shouldCollectData: () => {
20
20
  should: boolean;
21
- reason?: string;
21
+ reason: string;
22
+ } | {
23
+ should: boolean;
24
+ reason?: undefined;
22
25
  };
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
26
  cleanup: () => Promise<void>;
27
+ createUnauthenticatedContact: (payload: Dto["CreateContactDto"]) => Promise<Dto["WidgetContactDto"] | null>;
32
28
  };
33
29
  export {};
@@ -1,4 +1,4 @@
1
1
  export { createChat } from './chat';
2
- export { createContact } from './contact';
2
+ export { createContactHandler } from './contact';
3
3
  export { ApiCaller, type ApiCallerOptions } from './api';
4
4
  export { createConfig } from './config';
@@ -2,7 +2,7 @@ export * from './errors';
2
2
  export * from './types';
3
3
  export * from './platform';
4
4
  export { createChat } from './client/chat';
5
- export { createContact } from './client/contact';
5
+ export { createContactHandler } from './client/contact';
6
6
  export { createConfig } from './client/config';
7
7
  export { ApiCaller } from './client/api';
8
8
  export { createLogger } from './platform/logger';
@@ -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 {};
@@ -0,0 +1,2 @@
1
+ import { components } from '../sdk/schema';
2
+ export type Contact = components['schemas']['WidgetContactDto'];