@distilled.cloud/fly-io 1.0.0-rc.7 → 1.0.0-rc.9
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/LICENSE +201 -0
- package/lib/credentials.d.ts +11 -5
- package/lib/credentials.d.ts.map +1 -1
- package/lib/credentials.js +13 -7
- package/lib/credentials.js.map +1 -1
- package/lib/protocol.d.ts +1 -1
- package/lib/protocol.js +2 -2
- package/lib/protocol.js.map +1 -1
- package/lib/services/machines.d.ts +642 -92
- package/lib/services/machines.d.ts.map +1 -1
- package/lib/services/machines.js +810 -171
- package/lib/services/machines.js.map +1 -1
- package/package.json +6 -6
- package/src/credentials.ts +13 -7
- package/src/protocol.ts +2 -2
- package/src/services/machines.ts +1810 -283
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@distilled.cloud/fly-io",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.9",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/alchemy-run/distilled",
|
|
@@ -89,22 +89,22 @@
|
|
|
89
89
|
}
|
|
90
90
|
},
|
|
91
91
|
"dependencies": {
|
|
92
|
-
"@distilled.cloud/core": "1.0.0-rc.
|
|
92
|
+
"@distilled.cloud/core": "1.0.0-rc.9"
|
|
93
93
|
},
|
|
94
94
|
"devDependencies": {
|
|
95
95
|
"@types/bun": "latest",
|
|
96
96
|
"@types/node": "latest",
|
|
97
|
-
"@effect/platform-bun": ">=4.0.0-rc.
|
|
97
|
+
"@effect/platform-bun": ">=4.0.0-rc.112 || >=4.0.0"
|
|
98
98
|
},
|
|
99
99
|
"peerDependencies": {
|
|
100
|
-
"effect": ">=4.0.0-rc.
|
|
100
|
+
"effect": ">=4.0.0-rc.112 || >=4.0.0"
|
|
101
101
|
},
|
|
102
102
|
"scripts": {
|
|
103
103
|
"convert": "bun scripts/convert.ts",
|
|
104
104
|
"generate": "bun scripts/generate.ts",
|
|
105
105
|
"typecheck": "tsc -p tsconfig.json",
|
|
106
106
|
"build": "tsc -b",
|
|
107
|
-
"specs:fetch": "git submodule update --force --init --
|
|
108
|
-
"specs:update": "git
|
|
107
|
+
"specs:fetch": "git submodule update --force --init --depth=1 specs/spec-mirror-fly-io",
|
|
108
|
+
"specs:update": "git submodule update --remote --force --depth=1 specs/spec-mirror-fly-io"
|
|
109
109
|
}
|
|
110
110
|
}
|
package/src/credentials.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Alchemy and `flyctl` read `FLY_API_TOKEN`. `FLY_IO_API_KEY` is kept as a
|
|
9
9
|
* fallback for older distilled consumers. Optional `FLY_API_HOSTNAME`
|
|
10
|
-
* overrides the Machines API
|
|
10
|
+
* overrides the Machines API host (default `https://api.machines.dev`).
|
|
11
11
|
*
|
|
12
12
|
* Managed REST (MPG), GraphQL add-ons (Tigris, Redis), and Sprites all
|
|
13
13
|
* reuse this token. Sprites never reads a separate env var: the protocol
|
|
@@ -20,7 +20,12 @@ import * as Effect from "effect/Effect";
|
|
|
20
20
|
import * as Layer from "effect/Layer";
|
|
21
21
|
import * as Redacted from "effect/Redacted";
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Machines API host. The generated Machines routes carry the `/v1` prefix
|
|
25
|
+
* (`/v1/apps/{app_name}/machines`), as the upstream OpenAPI spells them, so
|
|
26
|
+
* the base URL must not.
|
|
27
|
+
*/
|
|
28
|
+
export const DEFAULT_API_BASE_URL = "https://api.machines.dev";
|
|
24
29
|
|
|
25
30
|
/** UI-EX REST + GraphQL host (MPG, Tigris, Redis). Not overridable via an invented env var. */
|
|
26
31
|
export const DEFAULT_FLY_API_BASE_URL = "https://api.fly.io";
|
|
@@ -29,17 +34,18 @@ export const DEFAULT_FLY_API_BASE_URL = "https://api.fly.io";
|
|
|
29
34
|
export const DEFAULT_SPRITES_API_BASE_URL = "https://api.sprites.dev/v1";
|
|
30
35
|
|
|
31
36
|
/**
|
|
32
|
-
* Normalize a Fly API hostname into the Machines API
|
|
37
|
+
* Normalize a Fly API hostname into the Machines API base URL.
|
|
33
38
|
*
|
|
34
|
-
* - unset / empty → `https://api.machines.dev
|
|
35
|
-
* -
|
|
36
|
-
* -
|
|
39
|
+
* - unset / empty → `https://api.machines.dev`
|
|
40
|
+
* - trailing slashes stripped
|
|
41
|
+
* - a trailing `/v1` is dropped: `flyctl` and older consumers set
|
|
42
|
+
* `FLY_API_HOSTNAME` to the `/v1` root, and the routes already carry it
|
|
37
43
|
*/
|
|
38
44
|
export const normalizeApiBaseUrl = (hostname?: string): string => {
|
|
39
45
|
if (hostname === undefined) return DEFAULT_API_BASE_URL;
|
|
40
46
|
const trimmed = hostname.trim().replace(/\/+$/, "");
|
|
41
47
|
if (trimmed.length === 0) return DEFAULT_API_BASE_URL;
|
|
42
|
-
return trimmed.endsWith("/v1") ? trimmed :
|
|
48
|
+
return trimmed.endsWith("/v1") ? trimmed.slice(0, -3) : trimmed;
|
|
43
49
|
};
|
|
44
50
|
|
|
45
51
|
export interface Config {
|
package/src/protocol.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Sprites REST.
|
|
4
4
|
*
|
|
5
5
|
* Machines (`FlyIoProtocol`) is a plain bearer-token JSON API at
|
|
6
|
-
* `api.machines.dev
|
|
6
|
+
* `api.machines.dev` (routes carry the `/v1` prefix). MPG (`FlyApiProtocol`) is the same token against
|
|
7
7
|
* `https://api.fly.io`. GraphQL add-ons (`FlyGraphqlProtocol`) POST
|
|
8
8
|
* `{ query, operationName, variables }` to `https://api.fly.io/graphql`.
|
|
9
9
|
*
|
|
@@ -355,7 +355,7 @@ const discoverOrgSlug = (fly: Config) =>
|
|
|
355
355
|
const token = Redacted.value(fly.apiKey);
|
|
356
356
|
const machinesRoot = fly.apiBaseUrl.replace(/\/+$/, "");
|
|
357
357
|
const currentReq = HttpClientRequest.make("GET")(
|
|
358
|
-
`${machinesRoot}/tokens/current`,
|
|
358
|
+
`${machinesRoot}/v1/tokens/current`,
|
|
359
359
|
).pipe(
|
|
360
360
|
HttpClientRequest.setHeaders({
|
|
361
361
|
Authorization: `Bearer ${token}`,
|