@opencx/widget 2.6.3 → 3.0.0

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 (155) hide show
  1. package/dist/basic.cjs +89 -89
  2. package/dist/basic.cjs.map +1 -1
  3. package/dist/basic.d.ts +1 -1
  4. package/dist/basic.js +34083 -34125
  5. package/dist/basic.js.map +1 -1
  6. package/dist/index.cjs +1 -1
  7. package/dist/index.d.ts +1 -1
  8. package/dist/index.js +3 -22
  9. package/dist/react.cjs +1 -1
  10. package/dist/react.cjs.map +1 -1
  11. package/dist/react.d.ts +1 -1
  12. package/dist/react.js +20 -10
  13. package/dist/react.js.map +1 -1
  14. package/dist/src/designs/react/basic/index.d.ts +10 -0
  15. package/dist/src/designs/{basic → react/basic}/utils/group-messages-by-type.d.ts +1 -1
  16. package/dist/src/{@components → designs/react/components}/BotOrAgentMessage.d.ts +1 -1
  17. package/dist/src/{@components → designs/react/components}/BotOrAgentMessageGroup.d.ts +2 -2
  18. package/dist/src/designs/react/components/BotOrAgentMessageWrapper.d.ts +7 -0
  19. package/dist/src/{@components → designs/react/components}/Fallback.component.d.ts +2 -2
  20. package/dist/src/{components → designs/react/components}/RenderFile.d.ts +2 -2
  21. package/dist/src/{@components → designs/react/components}/Text.component.d.ts +1 -1
  22. package/dist/src/{components → designs/react/components}/UserMessageGroup.d.ts +1 -1
  23. package/dist/src/{components → designs/react/components}/VoteButtons.d.ts +1 -1
  24. package/dist/src/designs/{constants.d.ts → react/constants.d.ts} +2 -4
  25. package/dist/src/designs/react/hooks/useLocale.d.ts +6 -0
  26. package/dist/src/{index.d.ts → designs/react/index.d.ts} +2 -2
  27. package/dist/src/designs/translation/ar.locale.d.ts +2 -0
  28. package/dist/src/designs/translation/de.locale.d.ts +2 -0
  29. package/dist/src/designs/translation/en.locale.d.ts +2 -0
  30. package/dist/src/designs/translation/fr.locale.d.ts +2 -0
  31. package/dist/src/designs/translation/index.d.ts +14 -0
  32. package/dist/src/designs/translation/nl.locale.d.ts +2 -0
  33. package/dist/src/designs/translation/pt.locale.d.ts +2 -0
  34. package/dist/src/designs/translation/translation.types.d.ts +4 -0
  35. package/dist/{core/client → src/headless/core}/api.d.ts +49 -103
  36. package/dist/src/headless/core/context/contact.d.ts +25 -0
  37. package/dist/src/headless/core/context/message.d.ts +40 -0
  38. package/dist/src/headless/core/context/session.d.ts +74 -0
  39. package/dist/src/headless/core/context/widget.d.ts +16 -0
  40. package/dist/src/headless/core/index.d.ts +7 -0
  41. package/dist/src/headless/core/types/WidgetConfig.d.ts +34 -0
  42. package/dist/src/headless/core/types/agent-or-bot.d.ts +6 -0
  43. package/dist/src/headless/core/types/helpers.d.ts +4 -0
  44. package/dist/{core → src/headless/core}/types/messages.d.ts +11 -31
  45. package/dist/src/headless/core/types/schemas.d.ts +9 -0
  46. package/dist/src/headless/core/utils/Poller.d.ts +12 -0
  47. package/dist/{core/types/pub-sub.d.ts → src/headless/core/utils/PubSub.d.ts} +6 -9
  48. package/dist/{react-web/core-integration/components.d.ts → src/headless/react/ComponentRegistry.d.ts} +1 -1
  49. package/dist/src/headless/react/WidgetProvider.d.ts +17 -0
  50. package/dist/src/headless/react/hooks/useConfig.d.ts +1 -0
  51. package/dist/src/headless/react/hooks/useContact.d.ts +10 -0
  52. package/dist/src/headless/react/hooks/useIsAwaitingBotReply.d.ts +3 -0
  53. package/dist/src/headless/react/hooks/useMessages.d.ts +8 -0
  54. package/dist/{react-web/core-integration → src/headless/react}/hooks/usePreludeData.d.ts +2 -2
  55. package/dist/{react-web/core-integration → src/headless/react}/hooks/usePubsub.d.ts +1 -1
  56. package/dist/src/headless/react/hooks/useSession.d.ts +6 -0
  57. package/dist/{react-web/core-integration → src/headless/react}/hooks/useVote.d.ts +2 -2
  58. package/dist/src/headless/react/index.d.ts +11 -0
  59. package/dist/src/headless/react/types/components.d.ts +15 -0
  60. package/dist/style.css +1 -1
  61. package/dist/useUploadFiles-BZa0DENN.cjs +18 -0
  62. package/dist/useUploadFiles-BZa0DENN.cjs.map +1 -0
  63. package/dist/useUploadFiles-BaCcqTwX.js +1336 -0
  64. package/dist/useUploadFiles-BaCcqTwX.js.map +1 -0
  65. package/dist/widget-BlvH6dre.cjs +2 -0
  66. package/dist/widget-BlvH6dre.cjs.map +1 -0
  67. package/dist/widget-DbgWez1r.js +514 -0
  68. package/dist/widget-DbgWez1r.js.map +1 -0
  69. package/dist-embed/script.js +120 -140
  70. package/dist-embed/script.js.map +1 -1
  71. package/package.json +9 -4
  72. package/dist/api-CAm3rFZk.js +0 -1070
  73. package/dist/api-CAm3rFZk.js.map +0 -1
  74. package/dist/api-oIDR-KZx.cjs +0 -2
  75. package/dist/api-oIDR-KZx.cjs.map +0 -1
  76. package/dist/core/client/chat.d.ts +0 -101
  77. package/dist/core/client/config.d.ts +0 -43
  78. package/dist/core/client/contact.d.ts +0 -29
  79. package/dist/core/client/index.d.ts +0 -4
  80. package/dist/core/errors/index.d.ts +0 -27
  81. package/dist/core/index.d.ts +0 -9
  82. package/dist/core/platform/audio.d.ts +0 -38
  83. package/dist/core/platform/index.d.ts +0 -15
  84. package/dist/core/platform/logger.d.ts +0 -14
  85. package/dist/core/platform/storage.d.ts +0 -52
  86. package/dist/core/tests/platform/logger.test.d.ts +0 -1
  87. package/dist/core/tests/platform/storage.test.d.ts +0 -1
  88. package/dist/core/tests/test-utils.d.ts +0 -2
  89. package/dist/core/tests/types/pub-sub.test.d.ts +0 -1
  90. package/dist/core/types/contact.d.ts +0 -2
  91. package/dist/core/types/helpers.d.ts +0 -20
  92. package/dist/core/types/index.d.ts +0 -52
  93. package/dist/core/types/prelude.d.ts +0 -14
  94. package/dist/core/types/schemas-v2.d.ts +0 -10
  95. package/dist/index-CSptf_Dw.cjs +0 -18
  96. package/dist/index-CSptf_Dw.cjs.map +0 -1
  97. package/dist/index-cUkS-tdv.js +0 -1232
  98. package/dist/index-cUkS-tdv.js.map +0 -1
  99. package/dist/react-web/core-integration/ChatProvider.d.ts +0 -107
  100. package/dist/react-web/core-integration/hooks/useChatMessages.d.ts +0 -70
  101. package/dist/react-web/core-integration/hooks/useChatSession.d.ts +0 -83
  102. package/dist/react-web/core-integration/hooks/useConfig.d.ts +0 -1
  103. package/dist/react-web/core-integration/hooks/useContact.d.ts +0 -17
  104. package/dist/react-web/core-integration/hooks/useLocale.d.ts +0 -4
  105. package/dist/react-web/core-integration/hooks.d.ts +0 -9
  106. package/dist/react-web/core-integration/index.d.ts +0 -2
  107. package/dist/react-web/core-integration/locales/ar.locale.d.ts +0 -2
  108. package/dist/react-web/core-integration/locales/de.locale.d.ts +0 -2
  109. package/dist/react-web/core-integration/locales/en.locale.d.ts +0 -55
  110. package/dist/react-web/core-integration/locales/fr.locale.d.ts +0 -2
  111. package/dist/react-web/core-integration/locales/helper.d.ts +0 -65
  112. package/dist/react-web/core-integration/locales/index.d.ts +0 -3
  113. package/dist/react-web/core-integration/locales/nl.locale.d.ts +0 -2
  114. package/dist/react-web/core-integration/locales/pt.locale.d.ts +0 -2
  115. package/dist/react-web/hooks/useScrollTo.d.ts +0 -2
  116. package/dist/react-web/index.d.ts +0 -4
  117. package/dist/react-web/types/components.d.ts +0 -13
  118. package/dist/react-web/types/index.d.ts +0 -8
  119. package/dist/react-web/types/options.d.ts +0 -17
  120. package/dist/src/@components/BotOrAgentMessageWrapper.d.ts +0 -9
  121. package/dist/src/@components/ChatEvent.component.d.ts +0 -9
  122. package/dist/src/@components/index.d.ts +0 -6
  123. package/dist/src/designs/basic/index.d.ts +0 -8
  124. /package/dist/src/designs/{basic → react/basic}/WidgetPopoverTrigger.d.ts +0 -0
  125. /package/dist/src/designs/{basic → react/basic}/screens/chat-screen/ChatFooter.d.ts +0 -0
  126. /package/dist/src/designs/{basic → react/basic}/screens/chat-screen/ChatHeader.d.ts +0 -0
  127. /package/dist/src/designs/{basic → react/basic}/screens/chat-screen/ChatMain.d.ts +0 -0
  128. /package/dist/src/designs/{basic → react/basic}/screens/chat-screen/ChatScreen.d.ts +0 -0
  129. /package/dist/src/designs/{basic → react/basic}/screens/root-screen.d.ts +0 -0
  130. /package/dist/src/designs/{basic → react/basic}/screens/welcome-screen/WelcomeScreen.d.ts +0 -0
  131. /package/dist/{core/tests/client/integration-perisitance.test.d.ts → src/designs/react/basic/widget-interaction-tests/widget.test.d.ts} +0 -0
  132. /package/dist/src/{@components → designs/react/components}/Loading.component.d.ts +0 -0
  133. /package/dist/src/{@components → designs/react/components}/OpenLogoSvg.d.ts +0 -0
  134. /package/dist/src/{components → designs/react/components}/keyboard.d.ts +0 -0
  135. /package/dist/src/{components → designs/react/components/lib}/MotionDiv.d.ts +0 -0
  136. /package/dist/src/{components → designs/react/components/lib}/avatar.d.ts +0 -0
  137. /package/dist/src/{components → designs/react/components/lib}/button.d.ts +0 -0
  138. /package/dist/src/{components → designs/react/components/lib}/dialog.d.ts +0 -0
  139. /package/dist/src/{components → designs/react/components/lib}/dropdown-menu.d.ts +0 -0
  140. /package/dist/src/{components → designs/react/components/lib}/input.d.ts +0 -0
  141. /package/dist/src/{components → designs/react/components/lib}/popover.d.ts +0 -0
  142. /package/dist/src/{components → designs/react/components/lib}/skeleton.d.ts +0 -0
  143. /package/dist/src/{components → designs/react/components/lib}/switch.d.ts +0 -0
  144. /package/dist/src/{components → designs/react/components/lib}/tooltip.d.ts +0 -0
  145. /package/dist/src/{utils.d.ts → designs/react/components/lib/utils/cn.d.ts} +0 -0
  146. /package/dist/src/{components → designs/react/components/lib}/wobble.d.ts +0 -0
  147. /package/dist/src/{@components → designs/react/components}/markdown.d.ts +0 -0
  148. /package/dist/{react-web → src/designs/react}/hooks/useWidgetContentHeight.d.ts +0 -0
  149. /package/dist/src/{render.d.ts → designs/react/render.d.ts} +0 -0
  150. /package/dist/{core → src/headless/core}/sdk/index.d.ts +0 -0
  151. /package/dist/{core/tests/client/integration.test.d.ts → src/headless/core/utils/PubSub.test.d.ts} +0 -0
  152. /package/dist/{core/utils/genUuid.d.ts → src/headless/core/utils/uuid.d.ts} +0 -0
  153. /package/dist/{react-web/core-integration → src/headless/react}/hooks/useUploadFiles.d.ts +0 -0
  154. /package/dist/{react-web → src/headless/react}/utils/create-safe-context.d.ts +0 -0
  155. /package/dist/{core/tests/platform/audio.test.d.ts → vitest/setup.d.ts} +0 -0
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./api-oIDR-KZx.cjs");exports.ApiCaller=r.ApiCaller;exports.AuthenticationError=r.AuthenticationError;exports.ConnectionError=r.ConnectionError;exports.ExternalIdNotDefinedError=r.ExternalIdNotDefinedError;exports.FileUploadError=r.FileUploadError;exports.LifecycleEvent=r.LifecycleEvent;exports.OpenCXError=r.OpenCXError;exports.PubSub=r.PubSub;exports.SessionError=r.SessionError;exports.SessionNotDefinedError=r.SessionNotDefinedError;exports.StorageNotAvailableError=r.StorageNotAvailableError;exports.TransportError=r.TransportError;exports.createChat=r.createChat;exports.createConfig=r.createConfig;exports.createContactHandler=r.createContactHandler;exports.createLogger=r.createLogger;exports.createPubSub=r.createPubSub;exports.isAudioAvailable=r.isAudioAvailable;exports.isStorageAvailable=r.isStorageAvailable;exports.safeAudioOperation=r.safeAudioOperation;exports.safeStorageOperation=r.safeStorageOperation;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./widget-BlvH6dre.cjs");exports.PubSub=e.PubSub;exports.WidgetCtx=e.WidgetCtx;
2
2
  //# sourceMappingURL=index.cjs.map
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './core/index'
1
+ export * from './src/headless/core/index'
2
2
  export {}
