@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.
@@ -42,7 +42,7 @@ import {
42
42
  termsAgreementSchema,
43
43
  userLicenseSchema,
44
44
  vendorProductTypeSchema
45
- } from "../chunk-XOFBUTNJ.mjs";
45
+ } from "../chunk-3JRVRK2N.mjs";
46
46
  export {
47
47
  APP_SETTINGS_ID,
48
48
  AdModel,
@@ -4981,6 +4981,12 @@ var OWNER_FIELDS_FRAGMENT = gql`
4981
4981
  userId
4982
4982
  }
4983
4983
  `;
4984
+ var PRODUCT_COUPON_FIELDS_FRAGMENT = gql`
4985
+ fragment ProductCouponFields on ProductCouponType {
4986
+ couponDocumentId
4987
+ couponId
4988
+ }
4989
+ `;
4984
4990
  var CATEGORY_FIELDS_FRAGMENT = gql`
4985
4991
  fragment CategoryFields on CategoryType {
4986
4992
  id
@@ -5454,109 +5460,6 @@ var GET_EVENT_INFO = gql`
5454
5460
  }
5455
5461
  ${EVENT_INFO}
5456
5462
  `;
5457
- var PRODUCT_COUPON_FIELDS_FRAGMENT = gql`
5458
- fragment ProductCouponFields on ProductCouponType {
5459
- couponDocumentId
5460
- couponId
5461
- }
5462
- `;
5463
- var COUPON_CODE_FIELDS_FRAGMENT = gql`
5464
- fragment CouponCodeFields on CouponCodeType {
5465
- code
5466
- qrCode {
5467
- ...ResourceImageFields
5468
- }
5469
- }
5470
- ${RESOURCE_IMAGE_FIELDS_FRAGMENT}
5471
- `;
5472
- var COUPON_PARTICIPANT_USER_FIELDS_FRAGMENT = gql`
5473
- fragment CouponParticipantUserFields on CouponParticipantUserType {
5474
- couponCollectedCount
5475
- couponRedeemedAt
5476
- createdAt
5477
- updatedAt
5478
- userId
5479
- }
5480
- `;
5481
- var COUPON_OPTION_FIELDS_FRAGMENT = gql`
5482
- fragment CouponOptionFields on CouponOptionType {
5483
- type
5484
- buy
5485
- get
5486
- unit
5487
- visits
5488
- }
5489
- `;
5490
- var COUPON_REWARD_FIELDS_FRAGMENT = gql`
5491
- fragment CouponRewardFields on CouponRewardType {
5492
- vendorId
5493
- productId
5494
- quantity
5495
- unit
5496
- }
5497
- `;
5498
- var COUPON_DATA_FIELDS_FRAGMENT = gql`
5499
- fragment CouponDataFields on CouponDataType {
5500
- _id
5501
- active
5502
- couponCode {
5503
- ...CouponCodeFields
5504
- }
5505
- couponDescription
5506
- couponOption {
5507
- ...CouponOptionFields
5508
- }
5509
- couponRewards {
5510
- ...CouponRewardFields
5511
- }
5512
- createdAt
5513
- endDate
5514
- participantUsers {
5515
- ...CouponParticipantUserFields
5516
- }
5517
- resourceId
5518
- resourceType
5519
- startDate
5520
- updatedAt
5521
- }
5522
- ${COUPON_CODE_FIELDS_FRAGMENT}
5523
- ${COUPON_OPTION_FIELDS_FRAGMENT}
5524
- ${COUPON_PARTICIPANT_USER_FIELDS_FRAGMENT}
5525
- ${COUPON_REWARD_FIELDS_FRAGMENT}
5526
- `;
5527
- var COUPON = gql`
5528
- fragment CouponFields on CouponType {
5529
- _id
5530
- active
5531
- couponData {
5532
- ...CouponDataFields
5533
- }
5534
- createdAt
5535
- deletedAt
5536
- owner {
5537
- ...OwnerFields
5538
- }
5539
- updatedAt
5540
- }
5541
- ${OWNER_FIELDS_FRAGMENT}
5542
- ${COUPON_DATA_FIELDS_FRAGMENT}
5543
- `;
5544
- var GET_COUPONS = gql`
5545
- query getCoupons {
5546
- coupons {
5547
- ...CouponFields
5548
- }
5549
- }
5550
- ${COUPON}
5551
- `;
5552
- var GET_COUPON = gql`
5553
- query getCoupon($_id: ID!) {
5554
- coupon(_id: $_id) {
5555
- ...CouponFields
5556
- }
5557
- }
5558
- ${COUPON}
5559
- `;
5560
5463
  var VENDOR_DATETIME_FIELDS_FRAGMENT = gql`
