@hedhog/admin 0.0.1
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 +33 -0
- package/dist/admin.module.js.map +1 -0
- package/dist/auth/src/auth.controller.d.ts +21 -0
- package/dist/auth/src/auth.controller.d.ts.map +1 -0
- package/dist/auth/src/auth.controller.js +77 -0
- package/dist/auth/src/auth.controller.js.map +1 -0
- package/dist/auth/src/auth.module.d.ts +3 -0
- package/dist/auth/src/auth.module.d.ts.map +1 -0
- package/dist/auth/src/auth.module.js +50 -0
- package/dist/auth/src/auth.module.js.map +1 -0
- package/dist/auth/src/auth.service.d.ts +36 -0
- package/dist/auth/src/auth.service.d.ts.map +1 -0
- package/dist/auth/src/auth.service.js +162 -0
- package/dist/auth/src/auth.service.js.map +1 -0
- package/dist/auth/src/auth.service.spec.d.ts +2 -0
- package/dist/auth/src/auth.service.spec.d.ts.map +1 -0
- package/dist/auth/src/auth.service.spec.js +17 -0
- package/dist/auth/src/auth.service.spec.js.map +1 -0
- package/dist/auth/src/decorators/public.decorator.d.ts +3 -0
- package/dist/auth/src/decorators/public.decorator.d.ts.map +1 -0
- package/dist/auth/src/decorators/public.decorator.js +8 -0
- package/dist/auth/src/decorators/public.decorator.js.map +1 -0
- package/dist/auth/src/decorators/user.decorator.d.ts +2 -0
- package/dist/auth/src/decorators/user.decorator.d.ts.map +1 -0
- package/dist/auth/src/decorators/user.decorator.js +12 -0
- package/dist/auth/src/decorators/user.decorator.js.map +1 -0
- package/dist/auth/src/dto/forget.dto.d.ts +4 -0
- package/dist/auth/src/dto/forget.dto.d.ts.map +1 -0
- package/dist/auth/src/dto/forget.dto.js +21 -0
- package/dist/auth/src/dto/forget.dto.js.map +1 -0
- package/dist/auth/src/dto/login.dto.d.ts +5 -0
- package/dist/auth/src/dto/login.dto.d.ts.map +1 -0
- package/dist/auth/src/dto/login.dto.js +31 -0
- package/dist/auth/src/dto/login.dto.js.map +1 -0
- package/dist/auth/src/dto/otp.dto.d.ts +5 -0
- package/dist/auth/src/dto/otp.dto.d.ts.map +1 -0
- package/dist/auth/src/dto/otp.dto.js +27 -0
- package/dist/auth/src/dto/otp.dto.js.map +1 -0
- package/dist/auth/src/enums/multifactor-type.enum.d.ts +5 -0
- package/dist/auth/src/enums/multifactor-type.enum.d.ts.map +1 -0
- package/dist/auth/src/enums/multifactor-type.enum.js +9 -0
- package/dist/auth/src/enums/multifactor-type.enum.js.map +1 -0
- package/dist/auth/src/guards/auth.guard.d.ts +11 -0
- package/dist/auth/src/guards/auth.guard.d.ts.map +1 -0
- package/dist/auth/src/guards/auth.guard.js +56 -0
- package/dist/auth/src/guards/auth.guard.js.map +1 -0
- package/dist/auth/src/migrations/index.d.ts +6 -0
- package/dist/auth/src/migrations/index.d.ts.map +1 -0
- package/dist/auth/src/migrations/index.js +121 -0
- package/dist/auth/src/migrations/index.js.map +1 -0
- package/dist/auth/src/types/user.type.d.ts +9 -0
- package/dist/auth/src/types/user.type.d.ts.map +1 -0
- package/dist/auth/src/types/user.type.js +3 -0
- package/dist/auth/src/types/user.type.js.map +1 -0
- package/dist/file/src/dto/delete.dto.d.ts +4 -0
- package/dist/file/src/dto/delete.dto.d.ts.map +1 -0
- package/dist/file/src/dto/delete.dto.js +23 -0
- package/dist/file/src/dto/delete.dto.js.map +1 -0
- package/dist/file/src/file.module.d.ts +3 -0
- package/dist/file/src/file.module.d.ts.map +1 -0
- package/dist/file/src/file.module.js +29 -0
- package/dist/file/src/file.module.js.map +1 -0
- package/dist/file/src/file.service.d.ts +12 -0
- package/dist/file/src/file.service.d.ts.map +1 -0
- package/dist/file/src/file.service.js +59 -0
- package/dist/file/src/file.service.js.map +1 -0
- package/dist/file/src/migrations/index.d.ts +6 -0
- package/dist/file/src/migrations/index.d.ts.map +1 -0
- package/dist/file/src/migrations/index.js +137 -0
- package/dist/file/src/migrations/index.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -0
- package/dist/mail/src/enums/mail-configuration-type.enum.d.ts +6 -0
- package/dist/mail/src/enums/mail-configuration-type.enum.d.ts.map +1 -0
- package/dist/mail/src/enums/mail-configuration-type.enum.js +10 -0
- package/dist/mail/src/enums/mail-configuration-type.enum.js.map +1 -0
- package/dist/mail/src/interfaces/index.d.ts +3 -0
- package/dist/mail/src/interfaces/index.d.ts.map +1 -0
- package/dist/mail/src/interfaces/index.js +19 -0
- package/dist/mail/src/interfaces/index.js.map +1 -0
- package/dist/mail/src/interfaces/mail-module-options.interface.d.ts +32 -0
- package/dist/mail/src/interfaces/mail-module-options.interface.d.ts.map +1 -0
- package/dist/mail/src/interfaces/mail-module-options.interface.js +3 -0
- package/dist/mail/src/interfaces/mail-module-options.interface.js.map +1 -0
- package/dist/mail/src/interfaces/mail-type.d.ts +13 -0
- package/dist/mail/src/interfaces/mail-type.d.ts.map +1 -0
- package/dist/mail/src/interfaces/mail-type.js +3 -0
- package/dist/mail/src/interfaces/mail-type.js.map +1 -0
- package/dist/mail/src/mail.consts.d.ts +17 -0
- package/dist/mail/src/mail.consts.d.ts.map +1 -0
- package/dist/mail/src/mail.consts.js +5 -0
- package/dist/mail/src/mail.consts.js.map +1 -0
- package/dist/mail/src/mail.module.d.ts +8 -0
- package/dist/mail/src/mail.module.d.ts.map +1 -0
- package/dist/mail/src/mail.module.js +51 -0
- package/dist/mail/src/mail.module.js.map +1 -0
- package/dist/mail/src/mail.service.d.ts +14 -0
- package/dist/mail/src/mail.service.d.ts.map +1 -0
- package/dist/mail/src/mail.service.js +281 -0
- package/dist/mail/src/mail.service.js.map +1 -0
- package/dist/mail/src/mail.service.spec.d.ts +2 -0
- package/dist/mail/src/mail.service.spec.d.ts.map +1 -0
- package/dist/mail/src/mail.service.spec.js +17 -0
- package/dist/mail/src/mail.service.spec.js.map +1 -0
- package/dist/menu/src/dto/create.dto.d.ts +8 -0
- package/dist/menu/src/dto/create.dto.d.ts.map +1 -0
- package/dist/menu/src/dto/create.dto.js +44 -0
- package/dist/menu/src/dto/create.dto.js.map +1 -0
- package/dist/menu/src/dto/delete.dto.d.ts +4 -0
- package/dist/menu/src/dto/delete.dto.d.ts.map +1 -0
- package/dist/menu/src/dto/delete.dto.js +24 -0
- package/dist/menu/src/dto/delete.dto.js.map +1 -0
- package/dist/menu/src/dto/order.dto.d.ts +4 -0
- package/dist/menu/src/dto/order.dto.d.ts.map +1 -0
- package/dist/menu/src/dto/order.dto.js +23 -0
- package/dist/menu/src/dto/order.dto.js.map +1 -0
- package/dist/menu/src/dto/update.dto.d.ts +7 -0
- package/dist/menu/src/dto/update.dto.d.ts.map +1 -0
- package/dist/menu/src/dto/update.dto.js +37 -0
- package/dist/menu/src/dto/update.dto.js.map +1 -0
- package/dist/menu/src/menu.controller.d.ts +19 -0
- package/dist/menu/src/menu.controller.d.ts.map +1 -0
- package/dist/menu/src/menu.controller.js +117 -0
- package/dist/menu/src/menu.controller.js.map +1 -0
- package/dist/menu/src/menu.module.d.ts +3 -0
- package/dist/menu/src/menu.module.d.ts.map +1 -0
- package/dist/menu/src/menu.module.js +31 -0
- package/dist/menu/src/menu.module.js.map +1 -0
- package/dist/menu/src/menu.service.d.ts +23 -0
- package/dist/menu/src/menu.service.d.ts.map +1 -0
- package/dist/menu/src/menu.service.js +117 -0
- package/dist/menu/src/menu.service.js.map +1 -0
- package/dist/menu/src/migrations/index.d.ts +7 -0
- package/dist/menu/src/migrations/index.d.ts.map +1 -0
- package/dist/menu/src/migrations/index.js +101 -0
- package/dist/menu/src/migrations/index.js.map +1 -0
- package/dist/migrations/1726795702341-migrate.d.ts +6 -0
- package/dist/migrations/1726795702341-migrate.d.ts.map +1 -0
- package/dist/migrations/1726795702341-migrate.js +121 -0
- package/dist/migrations/1726795702341-migrate.js.map +1 -0
- package/dist/migrations/1726795734665-migrate.d.ts +6 -0
- package/dist/migrations/1726795734665-migrate.d.ts.map +1 -0
- package/dist/migrations/1726795734665-migrate.js +40 -0
- package/dist/migrations/1726795734665-migrate.js.map +1 -0
- package/dist/migrations/1726795818403-migrate.d.ts +7 -0
- package/dist/migrations/1726795818403-migrate.d.ts.map +1 -0
- package/dist/migrations/1726795818403-migrate.js +101 -0
- package/dist/migrations/1726795818403-migrate.js.map +1 -0
- package/dist/migrations/1726795828359-migrate.d.ts +6 -0
- package/dist/migrations/1726795828359-migrate.d.ts.map +1 -0
- package/dist/migrations/1726795828359-migrate.js +525 -0
- package/dist/migrations/1726795828359-migrate.js.map +1 -0
- package/dist/permission/src/decorators/permission.decorator.d.ts +3 -0
- package/dist/permission/src/decorators/permission.decorator.d.ts.map +1 -0
- package/dist/permission/src/decorators/permission.decorator.js +8 -0
- package/dist/permission/src/decorators/permission.decorator.js.map +1 -0
- package/dist/permission/src/dto/create.dto.d.ts +5 -0
- package/dist/permission/src/dto/create.dto.d.ts.map +1 -0
- package/dist/permission/src/dto/create.dto.js +27 -0
- package/dist/permission/src/dto/create.dto.js.map +1 -0
- package/dist/permission/src/dto/delete.dto.d.ts +4 -0
- package/dist/permission/src/dto/delete.dto.d.ts.map +1 -0
- package/dist/permission/src/dto/delete.dto.js +23 -0
- package/dist/permission/src/dto/delete.dto.js.map +1 -0
- package/dist/permission/src/dto/update.dto.d.ts +5 -0
- package/dist/permission/src/dto/update.dto.d.ts.map +1 -0
- package/dist/permission/src/dto/update.dto.js +27 -0
- package/dist/permission/src/dto/update.dto.js.map +1 -0
- package/dist/permission/src/guards/permission.guard.d.ts +11 -0
- package/dist/permission/src/guards/permission.guard.d.ts.map +1 -0
- package/dist/permission/src/guards/permission.guard.js +99 -0
- package/dist/permission/src/guards/permission.guard.js.map +1 -0
- package/dist/permission/src/migrations/index.d.ts +6 -0
- package/dist/permission/src/migrations/index.d.ts.map +1 -0
- package/dist/permission/src/migrations/index.js +520 -0
- package/dist/permission/src/migrations/index.js.map +1 -0
- package/dist/permission/src/permission.controller.d.ts +14 -0
- package/dist/permission/src/permission.controller.d.ts.map +1 -0
- package/dist/permission/src/permission.controller.js +95 -0
- package/dist/permission/src/permission.controller.js.map +1 -0
- package/dist/permission/src/permission.module.d.ts +3 -0
- package/dist/permission/src/permission.module.d.ts.map +1 -0
- package/dist/permission/src/permission.module.js +39 -0
- package/dist/permission/src/permission.module.js.map +1 -0
- package/dist/permission/src/permission.service.d.ts +19 -0
- package/dist/permission/src/permission.service.d.ts.map +1 -0
- package/dist/permission/src/permission.service.js +73 -0
- package/dist/permission/src/permission.service.js.map +1 -0
- package/dist/permission/src/types/permission.types.d.ts +33 -0
- package/dist/permission/src/types/permission.types.d.ts.map +1 -0
- package/dist/permission/src/types/permission.types.js +3 -0
- package/dist/permission/src/types/permission.types.js.map +1 -0
- package/dist/screen/src/dto/create.dto.d.ts +7 -0
- package/dist/screen/src/dto/create.dto.d.ts.map +1 -0
- package/dist/screen/src/dto/create.dto.js +37 -0
- package/dist/screen/src/dto/create.dto.js.map +1 -0
- package/dist/screen/src/dto/delete.dto.d.ts +4 -0
- package/dist/screen/src/dto/delete.dto.d.ts.map +1 -0
- package/dist/screen/src/dto/delete.dto.js +23 -0
- package/dist/screen/src/dto/delete.dto.js.map +1 -0
- package/dist/screen/src/dto/update.dto.d.ts +7 -0
- package/dist/screen/src/dto/update.dto.d.ts.map +1 -0
- package/dist/screen/src/dto/update.dto.js +37 -0
- package/dist/screen/src/dto/update.dto.js.map +1 -0
- package/dist/screen/src/migrations/index.d.ts +6 -0
- package/dist/screen/src/migrations/index.d.ts.map +1 -0
- package/dist/screen/src/migrations/index.js +40 -0
- package/dist/screen/src/migrations/index.js.map +1 -0
- package/dist/screen/src/screen.controller.d.ts +14 -0
- package/dist/screen/src/screen.controller.d.ts.map +1 -0
- package/dist/screen/src/screen.controller.js +94 -0
- package/dist/screen/src/screen.controller.js.map +1 -0
- package/dist/screen/src/screen.module.d.ts +3 -0
- package/dist/screen/src/screen.module.d.ts.map +1 -0
- package/dist/screen/src/screen.module.js +31 -0
- package/dist/screen/src/screen.module.js.map +1 -0
- package/dist/screen/src/screen.service.d.ts +19 -0
- package/dist/screen/src/screen.service.d.ts.map +1 -0
- package/dist/screen/src/screen.service.js +73 -0
- package/dist/screen/src/screen.service.js.map +1 -0
- package/dist/setting/src/dto/create.dto.d.ts +4 -0
- package/dist/setting/src/dto/create.dto.d.ts.map +1 -0
- package/dist/setting/src/dto/create.dto.js +22 -0
- package/dist/setting/src/dto/create.dto.js.map +1 -0
- package/dist/setting/src/dto/delete.dto.d.ts +4 -0
- package/dist/setting/src/dto/delete.dto.d.ts.map +1 -0
- package/dist/setting/src/dto/delete.dto.js +23 -0
- package/dist/setting/src/dto/delete.dto.js.map +1 -0
- package/dist/setting/src/dto/update.dto.d.ts +4 -0
- package/dist/setting/src/dto/update.dto.d.ts.map +1 -0
- package/dist/setting/src/dto/update.dto.js +8 -0
- package/dist/setting/src/dto/update.dto.js.map +1 -0
- package/dist/setting/src/migrations/index.d.ts +6 -0
- package/dist/setting/src/migrations/index.d.ts.map +1 -0
- package/dist/setting/src/migrations/index.js +67 -0
- package/dist/setting/src/migrations/index.js.map +1 -0
- package/dist/setting/src/settings.controller.d.ts +14 -0
- package/dist/setting/src/settings.controller.d.ts.map +1 -0
- package/dist/setting/src/settings.controller.js +94 -0
- package/dist/setting/src/settings.controller.js.map +1 -0
- package/dist/setting/src/settings.module.d.ts +3 -0
- package/dist/setting/src/settings.module.d.ts.map +1 -0
- package/dist/setting/src/settings.module.js +31 -0
- package/dist/setting/src/settings.module.js.map +1 -0
- package/dist/setting/src/settings.service.d.ts +19 -0
- package/dist/setting/src/settings.service.d.ts.map +1 -0
- package/dist/setting/src/settings.service.js +70 -0
- package/dist/setting/src/settings.service.js.map +1 -0
- package/dist/user/src/constants/user.constants.d.ts +2 -0
- package/dist/user/src/constants/user.constants.d.ts.map +1 -0
- package/dist/user/src/constants/user.constants.js +5 -0
- package/dist/user/src/constants/user.constants.js.map +1 -0
- package/dist/user/src/dto/create.dto.d.ts +6 -0
- package/dist/user/src/dto/create.dto.d.ts.map +1 -0
- package/dist/user/src/dto/create.dto.js +37 -0
- package/dist/user/src/dto/create.dto.js.map +1 -0
- package/dist/user/src/dto/delete.dto.d.ts +4 -0
- package/dist/user/src/dto/delete.dto.d.ts.map +1 -0
- package/dist/user/src/dto/delete.dto.js +23 -0
- package/dist/user/src/dto/delete.dto.js.map +1 -0
- package/dist/user/src/dto/update.dto.d.ts +8 -0
- package/dist/user/src/dto/update.dto.d.ts.map +1 -0
- package/dist/user/src/dto/update.dto.js +50 -0
- package/dist/user/src/dto/update.dto.js.map +1 -0
- package/dist/user/src/user.controller.d.ts +14 -0
- package/dist/user/src/user.controller.d.ts.map +1 -0
- package/dist/user/src/user.controller.js +94 -0
- package/dist/user/src/user.controller.js.map +1 -0
- package/dist/user/src/user.module.d.ts +3 -0
- package/dist/user/src/user.module.d.ts.map +1 -0
- package/dist/user/src/user.module.js +31 -0
- package/dist/user/src/user.module.js.map +1 -0
- package/dist/user/src/user.service.d.ts +20 -0
- package/dist/user/src/user.service.d.ts.map +1 -0
- package/dist/user/src/user.service.js +84 -0
- package/dist/user/src/user.service.js.map +1 -0
- package/dist/user/src/user.service.spec.d.ts +2 -0
- package/dist/user/src/user.service.spec.d.ts.map +1 -0
- package/dist/user/src/user.service.spec.js +17 -0
- package/dist/user/src/user.service.spec.js.map +1 -0
- package/package.json +29 -0
- package/src/mail/src/mail.template.ejs +1 -0
- package/src/migrations/1726795702341-migrate.ts +107 -0
- package/src/migrations/1726795734665-migrate.ts +40 -0
- package/src/migrations/1726795818403-migrate.ts +161 -0
- package/src/migrations/1726795828359-migrate.ts +573 -0
@@ -0,0 +1,573 @@
|
|
1
|
+
import { idColumn, timestampColumn } from '@hedhog/utils';
|
2
|
+
|
3
|
+
import {
|
4
|
+
MigrationInterface,
|
5
|
+
QueryRunner,
|
6
|
+
Table,
|
7
|
+
TableForeignKey,
|
8
|
+
TableUnique,
|
9
|
+
} from 'typeorm';
|
10
|
+
|
11
|
+
export class Migrate1726795828359 implements MigrationInterface {
|
12
|
+
async up(queryRunner: QueryRunner) {
|
13
|
+
await queryRunner.createTable(
|
14
|
+
new Table({
|
15
|
+
name: 'routes',
|
16
|
+
columns: [
|
17
|
+
idColumn(),
|
18
|
+
{
|
19
|
+
name: 'url',
|
20
|
+
type: 'varchar',
|
21
|
+
},
|
22
|
+
{
|
23
|
+
name: 'method',
|
24
|
+
type: 'enum',
|
25
|
+
enum: ['GET', 'POST', 'PATCH', 'DELETE', 'PUT', 'OPTIONS', 'HEAD'],
|
26
|
+
},
|
27
|
+
timestampColumn(),
|
28
|
+
timestampColumn('updated_at'),
|
29
|
+
],
|
30
|
+
}),
|
31
|
+
);
|
32
|
+
|
33
|
+
await queryRunner.createUniqueConstraint(
|
34
|
+
'routes',
|
35
|
+
new TableUnique({
|
36
|
+
columnNames: ['url', 'method'],
|
37
|
+
name: 'unique_routes',
|
38
|
+
}),
|
39
|
+
);
|
40
|
+
|
41
|
+
await queryRunner.createTable(
|
42
|
+
new Table({
|
43
|
+
name: 'roles',
|
44
|
+
columns: [
|
45
|
+
idColumn(),
|
46
|
+
{
|
47
|
+
name: 'name',
|
48
|
+
type: 'varchar',
|
49
|
+
isNullable: false,
|
50
|
+
},
|
51
|
+
{
|
52
|
+
name: 'description',
|
53
|
+
type: 'varchar',
|
54
|
+
},
|
55
|
+
timestampColumn(),
|
56
|
+
timestampColumn('updated_at'),
|
57
|
+
],
|
58
|
+
}),
|
59
|
+
);
|
60
|
+
|
61
|
+
await queryRunner.createTable(
|
62
|
+
new Table({
|
63
|
+
name: 'role_menus',
|
64
|
+
columns: [
|
65
|
+
{
|
66
|
+
name: 'role_id',
|
67
|
+
type: 'int',
|
68
|
+
isPrimary: true,
|
69
|
+
unsigned: true,
|
70
|
+
},
|
71
|
+
{
|
72
|
+
name: 'menu_id',
|
73
|
+
type: 'int',
|
74
|
+
isPrimary: true,
|
75
|
+
unsigned: true,
|
76
|
+
},
|
77
|
+
timestampColumn(),
|
78
|
+
timestampColumn('updated_at'),
|
79
|
+
],
|
80
|
+
}),
|
81
|
+
);
|
82
|
+
|
83
|
+
await queryRunner.createForeignKeys('role_menus', [
|
84
|
+
new TableForeignKey({
|
85
|
+
columnNames: ['role_id'],
|
86
|
+
referencedColumnNames: ['id'],
|
87
|
+
referencedTableName: 'roles',
|
88
|
+
onDelete: 'CASCADE',
|
89
|
+
name: 'fk_role_menus_roles',
|
90
|
+
}),
|
91
|
+
new TableForeignKey({
|
92
|
+
columnNames: ['menu_id'],
|
93
|
+
referencedColumnNames: ['id'],
|
94
|
+
referencedTableName: 'menus',
|
95
|
+
onDelete: 'CASCADE',
|
96
|
+
name: 'fk_role_menus_menus',
|
97
|
+
}),
|
98
|
+
]);
|
99
|
+
|
100
|
+
await queryRunner.createTable(
|
101
|
+
new Table({
|
102
|
+
name: 'role_screens',
|
103
|
+
columns: [
|
104
|
+
{
|
105
|
+
name: 'role_id',
|
106
|
+
type: 'int',
|
107
|
+
isPrimary: true,
|
108
|
+
unsigned: true,
|
109
|
+
},
|
110
|
+
{
|
111
|
+
name: 'screen_id',
|
112
|
+
type: 'int',
|
113
|
+
isPrimary: true,
|
114
|
+
unsigned: true,
|
115
|
+
},
|
116
|
+
timestampColumn(),
|
117
|
+
timestampColumn('updated_at'),
|
118
|
+
],
|
119
|
+
}),
|
120
|
+
);
|
121
|
+
|
122
|
+
await queryRunner.createForeignKeys('role_screens', [
|
123
|
+
new TableForeignKey({
|
124
|
+
columnNames: ['role_id'],
|
125
|
+
referencedColumnNames: ['id'],
|
126
|
+
referencedTableName: 'roles',
|
127
|
+
onDelete: 'CASCADE',
|
128
|
+
name: 'fk_role_screens_roles',
|
129
|
+
}),
|
130
|
+
new TableForeignKey({
|
131
|
+
columnNames: ['screen_id'],
|
132
|
+
referencedColumnNames: ['id'],
|
133
|
+
referencedTableName: 'screens',
|
134
|
+
onDelete: 'CASCADE',
|
135
|
+
name: 'fk_role_screens_screens',
|
136
|
+
}),
|
137
|
+
]);
|
138
|
+
|
139
|
+
await queryRunner.createTable(
|
140
|
+
new Table({
|
141
|
+
name: 'role_users',
|
142
|
+
columns: [
|
143
|
+
{
|
144
|
+
name: 'role_id',
|
145
|
+
type: 'int',
|
146
|
+
isPrimary: true,
|
147
|
+
unsigned: true,
|
148
|
+
},
|
149
|
+
{
|
150
|
+
name: 'user_id',
|
151
|
+
type: 'int',
|
152
|
+
isPrimary: true,
|
153
|
+
unsigned: true,
|
154
|
+
},
|
155
|
+
timestampColumn(),
|
156
|
+
timestampColumn('updated_at'),
|
157
|
+
],
|
158
|
+
}),
|
159
|
+
);
|
160
|
+
|
161
|
+
await queryRunner.createForeignKeys('role_users', [
|
162
|
+
new TableForeignKey({
|
163
|
+
columnNames: ['role_id'],
|
164
|
+
referencedColumnNames: ['id'],
|
165
|
+
referencedTableName: 'roles',
|
166
|
+
onDelete: 'CASCADE',
|
167
|
+
name: 'fk_role_users_roles',
|
168
|
+
}),
|
169
|
+
|
170
|
+
new TableForeignKey({
|
171
|
+
columnNames: ['user_id'],
|
172
|
+
referencedColumnNames: ['id'],
|
173
|
+
referencedTableName: 'users',
|
174
|
+
onDelete: 'CASCADE',
|
175
|
+
name: 'fk_role_users_users',
|
176
|
+
}),
|
177
|
+
]);
|
178
|
+
|
179
|
+
await queryRunner.createTable(
|
180
|
+
new Table({
|
181
|
+
name: 'role_routes',
|
182
|
+
columns: [
|
183
|
+
{
|
184
|
+
name: 'role_id',
|
185
|
+
type: 'int',
|
186
|
+
isPrimary: true,
|
187
|
+
unsigned: true,
|
188
|
+
},
|
189
|
+
{
|
190
|
+
name: 'route_id',
|
191
|
+
type: 'int',
|
192
|
+
isPrimary: true,
|
193
|
+
unsigned: true,
|
194
|
+
},
|
195
|
+
timestampColumn(),
|
196
|
+
timestampColumn('updated_at'),
|
197
|
+
],
|
198
|
+
}),
|
199
|
+
);
|
200
|
+
|
201
|
+
await queryRunner.createForeignKeys('role_routes', [
|
202
|
+
new TableForeignKey({
|
203
|
+
columnNames: ['role_id'],
|
204
|
+
referencedColumnNames: ['id'],
|
205
|
+
referencedTableName: 'roles',
|
206
|
+
onDelete: 'CASCADE',
|
207
|
+
name: 'fk_role_routes_roles',
|
208
|
+
}),
|
209
|
+
new TableForeignKey({
|
210
|
+
columnNames: ['route_id'],
|
211
|
+
referencedColumnNames: ['id'],
|
212
|
+
referencedTableName: 'routes',
|
213
|
+
onDelete: 'CASCADE',
|
214
|
+
name: 'fk_role_routes_routes',
|
215
|
+
}),
|
216
|
+
]);
|
217
|
+
|
218
|
+
await queryRunner.manager
|
219
|
+
.createQueryBuilder()
|
220
|
+
.insert()
|
221
|
+
.into('routes', ['url', 'method'])
|
222
|
+
.values([
|
223
|
+
{
|
224
|
+
url: '/auth/verify',
|
225
|
+
method: 'GET',
|
226
|
+
},
|
227
|
+
{
|
228
|
+
url: '/menus',
|
229
|
+
method: 'GET',
|
230
|
+
},
|
231
|
+
{
|
232
|
+
url: '/menus/system',
|
233
|
+
method: 'GET',
|
234
|
+
},
|
235
|
+
{
|
236
|
+
url: '/menus/:menuId',
|
237
|
+
method: 'GET',
|
238
|
+
},
|
239
|
+
{
|
240
|
+
url: '/menus',
|
241
|
+
method: 'POST',
|
242
|
+
},
|
243
|
+
{
|
244
|
+
url: '/menus/:menuId',
|
245
|
+
method: 'PATCH',
|
246
|
+
},
|
247
|
+
{
|
248
|
+
url: '/menus',
|
249
|
+
method: 'DELETE',
|
250
|
+
},
|
251
|
+
{
|
252
|
+
url: '/menus/order',
|
253
|
+
method: 'PATCH',
|
254
|
+
},
|
255
|
+
{
|
256
|
+
url: '/permissions',
|
257
|
+
method: 'GET',
|
258
|
+
},
|
259
|
+
{
|
260
|
+
url: '/permissions/:permissionId',
|
261
|
+
method: 'GET',
|
262
|
+
},
|
263
|
+
{
|
264
|
+
url: '/permissions',
|
265
|
+
method: 'POST',
|
266
|
+
},
|
267
|
+
{
|
268
|
+
url: '/permissions/:permissionId',
|
269
|
+
method: 'PATCH',
|
270
|
+
},
|
271
|
+
{
|
272
|
+
url: '/permissions',
|
273
|
+
method: 'DELETE',
|
274
|
+
},
|
275
|
+
{
|
276
|
+
url: '/screens',
|
277
|
+
method: 'GET',
|
278
|
+
},
|
279
|
+
{
|
280
|
+
url: '/screens/:screenId',
|
281
|
+
method: 'GET',
|
282
|
+
},
|
283
|
+
{
|
284
|
+
url: '/screens',
|
285
|
+
method: 'POST',
|
286
|
+
},
|
287
|
+
{
|
288
|
+
url: '/screens/:screenId',
|
289
|
+
method: 'PATCH',
|
290
|
+
},
|
291
|
+
{
|
292
|
+
url: '/screens',
|
293
|
+
method: 'DELETE',
|
294
|
+
},
|
295
|
+
{
|
296
|
+
url: '/settings',
|
297
|
+
method: 'GET',
|
298
|
+
},
|
299
|
+
{
|
300
|
+
url: '/settings/:settingId',
|
301
|
+
method: 'GET',
|
302
|
+
},
|
303
|
+
{
|
304
|
+
url: '/settings',
|
305
|
+
method: 'POST',
|
306
|
+
},
|
307
|
+
{
|
308
|
+
url: '/settings/:settingId',
|
309
|
+
method: 'PATCH',
|
310
|
+
},
|
311
|
+
{
|
312
|
+
url: '/settings',
|
313
|
+
method: 'DELETE',
|
314
|
+
},
|
315
|
+
{
|
316
|
+
url: '/users',
|
317
|
+
method: 'GET',
|
318
|
+
},
|
319
|
+
{
|
320
|
+
url: '/users/:userId',
|
321
|
+
method: 'GET',
|
322
|
+
},
|
323
|
+
{
|
324
|
+
url: '/users',
|
325
|
+
method: 'POST',
|
326
|
+
},
|
327
|
+
{
|
328
|
+
url: '/users/:userId',
|
329
|
+
method: 'PATCH',
|
330
|
+
},
|
331
|
+
{
|
332
|
+
url: '/users',
|
333
|
+
method: 'DELETE',
|
334
|
+
},
|
335
|
+
])
|
336
|
+
.execute();
|
337
|
+
|
338
|
+
await queryRunner.manager
|
339
|
+
.createQueryBuilder()
|
340
|
+
.insert()
|
341
|
+
.into('roles', ['id', 'name', 'description'])
|
342
|
+
.values([
|
343
|
+
{
|
344
|
+
id: 1,
|
345
|
+
name: 'Administrator',
|
346
|
+
description: 'System administrator',
|
347
|
+
},
|
348
|
+
{
|
349
|
+
id: 2,
|
350
|
+
name: 'Screen Manager',
|
351
|
+
description: 'Screen manager',
|
352
|
+
},
|
353
|
+
])
|
354
|
+
.execute();
|
355
|
+
|
356
|
+
const routes = await queryRunner.manager
|
357
|
+
.createQueryBuilder()
|
358
|
+
.select()
|
359
|
+
.from('routes', 'r')
|
360
|
+
.execute();
|
361
|
+
|
362
|
+
for (const route of routes) {
|
363
|
+
await queryRunner.manager
|
364
|
+
.createQueryBuilder()
|
365
|
+
.insert()
|
366
|
+
.into('role_routes')
|
367
|
+
.values({
|
368
|
+
role_id: 1,
|
369
|
+
route_id: route.id,
|
370
|
+
})
|
371
|
+
.execute();
|
372
|
+
}
|
373
|
+
|
374
|
+
const menus = await queryRunner.manager
|
375
|
+
.createQueryBuilder()
|
376
|
+
.select()
|
377
|
+
.from('menus', 'm')
|
378
|
+
.execute();
|
379
|
+
|
380
|
+
for (const menu of menus) {
|
381
|
+
await queryRunner.manager
|
382
|
+
.createQueryBuilder()
|
383
|
+
.insert()
|
384
|
+
.into('role_menus')
|
385
|
+
.values({
|
386
|
+
role_id: 1,
|
387
|
+
menu_id: menu.id,
|
388
|
+
});
|
389
|
+
}
|
390
|
+
|
391
|
+
const routesScreens = await queryRunner.manager
|
392
|
+
.createQueryBuilder()
|
393
|
+
.select()
|
394
|
+
.from('routes', 's')
|
395
|
+
.where('s.url LIKE :url', { url: '/screens%' })
|
396
|
+
.execute();
|
397
|
+
|
398
|
+
for (const route of routesScreens) {
|
399
|
+
await queryRunner.manager
|
400
|
+
.createQueryBuilder()
|
401
|
+
.insert()
|
402
|
+
.into('role_routes')
|
403
|
+
.values({
|
404
|
+
role_id: 2,
|
405
|
+
route_id: route.id,
|
406
|
+
})
|
407
|
+
.execute();
|
408
|
+
}
|
409
|
+
|
410
|
+
await queryRunner.createTable(
|
411
|
+
new Table({
|
412
|
+
name: 'route_screens',
|
413
|
+
columns: [
|
414
|
+
{
|
415
|
+
name: 'route_id',
|
416
|
+
type: 'int',
|
417
|
+
unsigned: true,
|
418
|
+
isPrimary: true,
|
419
|
+
},
|
420
|
+
{
|
421
|
+
name: 'screen_id',
|
422
|
+
type: 'int',
|
423
|
+
unsigned: true,
|
424
|
+
isPrimary: true,
|
425
|
+
},
|
426
|
+
timestampColumn(),
|
427
|
+
timestampColumn('updated_at'),
|
428
|
+
],
|
429
|
+
}),
|
430
|
+
);
|
431
|
+
|
432
|
+
await queryRunner.createForeignKeys('route_screens', [
|
433
|
+
new TableForeignKey({
|
434
|
+
columnNames: ['route_id'],
|
435
|
+
referencedColumnNames: ['id'],
|
436
|
+
referencedTableName: 'routes',
|
437
|
+
onDelete: 'CASCADE',
|
438
|
+
name: 'fk_route_screens_routes',
|
439
|
+
}),
|
440
|
+
new TableForeignKey({
|
441
|
+
columnNames: ['screen_id'],
|
442
|
+
referencedColumnNames: ['id'],
|
443
|
+
referencedTableName: 'screens',
|
444
|
+
onDelete: 'CASCADE',
|
445
|
+
name: 'fk_route_screens_screens',
|
446
|
+
}),
|
447
|
+
]);
|
448
|
+
|
449
|
+
const screens = await queryRunner.manager
|
450
|
+
.createQueryBuilder()
|
451
|
+
.insert()
|
452
|
+
.into('screens', ['name', 'slug', 'description', 'icon'])
|
453
|
+
.values([
|
454
|
+
{
|
455
|
+
name: 'Users',
|
456
|
+
slug: '/management/users',
|
457
|
+
description: 'Check all users registered in the system.',
|
458
|
+
icon: 'users',
|
459
|
+
},
|
460
|
+
{
|
461
|
+
name: 'Roles',
|
462
|
+
slug: '/management/roles',
|
463
|
+
description: 'Check all roles registered in the system.',
|
464
|
+
icon: 'circles',
|
465
|
+
},
|
466
|
+
{
|
467
|
+
name: 'Screens',
|
468
|
+
slug: '/management/screens',
|
469
|
+
description: 'Check all screens registered in the system.',
|
470
|
+
icon: 'monitor',
|
471
|
+
},
|
472
|
+
{
|
473
|
+
name: 'Menus',
|
474
|
+
slug: '/management/menus',
|
475
|
+
description: 'Check all menus registered in the system.',
|
476
|
+
icon: 'menu',
|
477
|
+
},
|
478
|
+
])
|
479
|
+
.returning('id')
|
480
|
+
.execute();
|
481
|
+
|
482
|
+
for (const screen of screens.raw) {
|
483
|
+
await queryRunner.manager
|
484
|
+
.createQueryBuilder()
|
485
|
+
.insert()
|
486
|
+
.into('role_screens')
|
487
|
+
.values({
|
488
|
+
role_id: 1,
|
489
|
+
screen_id: screen.id,
|
490
|
+
})
|
491
|
+
.execute();
|
492
|
+
}
|
493
|
+
|
494
|
+
const screenIdScreen = await queryRunner.manager
|
495
|
+
.createQueryBuilder()
|
496
|
+
.select()
|
497
|
+
.from('screens', 's')
|
498
|
+
.where('slug = :slug', { slug: '/management/screens' })
|
499
|
+
.execute();
|
500
|
+
const screenIdRole = await queryRunner.manager
|
501
|
+
.createQueryBuilder()
|
502
|
+
.select()
|
503
|
+
.from('screens', 's')
|
504
|
+
.where('slug = :slug', { slug: '/management/roles' })
|
505
|
+
.execute();
|
506
|
+
const screenIdUser = await queryRunner.manager
|
507
|
+
.createQueryBuilder()
|
508
|
+
.select()
|
509
|
+
.from('screens', 's')
|
510
|
+
.where('slug = :slug', { slug: '/management/users' })
|
511
|
+
.execute();
|
512
|
+
const screenIdMenu = await queryRunner.manager
|
513
|
+
.createQueryBuilder()
|
514
|
+
.select()
|
515
|
+
.from('screens', 's')
|
516
|
+
.where('slug = :slug', { slug: '/management/menus' })
|
517
|
+
.execute();
|
518
|
+
|
519
|
+
for (const { url, screendId } of [
|
520
|
+
{ url: '/screens%', screendId: screenIdScreen[0].id },
|
521
|
+
{ url: '/roles%', screendId: screenIdRole[0].id },
|
522
|
+
{ url: '/users%', screendId: screenIdUser[0].id },
|
523
|
+
{ url: '/menus%', screendId: screenIdMenu[0].id },
|
524
|
+
]) {
|
525
|
+
const routesScreens = await queryRunner.manager
|
526
|
+
.createQueryBuilder()
|
527
|
+
.select()
|
528
|
+
.from('routes', 's')
|
529
|
+
.where('s.url LIKE :url', { url })
|
530
|
+
.execute();
|
531
|
+
|
532
|
+
for (const route of routesScreens) {
|
533
|
+
console.log({
|
534
|
+
route_id: route.id,
|
535
|
+
screen_id: screendId,
|
536
|
+
});
|
537
|
+
|
538
|
+
await queryRunner.manager
|
539
|
+
.createQueryBuilder()
|
540
|
+
.insert()
|
541
|
+
.into('route_screens')
|
542
|
+
.values({
|
543
|
+
route_id: route.id,
|
544
|
+
screen_id: screendId,
|
545
|
+
})
|
546
|
+
.execute();
|
547
|
+
}
|
548
|
+
}
|
549
|
+
}
|
550
|
+
async down(queryRunner: QueryRunner) {
|
551
|
+
for (const slug of [
|
552
|
+
'/management/users',
|
553
|
+
'/management/roles',
|
554
|
+
'/management/screens',
|
555
|
+
'/management/menus',
|
556
|
+
]) {
|
557
|
+
await queryRunner.manager
|
558
|
+
.createQueryBuilder()
|
559
|
+
.delete()
|
560
|
+
.from('screens')
|
561
|
+
.where('slug = :slug', { slug })
|
562
|
+
.execute();
|
563
|
+
}
|
564
|
+
|
565
|
+
await queryRunner.dropTable('role_routes');
|
566
|
+
await queryRunner.dropTable('role_screens');
|
567
|
+
await queryRunner.dropTable('role_users');
|
568
|
+
await queryRunner.dropTable('role_menus');
|
569
|
+
await queryRunner.dropTable('roles');
|
570
|
+
await queryRunner.dropTable('route_screens');
|
571
|
+
await queryRunner.dropTable('routes');
|
572
|
+
}
|
573
|
+
}
|