import type { EntityKind } from "@prisma/client"; export type KindInfo = { kind: EntityKind; slug: string; color: string; // world = berättelsens värld, register = stödregister (fordon, research, skisser ...) group: "world" | "register"; }; // Ordningen styr menyer och översikt. export const KINDS: KindInfo[] = [ { kind: "CHARACTER", slug: "characters", color: "blue", group: "world" }, { kind: "PET", slug: "pets", color: "orange", group: "world" }, { kind: "HOME", slug: "homes", color: "green", group: "world" }, { kind: "PLACE", slug: "places", color: "red", group: "world" }, { kind: "COMPANY", slug: "companies", color: "purple", group: "world" }, { kind: "PREMISES", slug: "premises", color: "teal", group: "world" }, { kind: "EDUCATION", slug: "education", color: "cyan", group: "world" }, { kind: "SCENARIO", slug: "scenarios", color: "pink", group: "world" }, { kind: "VEHICLE", slug: "vehicles", color: "indigo", group: "register" }, { kind: "SKETCH", slug: "sketches", color: "azure", group: "register" }, { kind: "RESEARCH", slug: "research", color: "lime", group: "register" }, { kind: "REFERENCE", slug: "references", color: "yellow", group: "register" }, { kind: "APP", slug: "apps", color: "dark", group: "register" }, { kind: "WEBSITE", slug: "websites", color: "secondary", group: "register" }, ]; export const KIND_BY_SLUG = new Map(KINDS.map((k) => [k.slug, k])); export const KIND_INFO = Object.fromEntries(KINDS.map((k) => [k.kind, k])) as Record; export function parseKind(value: unknown): EntityKind | null { return typeof value === "string" && value in KIND_INFO ? (value as EntityKind) : null; } // Mallar finns för alla typer och dessutom för relationer. export type TemplateKind = EntityKind | "RELATION"; export const RELATION_SLUG = "relations"; export function parseTemplateKind(value: unknown): TemplateKind | null { return value === "RELATION" ? "RELATION" : parseKind(value); } export function templateSlug(kind: TemplateKind): string { return kind === "RELATION" ? RELATION_SLUG : KIND_INFO[kind].slug; } export function templateKindFromSlug(slug: string): TemplateKind | null { return slug === RELATION_SLUG ? "RELATION" : (KIND_BY_SLUG.get(slug)?.kind ?? null); } // Typer som kan ha arbetsplats i scheman export const WORKPLACE_KINDS: EntityKind[] = ["COMPANY", "PREMISES", "PLACE", "EDUCATION"]; export const MARKER_COLORS: Record = { blue: "#206bc4", red: "#d63939", green: "#2fb344", orange: "#f76707", purple: "#ae3ec9", pink: "#d6336c", teal: "#0ca678", yellow: "#f59f00", };