storage.defineMap
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 10.5k
- Forks
- 564
- PR merge metrics
- No merged PRs in 30d
Description
Feature Request
Add support for storage.defineMap to manage namespaced collections in extension storage.
Currently, storage.defineItem is great for managing a single key/value with fallback and typing. However, many extensions need to manage collections of related entries (like accounts, sessions, cached items, etc.) where each entry should be stored under its own key but share a common namespace.
Proposed API
type AccountDetails = {
name: string;
email: string;
};
const accounts = storage.defineMap<string, AccountDetails | null>(
"local:account",
{
fallbackValue: null,
},
);
// set
await accounts.setValue("account-1", { name: "Alice", email: "a@ex.com" });
// get
const acc = await accounts.getValue("account-1"); // AccountDetails | null
// list
const allAccounts = await accounts.getAll();
// keys
const keys = await accounts.keys();
// delete
await accounts.deleteValue("account-1");
The entries would be stored as multiple keys with the format:
account:account-1
account:account-2
...
This mirrors defineItem’s ergonomics but allows managing collections in a structured way.
Is your feature request related to a bug?
N/A
What are the alternatives?
- Manually prefix keys with
storage.defineItemand manage them individually. - Implement custom helper utilities (which leads to duplicated code across projects).
- Use
defineItemwith a single object holding all entries, but this means writes overwrite the whole collection, making sync inefficient.
Additional context
defineMap would simplify working with multiple related storage items, improve readability, and reduce boilerplate in extensions that manage sets of accounts, wallets, or similar keyed collections.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the existing storage.defineItem implementation and its tests, then compare its typing, fallback, and key-handling behavior with the proposed defineMap API. Done means supporting setValue, getValue, getAll, keys, and deleteValue for namespaced entries using the documented key format, with appropriate tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100