@steroidsjs/nest 1.0.13 → 1.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/infrastructure/base/DatabaseNamingStrategy.d.ts +4 -0
- package/infrastructure/base/DatabaseNamingStrategy.js +12 -0
- package/infrastructure/base/DatabaseNamingStrategy.js.map +1 -0
- package/infrastructure/commands/dbml/dbml2code.js +5 -3
- package/infrastructure/commands/dbml/dbml2code.js.map +1 -1
- package/infrastructure/commands/dbml/templates.js +1 -1
- package/infrastructure/commands/dbml/templates.js.map +1 -1
- package/infrastructure/commands/generate/index.js +32 -10
- package/infrastructure/commands/generate/index.js.map +1 -1
- package/infrastructure/decorators/SteroidsSchema.d.ts +6 -0
- package/infrastructure/decorators/SteroidsSchema.js +11 -0
- package/infrastructure/decorators/SteroidsSchema.js.map +1 -0
- package/infrastructure/decorators/TableFromModel.js.map +1 -1
- package/infrastructure/decorators/fields/BaseField.d.ts +13 -3
- package/infrastructure/decorators/fields/BaseField.js +18 -15
- package/infrastructure/decorators/fields/BaseField.js.map +1 -1
- package/infrastructure/decorators/fields/BooleanField.js +5 -1
- package/infrastructure/decorators/fields/BooleanField.js.map +1 -1
- package/infrastructure/decorators/fields/CoordinateField.d.ts +1 -2
- package/infrastructure/decorators/fields/CoordinateField.js +5 -1
- package/infrastructure/decorators/fields/CoordinateField.js.map +1 -1
- package/infrastructure/decorators/fields/CreateTimeField.js +5 -1
- package/infrastructure/decorators/fields/CreateTimeField.js.map +1 -1
- package/infrastructure/decorators/fields/DateField.js +5 -1
- package/infrastructure/decorators/fields/DateField.js.map +1 -1
- package/infrastructure/decorators/fields/DateTimeField.js +5 -1
- package/infrastructure/decorators/fields/DateTimeField.js.map +1 -1
- package/infrastructure/decorators/fields/DecimalField.d.ts +1 -2
- package/infrastructure/decorators/fields/DecimalField.js +5 -1
- package/infrastructure/decorators/fields/DecimalField.js.map +1 -1
- package/infrastructure/decorators/fields/EmailField.js +5 -1
- package/infrastructure/decorators/fields/EmailField.js.map +1 -1
- package/infrastructure/decorators/fields/EnumField.d.ts +2 -3
- package/infrastructure/decorators/fields/EnumField.js +5 -1
- package/infrastructure/decorators/fields/EnumField.js.map +1 -1
- package/infrastructure/decorators/fields/ExtendField.js +18 -5
- package/infrastructure/decorators/fields/ExtendField.js.map +1 -1
- package/infrastructure/decorators/fields/FileField.d.ts +4 -1
- package/infrastructure/decorators/fields/FileField.js +7 -3
- package/infrastructure/decorators/fields/FileField.js.map +1 -1
- package/infrastructure/decorators/fields/HtmlField.js +5 -1
- package/infrastructure/decorators/fields/HtmlField.js.map +1 -1
- package/infrastructure/decorators/fields/IntegerField.js +5 -1
- package/infrastructure/decorators/fields/IntegerField.js.map +1 -1
- package/infrastructure/decorators/fields/PasswordField.js +5 -1
- package/infrastructure/decorators/fields/PasswordField.js.map +1 -1
- package/infrastructure/decorators/fields/PhoneField.js +5 -1
- package/infrastructure/decorators/fields/PhoneField.js.map +1 -1
- package/infrastructure/decorators/fields/PrimaryKeyField.js +5 -1
- package/infrastructure/decorators/fields/PrimaryKeyField.js.map +1 -1
- package/infrastructure/decorators/fields/RelationField.d.ts +1 -1
- package/infrastructure/decorators/fields/RelationField.js +6 -1
- package/infrastructure/decorators/fields/RelationField.js.map +1 -1
- package/infrastructure/decorators/fields/StringField.js +5 -1
- package/infrastructure/decorators/fields/StringField.js.map +1 -1
- package/infrastructure/decorators/fields/TextField.js +5 -1
- package/infrastructure/decorators/fields/TextField.js.map +1 -1
- package/infrastructure/decorators/fields/TimeField.js +5 -1
- package/infrastructure/decorators/fields/TimeField.js.map +1 -1
- package/infrastructure/decorators/fields/UidField.js +5 -1
- package/infrastructure/decorators/fields/UidField.js.map +1 -1
- package/infrastructure/decorators/fields/UpdateTimeField.js +5 -1
- package/infrastructure/decorators/fields/UpdateTimeField.js.map +1 -1
- package/infrastructure/decorators/fields/index.d.ts +10 -0
- package/infrastructure/decorators/fields/index.js.map +1 -1
- package/infrastructure/helpers/MetaHelper.d.ts +12 -2
- package/infrastructure/helpers/MetaHelper.js +50 -8
- package/infrastructure/helpers/MetaHelper.js.map +1 -1
- package/infrastructure/repositories/CrudRepository.d.ts +3 -2
- package/infrastructure/repositories/CrudRepository.js +6 -3
- package/infrastructure/repositories/CrudRepository.js.map +1 -1
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/usecases/base/SteroidsQuery.d.ts +13 -0
- package/usecases/base/SteroidsQuery.js +16 -0
- package/usecases/base/SteroidsQuery.js.map +1 -0
- package/usecases/helpers/DataMapperHelper.d.ts +1 -1
- package/usecases/helpers/DataMapperHelper.js +29 -4
- package/usecases/helpers/DataMapperHelper.js.map +1 -1
- package/usecases/helpers/SearchHelper.d.ts +5 -3
- package/usecases/helpers/SearchHelper.js +29 -8
- package/usecases/helpers/SearchHelper.js.map +1 -1
- package/usecases/helpers/ValidationHelper.d.ts +1 -1
- package/usecases/helpers/ValidationHelper.js +2 -2
- package/usecases/helpers/ValidationHelper.js.map +1 -1
- package/usecases/interfaces/ICrudRepository.d.ts +2 -1
- package/usecases/services/CrudService.d.ts +3 -3
- package/usecases/services/CrudService.js +12 -21
- package/usecases/services/CrudService.js.map +1 -1
- package/infrastructure/decorators/fields/ExtendFields.d.ts +0 -1
- package/infrastructure/decorators/fields/ExtendFields.js +0 -15
- package/infrastructure/decorators/fields/ExtendFields.js.map +0 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DatabaseNamingStrategy = void 0;
|
|
4
|
+
const StringUtils_1 = require("typeorm/util/StringUtils");
|
|
5
|
+
const typeorm_1 = require("typeorm");
|
|
6
|
+
class DatabaseNamingStrategy extends typeorm_1.DefaultNamingStrategy {
|
|
7
|
+
joinTableName(firstTableName, secondTableName, firstPropertyName, secondPropertyName) {
|
|
8
|
+
return (0, StringUtils_1.snakeCase)(firstTableName + '_' + secondTableName);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.DatabaseNamingStrategy = DatabaseNamingStrategy;
|
|
12
|
+
//# sourceMappingURL=DatabaseNamingStrategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatabaseNamingStrategy.js","sourceRoot":"","sources":["../../../src/infrastructure/base/DatabaseNamingStrategy.ts"],"names":[],"mappings":";;;AAAA,0DAAmD;AACnD,qCAA8C;AAE9C,MAAa,sBAAuB,SAAQ,+BAAqB;IAE7D,aAAa,CAAC,cAAsB,EACtB,eAAuB,EACvB,iBAAyB,EACzB,kBAA0B;QACpC,OAAO,IAAA,uBAAS,EAAC,cAAc,GAAG,GAAG,GAAG,eAAe,CAAC,CAAC;IAC7D,CAAC;CACJ;AARD,wDAQC"}
|
|
@@ -88,7 +88,7 @@ const getFieldType = (fieldName, typeName, isPrimaryKey) => {
|
|
|
88
88
|
};
|
|
89
89
|
const getFieldJsType = (fieldType) => {
|
|
90
90
|
let fieldJsType = 'string';
|
|
91
|
-
if (['integer', 'decimal'].includes(fieldType)) {
|
|
91
|
+
if (['integer', 'decimal', 'primaryKey'].includes(fieldType)) {
|
|
92
92
|
fieldJsType = 'number';
|
|
93
93
|
}
|
|
94
94
|
if (fieldType === 'boolean') {
|
|
@@ -171,8 +171,10 @@ async function dbml2code(path) {
|
|
|
171
171
|
relationsWithJoin.push(`${fieldRight.id} - ${fieldId}`);
|
|
172
172
|
}
|
|
173
173
|
importedFields.push('RelationField');
|
|
174
|
-
|
|
175
|
-
|
|
174
|
+
if (rightTable.name !== table.name) {
|
|
175
|
+
const moduleToImport = (0, lodash_1.split)(rightTable.name, '_')[0];
|
|
176
|
+
importedModels.push({ model: modelRightName, module: moduleToImport });
|
|
177
|
+
}
|
|
176
178
|
modelFieldCodes.push((0, templates_1.templateModelRelation)(fieldLabel, relationType, isOwningSide, modelRightName, fieldName));
|
|
177
179
|
});
|
|
178
180
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version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a,CAAC,MAAM,kBAAkB,aAAa,CAAC,KAAK,EAAE,CAAC;iBAClF;gBAED,IAAI,IAAI,YAAY,aAAa,CAAC,KAAK,YAAY,IAAI,MAAM,CAAC;gBAC9D,OAAO,IAAI,CAAC;YAChB,CAAC,EAAE,EAAE,CAAC,CAAC;YAGP,MAAM,SAAS,GAAG,IAAA,yBAAa,EAC3B,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,eAAe,CAClB,CAAC;YAEF,MAAM,aAAa,GAAG,IAAA,WAAI,EAAC,UAAU,EAAE,UAAU,EAAE,iBAAiB,SAAS,KAAK,CAAC,CAAC;YACpF,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE;gBAC/B,2BAAY,CAAC,UAAU,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;aACrD;YAED,MAAM,SAAS,GAAG,IAAA,yBAAa,EAC3B,SAAS,EACT,UAAU,EACV,SAAS,CACZ,CAAC;YACF,MAAM,aAAa,GAAG,IAAA,WAAI,EAAC,UAAU,EAAE,UAAU,EAAE,yBAAyB,SAAS,KAAK,CAAC,CAAC;YAC5F,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE;gBAC/B,2BAAY,CAAC,UAAU,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;aACrD;QACL,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AAEP,CAAC;AAnKD,8BAmKC"}
|
|
@@ -36,7 +36,7 @@ exports.templateModelRelation = templateModelRelation;
|
|
|
36
36
|
function templateTable(modelName, entityName, tableName) {
|
|
37
37
|
return `import {TableFromModel} from '@steroidsjs/nest/infrastructure/decorators/TableFromModel';
|
|
38
38
|
import {DeepPartial} from 'typeorm';
|
|
39
|
-
import {
|
|
39
|
+
import {${modelName}} from '../../domain/models/${modelName}';
|
|
40
40
|
|
|
41
41
|
@TableFromModel(${modelName}, '${entityName}')
|
|
42
42
|
export class ${tableName} implements DeepPartial<${modelName}> {}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../../src/infrastructure/commands/dbml/templates.ts"],"names":[],"mappings":";;;AAAA,mCAEgB;AAEhB,SAAgB,aAAa,CACzB,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,eAAe;IAEf,OAAO;EACT,IAAA,aAAK,EAAC,cAAc,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;;EAE5D,cAAc;;KAEX,gBAAgB;;eAEN,SAAS;EACtB,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC;;CAE7B,CAAC;AACF,CAAC;AAlBD,sCAkBC;AAED,SAAgB,kBAAkB,CAC9B,aAAa,EACb,UAAU,EACV,SAAS,EACT,WAAW;IAEX,OAAO,QAAQ,aAAa;kBACd,UAAU;;MAEtB,SAAS,KAAK,WAAW,GAAG,CAAC;AACnC,CAAC;AAVD,gDAUC;AAED,SAAgB,qBAAqB,CACjC,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,SAAS;IAET,OAAO;kBACO,UAAU;iBACX,YAAY;wBACL,YAAY;4BACR,cAAc;;MAEpC,SAAS,KAAK,cAAc,GAAG,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC;AAClF,CAAC;AAdD,sDAcC;AAED,SAAgB,aAAa,CACzB,SAAS,EACT,UAAU,EACV,SAAS;IAET,OAAO;;
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../../src/infrastructure/commands/dbml/templates.ts"],"names":[],"mappings":";;;AAAA,mCAEgB;AAEhB,SAAgB,aAAa,CACzB,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,eAAe;IAEf,OAAO;EACT,IAAA,aAAK,EAAC,cAAc,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;;EAE5D,cAAc;;KAEX,gBAAgB;;eAEN,SAAS;EACtB,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC;;CAE7B,CAAC;AACF,CAAC;AAlBD,sCAkBC;AAED,SAAgB,kBAAkB,CAC9B,aAAa,EACb,UAAU,EACV,SAAS,EACT,WAAW;IAEX,OAAO,QAAQ,aAAa;kBACd,UAAU;;MAEtB,SAAS,KAAK,WAAW,GAAG,CAAC;AACnC,CAAC;AAVD,gDAUC;AAED,SAAgB,qBAAqB,CACjC,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,SAAS;IAET,OAAO;kBACO,UAAU;iBACX,YAAY;wBACL,YAAY;4BACR,cAAc;;MAEpC,SAAS,KAAK,cAAc,GAAG,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC;AAClF,CAAC;AAdD,sDAcC;AAED,SAAgB,aAAa,CACzB,SAAS,EACT,UAAU,EACV,SAAS;IAET,OAAO;;UAED,SAAS,+BAA+B,SAAS;;kBAEzC,SAAS,MAAM,UAAU;eAC5B,SAAS,2BAA2B,SAAS;CAC3D,CAAC;AACF,CAAC;AAZD,sCAYC"}
|
|
@@ -40,10 +40,16 @@ ${downSqls.join(`
|
|
|
40
40
|
`;
|
|
41
41
|
};
|
|
42
42
|
const generate = async (connection) => {
|
|
43
|
+
const junctionTablesMap = {};
|
|
43
44
|
const classesToTablesMap = connection.entityMetadatas.reduce((obj, entityMeta) => {
|
|
44
45
|
obj[entityMeta.targetName] = entityMeta.tableName;
|
|
46
|
+
entityMeta.manyToManyRelations.forEach(manyToManyRelation => {
|
|
47
|
+
if (manyToManyRelation.joinTableName) {
|
|
48
|
+
junctionTablesMap[manyToManyRelation.joinTableName] = entityMeta.tableName;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
45
51
|
return obj;
|
|
46
|
-
});
|
|
52
|
+
}, {});
|
|
47
53
|
const cliConfiguration = await (0, load_configuration_1.loadConfiguration)();
|
|
48
54
|
const sourceRoot = (0, path_1.join)(process.cwd(), cliConfiguration.sourceRoot);
|
|
49
55
|
const tablesInfo = {};
|
|
@@ -69,16 +75,18 @@ const generate = async (connection) => {
|
|
|
69
75
|
const migrationsByTables = {};
|
|
70
76
|
const sqlInMemory = await (new CustomRdbmsSchemaBuilder_1.CustomRdbmsSchemaBuilder(connection)).log();
|
|
71
77
|
for (const item of sqlInMemory.upTableQueries) {
|
|
72
|
-
|
|
73
|
-
|
|
78
|
+
const tableName = junctionTablesMap[item.tableName] || item.tableName;
|
|
79
|
+
if (!migrationsByTables[tableName]) {
|
|
80
|
+
migrationsByTables[tableName] = {
|
|
74
81
|
upQueries: [],
|
|
75
82
|
downQueries: [],
|
|
76
83
|
};
|
|
77
84
|
}
|
|
78
|
-
migrationsByTables[
|
|
85
|
+
migrationsByTables[tableName].upQueries.push(' await queryRunner.query(`' + prettifyQuery(item.query.query) + '`' + queryParams(item.query.parameters) + ');');
|
|
79
86
|
}
|
|
80
87
|
for (const item of sqlInMemory.downTableQueries) {
|
|
81
|
-
|
|
88
|
+
const tableName = junctionTablesMap[item.tableName] || item.tableName;
|
|
89
|
+
migrationsByTables[tableName].downQueries.push(' await queryRunner.query(`' + prettifyQuery(item.query.query) + '`' + queryParams(item.query.parameters) + ');');
|
|
82
90
|
}
|
|
83
91
|
const timestamp = new Date().getTime();
|
|
84
92
|
if (Object.keys(migrationsByTables).length === 0) {
|
|
@@ -93,11 +101,25 @@ const generate = async (connection) => {
|
|
|
93
101
|
}
|
|
94
102
|
const tableClassName = tablesInfo[tableName].tableClassName;
|
|
95
103
|
const moduleDir = tablesInfo[tableName].moduleDir;
|
|
96
|
-
const
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
104
|
+
const tableDeclarationUpQueries = migrationsByTables[tableName].upQueries.filter(query => query.includes('CREATE TABLE'));
|
|
105
|
+
const tableDeclarationDownQueries = migrationsByTables[tableName].downQueries.filter(query => query.includes('DROP TABLE')).reverse();
|
|
106
|
+
if (tableDeclarationUpQueries.length > 0 || tableDeclarationDownQueries.length > 0) {
|
|
107
|
+
const tableDeclarationFileContent = getTemplate(tableClassName, timestamp, tableDeclarationUpQueries, tableDeclarationDownQueries);
|
|
108
|
+
const tableDeclarationFileName = timestamp + '-' + tableClassName + '.ts';
|
|
109
|
+
const tableDeclarationFilePath = (0, path_1.join)(moduleDir, '/infrastructure/migrations', tableDeclarationFileName);
|
|
110
|
+
console.log('info', '\t' + tableDeclarationFilePath);
|
|
111
|
+
await CommandUtils_1.CommandUtils.createFile(tableDeclarationFilePath, tableDeclarationFileContent);
|
|
112
|
+
}
|
|
113
|
+
const nextTimestamp = timestamp + 1;
|
|
114
|
+
const foreignKeysUpQueries = migrationsByTables[tableName].upQueries.filter(query => !query.includes('CREATE TABLE'));
|
|
115
|
+
const foreignKeysDownQueries = migrationsByTables[tableName].downQueries.filter(query => !query.includes('DROP TABLE')).reverse();
|
|
116
|
+
if (foreignKeysUpQueries.length > 0 || foreignKeysDownQueries.length > 0) {
|
|
117
|
+
const foreignKeysFileContent = getTemplate(tableClassName, nextTimestamp, foreignKeysUpQueries, foreignKeysDownQueries);
|
|
118
|
+
const foreignKeysFileName = nextTimestamp + '-' + tableClassName + '.ts';
|
|
119
|
+
const foreignKeysFilePath = (0, path_1.join)(moduleDir, '/infrastructure/migrations', foreignKeysFileName);
|
|
120
|
+
console.log('info', '\t' + foreignKeysFilePath);
|
|
121
|
+
await CommandUtils_1.CommandUtils.createFile(foreignKeysFilePath, foreignKeysFileContent);
|
|
122
|
+
}
|
|
101
123
|
}
|
|
102
124
|
}
|
|
103
125
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/infrastructure/commands/generate/index.ts"],"names":[],"mappings":";;;AAAA,iFAA2E;AAC3E,+BAA0B;AAC1B,iCAAiC;AACjC,yBAAyB;AACzB,gEAA2D;AAE3D,mDAA2C;AAC3C,yEAAoE;AAEpE,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,CAAA;AAED,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,cAAc,CAAC,OAAO,CAAC,KAAK,EAAE,cAAc,CAAC,GAAG,YAAY,CAAC;IAC5E,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACnC,OAAO,KAAK,CAAC;AACjB,CAAC,CAAA;AAKD,MAAM,WAAW,GAAG,CAAC,IAAY,EAAE,SAAiB,EAAE,MAAgB,EAAE,QAAkB,EAAU,EAAE;IAClG,MAAM,aAAa,GAAG,GAAG,IAAI,GAAG,SAAS,EAAE,CAAC;IAE5C,OAAO;;eAEI,aAAa;cACd,aAAa;;;EAGzB,MAAM,CAAC,IAAI,CAAC;CACb,CAAC;;;;EAIA,QAAQ,CAAC,IAAI,CAAC;CACf,CAAC;;;CAGD,CAAC;AACF,CAAC,CAAA;AAEM,MAAM,QAAQ,GAAG,KAAK,EAAE,UAAsB,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/infrastructure/commands/generate/index.ts"],"names":[],"mappings":";;;AAAA,iFAA2E;AAC3E,+BAA0B;AAC1B,iCAAiC;AACjC,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CHEMA_META_KEY = void 0;
|
|
4
|
+
exports.SCHEMA_META_KEY = 'meta';
|
|
5
|
+
function SteroidsSchema(options = {}) {
|
|
6
|
+
return (target) => {
|
|
7
|
+
Reflect.defineMetadata(exports.SCHEMA_META_KEY, options, target);
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
exports.SteroidsSchema = SteroidsSchema;
|
|
11
|
+
//# sourceMappingURL=SteroidsSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SteroidsSchema.js","sourceRoot":"","sources":["../../../src/infrastructure/decorators/SteroidsSchema.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,MAAM,CAAC;AAOtC,SAAgB,cAAc,CAAC,UAA0B,EAAE;IACvD,OAAO,CAAC,MAAM,EAAE,EAAE;QACd,OAAO,CAAC,cAAc,CAAC,uBAAe,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAC7D,CAAC,CAAC;AACN,CAAC;AAJD,wCAIC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableFromModel.js","sourceRoot":"","sources":["../../../src/infrastructure/decorators/TableFromModel.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"TableFromModel.js","sourceRoot":"","sources":["../../../src/infrastructure/decorators/TableFromModel.ts"],"names":[],"mappings":";;;AAAA,qCAA+B;AAC/B,8EAAyE;AACzE,sDAAiD;AACjD,2CAA+C;AAQ/C,SAAS,sBAAsB,CAAC,UAAU;IACtC,OAAO,CAAC,MAAM,EAAE,EAAE;QACd,MAAM,MAAM,GAAG,mCAAgB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACpD,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YACnB,IAAA,yBAAW,EAAC,UAAU,CAAC,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC;AACN,CAAC;AAED,SAAgB,cAAc,CAAC,UAAU,EAAE,SAAS;IAChD,OAAO,IAAA,wBAAe,EAClB,IAAA,gBAAM,EAAC,SAAS,CAAC,EACjB,sBAAsB,CAAC,UAAU,CAAC,CACrC,CAAC;AACN,CAAC;AALD,wCAKC"}
|
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
import { ColumnType } from 'typeorm/driver/types/ColumnTypes';
|
|
2
2
|
export declare const MODEL_META_KEY = "meta";
|
|
3
|
+
export declare const MODEL_FIELD_DECORATOR_NAME = "meta_field_decorator_name";
|
|
3
4
|
export declare const MODEL_FIELD_NAMES_KEY = "meta_field_names";
|
|
4
|
-
export declare type AppColumnType = 'boolean' | 'createTime' | 'date' | 'dateTime' | 'decimal' | 'email' | 'enum' | 'file' | 'html' | 'integer' | 'password' | 'phone' | 'primaryKey' | 'string' | 'text' | 'time' | 'updateTime' | string;
|
|
5
|
+
export declare type AppColumnType = 'boolean' | 'createTime' | 'date' | 'dateTime' | 'decimal' | 'email' | 'enum' | 'file' | 'html' | 'integer' | 'password' | 'phone' | 'primaryKey' | 'relation' | 'string' | 'text' | 'time' | 'updateTime' | string;
|
|
6
|
+
export declare type JsType = 'boolean' | 'string' | 'number' | string;
|
|
5
7
|
export interface IBaseFieldOptions {
|
|
6
|
-
decoratorName?: string;
|
|
7
8
|
appType?: AppColumnType;
|
|
9
|
+
jsType?: ColumnType;
|
|
8
10
|
dbType?: ColumnType;
|
|
9
11
|
label?: string;
|
|
10
12
|
hint?: string;
|
|
11
13
|
example?: string;
|
|
12
14
|
defaultValue?: any;
|
|
15
|
+
required?: boolean;
|
|
13
16
|
nullable?: boolean;
|
|
17
|
+
isArray?: boolean;
|
|
14
18
|
min?: number;
|
|
15
19
|
max?: number;
|
|
16
20
|
items?: string;
|
|
17
21
|
}
|
|
18
|
-
export
|
|
22
|
+
export interface IInternalFieldOptions {
|
|
23
|
+
appType?: AppColumnType;
|
|
24
|
+
jsType?: ColumnType;
|
|
25
|
+
decoratorName?: string;
|
|
26
|
+
isArray?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export declare function BaseField(options: IBaseFieldOptions, internalOptions: IInternalFieldOptions): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -1,28 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseField = exports.MODEL_FIELD_NAMES_KEY = exports.MODEL_META_KEY = void 0;
|
|
3
|
+
exports.BaseField = exports.MODEL_FIELD_NAMES_KEY = exports.MODEL_FIELD_DECORATOR_NAME = exports.MODEL_META_KEY = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
5
|
const swagger_1 = require("@nestjs/swagger");
|
|
6
|
+
const class_validator_1 = require("class-validator");
|
|
6
7
|
exports.MODEL_META_KEY = 'meta';
|
|
8
|
+
exports.MODEL_FIELD_DECORATOR_NAME = 'meta_field_decorator_name';
|
|
7
9
|
exports.MODEL_FIELD_NAMES_KEY = 'meta_field_names';
|
|
8
|
-
const ColumnMetaDecorator =
|
|
9
|
-
Reflect.defineMetadata(exports.MODEL_META_KEY,
|
|
10
|
+
const ColumnMetaDecorator = (options, internalOptions) => (object, propertyName) => {
|
|
11
|
+
Reflect.defineMetadata(exports.MODEL_META_KEY, options, object, propertyName);
|
|
12
|
+
Reflect.defineMetadata(exports.MODEL_FIELD_DECORATOR_NAME, internalOptions.decoratorName, object, propertyName);
|
|
10
13
|
const fieldNames = Reflect.getMetadata(exports.MODEL_FIELD_NAMES_KEY, object) || [];
|
|
11
14
|
fieldNames.push(propertyName);
|
|
12
15
|
Reflect.defineMetadata(exports.MODEL_FIELD_NAMES_KEY, fieldNames, object);
|
|
13
16
|
};
|
|
14
|
-
function BaseField(options = null) {
|
|
15
|
-
return (0, common_1.applyDecorators)(
|
|
16
|
-
label: options.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
function BaseField(options = null, internalOptions) {
|
|
18
|
+
return (0, common_1.applyDecorators)(...[
|
|
19
|
+
ColumnMetaDecorator(Object.assign(Object.assign({ label: null, hint: null, items: null }, options), { isArray: internalOptions.isArray || null, appType: internalOptions.appType || null }), internalOptions),
|
|
20
|
+
(0, swagger_1.ApiProperty)({
|
|
21
|
+
type: options.jsType,
|
|
22
|
+
description: options.label || undefined,
|
|
23
|
+
example: options.example || undefined,
|
|
24
|
+
required: options.nullable === false,
|
|
25
|
+
isArray: options.isArray,
|
|
26
|
+
}),
|
|
27
|
+
options.required && (0, class_validator_1.IsNotEmpty)(),
|
|
28
|
+
].filter(Boolean));
|
|
26
29
|
}
|
|
27
30
|
exports.BaseField = BaseField;
|
|
28
31
|
//# sourceMappingURL=BaseField.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/BaseField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,6CAA4C;
|
|
1
|
+
{"version":3,"file":"BaseField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/BaseField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,6CAA4C;AAE5C,qDAA2C;AAE9B,QAAA,cAAc,GAAG,MAAM,CAAC;AACxB,QAAA,0BAA0B,GAAG,2BAA2B,CAAC;AACzD,QAAA,qBAAqB,GAAG,kBAAkB,CAAC;AA8BxD,MAAM,mBAAmB,GAAG,CAAC,OAA0B,EAAE,eAAsC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,YAAY,EAAE,EAAE;IACzH,OAAO,CAAC,cAAc,CAAC,sBAAc,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;IACtE,OAAO,CAAC,cAAc,CAAC,kCAA0B,EAAE,eAAe,CAAC,aAAa,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;IAGxG,MAAM,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,6BAAqB,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;IAC5E,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC9B,OAAO,CAAC,cAAc,CAAC,6BAAqB,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;AACtE,CAAC,CAAC;AAEF,SAAgB,SAAS,CAAC,UAA6B,IAAI,EAAE,eAAsC;IAC/F,OAAO,IAAA,wBAAe,EAClB,GAAG;QACC,mBAAmB,+BACf,KAAK,EAAE,IAAI,EACX,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,IAAI,IACR,OAAO,KACV,OAAO,EAAE,eAAe,CAAC,OAAO,IAAI,IAAI,EACxC,OAAO,EAAE,eAAe,CAAC,OAAO,IAAI,IAAI,KACzC,eAAe,CAAC;QACnB,IAAA,qBAAW,EAAC;YACR,IAAI,EAAE,OAAO,CAAC,MAAM;YACpB,WAAW,EAAE,OAAO,CAAC,KAAK,IAAI,SAAS;YACvC,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,SAAS;YACrC,QAAQ,EAAE,OAAO,CAAC,QAAQ,KAAK,KAAK;YACpC,OAAO,EAAE,OAAO,CAAC,OAAO;SAC3B,CAAC;QACF,OAAO,CAAC,QAAQ,IAAI,IAAA,4BAAU,GAAE;KACnC,CAAC,MAAM,CAAC,OAAO,CAAC,CACpB,CAAC;AACN,CAAC;AArBD,8BAqBC"}
|
|
@@ -7,7 +7,11 @@ const typeorm_1 = require("typeorm");
|
|
|
7
7
|
const class_validator_1 = require("class-validator");
|
|
8
8
|
const BaseField_1 = require("./BaseField");
|
|
9
9
|
function BooleanField(options = {}) {
|
|
10
|
-
return (0, common_1.applyDecorators)((0, BaseField_1.BaseField)(
|
|
10
|
+
return (0, common_1.applyDecorators)((0, BaseField_1.BaseField)(options, {
|
|
11
|
+
decoratorName: 'BooleanField',
|
|
12
|
+
appType: 'boolean',
|
|
13
|
+
jsType: 'boolean',
|
|
14
|
+
}), (0, typeorm_1.Column)({
|
|
11
15
|
type: options.dbType || 'boolean',
|
|
12
16
|
default: (0, lodash_1.has)(options, 'defaultValue') ? options.defaultValue : false,
|
|
13
17
|
nullable: (0, lodash_1.has)(options, 'nullable') ? options.nullable : false,
|
|
@@ -1 +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,
|
|
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,EAAC,OAAO,EAAE;QACf,aAAa,EAAE,cAAc;QAC7B,OAAO,EAAE,SAAS;QAClB,MAAM,EAAE,SAAS;KACpB,CAAC,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"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { IBaseFieldOptions } from './BaseField';
|
|
2
|
-
interface ICoordinateFieldOptions extends IBaseFieldOptions {
|
|
2
|
+
export interface ICoordinateFieldOptions extends IBaseFieldOptions {
|
|
3
3
|
precision?: number;
|
|
4
4
|
scale?: number;
|
|
5
5
|
}
|
|
6
6
|
export declare function CoordinateField(options?: ICoordinateFieldOptions): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
7
|
-
export {};
|
|
@@ -7,7 +7,11 @@ const class_validator_1 = require("class-validator");
|
|
|
7
7
|
const BaseField_1 = require("./BaseField");
|
|
8
8
|
function CoordinateField(options = {}) {
|
|
9
9
|
return (0, common_1.applyDecorators)(...[
|
|
10
|
-
(0, BaseField_1.BaseField)(
|
|
10
|
+
(0, BaseField_1.BaseField)(options, {
|
|
11
|
+
decoratorName: 'CoordinateField',
|
|
12
|
+
appType: 'decimal',
|
|
13
|
+
jsType: 'number',
|
|
14
|
+
}),
|
|
11
15
|
(0, typeorm_1.Column)({
|
|
12
16
|
type: 'decimal',
|
|
13
17
|
default: options.defaultValue,
|
|
@@ -1 +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,qDAAqD;AACrD,2CAAyD;AAOzD,SAAgB,eAAe,CAAC,UAAmC,EAAE;IACjE,OAAO,IAAA,wBAAe,EAAC,GAAG;QACtB,IAAA,qBAAS,
|
|
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,qDAAqD;AACrD,2CAAyD;AAOzD,SAAgB,eAAe,CAAC,UAAmC,EAAE;IACjE,OAAO,IAAA,wBAAe,EAAC,GAAG;QACtB,IAAA,qBAAS,EAAC,OAAO,EAAE;YACf,aAAa,EAAE,iBAAiB;YAChC,OAAO,EAAE,SAAS;YAClB,MAAM,EAAE,QAAQ;SACnB,CAAC;QACF,IAAA,gBAAM,EAAC;YACH,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,OAAO,CAAC,YAAY;YAC7B,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,EAAE;YAClC,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;SAC5B,CAAC;QACF,OAAO,CAAC,QAAQ,IAAI,IAAA,4BAAU,EAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC;QACjE,IAAA,0BAAQ,GAAE;KACT,CAAC,MAAM,CAAC,OAAO,CAAC,CACpB,CAAC;AACN,CAAC;AAlBD,0CAkBC"}
|
|
@@ -24,7 +24,11 @@ function CreateTimeField(options = {}) {
|
|
|
24
24
|
if (!options.label) {
|
|
25
25
|
options.label = 'Создан';
|
|
26
26
|
}
|
|
27
|
-
return (0, common_1.applyDecorators)((0, BaseField_1.BaseField)(
|
|
27
|
+
return (0, common_1.applyDecorators)((0, BaseField_1.BaseField)(options, {
|
|
28
|
+
decoratorName: 'CreateTimeField',
|
|
29
|
+
appType: 'createTime',
|
|
30
|
+
jsType: 'string',
|
|
31
|
+
}), (0, typeorm_1.CreateDateColumn)({
|
|
28
32
|
type: 'timestamp',
|
|
29
33
|
precision: (0, lodash_1.has)(options, 'precision') ? options.precision : 0,
|
|
30
34
|
default: (0, lodash_1.has)(options, 'defaultValue') ? options.defaultValue : undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateTimeField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/CreateTimeField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,mCAAmC;AACnC,qCAAiE;AACjE,kFAA6E;AAC7E,yDAAuC;AACvC,2CAAyD;AAMzD,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,YAAY,EAAE,EAAE;IACjD,MAAM,UAAU,GAAG,YAAY,GAAG,uBAAuB,CAAC;IAC1D,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE;QAErB,MAAM,CAAC,UAAU,CAAC,GAAG;YACjB,IAAI,CAAC,YAAY,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;QACpC,CAAC,CAAC;KACL;IAED,IAAA,gCAAsB,GAAE,CAAC,eAAe,CAAC,IAAI,CAAC;QAC1C,MAAM,EAAE,MAAM,CAAC,WAAW;QAC1B,YAAY,EAAE,UAAU;QACxB,IAAI,EAAE,uCAAkB,CAAC,aAAa;KACzC,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,SAAgB,eAAe,CAAC,UAAmC,EAAE;IACjE,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;QAChB,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC;KAC5B;IAED,OAAO,IAAA,wBAAe,EAClB,IAAA,qBAAS,
|
|
1
|
+
{"version":3,"file":"CreateTimeField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/CreateTimeField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,mCAAmC;AACnC,qCAAiE;AACjE,kFAA6E;AAC7E,yDAAuC;AACvC,2CAAyD;AAMzD,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,YAAY,EAAE,EAAE;IACjD,MAAM,UAAU,GAAG,YAAY,GAAG,uBAAuB,CAAC;IAC1D,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE;QAErB,MAAM,CAAC,UAAU,CAAC,GAAG;YACjB,IAAI,CAAC,YAAY,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;QACpC,CAAC,CAAC;KACL;IAED,IAAA,gCAAsB,GAAE,CAAC,eAAe,CAAC,IAAI,CAAC;QAC1C,MAAM,EAAE,MAAM,CAAC,WAAW;QAC1B,YAAY,EAAE,UAAU;QACxB,IAAI,EAAE,uCAAkB,CAAC,aAAa;KACzC,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,SAAgB,eAAe,CAAC,UAAmC,EAAE;IACjE,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;QAChB,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC;KAC5B;IAED,OAAO,IAAA,wBAAe,EAClB,IAAA,qBAAS,EAAC,OAAO,EAAE;QACf,aAAa,EAAE,iBAAiB;QAChC,OAAO,EAAE,YAAY;QACrB,MAAM,EAAE,QAAQ;KACnB,CAAC,EACF,IAAA,0BAAgB,EAAC;QACb,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,IAAA,YAAI,EAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS;QACzE,QAAQ,EAAE,IAAA,YAAI,EAAC,OAAO,EAAE,UAAU,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"}
|
|
@@ -7,7 +7,11 @@ const class_validator_1 = require("class-validator");
|
|
|
7
7
|
const class_transformer_1 = require("class-transformer");
|
|
8
8
|
const BaseField_1 = require("./BaseField");
|
|
9
9
|
function DateField(options = {}) {
|
|
10
|
-
return (0, common_1.applyDecorators)((0, BaseField_1.BaseField)(
|
|
10
|
+
return (0, common_1.applyDecorators)((0, BaseField_1.BaseField)(options, {
|
|
11
|
+
decoratorName: 'DateField',
|
|
12
|
+
appType: 'date',
|
|
13
|
+
jsType: 'string',
|
|
14
|
+
}), (0, typeorm_1.Column)({
|
|
11
15
|
type: 'date',
|
|
12
16
|
default: options.defaultValue,
|
|
13
17
|
nullable: options.nullable,
|
|
@@ -1 +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,
|
|
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,EAAC,OAAO,EAAE;QACf,aAAa,EAAE,WAAW;QAC1B,OAAO,EAAE,MAAM;QACf,MAAM,EAAE,QAAQ;KACnB,CAAC,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"}
|
|
@@ -8,7 +8,11 @@ const class_validator_1 = require("class-validator");
|
|
|
8
8
|
const class_transformer_1 = require("class-transformer");
|
|
9
9
|
const BaseField_1 = require("./BaseField");
|
|
10
10
|
function DateTimeField(options = {}) {
|
|
11
|
-
return (0, common_1.applyDecorators)((0, BaseField_1.BaseField)(
|
|
11
|
+
return (0, common_1.applyDecorators)((0, BaseField_1.BaseField)(options, {
|
|
12
|
+
decoratorName: 'DateTimeField',
|
|
13
|
+
appType: 'dateTime',
|
|
14
|
+
jsType: 'string',
|
|
15
|
+
}), (0, typeorm_1.Column)({
|
|
12
16
|
type: 'timestamp',
|
|
13
17
|
precision: (0, lodash_1.has)(options, 'precision') ? options.precision : 0,
|
|
14
18
|
default: options.defaultValue,
|
|
@@ -1 +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,
|
|
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,EAAC,OAAO,EAAE;QACf,aAAa,EAAE,eAAe;QAC9B,OAAO,EAAE,UAAU;QACnB,MAAM,EAAE,QAAQ;KACnB,CAAC,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"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { IBaseFieldOptions } from './BaseField';
|
|
2
|
-
interface IDecimalFieldOptions extends IBaseFieldOptions {
|
|
2
|
+
export interface IDecimalFieldOptions extends IBaseFieldOptions {
|
|
3
3
|
precision?: number;
|
|
4
4
|
scale?: number;
|
|
5
5
|
}
|
|
6
6
|
export declare function DecimalField(options?: IDecimalFieldOptions): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
7
|
-
export {};
|
|
@@ -7,7 +7,11 @@ const class_validator_1 = require("class-validator");
|
|
|
7
7
|
const BaseField_1 = require("./BaseField");
|
|
8
8
|
function DecimalField(options = {}) {
|
|
9
9
|
return (0, common_1.applyDecorators)(...[
|
|
10
|
-
(0, BaseField_1.BaseField)(
|
|
10
|
+
(0, BaseField_1.BaseField)(options, {
|
|
11
|
+
decoratorName: 'DecimalField',
|
|
12
|
+
appType: 'decimal',
|
|
13
|
+
jsType: 'number',
|
|
14
|
+
}),
|
|
11
15
|
(0, typeorm_1.Column)({
|
|
12
16
|
type: 'decimal',
|
|
13
17
|
default: options.defaultValue,
|
|
@@ -1 +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,qDAAqD;AACrD,2CAAyD;AAOzD,SAAgB,YAAY,CAAC,UAAgC,EAAE;IAC3D,OAAO,IAAA,wBAAe,EAAC,GAAG;QACtB,IAAA,qBAAS,
|
|
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,qDAAqD;AACrD,2CAAyD;AAOzD,SAAgB,YAAY,CAAC,UAAgC,EAAE;IAC3D,OAAO,IAAA,wBAAe,EAAC,GAAG;QACtB,IAAA,qBAAS,EAAC,OAAO,EAAE;YACf,aAAa,EAAE,cAAc;YAC7B,OAAO,EAAE,SAAS;YAClB,MAAM,EAAE,QAAQ;SACnB,CAAC;QACF,IAAA,gBAAM,EAAC;YACH,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,OAAO,CAAC,YAAY;YAC7B,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,EAAE;YAClC,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;SAC5B,CAAC;QACF,OAAO,CAAC,QAAQ,IAAI,IAAA,4BAAU,EAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC;QACjE,IAAA,0BAAQ,GAAE;KACT,CAAC,MAAM,CAAC,OAAO,CAAC,CACpB,CAAC;AACN,CAAC;AAlBD,oCAkBC"}
|
|
@@ -9,7 +9,11 @@ function EmailField(options = {}) {
|
|
|
9
9
|
if (!options.label) {
|
|
10
10
|
options.label = 'Email';
|
|
11
11
|
}
|
|
12
|
-
return (0, common_1.applyDecorators)((0, BaseField_1.BaseField)(
|
|
12
|
+
return (0, common_1.applyDecorators)((0, BaseField_1.BaseField)(options, {
|
|
13
|
+
decoratorName: 'EmailField',
|
|
14
|
+
appType: 'email',
|
|
15
|
+
jsType: 'string',
|
|
16
|
+
}), (0, typeorm_1.Column)({
|
|
13
17
|
type: 'varchar',
|
|
14
18
|
default: options.defaultValue,
|
|
15
19
|
nullable: options.nullable,
|
|
@@ -1 +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,
|
|
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,EAAC,OAAO,EAAC;QACd,aAAa,EAAE,YAAY;QAC3B,OAAO,EAAE,OAAO;QAChB,MAAM,EAAE,QAAQ;KACnB,CAAC,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"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { IBaseFieldOptions } from './BaseField';
|
|
2
|
-
interface
|
|
2
|
+
export interface IEnumFieldOptions extends IBaseFieldOptions {
|
|
3
3
|
enum?: object | string[] | any;
|
|
4
4
|
}
|
|
5
|
-
export declare function EnumField(options?:
|
|
6
|
-
export {};
|
|
5
|
+
export declare function EnumField(options?: IEnumFieldOptions): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -22,7 +22,11 @@ function EnumField(options = {}) {
|
|
|
22
22
|
options.enum = options.enum.toEnum();
|
|
23
23
|
}
|
|
24
24
|
return (0, common_1.applyDecorators)(...[
|
|
25
|
-
(0, BaseField_1.BaseField)(
|
|
25
|
+
(0, BaseField_1.BaseField)(options, {
|
|
26
|
+
decoratorName: 'EnumField',
|
|
27
|
+
appType: 'enum',
|
|
28
|
+
jsType: 'string',
|
|
29
|
+
}),
|
|
26
30
|
(0, typeorm_1.Column)({
|
|
27
31
|
type: 'varchar',
|
|
28
32
|
default: options.defaultValue,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnumField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/EnumField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,qCAA+B;AAC/B,qDAAmD;AACnD,2CAAyD;AACzD,4DAAqD;AAMrD,SAAgB,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"EnumField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/EnumField.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAC/C,qCAA+B;AAC/B,qDAAmD;AACnD,2CAAyD;AACzD,4DAAqD;AAMrD,SAAgB,SAAS,CAAC,UAA6B,EAAE;IACrD,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QAC7B,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;YAC9C,IAAI,KAAK,CAAC,SAAS,YAAY,kBAAQ,EAAE;gBACrC,GAAG,mCACI,GAAG,GACH,KAAK,CAAC,MAAM,EAAE,CACpB,CAAC;aACL;iBAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;gBAClC,GAAG,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;aACtB;YACD,OAAO,GAAG,CAAC;QACf,CAAC,EAAE,EAAE,CAAC,CAAC;KACV;SAAM,IAAI,OAAO,OAAO,CAAC,IAAI,KAAK,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,SAAS,YAAY,kBAAQ,EAAE;QACzF,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;KACxC;IAED,OAAO,IAAA,wBAAe,EAAC,GAAG;QAClB,IAAA,qBAAS,EAAC,OAAO,EAAC;YACd,aAAa,EAAE,WAAW;YAC1B,OAAO,EAAE,MAAM;YACf,MAAM,EAAE,QAAQ;SACnB,CAAC;QACF,IAAA,gBAAM,EAAC;YACH,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,OAAO,CAAC,YAAY;YAC7B,QAAQ,EAAE,OAAO,CAAC,QAAQ;SAC7B,CAAC;QACF,OAAO,CAAC,QAAQ,IAAI,IAAA,4BAAU,EAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC;QACjE,IAAA,wBAAM,EAAC,OAAO,CAAC,IAAI,CAAC;KACvB,CAAC,MAAM,CAAC,OAAO,CAAC,CACpB,CAAC;AACN,CAAC;AAhCD,8BAgCC"}
|
|
@@ -2,18 +2,31 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ExtendField = void 0;
|
|
4
4
|
const BaseField_1 = require("./BaseField");
|
|
5
|
+
const DataMapperHelper_1 = require("../../../usecases/helpers/DataMapperHelper");
|
|
5
6
|
function ExtendField(modelClass, options = {}) {
|
|
6
7
|
return (object, propertyName) => {
|
|
7
8
|
if (options.propertyName) {
|
|
8
9
|
propertyName = options.propertyName;
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
11
|
+
let modelFieldName;
|
|
12
|
+
const modelFieldNames = DataMapperHelper_1.DataMapperHelper.getKeys(modelClass);
|
|
13
|
+
for (let suffix of ['', 'Id', 'Ids']) {
|
|
14
|
+
const nameWithoutSuffix = propertyName.replace(new RegExp(suffix + '$', 'g'), '');
|
|
15
|
+
if (modelFieldNames.includes(nameWithoutSuffix)) {
|
|
16
|
+
modelFieldName = nameWithoutSuffix;
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (!modelFieldName) {
|
|
21
|
+
throw new Error('Not found field "' + propertyName + '" in model "' + modelClass.name + '"');
|
|
22
|
+
}
|
|
23
|
+
const extendOptions = Reflect.getMetadata(BaseField_1.MODEL_META_KEY, modelClass.prototype, modelFieldName);
|
|
24
|
+
const decoratorName = Reflect.getMetadata(BaseField_1.MODEL_FIELD_DECORATOR_NAME, modelClass.prototype, modelFieldName);
|
|
25
|
+
const decorator = require('./index')[decoratorName];
|
|
13
26
|
if (!decorator) {
|
|
14
|
-
throw new Error(`Not found Field decorator ${
|
|
27
|
+
throw new Error(`Not found Field decorator ${decoratorName}, property: ${propertyName}`);
|
|
15
28
|
}
|
|
16
|
-
decorator(extendOptions)(object, propertyName);
|
|
29
|
+
decorator(Object.assign(Object.assign({}, extendOptions), options))(object, propertyName);
|
|
17
30
|
};
|
|
18
31
|
}
|
|
19
32
|
exports.ExtendField = ExtendField;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExtendField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/ExtendField.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"ExtendField.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/ExtendField.ts"],"names":[],"mappings":";;;AAAA,2CAA0F;AAC1F,iFAA4E;AAM5E,SAAgB,WAAW,CAAC,UAAU,EAAE,UAA+B,EAAE;IACrE,OAAO,CAAC,MAAM,EAAE,YAAY,EAAE,EAAE;QAC5B,IAAI,OAAO,CAAC,YAAY,EAAE;YACtB,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;SACvC;QAGD,IAAI,cAAc,CAAC;QACnB,MAAM,eAAe,GAAG,mCAAgB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAG7D,KAAK,IA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