@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.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) {
@@ -7838,8 +7887,16 @@ var CREATE_COUPON_MUTATION = gql`
7838
7887
  ${COUPON}
7839
7888
  `;
7840
7889
  var UPDATE_COUPON_MUTATION = gql`
7841
- mutation updateCoupon($_id: ID!, $input: CouponInputType!) {
7842
- updateCoupon(_id: $_id, input: $input) {
7890
+ mutation updateCoupon(
7891
+ $couponDocumentId: ID!
7892
+ $couponId: ID!
7893
+ $input: CouponInputType!
7894
+ ) {
7895
+ updateCoupon(
7896
+ couponDocumentId: $couponDocumentId
7897
+ couponId: $couponId
7898
+ input: $input
7899
+ ) {
7843
7900
  data {
7844
7901
  ...CouponFields
7845
7902
  }
@@ -7849,8 +7906,8 @@ var UPDATE_COUPON_MUTATION = gql`
7849
7906
  ${COUPON}
7850
7907
  `;
7851
7908
  var DELETE_COUPON_MUTATION = gql`
7852
- mutation deleteCoupon($_id: ID!) {
7853
- deleteCoupon(_id: $_id) {
7909
+ mutation deleteCoupon($couponDocumentId: ID!, $couponId: ID!) {
7910
+ deleteCoupon(couponDocumentId: $couponDocumentId, couponId: $couponId) {
7854
7911
  data
7855
7912
  message
7856
7913
  }
@@ -9116,7 +9173,7 @@ var vendorProductTypeSchema = new MongooseSchema14(
9116
9173
  );
9117
9174
  var productWrapperSchema = new MongooseSchema14(
9118
9175
  {
9119
- active: { default: false, required: true, type: Boolean },
9176
+ active: { default: false, required: false, type: Boolean },
9120
9177
  productsList: { required: false, type: [vendorProductTypeSchema] }
9121
9178
  },
9122
9179
  { _id: false }
@@ -9866,7 +9923,7 @@ var SHARE_RESOURCE_LABEL2 = {
9866
9923
  school: "School"
9867
9924
  };
9868
9925
 
9869
- // node_modules/@timardex/cluemart-shared/dist/chunk-UV5GH6NI.mjs
9926
+ // node_modules/@timardex/cluemart-shared/dist/chunk-3HRC67D3.mjs
9870
9927
  var PROMO_CODE_PREFIX2 = "CM-";
9871
9928
  var OBJECT_ID_PATH_SEGMENT2 = "[a-f0-9]{24}";
9872
9929
  var OBJECT_ID_PATH_SEGMENT_END2 = `${OBJECT_ID_PATH_SEGMENT2}$`;
@@ -9968,7 +10025,7 @@ var gameScreenIdentifierList2 = [
9968
10025
  }
9969
10026
  ];
9970
10027
 
9971
- // node_modules/@timardex/cluemart-shared/dist/chunk-3UYXNSNB.mjs
10028
+ // node_modules/@timardex/cluemart-shared/dist/chunk-E7KKXQDI.mjs
9972
10029
  import dayjs4 from "dayjs";
9973
10030
  var statusOptions2 = [
9974
10031
  ...Object.values(EnumInviteStatus2).map((status) => ({
@@ -11012,12 +11069,6 @@ function createAffiliateReward(rewardType, createdAt) {
11012
11069
  };
11013
11070
  }
11014
11071
 
11015
- // src/service/promoCode/normalizePromoCode.ts
11016
- function normalizePromoCode(decoratedPromoCode) {
11017
- const normalized = decoratedPromoCode?.trim().toUpperCase();
11018
- return normalized || null;
11019
- }
11020
-
11021
11072
  // src/service/saveNotificationsInDb.ts
11022
11073
  async function saveNotificationsInDb(payload) {
11023
11074
  const { data, message, title, type, userIds } = payload;
@@ -11197,10 +11248,9 @@ async function findAffiliatesWithActiveVendorReferrals() {
11197
11248
  }
11198
11249
  },
11199
11250
  deletedAt: null
11200
- }).select("_id affiliateCode affiliateResources owner").lean().exec();
11251
+ }).select("_id affiliateResources owner").lean().exec();
11201
11252
  }
11202
11253
  async function isEligibleReferredVendor({
11203
- affiliateCode,
11204
11254
  resourceId,
11205
11255
  resourceOwnerUserId
11206
11256
  }) {
@@ -11208,8 +11258,7 @@ async function isEligibleReferredVendor({
11208
11258
  _id: resourceId,
11209
11259
  active: true,
11210
11260
  deletedAt: null,
11211
- "owner.userId": resourceOwnerUserId,
11212
- promoCodes: affiliateCode
11261
+ "owner.userId": resourceOwnerUserId
11213
11262
  }).exec();
11214
11263
  return Boolean(match);
11215
11264
  }
@@ -11298,14 +11347,12 @@ async function tryAwardSubscriptionReward({
11298
11347
  }
11299
11348
  async function processAffiliateVendorReferral({
11300
11349
  affiliate,
11301
- affiliateCode,
11302
11350
  createdAt,
11303
11351
  now,
11304
11352
  period,
11305
11353
  resource
11306
11354
  }) {
11307
11355
  const vendorEligible = await isEligibleReferredVendor({
11308
- affiliateCode,
11309
11356
  resourceId: resource.resourceId,
11310
11357
  resourceOwnerUserId: resource.resourceOwner.userId
11311
11358
  });
@@ -11335,10 +11382,6 @@ async function awardAffiliateVendorSubscriptionRewards(now = /* @__PURE__ */ new
11335
11382
  let skipped = 0;
11336
11383
  const seenPairs = /* @__PURE__ */ new Set();
11337
11384
  for (const affiliate of affiliates) {
11338
- const affiliateCode = normalizePromoCode(affiliate.affiliateCode);
11339
- if (!affiliateCode) {
11340
- continue;
11341
- }
11342
11385
  for (const resource of affiliate.affiliateResources) {
11343
11386
  if (!isEligibleVendorResource(resource)) {
11344
11387
  continue;
@@ -11350,7 +11393,6 @@ async function awardAffiliateVendorSubscriptionRewards(now = /* @__PURE__ */ new
11350
11393
  seenPairs.add(pairKey);
11351
11394
  const outcome = await processAffiliateVendorReferral({
11352
11395
  affiliate,
11353
- affiliateCode,
11354
11396
  createdAt,
11355
11397
  now,
11356
11398
  period,
@@ -11374,6 +11416,12 @@ async function findAffiliateByPromoCode(promoCode) {
11374
11416
  }).exec();
11375
11417
  }
11376
11418
 
11419
+ // src/service/promoCode/normalizePromoCode.ts
11420
+ function normalizePromoCode(decoratedPromoCode) {
11421
+ const normalized = decoratedPromoCode?.trim().toUpperCase();
11422
+ return normalized || null;
11423
+ }
11424
+
11377
11425
  // src/service/affiliate/normalizeAffiliatePromoCodes.ts
11378
11426
  function normalizeAffiliatePromoCodes(promoCodes) {
11379
11427
  const normalized = (promoCodes ?? []).map((code) => normalizePromoCode(code)).filter((code) => code !== null);