@supacloud/cli 0.14.2 → 0.14.3
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 +38 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7551,6 +7551,20 @@ function parseSecrets(value) {
|
|
|
7551
7551
|
}).filter((entry) => entry.name);
|
|
7552
7552
|
}
|
|
7553
7553
|
var secretsSchema = Type.Optional(decodedSchema(Type.Union([Type.String(), secretListSchema]), secretListSchema, parseSecrets));
|
|
7554
|
+
function confirmedFunctionConfig(payload, expected) {
|
|
7555
|
+
if (!payload || typeof payload !== "object" || Array.isArray(payload))
|
|
7556
|
+
return false;
|
|
7557
|
+
const response = payload;
|
|
7558
|
+
if (expected.verify_jwt !== undefined && response.verify_jwt !== expected.verify_jwt)
|
|
7559
|
+
return false;
|
|
7560
|
+
if (expected.background_routes !== undefined) {
|
|
7561
|
+
if (!Array.isArray(response.background_routes))
|
|
7562
|
+
return false;
|
|
7563
|
+
if (JSON.stringify(response.background_routes) !== JSON.stringify(expected.background_routes))
|
|
7564
|
+
return false;
|
|
7565
|
+
}
|
|
7566
|
+
return true;
|
|
7567
|
+
}
|
|
7554
7568
|
function registerAdvancedTools(server, http) {
|
|
7555
7569
|
server.tool("edge_functions", `Edge Function management (Deno/Bun serverless). Server auto-bundles dependencies.
|
|
7556
7570
|
Actions: list, deploy, deploy_bundle, config, source, delete, check`, {
|
|
@@ -7585,6 +7599,17 @@ Actions: list, deploy, deploy_bundle, config, source, delete, check`, {
|
|
|
7585
7599
|
const cr = await http.patch(`/v1/projects/${ref}/functions/${slug}/config`, functionConfig());
|
|
7586
7600
|
return cr.ok ? `✅ Function ${slug} config updated
|
|
7587
7601
|
${JSON.stringify(cr.data, null, 2)}` : `❌ Config update failed (${cr.status}): ${JSON.stringify(cr.data)}`;
|
|
7602
|
+
};
|
|
7603
|
+
const confirmedDeploymentText = async (successText, responsePayload) => {
|
|
7604
|
+
if (!hasFunctionConfig() || confirmedFunctionConfig(responsePayload, functionConfig())) {
|
|
7605
|
+
return successText;
|
|
7606
|
+
}
|
|
7607
|
+
const fallback = await http.patch(`/v1/projects/${ref}/functions/${slug}/config`, functionConfig());
|
|
7608
|
+
if (!fallback.ok || !confirmedFunctionConfig(fallback.data, functionConfig())) {
|
|
7609
|
+
return `❌ Partial deployment (unsafe): POST succeeded and the code/bundle was deployed, but the function policy was not confirmed; legacy PATCH fallback failed (${fallback.status}): ${JSON.stringify(fallback.data)}`;
|
|
7610
|
+
}
|
|
7611
|
+
return `${successText}
|
|
7612
|
+
⚠️ Legacy non-atomic compatibility path: policy applied with follow-up PATCH`;
|
|
7588
7613
|
};
|
|
7589
7614
|
const checkSyntax = async (sourceCode) => {
|
|
7590
7615
|
const tmpDir = mkdtempSync(join2(tmpdir(), "supacloud-edge-check-"));
|
|
@@ -7630,24 +7655,31 @@ ${checkRes.err}`;
|
|
|
7630
7655
|
${deployCheck.err}`;
|
|
7631
7656
|
break;
|
|
7632
7657
|
}
|
|
7633
|
-
const dr = await http.post(`/v1/projects/${ref}/functions/${slug}`, {
|
|
7658
|
+
const dr = await http.post(`/v1/projects/${ref}/functions/${slug}`, {
|
|
7659
|
+
code,
|
|
7660
|
+
minify,
|
|
7661
|
+
...functionConfig()
|
|
7662
|
+
});
|
|
7634
7663
|
if (!dr.ok) {
|
|
7635
7664
|
text = `❌ Failed (${dr.status}): ${JSON.stringify(dr.data)}`;
|
|
7636
7665
|
break;
|
|
7637
7666
|
}
|
|
7638
|
-
text =
|
|
7639
|
-
${await updateFunctionConfig()}` : `✅ Function ${slug} deployed`;
|
|
7667
|
+
text = await confirmedDeploymentText(`✅ Function ${slug} deployed`, dr.data);
|
|
7640
7668
|
break;
|
|
7641
7669
|
case "deploy_bundle":
|
|
7642
7670
|
need("slug", slug);
|
|
7643
7671
|
need("files", files);
|
|
7644
|
-
const br = await http.post(`/v1/projects/${ref}/functions/${slug}/bundle`, {
|
|
7672
|
+
const br = await http.post(`/v1/projects/${ref}/functions/${slug}/bundle`, {
|
|
7673
|
+
files,
|
|
7674
|
+
entrypoint,
|
|
7675
|
+
minify,
|
|
7676
|
+
...functionConfig()
|
|
7677
|
+
});
|
|
7645
7678
|
if (!br.ok) {
|
|
7646
7679
|
text = `❌ Failed (${br.status}): ${JSON.stringify(br.data)}`;
|
|
7647
7680
|
break;
|
|
7648
7681
|
}
|
|
7649
|
-
text =
|
|
7650
|
-
${await updateFunctionConfig()}` : `✅ Function ${slug} bundle deployed (${Object.keys(files).length} files)`;
|
|
7682
|
+
text = await confirmedDeploymentText(`✅ Function ${slug} bundle deployed (${Object.keys(files).length} files)`, br.data);
|
|
7651
7683
|
break;
|
|
7652
7684
|
case "config":
|
|
7653
7685
|
text = await updateFunctionConfig();
|