Loading...
Loading...
Review Vendure entities for missing VendureEntity inheritance, improper decorators, missing migrations, index violations, and TypeORM anti-patterns. Use when reviewing entity PRs or auditing data models.
npx skill4agent add meriley/claude-code-skills vendure-entity-reviewing# Find entity files
find . -name "*.entity.ts"
# Find migration files
find . -name "*migration*.ts" -o -name "*Migration*.ts"# === CRITICAL VIOLATIONS ===
# Not extending VendureEntity
grep -rn "export class.*Entity" --include="*.entity.ts" | grep -v "extends VendureEntity"
# Missing @Entity decorator
grep -rn "export class.*Entity" --include="*.entity.ts" | grep -v "@Entity"
# Direct repository injection (should use TransactionalConnection)
grep -rn "@InjectRepository" --include="*.service.ts"
# === HIGH PRIORITY ===
# Missing indexes on foreign keys
grep -rn "@ManyToOne\|@OneToMany" --include="*.entity.ts" -B 2 | grep -v "@Index"
# Missing DeepPartial constructor
grep -rn "export class.*extends VendureEntity" --include="*.entity.ts" -A 5 | grep -v "DeepPartial"
# Using 'any' type
grep -rn ": any" --include="*.entity.ts"
# === MEDIUM PRIORITY ===
# Missing nullable specification
grep -rn "@Column()" --include="*.entity.ts" | head -20
# Date stored as string (should be timestamp)
grep -rn "type: 'varchar'.*[dD]ate\|[dD]ate.*type: 'varchar'" --include="*.entity.ts"@Entity()
export class MyEntity {
// Missing extends!
@PrimaryGeneratedColumn()
id: number;
}@Entity()
export class MyEntity extends VendureEntity {
constructor(input?: DeepPartial<MyEntity>) {
super(input);
}
}@ManyToOne(() => Product)
product: Product;
@Column()
productId: number; // No index!@Index()
@ManyToOne(() => Product)
product: Product;
@Column()
productId: number;@Injectable()
export class MyService {
constructor(
@InjectRepository(MyEntity) // WRONG
private repo: Repository<MyEntity>,
) {}
}@Injectable()
export class MyService {
constructor(
private connection: TransactionalConnection, // CORRECT
) {}
async find(ctx: RequestContext) {
return this.connection.getRepository(ctx, MyEntity).find();
}
}@Entity()
export class MyEntity extends VendureEntity {
@Column()
name: string;
// No constructor!
}@Entity()
export class MyEntity extends VendureEntity {
constructor(input?: DeepPartial<MyEntity>) {
super(input);
}
@Column()
name: string;
}@Column({ type: 'simple-json' })
metadata: any; // No type safety!interface MyMetadata {
key: string;
value: number;
}
@Column({ type: 'simple-json', nullable: true })
metadata: MyMetadata | null;# All-in-one entity audit
echo "=== CRITICAL: Not extending VendureEntity ===" && \
grep -rn "export class.*Entity" --include="*.entity.ts" | grep -v "extends VendureEntity" && \
echo "" && \
echo "=== HIGH: Missing @Index ===" && \
grep -rn "@ManyToOne" --include="*.entity.ts" -B 2 | grep -v "@Index" && \
echo "" && \
echo "=== MEDIUM: Using any ===" && \
grep -rn ": any" --include="*.entity.ts"## Entity Review: [Entity Name]
### Summary
[Overview of entity quality]
### Critical Issues (Must Fix)
- [ ] [Issue] - `file:line`
### High Priority
- [ ] [Issue] - `file:line`
### Passed Checks
- [x] Extends VendureEntity
- [x] @Entity decorator present
- [x] Migration exists
### Recommendations
- [Suggestions]