package/dist/index.js CHANGED
@@ -1,25 +1,6 @@
1
- import { A as e, e as o, C as s, E as t, F as i, L as n, O as l, P as E, S as c, f as b, g as d, T as f, c as A, b as S, a as g, d as p, h as u, j as C, i as v, k as O, s as h } from "./api-CAm3rFZk.js";
1
+ import { P as b, W as e } from "./widget-DbgWez1r.js";
2
2
  export {
3
- e as ApiCaller,
4
- o as AuthenticationError,
5
- s as ConnectionError,
6
- t as ExternalIdNotDefinedError,
7
- i as FileUploadError,
8
- n as LifecycleEvent,
9
- l as OpenCXError,
10
- E as PubSub,
11
- c as SessionError,
12
- b as SessionNotDefinedError,
13
- d as StorageNotAvailableError,
14
- f as TransportError,
15
- A as createChat,
16
- S as createConfig,
17
- g as createContactHandler,
18
- p as createLogger,
19
- u as createPubSub,
20
- C as isAudioAvailable,
21
- v as isStorageAvailable,
22
- O as safeAudioOperation,
23
- h as safeStorageOperation
3
+ b as PubSub,
4
+ e as WidgetCtx
24
5
  };
25
6
  //# sourceMappingURL=index.js.map
