@timardex/cluemart-server-shared 1.0.291 → 1.0.293

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
@@ -3608,6 +3608,12 @@ var EnumGameType = /* @__PURE__ */ ((EnumGameType2) => {
3608
3608
  EnumGameType2["ODD_ONE_OUT"] = "oddOneOut";
3609
3609
  return EnumGameType2;
3610
3610
  })(EnumGameType || {});
3611
+ var EnumAffiliateParticipantType = /* @__PURE__ */ ((EnumAffiliateParticipantType2) => {
3612
+ EnumAffiliateParticipantType2["INDIVIDUAL"] = "INDIVIDUAL";
3613
+ EnumAffiliateParticipantType2["SOLE_TRADER"] = "SOLE_TRADER";
3614
+ EnumAffiliateParticipantType2["COMPANY"] = "COMPANY";
3615
+ return EnumAffiliateParticipantType2;
3616
+ })(EnumAffiliateParticipantType || {});
3611
3617
  var EnumAffiliateRewardType = /* @__PURE__ */ ((EnumAffiliateRewardType22) => {
3612
3618
  EnumAffiliateRewardType22["ACTIVE_EVENT_WITH_VENDOR_REGISTRATIONS"] = "ACTIVE_EVENT_WITH_VENDOR_REGISTRATIONS";
3613
3619
  EnumAffiliateRewardType22["ACTIVE_VENDOR_BONUS_REWARD"] = "ACTIVE_VENDOR_BONUS_REWARD";
@@ -7466,6 +7472,14 @@ var AFFILIATE_DETAILS_FIELDS_FRAGMENT = gql`
7466
7472
  contactDetails {
7467
7473
  mobilePhone
7468
7474
  }
7475
+ irdNumber
7476
+ participantType
7477
+ email
7478
+ firstName
7479
+ lastName
7480
+ location {
7481
+ ...LocationFields
7482
+ }
7469
7483
  region
7470
7484
  socialMedia {
7471
7485
  ...SocialMediaFields
@@ -7475,6 +7489,7 @@ var AFFILIATE_DETAILS_FIELDS_FRAGMENT = gql`
7475
7489
  }
7476
7490
  }
7477
7491
  ${AFFILIATE_BANK_ACCOUNT_DETAILS_FIELDS_FRAGMENT}
7492
+ ${LOCATION_FIELDS_FRAGMENT}
7478
7493
  ${SOCIAL_MEDIA_FIELDS_FRAGMENT}
7479
7494
  ${TERMS_AGREEMENT_FIELDS_FRAGMENT}
7480
7495
  `;
@@ -7540,6 +7555,14 @@ var DELETE_AFFILIATE_MUTATION = gql`
7540
7555
  deleteAffiliate(_id: $_id)
7541
7556
  }
7542
7557
  `;
7558
+ var REDEEM_AFFILIATE_REWARD_MUTATION = gql`
7559
+ mutation redeemAffiliateReward($affiliateId: ID!) {
7560
+ redeemAffiliateReward(affiliateId: $affiliateId) {
7561
+ ...AffiliateFields
7562
+ }
7563
+ }
7564
+ ${AFFILIATE_FIELDS_FRAGMENT}
7565
+ `;
7543
7566
  var PKG = "@timardex/cluemart-shared";
7544
7567
  var IMAGE_EXTENSION = ".webp";
7545
7568
  var posterIds = [
@@ -9275,6 +9298,16 @@ var affiliateDetailsSchema = new MongooseSchema25(
9275
9298
  type: affiliateBankAccountDetailsSchema
9276
9299
  },
9277
9300
  contactDetails: { required: true, type: affiliateContactDetailsSchema },
9301
+ email: { required: true, type: String },
9302
+ firstName: { required: true, type: String },
9303
+ irdNumber: { required: true, type: String },
9304
+ lastName: { required: true, type: String },
9305
+ location: { required: true, type: locationsSchema },
9306
+ participantType: {
9307
+ enum: Object.values(EnumAffiliateParticipantType),
9308
+ required: true,
9309
+ type: String
9310
+ },
9278
9311
  region: { required: true, type: String },
9279
9312
  socialMedia: { required: false, type: [SocialMediaTypeSchema] },
9280
9313
  termsAgreement: { required: true, type: termsAgreementSchema }
@@ -9802,14 +9835,16 @@ async function notifyUsers({
9802
9835
  try {
9803
9836
  await sendPushNotifications(payload);
9804
9837
  const uniqueUserIds = await saveNotificationsInDb(payload);
9805
- if (!pubsub) {
9806
- return;
9807
- }
9808
- for (const userId of uniqueUserIds) {
9809
- await publishNotificationEvents(userId, pubsub);
9838
+ const persisted = payload.userIds.length === 0 || uniqueUserIds.length > 0;
9839
+ if (pubsub) {
9840
+ for (const userId of uniqueUserIds) {
9841
+ await publishNotificationEvents(userId, pubsub);
9842
+ }
9810
9843
  }
9844
+ return persisted;
9811
9845
  } catch (error) {
9812
9846
  console.error("Error in notifyUsers:", error);
9847
+ return false;
9813
9848
  }
9814
9849
  }
9815
9850