// engine/spec-types-loader.ts — Extensible SpecType loader (SPEC-216)
//
// Loads spec type definitions from src/config/spec-types.json via ConfigLoader,
// allowing organizations to add custom types via data/global/spec-types-custom.json
// or per-project via data/projects/{hash}/config/spec-types-overrides.json.
import { z } from 'zod';
import { ConfigLoader } from './config-loader.js';
// ---------------------------------------------------------------------------
// Config schema
// ---------------------------------------------------------------------------
const SpecTypeConfigSchema = z.object({
    id: z.string(),
    label: z.string(),
    description: z.string(),
});
const SpecTypeConfigArraySchema = z.array(SpecTypeConfigSchema);
// ---------------------------------------------------------------------------
// Loader
// ---------------------------------------------------------------------------
const loader = new ConfigLoader('spec-types', SpecTypeConfigArraySchema);
/**
 * Returns all spec type ids for an optional project hash.
 * Includes system defaults merged with any custom overrides.
 */
export function loadSpecTypes(projectHash) {
    return loader.load(projectHash).map((t) => t.id);
}
/**
 * Returns spec type configs (id + label + description) for an optional project hash.
 */
export function loadSpecTypeConfigs(projectHash) {
    return loader.load(projectHash);
}
/**
 * Returns true if the given type id is valid for the project.
 */
export function isValidSpecType(typeId, projectHash) {
    return loadSpecTypes(projectHash).includes(typeId);
}
// ---------------------------------------------------------------------------
// System-level SPEC_TYPES constant (for runtime validation without a projectHash)
// ---------------------------------------------------------------------------
/**
 * Array of system-default spec type ids.
 * Loaded once at module init from src/config/spec-types.json.
 *
 * For organization/project custom types use loadSpecTypes(projectHash).
 */
export const SPEC_TYPES = Object.freeze(loader.load().map((t) => t.id));
//# sourceMappingURL=spec-types-loader.js.map