@novu/js 3.17.0 → 3.18.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.
- package/dist/cjs/{chunk-7B52C2XE.js → chunk-A6CBLMST.js} +9 -0
- package/dist/cjs/{chunk-SP44ETLM.js → chunk-NR4RSYUE.js} +772 -694
- package/dist/cjs/{chunk-WDGG3OER.js → chunk-TLQQB5Y7.js} +217 -199
- package/dist/{esm/inbox-service-CGCuuYnv.d.mts → cjs/inbox-service-DSSwFYNG.d.ts} +18 -2
- package/dist/cjs/index.d.ts +93 -4
- package/dist/cjs/index.js +246 -20
- package/dist/cjs/internal/index.d.ts +1 -1
- package/dist/cjs/internal/index.js +7 -7
- package/dist/cjs/{novu-CmNBco-0.d.ts → novu-BQCC3vQS.d.ts} +3 -2
- package/dist/cjs/themes/index.d.ts +3 -3
- package/dist/cjs/themes/index.js +1 -1
- package/dist/cjs/{types-BF6zvyj6.d.ts → types-Djf8MaW9.d.ts} +2 -2
- package/dist/cjs/ui/index.d.ts +18 -6
- package/dist/cjs/ui/index.js +609 -243
- package/dist/esm/{chunk-BKA3HRZM.mjs → chunk-33B2GJE2.mjs} +140 -64
- package/dist/esm/{chunk-STZMOEWR.mjs → chunk-3LR3AF54.mjs} +9 -1
- package/dist/esm/{chunk-4S22IB5W.mjs → chunk-T3NTOGY3.mjs} +193 -176
- package/dist/{cjs/inbox-service-CGCuuYnv.d.ts → esm/inbox-service-DSSwFYNG.d.mts} +18 -2
- package/dist/esm/index.d.mts +93 -4
- package/dist/esm/index.mjs +228 -3
- package/dist/esm/internal/index.d.mts +1 -1
- package/dist/esm/internal/index.mjs +2 -2
- package/dist/esm/{novu-CFYEiYN8.d.mts → novu-Z0z0-IxO.d.mts} +3 -2
- package/dist/esm/themes/index.d.mts +3 -3
- package/dist/esm/themes/index.mjs +1 -1
- package/dist/esm/{types-CJKmgwu6.d.mts → types-BJ345m1Q.d.mts} +2 -2
- package/dist/esm/ui/index.d.mts +18 -6
- package/dist/esm/ui/index.mjs +424 -58
- package/dist/novu.min.js +15 -15
- package/dist/novu.min.js.gz +0 -0
- package/package.json +7 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __privateAdd, __privateSet, __privateGet, __async, __spreadProps, __spreadValues } from './chunk-3LR3AF54.mjs';
|
|
2
2
|
|
|
3
3
|
// src/ui/internal/buildContextKey.ts
|
|
4
4
|
function buildContextKey(context) {
|
|
@@ -93,7 +93,193 @@ var NovuError = class extends Error {
|
|
|
93
93
|
}
|
|
94
94
|
};
|
|
95
95
|
|
|
96
|
+
// src/notifications/notification.ts
|
|
97
|
+
var _emitter, _inboxService;
|
|
98
|
+
var Notification = class {
|
|
99
|
+
constructor(notification, emitter, inboxService) {
|
|
100
|
+
__privateAdd(this, _emitter);
|
|
101
|
+
__privateAdd(this, _inboxService);
|
|
102
|
+
__privateSet(this, _emitter, emitter);
|
|
103
|
+
__privateSet(this, _inboxService, inboxService);
|
|
104
|
+
this.id = notification.id;
|
|
105
|
+
this.transactionId = notification.transactionId;
|
|
106
|
+
this.subject = notification.subject;
|
|
107
|
+
this.body = notification.body;
|
|
108
|
+
this.to = notification.to;
|
|
109
|
+
this.isRead = notification.isRead;
|
|
110
|
+
this.isSeen = notification.isSeen;
|
|
111
|
+
this.isArchived = notification.isArchived;
|
|
112
|
+
this.isSnoozed = notification.isSnoozed;
|
|
113
|
+
this.snoozedUntil = notification.snoozedUntil;
|
|
114
|
+
this.deliveredAt = notification.deliveredAt;
|
|
115
|
+
this.createdAt = notification.createdAt;
|
|
116
|
+
this.readAt = notification.readAt;
|
|
117
|
+
this.firstSeenAt = notification.firstSeenAt;
|
|
118
|
+
this.archivedAt = notification.archivedAt;
|
|
119
|
+
this.avatar = notification.avatar;
|
|
120
|
+
this.primaryAction = notification.primaryAction;
|
|
121
|
+
this.secondaryAction = notification.secondaryAction;
|
|
122
|
+
this.channelType = notification.channelType;
|
|
123
|
+
this.tags = notification.tags;
|
|
124
|
+
this.redirect = notification.redirect;
|
|
125
|
+
this.data = notification.data;
|
|
126
|
+
this.workflow = notification.workflow;
|
|
127
|
+
this.severity = notification.severity;
|
|
128
|
+
}
|
|
129
|
+
read() {
|
|
130
|
+
return read({
|
|
131
|
+
emitter: __privateGet(this, _emitter),
|
|
132
|
+
apiService: __privateGet(this, _inboxService),
|
|
133
|
+
args: {
|
|
134
|
+
notification: this
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
unread() {
|
|
139
|
+
return unread({
|
|
140
|
+
emitter: __privateGet(this, _emitter),
|
|
141
|
+
apiService: __privateGet(this, _inboxService),
|
|
142
|
+
args: {
|
|
143
|
+
notification: this
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
seen() {
|
|
148
|
+
return seen({
|
|
149
|
+
emitter: __privateGet(this, _emitter),
|
|
150
|
+
apiService: __privateGet(this, _inboxService),
|
|
151
|
+
args: {
|
|
152
|
+
notification: this
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
archive() {
|
|
157
|
+
return archive({
|
|
158
|
+
emitter: __privateGet(this, _emitter),
|
|
159
|
+
apiService: __privateGet(this, _inboxService),
|
|
160
|
+
args: {
|
|
161
|
+
notification: this
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
unarchive() {
|
|
166
|
+
return unarchive({
|
|
167
|
+
emitter: __privateGet(this, _emitter),
|
|
168
|
+
apiService: __privateGet(this, _inboxService),
|
|
169
|
+
args: {
|
|
170
|
+
notification: this
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
delete() {
|
|
175
|
+
return deleteNotification({
|
|
176
|
+
emitter: __privateGet(this, _emitter),
|
|
177
|
+
apiService: __privateGet(this, _inboxService),
|
|
178
|
+
args: {
|
|
179
|
+
notification: this
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
snooze(snoozeUntil) {
|
|
184
|
+
return snooze({
|
|
185
|
+
emitter: __privateGet(this, _emitter),
|
|
186
|
+
apiService: __privateGet(this, _inboxService),
|
|
187
|
+
args: {
|
|
188
|
+
notification: this,
|
|
189
|
+
snoozeUntil
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
unsnooze() {
|
|
194
|
+
return unsnooze({
|
|
195
|
+
emitter: __privateGet(this, _emitter),
|
|
196
|
+
apiService: __privateGet(this, _inboxService),
|
|
197
|
+
args: { notification: this }
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
completePrimary() {
|
|
201
|
+
if (!this.primaryAction) {
|
|
202
|
+
throw new Error("Primary action is not available");
|
|
203
|
+
}
|
|
204
|
+
return completeAction({
|
|
205
|
+
emitter: __privateGet(this, _emitter),
|
|
206
|
+
apiService: __privateGet(this, _inboxService),
|
|
207
|
+
args: {
|
|
208
|
+
notification: this
|
|
209
|
+
},
|
|
210
|
+
actionType: "primary" /* PRIMARY */
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
completeSecondary() {
|
|
214
|
+
if (!this.primaryAction) {
|
|
215
|
+
throw new Error("Secondary action is not available");
|
|
216
|
+
}
|
|
217
|
+
return completeAction({
|
|
218
|
+
emitter: __privateGet(this, _emitter),
|
|
219
|
+
apiService: __privateGet(this, _inboxService),
|
|
220
|
+
args: {
|
|
221
|
+
notification: this
|
|
222
|
+
},
|
|
223
|
+
actionType: "secondary" /* SECONDARY */
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
revertPrimary() {
|
|
227
|
+
if (!this.primaryAction) {
|
|
228
|
+
throw new Error("Primary action is not available");
|
|
229
|
+
}
|
|
230
|
+
return revertAction({
|
|
231
|
+
emitter: __privateGet(this, _emitter),
|
|
232
|
+
apiService: __privateGet(this, _inboxService),
|
|
233
|
+
args: {
|
|
234
|
+
notification: this
|
|
235
|
+
},
|
|
236
|
+
actionType: "primary" /* PRIMARY */
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
revertSecondary() {
|
|
240
|
+
if (!this.primaryAction) {
|
|
241
|
+
throw new Error("Secondary action is not available");
|
|
242
|
+
}
|
|
243
|
+
return revertAction({
|
|
244
|
+
emitter: __privateGet(this, _emitter),
|
|
245
|
+
apiService: __privateGet(this, _inboxService),
|
|
246
|
+
args: {
|
|
247
|
+
notification: this
|
|
248
|
+
},
|
|
249
|
+
actionType: "secondary" /* SECONDARY */
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
on(eventName, listener) {
|
|
253
|
+
const cleanup = __privateGet(this, _emitter).on(eventName, listener);
|
|
254
|
+
return () => {
|
|
255
|
+
cleanup();
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* @deprecated
|
|
260
|
+
* Use the cleanup function returned by the "on" method instead.
|
|
261
|
+
*/
|
|
262
|
+
off(eventName, listener) {
|
|
263
|
+
__privateGet(this, _emitter).off(eventName, listener);
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
_emitter = new WeakMap();
|
|
267
|
+
_inboxService = new WeakMap();
|
|
268
|
+
|
|
96
269
|
// src/notifications/helpers.ts
|
|
270
|
+
function ensureNotificationInstance({
|
|
271
|
+
notification,
|
|
272
|
+
emitter,
|
|
273
|
+
inboxService
|
|
274
|
+
}) {
|
|
275
|
+
if (notification instanceof Notification) {
|
|
276
|
+
return notification;
|
|
277
|
+
}
|
|
278
|
+
if (typeof notification.read === "function") {
|
|
279
|
+
return notification;
|
|
280
|
+
}
|
|
281
|
+
return new Notification(notification, emitter, inboxService);
|
|
282
|
+
}
|
|
97
283
|
var read = (_0) => __async(null, [_0], function* ({
|
|
98
284
|
emitter,
|
|
99
285
|
apiService,
|
|
@@ -561,186 +747,17 @@ var deleteAll = (_0) => __async(null, [_0], function* ({
|
|
|
561
747
|
}
|
|
562
748
|
});
|
|
563
749
|
|
|
564
|
-
// src/notifications/notification.ts
|
|
565
|
-
var _emitter, _inboxService;
|
|
566
|
-
var Notification = class {
|
|
567
|
-
constructor(notification, emitter, inboxService) {
|
|
568
|
-
__privateAdd(this, _emitter);
|
|
569
|
-
__privateAdd(this, _inboxService);
|
|
570
|
-
__privateSet(this, _emitter, emitter);
|
|
571
|
-
__privateSet(this, _inboxService, inboxService);
|
|
572
|
-
this.id = notification.id;
|
|
573
|
-
this.transactionId = notification.transactionId;
|
|
574
|
-
this.subject = notification.subject;
|
|
575
|
-
this.body = notification.body;
|
|
576
|
-
this.to = notification.to;
|
|
577
|
-
this.isRead = notification.isRead;
|
|
578
|
-
this.isSeen = notification.isSeen;
|
|
579
|
-
this.isArchived = notification.isArchived;
|
|
580
|
-
this.isSnoozed = notification.isSnoozed;
|
|
581
|
-
this.snoozedUntil = notification.snoozedUntil;
|
|
582
|
-
this.deliveredAt = notification.deliveredAt;
|
|
583
|
-
this.createdAt = notification.createdAt;
|
|
584
|
-
this.readAt = notification.readAt;
|
|
585
|
-
this.firstSeenAt = notification.firstSeenAt;
|
|
586
|
-
this.archivedAt = notification.archivedAt;
|
|
587
|
-
this.avatar = notification.avatar;
|
|
588
|
-
this.primaryAction = notification.primaryAction;
|
|
589
|
-
this.secondaryAction = notification.secondaryAction;
|
|
590
|
-
this.channelType = notification.channelType;
|
|
591
|
-
this.tags = notification.tags;
|
|
592
|
-
this.redirect = notification.redirect;
|
|
593
|
-
this.data = notification.data;
|
|
594
|
-
this.workflow = notification.workflow;
|
|
595
|
-
this.severity = notification.severity;
|
|
596
|
-
}
|
|
597
|
-
read() {
|
|
598
|
-
return read({
|
|
599
|
-
emitter: __privateGet(this, _emitter),
|
|
600
|
-
apiService: __privateGet(this, _inboxService),
|
|
601
|
-
args: {
|
|
602
|
-
notification: this
|
|
603
|
-
}
|
|
604
|
-
});
|
|
605
|
-
}
|
|
606
|
-
unread() {
|
|
607
|
-
return unread({
|
|
608
|
-
emitter: __privateGet(this, _emitter),
|
|
609
|
-
apiService: __privateGet(this, _inboxService),
|
|
610
|
-
args: {
|
|
611
|
-
notification: this
|
|
612
|
-
}
|
|
613
|
-
});
|
|
614
|
-
}
|
|
615
|
-
seen() {
|
|
616
|
-
return seen({
|
|
617
|
-
emitter: __privateGet(this, _emitter),
|
|
618
|
-
apiService: __privateGet(this, _inboxService),
|
|
619
|
-
args: {
|
|
620
|
-
notification: this
|
|
621
|
-
}
|
|
622
|
-
});
|
|
623
|
-
}
|
|
624
|
-
archive() {
|
|
625
|
-
return archive({
|
|
626
|
-
emitter: __privateGet(this, _emitter),
|
|
627
|
-
apiService: __privateGet(this, _inboxService),
|
|
628
|
-
args: {
|
|
629
|
-
notification: this
|
|
630
|
-
}
|
|
631
|
-
});
|
|
632
|
-
}
|
|
633
|
-
unarchive() {
|
|
634
|
-
return unarchive({
|
|
635
|
-
emitter: __privateGet(this, _emitter),
|
|
636
|
-
apiService: __privateGet(this, _inboxService),
|
|
637
|
-
args: {
|
|
638
|
-
notification: this
|
|
639
|
-
}
|
|
640
|
-
});
|
|
641
|
-
}
|
|
642
|
-
delete() {
|
|
643
|
-
return deleteNotification({
|
|
644
|
-
emitter: __privateGet(this, _emitter),
|
|
645
|
-
apiService: __privateGet(this, _inboxService),
|
|
646
|
-
args: {
|
|
647
|
-
notification: this
|
|
648
|
-
}
|
|
649
|
-
});
|
|
650
|
-
}
|
|
651
|
-
snooze(snoozeUntil) {
|
|
652
|
-
return snooze({
|
|
653
|
-
emitter: __privateGet(this, _emitter),
|
|
654
|
-
apiService: __privateGet(this, _inboxService),
|
|
655
|
-
args: {
|
|
656
|
-
notification: this,
|
|
657
|
-
snoozeUntil
|
|
658
|
-
}
|
|
659
|
-
});
|
|
660
|
-
}
|
|
661
|
-
unsnooze() {
|
|
662
|
-
return unsnooze({
|
|
663
|
-
emitter: __privateGet(this, _emitter),
|
|
664
|
-
apiService: __privateGet(this, _inboxService),
|
|
665
|
-
args: { notification: this }
|
|
666
|
-
});
|
|
667
|
-
}
|
|
668
|
-
completePrimary() {
|
|
669
|
-
if (!this.primaryAction) {
|
|
670
|
-
throw new Error("Primary action is not available");
|
|
671
|
-
}
|
|
672
|
-
return completeAction({
|
|
673
|
-
emitter: __privateGet(this, _emitter),
|
|
674
|
-
apiService: __privateGet(this, _inboxService),
|
|
675
|
-
args: {
|
|
676
|
-
notification: this
|
|
677
|
-
},
|
|
678
|
-
actionType: "primary" /* PRIMARY */
|
|
679
|
-
});
|
|
680
|
-
}
|
|
681
|
-
completeSecondary() {
|
|
682
|
-
if (!this.primaryAction) {
|
|
683
|
-
throw new Error("Secondary action is not available");
|
|
684
|
-
}
|
|
685
|
-
return completeAction({
|
|
686
|
-
emitter: __privateGet(this, _emitter),
|
|
687
|
-
apiService: __privateGet(this, _inboxService),
|
|
688
|
-
args: {
|
|
689
|
-
notification: this
|
|
690
|
-
},
|
|
691
|
-
actionType: "secondary" /* SECONDARY */
|
|
692
|
-
});
|
|
693
|
-
}
|
|
694
|
-
revertPrimary() {
|
|
695
|
-
if (!this.primaryAction) {
|
|
696
|
-
throw new Error("Primary action is not available");
|
|
697
|
-
}
|
|
698
|
-
return revertAction({
|
|
699
|
-
emitter: __privateGet(this, _emitter),
|
|
700
|
-
apiService: __privateGet(this, _inboxService),
|
|
701
|
-
args: {
|
|
702
|
-
notification: this
|
|
703
|
-
},
|
|
704
|
-
actionType: "primary" /* PRIMARY */
|
|
705
|
-
});
|
|
706
|
-
}
|
|
707
|
-
revertSecondary() {
|
|
708
|
-
if (!this.primaryAction) {
|
|
709
|
-
throw new Error("Secondary action is not available");
|
|
710
|
-
}
|
|
711
|
-
return revertAction({
|
|
712
|
-
emitter: __privateGet(this, _emitter),
|
|
713
|
-
apiService: __privateGet(this, _inboxService),
|
|
714
|
-
args: {
|
|
715
|
-
notification: this
|
|
716
|
-
},
|
|
717
|
-
actionType: "secondary" /* SECONDARY */
|
|
718
|
-
});
|
|
719
|
-
}
|
|
720
|
-
on(eventName, listener) {
|
|
721
|
-
const cleanup = __privateGet(this, _emitter).on(eventName, listener);
|
|
722
|
-
return () => {
|
|
723
|
-
cleanup();
|
|
724
|
-
};
|
|
725
|
-
}
|
|
726
|
-
/**
|
|
727
|
-
* @deprecated
|
|
728
|
-
* Use the cleanup function returned by the "on" method instead.
|
|
729
|
-
*/
|
|
730
|
-
off(eventName, listener) {
|
|
731
|
-
__privateGet(this, _emitter).off(eventName, listener);
|
|
732
|
-
}
|
|
733
|
-
};
|
|
734
|
-
_emitter = new WeakMap();
|
|
735
|
-
_inboxService = new WeakMap();
|
|
736
|
-
|
|
737
750
|
// src/ui/internal/createNotification.ts
|
|
738
751
|
function createNotification({
|
|
739
752
|
emitter,
|
|
740
753
|
inboxService,
|
|
741
754
|
notification
|
|
742
755
|
}) {
|
|
743
|
-
return
|
|
756
|
+
return ensureNotificationInstance({
|
|
757
|
+
notification,
|
|
758
|
+
emitter,
|
|
759
|
+
inboxService
|
|
760
|
+
});
|
|
744
761
|
}
|
|
745
762
|
|
|
746
763
|
// src/ui/internal/parseMarkdown.tsx
|
|
@@ -799,4 +816,4 @@ var parseMarkdownIntoTokens = (text) => {
|
|
|
799
816
|
return tokens;
|
|
800
817
|
};
|
|
801
818
|
|
|
802
|
-
export { ChannelType, Notification, NotificationStatus, NovuError, PreferenceLevel, SeverityLevelEnum, WebSocketEvent, WorkflowCriticalityEnum, archive, archiveAll, archiveAllRead, buildContextKey, buildSubscriber, buildSubscriptionIdentifier, completeAction, createNotification, deleteAll, deleteNotification, parseMarkdownIntoTokens, read, readAll, revertAction, seen, seenAll, snooze, unarchive, unread, unsnooze };
|
|
819
|
+
export { ChannelType, Notification, NotificationStatus, NovuError, PreferenceLevel, SeverityLevelEnum, WebSocketEvent, WorkflowCriticalityEnum, archive, archiveAll, archiveAllRead, buildContextKey, buildSubscriber, buildSubscriptionIdentifier, completeAction, createNotification, deleteAll, deleteNotification, ensureNotificationInstance, parseMarkdownIntoTokens, read, readAll, revertAction, seen, seenAll, snooze, unarchive, unread, unsnooze };
|
|
@@ -301,6 +301,7 @@ type ChannelEndpointsFetchEvents = BaseEvents<'channel-endpoints.list', ListChan
|
|
|
301
301
|
type ChannelEndpointGetEvents = BaseEvents<'channel-endpoint.get', GetChannelEndpointArgs, ChannelEndpointResponse | null>;
|
|
302
302
|
type ChannelEndpointCreateEvents = BaseEvents<'channel-endpoint.create', CreateChannelEndpointArgs, ChannelEndpointResponse>;
|
|
303
303
|
type ChannelEndpointDeleteEvents = BaseEvents<'channel-endpoint.delete', DeleteChannelEndpointArgs, void>;
|
|
304
|
+
type ChannelEndpointLinkEvents = BaseEvents<'channel-endpoint.link', LinkChannelEndpointArgs, LinkChannelEndpointResponse>;
|
|
304
305
|
type SocketConnectEvents = BaseEvents<'socket.connect', {
|
|
305
306
|
socketUrl: string;
|
|
306
307
|
}, undefined>;
|
|
@@ -354,7 +355,7 @@ type Events = SessionInitializeEvents & NotificationsFetchEvents & {
|
|
|
354
355
|
subscriptions: TopicSubscription[];
|
|
355
356
|
};
|
|
356
357
|
};
|
|
357
|
-
} & ChannelConnectionOAuthUrlEvents & ChannelConnectionsFetchEvents & ChannelConnectionGetEvents & ChannelConnectionDeleteEvents & ChannelEndpointOAuthUrlEvents & ChannelEndpointsFetchEvents & ChannelEndpointGetEvents & ChannelEndpointCreateEvents & ChannelEndpointDeleteEvents & SocketConnectEvents & SocketEvents & NotificationReadEvents & NotificationUnreadEvents & NotificationSeenEvents & NotificationArchiveEvents & NotificationUnarchiveEvents & NotificationDeleteEvents & NotificationSnoozeEvents & NotificationUnsnoozeEvents & NotificationCompleteActionEvents & NotificationRevertActionEvents & NotificationsReadAllEvents & NotificationsSeenAllEvents & NotificationsArchivedAllEvents & NotificationsReadArchivedAllEvents & NotificationsDeletedAllEvents;
|
|
358
|
+
} & ChannelConnectionOAuthUrlEvents & ChannelConnectionsFetchEvents & ChannelConnectionGetEvents & ChannelConnectionDeleteEvents & ChannelEndpointOAuthUrlEvents & ChannelEndpointsFetchEvents & ChannelEndpointGetEvents & ChannelEndpointCreateEvents & ChannelEndpointDeleteEvents & ChannelEndpointLinkEvents & SocketConnectEvents & SocketEvents & NotificationReadEvents & NotificationUnreadEvents & NotificationSeenEvents & NotificationArchiveEvents & NotificationUnarchiveEvents & NotificationDeleteEvents & NotificationSnoozeEvents & NotificationUnsnoozeEvents & NotificationCompleteActionEvents & NotificationRevertActionEvents & NotificationsReadAllEvents & NotificationsSeenAllEvents & NotificationsArchivedAllEvents & NotificationsReadArchivedAllEvents & NotificationsDeletedAllEvents;
|
|
358
359
|
type EventNames = keyof Events;
|
|
359
360
|
type SocketEventNames = keyof SocketEvents;
|
|
360
361
|
type EventHandler<T = unknown> = (event: T) => void;
|
|
@@ -864,6 +865,20 @@ type CreateChannelEndpointArgs = {
|
|
|
864
865
|
type DeleteChannelEndpointArgs = {
|
|
865
866
|
identifier: string;
|
|
866
867
|
};
|
|
868
|
+
/**
|
|
869
|
+
* Args for issuing a provider-specific URL the subscriber opens to link their
|
|
870
|
+
* chat identity (e.g. a Telegram `t.me` deep link). The subscriber is derived
|
|
871
|
+
* from the session token, so only the integration identifier is required.
|
|
872
|
+
*/
|
|
873
|
+
type LinkChannelEndpointArgs = {
|
|
874
|
+
integrationIdentifier: string;
|
|
875
|
+
};
|
|
876
|
+
type LinkChannelEndpointResponse = {
|
|
877
|
+
/** URL the subscriber opens to link their chat identity (deep link or OAuth URL). */
|
|
878
|
+
url: string;
|
|
879
|
+
/** Provider-specific metadata returned alongside the link URL (e.g. Telegram `botUsername`, `expiresAt`). */
|
|
880
|
+
providerMetadata?: Record<string, unknown>;
|
|
881
|
+
};
|
|
867
882
|
|
|
868
883
|
type InboxServiceOptions = HttpClientOptions;
|
|
869
884
|
declare class InboxService {
|
|
@@ -1038,6 +1053,7 @@ declare class InboxService {
|
|
|
1038
1053
|
getChannelEndpoint(identifier: string): Promise<ChannelEndpointResponse>;
|
|
1039
1054
|
createChannelEndpoint({ identifier, integrationIdentifier, connectionIdentifier, subscriberId, context, type, endpoint, }: CreateChannelEndpointArgs): Promise<ChannelEndpointResponse>;
|
|
1040
1055
|
deleteChannelEndpoint(identifier: string): Promise<void>;
|
|
1056
|
+
linkChannelEndpoint({ integrationIdentifier }: LinkChannelEndpointArgs): Promise<LinkChannelEndpointResponse>;
|
|
1041
1057
|
}
|
|
1042
1058
|
|
|
1043
|
-
export { type
|
|
1059
|
+
export { type UnreadCount as $, type NovuOptions as A, type BaseDeleteSubscriptionArgs as B, type ChannelConnectionResponse as C, type DaySchedule as D, type EventHandler as E, type FiltersCountResponse as F, type GenerateChatOAuthUrlArgs as G, type NovuSocketOptions as H, type InboxNotification as I, type PreferenceFilter as J, PreferenceLevel as K, type LinkChannelEndpointArgs as L, type PreferencesResponse as M, Notification as N, Schedule as O, Preference as P, type SocketEventNames as Q, type SocketTypeOption as R, SeverityLevelEnum as S, type TagsFilter as T, type StandardNovuOptions as U, type Subscriber as V, SubscriptionPreference as W, type TagsFilterAndForm as X, type TagsFilterOrGroup as Y, type TimeRange as Z, TopicSubscription as _, type NotificationFilter as a, type UpdateSubscriptionArgs as a0, type UpdateSubscriptionPreferenceArgs as a1, WebSocketEvent as a2, type WeeklySchedule as a3, WorkflowCriticalityEnum as a4, type WorkflowFilter as a5, type WorkflowGroupFilter as a6, type WorkflowIdentifierOrId as a7, type ConnectionMode as a8, InboxService as a9, NovuEventEmitter as aa, type Session as ab, type Result as ac, ScheduleCache as ad, type UpdateScheduleArgs as ae, PreferencesCache as af, type ListPreferencesArgs as ag, type BasePreferenceArgs as ah, type InstancePreferenceArgs as ai, type ListNotificationsArgs as aj, type FilterCountArgs as ak, type FilterCountResponse as al, type FiltersCountArgs as am, type BaseArgs as an, type InstanceArgs as ao, type SnoozeArgs as ap, type GenerateConnectOAuthUrlArgs as aq, type GenerateLinkUserOAuthUrlArgs as ar, SubscriptionsCache as as, type Options as at, type EventNames as au, type ContextValue as av, type BaseUpdateSubscriptionArgs as b, type ChannelEndpointResponse as c, type ChannelPreference as d, ChannelType as e, type Context as f, type CreateChannelConnectionArgs as g, type CreateChannelEndpointArgs as h, type CreateSubscriptionArgs as i, type DefaultSchedule as j, type DeleteChannelConnectionArgs as k, type DeleteChannelEndpointArgs as l, type DeleteSubscriptionArgs as m, type Events as n, type GetChannelConnectionArgs as o, type GetChannelEndpointArgs as p, type GetSubscriptionArgs as q, type InstanceDeleteSubscriptionArgs as r, type InstanceUpdateSubscriptionArgs as s, type LinkChannelEndpointResponse as t, type ListChannelConnectionsArgs as u, type ListChannelEndpointsArgs as v, type ListNotificationsResponse as w, type ListSubscriptionsArgs as x, NotificationStatus as y, NovuError as z };
|
package/dist/esm/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from 'json-logic-js';
|
|
2
|
-
import { S as SeverityLevelEnum, T as TagsFilter, N as Notification, a as NotificationFilter } from './inbox-service-
|
|
3
|
-
export { B as BaseDeleteSubscriptionArgs, b as BaseUpdateSubscriptionArgs, C as ChannelConnectionResponse, c as ChannelEndpointResponse, d as ChannelPreference, e as ChannelType, f as Context, g as CreateChannelConnectionArgs, h as CreateChannelEndpointArgs, i as CreateSubscriptionArgs, D as DaySchedule, j as DefaultSchedule, k as DeleteChannelConnectionArgs, l as DeleteChannelEndpointArgs, m as DeleteSubscriptionArgs, E as EventHandler, n as Events, F as FiltersCountResponse, G as GenerateChatOAuthUrlArgs, o as GetChannelConnectionArgs, p as GetChannelEndpointArgs, q as GetSubscriptionArgs, I as InboxNotification, r as InstanceDeleteSubscriptionArgs, s as InstanceUpdateSubscriptionArgs, L as
|
|
4
|
-
export { N as Novu } from './novu-
|
|
2
|
+
import { S as SeverityLevelEnum, T as TagsFilter, N as Notification, a as NotificationFilter } from './inbox-service-DSSwFYNG.mjs';
|
|
3
|
+
export { B as BaseDeleteSubscriptionArgs, b as BaseUpdateSubscriptionArgs, C as ChannelConnectionResponse, c as ChannelEndpointResponse, d as ChannelPreference, e as ChannelType, f as Context, g as CreateChannelConnectionArgs, h as CreateChannelEndpointArgs, i as CreateSubscriptionArgs, D as DaySchedule, j as DefaultSchedule, k as DeleteChannelConnectionArgs, l as DeleteChannelEndpointArgs, m as DeleteSubscriptionArgs, E as EventHandler, n as Events, F as FiltersCountResponse, G as GenerateChatOAuthUrlArgs, o as GetChannelConnectionArgs, p as GetChannelEndpointArgs, q as GetSubscriptionArgs, I as InboxNotification, r as InstanceDeleteSubscriptionArgs, s as InstanceUpdateSubscriptionArgs, L as LinkChannelEndpointArgs, t as LinkChannelEndpointResponse, u as ListChannelConnectionsArgs, v as ListChannelEndpointsArgs, w as ListNotificationsResponse, x as ListSubscriptionsArgs, y as NotificationStatus, z as NovuError, A as NovuOptions, H as NovuSocketOptions, P as Preference, J as PreferenceFilter, K as PreferenceLevel, M as PreferencesResponse, O as Schedule, Q as SocketEventNames, R as SocketTypeOption, U as StandardNovuOptions, V as Subscriber, W as SubscriptionPreference, X as TagsFilterAndForm, Y as TagsFilterOrGroup, Z as TimeRange, _ as TopicSubscription, $ as UnreadCount, a0 as UpdateSubscriptionArgs, a1 as UpdateSubscriptionPreferenceArgs, a2 as WebSocketEvent, a3 as WeeklySchedule, a4 as WorkflowCriticalityEnum, a5 as WorkflowFilter, a6 as WorkflowGroupFilter, a7 as WorkflowIdentifierOrId } from './inbox-service-DSSwFYNG.mjs';
|
|
4
|
+
export { N as Novu } from './novu-Z0z0-IxO.mjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Normalizes inbox tag filters to CNF: `string[][]` where each inner array is one OR-group.
|
|
@@ -31,4 +31,93 @@ declare function checkNotificationDataFilter(notificationData: Notification['dat
|
|
|
31
31
|
*/
|
|
32
32
|
declare function checkNotificationMatchesFilter(notification: Notification, filter: NotificationFilter): boolean;
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
declare const NOTIFICATION_COUNT_SYNC_EVENTS: readonly ["notification.read.resolved", "notification.unread.resolved", "notification.seen.resolved", "notification.archive.resolved", "notification.unarchive.resolved", "notification.snooze.resolved", "notification.unsnooze.resolved", "notification.delete.resolved", "notifications.read_all.resolved", "notifications.seen_all.resolved", "notifications.archive_all.resolved", "notifications.archive_all_read.resolved", "notifications.delete_all.resolved"];
|
|
35
|
+
|
|
36
|
+
type TelegramSubscriberLinkStatus = 'loading' | 'pending' | 'connected' | 'expired';
|
|
37
|
+
type TelegramSubscriberLinkResponse = {
|
|
38
|
+
deepLinkUrl: string;
|
|
39
|
+
botUsername: string;
|
|
40
|
+
expiresAt: string;
|
|
41
|
+
};
|
|
42
|
+
type TelegramSubscriberLinkOptions = {
|
|
43
|
+
/**
|
|
44
|
+
* Base URL of the Novu API (or your backend proxy).
|
|
45
|
+
* Defaults to `https://api.novu.co`.
|
|
46
|
+
*/
|
|
47
|
+
apiUrl?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Novu server-side secret key (`Authorization: ApiKey <key>`).
|
|
50
|
+
* Required when calling the Novu API directly.
|
|
51
|
+
* Omit when routing through a backend proxy that injects its own auth.
|
|
52
|
+
*/
|
|
53
|
+
secretKey?: string;
|
|
54
|
+
/** Integration identifier (the `identifier` field on the Telegram integration, not `_id`). */
|
|
55
|
+
integrationIdentifier: string;
|
|
56
|
+
/** External subscriber ID to link to the Telegram chat. */
|
|
57
|
+
subscriberId: string;
|
|
58
|
+
/**
|
|
59
|
+
* Polling interval in milliseconds to check for connection confirmation.
|
|
60
|
+
* Defaults to `2000` (2 seconds).
|
|
61
|
+
*/
|
|
62
|
+
pollIntervalMs?: number;
|
|
63
|
+
/**
|
|
64
|
+
* Custom fetch function. Defaults to the global `fetch`.
|
|
65
|
+
* Useful for injecting auth headers in a backend-proxy scenario.
|
|
66
|
+
*/
|
|
67
|
+
fetchFn?: typeof fetch;
|
|
68
|
+
};
|
|
69
|
+
type TelegramSubscriberLinkState = {
|
|
70
|
+
status: TelegramSubscriberLinkStatus;
|
|
71
|
+
deepLinkUrl: string | null;
|
|
72
|
+
botUsername: string | null;
|
|
73
|
+
expiresAt: string | null;
|
|
74
|
+
error: Error | null;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
type StateListener = (state: TelegramSubscriberLinkState) => void;
|
|
78
|
+
/**
|
|
79
|
+
* Framework-agnostic helper that manages the full Telegram subscriber-link
|
|
80
|
+
* lifecycle: issue a deep link, poll for the subscriber's `/start` tap, and
|
|
81
|
+
* re-issue automatically when the 10-minute code expires.
|
|
82
|
+
*
|
|
83
|
+
* **Important:** The subscriber-link endpoint requires `INTEGRATION_WRITE`
|
|
84
|
+
* permission and must be called from a trusted server or via a backend proxy —
|
|
85
|
+
* never directly from an untrusted browser with end-user credentials.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* import { TelegramSubscriberLink } from '@novu/js';
|
|
90
|
+
*
|
|
91
|
+
* const link = new TelegramSubscriberLink({
|
|
92
|
+
* secretKey: process.env.NOVU_SECRET_KEY,
|
|
93
|
+
* integrationIdentifier: '<telegram-integration-identifier>',
|
|
94
|
+
* subscriberId: 'user-42',
|
|
95
|
+
* });
|
|
96
|
+
*
|
|
97
|
+
* link.onStateChange((state) => {
|
|
98
|
+
* console.log(state.status, state.deepLinkUrl);
|
|
99
|
+
* });
|
|
100
|
+
*
|
|
101
|
+
* await link.start();
|
|
102
|
+
* // … later …
|
|
103
|
+
* link.stop();
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
declare class TelegramSubscriberLink {
|
|
107
|
+
#private;
|
|
108
|
+
constructor(options: TelegramSubscriberLinkOptions);
|
|
109
|
+
get state(): Readonly<TelegramSubscriberLinkState>;
|
|
110
|
+
onStateChange(listener: StateListener): () => void;
|
|
111
|
+
/**
|
|
112
|
+
* Check whether the subscriber is already connected; if not, issue a deep
|
|
113
|
+
* link and begin polling for connection. Call {@link stop} to cancel polling
|
|
114
|
+
* and timers.
|
|
115
|
+
*/
|
|
116
|
+
start(): Promise<void>;
|
|
117
|
+
/** Re-issue a fresh deep link (e.g. after expiry or on-demand refresh). */
|
|
118
|
+
refresh(): Promise<void>;
|
|
119
|
+
/** Stop all polling and expiry timers. */
|
|
120
|
+
stop(): void;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export { NOTIFICATION_COUNT_SYNC_EVENTS, Notification, NotificationFilter, SeverityLevelEnum, TagsFilter, TelegramSubscriberLink, type TelegramSubscriberLinkOptions, type TelegramSubscriberLinkResponse, type TelegramSubscriberLinkState, type TelegramSubscriberLinkStatus, areSeveritiesEqual, areTagsEqual, checkNotificationDataFilter, checkNotificationMatchesFilter, isSameFilter, normalizeTagGroups };
|