package/dist/react.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CSptf_Dw.cjs");exports.ChatProvider=e.ChatProvider;exports.useChat=e.useChat;exports.useChatSession=e.useChatSession;exports.useChatState=e.useChatState;exports.useConfig=e.useConfig;exports.useContact=e.useContact;exports.useLocale=e.useLocale;exports.usePreludeData=e.usePreludeData;exports.useUploadFiles=e.useUploadFiles;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./useUploadFiles-BZa0DENN.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.usePubsub=e.usePubsub;exports.useSession=e.useSession;exports.useUploadFiles=e.useUploadFiles;exports.useWidget=e.useWidget;exports.useVote=a;
2
2
  //# sourceMappingURL=react.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"react.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
1
+ {"version":3,"file":"react.cjs","sources":["../src/headless/react/hooks/useVote.ts"],"sourcesContent":["import useAsyncFn from \"react-use/lib/useAsyncFn\";\nimport { useWidget } from \"../WidgetProvider\";\n\n/**\n * @param id\n * @param onSuccess\n * @returns\n */\nexport function useVote(id: string, sessionId: string, onSuccess?: () => void) {\n const { widgetCtx: { api } } = useWidget();\n return useAsyncFn(\n async (action: \"up\" | \"down\") => {\n if (action === \"up\") {\n return api\n .vote({ action: \"upvote\", messagePublicId: id, sessionId })\n .then(onSuccess);\n } else {\n return api\n .vote({ action: \"downvote\", messagePublicId: id, sessionId })\n .then(onSuccess);\n }\n },\n [api, id, sessionId, onSuccess],\n );\n}\n\n/**\n * @param id\n * @param onSuccess\n * @deprecated use useVote instead\n */\nexport function useUpvote(\n id: string,\n sessionId: string,\n onSuccess?: () => void,\n) {\n const { widgetCtx: { api } } = useWidget();\n return useAsyncFn(\n async () =>\n api\n .vote({ action: \"upvote\", messagePublicId: id, sessionId })\n .then(onSuccess),\n [api, id, sessionId, onSuccess],\n );\n}\n\n/**\n * @param id\n * @param onSuccess\n * @deprecated use useVote instead\n */\nexport function useDownvote(\n id: string,\n sessionId: string,\n onSuccess?: () => void,\n) {\n const { widgetCtx: { api } } = useWidget();\n return useAsyncFn(\n async () =>\n api\n .vote({ action: \"downvote\", messagePublicId: id, sessionId })\n .then(onSuccess),\n [api, id, sessionId, onSuccess],\n );\n}\n"],"names":["useVote","id","sessionId","onSuccess","api","useWidget","useAsyncFn","action"],"mappings":"iIAQgB,SAAAA,EAAQC,EAAYC,EAAmBC,EAAwB,CAC7E,KAAM,CAAE,UAAW,CAAE,IAAAC,CAAI,GAAMC,EAAU,UAAA,EAClC,OAAAC,EAAA,SACL,MAAOC,GACDA,IAAW,KACNH,EACJ,KAAK,CAAE,OAAQ,SAAU,gBAAiBH,EAAI,UAAAC,CAAW,CAAA,EACzD,KAAKC,CAAS,EAEVC,EACJ,KAAK,CAAE,OAAQ,WAAY,gBAAiBH,EAAI,UAAAC,CAAW,CAAA,EAC3D,KAAKC,CAAS,EAGrB,CAACC,EAAKH,EAAIC,EAAWC,CAAS,CAAA,CAElC"}
package/dist/react.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './react-web/index'
1
+ export * from './src/headless/react/index'
2
2
  export {}
