zenstack/packages/clients/tanstack-query
ymc9 2c6aa2383a feat(fetch-client): add @zenstackhq/fetch-client package
A simple fetch-based, non-reactive client library that consumes the
RPC-style auto CRUD API.

- Per-model CRUD operations (`findUnique`, `findMany`, `create`, etc.)
  derived from the ORM's `AllModelOperations`, with slicing applied via
  a key-filter mapped type that preserves per-call generic narrowing.
- `findUniqueOrThrow` / `findFirstOrThrow` raise a typed `CrudError`
  with `code: CrudErrorCode.NotFound` and the offending model name.
- Sequential transactions via `client.\$transaction([...])` accepting an
  array of typed `{ model, op, args }` operations; result tuple is
  typed per-position via `TransactionResults`.
- Custom procedures exposed under `client.\$procs` with `query` /
  `mutate` based on the procedure shape.
- Endpoint is required and validated as a fully qualified URL.
- Threads `ExtQueryArgs` and `ExtResult` through model ops and
  transactions so plugin-extended query args / result fields are
  reflected in user-facing types.

Refactors:
- Move `TransactionOperation` / `TransactionResults` types and the
  `CUSTOM_PROC_ROUTE_NAME` / `TRANSACTION_ROUTE_PREFIX` constants into
  `@zenstackhq/client-helpers` so both clients can share them.
- Move the `DEFAULT_QUERY_ENDPOINT` constant to tanstack-query (where
  it belongs).

Tests: 47 runtime tests + 13 type-level tests covering CRUD ops, HTTP
methods, SuperJSON serialization, error handling, transactions, slicing,
ExtQueryArgs, and ExtResult propagation. Test schemas use real ZModel
files generated via the existing `scripts/test-generate.ts`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-05 22:56:08 -07:00
..
src feat(fetch-client): add @zenstackhq/fetch-client package 2026-05-05 22:56:08 -07:00
test refactor(tanstack-query, orm): thread plugin generics through transactions (#2645) 2026-05-05 10:56:06 -07:00
.gitignore refactor: extract client-helpers package, update svelte-query to v6 (#535) 2025-12-27 22:49:19 +08:00
eslint.config.js feat(tanstack-query): new implementation of tanstack-query react hooks (#356) 2025-11-02 23:14:11 -08:00
package.json refactor(tanstack-query, orm): thread plugin generics through transactions (#2645) 2026-05-05 10:56:06 -07:00
tsconfig.general.json chore: migrate from tsup to tsdown (#2580) 2026-04-15 12:13:34 -07:00
tsconfig.json refactor: extract client-helpers package, update svelte-query to v6 (#535) 2025-12-27 22:49:19 +08:00
tsconfig.svelte.json chore: migrate from tsup to tsdown (#2580) 2026-04-15 12:13:34 -07:00
tsconfig.test.json chore: migrate from tsup to tsdown (#2580) 2026-04-15 12:13:34 -07:00
vitest.config.ts feat: ORM api slicing (#2383) 2026-02-18 07:45:04 -08:00