@hedhog/admin 0.0.37 → 0.0.38

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. package/dist/admin.module.d.ts.map +1 -1
  2. package/dist/admin.module.js +2 -0
  3. package/dist/admin.module.js.map +1 -1
  4. package/dist/locale/dto/create.dto.d.ts +7 -0
  5. package/dist/locale/dto/create.dto.d.ts.map +1 -0
  6. package/dist/locale/dto/create.dto.js +33 -0
  7. package/dist/locale/dto/create.dto.js.map +1 -0
  8. package/dist/locale/dto/delete.dto.d.ts +4 -0
  9. package/dist/locale/dto/delete.dto.d.ts.map +1 -0
  10. package/dist/locale/dto/delete.dto.js +23 -0
  11. package/dist/locale/dto/delete.dto.js.map +1 -0
  12. package/dist/locale/dto/update.dto.d.ts +7 -0
  13. package/dist/locale/dto/update.dto.d.ts.map +1 -0
  14. package/dist/locale/dto/update.dto.js +37 -0
  15. package/dist/locale/dto/update.dto.js.map +1 -0
  16. package/dist/locale/index.d.ts +5 -0
  17. package/dist/locale/index.d.ts.map +1 -0
  18. package/dist/locale/index.js +21 -0
  19. package/dist/locale/index.js.map +1 -0
  20. package/dist/locale/locale.controller.d.ts +16 -0
  21. package/dist/locale/locale.controller.d.ts.map +1 -0
  22. package/dist/locale/locale.controller.js +110 -0
  23. package/dist/locale/locale.controller.js.map +1 -0
  24. package/dist/locale/locale.decorator.d.ts +2 -0
  25. package/dist/locale/locale.decorator.d.ts.map +1 -0
  26. package/dist/locale/locale.decorator.js +9 -0
  27. package/dist/locale/locale.decorator.js.map +1 -0
  28. package/dist/locale/locale.middleware.d.ts +10 -0
  29. package/dist/locale/locale.middleware.d.ts.map +1 -0
  30. package/dist/locale/locale.middleware.js +45 -0
  31. package/dist/locale/locale.middleware.js.map +1 -0
  32. package/dist/locale/locale.module.d.ts +5 -0
  33. package/dist/locale/locale.module.d.ts.map +1 -0
  34. package/dist/locale/locale.module.js +35 -0
  35. package/dist/locale/locale.module.js.map +1 -0
  36. package/dist/locale/locale.service.d.ts +26 -0
  37. package/dist/locale/locale.service.d.ts.map +1 -0
  38. package/dist/locale/locale.service.js +166 -0
  39. package/dist/locale/locale.service.js.map +1 -0
  40. package/dist/menu/menu.controller.js +1 -1
  41. package/dist/menu/menu.controller.js.map +1 -1
  42. package/dist/role/role.controller.d.ts.map +1 -1
  43. package/dist/role/role.controller.js +1 -1
  44. package/dist/role/role.controller.js.map +1 -1
  45. package/dist/route/route.controller.js +1 -1
  46. package/dist/route/route.controller.js.map +1 -1
  47. package/dist/screen/screen.controller.js +1 -1
  48. package/dist/screen/screen.controller.js.map +1 -1
  49. package/package.json +1 -3
  50. package/src/migrations/migrate-01.ts +270 -121
  51. package/src/migrations/migrate-02.ts +137 -236
  52. package/src/migrations/migrate-03.ts +98 -192
  53. package/src/migrations/migrate-04.ts +167 -197
  54. package/src/migrations/migrate-05.ts +185 -42
  55. package/src/migrations/migrate-06.ts +245 -33
  56. package/src/migrations/migrate-07.ts +87 -21
  57. package/src/migrations/migrate-08.ts +8 -8
  58. package/src/migrations/migrate-09.ts +13 -14
  59. package/src/migrations/migrate-10.ts +8 -8
  60. package/src/migrations/migrate-11.ts +46 -17
  61. package/src/migrations/migrate-12.ts +46 -71
  62. package/src/migrations/migrate-13.ts +15 -9
  63. package/src/migrations/migrate-14.ts +55 -33
  64. package/src/migrations/migrate-15.ts +9 -16
  65. package/src/migrations/migrate-16.ts +37 -17
  66. package/src/migrations/migrate-17.ts +20 -169
  67. package/src/migrations/migrate-18.ts +30 -191
  68. package/src/migrations/migrate-19.ts +176 -0
  69. package/src/migrations/migrate-20.ts +198 -0
