@fly.io/sdk 0.1.0 → 0.1.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/README.md +56 -0
- package/package.json +6 -2
package/README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# @fly.io/sdk
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for Fly Machines REST and GraphQL APIs.
|
|
4
|
+
|
|
5
|
+
This package is maintained in the `fly-admin` folder of the kimaki monorepo:
|
|
6
|
+
https://github.com/remorses/kimaki/tree/main/fly-admin
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pnpm add @fly.io/sdk
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Quick start
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import { Client } from '@fly.io/sdk'
|
|
18
|
+
|
|
19
|
+
const client = new Client(process.env.FLY_API_TOKEN || '')
|
|
20
|
+
|
|
21
|
+
const app = await client.App.getApp('my-app')
|
|
22
|
+
if (app instanceof Error) {
|
|
23
|
+
console.error(app.message)
|
|
24
|
+
} else {
|
|
25
|
+
console.log(app.name)
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Error handling
|
|
30
|
+
|
|
31
|
+
All methods return `Error | T` (via `FlyResult<T>`), following the errore style.
|
|
32
|
+
|
|
33
|
+
Status-based HTTP errors are exposed as typed classes:
|
|
34
|
+
|
|
35
|
+
- `FlyBadRequestError` (400)
|
|
36
|
+
- `FlyUnauthorizedError` (401)
|
|
37
|
+
- `FlyNotFoundError` (404)
|
|
38
|
+
- `FlyPreconditionFailedError` (412)
|
|
39
|
+
- `FlyUnprocessableEntityError` (422)
|
|
40
|
+
- `FlyInternalServerError` (500)
|
|
41
|
+
- `FlyApiError` (fallback)
|
|
42
|
+
- `FlyGraphQLError`
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import { Client, FlyNotFoundError } from '@fly.io/sdk'
|
|
46
|
+
|
|
47
|
+
const client = new Client(process.env.FLY_API_TOKEN || '')
|
|
48
|
+
const machine = await client.Machine.getMachine({
|
|
49
|
+
app_name: 'my-app',
|
|
50
|
+
machine_id: '123',
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
if (machine instanceof FlyNotFoundError) {
|
|
54
|
+
console.error('Machine not found')
|
|
55
|
+
}
|
|
56
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fly.io/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "TypeScript client for the Fly Machines REST and GraphQL APIs. Vendored fork of supabase/fly-admin with native fetch, exec, releaseLease, and metadata support.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -30,9 +30,13 @@
|
|
|
30
30
|
},
|
|
31
31
|
"repository": {
|
|
32
32
|
"type": "git",
|
|
33
|
-
"url": "https://github.com/remorses/
|
|
33
|
+
"url": "https://github.com/remorses/kimaki",
|
|
34
34
|
"directory": "fly-admin"
|
|
35
35
|
},
|
|
36
|
+
"homepage": "https://github.com/remorses/kimaki/tree/main/fly-admin",
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://github.com/remorses/kimaki/issues"
|
|
39
|
+
},
|
|
36
40
|
"keywords": [
|
|
37
41
|
"fly",
|
|
38
42
|
"fly.io",
|