@opencx/widget 2.6.2 → 3.0.0

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 (155) hide show
  1. package/dist/basic.cjs +89 -89
  2. package/dist/basic.cjs.map +1 -1
  3. package/dist/basic.d.ts +1 -1
  4. package/dist/basic.js +34083 -34125
  5. package/dist/basic.js.map +1 -1
  6. package/dist/index.cjs +1 -1
  7. package/dist/index.d.ts +1 -1
  8. package/dist/index.js +3 -22
  9. package/dist/react.cjs +1 -1
  10. package/dist/react.cjs.map +1 -1
  11. package/dist/react.d.ts +1 -1
  12. package/dist/react.js +20 -10
  13. package/dist/react.js.map +1 -1
  14. package/dist/src/designs/react/basic/index.d.ts +10 -0
  15. package/dist/src/designs/{basic → react/basic}/utils/group-messages-by-type.d.ts +1 -1
  16. package/dist/src/{@components → designs/react/components}/BotOrAgentMessage.d.ts +1 -1
  17. package/dist/src/{@components → designs/react/components}/BotOrAgentMessageGroup.d.ts +2 -2
  18. package/dist/src/designs/react/components/BotOrAgentMessageWrapper.d.ts +7 -0
  19. package/dist/src/{@components → designs/react/components}/Fallback.component.d.ts +2 -2
  20. package/dist/src/{components → designs/react/components}/RenderFile.d.ts +2 -2
  21. package/dist/src/{@components → designs/react/components}/Text.component.d.ts +1 -1
  22. package/dist/src/{components → designs/react/components}/UserMessageGroup.d.ts +1 -1
  23. package/dist/src/{components → designs/react/components}/VoteButtons.d.ts +1 -1
  24. package/dist/src/designs/{constants.d.ts → react/constants.d.ts} +2 -4
  25. package/dist/src/designs/react/hooks/useLocale.d.ts +6 -0
  26. package/dist/src/{index.d.ts → designs/react/index.d.ts} +2 -2
  27. package/dist/src/designs/translation/ar.locale.d.ts +2 -0
  28. package/dist/src/designs/translation/de.locale.d.ts +2 -0
  29. package/dist/src/designs/translation/en.locale.d.ts +2 -0
  30. package/dist/src/designs/translation/fr.locale.d.ts +2 -0
  31. package/dist/src/designs/translation/index.d.ts +14 -0
  32. package/dist/src/designs/translation/nl.locale.d.ts +2 -0
  33. package/dist/src/designs/translation/pt.locale.d.ts +2 -0
  34. package/dist/src/designs/translation/translation.types.d.ts +4 -0
  35. package/dist/{core/client → src/headless/core}/api.d.ts +56 -143
  36. package/dist/src/headless/core/context/contact.d.ts +25 -0
  37. package/dist/src/headless/core/context/message.d.ts +40 -0
  38. package/dist/src/headless/core/context/session.d.ts +74 -0
  39. package/dist/src/headless/core/context/widget.d.ts +16 -0
  40. package/dist/src/headless/core/index.d.ts +7 -0
  41. package/dist/{core → src/headless/core}/sdk/index.d.ts +5 -4
  42. package/dist/src/headless/core/types/WidgetConfig.d.ts +34 -0
  43. package/dist/src/headless/core/types/agent-or-bot.d.ts +6 -0
  44. package/dist/src/headless/core/types/helpers.d.ts +4 -0
  45. package/dist/{core → src/headless/core}/types/messages.d.ts +11 -31
  46. package/dist/src/headless/core/types/schemas.d.ts +9 -0
  47. package/dist/src/headless/core/utils/Poller.d.ts +12 -0
  48. package/dist/{core/types/pub-sub.d.ts → src/headless/core/utils/PubSub.d.ts} +6 -9
  49. package/dist/{react-web/core-integration/components.d.ts → src/headless/react/ComponentRegistry.d.ts} +1 -1
  50. package/dist/src/headless/react/WidgetProvider.d.ts +17 -0
  51. package/dist/src/headless/react/hooks/useConfig.d.ts +1 -0
  52. package/dist/src/headless/react/hooks/useContact.d.ts +10 -0
  53. package/dist/src/headless/react/hooks/useIsAwaitingBotReply.d.ts +3 -0
  54. package/dist/src/headless/react/hooks/useMessages.d.ts +8 -0
  55. package/dist/{react-web/core-integration → src/headless/react}/hooks/usePreludeData.d.ts +2 -2
  56. package/dist/{react-web/core-integration → src/headless/react}/hooks/usePubsub.d.ts +1 -1
  57. package/dist/src/headless/react/hooks/useSession.d.ts +6 -0
  58. package/dist/{react-web/core-integration → src/headless/react}/hooks/useUploadFiles.d.ts +1 -1
  59. package/dist/{react-web/core-integration → src/headless/react}/hooks/useVote.d.ts +2 -2
  60. package/dist/src/headless/react/index.d.ts +11 -0
  61. package/dist/src/headless/react/types/components.d.ts +15 -0
  62. package/dist/style.css +1 -1
  63. package/dist/useUploadFiles-BZa0DENN.cjs +18 -0
  64. package/dist/useUploadFiles-BZa0DENN.cjs.map +1 -0
  65. package/dist/useUploadFiles-BaCcqTwX.js +1336 -0
  66. package/dist/useUploadFiles-BaCcqTwX.js.map +1 -0
  67. package/dist/widget-BlvH6dre.cjs +2 -0
  68. package/dist/widget-BlvH6dre.cjs.map +1 -0
  69. package/dist/widget-DbgWez1r.js +514 -0
  70. package/dist/widget-DbgWez1r.js.map +1 -0
  71. package/dist-embed/script.js +127 -142
  72. package/dist-embed/script.js.map +1 -1
  73. package/package.json +12 -8
  74. package/dist/api-BEtFfKMB.cjs +0 -2
  75. package/dist/api-BEtFfKMB.cjs.map +0 -1
  76. package/dist/api-Cez5T-se.js +0 -1393
  77. package/dist/api-Cez5T-se.js.map +0 -1
  78. package/dist/core/client/chat.d.ts +0 -101
  79. package/dist/core/client/config.d.ts +0 -43
  80. package/dist/core/client/contact.d.ts +0 -29
  81. package/dist/core/client/index.d.ts +0 -4
  82. package/dist/core/errors/index.d.ts +0 -27
  83. package/dist/core/index.d.ts +0 -9
  84. package/dist/core/platform/audio.d.ts +0 -38
  85. package/dist/core/platform/index.d.ts +0 -15
  86. package/dist/core/platform/logger.d.ts +0 -14
  87. package/dist/core/platform/storage.d.ts +0 -52
  88. package/dist/core/tests/platform/logger.test.d.ts +0 -1
  89. package/dist/core/tests/platform/storage.test.d.ts +0 -1
  90. package/dist/core/tests/test-utils.d.ts +0 -2
  91. package/dist/core/tests/types/pub-sub.test.d.ts +0 -1
  92. package/dist/core/types/contact.d.ts +0 -2
  93. package/dist/core/types/helpers.d.ts +0 -20
  94. package/dist/core/types/index.d.ts +0 -52
  95. package/dist/core/types/prelude.d.ts +0 -14
  96. package/dist/core/types/schemas-v2.d.ts +0 -10
  97. package/dist/index-BzidnDPX.cjs +0 -18
  98. package/dist/index-BzidnDPX.cjs.map +0 -1
  99. package/dist/index-DUlnC30_.js +0 -1219
  100. package/dist/index-DUlnC30_.js.map +0 -1
  101. package/dist/react-web/core-integration/ChatProvider.d.ts +0 -107
  102. package/dist/react-web/core-integration/hooks/useChatMessages.d.ts +0 -70
  103. package/dist/react-web/core-integration/hooks/useChatSession.d.ts +0 -83
  104. package/dist/react-web/core-integration/hooks/useConfig.d.ts +0 -1
  105. package/dist/react-web/core-integration/hooks/useContact.d.ts +0 -17
  106. package/dist/react-web/core-integration/hooks/useLocale.d.ts +0 -4
  107. package/dist/react-web/core-integration/hooks.d.ts +0 -9
  108. package/dist/react-web/core-integration/index.d.ts +0 -2
  109. package/dist/react-web/core-integration/locales/ar.locale.d.ts +0 -2
  110. package/dist/react-web/core-integration/locales/de.locale.d.ts +0 -2
  111. package/dist/react-web/core-integration/locales/en.locale.d.ts +0 -55
  112. package/dist/react-web/core-integration/locales/fr.locale.d.ts +0 -2
  113. package/dist/react-web/core-integration/locales/helper.d.ts +0 -65
  114. package/dist/react-web/core-integration/locales/index.d.ts +0 -3
  115. package/dist/react-web/core-integration/locales/nl.locale.d.ts +0 -2
  116. package/dist/react-web/core-integration/locales/pt.locale.d.ts +0 -2
  117. package/dist/react-web/hooks/useScrollTo.d.ts +0 -2
  118. package/dist/react-web/index.d.ts +0 -4
  119. package/dist/react-web/types/components.d.ts +0 -13
  120. package/dist/react-web/types/index.d.ts +0 -8
  121. package/dist/react-web/types/options.d.ts +0 -17
  122. package/dist/src/@components/BotOrAgentMessageWrapper.d.ts +0 -9
  123. package/dist/src/@components/ChatEvent.component.d.ts +0 -9
  124. package/dist/src/@components/index.d.ts +0 -6
  125. package/dist/src/designs/basic/index.d.ts +0 -8
  126. /package/dist/src/designs/{basic → react/basic}/WidgetPopoverTrigger.d.ts +0 -0
  127. /package/dist/src/designs/{basic → react/basic}/screens/chat-screen/ChatFooter.d.ts +0 -0
  128. /package/dist/src/designs/{basic → react/basic}/screens/chat-screen/ChatHeader.d.ts +0 -0
  129. /package/dist/src/designs/{basic → react/basic}/screens/chat-screen/ChatMain.d.ts +0 -0
  130. /package/dist/src/designs/{basic → react/basic}/screens/chat-screen/ChatScreen.d.ts +0 -0
  131. /package/dist/src/designs/{basic → react/basic}/screens/root-screen.d.ts +0 -0
  132. /package/dist/src/designs/{basic → react/basic}/screens/welcome-screen/WelcomeScreen.d.ts +0 -0
  133. /package/dist/{core/tests/client/integration-perisitance.test.d.ts → src/designs/react/basic/widget-interaction-tests/widget.test.d.ts} +0 -0
  134. /package/dist/src/{@components → designs/react/components}/Loading.component.d.ts +0 -0
  135. /package/dist/src/{@components → designs/react/components}/OpenLogoSvg.d.ts +0 -0
  136. /package/dist/src/{components → designs/react/components}/keyboard.d.ts +0 -0
  137. /package/dist/src/{components → designs/react/components/lib}/MotionDiv.d.ts +0 -0
  138. /package/dist/src/{components → designs/react/components/lib}/avatar.d.ts +0 -0
  139. /package/dist/src/{components → designs/react/components/lib}/button.d.ts +0 -0
  140. /package/dist/src/{components → designs/react/components/lib}/dialog.d.ts +0 -0
  141. /package/dist/src/{components → designs/react/components/lib}/dropdown-menu.d.ts +0 -0
  142. /package/dist/src/{components → designs/react/components/lib}/input.d.ts +0 -0
  143. /package/dist/src/{components → designs/react/components/lib}/popover.d.ts +0 -0
  144. /package/dist/src/{components → designs/react/components/lib}/skeleton.d.ts +0 -0
  145. /package/dist/src/{components → designs/react/components/lib}/switch.d.ts +0 -0
  146. /package/dist/src/{components → designs/react/components/lib}/tooltip.d.ts +0 -0
  147. /package/dist/src/{utils.d.ts → designs/react/components/lib/utils/cn.d.ts} +0 -0
  148. /package/dist/src/{components → designs/react/components/lib}/wobble.d.ts +0 -0
  149. /package/dist/src/{@components → designs/react/components}/markdown.d.ts +0 -0
  150. /package/dist/{react-web → src/designs/react}/hooks/useWidgetContentHeight.d.ts +0 -0
  151. /package/dist/src/{render.d.ts → designs/react/render.d.ts} +0 -0
  152. /package/dist/{core/tests/client/integration.test.d.ts → src/headless/core/utils/PubSub.test.d.ts} +0 -0
  153. /package/dist/{core/utils/genUuid.d.ts → src/headless/core/utils/uuid.d.ts} +0 -0
  154. /package/dist/{react-web → src/headless/react}/utils/create-safe-context.d.ts +0 -0
  155. /package/dist/{core/tests/platform/audio.test.d.ts → vitest/setup.d.ts} +0 -0