@@ -1,22 +1,28 @@
1
1
  import { idColumn, timestampColumn } from '@hedhog/utils';
2
2
 
3
- import { MigrationInterface, QueryRunner, Table, TableUnique } from 'typeorm';
3
+ import {
4
+ MigrationInterface,
5
+ QueryRunner,
6
+ Table,
7
+ TableForeignKey,
8
+ } from 'typeorm';
4
9
 
5
10
  export class Migrate implements MigrationInterface {
6
11
  async up(queryRunner: QueryRunner) {
7
12
  await queryRunner.createTable(
8
13
  new Table({
9
- name: 'routes',
14
+ name: 'screens',
10
15
  columns: [
11
16
  idColumn(),
12
17
  {
13
- name: 'url',
18
+ name: 'slug',
14
19
  type: 'varchar',
20
+ isUnique: true,
15
21
  },
16
22
  {
17
- name: 'method',
18
- type: 'enum',
19
- enum: ['GET', 'POST', 'PATCH', 'DELETE', 'PUT', 'OPTIONS', 'HEAD'],
23
+ name: 'icon',
24
+ type: 'varchar',
25
+ isNullable: true,
20
26
  },
21
27
  timestampColumn(),
22
28
  timestampColumn('updated_at'),
@@ -24,243 +30,207 @@ export class Migrate implements MigrationInterface {
24
30
  }),
25
31
  );
26
32
 
27
- await queryRunner.createUniqueConstraint(
28
- 'routes',
29
- new TableUnique({
30
- columnNames: ['url', 'method'],
31
- name: 'unique_routes',
33
+ await queryRunner.createTable(
34
+ new Table({
35
+ name: 'screen_translations',
36
+ columns: [
37
+ {
38
+ name: 'screen_id',
39
+ type: 'int',
40
+ unsigned: true,
41
+ isPrimary: true,
42
+ },
43
+ {
44
+ name: 'locale_id',
45
+ type: 'int',
46
+ unsigned: true,
47
+ isPrimary: true,
48
+ },
49
+ {
50
+ name: 'name',
51
+ type: 'varchar',
52
+ },
53
+ {
54
+ name: 'description',
55
+ type: 'varchar',
56
+ },
57
+ timestampColumn(),
58
+ timestampColumn('updated_at'),
59
+ ],
60
+ foreignKeys: [
61
+ new TableForeignKey({
62
+ columnNames: ['screen_id'],
63
+ referencedTableName: 'screens',
64
+ referencedColumnNames: ['id'],
65
+ onDelete: 'CASCADE',
66
+ }),
67
+ new TableForeignKey({
68
+ columnNames: ['locale_id'],
69
+ referencedTableName: 'locales',
70
+ referencedColumnNames: ['id'],
71
+ onDelete: 'CASCADE',
72
+ }),
73
+ ],
32
74
  }),
33
75
  );
34
76
 
35
77
  await queryRunner.manager
36
78
  .createQueryBuilder()
37
79
  .insert()
38
- .into('routes', ['url', 'method'])
80
+ .into('screens', ['slug', 'icon'])
39
81
  .values([
40
82
  {
41
- url: '/auth/verify',
42
- method: 'GET',
43
- },
44
- {
45
- url: '/menus',
46
- method: 'GET',
47
- },
48
- {
49
- url: '/menus/system',
50
- method: 'GET',
51
- },
52
- {
53
- url: '/menus/:menuId',
54
- method: 'GET',
55
- },
56
- {
57
- url: '/menus',
58
- method: 'POST',
59
- },
60
- {
61
- url: '/menus/:menuId',
62
- method: 'PATCH',
63
- },
64
- {
65
- url: '/menus/:menuId/roles',
66
- method: 'GET',
67
- },
68
- {
69
- url: '/menus/:menuId/roles',
70
- method: 'PATCH',
71
- },
72
- {
73
- url: '/menus/:menuId/screens',
74
- method: 'GET',
75
- },
76
- {
77
- url: '/menus/:menuId/screens',
78
- method: 'PATCH',
79
- },
80
- {
81
- url: '/menus',
82
- method: 'DELETE',
83
- },
84
- {
85
- url: '/menus/order',
86
- method: 'PATCH',
87
- },
88
- {
89
- url: '/roles',
90
- method: 'GET',
91
- },
92
- {
93
- url: '/roles/:roleId',
94
- method: 'GET',
95
- },
96
- {
97
- url: '/roles/:roleId/users',
98
- method: 'GET',
99
- },
100
- {
101
- url: '/roles/:roleId/menus',
102
- method: 'GET',
103
- },
104
- {
105
- url: '/roles/:roleId/routes',
106
- method: 'GET',
107
- },
108
- {
109
- url: '/roles/:roleId/screens',
110
- method: 'GET',
111
- },
112
- {
113
- url: '/roles/:roleId/users',
114
- method: 'PATCH',
115
- },
116
- {
117
- url: '/roles/:roleId/menus',
118
- method: 'PATCH',
119
- },
120
- {
121
- url: '/roles/:roleId/routes',
122
- method: 'PATCH',
123
- },
124
- {
125
- url: '/roles/:roleId/screens',
126
- method: 'PATCH',
127
- },
128
- {
129
- url: '/roles',
130
- method: 'POST',
131
- },
132
- {
133
- url: '/roles/:roleId',
134
- method: 'PATCH',
135
- },
136
- {
137
- url: '/roles',
138
- method: 'DELETE',
139
- },
140
- {
141
- url: '/screens',
142
- method: 'GET',
143
- },
144
- {
145
- url: '/screens/:screenId',
146
- method: 'GET',
147
- },
148
- {
149
- url: '/screens/:screenId/roles',
150
- method: 'GET',
151
- },
152
- {
153
- url: '/screens/:screenId/routes',
154
- method: 'GET',
155
- },
156
- {
157
- url: '/screens/:screenId/roles',
158
- method: 'PATCH',
159
- },
160
- {
161
- url: '/screens/:screenId/routes',
162
- method: 'PATCH',
163
- },
164
- {
165
- url: '/screens',
166
- method: 'POST',
167
- },
168
- {
169
- url: '/screens/:screenId',
170
- method: 'PATCH',
171
- },
172
- {
173
- url: '/screens',
174
- method: 'DELETE',
175
- },
176
- {
177
- url: '/settings',
178
- method: 'GET',
83
+ slug: '/management/users',
84
+ icon: 'users',
179
85
  },
180
86
  {
181
- url: '/settings/:settingId',
182
- method: 'GET',
87
+ slug: '/management/roles',
88
+ icon: 'circles',
183
89
  },
184
90
  {
185
- url: '/settings',
186
- method: 'POST',
91
+ slug: '/management/screens',
92
+ icon: 'monitor',
187
93
  },
188
94
  {
189
- url: '/settings/:settingId',
190
- method: 'PATCH',
95
+ slug: '/management/menus',
96
+ icon: 'menu',
191
97
  },
192
98
  {
193
- url: '/settings',
194
- method: 'DELETE',
99
+ slug: '/management/routes',
100
+ icon: 'route',
195
101
  },
196
102
  {
197
- url: '/users',
198
- method: 'GET',
199
- },
200
- {
201
- url: '/users/:userId',
202
- method: 'GET',
203
- },
204
- {
205
- url: '/users/:userId/roles',
206
- method: 'GET',
207
- },
208
- {
209
- url: '/users',
210
- method: 'POST',
103
+ slug: '/management/settings',
104
+ icon: 'settings',
211
105
  },
106
+ ])
107
+ .execute();
108
+
109
+ const screenUsers = await queryRunner.manager
110
+ .createQueryBuilder()
111
+ .select('id')
112
+ .from('screens', 's')
113
+ .where('s.slug = :slug', { slug: '/management/users' })
114
+ .execute();
115
+ const screenRoles = await queryRunner.manager
116
+ .createQueryBuilder()
117
+ .select('id')
118
+ .from('screens', 's')
119
+ .where('s.slug = :slug', { slug: '/management/roles' })
120
+ .execute();
121
+ const screenScreens = await queryRunner.manager
122
+ .createQueryBuilder()
123
+ .select('id')
124
+ .from('screens', 's')
125
+ .where('s.slug = :slug', { slug: '/management/screens' })
126
+ .execute();
127
+ const screenMenus = await queryRunner.manager
128
+ .createQueryBuilder()
129
+ .select('id')
130
+ .from('screens', 's')
131
+ .where('s.slug = :slug', { slug: '/management/menus' })
132
+ .execute();
133
+ const screenRoutes = await queryRunner.manager
134
+ .createQueryBuilder()
135
+ .select('id')
136
+ .from('screens', 's')
137
+ .where('s.slug = :slug', { slug: '/management/routes' })
138
+ .execute();
139
+ const screenSettings = await queryRunner.manager
140
+ .createQueryBuilder()
141
+ .select('id')
142
+ .from('screens', 's')
143
+ .where('s.slug = :slug', { slug: '/management/settings' })
144
+ .execute();
145
+
146
+ await queryRunner.manager
147
+ .createQueryBuilder()
148
+ .insert()
149
+ .into('screen_translations', [
150
+ 'screen_id',
151
+ 'locale_id',
152
+ 'name',
153
+ 'description',
154
+ ])
155
+ .values([
212
156
  {
213
- url: '/users/:userId',
214
- method: 'PATCH',
157
+ screen_id: screenUsers[0].id,
158
+ locale_id: 1,
159
+ name: 'Users',
160
+ description: 'Check all users registered in the system.',
215
161
  },
216
162
  {
217
- url: '/users/:userId/roles',
218
- method: 'PATCH',
163
+ screen_id: screenUsers[0].id,
164
+ locale_id: 2,
165
+ name: 'Usuários',
166
+ description: 'Verifique todos os usuários registrados no sistema.',
219
167
  },
220
168
  {
221
- url: '/users',
222
- method: 'DELETE',
169
+ screen_id: screenRoles[0].id,
170
+ locale_id: 1,
171
+ name: 'Roles',
172
+ description: 'Check all roles registered in the system.',
223
173
  },
224
174
  {
225
- url: '/routes',
226
- method: 'GET',
175
+ screen_id: screenRoles[0].id,
176
+ locale_id: 2,
177
+ name: 'Funções',
178
+ description: 'Verifique todas as funções registradas no sistema.',
227
179
  },
228
180
  {
229
- url: '/routes',
230
- method: 'POST',
181
+ screen_id: screenScreens[0].id,
182
+ locale_id: 1,
183
+ name: 'Screens',
184
+ description: 'Check all screens registered in the system.',
231
185
  },
232
186
  {
233
- url: '/routes',
234
- method: 'DELETE',
187
+ screen_id: screenScreens[0].id,
188
+ locale_id: 2,
189
+ name: 'Telas',
190
+ description: 'Verifique todas as telas registradas no sistema.',
235
191
  },
236
192
  {
237
- url: '/routes/:routeId',
238
- method: 'GET',
193
+ screen_id: screenMenus[0].id,
194
+ locale_id: 1,
195
+ name: 'Menus',
196
+ description: 'Check all menus registered in the system.',
239
197
  },
240
198
  {
241
- url: '/routes/:routeId',
242
- method: 'PATCH',
199
+ screen_id: screenMenus[0].id,
200
+ locale_id: 2,
201
+ name: 'Menus',
202
+ description: 'Verifique todos os menus registrados no sistema.',
243
203
  },
244
204
  {
245
- url: '/routes/:routeId/roles',
246
- method: 'GET',
205
+ screen_id: screenRoutes[0].id,
206
+ locale_id: 1,
207
+ name: 'Routes',
208
+ description: 'Check all routes registered in the system.',
247
209
  },
248
210
  {
249
- url: '/routes/:routeId/roles',
250
- method: 'PATCH',
211
+ screen_id: screenRoutes[0].id,
212
+ locale_id: 2,
213
+ name: 'Rotas',
214
+ description: 'Verifique todas as rotas registradas no sistema.',
251
215
  },
252
216
  {
253
- url: '/routes/:routeId/screens',
254
- method: 'GET',
217
+ screen_id: screenSettings[0].id,
218
+ locale_id: 1,
219
+ name: 'Settings',
220
+ description: 'Check all settings registered in the system.',
255
221
  },
256
222
  {
257
- url: '/routes/:routeId/screens',
258
- method: 'PATCH',
223
+ screen_id: screenSettings[0].id,
224
+ locale_id: 2,
225
+ name: 'Configurações',
226
+ description:
227
+ 'Verifique todas as configurações registradas no sistema.',
259
228
  },
260
229
  ])
261
230
  .execute();
262
231
  }
232
+
263
233
  async down(queryRunner: QueryRunner) {
264
- await queryRunner.dropTable('routes');
234
+ await queryRunner.dropTable('screens');
265
235
  }
266
236
  }