feat(internal): add resolveConfig helper, use in supabase adapter
AM
5d ago+184+184+012345678901234567890123456789-3-3-0123456789
Problem
The SupabaseMemoryAdapter hardcodes its defaults inline (options.tableName ?? "voltagent_memory", options.debug ?? false, and the logger name). There is no shared way to resolve default values against user options, so each adapter repeats the ?? pattern.
Change
@voltagent/internal: addresolveConfig(defaults, overrides)insrc/config. It is exported through a new@voltagent/internal/configentry point. That entry point has its ownpackage.jsonexport andtypesVersionsentries, atsupbuild target and a README mention.- The merge is shallow and returns a new object.
undefinedandnulloverrides fall back to the default, the same as??.- Falsy values (
false,0,"") are kept. defaultsis never mutated.
@voltagent/supabase: addSUPABASE_MEMORY_DEFAULTSinsrc/config.tsand useresolveConfigin the adapter constructor fortableNameanddebug. The default logger name now readsSUPABASE_MEMORY_DEFAULTS.loggerName. Behavior is unchanged: the defaults are stillvoltagent_memory,falseandsupabase-memory-v2.- Add a changeset:
@voltagent/internalminor,@voltagent/supabasepatch.
Tests
- New
packages/internal/src/config/config.spec.tscovers:- no overrides and null overrides
- a defined override
- undefined and null values
- falsy values
- no mutation of the defaults
- a new object being returned
- Extended
packages/supabase/src/memory-adapter.spec.tsto cover:- the default and custom table name
- the
debugdefault and enabling it - the default logger being created with the expected name
- no logger being created when one is provided
I did not run the tests or the build when writing this description.
Fixes #263
How this was validated
install: exit 0build-supabase-deps: exit 0lint: exit 0publint-internal: exit 0test-internal: exit 0test-supabase: exit 0internal-config-cjs: exit 0internal-config-esm: exit 0
Validation run locally: 8/8 commands passed (install, build-supabase-deps, lint, publint-internal, test-internal, test-supabase, internal-config-cjs, internal-config-esm).
🤖 AI assistance disclosure: prepared with autonomous-oss-contributor; reviewed and approved by @Amsal1 before submission.
Summary by CodeRabbit
- New Features
- Added a reusable configuration resolver that applies provided values over defaults while preserving valid falsy values and leaving the original defaults unchanged.
- Supabase memory adapters now use consistent defaults: the
voltagent_memorytable, debug logging off, and a default logger. You can still customize settings or provide your own logger.