@supacloud/admin 0.7.0 → 0.7.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 +36 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -25159,29 +25159,46 @@ function resolveSupaCloudContext(env = process.env, cwd = process.cwd()) {
|
|
|
25159
25159
|
var DEFAULT_TIMEOUT = 30000;
|
|
25160
25160
|
var MAX_RETRIES = 2;
|
|
25161
25161
|
var RETRY_BASE_DELAY = 500;
|
|
25162
|
-
|
|
25162
|
+
function isRetryableMethod(method) {
|
|
25163
|
+
const normalizedMethod = (method ?? "GET").toUpperCase();
|
|
25164
|
+
return normalizedMethod === "GET" || normalizedMethod === "HEAD";
|
|
25165
|
+
}
|
|
25166
|
+
function isRetryableError(error) {
|
|
25167
|
+
if (!(error instanceof Error))
|
|
25168
|
+
return false;
|
|
25169
|
+
const networkError = error;
|
|
25170
|
+
return networkError.name === "AbortError" || networkError.code === "ECONNREFUSED" || networkError.code === "ECONNRESET";
|
|
25171
|
+
}
|
|
25172
|
+
async function fetchWithTimeout(url, options) {
|
|
25173
|
+
const controller = new AbortController;
|
|
25174
|
+
const timeout = setTimeout(() => controller.abort(), DEFAULT_TIMEOUT);
|
|
25175
|
+
try {
|
|
25176
|
+
return await fetch(url, {
|
|
25177
|
+
...options,
|
|
25178
|
+
signal: controller.signal
|
|
25179
|
+
});
|
|
25180
|
+
} finally {
|
|
25181
|
+
clearTimeout(timeout);
|
|
25182
|
+
}
|
|
25183
|
+
}
|
|
25184
|
+
async function fetchWithRetry(url, options) {
|
|
25185
|
+
const retries = isRetryableMethod(options.method) ? MAX_RETRIES : 0;
|
|
25163
25186
|
for (let attempt = 0;attempt <= retries; attempt++) {
|
|
25164
25187
|
try {
|
|
25165
|
-
const
|
|
25166
|
-
|
|
25167
|
-
const res = await fetch(url, {
|
|
25168
|
-
...options,
|
|
25169
|
-
signal: controller.signal
|
|
25170
|
-
});
|
|
25171
|
-
clearTimeout(timeout);
|
|
25172
|
-
if (res.status >= 500 && attempt < retries) {
|
|
25188
|
+
const res = await fetchWithTimeout(url, options);
|
|
25189
|
+
if (res.status >= 500 && res.status < 600 && attempt < retries) {
|
|
25173
25190
|
const delay = RETRY_BASE_DELAY * Math.pow(2, attempt);
|
|
25174
25191
|
await new Promise((r) => setTimeout(r, delay));
|
|
25175
25192
|
continue;
|
|
25176
25193
|
}
|
|
25177
25194
|
return res;
|
|
25178
|
-
} catch (
|
|
25179
|
-
if (attempt < retries && (
|
|
25195
|
+
} catch (error) {
|
|
25196
|
+
if (attempt < retries && isRetryableError(error)) {
|
|
25180
25197
|
const delay = RETRY_BASE_DELAY * Math.pow(2, attempt);
|
|
25181
25198
|
await new Promise((r) => setTimeout(r, delay));
|
|
25182
25199
|
continue;
|
|
25183
25200
|
}
|
|
25184
|
-
throw
|
|
25201
|
+
throw error;
|
|
25185
25202
|
}
|
|
25186
25203
|
}
|
|
25187
25204
|
throw new Error("Unreachable");
|
|
@@ -25578,6 +25595,7 @@ class SshTransport {
|
|
|
25578
25595
|
import { randomUUID } from "node:crypto";
|
|
25579
25596
|
var SAFE_CONTAINER_NAME = /^[a-zA-Z0-9][a-zA-Z0-9_.-]{0,127}$/;
|
|
25580
25597
|
var SAFE_PROJECT_REF = /^[a-z0-9-]{1,20}$/;
|
|
25598
|
+
var SAFE_SCHEMA_IDENTIFIER = /^[a-zA-Z_][a-zA-Z0-9_]{0,62}$/;
|
|
25581
25599
|
var SAFE_RELEASE_TAG = /^[a-zA-Z0-9._-]{1,80}$/;
|
|
25582
25600
|
var SAFE_TIMEOUT_SECONDS = 300;
|
|
25583
25601
|
var SAFE_HOSTNAME = /^(?=.{1,253}$)(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)(?:\.(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?))*$/;
|
|
@@ -26071,12 +26089,15 @@ ${output}`;
|
|
|
26071
26089
|
if (sourceRef === targetRef)
|
|
26072
26090
|
throw new Error("source_ref and target_ref must be different");
|
|
26073
26091
|
const s = args.schemas || "public,auth,storage";
|
|
26074
|
-
if (!/^[a-z_,\s]+$/.test(s))
|
|
26075
|
-
throw new Error("Invalid schemas");
|
|
26076
26092
|
const schemas = s.split(",").map((x) => x.trim()).filter(Boolean);
|
|
26077
26093
|
if (schemas.length === 0)
|
|
26078
26094
|
throw new Error("At least one schema is required");
|
|
26079
|
-
const
|
|
26095
|
+
for (const schema of schemas) {
|
|
26096
|
+
if (!SAFE_SCHEMA_IDENTIFIER.test(schema)) {
|
|
26097
|
+
throw new Error(`Invalid schema identifier: ${JSON.stringify(schema)}`);
|
|
26098
|
+
}
|
|
26099
|
+
}
|
|
26100
|
+
const schemaArgs = schemas.map((schema) => `-n '${schema}'`).join(" ");
|
|
26080
26101
|
const df = args.data_only ? "--data-only" : "";
|
|
26081
26102
|
const cmd = [
|
|
26082
26103
|
"set -euo pipefail",
|