@steroidsjs/nest 4.0.2 → 4.1.1
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/README.md +6 -12
- package/infrastructure/applications/BaseApplication.d.ts +7 -0
- package/infrastructure/applications/BaseApplication.js +37 -0
- package/infrastructure/applications/BaseApplication.js.map +1 -1
- package/infrastructure/applications/IAppModuleConfig.d.ts +4 -0
- package/infrastructure/applications/base/config.js +2 -5
- package/infrastructure/applications/base/config.js.map +1 -1
- package/infrastructure/applications/rest/IRestAppModuleConfig.d.ts +5 -0
- package/infrastructure/applications/rest/RestApplication.d.ts +4 -11
- package/infrastructure/applications/rest/RestApplication.js +13 -16
- package/infrastructure/applications/rest/RestApplication.js.map +1 -1
- package/infrastructure/applications/rest/SentryExceptionFilter.d.ts +2 -0
- package/infrastructure/applications/rest/SentryExceptionFilter.js +10 -3
- package/infrastructure/applications/rest/SentryExceptionFilter.js.map +1 -1
- package/infrastructure/applications/rest/config.d.ts +3 -3
- package/infrastructure/applications/rest/config.js +6 -1
- package/infrastructure/applications/rest/config.js.map +1 -1
- package/infrastructure/base/consts.d.ts +1 -0
- package/infrastructure/base/consts.js +5 -0
- package/infrastructure/base/consts.js.map +1 -0
- package/infrastructure/commands/MigrateCommand.d.ts +1 -0
- package/infrastructure/commands/MigrateCommand.js +34 -0
- package/infrastructure/commands/MigrateCommand.js.map +1 -1
- package/infrastructure/commands/entity-generator/EntityCodeGenerateCommand.d.ts +1 -1
- package/infrastructure/commands/entity-generator/EntityCodeGenerateCommand.js +9 -4
- package/infrastructure/commands/entity-generator/EntityCodeGenerateCommand.js.map +1 -1
- package/infrastructure/commands/entity-generator/EntityCodeGenerator.d.ts +3 -1
- package/infrastructure/commands/entity-generator/EntityCodeGenerator.js +24 -6
- package/infrastructure/commands/entity-generator/EntityCodeGenerator.js.map +1 -1
- package/infrastructure/commands/entity-generator/templates/{ServiceTemplate.txt → CrudServiceTemplate.txt} +4 -1
- package/infrastructure/commands/entity-generator/templates/ReadServiceTemplate.txt +18 -0
- package/infrastructure/commands/entity-generator/templates/TableTemplate.txt +1 -1
- package/infrastructure/commands/generate/index.d.ts +6 -1
- package/infrastructure/commands/generate/index.js +41 -2
- package/infrastructure/commands/generate/index.js.map +1 -1
- package/infrastructure/decorators/fields/ComputableField.d.ts +2 -0
- package/infrastructure/decorators/fields/ComputableField.js +1 -0
- package/infrastructure/decorators/fields/ComputableField.js.map +1 -1
- package/infrastructure/decorators/fields/DecimalField.js +3 -1
- package/infrastructure/decorators/fields/DecimalField.js.map +1 -1
- package/infrastructure/decorators/fields/DecimalNumberField.js +2 -1
- package/infrastructure/decorators/fields/DecimalNumberField.js.map +1 -1
- package/infrastructure/decorators/fields/EnumField.d.ts +3 -2
- package/infrastructure/decorators/fields/EnumField.js +2 -1
- package/infrastructure/decorators/fields/EnumField.js.map +1 -1
- package/infrastructure/decorators/fields/PasswordField.d.ts +9 -1
- package/infrastructure/decorators/fields/PasswordField.js +12 -4
- package/infrastructure/decorators/fields/PasswordField.js.map +1 -1
- package/infrastructure/decorators/fields/index.d.ts +2 -2
- package/infrastructure/decorators/fields/index.js.map +1 -1
- package/infrastructure/decorators/typeorm/fields/TypeOrmDecimalField/index.js +2 -1
- package/infrastructure/decorators/typeorm/fields/TypeOrmDecimalField/index.js.map +1 -1
- package/infrastructure/decorators/typeorm/fields/TypeOrmDecimalNumberField/index.js +2 -1
- package/infrastructure/decorators/typeorm/fields/TypeOrmDecimalNumberField/index.js.map +1 -1
- package/infrastructure/repositories/CrudRepository.d.ts +2 -2
- package/infrastructure/repositories/CrudRepository.js +4 -6
- package/infrastructure/repositories/CrudRepository.js.map +1 -1
- package/infrastructure/utils/getNewPermissions.d.ts +2 -0
- package/infrastructure/utils/getNewPermissions.js +18 -0
- package/infrastructure/utils/getNewPermissions.js.map +1 -0
- package/package.json +2 -4
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,15 +1,18 @@
|
|
|
1
|
+
import {Inject, Injectable} from '@nestjs/common';
|
|
1
2
|
import {CrudService} from '@steroidsjs/nest/usecases/services/CrudService';
|
|
2
3
|
import {%entityName%SearchDto} from '../dtos/%entityName%SearchDto';
|
|
3
4
|
import {%entityName%SaveDto} from '../dtos/%entityName%SaveDto';
|
|
4
5
|
import {%entityName%Model} from '../models/%entityName%Model';
|
|
5
6
|
import {I%entityName%Repository} from '../interfaces/I%entityName%Repository';
|
|
6
7
|
|
|
8
|
+
@Injectable()
|
|
7
9
|
export class %entityName%Service extends CrudService<%entityName%Model, %entityName%SearchDto, %entityName%SaveDto> {
|
|
8
10
|
protected modelClass = %entityName%Model;
|
|
9
11
|
|
|
10
12
|
constructor(
|
|
11
13
|
/** %entityName%Repository */
|
|
12
|
-
|
|
14
|
+
@Inject(I%entityName%Repository)
|
|
15
|
+
protected readonly repository: I%entityName%Repository,
|
|
13
16
|
) {
|
|
14
17
|
super();
|
|
15
18
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {Inject, Injectable} from '@nestjs/common';
|
|
2
|
+
import {ReadService} from '@steroidsjs/nest/usecases/services/ReadService';
|
|
3
|
+
import {%entityName%SearchDto} from '../dtos/%entityName%SearchDto';
|
|
4
|
+
import {%entityName%Model} from '../models/%entityName%Model';
|
|
5
|
+
import {I%entityName%Repository} from '../interfaces/I%entityName%Repository';
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class %entityName%Service extends ReadService<%entityName%Model, %entityName%SearchDto> {
|
|
9
|
+
protected modelClass = %entityName%Model;
|
|
10
|
+
|
|
11
|
+
constructor(
|
|
12
|
+
/** %entityName%Repository */
|
|
13
|
+
@Inject(I%entityName%Repository)
|
|
14
|
+
protected readonly repository: I%entityName%Repository,
|
|
15
|
+
) {
|
|
16
|
+
super();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {IDeepPartial} from '@steroidsjs/nest/usecases/interfaces/IDeepPartial';
|
|
2
|
-
import {TypeOrmTableFromModel} from '@steroidsjs/nest/infrastructure/decorators/TypeOrmTableFromModel';
|
|
2
|
+
import {TypeOrmTableFromModel} from '@steroidsjs/nest/infrastructure/decorators/typeorm/TypeOrmTableFromModel';
|
|
3
3
|
import {%entityName%Model} from '../../domain/models/%entityName%Model';
|
|
4
4
|
|
|
5
5
|
@TypeOrmTableFromModel(%entityName%Model, '%tableName%')
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
import { Connection } from '@steroidsjs/typeorm';
|
|
1
|
+
import { Connection, DataSource } from '@steroidsjs/typeorm';
|
|
2
|
+
export declare const generateMigrationsForPermissions: (dataSource: DataSource, permissionOptions?: {
|
|
3
|
+
table: string;
|
|
4
|
+
column: string;
|
|
5
|
+
module: string;
|
|
6
|
+
}) => Promise<void>;
|
|
2
7
|
export declare const generate: (connection: Connection) => Promise<void>;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generate = void 0;
|
|
3
|
+
exports.generate = exports.generateMigrationsForPermissions = void 0;
|
|
4
4
|
const load_configuration_1 = require("@nestjs/cli/lib/utils/load-configuration");
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const fs = require("fs");
|
|
7
7
|
const CommandUtils_1 = require("@steroidsjs/typeorm/commands/CommandUtils");
|
|
8
8
|
const formatter_1 = require("@sqltools/formatter");
|
|
9
|
-
const CustomRdbmsSchemaBuilder_1 = require("./CustomRdbmsSchemaBuilder");
|
|
10
9
|
const glob = require("glob");
|
|
10
|
+
const CustomRdbmsSchemaBuilder_1 = require("./CustomRdbmsSchemaBuilder");
|
|
11
11
|
const ModuleHelper_1 = require("../../helpers/ModuleHelper");
|
|
12
|
+
const getNewPermissions_1 = require("../../utils/getNewPermissions");
|
|
13
|
+
const ADD_PERMISSIONS_NAME = 'AddPermissions';
|
|
12
14
|
const queryParams = (parameters) => {
|
|
13
15
|
if (!parameters || !parameters.length) {
|
|
14
16
|
return '';
|
|
@@ -43,7 +45,44 @@ ${downSqls.join(`
|
|
|
43
45
|
}
|
|
44
46
|
`;
|
|
45
47
|
};
|
|
48
|
+
const generateMigrationsForPermissions = async (dataSource, permissionOptions = {
|
|
49
|
+
table: 'auth_permission',
|
|
50
|
+
column: 'name',
|
|
51
|
+
module: 'auth',
|
|
52
|
+
}) => {
|
|
53
|
+
const newPermissions = await (0, getNewPermissions_1.getNewPermissions)(dataSource, permissionOptions.table, permissionOptions.column);
|
|
54
|
+
if (!newPermissions.length) {
|
|
55
|
+
// eslint-disable-next-line no-console
|
|
56
|
+
console.log('info', 'No changes in permissions were found');
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const cliConfiguration = await (0, load_configuration_1.loadConfiguration)();
|
|
60
|
+
const dirPath = (0, path_1.join)(process.cwd(), cliConfiguration.sourceRoot, permissionOptions.module, 'infrastructure', 'migrations');
|
|
61
|
+
const values = newPermissions
|
|
62
|
+
.map(key => `('${key}')`)
|
|
63
|
+
.join(',\n ');
|
|
64
|
+
const upRaw = `INSERT INTO ${permissionOptions.table} (${permissionOptions.column}) VALUES\n ${values};`;
|
|
65
|
+
const downRaw = `DELETE FROM ${permissionOptions.table} WHERE ${permissionOptions.column} IN (${newPermissions.map(permission => `'${permission}'`).join(', ')});`;
|
|
66
|
+
const upQueries = [
|
|
67
|
+
` await queryRunner.query(\`${prettifyQuery(upRaw)}\`);`,
|
|
68
|
+
];
|
|
69
|
+
const downQueries = [
|
|
70
|
+
` await queryRunner.query(\`${prettifyQuery(downRaw)}\`);`,
|
|
71
|
+
];
|
|
72
|
+
const timestamp = new Date().getTime();
|
|
73
|
+
const migrationFileContent = getTemplate(ADD_PERMISSIONS_NAME, timestamp, upQueries, downQueries);
|
|
74
|
+
const migrationFilePath = (0, path_1.join)(dirPath, `${timestamp}-${ADD_PERMISSIONS_NAME}.ts`);
|
|
75
|
+
// eslint-disable-next-line no-console
|
|
76
|
+
console.log('info', '\t' + migrationFilePath);
|
|
77
|
+
await CommandUtils_1.CommandUtils.createFile(migrationFilePath, migrationFileContent);
|
|
78
|
+
};
|
|
79
|
+
exports.generateMigrationsForPermissions = generateMigrationsForPermissions;
|
|
46
80
|
const generate = async (connection) => {
|
|
81
|
+
const hasPendingMigrations = await connection.showMigrations();
|
|
82
|
+
if (hasPendingMigrations) {
|
|
83
|
+
console.error('[ERROR!] Unapplied migrations detected. Database schema is out of sync.');
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
47
86
|
// Get mapping model name to table name
|
|
48
87
|
const junctionTablesMap = {};
|
|
49
88
|
const classesToTablesMap = connection.entityMetadatas.reduce((obj, entityMeta) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/infrastructure/commands/generate/index.ts"],"names":[],"mappings":";;;AAAA,iFAA2E;AAC3E,+BAAmC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/infrastructure/commands/generate/index.ts"],"names":[],"mappings":";;;AAAA,iFAA2E;AAC3E,+BAAmC;AACnC,yBAAyB;AACzB,4EAAuE;AAEvE,mDAA2C;AAC3C,6BAA6B;AAC7B,yEAAoE;AACpE,6DAAwD;AACxD,qEAAgE;AAEhE,MAAM,oBAAoB,GAAG,gBAAgB,CAAC;AAE9C,MAAM,WAAW,GAAG,CAAC,UAA6B,EAAU,EAAE;IAC1D,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;QACnC,OAAO,EAAE,CAAC;KACb;IAED,OAAO,KAAK,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC;AAC7C,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,CAAC,KAAa,EAAE,EAAE;IACpC,MAAM,cAAc,GAAG,IAAA,kBAAM,EAAC,KAAK,EAAE,EAAC,MAAM,EAAE,MAAM,EAAC,CAAC,CAAC;IACvD,KAAK,GAAG,IAAI,GAAG,cAA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C,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;YAElI,IAAI,oBAAoB,CAAC,MAAM,GAAG,CAAC,IAAI,sBAAsB,CAAC,MAAM,GAAG,CAAC,EAAE;gBACtE,MAAM,sBAAsB,GAAG,WAAW,CACtC,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,sBAAsB,CACzB,CAAC;gBACF,MAAM,mBAAmB,GAAG,aAAa,GAAG,GAAG,GAAG,cAAc,GAAG,KAAK,CAAC;gBACzE,MAAM,mBAAmB,GAAG,IAAA,cAAO,EAAC,SAAS,EAAE,kBAAkB,EAAE,mBAAmB,CAAC,CAAC;gBAExF,sCAAsC;gBACtC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,GAAG,mBAAmB,CAAC,CAAC;gBAChD,MAAM,2BAAY,CAAC,UAAU,CAAC,mBAAmB,EAAE,sBAAsB,CAAC,CAAC;aAC9E;SACJ;KACJ;AACL,CAAC,CAAC;AA9IW,QAAA,QAAQ,YA8InB"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { ApiPropertyOptions } from '@nestjs/swagger';
|
|
1
2
|
import { IBaseFieldOptions, IRelationData } from './BaseField';
|
|
2
3
|
import { IComputableCallback } from '../Computable';
|
|
3
4
|
export interface IComputableFieldOptions extends IBaseFieldOptions {
|
|
4
5
|
unique?: boolean;
|
|
5
6
|
requiredRelations?: Array<IRelationData | string>;
|
|
6
7
|
callback?: IComputableCallback;
|
|
8
|
+
swaggerType?: ApiPropertyOptions['type'];
|
|
7
9
|
}
|
|
8
10
|
export declare function ComputableField(options: IComputableFieldOptions): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComputableField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/ComputableField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;
|
|
1
|
+
{"version":3,"file":"ComputableField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/ComputableField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAG/C,2CAAwE;AACxE,8CAA8D;AAW9D,SAAgB,eAAe,CAAC,OAAgC;IAC5D,OAAO,IAAA,wBAAe,EAClB,GAAG;QACC,IAAA,qBAAS,EAAC,OAAO,EAAE;YACf,aAAa,EAAE,iBAAiB;YAChC,OAAO,EAAE,YAAY;YACrB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,WAAW,EAAE,OAAO,CAAC,WAAyB;SACjD,CAAC;QACF,IAAA,uBAAU,EAAC,OAAO,CAAC,QAAQ,CAAC;KAC/B,CAAC,MAAM,CAAC,OAAO,CAAC,CACpB,CAAC;AACN,CAAC;AAZD,0CAYC"}
|
|
@@ -4,6 +4,7 @@ exports.DecimalField = exports.MAX_STRING_AS_NUMBER = exports.MIN_STRING_AS_NUMB
|
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
5
|
const class_validator_1 = require("class-validator");
|
|
6
6
|
const BaseField_1 = require("./BaseField");
|
|
7
|
+
const consts_1 = require("../../base/consts");
|
|
7
8
|
exports.MIN_STRING_AS_NUMBER = 'minStringAsNumber';
|
|
8
9
|
exports.MAX_STRING_AS_NUMBER = 'maxStringAsNumber';
|
|
9
10
|
function buildValidate(constraint, validateFunction, validationOptions) {
|
|
@@ -28,6 +29,7 @@ function StringMax(maxValue, validationOptions) {
|
|
|
28
29
|
return buildValidate(maxValue, stringMax, validationOptions);
|
|
29
30
|
}
|
|
30
31
|
function DecimalField(options = {}) {
|
|
32
|
+
var _a;
|
|
31
33
|
return (0, common_1.applyDecorators)(...[
|
|
32
34
|
(0, BaseField_1.BaseField)(options, {
|
|
33
35
|
decoratorName: 'DecimalField',
|
|
@@ -36,7 +38,7 @@ function DecimalField(options = {}) {
|
|
|
36
38
|
}),
|
|
37
39
|
options.nullable && (0, class_validator_1.ValidateIf)((object, value) => value !== null && typeof value !== 'undefined'),
|
|
38
40
|
(0, class_validator_1.IsDecimal)({
|
|
39
|
-
decimal_digits:
|
|
41
|
+
decimal_digits: '0,' + ((_a = options.scale) !== null && _a !== void 0 ? _a : consts_1.DEFAULT_DECIMAL_SCALE),
|
|
40
42
|
}, {
|
|
41
43
|
message: options.isDecimalConstraintMessage || 'Должно быть числом',
|
|
42
44
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DecimalField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/DecimalField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,qDAAqF;AACrF,2CAAyD;
|
|
1
|
+
{"version":3,"file":"DecimalField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/DecimalField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,qDAAqF;AACrF,2CAAyD;AACzD,8CAAwD;AAU3C,QAAA,oBAAoB,GAAG,mBAAmB,CAAC;AAE3C,QAAA,oBAAoB,GAAG,mBAAmB,CAAC;AAExD,SAAS,aAAa,CAClB,UAAkB,EAClB,gBAA6D,EAC7D,iBAAqC;IAErC,OAAO,IAAA,4BAAU,EACb;QACI,IAAI,EAAE,4BAAoB;QAC1B,WAAW,EAAE,CAAC,UAAU,CAAC;QACzB,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,gBAAgB,CAAC,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC,CAAC,CAAC,CAAC;SACpF;KACJ,EACD,iBAAiB,CACpB,CAAC;AACN,CAAC;AAED,SAAS,SAAS,CAAC,GAAY,EAAE,GAAW;IACxC,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,GAAG,CAAC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IAAI,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE;YACtD,IAAI,EAAE,OAAO,CAAC,OAAO;YACrB,OAAO,EAAE,OAAO,CAAC,2BAA2B,IAAI,yBAAyB,OAAO,CAAC,GAAG,EAAE;SACzF,CAAC;KACL,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AACvB,CAAC;AAtBD,oCAsBC"}
|
|
@@ -5,6 +5,7 @@ const common_1 = require("@nestjs/common");
|
|
|
5
5
|
const class_validator_1 = require("class-validator");
|
|
6
6
|
const BaseField_1 = require("./BaseField");
|
|
7
7
|
const Transform_1 = require("../Transform");
|
|
8
|
+
const consts_1 = require("../../base/consts");
|
|
8
9
|
exports.IS_DECIMAL_NUMBER = 'isDecimalNumber';
|
|
9
10
|
function isDecimalNumber(value, options) {
|
|
10
11
|
var _a;
|
|
@@ -12,7 +13,7 @@ function isDecimalNumber(value, options) {
|
|
|
12
13
|
return false;
|
|
13
14
|
}
|
|
14
15
|
return (0, class_validator_1.isDecimal)(value.toString(), {
|
|
15
|
-
decimal_digits: '0,' + ((_a = options.scale) !== null && _a !== void 0 ? _a :
|
|
16
|
+
decimal_digits: '0,' + ((_a = options.scale) !== null && _a !== void 0 ? _a : consts_1.DEFAULT_DECIMAL_SCALE),
|
|
16
17
|
});
|
|
17
18
|
}
|
|
18
19
|
exports.isDecimalNumber = isDecimalNumber;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DecimalNumberField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/DecimalNumberField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,qDAA6G;AAG7G,2CAAsC;AACtC,4CAA+D;
|
|
1
|
+
{"version":3,"file":"DecimalNumberField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/DecimalNumberField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,qDAA6G;AAG7G,2CAAsC;AACtC,4CAA+D;AAC/D,8CAAwD;AA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EAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,WAAW,CAAC;QACjG,eAAe,CAAC,OAAO,EAAE;YACrB,OAAO,EAAE,OAAO,CAAC,0BAA0B,IAAI,oBAAoB;SACtE,CAAC;QACF,OAAO,OAAO,CAAC,GAAG,KAAK,QAAQ,IAAI,IAAA,qBAAG,EAAC,OAAO,CAAC,GAAG,EAAE;YAChD,IAAI,EAAE,OAAO,CAAC,OAAO;YACrB,OAAO,EAAE,OAAO,CAAC,2BAA2B,IAAI,yBAAyB,OAAO,CAAC,GAAG,EAAE;SACzF,CAAC;QACF,OAAO,OAAO,CAAC,GAAG,KAAK,QAAQ,IAAI,IAAA,qBAAG,EAAC,OAAO,CAAC,GAAG,EAAE;YAChD,IAAI,EAAE,OAAO,CAAC,OAAO;YACrB,OAAO,EAAE,OAAO,CAAC,2BAA2B,IAAI,yBAAyB,OAAO,CAAC,GAAG,EAAE;SACzF,CAAC;KACL,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AACvB,CAAC;AArBD,gDAqBC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { IBaseFieldOptions } from './BaseField';
|
|
2
2
|
export interface IEnumFieldOptions extends IBaseFieldOptions {
|
|
3
|
-
enum
|
|
3
|
+
enum: object | string[] | any;
|
|
4
|
+
enumName?: string;
|
|
4
5
|
isEnumConstraintMessage?: string;
|
|
5
6
|
}
|
|
6
|
-
export declare function EnumField(options
|
|
7
|
+
export declare function EnumField(options: IEnumFieldOptions): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -32,7 +32,7 @@ function getValidatorEnum(enumEntity) {
|
|
|
32
32
|
}
|
|
33
33
|
return enumEntity;
|
|
34
34
|
}
|
|
35
|
-
function EnumField(options
|
|
35
|
+
function EnumField(options) {
|
|
36
36
|
return (0, common_1.applyDecorators)(...[
|
|
37
37
|
(0, BaseField_1.BaseField)(options, {
|
|
38
38
|
decoratorName: 'EnumField',
|
|
@@ -41,6 +41,7 @@ function EnumField(options = {}) {
|
|
|
41
41
|
}),
|
|
42
42
|
(0, swagger_1.ApiProperty)({
|
|
43
43
|
enum: getOpenApiEnum(options.enum),
|
|
44
|
+
enumName: options.enumName,
|
|
44
45
|
isArray: options.isArray,
|
|
45
46
|
}),
|
|
46
47
|
options.nullable && (0, class_validator_1.ValidateIf)((object, value) => value !== null && typeof value !== 'undefined'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnumField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/EnumField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,qDAAmD;AACnD,6CAA4C;AAC5C,2CAAyD;AACzD,4DAAqD;
|
|
1
|
+
{"version":3,"file":"EnumField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/EnumField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,qDAAmD;AACnD,6CAA4C;AAC5C,2CAAyD;AACzD,4DAAqD;AAYrD,SAAS,cAAc,CAAC,UAA6C;IACjE,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;QAC3B,OAAO,UAAU,CAAC;KACrB;IAED,IAAI,OAAO,UAAU,KAAK,UAAU,IAAI,UAAU,CAAC,SAAS,YAAY,kBAAQ,EAAE;QAC9E,OAAQ,UAA4B,CAAC,OAAO,EAAE,CAAC;KAClD;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;AACrC,CAAC;AAED,SAAS,gBAAgB,CAAC,UAAmC;IACzD,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;QAC3B,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;YACpC,IAAI,KAAK,CAAC,SAAS,YAAY,kBAAQ,EAAE;gB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
+
export interface IPasswordFieldOptions extends IBaseFieldOptions {
|
|
3
|
+
minLength?: number;
|
|
4
|
+
minLowercase?: number;
|
|
5
|
+
minUppercase?: number;
|
|
6
|
+
minNumbers?: number;
|
|
7
|
+
minSymbols?: number;
|
|
8
|
+
isStrongPasswordConstraintMessage?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function PasswordField(options?: IPasswordFieldOptions): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -2,15 +2,23 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PasswordField = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
|
+
const class_validator_1 = require("class-validator");
|
|
5
6
|
const BaseField_1 = require("./BaseField");
|
|
6
7
|
function PasswordField(options = {}) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
return (0, common_1.applyDecorators)((0, BaseField_1.BaseField)(options, {
|
|
8
|
+
const finalOptions = Object.assign({ label: 'Пароль', minLength: 8, minLowercase: 1, minUppercase: 1, minNumbers: 1, minSymbols: 0, isStrongPasswordConstraintMessage: 'Ненадёжный пароль' }, options);
|
|
9
|
+
return (0, common_1.applyDecorators)((0, BaseField_1.BaseField)(finalOptions, {
|
|
11
10
|
decoratorName: 'PasswordField',
|
|
12
11
|
appType: 'password',
|
|
13
12
|
jsType: 'string',
|
|
13
|
+
}), (0, class_validator_1.IsStrongPassword)({
|
|
14
|
+
minLength: finalOptions.minLength,
|
|
15
|
+
minLowercase: finalOptions.minLowercase,
|
|
16
|
+
minUppercase: finalOptions.minUppercase,
|
|
17
|
+
minNumbers: finalOptions.minNumbers,
|
|
18
|
+
minSymbols: finalOptions.minSymbols,
|
|
19
|
+
}, {
|
|
20
|
+
each: finalOptions.isArray,
|
|
21
|
+
message: finalOptions.isStrongPasswordConstraintMessage,
|
|
14
22
|
}));
|
|
15
23
|
}
|
|
16
24
|
exports.PasswordField = PasswordField;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PasswordField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/PasswordField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,2CAAyD;
|
|
1
|
+
{"version":3,"file":"PasswordField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/PasswordField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,qDAAiD;AACjD,2CAAyD;AAWzD,SAAgB,aAAa,CAAC,UAAiC,EAAE;IAC7D,MAAM,YAAY,mBACd,KAAK,EAAE,QAAQ,EACf,SAAS,EAAE,CAAC,EACZ,YAAY,EAAE,CAAC,EACf,YAAY,EAAE,CAAC,EACf,UAAU,EAAE,CAAC,EACb,UAAU,EAAE,CAAC,EACb,iCAAiC,EAAE,mBAAmB,IACnD,OAAO,CACb,CAAC;IAEF,OAAO,IAAA,wBAAe,EAClB,IAAA,qBAAS,EAAC,YAAY,EAAE;QACpB,aAAa,EAAE,eAAe;QAC9B,OAAO,EAAE,UAAU;QACnB,MAAM,EAAE,QAAQ;KACnB,CAAC,EACF,IAAA,kCAAgB,EAAC;QACb,SAAS,EAAE,YAAY,CAAC,SAAS;QACjC,YAAY,EAAE,YAAY,CAAC,YAAY;QACvC,YAAY,EAAE,YAAY,CAAC,YAAY;QACvC,UAAU,EAAE,YAAY,CAAC,UAAU;QACnC,UAAU,EAAE,YAAY,CAAC,UAAU;KACtC,EAAE;QACC,IAAI,EAAE,YAAY,CAAC,OAAO;QAC1B,OAAO,EAAE,YAAY,CAAC,iCAAiC;KAC1D,CAAC,CACL,CAAC;AACN,CAAC;AA7BD,sCA6BC"}
|
|
@@ -20,7 +20,7 @@ import { DecimalNumberField } from './DecimalNumberField';
|
|
|
20
20
|
import { DeleteDateField } from './DeleteDateField';
|
|
21
21
|
import { HtmlField } from './HtmlField';
|
|
22
22
|
import { ImageField } from './ImageField';
|
|
23
|
-
import { PasswordField } from './PasswordField';
|
|
23
|
+
import { IPasswordFieldOptions, PasswordField } from './PasswordField';
|
|
24
24
|
import { PrimaryKeyField } from './PrimaryKeyField';
|
|
25
25
|
import { TextField } from './TextField';
|
|
26
26
|
import { TimeField } from './TimeField';
|
|
@@ -54,7 +54,7 @@ export { TimeField } from './TimeField';
|
|
|
54
54
|
export { UidField } from './UidField';
|
|
55
55
|
export { UpdateTimeField } from './UpdateTimeField';
|
|
56
56
|
export { GeometryField } from './GeometryField';
|
|
57
|
-
export type IAllFieldOptions = ICreateTimeFieldOptions & IDateTimeFieldColumnOptions & IDecimalFieldOptions & IEnumFieldOptions & IExtendFieldOptions & IFileField & IRelationFieldOptions & IRelationIdFieldOptions & IUpdateTimeFieldOptions & IEmailFieldOptions & IPhoneFieldOptions & IStringFieldOptions & IIntegerFieldOptions & IDateFieldOptions & IComputableFieldOptions & IJSONBFieldOptions & IGeometryFieldOptions;
|
|
57
|
+
export type IAllFieldOptions = ICreateTimeFieldOptions & IDateTimeFieldColumnOptions & IDecimalFieldOptions & IEnumFieldOptions & IExtendFieldOptions & IFileField & IRelationFieldOptions & IRelationIdFieldOptions & IUpdateTimeFieldOptions & IEmailFieldOptions & IPhoneFieldOptions & IStringFieldOptions & IIntegerFieldOptions & IDateFieldOptions & IComputableFieldOptions & IJSONBFieldOptions & IGeometryFieldOptions & IPasswordFieldOptions;
|
|
58
58
|
declare const DecoratorField: {
|
|
59
59
|
readonly BooleanField: typeof BooleanField;
|
|
60
60
|
readonly ComputableField: typeof ComputableField;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/index.ts"],"names":[],"mappings":";;;AAAA,uDAA2E;AAC3E,uDAA2E;AAC3E,2CAAyD;AACzD,mDAA2E;AAC3E,iDAAkE;AAClE,6CAA4D;AAC5D,2CAAyD;AACzD,+CAA+D;AAC/D,2CAAkD;AAClD,iDAAkE;AAClE,6CAA4D;AAC5D,6CAA4D;AAC5D,mDAAqE;AACrE,uDAA2E;AAC3E,+CAA+D;AAC/D,uDAA2E;AAC3E,iDAA4C;AAC5C,uDAAkD;AAClD,6DAAwD;AACxD,uDAAkD;AAClD,2CAAsC;AACtC,6CAAwC;AACxC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/index.ts"],"names":[],"mappings":";;;AAAA,uDAA2E;AAC3E,uDAA2E;AAC3E,2CAAyD;AACzD,mDAA2E;AAC3E,iDAAkE;AAClE,6CAA4D;AAC5D,2CAAyD;AACzD,+CAA+D;AAC/D,2CAAkD;AAClD,iDAAkE;AAClE,6CAA4D;AAC5D,6CAA4D;AAC5D,mDAAqE;AACrE,uDAA2E;AAC3E,+CAA+D;AAC/D,uDAA2E;AAC3E,iDAA4C;AAC5C,uDAAkD;AAClD,6DAAwD;AACxD,uDAAkD;AAClD,2CAAsC;AACtC,6CAAwC;AACxC,mDAAqE;AACrE,uDAAkD;AAClD,2CAAsC;AACtC,2CAAsC;AACtC,yCAAoC;AACpC,mDAAqE;AAErE,+CAA4C;AAApC,4GAAA,YAAY,OAAA;AACpB,qDAAkD;AAA1C,kHAAA,eAAe,OAAA;AACvB,qDAAkD;AAA1C,kHAAA,eAAe,OAAA;AACvB,qDAAkD;AAA1C,kHAAA,eAAe,OAAA;AACvB,yCAAsC;AAA9B,sGAAA,SAAS,OAAA;AACjB,iDAA8C;AAAtC,8GAAA,aAAa,OAAA;AACrB,+CAA4C;AAApC,4GAAA,YAAY,OAAA;AACpB,2DAAwD;AAAhD,wHAAA,kBAAkB,OAAA;AAC1B,qDAAkD;AAA1C,kHAAA,eAAe,OAAA;AACvB,2CAAwC;AAAhC,wGAAA,UAAU,OAAA;AAClB,yCAAsC;AAA9B,sGAAA,SAAS,OAAA;AACjB,6CAA0C;AAAlC,0GAAA,WAAW,OAAA;AACnB,yCAAsC;AAA9B,sGAAA,SAAS,OAAA;AACjB,yCAAsC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T,qBAAS;IACT,QAAQ,EAAR,mBAAQ;IACR,eAAe,EAAf,iCAAe;IACf,aAAa,EAAb,6BAAa;CACP,CAAC"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const typeorm_1 = require("@steroidsjs/typeorm");
|
|
4
|
+
const consts_1 = require("../../../../base/consts");
|
|
4
5
|
exports.default = (options) => [
|
|
5
6
|
(0, typeorm_1.Column)({
|
|
6
7
|
type: 'decimal',
|
|
7
8
|
default: options.defaultValue,
|
|
8
9
|
nullable: options.nullable,
|
|
9
10
|
precision: options.precision || 10,
|
|
10
|
-
scale: options.scale ||
|
|
11
|
+
scale: options.scale || consts_1.DEFAULT_DECIMAL_SCALE,
|
|
11
12
|
array: options.isArray,
|
|
12
13
|
}),
|
|
13
14
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/infrastructure/decorators/typeorm/fields/TypeOrmDecimalField/index.ts"],"names":[],"mappings":";;AAAA,iDAA2C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/infrastructure/decorators/typeorm/fields/TypeOrmDecimalField/index.ts"],"names":[],"mappings":";;AAAA,iDAA2C;AAE3C,oDAA8D;AAE9D,kBAAe,CAAC,OAA6B,EAAE,EAAE,CAAC;IAC9C,IAAA,gBAAM,EAAC;QACH,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,OAAO,CAAC,YAAY;QAC7B,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,EAAE;QAClC,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,8BAAqB;QAC7C,KAAK,EAAE,OAAO,CAAC,OAAO;KACzB,CAAC;CACL,CAAC"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const typeorm_1 = require("@steroidsjs/typeorm");
|
|
4
|
+
const consts_1 = require("../../../../base/consts");
|
|
4
5
|
exports.default = (options) => [
|
|
5
6
|
(0, typeorm_1.Column)({
|
|
6
7
|
type: 'decimal',
|
|
7
8
|
default: options.defaultValue,
|
|
8
9
|
nullable: options.nullable,
|
|
9
10
|
precision: options.precision || 10,
|
|
10
|
-
scale: options.scale ||
|
|
11
|
+
scale: options.scale || consts_1.DEFAULT_DECIMAL_SCALE,
|
|
11
12
|
array: options.isArray,
|
|
12
13
|
}),
|
|
13
14
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/infrastructure/decorators/typeorm/fields/TypeOrmDecimalNumberField/index.ts"],"names":[],"mappings":";;AAAA,iDAA2C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/infrastructure/decorators/typeorm/fields/TypeOrmDecimalNumberField/index.ts"],"names":[],"mappings":";;AAAA,iDAA2C;AAE3C,oDAA8D;AAE9D,kBAAe,CAAC,OAA6B,EAAE,EAAE,CAAC;IAC9C,IAAA,gBAAM,EAAC;QACH,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,OAAO,CAAC,YAAY;QAC7B,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,EAAE;QAClC,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,8BAAqB;QAC7C,KAAK,EAAE,OAAO,CAAC,OAAO;KACzB,CAAC;CACL,CAAC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { DeepPartial, EntityManager, Repository } from '@steroidsjs/typeorm';
|
|
2
|
+
import { SelectQueryBuilder } from '@steroidsjs/typeorm/query-builder/SelectQueryBuilder';
|
|
3
|
+
import { OnModuleDestroy, OnModuleInit } from '@nestjs/common';
|
|
2
4
|
import { ICrudRepository, TransactionHandler } from '../../usecases/interfaces/ICrudRepository';
|
|
3
5
|
import { SearchInputDto } from '../../usecases/dtos/SearchInputDto';
|
|
4
6
|
import { SearchResultDto } from '../../usecases/dtos/SearchResultDto';
|
|
5
7
|
import SearchQuery, { ISearchQueryConfig } from '../../usecases/base/SearchQuery';
|
|
6
|
-
import { SelectQueryBuilder } from '@steroidsjs/typeorm/query-builder/SelectQueryBuilder';
|
|
7
8
|
import { ICondition } from '../helpers/typeORM/ConditionHelperTypeORM';
|
|
8
9
|
import { ISaveManager } from '../../usecases/interfaces/ISaveManager';
|
|
9
|
-
import { OnModuleDestroy, OnModuleInit } from '@nestjs/common';
|
|
10
10
|
/**
|
|
11
11
|
* Generic CRUD repository
|
|
12
12
|
*/
|
|
@@ -53,7 +53,9 @@ class CrudRepository {
|
|
|
53
53
|
*/
|
|
54
54
|
async findOne(conditionOrQuery, eagerLoading = true) {
|
|
55
55
|
const [dbQuery, searchQuery] = this.createQueryBuilder(conditionOrQuery, eagerLoading);
|
|
56
|
-
let row = await dbQuery
|
|
56
|
+
let row = await dbQuery
|
|
57
|
+
.take(1)
|
|
58
|
+
.getOne();
|
|
57
59
|
if (!row) {
|
|
58
60
|
return null;
|
|
59
61
|
}
|
|
@@ -129,11 +131,7 @@ class CrudRepository {
|
|
|
129
131
|
return this.entityToModel(newEntity);
|
|
130
132
|
};
|
|
131
133
|
if (transactionHandler) {
|
|
132
|
-
return this.dbRepository.manager.transaction(async (manager) => {
|
|
133
|
-
return transactionHandler(async () => {
|
|
134
|
-
return this.saveInternal({ save: (nextModel) => saver(manager, nextModel), }, model);
|
|
135
|
-
});
|
|
136
|
-
});
|
|
134
|
+
return this.dbRepository.manager.transaction(async (manager) => transactionHandler(async () => this.saveInternal({ save: (nextModel) => saver(manager, nextModel) }, model)));
|
|
137
135
|
}
|
|
138
136
|
else {
|
|
139
137
|
return this.saveInternal({ save: (nextModel) => saver(this.dbRepository.manager, nextModel) }, model);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CrudRepository.js","sourceRoot":"","sources":["../../../src/infrastructure/repositories/CrudRepository.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"CrudRepository.js","sourceRoot":"","sources":["../../../src/infrastructure/repositories/CrudRepository.ts"],"names":[],"mappings":";;;AAGA,gFAA2E;AAI3E,iEAAgF;AAChF,kEAA6D;AAG7D,uDAAqF;AACrF,yEAAoE;AACpE,iEAA6E;AAE7E;;GAEG;AACH,MAAa,cAAc;IAA3B;QACI;;WAEG;QACI,eAAU,GAAW,IAAI,CAAC;IAqRrC,CAAC;IAvQG,YAAY;QACR,IAAI,IAAI,CAAC,UAAU,EAAE;YACjB,IAAA,mCAAe,EAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;SACnE;IACL,CAAC;IAED,eAAe;QACX,IAAI,IAAI,CAAC,UAAU,EAAE;YACjB,IAAA,mCAAe,EAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;SAC1C;IACL,CAAC;IAED;;;;OAIG;IACI,IAAI,CAAC,YAA6B,EAAE,UAAe;QACtD,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,GAAmB,EAAE,WAAgC;QAC9D,MAAM,MAAM,GAAG,MAAM,yCAAmB,CAAC,MAAM,CAC3C,IAAI,CAAC,YAAmB,EACxB,GAAG,EACH,WAAW,EACX,IAAI,CACP,CAAC;QACF,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;QAClE,OAAO,MAAM,CAAC;IAClB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,OAAO,CAAC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IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAC,EAAE,EAAC,CAAC,CAAC,CAAC;IAC7D,CAAC;IAED;;;OAGG;IACH,YAAY,CAAC,EAAU;QACnB,OAAO,IAAI,CAAC,YAAY,CAAC,kBAAkB,EAAE;aACxC,KAAK,CAAC,EAAC,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE,EAAC,CAAC;aAC9B,SAAS,EAAE,CAAC;IACrB,CAAC;CACJ;AAzRD,wCAyRC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getNewPermissions = void 0;
|
|
4
|
+
const PermissionsFactory_1 = require("../helpers/PermissionsFactory");
|
|
5
|
+
const getNewPermissions = async (dataSource, tableName = 'auth_permission', columnName = 'name') => {
|
|
6
|
+
const allPermissions = PermissionsFactory_1.PermissionsFactory.getAllPermissionsKeys();
|
|
7
|
+
if (allPermissions.length === 0) {
|
|
8
|
+
return allPermissions;
|
|
9
|
+
}
|
|
10
|
+
const existingPermissions = new Set();
|
|
11
|
+
const existingPermissionsRows = await dataSource.query(`SELECT ${columnName} FROM ${tableName}`);
|
|
12
|
+
for (const row of existingPermissionsRows) {
|
|
13
|
+
existingPermissions.add(row[columnName]);
|
|
14
|
+
}
|
|
15
|
+
return allPermissions.filter(permission => !existingPermissions.has(permission));
|
|
16
|
+
};
|
|
17
|
+
exports.getNewPermissions = getNewPermissions;
|
|
18
|
+
//# sourceMappingURL=getNewPermissions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getNewPermissions.js","sourceRoot":"","sources":["../../../src/infrastructure/utils/getNewPermissions.ts"],"names":[],"mappings":";;;AACA,sEAAiE;AAE1D,MAAM,iBAAiB,GAAG,KAAK,EAAE,UAAsB,EAAE,SAAS,GAAG,iBAAiB,EAAE,UAAU,GAAG,MAAM,EAAE,EAAE;IAClH,MAAM,cAAc,GAAG,uCAAkB,CAAC,qBAAqB,EAAE,CAAC;IAElE,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE;QAC7B,OAAO,cAAc,CAAC;KACzB;IAED,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9C,MAAM,uBAAuB,GAAwC,MAAM,UAAU,CAAC,KAAK,CACvF,UAAU,UAAU,SAAS,SAAS,EAAE,CAC3C,CAAC;IACF,KAAK,MAAM,GAAG,IAAI,uBAAuB,EAAE;QACvC,mBAAmB,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;KAC5C;IAED,OAAO,cAAc,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,mBAAmB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;AACrF,CAAC,CAAC;AAhBW,QAAA,iBAAiB,qBAgB5B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steroidsjs/nest",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.1",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"script": "nps",
|
|
6
6
|
"watch": "nps watch",
|
|
@@ -22,9 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@dbml/core": "^2.4.4",
|
|
25
|
-
"@
|
|
26
|
-
"@sentry/node": "^7.34.0",
|
|
27
|
-
"@sentry/types": "^7.34.0",
|
|
25
|
+
"@sentry/nestjs": "^10.38.0",
|
|
28
26
|
"@sqltools/formatter": "^1.2.5",
|
|
29
27
|
"@supercharge/request-ip": "^1.2.0",
|
|
30
28
|
"body-parser": "^2.2.1",
|