Open
Conversation
Contributor
|
@vincenzodomina is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
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 #252
Adds
@chat-adapter/state-supabase, a production state adapter that uses an existing Supabase client and RPCs for subscriptions, locks, cache, and list state—no Redis or separate Postgres URL.Why
For apps already on Supabase, this keeps Chat SDK state on the same DB and client: reuse the app’s Supabase client, manage schema via migrations, and keep access and permissions under Supabase (e.g. service-role RPCs only). Avoids the mismatch of
@chat-adapter/state-pg(directpg/ connection URL and runtime schema creation).What’s in this PR
packages/state-supabase:createSupabaseState({ client, keyPrefix?, logger? })using the sharedStateAdaptercontract.sql/chat_state.sql: copy-paste migration for a dedicatedchat_stateschema (tables + RPCs). Grants are RPC-only forservice_role; schema is not created at runtime.chat_state_subscribe,chat_state_acquire_lock,chat_state_set,chat_state_append_to_list). TTL handling matches memory/Redis (0 or invalid = no expiry). List appends are serialized per key withpg_advisory_xact_lockso trim and TTL stay correct under concurrency.RUN_INTEGRATION=1. 100% coverage on the adapter module.Usage
sql/chat_state.sqlto your Supabase schema/migrations.chat_stateschema in the Supabase API.Test plan
.changeset/add-state-supabase-adapter.mdwithminorfor@chat-adapter/state-supabaseand a short changelog summary, per contributing guidelines and Changesets workflow.pnpm check,pnpm typecheck, andpnpm buildat repo root (and/orpnpm validate) so the new package passes lint, typecheck, and build.pnpm --filter @chat-adapter/state-supabase test. All 60 unit tests pass with 100% coverage on the adapter; tests cover factory, connection lifecycle, ensureConnected for every public method, use-after-disconnect, RPC error propagation, subscriptions, locking (including lock normalization andextendLockfalse), cache (including TTL normalization andsetIfNotExistsfalse), lists (including partial options andttlMs0), and StateAdapter contract.RUN_INTEGRATION=1, the Testcontainers-based integration suite runs (Postgres +sql/chat_state.sql), including schema/RPC checks and the adapter against a real DB; this is skipped in default CI.