jarvis-arch-hexagonal-gen 1.0.14 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core/parser.js
CHANGED
|
@@ -9,11 +9,15 @@ function parseEntity(entityName, options = {}) {
|
|
|
9
9
|
const route = pluralLower;
|
|
10
10
|
const table = `tb_${pluralLower}`;
|
|
11
11
|
// Colunas podem vir das opções ou de um schema
|
|
12
|
-
|
|
12
|
+
let columns = options.columns || [
|
|
13
13
|
{ name: 'id', type: 'number', primary: true },
|
|
14
14
|
{ name: 'name', type: 'string' },
|
|
15
15
|
{ name: 'createdAt', type: 'Date' },
|
|
16
16
|
{ name: 'updatedAt', type: 'Date' },
|
|
17
17
|
];
|
|
18
|
+
columns = columns.map((col) => ({
|
|
19
|
+
...col,
|
|
20
|
+
dbName: col.name.replace(/([A-Z])/g, '_$1').toLowerCase()
|
|
21
|
+
}));
|
|
18
22
|
return { entity, entityName: entity, entityLower, plural, pluralLower, route, table, columns };
|
|
19
23
|
}
|
|
@@ -6,19 +6,15 @@ import {
|
|
|
6
6
|
UpdateDateColumn
|
|
7
7
|
} from 'typeorm';
|
|
8
8
|
|
|
9
|
-
// Função auxiliar para converter camelCase para snake_case
|
|
10
|
-
function toSnakeCase(str) {
|
|
11
|
-
return str.replace(/([A-Z])/g, '_$1').toLowerCase();
|
|
12
|
-
}
|
|
13
|
-
|
|
14
9
|
@Entity({ name: 'tb_<%= pluralLower %>' })
|
|
15
10
|
export class <%= entity %> {
|
|
11
|
+
|
|
16
12
|
@PrimaryGeneratedColumn()
|
|
17
13
|
id: number;
|
|
18
14
|
|
|
19
15
|
<% columns.forEach(column => { %>
|
|
20
16
|
@Column({
|
|
21
|
-
name: '<%=
|
|
17
|
+
name: '<%= column.dbName %>',
|
|
22
18
|
type: '<%= column.type === 'number' ? 'int' : 'varchar' %>'<%= column.type === 'string' ? ', length: 255' : '' %>
|
|
23
19
|
})
|
|
24
20
|
<%= column.name %>: <%= column.type %>;
|