Skip to content

feat: add computed fields support via ExtResult#64

Open
genu wants to merge 6 commits intomasterfrom
genu/computed-fields-support
Open

feat: add computed fields support via ExtResult#64
genu wants to merge 6 commits intomasterfrom
genu/computed-fields-support

Conversation

@genu
Copy link
Owner

@genu genu commented Mar 17, 2026

Summary

  • Computed fields (ExtResult): Thread ExtResult type parameter through all hook signatures. Users can pass a ClientContract type (e.g. typeof db) to useClientQueries to get type-safe computed fields in query/mutation results.
  • Slicing support: Replace TrimDelegateModelOperations with TrimSlicedOperations, use GetSlicedModels and GetSlicedProcedures to respect client-level model/operation/procedure slicing via QueryOptions.
  • Options passthrough: Pass Options to all Args types (ExistsArgs, CountArgs, AggregateArgs, GroupByArgs, UpdateManyArgs, DeleteManyArgs) for filter slicing support.
  • All changes are backwards compatible — new generics default to {}.

Test plan

  • Verify type tests pass after @zenstackhq/orm is updated to the version with ExtResult support
  • Verify slicing type tests pass (model filtering, operation filtering, procedure filtering)
  • Verify existing type tests continue to pass (no regressions)

🤖 Generated with Claude Code

genu added 6 commits March 17, 2026 08:14
Threads ExtResult generic through all hook signatures to support ZenStack
plugins that define computed fields. Users can now pass a ClientContract
type to useClientQueries to get fully-typed computed fields in results.

Backwards compatible - existing code without ExtResult continues to work.
Replace TrimDelegateModelOperations with TrimSlicedOperations to support
client-level model/operation/procedure slicing via QueryOptions. Pass
Options through to all Args types for filter slicing support.
…ent-helpers

Replace local type definitions with shared utilities from
@zenstackhq/client-helpers. Collapse useClientQueries to a single Client
generic - Schema, Options, and ExtResult are all inferred automatically.
Slicing tests now use ClientContract types to embed options.
…Client

Hooks are not subject to result extension — pass {} directly instead of
threading ExtResult through ClientHooks, ModelQueryHooks, and
ModelMutationModelResult. Matches upstream TanStack Query refactor.
The previous commit over-removed ExtResult from all hooks. Model hooks
need ExtResult for plugin-computed field support. Procedure hooks don't
have computed fields, so they correctly use {}.

Matches upstream TanStack Query fix (zenstackhq/zenstack@d5aead0).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant