UNPKG

@samiyev/guardian

Version:

Research-backed code quality guardian for AI-assisted development. Detects hardcodes, secrets, circular deps, framework leaks, entity exposure, and 9 architecture violations. Enforces Clean Architecture/DDD principles. Works with GitHub Copilot, Cursor, W

69 lines 2.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.OrmTypeMatcher = void 0; const orm_methods_1 = require("../constants/orm-methods"); const Messages_1 = require("../../domain/constants/Messages"); /** * Matches and validates ORM-specific types and patterns * * Identifies ORM-specific types (Prisma, TypeORM, Mongoose, etc.) * that should not appear in domain layer repository interfaces. */ class OrmTypeMatcher { ormTypePatterns = [ /Prisma\./, /PrismaClient/, /TypeORM/, /@Entity/, /@Column/, /@PrimaryColumn/, /@PrimaryGeneratedColumn/, /@ManyToOne/, /@OneToMany/, /@ManyToMany/, /@JoinColumn/, /@JoinTable/, /Mongoose\./, /Schema/, /Model</, /Document/, /Sequelize\./, /DataTypes\./, /FindOptions/, /WhereOptions/, /IncludeOptions/, /QueryInterface/, /MikroORM/, /EntityManager/, /EntityRepository/, /Collection</, ]; /** * Checks if a type name is an ORM-specific type */ isOrmType(typeName) { return this.ormTypePatterns.some((pattern) => pattern.test(typeName)); } /** * Extracts ORM type name from a code line */ extractOrmType(line) { for (const pattern of this.ormTypePatterns) { const match = line.match(pattern); if (match) { const startIdx = match.index || 0; const typeMatch = /[\w.]+/.exec(line.slice(startIdx)); return typeMatch ? typeMatch[0] : Messages_1.REPOSITORY_PATTERN_MESSAGES.UNKNOWN_TYPE; } } return Messages_1.REPOSITORY_PATTERN_MESSAGES.UNKNOWN_TYPE; } /** * Checks if a method name is a technical ORM method */ isTechnicalMethod(methodName) { return orm_methods_1.ORM_QUERY_METHODS.includes(methodName); } } exports.OrmTypeMatcher = OrmTypeMatcher; //# sourceMappingURL=OrmTypeMatcher.js.map