@novu/js 3.3.0 → 3.4.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.
@@ -62,7 +62,7 @@ var isSameFilter = (filter1, filter2) => {
62
62
  // src/api/http-client.ts
63
63
  var DEFAULT_API_VERSION = "v1";
64
64
  var DEFAULT_BACKEND_URL = "https://api.novu.co";
65
- var DEFAULT_USER_AGENT = `${"@novu/js"}@${"3.3.0"}`;
65
+ var DEFAULT_USER_AGENT = `${"@novu/js"}@${"3.4.0"}`;
66
66
  var HttpClient = class {
67
67
  constructor(options = {}) {
68
68
  const {
@@ -280,6 +280,9 @@ var InboxService = class {
280
280
  const query = queryParams.size ? `?${queryParams.toString()}` : "";
281
281
  return chunk7B52C2XE_js.__privateGet(this, _httpClient).get(`${INBOX_ROUTE}/preferences${query}`);
282
282
  }
283
+ bulkUpdatePreferences(preferences) {
284
+ return chunk7B52C2XE_js.__privateGet(this, _httpClient).patch(`${INBOX_ROUTE}/preferences/bulk`, { preferences });
285
+ }
283
286
  updateGlobalPreferences(channels) {
284
287
  return chunk7B52C2XE_js.__privateGet(this, _httpClient).patch(`${INBOX_ROUTE}/preferences`, channels);
285
288
  }
@@ -1355,11 +1358,13 @@ var updatePreference = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function*
1355
1358
  useCache,
1356
1359
  args
1357
1360
  }) {
1358
- const { workflowId, channels } = args;
1361
+ var _a;
1362
+ const { channels } = args;
1363
+ const workflowId = "workflowId" in args ? args.workflowId : (_a = args.preference.workflow) == null ? void 0 : _a.id;
1359
1364
  try {
1360
1365
  emitter.emit("preference.update.pending", {
1361
1366
  args,
1362
- data: args.preference ? new Preference(
1367
+ data: "preference" in args ? new Preference(
1363
1368
  chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, args.preference), {
1364
1369
  channels: chunk7B52C2XE_js.__spreadValues(chunk7B52C2XE_js.__spreadValues({}, args.preference.channels), channels)
1365
1370
  }),
@@ -1388,7 +1393,58 @@ var updatePreference = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function*
1388
1393
  return { data: preference };
1389
1394
  } catch (error) {
1390
1395
  emitter.emit("preference.update.resolved", { args, error });
1391
- return { error: new NovuError("Failed to fetch notifications", error) };
1396
+ return { error: new NovuError("Failed to update preference", error) };
1397
+ }
1398
+ });
1399
+ var bulkUpdatePreference = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
1400
+ emitter,
1401
+ apiService,
1402
+ cache,
1403
+ useCache,
1404
+ args
1405
+ }) {
1406
+ const globalPreference = args.find((arg) => "preference" in arg && arg.preference.level === "global" /* GLOBAL */);
1407
+ if (globalPreference) {
1408
+ return { error: new NovuError("Global preference is not supported in bulk update", "") };
1409
+ }
1410
+ try {
1411
+ const optimisticallyUpdatedPreferences = args.map(
1412
+ (arg) => "preference" in arg ? new Preference(
1413
+ chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, arg.preference), {
1414
+ channels: chunk7B52C2XE_js.__spreadValues(chunk7B52C2XE_js.__spreadValues({}, arg.preference.channels), arg.channels)
1415
+ }),
1416
+ {
1417
+ emitterInstance: emitter,
1418
+ inboxServiceInstance: apiService,
1419
+ cache,
1420
+ useCache
1421
+ }
1422
+ ) : void 0
1423
+ ).filter((el) => el !== void 0);
1424
+ emitter.emit("preferences.bulk_update.pending", {
1425
+ args,
1426
+ data: optimisticallyUpdatedPreferences
1427
+ });
1428
+ const preferencesToUpdate = args.map((arg) => {
1429
+ var _a, _b, _c, _d;
1430
+ return chunk7B52C2XE_js.__spreadValues({
1431
+ workflowId: "workflowId" in arg ? arg.workflowId : (_d = (_c = (_a = arg.preference.workflow) == null ? void 0 : _a.id) != null ? _c : (_b = arg.preference.workflow) == null ? void 0 : _b.identifier) != null ? _d : ""
1432
+ }, arg.channels);
1433
+ });
1434
+ const response = yield apiService.bulkUpdatePreferences(preferencesToUpdate);
1435
+ const preferences = response.map(
1436
+ (el) => new Preference(el, {
1437
+ emitterInstance: emitter,
1438
+ inboxServiceInstance: apiService,
1439
+ cache,
1440
+ useCache
1441
+ })
1442
+ );
1443
+ emitter.emit("preferences.bulk_update.resolved", { args, data: preferences });
1444
+ return { data: preferences };
1445
+ } catch (error) {
1446
+ emitter.emit("preferences.bulk_update.resolved", { args, error });
1447
+ return { error: new NovuError("Failed to bulk update preferences", error) };
1392
1448
  }
