import { DeployFunctionInput, NeonApi } from "./neon-api.js"; //#region src/lib/neon-api-real.d.ts interface CreateNeonAuthRestInput { auth_provider: "better_auth"; database_name?: string; } /** * Adapt `@neon/sdk` (raw layer) to the narrow {@link NeonApi} façade used by the rest of * this package. Constructs are restricted to whole-object read/write of just the fields we * model in {@link Config}; anything else stays untouched on the remote. */ declare function createRealNeonApi(options: { apiKey: string; baseUrl?: string; /** * Tuning knob for the built-in 423 retry. Defaults: ~30s of total wait spread across * 12 attempts with exponential backoff capped at 5s. Lowering this is mostly useful in * tests; raising it is rarely needed because Neon operations are usually sub-second. */ retryOnLocked?: { maxAttempts?: number; initialDelayMs?: number; maxDelayMs?: number; }; }): NeonApi; interface RetryConfig { maxAttempts: number; initialDelayMs: number; maxDelayMs: number; } /** * Retry a function whenever it throws an HTTP 423 (Locked) — Neon's signal that a prior * mutation on the same resource is still in flight. Uses exponential backoff capped at * `maxDelayMs`. Any other error (and the last attempt) propagates. * * Exported only for tests; production callers go through the wrapped {@link NeonApi}. */ declare function retryOnLocked(fn: () => Promise, config: RetryConfig): Promise; /** * Whether an error from a Preview-feature read means the feature simply isn't available * for this project/branch/region (as opposed to a real, transient failure). Neon signals * this a few ways: a 404 "this route does not exist" (the route isn't deployed at all), or * a 503/4xx whose message says the platform feature is "not available" / "not enabled". * * Callers do **not** swallow this into an empty result — touching a Preview feature that * isn't available is surfaced as a {@link previewUnavailableError} so `plan` / `status` / * `pull` (and `neon dev`) fail clearly instead of, say, planning to create resources the * API will refuse to create. */ declare function isPreviewFeatureUnavailable(err: unknown): boolean; /** * Convert a Preview-feature error into a clear {@link PlatformError} when the feature is * unavailable for the project; otherwise pass the original error through unchanged so a * genuine failure (auth, transient 5xx, …) keeps its specific code and message. * * The message names the failing feature, summarizes the response in one short * `HTTP ` line, includes the raw Neon API message + request id (valuable * signal while the feature is in beta), gives status-specific guidance (see * {@link platformFeatureUnavailableHint}), and offers removing the feature from the policy as an * escape hatch. `status`/`requestId` are also kept on `details` for programmatic consumers. */ declare function previewUnavailableError(err: unknown, featureLabel: string): unknown; declare function createNeonAuthRestInput(input: { databaseName?: string; }): CreateNeonAuthRestInput; /** * Build the `multipart/form-data` body for a function deployment, matching the public * `FunctionDeployRequest` schema (`POST .../functions/{slug}/deployments`): * * - `zip` — the bundle as a binary part (named `bundle.zip`). * - `runtime` — the function runtime. * - `environment` — a single JSON-encoded string→string map (multipart can't carry a typed * object part), omitted entirely when there are no env vars. * * Pure (no I/O) so it can be unit-tested against the spec without stubbing `fetch`. */ declare function buildFunctionDeployForm(input: DeployFunctionInput): FormData; /** * Read a response body as JSON, tolerating non-JSON. Some Neon routes return a plain-text * body (e.g. a 404 `"this route does not exist"` for a Preview feature not enabled in the * project/region). Parsing that with `JSON.parse` used to throw a cryptic * `SyntaxError: Unexpected token …`, which — because parsing happens before the `res.ok` * check in {@link request} — masked the real HTTP status. We instead return the raw text * wrapped as `{ message }` so the status-based error path in `request` / `wrapNeonError` * runs and produces a proper {@link PlatformError} (e.g. `NotFound`), and a non-error body * that simply isn't JSON degrades to text rather than crashing. */ declare function readJsonBody(res: Response): Promise; //#endregion export { buildFunctionDeployForm, createNeonAuthRestInput, createRealNeonApi, isPreviewFeatureUnavailable, previewUnavailableError, readJsonBody, retryOnLocked }; //# sourceMappingURL=neon-api-real.d.ts.map