@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,107 @@
|
|
1
|
+
import {
|
2
|
+
MigrationInterface,
|
3
|
+
QueryRunner,
|
4
|
+
Table,
|
5
|
+
TableForeignKey,
|
6
|
+
} from "typeorm";
|
7
|
+
import { idColumn, timestampColumn } from "@hedhog/utils";
|
8
|
+
import * as bcrypt from "bcrypt";
|
9
|
+
|
10
|
+
export class Migrate1726795702341 implements MigrationInterface {
|
11
|
+
async up(queryRunner: QueryRunner) {
|
12
|
+
await queryRunner.createTable(
|
13
|
+
new Table({
|
14
|
+
name: "multifactors",
|
15
|
+
columns: [
|
16
|
+
idColumn(),
|
17
|
+
{
|
18
|
+
name: "name",
|
19
|
+
type: "varchar",
|
20
|
+
},
|
21
|
+
timestampColumn(),
|
22
|
+
timestampColumn("updated_at"),
|
23
|
+
],
|
24
|
+
}),
|
25
|
+
);
|
26
|
+
|
27
|
+
await queryRunner.manager
|
28
|
+
.createQueryBuilder()
|
29
|
+
.insert()
|
30
|
+
.into("multifactors", ["name"])
|
31
|
+
.values([
|
32
|
+
{
|
33
|
+
name: "Email",
|
34
|
+
},
|
35
|
+
{
|
36
|
+
name: "Applicativo",
|
37
|
+
},
|
38
|
+
])
|
39
|
+
.execute();
|
40
|
+
|
41
|
+
await queryRunner.createTable(
|
42
|
+
new Table({
|
43
|
+
name: "users",
|
44
|
+
columns: [
|
45
|
+
idColumn(),
|
46
|
+
{
|
47
|
+
name: "name",
|
48
|
+
type: "varchar",
|
49
|
+
},
|
50
|
+
{
|
51
|
+
name: "email",
|
52
|
+
type: "varchar",
|
53
|
+
},
|
54
|
+
{
|
55
|
+
name: "password",
|
56
|
+
type: "varchar",
|
57
|
+
},
|
58
|
+
{
|
59
|
+
name: "multifactor_id",
|
60
|
+
type: "int",
|
61
|
+
isNullable: true,
|
62
|
+
unsigned: true,
|
63
|
+
},
|
64
|
+
{
|
65
|
+
name: "code",
|
66
|
+
type: "varchar",
|
67
|
+
isNullable: true,
|
68
|
+
},
|
69
|
+
timestampColumn(),
|
70
|
+
timestampColumn("updated_at"),
|
71
|
+
],
|
72
|
+
}),
|
73
|
+
);
|
74
|
+
|
75
|
+
await queryRunner.createForeignKeys("users", [
|
76
|
+
new TableForeignKey({
|
77
|
+
columnNames: ["multifactor_id"],
|
78
|
+
referencedColumnNames: ["id"],
|
79
|
+
referencedTableName: "multifactors",
|
80
|
+
name: "fk_users_to_multifactors_on_multifactor_id",
|
81
|
+
onDelete: "Cascade",
|
82
|
+
}),
|
83
|
+
]);
|
84
|
+
|
85
|
+
await queryRunner.manager
|
86
|
+
.createQueryBuilder()
|
87
|
+
.insert()
|
88
|
+
.into("users", ["name", "email", "password"])
|
89
|
+
.values([
|
90
|
+
{
|
91
|
+
name: "Superuser",
|
92
|
+
email: "root@hedhog.com",
|
93
|
+
password: await bcrypt.hash(`hedhog`, 12),
|
94
|
+
},
|
95
|
+
{
|
96
|
+
name: "User",
|
97
|
+
email: "user@hedhog.com",
|
98
|
+
password: await bcrypt.hash(`hedhog`, 12),
|
99
|
+
},
|
100
|
+
])
|
101
|
+
.execute();
|
102
|
+
}
|
103
|
+
async down(queryRunner: QueryRunner) {
|
104
|
+
await queryRunner.dropTable("multifactors");
|
105
|
+
await queryRunner.dropTable("users");
|
106
|
+
}
|
107
|
+
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import { idColumn, timestampColumn } from "@hedhog/utils";
|
2
|
+
|
3
|
+
import { MigrationInterface, QueryRunner, Table } from "typeorm";
|
4
|
+
|
5
|
+
export class Migrate1726795734665 implements MigrationInterface {
|
6
|
+
async up(queryRunner: QueryRunner) {
|
7
|
+
await queryRunner.createTable(
|
8
|
+
new Table({
|
9
|
+
name: "screens",
|
10
|
+
columns: [
|
11
|
+
idColumn(),
|
12
|
+
{
|
13
|
+
name: "name",
|
14
|
+
type: "varchar",
|
15
|
+
},
|
16
|
+
{
|
17
|
+
name: "slug",
|
18
|
+
type: "varchar",
|
19
|
+
isUnique: true,
|
20
|
+
},
|
21
|
+
{
|
22
|
+
name: "description",
|
23
|
+
type: "varchar",
|
24
|
+
},
|
25
|
+
{
|
26
|
+
name: "icon",
|
27
|
+
type: "varchar",
|
28
|
+
isNullable: true,
|
29
|
+
},
|
30
|
+
timestampColumn(),
|
31
|
+
timestampColumn("updated_at"),
|
32
|
+
],
|
33
|
+
}),
|
34
|
+
);
|
35
|
+
}
|
36
|
+
|
37
|
+
async down(queryRunner: QueryRunner) {
|
38
|
+
await queryRunner.dropTable("screens");
|
39
|
+
}
|
40
|
+
}
|
@@ -0,0 +1,161 @@
|
|
1
|
+
import {
|
2
|
+
MigrationInterface,
|
3
|
+
QueryRunner,
|
4
|
+
Table,
|
5
|
+
TableForeignKey,
|
6
|
+
} from "typeorm";
|
7
|
+
import { idColumn, timestampColumn } from "@hedhog/utils";
|
8
|
+
|
9
|
+
export class Migrate1726795818403 implements MigrationInterface {
|
10
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
11
|
+
await queryRunner.createTable(
|
12
|
+
new Table({
|
13
|
+
name: "menus",
|
14
|
+
columns: [
|
15
|
+
idColumn(),
|
16
|
+
{
|
17
|
+
name: "name",
|
18
|
+
type: "varchar",
|
19
|
+
},
|
20
|
+
{
|
21
|
+
name: "url",
|
22
|
+
type: "varchar",
|
23
|
+
isNullable: true,
|
24
|
+
},
|
25
|
+
{
|
26
|
+
name: "order",
|
27
|
+
type: "int",
|
28
|
+
default: 0,
|
29
|
+
unsigned: true,
|
30
|
+
},
|
31
|
+
{
|
32
|
+
name: "menu_id",
|
33
|
+
type: "int",
|
34
|
+
isNullable: true,
|
35
|
+
unsigned: true,
|
36
|
+
},
|
37
|
+
{
|
38
|
+
name: "icon",
|
39
|
+
type: "varchar",
|
40
|
+
isNullable: true,
|
41
|
+
},
|
42
|
+
timestampColumn(),
|
43
|
+
timestampColumn("updated_at"),
|
44
|
+
],
|
45
|
+
}),
|
46
|
+
);
|
47
|
+
|
48
|
+
await queryRunner.createTable(
|
49
|
+
new Table({
|
50
|
+
name: "menu_screens",
|
51
|
+
columns: [
|
52
|
+
{
|
53
|
+
name: "menu_id",
|
54
|
+
type: "int",
|
55
|
+
isPrimary: true,
|
56
|
+
unsigned: true,
|
57
|
+
},
|
58
|
+
{
|
59
|
+
name: "screen_id",
|
60
|
+
type: "int",
|
61
|
+
isPrimary: true,
|
62
|
+
unsigned: true,
|
63
|
+
},
|
64
|
+
],
|
65
|
+
}),
|
66
|
+
);
|
67
|
+
|
68
|
+
await queryRunner.createForeignKey(
|
69
|
+
"menu_screens",
|
70
|
+
new TableForeignKey({
|
71
|
+
columnNames: ["menu_id"],
|
72
|
+
referencedColumnNames: ["id"],
|
73
|
+
referencedTableName: "menus",
|
74
|
+
onDelete: "CASCADE",
|
75
|
+
}),
|
76
|
+
);
|
77
|
+
|
78
|
+
await queryRunner.createForeignKey(
|
79
|
+
"menu_screens",
|
80
|
+
new TableForeignKey({
|
81
|
+
columnNames: ["screen_id"],
|
82
|
+
referencedColumnNames: ["id"],
|
83
|
+
referencedTableName: "screens",
|
84
|
+
onDelete: "CASCADE",
|
85
|
+
}),
|
86
|
+
);
|
87
|
+
|
88
|
+
//System Populating
|
89
|
+
await this.insertMenu(queryRunner, "Dashboard", "/", 0, null, "dashboard");
|
90
|
+
const managementId = await this.insertMenu(
|
91
|
+
queryRunner,
|
92
|
+
"Management",
|
93
|
+
null,
|
94
|
+
1,
|
95
|
+
null,
|
96
|
+
"settings",
|
97
|
+
);
|
98
|
+
await this.insertMenu(
|
99
|
+
queryRunner,
|
100
|
+
"Users",
|
101
|
+
"/management/users",
|
102
|
+
0,
|
103
|
+
managementId,
|
104
|
+
"users",
|
105
|
+
);
|
106
|
+
await this.insertMenu(
|
107
|
+
queryRunner,
|
108
|
+
"Roles",
|
109
|
+
"/management/roles",
|
110
|
+
1,
|
111
|
+
managementId,
|
112
|
+
"circles",
|
113
|
+
);
|
114
|
+
await this.insertMenu(
|
115
|
+
queryRunner,
|
116
|
+
"Screens",
|
117
|
+
"/management/screens",
|
118
|
+
2,
|
119
|
+
managementId,
|
120
|
+
"screem",
|
121
|
+
);
|
122
|
+
await this.insertMenu(
|
123
|
+
queryRunner,
|
124
|
+
"Menus",
|
125
|
+
"/management/menus",
|
126
|
+
3,
|
127
|
+
managementId,
|
128
|
+
"menu",
|
129
|
+
);
|
130
|
+
}
|
131
|
+
|
132
|
+
private async insertMenu(
|
133
|
+
queryRunner: QueryRunner,
|
134
|
+
name: string,
|
135
|
+
url: string,
|
136
|
+
order: number,
|
137
|
+
menuId: number,
|
138
|
+
icon: string,
|
139
|
+
) {
|
140
|
+
const result = await queryRunner.manager
|
141
|
+
.createQueryBuilder()
|
142
|
+
.insert()
|
143
|
+
.into("menus")
|
144
|
+
.values({
|
145
|
+
name,
|
146
|
+
url,
|
147
|
+
order,
|
148
|
+
menu_id: menuId,
|
149
|
+
icon,
|
150
|
+
})
|
151
|
+
.returning("id")
|
152
|
+
.execute();
|
153
|
+
|
154
|
+
return result.raw[0].id;
|
155
|
+
}
|
156
|
+
|
157
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
158
|
+
await queryRunner.dropTable("menu_screens");
|
159
|
+
await queryRunner.dropTable("menus");
|
160
|
+
}
|
161
|
+
}
|