@novu/js 3.11.0 → 3.11.2-nightly.20251224.97b30e30dd

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.
Files changed (36) hide show
  1. package/dist/cjs/{chunk-QQNKEWGC.js → chunk-AFLPFCXM.js} +1338 -1241
  2. package/dist/cjs/chunk-CDGREQFE.js +799 -0
  3. package/dist/cjs/index.d.ts +4 -4
  4. package/dist/cjs/index.js +38 -26
  5. package/dist/cjs/internal/index.d.ts +14 -2
  6. package/dist/cjs/internal/index.js +12 -4
  7. package/dist/cjs/novu-DxuaDf-Z.d.ts +192 -0
  8. package/dist/{esm/novu-DY-mm8Og.d.mts → cjs/novu-event-emitter-BOA_6GfJ.d.ts} +413 -162
  9. package/dist/cjs/themes/index.d.ts +11 -5
  10. package/dist/cjs/themes/index.js +17 -1
  11. package/dist/cjs/types-Buzm23uF.d.ts +836 -0
  12. package/dist/cjs/ui/index.d.ts +74 -7
  13. package/dist/cjs/ui/index.js +1836 -261
  14. package/dist/esm/{chunk-UM35OVAD.mjs → chunk-GDLXUD4E.mjs} +1308 -1207
  15. package/dist/esm/chunk-SWKDFXVR.mjs +770 -0
  16. package/dist/esm/index.d.mts +4 -4
  17. package/dist/esm/index.mjs +2 -2
  18. package/dist/esm/internal/index.d.mts +14 -2
  19. package/dist/esm/internal/index.mjs +1 -1
  20. package/dist/esm/novu-DY8vwRGE.d.mts +192 -0
  21. package/dist/{cjs/novu-ThMWeiRt.d.ts → esm/novu-event-emitter-BOA_6GfJ.d.mts} +413 -162
  22. package/dist/esm/themes/index.d.mts +11 -5
  23. package/dist/esm/themes/index.mjs +16 -2
  24. package/dist/esm/types-xBjzv9ok.d.mts +836 -0
  25. package/dist/esm/ui/index.d.mts +74 -7
  26. package/dist/esm/ui/index.mjs +1833 -257
  27. package/dist/index.css +1 -1
  28. package/dist/novu.min.js +12 -12
  29. package/dist/novu.min.js.gz +0 -0
  30. package/package.json +18 -17
  31. package/dist/cjs/chunk-VWSQDNZX.js +0 -66
  32. package/dist/cjs/types-BM_9Xx5Z.d.ts +0 -220
  33. package/dist/cjs/types-BjANCN3c.d.ts +0 -537
  34. package/dist/esm/chunk-RZWQYM3H.mjs +0 -62
  35. package/dist/esm/types-BM_9Xx5Z.d.mts +0 -220
  36. package/dist/esm/types-C5eX1GmB.d.mts +0 -537
@@ -1,7 +1,7 @@
1
- import { N as Notification } from './novu-ThMWeiRt.js';
2
- export { E as EventHandler, a as Events, F as FiltersCountResponse, L as ListNotificationsResponse, b as Novu, P as Preference, c as Schedule, S as SocketEventNames } from './novu-ThMWeiRt.js';
3
- import { S as SeverityLevelEnum, N as NotificationFilter } from './types-BM_9Xx5Z.js';
4
- export { C as ChannelPreference, a as ChannelType, b as Context, D as DaySchedule, c as DefaultSchedule, I as InboxNotification, d as NotificationStatus, e as NovuError, f as NovuOptions, P as PreferenceLevel, g as PreferencesResponse, h as StandardNovuOptions, i as Subscriber, T as TimeRange, U as UnreadCount, W as WebSocketEvent, j as WeeklySchedule, k as WorkflowCriticalityEnum } from './types-BM_9Xx5Z.js';
1
+ export * from 'json-logic-js';
2
+ import { S as SeverityLevelEnum, N as NotificationFilter, a as Notification } from './novu-event-emitter-BOA_6GfJ.js';
3
+ export { B as BaseDeleteSubscriptionArgs, f as BaseUpdateSubscriptionArgs, j as ChannelPreference, k as ChannelType, l as Context, C as CreateSubscriptionArgs, m as DaySchedule, n as DefaultSchedule, D as DeleteSubscriptionArgs, E as EventHandler, b as Events, F as FiltersCountResponse, G as GetSubscriptionArgs, o as InboxNotification, I as InstanceDeleteSubscriptionArgs, g as InstanceUpdateSubscriptionArgs, p as ListNotificationsResponse, L as ListSubscriptionsArgs, q as NotificationStatus, K as NovuError, r as NovuOptions, s as Preference, P as PreferenceFilter, t as PreferenceLevel, u as PreferencesResponse, v as Schedule, c as SocketEventNames, w as StandardNovuOptions, x as Subscriber, h as SubscriptionPreference, y as TimeRange, T as TopicSubscription, z as UnreadCount, U as UpdateSubscriptionArgs, i as UpdateSubscriptionPreferenceArgs, A as WebSocketEvent, H as WeeklySchedule, J as WorkflowCriticalityEnum, W as WorkflowFilter, d as WorkflowGroupFilter, e as WorkflowIdentifierOrId } from './novu-event-emitter-BOA_6GfJ.js';
4
+ export { N as Novu } from './novu-DxuaDf-Z.js';
5
5
 
