Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9124d13
chore: update vscode extension description (#1640)
jiashengguo Aug 9, 2024
9017a13
add path arg to @@validate and implement gencode (#1641)
j0rdanba1n Aug 12, 2024
b863060
chore: update jetbrains changelog (#1651)
ymc9 Aug 21, 2024
ca2a4f4
feat(cli): new "check" command for validating ZModel (#1652)
ymc9 Aug 21, 2024
1d546d4
chore: bump version (#1653)
ymc9 Aug 21, 2024
40ea9fa
feat(trpc): trpc v11 support (#1656)
ymc9 Aug 23, 2024
32c258c
feat(enhance): Prisma Pulse support (#1658)
ymc9 Aug 24, 2024
1d81325
fix(redwood): fix incorrect error type thrown (#1659)
ymc9 Aug 24, 2024
19a3b5d
fix: field-level policy should filter out records when the field used…
ymc9 Aug 27, 2024
8589b79
fix(delegate): delegate models returned in nested results don't inclu…
ymc9 Aug 27, 2024
62c624d
fix: `check` attribute function shouldn't delegate "postUpdate" rules…
ymc9 Aug 27, 2024
6225292
fix: incorrect policy injection for post-update rules with deep membe…
ymc9 Aug 27, 2024
854edcb
chore: upgrade to Prisma 5.19 (#1670)
ymc9 Aug 30, 2024
c411111
refactor: replace decimal.js with decimal.js-light for smaller footpr…
ymc9 Aug 30, 2024
e4e9fbf
fix(openapi): wrong spec for "Meta" object for rpc-style generation (…
ymc9 Aug 30, 2024
0b466bf
fix(delegate): update with "connect" is not properly rejected for pol…
ymc9 Aug 30, 2024
2275102
feat(cli): allow to include/exclude plugins when generate (#1676)
ymc9 Aug 31, 2024
83bdd6d
fix(cli): enhancer code fails to compile when generated into a custom…
ymc9 Sep 2, 2024
4ecfc11
fix: additional fix for 1667 (#1679)
ymc9 Sep 2, 2024
6ef6f89
chore(cli): add notifications (#1682)
ymc9 Sep 3, 2024
042df7e
refactor(runtime): separate node and edge enhancement code for edge-r…
ymc9 Sep 6, 2024
b421047
fix: more robust custom serializer (#1689)
ymc9 Sep 6, 2024
dc72b64
chore: update jetbrains changelog (#1690)
ymc9 Sep 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zenstack-monorepo",
"version": "2.4.1",
"version": "2.5.0",
"description": "",
"scripts": {
"build": "pnpm -r build",
Expand Down
2 changes: 1 addition & 1 deletion packages/ide/jetbrains/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions packages/ide/jetbrains/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## [Unreleased]
### Added
- A new `path` parameter to the `@@validate` attribute for providing an optional path to the field that caused the error.

## 2.4.0
### Added
- The `uuid()` function is updated to support the new UUID version feature from Prisma.

## 2.3.0
### Added
- New `check()` policy rule function.

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion packages/ide/jetbrains/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

group = "dev.zenstack"
version = "2.4.1"
version = "2.5.0"

repositories {
mavenCentral()
Expand Down
2 changes: 1 addition & 1 deletion packages/ide/jetbrains/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jetbrains",
"version": "2.4.1",
"version": "2.5.0",
"displayName": "ZenStack JetBrains IDE Plugin",
"description": "ZenStack JetBrains IDE plugin",
"homepage": "https://zenstack.dev",
Expand Down
2 changes: 1 addition & 1 deletion packages/language/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/language",
"version": "2.4.1",
"version": "2.5.0",
"displayName": "ZenStack modeling language compiler",
"description": "ZenStack modeling language compiler",
"homepage": "https://zenstack.dev",
Expand Down
2 changes: 1 addition & 1 deletion packages/misc/redwood/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zenstackhq/redwood",
"displayName": "ZenStack RedwoodJS Integration",
"version": "2.4.1",
"version": "2.5.0",
"description": "CLI and runtime for integrating ZenStack with RedwoodJS projects.",
"repository": {
"type": "git",
Expand Down
5 changes: 2 additions & 3 deletions packages/misc/redwood/src/graphql.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { ForbiddenError } from '@redwoodjs/graphql-server';
import { ForbiddenError, ValidationError } from '@redwoodjs/graphql-server';
import {
CrudFailureReason,
EnhancementOptions,
PrismaErrorCode,
ValidationError,
enhance,
isPrismaClientKnownRequestError,
type AuthUser,
Expand Down Expand Up @@ -47,7 +46,7 @@ export function useZenStack<PrismaClient extends object>(

// Transforms ZenStack errors into appropriate RedwoodJS errors
function transformError(error: unknown) {
if (isPrismaClientKnownRequestError(error) && error.code === PrismaErrorCode.CONSTRAINED_FAILED) {
if (isPrismaClientKnownRequestError(error) && error.code === PrismaErrorCode.CONSTRAINT_FAILED) {
if (
error.meta?.reason === CrudFailureReason.ACCESS_POLICY_VIOLATION ||
error.meta?.reason === CrudFailureReason.RESULT_NOT_READABLE
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/openapi/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zenstackhq/openapi",
"displayName": "ZenStack Plugin and Runtime for OpenAPI",
"version": "2.4.1",
"version": "2.5.0",
"description": "ZenStack plugin and runtime supporting OpenAPI",
"main": "index.js",
"repository": {
Expand Down
13 changes: 4 additions & 9 deletions packages/plugins/openapi/src/rpc-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -637,18 +637,13 @@ export class RPCOpenAPIGenerator extends OpenAPIGeneratorBase {

schemas['_Meta'] = {
type: 'object',
description: 'Meta information about the request or response',
properties: {
meta: {
type: 'object',
description: 'Meta information about the request or response',
properties: {
serialization: {
description: 'Serialization metadata',
},
},
additionalProperties: true,
serialization: {
description: 'Serialization metadata',
},
},
additionalProperties: true,
};

schemas['_Error'] = {
Expand Down
11 changes: 4 additions & 7 deletions packages/plugins/openapi/tests/baseline/rpc-3.0.0.baseline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3212,14 +3212,11 @@ components:
nullable: true
_Meta:
type: object
description: Meta information about the request or response
properties:
meta:
type: object
description: Meta information about the request or response
properties:
serialization:
description: Serialization metadata
additionalProperties: true
serialization:
description: Serialization metadata
additionalProperties: true
_Error:
type: object
required:
Expand Down
11 changes: 4 additions & 7 deletions packages/plugins/openapi/tests/baseline/rpc-3.1.0.baseline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3276,14 +3276,11 @@ components:
- type: string
_Meta:
type: object
description: Meta information about the request or response
properties:
meta:
type: object
description: Meta information about the request or response
properties:
serialization:
description: Serialization metadata
additionalProperties: true
serialization:
description: Serialization metadata
additionalProperties: true
_Error:
type: object
required:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1861,14 +1861,11 @@ components:
nullable: true
_Meta:
type: object
description: Meta information about the request or response
properties:
meta:
type: object
description: Meta information about the request or response
properties:
serialization:
description: Serialization metadata
additionalProperties: true
serialization:
description: Serialization metadata
additionalProperties: true
_Error:
type: object
required:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1903,14 +1903,11 @@ components:
format: byte
_Meta:
type: object
description: Meta information about the request or response
properties:
meta:
type: object
description: Meta information about the request or response
properties:
serialization:
description: Serialization metadata
additionalProperties: true
serialization:
description: Serialization metadata
additionalProperties: true
_Error:
type: object
required:
Expand Down
3 changes: 1 addition & 2 deletions packages/plugins/swr/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zenstackhq/swr",
"displayName": "ZenStack plugin for generating SWR hooks",
"version": "2.4.1",
"version": "2.5.0",
"description": "ZenStack plugin for generating SWR hooks",
"main": "index.js",
"repository": {
Expand Down Expand Up @@ -42,7 +42,6 @@
"@zenstackhq/sdk": "workspace:*",
"change-case": "^4.1.2",
"cross-fetch": "^4.0.0",
"decimal.js": "^10.4.2",
"lower-case-first": "^2.0.2",
"semver": "^7.5.2",
"ts-morph": "^16.0.0",
Expand Down
3 changes: 1 addition & 2 deletions packages/plugins/tanstack-query/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zenstackhq/tanstack-query",
"displayName": "ZenStack plugin for generating tanstack-query hooks",
"version": "2.4.1",
"version": "2.5.0",
"description": "ZenStack plugin for generating tanstack-query hooks",
"main": "index.js",
"exports": {
Expand Down Expand Up @@ -84,7 +84,6 @@
"@zenstackhq/sdk": "workspace:*",
"change-case": "^4.1.2",
"cross-fetch": "^4.0.0",
"decimal.js": "^10.4.2",
"lower-case-first": "^2.0.2",
"semver": "^7.5.2",
"ts-morph": "^16.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/trpc/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zenstackhq/trpc",
"displayName": "ZenStack plugin for tRPC",
"version": "2.4.1",
"version": "2.5.0",
"description": "ZenStack plugin for tRPC",
"main": "index.js",
"repository": {
Expand Down
16 changes: 16 additions & 0 deletions packages/plugins/trpc/res/client/v11/next.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* eslint-disable */

import type { AnyTRPCRouter as AnyRouter } from '@trpc/server';
import type { NextPageContext } from 'next';
import { type CreateTRPCNext, createTRPCNext as _createTRPCNext } from '@trpc/next';
import type { DeepOverrideAtPath } from './utils';
import type { ClientType } from '../routers';

export function createTRPCNext<
TRouter extends AnyRouter,
TPath extends string | undefined = undefined,
TSSRContext extends NextPageContext = NextPageContext
>(opts: Parameters<typeof _createTRPCNext>[0]) {
const r: CreateTRPCNext<TRouter, TSSRContext> = _createTRPCNext<TRouter, TSSRContext>(opts);
return r as DeepOverrideAtPath<CreateTRPCNext<TRouter, TSSRContext>, ClientType<TRouter>, TPath>;
}
16 changes: 16 additions & 0 deletions packages/plugins/trpc/res/client/v11/react.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* eslint-disable */

import type { AnyTRPCRouter as AnyRouter } from '@trpc/server';
import type { CreateTRPCReactOptions } from '@trpc/react-query/shared';
import { type CreateTRPCReact, createTRPCReact as _createTRPCReact } from '@trpc/react-query';
import type { DeepOverrideAtPath } from './utils';
import type { ClientType } from '../routers';

export function createTRPCReact<
TRouter extends AnyRouter,
TPath extends string | undefined = undefined,
TSSRContext = unknown
>(opts?: CreateTRPCReactOptions<TRouter>) {
const r: CreateTRPCReact<TRouter, TSSRContext> = _createTRPCReact<TRouter, TSSRContext>(opts);
return r as DeepOverrideAtPath<CreateTRPCReact<TRouter, TSSRContext>, ClientType<TRouter>, TPath>;
}
32 changes: 32 additions & 0 deletions packages/plugins/trpc/res/client/v11/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* eslint-disable */

// inspired by: https://stackoverflow.com/questions/70632026/generic-to-recursively-modify-a-given-type-interface-in-typescript

type Primitive = string | Function | number | boolean | Symbol | undefined | null;

/**
* Recursively merges `T` and `R`. If there's a shared key, use `R`'s field type to overwrite `T`.
*/
export type DeepOverride<T, R> = T extends Primitive
? R
: R extends Primitive
? R
: {
[K in keyof T]: K extends keyof R ? DeepOverride<T[K], R[K]> : T[K];
} & {
[K in Exclude<keyof R, keyof T>]: R[K];
};

/**
* Traverse to `Path` (denoted by dot separated string literal type) in `T`, and starting from there,
* recursively merge with `R`.
*/
export type DeepOverrideAtPath<T, R, Path extends string | undefined = undefined> = Path extends undefined
? DeepOverride<T, R>
: Path extends `${infer P1}.${infer P2}`
? P1 extends keyof T
? Omit<T, P1> & Record<P1, DeepOverride<T[P1], DeepOverrideAtPath<T[P1], R, P2>>>
: never
: Path extends keyof T
? Omit<T, Path> & Record<Path, DeepOverride<T[Path], R>>
: never;
Loading