@timardex/cluemart-server-shared 1.1.36 → 1.1.37

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.
@@ -333,6 +333,19 @@ declare function getPartnerResourceInfo(userId: ObjectId, partnerId: ObjectId):
333
333
  */
334
334
  declare function remindUsersAboutLicenseExpiration(): Promise<void>;
335
335
 
336
+ /**
337
+ * License expiration reminder window bounds.
338
+ *
339
+ * A licence qualifies for the "7 days before expiry" reminder when its expiry is
340
+ * between {@link REMINDER_WINDOW_MIN_HOURS} and {@link REMINDER_WINDOW_MAX_HOURS}
341
+ * away.
342
+ *
343
+ * Expressed in hours (derived from days) because dayjs rounds fractional "day"
344
+ * adds: `now.add(6.5, "day")` becomes 7 days and `now.add(7.5, "day")` 8 days.
345
+ */
346
+ declare const REMINDER_WINDOW_MIN_HOURS: number;
347
+ declare const REMINDER_WINDOW_MAX_HOURS: number;
348
+
336
349
  /**
337
350
  * Single source of truth for how a licence type is handled on expiry.
338
351
  *
@@ -449,4 +462,4 @@ declare function checkOwnerHasLicence({ userId, resourceType, }: {
449
462
  resourceType: EnumResourceType;
450
463
  }): Promise<void>;
451
464
 
452
- export { ACTIVE_NOT_DELETED_FILTER, type AwardAffiliateVendorSubscriptionRewardsResult, LicenceCategory, LicenceExpiryDate, type NotificationPubSub, SUBSCRIPTION_REWARD_TIMEZONE, activeAffiliateCodeExists, awardAffiliateVendorSubscriptionRewards, buildLicenceExpiryPipeline, checkOwnerHasLicence, connectToDatabase, convertObjectIdsToStrings, createLicenceObject, didRemoveAnyEventDates, ensureUserLicenseCompliance, eventLicences, findAffiliateByPromoCode, findEventOrImportedMarketById, getEventResourceInfo, getHighestLicenceForCategory, getLicenceCategory, getLicenceExpiryMode, getPartnerResourceInfo, getPayingEventStripeSubscriptionPlan, getPayingStripeSubscriptionPlan, getPayingVendorStripeSubscriptionPlan, getSubscriptionRewardPeriodBounds, getVendorResourceInfo, handleEventLicenceCompliance, handlePartnerLicenceCompliance, handleVendorLicenceCompliance, hasValidLicence, isStandardLicence, isValidObjectId, licenceCategoryMapping, licencePriority, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, partnerLicences, processLicenseReminder, processUserCompliance, processUserLicenseReminders, publishNotificationEvents, remindUsersAboutLicenseExpiration, replaceUserLicenceWithObject, saveNotificationsInDb, sendDeactivationNotification, sendLicenseReminder, sendPushNotifications, sendReminderSafely, syncUserLicencesAfterExpiry, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, updateSingleDateTimeStatus, updateVendorBasedOnUserLicense, upgradeUserToLicence, vendorLicences, vendorOwnerHasProLicence };
465
+ export { ACTIVE_NOT_DELETED_FILTER, type AwardAffiliateVendorSubscriptionRewardsResult, LicenceCategory, LicenceExpiryDate, type NotificationPubSub, REMINDER_WINDOW_MAX_HOURS, REMINDER_WINDOW_MIN_HOURS, SUBSCRIPTION_REWARD_TIMEZONE, activeAffiliateCodeExists, awardAffiliateVendorSubscriptionRewards, buildLicenceExpiryPipeline, checkOwnerHasLicence, connectToDatabase, convertObjectIdsToStrings, createLicenceObject, didRemoveAnyEventDates, ensureUserLicenseCompliance, eventLicences, findAffiliateByPromoCode, findEventOrImportedMarketById, getEventResourceInfo, getHighestLicenceForCategory, getLicenceCategory, getLicenceExpiryMode, getPartnerResourceInfo, getPayingEventStripeSubscriptionPlan, getPayingStripeSubscriptionPlan, getPayingVendorStripeSubscriptionPlan, getSubscriptionRewardPeriodBounds, getVendorResourceInfo, handleEventLicenceCompliance, handlePartnerLicenceCompliance, handleVendorLicenceCompliance, hasValidLicence, isStandardLicence, isValidObjectId, licenceCategoryMapping, licencePriority, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, partnerLicences, processLicenseReminder, processUserCompliance, processUserLicenseReminders, publishNotificationEvents, remindUsersAboutLicenseExpiration, replaceUserLicenceWithObject, saveNotificationsInDb, sendDeactivationNotification, sendLicenseReminder, sendPushNotifications, sendReminderSafely, syncUserLicencesAfterExpiry, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, updateSingleDateTimeStatus, updateVendorBasedOnUserLicense, upgradeUserToLicence, vendorLicences, vendorOwnerHasProLicence };
@@ -333,6 +333,19 @@ declare function getPartnerResourceInfo(userId: ObjectId, partnerId: ObjectId):
333
333
  */
