From b3b82eb82ece133f816066c138d169d358295bc5 Mon Sep 17 00:00:00 2001 From: Paul Paterson Date: Tue, 10 Dec 2024 19:08:29 -0500 Subject: [PATCH] Update usage of the schema API for push, status, and diff (#502) Co-authored-by: E. Cooper --- src/commands/schema/diff.mjs | 2 +- src/commands/schema/push.mjs | 6 ++---- src/commands/schema/status.mjs | 2 +- src/lib/db.mjs | 2 +- test/schema/diff.mjs | 8 ++++---- test/schema/push.mjs | 15 +++++---------- test/schema/status.mjs | 8 ++++---- 7 files changed, 18 insertions(+), 25 deletions(-) diff --git a/src/commands/schema/diff.mjs b/src/commands/schema/diff.mjs index 5cc9f865..b3e9a957 100644 --- a/src/commands/schema/diff.mjs +++ b/src/commands/schema/diff.mjs @@ -87,7 +87,7 @@ async function doDiff(argv) { } else { const { diff } = await makeFaunaRequest({ argv, - path: "/schema/1/validate", + path: "/schema/1/diff", params: buildValidateParams(argv, version), body: files, method: "POST", diff --git a/src/commands/schema/push.mjs b/src/commands/schema/push.mjs index 3bc5f8d0..def4c50b 100644 --- a/src/commands/schema/push.mjs +++ b/src/commands/schema/push.mjs @@ -31,16 +31,14 @@ async function doPush(argv) { secret, }); } else { - // Confirm diff, then push it. `force` is set on `validate` so we don't - // need to pass the last known schema version through. + // Confirm diff, then push it. const params = new URLSearchParams({ - force: "true", staged: argv.active ? "false" : "true", }); const response = await makeFaunaRequest({ argv, - path: "/schema/1/validate", + path: "/schema/1/diff", params, body: fsl, method: "POST", diff --git a/src/commands/schema/status.mjs b/src/commands/schema/status.mjs index dc7822e5..3c1cd970 100644 --- a/src/commands/schema/status.mjs +++ b/src/commands/schema/status.mjs @@ -36,7 +36,7 @@ async function doStatus(argv) { const validationResponse = await makeFaunaRequest({ argv, - path: "/schema/1/validate", + path: "/schema/1/diff", params, method: "POST", body: fsl, diff --git a/src/lib/db.mjs b/src/lib/db.mjs index ed9f4829..da84d2fe 100644 --- a/src/lib/db.mjs +++ b/src/lib/db.mjs @@ -5,7 +5,7 @@ import { CommandError } from "./command-helpers.mjs"; import { retryInvalidCredsOnce } from "./fauna-client.mjs"; function buildParamsString({ argv, params, path }) { - const routesWithColor = ["/schema/1/staged/status", "/schema/1/validate"]; + const routesWithColor = ["/schema/1/staged/status", "/schema/1/diff"]; if (params && argv.color && routesWithColor.includes(path)) params.set("color", "ansi"); if (params && params.sort) params.sort(); diff --git a/test/schema/diff.mjs b/test/schema/diff.mjs index d2643baa..b21ff8b2 100644 --- a/test/schema/diff.mjs +++ b/test/schema/diff.mjs @@ -45,7 +45,7 @@ describe("schema diff", function () { { ...commonFetchParams, method: "GET" }, ); expect(fetch).to.have.been.calledWith( - buildUrl("/schema/1/validate", { + buildUrl("/schema/1/diff", { color: "ansi", diff: "semantic", force: "true", @@ -72,7 +72,7 @@ describe("schema diff", function () { { ...commonFetchParams, method: "GET" }, ); expect(fetch).to.have.been.calledWith( - buildUrl("/schema/1/validate", { + buildUrl("/schema/1/diff", { color: "ansi", diff: "semantic", force: "true", @@ -99,7 +99,7 @@ describe("schema diff", function () { method: "GET", }); expect(fetch).to.have.been.calledWith( - buildUrl("/schema/1/validate", { + buildUrl("/schema/1/diff", { force: "true", staged: "true", diff: "semantic", @@ -125,7 +125,7 @@ describe("schema diff", function () { { ...commonFetchParams, method: "GET" }, ); expect(fetch).to.have.been.calledWith( - buildUrl("/schema/1/validate", { + buildUrl("/schema/1/diff", { force: "true", color: "ansi", staged: "true", diff --git a/test/schema/push.mjs b/test/schema/push.mjs index 29721824..b93a4b22 100644 --- a/test/schema/push.mjs +++ b/test/schema/push.mjs @@ -71,8 +71,7 @@ describe("schema push", function () { await run(`schema push --secret "secret"`, container); expect(fetch).to.have.been.calledWith( - buildUrl("/schema/1/validate", { - force: "true", + buildUrl("/schema/1/diff", { staged: "true", color: "ansi", }), @@ -125,8 +124,7 @@ describe("schema push", function () { await run(`schema push --secret "secret" --active`, container); expect(fetch).to.have.been.calledWith( - buildUrl("/schema/1/validate", { - force: "true", + buildUrl("/schema/1/diff", { staged: "false", color: "ansi", }), @@ -172,8 +170,7 @@ describe("schema push", function () { await run(`schema push --secret "secret"`, container); expect(fetch).to.have.been.calledWith( - buildUrl("/schema/1/validate", { - force: "true", + buildUrl("/schema/1/diff", { staged: "true", color: "ansi", }), @@ -215,8 +212,7 @@ describe("schema push", function () { await run(`schema push --secret "secret"`, container); expect(fetch).to.have.been.calledWith( - buildUrl("/schema/1/validate", { - force: "true", + buildUrl("/schema/1/diff", { staged: "true", color: "ansi", }), @@ -261,8 +257,7 @@ describe("schema push", function () { await run(`schema push --secret "secret" --active`, container); expect(fetch).to.have.been.calledWith( - buildUrl("/schema/1/validate", { - force: "true", + buildUrl("/schema/1/diff", { staged: "false", color: "ansi", }), diff --git a/test/schema/status.mjs b/test/schema/status.mjs index cf60c878..fbee9d1f 100644 --- a/test/schema/status.mjs +++ b/test/schema/status.mjs @@ -92,7 +92,7 @@ describe("schema status", function () { commonFetchParams, ); expect(fetch).to.have.been.calledWith( - buildUrl("/schema/1/validate", { + buildUrl("/schema/1/diff", { diff: "summary", staged: "true", version: "0", @@ -135,7 +135,7 @@ describe("schema status", function () { commonFetchParams, ); expect(fetch).to.have.been.calledWith( - buildUrl("/schema/1/validate", { + buildUrl("/schema/1/diff", { diff: "summary", staged: "true", version: "0", @@ -184,7 +184,7 @@ describe("schema status", function () { ); expect(fetch).to.have.been.calledWith( - buildUrl("/schema/1/validate", { + buildUrl("/schema/1/diff", { diff: "summary", staged: "true", version: "0", @@ -230,7 +230,7 @@ describe("schema status", function () { commonFetchParams, ); expect(fetch).to.have.been.calledWith( - buildUrl("/schema/1/validate", { + buildUrl("/schema/1/diff", { diff: "summary", staged: "true", version: "0",