@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.cjs CHANGED
@@ -5027,6 +5027,12 @@ var OWNER_FIELDS_FRAGMENT = gql`
5027
5027
  userId
5028
5028
  }
5029
5029
  `;
5030
+ var PRODUCT_COUPON_FIELDS_FRAGMENT = gql`
5031
+ fragment ProductCouponFields on ProductCouponType {
5032
+ couponDocumentId
5033
+ couponId
5034
+ }
5035
+ `;
5030
5036
  var CATEGORY_FIELDS_FRAGMENT = gql`
5031
5037
  fragment CategoryFields on CategoryType {
5032
5038
  id
@@ -5500,109 +5506,6 @@ var GET_EVENT_INFO = gql`
5500
5506
  }
5501
5507
  ${EVENT_INFO}
5502
5508
  `;
5503
- var PRODUCT_COUPON_FIELDS_FRAGMENT = gql`
5504
- fragment ProductCouponFields on ProductCouponType {
5505
- couponDocumentId
5506
- couponId
5507
- }
5508
- `;
5509
- var COUPON_CODE_FIELDS_FRAGMENT = gql`
5510
- fragment CouponCodeFields on CouponCodeType {
5511
- code
5512
- qrCode {
5513
- ...ResourceImageFields
5514
- }
5515
- }
5516
- ${RESOURCE_IMAGE_FIELDS_FRAGMENT}
5517
- `;
5518
- var COUPON_PARTICIPANT_USER_FIELDS_FRAGMENT = gql`
5519
- fragment CouponParticipantUserFields on CouponParticipantUserType {
5520
- couponCollectedCount
5521
- couponRedeemedAt
5522
- createdAt
5523
- updatedAt
5524
- userId
5525
- }
5526
- `;
5527
- var COUPON_OPTION_FIELDS_FRAGMENT = gql`
5528
- fragment CouponOptionFields on CouponOptionType {
5529
- type
5530
- buy
5531
- get
5532
- unit
5533
- visits
5534
- }
5535
- `;
5536
- var COUPON_REWARD_FIELDS_FRAGMENT = gql`
5537
- fragment CouponRewardFields on CouponRewardType {
5538
- vendorId
5539
- productId
5540
- quantity
5541
- unit
5542
- }
5543
- `;
5544
- var COUPON_DATA_FIELDS_FRAGMENT = gql`
5545
- fragment CouponDataFields on CouponDataType {
5546
- _id
5547
- active
5548
- couponCode {
5549
- ...CouponCodeFields
5550
- }
5551
- couponDescription
5552
- couponOption {
5553
- ...CouponOptionFields
5554
- }
5555
- couponRewards {
5556
- ...CouponRewardFields
5557
- }
5558
- createdAt
5559
- endDate
5560
- participantUsers {
5561
- ...CouponParticipantUserFields
5562
- }
5563
- resourceId
5564
- resourceType
5565
- startDate
5566
- updatedAt
5567
- }
5568
- ${COUPON_CODE_FIELDS_FRAGMENT}
5569
- ${COUPON_OPTION_FIELDS_FRAGMENT}
5570
- ${COUPON_PARTICIPANT_USER_FIELDS_FRAGMENT}
5571
- ${COUPON_REWARD_FIELDS_FRAGMENT}
5572
- `;
5573
- var COUPON = gql`
5574
- fragment CouponFields on CouponType {
5575
- _id
5576
- active
5577
- couponData {
5578
- ...CouponDataFields
5579
- }
5580
- createdAt
5581
- deletedAt
5582
- owner {
5583
- ...OwnerFields
5584
- }
5585
- updatedAt
5586
- }
5587
- ${OWNER_FIELDS_FRAGMENT}
5588
- ${COUPON_DATA_FIELDS_FRAGMENT}
5589
- `;
5590
- var GET_COUPONS = gql`
5591
- query getCoupons {
5592
- coupons {
5593
- ...CouponFields
5594
- }
5595
- }
5596
- ${COUPON}
5597
- `;
5598
- var GET_COUPON = gql`
5599
- query getCoupon($_id: ID!) {
5600
- coupon(_id: $_id) {
5601
- ...CouponFields
5602
- }
5603
- }
5604
- ${COUPON}
5605
- `;
5606
5509
  var VENDOR_DATETIME_FIELDS_FRAGMENT = gql`
