@timardex/cluemart-server-shared 1.1.23 → 1.1.24
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-6LIZONJ6.mjs → chunk-YILYRHDN.mjs} +28 -6
- package/dist/chunk-YILYRHDN.mjs.map +1 -0
- package/dist/index.cjs +82 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +24 -2
- package/dist/index.d.ts +24 -2
- package/dist/index.mjs +79 -26
- package/dist/index.mjs.map +1 -1
- package/dist/mongoose/index.cjs +4 -4
- package/dist/mongoose/index.cjs.map +1 -1
- package/dist/mongoose/index.mjs +1 -1
- package/dist/service/index.cjs +82 -26
- package/dist/service/index.cjs.map +1 -1
- package/dist/service/index.d.mts +26 -4
- package/dist/service/index.d.ts +26 -4
- package/dist/service/index.mjs +56 -23
- package/dist/service/index.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-6LIZONJ6.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -7,6 +7,7 @@ import { NotificationCount, DateTimeType as DateTimeType$1 } from '@timardex/clu
|
|
|
7
7
|
import express from 'express';
|
|
8
8
|
export { default as express } from 'express';
|
|
9
9
|
import dayjs from 'dayjs';
|
|
10
|
+
import { EnumUserLicence as EnumUserLicence$1 } from '@timardex/cluemart-shared/enums';
|
|
10
11
|
|
|
11
12
|
declare const AdModel: mongoose__default.Model<AdType, {}, {}, {}, mongoose__default.Document<unknown, {}, AdType, {}, {}> & AdType & Required<{
|
|
12
13
|
_id: string;
|
|
@@ -873,7 +874,7 @@ declare function normalizeAffiliatePromoCodes(promoCodes: PromoCodeType[] | null
|
|
|
873
874
|
* otherwise falls back to the Standard subscription reward.
|
|
874
875
|
* Returns `null` when no non-expired vendor licence applies.
|
|
875
876
|
*/
|
|
876
|
-
declare function mapVendorLicenceToSubscriptionRewardType(
|
|
877
|
+
declare function mapVendorLicenceToSubscriptionRewardType(userId: ObjectId | string, now?: Date): Promise<EnumAffiliateRewardType | null>;
|
|
877
878
|
/** Inclusive start / exclusive end of the UTC calendar month containing `now`. */
|
|
878
879
|
declare function getSubscriptionRewardPeriodBounds(now?: Date): {
|
|
879
880
|
periodEnd: Date;
|
|
@@ -981,4 +982,25 @@ declare function didRemoveAnyEventDates(previousDateTime: EventDateSlot[] | unde
|
|
|
981
982
|
*/
|
|
982
983
|
declare function updateRelationDatesToUnavailable(relationDates: SchemaRelationType["relationDates"], eventDateTime: DateTimeWithPriceType[] | undefined): SchemaRelationType["relationDates"];
|
|
983
984
|
|
|
984
|
-
|
|
985
|
+
type PayingStripeSubscriptionPlanResult = {
|
|
986
|
+
hasSubscription: boolean;
|
|
987
|
+
plan: EnumUserLicence$1 | null;
|
|
988
|
+
validTypes: Set<EnumUserLicence$1>;
|
|
989
|
+
};
|
|
990
|
+
/**
|
|
991
|
+
* Returns the paying Stripe plan when `currentPlan` is any PRO plan
|
|
992
|
+
* (event or vendor) and the subscription is active/trialing.
|
|
993
|
+
*/
|
|
994
|
+
declare function getPayingStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<PayingStripeSubscriptionPlanResult>;
|
|
995
|
+
/**
|
|
996
|
+
* Like {@link getPayingStripeSubscriptionPlan} but only treats a vendor PRO
|
|
997
|
+
* plan (`PRO_VENDOR` / `PRO_PLUS_VENDOR`) as paying.
|
|
998
|
+
*/
|
|
999
|
+
declare function getPayingVendorStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<PayingStripeSubscriptionPlanResult>;
|
|
1000
|
+
/**
|
|
1001
|
+
* Like {@link getPayingStripeSubscriptionPlan} but only treats an event PRO
|
|
1002
|
+
* plan (`PRO_EVENT` / `PRO_PLUS_EVENT`) as paying.
|
|
1003
|
+
*/
|
|
1004
|
+
declare function getPayingEventStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<PayingStripeSubscriptionPlanResult>;
|
|
1005
|
+
|
|
1006
|
+
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, productCouponSchema, publishNotificationEvents, refundPolicySchema, relatedPostSchema, relationDatesSchema, resourceRelationsSchema, saveNotificationsInDb, sendPushNotifications, socialShareResourceSchema, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, updateSingleDateTimeStatus, updateVendorBasedOnUserLicense, userLicenseSchema, vendorProductTypeSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { NotificationCount, DateTimeType as DateTimeType$1 } from '@timardex/clu
|
|
|
7
7
|
import express from 'express';
|
|
8
8
|
export { default as express } from 'express';
|
|
9
9
|
import dayjs from 'dayjs';
|
|
10
|
+
import { EnumUserLicence as EnumUserLicence$1 } from '@timardex/cluemart-shared/enums';
|
|
10
11
|
|
|
11
12
|
declare const AdModel: mongoose__default.Model<AdType, {}, {}, {}, mongoose__default.Document<unknown, {}, AdType, {}, {}> & AdType & Required<{
|
|
12
13
|
_id: string;
|
|
@@ -873,7 +874,7 @@ declare function normalizeAffiliatePromoCodes(promoCodes: PromoCodeType[] | null
|
|
|
873
874
|
* otherwise falls back to the Standard subscription reward.
|
|
874
875
|
* Returns `null` when no non-expired vendor licence applies.
|
|
875
876
|
*/
|
|
876
|
-
declare function mapVendorLicenceToSubscriptionRewardType(
|
|
877
|
+
declare function mapVendorLicenceToSubscriptionRewardType(userId: ObjectId | string, now?: Date): Promise<EnumAffiliateRewardType | null>;
|
|
877
878
|
/** Inclusive start / exclusive end of the UTC calendar month containing `now`. */
|
|
878
879
|
declare function getSubscriptionRewardPeriodBounds(now?: Date): {
|
|
879
880
|
periodEnd: Date;
|
|
@@ -981,4 +982,25 @@ declare function didRemoveAnyEventDates(previousDateTime: EventDateSlot[] | unde
|
|
|
981
982
|
*/
|
|
982
983
|
declare function updateRelationDatesToUnavailable(relationDates: SchemaRelationType["relationDates"], eventDateTime: DateTimeWithPriceType[] | undefined): SchemaRelationType["relationDates"];
|
|
983
984
|
|
|
984
|
-
|
|
985
|
+
type PayingStripeSubscriptionPlanResult = {
|
|
986
|
+
hasSubscription: boolean;
|
|
987
|
+
plan: EnumUserLicence$1 | null;
|
|
988
|
+
validTypes: Set<EnumUserLicence$1>;
|
|
989
|
+
};
|
|
990
|
+
/**
|
|
991
|
+
* Returns the paying Stripe plan when `currentPlan` is any PRO plan
|
|
992
|
+
* (event or vendor) and the subscription is active/trialing.
|
|
993
|
+
*/
|
|
994
|
+
declare function getPayingStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<PayingStripeSubscriptionPlanResult>;
|
|
995
|
+
/**
|
|
996
|
+
* Like {@link getPayingStripeSubscriptionPlan} but only treats a vendor PRO
|
|
997
|
+
* plan (`PRO_VENDOR` / `PRO_PLUS_VENDOR`) as paying.
|
|
998
|
+
*/
|
|
999
|
+
declare function getPayingVendorStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<PayingStripeSubscriptionPlanResult>;
|
|
1000
|
+
/**
|
|
1001
|
+
* Like {@link getPayingStripeSubscriptionPlan} but only treats an event PRO
|
|
1002
|
+
* plan (`PRO_EVENT` / `PRO_PLUS_EVENT`) as paying.
|
|
1003
|
+
*/
|
|
1004
|
+
declare function getPayingEventStripeSubscriptionPlan(userId: ObjectId | string, now?: Date): Promise<PayingStripeSubscriptionPlanResult>;
|
|
1005
|
+
|
|
1006
|
+
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, productCouponSchema, publishNotificationEvents, refundPolicySchema, relatedPostSchema, relationDatesSchema, resourceRelationsSchema, saveNotificationsInDb, sendPushNotifications, socialShareResourceSchema, termsAgreementSchema, updateAdStatuses, updateAllEventDateTimeStatuses, updateRelationDatesToUnavailable, updateSingleDateTimeStatus, updateVendorBasedOnUserLicense, userLicenseSchema, vendorProductTypeSchema };
|
package/dist/index.mjs
CHANGED
|
@@ -3393,17 +3393,17 @@ var gameScreenIdentifierList = [
|
|
|
3393
3393
|
{
|
|
3394
3394
|
clue: "Where your actions turn into a timeline.",
|
|
3395
3395
|
id: "activities",
|
|
3396
|
-
match: "/profile/
|
|
3396
|
+
match: "/profile/account/favourites"
|
|
3397
3397
|
},
|
|
3398
3398
|
{
|
|
3399
3399
|
clue: "Where conversations happen without speaking.",
|
|
3400
3400
|
id: "chat",
|
|
3401
|
-
match: "/
|
|
3401
|
+
match: "/chat"
|
|
3402
3402
|
},
|
|
3403
3403
|
{
|
|
3404
3404
|
clue: "The place to redefine who you are.",
|
|
3405
3405
|
id: "edit-profile",
|
|
3406
|
-
match: "/profile/
|
|
3406
|
+
match: "/profile/account"
|
|
3407
3407
|
},
|
|
3408
3408
|
{
|
|
3409
3409
|
clue: "A single moment worth showing up for.",
|
|
@@ -3581,8 +3581,8 @@ var EnumActivity = /* @__PURE__ */ ((EnumActivity2) => {
|
|
|
3581
3581
|
return EnumActivity2;
|
|
3582
3582
|
})(EnumActivity || {});
|
|
3583
3583
|
var EnumPostType = /* @__PURE__ */ ((EnumPostType2) => {
|
|
3584
|
-
EnumPostType2["MARKET_FACES"] = "market_faces";
|
|
3585
3584
|
EnumPostType2["CLUE_BITES"] = "clue_bites";
|
|
3585
|
+
EnumPostType2["MARKET_FACES"] = "market_faces";
|
|
3586
3586
|
EnumPostType2["PLAY_AND_WIN"] = "play_and_win";
|
|
3587
3587
|
return EnumPostType2;
|
|
3588
3588
|
})(EnumPostType || {});
|
|
@@ -8761,6 +8761,18 @@ var EnumRegions2 = /* @__PURE__ */ ((EnumRegions22) => {
|
|
|
8761
8761
|
EnumRegions22["Wellington"] = "Wellington";
|
|
8762
8762
|
return EnumRegions22;
|
|
8763
8763
|
})(EnumRegions2 || {});
|
|
8764
|
+
var EnumUserLicence2 = /* @__PURE__ */ ((EnumUserLicence22) => {
|
|
8765
|
+
EnumUserLicence22["PRO_EVENT"] = "pro_event";
|
|
8766
|
+
EnumUserLicence22["PRO_PLUS_EVENT"] = "pro_plus_event";
|
|
8767
|
+
EnumUserLicence22["PRO_PLUS_VENDOR"] = "pro_plus_vendor";
|
|
8768
|
+
EnumUserLicence22["PRO_VENDOR"] = "pro_vendor";
|
|
8769
|
+
EnumUserLicence22["STANDARD_EVENT"] = "standard_event";
|
|
8770
|
+
EnumUserLicence22["STANDARD_VENDOR"] = "standard_vendor";
|
|
8771
|
+
EnumUserLicence22["STANDARD_PARTNER"] = "standard_partner";
|
|
8772
|
+
EnumUserLicence22["STANDARD_AFFILIATE"] = "standard_affiliate";
|
|
8773
|
+
EnumUserLicence22["STANDARD_SCHOOL"] = "standard_school";
|
|
8774
|
+
return EnumUserLicence22;
|
|
8775
|
+
})(EnumUserLicence2 || {});
|
|
8764
8776
|
var EnumEventDateStatus2 = /* @__PURE__ */ ((EnumEventDateStatus22) => {
|
|
8765
8777
|
EnumEventDateStatus22["STARTING_SOON"] = "Starting_Soon";
|
|
8766
8778
|
EnumEventDateStatus22["STARTED"] = "Started";
|
|
@@ -8775,6 +8787,15 @@ var EnumEventDateStatus2 = /* @__PURE__ */ ((EnumEventDateStatus22) => {
|
|
|
8775
8787
|
EnumEventDateStatus22["INVALID"] = "Invalid";
|
|
8776
8788
|
return EnumEventDateStatus22;
|
|
8777
8789
|
})(EnumEventDateStatus2 || {});
|
|
8790
|
+
var EnumSubscriptionStatus2 = /* @__PURE__ */ ((EnumSubscriptionStatus22) => {
|
|
8791
|
+
EnumSubscriptionStatus22["ACTIVE"] = "active";
|
|
8792
|
+
EnumSubscriptionStatus22["INACTIVE"] = "inactive";
|
|
8793
|
+
EnumSubscriptionStatus22["CANCELLED"] = "cancelled";
|
|
8794
|
+
EnumSubscriptionStatus22["NO_SUBSCRIPTION"] = "no_subscription";
|
|
8795
|
+
EnumSubscriptionStatus22["PAST_DUE"] = "past_due";
|
|
8796
|
+
EnumSubscriptionStatus22["TRIALING"] = "trialing";
|
|
8797
|
+
return EnumSubscriptionStatus22;
|
|
8798
|
+
})(EnumSubscriptionStatus2 || {});
|
|
8778
8799
|
|
|
8779
8800
|
// src/mongoose/PushToken.ts
|
|
8780
8801
|
import mongoose9 from "mongoose";
|
|
@@ -9939,7 +9960,7 @@ var SHARE_RESOURCE_LABEL2 = {
|
|
|
9939
9960
|
school: "School"
|
|
9940
9961
|
};
|
|
9941
9962
|
|
|
9942
|
-
// node_modules/@timardex/cluemart-shared/dist/chunk-
|
|
9963
|
+
// node_modules/@timardex/cluemart-shared/dist/chunk-5D2JVHC2.mjs
|
|
9943
9964
|
var PROMO_CODE_PREFIX2 = "CM-";
|
|
9944
9965
|
var OBJECT_ID_PATH_SEGMENT2 = "[a-f0-9]{24}";
|
|
9945
9966
|
var OBJECT_ID_PATH_SEGMENT_END2 = `${OBJECT_ID_PATH_SEGMENT2}$`;
|
|
@@ -9947,17 +9968,17 @@ var gameScreenIdentifierList2 = [
|
|
|
9947
9968
|
{
|
|
9948
9969
|
clue: "Where your actions turn into a timeline.",
|
|
9949
9970
|
id: "activities",
|
|
9950
|
-
match: "/profile/
|
|
9971
|
+
match: "/profile/account/favourites"
|
|
9951
9972
|
},
|
|
9952
9973
|
{
|
|
9953
9974
|
clue: "Where conversations happen without speaking.",
|
|
9954
9975
|
id: "chat",
|
|
9955
|
-
match: "/
|
|
9976
|
+
match: "/chat"
|
|
9956
9977
|
},
|
|
9957
9978
|
{
|
|
9958
9979
|
clue: "The place to redefine who you are.",
|
|
9959
9980
|
id: "edit-profile",
|
|
9960
|
-
match: "/profile/
|
|
9981
|
+
match: "/profile/account"
|
|
9961
9982
|
},
|
|
9962
9983
|
{
|
|
9963
9984
|
clue: "A single moment worth showing up for.",
|
|
@@ -10041,7 +10062,7 @@ var gameScreenIdentifierList2 = [
|
|
|
10041
10062
|
}
|
|
10042
10063
|
];
|
|
10043
10064
|
|
|
10044
|
-
// node_modules/@timardex/cluemart-shared/dist/chunk-
|
|
10065
|
+
// node_modules/@timardex/cluemart-shared/dist/chunk-P4JLZCWZ.mjs
|
|
10045
10066
|
import dayjs4 from "dayjs";
|
|
10046
10067
|
var statusOptions2 = [
|
|
10047
10068
|
...Object.values(EnumInviteStatus2).map((status) => ({
|
|
@@ -11218,19 +11239,56 @@ async function sendPushNotifications({
|
|
|
11218
11239
|
}
|
|
11219
11240
|
}
|
|
11220
11241
|
|
|
11221
|
-
// src/service/
|
|
11222
|
-
|
|
11223
|
-
|
|
11224
|
-
|
|
11225
|
-
|
|
11226
|
-
|
|
11242
|
+
// src/service/license.ts
|
|
11243
|
+
var PRO_EVENT_PLANS = /* @__PURE__ */ new Set([
|
|
11244
|
+
EnumUserLicence2.PRO_EVENT,
|
|
11245
|
+
EnumUserLicence2.PRO_PLUS_EVENT
|
|
11246
|
+
]);
|
|
11247
|
+
var PRO_VENDOR_PLANS = /* @__PURE__ */ new Set([
|
|
11248
|
+
EnumUserLicence2.PRO_VENDOR,
|
|
11249
|
+
EnumUserLicence2.PRO_PLUS_VENDOR
|
|
11250
|
+
]);
|
|
11251
|
+
var PRO_PLANS = /* @__PURE__ */ new Set([
|
|
11252
|
+
...PRO_EVENT_PLANS,
|
|
11253
|
+
...PRO_VENDOR_PLANS
|
|
11254
|
+
]);
|
|
11255
|
+
async function getPayingStripePlanFor(userId, now, payingPlans) {
|
|
11256
|
+
const user = await UserModel.findById(userId).select("licences stripe").lean().exec();
|
|
11257
|
+
if (!user) {
|
|
11258
|
+
return { hasSubscription: false, plan: null, validTypes: /* @__PURE__ */ new Set() };
|
|
11259
|
+
}
|
|
11260
|
+
const stripe = user.stripe;
|
|
11261
|
+
const licences = user.licences ?? [];
|
|
11227
11262
|
const validTypes = new Set(
|
|
11228
|
-
|
|
11263
|
+
licences.filter(
|
|
11229
11264
|
(licence) => new Date(licence.expiryDate).getTime() > now.getTime()
|
|
11230
11265
|
).map((licence) => licence.licenceType)
|
|
11231
11266
|
);
|
|
11267
|
+
if (stripe == null || stripe.subscriptionId == null) {
|
|
11268
|
+
return { hasSubscription: false, plan: null, validTypes };
|
|
11269
|
+
}
|
|
11270
|
+
const hasActiveStatus = stripe.status === EnumSubscriptionStatus2.ACTIVE || stripe.status === EnumSubscriptionStatus2.TRIALING;
|
|
11271
|
+
if (!hasActiveStatus || stripe.currentPlan == null) {
|
|
11272
|
+
return { hasSubscription: false, plan: null, validTypes };
|
|
11273
|
+
}
|
|
11274
|
+
const plan = payingPlans.has(stripe.currentPlan) ? stripe.currentPlan : null;
|
|
11275
|
+
return { hasSubscription: plan != null, plan, validTypes };
|
|
11276
|
+
}
|
|
11277
|
+
async function getPayingStripeSubscriptionPlan(userId, now = /* @__PURE__ */ new Date()) {
|
|
11278
|
+
return getPayingStripePlanFor(userId, now, PRO_PLANS);
|
|
11279
|
+
}
|
|
11280
|
+
async function getPayingVendorStripeSubscriptionPlan(userId, now = /* @__PURE__ */ new Date()) {
|
|
11281
|
+
return getPayingStripePlanFor(userId, now, PRO_VENDOR_PLANS);
|
|
11282
|
+
}
|
|
11283
|
+
async function getPayingEventStripeSubscriptionPlan(userId, now = /* @__PURE__ */ new Date()) {
|
|
11284
|
+
return getPayingStripePlanFor(userId, now, PRO_EVENT_PLANS);
|
|
11285
|
+
}
|
|
11286
|
+
|
|
11287
|
+
// src/service/affiliate/vendorSubscriptionRewards.ts
|
|
11288
|
+
async function mapVendorLicenceToSubscriptionRewardType(userId, now = /* @__PURE__ */ new Date()) {
|
|
11289
|
+
const { hasSubscription, validTypes } = await getPayingVendorStripeSubscriptionPlan(userId, now);
|
|
11232
11290
|
if (validTypes.has(EnumUserLicence.PRO_VENDOR) || validTypes.has(EnumUserLicence.PRO_PLUS_VENDOR)) {
|
|
11233
|
-
if (
|
|
11291
|
+
if (hasSubscription) {
|
|
11234
11292
|
return EnumAffiliateRewardType.ACTIVE_VENDOR_PRO_SUBSCRIPTION;
|
|
11235
11293
|
}
|
|
11236
11294
|
return EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
|
|
@@ -11278,14 +11336,6 @@ async function isEligibleReferredVendor({
|
|
|
11278
11336
|
}).exec();
|
|
11279
11337
|
return Boolean(match);
|
|
11280
11338
|
}
|
|
11281
|
-
async function resolveSubscriptionRewardTypeForVendorOwner(vendorOwnerUserId, now) {
|
|
11282
|
-
const vendorOwner = await UserModel.findById(vendorOwnerUserId).select("licences stripe").lean().exec();
|
|
11283
|
-
return mapVendorLicenceToSubscriptionRewardType(
|
|
11284
|
-
vendorOwner?.licences,
|
|
11285
|
-
now,
|
|
11286
|
-
vendorOwner?.stripe
|
|
11287
|
-
);
|
|
11288
|
-
}
|
|
11289
11339
|
async function notifyAffiliateOwnerOfSubscriptionReward({
|
|
11290
11340
|
affiliateId,
|
|
11291
11341
|
affiliateOwnerUserId,
|
|
@@ -11375,7 +11425,7 @@ async function processAffiliateVendorReferral({
|
|
|
11375
11425
|
if (!vendorEligible) {
|
|
11376
11426
|
return "skipped";
|
|
11377
11427
|
}
|
|
11378
|
-
const rewardType = await
|
|
11428
|
+
const rewardType = await mapVendorLicenceToSubscriptionRewardType(
|
|
11379
11429
|
resource.resourceOwner.userId,
|
|
11380
11430
|
now
|
|
11381
11431
|
);
|
|
@@ -11833,6 +11883,9 @@ export {
|
|
|
11833
11883
|
express,
|
|
11834
11884
|
findAffiliateByPromoCode,
|
|
11835
11885
|
findEventOrImportedMarketById,
|
|
11886
|
+
getPayingEventStripeSubscriptionPlan,
|
|
11887
|
+
getPayingStripeSubscriptionPlan,
|
|
11888
|
+
getPayingVendorStripeSubscriptionPlan,
|
|
11836
11889
|
getSubscriptionRewardPeriodBounds,
|
|
11837
11890
|
isValidObjectId,
|
|
11838
11891
|
locationGeoSchema,
|