// ─── Value objects ────────────────────────────────────────────────────────────
/**
 * Registry of all supported master-data domains.
 * ALL SQL table names are resolved from this map — never from user input.
 */
export const DOMAIN_REGISTRY = new Map([
    ["country", { table: "master.mst_country", hierarchical: false }],
    ["company", { table: "master.mst_company", hierarchical: false }],
    ["organisation", { table: "master.mst_organisation", hierarchical: false }],
    ["business-unit", { table: "master.mst_business_unit", hierarchical: false }],
    ["department", { table: "master.mst_department", hierarchical: false }],
    ["entity", { table: "master.mst_entity", hierarchical: false }],
    ["area", { table: "master.mst_area", hierarchical: true, extraCols: ["parent_id", "path", "depth", "area_type"] }],
    ["incident-type", { table: "master.mst_incident_type", hierarchical: false, extraCols: ["group_id"] }],
    ["incident-group", { table: "master.mst_incident_group", hierarchical: false }],
    ["incident-sub-type", { table: "master.mst_incident_sub_type", hierarchical: false }],
    ["person-role-type", { table: "master.mst_person_role_type", hierarchical: false, noAuditCols: true, noUpdatedAt: true }],
    ["suggestion-group", { table: "master.mst_suggestion_group", hierarchical: false }],
    ["priority", { table: "master.mst_priority", hierarchical: false, nameCol: "label", noAuditCols: true }],
    ["severity", { table: "master.mst_severity", hierarchical: false, nameCol: "label", noAuditCols: true }],
    ["likelihood", { table: "master.mst_likelihood", hierarchical: false, nameCol: "label", noAuditCols: true }],
    ["uom", { table: "master.mst_uom", hierarchical: false, noAuditCols: true }],
    ["currency", { table: "master.mst_currency", hierarchical: false, noAuditCols: true }],
    ["speciality", { table: "master.mst_speciality", hierarchical: false, noAuditCols: true }],
    ["root-cause-category", { table: "master.mst_root_cause_category", hierarchical: false, nameCol: "label", noAuditCols: true }],
    ["symptoms", { table: "master.mst_symptoms", hierarchical: false }],
    ["modules", { table: "master.mst_modules", hierarchical: false }],
    ["answer-type", { table: "master.mst_answer_type", hierarchical: false, noAuditCols: true, noIsActive: true }],
]);
export function resolveDomain(domain) {
    const cfg = DOMAIN_REGISTRY.get(domain);
    if (!cfg) {
        const validDomains = [...DOMAIN_REGISTRY.keys()].join(", ");
        throw new Error(`Unknown master-data domain "${domain}". Valid domains: ${validDomains}`);
    }
    return cfg;
}
