@timardex/cluemart-server-shared 1.1.36 → 1.1.38
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-DBGVZNUX.mjs → chunk-DJHOLZ3J.mjs} +9 -1
- package/dist/chunk-DJHOLZ3J.mjs.map +1 -0
- package/dist/index.cjs +23 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +16 -3
- package/dist/index.d.ts +16 -3
- package/dist/index.mjs +21 -7
- package/dist/index.mjs.map +1 -1
- package/dist/mongoose/index.cjs +8 -0
- package/dist/mongoose/index.cjs.map +1 -1
- package/dist/mongoose/index.mjs +1 -1
- package/dist/service/index.cjs +23 -7
- package/dist/service/index.cjs.map +1 -1
- package/dist/service/index.d.mts +16 -3
- package/dist/service/index.d.ts +16 -3
- package/dist/service/index.mjs +14 -8
- package/dist/service/index.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-DBGVZNUX.mjs.map +0 -1
package/dist/service/index.d.mts
CHANGED
|
@@ -169,14 +169,14 @@ declare function updateSingleDateTimeStatus<T extends DateTimeType>(dateTime: T,
|
|
|
169
169
|
*/
|
|
170
170
|
declare function updateAllEventDateTimeStatuses(): Promise<void>;
|
|
171
171
|
|
|
172
|
-
type EventOrMarket = Pick<EventListItemType, "_id" | "name"> | null;
|
|
172
|
+
type EventOrMarket = Pick<EventListItemType, "_id" | "name" | "dateTime"> | null;
|
|
173
173
|
/**
|
|
174
174
|
* This function attempts to find an Event or a Google Imported Market by the given resource ID.
|
|
175
175
|
* It first normalizes the resource ID to a string format, then performs parallel queries to both collections.
|
|
176
176
|
* If an Event is found, it returns that; otherwise, it checks for a Google Imported Market and returns it if found.
|
|
177
177
|
* If neither is found, it returns null.
|
|
178
178
|
* @param resourceId - The ID of the resource to find, which can be an ObjectId, string, null, or undefined.
|
|
179
|
-
* @returns A promise that resolves to either an Event or a Google Imported Market object containing _id and
|
|
179
|
+
* @returns A promise that resolves to either an Event or a Google Imported Market object containing _id, name, and dateTime, or null if not found.
|
|
180
180
|
*/
|
|
181
181
|
declare function findEventOrImportedMarketById(resourceId: ObjectId | string | null | undefined): Promise<EventOrMarket>;
|
|
182
182
|
|
|
@@ -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 };
|
package/dist/service/index.d.ts
CHANGED
|
@@ -169,14 +169,14 @@ declare function updateSingleDateTimeStatus<T extends DateTimeType>(dateTime: T,
|
|
|
169
169
|
*/
|
|
170
170
|
declare function updateAllEventDateTimeStatuses(): Promise<void>;
|
|
171
171
|
|
|
172
|
-
type EventOrMarket = Pick<EventListItemType, "_id" | "name"> | null;
|
|
172
|
+
type EventOrMarket = Pick<EventListItemType, "_id" | "name" | "dateTime"> | null;
|
|
173
173
|
/**
|
|
174
174
|
* This function attempts to find an Event or a Google Imported Market by the given resource ID.
|
|
175
175
|
* It first normalizes the resource ID to a string format, then performs parallel queries to both collections.
|
|
176
176
|
* If an Event is found, it returns that; otherwise, it checks for a Google Imported Market and returns it if found.
|
|
177
177
|
* If neither is found, it returns null.
|
|
178
178
|
* @param resourceId - The ID of the resource to find, which can be an ObjectId, string, null, or undefined.
|
|
179
|
-
* @returns A promise that resolves to either an Event or a Google Imported Market object containing _id and
|
|
179
|
+
* @returns A promise that resolves to either an Event or a Google Imported Market object containing _id, name, and dateTime, or null if not found.
|
|
180
180
|
*/
|
|
181
181
|
declare function findEventOrImportedMarketById(resourceId: ObjectId | string | null | undefined): Promise<EventOrMarket>;
|
|
182
182
|
|
|
@@ -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 };
|
package/dist/service/index.mjs
CHANGED
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
isNonVisitorResourceType,
|
|
27
27
|
licenseNiceNames,
|
|
28
28
|
timeFormat
|
|
29
|
-
} from "../chunk-
|
|
29
|
+
} from "../chunk-DJHOLZ3J.mjs";
|
|
30
30
|
import "../chunk-6PNG5BI5.mjs";
|
|
31
31
|
|
|
32
32
|
// src/service/promoCode/constants.ts
|
|
@@ -229,7 +229,7 @@ var gameScreenIdentifierList = [
|
|
|
229
229
|
}
|
|
230
230
|
];
|
|
231
231
|
|
|
232
|
-
// node_modules/@timardex/cluemart-shared/dist/chunk-
|
|
232
|
+
// node_modules/@timardex/cluemart-shared/dist/chunk-RCARDOVS.mjs
|
|
233
233
|
import dayjs2 from "dayjs";
|
|
234
234
|
var statusOptions = [
|
|
235
235
|
...Object.values(EnumInviteStatus2).map((status) => ({
|
|
@@ -1932,8 +1932,8 @@ async function findEventOrImportedMarketById(resourceId) {
|
|
|
1932
1932
|
}
|
|
1933
1933
|
const normalizedId = convertObjectIdsToStrings(resourceId);
|
|
1934
1934
|
const [eventDoc, googleImportedDoc] = await Promise.all([
|
|
1935
|
-
EventModel.findById(normalizedId).select("_id name").lean().exec(),
|
|
1936
|
-
GoogleImportedMarketModel.findById(normalizedId).select("_id name").lean().exec()
|
|
1935
|
+
EventModel.findById(normalizedId).select("_id name dateTime").lean().exec(),
|
|
1936
|
+
GoogleImportedMarketModel.findById(normalizedId).select("_id name dateTime").lean().exec()
|
|
1937
1937
|
]);
|
|
1938
1938
|
return eventDoc ?? googleImportedDoc;
|
|
1939
1939
|
}
|
|
@@ -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
|
|
2725
|
-
return
|
|
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(
|
|
2890
|
-
const maxExpiryDate = now.add(
|
|
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,
|