@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/mongoose/index.mjs
CHANGED
package/dist/service/index.cjs
CHANGED
|
@@ -38,6 +38,9 @@ __export(service_exports, {
|
|
|
38
38
|
didRemoveAnyEventDates: () => didRemoveAnyEventDates,
|
|
39
39
|
findAffiliateByPromoCode: () => findAffiliateByPromoCode,
|
|
40
40
|
findEventOrImportedMarketById: () => findEventOrImportedMarketById,
|
|
41
|
+
getPayingEventStripeSubscriptionPlan: () => getPayingEventStripeSubscriptionPlan,
|
|
42
|
+
getPayingStripeSubscriptionPlan: () => getPayingStripeSubscriptionPlan,
|
|
43
|
+
getPayingVendorStripeSubscriptionPlan: () => getPayingVendorStripeSubscriptionPlan,
|
|
41
44
|
getSubscriptionRewardPeriodBounds: () => getSubscriptionRewardPeriodBounds,
|
|
42
45
|
isValidObjectId: () => isValidObjectId,
|
|
43
46
|
mapVendorLicenceToSubscriptionRewardType: () => mapVendorLicenceToSubscriptionRewardType,
|
|
@@ -3450,17 +3453,17 @@ var gameScreenIdentifierList = [
|
|
|
3450
3453
|
{
|
|
3451
3454
|
clue: "Where your actions turn into a timeline.",
|
|
3452
3455
|
id: "activities",
|
|
3453
|
-
match: "/profile/
|
|
3456
|
+
match: "/profile/account/favourites"
|
|
3454
3457
|
},
|
|
3455
3458
|
{
|
|
3456
3459
|
clue: "Where conversations happen without speaking.",
|
|
3457
3460
|
id: "chat",
|
|
3458
|
-
match: "/
|
|
3461
|
+
match: "/chat"
|
|
3459
3462
|
},
|
|
3460
3463
|
{
|
|
3461
3464
|
clue: "The place to redefine who you are.",
|
|
3462
3465
|
id: "edit-profile",
|
|
3463
|
-
match: "/profile/
|
|
3466
|
+
match: "/profile/account"
|
|
3464
3467
|
},
|
|
3465
3468
|
{
|
|
3466
3469
|
clue: "A single moment worth showing up for.",
|
|
@@ -3638,8 +3641,8 @@ var EnumActivity = /* @__PURE__ */ ((EnumActivity2) => {
|
|
|
3638
3641
|
return EnumActivity2;
|
|
3639
3642
|
})(EnumActivity || {});
|
|
3640
3643
|
var EnumPostType = /* @__PURE__ */ ((EnumPostType2) => {
|
|
3641
|
-
EnumPostType2["MARKET_FACES"] = "market_faces";
|
|
3642
3644
|
EnumPostType2["CLUE_BITES"] = "clue_bites";
|
|
3645
|
+
EnumPostType2["MARKET_FACES"] = "market_faces";
|
|
3643
3646
|
EnumPostType2["PLAY_AND_WIN"] = "play_and_win";
|
|
3644
3647
|
return EnumPostType2;
|
|
3645
3648
|
})(EnumPostType || {});
|
|
@@ -8818,6 +8821,18 @@ var EnumRegions2 = /* @__PURE__ */ ((EnumRegions22) => {
|
|
|
8818
8821
|
EnumRegions22["Wellington"] = "Wellington";
|
|
8819
8822
|
return EnumRegions22;
|
|
8820
8823
|
})(EnumRegions2 || {});
|
|
8824
|
+
var EnumUserLicence2 = /* @__PURE__ */ ((EnumUserLicence22) => {
|
|
8825
|
+
EnumUserLicence22["PRO_EVENT"] = "pro_event";
|
|
8826
|
+
EnumUserLicence22["PRO_PLUS_EVENT"] = "pro_plus_event";
|
|
8827
|
+
EnumUserLicence22["PRO_PLUS_VENDOR"] = "pro_plus_vendor";
|
|
8828
|
+
EnumUserLicence22["PRO_VENDOR"] = "pro_vendor";
|
|
8829
|
+
EnumUserLicence22["STANDARD_EVENT"] = "standard_event";
|
|
8830
|
+
EnumUserLicence22["STANDARD_VENDOR"] = "standard_vendor";
|
|
8831
|
+
EnumUserLicence22["STANDARD_PARTNER"] = "standard_partner";
|
|
8832
|
+
EnumUserLicence22["STANDARD_AFFILIATE"] = "standard_affiliate";
|
|
8833
|
+
EnumUserLicence22["STANDARD_SCHOOL"] = "standard_school";
|
|
8834
|
+
return EnumUserLicence22;
|
|
8835
|
+
})(EnumUserLicence2 || {});
|
|
8821
8836
|
var EnumEventDateStatus2 = /* @__PURE__ */ ((EnumEventDateStatus22) => {
|
|
8822
8837
|
EnumEventDateStatus22["STARTING_SOON"] = "Starting_Soon";
|
|
8823
8838
|
EnumEventDateStatus22["STARTED"] = "Started";
|
|
@@ -8832,6 +8847,15 @@ var EnumEventDateStatus2 = /* @__PURE__ */ ((EnumEventDateStatus22) => {
|
|
|
8832
8847
|
EnumEventDateStatus22["INVALID"] = "Invalid";
|
|
8833
8848
|
return EnumEventDateStatus22;
|
|
8834
8849
|
})(EnumEventDateStatus2 || {});
|
|
8850
|
+
var EnumSubscriptionStatus2 = /* @__PURE__ */ ((EnumSubscriptionStatus22) => {
|
|
8851
|
+
EnumSubscriptionStatus22["ACTIVE"] = "active";
|
|
8852
|
+
EnumSubscriptionStatus22["INACTIVE"] = "inactive";
|
|
8853
|
+
EnumSubscriptionStatus22["CANCELLED"] = "cancelled";
|
|
8854
|
+
EnumSubscriptionStatus22["NO_SUBSCRIPTION"] = "no_subscription";
|
|
8855
|
+
EnumSubscriptionStatus22["PAST_DUE"] = "past_due";
|
|
8856
|
+
EnumSubscriptionStatus22["TRIALING"] = "trialing";
|
|
8857
|
+
return EnumSubscriptionStatus22;
|
|
8858
|
+
})(EnumSubscriptionStatus2 || {});
|
|
8835
8859
|
|
|
8836
8860
|
// src/mongoose/PushToken.ts
|
|
8837
8861
|
var import_mongoose9 = __toESM(require("mongoose"));
|
|
@@ -9996,7 +10020,7 @@ var SHARE_RESOURCE_LABEL2 = {
|
|
|
9996
10020
|
school: "School"
|
|
9997
10021
|
};
|
|
9998
10022
|
|
|
9999
|
-
// node_modules/@timardex/cluemart-shared/dist/chunk-
|
|
10023
|
+
// node_modules/@timardex/cluemart-shared/dist/chunk-5D2JVHC2.mjs
|
|
10000
10024
|
var PROMO_CODE_PREFIX2 = "CM-";
|
|
10001
10025
|
var OBJECT_ID_PATH_SEGMENT2 = "[a-f0-9]{24}";
|
|
10002
10026
|
var OBJECT_ID_PATH_SEGMENT_END2 = `${OBJECT_ID_PATH_SEGMENT2}$`;
|
|
@@ -10004,17 +10028,17 @@ var gameScreenIdentifierList2 = [
|
|
|
10004
10028
|
{
|
|
10005
10029
|
clue: "Where your actions turn into a timeline.",
|
|
10006
10030
|
id: "activities",
|
|
10007
|
-
match: "/profile/
|
|
10031
|
+
match: "/profile/account/favourites"
|
|
10008
10032
|
},
|
|
10009
10033
|
{
|
|
10010
10034
|
clue: "Where conversations happen without speaking.",
|
|
10011
10035
|
id: "chat",
|
|
10012
|
-
match: "/
|
|
10036
|
+
match: "/chat"
|
|
10013
10037
|
},
|
|
10014
10038
|
{
|
|
10015
10039
|
clue: "The place to redefine who you are.",
|
|
10016
10040
|
id: "edit-profile",
|
|
10017
|
-
match: "/profile/
|
|
10041
|
+
match: "/profile/account"
|
|
10018
10042
|
},
|
|
10019
10043
|
{
|
|
10020
10044
|
clue: "A single moment worth showing up for.",
|
|
@@ -10098,7 +10122,7 @@ var gameScreenIdentifierList2 = [
|
|
|
10098
10122
|
}
|
|
10099
10123
|
];
|
|
10100
10124
|
|
|
10101
|
-
// node_modules/@timardex/cluemart-shared/dist/chunk-
|
|
10125
|
+
// node_modules/@timardex/cluemart-shared/dist/chunk-P4JLZCWZ.mjs
|
|
10102
10126
|
var import_dayjs4 = __toESM(require("dayjs"), 1);
|
|
10103
10127
|
var statusOptions2 = [
|
|
10104
10128
|
...Object.values(EnumInviteStatus2).map((status) => ({
|
|
@@ -11275,19 +11299,56 @@ async function sendPushNotifications({
|
|
|
11275
11299
|
}
|
|
11276
11300
|
}
|
|
11277
11301
|
|
|
11278
|
-
// src/service/
|
|
11279
|
-
|
|
11280
|
-
|
|
11281
|
-
|
|
11282
|
-
|
|
11283
|
-
|
|
11302
|
+
// src/service/license.ts
|
|
11303
|
+
var PRO_EVENT_PLANS = /* @__PURE__ */ new Set([
|
|
11304
|
+
EnumUserLicence2.PRO_EVENT,
|
|
11305
|
+
EnumUserLicence2.PRO_PLUS_EVENT
|
|
11306
|
+
]);
|
|
11307
|
+
var PRO_VENDOR_PLANS = /* @__PURE__ */ new Set([
|
|
11308
|
+
EnumUserLicence2.PRO_VENDOR,
|
|
11309
|
+
EnumUserLicence2.PRO_PLUS_VENDOR
|
|
11310
|
+
]);
|
|
11311
|
+
var PRO_PLANS = /* @__PURE__ */ new Set([
|
|
11312
|
+
...PRO_EVENT_PLANS,
|
|
11313
|
+
...PRO_VENDOR_PLANS
|
|
11314
|
+
]);
|
|
11315
|
+
async function getPayingStripePlanFor(userId, now, payingPlans) {
|
|
11316
|
+
const user = await UserModel.findById(userId).select("licences stripe").lean().exec();
|
|
11317
|
+
if (!user) {
|
|
11318
|
+
return { hasSubscription: false, plan: null, validTypes: /* @__PURE__ */ new Set() };
|
|
11319
|
+
}
|
|
11320
|
+
const stripe = user.stripe;
|
|
11321
|
+
const licences = user.licences ?? [];
|
|
11284
11322
|
const validTypes = new Set(
|
|
11285
|
-
|
|
11323
|
+
licences.filter(
|
|
11286
11324
|
(licence) => new Date(licence.expiryDate).getTime() > now.getTime()
|
|
11287
11325
|
).map((licence) => licence.licenceType)
|
|
11288
11326
|
);
|
|
11327
|
+
if (stripe == null || stripe.subscriptionId == null) {
|
|
11328
|
+
return { hasSubscription: false, plan: null, validTypes };
|
|
11329
|
+
}
|
|
11330
|
+
const hasActiveStatus = stripe.status === EnumSubscriptionStatus2.ACTIVE || stripe.status === EnumSubscriptionStatus2.TRIALING;
|
|
11331
|
+
if (!hasActiveStatus || stripe.currentPlan == null) {
|
|
11332
|
+
return { hasSubscription: false, plan: null, validTypes };
|
|
11333
|
+
}
|
|
11334
|
+
const plan = payingPlans.has(stripe.currentPlan) ? stripe.currentPlan : null;
|
|
11335
|
+
return { hasSubscription: plan != null, plan, validTypes };
|
|
11336
|
+
}
|
|
11337
|
+
async function getPayingStripeSubscriptionPlan(userId, now = /* @__PURE__ */ new Date()) {
|
|
11338
|
+
return getPayingStripePlanFor(userId, now, PRO_PLANS);
|
|
11339
|
+
}
|
|
11340
|
+
async function getPayingVendorStripeSubscriptionPlan(userId, now = /* @__PURE__ */ new Date()) {
|
|
11341
|
+
return getPayingStripePlanFor(userId, now, PRO_VENDOR_PLANS);
|
|
11342
|
+
}
|
|
11343
|
+
async function getPayingEventStripeSubscriptionPlan(userId, now = /* @__PURE__ */ new Date()) {
|
|
11344
|
+
return getPayingStripePlanFor(userId, now, PRO_EVENT_PLANS);
|
|
11345
|
+
}
|
|
11346
|
+
|
|
11347
|
+
// src/service/affiliate/vendorSubscriptionRewards.ts
|
|
11348
|
+
async function mapVendorLicenceToSubscriptionRewardType(userId, now = /* @__PURE__ */ new Date()) {
|
|
11349
|
+
const { hasSubscription, validTypes } = await getPayingVendorStripeSubscriptionPlan(userId, now);
|
|
11289
11350
|
if (validTypes.has(EnumUserLicence.PRO_VENDOR) || validTypes.has(EnumUserLicence.PRO_PLUS_VENDOR)) {
|
|
11290
|
-
if (
|
|
11351
|
+
if (hasSubscription) {
|
|
11291
11352
|
return EnumAffiliateRewardType.ACTIVE_VENDOR_PRO_SUBSCRIPTION;
|
|
11292
11353
|
}
|
|
11293
11354
|
return EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
|
|
@@ -11335,14 +11396,6 @@ async function isEligibleReferredVendor({
|
|
|
11335
11396
|
}).exec();
|
|
11336
11397
|
return Boolean(match);
|
|
11337
11398
|
}
|
|
11338
|
-
async function resolveSubscriptionRewardTypeForVendorOwner(vendorOwnerUserId, now) {
|
|
11339
|
-
const vendorOwner = await UserModel.findById(vendorOwnerUserId).select("licences stripe").lean().exec();
|
|
11340
|
-
return mapVendorLicenceToSubscriptionRewardType(
|
|
11341
|
-
vendorOwner?.licences,
|
|
11342
|
-
now,
|
|
11343
|
-
vendorOwner?.stripe
|
|
11344
|
-
);
|
|
11345
|
-
}
|
|
11346
11399
|
async function notifyAffiliateOwnerOfSubscriptionReward({
|
|
11347
11400
|
affiliateId,
|
|
11348
11401
|
affiliateOwnerUserId,
|
|
@@ -11432,7 +11485,7 @@ async function processAffiliateVendorReferral({
|
|
|
11432
11485
|
if (!vendorEligible) {
|
|
11433
11486
|
return "skipped";
|
|
11434
11487
|
}
|
|
11435
|
-
const rewardType = await
|
|
11488
|
+
const rewardType = await mapVendorLicenceToSubscriptionRewardType(
|
|
11436
11489
|
resource.resourceOwner.userId,
|
|
11437
11490
|
now
|
|
11438
11491
|
);
|
|
@@ -11850,6 +11903,9 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
|
|
|
11850
11903
|
didRemoveAnyEventDates,
|
|
11851
11904
|
findAffiliateByPromoCode,
|
|
11852
11905
|
findEventOrImportedMarketById,
|
|
11906
|
+
getPayingEventStripeSubscriptionPlan,
|
|
11907
|
+
getPayingStripeSubscriptionPlan,
|
|
11908
|
+
getPayingVendorStripeSubscriptionPlan,
|
|
11853
11909
|
getSubscriptionRewardPeriodBounds,
|
|
11854
11910
|
isValidObjectId,
|
|
11855
11911
|
mapVendorLicenceToSubscriptionRewardType,
|