@timardex/cluemart-server-shared 1.1.18 → 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) {
@@ -7941,8 +7990,16 @@ var CREATE_COUPON_MUTATION = gql`
7941
7990
  ${COUPON}
7942
7991
  `;
7943
7992
  var UPDATE_COUPON_MUTATION = gql`
7944
- mutation updateCoupon($_id: ID!, $input: CouponInputType!) {
7945
- updateCoupon(_id: $_id, input: $input) {
7993
+ mutation updateCoupon(
7994
+ $couponDocumentId: ID!
7995
+ $couponId: ID!
7996
+ $input: CouponInputType!
7997
+ ) {
7998
+ updateCoupon(
7999
+ couponDocumentId: $couponDocumentId
8000
+ couponId: $couponId
8001
+ input: $input
8002
+ ) {
7946
8003
  data {
7947
8004
  ...CouponFields
7948
8005
  }
@@ -7952,8 +8009,8 @@ var UPDATE_COUPON_MUTATION = gql`
7952
8009
  ${COUPON}
7953
8010
  `;
7954
8011
  var DELETE_COUPON_MUTATION = gql`
7955
- mutation deleteCoupon($_id: ID!) {
7956
- deleteCoupon(_id: $_id) {
8012
+ mutation deleteCoupon($couponDocumentId: ID!, $couponId: ID!) {
8013
+ deleteCoupon(couponDocumentId: $couponDocumentId, couponId: $couponId) {
7957
8014
  data
7958
8015
  message
7959
8016
  }
@@ -9219,7 +9276,7 @@ var vendorProductTypeSchema = new MongooseSchema14(
9219
9276
  );
9220
9277
  var productWrapperSchema = new MongooseSchema14(
9221
9278
  {
9222
- active: { default: false, required: true, type: Boolean },
9279
+ active: { default: false, required: false, type: Boolean },
9223
9280
  productsList: { required: false, type: [vendorProductTypeSchema] }
9224
9281
  },
9225
9282
  { _id: false }
@@ -9969,7 +10026,7 @@ var SHARE_RESOURCE_LABEL2 = {
9969
10026
  school: "School"
9970
10027
  };
9971
10028
 
9972
- // node_modules/@timardex/cluemart-shared/dist/chunk-UV5GH6NI.mjs
10029
+ // node_modules/@timardex/cluemart-shared/dist/chunk-3HRC67D3.mjs
9973
10030
  var PROMO_CODE_PREFIX2 = "CM-";
9974
10031
  var OBJECT_ID_PATH_SEGMENT2 = "[a-f0-9]{24}";
9975
10032
  var OBJECT_ID_PATH_SEGMENT_END2 = `${OBJECT_ID_PATH_SEGMENT2}$`;
@@ -10071,7 +10128,7 @@ var gameScreenIdentifierList2 = [
10071
10128
  }
10072
10129
  ];
10073
10130
 
10074
- // node_modules/@timardex/cluemart-shared/dist/chunk-3UYXNSNB.mjs
10131
+ // node_modules/@timardex/cluemart-shared/dist/chunk-E7KKXQDI.mjs
10075
10132
  var import_dayjs4 = __toESM(require("dayjs"), 1);
10076
10133
  var statusOptions2 = [
10077
10134
  ...Object.values(EnumInviteStatus2).map((status) => ({
@@ -11115,12 +11172,6 @@ function createAffiliateReward(rewardType, createdAt) {
11115
11172
  };
11116
11173
  }
11117
11174
 
11118
- // src/service/promoCode/normalizePromoCode.ts
11119
- function normalizePromoCode(decoratedPromoCode) {
11120
- const normalized = decoratedPromoCode?.trim().toUpperCase();
11121
- return normalized || null;
11122
- }
11123
-
11124
11175
  // src/service/saveNotificationsInDb.ts
11125
11176
  async function saveNotificationsInDb(payload) {
11126
11177
  const { data, message, title, type, userIds } = payload;
@@ -11300,10 +11351,9 @@ async function findAffiliatesWithActiveVendorReferrals() {
11300
11351
  }
11301
11352
  },
11302
11353
  deletedAt: null
11303
- }).select("_id affiliateCode affiliateResources owner").lean().exec();
11354
+ }).select("_id affiliateResources owner").lean().exec();
11304
11355
  }
11305
11356
  async function isEligibleReferredVendor({
11306
- affiliateCode,
11307
11357
  resourceId,
11308
11358
  resourceOwnerUserId
11309
11359
  }) {
@@ -11311,8 +11361,7 @@ async function isEligibleReferredVendor({
11311
11361
  _id: resourceId,
11312
11362
  active: true,
11313
11363
  deletedAt: null,
11314
- "owner.userId": resourceOwnerUserId,
11315
- promoCodes: affiliateCode
11364
+ "owner.userId": resourceOwnerUserId
11316
11365
  }).exec();
11317
11366
  return Boolean(match);
11318
11367
  }
@@ -11401,14 +11450,12 @@ async function tryAwardSubscriptionReward({
11401
11450
  }
11402
11451
  async function processAffiliateVendorReferral({
11403
11452
  affiliate,
11404
- affiliateCode,
11405
11453
  createdAt,
11406
11454
  now,
11407
11455
  period,
11408
11456
  resource
11409
11457
  }) {
11410
11458
  const vendorEligible = await isEligibleReferredVendor({
11411
- affiliateCode,
11412
11459
  resourceId: resource.resourceId,
11413
11460
  resourceOwnerUserId: resource.resourceOwner.userId
11414
11461
  });
@@ -11438,10 +11485,6 @@ async function awardAffiliateVendorSubscriptionRewards(now = /* @__PURE__ */ new
11438
11485
  let skipped = 0;
11439
11486
  const seenPairs = /* @__PURE__ */ new Set();
11440
11487
  for (const affiliate of affiliates) {
11441
- const affiliateCode = normalizePromoCode(affiliate.affiliateCode);
11442
- if (!affiliateCode) {
11443
- continue;
11444
- }
11445
11488
  for (const resource of affiliate.affiliateResources) {
11446
11489
  if (!isEligibleVendorResource(resource)) {
11447
11490
  continue;
@@ -11453,7 +11496,6 @@ async function awardAffiliateVendorSubscriptionRewards(now = /* @__PURE__ */ new
11453
11496
  seenPairs.add(pairKey);
11454
11497
  const outcome = await processAffiliateVendorReferral({
11455
11498
  affiliate,
11456
- affiliateCode,
11457
11499
  createdAt,
11458
11500
  now,
11459
11501
  period,
@@ -11477,6 +11519,12 @@ async function findAffiliateByPromoCode(promoCode) {
11477
11519
  }).exec();
11478
11520
  }
11479
11521
 
11522
+ // src/service/promoCode/normalizePromoCode.ts
11523
+ function normalizePromoCode(decoratedPromoCode) {
11524
+ const normalized = decoratedPromoCode?.trim().toUpperCase();
11525
+ return normalized || null;
11526
+ }
11527
+
11480
11528
  // src/service/affiliate/normalizeAffiliatePromoCodes.ts
11481
11529
  function normalizeAffiliatePromoCodes(promoCodes) {
11482
11530
  const normalized = (promoCodes ?? []).map((code) => normalizePromoCode(code)).filter((code) => code !== null);