5607
5510
  fragment VendorDateTimeFields on VendorDateTimeType {
5608
5511
  dateStatus
@@ -5629,6 +5532,15 @@ var VENDOR_PRODUCT_LIST_FIELDS_FRAGMENT = gql`
5629
5532
  }
5630
5533
  ${PRODUCT_COUPON_FIELDS_FRAGMENT}
5631
5534
  `;
5535
+ var VENDOR_PRODUCTS_FIELDS_FRAGMENT = gql`
5536
+ fragment VendorProductsFields on VendorProductsType {
5537
+ active
5538
+ productsList {
5539
+ ...VendorProductListFields
5540
+ }
5541
+ }
5542
+ ${VENDOR_PRODUCT_LIST_FIELDS_FRAGMENT}
5543
+ `;
5632
5544
  var VENDOR = gql`
5633
5545
  fragment VendorFields on VendorType {
5634
5546
  _id
@@ -5678,10 +5590,7 @@ var VENDOR = gql`
5678
5590
  ...OwnerFields
5679
5591
  }
5680
5592
  products {
5681
- active
5682
- productsList {
5683
- ...VendorProductListFields
5684
- }
5593
+ ...VendorProductsFields
5685
5594
  }
5686
5595
  promoCodes
5687
5596
  posterUsage {
@@ -5723,7 +5632,7 @@ var VENDOR = gql`
5723
5632
  ${RESOURCE_IMAGE_FIELDS_FRAGMENT}
5724
5633
  ${SOCIAL_MEDIA_FIELDS_FRAGMENT}
5725
5634
  ${POSTER_USAGE_FIELDS_FRAGMENT}
5726
- ${VENDOR_PRODUCT_LIST_FIELDS_FRAGMENT}
5635
+ ${VENDOR_PRODUCTS_FIELDS_FRAGMENT}
5727
5636
  ${CONTACT_DETAILS_FIELDS_FRAGMENT}
5728
5637
  ${TERMS_AGREEMENT_FIELDS_FRAGMENT}
5729
5638
  ${RELATION_DATES_FRAGMENT}
@@ -7929,6 +7838,146 @@ var ASSIGN_AFFILIATE_BONUS_REWARD_MUTATION = gql`
7929
7838
  }
7930
7839
  ${AFFILIATE_FIELDS_FRAGMENT}
