Spaces:
Paused
Paused
Download apps/prevision-api/src/catalog/admin-catalog.ts from modventures/prevision: direct link, hf CLI and curl.
- Browser
- Download file 1.06 kB
-
https://huggingface.co/spaces/modventures/prevision/resolve/main/apps/prevision-api/src/catalog/admin-catalog.ts
- Command line
-
hf download hf://spaces/modventures/prevision/apps/prevision-api/src/catalog/admin-catalog.ts
-
curl -L -o admin-catalog.ts https://huggingface.co/spaces/modventures/prevision/resolve/main/apps/prevision-api/src/catalog/admin-catalog.ts
1.06 kB
| 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<string>(); | |
| 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; | |
| } | |