import type { State } from "./compile.js"; /** * Where this project's cargo.state.json is. * * Preference order: * 1. Repo root (`/cargo.state.json`) — the standard location * 2. Project directory (`/infra/cargo.state.json`) — fallback * * New repos get state at the root; existing repos with state in `infra/` keep * working. Once a repo has state at the root, that's always used. */ export declare function statePath(root: string): string; /** * The directory where state-related files live (state, lock, audit, backup). * All must be in the same directory so the lock actually guards the state. */ export declare function stateDir(root: string): string; /** * Snapshot the current cargo.state.json to cargo.state.bak.json before a * mutating command, so `cdk rollback` can restore the prior state. No-op when no * state exists yet (first deploy). Returns whether a snapshot was taken. */ export declare function snapshotState(root: string): boolean; /** * Restore the snapshot taken before the last mutating command. Returns whether a * backup existed to restore. */ export declare function restoreSnapshot(root: string): boolean; /** * Read a repo's cargo.state.json when it holds the resource map itself, or * undefined on the first deploy. * * A POINTER file also reads as undefined here: it carries a uuid, not * resources, so there is no local state to return. Callers that can reach the * API go through a `StateBackend` instead, which follows the pointer. */ export declare function readState(root: string): State | undefined; /** * What the committed cargo.state.json turned out to be. * * The shape says which backend the project is on, so there is no `backend` * field to keep in sync with it: resources present means the file IS the state, * a uuid means the file points at one. */ export type StateFile = { kind: "fat"; state: State; } | { kind: "pointer"; stateUuid: string | undefined; } | { kind: "missing"; }; /** * The blob as a deploy state, or undefined when it is not one. * * This is the shape test the whole backend selection rests on, so both readers * of an untyped blob — the committed file and the stored contents of a cloud * state — ask it here. A state that has never been written is `{}`, which means * "nothing deployed" rather than a state with no resources. */ export declare function asDeployState(value: Record): State | undefined; /** * Read and classify cargo.state.json. * * Throws if it is not valid JSON, and if it is JSON that is neither shape. A * resource map that lost its `resources` would otherwise read as a pointer with * no uuid, and the next deploy would bind it to a fresh, empty state — orphaning * everything the old map tracked, which is the failure the missing-file branch * exists to prevent. */ export declare function readStateFile(root: string): StateFile; /** * Write the committed pointer. `stateUuid` is undefined when `cdk init` ran * with no way to reach the API: the file still lands, so the scaffold commit * carries it and a later `cdk state create` only has to fill in the uuid. */ export declare function writeStatePointer(root: string, stateUuid: string | undefined): void; /** Remember the blob a cloud read returned, for the offline commands. */ export declare function writeStateCache(root: string, state: State): void; /** * What this disk knows, whichever backend the project is on: the committed file * when it holds the map, and otherwise the last blob a cloud read cached. * * Every command that describes a project without touching the network answers * from here, so the "file, else cache" rule lives in one place. */ export declare function readStateOffline(root: string): State | undefined; /** * Write cargo.state.json — pretty-printed + trailing newline (it's committed). * * Refuses a bound pointer: that file is not the map, and overwriting it would * drop the uuid that finds the real one. */ export declare function writeState(root: string, state: State): void; /** A fresh, empty state bound to a workspace (used on the first deploy). */ export declare function emptyState(workspaceUuid: string): State; //# sourceMappingURL=state.d.ts.map