import type { CatalogEntry } from './interfaces/catalog-entry.interface.js'; /** * Checks an admin-only supplier catalog before it is imported: every entry must be * `visibility: "admin"`, and no slug may collide with the public catalog (an upsert * would otherwise turn a public tile into a hidden one, or the other way round). */ export function adminCatalogProblems(entries: CatalogEntry[], publicCatalog: CatalogEntry[]): string[] { const publicSlugs = new Set(publicCatalog.map((entry) => entry.slug)); const seen = new Set(); const problems: string[] = []; for (const entry of entries) { if (entry.visibility !== 'admin') problems.push(`${entry.slug}: visibility must be "admin"`); if (publicSlugs.has(entry.slug)) problems.push(`${entry.slug}: slug is already in the public catalog`); if (seen.has(entry.slug)) problems.push(`${entry.slug}: duplicate slug`); if (!entry.brand || !entry.organization) problems.push(`${entry.slug}: brand and organization are required`); seen.add(entry.slug); } return problems; }