@timardex/cluemart-server-shared 1.1.19 → 1.1.20

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/index.d.mts CHANGED
@@ -817,8 +817,8 @@ type AwardAffiliateVendorSubscriptionRewardsResult = {
817
817
  * Eligibility per affiliate resource:
818
818
  * - Affiliate is not soft-deleted
819
819
  * - Linked `affiliateResources` entry is vendor, `resourceActive`, and not deleted
820
- * - Vendor is active, not deleted, has the affiliate promo code, and
821
- * `owner.userId` matches `affiliateResources.resourceOwner.userId`
820
+ * - Vendor is active, not deleted, and `owner.userId` matches
821
+ * `affiliateResources.resourceOwner.userId`
822
822
  * - `affiliateResources.resourceOwner` has a non-expired Standard / Pro / Pro+ vendor licence
823
823
  *
824
824
  * Reward type follows the owner's highest valid licence + Stripe paying status:
package/dist/index.d.ts CHANGED
@@ -817,8 +817,8 @@ type AwardAffiliateVendorSubscriptionRewardsResult = {
817
817
  * Eligibility per affiliate resource:
818
818
  * - Affiliate is not soft-deleted
819
819
  * - Linked `affiliateResources` entry is vendor, `resourceActive`, and not deleted
820
- * - Vendor is active, not deleted, has the affiliate promo code, and
821
- * `owner.userId` matches `affiliateResources.resourceOwner.userId`
820
+ * - Vendor is active, not deleted, and `owner.userId` matches
821
+ * `affiliateResources.resourceOwner.userId`
822
822
  * - `affiliateResources.resourceOwner` has a non-expired Standard / Pro / Pro+ vendor licence
823
823
  *
824
824
  * Reward type follows the owner's highest valid licence + Stripe paying status:
package/dist/index.mjs CHANGED
@@ -4924,6 +4924,12 @@ var OWNER_FIELDS_FRAGMENT = gql`
4924
4924
  userId
4925
4925
  }
4926
4926
  `;
4927
+ var PRODUCT_COUPON_FIELDS_FRAGMENT = gql`
4928
+ fragment ProductCouponFields on ProductCouponType {
4929
+ couponDocumentId
4930
+ couponId
4931
+ }
4932
+ `;
4927
4933
  var CATEGORY_FIELDS_FRAGMENT = gql`
4928
4934
  fragment CategoryFields on CategoryType {
4929
4935
  id
@@ -5397,109 +5403,6 @@ var GET_EVENT_INFO = gql`
5397
5403
  }
5398
5404
  ${EVENT_INFO}
5399
5405
  `;
5400
- var PRODUCT_COUPON_FIELDS_FRAGMENT = gql`
5401
- fragment ProductCouponFields on ProductCouponType {
5402
- couponDocumentId
5403
- couponId
5404
- }
5405
- `;
5406
- var COUPON_CODE_FIELDS_FRAGMENT = gql`
5407
- fragment CouponCodeFields on CouponCodeType {
5408
- code
5409
- qrCode {
5410
- ...ResourceImageFields
5411
- }
5412
- }
5413
- ${RESOURCE_IMAGE_FIELDS_FRAGMENT}
5414
- `;
5415
- var COUPON_PARTICIPANT_USER_FIELDS_FRAGMENT = gql`
5416
- fragment CouponParticipantUserFields on CouponParticipantUserType {
5417
- couponCollectedCount
5418
- couponRedeemedAt
5419
- createdAt
5420
- updatedAt
5421
- userId
5422
- }
5423
- `;
5424
- var COUPON_OPTION_FIELDS_FRAGMENT = gql`
5425
- fragment CouponOptionFields on CouponOptionType {
5426
- type
5427
- buy
5428
- get
5429
- unit
5430
- visits
5431
- }
5432
- `;
5433
- var COUPON_REWARD_FIELDS_FRAGMENT = gql`
5434
- fragment CouponRewardFields on CouponRewardType {
5435
- vendorId
5436
- productId
5437
- quantity
5438
- unit
5439
- }
5440
- `;
5441
- var COUPON_DATA_FIELDS_FRAGMENT = gql`
5442
- fragment CouponDataFields on CouponDataType {
5443
- _id
5444
- active
5445
- couponCode {
5446
- ...CouponCodeFields
5447
- }
5448
- couponDescription
5449
- couponOption {
5450
- ...CouponOptionFields
5451
- }
5452
- couponRewards {
5453
- ...CouponRewardFields
5454
- }
5455
- createdAt
5456
- endDate
5457
- participantUsers {
5458
- ...CouponParticipantUserFields
5459
- }
5460
- resourceId
5461
- resourceType
5462
- startDate
5463
- updatedAt
5464
- }
5465
- ${COUPON_CODE_FIELDS_FRAGMENT}
5466
- ${COUPON_OPTION_FIELDS_FRAGMENT}
5467
- ${COUPON_PARTICIPANT_USER_FIELDS_FRAGMENT}
5468
- ${COUPON_REWARD_FIELDS_FRAGMENT}
5469
- `;
5470
- var COUPON = gql`
5471
- fragment CouponFields on CouponType {
5472
- _id
5473
- active
5474
- couponData {
5475
- ...CouponDataFields
5476
- }
5477
- createdAt
5478
- deletedAt
5479
- owner {
5480
- ...OwnerFields
5481
- }
5482
- updatedAt
5483
- }
5484
- ${OWNER_FIELDS_FRAGMENT}
5485
- ${COUPON_DATA_FIELDS_FRAGMENT}
5486
- `;
5487
- var GET_COUPONS = gql`
5488
- query getCoupons {
5489
- coupons {
5490
- ...CouponFields
5491
- }
5492
- }
5493
- ${COUPON}
5494
- `;
5495
- var GET_COUPON = gql`
5496
- query getCoupon($_id: ID!) {
5497
- coupon(_id: $_id) {
5498
- ...CouponFields
5499
- }
5500
- }
5501
- ${COUPON}
5502
- `;
5503
5406
  var VENDOR_DATETIME_FIELDS_FRAGMENT = gql`
5504
5407
  fragment VendorDateTimeFields on VendorDateTimeType {
5505
5408
  dateStatus
@@ -5526,6 +5429,15 @@ var VENDOR_PRODUCT_LIST_FIELDS_FRAGMENT = gql`
5526
5429
  }
5527
5430
  ${PRODUCT_COUPON_FIELDS_FRAGMENT}
5528
5431
  `;
5432
+ var VENDOR_PRODUCTS_FIELDS_FRAGMENT = gql`
5433
+ fragment VendorProductsFields on VendorProductsType {
5434
+ active
5435
+ productsList {
5436
+ ...VendorProductListFields
5437
+ }
5438
+ }
5439
+ ${VENDOR_PRODUCT_LIST_FIELDS_FRAGMENT}
5440
+ `;
5529
5441
  var VENDOR = gql`
5530
5442
  fragment VendorFields on VendorType {
5531
5443
  _id
@@ -5575,10 +5487,7 @@ var VENDOR = gql`
5575
5487
  ...OwnerFields
5576
5488
  }
5577
5489
  products {
5578
- active
5579
- productsList {
5580
- ...VendorProductListFields
5581
- }
5490
+ ...VendorProductsFields
5582
5491
  }
5583
5492
  promoCodes
5584
5493
  posterUsage {
@@ -5620,7 +5529,7 @@ var VENDOR = gql`
5620
5529
  ${RESOURCE_IMAGE_FIELDS_FRAGMENT}
5621
5530
  ${SOCIAL_MEDIA_FIELDS_FRAGMENT}
5622
5531
  ${POSTER_USAGE_FIELDS_FRAGMENT}
5623
- ${VENDOR_PRODUCT_LIST_FIELDS_FRAGMENT}
5532
+ ${VENDOR_PRODUCTS_FIELDS_FRAGMENT}
5624
5533
  ${CONTACT_DETAILS_FIELDS_FRAGMENT}
5625
5534
  ${TERMS_AGREEMENT_FIELDS_FRAGMENT}
5626
5535
  ${RELATION_DATES_FRAGMENT}
@@ -7826,6 +7735,146 @@ var ASSIGN_AFFILIATE_BONUS_REWARD_MUTATION = gql`
7826
7735
  }
7827
7736
  ${AFFILIATE_FIELDS_FRAGMENT}
7828
7737
  `;
7738
+ var COUPON_CODE_FIELDS_FRAGMENT = gql`
7739
+ fragment CouponCodeFields on CouponCodeType {
7740
+ code
7741
+ qrCode {
7742
+ ...ResourceImageFields
7743
+ }
7744
+ }
7745
+ ${RESOURCE_IMAGE_FIELDS_FRAGMENT}
7746
+ `;
7747
+ var COUPON_PARTICIPANT_USER_FIELDS_FRAGMENT = gql`
7748
+ fragment CouponParticipantUserFields on CouponParticipantUserType {
7749
+ couponCollectedCount
7750
+ couponRedeemedAt
7751
+ createdAt
7752
+ updatedAt
7753
+ userId
7754
+ }
7755
+ `;
7756
+ var COUPON_OPTION_FIELDS_FRAGMENT = gql`
7757
+ fragment CouponOptionFields on CouponOptionType {
7758
+ type
7759
+ buy
7760
+ get
7761
+ unit
7762
+ visits
7763
+ }
7764
+ `;
7765
+ var COUPON_REWARD_FIELDS_FRAGMENT = gql`
7766
+ fragment CouponRewardFields on CouponRewardType {
7767
+ vendorId
7768
+ productId
7769
+ quantity
7770
+ unit
7771
+ }
7772
+ `;
7773
+ var COUPON_DATA_PRODUCTS_FIELDS_FRAGMENT = gql`
7774
+ fragment CouponDataProductsFields on CouponDataProductsType {
7775
+ active
7776
+ productsList {
7777
+ ...VendorProductListFields
7778
+ }
7779
+ vendorLogo {
7780
+ ...ResourceImageFields
7781
+ }
7782
+ vendorName
7783
+ }
7784
+ ${VENDOR_PRODUCT_LIST_FIELDS_FRAGMENT}
7785
+ ${RESOURCE_IMAGE_FIELDS_FRAGMENT}
7786
+ `;
7787
+ var COUPON_DATA_FIELDS_FRAGMENT = gql`
7788
+ fragment CouponDataFields on CouponDataType {
7789
+ _id
7790
+ active
7791
+ couponCode {
7792
+ ...CouponCodeFields
7793
+ }
7794
+ couponDescription
7795
+ couponOption {
7796
+ ...CouponOptionFields
7797
+ }
7798
+ couponRewards {
7799
+ ...CouponRewardFields
7800
+ }
7801
+ createdAt
7802
+ endDate
7803
+ participantUsers {
7804
+ ...CouponParticipantUserFields
7805
+ }
7806
+ products {
7807
+ ...CouponDataProductsFields
7808
+ }
7809
+ resourceId
7810
+ resourceType
7811
+ startDate
7812
+ updatedAt
7813
+ }
7814
+ ${COUPON_CODE_FIELDS_FRAGMENT}
7815
+ ${COUPON_OPTION_FIELDS_FRAGMENT}
7816
+ ${COUPON_PARTICIPANT_USER_FIELDS_FRAGMENT}
7817
+ ${COUPON_REWARD_FIELDS_FRAGMENT}
7818
+ ${COUPON_DATA_PRODUCTS_FIELDS_FRAGMENT}
7819
+ `;
7820
+ var COUPON = gql`
7821
+ fragment CouponFields on CouponType {
7822
+ _id
7823
+ active
7824
+ couponData {
7825
+ ...CouponDataFields
7826
+ }
7827
+ createdAt
7828
+ deletedAt
7829
+ owner {
7830
+ ...OwnerFields
7831
+ }
7832
+ updatedAt
7833
+ }
7834
+ ${OWNER_FIELDS_FRAGMENT}
7835
+ ${COUPON_DATA_FIELDS_FRAGMENT}
7836
+ `;
7837
+ var GET_COUPONS = gql`
7838
+ query getCoupons {
7839
+ coupons {
7840
+ active {
7841
+ listName
7842
+ data {
7843
+ ...CouponFields
7844
+ }
7845
+ }
7846
+ owned {
7847
+ listName
7848
+ data {
7849
+ ...CouponFields
7850
+ }
7851
+ }
7852
+ scanned {
7853
+ listName
7854
+ data {
7855
+ ...CouponFields
7856
+ }
7857
+ }
7858
+ }
7859
+ }
7860
+ ${COUPON}
7861
+ `;
7862
+ var GET_COUPON = gql`
7863
+ query getCoupon($_id: ID!) {
7864
+ coupon(_id: $_id) {
7865
+ ...CouponFields
7866
+ }
7867
+ }
7868
+ ${COUPON}
7869
+ `;
7870
+ var GET_RESOURCE_COUPONS = gql`
7871
+ query getResourceCoupons($resourceId: ID!, $resourceType: ResourceTypeEnum!) {
7872
+ resourceCoupons(resourceId: $resourceId, resourceType: $resourceType) {
7873
+ ...CouponFields
7874
+ }
7875
+ }
7876
+ ${COUPON}
7877
+ `;
7829
7878
  var CREATE_COUPON_MUTATION = gql`
7830
7879
  mutation createCoupon($input: CouponInputType!) {
7831
7880
  createCoupon(input: $input) {
@@ -9874,7 +9923,7 @@ var SHARE_RESOURCE_LABEL2 = {
9874
9923
  school: "School"
9875
9924
  };
9876
9925
 
9877
- // node_modules/@timardex/cluemart-shared/dist/chunk-OH7ZORGB.mjs
9926
+ // node_modules/@timardex/cluemart-shared/dist/chunk-3HRC67D3.mjs
9878
9927
  var PROMO_CODE_PREFIX2 = "CM-";
9879
9928
  var OBJECT_ID_PATH_SEGMENT2 = "[a-f0-9]{24}";
9880
9929
  var OBJECT_ID_PATH_SEGMENT_END2 = `${OBJECT_ID_PATH_SEGMENT2}$`;
@@ -9976,7 +10025,7 @@ var gameScreenIdentifierList2 = [
9976
10025
  }
9977
10026
  ];
9978
10027
 
9979
- // node_modules/@timardex/cluemart-shared/dist/chunk-IH3BEKPK.mjs
10028
+ // node_modules/@timardex/cluemart-shared/dist/chunk-E7KKXQDI.mjs
9980
10029
  import dayjs4 from "dayjs";
9981
10030
  var statusOptions2 = [
9982
10031
  ...Object.values(EnumInviteStatus2).map((status) => ({
@@ -11020,12 +11069,6 @@ function createAffiliateReward(rewardType, createdAt) {
11020
11069
  };
11021
11070
  }
11022
11071
 
11023
- // src/service/promoCode/normalizePromoCode.ts
11024
- function normalizePromoCode(decoratedPromoCode) {
11025
- const normalized = decoratedPromoCode?.trim().toUpperCase();
11026
- return normalized || null;
11027
- }
11028
-
11029
11072
  // src/service/saveNotificationsInDb.ts
11030
11073
  async function saveNotificationsInDb(payload) {
11031
11074
  const { data, message, title, type, userIds } = payload;
@@ -11205,10 +11248,9 @@ async function findAffiliatesWithActiveVendorReferrals() {
11205
11248
  }
11206
11249
  },
11207
11250
  deletedAt: null
11208
- }).select("_id affiliateCode affiliateResources owner").lean().exec();
11251
+ }).select("_id affiliateResources owner").lean().exec();
11209
11252
  }
