@cossistant/react 0.0.3 → 0.0.5

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 (320) hide show
  1. package/README.md +74 -0
  2. package/_virtual/rolldown_runtime.js +19 -0
  3. package/conversation.d.ts +26 -3
  4. package/conversation.d.ts.map +1 -1
  5. package/hooks/index.d.ts +5 -3
  6. package/hooks/index.js +7 -5
  7. package/hooks/private/store/use-conversations-store.d.ts +8 -0
  8. package/hooks/private/store/use-conversations-store.d.ts.map +1 -1
  9. package/hooks/private/store/use-conversations-store.js +8 -0
  10. package/hooks/private/store/use-conversations-store.js.map +1 -1
  11. package/hooks/private/store/use-store-selector.d.ts +4 -0
  12. package/hooks/private/store/use-store-selector.d.ts.map +1 -1
  13. package/hooks/private/store/use-store-selector.js +5 -2
  14. package/hooks/private/store/use-store-selector.js.map +1 -1
  15. package/hooks/private/store/use-website-store.d.ts +4 -0
  16. package/hooks/private/store/use-website-store.d.ts.map +1 -1
  17. package/hooks/private/store/use-website-store.js +6 -3
  18. package/hooks/private/store/use-website-store.js.map +1 -1
  19. package/hooks/private/typing.d.ts +35 -0
  20. package/hooks/private/typing.d.ts.map +1 -0
  21. package/hooks/private/typing.js +49 -0
  22. package/hooks/private/typing.js.map +1 -0
  23. package/hooks/private/use-client-query.d.ts +5 -0
  24. package/hooks/private/use-client-query.d.ts.map +1 -1
  25. package/hooks/private/use-client-query.js +5 -0
  26. package/hooks/private/use-client-query.js.map +1 -1
  27. package/hooks/private/use-grouped-messages.d.ts +10 -4
  28. package/hooks/private/use-grouped-messages.d.ts.map +1 -1
  29. package/hooks/private/use-grouped-messages.js +24 -4
  30. package/hooks/private/use-grouped-messages.js.map +1 -1
  31. package/hooks/private/use-multimodal-input.d.ts.map +1 -1
  32. package/hooks/private/use-rest-client.d.ts.map +1 -1
  33. package/hooks/private/use-visitor-typing-reporter.d.ts +6 -0
  34. package/hooks/private/use-visitor-typing-reporter.d.ts.map +1 -1
  35. package/hooks/private/use-visitor-typing-reporter.js +6 -0
  36. package/hooks/private/use-visitor-typing-reporter.js.map +1 -1
  37. package/hooks/use-composer-refocus.d.ts.map +1 -1
  38. package/hooks/use-conversation-auto-seen.d.ts +9 -0
  39. package/hooks/use-conversation-auto-seen.d.ts.map +1 -1
  40. package/hooks/use-conversation-auto-seen.js +44 -3
  41. package/hooks/use-conversation-auto-seen.js.map +1 -1
  42. package/hooks/use-conversation-history-page.d.ts.map +1 -1
  43. package/hooks/use-conversation-history-page.js +16 -18
  44. package/hooks/use-conversation-history-page.js.map +1 -1
  45. package/hooks/use-conversation-lifecycle.d.ts.map +1 -1
  46. package/hooks/use-conversation-lifecycle.js +2 -4
  47. package/hooks/use-conversation-lifecycle.js.map +1 -1
  48. package/hooks/use-conversation-page.d.ts +6 -0
  49. package/hooks/use-conversation-page.d.ts.map +1 -1
  50. package/hooks/use-conversation-page.js +41 -3
  51. package/hooks/use-conversation-page.js.map +1 -1
  52. package/hooks/use-conversation-preview.d.ts +61 -0
  53. package/hooks/use-conversation-preview.d.ts.map +1 -0
  54. package/hooks/use-conversation-preview.js +173 -0
  55. package/hooks/use-conversation-preview.js.map +1 -0
  56. package/hooks/use-conversation-seen.d.ts +4 -0
  57. package/hooks/use-conversation-seen.d.ts.map +1 -1
  58. package/hooks/use-conversation-seen.js +4 -0
  59. package/hooks/use-conversation-seen.js.map +1 -1
  60. package/hooks/use-conversation-timeline-items.d.ts +4 -0
  61. package/hooks/use-conversation-timeline-items.d.ts.map +1 -1
  62. package/hooks/use-conversation-timeline-items.js +4 -0
  63. package/hooks/use-conversation-timeline-items.js.map +1 -1
  64. package/hooks/use-conversation-timeline.d.ts +32 -0
  65. package/hooks/use-conversation-timeline.d.ts.map +1 -0
  66. package/hooks/use-conversation-timeline.js +41 -0
  67. package/hooks/use-conversation-timeline.js.map +1 -0
  68. package/hooks/use-conversation-typing.d.ts +4 -0
  69. package/hooks/use-conversation-typing.d.ts.map +1 -1
  70. package/hooks/use-conversation-typing.js +4 -0
  71. package/hooks/use-conversation-typing.js.map +1 -1
  72. package/hooks/use-conversation.d.ts +11 -0
  73. package/hooks/use-conversation.d.ts.map +1 -1
  74. package/hooks/use-conversation.js +11 -0
  75. package/hooks/use-conversation.js.map +1 -1
  76. package/hooks/use-conversations.d.ts +12 -0
  77. package/hooks/use-conversations.d.ts.map +1 -1
  78. package/hooks/use-conversations.js +12 -0
  79. package/hooks/use-conversations.js.map +1 -1
  80. package/hooks/use-create-conversation.d.ts +5 -0
  81. package/hooks/use-create-conversation.d.ts.map +1 -1
  82. package/hooks/use-create-conversation.js +12 -9
  83. package/hooks/use-create-conversation.js.map +1 -1
  84. package/hooks/use-home-page.d.ts.map +1 -1
  85. package/hooks/use-home-page.js +6 -4
  86. package/hooks/use-home-page.js.map +1 -1
  87. package/hooks/use-message-composer.d.ts.map +1 -1
  88. package/hooks/use-realtime-support.d.ts.map +1 -1
  89. package/hooks/use-send-message.d.ts +9 -0
  90. package/hooks/use-send-message.d.ts.map +1 -1
  91. package/hooks/use-send-message.js +15 -13
  92. package/hooks/use-send-message.js.map +1 -1
  93. package/hooks/use-visitor.d.ts.map +1 -1
  94. package/hooks/use-visitor.js +28 -30
  95. package/hooks/use-visitor.js.map +1 -1
  96. package/hooks/use-window-visibility-focus.d.ts +4 -0
  97. package/hooks/use-window-visibility-focus.d.ts.map +1 -1
  98. package/hooks/use-window-visibility-focus.js +5 -2
  99. package/hooks/use-window-visibility-focus.js.map +1 -1
  100. package/identify-visitor.d.ts +12 -3
  101. package/identify-visitor.d.ts.map +1 -1
  102. package/identify-visitor.js +58 -9
  103. package/identify-visitor.js.map +1 -1
  104. package/index.d.ts +10 -7
  105. package/index.js +10 -9
  106. package/package.json +14 -17
  107. package/primitives/avatar/avatar.d.ts.map +1 -1
  108. package/primitives/avatar/fallback.d.ts.map +1 -1
  109. package/primitives/avatar/fallback.js +1 -3
  110. package/primitives/avatar/fallback.js.map +1 -1
  111. package/primitives/avatar/image.d.ts.map +1 -1
  112. package/primitives/avatar/index.d.ts +1 -0
  113. package/primitives/bubble.d.ts +2 -0
  114. package/primitives/bubble.d.ts.map +1 -1
  115. package/primitives/bubble.js +8 -2
  116. package/primitives/bubble.js.map +1 -1
  117. package/primitives/button.d.ts.map +1 -1
  118. package/primitives/conversation-timeline.d.ts.map +1 -1
  119. package/primitives/conversation-timeline.js +58 -5
  120. package/primitives/conversation-timeline.js.map +1 -1
  121. package/primitives/index.d.ts +1 -0
  122. package/primitives/index.parts.d.ts +1 -0
  123. package/primitives/multimodal-input.d.ts.map +1 -1
  124. package/primitives/timeline-item-group.d.ts +7 -7
  125. package/primitives/timeline-item-group.d.ts.map +1 -1
  126. package/primitives/timeline-item-group.js.map +1 -1
  127. package/primitives/timeline-item.d.ts +1 -1
  128. package/primitives/timeline-item.d.ts.map +1 -1
  129. package/primitives/timeline-item.js +7 -1
  130. package/primitives/timeline-item.js.map +1 -1
  131. package/primitives/window.d.ts +1 -1
  132. package/primitives/window.d.ts.map +1 -1
  133. package/primitives/window.js +4 -4
  134. package/primitives/window.js.map +1 -1
  135. package/provider.d.ts +23 -43
  136. package/provider.d.ts.map +1 -1
  137. package/provider.js +152 -49
  138. package/provider.js.map +1 -1
  139. package/realtime/event-filter.d.ts +4 -0
  140. package/realtime/event-filter.d.ts.map +1 -1
  141. package/realtime/event-filter.js +4 -0
  142. package/realtime/event-filter.js.map +1 -1
  143. package/realtime/index.js +1 -1
  144. package/realtime/provider.d.ts +7 -2
  145. package/realtime/provider.d.ts.map +1 -1
  146. package/realtime/provider.js +23 -1
  147. package/realtime/provider.js.map +1 -1
  148. package/realtime/seen-store.d.ts +13 -0
  149. package/realtime/seen-store.d.ts.map +1 -1
  150. package/realtime/seen-store.js +14 -2
  151. package/realtime/seen-store.js.map +1 -1
  152. package/realtime/support-provider.d.ts +1 -2
  153. package/realtime/support-provider.d.ts.map +1 -1
  154. package/realtime/support-provider.js +19 -20
  155. package/realtime/support-provider.js.map +1 -1
  156. package/realtime/typing-store.d.ts +18 -0
  157. package/realtime/typing-store.d.ts.map +1 -1
  158. package/realtime/typing-store.js +19 -2
  159. package/realtime/typing-store.js.map +1 -1
  160. package/realtime/use-realtime.d.ts +8 -4
  161. package/realtime/use-realtime.d.ts.map +1 -1
  162. package/realtime/use-realtime.js +4 -0
  163. package/realtime/use-realtime.js.map +1 -1
  164. package/realtime-events.d.ts +17 -3
  165. package/realtime-events.d.ts.map +1 -1
  166. package/schemas.d.ts +7 -1
  167. package/schemas.d.ts.map +1 -1
  168. package/support/components/avatar-stack.d.ts +8 -4
  169. package/support/components/avatar-stack.d.ts.map +1 -1
  170. package/support/components/avatar-stack.js +4 -0
  171. package/support/components/avatar-stack.js.map +1 -1
  172. package/support/components/avatar.d.ts +11 -6
  173. package/support/components/avatar.d.ts.map +1 -1
  174. package/support/components/avatar.js +4 -0
  175. package/support/components/avatar.js.map +1 -1
  176. package/support/components/bubble.d.ts.map +1 -1
  177. package/support/components/bubble.js +29 -6
  178. package/support/components/bubble.js.map +1 -1
  179. package/support/components/button.d.ts +8 -5
  180. package/support/components/button.d.ts.map +1 -1
  181. package/support/components/button.js +5 -1
  182. package/support/components/button.js.map +1 -1
  183. package/support/components/container.d.ts +0 -1
  184. package/support/components/container.d.ts.map +1 -1
  185. package/support/components/container.js +2 -8
  186. package/support/components/container.js.map +1 -1
  187. package/support/components/conversation-button-link.d.ts +8 -21
  188. package/support/components/conversation-button-link.d.ts.map +1 -1
  189. package/support/components/conversation-button-link.js +62 -178
  190. package/support/components/conversation-button-link.js.map +1 -1
  191. package/support/components/conversation-event.d.ts.map +1 -1
  192. package/support/components/conversation-event.js +4 -0
  193. package/support/components/conversation-event.js.map +1 -1
  194. package/support/components/conversation-timeline.d.ts +10 -1
  195. package/support/components/conversation-timeline.d.ts.map +1 -1
  196. package/support/components/conversation-timeline.js +63 -57
  197. package/support/components/conversation-timeline.js.map +1 -1
  198. package/support/components/cossistant-branding.d.ts +5 -2
  199. package/support/components/cossistant-branding.d.ts.map +1 -1
  200. package/support/components/cossistant-branding.js +3 -0
  201. package/support/components/cossistant-branding.js.map +1 -1
  202. package/support/components/header.d.ts.map +1 -1
  203. package/support/components/header.js +2 -2
  204. package/support/components/header.js.map +1 -1
  205. package/support/components/icons.d.ts.map +1 -1
  206. package/support/components/multimodal-input.d.ts.map +1 -1
  207. package/support/components/multimodal-input.js +5 -24
  208. package/support/components/multimodal-input.js.map +1 -1
  209. package/support/components/navigation-tab.d.ts +7 -2
  210. package/support/components/navigation-tab.d.ts.map +1 -1
  211. package/support/components/navigation-tab.js +4 -0
  212. package/support/components/navigation-tab.js.map +1 -1
  213. package/support/components/support-content.d.ts +1 -1
  214. package/support/components/support-content.d.ts.map +1 -1
  215. package/support/components/support-content.js +7 -10
  216. package/support/components/support-content.js.map +1 -1
  217. package/support/components/text-effect.d.ts +5 -2
  218. package/support/components/text-effect.d.ts.map +1 -1
  219. package/support/components/text-effect.js +4 -0
  220. package/support/components/text-effect.js.map +1 -1
  221. package/support/components/timeline-identification-tool.d.ts +7 -0
  222. package/support/components/timeline-identification-tool.d.ts.map +1 -0
  223. package/support/components/timeline-identification-tool.js +139 -0
  224. package/support/components/timeline-identification-tool.js.map +1 -0
  225. package/support/components/timeline-message-group.d.ts +2 -1
  226. package/support/components/timeline-message-group.d.ts.map +1 -1
  227. package/support/components/timeline-message-group.js +4 -19
  228. package/support/components/timeline-message-group.js.map +1 -1
  229. package/support/components/timeline-message-item.d.ts +6 -2
  230. package/support/components/timeline-message-item.d.ts.map +1 -1
  231. package/support/components/timeline-message-item.js +8 -4
  232. package/support/components/timeline-message-item.js.map +1 -1
  233. package/support/components/typing-indicator.d.ts +5 -2
  234. package/support/components/typing-indicator.d.ts.map +1 -1
  235. package/support/components/typing-indicator.js +4 -4
  236. package/support/components/typing-indicator.js.map +1 -1
  237. package/support/components/watermark.d.ts.map +1 -1
  238. package/support/context/websocket.d.ts +8 -0
  239. package/support/context/websocket.d.ts.map +1 -1
  240. package/support/context/websocket.js +12 -6
  241. package/support/context/websocket.js.map +1 -1
  242. package/support/index.d.ts +8 -8
  243. package/support/index.d.ts.map +1 -1
  244. package/support/index.js +18 -18
  245. package/support/index.js.map +1 -1
  246. package/support/pages/conversation-history.js +46 -54
  247. package/support/pages/conversation-history.js.map +1 -1
  248. package/support/pages/conversation.d.ts +3 -6
  249. package/support/pages/conversation.d.ts.map +1 -1
  250. package/support/pages/conversation.js +19 -9
  251. package/support/pages/conversation.js.map +1 -1
  252. package/support/pages/home.d.ts +2 -2
  253. package/support/pages/home.d.ts.map +1 -1
  254. package/support/pages/home.js +64 -77
  255. package/support/pages/home.js.map +1 -1
  256. package/support/store/support-store.d.ts +18 -2
  257. package/support/store/support-store.d.ts.map +1 -1
  258. package/support/store/support-store.js +20 -5
  259. package/support/store/support-store.js.map +1 -1
  260. package/support/{support-CMoDLQoC.css → support-Ck4jy29i.css} +1 -2
  261. package/support/support-Ck4jy29i.css.map +1 -0
  262. package/support/text/index.d.ts +15 -2
  263. package/support/text/index.d.ts.map +1 -1
  264. package/support/text/index.js +15 -2
  265. package/support/text/index.js.map +1 -1
  266. package/support/text/locales/en.js +22 -4
  267. package/support/text/locales/en.js.map +1 -1
  268. package/support/text/locales/es.js +18 -0
  269. package/support/text/locales/es.js.map +1 -1
  270. package/support/text/locales/fr.js +18 -0
  271. package/support/text/locales/fr.js.map +1 -1
  272. package/support/text/locales/keys.d.ts +69 -9
  273. package/support/text/locales/keys.d.ts.map +1 -1
  274. package/support/text/locales/keys.js +18 -0
  275. package/support/text/locales/keys.js.map +1 -1
  276. package/support/text/runtime.d.ts +21 -0
  277. package/support/text/runtime.d.ts.map +1 -1
  278. package/support/text/runtime.js +21 -0
  279. package/support/text/runtime.js.map +1 -1
  280. package/support/utils/index.d.ts +4 -0
  281. package/support/utils/index.d.ts.map +1 -1
  282. package/support/utils/index.js +4 -1
  283. package/support/utils/index.js.map +1 -1
  284. package/support/utils/time.d.ts +3 -0
  285. package/support/utils/time.d.ts.map +1 -1
  286. package/support/utils/time.js +3 -0
  287. package/support/utils/time.js.map +1 -1
  288. package/support-config.d.ts +2 -1
  289. package/support-config.d.ts.map +1 -1
  290. package/support-config.js.map +1 -1
  291. package/support.css +2 -2
  292. package/timeline-item.d.ts +10 -0
  293. package/timeline-item.d.ts.map +1 -1
  294. package/utils/conversation.d.ts +7 -0
  295. package/utils/conversation.d.ts.map +1 -0
  296. package/utils/conversation.js +18 -0
  297. package/utils/conversation.js.map +1 -0
  298. package/utils/id.d.ts +3 -0
  299. package/utils/id.d.ts.map +1 -1
  300. package/utils/id.js +3 -0
  301. package/utils/id.js.map +1 -1
  302. package/utils/index.d.ts +2 -1
  303. package/utils/index.js +2 -1
  304. package/utils/metadata-hash.d.ts +12 -0
  305. package/utils/metadata-hash.d.ts.map +1 -0
  306. package/utils/metadata-hash.js +26 -0
  307. package/utils/metadata-hash.js.map +1 -0
  308. package/utils/text.d.ts +3 -0
  309. package/utils/text.d.ts.map +1 -1
  310. package/utils/text.js +3 -0
  311. package/utils/text.js.map +1 -1
  312. package/utils/use-render-element.d.ts +3 -0
  313. package/utils/use-render-element.d.ts.map +1 -1
  314. package/utils/use-render-element.js +3 -0
  315. package/utils/use-render-element.js.map +1 -1
  316. package/support/context/config.d.ts +0 -32
  317. package/support/context/config.d.ts.map +0 -1
  318. package/support/context/config.js +0 -27
  319. package/support/context/config.js.map +0 -1
  320. package/support/support-CMoDLQoC.css.map +0 -1
