Skip to content

merge dev to main (v2.12.2) #2032

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

Merged
merged 3 commits into from
Mar 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ Thank you for your generous support!

<table>
<tr>
<td align="center"><a href="https://suhyl.com/"><img src="https://avatars.githubusercontent.com/u/124434734?s=200&v=4" width="100" style="border-radius:50%" alt="Suhyl"/><br />Suhyl</a></td>
<td align="center"><a href="https://www.marblism.com/"><img src="https://avatars.githubusercontent.com/u/143199531?s=200&v=4" width="100" style="border-radius:50%" alt="Marblism"/><br />Marblism</a></td>
<td align="center"><a href="https://www.mermaidchart.com/"><img src="https://avatars.githubusercontent.com/u/117662492?s=200&v=4" width="100" style="border-radius:50%" alt="Mermaid Chart"/><br />Mermaid Chart</a></td>
<td align="center"><a href="https://coderabbit.ai/"><img src="https://avatars.githubusercontent.com/u/132028505?v=4" width="100" style="border-radius:50%" alt="CodeRabbit"/><br />CodeRabbit</a></td>
Expand Down
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.12.1",
"version": "2.12.2",
"description": "",
"scripts": {
"build": "pnpm -r --filter=\"!./packages/ide/*\" 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.12.1"
version = "2.12.2"

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.12.1",
"version": "2.12.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.12.1",
"version": "2.12.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.12.1",
"version": "2.12.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.12.1",
"version": "2.12.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.12.1",
"version": "2.12.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.12.1",
"version": "2.12.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.12.1",
"version": "2.12.2",
"description": "ZenStack plugin for tRPC",
"main": "index.js",
"repository": {
Expand Down
2 changes: 1 addition & 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.12.1",
"version": "2.12.2",
"description": "Runtime of ZenStack for both client-side and server-side environments.",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"publisher": "zenstack",
"displayName": "ZenStack Language Tools",
"description": "FullStack enhancement for Prisma ORM: seamless integration from database to UI",
"version": "2.12.1",
"version": "2.12.2",
"author": {
"name": "ZenStack Team"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/schema/src/plugins/enhancer/enhance/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,10 +565,10 @@ export type Enhanced<Client> =
const structure = iface.getStructure();

// filter out aux fields
structure.properties = structure.properties?.filter((p) => !p.name.startsWith(DELEGATE_AUX_RELATION_PREFIX));
structure.properties = structure.properties?.filter((p) => !p.name.includes(DELEGATE_AUX_RELATION_PREFIX));

// filter out aux methods
structure.methods = structure.methods?.filter((m) => !m.name.startsWith(DELEGATE_AUX_RELATION_PREFIX));
structure.methods = structure.methods?.filter((m) => !m.name.includes(DELEGATE_AUX_RELATION_PREFIX));

if (delegateInfo.some(([delegate]) => `${delegate.name}Delegate` === iface.getName())) {
// delegate models cannot be created directly, remove create/createMany/upsert
Expand Down Expand Up @@ -850,7 +850,7 @@ export type Enhanced<Client> =
private findAuxDecls(node: Node) {
return node
.getDescendantsOfKind(SyntaxKind.PropertySignature)
.filter((n) => n.getName().startsWith(DELEGATE_AUX_RELATION_PREFIX));
.filter((n) => n.getName().includes(DELEGATE_AUX_RELATION_PREFIX));
}

private saveSourceFile(sf: SourceFile) {
Expand Down
2 changes: 1 addition & 1 deletion packages/schema/src/plugins/zod/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export class ZodSchemaGenerator {
const moduleNames: string[] = [];
for (let i = 0; i < inputObjectTypes.length; i += 1) {
// exclude delegate aux fields
const fields = inputObjectTypes[i]?.fields?.filter((f) => !f.name.startsWith(DELEGATE_AUX_RELATION_PREFIX));
const fields = inputObjectTypes[i]?.fields?.filter((f) => !f.name.includes(DELEGATE_AUX_RELATION_PREFIX));
const name = inputObjectTypes[i]?.name;

if (!generateUnchecked && name.includes('Unchecked')) {
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/sdk",
"version": "2.12.1",
"version": "2.12.2",
"description": "ZenStack plugin development SDK",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/server",
"version": "2.12.1",
"version": "2.12.2",
"displayName": "ZenStack Server-side Adapters",
"description": "ZenStack server-side adapters",
"homepage": "https://zenstack.dev",
Expand Down
2 changes: 1 addition & 1 deletion packages/testtools/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/testtools",
"version": "2.12.1",
"version": "2.12.2",
"description": "ZenStack Test Tools",
"main": "index.js",
"private": true,
Expand Down
116 changes: 116 additions & 0 deletions tests/regression/tests/issue-2028.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import { createPostgresDb, loadSchema } from '@zenstackhq/testtools';

describe('issue 2028', () => {
it('regression', async () => {
const dbUrl = await createPostgresDb('issue-2028');
const { enhance, zodSchemas } = await loadSchema(
`
enum FooType {
Bar
Baz
}

model User {
id String @id @default(cuid())
userFolders UserFolder[]
@@allow('all', true)
}

model Foo {
id String @id @default(cuid())
type FooType

userFolders UserFolder[]

@@delegate(type)
@@allow('all', true)
}

model Bar extends Foo {
name String
}

model Baz extends Foo {
age Int
}

model UserFolder {
id String @id @default(cuid())
userId String
fooId String

user User @relation(fields: [userId], references: [id])
foo Foo @relation(fields: [fooId], references: [id])

@@unique([userId, fooId])
@@allow('all', true)
}
`,
{
fullZod: true,
provider: 'postgresql',
dbUrl,
}
);
// Ensure Zod Schemas don't include the delegate fields
expect(
zodSchemas.objects.UserFolderWhereUniqueInputObjectSchema.safeParse({
userId_delegate_aux_UserFolder_fooId_Bar: {
userId: '1',
fooId: '2',
},
}).success
).toBeFalsy();

expect(
zodSchemas.objects.UserFolderWhereUniqueInputObjectSchema.safeParse({
userId_delegate_aux_UserFolder_fooId_Baz: {
userId: '1',
fooId: '2',
},
}).success
).toBeFalsy();

// Ensure we can query by the CompoundUniqueInput
const db = enhance();
const user = await db.user.create({ data: {} });
const bar = await db.bar.create({ data: { name: 'bar' } });
const baz = await db.baz.create({ data: { age: 1 } });

const userFolderA = await db.userFolder.create({
data: {
userId: user.id,
fooId: bar.id,
},
});

const userFolderB = await db.userFolder.create({
data: {
userId: user.id,
fooId: baz.id,
},
});

await expect(
db.userFolder.findUnique({
where: {
userId_fooId: {
userId: user.id,
fooId: bar.id,
},
},
})
).resolves.toMatchObject(userFolderA);

await expect(
db.userFolder.findUnique({
where: {
userId_fooId: {
userId: user.id,
fooId: baz.id,
},
},
})
).resolves.toMatchObject(userFolderB);
});
});
Loading