@hedhog/admin 0.0.39 → 0.0.40
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/auth/auth.service.spec.d.ts +2 -0
- package/dist/auth/auth.service.spec.d.ts.map +1 -0
- package/dist/auth/auth.service.spec.js +163 -0
- package/dist/auth/auth.service.spec.js.map +1 -0
- package/dist/locale/locale.module.js +2 -2
- package/dist/locale/locale.module.js.map +1 -1
- package/dist/locale/locale.service.js +1 -1
- package/dist/locale/locale.service.js.map +1 -1
- package/dist/locale/locale.service.spec.d.ts +2 -0
- package/dist/locale/locale.service.spec.d.ts.map +1 -0
- package/dist/locale/locale.service.spec.js +171 -0
- package/dist/locale/locale.service.spec.js.map +1 -0
- package/dist/menu/menu.service.spec.d.ts +2 -0
- package/dist/menu/menu.service.spec.d.ts.map +1 -0
- package/dist/menu/menu.service.spec.js +196 -0
- package/dist/menu/menu.service.spec.js.map +1 -0
- package/dist/role/role.service.spec.d.ts +2 -0
- package/dist/role/role.service.spec.d.ts.map +1 -0
- package/dist/role/role.service.spec.js +343 -0
- package/dist/role/role.service.spec.js.map +1 -0
- package/dist/route/route.service.spec.d.ts +2 -0
- package/dist/route/route.service.spec.d.ts.map +1 -0
- package/dist/route/route.service.spec.js +235 -0
- package/dist/route/route.service.spec.js.map +1 -0
- package/dist/screen/screen.service.spec.d.ts +2 -0
- package/dist/screen/screen.service.spec.d.ts.map +1 -0
- package/dist/screen/screen.service.spec.js +242 -0
- package/dist/screen/screen.service.spec.js.map +1 -0
- package/dist/setting/settings.service.spec.d.ts +2 -0
- package/dist/setting/settings.service.spec.d.ts.map +1 -0
- package/dist/setting/settings.service.spec.js +147 -0
- package/dist/setting/settings.service.spec.js.map +1 -0
- package/dist/user/user.service.spec.d.ts +2 -0
- package/dist/user/user.service.spec.d.ts.map +1 -0
- package/dist/user/user.service.spec.js +239 -0
- package/dist/user/user.service.spec.js.map +1 -0
- package/package.json +1 -1
- package/src/migrations/migrate-02.ts +137 -137
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"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AiB,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;YAEnC,MAAM,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YAEhC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,oBAAoB,CAAC;gBAC1D,KAAK,EAAE;oBACL,EAAE,EAAE,EAAE,EAAE,EAAE,SAAS,CAAC,GAAG,EAAE;oBACzB,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE;iBACxC;aACF,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
@@ -1,137 +1,137 @@
|
|
1
|
-
import {
|
2
|
-
MigrationInterface,
|
3
|
-
QueryRunner,
|
4
|
-
Table,
|
5
|
-
TableForeignKey,
|
6
|
-
} from 'typeorm';
|
7
|
-
import { idColumn, timestampColumn } from '@hedhog/utils';
|
8
|
-
|
9
|
-
export class Migrate implements MigrationInterface {
|
10
|
-
public async up(queryRunner: QueryRunner): Promise<void> {
|
11
|
-
await await queryRunner.createTable(
|
12
|
-
new Table({
|
13
|
-
name: 'translation_namespaces',
|
14
|
-
columns: [
|
15
|
-
idColumn(),
|
16
|
-
{
|
17
|
-
name: 'name',
|
18
|
-
type: 'varchar',
|
19
|
-
isNullable: false,
|
20
|
-
},
|
21
|
-
timestampColumn(),
|
22
|
-
timestampColumn('updated_at'),
|
23
|
-
],
|
24
|
-
}),
|
25
|
-
true,
|
26
|
-
);
|
27
|
-
|
28
|
-
await await queryRunner.manager
|
29
|
-
.createQueryBuilder()
|
30
|
-
.insert()
|
31
|
-
.into('translation_namespaces')
|
32
|
-
.values([{ name: 'translation' }])
|
33
|
-
.execute();
|
34
|
-
|
35
|
-
await queryRunner.createTable(
|
36
|
-
new Table({
|
37
|
-
name: 'translations',
|
38
|
-
columns: [
|
39
|
-
idColumn(),
|
40
|
-
{
|
41
|
-
name: 'locale_id',
|
42
|
-
type: 'int',
|
43
|
-
isNullable: false,
|
44
|
-
unsigned: true,
|
45
|
-
},
|
46
|
-
{
|
47
|
-
name: 'namespace_id',
|
48
|
-
type: 'int',
|
49
|
-
isNullable: false,
|
50
|
-
unsigned: true,
|
51
|
-
},
|
52
|
-
{
|
53
|
-
name: 'name',
|
54
|
-
type: 'varchar',
|
55
|
-
isNullable: false,
|
56
|
-
},
|
57
|
-
{
|
58
|
-
name: 'value',
|
59
|
-
type: 'varchar',
|
60
|
-
isNullable: false,
|
61
|
-
},
|
62
|
-
timestampColumn(),
|
63
|
-
timestampColumn('updated_at'),
|
64
|
-
],
|
65
|
-
uniques: [
|
66
|
-
{
|
67
|
-
columnNames: ['locale_id', 'namespace_id', 'name'],
|
68
|
-
},
|
69
|
-
],
|
70
|
-
foreignKeys: [
|
71
|
-
new TableForeignKey({
|
72
|
-
columnNames: ['locale_id'],
|
73
|
-
referencedTableName: 'locales',
|
74
|
-
referencedColumnNames: ['id'],
|
75
|
-
onDelete: 'CASCADE',
|
76
|
-
}),
|
77
|
-
new TableForeignKey({
|
78
|
-
columnNames: ['namespace_id'],
|
79
|
-
referencedTableName: 'translation_namespaces',
|
80
|
-
referencedColumnNames: ['id'],
|
81
|
-
onDelete: 'CASCADE',
|
82
|
-
}),
|
83
|
-
],
|
84
|
-
}),
|
85
|
-
true,
|
86
|
-
);
|
87
|
-
|
88
|
-
await await queryRunner.manager
|
89
|
-
.createQueryBuilder()
|
90
|
-
.insert()
|
91
|
-
.into('translations', ['locale_id', 'namespace_id', 'name', 'value'])
|
92
|
-
.values([
|
93
|
-
{
|
94
|
-
locale_id: 1,
|
95
|
-
namespace_id: 1,
|
96
|
-
name: 'slogan',
|
97
|
-
value: 'Administration Panel',
|
98
|
-
},
|
99
|
-
{
|
100
|
-
locale_id: 1,
|
101
|
-
namespace_id: 1,
|
102
|
-
name: 'en',
|
103
|
-
value: 'English',
|
104
|
-
},
|
105
|
-
{
|
106
|
-
locale_id: 1,
|
107
|
-
namespace_id: 1,
|
108
|
-
name: 'pt',
|
109
|
-
value: 'Portuguese',
|
110
|
-
},
|
111
|
-
{
|
112
|
-
locale_id: 2,
|
113
|
-
namespace_id: 1,
|
114
|
-
name: 'slogan',
|
115
|
-
value: 'Painel de Administração',
|
116
|
-
},
|
117
|
-
{
|
118
|
-
locale_id: 2,
|
119
|
-
namespace_id: 1,
|
120
|
-
name: 'en',
|
121
|
-
value: 'Inglês',
|
122
|
-
},
|
123
|
-
{
|
124
|
-
locale_id: 2,
|
125
|
-
namespace_id: 1,
|
126
|
-
name: 'pt',
|
127
|
-
value: 'Português',
|
128
|
-
},
|
129
|
-
])
|
130
|
-
.execute();
|
131
|
-
}
|
132
|
-
|
133
|
-
public async down(queryRunner: QueryRunner): Promise<void> {
|
134
|
-
await queryRunner.dropTable('translations');
|
135
|
-
await queryRunner.dropTable('translation_namespaces');
|
136
|
-
}
|
137
|
-
}
|
1
|
+
import {
|
2
|
+
MigrationInterface,
|
3
|
+
QueryRunner,
|
4
|
+
Table,
|
5
|
+
TableForeignKey,
|
6
|
+
} from 'typeorm';
|
7
|
+
import { idColumn, timestampColumn } from '@hedhog/utils';
|
8
|
+
|
9
|
+
export class Migrate implements MigrationInterface {
|
10
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
11
|
+
await await queryRunner.createTable(
|
12
|
+
new Table({
|
13
|
+
name: 'translation_namespaces',
|
14
|
+
columns: [
|
15
|
+
idColumn(),
|
16
|
+
{
|
17
|
+
name: 'name',
|
18
|
+
type: 'varchar',
|
19
|
+
isNullable: false,
|
20
|
+
},
|
21
|
+
timestampColumn(),
|
22
|
+
timestampColumn('updated_at'),
|
23
|
+
],
|
24
|
+
}),
|
25
|
+
true,
|
26
|
+
);
|
27
|
+
|
28
|
+
await await queryRunner.manager
|
29
|
+
.createQueryBuilder()
|
30
|
+
.insert()
|
31
|
+
.into('translation_namespaces')
|
32
|
+
.values([{ name: 'translation' }])
|
33
|
+
.execute();
|
34
|
+
|
35
|
+
await queryRunner.createTable(
|
36
|
+
new Table({
|
37
|
+
name: 'translations',
|
38
|
+
columns: [
|
39
|
+
idColumn(),
|
40
|
+
{
|
41
|
+
name: 'locale_id',
|
42
|
+
type: 'int',
|
43
|
+
isNullable: false,
|
44
|
+
unsigned: true,
|
45
|
+
},
|
46
|
+
{
|
47
|
+
name: 'namespace_id',
|
48
|
+
type: 'int',
|
49
|
+
isNullable: false,
|
50
|
+
unsigned: true,
|
51
|
+
},
|
52
|
+
{
|
53
|
+
name: 'name',
|
54
|
+
type: 'varchar',
|
55
|
+
isNullable: false,
|
56
|
+
},
|
57
|
+
{
|
58
|
+
name: 'value',
|
59
|
+
type: 'varchar',
|
60
|
+
isNullable: false,
|
61
|
+
},
|
62
|
+
timestampColumn(),
|
63
|
+
timestampColumn('updated_at'),
|
64
|
+
],
|
65
|
+
uniques: [
|
66
|
+
{
|
67
|
+
columnNames: ['locale_id', 'namespace_id', 'name'],
|
68
|
+
},
|
69
|
+
],
|
70
|
+
foreignKeys: [
|
71
|
+
new TableForeignKey({
|
72
|
+
columnNames: ['locale_id'],
|
73
|
+
referencedTableName: 'locales',
|
74
|
+
referencedColumnNames: ['id'],
|
75
|
+
onDelete: 'CASCADE',
|
76
|
+
}),
|
77
|
+
new TableForeignKey({
|
78
|
+
columnNames: ['namespace_id'],
|
79
|
+
referencedTableName: 'translation_namespaces',
|
80
|
+
referencedColumnNames: ['id'],
|
81
|
+
onDelete: 'CASCADE',
|
82
|
+
}),
|
83
|
+
],
|
84
|
+
}),
|
85
|
+
true,
|
86
|
+
);
|
87
|
+
|
88
|
+
await await queryRunner.manager
|
89
|
+
.createQueryBuilder()
|
90
|
+
.insert()
|
91
|
+
.into('translations', ['locale_id', 'namespace_id', 'name', 'value'])
|
92
|
+
.values([
|
93
|
+
{
|
94
|
+
locale_id: 1,
|
95
|
+
namespace_id: 1,
|
96
|
+
name: 'slogan',
|
97
|
+
value: 'Administration Panel',
|
98
|
+
},
|
99
|
+
{
|
100
|
+
locale_id: 1,
|
101
|
+
namespace_id: 1,
|
102
|
+
name: 'en',
|
103
|
+
value: 'English',
|
104
|
+
},
|
105
|
+
{
|
106
|
+
locale_id: 1,
|
107
|
+
namespace_id: 1,
|
108
|
+
name: 'pt',
|
109
|
+
value: 'Portuguese',
|
110
|
+
},
|
111
|
+
{
|
112
|
+
locale_id: 2,
|
113
|
+
namespace_id: 1,
|
114
|
+
name: 'slogan',
|
115
|
+
value: 'Painel de Administração',
|
116
|
+
},
|
117
|
+
{
|
118
|
+
locale_id: 2,
|
119
|
+
namespace_id: 1,
|
120
|
+
name: 'en',
|
121
|
+
value: 'Inglês',
|
122
|
+
},
|
123
|
+
{
|
124
|
+
locale_id: 2,
|
125
|
+
namespace_id: 1,
|
126
|
+
name: 'pt',
|
127
|
+
value: 'Português',
|
128
|
+
},
|
129
|
+
])
|
130
|
+
.execute();
|
131
|
+
}
|
132
|
+
|
133
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
134
|
+
await queryRunner.dropTable('translations');
|
135
|
+
await queryRunner.dropTable('translation_namespaces');
|
136
|
+
}
|
137
|
+
}
|