package/README.md ADDED
@@ -0,0 +1,74 @@
1
+ # Cossistant React SDK
2
+
3
+ Build fully featured customer support experiences in React with the official `@cossistant/react` package. The SDK wraps the REST and WebSocket APIs, comes with a prebuilt widget, hooks, and UI primitives so you can ship your support quickly and customize later.
4
+
5
+ > 📚 **New to Cossistant?** Follow the [Quickstart guide](https://cossistant/docs/quickstart) in our official documentation.
6
+
7
+ ## Installation
8
+
9
+ Pick the command that matches your package manager:
10
+
11
+ ```bash
12
+ bun add @cossistant/react
13
+ # or
14
+ npm install @cossistant/react
15
+ # or
16
+ yarn add @cossistant/react
17
+ ```
18
+
19
+ ## Render the widget
20
+
21
+ ```tsx
22
+ import { SupportProvider, Support } from "@cossistant/react";
23
+
24
+ export function App() {
25
+ return (
26
+ <SupportProvider publicKey={process.env.NEXT_PUBLIC_COSSISTANT_KEY}>
27
+ <Support />
28
+ </SupportProvider>
29
+ );
30
+ }
31
+ ```
32
+
33
+ 1. Wrap the subtree that should access support data with `SupportProvider` and supply your public key (A Cossistant account is mandatory)
34
+ 2. Drop the `Support` component anywhere inside that provider to mount the floating widget.
35
+ 3. Optionally pass `defaultOpen`, `quickOptions`, `defaultMessages`, or locale overrides straight into `Support` for instant personalization.
36
+
37
+ ### Identify visitors and seed defaults
38
+
39
+ Use the helper components to identify a visitor, attach metadata or display different default messages or quick options.
40
+
41
+ ```tsx
42
+ import {
43
+ IdentifySupportVisitor,
44
+ Support,
45
+ SupportConfig,
46
+ SupportProvider,
47
+ SenderType,
48
+ } from "@cossistant/react";
49
+
50
+ export function Dashboard({
51
+ visitor,
52
+ }: {
53
+ visitor: { id: string; email: string };
54
+ }) {
55
+ return (
56
+ <>
57
+ <IdentifySupportVisitor externalId={visitor.id} email={visitor.email} />
58
+ <SupportConfig
59
+ defaultMessages={[
60
+ {
61
+ content:
62
+ "Welcome in our your dashboard, if you need any help I'm here!",
63
+ senderType: SenderType.TeamMember,
64
+ },
65
+ ]}
66
+ />
67
+ </>
68
+ );
69
+ }
70
+ ```
71
+
72
+ ## Need help or spot a typo?
73
+
74
+ Open an issue in the main repository or start a discussion so we can improve the docs together. Screenshots, reproduction steps, and suggestions are welcome.
@@ -1,5 +1,10 @@
1
1
  //#region rolldown:runtime
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
3
8
  var __export = (all) => {
4
9
  let target = {};
5
10
  for (var name in all) __defProp(target, name, {
@@ -8,6 +13,20 @@ var __export = (all) => {
8
13
  });
9
14
  return target;
10
15
  };
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
18
+ key = keys[i];
19
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
20
+ get: ((k) => from[k]).bind(null, key),
21
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
22
+ });
23
+ }
24
+ return to;
25
+ };
26
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
27
+ value: mod,
28
+ enumerable: true
29
+ }) : target, mod));
11
30
 
12
31
  //#endregion
13
32
  export { __export };
