Skip to content

Commit

Permalink
merge dev to main (v2.5.0) (#1680)
Browse files Browse the repository at this point in the history
  • Loading branch information
ymc9 authored Sep 6, 2024
2 parents 61e07d0 + dc72b64 commit 8297c03
Show file tree
Hide file tree
Showing 142 changed files with 10,625 additions and 850 deletions.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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

0 comments on commit 8297c03

Please sign in to comment.