mblabs-roccato-backend-commons 1.0.79 → 1.0.81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/database/entities/account.d.ts +1 -0
- package/dist/database/entities/account.js +5 -0
- package/dist/database/migrations/1748448589934-CreateAccountsTable.js +5 -0
- package/dist/database/migrations/1759768335075-AddCanAddWidgetToAccountModuleTable.js +10 -0
- package/dist/database/migrations/1759768342995-AddCanAddWidgetToGroupModuleTable.js +10 -0
- package/dist/database/migrations/1759768354127-AddCanAddWidgetToProfileModuleTable.js +10 -0
- package/dist/database/utils.d.ts +21 -0
- package/dist/database/utils.js +27 -0
- package/package.json +1 -1
- package/src/database/entities/account.ts +3 -0
- package/src/database/migrations/1748448589934-CreateAccountsTable.ts +5 -0
- package/src/database/migrations/1759768335075-AddCanAddWidgetToAccountModuleTable.ts +11 -1
- package/src/database/migrations/1759768342995-AddCanAddWidgetToGroupModuleTable.ts +10 -0
- package/src/database/migrations/1759768354127-AddCanAddWidgetToProfileModuleTable.ts +10 -0
- package/src/database/utils.ts +44 -2
|
@@ -12,6 +12,7 @@ export default class AccountEntity extends BaseEntity {
|
|
|
12
12
|
businessDocument?: string;
|
|
13
13
|
lastAccessAt?: Date;
|
|
14
14
|
metadata?: unknown;
|
|
15
|
+
isDefault?: boolean;
|
|
15
16
|
accountModules?: Relation<AccountModuleEntity>[];
|
|
16
17
|
accountGroups?: Relation<AccountGroupEntity>[];
|
|
17
18
|
profile?: Relation<ProfileEntity>;
|
|
@@ -26,6 +26,7 @@ let AccountEntity = class AccountEntity extends base_1.default {
|
|
|
26
26
|
businessDocument;
|
|
27
27
|
lastAccessAt;
|
|
28
28
|
metadata;
|
|
29
|
+
isDefault;
|
|
29
30
|
accountModules;
|
|
30
31
|
accountGroups;
|
|
31
32
|
profile;
|
|
@@ -66,6 +67,10 @@ __decorate([
|
|
|
66
67
|
(0, typeorm_1.Column)({ type: 'jsonb', nullable: true }),
|
|
67
68
|
__metadata("design:type", Object)
|
|
68
69
|
], AccountEntity.prototype, "metadata", void 0);
|
|
70
|
+
__decorate([
|
|
71
|
+
(0, typeorm_1.Column)({ type: 'boolean', nullable: true }),
|
|
72
|
+
__metadata("design:type", Boolean)
|
|
73
|
+
], AccountEntity.prototype, "isDefault", void 0);
|
|
69
74
|
__decorate([
|
|
70
75
|
(0, typeorm_1.OneToMany)(() => account_module_1.default, am => am.account),
|
|
71
76
|
__metadata("design:type", Array)
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.AddCanAddWidgetToAccountModuleTable1759768335075 = void 0;
|
|
4
7
|
const typeorm_1 = require("typeorm");
|
|
8
|
+
const utils_1 = __importDefault(require("../utils"));
|
|
5
9
|
class AddCanAddWidgetToAccountModuleTable1759768335075 {
|
|
6
10
|
async up(queryRunner) {
|
|
11
|
+
const hasColumn = await utils_1.default.checkHasColumn('account_module', 'canAddWidget', queryRunner);
|
|
12
|
+
if (hasColumn)
|
|
13
|
+
return;
|
|
7
14
|
await queryRunner.addColumn('account_module', new typeorm_1.TableColumn({
|
|
8
15
|
name: 'canAddWidget',
|
|
9
16
|
type: 'boolean',
|
|
@@ -12,6 +19,9 @@ class AddCanAddWidgetToAccountModuleTable1759768335075 {
|
|
|
12
19
|
}));
|
|
13
20
|
}
|
|
14
21
|
async down(queryRunner) {
|
|
22
|
+
const hasColumn = await utils_1.default.checkHasColumn('account_module', 'canAddWidget', queryRunner);
|
|
23
|
+
if (!hasColumn)
|
|
24
|
+
return;
|
|
15
25
|
await queryRunner.dropColumn('account_module', 'canAddWidget');
|
|
16
26
|
}
|
|
17
27
|
}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.AddCanAddWidgetToGroupModuleTable1759768342995 = void 0;
|
|
4
7
|
const typeorm_1 = require("typeorm");
|
|
8
|
+
const utils_1 = __importDefault(require("../utils"));
|
|
5
9
|
class AddCanAddWidgetToGroupModuleTable1759768342995 {
|
|
6
10
|
async up(queryRunner) {
|
|
11
|
+
const hasColumn = await utils_1.default.checkHasColumn('group_module', 'canAddWidget', queryRunner);
|
|
12
|
+
if (hasColumn)
|
|
13
|
+
return;
|
|
7
14
|
await queryRunner.addColumn('group_module', new typeorm_1.TableColumn({
|
|
8
15
|
name: 'canAddWidget',
|
|
9
16
|
type: 'boolean',
|
|
@@ -12,6 +19,9 @@ class AddCanAddWidgetToGroupModuleTable1759768342995 {
|
|
|
12
19
|
}));
|
|
13
20
|
}
|
|
14
21
|
async down(queryRunner) {
|
|
22
|
+
const hasColumn = await utils_1.default.checkHasColumn('group_module', 'canAddWidget', queryRunner);
|
|
23
|
+
if (!hasColumn)
|
|
24
|
+
return;
|
|
15
25
|
await queryRunner.dropColumn('group_module', 'canAddWidget');
|
|
16
26
|
}
|
|
17
27
|
}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.AddCanAddWidgetToProfileModuleTable1759768354127 = void 0;
|
|
4
7
|
const typeorm_1 = require("typeorm");
|
|
8
|
+
const utils_1 = __importDefault(require("../utils"));
|
|
5
9
|
class AddCanAddWidgetToProfileModuleTable1759768354127 {
|
|
6
10
|
async up(queryRunner) {
|
|
11
|
+
const hasColumn = await utils_1.default.checkHasColumn('profile_module', 'canAddWidget', queryRunner);
|
|
12
|
+
if (hasColumn)
|
|
13
|
+
return;
|
|
7
14
|
await queryRunner.addColumn('profile_module', new typeorm_1.TableColumn({
|
|
8
15
|
name: 'canAddWidget',
|
|
9
16
|
type: 'boolean',
|
|
@@ -12,6 +19,9 @@ class AddCanAddWidgetToProfileModuleTable1759768354127 {
|
|
|
12
19
|
}));
|
|
13
20
|
}
|
|
14
21
|
async down(queryRunner) {
|
|
22
|
+
const hasColumn = await utils_1.default.checkHasColumn('profile_module', 'canAddWidget', queryRunner);
|
|
23
|
+
if (!hasColumn)
|
|
24
|
+
return;
|
|
15
25
|
await queryRunner.dropColumn('profile_module', 'canAddWidget');
|
|
16
26
|
}
|
|
17
27
|
}
|
package/dist/database/utils.d.ts
CHANGED
|
@@ -10,6 +10,27 @@ declare class DatabaseUtils {
|
|
|
10
10
|
dropUniqueConstraint(tableName: string, uniqueConstraintName: string, queryRunner: QueryRunner): Promise<void>;
|
|
11
11
|
serializeOrderBy<Entity>(entity: EntityTarget<Entity>, orderBy: string): string;
|
|
12
12
|
serializeEntity<T>(entity: ClassConstructor<T>, data: T): T;
|
|
13
|
+
serializeError(err: unknown): {
|
|
14
|
+
name: string;
|
|
15
|
+
message: string;
|
|
16
|
+
details: {
|
|
17
|
+
query: string;
|
|
18
|
+
parameters: any[];
|
|
19
|
+
driverError: any;
|
|
20
|
+
};
|
|
21
|
+
} | {
|
|
22
|
+
name: string;
|
|
23
|
+
message: string;
|
|
24
|
+
details?: undefined;
|
|
25
|
+
} | {
|
|
26
|
+
name: string;
|
|
27
|
+
message: string;
|
|
28
|
+
details: string;
|
|
29
|
+
} | {
|
|
30
|
+
name?: undefined;
|
|
31
|
+
message?: undefined;
|
|
32
|
+
details?: undefined;
|
|
33
|
+
};
|
|
13
34
|
}
|
|
14
35
|
declare const _default: DatabaseUtils;
|
|
15
36
|
export default _default;
|
package/dist/database/utils.js
CHANGED
|
@@ -78,5 +78,32 @@ class DatabaseUtils {
|
|
|
78
78
|
const entitySerialized = (0, class_transformer_1.plainToInstance)(entity, data);
|
|
79
79
|
return entitySerialized;
|
|
80
80
|
}
|
|
81
|
+
serializeError(err) {
|
|
82
|
+
if (err instanceof typeorm_1.QueryFailedError) {
|
|
83
|
+
return {
|
|
84
|
+
name: typeorm_1.QueryFailedError.name,
|
|
85
|
+
message: err.message,
|
|
86
|
+
details: {
|
|
87
|
+
query: err.query,
|
|
88
|
+
parameters: err.parameters,
|
|
89
|
+
driverError: err.driverError,
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
if (err instanceof typeorm_1.EntityNotFoundError) {
|
|
94
|
+
return {
|
|
95
|
+
name: typeorm_1.EntityNotFoundError.name,
|
|
96
|
+
message: err.message,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
if (err instanceof Error) {
|
|
100
|
+
return {
|
|
101
|
+
name: err.name,
|
|
102
|
+
message: err.message,
|
|
103
|
+
details: err.stack,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
return {};
|
|
107
|
+
}
|
|
81
108
|
}
|
|
82
109
|
exports.default = new DatabaseUtils();
|
package/package.json
CHANGED
|
@@ -39,6 +39,9 @@ export default class AccountEntity extends BaseEntity {
|
|
|
39
39
|
@Column({ type: 'jsonb', nullable: true })
|
|
40
40
|
public metadata?: unknown;
|
|
41
41
|
|
|
42
|
+
@Column({ type: 'boolean', nullable: true })
|
|
43
|
+
public isDefault?: boolean;
|
|
44
|
+
|
|
42
45
|
@OneToMany(() => AccountModuleEntity, am => am.account)
|
|
43
46
|
public accountModules?: Relation<AccountModuleEntity>[];
|
|
44
47
|
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm';
|
|
2
2
|
|
|
3
|
+
import DatabaseUtils from '../utils';
|
|
4
|
+
|
|
3
5
|
export class AddCanAddWidgetToAccountModuleTable1759768335075 implements MigrationInterface {
|
|
4
6
|
|
|
5
7
|
public async up (queryRunner: QueryRunner): Promise<void> {
|
|
8
|
+
const hasColumn = await DatabaseUtils.checkHasColumn('account_module', 'canAddWidget', queryRunner);
|
|
9
|
+
|
|
10
|
+
if (hasColumn) return;
|
|
11
|
+
|
|
6
12
|
await queryRunner.addColumn('account_module', new TableColumn({
|
|
7
13
|
name: 'canAddWidget',
|
|
8
14
|
type: 'boolean',
|
|
@@ -12,6 +18,10 @@ export class AddCanAddWidgetToAccountModuleTable1759768335075 implements Migrati
|
|
|
12
18
|
}
|
|
13
19
|
|
|
14
20
|
public async down (queryRunner: QueryRunner): Promise<void> {
|
|
21
|
+
const hasColumn = await DatabaseUtils.checkHasColumn('account_module', 'canAddWidget', queryRunner);
|
|
22
|
+
|
|
23
|
+
if (!hasColumn) return;
|
|
24
|
+
|
|
15
25
|
await queryRunner.dropColumn('account_module', 'canAddWidget');
|
|
16
26
|
}
|
|
17
|
-
}
|
|
27
|
+
}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm';
|
|
2
2
|
|
|
3
|
+
import DatabaseUtils from '../utils';
|
|
4
|
+
|
|
3
5
|
export class AddCanAddWidgetToGroupModuleTable1759768342995 implements MigrationInterface {
|
|
4
6
|
|
|
5
7
|
public async up (queryRunner: QueryRunner): Promise<void> {
|
|
8
|
+
const hasColumn = await DatabaseUtils.checkHasColumn('group_module', 'canAddWidget', queryRunner);
|
|
9
|
+
|
|
10
|
+
if (hasColumn) return;
|
|
11
|
+
|
|
6
12
|
await queryRunner.addColumn('group_module', new TableColumn({
|
|
7
13
|
name: 'canAddWidget',
|
|
8
14
|
type: 'boolean',
|
|
@@ -12,6 +18,10 @@ export class AddCanAddWidgetToGroupModuleTable1759768342995 implements Migration
|
|
|
12
18
|
}
|
|
13
19
|
|
|
14
20
|
public async down (queryRunner: QueryRunner): Promise<void> {
|
|
21
|
+
const hasColumn = await DatabaseUtils.checkHasColumn('group_module', 'canAddWidget', queryRunner);
|
|
22
|
+
|
|
23
|
+
if (!hasColumn) return;
|
|
24
|
+
|
|
15
25
|
await queryRunner.dropColumn('group_module', 'canAddWidget');
|
|
16
26
|
}
|
|
17
27
|
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm';
|
|
2
2
|
|
|
3
|
+
import DatabaseUtils from '../utils';
|
|
4
|
+
|
|
3
5
|
export class AddCanAddWidgetToProfileModuleTable1759768354127 implements MigrationInterface {
|
|
4
6
|
|
|
5
7
|
public async up (queryRunner: QueryRunner): Promise<void> {
|
|
8
|
+
const hasColumn = await DatabaseUtils.checkHasColumn('profile_module', 'canAddWidget', queryRunner);
|
|
9
|
+
|
|
10
|
+
if (hasColumn) return;
|
|
11
|
+
|
|
6
12
|
await queryRunner.addColumn('profile_module', new TableColumn({
|
|
7
13
|
name: 'canAddWidget',
|
|
8
14
|
type: 'boolean',
|
|
@@ -12,6 +18,10 @@ export class AddCanAddWidgetToProfileModuleTable1759768354127 implements Migrati
|
|
|
12
18
|
}
|
|
13
19
|
|
|
14
20
|
public async down (queryRunner: QueryRunner): Promise<void> {
|
|
21
|
+
const hasColumn = await DatabaseUtils.checkHasColumn('profile_module', 'canAddWidget', queryRunner);
|
|
22
|
+
|
|
23
|
+
if (!hasColumn) return;
|
|
24
|
+
|
|
15
25
|
await queryRunner.dropColumn('profile_module', 'canAddWidget');
|
|
16
26
|
}
|
|
17
27
|
|
package/src/database/utils.ts
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
ClassConstructor,
|
|
3
|
+
plainToInstance,
|
|
4
|
+
} from 'class-transformer';
|
|
5
|
+
import {
|
|
6
|
+
EntityNotFoundError,
|
|
7
|
+
EntityTarget,
|
|
8
|
+
getMetadataArgsStorage,
|
|
9
|
+
QueryFailedError,
|
|
10
|
+
QueryRunner,
|
|
11
|
+
Table,
|
|
12
|
+
TableForeignKey,
|
|
13
|
+
} from 'typeorm';
|
|
3
14
|
|
|
4
15
|
class DatabaseUtils {
|
|
5
16
|
async dropTableForeignKeys (
|
|
@@ -143,6 +154,37 @@ class DatabaseUtils {
|
|
|
143
154
|
|
|
144
155
|
return entitySerialized;
|
|
145
156
|
}
|
|
157
|
+
|
|
158
|
+
public serializeError (err: unknown) {
|
|
159
|
+
if (err instanceof QueryFailedError) {
|
|
160
|
+
return {
|
|
161
|
+
name: QueryFailedError.name,
|
|
162
|
+
message: err.message,
|
|
163
|
+
details: {
|
|
164
|
+
query: err.query,
|
|
165
|
+
parameters: err.parameters,
|
|
166
|
+
driverError: err.driverError,
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (err instanceof EntityNotFoundError) {
|
|
172
|
+
return {
|
|
173
|
+
name: EntityNotFoundError.name,
|
|
174
|
+
message: err.message,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (err instanceof Error) {
|
|
179
|
+
return {
|
|
180
|
+
name: err.name,
|
|
181
|
+
message: err.message,
|
|
182
|
+
details: err.stack,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return {};
|
|
187
|
+
}
|
|
146
188
|
}
|
|
147
189
|
|
|
148
190
|
export default new DatabaseUtils();
|