@timardex/cluemart-server-shared 1.0.304 → 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-GQWLGM2W.mjs → chunk-SY7T26IW.mjs} +11 -1
- package/dist/chunk-SY7T26IW.mjs.map +1 -0
- package/dist/index.cjs +37 -25
- 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 +37 -25
- package/dist/index.mjs.map +1 -1
- package/dist/mongoose/index.cjs +10 -0
- 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 +37 -25
- 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-GQWLGM2W.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
|
@@ -7339,12 +7339,16 @@ var AFFILIATE_RESOURCE_FIELDS_FRAGMENT = gql`
|
|
|
7339
7339
|
resourceDeletedAt
|
|
7340
7340
|
resourceId
|
|
7341
7341
|
resourceName
|
|
7342
|
+
resourceOwner {
|
|
7343
|
+
...OwnerFields
|
|
7344
|
+
}
|
|
7342
7345
|
resourceType
|
|
7343
7346
|
rewards {
|
|
7344
7347
|
...AffiliateRewardFields
|
|
7345
7348
|
}
|
|
7346
7349
|
}
|
|
7347
7350
|
${AFFILIATE_REWARD_FIELDS_FRAGMENT}
|
|
7351
|
+
${OWNER_FIELDS_FRAGMENT}
|
|
7348
7352
|
`;
|
|
7349
7353
|
var AFFILIATE_BANK_ACCOUNT_DETAILS_FIELDS_FRAGMENT = gql`
|
|
7350
7354
|
fragment AffiliateBankAccountDetailsFields on AffiliateBankAccountDetailsType {
|
|
@@ -7399,6 +7403,7 @@ var AFFILIATE_FIELDS_FRAGMENT = gql`
|
|
|
7399
7403
|
createdAt
|
|
7400
7404
|
deletedAt
|
|
7401
7405
|
redeemHistory {
|
|
7406
|
+
paidAt
|
|
7402
7407
|
redeemedAt
|
|
7403
7408
|
rewardValue
|
|
7404
7409
|
}
|
|
@@ -9205,6 +9210,10 @@ var affiliateResourceSchema = new MongooseSchema25(
|
|
|
9205
9210
|
type: import_mongoose25.default.Schema.Types.ObjectId
|
|
9206
9211
|
},
|
|
9207
9212
|
resourceName: { required: true, type: String },
|
|
9213
|
+
resourceOwner: {
|
|
9214
|
+
required: true,
|
|
9215
|
+
type: OwnerTypeSchema
|
|
9216
|
+
},
|
|
9208
9217
|
resourceType: {
|
|
9209
9218
|
enum: Object.values(EnumResourceType),
|
|
9210
9219
|
required: true,
|
|
@@ -9256,6 +9265,7 @@ var affiliateDetailsSchema = new MongooseSchema25(
|
|
|
9256
9265
|
);
|
|
9257
9266
|
var redeemHistorySchema = new MongooseSchema25(
|
|
9258
9267
|
{
|
|
9268
|
+
paidAt: { default: null, required: false, type: Date },
|
|
9259
9269
|
redeemedAt: { required: true, type: Date },
|
|
9260
9270
|
rewardValue: { required: true, type: Number }
|
|
9261
9271
|
},
|
|
@@ -9370,7 +9380,7 @@ var SHARE_RESOURCE_LABEL2 = {
|
|
|
9370
9380
|
school: "School"
|
|
9371
9381
|
};
|
|
9372
9382
|
|
|
9373
|
-
// node_modules/@timardex/cluemart-shared/dist/chunk-
|
|
9383
|
+
// node_modules/@timardex/cluemart-shared/dist/chunk-OBZTGPBJ.mjs
|
|
9374
9384
|
var PROMO_CODE_PREFIX2 = "CM-";
|
|
9375
9385
|
var OBJECT_ID_PATH_SEGMENT2 = "[a-f0-9]{24}";
|
|
9376
9386
|
var OBJECT_ID_PATH_SEGMENT_END2 = `${OBJECT_ID_PATH_SEGMENT2}$`;
|
|
@@ -9472,7 +9482,7 @@ var gameScreenIdentifierList2 = [
|
|
|
9472
9482
|
}
|
|
9473
9483
|
];
|
|
9474
9484
|
|
|
9475
|
-
// node_modules/@timardex/cluemart-shared/dist/chunk-
|
|
9485
|
+
// node_modules/@timardex/cluemart-shared/dist/chunk-QBU7N4P2.mjs
|
|
9476
9486
|
var import_dayjs4 = __toESM(require("dayjs"), 1);
|
|
9477
9487
|
var statusOptions2 = [
|
|
9478
9488
|
...Object.values(EnumInviteStatus2).map((status) => ({
|
|
@@ -10703,13 +10713,19 @@ async function findAffiliatesWithActiveVendorReferrals() {
|
|
|
10703
10713
|
deletedAt: null
|
|
10704
10714
|
}).select("_id affiliateCode affiliateResources owner").lean().exec();
|
|
10705
10715
|
}
|
|
10706
|
-
async function
|
|
10707
|
-
|
|
10716
|
+
async function isEligibleReferredVendor({
|
|
10717
|
+
affiliateCode,
|
|
10718
|
+
resourceId,
|
|
10719
|
+
resourceOwnerUserId
|
|
10720
|
+
}) {
|
|
10721
|
+
const match = await VendorModel.exists({
|
|
10708
10722
|
_id: resourceId,
|
|
10709
10723
|
active: true,
|
|
10710
10724
|
deletedAt: null,
|
|
10725
|
+
"owner.userId": resourceOwnerUserId,
|
|
10711
10726
|
promoCodes: affiliateCode
|
|
10712
|
-
}).
|
|
10727
|
+
}).exec();
|
|
10728
|
+
return Boolean(match);
|
|
10713
10729
|
}
|
|
10714
10730
|
async function resolveSubscriptionRewardTypeForVendorOwner(vendorOwnerUserId, now) {
|
|
10715
10731
|
const vendorOwner = await UserModel.findById(vendorOwnerUserId).select("licences stripe").lean().exec();
|
|
@@ -10751,8 +10767,7 @@ async function tryAwardSubscriptionReward({
|
|
|
10751
10767
|
createdAt,
|
|
10752
10768
|
period,
|
|
10753
10769
|
resource,
|
|
10754
|
-
rewardType
|
|
10755
|
-
vendor
|
|
10770
|
+
rewardType
|
|
10756
10771
|
}) {
|
|
10757
10772
|
const reward = createAffiliateReward(rewardType, createdAt);
|
|
10758
10773
|
const updateResult = await AffiliateModel.updateOne(
|
|
@@ -10762,7 +10777,7 @@ async function tryAwardSubscriptionReward({
|
|
|
10762
10777
|
$elemMatch: {
|
|
10763
10778
|
resourceActive: true,
|
|
10764
10779
|
resourceDeletedAt: null,
|
|
10765
|
-
resourceId:
|
|
10780
|
+
resourceId: resource.resourceId,
|
|
10766
10781
|
resourceType: EnumResourceType.VENDOR,
|
|
10767
10782
|
rewards: {
|
|
10768
10783
|
$not: {
|
|
@@ -10787,15 +10802,12 @@ async function tryAwardSubscriptionReward({
|
|
|
10787
10802
|
if (updateResult.modifiedCount === 0) {
|
|
10788
10803
|
return "skipped";
|
|
10789
10804
|
}
|
|
10790
|
-
|
|
10791
|
-
|
|
10792
|
-
|
|
10793
|
-
|
|
10794
|
-
|
|
10795
|
-
|
|
10796
|
-
rewardValue: reward.rewardValue
|
|
10797
|
-
});
|
|
10798
|
-
}
|
|
10805
|
+
await notifyAffiliateOwnerOfSubscriptionReward({
|
|
10806
|
+
affiliateId: affiliate._id,
|
|
10807
|
+
affiliateOwnerUserId: affiliate.owner.userId,
|
|
10808
|
+
resourceName: resource.resourceName,
|
|
10809
|
+
rewardValue: reward.rewardValue
|
|
10810
|
+
});
|
|
10799
10811
|
return "awarded";
|
|
10800
10812
|
}
|
|
10801
10813
|
async function processAffiliateVendorReferral({
|
|
@@ -10806,15 +10818,16 @@ async function processAffiliateVendorReferral({
|
|
|
10806
10818
|
period,
|
|
10807
10819
|
resource
|
|
10808
10820
|
}) {
|
|
10809
|
-
const
|
|
10810
|
-
|
|
10811
|
-
|
|
10812
|
-
|
|
10813
|
-
|
|
10821
|
+
const vendorEligible = await isEligibleReferredVendor({
|
|
10822
|
+
affiliateCode,
|
|
10823
|
+
resourceId: resource.resourceId,
|
|
10824
|
+
resourceOwnerUserId: resource.resourceOwner.userId
|
|
10825
|
+
});
|
|
10826
|
+
if (!vendorEligible) {
|
|
10814
10827
|
return "skipped";
|
|
10815
10828
|
}
|
|
10816
10829
|
const rewardType = await resolveSubscriptionRewardTypeForVendorOwner(
|
|
10817
|
-
|
|
10830
|
+
resource.resourceOwner.userId,
|
|
10818
10831
|
now
|
|
10819
10832
|
);
|
|
10820
10833
|
if (!rewardType) {
|
|
@@ -10825,8 +10838,7 @@ async function processAffiliateVendorReferral({
|
|
|
10825
10838
|
createdAt,
|
|
10826
10839
|
period,
|
|
10827
10840
|
resource,
|
|
10828
|
-
rewardType
|
|
10829
|
-
vendor
|
|
10841
|
+
rewardType
|
|
10830
10842
|
});
|
|
10831
10843
|
}
|
|
10832
10844
|
async function awardAffiliateVendorSubscriptionRewards(now = /* @__PURE__ */ new Date()) {
|