@novu/js 3.11.0 → 3.12.0-rc.2

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 (32) hide show
  1. package/dist/cjs/{chunk-VWSQDNZX.js → chunk-OZV3TKWX.js} +6 -0
  2. package/dist/cjs/{chunk-QQNKEWGC.js → chunk-SZEUW4CB.js} +1070 -309
  3. package/dist/cjs/index.d.ts +5 -4
  4. package/dist/cjs/index.js +26 -14
  5. package/dist/cjs/internal/index.d.ts +8 -2
  6. package/dist/cjs/internal/index.js +8 -4
  7. package/dist/{esm/novu-DY-mm8Og.d.mts → cjs/novu-BVtCFUxa.d.ts} +398 -203
  8. package/dist/cjs/themes/index.d.ts +11 -5
  9. package/dist/cjs/themes/index.js +17 -1
  10. package/dist/{esm/types-BM_9Xx5Z.d.mts → cjs/types-D-9ozWeQ.d.ts} +20 -1
  11. package/dist/cjs/types-Rjzg7eo3.d.ts +836 -0
  12. package/dist/cjs/ui/index.d.ts +74 -7
  13. package/dist/cjs/ui/index.js +1785 -260
  14. package/dist/esm/{chunk-UM35OVAD.mjs → chunk-IA6ISHOP.mjs} +1068 -310
  15. package/dist/esm/{chunk-RZWQYM3H.mjs → chunk-RO3GDYAG.mjs} +6 -1
  16. package/dist/esm/index.d.mts +5 -4
  17. package/dist/esm/index.mjs +2 -2
  18. package/dist/esm/internal/index.d.mts +8 -2
  19. package/dist/esm/internal/index.mjs +1 -1
  20. package/dist/{cjs/novu-ThMWeiRt.d.ts → esm/novu-YP3PwsQR.d.mts} +398 -203
  21. package/dist/esm/themes/index.d.mts +11 -5
  22. package/dist/esm/themes/index.mjs +16 -2
  23. package/dist/{cjs/types-BM_9Xx5Z.d.ts → esm/types-D-9ozWeQ.d.mts} +20 -1
  24. package/dist/esm/types-DmMJ1GiR.d.mts +836 -0
  25. package/dist/esm/ui/index.d.mts +74 -7
  26. package/dist/esm/ui/index.mjs +1782 -256
  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/types-BjANCN3c.d.ts +0 -537
  32. package/dist/esm/types-C5eX1GmB.d.mts +0 -537
@@ -1,4 +1,5 @@
1
- import { j as WeeklySchedule, S as SeverityLevelEnum, k as WorkflowCriticalityEnum, C as ChannelPreference, l as Session, R as Result, P as PreferenceLevel, m as Workflow, n as Prettify, i as Subscriber, c as DefaultSchedule, b as Context, I as InboxNotification, N as NotificationFilter, A as ActionTypeEnum, g as PreferencesResponse, W as WebSocketEvent, o as ContextValue, f as NovuOptions } from './types-BM_9Xx5Z.js';
1
+ import { I as InboxNotification, R as Result, m as Session, N as NotificationFilter, S as SeverityLevelEnum, i as WeeklySchedule, j as WorkflowCriticalityEnum, C as ChannelPreference, P as PreferenceLevel, n as Workflow, o as Prettify, p as SubscriptionPreferenceResponse, l as NonEmptyArray, h as Subscriber, c as DefaultSchedule, b as Context, A as ActionTypeEnum, f as PreferencesResponse, q as SubscriptionResponse, O as Options, W as WebSocketEvent, r as ContextValue, e as NovuOptions } from './types-D-9ozWeQ.mjs';
2
+ import { RulesLogic } from 'json-logic-js';
2
3
 