package/dist/react.js CHANGED
@@ -1,13 +1,23 @@
1
- import { C as e, u as t, b as u, a as o, c as C, f as r, e as d, d as h, g as i } from "./index-cUkS-tdv.js";
1
+ import { u as o, _ as r } from "./useUploadFiles-BaCcqTwX.js";
2
+ import { W as p, a as d, b as f, c as b, d as c, e as m, f as v, g as P, h } from "./useUploadFiles-BaCcqTwX.js";
3
+ function n(e, t, s) {
4
+ const { widgetCtx: { api: a } } = o();
5
+ return r(
6
+ async (u) => u === "up" ? a.vote({ action: "upvote", messagePublicId: e, sessionId: t }).then(s) : a.vote({ action: "downvote", messagePublicId: e, sessionId: t }).then(s),
7
+ [a, e, t, s]
8
+ );
9
+ }
2
10
  export {
3
- e as ChatProvider,
4
- t as useChat,
5
- u as useChatSession,
6
- o as useChatState,
7
- C as useConfig,
8
- r as useContact,
9
- d as useLocale,
10
- h as usePreludeData,
11
- i as useUploadFiles
11
+ p as WidgetProvider,
12
+ d as useConfig,
13
+ f as useContact,
14
+ b as useIsAwaitingBotReply,
15
+ c as useMessages,
16
+ m as usePreludeData,
17
+ v as usePubsub,
18
+ P as useSession,
19
+ h as useUploadFiles,
20
+ n as useVote,
21
+ o as useWidget
12
22
  };
13
23
  //# sourceMappingURL=react.js.map
package/dist/react.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"react.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"react.js","sources":["../src/headless/react/hooks/useVote.ts"],"sourcesContent":["import useAsyncFn from \"react-use/lib/useAsyncFn\";\nimport { useWidget } from \"../WidgetProvider\";\n\n/**\n * @param id\n * @param onSuccess\n * @returns\n */\nexport function useVote(id: string, sessionId: string, onSuccess?: () => void) {\n const { widgetCtx: { api } } = useWidget();\n return useAsyncFn(\n async (action: \"up\" | \"down\") => {\n if (action === \"up\") {\n return api\n .vote({ action: \"upvote\", messagePublicId: id, sessionId })\n .then(onSuccess);\n } else {\n return api\n .vote({ action: \"downvote\", messagePublicId: id, sessionId })\n .then(onSuccess);\n }\n },\n [api, id, sessionId, onSuccess],\n );\n}\n\n/**\n * @param id\n * @param onSuccess\n * @deprecated use useVote instead\n */\nexport function useUpvote(\n id: string,\n sessionId: string,\n onSuccess?: () => void,\n) {\n const { widgetCtx: { api } } = useWidget();\n return useAsyncFn(\n async () =>\n api\n .vote({ action: \"upvote\", messagePublicId: id, sessionId })\n .then(onSuccess),\n [api, id, sessionId, onSuccess],\n );\n}\n\n/**\n * @param id\n * @param onSuccess\n * @deprecated use useVote instead\n */\nexport function useDownvote(\n id: string,\n sessionId: string,\n onSuccess?: () => void,\n) {\n const { widgetCtx: { api } } = useWidget();\n return useAsyncFn(\n async () =>\n api\n .vote({ action: \"downvote\", messagePublicId: id, sessionId })\n .then(onSuccess),\n [api, id, sessionId, onSuccess],\n );\n}\n"],"names":["useVote","id","sessionId","onSuccess","api","useWidget","useAsyncFn","action"],"mappings":";;AAQgB,SAAAA,EAAQC,GAAYC,GAAmBC,GAAwB;AAC7E,QAAM,EAAE,WAAW,EAAE,KAAAC,EAAI,MAAMC,EAAU;AAClC,SAAAC;AAAAA,IACL,OAAOC,MACDA,MAAW,OACNH,EACJ,KAAK,EAAE,QAAQ,UAAU,iBAAiBH,GAAI,WAAAC,EAAW,CAAA,EACzD,KAAKC,CAAS,IAEVC,EACJ,KAAK,EAAE,QAAQ,YAAY,iBAAiBH,GAAI,WAAAC,EAAW,CAAA,EAC3D,KAAKC,CAAS;AAAA,IAGrB,CAACC,GAAKH,GAAIC,GAAWC,CAAS;AAAA,EAAA;AAElC;"}
@@ -0,0 +1,10 @@
1
+ import { default as React, ComponentPropsWithoutRef, ReactNode } from 'react';
2
+ import { WidgetConfig } from 'src/headless/core';
3
+ declare function Widget({ className, opened, ...props }: ComponentPropsWithoutRef<"div"> & {
4
+ opened?: boolean;
5
+ }): React.JSX.Element;
6
+ declare function WidgetRoot({ options, children, }: {
7
+ options: WidgetConfig;
8
+ children: ReactNode;
9
+ }): React.JSX.Element;
10
+ export { WidgetRoot, Widget };
@@ -1,4 +1,4 @@
1
- import { AgentMessageType, BotMessageType, MessageType, UserMessageType } from '../../../../core/types';
1
+ import { AgentMessageType, BotMessageType, MessageType, UserMessageType } from 'src/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[];
@@ -1,4 +1,4 @@
1
- import { AgentMessageType, BotMessageType } from '../../core/types';
1
+ import { AgentMessageType, BotMessageType } from 'src/headless/core';
2
2
  import { default as React } from 'react';
