import type { Operation } from "../ir/operations.js"; import { type MediaFallback } from "../api/ref-encoding.js"; import type { AuthoringApiClient, RemoteItem } from "../api/client.js"; import { type SitesApiClient } from "../api/sites-client.js"; import type { BaselineIndex } from "./baseline.js"; import type { PlannedAction, PlanOptions } from "./plan-types.js"; /** * Plan a single op against the current remote state. Exposed so the * executor's apply mode can interleave plan-and-apply per-op (each op's * plan sees the cascading effect of earlier ops' applies — required for * idempotency: a second push must see no drift on update-style ops whose * targets the first push created). * * Updates `capturedItemIds` when `getItem(by path)` finds an existing * item (so subsequent ops can resolve refs without dispatching). * * When a `pathSnapshotCache` is provided (workspace prefetch), each * `getItem({ path })` call short-circuits to the cached value when the * path is already known — `null` means "checked and missing", a * `RemoteItem` means "use this snapshot". Non-path lookups (by itemId) * still hit the wire. */ export interface BuildActionOptions { index: number; op: Operation; client: AuthoringApiClient; capturedItemIds: Map; sitesClient?: SitesApiClient; pathSnapshotCache?: Map; /** * Operator override for prune-rollback snapshot languages. Forwarded * to `planPruneChildren`. Leave undefined to let the planner * auto-discover via `client.getTenantLanguages` once per push. */ snapshotLanguages?: readonly string[]; /** * Three-way merge baseline + conflict policy. Forwarded to * `planCreateItem` / `planUpdateOp` so per-field drift classifies as * `recipe-change` / `cms-edit` / `conflict` and routes per the policy. */ baselineIndex?: BaselineIndex; conflictPolicy?: PlanOptions["conflictPolicy"]; /** * RefKeys of items CREATED earlier in this push run (apply mode * tracks them across IRs). Update-style ops targeting one of these * bypass baseline classification entirely: a brand-new item cannot * carry CMS edits, so any divergence between its server-initialised * field values and a stale baseline (e.g. the same refKey's previous * item at an old path) is NOT an author edit — treating it as one * skipped the write and shipped items with default field values (the * page-template base-templates regression: relocated templates kept * Sitecore's default Standard-template-only inheritance because the * stale baseline classified the fresh item as a cms-edit/conflict). */ createdThisRun?: ReadonlySet; /** * Item names this push's CreateItem ops claim, grouped by parent — built * once per plan by {@link buildSiblingCreateNames}. * * Guards the sibling-rename fallback against rebinding one op onto ANOTHER * op's item when a single recipe creates several items under one parent * (inline treelist children). Omitting it restores the old, unsafe * "exactly one marked sibling ⇒ rename" behavior — see * {@link findCreateItemSibling}. */ siblingCreateNames?: ReadonlyMap>; /** * Push-scoped itemId → snapshot cache for itemId-selector reads, with * write-through from the executor's apply loop — see * `ExecuteOptions.idSnapshotCache`. When absent, every op pays its own * `getItem({ itemId })` round trip (the historical behavior). */ idSnapshotCache?: Map; /** * Push-scoped itemId → (language → max version) stacks for * `planAddItemVersion` — see `ExecuteOptions.versionStackCache`. */ versionStackCache?: Map>; /** * Every language the current IR adds versions to on THIS op's target * refKey (only set for `AddItemVersion` ops). Lets the version-stack * seed read fetch all of them in one batch. */ addVersionLanguagesHint?: readonly string[]; /** * Hotlink fallbacks for failed external-URL media uploads — written * by `planMediaUpload` when byte sourcing fails, read by every * `media-xml-ref` resolution so the referencing field degrades to * `` instead of aborting the push. Callers pushing * multiple IRs pass ONE map so cross-IR refs see earlier failures. */ mediaFallbacks?: Map; /** RefKeys this push writes fields to via SetField ops — see {@link buildFieldTargetRefKeys}. */ fieldTargetRefKeys?: ReadonlySet; } export declare const buildAction: ({ index, op, client, capturedItemIds, sitesClient, pathSnapshotCache, snapshotLanguages, baselineIndex, conflictPolicy, createdThisRun, idSnapshotCache, versionStackCache, addVersionLanguagesHint, mediaFallbacks, siblingCreateNames, fieldTargetRefKeys, }: BuildActionOptions) => Promise;