shuttlepro-shared 1.2.88 → 1.2.90

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.
@@ -201,25 +201,15 @@ const updateRoleById = async (id, updateData) => {
201
201
  };
202
202
 
203
203
  const updateRoleByFilter = async (filter, updateData) => {
204
- console.log(filter, "filter");
205
- console.log(updateData, "updateData");
206
204
  const updatedRole = await Role.findOneAndUpdate(filter, updateData, {
207
205
  new: true,
208
206
  })
209
207
  .populate("permissionId")
210
208
  .lean()
211
209
  .exec();
212
-
213
- // if (updatedRole) {
214
- // if (updatedRole.workspaceId) {
215
- // await updateCachedRoles(updatedRole.workspaceId);
216
- // }
217
- // // Update default roles cache if needed
218
- // if (!updatedRole.workspaceId) {
219
- // await updateCachedDefaultRoles();
220
- // }
221
- // }
222
-
210
+ if (updatedRole?.workspaceId) {
211
+ await updateCachedRoles(updatedRole?.workspaceId?.toString());
212
+ }
223
213
  return updatedRole;
224
214
  };
225
215
 
@@ -88,7 +88,7 @@ const findOneAndUpdateUserRole = async (filter, payload) => {
88
88
  )
89
89
  .lean()
90
90
  .exec();
91
- return await updateCachedMembers(workspaceId);
91
+ return await updateCachedMembers(filter.workspaceId);
92
92
  };
93
93
 
94
94
  const updateUserRole = async (filter, payload) => {
@@ -96,6 +96,12 @@ const updateUserRole = async (filter, payload) => {
96
96
  return await updateCachedMembers(filter.workspaceId);
97
97
  };
98
98
 
99
+ // Update multiple user roles based on filter
100
+ const updateManyUserRoles = async (filter, payload) => {
101
+ await UserRole.updateMany(filter, { $set: payload }).exec();
102
+ return await updateCachedMembers(filter.workspaceId);
103
+ };
104
+
99
105
  const deleteUserRoleByFilter = async (filter) => {
100
106
  await UserRole.deleteOne(filter).exec();
101
107
  return await updateCachedMembers(filter.workspaceId);
@@ -216,6 +222,7 @@ const findUserWorkspaces = async (userId) => {
216
222
  module.exports = {
217
223
  createUserRole,
218
224
  updateUserRole,
225
+ updateManyUserRoles,
219
226
  findAllUserRoles,
220
227
  deleteUserRoleByFilter,
221
228
  findUserWorkspaces,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shuttlepro-shared",
3
- "version": "1.2.88",
3
+ "version": "1.2.90",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {