@timardex/cluemart-server-shared 1.1.33 → 1.1.34
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-WLOHVSV6.mjs → chunk-UGGLUJIR.mjs} +9 -5
- package/dist/chunk-UGGLUJIR.mjs.map +1 -0
- package/dist/index.cjs +29 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +7 -4
- package/dist/index.d.ts +7 -4
- package/dist/index.mjs +28 -19
- package/dist/index.mjs.map +1 -1
- package/dist/mongoose/index.cjs +8 -4
- package/dist/mongoose/index.cjs.map +1 -1
- package/dist/mongoose/index.mjs +1 -1
- package/dist/service/index.cjs +29 -19
- package/dist/service/index.cjs.map +1 -1
- package/dist/service/index.d.mts +7 -4
- package/dist/service/index.d.ts +7 -4
- package/dist/service/index.mjs +21 -16
- package/dist/service/index.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-WLOHVSV6.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -802,7 +802,7 @@ type AwardAffiliateVendorSubscriptionRewardsResult = {
|
|
|
802
802
|
* Awards monthly vendor subscription rewards to affiliates with active referred vendors.
|
|
803
803
|
*
|
|
804
804
|
* Eligibility per affiliate resource:
|
|
805
|
-
* - Affiliate is not soft-deleted
|
|
805
|
+
* - Affiliate is active and not soft-deleted
|
|
806
806
|
* - Linked `affiliateResources` entry is vendor, `resourceActive`, and not deleted
|
|
807
807
|
* - Vendor is active, not deleted, and `owner.userId` matches
|
|
808
808
|
* `affiliateResources.resourceOwner.userId`
|
|
@@ -813,7 +813,8 @@ type AwardAffiliateVendorSubscriptionRewardsResult = {
|
|
|
813
813
|
* - Pro / Pro+ without paying Stripe → `ACTIVE_VENDOR_STANDARD_SUBSCRIPTION` (1 pt)
|
|
814
814
|
* - Standard → `ACTIVE_VENDOR_STANDARD_SUBSCRIPTION` (1 pt)
|
|
815
815
|
*
|
|
816
|
-
* Idempotent per affiliate + vendor +
|
|
816
|
+
* Idempotent per affiliate + vendor + calendar month — a mid-month licence
|
|
817
|
+
* upgrade (Standard → paying Pro) takes effect from the following month.
|
|
817
818
|
* On successful award, notifies the affiliate owner (best-effort).
|
|
818
819
|
*
|
|
819
820
|
* @param now - Reference time for month bounds and licence expiry (defaults to now).
|
|
@@ -850,6 +851,8 @@ declare function findAffiliateByPromoCode(promoCode: PromoCodeType): Promise<(mo
|
|
|
850
851
|
*/
|
|
851
852
|
declare function normalizeAffiliatePromoCodes(promoCodes: PromoCodeType[] | null | undefined): PromoCodeType[];
|
|
852
853
|
|
|
854
|
+
/** Timezone the monthly reward window aligns to (matches the cron scheduler's `tz`). */
|
|
855
|
+
declare const SUBSCRIPTION_REWARD_TIMEZONE = "Pacific/Auckland";
|
|
853
856
|
/**
|
|
854
857
|
* Maps a vendor owner's highest valid vendor licence to a monthly subscription reward.
|
|
855
858
|
*
|
|
@@ -859,7 +862,7 @@ declare function normalizeAffiliatePromoCodes(promoCodes: PromoCodeType[] | null
|
|
|
859
862
|
* Returns `null` when no non-expired vendor licence applies.
|
|
860
863
|
*/
|
|
861
864
|
declare function mapVendorLicenceToSubscriptionRewardType(userId: ObjectId | string, now?: Date): Promise<EnumAffiliateRewardType | null>;
|
|
862
|
-
/** Inclusive start / exclusive end of the
|
|
865
|
+
/** Inclusive start / exclusive end of the {@link SUBSCRIPTION_REWARD_TIMEZONE} calendar month containing `now`. */
|
|
863
866
|
declare function getSubscriptionRewardPeriodBounds(now?: Date): {
|
|
864
867
|
periodEnd: Date;
|
|
865
868
|
periodStart: Date;
|
|
@@ -987,4 +990,4 @@ declare function getPayingVendorStripeSubscriptionPlan(userId: ObjectId | string
|
|
|
987
990
|
*/
|
|
988
991
|
declare function getPayingEventStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<PayingStripeSubscriptionPlanResult>;
|
|
989
992
|
|
|
990
|
-
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, NotificationModel, type NotificationPubSub, type ObjectId, OwnerTypeSchema, PartnerModel, PostModel, PushTokenModel, RelationModel, RelationTypeSchema, ResourceActivityModel, ResourceImageTypeSchema, 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, connectToDatabase, convertObjectIdsToStrings, dateTimeSchema, didRemoveAnyEventDates, findAffiliateByPromoCode, findEventOrImportedMarketById, getPayingEventStripeSubscriptionPlan, getPayingStripeSubscriptionPlan, getPayingVendorStripeSubscriptionPlan, getSubscriptionRewardPeriodBounds, isValidObjectId, locationGeoSchema, locationsSchema, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, publishNotificationEvents, refundPolicySchema, relatedPostSchema, relationDatesSchema, resourceRelationsSchema, saveNotificationsInDb, sendPushNotifications, socialShareResourceSchema, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, updateSingleDateTimeStatus, updateVendorBasedOnUserLicense, userLicenseSchema, vendorProductTypeSchema };
|
|
993
|
+
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, 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, connectToDatabase, convertObjectIdsToStrings, dateTimeSchema, didRemoveAnyEventDates, findAffiliateByPromoCode, findEventOrImportedMarketById, getPayingEventStripeSubscriptionPlan, getPayingStripeSubscriptionPlan, getPayingVendorStripeSubscriptionPlan, getSubscriptionRewardPeriodBounds, isValidObjectId, locationGeoSchema, locationsSchema, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, publishNotificationEvents, refundPolicySchema, relatedPostSchema, relationDatesSchema, resourceRelationsSchema, saveNotificationsInDb, sendPushNotifications, socialShareResourceSchema, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, updateSingleDateTimeStatus, updateVendorBasedOnUserLicense, userLicenseSchema, vendorProductTypeSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -802,7 +802,7 @@ type AwardAffiliateVendorSubscriptionRewardsResult = {
|
|
|
802
802
|
* Awards monthly vendor subscription rewards to affiliates with active referred vendors.
|
|
803
803
|
*
|
|
804
804
|
* Eligibility per affiliate resource:
|
|
805
|
-
* - Affiliate is not soft-deleted
|
|
805
|
+
* - Affiliate is active and not soft-deleted
|
|
806
806
|
* - Linked `affiliateResources` entry is vendor, `resourceActive`, and not deleted
|
|
807
807
|
* - Vendor is active, not deleted, and `owner.userId` matches
|
|
808
808
|
* `affiliateResources.resourceOwner.userId`
|
|
@@ -813,7 +813,8 @@ type AwardAffiliateVendorSubscriptionRewardsResult = {
|
|
|
813
813
|
* - Pro / Pro+ without paying Stripe → `ACTIVE_VENDOR_STANDARD_SUBSCRIPTION` (1 pt)
|
|
814
814
|
* - Standard → `ACTIVE_VENDOR_STANDARD_SUBSCRIPTION` (1 pt)
|
|
815
815
|
*
|
|
816
|
-
* Idempotent per affiliate + vendor +
|
|
816
|
+
* Idempotent per affiliate + vendor + calendar month — a mid-month licence
|
|
817
|
+
* upgrade (Standard → paying Pro) takes effect from the following month.
|
|
817
818
|
* On successful award, notifies the affiliate owner (best-effort).
|
|
818
819
|
*
|
|
819
820
|
* @param now - Reference time for month bounds and licence expiry (defaults to now).
|
|
@@ -850,6 +851,8 @@ declare function findAffiliateByPromoCode(promoCode: PromoCodeType): Promise<(mo
|
|
|
850
851
|
*/
|
|
851
852
|
declare function normalizeAffiliatePromoCodes(promoCodes: PromoCodeType[] | null | undefined): PromoCodeType[];
|
|
852
853
|
|
|
854
|
+
/** Timezone the monthly reward window aligns to (matches the cron scheduler's `tz`). */
|
|
855
|
+
declare const SUBSCRIPTION_REWARD_TIMEZONE = "Pacific/Auckland";
|
|
853
856
|
/**
|
|
854
857
|
* Maps a vendor owner's highest valid vendor licence to a monthly subscription reward.
|
|
855
858
|
*
|
|
@@ -859,7 +862,7 @@ declare function normalizeAffiliatePromoCodes(promoCodes: PromoCodeType[] | null
|
|
|
859
862
|
* Returns `null` when no non-expired vendor licence applies.
|
|
860
863
|
*/
|
|
861
864
|
declare function mapVendorLicenceToSubscriptionRewardType(userId: ObjectId | string, now?: Date): Promise<EnumAffiliateRewardType | null>;
|
|
862
|
-
/** Inclusive start / exclusive end of the
|
|
865
|
+
/** Inclusive start / exclusive end of the {@link SUBSCRIPTION_REWARD_TIMEZONE} calendar month containing `now`. */
|
|
863
866
|
declare function getSubscriptionRewardPeriodBounds(now?: Date): {
|
|
864
867
|
periodEnd: Date;
|
|
865
868
|
periodStart: Date;
|
|
@@ -987,4 +990,4 @@ declare function getPayingVendorStripeSubscriptionPlan(userId: ObjectId | string
|
|
|
987
990
|
*/
|
|
988
991
|
declare function getPayingEventStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<PayingStripeSubscriptionPlanResult>;
|
|
989
992
|
|
|
990
|
-
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, NotificationModel, type NotificationPubSub, type ObjectId, OwnerTypeSchema, PartnerModel, PostModel, PushTokenModel, RelationModel, RelationTypeSchema, ResourceActivityModel, ResourceImageTypeSchema, 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, connectToDatabase, convertObjectIdsToStrings, dateTimeSchema, didRemoveAnyEventDates, findAffiliateByPromoCode, findEventOrImportedMarketById, getPayingEventStripeSubscriptionPlan, getPayingStripeSubscriptionPlan, getPayingVendorStripeSubscriptionPlan, getSubscriptionRewardPeriodBounds, isValidObjectId, locationGeoSchema, locationsSchema, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, publishNotificationEvents, refundPolicySchema, relatedPostSchema, relationDatesSchema, resourceRelationsSchema, saveNotificationsInDb, sendPushNotifications, socialShareResourceSchema, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, updateSingleDateTimeStatus, updateVendorBasedOnUserLicense, userLicenseSchema, vendorProductTypeSchema };
|
|
993
|
+
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, 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, connectToDatabase, convertObjectIdsToStrings, dateTimeSchema, didRemoveAnyEventDates, findAffiliateByPromoCode, findEventOrImportedMarketById, getPayingEventStripeSubscriptionPlan, getPayingStripeSubscriptionPlan, getPayingVendorStripeSubscriptionPlan, getSubscriptionRewardPeriodBounds, isValidObjectId, locationGeoSchema, locationsSchema, mapVendorLicenceToSubscriptionRewardType, normalizeAffiliatePromoCodes, normalizePromoCode, notifyUsers, publishNotificationEvents, refundPolicySchema, relatedPostSchema, relationDatesSchema, resourceRelationsSchema, saveNotificationsInDb, sendPushNotifications, socialShareResourceSchema, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, updateSingleDateTimeStatus, updateVendorBasedOnUserLicense, userLicenseSchema, vendorProductTypeSchema };
|
package/dist/index.mjs
CHANGED
|
@@ -4775,7 +4775,7 @@ var registerFields = [
|
|
|
4775
4775
|
required: true
|
|
4776
4776
|
},
|
|
4777
4777
|
{
|
|
4778
|
-
helperText: "Enter Nickname",
|
|
4778
|
+
helperText: "Enter Nickname (optional)",
|
|
4779
4779
|
keyboardType: "default",
|
|
4780
4780
|
name: "nickName",
|
|
4781
4781
|
placeholder: "Nickname",
|
|
@@ -4832,16 +4832,18 @@ var profileFields = [
|
|
|
4832
4832
|
helperText: "Enter first name",
|
|
4833
4833
|
keyboardType: "default",
|
|
4834
4834
|
name: "firstName",
|
|
4835
|
-
placeholder: "First Name"
|
|
4835
|
+
placeholder: "First Name",
|
|
4836
|
+
required: true
|
|
4836
4837
|
},
|
|
4837
4838
|
{
|
|
4838
4839
|
helperText: "Enter last name",
|
|
4839
4840
|
keyboardType: "default",
|
|
4840
4841
|
name: "lastName",
|
|
4841
|
-
placeholder: "Last Name"
|
|
4842
|
+
placeholder: "Last Name",
|
|
4843
|
+
required: true
|
|
4842
4844
|
},
|
|
4843
4845
|
{
|
|
4844
|
-
helperText: "Enter Nickname",
|
|
4846
|
+
helperText: "Enter Nickname (optional)",
|
|
4845
4847
|
keyboardType: "default",
|
|
4846
4848
|
name: "nickName",
|
|
4847
4849
|
placeholder: "Nickname",
|
|
@@ -4852,6 +4854,7 @@ var profileFields = [
|
|
|
4852
4854
|
keyboardType: "default",
|
|
4853
4855
|
name: "password",
|
|
4854
4856
|
placeholder: "Password",
|
|
4857
|
+
required: true,
|
|
4855
4858
|
secureTextEntry: true
|
|
4856
4859
|
},
|
|
4857
4860
|
{
|
|
@@ -4859,6 +4862,7 @@ var profileFields = [
|
|
|
4859
4862
|
keyboardType: "default",
|
|
4860
4863
|
name: "confirmPassword",
|
|
4861
4864
|
placeholder: "Confirm Password",
|
|
4865
|
+
required: true,
|
|
4862
4866
|
secureTextEntry: true
|
|
4863
4867
|
}
|
|
4864
4868
|
];
|
|
@@ -11315,6 +11319,11 @@ async function sendPushNotifications({
|
|
|
11315
11319
|
}
|
|
11316
11320
|
}
|
|
11317
11321
|
|
|
11322
|
+
// src/service/affiliate/vendorSubscriptionRewards.ts
|
|
11323
|
+
import dayjs5 from "dayjs";
|
|
11324
|
+
import timezone3 from "dayjs/plugin/timezone";
|
|
11325
|
+
import utc3 from "dayjs/plugin/utc";
|
|
11326
|
+
|
|
11318
11327
|
// src/service/license.ts
|
|
11319
11328
|
var PRO_EVENT_PLANS = /* @__PURE__ */ new Set([
|
|
11320
11329
|
EnumUserLicence2.PRO_EVENT,
|
|
@@ -11361,6 +11370,9 @@ async function getPayingEventStripeSubscriptionPlan(userId, now = /* @__PURE__ *
|
|
|
11361
11370
|
}
|
|
11362
11371
|
|
|
11363
11372
|
// src/service/affiliate/vendorSubscriptionRewards.ts
|
|
11373
|
+
dayjs5.extend(utc3);
|
|
11374
|
+
dayjs5.extend(timezone3);
|
|
11375
|
+
var SUBSCRIPTION_REWARD_TIMEZONE = "Pacific/Auckland";
|
|
11364
11376
|
async function mapVendorLicenceToSubscriptionRewardType(userId, now = /* @__PURE__ */ new Date()) {
|
|
11365
11377
|
const { hasSubscription, validTypes } = await getPayingVendorStripeSubscriptionPlan(userId, now);
|
|
11366
11378
|
if (validTypes.has(EnumUserLicence.PRO_VENDOR) || validTypes.has(EnumUserLicence.PRO_PLUS_VENDOR)) {
|
|
@@ -11375,12 +11387,8 @@ async function mapVendorLicenceToSubscriptionRewardType(userId, now = /* @__PURE
|
|
|
11375
11387
|
return null;
|
|
11376
11388
|
}
|
|
11377
11389
|
function getSubscriptionRewardPeriodBounds(now = /* @__PURE__ */ new Date()) {
|
|
11378
|
-
const periodStart =
|
|
11379
|
-
|
|
11380
|
-
);
|
|
11381
|
-
const periodEnd = new Date(
|
|
11382
|
-
Date.UTC(now.getUTCFullYear(), now.getUTCMonth() + 1, 1)
|
|
11383
|
-
);
|
|
11390
|
+
const periodStart = dayjs5(now).tz(SUBSCRIPTION_REWARD_TIMEZONE).startOf("month").toDate();
|
|
11391
|
+
const periodEnd = dayjs5(now).tz(SUBSCRIPTION_REWARD_TIMEZONE).startOf("month").add(1, "month").toDate();
|
|
11384
11392
|
return { periodEnd, periodStart };
|
|
11385
11393
|
}
|
|
11386
11394
|
|
|
@@ -11390,6 +11398,7 @@ function isEligibleVendorResource(resource) {
|
|
|
11390
11398
|
}
|
|
11391
11399
|
async function findAffiliatesWithActiveVendorReferrals() {
|
|
11392
11400
|
return await AffiliateModel.find({
|
|
11401
|
+
active: true,
|
|
11393
11402
|
affiliateResources: {
|
|
11394
11403
|
$elemMatch: {
|
|
11395
11404
|
resourceActive: true,
|
|
@@ -11462,8 +11471,7 @@ async function tryAwardSubscriptionReward({
|
|
|
11462
11471
|
createdAt: {
|
|
11463
11472
|
$gte: period.periodStart,
|
|
11464
11473
|
$lt: period.periodEnd
|
|
11465
|
-
}
|
|
11466
|
-
rewardType
|
|
11474
|
+
}
|
|
11467
11475
|
}
|
|
11468
11476
|
}
|
|
11469
11477
|
}
|
|
@@ -11755,11 +11763,11 @@ function convertObjectIdsToStrings(obj) {
|
|
|
11755
11763
|
}
|
|
11756
11764
|
|
|
11757
11765
|
// src/service/event/updateAllEventDateTimeStatuses.ts
|
|
11758
|
-
import
|
|
11766
|
+
import dayjs6 from "dayjs";
|
|
11759
11767
|
import customParseFormat3 from "dayjs/plugin/customParseFormat";
|
|
11760
11768
|
import isoWeek from "dayjs/plugin/isoWeek";
|
|
11761
|
-
|
|
11762
|
-
|
|
11769
|
+
dayjs6.extend(customParseFormat3);
|
|
11770
|
+
dayjs6.extend(isoWeek);
|
|
11763
11771
|
function getFutureEventStatus(startDateTime, now) {
|
|
11764
11772
|
const hoursUntilStart = startDateTime.diff(now, "hour", true);
|
|
11765
11773
|
if (hoursUntilStart > 0 && hoursUntilStart <= 4) {
|
|
@@ -11779,14 +11787,14 @@ function getFutureEventStatus(startDateTime, now) {
|
|
|
11779
11787
|
}
|
|
11780
11788
|
return EnumEventDateStatus.UPCOMING;
|
|
11781
11789
|
}
|
|
11782
|
-
function updateSingleDateTimeStatus(dateTime, now =
|
|
11790
|
+
function updateSingleDateTimeStatus(dateTime, now = dayjs6()) {
|
|
11783
11791
|
const dateTimeFormat = `${dateFormat} ${timeFormat}`;
|
|
11784
|
-
const startDateTime =
|
|
11792
|
+
const startDateTime = dayjs6(
|
|
11785
11793
|
`${dateTime.startDate} ${dateTime.startTime}`,
|
|
11786
11794
|
dateTimeFormat,
|
|
11787
11795
|
true
|
|
11788
11796
|
);
|
|
11789
|
-
const endDateTime =
|
|
11797
|
+
const endDateTime = dayjs6(
|
|
11790
11798
|
`${dateTime.endDate} ${dateTime.endTime}`,
|
|
11791
11799
|
dateTimeFormat,
|
|
11792
11800
|
true
|
|
@@ -11868,7 +11876,7 @@ async function updateModelDateTimeStatuses(model, now) {
|
|
|
11868
11876
|
return updated;
|
|
11869
11877
|
}
|
|
11870
11878
|
async function updateAllEventDateTimeStatuses() {
|
|
11871
|
-
const now =
|
|
11879
|
+
const now = dayjs6();
|
|
11872
11880
|
const [eventCount, marketCount] = await Promise.all([
|
|
11873
11881
|
updateModelDateTimeStatuses(EventModel, now),
|
|
11874
11882
|
updateModelDateTimeStatuses(
|
|
@@ -11941,6 +11949,7 @@ export {
|
|
|
11941
11949
|
RelationTypeSchema,
|
|
11942
11950
|
ResourceActivityModel,
|
|
11943
11951
|
ResourceImageTypeSchema,
|
|
11952
|
+
SUBSCRIPTION_REWARD_TIMEZONE,
|
|
11944
11953
|
SchoolModel,
|
|
11945
11954
|
SocialMediaTypeSchema,
|
|
11946
11955
|
StallTypeSchema,
|