@novu/js 3.11.0 → 3.11.1

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.
@@ -1,7 +1,6 @@
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
+ import { S as SeverityLevelEnum, N as NotificationFilter, a as Notification } from './novu-event-emitter-C7GZ7-r1.js';
2
+ export { C as ChannelPreference, d as ChannelType, e as Context, D as DaySchedule, f as DefaultSchedule, E as EventHandler, b as Events, F as FiltersCountResponse, I as InboxNotification, L as ListNotificationsResponse, g as NotificationStatus, h as NovuError, i as NovuOptions, P as Preference, j as PreferenceLevel, k as PreferencesResponse, l as Schedule, c as SocketEventNames, m as StandardNovuOptions, n as Subscriber, T as TimeRange, U as UnreadCount, W as WebSocketEvent, o as WeeklySchedule, p as WorkflowCriticalityEnum } from './novu-event-emitter-C7GZ7-r1.js';
3
+ export { N as Novu } from './novu-CKWESYFZ.js';
5
4
 
6
5
  declare const areTagsEqual: (tags1?: string[], tags2?: string[]) => boolean;
7
6
  declare const areSeveritiesEqual: (el1?: SeverityLevelEnum | SeverityLevelEnum[], el2?: SeverityLevelEnum | SeverityLevelEnum[]) => boolean;
package/dist/cjs/index.js CHANGED
@@ -1,56 +1,56 @@
1
1
  'use strict';
2
2
 
3
- var chunkQQNKEWGC_js = require('./chunk-QQNKEWGC.js');
4
- require('./chunk-VWSQDNZX.js');
3
+ var chunkMKYWGA37_js = require('./chunk-MKYWGA37.js');
4
+ var chunkWFVHYVDM_js = require('./chunk-WFVHYVDM.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 chunkMKYWGA37_js.Novu; }
12
12
  });
