/** * "Replace homepage with this page". Snapshot the current homepage widgets * into a new disabled backup landing page, then clone the chosen landing * page's body onto route `homepage`. One transaction, fail-fast on contention, * conditional on the state the preflight described. * Spec: specifications/replace-homepage-with-landing-page.md ยง3. */ export type ReplaceHomepageErrorCode = 'LANDING_PAGE_NOT_FOUND' | 'HOMEPAGE_ROLLOUT_ACTIVE' | 'HOMEPAGE_CHANGED' | 'HOMEPAGE_ENTITY_SCOPED' | 'REPLACE_IN_PROGRESS'; export declare class ReplaceHomepageError extends Error { readonly status: number; readonly code: ReplaceHomepageErrorCode; readonly rolloutPlans?: RolloutPlanSummary[]; constructor(code: ReplaceHomepageErrorCode, status: number, message: string, rolloutPlans?: RolloutPlanSummary[]); } export interface RolloutPlanSummary { uuid: string; name: string; startTime: string; endTime: string | null; status: 'active' | 'upcoming' | 'past'; editUrl: string; } export declare const ADVISORY_LOCK_KEY = "evershop:replace-homepage"; export declare function isUuid(value: unknown): value is string; /** Order-independent fingerprint of a set of uuids. Pure. */ export declare function fingerprint(uuids: readonly string[]): string; export declare function isLandingPageLive(lp: { status: boolean; publish_start?: Date | string | null; publish_end?: Date | string | null; }): boolean; interface BodyRow { uuid: string; instance_uuid: string; area: string; status: boolean | null; type: string; settings_text: string; } /** Rows in `landing_page_content`/other areas that would actually render: status true, type registered, parent present for children. Pure. */ export declare function countRenderable(body: BodyRow[], enabledTypes: Set): number; export interface PreflightResult { landingPage: { uuid: string; name: string; status: boolean; publishStart: string | null; publishEnd: string | null; isLive: boolean; bodyPlacementCount: number; renderablePlacementCount: number; hiddenPlacementCount: number; sharedRouteLevelCount: number; selfLinkCount: number; unpublishedOperationCount: number; rolloutPlans: RolloutPlanSummary[]; }; homepage: { placementCount: number; allRouteContentCount: number; }; /** `willCreate` is always true (kept for shape stability); `name` is the backup's name before suffixing. */ backup: { willCreate: boolean; name: string; }; drafts: { operationCount: number; byCurrentAdmin: number; otherAdminCount: number; detachedRolloutOperationCount: number; }; pastPlansToCancel: RolloutPlanSummary[]; blockers: { rolloutPlans: RolloutPlanSummary[]; entityScopedHomepage: boolean; }; fingerprints: { homepage: string; landingPage: string; }; backupsTotal: number; warnings: string[]; } export declare function preflightReplaceHomepage(uuid: string, userId: number): Promise; export interface ReplaceHomepageContext { routeId?: string; userId: number; /** From preflight; execute refuses when the live state differs. */ expectedFingerprints?: { homepage: string; landingPage: string; }; } export interface ReplaceHomepageResult { /** Always present: the backup is the restore point even when the homepage was empty. */ backup: { uuid: string; name: string; editUrl: string; }; backedUpInstances: number; backedUpPlacements: number; deletedInstances: number; clonedInstances: number; clonedPlacements: number; discardedChangesets: Array<{ changesetId: number; createdBy: number; kind: 'draft' | 'detachedRollout'; operationsRemoved: number; }>; cancelledPastPlans: Array<{ uuid: string; name: string; }>; backupsTotal: number; } export declare const replaceHomepageCore: (uuid: string, context: ReplaceHomepageContext) => Promise; export declare function replaceHomepage(uuid: string, context: ReplaceHomepageContext): Promise; export default replaceHomepage; export declare function hookBeforeReplaceHomepage(callback: (...args: any[]) => void | Promise, priority?: number): void; export declare function hookAfterReplaceHomepage(callback: (...args: any[]) => void | Promise, priority?: number): void; export declare function hookBeforeCreateHomepageBackup(callback: (...args: any[]) => void | Promise, priority?: number): void; export declare function hookAfterCreateHomepageBackup(callback: (...args: any[]) => void | Promise, priority?: number): void; export declare function hookBeforeSnapshotHomepage(callback: (...args: any[]) => void | Promise, priority?: number): void; export declare function hookAfterSnapshotHomepage(callback: (...args: any[]) => void | Promise, priority?: number): void;