Skip to content

Releases: zenstackhq/zenstack

ZenStack Release v2.22.3

06 Jun 18:26
48221b2

Choose a tag to compare

What's Changed

  • Several npm audit updates for v2.

Full Changelog: v2.22.2...v2.22.3

ZenStack Release v3.7.2

31 May 03:03
55d7bc2

Choose a tag to compare

What's Changed

  • [orm] Added @phone validation attribute by @sanny-io.
  • [zod] Fixed incorrect input type inferred from the derived schemas by @sanny-io #2673

Full Changelog: v3.7.1...v3.7.2

ZenStack Release v3.7.1

24 May 01:53
b15bdfd

Choose a tag to compare

What's Changed

  • [orm] You can now use the @@delegateMap attribute to control the value used for discriminator field values in polymorphic models by @wolflu05 doc.
  • [orm] Fixed an invalid Prisma schema generation issue when using ID formatting by @sanny-io

Full Changelog: v3.7.0...v3.7.1

ZenStack Release v3.7.0

14 May 21:04
ed01275

Choose a tag to compare

New Features

Several cool additions landed in this release 🥳 !

Full-Text Search (Postgres Only)

You can now use the fts and _ftsRelevance query fields to do full-text queries against Postgres database doc. Mark fields you want to search with the @fullText attribute and enjoy effortless queries.

model Article {
  id       Int     @id @default(autoincrement())
  title    String  @fullText
  body     String  @fullText
  subtitle String? @fullText
  notes    String? // not full-text-searchable
}
await db.article.findMany({
  where: { title: { fts: { search: 'cat & dog' } } },
});

await db.article.findMany({
  orderBy: {
    _ftsRelevance: { fields: ['body'], search: 'cat & dog', sort: 'desc' },
  },
});

Fuzzy Search (Postgres Only)

You can now use the fuzzy and _fuzzyRelevance query fields to do fuzzy search against Postgres database doc. Mark fields you want to search with the @fuzzy attribute and enjoy effortless queries. This feature requires the pg_trgm extension. Read the docs for more details.

This awesome feature is contributed by @docloulou .

model Flavor {
  id          Int     @id @default(autoincrement())
  name        String? @fuzzy
  description String  @fuzzy
  notes       String? // not fuzzy-searchable
}
await db.flavor.findMany({
  where: { name: { fuzzy: { search: 'Aple' } } },
});

await db.flavor.findMany({
  orderBy: {
    _fuzzyRelevance: { fields: ['name'], search: 'Apple', sort: 'desc' },
  },
});

Fetch-Based API Client

A new @zenstackhq/fetch-client package is added to provide a simple fetch-based client for consuming the automated CRUD services (RPC-style only). Think of it as the sibling of the @zenstackhq/tanstack-query package, but without framework dependency and complexity of reactive state management. Ideal when you just need a simple, promise-based client. doc

import { createClient } from '@zenstackhq/fetch-client';
import { schema } from '~/zenstack/schema-lite';

const client = createClient(schema, {
  endpoint: 'https://example.com/api/model',
});

const users = await client.user.findMany({ include: { posts: true } });
const post = await client.post.create({ data: { title: 'Hello' } });

TanStack Query Sequential Transactions

You can now use the $transaction.useSequential hook to execute sequential transactions from the frontend doc.

const client = useClientQueries(schema);
const tx = client.$transaction.useSequential();

function onSubmit() {
  tx.mutate([
    { model: 'User', op: 'create', args: { data: { email: 'foo@bar.com' } } },
    { model: 'Post', op: 'create', args: { data: { title: 'Hello' } } },
  ]);
}

Kysely Version Bumped to v0.29.x

We've bumped Kysely dependency version to its latest. Please note that the new version appears to be ESM-only. Please double-check compatibility after the upgrade.