3
4
  type HttpClientOptions = {
4
5
  apiVersion?: string;
@@ -7,6 +8,220 @@ type HttpClientOptions = {
7
8
  headers?: Record<string, string>;
8
9
  };
9
10
 
11
+ declare class Notification implements Pick<NovuEventEmitter, 'on'>, InboxNotification {
12
+ #private;
13
+ readonly id: InboxNotification['id'];
14
+ readonly transactionId: InboxNotification['transactionId'];
15
+ readonly subject?: InboxNotification['subject'];
16
+ readonly body: InboxNotification['body'];
17
+ readonly to: InboxNotification['to'];
18
+ readonly isRead: InboxNotification['isRead'];
19
+ readonly isSeen: InboxNotification['isSeen'];
20
+ readonly isArchived: InboxNotification['isArchived'];
21
+ readonly isSnoozed: InboxNotification['isSnoozed'];
22
+ readonly snoozedUntil?: InboxNotification['snoozedUntil'];
23
+ readonly deliveredAt?: InboxNotification['deliveredAt'];
24
+ readonly createdAt: InboxNotification['createdAt'];
25
+ readonly readAt?: InboxNotification['readAt'];
26
+ readonly firstSeenAt?: InboxNotification['firstSeenAt'];
27
+ readonly archivedAt?: InboxNotification['archivedAt'];
28
+ readonly avatar?: InboxNotification['avatar'];
29
+ readonly primaryAction?: InboxNotification['primaryAction'];
30
+ readonly secondaryAction?: InboxNotification['secondaryAction'];
31
+ readonly channelType: InboxNotification['channelType'];
32
+ readonly tags: InboxNotification['tags'];
33
+ readonly redirect: InboxNotification['redirect'];
34
+ readonly data?: InboxNotification['data'];
35
+ readonly workflow?: InboxNotification['workflow'];
36
+ readonly severity: InboxNotification['severity'];
37
+ constructor(notification: InboxNotification, emitter: NovuEventEmitter, inboxService: InboxService);
38
+ read(): Result<Notification>;
39
+ unread(): Result<Notification>;
40
+ seen(): Result<Notification>;
41
+ archive(): Result<Notification>;
42
+ unarchive(): Result<Notification>;
43
+ delete(): Result<void>;
44
+ snooze(snoozeUntil: string): Result<Notification>;
45
+ unsnooze(): Result<Notification>;
46
+ completePrimary(): Result<Notification>;
47
+ completeSecondary(): Result<Notification>;
48
+ revertPrimary(): Result<Notification>;
49
+ revertSecondary(): Result<Notification>;
50
+ on<Key extends EventNames>(eventName: Key, listener: EventHandler<Events[Key]>): () => void;
51
+ /**
52
+ * @deprecated
53
+ * Use the cleanup function returned by the "on" method instead.
54
+ */
55
+ off<Key extends EventNames>(eventName: Key, listener: EventHandler<Events[Key]>): void;
56
+ }
57
+
58
+ declare class BaseModule {
59
+ #private;
60
+ protected _inboxService: InboxService;
61
+ protected _emitter: NovuEventEmitter;
62
+ constructor({ inboxServiceInstance, eventEmitterInstance, }: {
63
+ inboxServiceInstance: InboxService;
64
+ eventEmitterInstance: NovuEventEmitter;
65
+ });
66
+ protected onSessionSuccess(_: Session): void;
67
+ protected onSessionError(_: unknown): void;
68
+ callWithSession<T>(fn: () => Result<T>): Result<T>;
69
+ }
70
+
71
+ declare class NotificationsCache {
72
+ #private;
73
+ constructor({ emitter }: {
74
+ emitter: NovuEventEmitter;
75
+ });
76
+ private updateNotification;
77
+ private removeNotification;
78
+ private handleNotificationEvent;
79
+ private getAggregated;
80
+ has(args: ListNotificationsArgs): boolean;
81
+ set(args: ListNotificationsArgs, data: ListNotificationsResponse): void;
82
+ update(args: ListNotificationsArgs, data: ListNotificationsResponse): void;
83
+ getAll(args: ListNotificationsArgs): ListNotificationsResponse | undefined;
84
+ /**
85
+ * Get unique notifications based on specified filter fields.
86
+ * The same tags and data can be applied to multiple filters which means that the same notification can be duplicated.
87
+ */
88
+ getUniqueNotifications({ tags, read, data, }: Pick<ListNotificationsArgs, 'tags' | 'read' | 'data'>): Array<Notification>;
89
+ clear(filter: NotificationFilter): void;
90
+ clearAll(): void;
91
+ }
92
+
93
+ type ListNotificationsArgs = {
94
+ tags?: string[];
95
+ read?: boolean;
96
+ data?: Record<string, unknown>;
97
+ archived?: boolean;
98
+ snoozed?: boolean;
99
+ seen?: boolean;
100
+ severity?: SeverityLevelEnum | SeverityLevelEnum[];
101
+ limit?: number;
102
+ after?: string;
103
+ offset?: number;
104
+ useCache?: boolean;
105
+ };
106
+ type ListNotificationsResponse = {
107
+ notifications: Notification[];
108
+ hasMore: boolean;
109
+ filter: NotificationFilter;
110
+ };
111
+ type FilterCountArgs = {
112
+ tags?: string[];
113
+ data?: Record<string, unknown>;
114
+ read?: boolean;
115
+ archived?: boolean;
116
+ snoozed?: boolean;
117
+ seen?: boolean;
118
+ severity?: SeverityLevelEnum | SeverityLevelEnum[];
119
+ };
120
+ type FiltersCountArgs = {
121
+ filters: Array<{
122
+ tags?: string[];
123
+ read?: boolean;
124
+ archived?: boolean;
125
+ snoozed?: boolean;
126
+ seen?: boolean;
127
+ data?: Record<string, unknown>;
128
+ severity?: SeverityLevelEnum | SeverityLevelEnum[];
129
+ }>;
130
+ };
131
+ type CountArgs = undefined | FilterCountArgs | FiltersCountArgs;
132
+ type FilterCountResponse = {
133
+ count: number;
134
+ filter: NotificationFilter;
135
+ };
136
+ type FiltersCountResponse = {
137
+ counts: Array<{
138
+ count: number;
139
+ filter: NotificationFilter;
140
+ }>;
141
+ };
142
+ type CountResponse = FilterCountResponse | FiltersCountResponse;
143
+ type BaseArgs = {
144
+ notificationId: string;
145
+ };
146
+ type InstanceArgs = {
147
+ notification: Notification;
148
+ };
149
+ type ReadArgs = BaseArgs | InstanceArgs;
150
+ type UnreadArgs = BaseArgs | InstanceArgs;
151
+ type ArchivedArgs = BaseArgs | InstanceArgs;
152
+ type UnarchivedArgs = BaseArgs | InstanceArgs;
153
+ type DeletedArgs = BaseArgs | InstanceArgs;
154
+ type SeenArgs = BaseArgs | InstanceArgs;
155
+ type SnoozeArgs = (BaseArgs | InstanceArgs) & {
156
+ snoozeUntil: string;
157
+ };
158
+ type UnsnoozeArgs = BaseArgs | InstanceArgs;
159
+ type CompleteArgs = BaseArgs | InstanceArgs;
160
+ type RevertArgs = BaseArgs | InstanceArgs;
161
+
162
+ declare class Notifications extends BaseModule {
163
+ #private;
164
+ readonly cache: NotificationsCache;
165
+ constructor({ useCache, inboxServiceInstance, eventEmitterInstance, }: {
166
+ useCache: boolean;
167
+ inboxServiceInstance: InboxService;
168
+ eventEmitterInstance: NovuEventEmitter;
169
+ });
170
+ get inboxService(): InboxService;
171
+ list({ limit, ...restOptions }?: ListNotificationsArgs): Result<ListNotificationsResponse>;
172
+ count(args?: FilterCountArgs): Result<FilterCountResponse>;
173
+ count(args?: FiltersCountArgs): Result<FiltersCountResponse>;
174
+ read(args: BaseArgs): Result<Notification>;
175
+ read(args: InstanceArgs): Result<Notification>;
176
+ unread(args: BaseArgs): Result<Notification>;
177
+ unread(args: InstanceArgs): Result<Notification>;
178
+ seen(args: BaseArgs): Result<Notification>;
179
+ seen(args: InstanceArgs): Result<Notification>;
180
+ archive(args: BaseArgs): Result<Notification>;
181
+ archive(args: InstanceArgs): Result<Notification>;
182
+ unarchive(args: BaseArgs): Result<Notification>;
183
+ unarchive(args: InstanceArgs): Result<Notification>;
184
+ delete(args: BaseArgs): Result<void>;
185
+ delete(args: InstanceArgs): Result<void>;
186
+ snooze(args: SnoozeArgs): Result<Notification>;
187
+ unsnooze(args: BaseArgs): Result<Notification>;
188
+ unsnooze(args: InstanceArgs): Result<Notification>;
189
+ completePrimary(args: BaseArgs): Result<Notification>;
190
+ completePrimary(args: InstanceArgs): Result<Notification>;
191
+ completeSecondary(args: BaseArgs): Result<Notification>;
192
+ completeSecondary(args: InstanceArgs): Result<Notification>;
193
+ revertPrimary(args: BaseArgs): Result<Notification>;
194
+ revertPrimary(args: InstanceArgs): Result<Notification>;
195
+ revertSecondary(args: BaseArgs): Result<Notification>;
196
+ revertSecondary(args: InstanceArgs): Result<Notification>;
197
+ readAll({ tags, data, }?: {
198
+ tags?: NotificationFilter['tags'];
199
+ data?: Record<string, unknown>;
200
+ }): Result<void>;
201
+ seenAll(args?: {
202
+ notificationIds: string[];
203
+ } | {
204
+ tags?: NotificationFilter['tags'];
205
+ data?: Record<string, unknown>;
206
+ } | {}): Result<void>;
207
+ archiveAll({ tags, data, }?: {
208
+ tags?: NotificationFilter['tags'];
209
+ data?: Record<string, unknown>;
210
+ }): Result<void>;
211
+ archiveAllRead({ tags, data }?: {
212
+ tags?: string[];
213
+ data?: Record<string, unknown>;
214
+ }): Result<void>;
215
+ deleteAll({ tags, data, }?: {
216
+ tags?: NotificationFilter['tags'];
217
+ data?: Record<string, unknown>;
218
+ }): Result<void>;
219
+ clearCache({ filter }?: {
220
+ filter?: NotificationFilter;
221
+ }): void;
222
+ triggerHelloWorldEvent(): Promise<any>;
223
+ }
224
+
10
225
  type ListPreferencesArgs = {
11
226
  tags?: string[];
12
227
  severity?: SeverityLevelEnum | SeverityLevelEnum[];
@@ -41,19 +256,6 @@ declare class PreferencesCache {
41
256
  clearAll(): void;
42
257
  }
43
258
 
44
- declare class BaseModule {
45
- #private;
46
- protected _inboxService: InboxService;
47
- protected _emitter: NovuEventEmitter;
48
- constructor({ inboxServiceInstance, eventEmitterInstance, }: {
49
- inboxServiceInstance: InboxService;
50
- eventEmitterInstance: NovuEventEmitter;
51
- });
52
- protected onSessionSuccess(_: Session): void;
53
- protected onSessionError(_: unknown): void;
54
- callWithSession<T>(fn: () => Result<T>): Result<T>;
55
- }
56
-
57
259
  type ScheduleLike = Partial<Pick<Schedule, 'isEnabled' | 'weeklySchedule'>>;
58
260
  declare class Schedule {
59
261
  #private;
@@ -134,6 +336,79 @@ declare class Preference {
134
336
  }>): Result<Preference>;
135
337
  }
136
338
 
339
+ declare class SubscriptionPreference {
340
+ #private;
341
+ readonly subscriptionId: string;
342
+ readonly workflow: Workflow;
343
+ readonly enabled: boolean;
344
+ readonly condition?: RulesLogic;
345
+ constructor(preference: SubscriptionPreferenceResponse, emitter: NovuEventEmitter, inboxService: InboxService, cache: SubscriptionsCache, useCache?: boolean);
346
+ update(args: {
347
+ value: boolean | RulesLogic;
348
+ }): Result<SubscriptionPreference>;
349
+ }
350
+
351
+ type WorkflowIdentifierOrId = string;
352
+ type WorkflowFilter = {
353
+ workflowId: WorkflowIdentifierOrId;
354
+ enabled?: boolean;
355
+ condition?: RulesLogic;
356
+ filter?: never;
357
+ };
358
+ type WorkflowGroupFilter = {
359
+ filter: {
360
+ workflowIds?: Array<WorkflowIdentifierOrId>;
361
+ tags?: string[];
362
+ };
363
+ enabled?: boolean;
364
+ condition?: RulesLogic;
365
+ workflowId?: never;
366
+ };
367
+ type PreferenceFilter = WorkflowIdentifierOrId | WorkflowFilter | WorkflowGroupFilter;
368
+ type ListSubscriptionsArgs = {
369
+ topicKey: string;
370
+ };
371
+ type GetSubscriptionArgs = {
372
+ topicKey: string;
373
+ identifier?: string;
374
+ };
375
+ type CreateSubscriptionArgs = {
376
+ topicKey: string;
377
+ topicName?: string;
378
+ identifier?: string;
379
+ name?: string;
380
+ preferences: NonEmptyArray<PreferenceFilter>;
381
+ };
382
+ type BaseUpdateSubscriptionArgs = {
383
+ topicKey: string;
384
+ subscriptionId: string;
385
+ name?: string;
386
+ preferences?: NonEmptyArray<PreferenceFilter>;
387
+ };
388
+ type InstanceUpdateSubscriptionArgs = {
389
+ subscription: TopicSubscription;
390
+ name?: string;
391
+ preferences?: NonEmptyArray<PreferenceFilter>;
392
+ };
393
+ type UpdateSubscriptionArgs = BaseUpdateSubscriptionArgs | InstanceUpdateSubscriptionArgs;
394
+ type BaseSubscriptionPreferenceArgs = {
395
+ workflowId: string;
396
+ value: boolean | RulesLogic;
397
+ };
398
+ type InstanceSubscriptionPreferenceArgs = {
399
+ preference: SubscriptionPreference;
400
+ value: boolean | RulesLogic;
401
+ };
402
+ type UpdateSubscriptionPreferenceArgs = BaseSubscriptionPreferenceArgs | InstanceSubscriptionPreferenceArgs;
403
+ type BaseDeleteSubscriptionArgs = {
404
+ subscriptionId: string;
405
+ topicKey: string;
406
+ };
407
+ type InstanceDeleteSubscriptionArgs = {
408
+ subscription: TopicSubscription;
409
+ };
410
+ type DeleteSubscriptionArgs = BaseDeleteSubscriptionArgs | InstanceDeleteSubscriptionArgs;
411
+
137
412
  type InboxServiceOptions = HttpClientOptions;
138
413
  declare class InboxService {
139
414
  #private;
@@ -236,207 +511,102 @@ declare class InboxService {
236
511
  }): Promise<PreferencesResponse>;
237
512
  fetchGlobalPreferences(): Promise<PreferencesResponse>;
238
513
  triggerHelloWorldEvent(): Promise<unknown>;
514
+ fetchSubscriptions(topicKey: string): Promise<SubscriptionResponse[]>;
515
+ getSubscription({ topicKey, identifier, }: {
516
+ topicKey: string;
517
+ identifier: string;
518
+ }): Promise<SubscriptionResponse | undefined>;
519
+ createSubscription({ identifier, name, topicKey, topicName, preferences, }: {
520
+ identifier?: string;
521
+ name?: string;
522
+ topicKey: string;
523
+ topicName?: string;
524
+ preferences: Array<PreferenceFilter>;
525
+ }): Promise<SubscriptionResponse>;
526
+ updateSubscription({ topicKey, subscriptionId, name, preferences, }: {
527
+ topicKey: string;
528
+ subscriptionId: string;
529
+ name?: string;
530
+ preferences?: Array<PreferenceFilter>;
531
+ }): Promise<SubscriptionResponse>;
532
+ updateSubscriptionPreference({ subscriptionId, workflowId, enabled, condition, }: {
533
+ subscriptionId: string;
534
+ workflowId: string;
535
+ enabled?: boolean;
536
+ condition?: RulesLogic;
537
+ }): Promise<SubscriptionPreferenceResponse>;
538
+ bulkUpdateSubscriptionPreferences(preferences: Array<{
539
+ subscriptionIdOrIdentifier: string;
540
+ workflowId: string;
541
+ enabled?: boolean;
542
+ condition?: RulesLogic;
543
+ }>): Promise<SubscriptionPreferenceResponse[]>;
544
+ deleteSubscription({ topicKey, subscriptionId }: {
545
+ topicKey: string;
546
+ subscriptionId: string;
547
+ }): Promise<void>;
239
548
  }