6
6
  declare const areTagsEqual: (tags1?: string[], tags2?: string[]) => boolean;
7
7
  declare const areSeveritiesEqual: (el1?: SeverityLevelEnum | SeverityLevelEnum[], el2?: SeverityLevelEnum | SeverityLevelEnum[]) => boolean;
package/dist/cjs/index.js CHANGED
@@ -1,56 +1,68 @@
1
1
  'use strict';
2
2
 
3
- var chunkQQNKEWGC_js = require('./chunk-QQNKEWGC.js');
4
- require('./chunk-VWSQDNZX.js');
3
+ var chunkAFLPFCXM_js = require('./chunk-AFLPFCXM.js');
4
+ var chunkCDGREQFE_js = require('./chunk-CDGREQFE.js');
5
5
  require('./chunk-7B52C2XE.js');
6
6
 
7
7
 
8
8
 
9
- Object.defineProperty(exports, "ChannelType", {
9
+ Object.defineProperty(exports, "Novu", {
10
10
  enumerable: true,
11
- get: function () { return chunkQQNKEWGC_js.ChannelType; }
11
+ get: function () { return chunkAFLPFCXM_js.Novu; }
12
12
  });
13
- Object.defineProperty(exports, "NotificationStatus", {
13
+ Object.defineProperty(exports, "SubscriptionPreference", {
14
14
  enumerable: true,
15
- get: function () { return chunkQQNKEWGC_js.NotificationStatus; }
15
+ get: function () { return chunkAFLPFCXM_js.SubscriptionPreference; }
16
16
  });
17
- Object.defineProperty(exports, "Novu", {
17
+ Object.defineProperty(exports, "TopicSubscription", {
18
18
  enumerable: true,
19
- get: function () { return chunkQQNKEWGC_js.Novu; }
19
+ get: function () { return chunkAFLPFCXM_js.TopicSubscription; }
20
20
  });
21
- Object.defineProperty(exports, "PreferenceLevel", {
21
+ Object.defineProperty(exports, "areSeveritiesEqual", {
22
22
  enumerable: true,
23
- get: function () { return chunkQQNKEWGC_js.PreferenceLevel; }
23
+ get: function () { return chunkAFLPFCXM_js.areSeveritiesEqual; }
24
24
  });
25
- Object.defineProperty(exports, "SeverityLevelEnum", {
25
+ Object.defineProperty(exports, "areTagsEqual", {
26
26
  enumerable: true,
27
- get: function () { return chunkQQNKEWGC_js.SeverityLevelEnum; }
27
+ get: function () { return chunkAFLPFCXM_js.areTagsEqual; }
28
28
  });
29
- Object.defineProperty(exports, "WebSocketEvent", {
29
+ Object.defineProperty(exports, "checkNotificationDataFilter", {
30
30
  enumerable: true,
31
- get: function () { return chunkQQNKEWGC_js.WebSocketEvent; }
31
+ get: function () { return chunkAFLPFCXM_js.checkNotificationDataFilter; }
32
32
  });
33
- Object.defineProperty(exports, "WorkflowCriticalityEnum", {
33
+ Object.defineProperty(exports, "checkNotificationMatchesFilter", {
34
34
  enumerable: true,
35
- get: function () { return chunkQQNKEWGC_js.WorkflowCriticalityEnum; }
35
+ get: function () { return chunkAFLPFCXM_js.checkNotificationMatchesFilter; }
36
36
  });
37
- Object.defineProperty(exports, "areSeveritiesEqual", {
37
+ Object.defineProperty(exports, "isSameFilter", {
38
38
  enumerable: true,
39
- get: function () { return chunkQQNKEWGC_js.areSeveritiesEqual; }
39
+ get: function () { return chunkAFLPFCXM_js.isSameFilter; }
40
40
  });
41
- Object.defineProperty(exports, "areTagsEqual", {
41
+ Object.defineProperty(exports, "ChannelType", {
42
42
  enumerable: true,
43
- get: function () { return chunkQQNKEWGC_js.areTagsEqual; }
43
+ get: function () { return chunkCDGREQFE_js.ChannelType; }
44
44
  });
45
- Object.defineProperty(exports, "checkNotificationDataFilter", {
45
+ Object.defineProperty(exports, "NotificationStatus", {
46
46
  enumerable: true,
47
- get: function () { return chunkQQNKEWGC_js.checkNotificationDataFilter; }
47
+ get: function () { return chunkCDGREQFE_js.NotificationStatus; }
48
48
  });
49
- Object.defineProperty(exports, "checkNotificationMatchesFilter", {
49
+ Object.defineProperty(exports, "NovuError", {
50
50
  enumerable: true,
51
- get: function () { return chunkQQNKEWGC_js.checkNotificationMatchesFilter; }
51
+ get: function () { return chunkCDGREQFE_js.NovuError; }
52
52
  });
53
- Object.defineProperty(exports, "isSameFilter", {
53
+ Object.defineProperty(exports, "PreferenceLevel", {
54
+ enumerable: true,
55
+ get: function () { return chunkCDGREQFE_js.PreferenceLevel; }
56
+ });
57
+ Object.defineProperty(exports, "SeverityLevelEnum", {
58
+ enumerable: true,
59
+ get: function () { return chunkCDGREQFE_js.SeverityLevelEnum; }
60
+ });
61
+ Object.defineProperty(exports, "WebSocketEvent", {
62
+ enumerable: true,
63
+ get: function () { return chunkCDGREQFE_js.WebSocketEvent; }
64
+ });
65
+ Object.defineProperty(exports, "WorkflowCriticalityEnum", {
54
66
  enumerable: true,
55
- get: function () { return chunkQQNKEWGC_js.isSameFilter; }
67
+ get: function () { return chunkCDGREQFE_js.WorkflowCriticalityEnum; }
56
68
  });
@@ -1,4 +1,5 @@
1
- import { b as Context, i as Subscriber } from '../types-BM_9Xx5Z.js';
1
+ import { l as Context, x as Subscriber, O as NovuEventEmitter, M as InboxService, o as InboxNotification, a as Notification } from '../novu-event-emitter-BOA_6GfJ.js';
2
+ import 'json-logic-js';
2
3
 
3
4
  /**
4
5
  * Builds a compact, stable string key from context objects by extracting only type:id pairs.
@@ -19,10 +20,21 @@ declare function buildSubscriber({ subscriberId, subscriber, }: {
19
20
  subscriber: Subscriber | string | undefined;
20
21
  }): Subscriber;
21
22
 
23
+ declare function buildSubscriptionIdentifier({ topicKey, subscriberId }: {
24
+ topicKey: string;
25
+ subscriberId?: string;
26
+ }): string;
27
+
28
+ declare function createNotification({ emitter, inboxService, notification, }: {
29
+ emitter: NovuEventEmitter;
30
+ inboxService: InboxService;
31
+ notification: InboxNotification;
32
+ }): Notification;
33
+
22
34
  interface Token {
23
35
  type: 'bold' | 'text';
24
36
  content: string;
25
37
  }
26
38
  declare const parseMarkdownIntoTokens: (text: string) => Token[];
27
39
 
28
- export { type Token, buildContextKey, buildSubscriber, parseMarkdownIntoTokens };
40
+ export { type Token, buildContextKey, buildSubscriber, buildSubscriptionIdentifier, createNotification, parseMarkdownIntoTokens };
@@ -1,19 +1,27 @@
1
1
  'use strict';
2
2
 
3
- var chunkVWSQDNZX_js = require('../chunk-VWSQDNZX.js');
3
+ var chunkCDGREQFE_js = require('../chunk-CDGREQFE.js');
4
4
  require('../chunk-7B52C2XE.js');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, "buildContextKey", {
9
9
  enumerable: true,
10
- get: function () { return chunkVWSQDNZX_js.buildContextKey; }
10
+ get: function () { return chunkCDGREQFE_js.buildContextKey; }
11
11
  });
12
12
  Object.defineProperty(exports, "buildSubscriber", {
13
13
  enumerable: true,
14
- get: function () { return chunkVWSQDNZX_js.buildSubscriber; }
14
+ get: function () { return chunkCDGREQFE_js.buildSubscriber; }
15
+ });
16
+ Object.defineProperty(exports, "buildSubscriptionIdentifier", {
17
+ enumerable: true,
18
+ get: function () { return chunkCDGREQFE_js.buildSubscriptionIdentifier; }
19
+ });
20
+ Object.defineProperty(exports, "createNotification", {
21
+ enumerable: true,
22
+ get: function () { return chunkCDGREQFE_js.createNotification; }
15
23
  });
16
24
  Object.defineProperty(exports, "parseMarkdownIntoTokens", {
17
25
  enumerable: true,
18
- get: function () { return chunkVWSQDNZX_js.parseMarkdownIntoTokens; }
26
+ get: function () { return chunkCDGREQFE_js.parseMarkdownIntoTokens; }
19
27
  });
@@ -0,0 +1,192 @@
1
+ import { M as InboxService, O as NovuEventEmitter, Q as Session, R as Result, V as ScheduleCache, v as Schedule, X as UpdateScheduleArgs, Y as PreferencesCache, Z as ListPreferencesArgs, s as Preference, _ as BasePreferenceArgs, $ as InstancePreferenceArgs, a0 as ListNotificationsArgs, p as ListNotificationsResponse, o as InboxNotification, a as Notification, N as NotificationFilter, a1 as FilterCountArgs, a2 as FilterCountResponse, a3 as FiltersCountArgs, F as FiltersCountResponse, a4 as BaseArgs, a5 as InstanceArgs, a6 as SnoozeArgs, a7 as SubscriptionsCache, x as Subscriber, L as ListSubscriptionsArgs, a8 as Options, T as TopicSubscription, G as GetSubscriptionArgs, C as CreateSubscriptionArgs, f as BaseUpdateSubscriptionArgs, g as InstanceUpdateSubscriptionArgs, B as BaseDeleteSubscriptionArgs, I as InstanceDeleteSubscriptionArgs, c as SocketEventNames, a9 as EventNames, E as EventHandler, b as Events, aa as ContextValue, r as NovuOptions, l as Context } from './novu-event-emitter-BOA_6GfJ.js';
2
+
3
+ declare class BaseModule {
4
+ #private;
5
+ _inboxService: InboxService;
6
+ _emitter: NovuEventEmitter;
7
+ constructor({ inboxServiceInstance, eventEmitterInstance, }: {
8
+ inboxServiceInstance: InboxService;
9
+ eventEmitterInstance: NovuEventEmitter;
10
+ });
11
+ protected onSessionSuccess(_: Session): void;
12
+ protected onSessionError(_: unknown): void;
13
+ callWithSession<T>(fn: () => Result<T>): Result<T>;
14
+ }
15
+
16
+ declare class PreferenceSchedule extends BaseModule {
17
+ #private;
18
+ readonly cache: ScheduleCache;
19
+ constructor({ cache, useCache, inboxServiceInstance, eventEmitterInstance, }: {
20
+ cache: ScheduleCache;
21
+ useCache: boolean;
22
+ inboxServiceInstance: InboxService;
23
+ eventEmitterInstance: NovuEventEmitter;
24
+ });
25
+ get(): Result<Schedule>;
26
+ update(args: UpdateScheduleArgs): Result<Schedule>;
27
+ }
28
+
29
+ declare class Preferences extends BaseModule {
30
+ #private;
31
+ readonly cache: PreferencesCache;
32
+ readonly scheduleCache: ScheduleCache;
33
+ readonly schedule: PreferenceSchedule;
34
+ constructor({ useCache, inboxServiceInstance, eventEmitterInstance, }: {
35
+ useCache: boolean;
36
+ inboxServiceInstance: InboxService;
37
+ eventEmitterInstance: NovuEventEmitter;
38
+ });
39
+ list(args?: ListPreferencesArgs): Result<Preference[]>;
40
+ update(args: BasePreferenceArgs): Result<Preference>;
41
+ update(args: InstancePreferenceArgs): Result<Preference>;
42
+ bulkUpdate(args: Array<BasePreferenceArgs>): Result<Preference[]>;
43
+ bulkUpdate(args: Array<InstancePreferenceArgs>): Result<Preference[]>;
44
+ }
45
+
46
+ declare class NotificationsCache {
47
+ #private;
48
+ constructor({ emitter, inboxService }: {
49
+ emitter: NovuEventEmitter;
50
+ inboxService: InboxService;
51
+ });
52
+ private updateNotification;
53
+ private removeNotification;
54
+ private handleNotificationEvent;
55
+ private getAggregated;
56
+ get(args: ListNotificationsArgs): ListNotificationsResponse | undefined;
57
+ has(args: ListNotificationsArgs): boolean;
58
+ set(args: ListNotificationsArgs, data: ListNotificationsResponse): void;
59
+ unshift(args: ListNotificationsArgs, notification: InboxNotification): void;
60
+ update(args: ListNotificationsArgs, data: ListNotificationsResponse): void;
61
+ getAll(args: ListNotificationsArgs): ListNotificationsResponse | undefined;
62
+ /**
63
+ * Get unique notifications based on specified filter fields.
64
+ * The same tags and data can be applied to multiple filters which means that the same notification can be duplicated.
65
+ */
66
+ getUniqueNotifications({ tags, read, data, }: Pick<ListNotificationsArgs, 'tags' | 'read' | 'data'>): Array<Notification>;
67
+ clear(filter: NotificationFilter): void;
68
+ clearAll(): void;
69
+ }
70
+
71
+ declare class Notifications extends BaseModule {
72
+ #private;
73
+ readonly cache: NotificationsCache;
74
+ constructor({ useCache, inboxServiceInstance, eventEmitterInstance, }: {
75
+ useCache: boolean;
76
+ inboxServiceInstance: InboxService;
77
+ eventEmitterInstance: NovuEventEmitter;
78
+ });
79
+ list({ limit, ...restOptions }?: ListNotificationsArgs): Result<ListNotificationsResponse>;
80
+ count(args?: FilterCountArgs): Result<FilterCountResponse>;
81
+ count(args?: FiltersCountArgs): Result<FiltersCountResponse>;
82
+ read(args: BaseArgs): Result<Notification>;
83
+ read(args: InstanceArgs): Result<Notification>;
84
+ unread(args: BaseArgs): Result<Notification>;
85
+ unread(args: InstanceArgs): Result<Notification>;
86
+ seen(args: BaseArgs): Result<Notification>;
87
+ seen(args: InstanceArgs): Result<Notification>;
88
+ archive(args: BaseArgs): Result<Notification>;
89
+ archive(args: InstanceArgs): Result<Notification>;
90
+ unarchive(args: BaseArgs): Result<Notification>;
91
+ unarchive(args: InstanceArgs): Result<Notification>;
92
+ delete(args: BaseArgs): Result<void>;
93
+ delete(args: InstanceArgs): Result<void>;
94
+ snooze(args: SnoozeArgs): Result<Notification>;
95
+ unsnooze(args: BaseArgs): Result<Notification>;
96
+ unsnooze(args: InstanceArgs): Result<Notification>;
97
+ completePrimary(args: BaseArgs): Result<Notification>;
98
+ completePrimary(args: InstanceArgs): Result<Notification>;
99
+ completeSecondary(args: BaseArgs): Result<Notification>;
100
+ completeSecondary(args: InstanceArgs): Result<Notification>;
101
+ revertPrimary(args: BaseArgs): Result<Notification>;
102
+ revertPrimary(args: InstanceArgs): Result<Notification>;
103
+ revertSecondary(args: BaseArgs): Result<Notification>;
104
+ revertSecondary(args: InstanceArgs): Result<Notification>;
105
+ readAll({ tags, data, }?: {
106
+ tags?: NotificationFilter['tags'];
107
+ data?: Record<string, unknown>;
108
+ }): Result<void>;
109
+ seenAll(args?: {
110
+ notificationIds: string[];
111
+ } | {
112
+ tags?: NotificationFilter['tags'];
113
+ data?: Record<string, unknown>;
114
+ } | {}): Result<void>;
115
+ archiveAll({ tags, data, }?: {
116
+ tags?: NotificationFilter['tags'];
117
+ data?: Record<string, unknown>;
118
+ }): Result<void>;
119
+ archiveAllRead({ tags, data }?: {
120
+ tags?: string[];
121
+ data?: Record<string, unknown>;
122
+ }): Result<void>;
123
+ deleteAll({ tags, data, }?: {
124
+ tags?: NotificationFilter['tags'];
125
+ data?: Record<string, unknown>;
126
+ }): Result<void>;
127
+ clearCache({ filter }?: {
128
+ filter?: NotificationFilter;
129
+ }): void;
130
+ triggerHelloWorldEvent(): Promise<any>;
131
+ }
132
+
133
+ declare class Subscriptions extends BaseModule {
134
+ #private;
135
+ readonly cache: SubscriptionsCache;
136
+ constructor({ useCache, inboxServiceInstance, eventEmitterInstance, subscriber, }: {
137
+ useCache: boolean;
138
+ inboxServiceInstance: InboxService;
139
+ eventEmitterInstance: NovuEventEmitter;
140
+ subscriber: Subscriber;
141
+ });
142
+ list(args: ListSubscriptionsArgs, options?: Options): Result<TopicSubscription[]>;
143
+ get(args: GetSubscriptionArgs, options?: Options): Result<TopicSubscription | null>;
144
+ create(args: CreateSubscriptionArgs): Result<TopicSubscription>;
145
+ update(args: BaseUpdateSubscriptionArgs): Result<TopicSubscription>;
146
+ update(args: InstanceUpdateSubscriptionArgs): Result<TopicSubscription>;
147
+ delete(args: BaseDeleteSubscriptionArgs): Result<void>;
148
+ delete(args: InstanceDeleteSubscriptionArgs): Result<void>;
149
+ }
150
+
151
+ interface BaseSocketInterface {
152
+ isSocketEvent(eventName: string): eventName is SocketEventNames;
153
+ connect(): Result<void>;
154
+ disconnect(): Result<void>;
155
+ }
156
+
157
+ declare class Novu implements Pick<NovuEventEmitter, 'on'> {
158
+ #private;
159
+ readonly notifications: Notifications;
160
+ readonly preferences: Preferences;
161
+ readonly subscriptions: Subscriptions;
162
+ readonly socket: BaseSocketInterface;
163
+ on: <Key extends EventNames>(eventName: Key, listener: EventHandler<Events[Key]>) => () => void;
164
+ /**
165
+ * @deprecated
166
+ * Use the cleanup function returned by the "on" method instead.
167
+ */
168
+ off: <Key extends EventNames>(eventName: Key, listener: EventHandler<Events[Key]>) => void;
169
+ get applicationIdentifier(): string | undefined;
170
+ get subscriberId(): string | undefined;
171
+ get context(): Partial<Record<string, ContextValue>> | undefined;
172
+ get options(): NovuOptions;
173
+ get contextKey(): string;
174
+ constructor(options: NovuOptions);
175
+ private clearCache;
176
+ /**
177
+ * @deprecated
178
+ */
179
+ changeSubscriber(options: {
180
+ subscriber: Subscriber;
181
+ subscriberHash?: string;
182
+ }): Promise<void>;
183
+ /**
184
+ * @deprecated
185
+ */
186
+ changeContext(options: {
187
+ context: Context;
188
+ contextHash?: string;
189
+ }): Promise<void>;
190
+ }
191
+
192
+ export { Novu as N };