Feat api versioning,deprecation and sunset for breaking stream contract changes#182
Merged
Conversation
…ream API changes Implements the full API versioning framework for issue Streampay-Org#122: - app/lib/api-version.ts: detectVersion(), isV1SunsetPassed(), addV1DeprecationHeaders(), sunsetResponse(), toV2Stream() transformer - middleware.ts: rewrites /api/v1/* → /api/* and injects RFC 9745 Deprecation + Sunset headers on every v1 response; returns 410 Gone after 2026-12-31 - app/api/v2/streams/route.ts + [id]/route.ts: v2 CRUD with 3 breaking changes (allowed_actions array, snake_case dates, structured settlement) - app/lib/api-version.test.ts: 31 unit tests for all versioning utilities - app/api/streams/v1-contract.test.ts: 14 contract tests that pin the v1 shape for the full deprecation window; includes a policy assertion that sunset ≥ 90 days after deprecation - CHANGELOG.md: Keep-a-Changelog format with v1.0.0 baseline and v2.0.0 breaking-change table - docs/api-v2-migration.md: field-by-field diff with migration snippets and wallet-partner checklist; deadline 2026-12-31 - docs/deprecation-notice-template.md: comms template for future majors - Fixed pre-existing merge-conflict corruption in db.ts, route.ts, [id]/route.ts, start/route.ts, pause/route.ts, settle/route.ts
|
@TheDEV111 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! 🚀 |
Author
|
@greatest0fallt1me pls merge |
…or-breaking-stream-contract-changes
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
closes #122
app/lib/api-version.ts— core versioning library:detectVersion(URL path → header → default),
isV1SunsetPassed, RFC 9745addV1DeprecationHeaders,sunsetResponse(410 Gone), andtoV2Streamtransformer for the three breaking shape changesmiddleware.ts— Next.js middleware rewrites/api/v1/*→/api/*, injectsDeprecation+Sunset+Linkheaders on everyv1 response, and short-circuits with 410 after 2026-12-31
/api/v2/streams/— v2 list/create/get/delete with the newresponse shape; action routes (start/pause/settle/withdraw) are
tracked as child issues per the 96h framework scope
api-version.test.ts) and 14 contract tests(
v1-contract.test.ts) — the contract suite pins the v1 wire shapeand includes a policy assertion that sunset ≥ 90 days after
deprecation; run in CI for the full deprecation window
CHANGELOG.md+docs/api-v2-migration.md+docs/deprecation-notice-template.md+ README versioningsection
db.ts,route.ts,[id]/route.ts,start/,pause/, andsettle/route files thatwere causing all tests importing those modules to fail at suite load
The three breaking changes (v1 → v2)
nextAction: stringallowed_actions: string[]createdAt/updatedAtcreated_at/updated_atsettlementTxHash?: stringsettlement: {tx_hash, settled_at} | nullDeprecation timeline
Deprecation/Sunsetheaders on all v1 responses/api/v1/*returns410 Gone245-day notice (minimum policy: 90 days).
Test plan
npm test -- --testPathPattern="api-version|v1-contract|stream-lifecycle.e2e"— all 45 passcurl -i /api/v1/streamsincludesDeprecation,Sunset,Linkresponse headerscurl -i /api/v2/streamsresponse body hasallowed_actions,created_at,settlement: nullV1_SUNSET_DATEto a past date,/api/v1/streamsreturns410withAPI_VERSION_SUNSETbodyCHANGELOG.mdanddocs/api-v2-migration.mdrender correctly on GitHubSecurity notes
No auth, key, PII, or money-movement paths changed. The middleware
operates on path prefix only. The v2 routes share the same in-memory
dband idempotency store as v1 — no new persistence surface.