refactor: resolver node type#3907
Conversation
|
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 3aabff2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
There was a problem hiding this comment.
Note
Type-only refactor. Structural shape of every resolver context is unchanged, so existing call sites that construct { nodes: { ... } } continue to satisfy the new interface inheritance without modification.
TL;DR — Extracts the duplicated nodes property from every *ResolverContext interface into a shared Plugin.ResolverNodes<T> wrapper exported from @hey-api/shared, so each resolver context now extends BaseContext, Plugin.ResolverNodes<{ ... }> instead of redeclaring the property inline.
Key changes
- Add
Plugin.ResolverNodes<T>to the sharedPluginnamespace — single source of truth for thenodesshape used by validator/type/faker/pydantic resolvers, including the centralized JSDoc. - Convert resolver contexts to interface extension —
pydantic,@hey-api/typescript,@faker-js/faker,valibot, andzodresolver context interfaces drop their inlinenodes: { ... }in favor ofPlugin.ResolverNodes<{ ... }>. - Changeset — patch bump on
@hey-api/sharednoting the new export.
Summary | 7 files | 1 commit | base: main ← refactor/types-resolver-nodes
Centralized nodes shape via Plugin.ResolverNodes<T>
Before: Every
*ResolverContextredeclarednodes: { ... }inline with its own copy of the"Nodes used to build different parts of the result."JSDoc.
After:Plugin.ResolverNodes<T>carries thenodes: Tfield and its doc comment once; contexts express the shape by extending it.
Per-node JSDoc (Returns the base ..., Returns the literal type for const values., etc.) is preserved on each entry of the T map. Runtime semantics are unchanged — the produced type is structurally identical to the previous inline form, so consumers in */v{1,2,3,4}/toAst/*.ts and api.ts that build context objects with a nodes field continue to type-check without edits.
packages/shared/src/plugins/types.ts · packages/openapi-ts/src/plugins/zod/resolvers.ts · packages/openapi-ts/src/plugins/valibot/resolvers.ts · packages/openapi-python/src/plugins/pydantic/resolvers.ts
Claude Opus | 𝕏
@hey-api/codegen-core
@hey-api/json-schema-ref-parser
@hey-api/nuxt
@hey-api/openapi-ts
@hey-api/shared
@hey-api/spec-types
@hey-api/types
@hey-api/vite-plugin
commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3907 +/- ##
=======================================
Coverage 37.73% 37.73%
=======================================
Files 582 582
Lines 20837 20837
Branches 6059 6066 +7
=======================================
Hits 7862 7862
Misses 10567 10567
Partials 2408 2408
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|

No description provided.