@timardex/cluemart-server-shared 1.0.143 → 1.0.145

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.
@@ -12393,6 +12393,7 @@ var schema15 = new MongooseSchema20(
12393
12393
  var SchoolModel = mongoose20.models.School || mongoose20.model("School", schema15);
12394
12394
 
12395
12395
  export {
12396
+ EnumResourceType,
12396
12397
  EnumUserLicence,
12397
12398
  EnumAdStatus,
12398
12399
  AdModel,
@@ -12458,4 +12459,4 @@ react/cjs/react.development.js:
12458
12459
  * LICENSE file in the root directory of this source tree.
12459
12460
  *)
12460
12461
  */
12461
- //# sourceMappingURL=chunk-FA5DXWVE.mjs.map
12462
+ //# sourceMappingURL=chunk-ZKCRLNCH.mjs.map
package/dist/index.cjs CHANGED
@@ -1711,7 +1711,7 @@ __export(index_exports, {
1711
1711
  findEventOrImportedMarketById: () => findEventOrImportedMarketById,
1712
1712
  locationGeoSchema: () => locationGeoSchema,
1713
1713
  locationsSchema: () => locationsSchema,
1714
- mongoose: () => import_mongoose26.default,
1714
+ mongoose: () => import_mongoose27.default,
1715
1715
  refundPolicySchema: () => refundPolicySchema,
1716
1716
  relationDatesSchema: () => relationDatesSchema,
1717
1717
  resourceRelationsSchema: () => resourceRelationsSchema,
@@ -12665,6 +12665,37 @@ async function updateAdStatuses() {
12665
12665
  );
12666
12666
  }
12667
12667
 
12668
+ // src/service/associate.ts
12669
+ async function removeAssociateFromResource(resourceId, resourceType) {
12670
+ const normalizedResourceId = resourceId.toString();
12671
+ try {
12672
+ await UserModel.updateMany(
12673
+ {
12674
+ associates: {
12675
+ $elemMatch: {
12676
+ resourceId: normalizedResourceId,
12677
+ resourceType
12678
+ }
12679
+ }
12680
+ },
12681
+ {
12682
+ $pull: {
12683
+ associates: {
12684
+ resourceId: normalizedResourceId,
12685
+ resourceType
12686
+ }
12687
+ }
12688
+ }
12689
+ ).exec();
12690
+ } catch (error) {
12691
+ console.error(
12692
+ `[removeAssociateFromResource] Failed to remove associates for resourceId=${normalizedResourceId}, resourceType=${resourceType}`,
12693
+ error
12694
+ );
12695
+ throw error;
12696
+ }
12697
+ }
12698
+
12668
12699
  // src/service/vendor.ts
12669
12700
  async function updateVendorBasedOnUserLicense(userId, licenceType) {
12670
12701
  try {
@@ -12717,18 +12748,19 @@ async function updateVendorBasedOnUserLicense(userId, licenceType) {
12717
12748
  },
12718
12749
  { new: true }
12719
12750
  );
12751
+ await removeAssociateFromResource(userVendor._id, EnumResourceType.VENDOR);
12720
12752
  } catch (error) {
12721
12753
  console.error("Error updating vendor based on user license:", error);
12722
12754
  }
12723
12755
  }
12724
12756
 
12725
12757
  // src/service/objectIdToString.ts
12726
- var import_mongoose24 = __toESM(require("mongoose"));
12758
+ var import_mongoose25 = __toESM(require("mongoose"));
12727
12759
  function convertObjectIdsToStrings(obj) {
12728
12760
  if (obj === null || obj === void 0) {
12729
12761
  return obj;
12730
12762
  }
12731
- if (obj instanceof import_mongoose24.default.Types.ObjectId) {
12763
+ if (obj instanceof import_mongoose25.default.Types.ObjectId) {
12732
12764
  return obj.toString();
12733
12765
  }
12734
12766
  if (Array.isArray(obj)) {
@@ -12759,7 +12791,7 @@ async function findEventOrImportedMarketById(resourceId) {
12759
12791
 
12760
12792
  // src/types/index.ts
12761
12793
  var import_express = __toESM(require("express"));
12762
- var import_mongoose26 = __toESM(require("mongoose"));
12794
+ var import_mongoose27 = __toESM(require("mongoose"));
12763
12795
  var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
12764
12796
  EnumPubSubEvents2["GET_CHAT_MESSAGE"] = "GET_CHAT_MESSAGE";
12765
12797
  EnumPubSubEvents2["GET_NOTIFICATIONS"] = "GET_NOTIFICATIONS";