@timardex/cluemart-server-shared 1.0.158 → 1.0.160

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -694,16 +694,6 @@ declare function sendPushNotifications({ data, message, title, userIds, }: Schem
694
694
  */
695
695
  declare function updateAdStatuses(): Promise<void>;
696
696
 
697
- /**
698
- *
699
- * This function updates the vendor's features based on the user's license.
700
- * It checks the type of license and updates the vendor's associates and availability accordingly.
701
- * If the user has a Pro Vendor license, they can have multiple associates and access to all availability types.
702
- * If they have a Standard Vendor license, their associates are removed and availability is restricted.
703
- * @param userId
704
- * @param licenceType
705
- * @returns
706
- */
707
697
  declare function updateVendorBasedOnUserLicense(userId: ObjectId, licenceType: EnumUserLicence): Promise<void>;
708
698
 
709
699
  /**
package/dist/index.d.ts CHANGED
@@ -694,16 +694,6 @@ declare function sendPushNotifications({ data, message, title, userIds, }: Schem
694
694
  */
695
695
  declare function updateAdStatuses(): Promise<void>;
696
696
 
697
- /**
698
- *
699
- * This function updates the vendor's features based on the user's license.
700
- * It checks the type of license and updates the vendor's associates and availability accordingly.
701
- * If the user has a Pro Vendor license, they can have multiple associates and access to all availability types.
702
- * If they have a Standard Vendor license, their associates are removed and availability is restricted.
703
- * @param userId
704
- * @param licenceType
705
- * @returns
706
- */
707
697
  declare function updateVendorBasedOnUserLicense(userId: ObjectId, licenceType: EnumUserLicence): Promise<void>;
708
698
 
709
699
  /**
package/dist/index.mjs CHANGED
@@ -8491,6 +8491,21 @@ var EVENT_LIST_ITEM = gql`
8491
8491
  ${RESOURCE_IMAGE_FIELDS_FRAGMENT}
8492
8492
  ${RELATION_DATES_FRAGMENT}
8493
8493
  `;
8494
+ var UNREGISTERED_VENDOR_LIST_ITEM_FIELDS_FRAGMENT = gql`
8495
+ fragment UnregisteredVendorListItemFields on UnregisteredVendorListItemType {
8496
+ _id
8497
+ categoryIds
8498
+ email
8499
+ invitations {
8500
+ dateTime {
8501
+ ...DateTimeFields
8502
+ }
8503
+ eventId
8504
+ }
8505
+ name
8506
+ }
8507
+ ${DATETIME_FIELDS_FRAGMENT}
8508
+ `;
8494
8509
  var EVENT_INFO = gql`
8495
8510
  fragment EventInfoFields on EventInfoType {
8496
8511
  _id
@@ -8579,10 +8594,11 @@ var EVENT = gql`
8579
8594
  }
8580
8595
  rating
8581
8596
  reviewCount
8597
+ rainOrShine
8598
+ unregisteredVendorIds
8582
8599
  socialMedia {
8583
8600
  ...SocialMediaFields
8584
8601
  }
8585
- rainOrShine
8586
8602
  tags
8587
8603
  termsAgreement {
8588
8604
  ...TermsAgreementFields
@@ -8813,23 +8829,19 @@ var VENDOR_INFO = gql`
8813
8829
  `;
8814
8830
  var UNREGISTERED_VENDOR_INVITATION_FRAGMENT = gql`
8815
8831
  fragment UnregisteredVendorInvitationFields on UnregisteredVendorInvitationType {
8816
- dateTime {
8817
- ...DateTimeFields
8818
- }
8819
- eventId
8820
- location {
8821
- ...LocationFields
8832
+ invitations {
8833
+ dateTime {
8834
+ ...DateTimeFields
8835
+ }
8836
+ eventId
8822
8837
  }
8823
8838
  }
8824
8839
  ${DATETIME_FIELDS_FRAGMENT}
8825
- ${LOCATION_FIELDS_FRAGMENT}
8826
8840
  `;
8827
8841
  var UNREGISTERED_VENDOR = gql`
8828
8842
  fragment UnregisteredVendorFields on UnregisteredVendorType {
8829
8843
  _id
8830
- categories {
8831
- ...CategoryFields
8832
- }
8844
+ categoryIds
8833
8845
  createdAt
8834
8846
  deletedAt
8835
8847
  email
@@ -8837,10 +8849,8 @@ var UNREGISTERED_VENDOR = gql`
8837
8849
  ...UnregisteredVendorInvitationFields
8838
8850
  }
8839
8851
  name
8840
- region
8841
8852
  updatedAt
8842
8853
  }
8843
- ${CATEGORY_FIELDS_FRAGMENT}
8844
8854
  ${UNREGISTERED_VENDOR_INVITATION_FRAGMENT}
8845
8855
  `;
8846
8856
  var GET_VENDORS = gql`
@@ -10306,10 +10316,20 @@ var SCHOOL_REGISTERED_USERS_FIELDS_FRAGMENT = gql`
10306
10316
  }
10307
10317
  ${RESOURCE_IMAGE_FIELDS_FRAGMENT}
10308
10318
  `;
10319
+ var SCHOOL_CAMPAIGN_FIELDS_FRAGMENT = gql`
10320
+ fragment SchoolCampaignFields on SchoolCampaignType {
10321
+ endDate
10322
+ name
10323
+ startDate
10324
+ }
10325
+ `;
10309
10326
  var SCHOOL = gql`
10310
10327
  fragment SchoolFields on SchoolType {
10311
10328
  _id
10312
10329
  active
10330
+ campaigns {
10331
+ ...SchoolCampaignFields
10332
+ }
10313
10333
  contactDetails {
10314
10334
  ...ContactDetailsFields
10315
10335
  }
@@ -10344,6 +10364,7 @@ var SCHOOL = gql`
10344
10364
  ${CONTACT_DETAILS_FIELDS_FRAGMENT}
10345
10365
  ${TERMS_AGREEMENT_FIELDS_FRAGMENT}
10346
10366
  ${SOCIAL_MEDIA_FIELDS_FRAGMENT}
10367
+ ${SCHOOL_CAMPAIGN_FIELDS_FRAGMENT}
10347
10368
  `;
10348
10369
  var GET_SCHOOL = gql`
10349
10370
  query getSchool($_id: ID!) {
@@ -10686,17 +10707,9 @@ var vendorSchema = globalResourceSchema.shape({
10686
10707
  vendorType: create$8().oneOf(Object.values(EnumVendorType)).required("Please select a Vendor type")
10687
10708
  });
10688
10709
  var unregisteredVendorSchema = create$3().shape({
10689
- categories: categorySchema.min(1, "Category list must contain at least one item").required("Categories are required"),
10690
- email: emailRequiredSchema,
10691
- invitations: create$2().of(
10692
- create$3({
10693
- dateTime: create$2().of(dateTimeSchema).required("DateTime is required"),
10694
- eventId: create$6().required("Event ID is required"),
10695
- location: locationSchema
10696
- })
10697
- ).nullable().default(null),
10698
- name: create$6().label("Name").trim().min(3).max(40).required("Name is required"),
10699
- region: create$6().label("Region").required("Region is required")
10710
+ categoryIds: create$2().of(create$6().defined()).min(1, "Category list must contain at least one item").required("Categories are required"),
10711
+ email: emailOptionalSchema,
10712
+ name: create$6().label("Stallholder Name").trim().min(3, "Name must be at least 3 characters").required("Name is required")
10700
10713
  });
10701
10714
  var vendorInfoSchema = create$3().shape({
10702
10715
  product: create$3().shape({
@@ -11035,7 +11048,12 @@ var posterIds = [
11035
11048
  "mini-market5",
11036
11049
  "poster1",
11037
11050
  "poster2",
11038
- "poster3"
11051
+ "poster3",
11052
+ // New
11053
+ "poster4",
11054
+ "poster5",
11055
+ "poster6",
11056
+ "poster7"
11039
11057
  ];
11040
11058
  var posterFiles = Object.fromEntries(
11041
11059
  posterIds.map((id) => [id, `${id}${IMAGE_EXTENSION}`])
@@ -12525,10 +12543,19 @@ var GameModel = mongoose22.models.Game || mongoose22.model("Game", schema14);
12525
12543
  // src/mongoose/School.ts
12526
12544
  import mongoose23 from "mongoose";
12527
12545
  var MongooseSchema23 = mongoose23.Schema;
12546
+ var campaignsSchema = new MongooseSchema23(
12547
+ {
12548
+ endDate: { required: true, type: Date },
12549
+ name: { required: true, type: String },
12550
+ startDate: { required: true, type: Date }
12551
+ },
12552
+ { _id: false }
12553
+ );
12528
12554
  var schema15 = new MongooseSchema23(
12529
12555
  {
12530
12556
  // New schools are active by default
12531
12557
  active: { default: true, required: true, type: Boolean },
12558
+ campaigns: { required: false, type: [campaignsSchema] },
12532
12559
  contactDetails: { required: false, type: ContactDetailsSchema },
12533
12560
  deletedAt: { default: null, required: false, type: Date },
12534
12561
  location: {
@@ -12744,9 +12771,6 @@ async function updateAdStatuses() {
12744
12771
  );
12745
12772
  }
12746
12773
 
12747
- // src/service/vendor.ts
12748
- import mongoose26 from "mongoose";
12749
-
12750
12774
  // src/service/associate.ts
12751
12775
  import mongoose25 from "mongoose";
12752
12776
  async function removeAssociateFromResource({
@@ -12754,11 +12778,9 @@ async function removeAssociateFromResource({
12754
12778
  resourceOwnerId,
12755
12779
  resourceType
12756
12780
  }) {
12757
- const normalizedResourceId = resourceId.toString();
12758
- const normalizedOwnerId = typeof resourceOwnerId === "string" ? new mongoose25.Types.ObjectId(resourceOwnerId) : resourceOwnerId;
12759
- const session = await mongoose25.startSession();
12760
12781
  try {
12761
- session.startTransaction();
12782
+ const normalizedResourceId = resourceId.toString();
12783
+ const normalizedOwnerId = typeof resourceOwnerId === "string" ? new mongoose25.Types.ObjectId(resourceOwnerId) : resourceOwnerId;
12762
12784
  const usersWithAssociates = await UserModel.find(
12763
12785
  {
12764
12786
  associates: {
@@ -12770,16 +12792,18 @@ async function removeAssociateFromResource({
12770
12792
  },
12771
12793
  {
12772
12794
  associates: 1
12773
- // Only fetch associates field for efficiency
12774
12795
  }
12775
- ).lean().session(session);
12776
- const associateEmails = usersWithAssociates.flatMap(
12777
- (user) => (user.associates ?? []).filter(
12778
- (assoc) => assoc.resourceId === normalizedResourceId && assoc.resourceType === resourceType
12779
- ).map((assoc) => assoc.email)
12780
- );
12796
+ ).lean();
12797
+ const associateEmails = [
12798
+ ...new Set(
12799
+ usersWithAssociates.flatMap(
12800
+ (user) => (user.associates ?? []).filter(
12801
+ (associate) => associate.resourceId === normalizedResourceId && associate.resourceType === resourceType
12802
+ ).map((associate) => associate.email)
12803
+ )
12804
+ )
12805
+ ];
12781
12806
  if (associateEmails.length === 0) {
12782
- await session.commitTransaction();
12783
12807
  return;
12784
12808
  }
12785
12809
  await UserModel.updateMany(
@@ -12798,8 +12822,7 @@ async function removeAssociateFromResource({
12798
12822
  resourceType
12799
12823
  }
12800
12824
  }
12801
- },
12802
- { session }
12825
+ }
12803
12826
  );
12804
12827
  await ChatModel.updateMany(
12805
12828
  {
@@ -12814,103 +12837,83 @@ async function removeAssociateFromResource({
12814
12837
  },
12815
12838
  {
12816
12839
  $set: {
12817
- "participants.$[assoc].active": false
12840
+ "participants.$[associate].active": false
12818
12841
  }
12819
12842
  },
12820
12843
  {
12821
12844
  arrayFilters: [
12822
12845
  {
12823
- "assoc.isAssociate": true,
12824
- "assoc.userEmail": { $in: associateEmails }
12846
+ "associate.isAssociate": true,
12847
+ "associate.userEmail": {
12848
+ $in: associateEmails
12849
+ }
12825
12850
  }
12826
- ],
12827
- session
12851
+ ]
12828
12852
  }
12829
12853
  );
12830
- await session.commitTransaction();
12831
12854
  } catch (error) {
12832
- await session.abortTransaction();
12833
12855
  console.error(
12834
- `[removeAssociateFromResource] Failed for resourceId=${normalizedResourceId}, resourceType=${resourceType}`,
12856
+ `[removeAssociateFromResource] Failed for resourceId=${resourceId}, resourceType=${resourceType}`,
12835
12857
  error
12836
12858
  );
12837
- throw error;
12838
- } finally {
12839
- session.endSession();
12840
12859
  }
12841
12860
  }
12842
12861
 
12843
12862
  // src/service/vendor.ts
12844
12863
  async function updateVendorBasedOnUserLicense(userId, licenceType) {
12845
- const session = await mongoose26.startSession();
12846
12864
  try {
12847
- session.startTransaction();
12848
- const user = await UserModel.findById(userId).select("vendor").lean().session(session);
12865
+ const user = await UserModel.findById(userId).select("vendor").lean();
12849
12866
  if (!user?.vendor) {
12850
- console.warn(`[updateVendor] No vendor for userId=${userId}`);
12851
- await session.abortTransaction();
12867
+ console.warn(`[updateVendor] No vendor found for userId=${userId}`);
12852
12868
  return;
12853
12869
  }
12854
- const vendor = await VendorModel.findById(user.vendor).lean().session(session);
12870
+ const vendor = await VendorModel.findById(user.vendor).lean();
12855
12871
  if (!vendor) {
12856
12872
  console.warn(`[updateVendor] Vendor not found for id=${user.vendor}`);
12857
- await session.abortTransaction();
12858
12873
  return;
12859
12874
  }
12860
- const vendorUpdateData = {};
12861
- if (licenceType === EnumUserLicence.STANDARD_VENDOR) {
12862
- vendorUpdateData.associates = [];
12863
- vendorUpdateData.availability = {
12875
+ const updateData = {};
12876
+ const isStandardVendor = licenceType === EnumUserLicence.STANDARD_VENDOR;
12877
+ if (isStandardVendor) {
12878
+ updateData.associates = [];
12879
+ updateData.availability = {
12864
12880
  corporate: false,
12865
12881
  private: false,
12866
12882
  school: false
12867
12883
  };
12868
- vendorUpdateData.products = {
12884
+ updateData.products = {
12869
12885
  active: false,
12870
12886
  productsList: vendor.products?.productsList ?? []
12871
12887
  };
12872
- vendorUpdateData.calendar = {
12888
+ updateData.calendar = {
12873
12889
  active: false,
12874
12890
  calendarData: vendor.calendar?.calendarData ?? []
12875
12891
  };
12876
- vendorUpdateData.images = (vendor.images ?? []).map((img, index) => ({
12877
- ...img,
12878
- active: index < 6
12879
- }));
12880
- } else {
12881
- vendorUpdateData.images = (vendor.images ?? []).map((img) => ({
12882
- ...img,
12883
- active: true
12884
- }));
12885
12892
  }
12886
- await VendorModel.updateOne(
12887
- { _id: vendor._id },
12888
- { $set: vendorUpdateData },
12889
- { session }
12890
- );
12891
- if (licenceType === EnumUserLicence.STANDARD_VENDOR) {
12893
+ updateData.images = (vendor.images ?? []).map((image, index) => ({
12894
+ ...image,
12895
+ active: isStandardVendor ? index < 6 : true
12896
+ }));
12897
+ await VendorModel.updateOne({ _id: vendor._id }, { $set: updateData });
12898
+ if (isStandardVendor) {
12892
12899
  await removeAssociateFromResource({
12893
12900
  resourceId: vendor._id,
12894
12901
  resourceOwnerId: vendor.owner.userId,
12895
12902
  resourceType: EnumResourceType.VENDOR
12896
12903
  });
12897
12904
  }
12898
- await session.commitTransaction();
12899
12905
  } catch (error) {
12900
- await session.abortTransaction();
12901
12906
  console.error("[updateVendorBasedOnUserLicense] Failed:", error);
12902
- } finally {
12903
- session.endSession();
12904
12907
  }
12905
12908
  }
12906
12909
 
12907
12910
  // src/service/objectIdToString.ts
12908
- import mongoose27 from "mongoose";
12911
+ import mongoose26 from "mongoose";
12909
12912
  function convertObjectIdsToStrings(obj) {
12910
12913
  if (obj === null || obj === void 0) {
12911
12914
  return obj;
12912
12915
  }
12913
- if (obj instanceof mongoose27.Types.ObjectId) {
12916
+ if (obj instanceof mongoose26.Types.ObjectId) {
12914
12917
  return obj.toString();
12915
12918
  }
12916
12919
  if (Array.isArray(obj)) {
@@ -12941,7 +12944,7 @@ async function findEventOrImportedMarketById(resourceId) {
12941
12944
 
12942
12945
  // src/types/index.ts
12943
12946
  import express from "express";
12944
- import mongoose28 from "mongoose";
12947
+ import mongoose27 from "mongoose";
12945
12948
  var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
12946
12949
  EnumPubSubEvents2["GET_CHAT_MESSAGE"] = "GET_CHAT_MESSAGE";
12947
12950
  EnumPubSubEvents2["GET_NOTIFICATIONS"] = "GET_NOTIFICATIONS";
@@ -12987,7 +12990,7 @@ export {
12987
12990
  findEventOrImportedMarketById,
12988
12991
  locationGeoSchema,
12989
12992
  locationsSchema,
12990
- mongoose28 as mongoose,
12993
+ mongoose27 as mongoose,
12991
12994
  refundPolicySchema,
12992
12995
  relationDatesSchema,
12993
12996
  resourceRelationsSchema,