package/conversation.d.ts CHANGED
@@ -14,8 +14,10 @@ declare const createConversationResponseSchema: z.ZodObject<{
14
14
  type: z.ZodEnum<{
15
15
  message: "message";
16
16
  event: "event";
17
+ identification: "identification";
17
18
  }>;
18
19
  text: z.ZodNullable<z.ZodString>;
20
+ tool: z.ZodOptional<z.ZodNullable<z.ZodString>>;
19
21
  parts: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
20
22
  type: z.ZodLiteral<"text">;
21
23
  text: z.ZodString;
@@ -33,6 +35,9 @@ declare const createConversationResponseSchema: z.ZodObject<{
33
35
  tag_removed: "tag_removed";
34
36
  resolved: "resolved";
35
37
  reopened: "reopened";
38
+ visitor_blocked: "visitor_blocked";
39
+ visitor_unblocked: "visitor_unblocked";
40
+ visitor_identified: "visitor_identified";
36
41
  }>;
37
42
  actorUserId: z.ZodNullable<z.ZodString>;
38
43
  actorAiAgentId: z.ZodNullable<z.ZodString>;
@@ -68,10 +73,11 @@ declare const createConversationResponseSchema: z.ZodObject<{
68
73
  visitorId: z.ZodString;
69
74
  websiteId: z.ZodString;
70
75
  status: z.ZodDefault<z.ZodEnum<{
71
- resolved: "resolved";
72
76
  open: "open";
77
+ resolved: "resolved";
73
78
  spam: "spam";
74
79
  }>>;
80
+ deletedAt: z.ZodDefault<z.ZodNullable<z.ZodString>>;
75
81
  lastTimelineItem: z.ZodOptional<z.ZodObject<{
76
82
  id: z.ZodOptional<z.ZodString>;
77
83
  conversationId: z.ZodString;
@@ -83,8 +89,10 @@ declare const createConversationResponseSchema: z.ZodObject<{
83
89
  type: z.ZodEnum<{
84
90
  message: "message";
85
91
  event: "event";
92
+ identification: "identification";
86
93
  }>;
87
94
  text: z.ZodNullable<z.ZodString>;
95
+ tool: z.ZodOptional<z.ZodNullable<z.ZodString>>;
88
96
  parts: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
89
97
  type: z.ZodLiteral<"text">;
90
98
  text: z.ZodString;
@@ -102,6 +110,9 @@ declare const createConversationResponseSchema: z.ZodObject<{
102
110
  tag_removed: "tag_removed";
103
111
  resolved: "resolved";
104
112
  reopened: "reopened";
113
+ visitor_blocked: "visitor_blocked";
114
+ visitor_unblocked: "visitor_unblocked";
115
+ visitor_identified: "visitor_identified";
105
116
  }>;
106
117
  actorUserId: z.ZodNullable<z.ZodString>;
107
118
  actorAiAgentId: z.ZodNullable<z.ZodString>;
@@ -159,10 +170,11 @@ declare const listConversationsResponseSchema: z.ZodObject<{
159
170
  visitorId: z.ZodString;
160
171
  websiteId: z.ZodString;
161
172
  status: z.ZodDefault<z.ZodEnum<{
162
- resolved: "resolved";
163
173
  open: "open";
174
+ resolved: "resolved";
164
175
  spam: "spam";
165
176
  }>>;
177
+ deletedAt: z.ZodDefault<z.ZodNullable<z.ZodString>>;
166
178
  lastTimelineItem: z.ZodOptional<z.ZodObject<{
167
179
  id: z.ZodOptional<z.ZodString>;
168
180
  conversationId: z.ZodString;
@@ -174,8 +186,10 @@ declare const listConversationsResponseSchema: z.ZodObject<{
174
186
  type: z.ZodEnum<{
175
187
  message: "message";
176
188
  event: "event";
189
+ identification: "identification";
177
190
  }>;
178
191
  text: z.ZodNullable<z.ZodString>;
192
+ tool: z.ZodOptional<z.ZodNullable<z.ZodString>>;
179
193
  parts: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
180
194
  type: z.ZodLiteral<"text">;
181
195
  text: z.ZodString;
@@ -193,6 +207,9 @@ declare const listConversationsResponseSchema: z.ZodObject<{
193
207
  tag_removed: "tag_removed";
194
208
  resolved: "resolved";
195
209
  reopened: "reopened";
210
+ visitor_blocked: "visitor_blocked";
211
+ visitor_unblocked: "visitor_unblocked";
212
+ visitor_identified: "visitor_identified";
196
213
  }>;
197
214
  actorUserId: z.ZodNullable<z.ZodString>;
198
215
  actorAiAgentId: z.ZodNullable<z.ZodString>;
@@ -243,10 +260,11 @@ declare const getConversationResponseSchema: z.ZodObject<{
243
260
  visitorId: z.ZodString;
244
261
  websiteId: z.ZodString;
245
262
  status: z.ZodDefault<z.ZodEnum<{
246
- resolved: "resolved";
247
263
  open: "open";
264
+ resolved: "resolved";
248
265
  spam: "spam";
249
266
  }>>;
267
+ deletedAt: z.ZodDefault<z.ZodNullable<z.ZodString>>;
250
268
  lastTimelineItem: z.ZodOptional<z.ZodObject<{
251
269
  id: z.ZodOptional<z.ZodString>;
252
270
  conversationId: z.ZodString;
@@ -258,8 +276,10 @@ declare const getConversationResponseSchema: z.ZodObject<{
258
276
  type: z.ZodEnum<{
259
277
  message: "message";
260
278
  event: "event";
279
+ identification: "identification";
261
280
  }>;
262
281
  text: z.ZodNullable<z.ZodString>;
282
+ tool: z.ZodOptional<z.ZodNullable<z.ZodString>>;
263
283
  parts: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
264
284
  type: z.ZodLiteral<"text">;
265
285
  text: z.ZodString;
@@ -277,6 +297,9 @@ declare const getConversationResponseSchema: z.ZodObject<{
277
297
  tag_removed: "tag_removed";
278
298
  resolved: "resolved";
279
299
  reopened: "reopened";
300
+ visitor_blocked: "visitor_blocked";
301
+ visitor_unblocked: "visitor_unblocked";
302
+ visitor_identified: "visitor_identified";
280
303
  }>;
281
304
  actorUserId: z.ZodNullable<z.ZodString>;
282
305
  actorAiAgentId: z.ZodNullable<z.ZodString>;
@@ -1 +1 @@
1
- {"version":3,"file":"conversation.d.ts","names":[],"sources":["../../types/src/api/conversation.ts"],"sourcesContent":[],"mappings":";;;;cA8Ba,kCAAgC,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAAA,CAAA,CAAA;MAAA,IAAA,eAAA,YAAA,CAAA;MASjC,KAAA,YAAA,WAA8B,CAAA,SAAA,YAAA,CAAA;QAAA,IAAA,cAAA,CAAA,MAAA,CAAA;QAClC,IAAA,aAAA;MADuC,CAAA,eAAA,CAAA,aAAA,CAAA;QAAK,IAAA,cAAA,CAAA,OAAA,CAAA;QAIvC,SAAA,WAAA,CA2BV;UAAA,QAAA,EAAA,UAAA;;;;;;;;;;;;;;QA3BwC,YAAA,eAAA,YAAA,CAAA;QAAA,eAAA,eAAA,YAAA,CAAA;QA6B/B,OAAA,eAAwB,cAAA,YAAA,CAAA,CAAA;MAAA,CAAA,eAAA,CAAA,aAAA,CAAA;QAC5B,IAAA,cAAA,CAAA,OAAA,CAAA;QADiC,GAAA,aAAA;QAAK,SAAA,aAAA;QAIjC,QAAA,eAaV,YAAA,CAAA;QAAA,IAAA,eAAA,YAAA,CAAA;;;;;;;;;;;;;;;;;;KAlDS,8BAAA,GAAiC,CAAA,CAAE,aACvC;cAGK,gCAA8B,CAAA,CAAA;;;;;;;;;;;;;;;;;KA6B/B,wBAAA,GAA2B,CAAA,CAAE,aACjC;cAGK,iCAA+B,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAAA,OAAA,eAAA,cAAA,YAAA,CAAA,CAAA;MAAA,CAAA,eAAA,CAAA,aAAA,CAAA;QAehC,IAAA,cAAyB,CAAA,OAAA,CAAA;QAAA,GAAA,aAAA;QAC7B,SAAA,aAAA;QADkC,QAAA,eAAA,YAAA,CAAA;QAAK,IAAA,eAAA,YAAA,CAAA;QAIlC,KAAA,eAQV,YAAA,CAAA;QAAA,MAAA,eAAA,YAAA,CAAA;;;QARsC,GAAA,aAAA;QAAA,SAAA,aAAA;QAU7B,QAAA,eAAsB,YAAA,CAAA;QAAA,IAAA,eAAA,YAAA,CAAA;MAC1B,CAAA,eAAA,CAAA,CAAA,CAAA,CAAA;MAD+B,MAAA,eAAA,YAAA,CAAA;MAAK,SAAA,eAAA,YAAA,CAAA;MAI/B,SAAA,eAMV,YAAA,CAAA;MAAA,SAAA,aAAA;;;;;;;;;;;;KAxBS,yBAAA,GAA4B,CAAA,CAAE,aAClC;cAGK,8BAA4B,CAAA,CAAA;;;KAU7B,sBAAA,GAAyB,CAAA,CAAE,aAC/B;cAGK,+BAA6B,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAAA,SAAA,aAAA;QAAA,QAAA,eAAA,YAAA,CAAA;QAQ9B,IAAA,eAAuB,YAAA,CAAA;MAAA,CAAA,eAAA,CAAA,CAAA,CAAA,CAAA;MAC3B,MAAA,eAAA,YAAA,CAAA;MADgC,SAAA,eAAA,YAAA,CAAA;MAAK,SAAA,eAAA,YAAA,CAAA;;;;;;KAAjC,uBAAA,GAA0B,CAAA,CAAE,aAChC"}
1
+ {"version":3,"file":"conversation.d.ts","names":[],"sources":["../../types/src/api/conversation.ts"],"sourcesContent":[],"mappings":";;;;cA8Ba,kCAAgC,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAAA,IAAA,WAAA,CAAA;QAAA,OAAA,EAAA,SAAA;QASjC,KAAA,EAAA,OAAA;QAIC,cAAA,EAAA,gBA2BV;;;;;;;;;;;;;;UA3BwC,gBAAA,EAAA,kBAAA;UAAA,cAAA,EAAA,gBAAA;UA6B/B,gBAAwB,EAAA,kBAC5B;UAGK,SAAA,EAAA,WAaV;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAlDS,8BAAA,GAAiC,CAAA,CAAE,aACvC;cAGK,gCAA8B,CAAA,CAAA;;;;;;;;;;;;;;;;;KA6B/B,wBAAA,GAA2B,CAAA,CAAE,aACjC;cAGK,iCAA+B,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAAA,UAAA,EAAA,YAAA;UAAA,qBAAA,EAAA,uBAAA;UAehC,kBAAyB,EAAA,oBAC7B;UAGK,gBAQV,EAAA,kBAAA;;;UARsC,SAAA,EAAA,WAAA;UAAA,WAAA,EAAA,aAAA;UAU7B,QAAA,EAAsB,UAAA;UAIrB,QAAA,EAAA,UAMV;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAxBS,yBAAA,GAA4B,CAAA,CAAE,aAClC;cAGK,8BAA4B,CAAA,CAAA;;;KAU7B,sBAAA,GAAyB,CAAA,CAAE,aAC/B;cAGK,+BAA6B,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAAA,kBAAA,EAAA,oBAAA;UAAA,gBAAA,EAAA,kBAAA;UAQ9B,cAAuB,EAAA,gBAC3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KADI,uBAAA,GAA0B,CAAA,CAAE,aAChC"}
package/hooks/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { useClientQuery } from "./private/use-client-query.js";
2
2
  import { useDefaultMessages } from "./private/use-default-messages.js";
3
- import { ConversationItem, GroupedMessage, TimelineEventItem, UseGroupedMessagesOptions, UseGroupedMessagesProps, useGroupedMessages } from "./private/use-grouped-messages.js";
3
+ import { ConversationItem, GroupedMessage, TimelineEventItem, TimelineToolItem, UseGroupedMessagesOptions, UseGroupedMessagesProps, useGroupedMessages } from "./private/use-grouped-messages.js";
4
4
  import { UseMultimodalInputOptions, UseMultimodalInputReturn, useMultimodalInput } from "./private/use-multimodal-input.js";
5
5
  import { UseClientResult, useClient } from "./private/use-rest-client.js";
6
6
  import { UseComposerRefocusOptions, UseComposerRefocusReturn, useComposerRefocus } from "./use-composer-refocus.js";
@@ -9,9 +9,11 @@ import { CONVERSATION_AUTO_SEEN_DELAY_MS, UseConversationAutoSeenOptions, useCon
9
9
  import { UseConversationHistoryPageOptions, UseConversationHistoryPageReturn, useConversationHistoryPage } from "./use-conversation-history-page.js";
10
10
  import { ConversationLifecycleState, UseConversationLifecycleOptions, UseConversationLifecycleReturn, useConversationLifecycle } from "./use-conversation-lifecycle.js";
11
11
  import { UseConversationPageOptions, UseConversationPageReturn, useConversationPage } from "./use-conversation-page.js";
12
- import { useConversationSeen, useDebouncedConversationSeen } from "./use-conversation-seen.js";
13
12
  import { UseConversationTimelineItemsOptions, UseConversationTimelineItemsResult, useConversationTimelineItems } from "./use-conversation-timeline-items.js";
13
+ import { ConversationPreviewAssignedAgent, ConversationPreviewLastMessage, ConversationPreviewTypingParticipant, ConversationPreviewTypingState, UseConversationPreviewOptions, UseConversationPreviewReturn, useConversationPreview } from "./use-conversation-preview.js";
14
+ import { useConversationSeen, useDebouncedConversationSeen } from "./use-conversation-seen.js";
14
15
  import { ConversationTypingParticipant, useConversationTyping } from "./use-conversation-typing.js";
16
+ import { ConversationTimelineTypingParticipant, UseConversationTimelineOptions, UseConversationTimelineReturn, useConversationTimeline } from "./use-conversation-timeline.js";
15
17
  import { UseConversationsOptions, UseConversationsResult, useConversations } from "./use-conversations.js";
16
18
  import { CreateConversationVariables, UseCreateConversationOptions, UseCreateConversationResult, useCreateConversation } from "./use-create-conversation.js";
17
19
  import { UseHomePageOptions, UseHomePageReturn, useHomePage } from "./use-home-page.js";
@@ -20,4 +22,4 @@ import { UseRealtimeSupportOptions, UseRealtimeSupportResult, useRealtimeSupport
20
22
  import { SendMessageOptions, SendMessageResult, UseSendMessageOptions, UseSendMessageResult, useSendMessage } from "./use-send-message.js";
21
23
  import { UseVisitorReturn, useVisitor } from "./use-visitor.js";
22
24
  import { WindowVisibilityFocusState, useWindowVisibilityFocus } from "./use-window-visibility-focus.js";
23
- export { CONVERSATION_AUTO_SEEN_DELAY_MS, ConversationItem, ConversationLifecycleState, ConversationTypingParticipant, CreateConversationVariables, GroupedMessage, SendMessageOptions, SendMessageResult, TimelineEventItem, UseClientResult, UseComposerRefocusOptions, UseComposerRefocusReturn, UseConversationAutoSeenOptions, UseConversationHistoryPageOptions, UseConversationHistoryPageReturn, UseConversationLifecycleOptions, UseConversationLifecycleReturn, UseConversationOptions, UseConversationPageOptions, UseConversationPageReturn, UseConversationResult, UseConversationTimelineItemsOptions, UseConversationTimelineItemsResult, UseConversationsOptions, UseConversationsResult, UseCreateConversationOptions, UseCreateConversationResult, UseGroupedMessagesOptions, UseGroupedMessagesProps, UseHomePageOptions, UseHomePageReturn, UseMessageComposerOptions, UseMessageComposerReturn, UseMultimodalInputOptions, UseMultimodalInputReturn, UseRealtimeSupportOptions, UseRealtimeSupportResult, UseSendMessageOptions, UseSendMessageResult, UseVisitorReturn, WindowVisibilityFocusState, useClient, useClientQuery, useComposerRefocus, useConversation, useConversationAutoSeen, useConversationHistoryPage, useConversationLifecycle, useConversationPage, useConversationSeen, useConversationTimelineItems, useConversationTyping, useConversations, useCreateConversation, useDebouncedConversationSeen, useDefaultMessages, useGroupedMessages, useHomePage, useMessageComposer, useMultimodalInput, useRealtimeSupport, useSendMessage, useVisitor, useWindowVisibilityFocus };
25
+ export { CONVERSATION_AUTO_SEEN_DELAY_MS, ConversationItem, ConversationLifecycleState, ConversationPreviewAssignedAgent, ConversationPreviewLastMessage, ConversationPreviewTypingParticipant, ConversationPreviewTypingState, ConversationTimelineTypingParticipant, ConversationTypingParticipant, CreateConversationVariables, GroupedMessage, SendMessageOptions, SendMessageResult, TimelineEventItem, TimelineToolItem, UseClientResult, UseComposerRefocusOptions, UseComposerRefocusReturn, UseConversationAutoSeenOptions, UseConversationHistoryPageOptions, UseConversationHistoryPageReturn, UseConversationLifecycleOptions, UseConversationLifecycleReturn, UseConversationOptions, UseConversationPageOptions, UseConversationPageReturn, UseConversationPreviewOptions, UseConversationPreviewReturn, UseConversationResult, UseConversationTimelineItemsOptions, UseConversationTimelineItemsResult, UseConversationTimelineOptions, UseConversationTimelineReturn, UseConversationsOptions, UseConversationsResult, UseCreateConversationOptions, UseCreateConversationResult, UseGroupedMessagesOptions, UseGroupedMessagesProps, UseHomePageOptions, UseHomePageReturn, UseMessageComposerOptions, UseMessageComposerReturn, UseMultimodalInputOptions, UseMultimodalInputReturn, UseRealtimeSupportOptions, UseRealtimeSupportResult, UseSendMessageOptions, UseSendMessageResult, UseVisitorReturn, WindowVisibilityFocusState, useClient, useClientQuery, useComposerRefocus, useConversation, useConversationAutoSeen, useConversationHistoryPage, useConversationLifecycle, useConversationPage, useConversationPreview, useConversationSeen, useConversationTimeline, useConversationTimelineItems, useConversationTyping, useConversations, useCreateConversation, useDebouncedConversationSeen, useDefaultMessages, useGroupedMessages, useHomePage, useMessageComposer, useMultimodalInput, useRealtimeSupport, useSendMessage, useVisitor, useWindowVisibilityFocus };
package/hooks/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { useClientQuery } from "./private/use-client-query.js";
2
2
  import { useClient } from "./private/use-rest-client.js";
3
+ import { useConversation } from "./use-conversation.js";
3
4
  import { useWindowVisibilityFocus } from "./use-window-visibility-focus.js";
4
5
  import { CONVERSATION_AUTO_SEEN_DELAY_MS, useConversationAutoSeen } from "./use-conversation-auto-seen.js";
5
6
  import { useConversationLifecycle } from "./use-conversation-lifecycle.js";
@@ -9,16 +10,17 @@ import { useSendMessage } from "./use-send-message.js";
9
10
  import { useMessageComposer } from "./use-message-composer.js";
10
11
  import { useConversationPage } from "./use-conversation-page.js";
11
12
  import { useGroupedMessages } from "./private/use-grouped-messages.js";
13
+ import { useConversationSeen, useDebouncedConversationSeen } from "./use-conversation-seen.js";
14
+ import { useConversationTyping } from "./use-conversation-typing.js";
15
+ import { useConversationTimeline } from "./use-conversation-timeline.js";
12
16
  import { useComposerRefocus } from "./use-composer-refocus.js";
17
+ import { useVisitor } from "./use-visitor.js";
13
18
  import { useConversations } from "./use-conversations.js";
14
19
  import { useConversationHistoryPage } from "./use-conversation-history-page.js";
20
+ import { useConversationPreview } from "./use-conversation-preview.js";
15
21
  import { useHomePage } from "./use-home-page.js";
16
22
  import { useDefaultMessages } from "./private/use-default-messages.js";
17
- import { useConversation } from "./use-conversation.js";
18
- import { useConversationSeen, useDebouncedConversationSeen } from "./use-conversation-seen.js";
19
- import { useConversationTyping } from "./use-conversation-typing.js";
20
23
  import { useCreateConversation } from "./use-create-conversation.js";
21
24
  import { useRealtimeSupport } from "./use-realtime-support.js";
22
- import { useVisitor } from "./use-visitor.js";
23
25
 
24
- export { CONVERSATION_AUTO_SEEN_DELAY_MS, useClient, useClientQuery, useComposerRefocus, useConversation, useConversationAutoSeen, useConversationHistoryPage, useConversationLifecycle, useConversationPage, useConversationSeen, useConversationTimelineItems, useConversationTyping, useConversations, useCreateConversation, useDebouncedConversationSeen, useDefaultMessages, useGroupedMessages, useHomePage, useMessageComposer, useMultimodalInput, useRealtimeSupport, useSendMessage, useVisitor, useWindowVisibilityFocus };
26
+ export { CONVERSATION_AUTO_SEEN_DELAY_MS, useClient, useClientQuery, useComposerRefocus, useConversation, useConversationAutoSeen, useConversationHistoryPage, useConversationLifecycle, useConversationPage, useConversationPreview, useConversationSeen, useConversationTimeline, useConversationTimelineItems, useConversationTyping, useConversations, useCreateConversation, useDebouncedConversationSeen, useDefaultMessages, useGroupedMessages, useHomePage, useMessageComposer, useMultimodalInput, useRealtimeSupport, useSendMessage, useVisitor, useWindowVisibilityFocus };
@@ -6,7 +6,15 @@ type ConversationSelection = {
6
6
  conversations: Conversation[];
7
7
  pagination: ConversationPagination | null;
8
8
  };
9
+ /**
10
+ * Selector hook that exposes the normalized conversations list from the
11
+ * internal store alongside pagination metadata.
12
+ */
9
13
  declare function useConversationsStore(): ConversationSelection;
14
+ /**
15
+ * Picks a single conversation entity from the store by id. Returns `null` when
16
+ * the identifier is missing or the entity has not been fetched yet.
17
+ */
10
18
  declare function useConversationById(conversationId: string | null): Conversation | null;
11
19
  //#endregion
12
20
  export { useConversationById, useConversationsStore };
@@ -1 +1 @@
1
- {"version":3,"file":"use-conversations-store.d.ts","names":[],"sources":["../../../../src/hooks/private/store/use-conversations-store.ts"],"sourcesContent":[],"mappings":";;;;KAQK,qBAAA;iBACW;EADX,UAAA,EAEQ,sBAFa,GAAA,IAAA;CAAA;AACV,iBAoCA,qBAAA,CAAA,CApCA,EAoCyB,qBApCzB;AACH,iBA2DG,mBAAA,CA3DH,cAAA,EAAA,MAAA,GAAA,IAAA,CAAA,EA6DV,YA7DU,GAAA,IAAA"}
1
+ {"version":3,"file":"use-conversations-store.d.ts","names":[],"sources":["../../../../src/hooks/private/store/use-conversations-store.ts"],"sourcesContent":[],"mappings":";;;;KAQK,qBAAA;iBACW;EADX,UAAA,EAEQ,sBAFa,GACV,IAAA;AAwChB,CAAA;AA4BA;;;;iBA5BgB,qBAAA,CAAA,GAAyB;;;;;iBA4BzB,mBAAA,iCAEb"}
@@ -12,6 +12,10 @@ function areSelectionsEqual(a, b) {
12
12
  for (let index = 0; index < a.conversations.length; index += 1) if (a.conversations[index] !== b.conversations[index]) return false;
13
13
  return true;
14
14
  }
15
+ /**
16
+ * Selector hook that exposes the normalized conversations list from the
17
+ * internal store alongside pagination metadata.
18
+ */
15
19
  function useConversationsStore() {
16
20
  const { client } = useSupport();
17
21
  if (!client) throw new Error("useConversationsStore requires a configured Cossistant client");
@@ -20,6 +24,10 @@ function useConversationsStore() {
20
24
  pagination: state.pagination
21
25
  }), areSelectionsEqual);
22
26
  }
27
+ /**
28
+ * Picks a single conversation entity from the store by id. Returns `null` when
29
+ * the identifier is missing or the entity has not been fetched yet.
30
+ */
23
31
  function useConversationById(conversationId) {
24
32
  const { client } = useSupport();
25
33
  if (!client) throw new Error("useConversationById requires a configured Cossistant client");
@@ -1 +1 @@
1
- {"version":3,"file":"use-conversations-store.js","names":[],"sources":["../../../../src/hooks/private/store/use-conversations-store.ts"],"sourcesContent":["import type {\n\tConversationPagination,\n\tConversationsState,\n} from \"@cossistant/core\";\nimport type { Conversation } from \"@cossistant/types\";\nimport { useSupport } from \"../../../provider\";\nimport { useStoreSelector } from \"./use-store-selector\";\n\ntype ConversationSelection = {\n\tconversations: Conversation[];\n\tpagination: ConversationPagination | null;\n};\n\nfunction areSelectionsEqual(\n\ta: ConversationSelection,\n\tb: ConversationSelection\n): boolean {\n\tif (a === b) {\n\t\treturn true;\n\t}\n\tif (a.pagination !== b.pagination) {\n\t\tif (!(a.pagination && b.pagination)) {\n\t\t\treturn false;\n\t\t}\n\t\tif (\n\t\t\ta.pagination.page !== b.pagination.page ||\n\t\t\ta.pagination.limit !== b.pagination.limit ||\n\t\t\ta.pagination.total !== b.pagination.total ||\n\t\t\ta.pagination.totalPages !== b.pagination.totalPages ||\n\t\t\ta.pagination.hasMore !== b.pagination.hasMore\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t}\n\tif (a.conversations.length !== b.conversations.length) {\n\t\treturn false;\n\t}\n\tfor (let index = 0; index < a.conversations.length; index += 1) {\n\t\tif (a.conversations[index] !== b.conversations[index]) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\nexport function useConversationsStore(): ConversationSelection {\n\tconst { client } = useSupport();\n\n\tif (!client) {\n\t\tthrow new Error(\n\t\t\t\"useConversationsStore requires a configured Cossistant client\"\n\t\t);\n\t}\n\n\treturn useStoreSelector(\n\t\tclient.conversationsStore,\n\t\t(state: ConversationsState) => ({\n\t\t\tconversations: state.ids\n\t\t\t\t.map((id) => state.byId[id])\n\t\t\t\t.filter(\n\t\t\t\t\t(conversation): conversation is Conversation =>\n\t\t\t\t\t\tconversation !== undefined\n\t\t\t\t),\n\t\t\tpagination: state.pagination,\n\t\t}),\n\t\tareSelectionsEqual\n\t);\n}\n\nexport function useConversationById(\n\tconversationId: string | null\n): Conversation | null {\n\tconst { client } = useSupport();\n\n\tif (!client) {\n\t\tthrow new Error(\n\t\t\t\"useConversationById requires a configured Cossistant client\"\n\t\t);\n\t}\n\n\treturn useStoreSelector(client.conversationsStore, (state) => {\n\t\tif (!conversationId) {\n\t\t\treturn null;\n\t\t}\n\t\treturn state.byId[conversationId] ?? null;\n\t});\n}\n"],"mappings":";;;;AAaA,SAAS,mBACR,GACA,GACU;AACV,KAAI,MAAM,EACT,QAAO;AAER,KAAI,EAAE,eAAe,EAAE,YAAY;AAClC,MAAI,EAAE,EAAE,cAAc,EAAE,YACvB,QAAO;AAER,MACC,EAAE,WAAW,SAAS,EAAE,WAAW,QACnC,EAAE,WAAW,UAAU,EAAE,WAAW,SACpC,EAAE,WAAW,UAAU,EAAE,WAAW,SACpC,EAAE,WAAW,eAAe,EAAE,WAAW,cACzC,EAAE,WAAW,YAAY,EAAE,WAAW,QAEtC,QAAO;;AAGT,KAAI,EAAE,cAAc,WAAW,EAAE,cAAc,OAC9C,QAAO;AAER,MAAK,IAAI,QAAQ,GAAG,QAAQ,EAAE,cAAc,QAAQ,SAAS,EAC5D,KAAI,EAAE,cAAc,WAAW,EAAE,cAAc,OAC9C,QAAO;AAGT,QAAO;;AAGR,SAAgB,wBAA+C;CAC9D,MAAM,EAAE,WAAW,YAAY;AAE/B,KAAI,CAAC,OACJ,OAAM,IAAI,MACT,gEACA;AAGF,QAAO,iBACN,OAAO,qBACN,WAA+B;EAC/B,eAAe,MAAM,IACnB,KAAK,OAAO,MAAM,KAAK,IAAI,CAC3B,QACC,iBACA,iBAAiB,OAClB;EACF,YAAY,MAAM;EAClB,GACD,mBACA;;AAGF,SAAgB,oBACf,gBACsB;CACtB,MAAM,EAAE,WAAW,YAAY;AAE/B,KAAI,CAAC,OACJ,OAAM,IAAI,MACT,8DACA;AAGF,QAAO,iBAAiB,OAAO,qBAAqB,UAAU;AAC7D,MAAI,CAAC,eACJ,QAAO;AAER,SAAO,MAAM,KAAK,mBAAmB;GACpC"}
1
+ {"version":3,"file":"use-conversations-store.js","names":[],"sources":["../../../../src/hooks/private/store/use-conversations-store.ts"],"sourcesContent":["import type {\n\tConversationPagination,\n\tConversationsState,\n} from \"@cossistant/core\";\nimport type { Conversation } from \"@cossistant/types\";\nimport { useSupport } from \"../../../provider\";\nimport { useStoreSelector } from \"./use-store-selector\";\n\ntype ConversationSelection = {\n\tconversations: Conversation[];\n\tpagination: ConversationPagination | null;\n};\n\nfunction areSelectionsEqual(\n\ta: ConversationSelection,\n\tb: ConversationSelection\n): boolean {\n\tif (a === b) {\n\t\treturn true;\n\t}\n\tif (a.pagination !== b.pagination) {\n\t\tif (!(a.pagination && b.pagination)) {\n\t\t\treturn false;\n\t\t}\n\t\tif (\n\t\t\ta.pagination.page !== b.pagination.page ||\n\t\t\ta.pagination.limit !== b.pagination.limit ||\n\t\t\ta.pagination.total !== b.pagination.total ||\n\t\t\ta.pagination.totalPages !== b.pagination.totalPages ||\n\t\t\ta.pagination.hasMore !== b.pagination.hasMore\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t}\n\tif (a.conversations.length !== b.conversations.length) {\n\t\treturn false;\n\t}\n\tfor (let index = 0; index < a.conversations.length; index += 1) {\n\t\tif (a.conversations[index] !== b.conversations[index]) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n * Selector hook that exposes the normalized conversations list from the\n * internal store alongside pagination metadata.\n */\nexport function useConversationsStore(): ConversationSelection {\n\tconst { client } = useSupport();\n\n\tif (!client) {\n\t\tthrow new Error(\n\t\t\t\"useConversationsStore requires a configured Cossistant client\"\n\t\t);\n\t}\n\n\treturn useStoreSelector(\n\t\tclient.conversationsStore,\n\t\t(state: ConversationsState) => ({\n\t\t\tconversations: state.ids\n\t\t\t\t.map((id) => state.byId[id])\n\t\t\t\t.filter(\n\t\t\t\t\t(conversation): conversation is Conversation =>\n\t\t\t\t\t\tconversation !== undefined\n\t\t\t\t),\n\t\t\tpagination: state.pagination,\n\t\t}),\n\t\tareSelectionsEqual\n\t);\n}\n\n/**\n * Picks a single conversation entity from the store by id. Returns `null` when\n * the identifier is missing or the entity has not been fetched yet.\n */\nexport function useConversationById(\n\tconversationId: string | null\n): Conversation | null {\n\tconst { client } = useSupport();\n\n\tif (!client) {\n\t\tthrow new Error(\n\t\t\t\"useConversationById requires a configured Cossistant client\"\n\t\t);\n\t}\n\n\treturn useStoreSelector(client.conversationsStore, (state) => {\n\t\tif (!conversationId) {\n\t\t\treturn null;\n\t\t}\n\t\treturn state.byId[conversationId] ?? null;\n\t});\n}\n"],"mappings":";;;;AAaA,SAAS,mBACR,GACA,GACU;AACV,KAAI,MAAM,EACT,QAAO;AAER,KAAI,EAAE,eAAe,EAAE,YAAY;AAClC,MAAI,EAAE,EAAE,cAAc,EAAE,YACvB,QAAO;AAER,MACC,EAAE,WAAW,SAAS,EAAE,WAAW,QACnC,EAAE,WAAW,UAAU,EAAE,WAAW,SACpC,EAAE,WAAW,UAAU,EAAE,WAAW,SACpC,EAAE,WAAW,eAAe,EAAE,WAAW,cACzC,EAAE,WAAW,YAAY,EAAE,WAAW,QAEtC,QAAO;;AAGT,KAAI,EAAE,cAAc,WAAW,EAAE,cAAc,OAC9C,QAAO;AAER,MAAK,IAAI,QAAQ,GAAG,QAAQ,EAAE,cAAc,QAAQ,SAAS,EAC5D,KAAI,EAAE,cAAc,WAAW,EAAE,cAAc,OAC9C,QAAO;AAGT,QAAO;;;;;;AAOR,SAAgB,wBAA+C;CAC9D,MAAM,EAAE,WAAW,YAAY;AAE/B,KAAI,CAAC,OACJ,OAAM,IAAI,MACT,gEACA;AAGF,QAAO,iBACN,OAAO,qBACN,WAA+B;EAC/B,eAAe,MAAM,IACnB,KAAK,OAAO,MAAM,KAAK,IAAI,CAC3B,QACC,iBACA,iBAAiB,OAClB;EACF,YAAY,MAAM;EAClB,GACD,mBACA;;;;;;AAOF,SAAgB,oBACf,gBACsB;CACtB,MAAM,EAAE,WAAW,YAAY;AAE/B,KAAI,CAAC,OACJ,OAAM,IAAI,MACT,8DACA;AAGF,QAAO,iBAAiB,OAAO,qBAAqB,UAAU;AAC7D,MAAI,CAAC,eACJ,QAAO;AAER,SAAO,MAAM,KAAK,mBAAmB;GACpC"}
@@ -4,6 +4,10 @@ type BasicStore<TState> = {
4
4
  getState(): TState;
5
5
  subscribe(listener: Subscription<TState>): () => void;
6
6
  };
7
+ /**
8
+ * React hook that bridges Zustand-like stores with React components by
9
+ * memoizing selector results and resubscribing when dependencies change.
10
+ */
7
11
  declare function useStoreSelector<TState, TSelected>(store: BasicStore<TState>, selector: (state: TState) => TSelected, isEqual?: (previous: TSelected, next: TSelected) => boolean): TSelected;
8
12
  //#endregion
9
13
  export { useStoreSelector };
@@ -1 +1 @@
1
- {"version":3,"file":"use-store-selector.d.ts","names":[],"sources":["../../../../src/hooks/private/store/use-store-selector.ts"],"sourcesContent":[],"mappings":";KAEK,+BAA+B;KAE/B,UAFA,CAAA,MAAY,CAAA,GAAA;EAEZ,QAAA,EAAA,EACQ,MADE;EAAA,SAAA,CAAA,QAAA,EAEM,YAFN,CAEmB,MAFnB,CAAA,CAAA,EAAA,GAAA,GAAA,IAAA;;AAEmB,iBAGlB,gBAHkB,CAAA,MAAA,EAAA,SAAA,CAAA,CAAA,KAAA,EAI1B,UAJ0B,CAIf,MAJe,CAAA,EAAA,QAAA,EAAA,CAAA,KAAA,EAKf,MALe,EAAA,GAKJ,SALI,EAAA,OAAA,CAAA,EAAA,CAAA,QAAA,EAMb,SANa,EAAA,IAAA,EAMI,SANJ,EAAA,GAAA,OAAA,CAAA,EAO/B,SAP+B"}
1
+ {"version":3,"file":"use-store-selector.d.ts","names":[],"sources":["../../../../src/hooks/private/store/use-store-selector.ts"],"sourcesContent":[],"mappings":";KAEK,+BAA+B;KAE/B,UAFA,CAAA,MAAY,CAAA,GAAA;EAEZ,QAAA,EAAA,EACQ,MADE;EACF,SAAA,CAAA,QAAA,EACQ,YADR,CACqB,MADrB,CAAA,CAAA,EAAA,GAAA,GAAA,IAAA;CACqB;;;AAOlC;;AACQ,iBADQ,gBACR,CAAA,MAAA,EAAA,SAAA,CAAA,CAAA,KAAA,EAAA,UAAA,CAAW,MAAX,CAAA,EAAA,QAAA,EAAA,CAAA,KAAA,EACW,MADX,EAAA,GACsB,SADtB,EAAA,OAAA,CAAA,EAAA,CAAA,QAAA,EAEa,SAFb,EAAA,IAAA,EAE8B,SAF9B,EAAA,GAAA,OAAA,CAAA,EAGL,SAHK"}
@@ -1,13 +1,16 @@
1
1
  import { useRef, useSyncExternalStore } from "react";
2
2
 
3
3
  //#region src/hooks/private/store/use-store-selector.ts
4
+ /**
5
+ * React hook that bridges Zustand-like stores with React components by
6
+ * memoizing selector results and resubscribing when dependencies change.
7
+ */
4
8
  function useStoreSelector(store, selector, isEqual = Object.is) {
5
9
  const selectionRef = useRef(void 0);
6
10
  const subscribe = (onStoreChange) => store.subscribe(() => {
7
11
  onStoreChange();
8
12
  });
9
- const snapshot = useSyncExternalStore(subscribe, () => store.getState(), () => store.getState());
10
- const selected = selector(snapshot);
13
+ const selected = selector(useSyncExternalStore(subscribe, () => store.getState(), () => store.getState()));
11
14
  if (selectionRef.current === void 0 || !isEqual(selectionRef.current, selected)) selectionRef.current = selected;
12
15
  return selectionRef.current;
13
16
  }
@@ -1 +1 @@
1
- {"version":3,"file":"use-store-selector.js","names":[],"sources":["../../../../src/hooks/private/store/use-store-selector.ts"],"sourcesContent":["import { useRef, useSyncExternalStore } from \"react\";\n\ntype Subscription<TState> = (state: TState) => void;\n\ntype BasicStore<TState> = {\n\tgetState(): TState;\n\tsubscribe(listener: Subscription<TState>): () => void;\n};\n\nexport function useStoreSelector<TState, TSelected>(\n\tstore: BasicStore<TState>,\n\tselector: (state: TState) => TSelected,\n\tisEqual: (previous: TSelected, next: TSelected) => boolean = Object.is\n): TSelected {\n\tconst selectionRef = useRef<TSelected>(undefined);\n\n\tconst subscribe = (onStoreChange: () => void) =>\n\t\tstore.subscribe(() => {\n\t\t\tonStoreChange();\n\t\t});\n\n\tconst snapshot = useSyncExternalStore(\n\t\tsubscribe,\n\t\t() => store.getState(),\n\t\t() => store.getState()\n\t);\n\tconst selected = selector(snapshot);\n\n\tif (\n\t\tselectionRef.current === undefined ||\n\t\t!isEqual(selectionRef.current, selected)\n\t) {\n\t\tselectionRef.current = selected;\n\t}\n\n\treturn selectionRef.current as TSelected;\n}\n"],"mappings":";;;AASA,SAAgB,iBACf,OACA,UACA,UAA6D,OAAO,IACxD;CACZ,MAAM,eAAe,OAAkB,OAAU;CAEjD,MAAM,aAAa,kBAClB,MAAM,gBAAgB;AACrB,iBAAe;GACd;CAEH,MAAM,WAAW,qBAChB,iBACM,MAAM,UAAU,QAChB,MAAM,UAAU,CACtB;CACD,MAAM,WAAW,SAAS,SAAS;AAEnC,KACC,aAAa,YAAY,UACzB,CAAC,QAAQ,aAAa,SAAS,SAAS,CAExC,cAAa,UAAU;AAGxB,QAAO,aAAa"}
1
+ {"version":3,"file":"use-store-selector.js","names":[],"sources":["../../../../src/hooks/private/store/use-store-selector.ts"],"sourcesContent":["import { useRef, useSyncExternalStore } from \"react\";\n\ntype Subscription<TState> = (state: TState) => void;\n\ntype BasicStore<TState> = {\n\tgetState(): TState;\n\tsubscribe(listener: Subscription<TState>): () => void;\n};\n\n/**\n * React hook that bridges Zustand-like stores with React components by\n * memoizing selector results and resubscribing when dependencies change.\n */\nexport function useStoreSelector<TState, TSelected>(\n\tstore: BasicStore<TState>,\n\tselector: (state: TState) => TSelected,\n\tisEqual: (previous: TSelected, next: TSelected) => boolean = Object.is\n): TSelected {\n\tconst selectionRef = useRef<TSelected>(undefined);\n\n\tconst subscribe = (onStoreChange: () => void) =>\n\t\tstore.subscribe(() => {\n\t\t\tonStoreChange();\n\t\t});\n\n\tconst snapshot = useSyncExternalStore(\n\t\tsubscribe,\n\t\t() => store.getState(),\n\t\t() => store.getState()\n\t);\n\tconst selected = selector(snapshot);\n\n\tif (\n\t\tselectionRef.current === undefined ||\n\t\t!isEqual(selectionRef.current, selected)\n\t) {\n\t\tselectionRef.current = selected;\n\t}\n\n\treturn selectionRef.current as TSelected;\n}\n"],"mappings":";;;;;;;AAaA,SAAgB,iBACf,OACA,UACA,UAA6D,OAAO,IACxD;CACZ,MAAM,eAAe,OAAkB,OAAU;CAEjD,MAAM,aAAa,kBAClB,MAAM,gBAAgB;AACrB,iBAAe;GACd;CAOH,MAAM,WAAW,SALA,qBAChB,iBACM,MAAM,UAAU,QAChB,MAAM,UAAU,CACtB,CACkC;AAEnC,KACC,aAAa,YAAY,UACzB,CAAC,QAAQ,aAAa,SAAS,SAAS,CAExC,cAAa,UAAU;AAGxB,QAAO,aAAa"}
@@ -12,6 +12,10 @@ type UseWebsiteStoreOptions = {
12
12
  refetchInterval?: number | false;
13
13
  refetchOnWindowFocus?: boolean;
14
14
  };
15
+ /**
16
+ * Subscribes to the shared website store on the SDK client and exposes
17
+ * convenient loading/error state plus a manual refresh helper.
18
+ */
15
19
  declare function useWebsiteStore(client: CossistantClient, options?: UseWebsiteStoreOptions): UseWebsiteStoreResult;
16
20
  //#endregion
17
21
  export { UseWebsiteStoreOptions, UseWebsiteStoreResult, useWebsiteStore };
@@ -1 +1 @@
1
- {"version":3,"file":"use-website-store.d.ts","names":[],"sources":["../../../../src/hooks/private/store/use-website-store.ts"],"sourcesContent":[],"mappings":";;;KAgBY,qBAAA;WACF;EADE,MAAA,EAEH,YAFG,CAAA,QAAqB,CAAA;EAAA,SAAA,EAAA,OAAA;OACvB,EAGF,KAHE,GAAA,IAAA;SACD,EAAA,GAAA,GAGO,OAHP,CAGe,YAHf,CAAA,SAAA,CAAA,GAAA,IAAA,CAAA;;AAGe,KAGZ,sBAAA,GAHY;iBAAR,CAAA,EAAA,MAAA,GAAA,KAAA;EAAO,oBAAA,CAAA,EAAA,OAAA;AAGvB,CAAA;AAiBgB,iBAAA,eAAA,CAAe,MAAA,EACtB,gBADsB,EAAA,OAAA,CAAA,EAErB,sBAFqB,CAAA,EAG5B,qBAH4B"}
1
+ {"version":3,"file":"use-website-store.d.ts","names":[],"sources":["../../../../src/hooks/private/store/use-website-store.ts"],"sourcesContent":[],"mappings":";;;KAgBY,qBAAA;WACF;EADE,MAAA,EAEH,YAFG,CAAA,QAAqB,CAAA;EACvB,SAAA,EAAA,OAAA;EACD,KAAA,EAED,KAFC,GAAA,IAAA;EAED,OAAA,EAAA,GAAA,GACQ,OADR,CACgB,YADhB,CAAA,SAAA,CAAA,GAAA,IAAA,CAAA;CACgB;AAAR,KAGJ,sBAAA,GAHI;EAAO,eAAA,CAAA,EAAA,MAAA,GAAA,KAAA;EAGX,oBAAA,CAAA,EAAA,OAAsB;AAqBlC,CAAA;;;;;iBAAgB,eAAA,SACP,4BACC,yBACP"}
@@ -8,11 +8,14 @@ function toError(state, fallback) {
8
8
  if (!state.error) return null;
9
9
  return new Error(state.error.message);
10
10
  }
11
+ /**
12
+ * Subscribes to the shared website store on the SDK client and exposes
13
+ * convenient loading/error state plus a manual refresh helper.
14
+ */
11
15
  function useWebsiteStore(client, options = {}) {
12
- const store = client.websiteStore ?? (() => {
16
+ const state = useStoreSelector(client.websiteStore ?? (() => {
13
17
  throw new Error("Website store is not available on the client instance");
14
- })();
15
- const state = useStoreSelector(store, (current) => current);
18
+ })(), (current) => current);
16
19
  const query = useClientQuery({
17
20
  client,
18
21
  queryFn: (instance, params) => instance.fetchWebsite(params ?? {}),
@@ -1 +1 @@
1
- {"version":3,"file":"use-website-store.js","names":[],"sources":["../../../../src/hooks/private/store/use-website-store.ts"],"sourcesContent":["import type {\n\tCossistantClient,\n\tWebsiteState,\n\tWebsiteStore,\n} from \"@cossistant/core\";\nimport type { PublicWebsiteResponse } from \"@cossistant/types\";\nimport { useMemo } from \"react\";\nimport { useClientQuery } from \"../use-client-query\";\nimport { useStoreSelector } from \"./use-store-selector\";\n\nconst EMPTY_STATE: WebsiteState = {\n\twebsite: null,\n\tstatus: \"idle\",\n\terror: null,\n};\n\nexport type UseWebsiteStoreResult = {\n\twebsite: WebsiteState[\"website\"];\n\tstatus: WebsiteState[\"status\"];\n\tisLoading: boolean;\n\terror: Error | null;\n\trefresh: () => Promise<WebsiteState[\"website\"] | null>;\n};\n\nexport type UseWebsiteStoreOptions = {\n\trefetchInterval?: number | false;\n\trefetchOnWindowFocus?: boolean;\n};\n\nfunction toError(state: WebsiteState, fallback: Error | null): Error | null {\n\tif (fallback) {\n\t\treturn fallback;\n\t}\n\n\tif (!state.error) {\n\t\treturn null;\n\t}\n\n\treturn new Error(state.error.message);\n}\n\nexport function useWebsiteStore(\n\tclient: CossistantClient,\n\toptions: UseWebsiteStoreOptions = {}\n): UseWebsiteStoreResult {\n\tconst store =\n\t\tclient.websiteStore ??\n\t\t((): WebsiteStore => {\n\t\t\tthrow new Error(\"Website store is not available on the client instance\");\n\t\t})();\n\tconst state = useStoreSelector(store, (current) => current);\n\n\tconst query = useClientQuery<PublicWebsiteResponse, { force?: boolean }>({\n\t\tclient,\n\t\tqueryFn: (instance, params) => instance.fetchWebsite(params ?? {}),\n\t\tenabled: true,\n\t\trefetchInterval: options.refetchInterval ?? false,\n\t\trefetchOnWindowFocus: options.refetchOnWindowFocus ?? true,\n\t\trefetchOnMount: state.status === \"idle\",\n\t\tinitialData: state.website ?? undefined,\n\t});\n\n\tconst error = useMemo(\n\t\t() => toError(state, query.error),\n\t\t[state, query.error]\n\t);\n\tconst isLoading =\n\t\tquery.isLoading || state.status === \"loading\" || state.status === \"idle\";\n\n\tconst refresh = () =>\n\t\tquery\n\t\t\t.refetch({ force: true })\n\t\t\t.then((result) => result ?? client.websiteStore.getState().website)\n\t\t\t.catch(() => client.websiteStore.getState().website)\n\t\t\t.then((website) => website ?? null);\n\n\treturn {\n\t\twebsite: state.website,\n\t\tstatus: state.status,\n\t\tisLoading,\n\t\terror,\n\t\trefresh,\n\t};\n}\n"],"mappings":";;;;;AA6BA,SAAS,QAAQ,OAAqB,UAAsC;AAC3E,KAAI,SACH,QAAO;AAGR,KAAI,CAAC,MAAM,MACV,QAAO;AAGR,QAAO,IAAI,MAAM,MAAM,MAAM,QAAQ;;AAGtC,SAAgB,gBACf,QACA,UAAkC,EAAE,EACZ;CACxB,MAAM,QACL,OAAO,uBACc;AACpB,QAAM,IAAI,MAAM,wDAAwD;KACrE;CACL,MAAM,QAAQ,iBAAiB,QAAQ,YAAY,QAAQ;CAE3D,MAAM,QAAQ,eAA2D;EACxE;EACA,UAAU,UAAU,WAAW,SAAS,aAAa,UAAU,EAAE,CAAC;EAClE,SAAS;EACT,iBAAiB,QAAQ,mBAAmB;EAC5C,sBAAsB,QAAQ,wBAAwB;EACtD,gBAAgB,MAAM,WAAW;EACjC,aAAa,MAAM,WAAW;EAC9B,CAAC;CAEF,MAAM,QAAQ,cACP,QAAQ,OAAO,MAAM,MAAM,EACjC,CAAC,OAAO,MAAM,MAAM,CACpB;CACD,MAAM,YACL,MAAM,aAAa,MAAM,WAAW,aAAa,MAAM,WAAW;CAEnE,MAAM,gBACL,MACE,QAAQ,EAAE,OAAO,MAAM,CAAC,CACxB,MAAM,WAAW,UAAU,OAAO,aAAa,UAAU,CAAC,QAAQ,CAClE,YAAY,OAAO,aAAa,UAAU,CAAC,QAAQ,CACnD,MAAM,YAAY,WAAW,KAAK;AAErC,QAAO;EACN,SAAS,MAAM;EACf,QAAQ,MAAM;EACd;EACA;EACA;EACA"}
1
+ {"version":3,"file":"use-website-store.js","names":[],"sources":["../../../../src/hooks/private/store/use-website-store.ts"],"sourcesContent":["import type {\n\tCossistantClient,\n\tWebsiteState,\n\tWebsiteStore,\n} from \"@cossistant/core\";\nimport type { PublicWebsiteResponse } from \"@cossistant/types\";\nimport { useMemo } from \"react\";\nimport { useClientQuery } from \"../use-client-query\";\nimport { useStoreSelector } from \"./use-store-selector\";\n\nconst EMPTY_STATE: WebsiteState = {\n\twebsite: null,\n\tstatus: \"idle\",\n\terror: null,\n};\n\nexport type UseWebsiteStoreResult = {\n\twebsite: WebsiteState[\"website\"];\n\tstatus: WebsiteState[\"status\"];\n\tisLoading: boolean;\n\terror: Error | null;\n\trefresh: () => Promise<WebsiteState[\"website\"] | null>;\n};\n\nexport type UseWebsiteStoreOptions = {\n\trefetchInterval?: number | false;\n\trefetchOnWindowFocus?: boolean;\n};\n\nfunction toError(state: WebsiteState, fallback: Error | null): Error | null {\n\tif (fallback) {\n\t\treturn fallback;\n\t}\n\n\tif (!state.error) {\n\t\treturn null;\n\t}\n\n\treturn new Error(state.error.message);\n}\n\n/**\n * Subscribes to the shared website store on the SDK client and exposes\n * convenient loading/error state plus a manual refresh helper.\n */\nexport function useWebsiteStore(\n\tclient: CossistantClient,\n\toptions: UseWebsiteStoreOptions = {}\n): UseWebsiteStoreResult {\n\tconst store =\n\t\tclient.websiteStore ??\n\t\t((): WebsiteStore => {\n\t\t\tthrow new Error(\"Website store is not available on the client instance\");\n\t\t})();\n\tconst state = useStoreSelector(store, (current) => current);\n\n\tconst query = useClientQuery<PublicWebsiteResponse, { force?: boolean }>({\n\t\tclient,\n\t\tqueryFn: (instance, params) => instance.fetchWebsite(params ?? {}),\n\t\tenabled: true,\n\t\trefetchInterval: options.refetchInterval ?? false,\n\t\trefetchOnWindowFocus: options.refetchOnWindowFocus ?? true,\n\t\trefetchOnMount: state.status === \"idle\",\n\t\tinitialData: state.website ?? undefined,\n\t});\n\n\tconst error = useMemo(\n\t\t() => toError(state, query.error),\n\t\t[state, query.error]\n\t);\n\tconst isLoading =\n\t\tquery.isLoading || state.status === \"loading\" || state.status === \"idle\";\n\n\tconst refresh = () =>\n\t\tquery\n\t\t\t.refetch({ force: true })\n\t\t\t.then((result) => result ?? client.websiteStore.getState().website)\n\t\t\t.catch(() => client.websiteStore.getState().website)\n\t\t\t.then((website) => website ?? null);\n\n\treturn {\n\t\twebsite: state.website,\n\t\tstatus: state.status,\n\t\tisLoading,\n\t\terror,\n\t\trefresh,\n\t};\n}\n"],"mappings":";;;;;AA6BA,SAAS,QAAQ,OAAqB,UAAsC;AAC3E,KAAI,SACH,QAAO;AAGR,KAAI,CAAC,MAAM,MACV,QAAO;AAGR,QAAO,IAAI,MAAM,MAAM,MAAM,QAAQ;;;;;;AAOtC,SAAgB,gBACf,QACA,UAAkC,EAAE,EACZ;CAMxB,MAAM,QAAQ,iBAJb,OAAO,uBACc;AACpB,QAAM,IAAI,MAAM,wDAAwD;KACrE,GACkC,YAAY,QAAQ;CAE3D,MAAM,QAAQ,eAA2D;EACxE;EACA,UAAU,UAAU,WAAW,SAAS,aAAa,UAAU,EAAE,CAAC;EAClE,SAAS;EACT,iBAAiB,QAAQ,mBAAmB;EAC5C,sBAAsB,QAAQ,wBAAwB;EACtD,gBAAgB,MAAM,WAAW;EACjC,aAAa,MAAM,WAAW;EAC9B,CAAC;CAEF,MAAM,QAAQ,cACP,QAAQ,OAAO,MAAM,MAAM,EACjC,CAAC,OAAO,MAAM,MAAM,CACpB;CACD,MAAM,YACL,MAAM,aAAa,MAAM,WAAW,aAAa,MAAM,WAAW;CAEnE,MAAM,gBACL,MACE,QAAQ,EAAE,OAAO,MAAM,CAAC,CACxB,MAAM,WAAW,UAAU,OAAO,aAAa,UAAU,CAAC,QAAQ,CAClE,YAAY,OAAO,aAAa,UAAU,CAAC,QAAQ,CACnD,MAAM,YAAY,WAAW,KAAK;AAErC,QAAO;EACN,SAAS,MAAM;EACf,QAAQ,MAAM;EACd;EACA;EACA;EACA"}
@@ -0,0 +1,35 @@
1
+ import { SupportTextResolvedFormatter } from "../../support/text/locales/keys.js";
2
+ import { TypingEntry } from "@cossistant/core";
3
+ import { AvailableAIAgent, AvailableHumanAgent } from "@cossistant/types";
4
+
5
+ //#region src/hooks/private/typing.d.ts
6
+ type TimelineTypingParticipant = {
7
+ id: string;
8
+ type: "team_member" | "ai";
9
+ };
10
+ type PreviewTypingParticipant = TimelineTypingParticipant & {
11
+ name: string;
12
+ image: string | null;
13
+ };
14
+ type MapTypingEntriesToPreviewParticipantsOptions = {
15
+ availableHumanAgents: AvailableHumanAgent[];
16
+ availableAIAgents: AvailableAIAgent[];
17
+ text: SupportTextResolvedFormatter;
18
+ };
19
+ /**
20
+ * Converts raw typing events into participants understood by the timeline
21
+ * renderer.
22
+ */
23
+ declare function mapTypingEntriesToParticipants(entries: TypingEntry[]): TimelineTypingParticipant[];
24
+ /**
25
+ * Resolves typing events into fully hydrated preview participants with display
26
+ * names and avatars ready for UI consumption.
27
+ */
28
+ declare function mapTypingEntriesToPreviewParticipants(entries: TypingEntry[], {
29
+ availableHumanAgents,
30
+ availableAIAgents,
31
+ text
32
+ }: MapTypingEntriesToPreviewParticipantsOptions): PreviewTypingParticipant[];
33
+ //#endregion
34
+ export { MapTypingEntriesToPreviewParticipantsOptions, PreviewTypingParticipant, TimelineTypingParticipant, mapTypingEntriesToParticipants, mapTypingEntriesToPreviewParticipants };
35
+ //# sourceMappingURL=typing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typing.d.ts","names":[],"sources":["../../../src/hooks/private/typing.ts"],"sourcesContent":[],"mappings":";;;;;KAIY,yBAAA;;EAAA,IAAA,EAAA,aAAA,GAAA,IAAA;AAKZ,CAAA;AAKY,KALA,wBAAA,GAA2B,yBAKiB,GAAA;EACjC,IAAA,EAAA,MAAA;EACH,KAAA,EAAA,MAAA,GAAA,IAAA;CACb;AAA4B,KAHvB,4CAAA,GAGuB;EAOnB,oBAAA,EATO,mBASuB,EAAA;EA+B9B,iBAAA,EAvCI,gBAuCJ,EAAA;EACN,IAAA,EAvCH,4BAuCG;CAER;;;;;AAIyB,iBAtCX,8BAAA,CAsCW,OAAA,EArCjB,WAqCiB,EAAA,CAAA,EApCxB,yBAoCwB,EAAA;;;;;iBAPX,qCAAA,UACN;;;;GAKN,+CACD"}
@@ -0,0 +1,49 @@
1
+ //#region src/hooks/private/typing.ts
2
+ /**
3
+ * Converts raw typing events into participants understood by the timeline
4
+ * renderer.
5
+ */
6
+ function mapTypingEntriesToParticipants(entries) {
7
+ return entries.map((entry) => {
8
+ if (entry.actorType === "user") return {
9
+ id: entry.actorId,
10
+ type: "team_member"
11
+ };
12
+ if (entry.actorType === "ai_agent") return {
13
+ id: entry.actorId,
14
+ type: "ai"
15
+ };
16
+ return null;
17
+ }).filter((participant) => participant !== null);
18
+ }
19
+ /**
20
+ * Resolves typing events into fully hydrated preview participants with display
21
+ * names and avatars ready for UI consumption.
22
+ */
23
+ function mapTypingEntriesToPreviewParticipants(entries, { availableHumanAgents, availableAIAgents, text }) {
24
+ return entries.map((entry) => {
25
+ if (entry.actorType === "user") {
26
+ const human = availableHumanAgents.find((agent) => agent.id === entry.actorId);
27
+ return {
28
+ id: entry.actorId,
29
+ type: "team_member",
30
+ name: human?.name || text("common.fallbacks.supportTeam"),
31
+ image: human?.image ?? null
32
+ };
33
+ }
34
+ if (entry.actorType === "ai_agent") {
35
+ const ai = availableAIAgents.find((agent) => agent.id === entry.actorId);
36
+ return {
37
+ id: entry.actorId,
38
+ type: "ai",
39
+ name: ai?.name || text("common.fallbacks.aiAssistant"),
40
+ image: ai?.image ?? null
41
+ };
42
+ }
43
+ return null;
44
+ }).filter((participant) => participant !== null);
45
+ }
46
+
47
+ //#endregion
48
+ export { mapTypingEntriesToParticipants, mapTypingEntriesToPreviewParticipants };
49
+ //# sourceMappingURL=typing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typing.js","names":[],"sources":["../../../src/hooks/private/typing.ts"],"sourcesContent":["import type { TypingEntry } from \"@cossistant/core\";\nimport type { AvailableAIAgent, AvailableHumanAgent } from \"@cossistant/types\";\nimport type { SupportTextResolvedFormatter } from \"../../support/text/locales/keys\";\n\nexport type TimelineTypingParticipant = {\n\tid: string;\n\ttype: \"team_member\" | \"ai\";\n};\n\nexport type PreviewTypingParticipant = TimelineTypingParticipant & {\n\tname: string;\n\timage: string | null;\n};\n\nexport type MapTypingEntriesToPreviewParticipantsOptions = {\n\tavailableHumanAgents: AvailableHumanAgent[];\n\tavailableAIAgents: AvailableAIAgent[];\n\ttext: SupportTextResolvedFormatter;\n};\n\n/**\n * Converts raw typing events into participants understood by the timeline\n * renderer.\n */\nexport function mapTypingEntriesToParticipants(\n\tentries: TypingEntry[]\n): TimelineTypingParticipant[] {\n\treturn entries\n\t\t.map<TimelineTypingParticipant | null>((entry) => {\n\t\t\tif (entry.actorType === \"user\") {\n\t\t\t\treturn {\n\t\t\t\t\tid: entry.actorId,\n\t\t\t\t\ttype: \"team_member\",\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (entry.actorType === \"ai_agent\") {\n\t\t\t\treturn {\n\t\t\t\t\tid: entry.actorId,\n\t\t\t\t\ttype: \"ai\",\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn null;\n\t\t})\n\t\t.filter(\n\t\t\t(participant): participant is TimelineTypingParticipant =>\n\t\t\t\tparticipant !== null\n\t\t);\n}\n\n/**\n * Resolves typing events into fully hydrated preview participants with display\n * names and avatars ready for UI consumption.\n */\nexport function mapTypingEntriesToPreviewParticipants(\n\tentries: TypingEntry[],\n\t{\n\t\tavailableHumanAgents,\n\t\tavailableAIAgents,\n\t\ttext,\n\t}: MapTypingEntriesToPreviewParticipantsOptions\n): PreviewTypingParticipant[] {\n\treturn entries\n\t\t.map<PreviewTypingParticipant | null>((entry) => {\n\t\t\tif (entry.actorType === \"user\") {\n\t\t\t\tconst human = availableHumanAgents.find(\n\t\t\t\t\t(agent) => agent.id === entry.actorId\n\t\t\t\t);\n\n\t\t\t\treturn {\n\t\t\t\t\tid: entry.actorId,\n\t\t\t\t\ttype: \"team_member\",\n\t\t\t\t\tname: human?.name || text(\"common.fallbacks.supportTeam\"),\n\t\t\t\t\timage: human?.image ?? null,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (entry.actorType === \"ai_agent\") {\n\t\t\t\tconst ai = availableAIAgents.find(\n\t\t\t\t\t(agent) => agent.id === entry.actorId\n\t\t\t\t);\n\n\t\t\t\treturn {\n\t\t\t\t\tid: entry.actorId,\n\t\t\t\t\ttype: \"ai\",\n\t\t\t\t\tname: ai?.name || text(\"common.fallbacks.aiAssistant\"),\n\t\t\t\t\timage: ai?.image ?? null,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn null;\n\t\t})\n\t\t.filter(\n\t\t\t(participant): participant is PreviewTypingParticipant =>\n\t\t\t\tparticipant !== null\n\t\t);\n}\n"],"mappings":";;;;;AAwBA,SAAgB,+BACf,SAC8B;AAC9B,QAAO,QACL,KAAuC,UAAU;AACjD,MAAI,MAAM,cAAc,OACvB,QAAO;GACN,IAAI,MAAM;GACV,MAAM;GACN;AAGF,MAAI,MAAM,cAAc,WACvB,QAAO;GACN,IAAI,MAAM;GACV,MAAM;GACN;AAGF,SAAO;GACN,CACD,QACC,gBACA,gBAAgB,KACjB;;;;;;AAOH,SAAgB,sCACf,SACA,EACC,sBACA,mBACA,QAE4B;AAC7B,QAAO,QACL,KAAsC,UAAU;AAChD,MAAI,MAAM,cAAc,QAAQ;GAC/B,MAAM,QAAQ,qBAAqB,MACjC,UAAU,MAAM,OAAO,MAAM,QAC9B;AAED,UAAO;IACN,IAAI,MAAM;IACV,MAAM;IACN,MAAM,OAAO,QAAQ,KAAK,+BAA+B;IACzD,OAAO,OAAO,SAAS;IACvB;;AAGF,MAAI,MAAM,cAAc,YAAY;GACnC,MAAM,KAAK,kBAAkB,MAC3B,UAAU,MAAM,OAAO,MAAM,QAC9B;AAED,UAAO;IACN,IAAI,MAAM;IACV,MAAM;IACN,MAAM,IAAI,QAAQ,KAAK,+BAA+B;IACtD,OAAO,IAAI,SAAS;IACpB;;AAGF,SAAO;GACN,CACD,QACC,gBACA,gBAAgB,KACjB"}
@@ -19,6 +19,11 @@ type UseClientQueryResult<TData, TArgs> = {
19
19
  isLoading: boolean;
20
20
  refetch: (args?: TArgs) => Promise<TData | undefined>;
21
21
  };
22
+ /**
23
+ * Lightweight data-fetching abstraction that plugs into the SDK client instead
24
+ * of React Query. It tracks loading/error state, supports polling, window
25
+ * focus refetching and exposes a typed refetch helper.
26
+ */
22
27
  declare function useClientQuery<TData, TArgs = void>(options: UseClientQueryOptions<TData, TArgs>): UseClientQueryResult<TData, TArgs>;
23
28
  //#endregion
24
29
  export { useClientQuery };
@@ -1 +1 @@
1
- {"version":3,"file":"use-client-query.d.ts","names":[],"sources":["../../../src/hooks/private/use-client-query.ts"],"sourcesContent":[],"mappings":";;;KAGK,iCACI,yBACD,sBACH,QAAQ;KAER;EALA,MAAA,EAMI,gBANG;EAAA,OAAA,EAOF,OAPE,CAOM,KAPN,EAOa,KAPb,CAAA;SACH,CAAA,EAAA,OAAA;iBACD,CAAA,EAAA,MAAA,GAAA,KAAA;sBACK,CAAA,EAAA,OAAA;gBAAR,CAAA,EAAA,OAAA;EAAO,WAAA,CAAA,EASG,KATH;EAEP,WAAA,CAAA,EAQU,KARV;EAAqB,YAAA,CAAA,EAAA,SAAA,OAAA,EAAA;;KAYrB,oBAVa,CAAA,KAAA,EAAA,KAAA,CAAA,GAAA;MAAO,EAWlB,KAXkB,GAAA,SAAA;OAAf,EAYF,KAZE,GAAA,IAAA;WAKK,EAAA,OAAA;SACA,EAAA,CAAA,IAAA,CAAA,EAQG,KARH,EAAA,GAQa,OARb,CAQqB,KARrB,GAAA,SAAA,CAAA;CAAK;AAIf,iBAiBW,cAjBS,CAAA,KAAA,EAAA,QAAA,IAAA,CAAA,CAAA,OAAA,EAkBf,qBAlBe,CAkBO,KAlBP,EAkBc,KAlBd,CAAA,CAAA,EAmBtB,oBAnBsB,CAmBD,KAnBC,EAmBM,KAnBN,CAAA"}
1
+ {"version":3,"file":"use-client-query.d.ts","names":[],"sources":["../../../src/hooks/private/use-client-query.ts"],"sourcesContent":[],"mappings":";;;KAGK,iCACI,yBACD,sBACH,QAAQ;KAER;EALA,MAAA,EAMI,gBANG;EACH,OAAA,EAMC,OAND,CAMS,KANT,EAMgB,KANhB,CAAA;EACD,OAAA,CAAA,EAAA,OAAA;EACK,eAAA,CAAA,EAAA,MAAA,GAAA,KAAA;EAAR,oBAAA,CAAA,EAAA,OAAA;EAAO,cAAA,CAAA,EAAA,OAAA;EAEP,WAAA,CAAA,EAOU,KAPV;EACI,WAAA,CAAA,EAOM,KAPN;EACS,YAAA,CAAA,EAAA,SAAA,OAAA,EAAA;CAAO;KAUpB,oBAVK,CAAA,KAAA,EAAA,KAAA,CAAA,GAAA;EAKK,IAAA,EAMR,KANQ,GAAA,SAAA;EACA,KAAA,EAMP,KANO,GAAA,IAAA;EAAK,SAAA,EAAA,OAAA;EAIf,OAAA,EAAA,CAAA,IAAA,CAAA,EAIa,KAJb,EAAoB,GAIG,OAJH,CAIW,KAJX,GAAA,SAAA,CAAA;CAClB;;;;;;AAqBS,iBAAA,cAAc,CAAA,KAAA,EAAA,QAAA,IAAA,CAAA,CAAA,OAAA,EACpB,qBADoB,CACE,KADF,EACS,KADT,CAAA,CAAA,EAE3B,oBAF2B,CAEN,KAFM,EAEC,KAFD,CAAA"}
@@ -6,6 +6,11 @@ function toError(error) {
6
6
  return new Error(typeof error === "string" ? error : "Unknown error");
7
7
  }
8
8
  const EMPTY_DEPENDENCIES = [];
9
+ /**
10
+ * Lightweight data-fetching abstraction that plugs into the SDK client instead
11
+ * of React Query. It tracks loading/error state, supports polling, window
12
+ * focus refetching and exposes a typed refetch helper.
13
+ */
9
14
  function useClientQuery(options) {
10
15
  const { client, queryFn, enabled = true, refetchInterval = false, refetchOnWindowFocus = true, refetchOnMount = true, initialData, initialArgs, dependencies = EMPTY_DEPENDENCIES } = options;
11
16
  const [data, setData] = useState(initialData);