import type { DependencyGraph } from "./build.ts"; import { type SCC } from "./cycles.ts"; export type LoadStep = { kind: "single"; object: string; } | { kind: "cycle"; objects: string[]; breakEdge: { source: string; target: string; fieldName: string; } | null; internalEdges: SCC["internalEdges"]; }; export type LoadPlan = { /** * Ordered steps. A `single` step inserts one object. A `cycle` step inserts * the whole SCC in a two-phase pattern (insert with break-edge nulled, then update). */ steps: LoadStep[]; /** * Objects deliberately excluded from the load — standard root objects, and objects * the user did not request (we don't create records in parents). */ excluded: string[]; cycles: SCC[]; }; export type OrderOptions = { /** Only these objects will appear in the load plan. Others are "excluded". */ requestedObjects: string[]; /** Standard root objects (e.g. User, RecordType) are always excluded. */ includeStandardRoots?: boolean; }; /** * Compute a load plan: topological order of the condensation (SCCs collapsed to single nodes). * * Algorithm: * 1. Run Tarjan's SCC to find cycles. * 2. Build the condensation DAG: one node per SCC (or singleton), edges between SCCs. * 3. Kahn's topological sort on the condensation. Ties broken alphabetically for determinism. * 4. Filter the result to only objects the user requested (or everything if includeStandardRoots). */ export declare function computeLoadOrder(graph: DependencyGraph, opts: OrderOptions): LoadPlan;