3
3
  interface BotMessageProps<W extends React.ElementType> {
4
4
  message: BotMessageType | AgentMessageType;
@@ -1,6 +1,6 @@
1
- import { AgentMessageType, AgentType, BotMessageType } from '../../core/types';
1
+ import { AgentMessageType, AgentOrBotType, BotMessageType } from 'src/headless/core';
2
2
  import { default as React } from 'react';
3
3
  export declare function BotOrAgentMessageGroup({ messages, agent, }: {
4
4
  messages: BotMessageType[] | AgentMessageType[];
5
- agent: AgentType | undefined;
5
+ agent: AgentOrBotType | undefined;
6
6
  }): React.JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { default as React } from 'react';
2
+ export declare function BotOrAgentMessageWrapper({ children, className, messageId, }: {
3
+ children: React.ReactNode;
4
+ className?: string;
5
+ messageId?: string;
6
+ sessionId?: string;
7
+ }): React.JSX.Element;
@@ -1,6 +1,6 @@
1
- import { ComponentProps } from '../../react-web/types';
2
1
  import { default as React } from 'react';
3
- type Props = ComponentProps<unknown>;
2
+ import { WidgetComponentProps } from 'src/headless/react/types/components';
3
+ type Props = WidgetComponentProps<unknown>;
4
4
  /**
5
5
  * The Basic Fallback component (Rendered when Debug is True and the component key is not found)
6
6
  */
@@ -1,7 +1,7 @@
1
- import { ChatAttachmentType } from '../../core/types';
1
+ import { MessageAttachmentType } from 'src/headless/core';
2
2
  import { default as React } from 'react';
3
3
  type Props = {
4
- attachment: ChatAttachmentType;
4
+ attachment: MessageAttachmentType;
5
5
  };
6
6
  export declare function RenderAttachment({ attachment }: Props): React.JSX.Element;
7
7
  export {};
@@ -1,3 +1,3 @@
1
1
  import { default as React } from 'react';
2
- import { DefaultTextComponentProps } from '../../react-web/types';
2
+ import { DefaultTextComponentProps } from 'src/headless/react/types/components';
3
3
  export declare function BotOrAgentTextResponse({ data, id, type, attachments, }: DefaultTextComponentProps): React.JSX.Element;
@@ -1,4 +1,4 @@
1
- import { UserMessageType } from '../../core/types';
1
+ import { UserMessageType } from 'src/headless/core';
2
2
  import { default as React } from 'react';
3
3
  export declare function UserMessageGroup({ messages, }: {
4
4
  messages: UserMessageType[];
@@ -4,5 +4,5 @@ interface VoteButtonsProps {
4
4
  sessionId: string;
5
5
  className?: string;
6
6
  }
7
- export declare function VoteButtons({ messageId, sessionId, className }: VoteButtonsProps): React.JSX.Element;
7
+ export declare function VoteButtons({ messageId, sessionId, className, }: VoteButtonsProps): React.JSX.Element;
8
8
  export {};
@@ -7,9 +7,7 @@ export declare const DEFAULT_STYLES: {
7
7
  readonly widgetHeight: "h-[600px]";
8
8
  };
9
9
  interface Colors {
10
- primary: string;
10
+ primary?: string;
11
11
  }
12
- export declare const cssVars: (colors: Colors, _: {
13
- triggerOffset: string;
14
- }) => CSSProperties;
12
+ export declare const cssVars: ({ primary }: Colors) => CSSProperties;
15
13
  export {};
@@ -0,0 +1,6 @@
1
+ import { TranslationKeysU } from 'src/designs/translation/translation.types';
2
+ import { Locale } from 'src/designs/translation';
3
+ export declare function useLocale(): {
4
+ get: (key: TranslationKeysU) => string;
5
+ lang: Locale;
6
+ };
@@ -1,9 +1,9 @@
1
- import { WidgetOptions } from '../react-web/types';
1
+ import { WidgetConfig } from 'src/headless/core';
2
2
  declare global {
3
3
  interface Window {
4
4
  initOpenScript: typeof initOpenScript;
5
5
  openCXWidgetVersion: string;
6
6
  }
7
7
  }
8
- declare function initOpenScript(options: WidgetOptions): void;
8
+ declare function initOpenScript(options: WidgetConfig): void;
9
9
  export {};
@@ -0,0 +1,2 @@
1
+ import { TranslationInterface } from './translation.types';
2
+ export declare const arLocale: TranslationInterface;
@@ -0,0 +1,2 @@
1
+ import { TranslationInterface } from './translation.types';
2
+ export declare const deLocale: TranslationInterface;
@@ -0,0 +1,2 @@
1
+ import { TranslationInterface } from './translation.types';
2
+ export declare const enLocale: TranslationInterface;
@@ -0,0 +1,2 @@
1
+ import { TranslationInterface } from './translation.types';
2
+ export declare const frLocale: TranslationInterface;
@@ -0,0 +1,14 @@
1
+ import { TranslationKeysU } from './translation.types';
2
+ declare const locales: {
3
+ readonly en: import('./translation.types').TranslationInterface;
4
+ readonly ar: import('./translation.types').TranslationInterface;
5
+ readonly nl: import('./translation.types').TranslationInterface;
6
+ readonly fr: import('./translation.types').TranslationInterface;
7
+ readonly de: import('./translation.types').TranslationInterface;
8
+ readonly pt: import('./translation.types').TranslationInterface;
9
+ };
10
+ export declare const LOCALES: (keyof typeof locales)[];
11
+ export type Locale = (typeof LOCALES)[number];
12
+ export declare const isSupportedLocale: (lang: string | null | undefined) => lang is Locale;
13
+ export declare function getTranslation(key: TranslationKeysU, lang: Locale): string;
14
+ export {};
@@ -0,0 +1,2 @@
1
+ import { TranslationInterface } from './translation.types';
2
+ export declare const nlLocale: TranslationInterface;
@@ -0,0 +1,2 @@
1
+ import { TranslationInterface } from './translation.types';
2
+ export declare const ptLocale: TranslationInterface;
@@ -0,0 +1,4 @@
1
+ export type TranslationKeysU = "ok" | "yes" | "no" | "agree" | "cancel" | "yes-exit" | "yes-reset" | "no-cancel" | "are-you-sure" | "recording" | "thank-you" | "sorry-try-again" | "error-occurred" | "please-try-again" | "write-a-message" | "send-message" | "connected" | "connecting" | "reconnecting" | "reconnected" | "disconnecting" | "disconnected" | "error" | "persist-session" | "settings" | "close" | "help" | "chat" | "send" | "copy" | "copied" | "sound-effects" | "language" | "select" | "agent" | "user" | "bot" | "reset-conversation-confirm" | "close-widget" | "got-any-questions" | "typical-response-time" | "session-closed-lead" | "create-new-ticket" | "exit" | "reset-conversation" | "welcome-title" | "welcome-description" | "your-name" | "your-email" | "start-chat" | "starting-chat" | "hello-greeting";
2
+ export type TranslationInterface = {
3
+ [K in TranslationKeysU]: string;
4
+ };
@@ -1,81 +1,18 @@
1
- import { User } from '../types';
2
- import { SendChatDto, WidgetVoteDto } from '../types/schemas-v2';
3
- import { NormalizedConfig } from './config';
4
- import { Dto } from '../sdk';
5
- import { AxiosInstance, AxiosRequestConfig } from 'axios';
6
- export interface ApiCallerOptions {
7
- config: NormalizedConfig;
8
- }
1
+ import { AxiosRequestConfig } from 'axios';
2
+ import { Dto } from './sdk';
3
+ import { WidgetConfig } from './types/WidgetConfig';
4
+ import { SendMessageDto, VoteInputDto } from './types/schemas';
9
5
  export declare class ApiCaller {
10
- #private;
11
- private readonly options;
12
- constructor(options: ApiCallerOptions);
13
- constructClientOptions: (user: User) => {
14
- baseUrl: string;
15
- headers: {
16
- "X-Bot-Token": string;
17
- "X-Consumer-Id": string;
18
- "Content-Type": string;
19
- Accept: string;
20
- Authorization: string | undefined;
21
- };
22
- };
23
- createOpenAPIClient: ({ baseUrl, headers, }: ReturnType<typeof this.constructClientOptions>) => import('openapi-fetch').Client<import('../sdk/schema').paths, `${string}/${string}`>;
24
- createAxiosUploadClient: ({ baseUrl, headers, }: ReturnType<typeof this.constructClientOptions>) => AxiosInstance;
25
- setUser: (user: User) => void;
26
- me: () => Promise<import('openapi-fetch').FetchResponse<{
27
- parameters: {
28
- query?: never;
29
- header?: never;
30
- path?: never;
31
- cookie?: never;
32
- };
33
- requestBody?: never;
34
- responses: {
35
- 200: {
36
- headers: {
37
- [name: string]: unknown;
38
- };
39
- content: {
40
- "application/json": import('../sdk/schema').components["schemas"]["WidgetContactDto"];
41
- };
42
- };
43
- 500: {
44
- headers: {
45
- [name: string]: unknown;
46
- };
47
- content: {
48
- "application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
49
- };
50
- };
51
- };
52
- }, import('openapi-fetch').FetchOptions<{
53
- parameters: {
54
- query?: never;
55
- header?: never;
56
- path?: never;
57
- cookie?: never;
58
- };
59
- requestBody?: never;
60
- responses: {
61
- 200: {
62
- headers: {
63
- [name: string]: unknown;
64
- };
65
- content: {
66
- "application/json": import('../sdk/schema').components["schemas"]["WidgetContactDto"];
67
- };
68
- };
69
- 500: {
70
- headers: {
71
- [name: string]: unknown;
72
- };
73
- content: {
74
- "application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
75
- };
76
- };
77
- };
78
- }> | undefined, `${string}/${string}`>>;
6
+ private client;
7
+ private uploadFileClient;
8
+ private config;
9
+ constructor({ config, }: {
10
+ config: WidgetConfig;
11
+ });
12
+ private constructClientOptions;
13
+ private createOpenAPIClient;
14
+ private createAxiosUploadClient;
15
+ setAuthToken: (token: string) => void;
79
16
  widgetPrelude: () => Promise<import('openapi-fetch').FetchResponse<{
80
17
  parameters: {
81
18
  query?: never;
@@ -92,7 +29,7 @@ export declare class ApiCaller {
92
29
  [name: string]: unknown;
93
30
  };
94
31
  content: {
95
- "application/json": import('../sdk/schema').components["schemas"]["WidgetPreludeDto"];
32
+ "application/json": import('./sdk/schema').components["schemas"]["WidgetPreludeDto"];
96
33
  };
97
34
  };
98
35
  500: {
@@ -100,7 +37,7 @@ export declare class ApiCaller {
100
37
  [name: string]: unknown;
101
38
  };
102
39
  content: {
103
- "application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
40
+ "application/json": import('./sdk/schema').components["schemas"]["ErrorDto"];
104
41
  };
105
42
  };
106
43
  };
@@ -111,7 +48,7 @@ export declare class ApiCaller {
111
48
  };
112
49
  };
113
50
  }, `${string}/${string}`>>;
114
- handleMessage: (body: SendChatDto, abortSignal?: AbortSignal) => Promise<import('openapi-fetch').FetchResponse<{
51
+ sendMessage: (body: SendMessageDto, abortSignal?: AbortSignal) => Promise<import('openapi-fetch').FetchResponse<{
115
52
  parameters: {
116
53
  query?: never;
117
54
  header?: never;
@@ -120,7 +57,7 @@ export declare class ApiCaller {
120
57
  };
121
58
  requestBody: {
122
59
  content: {
123
- "application/json": import('../sdk/schema').components["schemas"]["HttpChatInputDto"];
60
+ "application/json": import('./sdk/schema').components["schemas"]["HttpChatInputDto"];
124
61
  };
125
62
  };
126
63
  responses: {
@@ -129,7 +66,7 @@ export declare class ApiCaller {
129
66
  [name: string]: unknown;
130
67
  };
131
68
  content: {
132
- "application/json": import('../sdk/schema').components["schemas"]["HandleContactMessageOutputDto"];
69
+ "application/json": import('./sdk/schema').components["schemas"]["HandleContactMessageOutputDto"];
133
70
  };
134
71
  };
135
72
  500: {
@@ -137,7 +74,7 @@ export declare class ApiCaller {
137
74
  [name: string]: unknown;
138
75
  };
139
76
  content: {
140
- "application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
77
+ "application/json": import('./sdk/schema').components["schemas"]["ErrorDto"];
141
78
  };
142
79
  };
143
80
  };
@@ -173,7 +110,11 @@ export declare class ApiCaller {
173
110
  };
174
111
  signal: AbortSignal | undefined;
175
112
  }, `${string}/${string}`>>;
176
- getSessionHistory: (sessionId: string, lastMessageTimestamp?: string) => Promise<import('openapi-fetch').FetchResponse<{
113
+ getSessionHistory: ({ sessionId, lastMessageTimestamp, abortSignal, }: {
114
+ sessionId: string;
115
+ lastMessageTimestamp?: string;
116
+ abortSignal: AbortSignal;
117
+ }) => Promise<import('openapi-fetch').FetchResponse<{
177
118
  parameters: {
178
119
  query?: {
179
120
  lastMessageTimestamp?: string;
@@ -191,7 +132,7 @@ export declare class ApiCaller {
191
132
  [name: string]: unknown;
192
133
  };
193
134
  content: {
194
- "application/json": import('../sdk/schema').components["schemas"]["WidgetHistoryDto"][];
135
+ "application/json": import('./sdk/schema').components["schemas"]["WidgetHistoryDto"][];
195
136
  };
196
137
  };
197
138
  500: {
@@ -199,7 +140,7 @@ export declare class ApiCaller {
199
140
  [name: string]: unknown;
200
141
  };
201
142
  content: {
202
- "application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
143
+ "application/json": import('./sdk/schema').components["schemas"]["ErrorDto"];
203
144
  };
204
145
  };
205
146
  };
@@ -212,8 +153,9 @@ export declare class ApiCaller {
212
153
  lastMessageTimestamp: string;
213
154
  } | undefined;
214
155
  };
156
+ signal: AbortSignal;
215
157
  }, `${string}/${string}`>>;
216
- createContact: (body: Dto["CreateContactDto"]) => Promise<import('openapi-fetch').FetchResponse<{
158
+ createUnverifiedContact: (body: Dto["CreateUnverifiedContactDto"]) => Promise<import('openapi-fetch').FetchResponse<{
217
159
  parameters: {
218
160
  query?: never;
219
161
  header: {
@@ -224,7 +166,7 @@ export declare class ApiCaller {
224
166
  };
225
167
  requestBody: {
226
168
  content: {
227
- "application/json": import('../sdk/schema').components["schemas"]["CreateContactDto"];
169
+ "application/json": import('./sdk/schema').components["schemas"]["CreateUnverifiedContactDto"];
228
170
  };
229
171
  };
230
172
  responses: {
@@ -233,7 +175,7 @@ export declare class ApiCaller {
233
175
  [name: string]: unknown;
234
176
  };
235
177
  content: {
236
- "application/json": import('../sdk/schema').components["schemas"]["WidgetContactDto"];
178
+ "application/json": import('./sdk/schema').components["schemas"]["WidgetContactTokenResponseDto"];
237
179
  };
238
180
  };
239
181
  500: {
@@ -241,7 +183,7 @@ export declare class ApiCaller {
241
183
  [name: string]: unknown;
242
184
  };
243
185
  content: {
244
- "application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
186
+ "application/json": import('./sdk/schema').components["schemas"]["ErrorDto"];
245
187
  };
246
188
  };
247
189
  };
@@ -252,8 +194,8 @@ export declare class ApiCaller {
252
194
  };
253
195
  };
254
196
  body: {
255
- email: string;
256
- name: string;
197
+ email?: string;
198
+ name?: string;
257
199
  };
258
200
  }, `${string}/${string}`>>;
259
201
  createSession: () => Promise<import('openapi-fetch').FetchResponse<{
@@ -270,7 +212,7 @@ export declare class ApiCaller {
270
212
  [name: string]: unknown;
271
213
  };
272
214
  content: {
273
- "application/json": import('../sdk/schema').components["schemas"]["WidgetSessionDto"];
215
+ "application/json": import('./sdk/schema').components["schemas"]["WidgetSessionDto"];
274
216
  };
275
217
  };
276
218
  500: {
@@ -278,7 +220,7 @@ export declare class ApiCaller {
278
220
  [name: string]: unknown;
279
221
  };
280
222
  content: {
281
- "application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
223
+ "application/json": import('./sdk/schema').components["schemas"]["ErrorDto"];
282
224
  };
283
225
  };
284
226
  };
@@ -296,7 +238,7 @@ export declare class ApiCaller {
296
238
  [name: string]: unknown;
297
239
  };
298
240
  content: {
299
- "application/json": import('../sdk/schema').components["schemas"]["WidgetSessionDto"];
241
+ "application/json": import('./sdk/schema').components["schemas"]["WidgetSessionDto"];
300
242
  };
301
243
  };
302
244
  500: {
@@ -304,12 +246,15 @@ export declare class ApiCaller {
304
246
  [name: string]: unknown;
305
247
  };
306
248
  content: {
307
- "application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
249
+ "application/json": import('./sdk/schema').components["schemas"]["ErrorDto"];
308
250
  };
309
251
  };
310
252
  };
311
253
  }> | undefined, `${string}/${string}`>>;
