@timardex/cluemart-server-shared 1.0.291 → 1.0.292

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/index.d.mts CHANGED
@@ -901,12 +901,16 @@ declare function publishNotificationEvents(userId: ObjectId, pubsub: Notificatio
901
901
  /**
902
902
  * Sends push notifications, saves them in the database, and (when a `pubsub`
903
903
  * is provided) publishes GraphQL subscription events for each affected user.
904
- * Errors are logged and swallowed; this function never throws.
904
+ *
905
+ * Errors are logged and swallowed; this function never throws. Instead it
906
+ * returns `false` when notifications were not confirmed (an error was thrown,
907
+ * or `saveNotificationsInDb` failed to persist any rows for a non-empty
908
+ * `userIds`), so callers can gate success logs/metrics on the result.
905
909
  */
906
910
  declare function notifyUsers({ payload, pubsub, }: {
907
911
  payload: SchemaCreateBulkNotificationInput;
908
912
  pubsub?: NotificationPubSub;
909
- }): Promise<void>;
913
+ }): Promise<boolean>;
910
914
 
911
915
  /**
912
916
  * Create notifications in the database for multiple users
package/dist/index.d.ts CHANGED
@@ -901,12 +901,16 @@ declare function publishNotificationEvents(userId: ObjectId, pubsub: Notificatio
901
901
  /**
902
902
  * Sends push notifications, saves them in the database, and (when a `pubsub`
903
903
  * is provided) publishes GraphQL subscription events for each affected user.
904
- * Errors are logged and swallowed; this function never throws.
904
+ *
905
+ * Errors are logged and swallowed; this function never throws. Instead it
906
+ * returns `false` when notifications were not confirmed (an error was thrown,
907
+ * or `saveNotificationsInDb` failed to persist any rows for a non-empty
908
+ * `userIds`), so callers can gate success logs/metrics on the result.
905
909
  */
906
910
  declare function notifyUsers({ payload, pubsub, }: {
907
911
  payload: SchemaCreateBulkNotificationInput;
908
912
  pubsub?: NotificationPubSub;
909
- }): Promise<void>;
913
+ }): Promise<boolean>;
910
914
 
911
915
  /**
912
916
  * Create notifications in the database for multiple users
package/dist/index.mjs CHANGED
@@ -9802,14 +9802,16 @@ async function notifyUsers({
9802
9802
  try {
9803
9803
  await sendPushNotifications(payload);
9804
9804
  const uniqueUserIds = await saveNotificationsInDb(payload);
9805
- if (!pubsub) {
9806
- return;
9807
- }
9808
- for (const userId of uniqueUserIds) {
9809
- await publishNotificationEvents(userId, pubsub);
9805
+ const persisted = payload.userIds.length === 0 || uniqueUserIds.length > 0;
9806
+ if (pubsub) {
9807
+ for (const userId of uniqueUserIds) {
9808
+ await publishNotificationEvents(userId, pubsub);
9809
+ }
9810
9810
  }
9811
+ return persisted;
9811
9812
  } catch (error) {
9812
9813
  console.error("Error in notifyUsers:", error);
9814
+ return false;
9813
9815
  }
9814
9816
  }
9815
9817