shuttlepro-shared 1.2.86 → 1.2.88

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.
@@ -188,28 +188,21 @@ const updateRoleById = async (id, updateData) => {
188
188
  }),
189
189
  };
190
190
  delete updateQuery.logs;
191
-
192
191
  const updatedRole = await Role.findByIdAndUpdate(id, updateQuery, {
193
192
  new: true,
194
193
  })
195
194
  .populate("permissionId")
196
195
  .lean()
197
196
  .exec();
198
-
199
197
  if (updatedRole) {
200
- if (updatedRole.workspaceId) {
201
- await updateCachedRoles(updatedRole.workspaceId);
202
- }
203
- // Update default roles cache if needed
204
- if (!updatedRole.workspaceId) {
205
- await updateCachedDefaultRoles();
206
- }
198
+ await updateCachedRoles(updatedRole?.workspaceId);
207
199
  }
208
-
209
200
  return updatedRole;
210
201
  };
211
202
 
212
203
  const updateRoleByFilter = async (filter, updateData) => {
204
+ console.log(filter, "filter");
205
+ console.log(updateData, "updateData");
213
206
  const updatedRole = await Role.findOneAndUpdate(filter, updateData, {
214
207
  new: true,
215
208
  })
@@ -217,15 +210,15 @@ const updateRoleByFilter = async (filter, updateData) => {
217
210
  .lean()
218
211
  .exec();
219
212
 
220
- if (updatedRole) {
221
- if (updatedRole.workspaceId) {
222
- await updateCachedRoles(updatedRole.workspaceId);
223
- }
224
- // Update default roles cache if needed
225
- if (!updatedRole.workspaceId) {
226
- await updateCachedDefaultRoles();
227
- }
228
- }
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
+ // }
229
222
 
230
223
  return updatedRole;
231
224
  };
@@ -316,56 +309,16 @@ const removePermissionFromRole = async (id, permission) => {
316
309
  return updatedRole;
317
310
  };
318
311
 
319
- const deleteRoleById = async (id) => {
320
- const role = await Role.findById(id).lean().exec();
321
- const workspaceId = role?.workspaceId;
322
-
323
- const deletedRole = await Role.findByIdAndDelete(id).lean().exec();
324
-
325
- if (deletedRole) {
326
- if (workspaceId) {
327
- await updateCachedRoles(workspaceId);
328
- }
329
- // Update default roles cache if needed
330
- if (!deletedRole.workspaceId) {
331
- await updateCachedDefaultRoles();
332
- }
333
- }
334
-
335
- return deletedRole;
312
+ const deleteRoleById = async (id, workspaceId) => {
313
+ return await Role.deleteOne({ _id: id }).exec();
336
314
  };
337
315
 
338
316
  const deleteSingleRole = async (filter) => {
339
- const workspaceId = filter.workspaceId;
340
- const deletedRole = await Role.findOneAndDelete(filter).lean().exec();
341
-
342
- if (deletedRole) {
343
- if (workspaceId) {
344
- await updateCachedRoles(workspaceId);
345
- }
346
- // Update default roles cache if needed
347
- if (!deletedRole.workspaceId) {
348
- await updateCachedDefaultRoles();
349
- }
350
- }
351
-
352
- return deletedRole;
317
+ return await Role.deleteOne(filter).exec();
353
318
  };
354
319
 
355
320
  const deleteManyRoles = async (filter) => {
356
- const workspaceId = filter.workspaceId;
357
- const includesDefaultRoles =
358
- !filter.workspaceId || filter.workspaceId === null;
359
- const result = await Role.deleteMany(filter);
360
- if (result.deletedCount > 0) {
361
- if (workspaceId) {
362
- await updateCachedRoles(workspaceId);
363
- }
364
- if (includesDefaultRoles) {
365
- await updateCachedDefaultRoles();
366
- }
367
- }
368
- return result;
321
+ return await Role.deleteMany(filter);
369
322
  };
370
323
 
371
324
  module.exports = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shuttlepro-shared",
3
- "version": "1.2.86",
3
+ "version": "1.2.88",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {