@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.
- package/dist/api-BEtFfKMB.cjs +2 -0
- package/dist/api-BEtFfKMB.cjs.map +1 -0
- package/dist/api-Cez5T-se.js +1393 -0
- package/dist/api-Cez5T-se.js.map +1 -0
- package/dist/basic.cjs +85 -85
- package/dist/basic.cjs.map +1 -1
- package/dist/basic.js +13159 -12639
- package/dist/basic.js.map +1 -1
- package/dist/core/client/api.d.ts +414 -40
- package/dist/core/client/chat.d.ts +33 -19
- package/dist/core/client/config.d.ts +13 -3
- package/dist/core/client/contact.d.ts +9 -13
- package/dist/core/client/index.d.ts +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/sdk/index.d.ts +11 -0
- package/dist/core/types/contact.d.ts +2 -0
- package/dist/core/types/helpers.d.ts +5 -2
- package/dist/core/types/index.d.ts +6 -6
- package/dist/core/types/messages.d.ts +20 -9
- package/dist/core/types/schemas-v2.d.ts +10 -713
- package/dist/index-BzidnDPX.cjs +18 -0
- package/dist/index-BzidnDPX.cjs.map +1 -0
- package/dist/index-DUlnC30_.js +1219 -0
- package/dist/index-DUlnC30_.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +22 -1071
- package/dist/index.js.map +1 -1
- package/dist/react-web/core-integration/ChatProvider.d.ts +107 -0
- package/dist/react-web/core-integration/components.d.ts +11 -0
- package/dist/react-web/core-integration/hooks/useChatMessages.d.ts +70 -0
- package/dist/react-web/core-integration/hooks/useChatSession.d.ts +83 -0
- package/dist/react-web/core-integration/hooks/useConfig.d.ts +1 -0
- package/dist/react-web/core-integration/hooks/useContact.d.ts +17 -0
- package/dist/react-web/core-integration/hooks/useLocale.d.ts +4 -0
- package/dist/react-web/core-integration/hooks/usePreludeData.d.ts +36 -0
- package/dist/react-web/core-integration/hooks/usePubsub.d.ts +2 -0
- package/dist/react-web/{hooks → core-integration/hooks}/useUploadFiles.d.ts +2 -2
- package/dist/react-web/{hooks → core-integration/hooks}/useVote.d.ts +2 -2
- package/dist/react-web/core-integration/hooks.d.ts +9 -0
- package/dist/react-web/core-integration/index.d.ts +2 -0
- package/dist/react-web/index.d.ts +4 -10
- package/dist/react-web/types/components.d.ts +6 -3
- package/dist/react-web/types/index.d.ts +3 -2
- package/dist/react-web/types/options.d.ts +4 -30
- package/dist/react.cjs +1 -1
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +10 -46
- package/dist/react.js.map +1 -1
- package/dist/src/@components/BotOrAgentMessageGroup.d.ts +1 -2
- package/dist/src/@components/BotOrAgentMessageWrapper.d.ts +2 -2
- package/dist/src/@components/ChatEvent.component.d.ts +3 -3
- package/dist/src/@components/Text.component.d.ts +1 -1
- package/dist/src/components/button.d.ts +1 -1
- package/dist/src/components/dialog.d.ts +9 -9
- package/dist/src/designs/basic/index.d.ts +1 -1
- package/dist/style.css +1 -1
- package/dist-embed/script.js +119 -124
- package/dist-embed/script.js.map +1 -1
- package/package.json +7 -4
- package/dist/core/tests/utils/create-fetch.test.d.ts +0 -1
- package/dist/core/types/schemas.d.ts +0 -543
- package/dist/core/utils/create-fetch.d.ts +0 -25
- package/dist/core/utils/genId.d.ts +0 -2
- package/dist/core/utils/history-to-widget-messages.d.ts +0 -4
- package/dist/genUuid-C12yFv3j.js +0 -137
- package/dist/genUuid-C12yFv3j.js.map +0 -1
- package/dist/genUuid-DdeSE04H.cjs +0 -2
- package/dist/genUuid-DdeSE04H.cjs.map +0 -1
- package/dist/index-C87obATS.js +0 -2616
- package/dist/index-C87obATS.js.map +0 -1
- package/dist/index-ChwS_h0D.cjs +0 -18
- package/dist/index-ChwS_h0D.cjs.map +0 -1
- package/dist/package.json.d.ts +0 -158
- package/dist/react-web/Root.d.ts +0 -6
- package/dist/react-web/hooks/index.d.ts +0 -6
- package/dist/react-web/hooks/use-sound.d.ts +0 -13
- package/dist/react-web/hooks/use-sound.test.d.ts +0 -1
- package/dist/react-web/hooks/use-sync-state.test.d.ts +0 -1
- package/dist/react-web/hooks/useAbstractChat.d.ts +0 -157
- package/dist/react-web/hooks/useAxiosInstance.d.ts +0 -190
- package/dist/react-web/hooks/useSyncState.d.ts +0 -4
- package/dist/react-web/hooks/useTimeoutState.d.ts +0 -3
- package/dist/react-web/providers/ChatProvider.d.ts +0 -143
- package/dist/react-web/providers/ConfigDataProvider.d.ts +0 -62
- package/dist/react-web/providers/ContactProvider.d.ts +0 -58
- package/dist/react-web/providers/LocalesProvider.d.ts +0 -11
- package/dist/react-web/providers/componentRegistry.d.ts +0 -13
- package/dist/react-web/providers/use-widget-sfx.d.ts +0 -7
- package/dist/react-web/providers/usePreludeData.d.ts +0 -2
- package/dist/react-web/utils/debug.d.ts +0 -2
- package/dist/react-web/utils/getters.d.ts +0 -24
- package/dist/react-web/utils/index.d.ts +0 -1
- package/dist/src/hooks/useShouldCollectData.d.ts +0 -3
- /package/dist/react-web/{locales → core-integration/locales}/ar.locale.d.ts +0 -0
- /package/dist/react-web/{locales → core-integration/locales}/de.locale.d.ts +0 -0
- /package/dist/react-web/{locales → core-integration/locales}/en.locale.d.ts +0 -0
- /package/dist/react-web/{locales → core-integration/locales}/fr.locale.d.ts +0 -0
- /package/dist/react-web/{locales → core-integration/locales}/helper.d.ts +0 -0
- /package/dist/react-web/{locales → core-integration/locales}/index.d.ts +0 -0
- /package/dist/react-web/{locales → core-integration/locales}/nl.locale.d.ts +0 -0
- /package/dist/react-web/{locales → core-integration/locales}/pt.locale.d.ts +0 -0
|
@@ -3,15 +3,18 @@ export type FunctionReturningPromise = (...args: any[]) => Promise<any>;
|
|
|
3
3
|
export type MakeKeysNotNullable<T, K extends keyof T> = Omit<T, K> & {
|
|
4
4
|
[P in K]-?: NonNullable<T[P]>;
|
|
5
5
|
};
|
|
6
|
-
export type LoadingReason = 'sending_message_to_bot' | 'sending_message_to_agent' | 'creating_session' | 'polling' | 'loading_contact' | 'saving_contact' | 'cleaning_up' | null;
|
|
6
|
+
export type LoadingReason = 'sending_message_to_bot' | 'sending_message_to_agent' | 'creating_session' | 'polling' | 'loading_contact' | 'saving_contact' | 'cleaning_up' | 'creating_unauthenticated_contact' | null;
|
|
7
7
|
export type LoadingState = {
|
|
8
8
|
isLoading: boolean;
|
|
9
9
|
reason: LoadingReason;
|
|
10
10
|
};
|
|
11
|
-
export type ErrorCode = 'SESSION_CREATION_FAILED' | 'SESSION_CLEAR_FAILED' | 'SESSION_PERSISTENCE_FAILED' | 'SESSION_POLLING_FAILED' | 'MESSAGES_POLLING_FAILED' | 'MESSAGE_SEND_FAILED' | 'NO_ACTIVE_SESSION' | 'CONTACT_PERSISTENCE_FAILED' | 'CONTACT_LOAD_FAILED' | 'CONTACT_SAVE_FAILED' | 'CONTACT_CLEANUP_FAILED';
|
|
11
|
+
export type ErrorCode = 'SESSION_CREATION_FAILED' | 'SESSION_CLEAR_FAILED' | 'SESSION_PERSISTENCE_FAILED' | 'SESSION_POLLING_FAILED' | 'MESSAGES_POLLING_FAILED' | 'MESSAGE_SEND_FAILED' | 'NO_ACTIVE_SESSION' | 'CONTACT_PERSISTENCE_FAILED' | 'CONTACT_LOAD_FAILED' | 'CONTACT_SAVE_FAILED' | 'CONTACT_CLEANUP_FAILED' | 'CONTACT_CREATION_FAILED';
|
|
12
12
|
export type ErrorState = {
|
|
13
13
|
hasError: boolean;
|
|
14
14
|
message?: string;
|
|
15
15
|
code?: ErrorCode;
|
|
16
16
|
};
|
|
17
17
|
export type SomeOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
18
|
+
export type SafeOmit<T, K extends keyof T> = Omit<T, K>;
|
|
19
|
+
export type SafeExtract<T, K extends T> = Extract<T, K>;
|
|
20
|
+
export type StringOrLiteral<T extends string> = T | (string & {});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AgentType } from './messages';
|
|
1
2
|
import { ChatAttachmentType } from './schemas-v2';
|
|
2
3
|
export * from './messages';
|
|
3
4
|
export * from './schemas-v2';
|
|
@@ -28,15 +29,11 @@ export interface CoreOptions {
|
|
|
28
29
|
pathParams?: Record<string, string>;
|
|
29
30
|
collectUserData?: boolean;
|
|
30
31
|
debug?: boolean;
|
|
32
|
+
initialMessages?: string[];
|
|
31
33
|
language?: string;
|
|
32
34
|
user?: User;
|
|
33
35
|
contactToken?: string;
|
|
34
|
-
bot?:
|
|
35
|
-
name?: string;
|
|
36
|
-
avatarUrl?: string;
|
|
37
|
-
id?: number | null;
|
|
38
|
-
is_ai?: boolean;
|
|
39
|
-
};
|
|
36
|
+
bot?: AgentType;
|
|
40
37
|
pollingInterval?: number;
|
|
41
38
|
soundEffectFiles?: {
|
|
42
39
|
messageArrived?: string;
|
|
@@ -49,4 +46,7 @@ export interface CoreOptions {
|
|
|
49
46
|
persistSession?: boolean;
|
|
50
47
|
useSoundEffects?: boolean;
|
|
51
48
|
};
|
|
49
|
+
assets?: {
|
|
50
|
+
organizationLogo?: string;
|
|
51
|
+
};
|
|
52
52
|
}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DefaultTextComponentBaseProps, WidgetLiteralComponentKey } from '../../react-web/types';
|
|
2
|
+
import { ChatAttachmentType, WidgetHistoryDto } from './schemas-v2';
|
|
3
|
+
import { SafeExtract, StringOrLiteral } from './helpers';
|
|
4
|
+
export type AgentType = {
|
|
5
|
+
isAi: boolean;
|
|
6
|
+
id: string | null;
|
|
7
|
+
name: string;
|
|
8
|
+
avatar: string | null;
|
|
9
|
+
};
|
|
2
10
|
export type UserMessageType = {
|
|
3
11
|
id: string;
|
|
4
12
|
type: "FROM_USER";
|
|
5
13
|
content: string;
|
|
6
14
|
deliveredAt: string | null;
|
|
7
|
-
attachments?: ChatAttachmentType[];
|
|
15
|
+
attachments?: ChatAttachmentType[] | null;
|
|
8
16
|
timestamp: string;
|
|
9
17
|
user?: {
|
|
10
18
|
name?: string;
|
|
@@ -14,23 +22,26 @@ export type UserMessageType = {
|
|
|
14
22
|
avatarUrl?: string;
|
|
15
23
|
};
|
|
16
24
|
};
|
|
17
|
-
export type BotMessageType<TData = unknown> = {
|
|
25
|
+
export type BotMessageType<TData = DefaultTextComponentBaseProps | unknown> = {
|
|
18
26
|
id: string;
|
|
19
27
|
type: "FROM_BOT";
|
|
20
|
-
|
|
28
|
+
/**
|
|
29
|
+
* The type is a bot_message literal string or other strings that correspond to the UI responses from AI action calls
|
|
30
|
+
*/
|
|
31
|
+
component: StringOrLiteral<SafeExtract<WidgetLiteralComponentKey, "bot_message">>;
|
|
21
32
|
data: TData;
|
|
22
33
|
timestamp: string;
|
|
23
|
-
original?:
|
|
34
|
+
original?: WidgetHistoryDto;
|
|
24
35
|
agent?: AgentType;
|
|
25
36
|
attachments?: ChatAttachmentType[];
|
|
26
37
|
};
|
|
27
|
-
export type AgentMessageType
|
|
38
|
+
export type AgentMessageType = {
|
|
28
39
|
id: string;
|
|
29
40
|
type: "FROM_AGENT";
|
|
30
|
-
component:
|
|
31
|
-
data:
|
|
41
|
+
component: SafeExtract<WidgetLiteralComponentKey, "agent_message">;
|
|
42
|
+
data: DefaultTextComponentBaseProps;
|
|
32
43
|
timestamp?: string;
|
|
33
|
-
original?:
|
|
44
|
+
original?: WidgetHistoryDto;
|
|
34
45
|
agent?: AgentType;
|
|
35
46
|
attachments?: ChatAttachmentType[];
|
|
36
47
|
};
|