convex
Version:
Client for the Convex Cloud
74 lines (73 loc) • 2.38 kB
JavaScript
import { changeSpinner, logFailure } from "../../bundler/context.js";
import { version } from "../version.js";
import { deploymentFetch, logAndHandleFetchError } from "./utils.js";
import {
startPushResponse
} from "./deployApi/startPush.js";
export async function startPush(ctx, url, request, verbose) {
if (verbose) {
const custom = (_k, s) => typeof s === "string" ? s.slice(0, 40) + (s.length > 40 ? "..." : "") : s;
console.log(JSON.stringify(request, custom, 2));
}
const fetch = deploymentFetch(url);
changeSpinner(ctx, "Analyzing and deploying source code...");
try {
const response = await fetch("/api/deploy2/start_push", {
body: JSON.stringify(request),
method: "POST",
headers: {
"Content-Type": "application/json",
"Convex-Client": `npm-cli-${version}`
}
});
return startPushResponse.parse(await response.json());
} catch (error) {
logFailure(ctx, "Error: Unable to start push to " + url);
return await logAndHandleFetchError(ctx, error);
}
}
export async function waitForSchema(ctx, adminKey, url, startPush2) {
const fetch = deploymentFetch(url);
try {
const response = await fetch("/api/deploy2/wait_for_schema", {
body: JSON.stringify({
adminKey,
schemaChange: startPush2.schemaChange,
dryRun: false
}),
method: "POST",
headers: {
"Content-Type": "application/json",
"Convex-Client": `npm-cli-${version}`
}
});
return await response.json();
} catch (error) {
logFailure(ctx, "Error: Unable to wait for schema from " + url);
return await logAndHandleFetchError(ctx, error);
}
}
export async function finishPush(ctx, adminKey, url, startPush2) {
const fetch = deploymentFetch(url);
changeSpinner(ctx, "Finalizing push...");
try {
const response = await fetch("/api/deploy2/finish_push", {
body: JSON.stringify({
adminKey,
startPush: startPush2,
dryRun: false
}),
method: "POST",
headers: {
"Content-Type": "application/json",
"Convex-Client": `npm-cli-${version}`
}
});
return await response.json();
} catch (error) {
logFailure(ctx, "Error: Unable to finish push to " + url);
return await logAndHandleFetchError(ctx, error);
}
}
//# sourceMappingURL=deploy2.js.map
;