[explorer] add implementation for local KV API (take 2)#12152
Merged
emily-shen merged 9 commits intomainfrom Jan 28, 2026
Merged
[explorer] add implementation for local KV API (take 2)#12152emily-shen merged 9 commits intomainfrom
emily-shen merged 9 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: 0ef809f The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
19cef98 to
33108bb
Compare
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
c2d7634 to
ee5f9e7
Compare
5 tasks
vicb
reviewed
Jan 27, 2026
vicb
reviewed
Jan 27, 2026
vicb
reviewed
Jan 27, 2026
vicb
reviewed
Jan 27, 2026
vicb
reviewed
Jan 27, 2026
vicb
reviewed
Jan 27, 2026
vicb
reviewed
Jan 27, 2026
vicb
reviewed
Jan 27, 2026
Contributor
There was a problem hiding this comment.
Did a quick pass and added a few comments.
I still have the same question. What would it like without Hono? If adding 50l could avoid adding 500kB of dependencies maybe it's worth it? (not sure about the 50l nor the 500kB but I think it's worth investigating)
Edit: it looks like hono is only ~20kB and using import { Hono } from 'hono/tiny' could even reduce that. So probably not worth the effort of finding something else.
NuroDev
reviewed
Jan 27, 2026
64ca50e to
a4b5c1d
Compare
NuroDev
reviewed
Jan 27, 2026
NuroDev
reviewed
Jan 27, 2026
Uses a JSON binding in the Local Explorer worker that maps binding names to namespace IDs
Merged
This was referenced Jan 28, 2026
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.
This PR implements the KV api by:
filter-openapi.ts, with config inopenapi-filter-config-ts).hey-api(inlocal-explorer/generated)By commit:
rename getLocalExplorerFromEnv() to getLocalExplorerEnabledFromEnv() - a stray fixup from the last PR
Add resource ID to binding name map - since we route by resource id, but the id is not available at runtime, pass in an id to binding name map as a JSON binding
Add script to filter openapi spec down - takes the existing cloudflare openapi spec which is a casual 400k lines and filters it down to just the endpoints we want, and also filters out specific components we have not yet implemented.
This is done via our own parsing script rather than a library because all openapi filtering tools i can find assume that you can annotate the original openapi spec (e.g. with x-ignore). i don't think it would be practical for us to checkout and modify the full openapi spec (again, 400k lines), so instead we have this filtering script. Claude wrote this filtering script, and i've sanity checked it, but tbh i think the best way to review this is to look at the output in
openapi.local.jsonand verify that it is what you expect. The filtering script is configured inopenapi-filter-config.tswhich makes it easier to extend in the future.Once we have an openapi spec, we generate zod schemas/types using
hey-api. These are in thelocal-explorer/generatedfolder.add implementation for KV API - we use hono to do the routing here, using its middleware to validate the requests using the generated zod schemas.
I've changed the approach since #12075 because I think it will be more maintainable to start from the existing OpenAPI spec (as much as i like the concept of writing the schema in typescript, it doesn't really make sense). Also, the existing openapi spec will not undergo breaking changes without a lot of warning, so given we periodically update this spec, we should always have a compatible subset of the remote APIs. I think it is fine if we have missing APIs, because adding APIs later is a non-breaking change.
A picture of a cute animal (not mandatory, but encouraged)