5561
5464
  fragment VendorDateTimeFields on VendorDateTimeType {
5562
5465
  dateStatus
@@ -5583,6 +5486,15 @@ var VENDOR_PRODUCT_LIST_FIELDS_FRAGMENT = gql`
5583
5486
  }
5584
5487
  ${PRODUCT_COUPON_FIELDS_FRAGMENT}
5585
5488
  `;
5489
+ var VENDOR_PRODUCTS_FIELDS_FRAGMENT = gql`
5490
+ fragment VendorProductsFields on VendorProductsType {
5491
+ active
5492
+ productsList {
5493
+ ...VendorProductListFields
5494
+ }
5495
+ }
5496
+ ${VENDOR_PRODUCT_LIST_FIELDS_FRAGMENT}
5497
+ `;
5586
5498
  var VENDOR = gql`
5587
5499
  fragment VendorFields on VendorType {
5588
5500
  _id
@@ -5632,10 +5544,7 @@ var VENDOR = gql`
5632
5544
  ...OwnerFields
5633
5545
  }
5634
5546
  products {
5635
- active
5636
- productsList {
5637
- ...VendorProductListFields
5638
- }
5547
+ ...VendorProductsFields
5639
5548
  }
5640
5549
  promoCodes
5641
5550
  posterUsage {
@@ -5677,7 +5586,7 @@ var VENDOR = gql`
5677
5586
  ${RESOURCE_IMAGE_FIELDS_FRAGMENT}
5678
5587
  ${SOCIAL_MEDIA_FIELDS_FRAGMENT}
5679
5588
  ${POSTER_USAGE_FIELDS_FRAGMENT}
5680
- ${VENDOR_PRODUCT_LIST_FIELDS_FRAGMENT}
5589
+ ${VENDOR_PRODUCTS_FIELDS_FRAGMENT}
5681
5590
  ${CONTACT_DETAILS_FIELDS_FRAGMENT}
5682
5591
  ${TERMS_AGREEMENT_FIELDS_FRAGMENT}
5683
5592
  ${RELATION_DATES_FRAGMENT}
@@ -7883,6 +7792,141 @@ var ASSIGN_AFFILIATE_BONUS_REWARD_MUTATION = gql`
7883
7792
  }
7884
7793
  ${AFFILIATE_FIELDS_FRAGMENT}
