Skip to content

Releases: zenstackhq/zenstack

ZenStack Release v2.11.0

07 Jan 15:39
70a81c6
Compare
Choose a tag to compare

🥳 Happy New Year 🥳

Wish you all enjoyed the holidays and are having a great start of 2025!

New Features

  • Field encryption 🔑

    Thanks @genu for implementing this much-desired (preview) feature! This feature allows you to mark fields with the @encrypted attribute and create an enhanced PrismaClient that transparently encrypt/decrypt the field values. See how to use it here.

  • New attribute functions for access policies:

    • currentModel(): return the name of the model for which the policy rule is defined.
    • currentOperation(): return the operation for which the policy rule is defined for.

    These functions are handy for implementing fine-grained RBAC where users are assigned permissions for specific resources and operations. E.g.:

    model Resource {
        ...
        owner User @relation(...)
        @@allow('all', 
            owner.roles?[
                permissions?[resource == currentModel() && action == currentOperation()
        ]])
    }

Fixes and Improvements

  • [openapi] generate "id" field type according to its declared type in ZModel #1908
  • [zmodel] check for cyclic model inheritance and report errors
  • [delegate] fixed incorrect injection when check() function is used with delegate models #1930
  • [delegate] fixed errors when selecting "_count" of relation fields defined in delegate base models #1467
  • [rest-api] return an empty object response with status 200 for "DELETE" route #1668
  • [delegate] don't inherit @@schema attribute from base if the attribute is already defined in a sub model #1647

Full Changelog: v2.10.2...v2.11.0

ZenStack Release v2.10.2

18 Dec 13:50
689d013
Compare
Choose a tag to compare

What's Changed

  • Prisma 6.1 support

Full Changelog: v2.10.1...v2.10.2

ZenStack Release v2.10.1

13 Dec 03:20
f7f85ea
Compare
Choose a tag to compare

What's Changed

  • Preserve custom attributes as comments in the generated logical prisma schema #1909
  • Fixed a typing compatibility issue with the latest Zod

Full Changelog: v2.10.0...v2.10.1

ZenStack Release v2.10.0

05 Dec 08:14
7cc5f00
Compare
Choose a tag to compare

What's Changed

  • Prisma 6.0 support
  • TanStack Query query cancellation support doc #1872
  • Allow Unsupported fields in @@index #1870
  • Removed ZenStack version number from generated TS source files to avoid unnecessary file updates when upgrading ZenStack
  • Fixed a typing regression that incorrectly requires a foreign key field when creating a polymorphic model #1894
  • Fixed a regression in OpenAPI generation that foreign keys with default values are incorrectly marked as required in Create payload #1893
  • Fixed zenstack init command to install the maximum supported Prisma version instead of "latest" #1905

Full Changelog: v2.9.4...v2.10.0

ZenStack Release v2.9.4

27 Nov 12:16
251c699
Compare
Choose a tag to compare

What's Changed

  • RESTful API handler now supports upsert operation by @thomassnielsen doc
  • Fixed inconsistency between OpenAPI specification and REStful API handler by @thomassnielsen

Full Changelog: v2.9.3...v2.9.4

ZenStack Release v2.9.3

26 Nov 01:11
f5e4e7c
Compare
Choose a tag to compare

What's Changed

  • Fixed hooks null reference error when optimistically updating nested queries involving null relationships by @roomman #1878
  • Proper IDE semantic highlighting and formatting for type declarations

New Contributors

Welcome @roomman as our new contributor ❤️ !

Full Changelog: v2.9.2...v2.9.3

ZenStack Release v2.9.2

22 Nov 20:09
efe65ec
Compare
Choose a tag to compare

What's Changed

  • Refixed CLI "generate" warnings in PNPM monorepos #1875
  • Properly handling model fields marked "@ignore" in the entire tool chain

Full Changelog: v2.9.1...v2.9.2

ZenStack Release v2.9.1

19 Nov 17:10
38530b8
Compare
Choose a tag to compare

What's Changed

  • Fixed a CLI warning when generating in a pnpm workspace with custom prisma client output settings #1875

Full Changelog: v2.9.0...v2.9.1

ZenStack Release v2.9.0

18 Nov 22:43
76c6579
Compare
Choose a tag to compare

New Features

1. Using "type" to define the shape of auth()

In previous versions, the auth() call in ZModel must be resolved to a User model or a model marked @@auth. However, when using auth-as-a-service products like Clerk, you can choose not to store user data in the database. This release allows you to define the auth model as a type. E.g.:

type User {
  id String
  ...
}

Or

type Auth {
  id String
  @@auth
}

2. Portable mode for TanStack Query hooks

The @zenstackhq/tanstack-query plugin has a new "portable" option to make the generated code's typing "self-contained". When enabled, PrismaClient's types will be included with the generated code. It's useful when you output the hooks code into a separate project where Prisma/ZenStack is not referenced. Please note that the "@zenstackhq/tanstack-query" package still needs to be referenced in the target project. doc

plugin hooks {
  provider = '@zenstackhq/tanstack-query'
  output = "../client/src/lib/hooks"
  target = "react"
  portable = true
}

3. Reducing the size of generated OpenAPI spec

When using the @zenstackhq/openapi plugin to generate API spec for the "rpc" flavor, the result can be huge due to how Prisma allows flexible structures of query and mutation input. This release introduced a omitInputDetails option to generate the specification with lower fidelity. When the option is turned on, fields in the query/mutation input like where, select, data, etc. will be generated as generic objects. doc

plugin openapi {
  provider = '@zenstackhq/openapi'
  flavor = 'rpc'
  omitInputDetails = true
  ...
}

Fixes and Improvements

  • TanStack Query and SWR hooks now handle nested read data during optimistic updates #1840
  • Prisma client extensions now work consistently regardless the order you call enhance and $extends
  • Generated TS code now includes // @ts-nocheck to suppress tsc warnings by @genu
  • Fixed the issue that unreferenced enums in ZModel cause generation errors #1835
  • Fixed compatibility issues with turborepo #1687
  • Fixed ZModel validation error when importing enums from a separate schema file #1849
  • Fixed runtime error when creating delegate model entities with foreign key fields with default values #1843
  • Include null into a type's field if the field is optional #1857
  • Fixed code generation issue when a type is recursive #1868
  • Using @@validate inside type declarations is now supported
  • Fixed OpenAPI generation to exclude foreign key fields from mutation payload by @thomassnielsen

New Contributors

  • Welcome @genu as our new contributor! ❤️

Full Changelog: v2.8.1...v2.9.0

ZenStack Release v2.8.1

07 Nov 20:25
d2554f2
Compare
Choose a tag to compare

What's Changed

  • Fixed incorrect validation errors when using typed JSON fields in a multi-file schema setup #1833
  • Support using enums as type declaration fields #1834

Full Changelog: v2.8.0...v2.8.1