Repository navigation
feat(api): revert a form to its previous published version - #229
Merged
Merged
Conversation
publishForm now copies the live config it replaces into previous_config, column to column in the same UPDATE, and dates it in previous_published_at_ms (the last publish, or the form's creation for a form that was live before its first publish). revertForm swaps the live config with the previous one, dates included, so reverting twice undoes the revert. It carries the destinations the form has now over the restored version and never touches the pending draft. NOTHING_TO_REVERT when there is no previous version. The swap is one stamp-guarded UPDATE, retried on a concurrent write. FormRow gains previousPublishedAt; the stored version stays server side. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Josue Hernandez <josue@daptatech.com>
Puts the previously published version back live and answers the form, with publicUrl, editorUrl and previousPublishedAt like every form response. 409 NOTHING_TO_REVERT when there is nothing to go back to. Allowed with an API key. Documented in the OpenAPI document. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Josue Hernandez <josue@daptatech.com>
…version admin.publish gains the publish menu label, the revert item with its date hint and disabled hint, the confirmation (which names the date of the version that goes live and says the draft does not change), and the success and error messages. EN and ES. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Josue Hernandez <josue@daptatech.com>
The Publish button gains a menu (the chevron beside it) with "Revert to the previous published version". The item shows when that version went live, is disabled while there is none, and asks first in a dialog that names the date and says the draft does not change. Pending edits are flushed before the call, as Publish does. After a revert the editor adopts the new stamp, refreshes its option locks, and, when no draft is pending, puts the reverted live config on screen so the next edit does not resurrect the version just taken down. A publish lights the item up without a reload, and a 409 NOTHING_TO_REVERT greys it out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Josue Hernandez <josue@daptatech.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Josue Hernandez <josue@daptatech.com>
Also move openConfig above reanchorAfterDelete's doc comment, which the extraction had left orphaned above the wrong function. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Josue Hernandez <josue@daptatech.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a one-step undo for publishing.
POST /v1/forms/:id/revert(and a matching button in the editor) puts the previously published version of a form back live. Live destinations are kept, the draft is never touched, and reverting twice undoes the revert.Changes
publishFormkeeps the replaced config and its publish date; newrevertFormswaps live and previous configs with a guarded UPDATE (retries on a concurrent write, returns STALE after 3 raced attempts). Uses the columns from migration 0024, so no new migration.POST /v1/forms/:id/revertreturns 200 with the form, 409NOTHING_TO_REVERT({error, message}) or 404. Scoped by account, allowed for API keys. The stored previous config is never returned and webhook secrets stay masked.@quill/dband@quill/shared.How it was tested
pnpm typecheck,pnpm lintandpnpm teston SQLite (db, api, web, shared and the other packages) all green on Node 22.@quill/dbsuite on Postgres (366/366).apps/api/src/form-revert.spec.ts,packages/db/src/form-revert.spec.ts,publish-button.spec.tsx(disabled state, date, dialog, 409, Spanish).PUBLISH_GATE_LOCAL=1 pnpm run publish-gatepasses.Review notes
An independent review fixed two small gaps (commit 7db3908):
openConfigwas extracted.Known, left as is: a brand kit applied after the last publish is not carried over by a revert (the spec keeps only destinations);
onRevertedin the editor is covered by Playwright, not vitest.🤖 Generated with Claude Code