@opencx/widget 3.0.9 → 3.0.12
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/{basic.cjs → designs.cjs} +41 -41
- package/dist/designs.cjs.map +1 -0
- package/dist/designs.d.ts +2 -0
- package/dist/{basic.js → designs.js} +3044 -3036
- package/dist/designs.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +3 -3
- package/dist/react.cjs +1 -1
- package/dist/react.js +12 -12
- package/dist/src/designs/react/index.d.ts +5 -8
- package/dist/src/designs/react/{basic/utils → utils}/group-messages-by-type.d.ts +1 -1
- package/dist/src/embedded/index.d.ts +11 -0
- package/dist/src/headless/core/api.d.ts +42 -16
- package/dist/src/headless/core/context/{contact.d.ts → contact.ctx.d.ts} +3 -3
- package/dist/src/headless/core/context/message.ctx.d.ts +33 -0
- package/dist/src/headless/core/context/router.ctx.d.ts +29 -0
- package/dist/src/headless/core/context/session.ctx.d.ts +56 -0
- package/dist/src/headless/core/context/{widget.d.ts → widget.ctx.d.ts} +5 -3
- package/dist/src/headless/core/index.d.ts +6 -5
- package/dist/src/headless/core/sdk/schema.d.ts +80 -4
- package/dist/src/headless/core/types/WidgetConfig.d.ts +22 -9
- package/dist/src/headless/core/utils/Poller.d.ts +2 -2
- package/dist/src/headless/core/utils/{PubSub.d.ts → PrimitiveState.d.ts} +1 -1
- package/dist/src/headless/react/hooks/useContact.d.ts +1 -1
- package/dist/src/headless/react/hooks/useMessages.d.ts +1 -1
- package/dist/src/headless/react/hooks/usePreludeData.d.ts +3 -1
- package/dist/src/headless/react/hooks/usePrimitiveState.d.ts +2 -0
- package/dist/src/headless/react/hooks/useSession.d.ts +7 -1
- package/dist/src/headless/react/hooks/useWidgetRouter.d.ts +7 -0
- package/dist/src/headless/react/index.d.ts +1 -1
- package/dist/{useUploadFiles-BsYBWtZE.js → useUploadFiles-BQkTgy3Z.js} +243 -237
- package/dist/useUploadFiles-BQkTgy3Z.js.map +1 -0
- package/dist/useUploadFiles-CgV45e1z.cjs +18 -0
- package/dist/useUploadFiles-CgV45e1z.cjs.map +1 -0
- package/dist/widget.ctx-BFXSWWWZ.cjs +2 -0
- package/dist/widget.ctx-BFXSWWWZ.cjs.map +1 -0
- package/dist/{widget-BeNOCqB5.js → widget.ctx-CKrjZfxE.js} +179 -89
- package/dist/widget.ctx-CKrjZfxE.js.map +1 -0
- package/dist-embed/script.js +118 -118
- package/dist-embed/script.js.map +1 -1
- package/package.json +5 -5
- package/dist/basic.cjs.map +0 -1
- package/dist/basic.d.ts +0 -2
- package/dist/basic.js.map +0 -1
- package/dist/src/designs/react/basic/index.d.ts +0 -10
- package/dist/src/designs/react/render.d.ts +0 -2
- package/dist/src/headless/core/context/message.d.ts +0 -42
- package/dist/src/headless/core/context/session.d.ts +0 -74
- package/dist/src/headless/core/utils/PubSub.test.d.ts +0 -1
- package/dist/src/headless/react/hooks/usePubsub.d.ts +0 -2
- package/dist/style.css +0 -1
- package/dist/useUploadFiles-BsYBWtZE.js.map +0 -1
- package/dist/useUploadFiles-CVNyTftw.cjs +0 -18
- package/dist/useUploadFiles-CVNyTftw.cjs.map +0 -1
- package/dist/widget-BeNOCqB5.js.map +0 -1
- package/dist/widget-DlAUwHzU.cjs +0 -2
- package/dist/widget-DlAUwHzU.cjs.map +0 -1
- /package/dist/src/designs/react/{basic/WidgetPopoverTrigger.d.ts → WidgetPopoverTrigger.d.ts} +0 -0
- /package/dist/src/designs/react/{basic/screens/chat-screen → screens/chat}/ChatFooter.d.ts +0 -0
- /package/dist/src/designs/react/{basic/screens/chat-screen → screens/chat}/ChatHeader.d.ts +0 -0
- /package/dist/src/designs/react/{basic/screens/chat-screen → screens/chat}/ChatMain.d.ts +0 -0
- /package/dist/src/designs/react/{basic/screens/chat-screen/ChatScreen.d.ts → screens/chat/index.d.ts} +0 -0
- /package/dist/src/designs/react/{basic/screens/root-screen.d.ts → screens/index.d.ts} +0 -0
- /package/dist/src/designs/react/{basic/screens/welcome-screen/WelcomeScreen.d.ts → screens/welcome/index.d.ts} +0 -0
- /package/dist/src/{designs/react/basic/widget-interaction-tests/widget.test.d.ts → headless/core/utils/PrimitiveState.test.d.ts} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./widget.ctx-BFXSWWWZ.cjs");exports.PrimitiveState=t.PrimitiveState;exports.WidgetCtx=t.WidgetCtx;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.js
CHANGED
package/dist/react.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./useUploadFiles-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./useUploadFiles-CgV45e1z.cjs");function a(t,s,u){const{widgetCtx:{api:i}}=e.useWidget();return e._default(async o=>o==="up"?i.vote({action:"upvote",messagePublicId:t,sessionId:s}).then(u):i.vote({action:"downvote",messagePublicId:t,sessionId:s}).then(u),[i,t,s,u])}exports.WidgetProvider=e.WidgetProvider;exports.useConfig=e.useConfig;exports.useContact=e.useContact;exports.useIsAwaitingBotReply=e.useIsAwaitingBotReply;exports.useMessages=e.useMessages;exports.usePreludeData=e.usePreludeData;exports.usePrimitiveState=e.usePrimitiveState;exports.useSession=e.useSession;exports.useUploadFiles=e.useUploadFiles;exports.useWidget=e.useWidget;exports.useVote=a;
|
|
2
2
|
//# sourceMappingURL=react.cjs.map
|
package/dist/react.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { u as o, _ as
|
|
2
|
-
import { W as p, a as d, b as f, c as
|
|
3
|
-
function n(e, t,
|
|
4
|
-
const { widgetCtx: { api:
|
|
5
|
-
return
|
|
6
|
-
async (u) => u === "up" ?
|
|
7
|
-
[
|
|
1
|
+
import { u as o, _ as i } from "./useUploadFiles-BQkTgy3Z.js";
|
|
2
|
+
import { W as p, a as d, b as f, c as m, d as v, e as c, f as P, g as b, h } from "./useUploadFiles-BQkTgy3Z.js";
|
|
3
|
+
function n(e, t, a) {
|
|
4
|
+
const { widgetCtx: { api: s } } = o();
|
|
5
|
+
return i(
|
|
6
|
+
async (u) => u === "up" ? s.vote({ action: "upvote", messagePublicId: e, sessionId: t }).then(a) : s.vote({ action: "downvote", messagePublicId: e, sessionId: t }).then(a),
|
|
7
|
+
[s, e, t, a]
|
|
8
8
|
);
|
|
9
9
|
}
|
|
10
10
|
export {
|
|
11
11
|
p as WidgetProvider,
|
|
12
12
|
d as useConfig,
|
|
13
13
|
f as useContact,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
m as useIsAwaitingBotReply,
|
|
15
|
+
v as useMessages,
|
|
16
|
+
c as usePreludeData,
|
|
17
|
+
P as usePrimitiveState,
|
|
18
|
+
b as useSession,
|
|
19
19
|
h as useUploadFiles,
|
|
20
20
|
n as useVote,
|
|
21
21
|
o as useWidget
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
1
2
|
import { WidgetConfig } from '../../headless/core';
|
|
2
|
-
declare
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
declare function initOpenScript(options: WidgetConfig): void;
|
|
9
|
-
export {};
|
|
3
|
+
declare function WidgetWrapper({ options }: {
|
|
4
|
+
options: WidgetConfig;
|
|
5
|
+
}): React.JSX.Element;
|
|
6
|
+
export { WidgetWrapper as Widget };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AgentMessageType, BotMessageType, MessageType, UserMessageType } from '
|
|
1
|
+
import { AgentMessageType, BotMessageType, MessageType, UserMessageType } from '../../../headless/core';
|
|
2
2
|
export declare function groupMessagesByType(messages: MessageType[]): MessageType[][];
|
|
3
3
|
export declare function isUserMessageGroup(messages: MessageType[]): messages is UserMessageType[];
|
|
4
4
|
export declare function isBotMessageGroup(messages: MessageType[]): messages is BotMessageType[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { WidgetConfig } from '../headless/core';
|
|
3
|
+
declare global {
|
|
4
|
+
interface Window {
|
|
5
|
+
initOpenScript: typeof initOpenScript;
|
|
6
|
+
openCXWidgetVersion: string;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
declare function initOpenScript(options: WidgetConfig): void;
|
|
10
|
+
export declare function render(rootId: string, component: React.JSX.Element): void;
|
|
11
|
+
export {};
|
|
@@ -198,14 +198,18 @@ export declare class ApiCaller {
|
|
|
198
198
|
name?: string;
|
|
199
199
|
};
|
|
200
200
|
}, `${string}/${string}`>>;
|
|
201
|
-
createSession: () => Promise<import('openapi-fetch').FetchResponse<{
|
|
201
|
+
createSession: (body: Dto["CreateWidgetChatSessionDto"]) => Promise<import('openapi-fetch').FetchResponse<{
|
|
202
202
|
parameters: {
|
|
203
203
|
query?: never;
|
|
204
204
|
header?: never;
|
|
205
205
|
path?: never;
|
|
206
206
|
cookie?: never;
|
|
207
207
|
};
|
|
208
|
-
requestBody
|
|
208
|
+
requestBody: {
|
|
209
|
+
content: {
|
|
210
|
+
"application/json": import('./sdk/schema').components["schemas"]["CreateWidgetChatSessionDto"];
|
|
211
|
+
};
|
|
212
|
+
};
|
|
209
213
|
responses: {
|
|
210
214
|
200: {
|
|
211
215
|
headers: {
|
|
@@ -224,11 +228,23 @@ export declare class ApiCaller {
|
|
|
224
228
|
};
|
|
225
229
|
};
|
|
226
230
|
};
|
|
227
|
-
},
|
|
231
|
+
}, {
|
|
232
|
+
body: {
|
|
233
|
+
customData?: {
|
|
234
|
+
[key: string]: string | number | boolean | unknown | unknown;
|
|
235
|
+
};
|
|
236
|
+
};
|
|
237
|
+
}, `${string}/${string}`>>;
|
|
238
|
+
getSession: ({ sessionId, abortSignal, }: {
|
|
239
|
+
sessionId: string;
|
|
240
|
+
abortSignal: AbortSignal;
|
|
241
|
+
}) => Promise<import('openapi-fetch').FetchResponse<{
|
|
228
242
|
parameters: {
|
|
229
243
|
query?: never;
|
|
230
244
|
header?: never;
|
|
231
|
-
path
|
|
245
|
+
path: {
|
|
246
|
+
sessionId: string;
|
|
247
|
+
};
|
|
232
248
|
cookie?: never;
|
|
233
249
|
};
|
|
234
250
|
requestBody?: never;
|
|
@@ -250,17 +266,26 @@ export declare class ApiCaller {
|
|
|
250
266
|
};
|
|
251
267
|
};
|
|
252
268
|
};
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
sessionId: string;
|
|
256
|
-
abortSignal: AbortSignal;
|
|
257
|
-
}) => Promise<import('openapi-fetch').FetchResponse<{
|
|
258
|
-
parameters: {
|
|
259
|
-
query?: never;
|
|
260
|
-
header?: never;
|
|
269
|
+
}, {
|
|
270
|
+
params: {
|
|
261
271
|
path: {
|
|
262
272
|
sessionId: string;
|
|
263
273
|
};
|
|
274
|
+
};
|
|
275
|
+
signal: AbortSignal;
|
|
276
|
+
}, `${string}/${string}`>>;
|
|
277
|
+
getSessions: ({ cursor, filters, abortSignal, }: {
|
|
278
|
+
cursor: string | undefined;
|
|
279
|
+
filters: Record<string, string>;
|
|
280
|
+
abortSignal?: AbortSignal;
|
|
281
|
+
}) => Promise<import('openapi-fetch').FetchResponse<{
|
|
282
|
+
parameters: {
|
|
283
|
+
query: {
|
|
284
|
+
filters: string;
|
|
285
|
+
cursor?: string;
|
|
286
|
+
};
|
|
287
|
+
header?: never;
|
|
288
|
+
path?: never;
|
|
264
289
|
cookie?: never;
|
|
265
290
|
};
|
|
266
291
|
requestBody?: never;
|
|
@@ -270,7 +295,7 @@ export declare class ApiCaller {
|
|
|
270
295
|
[name: string]: unknown;
|
|
271
296
|
};
|
|
272
297
|
content: {
|
|
273
|
-
"application/json": import('./sdk/schema').components["schemas"]["
|
|
298
|
+
"application/json": import('./sdk/schema').components["schemas"]["PaginatedWidgetSessionsDto"];
|
|
274
299
|
};
|
|
275
300
|
};
|
|
276
301
|
500: {
|
|
@@ -284,11 +309,12 @@ export declare class ApiCaller {
|
|
|
284
309
|
};
|
|
285
310
|
}, {
|
|
286
311
|
params: {
|
|
287
|
-
|
|
288
|
-
|
|
312
|
+
query: {
|
|
313
|
+
cursor: string | undefined;
|
|
314
|
+
filters: string;
|
|
289
315
|
};
|
|
290
316
|
};
|
|
291
|
-
signal: AbortSignal;
|
|
317
|
+
signal: AbortSignal | undefined;
|
|
292
318
|
}, `${string}/${string}`>>;
|
|
293
319
|
uploadFile: (file: {
|
|
294
320
|
id: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PrimitiveState } from '../utils/PrimitiveState';
|
|
2
2
|
import { ApiCaller } from '../api';
|
|
3
3
|
import { WidgetConfig } from '../types/WidgetConfig';
|
|
4
4
|
import { Dto } from '../sdk';
|
|
@@ -12,13 +12,13 @@ type ContactState = {
|
|
|
12
12
|
export declare class ContactCtx {
|
|
13
13
|
private config;
|
|
14
14
|
private api;
|
|
15
|
-
state:
|
|
15
|
+
state: PrimitiveState<ContactState>;
|
|
16
16
|
constructor({ config, api, }: {
|
|
17
17
|
api: ApiCaller;
|
|
18
18
|
config: WidgetConfig;
|
|
19
19
|
});
|
|
20
20
|
shouldCollectData: () => boolean;
|
|
21
|
-
autoCreateUnverifiedUser
|
|
21
|
+
private autoCreateUnverifiedUser;
|
|
22
22
|
createUnverifiedContact: (payload: Dto["CreateUnverifiedContactDto"]) => Promise<void>;
|
|
23
23
|
}
|
|
24
24
|
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ApiCaller } from '../api';
|
|
2
|
+
import { WidgetConfig } from '../types/WidgetConfig';
|
|
3
|
+
import { SafeOmit, SomeOptional } from '../types/helpers';
|
|
4
|
+
import { MessageType } from '../types/messages';
|
|
5
|
+
import { SendMessageDto } from '../types/schemas';
|
|
6
|
+
import { PrimitiveState } from '../utils/PrimitiveState';
|
|
7
|
+
import { SessionCtx } from './session.ctx';
|
|
8
|
+
export declare class MessageCtx {
|
|
9
|
+
private config;
|
|
10
|
+
private api;
|
|
11
|
+
private sessionCtx;
|
|
12
|
+
private poller;
|
|
13
|
+
state: PrimitiveState<{
|
|
14
|
+
messages: MessageType[];
|
|
15
|
+
isSendingMessage: boolean;
|
|
16
|
+
suggestedReplies: string[] | null;
|
|
17
|
+
}>;
|
|
18
|
+
private sendMessageAbortController;
|
|
19
|
+
constructor({ config, api, sessionCtx, }: {
|
|
20
|
+
config: WidgetConfig;
|
|
21
|
+
api: ApiCaller;
|
|
22
|
+
sessionCtx: SessionCtx;
|
|
23
|
+
});
|
|
24
|
+
reset: () => void;
|
|
25
|
+
private registerPolling;
|
|
26
|
+
sendMessage: (input: SomeOptional<SafeOmit<SendMessageDto, "bot_token" | "uuid">, "session_id" | "user">) => Promise<void>;
|
|
27
|
+
private fetchAndSetHistory;
|
|
28
|
+
/** Not the best name but whatever */
|
|
29
|
+
private static mapHistoryToMessage;
|
|
30
|
+
private static toUserMessage;
|
|
31
|
+
private static toBotMessage;
|
|
32
|
+
private static toErrorMessage;
|
|
33
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { PrimitiveState } from '../utils/PrimitiveState';
|
|
2
|
+
import { ContactCtx } from './contact.ctx';
|
|
3
|
+
import { SessionCtx } from './session.ctx';
|
|
4
|
+
import { WidgetCtx } from './widget.ctx';
|
|
5
|
+
type RouterState = {
|
|
6
|
+
screen: /** A welcome screen to collect user data. Useful in public non-logged-in environments */ "welcome"
|
|
7
|
+
/** Show a list of the user's previous sessions */
|
|
8
|
+
| "sessions"
|
|
9
|
+
/** Self-explanatory */
|
|
10
|
+
| "chat";
|
|
11
|
+
};
|
|
12
|
+
export declare class RouterCtx {
|
|
13
|
+
state: PrimitiveState<RouterState>;
|
|
14
|
+
private contactCtx;
|
|
15
|
+
private sessionCtx;
|
|
16
|
+
private resetChat;
|
|
17
|
+
constructor({ contactCtx, sessionCtx, resetChat, }: {
|
|
18
|
+
contactCtx: ContactCtx;
|
|
19
|
+
sessionCtx: SessionCtx;
|
|
20
|
+
resetChat: WidgetCtx["resetChat"];
|
|
21
|
+
});
|
|
22
|
+
private registerRoutingListener;
|
|
23
|
+
toSessionsScreen: () => void;
|
|
24
|
+
/**
|
|
25
|
+
* @param sessionId The ID of the session to open, or `undefined` if it is a new chat session
|
|
26
|
+
*/
|
|
27
|
+
toChatScreen: (sessionId?: string) => void;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ApiCaller } from '../api';
|
|
2
|
+
import { SessionDto } from '../types/schemas';
|
|
3
|
+
import { WidgetConfig } from '../types/WidgetConfig';
|
|
4
|
+
import { PrimitiveState } from '../utils/PrimitiveState';
|
|
5
|
+
import { ContactCtx } from './contact.ctx';
|
|
6
|
+
type SessionState = {
|
|
7
|
+
/**
|
|
8
|
+
* The currently selected session.
|
|
9
|
+
* Can be null if no session is selected, or if in chat screen and the session is not created yet.
|
|
10
|
+
*/
|
|
11
|
+
session: SessionDto | null;
|
|
12
|
+
isCreatingSession: boolean;
|
|
13
|
+
};
|
|
14
|
+
type SessionsState = {
|
|
15
|
+
/** List of all user sessions */
|
|
16
|
+
data: SessionDto[];
|
|
17
|
+
/** A cursor to get the next page of sessions */
|
|
18
|
+
cursor: string | undefined;
|
|
19
|
+
/** Indicates if no more pages are left */
|
|
20
|
+
isLastPage: boolean;
|
|
21
|
+
/** Did fetch for the first time */
|
|
22
|
+
didInitialFetch: boolean;
|
|
23
|
+
};
|
|
24
|
+
export declare class SessionCtx {
|
|
25
|
+
private config;
|
|
26
|
+
private api;
|
|
27
|
+
private contactCtx;
|
|
28
|
+
private poller;
|
|
29
|
+
sessionState: PrimitiveState<SessionState>;
|
|
30
|
+
sessionsState: PrimitiveState<SessionsState>;
|
|
31
|
+
constructor({ config, api, contactCtx, }: {
|
|
32
|
+
config: WidgetConfig;
|
|
33
|
+
api: ApiCaller;
|
|
34
|
+
contactCtx: ContactCtx;
|
|
35
|
+
});
|
|
36
|
+
/** Clears the session and stops polling */
|
|
37
|
+
reset: () => Promise<void>;
|
|
38
|
+
private registerPolling;
|
|
39
|
+
private registerInitialSessionsFetch;
|
|
40
|
+
createSession: () => Promise<{
|
|
41
|
+
id: string;
|
|
42
|
+
createdAt: string;
|
|
43
|
+
updatedAt: string;
|
|
44
|
+
isHandedOff: boolean;
|
|
45
|
+
isOpened: boolean;
|
|
46
|
+
assignee: {
|
|
47
|
+
kind: "human" | "ai" | "none" | "unknown";
|
|
48
|
+
name: string | null;
|
|
49
|
+
avatarUrl: string | null;
|
|
50
|
+
};
|
|
51
|
+
channel: string;
|
|
52
|
+
isVerified: boolean;
|
|
53
|
+
} | null>;
|
|
54
|
+
loadMoreSessions: () => Promise<void>;
|
|
55
|
+
}
|
|
56
|
+
export {};
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { ApiCaller } from '../api';
|
|
2
2
|
import { WidgetConfig } from '../types/WidgetConfig';
|
|
3
|
-
import { ContactCtx } from './contact';
|
|
4
|
-
import { MessageCtx } from './message';
|
|
5
|
-
import {
|
|
3
|
+
import { ContactCtx } from './contact.ctx';
|
|
4
|
+
import { MessageCtx } from './message.ctx';
|
|
5
|
+
import { RouterCtx } from './router.ctx';
|
|
6
|
+
import { SessionCtx } from './session.ctx';
|
|
6
7
|
export declare class WidgetCtx {
|
|
7
8
|
config: WidgetConfig;
|
|
8
9
|
api: ApiCaller;
|
|
9
10
|
contactCtx: ContactCtx;
|
|
10
11
|
sessionCtx: SessionCtx;
|
|
11
12
|
messageCtx: MessageCtx;
|
|
13
|
+
routerCtx: RouterCtx;
|
|
12
14
|
constructor({ config }: {
|
|
13
15
|
config: WidgetConfig;
|
|
14
16
|
});
|
|
@@ -3,8 +3,9 @@ export type { SafeExtract, SafeOmit, SomeOptional, StringOrLiteral, } from './ty
|
|
|
3
3
|
export type { WidgetComponentKey, DefaultWidgetTextComponentData, UserMessageType, AgentMessageType, BotMessageType, MessageType, } from './types/messages';
|
|
4
4
|
export type { MessageAttachmentType, MessageDto, PreludeDto, SendMessageDto, SendMessageOutputDto, SessionDto, VoteInputDto, VoteOutputDto, } from './types/schemas';
|
|
5
5
|
export type { WidgetConfig } from './types/WidgetConfig';
|
|
6
|
-
export { WidgetCtx } from './context/widget';
|
|
7
|
-
export type { ContactCtx } from './context/contact';
|
|
8
|
-
export type { SessionCtx } from './context/session';
|
|
9
|
-
export type { MessageCtx } from './context/message';
|
|
10
|
-
export {
|
|
6
|
+
export { WidgetCtx } from './context/widget.ctx';
|
|
7
|
+
export type { ContactCtx } from './context/contact.ctx';
|
|
8
|
+
export type { SessionCtx } from './context/session.ctx';
|
|
9
|
+
export type { MessageCtx } from './context/message.ctx';
|
|
10
|
+
export type { RouterCtx } from './context/router.ctx';
|
|
11
|
+
export { PrimitiveState } from './utils/PrimitiveState';
|
|
@@ -10,7 +10,6 @@ export interface paths {
|
|
|
10
10
|
path?: never;
|
|
11
11
|
cookie?: never;
|
|
12
12
|
};
|
|
13
|
-
/** Get the prelude for the widget */
|
|
14
13
|
get: operations["widgetPrelude"];
|
|
15
14
|
put?: never;
|
|
16
15
|
post?: never;
|
|
@@ -36,6 +35,22 @@ export interface paths {
|
|
|
36
35
|
patch?: never;
|
|
37
36
|
trace?: never;
|
|
38
37
|
};
|
|
38
|
+
"/backend/widget/v2/sessions": {
|
|
39
|
+
parameters: {
|
|
40
|
+
query?: never;
|
|
41
|
+
header?: never;
|
|
42
|
+
path?: never;
|
|
43
|
+
cookie?: never;
|
|
44
|
+
};
|
|
45
|
+
get: operations["getSessions"];
|
|
46
|
+
put?: never;
|
|
47
|
+
post?: never;
|
|
48
|
+
delete?: never;
|
|
49
|
+
options?: never;
|
|
50
|
+
head?: never;
|
|
51
|
+
patch?: never;
|
|
52
|
+
trace?: never;
|
|
53
|
+
};
|
|
39
54
|
"/backend/widget/v2/session/history/{sessionId}": {
|
|
40
55
|
parameters: {
|
|
41
56
|
query?: never;
|
|
@@ -93,7 +108,6 @@ export interface paths {
|
|
|
93
108
|
};
|
|
94
109
|
get?: never;
|
|
95
110
|
put?: never;
|
|
96
|
-
/** Upload file */
|
|
97
111
|
post: operations["uploadFile"];
|
|
98
112
|
delete?: never;
|
|
99
113
|
options?: never;
|
|
@@ -126,7 +140,6 @@ export interface paths {
|
|
|
126
140
|
};
|
|
127
141
|
get?: never;
|
|
128
142
|
put?: never;
|
|
129
|
-
/** Create an unverified contact for the widget */
|
|
130
143
|
post: operations["createUnverifiedContact"];
|
|
131
144
|
delete?: never;
|
|
132
145
|
options?: never;
|
|
@@ -142,6 +155,11 @@ export interface components {
|
|
|
142
155
|
email?: string;
|
|
143
156
|
name?: string;
|
|
144
157
|
};
|
|
158
|
+
CreateWidgetChatSessionDto: {
|
|
159
|
+
customData?: {
|
|
160
|
+
[key: string]: string | number | boolean | unknown | unknown;
|
|
161
|
+
};
|
|
162
|
+
};
|
|
145
163
|
FileUploadDto: {
|
|
146
164
|
/** Format: binary */
|
|
147
165
|
file: string;
|
|
@@ -214,6 +232,27 @@ export interface components {
|
|
|
214
232
|
url: string;
|
|
215
233
|
}[] | null;
|
|
216
234
|
};
|
|
235
|
+
/** @description Paginated response. */
|
|
236
|
+
PaginatedWidgetSessionsDto: {
|
|
237
|
+
items: {
|
|
238
|
+
/** Format: uuid */
|
|
239
|
+
id: string;
|
|
240
|
+
createdAt: string;
|
|
241
|
+
updatedAt: string;
|
|
242
|
+
isHandedOff: boolean;
|
|
243
|
+
isOpened: boolean;
|
|
244
|
+
assignee: {
|
|
245
|
+
/** @enum {string} */
|
|
246
|
+
kind: "human" | "ai" | "none" | "unknown";
|
|
247
|
+
name: string | null;
|
|
248
|
+
avatarUrl: string | null;
|
|
249
|
+
};
|
|
250
|
+
channel: string;
|
|
251
|
+
isVerified: boolean;
|
|
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
|
+
};
|
|
217
256
|
UploadWidgetFileResponseDto: {
|
|
218
257
|
fileName: string;
|
|
219
258
|
fileUrl: string;
|
|
@@ -398,6 +437,39 @@ export interface operations {
|
|
|
398
437
|
};
|
|
399
438
|
};
|
|
400
439
|
};
|
|
440
|
+
getSessions: {
|
|
441
|
+
parameters: {
|
|
442
|
+
query: {
|
|
443
|
+
/** @description A JSON-stringified Record<string, string>. These filters will be compared against the sessions' custom_data */
|
|
444
|
+
filters: string;
|
|
445
|
+
/** @description Pagination cursor to fetch the next set of results */
|
|
446
|
+
cursor?: string;
|
|
447
|
+
};
|
|
448
|
+
header?: never;
|
|
449
|
+
path?: never;
|
|
450
|
+
cookie?: never;
|
|
451
|
+
};
|
|
452
|
+
requestBody?: never;
|
|
453
|
+
responses: {
|
|
454
|
+
200: {
|
|
455
|
+
headers: {
|
|
456
|
+
[name: string]: unknown;
|
|
457
|
+
};
|
|
458
|
+
content: {
|
|
459
|
+
"application/json": components["schemas"]["PaginatedWidgetSessionsDto"];
|
|
460
|
+
};
|
|
461
|
+
};
|
|
462
|
+
/** @description Internal Server Error */
|
|
463
|
+
500: {
|
|
464
|
+
headers: {
|
|
465
|
+
[name: string]: unknown;
|
|
466
|
+
};
|
|
467
|
+
content: {
|
|
468
|
+
"application/json": components["schemas"]["ErrorDto"];
|
|
469
|
+
};
|
|
470
|
+
};
|
|
471
|
+
};
|
|
472
|
+
};
|
|
401
473
|
getSessionHistory: {
|
|
402
474
|
parameters: {
|
|
403
475
|
query?: {
|
|
@@ -438,7 +510,11 @@ export interface operations {
|
|
|
438
510
|
path?: never;
|
|
439
511
|
cookie?: never;
|
|
440
512
|
};
|
|
441
|
-
requestBody
|
|
513
|
+
requestBody: {
|
|
514
|
+
content: {
|
|
515
|
+
"application/json": components["schemas"]["CreateWidgetChatSessionDto"];
|
|
516
|
+
};
|
|
517
|
+
};
|
|
442
518
|
responses: {
|
|
443
519
|
200: {
|
|
444
520
|
headers: {
|
|
@@ -1,4 +1,24 @@
|
|
|
1
1
|
import { AgentOrBotType } from './agent-or-bot';
|
|
2
|
+
type UserBaseConfig = {
|
|
3
|
+
token: string;
|
|
4
|
+
data?: never;
|
|
5
|
+
} | {
|
|
6
|
+
token?: never;
|
|
7
|
+
data?: {
|
|
8
|
+
name?: string;
|
|
9
|
+
email?: string;
|
|
10
|
+
phone?: string;
|
|
11
|
+
customData?: Record<string, string>;
|
|
12
|
+
avatarUrl?: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export type UserConfig = UserBaseConfig & {
|
|
16
|
+
/**
|
|
17
|
+
* An external ID is useful to scope the sessions of a single user based on workspace.
|
|
18
|
+
* For example, if a user uses one email for multiple accounts (organizations) in your application.
|
|
19
|
+
*/
|
|
20
|
+
externalId?: string;
|
|
21
|
+
};
|
|
2
22
|
export interface WidgetConfig {
|
|
3
23
|
token: string;
|
|
4
24
|
apiUrl?: string;
|
|
@@ -8,15 +28,7 @@ export interface WidgetConfig {
|
|
|
8
28
|
debug?: boolean;
|
|
9
29
|
initialMessages?: string[];
|
|
10
30
|
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;
|
|
31
|
+
user?: UserConfig;
|
|
20
32
|
bot?: AgentOrBotType;
|
|
21
33
|
soundEffectsUrls?: {
|
|
22
34
|
messageArrived?: string;
|
|
@@ -32,3 +44,4 @@ export interface WidgetConfig {
|
|
|
32
44
|
organizationLogo?: string;
|
|
33
45
|
};
|
|
34
46
|
}
|
|
47
|
+
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PrimitiveState } from './PrimitiveState';
|
|
2
2
|
export type PollingState = {
|
|
3
3
|
isPolling: boolean;
|
|
4
4
|
isError: boolean;
|
|
5
5
|
};
|
|
6
6
|
export declare class Poller {
|
|
7
|
-
state:
|
|
7
|
+
state: PrimitiveState<PollingState>;
|
|
8
8
|
private abortController;
|
|
9
9
|
reset: () => void;
|
|
10
10
|
stopPolling: (() => void) | null;
|
|
@@ -6,5 +6,5 @@ export declare function useContact(): {
|
|
|
6
6
|
isCreatingUnverifiedContact: boolean;
|
|
7
7
|
isErrorCreatingUnverifiedContact: boolean;
|
|
8
8
|
};
|
|
9
|
-
|
|
9
|
+
createUnverifiedContact: (payload: import('../../core/sdk').Dto["CreateUnverifiedContactDto"]) => Promise<void>;
|
|
10
10
|
};
|
|
@@ -4,5 +4,5 @@ export declare function useMessages(): {
|
|
|
4
4
|
isSendingMessage: boolean;
|
|
5
5
|
suggestedReplies: string[] | null;
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
sendMessage: (input: import('../../core').SomeOptional<import('../../core').SafeOmit<import('../../core').SendMessageDto, "bot_token" | "uuid">, "session_id" | "user">) => Promise<void>;
|
|
8
8
|
};
|
|
@@ -32,5 +32,7 @@ declare function usePreludeData(): import('swr').SWRResponse<import('openapi-fet
|
|
|
32
32
|
"X-Bot-Token": string;
|
|
33
33
|
};
|
|
34
34
|
};
|
|
35
|
-
}, `${string}/${string}`>, any,
|
|
35
|
+
}, `${string}/${string}`>, any, {
|
|
36
|
+
revalidateOnFocus: false;
|
|
37
|
+
}>;
|
|
36
38
|
export { usePreludeData };
|
|
@@ -3,5 +3,11 @@ export declare function useSession(): {
|
|
|
3
3
|
session: import('../../core').SessionDto | null;
|
|
4
4
|
isCreatingSession: boolean;
|
|
5
5
|
};
|
|
6
|
-
|
|
6
|
+
sessionsState: {
|
|
7
|
+
data: import('../../core').SessionDto[];
|
|
8
|
+
cursor: string | undefined;
|
|
9
|
+
isLastPage: boolean;
|
|
10
|
+
didInitialFetch: boolean;
|
|
11
|
+
};
|
|
12
|
+
loadMoreSessions: () => Promise<void>;
|
|
7
13
|
};
|
|
@@ -5,7 +5,7 @@ export { useContact } from './hooks/useContact';
|
|
|
5
5
|
export { useIsAwaitingBotReply } from './hooks/useIsAwaitingBotReply';
|
|
6
6
|
export { useMessages } from './hooks/useMessages';
|
|
7
7
|
export { usePreludeData } from './hooks/usePreludeData';
|
|
8
|
-
export {
|
|
8
|
+
export { usePrimitiveState } from './hooks/usePrimitiveState';
|
|
9
9
|
export { useSession } from './hooks/useSession';
|
|
10
10
|
export { useVote } from './hooks/useVote';
|
|
11
11
|
export { type FileWithProgress, useUploadFiles } from './hooks/useUploadFiles';
|