Skip to content

BREAKING: Generated Types and Schemas - #893

Merged
bachmacintosh merged 5 commits into
v3from
exp-generate
Oct 12, 2026
Merged

bachmacintosh merged 5 commits into
v3from
exp-generate

Conversation

@bachmacintosh

@bachmacintosh bachmacintosh commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Description

In this PR, we've used Claude to move the WaniKani API schema definitions into an internal package, and written a generator that can create the TypeScript types/constants, as well as schema definitions for various runtime libraries (currently valibot and Zod). Documentation on how to use the new generator is included in its package README file.

We left tests unchanged in the existing packages to make sure the generated code matched up with what we're currently expecting. One major improvement from generating the types/schemas on the fly, however, is that we're printing JSDoc on all types, constants, objects, properties, etc. without having to manually keep them all up to date. The generated documentation also removes some old @see blocks that were typedoc package links.

There is a new check step in CI that makes sure the repo is clean after regenerating the types/schema so that nothing drifts away from the core schema definitions.

We also took the opportunity to update our vitest configuration to improve test bench performance, again with no actual changes to the tests themselves.

Nature of Pull Request

This Pull Request:

  • Adds/Updates Type(s)/Schemas
  • Adds/Updates Helper Functions/Type Guards
  • Updates Documentation
  • Updates Project and/or Community Health files (e.g. README, GitHub Actions, etc.)

Its changes constitutes a:

  • Non-code change (i.e. no version bump)
  • Bug Fix or Other Small Changes (i.e. patch version bump)
  • Forward-compatible Enhancement (i.e. minor version bump)
  • ⚠️ BREAKING CHANGE regarding TypeScript, Package, and/or WaniKani API version(s) (i.e. MAJOR version bump)

Contribution Terms

I understand that by submitting this Pull Request:

bachmacintosh and others added 3 commits October 12, 2026 15:04
Signed-off-by: Collin Bachman <3395010+bachmacintosh@users.noreply.github.com>
Signed-off-by: Collin Bachman <3395010+bachmacintosh@users.noreply.github.com>
@bachmacintosh
bachmacintosh marked this pull request as ready for review October 12, 2026 19:15
@codecov

codecov Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
packages/schema/src/core/analysis.ts 100.00% <100.00%> (ø)
packages/schema/src/core/codegen.ts 100.00% <100.00%> (ø)
packages/schema/src/core/docs.ts 100.00% <100.00%> (ø)
packages/schema/src/core/revision.ts 100.00% <100.00%> (ø)
packages/schema/src/core/schema.ts 100.00% <100.00%> (ø)
packages/schema/src/core/text.ts 100.00% <100.00%> (ø)
packages/schema/src/core/validate.ts 100.00% <100.00%> (ø)
packages/schema/src/v20170710/assignments.ts 100.00% <100.00%> (ø)
packages/schema/src/v20170710/base.ts 100.00% <100.00%> (ø)
...ackages/schema/src/v20170710/level-progressions.ts 100.00% <100.00%> (ø)
... and 36 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

bachmacintosh and others added 2 commits October 12, 2026 15:23
Test the core helpers that were previously only exercised by the generator scripts, which aren't measured for
coverage, along with error paths such as defineRevision() rejecting an invalid revision.

Also remove an unreachable branch from referencesOf(), and move findCycle() into analysis.ts as an export so its
handling of dependencies without their own entry can be tested directly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Aliases of CollectionParameters (e.g. ResetParameters) are generated as their own type (and schema) declarations
instead of `export { ... as ... }` re-exports, which makes them easier to document. Valibot and Zod modules with
aliases disable unicorn/prefer-export-from accordingly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bachmacintosh
bachmacintosh added this pull request to the merge queue Oct 12, 2026
@bachmacintosh bachmacintosh changed the title Experimental: Generated Types and Schemas Schema: Generated Types and Schemas Oct 12, 2026
@bachmacintosh bachmacintosh added the breaking change A breaking change that will require a major version bump label Oct 12, 2026
@bachmacintosh bachmacintosh changed the title Schema: Generated Types and Schemas BREAKING: Generated Types and Schemas Oct 12, 2026
Merged via the queue into v3 with commit e20ed24 Oct 12, 2026
8 checks passed
@bachmacintosh
bachmacintosh deleted the exp-generate branch October 12, 2026 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change A breaking change that will require a major version bump

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant