@hedhog/admin 0.0.59 → 0.0.60
Sign up to get free protection for your applications and to get access to all the features.
- package/hedhog.yaml +1024 -0
- package/package.json +1 -1
- package/src/migrations/migrate-01.ts +0 -194
- package/src/migrations/migrate-03.ts +0 -62
- package/src/migrations/migrate-04.ts +0 -155
- package/src/migrations/migrate-06.ts +0 -379
- package/src/migrations/migrate-07.ts +0 -64
@@ -5,145 +5,6 @@ import { Menu } from '../entities';
|
|
5
5
|
|
6
6
|
export class Migrate implements MigrationInterface {
|
7
7
|
async up(queryRunner: QueryRunner) {
|
8
|
-
const menus = [
|
9
|
-
{
|
10
|
-
name_en: 'Dashboard',
|
11
|
-
name_pt: 'Dashboard',
|
12
|
-
url: '/',
|
13
|
-
order: 0,
|
14
|
-
icon: 'dashboard',
|
15
|
-
slug: 'dashboard',
|
16
|
-
},
|
17
|
-
{
|
18
|
-
name_en: 'Management',
|
19
|
-
name_pt: 'Gereciamento',
|
20
|
-
url: '/management',
|
21
|
-
order: 1,
|
22
|
-
icon: 'settings',
|
23
|
-
slug: 'management',
|
24
|
-
},
|
25
|
-
];
|
26
|
-
|
27
|
-
for (const menu of menus) {
|
28
|
-
const m = await queryRunner.connection.getRepository(Menu).save({
|
29
|
-
url: menu.url,
|
30
|
-
order: menu.order,
|
31
|
-
icon: menu.icon,
|
32
|
-
slug: menu.slug,
|
33
|
-
});
|
34
|
-
|
35
|
-
console.log('menuInserted', m);
|
36
|
-
|
37
|
-
await queryRunner.manager
|
38
|
-
.createQueryBuilder()
|
39
|
-
.insert()
|
40
|
-
.into('menu_translations', ['menu_id', 'locale_id', 'name'])
|
41
|
-
.values([
|
42
|
-
{
|
43
|
-
menu_id: m.id,
|
44
|
-
locale_id: 1,
|
45
|
-
name: menu.name_en,
|
46
|
-
},
|
47
|
-
{
|
48
|
-
menu_id: m.id,
|
49
|
-
locale_id: 2,
|
50
|
-
name: menu.name_pt,
|
51
|
-
},
|
52
|
-
])
|
53
|
-
.execute();
|
54
|
-
}
|
55
|
-
|
56
|
-
const menusManagement = [
|
57
|
-
{
|
58
|
-
name_en: 'Users',
|
59
|
-
name_pt: 'Usuários',
|
60
|
-
url: '/management/users',
|
61
|
-
order: 0,
|
62
|
-
icon: 'users',
|
63
|
-
slug: 'management/users',
|
64
|
-
},
|
65
|
-
{
|
66
|
-
name_en: 'Roles',
|
67
|
-
name_pt: 'Funções',
|
68
|
-
url: '/management/roles',
|
69
|
-
order: 1,
|
70
|
-
icon: 'circles',
|
71
|
-
slug: 'management/roles',
|
72
|
-
},
|
73
|
-
{
|
74
|
-
name_en: 'Screens',
|
75
|
-
name_pt: 'Telas',
|
76
|
-
url: '/management/screens',
|
77
|
-
order: 2,
|
78
|
-
icon: 'device-tv',
|
79
|
-
slug: 'management/screens',
|
80
|
-
},
|
81
|
-
{
|
82
|
-
name_en: 'Menus',
|
83
|
-
name_pt: 'Menus',
|
84
|
-
url: '/management/menus',
|
85
|
-
order: 3,
|
86
|
-
icon: 'menu',
|
87
|
-
slug: 'management/menus',
|
88
|
-
},
|
89
|
-
{
|
90
|
-
name_en: 'Routes',
|
91
|
-
name_pt: 'Rotas',
|
92
|
-
url: '/management/routes',
|
93
|
-
order: 4,
|
94
|
-
icon: 'route',
|
95
|
-
slug: 'management/routes',
|
96
|
-
},
|
97
|
-
{
|
98
|
-
name_en: 'Settings',
|
99
|
-
name_pt: 'Configurações',
|
100
|
-
url: '/management/settings',
|
101
|
-
order: 5,
|
102
|
-
icon: 'settings',
|
103
|
-
slug: 'management/settings',
|
104
|
-
},
|
105
|
-
];
|
106
|
-
|
107
|
-
const menuManagement = await queryRunner.manager
|
108
|
-
.createQueryBuilder()
|
109
|
-
.select('id')
|
110
|
-
.from('menus', 'm')
|
111
|
-
.where('m.url = :url', { url: '/management' })
|
112
|
-
.execute();
|
113
|
-
|
114
|
-
for (const menu of menusManagement) {
|
115
|
-
const m = await queryRunner.manager
|
116
|
-
.createQueryBuilder()
|
117
|
-
.insert()
|
118
|
-
.into('menus', ['url', 'order', 'icon', 'menu_id', 'slug'])
|
119
|
-
.values({
|
120
|
-
url: menu.url,
|
121
|
-
order: menu.order,
|
122
|
-
icon: menu.icon,
|
123
|
-
menu_id: menuManagement[0].id,
|
124
|
-
slug: menu.slug,
|
125
|
-
})
|
126
|
-
.execute();
|
127
|
-
|
128
|
-
await queryRunner.manager
|
129
|
-
.createQueryBuilder()
|
130
|
-
.insert()
|
131
|
-
.into('menu_translations', ['menu_id', 'locale_id', 'name'])
|
132
|
-
.values([
|
133
|
-
{
|
134
|
-
menu_id: m.raw.insertId,
|
135
|
-
locale_id: 1,
|
136
|
-
name: menu.name_en,
|
137
|
-
},
|
138
|
-
{
|
139
|
-
menu_id: m.raw.insertId,
|
140
|
-
locale_id: 2,
|
141
|
-
name: menu.name_pt,
|
142
|
-
},
|
143
|
-
])
|
144
|
-
.execute();
|
145
|
-
}
|
146
|
-
|
147
8
|
await queryRunner.createTable(
|
148
9
|
new Table({
|
149
10
|
name: 'routes',
|
@@ -169,246 +30,6 @@ export class Migrate implements MigrationInterface {
|
|
169
30
|
],
|
170
31
|
}),
|
171
32
|
);
|
172
|
-
|
173
|
-
await queryRunner.manager
|
174
|
-
.createQueryBuilder()
|
175
|
-
.insert()
|
176
|
-
.into('routes', ['url', 'method'])
|
177
|
-
.values([
|
178
|
-
{
|
179
|
-
url: '/auth/verify',
|
180
|
-
method: 'GET',
|
181
|
-
},
|
182
|
-
{
|
183
|
-
url: '/menus',
|
184
|
-
method: 'GET',
|
185
|
-
},
|
186
|
-
{
|
187
|
-
url: '/menus/system',
|
188
|
-
method: 'GET',
|
189
|
-
},
|
190
|
-
{
|
191
|
-
url: '/menus/:menuId',
|
192
|
-
method: 'GET',
|
193
|
-
},
|
194
|
-
{
|
195
|
-
url: '/menus',
|
196
|
-
method: 'POST',
|
197
|
-
},
|
198
|
-
{
|
199
|
-
url: '/menus/:menuId',
|
200
|
-
method: 'PATCH',
|
201
|
-
},
|
202
|
-
{
|
203
|
-
url: '/menus/:menuId/roles',
|
204
|
-
method: 'GET',
|
205
|
-
},
|
206
|
-
{
|
207
|
-
url: '/menus/:menuId/roles',
|
208
|
-
method: 'PATCH',
|
209
|
-
},
|
210
|
-
{
|
211
|
-
url: '/menus/:menuId/screens',
|
212
|
-
method: 'GET',
|
213
|
-
},
|
214
|
-
{
|
215
|
-
url: '/menus/:menuId/screens',
|
216
|
-
method: 'PATCH',
|
217
|
-
},
|
218
|
-
{
|
219
|
-
url: '/menus',
|
220
|
-
method: 'DELETE',
|
221
|
-
},
|
222
|
-
{
|
223
|
-
url: '/menus/order',
|
224
|
-
method: 'PATCH',
|
225
|
-
},
|
226
|
-
{
|
227
|
-
url: '/roles',
|
228
|
-
method: 'GET',
|
229
|
-
},
|
230
|
-
{
|
231
|
-
url: '/roles/:roleId',
|
232
|
-
method: 'GET',
|
233
|
-
},
|
234
|
-
{
|
235
|
-
url: '/roles/:roleId/users',
|
236
|
-
method: 'GET',
|
237
|
-
},
|
238
|
-
{
|
239
|
-
url: '/roles/:roleId/menus',
|
240
|
-
method: 'GET',
|
241
|
-
},
|
242
|
-
{
|
243
|
-
url: '/roles/:roleId/routes',
|
244
|
-
method: 'GET',
|
245
|
-
},
|
246
|
-
{
|
247
|
-
url: '/roles/:roleId/screens',
|
248
|
-
method: 'GET',
|
249
|
-
},
|
250
|
-
{
|
251
|
-
url: '/roles/:roleId/users',
|
252
|
-
method: 'PATCH',
|
253
|
-
},
|
254
|
-
{
|
255
|
-
url: '/roles/:roleId/menus',
|
256
|
-
method: 'PATCH',
|
257
|
-
},
|
258
|
-
{
|
259
|
-
url: '/roles/:roleId/routes',
|
260
|
-
method: 'PATCH',
|
261
|
-
},
|
262
|
-
{
|
263
|
-
url: '/roles/:roleId/screens',
|
264
|
-
method: 'PATCH',
|
265
|
-
},
|
266
|
-
{
|
267
|
-
url: '/roles',
|
268
|
-
method: 'POST',
|
269
|
-
},
|
270
|
-
{
|
271
|
-
url: '/roles/:roleId',
|
272
|
-
method: 'PATCH',
|
273
|
-
},
|
274
|
-
{
|
275
|
-
url: '/roles',
|
276
|
-
method: 'DELETE',
|
277
|
-
},
|
278
|
-
{
|
279
|
-
url: '/screens',
|
280
|
-
method: 'GET',
|
281
|
-
},
|
282
|
-
{
|
283
|
-
url: '/screens/:screenId',
|
284
|
-
method: 'GET',
|
285
|
-
},
|
286
|
-
{
|
287
|
-
url: '/screens/:screenId/roles',
|
288
|
-
method: 'GET',
|
289
|
-
},
|
290
|
-
{
|
291
|
-
url: '/screens/:screenId/routes',
|
292
|
-
method: 'GET',
|
293
|
-
},
|
294
|
-
{
|
295
|
-
url: '/screens/:screenId/roles',
|
296
|
-
method: 'PATCH',
|
297
|
-
},
|
298
|
-
{
|
299
|
-
url: '/screens/:screenId/routes',
|
300
|
-
method: 'PATCH',
|
301
|
-
},
|
302
|
-
{
|
303
|
-
url: '/screens',
|
304
|
-
method: 'POST',
|
305
|
-
},
|
306
|
-
{
|
307
|
-
url: '/screens/:screenId',
|
308
|
-
method: 'PATCH',
|
309
|
-
},
|
310
|
-
{
|
311
|
-
url: '/screens',
|
312
|
-
method: 'DELETE',
|
313
|
-
},
|
314
|
-
{
|
315
|
-
url: '/settings',
|
316
|
-
method: 'GET',
|
317
|
-
},
|
318
|
-
{
|
319
|
-
url: '/settings/:settingId',
|
320
|
-
method: 'GET',
|
321
|
-
},
|
322
|
-
{
|
323
|
-
url: '/settings',
|
324
|
-
method: 'POST',
|
325
|
-
},
|
326
|
-
{
|
327
|
-
url: '/settings/:settingId',
|
328
|
-
method: 'PATCH',
|
329
|
-
},
|
330
|
-
{
|
331
|
-
url: '/settings/groups',
|
332
|
-
method: 'GET',
|
333
|
-
},
|
334
|
-
{
|
335
|
-
url: '"/settings/groups/:slug"',
|
336
|
-
method: 'GET',
|
337
|
-
},
|
338
|
-
{
|
339
|
-
url: '"/settings/:slug"',
|
340
|
-
method: 'PUT',
|
341
|
-
},
|
342
|
-
{
|
343
|
-
url: '/settings',
|
344
|
-
method: 'DELETE',
|
345
|
-
},
|
346
|
-
{
|
347
|
-
url: '/users',
|
348
|
-
method: 'GET',
|
349
|
-
},
|
350
|
-
{
|
351
|
-
url: '/users/:userId',
|
352
|
-
method: 'GET',
|
353
|
-
},
|
354
|
-
{
|
355
|
-
url: '/users/:userId/roles',
|
356
|
-
method: 'GET',
|
357
|
-
},
|
358
|
-
{
|
359
|
-
url: '/users',
|
360
|
-
method: 'POST',
|
361
|
-
},
|
362
|
-
{
|
363
|
-
url: '/users/:userId',
|
364
|
-
method: 'PATCH',
|
365
|
-
},
|
366
|
-
{
|
367
|
-
url: '/users/:userId/roles',
|
368
|
-
method: 'PATCH',
|
369
|
-
},
|
370
|
-
{
|
371
|
-
url: '/users',
|
372
|
-
method: 'DELETE',
|
373
|
-
},
|
374
|
-
{
|
375
|
-
url: '/routes',
|
376
|
-
method: 'GET',
|
377
|
-
},
|
378
|
-
{
|
379
|
-
url: '/routes',
|
380
|
-
method: 'POST',
|
381
|
-
},
|
382
|
-
{
|
383
|
-
url: '/routes',
|
384
|
-
method: 'DELETE',
|
385
|
-
},
|
386
|
-
{
|
387
|
-
url: '/routes/:routeId',
|
388
|
-
method: 'GET',
|
389
|
-
},
|
390
|
-
{
|
391
|
-
url: '/routes/:routeId',
|
392
|
-
method: 'PATCH',
|
393
|
-
},
|
394
|
-
{
|
395
|
-
url: '/routes/:routeId/roles',
|
396
|
-
method: 'GET',
|
397
|
-
},
|
398
|
-
{
|
399
|
-
url: '/routes/:routeId/roles',
|
400
|
-
method: 'PATCH',
|
401
|
-
},
|
402
|
-
{
|
403
|
-
url: '/routes/:routeId/screens',
|
404
|
-
method: 'GET',
|
405
|
-
},
|
406
|
-
{
|
407
|
-
url: '/routes/:routeId/screens',
|
408
|
-
method: 'PATCH',
|
409
|
-
},
|
410
|
-
])
|
411
|
-
.execute();
|
412
33
|
}
|
413
34
|
async down(queryRunner: QueryRunner) {
|
414
35
|
await queryRunner.dropTable('routes');
|
@@ -58,70 +58,6 @@ export class Migrate implements MigrationInterface {
|
|
58
58
|
],
|
59
59
|
}),
|
60
60
|
);
|
61
|
-
|
62
|
-
const roles = [
|
63
|
-
{
|
64
|
-
id: 1,
|
65
|
-
name_en: 'Administrator',
|
66
|
-
name_pt: 'Administrador',
|
67
|
-
description_en: 'System administrator',
|
68
|
-
description_pt: 'Administrador do sistema',
|
69
|
-
slug: 'admin',
|
70
|
-
},
|
71
|
-
{
|
72
|
-
id: 2,
|
73
|
-
name_en: 'Screen Manager',
|
74
|
-
name_pt: 'Gerenciador de telas',
|
75
|
-
description_en: 'Screen manager',
|
76
|
-
description_pt: 'Gerenciador de telas',
|
77
|
-
slug: 'screen-manager',
|
78
|
-
},
|
79
|
-
{
|
80
|
-
id: 3,
|
81
|
-
name_en: 'Admin Access',
|
82
|
-
name_pt: 'Acesso de administrador',
|
83
|
-
description_en: 'Function to access the admin panel',
|
84
|
-
description_pt: 'Função para ter acesso ao painel de administração',
|
85
|
-
slug: 'admin-access',
|
86
|
-
},
|
87
|
-
];
|
88
|
-
|
89
|
-
for (const role of roles) {
|
90
|
-
await queryRunner.manager
|
91
|
-
.createQueryBuilder()
|
92
|
-
.insert()
|
93
|
-
.into('roles', ['id', 'slug'])
|
94
|
-
.values({
|
95
|
-
id: role.id,
|
96
|
-
slug: role.slug,
|
97
|
-
})
|
98
|
-
.execute();
|
99
|
-
|
100
|
-
await queryRunner.manager
|
101
|
-
.createQueryBuilder()
|
102
|
-
.insert()
|
103
|
-
.into('role_translations', [
|
104
|
-
'role_id',
|
105
|
-
'locale_id',
|
106
|
-
'name',
|
107
|
-
'description',
|
108
|
-
])
|
109
|
-
.values([
|
110
|
-
{
|
111
|
-
role_id: role.id,
|
112
|
-
locale_id: 1,
|
113
|
-
name: role.name_en,
|
114
|
-
description: role.description_en,
|
115
|
-
},
|
116
|
-
{
|
117
|
-
role_id: role.id,
|
118
|
-
locale_id: 2,
|
119
|
-
name: role.name_pt,
|
120
|
-
description: role.description_pt,
|
121
|
-
},
|
122
|
-
])
|
123
|
-
.execute();
|
124
|
-
}
|
125
61
|
}
|
126
62
|
|
127
63
|
async down(queryRunner: QueryRunner) {
|