@novu/js 3.5.0 → 3.6.0-nightly.20250627
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-5P6SPWNU.js → chunk-AVYEBJPB.js} +307 -16
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.js +8 -8
- package/dist/{esm/novu-Bocb1dH9.d.mts → cjs/novu-CnZkqUKP.d.ts} +6 -9
- package/dist/cjs/themes/index.d.ts +2 -2
- package/dist/cjs/{types-DeMFGM4g.d.ts → types-BSZsDqkz.d.ts} +1 -1
- package/dist/cjs/ui/index.d.ts +4 -4
- package/dist/cjs/ui/index.js +9 -9
- package/dist/esm/{chunk-MGTTV7JA.mjs → chunk-NOP2CVJO.mjs} +308 -17
- package/dist/esm/index.d.mts +2 -2
- package/dist/esm/index.mjs +1 -1
- package/dist/{cjs/novu-Bocb1dH9.d.ts → esm/novu-CnZkqUKP.d.mts} +6 -9
- package/dist/esm/themes/index.d.mts +2 -2
- package/dist/esm/{types-CObwRGDC.d.mts → types-DKUFj4Oc.d.mts} +1 -1
- package/dist/esm/ui/index.d.mts +4 -4
- package/dist/esm/ui/index.mjs +5 -5
- package/dist/index.css +1 -1
- package/dist/novu.min.js +39 -10
- package/dist/novu.min.js.gz +0 -0
- package/package.json +2 -1
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var chunk7B52C2XE_js = require('./chunk-7B52C2XE.js');
|
|
4
4
|
var mitt = require('mitt');
|
|
5
5
|
var io = require('socket.io-client');
|
|
6
|
+
var partysocket = require('partysocket');
|
|
6
7
|
|
|
7
8
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
9
|
|
|
@@ -74,7 +75,7 @@ var isSameFilter = (filter1, filter2) => {
|
|
|
74
75
|
|
|
75
76
|
// src/api/http-client.ts
|
|
76
77
|
var DEFAULT_API_VERSION = "v1";
|
|
77
|
-
var DEFAULT_USER_AGENT = `${"@novu/js"}@${"3.
|
|
78
|
+
var DEFAULT_USER_AGENT = `${"@novu/js"}@${"3.6.0-nightly.20250627"}`;
|
|
78
79
|
var HttpClient = class {
|
|
79
80
|
constructor(options = {}) {
|
|
80
81
|
// Environment variable for local development that overrides the default API endpoint without affecting the Inbox DX
|
|
@@ -1824,10 +1825,13 @@ var Session = class {
|
|
|
1824
1825
|
return null;
|
|
1825
1826
|
}
|
|
1826
1827
|
}
|
|
1827
|
-
initialize() {
|
|
1828
|
+
initialize(options) {
|
|
1828
1829
|
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
1829
1830
|
var _a, _b;
|
|
1830
1831
|
try {
|
|
1832
|
+
if (options) {
|
|
1833
|
+
chunk7B52C2XE_js.__privateSet(this, _options, options);
|
|
1834
|
+
}
|
|
1831
1835
|
const { subscriber, subscriberHash, applicationIdentifier } = chunk7B52C2XE_js.__privateGet(this, _options);
|
|
1832
1836
|
let finalApplicationIdentifier = applicationIdentifier;
|
|
1833
1837
|
if (!finalApplicationIdentifier) {
|
|
@@ -2056,56 +2060,329 @@ handleDisconnectSocket_fn = function() {
|
|
|
2056
2060
|
}
|
|
2057
2061
|
});
|
|
2058
2062
|
};
|
|
2063
|
+
var PRODUCTION_SOCKET_URL2 = "wss://socket.novu.co";
|
|
2064
|
+
var NOTIFICATION_RECEIVED2 = "notifications.notification_received";
|
|
2065
|
+
var UNSEEN_COUNT_CHANGED2 = "notifications.unseen_count_changed";
|
|
2066
|
+
var UNREAD_COUNT_CHANGED2 = "notifications.unread_count_changed";
|
|
2067
|
+
var mapToNotification2 = ({
|
|
2068
|
+
_id,
|
|
2069
|
+
content,
|
|
2070
|
+
read: read2,
|
|
2071
|
+
archived,
|
|
2072
|
+
snoozedUntil,
|
|
2073
|
+
deliveredAt,
|
|
2074
|
+
createdAt,
|
|
2075
|
+
lastReadDate,
|
|
2076
|
+
archivedAt,
|
|
2077
|
+
channel,
|
|
2078
|
+
subscriber,
|
|
2079
|
+
subject,
|
|
2080
|
+
avatar,
|
|
2081
|
+
cta,
|
|
2082
|
+
tags,
|
|
2083
|
+
data,
|
|
2084
|
+
workflow
|
|
2085
|
+
}) => {
|
|
2086
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2087
|
+
const to = {
|
|
2088
|
+
id: subscriber == null ? void 0 : subscriber._id,
|
|
2089
|
+
subscriberId: subscriber == null ? void 0 : subscriber.subscriberId,
|
|
2090
|
+
firstName: subscriber == null ? void 0 : subscriber.firstName,
|
|
2091
|
+
lastName: subscriber == null ? void 0 : subscriber.lastName,
|
|
2092
|
+
avatar: subscriber == null ? void 0 : subscriber.avatar,
|
|
2093
|
+
locale: subscriber == null ? void 0 : subscriber.locale,
|
|
2094
|
+
data: subscriber == null ? void 0 : subscriber.data,
|
|
2095
|
+
timezone: subscriber == null ? void 0 : subscriber.timezone,
|
|
2096
|
+
email: subscriber == null ? void 0 : subscriber.email,
|
|
2097
|
+
phone: subscriber == null ? void 0 : subscriber.phone
|
|
2098
|
+
};
|
|
2099
|
+
const primaryCta = (_b = (_a = cta.action) == null ? void 0 : _a.buttons) == null ? void 0 : _b.find((button) => button.type === "primary" /* PRIMARY */);
|
|
2100
|
+
const secondaryCta = (_d = (_c = cta.action) == null ? void 0 : _c.buttons) == null ? void 0 : _d.find((button) => button.type === "secondary" /* SECONDARY */);
|
|
2101
|
+
const actionType = (_f = (_e = cta.action) == null ? void 0 : _e.result) == null ? void 0 : _f.type;
|
|
2102
|
+
const actionStatus = (_g = cta.action) == null ? void 0 : _g.status;
|
|
2103
|
+
return chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues(chunk7B52C2XE_js.__spreadValues({
|
|
2104
|
+
id: _id,
|
|
2105
|
+
subject,
|
|
2106
|
+
body: content,
|
|
2107
|
+
to,
|
|
2108
|
+
isRead: read2,
|
|
2109
|
+
isArchived: archived,
|
|
2110
|
+
isSnoozed: !!snoozedUntil
|
|
2111
|
+
}, deliveredAt && {
|
|
2112
|
+
deliveredAt
|
|
2113
|
+
}), snoozedUntil && {
|
|
2114
|
+
snoozedUntil
|
|
2115
|
+
}), {
|
|
2116
|
+
createdAt,
|
|
2117
|
+
readAt: lastReadDate,
|
|
2118
|
+
archivedAt,
|
|
2119
|
+
avatar,
|
|
2120
|
+
primaryAction: primaryCta && {
|
|
2121
|
+
label: primaryCta.content,
|
|
2122
|
+
isCompleted: actionType === "primary" /* PRIMARY */ && actionStatus === "done" /* DONE */,
|
|
2123
|
+
redirect: primaryCta.url ? {
|
|
2124
|
+
target: primaryCta.target,
|
|
2125
|
+
url: primaryCta.url
|
|
2126
|
+
} : void 0
|
|
2127
|
+
},
|
|
2128
|
+
secondaryAction: secondaryCta && {
|
|
2129
|
+
label: secondaryCta.content,
|
|
2130
|
+
isCompleted: actionType === "secondary" /* SECONDARY */ && actionStatus === "done" /* DONE */,
|
|
2131
|
+
redirect: secondaryCta.url ? {
|
|
2132
|
+
target: secondaryCta.target,
|
|
2133
|
+
url: secondaryCta.url
|
|
2134
|
+
} : void 0
|
|
2135
|
+
},
|
|
2136
|
+
channelType: channel,
|
|
2137
|
+
tags,
|
|
2138
|
+
redirect: ((_h = cta.data) == null ? void 0 : _h.url) ? {
|
|
2139
|
+
url: cta.data.url,
|
|
2140
|
+
target: cta.data.target
|
|
2141
|
+
} : void 0,
|
|
2142
|
+
data,
|
|
2143
|
+
workflow
|
|
2144
|
+
});
|
|
2145
|
+
};
|
|
2146
|
+
var _token2, _emitter7, _partySocket, _socketUrl2, _notificationReceived2, _unseenCountChanged2, _unreadCountChanged2, _handleMessage, _PartySocketClient_instances, initializeSocket_fn2, handleConnectSocket_fn2, handleDisconnectSocket_fn2;
|
|
2147
|
+
var PartySocketClient = class extends BaseModule {
|
|
2148
|
+
constructor({
|
|
2149
|
+
socketUrl,
|
|
2150
|
+
inboxServiceInstance,
|
|
2151
|
+
eventEmitterInstance
|
|
2152
|
+
}) {
|
|
2153
|
+
super({
|
|
2154
|
+
eventEmitterInstance,
|
|
2155
|
+
inboxServiceInstance
|
|
2156
|
+
});
|
|
2157
|
+
chunk7B52C2XE_js.__privateAdd(this, _PartySocketClient_instances);
|
|
2158
|
+
chunk7B52C2XE_js.__privateAdd(this, _token2);
|
|
2159
|
+
chunk7B52C2XE_js.__privateAdd(this, _emitter7);
|
|
2160
|
+
chunk7B52C2XE_js.__privateAdd(this, _partySocket);
|
|
2161
|
+
chunk7B52C2XE_js.__privateAdd(this, _socketUrl2);
|
|
2162
|
+
chunk7B52C2XE_js.__privateAdd(this, _notificationReceived2, (event) => {
|
|
2163
|
+
try {
|
|
2164
|
+
const data = JSON.parse(event.data);
|
|
2165
|
+
if (data.event === "notification_received" /* RECEIVED */) {
|
|
2166
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter7).emit(NOTIFICATION_RECEIVED2, {
|
|
2167
|
+
result: new Notification(mapToNotification2(data.data.message), chunk7B52C2XE_js.__privateGet(this, _emitter7), this._inboxService)
|
|
2168
|
+
});
|
|
2169
|
+
}
|
|
2170
|
+
} catch (error) {
|
|
2171
|
+
console.log("error", error);
|
|
2172
|
+
}
|
|
2173
|
+
});
|
|
2174
|
+
chunk7B52C2XE_js.__privateAdd(this, _unseenCountChanged2, (event) => {
|
|
2175
|
+
try {
|
|
2176
|
+
const data = JSON.parse(event.data);
|
|
2177
|
+
if (data.event === "unseen_count_changed" /* UNSEEN */) {
|
|
2178
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter7).emit(UNSEEN_COUNT_CHANGED2, {
|
|
2179
|
+
result: data.data.unseenCount
|
|
2180
|
+
});
|
|
2181
|
+
}
|
|
2182
|
+
} catch (error) {
|
|
2183
|
+
}
|
|
2184
|
+
});
|
|
2185
|
+
chunk7B52C2XE_js.__privateAdd(this, _unreadCountChanged2, (event) => {
|
|
2186
|
+
try {
|
|
2187
|
+
const data = JSON.parse(event.data);
|
|
2188
|
+
if (data.event === "unread_count_changed" /* UNREAD */) {
|
|
2189
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter7).emit(UNREAD_COUNT_CHANGED2, {
|
|
2190
|
+
result: data.data.unreadCount
|
|
2191
|
+
});
|
|
2192
|
+
}
|
|
2193
|
+
} catch (error) {
|
|
2194
|
+
}
|
|
2195
|
+
});
|
|
2196
|
+
chunk7B52C2XE_js.__privateAdd(this, _handleMessage, (event) => {
|
|
2197
|
+
try {
|
|
2198
|
+
const data = JSON.parse(event.data);
|
|
2199
|
+
switch (data.event) {
|
|
2200
|
+
case "notification_received" /* RECEIVED */:
|
|
2201
|
+
chunk7B52C2XE_js.__privateGet(this, _notificationReceived2).call(this, event);
|
|
2202
|
+
break;
|
|
2203
|
+
case "unseen_count_changed" /* UNSEEN */:
|
|
2204
|
+
chunk7B52C2XE_js.__privateGet(this, _unseenCountChanged2).call(this, event);
|
|
2205
|
+
break;
|
|
2206
|
+
case "unread_count_changed" /* UNREAD */:
|
|
2207
|
+
chunk7B52C2XE_js.__privateGet(this, _unreadCountChanged2).call(this, event);
|
|
2208
|
+
break;
|
|
2209
|
+
default:
|
|
2210
|
+
}
|
|
2211
|
+
} catch (error) {
|
|
2212
|
+
}
|
|
2213
|
+
});
|
|
2214
|
+
chunk7B52C2XE_js.__privateSet(this, _emitter7, eventEmitterInstance);
|
|
2215
|
+
chunk7B52C2XE_js.__privateSet(this, _socketUrl2, socketUrl != null ? socketUrl : PRODUCTION_SOCKET_URL2);
|
|
2216
|
+
}
|
|
2217
|
+
onSessionSuccess({ token }) {
|
|
2218
|
+
chunk7B52C2XE_js.__privateSet(this, _token2, token);
|
|
2219
|
+
}
|
|
2220
|
+
isSocketEvent(eventName) {
|
|
2221
|
+
return eventName === NOTIFICATION_RECEIVED2 || eventName === UNSEEN_COUNT_CHANGED2 || eventName === UNREAD_COUNT_CHANGED2;
|
|
2222
|
+
}
|
|
2223
|
+
connect() {
|
|
2224
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
2225
|
+
if (chunk7B52C2XE_js.__privateGet(this, _token2)) {
|
|
2226
|
+
return chunk7B52C2XE_js.__privateMethod(this, _PartySocketClient_instances, handleConnectSocket_fn2).call(this);
|
|
2227
|
+
}
|
|
2228
|
+
return this.callWithSession(chunk7B52C2XE_js.__privateMethod(this, _PartySocketClient_instances, handleConnectSocket_fn2).bind(this));
|
|
2229
|
+
});
|
|
2230
|
+
}
|
|
2231
|
+
disconnect() {
|
|
2232
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
2233
|
+
if (chunk7B52C2XE_js.__privateGet(this, _partySocket)) {
|
|
2234
|
+
return chunk7B52C2XE_js.__privateMethod(this, _PartySocketClient_instances, handleDisconnectSocket_fn2).call(this);
|
|
2235
|
+
}
|
|
2236
|
+
return this.callWithSession(chunk7B52C2XE_js.__privateMethod(this, _PartySocketClient_instances, handleDisconnectSocket_fn2).bind(this));
|
|
2237
|
+
});
|
|
2238
|
+
}
|
|
2239
|
+
};
|
|
2240
|
+
_token2 = new WeakMap();
|
|
2241
|
+
_emitter7 = new WeakMap();
|
|
2242
|
+
_partySocket = new WeakMap();
|
|
2243
|
+
_socketUrl2 = new WeakMap();
|
|
2244
|
+
_notificationReceived2 = new WeakMap();
|
|
2245
|
+
_unseenCountChanged2 = new WeakMap();
|
|
2246
|
+
_unreadCountChanged2 = new WeakMap();
|
|
2247
|
+
_handleMessage = new WeakMap();
|
|
2248
|
+
_PartySocketClient_instances = new WeakSet();
|
|
2249
|
+
initializeSocket_fn2 = function() {
|
|
2250
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
2251
|
+
if (chunk7B52C2XE_js.__privateGet(this, _partySocket)) {
|
|
2252
|
+
return;
|
|
2253
|
+
}
|
|
2254
|
+
const args = { socketUrl: chunk7B52C2XE_js.__privateGet(this, _socketUrl2) };
|
|
2255
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter7).emit("socket.connect.pending", { args });
|
|
2256
|
+
const url = new URL(chunk7B52C2XE_js.__privateGet(this, _socketUrl2));
|
|
2257
|
+
url.searchParams.set("token", chunk7B52C2XE_js.__privateGet(this, _token2));
|
|
2258
|
+
chunk7B52C2XE_js.__privateSet(this, _partySocket, new partysocket.WebSocket(url.toString()));
|
|
2259
|
+
chunk7B52C2XE_js.__privateGet(this, _partySocket).addEventListener("open", () => {
|
|
2260
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter7).emit("socket.connect.resolved", { args });
|
|
2261
|
+
});
|
|
2262
|
+
chunk7B52C2XE_js.__privateGet(this, _partySocket).addEventListener("error", (error) => {
|
|
2263
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter7).emit("socket.connect.resolved", { args, error });
|
|
2264
|
+
});
|
|
2265
|
+
chunk7B52C2XE_js.__privateGet(this, _partySocket).addEventListener("message", chunk7B52C2XE_js.__privateGet(this, _handleMessage));
|
|
2266
|
+
});
|
|
2267
|
+
};
|
|
2268
|
+
handleConnectSocket_fn2 = function() {
|
|
2269
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
2270
|
+
try {
|
|
2271
|
+
yield chunk7B52C2XE_js.__privateMethod(this, _PartySocketClient_instances, initializeSocket_fn2).call(this);
|
|
2272
|
+
return {};
|
|
2273
|
+
} catch (error) {
|
|
2274
|
+
return { error: new NovuError("Failed to initialize the PartySocket", error) };
|
|
2275
|
+
}
|
|
2276
|
+
});
|
|
2277
|
+
};
|
|
2278
|
+
handleDisconnectSocket_fn2 = function() {
|
|
2279
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
2280
|
+
var _a;
|
|
2281
|
+
try {
|
|
2282
|
+
(_a = chunk7B52C2XE_js.__privateGet(this, _partySocket)) == null ? void 0 : _a.close();
|
|
2283
|
+
chunk7B52C2XE_js.__privateSet(this, _partySocket, void 0);
|
|
2284
|
+
return {};
|
|
2285
|
+
} catch (error) {
|
|
2286
|
+
return { error: new NovuError("Failed to disconnect from the PartySocket", error) };
|
|
2287
|
+
}
|
|
2288
|
+
});
|
|
2289
|
+
};
|
|
2290
|
+
|
|
2291
|
+
// src/ws/socket-factory.ts
|
|
2292
|
+
var PARTY_SOCKET_URLS = [
|
|
2293
|
+
"wss://eu.socket.novu.co",
|
|
2294
|
+
PRODUCTION_SOCKET_URL2,
|
|
2295
|
+
"wss://socket.novu-staging.co",
|
|
2296
|
+
"wss://socket-worker-local.cli-shortener.workers.dev"
|
|
2297
|
+
];
|
|
2298
|
+
var URL_TRANSFORMATIONS = {
|
|
2299
|
+
"https://eu.ws.novu.co": "wss://eu.socket.novu.co",
|
|
2300
|
+
"https://ws.novu.co": PRODUCTION_SOCKET_URL2,
|
|
2301
|
+
"https://dev.ws.novu.co": "wss://socket.novu-staging.co"
|
|
2302
|
+
};
|
|
2303
|
+
function transformSocketUrl(socketUrl) {
|
|
2304
|
+
if (!socketUrl) return PRODUCTION_SOCKET_URL2;
|
|
2305
|
+
return URL_TRANSFORMATIONS[socketUrl] || socketUrl;
|
|
2306
|
+
}
|
|
2307
|
+
function shouldUsePartySocket(socketUrl) {
|
|
2308
|
+
return !socketUrl || PARTY_SOCKET_URLS.includes(socketUrl);
|
|
2309
|
+
}
|
|
2310
|
+
function createSocket({
|
|
2311
|
+
socketUrl,
|
|
2312
|
+
inboxServiceInstance,
|
|
2313
|
+
eventEmitterInstance
|
|
2314
|
+
}) {
|
|
2315
|
+
const transformedSocketUrl = transformSocketUrl(socketUrl);
|
|
2316
|
+
const socketType = shouldUsePartySocket(transformedSocketUrl) ? "partysocket" /* PARTY_SOCKET */ : "socket.io" /* SOCKET_IO */;
|
|
2317
|
+
switch (socketType) {
|
|
2318
|
+
case "partysocket" /* PARTY_SOCKET */:
|
|
2319
|
+
return new PartySocketClient({
|
|
2320
|
+
socketUrl: transformedSocketUrl,
|
|
2321
|
+
inboxServiceInstance,
|
|
2322
|
+
eventEmitterInstance
|
|
2323
|
+
});
|
|
2324
|
+
case "socket.io" /* SOCKET_IO */:
|
|
2325
|
+
default:
|
|
2326
|
+
return new Socket({
|
|
2327
|
+
socketUrl: transformedSocketUrl,
|
|
2328
|
+
inboxServiceInstance,
|
|
2329
|
+
eventEmitterInstance
|
|
2330
|
+
});
|
|
2331
|
+
}
|
|
2332
|
+
}
|
|
2059
2333
|
|
|
2060
2334
|
// src/novu.ts
|
|
2061
|
-
var
|
|
2335
|
+
var _emitter8, _session, _inboxService3, _currentSubscriberId;
|
|
2062
2336
|
var Novu = class {
|
|
2063
2337
|
constructor(options) {
|
|
2064
|
-
chunk7B52C2XE_js.__privateAdd(this,
|
|
2338
|
+
chunk7B52C2XE_js.__privateAdd(this, _emitter8);
|
|
2065
2339
|
chunk7B52C2XE_js.__privateAdd(this, _session);
|
|
2066
2340
|
chunk7B52C2XE_js.__privateAdd(this, _inboxService3);
|
|
2341
|
+
chunk7B52C2XE_js.__privateAdd(this, _currentSubscriberId);
|
|
2067
2342
|
var _a, _b;
|
|
2068
2343
|
chunk7B52C2XE_js.__privateSet(this, _inboxService3, new InboxService({
|
|
2069
2344
|
apiUrl: options.apiUrl || options.backendUrl,
|
|
2070
2345
|
userAgent: options.__userAgent
|
|
2071
2346
|
}));
|
|
2072
|
-
chunk7B52C2XE_js.__privateSet(this,
|
|
2347
|
+
chunk7B52C2XE_js.__privateSet(this, _emitter8, new NovuEventEmitter());
|
|
2073
2348
|
chunk7B52C2XE_js.__privateSet(this, _session, new Session(
|
|
2074
|
-
|
|
2075
|
-
applicationIdentifier: options.applicationIdentifier,
|
|
2349
|
+
{
|
|
2350
|
+
applicationIdentifier: options.applicationIdentifier || "",
|
|
2076
2351
|
subscriberHash: options.subscriberHash,
|
|
2077
2352
|
subscriber: buildSubscriber(options)
|
|
2078
|
-
}
|
|
2353
|
+
},
|
|
2079
2354
|
chunk7B52C2XE_js.__privateGet(this, _inboxService3),
|
|
2080
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
2355
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter8)
|
|
2081
2356
|
));
|
|
2357
|
+
const initialSubscriber = buildSubscriber(options);
|
|
2358
|
+
chunk7B52C2XE_js.__privateSet(this, _currentSubscriberId, initialSubscriber.subscriberId);
|
|
2082
2359
|
chunk7B52C2XE_js.__privateGet(this, _session).initialize();
|
|
2083
2360
|
this.notifications = new Notifications({
|
|
2084
2361
|
useCache: (_a = options.useCache) != null ? _a : true,
|
|
2085
2362
|
inboxServiceInstance: chunk7B52C2XE_js.__privateGet(this, _inboxService3),
|
|
2086
|
-
eventEmitterInstance: chunk7B52C2XE_js.__privateGet(this,
|
|
2363
|
+
eventEmitterInstance: chunk7B52C2XE_js.__privateGet(this, _emitter8)
|
|
2087
2364
|
});
|
|
2088
2365
|
this.preferences = new Preferences({
|
|
2089
2366
|
useCache: (_b = options.useCache) != null ? _b : true,
|
|
2090
2367
|
inboxServiceInstance: chunk7B52C2XE_js.__privateGet(this, _inboxService3),
|
|
2091
|
-
eventEmitterInstance: chunk7B52C2XE_js.__privateGet(this,
|
|
2368
|
+
eventEmitterInstance: chunk7B52C2XE_js.__privateGet(this, _emitter8)
|
|
2092
2369
|
});
|
|
2093
|
-
this.socket =
|
|
2370
|
+
this.socket = createSocket({
|
|
2094
2371
|
socketUrl: options.socketUrl,
|
|
2095
|
-
eventEmitterInstance: chunk7B52C2XE_js.__privateGet(this,
|
|
2372
|
+
eventEmitterInstance: chunk7B52C2XE_js.__privateGet(this, _emitter8),
|
|
2096
2373
|
inboxServiceInstance: chunk7B52C2XE_js.__privateGet(this, _inboxService3)
|
|
2097
2374
|
});
|
|
2098
2375
|
this.on = (eventName, listener) => {
|
|
2099
2376
|
if (this.socket.isSocketEvent(eventName)) {
|
|
2100
2377
|
this.socket.connect();
|
|
2101
2378
|
}
|
|
2102
|
-
const cleanup = chunk7B52C2XE_js.__privateGet(this,
|
|
2379
|
+
const cleanup = chunk7B52C2XE_js.__privateGet(this, _emitter8).on(eventName, listener);
|
|
2103
2380
|
return () => {
|
|
2104
2381
|
cleanup();
|
|
2105
2382
|
};
|
|
2106
2383
|
};
|
|
2107
2384
|
this.off = (eventName, listener) => {
|
|
2108
|
-
chunk7B52C2XE_js.__privateGet(this,
|
|
2385
|
+
chunk7B52C2XE_js.__privateGet(this, _emitter8).off(eventName, listener);
|
|
2109
2386
|
};
|
|
2110
2387
|
}
|
|
2111
2388
|
get applicationIdentifier() {
|
|
@@ -2114,10 +2391,24 @@ var Novu = class {
|
|
|
2114
2391
|
get subscriberId() {
|
|
2115
2392
|
return chunk7B52C2XE_js.__privateGet(this, _session).subscriberId;
|
|
2116
2393
|
}
|
|
2394
|
+
changeSubscriber(options) {
|
|
2395
|
+
return chunk7B52C2XE_js.__async(this, null, function* () {
|
|
2396
|
+
if (chunk7B52C2XE_js.__privateGet(this, _currentSubscriberId) === options.subscriber.subscriberId) {
|
|
2397
|
+
return;
|
|
2398
|
+
}
|
|
2399
|
+
yield chunk7B52C2XE_js.__privateGet(this, _session).initialize({
|
|
2400
|
+
applicationIdentifier: chunk7B52C2XE_js.__privateGet(this, _session).applicationIdentifier || "",
|
|
2401
|
+
subscriberHash: options.subscriberHash,
|
|
2402
|
+
subscriber: options.subscriber
|
|
2403
|
+
});
|
|
2404
|
+
chunk7B52C2XE_js.__privateSet(this, _currentSubscriberId, options.subscriber.subscriberId);
|
|
2405
|
+
});
|
|
2406
|
+
}
|
|
2117
2407
|
};
|
|
2118
|
-
|
|
2408
|
+
_emitter8 = new WeakMap();
|
|
2119
2409
|
_session = new WeakMap();
|
|
2120
2410
|
_inboxService3 = new WeakMap();
|
|
2411
|
+
_currentSubscriberId = new WeakMap();
|
|
2121
2412
|
function buildSubscriber(options) {
|
|
2122
2413
|
if (options.subscriber) {
|
|
2123
2414
|
return typeof options.subscriber === "string" ? { subscriberId: options.subscriber } : options.subscriber;
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { N as NotificationFilter } from './novu-
|
|
2
|
-
export { C as ChannelPreference, c as ChannelType, E as EventHandler, a as Events, F as FiltersCountResponse, I as InboxNotification, L as ListNotificationsResponse, d as Notification, e as NotificationStatus, b as Novu, f as NovuError, g as NovuOptions, P as Preference, i as PreferenceLevel, j as PreferencesResponse, S as SocketEventNames, h as StandardNovuOptions, k as Subscriber, W as WebSocketEvent } from './novu-
|
|
1
|
+
import { N as NotificationFilter } from './novu-CnZkqUKP.js';
|
|
2
|
+
export { C as ChannelPreference, c as ChannelType, E as EventHandler, a as Events, F as FiltersCountResponse, I as InboxNotification, L as ListNotificationsResponse, d as Notification, e as NotificationStatus, b as Novu, f as NovuError, g as NovuOptions, P as Preference, i as PreferenceLevel, j as PreferencesResponse, S as SocketEventNames, h as StandardNovuOptions, k as Subscriber, W as WebSocketEvent } from './novu-CnZkqUKP.js';
|
|
3
3
|
|
|
4
4
|
declare const areTagsEqual: (tags1?: string[], tags2?: string[]) => boolean;
|
|
5
5
|
declare const isSameFilter: (filter1: NotificationFilter, filter2: NotificationFilter) => boolean;
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkAVYEBJPB_js = require('./chunk-AVYEBJPB.js');
|
|
4
4
|
require('./chunk-7B52C2XE.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, "ChannelType", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunkAVYEBJPB_js.ChannelType; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "NotificationStatus", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkAVYEBJPB_js.NotificationStatus; }
|
|
15
15
|
});
|
|
16
16
|
Object.defineProperty(exports, "Novu", {
|
|
17
17
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunkAVYEBJPB_js.Novu; }
|
|
19
19
|
});
|
|
20
20
|
Object.defineProperty(exports, "PreferenceLevel", {
|
|
21
21
|
enumerable: true,
|
|
22
|
-
get: function () { return
|
|
22
|
+
get: function () { return chunkAVYEBJPB_js.PreferenceLevel; }
|
|
23
23
|
});
|
|
24
24
|
Object.defineProperty(exports, "WebSocketEvent", {
|
|
25
25
|
enumerable: true,
|
|
26
|
-
get: function () { return
|
|
26
|
+
get: function () { return chunkAVYEBJPB_js.WebSocketEvent; }
|
|
27
27
|
});
|
|
28
28
|
Object.defineProperty(exports, "areTagsEqual", {
|
|
29
29
|
enumerable: true,
|
|
30
|
-
get: function () { return
|
|
30
|
+
get: function () { return chunkAVYEBJPB_js.areTagsEqual; }
|
|
31
31
|
});
|
|
32
32
|
Object.defineProperty(exports, "isSameFilter", {
|
|
33
33
|
enumerable: true,
|
|
34
|
-
get: function () { return
|
|
34
|
+
get: function () { return chunkAVYEBJPB_js.isSameFilter; }
|
|
35
35
|
});
|
|
@@ -586,14 +586,7 @@ declare class Preferences extends BaseModule {
|
|
|
586
586
|
bulkUpdate(args: Array<InstancePreferenceArgs>): Result<Preference[]>;
|
|
587
587
|
}
|
|
588
588
|
|
|
589
|
-
|
|
590
|
-
#private;
|
|
591
|
-
constructor({ socketUrl, inboxServiceInstance, eventEmitterInstance, }: {
|
|
592
|
-
socketUrl?: string;
|
|
593
|
-
inboxServiceInstance: InboxService;
|
|
594
|
-
eventEmitterInstance: NovuEventEmitter;
|
|
595
|
-
});
|
|
596
|
-
protected onSessionSuccess({ token }: Session): void;
|
|
589
|
+
interface BaseSocketInterface {
|
|
597
590
|
isSocketEvent(eventName: string): eventName is SocketEventNames;
|
|
598
591
|
connect(): Result<void>;
|
|
599
592
|
disconnect(): Result<void>;
|
|
@@ -603,7 +596,7 @@ declare class Novu implements Pick<NovuEventEmitter, 'on'> {
|
|
|
603
596
|
#private;
|
|
604
597
|
readonly notifications: Notifications;
|
|
605
598
|
readonly preferences: Preferences;
|
|
606
|
-
readonly socket:
|
|
599
|
+
readonly socket: BaseSocketInterface;
|
|
607
600
|
on: <Key extends EventNames>(eventName: Key, listener: EventHandler<Events[Key]>) => () => void;
|
|
608
601
|
/**
|
|
609
602
|
* @deprecated
|
|
@@ -613,6 +606,10 @@ declare class Novu implements Pick<NovuEventEmitter, 'on'> {
|
|
|
613
606
|
get applicationIdentifier(): string | undefined;
|
|
614
607
|
get subscriberId(): string | undefined;
|
|
615
608
|
constructor(options: NovuOptions);
|
|
609
|
+
changeSubscriber(options: {
|
|
610
|
+
subscriber: Subscriber;
|
|
611
|
+
subscriberHash?: string;
|
|
612
|
+
}): Promise<void>;
|
|
616
613
|
}
|
|
617
614
|
|
|
618
615
|
export { type ChannelPreference as C, type EventHandler as E, type FiltersCountResponse as F, type InboxNotification as I, type ListNotificationsResponse as L, type NotificationFilter as N, Preference as P, type SocketEventNames as S, WebSocketEvent as W, type Events as a, Novu as b, ChannelType as c, Notification as d, NotificationStatus as e, NovuError as f, type NovuOptions as g, type StandardNovuOptions as h, PreferenceLevel as i, type PreferencesResponse as j, type Subscriber as k };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as Notification, N as NotificationFilter, g as NovuOptions, b as Novu, P as Preference } from './novu-
|
|
1
|
+
import { d as Notification, N as NotificationFilter, g as NovuOptions, b as Novu, P as Preference } from './novu-CnZkqUKP.js';
|
|
2
2
|
|
|
3
3
|
declare const appearanceKeys: readonly ["button", "input", "icon", "badge", "popoverContent", "popoverTrigger", "popoverClose", "dropdownContent", "dropdownTrigger", "dropdownItem", "dropdownItemLabel", "dropdownItemLabelContainer", "dropdownItemLeft__icon", "dropdownItemRight__icon", "dropdownItem__icon", "collapsible", "tooltipContent", "tooltipTrigger", "datePicker", "datePickerGrid", "datePickerGridRow", "datePickerGridCell", "datePickerGridCellTrigger", "datePickerTrigger", "datePickerGridHeader", "datePickerControl", "datePickerControlPrevTrigger", "datePickerControlNextTrigger", "datePickerControlPrevTrigger__icon", "datePickerControlNextTrigger__icon", "datePickerCalendar", "datePickerHeaderMonth", "datePickerCalendarDay__button", "timePicker", "timePicker__hourSelect", "timePicker__minuteSelect", "timePicker__periodSelect", "timePicker__separator", "timePickerHour__input", "timePickerMinute__input", "snoozeDatePicker", "snoozeDatePicker__actions", "snoozeDatePickerCancel__button", "snoozeDatePickerApply__button", "snoozeDatePicker__timePickerContainer", "snoozeDatePicker__timePickerLabel", "back__button", "skeletonText", "skeletonAvatar", "skeletonSwitch", "skeletonSwitchThumb", "tabsRoot", "tabsList", "tabsContent", "tabsTrigger", "dots", "root", "bellIcon", "lockIcon", "bellContainer", "bellDot", "preferences__button", "preferencesContainer", "inboxHeader", "loading", "inboxContent", "inbox__popoverTrigger", "inbox__popoverContent", "notificationListContainer", "notificationList", "notificationListEmptyNoticeContainer", "notificationListEmptyNoticeOverlay", "notificationListEmptyNoticeIcon", "notificationListEmptyNotice", "notificationList__skeleton", "notificationList__skeletonContent", "notificationList__skeletonItem", "notificationList__skeletonAvatar", "notificationList__skeletonText", "notificationListNewNotificationsNotice__button", "notification", "notificationContent", "notificationTextContainer", "notificationDot", "notificationSubject", "notificationSubject__strong", "notificationBody", "notificationBody__strong", "notificationBodyContainer", "notificationImage", "notificationImageLoadingFallback", "notificationDate", "notificationDateActionsContainer", "notificationDefaultActions", "notificationCustomActions", "notificationPrimaryAction__button", "notificationSecondaryAction__button", "notificationRead__button", "notificationUnread__button", "notificationArchive__button", "notificationUnarchive__button", "notificationSnooze__button", "notificationUnsnooze__button", "notificationRead__icon", "notificationUnread__icon", "notificationArchive__icon", "notificationUnarchive__icon", "notificationSnooze__icon", "notificationUnsnooze__icon", "notificationsTabs__tabsRoot", "notificationsTabs__tabsList", "notificationsTabs__tabsContent", "notificationsTabs__tabsTrigger", "notificationsTabsTriggerLabel", "notificationsTabsTriggerCount", "inboxStatus__title", "inboxStatus__dropdownTrigger", "inboxStatus__dropdownContent", "inboxStatus__dropdownItem", "inboxStatus__dropdownItemLabel", "inboxStatus__dropdownItemLabelContainer", "inboxStatus__dropdownItemLeft__icon", "inboxStatus__dropdownItemRight__icon", "inboxStatus__dropdownItem__icon", "inboxStatus__dropdownItemCheck__icon", "moreActionsContainer", "moreActions__dropdownTrigger", "moreActions__dropdownContent", "moreActions__dropdownItem", "moreActions__dropdownItemLabel", "moreActions__dropdownItemLeft__icon", "moreActions__dots", "moreTabs__button", "moreTabs__icon", "moreTabs__dropdownTrigger", "moreTabs__dropdownContent", "moreTabs__dropdownItem", "moreTabs__dropdownItemLabel", "moreTabs__dropdownItemRight__icon", "workflowContainer", "workflowLabel", "workflowLabelHeader", "workflowLabelHeaderContainer", "workflowLabelIcon", "workflowLabelContainer", "workflowContainerDisabledNotice", "workflowLabelDisabled__icon", "workflowContainerRight__icon", "workflowArrow__icon", "workflowDescription", "preferencesGroupContainer", "preferencesGroupHeader", "preferencesGroupLabelContainer", "preferencesGroupLabelIcon", "preferencesGroupLabel", "preferencesGroupActionsContainer", "preferencesGroupActionsContainerRight__icon", "preferencesGroupBody", "preferencesGroupChannels", "preferencesGroupInfo", "preferencesGroupInfoIcon", "preferencesGroupWorkflows", "channelContainer", "channelIconContainer", "channel__icon", "channelsContainerCollapsible", "channelsContainer", "channelLabel", "channelLabelContainer", "channelName", "channelSwitchContainer", "channelSwitch", "channelSwitchThumb", "preferencesHeader", "preferencesHeader__back__button", "preferencesHeader__back__button__icon", "preferencesHeader__title", "preferencesHeader__icon", "preferencesListEmptyNoticeContainer", "preferencesListEmptyNotice", "preferencesList__skeleton", "preferencesList__skeletonContent", "preferencesList__skeletonItem", "preferencesList__skeletonIcon", "preferencesList__skeletonSwitch", "preferencesList__skeletonSwitchThumb", "preferencesList__skeletonText", "notificationSnooze__dropdownContent", "notificationSnooze__dropdownItem", "notificationSnooze__dropdownItem__icon", "notificationSnoozeCustomTime_popoverContent", "notificationDeliveredAt__badge", "notificationDeliveredAt__icon", "notificationSnoozedUntil__icon", "strong"];
|
|
4
4
|
|
package/dist/cjs/ui/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { g as NovuOptions } from '../novu-
|
|
2
|
-
export { d as Notification } from '../novu-
|
|
3
|
-
import { B as BellRenderer, N as NotificationClickHandler, a as NotificationActionClickHandler, b as NotificationRenderer, S as SubjectRenderer, c as BodyRenderer, d as NovuProviderProps, e as BaseNovuProviderProps, A as Appearance, L as Localization, T as Tab, P as PreferencesFilter, f as PreferenceGroups, R as RouterPush } from '../types-
|
|
4
|
-
export { g as AppearanceKey, h as ElementStyles, E as Elements, I as IconKey, i as IconOverrides, j as IconRenderer, k as LocalizationKey, l as NotificationStatus, m as Theme, V as Variables } from '../types-
|
|
1
|
+
import { g as NovuOptions } from '../novu-CnZkqUKP.js';
|
|
2
|
+
export { d as Notification } from '../novu-CnZkqUKP.js';
|
|
3
|
+
import { B as BellRenderer, N as NotificationClickHandler, a as NotificationActionClickHandler, b as NotificationRenderer, S as SubjectRenderer, c as BodyRenderer, d as NovuProviderProps, e as BaseNovuProviderProps, A as Appearance, L as Localization, T as Tab, P as PreferencesFilter, f as PreferenceGroups, R as RouterPush } from '../types-BSZsDqkz.js';
|
|
4
|
+
export { g as AppearanceKey, h as ElementStyles, E as Elements, I as IconKey, i as IconOverrides, j as IconRenderer, k as LocalizationKey, l as NotificationStatus, m as Theme, V as Variables } from '../types-BSZsDqkz.js';
|
|
5
5
|
import { Placement, OffsetOptions } from '@floating-ui/dom';
|
|
6
6
|
import * as solid_js from 'solid-js';
|
|
7
7
|
import { ComponentProps } from 'solid-js';
|