Releases: zenstackhq/zenstack
ZenStack Release v1.0.0-beta.10
Features and Improvements
- Prisma V5 is supported! #581
- ZModel now supports database views (read-only, updatable views are not supported). #258
- Instead of rejecting the query, enhanced clients now set field to
nullif a nested optional to-one relation is requested but not readable. #586 - API layer (both RESTful and RPC-style) always use superjson for serialization. More details: RESTful RPC.
- Fixed OpenAPI plugin issue with
Bytestype. #573 - Fixed issue with incorrect path generated on Windows environments #582
- Stricter type checking for binary expressions in ZModel #292
Breaking Changes
- The RPC-style API handler now wraps the query result into a "data" field. In addition, there can be a "meta" field in the response body containing serialization metadata. Please find more details here: https://zenstack.dev/docs/reference/server-adapters/api-handlers/rpc.
Full Changelog: v1.0.0-beta.8...v1.0.0-beta.10
ZenStack Release v1.0.0-beta.8
Fixes and Improvements
- New option for ExpressJS server adapter to control whether the middleware should send a response or just compute it. Docs. #531
- Fixed invalid Prisma query generated when doing nested update for models with multiple ID fields #552
- Allow to use a custom
fetchfunction when using SWR and TanStack Query hooks #542 #541 - Removed unnecessary peer dependencies to Prisma which caused Zod compilation issues when using pnpm #560
- Add type annotation to generated zod schemas to make
tschappy in pnpm workspace environment - Add "interactiveTransactions" preview features flag when a low Prisma version (< 4.7.0) is detected #508
- Fixed problem that "_count" selection in find queries are not subject to "read" policy filtering
Breaking Changes
- When connecting two models (with
create,update, etc. calls) with implicit many-to-many relationship, previously ZenStack didn't check if the model being connected passes "update" check. This is now tightened up. Please note that this only affects implicit many-to-many relationships.
Thanks @chemitaxis for the continuous contribution! 🙏🏻
Full Changelog: v1.0.0-beta.3...v1.0.0-beta.7
ZenStack Release v1.0.0-beta.3
New Features
-
[TRPC plugin] Improved typing for the generated routers #409
The plugin can now generate extra helpers for improve typing of the trpc client side, so calling the CRUD routers now has the same experience as calling Prisma methods. E.g.:const post = trpc.post.findFirst({ include: { author: true } });
The code above used to have a static typing of
Post, although at runtime the data contains anauthorfield. After applying the typing helper, the result is typed asPost & { author: User }.More details here: https://zenstack.dev/docs/reference/plugins/trpc#client-helpers
-
[Data Validation] Model-level validation rules #477
A new model-level attribute
@@validateis introduced to express more complex data validation rules. You can use it to write rules that involve multiple fields and combine boolean expressions. A set of validation functions are also added to support various kinds of field validation in a complex rule.model Model { x Int y String @@validate(x > 0 && contains(y, 'foo'), 'my custom condition') }
Field-level validation attributes (like
@email, etc.) are also extended with an optional error message parameter.More details here: https://zenstack.dev/docs/reference/zmodel-language#model-level-validation-attributes
-
[Zod Plugin] Generates zod schema for models, including validation rules #477
In previous versions,
@core/zodplugin only generated schemas for Prisma's CRUD input. It's got a renovation in this release and now generates three kinds of schemas:- models:
Schemas for models, including flavors for full validation, create, and update. Data validation rules are included. - input:
Schemas for Prisma CRUD method input. This is used by the trpc plugin to validate router input. - objects:
Schemas for objects used by the "input" schemas. You usually don't need to use this.
By default, the generated zod schemas are reexported through
@zenstackhq/runtime/zodand can be directly imported and used.Error messages attached to validation rules are now carried over to the generated zod schemas. E.g.:
email String @email('must be a valid email')is transformed toz.string().email('must be a valid email').Model-level validation rules written with
@@validateare also supported and are transformed toz.refine. E.g.,@@validate(x > 0 && contains(y, 'foo'))is transformed toz.object({...}).refine((value) => value.x > 0 && value.y?.includes('foo')). - models:
Fixes and Improvements
- Fixed the bug that SWR hooks call into wrong endpoint
- tRPC plugin generated routers now support unchecked input types #499
- Fixed incorrect policy code generation when a single boolean field is used as policy expression #509
- Fixed issue about wrong reference resolution when there're enum fields with the same name #498
- Fixed parser error when
trueorfalseare used as declaration name prefix #522 - The REST API handler now returns the total count in the
metasection for collection queries by @chemitaxis #527 - Added contribution guide
New Contributors
Welcome @chemitaxis to the contributor family!
Full Changelog: v1.0.0-beta.1...v1.0.0-beta.3
ZenStack Release v1.0.0-beta.1
New Features
- Next.js server adapter now supports the new "app directory" routes of V13
Improvements and Fixes
- Support
now()function in access policy rules #478 - Added missing parameters to
@db.Decimalattribute - Fixed wrong resource link in rest API handler #469
- Added
generateModelActionsconfig options to trpc plugin to control what CRUD actions to generate #460 - Improve error stack trace in proxied prisma methods #384
- Add option to log queries sent to Prisma:
logPrismaQuery - Put fields in base model on the top in generated Prisma schema
- Add
prisma generateerror output to telemetry for future improvements
Breaking Changes
- Signature change for the "enhancement" APIs (
withPresets,withPolicy,withPassword,withOmit): grouped extra parameters into anoptionsbag
New Contributors
- @Azzerty23 made their first contribution in #461
Full Changelog: v1.0.0-alpha.119...v1.0.0-beta.1
ZenStack Release v1.0.0-alpha.119
New Features
-
Server API handler for RESTful style API
Now ZenStack supports two styles of APIs: RPC (mirroring PrismaClient's query APIs) and RESTful (resource-centric API using JSON:API as transportation). When creating a server adapter, you can choose to use one of these handlers (defaults to RPC). Check out the documentation for more details.
A big ❤️THANK YOU❤️ to @jawadst for initiating this effort and contributing code!
-
OpenAPI specification generation for RESTful style API
Related to the previous feature, the
@zenstackhq/openapiplugin is also updated to support RESTful style API. -
Server adapter for SvelteKit
The
@zenstackhq/server/sveltekitmodule implements a SvelteKit server hook to provide an automatic RPC or RESTful style CRUD API. Check out the sample project here. -
New plugins:
@zenstackhq/swrand@zenstackhq/tanstack-queryThese plugins generate client hooks targeting SWR and TanStack Query. The original
@zenstackhq/reactplugin will be deprecated in the future and replaced by these two new plugins. SWR plugin is for React only, and TanStack Query plugin supports React and Svelte today and will support Vue in the future.Sample projects:
Fixes And Improvements
- Next.js server adapter is moved to
@zenstackhq/serverpackage. The original@zenstackhq/nextpackage will be deprecated soon. - Upgraded to Langium 1.2.0
- OpenAPI: component schema should be generated even if the model is marked as "@@openapi.ignore" #349
- Don't generate auxiliary fields when a model doesn't have any access policy #415
- ZModel: added supports to directUrl field in datasource declaration. This can be used to provide a separate database connection (usually without pooling) for migration.
Breaking Changes
- Plugin's output path handling is unified to be relative to the location of ZModel file. This wasn't implemented consistently previously. If you had ZModel residing in a non-root folder, you may need to adjust plugin output paths accordingly.
We're aiming to hit Beta for the next release!
Full Changelog: v1.0.0-alpha.114...v1.0.0-alpha.119
ZenStack Release v1.0.0-alpha.114
What's Changed
- Performance: avoid additional policy-checking db query when policy rules don't involve model fields
- Better VSCode formatting for ZModel files
- Better formatting for the generated
schema.prismafile - Allow more keywords to be used as declaration names #391
- Fixed the problem that zenstack auxiliary fields are not stripped from nested entities #386
- Added missing attribute parameters for "@@index", "@@unique" and "@@id" #390
- Fixed wrong validation error when relation foreign key is marked as "@id" instead of "@unique" #392
- Fixed deprecated import warning from "@prisma/client/runtime" package #312
Special thanks to @he-la, @potion-cellar, and @sidharthv96 for reporting multiple issues!
Full Changelog: v1.0.0-alpha.111...v1.0.0-alpha.114
ZenStack Release v1.0.0-alpha.111
New features
- Multi-schema file support
- Abstract model support
- Added support for Prisma's "Unsupported" types
- More flexible filter expressions in access policies #364
Improvements
- Better cli reporting of missing/invalid config file (by @potion-cellar)
- CLI execution speed is improved by roughly 30% - 40%
- Improved runtime performance by removing verbose log
- Zod plugin now generates an
index.tsto reexport all schema objects #361 - Fixed deprecated cuid dependency
- Fixed zod typing for DateTime field (by @Xemah)
- Test environment cleanup
Full Changelog: v1.0.0-alpha.102...v1.0.0-alpha.110
ZenStack Release v1.0.0-alpha.102
What's Changed
- Fixed wrongly generated types for the
groupByandcounthooks from the@zenstackhq/reactplugin - Fixed CLI checking for plugin setting fields when object syntax is used (reported by @Azzerty23)
Full Changelog: v1.0.0-alpha.99...v1.0.0-alpha.102
ZenStack Release v1.0.0-alpha.99
What's Changed
- Fixed VSCode extension error triggered by highlighting content when ZModel contains parse errors
- Fixed test environment compatibility with Win32 (by @potion-cellar )
- Added CLI config file support (see here for details)
- Added security scheme support and a few other configurations for
@zenstackhq/openapiplugin - Fixed the issue that VSCode extension reports errors for
@@openapi.metaattribute - Improved
@zenstackhq/trpcplugin to wrap Prisma errors into proper trpc errors
Special thanks to @potion-cellar, @Azzerty23, and @jawadst for filing several issues.
Full Changelog: v1.0.0-alpha.98...v1.0.0-alpha.99
ZenStack Release v1.0.0-alpha.98
What's Changed
- More robust url and payload handling in OpenAPI services (by @potion-cellar)
- Allow to customize OpenAPI specification version (with the "specVersion" option in plugin, defaults to "3.1.0")
- Added support to use @tanstack/react-query as data fetcher for "react" plugin (by @jonathangerbaud)
zenstack initcommand now installs ZenStack dependencies with pinned version- Added
zenstack infocommand to show package versions and available upgrade - Added the missing
counthooks for react hooks generation
New Contributors
- Welcome @potion-cellar and @jonathangerbaud to become our contributors. Thank you for your thoughtful ideas and code!
Full Changelog: v1.0.0-alpha.87...v1.0.0-alpha.98