@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.
- package/dist/api/FaableApi.js +22 -15
- package/package.json +2 -2
package/dist/api/FaableApi.js
CHANGED
|
@@ -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-
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
248
|
+
headers: projectHeader(team)
|
|
242
249
|
}));
|
|
243
250
|
}
|
|
244
251
|
// ── per-app WAF ───────────────────────────────────────────────────────────
|
|
245
252
|
//
|
|
246
|
-
// No `x-faable-
|
|
247
|
-
// app in the path (the server reads the
|
|
248
|
-
// a
|
|
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.
|
|
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.
|
|
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",
|