13
- Object.defineProperty(exports, "NotificationStatus", {
13
+ Object.defineProperty(exports, "areSeveritiesEqual", {
14
14
  enumerable: true,
15
- get: function () { return chunkQQNKEWGC_js.NotificationStatus; }
15
+ get: function () { return chunkMKYWGA37_js.areSeveritiesEqual; }
16
16
  });
17
- Object.defineProperty(exports, "Novu", {
17
+ Object.defineProperty(exports, "areTagsEqual", {
18
18
  enumerable: true,
19
- get: function () { return chunkQQNKEWGC_js.Novu; }
19
+ get: function () { return chunkMKYWGA37_js.areTagsEqual; }
20
20
  });
21
- Object.defineProperty(exports, "PreferenceLevel", {
21
+ Object.defineProperty(exports, "checkNotificationDataFilter", {
22
22
  enumerable: true,
23
- get: function () { return chunkQQNKEWGC_js.PreferenceLevel; }
23
+ get: function () { return chunkMKYWGA37_js.checkNotificationDataFilter; }
24
24
  });
25
- Object.defineProperty(exports, "SeverityLevelEnum", {
25
+ Object.defineProperty(exports, "checkNotificationMatchesFilter", {
26
26
  enumerable: true,
27
- get: function () { return chunkQQNKEWGC_js.SeverityLevelEnum; }
27
+ get: function () { return chunkMKYWGA37_js.checkNotificationMatchesFilter; }
28
28
  });
29
- Object.defineProperty(exports, "WebSocketEvent", {
29
+ Object.defineProperty(exports, "isSameFilter", {
30
30
  enumerable: true,
31
- get: function () { return chunkQQNKEWGC_js.WebSocketEvent; }
31
+ get: function () { return chunkMKYWGA37_js.isSameFilter; }
32
32
  });
33
- Object.defineProperty(exports, "WorkflowCriticalityEnum", {
33
+ Object.defineProperty(exports, "ChannelType", {
34
34
  enumerable: true,
35
- get: function () { return chunkQQNKEWGC_js.WorkflowCriticalityEnum; }
35
+ get: function () { return chunkWFVHYVDM_js.ChannelType; }
36
36
  });
37
- Object.defineProperty(exports, "areSeveritiesEqual", {
37
+ Object.defineProperty(exports, "NotificationStatus", {
38
38
  enumerable: true,
39
- get: function () { return chunkQQNKEWGC_js.areSeveritiesEqual; }
39
+ get: function () { return chunkWFVHYVDM_js.NotificationStatus; }
40
40
  });
41
- Object.defineProperty(exports, "areTagsEqual", {
41
+ Object.defineProperty(exports, "PreferenceLevel", {
42
42
  enumerable: true,
43
- get: function () { return chunkQQNKEWGC_js.areTagsEqual; }
43
+ get: function () { return chunkWFVHYVDM_js.PreferenceLevel; }
44
44
  });
45
- Object.defineProperty(exports, "checkNotificationDataFilter", {
45
+ Object.defineProperty(exports, "SeverityLevelEnum", {
46
46
  enumerable: true,
47
- get: function () { return chunkQQNKEWGC_js.checkNotificationDataFilter; }
47
+ get: function () { return chunkWFVHYVDM_js.SeverityLevelEnum; }
48
48
  });
49
- Object.defineProperty(exports, "checkNotificationMatchesFilter", {
49
+ Object.defineProperty(exports, "WebSocketEvent", {
50
50
  enumerable: true,
51
- get: function () { return chunkQQNKEWGC_js.checkNotificationMatchesFilter; }
51
+ get: function () { return chunkWFVHYVDM_js.WebSocketEvent; }
52
52
  });
53
- Object.defineProperty(exports, "isSameFilter", {
53
+ Object.defineProperty(exports, "WorkflowCriticalityEnum", {
54
54
  enumerable: true,
55
- get: function () { return chunkQQNKEWGC_js.isSameFilter; }
55
+ get: function () { return chunkWFVHYVDM_js.WorkflowCriticalityEnum; }
56
56
  });
@@ -1,4 +1,4 @@
1
- import { b as Context, i as Subscriber } from '../types-BM_9Xx5Z.js';
1
+ import { e as Context, n as Subscriber, r as NovuEventEmitter, q as InboxService, I as InboxNotification, a as Notification } from '../novu-event-emitter-C7GZ7-r1.js';
2
2
 
3
3
  /**
4
4
  * Builds a compact, stable string key from context objects by extracting only type:id pairs.
@@ -19,10 +19,16 @@ declare function buildSubscriber({ subscriberId, subscriber, }: {
19
19
  subscriber: Subscriber | string | undefined;
20
20
  }): Subscriber;
21
21
 
22
+ declare function createNotification({ emitter, inboxService, notification, }: {
23
+ emitter: NovuEventEmitter;
24
+ inboxService: InboxService;
25
+ notification: InboxNotification;
26
+ }): Notification;
27
+
22
28
  interface Token {
23
29
  type: 'bold' | 'text';
24
30
  content: string;
25
31
  }
26
32
  declare const parseMarkdownIntoTokens: (text: string) => Token[];
27
33
 
28
- export { type Token, buildContextKey, buildSubscriber, parseMarkdownIntoTokens };
34
+ export { type Token, buildContextKey, buildSubscriber, createNotification, parseMarkdownIntoTokens };
@@ -1,19 +1,23 @@
1
1
  'use strict';
2
2
 
3
- var chunkVWSQDNZX_js = require('../chunk-VWSQDNZX.js');
3
+ var chunkWFVHYVDM_js = require('../chunk-WFVHYVDM.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 chunkWFVHYVDM_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 chunkWFVHYVDM_js.buildSubscriber; }
15
+ });
16
+ Object.defineProperty(exports, "createNotification", {
17
+ enumerable: true,
18
+ get: function () { return chunkWFVHYVDM_js.createNotification; }
15
19
  });
16
20
  Object.defineProperty(exports, "parseMarkdownIntoTokens", {
17
21
  enumerable: true,
18
- get: function () { return chunkVWSQDNZX_js.parseMarkdownIntoTokens; }
22
+ get: function () { return chunkWFVHYVDM_js.parseMarkdownIntoTokens; }
19
23
  });
@@ -0,0 +1,165 @@
1
+ import { q as InboxService, r as NovuEventEmitter, s as Session, R as Result, t as ScheduleCache, l as Schedule, u as UpdateScheduleArgs, v as PreferencesCache, w as ListPreferencesArgs, P as Preference, B as BasePreferenceArgs, x as InstancePreferenceArgs, y as ListNotificationsArgs, L as ListNotificationsResponse, I as InboxNotification, a as Notification, N as NotificationFilter, z as FilterCountArgs, A as FilterCountResponse, G as FiltersCountArgs, F as FiltersCountResponse, H as BaseArgs, J as InstanceArgs, K as SnoozeArgs, c as SocketEventNames, M as EventNames, E as EventHandler, b as Events, O as ContextValue, i as NovuOptions, n as Subscriber, e as Context } from './novu-event-emitter-C7GZ7-r1.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
+ interface BaseSocketInterface {
134
+ isSocketEvent(eventName: string): eventName is SocketEventNames;
135
+ connect(): Result<void>;
136
+ disconnect(): Result<void>;
137
+ }
138
+
139
+ declare class Novu implements Pick<NovuEventEmitter, 'on'> {
140
+ #private;
141
+ readonly notifications: Notifications;
142
+ readonly preferences: Preferences;
143
+ readonly socket: BaseSocketInterface;
144
+ on: <Key extends EventNames>(eventName: Key, listener: EventHandler<Events[Key]>) => () => void;
145
+ /**
146
+ * @deprecated
147
+ * Use the cleanup function returned by the "on" method instead.
148
+ */
149
+ off: <Key extends EventNames>(eventName: Key, listener: EventHandler<Events[Key]>) => void;
150
+ get applicationIdentifier(): string | undefined;
151
+ get subscriberId(): string | undefined;
152
+ get context(): Partial<Record<string, ContextValue>> | undefined;
153
+ get contextKey(): string;
154
+ constructor(options: NovuOptions);
155
+ changeSubscriber(options: {
156
+ subscriber: Subscriber;
157
+ subscriberHash?: string;
158
+ }): Promise<void>;
159
+ changeContext(options: {
160
+ context: Context;
161
+ contextHash?: string;
162
+ }): Promise<void>;
163
+ }
164
+
165
+ export { Novu as N };