@opencx/widget 3.0.39 → 3.0.41

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.
@@ -92,7 +92,7 @@ export declare class ApiCaller {
92
92
  };
93
93
  requestBody: {
94
94
  content: {
95
- "application/json": import('./schema').components["schemas"]["HttpChatInputDto"];
95
+ "application/json": import('./schema').components["schemas"]["SendWidgetMessageDto"];
96
96
  };
97
97
  };
98
98
  responses: {
@@ -145,51 +145,6 @@ export declare class ApiCaller {
145
145
  };
146
146
  signal: AbortSignal | undefined;
147
147
  }, `${string}/${string}`>>;
148
- getSessionHistory: ({ sessionId, lastMessageTimestamp, abortSignal, }: {
149
- sessionId: string;
150
- lastMessageTimestamp?: string;
151
- abortSignal: AbortSignal;
152
- }) => Promise<import('openapi-fetch').FetchResponse<{
153
- parameters: {
154
- query?: {
155
- lastMessageTimestamp?: string;
156
- };
157
- header?: never;
158
- path: {
159
- sessionId: string;
160
- };
161
- cookie?: never;
162
- };
163
- requestBody?: never;
164
- responses: {
165
- 200: {
166
- headers: {
167
- [name: string]: unknown;
168
- };
169
- content: {
170
- "application/json": import('./schema').components["schemas"]["WidgetHistoryDto"][];
171
- };
172
- };
173
- 500: {
174
- headers: {
175
- [name: string]: unknown;
176
- };
177
- content: {
178
- "application/json": import('./schema').components["schemas"]["ErrorDto"];
179
- };
180
- };
181
- };
182
- }, {
183
- params: {
184
- path: {
185
- sessionId: string;
186
- };
187
- query: {
188
- lastMessageTimestamp: string;
189
- } | undefined;
190
- };
191
- signal: AbortSignal;
192
- }, `${string}/${string}`>>;
193
148
  createUnverifiedContact: (body: Dto["CreateUnverifiedContactDto"]) => Promise<import('openapi-fetch').FetchResponse<{
194
149
  parameters: {
195
150
  query?: never;
@@ -233,7 +188,7 @@ export declare class ApiCaller {
233
188
  name?: string;
234
189
  };
235
190
  }, `${string}/${string}`>>;
236
- createSession: (body: Dto["CreateWidgetChatSessionDto"]) => Promise<import('openapi-fetch').FetchResponse<{
191
+ createSession: (body: Dto["CreateWidgetSessionDto"]) => Promise<import('openapi-fetch').FetchResponse<{
237
192
  parameters: {
238
193
  query?: never;
239
194
  header?: never;
@@ -242,7 +197,7 @@ export declare class ApiCaller {
242
197
  };
243
198
  requestBody: {
244
199
  content: {
245
- "application/json": import('./schema').components["schemas"]["CreateWidgetChatSessionDto"];
200
+ "application/json": import('./schema').components["schemas"]["CreateWidgetSessionDto"];
246
201
  };
247
202
  };
248
203
  responses: {
@@ -270,12 +225,15 @@ export declare class ApiCaller {
270
225
  };
271
226
  };
272
227
  }, `${string}/${string}`>>;
273
- getSession: ({ sessionId, abortSignal, }: {
228
+ pollSessionAndHistory: ({ sessionId, lastMessageTimestamp, abortSignal, }: {
274
229
  sessionId: string;
230
+ lastMessageTimestamp?: string;
275
231
  abortSignal: AbortSignal;
276
232
  }) => Promise<import('openapi-fetch').FetchResponse<{
277
233
  parameters: {
278
- query?: never;
234
+ query?: {
235
+ lastMessageTimestamp?: string;
236
+ };
279
237
  header?: never;
280
238
  path: {
281
239
  sessionId: string;
@@ -289,7 +247,7 @@ export declare class ApiCaller {
289
247
  [name: string]: unknown;
290
248
  };
291
249
  content: {
292
- "application/json": import('./schema').components["schemas"]["WidgetSessionDto"];
250
+ "application/json": import('./schema').components["schemas"]["WidgetSessionAndHistoryDto"];
293
251
  };
294
252
  };
295
253
  500: {
@@ -306,6 +264,9 @@ export declare class ApiCaller {
306
264
  path: {
307
265
  sessionId: string;
308
266
  };
267
+ query: {
268
+ lastMessageTimestamp: string;
269
+ } | undefined;
309
270
  };
310
271
  signal: AbortSignal;
311
272
  }, `${string}/${string}`>>;
@@ -83,6 +83,22 @@ export interface paths {
83
83
  patch?: never;
84
84
  trace?: never;
85
85
  };
86
+ "/backend/widget/v2/poll/{sessionId}": {
87
+ parameters: {
88
+ query?: never;
89
+ header?: never;
90
+ path?: never;
91
+ cookie?: never;
92
+ };
93
+ get: operations["pollSessionAndHistory"];
94
+ put?: never;
95
+ post?: never;
96
+ delete?: never;
97
+ options?: never;
98
+ head?: never;
99
+ patch?: never;
100
+ trace?: never;
101
+ };
86
102
  "/backend/widget/v2/create-session": {
87
103
  parameters: {
88
104
  query?: never;
@@ -171,7 +187,7 @@ export interface components {
171
187
  email?: string;
172
188
  name?: string;
173
189
  };
174
- CreateWidgetChatSessionDto: {
190
+ CreateWidgetSessionDto: {
175
191
  customData?: {
176
192
  [key: string]: string | number | boolean | unknown | unknown;
177
193
  };
@@ -215,7 +231,29 @@ export interface components {
215
231
  message?: string;
216
232
  };
217
233
  };
218
- HttpChatInputDto: {
234
+ /** @description Paginated response. */
235
+ PaginatedWidgetSessionsDto: {
236
+ items: {
237
+ /** Format: uuid */
238
+ id: string;
239
+ createdAt: string;
240
+ updatedAt: string;
241
+ isHandedOff: boolean;
242
+ isOpened: boolean;
243
+ assignee: {
244
+ /** @enum {string} */
245
+ kind: "human" | "ai" | "none" | "unknown";
246
+ name: string | null;
247
+ avatarUrl: string | null;
248
+ };
249
+ channel: string;
250
+ isVerified: boolean;
251
+ lastMessage: string | null;
252
+ }[];
253
+ /** @description The `cursor` for the request to get the next set of items. Null if there is no more data. */
254
+ next: string | null;
255
+ };
256
+ SendWidgetMessageDto: {
219
257
  /** Format: uuid */
220
258
  uuid: string;
221
259
  content: string;
@@ -245,28 +283,6 @@ export interface components {
245
283
  url: string;
246
284
  }[] | null;
247
285
  };
248
- /** @description Paginated response. */
249
- PaginatedWidgetSessionsDto: {
250
- items: {
251
- /** Format: uuid */
252
- id: string;
253
- createdAt: string;
254
- updatedAt: string;
255
- isHandedOff: boolean;
256
- isOpened: boolean;
257
- assignee: {
258
- /** @enum {string} */
259
- kind: "human" | "ai" | "none" | "unknown";
260
- name: string | null;
261
- avatarUrl: string | null;
262
- };
263
- channel: string;
264
- isVerified: boolean;
265
- lastMessage: string | null;
266
- }[];
267
- /** @description The `cursor` for the request to get the next set of items. Null if there is no more data. */
268
- next: string | null;
269
- };
270
286
  UploadWidgetFileResponseDto: {
271
287
  fileName: string;
272
288
  fileUrl: string;
@@ -350,6 +366,53 @@ export interface components {
350
366
  officeHoursTimezone: string | null;
351
367
  organizationName: string;
352
368
  };
369
+ WidgetSessionAndHistoryDto: {
370
+ /** @description WidgetSession */
371
+ session: {
372
+ /** Format: uuid */
373
+ id: string;
374
+ createdAt: string;
375
+ updatedAt: string;
376
+ isHandedOff: boolean;
377
+ isOpened: boolean;
378
+ assignee: {
379
+ /** @enum {string} */
380
+ kind: "human" | "ai" | "none" | "unknown";
381
+ name: string | null;
382
+ avatarUrl: string | null;
383
+ };
384
+ channel: string;
385
+ isVerified: boolean;
386
+ lastMessage: string | null;
387
+ };
388
+ history: {
389
+ publicId: string;
390
+ /** @enum {string} */
391
+ type: "message" | "handoff" | "handoff_to_zendesk" | "agent_message" | "agent_joined" | "agent_comment" | "agent_took_session_from_ai" | "agent_reopened_session" | "ai_decided_to_resolve_the_issue" | "email_draft_message" | "followup" | "ai_assumed_the_session_resolved" | "user_confirmed_the_session_resolved" | "system_message";
392
+ content: {
393
+ text?: string | null;
394
+ };
395
+ sender: {
396
+ /** @enum {string} */
397
+ kind: "user" | "agent" | "ai" | "none" | "unknown";
398
+ name?: string | null;
399
+ avatar?: string | null;
400
+ };
401
+ sentAt?: string | null;
402
+ actionCalls?: {
403
+ actionName: string;
404
+ args?: unknown;
405
+ result?: unknown;
406
+ }[] | null;
407
+ attachments?: {
408
+ id: string;
409
+ name: string;
410
+ size: number;
411
+ type: string;
412
+ url: string;
413
+ }[] | null;
414
+ }[];
415
+ };
353
416
  /** @description WidgetSession */
354
417
  WidgetSessionDto: {
355
418
  /** Format: uuid */
@@ -548,6 +611,39 @@ export interface operations {
548
611
  };
549
612
  };
550
613
  };
614
+ pollSessionAndHistory: {
615
+ parameters: {
616
+ query?: {
617
+ /** @description The timestamp of the last message received by the widget in order to get any messages after. */
618
+ lastMessageTimestamp?: string;
619
+ };
620
+ header?: never;
621
+ path: {
622
+ sessionId: string;
623
+ };
624
+ cookie?: never;
625
+ };
626
+ requestBody?: never;
627
+ responses: {
628
+ 200: {
629
+ headers: {
630
+ [name: string]: unknown;
631
+ };
632
+ content: {
633
+ "application/json": components["schemas"]["WidgetSessionAndHistoryDto"];
634
+ };
635
+ };
636
+ /** @description Internal Server Error */
637
+ 500: {
638
+ headers: {
639
+ [name: string]: unknown;
640
+ };
641
+ content: {
642
+ "application/json": components["schemas"]["ErrorDto"];
643
+ };
644
+ };
645
+ };
646
+ };
551
647
  createChatSession: {
552
648
  parameters: {
553
649
  query?: never;
@@ -557,7 +653,7 @@ export interface operations {
557
653
  };
558
654
  requestBody: {
559
655
  content: {
560
- "application/json": components["schemas"]["CreateWidgetChatSessionDto"];
656
+ "application/json": components["schemas"]["CreateWidgetSessionDto"];
561
657
  };
562
658
  };
563
659
  responses: {
@@ -589,7 +685,7 @@ export interface operations {
589
685
  };
590
686
  requestBody: {
591
687
  content: {
592
- "application/json": components["schemas"]["HttpChatInputDto"];
688
+ "application/json": components["schemas"]["SendWidgetMessageDto"];
593
689
  };
594
690
  };
595
691
  responses: {
@@ -0,0 +1,24 @@
1
+ import { ApiCaller } from '../api/api-caller';
2
+ import { MessageType } from '../types/messages';
3
+ import { MessageDto } from '../types/schemas';
4
+ import { WidgetConfig } from '../types/widget-config';
5
+ import { MessageCtx } from './message.ctx';
6
+ import { SessionCtx } from './session.ctx';
7
+ export declare class ActiveSessionPollingCtx {
8
+ private api;
9
+ private config;
10
+ private sessionCtx;
11
+ private messageCtx;
12
+ private sessionPollingIntervalSeconds;
13
+ private poller;
14
+ constructor({ api, config, sessionCtx, messageCtx, sessionPollingIntervalSeconds, }: {
15
+ api: ApiCaller;
16
+ config: WidgetConfig;
17
+ sessionCtx: SessionCtx;
18
+ messageCtx: MessageCtx;
19
+ sessionPollingIntervalSeconds: number;
20
+ });
21
+ private registerPolling;
22
+ private hackAndSlash;
23
+ mapHistoryToMessage: (history: MessageDto) => MessageType;
24
+ }
@@ -15,22 +15,15 @@ export declare class MessageCtx {
15
15
  private config;
16
16
  private api;
17
17
  private sessionCtx;
18
- private sessionPollingIntervalSeconds;
19
- private poller;
20
18
  state: PrimitiveState<MessageCtxState>;
21
19
  private sendMessageAbortController;
22
- constructor({ config, api, sessionCtx, sessionPollingIntervalSeconds, }: {
20
+ constructor({ config, api, sessionCtx, }: {
23
21
  config: WidgetConfig;
24
22
  api: ApiCaller;
25
23
  sessionCtx: SessionCtx;
26
- sessionPollingIntervalSeconds: number;
27
24
  });
28
25
  reset: () => void;
29
- private registerPolling;
30
26
  sendMessage: (input: SomeOptional<SafeOmit<SendMessageDto, "bot_token" | "uuid">, "session_id" | "user">) => Promise<void>;
31
- private fetchAndSetHistory;
32
- /** Not the best name but whatever */
33
- private mapHistoryToMessage;
34
27
  private toUserMessage;
35
28
  private toBotMessage;
36
29
  private toBotErrorMessage;
@@ -24,22 +24,18 @@ type SessionsState = {
24
24
  export declare class SessionCtx {
25
25
  private api;
26
26
  private contactCtx;
27
- private sessionPollingIntervalSeconds;
28
27
  private sessionsPollingIntervalSeconds;
29
- private activeSessionPoller;
30
28
  private sessionsRefresher;
31
29
  sessionState: PrimitiveState<SessionState>;
32
30
  sessionsState: PrimitiveState<SessionsState>;
33
- constructor({ api, contactCtx, sessionPollingIntervalSeconds, sessionsPollingIntervalSeconds, }: {
31
+ constructor({ api, contactCtx, sessionsPollingIntervalSeconds, }: {
34
32
  api: ApiCaller;
35
33
  contactCtx: ContactCtx;
36
- sessionPollingIntervalSeconds: number;
37
34
  sessionsPollingIntervalSeconds: number;
38
35
  });
39
36
  /** Clears the session and stops polling */
40
37
  reset: () => Promise<void>;
41
- private registerActiveSessionPolling;
42
- private registerInitialSessionsFetch;
38
+ private registerSessionsRefresherWrapper;
43
39
  private registerSessionsRefresher;
44
40
  createSession: () => Promise<{
45
41
  id: string;
@@ -58,5 +54,6 @@ export declare class SessionCtx {
58
54
  } | null>;
59
55
  loadMoreSessions: () => Promise<void>;
60
56
  private getSessions;
57
+ refreshSessions: () => Promise<void>;
61
58
  }
62
59
  export {};
@@ -15,6 +15,7 @@ export declare class WidgetCtx {
15
15
  routerCtx: RouterCtx;
16
16
  storageCtx?: StorageCtx;
17
17
  private static pollingIntervalsSeconds;
18
+ private activeSessionPollingCtx;
18
19
  private constructor();
19
20
  static initialize: ({ config, storage, }: {
20
21
  config: WidgetConfig;
@@ -1,7 +1,7 @@
1
1
  import { Dto } from '../api/client';
2
2
  export type VoteInputDto = Dto["WidgetVoteDto"];
3
3
  export type VoteOutputDto = Dto["WidgetVoteResponseDto"];
4
- export type SendMessageDto = Dto["HttpChatInputDto"];
4
+ export type SendMessageDto = Dto["SendWidgetMessageDto"];
5
5
  export type SendMessageOutputDto = Dto["HandleContactMessageOutputDto"];
6
6
  export type SessionDto = Dto["WidgetSessionDto"];
7
7
  export type MessageDto = Dto["WidgetHistoryDto"];
@@ -3,7 +3,7 @@ var Yt = (e, t, n) => t in e ? zt(e, t, { enumerable: !0, configurable: !0, writ
3
3
  var Je = (e, t, n) => Yt(e, typeof t != "symbol" ? t + "" : t, n);
4
4
  import z, { createContext as ot, useContext as st, useRef as H, useState as it, useMemo as Ve, useEffect as Me, useSyncExternalStore as kt, useLayoutEffect as Jt, useCallback as Ee, useDebugValue as Xt } from "react";
5
5
  import { jsx as Qt } from "react/jsx-runtime";
6
- import { W as Zt } from "./widget.ctx-BhkkDE2y.js";
6
+ import { W as Zt } from "./widget.ctx-u1FxRDij.js";
7
7
  import { v4 as en } from "uuid";
8
8
  class tn {
9
9
  constructor(t) {
@@ -39,7 +39,7 @@ function nn(e) {
39
39
  return r;
40
40
  }, t.Provider];
41
41
  }
42
- const rn = "3.0.39", [Y, on] = nn();
42
+ const rn = "3.0.41", [Y, on] = nn();
43
43
  function tr({
44
44
  options: e,
45
45
  children: t,
@@ -1339,4 +1339,4 @@ export {
1339
1339
  At as n,
1340
1340
  Y as u
1341
1341
  };
1342
- //# sourceMappingURL=useUploadFiles-B-O5brqx.js.map
1342
+ //# sourceMappingURL=useUploadFiles-CwaNNtV0.js.map