github zenstackhq/zenstack v3.4.0
ZenStack Release v3.4.0

7 hours ago

New Features ☀️

Schema Introspection

The new "db pull" command introspects the current database schema and creates an incremental update to your current ZModel. This awesome feature is contributed by @svetch . doc

Slicing ORM API

The new slicing ORM client option allows you to restrict the capabilities of a client - what models to provide, what query operations to allow, what kinds of filtering are supported, etc. doc

const slicedDb = db.$setOptions({
  ...db.$options,
  slicing: {
    // exclude the Comment model entirely
    excludedModels: ['Comment'],
    models: {
      post: {
        // exclude `deleteMany` operation for 'Post' model
        excludedOperations: ['deleteMany'],
        fields: {
          title: {
            // only allow equality filter for "Post.title" field
            includedFilterKinds: ['Equality']
          }
        }
      }
    }
  }
});

Deriving Zod Schemas

This release introduced two Zod schema factories for different validation purposes.

1. Model Validation

A @zenstackhq/zod package is added that provides a factory for creating Zod schemas to validate models, types, and enums as defined in ZModel. doc

This is useful for use cases like using ZModel as the single source of truth for validating form input, etc.

2. ORM Query Args Validation

The ZenStackClient object now exposes a $zod property for creating Zod schemas that validate the input args of ORM API calls, like findUnique, createMany, etc. doc

This is useful for building layers above ZenStack ORM that eventually pass user input to ORM API calls.

Sequential Transaction for RPC API Handler

The RPC API handler now supports sequential transactions via the "$transaction/sequential" endpoint. doc

Fixes and Improvements 🔧

  • Fixed an issue with malformed SQL generation when entity mutation hooks are used with delegate models by @genu .
  • Fixed an issue with malformed SQL generation when calling find APIs with select but without any truthy fields #2344
  • Fixed the issue when "view" is used in ZModel, the Prisma schema generated during migration is not configured with the "views" preview feature #2376
  • Fixed a typing issue that "_count" property is not allowed in nested selection #2343
  • Fixed a malformed SQL generation issue related to field-level policies #2385
  • Fixed the issue that ORM-generated SQL may contain identifiers too long for Postgres #2378
  • Computed fields configuration is validated when creating ZenStackClient by @lsmith77 .
  • Updated several potentially vulnerable dependencies.

Breaking Changes ❗️

  • To make the generated TypeScript schema more portable, the import from "@zenstackhq/orm" is replaced with "@zenstackhq/schema" package. This may cause build errors depending on what package manager you use. It's recommended to explicitly install the "@zenstackhq/schema" package in projects where the TypeScript schema is consumed.

Don't miss a new zenstack release

NewReleases is sending notifications on new releases.