@krovacloud/sdk 0.4.0 → 0.4.1

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/dist/index.js CHANGED
@@ -1,545 +1,552 @@
1
- import createClient from 'openapi-fetch';
2
-
3
- // src/client.ts
4
-
5
- // src/error.ts
6
- var KrovaError = class _KrovaError extends Error {
7
- /** HTTP status code of the failing response. */
8
- status;
9
- /**
10
- * A machine-readable error code, when the API surfaces one via the
11
- * `X-Error-Code` response header. The documented error body only carries a
12
- * human-readable `error` string, so this is best-effort.
13
- */
14
- code;
15
- /**
16
- * The request id from the `X-Request-Id` response header, when present.
17
- * Useful when contacting Krova Cloud support about a specific failure.
18
- */
19
- requestId;
20
- /** The parsed JSON error body, when the response had one. */
21
- body;
22
- /** The raw `Response` object, for callers that need headers/url/etc. */
23
- response;
24
- constructor(message, init) {
25
- super(message);
26
- this.name = "KrovaError";
27
- this.status = init.status;
28
- this.code = init.code;
29
- this.requestId = init.requestId;
30
- this.body = init.body;
31
- this.response = init.response;
32
- Object.setPrototypeOf(this, _KrovaError.prototype);
33
- }
1
+ import createClient from "openapi-fetch";
2
+ //#region src/error.ts
3
+ /**
4
+ * Error thrown by the ergonomic {@link KrovaClient} helpers when the API
5
+ * responds with a non-2xx status.
6
+ *
7
+ * The raw openapi-fetch client (`client.raw`) never throws — it returns
8
+ * `{ data, error, response }`. The helpers wrap that and throw `KrovaError`
9
+ * so callers can `try/catch`.
10
+ */
11
+ var KrovaError = class KrovaError extends Error {
12
+ /** HTTP status code of the failing response. */
13
+ status;
14
+ /**
15
+ * A machine-readable error code, when the API surfaces one via the
16
+ * `X-Error-Code` response header. The documented error body only carries a
17
+ * human-readable `error` string, so this is best-effort.
18
+ */
19
+ code;
20
+ /**
21
+ * The request id from the `X-Request-Id` response header, when present.
22
+ * Useful when contacting Krova Cloud support about a specific failure.
23
+ */
24
+ requestId;
25
+ /** The parsed JSON error body, when the response had one. */
26
+ body;
27
+ /** The raw `Response` object, for callers that need headers/url/etc. */
28
+ response;
29
+ constructor(message, init) {
30
+ super(message);
31
+ this.name = "KrovaError";
32
+ this.status = init.status;
33
+ this.code = init.code;
34
+ this.requestId = init.requestId;
35
+ this.body = init.body;
36
+ this.response = init.response;
37
+ Object.setPrototypeOf(this, KrovaError.prototype);
38
+ }
34
39
  };
40
+ /**
41
+ * Build a {@link KrovaError} from a failing response + parsed error body.
42
+ */
35
43
  function krovaErrorFrom(response, body) {
36
- const message = typeof body?.error === "string" && body.error || response.statusText || `Request failed with status ${response.status}`;
37
- return new KrovaError(message, {
38
- status: response.status,
39
- code: response.headers.get("x-error-code") ?? void 0,
40
- requestId: response.headers.get("x-request-id") ?? void 0,
41
- body,
42
- response
43
- });
44
+ return new KrovaError(typeof body?.error === "string" && body.error || response.statusText || `Request failed with status ${response.status}`, {
45
+ status: response.status,
46
+ code: response.headers.get("x-error-code") ?? void 0,
47
+ requestId: response.headers.get("x-request-id") ?? void 0,
48
+ body,
49
+ response
50
+ });
44
51
  }
45
-
46
- // src/client.ts
47
- var DEFAULT_BASE_URL = "https://krova.cloud/api/v1";
48
- var RETRYABLE_STATUSES = /* @__PURE__ */ new Set([429, 503]);
49
- var BASE_BACKOFF_MS = 500;
50
- var MAX_BACKOFF_MS = 1e4;
51
- var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
52
+ //#endregion
53
+ //#region src/client.ts
54
+ /** Default API base URL — the single `servers[0].url` from the OpenAPI spec. */
55
+ const DEFAULT_BASE_URL = "https://krova.cloud/api/v1";
56
+ /** Statuses the retry middleware treats as transient. */
57
+ const RETRYABLE_STATUSES = /* @__PURE__ */ new Set([429, 503]);
58
+ /** Fallback backoff (ms) when the server sends no `Retry-After` header. */
59
+ const BASE_BACKOFF_MS = 500;
60
+ /** Cap on any single backoff wait (ms), to keep retries "small but real". */
61
+ const MAX_BACKOFF_MS = 1e4;
62
+ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
63
+ /**
64
+ * Parse a `Retry-After` header (RFC 7231): either delta-seconds or an
65
+ * HTTP-date. Returns milliseconds to wait, or `null` if absent/unparseable.
66
+ */
52
67
  function parseRetryAfterMs(headerValue) {
53
- if (!headerValue) return null;
54
- const seconds = Number(headerValue);
55
- if (Number.isFinite(seconds)) return Math.max(0, seconds * 1e3);
56
- const dateMs = Date.parse(headerValue);
57
- if (Number.isFinite(dateMs)) return Math.max(0, dateMs - Date.now());
58
- return null;
68
+ if (!headerValue) return null;
69
+ const seconds = Number(headerValue);
70
+ if (Number.isFinite(seconds)) return Math.max(0, seconds * 1e3);
71
+ const dateMs = Date.parse(headerValue);
72
+ if (Number.isFinite(dateMs)) return Math.max(0, dateMs - Date.now());
73
+ return null;
59
74
  }
60
75
  function authMiddleware(apiKey, scheme) {
61
- return {
62
- onRequest({ request }) {
63
- if (scheme === "bearer") {
64
- request.headers.set("Authorization", `Bearer ${apiKey}`);
65
- } else {
66
- request.headers.set("X-API-KEY", apiKey);
67
- }
68
- return request;
69
- }
70
- };
76
+ return { onRequest({ request }) {
77
+ if (scheme === "bearer") request.headers.set("Authorization", `Bearer ${apiKey}`);
78
+ else request.headers.set("X-API-KEY", apiKey);
79
+ return request;
80
+ } };
71
81
  }
82
+ /**
83
+ * Retry middleware: on a retryable status, wait (honoring `Retry-After` when
84
+ * present, else exponential backoff) and re-issue the request.
85
+ *
86
+ * A retried request may have a body (POST/PUT/DELETE — exactly the mutating,
87
+ * rate-limited endpoints). By the time `onResponse` runs, the request that was
88
+ * handed to `fetch` has had its body stream consumed, so `request.clone()` here
89
+ * throws `TypeError: unusable`. To re-issue it we stash a *pristine* clone in
90
+ * `onRequest` — captured before the body is read — keyed by openapi-fetch's
91
+ * per-request `id`, and clone from that pristine copy on each attempt.
92
+ */
72
93
  function retryMiddleware(maxRetries, doFetch) {
73
- const pristine = /* @__PURE__ */ new Map();
74
- return {
75
- onRequest({ request, id }) {
76
- pristine.set(id, request.clone());
77
- return request;
78
- },
79
- onError({ id }) {
80
- pristine.delete(id);
81
- },
82
- async onResponse({ request, response, id }) {
83
- const original = pristine.get(id) ?? request;
84
- pristine.delete(id);
85
- if (maxRetries <= 0 || !RETRYABLE_STATUSES.has(response.status)) {
86
- return response;
87
- }
88
- let current = response;
89
- for (let attempt = 1; attempt <= maxRetries; attempt++) {
90
- if (!RETRYABLE_STATUSES.has(current.status)) break;
91
- const retryAfterMs = parseRetryAfterMs(current.headers.get("retry-after"));
92
- const backoff = Math.min(BASE_BACKOFF_MS * 2 ** (attempt - 1), MAX_BACKOFF_MS);
93
- await sleep(Math.min(retryAfterMs ?? backoff, MAX_BACKOFF_MS));
94
- current = await doFetch(original.clone());
95
- }
96
- return current;
97
- }
98
- };
94
+ const pristine = /* @__PURE__ */ new Map();
95
+ return {
96
+ onRequest({ request, id }) {
97
+ pristine.set(id, request.clone());
98
+ return request;
99
+ },
100
+ onError({ id }) {
101
+ pristine.delete(id);
102
+ },
103
+ async onResponse({ request, response, id }) {
104
+ const original = pristine.get(id) ?? request;
105
+ pristine.delete(id);
106
+ if (maxRetries <= 0 || !RETRYABLE_STATUSES.has(response.status)) return response;
107
+ let current = response;
108
+ for (let attempt = 1; attempt <= maxRetries; attempt++) {
109
+ if (!RETRYABLE_STATUSES.has(current.status)) break;
110
+ const retryAfterMs = parseRetryAfterMs(current.headers.get("retry-after"));
111
+ const backoff = Math.min(BASE_BACKOFF_MS * 2 ** (attempt - 1), MAX_BACKOFF_MS);
112
+ await sleep(Math.min(retryAfterMs ?? backoff, MAX_BACKOFF_MS));
113
+ current = await doFetch(original.clone());
114
+ }
115
+ return current;
116
+ }
117
+ };
99
118
  }
119
+ /**
120
+ * A typed client for the Krova Cloud API.
121
+ *
122
+ * @example
123
+ * ```ts
124
+ * const krova = new KrovaClient({ apiKey: "kro_..." });
125
+ * const cubes = await krova.cubes.list("space_123");
126
+ * ```
127
+ */
100
128
  var KrovaClient = class {
101
- /**
102
- * The underlying openapi-fetch client — a fully typed escape hatch to every
103
- * path in the spec. Returns `{ data, error, response }` and never throws.
104
- *
105
- * @example
106
- * ```ts
107
- * const { data, error } = await krova.raw.GET(
108
- * "/spaces/{spaceId}/cubes/{cubeId}",
109
- * { params: { path: { spaceId, cubeId } } },
110
- * );
111
- * ```
112
- */
113
- raw;
114
- /** The resolved base URL in use. */
115
- baseUrl;
116
- constructor(options) {
117
- if (!options?.apiKey) {
118
- throw new Error("KrovaClient: `apiKey` is required.");
119
- }
120
- this.baseUrl = options.baseUrl ?? DEFAULT_BASE_URL;
121
- const doFetch = options.fetch ?? globalThis.fetch;
122
- const maxRetries = options.maxRetries ?? 2;
123
- this.raw = createClient({
124
- baseUrl: this.baseUrl,
125
- // SECURITY: never auto-follow redirects. The Krova Cloud API is a plain
126
- // JSON API and never legitimately 3xx's a data call. Following a redirect
127
- // would resend the `X-API-KEY` header to the redirect target — and unlike
128
- // `Authorization`, `Cookie`, and `Proxy-Authorization`, the Fetch spec does
129
- // NOT strip a custom header like `X-API-KEY` on a cross-origin redirect
130
- // (verified against undici/Node fetch). A compromised/misconfigured proxy,
131
- // an open-redirect on the API, or a MITM could otherwise exfiltrate the key
132
- // to an attacker's host. With `"manual"`, a redirect comes back as a
133
- // non-ok response and the helpers throw `KrovaError` instead of leaking.
134
- redirect: "manual",
135
- ...options.fetch ? { fetch: options.fetch } : {}
136
- });
137
- this.raw.use(authMiddleware(options.apiKey, options.authScheme ?? "x-api-key"));
138
- if (maxRetries > 0) {
139
- this.raw.use(retryMiddleware(maxRetries, doFetch));
140
- }
141
- }
142
- // ---------------------------------------------------------------------------
143
- // Cubes
144
- // ---------------------------------------------------------------------------
145
- cubes = {
146
- /** List Cubes in a Space, with pagination metadata. */
147
- list: async (spaceId) => {
148
- const { data, error, response } = await this.raw.GET("/spaces/{spaceId}/cubes", {
149
- params: { path: { spaceId } }
150
- });
151
- if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
152
- if (data === void 0)
153
- throw krovaErrorFrom(response, { error: "List Cubes response was empty." });
154
- return data;
155
- },
156
- /**
157
- * Create a Cube. Returns the created {@link Cube}.
158
- *
159
- * @param spaceId Target Space id.
160
- * @param body Cube spec — `{ name, image, resources, sshPublicKey, ... }`.
161
- * @param opts Optional `idempotencyKey` (max 255 chars, scoped per space).
162
- */
163
- create: async (spaceId, body, opts) => {
164
- const { data, error, response } = await this.raw.POST("/spaces/{spaceId}/cubes", {
165
- params: {
166
- path: { spaceId },
167
- ...opts?.idempotencyKey ? { header: { "Idempotency-Key": opts.idempotencyKey } } : {}
168
- },
169
- body
170
- });
171
- if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
172
- const cube = data?.cube;
173
- if (!cube) {
174
- throw krovaErrorFrom(response, { error: "Create Cube response had no `cube`." });
175
- }
176
- return cube;
177
- },
178
- /** Get a single Cube. Returns the {@link Cube}. */
179
- get: async (spaceId, cubeId) => {
180
- const { data, error, response } = await this.raw.GET(
181
- "/spaces/{spaceId}/cubes/{cubeId}",
182
- { params: { path: { spaceId, cubeId } } }
183
- );
184
- if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
185
- const cube = data?.cube;
186
- if (!cube) {
187
- throw krovaErrorFrom(response, { error: "Get Cube response had no `cube`." });
188
- }
189
- return cube;
190
- },
191
- /**
192
- * Update the IN-CUBE port that SSH is forwarded to.
193
- *
194
- * `cubePort` is the port **inside** the Cube that sshd listens on NOT the
195
- * host port you connect to. The host port is allocated by Krova and is not
196
- * changed by this call. Pointing this at a port nothing is listening on
197
- * inside the Cube will silently make SSH unreachable; the default is 22.
198
- *
199
- * The Krova Cloud API exposes no general Cube-mutation endpoint; the only
200
- * mutable Cube field over the API is this port, via
201
- * `PUT /spaces/{spaceId}/cubes/{cubeId}/ssh-port`. This helper maps to that
202
- * endpoint. (Compute resize / rename are not part of the public API.)
203
- */
204
- update: async (spaceId, cubeId, body) => {
205
- const { data, error, response } = await this.raw.PUT(
206
- "/spaces/{spaceId}/cubes/{cubeId}/ssh-port",
207
- { params: { path: { spaceId, cubeId } }, body }
208
- );
209
- if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
210
- return data;
211
- },
212
- /** Delete a Cube (asynchronous — deletion is enqueued). */
213
- delete: async (spaceId, cubeId) => {
214
- const { data, error, response } = await this.raw.DELETE(
215
- "/spaces/{spaceId}/cubes/{cubeId}",
216
- { params: { path: { spaceId, cubeId } } }
217
- );
218
- if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
219
- if (data === void 0)
220
- throw krovaErrorFrom(response, { error: "Delete Cube response was empty." });
221
- return data;
222
- },
223
- /** Power off a running Cube (asynchronous power-off is enqueued). The Cube
224
- * becomes `stopped` (its host RAM is freed); start it again with `wake`. */
225
- powerOff: async (spaceId, cubeId) => {
226
- const { data, error, response } = await this.raw.POST(
227
- "/spaces/{spaceId}/cubes/{cubeId}/power-off",
228
- { params: { path: { spaceId, cubeId } } }
229
- );
230
- if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
231
- return data;
232
- },
233
- /** Start a stopped Cube (asynchronous — start is enqueued). */
234
- /**
235
- * Restart a Cube (COLD restart).
236
- *
237
- * The hypervisor process is stopped and relaunched, so the Cube boots
238
- * against the host's current kernel. This is the only way a Cube picks up a
239
- * refreshed guest kernel after a platform image update — a `reboot` issued
240
- * INSIDE the Cube cannot do it, because Firecracker treats a guest reboot as
241
- * a shutdown and the kernel is supplied externally by the host.
242
- *
243
- * Disk state is preserved; only the kernel changes. The Cube must be
244
- * `running`. Concurrent restarts of the same Cube are rejected (409) rather
245
- * than queued twice.
246
- */
247
- restart: async (spaceId, cubeId) => {
248
- const { data, error, response } = await this.raw.POST(
249
- "/spaces/{spaceId}/cubes/{cubeId}/restart",
250
- { params: { path: { spaceId, cubeId } } }
251
- );
252
- if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
253
- return data;
254
- },
255
- wake: async (spaceId, cubeId) => {
256
- const { data, error, response } = await this.raw.POST(
257
- "/spaces/{spaceId}/cubes/{cubeId}/wake",
258
- { params: { path: { spaceId, cubeId } } }
259
- );
260
- if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
261
- return data;
262
- },
263
- /**
264
- * Get a Cube's SSH connection info — host, port, login user, and (when
265
- * available) the pinned host public keys for strict host-key verification.
266
- */
267
- ssh: async (spaceId, cubeId) => {
268
- const { data, error, response } = await this.raw.GET(
269
- "/spaces/{spaceId}/cubes/{cubeId}/ssh",
270
- { params: { path: { spaceId, cubeId } } }
271
- );
272
- if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
273
- if (data === void 0)
274
- throw krovaErrorFrom(response, { error: "Cube SSH-info response was empty." });
275
- return data;
276
- },
277
- /**
278
- * Restore a Cube's disk from one of its {@link Snapshot}s (asynchronous —
279
- * the restore is enqueued). The Cube's current disk is replaced.
280
- */
281
- restore: async (spaceId, cubeId, snapshotId) => {
282
- const { data, error, response } = await this.raw.POST(
283
- "/spaces/{spaceId}/cubes/{cubeId}/restore",
284
- { params: { path: { spaceId, cubeId } }, body: { snapshotId } }
285
- );
286
- if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
287
- return data;
288
- }
289
- };
290
- /**
291
- * Resolve the {@link Space} this API key is scoped to — so you don't have to
292
- * hardcode a `spaceId`. Handy right after constructing the client:
293
- *
294
- * @example
295
- * ```ts
296
- * const space = await krova.getSpace();
297
- * const cubes = await krova.cubes.list(space.id);
298
- * ```
299
- */
300
- async getSpace() {
301
- const { data, error, response } = await this.raw.GET("/space");
302
- if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
303
- if (data === void 0)
304
- throw krovaErrorFrom(response, { error: "Space response was empty." });
305
- return data;
306
- }
307
- // ---------------------------------------------------------------------------
308
- // Custom domains
309
- // ---------------------------------------------------------------------------
310
- domains = {
311
- /** List the custom domains attached to a Cube. */
312
- list: async (spaceId, cubeId) => {
313
- const { data, error, response } = await this.raw.GET(
314
- "/spaces/{spaceId}/cubes/{cubeId}/domains",
315
- { params: { path: { spaceId, cubeId } } }
316
- );
317
- if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
318
- return data?.domains ?? [];
319
- },
320
- /**
321
- * Attach a custom domain to a Cube. `domain` + `port` are required.
322
- *
323
- * Returns the domain AND the DNS records you must publish for it to work —
324
- * so you can create them in the same run, without a second call and without
325
- * hard-coding record shapes. A wildcard needs three; an exact host needs one.
326
- *
327
- * ⛔ BREAKING in 0.4.0: this used to resolve to `Domain`. It now resolves to
328
- * `{ domain, records }`, because for a wildcard two of the three records
329
- * (the ownership TXT and the `_acme-challenge` delegation) were not
330
- * derivable from anything the SDK returned an integration had to read
331
- * them out of the docs and hope they still matched the server.
332
- */
333
- create: async (spaceId, cubeId, body) => {
334
- const { data, error, response } = await this.raw.POST(
335
- "/spaces/{spaceId}/cubes/{cubeId}/domains",
336
- { params: { path: { spaceId, cubeId } }, body }
337
- );
338
- if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
339
- if (!data?.domain)
340
- throw krovaErrorFrom(response, { error: "Create domain response had no `domain`." });
341
- return { domain: data.domain, records: data.records ?? [] };
342
- },
343
- /**
344
- * The DNS records a domain needs, each checked against live DNS.
345
- *
346
- * Poll this after publishing them: `summary.complete` turns true only once
347
- * every record is `found`. Each call performs real DNS lookups and is rate
348
- * limited, so poll on an interval rather than in a tight loop.
349
- */
350
- records: async (spaceId, cubeId, mappingId) => {
351
- const { data, error, response } = await this.raw.GET(
352
- "/spaces/{spaceId}/cubes/{cubeId}/domains/{mappingId}/records",
353
- { params: { path: { spaceId, cubeId, mappingId } } }
354
- );
355
- if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
356
- if (!data)
357
- throw krovaErrorFrom(response, { error: "Domain records response was empty." });
358
- return data;
359
- },
360
- /** Update a domain's per-domain proxy settings. */
361
- update: async (spaceId, cubeId, mappingId, body) => {
362
- const { data, error, response } = await this.raw.PATCH(
363
- "/spaces/{spaceId}/cubes/{cubeId}/domains/{mappingId}",
364
- { params: { path: { spaceId, cubeId, mappingId } }, body }
365
- );
366
- if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
367
- if (!data?.domain)
368
- throw krovaErrorFrom(response, { error: "Update domain response had no `domain`." });
369
- return data.domain;
370
- },
371
- /** Detach a custom domain from a Cube. */
372
- delete: async (spaceId, cubeId, mappingId) => {
373
- const { data, error, response } = await this.raw.DELETE(
374
- "/spaces/{spaceId}/cubes/{cubeId}/domains/{mappingId}",
375
- { params: { path: { spaceId, cubeId, mappingId } } }
376
- );
377
- if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
378
- return data;
379
- }
380
- };
381
- // ---------------------------------------------------------------------------
382
- // Snapshots
383
- // ---------------------------------------------------------------------------
384
- snapshots = {
385
- /** List a Cube's snapshots. */
386
- list: async (spaceId, cubeId) => {
387
- const { data, error, response } = await this.raw.GET(
388
- "/spaces/{spaceId}/cubes/{cubeId}/snapshots",
389
- { params: { path: { spaceId, cubeId } } }
390
- );
391
- if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
392
- return data?.snapshots ?? [];
393
- },
394
- /** Create a snapshot of a Cube's disk (asynchronous — enqueued). */
395
- create: async (spaceId, cubeId, body) => {
396
- const { data, error, response } = await this.raw.POST(
397
- "/spaces/{spaceId}/cubes/{cubeId}/snapshots",
398
- { params: { path: { spaceId, cubeId } }, body: body ?? {} }
399
- );
400
- if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
401
- if (!data?.snapshot)
402
- throw krovaErrorFrom(response, { error: "Create snapshot response had no `snapshot`." });
403
- return data.snapshot;
404
- },
405
- /** Delete a snapshot. */
406
- delete: async (spaceId, cubeId, snapshotId) => {
407
- const { data, error, response } = await this.raw.DELETE(
408
- "/spaces/{spaceId}/cubes/{cubeId}/snapshots/{snapshotId}",
409
- { params: { path: { spaceId, cubeId, snapshotId } } }
410
- );
411
- if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
412
- return data;
413
- }
414
- };
415
- // ---------------------------------------------------------------------------
416
- // TCP port mappings
417
- // ---------------------------------------------------------------------------
418
- tcpMappings = {
419
- /** List a Cube's TCP port mappings. */
420
- list: async (spaceId, cubeId) => {
421
- const { data, error, response } = await this.raw.GET(
422
- "/spaces/{spaceId}/cubes/{cubeId}/tcp-mappings",
423
- { params: { path: { spaceId, cubeId } } }
424
- );
425
- if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
426
- return data?.tcpMappings ?? [];
427
- },
428
- /**
429
- * Create a TCP port mapping exposing a Cube port on the host. `cubePort` is
430
- * required; `whitelistIps` optionally restricts who can reach it.
431
- */
432
- create: async (spaceId, cubeId, body) => {
433
- const { data, error, response } = await this.raw.POST(
434
- "/spaces/{spaceId}/cubes/{cubeId}/tcp-mappings",
435
- { params: { path: { spaceId, cubeId } }, body }
436
- );
437
- if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
438
- if (!data?.tcpMapping)
439
- throw krovaErrorFrom(response, { error: "Create TCP mapping response had no `tcpMapping`." });
440
- return data.tcpMapping;
441
- },
442
- /** Delete a TCP port mapping. */
443
- delete: async (spaceId, cubeId, mappingId) => {
444
- const { data, error, response } = await this.raw.DELETE(
445
- "/spaces/{spaceId}/cubes/{cubeId}/tcp-mappings/{mappingId}",
446
- { params: { path: { spaceId, cubeId, mappingId } } }
447
- );
448
- if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
449
- return data;
450
- }
451
- };
452
- // ---------------------------------------------------------------------------
453
- // Imports & backups (.cube archive import / export)
454
- // ---------------------------------------------------------------------------
455
- imports = {
456
- /**
457
- * Start importing a `.cube` archive into a new Cube. Returns the multipart
458
- * upload target (`importId`, `uploadId`, presigned `parts`, …). Upload the
459
- * archive to those URLs, then call {@link imports.complete}.
460
- */
461
- create: async (spaceId, body) => {
462
- const { data, error, response } = await this.raw.POST("/spaces/{spaceId}/cubes/imports", {
463
- params: { path: { spaceId } },
464
- body
465
- });
466
- if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
467
- return data;
468
- },
469
- /** Get an in-progress or completed import by id. */
470
- get: async (spaceId, importId) => {
471
- const { data, error, response } = await this.raw.GET(
472
- "/spaces/{spaceId}/cubes/imports/{importId}",
473
- { params: { path: { spaceId, importId } } }
474
- );
475
- if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
476
- return data;
477
- },
478
- /**
479
- * Finish an import after the archive has been uploaded provisions the
480
- * Cube. Pass the uploaded `parts` (partNumber + etag) and the resolved
481
- * `config`.
482
- */
483
- complete: async (spaceId, importId, body) => {
484
- const { data, error, response } = await this.raw.POST(
485
- "/spaces/{spaceId}/cubes/imports/{importId}/complete",
486
- { params: { path: { spaceId, importId } }, body }
487
- );
488
- if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
489
- return data;
490
- },
491
- /** Cancel an in-progress import. */
492
- cancel: async (spaceId, importId) => {
493
- const { data, error, response } = await this.raw.DELETE(
494
- "/spaces/{spaceId}/cubes/imports/{importId}",
495
- { params: { path: { spaceId, importId } } }
496
- );
497
- if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
498
- return data;
499
- }
500
- };
501
- backups = {
502
- /** Get a time-limited download URL for a backup `.cube` archive. */
503
- download: async (spaceId, backupId) => {
504
- const { data, error, response } = await this.raw.GET(
505
- "/spaces/{spaceId}/backups/{backupId}/download",
506
- { params: { path: { spaceId, backupId } } }
507
- );
508
- if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
509
- return data;
510
- }
511
- };
512
- // ---------------------------------------------------------------------------
513
- // Public catalog (no auth required by the API, but the key is harmless)
514
- // ---------------------------------------------------------------------------
515
- catalog = {
516
- /** List regions with available capacity. */
517
- regions: async () => {
518
- const { data, error, response } = await this.raw.GET("/regions");
519
- if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
520
- if (data === void 0)
521
- throw krovaErrorFrom(response, { error: "Regions response was empty." });
522
- return data;
523
- },
524
- /** List available OS images. */
525
- images: async () => {
526
- const { data, error, response } = await this.raw.GET("/images");
527
- if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
528
- if (data === void 0)
529
- throw krovaErrorFrom(response, { error: "Images response was empty." });
530
- return data;
531
- },
532
- /** Per-resource hourly rates and volume pricing tiers. */
533
- pricing: async () => {
534
- const { data, error, response } = await this.raw.GET("/pricing");
535
- if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
536
- if (data === void 0)
537
- throw krovaErrorFrom(response, { error: "Pricing response was empty." });
538
- return data;
539
- }
540
- };
129
+ /**
130
+ * The underlying openapi-fetch client — a fully typed escape hatch to every
131
+ * path in the spec. Returns `{ data, error, response }` and never throws.
132
+ *
133
+ * @example
134
+ * ```ts
135
+ * const { data, error } = await krova.raw.GET(
136
+ * "/spaces/{spaceId}/cubes/{cubeId}",
137
+ * { params: { path: { spaceId, cubeId } } },
138
+ * );
139
+ * ```
140
+ */
141
+ raw;
142
+ /** The resolved base URL in use. */
143
+ baseUrl;
144
+ constructor(options) {
145
+ if (!options?.apiKey) throw new Error("KrovaClient: `apiKey` is required.");
146
+ this.baseUrl = options.baseUrl ?? "https://krova.cloud/api/v1";
147
+ const doFetch = options.fetch ?? globalThis.fetch;
148
+ const maxRetries = options.maxRetries ?? 2;
149
+ this.raw = createClient({
150
+ baseUrl: this.baseUrl,
151
+ redirect: "manual",
152
+ ...options.fetch ? { fetch: options.fetch } : {}
153
+ });
154
+ this.raw.use(authMiddleware(options.apiKey, options.authScheme ?? "x-api-key"));
155
+ if (maxRetries > 0) this.raw.use(retryMiddleware(maxRetries, doFetch));
156
+ }
157
+ cubes = {
158
+ /** List Cubes in a Space, with pagination metadata. */
159
+ list: async (spaceId) => {
160
+ const { data, error, response } = await this.raw.GET("/spaces/{spaceId}/cubes", { params: { path: { spaceId } } });
161
+ if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
162
+ if (data === void 0) throw krovaErrorFrom(response, { error: "List Cubes response was empty." });
163
+ return data;
164
+ },
165
+ /**
166
+ * Create a Cube. Returns the created {@link Cube}.
167
+ *
168
+ * @param spaceId Target Space id.
169
+ * @param body Cube spec — `{ name, image, resources, sshPublicKey, ... }`.
170
+ * @param opts Optional `idempotencyKey` (max 255 chars, scoped per space).
171
+ */
172
+ create: async (spaceId, body, opts) => {
173
+ const { data, error, response } = await this.raw.POST("/spaces/{spaceId}/cubes", {
174
+ params: {
175
+ path: { spaceId },
176
+ ...opts?.idempotencyKey ? { header: { "Idempotency-Key": opts.idempotencyKey } } : {}
177
+ },
178
+ body
179
+ });
180
+ if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
181
+ const cube = data?.cube;
182
+ if (!cube) throw krovaErrorFrom(response, { error: "Create Cube response had no `cube`." });
183
+ return cube;
184
+ },
185
+ /** Get a single Cube. Returns the {@link Cube}. */
186
+ get: async (spaceId, cubeId) => {
187
+ const { data, error, response } = await this.raw.GET("/spaces/{spaceId}/cubes/{cubeId}", { params: { path: {
188
+ spaceId,
189
+ cubeId
190
+ } } });
191
+ if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
192
+ const cube = data?.cube;
193
+ if (!cube) throw krovaErrorFrom(response, { error: "Get Cube response had no `cube`." });
194
+ return cube;
195
+ },
196
+ /**
197
+ * Update the IN-CUBE port that SSH is forwarded to.
198
+ *
199
+ * `cubePort` is the port **inside** the Cube that sshd listens on — NOT the
200
+ * host port you connect to. The host port is allocated by Krova and is not
201
+ * changed by this call. Pointing this at a port nothing is listening on
202
+ * inside the Cube will silently make SSH unreachable; the default is 22.
203
+ *
204
+ * The Krova Cloud API exposes no general Cube-mutation endpoint; the only
205
+ * mutable Cube field over the API is this port, via
206
+ * `PUT /spaces/{spaceId}/cubes/{cubeId}/ssh-port`. This helper maps to that
207
+ * endpoint. (Compute resize / rename are not part of the public API.)
208
+ */
209
+ update: async (spaceId, cubeId, body) => {
210
+ const { data, error, response } = await this.raw.PUT("/spaces/{spaceId}/cubes/{cubeId}/ssh-port", {
211
+ params: { path: {
212
+ spaceId,
213
+ cubeId
214
+ } },
215
+ body
216
+ });
217
+ if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
218
+ return data;
219
+ },
220
+ /** Delete a Cube (asynchronous deletion is enqueued). */
221
+ delete: async (spaceId, cubeId) => {
222
+ const { data, error, response } = await this.raw.DELETE("/spaces/{spaceId}/cubes/{cubeId}", { params: { path: {
223
+ spaceId,
224
+ cubeId
225
+ } } });
226
+ if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
227
+ if (data === void 0) throw krovaErrorFrom(response, { error: "Delete Cube response was empty." });
228
+ return data;
229
+ },
230
+ /** Power off a running Cube (asynchronous power-off is enqueued). The Cube
231
+ * becomes `stopped` (its host RAM is freed); start it again with `wake`. */
232
+ powerOff: async (spaceId, cubeId) => {
233
+ const { data, error, response } = await this.raw.POST("/spaces/{spaceId}/cubes/{cubeId}/power-off", { params: { path: {
234
+ spaceId,
235
+ cubeId
236
+ } } });
237
+ if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
238
+ return data;
239
+ },
240
+ /** Start a stopped Cube (asynchronous — start is enqueued). */
241
+ /**
242
+ * Restart a Cube (COLD restart).
243
+ *
244
+ * The hypervisor process is stopped and relaunched, so the Cube boots
245
+ * against the host's current kernel. This is the only way a Cube picks up a
246
+ * refreshed guest kernel after a platform image update — a `reboot` issued
247
+ * INSIDE the Cube cannot do it, because Firecracker treats a guest reboot as
248
+ * a shutdown and the kernel is supplied externally by the host.
249
+ *
250
+ * Disk state is preserved; only the kernel changes. The Cube must be
251
+ * `running`. Concurrent restarts of the same Cube are rejected (409) rather
252
+ * than queued twice.
253
+ */
254
+ restart: async (spaceId, cubeId) => {
255
+ const { data, error, response } = await this.raw.POST("/spaces/{spaceId}/cubes/{cubeId}/restart", { params: { path: {
256
+ spaceId,
257
+ cubeId
258
+ } } });
259
+ if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
260
+ return data;
261
+ },
262
+ wake: async (spaceId, cubeId) => {
263
+ const { data, error, response } = await this.raw.POST("/spaces/{spaceId}/cubes/{cubeId}/wake", { params: { path: {
264
+ spaceId,
265
+ cubeId
266
+ } } });
267
+ if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
268
+ return data;
269
+ },
270
+ /**
271
+ * Get a Cube's SSH connection info host, port, login user, and (when
272
+ * available) the pinned host public keys for strict host-key verification.
273
+ */
274
+ ssh: async (spaceId, cubeId) => {
275
+ const { data, error, response } = await this.raw.GET("/spaces/{spaceId}/cubes/{cubeId}/ssh", { params: { path: {
276
+ spaceId,
277
+ cubeId
278
+ } } });
279
+ if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
280
+ if (data === void 0) throw krovaErrorFrom(response, { error: "Cube SSH-info response was empty." });
281
+ return data;
282
+ },
283
+ /**
284
+ * Restore a Cube's disk from one of its {@link Snapshot}s (asynchronous —
285
+ * the restore is enqueued). The Cube's current disk is replaced.
286
+ */
287
+ restore: async (spaceId, cubeId, snapshotId) => {
288
+ const { data, error, response } = await this.raw.POST("/spaces/{spaceId}/cubes/{cubeId}/restore", {
289
+ params: { path: {
290
+ spaceId,
291
+ cubeId
292
+ } },
293
+ body: { snapshotId }
294
+ });
295
+ if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
296
+ return data;
297
+ }
298
+ };
299
+ /**
300
+ * Resolve the {@link Space} this API key is scoped to — so you don't have to
301
+ * hardcode a `spaceId`. Handy right after constructing the client:
302
+ *
303
+ * @example
304
+ * ```ts
305
+ * const space = await krova.getSpace();
306
+ * const cubes = await krova.cubes.list(space.id);
307
+ * ```
308
+ */
309
+ async getSpace() {
310
+ const { data, error, response } = await this.raw.GET("/space");
311
+ if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
312
+ if (data === void 0) throw krovaErrorFrom(response, { error: "Space response was empty." });
313
+ return data;
314
+ }
315
+ domains = {
316
+ /** List the custom domains attached to a Cube. */
317
+ list: async (spaceId, cubeId) => {
318
+ const { data, error, response } = await this.raw.GET("/spaces/{spaceId}/cubes/{cubeId}/domains", { params: { path: {
319
+ spaceId,
320
+ cubeId
321
+ } } });
322
+ if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
323
+ return data?.domains ?? [];
324
+ },
325
+ /**
326
+ * Attach a custom domain to a Cube. `domain` + `port` are required.
327
+ *
328
+ * Returns the domain AND the DNS records you must publish for it to work —
329
+ * so you can create them in the same run, without a second call and without
330
+ * hard-coding record shapes. A wildcard needs three; an exact host needs one.
331
+ *
332
+ * BREAKING in 0.4.0: this used to resolve to `Domain`. It now resolves to
333
+ * `{ domain, records }`, because for a wildcard two of the three records
334
+ * (the ownership TXT and the `_acme-challenge` delegation) were not
335
+ * derivable from anything the SDK returned — an integration had to read
336
+ * them out of the docs and hope they still matched the server.
337
+ */
338
+ create: async (spaceId, cubeId, body) => {
339
+ const { data, error, response } = await this.raw.POST("/spaces/{spaceId}/cubes/{cubeId}/domains", {
340
+ params: { path: {
341
+ spaceId,
342
+ cubeId
343
+ } },
344
+ body
345
+ });
346
+ if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
347
+ if (!data?.domain) throw krovaErrorFrom(response, { error: "Create domain response had no `domain`." });
348
+ return {
349
+ domain: data.domain,
350
+ records: data.records ?? []
351
+ };
352
+ },
353
+ /**
354
+ * The DNS records a domain needs, each checked against live DNS.
355
+ *
356
+ * Poll this after publishing them: `summary.complete` turns true only once
357
+ * every record is `found`. Each call performs real DNS lookups and is rate
358
+ * limited, so poll on an interval rather than in a tight loop.
359
+ */
360
+ records: async (spaceId, cubeId, mappingId) => {
361
+ const { data, error, response } = await this.raw.GET("/spaces/{spaceId}/cubes/{cubeId}/domains/{mappingId}/records", { params: { path: {
362
+ spaceId,
363
+ cubeId,
364
+ mappingId
365
+ } } });
366
+ if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
367
+ if (!data) throw krovaErrorFrom(response, { error: "Domain records response was empty." });
368
+ return data;
369
+ },
370
+ /** Update a domain's per-domain proxy settings. */
371
+ update: async (spaceId, cubeId, mappingId, body) => {
372
+ const { data, error, response } = await this.raw.PATCH("/spaces/{spaceId}/cubes/{cubeId}/domains/{mappingId}", {
373
+ params: { path: {
374
+ spaceId,
375
+ cubeId,
376
+ mappingId
377
+ } },
378
+ body
379
+ });
380
+ if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
381
+ if (!data?.domain) throw krovaErrorFrom(response, { error: "Update domain response had no `domain`." });
382
+ return data.domain;
383
+ },
384
+ /** Detach a custom domain from a Cube. */
385
+ delete: async (spaceId, cubeId, mappingId) => {
386
+ const { data, error, response } = await this.raw.DELETE("/spaces/{spaceId}/cubes/{cubeId}/domains/{mappingId}", { params: { path: {
387
+ spaceId,
388
+ cubeId,
389
+ mappingId
390
+ } } });
391
+ if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
392
+ return data;
393
+ }
394
+ };
395
+ snapshots = {
396
+ /** List a Cube's snapshots. */
397
+ list: async (spaceId, cubeId) => {
398
+ const { data, error, response } = await this.raw.GET("/spaces/{spaceId}/cubes/{cubeId}/snapshots", { params: { path: {
399
+ spaceId,
400
+ cubeId
401
+ } } });
402
+ if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
403
+ return data?.snapshots ?? [];
404
+ },
405
+ /** Create a snapshot of a Cube's disk (asynchronous — enqueued). */
406
+ create: async (spaceId, cubeId, body) => {
407
+ const { data, error, response } = await this.raw.POST("/spaces/{spaceId}/cubes/{cubeId}/snapshots", {
408
+ params: { path: {
409
+ spaceId,
410
+ cubeId
411
+ } },
412
+ body: body ?? {}
413
+ });
414
+ if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
415
+ if (!data?.snapshot) throw krovaErrorFrom(response, { error: "Create snapshot response had no `snapshot`." });
416
+ return data.snapshot;
417
+ },
418
+ /** Delete a snapshot. */
419
+ delete: async (spaceId, cubeId, snapshotId) => {
420
+ const { data, error, response } = await this.raw.DELETE("/spaces/{spaceId}/cubes/{cubeId}/snapshots/{snapshotId}", { params: { path: {
421
+ spaceId,
422
+ cubeId,
423
+ snapshotId
424
+ } } });
425
+ if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
426
+ return data;
427
+ }
428
+ };
429
+ tcpMappings = {
430
+ /** List a Cube's TCP port mappings. */
431
+ list: async (spaceId, cubeId) => {
432
+ const { data, error, response } = await this.raw.GET("/spaces/{spaceId}/cubes/{cubeId}/tcp-mappings", { params: { path: {
433
+ spaceId,
434
+ cubeId
435
+ } } });
436
+ if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
437
+ return data?.tcpMappings ?? [];
438
+ },
439
+ /**
440
+ * Create a TCP port mapping exposing a Cube port on the host. `cubePort` is
441
+ * required; `whitelistIps` optionally restricts who can reach it.
442
+ */
443
+ create: async (spaceId, cubeId, body) => {
444
+ const { data, error, response } = await this.raw.POST("/spaces/{spaceId}/cubes/{cubeId}/tcp-mappings", {
445
+ params: { path: {
446
+ spaceId,
447
+ cubeId
448
+ } },
449
+ body
450
+ });
451
+ if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
452
+ if (!data?.tcpMapping) throw krovaErrorFrom(response, { error: "Create TCP mapping response had no `tcpMapping`." });
453
+ return data.tcpMapping;
454
+ },
455
+ /** Delete a TCP port mapping. */
456
+ delete: async (spaceId, cubeId, mappingId) => {
457
+ const { data, error, response } = await this.raw.DELETE("/spaces/{spaceId}/cubes/{cubeId}/tcp-mappings/{mappingId}", { params: { path: {
458
+ spaceId,
459
+ cubeId,
460
+ mappingId
461
+ } } });
462
+ if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
463
+ return data;
464
+ }
465
+ };
466
+ imports = {
467
+ /**
468
+ * Start importing a `.cube` archive into a new Cube. Returns the multipart
469
+ * upload target (`importId`, `uploadId`, presigned `parts`, …). Upload the
470
+ * archive to those URLs, then call {@link imports.complete}.
471
+ */
472
+ create: async (spaceId, body) => {
473
+ const { data, error, response } = await this.raw.POST("/spaces/{spaceId}/cubes/imports", {
474
+ params: { path: { spaceId } },
475
+ body
476
+ });
477
+ if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
478
+ return data;
479
+ },
480
+ /** Get an in-progress or completed import by id. */
481
+ get: async (spaceId, importId) => {
482
+ const { data, error, response } = await this.raw.GET("/spaces/{spaceId}/cubes/imports/{importId}", { params: { path: {
483
+ spaceId,
484
+ importId
485
+ } } });
486
+ if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
487
+ return data;
488
+ },
489
+ /**
490
+ * Finish an import after the archive has been uploaded — provisions the
491
+ * Cube. Pass the uploaded `parts` (partNumber + etag) and the resolved
492
+ * `config`.
493
+ */
494
+ complete: async (spaceId, importId, body) => {
495
+ const { data, error, response } = await this.raw.POST("/spaces/{spaceId}/cubes/imports/{importId}/complete", {
496
+ params: { path: {
497
+ spaceId,
498
+ importId
499
+ } },
500
+ body
501
+ });
502
+ if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
503
+ return data;
504
+ },
505
+ /** Cancel an in-progress import. */
506
+ cancel: async (spaceId, importId) => {
507
+ const { data, error, response } = await this.raw.DELETE("/spaces/{spaceId}/cubes/imports/{importId}", { params: { path: {
508
+ spaceId,
509
+ importId
510
+ } } });
511
+ if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
512
+ return data;
513
+ }
514
+ };
515
+ backups = {
516
+ /** Get a time-limited download URL for a backup `.cube` archive. */
517
+ download: async (spaceId, backupId) => {
518
+ const { data, error, response } = await this.raw.GET("/spaces/{spaceId}/backups/{backupId}/download", { params: { path: {
519
+ spaceId,
520
+ backupId
521
+ } } });
522
+ if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
523
+ return data;
524
+ } };
525
+ catalog = {
526
+ /** List regions with available capacity. */
527
+ regions: async () => {
528
+ const { data, error, response } = await this.raw.GET("/regions");
529
+ if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
530
+ if (data === void 0) throw krovaErrorFrom(response, { error: "Regions response was empty." });
531
+ return data;
532
+ },
533
+ /** List available OS images. */
534
+ images: async () => {
535
+ const { data, error, response } = await this.raw.GET("/images");
536
+ if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
537
+ if (data === void 0) throw krovaErrorFrom(response, { error: "Images response was empty." });
538
+ return data;
539
+ },
540
+ /** Per-resource hourly rates and volume pricing tiers. */
541
+ pricing: async () => {
542
+ const { data, error, response } = await this.raw.GET("/pricing");
543
+ if (error !== void 0 || !response.ok) throw krovaErrorFrom(response, error);
544
+ if (data === void 0) throw krovaErrorFrom(response, { error: "Pricing response was empty." });
545
+ return data;
546
+ }
547
+ };
541
548
  };
542
-
549
+ //#endregion
543
550
  export { DEFAULT_BASE_URL, KrovaClient, KrovaError, krovaErrorFrom };
544
- //# sourceMappingURL=index.js.map
551
+
545
552
  //# sourceMappingURL=index.js.map