240
549
 
241
- declare class Notification implements Pick<NovuEventEmitter, 'on'>, InboxNotification {
242
- #private;
243
- readonly id: InboxNotification['id'];
244
- readonly transactionId: InboxNotification['transactionId'];
245
- readonly subject?: InboxNotification['subject'];
246
- readonly body: InboxNotification['body'];
247
- readonly to: InboxNotification['to'];
248
- readonly isRead: InboxNotification['isRead'];
249
- readonly isSeen: InboxNotification['isSeen'];
250
- readonly isArchived: InboxNotification['isArchived'];
251
- readonly isSnoozed: InboxNotification['isSnoozed'];
252
- readonly snoozedUntil?: InboxNotification['snoozedUntil'];
253
- readonly deliveredAt?: InboxNotification['deliveredAt'];
254
- readonly createdAt: InboxNotification['createdAt'];
255
- readonly readAt?: InboxNotification['readAt'];
256
- readonly firstSeenAt?: InboxNotification['firstSeenAt'];
257
- readonly archivedAt?: InboxNotification['archivedAt'];
258
- readonly avatar?: InboxNotification['avatar'];
259
- readonly primaryAction?: InboxNotification['primaryAction'];
260
- readonly secondaryAction?: InboxNotification['secondaryAction'];
261
- readonly channelType: InboxNotification['channelType'];
262
- readonly tags: InboxNotification['tags'];
263
- readonly redirect: InboxNotification['redirect'];
264
- readonly data?: InboxNotification['data'];
265
- readonly workflow?: InboxNotification['workflow'];
266
- readonly severity: InboxNotification['severity'];
267
- constructor(notification: InboxNotification, emitter: NovuEventEmitter, inboxService: InboxService);
268
- read(): Result<Notification>;
269
- unread(): Result<Notification>;
270
- seen(): Result<Notification>;
271
- archive(): Result<Notification>;
272
- unarchive(): Result<Notification>;
273
- delete(): Result<void>;
274
- snooze(snoozeUntil: string): Result<Notification>;
275
- unsnooze(): Result<Notification>;
276
- completePrimary(): Result<Notification>;
277
- completeSecondary(): Result<Notification>;
278
- revertPrimary(): Result<Notification>;
279
- revertSecondary(): Result<Notification>;
280
- on<Key extends EventNames>(eventName: Key, listener: EventHandler<Events[Key]>): () => void;
281
- /**
282
- * @deprecated
283
- * Use the cleanup function returned by the "on" method instead.
284
- */
285
- off<Key extends EventNames>(eventName: Key, listener: EventHandler<Events[Key]>): void;
286
- }
287
-
288
- declare class NotificationsCache {
550
+ declare class SubscriptionsCache {
289
551
  #private;
290
- constructor({ emitter }: {
291
- emitter: NovuEventEmitter;
552
+ constructor({ emitterInstance, inboxServiceInstance, useCache, }: {
553
+ emitterInstance: NovuEventEmitter;
554
+ inboxServiceInstance: InboxService;
555
+ useCache: boolean;
292
556
  });
293
- private updateNotification;
294
- private removeNotification;
295
- private handleNotificationEvent;
296
- private getAggregated;
297
- has(args: ListNotificationsArgs): boolean;
298
- set(args: ListNotificationsArgs, data: ListNotificationsResponse): void;
299
- update(args: ListNotificationsArgs, data: ListNotificationsResponse): void;
300
- getAll(args: ListNotificationsArgs): ListNotificationsResponse | undefined;
301
- /**
302
- * Get unique notifications based on specified filter fields.
303
- * The same tags and data can be applied to multiple filters which means that the same notification can be duplicated.
304
- */
305
- getUniqueNotifications({ tags, read, data, }: Pick<ListNotificationsArgs, 'tags' | 'read' | 'data'>): Array<Notification>;
306
- clear(filter: NotificationFilter): void;
557
+ private handleCreate;
558
+ private handleUpdate;
559
+ private handlePreferenceUpdate;
560
+ private handleBulkPreferenceUpdate;
561
+ private updateSubscriptionPreferences;
562
+ private createUpdatedSubscription;
563
+ private handleDelete;
564
+ private handleDeleteById;
565
+ has(args: ListSubscriptionsArgs): boolean;
566
+ set(args: ListSubscriptionsArgs, data: TopicSubscription[]): void;
567
+ setOne(args: GetSubscriptionArgs, data: TopicSubscription): void;
568
+ getAll(args: ListSubscriptionsArgs): TopicSubscription[] | undefined;
569
+ get(args: GetSubscriptionArgs): TopicSubscription | undefined;
570
+ invalidate(args: {
571
+ topicKey: string;
572
+ }): void;
307
573
  clearAll(): void;
308
574
  }
309
575
 
310
- type ListNotificationsArgs = {
311
- tags?: string[];
312
- read?: boolean;
313
- data?: Record<string, unknown>;
314
- archived?: boolean;
315
- snoozed?: boolean;
316
- seen?: boolean;
317
- severity?: SeverityLevelEnum | SeverityLevelEnum[];
318
- limit?: number;
319
- after?: string;
320
- offset?: number;
321
- useCache?: boolean;
322
- };
323
- type ListNotificationsResponse = {
324
- notifications: Notification[];
325
- hasMore: boolean;
326
- filter: NotificationFilter;
327
- };
328
- type FilterCountArgs = {
329
- tags?: string[];
330
- data?: Record<string, unknown>;
331
- read?: boolean;
332
- archived?: boolean;
333
- snoozed?: boolean;
334
- seen?: boolean;
335
- severity?: SeverityLevelEnum | SeverityLevelEnum[];
336
- };
337
- type FiltersCountArgs = {
338
- filters: Array<{
339
- tags?: string[];
340
- read?: boolean;
341
- archived?: boolean;
342
- snoozed?: boolean;
343
- seen?: boolean;
344
- data?: Record<string, unknown>;
345
- severity?: SeverityLevelEnum | SeverityLevelEnum[];
346
- }>;
347
- };
348
- type CountArgs = undefined | FilterCountArgs | FiltersCountArgs;
349
- type FilterCountResponse = {
350
- count: number;
351
- filter: NotificationFilter;
352
- };
353
- type FiltersCountResponse = {
354
- counts: Array<{
355
- count: number;
356
- filter: NotificationFilter;
357
- }>;
358
- };
359
- type CountResponse = FilterCountResponse | FiltersCountResponse;
360
- type BaseArgs = {
361
- notificationId: string;
362
- };
363
- type InstanceArgs = {
364
- notification: Notification;
365
- };
366
- type ReadArgs = BaseArgs | InstanceArgs;
367
- type UnreadArgs = BaseArgs | InstanceArgs;
368
- type ArchivedArgs = BaseArgs | InstanceArgs;
369
- type UnarchivedArgs = BaseArgs | InstanceArgs;
370
- type DeletedArgs = BaseArgs | InstanceArgs;
371
- type SeenArgs = BaseArgs | InstanceArgs;
372
- type SnoozeArgs = (BaseArgs | InstanceArgs) & {
373
- snoozeUntil: string;
374
- };
375
- type UnsnoozeArgs = BaseArgs | InstanceArgs;
376
- type CompleteArgs = BaseArgs | InstanceArgs;
377
- type RevertArgs = BaseArgs | InstanceArgs;
576
+ declare class TopicSubscription {
577
+ #private;
578
+ readonly id: string;
579
+ readonly identifier: string;
580
+ readonly topicKey: string;
581
+ readonly preferences: Array<SubscriptionPreference>;
582
+ constructor(subscription: SubscriptionResponse & {
583
+ topicKey: string;
584
+ }, emitter: NovuEventEmitter, inboxService: InboxService, cache: SubscriptionsCache, useCache?: boolean);
585
+ update(args: BaseUpdateSubscriptionArgs): Result<TopicSubscription>;
586
+ update(args: InstanceUpdateSubscriptionArgs): Result<TopicSubscription>;
587
+ updatePreference(args: BaseSubscriptionPreferenceArgs): Result<SubscriptionPreference>;
588
+ updatePreference(args: InstanceSubscriptionPreferenceArgs): Result<SubscriptionPreference>;
589
+ bulkUpdatePreferences(args: Array<BaseSubscriptionPreferenceArgs>): Result<SubscriptionPreference[]>;
590
+ bulkUpdatePreferences(args: Array<InstanceSubscriptionPreferenceArgs>): Result<SubscriptionPreference[]>;
591
+ delete(): Result<void>;
592
+ }
378
593
 
379
- declare class Notifications extends BaseModule {
594
+ declare class Subscriptions extends BaseModule {
380
595
  #private;
381
- readonly cache: NotificationsCache;
382
- constructor({ useCache, inboxServiceInstance, eventEmitterInstance, }: {
596
+ readonly cache: SubscriptionsCache;
597
+ constructor({ useCache, inboxServiceInstance, eventEmitterInstance, subscriber, }: {
383
598
  useCache: boolean;
384
599
  inboxServiceInstance: InboxService;
385
600
  eventEmitterInstance: NovuEventEmitter;
601
+ subscriber: Subscriber;
386
602
  });
387
- get inboxService(): InboxService;
388
- list({ limit, ...restOptions }?: ListNotificationsArgs): Result<ListNotificationsResponse>;
389
- count(args?: FilterCountArgs): Result<FilterCountResponse>;
390
- count(args?: FiltersCountArgs): Result<FiltersCountResponse>;
391
- read(args: BaseArgs): Result<Notification>;
392
- read(args: InstanceArgs): Result<Notification>;
393
- unread(args: BaseArgs): Result<Notification>;
394
- unread(args: InstanceArgs): Result<Notification>;
395
- seen(args: BaseArgs): Result<Notification>;
396
- seen(args: InstanceArgs): Result<Notification>;
397
- archive(args: BaseArgs): Result<Notification>;
398
- archive(args: InstanceArgs): Result<Notification>;
399
- unarchive(args: BaseArgs): Result<Notification>;
400
- unarchive(args: InstanceArgs): Result<Notification>;
401
- delete(args: BaseArgs): Result<void>;
402
- delete(args: InstanceArgs): Result<void>;
403
- snooze(args: SnoozeArgs): Result<Notification>;
404
- unsnooze(args: BaseArgs): Result<Notification>;
405
- unsnooze(args: InstanceArgs): Result<Notification>;
406
- completePrimary(args: BaseArgs): Result<Notification>;
407
- completePrimary(args: InstanceArgs): Result<Notification>;
408
- completeSecondary(args: BaseArgs): Result<Notification>;
409
- completeSecondary(args: InstanceArgs): Result<Notification>;
410
- revertPrimary(args: BaseArgs): Result<Notification>;
411
- revertPrimary(args: InstanceArgs): Result<Notification>;
412
- revertSecondary(args: BaseArgs): Result<Notification>;
413
- revertSecondary(args: InstanceArgs): Result<Notification>;
414
- readAll({ tags, data, }?: {
415
- tags?: NotificationFilter['tags'];
416
- data?: Record<string, unknown>;
417
- }): Result<void>;
418
- seenAll(args?: {
419
- notificationIds: string[];
420
- } | {
421
- tags?: NotificationFilter['tags'];
422
- data?: Record<string, unknown>;
423
- } | {}): Result<void>;
424
- archiveAll({ tags, data, }?: {
425
- tags?: NotificationFilter['tags'];
426
- data?: Record<string, unknown>;
427
- }): Result<void>;
428
- archiveAllRead({ tags, data }?: {
429
- tags?: string[];
430
- data?: Record<string, unknown>;
431
- }): Result<void>;
432
- deleteAll({ tags, data, }?: {
433
- tags?: NotificationFilter['tags'];
434
- data?: Record<string, unknown>;
435
- }): Result<void>;
436
- clearCache({ filter }?: {
437
- filter?: NotificationFilter;
438
- }): void;
439
- triggerHelloWorldEvent(): Promise<any>;
603
+ list(args: ListSubscriptionsArgs, options?: Options): Result<TopicSubscription[]>;
604
+ get(args: GetSubscriptionArgs, options?: Options): Result<TopicSubscription | null>;
605
+ create(args: CreateSubscriptionArgs): Result<TopicSubscription>;
606
+ update(args: BaseUpdateSubscriptionArgs): Result<TopicSubscription>;
607
+ update(args: InstanceUpdateSubscriptionArgs): Result<TopicSubscription>;
608
+ delete(args: BaseDeleteSubscriptionArgs): Result<void>;
609
+ delete(args: InstanceDeleteSubscriptionArgs): Result<void>;
440
610
  }
441
611
 
442
612
  type KeylessInitializeSessionArgs = {} & {
@@ -504,6 +674,15 @@ type PreferenceUpdateEvents = BaseEvents<'preference.update', UpdatePreferenceAr
504
674
  type PreferencesBulkUpdateEvents = BaseEvents<'preferences.bulk_update', Array<UpdatePreferenceArgs>, Preference[]>;
505
675
  type PreferenceScheduleGetEvents = BaseEvents<'preference.schedule.get', undefined, Schedule>;
506
676
  type PreferenceScheduleUpdateEvents = BaseEvents<'preference.schedule.update', UpdateScheduleArgs, Schedule>;
677
+ type SubscriptionsFetchEvents = BaseEvents<'subscriptions.list', ListSubscriptionsArgs, TopicSubscription[]>;
678
+ type SubscriptionGetEvents = BaseEvents<'subscription.get', GetSubscriptionArgs, TopicSubscription | null>;
679
+ type SubscriptionCreateEvents = BaseEvents<'subscription.create', CreateSubscriptionArgs, TopicSubscription>;
680
+ type SubscriptionUpdateEvents = BaseEvents<'subscription.update', UpdateSubscriptionArgs, TopicSubscription>;
681
+ type SubscriptionPreferenceUpdateEvents = BaseEvents<'subscription.preference.update', UpdateSubscriptionPreferenceArgs, SubscriptionPreference>;
682
+ type SubscriptionPreferencesBulkUpdateEvents = BaseEvents<'subscription.preferences.bulk_update', Array<UpdateSubscriptionPreferenceArgs & {
683
+ subscriptionId: string;
684
+ }>, SubscriptionPreference[]>;
685
+ type SubscriptionDeleteEvents = BaseEvents<'subscription.delete', DeleteSubscriptionArgs, void>;
507
686
  type SocketConnectEvents = BaseEvents<'socket.connect', {
508
687
  socketUrl: string;
509
688
  }, undefined>;
@@ -550,6 +729,13 @@ type Events = SessionInitializeEvents & NotificationsFetchEvents & {
550
729
  'preference.schedule.get.updated': {
551
730
  data: Schedule;
552
731
  };
732
+ } & SubscriptionsFetchEvents & SubscriptionGetEvents & SubscriptionCreateEvents & SubscriptionPreferenceUpdateEvents & SubscriptionUpdateEvents & SubscriptionPreferencesBulkUpdateEvents & SubscriptionDeleteEvents & {
733
+ 'subscriptions.list.updated': {
734
+ data: {
735
+ topicKey: string;
736
+ subscriptions: TopicSubscription[];
737
+ };
738
+ };
553
739
  } & SocketConnectEvents & SocketEvents & NotificationReadEvents & NotificationUnreadEvents & NotificationSeenEvents & NotificationArchiveEvents & NotificationUnarchiveEvents & NotificationDeleteEvents & NotificationSnoozeEvents & NotificationUnsnoozeEvents & NotificationCompleteActionEvents & NotificationRevertActionEvents & NotificationsReadAllEvents & NotificationsSeenAllEvents & NotificationsArchivedAllEvents & NotificationsReadArchivedAllEvents & NotificationsDeletedAllEvents;
554
740
  type EventNames = keyof Events;
555
741
  type SocketEventNames = keyof SocketEvents;
@@ -573,6 +759,7 @@ declare class Novu implements Pick<NovuEventEmitter, 'on'> {
573
759
  #private;
574
760
  readonly notifications: Notifications;
575
761
  readonly preferences: Preferences;
762
+ readonly subscriptions: Subscriptions;
576
763
  readonly socket: BaseSocketInterface;
577
764
  on: <Key extends EventNames>(eventName: Key, listener: EventHandler<Events[Key]>) => () => void;
578
765
  /**
@@ -583,16 +770,24 @@ declare class Novu implements Pick<NovuEventEmitter, 'on'> {
583
770
  get applicationIdentifier(): string | undefined;
584
771
  get subscriberId(): string | undefined;
585
772
  get context(): Partial<Record<string, ContextValue>> | undefined;
773
+ get options(): NovuOptions;
586
774
  get contextKey(): string;
587
775
  constructor(options: NovuOptions);
776
+ private clearCache;
777
+ /**
778
+ * @deprecated
779
+ */
588
780
  changeSubscriber(options: {
589
781
  subscriber: Subscriber;
590
782
  subscriberHash?: string;
591
783
  }): Promise<void>;
784
+ /**
785
+ * @deprecated
786
+ */
592
787
  changeContext(options: {
593
788
  context: Context;
594
789
  contextHash?: string;
595
790
  }): Promise<void>;
596
791
  }
597
792
 
598
- export { type EventHandler as E, type FiltersCountResponse as F, type ListNotificationsResponse as L, Notification as N, Preference as P, type SocketEventNames as S, type Events as a, Novu as b, Schedule as c };
793
+ export { type BaseDeleteSubscriptionArgs as B, type CreateSubscriptionArgs as C, type DeleteSubscriptionArgs as D, type EventHandler as E, type FiltersCountResponse as F, type GetSubscriptionArgs as G, type InstanceDeleteSubscriptionArgs as I, type ListSubscriptionsArgs as L, Notification as N, type PreferenceFilter as P, type SocketEventNames as S, TopicSubscription as T, type UpdateSubscriptionArgs as U, type WorkflowFilter as W, type Events as a, Novu as b, type WorkflowGroupFilter as c, type WorkflowIdentifierOrId as d, type BaseUpdateSubscriptionArgs as e, type InstanceUpdateSubscriptionArgs as f, SubscriptionPreference as g, type UpdateSubscriptionPreferenceArgs as h, type ListNotificationsResponse as i, Preference as j, Schedule as k };