import type { PoolClient } from 'pg'; /** * Copy a widget body — every `widget_placement` row in one scope together * with the `widget_instance` rows behind them — into another scope, with * fresh uuids for both instances and placements. Settings live on the * instance, so a placement-only copy would couple the two scopes. * * Used by Duplicate (landing page → new landing page, `theme: 'preserve'`) * and by "Replace homepage" twice: homepage → backup (the snapshot) and * landing page → homepage (`theme: 'active'`). See * specifications/replace-homepage-with-landing-page.md §3, §5. * * Writes both tables directly (like `applyOperationToSource`); cms widget * create hooks and processors do not fire. Set-based: three statements * regardless of body size. */ export interface CloneScope { /** Placement route. `null` in `from` = any route; `null` in `to` = keep each row's route. */ route: string | null; /** `null` = route-level placements (entity_urn IS NULL). */ entityUrn: string | null; } export interface CloneWidgetBodyOptions { from: CloneScope; to: CloneScope; /** Rename areas, e.g. `{ landing_page_content: 'content' }`. */ areaMap?: Record; /** Source rows in these areas are skipped entirely (e.g. `['content']` for a landing page body, which never renders there). */ excludeAreas?: string[]; /** * `'active'`: copy only rows in `activeTheme`'s bucket and stamp the copies with it. * `'preserve'`: copy every bucket and keep each row's own theme. */ theme: 'active' | 'preserve'; activeTheme?: string | null; /** Source instance ids whose rows must NOT be renamed through `areaMap` (unique-index guard, spec P14). */ keepAreaForInstanceIds?: Set; } export interface CloneWidgetBodyResult { clonedInstances: number; clonedPlacements: number; /** old instance uuid → new instance uuid */ instanceUuidMap: Map; sourcePlacementIds: number[]; sourceInstanceIds: number[]; } /** * Rewrite one area name for the target scope: named areas through `areaMap`, * synthetic container-child areas onto the copied parent's uuid, everything * else unchanged. Pure. */ export declare function rewriteArea(area: string, instanceUuidMap: ReadonlyMap, areaMap?: Record, skipAreaMap?: boolean): string; export declare function cloneWidgetBody(conn: PoolClient, opts: CloneWidgetBodyOptions): Promise;