@@ -1,69 +1,18 @@
1
- import { User } from '../types';
2
- import { SendChatDto, WidgetVoteDto } from '../types/schemas-v2';
3
- import { NormalizedConfig } from './config';
4
- import { Dto } from '../sdk';
5
- export interface ApiCallerOptions {
6
- config: NormalizedConfig;
7
- }
1
+ import { AxiosRequestConfig } from 'axios';
2
+ import { Dto } from './sdk';
3
+ import { WidgetConfig } from './types/WidgetConfig';
4
+ import { SendMessageDto, VoteInputDto } from './types/schemas';
8
5
  export declare class ApiCaller {
9
- #private;
10
- private readonly options;
11
- constructor(options: ApiCallerOptions);
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}`>>;
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;
67
16
  widgetPrelude: () => Promise<import('openapi-fetch').FetchResponse<{
68
17
  parameters: {
69
18
  query?: never;
@@ -80,7 +29,7 @@ export declare class ApiCaller {
80
29
  [name: string]: unknown;
81
30
  };
82
31
  content: {
83
- "application/json": import('../sdk/schema').components["schemas"]["WidgetPreludeDto"];
32
+ "application/json": import('./sdk/schema').components["schemas"]["WidgetPreludeDto"];
84
33
  };
85
34
  };
86
35
  500: {
@@ -88,7 +37,7 @@ export declare class ApiCaller {
88
37
  [name: string]: unknown;
89
38
  };
90
39
  content: {
91
- "application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
40
+ "application/json": import('./sdk/schema').components["schemas"]["ErrorDto"];
92
41
  };
93
42
  };
94
43
  };
@@ -99,7 +48,7 @@ export declare class ApiCaller {
99
48
  };
100
49
  };
101
50
  }, `${string}/${string}`>>;
102
- handleMessage: (body: SendChatDto, abortSignal?: AbortSignal) => Promise<import('openapi-fetch').FetchResponse<{
51
+ sendMessage: (body: SendMessageDto, abortSignal?: AbortSignal) => Promise<import('openapi-fetch').FetchResponse<{
103
52
  parameters: {
104
53
  query?: never;
105
54
  header?: never;
@@ -108,7 +57,7 @@ export declare class ApiCaller {
108
57
  };
109
58
  requestBody: {
110
59
  content: {
111
- "application/json": import('../sdk/schema').components["schemas"]["HttpChatInputDto"];
60
+ "application/json": import('./sdk/schema').components["schemas"]["HttpChatInputDto"];
112
61
  };
113
62
  };
114
63
  responses: {
@@ -117,7 +66,7 @@ export declare class ApiCaller {
117
66
  [name: string]: unknown;
118
67
  };
119
68
  content: {
120
- "application/json": import('../sdk/schema').components["schemas"]["HandleContactMessageOutputDto"];
69
+ "application/json": import('./sdk/schema').components["schemas"]["HandleContactMessageOutputDto"];
121
70
  };
122
71
  };
123
72
  500: {
@@ -125,7 +74,7 @@ export declare class ApiCaller {
125
74
  [name: string]: unknown;
126
75
  };
127
76
  content: {
128
- "application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
77
+ "application/json": import('./sdk/schema').components["schemas"]["ErrorDto"];
129
78
  };
130
79
  };
131
80
  };
@@ -161,7 +110,11 @@ export declare class ApiCaller {
161
110
  };
162
111
  signal: AbortSignal | undefined;
163
112
  }, `${string}/${string}`>>;
164
- getSessionHistory: (sessionId: string, lastMessageTimestamp?: string) => Promise<import('openapi-fetch').FetchResponse<{
113
+ getSessionHistory: ({ sessionId, lastMessageTimestamp, abortSignal, }: {
114
+ sessionId: string;
115
+ lastMessageTimestamp?: string;
116
+ abortSignal: AbortSignal;
117
+ }) => Promise<import('openapi-fetch').FetchResponse<{
165
118
  parameters: {
166
119
  query?: {
167
120
  lastMessageTimestamp?: string;
@@ -179,7 +132,7 @@ export declare class ApiCaller {
179
132
  [name: string]: unknown;
180
133
  };
181
134
  content: {
182
- "application/json": import('../sdk/schema').components["schemas"]["WidgetHistoryDto"][];
135
+ "application/json": import('./sdk/schema').components["schemas"]["WidgetHistoryDto"][];
183
136
  };
184
137
  };
185
138
  500: {
@@ -187,7 +140,7 @@ export declare class ApiCaller {
187
140
  [name: string]: unknown;
188
141
  };
189
142
  content: {
190
- "application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
143
+ "application/json": import('./sdk/schema').components["schemas"]["ErrorDto"];
191
144
  };
192
145
  };
193
146
  };
@@ -200,8 +153,9 @@ export declare class ApiCaller {
200
153
  lastMessageTimestamp: string;
201
154
  } | undefined;
202
155
  };
156
+ signal: AbortSignal;
203
157
  }, `${string}/${string}`>>;
204
- createContact: (body: Dto["CreateContactDto"]) => Promise<import('openapi-fetch').FetchResponse<{
158
+ createUnverifiedContact: (body: Dto["CreateUnverifiedContactDto"]) => Promise<import('openapi-fetch').FetchResponse<{
205
159
  parameters: {
206
160
  query?: never;
207
161
  header: {
@@ -212,7 +166,7 @@ export declare class ApiCaller {
212
166
  };
213
167
  requestBody: {
214
168
  content: {
215
- "application/json": import('../sdk/schema').components["schemas"]["CreateContactDto"];
169
+ "application/json": import('./sdk/schema').components["schemas"]["CreateUnverifiedContactDto"];
216
170
  };
217
171
  };
218
172
  responses: {
@@ -221,7 +175,7 @@ export declare class ApiCaller {
221
175
  [name: string]: unknown;
222
176
  };
223
177
  content: {
224
- "application/json": import('../sdk/schema').components["schemas"]["WidgetContactDto"];
178
+ "application/json": import('./sdk/schema').components["schemas"]["WidgetContactTokenResponseDto"];
225
179
  };
226
180
  };
227
181
  500: {
@@ -229,7 +183,7 @@ export declare class ApiCaller {
229
183
  [name: string]: unknown;
230
184
  };
231
185
  content: {
232
- "application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
186
+ "application/json": import('./sdk/schema').components["schemas"]["ErrorDto"];
233
187
  };
234
188
  };
235
189
  };
@@ -240,8 +194,8 @@ export declare class ApiCaller {
240
194
  };
241
195
  };
242
196
  body: {
243
- email: string;
244
- name: string;
197
+ email?: string;
198
+ name?: string;
245
199
  };
246
200
  }, `${string}/${string}`>>;
247
201
  createSession: () => Promise<import('openapi-fetch').FetchResponse<{
@@ -258,7 +212,7 @@ export declare class ApiCaller {
258
212
  [name: string]: unknown;
259
213
  };
260
214
  content: {
261
- "application/json": import('../sdk/schema').components["schemas"]["WidgetSessionDto"];
215
+ "application/json": import('./sdk/schema').components["schemas"]["WidgetSessionDto"];
262
216
  };
263
217
  };
264
218
  500: {
@@ -266,7 +220,7 @@ export declare class ApiCaller {
266
220
  [name: string]: unknown;
267
221
  };
268
222
  content: {
269
- "application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
223
+ "application/json": import('./sdk/schema').components["schemas"]["ErrorDto"];
270
224
  };
271
225
  };
272
226
  };
@@ -284,7 +238,7 @@ export declare class ApiCaller {
284
238
  [name: string]: unknown;
285
239
  };
286
240
  content: {
287
- "application/json": import('../sdk/schema').components["schemas"]["WidgetSessionDto"];
241
+ "application/json": import('./sdk/schema').components["schemas"]["WidgetSessionDto"];
288
242
  };
289
243
  };
290
244
  500: {
@@ -292,12 +246,15 @@ export declare class ApiCaller {
292
246
  [name: string]: unknown;
293
247
  };
294
248
  content: {
295
- "application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
249
+ "application/json": import('./sdk/schema').components["schemas"]["ErrorDto"];
296
250
  };
297
251
  };
298
252
  };
299
253
  }> | undefined, `${string}/${string}`>>;
300
- getSession: (sessionId: string) => Promise<import('openapi-fetch').FetchResponse<{
254
+ getSession: ({ sessionId, abortSignal, }: {
255
+ sessionId: string;
256
+ abortSignal: AbortSignal;
257
+ }) => Promise<import('openapi-fetch').FetchResponse<{
301
258
  parameters: {
302
259
  query?: never;
303
260
  header?: never;
@@ -313,7 +270,7 @@ export declare class ApiCaller {
313
270
  [name: string]: unknown;
314
271
  };
315
272
  content: {
316
- "application/json": import('../sdk/schema').components["schemas"]["WidgetSessionDto"];
273
+ "application/json": import('./sdk/schema').components["schemas"]["WidgetSessionDto"];
317
274
  };
318
275
  };
319
276
  500: {
@@ -321,7 +278,7 @@ export declare class ApiCaller {
321
278
  [name: string]: unknown;
322
279
  };
323
280
  content: {
324
- "application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
281
+ "application/json": import('./sdk/schema').components["schemas"]["ErrorDto"];
325
282
  };
326
283
  };
327
284
  };
@@ -331,60 +288,16 @@ export declare class ApiCaller {
331
288
  sessionId: string;
332
289
  };
333
290
  };
291
+ signal: AbortSignal;
334
292
  }, `${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<{
293
+ uploadFile: (file: {
294
+ id: string;
295
+ file: File;
296
+ }, config?: Partial<AxiosRequestConfig>) => Promise<{
297
+ fileName: string;
298
+ fileUrl: string;
299
+ }>;
300
+ vote: (body: VoteInputDto) => Promise<import('openapi-fetch').FetchResponse<{
388
301
  parameters: {
389
302
  query?: never;
390
303
  header?: never;
@@ -393,7 +306,7 @@ export declare class ApiCaller {
393
306
  };
394
307
  requestBody: {
395
308
  content: {
396
- "application/json": import('../sdk/schema').components["schemas"]["WidgetVoteDto"];
309
+ "application/json": import('./sdk/schema').components["schemas"]["WidgetVoteDto"];
397
310
  };
398
311
  };
399
312
  responses: {
@@ -402,7 +315,7 @@ export declare class ApiCaller {
402
315
  [name: string]: unknown;
403
316
  };
404
317
  content: {
405
- "application/json": import('../sdk/schema').components["schemas"]["WidgetVoteResponseDto"];
318
+ "application/json": import('./sdk/schema').components["schemas"]["WidgetVoteResponseDto"];
406
319
  };
407
320
  };
408
321
  500: {
@@ -410,7 +323,7 @@ export declare class ApiCaller {
410
323
  [name: string]: unknown;
411
324
  };
412
325
  content: {
413
- "application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
326
+ "application/json": import('./sdk/schema').components["schemas"]["ErrorDto"];
414
327
  };
415
328
  };
416
329
  };
@@ -0,0 +1,25 @@
1
+ import { PubSub } from '../utils/PubSub';
2
+ import { ApiCaller } from '../api';
3
+ import { Dto } from 'src/headless/core/sdk';
4
+ import { WidgetConfig } from 'src/headless/core/types/WidgetConfig';
5
+ type ContactState = {
6
+ contact: {
7
+ token: string;
8
+ } | null;
9
+ isCreatingUnverifiedContact: boolean;
10
+ isErrorCreatingUnverifiedContact: boolean;
11
+ };
12
+ export type CreateContactHandlerOptions = {
13
+ api: ApiCaller;
14
+ config: WidgetConfig;
15
+ };
16
+ export declare class ContactCtx {
17
+ private config;
18
+ private api;
19
+ state: PubSub<ContactState>;
20
+ constructor({ config, api }: CreateContactHandlerOptions);
21
+ shouldCollectData: () => boolean;
22
+ autoCreateUnverifiedUser: () => Promise<void>;
23
+ createUnverifiedContact: (payload: Dto["CreateUnverifiedContactDto"]) => Promise<void>;
24
+ }
25
+ export {};
@@ -0,0 +1,40 @@
1
+ import { MessageAttachmentType, SendMessageOutputDto, MessageDto, SomeOptional, SafeOmit, SendMessageDto, WidgetConfig } from 'src/headless/core';
2
+ import { BotMessageType, MessageType, UserMessageType } from 'src/headless/core/types/messages';
3
+ import { ApiCaller } from '../api';
4
+ import { SessionCtx } from './session';
5
+ import { PubSub } from 'src/headless/core/utils/PubSub';
6
+ export declare class MessageCtx {
7
+ private config;
8
+ private api;
9
+ private sessionCtx;
10
+ private poller;
11
+ state: PubSub<{
12
+ messages: MessageType[];
13
+ isSendingMessage: boolean;
14
+ suggestedReplies: string[] | null;
15
+ }>;
16
+ private sendMessageAbortController;
17
+ constructor({ config, api, sessionCtx, }: {
18
+ config: WidgetConfig;
19
+ api: ApiCaller;
20
+ sessionCtx: SessionCtx;
21
+ });
22
+ reset: () => void;
23
+ registerPolling: () => void;
24
+ sendMessage: (input: SomeOptional<SafeOmit<SendMessageDto, "bot_token" | "uuid">, "session_id" | "user">) => Promise<void>;
25
+ fetchAndSetHistory: (sessionId: string, abortSignal: AbortSignal) => Promise<void>;
26
+ /** Not the best name but whatever */
27
+ static mapHistoryToMessage(history: MessageDto): MessageType;
28
+ static toUserMessage(content: string, attachments?: MessageAttachmentType[]): UserMessageType;
29
+ static toBotMessage(response: SendMessageOutputDto): BotMessageType | null;
30
+ static toErrorMessage(message: string): {
31
+ type: "FROM_BOT";
32
+ id: string;
33
+ timestamp: string;
34
+ component: string;
35
+ data: {
36
+ message: string;
37
+ variant: string;
38
+ };
39
+ };
40
+ }
@@ -0,0 +1,74 @@
1
+ import { ApiCaller } from 'src/headless/core/api';
2
+ import { SessionDto } from 'src/headless/core';
3
+ import { PubSub } from 'src/headless/core/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 { WidgetConfig } from 'src/headless/core/types/WidgetConfig';
2
+ import { ApiCaller } from '../api';
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,7 @@
1
+ export * from './types/agent-or-bot';
2
+ export * from './types/helpers';
3
+ export * from './types/messages';
4
+ export * from './types/schemas';
5
+ export * from './types/WidgetConfig';
6
+ export { WidgetCtx } from './context/widget';
7
+ export { PubSub } from './utils/PubSub';
@@ -2,10 +2,11 @@ import { Middleware } from 'openapi-fetch';
2
2
  import { paths, components } from './schema';
3
3
  type Options = {
4
4
  baseUrl: string;
5
- onRequest?: Middleware['onRequest'];
6
- onResponse?: Middleware['onResponse'];
7
- onError?: Middleware['onError'];
5
+ onRequest?: Middleware["onRequest"];
6
+ onResponse?: Middleware["onResponse"];
7
+ onError?: Middleware["onError"];
8
8
  };
9
9
  export declare const basicClient: (options: Options) => import('openapi-fetch').Client<paths, `${string}/${string}`>;
10
- export type Dto = components['schemas'];
10
+ export type Endpoint = keyof paths;
11
+ export type Dto = components["schemas"];
11
12
  export {};
@@ -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
+ }
@@ -0,0 +1,6 @@
1
+ export type AgentOrBotType = {
2
+ isAi: boolean;
3
+ id: string | null;
4
+ name: string;
5
+ avatar: string | null;
6
+ };
@@ -0,0 +1,4 @@
1
+ export type SomeOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
2
+ export type SafeOmit<T, K extends keyof T> = Omit<T, K>;
3
+ export type SafeExtract<T, K extends T> = Extract<T, K>;
4
+ export type StringOrLiteral<T extends string> = T | (string & {});
@@ -1,18 +1,13 @@
1
- import { DefaultTextComponentBaseProps, WidgetLiteralComponentKey } from '../../react-web/types';
2
- import { ChatAttachmentType, WidgetHistoryDto } from './schemas-v2';
1
+ import { MessageAttachmentType, MessageDto } from './schemas';
3
2
  import { SafeExtract, StringOrLiteral } from './helpers';
4
- export type AgentType = {
5
- isAi: boolean;
6
- id: string | null;
7
- name: string;
8
- avatar: string | null;
9
- };
3
+ import { AgentOrBotType } from './agent-or-bot';
4
+ import { DefaultTextComponentBaseProps, WidgetLiteralComponentKey } from 'src/headless/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?: ChatAttachmentType[] | null;
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?: WidgetHistoryDto;
35
- agent?: AgentType;
36
- attachments?: ChatAttachmentType[];
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?: WidgetHistoryDto;
45
- agent?: AgentType;
46
- attachments?: ChatAttachmentType[];
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
- }