@hedhog/admin 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (290) hide show
  1. package/dist/admin.module.d.ts +3 -0
  2. package/dist/admin.module.d.ts.map +1 -0
  3. package/dist/admin.module.js +33 -0
  4. package/dist/admin.module.js.map +1 -0
  5. package/dist/auth/src/auth.controller.d.ts +21 -0
  6. package/dist/auth/src/auth.controller.d.ts.map +1 -0
  7. package/dist/auth/src/auth.controller.js +77 -0
  8. package/dist/auth/src/auth.controller.js.map +1 -0
  9. package/dist/auth/src/auth.module.d.ts +3 -0
  10. package/dist/auth/src/auth.module.d.ts.map +1 -0
  11. package/dist/auth/src/auth.module.js +50 -0
  12. package/dist/auth/src/auth.module.js.map +1 -0
  13. package/dist/auth/src/auth.service.d.ts +36 -0
  14. package/dist/auth/src/auth.service.d.ts.map +1 -0
  15. package/dist/auth/src/auth.service.js +162 -0
  16. package/dist/auth/src/auth.service.js.map +1 -0
  17. package/dist/auth/src/auth.service.spec.d.ts +2 -0
  18. package/dist/auth/src/auth.service.spec.d.ts.map +1 -0
  19. package/dist/auth/src/auth.service.spec.js +17 -0
  20. package/dist/auth/src/auth.service.spec.js.map +1 -0
  21. package/dist/auth/src/decorators/public.decorator.d.ts +3 -0
  22. package/dist/auth/src/decorators/public.decorator.d.ts.map +1 -0
  23. package/dist/auth/src/decorators/public.decorator.js +8 -0
  24. package/dist/auth/src/decorators/public.decorator.js.map +1 -0
  25. package/dist/auth/src/decorators/user.decorator.d.ts +2 -0
  26. package/dist/auth/src/decorators/user.decorator.d.ts.map +1 -0
  27. package/dist/auth/src/decorators/user.decorator.js +12 -0
  28. package/dist/auth/src/decorators/user.decorator.js.map +1 -0
  29. package/dist/auth/src/dto/forget.dto.d.ts +4 -0
  30. package/dist/auth/src/dto/forget.dto.d.ts.map +1 -0
  31. package/dist/auth/src/dto/forget.dto.js +21 -0
  32. package/dist/auth/src/dto/forget.dto.js.map +1 -0
  33. package/dist/auth/src/dto/login.dto.d.ts +5 -0
  34. package/dist/auth/src/dto/login.dto.d.ts.map +1 -0
  35. package/dist/auth/src/dto/login.dto.js +31 -0
  36. package/dist/auth/src/dto/login.dto.js.map +1 -0
  37. package/dist/auth/src/dto/otp.dto.d.ts +5 -0
  38. package/dist/auth/src/dto/otp.dto.d.ts.map +1 -0
  39. package/dist/auth/src/dto/otp.dto.js +27 -0
  40. package/dist/auth/src/dto/otp.dto.js.map +1 -0
  41. package/dist/auth/src/enums/multifactor-type.enum.d.ts +5 -0
  42. package/dist/auth/src/enums/multifactor-type.enum.d.ts.map +1 -0
  43. package/dist/auth/src/enums/multifactor-type.enum.js +9 -0
  44. package/dist/auth/src/enums/multifactor-type.enum.js.map +1 -0
  45. package/dist/auth/src/guards/auth.guard.d.ts +11 -0
  46. package/dist/auth/src/guards/auth.guard.d.ts.map +1 -0
  47. package/dist/auth/src/guards/auth.guard.js +56 -0
  48. package/dist/auth/src/guards/auth.guard.js.map +1 -0
  49. package/dist/auth/src/migrations/index.d.ts +6 -0
  50. package/dist/auth/src/migrations/index.d.ts.map +1 -0
  51. package/dist/auth/src/migrations/index.js +121 -0
  52. package/dist/auth/src/migrations/index.js.map +1 -0
  53. package/dist/auth/src/types/user.type.d.ts +9 -0
  54. package/dist/auth/src/types/user.type.d.ts.map +1 -0
  55. package/dist/auth/src/types/user.type.js +3 -0
  56. package/dist/auth/src/types/user.type.js.map +1 -0
  57. package/dist/file/src/dto/delete.dto.d.ts +4 -0
  58. package/dist/file/src/dto/delete.dto.d.ts.map +1 -0
  59. package/dist/file/src/dto/delete.dto.js +23 -0
  60. package/dist/file/src/dto/delete.dto.js.map +1 -0
  61. package/dist/file/src/file.module.d.ts +3 -0
  62. package/dist/file/src/file.module.d.ts.map +1 -0
  63. package/dist/file/src/file.module.js +29 -0
  64. package/dist/file/src/file.module.js.map +1 -0
  65. package/dist/file/src/file.service.d.ts +12 -0
  66. package/dist/file/src/file.service.d.ts.map +1 -0
  67. package/dist/file/src/file.service.js +59 -0
  68. package/dist/file/src/file.service.js.map +1 -0
  69. package/dist/file/src/migrations/index.d.ts +6 -0
  70. package/dist/file/src/migrations/index.d.ts.map +1 -0
  71. package/dist/file/src/migrations/index.js +137 -0
  72. package/dist/file/src/migrations/index.js.map +1 -0
  73. package/dist/index.d.ts +26 -0
  74. package/dist/index.d.ts.map +1 -0
  75. package/dist/index.js +51 -0
  76. package/dist/index.js.map +1 -0
  77. package/dist/mail/src/enums/mail-configuration-type.enum.d.ts +6 -0
  78. package/dist/mail/src/enums/mail-configuration-type.enum.d.ts.map +1 -0
  79. package/dist/mail/src/enums/mail-configuration-type.enum.js +10 -0
  80. package/dist/mail/src/enums/mail-configuration-type.enum.js.map +1 -0
  81. package/dist/mail/src/interfaces/index.d.ts +3 -0
  82. package/dist/mail/src/interfaces/index.d.ts.map +1 -0
  83. package/dist/mail/src/interfaces/index.js +19 -0
  84. package/dist/mail/src/interfaces/index.js.map +1 -0
  85. package/dist/mail/src/interfaces/mail-module-options.interface.d.ts +32 -0
  86. package/dist/mail/src/interfaces/mail-module-options.interface.d.ts.map +1 -0
  87. package/dist/mail/src/interfaces/mail-module-options.interface.js +3 -0
  88. package/dist/mail/src/interfaces/mail-module-options.interface.js.map +1 -0
  89. package/dist/mail/src/interfaces/mail-type.d.ts +13 -0
  90. package/dist/mail/src/interfaces/mail-type.d.ts.map +1 -0
  91. package/dist/mail/src/interfaces/mail-type.js +3 -0
  92. package/dist/mail/src/interfaces/mail-type.js.map +1 -0
  93. package/dist/mail/src/mail.consts.d.ts +17 -0
  94. package/dist/mail/src/mail.consts.d.ts.map +1 -0
  95. package/dist/mail/src/mail.consts.js +5 -0
  96. package/dist/mail/src/mail.consts.js.map +1 -0
  97. package/dist/mail/src/mail.module.d.ts +8 -0
  98. package/dist/mail/src/mail.module.d.ts.map +1 -0
  99. package/dist/mail/src/mail.module.js +51 -0
  100. package/dist/mail/src/mail.module.js.map +1 -0
  101. package/dist/mail/src/mail.service.d.ts +14 -0
  102. package/dist/mail/src/mail.service.d.ts.map +1 -0
  103. package/dist/mail/src/mail.service.js +281 -0
  104. package/dist/mail/src/mail.service.js.map +1 -0
  105. package/dist/mail/src/mail.service.spec.d.ts +2 -0
  106. package/dist/mail/src/mail.service.spec.d.ts.map +1 -0
  107. package/dist/mail/src/mail.service.spec.js +17 -0
  108. package/dist/mail/src/mail.service.spec.js.map +1 -0
  109. package/dist/menu/src/dto/create.dto.d.ts +8 -0
  110. package/dist/menu/src/dto/create.dto.d.ts.map +1 -0
  111. package/dist/menu/src/dto/create.dto.js +44 -0
  112. package/dist/menu/src/dto/create.dto.js.map +1 -0
  113. package/dist/menu/src/dto/delete.dto.d.ts +4 -0
  114. package/dist/menu/src/dto/delete.dto.d.ts.map +1 -0
  115. package/dist/menu/src/dto/delete.dto.js +24 -0
  116. package/dist/menu/src/dto/delete.dto.js.map +1 -0
  117. package/dist/menu/src/dto/order.dto.d.ts +4 -0
  118. package/dist/menu/src/dto/order.dto.d.ts.map +1 -0
  119. package/dist/menu/src/dto/order.dto.js +23 -0
  120. package/dist/menu/src/dto/order.dto.js.map +1 -0
  121. package/dist/menu/src/dto/update.dto.d.ts +7 -0
  122. package/dist/menu/src/dto/update.dto.d.ts.map +1 -0
  123. package/dist/menu/src/dto/update.dto.js +37 -0
  124. package/dist/menu/src/dto/update.dto.js.map +1 -0
  125. package/dist/menu/src/menu.controller.d.ts +19 -0
  126. package/dist/menu/src/menu.controller.d.ts.map +1 -0
  127. package/dist/menu/src/menu.controller.js +117 -0
  128. package/dist/menu/src/menu.controller.js.map +1 -0
  129. package/dist/menu/src/menu.module.d.ts +3 -0
  130. package/dist/menu/src/menu.module.d.ts.map +1 -0
  131. package/dist/menu/src/menu.module.js +31 -0
  132. package/dist/menu/src/menu.module.js.map +1 -0
  133. package/dist/menu/src/menu.service.d.ts +23 -0
  134. package/dist/menu/src/menu.service.d.ts.map +1 -0
  135. package/dist/menu/src/menu.service.js +117 -0
  136. package/dist/menu/src/menu.service.js.map +1 -0
  137. package/dist/menu/src/migrations/index.d.ts +7 -0
  138. package/dist/menu/src/migrations/index.d.ts.map +1 -0
  139. package/dist/menu/src/migrations/index.js +101 -0
  140. package/dist/menu/src/migrations/index.js.map +1 -0
  141. package/dist/migrations/1726795702341-migrate.d.ts +6 -0
  142. package/dist/migrations/1726795702341-migrate.d.ts.map +1 -0
  143. package/dist/migrations/1726795702341-migrate.js +121 -0
  144. package/dist/migrations/1726795702341-migrate.js.map +1 -0
  145. package/dist/migrations/1726795734665-migrate.d.ts +6 -0
  146. package/dist/migrations/1726795734665-migrate.d.ts.map +1 -0
  147. package/dist/migrations/1726795734665-migrate.js +40 -0
  148. package/dist/migrations/1726795734665-migrate.js.map +1 -0
  149. package/dist/migrations/1726795818403-migrate.d.ts +7 -0
  150. package/dist/migrations/1726795818403-migrate.d.ts.map +1 -0
  151. package/dist/migrations/1726795818403-migrate.js +101 -0
  152. package/dist/migrations/1726795818403-migrate.js.map +1 -0
  153. package/dist/migrations/1726795828359-migrate.d.ts +6 -0
  154. package/dist/migrations/1726795828359-migrate.d.ts.map +1 -0
  155. package/dist/migrations/1726795828359-migrate.js +525 -0
  156. package/dist/migrations/1726795828359-migrate.js.map +1 -0
  157. package/dist/permission/src/decorators/permission.decorator.d.ts +3 -0
  158. package/dist/permission/src/decorators/permission.decorator.d.ts.map +1 -0
  159. package/dist/permission/src/decorators/permission.decorator.js +8 -0
  160. package/dist/permission/src/decorators/permission.decorator.js.map +1 -0
  161. package/dist/permission/src/dto/create.dto.d.ts +5 -0
  162. package/dist/permission/src/dto/create.dto.d.ts.map +1 -0
  163. package/dist/permission/src/dto/create.dto.js +27 -0
  164. package/dist/permission/src/dto/create.dto.js.map +1 -0
  165. package/dist/permission/src/dto/delete.dto.d.ts +4 -0
  166. package/dist/permission/src/dto/delete.dto.d.ts.map +1 -0
  167. package/dist/permission/src/dto/delete.dto.js +23 -0
  168. package/dist/permission/src/dto/delete.dto.js.map +1 -0
  169. package/dist/permission/src/dto/update.dto.d.ts +5 -0
  170. package/dist/permission/src/dto/update.dto.d.ts.map +1 -0
  171. package/dist/permission/src/dto/update.dto.js +27 -0
  172. package/dist/permission/src/dto/update.dto.js.map +1 -0
  173. package/dist/permission/src/guards/permission.guard.d.ts +11 -0
  174. package/dist/permission/src/guards/permission.guard.d.ts.map +1 -0
  175. package/dist/permission/src/guards/permission.guard.js +99 -0
  176. package/dist/permission/src/guards/permission.guard.js.map +1 -0
  177. package/dist/permission/src/migrations/index.d.ts +6 -0
  178. package/dist/permission/src/migrations/index.d.ts.map +1 -0
  179. package/dist/permission/src/migrations/index.js +520 -0
  180. package/dist/permission/src/migrations/index.js.map +1 -0
  181. package/dist/permission/src/permission.controller.d.ts +14 -0
  182. package/dist/permission/src/permission.controller.d.ts.map +1 -0
  183. package/dist/permission/src/permission.controller.js +95 -0
  184. package/dist/permission/src/permission.controller.js.map +1 -0
  185. package/dist/permission/src/permission.module.d.ts +3 -0
  186. package/dist/permission/src/permission.module.d.ts.map +1 -0
  187. package/dist/permission/src/permission.module.js +39 -0
  188. package/dist/permission/src/permission.module.js.map +1 -0
  189. package/dist/permission/src/permission.service.d.ts +19 -0
  190. package/dist/permission/src/permission.service.d.ts.map +1 -0
  191. package/dist/permission/src/permission.service.js +73 -0
  192. package/dist/permission/src/permission.service.js.map +1 -0
  193. package/dist/permission/src/types/permission.types.d.ts +33 -0
  194. package/dist/permission/src/types/permission.types.d.ts.map +1 -0
  195. package/dist/permission/src/types/permission.types.js +3 -0
  196. package/dist/permission/src/types/permission.types.js.map +1 -0
  197. package/dist/screen/src/dto/create.dto.d.ts +7 -0
  198. package/dist/screen/src/dto/create.dto.d.ts.map +1 -0
  199. package/dist/screen/src/dto/create.dto.js +37 -0
  200. package/dist/screen/src/dto/create.dto.js.map +1 -0
  201. package/dist/screen/src/dto/delete.dto.d.ts +4 -0
  202. package/dist/screen/src/dto/delete.dto.d.ts.map +1 -0
  203. package/dist/screen/src/dto/delete.dto.js +23 -0
  204. package/dist/screen/src/dto/delete.dto.js.map +1 -0
  205. package/dist/screen/src/dto/update.dto.d.ts +7 -0
  206. package/dist/screen/src/dto/update.dto.d.ts.map +1 -0
  207. package/dist/screen/src/dto/update.dto.js +37 -0
  208. package/dist/screen/src/dto/update.dto.js.map +1 -0
  209. package/dist/screen/src/migrations/index.d.ts +6 -0
  210. package/dist/screen/src/migrations/index.d.ts.map +1 -0
  211. package/dist/screen/src/migrations/index.js +40 -0
  212. package/dist/screen/src/migrations/index.js.map +1 -0
  213. package/dist/screen/src/screen.controller.d.ts +14 -0
  214. package/dist/screen/src/screen.controller.d.ts.map +1 -0
  215. package/dist/screen/src/screen.controller.js +94 -0
  216. package/dist/screen/src/screen.controller.js.map +1 -0
  217. package/dist/screen/src/screen.module.d.ts +3 -0
  218. package/dist/screen/src/screen.module.d.ts.map +1 -0
  219. package/dist/screen/src/screen.module.js +31 -0
  220. package/dist/screen/src/screen.module.js.map +1 -0
  221. package/dist/screen/src/screen.service.d.ts +19 -0
  222. package/dist/screen/src/screen.service.d.ts.map +1 -0
  223. package/dist/screen/src/screen.service.js +73 -0
  224. package/dist/screen/src/screen.service.js.map +1 -0
  225. package/dist/setting/src/dto/create.dto.d.ts +4 -0
  226. package/dist/setting/src/dto/create.dto.d.ts.map +1 -0
  227. package/dist/setting/src/dto/create.dto.js +22 -0
  228. package/dist/setting/src/dto/create.dto.js.map +1 -0
  229. package/dist/setting/src/dto/delete.dto.d.ts +4 -0
  230. package/dist/setting/src/dto/delete.dto.d.ts.map +1 -0
  231. package/dist/setting/src/dto/delete.dto.js +23 -0
  232. package/dist/setting/src/dto/delete.dto.js.map +1 -0
  233. package/dist/setting/src/dto/update.dto.d.ts +4 -0
  234. package/dist/setting/src/dto/update.dto.d.ts.map +1 -0
  235. package/dist/setting/src/dto/update.dto.js +8 -0
  236. package/dist/setting/src/dto/update.dto.js.map +1 -0
  237. package/dist/setting/src/migrations/index.d.ts +6 -0
  238. package/dist/setting/src/migrations/index.d.ts.map +1 -0
  239. package/dist/setting/src/migrations/index.js +67 -0
  240. package/dist/setting/src/migrations/index.js.map +1 -0
  241. package/dist/setting/src/settings.controller.d.ts +14 -0
  242. package/dist/setting/src/settings.controller.d.ts.map +1 -0
  243. package/dist/setting/src/settings.controller.js +94 -0
  244. package/dist/setting/src/settings.controller.js.map +1 -0
  245. package/dist/setting/src/settings.module.d.ts +3 -0
  246. package/dist/setting/src/settings.module.d.ts.map +1 -0
  247. package/dist/setting/src/settings.module.js +31 -0
  248. package/dist/setting/src/settings.module.js.map +1 -0
  249. package/dist/setting/src/settings.service.d.ts +19 -0
  250. package/dist/setting/src/settings.service.d.ts.map +1 -0
  251. package/dist/setting/src/settings.service.js +70 -0
  252. package/dist/setting/src/settings.service.js.map +1 -0
  253. package/dist/user/src/constants/user.constants.d.ts +2 -0
  254. package/dist/user/src/constants/user.constants.d.ts.map +1 -0
  255. package/dist/user/src/constants/user.constants.js +5 -0
  256. package/dist/user/src/constants/user.constants.js.map +1 -0
  257. package/dist/user/src/dto/create.dto.d.ts +6 -0
  258. package/dist/user/src/dto/create.dto.d.ts.map +1 -0
  259. package/dist/user/src/dto/create.dto.js +37 -0
  260. package/dist/user/src/dto/create.dto.js.map +1 -0
  261. package/dist/user/src/dto/delete.dto.d.ts +4 -0
  262. package/dist/user/src/dto/delete.dto.d.ts.map +1 -0
  263. package/dist/user/src/dto/delete.dto.js +23 -0
  264. package/dist/user/src/dto/delete.dto.js.map +1 -0
  265. package/dist/user/src/dto/update.dto.d.ts +8 -0
  266. package/dist/user/src/dto/update.dto.d.ts.map +1 -0
  267. package/dist/user/src/dto/update.dto.js +50 -0
  268. package/dist/user/src/dto/update.dto.js.map +1 -0
  269. package/dist/user/src/user.controller.d.ts +14 -0
  270. package/dist/user/src/user.controller.d.ts.map +1 -0
  271. package/dist/user/src/user.controller.js +94 -0
  272. package/dist/user/src/user.controller.js.map +1 -0
  273. package/dist/user/src/user.module.d.ts +3 -0
  274. package/dist/user/src/user.module.d.ts.map +1 -0
  275. package/dist/user/src/user.module.js +31 -0
  276. package/dist/user/src/user.module.js.map +1 -0
  277. package/dist/user/src/user.service.d.ts +20 -0
  278. package/dist/user/src/user.service.d.ts.map +1 -0
  279. package/dist/user/src/user.service.js +84 -0
  280. package/dist/user/src/user.service.js.map +1 -0
  281. package/dist/user/src/user.service.spec.d.ts +2 -0
  282. package/dist/user/src/user.service.spec.d.ts.map +1 -0
  283. package/dist/user/src/user.service.spec.js +17 -0
  284. package/dist/user/src/user.service.spec.js.map +1 -0
  285. package/package.json +29 -0
  286. package/src/mail/src/mail.template.ejs +1 -0
  287. package/src/migrations/1726795702341-migrate.ts +107 -0
  288. package/src/migrations/1726795734665-migrate.ts +40 -0
  289. package/src/migrations/1726795818403-migrate.ts +161 -0
  290. 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
+ }