@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/CHANGELOG.md +6 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.js +44 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -319,13 +319,13 @@ declare function useMemberRepo(): {
|
|
|
319
319
|
getById: (_id: string | ObjectId) => Promise<TMember | null>;
|
|
320
320
|
getByRole: (role: string | ObjectId) => Promise<TMember | null>;
|
|
321
321
|
getAll: ({ search, limit, page, user, org, app, status }?: {
|
|
322
|
-
search
|
|
323
|
-
limit
|
|
324
|
-
page
|
|
322
|
+
search?: string | undefined;
|
|
323
|
+
limit?: number | undefined;
|
|
324
|
+
page?: number | undefined;
|
|
325
325
|
user?: string | ObjectId | undefined;
|
|
326
326
|
org?: string | ObjectId | undefined;
|
|
327
327
|
app: string;
|
|
328
|
-
status
|
|
328
|
+
status?: string | undefined;
|
|
329
329
|
}) => Promise<Record<string, any>>;
|
|
330
330
|
getOrgsByUserId: ({ search, page, limit, sort, user, status, }?: {
|
|
331
331
|
user: string | ObjectId;
|
|
@@ -384,6 +384,7 @@ declare function useMemberController(): {
|
|
|
384
384
|
updateRoleById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
385
385
|
updateStatusById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
386
386
|
deleteById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
387
|
+
getAllByAppUser: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
387
388
|
};
|
|
388
389
|
|
|
389
390
|
type TOrg = {
|
package/dist/index.js
CHANGED
|
@@ -1895,9 +1895,10 @@ function useMemberRepo() {
|
|
|
1895
1895
|
}
|
|
1896
1896
|
}
|
|
1897
1897
|
async function getAll({ search, limit, page, user, org, app, status } = {}) {
|
|
1898
|
-
limit = limit > 0 ? limit : 10;
|
|
1898
|
+
limit = limit && limit > 0 ? limit : 10;
|
|
1899
1899
|
search = search || "";
|
|
1900
|
-
page = page > 0 ? page - 1 : 0;
|
|
1900
|
+
page = page && page > 0 ? page - 1 : 0;
|
|
1901
|
+
status = status ?? "active";
|
|
1901
1902
|
const query = { app, status };
|
|
1902
1903
|
const cacheKeyOptions = { app, status, limit, page };
|
|
1903
1904
|
if (user) {
|
|
@@ -5403,6 +5404,44 @@ function useMemberController() {
|
|
|
5403
5404
|
next(error2);
|
|
5404
5405
|
}
|
|
5405
5406
|
}
|
|
5407
|
+
async function getAllByAppUser(req, res, next) {
|
|
5408
|
+
const limit = Number(req.query.limit) ?? 10;
|
|
5409
|
+
const search = req.query.search ?? "";
|
|
5410
|
+
const page = Number(req.query.page) ?? 1;
|
|
5411
|
+
const user = req.params.user ?? "";
|
|
5412
|
+
const app = req.params.app ?? "";
|
|
5413
|
+
const validation = import_joi20.default.object({
|
|
5414
|
+
limit: import_joi20.default.number().min(10).max(50).allow(null, ""),
|
|
5415
|
+
search: import_joi20.default.string().optional().allow("", null),
|
|
5416
|
+
page: import_joi20.default.number().optional().allow(null, ""),
|
|
5417
|
+
app: import_joi20.default.string().required(),
|
|
5418
|
+
user: import_joi20.default.string().hex().required()
|
|
5419
|
+
});
|
|
5420
|
+
const { error } = validation.validate({
|
|
5421
|
+
search,
|
|
5422
|
+
page,
|
|
5423
|
+
limit,
|
|
5424
|
+
user,
|
|
5425
|
+
app
|
|
5426
|
+
});
|
|
5427
|
+
if (error) {
|
|
5428
|
+
next(new import_utils29.BadRequestError(error.message));
|
|
5429
|
+
return;
|
|
5430
|
+
}
|
|
5431
|
+
try {
|
|
5432
|
+
const items = await _getAll({
|
|
5433
|
+
search,
|
|
5434
|
+
page,
|
|
5435
|
+
limit,
|
|
5436
|
+
user,
|
|
5437
|
+
app
|
|
5438
|
+
});
|
|
5439
|
+
res.json(items);
|
|
5440
|
+
return;
|
|
5441
|
+
} catch (error2) {
|
|
5442
|
+
next(error2);
|
|
5443
|
+
}
|
|
5444
|
+
}
|
|
5406
5445
|
async function getOrgsByMembership(req, res, next) {
|
|
5407
5446
|
const limit = Number(req.query.limit) ?? 10;
|
|
5408
5447
|
const search = req.query.search ?? "";
|
|
@@ -5509,7 +5548,8 @@ function useMemberController() {
|
|
|
5509
5548
|
getByUserType,
|
|
5510
5549
|
updateRoleById,
|
|
5511
5550
|
updateStatusById,
|
|
5512
|
-
deleteById
|
|
5551
|
+
deleteById,
|
|
5552
|
+
getAllByAppUser
|
|
5513
5553
|
};
|
|
5514
5554
|
}
|
|
5515
5555
|
|
|
@@ -6725,6 +6765,7 @@ function useOrgService() {
|
|
|
6725
6765
|
role: String(role),
|
|
6726
6766
|
roleName: roleData.name,
|
|
6727
6767
|
org: String(org),
|
|
6768
|
+
orgName: value.name,
|
|
6728
6769
|
name: `${user.firstName} ${user.lastName}`,
|
|
6729
6770
|
user: createdBy,
|
|
6730
6771
|
app: "org"
|