Skip to content

Releases: zenstackhq/zenstack

ZenStack Release v2.6.1

23 Sep 18:48
6f30022

Choose a tag to compare

What's Changed

  • Fixed an issue that the policy filters/field-selections generated into polymorphic read are not always wrapped into correct relation layer #1734

Full Changelog: v2.6.0...v2.6.1

ZenStack Release v2.6.0

23 Sep 06:05
cb2e423

Choose a tag to compare

Security Fixes

This release fixed an important security issue related to polymorphic models.

Background

In a polymorphic model hierarchy, both the base and concrete models inherited from it can have access policies. When reading entities with a base model type, the corresponding concrete model fields are also fetched and returned. However, in this case, the access policies directly defined on the concrete models were not properly enforced in the previous releases, resulting in returning concrete model fields when they should have been excluded. This also happens to fields marked @omit on the concrete models.

The issue only happened when you read with a polymorphic base model (marked with @@delegate). When reading directly with a concrete model type, policies were correctly enforced.

This release fixed the issue. If a concrete model is not readable, its fields are not included, and only the base model's fields are returned. It's recommended that you upgrade ASAP if you're using the polymorphic models feature.

A big THANK YOU 🙏 to @svetch for reporting this issue!

New Features

  • Added a new option to "@core/zod" plugin to specify if the generated schemas should reject, strip, or passthrough fields not recognized #1696 Doc

    Example:

    plugin zod {
        provider = "@core/zod"
        mode = "strip"
    }

Fixes and Improvements

  • Fixed the issue that in certain cases concrete model fields are not returned in a polymorphic read #1698
  • Fixed ZModel type checker issue that fields from abstract base model cannot be accessed from future(). or this. #1695 #1713
  • Fix zod compilation issue when a @@delegate field has a default value #1693
  • Fixed the issue that using auth() in @default() is not effective for createMany and createManyAndReturn #1681
  • TRPC plugin now generates procedures that better conform to PrismaClient's typing: APIs like findMany, count, etc. now has optional parameter type #1707

Full Changelog: v2.5.1...v2.6.0

ZenStack Release v2.5.1

07 Sep 16:40
61b32cb

Choose a tag to compare

Fixed an unintended change that resulted in a "backLink" field change in model metadata for abstract models. Although I haven't observed any adverse behavior related to it, it's good to upgrade if you're already on v2.5.0.

ZenStack Release v2.5.0

07 Sep 01:51
8297c03

Choose a tag to compare

New Features

  • TRPC v11 support (preview) docs
  • Prisma Pulse support (preview) docs
  • New zenstack check CLI command for checking ZModel file for errors docs
  • The zenstack generate CLI command now allows you to include/exclude specific plugins. You can use it to exclude plugins like tanstack-query hooks generation during CI docs
  • Updated Prisma peer dependencies to 5.19.x

Security Fixes

  • Fixed the issue that "connect" operation can circumvent "update" policy check for foreign key fields when the operation is initiated from a polymorphic model #1674

    Special thanks to @eqqe for reporting this issue! The background is: when you use the "connect" operator to establish relations between entities, you need to have "update" permission on the entity that gets a foreign key update due to the "connect". However, this permission was not properly checked if the update is initiated from a polymorphic model in previous releases.

Fixes and Improvements

  • The @@validate data validation attribute is added with a new "path" parameter to indicate the path of the field that caused the error. Thanks @j0rdanba1n for proposing and implementing this! docs
  • Fixed inconsistent filtering/stripping behavior for field-level policies when findMany and count APIs #1644
  • Fixed the issue that polymorphic entities returned in a nested read don't contain fields from base #1645
  • Fixed the check() attribute function's compatibility with post-update policies #1642
  • Fixed post-update policy validation issue with deeply nested field access #1648
  • Replaced "decimal.js" dependency with the more lightweight "decimal.js-light" in @zenstackhq/runtime #1571
  • Fixed incorrect OpenAPI spec generated for the Meta section #1549
  • Fixed the code generation compilation errors when @core/enhance plugin is configured with a custom output directory #1667
  • Fixed @zenstackhq/runtime's compatibility issue with CloudFlare Workers. Please make sure you import enhance from @zenstackhq/runtime/edge when using edge runtime #1672.

New Contributors

Full Changelog: v2.4.1...v2.5.0

ZenStack Release v2.4.1

07 Aug 02:47
61e07d0

