@timardex/cluemart-server-shared 1.0.305 → 1.0.306
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-SY7T26IW.mjs} +1 -1
- package/dist/{chunk-7X5A335O.mjs.map → chunk-SY7T26IW.mjs.map} +1 -1
- package/dist/index.cjs +25 -23
- 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 +25 -23
- package/dist/index.mjs.map +1 -1
- 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 +25 -23
- 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 +26 -24
- package/dist/service/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -3,8 +3,8 @@ import { AdType, ReportChatUser, GoogleImportedMarket, PushTokenType, ResourceAc
|
|
|
3
3
|
import mongoose__default from 'mongoose';
|
|
4
4
|
import { O as ObjectId } from '../Chat-Wn7yfc3v.mjs';
|
|
5
5
|
export { C as ChatModel, N as NotificationModel, a as SchemaChatMessageReactionType, S as SchemaChatMessageReplyPreviewType, b as SchemaChatMessageSeenType, c as SchemaChatMessageType, e as SchemaChatType, f as SchemaCreateBulkNotificationInput, g as SchemaNotificationType, d as SchemaParticipantType } from '../Chat-Wn7yfc3v.mjs';
|
|
6
|
-
import { S as SchemaOwnerType } from '../Affiliate-
|
|
7
|
-
export { A as AffiliateModel, C as CategorySchema, c as ContactDetailsSchema, O as OwnerTypeSchema, k as RelationModel, j as RelationTypeSchema, R as ResourceImageTypeSchema, n as SchemaAffiliateResourceType, m as SchemaAffiliateReward, a as SchemaRelatedPostType, i as SchemaRelationType, b as SocialMediaTypeSchema, g as baseResourceFields, d as dateTimeSchema, l as locationGeoSchema, e as locationsSchema, f as relatedPostSchema, h as relationDatesSchema, r as resourceRelationsSchema, s as socialShareResourceSchema, t as termsAgreementSchema, u as userLicenseSchema } from '../Affiliate-
|
|
6
|
+
import { S as SchemaOwnerType } from '../Affiliate-B76iZ3fE.mjs';
|
|
7
|
+
export { A as AffiliateModel, C as CategorySchema, c as ContactDetailsSchema, O as OwnerTypeSchema, k as RelationModel, j as RelationTypeSchema, R as ResourceImageTypeSchema, n as SchemaAffiliateResourceType, m as SchemaAffiliateReward, a as SchemaRelatedPostType, i as SchemaRelationType, b as SocialMediaTypeSchema, g as baseResourceFields, d as dateTimeSchema, l as locationGeoSchema, e as locationsSchema, f as relatedPostSchema, h as relationDatesSchema, r as resourceRelationsSchema, s as socialShareResourceSchema, t as termsAgreementSchema, u as userLicenseSchema } from '../Affiliate-B76iZ3fE.mjs';
|
|
8
8
|
import '@timardex/cluemart-shared/types';
|
|
9
9
|
import 'express';
|
|
10
10
|
|
package/dist/mongoose/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { AdType, ReportChatUser, GoogleImportedMarket, PushTokenType, ResourceAc
|
|
|
3
3
|
import mongoose__default from 'mongoose';
|
|
4
4
|
import { O as ObjectId } from '../Chat-Wn7yfc3v.js';
|
|
5
5
|
export { C as ChatModel, N as NotificationModel, a as SchemaChatMessageReactionType, S as SchemaChatMessageReplyPreviewType, b as SchemaChatMessageSeenType, c as SchemaChatMessageType, e as SchemaChatType, f as SchemaCreateBulkNotificationInput, g as SchemaNotificationType, d as SchemaParticipantType } from '../Chat-Wn7yfc3v.js';
|
|
6
|
-
import { S as SchemaOwnerType } from '../Affiliate-
|
|
7
|
-
export { A as AffiliateModel, C as CategorySchema, c as ContactDetailsSchema, O as OwnerTypeSchema, k as RelationModel, j as RelationTypeSchema, R as ResourceImageTypeSchema, n as SchemaAffiliateResourceType, m as SchemaAffiliateReward, a as SchemaRelatedPostType, i as SchemaRelationType, b as SocialMediaTypeSchema, g as baseResourceFields, d as dateTimeSchema, l as locationGeoSchema, e as locationsSchema, f as relatedPostSchema, h as relationDatesSchema, r as resourceRelationsSchema, s as socialShareResourceSchema, t as termsAgreementSchema, u as userLicenseSchema } from '../Affiliate-
|
|
6
|
+
import { S as SchemaOwnerType } from '../Affiliate-gqV1-654.js';
|
|
7
|
+
export { A as AffiliateModel, C as CategorySchema, c as ContactDetailsSchema, O as OwnerTypeSchema, k as RelationModel, j as RelationTypeSchema, R as ResourceImageTypeSchema, n as SchemaAffiliateResourceType, m as SchemaAffiliateReward, a as SchemaRelatedPostType, i as SchemaRelationType, b as SocialMediaTypeSchema, g as baseResourceFields, d as dateTimeSchema, l as locationGeoSchema, e as locationsSchema, f as relatedPostSchema, h as relationDatesSchema, r as resourceRelationsSchema, s as socialShareResourceSchema, t as termsAgreementSchema, u as userLicenseSchema } from '../Affiliate-gqV1-654.js';
|
|
8
8
|
import '@timardex/cluemart-shared/types';
|
|
9
9
|
import 'express';
|
|
10
10
|
|
package/dist/mongoose/index.mjs
CHANGED
package/dist/service/index.cjs
CHANGED
|
@@ -10713,13 +10713,19 @@ async function findAffiliatesWithActiveVendorReferrals() {
|
|
|
10713
10713
|
deletedAt: null
|
|
10714
10714
|
}).select("_id affiliateCode affiliateResources owner").lean().exec();
|
|
10715
10715
|
}
|
|
10716
|
-
async function
|
|
10717
|
-
|
|
10716
|
+
async function isEligibleReferredVendor({
|
|
10717
|
+
affiliateCode,
|
|
10718
|
+
resourceId,
|
|
10719
|
+
resourceOwnerUserId
|
|
10720
|
+
}) {
|
|
10721
|
+
const match = await VendorModel.exists({
|
|
10718
10722
|
_id: resourceId,
|
|
10719
10723
|
active: true,
|
|
10720
10724
|
deletedAt: null,
|
|
10725
|
+
"owner.userId": resourceOwnerUserId,
|
|
10721
10726
|
promoCodes: affiliateCode
|
|
10722
|
-
}).
|
|
10727
|
+
}).exec();
|
|
10728
|
+
return Boolean(match);
|
|
10723
10729
|
}
|
|
10724
10730
|
async function resolveSubscriptionRewardTypeForVendorOwner(vendorOwnerUserId, now) {
|
|
10725
10731
|
const vendorOwner = await UserModel.findById(vendorOwnerUserId).select("licences stripe").lean().exec();
|
|
@@ -10761,8 +10767,7 @@ async function tryAwardSubscriptionReward({
|
|
|
10761
10767
|
createdAt,
|
|
10762
10768
|
period,
|
|
10763
10769
|
resource,
|
|
10764
|
-
rewardType
|
|
10765
|
-
vendor
|
|
10770
|
+
rewardType
|
|
10766
10771
|
}) {
|
|
10767
10772
|
const reward = createAffiliateReward(rewardType, createdAt);
|
|
10768
10773
|
const updateResult = await AffiliateModel.updateOne(
|
|
@@ -10772,7 +10777,7 @@ async function tryAwardSubscriptionReward({
|
|
|
10772
10777
|
$elemMatch: {
|
|
10773
10778
|
resourceActive: true,
|
|
10774
10779
|
resourceDeletedAt: null,
|
|
10775
|
-
resourceId:
|
|
10780
|
+
resourceId: resource.resourceId,
|
|
10776
10781
|
resourceType: EnumResourceType.VENDOR,
|
|
10777
10782
|
rewards: {
|
|
10778
10783
|
$not: {
|
|
@@ -10797,15 +10802,12 @@ async function tryAwardSubscriptionReward({
|
|
|
10797
10802
|
if (updateResult.modifiedCount === 0) {
|
|
10798
10803
|
return "skipped";
|
|
10799
10804
|
}
|
|
10800
|
-
|
|
10801
|
-
|
|
10802
|
-
|
|
10803
|
-
|
|
10804
|
-
|
|
10805
|
-
|
|
10806
|
-
rewardValue: reward.rewardValue
|
|
10807
|
-
});
|
|
10808
|
-
}
|
|
10805
|
+
await notifyAffiliateOwnerOfSubscriptionReward({
|
|
10806
|
+
affiliateId: affiliate._id,
|
|
10807
|
+
affiliateOwnerUserId: affiliate.owner.userId,
|
|
10808
|
+
resourceName: resource.resourceName,
|
|
10809
|
+
rewardValue: reward.rewardValue
|
|
10810
|
+
});
|
|
10809
10811
|
return "awarded";
|
|
10810
10812
|
}
|
|
10811
10813
|
async function processAffiliateVendorReferral({
|
|
@@ -10816,15 +10818,16 @@ async function processAffiliateVendorReferral({
|
|
|
10816
10818
|
period,
|
|
10817
10819
|
resource
|
|
10818
10820
|
}) {
|
|
10819
|
-
const
|
|
10820
|
-
|
|
10821
|
-
|
|
10822
|
-
|
|
10823
|
-
|
|
10821
|
+
const vendorEligible = await isEligibleReferredVendor({
|
|
10822
|
+
affiliateCode,
|
|
10823
|
+
resourceId: resource.resourceId,
|
|
10824
|
+
resourceOwnerUserId: resource.resourceOwner.userId
|
|
10825
|
+
});
|
|
10826
|
+
if (!vendorEligible) {
|
|
10824
10827
|
return "skipped";
|
|
10825
10828
|
}
|
|
10826
10829
|
const rewardType = await resolveSubscriptionRewardTypeForVendorOwner(
|
|
10827
|
-
|
|
10830
|
+
resource.resourceOwner.userId,
|
|
10828
10831
|
now
|
|
10829
10832
|
);
|
|
10830
10833
|
if (!rewardType) {
|
|
@@ -10835,8 +10838,7 @@ async function processAffiliateVendorReferral({
|
|
|
10835
10838
|
createdAt,
|
|
10836
10839
|
period,
|
|
10837
10840
|
resource,
|
|
10838
|
-
rewardType
|
|
10839
|
-
vendor
|
|
10841
|
+
rewardType
|
|
10840
10842
|
});
|
|
10841
10843
|
}
|
|
10842
10844
|
async function awardAffiliateVendorSubscriptionRewards(now = /* @__PURE__ */ new Date()) {
|