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
Bot releases are hidden (Show)
Published by ymc9 over 1 year ago
null
if a nested optional to-one relation is requested but not readable. #586Bytes
type. #573Full Changelog: https://github.com/zenstackhq/zenstack/compare/v1.0.0-beta.8...v1.0.0-beta.10
Published by ymc9 over 1 year ago
fetch
function when using SWR and TanStack Query hooks #542 #541tsc
happy in pnpm workspace environmentcreate
, 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: https://github.com/zenstackhq/zenstack/compare/v1.0.0-beta.3...v1.0.0-beta.7
Published by ymc9 over 1 year ago
[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:
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'))
.
true
or false
are used as declaration name prefix #522meta
section for collection queries by @chemitaxis #527Welcome @chemitaxis to the contributor family!
Full Changelog: https://github.com/zenstackhq/zenstack/compare/v1.0.0-beta.1...v1.0.0-beta.3
Published by ymc9 over 1 year ago
now()
function in access policy rules #478@db.Decimal
attributegenerateModelActions
config options to trpc plugin to control what CRUD actions to generate #460logPrismaQuery
prisma generate
error output to telemetry for future improvementswithPresets
, withPolicy
, withPassword
, withOmit
): grouped extra parameters into an options
bagFull Changelog: https://github.com/zenstackhq/zenstack/compare/v1.0.0-alpha.119...v1.0.0-beta.1
Published by ymc9 over 1 year ago
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:
@zenstackhq/server
package. The original @zenstackhq/next
package will be deprecated soon.We're aiming to hit Beta for the next release!
Full Changelog: https://github.com/zenstackhq/zenstack/compare/v1.0.0-alpha.114...v1.0.0-alpha.119
Published by ymc9 over 1 year ago
schema.prisma
fileSpecial thanks to @he-la, @potion-cellar, and @sidharthv96 for reporting multiple issues!
Full Changelog: https://github.com/zenstackhq/zenstack/compare/v1.0.0-alpha.111...v1.0.0-alpha.114
Published by jiashengguo over 1 year ago
index.ts
to reexport all schema objects #361Full Changelog: https://github.com/zenstackhq/zenstack/compare/v1.0.0-alpha.102...v1.0.0-alpha.110
Published by ymc9 over 1 year ago
groupBy
and count
hooks from the @zenstackhq/react
pluginFull Changelog: https://github.com/zenstackhq/zenstack/compare/v1.0.0-alpha.99...v1.0.0-alpha.102
Published by ymc9 over 1 year ago
@zenstackhq/openapi
plugin
@@openapi.meta
attribute@zenstackhq/trpc
plugin to wrap Prisma errors into proper trpc errorsSpecial thanks to @potion-cellar, @Azzerty23, and @jawadst for filing several issues.
Full Changelog: https://github.com/zenstackhq/zenstack/compare/v1.0.0-alpha.98...v1.0.0-alpha.99
Published by ymc9 over 1 year ago
zenstack init
command now installs ZenStack dependencies with pinned versionzenstack info
command to show package versions and available upgradecount
hooks for react hooks generationFull Changelog: https://github.com/zenstackhq/zenstack/compare/v1.0.0-alpha.87...v1.0.0-alpha.98
Published by ymc9 over 1 year ago
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.auth()
objectFull Changelog: https://github.com/zenstackhq/zenstack/compare/v1.0.0-alpha.85...v1.0.0-alpha.87
Published by ymc9 over 1 year ago
langium
dependency (old version results in a StackOverflow error)@@ignore
and @ignore
attributes@relation
field generationPublished by ymc9 over 1 year ago
@zenstackhq/openapi
pluginconnect
, connectOrCreate
, and update
now trigger the validation of "update" policy on the relation owner side (since such operations update foreign keys). It wasn't enforced in the previous releases. You may need to adjust access policies accordingly.E.g.:
model User {
...
posts Post[]
}
model Post {
...
author User? @relation(fields: [authorId], references: [id])
authorId String?
db.user.create({
data: {
posts: { connect: { id: 'post1' } }
}
});
The above code may fail if Post
model is not updatable by the current user.
Published by ymc9 over 1 year ago
Under the hood, this release includes a unified OpenAPI layer for handling CRUD operations, which is used by the new fastify adapter and will also be the foundation for other upcoming new server-side adapters.
Published by ymc9 over 1 year ago
@@schema
attribute for supporting "multi-schema setup"Thanks to @digoburigo for reporting the multi-schema issue.
Thanks to @keanugrieves for reporting mono-repro problems.
Published by ymc9 over 1 year ago
@db.Text
, @db.Date
etc. #236@@id
#238@prisma.passthrough
, @@prisma.passthrough
Published by ymc9 over 1 year ago
@default
#232Published by ymc9 over 1 year ago
@zenstackhq/react
hooks generator: now when a mutation succeeds but the result can't be read back, hook returns undefined
instead of throwing an error@zenstackhq/trpc
generated routers return undefined
when result can't be read back@zenstackhq/runtime
zenstack init
, install Prisma if not found #219@@map
and @map
attributes from zmodel to prisma schemaPlease upgrade your VSCode extension too (v1.0.7).
Published by ymc9 over 1 year ago
Published by ymc9 over 1 year ago