@timardex/cluemart-server-shared 2.2.12 → 2.2.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.
package/dist/index.cjs CHANGED
@@ -54,6 +54,8 @@ __export(index_exports, {
54
54
  EventModel: () => EventModel,
55
55
  GameModel: () => GameModel,
56
56
  GoogleImportedMarketModel: () => GoogleImportedMarketModel,
57
+ ImpersonationAuditModel: () => ImpersonationAuditModel,
58
+ ImpersonationSessionModel: () => ImpersonationSessionModel,
57
59
  LicenceCategory: () => LicenceCategory,
58
60
  NotificationModel: () => NotificationModel,
59
61
  OwnerTypeSchema: () => OwnerTypeSchema,
@@ -116,7 +118,7 @@ __export(index_exports, {
116
118
  locationGeoSchema: () => locationGeoSchema,
117
119
  locationsSchema: () => locationsSchema,
118
120
  mapVendorLicenceToSubscriptionRewardType: () => mapVendorLicenceToSubscriptionRewardType,
119
- mongoose: () => import_mongoose37.default,
121
+ mongoose: () => import_mongoose38.default,
120
122
  normalizeAffiliatePromoCodes: () => normalizeAffiliatePromoCodes,
121
123
  normalizePromoCode: () => normalizePromoCode,
122
124
  notifyUsers: () => notifyUsers,
@@ -145,7 +147,7 @@ __export(index_exports, {
145
147
  updateAdStatuses: () => updateAdStatuses,
146
148
  updateAllEventDateTimeStatuses: () => updateAllEventDateTimeStatuses,
147
149
  updateRelationDatesToUnavailable: () => updateRelationDatesToUnavailable,
148
- updateSingleDateTimeStatus: () => import_cluemart_shared34.updateSingleDateTimeStatus,
150
+ updateSingleDateTimeStatus: () => import_cluemart_shared35.updateSingleDateTimeStatus,
149
151
  upgradeUserToLicence: () => upgradeUserToLicence,
150
152
  userLicenseSchema: () => userLicenseSchema,
151
153
  vendorOwnerHasProLicence: () => vendorOwnerHasProLicence,
@@ -2599,6 +2601,62 @@ schema24.index({ active: 1, deletedAt: 1, "owner.userId": 1 });
2599
2601
  schema24.index({ "couponData.participantUsers.userId": 1 });
2600
2602
  var CouponModel = import_mongoose32.default.models.Coupon || import_mongoose32.default.model("Coupon", schema24);
2601
2603
 
2604
+ // src/mongoose/Impersonation.ts
2605
+ var import_cluemart_shared22 = require("@timardex/cluemart-shared");
2606
+ var import_mongoose33 = __toESM(require("mongoose"));
2607
+ var MongooseSchema28 = import_mongoose33.default.Schema;
2608
+ var impersonationSessionSchema = new MongooseSchema28(
2609
+ {
2610
+ expiresAt: { expires: 0, required: true, type: Date },
2611
+ impersonatedUserId: {
2612
+ index: true,
2613
+ ref: "User",
2614
+ required: true,
2615
+ type: import_mongoose33.default.Schema.Types.ObjectId
2616
+ },
2617
+ impersonatorUserId: {
2618
+ index: true,
2619
+ ref: "User",
2620
+ required: true,
2621
+ type: import_mongoose33.default.Schema.Types.ObjectId
2622
+ },
2623
+ refreshToken: { required: true, type: String }
2624
+ },
2625
+ { timestamps: true }
2626
+ );
2627
+ var ImpersonationSessionModel = import_mongoose33.default.models.ImpersonationSession || import_mongoose33.default.model(
2628
+ "ImpersonationSession",
2629
+ impersonationSessionSchema
2630
+ );
2631
+ var impersonationAuditSchema = new MongooseSchema28(
2632
+ {
2633
+ action: { enum: ["start", "end"], required: true, type: String },
2634
+ endReason: { type: String },
2635
+ impersonatedUserId: {
2636
+ ref: "User",
2637
+ required: true,
2638
+ type: import_mongoose33.default.Schema.Types.ObjectId
2639
+ },
2640
+ impersonatorUserId: {
2641
+ ref: "User",
2642
+ required: true,
2643
+ type: import_mongoose33.default.Schema.Types.ObjectId
2644
+ },
2645
+ resourceId: { type: import_mongoose33.default.Schema.Types.ObjectId },
2646
+ resourceType: { enum: Object.values(import_cluemart_shared22.EnumResourceType), type: String },
2647
+ sessionId: {
2648
+ ref: "ImpersonationSession",
2649
+ required: true,
2650
+ type: import_mongoose33.default.Schema.Types.ObjectId
2651
+ }
2652
+ },
2653
+ { timestamps: true }
2654
+ );
2655
+ var ImpersonationAuditModel = import_mongoose33.default.models.ImpersonationAudit || import_mongoose33.default.model(
2656
+ "ImpersonationAudit",
2657
+ impersonationAuditSchema
2658
+ );
2659
+
2602
2660
  // src/service/promoCode/constants.ts
2603
2661
  var ACTIVE_NOT_DELETED_FILTER = {
2604
2662
  active: true,
@@ -2615,7 +2673,7 @@ async function activeAffiliateCodeExists(affiliateCode) {
2615
2673
  }
2616
2674
 
2617
2675
  // src/service/affiliate/awardAffiliateVendorSubscriptionRewards.ts
2618
- var import_cluemart_shared23 = require("@timardex/cluemart-shared");
2676
+ var import_cluemart_shared24 = require("@timardex/cluemart-shared");
2619
2677
  var import_utils3 = require("@timardex/cluemart-shared/utils");
2620
2678
 
2621
2679
  // src/service/saveNotificationsInDb.ts
@@ -2750,7 +2808,7 @@ async function sendPushNotifications({
2750
2808
  }
2751
2809
 
2752
2810
  // src/service/affiliate/vendorSubscriptionRewards.ts
2753
- var import_cluemart_shared22 = require("@timardex/cluemart-shared");
2811
+ var import_cluemart_shared23 = require("@timardex/cluemart-shared");
2754
2812
  var import_dayjs = __toESM(require("dayjs"));
2755
2813
  var import_timezone = __toESM(require("dayjs/plugin/timezone"));
2756
2814
  var import_utc = __toESM(require("dayjs/plugin/utc"));
@@ -2808,14 +2866,14 @@ import_dayjs.default.extend(import_timezone.default);
2808
2866
  var SUBSCRIPTION_REWARD_TIMEZONE = "Pacific/Auckland";
2809
2867
  async function mapVendorLicenceToSubscriptionRewardType(userId, now = /* @__PURE__ */ new Date()) {
2810
2868
  const { hasSubscription, validTypes } = await getPayingVendorStripeSubscriptionPlan(userId, now);
2811
- if (validTypes.has(import_cluemart_shared22.EnumUserLicence.PRO_VENDOR) || validTypes.has(import_cluemart_shared22.EnumUserLicence.PRO_PLUS_VENDOR)) {
2869
+ if (validTypes.has(import_cluemart_shared23.EnumUserLicence.PRO_VENDOR) || validTypes.has(import_cluemart_shared23.EnumUserLicence.PRO_PLUS_VENDOR)) {
2812
2870
  if (hasSubscription) {
2813
- return import_cluemart_shared22.EnumAffiliateRewardType.ACTIVE_VENDOR_PRO_SUBSCRIPTION;
2871
+ return import_cluemart_shared23.EnumAffiliateRewardType.ACTIVE_VENDOR_PRO_SUBSCRIPTION;
2814
2872
  }
2815
- return import_cluemart_shared22.EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
2873
+ return import_cluemart_shared23.EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
2816
2874
  }
2817
- if (validTypes.has(import_cluemart_shared22.EnumUserLicence.STANDARD_VENDOR)) {
2818
- return import_cluemart_shared22.EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
2875
+ if (validTypes.has(import_cluemart_shared23.EnumUserLicence.STANDARD_VENDOR)) {
2876
+ return import_cluemart_shared23.EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
2819
2877
  }
2820
2878
  return null;
2821
2879
  }
@@ -2827,7 +2885,7 @@ function getSubscriptionRewardPeriodBounds(now = /* @__PURE__ */ new Date()) {
2827
2885
 
2828
2886
  // src/service/affiliate/awardAffiliateVendorSubscriptionRewards.ts
2829
2887
  function isEligibleVendorResource(resource) {
2830
- return resource.resourceType === import_cluemart_shared23.EnumResourceType.VENDOR && resource.resourceActive === true && resource.resourceDeletedAt == null;
2888
+ return resource.resourceType === import_cluemart_shared24.EnumResourceType.VENDOR && resource.resourceActive === true && resource.resourceDeletedAt == null;
2831
2889
  }
2832
2890
  async function findAffiliatesWithActiveVendorReferrals() {
2833
2891
  return await AffiliateModel.find({
@@ -2836,7 +2894,7 @@ async function findAffiliatesWithActiveVendorReferrals() {
2836
2894
  $elemMatch: {
2837
2895
  resourceActive: true,
2838
2896
  resourceDeletedAt: null,
2839
- resourceType: import_cluemart_shared23.EnumResourceType.VENDOR
2897
+ resourceType: import_cluemart_shared24.EnumResourceType.VENDOR
2840
2898
  }
2841
2899
  },
2842
2900
  deletedAt: null
@@ -2870,11 +2928,11 @@ async function notifyAffiliateOwnerOfSubscriptionReward({
2870
2928
  data: {
2871
2929
  resourceId: String(affiliateId),
2872
2930
  resourceName: resourceNames.join(", "),
2873
- resourceType: import_cluemart_shared23.EnumNotificationResourceType.AFFILIATE_REWARD_RECEIVED
2931
+ resourceType: import_cluemart_shared24.EnumNotificationResourceType.AFFILIATE_REWARD_RECEIVED
2874
2932
  },
2875
2933
  message,
2876
2934
  title: "Affiliate points earned",
2877
- type: import_cluemart_shared23.EnumNotificationType.SYSTEM,
2935
+ type: import_cluemart_shared24.EnumNotificationType.SYSTEM,
2878
2936
  userIds: [affiliateOwnerUserId]
2879
2937
  };
2880
2938
  try {
@@ -2903,7 +2961,7 @@ async function tryAwardSubscriptionReward({
2903
2961
  resourceActive: true,
2904
2962
  resourceDeletedAt: null,
2905
2963
  resourceId: resource.resourceId,
2906
- resourceType: import_cluemart_shared23.EnumResourceType.VENDOR,
2964
+ resourceType: import_cluemart_shared24.EnumResourceType.VENDOR,
2907
2965
  rewards: {
2908
2966
  $not: {
2909
2967
  $elemMatch: {
@@ -3024,7 +3082,7 @@ function normalizeAffiliatePromoCodes(promoCodes) {
3024
3082
  }
3025
3083
 
3026
3084
  // src/service/database.ts
3027
- var import_mongoose36 = __toESM(require("mongoose"));
3085
+ var import_mongoose37 = __toESM(require("mongoose"));
3028
3086
  var connectToDatabase = async ({
3029
3087
  appName,
3030
3088
  dbName,
@@ -3037,7 +3095,7 @@ var connectToDatabase = async ({
3037
3095
  // Fallback to MongoDB Atlas connection string
3038
3096
  `mongodb+srv://${dbUser}:${dbPassword}@${dbName}.mongodb.net/?retryWrites=true&w=majority&appName=${appName}`
3039
3097
  );
3040
- await import_mongoose36.default.connect(mongoUri);
3098
+ await import_mongoose37.default.connect(mongoUri);
3041
3099
  const connectionType = mongodbUri ? "Local MongoDB" : "MongoDB Atlas";
3042
3100
  console.log(
3043
3101
  `${connectionType} connected from server/src/service/database.ts`
@@ -3050,7 +3108,7 @@ var connectToDatabase = async ({
3050
3108
 
3051
3109
  // src/types/index.ts
3052
3110
  var import_express = __toESM(require("express"));
3053
- var import_mongoose37 = __toESM(require("mongoose"));
3111
+ var import_mongoose38 = __toESM(require("mongoose"));
3054
3112
  var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
3055
3113
  EnumPubSubEvents2["GET_CHAT_MESSAGE"] = "GET_CHAT_MESSAGE";
3056
3114
  EnumPubSubEvents2["GET_NOTIFICATIONS"] = "GET_NOTIFICATIONS";
@@ -3105,7 +3163,7 @@ async function notifyUsers({
3105
3163
  }
3106
3164
 
3107
3165
  // src/service/updateAdStatus.ts
3108
- var import_cluemart_shared24 = require("@timardex/cluemart-shared");
3166
+ var import_cluemart_shared25 = require("@timardex/cluemart-shared");
3109
3167
  async function updateAdStatuses() {
3110
3168
  const now = /* @__PURE__ */ new Date();
3111
3169
  const invalidResult = await AdModel.updateMany(
@@ -3115,50 +3173,50 @@ async function updateAdStatuses() {
3115
3173
  { end: { $exists: false } },
3116
3174
  { $expr: { $gt: ["$start", "$end"] } }
3117
3175
  ],
3118
- status: { $ne: import_cluemart_shared24.EnumAdStatus.PAUSED }
3176
+ status: { $ne: import_cluemart_shared25.EnumAdStatus.PAUSED }
3119
3177
  },
3120
- { $set: { status: import_cluemart_shared24.EnumAdStatus.PAUSED } }
3178
+ { $set: { status: import_cluemart_shared25.EnumAdStatus.PAUSED } }
3121
3179
  );
3122
3180
  const expiredResult = await AdModel.updateMany(
3123
- { end: { $lte: now }, status: { $ne: import_cluemart_shared24.EnumAdStatus.EXPIRED } },
3124
- { $set: { status: import_cluemart_shared24.EnumAdStatus.EXPIRED } }
3181
+ { end: { $lte: now }, status: { $ne: import_cluemart_shared25.EnumAdStatus.EXPIRED } },
3182
+ { $set: { status: import_cluemart_shared25.EnumAdStatus.EXPIRED } }
3125
3183
  );
3126
3184
  const eligibleBooking = {
3127
3185
  $or: [
3128
3186
  { bookingKind: { $exists: false } },
3129
3187
  { bookingKind: null },
3130
3188
  {
3131
- approvalStatus: import_cluemart_shared24.EnumAdApprovalStatus.APPROVED,
3132
- bookingKind: import_cluemart_shared24.EnumAdBookingSlotKind.RESERVED
3189
+ approvalStatus: import_cluemart_shared25.EnumAdApprovalStatus.APPROVED,
3190
+ bookingKind: import_cluemart_shared25.EnumAdBookingSlotKind.RESERVED
3133
3191
  },
3134
3192
  {
3135
- approvalStatus: import_cluemart_shared24.EnumAdApprovalStatus.APPROVED,
3136
- bookingKind: import_cluemart_shared24.EnumAdBookingSlotKind.PAID,
3137
- paymentStatus: import_cluemart_shared24.EnumAdPaymentStatus.PAID
3193
+ approvalStatus: import_cluemart_shared25.EnumAdApprovalStatus.APPROVED,
3194
+ bookingKind: import_cluemart_shared25.EnumAdBookingSlotKind.PAID,
3195
+ paymentStatus: import_cluemart_shared25.EnumAdPaymentStatus.PAID
3138
3196
  }
3139
3197
  ]
3140
3198
  };
3141
3199
  const awaitingApprovalResult = await AdModel.updateMany(
3142
3200
  {
3143
3201
  $nor: eligibleBooking.$or,
3144
- bookingKind: { $in: Object.values(import_cluemart_shared24.EnumAdBookingSlotKind) },
3202
+ bookingKind: { $in: Object.values(import_cluemart_shared25.EnumAdBookingSlotKind) },
3145
3203
  end: { $gt: now },
3146
- status: import_cluemart_shared24.EnumAdStatus.ACTIVE
3204
+ status: import_cluemart_shared25.EnumAdStatus.ACTIVE
3147
3205
  },
3148
- { $set: { status: import_cluemart_shared24.EnumAdStatus.PAUSED } }
3206
+ { $set: { status: import_cluemart_shared25.EnumAdStatus.PAUSED } }
3149
3207
  );
3150
3208
  const activeResult = await AdModel.updateMany(
3151
3209
  {
3152
3210
  end: { $gt: now },
3153
3211
  start: { $lte: now },
3154
- status: { $ne: import_cluemart_shared24.EnumAdStatus.ACTIVE },
3212
+ status: { $ne: import_cluemart_shared25.EnumAdStatus.ACTIVE },
3155
3213
  ...eligibleBooking
3156
3214
  },
3157
- { $set: { status: import_cluemart_shared24.EnumAdStatus.ACTIVE } }
3215
+ { $set: { status: import_cluemart_shared25.EnumAdStatus.ACTIVE } }
3158
3216
  );
3159
3217
  const pausedResult = await AdModel.updateMany(
3160
- { start: { $gt: now }, status: { $ne: import_cluemart_shared24.EnumAdStatus.PAUSED } },
3161
- { $set: { status: import_cluemart_shared24.EnumAdStatus.PAUSED } }
3218
+ { start: { $gt: now }, status: { $ne: import_cluemart_shared25.EnumAdStatus.PAUSED } },
3219
+ { $set: { status: import_cluemart_shared25.EnumAdStatus.PAUSED } }
3162
3220
  );
3163
3221
  console.log(
3164
3222
  `\u2705 Ad statuses updated: invalid=${invalidResult.modifiedCount}, expired=${expiredResult.modifiedCount}, awaitingApproval=${awaitingApprovalResult.modifiedCount}, active=${activeResult.modifiedCount}, paused=${pausedResult.modifiedCount}`
@@ -3166,15 +3224,15 @@ async function updateAdStatuses() {
3166
3224
  }
3167
3225
 
3168
3226
  // src/service/objectIdToString.ts
3169
- var import_mongoose39 = __toESM(require("mongoose"));
3227
+ var import_mongoose40 = __toESM(require("mongoose"));
3170
3228
  function isValidObjectId(value) {
3171
- return import_mongoose39.default.Types.ObjectId.isValid(value);
3229
+ return import_mongoose40.default.Types.ObjectId.isValid(value);
3172
3230
  }
3173
3231
  function convertObjectIdsToStrings(obj) {
3174
3232
  if (obj === null || obj === void 0) {
3175
3233
  return obj;
3176
3234
  }
3177
- if (obj instanceof import_mongoose39.default.Types.ObjectId) {
3235
+ if (obj instanceof import_mongoose40.default.Types.ObjectId) {
3178
3236
  return obj.toString();
3179
3237
  }
3180
3238
  if (obj instanceof Date) {
@@ -3194,16 +3252,16 @@ function convertObjectIdsToStrings(obj) {
3194
3252
  }
3195
3253
 
3196
3254
  // src/service/event/updateAllEventDateTimeStatuses.ts
3197
- var import_cluemart_shared26 = require("@timardex/cluemart-shared");
3255
+ var import_cluemart_shared27 = require("@timardex/cluemart-shared");
3198
3256
  var import_dayjs2 = __toESM(require("dayjs"));
3199
3257
 
3200
3258
  // src/service/event/archiveEndedEventDates.ts
3201
- var import_cluemart_shared25 = require("@timardex/cluemart-shared");
3259
+ var import_cluemart_shared26 = require("@timardex/cluemart-shared");
3202
3260
  var ARCHIVED_STATUSES = /* @__PURE__ */ new Set([
3203
- import_cluemart_shared25.EnumEventDateStatus.ENDED
3261
+ import_cluemart_shared26.EnumEventDateStatus.ENDED
3204
3262
  ]);
3205
3263
  var DISCARDED_STATUSES = /* @__PURE__ */ new Set([
3206
- import_cluemart_shared25.EnumEventDateStatus.INVALID
3264
+ import_cluemart_shared26.EnumEventDateStatus.INVALID
3207
3265
  ]);
3208
3266
  function splitEventDatesForArchive(dateTime) {
3209
3267
  return {
@@ -3266,7 +3324,7 @@ async function updateModelDateTimeStatuses(model, now) {
3266
3324
  try {
3267
3325
  for await (const doc of cursor) {
3268
3326
  const dateTime = doc.dateTime.map(
3269
- (slot) => (0, import_cluemart_shared26.updateSingleDateTimeStatus)(slot, now)
3327
+ (slot) => (0, import_cluemart_shared27.updateSingleDateTimeStatus)(slot, now)
3270
3328
  );
3271
3329
  if (!hasDateTimeStatusChanges(doc.dateTime, dateTime)) {
3272
3330
  continue;
@@ -3289,7 +3347,7 @@ async function updateModelDateTimeStatuses(model, now) {
3289
3347
  }
3290
3348
  var ARCHIVABLE_EVENT_FILTER = {
3291
3349
  "dateTime.dateStatus": {
3292
- $in: [import_cluemart_shared26.EnumEventDateStatus.ENDED, import_cluemart_shared26.EnumEventDateStatus.INVALID]
3350
+ $in: [import_cluemart_shared27.EnumEventDateStatus.ENDED, import_cluemart_shared27.EnumEventDateStatus.INVALID]
3293
3351
  },
3294
3352
  deletedAt: null
3295
3353
  };
@@ -3311,7 +3369,7 @@ async function archiveEndedAndDiscardInvalidEventDates(now) {
3311
3369
  try {
3312
3370
  for await (const doc of cursor) {
3313
3371
  const updated = doc.dateTime.map(
3314
- (slot) => (0, import_cluemart_shared26.updateSingleDateTimeStatus)(slot, now)
3372
+ (slot) => (0, import_cluemart_shared27.updateSingleDateTimeStatus)(slot, now)
3315
3373
  );
3316
3374
  const { archive, discard } = splitEventDatesForArchive(updated);
3317
3375
  if (archive.length === 0 && discard.length === 0) {
@@ -3335,7 +3393,7 @@ async function archiveEndedAndDiscardInvalidEventDates(now) {
3335
3393
  $pull: {
3336
3394
  dateTime: {
3337
3395
  dateStatus: {
3338
- $in: [import_cluemart_shared26.EnumEventDateStatus.ENDED, import_cluemart_shared26.EnumEventDateStatus.INVALID]
3396
+ $in: [import_cluemart_shared27.EnumEventDateStatus.ENDED, import_cluemart_shared27.EnumEventDateStatus.INVALID]
3339
3397
  }
3340
3398
  }
3341
3399
  }
@@ -3369,9 +3427,9 @@ async function cleanEventInfoDates(now) {
3369
3427
  try {
3370
3428
  for await (const doc of cursor) {
3371
3429
  const updated = doc.dateTime.map(
3372
- (slot) => (0, import_cluemart_shared26.updateSingleDateTimeStatus)(slot, now)
3430
+ (slot) => (0, import_cluemart_shared27.updateSingleDateTimeStatus)(slot, now)
3373
3431
  );
3374
- const kept = (0, import_cluemart_shared26.filterDatesByFutureStatus)(updated);
3432
+ const kept = (0, import_cluemart_shared27.filterDatesByFutureStatus)(updated);
3375
3433
  if (kept.length === updated.length) {
3376
3434
  continue;
3377
3435
  }
@@ -3417,7 +3475,7 @@ async function updateAllEventDateTimeStatuses() {
3417
3475
  }
3418
3476
 
3419
3477
  // src/service/index.ts
3420
- var import_cluemart_shared34 = require("@timardex/cluemart-shared");
3478
+ var import_cluemart_shared35 = require("@timardex/cluemart-shared");
3421
3479
 
3422
3480
  // src/service/event/findEventOrImportedMarketById.ts
3423
3481
  async function findEventOrImportedMarketById(resourceId) {
@@ -3433,7 +3491,7 @@ async function findEventOrImportedMarketById(resourceId) {
3433
3491
  }
3434
3492
 
3435
3493
  // src/service/relations.ts
3436
- var import_cluemart_shared27 = require("@timardex/cluemart-shared");
3494
+ var import_cluemart_shared28 = require("@timardex/cluemart-shared");
3437
3495
  function didRemoveAnyEventDates(previousDateTime, nextDateTime) {
3438
3496
  if (!previousDateTime?.length) {
3439
3497
  return false;
@@ -3451,7 +3509,7 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
3451
3509
  ) ?? false;
3452
3510
  return {
3453
3511
  ...relationDate,
3454
- status: existsInEvent ? relationDate.status : import_cluemart_shared27.EnumInviteStatus.UNAVAILABLE
3512
+ status: existsInEvent ? relationDate.status : import_cluemart_shared28.EnumInviteStatus.UNAVAILABLE
3455
3513
  };
3456
3514
  });
3457
3515
  }
@@ -3460,15 +3518,15 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
3460
3518
  var import_dayjs6 = __toESM(require("dayjs"));
3461
3519
 
3462
3520
  // src/service/license/compliance/utils.ts
3463
- var import_cluemart_shared32 = require("@timardex/cluemart-shared");
3521
+ var import_cluemart_shared33 = require("@timardex/cluemart-shared");
3464
3522
  var import_dayjs5 = __toESM(require("dayjs"));
3465
3523
 
3466
3524
  // src/service/license/compliance/event.ts
3467
- var import_cluemart_shared28 = require("@timardex/cluemart-shared");
3525
+ var import_cluemart_shared29 = require("@timardex/cluemart-shared");
3468
3526
  var eventLicences = [
3469
- import_cluemart_shared28.EnumUserLicence.STANDARD_EVENT,
3470
- import_cluemart_shared28.EnumUserLicence.PRO_EVENT,
3471
- import_cluemart_shared28.EnumUserLicence.PRO_PLUS_EVENT
3527
+ import_cluemart_shared29.EnumUserLicence.STANDARD_EVENT,
3528
+ import_cluemart_shared29.EnumUserLicence.PRO_EVENT,
3529
+ import_cluemart_shared29.EnumUserLicence.PRO_PLUS_EVENT
3472
3530
  ];
3473
3531
  async function handleEventLicenceCompliance(user, now) {
3474
3532
  if (!user.licences || !user.events?.length) {
@@ -3680,9 +3738,9 @@ function buildLicenceExpiryPipeline(params) {
3680
3738
  }
3681
3739
 
3682
3740
  // src/service/license/compliance/partner.ts
3683
- var import_cluemart_shared29 = require("@timardex/cluemart-shared");
3741
+ var import_cluemart_shared30 = require("@timardex/cluemart-shared");
3684
3742
  var partnerLicences = [
3685
- import_cluemart_shared29.EnumUserLicence.STANDARD_PARTNER
3743
+ import_cluemart_shared30.EnumUserLicence.STANDARD_PARTNER
3686
3744
  ];
3687
3745
  async function handlePartnerLicenceCompliance(user, now) {
3688
3746
  if (!user.licences || !user.partner) {
@@ -3692,11 +3750,11 @@ async function handlePartnerLicenceCompliance(user, now) {
3692
3750
  }
3693
3751
 
3694
3752
  // src/service/license/compliance/vendor.ts
3695
- var import_cluemart_shared31 = require("@timardex/cluemart-shared");
3753
+ var import_cluemart_shared32 = require("@timardex/cluemart-shared");
3696
3754
  var import_dayjs4 = __toESM(require("dayjs"));
3697
3755
 
3698
3756
  // src/service/license/models.ts
3699
- var import_cluemart_shared30 = require("@timardex/cluemart-shared");
3757
+ var import_cluemart_shared31 = require("@timardex/cluemart-shared");
3700
3758
  var import_dayjs3 = __toESM(require("dayjs"));
3701
3759
  var import_graphql = require("graphql");
3702
3760
  var LicenceCategory = /* @__PURE__ */ ((LicenceCategory2) => {
@@ -3708,31 +3766,31 @@ var LicenceCategory = /* @__PURE__ */ ((LicenceCategory2) => {
3708
3766
  return LicenceCategory2;
3709
3767
  })(LicenceCategory || {});
3710
3768
  var licenceCategoryMapping = {
3711
- [import_cluemart_shared30.EnumUserLicence.PRO_EVENT]: "event" /* EVENT */,
3712
- [import_cluemart_shared30.EnumUserLicence.PRO_PLUS_EVENT]: "event" /* EVENT */,
3713
- [import_cluemart_shared30.EnumUserLicence.PRO_PLUS_VENDOR]: "vendor" /* VENDOR */,
3714
- [import_cluemart_shared30.EnumUserLicence.PRO_VENDOR]: "vendor" /* VENDOR */,
3715
- [import_cluemart_shared30.EnumUserLicence.STANDARD_EVENT]: "event" /* EVENT */,
3716
- [import_cluemart_shared30.EnumUserLicence.STANDARD_PARTNER]: "partner" /* PARTNER */,
3717
- [import_cluemart_shared30.EnumUserLicence.STANDARD_VENDOR]: "vendor" /* VENDOR */,
3718
- [import_cluemart_shared30.EnumUserLicence.STANDARD_AFFILIATE]: "affiliate" /* AFFILIATE */,
3719
- [import_cluemart_shared30.EnumUserLicence.STANDARD_SCHOOL]: "school" /* SCHOOL */
3769
+ [import_cluemart_shared31.EnumUserLicence.PRO_EVENT]: "event" /* EVENT */,
3770
+ [import_cluemart_shared31.EnumUserLicence.PRO_PLUS_EVENT]: "event" /* EVENT */,
3771
+ [import_cluemart_shared31.EnumUserLicence.PRO_PLUS_VENDOR]: "vendor" /* VENDOR */,
3772
+ [import_cluemart_shared31.EnumUserLicence.PRO_VENDOR]: "vendor" /* VENDOR */,
3773
+ [import_cluemart_shared31.EnumUserLicence.STANDARD_EVENT]: "event" /* EVENT */,
3774
+ [import_cluemart_shared31.EnumUserLicence.STANDARD_PARTNER]: "partner" /* PARTNER */,
3775
+ [import_cluemart_shared31.EnumUserLicence.STANDARD_VENDOR]: "vendor" /* VENDOR */,
3776
+ [import_cluemart_shared31.EnumUserLicence.STANDARD_AFFILIATE]: "affiliate" /* AFFILIATE */,
3777
+ [import_cluemart_shared31.EnumUserLicence.STANDARD_SCHOOL]: "school" /* SCHOOL */
3720
3778
  };
3721
3779
  var licencePriority = {
3722
- [import_cluemart_shared30.EnumUserLicence.PRO_PLUS_EVENT]: 3,
3723
- [import_cluemart_shared30.EnumUserLicence.PRO_EVENT]: 2,
3724
- [import_cluemart_shared30.EnumUserLicence.STANDARD_EVENT]: 1,
3725
- [import_cluemart_shared30.EnumUserLicence.PRO_PLUS_VENDOR]: 3,
3726
- [import_cluemart_shared30.EnumUserLicence.PRO_VENDOR]: 2,
3727
- [import_cluemart_shared30.EnumUserLicence.STANDARD_VENDOR]: 1,
3728
- [import_cluemart_shared30.EnumUserLicence.STANDARD_PARTNER]: 1,
3729
- [import_cluemart_shared30.EnumUserLicence.STANDARD_AFFILIATE]: 1,
3730
- [import_cluemart_shared30.EnumUserLicence.STANDARD_SCHOOL]: 1
3780
+ [import_cluemart_shared31.EnumUserLicence.PRO_PLUS_EVENT]: 3,
3781
+ [import_cluemart_shared31.EnumUserLicence.PRO_EVENT]: 2,
3782
+ [import_cluemart_shared31.EnumUserLicence.STANDARD_EVENT]: 1,
3783
+ [import_cluemart_shared31.EnumUserLicence.PRO_PLUS_VENDOR]: 3,
3784
+ [import_cluemart_shared31.EnumUserLicence.PRO_VENDOR]: 2,
3785
+ [import_cluemart_shared31.EnumUserLicence.STANDARD_VENDOR]: 1,
3786
+ [import_cluemart_shared31.EnumUserLicence.STANDARD_PARTNER]: 1,
3787
+ [import_cluemart_shared31.EnumUserLicence.STANDARD_AFFILIATE]: 1,
3788
+ [import_cluemart_shared31.EnumUserLicence.STANDARD_SCHOOL]: 1
3731
3789
  };
3732
3790
  var standardLicences = [
3733
- import_cluemart_shared30.EnumUserLicence.STANDARD_VENDOR,
3734
- import_cluemart_shared30.EnumUserLicence.STANDARD_EVENT,
3735
- import_cluemart_shared30.EnumUserLicence.STANDARD_PARTNER
3791
+ import_cluemart_shared31.EnumUserLicence.STANDARD_VENDOR,
3792
+ import_cluemart_shared31.EnumUserLicence.STANDARD_EVENT,
3793
+ import_cluemart_shared31.EnumUserLicence.STANDARD_PARTNER
3736
3794
  ];
3737
3795
  var standardLicenceSet = new Set(standardLicences);
3738
3796
  function isStandardLicence(licence) {
@@ -3746,11 +3804,11 @@ var categoryRegexMapping = {
3746
3804
  ["school" /* SCHOOL */]: /_school$/
3747
3805
  };
3748
3806
  var categoryFallbackLicence = {
3749
- ["event" /* EVENT */]: import_cluemart_shared30.EnumUserLicence.STANDARD_EVENT,
3750
- ["partner" /* PARTNER */]: import_cluemart_shared30.EnumUserLicence.STANDARD_PARTNER,
3751
- ["vendor" /* VENDOR */]: import_cluemart_shared30.EnumUserLicence.STANDARD_VENDOR,
3752
- ["affiliate" /* AFFILIATE */]: import_cluemart_shared30.EnumUserLicence.STANDARD_AFFILIATE,
3753
- ["school" /* SCHOOL */]: import_cluemart_shared30.EnumUserLicence.STANDARD_SCHOOL
3807
+ ["event" /* EVENT */]: import_cluemart_shared31.EnumUserLicence.STANDARD_EVENT,
3808
+ ["partner" /* PARTNER */]: import_cluemart_shared31.EnumUserLicence.STANDARD_PARTNER,
3809
+ ["vendor" /* VENDOR */]: import_cluemart_shared31.EnumUserLicence.STANDARD_VENDOR,
3810
+ ["affiliate" /* AFFILIATE */]: import_cluemart_shared31.EnumUserLicence.STANDARD_AFFILIATE,
3811
+ ["school" /* SCHOOL */]: import_cluemart_shared31.EnumUserLicence.STANDARD_SCHOOL
3754
3812
  };
3755
3813
  var LicenceFilterInput = {
3756
3814
  INPUT_USER_LICENCES: "$licences"
@@ -3780,11 +3838,11 @@ function getHighestLicenceForCategory(licences, category) {
3780
3838
  function createLicenceObject(expiryDate, licenceType) {
3781
3839
  const today = (0, import_dayjs3.default)();
3782
3840
  const expiryDateMapping = {
3783
- [import_cluemart_shared30.LicenceExpiryDate.ONE_YEAR]: today.add(1, "year").endOf("day").toDate(),
3784
- [import_cluemart_shared30.LicenceExpiryDate.ONE_MONTH]: today.add(1, "month").endOf("day").toDate(),
3785
- [import_cluemart_shared30.LicenceExpiryDate.TWO_MONTHS]: today.add(2, "month").endOf("day").toDate(),
3786
- [import_cluemart_shared30.LicenceExpiryDate.THREE_MONTHS]: today.add(3, "month").endOf("day").toDate(),
3787
- [import_cluemart_shared30.LicenceExpiryDate.SIX_MONTHS]: today.add(6, "month").endOf("day").toDate()
3841
+ [import_cluemart_shared31.LicenceExpiryDate.ONE_YEAR]: today.add(1, "year").endOf("day").toDate(),
3842
+ [import_cluemart_shared31.LicenceExpiryDate.ONE_MONTH]: today.add(1, "month").endOf("day").toDate(),
3843
+ [import_cluemart_shared31.LicenceExpiryDate.TWO_MONTHS]: today.add(2, "month").endOf("day").toDate(),
3844
+ [import_cluemart_shared31.LicenceExpiryDate.THREE_MONTHS]: today.add(3, "month").endOf("day").toDate(),
3845
+ [import_cluemart_shared31.LicenceExpiryDate.SIX_MONTHS]: today.add(6, "month").endOf("day").toDate()
3788
3846
  };
3789
3847
  const licenceObject = {
3790
3848
  expiryDate: expiryDateMapping[expiryDate],
@@ -3888,13 +3946,13 @@ async function checkOwnerHasLicence({
3888
3946
  const owner = await UserModel.findById(userId);
3889
3947
  if (!owner) throw new import_graphql.GraphQLError("Owner not found");
3890
3948
  const categoryByResource = {
3891
- [import_cluemart_shared30.EnumResourceType.EVENT]: "event" /* EVENT */,
3892
- [import_cluemart_shared30.EnumResourceType.PARTNER]: "partner" /* PARTNER */,
3893
- [import_cluemart_shared30.EnumResourceType.VENDOR]: "vendor" /* VENDOR */,
3894
- [import_cluemart_shared30.EnumResourceType.AFFILIATE]: "affiliate" /* AFFILIATE */,
3895
- [import_cluemart_shared30.EnumResourceType.SCHOOL]: "school" /* SCHOOL */
3949
+ [import_cluemart_shared31.EnumResourceType.EVENT]: "event" /* EVENT */,
3950
+ [import_cluemart_shared31.EnumResourceType.PARTNER]: "partner" /* PARTNER */,
3951
+ [import_cluemart_shared31.EnumResourceType.VENDOR]: "vendor" /* VENDOR */,
3952
+ [import_cluemart_shared31.EnumResourceType.AFFILIATE]: "affiliate" /* AFFILIATE */,
3953
+ [import_cluemart_shared31.EnumResourceType.SCHOOL]: "school" /* SCHOOL */
3896
3954
  };
3897
- if (!(0, import_cluemart_shared30.isNonVisitorResourceType)(resourceType)) {
3955
+ if (!(0, import_cluemart_shared31.isNonVisitorResourceType)(resourceType)) {
3898
3956
  throw new import_graphql.GraphQLError(`Invalid resource type: ${resourceType}.`);
3899
3957
  }
3900
3958
  const requiredCategory = categoryByResource[resourceType];
@@ -3974,7 +4032,7 @@ async function applyVendorDowngrade(vendor, ownerUserId) {
3974
4032
  return (result?.matchedCount ?? 0) > 0;
3975
4033
  }
3976
4034
  async function downgradeVendorProFeatures(userId, licenceType) {
3977
- const isStandardVendor = licenceType === import_cluemart_shared31.EnumUserLicence.STANDARD_VENDOR;
4035
+ const isStandardVendor = licenceType === import_cluemart_shared32.EnumUserLicence.STANDARD_VENDOR;
3978
4036
  if (!isStandardVendor) {
3979
4037
  return;
3980
4038
  }
@@ -4021,7 +4079,7 @@ async function applyVendorRestore(vendor, ownerUserId) {
4021
4079
  return (result?.matchedCount ?? 0) > 0;
4022
4080
  }
4023
4081
  async function restoreVendorProFeatures(userId, licenceType) {
4024
- const isProVendor = licenceType === import_cluemart_shared31.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared31.EnumUserLicence.PRO_PLUS_VENDOR;
4082
+ const isProVendor = licenceType === import_cluemart_shared32.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared32.EnumUserLicence.PRO_PLUS_VENDOR;
4025
4083
  if (!isProVendor) {
4026
4084
  return;
4027
4085
  }
@@ -4042,14 +4100,14 @@ function isProtectedByCurrentStripeSubscription(user, licenceType, now) {
4042
4100
  return false;
4043
4101
  }
4044
4102
  const gracePeriodEndsAt = stripe.paymentGracePeriodEndsAt ? (0, import_dayjs4.default)(stripe.paymentGracePeriodEndsAt) : null;
4045
- const hasActivePaymentGracePeriod = (stripe.status === import_cluemart_shared31.EnumSubscriptionStatus.PAST_DUE || stripe.status === import_cluemart_shared31.EnumSubscriptionStatus.INACTIVE) && Boolean(stripe.paymentGraceSubscriptionId) && (!stripe.subscriptionId || stripe.subscriptionId === stripe.paymentGraceSubscriptionId) && gracePeriodEndsAt !== null && gracePeriodEndsAt.isValid() && gracePeriodEndsAt.isAfter(now);
4103
+ const hasActivePaymentGracePeriod = (stripe.status === import_cluemart_shared32.EnumSubscriptionStatus.PAST_DUE || stripe.status === import_cluemart_shared32.EnumSubscriptionStatus.INACTIVE) && Boolean(stripe.paymentGraceSubscriptionId) && (!stripe.subscriptionId || stripe.subscriptionId === stripe.paymentGraceSubscriptionId) && gracePeriodEndsAt !== null && gracePeriodEndsAt.isValid() && gracePeriodEndsAt.isAfter(now);
4046
4104
  if (hasActivePaymentGracePeriod) {
4047
4105
  return true;
4048
4106
  }
4049
4107
  if (!stripe.subscriptionId) {
4050
4108
  return false;
4051
4109
  }
4052
- if (stripe.status !== import_cluemart_shared31.EnumSubscriptionStatus.ACTIVE) {
4110
+ if (stripe.status !== import_cluemart_shared32.EnumSubscriptionStatus.ACTIVE) {
4053
4111
  return false;
4054
4112
  }
4055
4113
  if (!stripe.endDate) {
@@ -4069,7 +4127,7 @@ async function handleVendorLicenceCompliance(user, now) {
4069
4127
  return;
4070
4128
  }
4071
4129
  const proLicences = vendorLicencesOfUser.filter(
4072
- (licence) => licence.licenceType !== import_cluemart_shared31.EnumUserLicence.STANDARD_VENDOR
4130
+ (licence) => licence.licenceType !== import_cluemart_shared32.EnumUserLicence.STANDARD_VENDOR
4073
4131
  );
4074
4132
  const expiredProLicences = proLicences.filter(
4075
4133
  (licence) => !(0, import_dayjs4.default)(licence.expiryDate).isAfter(now)
@@ -4082,7 +4140,7 @@ async function handleVendorLicenceCompliance(user, now) {
4082
4140
  const expiredProLicence = expiredProLicences.some(
4083
4141
  (licence) => !stripeProtectedLicenceTypes.has(licence.licenceType)
4084
4142
  );
4085
- const hasValidProLicence = stripeProtectedLicenceTypes.size > 0 || hasValidLicence(proLicences, import_cluemart_shared31.vendorLicences, now);
4143
+ const hasValidProLicence = stripeProtectedLicenceTypes.size > 0 || hasValidLicence(proLicences, import_cluemart_shared32.vendorLicences, now);
4086
4144
  const hasExpiredVendorLicence = vendorLicencesOfUser.some(
4087
4145
  (licence) => !(0, import_dayjs4.default)(licence.expiryDate).isAfter(now) && !stripeProtectedLicenceTypes.has(licence.licenceType)
4088
4146
  );
@@ -4098,7 +4156,7 @@ async function handleVendorLicenceCompliance(user, now) {
4098
4156
  "owner.userId": user._id
4099
4157
  }).lean().exec();
4100
4158
  }
4101
- const licencesToSync = import_cluemart_shared31.vendorLicences.filter(
4159
+ const licencesToSync = import_cluemart_shared32.vendorLicences.filter(
4102
4160
  (licenceType) => !stripeProtectedLicenceTypes.has(licenceType)
4103
4161
  );
4104
4162
  await syncUserLicencesAfterExpiry(user._id, licencesToSync, now, "downgrade");
@@ -4113,11 +4171,11 @@ async function handleVendorLicenceCompliance(user, now) {
4113
4171
  data: {
4114
4172
  resourceId: String(vendor._id),
4115
4173
  resourceName: vendor.name,
4116
- resourceType: import_cluemart_shared31.EnumNotificationResourceType.DOWNGRADED_VENDOR
4174
+ resourceType: import_cluemart_shared32.EnumNotificationResourceType.DOWNGRADED_VENDOR
4117
4175
  },
4118
4176
  message: `Your Vendor licence has been downgraded due to licence expiration.`,
4119
4177
  title: `Vendor Licence Downgraded`,
4120
- type: import_cluemart_shared31.EnumNotificationType.SYSTEM,
4178
+ type: import_cluemart_shared32.EnumNotificationType.SYSTEM,
4121
4179
  userIds: [user._id]
4122
4180
  };
4123
4181
  await sendDeactivationNotification(payload, user._id, vendor.name, "vendor");
@@ -4150,7 +4208,7 @@ async function vendorOwnerHasProLicence(vendorId) {
4150
4208
  effectiveVendorLicences,
4151
4209
  "vendor" /* VENDOR */
4152
4210
  );
4153
- return highestVendorLicence !== null && licencePriority[highestVendorLicence] >= licencePriority[import_cluemart_shared31.EnumUserLicence.PRO_VENDOR];
4211
+ return highestVendorLicence !== null && licencePriority[highestVendorLicence] >= licencePriority[import_cluemart_shared32.EnumUserLicence.PRO_VENDOR];
4154
4212
  }
4155
4213
 
4156
4214
  // src/service/license/compliance/utils.ts
@@ -4160,12 +4218,12 @@ async function syncUserLicencesAfterExpiry(userId, licenceTypes, now, mode = "do
4160
4218
  const pipeline = buildLicenceExpiryPipeline({
4161
4219
  downgradeBranches: [
4162
4220
  {
4163
- case: import_cluemart_shared32.EnumUserLicence.PRO_PLUS_VENDOR,
4164
- then: import_cluemart_shared32.EnumUserLicence.STANDARD_VENDOR
4221
+ case: import_cluemart_shared33.EnumUserLicence.PRO_PLUS_VENDOR,
4222
+ then: import_cluemart_shared33.EnumUserLicence.STANDARD_VENDOR
4165
4223
  },
4166
4224
  {
4167
- case: import_cluemart_shared32.EnumUserLicence.PRO_VENDOR,
4168
- then: import_cluemart_shared32.EnumUserLicence.STANDARD_VENDOR
4225
+ case: import_cluemart_shared33.EnumUserLicence.PRO_VENDOR,
4226
+ then: import_cluemart_shared33.EnumUserLicence.STANDARD_VENDOR
4169
4227
  }
4170
4228
  ],
4171
4229
  licenceTypes,
@@ -4294,7 +4352,7 @@ var REMINDER_WINDOW_MIN_HOURS = 6.5 * 24;
4294
4352
  var REMINDER_WINDOW_MAX_HOURS = 7.5 * 24;
4295
4353
 
4296
4354
  // src/service/license/reminder/utils.ts
4297
- var import_cluemart_shared33 = require("@timardex/cluemart-shared");
4355
+ var import_cluemart_shared34 = require("@timardex/cluemart-shared");
4298
4356
  var import_utils8 = require("@timardex/cluemart-shared/utils");
4299
4357
  var import_dayjs7 = __toESM(require("dayjs"));
4300
4358
 
@@ -4360,28 +4418,28 @@ function isLicenseExpiringIn7Days(expiryDate, now) {
4360
4418
  return hoursUntilExpiry >= REMINDER_WINDOW_MIN_HOURS && hoursUntilExpiry <= REMINDER_WINDOW_MAX_HOURS;
4361
4419
  }
4362
4420
  function getLicenseName(licenceType) {
4363
- return import_cluemart_shared33.licenseNiceNames[licenceType] || licenceType;
4421
+ return import_cluemart_shared34.licenseNiceNames[licenceType] || licenceType;
4364
4422
  }
4365
4423
  function getNotificationTypes(isVendorLicense, isPartnerLicense) {
4366
4424
  if (isVendorLicense) {
4367
4425
  return {
4368
- notificationType: import_cluemart_shared33.EnumNotificationType.SYSTEM,
4369
- resourceType: import_cluemart_shared33.EnumNotificationResourceType.EXPIRATION_REMINDER_VENDOR
4426
+ notificationType: import_cluemart_shared34.EnumNotificationType.SYSTEM,
4427
+ resourceType: import_cluemart_shared34.EnumNotificationResourceType.EXPIRATION_REMINDER_VENDOR
4370
4428
  };
4371
4429
  }
4372
4430
  if (isPartnerLicense) {
4373
4431
  return {
4374
- notificationType: import_cluemart_shared33.EnumNotificationType.SYSTEM,
4375
- resourceType: import_cluemart_shared33.EnumNotificationResourceType.EXPIRATION_REMINDER_PARTNER
4432
+ notificationType: import_cluemart_shared34.EnumNotificationType.SYSTEM,
4433
+ resourceType: import_cluemart_shared34.EnumNotificationResourceType.EXPIRATION_REMINDER_PARTNER
4376
4434
  };
4377
4435
  }
4378
4436
  return {
4379
- notificationType: import_cluemart_shared33.EnumNotificationType.SYSTEM,
4380
- resourceType: import_cluemart_shared33.EnumNotificationResourceType.EXPIRATION_REMINDER_EVENT
4437
+ notificationType: import_cluemart_shared34.EnumNotificationType.SYSTEM,
4438
+ resourceType: import_cluemart_shared34.EnumNotificationResourceType.EXPIRATION_REMINDER_EVENT
4381
4439
  };
4382
4440
  }
4383
4441
  async function getLicenseResourceInfo(user, licence) {
4384
- const isVendorLicense = import_cluemart_shared33.vendorLicences.includes(licence.licenceType);
4442
+ const isVendorLicense = import_cluemart_shared34.vendorLicences.includes(licence.licenceType);
4385
4443
  const isPartnerLicense = partnerLicences.includes(licence.licenceType);
4386
4444
  const licenceName = getLicenseName(licence.licenceType);
4387
4445
  const { notificationType, resourceType } = getNotificationTypes(
@@ -4429,11 +4487,11 @@ async function getLicenseResourceInfo(user, licence) {
4429
4487
  };
4430
4488
  }
4431
4489
  function getLicenceExpiryMode(licenceType) {
4432
- return licenceType === import_cluemart_shared33.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared33.EnumUserLicence.PRO_PLUS_VENDOR ? "downgrade" : "extend";
4490
+ return licenceType === import_cluemart_shared34.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared34.EnumUserLicence.PRO_PLUS_VENDOR ? "downgrade" : "extend";
4433
4491
  }
4434
4492
  async function sendLicenseReminder(user, licence) {
4435
4493
  const licenceName = getLicenseName(licence.licenceType);
4436
- const expiryDate = (0, import_dayjs7.default)(licence.expiryDate).format(import_cluemart_shared33.dateFormat);
4494
+ const expiryDate = (0, import_dayjs7.default)(licence.expiryDate).format(import_cluemart_shared34.dateFormat);
4437
4495
  const userId = String(user._id);
4438
4496
  const resourceInfo = await getLicenseResourceInfo(user, licence);
4439
4497
  if (!resourceInfo) {
@@ -4582,6 +4640,8 @@ async function remindUsersAboutLicenseExpiration() {
4582
4640
  EventModel,
4583
4641
  GameModel,
4584
4642
  GoogleImportedMarketModel,
4643
+ ImpersonationAuditModel,
4644
+ ImpersonationSessionModel,
4585
4645
  LicenceCategory,
4586
4646
  NotificationModel,
4587
4647
  OwnerTypeSchema,