import { type HygieneCommonOptions } from "../shared.js"; export interface CleanupRenameOptions extends HygieneCommonOptions { /** * Required. Pattern to match against item names. JS regex by default; * pass `--literal` to escape the input. */ pattern: string; /** * Required. Replacement string. Supports JS RegExp backreferences * (`$1`, `$&`, `$`). Use `$$` for a literal `$`. */ replacement: string; literal?: boolean; ignoreCase?: boolean; flags?: string; /** Restrict by template name pattern. Recommended. */ templatePattern?: string; /** Content-tree root. Default `/sitecore/content`. */ root?: string; index?: string; limit?: number; includeSystem?: boolean; concurrency?: number; pageParallelism?: number; cache?: boolean; exclude?: string[]; since?: string; owner?: string; whatIf?: boolean; allowWrite?: boolean; baseline?: boolean; output?: string; format?: "json" | "csv" | "markdown"; /** * Maximum number of items renamed per run. Default 100. Renames mutate * paths — a stray match against `Page1`/`Page2`/... could thousand-fold * the site map. Cap is intentionally low. */ maxRenames?: number; } export interface RenameAction { itemId: string; oldPath: string; oldName: string; newName: string; newPath: string; templateName: string | null; status: "applied" | "what-if" | "failed" | "skipped-no-change" | "skipped-shape"; error?: string; } /** * Bulk-rename items by pattern. * * Strategy: * 1. Scan via `scanItemsAndFields(skipFields: true)` — we only need * the item's name + path. * 2. For each item, compute `newName = oldName.replace(pattern, replacement)`. * 3. Validate the new name: no slashes, non-empty, ≠ old name. * 4. Call `client.renameItem({itemId, name: newName})`. * * Safety rails: * - `--what-if` reports without writing. * - `--allow-write` required outside what-if. * - `--max-renames` caps the blast radius (default 100). * - `--template-pattern` is strongly recommended; renaming items by * a generic name pattern across every template is rarely the * intent. * * Notes: * - The Authoring API's `updateItem(name: …)` rejects slashes in * names (resolves to an unreachable path). We reject up-front. * - Renaming changes the URL slug of pages — coordinate with * redirects / sitemap regeneration in the surrounding workflow. * - Display name (`__Display Name`) is a separate field; this verb * does NOT touch it. Use `cleanup field-set --field "__Display Name"` * when the operator wants the editor-visible name to change too. */ export declare const runCleanupRename: (options: CleanupRenameOptions) => Promise;