@hedhog/admin 0.0.36 → 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
@@ -2,26 +2,19 @@ import { MigrationInterface, QueryRunner } from 'typeorm';
2
2
 
3
3
  export class Migrate implements MigrationInterface {
4
4
  async up(queryRunner: QueryRunner) {
5
- const screens = await queryRunner.manager
5
+ await queryRunner.manager
6
6
  .createQueryBuilder()
7
- .select()
8
- .from('screens', 's')
7
+ .insert()
8
+ .into('role_users')
9
+ .values([
10
+ { role_id: 1, user_id: 1 },
11
+ { role_id: 2, user_id: 2 },
12
+ ])
9
13
  .execute();
10
-
11
- for (const screen of screens) {
12
- await queryRunner.manager
13
- .createQueryBuilder()
14
- .insert()
15
- .into('role_screens')
16
- .values({
17
- role_id: 1,
18
- screen_id: screen.id,
19
- })
20
- .execute();
21
- }
22
14
  }
23
15
 
24
16
  async down(queryRunner: QueryRunner) {
25
- await queryRunner.manager.delete('role_screens', { role_id: 1 });
17
+ await queryRunner.manager.delete('role_users', { role_id: 1 });
18
+ await queryRunner.manager.delete('role_users', { role_id: 2 });
26
19
  }
27
20
  }
@@ -2,36 +2,56 @@ import { MigrationInterface, QueryRunner } from 'typeorm';
2
2
 
3
3
  export class Migrate implements MigrationInterface {
4
4
  async up(queryRunner: QueryRunner) {
5
- const menus = await queryRunner.manager
5
+ const routes = await queryRunner.manager
6
6
  .createQueryBuilder()
7
7
  .select()
8
- .from('menus', 'm')
8
+ .from('routes', 'r')
9
9
  .execute();
10
10
 
11
- await queryRunner.manager
12
- .createQueryBuilder()
13
- .insert()
14
- .into('role_menus', ['role_id', 'menu_id'])
15
- .values(
16
- menus.map((menu) => ({
11
+ for (const route of routes) {
12
+ await queryRunner.manager
13
+ .createQueryBuilder()
14
+ .insert()
15
+ .into('role_routes')
16
+ .values({
17
17
  role_id: 1,
18
- menu_id: menu.id,
19
- })),
20
- )
21
- .execute();
18
+ route_id: route.id,
19
+ })
20
+ .execute();
21
+ }
22
22
 
23
23
  await queryRunner.manager
24
24
  .createQueryBuilder()
25
25
  .insert()
26
- .into('role_menus', ['role_id', 'menu_id'])
26
+ .into('role_routes')
27
27
  .values({
28
28
  role_id: 2,
29
- menu_id: 1,
30
- });
29
+ route_id: 3,
30
+ })
31
+ .execute();
32
+
33
+ const routesScreens = await queryRunner.manager
34
+ .createQueryBuilder()
35
+ .select()
36
+ .from('routes', 's')
37
+ .where('s.url LIKE :url', { url: '/screens%' })
38
+ .execute();
39
+
40
+ for (const route of routesScreens) {
41
+ await queryRunner.manager
42
+ .createQueryBuilder()
43
+ .insert()
44
+ .into('role_routes')
45
+ .values({
46
+ role_id: 2,
47
+ route_id: route.id,
48
+ })
49
+ .execute();
50
+ }
31
51
  }
32
52
 
33
53
  async down(queryRunner: QueryRunner) {
34
- await queryRunner.manager.delete('role_menus', { role_id: 1 });
35
- await queryRunner.manager.delete('role_menus', { role_id: 2 });
54
+ await queryRunner.manager.delete('role_routes', { role_id: 1 });
55
+ await queryRunner.manager.delete('role_routes', { role_id: 2 });
36
56
  }
37
57
  }
@@ -1,176 +1,27 @@
1
- import {
2
- MigrationInterface,
3
- QueryRunner,
4
- Table,
5
- TableForeignKey,
6
- } from 'typeorm';
7
- import { idColumn, timestampColumn } from '@hedhog/utils';
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
8
2
 
