@krovacloud/sdk 0.4.12 → 0.4.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["createClient"],"sources":["../src/error.ts","../src/client.ts"],"sourcesContent":["/**\n * The error body shape returned by the Krova Cloud API.\n *\n * Per the OpenAPI spec (`components.schemas.Error`), every non-2xx response\n * body is `{ \"error\": string }`.\n */\nexport interface KrovaErrorBody {\n error?: string;\n}\n\n/**\n * The richer 409 body shape the v1 API returns for a termination-protected\n * Cube. The base {@link KrovaErrorBody} only carries `error: string` because\n * the documented `Error` schema is flat; the DELETE handler returns this\n * nested form for `error.code = \"termination_protected\"`. The {@link KrovaError}\n * `body` slot stays a `KrovaErrorBody` for backwards compatibility — the\n * dedicated error class below carries the parsed cube fields instead.\n */\nexport interface TerminationProtectedErrorBody {\n error?: {\n code?: string;\n message?: string;\n cube?: {\n id?: string;\n terminationProtectionChangedAt?: string | null;\n terminationProtectionChangedBy?: string | null;\n };\n };\n}\n\n/**\n * Error thrown by the ergonomic {@link KrovaClient} helpers when the API\n * responds with a non-2xx status.\n *\n * The raw openapi-fetch client (`client.raw`) never throws — it returns\n * `{ data, error, response }`. The helpers wrap that and throw `KrovaError`\n * so callers can `try/catch`.\n */\nexport class KrovaError extends Error {\n /** HTTP status code of the failing response. */\n readonly status: number;\n\n /**\n * A machine-readable error code, when the API surfaces one via the\n * `X-Error-Code` response header. The documented error body only carries a\n * human-readable `error` string, so this is best-effort.\n */\n readonly code?: string;\n\n /**\n * The request id from the `X-Request-Id` response header, when present.\n * Useful when contacting Krova Cloud support about a specific failure.\n */\n readonly requestId?: string;\n\n /** The parsed JSON error body, when the response had one. */\n readonly body?: KrovaErrorBody;\n\n /** The raw `Response` object, for callers that need headers/url/etc. */\n readonly response?: Response;\n\n constructor(\n message: string,\n init: {\n status: number;\n code?: string;\n requestId?: string;\n body?: KrovaErrorBody;\n response?: Response;\n },\n ) {\n super(message);\n this.name = \"KrovaError\";\n this.status = init.status;\n this.code = init.code;\n this.requestId = init.requestId;\n this.body = init.body;\n this.response = init.response;\n // Restore prototype chain for instanceof across compilation targets.\n Object.setPrototypeOf(this, KrovaError.prototype);\n }\n}\n\n/**\n * Build a {@link KrovaError} from a failing response + parsed error body.\n *\n * `body` is `unknown` rather than {@link KrovaErrorBody} because not every\n * documented error response is the flat `{ error: string }` shape — DELETE\n * /cubes/{cubeId} publishes a 409 whose `error` is an object. This function\n * already coped with that at runtime; typing the parameter narrowly only meant\n * the call sites had to lie. Widening accepts strictly more, so no caller\n * breaks.\n *\n * `body` is carried onto the error only when it really is the flat shape, so\n * {@link KrovaError.body} never advertises a `string` that is not there. A\n * caller that needs the raw payload of some other shape has `response`.\n */\nexport function krovaErrorFrom(response: Response, body: unknown): KrovaError {\n const flat =\n typeof body === \"object\" && body !== null && typeof (body as KrovaErrorBody).error === \"string\"\n ? (body as KrovaErrorBody)\n : undefined;\n const message =\n flat?.error || response.statusText || `Request failed with status ${response.status}`;\n return new KrovaError(message, {\n status: response.status,\n code: response.headers.get(\"x-error-code\") ?? undefined,\n requestId: response.headers.get(\"x-request-id\") ?? undefined,\n body: flat,\n response,\n });\n}\n\n/**\n * Thrown by `client.cubes.delete` when the server rejects a delete with\n * `409` and `error.code = \"termination_protected\"`.\n *\n * The customer-facing contract is: a Cube with `terminationProtection = true`\n * cannot be deleted until the flag is turned off. The CLI and MCP surface the\n * server's message verbatim, so callers can switch on `code` rather than\n * parsing prose. `cubeId` / `changedAt` / `changedBy` are best-effort — a\n * defensive server (or an older control plane) may omit the `cube` block, in\n * which case the SDK falls back to the id the call was made with and leaves\n * the two timestamps `null`.\n */\nexport class TerminationProtectedError extends KrovaError {\n /** The id of the Cube the customer tried to delete. */\n readonly cubeId: string;\n\n /**\n * When the flag was last changed (`terminationProtectionChangedAt` on the\n * Cube row). `null` when the server's 409 body omitted it.\n */\n readonly changedAt: string | null;\n\n /**\n * Who last changed the flag (`terminationProtectionChangedBy` on the Cube\n * row — typically `\"user:<id>\"`). `null` when the server's 409 body omitted\n * it.\n */\n readonly changedBy: string | null;\n\n constructor(\n message: string,\n init: {\n status: number;\n code: string;\n requestId?: string;\n body?: KrovaErrorBody;\n response?: Response;\n cubeId: string;\n changedAt: string | null;\n changedBy: string | null;\n },\n ) {\n super(message, {\n status: init.status,\n code: init.code,\n ...(init.requestId ? { requestId: init.requestId } : {}),\n ...(init.body ? { body: init.body } : {}),\n ...(init.response ? { response: init.response } : {}),\n });\n this.name = \"TerminationProtectedError\";\n this.cubeId = init.cubeId;\n this.changedAt = init.changedAt;\n this.changedBy = init.changedBy;\n Object.setPrototypeOf(this, TerminationProtectedError.prototype);\n }\n}\n\n/**\n * Try to interpret a failing DELETE response as the v1 API's\n * termination-protected 409. Returns a {@link TerminationProtectedError} when\n * the body shape matches, `null` otherwise (the caller then falls back to a\n * plain {@link KrovaError}).\n *\n * The 409 body is published as `{ error: { code, message, cube: { … } } }`,\n * but the bundled OpenAPI spec only declares `{ error: string }` for the\n * generic `Error` schema — so the cast is best-effort and we tolerate\n * missing optional fields.\n */\nexport function terminationProtectedFrom(\n response: Response,\n cubeId: string,\n body: unknown,\n): TerminationProtectedError | null {\n if (response.status !== 409 || body === null || typeof body !== \"object\") return null;\n const errBlock = (body as TerminationProtectedErrorBody).error;\n if (!errBlock || typeof errBlock !== \"object\") return null;\n if (errBlock.code !== \"termination_protected\") return null;\n const cubeBlock = errBlock.cube;\n const message =\n (typeof errBlock.message === \"string\" && errBlock.message) ||\n `Cube ${cubeId} has termination protection on. Turn it off before deleting.`;\n return new TerminationProtectedError(message, {\n status: 409,\n code: \"termination_protected\",\n requestId: response.headers.get(\"x-request-id\") ?? undefined,\n body: { error: message },\n response,\n cubeId: typeof cubeBlock?.id === \"string\" ? cubeBlock.id : cubeId,\n changedAt:\n typeof cubeBlock?.terminationProtectionChangedAt === \"string\"\n ? cubeBlock.terminationProtectionChangedAt\n : null,\n changedBy:\n typeof cubeBlock?.terminationProtectionChangedBy === \"string\"\n ? cubeBlock.terminationProtectionChangedBy\n : null,\n });\n}\n","import createClient, { type Client, type Middleware } from \"openapi-fetch\";\nimport { krovaErrorFrom, terminationProtectedFrom } from \"./error.js\";\nimport type { components, paths } from \"./generated/types.js\";\n\n/** The Cube resource, as defined in the Krova Cloud OpenAPI spec. */\nexport type Cube = components[\"schemas\"][\"Cube\"];\n\n/** A region with available capacity (from the catalog). */\nexport type Region = components[\"schemas\"][\"Region\"];\n\n/** A selectable OS image (from the catalog). */\nexport type Image = components[\"schemas\"][\"Image\"];\n\n/** A volume-pricing tier (from the catalog). */\nexport type PricingTier = components[\"schemas\"][\"PricingTier\"];\n\n/** Pagination envelope returned alongside a Cube list. */\nexport type Pagination = components[\"schemas\"][\"Pagination\"];\n\n/** A Space — the tenancy an API key is scoped to. */\nexport type Space = components[\"schemas\"][\"Space\"];\n\n/** A Cube's SSH connection info (host, port, user, and pinned host keys). */\nexport type CubeSshInfo = components[\"schemas\"][\"CubeSshInfo\"];\n\n/** A custom domain attached to a Cube. */\nexport type Domain = components[\"schemas\"][\"Domain\"];\n\n/**\n * One DNS record you must publish for a domain to work.\n *\n * An ordinary subdomain needs one CNAME. A wildcard needs three: an ownership\n * TXT, the routing CNAME, and an `_acme-challenge` CNAME that lets Krova issue\n * and renew its certificate.\n *\n * ⛔ `mustBeGrey` and `proxyOk` are deliberate OPPOSITES, and automation needs\n * both. The routing record may sit behind Cloudflare's proxy (orange); the\n * `_acme-challenge` record must not, because a proxied one answers with\n * Cloudflare's addresses and the certificate authority finds nothing there.\n */\nexport type DnsRecord = components[\"schemas\"][\"DnsRecord\"];\n\n/**\n * A {@link DnsRecord} plus what Krova can currently see in public DNS.\n *\n * ⛔ `state: \"missing\"` means NOT PUBLISHED YET — the expected state before you\n * create the record, never an error. `state: \"unknown\"` means Krova could not\n * complete the lookup, which is never a statement about your DNS. Surfacing\n * either to your own users as a failure would be wrong.\n */\nexport type DnsRecordStatus = components[\"schemas\"][\"DnsRecordStatus\"];\n\n/** A snapshot of a Cube's disk. */\nexport type Snapshot = components[\"schemas\"][\"Snapshot\"];\n\n/** A TCP port mapping exposing a Cube port on the host. */\nexport type TcpMapping = components[\"schemas\"][\"TcpMapping\"];\n\n/** Request body for attaching a custom domain to a Cube. */\nexport type CreateDomainInput = NonNullable<\n paths[\"/spaces/{spaceId}/cubes/{cubeId}/domains\"][\"post\"][\"requestBody\"]\n>[\"content\"][\"application/json\"];\n\n/** Request body for updating a custom domain's proxy settings. */\nexport type UpdateDomainInput = NonNullable<\n paths[\"/spaces/{spaceId}/cubes/{cubeId}/domains/{mappingId}\"][\"patch\"][\"requestBody\"]\n>[\"content\"][\"application/json\"];\n\n/** Request body for creating a TCP port mapping. */\nexport type CreateTcpMappingInput = NonNullable<\n paths[\"/spaces/{spaceId}/cubes/{cubeId}/tcp-mappings\"][\"post\"][\"requestBody\"]\n>[\"content\"][\"application/json\"];\n\n/**\n * Request body for `POST /spaces/{spaceId}/cubes` as defined in the OpenAPI\n * spec, with `terminationProtection` intersected on because the bundled spec\n * does not declare the field but the v1 API accepts it. A boolean `false` (or\n * omission) leaves the Cube in the documented default-unprotected state; `true`\n * opts the Cube out of customer-initiated deletion until the flag is toggled\n * back via `cubes.setTerminationProtection`.\n */\nexport type CreateCubeInput = NonNullable<\n paths[\"/spaces/{spaceId}/cubes\"][\"post\"][\"requestBody\"]\n>[\"content\"][\"application/json\"] & {\n /** Opt this Cube out of customer-initiated deletion (default `false`). */\n terminationProtection?: boolean;\n};\n\n/**\n * Request body for `PATCH /spaces/{spaceId}/cubes/{cubeId}` — the v1 API\n * endpoint the SDK uses to toggle termination protection on an existing Cube.\n * The bundled OpenAPI spec does not declare a PATCH on this path yet, so the\n * type is structurally derived from the {@link Cube} fields the API echoes\n * back. Only `terminationProtection` is exposed by `setTerminationProtection`;\n * future toggles can extend this without breaking the public signature.\n */\nexport type SetTerminationProtectionInput = {\n terminationProtection: boolean;\n};\n\n/**\n * A webhook endpoint subscribed to Space events.\n *\n * ⛔ Runtime discrepancy: the bundled OpenAPI spec does not declare\n * `description`, but `GET /spaces/{spaceId}/webhooks/{endpointId}` includes\n * it as `string | null`. The schema-derived type is extended here so callers\n * reading a single webhook see the field; it is optional so list responses\n * (which omit it) still typecheck.\n */\nexport type Webhook = components[\"schemas\"][\"Webhook\"] & {\n description?: string | null;\n};\n\n/** A recorded webhook delivery attempt (last 30 days of history). */\nexport type WebhookDelivery = components[\"schemas\"][\"WebhookDelivery\"];\n\n/**\n * Request body for creating a webhook endpoint.\n *\n * Derived from `paths[\"/spaces/{spaceId}/webhooks\"][\"post\"]` exactly like\n * {@link CreateDomainInput}; `description` is intersected on because the\n * bundled spec omits it but the runtime accepts it.\n */\nexport type CreateWebhookInput = NonNullable<\n paths[\"/spaces/{spaceId}/webhooks\"][\"post\"][\"requestBody\"]\n>[\"content\"][\"application/json\"] & {\n /** Optional human-readable label shown on the endpoint. */\n description?: string;\n};\n\n/** A webhook plus its signing secret. Returned ONLY by {@link KrovaClient.webhooks}.create. */\nexport type WebhookWithSecret = Webhook & { secret: string };\n\n/** Default API base URL — the single `servers[0].url` from the OpenAPI spec. */\nexport const DEFAULT_BASE_URL = \"https://krova.cloud/api/v1\";\n\n/**\n * How the API key is presented to the server.\n *\n * - `\"x-api-key\"` (default) — `X-API-KEY: <key>`, matching the spec's\n * `components.securitySchemes.ApiKeyAuth` (an `apiKey` header named\n * `X-API-KEY`).\n * - `\"bearer\"` — `Authorization: Bearer <key>`, for gateways that expect it.\n */\nexport type AuthScheme = \"x-api-key\" | \"bearer\";\n\nexport interface KrovaClientOptions {\n /**\n * Your Krova Cloud API key (a `kro_...` token). Keys are scoped per Space\n * and inherit the permissions of the membership that created them.\n */\n apiKey: string;\n /** Override the API base URL. Defaults to {@link DEFAULT_BASE_URL}. */\n baseUrl?: string;\n /**\n * Auth header scheme. Defaults to `\"x-api-key\"` (the spec's scheme).\n */\n authScheme?: AuthScheme;\n /**\n * Max automatic retries on retryable statuses (429, 503).\n * Defaults to 2. Set to 0 to disable retries.\n */\n maxRetries?: number;\n /**\n * A custom `fetch` implementation (e.g. for tests or a proxy). Defaults to\n * the global `fetch`.\n */\n fetch?: typeof fetch;\n}\n\n/** Statuses the retry middleware treats as transient. */\nconst RETRYABLE_STATUSES = new Set([429, 503]);\n/** Fallback backoff (ms) when the server sends no `Retry-After` header. */\nconst BASE_BACKOFF_MS = 500;\n/** Cap on any single backoff wait (ms), to keep retries \"small but real\". */\nconst MAX_BACKOFF_MS = 10_000;\n\nconst sleep = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms));\n\n/**\n * Parse a `Retry-After` header (RFC 7231): either delta-seconds or an\n * HTTP-date. Returns milliseconds to wait, or `null` if absent/unparseable.\n */\nfunction parseRetryAfterMs(headerValue: string | null): number | null {\n if (!headerValue) return null;\n const seconds = Number(headerValue);\n if (Number.isFinite(seconds)) return Math.max(0, seconds * 1000);\n const dateMs = Date.parse(headerValue);\n if (Number.isFinite(dateMs)) return Math.max(0, dateMs - Date.now());\n return null;\n}\n\nfunction authMiddleware(apiKey: string, scheme: AuthScheme): Middleware {\n return {\n onRequest({ request }) {\n if (scheme === \"bearer\") {\n request.headers.set(\"Authorization\", `Bearer ${apiKey}`);\n } else {\n request.headers.set(\"X-API-KEY\", apiKey);\n }\n return request;\n },\n };\n}\n\n/**\n * Retry middleware: on a retryable status, wait (honoring `Retry-After` when\n * present, else exponential backoff) and re-issue the request.\n *\n * A retried request may have a body (POST/PUT/DELETE — exactly the mutating,\n * rate-limited endpoints). By the time `onResponse` runs, the request that was\n * handed to `fetch` has had its body stream consumed, so `request.clone()` here\n * throws `TypeError: unusable`. To re-issue it we stash a *pristine* clone in\n * `onRequest` — captured before the body is read — keyed by openapi-fetch's\n * per-request `id`, and clone from that pristine copy on each attempt.\n */\nfunction retryMiddleware(maxRetries: number, doFetch: typeof fetch): Middleware {\n const pristine = new Map<string, Request>();\n return {\n onRequest({ request, id }) {\n pristine.set(id, request.clone());\n return request;\n },\n onError({ id }) {\n // fetch rejected (network error) — no onResponse will fire; don't leak.\n pristine.delete(id);\n },\n async onResponse({ request, response, id }) {\n const original = pristine.get(id) ?? request;\n pristine.delete(id);\n if (maxRetries <= 0 || !RETRYABLE_STATUSES.has(response.status)) {\n return response;\n }\n let current = response;\n for (let attempt = 1; attempt <= maxRetries; attempt++) {\n if (!RETRYABLE_STATUSES.has(current.status)) break;\n const retryAfterMs = parseRetryAfterMs(current.headers.get(\"retry-after\"));\n const backoff = Math.min(BASE_BACKOFF_MS * 2 ** (attempt - 1), MAX_BACKOFF_MS);\n // Cap the wait — including a server-supplied `Retry-After` — so a hostile\n // or misconfigured server can't park the client for minutes/hours.\n await sleep(Math.min(retryAfterMs ?? backoff, MAX_BACKOFF_MS));\n // Re-issue from the pristine clone; `.clone()` keeps it reusable across\n // multiple attempts.\n current = await doFetch(original.clone());\n }\n return current;\n },\n };\n}\n\n/**\n * A typed client for the Krova Cloud API.\n *\n * @example\n * ```ts\n * const krova = new KrovaClient({ apiKey: \"kro_...\" });\n * const cubes = await krova.cubes.list(\"space_123\");\n * ```\n */\nexport class KrovaClient {\n /**\n * The underlying openapi-fetch client — a fully typed escape hatch to every\n * path in the spec. Returns `{ data, error, response }` and never throws.\n *\n * @example\n * ```ts\n * const { data, error } = await krova.raw.GET(\n * \"/spaces/{spaceId}/cubes/{cubeId}\",\n * { params: { path: { spaceId, cubeId } } },\n * );\n * ```\n */\n readonly raw: Client<paths>;\n\n /** The resolved base URL in use. */\n readonly baseUrl: string;\n\n constructor(options: KrovaClientOptions) {\n if (!options?.apiKey) {\n throw new Error(\"KrovaClient: `apiKey` is required.\");\n }\n this.baseUrl = options.baseUrl ?? DEFAULT_BASE_URL;\n const doFetch = options.fetch ?? globalThis.fetch;\n const maxRetries = options.maxRetries ?? 2;\n\n this.raw = createClient<paths>({\n baseUrl: this.baseUrl,\n // SECURITY: never auto-follow redirects. The Krova Cloud API is a plain\n // JSON API and never legitimately 3xx's a data call. Following a redirect\n // would resend the `X-API-KEY` header to the redirect target — and unlike\n // `Authorization`, `Cookie`, and `Proxy-Authorization`, the Fetch spec does\n // NOT strip a custom header like `X-API-KEY` on a cross-origin redirect\n // (verified against undici/Node fetch). A compromised/misconfigured proxy,\n // an open-redirect on the API, or a MITM could otherwise exfiltrate the key\n // to an attacker's host. With `\"manual\"`, a redirect comes back as a\n // non-ok response and the helpers throw `KrovaError` instead of leaking.\n redirect: \"manual\",\n ...(options.fetch ? { fetch: options.fetch } : {}),\n });\n this.raw.use(authMiddleware(options.apiKey, options.authScheme ?? \"x-api-key\"));\n if (maxRetries > 0) {\n this.raw.use(retryMiddleware(maxRetries, doFetch));\n }\n }\n\n // ---------------------------------------------------------------------------\n // Cubes\n // ---------------------------------------------------------------------------\n\n readonly cubes = {\n /** List Cubes in a Space, with pagination metadata. */\n list: async (spaceId: string) => {\n const { data, error, response } = await this.raw.GET(\"/spaces/{spaceId}/cubes\", {\n params: { path: { spaceId } },\n });\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n if (data === undefined)\n throw krovaErrorFrom(response, { error: \"List Cubes response was empty.\" });\n return data;\n },\n\n /**\n * Create a Cube. Returns the created {@link Cube}.\n *\n * Set `terminationProtection: true` to opt the Cube out of\n * customer-initiated deletion. The flag is per-Cube; power-off, wake,\n * restart, snapshot, and restore remain allowed regardless.\n *\n * @param spaceId Target Space id.\n * @param body Cube spec — `{ name, image, resources, sshPublicKey, terminationProtection?, ... }`.\n * @param opts Optional `idempotencyKey` (max 255 chars, scoped per space).\n */\n create: async (\n spaceId: string,\n body: CreateCubeInput,\n opts?: { idempotencyKey?: string },\n ): Promise<Cube> => {\n const { data, error, response } = await this.raw.POST(\"/spaces/{spaceId}/cubes\", {\n params: {\n path: { spaceId },\n ...(opts?.idempotencyKey ? { header: { \"Idempotency-Key\": opts.idempotencyKey } } : {}),\n },\n body,\n });\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n const cube = data?.cube;\n if (!cube) {\n throw krovaErrorFrom(response, { error: \"Create Cube response had no `cube`.\" });\n }\n return cube;\n },\n\n /** Get a single Cube. Returns the {@link Cube}. */\n get: async (spaceId: string, cubeId: string): Promise<Cube> => {\n const { data, error, response } = await this.raw.GET(\"/spaces/{spaceId}/cubes/{cubeId}\", {\n params: { path: { spaceId, cubeId } },\n });\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n const cube = data?.cube;\n if (!cube) {\n throw krovaErrorFrom(response, { error: \"Get Cube response had no `cube`.\" });\n }\n return cube;\n },\n\n /**\n * Update the IN-CUBE port that SSH is forwarded to.\n *\n * `cubePort` is the port **inside** the Cube that sshd listens on — NOT the\n * host port you connect to. The host port is allocated by Krova and is not\n * changed by this call. Pointing this at a port nothing is listening on\n * inside the Cube will silently make SSH unreachable; the default is 22.\n *\n * The Krova Cloud API exposes no general Cube-mutation endpoint; the only\n * mutable Cube field over the API is this port, via\n * `PUT /spaces/{spaceId}/cubes/{cubeId}/ssh-port`. This helper maps to that\n * endpoint. (Compute resize / rename are not part of the public API.)\n */\n update: async (\n spaceId: string,\n cubeId: string,\n body: NonNullable<\n paths[\"/spaces/{spaceId}/cubes/{cubeId}/ssh-port\"][\"put\"][\"requestBody\"]\n >[\"content\"][\"application/json\"],\n ): Promise<unknown> => {\n const { data, error, response } = await this.raw.PUT(\n \"/spaces/{spaceId}/cubes/{cubeId}/ssh-port\",\n { params: { path: { spaceId, cubeId } }, body },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n return data;\n },\n\n /**\n * Toggle a Cube's termination-protection flag.\n *\n * The v1 API exposes `PATCH /spaces/{spaceId}/cubes/{cubeId}` with body\n * `{ terminationProtection: boolean }`. The call is idempotent: passing the\n * current value is a no-op server-side (no audit row is written).\n *\n * Returns the updated {@link Cube}, including `terminationProtection`,\n * `terminationProtectionChangedAt`, and `terminationProtectionChangedBy`.\n */\n setTerminationProtection: async (\n spaceId: string,\n cubeId: string,\n enabled: boolean,\n ): Promise<Cube> => {\n // The bundled OpenAPI spec does not declare a PATCH on this path; the\n // PATCH endpoint lands when the v1 control-plane PR ships. Until then\n // this is the typed escape hatch (`client.raw`) used everywhere else in\n // the SDK for spec-evolving surfaces — the runtime contract is asserted\n // by the integration suite.\n const { data, error, response } = await this.raw.PATCH(\"/spaces/{spaceId}/cubes/{cubeId}\", {\n params: { path: { spaceId, cubeId } },\n body: { terminationProtection: enabled } as SetTerminationProtectionInput,\n });\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n const cube = (data as { cube?: Cube } | undefined)?.cube;\n if (!cube) {\n throw krovaErrorFrom(response, {\n error: \"Set termination-protection response had no `cube`.\",\n });\n }\n return cube;\n },\n\n /**\n * Delete a Cube (asynchronous — deletion is enqueued).\n *\n * Throws {@link TerminationProtectedError} when the server returns `409`\n * with `error.code = \"termination_protected\"` — the Cube had its\n * termination-protection flag set and must be unprotected first. Any other\n * non-2xx response surfaces as a plain {@link KrovaError}.\n */\n delete: async (spaceId: string, cubeId: string) => {\n const { data, error, response } = await this.raw.DELETE(\"/spaces/{spaceId}/cubes/{cubeId}\", {\n params: { path: { spaceId, cubeId } },\n });\n if (error !== undefined || !response.ok) {\n // Most errors are the flat `{ error: string }` schema; the\n // termination-protected 409 is published as `{ error: { code, message,\n // cube } }`. Try the richer shape first; fall through to a plain\n // KrovaError on anything else so callers see a typed error for every\n // failure mode.\n const tpe = terminationProtectedFrom(response, cubeId, error);\n if (tpe) throw tpe;\n throw krovaErrorFrom(response, error);\n }\n if (data === undefined)\n throw krovaErrorFrom(response, { error: \"Delete Cube response was empty.\" });\n return data;\n },\n\n /** Power off a running Cube (asynchronous — power-off is enqueued). The Cube\n * becomes `stopped` (its host RAM is freed); start it again with `wake`. */\n powerOff: async (spaceId: string, cubeId: string): Promise<unknown> => {\n const { data, error, response } = await this.raw.POST(\n \"/spaces/{spaceId}/cubes/{cubeId}/power-off\",\n { params: { path: { spaceId, cubeId } } },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n return data;\n },\n\n /** Start a stopped Cube (asynchronous — start is enqueued). */\n /**\n * Restart a Cube (COLD restart).\n *\n * The hypervisor process is stopped and relaunched, so the Cube boots\n * against the host's current kernel. This is the only way a Cube picks up a\n * refreshed guest kernel after a platform image update — a `reboot` issued\n * INSIDE the Cube cannot do it, because Firecracker treats a guest reboot as\n * a shutdown and the kernel is supplied externally by the host.\n *\n * Disk state is preserved; only the kernel changes. The Cube must be\n * `running`. Concurrent restarts of the same Cube are rejected (409) rather\n * than queued twice.\n */\n restart: async (spaceId: string, cubeId: string): Promise<unknown> => {\n const { data, error, response } = await this.raw.POST(\n \"/spaces/{spaceId}/cubes/{cubeId}/restart\",\n { params: { path: { spaceId, cubeId } } },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n return data;\n },\n\n wake: async (spaceId: string, cubeId: string): Promise<unknown> => {\n const { data, error, response } = await this.raw.POST(\n \"/spaces/{spaceId}/cubes/{cubeId}/wake\",\n { params: { path: { spaceId, cubeId } } },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n return data;\n },\n\n /**\n * Get a Cube's SSH connection info — host, port, login user, and (when\n * available) the pinned host public keys for strict host-key verification.\n */\n ssh: async (spaceId: string, cubeId: string): Promise<CubeSshInfo> => {\n const { data, error, response } = await this.raw.GET(\"/spaces/{spaceId}/cubes/{cubeId}/ssh\", {\n params: { path: { spaceId, cubeId } },\n });\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n if (data === undefined)\n throw krovaErrorFrom(response, { error: \"Cube SSH-info response was empty.\" });\n return data;\n },\n\n /**\n * Restore a Cube's disk from one of its {@link Snapshot}s (asynchronous —\n * the restore is enqueued). The Cube's current disk is replaced.\n */\n restore: async (spaceId: string, cubeId: string, snapshotId: string) => {\n const { data, error, response } = await this.raw.POST(\n \"/spaces/{spaceId}/cubes/{cubeId}/restore\",\n { params: { path: { spaceId, cubeId } }, body: { snapshotId } },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n return data;\n },\n };\n\n /**\n * Resolve the {@link Space} this API key is scoped to — so you don't have to\n * hardcode a `spaceId`. Handy right after constructing the client:\n *\n * @example\n * ```ts\n * const space = await krova.getSpace();\n * const cubes = await krova.cubes.list(space.id);\n * ```\n */\n async getSpace(): Promise<Space> {\n const { data, error, response } = await this.raw.GET(\"/space\");\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n if (data === undefined) throw krovaErrorFrom(response, { error: \"Space response was empty.\" });\n return data;\n }\n\n // ---------------------------------------------------------------------------\n // Custom domains\n // ---------------------------------------------------------------------------\n\n readonly domains = {\n /** List the custom domains attached to a Cube. */\n list: async (spaceId: string, cubeId: string): Promise<Domain[]> => {\n const { data, error, response } = await this.raw.GET(\n \"/spaces/{spaceId}/cubes/{cubeId}/domains\",\n { params: { path: { spaceId, cubeId } } },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n return data?.domains ?? [];\n },\n\n /**\n * Attach a custom domain to a Cube. `domain` + `port` are required.\n *\n * Returns the domain AND the DNS records you must publish for it to work —\n * so you can create them in the same run, without a second call and without\n * hard-coding record shapes. A wildcard needs three; an exact host needs one.\n *\n * ⛔ BREAKING in 0.4.0: this used to resolve to `Domain`. It now resolves to\n * `{ domain, records }`, because for a wildcard two of the three records\n * (the ownership TXT and the `_acme-challenge` delegation) were not\n * derivable from anything the SDK returned — an integration had to read\n * them out of the docs and hope they still matched the server.\n */\n create: async (\n spaceId: string,\n cubeId: string,\n body: CreateDomainInput,\n ): Promise<{ domain: Domain; records: DnsRecord[] }> => {\n const { data, error, response } = await this.raw.POST(\n \"/spaces/{spaceId}/cubes/{cubeId}/domains\",\n { params: { path: { spaceId, cubeId } }, body },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n if (!data?.domain)\n throw krovaErrorFrom(response, { error: \"Create domain response had no `domain`.\" });\n return { domain: data.domain, records: data.records ?? [] };\n },\n\n /**\n * The DNS records a domain needs, each checked against live DNS.\n *\n * Poll this after publishing them: `summary.complete` turns true only once\n * every record is `found`. Each call performs real DNS lookups and is rate\n * limited, so poll on an interval rather than in a tight loop.\n */\n records: async (\n spaceId: string,\n cubeId: string,\n mappingId: string,\n ): Promise<{\n domain: string;\n isWildcard: boolean;\n records: DnsRecordStatus[];\n summary: { found: number; total: number; complete: boolean };\n checkedAt: string;\n }> => {\n const { data, error, response } = await this.raw.GET(\n \"/spaces/{spaceId}/cubes/{cubeId}/domains/{mappingId}/records\",\n { params: { path: { spaceId, cubeId, mappingId } } },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n if (!data) throw krovaErrorFrom(response, { error: \"Domain records response was empty.\" });\n return data;\n },\n\n /** Update a domain's per-domain proxy settings. */\n update: async (\n spaceId: string,\n cubeId: string,\n mappingId: string,\n body: UpdateDomainInput,\n ): Promise<Domain> => {\n const { data, error, response } = await this.raw.PATCH(\n \"/spaces/{spaceId}/cubes/{cubeId}/domains/{mappingId}\",\n { params: { path: { spaceId, cubeId, mappingId } }, body },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n if (!data?.domain)\n throw krovaErrorFrom(response, { error: \"Update domain response had no `domain`.\" });\n return data.domain;\n },\n\n /** Detach a custom domain from a Cube. */\n delete: async (spaceId: string, cubeId: string, mappingId: string) => {\n const { data, error, response } = await this.raw.DELETE(\n \"/spaces/{spaceId}/cubes/{cubeId}/domains/{mappingId}\",\n { params: { path: { spaceId, cubeId, mappingId } } },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n return data;\n },\n };\n\n // ---------------------------------------------------------------------------\n // Snapshots\n // ---------------------------------------------------------------------------\n\n readonly snapshots = {\n /** List a Cube's snapshots. */\n list: async (spaceId: string, cubeId: string): Promise<Snapshot[]> => {\n const { data, error, response } = await this.raw.GET(\n \"/spaces/{spaceId}/cubes/{cubeId}/snapshots\",\n { params: { path: { spaceId, cubeId } } },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n return data?.snapshots ?? [];\n },\n\n /** Create a snapshot of a Cube's disk (asynchronous — enqueued). */\n create: async (\n spaceId: string,\n cubeId: string,\n body?: { name?: string },\n ): Promise<Snapshot> => {\n const { data, error, response } = await this.raw.POST(\n \"/spaces/{spaceId}/cubes/{cubeId}/snapshots\",\n { params: { path: { spaceId, cubeId } }, body: body ?? {} },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n if (!data?.snapshot)\n throw krovaErrorFrom(response, { error: \"Create snapshot response had no `snapshot`.\" });\n return data.snapshot;\n },\n\n /** Delete a snapshot. */\n delete: async (spaceId: string, cubeId: string, snapshotId: string) => {\n const { data, error, response } = await this.raw.DELETE(\n \"/spaces/{spaceId}/cubes/{cubeId}/snapshots/{snapshotId}\",\n { params: { path: { spaceId, cubeId, snapshotId } } },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n return data;\n },\n };\n\n // ---------------------------------------------------------------------------\n // TCP port mappings\n // ---------------------------------------------------------------------------\n\n readonly tcpMappings = {\n /** List a Cube's TCP port mappings. */\n list: async (spaceId: string, cubeId: string): Promise<TcpMapping[]> => {\n const { data, error, response } = await this.raw.GET(\n \"/spaces/{spaceId}/cubes/{cubeId}/tcp-mappings\",\n { params: { path: { spaceId, cubeId } } },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n return data?.tcpMappings ?? [];\n },\n\n /**\n * Create a TCP port mapping exposing a Cube port on the host. `cubePort` is\n * required; `whitelistedIps` optionally restricts who can reach it.\n *\n * ⛔ Send `whitelistedIps`, not `whitelistIps`. The published spec named\n * the field `whitelistIps` while the server has always read\n * `whitelistedIps`, so every allow-listed mapping created through this SDK\n * was silently published WORLD-OPEN, with a 201 and no error (reproduced\n * on production 2026-09-02). The server now accepts both, so an older\n * client keeps working, but `whitelistIps` is deprecated.\n *\n * **Omitting the allow-list leaves the port open to the internet.** That is\n * the documented behaviour, not an oversight — but it means a typo in the\n * field name fails OPEN, which is exactly how the original defect survived.\n *\n * `udpEnabled` optionally forwards UDP traffic on the same host port\n * alongside TCP. It is optional and the server defaults it to `true` when\n * omitted — so leave it unset to get UDP forwarding, and pass `false`\n * only to explicitly disable it.\n */\n create: async (\n spaceId: string,\n cubeId: string,\n body: CreateTcpMappingInput,\n ): Promise<TcpMapping> => {\n const { data, error, response } = await this.raw.POST(\n \"/spaces/{spaceId}/cubes/{cubeId}/tcp-mappings\",\n { params: { path: { spaceId, cubeId } }, body },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n if (!data?.tcpMapping)\n throw krovaErrorFrom(response, {\n error: \"Create TCP mapping response had no `tcpMapping`.\",\n });\n return data.tcpMapping;\n },\n\n /** Delete a TCP port mapping. */\n delete: async (spaceId: string, cubeId: string, mappingId: string) => {\n const { data, error, response } = await this.raw.DELETE(\n \"/spaces/{spaceId}/cubes/{cubeId}/tcp-mappings/{mappingId}\",\n { params: { path: { spaceId, cubeId, mappingId } } },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n return data;\n },\n };\n\n // ---------------------------------------------------------------------------\n // Imports & backups (.cube archive import / export)\n // ---------------------------------------------------------------------------\n\n readonly imports = {\n /**\n * Start importing a `.cube` archive into a new Cube. Returns the multipart\n * upload target (`importId`, `uploadId`, presigned `parts`, …). Upload the\n * archive to those URLs, then call {@link imports.complete}.\n */\n create: async (\n spaceId: string,\n body: NonNullable<\n paths[\"/spaces/{spaceId}/cubes/imports\"][\"post\"][\"requestBody\"]\n >[\"content\"][\"application/json\"],\n ) => {\n const { data, error, response } = await this.raw.POST(\"/spaces/{spaceId}/cubes/imports\", {\n params: { path: { spaceId } },\n body,\n });\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n return data;\n },\n\n /** Get an in-progress or completed import by id. */\n get: async (spaceId: string, importId: string) => {\n const { data, error, response } = await this.raw.GET(\n \"/spaces/{spaceId}/cubes/imports/{importId}\",\n { params: { path: { spaceId, importId } } },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n return data;\n },\n\n /**\n * Finish an import after the archive has been uploaded — provisions the\n * Cube. Pass the uploaded `parts` (partNumber + etag) and the resolved\n * `config`.\n */\n complete: async (\n spaceId: string,\n importId: string,\n body: NonNullable<\n paths[\"/spaces/{spaceId}/cubes/imports/{importId}/complete\"][\"post\"][\"requestBody\"]\n >[\"content\"][\"application/json\"],\n ) => {\n const { data, error, response } = await this.raw.POST(\n \"/spaces/{spaceId}/cubes/imports/{importId}/complete\",\n { params: { path: { spaceId, importId } }, body },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n return data;\n },\n\n /** Cancel an in-progress import. */\n cancel: async (spaceId: string, importId: string) => {\n const { data, error, response } = await this.raw.DELETE(\n \"/spaces/{spaceId}/cubes/imports/{importId}\",\n { params: { path: { spaceId, importId } } },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n return data;\n },\n };\n\n readonly backups = {\n /** Get a time-limited download URL for a backup `.cube` archive. */\n download: async (spaceId: string, backupId: string) => {\n const { data, error, response } = await this.raw.GET(\n \"/spaces/{spaceId}/backups/{backupId}/download\",\n { params: { path: { spaceId, backupId } } },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n return data;\n },\n };\n\n // ---------------------------------------------------------------------------\n // Webhooks\n //\n // ⛔ The Krova Cloud API exposes no PATCH endpoint for webhooks, so this\n // group deliberately has no `update` or `rotateSecret` helper. To change a\n // webhook's URL, events, or signing secret, delete it and create a new\n // endpoint. The signing secret is returned ONCE — losing it means every\n // subsequent delivery will fail signature verification.\n // ---------------------------------------------------------------------------\n\n readonly webhooks = {\n /** List webhook endpoints in a Space. */\n list: async (spaceId: string): Promise<Webhook[]> => {\n const { data, error, response } = await this.raw.GET(\"/spaces/{spaceId}/webhooks\", {\n params: { path: { spaceId } },\n });\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n // The bundled spec does not declare a response body schema for this\n // path (only `description`); cast to the documented runtime shape.\n return (data as { webhooks?: Webhook[] } | undefined)?.webhooks ?? [];\n },\n\n /** Get a single webhook endpoint by id. Does NOT include the signing secret. */\n get: async (spaceId: string, endpointId: string): Promise<Webhook> => {\n const { data, error, response } = await this.raw.GET(\n \"/spaces/{spaceId}/webhooks/{endpointId}\",\n { params: { path: { spaceId, endpointId } } },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n // The bundled spec does not declare a response body schema for this\n // path (only `description`); cast to the documented runtime shape.\n const body = data as { webhook?: Webhook } | undefined;\n if (!body?.webhook)\n throw krovaErrorFrom(response, { error: \"Get webhook response had no `webhook`.\" });\n return body.webhook;\n },\n\n /**\n * Create a webhook endpoint. Returns the endpoint AND its signing secret.\n *\n * ⛔ The signing secret is shown ONLY at creation. Persist it immediately;\n * you cannot retrieve it later — `webhooks.get` deliberately omits it.\n * Losing the secret means every subsequent delivery will fail signature\n * verification, and you will have to delete the endpoint and create a new\n * one. An automation that swallows this helper's return value will lose\n * the secret on the next request, so the response is checked here and\n * throws if the server omits either the webhook or the secret.\n *\n * @param spaceId Target Space id.\n * @param body Webhook spec — `{ url, events, description? }`.\n */\n create: async (spaceId: string, body: CreateWebhookInput): Promise<WebhookWithSecret> => {\n const { data, error, response } = await this.raw.POST(\"/spaces/{spaceId}/webhooks\", {\n params: { path: { spaceId } },\n body,\n });\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n // The bundled spec does not declare a response body schema for this\n // path (only `description`); cast to the documented runtime shape.\n const payload = data as { webhook?: WebhookWithSecret } | undefined;\n if (!payload?.webhook)\n throw krovaErrorFrom(response, { error: \"Create webhook response had no `webhook`.\" });\n if (!payload.webhook.secret)\n throw krovaErrorFrom(response, {\n error:\n \"Create webhook response had no `secret` — capture it NOW; it is never returned again.\",\n });\n return payload.webhook;\n },\n\n /**\n * Delete a webhook endpoint (cascades delivery history).\n *\n * Resolves on any 2xx; the response body is intentionally not parsed\n * because the server returns `{ success: true }` but the caller does not\n * need it.\n */\n delete: async (spaceId: string, endpointId: string): Promise<void> => {\n const { error, response } = await this.raw.DELETE(\"/spaces/{spaceId}/webhooks/{endpointId}\", {\n params: { path: { spaceId, endpointId } },\n });\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n },\n\n /**\n * List recent deliveries for a webhook endpoint (last 30 days, max 100).\n *\n * @param spaceId Target Space id.\n * @param endpointId Webhook endpoint id.\n * @param opts Optional `limit` (1..100). Omit to let the server default to 50.\n */\n deliveries: async (\n spaceId: string,\n endpointId: string,\n opts?: { limit?: number },\n ): Promise<WebhookDelivery[]> => {\n const { data, error, response } = await this.raw.GET(\n \"/spaces/{spaceId}/webhooks/{endpointId}/deliveries\",\n {\n params: {\n path: { spaceId, endpointId },\n ...(opts?.limit !== undefined ? { query: { limit: opts.limit } } : {}),\n },\n },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n // The bundled spec does not declare a response body schema for this\n // path (only `description`); cast to the documented runtime shape.\n return (data as { deliveries?: WebhookDelivery[] } | undefined)?.deliveries ?? [];\n },\n };\n\n // ---------------------------------------------------------------------------\n // Public catalog (no auth required by the API, but the key is harmless)\n // ---------------------------------------------------------------------------\n\n readonly catalog = {\n /** List regions with available capacity. */\n regions: async () => {\n const { data, error, response } = await this.raw.GET(\"/regions\");\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n if (data === undefined)\n throw krovaErrorFrom(response, { error: \"Regions response was empty.\" });\n return data;\n },\n\n /** List available OS images. */\n images: async () => {\n const { data, error, response } = await this.raw.GET(\"/images\");\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n if (data === undefined)\n throw krovaErrorFrom(response, { error: \"Images response was empty.\" });\n return data;\n },\n\n /** Per-resource hourly rates and volume pricing tiers. */\n pricing: async () => {\n const { data, error, response } = await this.raw.GET(\"/pricing\");\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n if (data === undefined)\n throw krovaErrorFrom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T;;EAGA,SAAS,YAAY;GACnB,MAAM,EAAE,MAAM,OAAO,aAAa,MAAM,KAAK,IAAI,IAAI,UAAU;GAC/D,IAAI,UAAU,KAAA,KAAa,CAAC,SAAS,IAAI,MAAM,eAAe,UAAU,KAAK;GAC7E,IAAI,SAAS,KAAA,GACX,MAAM,eAAe,UAAU,EAAE,OAAO,8BAA8B,CAAC;GACzE,OAAO;EACT;CACF;AACF"}
1
+ {"version":3,"file":"index.cjs","names":["createClient"],"sources":["../src/error.ts","../src/client.ts"],"sourcesContent":["/**\n * The error body shape returned by the Krova Cloud API.\n *\n * Per the OpenAPI spec (`components.schemas.Error`), every non-2xx response\n * body is `{ \"error\": string }`.\n */\nexport interface KrovaErrorBody {\n error?: string;\n}\n\n/**\n * The richer 409 body shape the v1 API returns for a termination-protected\n * Cube. The base {@link KrovaErrorBody} only carries `error: string` because\n * the documented `Error` schema is flat; the DELETE handler returns this\n * nested form for `error.code = \"termination_protected\"`. The {@link KrovaError}\n * `body` slot stays a `KrovaErrorBody` for backwards compatibility — the\n * dedicated error class below carries the parsed cube fields instead.\n */\nexport interface TerminationProtectedErrorBody {\n error?: {\n code?: string;\n message?: string;\n cube?: {\n id?: string;\n terminationProtectionChangedAt?: string | null;\n terminationProtectionChangedBy?: string | null;\n };\n };\n}\n\n/**\n * Error thrown by the ergonomic {@link KrovaClient} helpers when the API\n * responds with a non-2xx status.\n *\n * The raw openapi-fetch client (`client.raw`) never throws — it returns\n * `{ data, error, response }`. The helpers wrap that and throw `KrovaError`\n * so callers can `try/catch`.\n */\nexport class KrovaError extends Error {\n /** HTTP status code of the failing response. */\n readonly status: number;\n\n /**\n * A machine-readable error code, when the API surfaces one via the\n * `X-Error-Code` response header. The documented error body only carries a\n * human-readable `error` string, so this is best-effort.\n */\n readonly code?: string;\n\n /**\n * The request id from the `X-Request-Id` response header, when present.\n * Useful when contacting Krova Cloud support about a specific failure.\n */\n readonly requestId?: string;\n\n /** The parsed JSON error body, when the response had one. */\n readonly body?: KrovaErrorBody;\n\n /** The raw `Response` object, for callers that need headers/url/etc. */\n readonly response?: Response;\n\n constructor(\n message: string,\n init: {\n status: number;\n code?: string;\n requestId?: string;\n body?: KrovaErrorBody;\n response?: Response;\n },\n ) {\n super(message);\n this.name = \"KrovaError\";\n this.status = init.status;\n this.code = init.code;\n this.requestId = init.requestId;\n this.body = init.body;\n this.response = init.response;\n // Restore prototype chain for instanceof across compilation targets.\n Object.setPrototypeOf(this, KrovaError.prototype);\n }\n}\n\n/**\n * Build a {@link KrovaError} from a failing response + parsed error body.\n *\n * `body` is `unknown` rather than {@link KrovaErrorBody} because not every\n * documented error response is the flat `{ error: string }` shape — DELETE\n * /cubes/{cubeId} publishes a 409 whose `error` is an object. This function\n * already coped with that at runtime; typing the parameter narrowly only meant\n * the call sites had to lie. Widening accepts strictly more, so no caller\n * breaks.\n *\n * `body` is carried onto the error only when it really is the flat shape, so\n * {@link KrovaError.body} never advertises a `string` that is not there. A\n * caller that needs the raw payload of some other shape has `response`.\n */\nexport function krovaErrorFrom(response: Response, body: unknown): KrovaError {\n const flat =\n typeof body === \"object\" && body !== null && typeof (body as KrovaErrorBody).error === \"string\"\n ? (body as KrovaErrorBody)\n : undefined;\n const message =\n flat?.error || response.statusText || `Request failed with status ${response.status}`;\n return new KrovaError(message, {\n status: response.status,\n code: response.headers.get(\"x-error-code\") ?? undefined,\n requestId: response.headers.get(\"x-request-id\") ?? undefined,\n body: flat,\n response,\n });\n}\n\n/**\n * Thrown by `client.cubes.delete` when the server rejects a delete with\n * `409` and `error.code = \"termination_protected\"`.\n *\n * The customer-facing contract is: a Cube with `terminationProtection = true`\n * cannot be deleted until the flag is turned off. The CLI and MCP surface the\n * server's message verbatim, so callers can switch on `code` rather than\n * parsing prose. `cubeId` / `changedAt` / `changedBy` are best-effort — a\n * defensive server (or an older control plane) may omit the `cube` block, in\n * which case the SDK falls back to the id the call was made with and leaves\n * the two timestamps `null`.\n */\nexport class TerminationProtectedError extends KrovaError {\n /** The id of the Cube the customer tried to delete. */\n readonly cubeId: string;\n\n /**\n * When the flag was last changed (`terminationProtectionChangedAt` on the\n * Cube row). `null` when the server's 409 body omitted it.\n */\n readonly changedAt: string | null;\n\n /**\n * Who last changed the flag (`terminationProtectionChangedBy` on the Cube\n * row — typically `\"user:<id>\"`). `null` when the server's 409 body omitted\n * it.\n */\n readonly changedBy: string | null;\n\n constructor(\n message: string,\n init: {\n status: number;\n code: string;\n requestId?: string;\n body?: KrovaErrorBody;\n response?: Response;\n cubeId: string;\n changedAt: string | null;\n changedBy: string | null;\n },\n ) {\n super(message, {\n status: init.status,\n code: init.code,\n ...(init.requestId ? { requestId: init.requestId } : {}),\n ...(init.body ? { body: init.body } : {}),\n ...(init.response ? { response: init.response } : {}),\n });\n this.name = \"TerminationProtectedError\";\n this.cubeId = init.cubeId;\n this.changedAt = init.changedAt;\n this.changedBy = init.changedBy;\n Object.setPrototypeOf(this, TerminationProtectedError.prototype);\n }\n}\n\n/**\n * Try to interpret a failing DELETE response as the v1 API's\n * termination-protected 409. Returns a {@link TerminationProtectedError} when\n * the body shape matches, `null` otherwise (the caller then falls back to a\n * plain {@link KrovaError}).\n *\n * The 409 body is published as `{ error: { code, message, cube: { … } } }`,\n * but the bundled OpenAPI spec only declares `{ error: string }` for the\n * generic `Error` schema — so the cast is best-effort and we tolerate\n * missing optional fields.\n */\nexport function terminationProtectedFrom(\n response: Response,\n cubeId: string,\n body: unknown,\n): TerminationProtectedError | null {\n if (response.status !== 409 || body === null || typeof body !== \"object\") return null;\n const errBlock = (body as TerminationProtectedErrorBody).error;\n if (!errBlock || typeof errBlock !== \"object\") return null;\n if (errBlock.code !== \"termination_protected\") return null;\n const cubeBlock = errBlock.cube;\n const message =\n (typeof errBlock.message === \"string\" && errBlock.message) ||\n `Cube ${cubeId} has termination protection on. Turn it off before deleting.`;\n return new TerminationProtectedError(message, {\n status: 409,\n code: \"termination_protected\",\n requestId: response.headers.get(\"x-request-id\") ?? undefined,\n body: { error: message },\n response,\n cubeId: typeof cubeBlock?.id === \"string\" ? cubeBlock.id : cubeId,\n changedAt:\n typeof cubeBlock?.terminationProtectionChangedAt === \"string\"\n ? cubeBlock.terminationProtectionChangedAt\n : null,\n changedBy:\n typeof cubeBlock?.terminationProtectionChangedBy === \"string\"\n ? cubeBlock.terminationProtectionChangedBy\n : null,\n });\n}\n","import createClient, { type Client, type Middleware } from \"openapi-fetch\";\nimport { krovaErrorFrom, terminationProtectedFrom } from \"./error.js\";\nimport type { components, paths } from \"./generated/types.js\";\n\n/** The Cube resource, as defined in the Krova Cloud OpenAPI spec. */\nexport type Cube = components[\"schemas\"][\"Cube\"];\n\n/** A region with available capacity (from the catalog). */\nexport type Region = components[\"schemas\"][\"Region\"];\n\n/** A selectable OS image (from the catalog). */\nexport type Image = components[\"schemas\"][\"Image\"];\n\n/** A volume-pricing tier (from the catalog). */\nexport type PricingTier = components[\"schemas\"][\"PricingTier\"];\n\n/** Pagination envelope returned alongside a Cube list. */\nexport type Pagination = components[\"schemas\"][\"Pagination\"];\n\n/** A Space — the tenancy an API key is scoped to. */\nexport type Space = components[\"schemas\"][\"Space\"];\n\n/** A Cube's SSH connection info (host, port, user, and pinned host keys). */\nexport type CubeSshInfo = components[\"schemas\"][\"CubeSshInfo\"];\n\n/** A custom domain attached to a Cube. */\nexport type Domain = components[\"schemas\"][\"Domain\"];\n\n/**\n * One DNS record you must publish for a domain to work.\n *\n * An ordinary subdomain needs one CNAME. A wildcard needs three: an ownership\n * TXT, the routing CNAME, and an `_acme-challenge` CNAME that lets Krova issue\n * and renew its certificate.\n *\n * ⛔ `mustBeGrey` and `proxyOk` are deliberate OPPOSITES, and automation needs\n * both. The routing record may sit behind Cloudflare's proxy (orange); the\n * `_acme-challenge` record must not, because a proxied one answers with\n * Cloudflare's addresses and the certificate authority finds nothing there.\n */\nexport type DnsRecord = components[\"schemas\"][\"DnsRecord\"];\n\n/**\n * A {@link DnsRecord} plus what Krova can currently see in public DNS.\n *\n * ⛔ `state: \"missing\"` means NOT PUBLISHED YET — the expected state before you\n * create the record, never an error. `state: \"unknown\"` means Krova could not\n * complete the lookup, which is never a statement about your DNS. Surfacing\n * either to your own users as a failure would be wrong.\n */\nexport type DnsRecordStatus = components[\"schemas\"][\"DnsRecordStatus\"];\n\n/** A snapshot of a Cube's disk. */\nexport type Snapshot = components[\"schemas\"][\"Snapshot\"];\n\n/** A TCP port mapping exposing a Cube port on the host. */\nexport type TcpMapping = components[\"schemas\"][\"TcpMapping\"];\n\n/**\n * A backup: a Cube's disk and configuration, kept after the Cube is gone and\n * redeployable as a new Cube. `sharedFromBackupId` is set on a copy another\n * space shared with this one.\n */\nexport type Backup = components[\"schemas\"][\"Backup\"];\n\n/**\n * A request to give another space its own copy of a backup.\n *\n * `counterpartySpaceName` is the other side: the destination on an outgoing\n * share, the source on an incoming one. `copyBackupId` is set once accepted.\n */\nexport type BackupShare = components[\"schemas\"][\"BackupShare\"];\n\n/** Pending, unexpired backup shares into and out of a space. */\nexport interface BackupShareList {\n incoming: BackupShare[];\n outgoing: BackupShare[];\n}\n\n/** An accepted share, and the destination space's new copy. */\nexport interface AcceptedBackupShare {\n share: BackupShare;\n backup: Backup;\n}\n\n/** Request body for attaching a custom domain to a Cube. */\nexport type CreateDomainInput = NonNullable<\n paths[\"/spaces/{spaceId}/cubes/{cubeId}/domains\"][\"post\"][\"requestBody\"]\n>[\"content\"][\"application/json\"];\n\n/** Request body for updating a custom domain's proxy settings. */\nexport type UpdateDomainInput = NonNullable<\n paths[\"/spaces/{spaceId}/cubes/{cubeId}/domains/{mappingId}\"][\"patch\"][\"requestBody\"]\n>[\"content\"][\"application/json\"];\n\n/** Request body for creating a TCP port mapping. */\nexport type CreateTcpMappingInput = NonNullable<\n paths[\"/spaces/{spaceId}/cubes/{cubeId}/tcp-mappings\"][\"post\"][\"requestBody\"]\n>[\"content\"][\"application/json\"];\n\n/**\n * Request body for `POST /spaces/{spaceId}/cubes` as defined in the OpenAPI\n * spec, with `terminationProtection` intersected on because the bundled spec\n * does not declare the field but the v1 API accepts it. A boolean `false` (or\n * omission) leaves the Cube in the documented default-unprotected state; `true`\n * opts the Cube out of customer-initiated deletion until the flag is toggled\n * back via `cubes.setTerminationProtection`.\n */\nexport type CreateCubeInput = NonNullable<\n paths[\"/spaces/{spaceId}/cubes\"][\"post\"][\"requestBody\"]\n>[\"content\"][\"application/json\"] & {\n /** Opt this Cube out of customer-initiated deletion (default `false`). */\n terminationProtection?: boolean;\n};\n\n/**\n * Request body for `PATCH /spaces/{spaceId}/cubes/{cubeId}` — the v1 API\n * endpoint the SDK uses to toggle termination protection on an existing Cube.\n * The bundled OpenAPI spec does not declare a PATCH on this path yet, so the\n * type is structurally derived from the {@link Cube} fields the API echoes\n * back. Only `terminationProtection` is exposed by `setTerminationProtection`;\n * future toggles can extend this without breaking the public signature.\n */\nexport type SetTerminationProtectionInput = {\n terminationProtection: boolean;\n};\n\n/**\n * A webhook endpoint subscribed to Space events.\n *\n * ⛔ Runtime discrepancy: the bundled OpenAPI spec does not declare\n * `description`, but `GET /spaces/{spaceId}/webhooks/{endpointId}` includes\n * it as `string | null`. The schema-derived type is extended here so callers\n * reading a single webhook see the field; it is optional so list responses\n * (which omit it) still typecheck.\n */\nexport type Webhook = components[\"schemas\"][\"Webhook\"] & {\n description?: string | null;\n};\n\n/** A recorded webhook delivery attempt (last 30 days of history). */\nexport type WebhookDelivery = components[\"schemas\"][\"WebhookDelivery\"];\n\n/**\n * Request body for creating a webhook endpoint.\n *\n * Derived from `paths[\"/spaces/{spaceId}/webhooks\"][\"post\"]` exactly like\n * {@link CreateDomainInput}; `description` is intersected on because the\n * bundled spec omits it but the runtime accepts it.\n */\nexport type CreateWebhookInput = NonNullable<\n paths[\"/spaces/{spaceId}/webhooks\"][\"post\"][\"requestBody\"]\n>[\"content\"][\"application/json\"] & {\n /** Optional human-readable label shown on the endpoint. */\n description?: string;\n};\n\n/** A webhook plus its signing secret. Returned ONLY by {@link KrovaClient.webhooks}.create. */\nexport type WebhookWithSecret = Webhook & { secret: string };\n\n/** Default API base URL — the single `servers[0].url` from the OpenAPI spec. */\nexport const DEFAULT_BASE_URL = \"https://krova.cloud/api/v1\";\n\n/**\n * How the API key is presented to the server.\n *\n * - `\"x-api-key\"` (default) — `X-API-KEY: <key>`, matching the spec's\n * `components.securitySchemes.ApiKeyAuth` (an `apiKey` header named\n * `X-API-KEY`).\n * - `\"bearer\"` — `Authorization: Bearer <key>`, for gateways that expect it.\n */\nexport type AuthScheme = \"x-api-key\" | \"bearer\";\n\nexport interface KrovaClientOptions {\n /**\n * Your Krova Cloud API key (a `kro_...` token). Keys are scoped per Space\n * and inherit the permissions of the membership that created them.\n */\n apiKey: string;\n /** Override the API base URL. Defaults to {@link DEFAULT_BASE_URL}. */\n baseUrl?: string;\n /**\n * Auth header scheme. Defaults to `\"x-api-key\"` (the spec's scheme).\n */\n authScheme?: AuthScheme;\n /**\n * Max automatic retries on retryable statuses (429, 503).\n * Defaults to 2. Set to 0 to disable retries.\n */\n maxRetries?: number;\n /**\n * A custom `fetch` implementation (e.g. for tests or a proxy). Defaults to\n * the global `fetch`.\n */\n fetch?: typeof fetch;\n}\n\n/** Statuses the retry middleware treats as transient. */\nconst RETRYABLE_STATUSES = new Set([429, 503]);\n/** Fallback backoff (ms) when the server sends no `Retry-After` header. */\nconst BASE_BACKOFF_MS = 500;\n/** Cap on any single backoff wait (ms), to keep retries \"small but real\". */\nconst MAX_BACKOFF_MS = 10_000;\n\nconst sleep = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms));\n\n/**\n * Parse a `Retry-After` header (RFC 7231): either delta-seconds or an\n * HTTP-date. Returns milliseconds to wait, or `null` if absent/unparseable.\n */\nfunction parseRetryAfterMs(headerValue: string | null): number | null {\n if (!headerValue) return null;\n const seconds = Number(headerValue);\n if (Number.isFinite(seconds)) return Math.max(0, seconds * 1000);\n const dateMs = Date.parse(headerValue);\n if (Number.isFinite(dateMs)) return Math.max(0, dateMs - Date.now());\n return null;\n}\n\nfunction authMiddleware(apiKey: string, scheme: AuthScheme): Middleware {\n return {\n onRequest({ request }) {\n if (scheme === \"bearer\") {\n request.headers.set(\"Authorization\", `Bearer ${apiKey}`);\n } else {\n request.headers.set(\"X-API-KEY\", apiKey);\n }\n return request;\n },\n };\n}\n\n/**\n * Retry middleware: on a retryable status, wait (honoring `Retry-After` when\n * present, else exponential backoff) and re-issue the request.\n *\n * A retried request may have a body (POST/PUT/DELETE — exactly the mutating,\n * rate-limited endpoints). By the time `onResponse` runs, the request that was\n * handed to `fetch` has had its body stream consumed, so `request.clone()` here\n * throws `TypeError: unusable`. To re-issue it we stash a *pristine* clone in\n * `onRequest` — captured before the body is read — keyed by openapi-fetch's\n * per-request `id`, and clone from that pristine copy on each attempt.\n */\nfunction retryMiddleware(maxRetries: number, doFetch: typeof fetch): Middleware {\n const pristine = new Map<string, Request>();\n return {\n onRequest({ request, id }) {\n pristine.set(id, request.clone());\n return request;\n },\n onError({ id }) {\n // fetch rejected (network error) — no onResponse will fire; don't leak.\n pristine.delete(id);\n },\n async onResponse({ request, response, id }) {\n const original = pristine.get(id) ?? request;\n pristine.delete(id);\n if (maxRetries <= 0 || !RETRYABLE_STATUSES.has(response.status)) {\n return response;\n }\n let current = response;\n for (let attempt = 1; attempt <= maxRetries; attempt++) {\n if (!RETRYABLE_STATUSES.has(current.status)) break;\n const retryAfterMs = parseRetryAfterMs(current.headers.get(\"retry-after\"));\n const backoff = Math.min(BASE_BACKOFF_MS * 2 ** (attempt - 1), MAX_BACKOFF_MS);\n // Cap the wait — including a server-supplied `Retry-After` — so a hostile\n // or misconfigured server can't park the client for minutes/hours.\n await sleep(Math.min(retryAfterMs ?? backoff, MAX_BACKOFF_MS));\n // Re-issue from the pristine clone; `.clone()` keeps it reusable across\n // multiple attempts.\n current = await doFetch(original.clone());\n }\n return current;\n },\n };\n}\n\n/**\n * A typed client for the Krova Cloud API.\n *\n * @example\n * ```ts\n * const krova = new KrovaClient({ apiKey: \"kro_...\" });\n * const cubes = await krova.cubes.list(\"space_123\");\n * ```\n */\nexport class KrovaClient {\n /**\n * The underlying openapi-fetch client — a fully typed escape hatch to every\n * path in the spec. Returns `{ data, error, response }` and never throws.\n *\n * @example\n * ```ts\n * const { data, error } = await krova.raw.GET(\n * \"/spaces/{spaceId}/cubes/{cubeId}\",\n * { params: { path: { spaceId, cubeId } } },\n * );\n * ```\n */\n readonly raw: Client<paths>;\n\n /** The resolved base URL in use. */\n readonly baseUrl: string;\n\n constructor(options: KrovaClientOptions) {\n if (!options?.apiKey) {\n throw new Error(\"KrovaClient: `apiKey` is required.\");\n }\n this.baseUrl = options.baseUrl ?? DEFAULT_BASE_URL;\n const doFetch = options.fetch ?? globalThis.fetch;\n const maxRetries = options.maxRetries ?? 2;\n\n this.raw = createClient<paths>({\n baseUrl: this.baseUrl,\n // SECURITY: never auto-follow redirects. The Krova Cloud API is a plain\n // JSON API and never legitimately 3xx's a data call. Following a redirect\n // would resend the `X-API-KEY` header to the redirect target — and unlike\n // `Authorization`, `Cookie`, and `Proxy-Authorization`, the Fetch spec does\n // NOT strip a custom header like `X-API-KEY` on a cross-origin redirect\n // (verified against undici/Node fetch). A compromised/misconfigured proxy,\n // an open-redirect on the API, or a MITM could otherwise exfiltrate the key\n // to an attacker's host. With `\"manual\"`, a redirect comes back as a\n // non-ok response and the helpers throw `KrovaError` instead of leaking.\n redirect: \"manual\",\n ...(options.fetch ? { fetch: options.fetch } : {}),\n });\n this.raw.use(authMiddleware(options.apiKey, options.authScheme ?? \"x-api-key\"));\n if (maxRetries > 0) {\n this.raw.use(retryMiddleware(maxRetries, doFetch));\n }\n }\n\n // ---------------------------------------------------------------------------\n // Cubes\n // ---------------------------------------------------------------------------\n\n readonly cubes = {\n /** List Cubes in a Space, with pagination metadata. */\n list: async (spaceId: string) => {\n const { data, error, response } = await this.raw.GET(\"/spaces/{spaceId}/cubes\", {\n params: { path: { spaceId } },\n });\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n if (data === undefined)\n throw krovaErrorFrom(response, { error: \"List Cubes response was empty.\" });\n return data;\n },\n\n /**\n * Create a Cube. Returns the created {@link Cube}.\n *\n * Set `terminationProtection: true` to opt the Cube out of\n * customer-initiated deletion. The flag is per-Cube; power-off, wake,\n * restart, snapshot, and restore remain allowed regardless.\n *\n * @param spaceId Target Space id.\n * @param body Cube spec — `{ name, image, resources, sshPublicKey, terminationProtection?, ... }`.\n * @param opts Optional `idempotencyKey` (max 255 chars, scoped per space).\n */\n create: async (\n spaceId: string,\n body: CreateCubeInput,\n opts?: { idempotencyKey?: string },\n ): Promise<Cube> => {\n const { data, error, response } = await this.raw.POST(\"/spaces/{spaceId}/cubes\", {\n params: {\n path: { spaceId },\n ...(opts?.idempotencyKey ? { header: { \"Idempotency-Key\": opts.idempotencyKey } } : {}),\n },\n body,\n });\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n const cube = data?.cube;\n if (!cube) {\n throw krovaErrorFrom(response, { error: \"Create Cube response had no `cube`.\" });\n }\n return cube;\n },\n\n /** Get a single Cube. Returns the {@link Cube}. */\n get: async (spaceId: string, cubeId: string): Promise<Cube> => {\n const { data, error, response } = await this.raw.GET(\"/spaces/{spaceId}/cubes/{cubeId}\", {\n params: { path: { spaceId, cubeId } },\n });\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n const cube = data?.cube;\n if (!cube) {\n throw krovaErrorFrom(response, { error: \"Get Cube response had no `cube`.\" });\n }\n return cube;\n },\n\n /**\n * Update the IN-CUBE port that SSH is forwarded to.\n *\n * `cubePort` is the port **inside** the Cube that sshd listens on — NOT the\n * host port you connect to. The host port is allocated by Krova and is not\n * changed by this call. Pointing this at a port nothing is listening on\n * inside the Cube will silently make SSH unreachable; the default is 22.\n *\n * The Krova Cloud API exposes no general Cube-mutation endpoint; the only\n * mutable Cube field over the API is this port, via\n * `PUT /spaces/{spaceId}/cubes/{cubeId}/ssh-port`. This helper maps to that\n * endpoint. (Compute resize / rename are not part of the public API.)\n */\n update: async (\n spaceId: string,\n cubeId: string,\n body: NonNullable<\n paths[\"/spaces/{spaceId}/cubes/{cubeId}/ssh-port\"][\"put\"][\"requestBody\"]\n >[\"content\"][\"application/json\"],\n ): Promise<unknown> => {\n const { data, error, response } = await this.raw.PUT(\n \"/spaces/{spaceId}/cubes/{cubeId}/ssh-port\",\n { params: { path: { spaceId, cubeId } }, body },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n return data;\n },\n\n /**\n * Toggle a Cube's termination-protection flag.\n *\n * The v1 API exposes `PATCH /spaces/{spaceId}/cubes/{cubeId}` with body\n * `{ terminationProtection: boolean }`. The call is idempotent: passing the\n * current value is a no-op server-side (no audit row is written).\n *\n * Returns the updated {@link Cube}, including `terminationProtection`,\n * `terminationProtectionChangedAt`, and `terminationProtectionChangedBy`.\n */\n setTerminationProtection: async (\n spaceId: string,\n cubeId: string,\n enabled: boolean,\n ): Promise<Cube> => {\n // The bundled OpenAPI spec does not declare a PATCH on this path; the\n // PATCH endpoint lands when the v1 control-plane PR ships. Until then\n // this is the typed escape hatch (`client.raw`) used everywhere else in\n // the SDK for spec-evolving surfaces — the runtime contract is asserted\n // by the integration suite.\n const { data, error, response } = await this.raw.PATCH(\"/spaces/{spaceId}/cubes/{cubeId}\", {\n params: { path: { spaceId, cubeId } },\n body: { terminationProtection: enabled } as SetTerminationProtectionInput,\n });\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n const cube = (data as { cube?: Cube } | undefined)?.cube;\n if (!cube) {\n throw krovaErrorFrom(response, {\n error: \"Set termination-protection response had no `cube`.\",\n });\n }\n return cube;\n },\n\n /**\n * Delete a Cube (asynchronous — deletion is enqueued).\n *\n * Throws {@link TerminationProtectedError} when the server returns `409`\n * with `error.code = \"termination_protected\"` — the Cube had its\n * termination-protection flag set and must be unprotected first. Any other\n * non-2xx response surfaces as a plain {@link KrovaError}.\n */\n delete: async (spaceId: string, cubeId: string) => {\n const { data, error, response } = await this.raw.DELETE(\"/spaces/{spaceId}/cubes/{cubeId}\", {\n params: { path: { spaceId, cubeId } },\n });\n if (error !== undefined || !response.ok) {\n // Most errors are the flat `{ error: string }` schema; the\n // termination-protected 409 is published as `{ error: { code, message,\n // cube } }`. Try the richer shape first; fall through to a plain\n // KrovaError on anything else so callers see a typed error for every\n // failure mode.\n const tpe = terminationProtectedFrom(response, cubeId, error);\n if (tpe) throw tpe;\n throw krovaErrorFrom(response, error);\n }\n if (data === undefined)\n throw krovaErrorFrom(response, { error: \"Delete Cube response was empty.\" });\n return data;\n },\n\n /** Power off a running Cube (asynchronous — power-off is enqueued). The Cube\n * becomes `stopped` (its host RAM is freed); start it again with `wake`. */\n powerOff: async (spaceId: string, cubeId: string): Promise<unknown> => {\n const { data, error, response } = await this.raw.POST(\n \"/spaces/{spaceId}/cubes/{cubeId}/power-off\",\n { params: { path: { spaceId, cubeId } } },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n return data;\n },\n\n /** Start a stopped Cube (asynchronous — start is enqueued). */\n /**\n * Restart a Cube (COLD restart).\n *\n * The hypervisor process is stopped and relaunched, so the Cube boots\n * against the host's current kernel. This is the only way a Cube picks up a\n * refreshed guest kernel after a platform image update — a `reboot` issued\n * INSIDE the Cube cannot do it, because Firecracker treats a guest reboot as\n * a shutdown and the kernel is supplied externally by the host.\n *\n * Disk state is preserved; only the kernel changes. The Cube must be\n * `running`. Concurrent restarts of the same Cube are rejected (409) rather\n * than queued twice.\n */\n restart: async (spaceId: string, cubeId: string): Promise<unknown> => {\n const { data, error, response } = await this.raw.POST(\n \"/spaces/{spaceId}/cubes/{cubeId}/restart\",\n { params: { path: { spaceId, cubeId } } },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n return data;\n },\n\n wake: async (spaceId: string, cubeId: string): Promise<unknown> => {\n const { data, error, response } = await this.raw.POST(\n \"/spaces/{spaceId}/cubes/{cubeId}/wake\",\n { params: { path: { spaceId, cubeId } } },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n return data;\n },\n\n /**\n * Get a Cube's SSH connection info — host, port, login user, and (when\n * available) the pinned host public keys for strict host-key verification.\n */\n ssh: async (spaceId: string, cubeId: string): Promise<CubeSshInfo> => {\n const { data, error, response } = await this.raw.GET(\"/spaces/{spaceId}/cubes/{cubeId}/ssh\", {\n params: { path: { spaceId, cubeId } },\n });\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n if (data === undefined)\n throw krovaErrorFrom(response, { error: \"Cube SSH-info response was empty.\" });\n return data;\n },\n\n /**\n * Restore a Cube's disk from one of its {@link Snapshot}s (asynchronous —\n * the restore is enqueued). The Cube's current disk is replaced.\n */\n restore: async (spaceId: string, cubeId: string, snapshotId: string) => {\n const { data, error, response } = await this.raw.POST(\n \"/spaces/{spaceId}/cubes/{cubeId}/restore\",\n { params: { path: { spaceId, cubeId } }, body: { snapshotId } },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n return data;\n },\n };\n\n /**\n * Resolve the {@link Space} this API key is scoped to — so you don't have to\n * hardcode a `spaceId`. Handy right after constructing the client:\n *\n * @example\n * ```ts\n * const space = await krova.getSpace();\n * const cubes = await krova.cubes.list(space.id);\n * ```\n */\n async getSpace(): Promise<Space> {\n const { data, error, response } = await this.raw.GET(\"/space\");\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n if (data === undefined) throw krovaErrorFrom(response, { error: \"Space response was empty.\" });\n return data;\n }\n\n // ---------------------------------------------------------------------------\n // Custom domains\n // ---------------------------------------------------------------------------\n\n readonly domains = {\n /** List the custom domains attached to a Cube. */\n list: async (spaceId: string, cubeId: string): Promise<Domain[]> => {\n const { data, error, response } = await this.raw.GET(\n \"/spaces/{spaceId}/cubes/{cubeId}/domains\",\n { params: { path: { spaceId, cubeId } } },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n return data?.domains ?? [];\n },\n\n /**\n * Attach a custom domain to a Cube. `domain` + `port` are required.\n *\n * Returns the domain AND the DNS records you must publish for it to work —\n * so you can create them in the same run, without a second call and without\n * hard-coding record shapes. A wildcard needs three; an exact host needs one.\n *\n * ⛔ BREAKING in 0.4.0: this used to resolve to `Domain`. It now resolves to\n * `{ domain, records }`, because for a wildcard two of the three records\n * (the ownership TXT and the `_acme-challenge` delegation) were not\n * derivable from anything the SDK returned — an integration had to read\n * them out of the docs and hope they still matched the server.\n */\n create: async (\n spaceId: string,\n cubeId: string,\n body: CreateDomainInput,\n ): Promise<{ domain: Domain; records: DnsRecord[] }> => {\n const { data, error, response } = await this.raw.POST(\n \"/spaces/{spaceId}/cubes/{cubeId}/domains\",\n { params: { path: { spaceId, cubeId } }, body },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n if (!data?.domain)\n throw krovaErrorFrom(response, { error: \"Create domain response had no `domain`.\" });\n return { domain: data.domain, records: data.records ?? [] };\n },\n\n /**\n * The DNS records a domain needs, each checked against live DNS.\n *\n * Poll this after publishing them: `summary.complete` turns true only once\n * every record is `found`. Each call performs real DNS lookups and is rate\n * limited, so poll on an interval rather than in a tight loop.\n */\n records: async (\n spaceId: string,\n cubeId: string,\n mappingId: string,\n ): Promise<{\n domain: string;\n isWildcard: boolean;\n records: DnsRecordStatus[];\n summary: { found: number; total: number; complete: boolean };\n checkedAt: string;\n }> => {\n const { data, error, response } = await this.raw.GET(\n \"/spaces/{spaceId}/cubes/{cubeId}/domains/{mappingId}/records\",\n { params: { path: { spaceId, cubeId, mappingId } } },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n if (!data) throw krovaErrorFrom(response, { error: \"Domain records response was empty.\" });\n return data;\n },\n\n /** Update a domain's per-domain proxy settings. */\n update: async (\n spaceId: string,\n cubeId: string,\n mappingId: string,\n body: UpdateDomainInput,\n ): Promise<Domain> => {\n const { data, error, response } = await this.raw.PATCH(\n \"/spaces/{spaceId}/cubes/{cubeId}/domains/{mappingId}\",\n { params: { path: { spaceId, cubeId, mappingId } }, body },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n if (!data?.domain)\n throw krovaErrorFrom(response, { error: \"Update domain response had no `domain`.\" });\n return data.domain;\n },\n\n /** Detach a custom domain from a Cube. */\n delete: async (spaceId: string, cubeId: string, mappingId: string) => {\n const { data, error, response } = await this.raw.DELETE(\n \"/spaces/{spaceId}/cubes/{cubeId}/domains/{mappingId}\",\n { params: { path: { spaceId, cubeId, mappingId } } },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n return data;\n },\n };\n\n // ---------------------------------------------------------------------------\n // Snapshots\n // ---------------------------------------------------------------------------\n\n readonly snapshots = {\n /** List a Cube's snapshots. */\n list: async (spaceId: string, cubeId: string): Promise<Snapshot[]> => {\n const { data, error, response } = await this.raw.GET(\n \"/spaces/{spaceId}/cubes/{cubeId}/snapshots\",\n { params: { path: { spaceId, cubeId } } },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n return data?.snapshots ?? [];\n },\n\n /** Create a snapshot of a Cube's disk (asynchronous — enqueued). */\n create: async (\n spaceId: string,\n cubeId: string,\n body?: { name?: string },\n ): Promise<Snapshot> => {\n const { data, error, response } = await this.raw.POST(\n \"/spaces/{spaceId}/cubes/{cubeId}/snapshots\",\n { params: { path: { spaceId, cubeId } }, body: body ?? {} },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n if (!data?.snapshot)\n throw krovaErrorFrom(response, { error: \"Create snapshot response had no `snapshot`.\" });\n return data.snapshot;\n },\n\n /** Delete a snapshot. */\n delete: async (spaceId: string, cubeId: string, snapshotId: string) => {\n const { data, error, response } = await this.raw.DELETE(\n \"/spaces/{spaceId}/cubes/{cubeId}/snapshots/{snapshotId}\",\n { params: { path: { spaceId, cubeId, snapshotId } } },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n return data;\n },\n };\n\n // ---------------------------------------------------------------------------\n // TCP port mappings\n // ---------------------------------------------------------------------------\n\n readonly tcpMappings = {\n /** List a Cube's TCP port mappings. */\n list: async (spaceId: string, cubeId: string): Promise<TcpMapping[]> => {\n const { data, error, response } = await this.raw.GET(\n \"/spaces/{spaceId}/cubes/{cubeId}/tcp-mappings\",\n { params: { path: { spaceId, cubeId } } },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n return data?.tcpMappings ?? [];\n },\n\n /**\n * Create a TCP port mapping exposing a Cube port on the host. `cubePort` is\n * required; `whitelistedIps` optionally restricts who can reach it.\n *\n * ⛔ Send `whitelistedIps`, not `whitelistIps`. The published spec named\n * the field `whitelistIps` while the server has always read\n * `whitelistedIps`, so every allow-listed mapping created through this SDK\n * was silently published WORLD-OPEN, with a 201 and no error (reproduced\n * on production 2026-09-02). The server now accepts both, so an older\n * client keeps working, but `whitelistIps` is deprecated.\n *\n * **Omitting the allow-list leaves the port open to the internet.** That is\n * the documented behaviour, not an oversight — but it means a typo in the\n * field name fails OPEN, which is exactly how the original defect survived.\n *\n * `udpEnabled` optionally forwards UDP traffic on the same host port\n * alongside TCP. It is optional and the server defaults it to `true` when\n * omitted — so leave it unset to get UDP forwarding, and pass `false`\n * only to explicitly disable it.\n */\n create: async (\n spaceId: string,\n cubeId: string,\n body: CreateTcpMappingInput,\n ): Promise<TcpMapping> => {\n const { data, error, response } = await this.raw.POST(\n \"/spaces/{spaceId}/cubes/{cubeId}/tcp-mappings\",\n { params: { path: { spaceId, cubeId } }, body },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n if (!data?.tcpMapping)\n throw krovaErrorFrom(response, {\n error: \"Create TCP mapping response had no `tcpMapping`.\",\n });\n return data.tcpMapping;\n },\n\n /** Delete a TCP port mapping. */\n delete: async (spaceId: string, cubeId: string, mappingId: string) => {\n const { data, error, response } = await this.raw.DELETE(\n \"/spaces/{spaceId}/cubes/{cubeId}/tcp-mappings/{mappingId}\",\n { params: { path: { spaceId, cubeId, mappingId } } },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n return data;\n },\n };\n\n // ---------------------------------------------------------------------------\n // Imports & backups (.cube archive import / export)\n // ---------------------------------------------------------------------------\n\n readonly imports = {\n /**\n * Start importing a `.cube` archive into a new Cube. Returns the multipart\n * upload target (`importId`, `uploadId`, presigned `parts`, …). Upload the\n * archive to those URLs, then call {@link imports.complete}.\n */\n create: async (\n spaceId: string,\n body: NonNullable<\n paths[\"/spaces/{spaceId}/cubes/imports\"][\"post\"][\"requestBody\"]\n >[\"content\"][\"application/json\"],\n ) => {\n const { data, error, response } = await this.raw.POST(\"/spaces/{spaceId}/cubes/imports\", {\n params: { path: { spaceId } },\n body,\n });\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n return data;\n },\n\n /** Get an in-progress or completed import by id. */\n get: async (spaceId: string, importId: string) => {\n const { data, error, response } = await this.raw.GET(\n \"/spaces/{spaceId}/cubes/imports/{importId}\",\n { params: { path: { spaceId, importId } } },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n return data;\n },\n\n /**\n * Finish an import after the archive has been uploaded — provisions the\n * Cube. Pass the uploaded `parts` (partNumber + etag) and the resolved\n * `config`.\n */\n complete: async (\n spaceId: string,\n importId: string,\n body: NonNullable<\n paths[\"/spaces/{spaceId}/cubes/imports/{importId}/complete\"][\"post\"][\"requestBody\"]\n >[\"content\"][\"application/json\"],\n ) => {\n const { data, error, response } = await this.raw.POST(\n \"/spaces/{spaceId}/cubes/imports/{importId}/complete\",\n { params: { path: { spaceId, importId } }, body },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n return data;\n },\n\n /** Cancel an in-progress import. */\n cancel: async (spaceId: string, importId: string) => {\n const { data, error, response } = await this.raw.DELETE(\n \"/spaces/{spaceId}/cubes/imports/{importId}\",\n { params: { path: { spaceId, importId } } },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n return data;\n },\n };\n\n // ⛔ Every backup call reads the Backups permissions (`backup.view` to\n // read, `backup.manage` for everything else), not the Cube ones. A key whose\n // member holds only Cube permissions gets a 403 here.\n\n readonly backups = {\n /** List the space's backups, newest first, including copies shared into it. */\n list: async (spaceId: string): Promise<Backup[]> => {\n const { data, error, response } = await this.raw.GET(\"/spaces/{spaceId}/backups\", {\n params: { path: { spaceId } },\n });\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n return data?.backups ?? [];\n },\n\n /** Get one backup. */\n get: async (spaceId: string, backupId: string): Promise<Backup> => {\n const { data, error, response } = await this.raw.GET(\n \"/spaces/{spaceId}/backups/{backupId}\",\n { params: { path: { spaceId, backupId } } },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n if (!data?.backup)\n throw krovaErrorFrom(response, { error: \"Get backup response had no `backup`.\" });\n return data.backup;\n },\n\n /** Get a time-limited download URL for a backup `.cube` archive. */\n download: async (spaceId: string, backupId: string) => {\n const { data, error, response } = await this.raw.GET(\n \"/spaces/{spaceId}/backups/{backupId}/download\",\n { params: { path: { spaceId, backupId } } },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n return data;\n },\n\n /**\n * Offer a copy of a backup to another space. Returns the pending\n * {@link BackupShare}.\n *\n * Nothing is copied until the destination accepts: its owner, or a member\n * there with `backup.manage`, within 48 hours. The accepted copy is the\n * destination's own and is billed to it; this space's backup and bill are\n * unchanged. Through the API a share is always a request, even when your\n * user owns both spaces.\n *\n * A refusal at this step never says anything about the destination's\n * billing or verification; those are checked when it accepts.\n *\n * @param spaceId The space that holds the backup.\n * @param backupId The backup to share.\n * @param body `{ destinationSpaceId }`.\n * @param opts Optional `idempotencyKey` (max 255 chars, scoped per space).\n */\n share: async (\n spaceId: string,\n backupId: string,\n body: { destinationSpaceId: string },\n opts?: { idempotencyKey?: string },\n ): Promise<BackupShare> => {\n const { data, error, response } = await this.raw.POST(\n \"/spaces/{spaceId}/backups/{backupId}/shares\",\n {\n params: {\n path: { spaceId, backupId },\n ...(opts?.idempotencyKey ? { header: { \"Idempotency-Key\": opts.idempotencyKey } } : {}),\n },\n body,\n },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n if (!data?.share)\n throw krovaErrorFrom(response, { error: \"Share backup response had no `share`.\" });\n return data.share;\n },\n };\n\n readonly backupShares = {\n /** Pending, unexpired shares into (`incoming`) and out of (`outgoing`) a space. */\n list: async (spaceId: string): Promise<BackupShareList> => {\n const { data, error, response } = await this.raw.GET(\"/spaces/{spaceId}/backup-shares\", {\n params: { path: { spaceId } },\n });\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n return { incoming: data?.incoming ?? [], outgoing: data?.outgoing ?? [] };\n },\n\n /**\n * Accept a share offered to this space. Returns the share and the space's\n * new copy of the backup.\n *\n * The copy is billed to this space from now, so only a key of the space's\n * owner, or of a member holding `backup.manage`, may accept. A space that\n * cannot take the copy (no card or credit, owner not verified, an open abuse\n * notice, or no backup allowance left on its plan) is refused with a 422.\n */\n accept: async (spaceId: string, shareId: string): Promise<AcceptedBackupShare> => {\n const { data, error, response } = await this.raw.POST(\n \"/spaces/{spaceId}/backup-shares/{shareId}/accept\",\n { params: { path: { spaceId, shareId } } },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n if (!data?.share || !data.backup)\n throw krovaErrorFrom(response, {\n error: \"Accept backup share response had no `share` or `backup`.\",\n });\n return { share: data.share, backup: data.backup };\n },\n\n /** Decline a share offered to this space. Same permission as {@link accept}. */\n decline: async (spaceId: string, shareId: string): Promise<BackupShare> => {\n const { data, error, response } = await this.raw.POST(\n \"/spaces/{spaceId}/backup-shares/{shareId}/decline\",\n { params: { path: { spaceId, shareId } } },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n if (!data?.share)\n throw krovaErrorFrom(response, { error: \"Decline backup share response had no `share`.\" });\n return data.share;\n },\n\n /**\n * Withdraw a pending share this space offered. Allowed for a key of the\n * space's owner, of a member holding `backup.manage`, or of the member who\n * raised the request.\n */\n cancel: async (spaceId: string, shareId: string): Promise<BackupShare> => {\n const { data, error, response } = await this.raw.POST(\n \"/spaces/{spaceId}/backup-shares/{shareId}/cancel\",\n { params: { path: { spaceId, shareId } } },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n if (!data?.share)\n throw krovaErrorFrom(response, { error: \"Cancel backup share response had no `share`.\" });\n return data.share;\n },\n };\n\n // ---------------------------------------------------------------------------\n // Webhooks\n //\n // ⛔ The Krova Cloud API exposes no PATCH endpoint for webhooks, so this\n // group deliberately has no `update` or `rotateSecret` helper. To change a\n // webhook's URL, events, or signing secret, delete it and create a new\n // endpoint. The signing secret is returned ONCE — losing it means every\n // subsequent delivery will fail signature verification.\n // ---------------------------------------------------------------------------\n\n readonly webhooks = {\n /** List webhook endpoints in a Space. */\n list: async (spaceId: string): Promise<Webhook[]> => {\n const { data, error, response } = await this.raw.GET(\"/spaces/{spaceId}/webhooks\", {\n params: { path: { spaceId } },\n });\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n // The bundled spec does not declare a response body schema for this\n // path (only `description`); cast to the documented runtime shape.\n return (data as { webhooks?: Webhook[] } | undefined)?.webhooks ?? [];\n },\n\n /** Get a single webhook endpoint by id. Does NOT include the signing secret. */\n get: async (spaceId: string, endpointId: string): Promise<Webhook> => {\n const { data, error, response } = await this.raw.GET(\n \"/spaces/{spaceId}/webhooks/{endpointId}\",\n { params: { path: { spaceId, endpointId } } },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n // The bundled spec does not declare a response body schema for this\n // path (only `description`); cast to the documented runtime shape.\n const body = data as { webhook?: Webhook } | undefined;\n if (!body?.webhook)\n throw krovaErrorFrom(response, { error: \"Get webhook response had no `webhook`.\" });\n return body.webhook;\n },\n\n /**\n * Create a webhook endpoint. Returns the endpoint AND its signing secret.\n *\n * ⛔ The signing secret is shown ONLY at creation. Persist it immediately;\n * you cannot retrieve it later — `webhooks.get` deliberately omits it.\n * Losing the secret means every subsequent delivery will fail signature\n * verification, and you will have to delete the endpoint and create a new\n * one. An automation that swallows this helper's return value will lose\n * the secret on the next request, so the response is checked here and\n * throws if the server omits either the webhook or the secret.\n *\n * @param spaceId Target Space id.\n * @param body Webhook spec — `{ url, events, description? }`.\n */\n create: async (spaceId: string, body: CreateWebhookInput): Promise<WebhookWithSecret> => {\n const { data, error, response } = await this.raw.POST(\"/spaces/{spaceId}/webhooks\", {\n params: { path: { spaceId } },\n body,\n });\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n // The bundled spec does not declare a response body schema for this\n // path (only `description`); cast to the documented runtime shape.\n const payload = data as { webhook?: WebhookWithSecret } | undefined;\n if (!payload?.webhook)\n throw krovaErrorFrom(response, { error: \"Create webhook response had no `webhook`.\" });\n if (!payload.webhook.secret)\n throw krovaErrorFrom(response, {\n error:\n \"Create webhook response had no `secret` — capture it NOW; it is never returned again.\",\n });\n return payload.webhook;\n },\n\n /**\n * Delete a webhook endpoint (cascades delivery history).\n *\n * Resolves on any 2xx; the response body is intentionally not parsed\n * because the server returns `{ success: true }` but the caller does not\n * need it.\n */\n delete: async (spaceId: string, endpointId: string): Promise<void> => {\n const { error, response } = await this.raw.DELETE(\"/spaces/{spaceId}/webhooks/{endpointId}\", {\n params: { path: { spaceId, endpointId } },\n });\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n },\n\n /**\n * List recent deliveries for a webhook endpoint (last 30 days, max 100).\n *\n * @param spaceId Target Space id.\n * @param endpointId Webhook endpoint id.\n * @param opts Optional `limit` (1..100). Omit to let the server default to 50.\n */\n deliveries: async (\n spaceId: string,\n endpointId: string,\n opts?: { limit?: number },\n ): Promise<WebhookDelivery[]> => {\n const { data, error, response } = await this.raw.GET(\n \"/spaces/{spaceId}/webhooks/{endpointId}/deliveries\",\n {\n params: {\n path: { spaceId, endpointId },\n ...(opts?.limit !== undefined ? { query: { limit: opts.limit } } : {}),\n },\n },\n );\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n // The bundled spec does not declare a response body schema for this\n // path (only `description`); cast to the documented runtime shape.\n return (data as { deliveries?: WebhookDelivery[] } | undefined)?.deliveries ?? [];\n },\n };\n\n // ---------------------------------------------------------------------------\n // Public catalog (no auth required by the API, but the key is harmless)\n // ---------------------------------------------------------------------------\n\n readonly catalog = {\n /** List regions with available capacity. */\n regions: async () => {\n const { data, error, response } = await this.raw.GET(\"/regions\");\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n if (data === undefined)\n throw krovaErrorFrom(response, { error: \"Regions response was empty.\" });\n return data;\n },\n\n /** List available OS images. */\n images: async () => {\n const { data, error, response } = await this.raw.GET(\"/images\");\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n if (data === undefined)\n throw krovaErrorFrom(response, { error: \"Images response was empty.\" });\n return data;\n },\n\n /** Per-resource hourly rates and volume pricing tiers. */\n pricing: async () => {\n const { data, error, response } = await this.raw.GET(\"/pricing\");\n if (error !== undefined || !response.ok) throw krovaErrorFrom(response, error);\n if (data === undefined)\n throw krovaErrorFrom(response, { error: \"Pricing response was empty.\" });\n return data;\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,IAAa,aAAb,MAAa,mBAAmB,MAAM;;CAEpC;;;;;;CAOA;;;;;CAMA;;CAGA;;CAGA;CAEA,YACE,SACA,MAOA;EACA,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,SAAS,KAAK;EACnB,KAAK,OAAO,KAAK;EACjB,KAAK,YAAY,KAAK;EACtB,KAAK,OAAO,KAAK;EACjB,KAAK,WAAW,KAAK;EAErB,OAAO,eAAe,MAAM,WAAW,SAAS;CAClD;AACF;;;;;;;;;;;;;;;AAgBA,SAAgB,eAAe,UAAoB,MAA2B;CAC5E,MAAM,OACJ,OAAO,SAAS,YAAY,SAAS,QAAQ,OAAQ,KAAwB,UAAU,WAClF,OACD,KAAA;CAGN,OAAO,IAAI,WADT,MAAM,SAAS,SAAS,cAAc,8BAA8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