@faable/faable 3.3.0 → 3.3.2

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.
@@ -8,6 +8,13 @@ const RETRY_DELAY_MS = 300;
8
8
  const is_connection_reset = (e) => e.isAxiosError &&
9
9
  !e.response &&
10
10
  (RESET_CODES.has(e.code ?? '') || e.message.includes('socket hang up'));
11
+ // The api's tenant header is `x-faable-project: project_<hex>`; the old
12
+ // `x-faable-team` is deprecated. A project and a team share the hex suffix,
13
+ // so the app's `team` (`team_<hex>`) maps 1:1. Never send both: the api
14
+ // rejects a pair that disagrees.
15
+ const projectHeader = (team) => ({
16
+ 'x-faable-project': team.replace(/^team_/, 'project_')
17
+ });
11
18
  const firstPage = async (res) => {
12
19
  const items = (await res).results;
13
20
  return items;
@@ -165,9 +172,9 @@ class FaableApi {
165
172
  // app; the per-secret upsert/delete endpoints are not used by the CLI.
166
173
  // The endpoint stamps the created secrets with the team from the request
167
174
  // context, which a CLI user token does not carry — pass the app's team
168
- // (from getApp) so it travels as the `x-faable-team` header.
175
+ // (from getApp) so it travels as the `x-faable-project` header.
169
176
  async createSecretsBatch(context_id, team, secrets) {
170
- return data(this.client.post(`/secret/createbatch`, { context_id, secrets }, { headers: { 'x-faable-team': team } }));
177
+ return data(this.client.post(`/secret/createbatch`, { context_id, secrets }, { headers: projectHeader(team) }));
171
178
  }
172
179
  async updateApp(app_id, params) {
173
180
  return data(this.client.post(`/app/${app_id}`, params));
@@ -196,7 +203,7 @@ class FaableApi {
196
203
  async listDeployments(app_id, team) {
197
204
  return firstPage(data(this.client.get(`/deployment`, {
198
205
  params: { app_id },
199
- headers: { 'x-faable-team': team }
206
+ headers: projectHeader(team)
200
207
  })));
201
208
  }
202
209
  // Build and deploy the current head of the deploy branch server-side —
@@ -208,44 +215,44 @@ class FaableApi {
208
215
  // git ref). The API enforces the guards: failed phase only, never older
209
216
  // than what production serves.
210
217
  async redeployDeployment(deployment_id, team) {
211
- return data(this.client.post(`/deployment/${deployment_id}/redeploy`, undefined, { headers: { 'x-faable-team': team } }));
218
+ return data(this.client.post(`/deployment/${deployment_id}/redeploy`, undefined, { headers: projectHeader(team) }));
212
219
  }
213
220
  // Give up on a build still in the pre-handoff window (QUEUED/BUILDING).
214
221
  // A route of its own rather than a `{phase: 'CANCELED'}` status write:
215
222
  // phase transitions belong to the controller, and the api only lets a user
216
223
  // token touch the phases the CLI owns.
217
224
  async cancelDeployment(deployment_id, team) {
218
- return data(this.client.post(`/deployment/${deployment_id}/cancel`, undefined, { headers: { 'x-faable-team': team } }));
225
+ return data(this.client.post(`/deployment/${deployment_id}/cancel`, undefined, { headers: projectHeader(team) }));
219
226
  }
220
227
  // Domains are team-scoped rows; a CLI user token carries no default team,
221
- // so every call pins the app's team via `x-faable-team` (same pattern as
222
- // createSecretsBatch).
228
+ // so every call pins the app's project via `x-faable-project` (same pattern
229
+ // as createSecretsBatch).
223
230
  async listDomains(app_id, team) {
224
231
  return firstPage(data(this.client.get(`/domain`, {
225
232
  params: { app_id },
226
- headers: { 'x-faable-team': team }
233
+ headers: projectHeader(team)
227
234
  })));
228
235
  }
229
236
  async createDomain(team, params) {
230
237
  return data(this.client.post(`/domain`, params, {
231
- headers: { 'x-faable-team': team }
238
+ headers: projectHeader(team)
232
239
  }));
233
240
  }
234
241
  async getDomain(domain_id, team) {
235
242
  return data(this.client.get(`/domain/${domain_id}`, {
236
- headers: { 'x-faable-team': team }
243
+ headers: projectHeader(team)
237
244
  }));
238
245
  }
239
246
  async deleteDomain(domain_id, team) {
240
247
  return data(this.client.delete(`/domain/${domain_id}`, {
241
- headers: { 'x-faable-team': team }
248
+ headers: projectHeader(team)
242
249
  }));
243
250
  }
244
251
  // ── per-app WAF ───────────────────────────────────────────────────────────
245
252
  //
246
- // No `x-faable-team` header on any of these: the routes are scoped by the
247
- // app in the path (the server reads the team off the App row), and sending
248
- // a team override would only narrow the lookup.
253
+ // No `x-faable-project` header on any of these: the routes are scoped by the
254
+ // app in the path (the server reads the project off the App row), and sending
255
+ // a project override would only narrow the lookup.
249
256
  async getAppWaf(app_id) {
250
257
  return data(this.client.get(`/app/${app_id}/waf`));
251
258
  }
@@ -259,4 +266,4 @@ class FaableApi {
259
266
  }
260
267
  }
261
268
 
262
- export { FaableApi };
269
+ export { FaableApi, projectHeader };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faable/faable",
3
- "version": "3.3.0",
3
+ "version": "3.3.2",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "author": "Marc Pomar <marc@faable.com>",
@@ -27,7 +27,7 @@
27
27
  ],
28
28
  "dependencies": {
29
29
  "@actions/core": "^3.0.0",
30
- "@faable/auth-sdk": "^2.6.0",
30
+ "@faable/auth-sdk": "^2.6.3",
31
31
  "axios": "^1.18.1",
32
32
  "fs-extra": "^11.3.2",
33
33
  "open": "^11.0.0",