import { type OperationIr } from "../ir/operations.js"; import { type EnumerationRecipe } from "../schema/recipe.js"; import { type CompileContext } from "./shared.js"; /** * Compile an `EnumerationRecipe` to an Operation IR. * * Emits the per-site `Enumerations Folder` + `Enumeration` + * `Enumeration Value` template trio (idempotent across the recipe set * via the shared `emittedFolders` sentinel), an optional grouping * folder under `` driven by `recipe.location.folder` * (also idempotent), one CreateItem op for the per-enum container item, * and one CreateItem op per declared value parented under that * container. * * Path resolution: * - With `recipe.location.folder` set → * `///`. The leaf * folder lands as a `CreateOnly` item conforming to the per-site * `Enumerations Folder` template; multiple recipes naming the same * folder path share it via the `emittedFolders` sentinel. * - Without `recipe.location` (or `recipe.location.folder`) → * `//` (flat layout). * * Template assignment (each item conforms to a different template — * roles are NOT collapsed): * - Grouping folders → `Enumerations Folder` template * - Per-enum container → `Enumeration` template * - Leaf value items → `Enumeration Value` template * * All three templates inherit Standard Template and stamp the * `keyboard_key_e.png` icon via template-level inheritance, so the SXA * editor shows enum items with the enum icon without per-item overrides. * * Each value item also writes its `value.name` to the `Value` shared * field defined on the `Enumeration Value` template's inner * `Enumeration` section. Without this the value items would have no * payload — the Droplink picker would still enumerate them, but * consumers reading the picked item's `Value` field (the canonical SXA * pattern) would find it empty. * * Refkeys: * - Grouping folder: `enumerationsGroupingFolderId(site, folder)` — * site + cumulative path keyed so two recipes naming the same * folder reuse one item rather than colliding. * - Per-enum container: `enumerationFolderId(site, recipe.handle)` — * site-scoped so cross-site pushes don't collide. (Function name is * legacy; the item it identifies is the per-enum container, not a * folder.) * - Values: `enumValueId(folderRefKey, value.name)` — value-name keyed * under the container. Renaming a value (`primary` → `accent`) emits * a different GUID; consuming fields whose default referenced the * old name end up orphaned. Author error. * * Throws `INPUT_INVALID` when `context.enumerationsRoot` is unset, or * when `recipe.location.scope` is `"siteCollection"` (reserved for * shared-vocabulary use; not yet implemented). */ export declare function compileEnumerationRecipe(input: EnumerationRecipe, context: CompileContext, emittedFolders?: Set): OperationIr;