@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.
- package/dist/index.cjs +12 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +14 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.mjs +10 -4
- package/dist/index.mjs.map +1 -1
- package/dist/service/index.cjs +12 -4
- package/dist/service/index.cjs.map +1 -1
- package/dist/service/index.d.mts +14 -1
- package/dist/service/index.d.ts +14 -1
- package/dist/service/index.mjs +10 -4
- package/dist/service/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1108,6 +1108,19 @@ declare function getPartnerResourceInfo(userId: ObjectId, partnerId: ObjectId):
|
|
|
1108
1108
|
*/
|
|
1109
1109
|
declare function remindUsersAboutLicenseExpiration(): Promise<void>;
|
|
1110
1110
|
|
|
1111
|
+
/**
|
|
1112
|
+
* License expiration reminder window bounds.
|
|
1113
|
+
*
|
|
1114
|
+
* A licence qualifies for the "7 days before expiry" reminder when its expiry is
|
|
1115
|
+
* between {@link REMINDER_WINDOW_MIN_HOURS} and {@link REMINDER_WINDOW_MAX_HOURS}
|
|
1116
|
+
* away.
|
|
1117
|
+
*
|
|
1118
|
+
* Expressed in hours (derived from days) because dayjs rounds fractional "day"
|
|
1119
|
+
* adds: `now.add(6.5, "day")` becomes 7 days and `now.add(7.5, "day")` 8 days.
|
|
1120
|
+
*/
|
|
1121
|
+
declare const REMINDER_WINDOW_MIN_HOURS: number;
|
|
1122
|
+
declare const REMINDER_WINDOW_MAX_HOURS: number;
|
|
1123
|
+
|
|
1111
1124
|
/**
|
|
1112
1125
|
* Single source of truth for how a licence type is handled on expiry.
|
|
1113
1126
|
*
|
|
@@ -1224,4 +1237,4 @@ declare function checkOwnerHasLicence({ userId, resourceType, }: {
|
|
|
1224
1237
|
resourceType: EnumResourceType;
|
|
1225
1238
|
}): Promise<void>;
|
|
1226
1239
|
|
|
1227
|
-
export { ACTIVE_NOT_DELETED_FILTER, APP_SETTINGS_ID, AdModel, AffiliateModel, AppSettingModel, type AuthUser, type AwardAffiliateVendorSubscriptionRewardsResult, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, type CouponDocument, CouponModel, EnumPubSubEvents, EventInfoModel, EventModel, GameModel, GoogleImportedMarketModel, type GraphQLContext, LicenceCategory, LicenceExpiryDate, NotificationModel, type NotificationPubSub, type ObjectId, OwnerTypeSchema, PartnerModel, PostModel, PushTokenModel, RelationModel, RelationTypeSchema, ResourceActivityModel, ResourceImageTypeSchema, SUBSCRIPTION_REWARD_TIMEZONE, type SchemaAffiliateResourceType, type SchemaAffiliateReward, type SchemaChatMessageReactionType, type SchemaChatMessageReplyPreviewType, type SchemaChatMessageSeenType, type SchemaChatMessageType, type SchemaChatReportType, type SchemaChatType, type SchemaCreateBulkNotificationInput, type SchemaEventInfoType, type SchemaEventType, type SchemaGameType, type SchemaGoogleImportedMarket, type SchemaNotificationType, type SchemaOwnerType, type SchemaParticipantType, type SchemaPartnerType, type SchemaPostType, type SchemaPushTokenType, type SchemaRelatedPostType, type SchemaRelationType, type SchemaUnregisteredVendorInvitationType, type SchemaUnregisteredVendorType, type SchemaUserActivityEvent, type SchemaUserType, type SchemaVendorInfoType, type SchemaVendorType, SchoolModel, SocialMediaTypeSchema, StallTypeSchema, type SubscriptionPayload, UnregisteredVendorModel, UserModel, VendorInfoModel, VendorModel, VerificationTokenModel, type VerificationTokenType, activeAffiliateCodeExists, awardAffiliateVendorSubscriptionRewards, baseResourceFields, buildLicenceExpiryPipeline, checkOwnerHasLicence, connectToDatabase, convertObjectIdsToStrings, createLicenceObject, dateTimeSchema, didRemoveAnyEventDates, ensureUserLicenseCompliance, eventLicences, findAffiliateByPromoCode, findEventOrImportedMarketById, getEventResourceInfo, getHighestLicenceForCategory, getLicenceCategory, getLicenceExpiryMode, getPartnerResourceInfo, getPayingEventStripeSubscriptionPlan, getPayingStripeSubscriptionPlan, getPayingVendorStripeSubscriptionPlan, getSubscriptionRewardPeriodBounds, getVendorResourceInfo, handleEventLicenceCompliance, handlePartnerLicenceCompliance, handleVendorLicenceCompliance, hasValidLicence, isStandardLicence, isValidObjectId, licenceCategoryMapping, licencePriority, locationGeoSchema, locationsSchema, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, partnerLicences, processLicenseReminder, processUserCompliance, processUserLicenseReminders, publishNotificationEvents, refundPolicySchema, relatedPostSchema, relationDatesSchema, remindUsersAboutLicenseExpiration, replaceUserLicenceWithObject, resourceRelationsSchema, saveNotificationsInDb, sendDeactivationNotification, sendLicenseReminder, sendPushNotifications, sendReminderSafely, socialShareResourceSchema, syncUserLicencesAfterExpiry, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, updateSingleDateTimeStatus, updateVendorBasedOnUserLicense, upgradeUserToLicence, userLicenseSchema, vendorLicences, vendorOwnerHasProLicence, vendorProductTypeSchema };
|
|
1240
|
+
export { ACTIVE_NOT_DELETED_FILTER, APP_SETTINGS_ID, AdModel, AffiliateModel, AppSettingModel, type AuthUser, type AwardAffiliateVendorSubscriptionRewardsResult, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, type CouponDocument, CouponModel, EnumPubSubEvents, EventInfoModel, EventModel, GameModel, GoogleImportedMarketModel, type GraphQLContext, LicenceCategory, LicenceExpiryDate, NotificationModel, type NotificationPubSub, type ObjectId, OwnerTypeSchema, PartnerModel, PostModel, PushTokenModel, REMINDER_WINDOW_MAX_HOURS, REMINDER_WINDOW_MIN_HOURS, RelationModel, RelationTypeSchema, ResourceActivityModel, ResourceImageTypeSchema, SUBSCRIPTION_REWARD_TIMEZONE, type SchemaAffiliateResourceType, type SchemaAffiliateReward, type SchemaChatMessageReactionType, type SchemaChatMessageReplyPreviewType, type SchemaChatMessageSeenType, type SchemaChatMessageType, type SchemaChatReportType, type SchemaChatType, type SchemaCreateBulkNotificationInput, type SchemaEventInfoType, type SchemaEventType, type SchemaGameType, type SchemaGoogleImportedMarket, type SchemaNotificationType, type SchemaOwnerType, type SchemaParticipantType, type SchemaPartnerType, type SchemaPostType, type SchemaPushTokenType, type SchemaRelatedPostType, type SchemaRelationType, type SchemaUnregisteredVendorInvitationType, type SchemaUnregisteredVendorType, type SchemaUserActivityEvent, type SchemaUserType, type SchemaVendorInfoType, type SchemaVendorType, SchoolModel, SocialMediaTypeSchema, StallTypeSchema, type SubscriptionPayload, UnregisteredVendorModel, UserModel, VendorInfoModel, VendorModel, VerificationTokenModel, type VerificationTokenType, activeAffiliateCodeExists, awardAffiliateVendorSubscriptionRewards, baseResourceFields, buildLicenceExpiryPipeline, checkOwnerHasLicence, connectToDatabase, convertObjectIdsToStrings, createLicenceObject, dateTimeSchema, didRemoveAnyEventDates, ensureUserLicenseCompliance, eventLicences, findAffiliateByPromoCode, findEventOrImportedMarketById, getEventResourceInfo, getHighestLicenceForCategory, getLicenceCategory, getLicenceExpiryMode, getPartnerResourceInfo, getPayingEventStripeSubscriptionPlan, getPayingStripeSubscriptionPlan, getPayingVendorStripeSubscriptionPlan, getSubscriptionRewardPeriodBounds, getVendorResourceInfo, handleEventLicenceCompliance, handlePartnerLicenceCompliance, handleVendorLicenceCompliance, hasValidLicence, isStandardLicence, isValidObjectId, licenceCategoryMapping, licencePriority, locationGeoSchema, locationsSchema, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, partnerLicences, processLicenseReminder, processUserCompliance, processUserLicenseReminders, publishNotificationEvents, refundPolicySchema, relatedPostSchema, relationDatesSchema, remindUsersAboutLicenseExpiration, replaceUserLicenceWithObject, resourceRelationsSchema, saveNotificationsInDb, sendDeactivationNotification, sendLicenseReminder, sendPushNotifications, sendReminderSafely, socialShareResourceSchema, syncUserLicencesAfterExpiry, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, updateSingleDateTimeStatus, updateVendorBasedOnUserLicense, upgradeUserToLicence, userLicenseSchema, vendorLicences, vendorOwnerHasProLicence, vendorProductTypeSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -1108,6 +1108,19 @@ declare function getPartnerResourceInfo(userId: ObjectId, partnerId: ObjectId):
|
|
|
1108
1108
|
*/
|
|
1109
1109
|
declare function remindUsersAboutLicenseExpiration(): Promise<void>;
|
|
1110
1110
|
|
|
1111
|
+
/**
|
|
1112
|
+
* License expiration reminder window bounds.
|
|
1113
|
+
*
|
|
1114
|
+
* A licence qualifies for the "7 days before expiry" reminder when its expiry is
|
|
1115
|
+
* between {@link REMINDER_WINDOW_MIN_HOURS} and {@link REMINDER_WINDOW_MAX_HOURS}
|
|
1116
|
+
* away.
|
|
1117
|
+
*
|
|
1118
|
+
* Expressed in hours (derived from days) because dayjs rounds fractional "day"
|
|
1119
|
+
* adds: `now.add(6.5, "day")` becomes 7 days and `now.add(7.5, "day")` 8 days.
|
|
1120
|
+
*/
|
|
1121
|
+
declare const REMINDER_WINDOW_MIN_HOURS: number;
|
|
1122
|
+
declare const REMINDER_WINDOW_MAX_HOURS: number;
|
|
1123
|
+
|
|
1111
1124
|
/**
|
|
1112
1125
|
* Single source of truth for how a licence type is handled on expiry.
|
|
1113
1126
|
*
|
|
@@ -1224,4 +1237,4 @@ declare function checkOwnerHasLicence({ userId, resourceType, }: {
|
|
|
1224
1237
|
resourceType: EnumResourceType;
|
|
1225
1238
|
}): Promise<void>;
|
|
1226
1239
|
|
|
1227
|
-
export { ACTIVE_NOT_DELETED_FILTER, APP_SETTINGS_ID, AdModel, AffiliateModel, AppSettingModel, type AuthUser, type AwardAffiliateVendorSubscriptionRewardsResult, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, type CouponDocument, CouponModel, EnumPubSubEvents, EventInfoModel, EventModel, GameModel, GoogleImportedMarketModel, type GraphQLContext, LicenceCategory, LicenceExpiryDate, NotificationModel, type NotificationPubSub, type ObjectId, OwnerTypeSchema, PartnerModel, PostModel, PushTokenModel, RelationModel, RelationTypeSchema, ResourceActivityModel, ResourceImageTypeSchema, SUBSCRIPTION_REWARD_TIMEZONE, type SchemaAffiliateResourceType, type SchemaAffiliateReward, type SchemaChatMessageReactionType, type SchemaChatMessageReplyPreviewType, type SchemaChatMessageSeenType, type SchemaChatMessageType, type SchemaChatReportType, type SchemaChatType, type SchemaCreateBulkNotificationInput, type SchemaEventInfoType, type SchemaEventType, type SchemaGameType, type SchemaGoogleImportedMarket, type SchemaNotificationType, type SchemaOwnerType, type SchemaParticipantType, type SchemaPartnerType, type SchemaPostType, type SchemaPushTokenType, type SchemaRelatedPostType, type SchemaRelationType, type SchemaUnregisteredVendorInvitationType, type SchemaUnregisteredVendorType, type SchemaUserActivityEvent, type SchemaUserType, type SchemaVendorInfoType, type SchemaVendorType, SchoolModel, SocialMediaTypeSchema, StallTypeSchema, type SubscriptionPayload, UnregisteredVendorModel, UserModel, VendorInfoModel, VendorModel, VerificationTokenModel, type VerificationTokenType, activeAffiliateCodeExists, awardAffiliateVendorSubscriptionRewards, baseResourceFields, buildLicenceExpiryPipeline, checkOwnerHasLicence, connectToDatabase, convertObjectIdsToStrings, createLicenceObject, dateTimeSchema, didRemoveAnyEventDates, ensureUserLicenseCompliance, eventLicences, findAffiliateByPromoCode, findEventOrImportedMarketById, getEventResourceInfo, getHighestLicenceForCategory, getLicenceCategory, getLicenceExpiryMode, getPartnerResourceInfo, getPayingEventStripeSubscriptionPlan, getPayingStripeSubscriptionPlan, getPayingVendorStripeSubscriptionPlan, getSubscriptionRewardPeriodBounds, getVendorResourceInfo, handleEventLicenceCompliance, handlePartnerLicenceCompliance, handleVendorLicenceCompliance, hasValidLicence, isStandardLicence, isValidObjectId, licenceCategoryMapping, licencePriority, locationGeoSchema, locationsSchema, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, partnerLicences, processLicenseReminder, processUserCompliance, processUserLicenseReminders, publishNotificationEvents, refundPolicySchema, relatedPostSchema, relationDatesSchema, remindUsersAboutLicenseExpiration, replaceUserLicenceWithObject, resourceRelationsSchema, saveNotificationsInDb, sendDeactivationNotification, sendLicenseReminder, sendPushNotifications, sendReminderSafely, socialShareResourceSchema, syncUserLicencesAfterExpiry, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, updateSingleDateTimeStatus, updateVendorBasedOnUserLicense, upgradeUserToLicence, userLicenseSchema, vendorLicences, vendorOwnerHasProLicence, vendorProductTypeSchema };
|
|
1240
|
+
export { ACTIVE_NOT_DELETED_FILTER, APP_SETTINGS_ID, AdModel, AffiliateModel, AppSettingModel, type AuthUser, type AwardAffiliateVendorSubscriptionRewardsResult, CategorySchema, ChatModel, ChatReportModel, ContactDetailsSchema, type CouponDocument, CouponModel, EnumPubSubEvents, EventInfoModel, EventModel, GameModel, GoogleImportedMarketModel, type GraphQLContext, LicenceCategory, LicenceExpiryDate, NotificationModel, type NotificationPubSub, type ObjectId, OwnerTypeSchema, PartnerModel, PostModel, PushTokenModel, REMINDER_WINDOW_MAX_HOURS, REMINDER_WINDOW_MIN_HOURS, RelationModel, RelationTypeSchema, ResourceActivityModel, ResourceImageTypeSchema, SUBSCRIPTION_REWARD_TIMEZONE, type SchemaAffiliateResourceType, type SchemaAffiliateReward, type SchemaChatMessageReactionType, type SchemaChatMessageReplyPreviewType, type SchemaChatMessageSeenType, type SchemaChatMessageType, type SchemaChatReportType, type SchemaChatType, type SchemaCreateBulkNotificationInput, type SchemaEventInfoType, type SchemaEventType, type SchemaGameType, type SchemaGoogleImportedMarket, type SchemaNotificationType, type SchemaOwnerType, type SchemaParticipantType, type SchemaPartnerType, type SchemaPostType, type SchemaPushTokenType, type SchemaRelatedPostType, type SchemaRelationType, type SchemaUnregisteredVendorInvitationType, type SchemaUnregisteredVendorType, type SchemaUserActivityEvent, type SchemaUserType, type SchemaVendorInfoType, type SchemaVendorType, SchoolModel, SocialMediaTypeSchema, StallTypeSchema, type SubscriptionPayload, UnregisteredVendorModel, UserModel, VendorInfoModel, VendorModel, VerificationTokenModel, type VerificationTokenType, activeAffiliateCodeExists, awardAffiliateVendorSubscriptionRewards, baseResourceFields, buildLicenceExpiryPipeline, checkOwnerHasLicence, connectToDatabase, convertObjectIdsToStrings, createLicenceObject, dateTimeSchema, didRemoveAnyEventDates, ensureUserLicenseCompliance, eventLicences, findAffiliateByPromoCode, findEventOrImportedMarketById, getEventResourceInfo, getHighestLicenceForCategory, getLicenceCategory, getLicenceExpiryMode, getPartnerResourceInfo, getPayingEventStripeSubscriptionPlan, getPayingStripeSubscriptionPlan, getPayingVendorStripeSubscriptionPlan, getSubscriptionRewardPeriodBounds, getVendorResourceInfo, handleEventLicenceCompliance, handlePartnerLicenceCompliance, handleVendorLicenceCompliance, hasValidLicence, isStandardLicence, isValidObjectId, licenceCategoryMapping, licencePriority, locationGeoSchema, locationsSchema, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, partnerLicences, processLicenseReminder, processUserCompliance, processUserLicenseReminders, publishNotificationEvents, refundPolicySchema, relatedPostSchema, relationDatesSchema, remindUsersAboutLicenseExpiration, replaceUserLicenceWithObject, resourceRelationsSchema, saveNotificationsInDb, sendDeactivationNotification, sendLicenseReminder, sendPushNotifications, sendReminderSafely, socialShareResourceSchema, syncUserLicencesAfterExpiry, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, updateSingleDateTimeStatus, updateVendorBasedOnUserLicense, upgradeUserToLicence, userLicenseSchema, vendorLicences, vendorOwnerHasProLicence, vendorProductTypeSchema };
|
package/dist/index.mjs
CHANGED
|
@@ -9655,6 +9655,10 @@ async function getPartnerResourceInfo(userId, partnerId) {
|
|
|
9655
9655
|
// src/service/license/reminder/remindUsersAboutLicenseExpiration.ts
|
|
9656
9656
|
import dayjs12 from "dayjs";
|
|
9657
9657
|
|
|
9658
|
+
// src/service/license/reminder/reminderWindow.ts
|
|
9659
|
+
var REMINDER_WINDOW_MIN_HOURS = 6.5 * 24;
|
|
9660
|
+
var REMINDER_WINDOW_MAX_HOURS = 7.5 * 24;
|
|
9661
|
+
|
|
9658
9662
|
// src/service/license/reminder/utils.ts
|
|
9659
9663
|
import dayjs11 from "dayjs";
|
|
9660
9664
|
|
|
@@ -9716,8 +9720,8 @@ async function checkAndCreateNotification(payload) {
|
|
|
9716
9720
|
}
|
|
9717
9721
|
function isLicenseExpiringIn7Days(expiryDate, now) {
|
|
9718
9722
|
const expiry = dayjs11(expiryDate);
|
|
9719
|
-
const
|
|
9720
|
-
return
|
|
9723
|
+
const hoursUntilExpiry = expiry.diff(now, "hour", true);
|
|
9724
|
+
return hoursUntilExpiry >= REMINDER_WINDOW_MIN_HOURS && hoursUntilExpiry <= REMINDER_WINDOW_MAX_HOURS;
|
|
9721
9725
|
}
|
|
9722
9726
|
function getLicenseName(licenceType) {
|
|
9723
9727
|
return licenseNiceNames[licenceType] || licenceType;
|
|
@@ -9881,8 +9885,8 @@ async function processUserLicenseReminders(user, now) {
|
|
|
9881
9885
|
async function remindUsersAboutLicenseExpiration() {
|
|
9882
9886
|
const now = dayjs12();
|
|
9883
9887
|
console.log(`\u{1F50D} Checking for licenses expiring in 7 days at ${now.format()}`);
|
|
9884
|
-
const minExpiryDate = now.add(
|
|
9885
|
-
const maxExpiryDate = now.add(
|
|
9888
|
+
const minExpiryDate = now.add(REMINDER_WINDOW_MIN_HOURS, "hour").toDate();
|
|
9889
|
+
const maxExpiryDate = now.add(REMINDER_WINDOW_MAX_HOURS, "hour").toDate();
|
|
9886
9890
|
const users = await UserModel.find({
|
|
9887
9891
|
licences: {
|
|
9888
9892
|
$elemMatch: {
|
|
@@ -9939,6 +9943,8 @@ export {
|
|
|
9939
9943
|
PartnerModel,
|
|
9940
9944
|
PostModel,
|
|
9941
9945
|
PushTokenModel,
|
|
9946
|
+
REMINDER_WINDOW_MAX_HOURS,
|
|
9947
|
+
REMINDER_WINDOW_MIN_HOURS,
|
|
9942
9948
|
RelationModel,
|
|
9943
9949
|
RelationTypeSchema,
|
|
9944
9950
|
ResourceActivityModel,
|