334
334
  declare function remindUsersAboutLicenseExpiration(): Promise<void>;
335
335
 
336
+ /**
337
+ * License expiration reminder window bounds.
338
+ *
339
+ * A licence qualifies for the "7 days before expiry" reminder when its expiry is
340
+ * between {@link REMINDER_WINDOW_MIN_HOURS} and {@link REMINDER_WINDOW_MAX_HOURS}
341
+ * away.
342
+ *
343
+ * Expressed in hours (derived from days) because dayjs rounds fractional "day"
344
+ * adds: `now.add(6.5, "day")` becomes 7 days and `now.add(7.5, "day")` 8 days.
345
+ */
346
+ declare const REMINDER_WINDOW_MIN_HOURS: number;
347
+ declare const REMINDER_WINDOW_MAX_HOURS: number;
348
+
336
349
  /**
337
350
  * Single source of truth for how a licence type is handled on expiry.
338
351
  *
@@ -449,4 +462,4 @@ declare function checkOwnerHasLicence({ userId, resourceType, }: {
449
462
  resourceType: EnumResourceType;
450
463
  }): Promise<void>;
451
464
 
452
- export { ACTIVE_NOT_DELETED_FILTER, type AwardAffiliateVendorSubscriptionRewardsResult, LicenceCategory, LicenceExpiryDate, type NotificationPubSub, SUBSCRIPTION_REWARD_TIMEZONE, activeAffiliateCodeExists, awardAffiliateVendorSubscriptionRewards, buildLicenceExpiryPipeline, checkOwnerHasLicence, connectToDatabase, convertObjectIdsToStrings, createLicenceObject, didRemoveAnyEventDates, ensureUserLicenseCompliance, eventLicences, findAffiliateByPromoCode, findEventOrImportedMarketById, getEventResourceInfo, getHighestLicenceForCategory, getLicenceCategory, getLicenceExpiryMode, getPartnerResourceInfo, getPayingEventStripeSubscriptionPlan, getPayingStripeSubscriptionPlan, getPayingVendorStripeSubscriptionPlan, getSubscriptionRewardPeriodBounds, getVendorResourceInfo, handleEventLicenceCompliance, handlePartnerLicenceCompliance, handleVendorLicenceCompliance, hasValidLicence, isStandardLicence, isValidObjectId, licenceCategoryMapping, licencePriority, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, partnerLicences, processLicenseReminder, processUserCompliance, processUserLicenseReminders, publishNotificationEvents, remindUsersAboutLicenseExpiration, replaceUserLicenceWithObject, saveNotificationsInDb, sendDeactivationNotification, sendLicenseReminder, sendPushNotifications, sendReminderSafely, syncUserLicencesAfterExpiry, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, updateSingleDateTimeStatus, updateVendorBasedOnUserLicense, upgradeUserToLicence, vendorLicences, vendorOwnerHasProLicence };
465
+ export { ACTIVE_NOT_DELETED_FILTER, type AwardAffiliateVendorSubscriptionRewardsResult, LicenceCategory, LicenceExpiryDate, type NotificationPubSub, REMINDER_WINDOW_MAX_HOURS, REMINDER_WINDOW_MIN_HOURS, SUBSCRIPTION_REWARD_TIMEZONE, activeAffiliateCodeExists, awardAffiliateVendorSubscriptionRewards, buildLicenceExpiryPipeline, checkOwnerHasLicence, connectToDatabase, convertObjectIdsToStrings, createLicenceObject, didRemoveAnyEventDates, ensureUserLicenseCompliance, eventLicences, findAffiliateByPromoCode, findEventOrImportedMarketById, getEventResourceInfo, getHighestLicenceForCategory, getLicenceCategory, getLicenceExpiryMode, getPartnerResourceInfo, getPayingEventStripeSubscriptionPlan, getPayingStripeSubscriptionPlan, getPayingVendorStripeSubscriptionPlan, getSubscriptionRewardPeriodBounds, getVendorResourceInfo, handleEventLicenceCompliance, handlePartnerLicenceCompliance, handleVendorLicenceCompliance, hasValidLicence, isStandardLicence, isValidObjectId, licenceCategoryMapping, licencePriority, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, partnerLicences, processLicenseReminder, processUserCompliance, processUserLicenseReminders, publishNotificationEvents, remindUsersAboutLicenseExpiration, replaceUserLicenceWithObject, saveNotificationsInDb, sendDeactivationNotification, sendLicenseReminder, sendPushNotifications, sendReminderSafely, syncUserLicencesAfterExpiry, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, updateSingleDateTimeStatus, updateVendorBasedOnUserLicense, upgradeUserToLicence, vendorLicences, vendorOwnerHasProLicence };
@@ -2660,6 +2660,10 @@ async function getPartnerResourceInfo(userId, partnerId) {
2660
2660
  // src/service/license/reminder/remindUsersAboutLicenseExpiration.ts
2661
2661
  import dayjs10 from "dayjs";
2662
2662
 
2663
+ // src/service/license/reminder/reminderWindow.ts
2664
+ var REMINDER_WINDOW_MIN_HOURS = 6.5 * 24;
2665
+ var REMINDER_WINDOW_MAX_HOURS = 7.5 * 24;
2666
+
2663
2667
  // src/service/license/reminder/utils.ts
2664
2668
  import dayjs9 from "dayjs";
2665
2669
 
@@ -2721,8 +2725,8 @@ async function checkAndCreateNotification(payload) {
2721
2725
  }
2722
2726
  function isLicenseExpiringIn7Days(expiryDate, now) {
2723
2727
  const expiry = dayjs9(expiryDate);
2724
- const daysUntilExpiry = expiry.diff(now, "day", true);
2725
- return daysUntilExpiry >= 6.5 && daysUntilExpiry <= 7.5;
2728
+ const hoursUntilExpiry = expiry.diff(now, "hour", true);
2729
+ return hoursUntilExpiry >= REMINDER_WINDOW_MIN_HOURS && hoursUntilExpiry <= REMINDER_WINDOW_MAX_HOURS;
2726
2730
  }
2727
2731
  function getLicenseName(licenceType) {
2728
2732
  return licenseNiceNames[licenceType] || licenceType;
@@ -2886,8 +2890,8 @@ async function processUserLicenseReminders(user, now) {
2886
2890
  async function remindUsersAboutLicenseExpiration() {
2887
2891
  const now = dayjs10();
2888
2892
  console.log(`\u{1F50D} Checking for licenses expiring in 7 days at ${now.format()}`);
2889
- const minExpiryDate = now.add(6.5, "day").toDate();
2890
- const maxExpiryDate = now.add(7.5, "day").toDate();
2893
+ const minExpiryDate = now.add(REMINDER_WINDOW_MIN_HOURS, "hour").toDate();
2894
+ const maxExpiryDate = now.add(REMINDER_WINDOW_MAX_HOURS, "hour").toDate();
2891
2895
  const users = await UserModel.find({
2892
2896
  licences: {
2893
2897
  $elemMatch: {
@@ -2925,6 +2929,8 @@ export {
2925
2929
  ACTIVE_NOT_DELETED_FILTER,
2926
2930
  LicenceCategory,
2927
2931
  LicenceExpiryDate,
2932
+ REMINDER_WINDOW_MAX_HOURS,
2933
+ REMINDER_WINDOW_MIN_HOURS,
2928
2934
  SUBSCRIPTION_REWARD_TIMEZONE,
2929
2935
  activeAffiliateCodeExists,
2930
2936
  awardAffiliateVendorSubscriptionRewards,