@hedhog/admin 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/admin.module.d.ts +3 -0
- package/dist/admin.module.d.ts.map +1 -0
- package/dist/admin.module.js +34 -0
- package/dist/admin.module.js.map +1 -0
- package/dist/auth/auth.controller.d.ts +21 -0
- package/dist/auth/auth.controller.d.ts.map +1 -0
- package/dist/auth/auth.controller.js +77 -0
- package/dist/auth/auth.controller.js.map +1 -0
- package/dist/auth/auth.module.d.ts +3 -0
- package/dist/auth/auth.module.d.ts.map +1 -0
- package/dist/auth/auth.module.js +50 -0
- package/dist/auth/auth.module.js.map +1 -0
- package/dist/auth/auth.service.d.ts +36 -0
- package/dist/auth/auth.service.d.ts.map +1 -0
- package/dist/auth/auth.service.js +162 -0
- package/dist/auth/auth.service.js.map +1 -0
- package/dist/auth/auth.service.spec.d.ts +2 -0
- package/dist/auth/auth.service.spec.d.ts.map +1 -0
- package/dist/auth/auth.service.spec.js +17 -0
- package/dist/auth/auth.service.spec.js.map +1 -0
- package/dist/auth/decorators/public.decorator.d.ts +3 -0
- package/dist/auth/decorators/public.decorator.d.ts.map +1 -0
- package/dist/auth/decorators/public.decorator.js +8 -0
- package/dist/auth/decorators/public.decorator.js.map +1 -0
- package/dist/auth/decorators/user.decorator.d.ts +2 -0
- package/dist/auth/decorators/user.decorator.d.ts.map +1 -0
- package/dist/auth/decorators/user.decorator.js +12 -0
- package/dist/auth/decorators/user.decorator.js.map +1 -0
- package/dist/auth/dto/forget.dto.d.ts +4 -0
- package/dist/auth/dto/forget.dto.d.ts.map +1 -0
- package/dist/auth/dto/forget.dto.js +21 -0
- package/dist/auth/dto/forget.dto.js.map +1 -0
- package/dist/auth/dto/login.dto.d.ts +5 -0
- package/dist/auth/dto/login.dto.d.ts.map +1 -0
- package/dist/auth/dto/login.dto.js +31 -0
- package/dist/auth/dto/login.dto.js.map +1 -0
- package/dist/auth/dto/otp.dto.d.ts +5 -0
- package/dist/auth/dto/otp.dto.d.ts.map +1 -0
- package/dist/auth/dto/otp.dto.js +27 -0
- package/dist/auth/dto/otp.dto.js.map +1 -0
- package/dist/auth/enums/multifactor-type.enum.d.ts +5 -0
- package/dist/auth/enums/multifactor-type.enum.d.ts.map +1 -0
- package/dist/auth/enums/multifactor-type.enum.js +9 -0
- package/dist/auth/enums/multifactor-type.enum.js.map +1 -0
- package/dist/auth/guards/auth.guard.d.ts +11 -0
- package/dist/auth/guards/auth.guard.d.ts.map +1 -0
- package/dist/auth/guards/auth.guard.js +56 -0
- package/dist/auth/guards/auth.guard.js.map +1 -0
- package/dist/auth/migrations/index.d.ts +6 -0
- package/dist/auth/migrations/index.d.ts.map +1 -0
- package/dist/auth/migrations/index.js +121 -0
- package/dist/auth/migrations/index.js.map +1 -0
- package/dist/auth/types/user.type.d.ts +9 -0
- package/dist/auth/types/user.type.d.ts.map +1 -0
- package/dist/auth/types/user.type.js +3 -0
- package/dist/auth/types/user.type.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js.map +1 -0
- package/dist/menu/dto/create.dto.d.ts +8 -0
- package/dist/menu/dto/create.dto.d.ts.map +1 -0
- package/dist/menu/dto/create.dto.js +44 -0
- package/dist/menu/dto/create.dto.js.map +1 -0
- package/dist/menu/dto/delete.dto.d.ts +4 -0
- package/dist/menu/dto/delete.dto.d.ts.map +1 -0
- package/dist/menu/dto/delete.dto.js +24 -0
- package/dist/menu/dto/delete.dto.js.map +1 -0
- package/dist/menu/dto/order.dto.d.ts +4 -0
- package/dist/menu/dto/order.dto.d.ts.map +1 -0
- package/dist/menu/dto/order.dto.js +23 -0
- package/dist/menu/dto/order.dto.js.map +1 -0
- package/dist/menu/dto/update.dto.d.ts +7 -0
- package/dist/menu/dto/update.dto.d.ts.map +1 -0
- package/dist/menu/dto/update.dto.js +37 -0
- package/dist/menu/dto/update.dto.js.map +1 -0
- package/dist/menu/menu.controller.d.ts +19 -0
- package/dist/menu/menu.controller.d.ts.map +1 -0
- package/dist/menu/menu.controller.js +119 -0
- package/dist/menu/menu.controller.js.map +1 -0
- package/dist/menu/menu.module.d.ts +3 -0
- package/dist/menu/menu.module.d.ts.map +1 -0
- package/dist/menu/menu.module.js +33 -0
- package/dist/menu/menu.module.js.map +1 -0
- package/dist/menu/menu.service.d.ts +23 -0
- package/dist/menu/menu.service.d.ts.map +1 -0
- package/dist/menu/menu.service.js +117 -0
- package/dist/menu/menu.service.js.map +1 -0
- package/dist/menu/migrations/index.d.ts +7 -0
- package/dist/menu/migrations/index.d.ts.map +1 -0
- package/dist/menu/migrations/index.js +101 -0
- package/dist/menu/migrations/index.js.map +1 -0
- package/dist/permission/decorators/permission.decorator.d.ts +3 -0
- package/dist/permission/decorators/permission.decorator.d.ts.map +1 -0
- package/dist/permission/decorators/permission.decorator.js +8 -0
- package/dist/permission/decorators/permission.decorator.js.map +1 -0
- package/dist/permission/dto/create.dto.d.ts +5 -0
- package/dist/permission/dto/create.dto.d.ts.map +1 -0
- package/dist/permission/dto/create.dto.js +27 -0
- package/dist/permission/dto/create.dto.js.map +1 -0
- package/dist/permission/dto/delete.dto.d.ts +4 -0
- package/dist/permission/dto/delete.dto.d.ts.map +1 -0
- package/dist/permission/dto/delete.dto.js +23 -0
- package/dist/permission/dto/delete.dto.js.map +1 -0
- package/dist/permission/dto/update.dto.d.ts +5 -0
- package/dist/permission/dto/update.dto.d.ts.map +1 -0
- package/dist/permission/dto/update.dto.js +27 -0
- package/dist/permission/dto/update.dto.js.map +1 -0
- package/dist/permission/guards/permission.guard.d.ts +11 -0
- package/dist/permission/guards/permission.guard.d.ts.map +1 -0
- package/dist/permission/guards/permission.guard.js +99 -0
- package/dist/permission/guards/permission.guard.js.map +1 -0
- package/dist/permission/migrations/index.d.ts +6 -0
- package/dist/permission/migrations/index.d.ts.map +1 -0
- package/dist/permission/migrations/index.js +520 -0
- package/dist/permission/migrations/index.js.map +1 -0
- package/dist/permission/permission.controller.d.ts +14 -0
- package/dist/permission/permission.controller.d.ts.map +1 -0
- package/dist/permission/permission.controller.js +95 -0
- package/dist/permission/permission.controller.js.map +1 -0
- package/dist/permission/permission.module.d.ts +3 -0
- package/dist/permission/permission.module.d.ts.map +1 -0
- package/dist/permission/permission.module.js +39 -0
- package/dist/permission/permission.module.js.map +1 -0
- package/dist/permission/permission.service.d.ts +19 -0
- package/dist/permission/permission.service.d.ts.map +1 -0
- package/dist/permission/permission.service.js +73 -0
- package/dist/permission/permission.service.js.map +1 -0
- package/dist/permission/types/permission.types.d.ts +33 -0
- package/dist/permission/types/permission.types.d.ts.map +1 -0
- package/dist/permission/types/permission.types.js +3 -0
- package/dist/permission/types/permission.types.js.map +1 -0
- package/dist/screen/dto/create.dto.d.ts +7 -0
- package/dist/screen/dto/create.dto.d.ts.map +1 -0
- package/dist/screen/dto/create.dto.js +37 -0
- package/dist/screen/dto/create.dto.js.map +1 -0
- package/dist/screen/dto/delete.dto.d.ts +4 -0
- package/dist/screen/dto/delete.dto.d.ts.map +1 -0
- package/dist/screen/dto/delete.dto.js +23 -0
- package/dist/screen/dto/delete.dto.js.map +1 -0
- package/dist/screen/dto/update.dto.d.ts +7 -0
- package/dist/screen/dto/update.dto.d.ts.map +1 -0
- package/dist/screen/dto/update.dto.js +37 -0
- package/dist/screen/dto/update.dto.js.map +1 -0
- package/dist/screen/migrations/index.d.ts +6 -0
- package/dist/screen/migrations/index.d.ts.map +1 -0
- package/dist/screen/migrations/index.js +40 -0
- package/dist/screen/migrations/index.js.map +1 -0
- package/dist/screen/screen.controller.d.ts +14 -0
- package/dist/screen/screen.controller.d.ts.map +1 -0
- package/dist/screen/screen.controller.js +95 -0
- package/dist/screen/screen.controller.js.map +1 -0
- package/dist/screen/screen.module.d.ts +3 -0
- package/dist/screen/screen.module.d.ts.map +1 -0
- package/dist/screen/screen.module.js +31 -0
- package/dist/screen/screen.module.js.map +1 -0
- package/dist/screen/screen.service.d.ts +19 -0
- package/dist/screen/screen.service.d.ts.map +1 -0
- package/dist/screen/screen.service.js +73 -0
- package/dist/screen/screen.service.js.map +1 -0
- package/dist/user/constants/user.constants.d.ts +2 -0
- package/dist/user/constants/user.constants.d.ts.map +1 -0
- package/dist/user/constants/user.constants.js +5 -0
- package/dist/user/constants/user.constants.js.map +1 -0
- package/dist/user/dto/create.dto.d.ts +6 -0
- package/dist/user/dto/create.dto.d.ts.map +1 -0
- package/dist/user/dto/create.dto.js +37 -0
- package/dist/user/dto/create.dto.js.map +1 -0
- package/dist/user/dto/delete.dto.d.ts +4 -0
- package/dist/user/dto/delete.dto.d.ts.map +1 -0
- package/dist/user/dto/delete.dto.js +23 -0
- package/dist/user/dto/delete.dto.js.map +1 -0
- package/dist/user/dto/update.dto.d.ts +8 -0
- package/dist/user/dto/update.dto.d.ts.map +1 -0
- package/dist/user/dto/update.dto.js +50 -0
- package/dist/user/dto/update.dto.js.map +1 -0
- package/dist/user/user.controller.d.ts +14 -0
- package/dist/user/user.controller.d.ts.map +1 -0
- package/dist/user/user.controller.js +95 -0
- package/dist/user/user.controller.js.map +1 -0
- package/dist/user/user.module.d.ts +3 -0
- package/dist/user/user.module.d.ts.map +1 -0
- package/dist/user/user.module.js +31 -0
- package/dist/user/user.module.js.map +1 -0
- package/dist/user/user.service.d.ts +20 -0
- package/dist/user/user.service.d.ts.map +1 -0
- package/dist/user/user.service.js +84 -0
- package/dist/user/user.service.js.map +1 -0
- package/dist/user/user.service.spec.d.ts +2 -0
- package/dist/user/user.service.spec.d.ts.map +1 -0
- package/dist/user/user.service.spec.js +17 -0
- package/dist/user/user.service.spec.js.map +1 -0
- package/package.json +2 -1
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"menu.module.d.ts","sourceRoot":"","sources":["../../src/menu/menu.module.ts"],"names":[],"mappings":"AAQA,qBAWa,UAAU;CAAG"}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7
|
+
};
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
9
|
+
exports.MenuModule = void 0;
|
10
|
+
const auth_module_1 = require("../auth/auth.module");
|
11
|
+
const pagination_1 = require("@hedhog/pagination");
|
12
|
+
const prisma_1 = require("@hedhog/prisma");
|
13
|
+
const common_1 = require("@nestjs/common");
|
14
|
+
const menu_controller_1 = require("./menu.controller");
|
15
|
+
const menu_service_1 = require("./menu.service");
|
16
|
+
const permission_module_1 = require("../permission/permission.module");
|
17
|
+
let MenuModule = class MenuModule {
|
18
|
+
};
|
19
|
+
exports.MenuModule = MenuModule;
|
20
|
+
exports.MenuModule = MenuModule = __decorate([
|
21
|
+
(0, common_1.Module)({
|
22
|
+
providers: [menu_service_1.MenuService],
|
23
|
+
exports: [menu_service_1.MenuService],
|
24
|
+
controllers: [menu_controller_1.MenuController],
|
25
|
+
imports: [
|
26
|
+
(0, common_1.forwardRef)(() => auth_module_1.AuthModule),
|
27
|
+
(0, common_1.forwardRef)(() => prisma_1.PrismaModule),
|
28
|
+
(0, common_1.forwardRef)(() => pagination_1.PaginationModule),
|
29
|
+
(0, common_1.forwardRef)(() => permission_module_1.PermissionModule),
|
30
|
+
],
|
31
|
+
})
|
32
|
+
], MenuModule);
|
33
|
+
//# sourceMappingURL=menu.module.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"menu.module.js","sourceRoot":"","sources":["../../src/menu/menu.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,qDAAiD;AACjD,mDAAsD;AACtD,2CAA8C;AAC9C,2CAAoD;AACpD,uDAAmD;AACnD,iDAA6C;AAC7C,uEAAmE;AAa5D,IAAM,UAAU,GAAhB,MAAM,UAAU;CAAG,CAAA;AAAb,gCAAU;qBAAV,UAAU;IAXtB,IAAA,eAAM,EAAC;QACN,SAAS,EAAE,CAAC,0BAAW,CAAC;QACxB,OAAO,EAAE,CAAC,0BAAW,CAAC;QACtB,WAAW,EAAE,CAAC,gCAAc,CAAC;QAC7B,OAAO,EAAE;YACP,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,wBAAU,CAAC;YAC5B,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,qBAAY,CAAC;YAC9B,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,6BAAgB,CAAC;YAClC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,oCAAgB,CAAC;SACnC;KACF,CAAC;GACW,UAAU,CAAG"}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { PaginationDTO, PaginationService } from '@hedhog/pagination';
|
2
|
+
import { PrismaService } from '@hedhog/prisma';
|
3
|
+
import { CreateDTO } from './dto/create.dto';
|
4
|
+
import { DeleteDTO } from './dto/delete.dto';
|
5
|
+
import { UpdateDTO } from './dto/update.dto';
|
6
|
+
import { OrderDTO } from './dto/order.dto';
|
7
|
+
export declare class MenuService {
|
8
|
+
private readonly prismaService;
|
9
|
+
private readonly paginationService;
|
10
|
+
constructor(prismaService: PrismaService, paginationService: PaginationService);
|
11
|
+
getMenus(userId: number, menuId?: number): Promise<any[]>;
|
12
|
+
getSystemMenu(userId: number): Promise<any[]>;
|
13
|
+
getMenu(paginationParams: PaginationDTO): Promise<import("@hedhog/pagination").PaginatedResult<unknown>>;
|
14
|
+
get(menuId: number): Promise<any>;
|
15
|
+
create({ name, url, icon, order, menuId }: CreateDTO): Promise<any>;
|
16
|
+
update({ id, data }: {
|
17
|
+
id: number;
|
18
|
+
data: UpdateDTO;
|
19
|
+
}): Promise<any>;
|
20
|
+
delete({ ids }: DeleteDTO): Promise<any>;
|
21
|
+
updateOrder({ ids }: OrderDTO): Promise<void>;
|
22
|
+
}
|
23
|
+
//# sourceMappingURL=menu.service.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"menu.service.d.ts","sourceRoot":"","sources":["../../src/menu/menu.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAO/C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,qBACa,WAAW;IAGpB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAE9B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;gBAFjB,aAAa,EAAE,aAAa,EAE5B,iBAAiB,EAAE,iBAAiB;IAGjD,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,SAAI;IAgCnC,aAAa,CAAC,MAAM,EAAE,MAAM;IAI5B,OAAO,CAAC,gBAAgB,EAAE,aAAa;IAkBvC,GAAG,CAAC,MAAM,EAAE,MAAM;IAMlB,MAAM,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,SAAS;IAMpD,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,SAAS,CAAA;KAAE;IAOpD,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,SAAS;IAgBzB,WAAW,CAAC,EAAE,GAAG,EAAE,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAsBpD"}
|
@@ -0,0 +1,117 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7
|
+
};
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
10
|
+
};
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
13
|
+
};
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
+
exports.MenuService = void 0;
|
16
|
+
const pagination_1 = require("@hedhog/pagination");
|
17
|
+
const prisma_1 = require("@hedhog/prisma");
|
18
|
+
const common_1 = require("@nestjs/common");
|
19
|
+
let MenuService = class MenuService {
|
20
|
+
constructor(prismaService, paginationService) {
|
21
|
+
this.prismaService = prismaService;
|
22
|
+
this.paginationService = paginationService;
|
23
|
+
}
|
24
|
+
async getMenus(userId, menuId = 0) {
|
25
|
+
if (menuId === 0) {
|
26
|
+
menuId = null;
|
27
|
+
}
|
28
|
+
const menus = (await this.prismaService.menus.findMany({
|
29
|
+
where: {
|
30
|
+
menu_id: menuId,
|
31
|
+
role_menus: {
|
32
|
+
some: {
|
33
|
+
roles: {
|
34
|
+
role_users: {
|
35
|
+
some: {
|
36
|
+
user_id: userId,
|
37
|
+
},
|
38
|
+
},
|
39
|
+
},
|
40
|
+
},
|
41
|
+
},
|
42
|
+
},
|
43
|
+
orderBy: {
|
44
|
+
order: 'asc',
|
45
|
+
},
|
46
|
+
}));
|
47
|
+
for (let i = 0; i < menus.length; i++) {
|
48
|
+
menus[i].menus = await this.getMenus(userId, menus[i].id);
|
49
|
+
}
|
50
|
+
return menus;
|
51
|
+
}
|
52
|
+
async getSystemMenu(userId) {
|
53
|
+
return this.getMenus(userId);
|
54
|
+
}
|
55
|
+
async getMenu(paginationParams) {
|
56
|
+
const fields = ['name', 'url', 'icon'];
|
57
|
+
const OR = this.prismaService.createInsensitiveSearch(fields, paginationParams);
|
58
|
+
return this.paginationService.paginate(this.prismaService.menus, paginationParams, {
|
59
|
+
where: {
|
60
|
+
OR,
|
61
|
+
},
|
62
|
+
});
|
63
|
+
}
|
64
|
+
async get(menuId) {
|
65
|
+
return this.prismaService.menus.findUnique({
|
66
|
+
where: { id: menuId },
|
67
|
+
});
|
68
|
+
}
|
69
|
+
async create({ name, url, icon, order, menuId }) {
|
70
|
+
return this.prismaService.menus.create({
|
71
|
+
data: { name, url, icon, order, menu_id: menuId },
|
72
|
+
});
|
73
|
+
}
|
74
|
+
async update({ id, data }) {
|
75
|
+
return this.prismaService.menus.update({
|
76
|
+
where: { id },
|
77
|
+
data,
|
78
|
+
});
|
79
|
+
}
|
80
|
+
async delete({ ids }) {
|
81
|
+
if (ids == undefined || ids == null) {
|
82
|
+
throw new common_1.BadRequestException(`You must select at least one menu to delete.`);
|
83
|
+
}
|
84
|
+
return this.prismaService.menus.deleteMany({
|
85
|
+
where: {
|
86
|
+
id: {
|
87
|
+
in: ids,
|
88
|
+
},
|
89
|
+
},
|
90
|
+
});
|
91
|
+
}
|
92
|
+
async updateOrder({ ids }) {
|
93
|
+
const count = await this.prismaService.menus.count({
|
94
|
+
where: {
|
95
|
+
id: {
|
96
|
+
in: ids,
|
97
|
+
},
|
98
|
+
},
|
99
|
+
});
|
100
|
+
if (count !== ids.length) {
|
101
|
+
throw new common_1.BadRequestException('IDs inválidos.');
|
102
|
+
}
|
103
|
+
await Promise.all(ids.map((id, index) => this.prismaService.menus.update({
|
104
|
+
where: { id },
|
105
|
+
data: { order: index + 1 },
|
106
|
+
})));
|
107
|
+
}
|
108
|
+
};
|
109
|
+
exports.MenuService = MenuService;
|
110
|
+
exports.MenuService = MenuService = __decorate([
|
111
|
+
(0, common_1.Injectable)(),
|
112
|
+
__param(0, (0, common_1.Inject)((0, common_1.forwardRef)(() => prisma_1.PrismaService))),
|
113
|
+
__param(1, (0, common_1.Inject)((0, common_1.forwardRef)(() => pagination_1.PaginationService))),
|
114
|
+
__metadata("design:paramtypes", [prisma_1.PrismaService,
|
115
|
+
pagination_1.PaginationService])
|
116
|
+
], MenuService);
|
117
|
+
//# sourceMappingURL=menu.service.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"menu.service.js","sourceRoot":"","sources":["../../src/menu/menu.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mDAAsE;AACtE,2CAA+C;AAC/C,2CAKwB;AAOjB,IAAM,WAAW,GAAjB,MAAM,WAAW;IACtB,YAEmB,aAA4B,EAE5B,iBAAoC;QAFpC,kBAAa,GAAb,aAAa,CAAe;QAE5B,sBAAiB,GAAjB,iBAAiB,CAAmB;IACpD,CAAC;IAEJ,KAAK,CAAC,QAAQ,CAAC,MAAc,EAAE,MAAM,GAAG,CAAC;QACvC,IAAI,MAAM,KAAK,CAAC,EAAE,CAAC;YACjB,MAAM,GAAG,IAAI,CAAC;QAChB,CAAC;QAED,MAAM,KAAK,GAAG,CAAC,MAAM,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC;YACrD,KAAK,EAAE;gBACL,OAAO,EAAE,MAAM;gBACf,UAAU,EAAE;oBACV,IAAI,EAAE;wBACJ,KAAK,EAAE;4BACL,UAAU,EAAE;gCACV,IAAI,EAAE;oCACJ,OAAO,EAAE,MAAM;iCAChB;6BACF;yBACF;qBACF;iBACF;aACF;YACD,OAAO,EAAE;gBACP,KAAK,EAAE,KAAK;aACb;SACF,CAAC,CAAuB,CAAC;QAE1B,KAAK,I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GAAG,EAAE,CAAC,sBAAa,CAAC,CAAC,CAAA;IAEvC,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,8BAAiB,CAAC,CAAC,CAAA;qCADZ,sBAAa;QAET,8BAAiB;GAL5C,WAAW,CAuHvB"}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { MigrationInterface, QueryRunner } from 'typeorm';
|
2
|
+
export declare class Migrate implements MigrationInterface {
|
3
|
+
up(queryRunner: QueryRunner): Promise<void>;
|
4
|
+
private insertMenu;
|
5
|
+
down(queryRunner: QueryRunner): Promise<void>;
|
6
|
+
}
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/menu/migrations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,WAAW,EAGZ,MAAM,SAAS,CAAC;AAGjB,qBAAa,OAAQ,YAAW,kBAAkB;IACnC,EAAE,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;YA0H1C,UAAU;IAyBX,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CAI3D"}
|
@@ -0,0 +1,101 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Migrate = void 0;
|
4
|
+
const typeorm_1 = require("typeorm");
|
5
|
+
const utils_1 = require("@hedhog/utils");
|
6
|
+
class Migrate {
|
7
|
+
async up(queryRunner) {
|
8
|
+
await queryRunner.createTable(new typeorm_1.Table({
|
9
|
+
name: 'menus',
|
10
|
+
columns: [
|
11
|
+
(0, utils_1.idColumn)(),
|
12
|
+
{
|
13
|
+
name: 'name',
|
14
|
+
type: 'varchar',
|
15
|
+
},
|
16
|
+
{
|
17
|
+
name: 'url',
|
18
|
+
type: 'varchar',
|
19
|
+
isNullable: true,
|
20
|
+
},
|
21
|
+
{
|
22
|
+
name: 'order',
|
23
|
+
type: 'int',
|
24
|
+
default: 0,
|
25
|
+
unsigned: true,
|
26
|
+
},
|
27
|
+
{
|
28
|
+
name: 'menu_id',
|
29
|
+
type: 'int',
|
30
|
+
isNullable: true,
|
31
|
+
unsigned: true,
|
32
|
+
},
|
33
|
+
{
|
34
|
+
name: 'icon',
|
35
|
+
type: 'varchar',
|
36
|
+
isNullable: true,
|
37
|
+
},
|
38
|
+
(0, utils_1.timestampColumn)(),
|
39
|
+
(0, utils_1.timestampColumn)('updated_at'),
|
40
|
+
],
|
41
|
+
}));
|
42
|
+
await queryRunner.createTable(new typeorm_1.Table({
|
43
|
+
name: 'menu_screens',
|
44
|
+
columns: [
|
45
|
+
{
|
46
|
+
name: 'menu_id',
|
47
|
+
type: 'int',
|
48
|
+
isPrimary: true,
|
49
|
+
unsigned: true,
|
50
|
+
},
|
51
|
+
{
|
52
|
+
name: 'screen_id',
|
53
|
+
type: 'int',
|
54
|
+
isPrimary: true,
|
55
|
+
unsigned: true,
|
56
|
+
},
|
57
|
+
],
|
58
|
+
}));
|
59
|
+
await queryRunner.createForeignKey('menu_screens', new typeorm_1.TableForeignKey({
|
60
|
+
columnNames: ['menu_id'],
|
61
|
+
referencedColumnNames: ['id'],
|
62
|
+
referencedTableName: 'menus',
|
63
|
+
onDelete: 'CASCADE',
|
64
|
+
}));
|
65
|
+
await queryRunner.createForeignKey('menu_screens', new typeorm_1.TableForeignKey({
|
66
|
+
columnNames: ['screen_id'],
|
67
|
+
referencedColumnNames: ['id'],
|
68
|
+
referencedTableName: 'screens',
|
69
|
+
onDelete: 'CASCADE',
|
70
|
+
}));
|
71
|
+
//System Populating
|
72
|
+
await this.insertMenu(queryRunner, 'Dashboard', '/', 0, null, 'dashboard');
|
73
|
+
const managementId = await this.insertMenu(queryRunner, 'Management', null, 1, null, 'settings');
|
74
|
+
await this.insertMenu(queryRunner, 'Users', '/management/users', 0, managementId, 'users');
|
75
|
+
await this.insertMenu(queryRunner, 'Roles', '/management/roles', 1, managementId, 'circles');
|
76
|
+
await this.insertMenu(queryRunner, 'Screens', '/management/screens', 2, managementId, 'monitor');
|
77
|
+
await this.insertMenu(queryRunner, 'Menus', '/management/menus', 3, managementId, 'menu');
|
78
|
+
}
|
79
|
+
async insertMenu(queryRunner, name, url, order, menuId, icon) {
|
80
|
+
const result = await queryRunner.manager
|
81
|
+
.createQueryBuilder()
|
82
|
+
.insert()
|
83
|
+
.into('menus')
|
84
|
+
.values({
|
85
|
+
name,
|
86
|
+
url,
|
87
|
+
order,
|
88
|
+
menu_id: menuId,
|
89
|
+
icon,
|
90
|
+
})
|
91
|
+
.returning('id')
|
92
|
+
.execute();
|
93
|
+
return result.raw[0].id;
|
94
|
+
}
|
95
|
+
async down(queryRunner) {
|
96
|
+
await queryRunner.dropTable('menu_screens');
|
97
|
+
await queryRunner.dropTable('menus');
|
98
|
+
}
|
99
|
+
}
|
100
|
+
exports.Migrate = Migrate;
|
101
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/menu/migrations/index.ts"],"names":[],"mappings":";;;AAAA,qCAKiB;AACjB,yCAA0D;AAE1D,MAAa,OAAO;IACX,KAAK,CAAC,EAAE,CAAC,WAAwB;QACtC,MAAM,WAAW,CAAC,WAAW,CAC3B,IAAI,eAAK,CAAC;YACR,IAAI,EAAE,OAAO;YACb,OAAO,EAAE;gBACP,IAAA,gBAAQ,GAAE;gBACV;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,SAAS;iBAChB;gBACD;oBACE,IAAI,EAAE,KAAK;oBACX,IAAI,EAAE,SAAS;oBACf,UAAU,EAAE,IAAI;iBACjB;gBACD;oBACE,IAAI,EAAE,OAAO;oBACb,IAAI,EAAE,KAAK;oBACX,OAAO,EAAE,CAAC;oBACV,QAAQ,EAAE,IAAI;iBACf;gBACD;oBACE,IAAI,EAAE,SAA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AAW,EACX,YAAY,EACZ,IAAI,EACJ,CAAC,EACD,IAAI,EACJ,UAAU,CACX,CAAC;QACF,MAAM,IAAI,CAAC,UAAU,CACnB,WAAW,EACX,OAAO,EACP,mBAAmB,EACnB,CAAC,EACD,YAAY,EACZ,OAAO,CACR,CAAC;QACF,MAAM,IAAI,CAAC,UAAU,CACnB,WAAW,EACX,OAAO,EACP,mBAAmB,EACnB,CAAC,EACD,YAAY,EACZ,SAAS,CACV,CAAC;QACF,MAAM,IAAI,CAAC,UAAU,CACnB,WAAW,EACX,SAAS,EACT,qBAAqB,EACrB,CAAC,EACD,YAAY,EACZ,SAAS,CACV,CAAC;QACF,MAAM,IAAI,CAAC,UAAU,CACnB,WAAW,EACX,OAAO,EACP,mBAAmB,EACnB,CAAC,EACD,YAAY,EACZ,MAAM,CACP,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,UAAU,CACtB,WAAwB,EACxB,IAAY,EACZ,GAAW,EACX,KAAa,EACb,MAAc,EACd,IAAY;QAEZ,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,OAAO;aACrC,kBAAkB,EAAE;aACpB,MAAM,EAAE;aACR,IAAI,CAAC,OAAO,CAAC;aACb,MAAM,CAAC;YACN,IAAI;YACJ,GAAG;YACH,KAAK;YACL,OAAO,EAAE,MAAM;YACf,IAAI;SACL,CAAC;aACD,SAAS,CAAC,IAAI,CAAC;aACf,OAAO,EAAE,CAAC;QAEb,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1B,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,WAAwB;QACxC,MAAM,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;QAC5C,MAAM,WAAW,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;CACF;AAxJD,0BAwJC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"permission.decorator.d.ts","sourceRoot":"","sources":["../../../src/permission/decorators/permission.decorator.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,mBAAmB,CAAC;AAChD,eAAO,MAAM,UAAU,wDAA2C,CAAC"}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Permission = exports.WITH_PERMISSION = void 0;
|
4
|
+
const common_1 = require("@nestjs/common");
|
5
|
+
exports.WITH_PERMISSION = 'withPermission';
|
6
|
+
const Permission = () => (0, common_1.SetMetadata)(exports.WITH_PERMISSION, true);
|
7
|
+
exports.Permission = Permission;
|
8
|
+
//# sourceMappingURL=permission.decorator.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"permission.decorator.js","sourceRoot":"","sources":["../../../src/permission/decorators/permission.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAEhC,QAAA,eAAe,GAAG,gBAAgB,CAAC;AACzC,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,IAAA,oBAAW,EAAC,uBAAe,EAAE,IAAI,CAAC,CAAC;AAAtD,QAAA,UAAU,cAA4C"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"create.dto.d.ts","sourceRoot":"","sources":["../../../src/permission/dto/create.dto.ts"],"names":[],"mappings":"AAEA,qBAAa,SAAS;IAGpB,IAAI,EAAE,MAAM,CAAC;IAIb,WAAW,EAAE,MAAM,CAAC;CACrB"}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7
|
+
};
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
10
|
+
};
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
exports.CreateDTO = void 0;
|
13
|
+
const class_validator_1 = require("class-validator");
|
14
|
+
class CreateDTO {
|
15
|
+
}
|
16
|
+
exports.CreateDTO = CreateDTO;
|
17
|
+
__decorate([
|
18
|
+
(0, class_validator_1.IsString)({ message: 'O nome deve ser uma string' }),
|
19
|
+
(0, class_validator_1.IsNotEmpty)({ message: 'O nome é obrigatório.' }),
|
20
|
+
__metadata("design:type", String)
|
21
|
+
], CreateDTO.prototype, "name", void 0);
|
22
|
+
__decorate([
|
23
|
+
(0, class_validator_1.IsString)({ message: 'A descrição deve ser uma string' }),
|
24
|
+
(0, class_validator_1.IsNotEmpty)({ message: 'A descrição é obrigatória.' }),
|
25
|
+
__metadata("design:type", String)
|
26
|
+
], CreateDTO.prototype, "description", void 0);
|
27
|
+
//# sourceMappingURL=create.dto.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"create.dto.js","sourceRoot":"","sources":["../../../src/permission/dto/create.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAuD;AAEvD,MAAa,SAAS;CAQrB;AARD,8BAQC;AALC;IAFC,IAAA,0BAAQ,EAAC,EAAE,OAAO,EAAE,4BAA4B,EAAE,CAAC;IACnD,IAAA,4BAAU,EAAC,EAAE,OAAO,EAAE,uBAAuB,EAAE,CAAC;;uCACpC;AAIb;IAFC,IAAA,0BAAQ,EAAC,EAAE,OAAO,EAAE,iCAAiC,EAAE,CAAC;IACxD,IAAA,4BAAU,EAAC,EAAE,OAAO,EAAE,4BAA4B,EAAE,CAAC;;8CAClC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"delete.dto.d.ts","sourceRoot":"","sources":["../../../src/permission/dto/delete.dto.ts"],"names":[],"mappings":"AAEA,qBAAa,SAAS;IAIpB,GAAG,EAAE,MAAM,EAAE,CAAC;CACf"}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7
|
+
};
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
10
|
+
};
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
exports.DeleteDTO = void 0;
|
13
|
+
const class_validator_1 = require("class-validator");
|
14
|
+
class DeleteDTO {
|
15
|
+
}
|
16
|
+
exports.DeleteDTO = DeleteDTO;
|
17
|
+
__decorate([
|
18
|
+
(0, class_validator_1.IsArray)(),
|
19
|
+
(0, class_validator_1.ArrayMinSize)(1),
|
20
|
+
(0, class_validator_1.IsInt)({ each: true }),
|
21
|
+
__metadata("design:type", Array)
|
22
|
+
], DeleteDTO.prototype, "ids", void 0);
|
23
|
+
//# sourceMappingURL=delete.dto.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"delete.dto.js","sourceRoot":"","sources":["../../../src/permission/dto/delete.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA+D;AAE/D,MAAa,SAAS;CAKrB;AALD,8BAKC;AADC;IAHC,IAAA,yBAAO,GAAE;IACT,IAAA,8BAAY,EAAC,CAAC,CAAC;IACf,IAAA,uBAAK,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;;sCACR"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"update.dto.d.ts","sourceRoot":"","sources":["../../../src/permission/dto/update.dto.ts"],"names":[],"mappings":"AAEA,qBAAa,SAAS;IAGpB,IAAI,CAAC,EAAE,MAAM,CAAC;IAId,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB"}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7
|
+
};
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
10
|
+
};
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
exports.UpdateDTO = void 0;
|
13
|
+
const class_validator_1 = require("class-validator");
|
14
|
+
class UpdateDTO {
|
15
|
+
}
|
16
|
+
exports.UpdateDTO = UpdateDTO;
|
17
|
+
__decorate([
|
18
|
+
(0, class_validator_1.IsOptional)(),
|
19
|
+
(0, class_validator_1.IsString)({ message: 'O nome deve ser uma string' }),
|
20
|
+
__metadata("design:type", String)
|
21
|
+
], UpdateDTO.prototype, "name", void 0);
|
22
|
+
__decorate([
|
23
|
+
(0, class_validator_1.IsOptional)(),
|
24
|
+
(0, class_validator_1.IsString)({ message: 'A descrição deve ser uma string' }),
|
25
|
+
__metadata("design:type", String)
|
26
|
+
], UpdateDTO.prototype, "description", void 0);
|
27
|
+
//# sourceMappingURL=update.dto.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"update.dto.js","sourceRoot":"","sources":["../../../src/permission/dto/update.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAuD;AAEvD,MAAa,SAAS;CAQrB;AARD,8BAQC;AALC;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,EAAC,EAAE,OAAO,EAAE,4BAA4B,EAAE,CAAC;;uCACtC;AAId;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,EAAC,EAAE,OAAO,EAAE,iCAAiC,EAAE,CAAC;;8CACpC"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { CanActivate, ExecutionContext } from '@nestjs/common';
|
2
|
+
import { Reflector } from '@nestjs/core';
|
3
|
+
import { PrismaService } from '@hedhog/prisma';
|
4
|
+
export declare class PermissionGuard implements CanActivate {
|
5
|
+
private reflector;
|
6
|
+
private prisma;
|
7
|
+
constructor(reflector: Reflector, prisma: PrismaService);
|
8
|
+
canActivate(context: ExecutionContext): Promise<boolean>;
|
9
|
+
private extractTokenFromHeader;
|
10
|
+
}
|
11
|
+
//# sourceMappingURL=permission.guard.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"permission.guard.d.ts","sourceRoot":"","sources":["../../../src/permission/guards/permission.guard.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,gBAAgB,EAIjB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,qBACa,eAAgB,YAAW,WAAW;IAE/C,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,MAAM;gBADN,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,aAAa;IAGzB,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IAgF9D,OAAO,CAAC,sBAAsB;CAI/B"}
|
@@ -0,0 +1,99 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7
|
+
};
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
10
|
+
};
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
exports.PermissionGuard = void 0;
|
13
|
+
const common_1 = require("@nestjs/common");
|
14
|
+
const core_1 = require("@nestjs/core");
|
15
|
+
const constants_1 = require("@nestjs/common/constants");
|
16
|
+
const permission_decorator_1 = require("../decorators/permission.decorator");
|
17
|
+
const prisma_1 = require("@hedhog/prisma");
|
18
|
+
let PermissionGuard = class PermissionGuard {
|
19
|
+
constructor(reflector, prisma) {
|
20
|
+
this.reflector = reflector;
|
21
|
+
this.prisma = prisma;
|
22
|
+
}
|
23
|
+
async canActivate(context) {
|
24
|
+
var _a, _b;
|
25
|
+
const withPermission = this.reflector.getAllAndOverride(permission_decorator_1.WITH_PERMISSION, [context.getHandler(), context.getClass()]);
|
26
|
+
if (!withPermission) {
|
27
|
+
return true;
|
28
|
+
}
|
29
|
+
const request = context.switchToHttp().getRequest();
|
30
|
+
const controller = context.getClass();
|
31
|
+
const handler = context.getHandler();
|
32
|
+
const controllerPath = this.reflector.get('path', controller) || '';
|
33
|
+
const methodPath = this.reflector.get('path', handler) || '';
|
34
|
+
const requestMethod = this.reflector.get(constants_1.METHOD_METADATA, handler);
|
35
|
+
const fullPath = `/${controllerPath}/${methodPath}`.replace(/\/+/g, '/');
|
36
|
+
const token = this.extractTokenFromHeader(request);
|
37
|
+
if (!token) {
|
38
|
+
throw new common_1.UnauthorizedException();
|
39
|
+
}
|
40
|
+
const userId = (_b = (_a = request === null || request === void 0 ? void 0 : request.auth) === null || _a === void 0 ? void 0 : _a.user) === null || _b === void 0 ? void 0 : _b.id;
|
41
|
+
let httpMethod;
|
42
|
+
switch (requestMethod) {
|
43
|
+
case common_1.RequestMethod.GET:
|
44
|
+
httpMethod = 'GET';
|
45
|
+
break;
|
46
|
+
case common_1.RequestMethod.POST:
|
47
|
+
httpMethod = 'POST';
|
48
|
+
break;
|
49
|
+
case common_1.RequestMethod.PUT:
|
50
|
+
httpMethod = 'PUT';
|
51
|
+
break;
|
52
|
+
case common_1.RequestMethod.DELETE:
|
53
|
+
httpMethod = 'DELETE';
|
54
|
+
break;
|
55
|
+
case common_1.RequestMethod.PATCH:
|
56
|
+
httpMethod = 'PATCH';
|
57
|
+
break;
|
58
|
+
case common_1.RequestMethod.OPTIONS:
|
59
|
+
httpMethod = 'OPTIONS';
|
60
|
+
break;
|
61
|
+
case common_1.RequestMethod.HEAD:
|
62
|
+
httpMethod = 'HEAD';
|
63
|
+
break;
|
64
|
+
case common_1.RequestMethod.ALL:
|
65
|
+
httpMethod = 'ALL';
|
66
|
+
break;
|
67
|
+
}
|
68
|
+
const route = await this.prisma.routes.count({
|
69
|
+
where: {
|
70
|
+
method: httpMethod,
|
71
|
+
url: fullPath,
|
72
|
+
role_routes: {
|
73
|
+
some: {
|
74
|
+
roles: {
|
75
|
+
role_users: {
|
76
|
+
some: {
|
77
|
+
user_id: Number(userId),
|
78
|
+
},
|
79
|
+
},
|
80
|
+
},
|
81
|
+
},
|
82
|
+
},
|
83
|
+
},
|
84
|
+
});
|
85
|
+
return route === 1;
|
86
|
+
}
|
87
|
+
extractTokenFromHeader(request) {
|
88
|
+
var _a, _b;
|
89
|
+
const [type, token] = (_b = (_a = request.headers.authorization) === null || _a === void 0 ? void 0 : _a.split(' ')) !== null && _b !== void 0 ? _b : [];
|
90
|
+
return type === 'Bearer' ? token : undefined;
|
91
|
+
}
|
92
|
+
};
|
93
|
+
exports.PermissionGuard = PermissionGuard;
|
94
|
+
exports.PermissionGuard = PermissionGuard = __decorate([
|
95
|
+
(0, common_1.Injectable)(),
|
96
|
+
__metadata("design:paramtypes", [core_1.Reflector,
|
97
|
+
prisma_1.PrismaService])
|
98
|
+
], PermissionGuard);
|
99
|
+
//# sourceMappingURL=permission.guard.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"permission.guard.js","sourceRoot":"","sources":["../../../src/permission/guards/permission.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAMwB;AAExB,uCAAyC;AACzC,wDAA2D;AAC3D,6EAAqE;AACrE,2CAA+C;AAGxC,IAAM,eAAe,GAArB,MAAM,eAAe;IAC1B,YACU,SAAoB,EACpB,MAAqB;QADrB,cAAS,GAAT,SAAS,CAAW;QACpB,WAAM,GAAN,MAAM,CAAe;IAC5B,CAAC;IAEJ,KAAK,CAAC,WAAW,CAAC,OAAyB;;QACzC,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CACrD,sCAAe,EACf,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAC3C,CAAC;QAEF,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAW,CAAC;QAC7D,MAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;QACtC,MAAM,OAAO,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