@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
|
@@ -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
|
@@ -7372,7 +7372,6 @@ var AFFILIATE_DETAILS_FIELDS_FRAGMENT = gql`
|
|
|
7372
7372
|
location {
|
|
7373
7373
|
...LocationFields
|
|
7374
7374
|
}
|
|
7375
|
-
region
|
|
7376
7375
|
socialMedia {
|
|
7377
7376
|
...SocialMediaFields
|
|
7378
7377
|
}
|
|
@@ -9257,7 +9256,6 @@ var affiliateDetailsSchema = new MongooseSchema25(
|
|
|
9257
9256
|
required: true,
|
|
9258
9257
|
type: String
|
|
9259
9258
|
},
|
|
9260
|
-
region: { required: true, type: String },
|
|
9261
9259
|
socialMedia: { required: false, type: [SocialMediaTypeSchema] },
|
|
9262
9260
|
termsAgreement: { required: true, type: termsAgreementSchema }
|
|
9263
9261
|
},
|
|
@@ -9380,7 +9378,7 @@ var SHARE_RESOURCE_LABEL2 = {
|
|
|
9380
9378
|
school: "School"
|
|
9381
9379
|
};
|
|
9382
9380
|
|
|
9383
|
-
// node_modules/@timardex/cluemart-shared/dist/chunk-
|
|
9381
|
+
// node_modules/@timardex/cluemart-shared/dist/chunk-QMJB5OJ4.mjs
|
|
9384
9382
|
var PROMO_CODE_PREFIX2 = "CM-";
|
|
9385
9383
|
var OBJECT_ID_PATH_SEGMENT2 = "[a-f0-9]{24}";
|
|
9386
9384
|
var OBJECT_ID_PATH_SEGMENT_END2 = `${OBJECT_ID_PATH_SEGMENT2}$`;
|
|
@@ -9482,7 +9480,7 @@ var gameScreenIdentifierList2 = [
|
|
|
9482
9480
|
}
|
|
9483
9481
|
];
|
|
9484
9482
|
|
|
9485
|
-
// node_modules/@timardex/cluemart-shared/dist/chunk-
|
|
9483
|
+
// node_modules/@timardex/cluemart-shared/dist/chunk-A7IXLYYS.mjs
|
|
9486
9484
|
var import_dayjs4 = __toESM(require("dayjs"), 1);
|
|
9487
9485
|
var statusOptions2 = [
|
|
9488
9486
|
...Object.values(EnumInviteStatus2).map((status) => ({
|
|
@@ -10713,13 +10711,19 @@ async function findAffiliatesWithActiveVendorReferrals() {
|
|
|
10713
10711
|
deletedAt: null
|
|
10714
10712
|
}).select("_id affiliateCode affiliateResources owner").lean().exec();
|
|
10715
10713
|
}
|
|
10716
|
-
async function
|
|
10717
|
-
|
|
10714
|
+
async function isEligibleReferredVendor({
|
|
10715
|
+
affiliateCode,
|
|
10716
|
+
resourceId,
|
|
10717
|
+
resourceOwnerUserId
|
|
10718
|
+
}) {
|
|
10719
|
+
const match = await VendorModel.exists({
|
|
10718
10720
|
_id: resourceId,
|
|
10719
10721
|
active: true,
|
|
10720
10722
|
deletedAt: null,
|
|
10723
|
+
"owner.userId": resourceOwnerUserId,
|
|
10721
10724
|
promoCodes: affiliateCode
|
|
10722
|
-
}).
|
|
10725
|
+
}).exec();
|
|
10726
|
+
return Boolean(match);
|
|
10723
10727
|
}
|
|
10724
10728
|
async function resolveSubscriptionRewardTypeForVendorOwner(vendorOwnerUserId, now) {
|
|
10725
10729
|
const vendorOwner = await UserModel.findById(vendorOwnerUserId).select("licences stripe").lean().exec();
|
|
@@ -10761,8 +10765,7 @@ async function tryAwardSubscriptionReward({
|
|
|
10761
10765
|
createdAt,
|
|
10762
10766
|
period,
|
|
10763
10767
|
resource,
|
|
10764
|
-
rewardType
|
|
10765
|
-
vendor
|
|
10768
|
+
rewardType
|
|
10766
10769
|
}) {
|
|
10767
10770
|
const reward = createAffiliateReward(rewardType, createdAt);
|
|
10768
10771
|
const updateResult = await AffiliateModel.updateOne(
|
|
@@ -10772,7 +10775,7 @@ async function tryAwardSubscriptionReward({
|
|
|
10772
10775
|
$elemMatch: {
|
|
10773
10776
|
resourceActive: true,
|
|
10774
10777
|
resourceDeletedAt: null,
|
|
10775
|
-
resourceId:
|
|
10778
|
+
resourceId: resource.resourceId,
|
|
10776
10779
|
resourceType: EnumResourceType.VENDOR,
|
|
10777
10780
|
rewards: {
|
|
10778
10781
|
$not: {
|
|
@@ -10797,15 +10800,12 @@ async function tryAwardSubscriptionReward({
|
|
|
10797
10800
|
if (updateResult.modifiedCount === 0) {
|
|
10798
10801
|
return "skipped";
|
|
10799
10802
|
}
|
|
10800
|
-
|
|
10801
|
-
|
|
10802
|
-
|
|
10803
|
-
|
|
10804
|
-
|
|
10805
|
-
|
|
10806
|
-
rewardValue: reward.rewardValue
|
|
10807
|
-
});
|
|
10808
|
-
}
|
|
10803
|
+
await notifyAffiliateOwnerOfSubscriptionReward({
|
|
10804
|
+
affiliateId: affiliate._id,
|
|
10805
|
+
affiliateOwnerUserId: affiliate.owner.userId,
|
|
10806
|
+
resourceName: resource.resourceName,
|
|
10807
|
+
rewardValue: reward.rewardValue
|
|
10808
|
+
});
|
|
10809
10809
|
return "awarded";
|
|
10810
10810
|
}
|
|
10811
10811
|
async function processAffiliateVendorReferral({
|
|
@@ -10816,15 +10816,16 @@ async function processAffiliateVendorReferral({
|
|
|
10816
10816
|
period,
|
|
10817
10817
|
resource
|
|
10818
10818
|
}) {
|
|
10819
|
-
const
|
|
10820
|
-
|
|
10821
|
-
|
|
10822
|
-
|
|
10823
|
-
|
|
10819
|
+
const vendorEligible = await isEligibleReferredVendor({
|
|
10820
|
+
affiliateCode,
|
|
10821
|
+
resourceId: resource.resourceId,
|
|
10822
|
+
resourceOwnerUserId: resource.resourceOwner.userId
|
|
10823
|
+
});
|
|
10824
|
+
if (!vendorEligible) {
|
|
10824
10825
|
return "skipped";
|
|
10825
10826
|
}
|
|
10826
10827
|
const rewardType = await resolveSubscriptionRewardTypeForVendorOwner(
|
|
10827
|
-
|
|
10828
|
+
resource.resourceOwner.userId,
|
|
10828
10829
|
now
|
|
10829
10830
|
);
|
|
10830
10831
|
if (!rewardType) {
|
|
@@ -10835,8 +10836,7 @@ async function processAffiliateVendorReferral({
|
|
|
10835
10836
|
createdAt,
|
|
10836
10837
|
period,
|
|
10837
10838
|
resource,
|
|
10838
|
-
rewardType
|
|
10839
|
-
vendor
|
|
10839
|
+
rewardType
|
|
10840
10840
|
});
|
|
10841
10841
|
}
|
|
10842
10842
|
async function awardAffiliateVendorSubscriptionRewards(now = /* @__PURE__ */ new Date()) {
|