Skip to content

feat: support KVS.listKeys() prefix and collection parameters#3001

Merged
barjin merged 3 commits intomasterfrom
feat/kvs-listkeys-prefix-collection
Jun 9, 2025
Merged

feat: support KVS.listKeys() prefix and collection parameters#3001
barjin merged 3 commits intomasterfrom
feat/kvs-listkeys-prefix-collection

Conversation

@barjin
Copy link
Member

@barjin barjin commented Jun 6, 2025

Adds prefix and collection parameters to the KVS.forEachKey() interface and implements the prefix filter in the MemoryStorage implementation of KVS. Note that MemoryStorage doesn't currently support the collection parameter (it's noop).

Closes #2974

@barjin barjin requested review from Copilot and janbuchar June 6, 2025 14:42
@barjin barjin self-assigned this Jun 6, 2025
@barjin barjin changed the title feat: add KVS.listKeys() prefix and collection parameters feat: support KVS.listKeys() prefix and collection parameters Jun 6, 2025
@github-actions github-actions bot added this to the 116th sprint - Tooling team milestone Jun 6, 2025
@github-actions github-actions bot added t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics. labels Jun 6, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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));

@barjin barjin merged commit 5c4726d into master Jun 9, 2025
9 checks passed
@barjin barjin deleted the feat/kvs-listkeys-prefix-collection branch June 9, 2025 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: support new parameters for KeyValueStore.listKeys

4 participants