@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
@@ -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 { AgentType, ChatAttachmentType, ChatHistoryMessageType } from './schemas';
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
- component: string;
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?: ChatHistoryMessageType;
34
+ original?: WidgetHistoryDto;
24
35
  agent?: AgentType;
25
36
  attachments?: ChatAttachmentType[];
26
37
  };
27
- export type AgentMessageType<TData = unknown> = {
38
+ export type AgentMessageType = {
28
39
  id: string;
29
40
  type: "FROM_AGENT";
30
- component: string;
31
- data: TData;
41
+ component: SafeExtract<WidgetLiteralComponentKey, "agent_message">;
42
+ data: DefaultTextComponentBaseProps;
32
43
  timestamp?: string;
33
- original?: ChatHistoryMessageType;
44
+ original?: WidgetHistoryDto;
34
45
  agent?: AgentType;
35
46
  attachments?: ChatAttachmentType[];
36
47
  };