Releases: AndrewBastin/verzod
v0.5.1
This release fixes a bug in isLatest() where it could incorrectly return true even when getVersion() indicated the entity wasn't actually at the latest version. The function now properly validates the version number, aligning its behavior with is().
What's Changed
- Check version number in
isLatest()(as inis()) by @janbaykara in #8
Full Changelog: v0.5.0...v0.5.1
v0.5.0
This release mainly improves migration safety by formally validating the results of up functions during migrations.
Previously, if an up function returned data that didn't match the target schema, it could lead to subtle runtime issues. Now, verzod validates migration outputs and provides clear error messages when schema mismatches occur.
Caution
Possible behavior change for cyclic/nested entities
Because migration results are now parsed through the target schema, any entityReference transforms in the schema will be applied to the up function's output. This means nested entities will now be automatically migrated to the target version by the schema's entityRefUptoVersion transform.
Before: Nested children stayed at whatever version your up function returned them as.
After: Nested children are migrated to the target version by the schema's transform after up completes.
If your up functions relied on children remaining at their original version, you may need to adjust your migration logic.
What's Changed
- fix: formally validate up results during migrations by @janbaykara in #7
- chore: bump dependencies and switch to node 24 for nix dev shell by @AndrewBastin in d330aff
New Contributors
- @janbaykara made their first contribution in #7
Full Changelog: v0.4.0...v0.5.0
v0.4.0
This release introduces direct access to the latest entity schema and includes development tooling improvements.
The new latestSchema getter property allows you to access the Zod schema of the latest version of an entity directly. This is useful when you need to work with the raw Zod schema in existing validation workflows:
const Environment = createVersionedEntity({
latestVersion: 2,
versionMap: { /* ... */ },
getVersion: (data) => data.v
})
// Access the latest schema directly
const latestSchema = Environment.latestSchema // Returns the z.object() schema for version 2
// Use it with existing Zod workflows
const result = latestSchema.safeParse(someData)What's Changed
- feat: ability to get the zod schema of latest version of an entity by @AndrewBastin in 5716ec9
- feat: add nix tooling by @AndrewBastin in 09b9dfa
- fix: vitest should only check against tests in src folder by @AndrewBastin in 16325b9
- chore: enable typecheck on tests by @AndrewBastin in 5963ae7
- chore: bump and pin dev dependencies by @AndrewBastin in dfa3b05
Contributors
Full Changelog: v0.3.0...v0.4.0
v0.3.0
This release focuses on introducing features around adding upTo-series of functions for pinned entity references.
New upTo Version-Bounded Functions
This release introduces powerful version-bounded parsing and migration capabilities, allowing you to parse and migrate entities only up to a specific version rather than always migrating to the latest. This is particularly useful for recursive entity definitions where entities reference themselves.
Key additions:
VersionedEntity.isUpToVersion(data, version)- Type guard to check if data is valid for any version up to the specified versionVersionedEntity.safeParseUpToVersion(data, version)- Parse and migrate data up to a specific version (not beyond)entityRefUptoVersion(entity, version)- Create Zod schemas for version-bounded entity references
When migrating recursive structures (like trees), you can now ensure that child entities are only migrated up to the version you're currently migrating to, preventing issues where children might be migrated to future versions that didn't exist when you wrote the migration logic.
What's Changed
- feat: ability to define entity references up to a specific version by @AndrewBastin
Full Changelog: v0.2.4...v0.3.0
v0.2.4
What's Changed
- fix: update return type of
entityReferenceto remove type recursion error issues by @AndrewBastin in #3
New Contributors
- @AndrewBastin made their first contribution in #3
Full Changelog: v0.2.3...v0.2.4
v0.2.3
What's Changed
- fix: nested entity references by @saschatimme in #1
- chore: bump dev dependencies to the latest versions by @AndrewBastin
New Contributors
- @saschatimme made their first contribution in #1
Full Changelog: v0.2.2...v0.2.3
v0.2.2
This is a small patch fix update for a fix with how InferredEntity deals with Zod schemas that have a catch schema applied on them resolving to undefined.
What's Changed
- fix: InferredEntity not dealing with catch schemas properly by @AndrewBastin in e47f6b4
Full Changelog: v0.2.0...v0.2.2
v0.2.0
What's Changed
- chore: introduce
test:watchcommand for development testing. - feat: introduce
entityReferencefunction that returns a custom zod schema to refer to an entity in a zod schema - chore: update README to feature the usage of
entityReference - chore: move
zodfrom dependency to as apeerDependency.
Full Changelog: v0.1.1...v0.2.0
v0.1.1
v0.1.0 - Initial Release
This marks the initial release of the library.
Full Changelog: https://github.com/AndrewBastin/verzod/commits/v0.1.0