@timardex/cluemart-server-shared 2.1.0 → 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,
@@ -109,7 +115,7 @@ __export(index_exports, {
109
115
  locationGeoSchema: () => locationGeoSchema,
110
116
  locationsSchema: () => locationsSchema,
111
117
  mapVendorLicenceToSubscriptionRewardType: () => mapVendorLicenceToSubscriptionRewardType,
112
- mongoose: () => import_mongoose32.default,
118
+ mongoose: () => import_mongoose36.default,
113
119
  normalizeAffiliatePromoCodes: () => normalizeAffiliatePromoCodes,
114
120
  normalizePromoCode: () => normalizePromoCode,
115
121
  notifyUsers: () => notifyUsers,
@@ -126,6 +132,7 @@ __export(index_exports, {
126
132
  resourceRelationsSchema: () => resourceRelationsSchema,
127
133
  restoreVendorProFeatures: () => restoreVendorProFeatures,
128
134
  saveNotificationsInDb: () => saveNotificationsInDb,
135
+ schemaAdresource: () => schemaAdresource,
129
136
  sendDeactivationNotification: () => sendDeactivationNotification,
130
137
  sendLicenseReminder: () => sendLicenseReminder,
131
138
  sendPushNotifications: () => sendPushNotifications,
@@ -178,9 +185,30 @@ var schemaAdresource = new MongooseSchema({
178
185
  var schema = new MongooseSchema(
179
186
  {
180
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
+ },
181
204
  clicks: { default: 0, required: true, type: Number },
182
205
  end: { required: true, type: Date },
183
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
+ },
184
212
  resource: { required: true, type: schemaAdresource },
185
213
  showOn: {
186
214
  default: [import_cluemart_shared.EnumAdShowOn.FRONT_PAGE],
@@ -212,20 +240,282 @@ schema.index({
212
240
  // eslint-disable-next-line sort-keys
213
241
  start: -1
214
242
  });
243
+ schema.index(
244
+ { bookingIds: 1 },
245
+ {
246
+ partialFilterExpression: { bookingIds: { $exists: true } },
247
+ unique: true
248
+ }
249
+ );
215
250
  var AdModel = import_mongoose.default.models.Ad || import_mongoose.default.model("Ad", schema);
216
251
 
217
- // src/mongoose/BillingCatalog.ts
218
- var import_cluemart_shared2 = require("@timardex/cluemart-shared");
252
+ // src/mongoose/AdBillingCatalog.ts
219
253
  var import_mongoose2 = __toESM(require("mongoose"));
220
- 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;
221
511
  var BILLING_CATALOG_COLLECTION_NAME = "billingCatalog";
222
512
  var paidVendorLicences = [
223
- import_cluemart_shared2.EnumUserLicence.PRO_VENDOR,
224
- import_cluemart_shared2.EnumUserLicence.PRO_PLUS_VENDOR
513
+ import_cluemart_shared4.EnumUserLicence.PRO_VENDOR,
514
+ import_cluemart_shared4.EnumUserLicence.PRO_PLUS_VENDOR
225
515
  ];
226
516
  var supportedBillingPeriods = [
227
- import_cluemart_shared2.EnumBillingPeriod.MONTHLY_CANCEL_ANYTIME,
228
- import_cluemart_shared2.EnumBillingPeriod.YEARLY_ANNUAL_BILLED
517
+ import_cluemart_shared4.EnumBillingPeriod.MONTHLY_CANCEL_ANYTIME,
518
+ import_cluemart_shared4.EnumBillingPeriod.YEARLY_ANNUAL_BILLED
229
519
  ];
230
520
  var unitAmountField = {
231
521
  min: 1,
@@ -237,8 +527,8 @@ var unitAmountField = {
237
527
  }
238
528
  };
239
529
  var currencyField = {
240
- default: import_cluemart_shared2.BILLING_CATALOG_CURRENCY,
241
- enum: [import_cluemart_shared2.BILLING_CATALOG_CURRENCY],
530
+ default: import_cluemart_shared4.BILLING_CATALOG_CURRENCY,
531
+ enum: [import_cluemart_shared4.BILLING_CATALOG_CURRENCY],
242
532
  immutable: true,
243
533
  lowercase: true,
244
534
  required: true,
@@ -264,7 +554,7 @@ var priceHistorySchema = new MongooseSchema2(
264
554
  default: null,
265
555
  ref: "User",
266
556
  required: false,
267
- type: import_mongoose2.default.Schema.Types.ObjectId
557
+ type: import_mongoose6.default.Schema.Types.ObjectId
268
558
  },
269
559
  currency: currencyField,
270
560
  effectiveFrom: { required: true, type: Date },
@@ -275,7 +565,7 @@ var priceHistorySchema = new MongooseSchema2(
275
565
  },
276
566
  { _id: false }
277
567
  );
278
- var schema2 = new MongooseSchema2(
568
+ var schema6 = new MongooseSchema2(
279
569
  {
280
570
  active: { default: true, required: true, type: Boolean },
281
571
  billingPeriod: {
@@ -287,7 +577,7 @@ var schema2 = new MongooseSchema2(
287
577
  currency: currencyField,
288
578
  effectiveFrom: { default: Date.now, required: true, type: Date },
289
579
  key: {
290
- enum: import_cluemart_shared2.BILLING_CATALOG_KEYS,
580
+ enum: import_cluemart_shared4.BILLING_CATALOG_KEYS,
291
581
  immutable: true,
292
582
  required: true,
293
583
  type: String,
@@ -331,7 +621,7 @@ var schema2 = new MongooseSchema2(
331
621
  default: null,
332
622
  ref: "User",
333
623
  required: false,
334
- type: import_mongoose2.default.Schema.Types.ObjectId
624
+ type: import_mongoose6.default.Schema.Types.ObjectId
335
625
  }
336
626
  },
337
627
  {
@@ -340,30 +630,30 @@ var schema2 = new MongooseSchema2(
340
630
  timestamps: true
341
631
  }
342
632
  );
343
- schema2.pre("validate", function validateDefinition() {
344
- if (!(0, import_cluemart_shared2.billingCatalogDefinitionMatches)(this)) {
633
+ schema6.pre("validate", function validateDefinition() {
634
+ if (!(0, import_cluemart_shared4.billingCatalogDefinitionMatches)(this)) {
345
635
  this.invalidate(
346
636
  "key",
347
637
  "Billing catalogue key does not match its licence and billing period."
348
638
  );
349
639
  }
350
640
  });
351
- schema2.index({ billingPeriod: 1, licenceType: 1 }, { unique: true });
352
- schema2.index({ active: 1, licenceType: 1 });
353
- schema2.index(
641
+ schema6.index({ billingPeriod: 1, licenceType: 1 }, { unique: true });
642
+ schema6.index({ active: 1, licenceType: 1 });
643
+ schema6.index(
354
644
  { stripePriceId: 1 },
355
645
  {
356
646
  partialFilterExpression: { stripePriceId: { $type: "string" } },
357
647
  unique: true
358
648
  }
359
649
  );
360
- var BillingCatalogModel = import_mongoose2.default.models.BillingCatalogEntry || import_mongoose2.default.model(
650
+ var BillingCatalogModel = import_mongoose6.default.models.BillingCatalogEntry || import_mongoose6.default.model(
361
651
  "BillingCatalogEntry",
362
- schema2,
652
+ schema6,
363
653
  BILLING_CATALOG_COLLECTION_NAME
364
654
  );
365
655
  function buildInitialBillingCatalogEntries(now = /* @__PURE__ */ new Date()) {
366
- return import_cluemart_shared2.INITIAL_BILLING_CATALOG.map((entry) => ({
656
+ return import_cluemart_shared4.INITIAL_BILLING_CATALOG.map((entry) => ({
367
657
  active: entry.active,
368
658
  billingPeriod: entry.billingPeriod,
369
659
  currency: entry.currency,
@@ -380,20 +670,20 @@ function buildInitialBillingCatalogEntries(now = /* @__PURE__ */ new Date()) {
380
670
  }));
381
671
  }
382
672
  function getBillingCatalogDefinition(key) {
383
- return import_cluemart_shared2.BILLING_CATALOG_DEFINITIONS[key];
673
+ return import_cluemart_shared4.BILLING_CATALOG_DEFINITIONS[key];
384
674
  }
385
675
 
386
676
  // src/mongoose/chat/Chat.ts
387
- var import_cluemart_shared3 = require("@timardex/cluemart-shared");
388
- var import_mongoose3 = __toESM(require("mongoose"));
389
- 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;
390
680
  var MessageReplyPreviewSchema = new MongooseSchema3(
391
681
  {
392
682
  contentPreview: { required: true, type: String },
393
683
  senderId: {
394
684
  ref: "User",
395
685
  required: true,
396
- type: import_mongoose3.default.Schema.Types.ObjectId
686
+ type: import_mongoose7.default.Schema.Types.ObjectId
397
687
  },
398
688
  senderName: { required: true, type: String }
399
689
  },
@@ -405,7 +695,7 @@ var MessageReactionSchema = new MongooseSchema3(
405
695
  userId: {
406
696
  ref: "User",
407
697
  required: true,
408
- type: import_mongoose3.default.Schema.Types.ObjectId
698
+ type: import_mongoose7.default.Schema.Types.ObjectId
409
699
  }
410
700
  },
411
701
  { _id: false }
@@ -416,7 +706,7 @@ var MessageSeenSchema = new MongooseSchema3(
416
706
  userId: {
417
707
  ref: "User",
418
708
  required: true,
419
- type: import_mongoose3.default.Schema.Types.ObjectId
709
+ type: import_mongoose7.default.Schema.Types.ObjectId
420
710
  }
421
711
  },
422
712
  { _id: false }
@@ -432,13 +722,13 @@ var MessageSchema = new MongooseSchema3(
432
722
  replyToMessageId: {
433
723
  ref: "Chat.messages",
434
724
  required: false,
435
- type: import_mongoose3.default.Schema.Types.ObjectId
725
+ type: import_mongoose7.default.Schema.Types.ObjectId
436
726
  },
437
727
  seenBy: { default: [], required: false, type: [MessageSeenSchema] },
438
728
  senderId: {
439
729
  ref: "User",
440
730
  required: true,
441
- type: import_mongoose3.default.Schema.Types.ObjectId
731
+ type: import_mongoose7.default.Schema.Types.ObjectId
442
732
  }
443
733
  },
444
734
  { timestamps: true }
@@ -451,7 +741,7 @@ var ParticipantSchema = new MongooseSchema3(
451
741
  userId: {
452
742
  ref: "User",
453
743
  required: true,
454
- type: import_mongoose3.default.Schema.Types.ObjectId
744
+ type: import_mongoose7.default.Schema.Types.ObjectId
455
745
  },
456
746
  userName: { required: true, type: String }
457
747
  },
@@ -464,7 +754,7 @@ var ChatSchema = new MongooseSchema3(
464
754
  chatDescription: { required: false, type: String },
465
755
  chatName: { required: true, type: String },
466
756
  chatType: {
467
- enum: Object.values(import_cluemart_shared3.EnumChatType),
757
+ enum: Object.values(import_cluemart_shared5.EnumChatType),
468
758
  required: true,
469
759
  type: String
470
760
  },
@@ -482,17 +772,17 @@ ChatSchema.index({
482
772
  "participants.userId": 1,
483
773
  updatedAt: -1
484
774
  });
485
- 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);
486
776
 
487
777
  // src/mongoose/chat/ChatReport.ts
488
- var import_cluemart_shared4 = require("@timardex/cluemart-shared");
489
- var import_mongoose4 = __toESM(require("mongoose"));
490
- 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;
491
781
  var ReasonSchema = new MongooseSchema4(
492
782
  {
493
783
  details: { default: null, required: false, type: String },
494
784
  reasonType: {
495
- enum: Object.values(import_cluemart_shared4.EnumChatReportReason),
785
+ enum: Object.values(import_cluemart_shared6.EnumChatReportReason),
496
786
  required: true,
497
787
  type: String
498
788
  }
@@ -504,18 +794,18 @@ var ChatReportSchema = new MongooseSchema4(
504
794
  chatId: {
505
795
  ref: "Chat",
506
796
  required: true,
507
- type: import_mongoose4.default.Schema.Types.ObjectId
797
+ type: import_mongoose8.default.Schema.Types.ObjectId
508
798
  },
509
799
  reason: { required: true, type: ReasonSchema },
510
800
  reportedUserId: {
511
801
  ref: "User",
512
802
  required: true,
513
- type: import_mongoose4.default.Schema.Types.ObjectId
803
+ type: import_mongoose8.default.Schema.Types.ObjectId
514
804
  },
515
805
  reporterUserId: {
516
806
  ref: "User",
517
807
  required: true,
518
- type: import_mongoose4.default.Schema.Types.ObjectId
808
+ type: import_mongoose8.default.Schema.Types.ObjectId
519
809
  },
520
810
  resolved: { default: false, required: true, type: Boolean }
521
811
  },
@@ -523,20 +813,20 @@ var ChatReportSchema = new MongooseSchema4(
523
813
  );
524
814
  ChatReportSchema.index({ chatId: 1, reportedUserId: 1 });
525
815
  ChatReportSchema.index({ createdAt: -1, reporterUserId: 1 });
526
- 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);
527
817
 
528
818
  // src/mongoose/global.ts
529
- var import_cluemart_shared7 = require("@timardex/cluemart-shared");
530
- var import_mongoose7 = __toESM(require("mongoose"));
819
+ var import_cluemart_shared9 = require("@timardex/cluemart-shared");
820
+ var import_mongoose11 = __toESM(require("mongoose"));
531
821
 
532
822
  // src/mongoose/Relation.ts
533
- var import_cluemart_shared6 = require("@timardex/cluemart-shared");
534
- var import_mongoose6 = __toESM(require("mongoose"));
823
+ var import_cluemart_shared8 = require("@timardex/cluemart-shared");
824
+ var import_mongoose10 = __toESM(require("mongoose"));
535
825
 
536
826
  // src/mongoose/event/EventInfo.ts
537
- var import_cluemart_shared5 = require("@timardex/cluemart-shared");
538
- var import_mongoose5 = __toESM(require("mongoose"));
539
- 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;
540
830
  var StallTypeSchema = new MongooseSchema5(
541
831
  {
542
832
  label: { required: false, type: String },
@@ -551,7 +841,7 @@ var StallTypeSchema = new MongooseSchema5(
551
841
  var dateTimeSchema = new MongooseSchema5(
552
842
  {
553
843
  dateStatus: {
554
- enum: Object.values(import_cluemart_shared5.EnumEventDateStatus),
844
+ enum: Object.values(import_cluemart_shared7.EnumEventDateStatus),
555
845
  required: false,
556
846
  type: String
557
847
  },
@@ -570,7 +860,7 @@ var paymentInfoSchema = new MongooseSchema5(
570
860
  accountNumber: { required: false, type: String },
571
861
  link: { required: false, type: String },
572
862
  paymentMethod: {
573
- enum: Object.values(import_cluemart_shared5.EnumPaymentMethod),
863
+ enum: Object.values(import_cluemart_shared7.EnumPaymentMethod),
574
864
  required: true,
575
865
  type: String
576
866
  }
@@ -597,7 +887,7 @@ var refundPolicySchema = new MongooseSchema5(
597
887
  },
598
888
  { _id: false }
599
889
  );
600
- var schema3 = new MongooseSchema5(
890
+ var schema7 = new MongooseSchema5(
601
891
  {
602
892
  active: { default: true, type: Boolean },
603
893
  applicationDeadlineHours: { required: true, type: Number },
@@ -605,7 +895,7 @@ var schema3 = new MongooseSchema5(
605
895
  eventId: {
606
896
  ref: "Event",
607
897
  required: true,
608
- type: import_mongoose5.default.Schema.Types.ObjectId
898
+ type: import_mongoose9.default.Schema.Types.ObjectId
609
899
  },
610
900
  packInTime: { required: true, type: Number },
611
901
  paymentDueHours: { required: true, type: Number },
@@ -615,15 +905,15 @@ var schema3 = new MongooseSchema5(
615
905
  },
616
906
  { timestamps: true }
617
907
  );
618
- schema3.index({ eventId: 1 });
619
- 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);
620
910
 
621
911
  // src/mongoose/Relation.ts
622
- var MongooseSchema6 = import_mongoose6.default.Schema;
912
+ var MongooseSchema6 = import_mongoose10.default.Schema;
623
913
  var relationDateTimeSchema = new MongooseSchema6(
624
914
  {
625
915
  dateStatus: {
626
- enum: Object.values(import_cluemart_shared6.EnumEventDateStatus),
916
+ enum: Object.values(import_cluemart_shared8.EnumEventDateStatus),
627
917
  required: true,
628
918
  type: String
629
919
  },
@@ -647,7 +937,7 @@ var relationDatesSchema = new MongooseSchema6(
647
937
  },
648
938
  paymentReference: { required: false, type: String },
649
939
  status: {
650
- enum: Object.values(import_cluemart_shared6.EnumInviteStatus),
940
+ enum: Object.values(import_cluemart_shared8.EnumInviteStatus),
651
941
  required: false,
652
942
  type: String
653
943
  }
@@ -660,29 +950,29 @@ var RelationTypeSchema = new MongooseSchema6(
660
950
  chatId: {
661
951
  ref: "Chat",
662
952
  required: true,
663
- type: import_mongoose6.default.Schema.Types.ObjectId
953
+ type: import_mongoose10.default.Schema.Types.ObjectId
664
954
  },
665
955
  deletedAt: { default: null, required: false, type: Date },
666
956
  eventId: {
667
957
  ref: "Event",
668
958
  required: true,
669
- type: import_mongoose6.default.Schema.Types.ObjectId
959
+ type: import_mongoose10.default.Schema.Types.ObjectId
670
960
  },
671
961
  lastUpdateBy: {
672
- enum: Object.values(import_cluemart_shared6.EnumResourceType),
962
+ enum: Object.values(import_cluemart_shared8.EnumResourceType),
673
963
  required: true,
674
964
  type: String
675
965
  },
676
966
  relationDates: [relationDatesSchema],
677
967
  relationType: {
678
- enum: Object.values(import_cluemart_shared6.EnumRelationResource),
968
+ enum: Object.values(import_cluemart_shared8.EnumRelationResource),
679
969
  required: true,
680
970
  type: String
681
971
  },
682
972
  vendorId: {
683
973
  ref: "Vendor",
684
974
  required: true,
685
- type: import_mongoose6.default.Schema.Types.ObjectId
975
+ type: import_mongoose10.default.Schema.Types.ObjectId
686
976
  }
687
977
  },
688
978
  { timestamps: true }
@@ -694,17 +984,17 @@ RelationTypeSchema.index({
694
984
  "relationDates.status": 1,
695
985
  vendorId: 1
696
986
  });
697
- 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);
698
988
 
699
989
  // src/mongoose/global.ts
700
- var MongooseSchema7 = import_mongoose7.default.Schema;
990
+ var MongooseSchema7 = import_mongoose11.default.Schema;
701
991
  var OwnerTypeSchema = new MongooseSchema7(
702
992
  {
703
993
  email: { required: true, type: String },
704
994
  userId: {
705
995
  ref: "User",
706
996
  required: true,
707
- type: import_mongoose7.default.Schema.Types.ObjectId
997
+ type: import_mongoose11.default.Schema.Types.ObjectId
708
998
  }
709
999
  },
710
1000
  { _id: false }
@@ -763,12 +1053,12 @@ var userLicenseSchema = new MongooseSchema7(
763
1053
  expiryDate: { required: true, type: Date },
764
1054
  issuedDate: { required: true, type: Date },
765
1055
  licenceType: {
766
- enum: Object.values(import_cluemart_shared7.EnumUserLicence),
1056
+ enum: Object.values(import_cluemart_shared9.EnumUserLicence),
767
1057
  required: true,
768
1058
  type: String
769
1059
  },
770
1060
  prevLicenceType: {
771
- enum: Object.values(import_cluemart_shared7.EnumUserLicence),
1061
+ enum: Object.values(import_cluemart_shared9.EnumUserLicence),
772
1062
  required: false,
773
1063
  type: String
774
1064
  }
@@ -811,7 +1101,7 @@ var resourceRelationsSchema = new MongooseSchema7(
811
1101
  relationId: {
812
1102
  ref: "Relation",
813
1103
  required: false,
814
- type: import_mongoose7.default.Schema.Types.ObjectId
1104
+ type: import_mongoose11.default.Schema.Types.ObjectId
815
1105
  }
816
1106
  },
817
1107
  { _id: false }
@@ -819,7 +1109,7 @@ var resourceRelationsSchema = new MongooseSchema7(
819
1109
  var dateTimeSchema2 = new MongooseSchema7(
820
1110
  {
821
1111
  dateStatus: {
822
- enum: Object.values(import_cluemart_shared7.EnumEventDateStatus),
1112
+ enum: Object.values(import_cluemart_shared9.EnumEventDateStatus),
823
1113
  required: false,
824
1114
  type: String
825
1115
  },
@@ -862,11 +1152,11 @@ var relatedPostSchema = new MongooseSchema7(
862
1152
  postId: {
863
1153
  ref: "Post",
864
1154
  required: true,
865
- type: import_mongoose7.default.Schema.Types.ObjectId
1155
+ type: import_mongoose11.default.Schema.Types.ObjectId
866
1156
  },
867
1157
  postSlug: { required: true, type: String },
868
1158
  postType: {
869
- enum: Object.values(import_cluemart_shared7.EnumPostType),
1159
+ enum: Object.values(import_cluemart_shared9.EnumPostType),
870
1160
  required: true,
871
1161
  type: String
872
1162
  }
@@ -887,7 +1177,7 @@ var baseResourceFields = {
887
1177
  adIds: {
888
1178
  ref: "Ad",
889
1179
  required: false,
890
- type: [import_mongoose7.default.Schema.Types.ObjectId]
1180
+ type: [import_mongoose11.default.Schema.Types.ObjectId]
891
1181
  },
892
1182
  approvedAt: { default: null, required: false, type: Date },
893
1183
  contactDetails: { required: false, type: ContactDetailsSchema },
@@ -917,8 +1207,8 @@ var baseResourceFields = {
917
1207
  };
918
1208
 
919
1209
  // src/mongoose/GoogleImportedMarket.ts
920
- var import_cluemart_shared8 = require("@timardex/cluemart-shared");
921
- var import_mongoose8 = __toESM(require("mongoose"));
1210
+ var import_cluemart_shared10 = require("@timardex/cluemart-shared");
1211
+ var import_mongoose12 = __toESM(require("mongoose"));
922
1212
 
923
1213
  // src/mongoose/searchNamePlugin.ts
924
1214
  function deriveSearchName(name) {
@@ -964,15 +1254,15 @@ function syncSearchNameInUpdate(update) {
964
1254
  }
965
1255
  return null;
966
1256
  }
967
- function searchNamePlugin(schema20) {
968
- schema20.add({ searchName: { default: "", required: false, type: String } });
969
- schema20.index({ searchName: 1 });
970
- 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) {
971
1261
  const doc = this;
972
1262
  doc.searchName = deriveSearchName(doc.name);
973
1263
  next();
974
1264
  });
975
- schema20.pre("insertMany", function syncSearchNameOnInsertMany(next, docs) {
1265
+ schema24.pre("insertMany", function syncSearchNameOnInsertMany(next, docs) {
976
1266
  const list = Array.isArray(docs) ? docs : [docs];
977
1267
  for (const doc of list) {
978
1268
  if (doc && typeof doc.name === "string") {
@@ -981,7 +1271,7 @@ function searchNamePlugin(schema20) {
981
1271
  }
982
1272
  next();
983
1273
  });
984
- schema20.pre("bulkWrite", function syncSearchNameOnBulkWrite(next, ops) {
1274
+ schema24.pre("bulkWrite", function syncSearchNameOnBulkWrite(next, ops) {
985
1275
  for (const op of ops) {
986
1276
  const doc = op.insertOne?.document ?? op.replaceOne?.replacement;
987
1277
  if (doc && typeof doc.name === "string") {
@@ -1007,14 +1297,14 @@ function searchNamePlugin(schema20) {
1007
1297
  }
1008
1298
  next();
1009
1299
  };
1010
- schema20.pre(
1300
+ schema24.pre(
1011
1301
  ["findOneAndUpdate", "updateOne", "updateMany"],
1012
1302
  syncSearchNameOnUpdate
1013
1303
  );
1014
1304
  }
1015
1305
 
1016
1306
  // src/mongoose/GoogleImportedMarket.ts
1017
- var MongooseSchema8 = import_mongoose8.default.Schema;
1307
+ var MongooseSchema8 = import_mongoose12.default.Schema;
1018
1308
  var addressComponentSchema = new MongooseSchema8(
1019
1309
  {
1020
1310
  longName: { required: false, type: String },
@@ -1023,7 +1313,7 @@ var addressComponentSchema = new MongooseSchema8(
1023
1313
  },
1024
1314
  { _id: false }
1025
1315
  );
1026
- var schema4 = new MongooseSchema8(
1316
+ var schema8 = new MongooseSchema8(
1027
1317
  {
1028
1318
  active: { default: false, required: true, type: Boolean },
1029
1319
  address: { required: true, type: String },
@@ -1035,7 +1325,7 @@ var schema4 = new MongooseSchema8(
1035
1325
  claimedByUserId: {
1036
1326
  ref: "User",
1037
1327
  required: false,
1038
- type: import_mongoose8.default.Schema.Types.ObjectId
1328
+ type: import_mongoose12.default.Schema.Types.ObjectId
1039
1329
  },
1040
1330
  cover: {
1041
1331
  required: false,
@@ -1047,10 +1337,10 @@ var schema4 = new MongooseSchema8(
1047
1337
  eventId: {
1048
1338
  ref: "Event",
1049
1339
  required: false,
1050
- type: import_mongoose8.default.Schema.Types.ObjectId
1340
+ type: import_mongoose12.default.Schema.Types.ObjectId
1051
1341
  },
1052
1342
  eventType: {
1053
- enum: Object.values(import_cluemart_shared8.EnumEventType),
1343
+ enum: Object.values(import_cluemart_shared10.EnumEventType),
1054
1344
  required: true,
1055
1345
  type: String
1056
1346
  },
@@ -1086,27 +1376,27 @@ var schema4 = new MongooseSchema8(
1086
1376
  },
1087
1377
  { timestamps: true }
1088
1378
  );
1089
- schema4.index({ "location.geo": "2dsphere" });
1090
- schema4.index({ name: 1 });
1091
- schema4.index({ region: 1 });
1092
- schema4.index({ deletedAt: 1 });
1093
- schema4.index({ "dateTime.dateStatus": 1 });
1094
- schema4.index({ slug: 1 });
1095
- schema4.index({ name: "text", description: "text" });
1096
- schema4.plugin(searchNamePlugin);
1097
- 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);
1098
1388
 
1099
1389
  // src/mongoose/Notification.ts
1100
- var import_cluemart_shared9 = require("@timardex/cluemart-shared");
1101
- var import_mongoose9 = __toESM(require("mongoose"));
1102
- var MongooseSchema9 = import_mongoose9.default.Schema;
1103
- 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(
1104
1394
  {
1105
1395
  data: {
1106
1396
  resourceId: { required: true, type: String },
1107
1397
  resourceName: { required: true, type: String },
1108
1398
  resourceType: {
1109
- enum: Object.values(import_cluemart_shared9.EnumNotificationResourceType),
1399
+ enum: Object.values(import_cluemart_shared11.EnumNotificationResourceType),
1110
1400
  required: true,
1111
1401
  type: String
1112
1402
  }
@@ -1115,28 +1405,28 @@ var schema5 = new MongooseSchema9(
1115
1405
  message: { required: true, type: String },
1116
1406
  title: { required: true, type: String },
1117
1407
  type: {
1118
- default: import_cluemart_shared9.EnumNotificationType.SYSTEM,
1119
- enum: Object.values(import_cluemart_shared9.EnumNotificationType),
1408
+ default: import_cluemart_shared11.EnumNotificationType.SYSTEM,
1409
+ enum: Object.values(import_cluemart_shared11.EnumNotificationType),
1120
1410
  required: true,
1121
1411
  type: String
1122
1412
  },
1123
1413
  userId: {
1124
1414
  ref: "User",
1125
1415
  required: true,
1126
- type: import_mongoose9.default.Schema.Types.ObjectId
1416
+ type: import_mongoose13.default.Schema.Types.ObjectId
1127
1417
  }
1128
1418
  },
1129
1419
  { timestamps: true }
1130
1420
  );
1131
- schema5.index({ isRead: 1, userId: 1 });
1132
- schema5.index({ createdAt: -1, userId: 1 });
1133
- 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);
1134
1424
 
1135
1425
  // src/mongoose/PushToken.ts
1136
1426
  var import_enums = require("@timardex/cluemart-shared/enums");
1137
- var import_mongoose10 = __toESM(require("mongoose"));
1138
- var MongooseSchema10 = import_mongoose10.default.Schema;
1139
- var schema6 = new MongooseSchema10(
1427
+ var import_mongoose14 = __toESM(require("mongoose"));
1428
+ var MongooseSchema10 = import_mongoose14.default.Schema;
1429
+ var schema10 = new MongooseSchema10(
1140
1430
  {
1141
1431
  platform: {
1142
1432
  enum: Object.values(import_enums.EnumOSPlatform),
@@ -1147,26 +1437,26 @@ var schema6 = new MongooseSchema10(
1147
1437
  userId: {
1148
1438
  ref: "User",
1149
1439
  required: true,
1150
- type: import_mongoose10.default.Schema.Types.ObjectId
1440
+ type: import_mongoose14.default.Schema.Types.ObjectId
1151
1441
  }
1152
1442
  },
1153
1443
  { timestamps: true }
1154
1444
  );
1155
- 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);
1156
1446
 
1157
1447
  // src/mongoose/ResourceActivity.ts
1158
- var import_cluemart_shared10 = require("@timardex/cluemart-shared");
1159
- var import_mongoose11 = __toESM(require("mongoose"));
1160
- 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;
1161
1451
  var ActivitySchema = new MongooseSchema11(
1162
1452
  {
1163
1453
  activityType: {
1164
- enum: Object.values(import_cluemart_shared10.EnumActivity),
1454
+ enum: Object.values(import_cluemart_shared12.EnumActivity),
1165
1455
  required: true,
1166
1456
  type: String
1167
1457
  },
1168
1458
  dateStatus: {
1169
- enum: Object.values(import_cluemart_shared10.EnumEventDateStatus),
1459
+ enum: Object.values(import_cluemart_shared12.EnumEventDateStatus),
1170
1460
  required: false,
1171
1461
  type: String
1172
1462
  },
@@ -1178,7 +1468,7 @@ var ActivitySchema = new MongooseSchema11(
1178
1468
  startTime: { required: false, type: String },
1179
1469
  timestamp: { default: Date.now, type: Date },
1180
1470
  userAgent: {
1181
- enum: Object.values(import_cluemart_shared10.EnumOSPlatform),
1471
+ enum: Object.values(import_cluemart_shared12.EnumOSPlatform),
1182
1472
  required: true,
1183
1473
  type: String
1184
1474
  },
@@ -1186,33 +1476,33 @@ var ActivitySchema = new MongooseSchema11(
1186
1476
  },
1187
1477
  { _id: false }
1188
1478
  );
1189
- var schema7 = new MongooseSchema11(
1479
+ var schema11 = new MongooseSchema11(
1190
1480
  {
1191
1481
  activity: { default: [], type: [ActivitySchema] },
1192
1482
  resourceId: { required: true, type: String },
1193
1483
  resourceType: {
1194
- enum: Object.values(import_cluemart_shared10.EnumResourceType),
1484
+ enum: Object.values(import_cluemart_shared12.EnumResourceType),
1195
1485
  required: true,
1196
1486
  type: String
1197
1487
  }
1198
1488
  },
1199
1489
  { timestamps: true }
1200
1490
  );
1201
- schema7.index({ resourceId: 1, resourceType: 1 }, { unique: true });
1202
- schema7.index({ "views.location": "2dsphere" });
1203
- 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);
1204
1494
 
1205
1495
  // src/mongoose/User.ts
1206
- var import_cluemart_shared11 = require("@timardex/cluemart-shared");
1207
- var import_mongoose12 = __toESM(require("mongoose"));
1208
- 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;
1209
1499
  var userActivityEventSchema = new MongooseSchema12(
1210
1500
  {
1211
1501
  dateTime: dateTimeSchema2,
1212
1502
  resourceId: {
1213
1503
  ref: "Event",
1214
1504
  required: false,
1215
- type: import_mongoose12.default.Schema.Types.ObjectId
1505
+ type: import_mongoose16.default.Schema.Types.ObjectId
1216
1506
  }
1217
1507
  },
1218
1508
  { _id: false }
@@ -1222,17 +1512,17 @@ var userActivityFavouritesSchema = new MongooseSchema12(
1222
1512
  events: {
1223
1513
  ref: "Event",
1224
1514
  required: false,
1225
- type: [import_mongoose12.default.Schema.Types.ObjectId]
1515
+ type: [import_mongoose16.default.Schema.Types.ObjectId]
1226
1516
  },
1227
1517
  partners: {
1228
1518
  ref: "Partner",
1229
1519
  required: false,
1230
- type: [import_mongoose12.default.Schema.Types.ObjectId]
1520
+ type: [import_mongoose16.default.Schema.Types.ObjectId]
1231
1521
  },
1232
1522
  vendors: {
1233
1523
  ref: "Vendor",
1234
1524
  required: false,
1235
- type: [import_mongoose12.default.Schema.Types.ObjectId]
1525
+ type: [import_mongoose16.default.Schema.Types.ObjectId]
1236
1526
  }
1237
1527
  },
1238
1528
  { _id: false }
@@ -1240,7 +1530,7 @@ var userActivityFavouritesSchema = new MongooseSchema12(
1240
1530
  var stripeSchema = new MongooseSchema12(
1241
1531
  {
1242
1532
  billingPeriod: {
1243
- enum: Object.values(import_cluemart_shared11.EnumBillingPeriod),
1533
+ enum: Object.values(import_cluemart_shared13.EnumBillingPeriod),
1244
1534
  required: false,
1245
1535
  type: String
1246
1536
  },
@@ -1249,7 +1539,7 @@ var stripeSchema = new MongooseSchema12(
1249
1539
  type: Boolean
1250
1540
  },
1251
1541
  currentPlan: {
1252
- enum: Object.values(import_cluemart_shared11.EnumUserLicence),
1542
+ enum: Object.values(import_cluemart_shared13.EnumUserLicence),
1253
1543
  required: false,
1254
1544
  type: String
1255
1545
  },
@@ -1261,8 +1551,20 @@ var stripeSchema = new MongooseSchema12(
1261
1551
  required: false,
1262
1552
  type: Date
1263
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
+ },
1264
1566
  pendingBillingPeriod: {
1265
- enum: Object.values(import_cluemart_shared11.EnumBillingPeriod),
1567
+ enum: Object.values(import_cluemart_shared13.EnumBillingPeriod),
1266
1568
  required: false,
1267
1569
  type: String
1268
1570
  },
@@ -1271,7 +1573,7 @@ var stripeSchema = new MongooseSchema12(
1271
1573
  type: Date
1272
1574
  },
1273
1575
  pendingPlan: {
1274
- enum: Object.values(import_cluemart_shared11.EnumUserLicence),
1576
+ enum: Object.values(import_cluemart_shared13.EnumUserLicence),
1275
1577
  required: false,
1276
1578
  type: String
1277
1579
  },
@@ -1288,7 +1590,7 @@ var stripeSchema = new MongooseSchema12(
1288
1590
  type: Date
1289
1591
  },
1290
1592
  status: {
1291
- enum: Object.values(import_cluemart_shared11.EnumSubscriptionStatus),
1593
+ enum: Object.values(import_cluemart_shared13.EnumSubscriptionStatus),
1292
1594
  required: false,
1293
1595
  type: String
1294
1596
  },
@@ -1310,7 +1612,7 @@ var stripeSchema = new MongooseSchema12(
1310
1612
  var redeemedRewardSchema = new MongooseSchema12(
1311
1613
  {
1312
1614
  name: {
1313
- enum: Object.values(import_cluemart_shared11.EnumReward),
1615
+ enum: Object.values(import_cluemart_shared13.EnumReward),
1314
1616
  required: true,
1315
1617
  type: String
1316
1618
  },
@@ -1319,13 +1621,13 @@ var redeemedRewardSchema = new MongooseSchema12(
1319
1621
  },
1320
1622
  { _id: false }
1321
1623
  );
1322
- var schema8 = new MongooseSchema12(
1624
+ var schema12 = new MongooseSchema12(
1323
1625
  {
1324
1626
  active: { default: false, required: true, type: Boolean },
1325
1627
  affiliate: {
1326
1628
  ref: "Affiliate",
1327
1629
  required: false,
1328
- type: import_mongoose12.default.Schema.Types.ObjectId
1630
+ type: import_mongoose16.default.Schema.Types.ObjectId
1329
1631
  },
1330
1632
  avatar: {
1331
1633
  required: false,
@@ -1334,28 +1636,28 @@ var schema8 = new MongooseSchema12(
1334
1636
  coupon: {
1335
1637
  ref: "Coupon",
1336
1638
  required: false,
1337
- type: import_mongoose12.default.Schema.Types.ObjectId
1639
+ type: import_mongoose16.default.Schema.Types.ObjectId
1338
1640
  },
1339
1641
  deletedAt: { default: null, required: false, type: Date },
1340
1642
  email: { required: true, type: String },
1341
1643
  emailSentFor: {
1342
- enum: Object.values(import_cluemart_shared11.EnumNotificationResourceType),
1644
+ enum: Object.values(import_cluemart_shared13.EnumNotificationResourceType),
1343
1645
  required: false,
1344
1646
  type: [String]
1345
1647
  },
1346
1648
  events: {
1347
1649
  ref: "Event",
1348
1650
  required: false,
1349
- type: [import_mongoose12.default.Schema.Types.ObjectId]
1651
+ type: [import_mongoose16.default.Schema.Types.ObjectId]
1350
1652
  },
1351
1653
  firstName: { required: true, type: String },
1352
1654
  game: {
1353
1655
  ref: "Game",
1354
1656
  required: false,
1355
- type: import_mongoose12.default.Schema.Types.ObjectId
1657
+ type: import_mongoose16.default.Schema.Types.ObjectId
1356
1658
  },
1357
1659
  interests: {
1358
- enum: Object.values(import_cluemart_shared11.EnumResourceType),
1660
+ enum: Object.values(import_cluemart_shared13.EnumResourceType),
1359
1661
  required: false,
1360
1662
  type: [String]
1361
1663
  },
@@ -1374,11 +1676,11 @@ var schema8 = new MongooseSchema12(
1374
1676
  partner: {
1375
1677
  ref: "Partner",
1376
1678
  required: false,
1377
- type: import_mongoose12.default.Schema.Types.ObjectId
1679
+ type: import_mongoose16.default.Schema.Types.ObjectId
1378
1680
  },
1379
1681
  password: { required: true, type: String },
1380
1682
  platform: {
1381
- enum: Object.values(import_cluemart_shared11.EnumOSPlatform),
1683
+ enum: Object.values(import_cluemart_shared13.EnumOSPlatform),
1382
1684
  required: false,
1383
1685
  type: String
1384
1686
  },
@@ -1399,15 +1701,15 @@ var schema8 = new MongooseSchema12(
1399
1701
  type: String
1400
1702
  },
1401
1703
  roles: {
1402
- default: [import_cluemart_shared11.EnumUserRole.CUSTOMER],
1403
- enum: Object.values(import_cluemart_shared11.EnumUserRole),
1704
+ default: [import_cluemart_shared13.EnumUserRole.CUSTOMER],
1705
+ enum: Object.values(import_cluemart_shared13.EnumUserRole),
1404
1706
  required: true,
1405
1707
  type: [String]
1406
1708
  },
1407
1709
  school: {
1408
1710
  ref: "School",
1409
1711
  required: false,
1410
- type: import_mongoose12.default.Schema.Types.ObjectId
1712
+ type: import_mongoose16.default.Schema.Types.ObjectId
1411
1713
  },
1412
1714
  stripe: {
1413
1715
  required: false,
@@ -1432,20 +1734,20 @@ var schema8 = new MongooseSchema12(
1432
1734
  vendor: {
1433
1735
  ref: "Vendor",
1434
1736
  required: false,
1435
- type: import_mongoose12.default.Schema.Types.ObjectId
1737
+ type: import_mongoose16.default.Schema.Types.ObjectId
1436
1738
  }
1437
1739
  },
1438
1740
  { strict: false, timestamps: true }
1439
1741
  );
1440
- schema8.index({ "licences.expiryDate": 1 });
1441
- schema8.index({ "licences.licenceType": 1 });
1442
- schema8.index({ promoCodes: 1, active: 1, deletedAt: 1 });
1443
- 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);
1444
1746
 
1445
1747
  // src/mongoose/VerificationToken.ts
1446
- var import_mongoose13 = __toESM(require("mongoose"));
1447
- var MongooseSchema13 = import_mongoose13.default.Schema;
1448
- var schema9 = new MongooseSchema13(
1748
+ var import_mongoose17 = __toESM(require("mongoose"));
1749
+ var MongooseSchema13 = import_mongoose17.default.Schema;
1750
+ var schema13 = new MongooseSchema13(
1449
1751
  {
1450
1752
  createdAt: {
1451
1753
  default: Date.now,
@@ -1460,12 +1762,12 @@ var schema9 = new MongooseSchema13(
1460
1762
  },
1461
1763
  { timestamps: true }
1462
1764
  );
1463
- 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);
1464
1766
 
1465
1767
  // src/mongoose/vendor/Vendor.ts
1466
- var import_cluemart_shared12 = require("@timardex/cluemart-shared");
1467
- var import_mongoose14 = __toESM(require("mongoose"));
1468
- 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;
1469
1771
  var vendorProductTypeSchema = new MongooseSchema14(
1470
1772
  {
1471
1773
  description: { required: false, type: String },
@@ -1488,7 +1790,7 @@ var calendarSchema = new MongooseSchema14(
1488
1790
  {
1489
1791
  dateTime: {
1490
1792
  dateStatus: {
1491
- enum: Object.values(import_cluemart_shared12.EnumEventDateStatus),
1793
+ enum: Object.values(import_cluemart_shared14.EnumEventDateStatus),
1492
1794
  required: false,
1493
1795
  type: String
1494
1796
  },
@@ -1528,7 +1830,7 @@ var downgradeSnapshotSchema = new MongooseSchema14(
1528
1830
  },
1529
1831
  { _id: false }
1530
1832
  );
1531
- var schema10 = new MongooseSchema14(
1833
+ var schema14 = new MongooseSchema14(
1532
1834
  {
1533
1835
  ...baseResourceFields,
1534
1836
  // Importing base resource fields from global.ts
@@ -1552,39 +1854,39 @@ var schema10 = new MongooseSchema14(
1552
1854
  unregisteredVendorId: {
1553
1855
  ref: "UnregisteredVendor",
1554
1856
  required: false,
1555
- type: import_mongoose14.default.Schema.Types.ObjectId
1857
+ type: import_mongoose18.default.Schema.Types.ObjectId
1556
1858
  },
1557
1859
  vendorInfoId: {
1558
1860
  ref: "VendorInfo",
1559
1861
  required: false,
1560
- type: import_mongoose14.default.Schema.Types.ObjectId
1862
+ type: import_mongoose18.default.Schema.Types.ObjectId
1561
1863
  },
1562
1864
  vendorType: {
1563
- enum: Object.values(import_cluemart_shared12.EnumVendorType),
1865
+ enum: Object.values(import_cluemart_shared14.EnumVendorType),
1564
1866
  required: true,
1565
1867
  type: String
1566
1868
  }
1567
1869
  },
1568
1870
  { timestamps: true }
1569
1871
  );
1570
- schema10.index({ name: 1 });
1571
- schema10.index({ description: 1 });
1572
- schema10.index({ region: 1 });
1573
- schema10.index({ "categories.name": 1 });
1574
- schema10.index({ slug: 1 });
1575
- schema10.index({
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({
1576
1878
  categoriesNames: "text",
1577
1879
  description: "text",
1578
1880
  name: "text"
1579
1881
  });
1580
- schema10.index({ deletedAt: 1, "owner.userId": 1 });
1581
- schema10.plugin(searchNamePlugin);
1582
- 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);
1583
1885
 
1584
1886
  // src/mongoose/vendor/VendorInfo.ts
1585
- var import_cluemart_shared13 = require("@timardex/cluemart-shared");
1586
- var import_mongoose15 = __toESM(require("mongoose"));
1587
- 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;
1588
1890
  var AttributesSchema = new MongooseSchema15(
1589
1891
  {
1590
1892
  details: { required: false, type: String },
@@ -1592,7 +1894,7 @@ var AttributesSchema = new MongooseSchema15(
1592
1894
  },
1593
1895
  { _id: false }
1594
1896
  );
1595
- var schema11 = new MongooseSchema15(
1897
+ var schema15 = new MongooseSchema15(
1596
1898
  {
1597
1899
  active: { default: true, type: Boolean },
1598
1900
  compliance: {
@@ -1602,7 +1904,7 @@ var schema11 = new MongooseSchema15(
1602
1904
  documents: [ResourceImageTypeSchema],
1603
1905
  product: {
1604
1906
  foodFlavors: {
1605
- enum: Object.values(import_cluemart_shared13.EnumFoodFlavor),
1907
+ enum: Object.values(import_cluemart_shared15.EnumFoodFlavor),
1606
1908
  required: true,
1607
1909
  type: [String]
1608
1910
  },
@@ -1627,29 +1929,29 @@ var schema11 = new MongooseSchema15(
1627
1929
  vendorId: {
1628
1930
  ref: "Vendor",
1629
1931
  required: true,
1630
- type: import_mongoose15.default.Schema.Types.ObjectId
1932
+ type: import_mongoose19.default.Schema.Types.ObjectId
1631
1933
  }
1632
1934
  },
1633
1935
  { timestamps: true }
1634
1936
  );
1635
- schema11.index({ vendorId: 1 });
1636
- 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);
1637
1939
 
1638
1940
  // src/mongoose/vendor/UnregisteredVendor.ts
1639
- var import_mongoose16 = __toESM(require("mongoose"));
1640
- var MongooseSchema16 = import_mongoose16.default.Schema;
1941
+ var import_mongoose20 = __toESM(require("mongoose"));
1942
+ var MongooseSchema16 = import_mongoose20.default.Schema;
1641
1943
  var invitationSchema = new MongooseSchema16(
1642
1944
  {
1643
1945
  dateTime: { required: true, type: [dateTimeSchema2] },
1644
1946
  inviterId: {
1645
1947
  ref: "Event",
1646
1948
  required: true,
1647
- type: import_mongoose16.default.Schema.Types.ObjectId
1949
+ type: import_mongoose20.default.Schema.Types.ObjectId
1648
1950
  }
1649
1951
  },
1650
1952
  { _id: false }
1651
1953
  );
1652
- var schema12 = new MongooseSchema16(
1954
+ var schema16 = new MongooseSchema16(
1653
1955
  {
1654
1956
  active: { default: true, required: true, type: Boolean },
1655
1957
  categoryIds: { required: true, type: [String] },
@@ -1658,7 +1960,7 @@ var schema12 = new MongooseSchema16(
1658
1960
  claimedByUserId: {
1659
1961
  ref: "User",
1660
1962
  required: false,
1661
- type: import_mongoose16.default.Schema.Types.ObjectId
1963
+ type: import_mongoose20.default.Schema.Types.ObjectId
1662
1964
  },
1663
1965
  claimInitiatedAt: { default: null, required: false, type: Date },
1664
1966
  claimToken: { default: null, required: false, type: String },
@@ -1671,15 +1973,15 @@ var schema12 = new MongooseSchema16(
1671
1973
  },
1672
1974
  { timestamps: true }
1673
1975
  );
1674
- schema12.index({ name: 1 });
1675
- schema12.index({ email: 1 });
1676
- 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);
1677
1979
 
1678
1980
  // src/mongoose/event/Event.ts
1679
- var import_cluemart_shared14 = require("@timardex/cluemart-shared");
1680
- var import_mongoose17 = __toESM(require("mongoose"));
1681
- var MongooseSchema17 = import_mongoose17.default.Schema;
1682
- 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(
1683
1985
  {
1684
1986
  ...baseResourceFields,
1685
1987
  // Importing base resource fields from global.ts
@@ -1688,10 +1990,10 @@ var schema13 = new MongooseSchema17(
1688
1990
  eventInfoId: {
1689
1991
  ref: "EventInfo",
1690
1992
  required: false,
1691
- type: import_mongoose17.default.Schema.Types.ObjectId
1993
+ type: import_mongoose21.default.Schema.Types.ObjectId
1692
1994
  },
1693
1995
  eventType: {
1694
- enum: Object.values(import_cluemart_shared14.EnumEventType),
1996
+ enum: Object.values(import_cluemart_shared16.EnumEventType),
1695
1997
  required: true,
1696
1998
  type: String
1697
1999
  },
@@ -1717,24 +2019,24 @@ var schema13 = new MongooseSchema17(
1717
2019
  },
1718
2020
  { timestamps: true }
1719
2021
  );
1720
- schema13.index({ name: 1 });
1721
- schema13.index({ description: 1 });
1722
- schema13.index({ region: 1 });
1723
- schema13.index({ "location.geo": "2dsphere" });
1724
- schema13.index({ tags: 1 });
1725
- schema13.index({ deletedAt: 1 });
1726
- schema13.index({ "dateTime.dateStatus": 1 });
1727
- schema13.index({ slug: 1 });
1728
- schema13.index({ name: "text", description: "text", tags: "text" });
1729
- schema13.index({ "owner.userId": 1, deletedAt: 1 });
1730
- schema13.plugin(searchNamePlugin);
1731
- 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);
1732
2034
 
1733
2035
  // src/mongoose/Partner.ts
1734
- var import_cluemart_shared15 = require("@timardex/cluemart-shared");
1735
- var import_mongoose18 = __toESM(require("mongoose"));
1736
- var MongooseSchema18 = import_mongoose18.default.Schema;
1737
- 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(
1738
2040
  {
1739
2041
  ...baseResourceFields,
1740
2042
  location: {
@@ -1743,33 +2045,33 @@ var schema14 = new MongooseSchema18(
1743
2045
  },
1744
2046
  nzbn: { required: true, type: String },
1745
2047
  partnerType: {
1746
- enum: Object.values(import_cluemart_shared15.EnumPartnerType),
2048
+ enum: Object.values(import_cluemart_shared17.EnumPartnerType),
1747
2049
  required: true,
1748
2050
  type: String
1749
2051
  }
1750
2052
  },
1751
2053
  { timestamps: true }
1752
2054
  );
1753
- schema14.index({ name: 1 });
1754
- schema14.index({ description: 1 });
1755
- schema14.index({ region: 1 });
1756
- schema14.index({ "location.geo": "2dsphere" });
1757
- schema14.index({ slug: 1 });
1758
- schema14.index({ name: "text", description: "text" });
1759
- schema14.index({ "owner.userId": 1, deletedAt: 1 });
1760
- schema14.plugin(searchNamePlugin);
1761
- 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);
1762
2064
 
1763
2065
  // src/mongoose/Post.ts
1764
- var import_cluemart_shared16 = require("@timardex/cluemart-shared");
1765
- var import_mongoose19 = __toESM(require("mongoose"));
1766
- 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;
1767
2069
  var contentSchema = new MongooseSchema19(
1768
2070
  {
1769
- contentData: import_mongoose19.Schema.Types.Mixed,
2071
+ contentData: import_mongoose23.Schema.Types.Mixed,
1770
2072
  contentOrder: { required: true, type: Number },
1771
2073
  contentType: {
1772
- enum: Object.values(import_cluemart_shared16.EnumPostContentType),
2074
+ enum: Object.values(import_cluemart_shared18.EnumPostContentType),
1773
2075
  required: true,
1774
2076
  type: String
1775
2077
  }
@@ -1782,14 +2084,14 @@ var resourceSchema = new MongooseSchema19(
1782
2084
  resourceRegion: { required: true, type: String },
1783
2085
  resourceSlug: { required: true, type: String },
1784
2086
  resourceType: {
1785
- enum: Object.values(import_cluemart_shared16.EnumResourceType),
2087
+ enum: Object.values(import_cluemart_shared18.EnumResourceType),
1786
2088
  required: true,
1787
2089
  type: String
1788
2090
  }
1789
2091
  },
1790
2092
  { _id: false }
1791
2093
  );
1792
- var schema15 = new MongooseSchema19(
2094
+ var schema19 = new MongooseSchema19(
1793
2095
  {
1794
2096
  active: { default: false, required: true, type: Boolean },
1795
2097
  approvedAt: { default: null, required: false, type: Date },
@@ -1805,7 +2107,7 @@ var schema15 = new MongooseSchema19(
1805
2107
  },
1806
2108
  deletedAt: { default: null, required: false, type: Date },
1807
2109
  postType: {
1808
- enum: Object.values(import_cluemart_shared16.EnumPostType),
2110
+ enum: Object.values(import_cluemart_shared18.EnumPostType),
1809
2111
  required: true,
1810
2112
  type: String
1811
2113
  },
@@ -1820,14 +2122,14 @@ var schema15 = new MongooseSchema19(
1820
2122
  },
1821
2123
  { timestamps: true }
1822
2124
  );
1823
- schema15.index({ title: 1 });
1824
- schema15.index({ tags: 1 });
1825
- schema15.index({ postType: 1, slug: 1 }, { unique: true });
1826
- 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);
1827
2129
 
1828
2130
  // src/mongoose/AppSetting.ts
1829
- var import_mongoose20 = __toESM(require("mongoose"));
1830
- var MongooseSchema20 = import_mongoose20.default.Schema;
2131
+ var import_mongoose24 = __toESM(require("mongoose"));
2132
+ var MongooseSchema20 = import_mongoose24.default.Schema;
1831
2133
  var APP_SETTINGS_ID = "APP_SETTINGS_DOCUMENT_ID";
1832
2134
  var AppSettingSchema = new MongooseSchema20(
1833
2135
  {
@@ -1860,18 +2162,18 @@ var AppSettingSchema = new MongooseSchema20(
1860
2162
  },
1861
2163
  { timestamps: true }
1862
2164
  );
1863
- 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);
1864
2166
 
1865
2167
  // src/mongoose/game/Game.ts
1866
- var import_cluemart_shared17 = require("@timardex/cluemart-shared");
1867
- var import_mongoose24 = __toESM(require("mongoose"));
2168
+ var import_cluemart_shared19 = require("@timardex/cluemart-shared");
2169
+ var import_mongoose28 = __toESM(require("mongoose"));
1868
2170
 
1869
2171
  // src/mongoose/game/DailyClue.ts
1870
- var import_mongoose22 = __toESM(require("mongoose"));
2172
+ var import_mongoose26 = __toESM(require("mongoose"));
1871
2173
 
1872
2174
  // src/mongoose/game/utils.ts
1873
- var import_mongoose21 = __toESM(require("mongoose"));
1874
- var MongooseSchema21 = import_mongoose21.default.Schema;
2175
+ var import_mongoose25 = __toESM(require("mongoose"));
2176
+ var MongooseSchema21 = import_mongoose25.default.Schema;
1875
2177
  var schemaGameDate = new MongooseSchema21(
1876
2178
  {
1877
2179
  endDate: { required: true, type: Date },
@@ -1881,7 +2183,7 @@ var schemaGameDate = new MongooseSchema21(
1881
2183
  );
1882
2184
 
1883
2185
  // src/mongoose/game/DailyClue.ts
1884
- var MongooseSchema22 = import_mongoose22.default.Schema;
2186
+ var MongooseSchema22 = import_mongoose26.default.Schema;
1885
2187
  var schemaLetters = new MongooseSchema22(
1886
2188
  {
1887
2189
  collected: { required: false, type: [String] },
@@ -1912,8 +2214,8 @@ var schemaDailyClueGameData = new MongooseSchema22(
1912
2214
  );
1913
2215
 
1914
2216
  // src/mongoose/game/PuzzleGame.ts
1915
- var import_mongoose23 = __toESM(require("mongoose"));
1916
- var MongooseSchema23 = import_mongoose23.default.Schema;
2217
+ var import_mongoose27 = __toESM(require("mongoose"));
2218
+ var MongooseSchema23 = import_mongoose27.default.Schema;
1917
2219
  var schemaPuzzleAnswer = new MongooseSchema23(
1918
2220
  {
1919
2221
  answer: { required: true, type: String },
@@ -1958,16 +2260,16 @@ var schemaPuzzleGameData = new MongooseSchema23(
1958
2260
  );
1959
2261
 
1960
2262
  // src/mongoose/game/Game.ts
1961
- var MongooseSchema24 = import_mongoose24.default.Schema;
2263
+ var MongooseSchema24 = import_mongoose28.default.Schema;
1962
2264
  var gameDataSchemas = {
1963
- [import_cluemart_shared17.EnumGameType.DAILY_CLUE]: schemaDailyClueGameData,
1964
- [import_cluemart_shared17.EnumGameType.MINI_QUIZ]: schemaPuzzleGameData,
1965
- [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
1966
2268
  };
1967
2269
  var gameDataDefinition = Object.fromEntries(
1968
- Object.entries(gameDataSchemas).map(([key, schema20]) => [
2270
+ Object.entries(gameDataSchemas).map(([key, schema24]) => [
1969
2271
  key,
1970
- { default: null, required: false, type: schema20 }
2272
+ { default: null, required: false, type: schema24 }
1971
2273
  ])
1972
2274
  );
1973
2275
  var gameHistorySchema = new MongooseSchema24(
@@ -1975,13 +2277,13 @@ var gameHistorySchema = new MongooseSchema24(
1975
2277
  createdAt: { required: true, type: Date },
1976
2278
  gameDate: { required: true, type: schemaGameDate },
1977
2279
  gameStatus: {
1978
- enum: Object.values(import_cluemart_shared17.EnumGameStatus),
2280
+ enum: Object.values(import_cluemart_shared19.EnumGameStatus),
1979
2281
  required: true,
1980
2282
  type: String
1981
2283
  },
1982
2284
  gameTitle: { required: true, type: String },
1983
2285
  gameType: {
1984
- enum: Object.values(import_cluemart_shared17.EnumGameType),
2286
+ enum: Object.values(import_cluemart_shared19.EnumGameType),
1985
2287
  required: true,
1986
2288
  type: String
1987
2289
  },
@@ -1997,7 +2299,7 @@ var gameTypeSchema = new MongooseSchema24(
1997
2299
  gameHistory: { default: [], required: true, type: [gameHistorySchema] },
1998
2300
  gameTitle: { required: true, type: String },
1999
2301
  gameType: {
2000
- enum: Object.values(import_cluemart_shared17.EnumGameType),
2302
+ enum: Object.values(import_cluemart_shared19.EnumGameType),
2001
2303
  required: true,
2002
2304
  type: String
2003
2305
  },
@@ -2005,7 +2307,7 @@ var gameTypeSchema = new MongooseSchema24(
2005
2307
  },
2006
2308
  { timestamps: true }
2007
2309
  );
2008
- var schema16 = new MongooseSchema24(
2310
+ var schema20 = new MongooseSchema24(
2009
2311
  {
2010
2312
  active: { default: false, required: true, type: Boolean },
2011
2313
  deletedAt: { default: null, required: false, type: Date },
@@ -2018,11 +2320,11 @@ var schema16 = new MongooseSchema24(
2018
2320
  },
2019
2321
  { timestamps: true }
2020
2322
  );
2021
- 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);
2022
2324
 
2023
2325
  // src/mongoose/School.ts
2024
- var import_mongoose25 = __toESM(require("mongoose"));
2025
- var MongooseSchema25 = import_mongoose25.default.Schema;
2326
+ var import_mongoose29 = __toESM(require("mongoose"));
2327
+ var MongooseSchema25 = import_mongoose29.default.Schema;
2026
2328
  var campaignsSchema = new MongooseSchema25(
2027
2329
  {
2028
2330
  endDate: { required: true, type: Date },
@@ -2031,7 +2333,7 @@ var campaignsSchema = new MongooseSchema25(
2031
2333
  },
2032
2334
  { _id: false }
2033
2335
  );
2034
- var schema17 = new MongooseSchema25(
2336
+ var schema21 = new MongooseSchema25(
2035
2337
  {
2036
2338
  // New schools are active by default
2037
2339
  active: { default: false, required: true, type: Boolean },
@@ -2058,26 +2360,26 @@ var schema17 = new MongooseSchema25(
2058
2360
  },
2059
2361
  { timestamps: true }
2060
2362
  );
2061
- schema17.index(
2363
+ schema21.index(
2062
2364
  { schoolCode: 1 },
2063
2365
  {
2064
2366
  partialFilterExpression: { active: true, deletedAt: null },
2065
2367
  unique: true
2066
2368
  }
2067
2369
  );
2068
- 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);
2069
2371
 
2070
2372
  // src/mongoose/Affiliate.ts
2071
- var import_cluemart_shared18 = require("@timardex/cluemart-shared");
2072
- var import_mongoose26 = __toESM(require("mongoose"));
2073
- 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;
2074
2376
  var affiliateRewardSchema = new MongooseSchema26(
2075
2377
  {
2076
2378
  createdAt: { required: true, type: Date },
2077
2379
  redeemedAt: { default: null, required: false, type: Date },
2078
2380
  rewardDescription: { required: true, type: String },
2079
2381
  rewardType: {
2080
- enum: Object.values(import_cluemart_shared18.EnumAffiliateRewardType),
2382
+ enum: Object.values(import_cluemart_shared20.EnumAffiliateRewardType),
2081
2383
  required: true,
2082
2384
  type: String
2083
2385
  },
@@ -2091,7 +2393,7 @@ var affiliateResourceSchema = new MongooseSchema26(
2091
2393
  resourceDeletedAt: { default: null, required: false, type: Date },
2092
2394
  resourceId: {
2093
2395
  required: true,
2094
- type: import_mongoose26.default.Schema.Types.ObjectId
2396
+ type: import_mongoose30.default.Schema.Types.ObjectId
2095
2397
  },
2096
2398
  resourceName: { required: true, type: String },
2097
2399
  resourceOwner: {
@@ -2099,7 +2401,7 @@ var affiliateResourceSchema = new MongooseSchema26(
2099
2401
  type: OwnerTypeSchema
2100
2402
  },
2101
2403
  resourceType: {
2102
- enum: Object.values(import_cluemart_shared18.EnumResourceType),
2404
+ enum: Object.values(import_cluemart_shared20.EnumResourceType),
2103
2405
  required: true,
2104
2406
  type: String
2105
2407
  },
@@ -2137,7 +2439,7 @@ var affiliateDetailsSchema = new MongooseSchema26(
2137
2439
  lastName: { required: true, type: String },
2138
2440
  location: { required: true, type: locationsSchema },
2139
2441
  participantType: {
2140
- enum: Object.values(import_cluemart_shared18.EnumAffiliateParticipantType),
2442
+ enum: Object.values(import_cluemart_shared20.EnumAffiliateParticipantType),
2141
2443
  required: true,
2142
2444
  type: String
2143
2445
  },
@@ -2154,7 +2456,7 @@ var redeemHistorySchema = new MongooseSchema26(
2154
2456
  },
2155
2457
  { _id: false }
2156
2458
  );
2157
- var schema18 = new MongooseSchema26(
2459
+ var schema22 = new MongooseSchema26(
2158
2460
  {
2159
2461
  active: { default: false, required: true, type: Boolean },
2160
2462
  affiliateBonusRewards: {
@@ -2184,26 +2486,26 @@ var schema18 = new MongooseSchema26(
2184
2486
  },
2185
2487
  { timestamps: true }
2186
2488
  );
2187
- schema18.index(
2489
+ schema22.index(
2188
2490
  { affiliateCode: 1 },
2189
2491
  {
2190
2492
  partialFilterExpression: { active: true, deletedAt: null },
2191
2493
  unique: true
2192
2494
  }
2193
2495
  );
2194
- 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);
2195
2497
 
2196
2498
  // src/mongoose/Coupon.ts
2197
- var import_cluemart_shared19 = require("@timardex/cluemart-shared");
2198
- var import_mongoose27 = __toESM(require("mongoose"));
2199
- 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;
2200
2502
  var couponOptionSchema = new MongooseSchema27(
2201
2503
  {
2202
2504
  buy: { required: false, type: Number },
2203
2505
  get: { required: false, type: Number },
2204
2506
  maxRewardCount: { required: false, type: Number },
2205
2507
  type: {
2206
- enum: Object.values(import_cluemart_shared19.EnumCouponQualificationType),
2508
+ enum: Object.values(import_cluemart_shared21.EnumCouponQualificationType),
2207
2509
  required: true,
2208
2510
  type: String
2209
2511
  },
@@ -2216,20 +2518,20 @@ var couponVendorProductSchema = new MongooseSchema27(
2216
2518
  {
2217
2519
  couponId: {
2218
2520
  required: true,
2219
- type: import_mongoose27.default.Schema.Types.ObjectId
2521
+ type: import_mongoose31.default.Schema.Types.ObjectId
2220
2522
  },
2221
2523
  productId: {
2222
2524
  required: true,
2223
- type: import_mongoose27.default.Schema.Types.ObjectId
2525
+ type: import_mongoose31.default.Schema.Types.ObjectId
2224
2526
  },
2225
2527
  vendorCouponId: {
2226
2528
  required: false,
2227
- type: import_mongoose27.default.Schema.Types.ObjectId
2529
+ type: import_mongoose31.default.Schema.Types.ObjectId
2228
2530
  },
2229
2531
  vendorId: {
2230
2532
  ref: "Vendor",
2231
2533
  required: true,
2232
- type: import_mongoose27.default.Schema.Types.ObjectId
2534
+ type: import_mongoose31.default.Schema.Types.ObjectId
2233
2535
  }
2234
2536
  },
2235
2537
  { _id: false }
@@ -2251,7 +2553,7 @@ var couponParticipantUserSchema = new MongooseSchema27(
2251
2553
  userId: {
2252
2554
  ref: "User",
2253
2555
  required: true,
2254
- type: import_mongoose27.default.Schema.Types.ObjectId
2556
+ type: import_mongoose31.default.Schema.Types.ObjectId
2255
2557
  }
2256
2558
  },
2257
2559
  { timestamps: true }
@@ -2275,7 +2577,7 @@ var couponDataSchema = new MongooseSchema27(
2275
2577
  },
2276
2578
  resourceId: { required: true, type: String },
2277
2579
  resourceType: {
2278
- enum: Object.values(import_cluemart_shared19.EnumResourceType),
2580
+ enum: Object.values(import_cluemart_shared21.EnumResourceType),
2279
2581
  required: true,
2280
2582
  type: String
2281
2583
  },
@@ -2283,7 +2585,7 @@ var couponDataSchema = new MongooseSchema27(
2283
2585
  },
2284
2586
  { timestamps: true }
2285
2587
  );
2286
- var schema19 = new MongooseSchema27(
2588
+ var schema23 = new MongooseSchema27(
2287
2589
  {
2288
2590
  active: { default: true, required: true, type: Boolean },
2289
2591
  couponData: { default: [], required: false, type: [couponDataSchema] },
@@ -2295,9 +2597,9 @@ var schema19 = new MongooseSchema27(
2295
2597
  },
2296
2598
  { timestamps: true }
2297
2599
  );
2298
- schema19.index({ active: 1, deletedAt: 1, "owner.userId": 1 });
2299
- schema19.index({ "couponData.participantUsers.userId": 1 });
2300
- 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);
2301
2603
 
2302
2604
  // src/service/promoCode/constants.ts
2303
2605
  var ACTIVE_NOT_DELETED_FILTER = {
@@ -2315,7 +2617,7 @@ async function activeAffiliateCodeExists(affiliateCode) {
2315
2617
  }
2316
2618
 
2317
2619
  // src/service/affiliate/awardAffiliateVendorSubscriptionRewards.ts
2318
- var import_cluemart_shared21 = require("@timardex/cluemart-shared");
2620
+ var import_cluemart_shared23 = require("@timardex/cluemart-shared");
2319
2621
  var import_utils3 = require("@timardex/cluemart-shared/utils");
2320
2622
 
2321
2623
  // src/service/saveNotificationsInDb.ts
@@ -2452,7 +2754,7 @@ async function sendPushNotifications({
2452
2754
  }
2453
2755
 
2454
2756
  // src/service/affiliate/vendorSubscriptionRewards.ts
2455
- var import_cluemart_shared20 = require("@timardex/cluemart-shared");
2757
+ var import_cluemart_shared22 = require("@timardex/cluemart-shared");
2456
2758
  var import_dayjs = __toESM(require("dayjs"));
2457
2759
  var import_timezone = __toESM(require("dayjs/plugin/timezone"));
2458
2760
  var import_utc = __toESM(require("dayjs/plugin/utc"));
@@ -2486,8 +2788,9 @@ async function getPayingStripePlanFor(userId, now, payingPlans) {
2486
2788
  if (stripe == null || stripe.subscriptionId == null) {
2487
2789
  return { hasSubscription: false, plan: null, validTypes };
2488
2790
  }
2489
- const hasActiveStatus = stripe.status === import_enums2.EnumSubscriptionStatus.ACTIVE || stripe.status === import_enums2.EnumSubscriptionStatus.TRIALING;
2490
- 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) {
2491
2794
  return { hasSubscription: false, plan: null, validTypes };
2492
2795
  }
2493
2796
  const plan = payingPlans.has(stripe.currentPlan) ? stripe.currentPlan : null;
@@ -2509,14 +2812,14 @@ import_dayjs.default.extend(import_timezone.default);
2509
2812
  var SUBSCRIPTION_REWARD_TIMEZONE = "Pacific/Auckland";
2510
2813
  async function mapVendorLicenceToSubscriptionRewardType(userId, now = /* @__PURE__ */ new Date()) {
2511
2814
  const { hasSubscription, validTypes } = await getPayingVendorStripeSubscriptionPlan(userId, now);
2512
- 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)) {
2513
2816
  if (hasSubscription) {
2514
- return import_cluemart_shared20.EnumAffiliateRewardType.ACTIVE_VENDOR_PRO_SUBSCRIPTION;
2817
+ return import_cluemart_shared22.EnumAffiliateRewardType.ACTIVE_VENDOR_PRO_SUBSCRIPTION;
2515
2818
  }
2516
- return import_cluemart_shared20.EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
2819
+ return import_cluemart_shared22.EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
2517
2820
  }
2518
- if (validTypes.has(import_cluemart_shared20.EnumUserLicence.STANDARD_VENDOR)) {
2519
- 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;
2520
2823
  }
2521
2824
  return null;
2522
2825
  }
@@ -2528,7 +2831,7 @@ function getSubscriptionRewardPeriodBounds(now = /* @__PURE__ */ new Date()) {
2528
2831
 
2529
2832
  // src/service/affiliate/awardAffiliateVendorSubscriptionRewards.ts
2530
2833
  function isEligibleVendorResource(resource) {
2531
- 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;
2532
2835
  }
2533
2836
  async function findAffiliatesWithActiveVendorReferrals() {
2534
2837
  return await AffiliateModel.find({
@@ -2537,7 +2840,7 @@ async function findAffiliatesWithActiveVendorReferrals() {
2537
2840
  $elemMatch: {
2538
2841
  resourceActive: true,
2539
2842
  resourceDeletedAt: null,
2540
- resourceType: import_cluemart_shared21.EnumResourceType.VENDOR
2843
+ resourceType: import_cluemart_shared23.EnumResourceType.VENDOR
2541
2844
  }
2542
2845
  },
2543
2846
  deletedAt: null
@@ -2558,18 +2861,24 @@ async function isEligibleReferredVendor({
2558
2861
  async function notifyAffiliateOwnerOfSubscriptionReward({
2559
2862
  affiliateId,
2560
2863
  affiliateOwnerUserId,
2561
- resourceName,
2562
- rewardValue
2864
+ awards
2563
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.`;
2564
2873
  const payload = {
2565
2874
  data: {
2566
2875
  resourceId: String(affiliateId),
2567
- resourceName,
2568
- resourceType: import_cluemart_shared21.EnumNotificationResourceType.AFFILIATE_REWARD_RECEIVED
2876
+ resourceName: resourceNames.join(", "),
2877
+ resourceType: import_cluemart_shared23.EnumNotificationResourceType.AFFILIATE_REWARD_RECEIVED
2569
2878
  },
2570
- message: `You earned ${rewardValue} points! Your referred vendor "${resourceName}" has an active subscription.`,
2879
+ message,
2571
2880
  title: "Affiliate points earned",
2572
- type: import_cluemart_shared21.EnumNotificationType.SYSTEM,
2881
+ type: import_cluemart_shared23.EnumNotificationType.SYSTEM,
2573
2882
  userIds: [affiliateOwnerUserId]
2574
2883
  };
2575
2884
  try {
@@ -2598,7 +2907,7 @@ async function tryAwardSubscriptionReward({
2598
2907
  resourceActive: true,
2599
2908
  resourceDeletedAt: null,
2600
2909
  resourceId: resource.resourceId,
2601
- resourceType: import_cluemart_shared21.EnumResourceType.VENDOR,
2910
+ resourceType: import_cluemart_shared23.EnumResourceType.VENDOR,
2602
2911
  rewards: {
2603
2912
  $not: {
2604
2913
  $elemMatch: {
@@ -2619,15 +2928,12 @@ async function tryAwardSubscriptionReward({
2619
2928
  }
2620
2929
  ).exec();
2621
2930
  if (updateResult.modifiedCount === 0) {
2622
- return "skipped";
2931
+ return null;
2623
2932
  }
2624
- await notifyAffiliateOwnerOfSubscriptionReward({
2625
- affiliateId: affiliate._id,
2626
- affiliateOwnerUserId: affiliate.owner.userId,
2933
+ return {
2627
2934
  resourceName: resource.resourceName,
2628
2935
  rewardValue: reward.rewardValue
2629
- });
2630
- return "awarded";
2936
+ };
2631
2937
  }
2632
2938
  async function processAffiliateVendorReferral({
2633
2939
  affiliate,
@@ -2641,14 +2947,14 @@ async function processAffiliateVendorReferral({
2641
2947
  resourceOwnerUserId: resource.resourceOwner.userId
2642
2948
  });
2643
2949
  if (!vendorEligible) {
2644
- return "skipped";
2950
+ return null;
2645
2951
  }
2646
2952
  const rewardType = await mapVendorLicenceToSubscriptionRewardType(
2647
2953
  resource.resourceOwner.userId,
2648
2954
  now
2649
2955
  );
2650
2956
  if (!rewardType) {
2651
- return "skipped";
2957
+ return null;
2652
2958
  }
2653
2959
  return tryAwardSubscriptionReward({
2654
2960
  affiliate,
@@ -2664,8 +2970,9 @@ async function awardAffiliateVendorSubscriptionRewards(now = /* @__PURE__ */ new
2664
2970
  const affiliates = await findAffiliatesWithActiveVendorReferrals();
2665
2971
  let awarded = 0;
2666
2972
  let skipped = 0;
2667
- const seenPairs = /* @__PURE__ */ new Set();
2668
2973
  for (const affiliate of affiliates) {
2974
+ const awards = [];
2975
+ const seenPairs = /* @__PURE__ */ new Set();
2669
2976
  for (const resource of affiliate.affiliateResources) {
2670
2977
  if (!isEligibleVendorResource(resource)) {
2671
2978
  continue;
@@ -2675,19 +2982,27 @@ async function awardAffiliateVendorSubscriptionRewards(now = /* @__PURE__ */ new
2675
2982
  continue;
2676
2983
  }
2677
2984
  seenPairs.add(pairKey);
2678
- const outcome = await processAffiliateVendorReferral({
2985
+ const award = await processAffiliateVendorReferral({
2679
2986
  affiliate,
2680
2987
  createdAt,
2681
2988
  now,
2682
2989
  period,
2683
2990
  resource
2684
2991
  });
2685
- if (outcome === "awarded") {
2992
+ if (award) {
2686
2993
  awarded += 1;
2994
+ awards.push(award);
2687
2995
  } else {
2688
2996
  skipped += 1;
2689
2997
  }
2690
2998
  }
2999
+ if (awards.length > 0) {
3000
+ await notifyAffiliateOwnerOfSubscriptionReward({
3001
+ affiliateId: affiliate._id,
3002
+ affiliateOwnerUserId: affiliate.owner.userId,
3003
+ awards
3004
+ });
3005
+ }
2691
3006
  }
2692
3007
  return { awarded, skipped };
2693
3008
  }
@@ -2713,7 +3028,7 @@ function normalizeAffiliatePromoCodes(promoCodes) {
2713
3028
  }
2714
3029
 
2715
3030
  // src/service/database.ts
2716
- var import_mongoose31 = __toESM(require("mongoose"));
3031
+ var import_mongoose35 = __toESM(require("mongoose"));
2717
3032
  var connectToDatabase = async ({
2718
3033
  appName,
2719
3034
  dbName,
@@ -2726,7 +3041,7 @@ var connectToDatabase = async ({
2726
3041
  // Fallback to MongoDB Atlas connection string
2727
3042
  `mongodb+srv://${dbUser}:${dbPassword}@${dbName}.mongodb.net/?retryWrites=true&w=majority&appName=${appName}`
2728
3043
  );
2729
- await import_mongoose31.default.connect(mongoUri);
3044
+ await import_mongoose35.default.connect(mongoUri);
2730
3045
  const connectionType = mongodbUri ? "Local MongoDB" : "MongoDB Atlas";
2731
3046
  console.log(
2732
3047
  `${connectionType} connected from server/src/service/database.ts`
@@ -2739,7 +3054,7 @@ var connectToDatabase = async ({
2739
3054
 
2740
3055
  // src/types/index.ts
2741
3056
  var import_express = __toESM(require("express"));
2742
- var import_mongoose32 = __toESM(require("mongoose"));
3057
+ var import_mongoose36 = __toESM(require("mongoose"));
2743
3058
  var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
2744
3059
  EnumPubSubEvents2["GET_CHAT_MESSAGE"] = "GET_CHAT_MESSAGE";
2745
3060
  EnumPubSubEvents2["GET_NOTIFICATIONS"] = "GET_NOTIFICATIONS";
@@ -2794,7 +3109,7 @@ async function notifyUsers({
2794
3109
  }
2795
3110
 
2796
3111
  // src/service/updateAdStatus.ts
2797
- var import_cluemart_shared22 = require("@timardex/cluemart-shared");
3112
+ var import_cluemart_shared24 = require("@timardex/cluemart-shared");
2798
3113
  async function updateAdStatuses() {
2799
3114
  const now = /* @__PURE__ */ new Date();
2800
3115
  const invalidResult = await AdModel.updateMany(
@@ -2804,41 +3119,66 @@ async function updateAdStatuses() {
2804
3119
  { end: { $exists: false } },
2805
3120
  { $expr: { $gt: ["$start", "$end"] } }
2806
3121
  ],
2807
- status: { $ne: import_cluemart_shared22.EnumAdStatus.PAUSED }
3122
+ status: { $ne: import_cluemart_shared24.EnumAdStatus.PAUSED }
2808
3123
  },
2809
- { $set: { status: import_cluemart_shared22.EnumAdStatus.PAUSED } }
3124
+ { $set: { status: import_cluemart_shared24.EnumAdStatus.PAUSED } }
2810
3125
  );
2811
3126
  const expiredResult = await AdModel.updateMany(
2812
- { end: { $lte: now }, status: { $ne: import_cluemart_shared22.EnumAdStatus.EXPIRED } },
2813
- { $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 } }
2814
3153
  );
2815
3154
  const activeResult = await AdModel.updateMany(
2816
3155
  {
2817
3156
  end: { $gt: now },
2818
3157
  start: { $lte: now },
2819
- status: { $ne: import_cluemart_shared22.EnumAdStatus.ACTIVE }
3158
+ status: { $ne: import_cluemart_shared24.EnumAdStatus.ACTIVE },
3159
+ ...eligibleBooking
2820
3160
  },
2821
- { $set: { status: import_cluemart_shared22.EnumAdStatus.ACTIVE } }
3161
+ { $set: { status: import_cluemart_shared24.EnumAdStatus.ACTIVE } }
2822
3162
  );
2823
3163
  const pausedResult = await AdModel.updateMany(
2824
- { start: { $gt: now }, status: { $ne: import_cluemart_shared22.EnumAdStatus.PAUSED } },
2825
- { $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 } }
2826
3166
  );
2827
3167
  console.log(
2828
- `\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}`
2829
3169
  );
2830
3170
  }
2831
3171
 
2832
3172
  // src/service/objectIdToString.ts
2833
- var import_mongoose34 = __toESM(require("mongoose"));
3173
+ var import_mongoose38 = __toESM(require("mongoose"));
2834
3174
  function isValidObjectId(value) {
2835
- return import_mongoose34.default.Types.ObjectId.isValid(value);
3175
+ return import_mongoose38.default.Types.ObjectId.isValid(value);
2836
3176
  }
2837
3177
  function convertObjectIdsToStrings(obj) {
2838
3178
  if (obj === null || obj === void 0) {
2839
3179
  return obj;
2840
3180
  }
2841
- if (obj instanceof import_mongoose34.default.Types.ObjectId) {
3181
+ if (obj instanceof import_mongoose38.default.Types.ObjectId) {
2842
3182
  return obj.toString();
2843
3183
  }
2844
3184
  if (obj instanceof Date) {
@@ -2858,7 +3198,7 @@ function convertObjectIdsToStrings(obj) {
2858
3198
  }
2859
3199
 
2860
3200
  // src/service/event/updateAllEventDateTimeStatuses.ts
2861
- var import_cluemart_shared23 = require("@timardex/cluemart-shared");
3201
+ var import_cluemart_shared25 = require("@timardex/cluemart-shared");
2862
3202
  var import_dayjs2 = __toESM(require("dayjs"));
2863
3203
  var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat"));
2864
3204
  var import_isoWeek = __toESM(require("dayjs/plugin/isoWeek"));
@@ -2867,24 +3207,24 @@ import_dayjs2.default.extend(import_isoWeek.default);
2867
3207
  function getFutureEventStatus(startDateTime, now) {
2868
3208
  const hoursUntilStart = startDateTime.diff(now, "hour", true);
2869
3209
  if (hoursUntilStart > 0 && hoursUntilStart <= 4) {
2870
- return import_cluemart_shared23.EnumEventDateStatus.STARTING_SOON;
3210
+ return import_cluemart_shared25.EnumEventDateStatus.STARTING_SOON;
2871
3211
  }
2872
3212
  if (startDateTime.isSame(now, "day")) {
2873
- return import_cluemart_shared23.EnumEventDateStatus.TODAY;
3213
+ return import_cluemart_shared25.EnumEventDateStatus.TODAY;
2874
3214
  }
2875
3215
  if (startDateTime.isSame(now.add(1, "day"), "day")) {
2876
- return import_cluemart_shared23.EnumEventDateStatus.TOMORROW;
3216
+ return import_cluemart_shared25.EnumEventDateStatus.TOMORROW;
2877
3217
  }
2878
3218
  if (startDateTime.isSame(now, "isoWeek")) {
2879
- return import_cluemart_shared23.EnumEventDateStatus.THIS_WEEK;
3219
+ return import_cluemart_shared25.EnumEventDateStatus.THIS_WEEK;
2880
3220
  }
2881
3221
  if (startDateTime.isSame(now.add(1, "week"), "isoWeek")) {
2882
- return import_cluemart_shared23.EnumEventDateStatus.NEXT_WEEK;
3222
+ return import_cluemart_shared25.EnumEventDateStatus.NEXT_WEEK;
2883
3223
  }
2884
- return import_cluemart_shared23.EnumEventDateStatus.UPCOMING;
3224
+ return import_cluemart_shared25.EnumEventDateStatus.UPCOMING;
2885
3225
  }
2886
3226
  function updateSingleDateTimeStatus(dateTime, now = (0, import_dayjs2.default)()) {
2887
- const dateTimeFormat = `${import_cluemart_shared23.dateFormat} ${import_cluemart_shared23.timeFormat}`;
3227
+ const dateTimeFormat = `${import_cluemart_shared25.dateFormat} ${import_cluemart_shared25.timeFormat}`;
2888
3228
  const startDateTime = (0, import_dayjs2.default)(
2889
3229
  `${dateTime.startDate} ${dateTime.startTime}`,
2890
3230
  dateTimeFormat,
@@ -2898,13 +3238,13 @@ function updateSingleDateTimeStatus(dateTime, now = (0, import_dayjs2.default)()
2898
3238
  if (!startDateTime.isValid() || !endDateTime.isValid()) {
2899
3239
  return {
2900
3240
  ...dateTime,
2901
- dateStatus: import_cluemart_shared23.EnumEventDateStatus.INVALID
3241
+ dateStatus: import_cluemart_shared25.EnumEventDateStatus.INVALID
2902
3242
  };
2903
3243
  }
2904
3244
  if (endDateTime.isBefore(startDateTime)) {
2905
3245
  return {
2906
3246
  ...dateTime,
2907
- dateStatus: import_cluemart_shared23.EnumEventDateStatus.INVALID
3247
+ dateStatus: import_cluemart_shared25.EnumEventDateStatus.INVALID
2908
3248
  };
2909
3249
  }
2910
3250
  let dateStatus;
@@ -2912,10 +3252,10 @@ function updateSingleDateTimeStatus(dateTime, now = (0, import_dayjs2.default)()
2912
3252
  if (startDateTime.isAfter(now)) {
2913
3253
  dateStatus = getFutureEventStatus(startDateTime, now);
2914
3254
  } else {
2915
- dateStatus = import_cluemart_shared23.EnumEventDateStatus.STARTED;
3255
+ dateStatus = import_cluemart_shared25.EnumEventDateStatus.STARTED;
2916
3256
  }
2917
3257
  } else {
2918
- dateStatus = import_cluemart_shared23.EnumEventDateStatus.ENDED;
3258
+ dateStatus = import_cluemart_shared25.EnumEventDateStatus.ENDED;
2919
3259
  }
2920
3260
  return {
2921
3261
  ...dateTime,
@@ -2999,7 +3339,7 @@ async function findEventOrImportedMarketById(resourceId) {
2999
3339
  }
3000
3340
 
3001
3341
  // src/service/relations.ts
3002
- var import_cluemart_shared24 = require("@timardex/cluemart-shared");
3342
+ var import_cluemart_shared26 = require("@timardex/cluemart-shared");
3003
3343
  function didRemoveAnyEventDates(previousDateTime, nextDateTime) {
3004
3344
  if (!previousDateTime?.length) {
3005
3345
  return false;
@@ -3017,7 +3357,7 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
3017
3357
  ) ?? false;
3018
3358
  return {
3019
3359
  ...relationDate,
3020
- status: existsInEvent ? relationDate.status : import_cluemart_shared24.EnumInviteStatus.UNAVAILABLE
3360
+ status: existsInEvent ? relationDate.status : import_cluemart_shared26.EnumInviteStatus.UNAVAILABLE
3021
3361
  };
3022
3362
  });
3023
3363
  }
@@ -3026,15 +3366,15 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
3026
3366
  var import_dayjs6 = __toESM(require("dayjs"));
3027
3367
 
3028
3368
  // src/service/license/compliance/utils.ts
3029
- var import_cluemart_shared29 = require("@timardex/cluemart-shared");
3369
+ var import_cluemart_shared31 = require("@timardex/cluemart-shared");
3030
3370
  var import_dayjs5 = __toESM(require("dayjs"));
3031
3371
 
3032
3372
  // src/service/license/compliance/event.ts
3033
- var import_cluemart_shared25 = require("@timardex/cluemart-shared");
3373
+ var import_cluemart_shared27 = require("@timardex/cluemart-shared");
3034
3374
  var eventLicences = [
3035
- import_cluemart_shared25.EnumUserLicence.STANDARD_EVENT,
3036
- import_cluemart_shared25.EnumUserLicence.PRO_EVENT,
3037
- 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
3038
3378
  ];
3039
3379
  async function handleEventLicenceCompliance(user, now) {
3040
3380
  if (!user.licences || !user.events?.length) {
@@ -3246,9 +3586,9 @@ function buildLicenceExpiryPipeline(params) {
3246
3586
  }
3247
3587
 
3248
3588
  // src/service/license/compliance/partner.ts
3249
- var import_cluemart_shared26 = require("@timardex/cluemart-shared");
3589
+ var import_cluemart_shared28 = require("@timardex/cluemart-shared");
3250
3590
  var partnerLicences = [
3251
- import_cluemart_shared26.EnumUserLicence.STANDARD_PARTNER
3591
+ import_cluemart_shared28.EnumUserLicence.STANDARD_PARTNER
3252
3592
  ];
3253
3593
  async function handlePartnerLicenceCompliance(user, now) {
3254
3594
  if (!user.licences || !user.partner) {
@@ -3258,11 +3598,11 @@ async function handlePartnerLicenceCompliance(user, now) {
3258
3598
  }
3259
3599
 
3260
3600
  // src/service/license/compliance/vendor.ts
3261
- var import_cluemart_shared28 = require("@timardex/cluemart-shared");
3601
+ var import_cluemart_shared30 = require("@timardex/cluemart-shared");
3262
3602
  var import_dayjs4 = __toESM(require("dayjs"));
3263
3603
 
3264
3604
  // src/service/license/models.ts
3265
- var import_cluemart_shared27 = require("@timardex/cluemart-shared");
3605
+ var import_cluemart_shared29 = require("@timardex/cluemart-shared");
3266
3606
  var import_dayjs3 = __toESM(require("dayjs"));
3267
3607
  var import_graphql = require("graphql");
3268
3608
  var LicenceExpiryDate = /* @__PURE__ */ ((LicenceExpiryDate2) => {
@@ -3280,31 +3620,31 @@ var LicenceCategory = /* @__PURE__ */ ((LicenceCategory2) => {
3280
3620
  return LicenceCategory2;
3281
3621
  })(LicenceCategory || {});
3282
3622
  var licenceCategoryMapping = {
3283
- [import_cluemart_shared27.EnumUserLicence.PRO_EVENT]: "event" /* EVENT */,
3284
- [import_cluemart_shared27.EnumUserLicence.PRO_PLUS_EVENT]: "event" /* EVENT */,
3285
- [import_cluemart_shared27.EnumUserLicence.PRO_PLUS_VENDOR]: "vendor" /* VENDOR */,
3286
- [import_cluemart_shared27.EnumUserLicence.PRO_VENDOR]: "vendor" /* VENDOR */,
3287
- [import_cluemart_shared27.EnumUserLicence.STANDARD_EVENT]: "event" /* EVENT */,
3288
- [import_cluemart_shared27.EnumUserLicence.STANDARD_PARTNER]: "partner" /* PARTNER */,
3289
- [import_cluemart_shared27.EnumUserLicence.STANDARD_VENDOR]: "vendor" /* VENDOR */,
3290
- [import_cluemart_shared27.EnumUserLicence.STANDARD_AFFILIATE]: "affiliate" /* AFFILIATE */,
3291
- [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 */
3292
3632
  };
3293
3633
  var licencePriority = {
3294
- [import_cluemart_shared27.EnumUserLicence.PRO_PLUS_EVENT]: 3,
3295
- [import_cluemart_shared27.EnumUserLicence.PRO_EVENT]: 2,
3296
- [import_cluemart_shared27.EnumUserLicence.STANDARD_EVENT]: 1,
3297
- [import_cluemart_shared27.EnumUserLicence.PRO_PLUS_VENDOR]: 3,
3298
- [import_cluemart_shared27.EnumUserLicence.PRO_VENDOR]: 2,
3299
- [import_cluemart_shared27.EnumUserLicence.STANDARD_VENDOR]: 1,
3300
- [import_cluemart_shared27.EnumUserLicence.STANDARD_PARTNER]: 1,
3301
- [import_cluemart_shared27.EnumUserLicence.STANDARD_AFFILIATE]: 1,
3302
- [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
3303
3643
  };
3304
3644
  var standardLicences = [
3305
- import_cluemart_shared27.EnumUserLicence.STANDARD_VENDOR,
3306
- import_cluemart_shared27.EnumUserLicence.STANDARD_EVENT,
3307
- 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
3308
3648
  ];
3309
3649
  var standardLicenceSet = new Set(standardLicences);
3310
3650
  function isStandardLicence(licence) {
@@ -3318,11 +3658,11 @@ var categoryRegexMapping = {
3318
3658
  ["school" /* SCHOOL */]: /_school$/
3319
3659
  };
3320
3660
  var categoryFallbackLicence = {
3321
- ["event" /* EVENT */]: import_cluemart_shared27.EnumUserLicence.STANDARD_EVENT,
3322
- ["partner" /* PARTNER */]: import_cluemart_shared27.EnumUserLicence.STANDARD_PARTNER,
3323
- ["vendor" /* VENDOR */]: import_cluemart_shared27.EnumUserLicence.STANDARD_VENDOR,
3324
- ["affiliate" /* AFFILIATE */]: import_cluemart_shared27.EnumUserLicence.STANDARD_AFFILIATE,
3325
- ["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
3326
3666
  };
3327
3667
  var LicenceFilterInput = {
3328
3668
  INPUT_USER_LICENCES: "$licences"
@@ -3458,13 +3798,13 @@ async function checkOwnerHasLicence({
3458
3798
  const owner = await UserModel.findById(userId);
3459
3799
  if (!owner) throw new import_graphql.GraphQLError("Owner not found");
3460
3800
  const categoryByResource = {
3461
- [import_cluemart_shared27.EnumResourceType.EVENT]: "event" /* EVENT */,
3462
- [import_cluemart_shared27.EnumResourceType.PARTNER]: "partner" /* PARTNER */,
3463
- [import_cluemart_shared27.EnumResourceType.VENDOR]: "vendor" /* VENDOR */,
3464
- [import_cluemart_shared27.EnumResourceType.AFFILIATE]: "affiliate" /* AFFILIATE */,
3465
- [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 */
3466
3806
  };
3467
- if (!(0, import_cluemart_shared27.isNonVisitorResourceType)(resourceType)) {
3807
+ if (!(0, import_cluemart_shared29.isNonVisitorResourceType)(resourceType)) {
3468
3808
  throw new import_graphql.GraphQLError(`Invalid resource type: ${resourceType}.`);
3469
3809
  }
3470
3810
  const requiredCategory = categoryByResource[resourceType];
@@ -3501,7 +3841,9 @@ async function findUserVendor(userId, logLabel) {
3501
3841
  "owner.userId": userId
3502
3842
  }).lean().exec();
3503
3843
  if (!vendor) {
3504
- console.warn(`[${logLabel}] Vendor not found for id=${user.vendor}`);
3844
+ console.warn(
3845
+ `[${logLabel}] Vendor not found for id=${user.vendor}, userId=${userId}`
3846
+ );
3505
3847
  return null;
3506
3848
  }
3507
3849
  return vendor;
@@ -3542,7 +3884,7 @@ async function applyVendorDowngrade(vendor, ownerUserId) {
3542
3884
  return (result?.matchedCount ?? 0) > 0;
3543
3885
  }
3544
3886
  async function downgradeVendorProFeatures(userId, licenceType) {
3545
- const isStandardVendor = licenceType === import_cluemart_shared28.EnumUserLicence.STANDARD_VENDOR;
3887
+ const isStandardVendor = licenceType === import_cluemart_shared30.EnumUserLicence.STANDARD_VENDOR;
3546
3888
  if (!isStandardVendor) {
3547
3889
  return;
3548
3890
  }
@@ -3554,6 +3896,7 @@ async function downgradeVendorProFeatures(userId, licenceType) {
3554
3896
  await applyVendorDowngrade(vendor, userId);
3555
3897
  } catch (error) {
3556
3898
  console.error("[downgradeVendorProFeatures] Failed:", error);
3899
+ throw error;
3557
3900
  }
3558
3901
  }
3559
3902
  async function applyVendorRestore(vendor, ownerUserId) {
@@ -3588,7 +3931,7 @@ async function applyVendorRestore(vendor, ownerUserId) {
3588
3931
  return (result?.matchedCount ?? 0) > 0;
3589
3932
  }
3590
3933
  async function restoreVendorProFeatures(userId, licenceType) {
3591
- const isProVendor = licenceType === import_cluemart_shared28.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared28.EnumUserLicence.PRO_PLUS_VENDOR;
3934
+ const isProVendor = licenceType === import_cluemart_shared30.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared30.EnumUserLicence.PRO_PLUS_VENDOR;
3592
3935
  if (!isProVendor) {
3593
3936
  return;
3594
3937
  }
@@ -3600,23 +3943,35 @@ async function restoreVendorProFeatures(userId, licenceType) {
3600
3943
  await applyVendorRestore(vendor, userId);
3601
3944
  } catch (error) {
3602
3945
  console.error("[restoreVendorProFeatures] Failed:", error);
3946
+ throw error;
3603
3947
  }
3604
3948
  }
3605
3949
  var vendorLicences = [
3606
- import_cluemart_shared28.EnumUserLicence.STANDARD_VENDOR,
3607
- import_cluemart_shared28.EnumUserLicence.PRO_VENDOR,
3608
- 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
3609
3953
  ];
3610
3954
  function isProtectedByCurrentStripeSubscription(user, licenceType, now) {
3611
3955
  const stripe = user.stripe;
3612
- 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) {
3613
3957
  return false;
3614
3958
  }
3615
- 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) {
3616
3962
  return true;
3617
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
+ }
3618
3973
  const paidThrough = (0, import_dayjs4.default)(stripe.endDate);
3619
- return !paidThrough.isValid() || paidThrough.isAfter(now);
3974
+ return paidThrough.isValid() && paidThrough.isAfter(now);
3620
3975
  }
3621
3976
  async function handleVendorLicenceCompliance(user, now) {
3622
3977
  if (!user.licences || !user.vendor) {
@@ -3629,7 +3984,7 @@ async function handleVendorLicenceCompliance(user, now) {
3629
3984
  return;
3630
3985
  }
3631
3986
  const proLicences = vendorLicencesOfUser.filter(
3632
- (licence) => licence.licenceType !== import_cluemart_shared28.EnumUserLicence.STANDARD_VENDOR
3987
+ (licence) => licence.licenceType !== import_cluemart_shared30.EnumUserLicence.STANDARD_VENDOR
3633
3988
  );
3634
3989
  const expiredProLicences = proLicences.filter(
3635
3990
  (licence) => !(0, import_dayjs4.default)(licence.expiryDate).isAfter(now)
@@ -3673,11 +4028,11 @@ async function handleVendorLicenceCompliance(user, now) {
3673
4028
  data: {
3674
4029
  resourceId: String(vendor._id),
3675
4030
  resourceName: vendor.name,
3676
- resourceType: import_cluemart_shared28.EnumNotificationResourceType.DOWNGRADED_VENDOR
4031
+ resourceType: import_cluemart_shared30.EnumNotificationResourceType.DOWNGRADED_VENDOR
3677
4032
  },
3678
4033
  message: `Your Vendor license has been downgraded due to licence expiration.`,
3679
4034
  title: `Vendor License Downgraded`,
3680
- type: import_cluemart_shared28.EnumNotificationType.SYSTEM,
4035
+ type: import_cluemart_shared30.EnumNotificationType.SYSTEM,
3681
4036
  userIds: [user._id]
3682
4037
  };
3683
4038
  await sendDeactivationNotification(payload, user._id, vendor.name, "vendor");
@@ -3691,12 +4046,26 @@ async function vendorOwnerHasProLicence(vendorId) {
3691
4046
  if (!vendor) {
3692
4047
  return false;
3693
4048
  }
3694
- 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
+ );
3695
4064
  const highestVendorLicence = getHighestLicenceForCategory(
3696
- owner?.licences,
4065
+ effectiveVendorLicences,
3697
4066
  "vendor" /* VENDOR */
3698
4067
  );
3699
- 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];
3700
4069
  }
3701
4070
 
3702
4071
  // src/service/license/compliance/utils.ts
@@ -3706,12 +4075,12 @@ async function syncUserLicencesAfterExpiry(userId, licenceTypes, now, mode = "do
3706
4075
  const pipeline = buildLicenceExpiryPipeline({
3707
4076
  downgradeBranches: [
3708
4077
  {
3709
- case: import_cluemart_shared29.EnumUserLicence.PRO_PLUS_VENDOR,
3710
- then: import_cluemart_shared29.EnumUserLicence.STANDARD_VENDOR
4078
+ case: import_cluemart_shared31.EnumUserLicence.PRO_PLUS_VENDOR,
4079
+ then: import_cluemart_shared31.EnumUserLicence.STANDARD_VENDOR
3711
4080
  },
3712
4081
  {
3713
- case: import_cluemart_shared29.EnumUserLicence.PRO_VENDOR,
3714
- then: import_cluemart_shared29.EnumUserLicence.STANDARD_VENDOR
4082
+ case: import_cluemart_shared31.EnumUserLicence.PRO_VENDOR,
4083
+ then: import_cluemart_shared31.EnumUserLicence.STANDARD_VENDOR
3715
4084
  }
3716
4085
  ],
3717
4086
  licenceTypes,
@@ -3840,7 +4209,7 @@ var REMINDER_WINDOW_MIN_HOURS = 6.5 * 24;
3840
4209
  var REMINDER_WINDOW_MAX_HOURS = 7.5 * 24;
3841
4210
 
3842
4211
  // src/service/license/reminder/utils.ts
3843
- var import_cluemart_shared30 = require("@timardex/cluemart-shared");
4212
+ var import_cluemart_shared32 = require("@timardex/cluemart-shared");
3844
4213
  var import_utils8 = require("@timardex/cluemart-shared/utils");
3845
4214
  var import_dayjs7 = __toESM(require("dayjs"));
3846
4215
 
@@ -3906,24 +4275,24 @@ function isLicenseExpiringIn7Days(expiryDate, now) {
3906
4275
  return hoursUntilExpiry >= REMINDER_WINDOW_MIN_HOURS && hoursUntilExpiry <= REMINDER_WINDOW_MAX_HOURS;
3907
4276
  }
3908
4277
  function getLicenseName(licenceType) {
3909
- return import_cluemart_shared30.licenseNiceNames[licenceType] || licenceType;
4278
+ return import_cluemart_shared32.licenseNiceNames[licenceType] || licenceType;
3910
4279
  }
3911
4280
  function getNotificationTypes(isVendorLicense, isPartnerLicense) {
3912
4281
  if (isVendorLicense) {
3913
4282
  return {
3914
- notificationType: import_cluemart_shared30.EnumNotificationType.SYSTEM,
3915
- resourceType: import_cluemart_shared30.EnumNotificationResourceType.EXPIRATION_REMINDER_VENDOR
4283
+ notificationType: import_cluemart_shared32.EnumNotificationType.SYSTEM,
4284
+ resourceType: import_cluemart_shared32.EnumNotificationResourceType.EXPIRATION_REMINDER_VENDOR
3916
4285
  };
3917
4286
  }
3918
4287
  if (isPartnerLicense) {
3919
4288
  return {
3920
- notificationType: import_cluemart_shared30.EnumNotificationType.SYSTEM,
3921
- resourceType: import_cluemart_shared30.EnumNotificationResourceType.EXPIRATION_REMINDER_PARTNER
4289
+ notificationType: import_cluemart_shared32.EnumNotificationType.SYSTEM,
4290
+ resourceType: import_cluemart_shared32.EnumNotificationResourceType.EXPIRATION_REMINDER_PARTNER
3922
4291
  };
3923
4292
  }
3924
4293
  return {
3925
- notificationType: import_cluemart_shared30.EnumNotificationType.SYSTEM,
3926
- resourceType: import_cluemart_shared30.EnumNotificationResourceType.EXPIRATION_REMINDER_EVENT
4294
+ notificationType: import_cluemart_shared32.EnumNotificationType.SYSTEM,
4295
+ resourceType: import_cluemart_shared32.EnumNotificationResourceType.EXPIRATION_REMINDER_EVENT
3927
4296
  };
3928
4297
  }
3929
4298
  async function getLicenseResourceInfo(user, licence) {
@@ -3975,11 +4344,11 @@ async function getLicenseResourceInfo(user, licence) {
3975
4344
  };
3976
4345
  }
3977
4346
  function getLicenceExpiryMode(licenceType) {
3978
- 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";
3979
4348
  }
3980
4349
  async function sendLicenseReminder(user, licence) {
3981
4350
  const licenceName = getLicenseName(licence.licenceType);
3982
- 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);
3983
4352
  const userId = String(user._id);
3984
4353
  const resourceInfo = await getLicenseResourceInfo(user, licence);
3985
4354
  if (!resourceInfo) {
@@ -4105,8 +4474,13 @@ async function remindUsersAboutLicenseExpiration() {
4105
4474
  // Annotate the CommonJS export names for ESM import in node:
4106
4475
  0 && (module.exports = {
4107
4476
  ACTIVE_NOT_DELETED_FILTER,
4477
+ AD_BILLING_CATALOG_COLLECTION_NAME,
4108
4478
  APP_SETTINGS_ID,
4479
+ AdBillingCatalogModel,
4480
+ AdBookingModel,
4481
+ AdImpressionModel,
4109
4482
  AdModel,
4483
+ AdSettingsModel,
4110
4484
  AffiliateModel,
4111
4485
  AppSettingModel,
4112
4486
  BILLING_CATALOG_COLLECTION_NAME,
@@ -4116,6 +4490,7 @@ async function remindUsersAboutLicenseExpiration() {
4116
4490
  ChatReportModel,
4117
4491
  ContactDetailsSchema,
4118
4492
  CouponModel,
4493
+ DEFAULT_AD_SETTINGS,
4119
4494
  EnumPubSubEvents,
4120
4495
  EventInfoModel,
4121
4496
  EventModel,
@@ -4200,6 +4575,7 @@ async function remindUsersAboutLicenseExpiration() {
4200
4575
  resourceRelationsSchema,
4201
4576
  restoreVendorProFeatures,
4202
4577
  saveNotificationsInDb,
4578
+ schemaAdresource,
4203
4579
  sendDeactivationNotification,
4204
4580
  sendLicenseReminder,
4205
4581
  sendPushNotifications,