import { type Operation, type PushPolicy, type SetFieldOp } from "../ir/operations.js"; import type { Layout } from "../schema/recipe.js"; import { type CompileContext } from "./shared.js"; /** * Scoped-datasource materialisation for the layout-holding items that host * their own content but are NOT the render-time context: partial designs and * page designs. * * A `kind: "scoped"` placement means "this rendering's content belongs to THIS * design and is authored inline." The design item hosts a real datasource item * at `/Data/`, shared by every page that uses the design — the * right semantics for design chrome like a footer sign-off. * * The page compiler materialises the same `/Data/` structure * (`compile/page.ts`) and references its slots with the page-relative * `ds="local:/Data/"` form. Partial designs reference their slots the * same way: XM Cloud Pages authors a partial design's own datasources with * `local:/Data/` (resolved for the partial's renderings against the * items materialised under the partial design), so the compiler mirrors that * form rather than an absolute GUID. Page designs still pass * `scopedDatasourceIdFor` for any own placements (an absolute GUID), since a * page design's `__Renderings` round-trips canonical byte-for-byte. */ export interface ScopedSlotInfo { /** Handle of the placed component — drives datasource-template fallback. */ componentHandle: string; /** Field values for the materialised `/Data/` item. */ fields: Record; } /** Collect the deduped `` map for a design's layout. */ export declare const collectScopedSlots: (layout: Layout | undefined) => Map; /** * Collect the deduped set of datasource-template handles for the design's * `Data` folder Insert Options — the union across EVERY placement (not just * scoped ones), by the same precedence as `collectPageDataInsertOptions`. */ export declare const collectDataInsertOptions: (layout: Layout | undefined, context: CompileContext) => readonly string[]; export interface ScopedMaterialization { /** Data folder + Insert-Options + per-slot `CreateItem` ops, in order. */ structureOps: Operation[]; /** Field `SetField` ops for the materialised slot items (versioned). */ fieldOps: SetFieldOp[]; /** Resolver for `emitLayoutXml`'s `scopedDatasourceIdFor` (absolute GUID). */ scopedDatasourceIdFor: (slot: string) => string; } /** * Build the ops that materialise a design's scoped datasource items under * `/Data/`. Returns `structureOps` (creation) and `fieldOps` * (values) separately so the caller can land the layout SetField (which the * items' GUIDs resolve against) between them. */ export declare function materializeScopedDatasources(params: { hostItemRefKey: string; hostItemPath: string; scopedSlots: Map; insertOptionHandles: readonly string[]; site: string; policy: PushPolicy; context: CompileContext; recipeHandle: string; /** Op-label prefix: `"partial-design"` | `"page-design"`. */ labelPrefix: string; }): ScopedMaterialization;