7931
7840
  `;
7841
+ var COUPON_CODE_FIELDS_FRAGMENT = gql`
7842
+ fragment CouponCodeFields on CouponCodeType {
7843
+ code
7844
+ qrCode {
7845
+ ...ResourceImageFields
7846
+ }
7847
+ }
7848
+ ${RESOURCE_IMAGE_FIELDS_FRAGMENT}
7849
+ `;
7850
+ var COUPON_PARTICIPANT_USER_FIELDS_FRAGMENT = gql`
7851
+ fragment CouponParticipantUserFields on CouponParticipantUserType {
7852
+ couponCollectedCount
7853
+ couponRedeemedAt
7854
+ createdAt
7855
+ updatedAt
7856
+ userId
7857
+ }
7858
+ `;
7859
+ var COUPON_OPTION_FIELDS_FRAGMENT = gql`
7860
+ fragment CouponOptionFields on CouponOptionType {
7861
+ type
7862
+ buy
7863
+ get
7864
+ unit
7865
+ visits
7866
+ }
7867
+ `;
7868
+ var COUPON_REWARD_FIELDS_FRAGMENT = gql`
7869
+ fragment CouponRewardFields on CouponRewardType {
7870
+ vendorId
7871
+ productId
7872
+ quantity
7873
+ unit
7874
+ }
7875
+ `;
7876
+ var COUPON_DATA_PRODUCTS_FIELDS_FRAGMENT = gql`
7877
+ fragment CouponDataProductsFields on CouponDataProductsType {
7878
+ active
7879
+ productsList {
7880
+ ...VendorProductListFields
7881
+ }
7882
+ vendorLogo {
7883
+ ...ResourceImageFields
7884
+ }
7885
+ vendorName
7886
+ }
7887
+ ${VENDOR_PRODUCT_LIST_FIELDS_FRAGMENT}
7888
+ ${RESOURCE_IMAGE_FIELDS_FRAGMENT}
7889
+ `;
7890
+ var COUPON_DATA_FIELDS_FRAGMENT = gql`
7891
+ fragment CouponDataFields on CouponDataType {
7892
+ _id
7893
+ active
7894
+ couponCode {
7895
+ ...CouponCodeFields
7896
+ }
7897
+ couponDescription
7898
+ couponOption {
7899
+ ...CouponOptionFields
7900
+ }
7901
+ couponRewards {
7902
+ ...CouponRewardFields
7903
+ }
7904
+ createdAt
7905
+ endDate
7906
+ participantUsers {
7907
+ ...CouponParticipantUserFields
7908
+ }
7909
+ products {
7910
+ ...CouponDataProductsFields
7911
+ }
7912
+ resourceId
7913
+ resourceType
7914
+ startDate
7915
+ updatedAt
7916
+ }
7917
+ ${COUPON_CODE_FIELDS_FRAGMENT}
7918
+ ${COUPON_OPTION_FIELDS_FRAGMENT}
7919
+ ${COUPON_PARTICIPANT_USER_FIELDS_FRAGMENT}
7920
+ ${COUPON_REWARD_FIELDS_FRAGMENT}
7921
+ ${COUPON_DATA_PRODUCTS_FIELDS_FRAGMENT}
7922
+ `;
7923
+ var COUPON = gql`
7924
+ fragment CouponFields on CouponType {
7925
+ _id
7926
+ active
7927
+ couponData {
7928
+ ...CouponDataFields
7929
+ }
7930
+ createdAt
7931
+ deletedAt
7932
+ owner {
7933
+ ...OwnerFields
7934
+ }
7935
+ updatedAt
7936
+ }
7937
+ ${OWNER_FIELDS_FRAGMENT}
7938
+ ${COUPON_DATA_FIELDS_FRAGMENT}
7939
+ `;
7940
+ var GET_COUPONS = gql`
7941
+ query getCoupons {
7942
+ coupons {
7943
+ active {
7944
+ listName
7945
+ data {
7946
+ ...CouponFields
7947
+ }
7948
+ }
7949
+ owned {
7950
+ listName
7951
+ data {
7952
+ ...CouponFields
7953
+ }
7954
+ }
7955
+ scanned {
7956
+ listName
7957
+ data {
7958
+ ...CouponFields
7959
+ }
7960
+ }
7961
+ }
7962
+ }
7963
+ ${COUPON}
7964
+ `;
7965
+ var GET_COUPON = gql`
7966
+ query getCoupon($_id: ID!) {
7967
+ coupon(_id: $_id) {
7968
+ ...CouponFields
7969
+ }
7970
+ }
7971
+ ${COUPON}
7972
+ `;
7973
+ var GET_RESOURCE_COUPONS = gql`
7974
+ query getResourceCoupons($resourceId: ID!, $resourceType: ResourceTypeEnum!) {
7975
+ resourceCoupons(resourceId: $resourceId, resourceType: $resourceType) {
7976
+ ...CouponFields
7977
+ }
7978
+ }
7979
+ ${COUPON}
7980
+ `;
7932
7981
  var CREATE_COUPON_MUTATION = gql`
