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.
@@ -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
- const columns = options.columns || [
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
  }
@@ -5,7 +5,7 @@
5
5
  "files": [
6
6
  {
7
7
  "template": "entity.ejs",
8
- "output": "src/adapters/outbound/entities/persistence/typeorm/<%= entity %>.entity.ts"
8
+ "output": "src/adapters/outbound/persistence/typeorm/entities/<%= entityLower %>.entity.ts"
9
9
  }
10
10
  ],
11
11
  "hooks": {}
@@ -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: '<%= toSnakeCase(column.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 %>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jarvis-arch-hexagonal-gen",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "description": "Gerador de recursos para projetos Node.js com TypeScript",
5
5
  "keywords": [
6
6
  "Arquitetura Hexagonal",