Skip to content

merge dev to main (v2.5.2) #1722

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
Closed
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.5.1",
"version": "2.5.2",
"description": "",
"scripts": {
"build": "pnpm -r build",
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.5.1"
version = "2.5.2"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

Codebase Verification

Changelog is severely outdated and missing version 2.5.2

The changelog has not been updated to include version 2.5.2 or any other 2.x versions. In fact, the most recent entry in the main CHANGELOG.md file is for version 0.5.0, dated 2022-12-15. This significant gap in documentation is a critical issue that needs immediate attention.

Action items:

  • Update the CHANGELOG.md file to include all major versions and changes from 0.5.0 up to the current 2.5.2 release.
  • Ensure that the changelog includes a detailed entry for version 2.5.2, highlighting all new features, improvements, and breaking changes.
  • Implement a process to consistently update the changelog with each new release to prevent this issue from recurring.
Analysis chain

LGTM!

The version update aligns with the PR objective of merging dev to main for v2.5.2.

Please verify that the changelog has been updated to reflect the changes included in this release.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the changelog has been updated for version 2.5.2.

# Test: Search for the version in the changelog. Expect: At least one match.
rg --type markdown $'2\.5\.2' $(fd CHANGELOG.md)

Length of output: 433


Script:

#!/bin/bash
# Description: Search for different version formats in changelog files

# Search for "v2.5.2" (with 'v' prefix)
echo "Searching for 'v2.5.2':"
rg --type markdown 'v2\.5\.2' $(fd CHANGELOG.md)

# Search for "2.5.2" with surrounding characters
echo "Searching for '2.5.2' with surrounding characters:"
rg --type markdown '[^0-9]2\.5\.2[^0-9]' $(fd CHANGELOG.md)

# List the content of the main CHANGELOG.md file
echo "Content of the main CHANGELOG.md file:"
cat CHANGELOG.md

Length of output: 4639


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.5.1",
"version": "2.5.2",
"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.5.1",
"version": "2.5.2",
"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.5.1",
"version": "2.5.2",
"description": "CLI and runtime for integrating ZenStack with RedwoodJS projects.",
"repository": {
"type": "git",
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.5.1",
"version": "2.5.2",
"description": "ZenStack plugin and runtime supporting OpenAPI",
"main": "index.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion 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.5.1",
"version": "2.5.2",
"description": "ZenStack plugin for generating SWR hooks",
"main": "index.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion 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.5.1",
"version": "2.5.2",
"description": "ZenStack plugin for generating tanstack-query hooks",
"main": "index.js",
"exports": {
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.5.1",
"version": "2.5.2",
"description": "ZenStack plugin for tRPC",
"main": "index.js",
"repository": {
Expand Down
4 changes: 3 additions & 1 deletion packages/runtime/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zenstackhq/runtime",
"displayName": "ZenStack Runtime Library",
"version": "2.5.1",
"version": "2.5.2",
"description": "Runtime of ZenStack for both client-side and server-side environments.",
"repository": {
"type": "git",
Expand Down Expand Up @@ -98,6 +98,7 @@
"semver": "^7.5.2",
"superjson": "^1.13.0",
"tiny-invariant": "^1.3.1",
"traverse": "^0.6.10",
"ts-pattern": "^4.3.0",
"tslib": "^2.4.1",
"upper-case-first": "^2.0.2",
Expand All @@ -118,6 +119,7 @@
"@types/pluralize": "^0.0.29",
"@types/safe-json-stringify": "^1.1.5",
"@types/semver": "^7.3.13",
"@types/traverse": "^0.6.37",
"@types/uuid": "^8.3.4"
}
}
1 change: 1 addition & 0 deletions packages/runtime/src/cross/nested-write-visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ export class NestedWriteVisitor {
break;

case 'createMany':
case 'createManyAndReturn':
if (data) {
const newContext = pushNewContext(field, model, {});
let callbackResult: any;
Expand Down
1 change: 1 addition & 0 deletions packages/runtime/src/cross/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
export const PrismaWriteActions = [
'create',
'createMany',
'createManyAndReturn',
'connectOrCreate',
'update',
'updateMany',
Expand Down
34 changes: 31 additions & 3 deletions packages/runtime/src/enhancements/node/create-enhancement.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import semver from 'semver';
import { PRISMA_MINIMUM_VERSION } from '../../constants';
import { isDelegateModel, type ModelMeta } from '../../cross';
import type { EnhancementContext, EnhancementKind, EnhancementOptions, ZodSchemas } from '../../types';
import type {
DbClientContract,
EnhancementContext,
EnhancementKind,
EnhancementOptions,
ZodSchemas,
} from '../../types';
import { withDefaultAuth } from './default-auth';
import { withDelegate } from './delegate';
import { Logger } from './logger';
import { withOmit } from './omit';
import { withPassword } from './password';
import { withPolicy } from './policy';
import { policyProcessIncludeRelationPayload, withPolicy } from './policy';
import type { PolicyDef } from './types';

/**
Expand Down Expand Up @@ -41,6 +47,18 @@ export type InternalEnhancementOptions = EnhancementOptions & {
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
prismaModule: any;

/**
* A callback shared among enhancements to process the payload for including a relation
* field. e.g.: `{ author: true }`.
*/
processIncludeRelationPayload?: (
prisma: DbClientContract,
model: string,
payload: unknown,
options: InternalEnhancementOptions,
context: EnhancementContext | undefined
) => Promise<void>;
Comment on lines +55 to +61
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specify a more precise type for the payload parameter.

The payload parameter in processIncludeRelationPayload is currently typed as unknown. Providing a more specific type can enhance type safety and improve code readability.

If there is a defined type that represents the structure of the payload (e.g., IncludeRelationPayload), consider updating the parameter type:

 processIncludeRelationPayload?: (
     prisma: DbClientContract,
     model: string,
-    payload: unknown,
+    payload: IncludeRelationPayload,
     options: InternalEnhancementOptions,
     context: EnhancementContext | undefined
 ) => Promise<void>;

Committable suggestion was skipped due to low confidence.

};

/**
Expand Down Expand Up @@ -89,7 +107,7 @@ export function createEnhancement<DbClient extends object>(
'Your ZModel contains delegate models but "delegate" enhancement kind is not enabled. This may result in unexpected behavior.'
);
} else {
result = withDelegate(result, options);
result = withDelegate(result, options, context);
}
}

Expand All @@ -103,6 +121,16 @@ export function createEnhancement<DbClient extends object>(
// 'policy' and 'validation' enhancements are both enabled by `withPolicy`
if (kinds.includes('policy') || kinds.includes('validation')) {
result = withPolicy(result, options, context);

// if any enhancement is to introduce an inclusion of a relation field, the
// inclusion payload must be processed by the policy enhancement for injecting
// access control rules

// TODO: this is currently a global callback shared among all enhancements, which
// is far from ideal

options.processIncludeRelationPayload = policyProcessIncludeRelationPayload;

if (kinds.includes('policy') && hasDefaultAuth) {
// @default(auth()) proxy
result = withDefaultAuth(result, options, context);
Expand Down
9 changes: 8 additions & 1 deletion packages/runtime/src/enhancements/node/default-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,14 @@ class DefaultAuthHandler extends DefaultPrismaProxyHandler {

// base override
protected async preprocessArgs(action: PrismaProxyActions, args: any) {
const actionsOfInterest: PrismaProxyActions[] = ['create', 'createMany', 'update', 'updateMany', 'upsert'];
const actionsOfInterest: PrismaProxyActions[] = [
'create',
'createMany',
'createManyAndReturn',
'update',
'updateMany',
'upsert',
];
if (actionsOfInterest.includes(action)) {
const newArgs = await this.preprocessWritePayload(this.model, action as PrismaWriteActionType, args);
return newArgs;
Expand Down
Loading
Loading