@novu/react 3.18.2 → 3.20.0-rc.d57e78e026

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 (31) hide show
  1. package/dist/cjs/components/telegram-connect-button/DefaultTelegramConnectButton.cjs +3 -0
  2. package/dist/cjs/components/telegram-connect-button/DefaultTelegramConnectButton.cjs.map +1 -1
  3. package/dist/cjs/components/telegram-connect-button/DefaultTelegramConnectButton.d.cts +1 -1
  4. package/dist/cjs/hooks/index.cjs +2 -0
  5. package/dist/cjs/hooks/index.cjs.map +1 -1
  6. package/dist/cjs/hooks/index.d.cts +1 -0
  7. package/dist/cjs/hooks/useAgentChat.cjs +290 -0
  8. package/dist/cjs/hooks/useAgentChat.cjs.map +1 -0
  9. package/dist/cjs/hooks/useAgentChat.d.cts +69 -0
  10. package/dist/cjs/index.cjs +2 -0
  11. package/dist/cjs/index.cjs.map +1 -1
  12. package/dist/cjs/index.d.cts +1 -0
  13. package/dist/cjs/server/index.cjs +18 -0
  14. package/dist/cjs/server/index.cjs.map +1 -1
  15. package/dist/cjs/server/index.d.cts +3 -1
  16. package/dist/esm/components/telegram-connect-button/DefaultTelegramConnectButton.d.ts +1 -1
  17. package/dist/esm/components/telegram-connect-button/DefaultTelegramConnectButton.js +3 -0
  18. package/dist/esm/components/telegram-connect-button/DefaultTelegramConnectButton.js.map +1 -1
  19. package/dist/esm/hooks/index.d.ts +1 -0
  20. package/dist/esm/hooks/index.js +1 -0
  21. package/dist/esm/hooks/index.js.map +1 -1
  22. package/dist/esm/hooks/useAgentChat.d.ts +69 -0
  23. package/dist/esm/hooks/useAgentChat.js +259 -0
  24. package/dist/esm/hooks/useAgentChat.js.map +1 -0
  25. package/dist/esm/index.d.ts +1 -0
  26. package/dist/esm/index.js +2 -0
  27. package/dist/esm/index.js.map +1 -1
  28. package/dist/esm/server/index.d.ts +3 -1
  29. package/dist/esm/server/index.js +17 -0
  30. package/dist/esm/server/index.js.map +1 -1
  31. package/package.json +2 -2
@@ -1,7 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { TelegramConnectButtonProps } from '@novu/js/ui';
3
3
 
4
- type DefaultTelegramConnectButtonProps = Pick<TelegramConnectButtonProps, 'integrationIdentifier' | 'subscriberId' | 'context' | 'onConnectSuccess' | 'onConnectError' | 'onDisconnectSuccess' | 'onDisconnectError' | 'connectLabel' | 'connectedLabel'>;
4
+ type DefaultTelegramConnectButtonProps = Pick<TelegramConnectButtonProps, 'integrationIdentifier' | 'subscriberId' | 'context' | 'contextHash' | 'onConnectSuccess' | 'onConnectError' | 'onDisconnectSuccess' | 'onDisconnectError' | 'connectLabel' | 'connectedLabel'>;
5
5
  declare const DefaultTelegramConnectButton: (props: DefaultTelegramConnectButtonProps) => react_jsx_runtime.JSX.Element;
6
6
 
7
7
  export { DefaultTelegramConnectButton, type DefaultTelegramConnectButtonProps };
