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 v1.0.0-alpha.33

Published by ymc9 over 1 year ago

What's Changed

  • @zenstackhq/react, hooks are generated regardless if a model has access control rules
  • Fixed the issue that triple slash comments cannot be used on some ZModel declarations #194
  • Added support for @@unique constraint with multiple fields #196
  • @zenstackhq/react, fixed error handling in generated hooks code
  • improved VSCode extension's auto-formatting, added code action for adding the opposite side of relations
  • Support using enums as field's default value #204
zenstack - ZenStack Release v1.0.0-alpha.28

Published by ymc9 over 1 year ago

Road to V1

After listening to the feedback from our enthusiastic early adopters, we've decided to repackage ZenStack's features to meet the following goals:

Enhancing Prisma instead of hiding it

We started to build ZenStack because we really liked Prisma and thought it had more potential than an ORM. In pre-v1 versions, ZenStack tried to inherit the schema language from Prisma but hide it from a tooling point of view.

Feedback showed that fully replicating Prisma CLI didn't add much value. We've decided to focus on extending Prisma's schema where necessary and act like a transpiler that generates Prisma schema file into its standard location and leaves the ORM tasks - sync database schema, seeding database, generating migrations, etc., to the Prisma CLI.

Framework agnostic

Previous versions have a strong binding to Next.js at the surface, although the toolkit's core is independent. For the V1 release, ZenStack will be framework-agnostic, and there'll be integration packages and plugins for interfacing with various popular full-stack frameworks.

Flexible and extensible

The V1 release delivers its main features by wrapping standard PrismaClient instances. You can create an enhanced PrismaClient with features like access control, field validation, and field omission and use it with exactly the same API as regular Prisma.

This level of encapsulation allows more flexibility because you can use ZenStack entirely as a backend toolkit to save time writing explicit authorization code. On the other hand, you can also use it full-stack by leveraging its capability of creating RESTful services and generating client libraries to reduce your entire backend development work to a minimum (if any).

We've also exposed extensibility at the schema language level by introducing the new plugin construct. Users can implement their own plugins for custom code generation with full access to the schema's AST.

Changes

  • Simplified zenstack CLI to do only project initialization and code generation.

  • Added Prisma enhancement APIs - withPolicy, withOmit, withPassword and withPresets.

  • Added plugin construct to ZModel language for implementing custom code generation.

  • Added future() attribute function for accessing an entity's "post-update" state.

  • Extracted Next.js integration to the @zenstackhq/next package.

  • Extracted "react hooks generation" as the @zenstackhq/react plugin that can be enabled on-demand.

  • Added @zenstackhq/trpc plugin for generating tRPC CRUD routers.

  • Triple-slash comments are preserved when generating Prisma schema. Custom attributes are also output as triple-slash comments. It allows interoperability with existing Prisma generators that use the comment hack.

  • VS Code extension now supports auto-formatting.

  • Website is rebuilt with Docusaurus - better readability and better SEO.


We know it's a pretty big change, and would love to hear what you think about it. Please join our discord server and let's chat!

zenstack - ZenStack Release v0.5.0

Published by ymc9 almost 2 years ago

Features

  • Serialization between client (hooks) and server now uses superjson, [#139]

Fixes and improvements

  • Fixed goto definition issue in VSCode extension, [#69]

Breaking changes

  • Next-auth adapter and helper are moved to a separate package @zenstackhq/next-auth.
zenstack - ZenStack Release v0.4.0

Published by ymc9 almost 2 years ago

Features

  • zenstack init command for initializing a project, #109, doc.

  • Field constraint suport, #94, doc.

  • Support for server-side CRUD with access policy check (SSR), #126, doc.

  • Options for disabling fetching in hooks (useful when arguments are not ready), #57, doc.

  • Telemetry in CLI, #102, doc.

  • Iron-session based starter, #95, link.

  • Barebone starter (without authentication), link.

  • Website is live!

Fixes and improvements

  • Merge @zenstackhq/internal into @zenstackhq/runtime so as to have a single runtime dependency, #70.

  • More accurate log for access policy violation, #71.

  • auth() function's return type is now resolved to User model in ZModel, instead of Any, #65.

  • Improved ZModel type checking, #67, #46, #99.

  • Upgraded to Prisma 4.7.

Breaking changes

  • @zenstackhq/runtime doesn't export anything now.

    Use @zenstackhq/runtime/types for type definitions shared between client and server, @zenstackhq/runtime/client for client-specific libaries (like React hooks), and @zenstackhq/runtime/server for server-specific libraries.

zenstack - ZenStack Release v0.3.0

Published by ymc9 almost 2 years ago

Closes #48 #54 #45 #53 #51 #58

  • More robust policy checks
  • Configurable logging (to stdout and emitting as events)
  • Properly handles complex types like BigInt, Date, Decimal, etc.
  • Makes sure Prisma schema is regenerated for related CLI commands
  • @password and @omit attribute support
  • Lower VSCode engine version requirement for the extension
  • Better overall documentation
zenstack - ZenStack Release v0.2.4

Published by ymc9 almost 2 years ago

  • Refactored policy checking and added more integration tests
  • Added new @password and @omit field attributes
  • Cleaned up todo sample's redundant models
zenstack - ZenStack Release v0.2.1

Published by ymc9 almost 2 years ago

ZenStack Release v0.2.1 (2022-10-29)

Initial public release for ZenStack cli and runtime packages

New Features

  • ZModel data modeling schema (an extension to Prisma Schema)
  • zenstack cli for generating RESTful services, auth adapters and React hooks from ZModel
  • Policy engine that transforms policy rules into Prisma query conditions
  • Runtime packages
  • An initial set of tests
Package Rankings
Top 3.07% on Npmjs.org
Related Projects