@krovacloud/sdk 0.3.8 → 0.3.10
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.
- package/README.md +33 -5
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +44 -4
- package/dist/index.d.ts +44 -4
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -49,7 +49,7 @@ const cube = await krova.cubes.create("space_123", {
|
|
|
49
49
|
console.log(`Created cube ${cube.id} (${cube.state})`);
|
|
50
50
|
console.log(` ${cube.resources.vcpu} vCPU / ${cube.resources.ramGb} GB RAM, image ${cube.image}`);
|
|
51
51
|
|
|
52
|
-
//
|
|
52
|
+
// Power it off, then start it again
|
|
53
53
|
await krova.cubes.powerOff("space_123", cube.id);
|
|
54
54
|
await krova.cubes.wake("space_123", cube.id);
|
|
55
55
|
await krova.cubes.restart("space_123", cube.id); // cold restart
|
|
@@ -105,8 +105,8 @@ Ergonomic helpers for the Cube lifecycle. Each unwraps the response body and thr
|
|
|
105
105
|
| `get` | `(spaceId, cubeId)` | the Cube body |
|
|
106
106
|
| `update` | `(spaceId, cubeId, body)` | updates the Cube's SSH port |
|
|
107
107
|
| `delete` | `(spaceId, cubeId)` | enqueues deletion |
|
|
108
|
-
| `
|
|
109
|
-
| `wake` | `(spaceId, cubeId)` | enqueues
|
|
108
|
+
| `powerOff` | `(spaceId, cubeId)` | enqueues a power-off |
|
|
109
|
+
| `wake` | `(spaceId, cubeId)` | enqueues a start |
|
|
110
110
|
| `ssh` | `(spaceId, cubeId)` | the Cube's SSH connection info (`host`, `port`, `user`, `hostKeys`) |
|
|
111
111
|
| `restore` | `(spaceId, cubeId, snapshotId)` | enqueues a restore — replaces the Cube's disk from a snapshot |
|
|
112
112
|
|
|
@@ -120,7 +120,7 @@ const cube = await krova.cubes.create(
|
|
|
120
120
|
image: "ubuntu-24.04",
|
|
121
121
|
resources: { vcpu: 2, ramGb: 4, diskGb: 40 },
|
|
122
122
|
sshPublicKey: "ssh-ed25519 AAAA... you@host",
|
|
123
|
-
region: "us
|
|
123
|
+
region: "us", // optional — slug from catalog.regions()
|
|
124
124
|
userData: "#cloud-config\n", // optional — cloud-init (max 16 KB)
|
|
125
125
|
},
|
|
126
126
|
{ idempotencyKey: "deploy-2026-07-01" },
|
|
@@ -133,7 +133,7 @@ const all = await krova.cubes.list("space_123");
|
|
|
133
133
|
// update — the only mutable Cube field over the public API is the SSH port
|
|
134
134
|
await krova.cubes.update("space_123", cube.id, { cubePort: 2222 });
|
|
135
135
|
|
|
136
|
-
// lifecycle —
|
|
136
|
+
// lifecycle — powerOff, wake, delete are asynchronous (enqueued)
|
|
137
137
|
await krova.cubes.powerOff("space_123", cube.id);
|
|
138
138
|
await krova.cubes.wake("space_123", cube.id);
|
|
139
139
|
// Cold restart: reboots against the host's current kernel, preserving the disk.
|
|
@@ -301,6 +301,34 @@ The package ships its own type declarations — no `@types/*` install needed. `C
|
|
|
301
301
|
|
|
302
302
|
See [CONTRIBUTING.md](https://github.com/krovacloud/krova-node/blob/main/CONTRIBUTING.md). Report security issues privately per [SECURITY.md](https://github.com/krovacloud/krova-node/blob/main/SECURITY.md).
|
|
303
303
|
|
|
304
|
+
|
|
305
|
+
## Custom domains: HTTPS to the Cube
|
|
306
|
+
|
|
307
|
+
By default the edge reaches your Cube over cleartext HTTP — visitors are on
|
|
308
|
+
HTTPS either way, since TLS terminates at the edge. Set `originScheme: "https"`
|
|
309
|
+
when the Cube terminates TLS *itself*: a control panel holding its own
|
|
310
|
+
certificate, or an app listening on HTTPS, answers plain HTTP with a redirect
|
|
311
|
+
and cannot be served over cleartext at all.
|
|
312
|
+
|
|
313
|
+
```ts
|
|
314
|
+
// When attaching the domain…
|
|
315
|
+
await krova.domains.create(spaceId, cubeId, {
|
|
316
|
+
domain: "panel.example.com",
|
|
317
|
+
port: 443,
|
|
318
|
+
originScheme: "https",
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
// …or switch an already-attached domain over.
|
|
322
|
+
await krova.domains.update(spaceId, cubeId, mappingId, {
|
|
323
|
+
originScheme: "https",
|
|
324
|
+
});
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
The dial port is derived: `https` on the default port 80 connects on 443, and a
|
|
328
|
+
deliberate custom port is honoured exactly. The setting is verified against the
|
|
329
|
+
Cube before it is applied — if the domain does not serve, the route is left on
|
|
330
|
+
`http`.
|
|
331
|
+
|
|
304
332
|
## License
|
|
305
333
|
|
|
306
334
|
[MIT](./LICENSE) © 2026 Krova Inc.
|
package/dist/index.cjs
CHANGED
|
@@ -236,7 +236,7 @@ var KrovaClient = class {
|
|
|
236
236
|
if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
|
|
237
237
|
return data;
|
|
238
238
|
},
|
|
239
|
-
/** Start a stopped Cube
|
|
239
|
+
/** Start a stopped Cube (asynchronous — start is enqueued). */
|
|
240
240
|
/**
|
|
241
241
|
* Restart a Cube (COLD restart).
|
|
242
242
|
*
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/error.ts","../src/client.ts"],"names":["createClient"],"mappings":";;;;;;;;;;;AAoBO,IAAM,UAAA,GAAN,MAAM,WAAA,SAAmB,KAAA,CAAM;AAAA;AAAA,EAE3B,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAA;AAAA;AAAA,EAGA,IAAA;AAAA;AAAA,EAGA,QAAA;AAAA,EAET,WAAA,CACE,SACA,IAAA,EAOA;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,YAAA;AACZ,IAAA,IAAA,CAAK,SAAS,IAAA,CAAK,MAAA;AACnB,IAAA,IAAA,CAAK,OAAO,IAAA,CAAK,IAAA;AACjB,IAAA,IAAA,CAA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;AACzE,MAAA,OAAO,IAAA;AAAA,IACT,CAAA;AAAA;AAAA,IAGA,QAAQ,YAAY;AAClB,MAAA,MAAM,EAAE,MAAM,KAAA,EAAO,QAAA,KAAa,MAAM,IAAA,CAAK,GAAA,CAAI,GAAA,CAAI,SAAS,CAAA;AAC9D,MAAA,IAAI,KAAA,KAAU,UAAa,CAAC,QAAA,CAAS,IAAI,MAAM,cAAA,CAAe,UAAU,KAAK,CAAA;AAC7E,MAAA,IAAI,IAAA,KAAS,MAAA;AACX,QAAA,MAAM,cAAA,CAAe,QAAA,EAAU,EAAE,KAAA,EAAO,8BAA8B,CAAA;AACxE,MAAA,OAAO,IAAA;AAAA,IACT,CAAA;AAAA;AAAA,IAGA,SAAS,YAAY;AACnB,MAAA,MAAM,EAAE,MAAM,KAAA,EAAO,QAAA,KAAa,MAAM,IAAA,CAAK,GAAA,CAAI,GAAA,CAAI,UAAU,CAAA;AAC/D,MAAA,IAAI,KAAA,KAAU,UAAa,CAAC,QAAA,CAAS,IAAI,MAAM,cAAA,CAAe,UAAU,KAAK,CAAA;AAC7E,MAAA,IAAI,IAAA,KAAS,MAAA;AACX,QAAA,MAAM,cAAA,CAAe,QAAA,EAAU,EAAE,KAAA,EAAO,+BAA+B,CAAA;AACzE,MAAA,OAAO,IAAA;AAAA,IACT;AAAA,GACF;AACF","file":"index.cjs","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 }`. Additional fields may appear over time, so\n * we keep the type open.\n */\nexport interface KrovaErrorBody {\n error?: string;\n [key: string]: unknown;\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 */\nexport function krovaErrorFrom(\n response: Response,\n body: KrovaErrorBody | undefined,\n): KrovaError {\n const message =\n (typeof body?.error === \"string\" && body.error) ||\n response.statusText ||\n `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,\n response,\n });\n}\n","import createClient, { type Client, type Middleware } from \"openapi-fetch\";\nimport { krovaErrorFrom } 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/** 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/** 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> =>\n 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 * @param spaceId Target Space id.\n * @param body Cube spec — `{ name, image, resources, sshPublicKey, ... }`.\n * @param opts Optional `idempotencyKey` (max 255 chars, scoped per space).\n */\n create: async (\n spaceId: string,\n body: NonNullable<\n paths[\"/spaces/{spaceId}/cubes\"][\"post\"][\"requestBody\"]\n >[\"content\"][\"application/json\"],\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\n ? { header: { \"Idempotency-Key\": opts.idempotencyKey } }\n : {}),\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(\n \"/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 /** Delete a Cube (asynchronous — deletion is enqueued). */\n delete: async (spaceId: string, cubeId: string) => {\n const { data, error, response } = await this.raw.DELETE(\n \"/spaces/{spaceId}/cubes/{cubeId}\",\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: \"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 — a cold boot (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(\n \"/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)\n 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 /** Attach a custom domain to a Cube. `domain` + `port` are required. */\n create: async (\n spaceId: string,\n cubeId: string,\n body: CreateDomainInput,\n ): Promise<Domain> => {\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 data.domain;\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; `whitelistIps` optionally restricts who can reach 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, { error: \"Create TCP mapping response had no `tcpMapping`.\" });\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 // 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"]}
|
|
1
|
+
{"version":3,"sources":["../src/error.ts","../src/client.ts"],"names":["createClient"],"mappings":";;;;;;;;;;;AAoBO,IAAM,UAAA,GAAN,MAAM,WAAA,SAAmB,KAAA,CAAM;AAAA;AAAA,EAE3B,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAA;AAAA;AAAA,EAGA,IAAA;AAAA;AAAA,EAGA,QAAA;AAAA,EAET,WAAA,CACE,SACA,IAAA,EAOA;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,YAAA;AACZ,IAAA,IAAA,CAAK,SAAS,IAAA,CAAK,MAAA;AACnB,IAAA,IAAA,CAAK,OAAO,IAAA,CAAK,IAAA;AACjB,IAAA,IAAA,CAAK,YAAY,IAAA,CAAK,SAAA;AACtB,IAAA,IAAA,CAAK,OAAO,IAAA,CAAK,IAAA;AACjB,IAAA,IAAA,CAAK,WAAW,IAAA,CAAK,QAAA;AAErB,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,WAAA,CAAW,SAAS,CAAA;AAAA,EAClD;AACF;AAKO,SAAS,cAAA,CACd,UACA,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AI,MAAM,cAAA,CAAe,UAAU,KAAK,CAAA;AAC7E,MAAA,IAAI,IAAA,KAAS,MAAA;AACX,QAAA,MAAM,cAAA,CAAe,QAAA,EAAU,EAAE,KAAA,EAAO,8BAA8B,CAAA;AACxE,MAAA,OAAO,IAAA;AAAA,IACT,CAAA;AAAA;AAAA,IAGA,SAAS,YAAY;AACnB,MAAA,MAAM,EAAE,MAAM,KAAA,EAAO,QAAA,KAAa,MAAM,IAAA,CAAK,GAAA,CAAI,GAAA,CAAI,UAAU,CAAA;AAC/D,MAAA,IAAI,KAAA,KAAU,UAAa,CAAC,QAAA,CAAS,IAAI,MAAM,cAAA,CAAe,UAAU,KAAK,CAAA;AAC7E,MAAA,IAAI,IAAA,KAAS,MAAA;AACX,QAAA,MAAM,cAAA,CAAe,QAAA,EAAU,EAAE,KAAA,EAAO,+BAA+B,CAAA;AACzE,MAAA,OAAO,IAAA;AAAA,IACT;AAAA,GACF;AACF","file":"index.cjs","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 }`. Additional fields may appear over time, so\n * we keep the type open.\n */\nexport interface KrovaErrorBody {\n error?: string;\n [key: string]: unknown;\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 */\nexport function krovaErrorFrom(\n response: Response,\n body: KrovaErrorBody | undefined,\n): KrovaError {\n const message =\n (typeof body?.error === \"string\" && body.error) ||\n response.statusText ||\n `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,\n response,\n });\n}\n","import createClient, { type Client, type Middleware } from \"openapi-fetch\";\nimport { krovaErrorFrom } 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/** 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/** 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> =>\n 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 * @param spaceId Target Space id.\n * @param body Cube spec — `{ name, image, resources, sshPublicKey, ... }`.\n * @param opts Optional `idempotencyKey` (max 255 chars, scoped per space).\n */\n create: async (\n spaceId: string,\n body: NonNullable<\n paths[\"/spaces/{spaceId}/cubes\"][\"post\"][\"requestBody\"]\n >[\"content\"][\"application/json\"],\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\n ? { header: { \"Idempotency-Key\": opts.idempotencyKey } }\n : {}),\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(\n \"/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 /** Delete a Cube (asynchronous — deletion is enqueued). */\n delete: async (spaceId: string, cubeId: string) => {\n const { data, error, response } = await this.raw.DELETE(\n \"/spaces/{spaceId}/cubes/{cubeId}\",\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: \"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(\n \"/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)\n 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 /** Attach a custom domain to a Cube. `domain` + `port` are required. */\n create: async (\n spaceId: string,\n cubeId: string,\n body: CreateDomainInput,\n ): Promise<Domain> => {\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 data.domain;\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; `whitelistIps` optionally restricts who can reach 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, { error: \"Create TCP mapping response had no `tcpMapping`.\" });\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 // 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"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -516,7 +516,7 @@ interface paths {
|
|
|
516
516
|
};
|
|
517
517
|
get?: never;
|
|
518
518
|
put?: never;
|
|
519
|
-
/** Start a stopped Cube
|
|
519
|
+
/** Start a stopped Cube */
|
|
520
520
|
post: {
|
|
521
521
|
parameters: {
|
|
522
522
|
query?: never;
|
|
@@ -557,7 +557,7 @@ interface paths {
|
|
|
557
557
|
put?: never;
|
|
558
558
|
/**
|
|
559
559
|
* Restart a running Cube
|
|
560
|
-
* @description Cold-restarts the Cube: the hypervisor process is stopped and relaunched, so the Cube boots against the host's current kernel. This is how a Cube picks up a refreshed guest kernel after a platform image update — a `reboot` issued inside the Cube cannot do it, because the kernel is supplied externally by the host. Disk state is preserved; only the kernel changes.
|
|
560
|
+
* @description Cold-restarts the Cube: the hypervisor process is stopped and relaunched, so the Cube boots against the host's current kernel. This is how a Cube picks up a refreshed guest kernel after a platform image update — a `reboot` issued inside the Cube cannot do it, because the kernel is supplied externally by the host. Disk state is preserved; only the kernel changes. Cube must be `running` (a stopped Cube already picks up the latest kernel when started). Concurrent restarts of the same Cube are rejected with 409 rather than queued twice.
|
|
561
561
|
*/
|
|
562
562
|
post: {
|
|
563
563
|
parameters: {
|
|
@@ -744,7 +744,7 @@ interface paths {
|
|
|
744
744
|
"application/json": {
|
|
745
745
|
/** @description The hostname to attach, e.g. app.example.com */
|
|
746
746
|
domain: string;
|
|
747
|
-
/** @description
|
|
747
|
+
/** @description Cube port the domain proxies to. */
|
|
748
748
|
port: number;
|
|
749
749
|
/**
|
|
750
750
|
* @description enforced = proxy sets platform security headers (HSTS, X-Frame-Options, …); app_managed = the app's own headers pass through. Default enforced.
|
|
@@ -769,6 +769,26 @@ interface paths {
|
|
|
769
769
|
} | null;
|
|
770
770
|
/** @description Max request body size (MB). Null = unlimited (default). */
|
|
771
771
|
maxRequestBodyMb?: number | null;
|
|
772
|
+
/** @description Per-domain CORS policy, applied at the edge. Null (default) = CORS disabled and no Access-Control-* header is emitted anywhere. When set, the proxy answers OPTIONS preflight itself (204, the cube is never involved) and adds the headers to normal AND error responses, so a cross-origin request to a failing or sleeping cube is never CORS-masked. */
|
|
773
|
+
corsConfig?: {
|
|
774
|
+
/** @description Exact scheme://host[:port] origins (no path, query or trailing slash), or the single-element wildcard ["*"]. "*" and allowCredentials are mutually exclusive. */
|
|
775
|
+
allowedOrigins: string[];
|
|
776
|
+
/** @description Allowed methods. Omitted = GET, POST, PUT, PATCH, DELETE, OPTIONS. */
|
|
777
|
+
allowedMethods?: string[];
|
|
778
|
+
/** @description Allowed request headers. Omitted/empty = echo the preflight's Access-Control-Request-Headers. */
|
|
779
|
+
allowedHeaders?: string[];
|
|
780
|
+
/** @description Response headers exposed to JS. Omitted/empty = none. */
|
|
781
|
+
exposedHeaders?: string[];
|
|
782
|
+
/** @description Send Access-Control-Allow-Credentials: true. Rejected together with the "*" origin. */
|
|
783
|
+
allowCredentials?: boolean;
|
|
784
|
+
/** @description Preflight cache TTL. Default 600; 86400 is Chromium's hard cap. */
|
|
785
|
+
maxAgeSeconds?: number;
|
|
786
|
+
} | null;
|
|
787
|
+
/**
|
|
788
|
+
* @description Scheme the edge speaks to the CUBE on the backend hop. http (default) = cleartext. https = the cube terminates TLS itself (a control panel holding its own certificate, or an app listening on HTTPS) and answers plain HTTP with a redirect, so it cannot be reached over cleartext at all. Visitors are on HTTPS either way. The dial port is derived: https on the default port 80 connects on 443; a deliberate custom port is honoured exactly. Verified against the cube before it is applied — if the domain does not serve, the route is left on http.
|
|
789
|
+
* @enum {string}
|
|
790
|
+
*/
|
|
791
|
+
originScheme?: "http" | "https";
|
|
772
792
|
/** @description Edge gzip/zstd compression. Default false (domains behind a CDN are already compressed there). */
|
|
773
793
|
responseCompression?: boolean;
|
|
774
794
|
/** @description Visitor IP/CIDR allow-list (v4+v6). Non-empty ⇒ only these reach the app. Null/empty = open. */
|
|
@@ -885,6 +905,26 @@ interface paths {
|
|
|
885
905
|
} | null;
|
|
886
906
|
/** @description Max request body size (MB). Null = unlimited (default). */
|
|
887
907
|
maxRequestBodyMb?: number | null;
|
|
908
|
+
/** @description Per-domain CORS policy, applied at the edge. Null (default) = CORS disabled and no Access-Control-* header is emitted anywhere. When set, the proxy answers OPTIONS preflight itself (204, the cube is never involved) and adds the headers to normal AND error responses, so a cross-origin request to a failing or sleeping cube is never CORS-masked. */
|
|
909
|
+
corsConfig?: {
|
|
910
|
+
/** @description Exact scheme://host[:port] origins (no path, query or trailing slash), or the single-element wildcard ["*"]. "*" and allowCredentials are mutually exclusive. */
|
|
911
|
+
allowedOrigins: string[];
|
|
912
|
+
/** @description Allowed methods. Omitted = GET, POST, PUT, PATCH, DELETE, OPTIONS. */
|
|
913
|
+
allowedMethods?: string[];
|
|
914
|
+
/** @description Allowed request headers. Omitted/empty = echo the preflight's Access-Control-Request-Headers. */
|
|
915
|
+
allowedHeaders?: string[];
|
|
916
|
+
/** @description Response headers exposed to JS. Omitted/empty = none. */
|
|
917
|
+
exposedHeaders?: string[];
|
|
918
|
+
/** @description Send Access-Control-Allow-Credentials: true. Rejected together with the "*" origin. */
|
|
919
|
+
allowCredentials?: boolean;
|
|
920
|
+
/** @description Preflight cache TTL. Default 600; 86400 is Chromium's hard cap. */
|
|
921
|
+
maxAgeSeconds?: number;
|
|
922
|
+
} | null;
|
|
923
|
+
/**
|
|
924
|
+
* @description Scheme the edge speaks to the CUBE on the backend hop. http (default) = cleartext. https = the cube terminates TLS itself (a control panel holding its own certificate, or an app listening on HTTPS) and answers plain HTTP with a redirect, so it cannot be reached over cleartext at all. Visitors are on HTTPS either way. The dial port is derived: https on the default port 80 connects on 443; a deliberate custom port is honoured exactly. Verified against the cube before it is applied — if the domain does not serve, the route is left on http.
|
|
925
|
+
* @enum {string}
|
|
926
|
+
*/
|
|
927
|
+
originScheme?: "http" | "https";
|
|
888
928
|
/** @description Edge gzip/zstd compression. Default false (domains behind a CDN are already compressed there). */
|
|
889
929
|
responseCompression?: boolean;
|
|
890
930
|
/** @description Visitor IP/CIDR allow-list (v4+v6). Non-empty ⇒ only these reach the app. Null/empty = open. */
|
|
@@ -2042,7 +2082,7 @@ declare class KrovaClient {
|
|
|
2042
2082
|
/** Power off a running Cube (asynchronous — power-off is enqueued). The Cube
|
|
2043
2083
|
* becomes `stopped` (its host RAM is freed); start it again with `wake`. */
|
|
2044
2084
|
powerOff: (spaceId: string, cubeId: string) => Promise<unknown>;
|
|
2045
|
-
/** Start a stopped Cube
|
|
2085
|
+
/** Start a stopped Cube (asynchronous — start is enqueued). */
|
|
2046
2086
|
/**
|
|
2047
2087
|
* Restart a Cube (COLD restart).
|
|
2048
2088
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -516,7 +516,7 @@ interface paths {
|
|
|
516
516
|
};
|
|
517
517
|
get?: never;
|
|
518
518
|
put?: never;
|
|
519
|
-
/** Start a stopped Cube
|
|
519
|
+
/** Start a stopped Cube */
|
|
520
520
|
post: {
|
|
521
521
|
parameters: {
|
|
522
522
|
query?: never;
|
|
@@ -557,7 +557,7 @@ interface paths {
|
|
|
557
557
|
put?: never;
|
|
558
558
|
/**
|
|
559
559
|
* Restart a running Cube
|
|
560
|
-
* @description Cold-restarts the Cube: the hypervisor process is stopped and relaunched, so the Cube boots against the host's current kernel. This is how a Cube picks up a refreshed guest kernel after a platform image update — a `reboot` issued inside the Cube cannot do it, because the kernel is supplied externally by the host. Disk state is preserved; only the kernel changes.
|
|
560
|
+
* @description Cold-restarts the Cube: the hypervisor process is stopped and relaunched, so the Cube boots against the host's current kernel. This is how a Cube picks up a refreshed guest kernel after a platform image update — a `reboot` issued inside the Cube cannot do it, because the kernel is supplied externally by the host. Disk state is preserved; only the kernel changes. Cube must be `running` (a stopped Cube already picks up the latest kernel when started). Concurrent restarts of the same Cube are rejected with 409 rather than queued twice.
|
|
561
561
|
*/
|
|
562
562
|
post: {
|
|
563
563
|
parameters: {
|
|
@@ -744,7 +744,7 @@ interface paths {
|
|
|
744
744
|
"application/json": {
|
|
745
745
|
/** @description The hostname to attach, e.g. app.example.com */
|
|
746
746
|
domain: string;
|
|
747
|
-
/** @description
|
|
747
|
+
/** @description Cube port the domain proxies to. */
|
|
748
748
|
port: number;
|
|
749
749
|
/**
|
|
750
750
|
* @description enforced = proxy sets platform security headers (HSTS, X-Frame-Options, …); app_managed = the app's own headers pass through. Default enforced.
|
|
@@ -769,6 +769,26 @@ interface paths {
|
|
|
769
769
|
} | null;
|
|
770
770
|
/** @description Max request body size (MB). Null = unlimited (default). */
|
|
771
771
|
maxRequestBodyMb?: number | null;
|
|
772
|
+
/** @description Per-domain CORS policy, applied at the edge. Null (default) = CORS disabled and no Access-Control-* header is emitted anywhere. When set, the proxy answers OPTIONS preflight itself (204, the cube is never involved) and adds the headers to normal AND error responses, so a cross-origin request to a failing or sleeping cube is never CORS-masked. */
|
|
773
|
+
corsConfig?: {
|
|
774
|
+
/** @description Exact scheme://host[:port] origins (no path, query or trailing slash), or the single-element wildcard ["*"]. "*" and allowCredentials are mutually exclusive. */
|
|
775
|
+
allowedOrigins: string[];
|
|
776
|
+
/** @description Allowed methods. Omitted = GET, POST, PUT, PATCH, DELETE, OPTIONS. */
|
|
777
|
+
allowedMethods?: string[];
|
|
778
|
+
/** @description Allowed request headers. Omitted/empty = echo the preflight's Access-Control-Request-Headers. */
|
|
779
|
+
allowedHeaders?: string[];
|
|
780
|
+
/** @description Response headers exposed to JS. Omitted/empty = none. */
|
|
781
|
+
exposedHeaders?: string[];
|
|
782
|
+
/** @description Send Access-Control-Allow-Credentials: true. Rejected together with the "*" origin. */
|
|
783
|
+
allowCredentials?: boolean;
|
|
784
|
+
/** @description Preflight cache TTL. Default 600; 86400 is Chromium's hard cap. */
|
|
785
|
+
maxAgeSeconds?: number;
|
|
786
|
+
} | null;
|
|
787
|
+
/**
|
|
788
|
+
* @description Scheme the edge speaks to the CUBE on the backend hop. http (default) = cleartext. https = the cube terminates TLS itself (a control panel holding its own certificate, or an app listening on HTTPS) and answers plain HTTP with a redirect, so it cannot be reached over cleartext at all. Visitors are on HTTPS either way. The dial port is derived: https on the default port 80 connects on 443; a deliberate custom port is honoured exactly. Verified against the cube before it is applied — if the domain does not serve, the route is left on http.
|
|
789
|
+
* @enum {string}
|
|
790
|
+
*/
|
|
791
|
+
originScheme?: "http" | "https";
|
|
772
792
|
/** @description Edge gzip/zstd compression. Default false (domains behind a CDN are already compressed there). */
|
|
773
793
|
responseCompression?: boolean;
|
|
774
794
|
/** @description Visitor IP/CIDR allow-list (v4+v6). Non-empty ⇒ only these reach the app. Null/empty = open. */
|
|
@@ -885,6 +905,26 @@ interface paths {
|
|
|
885
905
|
} | null;
|
|
886
906
|
/** @description Max request body size (MB). Null = unlimited (default). */
|
|
887
907
|
maxRequestBodyMb?: number | null;
|
|
908
|
+
/** @description Per-domain CORS policy, applied at the edge. Null (default) = CORS disabled and no Access-Control-* header is emitted anywhere. When set, the proxy answers OPTIONS preflight itself (204, the cube is never involved) and adds the headers to normal AND error responses, so a cross-origin request to a failing or sleeping cube is never CORS-masked. */
|
|
909
|
+
corsConfig?: {
|
|
910
|
+
/** @description Exact scheme://host[:port] origins (no path, query or trailing slash), or the single-element wildcard ["*"]. "*" and allowCredentials are mutually exclusive. */
|
|
911
|
+
allowedOrigins: string[];
|
|
912
|
+
/** @description Allowed methods. Omitted = GET, POST, PUT, PATCH, DELETE, OPTIONS. */
|
|
913
|
+
allowedMethods?: string[];
|
|
914
|
+
/** @description Allowed request headers. Omitted/empty = echo the preflight's Access-Control-Request-Headers. */
|
|
915
|
+
allowedHeaders?: string[];
|
|
916
|
+
/** @description Response headers exposed to JS. Omitted/empty = none. */
|
|
917
|
+
exposedHeaders?: string[];
|
|
918
|
+
/** @description Send Access-Control-Allow-Credentials: true. Rejected together with the "*" origin. */
|
|
919
|
+
allowCredentials?: boolean;
|
|
920
|
+
/** @description Preflight cache TTL. Default 600; 86400 is Chromium's hard cap. */
|
|
921
|
+
maxAgeSeconds?: number;
|
|
922
|
+
} | null;
|
|
923
|
+
/**
|
|
924
|
+
* @description Scheme the edge speaks to the CUBE on the backend hop. http (default) = cleartext. https = the cube terminates TLS itself (a control panel holding its own certificate, or an app listening on HTTPS) and answers plain HTTP with a redirect, so it cannot be reached over cleartext at all. Visitors are on HTTPS either way. The dial port is derived: https on the default port 80 connects on 443; a deliberate custom port is honoured exactly. Verified against the cube before it is applied — if the domain does not serve, the route is left on http.
|
|
925
|
+
* @enum {string}
|
|
926
|
+
*/
|
|
927
|
+
originScheme?: "http" | "https";
|
|
888
928
|
/** @description Edge gzip/zstd compression. Default false (domains behind a CDN are already compressed there). */
|
|
889
929
|
responseCompression?: boolean;
|
|
890
930
|
/** @description Visitor IP/CIDR allow-list (v4+v6). Non-empty ⇒ only these reach the app. Null/empty = open. */
|
|
@@ -2042,7 +2082,7 @@ declare class KrovaClient {
|
|
|
2042
2082
|
/** Power off a running Cube (asynchronous — power-off is enqueued). The Cube
|
|
2043
2083
|
* becomes `stopped` (its host RAM is freed); start it again with `wake`. */
|
|
2044
2084
|
powerOff: (spaceId: string, cubeId: string) => Promise<unknown>;
|
|
2045
|
-
/** Start a stopped Cube
|
|
2085
|
+
/** Start a stopped Cube (asynchronous — start is enqueued). */
|
|
2046
2086
|
/**
|
|
2047
2087
|
* Restart a Cube (COLD restart).
|
|
2048
2088
|
*
|
package/dist/index.js
CHANGED
|
@@ -230,7 +230,7 @@ var KrovaClient = class {
|
|
|
230
230
|
if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
|
|
231
231
|
return data;
|
|
232
232
|
},
|
|
233
|
-
/** Start a stopped Cube
|
|
233
|
+
/** Start a stopped Cube (asynchronous — start is enqueued). */
|
|
234
234
|
/**
|
|
235
235
|
* Restart a Cube (COLD restart).
|
|
236
236
|
*
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/error.ts","../src/client.ts"],"names":[],"mappings":";;;;;AAoBO,IAAM,UAAA,GAAN,MAAM,WAAA,SAAmB,KAAA,CAAM;AAAA;AAAA,EAE3B,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAA;AAAA;AAAA,EAGA,IAAA;AAAA;AAAA,EAGA,QAAA;AAAA,EAET,WAAA,CACE,SACA,IAAA,EAOA;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,YAAA;AACZ,IAAA,IAAA,CAAK,SAAS,IAAA,CAAK,MAAA;AACnB,IAAA,IAAA,CAAK,OAAO,IAAA,CAAK,IAAA;AACjB,IAAA,IAAA,CAAK,YAAY,IAAA,CAAK,SAAA;AACtB,IAAA,IAAA,CAAK,OAAO,IAAA,CAAK,IAAA;AACjB,IAAA,IAAA,CAAK,WAAW,IAAA,CAAK,QAAA;AAErB,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,WAAA,CAAW,SAAS,CAAA;AAAA,EAClD;AACF;AAKO,SAAS,cAAA,CACd,UACA,IAAA,EACY;AACZ,EAAA,MAAM,OAAA,GACH,OAAO,IAAA,EAAM,KAAA,KAAU,QAAA,IAAY,IAAA,CAAK,KAAA,IACzC,QAAA,CAAS,UAAA,IACT,CAAA,2BAAA,EAA8B,QAAA,CAAS,MAAM,CAAA,CAAA;AAC/C,EAAA,OAAO,IAAI,WAAW,OAAA,EAAS;AAAA,IAC7B,QAAQ,QAAA,CAAS,MAAA;AAAA,IACjB,IAAA,EAAM,QAAA,CAAS,OAAA,CAAQ,GAAA,CAAI,cAAc,CAAA,IAAK,MAAA;AAAA,IAC9C,SAAA,EAAW,QAAA,CAA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,IAAI,MAAM,cAAA,CAAe,UAAU,KAAK,CAAA;AAC7E,MAAA,IAAI,IAAA,KAAS,MAAA;AACX,QAAA,MAAM,cAAA,CAAe,QAAA,EAAU,EAAE,KAAA,EAAO,+BAA+B,CAAA;AACzE,MAAA,OAAO,IAAA;AAAA,IACT;AAAA,GACF;AACF","file":"index.js","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 }`. Additional fields may appear over time, so\n * we keep the type open.\n */\nexport interface KrovaErrorBody {\n error?: string;\n [key: string]: unknown;\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 */\nexport function krovaErrorFrom(\n response: Response,\n body: KrovaErrorBody | undefined,\n): KrovaError {\n const message =\n (typeof body?.error === \"string\" && body.error) ||\n response.statusText ||\n `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,\n response,\n });\n}\n","import createClient, { type Client, type Middleware } from \"openapi-fetch\";\nimport { krovaErrorFrom } 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/** 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/** 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> =>\n 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 * @param spaceId Target Space id.\n * @param body Cube spec — `{ name, image, resources, sshPublicKey, ... }`.\n * @param opts Optional `idempotencyKey` (max 255 chars, scoped per space).\n */\n create: async (\n spaceId: string,\n body: NonNullable<\n paths[\"/spaces/{spaceId}/cubes\"][\"post\"][\"requestBody\"]\n >[\"content\"][\"application/json\"],\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\n ? { header: { \"Idempotency-Key\": opts.idempotencyKey } }\n : {}),\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(\n \"/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 /** Delete a Cube (asynchronous — deletion is enqueued). */\n delete: async (spaceId: string, cubeId: string) => {\n const { data, error, response } = await this.raw.DELETE(\n \"/spaces/{spaceId}/cubes/{cubeId}\",\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: \"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 — a cold boot (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(\n \"/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)\n 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 /** Attach a custom domain to a Cube. `domain` + `port` are required. */\n create: async (\n spaceId: string,\n cubeId: string,\n body: CreateDomainInput,\n ): Promise<Domain> => {\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 data.domain;\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; `whitelistIps` optionally restricts who can reach 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, { error: \"Create TCP mapping response had no `tcpMapping`.\" });\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 // 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"]}
|
|
1
|
+
{"version":3,"sources":["../src/error.ts","../src/client.ts"],"names":[],"mappings":";;;;;AAoBO,IAAM,UAAA,GAAN,MAAM,WAAA,SAAmB,KAAA,CAAM;AAAA;AAAA,EAE3B,MAAA;AAAA;AAAA;AAA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* Per the OpenAPI spec (`components.schemas.Error`), every non-2xx response\n * body is `{ \"error\": string }`. Additional fields may appear over time, so\n * we keep the type open.\n */\nexport interface KrovaErrorBody {\n error?: string;\n [key: string]: unknown;\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 */\nexport function krovaErrorFrom(\n response: Response,\n body: KrovaErrorBody | undefined,\n): KrovaError {\n const message =\n (typeof body?.error === \"string\" && body.error) ||\n response.statusText ||\n `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,\n response,\n });\n}\n","import createClient, { type Client, type Middleware } from \"openapi-fetch\";\nimport { krovaErrorFrom } 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/** 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/** 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> =>\n 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 * @param spaceId Target Space id.\n * @param body Cube spec — `{ name, image, resources, sshPublicKey, ... }`.\n * @param opts Optional `idempotencyKey` (max 255 chars, scoped per space).\n */\n create: async (\n spaceId: string,\n body: NonNullable<\n paths[\"/spaces/{spaceId}/cubes\"][\"post\"][\"requestBody\"]\n >[\"content\"][\"application/json\"],\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\n ? { header: { \"Idempotency-Key\": opts.idempotencyKey } }\n : {}),\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(\n \"/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 /** Delete a Cube (asynchronous — deletion is enqueued). */\n delete: async (spaceId: string, cubeId: string) => {\n const { data, error, response } = await this.raw.DELETE(\n \"/spaces/{spaceId}/cubes/{cubeId}\",\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: \"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(\n \"/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)\n 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 /** Attach a custom domain to a Cube. `domain` + `port` are required. */\n create: async (\n spaceId: string,\n cubeId: string,\n body: CreateDomainInput,\n ): Promise<Domain> => {\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 data.domain;\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; `whitelistIps` optionally restricts who can reach 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, { error: \"Create TCP mapping response had no `tcpMapping`.\" });\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 // 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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@krovacloud/sdk",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.10",
|
|
4
4
|
"description": "Official TypeScript SDK for Krova Cloud — a typed client for provisioning and managing Cubes (Firecracker microVMs) with dedicated resources.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|