Choose a tag to compare

Fixes and Improvements

  • Prisma 5.18.0 support

ZenStack Release v2.4.0

06 Aug 04:51
b054f9f

Choose a tag to compare

Security Fixes

  • Added more reduction to the generated Prisma queries to workaround a Prisma bug (prisma/prisma#21856) that can potentially breach access control #1627

    The background is ZenStack internally uses { AND: [] } to represent constant true and { OR: [] } for constant false. However, Prisma provides inconsistent query results in certain nesting combinations. The fix introduced more query reduction logic to avoid generating such combinations.

    It's recommended that you upgrade ASAP after thorough testing.

Fixes and Improvements

  • RedwoodJS package "@zenstackhq/redwood" now supports Redwood V7 #1553. Special thanks to @ladderschool for identifying the related breaking changes!
  • REST-flavor API: support comma-separated multiple filter values #1573
  • Fixed false-positive validation errors when using polymorphic models with tRPC #1608
  • Fixed Zod schema compilation errors when outputting to a custom directory #1610
  • Fixed "@zenstackhq/swr" plugin build issues which can cause typescript typing errors with certain tsconfig settings
  • Consistently throw Prisma error types #1596
  • Removed createMany from input arg's typing for delegate models to avoid confusion #1577
  • Fixed an excessively strict Zod schema causing rejection during update #1563
  • Fixed the issue that explicitly providing a "@core/enhancer" plugin in ZModel causes data validation to be muted #1562
  • Fixed Prisma schema generation errors when @map is used on a foreign key field #1551
  • Fixed Prisma schema generation errors when very long model names are used

Full Changelog: v2.3.3...v2.4.0

Thanks to @irvinzz for helping with this release!

ZenStack Release v2.3.3

19 Jul 23:15
bf2acfd

Choose a tag to compare

What's Changed

  • Update Prisma dependencies to 5.17.x

Full Changelog: v2.3.2...v2.3.3

ZenStack Release v2.3.2

15 Jul 04:08
085bb52

Choose a tag to compare

What's Changed

  • Update superjson dependency

Full Changelog: v2.3.1...v2.3.2

ZenStack Release v2.3.1

15 Jul 03:14
5034fdc

Choose a tag to compare

What's Changed

  • Fixed incorrect prisma query executed when count uses a where filter involving a polymorphic base field #1585
  • Fixed over-strict typing generated for auth() access #1589
  • Fixed compatibility issue between createManyAndReturn and polymorphism #1576
  • Fixed the issue that field-level override rules don't work with non-optional to-one relations #1574

Full Changelog: v2.3.0...v2.3.1

ZenStack Release v2.3.0

12 Jul 17:43
e40779e

Choose a tag to compare

New Features

  • The new check() policy function that allows you to delegate a models' permission checking to its relations. #276

    model Todo {
        ...
        list List @relation(fields: [listId], references: [id])
    
        // if the parent list is readable, grant full access to this Todo entity
        @@allow('all', check(list, 'read'))
    }

    You can use this feature to remove duplicated policy rules and keep the schema DRY. See a full guide here.

  • Prisma 5.16.x is now supported. The new Prisma version introduced a typing breaking change. An adaptation is added in this version of ZenStack.

Documentation

Fixes and Improvements

  • Runtime error with disconnecting a self-relation #1530
  • Incorrect query result when using Prisma.DbNull to filter JSON fields #1533
  • Fixed the issue that using @length on a @password field checks the length of hash password rather than the original value #1502
  • Typing conflict with Prisma client extension (with polymorphism or auth() in @default() is used) #1493
  • IDE formatting issue when Unsupported type is used #1517
  • Runtime error when creating a polymorphic model that inherits from an abstract model #1560
  • Set timeout for checking newer versions when running CLI to avoid hangs under unstable network #1529
  • Typing issue in generated hooks for vue-query #1564
  • Excluded create and upsert for delegate models from generated hooks and trpc routers, as they cannot be directly created.
  • When generation @relation for delegate models, user-provided relation name should be used if it exists #1575 by @irvinzz
  • SWR is now added as a peer dependency of @zenstackhq/swr plugin.
  • The ZenStack monorepo has enabled corepack to enforce a consistent version of pnpm.

New Contributors

Thanks to @jasonmacdonald @benjamintd @irvinzz @mentorkadriu for contributing to this release! ❤️

Full Changelog: v2.2.4...v2.3.0