@timardex/cluemart-server-shared 2.0.2 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -44,6 +44,7 @@ __export(service_exports, {
44
44
  convertObjectIdsToStrings: () => convertObjectIdsToStrings,
45
45
  createLicenceObject: () => createLicenceObject,
46
46
  didRemoveAnyEventDates: () => didRemoveAnyEventDates,
47
+ downgradeVendorProFeatures: () => downgradeVendorProFeatures,
47
48
  ensureUserLicenseCompliance: () => ensureUserLicenseCompliance,
48
49
  ensureUserLicenseComplianceForUser: () => ensureUserLicenseComplianceForUser,
49
50
  eventLicences: () => eventLicences,
@@ -78,6 +79,7 @@ __export(service_exports, {
78
79
  publishNotificationEvents: () => publishNotificationEvents,
79
80
  remindUsersAboutLicenseExpiration: () => remindUsersAboutLicenseExpiration,
80
81
  replaceUserLicenceWithObject: () => replaceUserLicenceWithObject,
82
+ restoreVendorProFeatures: () => restoreVendorProFeatures,
81
83
  saveNotificationsInDb: () => saveNotificationsInDb,
82
84
  sendDeactivationNotification: () => sendDeactivationNotification,
83
85
  sendLicenseReminder: () => sendLicenseReminder,
@@ -88,7 +90,6 @@ __export(service_exports, {
88
90
  updateAllEventDateTimeStatuses: () => updateAllEventDateTimeStatuses,
89
91
  updateRelationDatesToUnavailable: () => updateRelationDatesToUnavailable,
90
92
  updateSingleDateTimeStatus: () => updateSingleDateTimeStatus,
91
- updateVendorBasedOnUserLicense: () => updateVendorBasedOnUserLicense,
92
93
  upgradeUserToLicence: () => upgradeUserToLicence,
93
94
  vendorLicences: () => vendorLicences,
94
95
  vendorOwnerHasProLicence: () => vendorOwnerHasProLicence
@@ -128,9 +129,30 @@ var schemaAdresource = new MongooseSchema({
128
129
  var schema = new MongooseSchema(
129
130
  {
130
131
  active: { default: true, type: Boolean },
132
+ adminManaged: { default: false, type: Boolean },
133
+ approvalStatus: {
134
+ enum: Object.values(import_cluemart_shared.EnumAdApprovalStatus),
135
+ required: false,
136
+ type: String
137
+ },
138
+ bookingIds: {
139
+ default: void 0,
140
+ ref: "AdBooking",
141
+ type: [import_mongoose.default.Schema.Types.ObjectId]
142
+ },
143
+ bookingKind: {
144
+ enum: Object.values(import_cluemart_shared.EnumAdBookingSlotKind),
145
+ required: false,
146
+ type: String
147
+ },
131
148
  clicks: { default: 0, required: true, type: Number },
132
149
  end: { required: true, type: Date },
133
150
  impressions: { default: 0, required: true, type: Number },
151
+ paymentStatus: {
152
+ enum: Object.values(import_cluemart_shared.EnumAdPaymentStatus),
153
+ required: false,
154
+ type: String
155
+ },
134
156
  resource: { required: true, type: schemaAdresource },
135
157
  showOn: {
136
158
  default: [import_cluemart_shared.EnumAdShowOn.FRONT_PAGE],
@@ -162,20 +184,274 @@ schema.index({
162
184
  // eslint-disable-next-line sort-keys
163
185
  start: -1
164
186
  });
187
+ schema.index(
188
+ { bookingIds: 1 },
189
+ {
190
+ partialFilterExpression: { bookingIds: { $exists: true } },
191
+ unique: true
192
+ }
193
+ );
165
194
  var AdModel = import_mongoose.default.models.Ad || import_mongoose.default.model("Ad", schema);
166
195
 
167
- // src/mongoose/BillingCatalog.ts
168
- var import_cluemart_shared2 = require("@timardex/cluemart-shared");
196
+ // src/mongoose/AdBillingCatalog.ts
169
197
  var import_mongoose2 = __toESM(require("mongoose"));
170
- var MongooseSchema2 = import_mongoose2.default.Schema;
198
+ var AD_BILLING_CATALOG_COLLECTION_NAME = "adBillingCatalog";
199
+ var schema2 = new import_mongoose2.default.Schema(
200
+ {
201
+ active: { default: true, required: true, type: Boolean },
202
+ currency: {
203
+ default: "nzd",
204
+ enum: ["nzd"],
205
+ immutable: true,
206
+ required: true,
207
+ type: String
208
+ },
209
+ key: {
210
+ enum: ["front_page_day", "market_search_day"],
211
+ immutable: true,
212
+ required: true,
213
+ type: String,
214
+ unique: true
215
+ },
216
+ revision: { default: 1, min: 1, required: true, type: Number },
217
+ unitAmount: {
218
+ min: 1,
219
+ required: true,
220
+ type: Number,
221
+ validate: {
222
+ message: "Daily ad price must be a positive integer amount of cents.",
223
+ validator: Number.isInteger
224
+ }
225
+ }
226
+ },
227
+ { collection: AD_BILLING_CATALOG_COLLECTION_NAME, timestamps: true }
228
+ );
229
+ var AdBillingCatalogModel = import_mongoose2.default.models.AdBillingCatalog || import_mongoose2.default.model(
230
+ "AdBillingCatalog",
231
+ schema2,
232
+ AD_BILLING_CATALOG_COLLECTION_NAME
233
+ );
234
+
235
+ // src/mongoose/AdBooking.ts
236
+ var import_cluemart_shared2 = require("@timardex/cluemart-shared");
237
+ var import_mongoose3 = __toESM(require("mongoose"));
238
+ var liveStates = [
239
+ import_cluemart_shared2.EnumAdBookingState.HELD,
240
+ import_cluemart_shared2.EnumAdBookingState.PENDING_APPROVAL,
241
+ import_cluemart_shared2.EnumAdBookingState.APPROVED
242
+ ];
243
+ var placementValues = [import_cluemart_shared2.EnumAdShowOn.FRONT_PAGE, import_cluemart_shared2.EnumAdShowOn.MARKET_SEARCH];
244
+ var schema3 = new import_mongoose3.default.Schema(
245
+ {
246
+ adId: { default: null, ref: "Ad", type: String },
247
+ approvalStatus: {
248
+ default: import_cluemart_shared2.EnumAdApprovalStatus.PENDING,
249
+ enum: Object.values(import_cluemart_shared2.EnumAdApprovalStatus),
250
+ required: true,
251
+ type: String
252
+ },
253
+ checkoutAttemptId: { default: null, type: String },
254
+ currency: { default: null, lowercase: true, type: String },
255
+ dayKey: {
256
+ immutable: true,
257
+ match: /^\d{4}-\d{2}-\d{2}$/,
258
+ required: true,
259
+ type: String
260
+ },
261
+ entitlementClaimKey: { default: null, type: String },
262
+ entitlementSource: {
263
+ default: null,
264
+ enum: Object.values(import_cluemart_shared2.EnumAdEntitlementSource),
265
+ type: String
266
+ },
267
+ expiresAt: { default: null, type: Date },
268
+ placement: {
269
+ enum: placementValues,
270
+ immutable: true,
271
+ required: true,
272
+ type: String
273
+ },
274
+ purchaseKey: { default: null, immutable: true, type: String },
275
+ region: {
276
+ immutable: true,
277
+ lowercase: true,
278
+ required: true,
279
+ trim: true,
280
+ type: String
281
+ },
282
+ resource: { required: true, type: schemaAdresource },
283
+ slotKind: {
284
+ enum: Object.values(import_cluemart_shared2.EnumAdBookingSlotKind),
285
+ immutable: true,
286
+ required: true,
287
+ type: String
288
+ },
289
+ slotNumber: { immutable: true, min: 1, required: true, type: Number },
290
+ state: {
291
+ default: import_cluemart_shared2.EnumAdBookingState.HELD,
292
+ enum: Object.values(import_cluemart_shared2.EnumAdBookingState),
293
+ required: true,
294
+ type: String
295
+ },
296
+ stripeCheckoutSessionId: { default: null, type: String },
297
+ stripePaymentIntentId: { default: null, type: String },
298
+ unitAmount: { default: null, min: 1, type: Number },
299
+ userId: { immutable: true, ref: "User", required: true, type: String }
300
+ },
301
+ { timestamps: true }
302
+ );
303
+ schema3.pre(
304
+ "validate",
305
+ function validateSlot() {
306
+ if (!Number.isInteger(this.slotNumber)) {
307
+ this.invalidate("slotNumber", "Ad booking slot must be an integer.");
308
+ return;
309
+ }
310
+ const maximum = this.slotKind === import_cluemart_shared2.EnumAdBookingSlotKind.PAID ? 30 : 7;
311
+ if (this.slotNumber < 1 || this.slotNumber > maximum) {
312
+ this.invalidate(
313
+ "slotNumber",
314
+ `Ad booking slot must be between 1 and ${maximum}.`
315
+ );
316
+ }
317
+ 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)) {
318
+ this.invalidate(
319
+ "unitAmount",
320
+ "Paid ad booking must retain its checkout price."
321
+ );
322
+ }
323
+ }
324
+ );
325
+ schema3.index(
326
+ { region: 1, placement: 1, dayKey: 1, slotKind: 1, slotNumber: 1 },
327
+ { unique: true, partialFilterExpression: { state: { $in: liveStates } } }
328
+ );
329
+ schema3.index({ userId: 1, dayKey: -1 });
330
+ schema3.index(
331
+ { checkoutAttemptId: 1 },
332
+ {
333
+ partialFilterExpression: { checkoutAttemptId: { $type: "string" } },
334
+ unique: true
335
+ }
336
+ );
337
+ schema3.index(
338
+ { purchaseKey: 1 },
339
+ {
340
+ partialFilterExpression: {
341
+ purchaseKey: { $type: "string" },
342
+ state: { $in: liveStates }
343
+ },
344
+ unique: true
345
+ }
346
+ );
347
+ schema3.index(
348
+ { entitlementClaimKey: 1 },
349
+ {
350
+ partialFilterExpression: {
351
+ entitlementClaimKey: { $type: "string" },
352
+ state: { $in: liveStates }
353
+ },
354
+ unique: true
355
+ }
356
+ );
357
+ schema3.index(
358
+ { adId: 1, region: 1, placement: 1, dayKey: 1 },
359
+ {
360
+ partialFilterExpression: {
361
+ entitlementSource: import_cluemart_shared2.EnumAdEntitlementSource.ADMIN,
362
+ state: { $in: liveStates }
363
+ },
364
+ unique: true
365
+ }
366
+ );
367
+ schema3.index(
368
+ { stripeCheckoutSessionId: 1 },
369
+ {
370
+ partialFilterExpression: { stripeCheckoutSessionId: { $type: "string" } },
371
+ unique: true
372
+ }
373
+ );
374
+ var AdBookingModel = import_mongoose3.default.models.AdBooking || import_mongoose3.default.model("AdBooking", schema3);
375
+
376
+ // src/mongoose/AdImpression.ts
377
+ var import_cluemart_shared3 = require("@timardex/cluemart-shared");
378
+ var import_mongoose4 = __toESM(require("mongoose"));
379
+ var schema4 = new import_mongoose4.default.Schema(
380
+ {
381
+ _id: { required: true, type: String },
382
+ adId: { required: true, type: String },
383
+ dayKey: { match: /^\d{4}-\d{2}-\d{2}$/, required: true, type: String },
384
+ placement: {
385
+ enum: [import_cluemart_shared3.EnumAdShowOn.FRONT_PAGE, import_cluemart_shared3.EnumAdShowOn.MARKET_SEARCH],
386
+ required: true,
387
+ type: String
388
+ },
389
+ recordedAt: { default: Date.now, required: true, type: Date },
390
+ viewerSlotKey: { required: true, type: String }
391
+ },
392
+ { collection: "adImpressions" }
393
+ );
394
+ schema4.index({ adId: 1, recordedAt: 1 });
395
+ schema4.index({ adId: 1, placement: 1, viewerSlotKey: 1 }, { unique: true });
396
+ schema4.index({ recordedAt: 1 }, { expireAfterSeconds: 7 * 24 * 60 * 60 });
397
+ schema4.index({ dayKey: 1, placement: 1, adId: 1 });
398
+ var AdImpressionModel = import_mongoose4.default.models.AdImpression || import_mongoose4.default.model("AdImpression", schema4, "adImpressions");
399
+
400
+ // src/mongoose/AdSettings.ts
401
+ var import_mongoose5 = __toESM(require("mongoose"));
402
+ var schema5 = new import_mongoose5.default.Schema(
403
+ {
404
+ _id: { default: "default", enum: ["default"], type: String },
405
+ approvalRequired: { default: true, required: true, type: Boolean },
406
+ minAppearancesPerHour: {
407
+ default: 12,
408
+ min: 1,
409
+ required: true,
410
+ type: Number,
411
+ validate: {
412
+ message: "Minimum appearances per hour must be a whole number.",
413
+ validator: Number.isInteger
414
+ }
415
+ },
416
+ paidSlotsPerPlacement: {
417
+ default: 30,
418
+ enum: [30],
419
+ immutable: true,
420
+ type: Number
421
+ },
422
+ reservedSlotsPerPlacement: {
423
+ default: 7,
424
+ enum: [7],
425
+ immutable: true,
426
+ type: Number
427
+ },
428
+ rotationSeconds: { default: 8, enum: [8], immutable: true, type: Number }
429
+ },
430
+ { collection: "adSettings", timestamps: true }
431
+ );
432
+ schema5.pre("validate", function validateRotationCapacity() {
433
+ const availableRotationsPerHour = 3600 / this.rotationSeconds;
434
+ if (this.minAppearancesPerHour * (this.paidSlotsPerPlacement + this.reservedSlotsPerPlacement) > availableRotationsPerHour) {
435
+ this.invalidate(
436
+ "minAppearancesPerHour",
437
+ "The configured minimum exceeds the available rotation slots."
438
+ );
439
+ }
440
+ });
441
+ var AdSettingsModel = import_mongoose5.default.models.AdSettings || import_mongoose5.default.model("AdSettings", schema5, "adSettings");
442
+
443
+ // src/mongoose/BillingCatalog.ts
444
+ var import_cluemart_shared4 = require("@timardex/cluemart-shared");
445
+ var import_mongoose6 = __toESM(require("mongoose"));
446
+ var MongooseSchema2 = import_mongoose6.default.Schema;
171
447
  var BILLING_CATALOG_COLLECTION_NAME = "billingCatalog";
172
448
  var paidVendorLicences = [
173
- import_cluemart_shared2.EnumUserLicence.PRO_VENDOR,
174
- import_cluemart_shared2.EnumUserLicence.PRO_PLUS_VENDOR
449
+ import_cluemart_shared4.EnumUserLicence.PRO_VENDOR,
450
+ import_cluemart_shared4.EnumUserLicence.PRO_PLUS_VENDOR
175
451
  ];
176
452
  var supportedBillingPeriods = [
177
- import_cluemart_shared2.EnumBillingPeriod.MONTHLY_CANCEL_ANYTIME,
178
- import_cluemart_shared2.EnumBillingPeriod.YEARLY_ANNUAL_BILLED
453
+ import_cluemart_shared4.EnumBillingPeriod.MONTHLY_CANCEL_ANYTIME,
454
+ import_cluemart_shared4.EnumBillingPeriod.YEARLY_ANNUAL_BILLED
179
455
  ];
180
456
  var unitAmountField = {
181
457
  min: 1,
@@ -187,8 +463,8 @@ var unitAmountField = {
187
463
  }
188
464
  };
189
465
  var currencyField = {
190
- default: import_cluemart_shared2.BILLING_CATALOG_CURRENCY,
191
- enum: [import_cluemart_shared2.BILLING_CATALOG_CURRENCY],
466
+ default: import_cluemart_shared4.BILLING_CATALOG_CURRENCY,
467
+ enum: [import_cluemart_shared4.BILLING_CATALOG_CURRENCY],
192
468
  immutable: true,
193
469
  lowercase: true,
194
470
  required: true,
@@ -214,7 +490,7 @@ var priceHistorySchema = new MongooseSchema2(
214
490
  default: null,
215
491
  ref: "User",
216
492
  required: false,
217
- type: import_mongoose2.default.Schema.Types.ObjectId
493
+ type: import_mongoose6.default.Schema.Types.ObjectId
218
494
  },
219
495
  currency: currencyField,
220
496
  effectiveFrom: { required: true, type: Date },
@@ -225,7 +501,7 @@ var priceHistorySchema = new MongooseSchema2(
225
501
  },
226
502
  { _id: false }
227
503
  );
228
- var schema2 = new MongooseSchema2(
504
+ var schema6 = new MongooseSchema2(
229
505
  {
230
506
  active: { default: true, required: true, type: Boolean },
231
507
  billingPeriod: {
@@ -237,7 +513,7 @@ var schema2 = new MongooseSchema2(
237
513
  currency: currencyField,
238
514
  effectiveFrom: { default: Date.now, required: true, type: Date },
239
515
  key: {
240
- enum: import_cluemart_shared2.BILLING_CATALOG_KEYS,
516
+ enum: import_cluemart_shared4.BILLING_CATALOG_KEYS,
241
517
  immutable: true,
242
518
  required: true,
243
519
  type: String,
@@ -281,7 +557,7 @@ var schema2 = new MongooseSchema2(
281
557
  default: null,
282
558
  ref: "User",
283
559
  required: false,
284
- type: import_mongoose2.default.Schema.Types.ObjectId
560
+ type: import_mongoose6.default.Schema.Types.ObjectId
285
561
  }
286
562
  },
287
563
  {
@@ -290,40 +566,40 @@ var schema2 = new MongooseSchema2(
290
566
  timestamps: true
291
567
  }
292
568
  );
293
- schema2.pre("validate", function validateDefinition() {
294
- if (!(0, import_cluemart_shared2.billingCatalogDefinitionMatches)(this)) {
569
+ schema6.pre("validate", function validateDefinition() {
570
+ if (!(0, import_cluemart_shared4.billingCatalogDefinitionMatches)(this)) {
295
571
  this.invalidate(
296
572
  "key",
297
573
  "Billing catalogue key does not match its licence and billing period."
298
574
  );
299
575
  }
300
576
  });
301
- schema2.index({ billingPeriod: 1, licenceType: 1 }, { unique: true });
302
- schema2.index({ active: 1, licenceType: 1 });
303
- schema2.index(
577
+ schema6.index({ billingPeriod: 1, licenceType: 1 }, { unique: true });
578
+ schema6.index({ active: 1, licenceType: 1 });
579
+ schema6.index(
304
580
  { stripePriceId: 1 },
305
581
  {
306
582
  partialFilterExpression: { stripePriceId: { $type: "string" } },
307
583
  unique: true
308
584
  }
309
585
  );
310
- var BillingCatalogModel = import_mongoose2.default.models.BillingCatalogEntry || import_mongoose2.default.model(
586
+ var BillingCatalogModel = import_mongoose6.default.models.BillingCatalogEntry || import_mongoose6.default.model(
311
587
  "BillingCatalogEntry",
312
- schema2,
588
+ schema6,
313
589
  BILLING_CATALOG_COLLECTION_NAME
314
590
  );
315
591
 
316
592
  // src/mongoose/chat/Chat.ts
317
- var import_cluemart_shared3 = require("@timardex/cluemart-shared");
318
- var import_mongoose3 = __toESM(require("mongoose"));
319
- var MongooseSchema3 = import_mongoose3.default.Schema;
593
+ var import_cluemart_shared5 = require("@timardex/cluemart-shared");
594
+ var import_mongoose7 = __toESM(require("mongoose"));
595
+ var MongooseSchema3 = import_mongoose7.default.Schema;
320
596
  var MessageReplyPreviewSchema = new MongooseSchema3(
321
597
  {
322
598
  contentPreview: { required: true, type: String },
323
599
  senderId: {
324
600
  ref: "User",
325
601
  required: true,
326
- type: import_mongoose3.default.Schema.Types.ObjectId
602
+ type: import_mongoose7.default.Schema.Types.ObjectId
327
603
  },
328
604
  senderName: { required: true, type: String }
329
605
  },
@@ -335,7 +611,7 @@ var MessageReactionSchema = new MongooseSchema3(
335
611
  userId: {
336
612
  ref: "User",
337
613
  required: true,
338
- type: import_mongoose3.default.Schema.Types.ObjectId
614
+ type: import_mongoose7.default.Schema.Types.ObjectId
339
615
  }
340
616
  },
341
617
  { _id: false }
@@ -346,7 +622,7 @@ var MessageSeenSchema = new MongooseSchema3(
346
622
  userId: {
347
623
  ref: "User",
348
624
  required: true,
349
- type: import_mongoose3.default.Schema.Types.ObjectId
625
+ type: import_mongoose7.default.Schema.Types.ObjectId
350
626
  }
351
627
  },
352
628
  { _id: false }
@@ -362,13 +638,13 @@ var MessageSchema = new MongooseSchema3(
362
638
  replyToMessageId: {
363
639
  ref: "Chat.messages",
364
640
  required: false,
365
- type: import_mongoose3.default.Schema.Types.ObjectId
641
+ type: import_mongoose7.default.Schema.Types.ObjectId
366
642
  },
367
643
  seenBy: { default: [], required: false, type: [MessageSeenSchema] },
368
644
  senderId: {
369
645
  ref: "User",
370
646
  required: true,
371
- type: import_mongoose3.default.Schema.Types.ObjectId
647
+ type: import_mongoose7.default.Schema.Types.ObjectId
372
648
  }
373
649
  },
374
650
  { timestamps: true }
@@ -381,7 +657,7 @@ var ParticipantSchema = new MongooseSchema3(
381
657
  userId: {
382
658
  ref: "User",
383
659
  required: true,
384
- type: import_mongoose3.default.Schema.Types.ObjectId
660
+ type: import_mongoose7.default.Schema.Types.ObjectId
385
661
  },
386
662
  userName: { required: true, type: String }
387
663
  },
@@ -394,7 +670,7 @@ var ChatSchema = new MongooseSchema3(
394
670
  chatDescription: { required: false, type: String },
395
671
  chatName: { required: true, type: String },
396
672
  chatType: {
397
- enum: Object.values(import_cluemart_shared3.EnumChatType),
673
+ enum: Object.values(import_cluemart_shared5.EnumChatType),
398
674
  required: true,
399
675
  type: String
400
676
  },
@@ -412,17 +688,17 @@ ChatSchema.index({
412
688
  "participants.userId": 1,
413
689
  updatedAt: -1
414
690
  });
415
- var ChatModel = import_mongoose3.default.models.Chat || import_mongoose3.default.model("Chat", ChatSchema);
691
+ var ChatModel = import_mongoose7.default.models.Chat || import_mongoose7.default.model("Chat", ChatSchema);
416
692
 
417
693
  // src/mongoose/chat/ChatReport.ts
418
- var import_cluemart_shared4 = require("@timardex/cluemart-shared");
419
- var import_mongoose4 = __toESM(require("mongoose"));
420
- var MongooseSchema4 = import_mongoose4.default.Schema;
694
+ var import_cluemart_shared6 = require("@timardex/cluemart-shared");
695
+ var import_mongoose8 = __toESM(require("mongoose"));
696
+ var MongooseSchema4 = import_mongoose8.default.Schema;
421
697
  var ReasonSchema = new MongooseSchema4(
422
698
  {
423
699
  details: { default: null, required: false, type: String },
424
700
  reasonType: {
425
- enum: Object.values(import_cluemart_shared4.EnumChatReportReason),
701
+ enum: Object.values(import_cluemart_shared6.EnumChatReportReason),
426
702
  required: true,
427
703
  type: String
428
704
  }
@@ -434,18 +710,18 @@ var ChatReportSchema = new MongooseSchema4(
434
710
  chatId: {
435
711
  ref: "Chat",
436
712
  required: true,
437
- type: import_mongoose4.default.Schema.Types.ObjectId
713
+ type: import_mongoose8.default.Schema.Types.ObjectId
438
714
  },
439
715
  reason: { required: true, type: ReasonSchema },
440
716
  reportedUserId: {
441
717
  ref: "User",
442
718
  required: true,
443
- type: import_mongoose4.default.Schema.Types.ObjectId
719
+ type: import_mongoose8.default.Schema.Types.ObjectId
444
720
  },
445
721
  reporterUserId: {
446
722
  ref: "User",
447
723
  required: true,
448
- type: import_mongoose4.default.Schema.Types.ObjectId
724
+ type: import_mongoose8.default.Schema.Types.ObjectId
449
725
  },
450
726
  resolved: { default: false, required: true, type: Boolean }
451
727
  },
@@ -453,20 +729,20 @@ var ChatReportSchema = new MongooseSchema4(
453
729
  );
454
730
  ChatReportSchema.index({ chatId: 1, reportedUserId: 1 });
455
731
  ChatReportSchema.index({ createdAt: -1, reporterUserId: 1 });
456
- var ChatReportModel = import_mongoose4.default.models.ChatReport || import_mongoose4.default.model("ChatReport", ChatReportSchema);
732
+ var ChatReportModel = import_mongoose8.default.models.ChatReport || import_mongoose8.default.model("ChatReport", ChatReportSchema);
457
733
 
458
734
  // src/mongoose/global.ts
459
- var import_cluemart_shared7 = require("@timardex/cluemart-shared");
460
- var import_mongoose7 = __toESM(require("mongoose"));
735
+ var import_cluemart_shared9 = require("@timardex/cluemart-shared");
736
+ var import_mongoose11 = __toESM(require("mongoose"));
461
737
 
462
738
  // src/mongoose/Relation.ts
463
- var import_cluemart_shared6 = require("@timardex/cluemart-shared");
464
- var import_mongoose6 = __toESM(require("mongoose"));
739
+ var import_cluemart_shared8 = require("@timardex/cluemart-shared");
740
+ var import_mongoose10 = __toESM(require("mongoose"));
465
741
 
466
742
  // src/mongoose/event/EventInfo.ts
467
- var import_cluemart_shared5 = require("@timardex/cluemart-shared");
468
- var import_mongoose5 = __toESM(require("mongoose"));
469
- var MongooseSchema5 = import_mongoose5.default.Schema;
743
+ var import_cluemart_shared7 = require("@timardex/cluemart-shared");
744
+ var import_mongoose9 = __toESM(require("mongoose"));
745
+ var MongooseSchema5 = import_mongoose9.default.Schema;
470
746
  var StallTypeSchema = new MongooseSchema5(
471
747
  {
472
748
  label: { required: false, type: String },
@@ -481,7 +757,7 @@ var StallTypeSchema = new MongooseSchema5(
481
757
  var dateTimeSchema = new MongooseSchema5(
482
758
  {
483
759
  dateStatus: {
484
- enum: Object.values(import_cluemart_shared5.EnumEventDateStatus),
760
+ enum: Object.values(import_cluemart_shared7.EnumEventDateStatus),
485
761
  required: false,
486
762
  type: String
487
763
  },
@@ -500,7 +776,7 @@ var paymentInfoSchema = new MongooseSchema5(
500
776
  accountNumber: { required: false, type: String },
501
777
  link: { required: false, type: String },
502
778
  paymentMethod: {
503
- enum: Object.values(import_cluemart_shared5.EnumPaymentMethod),
779
+ enum: Object.values(import_cluemart_shared7.EnumPaymentMethod),
504
780
  required: true,
505
781
  type: String
506
782
  }
@@ -527,7 +803,7 @@ var refundPolicySchema = new MongooseSchema5(
527
803
  },
528
804
  { _id: false }
529
805
  );
530
- var schema3 = new MongooseSchema5(
806
+ var schema7 = new MongooseSchema5(
531
807
  {
532
808
  active: { default: true, type: Boolean },
533
809
  applicationDeadlineHours: { required: true, type: Number },
@@ -535,7 +811,7 @@ var schema3 = new MongooseSchema5(
535
811
  eventId: {
536
812
  ref: "Event",
537
813
  required: true,
538
- type: import_mongoose5.default.Schema.Types.ObjectId
814
+ type: import_mongoose9.default.Schema.Types.ObjectId
539
815
  },
540
816
  packInTime: { required: true, type: Number },
541
817
  paymentDueHours: { required: true, type: Number },
@@ -545,15 +821,15 @@ var schema3 = new MongooseSchema5(
545
821
  },
546
822
  { timestamps: true }
547
823
  );
548
- schema3.index({ eventId: 1 });
549
- var EventInfoModel = import_mongoose5.default.models.EventInfo || import_mongoose5.default.model("EventInfo", schema3);
824
+ schema7.index({ eventId: 1 });
825
+ var EventInfoModel = import_mongoose9.default.models.EventInfo || import_mongoose9.default.model("EventInfo", schema7);
550
826
 
551
827
  // src/mongoose/Relation.ts
552
- var MongooseSchema6 = import_mongoose6.default.Schema;
828
+ var MongooseSchema6 = import_mongoose10.default.Schema;
553
829
  var relationDateTimeSchema = new MongooseSchema6(
554
830
  {
555
831
  dateStatus: {
556
- enum: Object.values(import_cluemart_shared6.EnumEventDateStatus),
832
+ enum: Object.values(import_cluemart_shared8.EnumEventDateStatus),
557
833
  required: true,
558
834
  type: String
559
835
  },
@@ -577,7 +853,7 @@ var relationDatesSchema = new MongooseSchema6(
577
853
  },
578
854
  paymentReference: { required: false, type: String },
579
855
  status: {
580
- enum: Object.values(import_cluemart_shared6.EnumInviteStatus),
856
+ enum: Object.values(import_cluemart_shared8.EnumInviteStatus),
581
857
  required: false,
582
858
  type: String
583
859
  }
@@ -590,29 +866,29 @@ var RelationTypeSchema = new MongooseSchema6(
590
866
  chatId: {
591
867
  ref: "Chat",
592
868
  required: true,
593
- type: import_mongoose6.default.Schema.Types.ObjectId
869
+ type: import_mongoose10.default.Schema.Types.ObjectId
594
870
  },
595
871
  deletedAt: { default: null, required: false, type: Date },
596
872
  eventId: {
597
873
  ref: "Event",
598
874
  required: true,
599
- type: import_mongoose6.default.Schema.Types.ObjectId
875
+ type: import_mongoose10.default.Schema.Types.ObjectId
600
876
  },
601
877
  lastUpdateBy: {
602
- enum: Object.values(import_cluemart_shared6.EnumResourceType),
878
+ enum: Object.values(import_cluemart_shared8.EnumResourceType),
603
879
  required: true,
604
880
  type: String
605
881
  },
606
882
  relationDates: [relationDatesSchema],
607
883
  relationType: {
608
- enum: Object.values(import_cluemart_shared6.EnumRelationResource),
884
+ enum: Object.values(import_cluemart_shared8.EnumRelationResource),
609
885
  required: true,
610
886
  type: String
611
887
  },
612
888
  vendorId: {
613
889
  ref: "Vendor",
614
890
  required: true,
615
- type: import_mongoose6.default.Schema.Types.ObjectId
891
+ type: import_mongoose10.default.Schema.Types.ObjectId
616
892
  }
617
893
  },
618
894
  { timestamps: true }
@@ -624,17 +900,17 @@ RelationTypeSchema.index({
624
900
  "relationDates.status": 1,
625
901
  vendorId: 1
626
902
  });
627
- var RelationModel = import_mongoose6.default.models.Relation || import_mongoose6.default.model("Relation", RelationTypeSchema);
903
+ var RelationModel = import_mongoose10.default.models.Relation || import_mongoose10.default.model("Relation", RelationTypeSchema);
628
904
 
629
905
  // src/mongoose/global.ts
630
- var MongooseSchema7 = import_mongoose7.default.Schema;
906
+ var MongooseSchema7 = import_mongoose11.default.Schema;
631
907
  var OwnerTypeSchema = new MongooseSchema7(
632
908
  {
633
909
  email: { required: true, type: String },
634
910
  userId: {
635
911
  ref: "User",
636
912
  required: true,
637
- type: import_mongoose7.default.Schema.Types.ObjectId
913
+ type: import_mongoose11.default.Schema.Types.ObjectId
638
914
  }
639
915
  },
640
916
  { _id: false }
@@ -693,12 +969,12 @@ var userLicenseSchema = new MongooseSchema7(
693
969
  expiryDate: { required: true, type: Date },
694
970
  issuedDate: { required: true, type: Date },
695
971
  licenceType: {
696
- enum: Object.values(import_cluemart_shared7.EnumUserLicence),
972
+ enum: Object.values(import_cluemart_shared9.EnumUserLicence),
697
973
  required: true,
698
974
  type: String
699
975
  },
700
976
  prevLicenceType: {
701
- enum: Object.values(import_cluemart_shared7.EnumUserLicence),
977
+ enum: Object.values(import_cluemart_shared9.EnumUserLicence),
702
978
  required: false,
703
979
  type: String
704
980
  }
@@ -741,7 +1017,7 @@ var resourceRelationsSchema = new MongooseSchema7(
741
1017
  relationId: {
742
1018
  ref: "Relation",
743
1019
  required: false,
744
- type: import_mongoose7.default.Schema.Types.ObjectId
1020
+ type: import_mongoose11.default.Schema.Types.ObjectId
745
1021
  }
746
1022
  },
747
1023
  { _id: false }
@@ -749,7 +1025,7 @@ var resourceRelationsSchema = new MongooseSchema7(
749
1025
  var dateTimeSchema2 = new MongooseSchema7(
750
1026
  {
751
1027
  dateStatus: {
752
- enum: Object.values(import_cluemart_shared7.EnumEventDateStatus),
1028
+ enum: Object.values(import_cluemart_shared9.EnumEventDateStatus),
753
1029
  required: false,
754
1030
  type: String
755
1031
  },
@@ -792,11 +1068,11 @@ var relatedPostSchema = new MongooseSchema7(
792
1068
  postId: {
793
1069
  ref: "Post",
794
1070
  required: true,
795
- type: import_mongoose7.default.Schema.Types.ObjectId
1071
+ type: import_mongoose11.default.Schema.Types.ObjectId
796
1072
  },
797
1073
  postSlug: { required: true, type: String },
798
1074
  postType: {
799
- enum: Object.values(import_cluemart_shared7.EnumPostType),
1075
+ enum: Object.values(import_cluemart_shared9.EnumPostType),
800
1076
  required: true,
801
1077
  type: String
802
1078
  }
@@ -817,7 +1093,7 @@ var baseResourceFields = {
817
1093
  adIds: {
818
1094
  ref: "Ad",
819
1095
  required: false,
820
- type: [import_mongoose7.default.Schema.Types.ObjectId]
1096
+ type: [import_mongoose11.default.Schema.Types.ObjectId]
821
1097
  },
822
1098
  approvedAt: { default: null, required: false, type: Date },
823
1099
  contactDetails: { required: false, type: ContactDetailsSchema },
@@ -847,8 +1123,8 @@ var baseResourceFields = {
847
1123
  };
848
1124
 
849
1125
  // src/mongoose/GoogleImportedMarket.ts
850
- var import_cluemart_shared8 = require("@timardex/cluemart-shared");
851
- var import_mongoose8 = __toESM(require("mongoose"));
1126
+ var import_cluemart_shared10 = require("@timardex/cluemart-shared");
1127
+ var import_mongoose12 = __toESM(require("mongoose"));
852
1128
 
853
1129
  // src/mongoose/searchNamePlugin.ts
854
1130
  function deriveSearchName(name) {
@@ -894,15 +1170,15 @@ function syncSearchNameInUpdate(update) {
894
1170
  }
895
1171
  return null;
896
1172
  }
897
- function searchNamePlugin(schema20) {
898
- schema20.add({ searchName: { default: "", required: false, type: String } });
899
- schema20.index({ searchName: 1 });
900
- schema20.pre("save", function syncSearchNameOnSave(next) {
1173
+ function searchNamePlugin(schema24) {
1174
+ schema24.add({ searchName: { default: "", required: false, type: String } });
1175
+ schema24.index({ searchName: 1 });
1176
+ schema24.pre("save", function syncSearchNameOnSave(next) {
901
1177
  const doc = this;
902
1178
  doc.searchName = deriveSearchName(doc.name);
903
1179
  next();
904
1180
  });
905
- schema20.pre("insertMany", function syncSearchNameOnInsertMany(next, docs) {
1181
+ schema24.pre("insertMany", function syncSearchNameOnInsertMany(next, docs) {
906
1182
  const list = Array.isArray(docs) ? docs : [docs];
907
1183
  for (const doc of list) {
908
1184
  if (doc && typeof doc.name === "string") {
@@ -911,7 +1187,7 @@ function searchNamePlugin(schema20) {
911
1187
  }
912
1188
  next();
913
1189
  });
914
- schema20.pre("bulkWrite", function syncSearchNameOnBulkWrite(next, ops) {
1190
+ schema24.pre("bulkWrite", function syncSearchNameOnBulkWrite(next, ops) {
915
1191
  for (const op of ops) {
916
1192
  const doc = op.insertOne?.document ?? op.replaceOne?.replacement;
917
1193
  if (doc && typeof doc.name === "string") {
@@ -937,14 +1213,14 @@ function searchNamePlugin(schema20) {
937
1213
  }
938
1214
  next();
939
1215
  };
940
- schema20.pre(
1216
+ schema24.pre(
941
1217
  ["findOneAndUpdate", "updateOne", "updateMany"],
942
1218
  syncSearchNameOnUpdate
943
1219
  );
944
1220
  }
945
1221
 
946
1222
  // src/mongoose/GoogleImportedMarket.ts
947
- var MongooseSchema8 = import_mongoose8.default.Schema;
1223
+ var MongooseSchema8 = import_mongoose12.default.Schema;
948
1224
  var addressComponentSchema = new MongooseSchema8(
949
1225
  {
950
1226
  longName: { required: false, type: String },
@@ -953,7 +1229,7 @@ var addressComponentSchema = new MongooseSchema8(
953
1229
  },
954
1230
  { _id: false }
955
1231
  );
956
- var schema4 = new MongooseSchema8(
1232
+ var schema8 = new MongooseSchema8(
957
1233
  {
958
1234
  active: { default: false, required: true, type: Boolean },
959
1235
  address: { required: true, type: String },
@@ -965,7 +1241,7 @@ var schema4 = new MongooseSchema8(
965
1241
  claimedByUserId: {
966
1242
  ref: "User",
967
1243
  required: false,
968
- type: import_mongoose8.default.Schema.Types.ObjectId
1244
+ type: import_mongoose12.default.Schema.Types.ObjectId
969
1245
  },
970
1246
  cover: {
971
1247
  required: false,
@@ -977,10 +1253,10 @@ var schema4 = new MongooseSchema8(
977
1253
  eventId: {
978
1254
  ref: "Event",
979
1255
  required: false,
980
- type: import_mongoose8.default.Schema.Types.ObjectId
1256
+ type: import_mongoose12.default.Schema.Types.ObjectId
981
1257
  },
982
1258
  eventType: {
983
- enum: Object.values(import_cluemart_shared8.EnumEventType),
1259
+ enum: Object.values(import_cluemart_shared10.EnumEventType),
984
1260
  required: true,
985
1261
  type: String
986
1262
  },
@@ -1016,27 +1292,27 @@ var schema4 = new MongooseSchema8(
1016
1292
  },
1017
1293
  { timestamps: true }
1018
1294
  );
1019
- schema4.index({ "location.geo": "2dsphere" });
1020
- schema4.index({ name: 1 });
1021
- schema4.index({ region: 1 });
1022
- schema4.index({ deletedAt: 1 });
1023
- schema4.index({ "dateTime.dateStatus": 1 });
1024
- schema4.index({ slug: 1 });
1025
- schema4.index({ name: "text", description: "text" });
1026
- schema4.plugin(searchNamePlugin);
1027
- var GoogleImportedMarketModel = import_mongoose8.default.models.GoogleImportedMarket || import_mongoose8.default.model("GoogleImportedMarket", schema4);
1295
+ schema8.index({ "location.geo": "2dsphere" });
1296
+ schema8.index({ name: 1 });
1297
+ schema8.index({ region: 1 });
1298
+ schema8.index({ deletedAt: 1 });
1299
+ schema8.index({ "dateTime.dateStatus": 1 });
1300
+ schema8.index({ slug: 1 });
1301
+ schema8.index({ name: "text", description: "text" });
1302
+ schema8.plugin(searchNamePlugin);
1303
+ var GoogleImportedMarketModel = import_mongoose12.default.models.GoogleImportedMarket || import_mongoose12.default.model("GoogleImportedMarket", schema8);
1028
1304
 
1029
1305
  // src/mongoose/Notification.ts
1030
- var import_cluemart_shared9 = require("@timardex/cluemart-shared");
1031
- var import_mongoose9 = __toESM(require("mongoose"));
1032
- var MongooseSchema9 = import_mongoose9.default.Schema;
1033
- var schema5 = new MongooseSchema9(
1306
+ var import_cluemart_shared11 = require("@timardex/cluemart-shared");
1307
+ var import_mongoose13 = __toESM(require("mongoose"));
1308
+ var MongooseSchema9 = import_mongoose13.default.Schema;
1309
+ var schema9 = new MongooseSchema9(
1034
1310
  {
1035
1311
  data: {
1036
1312
  resourceId: { required: true, type: String },
1037
1313
  resourceName: { required: true, type: String },
1038
1314
  resourceType: {
1039
- enum: Object.values(import_cluemart_shared9.EnumNotificationResourceType),
1315
+ enum: Object.values(import_cluemart_shared11.EnumNotificationResourceType),
1040
1316
  required: true,
1041
1317
  type: String
1042
1318
  }
@@ -1045,28 +1321,28 @@ var schema5 = new MongooseSchema9(
1045
1321
  message: { required: true, type: String },
1046
1322
  title: { required: true, type: String },
1047
1323
  type: {
1048
- default: import_cluemart_shared9.EnumNotificationType.SYSTEM,
1049
- enum: Object.values(import_cluemart_shared9.EnumNotificationType),
1324
+ default: import_cluemart_shared11.EnumNotificationType.SYSTEM,
1325
+ enum: Object.values(import_cluemart_shared11.EnumNotificationType),
1050
1326
  required: true,
1051
1327
  type: String
1052
1328
  },
1053
1329
  userId: {
1054
1330
  ref: "User",
1055
1331
  required: true,
1056
- type: import_mongoose9.default.Schema.Types.ObjectId
1332
+ type: import_mongoose13.default.Schema.Types.ObjectId
1057
1333
  }
1058
1334
  },
1059
1335
  { timestamps: true }
1060
1336
  );
1061
- schema5.index({ isRead: 1, userId: 1 });
1062
- schema5.index({ createdAt: -1, userId: 1 });
1063
- var NotificationModel = import_mongoose9.default.models.Notification || import_mongoose9.default.model("Notification", schema5);
1337
+ schema9.index({ isRead: 1, userId: 1 });
1338
+ schema9.index({ createdAt: -1, userId: 1 });
1339
+ var NotificationModel = import_mongoose13.default.models.Notification || import_mongoose13.default.model("Notification", schema9);
1064
1340
 
1065
1341
  // src/mongoose/PushToken.ts
1066
1342
  var import_enums = require("@timardex/cluemart-shared/enums");
1067
- var import_mongoose10 = __toESM(require("mongoose"));
1068
- var MongooseSchema10 = import_mongoose10.default.Schema;
1069
- var schema6 = new MongooseSchema10(
1343
+ var import_mongoose14 = __toESM(require("mongoose"));
1344
+ var MongooseSchema10 = import_mongoose14.default.Schema;
1345
+ var schema10 = new MongooseSchema10(
1070
1346
  {
1071
1347
  platform: {
1072
1348
  enum: Object.values(import_enums.EnumOSPlatform),
@@ -1077,26 +1353,26 @@ var schema6 = new MongooseSchema10(
1077
1353
  userId: {
1078
1354
  ref: "User",
1079
1355
  required: true,
1080
- type: import_mongoose10.default.Schema.Types.ObjectId
1356
+ type: import_mongoose14.default.Schema.Types.ObjectId
1081
1357
  }
1082
1358
  },
1083
1359
  { timestamps: true }
1084
1360
  );
1085
- var PushTokenModel = import_mongoose10.default.models.PushToken || import_mongoose10.default.model("PushToken", schema6);
1361
+ var PushTokenModel = import_mongoose14.default.models.PushToken || import_mongoose14.default.model("PushToken", schema10);
1086
1362
 
1087
1363
  // src/mongoose/ResourceActivity.ts
1088
- var import_cluemart_shared10 = require("@timardex/cluemart-shared");
1089
- var import_mongoose11 = __toESM(require("mongoose"));
1090
- var MongooseSchema11 = import_mongoose11.default.Schema;
1364
+ var import_cluemart_shared12 = require("@timardex/cluemart-shared");
1365
+ var import_mongoose15 = __toESM(require("mongoose"));
1366
+ var MongooseSchema11 = import_mongoose15.default.Schema;
1091
1367
  var ActivitySchema = new MongooseSchema11(
1092
1368
  {
1093
1369
  activityType: {
1094
- enum: Object.values(import_cluemart_shared10.EnumActivity),
1370
+ enum: Object.values(import_cluemart_shared12.EnumActivity),
1095
1371
  required: true,
1096
1372
  type: String
1097
1373
  },
1098
1374
  dateStatus: {
1099
- enum: Object.values(import_cluemart_shared10.EnumEventDateStatus),
1375
+ enum: Object.values(import_cluemart_shared12.EnumEventDateStatus),
1100
1376
  required: false,
1101
1377
  type: String
1102
1378
  },
@@ -1108,7 +1384,7 @@ var ActivitySchema = new MongooseSchema11(
1108
1384
  startTime: { required: false, type: String },
1109
1385
  timestamp: { default: Date.now, type: Date },
1110
1386
  userAgent: {
1111
- enum: Object.values(import_cluemart_shared10.EnumOSPlatform),
1387
+ enum: Object.values(import_cluemart_shared12.EnumOSPlatform),
1112
1388
  required: true,
1113
1389
  type: String
1114
1390
  },
@@ -1116,33 +1392,33 @@ var ActivitySchema = new MongooseSchema11(
1116
1392
  },
1117
1393
  { _id: false }
1118
1394
  );
1119
- var schema7 = new MongooseSchema11(
1395
+ var schema11 = new MongooseSchema11(
1120
1396
  {
1121
1397
  activity: { default: [], type: [ActivitySchema] },
1122
1398
  resourceId: { required: true, type: String },
1123
1399
  resourceType: {
1124
- enum: Object.values(import_cluemart_shared10.EnumResourceType),
1400
+ enum: Object.values(import_cluemart_shared12.EnumResourceType),
1125
1401
  required: true,
1126
1402
  type: String
1127
1403
  }
1128
1404
  },
1129
1405
  { timestamps: true }
1130
1406
  );
1131
- schema7.index({ resourceId: 1, resourceType: 1 }, { unique: true });
1132
- schema7.index({ "views.location": "2dsphere" });
1133
- var ResourceActivityModel = import_mongoose11.default.models.ResourceActivity || import_mongoose11.default.model("ResourceActivity", schema7);
1407
+ schema11.index({ resourceId: 1, resourceType: 1 }, { unique: true });
1408
+ schema11.index({ "views.location": "2dsphere" });
1409
+ var ResourceActivityModel = import_mongoose15.default.models.ResourceActivity || import_mongoose15.default.model("ResourceActivity", schema11);
1134
1410
 
1135
1411
  // src/mongoose/User.ts
1136
- var import_cluemart_shared11 = require("@timardex/cluemart-shared");
1137
- var import_mongoose12 = __toESM(require("mongoose"));
1138
- var MongooseSchema12 = import_mongoose12.default.Schema;
1412
+ var import_cluemart_shared13 = require("@timardex/cluemart-shared");
1413
+ var import_mongoose16 = __toESM(require("mongoose"));
1414
+ var MongooseSchema12 = import_mongoose16.default.Schema;
1139
1415
  var userActivityEventSchema = new MongooseSchema12(
1140
1416
  {
1141
1417
  dateTime: dateTimeSchema2,
1142
1418
  resourceId: {
1143
1419
  ref: "Event",
1144
1420
  required: false,
1145
- type: import_mongoose12.default.Schema.Types.ObjectId
1421
+ type: import_mongoose16.default.Schema.Types.ObjectId
1146
1422
  }
1147
1423
  },
1148
1424
  { _id: false }
@@ -1152,17 +1428,17 @@ var userActivityFavouritesSchema = new MongooseSchema12(
1152
1428
  events: {
1153
1429
  ref: "Event",
1154
1430
  required: false,
1155
- type: [import_mongoose12.default.Schema.Types.ObjectId]
1431
+ type: [import_mongoose16.default.Schema.Types.ObjectId]
1156
1432
  },
1157
1433
  partners: {
1158
1434
  ref: "Partner",
1159
1435
  required: false,
1160
- type: [import_mongoose12.default.Schema.Types.ObjectId]
1436
+ type: [import_mongoose16.default.Schema.Types.ObjectId]
1161
1437
  },
1162
1438
  vendors: {
1163
1439
  ref: "Vendor",
1164
1440
  required: false,
1165
- type: [import_mongoose12.default.Schema.Types.ObjectId]
1441
+ type: [import_mongoose16.default.Schema.Types.ObjectId]
1166
1442
  }
1167
1443
  },
1168
1444
  { _id: false }
@@ -1170,7 +1446,7 @@ var userActivityFavouritesSchema = new MongooseSchema12(
1170
1446
  var stripeSchema = new MongooseSchema12(
1171
1447
  {
1172
1448
  billingPeriod: {
1173
- enum: Object.values(import_cluemart_shared11.EnumBillingPeriod),
1449
+ enum: Object.values(import_cluemart_shared13.EnumBillingPeriod),
1174
1450
  required: false,
1175
1451
  type: String
1176
1452
  },
@@ -1179,7 +1455,7 @@ var stripeSchema = new MongooseSchema12(
1179
1455
  type: Boolean
1180
1456
  },
1181
1457
  currentPlan: {
1182
- enum: Object.values(import_cluemart_shared11.EnumUserLicence),
1458
+ enum: Object.values(import_cluemart_shared13.EnumUserLicence),
1183
1459
  required: false,
1184
1460
  type: String
1185
1461
  },
@@ -1191,8 +1467,20 @@ var stripeSchema = new MongooseSchema12(
1191
1467
  required: false,
1192
1468
  type: Date
1193
1469
  },
1470
+ paymentFailedAt: {
1471
+ required: false,
1472
+ type: Date
1473
+ },
1474
+ paymentGracePeriodEndsAt: {
1475
+ required: false,
1476
+ type: Date
1477
+ },
1478
+ paymentGraceSubscriptionId: {
1479
+ required: false,
1480
+ type: String
1481
+ },
1194
1482
  pendingBillingPeriod: {
1195
- enum: Object.values(import_cluemart_shared11.EnumBillingPeriod),
1483
+ enum: Object.values(import_cluemart_shared13.EnumBillingPeriod),
1196
1484
  required: false,
1197
1485
  type: String
1198
1486
  },
@@ -1201,7 +1489,7 @@ var stripeSchema = new MongooseSchema12(
1201
1489
  type: Date
1202
1490
  },
1203
1491
  pendingPlan: {
1204
- enum: Object.values(import_cluemart_shared11.EnumUserLicence),
1492
+ enum: Object.values(import_cluemart_shared13.EnumUserLicence),
1205
1493
  required: false,
1206
1494
  type: String
1207
1495
  },
@@ -1218,7 +1506,7 @@ var stripeSchema = new MongooseSchema12(
1218
1506
  type: Date
1219
1507
  },
1220
1508
  status: {
1221
- enum: Object.values(import_cluemart_shared11.EnumSubscriptionStatus),
1509
+ enum: Object.values(import_cluemart_shared13.EnumSubscriptionStatus),
1222
1510
  required: false,
1223
1511
  type: String
1224
1512
  },
@@ -1240,7 +1528,7 @@ var stripeSchema = new MongooseSchema12(
1240
1528
  var redeemedRewardSchema = new MongooseSchema12(
1241
1529
  {
1242
1530
  name: {
1243
- enum: Object.values(import_cluemart_shared11.EnumReward),
1531
+ enum: Object.values(import_cluemart_shared13.EnumReward),
1244
1532
  required: true,
1245
1533
  type: String
1246
1534
  },
@@ -1249,13 +1537,13 @@ var redeemedRewardSchema = new MongooseSchema12(
1249
1537
  },
1250
1538
  { _id: false }
1251
1539
  );
1252
- var schema8 = new MongooseSchema12(
1540
+ var schema12 = new MongooseSchema12(
1253
1541
  {
1254
1542
  active: { default: false, required: true, type: Boolean },
1255
1543
  affiliate: {
1256
1544
  ref: "Affiliate",
1257
1545
  required: false,
1258
- type: import_mongoose12.default.Schema.Types.ObjectId
1546
+ type: import_mongoose16.default.Schema.Types.ObjectId
1259
1547
  },
1260
1548
  avatar: {
1261
1549
  required: false,
@@ -1264,28 +1552,28 @@ var schema8 = new MongooseSchema12(
1264
1552
  coupon: {
1265
1553
  ref: "Coupon",
1266
1554
  required: false,
1267
- type: import_mongoose12.default.Schema.Types.ObjectId
1555
+ type: import_mongoose16.default.Schema.Types.ObjectId
1268
1556
  },
1269
1557
  deletedAt: { default: null, required: false, type: Date },
1270
1558
  email: { required: true, type: String },
1271
1559
  emailSentFor: {
1272
- enum: Object.values(import_cluemart_shared11.EnumNotificationResourceType),
1560
+ enum: Object.values(import_cluemart_shared13.EnumNotificationResourceType),
1273
1561
  required: false,
1274
1562
  type: [String]
1275
1563
  },
1276
1564
  events: {
1277
1565
  ref: "Event",
1278
1566
  required: false,
1279
- type: [import_mongoose12.default.Schema.Types.ObjectId]
1567
+ type: [import_mongoose16.default.Schema.Types.ObjectId]
1280
1568
  },
1281
1569
  firstName: { required: true, type: String },
1282
1570
  game: {
1283
1571
  ref: "Game",
1284
1572
  required: false,
1285
- type: import_mongoose12.default.Schema.Types.ObjectId
1573
+ type: import_mongoose16.default.Schema.Types.ObjectId
1286
1574
  },
1287
1575
  interests: {
1288
- enum: Object.values(import_cluemart_shared11.EnumResourceType),
1576
+ enum: Object.values(import_cluemart_shared13.EnumResourceType),
1289
1577
  required: false,
1290
1578
  type: [String]
1291
1579
  },
@@ -1304,11 +1592,11 @@ var schema8 = new MongooseSchema12(
1304
1592
  partner: {
1305
1593
  ref: "Partner",
1306
1594
  required: false,
1307
- type: import_mongoose12.default.Schema.Types.ObjectId
1595
+ type: import_mongoose16.default.Schema.Types.ObjectId
1308
1596
  },
1309
1597
  password: { required: true, type: String },
1310
1598
  platform: {
1311
- enum: Object.values(import_cluemart_shared11.EnumOSPlatform),
1599
+ enum: Object.values(import_cluemart_shared13.EnumOSPlatform),
1312
1600
  required: false,
1313
1601
  type: String
1314
1602
  },
@@ -1329,15 +1617,15 @@ var schema8 = new MongooseSchema12(
1329
1617
  type: String
1330
1618
  },
1331
1619
  roles: {
1332
- default: [import_cluemart_shared11.EnumUserRole.CUSTOMER],
1333
- enum: Object.values(import_cluemart_shared11.EnumUserRole),
1620
+ default: [import_cluemart_shared13.EnumUserRole.CUSTOMER],
1621
+ enum: Object.values(import_cluemart_shared13.EnumUserRole),
1334
1622
  required: true,
1335
1623
  type: [String]
1336
1624
  },
1337
1625
  school: {
1338
1626
  ref: "School",
1339
1627
  required: false,
1340
- type: import_mongoose12.default.Schema.Types.ObjectId
1628
+ type: import_mongoose16.default.Schema.Types.ObjectId
1341
1629
  },
1342
1630
  stripe: {
1343
1631
  required: false,
@@ -1362,20 +1650,20 @@ var schema8 = new MongooseSchema12(
1362
1650
  vendor: {
1363
1651
  ref: "Vendor",
1364
1652
  required: false,
1365
- type: import_mongoose12.default.Schema.Types.ObjectId
1653
+ type: import_mongoose16.default.Schema.Types.ObjectId
1366
1654
  }
1367
1655
  },
1368
1656
  { strict: false, timestamps: true }
1369
1657
  );
1370
- schema8.index({ "licences.expiryDate": 1 });
1371
- schema8.index({ "licences.licenceType": 1 });
1372
- schema8.index({ promoCodes: 1, active: 1, deletedAt: 1 });
1373
- var UserModel = import_mongoose12.default.models.User || import_mongoose12.default.model("User", schema8);
1658
+ schema12.index({ "licences.expiryDate": 1 });
1659
+ schema12.index({ "licences.licenceType": 1 });
1660
+ schema12.index({ promoCodes: 1, active: 1, deletedAt: 1 });
1661
+ var UserModel = import_mongoose16.default.models.User || import_mongoose16.default.model("User", schema12);
1374
1662
 
1375
1663
  // src/mongoose/VerificationToken.ts
1376
- var import_mongoose13 = __toESM(require("mongoose"));
1377
- var MongooseSchema13 = import_mongoose13.default.Schema;
1378
- var schema9 = new MongooseSchema13(
1664
+ var import_mongoose17 = __toESM(require("mongoose"));
1665
+ var MongooseSchema13 = import_mongoose17.default.Schema;
1666
+ var schema13 = new MongooseSchema13(
1379
1667
  {
1380
1668
  createdAt: {
1381
1669
  default: Date.now,
@@ -1390,12 +1678,12 @@ var schema9 = new MongooseSchema13(
1390
1678
  },
1391
1679
  { timestamps: true }
1392
1680
  );
1393
- var VerificationTokenModel = import_mongoose13.default.models.VerificationToken || import_mongoose13.default.model("VerificationToken", schema9);
1681
+ var VerificationTokenModel = import_mongoose17.default.models.VerificationToken || import_mongoose17.default.model("VerificationToken", schema13);
1394
1682
 
1395
1683
  // src/mongoose/vendor/Vendor.ts
1396
- var import_cluemart_shared12 = require("@timardex/cluemart-shared");
1397
- var import_mongoose14 = __toESM(require("mongoose"));
1398
- var MongooseSchema14 = import_mongoose14.default.Schema;
1684
+ var import_cluemart_shared14 = require("@timardex/cluemart-shared");
1685
+ var import_mongoose18 = __toESM(require("mongoose"));
1686
+ var MongooseSchema14 = import_mongoose18.default.Schema;
1399
1687
  var vendorProductTypeSchema = new MongooseSchema14(
1400
1688
  {
1401
1689
  description: { required: false, type: String },
@@ -1418,7 +1706,7 @@ var calendarSchema = new MongooseSchema14(
1418
1706
  {
1419
1707
  dateTime: {
1420
1708
  dateStatus: {
1421
- enum: Object.values(import_cluemart_shared12.EnumEventDateStatus),
1709
+ enum: Object.values(import_cluemart_shared14.EnumEventDateStatus),
1422
1710
  required: false,
1423
1711
  type: String
1424
1712
  },
@@ -1442,15 +1730,27 @@ var calendarWrapperSchema = new MongooseSchema14(
1442
1730
  },
1443
1731
  { _id: false }
1444
1732
  );
1445
- var schema10 = new MongooseSchema14(
1733
+ var vendorAvailabilitySchema = new MongooseSchema14(
1734
+ {
1735
+ corporate: { default: false, required: false, type: Boolean },
1736
+ private: { default: false, required: false, type: Boolean },
1737
+ school: { default: false, required: false, type: Boolean }
1738
+ },
1739
+ { _id: false }
1740
+ );
1741
+ var downgradeSnapshotSchema = new MongooseSchema14(
1742
+ {
1743
+ availability: { required: false, type: vendorAvailabilitySchema },
1744
+ calendarActive: { required: false, type: Boolean },
1745
+ productsActive: { required: false, type: Boolean }
1746
+ },
1747
+ { _id: false }
1748
+ );
1749
+ var schema14 = new MongooseSchema14(
1446
1750
  {
1447
1751
  ...baseResourceFields,
1448
1752
  // Importing base resource fields from global.ts
1449
- availability: {
1450
- corporate: { default: false, required: false, type: Boolean },
1451
- private: { default: false, required: false, type: Boolean },
1452
- school: { default: false, required: false, type: Boolean }
1453
- },
1753
+ availability: { required: false, type: vendorAvailabilitySchema },
1454
1754
  calendar: {
1455
1755
  required: false,
1456
1756
  type: calendarWrapperSchema
@@ -1458,6 +1758,7 @@ var schema10 = new MongooseSchema14(
1458
1758
  categories: { required: true, type: [CategorySchema] },
1459
1759
  categoriesNames: { default: [], required: false, type: [String] },
1460
1760
  claimed: { default: true, required: false, type: Boolean },
1761
+ downgradeSnapshot: { required: false, type: downgradeSnapshotSchema },
1461
1762
  foodTruck: { required: true, type: Boolean },
1462
1763
  products: { required: false, type: productWrapperSchema },
1463
1764
  relations: {
@@ -1469,39 +1770,39 @@ var schema10 = new MongooseSchema14(
1469
1770
  unregisteredVendorId: {
1470
1771
  ref: "UnregisteredVendor",
1471
1772
  required: false,
1472
- type: import_mongoose14.default.Schema.Types.ObjectId
1773
+ type: import_mongoose18.default.Schema.Types.ObjectId
1473
1774
  },
1474
1775
  vendorInfoId: {
1475
1776
  ref: "VendorInfo",
1476
1777
  required: false,
1477
- type: import_mongoose14.default.Schema.Types.ObjectId
1778
+ type: import_mongoose18.default.Schema.Types.ObjectId
1478
1779
  },
1479
1780
  vendorType: {
1480
- enum: Object.values(import_cluemart_shared12.EnumVendorType),
1781
+ enum: Object.values(import_cluemart_shared14.EnumVendorType),
1481
1782
  required: true,
1482
1783
  type: String
1483
1784
  }
1484
1785
  },
1485
1786
  { timestamps: true }
1486
1787
  );
1487
- schema10.index({ name: 1 });
1488
- schema10.index({ description: 1 });
1489
- schema10.index({ region: 1 });
1490
- schema10.index({ "categories.name": 1 });
1491
- schema10.index({ slug: 1 });
1492
- schema10.index({
1493
- name: "text",
1788
+ schema14.index({ name: 1 });
1789
+ schema14.index({ description: 1 });
1790
+ schema14.index({ region: 1 });
1791
+ schema14.index({ "categories.name": 1 });
1792
+ schema14.index({ slug: 1 });
1793
+ schema14.index({
1794
+ categoriesNames: "text",
1494
1795
  description: "text",
1495
- categoriesNames: "text"
1796
+ name: "text"
1496
1797
  });
1497
- schema10.index({ "owner.userId": 1, deletedAt: 1 });
1498
- schema10.plugin(searchNamePlugin);
1499
- var VendorModel = import_mongoose14.default.models.Vendor || import_mongoose14.default.model("Vendor", schema10);
1798
+ schema14.index({ deletedAt: 1, "owner.userId": 1 });
1799
+ schema14.plugin(searchNamePlugin);
1800
+ var VendorModel = import_mongoose18.default.models.Vendor || import_mongoose18.default.model("Vendor", schema14);
1500
1801
 
1501
1802
  // src/mongoose/vendor/VendorInfo.ts
1502
- var import_cluemart_shared13 = require("@timardex/cluemart-shared");
1503
- var import_mongoose15 = __toESM(require("mongoose"));
1504
- var MongooseSchema15 = import_mongoose15.default.Schema;
1803
+ var import_cluemart_shared15 = require("@timardex/cluemart-shared");
1804
+ var import_mongoose19 = __toESM(require("mongoose"));
1805
+ var MongooseSchema15 = import_mongoose19.default.Schema;
1505
1806
  var AttributesSchema = new MongooseSchema15(
1506
1807
  {
1507
1808
  details: { required: false, type: String },
@@ -1509,7 +1810,7 @@ var AttributesSchema = new MongooseSchema15(
1509
1810
  },
1510
1811
  { _id: false }
1511
1812
  );
1512
- var schema11 = new MongooseSchema15(
1813
+ var schema15 = new MongooseSchema15(
1513
1814
  {
1514
1815
  active: { default: true, type: Boolean },
1515
1816
  compliance: {
@@ -1519,7 +1820,7 @@ var schema11 = new MongooseSchema15(
1519
1820
  documents: [ResourceImageTypeSchema],
1520
1821
  product: {
1521
1822
  foodFlavors: {
1522
- enum: Object.values(import_cluemart_shared13.EnumFoodFlavor),
1823
+ enum: Object.values(import_cluemart_shared15.EnumFoodFlavor),
1523
1824
  required: true,
1524
1825
  type: [String]
1525
1826
  },
@@ -1544,29 +1845,29 @@ var schema11 = new MongooseSchema15(
1544
1845
  vendorId: {
1545
1846
  ref: "Vendor",
1546
1847
  required: true,
1547
- type: import_mongoose15.default.Schema.Types.ObjectId
1848
+ type: import_mongoose19.default.Schema.Types.ObjectId
1548
1849
  }
1549
1850
  },
1550
1851
  { timestamps: true }
1551
1852
  );
1552
- schema11.index({ vendorId: 1 });
1553
- var VendorInfoModel = import_mongoose15.default.models.VendorInfo || import_mongoose15.default.model("VendorInfo", schema11);
1853
+ schema15.index({ vendorId: 1 });
1854
+ var VendorInfoModel = import_mongoose19.default.models.VendorInfo || import_mongoose19.default.model("VendorInfo", schema15);
1554
1855
 
1555
1856
  // src/mongoose/vendor/UnregisteredVendor.ts
1556
- var import_mongoose16 = __toESM(require("mongoose"));
1557
- var MongooseSchema16 = import_mongoose16.default.Schema;
1857
+ var import_mongoose20 = __toESM(require("mongoose"));
1858
+ var MongooseSchema16 = import_mongoose20.default.Schema;
1558
1859
  var invitationSchema = new MongooseSchema16(
1559
1860
  {
1560
1861
  dateTime: { required: true, type: [dateTimeSchema2] },
1561
1862
  inviterId: {
1562
1863
  ref: "Event",
1563
1864
  required: true,
1564
- type: import_mongoose16.default.Schema.Types.ObjectId
1865
+ type: import_mongoose20.default.Schema.Types.ObjectId
1565
1866
  }
1566
1867
  },
1567
1868
  { _id: false }
1568
1869
  );
1569
- var schema12 = new MongooseSchema16(
1870
+ var schema16 = new MongooseSchema16(
1570
1871
  {
1571
1872
  active: { default: true, required: true, type: Boolean },
1572
1873
  categoryIds: { required: true, type: [String] },
@@ -1575,7 +1876,7 @@ var schema12 = new MongooseSchema16(
1575
1876
  claimedByUserId: {
1576
1877
  ref: "User",
1577
1878
  required: false,
1578
- type: import_mongoose16.default.Schema.Types.ObjectId
1879
+ type: import_mongoose20.default.Schema.Types.ObjectId
1579
1880
  },
1580
1881
  claimInitiatedAt: { default: null, required: false, type: Date },
1581
1882
  claimToken: { default: null, required: false, type: String },
@@ -1588,15 +1889,15 @@ var schema12 = new MongooseSchema16(
1588
1889
  },
1589
1890
  { timestamps: true }
1590
1891
  );
1591
- schema12.index({ name: 1 });
1592
- schema12.index({ email: 1 });
1593
- var UnregisteredVendorModel = import_mongoose16.default.models.UnregisteredVendor || import_mongoose16.default.model("UnregisteredVendor", schema12);
1892
+ schema16.index({ name: 1 });
1893
+ schema16.index({ email: 1 });
1894
+ var UnregisteredVendorModel = import_mongoose20.default.models.UnregisteredVendor || import_mongoose20.default.model("UnregisteredVendor", schema16);
1594
1895
 
1595
1896
  // src/mongoose/event/Event.ts
1596
- var import_cluemart_shared14 = require("@timardex/cluemart-shared");
1597
- var import_mongoose17 = __toESM(require("mongoose"));
1598
- var MongooseSchema17 = import_mongoose17.default.Schema;
1599
- var schema13 = new MongooseSchema17(
1897
+ var import_cluemart_shared16 = require("@timardex/cluemart-shared");
1898
+ var import_mongoose21 = __toESM(require("mongoose"));
1899
+ var MongooseSchema17 = import_mongoose21.default.Schema;
1900
+ var schema17 = new MongooseSchema17(
1600
1901
  {
1601
1902
  ...baseResourceFields,
1602
1903
  // Importing base resource fields from global.ts
@@ -1605,10 +1906,10 @@ var schema13 = new MongooseSchema17(
1605
1906
  eventInfoId: {
1606
1907
  ref: "EventInfo",
1607
1908
  required: false,
1608
- type: import_mongoose17.default.Schema.Types.ObjectId
1909
+ type: import_mongoose21.default.Schema.Types.ObjectId
1609
1910
  },
1610
1911
  eventType: {
1611
- enum: Object.values(import_cluemart_shared14.EnumEventType),
1912
+ enum: Object.values(import_cluemart_shared16.EnumEventType),
1612
1913
  required: true,
1613
1914
  type: String
1614
1915
  },
@@ -1634,24 +1935,24 @@ var schema13 = new MongooseSchema17(
1634
1935
  },
1635
1936
  { timestamps: true }
1636
1937
  );
1637
- schema13.index({ name: 1 });
1638
- schema13.index({ description: 1 });
1639
- schema13.index({ region: 1 });
1640
- schema13.index({ "location.geo": "2dsphere" });
1641
- schema13.index({ tags: 1 });
1642
- schema13.index({ deletedAt: 1 });
1643
- schema13.index({ "dateTime.dateStatus": 1 });
1644
- schema13.index({ slug: 1 });
1645
- schema13.index({ name: "text", description: "text", tags: "text" });
1646
- schema13.index({ "owner.userId": 1, deletedAt: 1 });
1647
- schema13.plugin(searchNamePlugin);
1648
- var EventModel = import_mongoose17.default.models.Event || import_mongoose17.default.model("Event", schema13);
1938
+ schema17.index({ name: 1 });
1939
+ schema17.index({ description: 1 });
1940
+ schema17.index({ region: 1 });
1941
+ schema17.index({ "location.geo": "2dsphere" });
1942
+ schema17.index({ tags: 1 });
1943
+ schema17.index({ deletedAt: 1 });
1944
+ schema17.index({ "dateTime.dateStatus": 1 });
1945
+ schema17.index({ slug: 1 });
1946
+ schema17.index({ name: "text", description: "text", tags: "text" });
1947
+ schema17.index({ "owner.userId": 1, deletedAt: 1 });
1948
+ schema17.plugin(searchNamePlugin);
1949
+ var EventModel = import_mongoose21.default.models.Event || import_mongoose21.default.model("Event", schema17);
1649
1950
 
1650
1951
  // src/mongoose/Partner.ts
1651
- var import_cluemart_shared15 = require("@timardex/cluemart-shared");
1652
- var import_mongoose18 = __toESM(require("mongoose"));
1653
- var MongooseSchema18 = import_mongoose18.default.Schema;
1654
- var schema14 = new MongooseSchema18(
1952
+ var import_cluemart_shared17 = require("@timardex/cluemart-shared");
1953
+ var import_mongoose22 = __toESM(require("mongoose"));
1954
+ var MongooseSchema18 = import_mongoose22.default.Schema;
1955
+ var schema18 = new MongooseSchema18(
1655
1956
  {
1656
1957
  ...baseResourceFields,
1657
1958
  location: {
@@ -1660,33 +1961,33 @@ var schema14 = new MongooseSchema18(
1660
1961
  },
1661
1962
  nzbn: { required: true, type: String },
1662
1963
  partnerType: {
1663
- enum: Object.values(import_cluemart_shared15.EnumPartnerType),
1964
+ enum: Object.values(import_cluemart_shared17.EnumPartnerType),
1664
1965
  required: true,
1665
1966
  type: String
1666
1967
  }
1667
1968
  },
1668
1969
  { timestamps: true }
1669
1970
  );
1670
- schema14.index({ name: 1 });
1671
- schema14.index({ description: 1 });
1672
- schema14.index({ region: 1 });
1673
- schema14.index({ "location.geo": "2dsphere" });
1674
- schema14.index({ slug: 1 });
1675
- schema14.index({ name: "text", description: "text" });
1676
- schema14.index({ "owner.userId": 1, deletedAt: 1 });
1677
- schema14.plugin(searchNamePlugin);
1678
- var PartnerModel = import_mongoose18.default.models.Partner || import_mongoose18.default.model("Partner", schema14);
1971
+ schema18.index({ name: 1 });
1972
+ schema18.index({ description: 1 });
1973
+ schema18.index({ region: 1 });
1974
+ schema18.index({ "location.geo": "2dsphere" });
1975
+ schema18.index({ slug: 1 });
1976
+ schema18.index({ name: "text", description: "text" });
1977
+ schema18.index({ "owner.userId": 1, deletedAt: 1 });
1978
+ schema18.plugin(searchNamePlugin);
1979
+ var PartnerModel = import_mongoose22.default.models.Partner || import_mongoose22.default.model("Partner", schema18);
1679
1980
 
1680
1981
  // src/mongoose/Post.ts
1681
- var import_cluemart_shared16 = require("@timardex/cluemart-shared");
1682
- var import_mongoose19 = __toESM(require("mongoose"));
1683
- var MongooseSchema19 = import_mongoose19.default.Schema;
1982
+ var import_cluemart_shared18 = require("@timardex/cluemart-shared");
1983
+ var import_mongoose23 = __toESM(require("mongoose"));
1984
+ var MongooseSchema19 = import_mongoose23.default.Schema;
1684
1985
  var contentSchema = new MongooseSchema19(
1685
1986
  {
1686
- contentData: import_mongoose19.Schema.Types.Mixed,
1987
+ contentData: import_mongoose23.Schema.Types.Mixed,
1687
1988
  contentOrder: { required: true, type: Number },
1688
1989
  contentType: {
1689
- enum: Object.values(import_cluemart_shared16.EnumPostContentType),
1990
+ enum: Object.values(import_cluemart_shared18.EnumPostContentType),
1690
1991
  required: true,
1691
1992
  type: String
1692
1993
  }
@@ -1699,14 +2000,14 @@ var resourceSchema = new MongooseSchema19(
1699
2000
  resourceRegion: { required: true, type: String },
1700
2001
  resourceSlug: { required: true, type: String },
1701
2002
  resourceType: {
1702
- enum: Object.values(import_cluemart_shared16.EnumResourceType),
2003
+ enum: Object.values(import_cluemart_shared18.EnumResourceType),
1703
2004
  required: true,
1704
2005
  type: String
1705
2006
  }
1706
2007
  },
1707
2008
  { _id: false }
1708
2009
  );
1709
- var schema15 = new MongooseSchema19(
2010
+ var schema19 = new MongooseSchema19(
1710
2011
  {
1711
2012
  active: { default: false, required: true, type: Boolean },
1712
2013
  approvedAt: { default: null, required: false, type: Date },
@@ -1722,7 +2023,7 @@ var schema15 = new MongooseSchema19(
1722
2023
  },
1723
2024
  deletedAt: { default: null, required: false, type: Date },
1724
2025
  postType: {
1725
- enum: Object.values(import_cluemart_shared16.EnumPostType),
2026
+ enum: Object.values(import_cluemart_shared18.EnumPostType),
1726
2027
  required: true,
1727
2028
  type: String
1728
2029
  },
@@ -1737,14 +2038,14 @@ var schema15 = new MongooseSchema19(
1737
2038
  },
1738
2039
  { timestamps: true }
1739
2040
  );
1740
- schema15.index({ title: 1 });
1741
- schema15.index({ tags: 1 });
1742
- schema15.index({ postType: 1, slug: 1 }, { unique: true });
1743
- var PostModel = import_mongoose19.default.models.Post || import_mongoose19.default.model("Post", schema15);
2041
+ schema19.index({ title: 1 });
2042
+ schema19.index({ tags: 1 });
2043
+ schema19.index({ postType: 1, slug: 1 }, { unique: true });
2044
+ var PostModel = import_mongoose23.default.models.Post || import_mongoose23.default.model("Post", schema19);
1744
2045
 
1745
2046
  // src/mongoose/AppSetting.ts
1746
- var import_mongoose20 = __toESM(require("mongoose"));
1747
- var MongooseSchema20 = import_mongoose20.default.Schema;
2047
+ var import_mongoose24 = __toESM(require("mongoose"));
2048
+ var MongooseSchema20 = import_mongoose24.default.Schema;
1748
2049
  var APP_SETTINGS_ID = "APP_SETTINGS_DOCUMENT_ID";
1749
2050
  var AppSettingSchema = new MongooseSchema20(
1750
2051
  {
@@ -1777,18 +2078,18 @@ var AppSettingSchema = new MongooseSchema20(
1777
2078
  },
1778
2079
  { timestamps: true }
1779
2080
  );
1780
- var AppSettingModel = import_mongoose20.default.models.AppSetting || import_mongoose20.default.model("AppSetting", AppSettingSchema);
2081
+ var AppSettingModel = import_mongoose24.default.models.AppSetting || import_mongoose24.default.model("AppSetting", AppSettingSchema);
1781
2082
 
1782
2083
  // src/mongoose/game/Game.ts
1783
- var import_cluemart_shared17 = require("@timardex/cluemart-shared");
1784
- var import_mongoose24 = __toESM(require("mongoose"));
2084
+ var import_cluemart_shared19 = require("@timardex/cluemart-shared");
2085
+ var import_mongoose28 = __toESM(require("mongoose"));
1785
2086
 
1786
2087
  // src/mongoose/game/DailyClue.ts
1787
- var import_mongoose22 = __toESM(require("mongoose"));
2088
+ var import_mongoose26 = __toESM(require("mongoose"));
1788
2089
 
1789
2090
  // src/mongoose/game/utils.ts
1790
- var import_mongoose21 = __toESM(require("mongoose"));
1791
- var MongooseSchema21 = import_mongoose21.default.Schema;
2091
+ var import_mongoose25 = __toESM(require("mongoose"));
2092
+ var MongooseSchema21 = import_mongoose25.default.Schema;
1792
2093
  var schemaGameDate = new MongooseSchema21(
1793
2094
  {
1794
2095
  endDate: { required: true, type: Date },
@@ -1798,7 +2099,7 @@ var schemaGameDate = new MongooseSchema21(
1798
2099
  );
1799
2100
 
1800
2101
  // src/mongoose/game/DailyClue.ts
1801
- var MongooseSchema22 = import_mongoose22.default.Schema;
2102
+ var MongooseSchema22 = import_mongoose26.default.Schema;
1802
2103
  var schemaLetters = new MongooseSchema22(
1803
2104
  {
1804
2105
  collected: { required: false, type: [String] },
@@ -1829,8 +2130,8 @@ var schemaDailyClueGameData = new MongooseSchema22(
1829
2130
  );
1830
2131
 
1831
2132
  // src/mongoose/game/PuzzleGame.ts
1832
- var import_mongoose23 = __toESM(require("mongoose"));
1833
- var MongooseSchema23 = import_mongoose23.default.Schema;
2133
+ var import_mongoose27 = __toESM(require("mongoose"));
2134
+ var MongooseSchema23 = import_mongoose27.default.Schema;
1834
2135
  var schemaPuzzleAnswer = new MongooseSchema23(
1835
2136
  {
1836
2137
  answer: { required: true, type: String },
@@ -1875,16 +2176,16 @@ var schemaPuzzleGameData = new MongooseSchema23(
1875
2176
  );
1876
2177
 
1877
2178
  // src/mongoose/game/Game.ts
1878
- var MongooseSchema24 = import_mongoose24.default.Schema;
2179
+ var MongooseSchema24 = import_mongoose28.default.Schema;
1879
2180
  var gameDataSchemas = {
1880
- [import_cluemart_shared17.EnumGameType.DAILY_CLUE]: schemaDailyClueGameData,
1881
- [import_cluemart_shared17.EnumGameType.MINI_QUIZ]: schemaPuzzleGameData,
1882
- [import_cluemart_shared17.EnumGameType.ODD_ONE_OUT]: schemaPuzzleGameData
2181
+ [import_cluemart_shared19.EnumGameType.DAILY_CLUE]: schemaDailyClueGameData,
2182
+ [import_cluemart_shared19.EnumGameType.MINI_QUIZ]: schemaPuzzleGameData,
2183
+ [import_cluemart_shared19.EnumGameType.ODD_ONE_OUT]: schemaPuzzleGameData
1883
2184
  };
1884
2185
  var gameDataDefinition = Object.fromEntries(
1885
- Object.entries(gameDataSchemas).map(([key, schema20]) => [
2186
+ Object.entries(gameDataSchemas).map(([key, schema24]) => [
1886
2187
  key,
1887
- { default: null, required: false, type: schema20 }
2188
+ { default: null, required: false, type: schema24 }
1888
2189
  ])
1889
2190
  );
1890
2191
  var gameHistorySchema = new MongooseSchema24(
@@ -1892,13 +2193,13 @@ var gameHistorySchema = new MongooseSchema24(
1892
2193
  createdAt: { required: true, type: Date },
1893
2194
  gameDate: { required: true, type: schemaGameDate },
1894
2195
  gameStatus: {
1895
- enum: Object.values(import_cluemart_shared17.EnumGameStatus),
2196
+ enum: Object.values(import_cluemart_shared19.EnumGameStatus),
1896
2197
  required: true,
1897
2198
  type: String
1898
2199
  },
1899
2200
  gameTitle: { required: true, type: String },
1900
2201
  gameType: {
1901
- enum: Object.values(import_cluemart_shared17.EnumGameType),
2202
+ enum: Object.values(import_cluemart_shared19.EnumGameType),
1902
2203
  required: true,
1903
2204
  type: String
1904
2205
  },
@@ -1914,7 +2215,7 @@ var gameTypeSchema = new MongooseSchema24(
1914
2215
  gameHistory: { default: [], required: true, type: [gameHistorySchema] },
1915
2216
  gameTitle: { required: true, type: String },
1916
2217
  gameType: {
1917
- enum: Object.values(import_cluemart_shared17.EnumGameType),
2218
+ enum: Object.values(import_cluemart_shared19.EnumGameType),
1918
2219
  required: true,
1919
2220
  type: String
1920
2221
  },
@@ -1922,7 +2223,7 @@ var gameTypeSchema = new MongooseSchema24(
1922
2223
  },
1923
2224
  { timestamps: true }
1924
2225
  );
1925
- var schema16 = new MongooseSchema24(
2226
+ var schema20 = new MongooseSchema24(
1926
2227
  {
1927
2228
  active: { default: false, required: true, type: Boolean },
1928
2229
  deletedAt: { default: null, required: false, type: Date },
@@ -1935,11 +2236,11 @@ var schema16 = new MongooseSchema24(
1935
2236
  },
1936
2237
  { timestamps: true }
1937
2238
  );
1938
- var GameModel = import_mongoose24.default.models.Game || import_mongoose24.default.model("Game", schema16);
2239
+ var GameModel = import_mongoose28.default.models.Game || import_mongoose28.default.model("Game", schema20);
1939
2240
 
1940
2241
  // src/mongoose/School.ts
1941
- var import_mongoose25 = __toESM(require("mongoose"));
1942
- var MongooseSchema25 = import_mongoose25.default.Schema;
2242
+ var import_mongoose29 = __toESM(require("mongoose"));
2243
+ var MongooseSchema25 = import_mongoose29.default.Schema;
1943
2244
  var campaignsSchema = new MongooseSchema25(
1944
2245
  {
1945
2246
  endDate: { required: true, type: Date },
@@ -1948,7 +2249,7 @@ var campaignsSchema = new MongooseSchema25(
1948
2249
  },
1949
2250
  { _id: false }
1950
2251
  );
1951
- var schema17 = new MongooseSchema25(
2252
+ var schema21 = new MongooseSchema25(
1952
2253
  {
1953
2254
  // New schools are active by default
1954
2255
  active: { default: false, required: true, type: Boolean },
@@ -1975,26 +2276,26 @@ var schema17 = new MongooseSchema25(
1975
2276
  },
1976
2277
  { timestamps: true }
1977
2278
  );
1978
- schema17.index(
2279
+ schema21.index(
1979
2280
  { schoolCode: 1 },
1980
2281
  {
1981
2282
  partialFilterExpression: { active: true, deletedAt: null },
1982
2283
  unique: true
1983
2284
  }
1984
2285
  );
1985
- var SchoolModel = import_mongoose25.default.models.School || import_mongoose25.default.model("School", schema17);
2286
+ var SchoolModel = import_mongoose29.default.models.School || import_mongoose29.default.model("School", schema21);
1986
2287
 
1987
2288
  // src/mongoose/Affiliate.ts
1988
- var import_cluemart_shared18 = require("@timardex/cluemart-shared");
1989
- var import_mongoose26 = __toESM(require("mongoose"));
1990
- var MongooseSchema26 = import_mongoose26.default.Schema;
2289
+ var import_cluemart_shared20 = require("@timardex/cluemart-shared");
2290
+ var import_mongoose30 = __toESM(require("mongoose"));
2291
+ var MongooseSchema26 = import_mongoose30.default.Schema;
1991
2292
  var affiliateRewardSchema = new MongooseSchema26(
1992
2293
  {
1993
2294
  createdAt: { required: true, type: Date },
1994
2295
  redeemedAt: { default: null, required: false, type: Date },
1995
2296
  rewardDescription: { required: true, type: String },
1996
2297
  rewardType: {
1997
- enum: Object.values(import_cluemart_shared18.EnumAffiliateRewardType),
2298
+ enum: Object.values(import_cluemart_shared20.EnumAffiliateRewardType),
1998
2299
  required: true,
1999
2300
  type: String
2000
2301
  },
@@ -2008,7 +2309,7 @@ var affiliateResourceSchema = new MongooseSchema26(
2008
2309
  resourceDeletedAt: { default: null, required: false, type: Date },
2009
2310
  resourceId: {
2010
2311
  required: true,
2011
- type: import_mongoose26.default.Schema.Types.ObjectId
2312
+ type: import_mongoose30.default.Schema.Types.ObjectId
2012
2313
  },
2013
2314
  resourceName: { required: true, type: String },
2014
2315
  resourceOwner: {
@@ -2016,7 +2317,7 @@ var affiliateResourceSchema = new MongooseSchema26(
2016
2317
  type: OwnerTypeSchema
2017
2318
  },
2018
2319
  resourceType: {
2019
- enum: Object.values(import_cluemart_shared18.EnumResourceType),
2320
+ enum: Object.values(import_cluemart_shared20.EnumResourceType),
2020
2321
  required: true,
2021
2322
  type: String
2022
2323
  },
@@ -2054,7 +2355,7 @@ var affiliateDetailsSchema = new MongooseSchema26(
2054
2355
  lastName: { required: true, type: String },
2055
2356
  location: { required: true, type: locationsSchema },
2056
2357
  participantType: {
2057
- enum: Object.values(import_cluemart_shared18.EnumAffiliateParticipantType),
2358
+ enum: Object.values(import_cluemart_shared20.EnumAffiliateParticipantType),
2058
2359
  required: true,
2059
2360
  type: String
2060
2361
  },
@@ -2071,7 +2372,7 @@ var redeemHistorySchema = new MongooseSchema26(
2071
2372
  },
2072
2373
  { _id: false }
2073
2374
  );
2074
- var schema18 = new MongooseSchema26(
2375
+ var schema22 = new MongooseSchema26(
2075
2376
  {
2076
2377
  active: { default: false, required: true, type: Boolean },
2077
2378
  affiliateBonusRewards: {
@@ -2101,26 +2402,26 @@ var schema18 = new MongooseSchema26(
2101
2402
  },
2102
2403
  { timestamps: true }
2103
2404
  );
2104
- schema18.index(
2405
+ schema22.index(
2105
2406
  { affiliateCode: 1 },
2106
2407
  {
2107
2408
  partialFilterExpression: { active: true, deletedAt: null },
2108
2409
  unique: true
2109
2410
  }
2110
2411
  );
2111
- var AffiliateModel = import_mongoose26.default.models.Affiliate || import_mongoose26.default.model("Affiliate", schema18);
2412
+ var AffiliateModel = import_mongoose30.default.models.Affiliate || import_mongoose30.default.model("Affiliate", schema22);
2112
2413
 
2113
2414
  // src/mongoose/Coupon.ts
2114
- var import_cluemart_shared19 = require("@timardex/cluemart-shared");
2115
- var import_mongoose27 = __toESM(require("mongoose"));
2116
- var MongooseSchema27 = import_mongoose27.default.Schema;
2415
+ var import_cluemart_shared21 = require("@timardex/cluemart-shared");
2416
+ var import_mongoose31 = __toESM(require("mongoose"));
2417
+ var MongooseSchema27 = import_mongoose31.default.Schema;
2117
2418
  var couponOptionSchema = new MongooseSchema27(
2118
2419
  {
2119
2420
  buy: { required: false, type: Number },
2120
2421
  get: { required: false, type: Number },
2121
2422
  maxRewardCount: { required: false, type: Number },
2122
2423
  type: {
2123
- enum: Object.values(import_cluemart_shared19.EnumCouponQualificationType),
2424
+ enum: Object.values(import_cluemart_shared21.EnumCouponQualificationType),
2124
2425
  required: true,
2125
2426
  type: String
2126
2427
  },
@@ -2133,20 +2434,20 @@ var couponVendorProductSchema = new MongooseSchema27(
2133
2434
  {
2134
2435
  couponId: {
2135
2436
  required: true,
2136
- type: import_mongoose27.default.Schema.Types.ObjectId
2437
+ type: import_mongoose31.default.Schema.Types.ObjectId
2137
2438
  },
2138
2439
  productId: {
2139
2440
  required: true,
2140
- type: import_mongoose27.default.Schema.Types.ObjectId
2441
+ type: import_mongoose31.default.Schema.Types.ObjectId
2141
2442
  },
2142
2443
  vendorCouponId: {
2143
2444
  required: false,
2144
- type: import_mongoose27.default.Schema.Types.ObjectId
2445
+ type: import_mongoose31.default.Schema.Types.ObjectId
2145
2446
  },
2146
2447
  vendorId: {
2147
2448
  ref: "Vendor",
2148
2449
  required: true,
2149
- type: import_mongoose27.default.Schema.Types.ObjectId
2450
+ type: import_mongoose31.default.Schema.Types.ObjectId
2150
2451
  }
2151
2452
  },
2152
2453
  { _id: false }
@@ -2168,7 +2469,7 @@ var couponParticipantUserSchema = new MongooseSchema27(
2168
2469
  userId: {
2169
2470
  ref: "User",
2170
2471
  required: true,
2171
- type: import_mongoose27.default.Schema.Types.ObjectId
2472
+ type: import_mongoose31.default.Schema.Types.ObjectId
2172
2473
  }
2173
2474
  },
2174
2475
  { timestamps: true }
@@ -2192,7 +2493,7 @@ var couponDataSchema = new MongooseSchema27(
2192
2493
  },
2193
2494
  resourceId: { required: true, type: String },
2194
2495
  resourceType: {
2195
- enum: Object.values(import_cluemart_shared19.EnumResourceType),
2496
+ enum: Object.values(import_cluemart_shared21.EnumResourceType),
2196
2497
  required: true,
2197
2498
  type: String
2198
2499
  },
@@ -2200,7 +2501,7 @@ var couponDataSchema = new MongooseSchema27(
2200
2501
  },
2201
2502
  { timestamps: true }
2202
2503
  );
2203
- var schema19 = new MongooseSchema27(
2504
+ var schema23 = new MongooseSchema27(
2204
2505
  {
2205
2506
  active: { default: true, required: true, type: Boolean },
2206
2507
  couponData: { default: [], required: false, type: [couponDataSchema] },
@@ -2212,9 +2513,9 @@ var schema19 = new MongooseSchema27(
2212
2513
  },
2213
2514
  { timestamps: true }
2214
2515
  );
2215
- schema19.index({ active: 1, deletedAt: 1, "owner.userId": 1 });
2216
- schema19.index({ "couponData.participantUsers.userId": 1 });
2217
- var CouponModel = import_mongoose27.default.models.Coupon || import_mongoose27.default.model("Coupon", schema19);
2516
+ schema23.index({ active: 1, deletedAt: 1, "owner.userId": 1 });
2517
+ schema23.index({ "couponData.participantUsers.userId": 1 });
2518
+ var CouponModel = import_mongoose31.default.models.Coupon || import_mongoose31.default.model("Coupon", schema23);
2218
2519
 
2219
2520
  // src/service/promoCode/constants.ts
2220
2521
  var ACTIVE_NOT_DELETED_FILTER = {
@@ -2232,7 +2533,7 @@ async function activeAffiliateCodeExists(affiliateCode) {
2232
2533
  }
2233
2534
 
2234
2535
  // src/service/affiliate/awardAffiliateVendorSubscriptionRewards.ts
2235
- var import_cluemart_shared21 = require("@timardex/cluemart-shared");
2536
+ var import_cluemart_shared23 = require("@timardex/cluemart-shared");
2236
2537
  var import_utils3 = require("@timardex/cluemart-shared/utils");
2237
2538
 
2238
2539
  // src/service/saveNotificationsInDb.ts
@@ -2369,7 +2670,7 @@ async function sendPushNotifications({
2369
2670
  }
2370
2671
 
2371
2672
  // src/service/affiliate/vendorSubscriptionRewards.ts
2372
- var import_cluemart_shared20 = require("@timardex/cluemart-shared");
2673
+ var import_cluemart_shared22 = require("@timardex/cluemart-shared");
2373
2674
  var import_dayjs = __toESM(require("dayjs"));
2374
2675
  var import_timezone = __toESM(require("dayjs/plugin/timezone"));
2375
2676
  var import_utc = __toESM(require("dayjs/plugin/utc"));
@@ -2403,8 +2704,9 @@ async function getPayingStripePlanFor(userId, now, payingPlans) {
2403
2704
  if (stripe == null || stripe.subscriptionId == null) {
2404
2705
  return { hasSubscription: false, plan: null, validTypes };
2405
2706
  }
2406
- const hasActiveStatus = stripe.status === import_enums2.EnumSubscriptionStatus.ACTIVE || stripe.status === import_enums2.EnumSubscriptionStatus.TRIALING;
2407
- if (!hasActiveStatus || stripe.currentPlan == null) {
2707
+ const hasActiveStatus = stripe.status === import_enums2.EnumSubscriptionStatus.ACTIVE;
2708
+ const paidThrough = stripe.endDate ? new Date(stripe.endDate).getTime() : Number.NaN;
2709
+ if (!hasActiveStatus || !Number.isFinite(paidThrough) || paidThrough <= now.getTime() || stripe.currentPlan == null) {
2408
2710
  return { hasSubscription: false, plan: null, validTypes };
2409
2711
  }
2410
2712
  const plan = payingPlans.has(stripe.currentPlan) ? stripe.currentPlan : null;
@@ -2426,14 +2728,14 @@ import_dayjs.default.extend(import_timezone.default);
2426
2728
  var SUBSCRIPTION_REWARD_TIMEZONE = "Pacific/Auckland";
2427
2729
  async function mapVendorLicenceToSubscriptionRewardType(userId, now = /* @__PURE__ */ new Date()) {
2428
2730
  const { hasSubscription, validTypes } = await getPayingVendorStripeSubscriptionPlan(userId, now);
2429
- if (validTypes.has(import_cluemart_shared20.EnumUserLicence.PRO_VENDOR) || validTypes.has(import_cluemart_shared20.EnumUserLicence.PRO_PLUS_VENDOR)) {
2731
+ if (validTypes.has(import_cluemart_shared22.EnumUserLicence.PRO_VENDOR) || validTypes.has(import_cluemart_shared22.EnumUserLicence.PRO_PLUS_VENDOR)) {
2430
2732
  if (hasSubscription) {
2431
- return import_cluemart_shared20.EnumAffiliateRewardType.ACTIVE_VENDOR_PRO_SUBSCRIPTION;
2733
+ return import_cluemart_shared22.EnumAffiliateRewardType.ACTIVE_VENDOR_PRO_SUBSCRIPTION;
2432
2734
  }
2433
- return import_cluemart_shared20.EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
2735
+ return import_cluemart_shared22.EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
2434
2736
  }
2435
- if (validTypes.has(import_cluemart_shared20.EnumUserLicence.STANDARD_VENDOR)) {
2436
- return import_cluemart_shared20.EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
2737
+ if (validTypes.has(import_cluemart_shared22.EnumUserLicence.STANDARD_VENDOR)) {
2738
+ return import_cluemart_shared22.EnumAffiliateRewardType.ACTIVE_VENDOR_STANDARD_SUBSCRIPTION;
2437
2739
  }
2438
2740
  return null;
2439
2741
  }
@@ -2445,7 +2747,7 @@ function getSubscriptionRewardPeriodBounds(now = /* @__PURE__ */ new Date()) {
2445
2747
 
2446
2748
  // src/service/affiliate/awardAffiliateVendorSubscriptionRewards.ts
2447
2749
  function isEligibleVendorResource(resource) {
2448
- return resource.resourceType === import_cluemart_shared21.EnumResourceType.VENDOR && resource.resourceActive === true && resource.resourceDeletedAt == null;
2750
+ return resource.resourceType === import_cluemart_shared23.EnumResourceType.VENDOR && resource.resourceActive === true && resource.resourceDeletedAt == null;
2449
2751
  }
2450
2752
  async function findAffiliatesWithActiveVendorReferrals() {
2451
2753
  return await AffiliateModel.find({
@@ -2454,7 +2756,7 @@ async function findAffiliatesWithActiveVendorReferrals() {
2454
2756
  $elemMatch: {
2455
2757
  resourceActive: true,
2456
2758
  resourceDeletedAt: null,
2457
- resourceType: import_cluemart_shared21.EnumResourceType.VENDOR
2759
+ resourceType: import_cluemart_shared23.EnumResourceType.VENDOR
2458
2760
  }
2459
2761
  },
2460
2762
  deletedAt: null
@@ -2475,18 +2777,24 @@ async function isEligibleReferredVendor({
2475
2777
  async function notifyAffiliateOwnerOfSubscriptionReward({
2476
2778
  affiliateId,
2477
2779
  affiliateOwnerUserId,
2478
- resourceName,
2479
- rewardValue
2780
+ awards
2480
2781
  }) {
2782
+ if (awards.length === 0) {
2783
+ return;
2784
+ }
2785
+ const totalPoints = awards.reduce((sum, award) => sum + award.rewardValue, 0);
2786
+ const resourceNames = awards.map((award) => award.resourceName);
2787
+ const pointLabel = totalPoints === 1 ? "point" : "points";
2788
+ 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.`;
2481
2789
  const payload = {
2482
2790
  data: {
2483
2791
  resourceId: String(affiliateId),
2484
- resourceName,
2485
- resourceType: import_cluemart_shared21.EnumNotificationResourceType.AFFILIATE_REWARD_RECEIVED
2792
+ resourceName: resourceNames.join(", "),
2793
+ resourceType: import_cluemart_shared23.EnumNotificationResourceType.AFFILIATE_REWARD_RECEIVED
2486
2794
  },
2487
- message: `You earned ${rewardValue} points! Your referred vendor "${resourceName}" has an active subscription.`,
2795
+ message,
2488
2796
  title: "Affiliate points earned",
2489
- type: import_cluemart_shared21.EnumNotificationType.SYSTEM,
2797
+ type: import_cluemart_shared23.EnumNotificationType.SYSTEM,
2490
2798
  userIds: [affiliateOwnerUserId]
2491
2799
  };
2492
2800
  try {
@@ -2515,7 +2823,7 @@ async function tryAwardSubscriptionReward({
2515
2823
  resourceActive: true,
2516
2824
  resourceDeletedAt: null,
2517
2825
  resourceId: resource.resourceId,
2518
- resourceType: import_cluemart_shared21.EnumResourceType.VENDOR,
2826
+ resourceType: import_cluemart_shared23.EnumResourceType.VENDOR,
2519
2827
  rewards: {
2520
2828
  $not: {
2521
2829
  $elemMatch: {
@@ -2536,15 +2844,12 @@ async function tryAwardSubscriptionReward({
2536
2844
  }
2537
2845
  ).exec();
2538
2846
  if (updateResult.modifiedCount === 0) {
2539
- return "skipped";
2847
+ return null;
2540
2848
  }
2541
- await notifyAffiliateOwnerOfSubscriptionReward({
2542
- affiliateId: affiliate._id,
2543
- affiliateOwnerUserId: affiliate.owner.userId,
2849
+ return {
2544
2850
  resourceName: resource.resourceName,
2545
2851
  rewardValue: reward.rewardValue
2546
- });
2547
- return "awarded";
2852
+ };
2548
2853
  }
2549
2854
  async function processAffiliateVendorReferral({
2550
2855
  affiliate,
@@ -2558,14 +2863,14 @@ async function processAffiliateVendorReferral({
2558
2863
  resourceOwnerUserId: resource.resourceOwner.userId
2559
2864
  });
2560
2865
  if (!vendorEligible) {
2561
- return "skipped";
2866
+ return null;
2562
2867
  }
2563
2868
  const rewardType = await mapVendorLicenceToSubscriptionRewardType(
2564
2869
  resource.resourceOwner.userId,
2565
2870
  now
2566
2871
  );
2567
2872
  if (!rewardType) {
2568
- return "skipped";
2873
+ return null;
2569
2874
  }
2570
2875
  return tryAwardSubscriptionReward({
2571
2876
  affiliate,
@@ -2581,8 +2886,9 @@ async function awardAffiliateVendorSubscriptionRewards(now = /* @__PURE__ */ new
2581
2886
  const affiliates = await findAffiliatesWithActiveVendorReferrals();
2582
2887
  let awarded = 0;
2583
2888
  let skipped = 0;
2584
- const seenPairs = /* @__PURE__ */ new Set();
2585
2889
  for (const affiliate of affiliates) {
2890
+ const awards = [];
2891
+ const seenPairs = /* @__PURE__ */ new Set();
2586
2892
  for (const resource of affiliate.affiliateResources) {
2587
2893
  if (!isEligibleVendorResource(resource)) {
2588
2894
  continue;
@@ -2592,19 +2898,27 @@ async function awardAffiliateVendorSubscriptionRewards(now = /* @__PURE__ */ new
2592
2898
  continue;
2593
2899
  }
2594
2900
  seenPairs.add(pairKey);
2595
- const outcome = await processAffiliateVendorReferral({
2901
+ const award = await processAffiliateVendorReferral({
2596
2902
  affiliate,
2597
2903
  createdAt,
2598
2904
  now,
2599
2905
  period,
2600
2906
  resource
2601
2907
  });
2602
- if (outcome === "awarded") {
2908
+ if (award) {
2603
2909
  awarded += 1;
2910
+ awards.push(award);
2604
2911
  } else {
2605
2912
  skipped += 1;
2606
2913
  }
2607
2914
  }
2915
+ if (awards.length > 0) {
2916
+ await notifyAffiliateOwnerOfSubscriptionReward({
2917
+ affiliateId: affiliate._id,
2918
+ affiliateOwnerUserId: affiliate.owner.userId,
2919
+ awards
2920
+ });
2921
+ }
2608
2922
  }
2609
2923
  return { awarded, skipped };
2610
2924
  }
@@ -2630,7 +2944,7 @@ function normalizeAffiliatePromoCodes(promoCodes) {
2630
2944
  }
2631
2945
 
2632
2946
  // src/service/database.ts
2633
- var import_mongoose31 = __toESM(require("mongoose"));
2947
+ var import_mongoose35 = __toESM(require("mongoose"));
2634
2948
  var connectToDatabase = async ({
2635
2949
  appName,
2636
2950
  dbName,
@@ -2643,7 +2957,7 @@ var connectToDatabase = async ({
2643
2957
  // Fallback to MongoDB Atlas connection string
2644
2958
  `mongodb+srv://${dbUser}:${dbPassword}@${dbName}.mongodb.net/?retryWrites=true&w=majority&appName=${appName}`
2645
2959
  );
2646
- await import_mongoose31.default.connect(mongoUri);
2960
+ await import_mongoose35.default.connect(mongoUri);
2647
2961
  const connectionType = mongodbUri ? "Local MongoDB" : "MongoDB Atlas";
2648
2962
  console.log(
2649
2963
  `${connectionType} connected from server/src/service/database.ts`
@@ -2656,7 +2970,7 @@ var connectToDatabase = async ({
2656
2970
 
2657
2971
  // src/types/index.ts
2658
2972
  var import_express = __toESM(require("express"));
2659
- var import_mongoose32 = __toESM(require("mongoose"));
2973
+ var import_mongoose36 = __toESM(require("mongoose"));
2660
2974
 
2661
2975
  // src/service/notifyUsers.ts
2662
2976
  async function publishNotificationEvents(userId, pubsub) {
@@ -2704,7 +3018,7 @@ async function notifyUsers({
2704
3018
  }
2705
3019
 
2706
3020
  // src/service/updateAdStatus.ts
2707
- var import_cluemart_shared22 = require("@timardex/cluemart-shared");
3021
+ var import_cluemart_shared24 = require("@timardex/cluemart-shared");
2708
3022
  async function updateAdStatuses() {
2709
3023
  const now = /* @__PURE__ */ new Date();
2710
3024
  const invalidResult = await AdModel.updateMany(
@@ -2714,41 +3028,66 @@ async function updateAdStatuses() {
2714
3028
  { end: { $exists: false } },
2715
3029
  { $expr: { $gt: ["$start", "$end"] } }
2716
3030
  ],
2717
- status: { $ne: import_cluemart_shared22.EnumAdStatus.PAUSED }
3031
+ status: { $ne: import_cluemart_shared24.EnumAdStatus.PAUSED }
2718
3032
  },
2719
- { $set: { status: import_cluemart_shared22.EnumAdStatus.PAUSED } }
3033
+ { $set: { status: import_cluemart_shared24.EnumAdStatus.PAUSED } }
2720
3034
  );
2721
3035
  const expiredResult = await AdModel.updateMany(
2722
- { end: { $lte: now }, status: { $ne: import_cluemart_shared22.EnumAdStatus.EXPIRED } },
2723
- { $set: { status: import_cluemart_shared22.EnumAdStatus.EXPIRED } }
3036
+ { end: { $lte: now }, status: { $ne: import_cluemart_shared24.EnumAdStatus.EXPIRED } },
3037
+ { $set: { status: import_cluemart_shared24.EnumAdStatus.EXPIRED } }
3038
+ );
3039
+ const eligibleBooking = {
3040
+ $or: [
3041
+ { bookingKind: { $exists: false } },
3042
+ { bookingKind: null },
3043
+ {
3044
+ approvalStatus: import_cluemart_shared24.EnumAdApprovalStatus.APPROVED,
3045
+ bookingKind: import_cluemart_shared24.EnumAdBookingSlotKind.RESERVED
3046
+ },
3047
+ {
3048
+ approvalStatus: import_cluemart_shared24.EnumAdApprovalStatus.APPROVED,
3049
+ bookingKind: import_cluemart_shared24.EnumAdBookingSlotKind.PAID,
3050
+ paymentStatus: import_cluemart_shared24.EnumAdPaymentStatus.PAID
3051
+ }
3052
+ ]
3053
+ };
3054
+ const awaitingApprovalResult = await AdModel.updateMany(
3055
+ {
3056
+ $nor: eligibleBooking.$or,
3057
+ bookingKind: { $in: Object.values(import_cluemart_shared24.EnumAdBookingSlotKind) },
3058
+ end: { $gt: now },
3059
+ status: import_cluemart_shared24.EnumAdStatus.ACTIVE
3060
+ },
3061
+ { $set: { status: import_cluemart_shared24.EnumAdStatus.PAUSED } }
2724
3062
  );
2725
3063
  const activeResult = await AdModel.updateMany(
2726
3064
  {
2727
3065
  end: { $gt: now },
2728
3066
  start: { $lte: now },
2729
- status: { $ne: import_cluemart_shared22.EnumAdStatus.ACTIVE }
3067
+ status: { $ne: import_cluemart_shared24.EnumAdStatus.ACTIVE },
3068
+ ...eligibleBooking
2730
3069
  },
2731
- { $set: { status: import_cluemart_shared22.EnumAdStatus.ACTIVE } }
3070
+ { $set: { status: import_cluemart_shared24.EnumAdStatus.ACTIVE } }
2732
3071
  );
2733
3072
  const pausedResult = await AdModel.updateMany(
2734
- { start: { $gt: now }, status: { $ne: import_cluemart_shared22.EnumAdStatus.PAUSED } },
2735
- { $set: { status: import_cluemart_shared22.EnumAdStatus.PAUSED } }
3073
+ { start: { $gt: now }, status: { $ne: import_cluemart_shared24.EnumAdStatus.PAUSED } },
3074
+ { $set: { status: import_cluemart_shared24.EnumAdStatus.PAUSED } }
2736
3075
  );
2737
3076
  console.log(
2738
- `\u2705 Ad statuses updated: invalid=${invalidResult.modifiedCount}, expired=${expiredResult.modifiedCount}, active=${activeResult.modifiedCount}, paused=${pausedResult.modifiedCount}`
3077
+ `\u2705 Ad statuses updated: invalid=${invalidResult.modifiedCount}, expired=${expiredResult.modifiedCount}, awaitingApproval=${awaitingApprovalResult.modifiedCount}, active=${activeResult.modifiedCount}, paused=${pausedResult.modifiedCount}`
2739
3078
  );
2740
3079
  }
2741
3080
 
2742
3081
  // src/service/objectIdToString.ts
2743
- var import_mongoose34 = __toESM(require("mongoose"));
3082
+ var import_mongoose38 = __toESM(require("mongoose"));
2744
3083
  function isValidObjectId(value) {
2745
- return import_mongoose34.default.Types.ObjectId.isValid(value);
3084
+ return import_mongoose38.default.Types.ObjectId.isValid(value);
2746
3085
  }
2747
3086
  function convertObjectIdsToStrings(obj) {
2748
3087
  if (obj === null || obj === void 0) {
2749
3088
  return obj;
2750
3089
  }
2751
- if (obj instanceof import_mongoose34.default.Types.ObjectId) {
3090
+ if (obj instanceof import_mongoose38.default.Types.ObjectId) {
2752
3091
  return obj.toString();
2753
3092
  }
2754
3093
  if (obj instanceof Date) {
@@ -2768,7 +3107,7 @@ function convertObjectIdsToStrings(obj) {
2768
3107
  }
2769
3108
 
2770
3109
  // src/service/event/updateAllEventDateTimeStatuses.ts
2771
- var import_cluemart_shared23 = require("@timardex/cluemart-shared");
3110
+ var import_cluemart_shared25 = require("@timardex/cluemart-shared");
2772
3111
  var import_dayjs2 = __toESM(require("dayjs"));
2773
3112
  var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat"));
2774
3113
  var import_isoWeek = __toESM(require("dayjs/plugin/isoWeek"));
@@ -2777,24 +3116,24 @@ import_dayjs2.default.extend(import_isoWeek.default);
2777
3116
  function getFutureEventStatus(startDateTime, now) {
2778
3117
  const hoursUntilStart = startDateTime.diff(now, "hour", true);
2779
3118
  if (hoursUntilStart > 0 && hoursUntilStart <= 4) {
2780
- return import_cluemart_shared23.EnumEventDateStatus.STARTING_SOON;
3119
+ return import_cluemart_shared25.EnumEventDateStatus.STARTING_SOON;
2781
3120
  }
2782
3121
  if (startDateTime.isSame(now, "day")) {
2783
- return import_cluemart_shared23.EnumEventDateStatus.TODAY;
3122
+ return import_cluemart_shared25.EnumEventDateStatus.TODAY;
2784
3123
  }
2785
3124
  if (startDateTime.isSame(now.add(1, "day"), "day")) {
2786
- return import_cluemart_shared23.EnumEventDateStatus.TOMORROW;
3125
+ return import_cluemart_shared25.EnumEventDateStatus.TOMORROW;
2787
3126
  }
2788
3127
  if (startDateTime.isSame(now, "isoWeek")) {
2789
- return import_cluemart_shared23.EnumEventDateStatus.THIS_WEEK;
3128
+ return import_cluemart_shared25.EnumEventDateStatus.THIS_WEEK;
2790
3129
  }
2791
3130
  if (startDateTime.isSame(now.add(1, "week"), "isoWeek")) {
2792
- return import_cluemart_shared23.EnumEventDateStatus.NEXT_WEEK;
3131
+ return import_cluemart_shared25.EnumEventDateStatus.NEXT_WEEK;
2793
3132
  }
2794
- return import_cluemart_shared23.EnumEventDateStatus.UPCOMING;
3133
+ return import_cluemart_shared25.EnumEventDateStatus.UPCOMING;
2795
3134
  }
2796
3135
  function updateSingleDateTimeStatus(dateTime, now = (0, import_dayjs2.default)()) {
2797
- const dateTimeFormat = `${import_cluemart_shared23.dateFormat} ${import_cluemart_shared23.timeFormat}`;
3136
+ const dateTimeFormat = `${import_cluemart_shared25.dateFormat} ${import_cluemart_shared25.timeFormat}`;
2798
3137
  const startDateTime = (0, import_dayjs2.default)(
2799
3138
  `${dateTime.startDate} ${dateTime.startTime}`,
2800
3139
  dateTimeFormat,
@@ -2808,13 +3147,13 @@ function updateSingleDateTimeStatus(dateTime, now = (0, import_dayjs2.default)()
2808
3147
  if (!startDateTime.isValid() || !endDateTime.isValid()) {
2809
3148
  return {
2810
3149
  ...dateTime,
2811
- dateStatus: import_cluemart_shared23.EnumEventDateStatus.INVALID
3150
+ dateStatus: import_cluemart_shared25.EnumEventDateStatus.INVALID
2812
3151
  };
2813
3152
  }
2814
3153
  if (endDateTime.isBefore(startDateTime)) {
2815
3154
  return {
2816
3155
  ...dateTime,
2817
- dateStatus: import_cluemart_shared23.EnumEventDateStatus.INVALID
3156
+ dateStatus: import_cluemart_shared25.EnumEventDateStatus.INVALID
2818
3157
  };
2819
3158
  }
2820
3159
  let dateStatus;
@@ -2822,10 +3161,10 @@ function updateSingleDateTimeStatus(dateTime, now = (0, import_dayjs2.default)()
2822
3161
  if (startDateTime.isAfter(now)) {
2823
3162
  dateStatus = getFutureEventStatus(startDateTime, now);
2824
3163
  } else {
2825
- dateStatus = import_cluemart_shared23.EnumEventDateStatus.STARTED;
3164
+ dateStatus = import_cluemart_shared25.EnumEventDateStatus.STARTED;
2826
3165
  }
2827
3166
  } else {
2828
- dateStatus = import_cluemart_shared23.EnumEventDateStatus.ENDED;
3167
+ dateStatus = import_cluemart_shared25.EnumEventDateStatus.ENDED;
2829
3168
  }
2830
3169
  return {
2831
3170
  ...dateTime,
@@ -2909,7 +3248,7 @@ async function findEventOrImportedMarketById(resourceId) {
2909
3248
  }
2910
3249
 
2911
3250
  // src/service/relations.ts
2912
- var import_cluemart_shared24 = require("@timardex/cluemart-shared");
3251
+ var import_cluemart_shared26 = require("@timardex/cluemart-shared");
2913
3252
  function didRemoveAnyEventDates(previousDateTime, nextDateTime) {
2914
3253
  if (!previousDateTime?.length) {
2915
3254
  return false;
@@ -2927,7 +3266,7 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
2927
3266
  ) ?? false;
2928
3267
  return {
2929
3268
  ...relationDate,
2930
- status: existsInEvent ? relationDate.status : import_cluemart_shared24.EnumInviteStatus.UNAVAILABLE
3269
+ status: existsInEvent ? relationDate.status : import_cluemart_shared26.EnumInviteStatus.UNAVAILABLE
2931
3270
  };
2932
3271
  });
2933
3272
  }
@@ -2936,15 +3275,15 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
2936
3275
  var import_dayjs6 = __toESM(require("dayjs"));
2937
3276
 
2938
3277
  // src/service/license/compliance/utils.ts
2939
- var import_cluemart_shared29 = require("@timardex/cluemart-shared");
3278
+ var import_cluemart_shared31 = require("@timardex/cluemart-shared");
2940
3279
  var import_dayjs5 = __toESM(require("dayjs"));
2941
3280
 
2942
3281
  // src/service/license/compliance/event.ts
2943
- var import_cluemart_shared25 = require("@timardex/cluemart-shared");
3282
+ var import_cluemart_shared27 = require("@timardex/cluemart-shared");
2944
3283
  var eventLicences = [
2945
- import_cluemart_shared25.EnumUserLicence.STANDARD_EVENT,
2946
- import_cluemart_shared25.EnumUserLicence.PRO_EVENT,
2947
- import_cluemart_shared25.EnumUserLicence.PRO_PLUS_EVENT
3284
+ import_cluemart_shared27.EnumUserLicence.STANDARD_EVENT,
3285
+ import_cluemart_shared27.EnumUserLicence.PRO_EVENT,
3286
+ import_cluemart_shared27.EnumUserLicence.PRO_PLUS_EVENT
2948
3287
  ];
2949
3288
  async function handleEventLicenceCompliance(user, now) {
2950
3289
  if (!user.licences || !user.events?.length) {
@@ -3156,9 +3495,9 @@ function buildLicenceExpiryPipeline(params) {
3156
3495
  }
3157
3496
 
3158
3497
  // src/service/license/compliance/partner.ts
3159
- var import_cluemart_shared26 = require("@timardex/cluemart-shared");
3498
+ var import_cluemart_shared28 = require("@timardex/cluemart-shared");
3160
3499
  var partnerLicences = [
3161
- import_cluemart_shared26.EnumUserLicence.STANDARD_PARTNER
3500
+ import_cluemart_shared28.EnumUserLicence.STANDARD_PARTNER
3162
3501
  ];
3163
3502
  async function handlePartnerLicenceCompliance(user, now) {
3164
3503
  if (!user.licences || !user.partner) {
@@ -3168,11 +3507,11 @@ async function handlePartnerLicenceCompliance(user, now) {
3168
3507
  }
3169
3508
 
3170
3509
  // src/service/license/compliance/vendor.ts
3171
- var import_cluemart_shared28 = require("@timardex/cluemart-shared");
3510
+ var import_cluemart_shared30 = require("@timardex/cluemart-shared");
3172
3511
  var import_dayjs4 = __toESM(require("dayjs"));
3173
3512
 
3174
3513
  // src/service/license/models.ts
3175
- var import_cluemart_shared27 = require("@timardex/cluemart-shared");
3514
+ var import_cluemart_shared29 = require("@timardex/cluemart-shared");
3176
3515
  var import_dayjs3 = __toESM(require("dayjs"));
3177
3516
  var import_graphql = require("graphql");
3178
3517
  var LicenceExpiryDate = /* @__PURE__ */ ((LicenceExpiryDate2) => {
@@ -3190,31 +3529,31 @@ var LicenceCategory = /* @__PURE__ */ ((LicenceCategory2) => {
3190
3529
  return LicenceCategory2;
3191
3530
  })(LicenceCategory || {});
3192
3531
  var licenceCategoryMapping = {
3193
- [import_cluemart_shared27.EnumUserLicence.PRO_EVENT]: "event" /* EVENT */,
3194
- [import_cluemart_shared27.EnumUserLicence.PRO_PLUS_EVENT]: "event" /* EVENT */,
3195
- [import_cluemart_shared27.EnumUserLicence.PRO_PLUS_VENDOR]: "vendor" /* VENDOR */,
3196
- [import_cluemart_shared27.EnumUserLicence.PRO_VENDOR]: "vendor" /* VENDOR */,
3197
- [import_cluemart_shared27.EnumUserLicence.STANDARD_EVENT]: "event" /* EVENT */,
3198
- [import_cluemart_shared27.EnumUserLicence.STANDARD_PARTNER]: "partner" /* PARTNER */,
3199
- [import_cluemart_shared27.EnumUserLicence.STANDARD_VENDOR]: "vendor" /* VENDOR */,
3200
- [import_cluemart_shared27.EnumUserLicence.STANDARD_AFFILIATE]: "affiliate" /* AFFILIATE */,
3201
- [import_cluemart_shared27.EnumUserLicence.STANDARD_SCHOOL]: "school" /* SCHOOL */
3532
+ [import_cluemart_shared29.EnumUserLicence.PRO_EVENT]: "event" /* EVENT */,
3533
+ [import_cluemart_shared29.EnumUserLicence.PRO_PLUS_EVENT]: "event" /* EVENT */,
3534
+ [import_cluemart_shared29.EnumUserLicence.PRO_PLUS_VENDOR]: "vendor" /* VENDOR */,
3535
+ [import_cluemart_shared29.EnumUserLicence.PRO_VENDOR]: "vendor" /* VENDOR */,
3536
+ [import_cluemart_shared29.EnumUserLicence.STANDARD_EVENT]: "event" /* EVENT */,
3537
+ [import_cluemart_shared29.EnumUserLicence.STANDARD_PARTNER]: "partner" /* PARTNER */,
3538
+ [import_cluemart_shared29.EnumUserLicence.STANDARD_VENDOR]: "vendor" /* VENDOR */,
3539
+ [import_cluemart_shared29.EnumUserLicence.STANDARD_AFFILIATE]: "affiliate" /* AFFILIATE */,
3540
+ [import_cluemart_shared29.EnumUserLicence.STANDARD_SCHOOL]: "school" /* SCHOOL */
3202
3541
  };
3203
3542
  var licencePriority = {
3204
- [import_cluemart_shared27.EnumUserLicence.PRO_PLUS_EVENT]: 3,
3205
- [import_cluemart_shared27.EnumUserLicence.PRO_EVENT]: 2,
3206
- [import_cluemart_shared27.EnumUserLicence.STANDARD_EVENT]: 1,
3207
- [import_cluemart_shared27.EnumUserLicence.PRO_PLUS_VENDOR]: 3,
3208
- [import_cluemart_shared27.EnumUserLicence.PRO_VENDOR]: 2,
3209
- [import_cluemart_shared27.EnumUserLicence.STANDARD_VENDOR]: 1,
3210
- [import_cluemart_shared27.EnumUserLicence.STANDARD_PARTNER]: 1,
3211
- [import_cluemart_shared27.EnumUserLicence.STANDARD_AFFILIATE]: 1,
3212
- [import_cluemart_shared27.EnumUserLicence.STANDARD_SCHOOL]: 1
3543
+ [import_cluemart_shared29.EnumUserLicence.PRO_PLUS_EVENT]: 3,
3544
+ [import_cluemart_shared29.EnumUserLicence.PRO_EVENT]: 2,
3545
+ [import_cluemart_shared29.EnumUserLicence.STANDARD_EVENT]: 1,
3546
+ [import_cluemart_shared29.EnumUserLicence.PRO_PLUS_VENDOR]: 3,
3547
+ [import_cluemart_shared29.EnumUserLicence.PRO_VENDOR]: 2,
3548
+ [import_cluemart_shared29.EnumUserLicence.STANDARD_VENDOR]: 1,
3549
+ [import_cluemart_shared29.EnumUserLicence.STANDARD_PARTNER]: 1,
3550
+ [import_cluemart_shared29.EnumUserLicence.STANDARD_AFFILIATE]: 1,
3551
+ [import_cluemart_shared29.EnumUserLicence.STANDARD_SCHOOL]: 1
3213
3552
  };
3214
3553
  var standardLicences = [
3215
- import_cluemart_shared27.EnumUserLicence.STANDARD_VENDOR,
3216
- import_cluemart_shared27.EnumUserLicence.STANDARD_EVENT,
3217
- import_cluemart_shared27.EnumUserLicence.STANDARD_PARTNER
3554
+ import_cluemart_shared29.EnumUserLicence.STANDARD_VENDOR,
3555
+ import_cluemart_shared29.EnumUserLicence.STANDARD_EVENT,
3556
+ import_cluemart_shared29.EnumUserLicence.STANDARD_PARTNER
3218
3557
  ];
3219
3558
  var standardLicenceSet = new Set(standardLicences);
3220
3559
  function isStandardLicence(licence) {
@@ -3228,11 +3567,11 @@ var categoryRegexMapping = {
3228
3567
  ["school" /* SCHOOL */]: /_school$/
3229
3568
  };
3230
3569
  var categoryFallbackLicence = {
3231
- ["event" /* EVENT */]: import_cluemart_shared27.EnumUserLicence.STANDARD_EVENT,
3232
- ["partner" /* PARTNER */]: import_cluemart_shared27.EnumUserLicence.STANDARD_PARTNER,
3233
- ["vendor" /* VENDOR */]: import_cluemart_shared27.EnumUserLicence.STANDARD_VENDOR,
3234
- ["affiliate" /* AFFILIATE */]: import_cluemart_shared27.EnumUserLicence.STANDARD_AFFILIATE,
3235
- ["school" /* SCHOOL */]: import_cluemart_shared27.EnumUserLicence.STANDARD_SCHOOL
3570
+ ["event" /* EVENT */]: import_cluemart_shared29.EnumUserLicence.STANDARD_EVENT,
3571
+ ["partner" /* PARTNER */]: import_cluemart_shared29.EnumUserLicence.STANDARD_PARTNER,
3572
+ ["vendor" /* VENDOR */]: import_cluemart_shared29.EnumUserLicence.STANDARD_VENDOR,
3573
+ ["affiliate" /* AFFILIATE */]: import_cluemart_shared29.EnumUserLicence.STANDARD_AFFILIATE,
3574
+ ["school" /* SCHOOL */]: import_cluemart_shared29.EnumUserLicence.STANDARD_SCHOOL
3236
3575
  };
3237
3576
  var LicenceFilterInput = {
3238
3577
  INPUT_USER_LICENCES: "$licences"
@@ -3368,13 +3707,13 @@ async function checkOwnerHasLicence({
3368
3707
  const owner = await UserModel.findById(userId);
3369
3708
  if (!owner) throw new import_graphql.GraphQLError("Owner not found");
3370
3709
  const categoryByResource = {
3371
- [import_cluemart_shared27.EnumResourceType.EVENT]: "event" /* EVENT */,
3372
- [import_cluemart_shared27.EnumResourceType.PARTNER]: "partner" /* PARTNER */,
3373
- [import_cluemart_shared27.EnumResourceType.VENDOR]: "vendor" /* VENDOR */,
3374
- [import_cluemart_shared27.EnumResourceType.AFFILIATE]: "affiliate" /* AFFILIATE */,
3375
- [import_cluemart_shared27.EnumResourceType.SCHOOL]: "school" /* SCHOOL */
3710
+ [import_cluemart_shared29.EnumResourceType.EVENT]: "event" /* EVENT */,
3711
+ [import_cluemart_shared29.EnumResourceType.PARTNER]: "partner" /* PARTNER */,
3712
+ [import_cluemart_shared29.EnumResourceType.VENDOR]: "vendor" /* VENDOR */,
3713
+ [import_cluemart_shared29.EnumResourceType.AFFILIATE]: "affiliate" /* AFFILIATE */,
3714
+ [import_cluemart_shared29.EnumResourceType.SCHOOL]: "school" /* SCHOOL */
3376
3715
  };
3377
- if (!(0, import_cluemart_shared27.isNonVisitorResourceType)(resourceType)) {
3716
+ if (!(0, import_cluemart_shared29.isNonVisitorResourceType)(resourceType)) {
3378
3717
  throw new import_graphql.GraphQLError(`Invalid resource type: ${resourceType}.`);
3379
3718
  }
3380
3719
  const requiredCategory = categoryByResource[resourceType];
@@ -3398,59 +3737,150 @@ async function checkOwnerHasLicence({
3398
3737
  }
3399
3738
 
3400
3739
  // src/service/license/compliance/vendor.ts
3401
- async function updateVendorBasedOnUserLicense(userId, licenceType) {
3740
+ async function findUserVendor(userId, logLabel) {
3741
+ const user = await UserModel.findById(userId).select("vendor").lean().exec();
3742
+ if (!user?.vendor) {
3743
+ console.warn(`[${logLabel}] No vendor found for userId=${userId}`);
3744
+ return null;
3745
+ }
3746
+ const vendor = await VendorModel.findOne({
3747
+ _id: user.vendor,
3748
+ active: true,
3749
+ deletedAt: null,
3750
+ "owner.userId": userId
3751
+ }).lean().exec();
3752
+ if (!vendor) {
3753
+ console.warn(
3754
+ `[${logLabel}] Vendor not found for id=${user.vendor}, userId=${userId}`
3755
+ );
3756
+ return null;
3757
+ }
3758
+ return vendor;
3759
+ }
3760
+ async function applyVendorDowngrade(vendor, ownerUserId) {
3761
+ const updateData = {};
3762
+ updateData.availability = {
3763
+ corporate: false,
3764
+ private: false,
3765
+ school: false
3766
+ };
3767
+ updateData.products = {
3768
+ active: false,
3769
+ productsList: vendor.products?.productsList ?? []
3770
+ };
3771
+ updateData.calendar = {
3772
+ active: false,
3773
+ calendarData: vendor.calendar?.calendarData ?? []
3774
+ };
3775
+ updateData.downgradeSnapshot = {
3776
+ availability: vendor.availability,
3777
+ calendarActive: vendor.calendar?.active,
3778
+ productsActive: vendor.products?.active
3779
+ };
3780
+ updateData.images = (vendor.images ?? []).map((image, index) => ({
3781
+ ...image,
3782
+ active: index < 6
3783
+ }));
3784
+ const result = await VendorModel.updateOne(
3785
+ {
3786
+ _id: vendor._id,
3787
+ active: true,
3788
+ deletedAt: null,
3789
+ "owner.userId": ownerUserId
3790
+ },
3791
+ { $set: updateData }
3792
+ );
3793
+ return (result?.matchedCount ?? 0) > 0;
3794
+ }
3795
+ async function downgradeVendorProFeatures(userId, licenceType) {
3796
+ const isStandardVendor = licenceType === import_cluemart_shared30.EnumUserLicence.STANDARD_VENDOR;
3797
+ if (!isStandardVendor) {
3798
+ return;
3799
+ }
3402
3800
  try {
3403
- const user = await UserModel.findById(userId).select("vendor").lean().exec();
3404
- if (!user?.vendor) {
3405
- console.warn(`[updateVendor] No vendor found for userId=${userId}`);
3801
+ const vendor = await findUserVendor(userId, "downgradeVendorProFeatures");
3802
+ if (!vendor) {
3406
3803
  return;
3407
3804
  }
3408
- const vendor = await VendorModel.findById(user.vendor).lean().exec();
3805
+ await applyVendorDowngrade(vendor, userId);
3806
+ } catch (error) {
3807
+ console.error("[downgradeVendorProFeatures] Failed:", error);
3808
+ throw error;
3809
+ }
3810
+ }
3811
+ async function applyVendorRestore(vendor, ownerUserId) {
3812
+ const updateData = {};
3813
+ const snapshot = vendor.downgradeSnapshot;
3814
+ updateData.availability = {
3815
+ corporate: snapshot?.availability?.corporate ?? true,
3816
+ private: snapshot?.availability?.private ?? true,
3817
+ school: snapshot?.availability?.school ?? true
3818
+ };
3819
+ updateData.products = {
3820
+ active: snapshot?.productsActive ?? true,
3821
+ productsList: vendor.products?.productsList ?? []
3822
+ };
3823
+ updateData.calendar = {
3824
+ active: snapshot?.calendarActive ?? true,
3825
+ calendarData: vendor.calendar?.calendarData ?? []
3826
+ };
3827
+ updateData.images = (vendor.images ?? []).map((image) => ({
3828
+ ...image,
3829
+ active: true
3830
+ }));
3831
+ const result = await VendorModel.updateOne(
3832
+ {
3833
+ _id: vendor._id,
3834
+ active: true,
3835
+ deletedAt: null,
3836
+ "owner.userId": ownerUserId
3837
+ },
3838
+ { $set: updateData }
3839
+ );
3840
+ return (result?.matchedCount ?? 0) > 0;
3841
+ }
3842
+ async function restoreVendorProFeatures(userId, licenceType) {
3843
+ const isProVendor = licenceType === import_cluemart_shared30.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared30.EnumUserLicence.PRO_PLUS_VENDOR;
3844
+ if (!isProVendor) {
3845
+ return;
3846
+ }
3847
+ try {
3848
+ const vendor = await findUserVendor(userId, "restoreVendorProFeatures");
3409
3849
  if (!vendor) {
3410
- console.warn(`[updateVendor] Vendor not found for id=${user.vendor}`);
3411
3850
  return;
3412
3851
  }
3413
- const updateData = {};
3414
- const isStandardVendor = licenceType === import_cluemart_shared28.EnumUserLicence.STANDARD_VENDOR;
3415
- if (isStandardVendor) {
3416
- updateData.availability = {
3417
- corporate: false,
3418
- private: false,
3419
- school: false
3420
- };
3421
- updateData.products = {
3422
- active: false,
3423
- productsList: vendor.products?.productsList ?? []
3424
- };
3425
- updateData.calendar = {
3426
- active: false,
3427
- calendarData: vendor.calendar?.calendarData ?? []
3428
- };
3429
- }
3430
- updateData.images = (vendor.images ?? []).map((image, index) => ({
3431
- ...image,
3432
- active: isStandardVendor ? index < 6 : true
3433
- }));
3434
- await VendorModel.updateOne({ _id: vendor._id }, { $set: updateData });
3852
+ await applyVendorRestore(vendor, userId);
3435
3853
  } catch (error) {
3436
- console.error("[updateVendorBasedOnUserLicense] Failed:", error);
3854
+ console.error("[restoreVendorProFeatures] Failed:", error);
3855
+ throw error;
3437
3856
  }
3438
3857
  }
3439
3858
  var vendorLicences = [
3440
- import_cluemart_shared28.EnumUserLicence.STANDARD_VENDOR,
3441
- import_cluemart_shared28.EnumUserLicence.PRO_VENDOR,
3442
- import_cluemart_shared28.EnumUserLicence.PRO_PLUS_VENDOR
3859
+ import_cluemart_shared30.EnumUserLicence.STANDARD_VENDOR,
3860
+ import_cluemart_shared30.EnumUserLicence.PRO_VENDOR,
3861
+ import_cluemart_shared30.EnumUserLicence.PRO_PLUS_VENDOR
3443
3862
  ];
3444
3863
  function isProtectedByCurrentStripeSubscription(user, licenceType, now) {
3445
3864
  const stripe = user.stripe;
3446
- if (!stripe?.subscriptionId || stripe.currentPlan !== licenceType || stripe.status !== import_cluemart_shared28.EnumSubscriptionStatus.ACTIVE && stripe.status !== import_cluemart_shared28.EnumSubscriptionStatus.TRIALING) {
3865
+ if (!stripe || stripe.currentPlan !== licenceType) {
3447
3866
  return false;
3448
3867
  }
3449
- if (stripe.cancelAtPeriodEnd !== true || !stripe.endDate) {
3868
+ const gracePeriodEndsAt = stripe.paymentGracePeriodEndsAt ? (0, import_dayjs4.default)(stripe.paymentGracePeriodEndsAt) : null;
3869
+ 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);
3870
+ if (hasActivePaymentGracePeriod) {
3450
3871
  return true;
3451
3872
  }
3873
+ if (!stripe.subscriptionId) {
3874
+ return false;
3875
+ }
3876
+ if (stripe.status !== import_cluemart_shared30.EnumSubscriptionStatus.ACTIVE) {
3877
+ return false;
3878
+ }
3879
+ if (!stripe.endDate) {
3880
+ return false;
3881
+ }
3452
3882
  const paidThrough = (0, import_dayjs4.default)(stripe.endDate);
3453
- return !paidThrough.isValid() || paidThrough.isAfter(now);
3883
+ return paidThrough.isValid() && paidThrough.isAfter(now);
3454
3884
  }
3455
3885
  async function handleVendorLicenceCompliance(user, now) {
3456
3886
  if (!user.licences || !user.vendor) {
@@ -3463,7 +3893,7 @@ async function handleVendorLicenceCompliance(user, now) {
3463
3893
  return;
3464
3894
  }
3465
3895
  const proLicences = vendorLicencesOfUser.filter(
3466
- (licence) => licence.licenceType !== import_cluemart_shared28.EnumUserLicence.STANDARD_VENDOR
3896
+ (licence) => licence.licenceType !== import_cluemart_shared30.EnumUserLicence.STANDARD_VENDOR
3467
3897
  );
3468
3898
  const expiredProLicences = proLicences.filter(
3469
3899
  (licence) => !(0, import_dayjs4.default)(licence.expiryDate).isAfter(now)
@@ -3499,19 +3929,19 @@ async function handleVendorLicenceCompliance(user, now) {
3499
3929
  if (!expiredProLicence || !vendor || hasValidProLicence) {
3500
3930
  return;
3501
3931
  }
3502
- await updateVendorBasedOnUserLicense(
3503
- user._id,
3504
- import_cluemart_shared28.EnumUserLicence.STANDARD_VENDOR
3505
- );
3932
+ const downgraded = await applyVendorDowngrade(vendor, user._id);
3933
+ if (!downgraded) {
3934
+ return;
3935
+ }
3506
3936
  const payload = {
3507
3937
  data: {
3508
3938
  resourceId: String(vendor._id),
3509
3939
  resourceName: vendor.name,
3510
- resourceType: import_cluemart_shared28.EnumNotificationResourceType.DOWNGRADED_VENDOR
3940
+ resourceType: import_cluemart_shared30.EnumNotificationResourceType.DOWNGRADED_VENDOR
3511
3941
  },
3512
3942
  message: `Your Vendor license has been downgraded due to licence expiration.`,
3513
3943
  title: `Vendor License Downgraded`,
3514
- type: import_cluemart_shared28.EnumNotificationType.SYSTEM,
3944
+ type: import_cluemart_shared30.EnumNotificationType.SYSTEM,
3515
3945
  userIds: [user._id]
3516
3946
  };
3517
3947
  await sendDeactivationNotification(payload, user._id, vendor.name, "vendor");
@@ -3525,12 +3955,26 @@ async function vendorOwnerHasProLicence(vendorId) {
3525
3955
  if (!vendor) {
3526
3956
  return false;
3527
3957
  }
3528
- const owner = await UserModel.findById(vendor.owner.userId, { licences: 1 }).lean().exec();
3958
+ const owner = await UserModel.findById(vendor.owner.userId, {
3959
+ licences: 1,
3960
+ stripe: 1
3961
+ }).lean().exec();
3962
+ if (!owner) {
3963
+ return false;
3964
+ }
3965
+ const now = (0, import_dayjs4.default)();
3966
+ const effectiveVendorLicences = owner.licences?.filter(
3967
+ (licence) => licence?.licenceType && ((0, import_dayjs4.default)(licence.expiryDate).isAfter(now) || isProtectedByCurrentStripeSubscription(
3968
+ owner,
3969
+ licence.licenceType,
3970
+ now
3971
+ ))
3972
+ );
3529
3973
  const highestVendorLicence = getHighestLicenceForCategory(
3530
- owner?.licences,
3974
+ effectiveVendorLicences,
3531
3975
  "vendor" /* VENDOR */
3532
3976
  );
3533
- return highestVendorLicence !== null && licencePriority[highestVendorLicence] >= licencePriority[import_cluemart_shared28.EnumUserLicence.PRO_VENDOR];
3977
+ return highestVendorLicence !== null && licencePriority[highestVendorLicence] >= licencePriority[import_cluemart_shared30.EnumUserLicence.PRO_VENDOR];
3534
3978
  }
3535
3979
 
3536
3980
  // src/service/license/compliance/utils.ts
@@ -3540,12 +3984,12 @@ async function syncUserLicencesAfterExpiry(userId, licenceTypes, now, mode = "do
3540
3984
  const pipeline = buildLicenceExpiryPipeline({
3541
3985
  downgradeBranches: [
3542
3986
  {
3543
- case: import_cluemart_shared29.EnumUserLicence.PRO_PLUS_VENDOR,
3544
- then: import_cluemart_shared29.EnumUserLicence.STANDARD_VENDOR
3987
+ case: import_cluemart_shared31.EnumUserLicence.PRO_PLUS_VENDOR,
3988
+ then: import_cluemart_shared31.EnumUserLicence.STANDARD_VENDOR
3545
3989
  },
3546
3990
  {
3547
- case: import_cluemart_shared29.EnumUserLicence.PRO_VENDOR,
3548
- then: import_cluemart_shared29.EnumUserLicence.STANDARD_VENDOR
3991
+ case: import_cluemart_shared31.EnumUserLicence.PRO_VENDOR,
3992
+ then: import_cluemart_shared31.EnumUserLicence.STANDARD_VENDOR
3549
3993
  }
3550
3994
  ],
3551
3995
  licenceTypes,
@@ -3674,7 +4118,7 @@ var REMINDER_WINDOW_MIN_HOURS = 6.5 * 24;
3674
4118
  var REMINDER_WINDOW_MAX_HOURS = 7.5 * 24;
3675
4119
 
3676
4120
  // src/service/license/reminder/utils.ts
3677
- var import_cluemart_shared30 = require("@timardex/cluemart-shared");
4121
+ var import_cluemart_shared32 = require("@timardex/cluemart-shared");
3678
4122
  var import_utils8 = require("@timardex/cluemart-shared/utils");
3679
4123
  var import_dayjs7 = __toESM(require("dayjs"));
3680
4124
 
@@ -3740,24 +4184,24 @@ function isLicenseExpiringIn7Days(expiryDate, now) {
3740
4184
  return hoursUntilExpiry >= REMINDER_WINDOW_MIN_HOURS && hoursUntilExpiry <= REMINDER_WINDOW_MAX_HOURS;
3741
4185
  }
3742
4186
  function getLicenseName(licenceType) {
3743
- return import_cluemart_shared30.licenseNiceNames[licenceType] || licenceType;
4187
+ return import_cluemart_shared32.licenseNiceNames[licenceType] || licenceType;
3744
4188
  }
3745
4189
  function getNotificationTypes(isVendorLicense, isPartnerLicense) {
3746
4190
  if (isVendorLicense) {
3747
4191
  return {
3748
- notificationType: import_cluemart_shared30.EnumNotificationType.SYSTEM,
3749
- resourceType: import_cluemart_shared30.EnumNotificationResourceType.EXPIRATION_REMINDER_VENDOR
4192
+ notificationType: import_cluemart_shared32.EnumNotificationType.SYSTEM,
4193
+ resourceType: import_cluemart_shared32.EnumNotificationResourceType.EXPIRATION_REMINDER_VENDOR
3750
4194
  };
3751
4195
  }
3752
4196
  if (isPartnerLicense) {
3753
4197
  return {
3754
- notificationType: import_cluemart_shared30.EnumNotificationType.SYSTEM,
3755
- resourceType: import_cluemart_shared30.EnumNotificationResourceType.EXPIRATION_REMINDER_PARTNER
4198
+ notificationType: import_cluemart_shared32.EnumNotificationType.SYSTEM,
4199
+ resourceType: import_cluemart_shared32.EnumNotificationResourceType.EXPIRATION_REMINDER_PARTNER
3756
4200
  };
3757
4201
  }
3758
4202
  return {
3759
- notificationType: import_cluemart_shared30.EnumNotificationType.SYSTEM,
3760
- resourceType: import_cluemart_shared30.EnumNotificationResourceType.EXPIRATION_REMINDER_EVENT
4203
+ notificationType: import_cluemart_shared32.EnumNotificationType.SYSTEM,
4204
+ resourceType: import_cluemart_shared32.EnumNotificationResourceType.EXPIRATION_REMINDER_EVENT
3761
4205
  };
3762
4206
  }
3763
4207
  async function getLicenseResourceInfo(user, licence) {
@@ -3809,11 +4253,11 @@ async function getLicenseResourceInfo(user, licence) {
3809
4253
  };
3810
4254
  }
3811
4255
  function getLicenceExpiryMode(licenceType) {
3812
- return licenceType === import_cluemart_shared30.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared30.EnumUserLicence.PRO_PLUS_VENDOR ? "downgrade" : "extend";
4256
+ return licenceType === import_cluemart_shared32.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared32.EnumUserLicence.PRO_PLUS_VENDOR ? "downgrade" : "extend";
3813
4257
  }
3814
4258
  async function sendLicenseReminder(user, licence) {
3815
4259
  const licenceName = getLicenseName(licence.licenceType);
3816
- const expiryDate = (0, import_dayjs7.default)(licence.expiryDate).format(import_cluemart_shared30.dateFormat);
4260
+ const expiryDate = (0, import_dayjs7.default)(licence.expiryDate).format(import_cluemart_shared32.dateFormat);
3817
4261
  const userId = String(user._id);
3818
4262
  const resourceInfo = await getLicenseResourceInfo(user, licence);
3819
4263
  if (!resourceInfo) {
@@ -3952,6 +4396,7 @@ async function remindUsersAboutLicenseExpiration() {
3952
4396
  convertObjectIdsToStrings,
3953
4397
  createLicenceObject,
3954
4398
  didRemoveAnyEventDates,
4399
+ downgradeVendorProFeatures,
3955
4400
  ensureUserLicenseCompliance,
3956
4401
  ensureUserLicenseComplianceForUser,
3957
4402
  eventLicences,
@@ -3986,6 +4431,7 @@ async function remindUsersAboutLicenseExpiration() {
3986
4431
  publishNotificationEvents,
3987
4432
  remindUsersAboutLicenseExpiration,
3988
4433
  replaceUserLicenceWithObject,
4434
+ restoreVendorProFeatures,
3989
4435
  saveNotificationsInDb,
3990
4436
  sendDeactivationNotification,
3991
4437
  sendLicenseReminder,
@@ -3996,7 +4442,6 @@ async function remindUsersAboutLicenseExpiration() {
3996
4442
  updateAllEventDateTimeStatuses,
3997
4443
  updateRelationDatesToUnavailable,
3998
4444
  updateSingleDateTimeStatus,
3999
- updateVendorBasedOnUserLicense,
4000
4445
  upgradeUserToLicence,
4001
4446
  vendorLicences,
4002
4447
  vendorOwnerHasProLicence