7885
7794
  `;
7795
+ var COUPON_CODE_FIELDS_FRAGMENT = gql`
7796
+ fragment CouponCodeFields on CouponCodeType {
7797
+ code
7798
+ qrCode {
7799
+ ...ResourceImageFields
7800
+ }
7801
+ shareableQrCode {
7802
+ ...ResourceImageFields
7803
+ }
7804
+ }
7805
+ ${RESOURCE_IMAGE_FIELDS_FRAGMENT}
7806
+ `;
7807
+ var COUPON_PARTICIPANT_USER_FIELDS_FRAGMENT = gql`
7808
+ fragment CouponParticipantUserFields on CouponParticipantUserType {
7809
+ couponCollectedCount
7810
+ couponRedeemedAt
7811
+ createdAt
7812
+ updatedAt
7813
+ userId
7814
+ }
7815
+ `;
7816
+ var COUPON_OPTION_FIELDS_FRAGMENT = gql`
7817
+ fragment CouponOptionFields on CouponOptionType {
7818
+ type
7819
+ buy
7820
+ get
7821
+ unit
7822
+ visits
7823
+ }
7824
+ `;
7825
+ var COUPON_REWARD_FIELDS_FRAGMENT = gql`
7826
+ fragment CouponRewardFields on CouponRewardType {
7827
+ vendorId
7828
+ productId
7829
+ quantity
7830
+ unit
7831
+ }
7832
+ `;
7833
+ var COUPON_DATA_PRODUCTS_FIELDS_FRAGMENT = gql`
7834
+ fragment CouponDataProductsFields on CouponDataProductsType {
7835
+ active
7836
+ productsList {
7837
+ ...VendorProductListFields
7838
+ }
7839
+ vendorLogo {
7840
+ ...ResourceImageFields
7841
+ }
7842
+ vendorName
7843
+ }
7844
+ ${VENDOR_PRODUCT_LIST_FIELDS_FRAGMENT}
7845
+ ${RESOURCE_IMAGE_FIELDS_FRAGMENT}
7846
+ `;
7847
+ var COUPON_DATA_FIELDS_FRAGMENT = gql`
7848
+ fragment CouponDataFields on CouponDataType {
7849
+ _id
7850
+ active
7851
+ couponCode {
7852
+ ...CouponCodeFields
7853
+ }
7854
+ couponDescription
7855
+ couponOption {
7856
+ ...CouponOptionFields
7857
+ }
7858
+ couponRewards {
7859
+ ...CouponRewardFields
7860
+ }
7861
+ createdAt
7862
+ endDate
7863
+ participantUsers {
7864
+ ...CouponParticipantUserFields
7865
+ }
7866
+ products {
7867
+ ...CouponDataProductsFields
7868
+ }
7869
+ resourceId
7870
+ resourceType
7871
+ startDate
7872
+ updatedAt
7873
+ }
7874
+ ${COUPON_CODE_FIELDS_FRAGMENT}
7875
+ ${COUPON_OPTION_FIELDS_FRAGMENT}
7876
+ ${COUPON_PARTICIPANT_USER_FIELDS_FRAGMENT}
7877
+ ${COUPON_REWARD_FIELDS_FRAGMENT}
7878
+ ${COUPON_DATA_PRODUCTS_FIELDS_FRAGMENT}
7879
+ `;
7880
+ var COUPON = gql`
7881
+ fragment CouponFields on CouponType {
7882
+ _id
7883
+ active
7884
+ couponData {
7885
+ ...CouponDataFields
7886
+ }
7887
+ createdAt
7888
+ deletedAt
7889
+ owner {
7890
+ ...OwnerFields
7891
+ }
7892
+ updatedAt
7893
+ }
7894
+ ${OWNER_FIELDS_FRAGMENT}
7895
+ ${COUPON_DATA_FIELDS_FRAGMENT}
7896
+ `;
7897
+ var GET_COUPONS = gql`
7898
+ query getCoupons {
7899
+ coupons {
7900
+ active {
7901
+ listName
7902
+ data {
7903
+ ...CouponFields
7904
+ }
7905
+ }
7906
+ owned {
7907
+ listName
7908
+ data {
7909
+ ...CouponFields
7910
+ }
7911
+ }
7912
+ scanned {
7913
+ listName
7914
+ data {
7915
+ ...CouponFields
7916
+ }
7917
+ }
7918
+ }
7919
+ }
7920
+ ${COUPON}
7921
+ `;
7922
+ var GET_COUPON = gql`
7923
+ query getCoupon($_id: ID!) {
7924
+ coupon(_id: $_id) {
7925
+ ...CouponFields
7926
+ }
7927
+ }
7928
+ ${COUPON}
7929
+ `;
7886
7930
  var CREATE_COUPON_MUTATION = gql`
7887
7931
  mutation createCoupon($input: CouponInputType!) {
7888
7932
  createCoupon(input: $input) {
@@ -9112,7 +9156,8 @@ var couponRewardSchema = new MongooseSchema13(
9112
9156
  var couponCodeSchema = new MongooseSchema13(
9113
9157
  {
9114
9158
  code: { required: true, type: String },
9115
- qrCode: { required: true, type: ResourceImageTypeSchema }
9159
+ qrCode: { required: true, type: ResourceImageTypeSchema },
9160
+ shareableQrCode: { required: true, type: ResourceImageTypeSchema }
9116
9161
  },
9117
9162
  { _id: false }
9118
9163
  );
@@ -9931,7 +9976,7 @@ var SHARE_RESOURCE_LABEL2 = {
9931
9976
  school: "School"
9932
9977
  };
9933
9978
 
9934
- // node_modules/@timardex/cluemart-shared/dist/chunk-OH7ZORGB.mjs
9979
+ // node_modules/@timardex/cluemart-shared/dist/chunk-Q3X2EHHF.mjs
9935
9980
  var PROMO_CODE_PREFIX2 = "CM-";
9936
9981
  var OBJECT_ID_PATH_SEGMENT2 = "[a-f0-9]{24}";
9937
9982
  var OBJECT_ID_PATH_SEGMENT_END2 = `${OBJECT_ID_PATH_SEGMENT2}$`;
@@ -10033,7 +10078,7 @@ var gameScreenIdentifierList2 = [
10033
10078
  }
10034
10079
  ];
10035
10080
 
10036
- // node_modules/@timardex/cluemart-shared/dist/chunk-IH3BEKPK.mjs
10081
+ // node_modules/@timardex/cluemart-shared/dist/chunk-UGWEWOUM.mjs
10037
10082
  var import_dayjs4 = __toESM(require("dayjs"), 1);
10038
10083
  var statusOptions2 = [
10039
10084
  ...Object.values(EnumInviteStatus2).map((status) => ({
@@ -11077,12 +11122,6 @@ function createAffiliateReward(rewardType, createdAt) {
11077
11122
  };
11078
11123
  }
11079
11124
 
11080
- // src/service/promoCode/normalizePromoCode.ts
11081
- function normalizePromoCode(decoratedPromoCode) {
11082
- const normalized = decoratedPromoCode?.trim().toUpperCase();
11083
- return normalized || null;
11084
- }
11085
-
11086
11125
  // src/service/saveNotificationsInDb.ts
11087
11126
  async function saveNotificationsInDb(payload) {
11088
11127
  const { data, message, title, type, userIds } = payload;
@@ -11262,10 +11301,9 @@ async function findAffiliatesWithActiveVendorReferrals() {
11262
11301
  }
11263
11302
  },
11264
11303
  deletedAt: null
11265
- }).select("_id affiliateCode affiliateResources owner").lean().exec();
11304
+ }).select("_id affiliateResources owner").lean().exec();
11266
11305
  }