312
- getSession: (sessionId: string) => Promise<import('openapi-fetch').FetchResponse<{
254
+ getSession: ({ sessionId, abortSignal, }: {
255
+ sessionId: string;
256
+ abortSignal: AbortSignal;
257
+ }) => Promise<import('openapi-fetch').FetchResponse<{
313
258
  parameters: {
314
259
  query?: never;
315
260
  header?: never;
@@ -325,7 +270,7 @@ export declare class ApiCaller {
325
270
  [name: string]: unknown;
326
271
  };
327
272
  content: {
328
- "application/json": import('../sdk/schema').components["schemas"]["WidgetSessionDto"];
273
+ "application/json": import('./sdk/schema').components["schemas"]["WidgetSessionDto"];
329
274
  };
330
275
  };
331
276
  500: {
@@ -333,7 +278,7 @@ export declare class ApiCaller {
333
278
  [name: string]: unknown;
334
279
  };
335
280
  content: {
336
- "application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
281
+ "application/json": import('./sdk/schema').components["schemas"]["ErrorDto"];
337
282
  };
338
283
  };
339
284
  };
@@ -343,6 +288,7 @@ export declare class ApiCaller {
343
288
  sessionId: string;
344
289
  };
345
290
  };
291
+ signal: AbortSignal;
346
292
  }, `${string}/${string}`>>;
