Skip to content

Add DynamoDB state adapter#281

Open
anatolzak wants to merge 2 commits intovercel:mainfrom
anatolzak:feat/dynamodb-state-adapter
Open

Add DynamoDB state adapter#281
anatolzak wants to merge 2 commits intovercel:mainfrom
anatolzak:feat/dynamodb-state-adapter

Conversation

@anatolzak
Copy link

@anatolzak anatolzak commented Mar 21, 2026

Closes #282

Summary

  • Adds @chat-adapter/state-dynamodb — a serverless-native state adapter using DynamoDB single-table design
  • Uses DynamoDBDocument client with shorthand methods (.put(), .get(), .delete(), .query(), .update(), .batchWrite())
  • AWS SDK packages as peer dependencies to avoid version conflicts

Design

  • Single table (pk/sk string keys, no GSIs) with all record types (subscriptions, locks, cache, lists)
  • Atomic lock operations via DynamoDB conditional expressions
  • Dual-layer TTL: DynamoDB native TTL (epoch seconds) for GC + app-level expiresAtMs checks for correctness
  • List ordering via atomic counter (ADD seq :one) + 16-digit zero-padded sort keys
  • Values stored as native DynamoDB types (no JSON serialization)

Test plan

  • pnpm validate passes (typecheck, lint, knip, tests, build)
  • 41 unit tests with mocked DynamoDBDocument client
  • Manual test with DynamoDB Local + example Next.js app

🤖 Generated with Claude Code

anatolzak and others added 2 commits March 21, 2026 21:19
Adds @chat-adapter/state-dynamodb, a serverless-native state adapter
using DynamoDB single-table design with DynamoDBDocument client.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Users typically already have @aws-sdk in their project. Peer deps
avoid version conflicts and reduce bundle duplication.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Contributor

vercel bot commented Mar 21, 2026

@anatolzak is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

@socket-security
Copy link

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​aws-sdk/​client-dynamodb@​3.1014.09810010098100
Added@​aws-sdk/​lib-dynamodb@​3.1014.010010010098100

View full report

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.

Add DynamoDB state adapter

1 participant