feat: Offline Progress Sync API (#51)#57
Merged
Kaylahray merged 2 commits intoApr 27, 2026
Conversation
- Add SyncEvent Prisma model with idempotency key, deviceId, clientTimestamp, serverTimestamp, syncVersion, and per-item status - POST /sync/progress — accepts batched offline progress events with conflict resolution and stale version detection - POST /sync/completions — reconciles offline quiz attempts; updates score only when higher, creates new completion otherwise - Idempotency keys prevent duplicate processing of retried requests - Per-item results returned: applied, skipped, or rejected with reason - Both endpoints are rate-limited via authenticatedLimiter - Unit tests covering retry, conflict, partial success, and validation scenarios
|
@nonsobethel0-dev 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! 🚀 |
Kaylahray
approved these changes
Apr 27, 2026
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.
Fixes #51
What changed
SyncEventPrisma model trackingidempotencyKey,deviceId,clientTimestamp,serverTimestamp,syncVersion,status, andrejectionReasonPOST /api/v1/sync/progress— accepts batched offline progress events; resolves conflicts by rejecting stale sync versionsPOST /api/v1/sync/completions— reconciles offline quiz/completion attempts; updates score when higher, skips when equal or lower, creates new completion when none existsapplied,skipped, orrejectedwith a reasonauthenticatedLimiterWhy
How to test
POST /api/v1/sync/progresswith{ "events": [{ "idempotencyKey": "...", "deviceId": "...", "moduleId": "...", "progressPercent": 60, "clientTimestamp": "...", "syncVersion": 1 }] }→ should returnappliedskippedsyncVersionlower than an already-stored event → should returnskippedwith stale version reasonPOST /api/v1/sync/completionswith valid events → applied if module exists and score is new or higherskippedrejectedwith reason