@akanjs/devkit 3.0.0-beta.11 → 3.0.0-beta.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.
Files changed (2) hide show
  1. package/cloud/cloudApi.ts +19 -5
  2. package/package.json +2 -2
package/cloud/cloudApi.ts CHANGED
@@ -17,7 +17,7 @@ class HttpClient {
17
17
  ...headers,
18
18
  },
19
19
  });
20
- return await response.json();
20
+ return await HttpClient.#body<T>(response, url);
21
21
  }
22
22
  async getFile(url: string, localPath: string, headers?: Record<string, string>): Promise<void> {
23
23
  const response = await fetch(`${this.baseUrl}${url}`, {
@@ -35,7 +35,16 @@ class HttpClient {
35
35
  ? { ...this.headers, ...headers }
36
36
  : { "Content-Type": "application/json", ...this.headers, ...headers },
37
37
  });
38
- return await response.json();
38
+ return await HttpClient.#body<T>(response, url);
39
+ }
40
+ /**
41
+ * A route that does not exist answers the error *page*, not JSON, so parsing first reports a syntax error at
42
+ * `<` and buries the status that says what is actually wrong. Read the status before the body.
43
+ */
44
+ static async #body<T>(response: Response, url: string): Promise<T> {
45
+ const text = await response.text();
46
+ if (!response.ok) throw new Error(`${response.status} ${response.statusText} from ${url}: ${text.slice(0, 200)}`);
47
+ return JSON.parse(text) as T;
39
48
  }
40
49
  setHeaders(headers: Record<string, string>) {
41
50
  Object.assign(this.headers, headers);
@@ -132,16 +141,21 @@ export class CloudApi {
132
141
  this.#api.setHeaders({ Authorization: `Bearer ${this.#accessToken.jwt}` });
133
142
  return this.#accessToken;
134
143
  }
144
+ /**
145
+ * The `/tunnel` segment is the model's refName, which every database module's endpoints carry and the service
146
+ * modules above — `_cloud`, which owns `uploadEnv` and `getRemoteSelf` — do not. Dropping it to match those
147
+ * neighbours answers 404, and the control plane returns an HTML error page that fails as a JSON parse error.
148
+ */
135
149
  async requestTunnel(input: { name: string; ttlMinutes?: number }): Promise<TunnelGrant> {
136
- return await this.#api.post<TunnelGrant>(`/requestTunnel`, input);
150
+ return await this.#api.post<TunnelGrant>(`/tunnel/requestTunnel`, input);
137
151
  }
138
152
  /** The generated name of the model's own `inSelf` slice: a hand-written `listTunnels` would collide with it. */
139
153
  async tunnelListInSelf(): Promise<TunnelSummary[]> {
140
- return await this.#api.get<TunnelSummary[]>(`/tunnelListInSelf`);
154
+ return await this.#api.get<TunnelSummary[]>(`/tunnel/tunnelListInSelf`);
141
155
  }
142
156
  /** Hands the grant back. The CLI calls this "stop", which is what the operator is doing, not what it does. */
143
157
  async revokeTunnel(code: string): Promise<boolean> {
144
- return await this.#api.post<boolean>(`/revokeTunnel`, { code });
158
+ return await this.#api.post<boolean>(`/tunnel/revokeTunnel`, { code });
145
159
  }
146
160
  async getRemoteSelf(): Promise<{ id: string; nickname: string } | null> {
147
161
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/devkit",
3
- "version": "3.0.0-beta.11",
3
+ "version": "3.0.0-beta.13",
4
4
  "sourceType": "module",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -44,7 +44,7 @@
44
44
  "@langchain/openai": "^1.4.6",
45
45
  "@tailwindcss/node": "^4.3.0",
46
46
  "@trapezedev/project": "^7.1.4",
47
- "akanjs": "3.0.0-beta.11",
47
+ "akanjs": "3.0.0-beta.13",
48
48
  "chalk": "^5.6.2",
49
49
  "commander": "^14.0.3",
50
50
  "dayjs": "^1.11.20",