@opencx/widget 2.5.1 → 2.6.1

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 (108) hide show
  1. package/dist/api-BwKgAJ6p.cjs +2 -0
  2. package/dist/api-BwKgAJ6p.cjs.map +1 -0
  3. package/dist/api-DRZ9vPwy.js +1360 -0
  4. package/dist/api-DRZ9vPwy.js.map +1 -0
  5. package/dist/basic.cjs +85 -85
  6. package/dist/basic.cjs.map +1 -1
  7. package/dist/basic.js +13350 -12831
  8. package/dist/basic.js.map +1 -1
  9. package/dist/core/client/api.d.ts +368 -40
  10. package/dist/core/client/chat.d.ts +55 -12
  11. package/dist/core/client/config.d.ts +13 -3
  12. package/dist/core/client/contact.d.ts +3 -13
  13. package/dist/core/errors/index.d.ts +6 -0
  14. package/dist/core/platform/audio.d.ts +38 -0
  15. package/dist/core/platform/index.d.ts +6 -2
  16. package/dist/core/platform/storage.d.ts +8 -2
  17. package/dist/core/sdk/index.d.ts +11 -0
  18. package/dist/core/tests/platform/logger.test.d.ts +1 -0
  19. package/dist/core/tests/platform/storage.test.d.ts +1 -0
  20. package/dist/core/tests/test-utils.d.ts +2 -0
  21. package/dist/core/tests/types/pub-sub.test.d.ts +1 -0
  22. package/dist/core/types/helpers.d.ts +5 -2
  23. package/dist/core/types/index.d.ts +6 -6
  24. package/dist/core/types/messages.d.ts +20 -9
  25. package/dist/core/types/pub-sub.d.ts +1 -0
  26. package/dist/core/types/schemas-v2.d.ts +10 -710
  27. package/dist/index-B5YLfjom.cjs +18 -0
  28. package/dist/index-B5YLfjom.cjs.map +1 -0
  29. package/dist/index-EZN9_jan.js +1219 -0
  30. package/dist/index-EZN9_jan.js.map +1 -0
  31. package/dist/index.cjs +1 -1
  32. package/dist/index.cjs.map +1 -1
  33. package/dist/index.js +22 -874
  34. package/dist/index.js.map +1 -1
  35. package/dist/react-web/core-integration/ChatProvider.d.ts +101 -0
  36. package/dist/react-web/core-integration/components.d.ts +11 -0
  37. package/dist/react-web/core-integration/hooks/useChatMessages.d.ts +64 -0
  38. package/dist/react-web/core-integration/hooks/useChatSession.d.ts +77 -0
  39. package/dist/react-web/core-integration/hooks/useConfig.d.ts +1 -0
  40. package/dist/react-web/core-integration/hooks/useContact.d.ts +11 -0
  41. package/dist/react-web/core-integration/hooks/useLocale.d.ts +4 -0
  42. package/dist/react-web/core-integration/hooks/usePreludeData.d.ts +36 -0
  43. package/dist/react-web/core-integration/hooks/usePubsub.d.ts +2 -0
  44. package/dist/react-web/{hooks → core-integration/hooks}/useUploadFiles.d.ts +2 -2
  45. package/dist/react-web/{hooks → core-integration/hooks}/useVote.d.ts +2 -2
  46. package/dist/react-web/core-integration/hooks.d.ts +9 -0
  47. package/dist/react-web/core-integration/index.d.ts +2 -0
  48. package/dist/react-web/index.d.ts +4 -10
  49. package/dist/react-web/types/components.d.ts +6 -3
  50. package/dist/react-web/types/index.d.ts +3 -2
  51. package/dist/react-web/types/options.d.ts +4 -30
  52. package/dist/react.cjs +1 -1
  53. package/dist/react.cjs.map +1 -1
  54. package/dist/react.js +10 -46
  55. package/dist/react.js.map +1 -1
  56. package/dist/src/@components/BotOrAgentMessageGroup.d.ts +1 -2
  57. package/dist/src/@components/BotOrAgentMessageWrapper.d.ts +2 -2
  58. package/dist/src/@components/ChatEvent.component.d.ts +3 -3
  59. package/dist/src/@components/Text.component.d.ts +1 -1
  60. package/dist/src/components/button.d.ts +1 -1
  61. package/dist/src/components/dialog.d.ts +9 -9
  62. package/dist/src/designs/basic/index.d.ts +1 -1
  63. package/dist/style.css +1 -1
  64. package/dist-embed/script.js +119 -124
  65. package/dist-embed/script.js.map +1 -1
  66. package/package.json +8 -4
  67. package/dist/core/types/schemas.d.ts +0 -543
  68. package/dist/core/utils/create-fetch.d.ts +0 -24
  69. package/dist/core/utils/genId.d.ts +0 -2
  70. package/dist/core/utils/history-to-widget-messages.d.ts +0 -4
  71. package/dist/genUuid-BkZtn1k9.cjs +0 -2
  72. package/dist/genUuid-BkZtn1k9.cjs.map +0 -1
  73. package/dist/genUuid-CDpI3ugS.js +0 -136
  74. package/dist/genUuid-CDpI3ugS.js.map +0 -1
  75. package/dist/index-1bY4_hBw.cjs +0 -18
  76. package/dist/index-1bY4_hBw.cjs.map +0 -1
  77. package/dist/index-D84Xc70r.js +0 -2609
  78. package/dist/index-D84Xc70r.js.map +0 -1
  79. package/dist/package.json.d.ts +0 -157
  80. package/dist/react-web/Root.d.ts +0 -6
  81. package/dist/react-web/hooks/index.d.ts +0 -6
  82. package/dist/react-web/hooks/use-sound.d.ts +0 -13
  83. package/dist/react-web/hooks/useAbstractChat.d.ts +0 -157
  84. package/dist/react-web/hooks/useAxiosInstance.d.ts +0 -190
  85. package/dist/react-web/hooks/useSyncState.d.ts +0 -4
  86. package/dist/react-web/hooks/useTimeoutState.d.ts +0 -3
  87. package/dist/react-web/providers/ChatProvider.d.ts +0 -143
  88. package/dist/react-web/providers/ConfigDataProvider.d.ts +0 -62
  89. package/dist/react-web/providers/ContactProvider.d.ts +0 -58
  90. package/dist/react-web/providers/LocalesProvider.d.ts +0 -11
  91. package/dist/react-web/providers/componentRegistry.d.ts +0 -13
  92. package/dist/react-web/providers/use-widget-sfx.d.ts +0 -7
  93. package/dist/react-web/providers/usePreludeData.d.ts +0 -2
  94. package/dist/react-web/utils/debug.d.ts +0 -2
  95. package/dist/react-web/utils/getters.d.ts +0 -24
  96. package/dist/react-web/utils/index.d.ts +0 -1
  97. package/dist/src/hooks/useShouldCollectData.d.ts +0 -3
  98. /package/dist/core/{utils/genId.test.d.ts → tests/client/integration-perisitance.test.d.ts} +0 -0
  99. /package/dist/{react-web/hooks/use-sound.test.d.ts → core/tests/client/integration.test.d.ts} +0 -0
  100. /package/dist/{react-web/hooks/use-sync-state.test.d.ts → core/tests/platform/audio.test.d.ts} +0 -0
  101. /package/dist/react-web/{locales → core-integration/locales}/ar.locale.d.ts +0 -0
  102. /package/dist/react-web/{locales → core-integration/locales}/de.locale.d.ts +0 -0
  103. /package/dist/react-web/{locales → core-integration/locales}/en.locale.d.ts +0 -0
  104. /package/dist/react-web/{locales → core-integration/locales}/fr.locale.d.ts +0 -0
  105. /package/dist/react-web/{locales → core-integration/locales}/helper.d.ts +0 -0
  106. /package/dist/react-web/{locales → core-integration/locales}/index.d.ts +0 -0
  107. /package/dist/react-web/{locales → core-integration/locales}/nl.locale.d.ts +0 -0
  108. /package/dist/react-web/{locales → core-integration/locales}/pt.locale.d.ts +0 -0
