@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@distilled.cloud/fly-io",
3
- "version": "1.0.0-rc.7",
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.7"
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.111 || >=4.0.0"
97
+ "@effect/platform-bun": ">=4.0.0-rc.112 || >=4.0.0"
98
98
  },
99
99
  "peerDependencies": {
100
- "effect": ">=4.0.0-rc.111 || >=4.0.0"
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 --recursive --depth=1 specs/distilled-spec-fly-io && git -C specs/distilled-spec-fly-io checkout -- .",
108
- "specs:update": "git -C specs/distilled-spec-fly-io fetch && git -C specs/distilled-spec-fly-io checkout main && git -C specs/distilled-spec-fly-io pull"
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
  }
@@ -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 root (default `https://api.machines.dev/v1`).
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
- export const DEFAULT_API_BASE_URL = "https://api.machines.dev/v1";
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 root.
37
+ * Normalize a Fly API hostname into the Machines API base URL.
33
38
  *
34
- * - unset / empty → `https://api.machines.dev/v1`
35
- * - already ends with `/v1` → used as-is (trailing slashes stripped)
36
- * - otherwise `/v1` is appended
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 : `${trimmed}/v1`;
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/v1`. MPG (`FlyApiProtocol`) is the same token against
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}`,