@timardex/cluemart-server-shared 1.1.19 → 1.1.21

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,141 @@ 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
+ shareableQrCode {
7848
+ ...ResourceImageFields
7849
+ }
7850
+ }
7851
+ ${RESOURCE_IMAGE_FIELDS_FRAGMENT}
7852
+ `;
7853
+ var COUPON_PARTICIPANT_USER_FIELDS_FRAGMENT = gql`
7854
+ fragment CouponParticipantUserFields on CouponParticipantUserType {
7855
+ couponCollectedCount
7856
+ couponRedeemedAt
7857
+ createdAt
7858
+ updatedAt
7859
+ userId
7860
+ }
7861
+ `;
7862
+ var COUPON_OPTION_FIELDS_FRAGMENT = gql`
7863
+ fragment CouponOptionFields on CouponOptionType {
7864
+ type
7865
+ buy
7866
+ get
7867
+ unit
7868
+ visits
7869
+ }
7870
+ `;
7871
+ var COUPON_REWARD_FIELDS_FRAGMENT = gql`
7872
+ fragment CouponRewardFields on CouponRewardType {
7873
+ vendorId
7874
+ productId
7875
+ quantity
7876
+ unit
7877
+ }
7878
+ `;
7879
+ var COUPON_DATA_PRODUCTS_FIELDS_FRAGMENT = gql`
7880
+ fragment CouponDataProductsFields on CouponDataProductsType {
7881
+ active
7882
+ productsList {
7883
+ ...VendorProductListFields
7884
+ }
7885
+ vendorLogo {
7886
+ ...ResourceImageFields
7887
+ }
7888
+ vendorName
7889
+ }
7890
+ ${VENDOR_PRODUCT_LIST_FIELDS_FRAGMENT}
7891
+ ${RESOURCE_IMAGE_FIELDS_FRAGMENT}
7892
+ `;
7893
+ var COUPON_DATA_FIELDS_FRAGMENT = gql`
7894
+ fragment CouponDataFields on CouponDataType {
7895
+ _id
7896
+ active
7897
+ couponCode {
7898
+ ...CouponCodeFields
7899
+ }
7900
+ couponDescription
7901
+ couponOption {
7902
+ ...CouponOptionFields
7903
+ }
7904
+ couponRewards {
7905
+ ...CouponRewardFields
7906
+ }
7907
+ createdAt
7908
+ endDate
7909
+ participantUsers {
7910
+ ...CouponParticipantUserFields
7911
+ }
7912
+ products {
7913
+ ...CouponDataProductsFields
7914
+ }
7915
+ resourceId
7916
+ resourceType
7917
+ startDate
7918
+ updatedAt
7919
+ }
7920
+ ${COUPON_CODE_FIELDS_FRAGMENT}
7921
+ ${COUPON_OPTION_FIELDS_FRAGMENT}
7922
+ ${COUPON_PARTICIPANT_USER_FIELDS_FRAGMENT}
7923
+ ${COUPON_REWARD_FIELDS_FRAGMENT}
7924
+ ${COUPON_DATA_PRODUCTS_FIELDS_FRAGMENT}
7925
+ `;
7926
+ var COUPON = gql`
7927
+ fragment CouponFields on CouponType {
7928
+ _id
7929
+ active
7930
+ couponData {
7931
+ ...CouponDataFields
7932
+ }
7933
+ createdAt
7934
+ deletedAt
7935
+ owner {
7936
+ ...OwnerFields
7937
+ }
7938
+ updatedAt
7939
+ }
7940
+ ${OWNER_FIELDS_FRAGMENT}
7941
+ ${COUPON_DATA_FIELDS_FRAGMENT}
7942
+ `;
7943
+ var GET_COUPONS = gql`
7944
+ query getCoupons {
7945
+ coupons {
7946
+ active {
7947
+ listName
7948
+ data {
7949
+ ...CouponFields
7950
+ }
7951
+ }
7952
+ owned {
7953
+ listName
7954
+ data {
7955
+ ...CouponFields
7956
+ }
7957
+ }
7958
+ scanned {
7959
+ listName
7960
+ data {
7961
+ ...CouponFields
7962
+ }
7963
+ }
7964
+ }
7965
+ }
7966
+ ${COUPON}
7967
+ `;
7968
+ var GET_COUPON = gql`
7969
+ query getCoupon($_id: ID!) {
7970
+ coupon(_id: $_id) {
7971
+ ...CouponFields
7972
+ }
7973
+ }
7974
+ ${COUPON}
7975
+ `;
7932
7976
  var CREATE_COUPON_MUTATION = gql`