@@ -0,0 +1,11 @@
1
+ import { Middleware } from 'openapi-fetch';
2
+ import { paths, components } from './schema';
3
+ type Options = {
4
+ baseUrl: string;
5
+ onRequest?: Middleware['onRequest'];
6
+ onResponse?: Middleware['onResponse'];
7
+ onError?: Middleware['onError'];
8
+ };
9
+ export declare const basicClient: (options: Options) => import('openapi-fetch').Client<paths, `${string}/${string}`>;
10
+ export type Dto = components['schemas'];
11
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import { User } from '../types';
2
+ export declare function getTestUser(): User;
@@ -0,0 +1 @@
1
+ export {};
@@ -6,12 +6,15 @@ export type MakeKeysNotNullable<T, K extends keyof T> = Omit<T, K> & {
6
6
  export type LoadingReason = 'sending_message_to_bot' | 'sending_message_to_agent' | 'creating_session' | 'polling' | 'loading_contact' | 'saving_contact' | 'cleaning_up' | null;
7
7
  export type LoadingState = {
8
8
  isLoading: boolean;
9
- reason?: LoadingReason;
9
+ reason: LoadingReason;
10
10
  };
11
- export type ErrorCode = 'SESSION_CREATION_FAILED' | 'SESSION_CLEAR_FAILED' | 'SESSION_PERSISTENCE_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';
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
  };
@@ -19,6 +19,7 @@ export declare class PubSub<S> {
19
19
  private lifecycleListeners;
20
20
  constructor(state: S);
21
21
  private emitLifecycle;
22
+ private notifySubscribers;
22
23
  /**
23
24
  * Subscribe to state changes
24
25
  * @param callback Function to call when state changes