convex
Version:
Client for the Convex Cloud
66 lines (65 loc) • 2.21 kB
JavaScript
;
import { changeSpinner, logFailure } from "../../bundler/context.js";
import { deploymentFetch, logAndHandleFetchError } from "./utils/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 onError = (err) => {
if (err.toString() === "TypeError: fetch failed") {
changeSpinner(ctx, `Fetch failed, is ${url} correct? Retrying...`);
}
};
const fetch = deploymentFetch(url, request.adminKey, onError);
changeSpinner(ctx, "Analyzing and deploying source code...");
try {
const response = await fetch("/api/deploy2/start_push", {
body: JSON.stringify(request),
method: "POST"
});
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, adminKey);
try {
const response = await fetch("/api/deploy2/wait_for_schema", {
body: JSON.stringify({
adminKey,
schemaChange: startPush2.schemaChange,
dryRun: false
}),
method: "POST"
});
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, adminKey);
changeSpinner(ctx, "Finalizing push...");
try {
const response = await fetch("/api/deploy2/finish_push", {
body: JSON.stringify({
adminKey,
startPush: startPush2,
dryRun: false
}),
method: "POST"
});
return await response.json();
} catch (error) {
logFailure(ctx, "Error: Unable to finish push to " + url);
return await logAndHandleFetchError(ctx, error);
}
}
//# sourceMappingURL=deploy2.js.map