@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.
@@ -42,7 +42,7 @@ import {
42
42
  termsAgreementSchema,
43
43
  userLicenseSchema,
44
44
  vendorProductTypeSchema
45
- } from "../chunk-6LIZONJ6.mjs";
45
+ } from "../chunk-YXUMN7EM.mjs";
46
46
  export {
47
47
  APP_SETTINGS_ID,
48
48
  AdModel,
@@ -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/activities"
3456
+ match: "/profile/account/favourites"
3454
3457
  },
3455
3458
  {
3456
3459
  clue: "Where conversations happen without speaking.",
3457
3460
  id: "chat",
3458
- match: "/profile/chat"
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/edit-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 || {});
@@ -4820,6 +4823,13 @@ var registerFields = [
4820
4823
  placeholder: "Last Name",
4821
4824
  required: true
4822
4825
  },
4826
+ {
4827
+ helperText: "Enter Nickname",
4828
+ keyboardType: "default",
4829
+ name: "nickName",
4830
+ placeholder: "Nickname",
4831
+ required: false
4832
+ },
4823
4833
  {
4824
4834
  ...emailField,
4825
4835
  required: true
@@ -4879,6 +4889,13 @@ var profileFields = [
4879
4889
  name: "lastName",
4880
4890
  placeholder: "Last Name"
4881
4891
  },
4892
+ {
4893
+ helperText: "Enter Nickname",
4894
+ keyboardType: "default",
4895
+ name: "nickName",
4896
+ placeholder: "Nickname",
4897
+ required: false
4898
+ },
4882
4899
  {
4883
4900
  helperText: "Enter your new password",
4884
4901
  keyboardType: "default",
@@ -5123,6 +5140,7 @@ var USER_FIELDS_FRAGMENT = gql`
5123
5140
  game
5124
5141
  isTester
5125
5142
  lastName
5143
+ nickName
5126
5144
  licences {
5127
5145
  ...LicenceFields
5128
5146
  }
@@ -7722,6 +7740,17 @@ var GET_AFFILIATES = gql`
7722
7740
  }
7723
7741
  ${AFFILIATE_FIELDS_FRAGMENT}
7724
7742
  `;
7743
+ var CREATE_AFFILIATE_MUTATION = gql`
7744
+ mutation createAffiliate($input: AffiliateDetailsInputType!) {
7745
+ createAffiliate(input: $input) {
7746
+ data {
7747
+ ...AffiliateFields
7748
+ }
7749
+ message
7750
+ }
7751
+ }
7752
+ ${AFFILIATE_FIELDS_FRAGMENT}
7753
+ `;
7725
7754
  var UPDATE_AFFILIATE_DETAILS_MUTATION = gql`
7726
7755
  mutation updateAffiliateDetails(
7727
7756
  $input: AffiliateDetailsInputType!
@@ -8818,6 +8847,18 @@ var EnumRegions2 = /* @__PURE__ */ ((EnumRegions22) => {
8818
8847
  EnumRegions22["Wellington"] = "Wellington";
8819
8848
  return EnumRegions22;
8820
8849
  })(EnumRegions2 || {});
8850
+ var EnumUserLicence2 = /* @__PURE__ */ ((EnumUserLicence22) => {
8851
+ EnumUserLicence22["PRO_EVENT"] = "pro_event";
8852
+ EnumUserLicence22["PRO_PLUS_EVENT"] = "pro_plus_event";
8853
+ EnumUserLicence22["PRO_PLUS_VENDOR"] = "pro_plus_vendor";
8854
+ EnumUserLicence22["PRO_VENDOR"] = "pro_vendor";
8855
+ EnumUserLicence22["STANDARD_EVENT"] = "standard_event";
8856
+ EnumUserLicence22["STANDARD_VENDOR"] = "standard_vendor";
8857
+ EnumUserLicence22["STANDARD_PARTNER"] = "standard_partner";
8858
+ EnumUserLicence22["STANDARD_AFFILIATE"] = "standard_affiliate";
8859
+ EnumUserLicence22["STANDARD_SCHOOL"] = "standard_school";
8860
+ return EnumUserLicence22;
8861
+ })(EnumUserLicence2 || {});
8821
8862
  var EnumEventDateStatus2 = /* @__PURE__ */ ((EnumEventDateStatus22) => {
8822
8863
  EnumEventDateStatus22["STARTING_SOON"] = "Starting_Soon";
8823
8864
  EnumEventDateStatus22["STARTED"] = "Started";
@@ -8832,6 +8873,15 @@ var EnumEventDateStatus2 = /* @__PURE__ */ ((EnumEventDateStatus22) => {
8832
8873
  EnumEventDateStatus22["INVALID"] = "Invalid";
8833
8874
  return EnumEventDateStatus22;
8834
8875
  })(EnumEventDateStatus2 || {});
8876
+ var EnumSubscriptionStatus2 = /* @__PURE__ */ ((EnumSubscriptionStatus22) => {
8877
+ EnumSubscriptionStatus22["ACTIVE"] = "active";
8878
+ EnumSubscriptionStatus22["INACTIVE"] = "inactive";
8879
+ EnumSubscriptionStatus22["CANCELLED"] = "cancelled";
8880
+ EnumSubscriptionStatus22["NO_SUBSCRIPTION"] = "no_subscription";
8881
+ EnumSubscriptionStatus22["PAST_DUE"] = "past_due";
8882
+ EnumSubscriptionStatus22["TRIALING"] = "trialing";
8883
+ return EnumSubscriptionStatus22;
8884
+ })(EnumSubscriptionStatus2 || {});
8835
8885
 
8836
8886
  // src/mongoose/PushToken.ts
8837
8887
  var import_mongoose9 = __toESM(require("mongoose"));
@@ -9023,6 +9073,7 @@ var schema7 = new MongooseSchema11(
9023
9073
  required: false,
9024
9074
  type: locationsSchema
9025
9075
  },
9076
+ nickName: { required: false, type: String },
9026
9077
  overallPoints: { default: 0, required: false, type: Number },
9027
9078
  partner: {
9028
9079
  ref: "Partner",
@@ -9996,7 +10047,7 @@ var SHARE_RESOURCE_LABEL2 = {
9996
10047
  school: "School"
9997
10048
  };
9998
10049
 
9999
- // node_modules/@timardex/cluemart-shared/dist/chunk-LA47T6CY.mjs
10050
+ // node_modules/@timardex/cluemart-shared/dist/chunk-GZZMH35Y.mjs
10000
10051
  var PROMO_CODE_PREFIX2 = "CM-";
10001
10052
  var OBJECT_ID_PATH_SEGMENT2 = "[a-f0-9]{24}";
10002
10053
  var OBJECT_ID_PATH_SEGMENT_END2 = `${OBJECT_ID_PATH_SEGMENT2}$`;
@@ -10004,17 +10055,17 @@ var gameScreenIdentifierList2 = [
10004
10055
  {
10005
10056
  clue: "Where your actions turn into a timeline.",
10006
10057
  id: "activities",
10007
- match: "/profile/activities"
10058
+ match: "/profile/account/favourites"
10008
10059
  },
10009
10060
  {
10010
10061
  clue: "Where conversations happen without speaking.",
10011
10062
  id: "chat",
10012
- match: "/profile/chat"
10063
+ match: "/chat"
10013
10064
  },
10014
10065
  {
10015
10066
  clue: "The place to redefine who you are.",
10016
10067
  id: "edit-profile",
10017
- match: "/profile/edit-profile"
10068
+ match: "/profile/account"
10018
10069
  },
10019
10070
  {
10020
10071
  clue: "A single moment worth showing up for.",
@@ -10098,7 +10149,7 @@ var gameScreenIdentifierList2 = [
10098
10149
  }
10099
10150
  ];
10100
10151
 
10101
- // node_modules/@timardex/cluemart-shared/dist/chunk-Q2ZUHS2F.mjs
10152
+ // node_modules/@timardex/cluemart-shared/dist/chunk-TRWMYXB7.mjs
10102
10153
  var import_dayjs4 = __toESM(require("dayjs"), 1);
10103
10154
  var statusOptions2 = [
10104
10155
  ...Object.values(EnumInviteStatus2).map((status) => ({
@@ -11275,19 +11326,56 @@ async function sendPushNotifications({
11275
11326
  }
11276
11327
  }
11277
11328
 
11278
- // src/service/affiliate/vendorSubscriptionRewards.ts
11279
- function isPayingStripeSubscription(stripe) {
11280
- if (!stripe?.subscriptionId) return false;
11281
- return (stripe.status === EnumSubscriptionStatus.ACTIVE || stripe.status === EnumSubscriptionStatus.TRIALING) && (stripe.currentPlan === EnumUserLicence.PRO_VENDOR || stripe.currentPlan === EnumUserLicence.PRO_PLUS_VENDOR);
11282
- }
11283
- function mapVendorLicenceToSubscriptionRewardType(licences, now = /* @__PURE__ */ new Date(), stripe) {
11329
+ // src/service/license.ts
11330
+ var PRO_EVENT_PLANS = /* @__PURE__ */ new Set([
11331
+ EnumUserLicence2.PRO_EVENT,
11332
+ EnumUserLicence2.PRO_PLUS_EVENT
11333
+ ]);
11334
+ var PRO_VENDOR_PLANS = /* @__PURE__ */ new Set([
11335
+ EnumUserLicence2.PRO_VENDOR,
11336
+ EnumUserLicence2.PRO_PLUS_VENDOR
11337
+ ]);
11338
+ var PRO_PLANS = /* @__PURE__ */ new Set([
11339
+ ...PRO_EVENT_PLANS,
11340
+ ...PRO_VENDOR_PLANS
11341
+ ]);
11342
+ async function getPayingStripePlanFor(userId, now, payingPlans) {
11343
+ const user = await UserModel.findById(userId).select("licences stripe").lean().exec();
11344
+ if (!user) {
11345
+ return { hasSubscription: false, plan: null, validTypes: /* @__PURE__ */ new Set() };
11346
+ }
11347
+ const stripe = user.stripe;
11348
+ const licences = user.licences ?? [];
11284
11349
  const validTypes = new Set(
11285
- (licences ?? []).filter(
11350
+ licences.filter(
11286
11351
  (licence) => new Date(licence.expiryDate).getTime() > now.getTime()
11287
11352
  ).map((licence) => licence.licenceType)
11288
11353
  );
11354
+ if (stripe == null || stripe.subscriptionId == null) {
11355
+ return { hasSubscription: false, plan: null, validTypes };
11356
+ }
11357
+ const hasActiveStatus = stripe.status === EnumSubscriptionStatus2.ACTIVE || stripe.status === EnumSubscriptionStatus2.TRIALING;
11358
+ if (!hasActiveStatus || stripe.currentPlan == null) {
11359
+ return { hasSubscription: false, plan: null, validTypes };
11360
+ }
11361
+ const plan = payingPlans.has(stripe.currentPlan) ? stripe.currentPlan : null;
11362
+ return { hasSubscription: plan != null, plan, validTypes };
11363
+ }
11364
+ async function getPayingStripeSubscriptionPlan(userId, now = /* @__PURE__ */ new Date()) {
11365
+ return getPayingStripePlanFor(userId, now, PRO_PLANS);
11366
+ }
11367
+ async function getPayingVendorStripeSubscriptionPlan(userId, now = /* @__PURE__ */ new Date()) {
11368
+ return getPayingStripePlanFor(userId, now, PRO_VENDOR_PLANS);
11369
+ }
11370
+ async function getPayingEventStripeSubscriptionPlan(userId, now = /* @__PURE__ */ new Date()) {
11371
+ return getPayingStripePlanFor(userId, now, PRO_EVENT_PLANS);
11372
+ }
11373
+
11374
+ // src/service/affiliate/vendorSubscriptionRewards.ts
11375
+ async function mapVendorLicenceToSubscriptionRewardType(userId, now = /* @__PURE__ */ new Date()) {
11376
+ const { hasSubscription, validTypes } = await getPayingVendorStripeSubscriptionPlan(userId, now);
11289
11377
  if (validTypes.has(EnumUserLicence.PRO_VENDOR) || validTypes.has(EnumUserLicence.PRO_PLUS_VENDOR)) {
11290
- if (isPayingStripeSubscription(stripe)) {
11378
+ if (hasSubscription) {
11291
11379
  return EnumAffiliateRewardType.ACTIVE_VENDOR_PRO_SUBSCRIPTION;
11292
11380
  }
11293
11381
  return EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
@@ -11335,14 +11423,6 @@ async function isEligibleReferredVendor({
11335
11423
  }).exec();
11336
11424
  return Boolean(match);
11337
11425
  }
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
11426
  async function notifyAffiliateOwnerOfSubscriptionReward({
11347
11427
  affiliateId,
11348
11428
  affiliateOwnerUserId,
@@ -11432,7 +11512,7 @@ async function processAffiliateVendorReferral({
11432
11512
  if (!vendorEligible) {
11433
11513
  return "skipped";
11434
11514
  }
11435
- const rewardType = await resolveSubscriptionRewardTypeForVendorOwner(
11515
+ const rewardType = await mapVendorLicenceToSubscriptionRewardType(
11436
11516
  resource.resourceOwner.userId,
11437
11517
  now
11438
11518
  );
@@ -11850,6 +11930,9 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
11850
11930
  didRemoveAnyEventDates,
11851
11931
  findAffiliateByPromoCode,
11852
11932
  findEventOrImportedMarketById,
11933
+ getPayingEventStripeSubscriptionPlan,
11934
+ getPayingStripeSubscriptionPlan,
11935
+ getPayingVendorStripeSubscriptionPlan,
11853
11936
  getSubscriptionRewardPeriodBounds,
11854
11937
  isValidObjectId,
11855
11938
  mapVendorLicenceToSubscriptionRewardType,