/** * Single source of truth for a recipe's **outbound cross-recipe handle * references** — the per-kind traversal that both the dependency * topo-sort (`compile/ordering.ts`) and the cross-recipe validator * (`validate.ts`) consume. * * Before this module the inventory was duplicated: `collectRecipeDeps` * (in `compile.ts`) switched on `recipe.kind` to pull handles for the * topo-sort, and the `check*Refs` family (in `validate.ts`) switched on * the SAME `recipe.kind` to reference-check the SAME handles. A new * reference site had to be added in both places in lockstep — a missed * edit silently reverted a recipe pair to alphabetic file-glob order * (topo-sort side) or skipped a dangling-handle check (validate side). * * `recipeReferences()` returns every outbound handle ONCE, tagged with: * * - `handle` — the referenced recipe handle. The topo-sort needs only * this (which recipes must apply first). * - `field` — a dotted path into the recipe (`insertOptions.0`, * `layout.placeholders./header.0.componentHandle`). The validator * uses it verbatim as the `fromField` of an `UnresolvedHandle`, so * the strings here must match the historical `check*Refs` paths * exactly (asserted by `tests/unit/recipe/validate.test.ts`). * - `expectedKinds` — the recipe kinds that are a legal resolution of * this reference. PRESENT → the validator reference-checks it; * ABSENT → the reference is topo-sort-only and the validator skips * it. (Today only `VariantRecipe.targetRendering.handle` is * topo-only: it seeds apply-ordering when a brand variant ships * alongside its canonical component-template, but the canonical is * usually absent from the set, so validating it would raise a * spurious dangling-handle error. The pre-refactor `validate.ts` * had no `case "variant"` — this preserves that.) */ import type { Recipe, SitecoreFieldAugment } from "./schema/recipe.js"; export type RecipeKind = Recipe["kind"]; /** * One outbound cross-recipe handle reference carried by a recipe. * * `expectedKinds` present ⇒ the validator resolves + kind-checks the * handle; absent ⇒ the reference exists only to order the apply * (topo-sort), and the validator leaves it alone. */ export interface RecipeReference { /** The referenced recipe handle. */ handle: string; /** Dotted path into the source recipe — used as the validator's `fromField`. */ field: string; /** Legal resolution kinds; absent ⇒ topo-sort-only, not validated. */ expectedKinds?: readonly RecipeKind[]; } /** * The picker-scope handles a `SitecoreFieldAugment` declares as source * `types`. Empty when the augment is absent OR uses the `raw` source * mode (verbatim Source string — nothing to resolve). The ONE copy of * this helper; both consumers (validate + ordering) reach it through * `recipeReferences`. */ export declare const sourceTypesOf: (augment: SitecoreFieldAugment | undefined) => readonly string[]; /** * Enumerate every outbound cross-recipe handle reference a recipe * carries, tagged with its dotted field path and (when the reference is * validated) its legal resolution kinds. * * Pure per-kind routing. The single source of truth for the reference * inventory that both the apply-ordering topo-sort and the cross-recipe * validator consume — extend HERE when a new reference site is added. */ export declare function recipeReferences(recipe: Recipe): readonly RecipeReference[];