import type { Pool, PoolClient } from 'pg'; /** * SQL over the page-builder tables (`changeset`, `changeset_operation`, * `rollout_plan`) needed by "Replace homepage". Lives in promotion so the * page builder itself stays untouched. See * specifications/replace-homepage-with-landing-page.md §2, §6, §7. */ type Queryable = Pool | PoolClient; /** What an operation must touch to count as "touching" a page. */ export interface TargetSpec { /** Ops stamped with this editor route count (e.g. `'homepage'`). `null` = do not match on the stamp. */ route: string | null; /** INSERT placement ops scoped to this entity count (e.g. a landing page URN). */ entityUrn: string | null; /** Existing placement uuids of the page body. */ placementUuids: string[]; /** Existing instance uuids of the page body. */ instanceUuids: string[]; } export declare const PLACEMENT_URN_PREFIX = "urn:evershop:cms:widget_placement:"; export declare const INSTANCE_URN_PREFIX = "urn:evershop:cms:widget_instance:"; /** * Build the `` predicate for an alias, using positional * parameters starting at `startIndex`. Returns the SQL fragment and the * parameters to append, in order. Pure. */ export declare function touchesSql(spec: TargetSpec, startIndex: number, alias?: string): { sql: string; params: unknown[]; }; export interface RolloutPlanRef { rollout_plan_id: number; uuid: string; name: string; start_time: Date; end_time: Date | null; } export type PlanStatus = 'active' | 'upcoming' | 'past'; /** active = started and not ended; upcoming = not started; past = ended. Pure. */ export declare function classifyPlan(plan: { start_time: Date | string; end_time: Date | string | null; }, now: Date): PlanStatus; /** A personal draft is named `pb-draft-`; anything else unpublished and unattached is a detached rollout changeset. Pure. */ export declare function changesetKind(name: string): 'draft' | 'detachedRollout'; export interface PlansTouching { active: RolloutPlanRef[]; upcoming: RolloutPlanRef[]; past: RolloutPlanRef[]; } /** Every plan in the theme bucket whose changeset has ≥ 1 op touching the target, split by status. */ export declare function findRolloutPlansTouching(q: Queryable, theme: string | null, spec: TargetSpec, now?: Date): Promise; /** Delete plan rows only (the changeset is kept), exactly like `cancelRolloutPlan`. */ export declare function cancelPlans(conn: PoolClient, planIds: number[]): Promise; export interface ChangesetTouching { changeset_id: number; name: string; created_by: number; kind: 'draft' | 'detachedRollout'; operationCount: number; } /** * Unpublished changesets in the theme bucket, not attached to any plan, with * ≥ 1 op touching the target. `lock` takes `FOR UPDATE` on the changeset rows * (the `addChangesetOperation` idiom) so concurrent auto-saves serialise. */ export declare function findChangesetsTouching(q: Queryable, theme: string | null, spec: TargetSpec, lock?: boolean): Promise; /** * Delete the ops of one changeset that touch the target, then drop the * `homepage` cursor key. The row itself is never deleted (an emptied draft is * reused by `getOrCreateDraftChangeset`; deleting it would 404 every save in * an open editor tab). Both predicates are repeated inside the statements. */ export declare function discardOperationsTouching(conn: PoolClient, changesetId: number, spec: TargetSpec, cursorKey?: string): Promise; export {};