Skip to content

feat(snippets): Snippet Revision Management API #190 - #200

Merged
SudiptaPaul-31 merged 1 commit into
SudiptaPaul-31:mainfrom
Olayiwola2904:fix/snippet-revision-management-api-190
Sep 27, 2026
Merged

SudiptaPaul-31 merged 1 commit into
SudiptaPaul-31:mainfrom
Olayiwola2904:fix/snippet-revision-management-api-190

Conversation

@Olayiwola2904

Copy link
Copy Markdown
Contributor

Overview

This PR implements the Snippet Revision Management API so every meaningful snippet update is stored as an immutable, sequentially numbered revision. Restoring a past revision never erases history — it appends a new revision with the restored content.

Related Issue

Changes

Revision Engine

  • [ADD] lib/snippet-revisions.ts

    • createRevision — appends a new revision with sequential versionNumber
    • listRevisions — metadata list (version, timestamp, editor, preview)
    • compareRevisions — side-by-side diff via existing buildSideBySideDiff
    • restoreRevision — rolls back by creating a new revision entry
    • In-memory store + optional Neon snippet_revisions table
    • Audit trail for create / compare / restore / list (logEvent + in-memory)
  • [ADD] lib/snippet-revisions.test.ts

    • Covers all acceptance criteria (create-on-update, list metadata, diff, restore-preserves-history, sequential versions, audit logging)

API Routes

  • [ADD] POST/GET /api/snippets/:id/revisions
  • [ADD] GET /api/snippets/:id/revisions/:revId/compare/:revId2
  • [ADD] POST /api/snippets/:id/revisions/:revId/restore

Schema

  • [ADD] docs/snippet-revisions-schema.sql — snippet_revisions table matching the issue example

Verification Results

Acceptance Criteria
✅ Every update creates a revision entry — no silent overwrites
✅ Revisions retrievable by snippet ID — version number, timestamp, editor
✅ Diff comparison works correctly — highlighted line diffs + stats
✅ Restore action creates a new revision — history preserved
✅ Version numbers increment sequentially — no duplicates or gaps
✅ Audit logging — create, compare, restore tracked
Acceptance Criteria Status
Every update creates a revision entry ✅
Revisions retrievable by snippet ID ✅
Diff comparison works correctly ✅
Restore creates a new revision ✅
Version numbers increment sequentially ✅
Audit logging ✅

Closes #190

@drips-wave

drips-wave Bot commented Sep 24, 2026

Copy link
Copy Markdown

@Olayiwola2904 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@vercel

vercel Bot commented Sep 24, 2026

Copy link
Copy Markdown

@Olayiwola2904 is attempting to deploy a commit to the Sudipta 's projects Team on Vercel.

A member of the Team first needs to authorize it.

@SudiptaPaul-31
SudiptaPaul-31 merged commit 82a16bd into SudiptaPaul-31:main Sep 27, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Snippet Revision Management API

2 participants