Fixes and Improvements

  • [tanstack-query] You can now use DbNull/JsonNull/AnyNull to filter JSON fields with the query hooks doc
  • [zod] Fixed a JSON field typing inconsistency between zod schemas and ORM types by @Azzerty23 #2639
  • [orm] Fixed several issues related to using @db.Time/@db.TimeZ fields by @erwan-joly #2633 #2631
  • [orm] Fixed an infinite recursion issue when validating cyclic strongly-typed JSON #2654
  • [better-auth] Fixed adapter loading issues when targeting CJS #2646
  • [policy] Fixed policy plugin detection issue with certain bundlers by @Albatrosso #2662
  • [cli] Fixed db pull issue with multiple FK fields targeting the same model by @svetch
  • Upgraded to TypeScript 6

Full Changelog: v3.6.4...v3.7.0


Welcome @docloulou and @Albatrosso as our new contributors ❤️ !

ZenStack Release v3.6.4

28 Apr 03:35
d30ebad

Choose a tag to compare

What's Changed

  • [better-auth] Proper support for array-typed fields by @pkudinov #2615
  • [policy] Fixed false-positive policy rejection for "create" when rules involve fields from delegate base models #2620

Full Changelog: v3.6.3...v3.6.4

ZenStack Release v3.6.3

25 Apr 14:58
8609d5b

Choose a tag to compare

What's Changed

  • [policy] Use EXISTS instead of COUNT/SUM for policy evaluation for improved performance.
  • [better-auth] Lazy-load schema generator to avoid crashing in edge-like runtime environments #2610

Full Changelog: v3.6.2...v3.6.3

ZenStack Release v3.6.2

23 Apr 00:51
09ca875

Choose a tag to compare

What's Changed

  • [server] Fixed Nuxt typing issue by adding h3 as a peer dependency by @genu #2601.
  • [policy] Fixed invalid SQL when evaluating post-update policies involving fields defined in delegate base models #2595.
  • [orm] Fixed wrong postgres schema usage when querying many-to-many join tables #2603.

Full Changelog: v3.6.1...v3.6.2

ZenStack Release v3.6.1

22 Apr 02:44
14e1d55

Choose a tag to compare

What's Changed

  • [cli] Added a "--random-prisma-schema-name" option to "zen db push" and "zen migrate *" commands to allow running these commands in parallel without conflict by @jesus-gomez-aetonix #2491
  • [orm] Accept plain date strings for mutation input and filter by @lsmith77

New Contributors

Full Changelog: v3.6.0...v3.6.1

ZenStack Release v3.6.0

21 Apr 01:52
31f4c49

Choose a tag to compare

New Features

  • OpenAPI specification generation for RPC-style API doc.
  • Zod schema creation now allows you to control what fields to include/exclude and fields' optionality via options by @marcsigmund doc.
  • Custom types (type declarations) now allow relation fields. You can now declare relations on mixins and share them among models doc.

Breaking Changes

The makeModelSchema API from @zenstackhq/zod package now by default excludes all relation fields.

Improvements and Fixes

  • [orm] Fixed incorrect SQL generation when computed fields are defined on mixins #2540 by @lsmith77.
  • [orm] Improve query performance by using EXISTS instead of COUNT when including to-one relations by @evgenovalov #2578.
  • [orm] Fixed a SQL generation issue when cursor is used with fields inherited from delegate models by @genu #2588.
  • [orm] Fixed the issue that fields annotated with @db.Time are returned as string instead of Date object by @erwan-joly #2589.
  • MySQL support is now graduated from preview to GA.
  • Updated Kysely to its latest version.
  • Migrated bundler from tsup to tsdown.
  • Updated pnpm to its latest version.

New Contributors

Welcome @evgenovalov, @17, and @erwan-joly as our new contributors ❤️ !

Full Changelog: v3.5.6...v3.6.0

ZenStack Release v3.5.6

07 Apr 16:47
39a0a28

Choose a tag to compare

What's Changed

  • [orm] Fixed postgres issue that "distinct" and "orderBy" used together can cause errors #2529
  • [orm] Improved input validation to reject "orderBy" object with multiple keys
  • [tanstack] Fixed typing issue with useInfiniteFindMany query by @motopods #2426

Full Changelog: v3.5.5...v3.5.6