@timardex/cluemart-server-shared 2.3.0 → 2.5.0
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-XGBC5DCX.mjs → chunk-T5TP2XMR.mjs} +67 -89
- package/dist/chunk-T5TP2XMR.mjs.map +1 -0
- package/dist/index.cjs +287 -311
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +36 -26
- package/dist/index.d.ts +36 -26
- package/dist/index.mjs +86 -103
- package/dist/index.mjs.map +1 -1
- package/dist/mongoose/index.cjs +150 -177
- package/dist/mongoose/index.cjs.map +1 -1
- package/dist/mongoose/index.d.mts +15 -12
- package/dist/mongoose/index.d.ts +15 -12
- package/dist/mongoose/index.mjs +3 -3
- package/dist/service/index.cjs +282 -302
- package/dist/service/index.cjs.map +1 -1
- package/dist/service/index.d.mts +22 -15
- package/dist/service/index.d.ts +22 -15
- package/dist/service/index.mjs +21 -16
- package/dist/service/index.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-XGBC5DCX.mjs.map +0 -1
package/dist/service/index.d.mts
CHANGED
|
@@ -34,13 +34,15 @@ type AwardAffiliateVendorSubscriptionRewardsResult = {
|
|
|
34
34
|
* `affiliateResources.resourceOwner.userId`
|
|
35
35
|
* - `affiliateResources.resourceOwner` has a non-expired Standard / Pro / Pro+ vendor licence
|
|
36
36
|
*
|
|
37
|
-
* Reward type follows the owner's highest valid licence + Stripe
|
|
38
|
-
* - Pro / Pro+ with
|
|
39
|
-
* - Pro / Pro+ without
|
|
37
|
+
* Reward type follows the owner's highest valid licence + Stripe subscription status:
|
|
38
|
+
* - Pro / Pro+ with Stripe (ACTIVE/TRIALING) → `ACTIVE_VENDOR_PRO_SUBSCRIPTION` (3 pts)
|
|
39
|
+
* - Pro / Pro+ without an eligible Stripe subscription → `ACTIVE_VENDOR_STANDARD_SUBSCRIPTION` (1 pt)
|
|
40
40
|
* - Standard → `ACTIVE_VENDOR_STANDARD_SUBSCRIPTION` (1 pt)
|
|
41
41
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
42
|
+
* Stripe eligibility requires a subscription ID and a vendor Pro / Pro+ plan,
|
|
43
|
+
* but not a future paid-through endDate. It does not establish paid licence access.
|
|
44
|
+
* Idempotent per affiliate + vendor + calendar month — a mid-month upgrade
|
|
45
|
+
* (Standard → Pro with an eligible Stripe subscription) affects the next month.
|
|
44
46
|
* On successful awards, sends the affiliate owner a single aggregated
|
|
45
47
|
* notification per run (best-effort).
|
|
46
48
|
*
|
|
@@ -84,8 +86,10 @@ declare const SUBSCRIPTION_REWARD_TIMEZONE = "Pacific/Auckland";
|
|
|
84
86
|
* Maps a vendor owner's highest valid vendor licence to a monthly subscription reward.
|
|
85
87
|
*
|
|
86
88
|
* Prefer Pro / Pro+ over Standard when both are valid.
|
|
87
|
-
* Pro / Pro+
|
|
88
|
-
*
|
|
89
|
+
* Pro / Pro+ yields the Pro reward when the owner has a Stripe subscription ID,
|
|
90
|
+
* a vendor Pro / Pro+ plan, and ACTIVE or TRIALING subscription status.
|
|
91
|
+
* A future paid-through endDate is not required for rewards; this does not
|
|
92
|
+
* establish paid access for licence compliance. Otherwise falls back to Standard.
|
|
89
93
|
* Returns `null` when no non-expired vendor licence applies.
|
|
90
94
|
*/
|
|
91
95
|
declare function mapVendorLicenceToSubscriptionRewardType(userId: ObjectId | string, now?: Date): Promise<EnumAffiliateRewardType | null>;
|
|
@@ -145,7 +149,9 @@ declare function saveNotificationsInDb(payload: SchemaCreateBulkNotificationInpu
|
|
|
145
149
|
declare function sendPushNotifications({ data, message, title, userIds, }: SchemaCreateBulkNotificationInput): Promise<void>;
|
|
146
150
|
|
|
147
151
|
/**
|
|
148
|
-
* Updates ad statuses based on start/end dates and validity
|
|
152
|
+
* Updates ad statuses based on start/end dates and validity.
|
|
153
|
+
* `start`/`end` are UTC-midnight NZ day keys, so comparisons run against
|
|
154
|
+
* today's NZ day key rather than the current instant.
|
|
149
155
|
*/
|
|
150
156
|
declare function updateAdStatuses(): Promise<void>;
|
|
151
157
|
|
|
@@ -314,11 +320,12 @@ declare function didRemoveAnyEventDates(previousDateTime: EventDateSlot[] | unde
|
|
|
314
320
|
declare function didRemoveAnyStartedDates(previousDateTime: StartedDateSlot[] | undefined, nextDateTime: StartedDateSlot[] | undefined): boolean;
|
|
315
321
|
/**
|
|
316
322
|
* Helper: Update relationDates based on event's dateTime
|
|
317
|
-
* Marks dates as
|
|
323
|
+
* Marks dates as CANCELED if they no longer exist in the event's dateTime.
|
|
318
324
|
*/
|
|
319
|
-
declare function
|
|
325
|
+
declare function updateRelationDatesToCanceled(relationDates: SchemaRelationType["relationDates"], eventDateTime: DateTimeWithPriceType[] | undefined): SchemaRelationType["relationDates"];
|
|
320
326
|
|
|
321
|
-
type
|
|
327
|
+
type StripeSubscriptionPlanResult = {
|
|
328
|
+
/** Meets the caller's eligibility policy; reward eligibility is not paid access. */
|
|
322
329
|
hasSubscription: boolean;
|
|
323
330
|
plan: EnumUserLicence | null;
|
|
324
331
|
validTypes: Set<EnumUserLicence>;
|
|
@@ -328,17 +335,17 @@ type PayingStripeSubscriptionPlanResult = {
|
|
|
328
335
|
* (event or vendor), the subscription is active, and its finite paid-through
|
|
329
336
|
* `endDate` is later than `now`. Status alone does not establish paid access.
|
|
330
337
|
*/
|
|
331
|
-
declare function getPayingStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<
|
|
338
|
+
declare function getPayingStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<StripeSubscriptionPlanResult>;
|
|
332
339
|
/**
|
|
333
340
|
* Like {@link getPayingStripeSubscriptionPlan} but only treats a vendor PRO
|
|
334
341
|
* plan (`PRO_VENDOR` / `PRO_PLUS_VENDOR`) as paying.
|
|
335
342
|
*/
|
|
336
|
-
declare function getPayingVendorStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<
|
|
343
|
+
declare function getPayingVendorStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<StripeSubscriptionPlanResult>;
|
|
337
344
|
/**
|
|
338
345
|
* Like {@link getPayingStripeSubscriptionPlan} but only treats an event PRO
|
|
339
346
|
* plan (`PRO_EVENT` / `PRO_PLUS_EVENT`) as paying.
|
|
340
347
|
*/
|
|
341
|
-
declare function getPayingEventStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<
|
|
348
|
+
declare function getPayingEventStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<StripeSubscriptionPlanResult>;
|
|
342
349
|
|
|
343
350
|
/**
|
|
344
351
|
* Runs the established compliance pipeline for one freshly loaded user.
|
|
@@ -593,4 +600,4 @@ declare function checkOwnerHasLicence({ userId, resourceType, }: {
|
|
|
593
600
|
resourceType: EnumResourceType;
|
|
594
601
|
}): Promise<void>;
|
|
595
602
|
|
|
596
|
-
export { ACTIVE_NOT_DELETED_FILTER, type AwardAffiliateVendorSubscriptionRewardsResult, LicenceCategory, type NotificationPubSub, REMINDER_WINDOW_MAX_HOURS, REMINDER_WINDOW_MIN_HOURS, SUBSCRIPTION_REWARD_TIMEZONE, activeAffiliateCodeExists, awardAffiliateVendorSubscriptionRewards, buildLicenceExpiryPipeline, buildUserHasEnoughPointsFilter, buildUserPointAwardEntry, buildUserPointCreditFilter, buildUserPointDebitPipeline, buildUserPointEntryRemovalPipeline, checkOwnerHasLicence, connectToDatabase, convertObjectIdsToStrings, createLicenceObject, dedupeArchivedSlotsByStartDateTime, didRemoveAnyEventDates, didRemoveAnyStartedDates, downgradeVendorProFeatures, ensureUserLicenseCompliance, ensureUserLicenseComplianceForUser, 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, persistArchivedEventDates, processLicenseReminder, processUserCompliance, processUserLicenseReminders, publishNotificationEvents, remindUsersAboutLicenseExpiration, replaceUserLicenceWithObject, restoreVendorProFeatures, saveNotificationsInDb, sendDeactivationNotification, sendLicenseReminder, sendPushNotifications, sendReminderSafely, splitEventDatesForArchive, syncUserLicencesAfterExpiry, updateAdStatuses, updateAllEventDateTimeStatuses,
|
|
603
|
+
export { ACTIVE_NOT_DELETED_FILTER, type AwardAffiliateVendorSubscriptionRewardsResult, LicenceCategory, type NotificationPubSub, REMINDER_WINDOW_MAX_HOURS, REMINDER_WINDOW_MIN_HOURS, SUBSCRIPTION_REWARD_TIMEZONE, activeAffiliateCodeExists, awardAffiliateVendorSubscriptionRewards, buildLicenceExpiryPipeline, buildUserHasEnoughPointsFilter, buildUserPointAwardEntry, buildUserPointCreditFilter, buildUserPointDebitPipeline, buildUserPointEntryRemovalPipeline, checkOwnerHasLicence, connectToDatabase, convertObjectIdsToStrings, createLicenceObject, dedupeArchivedSlotsByStartDateTime, didRemoveAnyEventDates, didRemoveAnyStartedDates, downgradeVendorProFeatures, ensureUserLicenseCompliance, ensureUserLicenseComplianceForUser, 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, persistArchivedEventDates, processLicenseReminder, processUserCompliance, processUserLicenseReminders, publishNotificationEvents, remindUsersAboutLicenseExpiration, replaceUserLicenceWithObject, restoreVendorProFeatures, saveNotificationsInDb, sendDeactivationNotification, sendLicenseReminder, sendPushNotifications, sendReminderSafely, splitEventDatesForArchive, syncUserLicencesAfterExpiry, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToCanceled, upgradeUserToLicence, vendorOwnerHasProLicence };
|
package/dist/service/index.d.ts
CHANGED
|
@@ -34,13 +34,15 @@ type AwardAffiliateVendorSubscriptionRewardsResult = {
|
|
|
34
34
|
* `affiliateResources.resourceOwner.userId`
|
|
35
35
|
* - `affiliateResources.resourceOwner` has a non-expired Standard / Pro / Pro+ vendor licence
|
|
36
36
|
*
|
|
37
|
-
* Reward type follows the owner's highest valid licence + Stripe
|
|
38
|
-
* - Pro / Pro+ with
|
|
39
|
-
* - Pro / Pro+ without
|
|
37
|
+
* Reward type follows the owner's highest valid licence + Stripe subscription status:
|
|
38
|
+
* - Pro / Pro+ with Stripe (ACTIVE/TRIALING) → `ACTIVE_VENDOR_PRO_SUBSCRIPTION` (3 pts)
|
|
39
|
+
* - Pro / Pro+ without an eligible Stripe subscription → `ACTIVE_VENDOR_STANDARD_SUBSCRIPTION` (1 pt)
|
|
40
40
|
* - Standard → `ACTIVE_VENDOR_STANDARD_SUBSCRIPTION` (1 pt)
|
|
41
41
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
42
|
+
* Stripe eligibility requires a subscription ID and a vendor Pro / Pro+ plan,
|
|
43
|
+
* but not a future paid-through endDate. It does not establish paid licence access.
|
|
44
|
+
* Idempotent per affiliate + vendor + calendar month — a mid-month upgrade
|
|
45
|
+
* (Standard → Pro with an eligible Stripe subscription) affects the next month.
|
|
44
46
|
* On successful awards, sends the affiliate owner a single aggregated
|
|
45
47
|
* notification per run (best-effort).
|
|
46
48
|
*
|
|
@@ -84,8 +86,10 @@ declare const SUBSCRIPTION_REWARD_TIMEZONE = "Pacific/Auckland";
|
|
|
84
86
|
* Maps a vendor owner's highest valid vendor licence to a monthly subscription reward.
|
|
85
87
|
*
|
|
86
88
|
* Prefer Pro / Pro+ over Standard when both are valid.
|
|
87
|
-
* Pro / Pro+
|
|
88
|
-
*
|
|
89
|
+
* Pro / Pro+ yields the Pro reward when the owner has a Stripe subscription ID,
|
|
90
|
+
* a vendor Pro / Pro+ plan, and ACTIVE or TRIALING subscription status.
|
|
91
|
+
* A future paid-through endDate is not required for rewards; this does not
|
|
92
|
+
* establish paid access for licence compliance. Otherwise falls back to Standard.
|
|
89
93
|
* Returns `null` when no non-expired vendor licence applies.
|
|
90
94
|
*/
|
|
91
95
|
declare function mapVendorLicenceToSubscriptionRewardType(userId: ObjectId | string, now?: Date): Promise<EnumAffiliateRewardType | null>;
|
|
@@ -145,7 +149,9 @@ declare function saveNotificationsInDb(payload: SchemaCreateBulkNotificationInpu
|
|
|
145
149
|
declare function sendPushNotifications({ data, message, title, userIds, }: SchemaCreateBulkNotificationInput): Promise<void>;
|
|
146
150
|
|
|
147
151
|
/**
|
|
148
|
-
* Updates ad statuses based on start/end dates and validity
|
|
152
|
+
* Updates ad statuses based on start/end dates and validity.
|
|
153
|
+
* `start`/`end` are UTC-midnight NZ day keys, so comparisons run against
|
|
154
|
+
* today's NZ day key rather than the current instant.
|
|
149
155
|
*/
|
|
150
156
|
declare function updateAdStatuses(): Promise<void>;
|
|
151
157
|
|
|
@@ -314,11 +320,12 @@ declare function didRemoveAnyEventDates(previousDateTime: EventDateSlot[] | unde
|
|
|
314
320
|
declare function didRemoveAnyStartedDates(previousDateTime: StartedDateSlot[] | undefined, nextDateTime: StartedDateSlot[] | undefined): boolean;
|
|
315
321
|
/**
|
|
316
322
|
* Helper: Update relationDates based on event's dateTime
|
|
317
|
-
* Marks dates as
|
|
323
|
+
* Marks dates as CANCELED if they no longer exist in the event's dateTime.
|
|
318
324
|
*/
|
|
319
|
-
declare function
|
|
325
|
+
declare function updateRelationDatesToCanceled(relationDates: SchemaRelationType["relationDates"], eventDateTime: DateTimeWithPriceType[] | undefined): SchemaRelationType["relationDates"];
|
|
320
326
|
|
|
321
|
-
type
|
|
327
|
+
type StripeSubscriptionPlanResult = {
|
|
328
|
+
/** Meets the caller's eligibility policy; reward eligibility is not paid access. */
|
|
322
329
|
hasSubscription: boolean;
|
|
323
330
|
plan: EnumUserLicence | null;
|
|
324
331
|
validTypes: Set<EnumUserLicence>;
|
|
@@ -328,17 +335,17 @@ type PayingStripeSubscriptionPlanResult = {
|
|
|
328
335
|
* (event or vendor), the subscription is active, and its finite paid-through
|
|
329
336
|
* `endDate` is later than `now`. Status alone does not establish paid access.
|
|
330
337
|
*/
|
|
331
|
-
declare function getPayingStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<
|
|
338
|
+
declare function getPayingStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<StripeSubscriptionPlanResult>;
|
|
332
339
|
/**
|
|
333
340
|
* Like {@link getPayingStripeSubscriptionPlan} but only treats a vendor PRO
|
|
334
341
|
* plan (`PRO_VENDOR` / `PRO_PLUS_VENDOR`) as paying.
|
|
335
342
|
*/
|
|
336
|
-
declare function getPayingVendorStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<
|
|
343
|
+
declare function getPayingVendorStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<StripeSubscriptionPlanResult>;
|
|
337
344
|
/**
|
|
338
345
|
* Like {@link getPayingStripeSubscriptionPlan} but only treats an event PRO
|
|
339
346
|
* plan (`PRO_EVENT` / `PRO_PLUS_EVENT`) as paying.
|
|
340
347
|
*/
|
|
341
|
-
declare function getPayingEventStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<
|
|
348
|
+
declare function getPayingEventStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<StripeSubscriptionPlanResult>;
|
|
342
349
|
|
|
343
350
|
/**
|
|
344
351
|
* Runs the established compliance pipeline for one freshly loaded user.
|
|
@@ -593,4 +600,4 @@ declare function checkOwnerHasLicence({ userId, resourceType, }: {
|
|
|
593
600
|
resourceType: EnumResourceType;
|
|
594
601
|
}): Promise<void>;
|
|
595
602
|
|
|
596
|
-
export { ACTIVE_NOT_DELETED_FILTER, type AwardAffiliateVendorSubscriptionRewardsResult, LicenceCategory, type NotificationPubSub, REMINDER_WINDOW_MAX_HOURS, REMINDER_WINDOW_MIN_HOURS, SUBSCRIPTION_REWARD_TIMEZONE, activeAffiliateCodeExists, awardAffiliateVendorSubscriptionRewards, buildLicenceExpiryPipeline, buildUserHasEnoughPointsFilter, buildUserPointAwardEntry, buildUserPointCreditFilter, buildUserPointDebitPipeline, buildUserPointEntryRemovalPipeline, checkOwnerHasLicence, connectToDatabase, convertObjectIdsToStrings, createLicenceObject, dedupeArchivedSlotsByStartDateTime, didRemoveAnyEventDates, didRemoveAnyStartedDates, downgradeVendorProFeatures, ensureUserLicenseCompliance, ensureUserLicenseComplianceForUser, 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, persistArchivedEventDates, processLicenseReminder, processUserCompliance, processUserLicenseReminders, publishNotificationEvents, remindUsersAboutLicenseExpiration, replaceUserLicenceWithObject, restoreVendorProFeatures, saveNotificationsInDb, sendDeactivationNotification, sendLicenseReminder, sendPushNotifications, sendReminderSafely, splitEventDatesForArchive, syncUserLicencesAfterExpiry, updateAdStatuses, updateAllEventDateTimeStatuses,
|
|
603
|
+
export { ACTIVE_NOT_DELETED_FILTER, type AwardAffiliateVendorSubscriptionRewardsResult, LicenceCategory, type NotificationPubSub, REMINDER_WINDOW_MAX_HOURS, REMINDER_WINDOW_MIN_HOURS, SUBSCRIPTION_REWARD_TIMEZONE, activeAffiliateCodeExists, awardAffiliateVendorSubscriptionRewards, buildLicenceExpiryPipeline, buildUserHasEnoughPointsFilter, buildUserPointAwardEntry, buildUserPointCreditFilter, buildUserPointDebitPipeline, buildUserPointEntryRemovalPipeline, checkOwnerHasLicence, connectToDatabase, convertObjectIdsToStrings, createLicenceObject, dedupeArchivedSlotsByStartDateTime, didRemoveAnyEventDates, didRemoveAnyStartedDates, downgradeVendorProFeatures, ensureUserLicenseCompliance, ensureUserLicenseComplianceForUser, 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, persistArchivedEventDates, processLicenseReminder, processUserCompliance, processUserLicenseReminders, publishNotificationEvents, remindUsersAboutLicenseExpiration, replaceUserLicenceWithObject, restoreVendorProFeatures, saveNotificationsInDb, sendDeactivationNotification, sendLicenseReminder, sendPushNotifications, sendReminderSafely, splitEventDatesForArchive, syncUserLicencesAfterExpiry, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToCanceled, upgradeUserToLicence, vendorOwnerHasProLicence };
|
package/dist/service/index.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
PushTokenModel,
|
|
11
11
|
UserModel,
|
|
12
12
|
VendorModel
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-T5TP2XMR.mjs";
|
|
14
14
|
import "../chunk-TMPPPLIW.mjs";
|
|
15
15
|
|
|
16
16
|
// src/service/promoCode/constants.ts
|
|
@@ -170,7 +170,8 @@ async function sendPushNotifications({
|
|
|
170
170
|
// src/service/affiliate/vendorSubscriptionRewards.ts
|
|
171
171
|
import {
|
|
172
172
|
EnumAffiliateRewardType,
|
|
173
|
-
EnumUserLicence as EnumUserLicence2
|
|
173
|
+
EnumUserLicence as EnumUserLicence2,
|
|
174
|
+
NZ_TZ
|
|
174
175
|
} from "@timardex/cluemart-shared";
|
|
175
176
|
import dayjs from "dayjs";
|
|
176
177
|
import timezone from "dayjs/plugin/timezone";
|
|
@@ -193,7 +194,7 @@ var PRO_PLANS = /* @__PURE__ */ new Set([
|
|
|
193
194
|
...PRO_EVENT_PLANS,
|
|
194
195
|
...PRO_VENDOR_PLANS
|
|
195
196
|
]);
|
|
196
|
-
async function
|
|
197
|
+
async function getStripePlanFor(userId, now, allowedPlans, requirePaidAccess = true) {
|
|
197
198
|
const user = await UserModel.findById(userId).select("licences stripe").lean().exec();
|
|
198
199
|
if (!user) {
|
|
199
200
|
return { hasSubscription: false, plan: null, validTypes: /* @__PURE__ */ new Set() };
|
|
@@ -208,30 +209,33 @@ async function getPayingStripePlanFor(userId, now, payingPlans) {
|
|
|
208
209
|
if (stripe == null || stripe.subscriptionId == null) {
|
|
209
210
|
return { hasSubscription: false, plan: null, validTypes };
|
|
210
211
|
}
|
|
211
|
-
const hasActiveStatus = stripe.status === EnumSubscriptionStatus.ACTIVE;
|
|
212
|
+
const hasActiveStatus = stripe.status === EnumSubscriptionStatus.ACTIVE || !requirePaidAccess && stripe.status === EnumSubscriptionStatus.TRIALING;
|
|
212
213
|
const paidThrough = stripe.endDate ? new Date(stripe.endDate).getTime() : Number.NaN;
|
|
213
|
-
if (!hasActiveStatus || !Number.isFinite(paidThrough) || paidThrough <= now.getTime() || stripe.currentPlan == null) {
|
|
214
|
+
if (!hasActiveStatus || requirePaidAccess && (!Number.isFinite(paidThrough) || paidThrough <= now.getTime()) || stripe.currentPlan == null) {
|
|
214
215
|
return { hasSubscription: false, plan: null, validTypes };
|
|
215
216
|
}
|
|
216
|
-
const plan =
|
|
217
|
+
const plan = allowedPlans.has(stripe.currentPlan) ? stripe.currentPlan : null;
|
|
217
218
|
return { hasSubscription: plan != null, plan, validTypes };
|
|
218
219
|
}
|
|
219
220
|
async function getPayingStripeSubscriptionPlan(userId, now = /* @__PURE__ */ new Date()) {
|
|
220
|
-
return
|
|
221
|
+
return getStripePlanFor(userId, now, PRO_PLANS);
|
|
221
222
|
}
|
|
222
223
|
async function getPayingVendorStripeSubscriptionPlan(userId, now = /* @__PURE__ */ new Date()) {
|
|
223
|
-
return
|
|
224
|
+
return getStripePlanFor(userId, now, PRO_VENDOR_PLANS);
|
|
225
|
+
}
|
|
226
|
+
async function getVendorStripeSubscriptionPlanForRewards(userId, now = /* @__PURE__ */ new Date()) {
|
|
227
|
+
return getStripePlanFor(userId, now, PRO_VENDOR_PLANS, false);
|
|
224
228
|
}
|
|
225
229
|
async function getPayingEventStripeSubscriptionPlan(userId, now = /* @__PURE__ */ new Date()) {
|
|
226
|
-
return
|
|
230
|
+
return getStripePlanFor(userId, now, PRO_EVENT_PLANS);
|
|
227
231
|
}
|
|
228
232
|
|
|
229
233
|
// src/service/affiliate/vendorSubscriptionRewards.ts
|
|
230
234
|
dayjs.extend(utc);
|
|
231
235
|
dayjs.extend(timezone);
|
|
232
|
-
var SUBSCRIPTION_REWARD_TIMEZONE =
|
|
236
|
+
var SUBSCRIPTION_REWARD_TIMEZONE = NZ_TZ;
|
|
233
237
|
async function mapVendorLicenceToSubscriptionRewardType(userId, now = /* @__PURE__ */ new Date()) {
|
|
234
|
-
const { hasSubscription, validTypes } = await
|
|
238
|
+
const { hasSubscription, validTypes } = await getVendorStripeSubscriptionPlanForRewards(userId, now);
|
|
235
239
|
if (validTypes.has(EnumUserLicence2.PRO_VENDOR) || validTypes.has(EnumUserLicence2.PRO_PLUS_VENDOR)) {
|
|
236
240
|
if (hasSubscription) {
|
|
237
241
|
return EnumAffiliateRewardType.ACTIVE_VENDOR_PRO_SUBSCRIPTION;
|
|
@@ -522,10 +526,11 @@ import {
|
|
|
522
526
|
EnumAdApprovalStatus,
|
|
523
527
|
EnumAdBookingSlotKind,
|
|
524
528
|
EnumAdPaymentStatus,
|
|
525
|
-
EnumAdStatus
|
|
529
|
+
EnumAdStatus,
|
|
530
|
+
nzDayKey
|
|
526
531
|
} from "@timardex/cluemart-shared";
|
|
527
532
|
async function updateAdStatuses() {
|
|
528
|
-
const now =
|
|
533
|
+
const now = nzDayKey();
|
|
529
534
|
const invalidResult = await AdModel.updateMany(
|
|
530
535
|
{
|
|
531
536
|
$or: [
|
|
@@ -1091,14 +1096,14 @@ function didRemoveAnyStartedDates(previousDateTime, nextDateTime) {
|
|
|
1091
1096
|
)
|
|
1092
1097
|
);
|
|
1093
1098
|
}
|
|
1094
|
-
function
|
|
1099
|
+
function updateRelationDatesToCanceled(relationDates, eventDateTime) {
|
|
1095
1100
|
return relationDates.map((relationDate) => {
|
|
1096
1101
|
const existsInEvent = eventDateTime?.some(
|
|
1097
1102
|
(dt) => dt.startDate === relationDate.dateTime.startDate && dt.startTime === relationDate.dateTime.startTime
|
|
1098
1103
|
) ?? false;
|
|
1099
1104
|
return {
|
|
1100
1105
|
...relationDate,
|
|
1101
|
-
status: existsInEvent ? relationDate.status : EnumInviteStatus.
|
|
1106
|
+
status: existsInEvent ? relationDate.status : EnumInviteStatus.CANCELED
|
|
1102
1107
|
};
|
|
1103
1108
|
});
|
|
1104
1109
|
}
|
|
@@ -2290,7 +2295,7 @@ export {
|
|
|
2290
2295
|
syncUserLicencesAfterExpiry,
|
|
2291
2296
|
updateAdStatuses,
|
|
2292
2297
|
updateAllEventDateTimeStatuses,
|
|
2293
|
-
|
|
2298
|
+
updateRelationDatesToCanceled,
|
|
2294
2299
|
updateSingleDateTimeStatus2 as updateSingleDateTimeStatus,
|
|
2295
2300
|
upgradeUserToLicence,
|
|
2296
2301
|
vendorOwnerHasProLicence
|