import type { LintDiagnostic } from '../diagnostic.js' import type { DomainProject } from '../project.js' import { importedCalls } from '../source.js' import { analyzerDiagnostic, type AnalyzerRule } from './project-rule.js' const schemaModules = new Set(['@astrale-os/kernel-core', '@astrale-os/kernel-dsl']) const memberConstructors = new Set([ 'edgeClass', 'edgeInterface', 'fn', 'func', 'nodeClass', 'nodeInterface', ]) export const thinSchemaCompositionRoot: AnalyzerRule = { slug: 'thin-schema-composition-root', analyze(project: DomainProject): readonly LintDiagnostic[] { const root = project.files.find((file) => file.relativePath === 'schema/index.ts') if (!root) return [] return importedCalls(root, schemaModules, memberConstructors) .map((token) => analyzerDiagnostic(this.slug, root, token, `Found ${token.value}().`)) .filter((diagnostic): diagnostic is LintDiagnostic => diagnostic !== undefined) }, }