@timardex/cluemart-server-shared 1.0.305 → 1.0.308
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/{Affiliate-BxNv9k41.d.mts → Affiliate-B76iZ3fE.d.mts} +2 -1
- package/dist/{Affiliate-DRuifOv4.d.ts → Affiliate-gqV1-654.d.ts} +2 -1
- package/dist/{chunk-7X5A335O.mjs → chunk-MTFOFVHB.mjs} +1 -3
- package/dist/chunk-MTFOFVHB.mjs.map +1 -0
- package/dist/index.cjs +27 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.mjs +27 -27
- package/dist/index.mjs.map +1 -1
- package/dist/mongoose/index.cjs +0 -2
- package/dist/mongoose/index.cjs.map +1 -1
- package/dist/mongoose/index.d.mts +2 -2
- package/dist/mongoose/index.d.ts +2 -2
- package/dist/mongoose/index.mjs +1 -1
- package/dist/service/index.cjs +27 -27
- package/dist/service/index.cjs.map +1 -1
- package/dist/service/index.d.mts +4 -3
- package/dist/service/index.d.ts +4 -3
- package/dist/service/index.mjs +28 -26
- package/dist/service/index.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-7X5A335O.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -724,8 +724,9 @@ declare const SchoolModel: mongoose__default.Model<SchoolDocument, {}, {}, {}, m
|
|
|
724
724
|
}, any>;
|
|
725
725
|
|
|
726
726
|
type SchemaAffiliateReward = AffiliateRewardType;
|
|
727
|
-
type SchemaAffiliateResourceType = Omit<AffiliateResourceType, "resourceId"> & {
|
|
727
|
+
type SchemaAffiliateResourceType = Omit<AffiliateResourceType, "resourceId" | "resourceOwner"> & {
|
|
728
728
|
resourceId: ObjectId;
|
|
729
|
+
resourceOwner: SchemaOwnerType;
|
|
729
730
|
};
|
|
730
731
|
type AffiliateDocument = Omit<AffiliateType, "_id" | "owner" | "affiliateResources"> & {
|
|
731
732
|
affiliateResources: SchemaAffiliateResourceType[];
|
|
@@ -761,8 +762,9 @@ type AwardAffiliateVendorSubscriptionRewardsResult = {
|
|
|
761
762
|
* Eligibility per affiliate resource:
|
|
762
763
|
* - Affiliate is not soft-deleted
|
|
763
764
|
* - Linked `affiliateResources` entry is vendor, `resourceActive`, and not deleted
|
|
764
|
-
* - Vendor is active, not deleted,
|
|
765
|
-
*
|
|
765
|
+
* - Vendor is active, not deleted, has the affiliate promo code, and
|
|
766
|
+
* `owner.userId` matches `affiliateResources.resourceOwner.userId`
|
|
767
|
+
* - `affiliateResources.resourceOwner` has a non-expired Standard / Pro / Pro+ vendor licence
|
|
766
768
|
*
|
|
767
769
|
* Reward type follows the owner's highest valid licence + Stripe paying status:
|
|
768
770
|
* - Pro / Pro+ with paying Stripe (ACTIVE/TRIALING) → `ACTIVE_VENDOR_PRO_SUBSCRIPTION` (3 pts)
|
package/dist/index.d.ts
CHANGED
|
@@ -724,8 +724,9 @@ declare const SchoolModel: mongoose__default.Model<SchoolDocument, {}, {}, {}, m
|
|
|
724
724
|
}, any>;
|
|
725
725
|
|
|
726
726
|
type SchemaAffiliateReward = AffiliateRewardType;
|
|
727
|
-
type SchemaAffiliateResourceType = Omit<AffiliateResourceType, "resourceId"> & {
|
|
727
|
+
type SchemaAffiliateResourceType = Omit<AffiliateResourceType, "resourceId" | "resourceOwner"> & {
|
|
728
728
|
resourceId: ObjectId;
|
|
729
|
+
resourceOwner: SchemaOwnerType;
|
|
729
730
|
};
|
|
730
731
|
type AffiliateDocument = Omit<AffiliateType, "_id" | "owner" | "affiliateResources"> & {
|
|
731
732
|
affiliateResources: SchemaAffiliateResourceType[];
|
|
@@ -761,8 +762,9 @@ type AwardAffiliateVendorSubscriptionRewardsResult = {
|
|
|
761
762
|
* Eligibility per affiliate resource:
|
|
762
763
|
* - Affiliate is not soft-deleted
|
|
763
764
|
* - Linked `affiliateResources` entry is vendor, `resourceActive`, and not deleted
|
|
764
|
-
* - Vendor is active, not deleted,
|
|
765
|
-
*
|
|
765
|
+
* - Vendor is active, not deleted, has the affiliate promo code, and
|
|
766
|
+
* `owner.userId` matches `affiliateResources.resourceOwner.userId`
|
|
767
|
+
* - `affiliateResources.resourceOwner` has a non-expired Standard / Pro / Pro+ vendor licence
|
|
766
768
|
*
|
|
767
769
|
* Reward type follows the owner's highest valid licence + Stripe paying status:
|
|
768
770
|
* - Pro / Pro+ with paying Stripe (ACTIVE/TRIALING) → `ACTIVE_VENDOR_PRO_SUBSCRIPTION` (3 pts)
|
package/dist/index.mjs
CHANGED
|
@@ -7315,7 +7315,6 @@ var AFFILIATE_DETAILS_FIELDS_FRAGMENT = gql`
|
|
|
7315
7315
|
location {
|
|
7316
7316
|
...LocationFields
|
|
7317
7317
|
}
|
|
7318
|
-
region
|
|
7319
7318
|
socialMedia {
|
|
7320
7319
|
...SocialMediaFields
|
|
7321
7320
|
}
|
|
@@ -9200,7 +9199,6 @@ var affiliateDetailsSchema = new MongooseSchema25(
|
|
|
9200
9199
|
required: true,
|
|
9201
9200
|
type: String
|
|
9202
9201
|
},
|
|
9203
|
-
region: { required: true, type: String },
|
|
9204
9202
|
socialMedia: { required: false, type: [SocialMediaTypeSchema] },
|
|
9205
9203
|
termsAgreement: { required: true, type: termsAgreementSchema }
|
|
9206
9204
|
},
|
|
@@ -9323,7 +9321,7 @@ var SHARE_RESOURCE_LABEL2 = {
|
|
|
9323
9321
|
school: "School"
|
|
9324
9322
|
};
|
|
9325
9323
|
|
|
9326
|
-
// node_modules/@timardex/cluemart-shared/dist/chunk-
|
|
9324
|
+
// node_modules/@timardex/cluemart-shared/dist/chunk-QMJB5OJ4.mjs
|
|
9327
9325
|
var PROMO_CODE_PREFIX2 = "CM-";
|
|
9328
9326
|
var OBJECT_ID_PATH_SEGMENT2 = "[a-f0-9]{24}";
|
|
9329
9327
|
var OBJECT_ID_PATH_SEGMENT_END2 = `${OBJECT_ID_PATH_SEGMENT2}$`;
|
|
@@ -9425,7 +9423,7 @@ var gameScreenIdentifierList2 = [
|
|
|
9425
9423
|
}
|
|
9426
9424
|
];
|
|
9427
9425
|
|
|
9428
|
-
// node_modules/@timardex/cluemart-shared/dist/chunk-
|
|
9426
|
+
// node_modules/@timardex/cluemart-shared/dist/chunk-A7IXLYYS.mjs
|
|
9429
9427
|
import dayjs4 from "dayjs";
|
|
9430
9428
|
var statusOptions2 = [
|
|
9431
9429
|
...Object.values(EnumInviteStatus2).map((status) => ({
|
|
@@ -10656,13 +10654,19 @@ async function findAffiliatesWithActiveVendorReferrals() {
|
|
|
10656
10654
|
deletedAt: null
|
|
10657
10655
|
}).select("_id affiliateCode affiliateResources owner").lean().exec();
|
|
10658
10656
|
}
|
|
10659
|
-
async function
|
|
10660
|
-
|
|
10657
|
+
async function isEligibleReferredVendor({
|
|
10658
|
+
affiliateCode,
|
|
10659
|
+
resourceId,
|
|
10660
|
+
resourceOwnerUserId
|
|
10661
|
+
}) {
|
|
10662
|
+
const match = await VendorModel.exists({
|
|
10661
10663
|
_id: resourceId,
|
|
10662
10664
|
active: true,
|
|
10663
10665
|
deletedAt: null,
|
|
10666
|
+
"owner.userId": resourceOwnerUserId,
|
|
10664
10667
|
promoCodes: affiliateCode
|
|
10665
|
-
}).
|
|
10668
|
+
}).exec();
|
|
10669
|
+
return Boolean(match);
|
|
10666
10670
|
}
|
|
10667
10671
|
async function resolveSubscriptionRewardTypeForVendorOwner(vendorOwnerUserId, now) {
|
|
10668
10672
|
const vendorOwner = await UserModel.findById(vendorOwnerUserId).select("licences stripe").lean().exec();
|
|
@@ -10704,8 +10708,7 @@ async function tryAwardSubscriptionReward({
|
|
|
10704
10708
|
createdAt,
|
|
10705
10709
|
period,
|
|
10706
10710
|
resource,
|
|
10707
|
-
rewardType
|
|
10708
|
-
vendor
|
|
10711
|
+
rewardType
|
|
10709
10712
|
}) {
|
|
10710
10713
|
const reward = createAffiliateReward(rewardType, createdAt);
|
|
10711
10714
|
const updateResult = await AffiliateModel.updateOne(
|
|
@@ -10715,7 +10718,7 @@ async function tryAwardSubscriptionReward({
|
|
|
10715
10718
|
$elemMatch: {
|
|
10716
10719
|
resourceActive: true,
|
|
10717
10720
|
resourceDeletedAt: null,
|
|
10718
|
-
resourceId:
|
|
10721
|
+
resourceId: resource.resourceId,
|
|
10719
10722
|
resourceType: EnumResourceType.VENDOR,
|
|
10720
10723
|
rewards: {
|
|
10721
10724
|
$not: {
|
|
@@ -10740,15 +10743,12 @@ async function tryAwardSubscriptionReward({
|
|
|
10740
10743
|
if (updateResult.modifiedCount === 0) {
|
|
10741
10744
|
return "skipped";
|
|
10742
10745
|
}
|
|
10743
|
-
|
|
10744
|
-
|
|
10745
|
-
|
|
10746
|
-
|
|
10747
|
-
|
|
10748
|
-
|
|
10749
|
-
rewardValue: reward.rewardValue
|
|
10750
|
-
});
|
|
10751
|
-
}
|
|
10746
|
+
await notifyAffiliateOwnerOfSubscriptionReward({
|
|
10747
|
+
affiliateId: affiliate._id,
|
|
10748
|
+
affiliateOwnerUserId: affiliate.owner.userId,
|
|
10749
|
+
resourceName: resource.resourceName,
|
|
10750
|
+
rewardValue: reward.rewardValue
|
|
10751
|
+
});
|
|
10752
10752
|
return "awarded";
|
|
10753
10753
|
}
|
|
10754
10754
|
async function processAffiliateVendorReferral({
|
|
@@ -10759,15 +10759,16 @@ async function processAffiliateVendorReferral({
|
|
|
10759
10759
|
period,
|
|
10760
10760
|
resource
|
|
10761
10761
|
}) {
|
|
10762
|
-
const
|
|
10763
|
-
|
|
10764
|
-
|
|
10765
|
-
|
|
10766
|
-
|
|
10762
|
+
const vendorEligible = await isEligibleReferredVendor({
|
|
10763
|
+
affiliateCode,
|
|
10764
|
+
resourceId: resource.resourceId,
|
|
10765
|
+
resourceOwnerUserId: resource.resourceOwner.userId
|
|
10766
|
+
});
|
|
10767
|
+
if (!vendorEligible) {
|
|
10767
10768
|
return "skipped";
|
|
10768
10769
|
}
|
|
10769
10770
|
const rewardType = await resolveSubscriptionRewardTypeForVendorOwner(
|
|
10770
|
-
|
|
10771
|
+
resource.resourceOwner.userId,
|
|
10771
10772
|
now
|
|
10772
10773
|
);
|
|
10773
10774
|
if (!rewardType) {
|
|
@@ -10778,8 +10779,7 @@ async function processAffiliateVendorReferral({
|
|
|
10778
10779
|
createdAt,
|
|
10779
10780
|
period,
|
|
10780
10781
|
resource,
|
|
10781
|
-
rewardType
|
|
10782
|
-
vendor
|
|
10782
|
+
rewardType
|
|
10783
10783
|
});
|
|
10784
10784
|
}
|
|
10785
10785
|
async function awardAffiliateVendorSubscriptionRewards(now = /* @__PURE__ */ new Date()) {
|