@novu/js 2.4.0 → 2.6.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-XKQCRZD6.js → chunk-R7DABK4G.js} +133 -69
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.js +14 -14
- package/dist/{esm/novu-gS68EfJw.d.mts → cjs/novu-C3OVXS9Q.d.ts} +44 -34
- package/dist/cjs/themes/index.d.ts +2 -2
- package/dist/cjs/{types-XfKT8UJd.d.ts → types-Bg3djGZK.d.ts} +1 -1
- package/dist/cjs/ui/index.d.ts +4 -4
- package/dist/cjs/ui/index.js +19 -16
- package/dist/esm/{chunk-VCUP7D3X.mjs → chunk-BGMSCE2S.mjs} +133 -69
- package/dist/esm/index.d.mts +2 -2
- package/dist/esm/index.mjs +1 -1
- package/dist/{cjs/novu-gS68EfJw.d.ts → esm/novu-C3OVXS9Q.d.mts} +44 -34
- package/dist/esm/themes/index.d.mts +2 -2
- package/dist/esm/{types-MmHw9UXx.d.mts → types-Cuys78dx.d.mts} +1 -1
- package/dist/esm/ui/index.d.mts +4 -4
- package/dist/esm/ui/index.mjs +16 -13
- package/dist/index.css +1 -1
- package/dist/novu.min.js +10 -10
- package/dist/novu.min.js.gz +0 -0
- package/package.json +13 -13
|
@@ -96,6 +96,9 @@ var NovuEventEmitter = class {
|
|
|
96
96
|
}
|
|
97
97
|
on(eventName, listener) {
|
|
98
98
|
chunk7B52C2XE_js.__privateGet(this, _mittEmitter).on(eventName, listener);
|
|
99
|
+
return () => {
|
|
100
|
+
this.off(eventName, listener);
|
|
101
|
+
};
|
|
99
102
|
}
|
|
100
103
|
off(eventName, listener) {
|
|
101
104
|
chunk7B52C2XE_js.__privateGet(this, _mittEmitter).off(eventName, listener);
|
|
@@ -279,8 +282,15 @@ var Notification = class {
|
|
|
279
282
|
});
|
|
280
283
|
}
|
|
281
284
|
on(eventName, listener) {
|
|
282
|
-
chunk7B52C2XE_js.__privateGet(this, _emitter).on(eventName, listener);
|
|
285
|
+
const cleanup = chunk7B52C2XE_js.__privateGet(this, _emitter).on(eventName, listener);
|
|
286
|
+
return () => {
|
|
287
|
+
cleanup();
|
|
288
|
+
};
|
|
283
289
|
}
|
|
290
|
+
/**
|
|
291
|
+
* @deprecated
|
|
292
|
+
* Use the cleanup function returned by the "on" method instead.
|
|
293
|
+
*/
|
|
284
294
|
off(eventName, listener) {
|
|
285
295
|
chunk7B52C2XE_js.__privateGet(this, _emitter).off(eventName, listener);
|
|
286
296
|
}
|
|
@@ -813,7 +823,8 @@ var Notifications = class extends BaseModule {
|
|
|
813
823
|
return this.callWithSession(() => chunk7B52C2XE_js.__async(this, null, function* () {
|
|
814
824
|
const args = chunk7B52C2XE_js.__spreadValues({ limit }, restOptions);
|
|
815
825
|
try {
|
|
816
|
-
|
|
826
|
+
const shouldUseCache = "useCache" in args ? args.useCache : chunk7B52C2XE_js.__privateGet(this, _useCache);
|
|
827
|
+
let data = shouldUseCache ? this.cache.getAll(args) : void 0;
|
|
817
828
|
this._emitter.emit("notifications.list.pending", { args, data });
|
|
818
829
|
if (!data) {
|
|
819
830
|
const response = yield this._inboxService.fetchNotifications(chunk7B52C2XE_js.__spreadValues({
|
|
@@ -824,7 +835,7 @@ var Notifications = class extends BaseModule {
|
|
|
824
835
|
filter: response.filter,
|
|
825
836
|
notifications: response.data.map((el) => new Notification(el, this._emitter, this._inboxService))
|
|
826
837
|
};
|
|
827
|
-
if (
|
|
838
|
+
if (shouldUseCache) {
|
|
828
839
|
this.cache.set(args, data);
|
|
829
840
|
data = this.cache.getAll(args);
|
|
830
841
|
}
|
|
@@ -1051,44 +1062,12 @@ _emitter3 = new WeakMap();
|
|
|
1051
1062
|
_inboxService2 = new WeakMap();
|
|
1052
1063
|
_options = new WeakMap();
|
|
1053
1064
|
|
|
1054
|
-
// src/preferences/preference.ts
|
|
1055
|
-
var _emitter4, _apiService;
|
|
1056
|
-
var Preference = class {
|
|
1057
|
-
constructor(preference, { emitterInstance, inboxServiceInstance }) {
|
|
1058
|
-
chunk7B52C2XE_js.__privateAdd(this, _emitter4);
|
|
1059
|
-
chunk7B52C2XE_js.__privateAdd(this, _apiService);
|
|
1060
|
-
chunk7B52C2XE_js.__privateSet(this, _emitter4, emitterInstance);
|
|
1061
|
-
chunk7B52C2XE_js.__privateSet(this, _apiService, inboxServiceInstance);
|
|
1062
|
-
this.level = preference.level;
|
|
1063
|
-
this.enabled = preference.enabled;
|
|
1064
|
-
this.channels = preference.channels;
|
|
1065
|
-
this.workflow = preference.workflow;
|
|
1066
|
-
}
|
|
1067
|
-
update({ channelPreferences }) {
|
|
1068
|
-
var _a;
|
|
1069
|
-
return updatePreference({
|
|
1070
|
-
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter4),
|
|
1071
|
-
apiService: chunk7B52C2XE_js.__privateGet(this, _apiService),
|
|
1072
|
-
args: {
|
|
1073
|
-
workflowId: (_a = this.workflow) == null ? void 0 : _a.id,
|
|
1074
|
-
channelPreferences,
|
|
1075
|
-
preference: {
|
|
1076
|
-
level: this.level,
|
|
1077
|
-
enabled: this.enabled,
|
|
1078
|
-
channels: this.channels,
|
|
1079
|
-
workflow: this.workflow
|
|
1080
|
-
}
|
|
1081
|
-
}
|
|
1082
|
-
});
|
|
1083
|
-
}
|
|
1084
|
-
};
|
|
1085
|
-
_emitter4 = new WeakMap();
|
|
1086
|
-
_apiService = new WeakMap();
|
|
1087
|
-
|
|
1088
1065
|
// src/preferences/helpers.ts
|
|
1089
1066
|
var updatePreference = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
|
|
1090
1067
|
emitter,
|
|
1091
1068
|
apiService,
|
|
1069
|
+
cache,
|
|
1070
|
+
useCache,
|
|
1092
1071
|
args
|
|
1093
1072
|
}) {
|
|
1094
1073
|
const { workflowId, channelPreferences } = args;
|
|
@@ -1101,7 +1080,9 @@ var updatePreference = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function*
|
|
|
1101
1080
|
}),
|
|
1102
1081
|
{
|
|
1103
1082
|
emitterInstance: emitter,
|
|
1104
|
-
inboxServiceInstance: apiService
|
|
1083
|
+
inboxServiceInstance: apiService,
|
|
1084
|
+
cache,
|
|
1085
|
+
useCache
|
|
1105
1086
|
}
|
|
1106
1087
|
) : void 0
|
|
1107
1088
|
});
|
|
@@ -1109,11 +1090,14 @@ var updatePreference = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function*
|
|
|
1109
1090
|
if (workflowId) {
|
|
1110
1091
|
response = yield apiService.updateWorkflowPreferences({ workflowId, channelPreferences });
|
|
1111
1092
|
} else {
|
|
1093
|
+
optimisticUpdateWorkflowPreferences({ emitter, apiService, cache, useCache, args });
|
|
1112
1094
|
response = yield apiService.updateGlobalPreferences(channelPreferences);
|
|
1113
1095
|
}
|
|
1114
1096
|
const preference = new Preference(response, {
|
|
1115
1097
|
emitterInstance: emitter,
|
|
1116
|
-
inboxServiceInstance: apiService
|
|
1098
|
+
inboxServiceInstance: apiService,
|
|
1099
|
+
cache,
|
|
1100
|
+
useCache
|
|
1117
1101
|
});
|
|
1118
1102
|
emitter.emit("preference.update.resolved", { args, data: preference });
|
|
1119
1103
|
return { data: preference };
|
|
@@ -1122,6 +1106,90 @@ var updatePreference = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function*
|
|
|
1122
1106
|
return { error: new NovuError("Failed to fetch notifications", error) };
|
|
1123
1107
|
}
|
|
1124
1108
|
});
|
|
1109
|
+
var optimisticUpdateWorkflowPreferences = ({
|
|
1110
|
+
emitter,
|
|
1111
|
+
apiService,
|
|
1112
|
+
cache,
|
|
1113
|
+
useCache,
|
|
1114
|
+
args
|
|
1115
|
+
}) => {
|
|
1116
|
+
const allPreferences = useCache ? cache == null ? void 0 : cache.getAll({}) : void 0;
|
|
1117
|
+
allPreferences == null ? void 0 : allPreferences.forEach((el) => {
|
|
1118
|
+
var _a;
|
|
1119
|
+
if (el.level === "template" /* TEMPLATE */) {
|
|
1120
|
+
const mergedPreference = chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, el), {
|
|
1121
|
+
channels: Object.entries(el.channels).reduce((acc, [key, value]) => {
|
|
1122
|
+
var _a2;
|
|
1123
|
+
const channelType = key;
|
|
1124
|
+
acc[channelType] = (_a2 = args.channelPreferences[channelType]) != null ? _a2 : value;
|
|
1125
|
+
return acc;
|
|
1126
|
+
}, {})
|
|
1127
|
+
});
|
|
1128
|
+
const updatedPreference = args.preference ? new Preference(mergedPreference, {
|
|
1129
|
+
emitterInstance: emitter,
|
|
1130
|
+
inboxServiceInstance: apiService,
|
|
1131
|
+
cache,
|
|
1132
|
+
useCache
|
|
1133
|
+
}) : void 0;
|
|
1134
|
+
if (updatedPreference) {
|
|
1135
|
+
emitter.emit("preference.update.pending", {
|
|
1136
|
+
args: {
|
|
1137
|
+
workflowId: (_a = el.workflow) == null ? void 0 : _a.id,
|
|
1138
|
+
channelPreferences: updatedPreference.channels
|
|
1139
|
+
},
|
|
1140
|
+
data: updatedPreference
|
|
1141
|
+
});
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
});
|
|
1145
|
+
};
|
|
1146
|
+
|
|
1147
|
+
// src/preferences/preference.ts
|
|
1148
|
+
var _emitter4, _apiService, _cache3, _useCache2;
|
|
1149
|
+
var Preference = class {
|
|
1150
|
+
constructor(preference, {
|
|
1151
|
+
emitterInstance,
|
|
1152
|
+
inboxServiceInstance,
|
|
1153
|
+
cache,
|
|
1154
|
+
useCache
|
|
1155
|
+
}) {
|
|
1156
|
+
chunk7B52C2XE_js.__privateAdd(this, _emitter4);
|
|
1157
|
+
chunk7B52C2XE_js.__privateAdd(this, _apiService);
|
|
1158
|
+
chunk7B52C2XE_js.__privateAdd(this, _cache3);
|
|
1159
|
+
chunk7B52C2XE_js.__privateAdd(this, _useCache2);
|
|
1160
|
+
chunk7B52C2XE_js.__privateSet(this, _emitter4, emitterInstance);
|
|
1161
|
+
chunk7B52C2XE_js.__privateSet(this, _apiService, inboxServiceInstance);
|
|
1162
|
+
chunk7B52C2XE_js.__privateSet(this, _cache3, cache);
|
|
1163
|
+
chunk7B52C2XE_js.__privateSet(this, _useCache2, useCache);
|
|
1164
|
+
this.level = preference.level;
|
|
1165
|
+
this.enabled = preference.enabled;
|
|
1166
|
+
this.channels = preference.channels;
|
|
1167
|
+
this.workflow = preference.workflow;
|
|
1168
|
+
}
|
|
1169
|
+
update({ channelPreferences }) {
|
|
1170
|
+
var _a;
|
|
1171
|
+
return updatePreference({
|
|
1172
|
+
emitter: chunk7B52C2XE_js.__privateGet(this, _emitter4),
|
|
1173
|
+
apiService: chunk7B52C2XE_js.__privateGet(this, _apiService),
|
|
1174
|
+
cache: chunk7B52C2XE_js.__privateGet(this, _cache3),
|
|
1175
|
+
useCache: chunk7B52C2XE_js.__privateGet(this, _useCache2),
|
|
1176
|
+
args: {
|
|
1177
|
+
workflowId: (_a = this.workflow) == null ? void 0 : _a.id,
|
|
1178
|
+
channelPreferences,
|
|
1179
|
+
preference: {
|
|
1180
|
+
level: this.level,
|
|
1181
|
+
enabled: this.enabled,
|
|
1182
|
+
channels: this.channels,
|
|
1183
|
+
workflow: this.workflow
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
});
|
|
1187
|
+
}
|
|
1188
|
+
};
|
|
1189
|
+
_emitter4 = new WeakMap();
|
|
1190
|
+
_apiService = new WeakMap();
|
|
1191
|
+
_cache3 = new WeakMap();
|
|
1192
|
+
_useCache2 = new WeakMap();
|
|
1125
1193
|
|
|
1126
1194
|
// src/cache/preferences-cache.ts
|
|
1127
1195
|
var updateEvents2 = ["preference.update.pending", "preference.update.resolved"];
|
|
@@ -1135,13 +1203,13 @@ var excludeEmpty2 = ({ tags }) => Object.entries({ tags }).reduce((acc, [key, va
|
|
|
1135
1203
|
var getCacheKey2 = ({ tags }) => {
|
|
1136
1204
|
return JSON.stringify(excludeEmpty2({ tags }));
|
|
1137
1205
|
};
|
|
1138
|
-
var _emitter5,
|
|
1206
|
+
var _emitter5, _cache4;
|
|
1139
1207
|
var PreferencesCache = class {
|
|
1140
1208
|
constructor({ emitterInstance }) {
|
|
1141
1209
|
chunk7B52C2XE_js.__privateAdd(this, _emitter5);
|
|
1142
|
-
chunk7B52C2XE_js.__privateAdd(this,
|
|
1210
|
+
chunk7B52C2XE_js.__privateAdd(this, _cache4);
|
|
1143
1211
|
this.updatePreference = (key, data) => {
|
|
1144
|
-
const preferences = chunk7B52C2XE_js.__privateGet(this,
|
|
1212
|
+
const preferences = chunk7B52C2XE_js.__privateGet(this, _cache4).get(key);
|
|
1145
1213
|
if (!preferences) {
|
|
1146
1214
|
return false;
|
|
1147
1215
|
}
|
|
@@ -1156,16 +1224,16 @@ var PreferencesCache = class {
|
|
|
1156
1224
|
}
|
|
1157
1225
|
const updatedPreferences = [...preferences];
|
|
1158
1226
|
updatedPreferences[index] = data;
|
|
1159
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
1227
|
+
chunk7B52C2XE_js.__privateGet(this, _cache4).set(key, updatedPreferences);
|
|
1160
1228
|
return true;
|
|
1161
1229
|
};
|
|
1162
1230
|
this.handlePreferenceEvent = ({ data }) => {
|
|
1163
1231
|
if (!data) {
|
|
1164
1232
|
return;
|
|
1165
1233
|
}
|
|
1166
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
1234
|
+
chunk7B52C2XE_js.__privateGet(this, _cache4).keys().forEach((key) => {
|
|
1167
1235
|
const hasUpdatedPreference = this.updatePreference(key, data);
|
|
1168
|
-
const updatedPreference = chunk7B52C2XE_js.__privateGet(this,
|
|
1236
|
+
const updatedPreference = chunk7B52C2XE_js.__privateGet(this, _cache4).get(key);
|
|
1169
1237
|
if (!hasUpdatedPreference || !updatedPreference) {
|
|
1170
1238
|
return;
|
|
1171
1239
|
}
|
|
@@ -1178,28 +1246,28 @@ var PreferencesCache = class {
|
|
|
1178
1246
|
updateEvents2.forEach((event) => {
|
|
1179
1247
|
chunk7B52C2XE_js.__privateGet(this, _emitter5).on(event, this.handlePreferenceEvent);
|
|
1180
1248
|
});
|
|
1181
|
-
chunk7B52C2XE_js.__privateSet(this,
|
|
1249
|
+
chunk7B52C2XE_js.__privateSet(this, _cache4, new InMemoryCache());
|
|
1182
1250
|
}
|
|
1183
1251
|
has(args) {
|
|
1184
|
-
return chunk7B52C2XE_js.__privateGet(this,
|
|
1252
|
+
return chunk7B52C2XE_js.__privateGet(this, _cache4).get(getCacheKey2(args)) !== void 0;
|
|
1185
1253
|
}
|
|
1186
1254
|
set(args, data) {
|
|
1187
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
1255
|
+
chunk7B52C2XE_js.__privateGet(this, _cache4).set(getCacheKey2(args), data);
|
|
1188
1256
|
}
|
|
1189
1257
|
getAll(args) {
|
|
1190
1258
|
if (this.has(args)) {
|
|
1191
|
-
return chunk7B52C2XE_js.__privateGet(this,
|
|
1259
|
+
return chunk7B52C2XE_js.__privateGet(this, _cache4).get(getCacheKey2(args));
|
|
1192
1260
|
}
|
|
1193
1261
|
}
|
|
1194
1262
|
clearAll() {
|
|
1195
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
1263
|
+
chunk7B52C2XE_js.__privateGet(this, _cache4).clear();
|
|
1196
1264
|
}
|
|
1197
1265
|
};
|
|
1198
1266
|
_emitter5 = new WeakMap();
|
|
1199
|
-
|
|
1267
|
+
_cache4 = new WeakMap();
|
|
1200
1268
|
|
|
1201
1269
|
// src/preferences/preferences.ts
|
|
1202
|
-
var
|
|
1270
|
+
var _useCache3;
|
|
1203
1271
|
var Preferences = class extends BaseModule {
|
|
1204
1272
|
constructor({
|
|
1205
1273
|
useCache,
|
|
@@ -1210,27 +1278,29 @@ var Preferences = class extends BaseModule {
|
|
|
1210
1278
|
eventEmitterInstance,
|
|
1211
1279
|
inboxServiceInstance
|
|
1212
1280
|
});
|
|
1213
|
-
chunk7B52C2XE_js.__privateAdd(this,
|
|
1281
|
+
chunk7B52C2XE_js.__privateAdd(this, _useCache3);
|
|
1214
1282
|
this.cache = new PreferencesCache({
|
|
1215
1283
|
emitterInstance: this._emitter
|
|
1216
1284
|
});
|
|
1217
|
-
chunk7B52C2XE_js.__privateSet(this,
|
|
1285
|
+
chunk7B52C2XE_js.__privateSet(this, _useCache3, useCache);
|
|
1218
1286
|
}
|
|
1219
1287
|
list() {
|
|
1220
1288
|
return chunk7B52C2XE_js.__async(this, arguments, function* (args = {}) {
|
|
1221
1289
|
return this.callWithSession(() => chunk7B52C2XE_js.__async(this, null, function* () {
|
|
1222
1290
|
try {
|
|
1223
|
-
let data = chunk7B52C2XE_js.__privateGet(this,
|
|
1291
|
+
let data = chunk7B52C2XE_js.__privateGet(this, _useCache3) ? this.cache.getAll(args) : void 0;
|
|
1224
1292
|
this._emitter.emit("preferences.list.pending", { args, data });
|
|
1225
1293
|
if (!data) {
|
|
1226
1294
|
const response = yield this._inboxService.fetchPreferences(args.tags);
|
|
1227
1295
|
data = response.map(
|
|
1228
1296
|
(el) => new Preference(el, {
|
|
1229
1297
|
emitterInstance: this._emitter,
|
|
1230
|
-
inboxServiceInstance: this._inboxService
|
|
1298
|
+
inboxServiceInstance: this._inboxService,
|
|
1299
|
+
cache: this.cache,
|
|
1300
|
+
useCache: chunk7B52C2XE_js.__privateGet(this, _useCache3)
|
|
1231
1301
|
})
|
|
1232
1302
|
);
|
|
1233
|
-
if (chunk7B52C2XE_js.__privateGet(this,
|
|
1303
|
+
if (chunk7B52C2XE_js.__privateGet(this, _useCache3)) {
|
|
1234
1304
|
this.cache.set(args, data);
|
|
1235
1305
|
data = this.cache.getAll(args);
|
|
1236
1306
|
}
|
|
@@ -1244,17 +1314,8 @@ var Preferences = class extends BaseModule {
|
|
|
1244
1314
|
}));
|
|
1245
1315
|
});
|
|
1246
1316
|
}
|
|
1247
|
-
update(args) {
|
|
1248
|
-
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
1249
|
-
return this.callWithSession(
|
|
1250
|
-
() => chunk7B52C2XE_js.__async(this, null, function* () {
|
|
1251
|
-
return updatePreference({ emitter: this._emitter, apiService: this._inboxService, args });
|
|
1252
|
-
})
|
|
1253
|
-
);
|
|
1254
|
-
});
|
|
1255
|
-
}
|
|
1256
1317
|
};
|
|
1257
|
-
|
|
1318
|
+
_useCache3 = new WeakMap();
|
|
1258
1319
|
var PRODUCTION_SOCKET_URL = "https://ws.novu.co";
|
|
1259
1320
|
var NOTIFICATION_RECEIVED = "notifications.notification_received";
|
|
1260
1321
|
var UNSEEN_COUNT_CHANGED = "notifications.unseen_count_changed";
|
|
@@ -1532,7 +1593,7 @@ var InboxService = class {
|
|
|
1532
1593
|
_httpClient = new WeakMap();
|
|
1533
1594
|
|
|
1534
1595
|
// src/novu.ts
|
|
1535
|
-
var version = "2.
|
|
1596
|
+
var version = "2.6.0";
|
|
1536
1597
|
var name = "@novu/js";
|
|
1537
1598
|
var userAgent = `${name}@${version}`;
|
|
1538
1599
|
var _emitter7, _session, _socket, _inboxService3;
|
|
@@ -1577,7 +1638,10 @@ var Novu = class {
|
|
|
1577
1638
|
if (chunk7B52C2XE_js.__privateGet(this, _socket).isSocketEvent(eventName)) {
|
|
1578
1639
|
chunk7B52C2XE_js.__privateGet(this, _socket).initialize();
|
|
1579
1640
|
}
|
|
1580
|
-
chunk7B52C2XE_js.__privateGet(this, _emitter7).on(eventName, listener);
|
|
1641
|
+
const cleanup = chunk7B52C2XE_js.__privateGet(this, _emitter7).on(eventName, listener);
|
|
1642
|
+
return () => {
|
|
1643
|
+
cleanup();
|
|
1644
|
+
};
|
|
1581
1645
|
};
|
|
1582
1646
|
this.off = (eventName, listener) => {
|
|
1583
1647
|
chunk7B52C2XE_js.__privateGet(this, _emitter7).off(eventName, listener);
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { N as NotificationFilter } from './novu-
|
|
2
|
-
export { k as Action, A as ActionTypeEnum, m as ChannelPreference, f as ChannelType, C as CtaType, E as EventHandler, a as Events, F as FiltersCountResponse, q as IPreferenceOverride, I as InboxNotification, L as ListNotificationsResponse, i as MessageAction, M as MessageButton, t as Notification, e as NotificationActionStatus, d as NotificationButton, c as NotificationStatus, b as Novu, v as NovuError, s as NovuOptions, n as PaginatedResponse, u as Preference, P as PreferenceLevel, g as PreferenceOverrideSource, p as PreferenceOverrideSourceEnum, o as PreferencesResponse, R as Redirect, r as Result, h as Session, S as SocketEventNames, j as Subscriber, T as TODO, W as WebSocketEvent, l as Workflow } from './novu-
|
|
1
|
+
import { N as NotificationFilter } from './novu-C3OVXS9Q.js';
|
|
2
|
+
export { k as Action, A as ActionTypeEnum, m as ChannelPreference, f as ChannelType, C as CtaType, E as EventHandler, a as Events, F as FiltersCountResponse, q as IPreferenceOverride, I as InboxNotification, L as ListNotificationsResponse, i as MessageAction, M as MessageButton, t as Notification, e as NotificationActionStatus, d as NotificationButton, c as NotificationStatus, b as Novu, v as NovuError, s as NovuOptions, n as PaginatedResponse, u as Preference, P as PreferenceLevel, g as PreferenceOverrideSource, p as PreferenceOverrideSourceEnum, o as PreferencesResponse, R as Redirect, r as Result, h as Session, S as SocketEventNames, j as Subscriber, T as TODO, W as WebSocketEvent, l as Workflow } from './novu-C3OVXS9Q.js';
|
|
3
3
|
import '@novu/client';
|
|
4
4
|
|
|
5
5
|
declare const areTagsEqual: (tags1?: string[], tags2?: string[]) => boolean;
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkR7DABK4G_js = require('./chunk-R7DABK4G.js');
|
|
4
4
|
require('./chunk-7B52C2XE.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, "ActionTypeEnum", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunkR7DABK4G_js.ActionTypeEnum; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "ChannelType", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkR7DABK4G_js.ChannelType; }
|
|
15
15
|
});
|
|
16
16
|
Object.defineProperty(exports, "CtaType", {
|
|
17
17
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunkR7DABK4G_js.CtaType; }
|
|
19
19
|
});
|
|
20
20
|
Object.defineProperty(exports, "NotificationActionStatus", {
|
|
21
21
|
enumerable: true,
|
|
22
|
-
get: function () { return
|
|
22
|
+
get: function () { return chunkR7DABK4G_js.NotificationActionStatus; }
|
|
23
23
|
});
|
|
24
24
|
Object.defineProperty(exports, "NotificationButton", {
|
|
25
25
|
enumerable: true,
|
|
26
|
-
get: function () { return
|
|
26
|
+
get: function () { return chunkR7DABK4G_js.NotificationButton; }
|
|
27
27
|
});
|
|
28
28
|
Object.defineProperty(exports, "NotificationStatus", {
|
|
29
29
|
enumerable: true,
|
|
30
|
-
get: function () { return
|
|
30
|
+
get: function () { return chunkR7DABK4G_js.NotificationStatus; }
|
|
31
31
|
});
|
|
32
32
|
Object.defineProperty(exports, "Novu", {
|
|
33
33
|
enumerable: true,
|
|
34
|
-
get: function () { return
|
|
34
|
+
get: function () { return chunkR7DABK4G_js.Novu; }
|
|
35
35
|
});
|
|
36
36
|
Object.defineProperty(exports, "PreferenceLevel", {
|
|
37
37
|
enumerable: true,
|
|
38
|
-
get: function () { return
|
|
38
|
+
get: function () { return chunkR7DABK4G_js.PreferenceLevel; }
|
|
39
39
|
});
|
|
40
40
|
Object.defineProperty(exports, "PreferenceOverrideSource", {
|
|
41
41
|
enumerable: true,
|
|
42
|
-
get: function () { return
|
|
42
|
+
get: function () { return chunkR7DABK4G_js.PreferenceOverrideSource; }
|
|
43
43
|
});
|
|
44
44
|
Object.defineProperty(exports, "PreferenceOverrideSourceEnum", {
|
|
45
45
|
enumerable: true,
|
|
46
|
-
get: function () { return
|
|
46
|
+
get: function () { return chunkR7DABK4G_js.PreferenceOverrideSourceEnum; }
|
|
47
47
|
});
|
|
48
48
|
Object.defineProperty(exports, "WebSocketEvent", {
|
|
49
49
|
enumerable: true,
|
|
50
|
-
get: function () { return
|
|
50
|
+
get: function () { return chunkR7DABK4G_js.WebSocketEvent; }
|
|
51
51
|
});
|
|
52
52
|
Object.defineProperty(exports, "areTagsEqual", {
|
|
53
53
|
enumerable: true,
|
|
54
|
-
get: function () { return
|
|
54
|
+
get: function () { return chunkR7DABK4G_js.areTagsEqual; }
|
|
55
55
|
});
|
|
56
56
|
Object.defineProperty(exports, "isSameFilter", {
|
|
57
57
|
enumerable: true,
|
|
58
|
-
get: function () { return
|
|
58
|
+
get: function () { return chunkR7DABK4G_js.isSameFilter; }
|
|
59
59
|
});
|
|
@@ -5,6 +5,33 @@ declare class NovuError extends Error {
|
|
|
5
5
|
constructor(message: string, originalError: unknown);
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
type ListPreferencesArgs = {
|
|
9
|
+
tags?: string[];
|
|
10
|
+
};
|
|
11
|
+
type UpdatePreferencesArgs = {
|
|
12
|
+
workflowId?: string;
|
|
13
|
+
channelPreferences: ChannelPreference;
|
|
14
|
+
preference?: {
|
|
15
|
+
level: PreferenceLevel;
|
|
16
|
+
enabled: boolean;
|
|
17
|
+
channels: ChannelPreference;
|
|
18
|
+
workflow?: Workflow;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
declare class PreferencesCache {
|
|
23
|
+
#private;
|
|
24
|
+
constructor({ emitterInstance }: {
|
|
25
|
+
emitterInstance: NovuEventEmitter;
|
|
26
|
+
});
|
|
27
|
+
private updatePreference;
|
|
28
|
+
private handlePreferenceEvent;
|
|
29
|
+
has(args: ListPreferencesArgs): boolean;
|
|
30
|
+
set(args: ListPreferencesArgs, data: Preference[]): void;
|
|
31
|
+
getAll(args: ListPreferencesArgs): Preference[] | undefined;
|
|
32
|
+
clearAll(): void;
|
|
33
|
+
}
|
|
34
|
+
|
|
8
35
|
type PreferenceLike = Pick<Preference, 'level' | 'enabled' | 'channels' | 'workflow'>;
|
|
9
36
|
declare class Preference {
|
|
10
37
|
#private;
|
|
@@ -12,9 +39,11 @@ declare class Preference {
|
|
|
12
39
|
readonly enabled: boolean;
|
|
13
40
|
readonly channels: ChannelPreference;
|
|
14
41
|
readonly workflow?: Workflow;
|
|
15
|
-
constructor(preference: PreferenceLike, { emitterInstance, inboxServiceInstance }: {
|
|
42
|
+
constructor(preference: PreferenceLike, { emitterInstance, inboxServiceInstance, cache, useCache, }: {
|
|
16
43
|
emitterInstance: NovuEventEmitter;
|
|
17
44
|
inboxServiceInstance: InboxService;
|
|
45
|
+
cache: PreferencesCache;
|
|
46
|
+
useCache: boolean;
|
|
18
47
|
});
|
|
19
48
|
update({ channelPreferences }: {
|
|
20
49
|
channelPreferences: ChannelPreference;
|
|
@@ -251,7 +280,7 @@ declare class BaseModule {
|
|
|
251
280
|
callWithSession<T>(fn: () => Result<T>): Result<T>;
|
|
252
281
|
}
|
|
253
282
|
|
|
254
|
-
declare class Notification implements Pick<NovuEventEmitter, 'on'
|
|
283
|
+
declare class Notification implements Pick<NovuEventEmitter, 'on'>, InboxNotification {
|
|
255
284
|
#private;
|
|
256
285
|
readonly id: InboxNotification['id'];
|
|
257
286
|
readonly subject?: InboxNotification['subject'];
|
|
@@ -278,7 +307,11 @@ declare class Notification implements Pick<NovuEventEmitter, 'on' | 'off'>, Inbo
|
|
|
278
307
|
completeSecondary(): Result<Notification>;
|
|
279
308
|
revertPrimary(): Result<Notification>;
|
|
280
309
|
revertSecondary(): Result<Notification>;
|
|
281
|
-
on<Key extends EventNames>(eventName: Key, listener: EventHandler<Events[Key]>): void;
|
|
310
|
+
on<Key extends EventNames>(eventName: Key, listener: EventHandler<Events[Key]>): () => void;
|
|
311
|
+
/**
|
|
312
|
+
* @deprecated
|
|
313
|
+
* Use the cleanup function returned by the "on" method instead.
|
|
314
|
+
*/
|
|
282
315
|
off<Key extends EventNames>(eventName: Key, listener: EventHandler<Events[Key]>): void;
|
|
283
316
|
}
|
|
284
317
|
|
|
@@ -289,6 +322,7 @@ type ListNotificationsArgs = {
|
|
|
289
322
|
limit?: number;
|
|
290
323
|
after?: string;
|
|
291
324
|
offset?: number;
|
|
325
|
+
useCache?: boolean;
|
|
292
326
|
};
|
|
293
327
|
type ListNotificationsResponse = {
|
|
294
328
|
notifications: Notification[];
|
|
@@ -395,20 +429,6 @@ declare class Notifications extends BaseModule {
|
|
|
395
429
|
}): void;
|
|
396
430
|
}
|
|
397
431
|
|
|
398
|
-
type ListPreferencesArgs = {
|
|
399
|
-
tags?: string[];
|
|
400
|
-
};
|
|
401
|
-
type UpdatePreferencesArgs = {
|
|
402
|
-
workflowId?: string;
|
|
403
|
-
channelPreferences: ChannelPreference;
|
|
404
|
-
preference?: {
|
|
405
|
-
level: PreferenceLevel;
|
|
406
|
-
enabled: boolean;
|
|
407
|
-
channels: ChannelPreference;
|
|
408
|
-
workflow?: Workflow;
|
|
409
|
-
};
|
|
410
|
-
};
|
|
411
|
-
|
|
412
432
|
type InitializeSessionArgs = {
|
|
413
433
|
applicationIdentifier: string;
|
|
414
434
|
subscriberId: string;
|
|
@@ -495,24 +515,11 @@ type EventHandler<T = unknown> = (event: T) => void;
|
|
|
495
515
|
declare class NovuEventEmitter {
|
|
496
516
|
#private;
|
|
497
517
|
constructor();
|
|
498
|
-
on<Key extends EventNames>(eventName: Key, listener: EventHandler<Events[Key]>): void;
|
|
518
|
+
on<Key extends EventNames>(eventName: Key, listener: EventHandler<Events[Key]>): () => void;
|
|
499
519
|
off<Key extends EventNames>(eventName: Key, listener: EventHandler<Events[Key]>): void;
|
|
500
520
|
emit<Key extends EventNames>(type: Key, event?: Events[Key]): void;
|
|
501
521
|
}
|
|
502
522
|
|
|
503
|
-
declare class PreferencesCache {
|
|
504
|
-
#private;
|
|
505
|
-
constructor({ emitterInstance }: {
|
|
506
|
-
emitterInstance: NovuEventEmitter;
|
|
507
|
-
});
|
|
508
|
-
private updatePreference;
|
|
509
|
-
private handlePreferenceEvent;
|
|
510
|
-
has(args: ListPreferencesArgs): boolean;
|
|
511
|
-
set(args: ListPreferencesArgs, data: Preference[]): void;
|
|
512
|
-
getAll(args: ListPreferencesArgs): Preference[] | undefined;
|
|
513
|
-
clearAll(): void;
|
|
514
|
-
}
|
|
515
|
-
|
|
516
523
|
declare class Preferences extends BaseModule {
|
|
517
524
|
#private;
|
|
518
525
|
readonly cache: PreferencesCache;
|
|
@@ -522,14 +529,17 @@ declare class Preferences extends BaseModule {
|
|
|
522
529
|
eventEmitterInstance: NovuEventEmitter;
|
|
523
530
|
});
|
|
524
531
|
list(args?: ListPreferencesArgs): Result<Preference[]>;
|
|
525
|
-
update(args: UpdatePreferencesArgs): Result<Preference>;
|
|
526
532
|
}
|
|
527
533
|
|
|
528
|
-
declare class Novu implements Pick<NovuEventEmitter, 'on'
|
|
534
|
+
declare class Novu implements Pick<NovuEventEmitter, 'on'> {
|
|
529
535
|
#private;
|
|
530
536
|
readonly notifications: Notifications;
|
|
531
537
|
readonly preferences: Preferences;
|
|
532
|
-
on: <Key extends EventNames>(eventName: Key, listener: EventHandler<Events[Key]>) => void;
|
|
538
|
+
on: <Key extends EventNames>(eventName: Key, listener: EventHandler<Events[Key]>) => () => void;
|
|
539
|
+
/**
|
|
540
|
+
* @deprecated
|
|
541
|
+
* Use the cleanup function returned by the "on" method instead.
|
|
542
|
+
*/
|
|
533
543
|
off: <Key extends EventNames>(eventName: Key, listener: EventHandler<Events[Key]>) => void;
|
|
534
544
|
constructor(options: NovuOptions);
|
|
535
545
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as Notification, N as NotificationFilter, s as NovuOptions, b as Novu } from './novu-
|
|
1
|
+
import { t as Notification, N as NotificationFilter, s as NovuOptions, b as Novu } from './novu-C3OVXS9Q.js';
|
|
2
2
|
|
|
3
3
|
declare const defaultLocalization: {
|
|
4
4
|
readonly locale: "en-US";
|
package/dist/cjs/ui/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { s as NovuOptions } from '../novu-
|
|
2
|
-
export { t as Notification } from '../novu-
|
|
3
|
-
import { N as NotificationRenderer, B as BellRenderer, a as NotificationClickHandler, b as NotificationActionClickHandler, c as NovuProviderProps, d as BaseNovuProviderProps, A as Appearance, L as Localization, T as Tab, P as PreferencesFilter, R as RouterPush } from '../types-
|
|
4
|
-
export { e as AppearanceKey, C as CSSProperties, E as ElementStyles, f as Elements, i as LocalizationKey, h as NotificationStatus, g as Theme, V as Variables } from '../types-
|
|
1
|
+
import { s as NovuOptions } from '../novu-C3OVXS9Q.js';
|
|
2
|
+
export { t as Notification } from '../novu-C3OVXS9Q.js';
|
|
3
|
+
import { N as NotificationRenderer, B as BellRenderer, a as NotificationClickHandler, b as NotificationActionClickHandler, c as NovuProviderProps, d as BaseNovuProviderProps, A as Appearance, L as Localization, T as Tab, P as PreferencesFilter, R as RouterPush } from '../types-Bg3djGZK.js';
|
|
4
|
+
export { e as AppearanceKey, C as CSSProperties, E as ElementStyles, f as Elements, i as LocalizationKey, h as NotificationStatus, g as Theme, V as Variables } from '../types-Bg3djGZK.js';
|
|
5
5
|
import * as solid_js from 'solid-js';
|
|
6
6
|
import { ComponentProps } from 'solid-js';
|
|
7
7
|
import { MountableElement } from 'solid-js/web';
|