@novu/js 3.15.0 → 3.16.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/{chunk-C23LCEUU.js → chunk-6I5A5OGE.js} +393 -50
- package/dist/{esm/novu-event-emitter-D9AphR7g.d.mts → cjs/inbox-service-CEMMLHsX.d.ts} +715 -611
- package/dist/cjs/index.d.ts +3 -3
- package/dist/cjs/index.js +18 -18
- package/dist/cjs/internal/index.d.ts +1 -1
- package/dist/cjs/internal/index.js +6 -6
- package/dist/{esm/novu-DTGsXJjv.d.mts → cjs/novu-ChPiHuXt.d.ts} +27 -1
- package/dist/cjs/themes/index.d.ts +3 -3
- package/dist/cjs/{types-DXbz7pFA.d.ts → types-CPxEgcM4.d.ts} +52 -7
- package/dist/cjs/ui/index.d.ts +52 -6
- package/dist/cjs/ui/index.js +6574 -5632
- package/dist/esm/{chunk-DXONCY42.mjs → chunk-FBE56J52.mjs} +345 -2
- package/dist/{cjs/novu-event-emitter-D9AphR7g.d.ts → esm/inbox-service-CEMMLHsX.d.mts} +715 -611
- package/dist/esm/index.d.mts +3 -3
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/internal/index.d.mts +1 -1
- package/dist/esm/internal/index.mjs +1 -1
- package/dist/{cjs/novu-CI_mzxvm.d.ts → esm/novu-BlonRpYH.d.mts} +27 -1
- package/dist/esm/themes/index.d.mts +3 -3
- package/dist/esm/{types-zMKIpsOL.d.mts → types-B29Y1SQy.d.mts} +52 -7
- package/dist/esm/ui/index.d.mts +52 -6
- package/dist/esm/ui/index.mjs +6573 -5631
- package/dist/index.css +1 -1
- package/dist/novu.min.js +16 -16
- package/dist/novu.min.js.gz +0 -0
- package/package.json +1 -1
- /package/dist/cjs/{chunk-YPTYVCVE.js → chunk-WDGG3OER.js} +0 -0
- /package/dist/esm/{chunk-3WBJEI4O.mjs → chunk-4S22IB5W.mjs} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NovuError, buildSubscriber, buildContextKey, Notification, read, unread, seen, archive, unarchive, deleteNotification, snooze, unsnooze, completeAction, revertAction, readAll, seenAll, archiveAll, archiveAllRead, deleteAll, buildSubscriptionIdentifier, createNotification } from './chunk-
|
|
1
|
+
import { NovuError, buildSubscriber, buildContextKey, Notification, read, unread, seen, archive, unarchive, deleteNotification, snooze, unsnooze, completeAction, revertAction, readAll, seenAll, archiveAll, archiveAllRead, deleteAll, buildSubscriptionIdentifier, createNotification } from './chunk-4S22IB5W.mjs';
|
|
2
2
|
import { __privateAdd, __privateSet, __spreadValues, __privateGet, __async, __spreadProps, __objRest, __privateMethod } from './chunk-STZMOEWR.mjs';
|
|
3
3
|
import mitt from 'mitt';
|
|
4
4
|
import 'event-target-polyfill';
|
|
@@ -1036,7 +1036,7 @@ _contextKey = new WeakMap();
|
|
|
1036
1036
|
|
|
1037
1037
|
// src/api/http-client.ts
|
|
1038
1038
|
var DEFAULT_API_VERSION = "v1";
|
|
1039
|
-
var DEFAULT_CLIENT_VERSION = `${"@novu/js"}@${"3.
|
|
1039
|
+
var DEFAULT_CLIENT_VERSION = `${"@novu/js"}@${"3.16.0"}`;
|
|
1040
1040
|
var HttpClient = class {
|
|
1041
1041
|
constructor(options = {}) {
|
|
1042
1042
|
// Environment variable for local development that overrides the default API endpoint without affecting the Inbox DX
|
|
@@ -1150,6 +1150,30 @@ function combineUrl(...args) {
|
|
|
1150
1150
|
// src/api/inbox-service.ts
|
|
1151
1151
|
var INBOX_ROUTE = "/inbox";
|
|
1152
1152
|
var INBOX_NOTIFICATIONS_ROUTE = `${INBOX_ROUTE}/notifications`;
|
|
1153
|
+
var CHAT_OAUTH_ROUTE = `${INBOX_ROUTE}/chat/oauth`;
|
|
1154
|
+
var CHANNEL_CONNECTIONS_ROUTE = `${INBOX_ROUTE}/channel-connections`;
|
|
1155
|
+
var CHANNEL_ENDPOINTS_ROUTE = `${INBOX_ROUTE}/channel-endpoints`;
|
|
1156
|
+
function buildChannelListSearchParams(args) {
|
|
1157
|
+
const searchParams = new URLSearchParams();
|
|
1158
|
+
if (args.subscriberId) searchParams.append("subscriberId", args.subscriberId);
|
|
1159
|
+
if (args.integrationIdentifier) searchParams.append("integrationIdentifier", args.integrationIdentifier);
|
|
1160
|
+
if (args.connectionIdentifier) searchParams.append("connectionIdentifier", args.connectionIdentifier);
|
|
1161
|
+
if (args.channel) searchParams.append("channel", args.channel);
|
|
1162
|
+
if (args.providerId) searchParams.append("providerId", args.providerId);
|
|
1163
|
+
if (args.contextKeys !== void 0) {
|
|
1164
|
+
if (args.contextKeys.length === 0) {
|
|
1165
|
+
searchParams.append("contextKeys", "");
|
|
1166
|
+
} else {
|
|
1167
|
+
for (const key of args.contextKeys) {
|
|
1168
|
+
searchParams.append("contextKeys", key);
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
if (args.limit) searchParams.append("limit", String(args.limit));
|
|
1173
|
+
if (args.after) searchParams.append("after", args.after);
|
|
1174
|
+
if (args.before) searchParams.append("before", args.before);
|
|
1175
|
+
return searchParams.size ? `?${searchParams.toString()}` : "";
|
|
1176
|
+
}
|
|
1153
1177
|
function appendTagsToSearchParams(searchParams, tags) {
|
|
1154
1178
|
if (tags === void 0) {
|
|
1155
1179
|
return;
|
|
@@ -1467,8 +1491,319 @@ var InboxService = class {
|
|
|
1467
1491
|
deleteSubscription({ topicKey, identifier }) {
|
|
1468
1492
|
return __privateGet(this, _httpClient).delete(`${INBOX_ROUTE}/topics/${topicKey}/subscriptions/${identifier}`);
|
|
1469
1493
|
}
|
|
1494
|
+
generateChatOAuthUrl({
|
|
1495
|
+
integrationIdentifier,
|
|
1496
|
+
connectionIdentifier,
|
|
1497
|
+
subscriberId,
|
|
1498
|
+
context,
|
|
1499
|
+
scope,
|
|
1500
|
+
userScope,
|
|
1501
|
+
mode,
|
|
1502
|
+
connectionMode
|
|
1503
|
+
}) {
|
|
1504
|
+
return __privateGet(this, _httpClient).post(CHAT_OAUTH_ROUTE, {
|
|
1505
|
+
integrationIdentifier,
|
|
1506
|
+
connectionIdentifier,
|
|
1507
|
+
subscriberId,
|
|
1508
|
+
context,
|
|
1509
|
+
scope,
|
|
1510
|
+
userScope,
|
|
1511
|
+
mode,
|
|
1512
|
+
connectionMode
|
|
1513
|
+
});
|
|
1514
|
+
}
|
|
1515
|
+
listChannelConnections(args = {}) {
|
|
1516
|
+
const query = buildChannelListSearchParams(args);
|
|
1517
|
+
return __privateGet(this, _httpClient).get(`${CHANNEL_CONNECTIONS_ROUTE}${query}`, void 0, false);
|
|
1518
|
+
}
|
|
1519
|
+
getChannelConnection(identifier) {
|
|
1520
|
+
return __privateGet(this, _httpClient).get(`${CHANNEL_CONNECTIONS_ROUTE}/${identifier}`);
|
|
1521
|
+
}
|
|
1522
|
+
createChannelConnection({
|
|
1523
|
+
identifier,
|
|
1524
|
+
integrationIdentifier,
|
|
1525
|
+
subscriberId,
|
|
1526
|
+
context,
|
|
1527
|
+
workspace,
|
|
1528
|
+
auth
|
|
1529
|
+
}) {
|
|
1530
|
+
return __privateGet(this, _httpClient).post(CHANNEL_CONNECTIONS_ROUTE, {
|
|
1531
|
+
identifier,
|
|
1532
|
+
integrationIdentifier,
|
|
1533
|
+
subscriberId,
|
|
1534
|
+
context,
|
|
1535
|
+
workspace,
|
|
1536
|
+
auth
|
|
1537
|
+
});
|
|
1538
|
+
}
|
|
1539
|
+
deleteChannelConnection(identifier) {
|
|
1540
|
+
return __privateGet(this, _httpClient).delete(`${CHANNEL_CONNECTIONS_ROUTE}/${identifier}`);
|
|
1541
|
+
}
|
|
1542
|
+
listChannelEndpoints(args = {}) {
|
|
1543
|
+
const query = buildChannelListSearchParams(args);
|
|
1544
|
+
return __privateGet(this, _httpClient).get(`${CHANNEL_ENDPOINTS_ROUTE}${query}`, void 0, false);
|
|
1545
|
+
}
|
|
1546
|
+
getChannelEndpoint(identifier) {
|
|
1547
|
+
return __privateGet(this, _httpClient).get(`${CHANNEL_ENDPOINTS_ROUTE}/${identifier}`);
|
|
1548
|
+
}
|
|
1549
|
+
createChannelEndpoint({
|
|
1550
|
+
identifier,
|
|
1551
|
+
integrationIdentifier,
|
|
1552
|
+
connectionIdentifier,
|
|
1553
|
+
subscriberId,
|
|
1554
|
+
context,
|
|
1555
|
+
type,
|
|
1556
|
+
endpoint
|
|
1557
|
+
}) {
|
|
1558
|
+
return __privateGet(this, _httpClient).post(CHANNEL_ENDPOINTS_ROUTE, {
|
|
1559
|
+
identifier,
|
|
1560
|
+
integrationIdentifier,
|
|
1561
|
+
connectionIdentifier,
|
|
1562
|
+
subscriberId,
|
|
1563
|
+
context,
|
|
1564
|
+
type,
|
|
1565
|
+
endpoint
|
|
1566
|
+
});
|
|
1567
|
+
}
|
|
1568
|
+
deleteChannelEndpoint(identifier) {
|
|
1569
|
+
return __privateGet(this, _httpClient).delete(`${CHANNEL_ENDPOINTS_ROUTE}/${identifier}`);
|
|
1570
|
+
}
|
|
1470
1571
|
};
|
|
1471
1572
|
_httpClient = new WeakMap();
|
|
1573
|
+
|
|
1574
|
+
// src/channel-connections/helpers.ts
|
|
1575
|
+
var generateChatOAuthUrl = (_0) => __async(null, [_0], function* ({
|
|
1576
|
+
emitter,
|
|
1577
|
+
apiService,
|
|
1578
|
+
args
|
|
1579
|
+
}) {
|
|
1580
|
+
try {
|
|
1581
|
+
emitter.emit("channel-connection.oauth-url.pending", { args });
|
|
1582
|
+
const data = yield apiService.generateChatOAuthUrl(args);
|
|
1583
|
+
emitter.emit("channel-connection.oauth-url.resolved", { args, data });
|
|
1584
|
+
return { data };
|
|
1585
|
+
} catch (error) {
|
|
1586
|
+
emitter.emit("channel-connection.oauth-url.resolved", { args, error });
|
|
1587
|
+
return { error: new NovuError("Failed to generate chat OAuth URL", error) };
|
|
1588
|
+
}
|
|
1589
|
+
});
|
|
1590
|
+
var listChannelConnections = (_0) => __async(null, [_0], function* ({
|
|
1591
|
+
emitter,
|
|
1592
|
+
apiService,
|
|
1593
|
+
args
|
|
1594
|
+
}) {
|
|
1595
|
+
try {
|
|
1596
|
+
emitter.emit("channel-connections.list.pending", { args });
|
|
1597
|
+
const response = yield apiService.listChannelConnections(args);
|
|
1598
|
+
const data = response.data;
|
|
1599
|
+
emitter.emit("channel-connections.list.resolved", { args, data });
|
|
1600
|
+
return { data };
|
|
1601
|
+
} catch (error) {
|
|
1602
|
+
emitter.emit("channel-connections.list.resolved", { args, error });
|
|
1603
|
+
return { error: new NovuError("Failed to list channel connections", error) };
|
|
1604
|
+
}
|
|
1605
|
+
});
|
|
1606
|
+
var getChannelConnection = (_0) => __async(null, [_0], function* ({
|
|
1607
|
+
emitter,
|
|
1608
|
+
apiService,
|
|
1609
|
+
args
|
|
1610
|
+
}) {
|
|
1611
|
+
try {
|
|
1612
|
+
emitter.emit("channel-connection.get.pending", { args });
|
|
1613
|
+
const data = yield apiService.getChannelConnection(args.identifier);
|
|
1614
|
+
emitter.emit("channel-connection.get.resolved", { args, data });
|
|
1615
|
+
return { data };
|
|
1616
|
+
} catch (error) {
|
|
1617
|
+
emitter.emit("channel-connection.get.resolved", { args, error });
|
|
1618
|
+
return { error: new NovuError("Failed to get channel connection", error) };
|
|
1619
|
+
}
|
|
1620
|
+
});
|
|
1621
|
+
var deleteChannelConnection = (_0) => __async(null, [_0], function* ({
|
|
1622
|
+
emitter,
|
|
1623
|
+
apiService,
|
|
1624
|
+
args
|
|
1625
|
+
}) {
|
|
1626
|
+
try {
|
|
1627
|
+
emitter.emit("channel-connection.delete.pending", { args });
|
|
1628
|
+
yield apiService.deleteChannelConnection(args.identifier);
|
|
1629
|
+
emitter.emit("channel-connection.delete.resolved", { args });
|
|
1630
|
+
return { data: void 0 };
|
|
1631
|
+
} catch (error) {
|
|
1632
|
+
emitter.emit("channel-connection.delete.resolved", { args, error });
|
|
1633
|
+
return { error: new NovuError("Failed to delete channel connection", error) };
|
|
1634
|
+
}
|
|
1635
|
+
});
|
|
1636
|
+
|
|
1637
|
+
// src/channel-connections/channel-connections.ts
|
|
1638
|
+
var ChannelConnections = class extends BaseModule {
|
|
1639
|
+
constructor({
|
|
1640
|
+
inboxServiceInstance,
|
|
1641
|
+
eventEmitterInstance
|
|
1642
|
+
}) {
|
|
1643
|
+
super({ inboxServiceInstance, eventEmitterInstance });
|
|
1644
|
+
}
|
|
1645
|
+
generateOAuthUrl(args) {
|
|
1646
|
+
return __async(this, null, function* () {
|
|
1647
|
+
return this.callWithSession(
|
|
1648
|
+
() => generateChatOAuthUrl({
|
|
1649
|
+
emitter: this._emitter,
|
|
1650
|
+
apiService: this._inboxService,
|
|
1651
|
+
args
|
|
1652
|
+
})
|
|
1653
|
+
);
|
|
1654
|
+
});
|
|
1655
|
+
}
|
|
1656
|
+
list() {
|
|
1657
|
+
return __async(this, arguments, function* (args = {}) {
|
|
1658
|
+
return this.callWithSession(
|
|
1659
|
+
() => listChannelConnections({
|
|
1660
|
+
emitter: this._emitter,
|
|
1661
|
+
apiService: this._inboxService,
|
|
1662
|
+
args
|
|
1663
|
+
})
|
|
1664
|
+
);
|
|
1665
|
+
});
|
|
1666
|
+
}
|
|
1667
|
+
get(args) {
|
|
1668
|
+
return __async(this, null, function* () {
|
|
1669
|
+
return this.callWithSession(
|
|
1670
|
+
() => getChannelConnection({
|
|
1671
|
+
emitter: this._emitter,
|
|
1672
|
+
apiService: this._inboxService,
|
|
1673
|
+
args
|
|
1674
|
+
})
|
|
1675
|
+
);
|
|
1676
|
+
});
|
|
1677
|
+
}
|
|
1678
|
+
delete(args) {
|
|
1679
|
+
return __async(this, null, function* () {
|
|
1680
|
+
return this.callWithSession(
|
|
1681
|
+
() => deleteChannelConnection({
|
|
1682
|
+
emitter: this._emitter,
|
|
1683
|
+
apiService: this._inboxService,
|
|
1684
|
+
args
|
|
1685
|
+
})
|
|
1686
|
+
);
|
|
1687
|
+
});
|
|
1688
|
+
}
|
|
1689
|
+
};
|
|
1690
|
+
|
|
1691
|
+
// src/channel-endpoints/helpers.ts
|
|
1692
|
+
var listChannelEndpoints = (_0) => __async(null, [_0], function* ({
|
|
1693
|
+
emitter,
|
|
1694
|
+
apiService,
|
|
1695
|
+
args
|
|
1696
|
+
}) {
|
|
1697
|
+
try {
|
|
1698
|
+
emitter.emit("channel-endpoints.list.pending", { args });
|
|
1699
|
+
const response = yield apiService.listChannelEndpoints(args);
|
|
1700
|
+
const data = response.data;
|
|
1701
|
+
emitter.emit("channel-endpoints.list.resolved", { args, data });
|
|
1702
|
+
return { data };
|
|
1703
|
+
} catch (error) {
|
|
1704
|
+
emitter.emit("channel-endpoints.list.resolved", { args, error });
|
|
1705
|
+
return { error: new NovuError("Failed to list channel endpoints", error) };
|
|
1706
|
+
}
|
|
1707
|
+
});
|
|
1708
|
+
var getChannelEndpoint = (_0) => __async(null, [_0], function* ({
|
|
1709
|
+
emitter,
|
|
1710
|
+
apiService,
|
|
1711
|
+
args
|
|
1712
|
+
}) {
|
|
1713
|
+
try {
|
|
1714
|
+
emitter.emit("channel-endpoint.get.pending", { args });
|
|
1715
|
+
const data = yield apiService.getChannelEndpoint(args.identifier);
|
|
1716
|
+
emitter.emit("channel-endpoint.get.resolved", { args, data });
|
|
1717
|
+
return { data };
|
|
1718
|
+
} catch (error) {
|
|
1719
|
+
emitter.emit("channel-endpoint.get.resolved", { args, error });
|
|
1720
|
+
return { error: new NovuError("Failed to get channel endpoint", error) };
|
|
1721
|
+
}
|
|
1722
|
+
});
|
|
1723
|
+
var createChannelEndpoint = (_0) => __async(null, [_0], function* ({
|
|
1724
|
+
emitter,
|
|
1725
|
+
apiService,
|
|
1726
|
+
args
|
|
1727
|
+
}) {
|
|
1728
|
+
try {
|
|
1729
|
+
emitter.emit("channel-endpoint.create.pending", { args });
|
|
1730
|
+
const data = yield apiService.createChannelEndpoint(args);
|
|
1731
|
+
emitter.emit("channel-endpoint.create.resolved", { args, data });
|
|
1732
|
+
return { data };
|
|
1733
|
+
} catch (error) {
|
|
1734
|
+
emitter.emit("channel-endpoint.create.resolved", { args, error });
|
|
1735
|
+
return { error: new NovuError("Failed to create channel endpoint", error) };
|
|
1736
|
+
}
|
|
1737
|
+
});
|
|
1738
|
+
var deleteChannelEndpoint = (_0) => __async(null, [_0], function* ({
|
|
1739
|
+
emitter,
|
|
1740
|
+
apiService,
|
|
1741
|
+
args
|
|
1742
|
+
}) {
|
|
1743
|
+
try {
|
|
1744
|
+
emitter.emit("channel-endpoint.delete.pending", { args });
|
|
1745
|
+
yield apiService.deleteChannelEndpoint(args.identifier);
|
|
1746
|
+
emitter.emit("channel-endpoint.delete.resolved", { args });
|
|
1747
|
+
return { data: void 0 };
|
|
1748
|
+
} catch (error) {
|
|
1749
|
+
emitter.emit("channel-endpoint.delete.resolved", { args, error });
|
|
1750
|
+
return { error: new NovuError("Failed to delete channel endpoint", error) };
|
|
1751
|
+
}
|
|
1752
|
+
});
|
|
1753
|
+
|
|
1754
|
+
// src/channel-endpoints/channel-endpoints.ts
|
|
1755
|
+
var ChannelEndpoints = class extends BaseModule {
|
|
1756
|
+
constructor({
|
|
1757
|
+
inboxServiceInstance,
|
|
1758
|
+
eventEmitterInstance
|
|
1759
|
+
}) {
|
|
1760
|
+
super({ inboxServiceInstance, eventEmitterInstance });
|
|
1761
|
+
}
|
|
1762
|
+
list() {
|
|
1763
|
+
return __async(this, arguments, function* (args = {}) {
|
|
1764
|
+
return this.callWithSession(
|
|
1765
|
+
() => listChannelEndpoints({
|
|
1766
|
+
emitter: this._emitter,
|
|
1767
|
+
apiService: this._inboxService,
|
|
1768
|
+
args
|
|
1769
|
+
})
|
|
1770
|
+
);
|
|
1771
|
+
});
|
|
1772
|
+
}
|
|
1773
|
+
get(args) {
|
|
1774
|
+
return __async(this, null, function* () {
|
|
1775
|
+
return this.callWithSession(
|
|
1776
|
+
() => getChannelEndpoint({
|
|
1777
|
+
emitter: this._emitter,
|
|
1778
|
+
apiService: this._inboxService,
|
|
1779
|
+
args
|
|
1780
|
+
})
|
|
1781
|
+
);
|
|
1782
|
+
});
|
|
1783
|
+
}
|
|
1784
|
+
create(args) {
|
|
1785
|
+
return __async(this, null, function* () {
|
|
1786
|
+
return this.callWithSession(
|
|
1787
|
+
() => createChannelEndpoint({
|
|
1788
|
+
emitter: this._emitter,
|
|
1789
|
+
apiService: this._inboxService,
|
|
1790
|
+
args
|
|
1791
|
+
})
|
|
1792
|
+
);
|
|
1793
|
+
});
|
|
1794
|
+
}
|
|
1795
|
+
delete(args) {
|
|
1796
|
+
return __async(this, null, function* () {
|
|
1797
|
+
return this.callWithSession(
|
|
1798
|
+
() => deleteChannelEndpoint({
|
|
1799
|
+
emitter: this._emitter,
|
|
1800
|
+
apiService: this._inboxService,
|
|
1801
|
+
args
|
|
1802
|
+
})
|
|
1803
|
+
);
|
|
1804
|
+
});
|
|
1805
|
+
}
|
|
1806
|
+
};
|
|
1472
1807
|
var _mittEmitter;
|
|
1473
1808
|
var NovuEventEmitter = class {
|
|
1474
1809
|
constructor() {
|
|
@@ -3426,6 +3761,14 @@ var Novu = class {
|
|
|
3426
3761
|
inboxServiceInstance: __privateGet(this, _inboxService6),
|
|
3427
3762
|
eventEmitterInstance: __privateGet(this, _emitter12)
|
|
3428
3763
|
});
|
|
3764
|
+
this.channelConnections = new ChannelConnections({
|
|
3765
|
+
inboxServiceInstance: __privateGet(this, _inboxService6),
|
|
3766
|
+
eventEmitterInstance: __privateGet(this, _emitter12)
|
|
3767
|
+
});
|
|
3768
|
+
this.channelEndpoints = new ChannelEndpoints({
|
|
3769
|
+
inboxServiceInstance: __privateGet(this, _inboxService6),
|
|
3770
|
+
eventEmitterInstance: __privateGet(this, _emitter12)
|
|
3771
|
+
});
|
|
3429
3772
|
this.socket = createSocket({
|
|
3430
3773
|
socketUrl: options.socketUrl,
|
|
3431
3774
|
socketOptions: options.socketOptions,
|