@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.
@@ -28,8 +28,8 @@ type AwardAffiliateVendorSubscriptionRewardsResult = {
28
28
  * Eligibility per affiliate resource:
29
29
  * - Affiliate is not soft-deleted
30
30
  * - Linked `affiliateResources` entry is vendor, `resourceActive`, and not deleted
31
- * - Vendor is active, not deleted, has the affiliate promo code, and
32
- * `owner.userId` matches `affiliateResources.resourceOwner.userId`
31
+ * - Vendor is active, not deleted, and `owner.userId` matches
32
+ * `affiliateResources.resourceOwner.userId`
33
33
  * - `affiliateResources.resourceOwner` has a non-expired Standard / Pro / Pro+ vendor licence
34
34
  *
35
35
  * Reward type follows the owner's highest valid licence + Stripe paying status:
@@ -28,8 +28,8 @@ type AwardAffiliateVendorSubscriptionRewardsResult = {
28
28
  * Eligibility per affiliate resource:
29
29
  * - Affiliate is not soft-deleted
30
30
  * - Linked `affiliateResources` entry is vendor, `resourceActive`, and not deleted
31
- * - Vendor is active, not deleted, has the affiliate promo code, and
32
- * `owner.userId` matches `affiliateResources.resourceOwner.userId`
31
+ * - Vendor is active, not deleted, and `owner.userId` matches
32
+ * `affiliateResources.resourceOwner.userId`
33
33
  * - `affiliateResources.resourceOwner` has a non-expired Standard / Pro / Pro+ vendor licence
34
34
  *
35
35
  * Reward type follows the owner's highest valid licence + Stripe paying status:
@@ -22,7 +22,7 @@ import {
22
22
  VendorModel,
23
23
  dateFormat,
24
24
  timeFormat
25
- } from "../chunk-XOFBUTNJ.mjs";
25
+ } from "../chunk-3JRVRK2N.mjs";
26
26
  import "../chunk-6PNG5BI5.mjs";
27
27
 
28
28
  // src/service/promoCode/constants.ts
@@ -95,7 +95,7 @@ var SHARE_RESOURCE_LABEL = {
95
95
  school: "School"
96
96
  };
97
97
 
98
- // node_modules/@timardex/cluemart-shared/dist/chunk-OH7ZORGB.mjs
98
+ // node_modules/@timardex/cluemart-shared/dist/chunk-Q3X2EHHF.mjs
99
99
  var PROMO_CODE_PREFIX = "CM-";
100
100
  var OBJECT_ID_PATH_SEGMENT = "[a-f0-9]{24}";
101
101
  var OBJECT_ID_PATH_SEGMENT_END = `${OBJECT_ID_PATH_SEGMENT}$`;
@@ -197,7 +197,7 @@ var gameScreenIdentifierList = [
197
197
  }
198
198
  ];
199
199
 
200
- // node_modules/@timardex/cluemart-shared/dist/chunk-IH3BEKPK.mjs
200
+ // node_modules/@timardex/cluemart-shared/dist/chunk-UGWEWOUM.mjs
201
201
  import dayjs2 from "dayjs";
202
202
  var statusOptions = [
203
203
  ...Object.values(EnumInviteStatus2).map((status) => ({
@@ -1241,12 +1241,6 @@ function createAffiliateReward(rewardType, createdAt) {
1241
1241
  };
1242
1242
  }
1243
1243
 
1244
- // src/service/promoCode/normalizePromoCode.ts
1245
- function normalizePromoCode(decoratedPromoCode) {
1246
- const normalized = decoratedPromoCode?.trim().toUpperCase();
1247
- return normalized || null;
1248
- }
1249
-
1250
1244
  // src/service/saveNotificationsInDb.ts
1251
1245
  async function saveNotificationsInDb(payload) {
1252
1246
  const { data, message, title, type, userIds } = payload;
@@ -1426,10 +1420,9 @@ async function findAffiliatesWithActiveVendorReferrals() {
1426
1420
  }
1427
1421
  },
1428
1422
  deletedAt: null
1429
- }).select("_id affiliateCode affiliateResources owner").lean().exec();
1423
+ }).select("_id affiliateResources owner").lean().exec();
1430
1424
  }
1431
1425
  async function isEligibleReferredVendor({
1432
- affiliateCode,
1433
1426
  resourceId,
1434
1427
  resourceOwnerUserId
1435
1428
  }) {
@@ -1437,8 +1430,7 @@ async function isEligibleReferredVendor({
1437
1430
  _id: resourceId,
1438
1431
  active: true,
1439
1432
  deletedAt: null,
1440
- "owner.userId": resourceOwnerUserId,
1441
- promoCodes: affiliateCode
1433
+ "owner.userId": resourceOwnerUserId
1442
1434
  }).exec();
1443
1435
  return Boolean(match);
1444
1436
  }
@@ -1527,14 +1519,12 @@ async function tryAwardSubscriptionReward({
1527
1519
  }
1528
1520
  async function processAffiliateVendorReferral({
1529
1521
  affiliate,
1530
- affiliateCode,
1531
1522
  createdAt,
1532
1523
  now,
1533
1524
  period,
1534
1525
  resource
1535
1526
  }) {
1536
1527
  const vendorEligible = await isEligibleReferredVendor({
1537
- affiliateCode,
1538
1528
  resourceId: resource.resourceId,
1539
1529
  resourceOwnerUserId: resource.resourceOwner.userId
1540
1530
  });
@@ -1564,10 +1554,6 @@ async function awardAffiliateVendorSubscriptionRewards(now = /* @__PURE__ */ new
1564
1554
  let skipped = 0;
1565
1555
  const seenPairs = /* @__PURE__ */ new Set();
1566
1556
  for (const affiliate of affiliates) {
1567
- const affiliateCode = normalizePromoCode(affiliate.affiliateCode);
1568
- if (!affiliateCode) {
1569
- continue;
1570
- }
1571
1557
  for (const resource of affiliate.affiliateResources) {
1572
1558
  if (!isEligibleVendorResource(resource)) {
1573
1559
  continue;
@@ -1579,7 +1565,6 @@ async function awardAffiliateVendorSubscriptionRewards(now = /* @__PURE__ */ new
1579
1565
  seenPairs.add(pairKey);
1580
1566
  const outcome = await processAffiliateVendorReferral({
1581
1567
  affiliate,
1582
- affiliateCode,
1583
1568
  createdAt,
1584
1569
  now,
1585
1570
  period,
@@ -1603,6 +1588,12 @@ async function findAffiliateByPromoCode(promoCode) {
1603
1588
  }).exec();
1604
1589
  }
1605
1590
 
1591
+ // src/service/promoCode/normalizePromoCode.ts
1592
+ function normalizePromoCode(decoratedPromoCode) {
1593
+ const normalized = decoratedPromoCode?.trim().toUpperCase();
1594
+ return normalized || null;
1595
+ }
1596
+
1606
1597
  // src/service/affiliate/normalizeAffiliatePromoCodes.ts
1607
1598
  function normalizeAffiliatePromoCodes(promoCodes) {
1608
1599
  const normalized = (promoCodes ?? []).map((code) => normalizePromoCode(code)).filter((code) => code !== null);