feat(codecs): Standard Schema wraps; remove zod codec#36
Conversation
Add ./codecs/standard-schema with sync/async PersistStorage wraps and JSON factories; remove ./codecs/zod in favor of ~standard.
Cover factory wrong-lane/clearCorrupt paths and document async-hydrate gating on the async lane exports.
🦋 Changeset detectedLatest commit: 7d57e08 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
📝 WalkthroughWalkthroughThe PR replaces the Zod codec entry point with a Standard Schema implementation, adding sync and async validation wrappers, JSON storage factories, tests, package exports, build configuration, and corresponding documentation and recipe updates. ChangesStandard Schema persistence
Estimated code review effort: 4 (Complex) | ~45 minutes Suggested labels: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Checkov (3.3.8).size-limit.jsonTraceback (most recent call last): package.jsonTraceback (most recent call last): typedoc.jsonTraceback (most recent call last): Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/docs/content/concepts/three-seams.mdx`:
- Line 41: Qualify the corruption-handling guarantees in both documentation
examples: in apps/docs/content/concepts/three-seams.mdx at line 41, clarify that
invalid-state discard or cleanup occurs through createStorage or the Standard
Schema wrapper, not standardSchemaCodec alone; in
apps/docs/content/recipes/standard-schema.mdx at line 8, change “deletes the
key” to indicate that removal is only attempted.
In `@src/adapters/codecs/standard-schema.test.ts`:
- Around line 493-594: Add a regression test in the “standardSchemaCodec direct
seam” block covering createStorage with clearCorruptOnFailure enabled and an
accidentally asynchronous schema. Seed a valid stored value, assert the
synchronous get throws the async-validation error, and verify the value remains
in MemoryStorage instead of being cleared.
In `@src/adapters/codecs/standard-schema.ts`:
- Around line 102-123: Update standardSchemaCodec, specifically its decode path,
to rethrow async-schema wrong-lane errors in the same way as withStandardSchema
so createStorage does not classify them as corrupt or delete data when
clearCorruptOnFailure is enabled. Add a direct seam test in
src/adapters/codecs/standard-schema.test.ts covering standardSchemaCodec with
createStorage({ clearCorruptOnFailure: true }), verifying the key remains intact
and the async validation error propagates; the existing wrapper protection needs
no separate change.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 4f96ae11-9fcc-41b8-aa4f-98ab6be7d57a
📒 Files selected for processing (25)
.changeset/standard-schema-codec.md.size-limit.jsonapps/docs/content/adapters/index.mdxapps/docs/content/concepts/choosing-codec.mdxapps/docs/content/concepts/entry-points.mdxapps/docs/content/concepts/index.mdxapps/docs/content/concepts/three-seams.mdxapps/docs/content/recipes/index.mdxapps/docs/content/recipes/meta.tsapps/docs/content/recipes/standard-schema.mdxapps/docs/content/recipes/zod.mdxapps/docs/content/reference/api/index.mdxapps/docs/content/reference/api/meta.tsapps/docs/pages/_home/Batteries.astroapps/docs/pages/_home/Seams.astroapps/docs/pages/_home/UseCases.astrodocs/architecture.mddocs/plans/upstream-tanstack-pitch.mdpackage.jsonsrc/adapters/codecs/standard-schema.test.tssrc/adapters/codecs/standard-schema.tssrc/adapters/codecs/zod.test.tssrc/adapters/codecs/zod.tstsdown.config.tstypedoc.json
💤 Files with no reviewable changes (3)
- src/adapters/codecs/zod.test.ts
- src/adapters/codecs/zod.ts
- apps/docs/content/recipes/zod.mdx
Summary
./codecs/standard-schemawith sync/asyncPersistStoragewraps (withStandardSchema/withStandardSchemaAsync), JSON sugar factories, andstandardSchemaCodec(Form-style lanes; no silent hybrid)../codecs/zod— migrate to any sync~standardschema (Zod ≥3.24); Yup / Promise-returning validate → async lane (always-async hydrate — gate UI).Test plan
bun test ./src/adapters/codecs/standard-schema.test.ts(24)bun run typecheck/ lint / format (pre-commit)bun run size— standard-schema under 2 kB./codecs/zodimports in consumers (pre-1.0 breaking)Summary by CodeRabbit
New Features
Documentation
Breaking Changes