@goweekdays/core 2.4.0 → 2.4.1

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
@@ -1801,9 +1801,10 @@ function useMemberRepo() {
1801
1801
  }
1802
1802
  }
1803
1803
  async function getAll({ search, limit, page, user, org, app, status } = {}) {
1804
- limit = limit > 0 ? limit : 10;
1804
+ limit = limit && limit > 0 ? limit : 10;
1805
1805
  search = search || "";
1806
- page = page > 0 ? page - 1 : 0;
1806
+ page = page && page > 0 ? page - 1 : 0;
1807
+ status = status ?? "active";
1807
1808
  const query = { app, status };
1808
1809
  const cacheKeyOptions = { app, status, limit, page };
1809
1810
  if (user) {
@@ -5368,6 +5369,44 @@ function useMemberController() {
5368
5369
  next(error2);
5369
5370
  }
5370
5371
  }
5372
+ async function getAllByAppUser(req, res, next) {
5373
+ const limit = Number(req.query.limit) ?? 10;
5374
+ const search = req.query.search ?? "";
5375
+ const page = Number(req.query.page) ?? 1;
5376
+ const user = req.params.user ?? "";
5377
+ const app = req.params.app ?? "";
5378
+ const validation = Joi20.object({
5379
+ limit: Joi20.number().min(10).max(50).allow(null, ""),
5380
+ search: Joi20.string().optional().allow("", null),
5381
+ page: Joi20.number().optional().allow(null, ""),
5382
+ app: Joi20.string().required(),
5383
+ user: Joi20.string().hex().required()
5384
+ });
5385
+ const { error } = validation.validate({
5386
+ search,
5387
+ page,
5388
+ limit,
5389
+ user,
5390
+ app
5391
+ });
5392
+ if (error) {
5393
+ next(new BadRequestError28(error.message));
5394
+ return;
5395
+ }
5396
+ try {
5397
+ const items = await _getAll({
5398
+ search,
5399
+ page,
5400
+ limit,
5401
+ user,
5402
+ app
5403
+ });
5404
+ res.json(items);
5405
+ return;
5406
+ } catch (error2) {
5407
+ next(error2);
5408
+ }
5409
+ }
5371
5410
  async function getOrgsByMembership(req, res, next) {
5372
5411
  const limit = Number(req.query.limit) ?? 10;
5373
5412
  const search = req.query.search ?? "";
@@ -5474,7 +5513,8 @@ function useMemberController() {
5474
5513
  getByUserType,
5475
5514
  updateRoleById,
5476
5515
  updateStatusById,
5477
- deleteById
5516
+ deleteById,
5517
+ getAllByAppUser
5478
5518
  };
5479
5519
  }
5480
5520
 
@@ -6716,6 +6756,7 @@ function useOrgService() {
6716
6756
  role: String(role),
6717
6757
  roleName: roleData.name,
6718
6758
  org: String(org),
6759
+ orgName: value.name,
6719
6760
  name: `${user.firstName} ${user.lastName}`,
6720
6761
  user: createdBy,
6721
6762
  app: "org"