347
293
  uploadFile: (file: {
348
294
  id: string;
@@ -351,7 +297,7 @@ export declare class ApiCaller {
351
297
  fileName: string;
352
298
  fileUrl: string;
353
299
  }>;
354
- vote: (body: WidgetVoteDto) => Promise<import('openapi-fetch').FetchResponse<{
300
+ vote: (body: VoteInputDto) => Promise<import('openapi-fetch').FetchResponse<{
355
301
  parameters: {
356
302
  query?: never;
357
303
  header?: never;
@@ -360,7 +306,7 @@ export declare class ApiCaller {
360
306
  };
361
307
  requestBody: {
362
308
  content: {
363
- "application/json": import('../sdk/schema').components["schemas"]["WidgetVoteDto"];
309
+ "application/json": import('./sdk/schema').components["schemas"]["WidgetVoteDto"];
364
310
  };
365
311
  };
366
312
  responses: {
@@ -369,7 +315,7 @@ export declare class ApiCaller {
369
315
  [name: string]: unknown;
370
316
  };
371
317
  content: {
372
- "application/json": import('../sdk/schema').components["schemas"]["WidgetVoteResponseDto"];
318
+ "application/json": import('./sdk/schema').components["schemas"]["WidgetVoteResponseDto"];
373
319
  };
374
320
  };
375
321
  500: {
@@ -377,7 +323,7 @@ export declare class ApiCaller {
377
323
  [name: string]: unknown;
378
324
  };
379
325
  content: {
380
- "application/json": import('../sdk/schema').components["schemas"]["ErrorDto"];
326
+ "application/json": import('./sdk/schema').components["schemas"]["ErrorDto"];
381
327
  };
382
328
  };
383
329
  };
@@ -0,0 +1,25 @@
1
+ import { PubSub } from '../utils/PubSub';
2
+ import { ApiCaller } from '../api';
3
+ import { Dto } from 'src/headless/core/sdk';
4
+ import { WidgetConfig } from 'src/headless/core/types/WidgetConfig';
5
+ type ContactState = {
6
+ contact: {
7
+ token: string;
8
+ } | null;
9
+ isCreatingUnverifiedContact: boolean;
10
+ isErrorCreatingUnverifiedContact: boolean;
11
+ };
12
+ export type CreateContactHandlerOptions = {
13
+ api: ApiCaller;
14
+ config: WidgetConfig;
15
+ };
16
+ export declare class ContactCtx {
17
+ private config;
18
+ private api;
19
+ state: PubSub<ContactState>;
20
+ constructor({ config, api }: CreateContactHandlerOptions);
21
+ shouldCollectData: () => boolean;
22
+ autoCreateUnverifiedUser: () => Promise<void>;
23
+ createUnverifiedContact: (payload: Dto["CreateUnverifiedContactDto"]) => Promise<void>;
24
+ }
25
+ export {};