@timardex/cluemart-server-shared 1.1.23 → 1.1.25
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-YXUMN7EM.mjs} +55 -6
- package/dist/chunk-YXUMN7EM.mjs.map +1 -0
- package/dist/index.cjs +109 -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 +106 -26
- package/dist/index.mjs.map +1 -1
- package/dist/mongoose/index.cjs +31 -4
- package/dist/mongoose/index.cjs.map +1 -1
- package/dist/mongoose/index.mjs +1 -1
- package/dist/service/index.cjs +109 -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 || {});
|
|
@@ -4866,6 +4869,13 @@ var registerFields = [
|
|
|
4866
4869
|
placeholder: "Last Name",
|
|
4867
4870
|
required: true
|
|
4868
4871
|
},
|
|
4872
|
+
{
|
|
4873
|
+
helperText: "Enter Nickname",
|
|
4874
|
+
keyboardType: "default",
|
|
4875
|
+
name: "nickName",
|
|
4876
|
+
placeholder: "Nickname",
|
|
4877
|
+
required: false
|
|
4878
|
+
},
|
|
4869
4879
|
{
|
|
4870
4880
|
...emailField,
|
|
4871
4881
|
required: true
|
|
@@ -4925,6 +4935,13 @@ var profileFields = [
|
|
|
4925
4935
|
name: "lastName",
|
|
4926
4936
|
placeholder: "Last Name"
|
|
4927
4937
|
},
|
|
4938
|
+
{
|
|
4939
|
+
helperText: "Enter Nickname",
|
|
4940
|
+
keyboardType: "default",
|
|
4941
|
+
name: "nickName",
|
|
4942
|
+
placeholder: "Nickname",
|
|
4943
|
+
required: false
|
|
4944
|
+
},
|
|
4928
4945
|
{
|
|
4929
4946
|
helperText: "Enter your new password",
|
|
4930
4947
|
keyboardType: "default",
|
|
@@ -5169,6 +5186,7 @@ var USER_FIELDS_FRAGMENT = gql`
|
|
|
5169
5186
|
game
|
|
5170
5187
|
isTester
|
|
5171
5188
|
lastName
|
|
5189
|
+
nickName
|
|
5172
5190
|
licences {
|
|
5173
5191
|
...LicenceFields
|
|
5174
5192
|
}
|
|
@@ -7768,6 +7786,17 @@ var GET_AFFILIATES = gql`
|
|
|
7768
7786
|
}
|
|
7769
7787
|
${AFFILIATE_FIELDS_FRAGMENT}
|
|
7770
7788
|
`;
|
|
7789
|
+
var CREATE_AFFILIATE_MUTATION = gql`
|
|
7790
|
+
mutation createAffiliate($input: AffiliateDetailsInputType!) {
|
|
7791
|
+
createAffiliate(input: $input) {
|
|
7792
|
+
data {
|
|
7793
|
+
...AffiliateFields
|
|
7794
|
+
}
|
|
7795
|
+
message
|
|
7796
|
+
}
|
|
7797
|
+
}
|
|
7798
|
+
${AFFILIATE_FIELDS_FRAGMENT}
|
|
7799
|
+
`;
|
|
7771
7800
|
var UPDATE_AFFILIATE_DETAILS_MUTATION = gql`
|
|
7772
7801
|
mutation updateAffiliateDetails(
|
|
7773
7802
|
$input: AffiliateDetailsInputType!
|
|
@@ -8864,6 +8893,18 @@ var EnumRegions2 = /* @__PURE__ */ ((EnumRegions22) => {
|
|
|
8864
8893
|
EnumRegions22["Wellington"] = "Wellington";
|
|
8865
8894
|
return EnumRegions22;
|
|
8866
8895
|
})(EnumRegions2 || {});
|
|
8896
|
+
var EnumUserLicence2 = /* @__PURE__ */ ((EnumUserLicence22) => {
|
|
8897
|
+
EnumUserLicence22["PRO_EVENT"] = "pro_event";
|
|
8898
|
+
EnumUserLicence22["PRO_PLUS_EVENT"] = "pro_plus_event";
|
|
8899
|
+
EnumUserLicence22["PRO_PLUS_VENDOR"] = "pro_plus_vendor";
|
|
8900
|
+
EnumUserLicence22["PRO_VENDOR"] = "pro_vendor";
|
|
8901
|
+
EnumUserLicence22["STANDARD_EVENT"] = "standard_event";
|
|
8902
|
+
EnumUserLicence22["STANDARD_VENDOR"] = "standard_vendor";
|
|
8903
|
+
EnumUserLicence22["STANDARD_PARTNER"] = "standard_partner";
|
|
8904
|
+
EnumUserLicence22["STANDARD_AFFILIATE"] = "standard_affiliate";
|
|
8905
|
+
EnumUserLicence22["STANDARD_SCHOOL"] = "standard_school";
|
|
8906
|
+
return EnumUserLicence22;
|
|
8907
|
+
})(EnumUserLicence2 || {});
|
|
8867
8908
|
var EnumEventDateStatus2 = /* @__PURE__ */ ((EnumEventDateStatus22) => {
|
|
8868
8909
|
EnumEventDateStatus22["STARTING_SOON"] = "Starting_Soon";
|
|
8869
8910
|
EnumEventDateStatus22["STARTED"] = "Started";
|
|
@@ -8878,6 +8919,15 @@ var EnumEventDateStatus2 = /* @__PURE__ */ ((EnumEventDateStatus22) => {
|
|
|
8878
8919
|
EnumEventDateStatus22["INVALID"] = "Invalid";
|
|
8879
8920
|
return EnumEventDateStatus22;
|
|
8880
8921
|
})(EnumEventDateStatus2 || {});
|
|
8922
|
+
var EnumSubscriptionStatus2 = /* @__PURE__ */ ((EnumSubscriptionStatus22) => {
|
|
8923
|
+
EnumSubscriptionStatus22["ACTIVE"] = "active";
|
|
8924
|
+
EnumSubscriptionStatus22["INACTIVE"] = "inactive";
|
|
8925
|
+
EnumSubscriptionStatus22["CANCELLED"] = "cancelled";
|
|
8926
|
+
EnumSubscriptionStatus22["NO_SUBSCRIPTION"] = "no_subscription";
|
|
8927
|
+
EnumSubscriptionStatus22["PAST_DUE"] = "past_due";
|
|
8928
|
+
EnumSubscriptionStatus22["TRIALING"] = "trialing";
|
|
8929
|
+
return EnumSubscriptionStatus22;
|
|
8930
|
+
})(EnumSubscriptionStatus2 || {});
|
|
8881
8931
|
|
|
8882
8932
|
// src/mongoose/PushToken.ts
|
|
8883
8933
|
var import_mongoose9 = __toESM(require("mongoose"));
|
|
@@ -9069,6 +9119,7 @@ var schema7 = new MongooseSchema11(
|
|
|
9069
9119
|
required: false,
|
|
9070
9120
|
type: locationsSchema
|
|
9071
9121
|
},
|
|
9122
|
+
nickName: { required: false, type: String },
|
|
9072
9123
|
overallPoints: { default: 0, required: false, type: Number },
|
|
9073
9124
|
partner: {
|
|
9074
9125
|
ref: "Partner",
|
|
@@ -10042,7 +10093,7 @@ var SHARE_RESOURCE_LABEL2 = {
|
|
|
10042
10093
|
school: "School"
|
|
10043
10094
|
};
|
|
10044
10095
|
|
|
10045
|
-
// node_modules/@timardex/cluemart-shared/dist/chunk-
|
|
10096
|
+
// node_modules/@timardex/cluemart-shared/dist/chunk-GZZMH35Y.mjs
|
|
10046
10097
|
var PROMO_CODE_PREFIX2 = "CM-";
|
|
10047
10098
|
var OBJECT_ID_PATH_SEGMENT2 = "[a-f0-9]{24}";
|
|
10048
10099
|
var OBJECT_ID_PATH_SEGMENT_END2 = `${OBJECT_ID_PATH_SEGMENT2}$`;
|
|
@@ -10050,17 +10101,17 @@ var gameScreenIdentifierList2 = [
|
|
|
10050
10101
|
{
|
|
10051
10102
|
clue: "Where your actions turn into a timeline.",
|
|
10052
10103
|
id: "activities",
|
|
10053
|
-
match: "/profile/
|
|
10104
|
+
match: "/profile/account/favourites"
|
|
10054
10105
|
},
|
|
10055
10106
|
{
|
|
10056
10107
|
clue: "Where conversations happen without speaking.",
|
|
10057
10108
|
id: "chat",
|
|
10058
|
-
match: "/
|
|
10109
|
+
match: "/chat"
|
|
10059
10110
|
},
|
|
10060
10111
|
{
|
|
10061
10112
|
clue: "The place to redefine who you are.",
|
|
10062
10113
|
id: "edit-profile",
|
|
10063
|
-
match: "/profile/
|
|
10114
|
+
match: "/profile/account"
|
|
10064
10115
|
},
|
|
10065
10116
|
{
|
|
10066
10117
|
clue: "A single moment worth showing up for.",
|
|
@@ -10144,7 +10195,7 @@ var gameScreenIdentifierList2 = [
|
|
|
10144
10195
|
}
|
|
10145
10196
|
];
|
|
10146
10197
|
|
|
10147
|
-
// node_modules/@timardex/cluemart-shared/dist/chunk-
|
|
10198
|
+
// node_modules/@timardex/cluemart-shared/dist/chunk-TRWMYXB7.mjs
|
|
10148
10199
|
var import_dayjs4 = __toESM(require("dayjs"), 1);
|
|
10149
10200
|
var statusOptions2 = [
|
|
10150
10201
|
...Object.values(EnumInviteStatus2).map((status) => ({
|
|
@@ -11321,19 +11372,56 @@ async function sendPushNotifications({
|
|
|
11321
11372
|
}
|
|
11322
11373
|
}
|
|
11323
11374
|
|
|
11324
|
-
// src/service/
|
|
11325
|
-
|
|
11326
|
-
|
|
11327
|
-
|
|
11328
|
-
|
|
11329
|
-
|
|
11375
|
+
// src/service/license.ts
|
|
11376
|
+
var PRO_EVENT_PLANS = /* @__PURE__ */ new Set([
|
|
11377
|
+
EnumUserLicence2.PRO_EVENT,
|
|
11378
|
+
EnumUserLicence2.PRO_PLUS_EVENT
|
|
11379
|
+
]);
|
|
11380
|
+
var PRO_VENDOR_PLANS = /* @__PURE__ */ new Set([
|
|
11381
|
+
EnumUserLicence2.PRO_VENDOR,
|
|
11382
|
+
EnumUserLicence2.PRO_PLUS_VENDOR
|
|
11383
|
+
]);
|
|
11384
|
+
var PRO_PLANS = /* @__PURE__ */ new Set([
|
|
11385
|
+
...PRO_EVENT_PLANS,
|
|
11386
|
+
...PRO_VENDOR_PLANS
|
|
11387
|
+
]);
|
|
11388
|
+
async function getPayingStripePlanFor(userId, now, payingPlans) {
|
|
11389
|
+
const user = await UserModel.findById(userId).select("licences stripe").lean().exec();
|
|
11390
|
+
if (!user) {
|
|
11391
|
+
return { hasSubscription: false, plan: null, validTypes: /* @__PURE__ */ new Set() };
|
|
11392
|
+
}
|
|
11393
|
+
const stripe = user.stripe;
|
|
11394
|
+
const licences = user.licences ?? [];
|
|
11330
11395
|
const validTypes = new Set(
|
|
11331
|
-
|
|
11396
|
+
licences.filter(
|
|
11332
11397
|
(licence) => new Date(licence.expiryDate).getTime() > now.getTime()
|
|
11333
11398
|
).map((licence) => licence.licenceType)
|
|
11334
11399
|
);
|
|
11400
|
+
if (stripe == null || stripe.subscriptionId == null) {
|
|
11401
|
+
return { hasSubscription: false, plan: null, validTypes };
|
|
11402
|
+
}
|
|
11403
|
+
const hasActiveStatus = stripe.status === EnumSubscriptionStatus2.ACTIVE || stripe.status === EnumSubscriptionStatus2.TRIALING;
|
|
11404
|
+
if (!hasActiveStatus || stripe.currentPlan == null) {
|
|
11405
|
+
return { hasSubscription: false, plan: null, validTypes };
|
|
11406
|
+
}
|
|
11407
|
+
const plan = payingPlans.has(stripe.currentPlan) ? stripe.currentPlan : null;
|
|
11408
|
+
return { hasSubscription: plan != null, plan, validTypes };
|
|
11409
|
+
}
|
|
11410
|
+
async function getPayingStripeSubscriptionPlan(userId, now = /* @__PURE__ */ new Date()) {
|
|
11411
|
+
return getPayingStripePlanFor(userId, now, PRO_PLANS);
|
|
11412
|
+
}
|
|
11413
|
+
async function getPayingVendorStripeSubscriptionPlan(userId, now = /* @__PURE__ */ new Date()) {
|
|
11414
|
+
return getPayingStripePlanFor(userId, now, PRO_VENDOR_PLANS);
|
|
11415
|
+
}
|
|
11416
|
+
async function getPayingEventStripeSubscriptionPlan(userId, now = /* @__PURE__ */ new Date()) {
|
|
11417
|
+
return getPayingStripePlanFor(userId, now, PRO_EVENT_PLANS);
|
|
11418
|
+
}
|
|
11419
|
+
|
|
11420
|
+
// src/service/affiliate/vendorSubscriptionRewards.ts
|
|
11421
|
+
async function mapVendorLicenceToSubscriptionRewardType(userId, now = /* @__PURE__ */ new Date()) {
|
|
11422
|
+
const { hasSubscription, validTypes } = await getPayingVendorStripeSubscriptionPlan(userId, now);
|
|
11335
11423
|
if (validTypes.has(EnumUserLicence.PRO_VENDOR) || validTypes.has(EnumUserLicence.PRO_PLUS_VENDOR)) {
|
|
11336
|
-
if (
|
|
11424
|
+
if (hasSubscription) {
|
|
11337
11425
|
return EnumAffiliateRewardType.ACTIVE_VENDOR_PRO_SUBSCRIPTION;
|
|
11338
11426
|
}
|
|
11339
11427
|
return EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
|
|
@@ -11381,14 +11469,6 @@ async function isEligibleReferredVendor({
|
|
|
11381
11469
|
}).exec();
|
|
11382
11470
|
return Boolean(match);
|
|
11383
11471
|
}
|
|
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
11472
|
async function notifyAffiliateOwnerOfSubscriptionReward({
|
|
11393
11473
|
affiliateId,
|
|
11394
11474
|
affiliateOwnerUserId,
|
|
@@ -11478,7 +11558,7 @@ async function processAffiliateVendorReferral({
|
|
|
11478
11558
|
if (!vendorEligible) {
|
|
11479
11559
|
return "skipped";
|
|
11480
11560
|
}
|
|
11481
|
-
const rewardType = await
|
|
11561
|
+
const rewardType = await mapVendorLicenceToSubscriptionRewardType(
|
|
11482
11562
|
resource.resourceOwner.userId,
|
|
11483
11563
|
now
|
|
11484
11564
|
);
|
|
@@ -11937,6 +12017,9 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
|
|
|
11937
12017
|
express,
|
|
11938
12018
|
findAffiliateByPromoCode,
|
|
11939
12019
|
findEventOrImportedMarketById,
|
|
12020
|
+
getPayingEventStripeSubscriptionPlan,
|
|
12021
|
+
getPayingStripeSubscriptionPlan,
|
|
12022
|
+
getPayingVendorStripeSubscriptionPlan,
|
|
11940
12023
|
getSubscriptionRewardPeriodBounds,
|
|
11941
12024
|
isValidObjectId,
|
|
11942
12025
|
locationGeoSchema,
|