import type { BackupSchedule, BackupScheduleItem, Branch, Snapshot } from "../../client/types.gen.js"; import type { CallOptions, RequestContext } from "../context.js"; import { type Outcome } from "../result.js"; /** * Inspect a restored-but-un-finalized branch and decide whether to commit it. * * The second argument carries the call's `signal`. The SDK cannot interrupt this callback * — it is the caller's own code — so long-running checks should honour the signal * themselves; the restore is left un-finalized if the call is cancelled around it. */ export type RestorePreview = (branch: Branch, context: { signal?: AbortSignal; }) => boolean | Promise; /** Options for {@link Snapshots.create} (point-in-time + naming). */ export interface CreateSnapshotInput { /** A name for the snapshot. */ name?: string; /** Take the snapshot at this timestamp (ISO 8601). Mutually exclusive with `lsn`. */ timestamp?: string; /** Take the snapshot at this LSN. Mutually exclusive with `timestamp`. */ lsn?: string; /** When the snapshot is automatically deleted (ISO 8601). */ expiresAt?: string; } /** Input for {@link Snapshots.update}. */ export interface UpdateSnapshotInput { /** Rename the snapshot. */ name?: string; /** * Change when the snapshot expires (ISO 8601). Omit to leave the current * expiration unchanged, pass `null` to clear it so the snapshot never * expires, or a future timestamp to set an absolute expiration. */ expiresAt?: string | null; } /** Input for {@link Snapshots.restore}. */ export interface RestoreSnapshotInput { /** Name for the restored branch. Auto-generated when omitted. */ name?: string; /** Branch to restore onto. Defaults to the snapshot's source branch. */ targetBranchId?: string; /** * Finalize immediately (move computes onto the restored branch). Defaults to `true` * when restoring as a new branch (nothing to clobber) and `false` when restoring * **onto** an existing branch (`targetBranchId`), so you can preview before the swap. * Ignored when `preview` is set (the preview flow always restores un-finalized first). */ finalize?: boolean; /** * Transaction-style restore: receives the restored (un-finalized) branch; return `true` * to finalize (commit) or `false` to abort. On abort the preview branch is deleted * unless `keepOnAbort` is set. Either way `restore` resolves to the restored `Branch`. */ preview?: RestorePreview; /** Keep the preview branch when `preview` returns `false` (default: delete it). */ keepOnAbort?: boolean; } /** * How often the automatic snapshot (backup) schedule takes a snapshot. These are * the values the Neon API accepts, per the OpenAPI spec's `BackupScheduleItem` * description. The generated `BackupScheduleItem.frequency` is a broad `string` * (the spec documents the allowed values in prose rather than an `enum`), so this * union narrows what {@link Snapshots.setSchedule} sends. */ export type SnapshotFrequency = "daily" | "weekly" | "monthly"; /** * A single entry to write to an automatic snapshot (backup) schedule. Identical * to the generated {@link BackupScheduleItem} except `frequency` is narrowed to * {@link SnapshotFrequency} — the values the API actually accepts. */ export type BackupScheduleItemInput = Omit & { frequency: SnapshotFrequency; }; /** Input for {@link Snapshots.setSchedule}. */ export interface SetScheduleInput { /** The ordered list of schedule entries to apply to the branch. */ schedule: BackupScheduleItemInput[]; } export type SnapshotsListParams = { projectId: string; }; export type SnapshotsCreateParams = { projectId: string; branchId: string; } & CreateSnapshotInput; export type SnapshotsUpdateParams = { projectId: string; snapshotId: string; } & UpdateSnapshotInput; export type SnapshotsDeleteParams = { projectId: string; snapshotId: string; }; export type SnapshotsRestoreParams = { projectId: string; snapshotId: string; } & RestoreSnapshotInput; export type SnapshotsGetScheduleParams = { projectId: string; branchId: string; }; export type SnapshotsSetScheduleParams = { projectId: string; branchId: string; } & SetScheduleInput; /** Snapshot resource. */ export declare class Snapshots { #private; constructor(ctx: RequestContext); /** @apiCall GET /projects/{project_id}/snapshots */ list(params: SnapshotsListParams): Promise>; list(params: SnapshotsListParams, opts: CallOptions): Promise>; /** @apiCall POST /projects/{project_id}/branches/{branch_id}/snapshot */ create(params: SnapshotsCreateParams): Promise>; create(params: SnapshotsCreateParams, opts: CallOptions): Promise>; /** @apiCall PATCH /projects/{project_id}/snapshots/{snapshot_id} */ update(params: SnapshotsUpdateParams): Promise>; update(params: SnapshotsUpdateParams, opts: CallOptions): Promise>; /** @apiCall DELETE /projects/{project_id}/snapshots/{snapshot_id} */ delete(params: SnapshotsDeleteParams): Promise>; delete(params: SnapshotsDeleteParams, opts: CallOptions): Promise>; /** * Restore a snapshot into a branch. Returns the restored branch. * * - **As a new branch** (no `targetBranchId`): finalizes by default — ready to use. * - **Onto an existing branch** (`targetBranchId`): does **not** finalize by default, * so you can preview before the compute swap. Finish later with * `branches.finalizeRestore`, or pass a `preview` callback to do it transactionally. * * With `preview`, this restores un-finalized, runs your callback against the restored * branch, then finalizes (commit) or deletes the preview branch (abort, unless * `keepOnAbort`). Either way it resolves to the restored `Branch`. * * @apiCall POST /projects/{project_id}/snapshots/{snapshot_id}/restore */ restore(params: SnapshotsRestoreParams): Promise>; restore(params: SnapshotsRestoreParams, opts: CallOptions): Promise>; /** @apiCall GET /projects/{project_id}/branches/{branch_id}/backup_schedule */ getSchedule(params: SnapshotsGetScheduleParams): Promise>; getSchedule(params: SnapshotsGetScheduleParams, opts: CallOptions): Promise>; /** * Replace a branch's automatic snapshot schedule. * * `frequency` is narrowed to {@link SnapshotFrequency}, so a value the API * rejects fails to compile. {@link Snapshots.getSchedule} deliberately keeps * the wider generated type, because a branch can still hold a schedule * created when the API accepted other frequencies; feeding one straight back * here is a type error rather than a runtime rejection. * * @apiCall PUT /projects/{project_id}/branches/{branch_id}/backup_schedule */ setSchedule(params: SnapshotsSetScheduleParams): Promise>; setSchedule(params: SnapshotsSetScheduleParams, opts: CallOptions): Promise>; } //# sourceMappingURL=snapshots.d.ts.map