@timardex/cluemart-server-shared 4.2.1 → 5.1.0

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.
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var service_exports = {};
32
32
  __export(service_exports, {
33
33
  ACTIVE_NOT_DELETED_FILTER: () => ACTIVE_NOT_DELETED_FILTER,
34
+ LIVE_RESOURCE_FILTER: () => LIVE_RESOURCE_FILTER,
34
35
  LicenceCategory: () => LicenceCategory,
35
36
  REMINDER_WINDOW_MAX_HOURS: () => REMINDER_WINDOW_MAX_HOURS,
36
37
  REMINDER_WINDOW_MIN_HOURS: () => REMINDER_WINDOW_MIN_HOURS,
@@ -61,6 +62,7 @@ __export(service_exports, {
61
62
  eventLicences: () => eventLicences,
62
63
  findAffiliateByPromoCode: () => findAffiliateByPromoCode,
63
64
  findEventOrImportedMarketById: () => findEventOrImportedMarketById,
65
+ findEventOrImportedMarketDetailsById: () => findEventOrImportedMarketDetailsById,
64
66
  getActiveLicenceForResource: () => getActiveLicenceForResource,
65
67
  getAssociateAccessMeta: () => getAssociateAccessMeta,
66
68
  getEventResourceInfo: () => getEventResourceInfo,
@@ -81,6 +83,7 @@ __export(service_exports, {
81
83
  hasActiveProLicenceForResource: () => hasActiveProLicenceForResource,
82
84
  hasValidLicence: () => hasValidLicence,
83
85
  isAssociableResourceType: () => isAssociableResourceType,
86
+ isLiveResource: () => isLiveResource,
84
87
  isProLicence: () => isProLicence,
85
88
  isProtectedByCurrentStripeSubscription: () => isProtectedByCurrentStripeSubscription,
86
89
  isStandardLicence: () => isStandardLicence,
@@ -111,7 +114,7 @@ __export(service_exports, {
111
114
  updateAdStatuses: () => updateAdStatuses,
112
115
  updateAllEventDateTimeStatuses: () => updateAllEventDateTimeStatuses,
113
116
  updateRelationDatesToCanceled: () => updateRelationDatesToCanceled,
114
- updateSingleDateTimeStatus: () => import_cluemart_shared39.updateSingleDateTimeStatus,
117
+ updateSingleDateTimeStatus: () => import_cluemart_shared40.updateSingleDateTimeStatus,
115
118
  upgradeUserToLicence: () => upgradeUserToLicence,
116
119
  vendorOwnerHasProLicence: () => vendorOwnerHasProLicence
117
120
  });
@@ -1117,6 +1120,11 @@ var schema7 = new MongooseSchema6(
1117
1120
  type: ResourceImageTypeSchema
1118
1121
  },
1119
1122
  dateTime: [dateTimeSchema],
1123
+ deactivatedReason: {
1124
+ enum: Object.values(import_cluemart_shared9.EnumImportedMarketDeactivationReason),
1125
+ required: false,
1126
+ type: String
1127
+ },
1120
1128
  deletedAt: { default: null, required: false, type: Date },
1121
1129
  description: { required: true, type: String },
1122
1130
  earliestStartDate: { default: null, required: false, type: Date },
@@ -2008,6 +2016,14 @@ schema15.index({ "licences.licenceType": 1 });
2008
2016
  schema15.index({ promoCodes: 1, active: 1, deletedAt: 1 });
2009
2017
  schema15.index({ email: "text", firstName: "text", lastName: "text" });
2010
2018
  schema15.index({ email: 1 }, { name: "email_unique", unique: true });
2019
+ schema15.index(
2020
+ { email: 1 },
2021
+ {
2022
+ collation: { locale: "en", strength: 2 },
2023
+ name: "email_unique_normalized",
2024
+ unique: true
2025
+ }
2026
+ );
2011
2027
  schema15.index({ "associatedResources.events": 1 });
2012
2028
  schema15.index({ "associatedResources.partners": 1 });
2013
2029
  schema15.index({ "associatedResources.vendors": 1 });
@@ -4342,24 +4358,83 @@ async function updateAllEventDateTimeStatuses() {
4342
4358
  }
4343
4359
 
4344
4360
  // src/service/index.ts
4345
- var import_cluemart_shared39 = require("@timardex/cluemart-shared");
4361
+ var import_cluemart_shared40 = require("@timardex/cluemart-shared");
4346
4362
 
4347
4363
  // src/service/event/findEventOrImportedMarketById.ts
4348
- async function findEventOrImportedMarketById(resourceId) {
4349
- if (!resourceId) {
4350
- return null;
4364
+ var import_cluemart_shared32 = require("@timardex/cluemart-shared");
4365
+
4366
+ // src/service/event/resourceVisibility.ts
4367
+ var LIVE_RESOURCE_FILTER = { active: true, deletedAt: null };
4368
+ function isLiveResource(resource) {
4369
+ return resource.active === true && resource.deletedAt == null;
4370
+ }
4371
+
4372
+ // src/service/event/findEventOrImportedMarketById.ts
4373
+ var EVENT_REFERENCE_FIELDS = "_id active dateTime deletedAt name owner";
4374
+ var IMPORTED_MARKET_REFERENCE_FIELDS = "_id active dateTime deletedAt name";
4375
+ var AI_IMPORTED_MARKET_REFERENCE_FIELDS = `${IMPORTED_MARKET_REFERENCE_FIELDS} reviewStatus`;
4376
+ function isAddressableAiImport(market, includeDeleted) {
4377
+ const isApproved = market.reviewStatus === import_cluemart_shared32.EnumImportedMarketReviewStatus.APPROVED;
4378
+ return includeDeleted ? isApproved || market.deletedAt != null : isApproved && isLiveResource(market);
4379
+ }
4380
+ function pickMatch(eventDoc, googleImportedDoc, aiImportedDoc, includeDeleted) {
4381
+ if (eventDoc && (includeDeleted || isLiveResource(eventDoc))) {
4382
+ return { doc: eventDoc, kind: "event" };
4383
+ }
4384
+ if (googleImportedDoc && (includeDeleted || isLiveResource(googleImportedDoc))) {
4385
+ return { doc: googleImportedDoc, kind: "google" };
4386
+ }
4387
+ if (aiImportedDoc && isAddressableAiImport(aiImportedDoc, includeDeleted)) {
4388
+ return { doc: aiImportedDoc, kind: "ai" };
4351
4389
  }
4352
- const normalizedId = convertObjectIdsToStrings(resourceId);
4353
- const [eventDoc, googleImportedDoc, aiImportedDoc] = await Promise.all([
4354
- EventModel.findById(normalizedId).select("_id name dateTime owner").lean().exec(),
4355
- GoogleImportedMarketModel.findById(normalizedId).select("_id name dateTime").lean().exec(),
4356
- AiImportedMarketModel.findById(normalizedId).select("_id name dateTime").lean().exec()
4390
+ return null;
4391
+ }
4392
+ function normalizeLookupId(resourceId) {
4393
+ return resourceId ? convertObjectIdsToStrings(resourceId) : null;
4394
+ }
4395
+ async function findReferenceRows(normalizedId) {
4396
+ return Promise.all([
4397
+ EventModel.findById(normalizedId).select(EVENT_REFERENCE_FIELDS).lean().exec(),
4398
+ GoogleImportedMarketModel.findById(normalizedId).select(IMPORTED_MARKET_REFERENCE_FIELDS).lean().exec(),
4399
+ AiImportedMarketModel.findById(normalizedId).select(AI_IMPORTED_MARKET_REFERENCE_FIELDS).lean().exec()
4357
4400
  ]);
4358
- return eventDoc ?? googleImportedDoc ?? aiImportedDoc;
4401
+ }
4402
+ async function findDetailRows(normalizedId) {
4403
+ return Promise.all([
4404
+ EventModel.findById(normalizedId).lean().exec(),
4405
+ GoogleImportedMarketModel.findById(normalizedId).lean().exec(),
4406
+ AiImportedMarketModel.findById(normalizedId).lean().exec()
4407
+ ]);
4408
+ }
4409
+ async function findEventOrImportedMarketById(resourceId, options = {}) {
4410
+ const normalizedId = normalizeLookupId(resourceId);
4411
+ if (!normalizedId) {
4412
+ return null;
4413
+ }
4414
+ const [eventDoc, googleImportedDoc, aiImportedDoc] = await findReferenceRows(normalizedId);
4415
+ return pickMatch(
4416
+ eventDoc,
4417
+ googleImportedDoc,
4418
+ aiImportedDoc,
4419
+ options.includeDeleted ?? false
4420
+ );
4421
+ }
4422
+ async function findEventOrImportedMarketDetailsById(resourceId, options = {}) {
4423
+ const normalizedId = normalizeLookupId(resourceId);
4424
+ if (!normalizedId) {
4425
+ return null;
4426
+ }
4427
+ const [eventDoc, googleImportedDoc, aiImportedDoc] = await findDetailRows(normalizedId);
4428
+ return pickMatch(
4429
+ eventDoc,
4430
+ googleImportedDoc,
4431
+ aiImportedDoc,
4432
+ options.includeDeleted ?? false
4433
+ );
4359
4434
  }
4360
4435
 
4361
4436
  // src/service/relations.ts
4362
- var import_cluemart_shared32 = require("@timardex/cluemart-shared");
4437
+ var import_cluemart_shared33 = require("@timardex/cluemart-shared");
4363
4438
  function didRemoveAnyEventDates(previousDateTime, nextDateTime) {
4364
4439
  if (!previousDateTime?.length) {
4365
4440
  return false;
@@ -4375,8 +4450,8 @@ function didRemoveAnyStartedDates(previousDateTime, nextDateTime) {
4375
4450
  return false;
4376
4451
  }
4377
4452
  return previousDateTime.some(
4378
- (prev) => prev.dateStatus === import_cluemart_shared32.EnumEventDateStatus.STARTED && !nextDateTime?.some(
4379
- (next) => next.startDate === prev.startDate && next.startTime === prev.startTime && next.dateStatus === import_cluemart_shared32.EnumEventDateStatus.STARTED
4453
+ (prev) => prev.dateStatus === import_cluemart_shared33.EnumEventDateStatus.STARTED && !nextDateTime?.some(
4454
+ (next) => next.startDate === prev.startDate && next.startTime === prev.startTime && next.dateStatus === import_cluemart_shared33.EnumEventDateStatus.STARTED
4380
4455
  )
4381
4456
  );
4382
4457
  }
@@ -4387,7 +4462,7 @@ function updateRelationDatesToCanceled(relationDates, eventDateTime) {
4387
4462
  ) ?? false;
4388
4463
  return {
4389
4464
  ...relationDate,
4390
- status: existsInEvent ? relationDate.status : import_cluemart_shared32.EnumInviteStatus.CANCELED
4465
+ status: existsInEvent ? relationDate.status : import_cluemart_shared33.EnumInviteStatus.CANCELED
4391
4466
  };
4392
4467
  });
4393
4468
  }
@@ -4396,15 +4471,15 @@ function updateRelationDatesToCanceled(relationDates, eventDateTime) {
4396
4471
  var import_dayjs8 = __toESM(require("dayjs"));
4397
4472
 
4398
4473
  // src/service/license/compliance/utils.ts
4399
- var import_cluemart_shared37 = require("@timardex/cluemart-shared");
4474
+ var import_cluemart_shared38 = require("@timardex/cluemart-shared");
4400
4475
  var import_dayjs7 = __toESM(require("dayjs"));
4401
4476
 
4402
4477
  // src/service/license/compliance/event.ts
4403
- var import_cluemart_shared33 = require("@timardex/cluemart-shared");
4478
+ var import_cluemart_shared34 = require("@timardex/cluemart-shared");
4404
4479
  var eventLicences = [
4405
- import_cluemart_shared33.EnumUserLicence.STANDARD_EVENT,
4406
- import_cluemart_shared33.EnumUserLicence.PRO_EVENT,
4407
- import_cluemart_shared33.EnumUserLicence.PRO_PLUS_EVENT
4480
+ import_cluemart_shared34.EnumUserLicence.STANDARD_EVENT,
4481
+ import_cluemart_shared34.EnumUserLicence.PRO_EVENT,
4482
+ import_cluemart_shared34.EnumUserLicence.PRO_PLUS_EVENT
4408
4483
  ];
4409
4484
  async function handleEventLicenceCompliance(user, now) {
4410
4485
  if (!user.licences || !user.events?.length) {
@@ -4616,9 +4691,9 @@ function buildLicenceExpiryPipeline(params) {
4616
4691
  }
4617
4692
 
4618
4693
  // src/service/license/compliance/partner.ts
4619
- var import_cluemart_shared34 = require("@timardex/cluemart-shared");
4694
+ var import_cluemart_shared35 = require("@timardex/cluemart-shared");
4620
4695
  var partnerLicences = [
4621
- import_cluemart_shared34.EnumUserLicence.STANDARD_PARTNER
4696
+ import_cluemart_shared35.EnumUserLicence.STANDARD_PARTNER
4622
4697
  ];
4623
4698
  async function handlePartnerLicenceCompliance(user, now) {
4624
4699
  if (!user.licences || !user.partner) {
@@ -4628,11 +4703,11 @@ async function handlePartnerLicenceCompliance(user, now) {
4628
4703
  }
4629
4704
 
4630
4705
  // src/service/license/compliance/vendor.ts
4631
- var import_cluemart_shared36 = require("@timardex/cluemart-shared");
4706
+ var import_cluemart_shared37 = require("@timardex/cluemart-shared");
4632
4707
  var import_dayjs6 = __toESM(require("dayjs"));
4633
4708
 
4634
4709
  // src/service/license/models.ts
4635
- var import_cluemart_shared35 = require("@timardex/cluemart-shared");
4710
+ var import_cluemart_shared36 = require("@timardex/cluemart-shared");
4636
4711
  var import_dayjs5 = __toESM(require("dayjs"));
4637
4712
  var import_graphql = require("graphql");
4638
4713
  var LicenceCategory = /* @__PURE__ */ ((LicenceCategory3) => {
@@ -4644,41 +4719,41 @@ var LicenceCategory = /* @__PURE__ */ ((LicenceCategory3) => {
4644
4719
  return LicenceCategory3;
4645
4720
  })(LicenceCategory || {});
4646
4721
  var licenceCategoryMapping = {
4647
- [import_cluemart_shared35.EnumUserLicence.PRO_EVENT]: "event" /* EVENT */,
4648
- [import_cluemart_shared35.EnumUserLicence.PRO_PLUS_EVENT]: "event" /* EVENT */,
4649
- [import_cluemart_shared35.EnumUserLicence.PRO_PLUS_VENDOR]: "vendor" /* VENDOR */,
4650
- [import_cluemart_shared35.EnumUserLicence.PRO_VENDOR]: "vendor" /* VENDOR */,
4651
- [import_cluemart_shared35.EnumUserLicence.STANDARD_EVENT]: "event" /* EVENT */,
4652
- [import_cluemart_shared35.EnumUserLicence.STANDARD_PARTNER]: "partner" /* PARTNER */,
4653
- [import_cluemart_shared35.EnumUserLicence.STANDARD_VENDOR]: "vendor" /* VENDOR */,
4654
- [import_cluemart_shared35.EnumUserLicence.STANDARD_AFFILIATE]: "affiliate" /* AFFILIATE */,
4655
- [import_cluemart_shared35.EnumUserLicence.STANDARD_SCHOOL]: "school" /* SCHOOL */
4722
+ [import_cluemart_shared36.EnumUserLicence.PRO_EVENT]: "event" /* EVENT */,
4723
+ [import_cluemart_shared36.EnumUserLicence.PRO_PLUS_EVENT]: "event" /* EVENT */,
4724
+ [import_cluemart_shared36.EnumUserLicence.PRO_PLUS_VENDOR]: "vendor" /* VENDOR */,
4725
+ [import_cluemart_shared36.EnumUserLicence.PRO_VENDOR]: "vendor" /* VENDOR */,
4726
+ [import_cluemart_shared36.EnumUserLicence.STANDARD_EVENT]: "event" /* EVENT */,
4727
+ [import_cluemart_shared36.EnumUserLicence.STANDARD_PARTNER]: "partner" /* PARTNER */,
4728
+ [import_cluemart_shared36.EnumUserLicence.STANDARD_VENDOR]: "vendor" /* VENDOR */,
4729
+ [import_cluemart_shared36.EnumUserLicence.STANDARD_AFFILIATE]: "affiliate" /* AFFILIATE */,
4730
+ [import_cluemart_shared36.EnumUserLicence.STANDARD_SCHOOL]: "school" /* SCHOOL */
4656
4731
  };
4657
4732
  var licencePriority = {
4658
- [import_cluemart_shared35.EnumUserLicence.PRO_PLUS_EVENT]: 3,
4659
- [import_cluemart_shared35.EnumUserLicence.PRO_EVENT]: 2,
4660
- [import_cluemart_shared35.EnumUserLicence.STANDARD_EVENT]: 1,
4661
- [import_cluemart_shared35.EnumUserLicence.PRO_PLUS_VENDOR]: 3,
4662
- [import_cluemart_shared35.EnumUserLicence.PRO_VENDOR]: 2,
4663
- [import_cluemart_shared35.EnumUserLicence.STANDARD_VENDOR]: 1,
4664
- [import_cluemart_shared35.EnumUserLicence.STANDARD_PARTNER]: 1,
4665
- [import_cluemart_shared35.EnumUserLicence.STANDARD_AFFILIATE]: 1,
4666
- [import_cluemart_shared35.EnumUserLicence.STANDARD_SCHOOL]: 1
4733
+ [import_cluemart_shared36.EnumUserLicence.PRO_PLUS_EVENT]: 3,
4734
+ [import_cluemart_shared36.EnumUserLicence.PRO_EVENT]: 2,
4735
+ [import_cluemart_shared36.EnumUserLicence.STANDARD_EVENT]: 1,
4736
+ [import_cluemart_shared36.EnumUserLicence.PRO_PLUS_VENDOR]: 3,
4737
+ [import_cluemart_shared36.EnumUserLicence.PRO_VENDOR]: 2,
4738
+ [import_cluemart_shared36.EnumUserLicence.STANDARD_VENDOR]: 1,
4739
+ [import_cluemart_shared36.EnumUserLicence.STANDARD_PARTNER]: 1,
4740
+ [import_cluemart_shared36.EnumUserLicence.STANDARD_AFFILIATE]: 1,
4741
+ [import_cluemart_shared36.EnumUserLicence.STANDARD_SCHOOL]: 1
4667
4742
  };
4668
4743
  var standardLicences = [
4669
- import_cluemart_shared35.EnumUserLicence.STANDARD_VENDOR,
4670
- import_cluemart_shared35.EnumUserLicence.STANDARD_EVENT,
4671
- import_cluemart_shared35.EnumUserLicence.STANDARD_PARTNER
4744
+ import_cluemart_shared36.EnumUserLicence.STANDARD_VENDOR,
4745
+ import_cluemart_shared36.EnumUserLicence.STANDARD_EVENT,
4746
+ import_cluemart_shared36.EnumUserLicence.STANDARD_PARTNER
4672
4747
  ];
4673
4748
  var standardLicenceSet = new Set(standardLicences);
4674
4749
  function isStandardLicence(licence) {
4675
4750
  return standardLicenceSet.has(licence);
4676
4751
  }
4677
4752
  var proLicences = [
4678
- import_cluemart_shared35.EnumUserLicence.PRO_EVENT,
4679
- import_cluemart_shared35.EnumUserLicence.PRO_PLUS_EVENT,
4680
- import_cluemart_shared35.EnumUserLicence.PRO_VENDOR,
4681
- import_cluemart_shared35.EnumUserLicence.PRO_PLUS_VENDOR
4753
+ import_cluemart_shared36.EnumUserLicence.PRO_EVENT,
4754
+ import_cluemart_shared36.EnumUserLicence.PRO_PLUS_EVENT,
4755
+ import_cluemart_shared36.EnumUserLicence.PRO_VENDOR,
4756
+ import_cluemart_shared36.EnumUserLicence.PRO_PLUS_VENDOR
4682
4757
  ];
4683
4758
  var proLicenceSet = new Set(proLicences);
4684
4759
  function isProLicence(licence) {
@@ -4692,11 +4767,11 @@ var categoryRegexMapping = {
4692
4767
  ["school" /* SCHOOL */]: /_school$/
4693
4768
  };
4694
4769
  var categoryFallbackLicence = {
4695
- ["event" /* EVENT */]: import_cluemart_shared35.EnumUserLicence.STANDARD_EVENT,
4696
- ["partner" /* PARTNER */]: import_cluemart_shared35.EnumUserLicence.STANDARD_PARTNER,
4697
- ["vendor" /* VENDOR */]: import_cluemart_shared35.EnumUserLicence.STANDARD_VENDOR,
4698
- ["affiliate" /* AFFILIATE */]: import_cluemart_shared35.EnumUserLicence.STANDARD_AFFILIATE,
4699
- ["school" /* SCHOOL */]: import_cluemart_shared35.EnumUserLicence.STANDARD_SCHOOL
4770
+ ["event" /* EVENT */]: import_cluemart_shared36.EnumUserLicence.STANDARD_EVENT,
4771
+ ["partner" /* PARTNER */]: import_cluemart_shared36.EnumUserLicence.STANDARD_PARTNER,
4772
+ ["vendor" /* VENDOR */]: import_cluemart_shared36.EnumUserLicence.STANDARD_VENDOR,
4773
+ ["affiliate" /* AFFILIATE */]: import_cluemart_shared36.EnumUserLicence.STANDARD_AFFILIATE,
4774
+ ["school" /* SCHOOL */]: import_cluemart_shared36.EnumUserLicence.STANDARD_SCHOOL
4700
4775
  };
4701
4776
  var LicenceFilterInput = {
4702
4777
  INPUT_USER_LICENCES: "$licences"
@@ -4726,11 +4801,11 @@ function getHighestLicenceForCategory(licences, category) {
4726
4801
  function createLicenceObject(expiryDate, licenceType) {
4727
4802
  const today = (0, import_dayjs5.default)();
4728
4803
  const expiryDateMapping = {
4729
- [import_cluemart_shared35.LicenceExpiryDate.ONE_YEAR]: today.add(1, "year").endOf("day").toDate(),
4730
- [import_cluemart_shared35.LicenceExpiryDate.ONE_MONTH]: today.add(1, "month").endOf("day").toDate(),
4731
- [import_cluemart_shared35.LicenceExpiryDate.TWO_MONTHS]: today.add(2, "month").endOf("day").toDate(),
4732
- [import_cluemart_shared35.LicenceExpiryDate.THREE_MONTHS]: today.add(3, "month").endOf("day").toDate(),
4733
- [import_cluemart_shared35.LicenceExpiryDate.SIX_MONTHS]: today.add(6, "month").endOf("day").toDate()
4804
+ [import_cluemart_shared36.LicenceExpiryDate.ONE_YEAR]: today.add(1, "year").endOf("day").toDate(),
4805
+ [import_cluemart_shared36.LicenceExpiryDate.ONE_MONTH]: today.add(1, "month").endOf("day").toDate(),
4806
+ [import_cluemart_shared36.LicenceExpiryDate.TWO_MONTHS]: today.add(2, "month").endOf("day").toDate(),
4807
+ [import_cluemart_shared36.LicenceExpiryDate.THREE_MONTHS]: today.add(3, "month").endOf("day").toDate(),
4808
+ [import_cluemart_shared36.LicenceExpiryDate.SIX_MONTHS]: today.add(6, "month").endOf("day").toDate()
4734
4809
  };
4735
4810
  const licenceObject = {
4736
4811
  expiryDate: expiryDateMapping[expiryDate],
@@ -4834,13 +4909,13 @@ async function checkOwnerHasLicence({
4834
4909
  const owner = await UserModel.findById(userId);
4835
4910
  if (!owner) throw new import_graphql.GraphQLError("Owner not found");
4836
4911
  const categoryByResource = {
4837
- [import_cluemart_shared35.EnumResourceType.EVENT]: "event" /* EVENT */,
4838
- [import_cluemart_shared35.EnumResourceType.PARTNER]: "partner" /* PARTNER */,
4839
- [import_cluemart_shared35.EnumResourceType.VENDOR]: "vendor" /* VENDOR */,
4840
- [import_cluemart_shared35.EnumResourceType.AFFILIATE]: "affiliate" /* AFFILIATE */,
4841
- [import_cluemart_shared35.EnumResourceType.SCHOOL]: "school" /* SCHOOL */
4912
+ [import_cluemart_shared36.EnumResourceType.EVENT]: "event" /* EVENT */,
4913
+ [import_cluemart_shared36.EnumResourceType.PARTNER]: "partner" /* PARTNER */,
4914
+ [import_cluemart_shared36.EnumResourceType.VENDOR]: "vendor" /* VENDOR */,
4915
+ [import_cluemart_shared36.EnumResourceType.AFFILIATE]: "affiliate" /* AFFILIATE */,
4916
+ [import_cluemart_shared36.EnumResourceType.SCHOOL]: "school" /* SCHOOL */
4842
4917
  };
4843
- if (!(0, import_cluemart_shared35.isNonVisitorResourceType)(resourceType)) {
4918
+ if (!(0, import_cluemart_shared36.isNonVisitorResourceType)(resourceType)) {
4844
4919
  throw new import_graphql.GraphQLError(`Invalid resource type: ${resourceType}.`);
4845
4920
  }
4846
4921
  const requiredCategory = categoryByResource[resourceType];
@@ -4863,9 +4938,9 @@ async function checkOwnerHasLicence({
4863
4938
  }
4864
4939
  }
4865
4940
  var resourceLicenceCategory = {
4866
- [import_cluemart_shared35.EnumResourceType.EVENT]: "event" /* EVENT */,
4867
- [import_cluemart_shared35.EnumResourceType.PARTNER]: "partner" /* PARTNER */,
4868
- [import_cluemart_shared35.EnumResourceType.VENDOR]: "vendor" /* VENDOR */
4941
+ [import_cluemart_shared36.EnumResourceType.EVENT]: "event" /* EVENT */,
4942
+ [import_cluemart_shared36.EnumResourceType.PARTNER]: "partner" /* PARTNER */,
4943
+ [import_cluemart_shared36.EnumResourceType.VENDOR]: "vendor" /* VENDOR */
4869
4944
  };
4870
4945
  function isProtectedByCurrentStripeSubscription(user, licenceType, now) {
4871
4946
  const stripe = user.stripe;
@@ -4873,14 +4948,14 @@ function isProtectedByCurrentStripeSubscription(user, licenceType, now) {
4873
4948
  return false;
4874
4949
  }
4875
4950
  const gracePeriodEndsAt = stripe.paymentGracePeriodEndsAt ? (0, import_dayjs5.default)(stripe.paymentGracePeriodEndsAt) : null;
4876
- const hasActivePaymentGracePeriod = (stripe.status === import_cluemart_shared35.EnumSubscriptionStatus.PAST_DUE || stripe.status === import_cluemart_shared35.EnumSubscriptionStatus.INACTIVE) && Boolean(stripe.paymentGraceSubscriptionId) && (!stripe.subscriptionId || stripe.subscriptionId === stripe.paymentGraceSubscriptionId) && gracePeriodEndsAt !== null && gracePeriodEndsAt.isValid() && gracePeriodEndsAt.isAfter(now);
4951
+ const hasActivePaymentGracePeriod = (stripe.status === import_cluemart_shared36.EnumSubscriptionStatus.PAST_DUE || stripe.status === import_cluemart_shared36.EnumSubscriptionStatus.INACTIVE) && Boolean(stripe.paymentGraceSubscriptionId) && (!stripe.subscriptionId || stripe.subscriptionId === stripe.paymentGraceSubscriptionId) && gracePeriodEndsAt !== null && gracePeriodEndsAt.isValid() && gracePeriodEndsAt.isAfter(now);
4877
4952
  if (hasActivePaymentGracePeriod) {
4878
4953
  return true;
4879
4954
  }
4880
4955
  if (!stripe.subscriptionId) {
4881
4956
  return false;
4882
4957
  }
4883
- if (stripe.status !== import_cluemart_shared35.EnumSubscriptionStatus.ACTIVE) {
4958
+ if (stripe.status !== import_cluemart_shared36.EnumSubscriptionStatus.ACTIVE) {
4884
4959
  return false;
4885
4960
  }
4886
4961
  if (!stripe.endDate) {
@@ -5042,7 +5117,7 @@ async function applyVendorDowngrade(vendor, ownerUserId) {
5042
5117
  return (result?.matchedCount ?? 0) > 0;
5043
5118
  }
5044
5119
  async function downgradeVendorProFeatures(userId, licenceType) {
5045
- const isStandardVendor = licenceType === import_cluemart_shared36.EnumUserLicence.STANDARD_VENDOR;
5120
+ const isStandardVendor = licenceType === import_cluemart_shared37.EnumUserLicence.STANDARD_VENDOR;
5046
5121
  if (!isStandardVendor) {
5047
5122
  return;
5048
5123
  }
@@ -5089,7 +5164,7 @@ async function applyVendorRestore(vendor, ownerUserId) {
5089
5164
  return (result?.matchedCount ?? 0) > 0;
5090
5165
  }
5091
5166
  async function restoreVendorProFeatures(userId, licenceType) {
5092
- const isProVendor = licenceType === import_cluemart_shared36.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared36.EnumUserLicence.PRO_PLUS_VENDOR;
5167
+ const isProVendor = licenceType === import_cluemart_shared37.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared37.EnumUserLicence.PRO_PLUS_VENDOR;
5093
5168
  if (!isProVendor) {
5094
5169
  return;
5095
5170
  }
@@ -5115,7 +5190,7 @@ async function handleVendorLicenceCompliance(user, now) {
5115
5190
  return;
5116
5191
  }
5117
5192
  const proLicences2 = vendorLicencesOfUser.filter(
5118
- (licence) => licence.licenceType !== import_cluemart_shared36.EnumUserLicence.STANDARD_VENDOR
5193
+ (licence) => licence.licenceType !== import_cluemart_shared37.EnumUserLicence.STANDARD_VENDOR
5119
5194
  );
5120
5195
  const expiredProLicences = proLicences2.filter(
5121
5196
  (licence) => !(0, import_dayjs6.default)(licence.expiryDate).isAfter(now)
@@ -5128,7 +5203,7 @@ async function handleVendorLicenceCompliance(user, now) {
5128
5203
  const expiredProLicence = expiredProLicences.some(
5129
5204
  (licence) => !stripeProtectedLicenceTypes.has(licence.licenceType)
5130
5205
  );
5131
- const hasValidProLicence = stripeProtectedLicenceTypes.size > 0 || hasValidLicence(proLicences2, import_cluemart_shared36.vendorLicences, now);
5206
+ const hasValidProLicence = stripeProtectedLicenceTypes.size > 0 || hasValidLicence(proLicences2, import_cluemart_shared37.vendorLicences, now);
5132
5207
  const hasExpiredVendorLicence = vendorLicencesOfUser.some(
5133
5208
  (licence) => !(0, import_dayjs6.default)(licence.expiryDate).isAfter(now) && !stripeProtectedLicenceTypes.has(licence.licenceType)
5134
5209
  );
@@ -5144,7 +5219,7 @@ async function handleVendorLicenceCompliance(user, now) {
5144
5219
  "owner.userId": user._id
5145
5220
  }).lean().exec();
5146
5221
  }
5147
- const licencesToSync = import_cluemart_shared36.vendorLicences.filter(
5222
+ const licencesToSync = import_cluemart_shared37.vendorLicences.filter(
5148
5223
  (licenceType) => !stripeProtectedLicenceTypes.has(licenceType)
5149
5224
  );
5150
5225
  await syncUserLicencesAfterExpiry(user._id, licencesToSync, now, "downgrade");
@@ -5159,11 +5234,11 @@ async function handleVendorLicenceCompliance(user, now) {
5159
5234
  data: {
5160
5235
  resourceId: String(vendor._id),
5161
5236
  resourceName: vendor.name,
5162
- resourceType: import_cluemart_shared36.EnumNotificationResourceType.DOWNGRADED_VENDOR
5237
+ resourceType: import_cluemart_shared37.EnumNotificationResourceType.DOWNGRADED_VENDOR
5163
5238
  },
5164
5239
  message: `Your Vendor licence has been downgraded due to licence expiration.`,
5165
5240
  title: `Vendor Licence Downgraded`,
5166
- type: import_cluemart_shared36.EnumNotificationType.SYSTEM,
5241
+ type: import_cluemart_shared37.EnumNotificationType.SYSTEM,
5167
5242
  userIds: [user._id]
5168
5243
  };
5169
5244
  await sendDeactivationNotification(payload, user._id, vendor.name, "vendor");
@@ -5179,7 +5254,7 @@ async function vendorOwnerHasProLicence(vendorId) {
5179
5254
  }
5180
5255
  return hasActiveProLicenceForResource({
5181
5256
  includeStripeProtected: true,
5182
- resourceType: import_cluemart_shared36.EnumResourceType.VENDOR,
5257
+ resourceType: import_cluemart_shared37.EnumResourceType.VENDOR,
5183
5258
  userId: vendor.owner.userId
5184
5259
  });
5185
5260
  }
@@ -5191,12 +5266,12 @@ async function syncUserLicencesAfterExpiry(userId, licenceTypes, now, mode = "do
5191
5266
  const pipeline = buildLicenceExpiryPipeline({
5192
5267
  downgradeBranches: [
5193
5268
  {
5194
- case: import_cluemart_shared37.EnumUserLicence.PRO_PLUS_VENDOR,
5195
- then: import_cluemart_shared37.EnumUserLicence.STANDARD_VENDOR
5269
+ case: import_cluemart_shared38.EnumUserLicence.PRO_PLUS_VENDOR,
5270
+ then: import_cluemart_shared38.EnumUserLicence.STANDARD_VENDOR
5196
5271
  },
5197
5272
  {
5198
- case: import_cluemart_shared37.EnumUserLicence.PRO_VENDOR,
5199
- then: import_cluemart_shared37.EnumUserLicence.STANDARD_VENDOR
5273
+ case: import_cluemart_shared38.EnumUserLicence.PRO_VENDOR,
5274
+ then: import_cluemart_shared38.EnumUserLicence.STANDARD_VENDOR
5200
5275
  }
5201
5276
  ],
5202
5277
  licenceTypes,
@@ -5325,7 +5400,7 @@ var REMINDER_WINDOW_MIN_HOURS = 6.5 * 24;
5325
5400
  var REMINDER_WINDOW_MAX_HOURS = 7.5 * 24;
5326
5401
 
5327
5402
  // src/service/license/reminder/utils.ts
5328
- var import_cluemart_shared38 = require("@timardex/cluemart-shared");
5403
+ var import_cluemart_shared39 = require("@timardex/cluemart-shared");
5329
5404
  var import_utils8 = require("@timardex/cluemart-shared/utils");
5330
5405
  var import_dayjs9 = __toESM(require("dayjs"));
5331
5406
 
@@ -5391,28 +5466,28 @@ function isLicenseExpiringIn7Days(expiryDate, now) {
5391
5466
  return hoursUntilExpiry >= REMINDER_WINDOW_MIN_HOURS && hoursUntilExpiry <= REMINDER_WINDOW_MAX_HOURS;
5392
5467
  }
5393
5468
  function getLicenseName(licenceType) {
5394
- return import_cluemart_shared38.licenseNiceNames[licenceType] || licenceType;
5469
+ return import_cluemart_shared39.licenseNiceNames[licenceType] || licenceType;
5395
5470
  }
5396
5471
  function getNotificationTypes(isVendorLicense, isPartnerLicense) {
5397
5472
  if (isVendorLicense) {
5398
5473
  return {
5399
- notificationType: import_cluemart_shared38.EnumNotificationType.SYSTEM,
5400
- resourceType: import_cluemart_shared38.EnumNotificationResourceType.EXPIRATION_REMINDER_VENDOR
5474
+ notificationType: import_cluemart_shared39.EnumNotificationType.SYSTEM,
5475
+ resourceType: import_cluemart_shared39.EnumNotificationResourceType.EXPIRATION_REMINDER_VENDOR
5401
5476
  };
5402
5477
  }
5403
5478
  if (isPartnerLicense) {
5404
5479
  return {
5405
- notificationType: import_cluemart_shared38.EnumNotificationType.SYSTEM,
5406
- resourceType: import_cluemart_shared38.EnumNotificationResourceType.EXPIRATION_REMINDER_PARTNER
5480
+ notificationType: import_cluemart_shared39.EnumNotificationType.SYSTEM,
5481
+ resourceType: import_cluemart_shared39.EnumNotificationResourceType.EXPIRATION_REMINDER_PARTNER
5407
5482
  };
5408
5483
  }
5409
5484
  return {
5410
- notificationType: import_cluemart_shared38.EnumNotificationType.SYSTEM,
5411
- resourceType: import_cluemart_shared38.EnumNotificationResourceType.EXPIRATION_REMINDER_EVENT
5485
+ notificationType: import_cluemart_shared39.EnumNotificationType.SYSTEM,
5486
+ resourceType: import_cluemart_shared39.EnumNotificationResourceType.EXPIRATION_REMINDER_EVENT
5412
5487
  };
5413
5488
  }
5414
5489
  async function getLicenseResourceInfo(user, licence) {
5415
- const isVendorLicense = import_cluemart_shared38.vendorLicences.includes(licence.licenceType);
5490
+ const isVendorLicense = import_cluemart_shared39.vendorLicences.includes(licence.licenceType);
5416
5491
  const isPartnerLicense = partnerLicences.includes(licence.licenceType);
5417
5492
  const licenceName = getLicenseName(licence.licenceType);
5418
5493
  const { notificationType, resourceType } = getNotificationTypes(
@@ -5460,11 +5535,11 @@ async function getLicenseResourceInfo(user, licence) {
5460
5535
  };
5461
5536
  }
5462
5537
  function getLicenceExpiryMode(licenceType) {
5463
- return licenceType === import_cluemart_shared38.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared38.EnumUserLicence.PRO_PLUS_VENDOR ? "downgrade" : "extend";
5538
+ return licenceType === import_cluemart_shared39.EnumUserLicence.PRO_VENDOR || licenceType === import_cluemart_shared39.EnumUserLicence.PRO_PLUS_VENDOR ? "downgrade" : "extend";
5464
5539
  }
5465
5540
  async function sendLicenseReminder(user, licence) {
5466
5541
  const licenceName = getLicenseName(licence.licenceType);
5467
- const expiryDate = (0, import_dayjs9.default)(licence.expiryDate).format(import_cluemart_shared38.dateFormat);
5542
+ const expiryDate = (0, import_dayjs9.default)(licence.expiryDate).format(import_cluemart_shared39.dateFormat);
5468
5543
  const userId = String(user._id);
5469
5544
  const resourceInfo = await getLicenseResourceInfo(user, licence);
5470
5545
  if (!resourceInfo) {
@@ -5590,6 +5665,7 @@ async function remindUsersAboutLicenseExpiration() {
5590
5665
  // Annotate the CommonJS export names for ESM import in node:
5591
5666
  0 && (module.exports = {
5592
5667
  ACTIVE_NOT_DELETED_FILTER,
5668
+ LIVE_RESOURCE_FILTER,
5593
5669
  LicenceCategory,
5594
5670
  REMINDER_WINDOW_MAX_HOURS,
5595
5671
  REMINDER_WINDOW_MIN_HOURS,
@@ -5620,6 +5696,7 @@ async function remindUsersAboutLicenseExpiration() {
5620
5696
  eventLicences,
5621
5697
  findAffiliateByPromoCode,
5622
5698
  findEventOrImportedMarketById,
5699
+ findEventOrImportedMarketDetailsById,
5623
5700
  getActiveLicenceForResource,
5624
5701
  getAssociateAccessMeta,
5625
5702
  getEventResourceInfo,
@@ -5640,6 +5717,7 @@ async function remindUsersAboutLicenseExpiration() {
5640
5717
  hasActiveProLicenceForResource,
5641
5718
  hasValidLicence,
5642
5719
  isAssociableResourceType,
5720
+ isLiveResource,
5643
5721
  isProLicence,
5644
5722
  isProtectedByCurrentStripeSubscription,
5645
5723
  isStandardLicence,