zenstack

Fullstack TypeScript toolkit that enhances Prisma ORM with flexible Authorization layer for RBAC/ABAC/PBAC/ReBAC, offering auto-generated type-safe APIs and frontend hooks.

MIT License

Downloads
204.1K
Stars
2.1K
Committers
32

Bot releases are hidden (Show)

zenstack - ZenStack Release v2.0.2

Published by ymc9 6 months ago

What's Changed

  • Fixed the problem that enum documentation is lost in the generated prisma schema by @nopain1210
  • Fixed compatibility issue with pnpm workspace environment

New Contributors

  • Welcome @nopain1210 to becoming our new contributor!

Full Changelog: https://github.com/zenstackhq/zenstack/compare/v2.0.1...v2.0.2

zenstack - ZenStack Release v2.0.1

Published by ymc9 6 months ago

What's Changed

  • Prisma peer dependency version has been bumped to 5.13.x.
  • Fixed VSCode auto-fix code generation location issue.
  • Fixed policy compilation error for deeply nested post-update rules #1381

Full Changelog: https://github.com/zenstackhq/zenstack/compare/v2.0.0...v2.0.1

zenstack - ZenStack Release v2.0.0 🎉

Published by ymc9 6 months ago

Features

Make sure you read the full upgrade guide before upgrading!

1. Polymorphic Relations

You can now model a polymorphic inheritance hierarchy using the "delegated types" pattern. Read more details here.

2. Using auth() Inside @default Attribute

You can now use the auth() function call inside @default() attribute in ZModel. It's very handy for models that should always be connected to the current user during creation. By providing such a default value, you don't need to explicitly connect to the user anymore:

model Post {
  ...
  author User @relation(...)
  authorId String @default(auth().id)
}
const db = enhance(prisma, { user: getCurrentUser() });
const post = await db.post.create({ title: 'Post1' }); // no need to connect the `author` field

Special thanks to Augustin for making this feature happen!

3. Edge Runtime Support (Preview)

The @zenstackhq/runtime package is compatible with Vercel Edge Runtime and Cloudflare Workers. See here for more details.

4. Server Adapter for NestJS

An official adapter for using ZenStack with NestJS that plays well with its dependency injection. See here for more details.

5. Formating ZModel in Prisma Style

Yes, we heard your voices, and here it comes 😄. Please update the VSCode extension and JetBrains plugin to the latest version and enjoy.

image

You can toggle back to the old behavior in the extension settings (VSCode only).

Improvements and Fixes

This release also contains many DX improvements and fixes.

Full Changelog: https://github.com/zenstackhq/zenstack/compare/v1.12.4...v2.0.0

zenstack - ZenStack Release v1.12.4

Published by ymc9 6 months ago

What's Changed

  • Fixed access policy check issue with "upsert" models with compound @@id fields. #1271

Full Changelog: https://github.com/zenstackhq/zenstack/compare/v1.12.3...v1.12.4

zenstack - ZenStack Release v2.0.0-beta.13

Published by ymc9 6 months ago

What's Changed

  • VSCode extension and the zenstack CLI formats ZModel files with prisma-like indentation style by default. #885
  • zenstack CLI now auto-format the generated prisma schema by default.
  • Fixed several typing issues about using auth() inside @default().
  • Fixed the problem that member access from auth() is not properly resolved if the auth model is imported. #1257
  • Fixed the problem that @@index attribute is incorrectly inherited from the base. #1243
  • Removed several Prisma V4 dependencies since V4 is not supported anymore.

Full Changelog: https://github.com/zenstackhq/zenstack/compare/v2.0.0-beta.8...v2.0.0-beta.13

zenstack - ZenStack Release v1.12.3

Published by ymc9 6 months ago

What's Changed

  • Fixed the issue that enhance doesn't handle relations of the same type but different names properly #1241
  • Fixed openapi plugin to allow array form of input data

Full Changelog: https://github.com/zenstackhq/zenstack/compare/v1.12.2...v1.12.3

zenstack - ZenStack Release v1.12.2

Published by ymc9 6 months ago

What's Changed

  • Fixed the issue that post-update rule for "id" field is not effective when the id field is changed during an update #1235
  • Fixed incorrect access policy generation when this is used in post-update rules.

Full Changelog: https://github.com/zenstackhq/zenstack/compare/v1.12.1...v1.12.2

zenstack - ZenStack Release v2.0.0-beta.8

Published by ymc9 6 months ago

What's Changed

  • Support for edge runtime (Vercel edge and Cloudflare worker)
  • Clear plugins' output dir before running generation #1220
  • Add Prisma as peer dependency #1084
  • Make data validation a separate enhancement kind #1050
  • Fixed ZModel linker errors #1210