11267
11306
  async function isEligibleReferredVendor({
11268
- affiliateCode,
11269
11307
  resourceId,
11270
11308
  resourceOwnerUserId
11271
11309
  }) {
@@ -11273,8 +11311,7 @@ async function isEligibleReferredVendor({
11273
11311
  _id: resourceId,
11274
11312
  active: true,
11275
11313
  deletedAt: null,
11276
- "owner.userId": resourceOwnerUserId,
11277
- promoCodes: affiliateCode
11314
+ "owner.userId": resourceOwnerUserId
11278
11315
  }).exec();
11279
11316
  return Boolean(match);
11280
11317
  }
@@ -11363,14 +11400,12 @@ async function tryAwardSubscriptionReward({
11363
11400
  }
11364
11401
  async function processAffiliateVendorReferral({
11365
11402
  affiliate,
11366
- affiliateCode,
11367
11403
  createdAt,
11368
11404
  now,
11369
11405
  period,
11370
11406
  resource
11371
11407
  }) {
11372
11408
  const vendorEligible = await isEligibleReferredVendor({
11373
- affiliateCode,
11374
11409
  resourceId: resource.resourceId,
11375
11410
  resourceOwnerUserId: resource.resourceOwner.userId
11376
11411
  });
@@ -11400,10 +11435,6 @@ async function awardAffiliateVendorSubscriptionRewards(now = /* @__PURE__ */ new
11400
11435
  let skipped = 0;
11401
11436
  const seenPairs = /* @__PURE__ */ new Set();
11402
11437
  for (const affiliate of affiliates) {
11403
- const affiliateCode = normalizePromoCode(affiliate.affiliateCode);
11404
- if (!affiliateCode) {
11405
- continue;
11406
- }
11407
11438
  for (const resource of affiliate.affiliateResources) {
11408
11439
  if (!isEligibleVendorResource(resource)) {
11409
11440
  continue;
@@ -11415,7 +11446,6 @@ async function awardAffiliateVendorSubscriptionRewards(now = /* @__PURE__ */ new
11415
11446
  seenPairs.add(pairKey);
11416
11447
  const outcome = await processAffiliateVendorReferral({
11417
11448
  affiliate,
11418
- affiliateCode,
11419
11449
  createdAt,
11420
11450
  now,
11421
11451
  period,
@@ -11439,6 +11469,12 @@ async function findAffiliateByPromoCode(promoCode) {
11439
11469
  }).exec();
11440
11470
  }
11441
11471
 
11472
+ // src/service/promoCode/normalizePromoCode.ts
11473
+ function normalizePromoCode(decoratedPromoCode) {
11474
+ const normalized = decoratedPromoCode?.trim().toUpperCase();
11475
+ return normalized || null;
11476
+ }
11477
+
11442
11478
  // src/service/affiliate/normalizeAffiliatePromoCodes.ts
11443
11479
  function normalizeAffiliatePromoCodes(promoCodes) {
11444
11480
  const normalized = (promoCodes ?? []).map((code) => normalizePromoCode(code)).filter((code) => code !== null);