@timardex/cluemart-server-shared 1.0.143 → 1.0.146

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.mjs CHANGED
@@ -8643,8 +8643,8 @@ var GET_EVENTS_BY_REGION = gql`
8643
8643
  ${EVENT_LIST_ITEM}
8644
8644
  `;
8645
8645
  var SEARCH_EVENTS = gql`
8646
- query searchEvents($search: String!, $region: String) {
8647
- eventsSearch(search: $search, region: $region) {
8646
+ query searchEvents($region: String, $search: String,$tags: [String]) {
8647
+ eventsSearch(region: $region, search: $search, tags: $tags) {
8648
8648
  ...EventListItemFields
8649
8649
  }
8650
8650
  }
@@ -10116,6 +10116,7 @@ var POST_FIELDS_FRAGMENT = gql`
10116
10116
  postType
10117
10117
  resource {
10118
10118
  resourceId
10119
+ resourceRegion
10119
10120
  resourceType
10120
10121
  }
10121
10122
  tags
@@ -10856,6 +10857,7 @@ var postSchema = create$3().shape({
10856
10857
  postType: create$8().oneOf(Object.values(EnumPostType)).required(),
10857
10858
  resource: create$3({
10858
10859
  resourceId: create$6().required(),
10860
+ resourceRegion: create$6().required(),
10859
10861
  resourceType: create$8().oneOf(Object.values(EnumResourceType)).required()
10860
10862
  }).nullable().optional(),
10861
10863
  tags: create$2().of(create$6().required()).nullable().optional(),
@@ -12247,6 +12249,7 @@ var schema13 = new MongooseSchema17(
12247
12249
  required: false,
12248
12250
  type: {
12249
12251
  resourceId: { required: true, type: String },
12252
+ resourceRegion: { required: true, type: String },
12250
12253
  resourceType: {
12251
12254
  enum: Object.values(EnumResourceType),
12252
12255
  required: true,
@@ -12605,6 +12608,37 @@ async function updateAdStatuses() {
12605
12608
  );
12606
12609
  }
12607
12610
 
12611
+ // src/service/associate.ts
12612
+ async function removeAssociateFromResource(resourceId, resourceType) {
12613
+ const normalizedResourceId = resourceId.toString();
12614
+ try {
12615
+ await UserModel.updateMany(
12616
+ {
12617
+ associates: {
12618
+ $elemMatch: {
12619
+ resourceId: normalizedResourceId,
12620
+ resourceType
12621
+ }
12622
+ }
12623
+ },
12624
+ {
12625
+ $pull: {
12626
+ associates: {
12627
+ resourceId: normalizedResourceId,
12628
+ resourceType
12629
+ }
12630
+ }
12631
+ }
12632
+ ).exec();
12633
+ } catch (error) {
12634
+ console.error(
12635
+ `[removeAssociateFromResource] Failed to remove associates for resourceId=${normalizedResourceId}, resourceType=${resourceType}`,
12636
+ error
12637
+ );
12638
+ throw error;
12639
+ }
12640
+ }
12641
+
12608
12642
  // src/service/vendor.ts
12609
12643
  async function updateVendorBasedOnUserLicense(userId, licenceType) {
12610
12644
  try {
@@ -12657,6 +12691,7 @@ async function updateVendorBasedOnUserLicense(userId, licenceType) {
12657
12691
  },
12658
12692
  { new: true }
12659
12693
  );
12694
+ await removeAssociateFromResource(userVendor._id, EnumResourceType.VENDOR);
12660
12695
  } catch (error) {
12661
12696
  console.error("Error updating vendor based on user license:", error);
12662
12697
  }