@@ -8,6 +8,7 @@ var DefaultTelegramConnectButton = (props) => {
8
8
  integrationIdentifier,
9
9
  subscriberId,
10
10
  context,
11
+ contextHash,
11
12
  onConnectSuccess,
12
13
  onConnectError,
13
14
  onDisconnectSuccess,
@@ -24,6 +25,7 @@ var DefaultTelegramConnectButton = (props) => {
24
25
  integrationIdentifier,
25
26
  subscriberId,
26
27
  context,
28
+ contextHash,
27
29
  onConnectSuccess,
28
30
  onConnectError,
29
31
  onDisconnectSuccess,
@@ -39,6 +41,7 @@ var DefaultTelegramConnectButton = (props) => {
39
41
  integrationIdentifier,
40
42
  subscriberId,
41
43
  context,
44
+ contextHash,
42
45
  onConnectSuccess,
43
46
  onConnectError,
44
47
  onDisconnectSuccess,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/telegram-connect-button/DefaultTelegramConnectButton.tsx"],"sourcesContent":["import { TelegramConnectButtonProps } from '@novu/js/ui';\nimport { useCallback } from 'react';\nimport { useNovuUI } from '../../context/NovuUIContext';\nimport { Mounter } from '../Mounter';\n\nexport type DefaultTelegramConnectButtonProps = Pick<\n TelegramConnectButtonProps,\n | 'integrationIdentifier'\n | 'subscriberId'\n | 'context'\n | 'onConnectSuccess'\n | 'onConnectError'\n | 'onDisconnectSuccess'\n | 'onDisconnectError'\n | 'connectLabel'\n | 'connectedLabel'\n>;\n\nexport const DefaultTelegramConnectButton = (props: DefaultTelegramConnectButtonProps) => {\n const {\n integrationIdentifier,\n subscriberId,\n context,\n onConnectSuccess,\n onConnectError,\n onDisconnectSuccess,\n onDisconnectError,\n connectLabel,\n connectedLabel,\n } = props;\n const { novuUI } = useNovuUI();\n\n const mount = useCallback(\n (element: HTMLElement) => {\n return novuUI.mountComponent({\n name: 'TelegramConnectButton',\n props: {\n integrationIdentifier,\n subscriberId,\n context,\n onConnectSuccess,\n onConnectError,\n onDisconnectSuccess,\n onDisconnectError,\n connectLabel,\n connectedLabel,\n },\n element,\n });\n },\n [\n novuUI,\n integrationIdentifier,\n subscriberId,\n context,\n onConnectSuccess,\n onConnectError,\n onDisconnectSuccess,\n onDisconnectError,\n connectLabel,\n connectedLabel,\n ]\n );\n\n return <Mounter mount={mount} />;\n};\n"],"mappings":";AACA,SAAS,mBAAmB;AAC5B,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AA6Df;AA9CF,IAAM,+BAA+B,CAAC,UAA6C;AACxF,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AACJ,QAAM,EAAE,OAAO,IAAI,UAAU;AAE7B,QAAM,QAAQ;AAAA,IACZ,CAAC,YAAyB;AACxB,aAAO,OAAO,eAAe;AAAA,QAC3B,MAAM;AAAA,QACN,OAAO;AAAA,UACL;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO,oBAAC,WAAQ,OAAc;AAChC;","names":[]}
1
+ {"version":3,"sources":["../../../../src/components/telegram-connect-button/DefaultTelegramConnectButton.tsx"],"sourcesContent":["import { TelegramConnectButtonProps } from '@novu/js/ui';\nimport { useCallback } from 'react';\nimport { useNovuUI } from '../../context/NovuUIContext';\nimport { Mounter } from '../Mounter';\n\nexport type DefaultTelegramConnectButtonProps = Pick<\n TelegramConnectButtonProps,\n | 'integrationIdentifier'\n | 'subscriberId'\n | 'context'\n | 'contextHash'\n | 'onConnectSuccess'\n | 'onConnectError'\n | 'onDisconnectSuccess'\n | 'onDisconnectError'\n | 'connectLabel'\n | 'connectedLabel'\n>;\n\nexport const DefaultTelegramConnectButton = (props: DefaultTelegramConnectButtonProps) => {\n const {\n integrationIdentifier,\n subscriberId,\n context,\n contextHash,\n onConnectSuccess,\n onConnectError,\n onDisconnectSuccess,\n onDisconnectError,\n connectLabel,\n connectedLabel,\n } = props;\n const { novuUI } = useNovuUI();\n\n const mount = useCallback(\n (element: HTMLElement) => {\n return novuUI.mountComponent({\n name: 'TelegramConnectButton',\n props: {\n integrationIdentifier,\n subscriberId,\n context,\n contextHash,\n onConnectSuccess,\n onConnectError,\n onDisconnectSuccess,\n onDisconnectError,\n connectLabel,\n connectedLabel,\n },\n element,\n });\n },\n [\n novuUI,\n integrationIdentifier,\n subscriberId,\n context,\n contextHash,\n onConnectSuccess,\n onConnectError,\n onDisconnectSuccess,\n onDisconnectError,\n connectLabel,\n connectedLabel,\n ]\n );\n\n return <Mounter mount={mount} />;\n};\n"],"mappings":";AACA,SAAS,mBAAmB;AAC5B,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AAiEf;AAjDF,IAAM,+BAA+B,CAAC,UAA6C;AACxF,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AACJ,QAAM,EAAE,OAAO,IAAI,UAAU;AAE7B,QAAM,QAAQ;AAAA,IACZ,CAAC,YAAyB;AACxB,aAAO,OAAO,eAAe;AAAA,QAC3B,MAAM;AAAA,QACN,OAAO;AAAA,UACL;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO,oBAAC,WAAQ,OAAc;AAChC;","names":[]}
@@ -1,6 +1,7 @@
1
1
  export * from '@novu/js';
2
2
  export { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum } from '@novu/js';
3
3
  export { NovuProvider, useNovu } from './NovuProvider.js';
4
+ export { UseAgentChatProps, UseAgentChatResult, useAgentChat } from './useAgentChat.js';
4
5
  export { UseChannelConnectionProps, UseChannelConnectionResult, useChannelConnection } from './useChannelConnection.js';
5
6
  export { UseChannelConnectionsProps, UseChannelConnectionsResult, useChannelConnections } from './useChannelConnections.js';
6
7
  export { UseChannelEndpointProps, UseChannelEndpointResult, useChannelEndpoint } from './useChannelEndpoint.js';
@@ -1,6 +1,7 @@
1
1
  // src/hooks/index.ts
2
2
  import { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum } from "@novu/js";
3
3
  import { NovuProvider, useNovu } from "./NovuProvider.js";
4
+ export * from "./useAgentChat.js";
4
5
  export * from "./useChannelConnection.js";
5
6
  export * from "./useChannelConnections.js";
6
7
  export * from "./useChannelEndpoint.js";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/hooks/index.ts"],"sourcesContent":["export type * from '@novu/js';\nexport { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum } from '@novu/js';\nexport { NovuProvider, useNovu } from './NovuProvider';\nexport * from './useChannelConnection';\nexport * from './useChannelConnections';\nexport * from './useChannelEndpoint';\nexport * from './useChannelEndpoints';\nexport * from './useCounts';\nexport * from './useCreateChannelEndpoint';\nexport * from './useCreateSubscription';\nexport * from './useDeleteChannelConnection';\nexport * from './useDeleteChannelEndpoint';\nexport * from './useNotifications';\nexport * from './usePreferences';\nexport * from './useRemoveSubscription';\nexport * from './useSchedule';\nexport * from './useSubscription';\nexport * from './useSubscriptions';\nexport * from './useTelegramSubscriberLink';\nexport * from './useUpdateSubscription';\n"],"mappings":";AACA,SAAS,iBAAiB,mBAAmB,+BAA+B;AAC5E,SAAS,cAAc,eAAe;AACtC,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
1
+ {"version":3,"sources":["../../../src/hooks/index.ts"],"sourcesContent":["export type * from '@novu/js';\nexport { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum } from '@novu/js';\nexport { NovuProvider, useNovu } from './NovuProvider';\nexport * from './useAgentChat';\nexport * from './useChannelConnection';\nexport * from './useChannelConnections';\nexport * from './useChannelEndpoint';\nexport * from './useChannelEndpoints';\nexport * from './useCounts';\nexport * from './useCreateChannelEndpoint';\nexport * from './useCreateSubscription';\nexport * from './useDeleteChannelConnection';\nexport * from './useDeleteChannelEndpoint';\nexport * from './useNotifications';\nexport * from './usePreferences';\nexport * from './useRemoveSubscription';\nexport * from './useSchedule';\nexport * from './useSubscription';\nexport * from './useSubscriptions';\nexport * from './useTelegramSubscriberLink';\nexport * from './useUpdateSubscription';\n"],"mappings":";AACA,SAAS,iBAAiB,mBAAmB,+BAA+B;AAC5E,SAAS,cAAc,eAAe;AACtC,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
@@ -0,0 +1,69 @@
1
+ import { AgentHashFields, LoadConversationResult, NovuError, AgentChatPlanLimitError, AgentMessage, AgentPendingAction, AgentEventEnvelope, AgentConversationTyping, AgentConversationStatus, SendMessageResult, RespondToActionResult } from '@novu/js';
2
+
3
+ type UseAgentChatProps = AgentHashFields & {
4
+ agentId: string;
5
+ /**
6
+ * Resume this conversation. The hook loads history on mount.
7
+ * Omit this prop to start a new chat. The first send creates a conversation.
8
+ * Later sends pass the returned id. Remount or clear this prop to start another chat.
9
+ */
10
+ conversationId?: string;
11
+ onSuccess?: (data: LoadConversationResult) => void;
12
+ onError?: (error: NovuError | AgentChatPlanLimitError) => void;
13
+ /**
14
+ * Fires once per message, when the message id first appears on the conversation.
15
+ * History pages are silent: only new activity fires.
16
+ * An agent message can still be empty at this point, because the first envelope of a
17
+ * turn creates the message before any text is folded into it.
18
+ * A send that never reaches the server does not fire: the message flips to `failed` instead.
19
+ */
20
+ onMessage?: (message: AgentMessage) => void;
21
+ /**
22
+ * Fires once per pending action, including actions still pending on mount, so a
23
+ * resumed conversation reports what it is blocked on. Paging backwards is silent.
24
+ */
25
+ onActionRequested?: (action: AgentPendingAction) => void;
26
+ /**
27
+ * Raw envelopes for this conversation, before the derived callbacks for the same fold.
28
+ * A duplicate envelope that the store drops does not fire. Neither does an envelope that
29
+ * arrives before a newly created conversation claims its id.
30
+ * The store folds the envelope before this callback runs, so `messages` here is one render old.
31
+ */
32
+ onEvent?: (envelope: AgentEventEnvelope) => void;
33
+ };
34
+ type UseAgentChatResult = {
35
+ messages: AgentMessage[];
36
+ pendingActions: AgentPendingAction[];
37
+ conversationId?: string;
38
+ error?: NovuError | AgentChatPlanLimitError;
39
+ /** True until the first history fetch completes. False when there is no `conversationId` prop. */
40
+ isLoading: boolean;
41
+ isFetching: boolean;
42
+ isRunning: boolean;
43
+ typing?: AgentConversationTyping;
44
+ status: AgentConversationStatus;
45
+ /** True when older history pages are available via `fetchMore`. */
46
+ hasMore: boolean;
47
+ refetch: () => Promise<void>;
48
+ fetchMore: () => Promise<{
49
+ data?: {
50
+ messages: AgentMessage[];
51
+ hasMore: boolean;
52
+ };
53
+ error?: NovuError;
54
+ }>;
55
+ sendMessage: (text: string) => Promise<{
56
+ data?: SendMessageResult;
57
+ error?: NovuError | AgentChatPlanLimitError;
58
+ }>;
59
+ respondToAction: (args: {
60
+ actionId: string;
61
+ decision: 'approved' | 'denied';
62
+ }) => Promise<{
63
+ data?: RespondToActionResult;
64
+ error?: NovuError | AgentChatPlanLimitError;
65
+ }>;
66
+ };
67
+ declare const useAgentChat: (props: UseAgentChatProps) => UseAgentChatResult;
68
+
69
+ export { type UseAgentChatProps, type UseAgentChatResult, useAgentChat };
@@ -0,0 +1,259 @@
1
+ // src/hooks/useAgentChat.ts
2
+ import { derivePendingActions } from "@novu/js";
3
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
4
+ import { useDataRef } from "./internal/useDataRef.js";
5
+ import { useNovu } from "./NovuProvider.js";
6
+ function createLocalSessionKey() {
7
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
8
+ return `local_${crypto.randomUUID().replace(/-/g, "").slice(0, 12)}`;
9
+ }
10
+ if (typeof crypto !== "undefined" && typeof crypto.getRandomValues === "function") {
11
+ const bytes = new Uint8Array(6);
12
+ crypto.getRandomValues(bytes);
13
+ return `local_${Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("")}`;
14
+ }
15
+ return `local_${Date.now().toString(36)}`;
16
+ }
17
+ var EMPTY_CONVERSATION = {
18
+ messages: [],
19
+ isRunning: false,
20
+ typing: void 0,
21
+ status: "active",
22
+ hasMore: false
23
+ };
24
+ function applyConversationSnapshot(snapshot, setters) {
25
+ setters.setMessages(snapshot.messages);
26
+ setters.setIsRunning(snapshot.isRunning);
27
+ setters.setTyping(snapshot.typing);
28
+ setters.setStatus(snapshot.status);
29
+ setters.setHasMore(snapshot.hasMore);
30
+ }
31
+ var useAgentChat = (props) => {
32
+ const { agentId, agentHash, conversationId: conversationIdProp } = props;
33
+ const propsRef = useDataRef(props);
34
+ const novu = useNovu();
35
+ const [localSessionKey, setLocalSessionKey] = useState(createLocalSessionKey);
36
+ const sessionKey = conversationIdProp ?? localSessionKey;
37
+ const sessionKeyRef = useDataRef(sessionKey);
38
+ const prevAgentIdRef = useRef(agentId);
39
+ const prevConversationIdPropRef = useRef(conversationIdProp);
40
+ const [assignedConversationId, setAssignedConversationId] = useState();
41
+ const conversationId = conversationIdProp ?? assignedConversationId;
42
+ const conversationIdRef = useDataRef(conversationId);
43
+ const [messages, setMessages] = useState([]);
44
+ const [isRunning, setIsRunning] = useState(false);
45
+ const [typing, setTyping] = useState();
46
+ const [status, setStatus] = useState("active");
47
+ const [hasMore, setHasMore] = useState(false);
48
+ const [error, setError] = useState();
49
+ const [isLoading, setIsLoading] = useState(Boolean(conversationIdProp));
50
+ const [isFetching, setIsFetching] = useState(false);
51
+ const fetchGenerationRef = useRef(0);
52
+ const pendingActions = useMemo(() => derivePendingActions(messages), [messages]);
53
+ const snapshotSetters = useMemo(
54
+ () => ({
55
+ setMessages,
56
+ setIsRunning,
57
+ setTyping,
58
+ setStatus,
59
+ setHasMore
60
+ }),
61
+ []
62
+ );
63
+ useEffect(() => {
64
+ const agentChanged = prevAgentIdRef.current !== agentId;
65
+ const prevConversationIdProp = prevConversationIdPropRef.current;
66
+ prevAgentIdRef.current = agentId;
67
+ prevConversationIdPropRef.current = conversationIdProp;
68
+ if (agentChanged) {
69
+ setAssignedConversationId(void 0);
70
+ setLocalSessionKey(createLocalSessionKey());
71
+ applyConversationSnapshot(EMPTY_CONVERSATION, snapshotSetters);
72
+ setError(void 0);
73
+ setIsLoading(Boolean(conversationIdProp));
74
+ return;
75
+ }
76
+ if (conversationIdProp) {
77
+ setAssignedConversationId(void 0);
78
+ return;
79
+ }
80
+ setIsLoading(false);
81
+ if (prevConversationIdProp !== void 0) {
82
+ setAssignedConversationId(void 0);
83
+ setLocalSessionKey(createLocalSessionKey());
84
+ applyConversationSnapshot(EMPTY_CONVERSATION, snapshotSetters);
85
+ }
86
+ }, [agentId, conversationIdProp, snapshotSetters]);
87
+ const fetchConversation = useCallback(
88
+ async (targetConversationId) => {
89
+ const generation = ++fetchGenerationRef.current;
90
+ setError(void 0);
91
+ setIsLoading(true);
92
+ setIsFetching(true);
93
+ const response = await novu.agentChat.loadConversation({
94
+ agentId,
95
+ conversationId: targetConversationId
96
+ });
97
+ if (generation !== fetchGenerationRef.current) {
98
+ return;
99
+ }
100
+ if (response.error) {
101
+ setError(response.error);
102
+ propsRef.current.onError?.(response.error);
103
+ } else if (response.data) {
104
+ setMessages(response.data.messages);
105
+ setHasMore(response.data.hasMore);
106
+ propsRef.current.onSuccess?.(response.data);
107
+ }
108
+ setIsLoading(false);
109
+ setIsFetching(false);
110
+ },
111
+ [novu, agentId, propsRef]
112
+ );
113
+ useEffect(() => {
114
+ novu.agentChat.subscribe();
115
+ const snapshot = novu.agentChat.getConversation({
116
+ agentId,
117
+ key: sessionKey,
118
+ conversationId: conversationIdProp
119
+ });
120
+ if (snapshot) {
121
+ applyConversationSnapshot(
122
+ {
123
+ messages: snapshot.messages,
124
+ isRunning: snapshot.isRunning,
125
+ typing: snapshot.typing,
126
+ status: snapshot.status,
127
+ hasMore: snapshot.hasMore
128
+ },
129
+ snapshotSetters
130
+ );
131
+ if (snapshot.conversationId && !conversationIdProp) {
132
+ setAssignedConversationId(snapshot.conversationId);
133
+ }
134
+ for (const action of derivePendingActions(snapshot.messages)) {
135
+ propsRef.current.onActionRequested?.(action);
136
+ }
137
+ } else if (!conversationIdProp) {
138
+ applyConversationSnapshot(EMPTY_CONVERSATION, snapshotSetters);
139
+ }
140
+ const cleanup = novu.on("agent_chat.messages.updated", ({ data }) => {
141
+ if (data.key !== sessionKeyRef.current) {
142
+ return;
143
+ }
144
+ applyConversationSnapshot(
145
+ {
146
+ messages: data.messages,
147
+ isRunning: data.isRunning,
148
+ typing: data.typing,
149
+ status: data.status,
150
+ hasMore: data.hasMore
151
+ },
152
+ snapshotSetters
153
+ );
154
+ if (data.conversationId && !propsRef.current.conversationId) {
155
+ setAssignedConversationId(data.conversationId);
156
+ }
157
+ const { change } = data;
158
+ if (change.kind === "live") {
159
+ propsRef.current.onEvent?.(change.envelope);
160
+ }
161
+ if (change.kind !== "history") {
162
+ for (const message of change.addedMessages) {
163
+ propsRef.current.onMessage?.(message);
164
+ }
165
+ }
166
+ for (const action of change.newActions) {
167
+ propsRef.current.onActionRequested?.(action);
168
+ }
169
+ });
170
+ if (conversationIdProp) {
171
+ void fetchConversation(conversationIdProp);
172
+ }
173
+ return () => {
174
+ cleanup();
175
+ novu.agentChat.unsubscribe();
176
+ };
177
+ }, [novu, agentId, conversationIdProp, sessionKey, sessionKeyRef, propsRef, fetchConversation, snapshotSetters]);
178
+ const refetch = useCallback(async () => {
179
+ const id = conversationIdRef.current;
180
+ if (!id) {
181
+ return;
182
+ }
183
+ await fetchConversation(id);
184
+ }, [conversationIdRef, fetchConversation]);
185
+ const fetchMore = useCallback(async () => {
186
+ const response = await novu.agentChat.fetchMore({
187
+ agentId,
188
+ key: sessionKeyRef.current,
189
+ conversationId: conversationIdRef.current
190
+ });
191
+ if (response.error) {
192
+ setError(response.error);
193
+ propsRef.current.onError?.(response.error);
194
+ } else if (response.data) {
195
+ setMessages(response.data.messages);
196
+ setHasMore(response.data.hasMore);
197
+ }
198
+ return response;
199
+ }, [novu, agentId, sessionKeyRef, conversationIdRef, propsRef]);
200
+ const sendMessage = useCallback(
201
+ async (text) => {
202
+ setError(void 0);
203
+ const response = await novu.agentChat.sendMessage({
204
+ agentId,
205
+ agentHash,
206
+ text,
207
+ key: sessionKeyRef.current,
208
+ conversationId: conversationIdRef.current
209
+ });
210
+ if (response.error) {
211
+ setError(response.error);
212
+ propsRef.current.onError?.(response.error);
213
+ } else if (response.data && !propsRef.current.conversationId) {
214
+ setAssignedConversationId(response.data.conversationId);
215
+ }
216
+ return response;
217
+ },
218
+ [novu, agentId, agentHash, sessionKeyRef, conversationIdRef, propsRef]
219
+ );
220
+ const respondToAction = useCallback(
221
+ async (args) => {
222
+ setError(void 0);
223
+ const response = await novu.agentChat.respondToAction({
224
+ agentId,
225
+ agentHash,
226
+ key: sessionKeyRef.current,
227
+ conversationId: conversationIdRef.current,
228
+ actionId: args.actionId,
229
+ decision: args.decision
230
+ });
231
+ if (response.error) {
232
+ setError(response.error);
233
+ propsRef.current.onError?.(response.error);
234
+ }
235
+ return response;
236
+ },
237
+ [novu, agentId, agentHash, sessionKeyRef, conversationIdRef, propsRef]
238
+ );
239
+ return {
240
+ messages,
241
+ pendingActions,
242
+ sendMessage,
243
+ respondToAction,
244
+ conversationId,
245
+ error,
246
+ isLoading,
247
+ isFetching,
248
+ isRunning,
249
+ typing,
250
+ status,
251
+ hasMore,
252
+ refetch,
253
+ fetchMore
254
+ };
255
+ };
256
+ export {
257
+ useAgentChat
258
+ };
259
+ //# sourceMappingURL=useAgentChat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/hooks/useAgentChat.ts"],"sourcesContent":["import type {\n AgentChatPlanLimitError,\n AgentConversationStatus,\n AgentConversationTyping,\n AgentEventEnvelope,\n AgentHashFields,\n AgentMessage,\n AgentPendingAction,\n LoadConversationResult,\n NovuError,\n RespondToActionResult,\n SendMessageResult,\n} from '@novu/js';\nimport { derivePendingActions } from '@novu/js';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { useDataRef } from './internal/useDataRef';\nimport { useNovu } from './NovuProvider';\n\nexport type UseAgentChatProps = AgentHashFields & {\n agentId: string;\n /**\n * Resume this conversation. The hook loads history on mount.\n * Omit this prop to start a new chat. The first send creates a conversation.\n * Later sends pass the returned id. Remount or clear this prop to start another chat.\n */\n conversationId?: string;\n onSuccess?: (data: LoadConversationResult) => void;\n onError?: (error: NovuError | AgentChatPlanLimitError) => void;\n /**\n * Fires once per message, when the message id first appears on the conversation.\n * History pages are silent: only new activity fires.\n * An agent message can still be empty at this point, because the first envelope of a\n * turn creates the message before any text is folded into it.\n * A send that never reaches the server does not fire: the message flips to `failed` instead.\n */\n onMessage?: (message: AgentMessage) => void;\n /**\n * Fires once per pending action, including actions still pending on mount, so a\n * resumed conversation reports what it is blocked on. Paging backwards is silent.\n */\n onActionRequested?: (action: AgentPendingAction) => void;\n /**\n * Raw envelopes for this conversation, before the derived callbacks for the same fold.\n * A duplicate envelope that the store drops does not fire. Neither does an envelope that\n * arrives before a newly created conversation claims its id.\n * The store folds the envelope before this callback runs, so `messages` here is one render old.\n */\n onEvent?: (envelope: AgentEventEnvelope) => void;\n};\n\nexport type UseAgentChatResult = {\n messages: AgentMessage[];\n pendingActions: AgentPendingAction[];\n conversationId?: string;\n error?: NovuError | AgentChatPlanLimitError;\n /** True until the first history fetch completes. False when there is no `conversationId` prop. */\n isLoading: boolean;\n isFetching: boolean;\n isRunning: boolean;\n typing?: AgentConversationTyping;\n status: AgentConversationStatus;\n /** True when older history pages are available via `fetchMore`. */\n hasMore: boolean;\n refetch: () => Promise<void>;\n fetchMore: () => Promise<{\n data?: { messages: AgentMessage[]; hasMore: boolean };\n error?: NovuError;\n }>;\n sendMessage: (text: string) => Promise<{\n data?: SendMessageResult;\n error?: NovuError | AgentChatPlanLimitError;\n }>;\n respondToAction: (args: { actionId: string; decision: 'approved' | 'denied' }) => Promise<{\n data?: RespondToActionResult;\n error?: NovuError | AgentChatPlanLimitError;\n }>;\n};\n\nfunction createLocalSessionKey(): string {\n if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {\n return `local_${crypto.randomUUID().replace(/-/g, '').slice(0, 12)}`;\n }\n\n if (typeof crypto !== 'undefined' && typeof crypto.getRandomValues === 'function') {\n const bytes = new Uint8Array(6);\n crypto.getRandomValues(bytes);\n\n return `local_${Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0')).join('')}`;\n }\n\n return `local_${Date.now().toString(36)}`;\n}\n\ntype ConversationSnapshot = {\n messages: AgentMessage[];\n isRunning: boolean;\n typing?: AgentConversationTyping;\n status: AgentConversationStatus;\n hasMore: boolean;\n};\n\nconst EMPTY_CONVERSATION: ConversationSnapshot = {\n messages: [],\n isRunning: false,\n typing: undefined,\n status: 'active',\n hasMore: false,\n};\n\nfunction applyConversationSnapshot(\n snapshot: ConversationSnapshot,\n setters: {\n setMessages: (messages: AgentMessage[]) => void;\n setIsRunning: (isRunning: boolean) => void;\n setTyping: (typing?: AgentConversationTyping) => void;\n setStatus: (status: AgentConversationStatus) => void;\n setHasMore: (hasMore: boolean) => void;\n }\n): void {\n setters.setMessages(snapshot.messages);\n setters.setIsRunning(snapshot.isRunning);\n setters.setTyping(snapshot.typing);\n setters.setStatus(snapshot.status);\n setters.setHasMore(snapshot.hasMore);\n}\n\nexport const useAgentChat = (props: UseAgentChatProps): UseAgentChatResult => {\n const { agentId, agentHash, conversationId: conversationIdProp } = props;\n const propsRef = useDataRef(props);\n const novu = useNovu();\n\n // Resume: the prop is the key on the same render (no effect lag).\n // Create: keep a `local_*` key until remount, prop clear, or agent change.\n const [localSessionKey, setLocalSessionKey] = useState(createLocalSessionKey);\n const sessionKey = conversationIdProp ?? localSessionKey;\n const sessionKeyRef = useDataRef(sessionKey);\n const prevAgentIdRef = useRef(agentId);\n const prevConversationIdPropRef = useRef(conversationIdProp);\n\n const [assignedConversationId, setAssignedConversationId] = useState<string>();\n const conversationId = conversationIdProp ?? assignedConversationId;\n const conversationIdRef = useDataRef(conversationId);\n\n const [messages, setMessages] = useState<AgentMessage[]>([]);\n const [isRunning, setIsRunning] = useState(false);\n const [typing, setTyping] = useState<AgentConversationTyping>();\n const [status, setStatus] = useState<AgentConversationStatus>('active');\n const [hasMore, setHasMore] = useState(false);\n const [error, setError] = useState<NovuError | AgentChatPlanLimitError>();\n const [isLoading, setIsLoading] = useState(Boolean(conversationIdProp));\n const [isFetching, setIsFetching] = useState(false);\n const fetchGenerationRef = useRef(0);\n\n const pendingActions = useMemo(() => derivePendingActions(messages), [messages]);\n\n const snapshotSetters = useMemo(\n () => ({\n setMessages,\n setIsRunning,\n setTyping,\n setStatus,\n setHasMore,\n }),\n []\n );\n\n useEffect(() => {\n const agentChanged = prevAgentIdRef.current !== agentId;\n const prevConversationIdProp = prevConversationIdPropRef.current;\n prevAgentIdRef.current = agentId;\n prevConversationIdPropRef.current = conversationIdProp;\n\n if (agentChanged) {\n setAssignedConversationId(undefined);\n setLocalSessionKey(createLocalSessionKey());\n applyConversationSnapshot(EMPTY_CONVERSATION, snapshotSetters);\n setError(undefined);\n setIsLoading(Boolean(conversationIdProp));\n\n return;\n }\n\n if (conversationIdProp) {\n setAssignedConversationId(undefined);\n\n return;\n }\n\n setIsLoading(false);\n if (prevConversationIdProp !== undefined) {\n setAssignedConversationId(undefined);\n setLocalSessionKey(createLocalSessionKey());\n applyConversationSnapshot(EMPTY_CONVERSATION, snapshotSetters);\n }\n }, [agentId, conversationIdProp, snapshotSetters]);\n\n const fetchConversation = useCallback(\n async (targetConversationId: string) => {\n const generation = ++fetchGenerationRef.current;\n setError(undefined);\n setIsLoading(true);\n setIsFetching(true);\n\n const response = await novu.agentChat.loadConversation({\n agentId,\n conversationId: targetConversationId,\n });\n\n if (generation !== fetchGenerationRef.current) {\n return;\n }\n\n if (response.error) {\n setError(response.error);\n propsRef.current.onError?.(response.error);\n } else if (response.data) {\n setMessages(response.data.messages);\n setHasMore(response.data.hasMore);\n propsRef.current.onSuccess?.(response.data);\n }\n\n setIsLoading(false);\n setIsFetching(false);\n },\n [novu, agentId, propsRef]\n );\n\n useEffect(() => {\n novu.agentChat.subscribe();\n\n const snapshot = novu.agentChat.getConversation({\n agentId,\n key: sessionKey,\n conversationId: conversationIdProp,\n });\n if (snapshot) {\n applyConversationSnapshot(\n {\n messages: snapshot.messages,\n isRunning: snapshot.isRunning,\n typing: snapshot.typing,\n status: snapshot.status,\n hasMore: snapshot.hasMore,\n },\n snapshotSetters\n );\n if (snapshot.conversationId && !conversationIdProp) {\n setAssignedConversationId(snapshot.conversationId);\n }\n\n // The store reports each action once per holder, and a holder outlives a mount.\n // Replay from the snapshot so a remount still learns what the run is blocked on.\n for (const action of derivePendingActions(snapshot.messages)) {\n propsRef.current.onActionRequested?.(action);\n }\n } else if (!conversationIdProp) {\n applyConversationSnapshot(EMPTY_CONVERSATION, snapshotSetters);\n }\n\n const cleanup = novu.on('agent_chat.messages.updated', ({ data }) => {\n if (data.key !== sessionKeyRef.current) {\n return;\n }\n\n applyConversationSnapshot(\n {\n messages: data.messages,\n isRunning: data.isRunning,\n typing: data.typing,\n status: data.status,\n hasMore: data.hasMore,\n },\n snapshotSetters\n );\n if (data.conversationId && !propsRef.current.conversationId) {\n setAssignedConversationId(data.conversationId);\n }\n\n const { change } = data;\n if (change.kind === 'live') {\n propsRef.current.onEvent?.(change.envelope);\n }\n\n if (change.kind !== 'history') {\n for (const message of change.addedMessages) {\n propsRef.current.onMessage?.(message);\n }\n }\n\n for (const action of change.newActions) {\n propsRef.current.onActionRequested?.(action);\n }\n });\n\n if (conversationIdProp) {\n void fetchConversation(conversationIdProp);\n }\n\n return () => {\n cleanup();\n novu.agentChat.unsubscribe();\n };\n }, [novu, agentId, conversationIdProp, sessionKey, sessionKeyRef, propsRef, fetchConversation, snapshotSetters]);\n\n const refetch = useCallback(async () => {\n const id = conversationIdRef.current;\n if (!id) {\n return;\n }\n\n await fetchConversation(id);\n }, [conversationIdRef, fetchConversation]);\n\n const fetchMore = useCallback(async () => {\n const response = await novu.agentChat.fetchMore({\n agentId,\n key: sessionKeyRef.current,\n conversationId: conversationIdRef.current,\n });\n\n if (response.error) {\n setError(response.error);\n propsRef.current.onError?.(response.error);\n } else if (response.data) {\n setMessages(response.data.messages);\n setHasMore(response.data.hasMore);\n }\n\n return response;\n }, [novu, agentId, sessionKeyRef, conversationIdRef, propsRef]);\n\n const sendMessage = useCallback(\n async (text: string) => {\n setError(undefined);\n\n const response = await novu.agentChat.sendMessage({\n agentId,\n agentHash,\n text,\n key: sessionKeyRef.current,\n conversationId: conversationIdRef.current,\n });\n\n if (response.error) {\n setError(response.error);\n propsRef.current.onError?.(response.error);\n } else if (response.data && !propsRef.current.conversationId) {\n setAssignedConversationId(response.data.conversationId);\n }\n\n return response;\n },\n [novu, agentId, agentHash, sessionKeyRef, conversationIdRef, propsRef]\n );\n\n const respondToAction = useCallback(\n async (args: { actionId: string; decision: 'approved' | 'denied' }) => {\n setError(undefined);\n\n const response = await novu.agentChat.respondToAction({\n agentId,\n agentHash,\n key: sessionKeyRef.current,\n conversationId: conversationIdRef.current,\n actionId: args.actionId,\n decision: args.decision,\n });\n\n if (response.error) {\n setError(response.error);\n propsRef.current.onError?.(response.error);\n }\n\n return response;\n },\n [novu, agentId, agentHash, sessionKeyRef, conversationIdRef, propsRef]\n );\n\n return {\n messages,\n pendingActions,\n sendMessage,\n respondToAction,\n conversationId,\n error,\n isLoading,\n isFetching,\n isRunning,\n typing,\n status,\n hasMore,\n refetch,\n fetchMore,\n };\n};\n"],"mappings":";AAaA,SAAS,4BAA4B;AACrC,SAAS,aAAa,WAAW,SAAS,QAAQ,gBAAgB;AAClE,SAAS,kBAAkB;AAC3B,SAAS,eAAe;AA8DxB,SAAS,wBAAgC;AACvC,MAAI,OAAO,WAAW,eAAe,OAAO,OAAO,eAAe,YAAY;AAC5E,WAAO,SAAS,OAAO,WAAW,EAAE,QAAQ,MAAM,EAAE,EAAE,MAAM,GAAG,EAAE,CAAC;AAAA,EACpE;AAEA,MAAI,OAAO,WAAW,eAAe,OAAO,OAAO,oBAAoB,YAAY;AACjF,UAAM,QAAQ,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AiB;AACtB,eAAS,MAAS;AAElB,YAAM,WAAW,MAAM,KAAK,UAAU,YAAY;AAAA,QAChD;AAAA,QACA;AAAA,QACA;AAAA,QACA,KAAK,cAAc;AAAA,QACnB,gBAAgB,kBAAkB;AAAA,MACpC,CAAC;AAED,UAAI,SAAS,OAAO;AAClB,iBAAS,SAAS,KAAK;AACvB,iBAAS,QAAQ,UAAU,SAAS,KAAK;AAAA,MAC3C,WAAW,SAAS,QAAQ,CAAC,SAAS,QAAQ,gBAAgB;AAC5D,kCAA0B,SAAS,KAAK,cAAc;AAAA,MACxD;AAEA,aAAO;AAAA,IACT;AAAA,IACA,CAAC,MAAM,SAAS,WAAW,eAAe,mBAAmB,QAAQ;AAAA,EACvE;AAEA,QAAM,kBAAkB;AAAA,IACtB,OAAO,SAAgE;AACrE,eAAS,MAAS;AAElB,YAAM,WAAW,MAAM,KAAK,UAAU,gBAAgB;AAAA,QACpD;AAAA,QACA;AAAA,QACA,KAAK,cAAc;AAAA,QACnB,gBAAgB,kBAAkB;AAAA,QAClC,UAAU,KAAK;AAAA,QACf,UAAU,KAAK;AAAA,MACjB,CAAC;AAED,UAAI,SAAS,OAAO;AAClB,iBAAS,SAAS,KAAK;AACvB,iBAAS,QAAQ,UAAU,SAAS,KAAK;AAAA,MAC3C;AAEA,aAAO;AAAA,IACT;AAAA,IACA,CAAC,MAAM,SAAS,WAAW,eAAe,mBAAmB,QAAQ;AAAA,EACvE;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
@@ -15,6 +15,7 @@ export { Subscription, SubscriptionProps } from './components/subscription/Subsc
15
15
  export { SubscriptionButton, SubscriptionButtonProps } from './components/subscription/SubscriptionButton.js';
16
16
  export { SubscriptionPreferences, SubscriptionPreferencesProps } from './components/subscription/SubscriptionPreferences.js';
17
17
  export { TelegramConnectButton, TelegramConnectButtonProps } from './components/telegram-connect-button/TelegramConnectButton.js';
18
+ export { UseAgentChatProps, UseAgentChatResult, useAgentChat } from './hooks/useAgentChat.js';
18
19
  export { UseChannelConnectionProps, UseChannelConnectionResult, useChannelConnection } from './hooks/useChannelConnection.js';
19
20
  export { UseChannelConnectionsProps, UseChannelConnectionsResult, useChannelConnections } from './hooks/useChannelConnections.js';
20
21
  export { UseChannelEndpointProps, UseChannelEndpointResult, useChannelEndpoint } from './hooks/useChannelEndpoint.js';
package/dist/esm/index.js CHANGED
@@ -17,6 +17,7 @@ import {
17
17
  TelegramConnectButton
18
18
  } from "./components/index.js";
19
19
  import {
20
+ useAgentChat,
20
21
  useChannelConnection,
21
22
  useChannelConnections,
22
23
  useChannelEndpoint,
@@ -52,6 +53,7 @@ export {
52
53
  SubscriptionPreferences,
53
54
  TelegramConnectButton,
54
55
  WorkflowCriticalityEnum,
56
+ useAgentChat,
55
57
  useChannelConnection,
56
58
  useChannelConnections,
57
59
  useChannelEndpoint,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export type * from '@novu/js';\nexport { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum } from '@novu/js';\n\nexport type {\n AllLocalization,\n AllLocalizationKey,\n ChannelConnectButtonIconKey,\n ElementStyles,\n InboxAppearance,\n InboxAppearanceCallback,\n InboxAppearanceCallbackFunction,\n InboxAppearanceCallbackKeys,\n InboxAppearanceKey,\n InboxElements,\n InboxLocalization,\n InboxLocalizationKey,\n InboxTheme,\n NotificationActionClickHandler,\n NotificationClickHandler,\n NotificationRenderer,\n PreferenceGroups,\n PreferencesFilter,\n RouterPush,\n SubscriptionAppearance,\n SubscriptionAppearanceCallback,\n SubscriptionAppearanceCallbackFunction,\n SubscriptionAppearanceCallbackKeys,\n SubscriptionAppearanceKey,\n SubscriptionElements,\n SubscriptionLocalization,\n SubscriptionLocalizationKey,\n SubscriptionTheme,\n Tab,\n Variables,\n} from '@novu/js/ui';\nexport type {\n BellProps,\n InboxContentProps,\n InboxProps,\n MsTeamsConnectButtonProps,\n MsTeamsLinkUserProps,\n NotificationProps,\n NovuProviderProps,\n SlackConnectButtonProps,\n SlackLinkUserProps,\n SubscriptionButtonProps,\n SubscriptionPreferencesProps,\n SubscriptionProps,\n TelegramConnectButtonProps,\n} from './components';\nexport {\n Bell,\n Inbox,\n InboxContent,\n MsTeamsConnectButton,\n MsTeamsLinkUser,\n Notifications,\n NovuProvider,\n Preferences,\n SlackConnectButton,\n SlackLinkUser,\n Subscription,\n SubscriptionButton,\n SubscriptionPreferences,\n TelegramConnectButton,\n} from './components';\nexport type {\n UseChannelConnectionProps,\n UseChannelConnectionResult,\n UseChannelConnectionsProps,\n UseChannelConnectionsResult,\n UseChannelEndpointProps,\n UseChannelEndpointResult,\n UseCountsProps,\n UseCountsResult,\n UseCreateChannelEndpointProps,\n UseCreateChannelEndpointResult,\n UseDeleteChannelEndpointProps,\n UseDeleteChannelEndpointResult,\n UseNotificationsProps,\n UseNotificationsResult,\n UsePreferencesResult,\n UseScheduleProps as UsePreferencesProps,\n UseTelegramSubscriberLinkProps,\n UseTelegramSubscriberLinkResult,\n} from './hooks';\nexport {\n useChannelConnection,\n useChannelConnections,\n useChannelEndpoint,\n useCounts,\n useCreateChannelEndpoint,\n useCreateSubscription,\n useDeleteChannelEndpoint,\n useNotifications,\n useNovu,\n usePreferences,\n useRemoveSubscription,\n useSchedule,\n useSubscription,\n useSubscriptions,\n useTelegramSubscriberLink,\n useUpdateSubscription,\n} from './hooks';\n\nexport type {\n BaseProps,\n BellRenderer,\n BodyRenderer,\n DefaultInboxProps,\n DefaultProps,\n NoRendererProps,\n NotificationRendererProps,\n NotificationsRenderer,\n ReactAllAppearance,\n ReactInboxAppearance,\n ReactInboxTheme,\n ReactSubscriptionAppearance,\n ReactSubscriptionTheme,\n SubjectBodyRendererProps,\n SubjectRenderer,\n WithChildrenProps,\n} from './utils/types';\n"],"mappings":";AACA,SAAS,iBAAiB,mBAAmB,+BAA+B;AAiD5E;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAqBP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export type * from '@novu/js';\nexport { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum } from '@novu/js';\n\nexport type {\n AllLocalization,\n AllLocalizationKey,\n ChannelConnectButtonIconKey,\n ElementStyles,\n InboxAppearance,\n InboxAppearanceCallback,\n InboxAppearanceCallbackFunction,\n InboxAppearanceCallbackKeys,\n InboxAppearanceKey,\n InboxElements,\n InboxLocalization,\n InboxLocalizationKey,\n InboxTheme,\n NotificationActionClickHandler,\n NotificationClickHandler,\n NotificationRenderer,\n PreferenceGroups,\n PreferencesFilter,\n RouterPush,\n SubscriptionAppearance,\n SubscriptionAppearanceCallback,\n SubscriptionAppearanceCallbackFunction,\n SubscriptionAppearanceCallbackKeys,\n SubscriptionAppearanceKey,\n SubscriptionElements,\n SubscriptionLocalization,\n SubscriptionLocalizationKey,\n SubscriptionTheme,\n Tab,\n Variables,\n} from '@novu/js/ui';\nexport type {\n BellProps,\n InboxContentProps,\n InboxProps,\n MsTeamsConnectButtonProps,\n MsTeamsLinkUserProps,\n NotificationProps,\n NovuProviderProps,\n SlackConnectButtonProps,\n SlackLinkUserProps,\n SubscriptionButtonProps,\n SubscriptionPreferencesProps,\n SubscriptionProps,\n TelegramConnectButtonProps,\n} from './components';\nexport {\n Bell,\n Inbox,\n InboxContent,\n MsTeamsConnectButton,\n MsTeamsLinkUser,\n Notifications,\n NovuProvider,\n Preferences,\n SlackConnectButton,\n SlackLinkUser,\n Subscription,\n SubscriptionButton,\n SubscriptionPreferences,\n TelegramConnectButton,\n} from './components';\nexport type {\n UseAgentChatProps,\n UseAgentChatResult,\n UseChannelConnectionProps,\n UseChannelConnectionResult,\n UseChannelConnectionsProps,\n UseChannelConnectionsResult,\n UseChannelEndpointProps,\n UseChannelEndpointResult,\n UseCountsProps,\n UseCountsResult,\n UseCreateChannelEndpointProps,\n UseCreateChannelEndpointResult,\n UseDeleteChannelEndpointProps,\n UseDeleteChannelEndpointResult,\n UseNotificationsProps,\n UseNotificationsResult,\n UsePreferencesResult,\n UseScheduleProps as UsePreferencesProps,\n UseTelegramSubscriberLinkProps,\n UseTelegramSubscriberLinkResult,\n} from './hooks';\nexport {\n useAgentChat,\n useChannelConnection,\n useChannelConnections,\n useChannelEndpoint,\n useCounts,\n useCreateChannelEndpoint,\n useCreateSubscription,\n useDeleteChannelEndpoint,\n useNotifications,\n useNovu,\n usePreferences,\n useRemoveSubscription,\n useSchedule,\n useSubscription,\n useSubscriptions,\n useTelegramSubscriberLink,\n useUpdateSubscription,\n} from './hooks';\n\nexport type {\n BaseProps,\n BellRenderer,\n BodyRenderer,\n DefaultInboxProps,\n DefaultProps,\n NoRendererProps,\n NotificationRendererProps,\n NotificationsRenderer,\n ReactAllAppearance,\n ReactInboxAppearance,\n ReactInboxTheme,\n ReactSubscriptionAppearance,\n ReactSubscriptionTheme,\n SubjectBodyRendererProps,\n SubjectRenderer,\n WithChildrenProps,\n} from './utils/types';\n"],"mappings":";AACA,SAAS,iBAAiB,mBAAmB,+BAA+B;AAiD5E;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAuBP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":[]}
@@ -3,6 +3,7 @@ import { InboxProps } from '../components/Inbox.js';
3
3
  export * from '@novu/js';
4
4
  export { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum } from '@novu/js';
5
5
  import { NovuProviderProps } from '../hooks/NovuProvider.js';
6
+ import { UseAgentChatProps, UseAgentChatResult } from '../hooks/useAgentChat.js';
6
7
  import { UseCountsProps, UseCountsResult } from '../hooks/useCounts.js';
7
8
  import { UseCreateSubscriptionProps, UseCreateSubscriptionResult } from '../hooks/useCreateSubscription.js';
8
9
  import { UseNotificationsProps, UseNotificationsResult } from '../hooks/useNotifications.js';
@@ -40,6 +41,7 @@ declare function MsTeamsConnectButton(): react_jsx_runtime.JSX.Element;
40
41
  declare function MsTeamsLinkUser(): react_jsx_runtime.JSX.Element;
41
42
  declare function TelegramConnectButton(): react_jsx_runtime.JSX.Element;
42
43
  declare function useNovu(): null;
44
+ declare function useAgentChat(_: UseAgentChatProps): UseAgentChatResult;
43
45
  declare function useCounts(_: UseCountsProps): UseCountsResult;
44
46
  declare function useNotifications(_: UseNotificationsProps): UseNotificationsResult;
45
47
  declare function usePreferences(_: UsePreferencesProps): UsePreferencesResult;
@@ -50,4 +52,4 @@ declare function useUpdateSubscription(_?: UseUpdateSubscriptionProps): UseUpdat
50
52
  declare function useRemoveSubscription(_?: UseRemoveSubscriptionProps): UseRemoveSubscriptionResult;
51
53
  declare function useSubscriptions(_: UseSubscriptionsProps): UseSubscriptionsResult;
52
54
 
53
- export { Bell, Inbox, InboxContent, InboxProps, MsTeamsConnectButton, MsTeamsLinkUser, Notifications, NovuProvider, NovuProviderProps, Preferences, SlackConnectButton, SlackLinkUser, Subscription, SubscriptionButton, SubscriptionPreferences, TelegramConnectButton, UseCountsProps, UseCountsResult, UseNotificationsProps, UseNotificationsResult, UseScheduleProps as UsePreferencesProps, UsePreferencesResult, useCounts, useCreateSubscription, useNotifications, useNovu, usePreferences, useRemoveSubscription, useSchedule, useSubscription, useSubscriptions, useUpdateSubscription };
55
+ export { Bell, Inbox, InboxContent, InboxProps, MsTeamsConnectButton, MsTeamsLinkUser, Notifications, NovuProvider, NovuProviderProps, Preferences, SlackConnectButton, SlackLinkUser, Subscription, SubscriptionButton, SubscriptionPreferences, TelegramConnectButton, UseAgentChatProps, UseAgentChatResult, UseCountsProps, UseCountsResult, UseNotificationsProps, UseNotificationsResult, UseScheduleProps as UsePreferencesProps, UsePreferencesResult, useAgentChat, useCounts, useCreateSubscription, useNotifications, useNovu, usePreferences, useRemoveSubscription, useSchedule, useSubscription, useSubscriptions, useUpdateSubscription };
@@ -41,6 +41,22 @@ function TelegramConnectButton() {
41
41
  function useNovu() {
42
42
  return null;
43
43
  }
44
+ function useAgentChat(_) {
45
+ return {
46
+ messages: [],
47
+ pendingActions: [],
48
+ isLoading: false,
49
+ isFetching: false,
50
+ isRunning: false,
51
+ typing: void 0,
52
+ status: "active",
53
+ hasMore: false,
54
+ refetch: () => Promise.resolve(),
55
+ fetchMore: () => Promise.resolve({ data: void 0, error: void 0 }),
56
+ sendMessage: () => Promise.resolve({ data: void 0, error: void 0 }),
57
+ respondToAction: () => Promise.resolve({ data: void 0, error: void 0 })
58
+ };
59
+ }
44
60
  function useCounts(_) {
45
61
  return {
46
62
  isLoading: false,
@@ -128,6 +144,7 @@ export {
128
144
  SubscriptionPreferences,
129
145
  TelegramConnectButton,
130
146
  WorkflowCriticalityEnum,
147
+ useAgentChat,
131
148
  useCounts,
132
149
  useCreateSubscription,
133
150
  useNotifications,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/server/index.tsx"],"sourcesContent":["import type { InboxProps } from '../components/Inbox';\nimport { ShadowRootDetector } from '../components/ShadowRootDetector';\nimport type {\n UseCreateSubscriptionProps,\n UseCreateSubscriptionResult,\n UseNotificationsProps,\n UseNotificationsResult,\n UsePreferencesProps,\n UsePreferencesResult,\n UseRemoveSubscriptionProps,\n UseRemoveSubscriptionResult,\n UseScheduleProps,\n UseScheduleResult,\n UseSubscriptionProps,\n UseSubscriptionResult,\n UseSubscriptionsProps,\n UseSubscriptionsResult,\n UseUpdateSubscriptionProps,\n UseUpdateSubscriptionResult,\n} from '../hooks';\nimport type { NovuProviderProps } from '../hooks/NovuProvider';\nimport type { UseCountsProps, UseCountsResult } from '../hooks/useCounts';\n\n/**\n * Exporting all components from the components folder\n * as empty functions to fix build errors in SSR\n * This will be replaced with actual components\n * when we implement the SSR components in @novu/js/ui\n */\nexport function Inbox(props: InboxProps) {\n return <ShadowRootDetector />;\n}\n\nexport function InboxContent() {}\n\nexport function Notifications() {}\n\nexport function Preferences() {}\n\nexport function Bell() {}\n\nexport function NovuProvider(props: NovuProviderProps) {\n return <>{props.children}</>;\n}\n\nexport function Subscription() {\n return <ShadowRootDetector />;\n}\n\nexport function SubscriptionButton() {}\n\nexport function SubscriptionPreferences() {}\n\nexport function SlackConnectButton() {\n return <ShadowRootDetector />;\n}\n\nexport function SlackLinkUser() {\n return <ShadowRootDetector />;\n}\n\nexport function MsTeamsConnectButton() {\n return <ShadowRootDetector />;\n}\n\nexport function MsTeamsLinkUser() {\n return <ShadowRootDetector />;\n}\n\nexport function TelegramConnectButton() {\n return <ShadowRootDetector />;\n}\n\nexport function useNovu() {\n return null;\n}\n\nexport function useCounts(_: UseCountsProps): UseCountsResult {\n return {\n isLoading: false,\n isFetching: false,\n refetch: () => Promise.resolve(),\n };\n}\n\nexport function useNotifications(_: UseNotificationsProps): UseNotificationsResult {\n return {\n isLoading: false,\n isFetching: false,\n hasMore: false,\n readAll: () => Promise.resolve({ data: undefined, error: undefined }),\n seenAll: () => Promise.resolve({ data: undefined, error: undefined }),\n archiveAll: () => Promise.resolve({ data: undefined, error: undefined }),\n archiveAllRead: () => Promise.resolve({ data: undefined, error: undefined }),\n refetch: () => Promise.resolve(),\n fetchMore: () => Promise.resolve(),\n };\n}\n\nexport function usePreferences(_: UsePreferencesProps): UsePreferencesResult {\n return {\n isLoading: false,\n isFetching: false,\n refetch: () => Promise.resolve(),\n };\n}\n\nexport function useSchedule(_: UseScheduleProps): UseScheduleResult {\n return {\n isLoading: false,\n isFetching: false,\n refetch: () => Promise.resolve(),\n };\n}\n\nexport function useSubscription(_: UseSubscriptionProps): UseSubscriptionResult {\n return {\n isLoading: false,\n isFetching: false,\n refetch: () => Promise.resolve(),\n };\n}\n\nexport function useCreateSubscription(_: UseCreateSubscriptionProps = {}): UseCreateSubscriptionResult {\n return {\n isCreating: false,\n error: undefined,\n create: () => Promise.resolve({ data: undefined, error: undefined }),\n };\n}\n\nexport function useUpdateSubscription(_: UseUpdateSubscriptionProps = {}): UseUpdateSubscriptionResult {\n return {\n isUpdating: false,\n error: undefined,\n update: () => Promise.resolve({ data: undefined, error: undefined }),\n };\n}\n\nexport function useRemoveSubscription(_: UseRemoveSubscriptionProps = {}): UseRemoveSubscriptionResult {\n return {\n isRemoving: false,\n error: undefined,\n remove: () => Promise.resolve({ data: undefined, error: undefined }),\n };\n}\n\nexport function useSubscriptions(_: UseSubscriptionsProps): UseSubscriptionsResult {\n return {\n isLoading: false,\n isFetching: false,\n refetch: () => Promise.resolve(),\n };\n}\n\nexport type * from '@novu/js';\nexport { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum } from '@novu/js';\n\nexport type {\n AllLocalization,\n AllLocalizationKey,\n ElementStyles,\n InboxAppearance,\n InboxAppearanceCallback,\n InboxAppearanceCallbackFunction,\n InboxAppearanceCallbackKeys,\n InboxAppearanceKey,\n InboxElements,\n InboxLocalization,\n InboxLocalizationKey,\n InboxTheme,\n NotificationActionClickHandler,\n NotificationClickHandler,\n NotificationRenderer,\n PreferenceGroups,\n PreferencesFilter,\n RouterPush,\n SubscriptionAppearance,\n SubscriptionAppearanceCallback,\n SubscriptionAppearanceCallbackFunction,\n SubscriptionAppearanceCallbackKeys,\n SubscriptionAppearanceKey,\n SubscriptionElements,\n SubscriptionLocalization,\n SubscriptionLocalizationKey,\n SubscriptionTheme,\n Tab,\n Variables,\n} from '@novu/js/ui';\n\nexport type { BellProps, InboxContentProps, InboxProps, NotificationProps, NovuProviderProps } from '../components';\n\nexport type {\n UseCountsProps,\n UseCountsResult,\n UseNotificationsProps,\n UseNotificationsResult,\n UsePreferencesResult,\n UseScheduleProps as UsePreferencesProps,\n} from '../hooks';\n\nexport type {\n BaseProps,\n BellRenderer,\n BodyRenderer,\n DefaultInboxProps,\n DefaultProps,\n NoRendererProps,\n NotificationRendererProps,\n NotificationsRenderer,\n SubjectBodyRendererProps,\n SubjectRenderer,\n WithChildrenProps,\n} from '../utils/types';\n"],"mappings":";AACA,SAAS,0BAA0B;AA2JnC,SAAS,iBAAiB,mBAAmB,+BAA+B;AA9HnE,SAYA,UAZA;AADF,SAAS,MAAM,OAAmB;AACvC,SAAO,oBAAC,sBAAmB;AAC7B;AAEO,SAAS,eAAe;AAAC;AAEzB,SAAS,gBAAgB;AAAC;AAE1B,SAAS,cAAc;AAAC;AAExB,SAAS,OAAO;AAAC;AAEjB,SAAS,aAAa,OAA0B;AACrD,SAAO,gCAAG,gBAAM,UAAS;AAC3B;AAEO,SAAS,eAAe;AAC7B,SAAO,oBAAC,sBAAmB;AAC7B;AAEO,SAAS,qBAAqB;AAAC;AAE/B,SAAS,0BAA0B;AAAC;AAEpC,SAAS,qBAAqB;AACnC,SAAO,oBAAC,sBAAmB;AAC7B;AAEO,SAAS,gBAAgB;AAC9B,SAAO,oBAAC,sBAAmB;AAC7B;AAEO,SAAS,uBAAuB;AACrC,SAAO,oBAAC,sBAAmB;AAC7B;AAEO,SAAS,kBAAkB;AAChC,SAAO,oBAAC,sBAAmB;AAC7B;AAEO,SAAS,wBAAwB;AACtC,SAAO,oBAAC,sB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SAAS,sBAAsB,IAAgC,CAAC,GAAgC;AACrG,SAAO;AAAA,IACL,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,QAAQ,MAAM,QAAQ,QAAQ,EAAE,MAAM,QAAW,OAAO,OAAU,CAAC;AAAA,EACrE;AACF;AAEO,SAAS,sBAAsB,IAAgC,CAAC,GAAgC;AACrG,SAAO;AAAA,IACL,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,QAAQ,MAAM,QAAQ,QAAQ,EAAE,MAAM,QAAW,OAAO,OAAU,CAAC;AAAA,EACrE;AACF;AAEO,SAAS,iBAAiB,GAAkD;AACjF,SAAO;AAAA,IACL,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,SAAS,MAAM,QAAQ,QAAQ;AAAA,EACjC;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/server/index.tsx"],"sourcesContent":["import type { InboxProps } from '../components/Inbox';\nimport { ShadowRootDetector } from '../components/ShadowRootDetector';\nimport type {\n UseAgentChatProps,\n UseAgentChatResult,\n UseCreateSubscriptionProps,\n UseCreateSubscriptionResult,\n UseNotificationsProps,\n UseNotificationsResult,\n UsePreferencesProps,\n UsePreferencesResult,\n UseRemoveSubscriptionProps,\n UseRemoveSubscriptionResult,\n UseScheduleProps,\n UseScheduleResult,\n UseSubscriptionProps,\n UseSubscriptionResult,\n UseSubscriptionsProps,\n UseSubscriptionsResult,\n UseUpdateSubscriptionProps,\n UseUpdateSubscriptionResult,\n} from '../hooks';\nimport type { NovuProviderProps } from '../hooks/NovuProvider';\nimport type { UseCountsProps, UseCountsResult } from '../hooks/useCounts';\n\n/**\n * Exporting all components from the components folder\n * as empty functions to fix build errors in SSR\n * This will be replaced with actual components\n * when we implement the SSR components in @novu/js/ui\n */\nexport function Inbox(props: InboxProps) {\n return <ShadowRootDetector />;\n}\n\nexport function InboxContent() {}\n\nexport function Notifications() {}\n\nexport function Preferences() {}\n\nexport function Bell() {}\n\nexport function NovuProvider(props: NovuProviderProps) {\n return <>{props.children}</>;\n}\n\nexport function Subscription() {\n return <ShadowRootDetector />;\n}\n\nexport function SubscriptionButton() {}\n\nexport function SubscriptionPreferences() {}\n\nexport function SlackConnectButton() {\n return <ShadowRootDetector />;\n}\n\nexport function SlackLinkUser() {\n return <ShadowRootDetector />;\n}\n\nexport function MsTeamsConnectButton() {\n return <ShadowRootDetector />;\n}\n\nexport function MsTeamsLinkUser() {\n return <ShadowRootDetector />;\n}\n\nexport function TelegramConnectButton() {\n return <ShadowRootDetector />;\n}\n\nexport function useNovu() {\n return null;\n}\n\nexport function useAgentChat(_: UseAgentChatProps): UseAgentChatResult {\n return {\n messages: [],\n pendingActions: [],\n isLoading: false,\n isFetching: false,\n isRunning: false,\n typing: undefined,\n status: 'active',\n hasMore: false,\n refetch: () => Promise.resolve(),\n fetchMore: () => Promise.resolve({ data: undefined, error: undefined }),\n sendMessage: () => Promise.resolve({ data: undefined, error: undefined }),\n respondToAction: () => Promise.resolve({ data: undefined, error: undefined }),\n };\n}\n\nexport function useCounts(_: UseCountsProps): UseCountsResult {\n return {\n isLoading: false,\n isFetching: false,\n refetch: () => Promise.resolve(),\n };\n}\n\nexport function useNotifications(_: UseNotificationsProps): UseNotificationsResult {\n return {\n isLoading: false,\n isFetching: false,\n hasMore: false,\n readAll: () => Promise.resolve({ data: undefined, error: undefined }),\n seenAll: () => Promise.resolve({ data: undefined, error: undefined }),\n archiveAll: () => Promise.resolve({ data: undefined, error: undefined }),\n archiveAllRead: () => Promise.resolve({ data: undefined, error: undefined }),\n refetch: () => Promise.resolve(),\n fetchMore: () => Promise.resolve(),\n };\n}\n\nexport function usePreferences(_: UsePreferencesProps): UsePreferencesResult {\n return {\n isLoading: false,\n isFetching: false,\n refetch: () => Promise.resolve(),\n };\n}\n\nexport function useSchedule(_: UseScheduleProps): UseScheduleResult {\n return {\n isLoading: false,\n isFetching: false,\n refetch: () => Promise.resolve(),\n };\n}\n\nexport function useSubscription(_: UseSubscriptionProps): UseSubscriptionResult {\n return {\n isLoading: false,\n isFetching: false,\n refetch: () => Promise.resolve(),\n };\n}\n\nexport function useCreateSubscription(_: UseCreateSubscriptionProps = {}): UseCreateSubscriptionResult {\n return {\n isCreating: false,\n error: undefined,\n create: () => Promise.resolve({ data: undefined, error: undefined }),\n };\n}\n\nexport function useUpdateSubscription(_: UseUpdateSubscriptionProps = {}): UseUpdateSubscriptionResult {\n return {\n isUpdating: false,\n error: undefined,\n update: () => Promise.resolve({ data: undefined, error: undefined }),\n };\n}\n\nexport function useRemoveSubscription(_: UseRemoveSubscriptionProps = {}): UseRemoveSubscriptionResult {\n return {\n isRemoving: false,\n error: undefined,\n remove: () => Promise.resolve({ data: undefined, error: undefined }),\n };\n}\n\nexport function useSubscriptions(_: UseSubscriptionsProps): UseSubscriptionsResult {\n return {\n isLoading: false,\n isFetching: false,\n refetch: () => Promise.resolve(),\n };\n}\n\nexport type * from '@novu/js';\nexport { PreferenceLevel, SeverityLevelEnum, WorkflowCriticalityEnum } from '@novu/js';\n\nexport type {\n AllLocalization,\n AllLocalizationKey,\n ElementStyles,\n InboxAppearance,\n InboxAppearanceCallback,\n InboxAppearanceCallbackFunction,\n InboxAppearanceCallbackKeys,\n InboxAppearanceKey,\n InboxElements,\n InboxLocalization,\n InboxLocalizationKey,\n InboxTheme,\n NotificationActionClickHandler,\n NotificationClickHandler,\n NotificationRenderer,\n PreferenceGroups,\n PreferencesFilter,\n RouterPush,\n SubscriptionAppearance,\n SubscriptionAppearanceCallback,\n SubscriptionAppearanceCallbackFunction,\n SubscriptionAppearanceCallbackKeys,\n SubscriptionAppearanceKey,\n SubscriptionElements,\n SubscriptionLocalization,\n SubscriptionLocalizationKey,\n SubscriptionTheme,\n Tab,\n Variables,\n} from '@novu/js/ui';\n\nexport type { BellProps, InboxContentProps, InboxProps, NotificationProps, NovuProviderProps } from '../components';\n\nexport type {\n UseAgentChatProps,\n UseAgentChatResult,\n UseCountsProps,\n UseCountsResult,\n UseNotificationsProps,\n UseNotificationsResult,\n UsePreferencesResult,\n UseScheduleProps as UsePreferencesProps,\n} from '../hooks';\n\nexport type {\n BaseProps,\n BellRenderer,\n BodyRenderer,\n DefaultInboxProps,\n DefaultProps,\n NoRendererProps,\n NotificationRendererProps,\n NotificationsRenderer,\n SubjectBodyRendererProps,\n SubjectRenderer,\n WithChildrenProps,\n} from '../utils/types';\n"],"mappings":";AACA,SAAS,0BAA0B;AA8KnC,SAAS,iBAAiB,mBAAmB,+BAA+B;AA/InE,SAYA,UAZA;AADF,SAAS,MAAM,OAAmB;AACvC,SAAO,oBAAC,sBAAmB;AAC7B;AAEO,SAAS,eAAe;AAAC;AAEzB,SAAS,gBAAgB;AAAC;AAE1B,SAAS,cAAc;AAAC;AAExB,SAAS,OAAO;AAAC;AAEjB,SAAS,aAAa,OAA0B;AACrD,SAAO,gCAAG,gBAAM,UAAS;AAC3B;AAEO,SAAS,eAAe;AAC7B,SAAO,oBAAC,sBAAmB;AAC7B;AAEO,SAAS,qBAAqB;AAAC;AAE/B,SAAS,0BAA0B;AAAC;AAEpC,SAAS,qBAAqB;AACnC,SAAO,oBAAC,sBAAmB;AAC7B;AAEO,SAAS,gBAAgB;AAC9B,SAAO,oBAAC,sBAAmB;AAC7B;AAEO,SAAS,uBAAuB;AACrC,SAAO,oBAAC,sBAAmB;AAC7B;AAEO,SAAS,kBAAkB;AAChC,SAAO,oBAAC,sBAAmB;AAC7B;AAEO,SAAS,wBAAwB;AACtC,SAAO,oBAAC,sBAAmB;AAC7B;AAEO,SAAS,UAAU;AACxB,SAAO;AACT;AAEO,SAAS,aAAa,GAA0C;AACrE,SAAO;AAAA,IACL,UAAU,CAAC;AAAA,IACX,gBAAgB,CAAC;AAAA,IACjB,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,SAAS,MAAM,QAAQ,QAAQ;AAAA,IAC/B,WAAW,MAAM,QAAQ,QAAQ,EAAE,MAAM,QAAW,OAA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AO;AAAA,IACL,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,QAAQ,MAAM,QAAQ,QAAQ,EAAE,MAAM,QAAW,OAAO,OAAU,CAAC;AAAA,EACrE;AACF;AAEO,SAAS,sBAAsB,IAAgC,CAAC,GAAgC;AACrG,SAAO;AAAA,IACL,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,QAAQ,MAAM,QAAQ,QAAQ,EAAE,MAAM,QAAW,OAAO,OAAU,CAAC;AAAA,EACrE;AACF;AAEO,SAAS,sBAAsB,IAAgC,CAAC,GAAgC;AACrG,SAAO;AAAA,IACL,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,QAAQ,MAAM,QAAQ,QAAQ,EAAE,MAAM,QAAW,OAAO,OAAU,CAAC;AAAA,EACrE;AACF;AAEO,SAAS,iBAAiB,GAAkD;AACjF,SAAO;AAAA,IACL,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,SAAS,MAAM,QAAQ,QAAQ;AAAA,EACjC;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@novu/react",
3
- "version": "3.18.2",
3
+ "version": "3.20.0-rc.d57e78e026",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/novuhq/novu",
@@ -121,7 +121,7 @@
121
121
  }
122
122
  },
123
123
  "dependencies": {
124
- "@novu/js": "3.18.2"
124
+ "@novu/js": "3.20.0-rc.d57e78e026"
125
125
  },
126
126
  "nx": {
127
127
  "tags": [