@supacloud/cli 0.120.0 → 0.120.1
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/index.js +40 -14
- package/dist/shared/transports/http.d.ts +2 -0
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -9537,6 +9537,7 @@ var RELEASE_MUTATION_RESPONSE_TIMEOUT = 5000;
|
|
|
9537
9537
|
var RELEASE_MUTATION_RESPONSE_MAX_BYTES = 64 * 1024;
|
|
9538
9538
|
var MAX_RETRIES = 2;
|
|
9539
9539
|
var RETRY_BASE_DELAY = 500;
|
|
9540
|
+
var MAX_RETRY_AFTER_MS = 5 * 60000;
|
|
9540
9541
|
function validatedGetResponseLimit(options) {
|
|
9541
9542
|
const maxBytes = options.maxResponseBytes;
|
|
9542
9543
|
if (maxBytes === undefined)
|
|
@@ -9579,6 +9580,21 @@ function isRetryableError(error) {
|
|
|
9579
9580
|
const networkError = error;
|
|
9580
9581
|
return networkError.name === "AbortError" || networkError.code === "ECONNREFUSED" || networkError.code === "ECONNRESET";
|
|
9581
9582
|
}
|
|
9583
|
+
function retryAfterDelayMs(value) {
|
|
9584
|
+
const normalized = value?.trim() ?? "";
|
|
9585
|
+
if (/^\d+$/.test(normalized)) {
|
|
9586
|
+
const seconds = Number(normalized);
|
|
9587
|
+
if (Number.isSafeInteger(seconds))
|
|
9588
|
+
return Math.min(MAX_RETRY_AFTER_MS, seconds * 1000);
|
|
9589
|
+
}
|
|
9590
|
+
const retryAt = Date.parse(normalized);
|
|
9591
|
+
if (!Number.isNaN(retryAt))
|
|
9592
|
+
return Math.min(MAX_RETRY_AFTER_MS, Math.max(0, retryAt - Date.now()));
|
|
9593
|
+
return RETRY_BASE_DELAY;
|
|
9594
|
+
}
|
|
9595
|
+
function waitForRetry(delayMs) {
|
|
9596
|
+
return new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
9597
|
+
}
|
|
9582
9598
|
function transportFailure(error) {
|
|
9583
9599
|
const networkError = error instanceof Error ? error : null;
|
|
9584
9600
|
const code = networkError?.name === "AbortError" ? "TIMEOUT" : networkError?.code === "ECONNRESET" ? "CONNECTION_RESET" : "NETWORK_ERROR";
|
|
@@ -9611,21 +9627,31 @@ async function fetchWithTimeout(url, options, timeoutMs = DEFAULT_TIMEOUT, insec
|
|
|
9611
9627
|
clearTimeout(timeout);
|
|
9612
9628
|
}
|
|
9613
9629
|
}
|
|
9614
|
-
async function fetchWithRetry(url, options, timeoutMs = DEFAULT_TIMEOUT, insecureTls = false) {
|
|
9615
|
-
const
|
|
9630
|
+
async function fetchWithRetry(url, options, timeoutMs = DEFAULT_TIMEOUT, insecureTls = false, retryOptions = {}) {
|
|
9631
|
+
const retryOnRateLimit = retryOptions.retryOnRateLimit === true;
|
|
9632
|
+
const retryableMethod = isRetryableMethod(options.method);
|
|
9633
|
+
const retries = retryableMethod || retryOnRateLimit ? MAX_RETRIES : 0;
|
|
9616
9634
|
for (let attempt = 0;attempt <= retries; attempt++) {
|
|
9617
9635
|
try {
|
|
9618
9636
|
const res = await fetchWithTimeout(url, options, timeoutMs, insecureTls);
|
|
9619
|
-
if (res.status
|
|
9637
|
+
if (res.status === 429 && retryOnRateLimit && attempt < retries) {
|
|
9638
|
+
const delay = retryAfterDelayMs(res.headers.get("retry-after"));
|
|
9639
|
+
res.body?.cancel().catch(() => {
|
|
9640
|
+
return;
|
|
9641
|
+
});
|
|
9642
|
+
await waitForRetry(delay);
|
|
9643
|
+
continue;
|
|
9644
|
+
}
|
|
9645
|
+
if (retryableMethod && res.status >= 500 && res.status < 600 && attempt < retries) {
|
|
9620
9646
|
const delay = RETRY_BASE_DELAY * Math.pow(2, attempt);
|
|
9621
|
-
await
|
|
9647
|
+
await waitForRetry(delay);
|
|
9622
9648
|
continue;
|
|
9623
9649
|
}
|
|
9624
9650
|
return res;
|
|
9625
9651
|
} catch (error) {
|
|
9626
|
-
if (attempt < retries && isRetryableError(error)) {
|
|
9652
|
+
if (retryableMethod && attempt < retries && isRetryableError(error)) {
|
|
9627
9653
|
const delay = RETRY_BASE_DELAY * Math.pow(2, attempt);
|
|
9628
|
-
await
|
|
9654
|
+
await waitForRetry(delay);
|
|
9629
9655
|
continue;
|
|
9630
9656
|
}
|
|
9631
9657
|
throw error;
|
|
@@ -9776,14 +9802,14 @@ class HttpTransport {
|
|
|
9776
9802
|
...this.apiKey ? { apikey: this.apiKey } : {}
|
|
9777
9803
|
};
|
|
9778
9804
|
}
|
|
9779
|
-
async mutationWithResponseReader(method, path, serializedBody, responseReader, timeoutMs = DEFAULT_TIMEOUT) {
|
|
9805
|
+
async mutationWithResponseReader(method, path, serializedBody, responseReader, timeoutMs = DEFAULT_TIMEOUT, retryOnRateLimit = false) {
|
|
9780
9806
|
try {
|
|
9781
9807
|
const request = {
|
|
9782
9808
|
method,
|
|
9783
9809
|
headers: this.headers(),
|
|
9784
9810
|
...serializedBody === undefined ? {} : { body: serializedBody }
|
|
9785
9811
|
};
|
|
9786
|
-
const response = await fetchWithRetry(`${this.baseUrl}${path}`, request, timeoutMs, this.insecureTls);
|
|
9812
|
+
const response = await fetchWithRetry(`${this.baseUrl}${path}`, request, timeoutMs, this.insecureTls, { retryOnRateLimit });
|
|
9787
9813
|
const responseBody = await responseReader(response);
|
|
9788
9814
|
return responseBody.ok ? { ok: response.ok, status: response.status, data: responseBody.parsedJson } : responseReadFailure(response.status);
|
|
9789
9815
|
} catch (error) {
|
|
@@ -9850,7 +9876,7 @@ class HttpTransport {
|
|
|
9850
9876
|
}
|
|
9851
9877
|
async postReleaseMutation(path, body, options) {
|
|
9852
9878
|
const timeoutMs = validatedPostTimeout(options);
|
|
9853
|
-
return this.mutationWithResponseReader("POST", path, serializedRequestBody(body), releaseMutationResponseJson, timeoutMs);
|
|
9879
|
+
return this.mutationWithResponseReader("POST", path, serializedRequestBody(body), releaseMutationResponseJson, timeoutMs, options?.retryOnRateLimit === true);
|
|
9854
9880
|
}
|
|
9855
9881
|
async postBinary(path, body, options) {
|
|
9856
9882
|
if (options.contentType !== FRONTEND_ARCHIVE_CONTENT_TYPE) {
|
|
@@ -13437,7 +13463,7 @@ ${riskReport}`
|
|
|
13437
13463
|
skipped.push(file);
|
|
13438
13464
|
continue;
|
|
13439
13465
|
}
|
|
13440
|
-
const r = await managementHttp().postReleaseMutation(`/v1/projects/${ref}/database/migrations`, { name, sql, version });
|
|
13466
|
+
const r = await managementHttp().postReleaseMutation(`/v1/projects/${ref}/database/migrations`, { name, sql, version }, { retryOnRateLimit: true });
|
|
13441
13467
|
if (r.ok && r.status === 200 && confirmedMigrationReceipt(r.data, { name, version, sql })) {
|
|
13442
13468
|
applied.push(file);
|
|
13443
13469
|
} else if (isAlreadyAppliedMigrationResponse(r, { name, version, sql })) {
|
|
@@ -22245,7 +22271,7 @@ var starter_metadata_default = {
|
|
|
22245
22271
|
version: "0.16.1"
|
|
22246
22272
|
},
|
|
22247
22273
|
db: {
|
|
22248
|
-
version: "0.24.
|
|
22274
|
+
version: "0.24.1",
|
|
22249
22275
|
dependencies: {
|
|
22250
22276
|
"@zenstackhq/orm": "3.10.0",
|
|
22251
22277
|
"@zenstackhq/schema": "3.10.0",
|
|
@@ -34343,7 +34369,7 @@ async function runProjectDeployment(http, args) {
|
|
|
34343
34369
|
// package.json
|
|
34344
34370
|
var package_default = {
|
|
34345
34371
|
name: "@supacloud/cli",
|
|
34346
|
-
version: "0.120.
|
|
34372
|
+
version: "0.120.1",
|
|
34347
34373
|
description: "Project-scoped CLI for SupaCloud users",
|
|
34348
34374
|
type: "module",
|
|
34349
34375
|
main: "./dist/index.js",
|
|
@@ -34397,7 +34423,7 @@ var package_default = {
|
|
|
34397
34423
|
dependencies: {
|
|
34398
34424
|
"@supacloud/compiler": "^0.62.0",
|
|
34399
34425
|
"@supacloud/delivery": "0.26.0",
|
|
34400
|
-
"@supacloud/db": "0.24.
|
|
34426
|
+
"@supacloud/db": "0.24.1",
|
|
34401
34427
|
typebox: "1.4.3"
|
|
34402
34428
|
},
|
|
34403
34429
|
overrides: {
|
|
@@ -34405,7 +34431,7 @@ var package_default = {
|
|
|
34405
34431
|
"@supacloud/delivery": "0.26.0",
|
|
34406
34432
|
"@graphql-tools/utils": "^12.0.4",
|
|
34407
34433
|
"@supacloud/compiler": "^0.62.0",
|
|
34408
|
-
"@supacloud/db": "0.24.
|
|
34434
|
+
"@supacloud/db": "0.24.1",
|
|
34409
34435
|
"deepmerge-ts": "8.0.2",
|
|
34410
34436
|
prisma: "6.19.3"
|
|
34411
34437
|
},
|
|
@@ -33,6 +33,8 @@ export interface HttpPostOptions {
|
|
|
33
33
|
}
|
|
34
34
|
export interface HttpReleaseMutationOptions {
|
|
35
35
|
timeoutMs?: number;
|
|
36
|
+
/** Retry rate-limited requests only when the mutation is idempotent by contract. */
|
|
37
|
+
retryOnRateLimit?: boolean;
|
|
36
38
|
}
|
|
37
39
|
export interface HttpBinaryPostOptions {
|
|
38
40
|
contentType: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supacloud/cli",
|
|
3
|
-
"version": "0.120.
|
|
3
|
+
"version": "0.120.1",
|
|
4
4
|
"description": "Project-scoped CLI for SupaCloud users",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@supacloud/compiler": "^0.62.0",
|
|
56
56
|
"@supacloud/delivery": "0.26.0",
|
|
57
|
-
"@supacloud/db": "0.24.
|
|
57
|
+
"@supacloud/db": "0.24.1",
|
|
58
58
|
"typebox": "1.4.3"
|
|
59
59
|
},
|
|
60
60
|
"overrides": {
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"@supacloud/delivery": "0.26.0",
|
|
63
63
|
"@graphql-tools/utils": "^12.0.4",
|
|
64
64
|
"@supacloud/compiler": "^0.62.0",
|
|
65
|
-
"@supacloud/db": "0.24.
|
|
65
|
+
"@supacloud/db": "0.24.1",
|
|
66
66
|
"deepmerge-ts": "8.0.2",
|
|
67
67
|
"prisma": "6.19.3"
|
|
68
68
|
},
|