/** * Granularity dial for `pgpm export`: route exported sql_actions rows through * the dials pipeline (`restructureChanges` in `@pgpmjs/transform`) so change * paths are derived from the naming spec (`identityOf` + `pathFor`) and * `requires` come from the statement dependency graph instead of the * hand-chained deps recorded at action time. */ import { PgpmRow } from '@pgpmjs/ast'; import { PathStyle } from '@pgpmjs/naming-spec'; import { Granularity } from '@pgsql/transform'; import { ChangeGranularity } from './granularity-driver'; export type ExportGranularity = Granularity; export declare const EXPORT_GRANULARITIES: readonly ExportGranularity[]; export declare const isExportGranularity: (value: unknown) => value is ExportGranularity; export interface RestructureExportRowsResult { rows: PgpmRow[]; warnings: string[]; } export interface RestructureExportRowsOptions { /** Naming-spec rendering style for derived paths (default `directory`). */ naming?: PathStyle; /** * Change-level distribution (default `object`): with `alteration`, each * `ADD COLUMN` / `ADD CONSTRAINT` becomes its own change. See * {@link ChangeGranularity}. */ changeGranularity?: ChangeGranularity; } /** * Restructure exported migration rows to the target granularity. * * The rows' deploy SQL is flattened in export order, restructured, and * re-sliced into per-object changes whose paths come from the naming spec and * whose deps come from the statement graph. When two changes derive the same * path (the same object altered again), later occurrences get the spec's * alteration convention via `alterationPathFor` (monotonic per-parent * counter), with the parent added to their deps. * * Revert/verify scripts are not carried through from the original rows (the * restructured grouping no longer matches them one-to-one); instead each * change gets scripts generated from its own statements via * `revertFor`/`verifyFor` (drops in reverse topological order, one existence * check per created object). */ export declare const restructureExportRows: (rows: PgpmRow[], granularity: ExportGranularity, options?: RestructureExportRowsOptions) => Promise;