9
3
  export class Migrate implements MigrationInterface {
10
- public async up(queryRunner: QueryRunner): Promise<void> {
11
- await queryRunner.createTable(
12
- new Table({
13
- name: 'setting_groups',
14
- columns: [
15
- idColumn(),
16
- {
17
- name: 'icon',
18
- type: 'varchar',
19
- length: '31',
20
- },
21
- {
22
- name: 'slug',
23
- type: 'varchar',
24
- length: '63',
25
- },
26
- timestampColumn(),
27
- timestampColumn('updated_at'),
28
- ],
29
- }),
30
- );
4
+ async up(queryRunner: QueryRunner) {
5
+ const screens = await queryRunner.manager
6
+ .createQueryBuilder()
7
+ .select()
8
+ .from('screens', 's')
9
+ .execute();
31
10
 
32
- await queryRunner.createTable(
33
- new Table({
34
- name: 'setting_group_translations',
35
- columns: [
36
- {
37
- name: 'locale_id',
38
- type: 'int',
39
- unsigned: true,
40
- isPrimary: true,
41
- },
42
- {
43
- name: 'group_id',
44
- type: 'int',
45
- unsigned: true,
46
- isPrimary: true,
47
- },
48
- {
49
- name: 'name',
50
- type: 'varchar',
51
- length: '63',
52
- },
53
- {
54
- name: 'description',
55
- type: 'varchar',
56
- length: '255',
57
- isNullable: true,
58
- },
59
- timestampColumn(),
60
- timestampColumn('updated_at'),
61
- ],
62
- foreignKeys: [
63
- {
64
- columnNames: ['locale_id'],
65
- referencedColumnNames: ['id'],
66
- referencedTableName: 'locales',
67
- onDelete: 'CASCADE',
68
- },
69
- {
70
- columnNames: ['group_id'],
71
- referencedColumnNames: ['id'],
72
- referencedTableName: 'setting_groups',
73
- onDelete: 'CASCADE',
74
- },
75
- ],
76
- }),
77
- );
78
-
79
- await queryRunner.createTable(
80
- new Table({
81
- name: 'settings',
82
- columns: [
83
- idColumn(),
84
- {
85
- name: 'slug',
86
- type: 'varchar',
87
- isUnique: true,
88
- length: '63',
89
- },
90
- {
91
- name: 'group_id',
92
- type: 'int',
93
- unsigned: true,
94
- },
95
- {
96
- name: 'type',
97
- type: 'enum',
98
- enum: ['string', 'number', 'boolean', 'json'],
99
- default: "'string'",
100
- },
101
- {
102
- name: 'value',
103
- type: 'varchar',
104
- length: '1023',
105
- isNullable: true,
106
- },
107
- timestampColumn(),
108
- timestampColumn('updated_at'),
109
- ],
110
- foreignKeys: [
111
- {
112
- columnNames: ['group_id'],
113
- referencedColumnNames: ['id'],
114
- referencedTableName: 'setting_groups',
115
- onDelete: 'CASCADE',
116
- },
117
- ],
118
- }),
119
- );
120
-
121
- await queryRunner.createTable(
122
- new Table({
123
- name: 'setting_translations',
124
- columns: [
125
- {
126
- name: 'locale_id',
127
- type: 'int',
128
- unsigned: true,
129
- isPrimary: true,
130
- },
131
- {
132
- name: 'setting_id',
133
- type: 'int',
134
- unsigned: true,
135
- isPrimary: true,
136
- },
137
- {
138
- name: 'description',
139
- type: 'varchar',
140
- isNullable: true,
141
- length: '255',
142
- },
143
- {
144
- name: 'name',
145
- type: 'varchar',
146
- isNullable: true,
147
- length: '63',
148
- },
149
- timestampColumn(),
150
- timestampColumn('updated_at'),
151
- ],
152
- foreignKeys: [
153
- {
154
- columnNames: ['locale_id'],
155
- referencedColumnNames: ['id'],
156
- referencedTableName: 'locales',
157
- onDelete: 'CASCADE',
158
- },
159
- {
160
- columnNames: ['setting_id'],
161
- referencedColumnNames: ['id'],
162
- referencedTableName: 'settings',
163
- onDelete: 'CASCADE',
164
- },
165
- ],
166
- }),
167
- );
11
+ for (const screen of screens) {
12
+ await queryRunner.manager
13
+ .createQueryBuilder()
14
+ .insert()
15
+ .into('role_screens')
16
+ .values({
17
+ role_id: 1,
18
+ screen_id: screen.id,
19
+ })
20
+ .execute();
21
+ }
168
22
  }
169
23
 
170
- public async down(queryRunner: QueryRunner): Promise<void> {
171
- await queryRunner.dropTable('setting_translations');
172
- await queryRunner.dropTable('settings');
173
- await queryRunner.dropTable('setting_group_translations');
174
- await queryRunner.dropTable('setting_groups');
24
+ async down(queryRunner: QueryRunner) {
25
+ await queryRunner.manager.delete('role_screens', { role_id: 1 });
175
26
  }
176
27
  }
@@ -1,198 +1,37 @@
1
1
  import { MigrationInterface, QueryRunner } from 'typeorm';
2
2
 
3
3
  export class Migrate implements MigrationInterface {
4
- public async up(queryRunner: QueryRunner): Promise<void> {
5
- const groups = [
6
- {
7
- icon: 'world',
8
- slug: 'localization',
9
- name_en: 'Localization',
10
- name_pt: 'Localização',
11
- description_en: 'Settings related to localization',
12
- description_pt: 'Definições relacionadas com a localização',
13
- settings: [
14
- {
15
- slug: 'language',
16
- type: 'string',
17
- name_en: 'Language',
18
- name_pt: 'Idioma',
19
- description_en: 'The language to use',
20
- description_pt: 'O idioma a utilizar',
21
- value: 'en',
22
- },
23
- {
24
- slug: 'timezone',
25
- type: 'string',
26
- name_en: 'Timezone',
27
- name_pt: 'Fuso Horário',
28
- description_en: 'The timezone to use',
29
- description_pt: 'O fuso horário a utilizar',
30
- value: 'UTC',
31
- },
32
- ],
33
- },
34
- {
35
- icon: 'paint-brush',
36
- slug: 'appearance',
37
- name_en: 'Appearance',
38
- name_pt: 'Aparência',
39
- description_en: 'Settings related to appearance',
40
- description_pt: 'Definições relacionadas com a aparência',
41
- settings: [
42
- {
43
- slug: 'primary',
44
- type: 'string',
45
- name_en: 'Primary Color',
46
- name_pt: 'Cor Primária',
47
- description_en: 'The primary color to use',
48
- description_pt: 'A cor primária a utilizar',
49
- value: '#000000',
50
- },
51
- {
52
- slug: 'secondary',
53
- type: 'string',
54
- name_en: 'Secondary Color',
55
- name_pt: 'Cor Secundária',
56
- description_en: 'The secondary color to use',
57
- description_pt: 'A cor secundária a utilizar',
58
- value: '#FFFFFF',
59
- },
60
- {
61
- slug: 'accent',
62
- type: 'string',
63
- name_en: 'Accent Color',
64
- name_pt: 'Cor de Realce',
65
- description_en: 'The accent color to use',
66
- description_pt: 'A cor de realce a utilizar',
67
- value: '#000000',
68
- },
69
- {
70
- slug: 'background',
71
- type: 'string',
72
- name_en: 'Background Color',
73
- name_pt: 'Cor de Fundo',
74
- description_en: 'The background color to use',
75
- description_pt: 'A cor de fundo a utilizar',
76
- value: '#FFFFFF',
77
- },
78
- {
79
- slug: 'muted',
80
- type: 'string',
81
- name_en: 'Muted Color',
82
- name_pt: 'Cor Suave',
83
- description_en: 'The muted color to use',
84
- description_pt: 'A cor suave a utilizar',
85
- value: '#000000',
86
- },
87
- {
88
- slug: 'radius',
89
- type: 'number',
90
- name_en: 'Border Radius',
91
- name_pt: 'Raio da Borda',
92
- description_en: 'The border radius to use',
93
- description_pt: 'O raio da borda a utilizar',
94
- value: 0.5,
95
- },
96
- {
97
- slug: 'font',
98
- type: 'string',
99
- name_en: 'Font Family',
100
- name_pt: 'Família de Fontes',
101
- description_en: 'The font family to use',
102
- description_pt: 'A família de fontes a utilizar',
103
- value: 'ui-sans-serif, system-ui, sans-serif',
104
- },
105
- ],
106
- },
107
- ];
108
-
109
- for (const group of groups) {
110
- const settingGroup = await queryRunner.manager
111
- .createQueryBuilder()
112
- .insert()
113
- .into('setting_groups', ['icon', 'slug'])
114
- .values({
115
- icon: group.icon,
116
- slug: group.slug,
117
- })
118
- .returning('id')
119
- .execute();
120
-
121
- const settingGroupId = settingGroup.raw[0].id;
122
-
123
- await queryRunner.manager
124
- .createQueryBuilder()
125
- .insert()
126
- .into('setting_group_translations', [
127
- 'locale_id',
128
- 'group_id',
129
- 'name',
130
- 'description',
131
- ])
132
- .values([
133
- {
134
- locale_id: 1,
135
- group_id: settingGroupId,
136
- name: group.name_en,
137
- description: group.description_en,
138
- },
139
- {
140
- locale_id: 2,
141
- group_id: settingGroupId,
142
- name: group.name_pt,
143
- description: group.description_pt,
144
- },
145
- ])
146
- .execute();
147
-
148
- for (const s of group.settings) {
149
- const setting = await queryRunner.manager
150
- .createQueryBuilder()
151
- .insert()
152
- .into('settings', ['slug', 'group_id', 'type', 'value'])
153
- .values({
154
- slug: s.slug,
155
- group_id: settingGroupId,
156
- type: s.type,
157
- value: s.value,
158
- })
159
- .returning('id')
160
- .execute();
161
-
162
- const settingId = setting.raw[0].id;
163
-
164
- await queryRunner.manager
165
- .createQueryBuilder()
166
- .insert()
167
- .into('setting_translations', [
168
- 'locale_id',
169
- 'setting_id',
170
- 'name',
171
- 'description',
172
- ])
173
- .values([
174
- {
175
- locale_id: 1,
176
- setting_id: settingId,
177
- name: s.name_en,
178
- description: s.description_en,
179
- },
180
- {
181
- locale_id: 2,
182
- setting_id: settingId,
183
- name: s.name_pt,
184
- description: s.description_pt,
185
- },
186
- ])
187
- .execute();
188
- }
189
- }
4
+ async up(queryRunner: QueryRunner) {
5
+ const menus = await queryRunner.manager
6
+ .createQueryBuilder()
7
+ .select()
8
+ .from('menus', 'm')
9
+ .execute();
10
+
11
+ await queryRunner.manager
12
+ .createQueryBuilder()
13
+ .insert()
14
+ .into('role_menus', ['role_id', 'menu_id'])
15
+ .values(
16
+ menus.map((menu) => ({
17
+ role_id: 1,
18
+ menu_id: menu.id,
19
+ })),
20
+ )
21
+ .execute();
22
+
23
+ await queryRunner.manager
24
+ .createQueryBuilder()
25
+ .insert()
26
+ .into('role_menus', ['role_id', 'menu_id'])
27
+ .values({
28
+ role_id: 2,
29
+ menu_id: 1,
30
+ });
190
31
  }
191
32
 
192
- public async down(queryRunner: QueryRunner): Promise<void> {
193
- await queryRunner.query('DELETE FROM setting_translations');
194
- await queryRunner.query('DELETE FROM settings');
195
- await queryRunner.query('DELETE FROM setting_group_translations');
196
- await queryRunner.query('DELETE FROM setting_groups');
33
+ async down(queryRunner: QueryRunner) {
34
+ await queryRunner.manager.delete('role_menus', { role_id: 1 });
35
+ await queryRunner.manager.delete('role_menus', { role_id: 2 });
197
36
  }
198
37
  }