7933
7982
  mutation createCoupon($input: CouponInputType!) {
7934
7983
  createCoupon(input: $input) {
@@ -9977,7 +10026,7 @@ var SHARE_RESOURCE_LABEL2 = {
9977
10026
  school: "School"
9978
10027
  };
9979
10028
 
9980
- // node_modules/@timardex/cluemart-shared/dist/chunk-OH7ZORGB.mjs
10029
+ // node_modules/@timardex/cluemart-shared/dist/chunk-3HRC67D3.mjs
9981
10030
  var PROMO_CODE_PREFIX2 = "CM-";
9982
10031
  var OBJECT_ID_PATH_SEGMENT2 = "[a-f0-9]{24}";
9983
10032
  var OBJECT_ID_PATH_SEGMENT_END2 = `${OBJECT_ID_PATH_SEGMENT2}$`;
@@ -10079,7 +10128,7 @@ var gameScreenIdentifierList2 = [
10079
10128
  }
10080
10129
  ];
10081
10130
 
10082
- // node_modules/@timardex/cluemart-shared/dist/chunk-IH3BEKPK.mjs
10131
+ // node_modules/@timardex/cluemart-shared/dist/chunk-E7KKXQDI.mjs
10083
10132
  var import_dayjs4 = __toESM(require("dayjs"), 1);
10084
10133
  var statusOptions2 = [
10085
10134
  ...Object.values(EnumInviteStatus2).map((status) => ({
@@ -11123,12 +11172,6 @@ function createAffiliateReward(rewardType, createdAt) {
11123
11172
  };
11124
11173
  }
11125
11174
 
11126
- // src/service/promoCode/normalizePromoCode.ts
11127
- function normalizePromoCode(decoratedPromoCode) {
11128
- const normalized = decoratedPromoCode?.trim().toUpperCase();
11129
- return normalized || null;
11130
- }
11131
-
11132
11175
  // src/service/saveNotificationsInDb.ts
11133
11176
  async function saveNotificationsInDb(payload) {
11134
11177
  const { data, message, title, type, userIds } = payload;
@@ -11308,10 +11351,9 @@ async function findAffiliatesWithActiveVendorReferrals() {
11308
11351
  }
11309
11352
  },
11310
11353
  deletedAt: null
11311
- }).select("_id affiliateCode affiliateResources owner").lean().exec();
11354
+ }).select("_id affiliateResources owner").lean().exec();
11312
11355
  }
11313
11356
  async function isEligibleReferredVendor({
11314
- affiliateCode,
11315
11357
  resourceId,
11316
11358
  resourceOwnerUserId
11317
11359
  }) {
@@ -11319,8 +11361,7 @@ async function isEligibleReferredVendor({
11319
11361
  _id: resourceId,
11320
11362
  active: true,
11321
11363
  deletedAt: null,
11322
- "owner.userId": resourceOwnerUserId,
11323
- promoCodes: affiliateCode
11364
+ "owner.userId": resourceOwnerUserId
11324
11365
  }).exec();
11325
11366
  return Boolean(match);
11326
11367
  }
@@ -11409,14 +11450,12 @@ async function tryAwardSubscriptionReward({
11409
11450
  }
11410
11451
  async function processAffiliateVendorReferral({
11411
11452
  affiliate,
11412
- affiliateCode,
11413
11453
  createdAt,
11414
11454
  now,
11415
11455
  period,
11416
11456
  resource
11417
11457
  }) {
11418
11458
  const vendorEligible = await isEligibleReferredVendor({
11419
- affiliateCode,
11420
11459
  resourceId: resource.resourceId,
11421
11460
  resourceOwnerUserId: resource.resourceOwner.userId
11422
11461
  });
@@ -11446,10 +11485,6 @@ async function awardAffiliateVendorSubscriptionRewards(now = /* @__PURE__ */ new
11446
11485
  let skipped = 0;
11447
11486
  const seenPairs = /* @__PURE__ */ new Set();
11448
11487
  for (const affiliate of affiliates) {
11449
- const affiliateCode = normalizePromoCode(affiliate.affiliateCode);
11450
- if (!affiliateCode) {
11451
- continue;
11452
- }
11453
11488
  for (const resource of affiliate.affiliateResources) {
11454
11489
  if (!isEligibleVendorResource(resource)) {
11455
11490
  continue;
@@ -11461,7 +11496,6 @@ async function awardAffiliateVendorSubscriptionRewards(now = /* @__PURE__ */ new
11461
11496
  seenPairs.add(pairKey);
11462
11497
  const outcome = await processAffiliateVendorReferral({
11463
11498
  affiliate,
11464
- affiliateCode,
11465
11499
  createdAt,
11466
11500
  now,
11467
11501
  period,
@@ -11485,6 +11519,12 @@ async function findAffiliateByPromoCode(promoCode) {
11485
11519
  }).exec();
11486
11520
  }
11487
11521
 
11522
+ // src/service/promoCode/normalizePromoCode.ts
11523
+ function normalizePromoCode(decoratedPromoCode) {
11524
+ const normalized = decoratedPromoCode?.trim().toUpperCase();
11525
+ return normalized || null;
11526
+ }
11527
+
11488
11528
  // src/service/affiliate/normalizeAffiliatePromoCodes.ts
11489
11529
  function normalizeAffiliatePromoCodes(promoCodes) {
11490
11530
  const normalized = (promoCodes ?? []).map((code) => normalizePromoCode(code)).filter((code) => code !== null);