@timardex/cluemart-server-shared 2.0.2 → 2.1.1

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
@@ -31,8 +31,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
33
  ACTIVE_NOT_DELETED_FILTER: () => ACTIVE_NOT_DELETED_FILTER,
34
+ AD_BILLING_CATALOG_COLLECTION_NAME: () => AD_BILLING_CATALOG_COLLECTION_NAME,
34
35
  APP_SETTINGS_ID: () => APP_SETTINGS_ID,
36
+ AdBillingCatalogModel: () => AdBillingCatalogModel,
37
+ AdBookingModel: () => AdBookingModel,
38
+ AdImpressionModel: () => AdImpressionModel,
35
39
  AdModel: () => AdModel,
40
+ AdSettingsModel: () => AdSettingsModel,
36
41
  AffiliateModel: () => AffiliateModel,
37
42
  AppSettingModel: () => AppSettingModel,
38
43
  BILLING_CATALOG_COLLECTION_NAME: () => BILLING_CATALOG_COLLECTION_NAME,
@@ -42,6 +47,7 @@ __export(index_exports, {
42
47
  ChatReportModel: () => ChatReportModel,
43
48
  ContactDetailsSchema: () => ContactDetailsSchema,
44
49
  CouponModel: () => CouponModel,
50
+ DEFAULT_AD_SETTINGS: () => DEFAULT_AD_SETTINGS,
45
51
  EnumPubSubEvents: () => EnumPubSubEvents,
46
52
  EventInfoModel: () => EventInfoModel,
47
53
  EventModel: () => EventModel,
@@ -80,6 +86,7 @@ __export(index_exports, {
80
86
  createLicenceObject: () => createLicenceObject,
81
87
  dateTimeSchema: () => dateTimeSchema2,
82
88
  didRemoveAnyEventDates: () => didRemoveAnyEventDates,
89
+ downgradeVendorProFeatures: () => downgradeVendorProFeatures,
83
90
  ensureUserLicenseCompliance: () => ensureUserLicenseCompliance,
84
91
  ensureUserLicenseComplianceForUser: () => ensureUserLicenseComplianceForUser,
85
92
  eventLicences: () => eventLicences,
@@ -108,7 +115,7 @@ __export(index_exports, {
108
115
  locationGeoSchema: () => locationGeoSchema,
109
116
  locationsSchema: () => locationsSchema,
110
117
  mapVendorLicenceToSubscriptionRewardType: () => mapVendorLicenceToSubscriptionRewardType,
111
- mongoose: () => import_mongoose32.default,
118
+ mongoose: () => import_mongoose36.default,
112
119
  normalizeAffiliatePromoCodes: () => normalizeAffiliatePromoCodes,
113
120
  normalizePromoCode: () => normalizePromoCode,
114
121
  notifyUsers: () => notifyUsers,
@@ -123,7 +130,9 @@ __export(index_exports, {
123
130
  remindUsersAboutLicenseExpiration: () => remindUsersAboutLicenseExpiration,
124
131
  replaceUserLicenceWithObject: () => replaceUserLicenceWithObject,
125
132
  resourceRelationsSchema: () => resourceRelationsSchema,
133
+ restoreVendorProFeatures: () => restoreVendorProFeatures,
126
134
  saveNotificationsInDb: () => saveNotificationsInDb,
135
+ schemaAdresource: () => schemaAdresource,
127
136
  sendDeactivationNotification: () => sendDeactivationNotification,
128
137
  sendLicenseReminder: () => sendLicenseReminder,
129
138
  sendPushNotifications: () => sendPushNotifications,
@@ -135,7 +144,6 @@ __export(index_exports, {
135
144
  updateAllEventDateTimeStatuses: () => updateAllEventDateTimeStatuses,
136
145
  updateRelationDatesToUnavailable: () => updateRelationDatesToUnavailable,
137
146
  updateSingleDateTimeStatus: () => updateSingleDateTimeStatus,
138
- updateVendorBasedOnUserLicense: () => updateVendorBasedOnUserLicense,
139
147
  upgradeUserToLicence: () => upgradeUserToLicence,
140
148
  userLicenseSchema: () => userLicenseSchema,
141
149
  vendorLicences: () => vendorLicences,
@@ -177,9 +185,30 @@ var schemaAdresource = new MongooseSchema({
177
185
  var schema = new MongooseSchema(
178
186
  {
179
187
  active: { default: true, type: Boolean },
188
+ adminManaged: { default: false, type: Boolean },
189
+ approvalStatus: {
190
+ enum: Object.values(import_cluemart_shared.EnumAdApprovalStatus),
191
+ required: false,
192
+ type: String
193
+ },
194
+ bookingIds: {
195
+ default: void 0,
196
+ ref: "AdBooking",
197
+ type: [import_mongoose.default.Schema.Types.ObjectId]
198
+ },
199
+ bookingKind: {
200
+ enum: Object.values(import_cluemart_shared.EnumAdBookingSlotKind),
201
+ required: false,
202
+ type: String
203
+ },
180
204
  clicks: { default: 0, required: true, type: Number },
181
205
  end: { required: true, type: Date },
182
206
  impressions: { default: 0, required: true, type: Number },
207
+ paymentStatus: {
208
+ enum: Object.values(import_cluemart_shared.EnumAdPaymentStatus),
209
+ required: false,
210
+ type: String
211
+ },
183
212
  resource: { required: true, type: schemaAdresource },
184
213
  showOn: {
185
214
  default: [import_cluemart_shared.EnumAdShowOn.FRONT_PAGE],
@@ -211,20 +240,282 @@ schema.index({
211
240
  // eslint-disable-next-line sort-keys
212
241
  start: -1
213
242
  });
243
+ schema.index(
244
+ { bookingIds: 1 },
245
+ {
246
+ partialFilterExpression: { bookingIds: { $exists: true } },
247
+ unique: true
248
+ }
249
+ );
214
250
  var AdModel = import_mongoose.default.models.Ad || import_mongoose.default.model("Ad", schema);
215
251
 
216
- // src/mongoose/BillingCatalog.ts
217
- var import_cluemart_shared2 = require("@timardex/cluemart-shared");
252
+ // src/mongoose/AdBillingCatalog.ts
218
253
  var import_mongoose2 = __toESM(require("mongoose"));
219
- var MongooseSchema2 = import_mongoose2.default.Schema;
254
+ var AD_BILLING_CATALOG_COLLECTION_NAME = "adBillingCatalog";
255
+ var schema2 = new import_mongoose2.default.Schema(
256
+ {
257
+ active: { default: true, required: true, type: Boolean },
258
+ currency: {
259
+ default: "nzd",
260
+ enum: ["nzd"],
261
+ immutable: true,
262
+ required: true,
263
+ type: String
264
+ },
265
+ key: {
266
+ enum: ["front_page_day", "market_search_day"],
267
+ immutable: true,
268
+ required: true,
269
+ type: String,
270
+ unique: true
271
+ },
272
+ revision: { default: 1, min: 1, required: true, type: Number },
273
+ unitAmount: {
274
+ min: 1,
275
+ required: true,
276
+ type: Number,
277
+ validate: {
278
+ message: "Daily ad price must be a positive integer amount of cents.",
279
+ validator: Number.isInteger
280
+ }
281
+ }
282
+ },
283
+ { collection: AD_BILLING_CATALOG_COLLECTION_NAME, timestamps: true }
284
+ );
285
+ var AdBillingCatalogModel = import_mongoose2.default.models.AdBillingCatalog || import_mongoose2.default.model(
286
+ "AdBillingCatalog",
287
+ schema2,
288
+ AD_BILLING_CATALOG_COLLECTION_NAME
289
+ );
290
+
291
+ // src/mongoose/AdBooking.ts
292
+ var import_cluemart_shared2 = require("@timardex/cluemart-shared");
293
+ var import_mongoose3 = __toESM(require("mongoose"));
294
+ var liveStates = [
295
+ import_cluemart_shared2.EnumAdBookingState.HELD,
296
+ import_cluemart_shared2.EnumAdBookingState.PENDING_APPROVAL,
297
+ import_cluemart_shared2.EnumAdBookingState.APPROVED
298
+ ];
299
+ var placementValues = [import_cluemart_shared2.EnumAdShowOn.FRONT_PAGE, import_cluemart_shared2.EnumAdShowOn.MARKET_SEARCH];
300
+ var schema3 = new import_mongoose3.default.Schema(
301
+ {
302
+ adId: { default: null, ref: "Ad", type: String },
303
+ approvalStatus: {
304
+ default: import_cluemart_shared2.EnumAdApprovalStatus.PENDING,
305
+ enum: Object.values(import_cluemart_shared2.EnumAdApprovalStatus),
306
+ required: true,
307
+ type: String
308
+ },
309
+ checkoutAttemptId: { default: null, type: String },
310
+ currency: { default: null, lowercase: true, type: String },
311
+ dayKey: {
312
+ immutable: true,
313
+ match: /^\d{4}-\d{2}-\d{2}$/,
314
+ required: true,
315
+ type: String
316
+ },
317
+ entitlementClaimKey: { default: null, type: String },
318
+ entitlementSource: {
319
+ default: null,
320
+ enum: Object.values(import_cluemart_shared2.EnumAdEntitlementSource),
321
+ type: String
322
+ },
323
+ expiresAt: { default: null, type: Date },
324
+ placement: {
325
+ enum: placementValues,
326
+ immutable: true,
327
+ required: true,
328
+ type: String
329
+ },
330
+ purchaseKey: { default: null, immutable: true, type: String },
331
+ region: {
332
+ immutable: true,
333
+ lowercase: true,
334
+ required: true,
335
+ trim: true,
336
+ type: String
337
+ },
338
+ resource: { required: true, type: schemaAdresource },
339
+ slotKind: {
340
+ enum: Object.values(import_cluemart_shared2.EnumAdBookingSlotKind),
341
+ immutable: true,
342
+ required: true,
343
+ type: String
344
+ },
345
+ slotNumber: { immutable: true, min: 1, required: true, type: Number },
346
+ state: {
347
+ default: import_cluemart_shared2.EnumAdBookingState.HELD,
348
+ enum: Object.values(import_cluemart_shared2.EnumAdBookingState),
349
+ required: true,
350
+ type: String
351
+ },
352
+ stripeCheckoutSessionId: { default: null, type: String },
353
+ stripePaymentIntentId: { default: null, type: String },
354
+ unitAmount: { default: null, min: 1, type: Number },
355
+ userId: { immutable: true, ref: "User", required: true, type: String }
356
+ },
357
+ { timestamps: true }
358
+ );
359
+ schema3.pre(
360
+ "validate",
361
+ function validateSlot() {
362
+ if (!Number.isInteger(this.slotNumber)) {
363
+ this.invalidate("slotNumber", "Ad booking slot must be an integer.");
364
+ return;
365
+ }
366
+ const maximum = this.slotKind === import_cluemart_shared2.EnumAdBookingSlotKind.PAID ? 30 : 7;
367
+ if (this.slotNumber < 1 || this.slotNumber > maximum) {
368
+ this.invalidate(
369
+ "slotNumber",
370
+ `Ad booking slot must be between 1 and ${maximum}.`
371
+ );
372
+ }
373
+ if (this.slotKind === import_cluemart_shared2.EnumAdBookingSlotKind.PAID && this.state !== import_cluemart_shared2.EnumAdBookingState.HELD && this.state !== import_cluemart_shared2.EnumAdBookingState.FAILED && this.state !== import_cluemart_shared2.EnumAdBookingState.CANCELLED && (!this.unitAmount || !this.currency)) {
374
+ this.invalidate(
375
+ "unitAmount",
376
+ "Paid ad booking must retain its checkout price."
377
+ );
378
+ }
379
+ }
380
+ );
381
+ schema3.index(
382
+ { region: 1, placement: 1, dayKey: 1, slotKind: 1, slotNumber: 1 },
383
+ { unique: true, partialFilterExpression: { state: { $in: liveStates } } }
384
+ );
385
+ schema3.index({ userId: 1, dayKey: -1 });
386
+ schema3.index(
387
+ { checkoutAttemptId: 1 },
388
+ {
389
+ partialFilterExpression: { checkoutAttemptId: { $type: "string" } },
390
+ unique: true
391
+ }
392
+ );
393
+ schema3.index(
394
+ { purchaseKey: 1 },
395
+ {
396
+ partialFilterExpression: {
397
+ purchaseKey: { $type: "string" },
398
+ state: { $in: liveStates }
399
+ },
400
+ unique: true
401
+ }
402
+ );
403
+ schema3.index(
404
+ { entitlementClaimKey: 1 },
405
+ {
406
+ partialFilterExpression: {
407
+ entitlementClaimKey: { $type: "string" },
408
+ state: { $in: liveStates }
409
+ },
410
+ unique: true
411
+ }
412
+ );
413
+ schema3.index(
414
+ { adId: 1, region: 1, placement: 1, dayKey: 1 },
415
+ {
416
+ partialFilterExpression: {
417
+ entitlementSource: import_cluemart_shared2.EnumAdEntitlementSource.ADMIN,
418
+ state: { $in: liveStates }
419
+ },
420
+ unique: true
421
+ }
422
+ );
423
+ schema3.index(
424
+ { stripeCheckoutSessionId: 1 },
425
+ {
426
+ partialFilterExpression: { stripeCheckoutSessionId: { $type: "string" } },
427
+ unique: true
428
+ }
429
+ );
430
+ var AdBookingModel = import_mongoose3.default.models.AdBooking || import_mongoose3.default.model("AdBooking", schema3);
431
+
432
+ // src/mongoose/AdImpression.ts
433
+ var import_cluemart_shared3 = require("@timardex/cluemart-shared");
434
+ var import_mongoose4 = __toESM(require("mongoose"));
435
+ var schema4 = new import_mongoose4.default.Schema(
436
+ {
437
+ _id: { required: true, type: String },
438
+ adId: { required: true, type: String },
439
+ dayKey: { match: /^\d{4}-\d{2}-\d{2}$/, required: true, type: String },
440
+ placement: {
441
+ enum: [import_cluemart_shared3.EnumAdShowOn.FRONT_PAGE, import_cluemart_shared3.EnumAdShowOn.MARKET_SEARCH],
442
+ required: true,
443
+ type: String
444
+ },
445
+ recordedAt: { default: Date.now, required: true, type: Date },
446
+ viewerSlotKey: { required: true, type: String }
447
+ },
448
+ { collection: "adImpressions" }
449
+ );
450
+ schema4.index({ adId: 1, recordedAt: 1 });
451
+ schema4.index({ adId: 1, placement: 1, viewerSlotKey: 1 }, { unique: true });
452
+ schema4.index({ recordedAt: 1 }, { expireAfterSeconds: 7 * 24 * 60 * 60 });
453
+ schema4.index({ dayKey: 1, placement: 1, adId: 1 });
454
+ var AdImpressionModel = import_mongoose4.default.models.AdImpression || import_mongoose4.default.model("AdImpression", schema4, "adImpressions");
455
+
456
+ // src/mongoose/AdSettings.ts
457
+ var import_mongoose5 = __toESM(require("mongoose"));
458
+ var DEFAULT_AD_SETTINGS = {
459
+ _id: "default",
460
+ approvalRequired: true,
461
+ minAppearancesPerHour: 12,
462
+ paidSlotsPerPlacement: 30,
463
+ reservedSlotsPerPlacement: 7,
464
+ rotationSeconds: 8
465
+ };
466
+ var schema5 = new import_mongoose5.default.Schema(
467
+ {
468
+ _id: { default: "default", enum: ["default"], type: String },
469
+ approvalRequired: { default: true, required: true, type: Boolean },
470
+ minAppearancesPerHour: {
471
+ default: 12,
472
+ min: 1,
473
+ required: true,
474
+ type: Number,
475
+ validate: {
476
+ message: "Minimum appearances per hour must be a whole number.",
477
+ validator: Number.isInteger
478
+ }
479
+ },
480
+ paidSlotsPerPlacement: {
481
+ default: 30,
482
+ enum: [30],
483
+ immutable: true,
484
+ type: Number
485
+ },
486
+ reservedSlotsPerPlacement: {
487
+ default: 7,
488
+ enum: [7],
489
+ immutable: true,
490
+ type: Number
491
+ },
492
+ rotationSeconds: { default: 8, enum: [8], immutable: true, type: Number }
493
+ },
494
+ { collection: "adSettings", timestamps: true }
495
+ );
496
+ schema5.pre("validate", function validateRotationCapacity() {
497
+ const availableRotationsPerHour = 3600 / this.rotationSeconds;
498
+ if (this.minAppearancesPerHour * (this.paidSlotsPerPlacement + this.reservedSlotsPerPlacement) > availableRotationsPerHour) {
499
+ this.invalidate(
500
+ "minAppearancesPerHour",
501
+ "The configured minimum exceeds the available rotation slots."
502
+ );
503
+ }
504
+ });
505
+ var AdSettingsModel = import_mongoose5.default.models.AdSettings || import_mongoose5.default.model("AdSettings", schema5, "adSettings");
506
+
507
+ // src/mongoose/BillingCatalog.ts
508
+ var import_cluemart_shared4 = require("@timardex/cluemart-shared");
509
+ var import_mongoose6 = __toESM(require("mongoose"));
510
+ var MongooseSchema2 = import_mongoose6.default.Schema;
220
511
  var BILLING_CATALOG_COLLECTION_NAME = "billingCatalog";
221
512
  var paidVendorLicences = [
222
- import_cluemart_shared2.EnumUserLicence.PRO_VENDOR,
223
- import_cluemart_shared2.EnumUserLicence.PRO_PLUS_VENDOR
513
+ import_cluemart_shared4.EnumUserLicence.PRO_VENDOR,
514
+ import_cluemart_shared4.EnumUserLicence.PRO_PLUS_VENDOR
224
515
  ];
225
516
  var supportedBillingPeriods = [
226
- import_cluemart_shared2.EnumBillingPeriod.MONTHLY_CANCEL_ANYTIME,
227
- import_cluemart_shared2.EnumBillingPeriod.YEARLY_ANNUAL_BILLED
517
+ import_cluemart_shared4.EnumBillingPeriod.MONTHLY_CANCEL_ANYTIME,
518
+ import_cluemart_shared4.EnumBillingPeriod.YEARLY_ANNUAL_BILLED
228
519
  ];
229
520
  var unitAmountField = {
230
521
  min: 1,
@@ -236,8 +527,8 @@ var unitAmountField = {
236
527
  }
237
528
  };
238
529
  var currencyField = {
239
- default: import_cluemart_shared2.BILLING_CATALOG_CURRENCY,
240
- enum: [import_cluemart_shared2.BILLING_CATALOG_CURRENCY],
530
+ default: import_cluemart_shared4.BILLING_CATALOG_CURRENCY,
531
+ enum: [import_cluemart_shared4.BILLING_CATALOG_CURRENCY],
241
532
  immutable: true,
242
533
  lowercase: true,
243
534
  required: true,
@@ -263,7 +554,7 @@ var priceHistorySchema = new MongooseSchema2(
263
554
  default: null,
264
555
  ref: "User",
265
556
  required: false,
266
- type: import_mongoose2.default.Schema.Types.ObjectId
557
+ type: import_mongoose6.default.Schema.Types.ObjectId
267
558
  },
268
559
  currency: currencyField,
269
560
  effectiveFrom: { required: true, type: Date },
@@ -274,7 +565,7 @@ var priceHistorySchema = new MongooseSchema2(
274
565
  },
275
566
  { _id: false }
276
567
  );
277
- var schema2 = new MongooseSchema2(
568
+ var schema6 = new MongooseSchema2(
278
569
  {
279
570
  active: { default: true, required: true, type: Boolean },
280
571
  billingPeriod: {
@@ -286,7 +577,7 @@ var schema2 = new MongooseSchema2(
286
577
  currency: currencyField,
287
578
  effectiveFrom: { default: Date.now, required: true, type: Date },
288
579
  key: {
289
- enum: import_cluemart_shared2.BILLING_CATALOG_KEYS,
580
+ enum: import_cluemart_shared4.BILLING_CATALOG_KEYS,
290
581
  immutable: true,
291
582
  required: true,
292
583
  type: String,
@@ -330,7 +621,7 @@ var schema2 = new MongooseSchema2(
330
621
  default: null,
331
622
  ref: "User",
332
623
  required: false,
333
- type: import_mongoose2.default.Schema.Types.ObjectId
624
+ type: import_mongoose6.default.Schema.Types.ObjectId
334
625
  }
335
626
  },
336
627
  {
@@ -339,30 +630,30 @@ var schema2 = new MongooseSchema2(
339
630
  timestamps: true
340
631
  }
341
632
  );
342
- schema2.pre("validate", function validateDefinition() {
343
- if (!(0, import_cluemart_shared2.billingCatalogDefinitionMatches)(this)) {
633
+ schema6.pre("validate", function validateDefinition() {
634
+ if (!(0, import_cluemart_shared4.billingCatalogDefinitionMatches)(this)) {
344
635
  this.invalidate(
345
636
  "key",
346
637
  "Billing catalogue key does not match its licence and billing period."
347
638
  );
348
639
  }
349
640
  });
350
- schema2.index({ billingPeriod: 1, licenceType: 1 }, { unique: true });
351
- schema2.index({ active: 1, licenceType: 1 });
352
- schema2.index(
641
+ schema6.index({ billingPeriod: 1, licenceType: 1 }, { unique: true });
642
+ schema6.index({ active: 1, licenceType: 1 });
643
+ schema6.index(
353
644
  { stripePriceId: 1 },
354
645
  {
355
646
  partialFilterExpression: { stripePriceId: { $type: "string" } },
356
647
  unique: true
357
648
  }
358
649
  );
359
- var BillingCatalogModel = import_mongoose2.default.models.BillingCatalogEntry || import_mongoose2.default.model(
650
+ var BillingCatalogModel = import_mongoose6.default.models.BillingCatalogEntry || import_mongoose6.default.model(
360
651
  "BillingCatalogEntry",
361
- schema2,
652
+ schema6,
362
653
  BILLING_CATALOG_COLLECTION_NAME
363
654
  );
364
655
  function buildInitialBillingCatalogEntries(now = /* @__PURE__ */ new Date()) {
365
- return import_cluemart_shared2.INITIAL_BILLING_CATALOG.map((entry) => ({
656
+ return import_cluemart_shared4.INITIAL_BILLING_CATALOG.map((entry) => ({
366
657
  active: entry.active,
367
658
  billingPeriod: entry.billingPeriod,
368
659
  currency: entry.currency,
@@ -379,20 +670,20 @@ function buildInitialBillingCatalogEntries(now = /* @__PURE__ */ new Date()) {
379
670
  }));
380
671
  }
381
672
  function getBillingCatalogDefinition(key) {
382
- return import_cluemart_shared2.BILLING_CATALOG_DEFINITIONS[key];
673
+ return import_cluemart_shared4.BILLING_CATALOG_DEFINITIONS[key];
383
674
  }
384
675
 
385
676
  // src/mongoose/chat/Chat.ts
386
- var import_cluemart_shared3 = require("@timardex/cluemart-shared");
387
- var import_mongoose3 = __toESM(require("mongoose"));
388
- var MongooseSchema3 = import_mongoose3.default.Schema;
677
+ var import_cluemart_shared5 = require("@timardex/cluemart-shared");
678
+ var import_mongoose7 = __toESM(require("mongoose"));
679
+ var MongooseSchema3 = import_mongoose7.default.Schema;
389
680
  var MessageReplyPreviewSchema = new MongooseSchema3(
390
681
  {
391
682
  contentPreview: { required: true, type: String },
392
683
  senderId: {
393
684
  ref: "User",
394
685
  required: true,
395
- type: import_mongoose3.default.Schema.Types.ObjectId
686
+ type: import_mongoose7.default.Schema.Types.ObjectId
396
687
  },
397
688
  senderName: { required: true, type: String }
398
689
  },
@@ -404,7 +695,7 @@ var MessageReactionSchema = new MongooseSchema3(
404
695
  userId: {
405
696
  ref: "User",
406
697
  required: true,
407
- type: import_mongoose3.default.Schema.Types.ObjectId
698
+ type: import_mongoose7.default.Schema.Types.ObjectId
408
699
  }
409
700
  },
410
701
  { _id: false }
@@ -415,7 +706,7 @@ var MessageSeenSchema = new MongooseSchema3(
415
706
  userId: {
416
707
  ref: "User",
417
708
  required: true,
418
- type: import_mongoose3.default.Schema.Types.ObjectId
709
+ type: import_mongoose7.default.Schema.Types.ObjectId
419
710
  }
420
711
  },
421
712
  { _id: false }
@@ -431,13 +722,13 @@ var MessageSchema = new MongooseSchema3(
431
722
  replyToMessageId: {
432
723
  ref: "Chat.messages",
433
724
  required: false,
434
- type: import_mongoose3.default.Schema.Types.ObjectId
725
+ type: import_mongoose7.default.Schema.Types.ObjectId
435
726
  },
436
727
  seenBy: { default: [], required: false, type: [MessageSeenSchema] },
437
728
  senderId: {
438
729
  ref: "User",
439
730
  required: true,
440
- type: import_mongoose3.default.Schema.Types.ObjectId
731
+ type: import_mongoose7.default.Schema.Types.ObjectId
441
732
  }
442
733
  },
443
734
  { timestamps: true }
@@ -450,7 +741,7 @@ var ParticipantSchema = new MongooseSchema3(
450
741
  userId: {
451
742
  ref: "User",
452
743
  required: true,
453
- type: import_mongoose3.default.Schema.Types.ObjectId
744
+ type: import_mongoose7.default.Schema.Types.ObjectId
454
745
  },
455
746
  userName: { required: true, type: String }
456
747
  },
@@ -463,7 +754,7 @@ var ChatSchema = new MongooseSchema3(
463
754
  chatDescription: { required: false, type: String },
464
755
  chatName: { required: true, type: String },
465
756
  chatType: {
466
- enum: Object.values(import_cluemart_shared3.EnumChatType),
757
+ enum: Object.values(import_cluemart_shared5.EnumChatType),
467
758
  required: true,
468
759
  type: String
469
760
  },
@@ -481,17 +772,17 @@ ChatSchema.index({
481
772
  "participants.userId": 1,
482
773
  updatedAt: -1
483
774
  });
484
- var ChatModel = import_mongoose3.default.models.Chat || import_mongoose3.default.model("Chat", ChatSchema);
775
+ var ChatModel = import_mongoose7.default.models.Chat || import_mongoose7.default.model("Chat", ChatSchema);
485
776
 
486
777
  // src/mongoose/chat/ChatReport.ts
487
- var import_cluemart_shared4 = require("@timardex/cluemart-shared");
488
- var import_mongoose4 = __toESM(require("mongoose"));
489
- var MongooseSchema4 = import_mongoose4.default.Schema;
778
+ var import_cluemart_shared6 = require("@timardex/cluemart-shared");
779
+ var import_mongoose8 = __toESM(require("mongoose"));
780
+ var MongooseSchema4 = import_mongoose8.default.Schema;
490
781
  var ReasonSchema = new MongooseSchema4(
491
782
  {
492
783
  details: { default: null, required: false, type: String },
493
784
  reasonType: {
494
- enum: Object.values(import_cluemart_shared4.EnumChatReportReason),
785
+ enum: Object.values(import_cluemart_shared6.EnumChatReportReason),
495
786
  required: true,
496
787
  type: String
497
788
  }
@@ -503,18 +794,18 @@ var ChatReportSchema = new MongooseSchema4(
503
794
  chatId: {
504
795
  ref: "Chat",
505
796
  required: true,
506
- type: import_mongoose4.default.Schema.Types.ObjectId
797
+ type: import_mongoose8.default.Schema.Types.ObjectId
507
798
  },
508
799
  reason: { required: true, type: ReasonSchema },
509
800
  reportedUserId: {
510
801
  ref: "User",
511
802
  required: true,
512
- type: import_mongoose4.default.Schema.Types.ObjectId
803
+ type: import_mongoose8.default.Schema.Types.ObjectId
513
804
  },
514
805
  reporterUserId: {
515
806
  ref: "User",
516
807
  required: true,
517
- type: import_mongoose4.default.Schema.Types.ObjectId
808
+ type: import_mongoose8.default.Schema.Types.ObjectId
518
809
  },
519
810
  resolved: { default: false, required: true, type: Boolean }
520
811
  },
@@ -522,20 +813,20 @@ var ChatReportSchema = new MongooseSchema4(
522
813
  );
523
814
  ChatReportSchema.index({ chatId: 1, reportedUserId: 1 });
524
815
  ChatReportSchema.index({ createdAt: -1, reporterUserId: 1 });
525
- var ChatReportModel = import_mongoose4.default.models.ChatReport || import_mongoose4.default.model("ChatReport", ChatReportSchema);
816
+ var ChatReportModel = import_mongoose8.default.models.ChatReport || import_mongoose8.default.model("ChatReport", ChatReportSchema);
526
817
 
527
818
  // src/mongoose/global.ts
528
- var import_cluemart_shared7 = require("@timardex/cluemart-shared");
529
- var import_mongoose7 = __toESM(require("mongoose"));
819
+ var import_cluemart_shared9 = require("@timardex/cluemart-shared");
820
+ var import_mongoose11 = __toESM(require("mongoose"));
530
821
 
531
822
  // src/mongoose/Relation.ts
532
- var import_cluemart_shared6 = require("@timardex/cluemart-shared");
533
- var import_mongoose6 = __toESM(require("mongoose"));
823
+ var import_cluemart_shared8 = require("@timardex/cluemart-shared");
824
+ var import_mongoose10 = __toESM(require("mongoose"));
534
825
 
535
826
  // src/mongoose/event/EventInfo.ts
536
- var import_cluemart_shared5 = require("@timardex/cluemart-shared");
537
- var import_mongoose5 = __toESM(require("mongoose"));
538
- var MongooseSchema5 = import_mongoose5.default.Schema;
827
+ var import_cluemart_shared7 = require("@timardex/cluemart-shared");
828
+ var import_mongoose9 = __toESM(require("mongoose"));
829
+ var MongooseSchema5 = import_mongoose9.default.Schema;
539
830
  var StallTypeSchema = new MongooseSchema5(
540
831
  {
541
832
  label: { required: false, type: String },
@@ -550,7 +841,7 @@ var StallTypeSchema = new MongooseSchema5(
550
841
  var dateTimeSchema = new MongooseSchema5(
551
842
  {
552
843
  dateStatus: {
553
- enum: Object.values(import_cluemart_shared5.EnumEventDateStatus),
844
+ enum: Object.values(import_cluemart_shared7.EnumEventDateStatus),
554
845
  required: false,
555
846
  type: String
556
847
  },
@@ -569,7 +860,7 @@ var paymentInfoSchema = new MongooseSchema5(
569
860
  accountNumber: { required: false, type: String },
570
861
  link: { required: false, type: String },
571
862
  paymentMethod: {
572
- enum: Object.values(import_cluemart_shared5.EnumPaymentMethod),
863
+ enum: Object.values(import_cluemart_shared7.EnumPaymentMethod),
573
864
  required: true,
574
865
  type: String
575
866
  }
@@ -596,7 +887,7 @@ var refundPolicySchema = new MongooseSchema5(
596
887
  },
597
888
  { _id: false }
598
889
  );
599
- var schema3 = new MongooseSchema5(
890
+ var schema7 = new MongooseSchema5(
600
891
  {
601
892
  active: { default: true, type: Boolean },
602
893
  applicationDeadlineHours: { required: true, type: Number },
@@ -604,7 +895,7 @@ var schema3 = new MongooseSchema5(
604
895
  eventId: {
605
896
  ref: "Event",
606
897
  required: true,
607
- type: import_mongoose5.default.Schema.Types.ObjectId
898
+ type: import_mongoose9.default.Schema.Types.ObjectId
608
899
  },
609
900
  packInTime: { required: true, type: Number },
610
901
  paymentDueHours: { required: true, type: Number },
@@ -614,15 +905,15 @@ var schema3 = new MongooseSchema5(
614
905
  },
615
906
  { timestamps: true }
616
907
  );
617
- schema3.index({ eventId: 1 });
618
- var EventInfoModel = import_mongoose5.default.models.EventInfo || import_mongoose5.default.model("EventInfo", schema3);
908
+ schema7.index({ eventId: 1 });
909
+ var EventInfoModel = import_mongoose9.default.models.EventInfo || import_mongoose9.default.model("EventInfo", schema7);
619
910
 
620
911
  // src/mongoose/Relation.ts
621
- var MongooseSchema6 = import_mongoose6.default.Schema;
912
+ var MongooseSchema6 = import_mongoose10.default.Schema;
622
913
  var relationDateTimeSchema = new MongooseSchema6(
623
914
  {
624
915
  dateStatus: {
625
- enum: Object.values(import_cluemart_shared6.EnumEventDateStatus),
916
+ enum: Object.values(import_cluemart_shared8.EnumEventDateStatus),
626
917
  required: true,
627
918
  type: String
628
919
  },
@@ -646,7 +937,7 @@ var relationDatesSchema = new MongooseSchema6(
646
937
  },
647
938
  paymentReference: { required: false, type: String },
648
939
  status: {
649
- enum: Object.values(import_cluemart_shared6.EnumInviteStatus),
940
+ enum: Object.values(import_cluemart_shared8.EnumInviteStatus),
650
941
  required: false,
651
942
  type: String
652
943
  }
@@ -659,29 +950,29 @@ var RelationTypeSchema = new MongooseSchema6(
659
950
  chatId: {
660
951
  ref: "Chat",
661
952
  required: true,
662
- type: import_mongoose6.default.Schema.Types.ObjectId
953
+ type: import_mongoose10.default.Schema.Types.ObjectId
663
954
  },
664
955
  deletedAt: { default: null, required: false, type: Date },
665
956
  eventId: {
666
957
  ref: "Event",
667
958
  required: true,
668
- type: import_mongoose6.default.Schema.Types.ObjectId
959
+ type: import_mongoose10.default.Schema.Types.ObjectId
669
960
  },
670
961
  lastUpdateBy: {
671
- enum: Object.values(import_cluemart_shared6.EnumResourceType),
962
+ enum: Object.values(import_cluemart_shared8.EnumResourceType),
672
963
  required: true,
673
964
  type: String
674
965
  },
675
966
  relationDates: [relationDatesSchema],
676
967
  relationType: {
677
- enum: Object.values(import_cluemart_shared6.EnumRelationResource),
968
+ enum: Object.values(import_cluemart_shared8.EnumRelationResource),
678
969
  required: true,
679
970
  type: String
680
971
  },
681
972
  vendorId: {
682
973
  ref: "Vendor",
683
974
  required: true,
684
- type: import_mongoose6.default.Schema.Types.ObjectId
975
+ type: import_mongoose10.default.Schema.Types.ObjectId
685
976
  }
686
977
  },
687
978
  { timestamps: true }
@@ -693,17 +984,17 @@ RelationTypeSchema.index({
693
984
  "relationDates.status": 1,
694
985
  vendorId: 1
695
986
  });
696
- var RelationModel = import_mongoose6.default.models.Relation || import_mongoose6.default.model("Relation", RelationTypeSchema);
987
+ var RelationModel = import_mongoose10.default.models.Relation || import_mongoose10.default.model("Relation", RelationTypeSchema);
697
988
 
698
989
  // src/mongoose/global.ts
699
- var MongooseSchema7 = import_mongoose7.default.Schema;
990
+ var MongooseSchema7 = import_mongoose11.default.Schema;
700
991
  var OwnerTypeSchema = new MongooseSchema7(
701
992
  {
702
993
  email: { required: true, type: String },
703
994
  userId: {
704
995
  ref: "User",
705
996
  required: true,
706
- type: import_mongoose7.default.Schema.Types.ObjectId
997
+ type: import_mongoose11.default.Schema.Types.ObjectId
707
998
  }
708
999
  },
709
1000
  { _id: false }
@@ -762,12 +1053,12 @@ var userLicenseSchema = new MongooseSchema7(
762
1053
  expiryDate: { required: true, type: Date },
763
1054
  issuedDate: { required: true, type: Date },
764
1055
  licenceType: {
765
- enum: Object.values(import_cluemart_shared7.EnumUserLicence),
1056
+ enum: Object.values(import_cluemart_shared9.EnumUserLicence),
766
1057
  required: true,
767
1058
  type: String
768
1059
  },
769
1060
  prevLicenceType: {
770
- enum: Object.values(import_cluemart_shared7.EnumUserLicence),
1061
+ enum: Object.values(import_cluemart_shared9.EnumUserLicence),
771
1062
  required: false,
772
1063
  type: String
773
1064
  }
@@ -810,7 +1101,7 @@ var resourceRelationsSchema = new MongooseSchema7(
810
1101
  relationId: {
811
1102
  ref: "Relation",
812
1103
  required: false,
813
- type: import_mongoose7.default.Schema.Types.ObjectId
1104
+ type: import_mongoose11.default.Schema.Types.ObjectId
814
1105
  }
815
1106
  },
816
1107
  { _id: false }
@@ -818,7 +1109,7 @@ var resourceRelationsSchema = new MongooseSchema7(
818
1109
  var dateTimeSchema2 = new MongooseSchema7(
819
1110
  {
820
1111
  dateStatus: {
821
- enum: Object.values(import_cluemart_shared7.EnumEventDateStatus),
1112
+ enum: Object.values(import_cluemart_shared9.EnumEventDateStatus),
822
1113
  required: false,
823
1114
  type: String
824
1115
  },
@@ -861,11 +1152,11 @@ var relatedPostSchema = new MongooseSchema7(
861
1152
  postId: {
862
1153
  ref: "Post",
863
1154
  required: true,
864
- type: import_mongoose7.default.Schema.Types.ObjectId
1155
+ type: import_mongoose11.default.Schema.Types.ObjectId
865
1156
  },
866
1157
  postSlug: { required: true, type: String },
867
1158
  postType: {
868
- enum: Object.values(import_cluemart_shared7.EnumPostType),
1159
+ enum: Object.values(import_cluemart_shared9.EnumPostType),
869
1160
  required: true,
870
1161
  type: String
871
1162
  }
@@ -886,7 +1177,7 @@ var baseResourceFields = {
886
1177
  adIds: {
887
1178
  ref: "Ad",
888
1179
  required: false,
889
- type: [import_mongoose7.default.Schema.Types.ObjectId]
1180
+ type: [import_mongoose11.default.Schema.Types.ObjectId]
890
1181
  },
891
1182
  approvedAt: { default: null, required: false, type: Date },
892
1183
  contactDetails: { required: false, type: ContactDetailsSchema },
@@ -916,8 +1207,8 @@ var baseResourceFields = {
916
1207
  };
917
1208
 
918
1209
  // src/mongoose/GoogleImportedMarket.ts
919
- var import_cluemart_shared8 = require("@timardex/cluemart-shared");
920
- var import_mongoose8 = __toESM(require("mongoose"));
1210
+ var import_cluemart_shared10 = require("@timardex/cluemart-shared");
1211
+ var import_mongoose12 = __toESM(require("mongoose"));
921
1212
 
922
1213
  // src/mongoose/searchNamePlugin.ts
923
1214
  function deriveSearchName(name) {
@@ -963,15 +1254,15 @@ function syncSearchNameInUpdate(update) {
963
1254
  }
964
1255
  return null;
965
1256
  }
966
- function searchNamePlugin(schema20) {
967
- schema20.add({ searchName: { default: "", required: false, type: String } });
968
- schema20.index({ searchName: 1 });
969
- schema20.pre("save", function syncSearchNameOnSave(next) {
1257
+ function searchNamePlugin(schema24) {
1258
+ schema24.add({ searchName: { default: "", required: false, type: String } });
1259
+ schema24.index({ searchName: 1 });
1260
+ schema24.pre("save", function syncSearchNameOnSave(next) {
970
1261
  const doc = this;
971
1262
  doc.searchName = deriveSearchName(doc.name);
972
1263
  next();
973
1264
  });
974
- schema20.pre("insertMany", function syncSearchNameOnInsertMany(next, docs) {
1265
+ schema24.pre("insertMany", function syncSearchNameOnInsertMany(next, docs) {
975
1266
  const list = Array.isArray(docs) ? docs : [docs];
976
1267
  for (const doc of list) {
977
1268
  if (doc && typeof doc.name === "string") {
@@ -980,7 +1271,7 @@ function searchNamePlugin(schema20) {
980
1271
  }
981
1272
  next();
982
1273
  });
983
- schema20.pre("bulkWrite", function syncSearchNameOnBulkWrite(next, ops) {
1274
+ schema24.pre("bulkWrite", function syncSearchNameOnBulkWrite(next, ops) {
984
1275
  for (const op of ops) {
985
1276
  const doc = op.insertOne?.document ?? op.replaceOne?.replacement;
986
1277
  if (doc && typeof doc.name === "string") {
@@ -1006,14 +1297,14 @@ function searchNamePlugin(schema20) {
1006
1297
  }
1007
1298
  next();
1008
1299
  };
1009
- schema20.pre(
1300
+ schema24.pre(
1010
1301
  ["findOneAndUpdate", "updateOne", "updateMany"],
1011
1302
  syncSearchNameOnUpdate
1012
1303
  );
1013
1304
  }
1014
1305
 
1015
1306
  // src/mongoose/GoogleImportedMarket.ts
1016
- var MongooseSchema8 = import_mongoose8.default.Schema;
1307
+ var MongooseSchema8 = import_mongoose12.default.Schema;
1017
1308
  var addressComponentSchema = new MongooseSchema8(
1018
1309
  {
1019
1310
  longName: { required: false, type: String },
@@ -1022,7 +1313,7 @@ var addressComponentSchema = new MongooseSchema8(
1022
1313
  },
1023
1314
  { _id: false }
1024
1315
  );
1025
- var schema4 = new MongooseSchema8(
1316
+ var schema8 = new MongooseSchema8(
1026
1317
  {
1027
1318
  active: { default: false, required: true, type: Boolean },
1028
1319
  address: { required: true, type: String },
@@ -1034,7 +1325,7 @@ var schema4 = new MongooseSchema8(
1034
1325
  claimedByUserId: {
1035
1326
  ref: "User",
1036
1327
  required: false,
1037
- type: import_mongoose8.default.Schema.Types.ObjectId
1328
+ type: import_mongoose12.default.Schema.Types.ObjectId
1038
1329
  },
1039
1330
  cover: {
1040
1331
  required: false,
@@ -1046,10 +1337,10 @@ var schema4 = new MongooseSchema8(
1046
1337
  eventId: {
1047
1338
  ref: "Event",
1048
1339
  required: false,
1049
- type: import_mongoose8.default.Schema.Types.ObjectId
1340
+ type: import_mongoose12.default.Schema.Types.ObjectId
1050
1341
  },
1051
1342
  eventType: {
1052
- enum: Object.values(import_cluemart_shared8.EnumEventType),
1343
+ enum: Object.values(import_cluemart_shared10.EnumEventType),
1053
1344
  required: true,
1054
1345
  type: String
1055
1346
  },
@@ -1085,27 +1376,27 @@ var schema4 = new MongooseSchema8(
1085
1376
  },
1086
1377
  { timestamps: true }
1087
1378
  );
1088
- schema4.index({ "location.geo": "2dsphere" });
1089
- schema4.index({ name: 1 });
1090
- schema4.index({ region: 1 });
1091
- schema4.index({ deletedAt: 1 });
1092
- schema4.index({ "dateTime.dateStatus": 1 });
1093
- schema4.index({ slug: 1 });
1094
- schema4.index({ name: "text", description: "text" });
1095
- schema4.plugin(searchNamePlugin);
1096
- var GoogleImportedMarketModel = import_mongoose8.default.models.GoogleImportedMarket || import_mongoose8.default.model("GoogleImportedMarket", schema4);
1379
+ schema8.index({ "location.geo": "2dsphere" });
1380
+ schema8.index({ name: 1 });
1381
+ schema8.index({ region: 1 });
1382
+ schema8.index({ deletedAt: 1 });
1383
+ schema8.index({ "dateTime.dateStatus": 1 });
1384
+ schema8.index({ slug: 1 });
1385
+ schema8.index({ name: "text", description: "text" });
1386
+ schema8.plugin(searchNamePlugin);
1387
+ var GoogleImportedMarketModel = import_mongoose12.default.models.GoogleImportedMarket || import_mongoose12.default.model("GoogleImportedMarket", schema8);
1097
1388
 
1098
1389
  // src/mongoose/Notification.ts
1099
- var import_cluemart_shared9 = require("@timardex/cluemart-shared");
1100
- var import_mongoose9 = __toESM(require("mongoose"));
1101
- var MongooseSchema9 = import_mongoose9.default.Schema;
1102
- var schema5 = new MongooseSchema9(
1390
+ var import_cluemart_shared11 = require("@timardex/cluemart-shared");
1391
+ var import_mongoose13 = __toESM(require("mongoose"));
1392
+ var MongooseSchema9 = import_mongoose13.default.Schema;
1393
+ var schema9 = new MongooseSchema9(
1103
1394
  {
1104
1395
  data: {
1105
1396
  resourceId: { required: true, type: String },
1106
1397
  resourceName: { required: true, type: String },
1107
1398
  resourceType: {
1108
- enum: Object.values(import_cluemart_shared9.EnumNotificationResourceType),
1399
+ enum: Object.values(import_cluemart_shared11.EnumNotificationResourceType),
1109
1400
  required: true,
1110
1401
  type: String
1111
1402
  }
@@ -1114,28 +1405,28 @@ var schema5 = new MongooseSchema9(
1114
1405
  message: { required: true, type: String },
1115
1406
  title: { required: true, type: String },
1116
1407
  type: {
1117
- default: import_cluemart_shared9.EnumNotificationType.SYSTEM,
1118
- enum: Object.values(import_cluemart_shared9.EnumNotificationType),
1408
+ default: import_cluemart_shared11.EnumNotificationType.SYSTEM,
1409
+ enum: Object.values(import_cluemart_shared11.EnumNotificationType),
1119
1410
  required: true,
1120
1411
  type: String
1121
1412
  },
1122
1413
  userId: {
1123
1414
  ref: "User",
1124
1415
  required: true,
1125
- type: import_mongoose9.default.Schema.Types.ObjectId
1416
+ type: import_mongoose13.default.Schema.Types.ObjectId
1126
1417
  }
1127
1418
  },
1128
1419
  { timestamps: true }
1129
1420
  );
1130
- schema5.index({ isRead: 1, userId: 1 });
1131
- schema5.index({ createdAt: -1, userId: 1 });
1132
- var NotificationModel = import_mongoose9.default.models.Notification || import_mongoose9.default.model("Notification", schema5);
1421
+ schema9.index({ isRead: 1, userId: 1 });
1422
+ schema9.index({ createdAt: -1, userId: 1 });
1423
+ var NotificationModel = import_mongoose13.default.models.Notification || import_mongoose13.default.model("Notification", schema9);
1133
1424
 
1134
1425
  // src/mongoose/PushToken.ts
1135
1426
  var import_enums = require("@timardex/cluemart-shared/enums");
1136
- var import_mongoose10 = __toESM(require("mongoose"));
1137
- var MongooseSchema10 = import_mongoose10.default.Schema;
1138
- var schema6 = new MongooseSchema10(
1427
+ var import_mongoose14 = __toESM(require("mongoose"));
1428
+ var MongooseSchema10 = import_mongoose14.default.Schema;
1429
+ var schema10 = new MongooseSchema10(
1139
1430
  {
1140
1431
  platform: {
1141
1432
  enum: Object.values(import_enums.EnumOSPlatform),
@@ -1146,26 +1437,26 @@ var schema6 = new MongooseSchema10(
1146
1437
  userId: {
1147
1438
  ref: "User",
1148
1439
  required: true,
1149
- type: import_mongoose10.default.Schema.Types.ObjectId
1440
+ type: import_mongoose14.default.Schema.Types.ObjectId
1150
1441
  }
1151
1442
  },
1152
1443
  { timestamps: true }
1153
1444
  );
1154
- var PushTokenModel = import_mongoose10.default.models.PushToken || import_mongoose10.default.model("PushToken", schema6);
1445
+ var PushTokenModel = import_mongoose14.default.models.PushToken || import_mongoose14.default.model("PushToken", schema10);
1155
1446
 
1156
1447
  // src/mongoose/ResourceActivity.ts
1157
- var import_cluemart_shared10 = require("@timardex/cluemart-shared");
1158
- var import_mongoose11 = __toESM(require("mongoose"));
1159
- var MongooseSchema11 = import_mongoose11.default.Schema;
1448
+ var import_cluemart_shared12 = require("@timardex/cluemart-shared");
1449
+ var import_mongoose15 = __toESM(require("mongoose"));
1450
+ var MongooseSchema11 = import_mongoose15.default.Schema;
1160
1451
  var ActivitySchema = new MongooseSchema11(
1161
1452
  {
1162
1453
  activityType: {
1163
- enum: Object.values(import_cluemart_shared10.EnumActivity),
1454
+ enum: Object.values(import_cluemart_shared12.EnumActivity),
1164
1455
  required: true,
1165
1456
  type: String
1166
1457
  },
1167
1458
  dateStatus: {
1168
- enum: Object.values(import_cluemart_shared10.EnumEventDateStatus),
1459
+ enum: Object.values(import_cluemart_shared12.EnumEventDateStatus),
1169
1460
  required: false,
1170
1461
  type: String
1171
1462
  },
@@ -1177,7 +1468,7 @@ var ActivitySchema = new MongooseSchema11(
1177
1468
  startTime: { required: false, type: String },
1178
1469
  timestamp: { default: Date.now, type: Date },
1179
1470
  userAgent: {
1180
- enum: Object.values(import_cluemart_shared10.EnumOSPlatform),
1471
+ enum: Object.values(import_cluemart_shared12.EnumOSPlatform),
1181
1472
  required: true,
1182
1473
  type: String
1183
1474
  },
@@ -1185,33 +1476,33 @@ var ActivitySchema = new MongooseSchema11(
1185
1476
  },
1186
1477
  { _id: false }
1187
1478
  );
1188
- var schema7 = new MongooseSchema11(
1479
+ var schema11 = new MongooseSchema11(
1189
1480
  {
1190
1481
  activity: { default: [], type: [ActivitySchema] },
1191
1482
  resourceId: { required: true, type: String },
1192
1483
  resourceType: {
1193
- enum: Object.values(import_cluemart_shared10.EnumResourceType),
1484
+ enum: Object.values(import_cluemart_shared12.EnumResourceType),
1194
1485
  required: true,
1195
1486
  type: String
1196
1487
  }
1197
1488
  },
1198
1489
  { timestamps: true }
1199
1490
  );
1200
- schema7.index({ resourceId: 1, resourceType: 1 }, { unique: true });
1201
- schema7.index({ "views.location": "2dsphere" });
1202
- var ResourceActivityModel = import_mongoose11.default.models.ResourceActivity || import_mongoose11.default.model("ResourceActivity", schema7);
1491
+ schema11.index({ resourceId: 1, resourceType: 1 }, { unique: true });
1492
+ schema11.index({ "views.location": "2dsphere" });
1493
+ var ResourceActivityModel = import_mongoose15.default.models.ResourceActivity || import_mongoose15.default.model("ResourceActivity", schema11);
1203
1494
 
1204
1495
  // src/mongoose/User.ts
1205
- var import_cluemart_shared11 = require("@timardex/cluemart-shared");
1206
- var import_mongoose12 = __toESM(require("mongoose"));
1207
- var MongooseSchema12 = import_mongoose12.default.Schema;
1496
+ var import_cluemart_shared13 = require("@timardex/cluemart-shared");
1497
+ var import_mongoose16 = __toESM(require("mongoose"));
1498
+ var MongooseSchema12 = import_mongoose16.default.Schema;
1208
1499
  var userActivityEventSchema = new MongooseSchema12(
1209
1500
  {
1210
1501
  dateTime: dateTimeSchema2,
1211
1502
  resourceId: {
1212
1503
  ref: "Event",
1213
1504
  required: false,
1214
- type: import_mongoose12.default.Schema.Types.ObjectId
1505
+ type: import_mongoose16.default.Schema.Types.ObjectId
1215
1506
  }
1216
1507
  },
1217
1508
  { _id: false }
@@ -1221,17 +1512,17 @@ var userActivityFavouritesSchema = new MongooseSchema12(
1221
1512
  events: {
1222
1513
  ref: "Event",
1223
1514
  required: false,
1224
- type: [import_mongoose12.default.Schema.Types.ObjectId]
1515
+ type: [import_mongoose16.default.Schema.Types.ObjectId]
1225
1516
  },
1226
1517
  partners: {
1227
1518
  ref: "Partner",
1228
1519
  required: false,
1229
- type: [import_mongoose12.default.Schema.Types.ObjectId]
1520
+ type: [import_mongoose16.default.Schema.Types.ObjectId]
1230
1521
  },
1231
1522
  vendors: {
1232
1523
  ref: "Vendor",
1233
1524
  required: false,
1234
- type: [import_mongoose12.default.Schema.Types.ObjectId]
1525
+ type: [import_mongoose16.default.Schema.Types.ObjectId]
1235
1526
  }
1236
1527
  },
1237
1528
  { _id: false }
@@ -1239,7 +1530,7 @@ var userActivityFavouritesSchema = new MongooseSchema12(
1239
1530
  var stripeSchema = new MongooseSchema12(
1240
1531
  {
1241
1532
  billingPeriod: {
1242
- enum: Object.values(import_cluemart_shared11.EnumBillingPeriod),
1533
+ enum: Object.values(import_cluemart_shared13.EnumBillingPeriod),
1243
1534
  required: false,
1244
1535
  type: String
1245
1536
  },
@@ -1248,7 +1539,7 @@ var stripeSchema = new MongooseSchema12(
1248
1539
  type: Boolean
1249
1540
  },
1250
1541
  currentPlan: {
1251
- enum: Object.values(import_cluemart_shared11.EnumUserLicence),
1542
+ enum: Object.values(import_cluemart_shared13.EnumUserLicence),
1252
1543
  required: false,
1253
1544
  type: String
1254
1545
  },
@@ -1260,8 +1551,20 @@ var stripeSchema = new MongooseSchema12(
1260
1551
  required: false,
1261
1552
  type: Date
1262
1553
  },
1554
+ paymentFailedAt: {
1555
+ required: false,
1556
+ type: Date
1557
+ },
1558
+ paymentGracePeriodEndsAt: {
1559
+ required: false,
1560
+ type: Date
1561
+ },
1562
+ paymentGraceSubscriptionId: {
1563
+ required: false,
1564
+ type: String
1565
+ },
1263
1566
  pendingBillingPeriod: {
1264
- enum: Object.values(import_cluemart_shared11.EnumBillingPeriod),
1567
+ enum: Object.values(import_cluemart_shared13.EnumBillingPeriod),
1265
1568
  required: false,
1266
1569
  type: String
1267
1570
  },
@@ -1270,7 +1573,7 @@ var stripeSchema = new MongooseSchema12(
1270
1573
  type: Date
1271
1574
  },
1272
1575
  pendingPlan: {
1273
- enum: Object.values(import_cluemart_shared11.EnumUserLicence),
1576
+ enum: Object.values(import_cluemart_shared13.EnumUserLicence),
1274
1577
  required: false,
1275
1578
  type: String
1276
1579
  },
@@ -1287,7 +1590,7 @@ var stripeSchema = new MongooseSchema12(
1287
1590
  type: Date
1288
1591
  },
1289
1592
  status: {
1290
- enum: Object.values(import_cluemart_shared11.EnumSubscriptionStatus),
1593
+ enum: Object.values(import_cluemart_shared13.EnumSubscriptionStatus),
1291
1594
  required: false,
1292
1595
  type: String
1293
1596
  },
@@ -1309,7 +1612,7 @@ var stripeSchema = new MongooseSchema12(
1309
1612
  var redeemedRewardSchema = new MongooseSchema12(
1310
1613
  {
1311
1614
  name: {
1312
- enum: Object.values(import_cluemart_shared11.EnumReward),
1615
+ enum: Object.values(import_cluemart_shared13.EnumReward),
1313
1616
  required: true,
1314
1617
  type: String
1315
1618
  },
@@ -1318,13 +1621,13 @@ var redeemedRewardSchema = new MongooseSchema12(
1318
1621
  },
1319
1622
  { _id: false }
1320
1623
  );
1321
- var schema8 = new MongooseSchema12(
1624
+ var schema12 = new MongooseSchema12(
1322
1625
  {
1323
1626
  active: { default: false, required: true, type: Boolean },
1324
1627
  affiliate: {
1325
1628
  ref: "Affiliate",
1326
1629
  required: false,
1327
- type: import_mongoose12.default.Schema.Types.ObjectId
1630
+ type: import_mongoose16.default.Schema.Types.ObjectId
1328
1631
  },
1329
1632
  avatar: {
1330
1633
  required: false,
@@ -1333,28 +1636,28 @@ var schema8 = new MongooseSchema12(
1333
1636
  coupon: {
1334
1637
  ref: "Coupon",
1335
1638
  required: false,
1336
- type: import_mongoose12.default.Schema.Types.ObjectId
1639
+ type: import_mongoose16.default.Schema.Types.ObjectId
1337
1640
  },
1338
1641
  deletedAt: { default: null, required: false, type: Date },
1339
1642
  email: { required: true, type: String },
1340
1643
  emailSentFor: {
1341
- enum: Object.values(import_cluemart_shared11.EnumNotificationResourceType),
1644
+ enum: Object.values(import_cluemart_shared13.EnumNotificationResourceType),
1342
1645
  required: false,
1343
1646
  type: [String]
1344
1647
  },
1345
1648
  events: {
1346
1649
  ref: "Event",
1347
1650
  required: false,
1348
- type: [import_mongoose12.default.Schema.Types.ObjectId]
1651
+ type: [import_mongoose16.default.Schema.Types.ObjectId]
1349
1652
  },
1350
1653
  firstName: { required: true, type: String },
1351
1654
  game: {
1352
1655
  ref: "Game",
1353
1656
  required: false,
1354
- type: import_mongoose12.default.Schema.Types.ObjectId
1657
+ type: import_mongoose16.default.Schema.Types.ObjectId
1355
1658
  },
1356
1659
  interests: {
1357
- enum: Object.values(import_cluemart_shared11.EnumResourceType),
1660
+ enum: Object.values(import_cluemart_shared13.EnumResourceType),
1358
1661
  required: false,
1359
1662
  type: [String]
1360
1663
  },
@@ -1373,11 +1676,11 @@ var schema8 = new MongooseSchema12(
1373
1676
  partner: {
1374
1677
  ref: "Partner",
1375
1678
  required: false,
1376
- type: import_mongoose12.default.Schema.Types.ObjectId
1679
+ type: import_mongoose16.default.Schema.Types.ObjectId
1377
1680
  },
1378
1681
  password: { required: true, type: String },
1379
1682
  platform: {
1380
- enum: Object.values(import_cluemart_shared11.EnumOSPlatform),
1683
+ enum: Object.values(import_cluemart_shared13.EnumOSPlatform),
1381
1684
  required: false,
1382
1685
  type: String
1383
1686
  },
@@ -1398,15 +1701,15 @@ var schema8 = new MongooseSchema12(
1398
1701
  type: String
1399
1702
  },
1400
1703
  roles: {
1401
- default: [import_cluemart_shared11.EnumUserRole.CUSTOMER],
1402
- enum: Object.values(import_cluemart_shared11.EnumUserRole),
1704
+ default: [import_cluemart_shared13.EnumUserRole.CUSTOMER],
1705
+ enum: Object.values(import_cluemart_shared13.EnumUserRole),
1403
1706
  required: true,
1404
1707
  type: [String]
1405
1708
  },
1406
1709
  school: {
1407
1710
  ref: "School",
1408
1711
  required: false,
1409
- type: import_mongoose12.default.Schema.Types.ObjectId
1712
+ type: import_mongoose16.default.Schema.Types.ObjectId
1410
1713
  },
1411
1714
  stripe: {
1412
1715
  required: false,
@@ -1431,20 +1734,20 @@ var schema8 = new MongooseSchema12(
1431
1734
  vendor: {
1432
1735
  ref: "Vendor",
1433
1736
  required: false,
1434
- type: import_mongoose12.default.Schema.Types.ObjectId
1737
+ type: import_mongoose16.default.Schema.Types.ObjectId
1435
1738
  }
1436
1739
  },
1437
1740
  { strict: false, timestamps: true }
1438
1741
  );
1439
- schema8.index({ "licences.expiryDate": 1 });
1440
- schema8.index({ "licences.licenceType": 1 });
1441
- schema8.index({ promoCodes: 1, active: 1, deletedAt: 1 });
1442
- var UserModel = import_mongoose12.default.models.User || import_mongoose12.default.model("User", schema8);
1742
+ schema12.index({ "licences.expiryDate": 1 });
1743
+ schema12.index({ "licences.licenceType": 1 });
1744
+ schema12.index({ promoCodes: 1, active: 1, deletedAt: 1 });
1745
+ var UserModel = import_mongoose16.default.models.User || import_mongoose16.default.model("User", schema12);
1443
1746
 
1444
1747
  // src/mongoose/VerificationToken.ts
1445
- var import_mongoose13 = __toESM(require("mongoose"));
1446
- var MongooseSchema13 = import_mongoose13.default.Schema;
1447
- var schema9 = new MongooseSchema13(
1748
+ var import_mongoose17 = __toESM(require("mongoose"));
1749
+ var MongooseSchema13 = import_mongoose17.default.Schema;
1750
+ var schema13 = new MongooseSchema13(
1448
1751
  {
1449
1752
  createdAt: {
1450
1753
  default: Date.now,
@@ -1459,12 +1762,12 @@ var schema9 = new MongooseSchema13(
1459
1762
  },
1460
1763
  { timestamps: true }
1461
1764
  );
1462
- var VerificationTokenModel = import_mongoose13.default.models.VerificationToken || import_mongoose13.default.model("VerificationToken", schema9);
1765
+ var VerificationTokenModel = import_mongoose17.default.models.VerificationToken || import_mongoose17.default.model("VerificationToken", schema13);
1463
1766
 
1464
1767
  // src/mongoose/vendor/Vendor.ts
1465
- var import_cluemart_shared12 = require("@timardex/cluemart-shared");
1466
- var import_mongoose14 = __toESM(require("mongoose"));
1467
- var MongooseSchema14 = import_mongoose14.default.Schema;
1768
+ var import_cluemart_shared14 = require("@timardex/cluemart-shared");
1769
+ var import_mongoose18 = __toESM(require("mongoose"));
1770
+ var MongooseSchema14 = import_mongoose18.default.Schema;
1468
1771
  var vendorProductTypeSchema = new MongooseSchema14(
1469
1772
  {
1470
1773
  description: { required: false, type: String },
@@ -1487,7 +1790,7 @@ var calendarSchema = new MongooseSchema14(
1487
1790
  {
1488
1791
  dateTime: {
1489
1792
  dateStatus: {
1490
- enum: Object.values(import_cluemart_shared12.EnumEventDateStatus),
1793
+ enum: Object.values(import_cluemart_shared14.EnumEventDateStatus),
1491
1794
  required: false,
1492
1795
  type: String
1493
1796
  },
@@ -1511,15 +1814,27 @@ var calendarWrapperSchema = new MongooseSchema14(
1511
1814
  },
1512
1815
  { _id: false }
1513
1816
  );
1514
- var schema10 = new MongooseSchema14(
1817
+ var vendorAvailabilitySchema = new MongooseSchema14(
1818
+ {
1819
+ corporate: { default: false, required: false, type: Boolean },
1820
+ private: { default: false, required: false, type: Boolean },
1821
+ school: { default: false, required: false, type: Boolean }
1822
+ },
1823
+ { _id: false }
1824
+ );
1825
+ var downgradeSnapshotSchema = new MongooseSchema14(
1826
+ {
1827
+ availability: { required: false, type: vendorAvailabilitySchema },
1828
+ calendarActive: { required: false, type: Boolean },
1829
+ productsActive: { required: false, type: Boolean }
1830
+ },
1831
+ { _id: false }
1832
+ );
1833
+ var schema14 = new MongooseSchema14(
1515
1834
  {
1516
1835
  ...baseResourceFields,
1517
1836
  // Importing base resource fields from global.ts
1518
- availability: {
1519
- corporate: { default: false, required: false, type: Boolean },
1520
- private: { default: false, required: false, type: Boolean },
1521
- school: { default: false, required: false, type: Boolean }
1522
- },
1837
+ availability: { required: false, type: vendorAvailabilitySchema },
1523
1838
  calendar: {
1524
1839
  required: false,
1525
1840
  type: calendarWrapperSchema
@@ -1527,6 +1842,7 @@ var schema10 = new MongooseSchema14(
1527
1842
  categories: { required: true, type: [CategorySchema] },
1528
1843
  categoriesNames: { default: [], required: false, type: [String] },
1529
1844
  claimed: { default: true, required: false, type: Boolean },
1845
+ downgradeSnapshot: { required: false, type: downgradeSnapshotSchema },
1530
1846
  foodTruck: { required: true, type: Boolean },
1531
1847
  products: { required: false, type: productWrapperSchema },
1532
1848
  relations: {
@@ -1538,39 +1854,39 @@ var schema10 = new MongooseSchema14(
1538
1854
  unregisteredVendorId: {
1539
1855
  ref: "UnregisteredVendor",
1540
1856
  required: false,
1541
- type: import_mongoose14.default.Schema.Types.ObjectId
1857
+ type: import_mongoose18.default.Schema.Types.ObjectId
1542
1858
  },
1543
1859
  vendorInfoId: {
1544
1860
  ref: "VendorInfo",
1545
1861
  required: false,
1546
- type: import_mongoose14.default.Schema.Types.ObjectId
1862
+ type: import_mongoose18.default.Schema.Types.ObjectId
1547
1863
  },
1548
1864
  vendorType: {
1549
- enum: Object.values(import_cluemart_shared12.EnumVendorType),
1865
+ enum: Object.values(import_cluemart_shared14.EnumVendorType),
1550
1866
  required: true,
1551
1867
  type: String
1552
1868
  }
1553
1869
  },
1554
1870
  { timestamps: true }
1555
1871
  );
1556
- schema10.index({ name: 1 });
1557
- schema10.index({ description: 1 });
1558
- schema10.index({ region: 1 });
1559
- schema10.index({ "categories.name": 1 });
1560
- schema10.index({ slug: 1 });
1561
- schema10.index({
1562
- name: "text",
1872
+ schema14.index({ name: 1 });
1873
+ schema14.index({ description: 1 });
1874
+ schema14.index({ region: 1 });
1875
+ schema14.index({ "categories.name": 1 });
1876
+ schema14.index({ slug: 1 });
1877
+ schema14.index({
1878
+ categoriesNames: "text",
1563
1879
  description: "text",
1564
- categoriesNames: "text"
1880
+ name: "text"
1565
1881
  });
1566
- schema10.index({ "owner.userId": 1, deletedAt: 1 });
1567
- schema10.plugin(searchNamePlugin);
1568
- var VendorModel = import_mongoose14.default.models.Vendor || import_mongoose14.default.model("Vendor", schema10);
1882
+ schema14.index({ deletedAt: 1, "owner.userId": 1 });
1883
+ schema14.plugin(searchNamePlugin);
1884
+ var VendorModel = import_mongoose18.default.models.Vendor || import_mongoose18.default.model("Vendor", schema14);
1569
1885
 
1570
1886
  // src/mongoose/vendor/VendorInfo.ts
1571
- var import_cluemart_shared13 = require("@timardex/cluemart-shared");
1572
- var import_mongoose15 = __toESM(require("mongoose"));
1573
- var MongooseSchema15 = import_mongoose15.default.Schema;
1887
+ var import_cluemart_shared15 = require("@timardex/cluemart-shared");
1888
+ var import_mongoose19 = __toESM(require("mongoose"));
1889
+ var MongooseSchema15 = import_mongoose19.default.Schema;
1574
1890
  var AttributesSchema = new MongooseSchema15(
1575
1891
  {
1576
1892
  details: { required: false, type: String },
@@ -1578,7 +1894,7 @@ var AttributesSchema = new MongooseSchema15(
1578
1894
  },
1579
1895
  { _id: false }
1580
1896
  );
1581
- var schema11 = new MongooseSchema15(
1897
+ var schema15 = new MongooseSchema15(
1582
1898
  {
1583
1899
  active: { default: true, type: Boolean },
1584
1900
  compliance: {
@@ -1588,7 +1904,7 @@ var schema11 = new MongooseSchema15(
1588
1904
  documents: [ResourceImageTypeSchema],
1589
1905
  product: {
1590
1906
  foodFlavors: {
1591
- enum: Object.values(import_cluemart_shared13.EnumFoodFlavor),
1907
+ enum: Object.values(import_cluemart_shared15.EnumFoodFlavor),
1592
1908
  required: true,
1593
1909
  type: [String]
1594
1910
  },
@@ -1613,29 +1929,29 @@ var schema11 = new MongooseSchema15(
1613
1929
  vendorId: {
1614
1930
  ref: "Vendor",
1615
1931
  required: true,
1616
- type: import_mongoose15.default.Schema.Types.ObjectId
1932
+ type: import_mongoose19.default.Schema.Types.ObjectId
1617
1933
  }
1618
1934
  },
1619
1935
  { timestamps: true }
1620
1936
  );
1621
- schema11.index({ vendorId: 1 });
1622
- var VendorInfoModel = import_mongoose15.default.models.VendorInfo || import_mongoose15.default.model("VendorInfo", schema11);
1937
+ schema15.index({ vendorId: 1 });
1938
+ var VendorInfoModel = import_mongoose19.default.models.VendorInfo || import_mongoose19.default.model("VendorInfo", schema15);
1623
1939
 
1624
1940
  // src/mongoose/vendor/UnregisteredVendor.ts
1625
- var import_mongoose16 = __toESM(require("mongoose"));
1626
- var MongooseSchema16 = import_mongoose16.default.Schema;
1941
+ var import_mongoose20 = __toESM(require("mongoose"));
1942
+ var MongooseSchema16 = import_mongoose20.default.Schema;
1627
1943
  var invitationSchema = new MongooseSchema16(
1628
1944
  {
1629
1945
  dateTime: { required: true, type: [dateTimeSchema2] },
1630
1946
  inviterId: {
1631
1947
  ref: "Event",
1632
1948
  required: true,
1633
- type: import_mongoose16.default.Schema.Types.ObjectId
1949
+ type: import_mongoose20.default.Schema.Types.ObjectId
1634
1950
  }
1635
1951
  },
1636
1952
  { _id: false }
1637
1953
  );
1638
- var schema12 = new MongooseSchema16(
1954
+ var schema16 = new MongooseSchema16(
1639
1955
  {
1640
1956
  active: { default: true, required: true, type: Boolean },
1641
1957
  categoryIds: { required: true, type: [String] },
@@ -1644,7 +1960,7 @@ var schema12 = new MongooseSchema16(
1644
1960
  claimedByUserId: {
1645
1961
  ref: "User",
1646
1962
  required: false,
1647
- type: import_mongoose16.default.Schema.Types.ObjectId
1963
+ type: import_mongoose20.default.Schema.Types.ObjectId
1648
1964
  },
1649
1965
  claimInitiatedAt: { default: null, required: false, type: Date },
1650
1966
  claimToken: { default: null, required: false, type: String },
@@ -1657,15 +1973,15 @@ var schema12 = new MongooseSchema16(
1657
1973
  },
1658
1974
  { timestamps: true }
1659
1975
  );
1660
- schema12.index({ name: 1 });
1661
- schema12.index({ email: 1 });
1662
- var UnregisteredVendorModel = import_mongoose16.default.models.UnregisteredVendor || import_mongoose16.default.model("UnregisteredVendor", schema12);
1976
+ schema16.index({ name: 1 });
1977
+ schema16.index({ email: 1 });
1978
+ var UnregisteredVendorModel = import_mongoose20.default.models.UnregisteredVendor || import_mongoose20.default.model("UnregisteredVendor", schema16);
1663
1979
 
1664
1980
  // src/mongoose/event/Event.ts
1665
- var import_cluemart_shared14 = require("@timardex/cluemart-shared");
1666
- var import_mongoose17 = __toESM(require("mongoose"));
1667
- var MongooseSchema17 = import_mongoose17.default.Schema;
1668
- var schema13 = new MongooseSchema17(
1981
+ var import_cluemart_shared16 = require("@timardex/cluemart-shared");
1982
+ var import_mongoose21 = __toESM(require("mongoose"));
1983
+ var MongooseSchema17 = import_mongoose21.default.Schema;
1984
+ var schema17 = new MongooseSchema17(
1669
1985
  {
1670
1986
  ...baseResourceFields,
1671
1987
  // Importing base resource fields from global.ts
@@ -1674,10 +1990,10 @@ var schema13 = new MongooseSchema17(
1674
1990
  eventInfoId: {
1675
1991
  ref: "EventInfo",
1676
1992
  required: false,
1677
- type: import_mongoose17.default.Schema.Types.ObjectId
1993
+ type: import_mongoose21.default.Schema.Types.ObjectId
1678
1994
  },
1679
1995
  eventType: {
1680
- enum: Object.values(import_cluemart_shared14.EnumEventType),
1996
+ enum: Object.values(import_cluemart_shared16.EnumEventType),
1681
1997
  required: true,
1682
1998
  type: String
1683
1999
  },
@@ -1703,24 +2019,24 @@ var schema13 = new MongooseSchema17(
1703
2019
  },
1704
2020
  { timestamps: true }
1705
2021
  );
1706
- schema13.index({ name: 1 });
1707
- schema13.index({ description: 1 });
1708
- schema13.index({ region: 1 });
1709
- schema13.index({ "location.geo": "2dsphere" });
1710
- schema13.index({ tags: 1 });
1711
- schema13.index({ deletedAt: 1 });
1712
- schema13.index({ "dateTime.dateStatus": 1 });
1713
- schema13.index({ slug: 1 });
1714
- schema13.index({ name: "text", description: "text", tags: "text" });
1715
- schema13.index({ "owner.userId": 1, deletedAt: 1 });
1716
- schema13.plugin(searchNamePlugin);
1717
- var EventModel = import_mongoose17.default.models.Event || import_mongoose17.default.model("Event", schema13);
2022
+ schema17.index({ name: 1 });
2023
+ schema17.index({ description: 1 });
2024
+ schema17.index({ region: 1 });
2025
+ schema17.index({ "location.geo": "2dsphere" });
2026
+ schema17.index({ tags: 1 });
2027
+ schema17.index({ deletedAt: 1 });
2028
+ schema17.index({ "dateTime.dateStatus": 1 });
2029
+ schema17.index({ slug: 1 });
2030
+ schema17.index({ name: "text", description: "text", tags: "text" });
2031
+ schema17.index({ "owner.userId": 1, deletedAt: 1 });
2032
+ schema17.plugin(searchNamePlugin);
2033
+ var EventModel = import_mongoose21.default.models.Event || import_mongoose21.default.model("Event", schema17);
1718
2034
 
1719
2035
  // src/mongoose/Partner.ts
1720
- var import_cluemart_shared15 = require("@timardex/cluemart-shared");
1721
- var import_mongoose18 = __toESM(require("mongoose"));
1722
- var MongooseSchema18 = import_mongoose18.default.Schema;
1723
- var schema14 = new MongooseSchema18(
2036
+ var import_cluemart_shared17 = require("@timardex/cluemart-shared");
2037
+ var import_mongoose22 = __toESM(require("mongoose"));
2038
+ var MongooseSchema18 = import_mongoose22.default.Schema;
2039
+ var schema18 = new MongooseSchema18(
1724
2040
  {
1725
2041
  ...baseResourceFields,
1726
2042
  location: {
@@ -1729,33 +2045,33 @@ var schema14 = new MongooseSchema18(
1729
2045
  },
1730
2046
  nzbn: { required: true, type: String },
1731
2047
  partnerType: {
1732
- enum: Object.values(import_cluemart_shared15.EnumPartnerType),
2048
+ enum: Object.values(import_cluemart_shared17.EnumPartnerType),
1733
2049
  required: true,
1734
2050
  type: String
1735
2051
  }
1736
2052
  },
1737
2053
  { timestamps: true }
1738
2054
  );
1739
- schema14.index({ name: 1 });
1740
- schema14.index({ description: 1 });
1741
- schema14.index({ region: 1 });
1742
- schema14.index({ "location.geo": "2dsphere" });
1743
- schema14.index({ slug: 1 });
1744
- schema14.index({ name: "text", description: "text" });
1745
- schema14.index({ "owner.userId": 1, deletedAt: 1 });
1746
- schema14.plugin(searchNamePlugin);
1747
- var PartnerModel = import_mongoose18.default.models.Partner || import_mongoose18.default.model("Partner", schema14);
2055
+ schema18.index({ name: 1 });
2056
+ schema18.index({ description: 1 });
2057
+ schema18.index({ region: 1 });
2058
+ schema18.index({ "location.geo": "2dsphere" });
2059
+ schema18.index({ slug: 1 });
2060
+ schema18.index({ name: "text", description: "text" });
2061
+ schema18.index({ "owner.userId": 1, deletedAt: 1 });
2062
+ schema18.plugin(searchNamePlugin);
2063
+ var PartnerModel = import_mongoose22.default.models.Partner || import_mongoose22.default.model("Partner", schema18);
1748
2064
 
1749
2065
  // src/mongoose/Post.ts
1750
- var import_cluemart_shared16 = require("@timardex/cluemart-shared");
1751
- var import_mongoose19 = __toESM(require("mongoose"));
1752
- var MongooseSchema19 = import_mongoose19.default.Schema;
2066
+ var import_cluemart_shared18 = require("@timardex/cluemart-shared");
2067
+ var import_mongoose23 = __toESM(require("mongoose"));
2068
+ var MongooseSchema19 = import_mongoose23.default.Schema;
1753
2069
  var contentSchema = new MongooseSchema19(
1754
2070
  {
1755
- contentData: import_mongoose19.Schema.Types.Mixed,
2071
+ contentData: import_mongoose23.Schema.Types.Mixed,
1756
2072
  contentOrder: { required: true, type: Number },
1757
2073
  contentType: {
1758
- enum: Object.values(import_cluemart_shared16.EnumPostContentType),
2074
+ enum: Object.values(import_cluemart_shared18.EnumPostContentType),
1759
2075
  required: true,
1760
2076
  type: String
1761
2077
  }
@@ -1768,14 +2084,14 @@ var resourceSchema = new MongooseSchema19(
1768
2084
  resourceRegion: { required: true, type: String },
1769
2085
  resourceSlug: { required: true, type: String },
1770
2086
  resourceType: {
1771
- enum: Object.values(import_cluemart_shared16.EnumResourceType),
2087
+ enum: Object.values(import_cluemart_shared18.EnumResourceType),
1772
2088
  required: true,
1773
2089
  type: String
1774
2090
  }
1775
2091
  },
1776
2092
  { _id: false }
1777
2093
  );
1778
- var schema15 = new MongooseSchema19(
2094
+ var schema19 = new MongooseSchema19(
1779
2095
  {
1780
2096
  active: { default: false, required: true, type: Boolean },
1781
2097
  approvedAt: { default: null, required: false, type: Date },
@@ -1791,7 +2107,7 @@ var schema15 = new MongooseSchema19(
1791
2107
  },
1792
2108
  deletedAt: { default: null, required: false, type: Date },
1793
2109
  postType: {
1794
- enum: Object.values(import_cluemart_shared16.EnumPostType),
2110
+ enum: Object.values(import_cluemart_shared18.EnumPostType),
1795
2111
  required: true,
1796
2112
  type: String
1797
2113
  },
@@ -1806,14 +2122,14 @@ var schema15 = new MongooseSchema19(
1806
2122
  },
1807
2123
  { timestamps: true }
1808
2124
  );
1809
- schema15.index({ title: 1 });
1810
- schema15.index({ tags: 1 });
1811
- schema15.index({ postType: 1, slug: 1 }, { unique: true });
1812
- var PostModel = import_mongoose19.default.models.Post || import_mongoose19.default.model("Post", schema15);
2125
+ schema19.index({ title: 1 });
2126
+ schema19.index({ tags: 1 });
2127
+ schema19.index({ postType: 1, slug: 1 }, { unique: true });
2128
+ var PostModel = import_mongoose23.default.models.Post || import_mongoose23.default.model("Post", schema19);
1813
2129
 
1814
2130
  // src/mongoose/AppSetting.ts
1815
- var import_mongoose20 = __toESM(require("mongoose"));
1816
- var MongooseSchema20 = import_mongoose20.default.Schema;
2131
+ var import_mongoose24 = __toESM(require("mongoose"));
2132
+ var MongooseSchema20 = import_mongoose24.default.Schema;
1817
2133
  var APP_SETTINGS_ID = "APP_SETTINGS_DOCUMENT_ID";
1818
2134
  var AppSettingSchema = new MongooseSchema20(
1819
2135
  {
@@ -1846,18 +2162,18 @@ var AppSettingSchema = new MongooseSchema20(
1846
2162
  },
1847
2163
  { timestamps: true }
1848
2164
  );
1849
- var AppSettingModel = import_mongoose20.default.models.AppSetting || import_mongoose20.default.model("AppSetting", AppSettingSchema);
2165
+ var AppSettingModel = import_mongoose24.default.models.AppSetting || import_mongoose24.default.model("AppSetting", AppSettingSchema);
1850
2166
 
1851
2167
  // src/mongoose/game/Game.ts
1852
- var import_cluemart_shared17 = require("@timardex/cluemart-shared");
1853
- var import_mongoose24 = __toESM(require("mongoose"));
2168
+ var import_cluemart_shared19 = require("@timardex/cluemart-shared");
2169
+ var import_mongoose28 = __toESM(require("mongoose"));
1854
2170
 
1855
2171
  // src/mongoose/game/DailyClue.ts
1856
- var import_mongoose22 = __toESM(require("mongoose"));
2172
+ var import_mongoose26 = __toESM(require("mongoose"));
1857
2173
 
1858
2174
  // src/mongoose/game/utils.ts
1859
- var import_mongoose21 = __toESM(require("mongoose"));
1860
- var MongooseSchema21 = import_mongoose21.default.Schema;
2175
+ var import_mongoose25 = __toESM(require("mongoose"));
2176
+ var MongooseSchema21 = import_mongoose25.default.Schema;
1861
2177
  var schemaGameDate = new MongooseSchema21(
1862
2178
  {
1863
2179
  endDate: { required: true, type: Date },
@@ -1867,7 +2183,7 @@ var schemaGameDate = new MongooseSchema21(
1867
2183
  );
1868
2184
 
1869
2185
  // src/mongoose/game/DailyClue.ts
1870
- var MongooseSchema22 = import_mongoose22.default.Schema;
2186
+ var MongooseSchema22 = import_mongoose26.default.Schema;
1871
2187
  var schemaLetters = new MongooseSchema22(
1872
2188
  {
1873
2189
  collected: { required: false, type: [String] },
@@ -1898,8 +2214,8 @@ var schemaDailyClueGameData = new MongooseSchema22(
1898
2214
  );
1899
2215
 
1900
2216
  // src/mongoose/game/PuzzleGame.ts
1901
- var import_mongoose23 = __toESM(require("mongoose"));
1902
- var MongooseSchema23 = import_mongoose23.default.Schema;
2217
+ var import_mongoose27 = __toESM(require("mongoose"));
2218
+ var MongooseSchema23 = import_mongoose27.default.Schema;
1903
2219
  var schemaPuzzleAnswer = new MongooseSchema23(
1904
2220
  {
1905
2221
  answer: { required: true, type: String },
@@ -1944,16 +2260,16 @@ var schemaPuzzleGameData = new MongooseSchema23(
1944
2260
  );
1945
2261
 
1946
2262
  // src/mongoose/game/Game.ts
1947
- var MongooseSchema24 = import_mongoose24.default.Schema;
2263
+ var MongooseSchema24 = import_mongoose28.default.Schema;
1948
2264
  var gameDataSchemas = {
1949
- [import_cluemart_shared17.EnumGameType.DAILY_CLUE]: schemaDailyClueGameData,
1950
- [import_cluemart_shared17.EnumGameType.MINI_QUIZ]: schemaPuzzleGameData,
1951
- [import_cluemart_shared17.EnumGameType.ODD_ONE_OUT]: schemaPuzzleGameData
2265
+ [import_cluemart_shared19.EnumGameType.DAILY_CLUE]: schemaDailyClueGameData,
2266
+ [import_cluemart_shared19.EnumGameType.MINI_QUIZ]: schemaPuzzleGameData,
2267
+ [import_cluemart_shared19.EnumGameType.ODD_ONE_OUT]: schemaPuzzleGameData
1952
2268
  };
1953
2269
  var gameDataDefinition = Object.fromEntries(
1954
- Object.entries(gameDataSchemas).map(([key, schema20]) => [
2270
+ Object.entries(gameDataSchemas).map(([key, schema24]) => [
1955
2271
  key,
1956
- { default: null, required: false, type: schema20 }
2272
+ { default: null, required: false, type: schema24 }
1957
2273
  ])
1958
2274
  );
1959
2275
  var gameHistorySchema = new MongooseSchema24(
@@ -1961,13 +2277,13 @@ var gameHistorySchema = new MongooseSchema24(
1961
2277
  createdAt: { required: true, type: Date },
1962
2278
  gameDate: { required: true, type: schemaGameDate },
1963
2279
  gameStatus: {
1964
- enum: Object.values(import_cluemart_shared17.EnumGameStatus),
2280
+ enum: Object.values(import_cluemart_shared19.EnumGameStatus),
1965
2281
  required: true,
1966
2282
  type: String
1967
2283
  },
1968
2284
  gameTitle: { required: true, type: String },
1969
2285
  gameType: {
1970
- enum: Object.values(import_cluemart_shared17.EnumGameType),
2286
+ enum: Object.values(import_cluemart_shared19.EnumGameType),
1971
2287
  required: true,
1972
2288
  type: String
1973
2289
  },
@@ -1983,7 +2299,7 @@ var gameTypeSchema = new MongooseSchema24(
1983
2299
  gameHistory: { default: [], required: true, type: [gameHistorySchema] },
1984
2300
  gameTitle: { required: true, type: String },
1985
2301
  gameType: {
1986
- enum: Object.values(import_cluemart_shared17.EnumGameType),
2302
+ enum: Object.values(import_cluemart_shared19.EnumGameType),
1987
2303
  required: true,
1988
2304
  type: String
1989
2305
  },
@@ -1991,7 +2307,7 @@ var gameTypeSchema = new MongooseSchema24(
1991
2307
  },
1992
2308
  { timestamps: true }
1993
2309
  );
1994
- var schema16 = new MongooseSchema24(
2310
+ var schema20 = new MongooseSchema24(
1995
2311
  {
1996
2312
  active: { default: false, required: true, type: Boolean },
1997
2313
  deletedAt: { default: null, required: false, type: Date },
@@ -2004,11 +2320,11 @@ var schema16 = new MongooseSchema24(
2004
2320
  },
2005
2321
  { timestamps: true }
2006
2322
  );
2007
- var GameModel = import_mongoose24.default.models.Game || import_mongoose24.default.model("Game", schema16);
2323
+ var GameModel = import_mongoose28.default.models.Game || import_mongoose28.default.model("Game", schema20);
2008
2324
 
2009
2325
  // src/mongoose/School.ts
2010
- var import_mongoose25 = __toESM(require("mongoose"));
2011
- var MongooseSchema25 = import_mongoose25.default.Schema;
2326
+ var import_mongoose29 = __toESM(require("mongoose"));
2327
+ var MongooseSchema25 = import_mongoose29.default.Schema;
2012
2328
  var campaignsSchema = new MongooseSchema25(
2013
2329
  {
2014
2330
  endDate: { required: true, type: Date },
@@ -2017,7 +2333,7 @@ var campaignsSchema = new MongooseSchema25(
2017
2333
  },
2018
2334
  { _id: false }
2019
2335
  );
2020
- var schema17 = new MongooseSchema25(
2336
+ var schema21 = new MongooseSchema25(
2021
2337
  {
2022
2338
  // New schools are active by default
2023
2339
  active: { default: false, required: true, type: Boolean },
@@ -2044,26 +2360,26 @@ var schema17 = new MongooseSchema25(
2044
2360
  },
2045
2361
  { timestamps: true }
2046
2362
  );
2047
- schema17.index(
2363
+ schema21.index(
2048
2364
  { schoolCode: 1 },
2049
2365
  {
2050
2366
  partialFilterExpression: { active: true, deletedAt: null },
2051
2367
  unique: true
2052
2368
  }
2053
2369
  );
2054
- var SchoolModel = import_mongoose25.default.models.School || import_mongoose25.default.model("School", schema17);
2370
+ var SchoolModel = import_mongoose29.default.models.School || import_mongoose29.default.model("School", schema21);
2055
2371
 
2056
2372
  // src/mongoose/Affiliate.ts
2057
- var import_cluemart_shared18 = require("@timardex/cluemart-shared");
2058
- var import_mongoose26 = __toESM(require("mongoose"));
2059
- var MongooseSchema26 = import_mongoose26.default.Schema;
2373
+ var import_cluemart_shared20 = require("@timardex/cluemart-shared");
2374
+ var import_mongoose30 = __toESM(require("mongoose"));
2375
+ var MongooseSchema26 = import_mongoose30.default.Schema;
2060
2376
  var affiliateRewardSchema = new MongooseSchema26(
2061
2377
  {
2062
2378
  createdAt: { required: true, type: Date },
2063
2379
  redeemedAt: { default: null, required: false, type: Date },
2064
2380
  rewardDescription: { required: true, type: String },
2065
2381
  rewardType: {
2066
- enum: Object.values(import_cluemart_shared18.EnumAffiliateRewardType),
2382
+ enum: Object.values(import_cluemart_shared20.EnumAffiliateRewardType),
2067
2383
  required: true,
2068
2384
  type: String
2069
2385
  },
@@ -2077,7 +2393,7 @@ var affiliateResourceSchema = new MongooseSchema26(
2077
2393
  resourceDeletedAt: { default: null, required: false, type: Date },
2078
2394
  resourceId: {
2079
2395
  required: true,
2080
- type: import_mongoose26.default.Schema.Types.ObjectId
2396
+ type: import_mongoose30.default.Schema.Types.ObjectId
2081
2397
  },
2082
2398
  resourceName: { required: true, type: String },
2083
2399
  resourceOwner: {
@@ -2085,7 +2401,7 @@ var affiliateResourceSchema = new MongooseSchema26(
2085
2401
  type: OwnerTypeSchema
2086
2402
  },
2087
2403
  resourceType: {
2088
- enum: Object.values(import_cluemart_shared18.EnumResourceType),
2404
+ enum: Object.values(import_cluemart_shared20.EnumResourceType),
2089
2405
  required: true,
2090
2406
  type: String
2091
2407
  },
@@ -2123,7 +2439,7 @@ var affiliateDetailsSchema = new MongooseSchema26(
2123
2439
  lastName: { required: true, type: String },
2124
2440
  location: { required: true, type: locationsSchema },
2125
2441
  participantType: {
2126
- enum: Object.values(import_cluemart_shared18.EnumAffiliateParticipantType),
2442
+ enum: Object.values(import_cluemart_shared20.EnumAffiliateParticipantType),
2127
2443
  required: true,
2128
2444
  type: String
2129
2445
  },
@@ -2140,7 +2456,7 @@ var redeemHistorySchema = new MongooseSchema26(
2140
2456
  },
2141
2457
  { _id: false }
2142
2458
  );
2143
- var schema18 = new MongooseSchema26(
2459
+ var schema22 = new MongooseSchema26(
2144
2460
  {
2145
2461
  active: { default: false, required: true, type: Boolean },
2146
2462
  affiliateBonusRewards: {
@@ -2170,26 +2486,26 @@ var schema18 = new MongooseSchema26(
2170
2486
  },
2171
2487
  { timestamps: true }
2172
2488
  );
2173
- schema18.index(
2489
+ schema22.index(
2174
2490
  { affiliateCode: 1 },
2175
2491
  {
2176
2492
  partialFilterExpression: { active: true, deletedAt: null },
2177
2493
  unique: true
2178
2494
  }
2179
2495
  );
2180
- var AffiliateModel = import_mongoose26.default.models.Affiliate || import_mongoose26.default.model("Affiliate", schema18);
2496
+ var AffiliateModel = import_mongoose30.default.models.Affiliate || import_mongoose30.default.model("Affiliate", schema22);
2181
2497
 
2182
2498
  // src/mongoose/Coupon.ts
2183
- var import_cluemart_shared19 = require("@timardex/cluemart-shared");
2184
- var import_mongoose27 = __toESM(require("mongoose"));
2185
- var MongooseSchema27 = import_mongoose27.default.Schema;
2499
+ var import_cluemart_shared21 = require("@timardex/cluemart-shared");
2500
+ var import_mongoose31 = __toESM(require("mongoose"));
2501
+ var MongooseSchema27 = import_mongoose31.default.Schema;
2186
2502
  var couponOptionSchema = new MongooseSchema27(
2187
2503
  {
2188
2504
  buy: { required: false, type: Number },
2189
2505
  get: { required: false, type: Number },
2190
2506
  maxRewardCount: { required: false, type: Number },
2191
2507
  type: {
2192
- enum: Object.values(import_cluemart_shared19.EnumCouponQualificationType),
2508
+ enum: Object.values(import_cluemart_shared21.EnumCouponQualificationType),
2193
2509
  required: true,
2194
2510
  type: String
2195
2511
  },
@@ -2202,20 +2518,20 @@ var couponVendorProductSchema = new MongooseSchema27(
2202
2518
  {
2203
2519
  couponId: {
2204
2520
  required: true,
2205
- type: import_mongoose27.default.Schema.Types.ObjectId
2521
+ type: import_mongoose31.default.Schema.Types.ObjectId
2206
2522
  },
2207
2523
  productId: {
2208
2524
  required: true,
2209
- type: import_mongoose27.default.Schema.Types.ObjectId
2525
+ type: import_mongoose31.default.Schema.Types.ObjectId
2210
2526
  },
2211
2527
  vendorCouponId: {
2212
2528
  required: false,
2213
- type: import_mongoose27.default.Schema.Types.ObjectId
2529
+ type: import_mongoose31.default.Schema.Types.ObjectId
2214
2530
  },
2215
2531
  vendorId: {
2216
2532
  ref: "Vendor",
2217
2533
  required: true,
2218
- type: import_mongoose27.default.Schema.Types.ObjectId
2534
+ type: import_mongoose31.default.Schema.Types.ObjectId
2219
2535
  }
2220
2536
  },
2221
2537
  { _id: false }
@@ -2237,7 +2553,7 @@ var couponParticipantUserSchema = new MongooseSchema27(
2237
2553
  userId: {
2238
2554
  ref: "User",
2239
2555
  required: true,
2240
- type: import_mongoose27.default.Schema.Types.ObjectId
2556
+ type: import_mongoose31.default.Schema.Types.ObjectId
2241
2557
  }
2242
2558
  },
2243
2559
  { timestamps: true }
@@ -2261,7 +2577,7 @@ var couponDataSchema = new MongooseSchema27(
2261
2577
  },
2262
2578
  resourceId: { required: true, type: String },
2263
2579
  resourceType: {
2264
- enum: Object.values(import_cluemart_shared19.EnumResourceType),
2580
+ enum: Object.values(import_cluemart_shared21.EnumResourceType),
2265
2581
  required: true,
2266
2582
  type: String
2267
2583
  },
@@ -2269,7 +2585,7 @@ var couponDataSchema = new MongooseSchema27(
2269
2585
  },
2270
2586
  { timestamps: true }
2271
2587
  );
2272
- var schema19 = new MongooseSchema27(
2588
+ var schema23 = new MongooseSchema27(
2273
2589
  {
2274
2590
  active: { default: true, required: true, type: Boolean },
2275
2591
  couponData: { default: [], required: false, type: [couponDataSchema] },
@@ -2281,9 +2597,9 @@ var schema19 = new MongooseSchema27(
2281
2597
  },
2282
2598
  { timestamps: true }
2283
2599
  );
2284
- schema19.index({ active: 1, deletedAt: 1, "owner.userId": 1 });
2285
- schema19.index({ "couponData.participantUsers.userId": 1 });
2286
- var CouponModel = import_mongoose27.default.models.Coupon || import_mongoose27.default.model("Coupon", schema19);
2600
+ schema23.index({ active: 1, deletedAt: 1, "owner.userId": 1 });
2601
+ schema23.index({ "couponData.participantUsers.userId": 1 });
2602
+ var CouponModel = import_mongoose31.default.models.Coupon || import_mongoose31.default.model("Coupon", schema23);
2287
2603
 
2288
2604
  // src/service/promoCode/constants.ts
2289
2605
  var ACTIVE_NOT_DELETED_FILTER = {
@@ -2301,7 +2617,7 @@ async function activeAffiliateCodeExists(affiliateCode) {
2301
2617
  }
2302
2618
 
2303
2619
  // src/service/affiliate/awardAffiliateVendorSubscriptionRewards.ts
2304
- var import_cluemart_shared21 = require("@timardex/cluemart-shared");
2620
+ var import_cluemart_shared23 = require("@timardex/cluemart-shared");
2305
2621
  var import_utils3 = require("@timardex/cluemart-shared/utils");
2306
2622
 
2307
2623
  // src/service/saveNotificationsInDb.ts
@@ -2438,7 +2754,7 @@ async function sendPushNotifications({
2438
2754
  }
2439
2755
 
2440
2756
  // src/service/affiliate/vendorSubscriptionRewards.ts
2441
- var import_cluemart_shared20 = require("@timardex/cluemart-shared");
2757
+ var import_cluemart_shared22 = require("@timardex/cluemart-shared");
2442
2758
  var import_dayjs = __toESM(require("dayjs"));
2443
2759
  var import_timezone = __toESM(require("dayjs/plugin/timezone"));
2444
2760
  var import_utc = __toESM(require("dayjs/plugin/utc"));
@@ -2472,8 +2788,9 @@ async function getPayingStripePlanFor(userId, now, payingPlans) {
2472
2788
  if (stripe == null || stripe.subscriptionId == null) {
2473
2789
  return { hasSubscription: false, plan: null, validTypes };
2474
2790
  }
2475
- const hasActiveStatus = stripe.status === import_enums2.EnumSubscriptionStatus.ACTIVE || stripe.status === import_enums2.EnumSubscriptionStatus.TRIALING;
2476
- if (!hasActiveStatus || stripe.currentPlan == null) {
2791
+ const hasActiveStatus = stripe.status === import_enums2.EnumSubscriptionStatus.ACTIVE;
2792
+ const paidThrough = stripe.endDate ? new Date(stripe.endDate).getTime() : Number.NaN;
2793
+ if (!hasActiveStatus || !Number.isFinite(paidThrough) || paidThrough <= now.getTime() || stripe.currentPlan == null) {
2477
2794
  return { hasSubscription: false, plan: null, validTypes };
2478
2795
  }
2479
2796
  const plan = payingPlans.has(stripe.currentPlan) ? stripe.currentPlan : null;
@@ -2495,14 +2812,14 @@ import_dayjs.default.extend(import_timezone.default);
2495
2812
  var SUBSCRIPTION_REWARD_TIMEZONE = "Pacific/Auckland";
2496
2813
  async function mapVendorLicenceToSubscriptionRewardType(userId, now = /* @__PURE__ */ new Date()) {
2497
2814
  const { hasSubscription, validTypes } = await getPayingVendorStripeSubscriptionPlan(userId, now);
2498
- if (validTypes.has(import_cluemart_shared20.EnumUserLicence.PRO_VENDOR) || validTypes.has(import_cluemart_shared20.EnumUserLicence.PRO_PLUS_VENDOR)) {
2815
+ if (validTypes.has(import_cluemart_shared22.EnumUserLicence.PRO_VENDOR) || validTypes.has(import_cluemart_shared22.EnumUserLicence.PRO_PLUS_VENDOR)) {
2499
2816
  if (hasSubscription) {
2500
- return import_cluemart_shared20.EnumAffiliateRewardType.ACTIVE_VENDOR_PRO_SUBSCRIPTION;
2817
+ return import_cluemart_shared22.EnumAffiliateRewardType.ACTIVE_VENDOR_PRO_SUBSCRIPTION;
2501
2818
  }
2502
- return import_cluemart_shared20.EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
2819
+ return import_cluemart_shared22.EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
2503
2820
  }
2504
- if (validTypes.has(import_cluemart_shared20.EnumUserLicence.STANDARD_VENDOR)) {
2505
- return import_cluemart_shared20.EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
2821
+ if (validTypes.has(import_cluemart_shared22.EnumUserLicence.STANDARD_VENDOR)) {
2822
+ return import_cluemart_shared22.EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
2506
2823
  }
2507
2824
  return null;
2508
2825
  }
@@ -2514,7 +2831,7 @@ function getSubscriptionRewardPeriodBounds(now = /* @__PURE__ */ new Date()) {
2514
2831
 
2515
2832
  // src/service/affiliate/awardAffiliateVendorSubscriptionRewards.ts
2516
2833
  function isEligibleVendorResource(resource) {
2517
- return resource.resourceType === import_cluemart_shared21.EnumResourceType.VENDOR && resource.resourceActive === true && resource.resourceDeletedAt == null;
2834
+ return resource.resourceType === import_cluemart_shared23.EnumResourceType.VENDOR && resource.resourceActive === true && resource.resourceDeletedAt == null;
2518
2835
  }
2519
2836
  async function findAffiliatesWithActiveVendorReferrals() {
2520
2837
  return await AffiliateModel.find({
@@ -2523,7 +2840,7 @@ async function findAffiliatesWithActiveVendorReferrals() {
2523
2840
  $elemMatch: {
2524
2841
  resourceActive: true,
2525
2842
  resourceDeletedAt: null,
2526
- resourceType: import_cluemart_shared21.EnumResourceType.VENDOR
2843
+ resourceType: import_cluemart_shared23.EnumResourceType.VENDOR
2527
2844
  }
2528
2845
  },
2529
2846
  deletedAt: null
@@ -2544,18 +2861,24 @@ async function isEligibleReferredVendor({
2544
2861
  async function notifyAffiliateOwnerOfSubscriptionReward({
2545
2862
  affiliateId,
2546
2863
  affiliateOwnerUserId,
2547
- resourceName,
2548
- rewardValue
2864
+ awards
2549
2865
  }) {
2866
+ if (awards.length === 0) {
2867
+ return;
2868
+ }
2869
+ const totalPoints = awards.reduce((sum, award) => sum + award.rewardValue, 0);
2870
+ const resourceNames = awards.map((award) => award.resourceName);
2871
+ const pointLabel = totalPoints === 1 ? "point" : "points";
2872
+ const message = awards.length === 1 ? `You earned ${totalPoints} ${pointLabel}! Your referred vendor "${resourceNames[0]}" has an active subscription.` : `You earned ${totalPoints} ${pointLabel}! ${awards.length} of your referred vendors have an active subscription.`;
2550
2873
  const payload = {
2551
2874
  data: {
2552
2875
  resourceId: String(affiliateId),
2553
- resourceName,
2554
- resourceType: import_cluemart_shared21.EnumNotificationResourceType.AFFILIATE_REWARD_RECEIVED
2876
+ resourceName: resourceNames.join(", "),
2877
+ resourceType: import_cluemart_shared23.EnumNotificationResourceType.AFFILIATE_REWARD_RECEIVED
2555
2878
  },
2556
- message: `You earned ${rewardValue} points! Your referred vendor "${resourceName}" has an active subscription.`,
2879
+ message,
2557
2880
  title: "Affiliate points earned",
2558
- type: import_cluemart_shared21.EnumNotificationType.SYSTEM,
2881
+ type: import_cluemart_shared23.EnumNotificationType.SYSTEM,
2559
2882
  userIds: [affiliateOwnerUserId]
2560
2883
  };
2561
2884
  try {
@@ -2584,7 +2907,7 @@ async function tryAwardSubscriptionReward({
2584
2907
  resourceActive: true,
2585
2908
  resourceDeletedAt: null,
2586
2909
  resourceId: resource.resourceId,
2587
- resourceType: import_cluemart_shared21.EnumResourceType.VENDOR,
2910
+ resourceType: import_cluemart_shared23.EnumResourceType.VENDOR,
2588
2911
  rewards: {
2589
2912
  $not: {
2590
2913
  $elemMatch: {
@@ -2605,15 +2928,12 @@ async function tryAwardSubscriptionReward({
2605
2928
  }
2606
2929
  ).exec();
2607
2930
  if (updateResult.modifiedCount === 0) {
2608
- return "skipped";
2931
+ return null;
2609
2932
  }
2610
- await notifyAffiliateOwnerOfSubscriptionReward({
2611
- affiliateId: affiliate._id,
2612
- affiliateOwnerUserId: affiliate.owner.userId,
2933
+ return {
2613
2934
  resourceName: resource.resourceName,
2614
2935
  rewardValue: reward.rewardValue
2615
- });
2616
- return "awarded";
2936
+ };
2617
2937
  }
2618
2938
  async function processAffiliateVendorReferral({
2619
2939
  affiliate,
@@ -2627,14 +2947,14 @@ async function processAffiliateVendorReferral({
2627
2947
  resourceOwnerUserId: resource.resourceOwner.userId
2628
2948
  });
2629
2949
  if (!vendorEligible) {
2630
- return "skipped";
2950
+ return null;
2631
2951
  }
2632
2952
  const rewardType = await mapVendorLicenceToSubscriptionRewardType(
2633
2953
  resource.resourceOwner.userId,
2634
2954
  now
2635
2955
  );
2636
2956
  if (!rewardType) {
2637
- return "skipped";
2957
+ return null;
2638
2958
  }
2639
2959
  return tryAwardSubscriptionReward({
2640
2960
  affiliate,
@@ -2650,8 +2970,9 @@ async function awardAffiliateVendorSubscriptionRewards(now = /* @__PURE__ */ new
2650
2970
  const affiliates = await findAffiliatesWithActiveVendorReferrals();
2651
2971
  let awarded = 0;
2652
2972
  let skipped = 0;
2653
- const seenPairs = /* @__PURE__ */ new Set();
2654
2973
  for (const affiliate of affiliates) {
2974
+ const awards = [];
2975
+ const seenPairs = /* @__PURE__ */ new Set();
2655
2976
  for (const resource of affiliate.affiliateResources) {
2656
2977
  if (!isEligibleVendorResource(resource)) {
2657
2978
  continue;
@@ -2661,19 +2982,27 @@ async function awardAffiliateVendorSubscriptionRewards(now = /* @__PURE__ */ new
2661
2982
  continue;
2662
2983
  }
2663
2984
  seenPairs.add(pairKey);
2664
- const outcome = await processAffiliateVendorReferral({
2985
+ const award = await processAffiliateVendorReferral({
2665
2986
  affiliate,
2666
2987
  createdAt,
2667
2988
  now,
2668
2989
  period,
2669
2990
  resource
2670
2991
  });
2671
- if (outcome === "awarded") {
2992
+ if (award) {
2672
2993
  awarded += 1;
2994
+ awards.push(award);
2673
2995
  } else {
2674
2996
  skipped += 1;
2675
2997
  }
2676
2998
  }
2999
+ if (awards.length > 0) {
3000
+ await notifyAffiliateOwnerOfSubscriptionReward({
3001
+ affiliateId: affiliate._id,
3002
+ affiliateOwnerUserId: affiliate.owner.userId,
3003
+ awards
3004
+ });
3005
+ }
2677
3006
  }
2678
3007
  return { awarded, skipped };
2679
3008
  }
@@ -2699,7 +3028,7 @@ function normalizeAffiliatePromoCodes(promoCodes) {
2699
3028
  }
2700
3029
 
2701
3030
  // src/service/database.ts
2702
- var import_mongoose31 = __toESM(require("mongoose"));
3031
+ var import_mongoose35 = __toESM(require("mongoose"));
2703
3032
  var connectToDatabase = async ({
2704
3033
  appName,
2705
3034
  dbName,
@@ -2712,7 +3041,7 @@ var connectToDatabase = async ({
2712
3041
  // Fallback to MongoDB Atlas connection string
2713
3042
  `mongodb+srv://${dbUser}:${dbPassword}@${dbName}.mongodb.net/?retryWrites=true&w=majority&appName=${appName}`
2714
3043
  );
2715
- await import_mongoose31.default.connect(mongoUri);
3044
+ await import_mongoose35.default.connect(mongoUri);
2716
3045
  const connectionType = mongodbUri ? "Local MongoDB" : "MongoDB Atlas";
2717
3046
  console.log(
2718
3047
  `${connectionType} connected from server/src/service/database.ts`
@@ -2725,7 +3054,7 @@ var connectToDatabase = async ({
2725
3054
 
2726
3055
  // src/types/index.ts
2727
3056
  var import_express = __toESM(require("express"));
2728
- var import_mongoose32 = __toESM(require("mongoose"));
3057
+ var import_mongoose36 = __toESM(require("mongoose"));
2729
3058
  var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
2730
3059
  EnumPubSubEvents2["GET_CHAT_MESSAGE"] = "GET_CHAT_MESSAGE";
2731
3060
  EnumPubSubEvents2["GET_NOTIFICATIONS"] = "GET_NOTIFICATIONS";
@@ -2780,7 +3109,7 @@ async function notifyUsers({
2780
3109
  }
2781
3110
 
2782
3111
  // src/service/updateAdStatus.ts
2783
- var import_cluemart_shared22 = require("@timardex/cluemart-shared");
3112
+ var import_cluemart_shared24 = require("@timardex/cluemart-shared");
2784
3113
  async function updateAdStatuses() {
2785
3114
  const now = /* @__PURE__ */ new Date();
2786
3115
  const invalidResult = await AdModel.updateMany(
@@ -2790,41 +3119,66 @@ async function updateAdStatuses() {
2790
3119
  { end: { $exists: false } },
2791
3120
  { $expr: { $gt: ["$start", "$end"] } }
2792
3121
  ],
2793
- status: { $ne: import_cluemart_shared22.EnumAdStatus.PAUSED }
3122
+ status: { $ne: import_cluemart_shared24.EnumAdStatus.PAUSED }
2794
3123
  },
2795
- { $set: { status: import_cluemart_shared22.EnumAdStatus.PAUSED } }
3124
+ { $set: { status: import_cluemart_shared24.EnumAdStatus.PAUSED } }
2796
3125
  );
2797
3126
  const expiredResult = await AdModel.updateMany(
2798
- { end: { $lte: now }, status: { $ne: import_cluemart_shared22.EnumAdStatus.EXPIRED } },
2799
- { $set: { status: import_cluemart_shared22.EnumAdStatus.EXPIRED } }
3127
+ { end: { $lte: now }, status: { $ne: import_cluemart_shared24.EnumAdStatus.EXPIRED } },
3128
+ { $set: { status: import_cluemart_shared24.EnumAdStatus.EXPIRED } }
3129
+ );
3130
+ const eligibleBooking = {
3131
+ $or: [
3132
+ { bookingKind: { $exists: false } },
3133
+ { bookingKind: null },
3134
+ {
3135
+ approvalStatus: import_cluemart_shared24.EnumAdApprovalStatus.APPROVED,
3136
+ bookingKind: import_cluemart_shared24.EnumAdBookingSlotKind.RESERVED
3137
+ },
3138
+ {
3139
+ approvalStatus: import_cluemart_shared24.EnumAdApprovalStatus.APPROVED,
3140
+ bookingKind: import_cluemart_shared24.EnumAdBookingSlotKind.PAID,
3141
+ paymentStatus: import_cluemart_shared24.EnumAdPaymentStatus.PAID
3142
+ }
3143
+ ]
3144
+ };
3145
+ const awaitingApprovalResult = await AdModel.updateMany(
3146
+ {
3147
+ $nor: eligibleBooking.$or,
3148
+ bookingKind: { $in: Object.values(import_cluemart_shared24.EnumAdBookingSlotKind) },
3149
+ end: { $gt: now },
3150
+ status: import_cluemart_shared24.EnumAdStatus.ACTIVE
3151
+ },
3152
+ { $set: { status: import_cluemart_shared24.EnumAdStatus.PAUSED } }
2800
3153
  );
2801
3154
  const activeResult = await AdModel.updateMany(
2802
3155
  {
2803
3156
  end: { $gt: now },
2804
3157
  start: { $lte: now },
2805
- status: { $ne: import_cluemart_shared22.EnumAdStatus.ACTIVE }
3158
+ status: { $ne: import_cluemart_shared24.EnumAdStatus.ACTIVE },
3159
+ ...eligibleBooking
2806
3160
  },
2807
- { $set: { status: import_cluemart_shared22.EnumAdStatus.ACTIVE } }
3161
+ { $set: { status: import_cluemart_shared24.EnumAdStatus.ACTIVE } }
2808
3162
  );
2809
3163
  const pausedResult = await AdModel.updateMany(
2810
- { start: { $gt: now }, status: { $ne: import_cluemart_shared22.EnumAdStatus.PAUSED } },
2811
- { $set: { status: import_cluemart_shared22.EnumAdStatus.PAUSED } }
3164
+ { start: { $gt: now }, status: { $ne: import_cluemart_shared24.EnumAdStatus.PAUSED } },
3165
+ { $set: { status: import_cluemart_shared24.EnumAdStatus.PAUSED } }
2812
3166
  );
2813
3167
  console.log(
2814
- `\u2705 Ad statuses updated: invalid=${invalidResult.modifiedCount}, expired=${expiredResult.modifiedCount}, active=${activeResult.modifiedCount}, paused=${pausedResult.modifiedCount}`
3168
+ `\u2705 Ad statuses updated: invalid=${invalidResult.modifiedCount}, expired=${expiredResult.modifiedCount}, awaitingApproval=${awaitingApprovalResult.modifiedCount}, active=${activeResult.modifiedCount}, paused=${pausedResult.modifiedCount}`
2815
3169
  );
2816
3170
  }
2817
3171
 
2818
3172
  // src/service/objectIdToString.ts
2819
- var import_mongoose34 = __toESM(require("mongoose"));
3173
+ var import_mongoose38 = __toESM(require("mongoose"));
2820
3174
  function isValidObjectId(value) {
2821
- return import_mongoose34.default.Types.ObjectId.isValid(value);
3175
+ return import_mongoose38.default.Types.ObjectId.isValid(value);
2822
3176
  }
2823
3177
  function convertObjectIdsToStrings(obj) {
2824
3178
  if (obj === null || obj === void 0) {
2825
3179
  return obj;
2826
3180
  }
2827
- if (obj instanceof import_mongoose34.default.Types.ObjectId) {
3181
+ if (obj instanceof import_mongoose38.default.Types.ObjectId) {
2828
3182
  return obj.toString();
2829
3183
  }
2830
3184
  if (obj instanceof Date) {
@@ -2844,7 +3198,7 @@ function convertObjectIdsToStrings(obj) {
2844
3198
  }
2845
3199
 
2846
3200
  // src/service/event/updateAllEventDateTimeStatuses.ts
2847
- var import_cluemart_shared23 = require("@timardex/cluemart-shared");
3201
+ var import_cluemart_shared25 = require("@timardex/cluemart-shared");
2848
3202
  var import_dayjs2 = __toESM(require("dayjs"));
2849
3203
  var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat"));
2850
3204
  var import_isoWeek = __toESM(require("dayjs/plugin/isoWeek"));
@@ -2853,24 +3207,24 @@ import_dayjs2.default.extend(import_isoWeek.default);
2853
3207
  function getFutureEventStatus(startDateTime, now) {
2854
3208
  const hoursUntilStart = startDateTime.diff(now, "hour", true);
2855
3209
  if (hoursUntilStart > 0 && hoursUntilStart <= 4) {
2856
- return import_cluemart_shared23.EnumEventDateStatus.STARTING_SOON;
3210
+ return import_cluemart_shared25.EnumEventDateStatus.STARTING_SOON;
2857
3211
  }
2858
3212
  if (startDateTime.isSame(now, "day")) {
2859
- return import_cluemart_shared23.EnumEventDateStatus.TODAY;
3213
+ return import_cluemart_shared25.EnumEventDateStatus.TODAY;
2860
3214
  }
2861
3215
  if (startDateTime.isSame(now.add(1, "day"), "day")) {
2862
- return import_cluemart_shared23.EnumEventDateStatus.TOMORROW;
3216
+ return import_cluemart_shared25.EnumEventDateStatus.TOMORROW;
2863
3217
  }
2864
3218
  if (startDateTime.isSame(now, "isoWeek")) {
2865
- return import_cluemart_shared23.EnumEventDateStatus.THIS_WEEK;
3219
+ return import_cluemart_shared25.EnumEventDateStatus.THIS_WEEK;
2866
3220
  }
2867
3221
  if (startDateTime.isSame(now.add(1, "week"), "isoWeek")) {
2868
- return import_cluemart_shared23.EnumEventDateStatus.NEXT_WEEK;
3222
+ return import_cluemart_shared25.EnumEventDateStatus.NEXT_WEEK;
2869
3223
  }
2870
- return import_cluemart_shared23.EnumEventDateStatus.UPCOMING;
3224
+ return import_cluemart_shared25.EnumEventDateStatus.UPCOMING;
2871
3225
  }
2872
3226
  function updateSingleDateTimeStatus(dateTime, now = (0, import_dayjs2.default)()) {
2873
- const dateTimeFormat = `${import_cluemart_shared23.dateFormat} ${import_cluemart_shared23.timeFormat}`;
3227
+ const dateTimeFormat = `${import_cluemart_shared25.dateFormat} ${import_cluemart_shared25.timeFormat}`;
2874
3228
  const startDateTime = (0, import_dayjs2.default)(
2875
3229
  `${dateTime.startDate} ${dateTime.startTime}`,
2876
3230
  dateTimeFormat,
@@ -2884,13 +3238,13 @@ function updateSingleDateTimeStatus(dateTime, now = (0, import_dayjs2.default)()
2884
3238
  if (!startDateTime.isValid() || !endDateTime.isValid()) {
2885
3239
  return {
2886
3240
  ...dateTime,
2887
- dateStatus: import_cluemart_shared23.EnumEventDateStatus.INVALID
3241
+ dateStatus: import_cluemart_shared25.EnumEventDateStatus.INVALID
2888
3242
  };
2889
3243
  }
2890
3244
  if (endDateTime.isBefore(startDateTime)) {
2891
3245
  return {
2892
3246
  ...dateTime,
2893
- dateStatus: import_cluemart_shared23.EnumEventDateStatus.INVALID
3247
+ dateStatus: import_cluemart_shared25.EnumEventDateStatus.INVALID
2894
3248
  };
2895
3249
  }
2896
3250
  let dateStatus;
@@ -2898,10 +3252,10 @@ function updateSingleDateTimeStatus(dateTime, now = (0, import_dayjs2.default)()
2898
3252
  if (startDateTime.isAfter(now)) {
2899
3253
  dateStatus = getFutureEventStatus(startDateTime, now);
2900
3254
  } else {
2901
- dateStatus = import_cluemart_shared23.EnumEventDateStatus.STARTED;
3255
+ dateStatus = import_cluemart_shared25.EnumEventDateStatus.STARTED;
2902
3256
  }
2903
3257
  } else {
2904
- dateStatus = import_cluemart_shared23.EnumEventDateStatus.ENDED;
3258
+ dateStatus = import_cluemart_shared25.EnumEventDateStatus.ENDED;
2905
3259
  }
2906
3260
  return {
2907
3261
  ...dateTime,
@@ -2985,7 +3339,7 @@ async function findEventOrImportedMarketById(resourceId) {
2985
3339
  }
2986
3340
 
2987
3341
  // src/service/relations.ts
2988
- var import_cluemart_shared24 = require("@timardex/cluemart-shared");
3342
+ var import_cluemart_shared26 = require("@timardex/cluemart-shared");
2989
3343
  function didRemoveAnyEventDates(previousDateTime, nextDateTime) {
2990
3344
  if (!previousDateTime?.length) {
2991
3345
  return false;
@@ -3003,7 +3357,7 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
3003
3357
  ) ?? false;
3004
3358
  return {
3005
3359
  ...relationDate,
3006
- status: existsInEvent ? relationDate.status : import_cluemart_shared24.EnumInviteStatus.UNAVAILABLE
3360
+ status: existsInEvent ? relationDate.status : import_cluemart_shared26.EnumInviteStatus.UNAVAILABLE
3007
3361
  };
3008
3362
  });
3009
3363
  }
@@ -3012,15 +3366,15 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
3012
3366
  var import_dayjs6 = __toESM(require("dayjs"));
3013
3367
 
3014
3368
  // src/service/license/compliance/utils.ts
3015
- var import_cluemart_shared29 = require("@timardex/cluemart-shared");
3369
+ var import_cluemart_shared31 = require("@timardex/cluemart-shared");
3016
3370
  var import_dayjs5 = __toESM(require("dayjs"));
3017
3371
 
3018
3372
  // src/service/license/compliance/event.ts
3019
- var import_cluemart_shared25 = require("@timardex/cluemart-shared");
3373
+ var import_cluemart_shared27 = require("@timardex/cluemart-shared");
3020
3374
  var eventLicences = [
3021
- import_cluemart_shared25.EnumUserLicence.STANDARD_EVENT,
3022
- import_cluemart_shared25.EnumUserLicence.PRO_EVENT,
3023
- import_cluemart_shared25.EnumUserLicence.PRO_PLUS_EVENT
3375
+ import_cluemart_shared27.EnumUserLicence.STANDARD_EVENT,
3376
+ import_cluemart_shared27.EnumUserLicence.PRO_EVENT,
3377
+ import_cluemart_shared27.EnumUserLicence.PRO_PLUS_EVENT
3024
3378
  ];
3025
3379
  async function handleEventLicenceCompliance(user, now) {
3026
3380
  if (!user.licences || !user.events?.length) {
@@ -3232,9 +3586,9 @@ function buildLicenceExpiryPipeline(params) {
3232
3586
  }
3233
3587
 
3234
3588
  // src/service/license/compliance/partner.ts
3235
- var import_cluemart_shared26 = require("@timardex/cluemart-shared");
3589
+ var import_cluemart_shared28 = require("@timardex/cluemart-shared");
3236
3590
  var partnerLicences = [
3237
- import_cluemart_shared26.EnumUserLicence.STANDARD_PARTNER
3591
+ import_cluemart_shared28.EnumUserLicence.STANDARD_PARTNER
3238
3592
  ];
3239
3593
  async function handlePartnerLicenceCompliance(user, now) {
3240
3594
  if (!user.licences || !user.partner) {
@@ -3244,11 +3598,11 @@ async function handlePartnerLicenceCompliance(user, now) {
3244
3598
  }
3245
3599
 
3246
3600
  // src/service/license/compliance/vendor.ts
3247
- var import_cluemart_shared28 = require("@timardex/cluemart-shared");
3601
+ var import_cluemart_shared30 = require("@timardex/cluemart-shared");
3248
3602
  var import_dayjs4 = __toESM(require("dayjs"));
3249
3603
 
3250
3604
  // src/service/license/models.ts
3251
- var import_cluemart_shared27 = require("@timardex/cluemart-shared");
3605
+ var import_cluemart_shared29 = require("@timardex/cluemart-shared");
3252
3606
  var import_dayjs3 = __toESM(require("dayjs"));
3253
3607
  var import_graphql = require("graphql");
3254
3608
  var LicenceExpiryDate = /* @__PURE__ */ ((LicenceExpiryDate2) => {
@@ -3266,31 +3620,31 @@ var LicenceCategory = /* @__PURE__ */ ((LicenceCategory2) => {
3266
3620
  return LicenceCategory2;
3267
3621
  })(LicenceCategory || {});
3268
3622
  var licenceCategoryMapping = {
3269
- [import_cluemart_shared27.EnumUserLicence.PRO_EVENT]: "event" /* EVENT */,
3270
- [import_cluemart_shared27.EnumUserLicence.PRO_PLUS_EVENT]: "event" /* EVENT */,
3271
- [import_cluemart_shared27.EnumUserLicence.PRO_PLUS_VENDOR]: "vendor" /* VENDOR */,
3272
- [import_cluemart_shared27.EnumUserLicence.PRO_VENDOR]: "vendor" /* VENDOR */,
3273
- [import_cluemart_shared27.EnumUserLicence.STANDARD_EVENT]: "event" /* EVENT */,
3274
- [import_cluemart_shared27.EnumUserLicence.STANDARD_PARTNER]: "partner" /* PARTNER */,
3275
- [import_cluemart_shared27.EnumUserLicence.STANDARD_VENDOR]: "vendor" /* VENDOR */,
3276
- [import_cluemart_shared27.EnumUserLicence.STANDARD_AFFILIATE]: "affiliate" /* AFFILIATE */,
3277
- [import_cluemart_shared27.EnumUserLicence.STANDARD_SCHOOL]: "school" /* SCHOOL */
3623
+ [import_cluemart_shared29.EnumUserLicence.PRO_EVENT]: "event" /* EVENT */,
3624
+ [import_cluemart_shared29.EnumUserLicence.PRO_PLUS_EVENT]: "event" /* EVENT */,
3625
+ [import_cluemart_shared29.EnumUserLicence.PRO_PLUS_VENDOR]: "vendor" /* VENDOR */,
3626
+ [import_cluemart_shared29.EnumUserLicence.PRO_VENDOR]: "vendor" /* VENDOR */,
3627
+ [import_cluemart_shared29.EnumUserLicence.STANDARD_EVENT]: "event" /* EVENT */,
3628
+ [import_cluemart_shared29.EnumUserLicence.STANDARD_PARTNER]: "partner" /* PARTNER */,
3629
+ [import_cluemart_shared29.EnumUserLicence.STANDARD_VENDOR]: "vendor" /* VENDOR */,
3630
+ [import_cluemart_shared29.EnumUserLicence.STANDARD_AFFILIATE]: "affiliate" /* AFFILIATE */,
3631
+ [import_cluemart_shared29.EnumUserLicence.STANDARD_SCHOOL]: "school" /* SCHOOL */
3278
3632
  };
3279
3633
  var licencePriority = {
3280
- [import_cluemart_shared27.EnumUserLicence.PRO_PLUS_EVENT]: 3,
3281
- [import_cluemart_shared27.EnumUserLicence.PRO_EVENT]: 2,
3282
- [import_cluemart_shared27.EnumUserLicence.STANDARD_EVENT]: 1,
3283
- [import_cluemart_shared27.EnumUserLicence.PRO_PLUS_VENDOR]: 3,
3284
- [import_cluemart_shared27.EnumUserLicence.PRO_VENDOR]: 2,
3285
- [import_cluemart_shared27.EnumUserLicence.STANDARD_VENDOR]: 1,
3286
- [import_cluemart_shared27.EnumUserLicence.STANDARD_PARTNER]: 1,
3287
- [import_cluemart_shared27.EnumUserLicence.STANDARD_AFFILIATE]: 1,
3288
- [import_cluemart_shared27.EnumUserLicence.STANDARD_SCHOOL]: 1
3634
+ [import_cluemart_shared29.EnumUserLicence.PRO_PLUS_EVENT]: 3,
3635
+ [import_cluemart_shared29.EnumUserLicence.PRO_EVENT]: 2,
3636
+ [import_cluemart_shared29.EnumUserLicence.STANDARD_EVENT]: 1,
3637
+ [import_cluemart_shared29.EnumUserLicence.PRO_PLUS_VENDOR]: 3,
3638
+ [import_cluemart_shared29.EnumUserLicence.PRO_VENDOR]: 2,
3639
+ [import_cluemart_shared29.EnumUserLicence.STANDARD_VENDOR]: 1,
3640
+ [import_cluemart_shared29.EnumUserLicence.STANDARD_PARTNER]: 1,
3641
+ [import_cluemart_shared29.EnumUserLicence.STANDARD_AFFILIATE]: 1,
3642
+ [import_cluemart_shared29.EnumUserLicence.STANDARD_SCHOOL]: 1
3289
3643
  };
3290
3644
  var standardLicences = [
3291
- import_cluemart_shared27.EnumUserLicence.STANDARD_VENDOR,
3292
- import_cluemart_shared27.EnumUserLicence.STANDARD_EVENT,
3293
- import_cluemart_shared27.EnumUserLicence.STANDARD_PARTNER
3645
+ import_cluemart_shared29.EnumUserLicence.STANDARD_VENDOR,
3646
+ import_cluemart_shared29.EnumUserLicence.STANDARD_EVENT,
3647
+ import_cluemart_shared29.EnumUserLicence.STANDARD_PARTNER
3294
3648
  ];
3295
3649
  var standardLicenceSet = new Set(standardLicences);
3296
3650
  function isStandardLicence(licence) {
@@ -3304,11 +3658,11 @@ var categoryRegexMapping = {
3304
3658
  ["school" /* SCHOOL */]: /_school$/
3305
3659
  };
3306
3660
  var categoryFallbackLicence = {
3307
- ["event" /* EVENT */]: import_cluemart_shared27.EnumUserLicence.STANDARD_EVENT,
3308
- ["partner" /* PARTNER */]: import_cluemart_shared27.EnumUserLicence.STANDARD_PARTNER,
3309
- ["vendor" /* VENDOR */]: import_cluemart_shared27.EnumUserLicence.STANDARD_VENDOR,
3310
- ["affiliate" /* AFFILIATE */]: import_cluemart_shared27.EnumUserLicence.STANDARD_AFFILIATE,
3311
- ["school" /* SCHOOL */]: import_cluemart_shared27.EnumUserLicence.STANDARD_SCHOOL
3661
+ ["event" /* EVENT */]: import_cluemart_shared29.EnumUserLicence.STANDARD_EVENT,
3662
+ ["partner" /* PARTNER */]: import_cluemart_shared29.EnumUserLicence.STANDARD_PARTNER,
3663
+ ["vendor" /* VENDOR */]: import_cluemart_shared29.EnumUserLicence.STANDARD_VENDOR,
3664
+ ["affiliate" /* AFFILIATE */]: import_cluemart_shared29.EnumUserLicence.STANDARD_AFFILIATE,
3665
+ ["school" /* SCHOOL */]: import_cluemart_shared29.EnumUserLicence.STANDARD_SCHOOL
3312
3666
  };
3313
3667
  var LicenceFilterInput = {
3314
3668
  INPUT_USER_LICENCES: "$licences"
@@ -3444,13 +3798,13 @@ async function checkOwnerHasLicence({
3444
3798
  const owner = await UserModel.findById(userId);
3445
3799
  if (!owner) throw new import_graphql.GraphQLError("Owner not found");
3446
3800
  const categoryByResource = {
3447
- [import_cluemart_shared27.EnumResourceType.EVENT]: "event" /* EVENT */,
3448
- [import_cluemart_shared27.EnumResourceType.PARTNER]: "partner" /* PARTNER */,
3449
- [import_cluemart_shared27.EnumResourceType.VENDOR]: "vendor" /* VENDOR */,
3450
- [import_cluemart_shared27.EnumResourceType.AFFILIATE]: "affiliate" /* AFFILIATE */,
3451
- [import_cluemart_shared27.EnumResourceType.SCHOOL]: "school" /* SCHOOL */
3801
+ [import_cluemart_shared29.EnumResourceType.EVENT]: "event" /* EVENT */,
3802
+ [import_cluemart_shared29.EnumResourceType.PARTNER]: "partner" /* PARTNER */,
3803
+ [import_cluemart_shared29.EnumResourceType.VENDOR]: "vendor" /* VENDOR */,
3804
+ [import_cluemart_shared29.EnumResourceType.AFFILIATE]: "affiliate" /* AFFILIATE */,
3805
+ [import_cluemart_shared29.EnumResourceType.SCHOOL]: "school" /* SCHOOL */
3452
3806
  };
3453
- if (!(0, import_cluemart_shared27.isNonVisitorResourceType)(resourceType)) {
3807
+ if (!(0, import_cluemart_shared29.isNonVisitorResourceType)(resourceType)) {
3454
3808
  throw new import_graphql.GraphQLError(`Invalid resource type: ${resourceType}.`);
3455
3809
  }
3456
3810
  const requiredCategory = categoryByResource[resourceType];
@@ -3474,59 +3828,150 @@ async function checkOwnerHasLicence({
3474
3828
  }
3475
3829
 
3476
3830
  // src/service/license/compliance/vendor.ts
3477
- async function updateVendorBasedOnUserLicense(userId, licenceType) {
3831
+ async function findUserVendor(userId, logLabel) {
3832
+ const user = await UserModel.findById(userId).select("vendor").lean().exec();
3833
+ if (!user?.vendor) {
3834
+ console.warn(`[${logLabel}] No vendor found for userId=${userId}`);
3835
+ return null;
3836
+ }
3837
+ const vendor = await VendorModel.findOne({
3838
+ _id: user.vendor,
3839
+ active: true,
3840
+ deletedAt: null,
3841
+ "owner.userId": userId
3842
+ }).lean().exec();
3843
+ if (!vendor) {
3844
+ console.warn(
3845
+ `[${logLabel}] Vendor not found for id=${user.vendor}, userId=${userId}`
3846
+ );
3847
+ return null;
3848
+ }
3849
+ return vendor;
3850
+ }
3851
+ async function applyVendorDowngrade(vendor, ownerUserId) {
3852
+ const updateData = {};
3853
+ updateData.availability = {
3854
+ corporate: false,
3855
+ private: false,
3856
+ school: false
3857
+ };
3858
+ updateData.products = {
3859
+ active: false,
3860
+ productsList: vendor.products?.productsList ?? []
3861
+ };
3862
+ updateData.calendar = {
3863
+ active: false,
3864
+ calendarData: vendor.calendar?.calendarData ?? []
3865
+ };
3866
+ updateData.downgradeSnapshot = {
3867
+ availability: vendor.availability,
3868
+ calendarActive: vendor.calendar?.active,
3869
+ productsActive: vendor.products?.active
3870
+ };
3871
+ updateData.images = (vendor.images ?? []).map((image, index) => ({
3872
+ ...image,
3873
+ active: index < 6
3874
+ }));
3875
+ const result = await VendorModel.updateOne(
3876
+ {
3877
+ _id: vendor._id,
3878
+ active: true,
3879
+ deletedAt: null,
3880
+ "owner.userId": ownerUserId
3881
+ },
3882
+ { $set: updateData }
3883
+ );
3884
+ return (result?.matchedCount ?? 0) > 0;
3885
+ }
3886
+ async function downgradeVendorProFeatures(userId, licenceType) {
3887
+ const isStandardVendor = licenceType === import_cluemart_shared30.EnumUserLicence.STANDARD_VENDOR;
3888
+ if (!isStandardVendor) {
3889
+ return;
3890
+ }
3478
3891
  try {
3479
- const user = await UserModel.findById(userId).select("vendor").lean().exec();
3480
- if (!user?.vendor) {
3481
- console.warn(`[updateVendor] No vendor found for userId=${userId}`);
3892
+ const vendor = await findUserVendor(userId, "downgradeVendorProFeatures");
3893
+ if (!vendor) {
3482
3894
  return;
3483
3895
  }
3484
- const vendor = await VendorModel.findById(user.vendor).lean().exec();
3896
+ await applyVendorDowngrade(vendor, userId);
3897
+ } catch (error) {
3898
+ console.error("[downgradeVendorProFeatures] Failed:", error);
3899
+ throw error;
3900
+ }
3901
+ }
3902
+ async function applyVendorRestore(vendor, ownerUserId) {
3903
+ const updateData = {};
3904
+ const snapshot = vendor.downgradeSnapshot;
3905
+ updateData.availability = {
3906
+ corporate: snapshot?.availability?.corporate ?? true,
3907
+ private: snapshot?.availability?.private ?? true,
3908
+ school: snapshot?.availability?.school ?? true
3909
+ };
3910
+ updateData.products = {
3911
+ active: snapshot?.productsActive ?? true,
3912
+ productsList: vendor.products?.productsList ?? []
3913
+ };
3914
+ updateData.calendar = {
3915
+ active: snapshot?.calendarActive ?? true,
3916
+ calendarData: vendor.calendar?.calendarData ?? []
3917
+ };
3918
+ updateData.images = (vendor.images ?? []).map((image) => ({
3919
+ ...image,
3920
+ active: true
3921
+ }));
3922
+ const result = await VendorModel.updateOne(
3923
+ {
3924
+ _id: vendor._id,
3925
+ active: true,
3926
+ deletedAt: null,
3927
+ "owner.userId": ownerUserId
3928
+ },
3929
+ { $set: updateData }
3930
+ );
3931
+ return (result?.matchedCount ?? 0) > 0;
3932
+ }
3933
+ async function restoreVendorProFeatures(userId, licenceType) {
3934
+ const isProVendor = licenceType === import_cluemart_shared30.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared30.EnumUserLicence.PRO_PLUS_VENDOR;
3935
+ if (!isProVendor) {
3936
+ return;
3937
+ }
3938
+ try {
3939
+ const vendor = await findUserVendor(userId, "restoreVendorProFeatures");
3485
3940
  if (!vendor) {
3486
- console.warn(`[updateVendor] Vendor not found for id=${user.vendor}`);
3487
3941
  return;
3488
3942
  }
3489
- const updateData = {};
3490
- const isStandardVendor = licenceType === import_cluemart_shared28.EnumUserLicence.STANDARD_VENDOR;
3491
- if (isStandardVendor) {
3492
- updateData.availability = {
3493
- corporate: false,
3494
- private: false,
3495
- school: false
3496
- };
3497
- updateData.products = {
3498
- active: false,
3499
- productsList: vendor.products?.productsList ?? []
3500
- };
3501
- updateData.calendar = {
3502
- active: false,
3503
- calendarData: vendor.calendar?.calendarData ?? []
3504
- };
3505
- }
3506
- updateData.images = (vendor.images ?? []).map((image, index) => ({
3507
- ...image,
3508
- active: isStandardVendor ? index < 6 : true
3509
- }));
3510
- await VendorModel.updateOne({ _id: vendor._id }, { $set: updateData });
3943
+ await applyVendorRestore(vendor, userId);
3511
3944
  } catch (error) {
3512
- console.error("[updateVendorBasedOnUserLicense] Failed:", error);
3945
+ console.error("[restoreVendorProFeatures] Failed:", error);
3946
+ throw error;
3513
3947
  }
3514
3948
  }
3515
3949
  var vendorLicences = [
3516
- import_cluemart_shared28.EnumUserLicence.STANDARD_VENDOR,
3517
- import_cluemart_shared28.EnumUserLicence.PRO_VENDOR,
3518
- import_cluemart_shared28.EnumUserLicence.PRO_PLUS_VENDOR
3950
+ import_cluemart_shared30.EnumUserLicence.STANDARD_VENDOR,
3951
+ import_cluemart_shared30.EnumUserLicence.PRO_VENDOR,
3952
+ import_cluemart_shared30.EnumUserLicence.PRO_PLUS_VENDOR
3519
3953
  ];
3520
3954
  function isProtectedByCurrentStripeSubscription(user, licenceType, now) {
3521
3955
  const stripe = user.stripe;
3522
- if (!stripe?.subscriptionId || stripe.currentPlan !== licenceType || stripe.status !== import_cluemart_shared28.EnumSubscriptionStatus.ACTIVE && stripe.status !== import_cluemart_shared28.EnumSubscriptionStatus.TRIALING) {
3956
+ if (!stripe || stripe.currentPlan !== licenceType) {
3523
3957
  return false;
3524
3958
  }
3525
- if (stripe.cancelAtPeriodEnd !== true || !stripe.endDate) {
3959
+ const gracePeriodEndsAt = stripe.paymentGracePeriodEndsAt ? (0, import_dayjs4.default)(stripe.paymentGracePeriodEndsAt) : null;
3960
+ const hasActivePaymentGracePeriod = (stripe.status === import_cluemart_shared30.EnumSubscriptionStatus.PAST_DUE || stripe.status === import_cluemart_shared30.EnumSubscriptionStatus.INACTIVE) && Boolean(stripe.paymentGraceSubscriptionId) && (!stripe.subscriptionId || stripe.subscriptionId === stripe.paymentGraceSubscriptionId) && gracePeriodEndsAt !== null && gracePeriodEndsAt.isValid() && gracePeriodEndsAt.isAfter(now);
3961
+ if (hasActivePaymentGracePeriod) {
3526
3962
  return true;
3527
3963
  }
3964
+ if (!stripe.subscriptionId) {
3965
+ return false;
3966
+ }
3967
+ if (stripe.status !== import_cluemart_shared30.EnumSubscriptionStatus.ACTIVE) {
3968
+ return false;
3969
+ }
3970
+ if (!stripe.endDate) {
3971
+ return false;
3972
+ }
3528
3973
  const paidThrough = (0, import_dayjs4.default)(stripe.endDate);
3529
- return !paidThrough.isValid() || paidThrough.isAfter(now);
3974
+ return paidThrough.isValid() && paidThrough.isAfter(now);
3530
3975
  }
3531
3976
  async function handleVendorLicenceCompliance(user, now) {
3532
3977
  if (!user.licences || !user.vendor) {
@@ -3539,7 +3984,7 @@ async function handleVendorLicenceCompliance(user, now) {
3539
3984
  return;
3540
3985
  }
3541
3986
  const proLicences = vendorLicencesOfUser.filter(
3542
- (licence) => licence.licenceType !== import_cluemart_shared28.EnumUserLicence.STANDARD_VENDOR
3987
+ (licence) => licence.licenceType !== import_cluemart_shared30.EnumUserLicence.STANDARD_VENDOR
3543
3988
  );
3544
3989
  const expiredProLicences = proLicences.filter(
3545
3990
  (licence) => !(0, import_dayjs4.default)(licence.expiryDate).isAfter(now)
@@ -3575,19 +4020,19 @@ async function handleVendorLicenceCompliance(user, now) {
3575
4020
  if (!expiredProLicence || !vendor || hasValidProLicence) {
3576
4021
  return;
3577
4022
  }
3578
- await updateVendorBasedOnUserLicense(
3579
- user._id,
3580
- import_cluemart_shared28.EnumUserLicence.STANDARD_VENDOR
3581
- );
4023
+ const downgraded = await applyVendorDowngrade(vendor, user._id);
4024
+ if (!downgraded) {
4025
+ return;
4026
+ }
3582
4027
  const payload = {
3583
4028
  data: {
3584
4029
  resourceId: String(vendor._id),
3585
4030
  resourceName: vendor.name,
3586
- resourceType: import_cluemart_shared28.EnumNotificationResourceType.DOWNGRADED_VENDOR
4031
+ resourceType: import_cluemart_shared30.EnumNotificationResourceType.DOWNGRADED_VENDOR
3587
4032
  },
3588
4033
  message: `Your Vendor license has been downgraded due to licence expiration.`,
3589
4034
  title: `Vendor License Downgraded`,
3590
- type: import_cluemart_shared28.EnumNotificationType.SYSTEM,
4035
+ type: import_cluemart_shared30.EnumNotificationType.SYSTEM,
3591
4036
  userIds: [user._id]
3592
4037
  };
3593
4038
  await sendDeactivationNotification(payload, user._id, vendor.name, "vendor");
@@ -3601,12 +4046,26 @@ async function vendorOwnerHasProLicence(vendorId) {
3601
4046
  if (!vendor) {
3602
4047
  return false;
3603
4048
  }
3604
- const owner = await UserModel.findById(vendor.owner.userId, { licences: 1 }).lean().exec();
4049
+ const owner = await UserModel.findById(vendor.owner.userId, {
4050
+ licences: 1,
4051
+ stripe: 1
4052
+ }).lean().exec();
4053
+ if (!owner) {
4054
+ return false;
4055
+ }
4056
+ const now = (0, import_dayjs4.default)();
4057
+ const effectiveVendorLicences = owner.licences?.filter(
4058
+ (licence) => licence?.licenceType && ((0, import_dayjs4.default)(licence.expiryDate).isAfter(now) || isProtectedByCurrentStripeSubscription(
4059
+ owner,
4060
+ licence.licenceType,
4061
+ now
4062
+ ))
4063
+ );
3605
4064
  const highestVendorLicence = getHighestLicenceForCategory(
3606
- owner?.licences,
4065
+ effectiveVendorLicences,
3607
4066
  "vendor" /* VENDOR */
3608
4067
  );
3609
- return highestVendorLicence !== null && licencePriority[highestVendorLicence] >= licencePriority[import_cluemart_shared28.EnumUserLicence.PRO_VENDOR];
4068
+ return highestVendorLicence !== null && licencePriority[highestVendorLicence] >= licencePriority[import_cluemart_shared30.EnumUserLicence.PRO_VENDOR];
3610
4069
  }
3611
4070
 
3612
4071
  // src/service/license/compliance/utils.ts
@@ -3616,12 +4075,12 @@ async function syncUserLicencesAfterExpiry(userId, licenceTypes, now, mode = "do
3616
4075
  const pipeline = buildLicenceExpiryPipeline({
3617
4076
  downgradeBranches: [
3618
4077
  {
3619
- case: import_cluemart_shared29.EnumUserLicence.PRO_PLUS_VENDOR,
3620
- then: import_cluemart_shared29.EnumUserLicence.STANDARD_VENDOR
4078
+ case: import_cluemart_shared31.EnumUserLicence.PRO_PLUS_VENDOR,
4079
+ then: import_cluemart_shared31.EnumUserLicence.STANDARD_VENDOR
3621
4080
  },
3622
4081
  {
3623
- case: import_cluemart_shared29.EnumUserLicence.PRO_VENDOR,
3624
- then: import_cluemart_shared29.EnumUserLicence.STANDARD_VENDOR
4082
+ case: import_cluemart_shared31.EnumUserLicence.PRO_VENDOR,
4083
+ then: import_cluemart_shared31.EnumUserLicence.STANDARD_VENDOR
3625
4084
  }
3626
4085
  ],
3627
4086
  licenceTypes,
@@ -3750,7 +4209,7 @@ var REMINDER_WINDOW_MIN_HOURS = 6.5 * 24;
3750
4209
  var REMINDER_WINDOW_MAX_HOURS = 7.5 * 24;
3751
4210
 
3752
4211
  // src/service/license/reminder/utils.ts
3753
- var import_cluemart_shared30 = require("@timardex/cluemart-shared");
4212
+ var import_cluemart_shared32 = require("@timardex/cluemart-shared");
3754
4213
  var import_utils8 = require("@timardex/cluemart-shared/utils");
3755
4214
  var import_dayjs7 = __toESM(require("dayjs"));
3756
4215
 
@@ -3816,24 +4275,24 @@ function isLicenseExpiringIn7Days(expiryDate, now) {
3816
4275
  return hoursUntilExpiry >= REMINDER_WINDOW_MIN_HOURS && hoursUntilExpiry <= REMINDER_WINDOW_MAX_HOURS;
3817
4276
  }
3818
4277
  function getLicenseName(licenceType) {
3819
- return import_cluemart_shared30.licenseNiceNames[licenceType] || licenceType;
4278
+ return import_cluemart_shared32.licenseNiceNames[licenceType] || licenceType;
3820
4279
  }
3821
4280
  function getNotificationTypes(isVendorLicense, isPartnerLicense) {
3822
4281
  if (isVendorLicense) {
3823
4282
  return {
3824
- notificationType: import_cluemart_shared30.EnumNotificationType.SYSTEM,
3825
- resourceType: import_cluemart_shared30.EnumNotificationResourceType.EXPIRATION_REMINDER_VENDOR
4283
+ notificationType: import_cluemart_shared32.EnumNotificationType.SYSTEM,
4284
+ resourceType: import_cluemart_shared32.EnumNotificationResourceType.EXPIRATION_REMINDER_VENDOR
3826
4285
  };
3827
4286
  }
3828
4287
  if (isPartnerLicense) {
3829
4288
  return {
3830
- notificationType: import_cluemart_shared30.EnumNotificationType.SYSTEM,
3831
- resourceType: import_cluemart_shared30.EnumNotificationResourceType.EXPIRATION_REMINDER_PARTNER
4289
+ notificationType: import_cluemart_shared32.EnumNotificationType.SYSTEM,
4290
+ resourceType: import_cluemart_shared32.EnumNotificationResourceType.EXPIRATION_REMINDER_PARTNER
3832
4291
  };
3833
4292
  }
3834
4293
  return {
3835
- notificationType: import_cluemart_shared30.EnumNotificationType.SYSTEM,
3836
- resourceType: import_cluemart_shared30.EnumNotificationResourceType.EXPIRATION_REMINDER_EVENT
4294
+ notificationType: import_cluemart_shared32.EnumNotificationType.SYSTEM,
4295
+ resourceType: import_cluemart_shared32.EnumNotificationResourceType.EXPIRATION_REMINDER_EVENT
3837
4296
  };
3838
4297
  }
3839
4298
  async function getLicenseResourceInfo(user, licence) {
@@ -3885,11 +4344,11 @@ async function getLicenseResourceInfo(user, licence) {
3885
4344
  };
3886
4345
  }
3887
4346
  function getLicenceExpiryMode(licenceType) {
3888
- return licenceType === import_cluemart_shared30.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared30.EnumUserLicence.PRO_PLUS_VENDOR ? "downgrade" : "extend";
4347
+ return licenceType === import_cluemart_shared32.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared32.EnumUserLicence.PRO_PLUS_VENDOR ? "downgrade" : "extend";
3889
4348
  }
3890
4349
  async function sendLicenseReminder(user, licence) {
3891
4350
  const licenceName = getLicenseName(licence.licenceType);
3892
- const expiryDate = (0, import_dayjs7.default)(licence.expiryDate).format(import_cluemart_shared30.dateFormat);
4351
+ const expiryDate = (0, import_dayjs7.default)(licence.expiryDate).format(import_cluemart_shared32.dateFormat);
3893
4352
  const userId = String(user._id);
3894
4353
  const resourceInfo = await getLicenseResourceInfo(user, licence);
3895
4354
  if (!resourceInfo) {
@@ -4015,8 +4474,13 @@ async function remindUsersAboutLicenseExpiration() {
4015
4474
  // Annotate the CommonJS export names for ESM import in node:
4016
4475
  0 && (module.exports = {
4017
4476
  ACTIVE_NOT_DELETED_FILTER,
4477
+ AD_BILLING_CATALOG_COLLECTION_NAME,
4018
4478
  APP_SETTINGS_ID,
4479
+ AdBillingCatalogModel,
4480
+ AdBookingModel,
4481
+ AdImpressionModel,
4019
4482
  AdModel,
4483
+ AdSettingsModel,
4020
4484
  AffiliateModel,
4021
4485
  AppSettingModel,
4022
4486
  BILLING_CATALOG_COLLECTION_NAME,
@@ -4026,6 +4490,7 @@ async function remindUsersAboutLicenseExpiration() {
4026
4490
  ChatReportModel,
4027
4491
  ContactDetailsSchema,
4028
4492
  CouponModel,
4493
+ DEFAULT_AD_SETTINGS,
4029
4494
  EnumPubSubEvents,
4030
4495
  EventInfoModel,
4031
4496
  EventModel,
@@ -4064,6 +4529,7 @@ async function remindUsersAboutLicenseExpiration() {
4064
4529
  createLicenceObject,
4065
4530
  dateTimeSchema,
4066
4531
  didRemoveAnyEventDates,
4532
+ downgradeVendorProFeatures,
4067
4533
  ensureUserLicenseCompliance,
4068
4534
  ensureUserLicenseComplianceForUser,
4069
4535
  eventLicences,
@@ -4107,7 +4573,9 @@ async function remindUsersAboutLicenseExpiration() {
4107
4573
  remindUsersAboutLicenseExpiration,
4108
4574
  replaceUserLicenceWithObject,
4109
4575
  resourceRelationsSchema,
4576
+ restoreVendorProFeatures,
4110
4577
  saveNotificationsInDb,
4578
+ schemaAdresource,
4111
4579
  sendDeactivationNotification,
4112
4580
  sendLicenseReminder,
4113
4581
  sendPushNotifications,
@@ -4119,7 +4587,6 @@ async function remindUsersAboutLicenseExpiration() {
4119
4587
  updateAllEventDateTimeStatuses,
4120
4588
  updateRelationDatesToUnavailable,
4121
4589
  updateSingleDateTimeStatus,
4122
- updateVendorBasedOnUserLicense,
4123
4590
  upgradeUserToLicence,
4124
4591
  userLicenseSchema,
4125
4592
  vendorLicences,