@steroidsjs/nest 1.0.10 → 1.0.14
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/MigrateCommand.d.ts +1 -0
- package/infrastructure/commands/MigrateCommand.js +21 -0
- package/infrastructure/commands/MigrateCommand.js.map +1 -1
- package/infrastructure/commands/dbml/dbml2code.d.ts +1 -0
- package/infrastructure/commands/dbml/dbml2code.js +215 -0
- package/infrastructure/commands/dbml/dbml2code.js.map +1 -0
- package/infrastructure/commands/dbml/templates.d.ts +4 -0
- package/infrastructure/commands/dbml/templates.js +46 -0
- package/infrastructure/commands/dbml/templates.js.map +1 -0
- package/infrastructure/commands/generate/index.js +24 -10
- package/infrastructure/commands/generate/index.js.map +1 -1
- package/infrastructure/decorators/TableFromModel.d.ts +6 -0
- package/infrastructure/decorators/TableFromModel.js +20 -0
- package/infrastructure/decorators/TableFromModel.js.map +1 -0
- package/infrastructure/decorators/fields/index.d.ts +1 -1
- package/infrastructure/decorators/fields/index.js +3 -3
- package/infrastructure/repositories/CrudRepository.d.ts +2 -2
- package/infrastructure/repositories/CrudRepository.js.map +1 -1
- package/package.json +4 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/usecases/helpers/SearchHelper.d.ts +1 -1
- package/usecases/helpers/SearchHelper.js.map +1 -1
- package/usecases/interfaces/ICrudRepository.d.ts +6 -6
|
@@ -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"}
|
|
@@ -8,11 +8,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.MigrateCommand = void 0;
|
|
13
16
|
const nestjs_command_1 = require("nestjs-command");
|
|
14
17
|
const common_1 = require("@nestjs/common");
|
|
15
18
|
const typeorm_1 = require("typeorm");
|
|
19
|
+
const dbml2code_1 = require("./dbml/dbml2code");
|
|
16
20
|
const generate_1 = require("./generate");
|
|
17
21
|
let MigrateCommand = class MigrateCommand {
|
|
18
22
|
constructor(connection) {
|
|
@@ -31,6 +35,9 @@ let MigrateCommand = class MigrateCommand {
|
|
|
31
35
|
async show() {
|
|
32
36
|
await this.connection.showMigrations();
|
|
33
37
|
}
|
|
38
|
+
async dbml2code(path) {
|
|
39
|
+
await (0, dbml2code_1.dbml2code)(path);
|
|
40
|
+
}
|
|
34
41
|
async generate() {
|
|
35
42
|
await (0, generate_1.generate)(this.connection);
|
|
36
43
|
}
|
|
@@ -62,6 +69,20 @@ __decorate([
|
|
|
62
69
|
__metadata("design:paramtypes", []),
|
|
63
70
|
__metadata("design:returntype", Promise)
|
|
64
71
|
], MigrateCommand.prototype, "show", null);
|
|
72
|
+
__decorate([
|
|
73
|
+
(0, nestjs_command_1.Command)({
|
|
74
|
+
command: 'migrate:dbml2code <path>',
|
|
75
|
+
describe: 'Generate code from dbml diagram',
|
|
76
|
+
}),
|
|
77
|
+
__param(0, (0, nestjs_command_1.Positional)({
|
|
78
|
+
name: 'path',
|
|
79
|
+
describe: 'Path to *.dbml file',
|
|
80
|
+
type: 'string'
|
|
81
|
+
})),
|
|
82
|
+
__metadata("design:type", Function),
|
|
83
|
+
__metadata("design:paramtypes", [String]),
|
|
84
|
+
__metadata("design:returntype", Promise)
|
|
85
|
+
], MigrateCommand.prototype, "dbml2code", null);
|
|
65
86
|
__decorate([
|
|
66
87
|
(0, nestjs_command_1.Command)({
|
|
67
88
|
command: 'migrate:generate',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MigrateCommand.js","sourceRoot":"","sources":["../../../src/infrastructure/commands/MigrateCommand.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MigrateCommand.js","sourceRoot":"","sources":["../../../src/infrastructure/commands/MigrateCommand.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mDAAmD;AACnD,2CAA0C;AAC1C,qCAAmC;AACnC,gDAA2C;AAC3C,yCAAoC;AAWpC,IAAa,cAAc,GAA3B,MAAa,cAAc;IACvB,YACY,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAElC,CAA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IAD1B,IAAA,mBAAU,GAAE;qCAGe,oBAAU;GAFzB,cAAc,CA0D1B;AA1DY,wCAAc"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function dbml2code(path: any): Promise<void>;
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dbml2code = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const lodash_1 = require("lodash");
|
|
7
|
+
const pluralize = require("pluralize");
|
|
8
|
+
const load_configuration_1 = require("@nestjs/cli/lib/utils/load-configuration");
|
|
9
|
+
const CommandUtils_1 = require("typeorm/commands/CommandUtils");
|
|
10
|
+
const core_1 = require("@dbml/core");
|
|
11
|
+
const templates_1 = require("./templates");
|
|
12
|
+
const relationsMap = {
|
|
13
|
+
'11': 'OneToOne',
|
|
14
|
+
'1*': 'OneToMany',
|
|
15
|
+
'*1': 'ManyToOne',
|
|
16
|
+
'**': 'ManyToMany',
|
|
17
|
+
};
|
|
18
|
+
const determineRelation = (dbmlJson, manyToManyTables, endpointId) => {
|
|
19
|
+
const endpointLeft = dbmlJson.endpoints[endpointId];
|
|
20
|
+
const ref = dbmlJson.refs[endpointLeft.refId];
|
|
21
|
+
const endpointRight = dbmlJson.endpoints[ref.endpointIds.filter(refEndpointId => refEndpointId !== endpointId)[0]];
|
|
22
|
+
const relationLeft = endpointLeft.relation;
|
|
23
|
+
const relationRight = endpointRight.relation;
|
|
24
|
+
let relationType = relationLeft + relationRight;
|
|
25
|
+
let fieldRight = dbmlJson.fields[endpointRight.fieldIds[0]];
|
|
26
|
+
if (relationType === '1*') {
|
|
27
|
+
const manyToManyTable = manyToManyTables.find(table => table.id === fieldRight.tableId);
|
|
28
|
+
if (manyToManyTable) {
|
|
29
|
+
relationType = '**';
|
|
30
|
+
const manyToManyRelationFieldId = manyToManyTable.fieldIds.filter(fieldId => fieldId !== fieldRight.id)[0];
|
|
31
|
+
const manyToManyRelationField = dbmlJson.fields[manyToManyRelationFieldId];
|
|
32
|
+
const manyToManyRelationEndpoint = dbmlJson.endpoints[manyToManyRelationField.endpointIds[0]];
|
|
33
|
+
const manyToManyRelationRef = dbmlJson.refs[manyToManyRelationEndpoint.refId];
|
|
34
|
+
const realRelationEndpoint = dbmlJson.endpoints[manyToManyRelationRef.endpointIds.filter(endpointId => endpointId !== manyToManyRelationEndpoint.id)[0]];
|
|
35
|
+
fieldRight = dbmlJson.fields[realRelationEndpoint.fieldIds[0]];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
relationType,
|
|
40
|
+
fieldRight,
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
const findManyToManyTables = (dbmlJson) => {
|
|
44
|
+
const manyToManyTables = [];
|
|
45
|
+
Object.values(dbmlJson.tables).forEach((table) => {
|
|
46
|
+
if (table.fieldIds.length === 2
|
|
47
|
+
&& dbmlJson.fields[table.fieldIds[0]].name.endsWith('Id')
|
|
48
|
+
&& dbmlJson.fields[table.fieldIds[1]].name.endsWith('Id')) {
|
|
49
|
+
manyToManyTables.push(table);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
return manyToManyTables;
|
|
53
|
+
};
|
|
54
|
+
const findModules = (tables) => {
|
|
55
|
+
return (0, lodash_1.uniq)(tables.map(table => (0, lodash_1.split)(table.name, '_')[0]));
|
|
56
|
+
};
|
|
57
|
+
const getFieldType = (fieldName, typeName, isPrimaryKey) => {
|
|
58
|
+
const typesMap = {
|
|
59
|
+
varchar: 'string',
|
|
60
|
+
int: 'integer',
|
|
61
|
+
integer: 'integer',
|
|
62
|
+
bool: 'boolean',
|
|
63
|
+
boolean: 'boolean',
|
|
64
|
+
date: 'date',
|
|
65
|
+
datetime: 'dateTime',
|
|
66
|
+
double: 'decimal',
|
|
67
|
+
decimal: 'decimal',
|
|
68
|
+
float: 'decimal',
|
|
69
|
+
text: 'text',
|
|
70
|
+
};
|
|
71
|
+
let fieldType = typesMap[typeName] || 'string';
|
|
72
|
+
if (isPrimaryKey) {
|
|
73
|
+
fieldType = 'primaryKey';
|
|
74
|
+
}
|
|
75
|
+
if (['createTime', 'updateTime'].includes(fieldName)) {
|
|
76
|
+
fieldType = fieldName;
|
|
77
|
+
}
|
|
78
|
+
if (fieldName.indexOf('phone') !== -1) {
|
|
79
|
+
fieldType = 'phone';
|
|
80
|
+
}
|
|
81
|
+
if (fieldName.indexOf('email') !== -1) {
|
|
82
|
+
fieldType = 'email';
|
|
83
|
+
}
|
|
84
|
+
if (fieldName.indexOf('password') !== -1) {
|
|
85
|
+
fieldType = 'password';
|
|
86
|
+
}
|
|
87
|
+
return fieldType;
|
|
88
|
+
};
|
|
89
|
+
const getFieldJsType = (fieldType) => {
|
|
90
|
+
let fieldJsType = 'string';
|
|
91
|
+
if (['integer', 'decimal'].includes(fieldType)) {
|
|
92
|
+
fieldJsType = 'number';
|
|
93
|
+
}
|
|
94
|
+
if (fieldType === 'boolean') {
|
|
95
|
+
fieldJsType = 'boolean';
|
|
96
|
+
}
|
|
97
|
+
if (['createTime', 'updateTime'].includes(fieldType)) {
|
|
98
|
+
fieldJsType = 'Date';
|
|
99
|
+
}
|
|
100
|
+
return fieldJsType;
|
|
101
|
+
};
|
|
102
|
+
const getRelationFieldName = (baseName, relationType, fieldName, relalationTableName) => {
|
|
103
|
+
let relationFieldName = baseName;
|
|
104
|
+
if (relationType.endsWith('Many')) {
|
|
105
|
+
const nameWords = (0, lodash_1.split)(relalationTableName, '_');
|
|
106
|
+
nameWords[nameWords.length - 1] = pluralize.plural(nameWords[nameWords.length - 1]);
|
|
107
|
+
relationFieldName = (0, lodash_1.camelCase)(nameWords.join('_'));
|
|
108
|
+
}
|
|
109
|
+
if (relationType === 'ManyToOne') {
|
|
110
|
+
relationFieldName = fieldName.endsWith('Id') ? fieldName.slice(0, -2) : fieldName.name;
|
|
111
|
+
}
|
|
112
|
+
return relationFieldName;
|
|
113
|
+
};
|
|
114
|
+
async function dbml2code(path) {
|
|
115
|
+
if (!fs.existsSync(path)) {
|
|
116
|
+
throw new Error('Not found file: ' + path);
|
|
117
|
+
}
|
|
118
|
+
const cliConfiguration = await (0, load_configuration_1.loadConfiguration)();
|
|
119
|
+
const sourceRoot = (0, path_1.join)(process.cwd(), cliConfiguration.sourceRoot);
|
|
120
|
+
const dbmlRaw = fs.readFileSync(path, 'utf-8');
|
|
121
|
+
const dbmlJson = JSON.parse(core_1.exporter.export(dbmlRaw, 'json'));
|
|
122
|
+
const relationsWithJoin = [];
|
|
123
|
+
const manyToManyTables = findManyToManyTables(dbmlJson);
|
|
124
|
+
const modules = findModules(Object.values(dbmlJson.tables));
|
|
125
|
+
modules.forEach((moduleName) => {
|
|
126
|
+
[
|
|
127
|
+
'',
|
|
128
|
+
'domain',
|
|
129
|
+
'domain/models',
|
|
130
|
+
'infrastructure',
|
|
131
|
+
'infrastructure/tables',
|
|
132
|
+
].forEach(relativeDir => {
|
|
133
|
+
const dirPath = (0, path_1.join)(sourceRoot, moduleName, relativeDir);
|
|
134
|
+
if (!fs.existsSync(dirPath)) {
|
|
135
|
+
fs.mkdirSync(dirPath);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
Object.values(dbmlJson.tables).forEach((table) => {
|
|
139
|
+
if (!table.name.startsWith(moduleName) || manyToManyTables.includes(table)) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const entityName = table.name;
|
|
143
|
+
const modelName = (0, lodash_1.upperFirst)((0, lodash_1.camelCase)(entityName)) + 'Model';
|
|
144
|
+
const tableName = (0, lodash_1.upperFirst)((0, lodash_1.camelCase)(entityName)) + 'Table';
|
|
145
|
+
const tableDescription = table.note;
|
|
146
|
+
const importedFields = [];
|
|
147
|
+
const modelFieldCodes = [];
|
|
148
|
+
const importedModels = [];
|
|
149
|
+
table.fieldIds.forEach(fieldId => {
|
|
150
|
+
const fieldName = dbmlJson.fields[fieldId].name;
|
|
151
|
+
const fieldLabel = dbmlJson.fields[fieldId].note || '';
|
|
152
|
+
let isVirtualField = false;
|
|
153
|
+
if (dbmlJson.fields[fieldId].endpointIds.length > 0) {
|
|
154
|
+
const fieldLeft = dbmlJson.fields[fieldId];
|
|
155
|
+
fieldLeft.endpointIds.forEach(endpointId => {
|
|
156
|
+
let { relationType, fieldRight } = determineRelation(dbmlJson, manyToManyTables, endpointId);
|
|
157
|
+
relationType = relationsMap[relationType];
|
|
158
|
+
const rightTable = dbmlJson.tables[fieldRight.tableId];
|
|
159
|
+
const baseRightName = (0, lodash_1.camelCase)(rightTable.name);
|
|
160
|
+
const modelRightName = (0, lodash_1.upperFirst)(baseRightName) + 'Model';
|
|
161
|
+
let fieldName = getRelationFieldName(baseRightName, relationType, fieldLeft.name, rightTable.name);
|
|
162
|
+
if (relationType === 'ManyToOne') {
|
|
163
|
+
isVirtualField = true;
|
|
164
|
+
}
|
|
165
|
+
let isOwningSide = false;
|
|
166
|
+
if ((relationType === 'OneToOne' && fieldName !== 'id')
|
|
167
|
+
|| (relationType === 'ManyToMany'
|
|
168
|
+
&& !relationsWithJoin.includes(`${fieldId} - ${fieldRight.id}`))) {
|
|
169
|
+
isOwningSide = true;
|
|
170
|
+
isVirtualField = true;
|
|
171
|
+
relationsWithJoin.push(`${fieldRight.id} - ${fieldId}`);
|
|
172
|
+
}
|
|
173
|
+
importedFields.push('RelationField');
|
|
174
|
+
if (rightTable.name !== table.name) {
|
|
175
|
+
const moduleToImport = (0, lodash_1.split)(rightTable.name, '_')[0];
|
|
176
|
+
importedModels.push({ model: modelRightName, module: moduleToImport });
|
|
177
|
+
}
|
|
178
|
+
modelFieldCodes.push((0, templates_1.templateModelRelation)(fieldLabel, relationType, isOwningSide, modelRightName, fieldName));
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
if (isVirtualField && !dbmlJson.fields[fieldId].pk) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const fieldType = getFieldType(fieldName, dbmlJson.fields[fieldId].type.type_name, dbmlJson.fields[fieldId].pk);
|
|
185
|
+
const fieldJsType = getFieldJsType(fieldType);
|
|
186
|
+
const decoratorName = (0, lodash_1.upperFirst)(fieldType) + 'Field';
|
|
187
|
+
importedFields.push(decoratorName);
|
|
188
|
+
modelFieldCodes.push((0, templates_1.templateModelField)(decoratorName, fieldLabel, fieldName, fieldJsType));
|
|
189
|
+
});
|
|
190
|
+
const modulesImports = (0, lodash_1.uniqWith)(importedModels, lodash_1.isEqual).reduce((code, importedModel) => {
|
|
191
|
+
let path = '';
|
|
192
|
+
if (importedModel.module === moduleName) {
|
|
193
|
+
path = `./${importedModel.model}`;
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
path = `../../../${importedModel.module}/domain/models/${importedModel.model}`;
|
|
197
|
+
}
|
|
198
|
+
code += `import { ${importedModel.model} } from '${path}';\n`;
|
|
199
|
+
return code;
|
|
200
|
+
}, '');
|
|
201
|
+
const modelCode = (0, templates_1.templateModel)(importedFields, modulesImports, tableDescription, modelName, modelFieldCodes);
|
|
202
|
+
const modelFilePath = (0, path_1.join)(sourceRoot, moduleName, `domain/models/${modelName}.ts`);
|
|
203
|
+
if (!fs.existsSync(modelFilePath)) {
|
|
204
|
+
CommandUtils_1.CommandUtils.createFile(modelFilePath, modelCode);
|
|
205
|
+
}
|
|
206
|
+
const tableCode = (0, templates_1.templateTable)(modelName, entityName, tableName);
|
|
207
|
+
const tableFilePath = (0, path_1.join)(sourceRoot, moduleName, `infrastructure/tables/${tableName}.ts`);
|
|
208
|
+
if (!fs.existsSync(tableFilePath)) {
|
|
209
|
+
CommandUtils_1.CommandUtils.createFile(tableFilePath, tableCode);
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
exports.dbml2code = dbml2code;
|
|
215
|
+
//# sourceMappingURL=dbml2code.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dbml2code.js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AC;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"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function templateModel(importedFields: any, modulesImports: any, tableDescription: any, modelName: any, modelFieldCodes: any): string;
|
|
2
|
+
export declare function templateModelField(decoratorName: any, fieldLabel: any, fieldName: any, fieldJsType: any): string;
|
|
3
|
+
export declare function templateModelRelation(fieldLabel: any, relationType: any, isOwningSide: any, modelRightName: any, fieldName: any): string;
|
|
4
|
+
export declare function templateTable(modelName: any, entityName: any, tableName: any): string;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.templateTable = exports.templateModelRelation = exports.templateModelField = exports.templateModel = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
function templateModel(importedFields, modulesImports, tableDescription, modelName, modelFieldCodes) {
|
|
6
|
+
return `import {
|
|
7
|
+
${(0, lodash_1.uniq)(importedFields).map(line => ' ' + line).join(',\n')},
|
|
8
|
+
} from '@steroidsjs/nest/infrastructure/decorators/fields';
|
|
9
|
+
${modulesImports}
|
|
10
|
+
/**
|
|
11
|
+
* ${tableDescription}
|
|
12
|
+
*/
|
|
13
|
+
export class ${modelName} {
|
|
14
|
+
${modelFieldCodes.join('\n\n')}
|
|
15
|
+
}
|
|
16
|
+
`;
|
|
17
|
+
}
|
|
18
|
+
exports.templateModel = templateModel;
|
|
19
|
+
function templateModelField(decoratorName, fieldLabel, fieldName, fieldJsType) {
|
|
20
|
+
return ` @${decoratorName}({
|
|
21
|
+
label: '${fieldLabel}',
|
|
22
|
+
})
|
|
23
|
+
${fieldName}: ${fieldJsType};`;
|
|
24
|
+
}
|
|
25
|
+
exports.templateModelField = templateModelField;
|
|
26
|
+
function templateModelRelation(fieldLabel, relationType, isOwningSide, modelRightName, fieldName) {
|
|
27
|
+
return ` @RelationField({
|
|
28
|
+
label: '${fieldLabel}',
|
|
29
|
+
type: '${relationType}',
|
|
30
|
+
isOwningSide: ${isOwningSide},
|
|
31
|
+
modelClass: () => ${modelRightName},
|
|
32
|
+
})
|
|
33
|
+
${fieldName}: ${modelRightName}${relationType.endsWith('Many') ? '[]' : ''};`;
|
|
34
|
+
}
|
|
35
|
+
exports.templateModelRelation = templateModelRelation;
|
|
36
|
+
function templateTable(modelName, entityName, tableName) {
|
|
37
|
+
return `import {TableFromModel} from '@steroidsjs/nest/infrastructure/decorators/TableFromModel';
|
|
38
|
+
import {DeepPartial} from 'typeorm';
|
|
39
|
+
import {${modelName}} from '../../domain/models/${modelName}';
|
|
40
|
+
|
|
41
|
+
@TableFromModel(${modelName}, '${entityName}')
|
|
42
|
+
export class ${tableName} implements DeepPartial<${modelName}> {}
|
|
43
|
+
`;
|
|
44
|
+
}
|
|
45
|
+
exports.templateTable = templateTable;
|
|
46
|
+
//# sourceMappingURL=templates.js.map
|
|
@@ -0,0 +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;;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,17 @@ 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
|
-
const
|
|
99
|
-
console.log('info', '\t' +
|
|
100
|
-
await CommandUtils_1.CommandUtils.createFile(
|
|
104
|
+
const tableDeclarationFileContent = getTemplate(tableClassName, timestamp, migrationsByTables[tableName].upQueries.filter(query => query.includes('CREATE TABLE')), migrationsByTables[tableName].downQueries.filter(query => query.includes('DROP TABLE')).reverse());
|
|
105
|
+
const tableDeclarationFileName = timestamp + '-' + tableClassName + '.ts';
|
|
106
|
+
const tableDeclarationFilePath = (0, path_1.join)(moduleDir, '/infrastructure/migrations', tableDeclarationFileName);
|
|
107
|
+
console.log('info', '\t' + tableDeclarationFilePath);
|
|
108
|
+
await CommandUtils_1.CommandUtils.createFile(tableDeclarationFilePath, tableDeclarationFileContent);
|
|
109
|
+
const nextTimestamp = timestamp + 1;
|
|
110
|
+
const foreignKeysFileContent = getTemplate(tableClassName, nextTimestamp, migrationsByTables[tableName].upQueries.filter(query => !query.includes('CREATE TABLE')), migrationsByTables[tableName].downQueries.filter(query => !query.includes('DROP TABLE')).reverse());
|
|
111
|
+
const foreignKeysFileName = nextTimestamp + '-' + tableClassName + '.ts';
|
|
112
|
+
const foreignKeysFilePath = (0, path_1.join)(moduleDir, '/infrastructure/migrations', foreignKeysFileName);
|
|
113
|
+
console.log('info', '\t' + foreignKeysFilePath);
|
|
114
|
+
await CommandUtils_1.CommandUtils.createFile(foreignKeysFilePath, foreignKeysFileContent);
|
|
101
115
|
}
|
|
102
116
|
}
|
|
103
117
|
};
|
|
@@ -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,yE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AAE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,EACxF,kBAAkB,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,OAAO,EAAE,CACrG,CAAC;YACF,MAAM,mBAAmB,GAAG,aAAa,GAAG,GAAG,GAAG,cAAc,GAAG,KAAK,CAAC;YACzE,MAAM,mBAAmB,GAAG,IAAA,WAAI,EAAC,SAAS,EAAE,4BAA4B,EAAE,mBAAmB,CAAC,CAAC;YAG/F,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,GAAG,mBAAmB,CAAC,CAAC;YAChD,MAAM,2BAAY,CAAC,UAAU,CAAC,mBAAmB,EAAE,sBAAsB,CAAC,CAAC;SAC9E;KACJ;AACL,CAAC,CAAA;AAlHY,QAAA,QAAQ,YAkHpB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface ITableOptions {
|
|
2
|
+
name: string;
|
|
3
|
+
label?: string;
|
|
4
|
+
modelClass?: any;
|
|
5
|
+
}
|
|
6
|
+
export declare function TableFromModel(ModelClass: any, tableName: any): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TableFromModel = void 0;
|
|
4
|
+
const typeorm_1 = require("typeorm");
|
|
5
|
+
const DataMapperHelper_1 = require("../../usecases/helpers/DataMapperHelper");
|
|
6
|
+
const ExtendField_1 = require("./fields/ExtendField");
|
|
7
|
+
const common_1 = require("@nestjs/common");
|
|
8
|
+
function TableFromModelInternal(ModelClass) {
|
|
9
|
+
return (target) => {
|
|
10
|
+
const fields = DataMapperHelper_1.DataMapperHelper.getKeys(ModelClass);
|
|
11
|
+
fields.forEach(field => {
|
|
12
|
+
(0, ExtendField_1.ExtendField)(ModelClass)(target.prototype, field);
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function TableFromModel(ModelClass, tableName) {
|
|
17
|
+
return (0, common_1.applyDecorators)((0, typeorm_1.Entity)(tableName), TableFromModelInternal(ModelClass));
|
|
18
|
+
}
|
|
19
|
+
exports.TableFromModel = TableFromModel;
|
|
20
|
+
//# sourceMappingURL=TableFromModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableFromModel.js","sourceRoot":"","sources":["../../../src/infrastructure/decorators/TableFromModel.ts"],"names":[],"mappings":";;;AAAA,qCAA4C;AAC5C,8EAAyE;AACzE,sDAAiD;AAGjD,2CAA+C;AAkC/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;AAGD,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,6 +1,6 @@
|
|
|
1
1
|
export { BooleanField } from './BooleanField';
|
|
2
|
-
export { CreateTimeField } from './CreateTimeField';
|
|
3
2
|
export { CoordinateField } from './CoordinateField';
|
|
3
|
+
export { CreateTimeField } from './CreateTimeField';
|
|
4
4
|
export { DateField } from './DateField';
|
|
5
5
|
export { DateTimeField } from './DateTimeField';
|
|
6
6
|
export { DecimalField } from './DecimalField';
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RelationField = exports.UpdateTimeField = exports.UidField = exports.TimeField = exports.TextField = exports.StringField = exports.PrimaryKeyField = exports.PhoneField = exports.PasswordField = exports.IntegerField = exports.HtmlField = exports.FileField = exports.EnumField = exports.EmailField = exports.DecimalField = exports.DateTimeField = exports.DateField = exports.
|
|
3
|
+
exports.RelationField = exports.UpdateTimeField = exports.UidField = exports.TimeField = exports.TextField = exports.StringField = exports.PrimaryKeyField = exports.PhoneField = exports.PasswordField = exports.IntegerField = exports.HtmlField = exports.FileField = exports.EnumField = exports.EmailField = exports.DecimalField = exports.DateTimeField = exports.DateField = exports.CreateTimeField = exports.CoordinateField = exports.BooleanField = void 0;
|
|
4
4
|
var BooleanField_1 = require("./BooleanField");
|
|
5
5
|
Object.defineProperty(exports, "BooleanField", { enumerable: true, get: function () { return BooleanField_1.BooleanField; } });
|
|
6
|
-
var CreateTimeField_1 = require("./CreateTimeField");
|
|
7
|
-
Object.defineProperty(exports, "CreateTimeField", { enumerable: true, get: function () { return CreateTimeField_1.CreateTimeField; } });
|
|
8
6
|
var CoordinateField_1 = require("./CoordinateField");
|
|
9
7
|
Object.defineProperty(exports, "CoordinateField", { enumerable: true, get: function () { return CoordinateField_1.CoordinateField; } });
|
|
8
|
+
var CreateTimeField_1 = require("./CreateTimeField");
|
|
9
|
+
Object.defineProperty(exports, "CreateTimeField", { enumerable: true, get: function () { return CreateTimeField_1.CreateTimeField; } });
|
|
10
10
|
var DateField_1 = require("./DateField");
|
|
11
11
|
Object.defineProperty(exports, "DateField", { enumerable: true, get: function () { return DateField_1.DateField; } });
|
|
12
12
|
var DateTimeField_1 = require("./DateTimeField");
|
|
@@ -5,9 +5,9 @@ import { ICondition } from '../helpers/ConditionHelper';
|
|
|
5
5
|
import { SearchResultDto } from '../../usecases/dtos/SearchResultDto';
|
|
6
6
|
export declare class CrudRepository<TModel> implements ICrudRepository<TModel> {
|
|
7
7
|
primaryKey: string;
|
|
8
|
-
dbRepository: Repository<
|
|
8
|
+
dbRepository: Repository<any>;
|
|
9
9
|
protected modelClass: any;
|
|
10
|
-
init(dbRepository: Repository<
|
|
10
|
+
init(dbRepository: Repository<any>, modelClass: any): void;
|
|
11
11
|
search(dto: SearchInputDto): Promise<SearchResultDto<TModel>>;
|
|
12
12
|
findOne(condition: ICondition): Promise<TModel>;
|
|
13
13
|
create(model: TModel): Promise<TModel>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CrudRepository.js","sourceRoot":"","sources":["../../../src/infrastructure/repositories/CrudRepository.ts"],"names":[],"mappings":";;;AACA,yDAAkD;AAClD,sEAAiE;AAGjE,gEAAuE;AAMvE,MAAa,cAAc;IAA3B;QAIW,eAAU,GAAW,IAAI,CAAC;IA6FrC,CAAC;IA/EU,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"CrudRepository.js","sourceRoot":"","sources":["../../../src/infrastructure/repositories/CrudRepository.ts"],"names":[],"mappings":";;;AACA,yDAAkD;AAClD,sEAAiE;AAGjE,gEAAuE;AAMvE,MAAa,cAAc;IAA3B;QAIW,eAAU,GAAW,IAAI,CAAC;IA6FrC,CAAC;IA/EU,IAAI,CAAC,YAA6B,EAAE,UAAe;QACtD,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IACjC,CAAC;IAMD,KAAK,CAAC,MAAM,CAAC,GAAmB;QAC5B,MAAM,MAAM,GAAG,MAAM,2BAAY,CAAC,MAAM,CAAS,IAAI,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;QACzE,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;QAClE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I,UAAU,EAAE,CAAC;QAC/B,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,IAAA,mCAAe,EAAC,GAAG,CAAC,CAAC,CAAC;QAE3C,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ;AAjGD,wCAiGC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steroidsjs/nest",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "tsc && copyfiles ./{package.json,LICENSE,README.md} dist/"
|
|
6
6
|
},
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"url": "https://github.com/steroids/nest/issues"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
+
"@dbml/core": "^2.3.1",
|
|
20
21
|
"@nestjs/cli": "^8.1.6",
|
|
21
22
|
"@nestjs/common": "^8.0.0",
|
|
22
23
|
"@nestjs/config": "^1.1.5",
|
|
@@ -29,6 +30,8 @@
|
|
|
29
30
|
"express": "^4.17.2",
|
|
30
31
|
"lodash": "^4.17.21",
|
|
31
32
|
"nestjs-command": "^3.1.1",
|
|
33
|
+
"pluralize": "^8.0.0",
|
|
34
|
+
"typedi": "^0.10.0",
|
|
32
35
|
"typeorm": "^0.2.41",
|
|
33
36
|
"uuid": "^8.3.2"
|
|
34
37
|
},
|