@steroidsjs/nest 1.0.0
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/LICENSE +21 -0
- package/README.md +1 -0
- package/domain/base/BaseEnum.d.ts +9 -0
- package/domain/base/BaseEnum.js +35 -0
- package/domain/base/BaseEnum.js.map +1 -0
- package/index.d.ts +0 -0
- package/index.js +1 -0
- package/index.js.map +1 -0
- package/infrastructure/commands/MigrateCommand.d.ts +23 -0
- package/infrastructure/commands/MigrateCommand.js +186 -0
- package/infrastructure/commands/MigrateCommand.js.map +1 -0
- package/infrastructure/decorators/ApiOkSearchResponse.d.ts +1 -0
- package/infrastructure/decorators/ApiOkSearchResponse.js +25 -0
- package/infrastructure/decorators/ApiOkSearchResponse.js.map +1 -0
- package/infrastructure/decorators/fields/BaseField.d.ts +17 -0
- package/infrastructure/decorators/fields/BaseField.js +24 -0
- package/infrastructure/decorators/fields/BaseField.js.map +1 -0
- package/infrastructure/decorators/fields/BooleanField.d.ts +2 -0
- package/infrastructure/decorators/fields/BooleanField.js +17 -0
- package/infrastructure/decorators/fields/BooleanField.js.map +1 -0
- package/infrastructure/decorators/fields/CoordinateField.d.ts +7 -0
- package/infrastructure/decorators/fields/CoordinateField.js +18 -0
- package/infrastructure/decorators/fields/CoordinateField.js.map +1 -0
- package/infrastructure/decorators/fields/CreateTimeField.d.ts +5 -0
- package/infrastructure/decorators/fields/CreateTimeField.js +35 -0
- package/infrastructure/decorators/fields/CreateTimeField.js.map +1 -0
- package/infrastructure/decorators/fields/DateField.d.ts +2 -0
- package/infrastructure/decorators/fields/DateField.js +17 -0
- package/infrastructure/decorators/fields/DateField.js.map +1 -0
- package/infrastructure/decorators/fields/DateTimeField.d.ts +5 -0
- package/infrastructure/decorators/fields/DateTimeField.js +19 -0
- package/infrastructure/decorators/fields/DateTimeField.js.map +1 -0
- package/infrastructure/decorators/fields/DecimalField.d.ts +7 -0
- package/infrastructure/decorators/fields/DecimalField.js +18 -0
- package/infrastructure/decorators/fields/DecimalField.js.map +1 -0
- package/infrastructure/decorators/fields/EmailField.d.ts +2 -0
- package/infrastructure/decorators/fields/EmailField.js +19 -0
- package/infrastructure/decorators/fields/EmailField.js.map +1 -0
- package/infrastructure/decorators/fields/EnumField.d.ts +6 -0
- package/infrastructure/decorators/fields/EnumField.js +31 -0
- package/infrastructure/decorators/fields/EnumField.js.map +1 -0
- package/infrastructure/decorators/fields/ExtendField.d.ts +5 -0
- package/infrastructure/decorators/fields/ExtendField.js +20 -0
- package/infrastructure/decorators/fields/ExtendField.js.map +1 -0
- package/infrastructure/decorators/fields/ExtendFields.d.ts +1 -0
- package/infrastructure/decorators/fields/ExtendFields.js +15 -0
- package/infrastructure/decorators/fields/ExtendFields.js.map +1 -0
- package/infrastructure/decorators/fields/FileField.d.ts +2 -0
- package/infrastructure/decorators/fields/FileField.js +16 -0
- package/infrastructure/decorators/fields/FileField.js.map +1 -0
- package/infrastructure/decorators/fields/HtmlField.d.ts +2 -0
- package/infrastructure/decorators/fields/HtmlField.js +15 -0
- package/infrastructure/decorators/fields/HtmlField.js.map +1 -0
- package/infrastructure/decorators/fields/IntegerField.d.ts +2 -0
- package/infrastructure/decorators/fields/IntegerField.js +22 -0
- package/infrastructure/decorators/fields/IntegerField.js.map +1 -0
- package/infrastructure/decorators/fields/PasswordField.d.ts +2 -0
- package/infrastructure/decorators/fields/PasswordField.js +20 -0
- package/infrastructure/decorators/fields/PasswordField.js.map +1 -0
- package/infrastructure/decorators/fields/PhoneField.d.ts +2 -0
- package/infrastructure/decorators/fields/PhoneField.js +20 -0
- package/infrastructure/decorators/fields/PhoneField.js.map +1 -0
- package/infrastructure/decorators/fields/PrimaryKeyField.d.ts +2 -0
- package/infrastructure/decorators/fields/PrimaryKeyField.js +14 -0
- package/infrastructure/decorators/fields/PrimaryKeyField.js.map +1 -0
- package/infrastructure/decorators/fields/RelationField.d.ts +6 -0
- package/infrastructure/decorators/fields/RelationField.js +16 -0
- package/infrastructure/decorators/fields/RelationField.js.map +1 -0
- package/infrastructure/decorators/fields/StringField.d.ts +2 -0
- package/infrastructure/decorators/fields/StringField.js +24 -0
- package/infrastructure/decorators/fields/StringField.js.map +1 -0
- package/infrastructure/decorators/fields/TextField.d.ts +2 -0
- package/infrastructure/decorators/fields/TextField.js +16 -0
- package/infrastructure/decorators/fields/TextField.js.map +1 -0
- package/infrastructure/decorators/fields/TimeField.d.ts +2 -0
- package/infrastructure/decorators/fields/TimeField.js +17 -0
- package/infrastructure/decorators/fields/TimeField.js.map +1 -0
- package/infrastructure/decorators/fields/UidField.d.ts +2 -0
- package/infrastructure/decorators/fields/UidField.js +34 -0
- package/infrastructure/decorators/fields/UidField.js.map +1 -0
- package/infrastructure/decorators/fields/UpdateTimeField.d.ts +5 -0
- package/infrastructure/decorators/fields/UpdateTimeField.js +37 -0
- package/infrastructure/decorators/fields/UpdateTimeField.js.map +1 -0
- package/infrastructure/decorators/fields/index.d.ts +18 -0
- package/infrastructure/decorators/fields/index.js +40 -0
- package/infrastructure/decorators/fields/index.js.map +1 -0
- package/infrastructure/exception/ValidationException.d.ts +5 -0
- package/infrastructure/exception/ValidationException.js +12 -0
- package/infrastructure/exception/ValidationException.js.map +1 -0
- package/infrastructure/helpers/ConditionHelper.d.ts +8 -0
- package/infrastructure/helpers/ConditionHelper.js +74 -0
- package/infrastructure/helpers/ConditionHelper.js.map +1 -0
- package/infrastructure/helpers/DataMapperHelper.d.ts +4 -0
- package/infrastructure/helpers/DataMapperHelper.js +18 -0
- package/infrastructure/helpers/DataMapperHelper.js.map +1 -0
- package/infrastructure/helpers/MetaHelper.d.ts +5 -0
- package/infrastructure/helpers/MetaHelper.js +35 -0
- package/infrastructure/helpers/MetaHelper.js.map +1 -0
- package/infrastructure/helpers/SearchHelper.d.ts +7 -0
- package/infrastructure/helpers/SearchHelper.js +30 -0
- package/infrastructure/helpers/SearchHelper.js.map +1 -0
- package/infrastructure/pipes/ValidationPipe.d.ts +4 -0
- package/infrastructure/pipes/ValidationPipe.js +37 -0
- package/infrastructure/pipes/ValidationPipe.js.map +1 -0
- package/infrastructure/repositories/CrudRepository.d.ts +18 -0
- package/infrastructure/repositories/CrudRepository.js +53 -0
- package/infrastructure/repositories/CrudRepository.js.map +1 -0
- package/infrastructure/schemas/BaseSchema.d.ts +6 -0
- package/infrastructure/schemas/BaseSchema.js +19 -0
- package/infrastructure/schemas/BaseSchema.js.map +1 -0
- package/infrastructure/schemas/SearchSchema.d.ts +7 -0
- package/infrastructure/schemas/SearchSchema.js +36 -0
- package/infrastructure/schemas/SearchSchema.js.map +1 -0
- package/package.json +40 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/usecases/dtos/SearchInputDto.d.ts +10 -0
- package/usecases/dtos/SearchInputDto.js +29 -0
- package/usecases/dtos/SearchInputDto.js.map +1 -0
- package/usecases/dtos/SearchResultDto.d.ts +5 -0
- package/usecases/dtos/SearchResultDto.js +7 -0
- package/usecases/dtos/SearchResultDto.js.map +1 -0
- package/usecases/interfaces/ICrudRepository.d.ts +12 -0
- package/usecases/interfaces/ICrudRepository.js +3 -0
- package/usecases/interfaces/ICrudRepository.js.map +1 -0
- package/usecases/services/CrudService.d.ts +16 -0
- package/usecases/services/CrudService.js +45 -0
- package/usecases/services/CrudService.js.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Steroids
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# nest
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class BaseEnum {
|
|
4
|
+
static getLabels() {
|
|
5
|
+
return {};
|
|
6
|
+
}
|
|
7
|
+
static getKeys() {
|
|
8
|
+
return Object.keys(this.getLabels());
|
|
9
|
+
}
|
|
10
|
+
static getLabel(id) {
|
|
11
|
+
return this.getLabels()[id] || '';
|
|
12
|
+
}
|
|
13
|
+
static toEnum() {
|
|
14
|
+
if (!this._enumCache) {
|
|
15
|
+
this._enumCache = Object.freeze(this.getKeys().reduce((obj, value) => {
|
|
16
|
+
obj[value] = value;
|
|
17
|
+
return obj;
|
|
18
|
+
}, {}));
|
|
19
|
+
}
|
|
20
|
+
return this._enumCache;
|
|
21
|
+
}
|
|
22
|
+
static toArray() {
|
|
23
|
+
if (!this._arrayCache) {
|
|
24
|
+
this._arrayCache = Object.freeze(Object.entries(this.getLabels()).map(([id, label]) => ({
|
|
25
|
+
label,
|
|
26
|
+
id,
|
|
27
|
+
})));
|
|
28
|
+
}
|
|
29
|
+
return this._arrayCache;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.default = BaseEnum;
|
|
33
|
+
BaseEnum._enumCache = null;
|
|
34
|
+
BaseEnum._arrayCache = null;
|
|
35
|
+
//# sourceMappingURL=BaseEnum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseEnum.js","sourceRoot":"","sources":["../../../src/domain/base/BaseEnum.ts"],"names":[],"mappings":";;AAAA,MAAqB,QAAQ;IAKzB,MAAM,CAAC,SAAS;QACZ,OAAO,EAAE,CAAC;IACd,CAAC;IAED,MAAM,CAAC,OAAO;QACV,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;IACzC,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,EAAE;QACd,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC;IACtC,CAAC;IAED,MAAM,CAAC,MAAM;QACT,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YAClB,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,MAAM,CAC3B,IAAI,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;gBACjC,GAAG,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;gBACnB,OAAO,GAAG,CAAC;YACf,CAAC,EAAE,EAAE,CAAC,CACT,CAAC;SACL;QACD,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED,MAAM,CAAC,OAAO;QACV,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACnB,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,MAAM,CAC5B,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;gBACnD,KAAK;gBACL,EAAE;aACL,CAAC,CAAC,CACN,CAAC;SACL;QACD,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;;AAvCL,2BAwCC;AAvCkB,mBAAU,GAAG,IAAI,CAAC;AAElB,oBAAW,GAAG,IAAI,CAAC"}
|
package/index.d.ts
ADDED
|
File without changes
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Connection } from 'typeorm';
|
|
2
|
+
import { ConfigService } from '@nestjs/config';
|
|
3
|
+
interface IMigrationData {
|
|
4
|
+
moduleDir: string;
|
|
5
|
+
modelName: string;
|
|
6
|
+
tableName: string;
|
|
7
|
+
upQueries: string[];
|
|
8
|
+
downQueries: string[];
|
|
9
|
+
}
|
|
10
|
+
export declare class MigrateCommand {
|
|
11
|
+
private configService;
|
|
12
|
+
private connection;
|
|
13
|
+
constructor(configService: ConfigService, connection: Connection);
|
|
14
|
+
index(): Promise<void>;
|
|
15
|
+
redo(): Promise<void>;
|
|
16
|
+
show(): Promise<void>;
|
|
17
|
+
generate(): Promise<void>;
|
|
18
|
+
protected generateMigrations(moduleDir: any, modelPath: any, modelName: any, tableName: any): Promise<IMigrationData>;
|
|
19
|
+
protected static queryParams(parameters: any[] | undefined): string;
|
|
20
|
+
protected static prettifyQuery(query: string): string;
|
|
21
|
+
protected static getTemplate(name: string, timestamp: number, upSqls: string[], downSqls: string[]): string;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var MigrateCommand_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.MigrateCommand = void 0;
|
|
14
|
+
const nestjs_command_1 = require("nestjs-command");
|
|
15
|
+
const common_1 = require("@nestjs/common");
|
|
16
|
+
const typeorm_1 = require("typeorm");
|
|
17
|
+
const lodash = require("lodash");
|
|
18
|
+
const path_1 = require("path");
|
|
19
|
+
const fs = require("fs");
|
|
20
|
+
const sqlFormatter_1 = require("@sqltools/formatter/lib/sqlFormatter");
|
|
21
|
+
const config_1 = require("@nestjs/config");
|
|
22
|
+
const load_configuration_1 = require("@nestjs/cli/lib/utils/load-configuration");
|
|
23
|
+
const CommandUtils_1 = require("typeorm/commands/CommandUtils");
|
|
24
|
+
let MigrateCommand = MigrateCommand_1 = class MigrateCommand {
|
|
25
|
+
constructor(configService, connection) {
|
|
26
|
+
this.configService = configService;
|
|
27
|
+
this.connection = connection;
|
|
28
|
+
}
|
|
29
|
+
async index() {
|
|
30
|
+
await this.connection.runMigrations({
|
|
31
|
+
transaction: 'each',
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
async redo() {
|
|
35
|
+
await this.connection.undoLastMigration({
|
|
36
|
+
transaction: 'each',
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
async show() {
|
|
40
|
+
await this.connection.showMigrations();
|
|
41
|
+
}
|
|
42
|
+
async generate() {
|
|
43
|
+
const modelsToTablesMap = this.connection.entityMetadatas.reduce((obj, entityMeta) => {
|
|
44
|
+
obj[entityMeta.targetName] = entityMeta.tableName;
|
|
45
|
+
return obj;
|
|
46
|
+
});
|
|
47
|
+
const cliConfiguration = await (0, load_configuration_1.loadConfiguration)();
|
|
48
|
+
const sourceRoot = (0, path_1.join)(process.cwd(), cliConfiguration.sourceRoot);
|
|
49
|
+
const migrationsDataList = [];
|
|
50
|
+
const moduleDirs = fs.readdirSync(sourceRoot);
|
|
51
|
+
for (const moduleName of moduleDirs) {
|
|
52
|
+
if (fs.statSync((0, path_1.join)(sourceRoot, moduleName)).isDirectory()) {
|
|
53
|
+
const moduleDir = (0, path_1.join)(sourceRoot, moduleName);
|
|
54
|
+
const moduleClassPath = (0, path_1.join)(moduleDir, '/infrastructure/' + lodash.upperFirst(moduleName) + 'Module.ts');
|
|
55
|
+
if (fs.existsSync(moduleClassPath)) {
|
|
56
|
+
const modelsDir = (0, path_1.join)(sourceRoot, moduleName, 'infrastructure/tables');
|
|
57
|
+
const modelFiles = fs.readdirSync(modelsDir);
|
|
58
|
+
for (const modelFile of modelFiles) {
|
|
59
|
+
const modelName = modelFile.replace(/\.ts$/, '');
|
|
60
|
+
const modelPath = (0, path_1.join)(modelsDir, modelFile);
|
|
61
|
+
const result = await this.generateMigrations(moduleDir, modelPath, modelName, modelsToTablesMap[modelName]);
|
|
62
|
+
if (result) {
|
|
63
|
+
migrationsDataList.push(result);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const timestamp = new Date().getTime();
|
|
70
|
+
if (migrationsDataList.length === 0) {
|
|
71
|
+
console.log('info', 'No changes in database schema were found');
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
console.log('info', 'Created migrations:');
|
|
75
|
+
for (const migrationsData of migrationsDataList) {
|
|
76
|
+
const fileContent = MigrateCommand_1.getTemplate(migrationsData.modelName, timestamp, migrationsData.upQueries, migrationsData.downQueries.reverse());
|
|
77
|
+
const fileName = timestamp + '-' + migrationsData.modelName + '.ts';
|
|
78
|
+
const path = (0, path_1.join)(migrationsData.moduleDir, '/infrastructure/migrations', fileName);
|
|
79
|
+
console.log('info', '\t' + path);
|
|
80
|
+
await CommandUtils_1.CommandUtils.createFile(path, fileContent);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
async generateMigrations(moduleDir, modelPath, modelName, tableName) {
|
|
85
|
+
const connection = new typeorm_1.Connection(Object.assign(Object.assign({}, this.configService.get('database')), { entities: [modelPath], synchronize: false, migrationsRun: false, dropSchema: false }));
|
|
86
|
+
await connection.connect();
|
|
87
|
+
const migrationData = {
|
|
88
|
+
modelName,
|
|
89
|
+
moduleDir,
|
|
90
|
+
tableName,
|
|
91
|
+
upQueries: [],
|
|
92
|
+
downQueries: [],
|
|
93
|
+
};
|
|
94
|
+
try {
|
|
95
|
+
const sqlInMemory = await connection.driver.createSchemaBuilder().log();
|
|
96
|
+
for (const key of ['upQueries', 'downQueries']) {
|
|
97
|
+
for (const query of sqlInMemory[key]) {
|
|
98
|
+
query.query = MigrateCommand_1.prettifyQuery(query.query);
|
|
99
|
+
query.query = query.query.replace(/`/g, '\\`');
|
|
100
|
+
const params = MigrateCommand_1.queryParams(query.parameters);
|
|
101
|
+
migrationData[key].push(' await queryRunner.query(`' + query.query + '`' + params + ');');
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
finally {
|
|
106
|
+
await connection.close();
|
|
107
|
+
}
|
|
108
|
+
if (migrationData.upQueries.length === 0) {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
return migrationData;
|
|
112
|
+
}
|
|
113
|
+
static queryParams(parameters) {
|
|
114
|
+
if (!parameters || !parameters.length) {
|
|
115
|
+
return '';
|
|
116
|
+
}
|
|
117
|
+
return `, ${JSON.stringify(parameters)}`;
|
|
118
|
+
}
|
|
119
|
+
static prettifyQuery(query) {
|
|
120
|
+
const formattedQuery = (0, sqlFormatter_1.format)(query, { indent: ' ' });
|
|
121
|
+
return '\n' + formattedQuery.replace(/^/gm, ' ') + '\n ';
|
|
122
|
+
}
|
|
123
|
+
static getTemplate(name, timestamp, upSqls, downSqls) {
|
|
124
|
+
const migrationName = `${name}${timestamp}`;
|
|
125
|
+
return `import {MigrationInterface, QueryRunner} from 'typeorm';
|
|
126
|
+
|
|
127
|
+
export class ${migrationName} implements MigrationInterface {
|
|
128
|
+
name = '${migrationName}'
|
|
129
|
+
|
|
130
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
131
|
+
${upSqls.join(`
|
|
132
|
+
`)}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
136
|
+
${downSqls.join(`
|
|
137
|
+
`)}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
}
|
|
141
|
+
`;
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
__decorate([
|
|
145
|
+
(0, nestjs_command_1.Command)({
|
|
146
|
+
command: 'migrate',
|
|
147
|
+
describe: 'Run migrations',
|
|
148
|
+
}),
|
|
149
|
+
__metadata("design:type", Function),
|
|
150
|
+
__metadata("design:paramtypes", []),
|
|
151
|
+
__metadata("design:returntype", Promise)
|
|
152
|
+
], MigrateCommand.prototype, "index", null);
|
|
153
|
+
__decorate([
|
|
154
|
+
(0, nestjs_command_1.Command)({
|
|
155
|
+
command: 'migrate:revert',
|
|
156
|
+
describe: 'Revert last migration',
|
|
157
|
+
}),
|
|
158
|
+
__metadata("design:type", Function),
|
|
159
|
+
__metadata("design:paramtypes", []),
|
|
160
|
+
__metadata("design:returntype", Promise)
|
|
161
|
+
], MigrateCommand.prototype, "redo", null);
|
|
162
|
+
__decorate([
|
|
163
|
+
(0, nestjs_command_1.Command)({
|
|
164
|
+
command: 'migrate:show',
|
|
165
|
+
describe: 'Show migrations list',
|
|
166
|
+
}),
|
|
167
|
+
__metadata("design:type", Function),
|
|
168
|
+
__metadata("design:paramtypes", []),
|
|
169
|
+
__metadata("design:returntype", Promise)
|
|
170
|
+
], MigrateCommand.prototype, "show", null);
|
|
171
|
+
__decorate([
|
|
172
|
+
(0, nestjs_command_1.Command)({
|
|
173
|
+
command: 'migrate:generate',
|
|
174
|
+
describe: 'Create migrations for each model changes',
|
|
175
|
+
}),
|
|
176
|
+
__metadata("design:type", Function),
|
|
177
|
+
__metadata("design:paramtypes", []),
|
|
178
|
+
__metadata("design:returntype", Promise)
|
|
179
|
+
], MigrateCommand.prototype, "generate", null);
|
|
180
|
+
MigrateCommand = MigrateCommand_1 = __decorate([
|
|
181
|
+
(0, common_1.Injectable)(),
|
|
182
|
+
__metadata("design:paramtypes", [config_1.ConfigService,
|
|
183
|
+
typeorm_1.Connection])
|
|
184
|
+
], MigrateCommand);
|
|
185
|
+
exports.MigrateCommand = MigrateCommand;
|
|
186
|
+
//# sourceMappingURL=MigrateCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MigrateCommand.js","sourceRoot":"","sources":["../../../src/infrastructure/commands/MigrateCommand.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mDAAuC;AACvC,2CAA0C;AAC1C,qCAAmC;AACnC,iCAAiC;AACjC,+BAA0B;AAC1B,yBAAyB;AACzB,uEAA4D;AAC5D,2CAA6C;AAC7C,iFAA2E;AAC3E,gEAA2D;AAW3D,IAAa,cAAc,sBAA3B,MAAa,cAAc;IACvB,YACY,aAA4B,EAC5B,UAAsB;QADtB,kBAAa,GAAb,aAAa,CAAe;QAC5B,eAAU,GAAV,UAAU,CAAY;IAElC,CAAC;IAMD,KAAK,CAAC,KAAK;QACP,MAAM,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC;YAChC,WAAW,EAAE,MAAM;SACtB,CAAC,CAAC;IACP,CAAC;IAMD,KAAK,CAAC,IAAI;QACN,MAAM,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC;YACpC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GQ,cAAc;IAD1B,IAAA,mBAAU,GAAE;qCAGkB,sBAAa;QAChB,oBAAU;GAHzB,cAAc,CAqL1B;AArLY,wCAAc"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ApiOkSearchResponse(itemType: any): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiOkSearchResponse = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
6
|
+
const SearchSchema_1 = require("../schemas/SearchSchema");
|
|
7
|
+
function ApiOkSearchResponse(itemType) {
|
|
8
|
+
return (0, common_1.applyDecorators)((0, swagger_1.ApiExtraModels)(SearchSchema_1.SearchSchema, itemType), (0, swagger_1.ApiOkResponse)({
|
|
9
|
+
schema: {
|
|
10
|
+
allOf: [
|
|
11
|
+
{ $ref: (0, swagger_1.getSchemaPath)(SearchSchema_1.SearchSchema) },
|
|
12
|
+
{
|
|
13
|
+
properties: {
|
|
14
|
+
items: {
|
|
15
|
+
type: 'array',
|
|
16
|
+
items: { $ref: (0, swagger_1.getSchemaPath)(itemType) },
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
exports.ApiOkSearchResponse = ApiOkSearchResponse;
|
|
25
|
+
//# sourceMappingURL=ApiOkSearchResponse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiOkSearchResponse.js","sourceRoot":"","sources":["../../../src/infrastructure/decorators/ApiOkSearchResponse.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,6CAA6E;AAC7E,0DAAqD;AAErD,SAAgB,mBAAmB,CAAC,QAAQ;IACxC,OAAO,IAAA,wBAAe,EAClB,IAAA,wBAAc,EAAC,2BAAY,EAAE,QAAQ,CAAC,EACtC,IAAA,uBAAa,EAAC;QACV,MAAM,EAAE;YACJ,KAAK,EAAE;gBACH,EAAE,IAAI,EAAE,IAAA,uBAAa,EAAC,2BAAY,CAAC,EAAE;gBACrC;oBACI,UAAU,EAAE;wBACR,KAAK,EAAE;4BACH,IAAI,EAAE,OAAO;4BACb,KAAK,EAAE,EAAE,IAAI,EAAE,IAAA,uBAAa,EAAC,QAAQ,CAAC,EAAE;yBAC3C;qBACJ;iBACJ;aACJ;SACJ;KACJ,CAAC,CACL,CAAC;AACN,CAAC;AAnBD,kDAmBC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ColumnType } from 'typeorm/driver/types/ColumnTypes';
|
|
2
|
+
export declare const MODEL_META_KEY = "meta";
|
|
3
|
+
export declare type AppColumnType = 'boolean' | 'createTime' | 'date' | 'dateTime' | 'decimal' | 'email' | 'enum' | 'file' | 'html' | 'integer' | 'password' | 'phone' | 'primaryKey' | 'string' | 'text' | 'time' | 'updateTime' | string;
|
|
4
|
+
export interface IBaseFieldOptions {
|
|
5
|
+
decoratorName?: string;
|
|
6
|
+
appType?: AppColumnType;
|
|
7
|
+
dbType?: ColumnType;
|
|
8
|
+
label?: string;
|
|
9
|
+
hint?: string;
|
|
10
|
+
example?: string;
|
|
11
|
+
defaultValue?: any;
|
|
12
|
+
nullable?: boolean;
|
|
13
|
+
min?: number;
|
|
14
|
+
max?: number;
|
|
15
|
+
items?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function BaseField(options?: IBaseFieldOptions): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseField = exports.MODEL_META_KEY = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
6
|
+
exports.MODEL_META_KEY = 'meta';
|
|
7
|
+
const ColumnMetaDecorator = value => (object, propertyName) => {
|
|
8
|
+
Reflect.defineMetadata(exports.MODEL_META_KEY, value, object, propertyName);
|
|
9
|
+
};
|
|
10
|
+
function BaseField(options = null) {
|
|
11
|
+
return (0, common_1.applyDecorators)(ColumnMetaDecorator({
|
|
12
|
+
label: options.label || null,
|
|
13
|
+
hint: options.hint || null,
|
|
14
|
+
appType: options.appType || null,
|
|
15
|
+
items: options.items || null,
|
|
16
|
+
_raw: options,
|
|
17
|
+
}), (0, swagger_1.ApiProperty)({
|
|
18
|
+
description: options.label || undefined,
|
|
19
|
+
example: options.example || undefined,
|
|
20
|
+
required: options.nullable === false,
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
exports.BaseField = BaseField;
|
|
24
|
+
//# sourceMappingURL=BaseField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/BaseField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,6CAA4C;AAG/B,QAAA,cAAc,GAAG,MAAM,CAAC;AAoBrC,MAAM,mBAAmB,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,YAAY,EAAE,EAAE;IAC1D,OAAO,CAAC,cAAc,CAAC,sBAAc,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;AACxE,CAAC,CAAC;AAEF,SAAgB,SAAS,CAAC,UAA6B,IAAI;IACvD,OAAO,IAAA,wBAAe,EAClB,mBAAmB,CAAC;QAChB,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,IAAI;QAC5B,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,IAAI;QAC1B,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,IAAI;QAChC,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,IAAI;QAC5B,IAAI,EAAE,OAAO;KAChB,CAAC,EACF,IAAA,qBAAW,EAAC;QACR,WAAW,EAAE,OAAO,CAAC,KAAK,IAAI,SAAS;QACvC,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,SAAS;QACrC,QAAQ,EAAE,OAAO,CAAC,QAAQ,KAAK,KAAK;KACvC,CAAC,CACL,CAAC;AACN,CAAC;AAfD,8BAeC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BooleanField = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const lodash_1 = require("lodash");
|
|
6
|
+
const typeorm_1 = require("typeorm");
|
|
7
|
+
const class_validator_1 = require("class-validator");
|
|
8
|
+
const BaseField_1 = require("./BaseField");
|
|
9
|
+
function BooleanField(options = {}) {
|
|
10
|
+
return (0, common_1.applyDecorators)((0, BaseField_1.BaseField)(Object.assign(Object.assign({}, options), { decoratorName: 'BooleanField', appType: 'boolean' })), (0, typeorm_1.Column)({
|
|
11
|
+
type: options.dbType || 'boolean',
|
|
12
|
+
default: (0, lodash_1.has)(options, 'defaultValue') ? options.defaultValue : false,
|
|
13
|
+
nullable: (0, lodash_1.has)(options, 'nullable') ? options.nullable : false,
|
|
14
|
+
}), (0, class_validator_1.IsBoolean)(), (0, class_validator_1.IsOptional)());
|
|
15
|
+
}
|
|
16
|
+
exports.BooleanField = BooleanField;
|
|
17
|
+
//# sourceMappingURL=BooleanField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BooleanField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/BooleanField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,mCAAmC;AACnC,qCAA+B;AAC/B,qDAAsD;AACtD,2CAAyD;AAEzD,SAAgB,YAAY,CAAC,UAA6B,EAAE;IACxD,OAAO,IAAA,wBAAe,EAClB,IAAA,qBAAS,kCACF,OAAO,KACV,aAAa,EAAE,cAAc,EAC7B,OAAO,EAAE,SAAS,IACpB,EACF,IAAA,gBAAM,EAAC;QACH,IAAI,EAAE,OAAO,CAAC,MAAM,IAAI,SAAS;QACjC,OAAO,EAAE,IAAA,YAAI,EAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK;QACrE,QAAQ,EAAE,IAAA,YAAI,EAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK;KACjE,CAAC,EACF,IAAA,2BAAS,GAAE,EACX,IAAA,4BAAU,GAAE,CACf,CAAC;AACN,CAAC;AAfD,oCAeC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IBaseFieldOptions } from './BaseField';
|
|
2
|
+
interface ICoordinateFieldOptions extends IBaseFieldOptions {
|
|
3
|
+
precision?: number;
|
|
4
|
+
scale?: number;
|
|
5
|
+
}
|
|
6
|
+
export declare function CoordinateField(options?: ICoordinateFieldOptions): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CoordinateField = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const typeorm_1 = require("typeorm");
|
|
6
|
+
const class_validator_1 = require("class-validator");
|
|
7
|
+
const BaseField_1 = require("./BaseField");
|
|
8
|
+
function CoordinateField(options = {}) {
|
|
9
|
+
return (0, common_1.applyDecorators)((0, BaseField_1.BaseField)(Object.assign(Object.assign({}, options), { decoratorName: 'CoordinateField', appType: 'decimal' })), (0, typeorm_1.Column)({
|
|
10
|
+
type: 'decimal',
|
|
11
|
+
default: options.defaultValue,
|
|
12
|
+
nullable: options.nullable,
|
|
13
|
+
precision: options.precision || 12,
|
|
14
|
+
scale: options.scale || 9,
|
|
15
|
+
}), (0, class_validator_1.IsNumber)());
|
|
16
|
+
}
|
|
17
|
+
exports.CoordinateField = CoordinateField;
|
|
18
|
+
//# sourceMappingURL=CoordinateField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CoordinateField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/CoordinateField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,qCAA+B;AAC/B,qDAAyC;AACzC,2CAAyD;AAOzD,SAAgB,eAAe,CAAC,UAAmC,EAAE;IACjE,OAAO,IAAA,wBAAe,EAClB,IAAA,qBAAS,kCACF,OAAO,KACV,aAAa,EAAE,iBAAiB,EAChC,OAAO,EAAE,SAAS,IACpB,EACF,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,CAAC;KAC5B,CAAC,EACF,IAAA,0BAAQ,GAAE,CACb,CAAC;AACN,CAAC;AAhBD,0CAgBC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { IBaseFieldOptions } from './BaseField';
|
|
2
|
+
export interface ICreateTimeFieldOptions extends IBaseFieldOptions {
|
|
3
|
+
precision?: number;
|
|
4
|
+
}
|
|
5
|
+
export declare function CreateTimeField(options?: ICreateTimeFieldOptions): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CreateTimeField = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const lodash_1 = require("lodash");
|
|
6
|
+
const typeorm_1 = require("typeorm");
|
|
7
|
+
const EventListenerTypes_1 = require("typeorm/metadata/types/EventListenerTypes");
|
|
8
|
+
const class_transformer_1 = require("class-transformer");
|
|
9
|
+
const BaseField_1 = require("./BaseField");
|
|
10
|
+
const CreateTimeBehaviour = (object, propertyName) => {
|
|
11
|
+
const methodName = propertyName + '__createTimeBehaviour';
|
|
12
|
+
if (!object[methodName]) {
|
|
13
|
+
object[methodName] = function () {
|
|
14
|
+
this[propertyName] = new Date();
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
(0, typeorm_1.getMetadataArgsStorage)().entityListeners.push({
|
|
18
|
+
target: object.constructor,
|
|
19
|
+
propertyName: methodName,
|
|
20
|
+
type: EventListenerTypes_1.EventListenerTypes.BEFORE_INSERT,
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
function CreateTimeField(options = {}) {
|
|
24
|
+
if (!options.label) {
|
|
25
|
+
options.label = 'Создан';
|
|
26
|
+
}
|
|
27
|
+
return (0, common_1.applyDecorators)((0, BaseField_1.BaseField)(Object.assign(Object.assign({}, options), { decoratorName: 'CreateTimeField', appType: 'createTime' })), (0, typeorm_1.CreateDateColumn)({
|
|
28
|
+
type: 'timestamp',
|
|
29
|
+
precision: (0, lodash_1.has)(options, 'precision') ? options.precision : 0,
|
|
30
|
+
default: (0, lodash_1.has)(options, 'defaultValue') ? options.defaultValue : undefined,
|
|
31
|
+
nullable: (0, lodash_1.has)(options, 'nullable') ? options.nullable : false,
|
|
32
|
+
}), CreateTimeBehaviour, (0, class_transformer_1.Type)(() => Date));
|
|
33
|
+
}
|
|
34
|
+
exports.CreateTimeField = CreateTimeField;
|
|
35
|
+
//# sourceMappingURL=CreateTimeField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file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,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK;KACjE,CAAC,EACF,mBAAmB,EACnB,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CACnB,CAAC;AACN,CAAC;AApBD,0CAoBC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DateField = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const typeorm_1 = require("typeorm");
|
|
6
|
+
const class_validator_1 = require("class-validator");
|
|
7
|
+
const class_transformer_1 = require("class-transformer");
|
|
8
|
+
const BaseField_1 = require("./BaseField");
|
|
9
|
+
function DateField(options = {}) {
|
|
10
|
+
return (0, common_1.applyDecorators)((0, BaseField_1.BaseField)(Object.assign(Object.assign({}, options), { decoratorName: 'DateField', appType: 'date' })), (0, typeorm_1.Column)({
|
|
11
|
+
type: 'date',
|
|
12
|
+
default: options.defaultValue,
|
|
13
|
+
nullable: options.nullable,
|
|
14
|
+
}), (0, class_validator_1.IsDate)(), (0, class_transformer_1.Type)(() => Date));
|
|
15
|
+
}
|
|
16
|
+
exports.DateField = DateField;
|
|
17
|
+
//# sourceMappingURL=DateField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DateField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/DateField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,qCAA+B;AAC/B,qDAAuC;AACvC,yDAAuC;AACvC,2CAAyD;AAEzD,SAAgB,SAAS,CAAC,UAA6B,EAAE;IACrD,OAAO,IAAA,wBAAe,EAClB,IAAA,qBAAS,kCACF,OAAO,KACV,aAAa,EAAE,WAAW,EAC1B,OAAO,EAAE,MAAM,IACjB,EACF,IAAA,gBAAM,EAAC;QACH,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,OAAO,CAAC,YAAY;QAC7B,QAAQ,EAAE,OAAO,CAAC,QAAQ;KAC7B,CAAC,EACF,IAAA,wBAAM,GAAE,EACR,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CACnB,CAAC;AACN,CAAC;AAfD,8BAeC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { IBaseFieldOptions } from './BaseField';
|
|
2
|
+
export interface IDateTimeFieldColumnOptions extends IBaseFieldOptions {
|
|
3
|
+
precision?: number;
|
|
4
|
+
}
|
|
5
|
+
export declare function DateTimeField(options?: IDateTimeFieldColumnOptions): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DateTimeField = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const lodash_1 = require("lodash");
|
|
6
|
+
const typeorm_1 = require("typeorm");
|
|
7
|
+
const class_validator_1 = require("class-validator");
|
|
8
|
+
const class_transformer_1 = require("class-transformer");
|
|
9
|
+
const BaseField_1 = require("./BaseField");
|
|
10
|
+
function DateTimeField(options = {}) {
|
|
11
|
+
return (0, common_1.applyDecorators)((0, BaseField_1.BaseField)(Object.assign(Object.assign({}, options), { decoratorName: 'DateTimeField', appType: 'dateTime' })), (0, typeorm_1.Column)({
|
|
12
|
+
type: 'timestamp',
|
|
13
|
+
precision: (0, lodash_1.has)(options, 'precision') ? options.precision : 0,
|
|
14
|
+
default: options.defaultValue,
|
|
15
|
+
nullable: options.nullable,
|
|
16
|
+
}), (0, class_validator_1.IsDate)(), (0, class_transformer_1.Type)(() => Date));
|
|
17
|
+
}
|
|
18
|
+
exports.DateTimeField = DateTimeField;
|
|
19
|
+
//# sourceMappingURL=DateTimeField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DateTimeField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/DateTimeField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,mCAAmC;AACnC,qCAA+B;AAC/B,qDAAuC;AACvC,yDAAuC;AACvC,2CAAyD;AAMzD,SAAgB,aAAa,CAAC,UAAuC,EAAE;IACnE,OAAO,IAAA,wBAAe,EAClB,IAAA,qBAAS,kCACF,OAAO,KACV,aAAa,EAAE,eAAe,EAC9B,OAAO,EAAE,UAAU,IACrB,EACF,IAAA,gBAAM,EAAC;QACH,IAAI,EAAE,WAAW;QACjB,SAAS,EAAE,IAAA,YAAI,EAAC,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAC7D,OAAO,EAAE,OAAO,CAAC,YAAY;QAC7B,QAAQ,EAAE,OAAO,CAAC,QAAQ;KAO7B,CAAC,EACF,IAAA,wBAAM,GAAE,EACR,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CACnB,CAAC;AACN,CAAC;AAtBD,sCAsBC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IBaseFieldOptions } from './BaseField';
|
|
2
|
+
interface IDecimalFieldOptions extends IBaseFieldOptions {
|
|
3
|
+
precision?: number;
|
|
4
|
+
scale?: number;
|
|
5
|
+
}
|
|
6
|
+
export declare function DecimalField(options?: IDecimalFieldOptions): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DecimalField = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const typeorm_1 = require("typeorm");
|
|
6
|
+
const class_validator_1 = require("class-validator");
|
|
7
|
+
const BaseField_1 = require("./BaseField");
|
|
8
|
+
function DecimalField(options = {}) {
|
|
9
|
+
return (0, common_1.applyDecorators)((0, BaseField_1.BaseField)(Object.assign(Object.assign({}, options), { decoratorName: 'DecimalField', appType: 'decimal' })), (0, typeorm_1.Column)({
|
|
10
|
+
type: 'decimal',
|
|
11
|
+
default: options.defaultValue,
|
|
12
|
+
nullable: options.nullable,
|
|
13
|
+
precision: options.precision || 10,
|
|
14
|
+
scale: options.scale || 2,
|
|
15
|
+
}), (0, class_validator_1.IsNumber)());
|
|
16
|
+
}
|
|
17
|
+
exports.DecimalField = DecimalField;
|
|
18
|
+
//# sourceMappingURL=DecimalField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DecimalField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/DecimalField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,qCAA+B;AAC/B,qDAAyC;AACzC,2CAAyD;AAOzD,SAAgB,YAAY,CAAC,UAAgC,EAAE;IAC3D,OAAO,IAAA,wBAAe,EAClB,IAAA,qBAAS,kCACF,OAAO,KACV,aAAa,EAAE,cAAc,EAC7B,OAAO,EAAE,SAAS,IACpB,EACF,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,CAAC;KAC5B,CAAC,EACF,IAAA,0BAAQ,GAAE,CACb,CAAC;AACN,CAAC;AAhBD,oCAgBC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EmailField = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const typeorm_1 = require("typeorm");
|
|
6
|
+
const class_validator_1 = require("class-validator");
|
|
7
|
+
const BaseField_1 = require("./BaseField");
|
|
8
|
+
function EmailField(options = {}) {
|
|
9
|
+
if (!options.label) {
|
|
10
|
+
options.label = 'Email';
|
|
11
|
+
}
|
|
12
|
+
return (0, common_1.applyDecorators)((0, BaseField_1.BaseField)(Object.assign(Object.assign({}, options), { decoratorName: 'EmailField', appType: 'email' })), (0, typeorm_1.Column)({
|
|
13
|
+
type: 'varchar',
|
|
14
|
+
default: options.defaultValue,
|
|
15
|
+
nullable: options.nullable,
|
|
16
|
+
}), (0, class_validator_1.IsEmail)());
|
|
17
|
+
}
|
|
18
|
+
exports.EmailField = EmailField;
|
|
19
|
+
//# sourceMappingURL=EmailField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmailField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/EmailField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,qCAA+B;AAC/B,qDAAwC;AACxC,2CAAyD;AAEzD,SAAgB,UAAU,CAAC,UAA6B,EAAE;IACtD,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;QAChB,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC;KAC3B;IAED,OAAO,IAAA,wBAAe,EAClB,IAAA,qBAAS,kCACF,OAAO,KACV,aAAa,EAAE,YAAY,EAC3B,OAAO,EAAE,OAAO,IAClB,EACF,IAAA,gBAAM,EAAC;QACH,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,OAAO,CAAC,YAAY;QAC7B,QAAQ,EAAE,OAAO,CAAC,QAAQ;KAC7B,CAAC,EACF,IAAA,yBAAO,GAAE,CACZ,CAAC;AACN,CAAC;AAlBD,gCAkBC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IBaseFieldOptions } from './BaseField';
|
|
2
|
+
interface IBEnumFieldOptions extends IBaseFieldOptions {
|
|
3
|
+
enum?: object | string[] | any;
|
|
4
|
+
}
|
|
5
|
+
export declare function EnumField(options?: IBEnumFieldOptions): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
6
|
+
export {};
|