@timardex/cluemart-server-shared 1.1.21 → 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-3JRVRK2N.mjs → chunk-YILYRHDN.mjs} +63 -21
- package/dist/chunk-YILYRHDN.mjs.map +1 -0
- package/dist/index.cjs +117 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +30 -6
- package/dist/index.d.ts +30 -6
- package/dist/index.mjs +114 -41
- package/dist/index.mjs.map +1 -1
- package/dist/mongoose/index.cjs +39 -19
- package/dist/mongoose/index.cjs.map +1 -1
- package/dist/mongoose/index.d.mts +6 -4
- package/dist/mongoose/index.d.ts +6 -4
- package/dist/mongoose/index.mjs +1 -1
- package/dist/service/index.cjs +117 -41
- 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 +3 -2
- package/dist/chunk-3JRVRK2N.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 || {});
|
|
@@ -3728,6 +3731,7 @@ var EnumAffiliateRewardType = /* @__PURE__ */ ((EnumAffiliateRewardType22) => {
|
|
|
3728
3731
|
var EnumCouponQualificationType = /* @__PURE__ */ ((EnumCouponQualificationType2) => {
|
|
3729
3732
|
EnumCouponQualificationType2["PURCHASE"] = "PURCHASE";
|
|
3730
3733
|
EnumCouponQualificationType2["MARKET_VISIT"] = "MARKET_VISIT";
|
|
3734
|
+
EnumCouponQualificationType2["MARKET_PASSPORT"] = "MARKET_PASSPORT";
|
|
3731
3735
|
return EnumCouponQualificationType2;
|
|
3732
3736
|
})(EnumCouponQualificationType || {});
|
|
3733
3737
|
var statusOptions = [
|
|
@@ -7868,20 +7872,22 @@ var COUPON_OPTION_FIELDS_FRAGMENT = gql`
|
|
|
7868
7872
|
visits
|
|
7869
7873
|
}
|
|
7870
7874
|
`;
|
|
7871
|
-
var
|
|
7872
|
-
fragment
|
|
7875
|
+
var COUPON_VENDOR_PRODUCT_FIELDS_FRAGMENT = gql`
|
|
7876
|
+
fragment CouponVendorProductFields on CouponVendorProductType {
|
|
7877
|
+
couponId
|
|
7873
7878
|
vendorId
|
|
7874
7879
|
productId
|
|
7875
|
-
|
|
7876
|
-
unit
|
|
7880
|
+
vendorCouponId
|
|
7877
7881
|
}
|
|
7878
7882
|
`;
|
|
7879
7883
|
var COUPON_DATA_PRODUCTS_FIELDS_FRAGMENT = gql`
|
|
7880
7884
|
fragment CouponDataProductsFields on CouponDataProductsType {
|
|
7881
7885
|
active
|
|
7886
|
+
couponId
|
|
7882
7887
|
productsList {
|
|
7883
7888
|
...VendorProductListFields
|
|
7884
7889
|
}
|
|
7890
|
+
vendorId
|
|
7885
7891
|
vendorLogo {
|
|
7886
7892
|
...ResourceImageFields
|
|
7887
7893
|
}
|
|
@@ -7901,8 +7907,8 @@ var COUPON_DATA_FIELDS_FRAGMENT = gql`
|
|
|
7901
7907
|
couponOption {
|
|
7902
7908
|
...CouponOptionFields
|
|
7903
7909
|
}
|
|
7904
|
-
|
|
7905
|
-
...
|
|
7910
|
+
couponVendorProducts {
|
|
7911
|
+
...CouponVendorProductFields
|
|
7906
7912
|
}
|
|
7907
7913
|
createdAt
|
|
7908
7914
|
endDate
|
|
@@ -7920,7 +7926,7 @@ var COUPON_DATA_FIELDS_FRAGMENT = gql`
|
|
|
7920
7926
|
${COUPON_CODE_FIELDS_FRAGMENT}
|
|
7921
7927
|
${COUPON_OPTION_FIELDS_FRAGMENT}
|
|
7922
7928
|
${COUPON_PARTICIPANT_USER_FIELDS_FRAGMENT}
|
|
7923
|
-
${
|
|
7929
|
+
${COUPON_VENDOR_PRODUCT_FIELDS_FRAGMENT}
|
|
7924
7930
|
${COUPON_DATA_PRODUCTS_FIELDS_FRAGMENT}
|
|
7925
7931
|
`;
|
|
7926
7932
|
var COUPON = gql`
|
|
@@ -7941,8 +7947,8 @@ var COUPON = gql`
|
|
|
7941
7947
|
${COUPON_DATA_FIELDS_FRAGMENT}
|
|
7942
7948
|
`;
|
|
7943
7949
|
var GET_COUPONS = gql`
|
|
7944
|
-
query getCoupons {
|
|
7945
|
-
coupons {
|
|
7950
|
+
query getCoupons($region: String, $category: String) {
|
|
7951
|
+
coupons(region: $region, category: $category) {
|
|
7946
7952
|
active {
|
|
7947
7953
|
listName
|
|
7948
7954
|
data {
|
|
@@ -8004,8 +8010,16 @@ var UPDATE_COUPON_MUTATION = gql`
|
|
|
8004
8010
|
${COUPON}
|
|
8005
8011
|
`;
|
|
8006
8012
|
var DELETE_COUPON_MUTATION = gql`
|
|
8007
|
-
mutation deleteCoupon($
|
|
8008
|
-
deleteCoupon(
|
|
8013
|
+
mutation deleteCoupon($input: ProductCouponInputType!) {
|
|
8014
|
+
deleteCoupon(input: $input) {
|
|
8015
|
+
data
|
|
8016
|
+
message
|
|
8017
|
+
}
|
|
8018
|
+
}
|
|
8019
|
+
`;
|
|
8020
|
+
var SCAN_COUPON_MUTATION = gql`
|
|
8021
|
+
mutation scanCoupon($input: ProductCouponInputType!) {
|
|
8022
|
+
scanCoupon(input: $input) {
|
|
8009
8023
|
data
|
|
8010
8024
|
message
|
|
8011
8025
|
}
|
|
@@ -8853,6 +8867,18 @@ var EnumRegions2 = /* @__PURE__ */ ((EnumRegions22) => {
|
|
|
8853
8867
|
EnumRegions22["Wellington"] = "Wellington";
|
|
8854
8868
|
return EnumRegions22;
|
|
8855
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 || {});
|
|
8856
8882
|
var EnumEventDateStatus2 = /* @__PURE__ */ ((EnumEventDateStatus22) => {
|
|
8857
8883
|
EnumEventDateStatus22["STARTING_SOON"] = "Starting_Soon";
|
|
8858
8884
|
EnumEventDateStatus22["STARTED"] = "Started";
|
|
@@ -8867,6 +8893,15 @@ var EnumEventDateStatus2 = /* @__PURE__ */ ((EnumEventDateStatus22) => {
|
|
|
8867
8893
|
EnumEventDateStatus22["INVALID"] = "Invalid";
|
|
8868
8894
|
return EnumEventDateStatus22;
|
|
8869
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 || {});
|
|
8870
8905
|
|
|
8871
8906
|
// src/mongoose/PushToken.ts
|
|
8872
8907
|
var import_mongoose9 = __toESM(require("mongoose"));
|
|
@@ -9183,14 +9218,20 @@ var couponOptionSchema = new MongooseSchema13(
|
|
|
9183
9218
|
},
|
|
9184
9219
|
{ _id: false }
|
|
9185
9220
|
);
|
|
9186
|
-
var
|
|
9221
|
+
var couponVendorProductSchema = new MongooseSchema13(
|
|
9187
9222
|
{
|
|
9223
|
+
couponId: {
|
|
9224
|
+
required: true,
|
|
9225
|
+
type: import_mongoose13.default.Schema.Types.ObjectId
|
|
9226
|
+
},
|
|
9188
9227
|
productId: {
|
|
9189
9228
|
required: true,
|
|
9190
9229
|
type: import_mongoose13.default.Schema.Types.ObjectId
|
|
9191
9230
|
},
|
|
9192
|
-
|
|
9193
|
-
|
|
9231
|
+
vendorCouponId: {
|
|
9232
|
+
required: false,
|
|
9233
|
+
type: import_mongoose13.default.Schema.Types.ObjectId
|
|
9234
|
+
},
|
|
9194
9235
|
vendorId: {
|
|
9195
9236
|
ref: "Vendor",
|
|
9196
9237
|
required: true,
|
|
@@ -9225,7 +9266,10 @@ var couponDataSchema = new MongooseSchema13(
|
|
|
9225
9266
|
couponCode: { required: true, type: couponCodeSchema },
|
|
9226
9267
|
couponDescription: { required: true, type: String },
|
|
9227
9268
|
couponOption: { required: true, type: couponOptionSchema },
|
|
9228
|
-
|
|
9269
|
+
couponVendorProducts: {
|
|
9270
|
+
required: false,
|
|
9271
|
+
type: [couponVendorProductSchema]
|
|
9272
|
+
},
|
|
9229
9273
|
endDate: { required: true, type: Date },
|
|
9230
9274
|
participantUsers: {
|
|
9231
9275
|
default: null,
|
|
@@ -10022,7 +10066,7 @@ var SHARE_RESOURCE_LABEL2 = {
|
|
|
10022
10066
|
school: "School"
|
|
10023
10067
|
};
|
|
10024
10068
|
|
|
10025
|
-
// node_modules/@timardex/cluemart-shared/dist/chunk-
|
|
10069
|
+
// node_modules/@timardex/cluemart-shared/dist/chunk-5D2JVHC2.mjs
|
|
10026
10070
|
var PROMO_CODE_PREFIX2 = "CM-";
|
|
10027
10071
|
var OBJECT_ID_PATH_SEGMENT2 = "[a-f0-9]{24}";
|
|
10028
10072
|
var OBJECT_ID_PATH_SEGMENT_END2 = `${OBJECT_ID_PATH_SEGMENT2}$`;
|
|
@@ -10030,17 +10074,17 @@ var gameScreenIdentifierList2 = [
|
|
|
10030
10074
|
{
|
|
10031
10075
|
clue: "Where your actions turn into a timeline.",
|
|
10032
10076
|
id: "activities",
|
|
10033
|
-
match: "/profile/
|
|
10077
|
+
match: "/profile/account/favourites"
|
|
10034
10078
|
},
|
|
10035
10079
|
{
|
|
10036
10080
|
clue: "Where conversations happen without speaking.",
|
|
10037
10081
|
id: "chat",
|
|
10038
|
-
match: "/
|
|
10082
|
+
match: "/chat"
|
|
10039
10083
|
},
|
|
10040
10084
|
{
|
|
10041
10085
|
clue: "The place to redefine who you are.",
|
|
10042
10086
|
id: "edit-profile",
|
|
10043
|
-
match: "/profile/
|
|
10087
|
+
match: "/profile/account"
|
|
10044
10088
|
},
|
|
10045
10089
|
{
|
|
10046
10090
|
clue: "A single moment worth showing up for.",
|
|
@@ -10124,7 +10168,7 @@ var gameScreenIdentifierList2 = [
|
|
|
10124
10168
|
}
|
|
10125
10169
|
];
|
|
10126
10170
|
|
|
10127
|
-
// node_modules/@timardex/cluemart-shared/dist/chunk-
|
|
10171
|
+
// node_modules/@timardex/cluemart-shared/dist/chunk-P4JLZCWZ.mjs
|
|
10128
10172
|
var import_dayjs4 = __toESM(require("dayjs"), 1);
|
|
10129
10173
|
var statusOptions2 = [
|
|
10130
10174
|
...Object.values(EnumInviteStatus2).map((status) => ({
|
|
@@ -11301,19 +11345,56 @@ async function sendPushNotifications({
|
|
|
11301
11345
|
}
|
|
11302
11346
|
}
|
|
11303
11347
|
|
|
11304
|
-
// src/service/
|
|
11305
|
-
|
|
11306
|
-
|
|
11307
|
-
|
|
11308
|
-
|
|
11309
|
-
|
|
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 ?? [];
|
|
11310
11368
|
const validTypes = new Set(
|
|
11311
|
-
|
|
11369
|
+
licences.filter(
|
|
11312
11370
|
(licence) => new Date(licence.expiryDate).getTime() > now.getTime()
|
|
11313
11371
|
).map((licence) => licence.licenceType)
|
|
11314
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);
|
|
11315
11396
|
if (validTypes.has(EnumUserLicence.PRO_VENDOR) || validTypes.has(EnumUserLicence.PRO_PLUS_VENDOR)) {
|
|
11316
|
-
if (
|
|
11397
|
+
if (hasSubscription) {
|
|
11317
11398
|
return EnumAffiliateRewardType.ACTIVE_VENDOR_PRO_SUBSCRIPTION;
|
|
11318
11399
|
}
|
|
11319
11400
|
return EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
|
|
@@ -11361,14 +11442,6 @@ async function isEligibleReferredVendor({
|
|
|
11361
11442
|
}).exec();
|
|
11362
11443
|
return Boolean(match);
|
|
11363
11444
|
}
|
|
11364
|
-
async function resolveSubscriptionRewardTypeForVendorOwner(vendorOwnerUserId, now) {
|
|
11365
|
-
const vendorOwner = await UserModel.findById(vendorOwnerUserId).select("licences stripe").lean().exec();
|
|
11366
|
-
return mapVendorLicenceToSubscriptionRewardType(
|
|
11367
|
-
vendorOwner?.licences,
|
|
11368
|
-
now,
|
|
11369
|
-
vendorOwner?.stripe
|
|
11370
|
-
);
|
|
11371
|
-
}
|
|
11372
11445
|
async function notifyAffiliateOwnerOfSubscriptionReward({
|
|
11373
11446
|
affiliateId,
|
|
11374
11447
|
affiliateOwnerUserId,
|
|
@@ -11458,7 +11531,7 @@ async function processAffiliateVendorReferral({
|
|
|
11458
11531
|
if (!vendorEligible) {
|
|
11459
11532
|
return "skipped";
|
|
11460
11533
|
}
|
|
11461
|
-
const rewardType = await
|
|
11534
|
+
const rewardType = await mapVendorLicenceToSubscriptionRewardType(
|
|
11462
11535
|
resource.resourceOwner.userId,
|
|
11463
11536
|
now
|
|
11464
11537
|
);
|
|
@@ -11917,6 +11990,9 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
|
|
|
11917
11990
|
express,
|
|
11918
11991
|
findAffiliateByPromoCode,
|
|
11919
11992
|
findEventOrImportedMarketById,
|
|
11993
|
+
getPayingEventStripeSubscriptionPlan,
|
|
11994
|
+
getPayingStripeSubscriptionPlan,
|
|
11995
|
+
getPayingVendorStripeSubscriptionPlan,
|
|
11920
11996
|
getSubscriptionRewardPeriodBounds,
|
|
11921
11997
|
isValidObjectId,
|
|
11922
11998
|
locationGeoSchema,
|