/**
 * Entity Linting Service
 *
 * Schema-aware completeness checking — identifies entities with missing
 * recommended fields.
 */
/**
 * Recommended fields per entity type.
 * These are fields that should typically be present but aren't Zod-required.
 */
export const RECOMMENDED_FIELDS = {
    project: ['client', 'start_date', 'date', 'status', 'services'],
    event: ['attendees', 'project'],
    task: ['assignee', 'date', 'status'],
    deliverable: ['project', 'date'],
    deal: ['deal_value', 'date', 'client'],
    person: ['organization', 'email', 'category'],
    position: ['department', 'category', 'status'],
    'case-study': ['client', 'date_range', 'services', 'status'],
    service: ['sprint', 'status', 'deliverables'],
};
/**
 * Lint all entities in the workspace for missing recommended fields.
 * Returns a list of issues grouped by entity.
 */
export async function lintWorkspace(manager, filters) {
    const issues = [];
    // Get repos to scan (filtered or all)
    const allRepos = manager.getContentRepoConfigs();
    const repos = filters?.repo
        ? allRepos.filter(r => r.name === filters.repo)
        : allRepos;
    // Get entity types to check (filtered or all)
    const entityTypes = filters?.entityType
        ? [filters.entityType]
        : Object.keys(RECOMMENDED_FIELDS);
    for (const repoConfig of repos) {
        let graph;
        try {
            graph = manager.getGraph(repoConfig.name);
        }
        catch {
            // Repo not initialized on disk — skip
            continue;
        }
        for (const entityType of entityTypes) {
            try {
                const entityFiles = await graph.list(entityType);
                for (const entityFile of entityFiles) {
                    const recommended = RECOMMENDED_FIELDS[entityType];
                    if (!recommended)
                        continue;
                    const entityData = entityFile.data;
                    const missing = recommended.filter(field => {
                        const value = entityData[field];
                        return value === undefined || value === null || value === '';
                    });
                    if (missing.length > 0) {
                        issues.push({
                            repo: repoConfig.name,
                            entityType,
                            entityId: entityFile.id,
                            missingFields: missing,
                        });
                    }
                }
            }
            catch (err) {
                // Entity type might not exist in this repo — skip
                continue;
            }
        }
    }
    return issues;
}
//# sourceMappingURL=lint-service.js.map