7933
7977
  mutation createCoupon($input: CouponInputType!) {
7934
7978
  createCoupon(input: $input) {
@@ -9158,7 +9202,8 @@ var couponRewardSchema = new MongooseSchema13(
9158
9202
  var couponCodeSchema = new MongooseSchema13(
9159
9203
  {
9160
9204
  code: { required: true, type: String },
9161
- qrCode: { required: true, type: ResourceImageTypeSchema }
9205
+ qrCode: { required: true, type: ResourceImageTypeSchema },
9206
+ shareableQrCode: { required: true, type: ResourceImageTypeSchema }
9162
9207
  },
9163
9208
  { _id: false }
9164
9209
  );
@@ -9977,7 +10022,7 @@ var SHARE_RESOURCE_LABEL2 = {
9977
10022
  school: "School"
9978
10023
  };
9979
10024
 
9980
- // node_modules/@timardex/cluemart-shared/dist/chunk-OH7ZORGB.mjs
10025
+ // node_modules/@timardex/cluemart-shared/dist/chunk-Q3X2EHHF.mjs
9981
10026
  var PROMO_CODE_PREFIX2 = "CM-";
9982
10027
  var OBJECT_ID_PATH_SEGMENT2 = "[a-f0-9]{24}";
9983
10028
  var OBJECT_ID_PATH_SEGMENT_END2 = `${OBJECT_ID_PATH_SEGMENT2}$`;
@@ -10079,7 +10124,7 @@ var gameScreenIdentifierList2 = [
10079
10124
  }
10080
10125
  ];
10081
10126
 
10082
- // node_modules/@timardex/cluemart-shared/dist/chunk-IH3BEKPK.mjs
10127
+ // node_modules/@timardex/cluemart-shared/dist/chunk-UGWEWOUM.mjs
10083
10128
  var import_dayjs4 = __toESM(require("dayjs"), 1);
10084
10129
  var statusOptions2 = [
10085
10130
  ...Object.values(EnumInviteStatus2).map((status) => ({
@@ -11123,12 +11168,6 @@ function createAffiliateReward(rewardType, createdAt) {
11123
11168
  };
11124
11169
  }
11125
11170
 
11126
- // src/service/promoCode/normalizePromoCode.ts
11127
- function normalizePromoCode(decoratedPromoCode) {
11128
- const normalized = decoratedPromoCode?.trim().toUpperCase();
11129
- return normalized || null;
11130
- }
11131
-
11132
11171
  // src/service/saveNotificationsInDb.ts
11133
11172
  async function saveNotificationsInDb(payload) {
11134
11173
  const { data, message, title, type, userIds } = payload;
@@ -11308,10 +11347,9 @@ async function findAffiliatesWithActiveVendorReferrals() {
11308
11347
  }
11309
11348
  },
11310
11349
  deletedAt: null
11311
- }).select("_id affiliateCode affiliateResources owner").lean().exec();
11350
+ }).select("_id affiliateResources owner").lean().exec();
11312
11351
  }
11313
11352
  async function isEligibleReferredVendor({
11314
- affiliateCode,
11315
11353
  resourceId,
11316
11354
  resourceOwnerUserId
11317
11355
  }) {
@@ -11319,8 +11357,7 @@ async function isEligibleReferredVendor({
11319
11357
  _id: resourceId,
11320
11358
  active: true,
11321
11359
  deletedAt: null,
11322
- "owner.userId": resourceOwnerUserId,
11323
- promoCodes: affiliateCode
11360
+ "owner.userId": resourceOwnerUserId
11324
11361
  }).exec();
11325
11362
  return Boolean(match);
11326
11363
  }
@@ -11409,14 +11446,12 @@ async function tryAwardSubscriptionReward({
11409
11446
  }
11410
11447
  async function processAffiliateVendorReferral({
11411
11448
  affiliate,
11412
- affiliateCode,
11413
11449
  createdAt,
11414
11450
  now,
11415
11451
  period,
11416
11452
  resource
11417
11453
  }) {
11418
11454
  const vendorEligible = await isEligibleReferredVendor({
11419
- affiliateCode,
11420
11455
  resourceId: resource.resourceId,
11421
11456
  resourceOwnerUserId: resource.resourceOwner.userId
11422
11457
  });
@@ -11446,10 +11481,6 @@ async function awardAffiliateVendorSubscriptionRewards(now = /* @__PURE__ */ new
11446
11481
  let skipped = 0;
11447
11482
  const seenPairs = /* @__PURE__ */ new Set();
11448
11483
  for (const affiliate of affiliates) {
11449
- const affiliateCode = normalizePromoCode(affiliate.affiliateCode);
11450
- if (!affiliateCode) {
11451
- continue;
11452
- }
11453
11484
  for (const resource of affiliate.affiliateResources) {
11454
11485
  if (!isEligibleVendorResource(resource)) {
11455
11486
  continue;
@@ -11461,7 +11492,6 @@ async function awardAffiliateVendorSubscriptionRewards(now = /* @__PURE__ */ new
11461
11492
  seenPairs.add(pairKey);
11462
11493
  const outcome = await processAffiliateVendorReferral({
11463
11494
  affiliate,
11464
- affiliateCode,
11465
11495
  createdAt,
11466
11496
  now,
11467
11497
  period,
@@ -11485,6 +11515,12 @@ async function findAffiliateByPromoCode(promoCode) {
11485
11515
  }).exec();
11486
11516
  }
11487
11517
 
11518
+ // src/service/promoCode/normalizePromoCode.ts
11519
+ function normalizePromoCode(decoratedPromoCode) {
11520
+ const normalized = decoratedPromoCode?.trim().toUpperCase();
11521
+ return normalized || null;
11522
+ }
11523
+
11488
11524
  // src/service/affiliate/normalizeAffiliatePromoCodes.ts
11489
11525
  function normalizeAffiliatePromoCodes(promoCodes) {
11490
11526
  const normalized = (promoCodes ?? []).map((code) => normalizePromoCode(code)).filter((code) => code !== null);