Full Changelog: https://github.com/zenstackhq/zenstack/compare/v2.0.0-beta.5...v2.0.0-beta.8

zenstack - ZenStack Release v1.12.1

Published by ymc9 6 months ago

What's Changed

  • [Zod] Generate a field schema as zod UUID if it has @db.Uuid attribute by @sakgoyal

New Contributors

  • Welcome @sakgoyal to becoming our new contributor!

Full Changelog: https://github.com/zenstackhq/zenstack/compare/v1.12.0...v1.12.1

zenstack - ZenStack Release v1.12.0

Published by ymc9 7 months ago

This release notes includes cumulated fixes and improvements since the last 1.11.0 release.

What's Changed

  • [TRPC] Improved how the generated code imports zod schemas for better compatibility by @jbruxelle #1177
  • [TanStack] Vue-query hooks now properly handle reactive input (for both query args and options)
  • The enhance API now has an extra prismaModule option to allow passing in the Prisma module when the prisma client is generated into a custom location docs
  • Fixed unit test failures on Windows environments.
  • Fixed the issue with insufficient unique constraint conflict detection when the skipDuplicates option is specified in a nested createMany payload #1162

Full Changelog: https://github.com/zenstackhq/zenstack/compare/v1.11.0...v1.12.0

New Contributors

  • Welcome @jbruxelle to becoming our new contributor ❤️ !

Full Changelog: https://github.com/zenstackhq/zenstack/compare/v1.11.0...v1.12.0

zenstack - ZenStack Release v2.0.0-beta.5

Published by ymc9 7 months ago

New Features

Fixes and Improvements

  • [Runtime] Improved handling of Prisma fluent API call to make sure N+1 query optimization is effective #1178
  • [ZModel] Fixed the issue that auth() field from a base model is not properly resolved #1179
  • [ZModel] Fixed a linking error that happens after merging declarations from imported models #1186
  • [Server] Changed several default exports to named ones for better bundler compatibility

Full Changelog: https://github.com/zenstackhq/zenstack/compare/v2.0.0-beta.3...v2.0.0-beta.5

zenstack - ZenStack Release v2.0.0-beta.3

Published by ymc9 7 months ago

Breaking Changes

  • Server adapters now return HTTP 422 when the request is rejected due to validation errors.

What's Changed

  • Removed prettier dependency. The generated code is now directly formatted with ts-morph.
  • Fixed the issue that @@map attribute is incorrectly inherited from base models.
  • Disallow this in collection predicate expressions.

Full Changelog: https://github.com/zenstackhq/zenstack/compare/v1.11.0...v2.0.0-beta.3

zenstack - ZenStack Release v2.0.0-beta.1

Published by ymc9 7 months ago

Breaking Changes

  • [TanStack Query] hooks signature is cleaned up and extra parameters are merged into query/mutation options.
  • [SWR] legacy mutation function generation is removed. Use mutation hooks instead.
  • [SWR] removed the deprecated initialData option. Use fallbackData instead.
  • [Server Adapter] the deprecated useSuperJSON flag is removed.
  • [Zod] generated model schemas now follows field optionality as defined in ZModel schema.

Features

  • The enhance API now generates strong typing for the user context, based on the fields access from auth() in access policies.
  • [TanStack Query/SWR] a new optimisticDataProvider callback option is added. You can use it to fully control how optimistic update data is computed for each query cache entry.
  • [Polymorphism] the generated enhance API now respects the client extension's typing of the prisma parameter.

Fixes and Improvements

  • [Polymorphism] fixed the problem generated prisma schema may have foreign key constraint ambiguity issue.
  • [Polymorphism] fixed the problem that generated auxiliary relations can cause naming conflict.
  • [Polymorphism] fixed the problem that fields in base models cannot be used in orderBy.
  • [Polymorphism] return full entity data when queried with a base model.
  • [Polymorphism] disallow inheriting from multiple delegate models.
  • Fields with @default with auth() are properly generated as TypeScript optional.
  • More robustly calculate the default location for code generation.

Full Changelog: https://github.com/zenstackhq/zenstack/compare/v2.0.0-alpha.2...v2.0.0-beta.1

zenstack - ZenStack Release v1.11.0

Published by ymc9 7 months ago

New Features

  • You can now import ZModel from packages in node_modules! Very useful if you want to manage and share ZModel files in a component-based setup. By @TGTGamer

    import "@myorg/foo/bar"
    import "mypackage/base"
    ...
    

Fixes and Improvements

