feat: support KVS.listKeys() prefix and collection parameters#3001
Merged
feat: support KVS.listKeys() prefix and collection parameters#3001
KVS.listKeys() prefix and collection parameters#3001Conversation
KVS.listKeys() prefix and collection parametersKVS.listKeys() prefix and collection parameters
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds new parameters, prefix and collection, to the KeyValueStore.forEachKey interface and implements prefix filtering in the MemoryStorage implementation.
- Added tests to validate prefix filtering in forEachKey.
- Updated type definitions in storages.ts to include the new parameters.
- Modified MemoryStorage and core KeyValueStore implementations to process prefix and collection parameters (with collection remaining a noop).
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test/core/storages/key_value_store.test.ts | New tests added to verify prefix functionality and updated mock expectations |
| packages/types/src/storages.ts | Extended interface definitions to include prefix and collection |
| packages/memory-storage/src/resource-clients/key-value-store.ts | Added prefix filtering logic and updated pagination based on filtered items |
| packages/core/src/storages/key_value_store.ts | Propagated the new parameters to listKeys and recursive calls |
Comments suppressed due to low confidence (1)
packages/memory-storage/src/resource-clients/key-value-store.ts:160
- Consider updating inline documentation to clarify that the 'count' and pagination values are based on the filtered results when a prefix is provided.
const filteredItems = items.filter((item) => !prefix || item.key.startsWith(prefix));
janbuchar
approved these changes
Jun 7, 2025
packages/memory-storage/src/resource-clients/key-value-store.ts
Outdated
Show resolved
Hide resolved
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.
Adds
prefixandcollectionparameters to theKVS.forEachKey()interface and implements theprefixfilter in theMemoryStorageimplementation of KVS. Note thatMemoryStoragedoesn't currently support thecollectionparameter (it's noop).Closes #2974