zenstack/packages/schema
ymc9 8f70f17d94 feat(orm): add field-level @fuzzy attribute to gate fuzzy search
Adds a new ZModel field-level `@fuzzy` attribute that opts a `String` field
into fuzzy search. Without `@fuzzy`, the `fuzzy` filter operator and
`_fuzzyRelevance` orderBy are unavailable both at the type level and at runtime.

- Language: declare `@fuzzy` in stdlib (StringField only, @@@once)
- Validator: enforce postgres-only via shared `getDataSourceProvider` helper
- Schema: surface `fuzzy?: boolean` on `FieldDef`; generator emits it
- ORM types: gate `fuzzy:` filter and `_fuzzyRelevance.fields` to opted-in fields
- Zod factory: thread `withFuzzy` through string filter; filter `_fuzzyRelevance` enum
- Runtime: throw `InvalidInputError` when fuzzy is used on non-`@fuzzy` fields
- Tests: dedicated `fuzzy-search` test schema; validator coverage for postgres/sqlite/mysql/non-String

Breaking: existing schemas using fuzzy search must annotate fields with
`@fuzzy` to retain access. Fuzzy search shipped only one PR ago (#2573).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-03 20:45:40 -07:00
..
src feat(orm): add field-level @fuzzy attribute to gate fuzzy search 2026-05-03 20:45:40 -07:00
test feat: creating zod schemas for zmodel constructs and ORM query input validations (#2389) 2026-02-20 06:31:00 -08:00
eslint.config.js refactor: extract a runtime schema package (#350) 2025-11-02 09:23:58 -08:00
package.json [CI] Bump version 3.6.4 (#2624) 2026-04-27 17:50:05 -07:00
README.md docs: add README.md to all public packages 2026-03-22 21:51:13 -07:00
tsconfig.json refactor: extract a runtime schema package (#350) 2025-11-02 09:23:58 -08:00
tsdown.config.ts chore: migrate from tsup to tsdown (#2580) 2026-04-15 12:13:34 -07:00
vitest.config.ts feat: creating zod schemas for zmodel constructs and ORM query input validations (#2389) 2026-02-20 06:31:00 -08:00

@zenstackhq/schema

Runtime schema representation for ZenStack. Defines the TypeScript types and accessor utilities for the compiled schema that zenstack generate produces from ZModel files. This schema object describes models, fields, relations, expressions, and other metadata used by packages like @zenstackhq/orm and @zenstackhq/server at runtime.

Installation

npm install @zenstackhq/schema