@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.cjs
CHANGED
|
@@ -72,6 +72,9 @@ __export(index_exports, {
|
|
|
72
72
|
express: () => import_express.default,
|
|
73
73
|
findAffiliateByPromoCode: () => findAffiliateByPromoCode,
|
|
74
74
|
findEventOrImportedMarketById: () => findEventOrImportedMarketById,
|
|
75
|
+
getPayingEventStripeSubscriptionPlan: () => getPayingEventStripeSubscriptionPlan,
|
|
76
|
+
getPayingStripeSubscriptionPlan: () => getPayingStripeSubscriptionPlan,
|
|
77
|
+
getPayingVendorStripeSubscriptionPlan: () => getPayingVendorStripeSubscriptionPlan,
|
|
75
78
|
getSubscriptionRewardPeriodBounds: () => getSubscriptionRewardPeriodBounds,
|
|
76
79
|
isValidObjectId: () => isValidObjectId,
|
|
77
80
|
locationGeoSchema: () => locationGeoSchema,
|
|
@@ -3496,17 +3499,17 @@ var gameScreenIdentifierList = [
|
|
|
3496
3499
|
{
|
|
3497
3500
|
clue: "Where your actions turn into a timeline.",
|
|
3498
3501
|
id: "activities",
|
|
3499
|
-
match: "/profile/
|
|
3502
|
+
match: "/profile/account/favourites"
|
|
3500
3503
|
},
|
|
3501
3504
|
{
|
|
3502
3505
|
clue: "Where conversations happen without speaking.",
|
|
3503
3506
|
id: "chat",
|
|
3504
|
-
match: "/
|
|
3507
|
+
match: "/chat"
|
|
3505
3508
|
},
|
|
3506
3509
|
{
|
|
3507
3510
|
clue: "The place to redefine who you are.",
|
|
3508
3511
|
id: "edit-profile",
|
|
3509
|
-
match: "/profile/
|
|
3512
|
+
match: "/profile/account"
|
|
3510
3513
|
},
|
|
3511
3514
|
{
|
|
3512
3515
|
clue: "A single moment worth showing up for.",
|
|
@@ -3684,8 +3687,8 @@ var EnumActivity = /* @__PURE__ */ ((EnumActivity2) => {
|
|
|
3684
3687
|
return EnumActivity2;
|
|
3685
3688
|
})(EnumActivity || {});
|
|
3686
3689
|
var EnumPostType = /* @__PURE__ */ ((EnumPostType2) => {
|
|
3687
|
-
EnumPostType2["MARKET_FACES"] = "market_faces";
|
|
3688
3690
|
EnumPostType2["CLUE_BITES"] = "clue_bites";
|
|
3691
|
+
EnumPostType2["MARKET_FACES"] = "market_faces";
|
|
3689
3692
|
EnumPostType2["PLAY_AND_WIN"] = "play_and_win";
|
|
3690
3693
|
return EnumPostType2;
|
|
3691
3694
|
})(EnumPostType || {});
|
|
@@ -8864,6 +8867,18 @@ var EnumRegions2 = /* @__PURE__ */ ((EnumRegions22) => {
|
|
|
8864
8867
|
EnumRegions22["Wellington"] = "Wellington";
|
|
8865
8868
|
return EnumRegions22;
|
|
8866
8869
|
})(EnumRegions2 || {});
|
|
8870
|
+
var EnumUserLicence2 = /* @__PURE__ */ ((EnumUserLicence22) => {
|
|
8871
|
+
EnumUserLicence22["PRO_EVENT"] = "pro_event";
|
|
8872
|
+
EnumUserLicence22["PRO_PLUS_EVENT"] = "pro_plus_event";
|
|
8873
|
+
EnumUserLicence22["PRO_PLUS_VENDOR"] = "pro_plus_vendor";
|
|
8874
|
+
EnumUserLicence22["PRO_VENDOR"] = "pro_vendor";
|
|
8875
|
+
EnumUserLicence22["STANDARD_EVENT"] = "standard_event";
|
|
8876
|
+
EnumUserLicence22["STANDARD_VENDOR"] = "standard_vendor";
|
|
8877
|
+
EnumUserLicence22["STANDARD_PARTNER"] = "standard_partner";
|
|
8878
|
+
EnumUserLicence22["STANDARD_AFFILIATE"] = "standard_affiliate";
|
|
8879
|
+
EnumUserLicence22["STANDARD_SCHOOL"] = "standard_school";
|
|
8880
|
+
return EnumUserLicence22;
|
|
8881
|
+
})(EnumUserLicence2 || {});
|
|
8867
8882
|
var EnumEventDateStatus2 = /* @__PURE__ */ ((EnumEventDateStatus22) => {
|
|
8868
8883
|
EnumEventDateStatus22["STARTING_SOON"] = "Starting_Soon";
|
|
8869
8884
|
EnumEventDateStatus22["STARTED"] = "Started";
|
|
@@ -8878,6 +8893,15 @@ var EnumEventDateStatus2 = /* @__PURE__ */ ((EnumEventDateStatus22) => {
|
|
|
8878
8893
|
EnumEventDateStatus22["INVALID"] = "Invalid";
|
|
8879
8894
|
return EnumEventDateStatus22;
|
|
8880
8895
|
})(EnumEventDateStatus2 || {});
|
|
8896
|
+
var EnumSubscriptionStatus2 = /* @__PURE__ */ ((EnumSubscriptionStatus22) => {
|
|
8897
|
+
EnumSubscriptionStatus22["ACTIVE"] = "active";
|
|
8898
|
+
EnumSubscriptionStatus22["INACTIVE"] = "inactive";
|
|
8899
|
+
EnumSubscriptionStatus22["CANCELLED"] = "cancelled";
|
|
8900
|
+
EnumSubscriptionStatus22["NO_SUBSCRIPTION"] = "no_subscription";
|
|
8901
|
+
EnumSubscriptionStatus22["PAST_DUE"] = "past_due";
|
|
8902
|
+
EnumSubscriptionStatus22["TRIALING"] = "trialing";
|
|
8903
|
+
return EnumSubscriptionStatus22;
|
|
8904
|
+
})(EnumSubscriptionStatus2 || {});
|
|
8881
8905
|
|
|
8882
8906
|
// src/mongoose/PushToken.ts
|
|
8883
8907
|
var import_mongoose9 = __toESM(require("mongoose"));
|
|
@@ -10042,7 +10066,7 @@ var SHARE_RESOURCE_LABEL2 = {
|
|
|
10042
10066
|
school: "School"
|
|
10043
10067
|
};
|
|
10044
10068
|
|
|
10045
|
-
// node_modules/@timardex/cluemart-shared/dist/chunk-
|
|
10069
|
+
// node_modules/@timardex/cluemart-shared/dist/chunk-5D2JVHC2.mjs
|
|
10046
10070
|
var PROMO_CODE_PREFIX2 = "CM-";
|
|
10047
10071
|
var OBJECT_ID_PATH_SEGMENT2 = "[a-f0-9]{24}";
|
|
10048
10072
|
var OBJECT_ID_PATH_SEGMENT_END2 = `${OBJECT_ID_PATH_SEGMENT2}$`;
|
|
@@ -10050,17 +10074,17 @@ var gameScreenIdentifierList2 = [
|
|
|
10050
10074
|
{
|
|
10051
10075
|
clue: "Where your actions turn into a timeline.",
|
|
10052
10076
|
id: "activities",
|
|
10053
|
-
match: "/profile/
|
|
10077
|
+
match: "/profile/account/favourites"
|
|
10054
10078
|
},
|
|
10055
10079
|
{
|
|
10056
10080
|
clue: "Where conversations happen without speaking.",
|
|
10057
10081
|
id: "chat",
|
|
10058
|
-
match: "/
|
|
10082
|
+
match: "/chat"
|
|
10059
10083
|
},
|
|
10060
10084
|
{
|
|
10061
10085
|
clue: "The place to redefine who you are.",
|
|
10062
10086
|
id: "edit-profile",
|
|
10063
|
-
match: "/profile/
|
|
10087
|
+
match: "/profile/account"
|
|
10064
10088
|
},
|
|
10065
10089
|
{
|
|
10066
10090
|
clue: "A single moment worth showing up for.",
|
|
@@ -10144,7 +10168,7 @@ var gameScreenIdentifierList2 = [
|
|
|
10144
10168
|
}
|
|
10145
10169
|
];
|
|
10146
10170
|
|
|
10147
|
-
// node_modules/@timardex/cluemart-shared/dist/chunk-
|
|
10171
|
+
// node_modules/@timardex/cluemart-shared/dist/chunk-P4JLZCWZ.mjs
|
|
10148
10172
|
var import_dayjs4 = __toESM(require("dayjs"), 1);
|
|
10149
10173
|
var statusOptions2 = [
|
|
10150
10174
|
...Object.values(EnumInviteStatus2).map((status) => ({
|
|
@@ -11321,19 +11345,56 @@ async function sendPushNotifications({
|
|
|
11321
11345
|
}
|
|
11322
11346
|
}
|
|
11323
11347
|
|
|
11324
|
-
// src/service/
|
|
11325
|
-
|
|
11326
|
-
|
|
11327
|
-
|
|
11328
|
-
|
|
11329
|
-
|
|
11348
|
+
// src/service/license.ts
|
|
11349
|
+
var PRO_EVENT_PLANS = /* @__PURE__ */ new Set([
|
|
11350
|
+
EnumUserLicence2.PRO_EVENT,
|
|
11351
|
+
EnumUserLicence2.PRO_PLUS_EVENT
|
|
11352
|
+
]);
|
|
11353
|
+
var PRO_VENDOR_PLANS = /* @__PURE__ */ new Set([
|
|
11354
|
+
EnumUserLicence2.PRO_VENDOR,
|
|
11355
|
+
EnumUserLicence2.PRO_PLUS_VENDOR
|
|
11356
|
+
]);
|
|
11357
|
+
var PRO_PLANS = /* @__PURE__ */ new Set([
|
|
11358
|
+
...PRO_EVENT_PLANS,
|
|
11359
|
+
...PRO_VENDOR_PLANS
|
|
11360
|
+
]);
|
|
11361
|
+
async function getPayingStripePlanFor(userId, now, payingPlans) {
|
|
11362
|
+
const user = await UserModel.findById(userId).select("licences stripe").lean().exec();
|
|
11363
|
+
if (!user) {
|
|
11364
|
+
return { hasSubscription: false, plan: null, validTypes: /* @__PURE__ */ new Set() };
|
|
11365
|
+
}
|
|
11366
|
+
const stripe = user.stripe;
|
|
11367
|
+
const licences = user.licences ?? [];
|
|
11330
11368
|
const validTypes = new Set(
|
|
11331
|
-
|
|
11369
|
+
licences.filter(
|
|
11332
11370
|
(licence) => new Date(licence.expiryDate).getTime() > now.getTime()
|
|
11333
11371
|
).map((licence) => licence.licenceType)
|
|
11334
11372
|
);
|
|
11373
|
+
if (stripe == null || stripe.subscriptionId == null) {
|
|
11374
|
+
return { hasSubscription: false, plan: null, validTypes };
|
|
11375
|
+
}
|
|
11376
|
+
const hasActiveStatus = stripe.status === EnumSubscriptionStatus2.ACTIVE || stripe.status === EnumSubscriptionStatus2.TRIALING;
|
|
11377
|
+
if (!hasActiveStatus || stripe.currentPlan == null) {
|
|
11378
|
+
return { hasSubscription: false, plan: null, validTypes };
|
|
11379
|
+
}
|
|
11380
|
+
const plan = payingPlans.has(stripe.currentPlan) ? stripe.currentPlan : null;
|
|
11381
|
+
return { hasSubscription: plan != null, plan, validTypes };
|
|
11382
|
+
}
|
|
11383
|
+
async function getPayingStripeSubscriptionPlan(userId, now = /* @__PURE__ */ new Date()) {
|
|
11384
|
+
return getPayingStripePlanFor(userId, now, PRO_PLANS);
|
|
11385
|
+
}
|
|
11386
|
+
async function getPayingVendorStripeSubscriptionPlan(userId, now = /* @__PURE__ */ new Date()) {
|
|
11387
|
+
return getPayingStripePlanFor(userId, now, PRO_VENDOR_PLANS);
|
|
11388
|
+
}
|
|
11389
|
+
async function getPayingEventStripeSubscriptionPlan(userId, now = /* @__PURE__ */ new Date()) {
|
|
11390
|
+
return getPayingStripePlanFor(userId, now, PRO_EVENT_PLANS);
|
|
11391
|
+
}
|
|
11392
|
+
|
|
11393
|
+
// src/service/affiliate/vendorSubscriptionRewards.ts
|
|
11394
|
+
async function mapVendorLicenceToSubscriptionRewardType(userId, now = /* @__PURE__ */ new Date()) {
|
|
11395
|
+
const { hasSubscription, validTypes } = await getPayingVendorStripeSubscriptionPlan(userId, now);
|
|
11335
11396
|
if (validTypes.has(EnumUserLicence.PRO_VENDOR) || validTypes.has(EnumUserLicence.PRO_PLUS_VENDOR)) {
|
|
11336
|
-
if (
|
|
11397
|
+
if (hasSubscription) {
|
|
11337
11398
|
return EnumAffiliateRewardType.ACTIVE_VENDOR_PRO_SUBSCRIPTION;
|
|
11338
11399
|
}
|
|
11339
11400
|
return EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
|
|
@@ -11381,14 +11442,6 @@ async function isEligibleReferredVendor({
|
|
|
11381
11442
|
}).exec();
|
|
11382
11443
|
return Boolean(match);
|
|
11383
11444
|
}
|
|
11384
|
-
async function resolveSubscriptionRewardTypeForVendorOwner(vendorOwnerUserId, now) {
|
|
11385
|
-
const vendorOwner = await UserModel.findById(vendorOwnerUserId).select("licences stripe").lean().exec();
|
|
11386
|
-
return mapVendorLicenceToSubscriptionRewardType(
|
|
11387
|
-
vendorOwner?.licences,
|
|
11388
|
-
now,
|
|
11389
|
-
vendorOwner?.stripe
|
|
11390
|
-
);
|
|
11391
|
-
}
|
|
11392
11445
|
async function notifyAffiliateOwnerOfSubscriptionReward({
|
|
11393
11446
|
affiliateId,
|
|
11394
11447
|
affiliateOwnerUserId,
|
|
@@ -11478,7 +11531,7 @@ async function processAffiliateVendorReferral({
|
|
|
11478
11531
|
if (!vendorEligible) {
|
|
11479
11532
|
return "skipped";
|
|
11480
11533
|
}
|
|
11481
|
-
const rewardType = await
|
|
11534
|
+
const rewardType = await mapVendorLicenceToSubscriptionRewardType(
|
|
11482
11535
|
resource.resourceOwner.userId,
|
|
11483
11536
|
now
|
|
11484
11537
|
);
|
|
@@ -11937,6 +11990,9 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
|
|
|
11937
11990
|
express,
|
|
11938
11991
|
findAffiliateByPromoCode,
|
|
11939
11992
|
findEventOrImportedMarketById,
|
|
11993
|
+
getPayingEventStripeSubscriptionPlan,
|
|
11994
|
+
getPayingStripeSubscriptionPlan,
|
|
11995
|
+
getPayingVendorStripeSubscriptionPlan,
|
|
11940
11996
|
getSubscriptionRewardPeriodBounds,
|
|
11941
11997
|
isValidObjectId,
|
|
11942
11998
|
locationGeoSchema,
|