Support versioned types as collection schemas - #103
Merged
lejeunerenard merged 3 commits intoJul 30, 2026
Merged
Conversation
This was referenced Jul 20, 2026
shavtvalishvili
marked this pull request as ready for review
July 20, 2026 21:07
shavtvalishvili
force-pushed
the
versioned-collection-schemas
branch
from
July 20, 2026 21:12
450a183 to
acc441d
Compare
Covers why the `if (!field) return null` is necessary in `resolvePathToType()`.
lejeunerenard
approved these changes
Jul 30, 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 lets a collection use a hyperschema
versions:type as its row schema, so old rows read back in the newest shape - the same upgrade-on-read versioned types already give wire messages.Three things stood in the way: key paths don't look through the wrapper, the derived value schema doesn't know about versions, and
toCodeisn't told wheremessages.jslands (it throws once a maps file is involved).With this, a collection whose schema is a versioned type works end to end:
filenametotoCodeso the maps import path can be computedTests: a stored v1 row reads back mapped after the schema gains a v2, and a key path through a nested versioned field.
Depends on holepunchto/hyperschema#58 (reload with forward version refs) and holepunchto/hyperschema#59 (maps path persisted in schema.json) - the tests exercise both, since hyperdb's builder reloads schema.json on its own.
One heads-up: the new test re-requires
messages.jsbetween builds itself. The test helpers'build()refreshes the generatedindex.jsbut notmessages.js- and fixing that globally makesdefine versionField on collectionfail on main (it currently decodes gen-3 rows through gen-1's cached codec). I left the helper untouched and scoped the refresh to the new test; the versionField observation is filed as #104.Part of a series making versioned types usable end-to-end: holepunchto/hyperschema#58 (reload fix), holepunchto/hyperschema#59 (maps persistence), holepunchto/hyperschema#60 (encode default), #103 (versioned collection schemas), holepunchto/hyperschema-ts#9 (emitted types). Each stands alone except hyperdb#103, which needs #58 + #59.