@novu/react 3.17.0 → 3.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/index.cjs +3 -1
- package/dist/cjs/components/index.cjs.map +1 -1
- package/dist/cjs/components/index.d.cts +2 -0
- package/dist/cjs/components/telegram-connect-button/DefaultTelegramConnectButton.cjs +77 -0
- package/dist/cjs/components/telegram-connect-button/DefaultTelegramConnectButton.cjs.map +1 -0
- package/dist/cjs/components/telegram-connect-button/DefaultTelegramConnectButton.d.cts +7 -0
- package/dist/cjs/components/telegram-connect-button/TelegramConnectButton.cjs +63 -0
- package/dist/cjs/components/telegram-connect-button/TelegramConnectButton.cjs.map +1 -0
- package/dist/cjs/components/telegram-connect-button/TelegramConnectButton.d.cts +12 -0
- package/dist/cjs/hooks/index.cjs +2 -0
- package/dist/cjs/hooks/index.cjs.map +1 -1
- package/dist/cjs/hooks/index.d.cts +1 -0
- package/dist/cjs/hooks/useCounts.cjs +64 -45
- package/dist/cjs/hooks/useCounts.cjs.map +1 -1
- package/dist/cjs/hooks/usePreferences.cjs +2 -1
- package/dist/cjs/hooks/usePreferences.cjs.map +1 -1
- package/dist/cjs/hooks/useSchedule.cjs +2 -1
- package/dist/cjs/hooks/useSchedule.cjs.map +1 -1
- package/dist/cjs/hooks/useTelegramSubscriberLink.cjs +82 -0
- package/dist/cjs/hooks/useTelegramSubscriberLink.cjs.map +1 -0
- package/dist/cjs/hooks/useTelegramSubscriberLink.d.cts +51 -0
- package/dist/cjs/index.cjs +4 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +3 -0
- package/dist/cjs/server/index.cjs +25 -0
- package/dist/cjs/server/index.cjs.map +1 -1
- package/dist/cjs/server/index.d.cts +6 -1
- package/dist/esm/components/index.d.ts +2 -0
- package/dist/esm/components/index.js +1 -0
- package/dist/esm/components/index.js.map +1 -1
- package/dist/esm/components/telegram-connect-button/DefaultTelegramConnectButton.d.ts +7 -0
- package/dist/esm/components/telegram-connect-button/DefaultTelegramConnectButton.js +52 -0
- package/dist/esm/components/telegram-connect-button/DefaultTelegramConnectButton.js.map +1 -0
- package/dist/esm/components/telegram-connect-button/TelegramConnectButton.d.ts +12 -0
- package/dist/esm/components/telegram-connect-button/TelegramConnectButton.js +28 -0
- package/dist/esm/components/telegram-connect-button/TelegramConnectButton.js.map +1 -0
- package/dist/esm/hooks/index.d.ts +1 -0
- package/dist/esm/hooks/index.js +1 -0
- package/dist/esm/hooks/index.js.map +1 -1
- package/dist/esm/hooks/useCounts.js +65 -47
- package/dist/esm/hooks/useCounts.js.map +1 -1
- package/dist/esm/hooks/usePreferences.js +2 -1
- package/dist/esm/hooks/usePreferences.js.map +1 -1
- package/dist/esm/hooks/useSchedule.js +2 -1
- package/dist/esm/hooks/useSchedule.js.map +1 -1
- package/dist/esm/hooks/useTelegramSubscriberLink.d.ts +51 -0
- package/dist/esm/hooks/useTelegramSubscriberLink.js +57 -0
- package/dist/esm/hooks/useTelegramSubscriberLink.js.map +1 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +5 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/server/index.d.ts +6 -1
- package/dist/esm/server/index.js +20 -0
- package/dist/esm/server/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -30,6 +30,7 @@ __reExport(components_exports, require("./slack-link-user/SlackLinkUser.cjs"), m
|
|
|
30
30
|
__reExport(components_exports, require("./subscription/Subscription.cjs"), module.exports);
|
|
31
31
|
__reExport(components_exports, require("./subscription/SubscriptionButton.cjs"), module.exports);
|
|
32
32
|
__reExport(components_exports, require("./subscription/SubscriptionPreferences.cjs"), module.exports);
|
|
33
|
+
__reExport(components_exports, require("./telegram-connect-button/TelegramConnectButton.cjs"), module.exports);
|
|
33
34
|
// Annotate the CommonJS export names for ESM import in node:
|
|
34
35
|
0 && (module.exports = {
|
|
35
36
|
...require("../hooks/NovuProvider.cjs"),
|
|
@@ -44,6 +45,7 @@ __reExport(components_exports, require("./subscription/SubscriptionPreferences.c
|
|
|
44
45
|
...require("./slack-link-user/SlackLinkUser.cjs"),
|
|
45
46
|
...require("./subscription/Subscription.cjs"),
|
|
46
47
|
...require("./subscription/SubscriptionButton.cjs"),
|
|
47
|
-
...require("./subscription/SubscriptionPreferences.cjs")
|
|
48
|
+
...require("./subscription/SubscriptionPreferences.cjs"),
|
|
49
|
+
...require("./telegram-connect-button/TelegramConnectButton.cjs")
|
|
48
50
|
});
|
|
49
51
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/index.ts"],"sourcesContent":["export * from '../hooks/NovuProvider';\nexport * from './Bell';\nexport * from './Inbox';\nexport * from './InboxContent';\nexport * from './msteams-connect-button/MsTeamsConnectButton';\nexport * from './msteams-link-user/MsTeamsLinkUser';\nexport * from './Notifications';\nexport * from './Preferences';\nexport * from './slack-connect-button/SlackConnectButton';\nexport * from './slack-link-user/SlackLinkUser';\nexport * from './subscription/Subscription';\nexport * from './subscription/SubscriptionButton';\nexport * from './subscription/SubscriptionPreferences';\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,+BAAc,sCAAd;AACA,+BAAc,uBADd;AAEA,+BAAc,wBAFd;AAGA,+BAAc,+BAHd;AAIA,+BAAc,8DAJd;AAKA,+BAAc,oDALd;AAMA,+BAAc,gCANd;AAOA,+BAAc,8BAPd;AAQA,+BAAc,0DARd;AASA,+BAAc,gDATd;AAUA,+BAAc,4CAVd;AAWA,+BAAc,kDAXd;AAYA,+BAAc,uDAZd;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/index.ts"],"sourcesContent":["export * from '../hooks/NovuProvider';\nexport * from './Bell';\nexport * from './Inbox';\nexport * from './InboxContent';\nexport * from './msteams-connect-button/MsTeamsConnectButton';\nexport * from './msteams-link-user/MsTeamsLinkUser';\nexport * from './Notifications';\nexport * from './Preferences';\nexport * from './slack-connect-button/SlackConnectButton';\nexport * from './slack-link-user/SlackLinkUser';\nexport * from './subscription/Subscription';\nexport * from './subscription/SubscriptionButton';\nexport * from './subscription/SubscriptionPreferences';\nexport * from './telegram-connect-button/TelegramConnectButton';\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,+BAAc,sCAAd;AACA,+BAAc,uBADd;AAEA,+BAAc,wBAFd;AAGA,+BAAc,+BAHd;AAIA,+BAAc,8DAJd;AAKA,+BAAc,oDALd;AAMA,+BAAc,gCANd;AAOA,+BAAc,8BAPd;AAQA,+BAAc,0DARd;AASA,+BAAc,gDATd;AAUA,+BAAc,4CAVd;AAWA,+BAAc,kDAXd;AAYA,+BAAc,uDAZd;AAaA,+BAAc,gEAbd;","names":[]}
|
|
@@ -11,6 +11,7 @@ export { SlackLinkUser, SlackLinkUserProps } from './slack-link-user/SlackLinkUs
|
|
|
11
11
|
export { Subscription, SubscriptionProps } from './subscription/Subscription.cjs';
|
|
12
12
|
export { SubscriptionButton, SubscriptionButtonProps } from './subscription/SubscriptionButton.cjs';
|
|
13
13
|
export { SubscriptionPreferences, SubscriptionPreferencesProps } from './subscription/SubscriptionPreferences.cjs';
|
|
14
|
+
export { TelegramConnectButton, TelegramConnectButtonProps } from './telegram-connect-button/TelegramConnectButton.cjs';
|
|
14
15
|
import 'react/jsx-runtime';
|
|
15
16
|
import '@novu/js';
|
|
16
17
|
import 'react';
|
|
@@ -22,3 +23,4 @@ import './msteams-link-user/DefaultMsTeamsLinkUser.cjs';
|
|
|
22
23
|
import './slack-connect-button/DefaultSlackConnectButton.cjs';
|
|
23
24
|
import './slack-link-user/DefaultSlackLinkUser.cjs';
|
|
24
25
|
import './subscription/DefaultSubscription.cjs';
|
|
26
|
+
import './telegram-connect-button/DefaultTelegramConnectButton.cjs';
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/components/telegram-connect-button/DefaultTelegramConnectButton.tsx
|
|
21
|
+
var DefaultTelegramConnectButton_exports = {};
|
|
22
|
+
__export(DefaultTelegramConnectButton_exports, {
|
|
23
|
+
DefaultTelegramConnectButton: () => DefaultTelegramConnectButton
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(DefaultTelegramConnectButton_exports);
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var import_NovuUIContext = require("../../context/NovuUIContext.cjs");
|
|
28
|
+
var import_Mounter = require("../Mounter.cjs");
|
|
29
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
30
|
+
var DefaultTelegramConnectButton = (props) => {
|
|
31
|
+
const {
|
|
32
|
+
integrationIdentifier,
|
|
33
|
+
subscriberId,
|
|
34
|
+
onConnectSuccess,
|
|
35
|
+
onConnectError,
|
|
36
|
+
onDisconnectSuccess,
|
|
37
|
+
onDisconnectError,
|
|
38
|
+
connectLabel,
|
|
39
|
+
connectedLabel
|
|
40
|
+
} = props;
|
|
41
|
+
const { novuUI } = (0, import_NovuUIContext.useNovuUI)();
|
|
42
|
+
const mount = (0, import_react.useCallback)(
|
|
43
|
+
(element) => {
|
|
44
|
+
return novuUI.mountComponent({
|
|
45
|
+
name: "TelegramConnectButton",
|
|
46
|
+
props: {
|
|
47
|
+
integrationIdentifier,
|
|
48
|
+
subscriberId,
|
|
49
|
+
onConnectSuccess,
|
|
50
|
+
onConnectError,
|
|
51
|
+
onDisconnectSuccess,
|
|
52
|
+
onDisconnectError,
|
|
53
|
+
connectLabel,
|
|
54
|
+
connectedLabel
|
|
55
|
+
},
|
|
56
|
+
element
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
[
|
|
60
|
+
novuUI,
|
|
61
|
+
integrationIdentifier,
|
|
62
|
+
subscriberId,
|
|
63
|
+
onConnectSuccess,
|
|
64
|
+
onConnectError,
|
|
65
|
+
onDisconnectSuccess,
|
|
66
|
+
onDisconnectError,
|
|
67
|
+
connectLabel,
|
|
68
|
+
connectedLabel
|
|
69
|
+
]
|
|
70
|
+
);
|
|
71
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Mounter.Mounter, { mount });
|
|
72
|
+
};
|
|
73
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
74
|
+
0 && (module.exports = {
|
|
75
|
+
DefaultTelegramConnectButton
|
|
76
|
+
});
|
|
77
|
+
//# sourceMappingURL=DefaultTelegramConnectButton.cjs.map
|
|
@@ -0,0 +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 | '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 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 onConnectSuccess,\n onConnectError,\n onDisconnectSuccess,\n onDisconnectError,\n connectLabel,\n connectedLabel,\n },\n element,\n });\n },\n [\n novuUI,\n integrationIdentifier,\n subscriberId,\n onConnectSuccess,\n onConnectError,\n onDisconnectSuccess,\n onDisconnectError,\n connectLabel,\n connectedLabel,\n ]\n );\n\n return <Mounter mount={mount} />;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA4B;AAC5B,2BAA0B;AAC1B,qBAAwB;AAyDf;AA3CF,IAAM,+BAA+B,CAAC,UAA6C;AACxF,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AACJ,QAAM,EAAE,OAAO,QAAI,gCAAU;AAE7B,QAAM,YAAQ;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,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,IACF;AAAA,EACF;AAEA,SAAO,4CAAC,0BAAQ,OAAc;AAChC;","names":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { TelegramConnectButtonProps } from '@novu/js/ui';
|
|
3
|
+
|
|
4
|
+
type DefaultTelegramConnectButtonProps = Pick<TelegramConnectButtonProps, 'integrationIdentifier' | 'subscriberId' | 'onConnectSuccess' | 'onConnectError' | 'onDisconnectSuccess' | 'onDisconnectError' | 'connectLabel' | 'connectedLabel'>;
|
|
5
|
+
declare const DefaultTelegramConnectButton: (props: DefaultTelegramConnectButtonProps) => react_jsx_runtime.JSX.Element;
|
|
6
|
+
|
|
7
|
+
export { DefaultTelegramConnectButton, type DefaultTelegramConnectButtonProps };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
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;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/components/telegram-connect-button/TelegramConnectButton.tsx
|
|
31
|
+
var TelegramConnectButton_exports = {};
|
|
32
|
+
__export(TelegramConnectButton_exports, {
|
|
33
|
+
TelegramConnectButton: () => TelegramConnectButton
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(TelegramConnectButton_exports);
|
|
36
|
+
var import_react = __toESM(require("react"), 1);
|
|
37
|
+
var import_NovuProvider = require("../../hooks/NovuProvider.cjs");
|
|
38
|
+
var import_NovuUI = require("../NovuUI.cjs");
|
|
39
|
+
var import_Renderer = require("../Renderer.cjs");
|
|
40
|
+
var import_DefaultTelegramConnectButton = require("./DefaultTelegramConnectButton.cjs");
|
|
41
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
42
|
+
var TelegramConnectButtonInternal = (0, import_Renderer.withRenderer)((props) => {
|
|
43
|
+
const { container, appearance, ...defaultProps } = props;
|
|
44
|
+
const novu = (0, import_NovuProvider.useNovu)();
|
|
45
|
+
const options = (0, import_react.useMemo)(() => {
|
|
46
|
+
return {
|
|
47
|
+
container,
|
|
48
|
+
appearance,
|
|
49
|
+
options: novu.options
|
|
50
|
+
};
|
|
51
|
+
}, [container, appearance, novu.options]);
|
|
52
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_NovuUI.NovuUI, { options, novu, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_DefaultTelegramConnectButton.DefaultTelegramConnectButton, { ...defaultProps }) });
|
|
53
|
+
});
|
|
54
|
+
TelegramConnectButtonInternal.displayName = "TelegramConnectButtonInternal";
|
|
55
|
+
var TelegramConnectButton = import_react.default.memo((props) => {
|
|
56
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TelegramConnectButtonInternal, { ...props });
|
|
57
|
+
});
|
|
58
|
+
TelegramConnectButton.displayName = "TelegramConnectButton";
|
|
59
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
60
|
+
0 && (module.exports = {
|
|
61
|
+
TelegramConnectButton
|
|
62
|
+
});
|
|
63
|
+
//# sourceMappingURL=TelegramConnectButton.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/telegram-connect-button/TelegramConnectButton.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\nimport { useNovu } from '../../hooks/NovuProvider';\nimport { NovuUI, NovuUIOptions } from '../NovuUI';\nimport { withRenderer } from '../Renderer';\nimport { DefaultTelegramConnectButton, DefaultTelegramConnectButtonProps } from './DefaultTelegramConnectButton';\n\nexport type TelegramConnectButtonProps = DefaultTelegramConnectButtonProps &\n Pick<NovuUIOptions, 'container' | 'appearance'>;\n\nconst TelegramConnectButtonInternal = withRenderer<TelegramConnectButtonProps>((props) => {\n const { container, appearance, ...defaultProps } = props;\n const novu = useNovu();\n\n const options: NovuUIOptions = useMemo(() => {\n return {\n container,\n appearance,\n options: novu.options,\n };\n }, [container, appearance, novu.options]);\n\n return (\n <NovuUI options={options} novu={novu}>\n <DefaultTelegramConnectButton {...defaultProps} />\n </NovuUI>\n );\n});\n\nTelegramConnectButtonInternal.displayName = 'TelegramConnectButtonInternal';\n\nexport const TelegramConnectButton = React.memo((props: TelegramConnectButtonProps) => {\n return <TelegramConnectButtonInternal {...props} />;\n});\n\nTelegramConnectButton.displayName = 'TelegramConnectButton';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA+B;AAC/B,0BAAwB;AACxB,oBAAsC;AACtC,sBAA6B;AAC7B,0CAAgF;AAmB1E;AAdN,IAAM,oCAAgC,8BAAyC,CAAC,UAAU;AACxF,QAAM,EAAE,WAAW,YAAY,GAAG,aAAa,IAAI;AACnD,QAAM,WAAO,6BAAQ;AAErB,QAAM,cAAyB,sBAAQ,MAAM;AAC3C,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA,SAAS,KAAK;AAAA,IAChB;AAAA,EACF,GAAG,CAAC,WAAW,YAAY,KAAK,OAAO,CAAC;AAExC,SACE,4CAAC,wBAAO,SAAkB,MACxB,sDAAC,oEAA8B,GAAG,cAAc,GAClD;AAEJ,CAAC;AAED,8BAA8B,cAAc;AAErC,IAAM,wBAAwB,aAAAA,QAAM,KAAK,CAAC,UAAsC;AACrF,SAAO,4CAAC,iCAA+B,GAAG,OAAO;AACnD,CAAC;AAED,sBAAsB,cAAc;","names":["React"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import { NovuUIOptions } from '../NovuUI.cjs';
|
|
4
|
+
import { DefaultTelegramConnectButtonProps } from './DefaultTelegramConnectButton.cjs';
|
|
5
|
+
import '@novu/js';
|
|
6
|
+
import '@novu/js/ui';
|
|
7
|
+
import '../../utils/types.cjs';
|
|
8
|
+
|
|
9
|
+
type TelegramConnectButtonProps = DefaultTelegramConnectButtonProps & Pick<NovuUIOptions, 'container' | 'appearance'>;
|
|
10
|
+
declare const TelegramConnectButton: React__default.MemoExoticComponent<(props: TelegramConnectButtonProps) => react_jsx_runtime.JSX.Element>;
|
|
11
|
+
|
|
12
|
+
export { TelegramConnectButton, type TelegramConnectButtonProps };
|
package/dist/cjs/hooks/index.cjs
CHANGED
|
@@ -43,6 +43,7 @@ __reExport(hooks_exports, require("./useRemoveSubscription.cjs"), module.exports
|
|
|
43
43
|
__reExport(hooks_exports, require("./useSchedule.cjs"), module.exports);
|
|
44
44
|
__reExport(hooks_exports, require("./useSubscription.cjs"), module.exports);
|
|
45
45
|
__reExport(hooks_exports, require("./useSubscriptions.cjs"), module.exports);
|
|
46
|
+
__reExport(hooks_exports, require("./useTelegramSubscriberLink.cjs"), module.exports);
|
|
46
47
|
__reExport(hooks_exports, require("./useUpdateSubscription.cjs"), module.exports);
|
|
47
48
|
// Annotate the CommonJS export names for ESM import in node:
|
|
48
49
|
0 && (module.exports = {
|
|
@@ -64,6 +65,7 @@ __reExport(hooks_exports, require("./useUpdateSubscription.cjs"), module.exports
|
|
|
64
65
|
...require("./useSchedule.cjs"),
|
|
65
66
|
...require("./useSubscription.cjs"),
|
|
66
67
|
...require("./useSubscriptions.cjs"),
|
|
68
|
+
...require("./useTelegramSubscriberLink.cjs"),
|
|
67
69
|
...require("./useUpdateSubscription.cjs")
|
|
68
70
|
});
|
|
69
71
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -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 './useCounts';\nexport * from './useCreateChannelEndpoint';\nexport * from './useCreateSubscription';\nexport * from './useDeleteChannelEndpoint';\nexport * from './useNotifications';\nexport * from './usePreferences';\nexport * from './useRemoveSubscription';\nexport * from './useSchedule';\nexport * from './useSubscription';\nexport * from './useSubscriptions';\nexport * from './useUpdateSubscription';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,gBAA4E;AAC5E,0BAAsC;AACtC,0BAAc,uCAHd;AAIA,0BAAc,wCAJd;AAKA,0BAAc,qCALd;AAMA,0BAAc,4BANd;AAOA,0BAAc,2CAPd;AAQA,0BAAc,wCARd;AASA,0BAAc,2CATd;AAUA,0BAAc,mCAVd;AAWA,0BAAc,iCAXd;AAYA,0BAAc,wCAZd;AAaA,0BAAc,8BAbd;AAcA,0BAAc,kCAdd;AAeA,0BAAc,mCAfd;AAgBA,0BAAc,
|
|
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 './useCounts';\nexport * from './useCreateChannelEndpoint';\nexport * from './useCreateSubscription';\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":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,gBAA4E;AAC5E,0BAAsC;AACtC,0BAAc,uCAHd;AAIA,0BAAc,wCAJd;AAKA,0BAAc,qCALd;AAMA,0BAAc,4BANd;AAOA,0BAAc,2CAPd;AAQA,0BAAc,wCARd;AASA,0BAAc,2CATd;AAUA,0BAAc,mCAVd;AAWA,0BAAc,iCAXd;AAYA,0BAAc,wCAZd;AAaA,0BAAc,8BAbd;AAcA,0BAAc,kCAdd;AAeA,0BAAc,mCAfd;AAgBA,0BAAc,4CAhBd;AAiBA,0BAAc,wCAjBd;","names":[]}
|
|
@@ -14,6 +14,7 @@ export { UseRemoveSubscriptionProps, UseRemoveSubscriptionResult, useRemoveSubsc
|
|
|
14
14
|
export { UseScheduleProps, UseScheduleResult, useSchedule } from './useSchedule.cjs';
|
|
15
15
|
export { UseSubscriptionProps, UseSubscriptionResult, useSubscription } from './useSubscription.cjs';
|
|
16
16
|
export { UseSubscriptionsProps, UseSubscriptionsResult, useSubscriptions } from './useSubscriptions.cjs';
|
|
17
|
+
export { UseTelegramSubscriberLinkProps, UseTelegramSubscriberLinkResult, useTelegramSubscriberLink } from './useTelegramSubscriberLink.cjs';
|
|
17
18
|
export { UseUpdateSubscriptionProps, UseUpdateSubscriptionResult, useUpdateSubscription } from './useUpdateSubscription.cjs';
|
|
18
19
|
import 'react/jsx-runtime';
|
|
19
20
|
import 'react';
|
|
@@ -30,57 +30,65 @@ var import_useWebsocketEvent = require("./internal/useWebsocketEvent.cjs");
|
|
|
30
30
|
var import_NovuProvider = require("./NovuProvider.cjs");
|
|
31
31
|
var useCounts = (props) => {
|
|
32
32
|
const { filters, realtime: propsRealtime, onSuccess, onError } = props;
|
|
33
|
-
const
|
|
33
|
+
const novu = (0, import_NovuProvider.useNovu)();
|
|
34
|
+
const { notifications } = novu;
|
|
34
35
|
const providerRealtime = (0, import_NovuProvider.useRealtime)();
|
|
35
36
|
const realtime = propsRealtime ?? providerRealtime;
|
|
36
37
|
const filtersRef = (0, import_useDataRef.useDataRef)(filters);
|
|
38
|
+
const onSuccessRef = (0, import_useDataRef.useDataRef)(onSuccess);
|
|
39
|
+
const onErrorRef = (0, import_useDataRef.useDataRef)(onError);
|
|
40
|
+
const syncGenerationRef = (0, import_react.useRef)(0);
|
|
37
41
|
const [error, setError] = (0, import_react.useState)();
|
|
38
42
|
const [counts, setCounts] = (0, import_react.useState)();
|
|
39
43
|
const [isLoading, setIsLoading] = (0, import_react.useState)(true);
|
|
40
44
|
const [isFetching, setIsFetching] = (0, import_react.useState)(false);
|
|
41
|
-
const sync =
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
const sync = (0, import_react.useCallback)(
|
|
46
|
+
async (notification, overrideFilters) => {
|
|
47
|
+
var _a, _b;
|
|
48
|
+
const currentFilters = overrideFilters || filtersRef.current;
|
|
49
|
+
const existingCounts = currentFilters.map((filter) => ({ count: 0, filter }));
|
|
50
|
+
let countFiltersToFetch = [];
|
|
51
|
+
if (notification) {
|
|
52
|
+
countFiltersToFetch = currentFilters.filter(
|
|
53
|
+
(filter) => (0, import_js.checkNotificationMatchesFilter)(notification, filter)
|
|
54
|
+
);
|
|
55
|
+
} else {
|
|
56
|
+
countFiltersToFetch = currentFilters;
|
|
52
57
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
if (countFiltersToFetch.length === 0) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
setIsFetching(true);
|
|
60
|
-
const countsRes = await notifications.count({ filters: countFiltersToFetch });
|
|
61
|
-
setIsFetching(false);
|
|
62
|
-
setIsLoading(false);
|
|
63
|
-
if (countsRes.error) {
|
|
64
|
-
setError(countsRes.error);
|
|
65
|
-
onError == null ? void 0 : onError(countsRes.error);
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
const data = countsRes.data;
|
|
69
|
-
onSuccess == null ? void 0 : onSuccess(data.counts);
|
|
70
|
-
setCounts((oldCounts) => {
|
|
71
|
-
const newCounts = [];
|
|
72
|
-
const countsReceived = data.counts;
|
|
73
|
-
for (let i = 0; i < existingCounts.length; i++) {
|
|
74
|
-
const existingFilter = existingCounts[i].filter;
|
|
75
|
-
const countReceived = countsReceived.find((c) => (0, import_js.isSameFilter)(c.filter, existingFilter));
|
|
76
|
-
const count = countReceived || (oldCounts == null ? void 0 : oldCounts[i]);
|
|
77
|
-
if (count) {
|
|
78
|
-
newCounts.push(count);
|
|
79
|
-
}
|
|
58
|
+
if (countFiltersToFetch.length === 0) {
|
|
59
|
+
return;
|
|
80
60
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
61
|
+
const generation = ++syncGenerationRef.current;
|
|
62
|
+
setIsFetching(true);
|
|
63
|
+
const countsRes = await notifications.count({ filters: countFiltersToFetch });
|
|
64
|
+
if (generation !== syncGenerationRef.current) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
setIsFetching(false);
|
|
68
|
+
setIsLoading(false);
|
|
69
|
+
if (countsRes.error) {
|
|
70
|
+
setError(countsRes.error);
|
|
71
|
+
(_a = onErrorRef.current) == null ? void 0 : _a.call(onErrorRef, countsRes.error);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const data = countsRes.data;
|
|
75
|
+
(_b = onSuccessRef.current) == null ? void 0 : _b.call(onSuccessRef, data.counts);
|
|
76
|
+
setCounts((oldCounts) => {
|
|
77
|
+
const newCounts = [];
|
|
78
|
+
const countsReceived = data.counts;
|
|
79
|
+
for (let i = 0; i < existingCounts.length; i++) {
|
|
80
|
+
const existingFilter = existingCounts[i].filter;
|
|
81
|
+
const countReceived = countsReceived.find((c) => (0, import_js.isSameFilter)(c.filter, existingFilter));
|
|
82
|
+
const count = countReceived || (oldCounts == null ? void 0 : oldCounts[i]);
|
|
83
|
+
if (count) {
|
|
84
|
+
newCounts.push(count);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return newCounts;
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
[notifications, filtersRef, onErrorRef, onSuccessRef]
|
|
91
|
+
);
|
|
84
92
|
(0, import_useWebsocketEvent.useWebSocketEvent)({
|
|
85
93
|
event: "notifications.notification_received",
|
|
86
94
|
enabled: realtime,
|
|
@@ -95,15 +103,26 @@ var useCounts = (props) => {
|
|
|
95
103
|
sync();
|
|
96
104
|
}
|
|
97
105
|
});
|
|
106
|
+
(0, import_react.useEffect)(() => {
|
|
107
|
+
const cleanups = import_js.NOTIFICATION_COUNT_SYNC_EVENTS.map(
|
|
108
|
+
(event) => novu.on(event, (payload) => {
|
|
109
|
+
if ("error" in payload && payload.error) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
sync();
|
|
113
|
+
})
|
|
114
|
+
);
|
|
115
|
+
return () => cleanups.forEach((cleanup) => cleanup());
|
|
116
|
+
}, [novu, sync]);
|
|
98
117
|
(0, import_react.useEffect)(() => {
|
|
99
118
|
setError(void 0);
|
|
100
119
|
setIsLoading(true);
|
|
101
120
|
setIsFetching(false);
|
|
102
121
|
sync(void 0, filters);
|
|
103
|
-
}, [JSON.stringify(filters)]);
|
|
104
|
-
const refetch = async () => {
|
|
122
|
+
}, [JSON.stringify(filters), sync]);
|
|
123
|
+
const refetch = (0, import_react.useCallback)(async () => {
|
|
105
124
|
await sync();
|
|
106
|
-
};
|
|
125
|
+
}, [sync]);
|
|
107
126
|
return { counts, error, refetch, isLoading, isFetching };
|
|
108
127
|
};
|
|
109
128
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/useCounts.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/useCounts.ts"],"sourcesContent":["import { NOTIFICATION_COUNT_SYNC_EVENTS, checkNotificationMatchesFilter, isSameFilter, Notification, NotificationFilter, NovuError } from '@novu/js';\nimport { useCallback, useEffect, useRef, useState } from 'react';\nimport { useDataRef } from './internal/useDataRef';\nimport { useWebSocketEvent } from './internal/useWebsocketEvent';\nimport { useNovu, useRealtime } from './NovuProvider';\n\ntype Count = {\n count: number;\n filter: NotificationFilter;\n};\n\n/**\n * Props for the useCounts hook.\n *\n * @example\n * ```tsx\n * // Count unread notifications\n * const { counts } = useCounts({\n * filters: [{ read: false }]\n * });\n *\n * // Count unseen notifications with specific tags\n * const { counts } = useCounts({\n * filters: [{ seen: false, tags: ['important'] }]\n * });\n *\n * // Count seen but unread notifications\n * const { counts } = useCounts({\n * filters: [{ seen: true, read: false }]\n * });\n *\n * // Opt out of the built-in realtime count updates and drive them yourself\n * const { counts, refetch } = useCounts({\n * filters: [{ read: false }],\n * realtime: false,\n * });\n * ```\n */\nexport type UseCountsProps = {\n filters: NotificationFilter[];\n /**\n * When `false`, disables the WebSocket subscriptions that auto-resync\n * counts on `notifications.notification_received` and\n * `notifications.unread_count_changed`. The filter-driven fetch and\n * `refetch()` keep working. Use alongside\n * `useNotifications({ realtime: false })` when you drive live updates\n * yourself.\n *\n * When set, this prop takes precedence over the `realtime` config on\n * `<NovuProvider />`. When omitted, the provider value (default `true`) is used.\n */\n realtime?: boolean;\n onSuccess?: (data: Count[]) => void;\n onError?: (error: NovuError) => void;\n};\n\nexport type UseCountsResult = {\n counts?: Count[];\n error?: NovuError;\n isLoading: boolean; // initial loading\n isFetching: boolean; // the request is in flight\n refetch: () => Promise<void>;\n};\n\nexport const useCounts = (props: UseCountsProps): UseCountsResult => {\n const { filters, realtime: propsRealtime, onSuccess, onError } = props;\n const novu = useNovu();\n const { notifications } = novu;\n const providerRealtime = useRealtime();\n const realtime = propsRealtime ?? providerRealtime;\n const filtersRef = useDataRef<NotificationFilter[]>(filters);\n const onSuccessRef = useDataRef(onSuccess);\n const onErrorRef = useDataRef(onError);\n const syncGenerationRef = useRef(0);\n const [error, setError] = useState<NovuError>();\n const [counts, setCounts] = useState<Count[]>();\n const [isLoading, setIsLoading] = useState(true);\n const [isFetching, setIsFetching] = useState(false);\n\n const sync = useCallback(\n async (notification?: Notification, overrideFilters?: NotificationFilter[]) => {\n const currentFilters = overrideFilters || filtersRef.current;\n const existingCounts = currentFilters.map((filter) => ({ count: 0, filter }));\n let countFiltersToFetch: NotificationFilter[] = [];\n\n if (notification) {\n countFiltersToFetch = currentFilters.filter((filter) =>\n checkNotificationMatchesFilter(notification, filter)\n );\n } else {\n countFiltersToFetch = currentFilters;\n }\n\n if (countFiltersToFetch.length === 0) {\n return;\n }\n\n const generation = ++syncGenerationRef.current;\n setIsFetching(true);\n\n const countsRes = await notifications.count({ filters: countFiltersToFetch });\n\n if (generation !== syncGenerationRef.current) {\n return;\n }\n\n setIsFetching(false);\n setIsLoading(false);\n\n if (countsRes.error) {\n setError(countsRes.error);\n onErrorRef.current?.(countsRes.error);\n\n return;\n }\n\n const data = countsRes.data!;\n onSuccessRef.current?.(data.counts);\n\n setCounts((oldCounts) => {\n const newCounts: Count[] = [];\n const countsReceived = data.counts;\n\n for (let i = 0; i < existingCounts.length; i++) {\n const existingFilter = existingCounts[i].filter;\n const countReceived = countsReceived.find((c) => isSameFilter(c.filter, existingFilter));\n const count = countReceived || oldCounts?.[i];\n if (count) {\n newCounts.push(count);\n }\n }\n\n return newCounts;\n });\n },\n [notifications, filtersRef, onErrorRef, onSuccessRef]\n );\n\n useWebSocketEvent({\n event: 'notifications.notification_received',\n enabled: realtime,\n eventHandler: (data) => {\n sync(data.result);\n },\n });\n\n useWebSocketEvent({\n event: 'notifications.unread_count_changed',\n enabled: realtime,\n eventHandler: () => {\n sync();\n },\n });\n\n useEffect(() => {\n const cleanups = NOTIFICATION_COUNT_SYNC_EVENTS.map((event) =>\n novu.on(event, (payload) => {\n if ('error' in payload && payload.error) {\n return;\n }\n\n sync();\n })\n );\n\n return () => cleanups.forEach((cleanup) => cleanup());\n }, [novu, sync]);\n\n useEffect(() => {\n setError(undefined);\n setIsLoading(true);\n setIsFetching(false);\n sync(undefined, filters);\n }, [JSON.stringify(filters), sync]);\n\n const refetch = useCallback(async () => {\n await sync();\n }, [sync]);\n\n return { counts, error, refetch, isLoading, isFetching };\n};\n"],"mappings":"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","names":[]}
|
|
@@ -55,7 +55,8 @@ var usePreferences = (props) => {
|
|
|
55
55
|
if (response.error) {
|
|
56
56
|
setError(response.error);
|
|
57
57
|
onError == null ? void 0 : onError(response.error);
|
|
58
|
-
} else {
|
|
58
|
+
} else if (response.data) {
|
|
59
|
+
setData(response.data);
|
|
59
60
|
onSuccess == null ? void 0 : onSuccess(response.data);
|
|
60
61
|
}
|
|
61
62
|
setIsLoading(false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/usePreferences.ts"],"sourcesContent":["import { NovuError, Preference, SeverityLevelEnum, WorkflowCriticalityEnum } from '@novu/js';\nimport { useEffect, useState } from 'react';\nimport { useNovu } from './NovuProvider';\n\nexport type UsePreferencesProps = {\n filter?: {\n tags?: string[];\n severity?: SeverityLevelEnum | SeverityLevelEnum[];\n criticality?: WorkflowCriticalityEnum;\n };\n onSuccess?: (data: Preference[]) => void;\n onError?: (error: NovuError) => void;\n};\n\nexport type UsePreferencesResult = {\n preferences?: Preference[];\n error?: NovuError;\n isLoading: boolean; // initial loading\n isFetching: boolean; // the request is in flight\n refetch: () => Promise<void>;\n};\n\nexport const usePreferences = (props?: UsePreferencesProps): UsePreferencesResult => {\n const { onSuccess, onError } = props || {};\n const [data, setData] = useState<Preference[]>();\n const { preferences, on } = useNovu();\n const [error, setError] = useState<NovuError>();\n const [isLoading, setIsLoading] = useState(true);\n const [isFetching, setIsFetching] = useState(false);\n\n const sync = (event: { data?: Preference[] }) => {\n if (!event.data) {\n return;\n }\n setData(event.data);\n };\n\n useEffect(() => {\n fetchPreferences();\n\n const listUpdatedCleanup = on('preferences.list.updated', sync);\n const listPendingCleanup = on('preferences.list.pending', sync);\n const listResolvedCleanup = on('preferences.list.resolved', sync);\n\n return () => {\n listUpdatedCleanup();\n listPendingCleanup();\n listResolvedCleanup();\n };\n }, []);\n\n const fetchPreferences = async () => {\n setIsFetching(true);\n const response = await preferences.list(props?.filter);\n if (response.error) {\n setError(response.error);\n onError?.(response.error);\n } else {\n onSuccess?.(response.data
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/usePreferences.ts"],"sourcesContent":["import { NovuError, Preference, SeverityLevelEnum, WorkflowCriticalityEnum } from '@novu/js';\nimport { useEffect, useState } from 'react';\nimport { useNovu } from './NovuProvider';\n\nexport type UsePreferencesProps = {\n filter?: {\n tags?: string[];\n severity?: SeverityLevelEnum | SeverityLevelEnum[];\n criticality?: WorkflowCriticalityEnum;\n };\n onSuccess?: (data: Preference[]) => void;\n onError?: (error: NovuError) => void;\n};\n\nexport type UsePreferencesResult = {\n preferences?: Preference[];\n error?: NovuError;\n isLoading: boolean; // initial loading\n isFetching: boolean; // the request is in flight\n refetch: () => Promise<void>;\n};\n\nexport const usePreferences = (props?: UsePreferencesProps): UsePreferencesResult => {\n const { onSuccess, onError } = props || {};\n const [data, setData] = useState<Preference[]>();\n const { preferences, on } = useNovu();\n const [error, setError] = useState<NovuError>();\n const [isLoading, setIsLoading] = useState(true);\n const [isFetching, setIsFetching] = useState(false);\n\n const sync = (event: { data?: Preference[] }) => {\n if (!event.data) {\n return;\n }\n setData(event.data);\n };\n\n useEffect(() => {\n fetchPreferences();\n\n const listUpdatedCleanup = on('preferences.list.updated', sync);\n const listPendingCleanup = on('preferences.list.pending', sync);\n const listResolvedCleanup = on('preferences.list.resolved', sync);\n\n return () => {\n listUpdatedCleanup();\n listPendingCleanup();\n listResolvedCleanup();\n };\n }, []);\n\n const fetchPreferences = async () => {\n setIsFetching(true);\n const response = await preferences.list(props?.filter);\n if (response.error) {\n setError(response.error);\n onError?.(response.error);\n } else if (response.data) {\n setData(response.data);\n onSuccess?.(response.data);\n }\n setIsLoading(false);\n setIsFetching(false);\n };\n\n const refetch = () => {\n preferences.cache.clearAll();\n\n return fetchPreferences();\n };\n\n return {\n preferences: data,\n error,\n isLoading,\n isFetching,\n refetch,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAoC;AACpC,0BAAwB;AAoBjB,IAAM,iBAAiB,CAAC,UAAsD;AACnF,QAAM,EAAE,WAAW,QAAQ,IAAI,SAAS,CAAC;AACzC,QAAM,CAAC,MAAM,OAAO,QAAI,uBAAuB;AAC/C,QAAM,EAAE,aAAa,GAAG,QAAI,6BAAQ;AACpC,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAAoB;AAC9C,QAAM,CAAC,WAAW,YAAY,QAAI,uBAAS,IAAI;AAC/C,QAAM,CAAC,YAAY,aAAa,QAAI,uBAAS,KAAK;AAElD,QAAM,OAAO,CAAC,UAAmC;AAC/C,QAAI,CAAC,MAAM,MAAM;AACf;AAAA,IACF;AACA,YAAQ,MAAM,IAAI;AAAA,EACpB;AAEA,8BAAU,MAAM;AACd,qBAAiB;AAEjB,UAAM,qBAAqB,GAAG,4BAA4B,IAAI;AAC9D,UAAM,qBAAqB,GAAG,4BAA4B,IAAI;AAC9D,UAAM,sBAAsB,GAAG,6BAA6B,IAAI;AAEhE,WAAO,MAAM;AACX,yBAAmB;AACnB,yBAAmB;AACnB,0BAAoB;AAAA,IACtB;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,QAAM,mBAAmB,YAAY;AACnC,kBAAc,IAAI;AAClB,UAAM,WAAW,MAAM,YAAY,KAAK,+BAAO,MAAM;AACrD,QAAI,SAAS,OAAO;AAClB,eAAS,SAAS,KAAK;AACvB,yCAAU,SAAS;AAAA,IACrB,WAAW,SAAS,MAAM;AACxB,cAAQ,SAAS,IAAI;AACrB,6CAAY,SAAS;AAAA,IACvB;AACA,iBAAa,KAAK;AAClB,kBAAc,KAAK;AAAA,EACrB;AAEA,QAAM,UAAU,MAAM;AACpB,gBAAY,MAAM,SAAS;AAE3B,WAAO,iBAAiB;AAAA,EAC1B;AAEA,SAAO;AAAA,IACL,aAAa;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -55,7 +55,8 @@ var useSchedule = (props) => {
|
|
|
55
55
|
if (response.error) {
|
|
56
56
|
setError(response.error);
|
|
57
57
|
onError == null ? void 0 : onError(response.error);
|
|
58
|
-
} else {
|
|
58
|
+
} else if (response.data) {
|
|
59
|
+
setData(response.data);
|
|
59
60
|
onSuccess == null ? void 0 : onSuccess(response.data);
|
|
60
61
|
}
|
|
61
62
|
setIsLoading(false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/useSchedule.ts"],"sourcesContent":["import { NovuError, Schedule } from '@novu/js';\nimport { useEffect, useState } from 'react';\nimport { useNovu } from './NovuProvider';\n\nexport type UseScheduleProps = {\n onSuccess?: (data: Schedule) => void;\n onError?: (error: NovuError) => void;\n};\n\nexport type UseScheduleResult = {\n schedule?: Schedule;\n error?: NovuError;\n isLoading: boolean; // initial loading\n isFetching: boolean; // the request is in flight\n refetch: () => Promise<void>;\n};\n\nexport const useSchedule = (props?: UseScheduleProps): UseScheduleResult => {\n const { onSuccess, onError } = props || {};\n const [data, setData] = useState<Schedule>();\n const { preferences, on } = useNovu();\n const [error, setError] = useState<NovuError>();\n const [isLoading, setIsLoading] = useState(true);\n const [isFetching, setIsFetching] = useState(false);\n\n const sync = (event: { data?: Schedule }) => {\n if (!event.data) {\n return;\n }\n setData(event.data);\n };\n\n useEffect(() => {\n fetchSchedule();\n\n const listUpdatedCleanup = on('preference.schedule.get.updated', sync);\n const listPendingCleanup = on('preference.schedule.get.pending', sync);\n const listResolvedCleanup = on('preference.schedule.get.resolved', sync);\n\n return () => {\n listUpdatedCleanup();\n listPendingCleanup();\n listResolvedCleanup();\n };\n }, []);\n\n const fetchSchedule = async () => {\n setIsFetching(true);\n const response = await preferences.schedule.get();\n if (response.error) {\n setError(response.error);\n onError?.(response.error);\n } else {\n onSuccess?.(response.data
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/useSchedule.ts"],"sourcesContent":["import { NovuError, Schedule } from '@novu/js';\nimport { useEffect, useState } from 'react';\nimport { useNovu } from './NovuProvider';\n\nexport type UseScheduleProps = {\n onSuccess?: (data: Schedule) => void;\n onError?: (error: NovuError) => void;\n};\n\nexport type UseScheduleResult = {\n schedule?: Schedule;\n error?: NovuError;\n isLoading: boolean; // initial loading\n isFetching: boolean; // the request is in flight\n refetch: () => Promise<void>;\n};\n\nexport const useSchedule = (props?: UseScheduleProps): UseScheduleResult => {\n const { onSuccess, onError } = props || {};\n const [data, setData] = useState<Schedule>();\n const { preferences, on } = useNovu();\n const [error, setError] = useState<NovuError>();\n const [isLoading, setIsLoading] = useState(true);\n const [isFetching, setIsFetching] = useState(false);\n\n const sync = (event: { data?: Schedule }) => {\n if (!event.data) {\n return;\n }\n setData(event.data);\n };\n\n useEffect(() => {\n fetchSchedule();\n\n const listUpdatedCleanup = on('preference.schedule.get.updated', sync);\n const listPendingCleanup = on('preference.schedule.get.pending', sync);\n const listResolvedCleanup = on('preference.schedule.get.resolved', sync);\n\n return () => {\n listUpdatedCleanup();\n listPendingCleanup();\n listResolvedCleanup();\n };\n }, []);\n\n const fetchSchedule = async () => {\n setIsFetching(true);\n const response = await preferences.schedule.get();\n if (response.error) {\n setError(response.error);\n onError?.(response.error);\n } else if (response.data) {\n setData(response.data);\n onSuccess?.(response.data);\n }\n setIsLoading(false);\n setIsFetching(false);\n };\n\n const refetch = () => {\n preferences.schedule.cache.clearAll();\n\n return fetchSchedule();\n };\n\n return {\n schedule: data,\n error,\n isLoading,\n isFetching,\n refetch,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAoC;AACpC,0BAAwB;AAejB,IAAM,cAAc,CAAC,UAAgD;AAC1E,QAAM,EAAE,WAAW,QAAQ,IAAI,SAAS,CAAC;AACzC,QAAM,CAAC,MAAM,OAAO,QAAI,uBAAmB;AAC3C,QAAM,EAAE,aAAa,GAAG,QAAI,6BAAQ;AACpC,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAAoB;AAC9C,QAAM,CAAC,WAAW,YAAY,QAAI,uBAAS,IAAI;AAC/C,QAAM,CAAC,YAAY,aAAa,QAAI,uBAAS,KAAK;AAElD,QAAM,OAAO,CAAC,UAA+B;AAC3C,QAAI,CAAC,MAAM,MAAM;AACf;AAAA,IACF;AACA,YAAQ,MAAM,IAAI;AAAA,EACpB;AAEA,8BAAU,MAAM;AACd,kBAAc;AAEd,UAAM,qBAAqB,GAAG,mCAAmC,IAAI;AACrE,UAAM,qBAAqB,GAAG,mCAAmC,IAAI;AACrE,UAAM,sBAAsB,GAAG,oCAAoC,IAAI;AAEvE,WAAO,MAAM;AACX,yBAAmB;AACnB,yBAAmB;AACnB,0BAAoB;AAAA,IACtB;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,QAAM,gBAAgB,YAAY;AAChC,kBAAc,IAAI;AAClB,UAAM,WAAW,MAAM,YAAY,SAAS,IAAI;AAChD,QAAI,SAAS,OAAO;AAClB,eAAS,SAAS,KAAK;AACvB,yCAAU,SAAS;AAAA,IACrB,WAAW,SAAS,MAAM;AACxB,cAAQ,SAAS,IAAI;AACrB,6CAAY,SAAS;AAAA,IACvB;AACA,iBAAa,KAAK;AAClB,kBAAc,KAAK;AAAA,EACrB;AAEA,QAAM,UAAU,MAAM;AACpB,gBAAY,SAAS,MAAM,SAAS;AAEpC,WAAO,cAAc;AAAA,EACvB;AAEA,SAAO;AAAA,IACL,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/hooks/useTelegramSubscriberLink.ts
|
|
21
|
+
var useTelegramSubscriberLink_exports = {};
|
|
22
|
+
__export(useTelegramSubscriberLink_exports, {
|
|
23
|
+
useTelegramSubscriberLink: () => useTelegramSubscriberLink
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(useTelegramSubscriberLink_exports);
|
|
26
|
+
var import_js = require("@novu/js");
|
|
27
|
+
var import_react = require("react");
|
|
28
|
+
function useTelegramSubscriberLink(props) {
|
|
29
|
+
const [state, setState] = (0, import_react.useState)({
|
|
30
|
+
status: "loading",
|
|
31
|
+
deepLinkUrl: null,
|
|
32
|
+
botUsername: null,
|
|
33
|
+
expiresAt: null,
|
|
34
|
+
error: null
|
|
35
|
+
});
|
|
36
|
+
const instanceRef = (0, import_react.useRef)(null);
|
|
37
|
+
const { apiUrl, secretKey, integrationIdentifier, subscriberId, pollIntervalMs, fetchFn } = props;
|
|
38
|
+
const fetchFnRef = (0, import_react.useRef)(fetchFn);
|
|
39
|
+
fetchFnRef.current = fetchFn;
|
|
40
|
+
const stableFetchFn = (0, import_react.useCallback)((input, init) => {
|
|
41
|
+
const fn = fetchFnRef.current ?? fetch;
|
|
42
|
+
return fn(input, init);
|
|
43
|
+
}, []);
|
|
44
|
+
(0, import_react.useEffect)(() => {
|
|
45
|
+
const link = new import_js.TelegramSubscriberLink({
|
|
46
|
+
apiUrl,
|
|
47
|
+
secretKey,
|
|
48
|
+
integrationIdentifier,
|
|
49
|
+
subscriberId,
|
|
50
|
+
pollIntervalMs,
|
|
51
|
+
fetchFn: stableFetchFn
|
|
52
|
+
});
|
|
53
|
+
instanceRef.current = link;
|
|
54
|
+
setState({ ...link.state });
|
|
55
|
+
const unsubscribe = link.onStateChange((next) => {
|
|
56
|
+
setState({ ...next });
|
|
57
|
+
});
|
|
58
|
+
void link.start();
|
|
59
|
+
return () => {
|
|
60
|
+
unsubscribe();
|
|
61
|
+
link.stop();
|
|
62
|
+
instanceRef.current = null;
|
|
63
|
+
};
|
|
64
|
+
}, [apiUrl, secretKey, integrationIdentifier, subscriberId, pollIntervalMs, stableFetchFn]);
|
|
65
|
+
const refresh = (0, import_react.useCallback)(async () => {
|
|
66
|
+
if (instanceRef.current) {
|
|
67
|
+
await instanceRef.current.refresh();
|
|
68
|
+
}
|
|
69
|
+
}, []);
|
|
70
|
+
return {
|
|
71
|
+
deepLinkUrl: state.deepLinkUrl,
|
|
72
|
+
botUsername: state.botUsername,
|
|
73
|
+
status: state.status,
|
|
74
|
+
error: state.error,
|
|
75
|
+
refresh
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
79
|
+
0 && (module.exports = {
|
|
80
|
+
useTelegramSubscriberLink
|
|
81
|
+
});
|
|
82
|
+
//# sourceMappingURL=useTelegramSubscriberLink.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/useTelegramSubscriberLink.ts"],"sourcesContent":["import type {\n TelegramSubscriberLinkOptions,\n TelegramSubscriberLinkState,\n TelegramSubscriberLinkStatus,\n} from '@novu/js';\nimport { TelegramSubscriberLink } from '@novu/js';\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nexport type UseTelegramSubscriberLinkProps = TelegramSubscriberLinkOptions;\n\nexport type UseTelegramSubscriberLinkResult = {\n /** Current deep-link URL (`t.me/<bot>?start=<code>`), or `null` before the first issue. */\n deepLinkUrl: string | null;\n /** Telegram bot username (no `@`), or `null` before the first issue. */\n botUsername: string | null;\n /** Lifecycle status: `loading` while resolving initial state, `pending` while waiting for Start, `connected` once linked, `expired` briefly before auto-reissue. */\n status: TelegramSubscriberLinkStatus;\n /** Last error, if any. */\n error: Error | null;\n /** Re-issue a fresh deep link and restart polling. */\n refresh: () => Promise<void>;\n};\n\n/**\n * React hook wrapping {@link TelegramSubscriberLink} from `@novu/js`.\n *\n * Issues a Telegram subscriber-link deep link, polls for connection, and\n * re-issues automatically on code expiry. Returns reactive state that\n * updates as the lifecycle progresses.\n *\n * **Important:** The underlying API endpoint requires `INTEGRATION_WRITE` permission.\n * Either pass `secretKey` for direct server-side usage, or provide a custom\n * `fetchFn` / `apiUrl` that routes through your backend proxy.\n *\n * @example\n * ```tsx\n * import { useTelegramSubscriberLink } from '@novu/react';\n *\n * function TelegramConnect() {\n * const { deepLinkUrl, botUsername, status, refresh } = useTelegramSubscriberLink({\n * apiUrl: '/api/novu-proxy',\n * integrationIdentifier: '<telegram-integration-identifier>',\n * subscriberId: 'user-42',\n * });\n *\n * if (status === 'connected') return <p>Connected!</p>;\n *\n * return (\n * <div>\n * {deepLinkUrl && <a href={deepLinkUrl}>Open @{botUsername} in Telegram</a>}\n * <button onClick={refresh}>Refresh link</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useTelegramSubscriberLink(props: UseTelegramSubscriberLinkProps): UseTelegramSubscriberLinkResult {\n const [state, setState] = useState<TelegramSubscriberLinkState>({\n status: 'loading',\n deepLinkUrl: null,\n botUsername: null,\n expiresAt: null,\n error: null,\n });\n\n const instanceRef = useRef<TelegramSubscriberLink | null>(null);\n\n const { apiUrl, secretKey, integrationIdentifier, subscriberId, pollIntervalMs, fetchFn } = props;\n\n // Keep the latest `fetchFn` in a ref so a new inline-function identity on every\n // render does not re-trigger the effect (which would tear down and re-issue the\n // link on a loop). The stable wrapper below reads from this ref.\n const fetchFnRef = useRef(fetchFn);\n fetchFnRef.current = fetchFn;\n\n const stableFetchFn = useCallback<typeof fetch>((input, init) => {\n const fn = fetchFnRef.current ?? fetch;\n\n return fn(input, init);\n }, []);\n\n useEffect(() => {\n const link = new TelegramSubscriberLink({\n apiUrl,\n secretKey,\n integrationIdentifier,\n subscriberId,\n pollIntervalMs,\n fetchFn: stableFetchFn,\n });\n\n instanceRef.current = link;\n setState({ ...link.state });\n\n const unsubscribe = link.onStateChange((next) => {\n setState({ ...next });\n });\n\n void link.start();\n\n return () => {\n unsubscribe();\n link.stop();\n instanceRef.current = null;\n };\n }, [apiUrl, secretKey, integrationIdentifier, subscriberId, pollIntervalMs, stableFetchFn]);\n\n const refresh = useCallback(async () => {\n if (instanceRef.current) {\n await instanceRef.current.refresh();\n }\n }, []);\n\n return {\n deepLinkUrl: state.deepLinkUrl,\n botUsername: state.botUsername,\n status: state.status,\n error: state.error,\n refresh,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,gBAAuC;AACvC,mBAAyD;AAkDlD,SAAS,0BAA0B,OAAwE;AAChH,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAAsC;AAAA,IAC9D,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,aAAa;AAAA,IACb,WAAW;AAAA,IACX,OAAO;AAAA,EACT,CAAC;AAED,QAAM,kBAAc,qBAAsC,IAAI;AAE9D,QAAM,EAAE,QAAQ,WAAW,uBAAuB,cAAc,gBAAgB,QAAQ,IAAI;AAK5F,QAAM,iBAAa,qBAAO,OAAO;AACjC,aAAW,UAAU;AAErB,QAAM,oBAAgB,0BAA0B,CAAC,OAAO,SAAS;AAC/D,UAAM,KAAK,WAAW,WAAW;AAEjC,WAAO,GAAG,OAAO,IAAI;AAAA,EACvB,GAAG,CAAC,CAAC;AAEL,8BAAU,MAAM;AACd,UAAM,OAAO,IAAI,iCAAuB;AAAA,MACtC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAS;AAAA,IACX,CAAC;AAED,gBAAY,UAAU;AACtB,aAAS,EAAE,GAAG,KAAK,MAAM,CAAC;AAE1B,UAAM,cAAc,KAAK,cAAc,CAAC,SAAS;AAC/C,eAAS,EAAE,GAAG,KAAK,CAAC;AAAA,IACtB,CAAC;AAED,SAAK,KAAK,MAAM;AAEhB,WAAO,MAAM;AACX,kBAAY;AACZ,WAAK,KAAK;AACV,kBAAY,UAAU;AAAA,IACxB;AAAA,EACF,GAAG,CAAC,QAAQ,WAAW,uBAAuB,cAAc,gBAAgB,aAAa,CAAC;AAE1F,QAAM,cAAU,0BAAY,YAAY;AACtC,QAAI,YAAY,SAAS;AACvB,YAAM,YAAY,QAAQ,QAAQ;AAAA,IACpC;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AAAA,IACL,aAAa,MAAM;AAAA,IACnB,aAAa,MAAM;AAAA,IACnB,QAAQ,MAAM;AAAA,IACd,OAAO,MAAM;AAAA,IACb;AAAA,EACF;AACF;","names":[]}
|