Skip to content

Releases: zenstackhq/zenstack

ZenStack Release v1.0.0-beta.3

03 Jul 10:03
fe88dab
Compare
Choose a tag to compare

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 an author field. After applying the typing helper, the result is typed as Post & { 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 @@validate is 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/zod plugin 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/zod and 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 to z.string().email('must be a valid email').

    Model-level validation rules written with @@validate are also supported and are transformed to z.refine. E.g., @@validate(x > 0 && contains(y, 'foo')) is transformed to z.object({...}).refine((value) => value.x > 0 && value.y?.includes('foo')).

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 true or false are used as declaration name prefix #522
  • The REST API handler now returns the total count in the meta section 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

15 Jun 08:23
f31e0a2
Compare
Choose a tag to compare

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.Decimal attribute
  • Fixed wrong resource link in rest API handler #469
  • Added generateModelActions config 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 generate error output to telemetry for future improvements

Breaking Changes

  • Signature change for the "enhancement" APIs (withPresets, withPolicy, withPassword, withOmit): grouped extra parameters into an options bag

New Contributors

Full Changelog: v1.0.0-alpha.119...v1.0.0-beta.1

ZenStack Release v1.0.0-alpha.119

29 May 01:23
831b32c
Compare
Choose a tag to compare

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/openapi plugin is also updated to support RESTful style API.

  • Server adapter for SvelteKit

    The @zenstackhq/server/sveltekit module implements a SvelteKit server hook to provide an automatic RPC or RESTful style CRUD API. Check out the sample project here.

  • New plugins: @zenstackhq/swr and @zenstackhq/tanstack-query

    These plugins generate client hooks targeting SWR and TanStack Query. The original @zenstackhq/react plugin 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/server package. The original @zenstackhq/next package 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

07 May 01:36
3fdb686
Compare
Choose a tag to compare

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.prisma file
  • 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

01 May 10:24
e959463
Compare
Choose a tag to compare

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.ts to 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

14 Apr 18:44
cd0cab3
Compare
Choose a tag to compare

What's Changed

  • Fixed wrongly generated types for the groupBy and count hooks from the @zenstackhq/react plugin
  • 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

11 Apr 07:15
4d35a0f
Compare
Choose a tag to compare

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/openapi plugin
  • Fixed the issue that VSCode extension reports errors for @@openapi.meta attribute
  • Improved @zenstackhq/trpc plugin 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

31 Mar 13:35
e3993c5
Compare
Choose a tag to compare

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 init command now installs ZenStack dependencies with pinned version
  • Added zenstack info command to show package versions and available upgrade
  • Added the missing count hooks for react hooks generation

New Contributors

Full Changelog: v1.0.0-alpha.87...v1.0.0-alpha.98

ZenStack Release v1.0.0-alpha.87

28 Mar 11:43
1008b0e
Compare
Choose a tag to compare

What's Changed

  • Support for implicit many-to-many relations
  • Added attribute functions for filtering on fields in policy expressions: contains, search, startsWith, endsWith, has, hasSome, isEmpty. You can use these functions to write more flexible policy rules, e.g.:
    model Post {
      id String @id
      title String
      @@allow('update', startsWith(title, '[DRAFT]'))
    }
    See detailed documentation here: https://zenstack.dev/docs/reference/zmodel-language#predefined-attribute-functions.
  • Improved consistency in handling undefined and null values in auth() object

Full Changelog: v1.0.0-alpha.85...v1.0.0-alpha.87

v1.0.0-alpha.85

27 Mar 00:20
23180ce
Compare
Choose a tag to compare

What's Changed

  • Upgraded langium dependency (old version results in a StackOverflow error)
  • Added support for Prisma's @@ignore and @ignore attributes
  • VSCode: improved support for @relation field generation