@novu/js 2.6.3 → 2.6.4
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/{chunk-JNGDKCKO.js → chunk-NCIKS5DU.js} +121 -22
- package/dist/cjs/index.d.ts +2 -3
- package/dist/cjs/index.js +14 -14
- package/dist/{esm/novu-C3OVXS9Q.d.mts → cjs/novu-CTwfWx9z.d.ts} +7 -3
- package/dist/cjs/themes/index.d.ts +2 -3
- package/dist/cjs/{types-DJ_8ubnK.d.ts → types-C9Kspo68.d.ts} +1 -1
- package/dist/cjs/ui/index.d.ts +4 -5
- package/dist/cjs/ui/index.js +8 -5
- package/dist/esm/{chunk-CRYKKYGT.mjs → chunk-OMRGYSBS.mjs} +120 -21
- package/dist/esm/index.d.mts +2 -3
- package/dist/esm/index.mjs +1 -1
- package/dist/{cjs/novu-C3OVXS9Q.d.ts → esm/novu-CTwfWx9z.d.mts} +7 -3
- package/dist/esm/themes/index.d.mts +2 -3
- package/dist/esm/{types-mimIUjS9.d.mts → types-CKQNsFHO.d.mts} +1 -1
- package/dist/esm/ui/index.d.mts +4 -5
- package/dist/esm/ui/index.mjs +5 -2
- package/dist/novu.min.js +11 -11
- package/dist/novu.min.js.gz +0 -0
- package/package.json +3 -4
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
var chunk7B52C2XE_js = require('./chunk-7B52C2XE.js');
|
|
4
4
|
var mitt = require('mitt');
|
|
5
5
|
var io = require('socket.io-client');
|
|
6
|
-
var client = require('@novu/client');
|
|
7
6
|
|
|
8
7
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
8
|
|
|
@@ -1476,7 +1475,108 @@ initializeSocket_fn = function() {
|
|
|
1476
1475
|
|
|
1477
1476
|
// src/utils/config.ts
|
|
1478
1477
|
var PRODUCTION_BACKEND_URL = "https://api.novu.co";
|
|
1479
|
-
|
|
1478
|
+
|
|
1479
|
+
// src/api/http-client.ts
|
|
1480
|
+
var DEFAULT_API_VERSION = "v1";
|
|
1481
|
+
var DEFAULT_BACKEND_URL = "https://api.novu.co";
|
|
1482
|
+
var DEFAULT_USER_AGENT = `${"@novu/js"}@${"2.6.4"}`;
|
|
1483
|
+
var HttpClient = class {
|
|
1484
|
+
constructor(options = {}) {
|
|
1485
|
+
const {
|
|
1486
|
+
apiVersion = DEFAULT_API_VERSION,
|
|
1487
|
+
backendUrl = DEFAULT_BACKEND_URL,
|
|
1488
|
+
userAgent = DEFAULT_USER_AGENT
|
|
1489
|
+
} = options || {};
|
|
1490
|
+
this.apiVersion = apiVersion;
|
|
1491
|
+
this.backendUrl = `${backendUrl}/${this.apiVersion}`;
|
|
1492
|
+
this.headers = {
|
|
1493
|
+
"Novu-API-Version": "2024-06-26",
|
|
1494
|
+
"Content-Type": "application/json",
|
|
1495
|
+
"User-Agent": userAgent
|
|
1496
|
+
};
|
|
1497
|
+
}
|
|
1498
|
+
setAuthorizationToken(token) {
|
|
1499
|
+
this.headers.Authorization = `Bearer ${token}`;
|
|
1500
|
+
}
|
|
1501
|
+
setHeaders(headers) {
|
|
1502
|
+
this.headers = chunk7B52C2XE_js.__spreadValues(chunk7B52C2XE_js.__spreadValues({}, this.headers), headers);
|
|
1503
|
+
}
|
|
1504
|
+
get(path, searchParams, unwrapEnvelope = true) {
|
|
1505
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
1506
|
+
return this.doFetch({
|
|
1507
|
+
path,
|
|
1508
|
+
searchParams,
|
|
1509
|
+
options: {
|
|
1510
|
+
method: "GET"
|
|
1511
|
+
},
|
|
1512
|
+
unwrapEnvelope
|
|
1513
|
+
});
|
|
1514
|
+
});
|
|
1515
|
+
}
|
|
1516
|
+
post(path, body) {
|
|
1517
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
1518
|
+
return this.doFetch({
|
|
1519
|
+
path,
|
|
1520
|
+
options: {
|
|
1521
|
+
method: "POST",
|
|
1522
|
+
body
|
|
1523
|
+
}
|
|
1524
|
+
});
|
|
1525
|
+
});
|
|
1526
|
+
}
|
|
1527
|
+
patch(path, body) {
|
|
1528
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
1529
|
+
return this.doFetch({
|
|
1530
|
+
path,
|
|
1531
|
+
options: {
|
|
1532
|
+
method: "PATCH",
|
|
1533
|
+
body
|
|
1534
|
+
}
|
|
1535
|
+
});
|
|
1536
|
+
});
|
|
1537
|
+
}
|
|
1538
|
+
delete(path, body) {
|
|
1539
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
1540
|
+
return this.doFetch({
|
|
1541
|
+
path,
|
|
1542
|
+
options: {
|
|
1543
|
+
method: "DELETE",
|
|
1544
|
+
body
|
|
1545
|
+
}
|
|
1546
|
+
});
|
|
1547
|
+
});
|
|
1548
|
+
}
|
|
1549
|
+
doFetch(_0) {
|
|
1550
|
+
return chunk7B52C2XE_js.__async(this, arguments, function* ({
|
|
1551
|
+
path,
|
|
1552
|
+
searchParams,
|
|
1553
|
+
options,
|
|
1554
|
+
unwrapEnvelope = true
|
|
1555
|
+
}) {
|
|
1556
|
+
const fullUrl = combineUrl(this.backendUrl, path, searchParams ? `?${searchParams.toString()}` : "");
|
|
1557
|
+
const reqInit = {
|
|
1558
|
+
method: (options == null ? void 0 : options.method) || "GET",
|
|
1559
|
+
headers: chunk7B52C2XE_js.__spreadValues(chunk7B52C2XE_js.__spreadValues({}, this.headers), (options == null ? void 0 : options.headers) || {}),
|
|
1560
|
+
body: (options == null ? void 0 : options.body) ? JSON.stringify(options.body) : void 0
|
|
1561
|
+
};
|
|
1562
|
+
const response = yield fetch(fullUrl, reqInit);
|
|
1563
|
+
if (!response.ok) {
|
|
1564
|
+
const errorData = yield response.json();
|
|
1565
|
+
throw new Error(`${this.headers["User-Agent"]} error. Status: ${response.status}, Message: ${errorData.message}`);
|
|
1566
|
+
}
|
|
1567
|
+
if (response.status === 204) {
|
|
1568
|
+
return void 0;
|
|
1569
|
+
}
|
|
1570
|
+
const res = yield response.json();
|
|
1571
|
+
return unwrapEnvelope ? res.data : res;
|
|
1572
|
+
});
|
|
1573
|
+
}
|
|
1574
|
+
};
|
|
1575
|
+
function combineUrl(...args) {
|
|
1576
|
+
return args.map((part) => part.replace(/^\/+|\/+$/g, "")).join("/");
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1579
|
+
// src/api/inbox-service.ts
|
|
1480
1580
|
var INBOX_ROUTE = "/inbox";
|
|
1481
1581
|
var INBOX_NOTIFICATIONS_ROUTE = `${INBOX_ROUTE}/notifications`;
|
|
1482
1582
|
var _httpClient;
|
|
@@ -1484,11 +1584,7 @@ var InboxService = class {
|
|
|
1484
1584
|
constructor(options = {}) {
|
|
1485
1585
|
this.isSessionInitialized = false;
|
|
1486
1586
|
chunk7B52C2XE_js.__privateAdd(this, _httpClient);
|
|
1487
|
-
chunk7B52C2XE_js.__privateSet(this, _httpClient, new
|
|
1488
|
-
chunk7B52C2XE_js.__privateGet(this, _httpClient).updateHeaders({
|
|
1489
|
-
"Novu-API-Version": NOVU_API_VERSION,
|
|
1490
|
-
"Novu-User-Agent": options.userAgent || "@novu/js"
|
|
1491
|
-
});
|
|
1587
|
+
chunk7B52C2XE_js.__privateSet(this, _httpClient, new HttpClient(options));
|
|
1492
1588
|
}
|
|
1493
1589
|
initializeSession(_0) {
|
|
1494
1590
|
return chunk7B52C2XE_js.__async(this, arguments, function* ({
|
|
@@ -1514,26 +1610,32 @@ var InboxService = class {
|
|
|
1514
1610
|
read: read2,
|
|
1515
1611
|
tags
|
|
1516
1612
|
}) {
|
|
1517
|
-
const
|
|
1613
|
+
const searchParams = new URLSearchParams(`limit=${limit}`);
|
|
1518
1614
|
if (after) {
|
|
1519
|
-
|
|
1615
|
+
searchParams.append("after", after);
|
|
1520
1616
|
}
|
|
1521
1617
|
if (offset) {
|
|
1522
|
-
|
|
1618
|
+
searchParams.append("offset", `${offset}`);
|
|
1523
1619
|
}
|
|
1524
1620
|
if (tags) {
|
|
1525
|
-
tags.forEach((tag) =>
|
|
1621
|
+
tags.forEach((tag) => searchParams.append("tags[]", tag));
|
|
1526
1622
|
}
|
|
1527
1623
|
if (read2 !== void 0) {
|
|
1528
|
-
|
|
1624
|
+
searchParams.append("read", `${read2}`);
|
|
1529
1625
|
}
|
|
1530
1626
|
if (archived !== void 0) {
|
|
1531
|
-
|
|
1627
|
+
searchParams.append("archived", `${archived}`);
|
|
1532
1628
|
}
|
|
1533
|
-
return chunk7B52C2XE_js.__privateGet(this, _httpClient).
|
|
1629
|
+
return chunk7B52C2XE_js.__privateGet(this, _httpClient).get(INBOX_NOTIFICATIONS_ROUTE, searchParams, false);
|
|
1534
1630
|
}
|
|
1535
1631
|
count({ filters }) {
|
|
1536
|
-
return chunk7B52C2XE_js.__privateGet(this, _httpClient).
|
|
1632
|
+
return chunk7B52C2XE_js.__privateGet(this, _httpClient).get(
|
|
1633
|
+
`${INBOX_NOTIFICATIONS_ROUTE}/count`,
|
|
1634
|
+
new URLSearchParams({
|
|
1635
|
+
filters: JSON.stringify(filters)
|
|
1636
|
+
}),
|
|
1637
|
+
false
|
|
1638
|
+
);
|
|
1537
1639
|
}
|
|
1538
1640
|
read(notificationId) {
|
|
1539
1641
|
return chunk7B52C2XE_js.__privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/read`);
|
|
@@ -1593,9 +1695,6 @@ var InboxService = class {
|
|
|
1593
1695
|
_httpClient = new WeakMap();
|
|
1594
1696
|
|
|
1595
1697
|
// src/novu.ts
|
|
1596
|
-
var version = "2.6.3";
|
|
1597
|
-
var name = "@novu/js";
|
|
1598
|
-
var userAgent = `${name}@${version}`;
|
|
1599
1698
|
var _emitter7, _session, _socket, _inboxService3;
|
|
1600
1699
|
var Novu = class {
|
|
1601
1700
|
constructor(options) {
|
|
@@ -1603,10 +1702,10 @@ var Novu = class {
|
|
|
1603
1702
|
chunk7B52C2XE_js.__privateAdd(this, _session);
|
|
1604
1703
|
chunk7B52C2XE_js.__privateAdd(this, _socket);
|
|
1605
1704
|
chunk7B52C2XE_js.__privateAdd(this, _inboxService3);
|
|
1606
|
-
var _a, _b, _c
|
|
1705
|
+
var _a, _b, _c;
|
|
1607
1706
|
chunk7B52C2XE_js.__privateSet(this, _inboxService3, new InboxService({
|
|
1608
1707
|
backendUrl: (_a = options.backendUrl) != null ? _a : PRODUCTION_BACKEND_URL,
|
|
1609
|
-
userAgent:
|
|
1708
|
+
userAgent: options.__userAgent
|
|
1610
1709
|
}));
|
|
1611
1710
|
chunk7B52C2XE_js.__privateSet(this, _emitter7, new NovuEventEmitter());
|
|
1612
1711
|
chunk7B52C2XE_js.__privateSet(this, _session, new Session(
|
|
@@ -1620,12 +1719,12 @@ var Novu = class {
|
|
|
1620
1719
|
));
|
|
1621
1720
|
chunk7B52C2XE_js.__privateGet(this, _session).initialize();
|
|
1622
1721
|
this.notifications = new Notifications({
|
|
1623
|
-
useCache: (
|
|
1722
|
+
useCache: (_b = options.useCache) != null ? _b : true,
|
|
1624
1723
|
inboxServiceInstance: chunk7B52C2XE_js.__privateGet(this, _inboxService3),
|
|
1625
1724
|
eventEmitterInstance: chunk7B52C2XE_js.__privateGet(this, _emitter7)
|
|
1626
1725
|
});
|
|
1627
1726
|
this.preferences = new Preferences({
|
|
1628
|
-
useCache: (
|
|
1727
|
+
useCache: (_c = options.useCache) != null ? _c : true,
|
|
1629
1728
|
inboxServiceInstance: chunk7B52C2XE_js.__privateGet(this, _inboxService3),
|
|
1630
1729
|
eventEmitterInstance: chunk7B52C2XE_js.__privateGet(this, _emitter7)
|
|
1631
1730
|
});
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { N as NotificationFilter } from './novu-
|
|
2
|
-
export { k as Action, A as ActionTypeEnum, m as ChannelPreference, f as ChannelType, C as CtaType, E as EventHandler, a as Events, F as FiltersCountResponse, q as IPreferenceOverride, I as InboxNotification, L as ListNotificationsResponse, i as MessageAction, M as MessageButton, t as Notification, e as NotificationActionStatus, d as NotificationButton, c as NotificationStatus, b as Novu, v as NovuError, s as NovuOptions, n as PaginatedResponse, u as Preference, P as PreferenceLevel, g as PreferenceOverrideSource, p as PreferenceOverrideSourceEnum, o as PreferencesResponse, R as Redirect, r as Result, h as Session, S as SocketEventNames, j as Subscriber, T as TODO, W as WebSocketEvent, l as Workflow } from './novu-
|
|
3
|
-
import '@novu/client';
|
|
1
|
+
import { N as NotificationFilter } from './novu-CTwfWx9z.js';
|
|
2
|
+
export { k as Action, A as ActionTypeEnum, m as ChannelPreference, f as ChannelType, C as CtaType, E as EventHandler, a as Events, F as FiltersCountResponse, q as IPreferenceOverride, I as InboxNotification, L as ListNotificationsResponse, i as MessageAction, M as MessageButton, t as Notification, e as NotificationActionStatus, d as NotificationButton, c as NotificationStatus, b as Novu, v as NovuError, s as NovuOptions, n as PaginatedResponse, u as Preference, P as PreferenceLevel, g as PreferenceOverrideSource, p as PreferenceOverrideSourceEnum, o as PreferencesResponse, R as Redirect, r as Result, h as Session, S as SocketEventNames, j as Subscriber, T as TODO, W as WebSocketEvent, l as Workflow } from './novu-CTwfWx9z.js';
|
|
4
3
|
|
|
5
4
|
declare const areTagsEqual: (tags1?: string[], tags2?: string[]) => boolean;
|
|
6
5
|
declare const isSameFilter: (filter1: NotificationFilter, filter2: NotificationFilter) => boolean;
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkNCIKS5DU_js = require('./chunk-NCIKS5DU.js');
|
|
4
4
|
require('./chunk-7B52C2XE.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, "ActionTypeEnum", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunkNCIKS5DU_js.ActionTypeEnum; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "ChannelType", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkNCIKS5DU_js.ChannelType; }
|
|
15
15
|
});
|
|
16
16
|
Object.defineProperty(exports, "CtaType", {
|
|
17
17
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunkNCIKS5DU_js.CtaType; }
|
|
19
19
|
});
|
|
20
20
|
Object.defineProperty(exports, "NotificationActionStatus", {
|
|
21
21
|
enumerable: true,
|
|
22
|
-
get: function () { return
|
|
22
|
+
get: function () { return chunkNCIKS5DU_js.NotificationActionStatus; }
|
|
23
23
|
});
|
|
24
24
|
Object.defineProperty(exports, "NotificationButton", {
|
|
25
25
|
enumerable: true,
|
|
26
|
-
get: function () { return
|
|
26
|
+
get: function () { return chunkNCIKS5DU_js.NotificationButton; }
|
|
27
27
|
});
|
|
28
28
|
Object.defineProperty(exports, "NotificationStatus", {
|
|
29
29
|
enumerable: true,
|
|
30
|
-
get: function () { return
|
|
30
|
+
get: function () { return chunkNCIKS5DU_js.NotificationStatus; }
|
|
31
31
|
});
|
|
32
32
|
Object.defineProperty(exports, "Novu", {
|
|
33
33
|
enumerable: true,
|
|
34
|
-
get: function () { return
|
|
34
|
+
get: function () { return chunkNCIKS5DU_js.Novu; }
|
|
35
35
|
});
|
|
36
36
|
Object.defineProperty(exports, "PreferenceLevel", {
|
|
37
37
|
enumerable: true,
|
|
38
|
-
get: function () { return
|
|
38
|
+
get: function () { return chunkNCIKS5DU_js.PreferenceLevel; }
|
|
39
39
|
});
|
|
40
40
|
Object.defineProperty(exports, "PreferenceOverrideSource", {
|
|
41
41
|
enumerable: true,
|
|
42
|
-
get: function () { return
|
|
42
|
+
get: function () { return chunkNCIKS5DU_js.PreferenceOverrideSource; }
|
|
43
43
|
});
|
|
44
44
|
Object.defineProperty(exports, "PreferenceOverrideSourceEnum", {
|
|
45
45
|
enumerable: true,
|
|
46
|
-
get: function () { return
|
|
46
|
+
get: function () { return chunkNCIKS5DU_js.PreferenceOverrideSourceEnum; }
|
|
47
47
|
});
|
|
48
48
|
Object.defineProperty(exports, "WebSocketEvent", {
|
|
49
49
|
enumerable: true,
|
|
50
|
-
get: function () { return
|
|
50
|
+
get: function () { return chunkNCIKS5DU_js.WebSocketEvent; }
|
|
51
51
|
});
|
|
52
52
|
Object.defineProperty(exports, "areTagsEqual", {
|
|
53
53
|
enumerable: true,
|
|
54
|
-
get: function () { return
|
|
54
|
+
get: function () { return chunkNCIKS5DU_js.areTagsEqual; }
|
|
55
55
|
});
|
|
56
56
|
Object.defineProperty(exports, "isSameFilter", {
|
|
57
57
|
enumerable: true,
|
|
58
|
-
get: function () { return
|
|
58
|
+
get: function () { return chunkNCIKS5DU_js.isSameFilter; }
|
|
59
59
|
});
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { ApiOptions } from '@novu/client';
|
|
2
|
-
|
|
3
1
|
declare class NovuError extends Error {
|
|
4
2
|
originalError: Error;
|
|
5
3
|
constructor(message: string, originalError: unknown);
|
|
@@ -204,7 +202,13 @@ type NovuOptions = {
|
|
|
204
202
|
__userAgent?: string;
|
|
205
203
|
};
|
|
206
204
|
|
|
207
|
-
type
|
|
205
|
+
type HttpClientOptions = {
|
|
206
|
+
apiVersion?: string;
|
|
207
|
+
backendUrl?: string;
|
|
208
|
+
userAgent?: string;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
type InboxServiceOptions = HttpClientOptions;
|
|
208
212
|
declare class InboxService {
|
|
209
213
|
#private;
|
|
210
214
|
isSessionInitialized: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as Notification, N as NotificationFilter, s as NovuOptions, b as Novu } from './novu-
|
|
1
|
+
import { t as Notification, N as NotificationFilter, s as NovuOptions, b as Novu } from './novu-CTwfWx9z.js';
|
|
2
2
|
|
|
3
3
|
declare const defaultLocalization: {
|
|
4
4
|
readonly locale: "en-US";
|
package/dist/cjs/ui/index.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { s as NovuOptions } from '../novu-
|
|
2
|
-
export { t as Notification } from '../novu-
|
|
3
|
-
import { N as NotificationRenderer, B as BellRenderer, a as NotificationClickHandler, b as NotificationActionClickHandler, c as NovuProviderProps, d as BaseNovuProviderProps, A as Appearance, L as Localization, T as Tab, P as PreferencesFilter, R as RouterPush } from '../types-
|
|
4
|
-
export { e as AppearanceKey, C as CSSProperties, E as ElementStyles, f as Elements, i as LocalizationKey, h as NotificationStatus, g as Theme, V as Variables } from '../types-
|
|
1
|
+
import { s as NovuOptions } from '../novu-CTwfWx9z.js';
|
|
2
|
+
export { t as Notification } from '../novu-CTwfWx9z.js';
|
|
3
|
+
import { N as NotificationRenderer, B as BellRenderer, a as NotificationClickHandler, b as NotificationActionClickHandler, c as NovuProviderProps, d as BaseNovuProviderProps, A as Appearance, L as Localization, T as Tab, P as PreferencesFilter, R as RouterPush } from '../types-C9Kspo68.js';
|
|
4
|
+
export { e as AppearanceKey, C as CSSProperties, E as ElementStyles, f as Elements, i as LocalizationKey, h as NotificationStatus, g as Theme, V as Variables } from '../types-C9Kspo68.js';
|
|
5
5
|
import { Placement, OffsetOptions } from '@floating-ui/dom';
|
|
6
6
|
import * as solid_js from 'solid-js';
|
|
7
7
|
import { ComponentProps } from 'solid-js';
|
|
8
8
|
import { MountableElement } from 'solid-js/web';
|
|
9
|
-
import '@novu/client';
|
|
10
9
|
|
|
11
10
|
type InboxProps = {
|
|
12
11
|
open?: boolean;
|
package/dist/cjs/ui/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkNCIKS5DU_js = require('../chunk-NCIKS5DU.js');
|
|
4
4
|
var chunkERC62PGI_js = require('../chunk-ERC62PGI.js');
|
|
5
5
|
var chunk7B52C2XE_js = require('../chunk-7B52C2XE.js');
|
|
6
6
|
var web = require('solid-js/web');
|
|
@@ -754,7 +754,7 @@ var useInboxContext = () => {
|
|
|
754
754
|
};
|
|
755
755
|
var NovuContext = solidJs.createContext(void 0);
|
|
756
756
|
function NovuProvider(props) {
|
|
757
|
-
const novu = solidJs.createMemo(() => props.novu || new
|
|
757
|
+
const novu = solidJs.createMemo(() => props.novu || new chunkNCIKS5DU_js.Novu(props.options));
|
|
758
758
|
return web.createComponent(NovuContext.Provider, {
|
|
759
759
|
get value() {
|
|
760
760
|
return novu();
|
|
@@ -2013,7 +2013,7 @@ var useNotificationsInfiniteScroll = (props) => {
|
|
|
2013
2013
|
}));
|
|
2014
2014
|
solidJs.onMount(() => {
|
|
2015
2015
|
const listener = ({ data: data2 }) => {
|
|
2016
|
-
if (!data2 || !
|
|
2016
|
+
if (!data2 || !chunkNCIKS5DU_js.isSameFilter(filter, data2.filter)) {
|
|
2017
2017
|
return;
|
|
2018
2018
|
}
|
|
2019
2019
|
mutate({ data: data2.notifications, hasMore: data2.hasMore });
|
|
@@ -2023,7 +2023,7 @@ var useNotificationsInfiniteScroll = (props) => {
|
|
|
2023
2023
|
});
|
|
2024
2024
|
solidJs.createEffect(() => {
|
|
2025
2025
|
const newFilter = chunk7B52C2XE_js.__spreadValues({}, props.options());
|
|
2026
|
-
if (
|
|
2026
|
+
if (chunkNCIKS5DU_js.isSameFilter(filter, newFilter)) {
|
|
2027
2027
|
return;
|
|
2028
2028
|
}
|
|
2029
2029
|
novu.notifications.clearCache();
|
|
@@ -3522,6 +3522,9 @@ var InboxDropdownTab = (props) => {
|
|
|
3522
3522
|
get ["class"]() {
|
|
3523
3523
|
return style("moreTabs__dropdownItem", cn(dropdownItemVariants(), "nt-flex nt-justify-between nt-gap-2"));
|
|
3524
3524
|
},
|
|
3525
|
+
get onClick() {
|
|
3526
|
+
return props.onClick;
|
|
3527
|
+
},
|
|
3525
3528
|
get children() {
|
|
3526
3529
|
return [(() => {
|
|
3527
3530
|
var _el$3 = _tmpl$48();
|
|
@@ -3999,7 +4002,7 @@ var Renderer = (props) => {
|
|
|
3999
4002
|
}
|
|
4000
4003
|
});
|
|
4001
4004
|
};
|
|
4002
|
-
var version = "2.6.
|
|
4005
|
+
var version = "2.6.4";
|
|
4003
4006
|
var cssHref = `https://cdn.jsdelivr.net/npm/@novu/js@${version}/dist/index.css`;
|
|
4004
4007
|
var _dispose, _rootElement, _mountedElements, _setMountedElements, _appearance, _setAppearance, _localization, _setLocalization, _options, _setOptions, _tabs, _setTabs, _routerPush, _setRouterPush, _preferencesFilter, _setPreferencesFilter, _predefinedNovu, _NovuUI_instances, mountComponentRenderer_fn, updateComponentProps_fn;
|
|
4005
4008
|
var NovuUI = class {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { __privateAdd, __privateSet, __privateGet, __async, __objRest, __spreadValues, __privateMethod, __spreadProps } from './chunk-STZMOEWR.mjs';
|
|
2
2
|
import mitt from 'mitt';
|
|
3
3
|
import io from 'socket.io-client';
|
|
4
|
-
import { HttpClient } from '@novu/client';
|
|
5
4
|
|
|
6
5
|
// src/types.ts
|
|
7
6
|
var NotificationStatus = /* @__PURE__ */ ((NotificationStatus2) => {
|
|
@@ -1469,7 +1468,108 @@ initializeSocket_fn = function() {
|
|
|
1469
1468
|
|
|
1470
1469
|
// src/utils/config.ts
|
|
1471
1470
|
var PRODUCTION_BACKEND_URL = "https://api.novu.co";
|
|
1472
|
-
|
|
1471
|
+
|
|
1472
|
+
// src/api/http-client.ts
|
|
1473
|
+
var DEFAULT_API_VERSION = "v1";
|
|
1474
|
+
var DEFAULT_BACKEND_URL = "https://api.novu.co";
|
|
1475
|
+
var DEFAULT_USER_AGENT = `${"@novu/js"}@${"2.6.4"}`;
|
|
1476
|
+
var HttpClient = class {
|
|
1477
|
+
constructor(options = {}) {
|
|
1478
|
+
const {
|
|
1479
|
+
apiVersion = DEFAULT_API_VERSION,
|
|
1480
|
+
backendUrl = DEFAULT_BACKEND_URL,
|
|
1481
|
+
userAgent = DEFAULT_USER_AGENT
|
|
1482
|
+
} = options || {};
|
|
1483
|
+
this.apiVersion = apiVersion;
|
|
1484
|
+
this.backendUrl = `${backendUrl}/${this.apiVersion}`;
|
|
1485
|
+
this.headers = {
|
|
1486
|
+
"Novu-API-Version": "2024-06-26",
|
|
1487
|
+
"Content-Type": "application/json",
|
|
1488
|
+
"User-Agent": userAgent
|
|
1489
|
+
};
|
|
1490
|
+
}
|
|
1491
|
+
setAuthorizationToken(token) {
|
|
1492
|
+
this.headers.Authorization = `Bearer ${token}`;
|
|
1493
|
+
}
|
|
1494
|
+
setHeaders(headers) {
|
|
1495
|
+
this.headers = __spreadValues(__spreadValues({}, this.headers), headers);
|
|
1496
|
+
}
|
|
1497
|
+
get(path, searchParams, unwrapEnvelope = true) {
|
|
1498
|
+
return __async(this, null, function* () {
|
|
1499
|
+
return this.doFetch({
|
|
1500
|
+
path,
|
|
1501
|
+
searchParams,
|
|
1502
|
+
options: {
|
|
1503
|
+
method: "GET"
|
|
1504
|
+
},
|
|
1505
|
+
unwrapEnvelope
|
|
1506
|
+
});
|
|
1507
|
+
});
|
|
1508
|
+
}
|
|
1509
|
+
post(path, body) {
|
|
1510
|
+
return __async(this, null, function* () {
|
|
1511
|
+
return this.doFetch({
|
|
1512
|
+
path,
|
|
1513
|
+
options: {
|
|
1514
|
+
method: "POST",
|
|
1515
|
+
body
|
|
1516
|
+
}
|
|
1517
|
+
});
|
|
1518
|
+
});
|
|
1519
|
+
}
|
|
1520
|
+
patch(path, body) {
|
|
1521
|
+
return __async(this, null, function* () {
|
|
1522
|
+
return this.doFetch({
|
|
1523
|
+
path,
|
|
1524
|
+
options: {
|
|
1525
|
+
method: "PATCH",
|
|
1526
|
+
body
|
|
1527
|
+
}
|
|
1528
|
+
});
|
|
1529
|
+
});
|
|
1530
|
+
}
|
|
1531
|
+
delete(path, body) {
|
|
1532
|
+
return __async(this, null, function* () {
|
|
1533
|
+
return this.doFetch({
|
|
1534
|
+
path,
|
|
1535
|
+
options: {
|
|
1536
|
+
method: "DELETE",
|
|
1537
|
+
body
|
|
1538
|
+
}
|
|
1539
|
+
});
|
|
1540
|
+
});
|
|
1541
|
+
}
|
|
1542
|
+
doFetch(_0) {
|
|
1543
|
+
return __async(this, arguments, function* ({
|
|
1544
|
+
path,
|
|
1545
|
+
searchParams,
|
|
1546
|
+
options,
|
|
1547
|
+
unwrapEnvelope = true
|
|
1548
|
+
}) {
|
|
1549
|
+
const fullUrl = combineUrl(this.backendUrl, path, searchParams ? `?${searchParams.toString()}` : "");
|
|
1550
|
+
const reqInit = {
|
|
1551
|
+
method: (options == null ? void 0 : options.method) || "GET",
|
|
1552
|
+
headers: __spreadValues(__spreadValues({}, this.headers), (options == null ? void 0 : options.headers) || {}),
|
|
1553
|
+
body: (options == null ? void 0 : options.body) ? JSON.stringify(options.body) : void 0
|
|
1554
|
+
};
|
|
1555
|
+
const response = yield fetch(fullUrl, reqInit);
|
|
1556
|
+
if (!response.ok) {
|
|
1557
|
+
const errorData = yield response.json();
|
|
1558
|
+
throw new Error(`${this.headers["User-Agent"]} error. Status: ${response.status}, Message: ${errorData.message}`);
|
|
1559
|
+
}
|
|
1560
|
+
if (response.status === 204) {
|
|
1561
|
+
return void 0;
|
|
1562
|
+
}
|
|
1563
|
+
const res = yield response.json();
|
|
1564
|
+
return unwrapEnvelope ? res.data : res;
|
|
1565
|
+
});
|
|
1566
|
+
}
|
|
1567
|
+
};
|
|
1568
|
+
function combineUrl(...args) {
|
|
1569
|
+
return args.map((part) => part.replace(/^\/+|\/+$/g, "")).join("/");
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1572
|
+
// src/api/inbox-service.ts
|
|
1473
1573
|
var INBOX_ROUTE = "/inbox";
|
|
1474
1574
|
var INBOX_NOTIFICATIONS_ROUTE = `${INBOX_ROUTE}/notifications`;
|
|
1475
1575
|
var _httpClient;
|
|
@@ -1478,10 +1578,6 @@ var InboxService = class {
|
|
|
1478
1578
|
this.isSessionInitialized = false;
|
|
1479
1579
|
__privateAdd(this, _httpClient);
|
|
1480
1580
|
__privateSet(this, _httpClient, new HttpClient(options));
|
|
1481
|
-
__privateGet(this, _httpClient).updateHeaders({
|
|
1482
|
-
"Novu-API-Version": NOVU_API_VERSION,
|
|
1483
|
-
"Novu-User-Agent": options.userAgent || "@novu/js"
|
|
1484
|
-
});
|
|
1485
1581
|
}
|
|
1486
1582
|
initializeSession(_0) {
|
|
1487
1583
|
return __async(this, arguments, function* ({
|
|
@@ -1507,26 +1603,32 @@ var InboxService = class {
|
|
|
1507
1603
|
read: read2,
|
|
1508
1604
|
tags
|
|
1509
1605
|
}) {
|
|
1510
|
-
const
|
|
1606
|
+
const searchParams = new URLSearchParams(`limit=${limit}`);
|
|
1511
1607
|
if (after) {
|
|
1512
|
-
|
|
1608
|
+
searchParams.append("after", after);
|
|
1513
1609
|
}
|
|
1514
1610
|
if (offset) {
|
|
1515
|
-
|
|
1611
|
+
searchParams.append("offset", `${offset}`);
|
|
1516
1612
|
}
|
|
1517
1613
|
if (tags) {
|
|
1518
|
-
tags.forEach((tag) =>
|
|
1614
|
+
tags.forEach((tag) => searchParams.append("tags[]", tag));
|
|
1519
1615
|
}
|
|
1520
1616
|
if (read2 !== void 0) {
|
|
1521
|
-
|
|
1617
|
+
searchParams.append("read", `${read2}`);
|
|
1522
1618
|
}
|
|
1523
1619
|
if (archived !== void 0) {
|
|
1524
|
-
|
|
1620
|
+
searchParams.append("archived", `${archived}`);
|
|
1525
1621
|
}
|
|
1526
|
-
return __privateGet(this, _httpClient).
|
|
1622
|
+
return __privateGet(this, _httpClient).get(INBOX_NOTIFICATIONS_ROUTE, searchParams, false);
|
|
1527
1623
|
}
|
|
1528
1624
|
count({ filters }) {
|
|
1529
|
-
return __privateGet(this, _httpClient).
|
|
1625
|
+
return __privateGet(this, _httpClient).get(
|
|
1626
|
+
`${INBOX_NOTIFICATIONS_ROUTE}/count`,
|
|
1627
|
+
new URLSearchParams({
|
|
1628
|
+
filters: JSON.stringify(filters)
|
|
1629
|
+
}),
|
|
1630
|
+
false
|
|
1631
|
+
);
|
|
1530
1632
|
}
|
|
1531
1633
|
read(notificationId) {
|
|
1532
1634
|
return __privateGet(this, _httpClient).patch(`${INBOX_NOTIFICATIONS_ROUTE}/${notificationId}/read`);
|
|
@@ -1586,9 +1688,6 @@ var InboxService = class {
|
|
|
1586
1688
|
_httpClient = new WeakMap();
|
|
1587
1689
|
|
|
1588
1690
|
// src/novu.ts
|
|
1589
|
-
var version = "2.6.3";
|
|
1590
|
-
var name = "@novu/js";
|
|
1591
|
-
var userAgent = `${name}@${version}`;
|
|
1592
1691
|
var _emitter7, _session, _socket, _inboxService3;
|
|
1593
1692
|
var Novu = class {
|
|
1594
1693
|
constructor(options) {
|
|
@@ -1596,10 +1695,10 @@ var Novu = class {
|
|
|
1596
1695
|
__privateAdd(this, _session);
|
|
1597
1696
|
__privateAdd(this, _socket);
|
|
1598
1697
|
__privateAdd(this, _inboxService3);
|
|
1599
|
-
var _a, _b, _c
|
|
1698
|
+
var _a, _b, _c;
|
|
1600
1699
|
__privateSet(this, _inboxService3, new InboxService({
|
|
1601
1700
|
backendUrl: (_a = options.backendUrl) != null ? _a : PRODUCTION_BACKEND_URL,
|
|
1602
|
-
userAgent:
|
|
1701
|
+
userAgent: options.__userAgent
|
|
1603
1702
|
}));
|
|
1604
1703
|
__privateSet(this, _emitter7, new NovuEventEmitter());
|
|
1605
1704
|
__privateSet(this, _session, new Session(
|
|
@@ -1613,12 +1712,12 @@ var Novu = class {
|
|
|
1613
1712
|
));
|
|
1614
1713
|
__privateGet(this, _session).initialize();
|
|
1615
1714
|
this.notifications = new Notifications({
|
|
1616
|
-
useCache: (
|
|
1715
|
+
useCache: (_b = options.useCache) != null ? _b : true,
|
|
1617
1716
|
inboxServiceInstance: __privateGet(this, _inboxService3),
|
|
1618
1717
|
eventEmitterInstance: __privateGet(this, _emitter7)
|
|
1619
1718
|
});
|
|
1620
1719
|
this.preferences = new Preferences({
|
|
1621
|
-
useCache: (
|
|
1720
|
+
useCache: (_c = options.useCache) != null ? _c : true,
|
|
1622
1721
|
inboxServiceInstance: __privateGet(this, _inboxService3),
|
|
1623
1722
|
eventEmitterInstance: __privateGet(this, _emitter7)
|
|
1624
1723
|
});
|
package/dist/esm/index.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { N as NotificationFilter } from './novu-
|
|
2
|
-
export { k as Action, A as ActionTypeEnum, m as ChannelPreference, f as ChannelType, C as CtaType, E as EventHandler, a as Events, F as FiltersCountResponse, q as IPreferenceOverride, I as InboxNotification, L as ListNotificationsResponse, i as MessageAction, M as MessageButton, t as Notification, e as NotificationActionStatus, d as NotificationButton, c as NotificationStatus, b as Novu, v as NovuError, s as NovuOptions, n as PaginatedResponse, u as Preference, P as PreferenceLevel, g as PreferenceOverrideSource, p as PreferenceOverrideSourceEnum, o as PreferencesResponse, R as Redirect, r as Result, h as Session, S as SocketEventNames, j as Subscriber, T as TODO, W as WebSocketEvent, l as Workflow } from './novu-
|
|
3
|
-
import '@novu/client';
|
|
1
|
+
import { N as NotificationFilter } from './novu-CTwfWx9z.mjs';
|
|
2
|
+
export { k as Action, A as ActionTypeEnum, m as ChannelPreference, f as ChannelType, C as CtaType, E as EventHandler, a as Events, F as FiltersCountResponse, q as IPreferenceOverride, I as InboxNotification, L as ListNotificationsResponse, i as MessageAction, M as MessageButton, t as Notification, e as NotificationActionStatus, d as NotificationButton, c as NotificationStatus, b as Novu, v as NovuError, s as NovuOptions, n as PaginatedResponse, u as Preference, P as PreferenceLevel, g as PreferenceOverrideSource, p as PreferenceOverrideSourceEnum, o as PreferencesResponse, R as Redirect, r as Result, h as Session, S as SocketEventNames, j as Subscriber, T as TODO, W as WebSocketEvent, l as Workflow } from './novu-CTwfWx9z.mjs';
|
|
4
3
|
|
|
5
4
|
declare const areTagsEqual: (tags1?: string[], tags2?: string[]) => boolean;
|
|
6
5
|
declare const isSameFilter: (filter1: NotificationFilter, filter2: NotificationFilter) => boolean;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { ActionTypeEnum, ChannelType, CtaType, NotificationActionStatus, NotificationButton, NotificationStatus, Novu, PreferenceLevel, PreferenceOverrideSource, PreferenceOverrideSourceEnum, WebSocketEvent, areTagsEqual, isSameFilter } from './chunk-
|
|
1
|
+
export { ActionTypeEnum, ChannelType, CtaType, NotificationActionStatus, NotificationButton, NotificationStatus, Novu, PreferenceLevel, PreferenceOverrideSource, PreferenceOverrideSourceEnum, WebSocketEvent, areTagsEqual, isSameFilter } from './chunk-OMRGYSBS.mjs';
|
|
2
2
|
import './chunk-STZMOEWR.mjs';
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { ApiOptions } from '@novu/client';
|
|
2
|
-
|
|
3
1
|
declare class NovuError extends Error {
|
|
4
2
|
originalError: Error;
|
|
5
3
|
constructor(message: string, originalError: unknown);
|
|
@@ -204,7 +202,13 @@ type NovuOptions = {
|
|
|
204
202
|
__userAgent?: string;
|
|
205
203
|
};
|
|
206
204
|
|
|
207
|
-
type
|
|
205
|
+
type HttpClientOptions = {
|
|
206
|
+
apiVersion?: string;
|
|
207
|
+
backendUrl?: string;
|
|
208
|
+
userAgent?: string;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
type InboxServiceOptions = HttpClientOptions;
|
|
208
212
|
declare class InboxService {
|
|
209
213
|
#private;
|
|
210
214
|
isSessionInitialized: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as Notification, N as NotificationFilter, s as NovuOptions, b as Novu } from './novu-
|
|
1
|
+
import { t as Notification, N as NotificationFilter, s as NovuOptions, b as Novu } from './novu-CTwfWx9z.mjs';
|
|
2
2
|
|
|
3
3
|
declare const defaultLocalization: {
|
|
4
4
|
readonly locale: "en-US";
|