@novu/js 3.16.0 → 3.17.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.
@@ -179,6 +179,97 @@ var areDataEqual = (data1, data2) => {
179
179
  var isSameFilter = (filter1, filter2) => {
180
180
  return areDataEqual(filter1.data, filter2.data) && areTagsEqual(filter1.tags, filter2.tags) && filter1.read === filter2.read && filter1.archived === filter2.archived && filter1.snoozed === filter2.snoozed && filter1.seen === filter2.seen && areSeveritiesEqual(filter1.severity, filter2.severity) && filter1.createdGte === filter2.createdGte && filter1.createdLte === filter2.createdLte;
181
181
  };
182
+ function isPlainObject(value) {
183
+ return typeof value === "object" && value !== null && !Array.isArray(value);
184
+ }
185
+ function isOperatorObject(value) {
186
+ return Object.prototype.hasOwnProperty.call(value, "or") || Object.prototype.hasOwnProperty.call(value, "and");
187
+ }
188
+ function isScalarValue(value) {
189
+ if (value === null) return true;
190
+ if (typeof value === "boolean") return true;
191
+ if (typeof value === "string") return true;
192
+ if (typeof value === "number") return Number.isFinite(value);
193
+ return false;
194
+ }
195
+ function normalizeDataFieldValue(value) {
196
+ if (value === void 0) {
197
+ return [];
198
+ }
199
+ if (Array.isArray(value)) {
200
+ if (value.length === 0) return [];
201
+ if (!value.every(isScalarValue)) return null;
202
+ return [value];
203
+ }
204
+ if (isPlainObject(value)) {
205
+ const hasOr = Object.prototype.hasOwnProperty.call(value, "or");
206
+ const hasAnd = Object.prototype.hasOwnProperty.call(value, "and");
207
+ if (hasOr && hasAnd) return null;
208
+ const keys = Object.keys(value);
209
+ if (hasOr) {
210
+ if (keys.length !== 1) return null;
211
+ const orVal = value.or;
212
+ if (!Array.isArray(orVal)) return null;
213
+ if (orVal.length === 0) return [];
214
+ if (!orVal.every(isScalarValue)) return null;
215
+ return [orVal];
216
+ }
217
+ if (hasAnd) {
218
+ if (keys.length !== 1) return null;
219
+ const andVal = value.and;
220
+ if (!Array.isArray(andVal)) return null;
221
+ const groups = [];
222
+ for (const item of andVal) {
223
+ if (!isPlainObject(item)) return null;
224
+ const itemKeys = Object.keys(item);
225
+ if (itemKeys.length !== 1 || !("or" in item)) return null;
226
+ const innerOr = item.or;
227
+ if (!Array.isArray(innerOr) || innerOr.length === 0) return null;
228
+ if (!innerOr.every(isScalarValue)) return null;
229
+ groups.push(innerOr);
230
+ }
231
+ return groups;
232
+ }
233
+ return null;
234
+ }
235
+ if (!isScalarValue(value)) return null;
236
+ return [[value]];
237
+ }
238
+ function dataValueAtPath(obj, path) {
239
+ let current = obj;
240
+ for (const segment of path) {
241
+ if (current === null || current === void 0) return void 0;
242
+ if (typeof current !== "object" || Array.isArray(current)) return void 0;
243
+ current = current[segment];
244
+ }
245
+ return current;
246
+ }
247
+ function orGroupMatchesNotifValue(group, notifValue) {
248
+ if (Array.isArray(notifValue)) {
249
+ return notifValue.some((v) => group.some((g) => g === v));
250
+ }
251
+ return group.some((g) => g === notifValue);
252
+ }
253
+ function checkDataEntries(notificationData, filterData, pathPrefix, depth) {
254
+ if (depth > 2) return false;
255
+ for (const [rawKey, rawValue] of Object.entries(filterData)) {
256
+ if (rawKey.startsWith("$") || rawKey.startsWith(".") || rawKey === "__proto__" || rawKey === "constructor" || rawKey === "prototype") {
257
+ return false;
258
+ }
259
+ const path = [...pathPrefix, rawKey];
260
+ if (isPlainObject(rawValue) && !isOperatorObject(rawValue)) {
261
+ if (!checkDataEntries(notificationData, rawValue, path, depth + 1)) return false;
262
+ continue;
263
+ }
264
+ const groups = normalizeDataFieldValue(rawValue);
265
+ if (groups === null) return false;
266
+ if (groups.length === 0) continue;
267
+ const notifValue = notificationData ? dataValueAtPath(notificationData, path) : void 0;
268
+ if (notifValue === void 0) return false;
269
+ if (!groups.every((g) => orGroupMatchesNotifValue(g, notifValue))) return false;
270
+ }
271
+ return true;
272
+ }
182
273
  function checkNotificationDataFilter(notificationData, filterData) {
183
274
  if (!filterData || Object.keys(filterData).length === 0) {
184
275
  return true;
@@ -186,24 +277,7 @@ function checkNotificationDataFilter(notificationData, filterData) {
186
277
  if (!notificationData) {
187
278
  return false;
188
279
  }
189
- return Object.entries(filterData).every(([key, filterValue]) => {
190
- const notifValue = notificationData[key];
191
- if (notifValue === void 0 && filterValue !== void 0) {
192
- return false;
193
- }
194
- if (Array.isArray(filterValue)) {
195
- if (Array.isArray(notifValue)) {
196
- if (filterValue.length !== notifValue.length) return false;
197
- const sortedFilterValue = [...filterValue].sort();
198
- const sortedNotifValue = [...notifValue].sort();
199
- return sortedFilterValue.every((val, index) => val === sortedNotifValue[index]);
200
- } else {
201
- return filterValue.includes(notifValue);
202
- }
203
- } else {
204
- return notifValue === filterValue;
205
- }
206
- });
280
+ return checkDataEntries(notificationData, filterData, [], 1);
207
281
  }
208
282
  function checkNotificationTagFilter(notificationTags, filterTags) {
209
283
  let groups;
@@ -1036,7 +1110,7 @@ _contextKey = new WeakMap();
1036
1110
 
1037
1111
  // src/api/http-client.ts
1038
1112
  var DEFAULT_API_VERSION = "v1";
1039
- var DEFAULT_CLIENT_VERSION = `${"@novu/js"}@${"3.16.0"}`;
1113
+ var DEFAULT_CLIENT_VERSION = `${"@novu/js"}@${"3.17.0"}`;
1040
1114
  var HttpClient = class {
1041
1115
  constructor(options = {}) {
1042
1116
  // Environment variable for local development that overrides the default API endpoint without affecting the Inbox DX
@@ -1152,7 +1226,9 @@ var INBOX_ROUTE = "/inbox";
1152
1226
  var INBOX_NOTIFICATIONS_ROUTE = `${INBOX_ROUTE}/notifications`;
1153
1227
  var CHAT_OAUTH_ROUTE = `${INBOX_ROUTE}/chat/oauth`;
1154
1228
  var CHANNEL_CONNECTIONS_ROUTE = `${INBOX_ROUTE}/channel-connections`;
1229
+ var CHANNEL_CONNECTIONS_OAUTH_ROUTE = `${CHANNEL_CONNECTIONS_ROUTE}/oauth`;
1155
1230
  var CHANNEL_ENDPOINTS_ROUTE = `${INBOX_ROUTE}/channel-endpoints`;
1231
+ var CHANNEL_ENDPOINTS_OAUTH_ROUTE = `${CHANNEL_ENDPOINTS_ROUTE}/oauth`;
1156
1232
  function buildChannelListSearchParams(args) {
1157
1233
  const searchParams = new URLSearchParams();
1158
1234
  if (args.subscriberId) searchParams.append("subscriberId", args.subscriberId);
@@ -1491,6 +1567,9 @@ var InboxService = class {
1491
1567
  deleteSubscription({ topicKey, identifier }) {
1492
1568
  return __privateGet(this, _httpClient).delete(`${INBOX_ROUTE}/topics/${topicKey}/subscriptions/${identifier}`);
1493
1569
  }
1570
+ /**
1571
+ * @deprecated Use generateConnectOAuthUrl() or generateLinkUserOAuthUrl() instead.
1572
+ */
1494
1573
  generateChatOAuthUrl({
1495
1574
  integrationIdentifier,
1496
1575
  connectionIdentifier,
@@ -1499,7 +1578,8 @@ var InboxService = class {
1499
1578
  scope,
1500
1579
  userScope,
1501
1580
  mode,
1502
- connectionMode
1581
+ connectionMode,
1582
+ autoLinkUser
1503
1583
  }) {
1504
1584
  return __privateGet(this, _httpClient).post(CHAT_OAUTH_ROUTE, {
1505
1585
  integrationIdentifier,
@@ -1509,7 +1589,42 @@ var InboxService = class {
1509
1589
  scope,
1510
1590
  userScope,
1511
1591
  mode,
1512
- connectionMode
1592
+ connectionMode,
1593
+ autoLinkUser
1594
+ });
1595
+ }
1596
+ generateConnectOAuthUrl({
1597
+ integrationIdentifier,
1598
+ connectionIdentifier,
1599
+ subscriberId,
1600
+ context,
1601
+ scope,
1602
+ connectionMode,
1603
+ autoLinkUser
1604
+ }) {
1605
+ return __privateGet(this, _httpClient).post(CHANNEL_CONNECTIONS_OAUTH_ROUTE, {
1606
+ integrationIdentifier,
1607
+ connectionIdentifier,
1608
+ subscriberId,
1609
+ context,
1610
+ scope,
1611
+ connectionMode,
1612
+ autoLinkUser
1613
+ });
1614
+ }
1615
+ generateLinkUserOAuthUrl({
1616
+ integrationIdentifier,
1617
+ connectionIdentifier,
1618
+ subscriberId,
1619
+ context,
1620
+ userScope
1621
+ }) {
1622
+ return __privateGet(this, _httpClient).post(CHANNEL_ENDPOINTS_OAUTH_ROUTE, {
1623
+ integrationIdentifier,
1624
+ connectionIdentifier,
1625
+ subscriberId,
1626
+ context,
1627
+ userScope
1513
1628
  });
1514
1629
  }
1515
1630
  listChannelConnections(args = {}) {
@@ -1587,6 +1702,21 @@ var generateChatOAuthUrl = (_0) => __async(null, [_0], function* ({
1587
1702
  return { error: new NovuError("Failed to generate chat OAuth URL", error) };
1588
1703
  }
1589
1704
  });
1705
+ var generateConnectOAuthUrl = (_0) => __async(null, [_0], function* ({
1706
+ emitter,
1707
+ apiService,
1708
+ args
1709
+ }) {
1710
+ try {
1711
+ emitter.emit("channel-connection.oauth-url.pending", { args });
1712
+ const data = yield apiService.generateConnectOAuthUrl(args);
1713
+ emitter.emit("channel-connection.oauth-url.resolved", { args, data });
1714
+ return { data };
1715
+ } catch (error) {
1716
+ emitter.emit("channel-connection.oauth-url.resolved", { args, error });
1717
+ return { error: new NovuError("Failed to generate connect OAuth URL", error) };
1718
+ }
1719
+ });
1590
1720
  var listChannelConnections = (_0) => __async(null, [_0], function* ({
1591
1721
  emitter,
1592
1722
  apiService,
@@ -1642,6 +1772,9 @@ var ChannelConnections = class extends BaseModule {
1642
1772
  }) {
1643
1773
  super({ inboxServiceInstance, eventEmitterInstance });
1644
1774
  }
1775
+ /**
1776
+ * @deprecated Use generateConnectOAuthUrl() instead. For user-level linking use channelEndpoints.generateLinkUserOAuthUrl().
1777
+ */
1645
1778
  generateOAuthUrl(args) {
1646
1779
  return __async(this, null, function* () {
1647
1780
  return this.callWithSession(
@@ -1653,6 +1786,17 @@ var ChannelConnections = class extends BaseModule {
1653
1786
  );
1654
1787
  });
1655
1788
  }
1789
+ generateConnectOAuthUrl(args) {
1790
+ return __async(this, null, function* () {
1791
+ return this.callWithSession(
1792
+ () => generateConnectOAuthUrl({
1793
+ emitter: this._emitter,
1794
+ apiService: this._inboxService,
1795
+ args
1796
+ })
1797
+ );
1798
+ });
1799
+ }
1656
1800
  list() {
1657
1801
  return __async(this, arguments, function* (args = {}) {
1658
1802
  return this.callWithSession(
@@ -1689,6 +1833,21 @@ var ChannelConnections = class extends BaseModule {
1689
1833
  };
1690
1834
 
1691
1835
  // src/channel-endpoints/helpers.ts
1836
+ var generateLinkUserOAuthUrl = (_0) => __async(null, [_0], function* ({
1837
+ emitter,
1838
+ apiService,
1839
+ args
1840
+ }) {
1841
+ try {
1842
+ emitter.emit("channel-endpoint.oauth-url.pending", { args });
1843
+ const data = yield apiService.generateLinkUserOAuthUrl(args);
1844
+ emitter.emit("channel-endpoint.oauth-url.resolved", { args, data });
1845
+ return { data };
1846
+ } catch (error) {
1847
+ emitter.emit("channel-endpoint.oauth-url.resolved", { args, error });
1848
+ return { error: new NovuError("Failed to generate link user OAuth URL", error) };
1849
+ }
1850
+ });
1692
1851
  var listChannelEndpoints = (_0) => __async(null, [_0], function* ({
1693
1852
  emitter,
1694
1853
  apiService,
@@ -1759,6 +1918,17 @@ var ChannelEndpoints = class extends BaseModule {
1759
1918
  }) {
1760
1919
  super({ inboxServiceInstance, eventEmitterInstance });
1761
1920
  }
1921
+ generateLinkUserOAuthUrl(args) {
1922
+ return __async(this, null, function* () {
1923
+ return this.callWithSession(
1924
+ () => generateLinkUserOAuthUrl({
1925
+ emitter: this._emitter,
1926
+ apiService: this._inboxService,
1927
+ args
1928
+ })
1929
+ );
1930
+ });
1931
+ }
1762
1932
  list() {
1763
1933
  return __async(this, arguments, function* (args = {}) {
1764
1934
  return this.callWithSession(
@@ -3211,6 +3381,8 @@ _emitter9 = new WeakMap();
3211
3381
  _inboxService5 = new WeakMap();
3212
3382
  _options = new WeakMap();
3213
3383
  var PRODUCTION_SOCKET_URL = "wss://socket.novu.co";
3384
+ var HIBERNATION_HEARTBEAT_MS = 25e3;
3385
+ var HIBERNATION_PING_PAYLOAD = "ping";
3214
3386
  var NOTIFICATION_RECEIVED = "notifications.notification_received";
3215
3387
  var UNSEEN_COUNT_CHANGED = "notifications.unseen_count_changed";
3216
3388
  var UNREAD_COUNT_CHANGED = "notifications.unread_count_changed";
@@ -3301,7 +3473,7 @@ var mapToNotification = ({
3301
3473
  severity
3302
3474
  });
3303
3475
  };
3304
- var _token, _emitter10, _partySocket, _socketUrl, _socketOptions, _notificationReceived, _unseenCountChanged, _unreadCountChanged, _handleMessage, _PartySocketClient_instances, initializeSocket_fn, handleConnectSocket_fn, handleDisconnectSocket_fn;
3476
+ var _token, _emitter10, _partySocket, _socketUrl, _socketOptions, _hibernationHeartbeatIntervalId, _notificationReceived, _unseenCountChanged, _unreadCountChanged, _handleMessage, _PartySocketClient_instances, clearHibernationHeartbeat_fn, startHibernationHeartbeat_fn, initializeSocket_fn, handleConnectSocket_fn, handleDisconnectSocket_fn;
3305
3477
  var PartySocketClient = class extends BaseModule {
3306
3478
  constructor({
3307
3479
  socketUrl,
@@ -3319,6 +3491,7 @@ var PartySocketClient = class extends BaseModule {
3319
3491
  __privateAdd(this, _partySocket);
3320
3492
  __privateAdd(this, _socketUrl);
3321
3493
  __privateAdd(this, _socketOptions);
3494
+ __privateAdd(this, _hibernationHeartbeatIntervalId);
3322
3495
  __privateAdd(this, _notificationReceived, (event) => {
3323
3496
  try {
3324
3497
  const data = JSON.parse(event.data);
@@ -3354,6 +3527,9 @@ var PartySocketClient = class extends BaseModule {
3354
3527
  }
3355
3528
  });
3356
3529
  __privateAdd(this, _handleMessage, (event) => {
3530
+ if (event.data === HIBERNATION_PING_PAYLOAD || event.data === "pong") {
3531
+ return;
3532
+ }
3357
3533
  try {
3358
3534
  const data = JSON.parse(event.data);
3359
3535
  switch (data.event) {
@@ -3403,11 +3579,31 @@ _emitter10 = new WeakMap();
3403
3579
  _partySocket = new WeakMap();
3404
3580
  _socketUrl = new WeakMap();
3405
3581
  _socketOptions = new WeakMap();
3582
+ _hibernationHeartbeatIntervalId = new WeakMap();
3406
3583
  _notificationReceived = new WeakMap();
3407
3584
  _unseenCountChanged = new WeakMap();
3408
3585
  _unreadCountChanged = new WeakMap();
3409
3586
  _handleMessage = new WeakMap();
3410
3587
  _PartySocketClient_instances = new WeakSet();
3588
+ clearHibernationHeartbeat_fn = function() {
3589
+ if (__privateGet(this, _hibernationHeartbeatIntervalId) !== void 0) {
3590
+ clearInterval(__privateGet(this, _hibernationHeartbeatIntervalId));
3591
+ __privateSet(this, _hibernationHeartbeatIntervalId, void 0);
3592
+ }
3593
+ };
3594
+ startHibernationHeartbeat_fn = function() {
3595
+ __privateMethod(this, _PartySocketClient_instances, clearHibernationHeartbeat_fn).call(this);
3596
+ __privateSet(this, _hibernationHeartbeatIntervalId, setInterval(() => {
3597
+ const socket = __privateGet(this, _partySocket);
3598
+ if (!socket || socket.readyState !== WebSocket.OPEN) {
3599
+ return;
3600
+ }
3601
+ try {
3602
+ socket.send(HIBERNATION_PING_PAYLOAD);
3603
+ } catch (e) {
3604
+ }
3605
+ }, HIBERNATION_HEARTBEAT_MS));
3606
+ };
3411
3607
  initializeSocket_fn = function() {
3412
3608
  return __async(this, null, function* () {
3413
3609
  if (__privateGet(this, _partySocket)) {
@@ -3418,13 +3614,22 @@ initializeSocket_fn = function() {
3418
3614
  const url = new URL(__privateGet(this, _socketUrl));
3419
3615
  url.searchParams.set("token", __privateGet(this, _token));
3420
3616
  __privateSet(this, _partySocket, new WebSocket(url.toString(), void 0, __privateGet(this, _socketOptions)));
3421
- __privateGet(this, _partySocket).addEventListener("open", () => {
3617
+ const socket = __privateGet(this, _partySocket);
3618
+ socket.addEventListener("open", () => {
3619
+ __privateMethod(this, _PartySocketClient_instances, startHibernationHeartbeat_fn).call(this);
3422
3620
  __privateGet(this, _emitter10).emit("socket.connect.resolved", { args });
3423
3621
  });
3424
- __privateGet(this, _partySocket).addEventListener("error", (error) => {
3622
+ socket.addEventListener("error", (error) => {
3425
3623
  __privateGet(this, _emitter10).emit("socket.connect.resolved", { args, error });
3426
3624
  });
3427
- __privateGet(this, _partySocket).addEventListener("message", __privateGet(this, _handleMessage));
3625
+ socket.addEventListener("close", () => {
3626
+ if (socket !== __privateGet(this, _partySocket)) {
3627
+ return;
3628
+ }
3629
+ __privateMethod(this, _PartySocketClient_instances, clearHibernationHeartbeat_fn).call(this);
3630
+ __privateSet(this, _partySocket, void 0);
3631
+ });
3632
+ socket.addEventListener("message", __privateGet(this, _handleMessage));
3428
3633
  });
3429
3634
  };
3430
3635
  handleConnectSocket_fn = function() {
@@ -3441,6 +3646,7 @@ handleDisconnectSocket_fn = function() {
3441
3646
  return __async(this, null, function* () {
3442
3647
  var _a;
3443
3648
  try {
3649
+ __privateMethod(this, _PartySocketClient_instances, clearHibernationHeartbeat_fn).call(this);
3444
3650
  (_a = __privateGet(this, _partySocket)) == null ? void 0 : _a.close();
3445
3651
  __privateSet(this, _partySocket, void 0);
3446
3652
  return {};
@@ -294,6 +294,9 @@ type ChannelConnectionOAuthUrlEvents = BaseEvents<'channel-connection.oauth-url'
294
294
  type ChannelConnectionsFetchEvents = BaseEvents<'channel-connections.list', ListChannelConnectionsArgs, ChannelConnectionResponse[]>;
295
295
  type ChannelConnectionGetEvents = BaseEvents<'channel-connection.get', GetChannelConnectionArgs, ChannelConnectionResponse | null>;
296
296
  type ChannelConnectionDeleteEvents = BaseEvents<'channel-connection.delete', DeleteChannelConnectionArgs, void>;
297
+ type ChannelEndpointOAuthUrlEvents = BaseEvents<'channel-endpoint.oauth-url', GenerateLinkUserOAuthUrlArgs, {
298
+ url: string;
299
+ }>;
297
300
  type ChannelEndpointsFetchEvents = BaseEvents<'channel-endpoints.list', ListChannelEndpointsArgs, ChannelEndpointResponse[]>;
298
301
  type ChannelEndpointGetEvents = BaseEvents<'channel-endpoint.get', GetChannelEndpointArgs, ChannelEndpointResponse | null>;
299
302
  type ChannelEndpointCreateEvents = BaseEvents<'channel-endpoint.create', CreateChannelEndpointArgs, ChannelEndpointResponse>;
@@ -351,7 +354,7 @@ type Events = SessionInitializeEvents & NotificationsFetchEvents & {
351
354
  subscriptions: TopicSubscription[];
352
355
  };
353
356
  };
354
- } & ChannelConnectionOAuthUrlEvents & ChannelConnectionsFetchEvents & ChannelConnectionGetEvents & ChannelConnectionDeleteEvents & ChannelEndpointsFetchEvents & ChannelEndpointGetEvents & ChannelEndpointCreateEvents & ChannelEndpointDeleteEvents & SocketConnectEvents & SocketEvents & NotificationReadEvents & NotificationUnreadEvents & NotificationSeenEvents & NotificationArchiveEvents & NotificationUnarchiveEvents & NotificationDeleteEvents & NotificationSnoozeEvents & NotificationUnsnoozeEvents & NotificationCompleteActionEvents & NotificationRevertActionEvents & NotificationsReadAllEvents & NotificationsSeenAllEvents & NotificationsArchivedAllEvents & NotificationsReadArchivedAllEvents & NotificationsDeletedAllEvents;
357
+ } & ChannelConnectionOAuthUrlEvents & ChannelConnectionsFetchEvents & ChannelConnectionGetEvents & ChannelConnectionDeleteEvents & ChannelEndpointOAuthUrlEvents & ChannelEndpointsFetchEvents & ChannelEndpointGetEvents & ChannelEndpointCreateEvents & ChannelEndpointDeleteEvents & SocketConnectEvents & SocketEvents & NotificationReadEvents & NotificationUnreadEvents & NotificationSeenEvents & NotificationArchiveEvents & NotificationUnarchiveEvents & NotificationDeleteEvents & NotificationSnoozeEvents & NotificationUnsnoozeEvents & NotificationCompleteActionEvents & NotificationRevertActionEvents & NotificationsReadAllEvents & NotificationsSeenAllEvents & NotificationsArchivedAllEvents & NotificationsReadArchivedAllEvents & NotificationsDeletedAllEvents;
355
358
  type EventNames = keyof Events;
356
359
  type SocketEventNames = keyof SocketEvents;
357
360
  type EventHandler<T = unknown> = (event: T) => void;
@@ -638,6 +641,18 @@ type NotificationFilter = {
638
641
  archived?: boolean;
639
642
  snoozed?: boolean;
640
643
  seen?: boolean;
644
+ /**
645
+ * Filter notifications by keys in their `data` object.
646
+ *
647
+ * Each top-level key value can be:
648
+ * - a scalar (exact equality)
649
+ * - `Scalar[]` (OR — match any of the listed values)
650
+ * - `{ or: Scalar[] }` (explicit OR)
651
+ * - `{ and: [{ or: Scalar[] }, ...] }` (AND of OR-groups)
652
+ * - a 1-level nested object whose sub-keys follow the same rules
653
+ *
654
+ * Across keys clauses are AND-ed together.
655
+ */
641
656
  data?: Record<string, unknown>;
642
657
  severity?: SeverityLevelEnum | SeverityLevelEnum[];
643
658
  createdGte?: number;
@@ -759,6 +774,9 @@ type ChannelEndpointResponse = {
759
774
  };
760
775
  type OAuthMode = 'connect' | 'link_user';
761
776
  type ConnectionMode = 'subscriber' | 'shared';
777
+ /**
778
+ * @deprecated Use GenerateConnectOAuthUrlArgs or GenerateLinkUserOAuthUrlArgs instead.
779
+ */
762
780
  type GenerateChatOAuthUrlArgs = {
763
781
  integrationIdentifier: string;
764
782
  connectionIdentifier?: string;
@@ -768,6 +786,28 @@ type GenerateChatOAuthUrlArgs = {
768
786
  userScope?: string[];
769
787
  mode?: OAuthMode;
770
788
  connectionMode?: ConnectionMode;
789
+ autoLinkUser?: boolean;
790
+ };
791
+ /** Args for creating a workspace/tenant channel connection (Slack install or MS Teams admin consent). */
792
+ type GenerateConnectOAuthUrlArgs = {
793
+ integrationIdentifier: string;
794
+ connectionIdentifier?: string;
795
+ subscriberId?: string;
796
+ context?: Context;
797
+ /** Slack only: OAuth bot scopes to request. */
798
+ scope?: string[];
799
+ connectionMode?: ConnectionMode;
800
+ autoLinkUser?: boolean;
801
+ };
802
+ /** Args for linking a subscriber to their personal chat identity (Slack user or MS Teams user OID). */
803
+ type GenerateLinkUserOAuthUrlArgs = {
804
+ integrationIdentifier: string;
805
+ connectionIdentifier?: string;
806
+ /** Required — this operation always binds a specific subscriber to a user identity. */
807
+ subscriberId: string;
808
+ context?: Context;
809
+ /** Slack only: user-level OAuth scopes (e.g. identity.basic). */
810
+ userScope?: string[];
771
811
  };
772
812
  type ListChannelConnectionsArgs = {
773
813
  subscriberId?: string;
@@ -970,7 +1010,16 @@ declare class InboxService {
970
1010
  topicKey: string;
971
1011
  identifier: string;
972
1012
  }): Promise<void>;
973
- generateChatOAuthUrl({ integrationIdentifier, connectionIdentifier, subscriberId, context, scope, userScope, mode, connectionMode, }: GenerateChatOAuthUrlArgs): Promise<{
1013
+ /**
1014
+ * @deprecated Use generateConnectOAuthUrl() or generateLinkUserOAuthUrl() instead.
1015
+ */
1016
+ generateChatOAuthUrl({ integrationIdentifier, connectionIdentifier, subscriberId, context, scope, userScope, mode, connectionMode, autoLinkUser, }: GenerateChatOAuthUrlArgs): Promise<{
1017
+ url: string;
1018
+ }>;
1019
+ generateConnectOAuthUrl({ integrationIdentifier, connectionIdentifier, subscriberId, context, scope, connectionMode, autoLinkUser, }: GenerateConnectOAuthUrlArgs): Promise<{
1020
+ url: string;
1021
+ }>;
1022
+ generateLinkUserOAuthUrl({ integrationIdentifier, connectionIdentifier, subscriberId, context, userScope, }: GenerateLinkUserOAuthUrlArgs): Promise<{
974
1023
  url: string;
975
1024
  }>;
976
1025
  listChannelConnections(args?: ListChannelConnectionsArgs): Promise<{
@@ -991,4 +1040,4 @@ declare class InboxService {
991
1040
  deleteChannelEndpoint(identifier: string): Promise<void>;
992
1041
  }
993
1042
 
994
- export { type UpdateSubscriptionPreferenceArgs as $, type PreferenceFilter as A, type BaseDeleteSubscriptionArgs as B, type ChannelConnectionResponse as C, type DaySchedule as D, type EventHandler as E, type FiltersCountResponse as F, type GenerateChatOAuthUrlArgs as G, PreferenceLevel as H, type InboxNotification as I, type PreferencesResponse as J, Schedule as K, type ListChannelConnectionsArgs as L, type SocketEventNames as M, Notification as N, type SocketTypeOption as O, Preference as P, type StandardNovuOptions as Q, type Subscriber as R, SeverityLevelEnum as S, type TagsFilter as T, SubscriptionPreference as U, type TagsFilterAndForm as V, type TagsFilterOrGroup as W, type TimeRange as X, TopicSubscription as Y, type UnreadCount as Z, type UpdateSubscriptionArgs as _, type NotificationFilter as a, WebSocketEvent as a0, type WeeklySchedule as a1, WorkflowCriticalityEnum as a2, type WorkflowFilter as a3, type WorkflowGroupFilter as a4, type WorkflowIdentifierOrId as a5, type ConnectionMode as a6, InboxService as a7, NovuEventEmitter as a8, type Session as a9, type Result as aa, ScheduleCache as ab, type UpdateScheduleArgs as ac, PreferencesCache as ad, type ListPreferencesArgs as ae, type BasePreferenceArgs as af, type InstancePreferenceArgs as ag, type ListNotificationsArgs as ah, type FilterCountArgs as ai, type FilterCountResponse as aj, type FiltersCountArgs as ak, type BaseArgs as al, type InstanceArgs as am, type SnoozeArgs as an, SubscriptionsCache as ao, type Options as ap, type EventNames as aq, type ContextValue as ar, type BaseUpdateSubscriptionArgs as b, type ChannelEndpointResponse as c, type ChannelPreference as d, ChannelType as e, type Context as f, type CreateChannelConnectionArgs as g, type CreateChannelEndpointArgs as h, type CreateSubscriptionArgs as i, type DefaultSchedule as j, type DeleteChannelConnectionArgs as k, type DeleteChannelEndpointArgs as l, type DeleteSubscriptionArgs as m, type Events as n, type GetChannelConnectionArgs as o, type GetChannelEndpointArgs as p, type GetSubscriptionArgs as q, type InstanceDeleteSubscriptionArgs as r, type InstanceUpdateSubscriptionArgs as s, type ListChannelEndpointsArgs as t, type ListNotificationsResponse as u, type ListSubscriptionsArgs as v, NotificationStatus as w, NovuError as x, type NovuOptions as y, type NovuSocketOptions as z };
1043
+ export { type UpdateSubscriptionPreferenceArgs as $, type PreferenceFilter as A, type BaseDeleteSubscriptionArgs as B, type ChannelConnectionResponse as C, type DaySchedule as D, type EventHandler as E, type FiltersCountResponse as F, type GenerateChatOAuthUrlArgs as G, PreferenceLevel as H, type InboxNotification as I, type PreferencesResponse as J, Schedule as K, type ListChannelConnectionsArgs as L, type SocketEventNames as M, Notification as N, type SocketTypeOption as O, Preference as P, type StandardNovuOptions as Q, type Subscriber as R, SeverityLevelEnum as S, type TagsFilter as T, SubscriptionPreference as U, type TagsFilterAndForm as V, type TagsFilterOrGroup as W, type TimeRange as X, TopicSubscription as Y, type UnreadCount as Z, type UpdateSubscriptionArgs as _, type NotificationFilter as a, WebSocketEvent as a0, type WeeklySchedule as a1, WorkflowCriticalityEnum as a2, type WorkflowFilter as a3, type WorkflowGroupFilter as a4, type WorkflowIdentifierOrId as a5, type ConnectionMode as a6, InboxService as a7, NovuEventEmitter as a8, type Session as a9, type Result as aa, ScheduleCache as ab, type UpdateScheduleArgs as ac, PreferencesCache as ad, type ListPreferencesArgs as ae, type BasePreferenceArgs as af, type InstancePreferenceArgs as ag, type ListNotificationsArgs as ah, type FilterCountArgs as ai, type FilterCountResponse as aj, type FiltersCountArgs as ak, type BaseArgs as al, type InstanceArgs as am, type SnoozeArgs as an, type GenerateConnectOAuthUrlArgs as ao, type GenerateLinkUserOAuthUrlArgs as ap, SubscriptionsCache as aq, type Options as ar, type EventNames as as, type ContextValue as at, type BaseUpdateSubscriptionArgs as b, type ChannelEndpointResponse as c, type ChannelPreference as d, ChannelType as e, type Context as f, type CreateChannelConnectionArgs as g, type CreateChannelEndpointArgs as h, type CreateSubscriptionArgs as i, type DefaultSchedule as j, type DeleteChannelConnectionArgs as k, type DeleteChannelEndpointArgs as l, type DeleteSubscriptionArgs as m, type Events as n, type GetChannelConnectionArgs as o, type GetChannelEndpointArgs as p, type GetSubscriptionArgs as q, type InstanceDeleteSubscriptionArgs as r, type InstanceUpdateSubscriptionArgs as s, type ListChannelEndpointsArgs as t, type ListNotificationsResponse as u, type ListSubscriptionsArgs as v, NotificationStatus as w, NovuError as x, type NovuOptions as y, type NovuSocketOptions as z };
@@ -1,7 +1,7 @@
1
1
  export * from 'json-logic-js';
2
- import { S as SeverityLevelEnum, T as TagsFilter, N as Notification, a as NotificationFilter } from './inbox-service-CEMMLHsX.mjs';
3
- export { B as BaseDeleteSubscriptionArgs, b as BaseUpdateSubscriptionArgs, C as ChannelConnectionResponse, c as ChannelEndpointResponse, d as ChannelPreference, e as ChannelType, f as Context, g as CreateChannelConnectionArgs, h as CreateChannelEndpointArgs, i as CreateSubscriptionArgs, D as DaySchedule, j as DefaultSchedule, k as DeleteChannelConnectionArgs, l as DeleteChannelEndpointArgs, m as DeleteSubscriptionArgs, E as EventHandler, n as Events, F as FiltersCountResponse, G as GenerateChatOAuthUrlArgs, o as GetChannelConnectionArgs, p as GetChannelEndpointArgs, q as GetSubscriptionArgs, I as InboxNotification, r as InstanceDeleteSubscriptionArgs, s as InstanceUpdateSubscriptionArgs, L as ListChannelConnectionsArgs, t as ListChannelEndpointsArgs, u as ListNotificationsResponse, v as ListSubscriptionsArgs, w as NotificationStatus, x as NovuError, y as NovuOptions, z as NovuSocketOptions, P as Preference, A as PreferenceFilter, H as PreferenceLevel, J as PreferencesResponse, K as Schedule, M as SocketEventNames, O as SocketTypeOption, Q as StandardNovuOptions, R as Subscriber, U as SubscriptionPreference, V as TagsFilterAndForm, W as TagsFilterOrGroup, X as TimeRange, Y as TopicSubscription, Z as UnreadCount, _ as UpdateSubscriptionArgs, $ as UpdateSubscriptionPreferenceArgs, a0 as WebSocketEvent, a1 as WeeklySchedule, a2 as WorkflowCriticalityEnum, a3 as WorkflowFilter, a4 as WorkflowGroupFilter, a5 as WorkflowIdentifierOrId } from './inbox-service-CEMMLHsX.mjs';
4
- export { N as Novu } from './novu-BlonRpYH.mjs';
2
+ import { S as SeverityLevelEnum, T as TagsFilter, N as Notification, a as NotificationFilter } from './inbox-service-CGCuuYnv.mjs';
3
+ export { B as BaseDeleteSubscriptionArgs, b as BaseUpdateSubscriptionArgs, C as ChannelConnectionResponse, c as ChannelEndpointResponse, d as ChannelPreference, e as ChannelType, f as Context, g as CreateChannelConnectionArgs, h as CreateChannelEndpointArgs, i as CreateSubscriptionArgs, D as DaySchedule, j as DefaultSchedule, k as DeleteChannelConnectionArgs, l as DeleteChannelEndpointArgs, m as DeleteSubscriptionArgs, E as EventHandler, n as Events, F as FiltersCountResponse, G as GenerateChatOAuthUrlArgs, o as GetChannelConnectionArgs, p as GetChannelEndpointArgs, q as GetSubscriptionArgs, I as InboxNotification, r as InstanceDeleteSubscriptionArgs, s as InstanceUpdateSubscriptionArgs, L as ListChannelConnectionsArgs, t as ListChannelEndpointsArgs, u as ListNotificationsResponse, v as ListSubscriptionsArgs, w as NotificationStatus, x as NovuError, y as NovuOptions, z as NovuSocketOptions, P as Preference, A as PreferenceFilter, H as PreferenceLevel, J as PreferencesResponse, K as Schedule, M as SocketEventNames, O as SocketTypeOption, Q as StandardNovuOptions, R as Subscriber, U as SubscriptionPreference, V as TagsFilterAndForm, W as TagsFilterOrGroup, X as TimeRange, Y as TopicSubscription, Z as UnreadCount, _ as UpdateSubscriptionArgs, $ as UpdateSubscriptionPreferenceArgs, a0 as WebSocketEvent, a1 as WeeklySchedule, a2 as WorkflowCriticalityEnum, a3 as WorkflowFilter, a4 as WorkflowGroupFilter, a5 as WorkflowIdentifierOrId } from './inbox-service-CGCuuYnv.mjs';
4
+ export { N as Novu } from './novu-CFYEiYN8.mjs';
5
5
 
6
6
  /**
7
7
  * Normalizes inbox tag filters to CNF: `string[][]` where each inner array is one OR-group.
@@ -11,6 +11,19 @@ declare function normalizeTagGroups(tags: TagsFilter | undefined): string[][];
11
11
  declare const areTagsEqual: (tags1?: TagsFilter, tags2?: TagsFilter) => boolean;
12
12
  declare const areSeveritiesEqual: (el1?: SeverityLevelEnum | SeverityLevelEnum[], el2?: SeverityLevelEnum | SeverityLevelEnum[]) => boolean;
13
13
  declare const isSameFilter: (filter1: NotificationFilter, filter2: NotificationFilter) => boolean;
14
+ /**
15
+ * Check whether a notification's `data` matches the supplied filter shape.
16
+ *
17
+ * Supports per-key:
18
+ * - scalar (exact equality)
19
+ * - `Scalar[]` (OR — match any)
20
+ * - `{ or: Scalar[] }` (explicit OR)
21
+ * - `{ and: [{ or: Scalar[] }, ...] }` (AND of OR-groups)
22
+ * - 1 level of nested objects whose sub-keys follow the same rules
23
+ *
24
+ * Mirrors the server-side semantics from `@novu/shared#checkDataFilterMatches`
25
+ * so realtime, cache, and counts stay consistent.
26
+ */
14
27
  declare function checkNotificationDataFilter(notificationData: Notification['data'], filterData: NotificationFilter['data']): boolean;
15
28
  /**
16
29
  * Complete notification filter check combining all criteria.
@@ -1,3 +1,3 @@
1
- export { Novu, SubscriptionPreference, TopicSubscription, areSeveritiesEqual, areTagsEqual, checkNotificationDataFilter, checkNotificationMatchesFilter, isSameFilter, normalizeTagGroups } from './chunk-FBE56J52.mjs';
1
+ export { Novu, SubscriptionPreference, TopicSubscription, areSeveritiesEqual, areTagsEqual, checkNotificationDataFilter, checkNotificationMatchesFilter, isSameFilter, normalizeTagGroups } from './chunk-BKA3HRZM.mjs';
2
2
  export { ChannelType, NotificationStatus, NovuError, PreferenceLevel, SeverityLevelEnum, WebSocketEvent, WorkflowCriticalityEnum } from './chunk-4S22IB5W.mjs';
3
3
  import './chunk-STZMOEWR.mjs';
@@ -1,4 +1,4 @@
1
- import { f as Context, R as Subscriber, a8 as NovuEventEmitter, a7 as InboxService, I as InboxNotification, N as Notification } from '../inbox-service-CEMMLHsX.mjs';
1
+ import { f as Context, R as Subscriber, a8 as NovuEventEmitter, a7 as InboxService, I as InboxNotification, N as Notification } from '../inbox-service-CGCuuYnv.mjs';
2
2
  import 'json-logic-js';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { a7 as InboxService, a8 as NovuEventEmitter, a9 as Session, aa as Result, ab as ScheduleCache, K as Schedule, ac as UpdateScheduleArgs, ad as PreferencesCache, ae as ListPreferencesArgs, P as Preference, af as BasePreferenceArgs, ag as InstancePreferenceArgs, ah as ListNotificationsArgs, u as ListNotificationsResponse, I as InboxNotification, N as Notification, a as NotificationFilter, ai as FilterCountArgs, aj as FilterCountResponse, ak as FiltersCountArgs, F as FiltersCountResponse, al as BaseArgs, am as InstanceArgs, an as SnoozeArgs, G as GenerateChatOAuthUrlArgs, L as ListChannelConnectionsArgs, C as ChannelConnectionResponse, o as GetChannelConnectionArgs, k as DeleteChannelConnectionArgs, t as ListChannelEndpointsArgs, c as ChannelEndpointResponse, p as GetChannelEndpointArgs, h as CreateChannelEndpointArgs, l as DeleteChannelEndpointArgs, ao as SubscriptionsCache, R as Subscriber, v as ListSubscriptionsArgs, ap as Options, Y as TopicSubscription, q as GetSubscriptionArgs, i as CreateSubscriptionArgs, b as BaseUpdateSubscriptionArgs, s as InstanceUpdateSubscriptionArgs, B as BaseDeleteSubscriptionArgs, r as InstanceDeleteSubscriptionArgs, M as SocketEventNames, aq as EventNames, E as EventHandler, n as Events, ar as ContextValue, y as NovuOptions, f as Context } from './inbox-service-CEMMLHsX.js';
1
+ import { a7 as InboxService, a8 as NovuEventEmitter, a9 as Session, aa as Result, ab as ScheduleCache, K as Schedule, ac as UpdateScheduleArgs, ad as PreferencesCache, ae as ListPreferencesArgs, P as Preference, af as BasePreferenceArgs, ag as InstancePreferenceArgs, ah as ListNotificationsArgs, u as ListNotificationsResponse, I as InboxNotification, N as Notification, a as NotificationFilter, ai as FilterCountArgs, aj as FilterCountResponse, ak as FiltersCountArgs, F as FiltersCountResponse, al as BaseArgs, am as InstanceArgs, an as SnoozeArgs, G as GenerateChatOAuthUrlArgs, ao as GenerateConnectOAuthUrlArgs, L as ListChannelConnectionsArgs, C as ChannelConnectionResponse, o as GetChannelConnectionArgs, k as DeleteChannelConnectionArgs, ap as GenerateLinkUserOAuthUrlArgs, t as ListChannelEndpointsArgs, c as ChannelEndpointResponse, p as GetChannelEndpointArgs, h as CreateChannelEndpointArgs, l as DeleteChannelEndpointArgs, aq as SubscriptionsCache, R as Subscriber, v as ListSubscriptionsArgs, ar as Options, Y as TopicSubscription, q as GetSubscriptionArgs, i as CreateSubscriptionArgs, b as BaseUpdateSubscriptionArgs, s as InstanceUpdateSubscriptionArgs, B as BaseDeleteSubscriptionArgs, r as InstanceDeleteSubscriptionArgs, M as SocketEventNames, as as EventNames, E as EventHandler, n as Events, at as ContextValue, y as NovuOptions, f as Context } from './inbox-service-CGCuuYnv.mjs';
2
2
 
3
3
  declare class BaseModule {
4
4
  #private;
@@ -135,9 +135,15 @@ declare class ChannelConnections extends BaseModule {
135
135
  inboxServiceInstance: InboxService;
136
136
  eventEmitterInstance: NovuEventEmitter;
137
137
  });
138
+ /**
139
+ * @deprecated Use generateConnectOAuthUrl() instead. For user-level linking use channelEndpoints.generateLinkUserOAuthUrl().
140
+ */
138
141
  generateOAuthUrl(args: GenerateChatOAuthUrlArgs): Result<{
139
142
  url: string;
140
143
  }>;
144
+ generateConnectOAuthUrl(args: GenerateConnectOAuthUrlArgs): Result<{
145
+ url: string;
146
+ }>;
141
147
  list(args?: ListChannelConnectionsArgs): Result<ChannelConnectionResponse[]>;
142
148
  get(args: GetChannelConnectionArgs): Result<ChannelConnectionResponse | null>;
143
149
  delete(args: DeleteChannelConnectionArgs): Result<void>;
@@ -148,6 +154,9 @@ declare class ChannelEndpoints extends BaseModule {
148
154
  inboxServiceInstance: InboxService;
149
155
  eventEmitterInstance: NovuEventEmitter;
150
156
  });
157
+ generateLinkUserOAuthUrl(args: GenerateLinkUserOAuthUrlArgs): Result<{
158
+ url: string;
159
+ }>;
151
160
  list(args?: ListChannelEndpointsArgs): Result<ChannelEndpointResponse[]>;
152
161
  get(args: GetChannelEndpointArgs): Result<ChannelEndpointResponse | null>;
153
162
  create(args: CreateChannelEndpointArgs): Result<ChannelEndpointResponse>;
@@ -1,7 +1,7 @@
1
- import { L as InboxTheme, a3 as SubscriptionTheme } from '../types-B29Y1SQy.mjs';
2
- import '../inbox-service-CEMMLHsX.mjs';
1
+ import { L as InboxTheme, a6 as SubscriptionTheme } from '../types-CJKmgwu6.mjs';
2
+ import '../inbox-service-CGCuuYnv.mjs';
3
3
  import 'json-logic-js';
4
- import '../novu-BlonRpYH.mjs';
4
+ import '../novu-CFYEiYN8.mjs';
5
5
 
6
6
  declare const inboxDarkTheme: InboxTheme;
7
7
  /**