1393
1449
  });
1394
1450
  var optimisticUpdateWorkflowPreferences = ({
@@ -1400,7 +1456,7 @@ var optimisticUpdateWorkflowPreferences = ({
1400
1456
  }) => {
1401
1457
  const allPreferences = useCache ? cache == null ? void 0 : cache.getAll({}) : void 0;
1402
1458
  allPreferences == null ? void 0 : allPreferences.forEach((el) => {
1403
- var _a;
1459
+ var _a, _b;
1404
1460
  if (el.level === "template" /* TEMPLATE */) {
1405
1461
  const mergedPreference = chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, el), {
1406
1462
  channels: Object.entries(el.channels).reduce((acc, [key, value]) => {
@@ -1410,7 +1466,7 @@ var optimisticUpdateWorkflowPreferences = ({
1410
1466
  return acc;
1411
1467
  }, {})
1412
1468
  });
1413
- const updatedPreference = args.preference ? new Preference(mergedPreference, {
1469
+ const updatedPreference = "preference" in args ? new Preference(mergedPreference, {
1414
1470
  emitterInstance: emitter,
1415
1471
  inboxServiceInstance: apiService,
1416
1472
  cache,
@@ -1419,7 +1475,7 @@ var optimisticUpdateWorkflowPreferences = ({
1419
1475
  if (updatedPreference) {
1420
1476
  emitter.emit("preference.update.pending", {
1421
1477
  args: {
1422
- workflowId: (_a = el.workflow) == null ? void 0 : _a.id,
1478
+ workflowId: (_b = (_a = el.workflow) == null ? void 0 : _a.id) != null ? _b : "",
1423
1479
  channels: updatedPreference.channels
1424
1480
  },
1425
1481
  data: updatedPreference
@@ -1453,7 +1509,6 @@ var Preference = class {
1453
1509
  }
1454
1510
  update({
1455
1511
  channels,
1456
- /** @deprecated Use channels instead */
1457
1512
  channelPreferences
1458
1513
  }) {
1459
1514
  var _a;
@@ -1465,12 +1520,7 @@ var Preference = class {
1465
1520
  args: {
1466
1521
  workflowId: (_a = this.workflow) == null ? void 0 : _a.id,
1467
1522
  channels: channels || channelPreferences,
1468
- preference: {
1469
- level: this.level,
1470
- enabled: this.enabled,
1471
- channels: this.channels,
1472
- workflow: this.workflow
1473
- }
1523
+ preference: this
1474
1524
  }
1475
1525
  });
1476
1526
  }
@@ -1481,7 +1531,12 @@ _cache3 = new WeakMap();
1481
1531
  _useCache2 = new WeakMap();
1482
1532
 
1483
1533
  // src/cache/preferences-cache.ts
1484
- var updateEvents2 = ["preference.update.pending", "preference.update.resolved"];
1534
+ var updateEvents2 = [
1535
+ "preference.update.pending",
1536
+ "preference.update.resolved",
1537
+ "preferences.bulk_update.pending",
1538
+ "preferences.bulk_update.resolved"
1539
+ ];
1485
1540
  var excludeEmpty2 = ({ tags }) => Object.entries({ tags }).reduce((acc, [key, value]) => {
1486
1541
  if (value === null || value === void 0 || Array.isArray(value) && value.length === 0) {
1487
1542
  return acc;
@@ -1520,14 +1575,22 @@ var PreferencesCache = class {
1520
1575
  if (!data) {
1521
1576
  return;
1522
1577
  }
1578
+ const preferences = Array.isArray(data) ? data : [data];
1579
+ const uniqueFilterKeys = /* @__PURE__ */ new Set();
1523
1580
  chunk7B52C2XE_js.__privateGet(this, _cache4).keys().forEach((key) => {
1524
- const hasUpdatedPreference = this.updatePreference(key, data);
1525
- const updatedPreference = chunk7B52C2XE_js.__privateGet(this, _cache4).get(key);
1526
- if (!hasUpdatedPreference || !updatedPreference) {
1527
- return;
1528
- }
1581
+ preferences.forEach((preference) => {
1582
+ const hasUpdatedPreference = this.updatePreference(key, preference);
1583
+ const updatedPreference = chunk7B52C2XE_js.__privateGet(this, _cache4).get(key);
1584
+ if (!hasUpdatedPreference || !updatedPreference) {
1585
+ return;
1586
+ }
1587
+ uniqueFilterKeys.add(key);
1588
+ });
1589
+ });
1590
+ uniqueFilterKeys.forEach((key) => {
1591
+ var _a;
1529
1592
  chunk7B52C2XE_js.__privateGet(this, _emitter4).emit("preferences.list.updated", {
1530
- data: updatedPreference
1593
+ data: (_a = chunk7B52C2XE_js.__privateGet(this, _cache4).get(key)) != null ? _a : []
1531
1594
  });
1532
1595
  });
1533
1596
  };
@@ -1603,6 +1666,32 @@ var Preferences = class extends BaseModule {
1603
1666
  }));
1604
1667
  });
1605
1668
  }
1669
+ update(args) {
1670
+ return chunk7B52C2XE_js.__async(this, null, function* () {
1671
+ return this.callWithSession(
1672
+ () => updatePreference({
1673
+ emitter: this._emitter,
1674
+ apiService: this._inboxService,
1675
+ cache: this.cache,
1676
+ useCache: chunk7B52C2XE_js.__privateGet(this, _useCache3),
1677
+ args
1678
+ })
1679
+ );
1680
+ });
1681
+ }
1682
+ bulkUpdate(args) {
1683
+ return chunk7B52C2XE_js.__async(this, null, function* () {
1684
+ return this.callWithSession(
1685
+ () => bulkUpdatePreference({
1686
+ emitter: this._emitter,
1687
+ apiService: this._inboxService,
1688
+ cache: this.cache,
1689
+ useCache: chunk7B52C2XE_js.__privateGet(this, _useCache3),
1690
+ args
1691
+ })
1692
+ );
1693
+ });
1694
+ }
1606
1695
  };
1607
1696
  _useCache3 = new WeakMap();
1608
1697
 
@@ -1,5 +1,5 @@
1
- import { N as NotificationFilter } from './novu-DJTVB7VN.js';
2
- export { C as ChannelPreference, c as ChannelType, E as EventHandler, a as Events, F as FiltersCountResponse, I as InboxNotification, L as ListNotificationsResponse, d as Notification, e as NotificationStatus, b as Novu, f as NovuError, g as NovuOptions, P as Preference, h as PreferenceLevel, i as PreferencesResponse, S as SocketEventNames, j as Subscriber, W as WebSocketEvent } from './novu-DJTVB7VN.js';
1
+ import { N as NotificationFilter } from './novu-Nrvpy3Z1.js';
2
+ export { C as ChannelPreference, c as ChannelType, E as EventHandler, a as Events, F as FiltersCountResponse, I as InboxNotification, L as ListNotificationsResponse, d as Notification, e as NotificationStatus, b as Novu, f as NovuError, g as NovuOptions, P as Preference, h as PreferenceLevel, i as PreferencesResponse, S as SocketEventNames, j as Subscriber, W as WebSocketEvent } from './novu-Nrvpy3Z1.js';
3
3
 
4
4
  declare const areTagsEqual: (tags1?: string[], tags2?: string[]) => boolean;
5
5
  declare const isSameFilter: (filter1: NotificationFilter, filter2: NotificationFilter) => boolean;
package/dist/cjs/index.js CHANGED
@@ -1,35 +1,35 @@
1
1
  'use strict';
2
2
 
3
- var chunkKIOGWIKT_js = require('./chunk-KIOGWIKT.js');
3
+ var chunkWZT5QCVB_js = require('./chunk-WZT5QCVB.js');
4
4
  require('./chunk-7B52C2XE.js');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, "ChannelType", {
9
9
  enumerable: true,
10
- get: function () { return chunkKIOGWIKT_js.ChannelType; }
10
+ get: function () { return chunkWZT5QCVB_js.ChannelType; }
11
11
  });
12
12
  Object.defineProperty(exports, "NotificationStatus", {
13
13
  enumerable: true,
14
- get: function () { return chunkKIOGWIKT_js.NotificationStatus; }
14
+ get: function () { return chunkWZT5QCVB_js.NotificationStatus; }
15
15
  });
16
16
  Object.defineProperty(exports, "Novu", {
17
17
  enumerable: true,
18
- get: function () { return chunkKIOGWIKT_js.Novu; }
18
+ get: function () { return chunkWZT5QCVB_js.Novu; }
19
19
  });
20
20
  Object.defineProperty(exports, "PreferenceLevel", {
21
21
  enumerable: true,
22
- get: function () { return chunkKIOGWIKT_js.PreferenceLevel; }
22
+ get: function () { return chunkWZT5QCVB_js.PreferenceLevel; }
23
23
  });
24
24
  Object.defineProperty(exports, "WebSocketEvent", {
25
25
  enumerable: true,
26
- get: function () { return chunkKIOGWIKT_js.WebSocketEvent; }
26
+ get: function () { return chunkWZT5QCVB_js.WebSocketEvent; }
27
27
  });
28
28
  Object.defineProperty(exports, "areTagsEqual", {
29
29
  enumerable: true,
30
- get: function () { return chunkKIOGWIKT_js.areTagsEqual; }
30
+ get: function () { return chunkWZT5QCVB_js.areTagsEqual; }
31
31
  });
32
32
  Object.defineProperty(exports, "isSameFilter", {
33
33
  enumerable: true,
34
- get: function () { return chunkKIOGWIKT_js.isSameFilter; }
34
+ get: function () { return chunkWZT5QCVB_js.isSameFilter; }
35
35
  });
@@ -6,18 +6,15 @@ declare class NovuError extends Error {
6
6
  type ListPreferencesArgs = {
7
7
  tags?: string[];
8
8
  };
9
- type UpdatePreferencesArgs = {
10
- workflowId?: string;
9
+ type BasePreferenceArgs = {
10
+ workflowId: string;
11
11
  channels: ChannelPreference;
12
- /** @deprecated Use channels instead */
13
- channelPreferences?: ChannelPreference;
14
- preference?: {
15
- level: PreferenceLevel;
16
- enabled: boolean;
17
- channels: ChannelPreference;
18
- workflow?: Workflow;
19
- };
20
12
  };
13
+ type InstancePreferenceArgs = {
14
+ preference: Preference;
15
+ channels: ChannelPreference;
16
+ };
17
+ type UpdatePreferenceArgs = BasePreferenceArgs | InstancePreferenceArgs;
21
18
 
22
19
  declare class PreferencesCache {
23
20
  #private;
@@ -45,9 +42,10 @@ declare class Preference {
45
42
  cache: PreferencesCache;
46
43
  useCache: boolean;
47
44
  });
48
- update({ channels,
49
- /** @deprecated Use channels instead */
50
- channelPreferences, }: Prettify<Pick<UpdatePreferencesArgs, 'channels' | 'channelPreferences'>>): Result<Preference>;
45
+ update({ channels, channelPreferences, }: Prettify<Pick<UpdatePreferenceArgs, 'channels'> & {
46
+ /** @deprecated Use channels instead */
47
+ channelPreferences?: ChannelPreference;
48
+ }>): Result<Preference>;
51
49
  }
52
50
 
53
51
  declare global {
@@ -265,6 +263,9 @@ declare class InboxService {
265
263
  actionType: ActionTypeEnum;
266
264
  }): Promise<InboxNotification>;
267
265
  fetchPreferences(tags?: string[]): Promise<PreferencesResponse[]>;
266
+ bulkUpdatePreferences(preferences: Array<{
267
+ workflowId: string;
268
+ } & ChannelPreference>): Promise<PreferencesResponse[]>;
268
269
  updateGlobalPreferences(channels: ChannelPreference): Promise<PreferencesResponse>;
269
270
  updateWorkflowPreferences({ workflowId, channels, }: {
270
271
  workflowId: string;
@@ -490,7 +491,8 @@ type NotificationsReadArchivedAllEvents = BaseEvents<'notifications.archive_all_
490
491
  tags?: string[];
491
492
  }, Notification[]>;
492
493
  type PreferencesFetchEvents = BaseEvents<'preferences.list', ListPreferencesArgs, Preference[]>;
493
- type PreferenceUpdateEvents = BaseEvents<'preference.update', UpdatePreferencesArgs, Preference>;
494
+ type PreferenceUpdateEvents = BaseEvents<'preference.update', UpdatePreferenceArgs, Preference>;
495
+ type PreferencesBulkUpdateEvents = BaseEvents<'preferences.bulk_update', Array<UpdatePreferenceArgs>, Preference[]>;
494
496
  type SocketConnectEvents = BaseEvents<'socket.connect', {
495
497
  socketUrl: string;
496
498
  }, undefined>;
@@ -530,7 +532,7 @@ type Events = SessionInitializeEvents & NotificationsFetchEvents & {
530
532
  'preferences.list.updated': {
531
533
  data: Preference[];
532
534
  };
533
- } & PreferenceUpdateEvents & SocketConnectEvents & SocketEvents & NotificationReadEvents & NotificationUnreadEvents & NotificationArchiveEvents & NotificationUnarchiveEvents & NotificationSnoozeEvents & NotificationUnsnoozeEvents & NotificationCompleteActionEvents & NotificationRevertActionEvents & NotificationsReadAllEvents & NotificationsArchivedAllEvents & NotificationsReadArchivedAllEvents;
535
+ } & PreferenceUpdateEvents & PreferencesBulkUpdateEvents & SocketConnectEvents & SocketEvents & NotificationReadEvents & NotificationUnreadEvents & NotificationArchiveEvents & NotificationUnarchiveEvents & NotificationSnoozeEvents & NotificationUnsnoozeEvents & NotificationCompleteActionEvents & NotificationRevertActionEvents & NotificationsReadAllEvents & NotificationsArchivedAllEvents & NotificationsReadArchivedAllEvents;
534
536
  type EventNames = keyof Events;
535
537
  type SocketEventNames = keyof SocketEvents;
536
538
  type EventHandler<T = unknown> = (event: T) => void;
@@ -552,6 +554,10 @@ declare class Preferences extends BaseModule {
552
554
  eventEmitterInstance: NovuEventEmitter;
553
555
  });
554
556
  list(args?: ListPreferencesArgs): Result<Preference[]>;
557
+ update(args: BasePreferenceArgs): Result<Preference>;
558
+ update(args: InstancePreferenceArgs): Result<Preference>;
559
+ bulkUpdate(args: Array<BasePreferenceArgs>): Result<Preference[]>;
560
+ bulkUpdate(args: Array<InstancePreferenceArgs>): Result<Preference[]>;
555
561
  }
556
562
 
557
563
  declare class Socket extends BaseModule {
@@ -1,5 +1,5 @@
1
- import { j as Theme } from '../types-BPv1rvbm.js';
2
- import '../novu-DJTVB7VN.js';
1
+ import { m as Theme } from '../types-Bj3h0WFq.js';
2
+ import '../novu-Nrvpy3Z1.js';
3
3
 
4
4
  declare const dark: Theme;
5
5
 
@@ -1,6 +1,6 @@
1
- import { d as Notification, N as NotificationFilter, g as NovuOptions, b as Novu } from './novu-DJTVB7VN.js';
1
+ import { d as Notification, N as NotificationFilter, g as NovuOptions, b as Novu, P as Preference } from './novu-Nrvpy3Z1.js';
2
2
 
3
- declare const appearanceKeys: readonly ["button", "input", "icon", "badge", "popoverContent", "popoverTrigger", "popoverClose", "dropdownContent", "dropdownTrigger", "dropdownItem", "dropdownItemLabel", "dropdownItemLabelContainer", "dropdownItemLeft__icon", "dropdownItemRight__icon", "dropdownItem__icon", "collapsible", "tooltipContent", "tooltipTrigger", "datePicker", "datePickerGrid", "datePickerGridRow", "datePickerGridCell", "datePickerGridCellTrigger", "datePickerTrigger", "datePickerGridHeader", "datePickerControl", "datePickerControlPrevTrigger", "datePickerControlNextTrigger", "datePickerControlPrevTrigger__icon", "datePickerControlNextTrigger__icon", "datePickerCalendar", "datePickerHeaderMonth", "datePickerCalendarDay__button", "timePicker", "timePicker__hourSelect", "timePicker__minuteSelect", "timePicker__periodSelect", "timePicker__separator", "timePickerHour__input", "timePickerMinute__input", "snoozeDatePicker", "snoozeDatePicker__actions", "snoozeDatePickerCancel__button", "snoozeDatePickerApply__button", "snoozeDatePicker__timePickerContainer", "snoozeDatePicker__timePickerLabel", "back__button", "skeletonText", "skeletonAvatar", "skeletonSwitch", "skeletonSwitchThumb", "tabsRoot", "tabsList", "tabsContent", "tabsTrigger", "dots", "root", "bellIcon", "bellContainer", "bellDot", "preferences__button", "preferencesContainer", "inboxHeader", "loading", "inboxContent", "inbox__popoverTrigger", "inbox__popoverContent", "notificationListContainer", "notificationList", "notificationListEmptyNoticeContainer", "notificationListEmptyNoticeOverlay", "notificationListEmptyNoticeIcon", "notificationListEmptyNotice", "notificationList__skeleton", "notificationList__skeletonContent", "notificationList__skeletonItem", "notificationList__skeletonAvatar", "notificationList__skeletonText", "notificationListNewNotificationsNotice__button", "notification", "notificationContent", "notificationTextContainer", "notificationDot", "notificationSubject", "notificationSubject__strong", "notificationBody", "notificationBody__strong", "notificationBodyContainer", "notificationImage", "notificationImageLoadingFallback", "notificationDate", "notificationDateActionsContainer", "notificationDefaultActions", "notificationCustomActions", "notificationPrimaryAction__button", "notificationSecondaryAction__button", "notificationRead__button", "notificationUnread__button", "notificationArchive__button", "notificationUnarchive__button", "notificationSnooze__button", "notificationUnsnooze__button", "notificationRead__icon", "notificationUnread__icon", "notificationArchive__icon", "notificationUnarchive__icon", "notificationSnooze__icon", "notificationUnsnooze__icon", "notificationsTabs__tabsRoot", "notificationsTabs__tabsList", "notificationsTabs__tabsContent", "notificationsTabs__tabsTrigger", "notificationsTabsTriggerLabel", "notificationsTabsTriggerCount", "inboxStatus__title", "inboxStatus__dropdownTrigger", "inboxStatus__dropdownContent", "inboxStatus__dropdownItem", "inboxStatus__dropdownItemLabel", "inboxStatus__dropdownItemLabelContainer", "inboxStatus__dropdownItemLeft__icon", "inboxStatus__dropdownItemRight__icon", "inboxStatus__dropdownItem__icon", "inboxStatus__dropdownItemCheck__icon", "moreActionsContainer", "moreActions__dropdownTrigger", "moreActions__dropdownContent", "moreActions__dropdownItem", "moreActions__dropdownItemLabel", "moreActions__dropdownItemLeft__icon", "moreActions__dots", "moreTabs__button", "moreTabs__icon", "moreTabs__dropdownTrigger", "moreTabs__dropdownContent", "moreTabs__dropdownItem", "moreTabs__dropdownItemLabel", "moreTabs__dropdownItemRight__icon", "workflowContainer", "workflowLabel", "workflowLabelHeader", "workflowLabelContainer", "workflowContainerDisabledNotice", "workflowLabelDisabled__icon", "workflowContainerRight__icon", "workflowArrow__icon", "workflowDescription", "channelContainer", "channelIconContainer", "channel__icon", "channelsContainerCollapsible", "channelsContainer", "channelLabel", "channelLabelContainer", "channelName", "channelSwitchContainer", "channelSwitch", "channelSwitchThumb", "preferencesHeader", "preferencesHeader__back__button", "preferencesHeader__back__button__icon", "preferencesHeader__title", "preferencesHeader__icon", "preferencesListEmptyNoticeContainer", "preferencesListEmptyNotice", "preferencesList__skeleton", "preferencesList__skeletonContent", "preferencesList__skeletonItem", "preferencesList__skeletonIcon", "preferencesList__skeletonSwitch", "preferencesList__skeletonSwitchThumb", "preferencesList__skeletonText", "notificationSnooze__dropdownContent", "notificationSnooze__dropdownItem", "notificationSnooze__dropdownItem__icon", "notificationSnoozeCustomTime_popoverContent", "notificationDeliveredAt__badge", "notificationDeliveredAt__icon", "notificationSnoozedUntil__icon", "strong"];
3
+ declare const appearanceKeys: readonly ["button", "input", "icon", "badge", "popoverContent", "popoverTrigger", "popoverClose", "dropdownContent", "dropdownTrigger", "dropdownItem", "dropdownItemLabel", "dropdownItemLabelContainer", "dropdownItemLeft__icon", "dropdownItemRight__icon", "dropdownItem__icon", "collapsible", "tooltipContent", "tooltipTrigger", "datePicker", "datePickerGrid", "datePickerGridRow", "datePickerGridCell", "datePickerGridCellTrigger", "datePickerTrigger", "datePickerGridHeader", "datePickerControl", "datePickerControlPrevTrigger", "datePickerControlNextTrigger", "datePickerControlPrevTrigger__icon", "datePickerControlNextTrigger__icon", "datePickerCalendar", "datePickerHeaderMonth", "datePickerCalendarDay__button", "timePicker", "timePicker__hourSelect", "timePicker__minuteSelect", "timePicker__periodSelect", "timePicker__separator", "timePickerHour__input", "timePickerMinute__input", "snoozeDatePicker", "snoozeDatePicker__actions", "snoozeDatePickerCancel__button", "snoozeDatePickerApply__button", "snoozeDatePicker__timePickerContainer", "snoozeDatePicker__timePickerLabel", "back__button", "skeletonText", "skeletonAvatar", "skeletonSwitch", "skeletonSwitchThumb", "tabsRoot", "tabsList", "tabsContent", "tabsTrigger", "dots", "root", "bellIcon", "bellContainer", "bellDot", "preferences__button", "preferencesContainer", "inboxHeader", "loading", "inboxContent", "inbox__popoverTrigger", "inbox__popoverContent", "notificationListContainer", "notificationList", "notificationListEmptyNoticeContainer", "notificationListEmptyNoticeOverlay", "notificationListEmptyNoticeIcon", "notificationListEmptyNotice", "notificationList__skeleton", "notificationList__skeletonContent", "notificationList__skeletonItem", "notificationList__skeletonAvatar", "notificationList__skeletonText", "notificationListNewNotificationsNotice__button", "notification", "notificationContent", "notificationTextContainer", "notificationDot", "notificationSubject", "notificationSubject__strong", "notificationBody", "notificationBody__strong", "notificationBodyContainer", "notificationImage", "notificationImageLoadingFallback", "notificationDate", "notificationDateActionsContainer", "notificationDefaultActions", "notificationCustomActions", "notificationPrimaryAction__button", "notificationSecondaryAction__button", "notificationRead__button", "notificationUnread__button", "notificationArchive__button", "notificationUnarchive__button", "notificationSnooze__button", "notificationUnsnooze__button", "notificationRead__icon", "notificationUnread__icon", "notificationArchive__icon", "notificationUnarchive__icon", "notificationSnooze__icon", "notificationUnsnooze__icon", "notificationsTabs__tabsRoot", "notificationsTabs__tabsList", "notificationsTabs__tabsContent", "notificationsTabs__tabsTrigger", "notificationsTabsTriggerLabel", "notificationsTabsTriggerCount", "inboxStatus__title", "inboxStatus__dropdownTrigger", "inboxStatus__dropdownContent", "inboxStatus__dropdownItem", "inboxStatus__dropdownItemLabel", "inboxStatus__dropdownItemLabelContainer", "inboxStatus__dropdownItemLeft__icon", "inboxStatus__dropdownItemRight__icon", "inboxStatus__dropdownItem__icon", "inboxStatus__dropdownItemCheck__icon", "moreActionsContainer", "moreActions__dropdownTrigger", "moreActions__dropdownContent", "moreActions__dropdownItem", "moreActions__dropdownItemLabel", "moreActions__dropdownItemLeft__icon", "moreActions__dots", "moreTabs__button", "moreTabs__icon", "moreTabs__dropdownTrigger", "moreTabs__dropdownContent", "moreTabs__dropdownItem", "moreTabs__dropdownItemLabel", "moreTabs__dropdownItemRight__icon", "workflowContainer", "workflowLabel", "workflowLabelHeader", "workflowLabelHeaderContainer", "workflowLabelIcon", "workflowLabelContainer", "workflowContainerDisabledNotice", "workflowLabelDisabled__icon", "workflowContainerRight__icon", "workflowArrow__icon", "workflowDescription", "preferencesGroupContainer", "preferencesGroupHeader", "preferencesGroupLabelContainer", "preferencesGroupLabelIcon", "preferencesGroupLabel", "preferencesGroupActionsContainer", "preferencesGroupActionsContainerRight__icon", "preferencesGroupBody", "preferencesGroupChannels", "preferencesGroupInfo", "preferencesGroupInfoIcon", "preferencesGroupWorkflows", "channelContainer", "channelIconContainer", "channel__icon", "channelsContainerCollapsible", "channelsContainer", "channelLabel", "channelLabelContainer", "channelName", "channelSwitchContainer", "channelSwitch", "channelSwitchThumb", "preferencesHeader", "preferencesHeader__back__button", "preferencesHeader__back__button__icon", "preferencesHeader__title", "preferencesHeader__icon", "preferencesListEmptyNoticeContainer", "preferencesListEmptyNotice", "preferencesList__skeleton", "preferencesList__skeletonContent", "preferencesList__skeletonItem", "preferencesList__skeletonIcon", "preferencesList__skeletonSwitch", "preferencesList__skeletonSwitchThumb", "preferencesList__skeletonText", "notificationSnooze__dropdownContent", "notificationSnooze__dropdownItem", "notificationSnooze__dropdownItem__icon", "notificationSnoozeCustomTime_popoverContent", "notificationDeliveredAt__badge", "notificationDeliveredAt__icon", "notificationSnoozedUntil__icon", "strong"];
4
4
 
5
5
  declare const defaultLocalization: {
6
6
  readonly locale: "en-US";
@@ -31,6 +31,7 @@ declare const defaultLocalization: {
31
31
  readonly 'preferences.global': "Global Preferences";
32
32
  readonly 'preferences.workflow.disabled.notice': "Contact admin to enable subscription management for this critical notification.";
33
33
  readonly 'preferences.workflow.disabled.tooltip': "Contact admin to edit";
34
+ readonly 'preferences.group.info': "Applies to all notifications under this group.";
34
35
  readonly 'snooze.datePicker.timePickerLabel': "Time";
35
36
  readonly 'snooze.datePicker.apply': "Apply";
36
37
  readonly 'snooze.datePicker.cancel': "Cancel";
@@ -89,20 +90,30 @@ type Variables = {
89
90
  };
90
91
  type AppearanceKey = (typeof appearanceKeys)[number];
91
92
  type Elements = Partial<Record<AppearanceKey, ElementStyles>>;
93
+ type IconKey = 'bell' | 'clock' | 'arrowDropDown' | 'dots' | 'markAsRead' | 'cogs' | 'trash' | 'markAsArchived' | 'markAsArchivedRead' | 'markAsUnread' | 'markAsUnarchived' | 'unsnooze' | 'arrowRight' | 'arrowLeft' | 'unread' | 'sms' | 'inApp' | 'email' | 'push' | 'chat' | 'check' | 'arrowDown' | 'routeFill' | 'info' | 'nodeTree';
94
+ type IconRenderer = (el: HTMLDivElement, props: {
95
+ class?: string;
96
+ }) => () => void;
97
+ type IconOverrides = {
98
+ [key in IconKey]?: IconRenderer;
99
+ };
92
100
  type Theme = {
93
101
  variables?: Variables;
94
102
  elements?: Elements;
95
103
  animations?: boolean;
104
+ icons?: IconOverrides;
96
105
  };
97
106
  type Appearance = Theme & {
98
107
  baseTheme?: Theme | Theme[];
99
108
  };
100
109
  type BaseNovuProviderProps = {
110
+ container?: Node | string | null;
101
111
  appearance?: Appearance;
102
112
  localization?: Localization;
103
113
  options: NovuOptions;
104
114
  tabs?: Array<Tab>;
105
115
  preferencesFilter?: PreferencesFilter;
116
+ preferenceGroups?: PreferenceGroups;
106
117
  routerPush?: RouterPush;
107
118
  novu?: Novu;
108
119
  };
@@ -117,5 +128,15 @@ declare enum NotificationStatus {
117
128
  SNOOZED = "snoozed"
118
129
  }
119
130
  type PreferencesFilter = Pick<NotificationFilter, 'tags'>;
131
+ type PreferenceFilterFunction = (args: {
132
+ preferences: Preference[];
133
+ }) => Preference[];
134
+ type PreferenceGroupFilter = (PreferencesFilter & {
135
+ workflowIds?: string[];
136
+ }) | PreferenceFilterFunction;
137
+ type PreferenceGroups = Array<{
138
+ name: string;
139
+ filter: PreferenceGroupFilter;
140
+ }>;
120
141
 
121
- export { type Appearance as A, type BellRenderer as B, type Elements as E, type Localization as L, type NotificationClickHandler as N, type PreferencesFilter as P, type RouterPush as R, type SubjectRenderer as S, type Tab as T, type Variables as V, type NotificationActionClickHandler as a, type NotificationRenderer as b, type BodyRenderer as c, type NovuProviderProps as d, type BaseNovuProviderProps as e, type AppearanceKey as f, type ElementStyles as g, type LocalizationKey as h, NotificationStatus as i, type Theme as j };
142
+ export { type Appearance as A, type BellRenderer as B, type Elements as E, type IconKey as I, type Localization as L, type NotificationClickHandler as N, type PreferencesFilter as P, type RouterPush as R, type SubjectRenderer as S, type Tab as T, type Variables as V, type NotificationActionClickHandler as a, type NotificationRenderer as b, type BodyRenderer as c, type NovuProviderProps as d, type BaseNovuProviderProps as e, type PreferenceGroups as f, type AppearanceKey as g, type ElementStyles as h, type IconOverrides as i, type IconRenderer as j, type LocalizationKey as k, NotificationStatus as l, type Theme as m };
@@ -1,7 +1,7 @@
1
- import { g as NovuOptions } from '../novu-DJTVB7VN.js';
2
- export { d as Notification } from '../novu-DJTVB7VN.js';
3
- import { B as BellRenderer, N as NotificationClickHandler, a as NotificationActionClickHandler, b as NotificationRenderer, S as SubjectRenderer, c as BodyRenderer, d as NovuProviderProps, e as BaseNovuProviderProps, A as Appearance, L as Localization, T as Tab, P as PreferencesFilter, R as RouterPush } from '../types-BPv1rvbm.js';
4
- export { f as AppearanceKey, g as ElementStyles, E as Elements, h as LocalizationKey, i as NotificationStatus, V as Variables } from '../types-BPv1rvbm.js';
1
+ import { g as NovuOptions } from '../novu-Nrvpy3Z1.js';
2
+ export { d as Notification } from '../novu-Nrvpy3Z1.js';
3
+ import { B as BellRenderer, N as NotificationClickHandler, a as NotificationActionClickHandler, b as NotificationRenderer, S as SubjectRenderer, c as BodyRenderer, d as NovuProviderProps, e as BaseNovuProviderProps, A as Appearance, L as Localization, T as Tab, P as PreferencesFilter, f as PreferenceGroups, R as RouterPush } from '../types-Bj3h0WFq.js';
4
+ export { g as AppearanceKey, h as ElementStyles, E as Elements, I as IconKey, i as IconOverrides, j as IconRenderer, k as LocalizationKey, l as NotificationStatus, m as Theme, V as Variables } from '../types-Bj3h0WFq.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';
@@ -71,8 +71,10 @@ declare class NovuUI {
71
71
  updateOptions(options: NovuOptions): void;
72
72
  updateTabs(tabs?: Array<Tab>): void;
73
73
  updatePreferencesFilter(preferencesFilter?: PreferencesFilter): void;
74
+ updatePreferenceGroups(preferenceGroups?: PreferenceGroups): void;
74
75
  updateRouterPush(routerPush?: RouterPush): void;
76
+ updateContainer(container?: Node | string | null): void;
75
77
  unmount(): void;
76
78
  }
77
79
 
78
- export { Appearance, type BaseNovuUIOptions, BellRenderer, BodyRenderer, InboxPage, type InboxProps, Localization, NotificationActionClickHandler, NotificationClickHandler, NotificationRenderer, NovuProviderProps, NovuUI, type NovuUIOptions, PreferencesFilter, RouterPush, SubjectRenderer, Tab };
80
+ export { Appearance, type BaseNovuUIOptions, BellRenderer, BodyRenderer, InboxPage, type InboxProps, Localization, NotificationActionClickHandler, NotificationClickHandler, NotificationRenderer, NovuProviderProps, NovuUI, type NovuUIOptions, PreferenceGroups, PreferencesFilter, RouterPush, SubjectRenderer, Tab };