fix: review import templates #33
@@ -200,7 +200,9 @@ export function generateCleanArchitecture(
|
||||
|
||||
// Generar por cada Tag
|
||||
Object.keys(tagsMap).forEach((tag) => {
|
||||
const imports: { classname: string; classFilename: string; classVarName: string }[] = [];
|
||||
const returnImports: { classname: string; classFilename: string; classVarName: string }[] = [];
|
||||
const paramImports: { classname: string; classFilename: string; classVarName: string }[] = [];
|
||||
|
||||
Object.keys(schemas).forEach((s) => {
|
||||
const usedAsReturn = tagsMap[tag].some(
|
||||
(op) => op.returnType === s || op.returnType === `${s}[]`
|
||||
@@ -208,12 +210,14 @@ export function generateCleanArchitecture(
|
||||
const usedAsParam = tagsMap[tag].some((op) =>
|
||||
op.allParams.some((p) => p.dataType === s || p.dataType === `${s}[]`)
|
||||
);
|
||||
if (usedAsReturn || usedAsParam) {
|
||||
imports.push({
|
||||
classname: s,
|
||||
classFilename: toCamelCase(s),
|
||||
classVarName: toCamelCase(s)
|
||||
});
|
||||
|
||||
const entry = { classname: s, classFilename: toCamelCase(s), classVarName: toCamelCase(s) };
|
||||
|
||||
if (usedAsReturn) {
|
||||
returnImports.push(entry);
|
||||
} else if (usedAsParam) {
|
||||
// Param-only types: entity import needed for method signatures, but no Dto or Mapper
|
||||
paramImports.push(entry);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -227,7 +231,12 @@ export function generateCleanArchitecture(
|
||||
classVarName: toCamelCase(tag),
|
||||
constantName: tag.toUpperCase().replace(/[^A-Z0-9]/g, '_'),
|
||||
operation: tagsMap[tag],
|
||||
imports: imports
|
||||
// All entity imports (return + param) — for contracts and use-cases
|
||||
imports: [...returnImports, ...paramImports],
|
||||
// Return-type-only imports — for repo impl (Dto + Entity + Mapper)
|
||||
returnImports,
|
||||
// Param-only imports — for repo impl (Entity only, no Dto/Mapper)
|
||||
paramImports
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -10,11 +10,14 @@ import { environment } from '@environment';
|
||||
import { MRepository } from '@mercadona/core/utils/repository';
|
||||
|
||||
import { {{classname}}Repository } from '@/domain/repositories/{{classFilename}}.repository.contract';
|
||||
{{#imports}}
|
||||
{{#returnImports}}
|
||||
import { {{classname}}Dto } from '@/dtos/{{classFilename}}.dto';
|
||||
import { {{classname}} } from '@/entities/models/{{classFilename}}.model';
|
||||
import { {{classVarName}}Mapper } from '@/mappers/{{classFilename}}.mapper';
|
||||
{{/imports}}
|
||||
{{/returnImports}}
|
||||
{{#paramImports}}
|
||||
import { {{classname}} } from '@/entities/models/{{classFilename}}.model';
|
||||
{{/paramImports}}
|
||||
|
||||
/**
|
||||
* {{classname}} Repository Implementation
|
||||
|
||||
Reference in New Issue
Block a user