@krovacloud/sdk 0.4.12 → 0.4.13
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/CHANGELOG.md +4 -0
- package/README.md +33 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -28,6 +28,10 @@ All notable changes to `@krovacloud/sdk` are documented here. This project adher
|
|
|
28
28
|
arbitrary record should narrow to `body?.error` (or cast the body to a
|
|
29
29
|
concrete shape they actually expect).
|
|
30
30
|
|
|
31
|
+
### Documentation
|
|
32
|
+
|
|
33
|
+
- README documents `cubes.setTerminationProtection` (and `TerminationProtectedError`), `terminationProtection` on `cubes.create()` and on `Cube`, the `resizing` state, and `client.webhooks`. It no longer says webhooks need `client.raw`.
|
|
34
|
+
|
|
31
35
|
## 0.4.2
|
|
32
36
|
|
|
33
37
|
### Changed
|
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ The official TypeScript SDK for the [Krova Cloud](https://krova.cloud) API — a
|
|
|
10
10
|
## Highlights
|
|
11
11
|
|
|
12
12
|
- **Fully typed** — request bodies, responses, and path params are generated from the Krova Cloud OpenAPI spec via [`openapi-typescript`](https://github.com/openapi-ts/openapi-typescript) + [`openapi-fetch`](https://github.com/openapi-ts/openapi-typescript/tree/main/packages/openapi-fetch).
|
|
13
|
-
- **Ergonomic helpers** — `client.cubes
|
|
13
|
+
- **Ergonomic helpers** — `client.cubes`, `domains`, `snapshots`, `tcpMappings`, `imports`, `backups`, `webhooks` and `catalog` unwrap the response body and throw a typed `KrovaError` on failure.
|
|
14
14
|
- **Full escape hatch** — `client.raw` exposes the underlying typed client for every operation in the bundled OpenAPI spec (Domains, TCP mappings, Snapshots, Backups, Imports, Webhooks, and more).
|
|
15
15
|
- **Zero-config resilience** — automatic retries on `429` / `503`, honoring `Retry-After`.
|
|
16
16
|
- **ESM + CJS** — ships both, with bundled `.d.ts` declarations. No runtime dependencies beyond `openapi-fetch`.
|
|
@@ -118,7 +118,8 @@ Ergonomic helpers for the Cube lifecycle. Each unwraps the response body and thr
|
|
|
118
118
|
| `list` | `(spaceId: string)` | the Cube list body |
|
|
119
119
|
| `create` | `(spaceId, body, opts?)` | the created `Cube` |
|
|
120
120
|
| `get` | `(spaceId, cubeId)` | the Cube body |
|
|
121
|
-
| `update` | `(spaceId, cubeId, body)` |
|
|
121
|
+
| `update` | `(spaceId, cubeId, body)` | changes the port sshd listens on inside the Cube |
|
|
122
|
+
| `setTerminationProtection` | `(spaceId, cubeId, enabled)` | the updated `Cube`. While protection is on, `delete` throws `TerminationProtectedError` (a `KrovaError` for the API's `409`) |
|
|
122
123
|
| `delete` | `(spaceId, cubeId)` | enqueues deletion |
|
|
123
124
|
| `powerOff` | `(spaceId, cubeId)` | enqueues a power-off |
|
|
124
125
|
| `wake` | `(spaceId, cubeId)` | enqueues a start |
|
|
@@ -137,6 +138,7 @@ const cube = await krova.cubes.create(
|
|
|
137
138
|
sshPublicKey: "ssh-ed25519 AAAA... you@host",
|
|
138
139
|
region: "us", // optional — slug from catalog.regions()
|
|
139
140
|
userData: "#cloud-config\n", // optional — cloud-init (max 16 KB)
|
|
141
|
+
terminationProtection: true, // optional — refuse deletes until turned off
|
|
140
142
|
},
|
|
141
143
|
{ idempotencyKey: "deploy-2026-07-01" },
|
|
142
144
|
);
|
|
@@ -145,9 +147,12 @@ const cube = await krova.cubes.create(
|
|
|
145
147
|
const one = await krova.cubes.get("space_123", cube.id);
|
|
146
148
|
const all = await krova.cubes.list("space_123");
|
|
147
149
|
|
|
148
|
-
// update — the
|
|
150
|
+
// update — the port sshd listens on inside the Cube
|
|
149
151
|
await krova.cubes.update("space_123", cube.id, { cubePort: 2222 });
|
|
150
152
|
|
|
153
|
+
// termination protection — delete is refused until it is turned off
|
|
154
|
+
await krova.cubes.setTerminationProtection("space_123", cube.id, false);
|
|
155
|
+
|
|
151
156
|
// lifecycle — powerOff, wake, delete are asynchronous (enqueued)
|
|
152
157
|
await krova.cubes.powerOff("space_123", cube.id);
|
|
153
158
|
await krova.cubes.wake("space_123", cube.id);
|
|
@@ -165,10 +170,11 @@ The `Cube` type is exported for your own signatures:
|
|
|
165
170
|
import type { Cube } from "@krovacloud/sdk";
|
|
166
171
|
// {
|
|
167
172
|
// id: string; name: string;
|
|
168
|
-
// state: "pending" | "booting" | "running" | "stopped" | "stopping" | "error" | "deleted";
|
|
173
|
+
// state: "pending" | "booting" | "running" | "stopped" | "stopping" | "resizing" | "error" | "deleted";
|
|
169
174
|
// publicIpv4: string | null;
|
|
170
175
|
// resources: { vcpu: number; ramGb: number; diskGb: number };
|
|
171
176
|
// image: string; costPerHour: number;
|
|
177
|
+
// terminationProtection: boolean;
|
|
172
178
|
// createdAt: string; updatedAt: string;
|
|
173
179
|
// }
|
|
174
180
|
```
|
|
@@ -261,18 +267,35 @@ const status = await krova.imports.get("space_123", start.importId);
|
|
|
261
267
|
const dl = await krova.backups.download("space_123", "backup_123");
|
|
262
268
|
```
|
|
263
269
|
|
|
270
|
+
### Webhooks
|
|
271
|
+
|
|
272
|
+
`client.webhooks` manages a space's webhook endpoints. `create` is the only call that returns the signing secret, so store it straight away. To verify deliveries, use [`@krovacloud/webhook`](https://www.npmjs.com/package/@krovacloud/webhook).
|
|
273
|
+
|
|
274
|
+
```ts
|
|
275
|
+
const endpoint = await krova.webhooks.create("space_123", {
|
|
276
|
+
url: "https://example.com/hook",
|
|
277
|
+
events: ["cube.running", "cube.stopped"],
|
|
278
|
+
description: "deploy notifier", // optional
|
|
279
|
+
});
|
|
280
|
+
// endpoint.secret is returned only here: store it now
|
|
281
|
+
|
|
282
|
+
await krova.webhooks.list("space_123");
|
|
283
|
+
await krova.webhooks.get("space_123", endpoint.id);
|
|
284
|
+
await krova.webhooks.deliveries("space_123", endpoint.id, { limit: 20 }); // last 30 days
|
|
285
|
+
await krova.webhooks.delete("space_123", endpoint.id);
|
|
286
|
+
```
|
|
287
|
+
|
|
264
288
|
### `client.raw` — every endpoint
|
|
265
289
|
|
|
266
|
-
The helpers cover Cubes, the catalog, domains, snapshots, TCP mappings, imports, and
|
|
290
|
+
The helpers cover Cubes, the catalog, domains, snapshots, TCP mappings, imports, backups, and webhooks. When you would rather handle the error yourself than catch an exception, use `client.raw`, the fully typed [`openapi-fetch`](https://github.com/openapi-ts/openapi-typescript/tree/main/packages/openapi-fetch) client. It returns `{ data, error, response }` and **never throws**:
|
|
267
291
|
|
|
268
292
|
```ts
|
|
269
|
-
const { data, error } = await krova.raw.
|
|
270
|
-
params: { path: { spaceId: "space_123" } },
|
|
271
|
-
body: { url: "https://example.com/hook", events: ["cube.running"] },
|
|
293
|
+
const { data, error } = await krova.raw.GET("/spaces/{spaceId}/cubes/{cubeId}", {
|
|
294
|
+
params: { path: { spaceId: "space_123", cubeId: "cube_123" } },
|
|
272
295
|
});
|
|
273
296
|
|
|
274
297
|
if (error) {
|
|
275
|
-
console.error("
|
|
298
|
+
console.error("Cube lookup failed:", error.error);
|
|
276
299
|
} else {
|
|
277
300
|
console.log(data);
|
|
278
301
|
}
|
|
@@ -287,7 +310,7 @@ type Domain = components["schemas"]["Domain"];
|
|
|
287
310
|
|
|
288
311
|
### `KrovaError`
|
|
289
312
|
|
|
290
|
-
Thrown by
|
|
313
|
+
Thrown by every helper on any non-2xx response. (`client.raw` never throws — it returns the error in `{ error }`.)
|
|
291
314
|
|
|
292
315
|
| Field | Type | Source |
|
|
293
316
|
| --- | --- | --- |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@krovacloud/sdk",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.13",
|
|
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",
|