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

71 lines 1.99 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SourceFile = void 0; const BaseEntity_1 = require("./BaseEntity"); const rules_1 = require("../../shared/constants/rules"); /** * Represents a source code file in the analyzed project */ class SourceFile extends BaseEntity_1.BaseEntity { _path; _content; _imports; _exports; _layer; constructor(path, content, imports = [], exports = [], id) { super(id); this._path = path; this._content = content; this._imports = imports; this._exports = exports; this._layer = this.detectLayer(); } get path() { return this._path; } get content() { return this._content; } get imports() { return [...this._imports]; } get exports() { return [...this._exports]; } get layer() { return this._layer; } addImport(importPath) { if (!this._imports.includes(importPath)) { this._imports.push(importPath); this.touch(); } } addExport(exportName) { if (!this._exports.includes(exportName)) { this._exports.push(exportName); this.touch(); } } detectLayer() { const dir = this._path.directory.toLowerCase(); if (dir.includes(rules_1.LAYERS.DOMAIN)) { return rules_1.LAYERS.DOMAIN; } if (dir.includes(rules_1.LAYERS.APPLICATION)) { return rules_1.LAYERS.APPLICATION; } if (dir.includes(rules_1.LAYERS.INFRASTRUCTURE)) { return rules_1.LAYERS.INFRASTRUCTURE; } if (dir.includes(rules_1.LAYERS.SHARED)) { return rules_1.LAYERS.SHARED; } return undefined; } importsFrom(layer) { return this._imports.some((imp) => imp.toLowerCase().includes(layer)); } } exports.SourceFile = SourceFile; //# sourceMappingURL=SourceFile.js.map