This release gives a minor version bump for several fixes made in the "1.10.x" patch releases.

  • Fixed the issue that @@validate model-level rules cause incorrect runtime validation error for updates #1078
  • Fixed the issue that upsert with array-form input results in a partial write #1080
  • Fixed the issue that compound ids inherited from abstract models are not properly handled #1129

Full Changelog: https://github.com/zenstackhq/zenstack/compare/v1.10.0...v1.11.0

zenstack - ZenStack Release v1.10.0

Published by ymc9 8 months ago

Fixes and Improvements

  • Fixed typing issue in generated query hooks for TanStack Query (for Vue) #1056
  • Fixed zenstack CLI errors when running bun/bunx in non-tty environment by @ErikMCM
  • Allows enum types for id fields by @Ustice
  • Fixed missing parameters for a few built-in attributes (@@fulltext, @@db.VarBinary) by @Ustice
  • Fixed the problem that transformation attributes (@trim, @lower, @upper) are not effective for update operations #1005
  • Fixed the incorrect policy rejection when field-level policy specifies override but no model-level policy is defined #1014
  • Improved ZModel checking for nullability consistency between relation field and foreign key field #177
  • Generated Zod schemas now include coercion (z.coerce.date()) for DateTime typed fields #1067
  • Improved typing of error field of the TanStack Query mutation hooks #1062

Docs

New quick start guide for NextJS app router.

New Contributors

Welcome @ErikMCM @Ustice and @TGTGamer to becoming our new contributors!

Full Changelog: https://github.com/zenstackhq/zenstack/compare/v1.9.0...v1.10.0

zenstack - ZenStack Release v2.0.0-alpha.1

Published by ymc9 8 months ago

New Features

Breaking Changes

Check here for a list of breaking changes.


Please make sure to check out the Upgrading to V2 documentation for more details.

zenstack - ZenStack Release v1.9.0

Published by ymc9 8 months ago

What's Changed

  • New data transformation attributes @trim, @upper, @lower - they make sure values are transformed before storing into the database, and are also generated as corresponding Zod calls by the @core/zod plugin. By @simonedelmann docs
  • The parameters of Prisma transactions (timeout, maxWait, etc.) used internally by ZenStack are configurable #986 docs
  • Fixed several issues related to validating multi-level inheritance from abstract models #965 #971 #983
  • Fixed the issue the @omit attribute doesn't trim fields included in a nested one-to-many #984
  • Support for complex usage of "@@index" #987
  • Tanstack-query plugin now generates useSuspense and useSuspenseInfinite query hooks when generating for version "v5" and targeting "react" #857

New Contributors

  • Welcome @simonedelmann as our new contributor!

Full Changelog: https://github.com/zenstackhq/zenstack/compare/v1.8.1...v1.9.0

zenstack - ZenStack Release v1.8.1

Published by ymc9 9 months ago

Features and Improvements

  • Fixed "hostname not found" error when deploying to Vercel #931 by @Azzerty23
  • Fixed CLI crash when package.json is not found in the current dir #960
  • Fixed typing of tanstack-query code generation to properly support "select" options #963
  • Optimized typing of the generated TRPC code (to prepare for supporting trpc v11 down the road)

Thanks to @Azzerty23 for the contribution!

Full Changelog: https://github.com/zenstackhq/zenstack/compare/v1.7.1...v1.8.0

zenstack - ZenStack Release v1.7.1

Published by ymc9 9 months ago

What's Changed

  • Fixed an incorrect access policy injection when updateMany or delegeMany are nested inside update operation in certain cases #961

Full Changelog: https://github.com/zenstackhq/zenstack/compare/v1.7.0...v1.7.1

zenstack - ZenStack Release v1.7.0

Published by ymc9 9 months ago

New Features

  • VSCode extension and JetBrains plugin now support better auto-completion

    There's auto-completion inside attributes now. It's not perfect, but it should be a pretty big improvement compared to previous versions. Having accurate contextual auto-completion still requires quite some work, and we'll continue improving it down the road. Please let use know your pain points!

What's Changed

  • Fixed type generation error for tanstack-query plugin when targeting Svelt #945 by @bbozzay
  • Fixed ZModel validation error when using empty array in @default attribute #947 by @chunkerchunker

About V2

While gradually wrapping up the V1 track, we're making some good progressing on experimenting polymorphism in V2 branch. Please stay tuned for updates.

New Contributors

Welcome @bbozzay and @chunkerchunker to becoming warmhearted contributors! Thank you for making ZenStack a better toolkit!

Full Changelog: https://github.com/zenstackhq/zenstack/compare/v1.6.2...v1.7.0

Package Rankings
Top 3.07% on Npmjs.org
Related Projects