@timardex/cluemart-server-shared 2.2.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-HLRUWJLN.mjs → chunk-ZKHRT2PV.mjs} +16 -8
- package/dist/chunk-ZKHRT2PV.mjs.map +1 -0
- package/dist/index.cjs +29 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.mjs +29 -23
- package/dist/index.mjs.map +1 -1
- package/dist/mongoose/index.cjs +15 -7
- package/dist/mongoose/index.cjs.map +1 -1
- package/dist/mongoose/index.mjs +1 -1
- package/dist/service/index.cjs +29 -23
- package/dist/service/index.cjs.map +1 -1
- package/dist/service/index.d.mts +2 -3
- package/dist/service/index.d.ts +2 -3
- package/dist/service/index.mjs +15 -17
- package/dist/service/index.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-HLRUWJLN.mjs.map +0 -1
package/dist/mongoose/index.mjs
CHANGED
package/dist/service/index.cjs
CHANGED
|
@@ -1118,16 +1118,24 @@ var GoogleImportedMarketModel = import_mongoose10.default.models.GoogleImportedM
|
|
|
1118
1118
|
var import_cluemart_shared9 = require("@timardex/cluemart-shared");
|
|
1119
1119
|
var import_mongoose11 = __toESM(require("mongoose"));
|
|
1120
1120
|
var MongooseSchema7 = import_mongoose11.default.Schema;
|
|
1121
|
+
var notificationDataSchema = new MongooseSchema7(
|
|
1122
|
+
{
|
|
1123
|
+
resourceId: { required: true, type: String },
|
|
1124
|
+
resourceName: { required: true, type: String },
|
|
1125
|
+
resourceType: {
|
|
1126
|
+
enum: Object.values(import_cluemart_shared9.EnumNotificationResourceType),
|
|
1127
|
+
required: true,
|
|
1128
|
+
type: String
|
|
1129
|
+
}
|
|
1130
|
+
},
|
|
1131
|
+
{ _id: false }
|
|
1132
|
+
);
|
|
1121
1133
|
var schema8 = new MongooseSchema7(
|
|
1122
1134
|
{
|
|
1123
1135
|
data: {
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
enum: Object.values(import_cluemart_shared9.EnumNotificationResourceType),
|
|
1128
|
-
required: true,
|
|
1129
|
-
type: String
|
|
1130
|
-
}
|
|
1136
|
+
default: null,
|
|
1137
|
+
required: false,
|
|
1138
|
+
type: notificationDataSchema
|
|
1131
1139
|
},
|
|
1132
1140
|
isRead: { default: false, index: true, required: true, type: Boolean },
|
|
1133
1141
|
message: { required: true, type: String },
|
|
@@ -2529,25 +2537,24 @@ var import_utils3 = require("@timardex/cluemart-shared/utils");
|
|
|
2529
2537
|
// src/service/saveNotificationsInDb.ts
|
|
2530
2538
|
async function saveNotificationsInDb(payload) {
|
|
2531
2539
|
const { data, message, title, type, userIds } = payload;
|
|
2532
|
-
|
|
2540
|
+
const notifications = userIds.map((userId) => ({
|
|
2541
|
+
data,
|
|
2542
|
+
isRead: false,
|
|
2543
|
+
message,
|
|
2544
|
+
title,
|
|
2545
|
+
type,
|
|
2546
|
+
userId
|
|
2547
|
+
}));
|
|
2533
2548
|
try {
|
|
2534
|
-
const notifications = userIds.map((userId) => ({
|
|
2535
|
-
data,
|
|
2536
|
-
isRead: false,
|
|
2537
|
-
message,
|
|
2538
|
-
title,
|
|
2539
|
-
type,
|
|
2540
|
-
userId
|
|
2541
|
-
}));
|
|
2542
2549
|
await NotificationModel.insertMany(notifications);
|
|
2543
|
-
console.log(
|
|
2544
|
-
`Created ${notifications.length} notifications for ${userIds.length} users`
|
|
2545
|
-
);
|
|
2546
|
-
return [...new Set(userIds)];
|
|
2547
2550
|
} catch (error) {
|
|
2548
2551
|
console.error("Failed to create notifications:", error);
|
|
2549
|
-
|
|
2552
|
+
throw error;
|
|
2550
2553
|
}
|
|
2554
|
+
console.log(
|
|
2555
|
+
`Created ${notifications.length} notifications for ${userIds.length} users`
|
|
2556
|
+
);
|
|
2557
|
+
return [...new Set(userIds)];
|
|
2551
2558
|
}
|
|
2552
2559
|
|
|
2553
2560
|
// src/service/sendPushNotifications.ts
|
|
@@ -2571,7 +2578,7 @@ function createPushMessages({
|
|
|
2571
2578
|
}
|
|
2572
2579
|
messages.push({
|
|
2573
2580
|
body: message,
|
|
2574
|
-
data: { ...data },
|
|
2581
|
+
...data ? { data: { ...data } } : {},
|
|
2575
2582
|
sound: "tui.wav",
|
|
2576
2583
|
title,
|
|
2577
2584
|
to: token
|
|
@@ -2626,7 +2633,6 @@ async function sendPushNotifications({
|
|
|
2626
2633
|
}) {
|
|
2627
2634
|
const pushTokens = await PushTokenModel.find({ userId: { $in: userIds } });
|
|
2628
2635
|
const expoTokens = pushTokens.map((token) => token.token);
|
|
2629
|
-
if (!data) return;
|
|
2630
2636
|
const { messages, invalidTokens } = createPushMessages({
|
|
2631
2637
|
data,
|
|
2632
2638
|
message,
|