mirror of
https://github.com/zenstackhq/zenstack
synced 2026-05-24 10:08:55 +00:00
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>
|
||
|---|---|---|
| .. | ||
| src | ||
| test | ||
| .gitignore | ||
| eslint.config.js | ||
| package.json | ||
| tsconfig.general.json | ||
| tsconfig.json | ||
| tsconfig.svelte.json | ||
| tsconfig.test.json | ||
| vitest.config.ts | ||