@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.
@@ -37,7 +37,7 @@ import {
37
37
  resourceRelationsSchema,
38
38
  termsAgreementSchema,
39
39
  userLicenseSchema
40
- } from "../chunk-FA5DXWVE.mjs";
40
+ } from "../chunk-ZKCRLNCH.mjs";
41
41
  import "../chunk-3QS3WKRC.mjs";
42
42
  export {
43
43
  APP_SETTINGS_ID,
@@ -12626,6 +12626,37 @@ async function updateAdStatuses() {
12626
12626
  );
12627
12627
  }
12628
12628
 
12629
+ // src/service/associate.ts
12630
+ async function removeAssociateFromResource(resourceId, resourceType) {
12631
+ const normalizedResourceId = resourceId.toString();
12632
+ try {
12633
+ await UserModel.updateMany(
12634
+ {
12635
+ associates: {
12636
+ $elemMatch: {
12637
+ resourceId: normalizedResourceId,
12638
+ resourceType
12639
+ }
12640
+ }
12641
+ },
12642
+ {
12643
+ $pull: {
12644
+ associates: {
12645
+ resourceId: normalizedResourceId,
12646
+ resourceType
12647
+ }
12648
+ }
12649
+ }
12650
+ ).exec();
12651
+ } catch (error) {
12652
+ console.error(
12653
+ `[removeAssociateFromResource] Failed to remove associates for resourceId=${normalizedResourceId}, resourceType=${resourceType}`,
12654
+ error
12655
+ );
12656
+ throw error;
12657
+ }
12658
+ }
12659
+
12629
12660
  // src/service/vendor.ts
12630
12661
  async function updateVendorBasedOnUserLicense(userId, licenceType) {
12631
12662
  try {
@@ -12678,18 +12709,19 @@ async function updateVendorBasedOnUserLicense(userId, licenceType) {
12678
12709
  },
12679
12710
  { new: true }
12680
12711
  );
12712
+ await removeAssociateFromResource(userVendor._id, EnumResourceType.VENDOR);
12681
12713
  } catch (error) {
12682
12714
  console.error("Error updating vendor based on user license:", error);
12683
12715
  }
12684
12716
  }
12685
12717
 
12686
12718
  // src/service/objectIdToString.ts
12687
- var import_mongoose24 = __toESM(require("mongoose"));
12719
+ var import_mongoose25 = __toESM(require("mongoose"));
12688
12720
  function convertObjectIdsToStrings(obj) {
12689
12721
  if (obj === null || obj === void 0) {
12690
12722
  return obj;
12691
12723
  }
12692
- if (obj instanceof import_mongoose24.default.Types.ObjectId) {
12724
+ if (obj instanceof import_mongoose25.default.Types.ObjectId) {
12693
12725
  return obj.toString();
12694
12726
  }
12695
12727
  if (Array.isArray(obj)) {