11210
11253
  async function isEligibleReferredVendor({
11211
- affiliateCode,
11212
11254
  resourceId,
11213
11255
  resourceOwnerUserId
11214
11256
  }) {
@@ -11216,8 +11258,7 @@ async function isEligibleReferredVendor({
11216
11258
  _id: resourceId,
11217
11259
  active: true,
11218
11260
  deletedAt: null,
11219
- "owner.userId": resourceOwnerUserId,
11220
- promoCodes: affiliateCode
11261
+ "owner.userId": resourceOwnerUserId
11221
11262
  }).exec();
11222
11263
  return Boolean(match);
11223
11264
  }
@@ -11306,14 +11347,12 @@ async function tryAwardSubscriptionReward({
11306
11347
  }
11307
11348
  async function processAffiliateVendorReferral({
11308
11349
  affiliate,
11309
- affiliateCode,
11310
11350
  createdAt,
11311
11351
  now,
11312
11352
  period,
11313
11353
  resource
11314
11354
  }) {
11315
11355
  const vendorEligible = await isEligibleReferredVendor({
11316
- affiliateCode,
11317
11356
  resourceId: resource.resourceId,
11318
11357
  resourceOwnerUserId: resource.resourceOwner.userId
11319
11358
  });
@@ -11343,10 +11382,6 @@ async function awardAffiliateVendorSubscriptionRewards(now = /* @__PURE__ */ new
11343
11382
  let skipped = 0;
11344
11383
  const seenPairs = /* @__PURE__ */ new Set();
11345
11384
  for (const affiliate of affiliates) {
11346
- const affiliateCode = normalizePromoCode(affiliate.affiliateCode);
11347
- if (!affiliateCode) {
11348
- continue;
11349
- }
11350
11385
  for (const resource of affiliate.affiliateResources) {
11351
11386
  if (!isEligibleVendorResource(resource)) {
11352
11387
  continue;
@@ -11358,7 +11393,6 @@ async function awardAffiliateVendorSubscriptionRewards(now = /* @__PURE__ */ new
11358
11393
  seenPairs.add(pairKey);
11359
11394
  const outcome = await processAffiliateVendorReferral({
11360
11395
  affiliate,
11361
- affiliateCode,
11362
11396
  createdAt,
11363
11397
  now,
11364
11398
  period,
@@ -11382,6 +11416,12 @@ async function findAffiliateByPromoCode(promoCode) {
11382
11416
  }).exec();
11383
11417
  }
11384
11418
 
11419
+ // src/service/promoCode/normalizePromoCode.ts
11420
+ function normalizePromoCode(decoratedPromoCode) {
11421
+ const normalized = decoratedPromoCode?.trim().toUpperCase();
11422
+ return normalized || null;
11423
+ }
11424
+
11385
11425
  // src/service/affiliate/normalizeAffiliatePromoCodes.ts
11386
11426
  function normalizeAffiliatePromoCodes(promoCodes) {
11387
11427
  const normalized = (promoCodes ?? []).map((code) => normalizePromoCode(code)).filter((code) => code !== null);