refactor: plugin hooks order#3913
Conversation
|
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 7c330bc 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
Mechanical refactor that centralizes plugin hook resolution behind PluginInstance.getHooks. Hook ordering and runtime semantics are preserved across all five processors and the symbol/instance utilities.
TL;DR — Replaces the repeated [plugin.config['~hooks']?.X, plugin.context.config.parser.hooks.X] pattern with a single plugin.getHooks(selector, ...customHooks) helper, then threads it through every processor and the symbol resolver. Net effect is less boilerplate without behavioral change.
Key changes
- Add
getHookstoPluginInstance— single entry point that returns a filtered array of[...customHooks, local, global]hooks, dropping undefined entries. - Migrate schema extractors —
pydantic/v2,@hey-api/typescript/v1,valibot/v1,zod/{mini,v3,v4}all swap their hand-rolled hook arrays forplugin.getHooks((hooks) => hooks.schemas?.shouldExtract). - Migrate symbol resolvers —
getSymbolExportFromFilePath,getSymbolFilePath, andbuildSymbolInnow usegetHooksand drop their inline null-guard loop. - Simplify boolean-or-call branch —
hook?.(ctx) ?? falsebecomeshook(ctx)sincegetHooksalready filters undefined; downstreamif (result)truthiness still folds booleanfalseandundefinedtogether.
Summary | 9 files | 1 commit | base: main ← refactor/plugin-hooks-order
Centralized hook resolution
Before: every processor inlined
[plugin.config['~hooks']?.schemas?.shouldExtract, plugin.context.config.parser.hooks.schemas?.shouldExtract]and each loop guardedhook?.(ctx) ?? false.
After:plugin.getHooks((hooks) => hooks.schemas?.shouldExtract)returns the filtered, ordered array; pydantic additionally passes its two built-in extractor predicates as varargs so they're prepended ahead of user hooks.
Ordering is [customHooks…, local (config['~hooks']), global (parser.hooks)], which matches every call site's previous order — pydantic kept its built-in object/enum predicates first, and every other processor's [local, global] ordering is preserved. The boolean-vs-function dispatch inside each extractor loop is unchanged.
instance.ts · symbol.ts · pydantic/v2/processor.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❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3913 +/- ##
==========================================
- Coverage 37.73% 37.70% -0.03%
==========================================
Files 582 582
Lines 20837 20844 +7
Branches 6066 6063 -3
==========================================
- Hits 7862 7860 -2
- Misses 10567 10570 +3
- Partials 2408 2414 +6
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.