Skip to content

Commit d4fb5ab

Browse files
authored
merge dev to main (v2.12.2) (#2032)
2 parents 8934679 + e8694e6 commit d4fb5ab

File tree

18 files changed

+135
-18
lines changed

18 files changed

+135
-18
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ Thank you for your generous support!
238238

239239
<table>
240240
<tr>
241+
<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>
241242
<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>
242243
<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>
243244
<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>

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "zenstack-monorepo",
3-
"version": "2.12.1",
3+
"version": "2.12.2",
44
"description": "",
55
"scripts": {
66
"build": "pnpm -r --filter=\"!./packages/ide/*\" build",

packages/ide/jetbrains/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ plugins {
99
}
1010

1111
group = "dev.zenstack"
12-
version = "2.12.1"
12+
version = "2.12.2"
1313

1414
repositories {
1515
mavenCentral()

packages/ide/jetbrains/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jetbrains",
3-
"version": "2.12.1",
3+
"version": "2.12.2",
44
"displayName": "ZenStack JetBrains IDE Plugin",
55
"description": "ZenStack JetBrains IDE plugin",
66
"homepage": "https://zenstack.dev",

packages/language/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zenstackhq/language",
3-
"version": "2.12.1",
3+
"version": "2.12.2",
44
"displayName": "ZenStack modeling language compiler",
55
"description": "ZenStack modeling language compiler",
66
"homepage": "https://zenstack.dev",

packages/misc/redwood/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@zenstackhq/redwood",
33
"displayName": "ZenStack RedwoodJS Integration",
4-
"version": "2.12.1",
4+
"version": "2.12.2",
55
"description": "CLI and runtime for integrating ZenStack with RedwoodJS projects.",
66
"repository": {
77
"type": "git",

packages/plugins/openapi/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@zenstackhq/openapi",
33
"displayName": "ZenStack Plugin and Runtime for OpenAPI",
4-
"version": "2.12.1",
4+
"version": "2.12.2",
55
"description": "ZenStack plugin and runtime supporting OpenAPI",
66
"main": "index.js",
77
"repository": {

packages/plugins/swr/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@zenstackhq/swr",
33
"displayName": "ZenStack plugin for generating SWR hooks",
4-
"version": "2.12.1",
4+
"version": "2.12.2",
55
"description": "ZenStack plugin for generating SWR hooks",
66
"main": "index.js",
77
"repository": {

packages/plugins/tanstack-query/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@zenstackhq/tanstack-query",
33
"displayName": "ZenStack plugin for generating tanstack-query hooks",
4-
"version": "2.12.1",
4+
"version": "2.12.2",
55
"description": "ZenStack plugin for generating tanstack-query hooks",
66
"main": "index.js",
77
"exports": {

packages/plugins/trpc/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@zenstackhq/trpc",
33
"displayName": "ZenStack plugin for tRPC",
4-
"version": "2.12.1",
4+
"version": "2.12.2",
55
"description": "ZenStack plugin for tRPC",
66
"main": "index.js",
77
"repository": {

packages/runtime/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@zenstackhq/runtime",
33
"displayName": "ZenStack Runtime Library",
4-
"version": "2.12.1",
4+
"version": "2.12.2",
55
"description": "Runtime of ZenStack for both client-side and server-side environments.",
66
"repository": {
77
"type": "git",

packages/schema/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"publisher": "zenstack",
44
"displayName": "ZenStack Language Tools",
55
"description": "FullStack enhancement for Prisma ORM: seamless integration from database to UI",
6-
"version": "2.12.1",
6+
"version": "2.12.2",
77
"author": {
88
"name": "ZenStack Team"
99
},

packages/schema/src/plugins/enhancer/enhance/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -565,10 +565,10 @@ export type Enhanced<Client> =
565565
const structure = iface.getStructure();
566566

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

570570
// filter out aux methods
571-
structure.methods = structure.methods?.filter((m) => !m.name.startsWith(DELEGATE_AUX_RELATION_PREFIX));
571+
structure.methods = structure.methods?.filter((m) => !m.name.includes(DELEGATE_AUX_RELATION_PREFIX));
572572

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

856856
private saveSourceFile(sf: SourceFile) {

packages/schema/src/plugins/zod/generator.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ export class ZodSchemaGenerator {
244244
const moduleNames: string[] = [];
245245
for (let i = 0; i < inputObjectTypes.length; i += 1) {
246246
// exclude delegate aux fields
247-
const fields = inputObjectTypes[i]?.fields?.filter((f) => !f.name.startsWith(DELEGATE_AUX_RELATION_PREFIX));
247+
const fields = inputObjectTypes[i]?.fields?.filter((f) => !f.name.includes(DELEGATE_AUX_RELATION_PREFIX));
248248
const name = inputObjectTypes[i]?.name;
249249

250250
if (!generateUnchecked && name.includes('Unchecked')) {

packages/sdk/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zenstackhq/sdk",
3-
"version": "2.12.1",
3+
"version": "2.12.2",
44
"description": "ZenStack plugin development SDK",
55
"main": "index.js",
66
"scripts": {

packages/server/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zenstackhq/server",
3-
"version": "2.12.1",
3+
"version": "2.12.2",
44
"displayName": "ZenStack Server-side Adapters",
55
"description": "ZenStack server-side adapters",
66
"homepage": "https://zenstack.dev",

packages/testtools/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zenstackhq/testtools",
3-
"version": "2.12.1",
3+
"version": "2.12.2",
44
"description": "ZenStack Test Tools",
55
"main": "index.js",
66
"private": true,
+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
import { createPostgresDb, loadSchema } from '@zenstackhq/testtools';
2+
3+
describe('issue 2028', () => {
4+
it('regression', async () => {
5+
const dbUrl = await createPostgresDb('issue-2028');
6+
const { enhance, zodSchemas } = await loadSchema(
7+
`
8+
enum FooType {
9+
Bar
10+
Baz
11+
}
12+
13+
model User {
14+
id String @id @default(cuid())
15+
userFolders UserFolder[]
16+
@@allow('all', true)
17+
}
18+
19+
model Foo {
20+
id String @id @default(cuid())
21+
type FooType
22+
23+
userFolders UserFolder[]
24+
25+
@@delegate(type)
26+
@@allow('all', true)
27+
}
28+
29+
model Bar extends Foo {
30+
name String
31+
}
32+
33+
model Baz extends Foo {
34+
age Int
35+
}
36+
37+
model UserFolder {
38+
id String @id @default(cuid())
39+
userId String
40+
fooId String
41+
42+
user User @relation(fields: [userId], references: [id])
43+
foo Foo @relation(fields: [fooId], references: [id])
44+
45+
@@unique([userId, fooId])
46+
@@allow('all', true)
47+
}
48+
`,
49+
{
50+
fullZod: true,
51+
provider: 'postgresql',
52+
dbUrl,
53+
}
54+
);
55+
// Ensure Zod Schemas don't include the delegate fields
56+
expect(
57+
zodSchemas.objects.UserFolderWhereUniqueInputObjectSchema.safeParse({
58+
userId_delegate_aux_UserFolder_fooId_Bar: {
59+
userId: '1',
60+
fooId: '2',
61+
},
62+
}).success
63+
).toBeFalsy();
64+
65+
expect(
66+
zodSchemas.objects.UserFolderWhereUniqueInputObjectSchema.safeParse({
67+
userId_delegate_aux_UserFolder_fooId_Baz: {
68+
userId: '1',
69+
fooId: '2',
70+
},
71+
}).success
72+
).toBeFalsy();
73+
74+
// Ensure we can query by the CompoundUniqueInput
75+
const db = enhance();
76+
const user = await db.user.create({ data: {} });
77+
const bar = await db.bar.create({ data: { name: 'bar' } });
78+
const baz = await db.baz.create({ data: { age: 1 } });
79+
80+
const userFolderA = await db.userFolder.create({
81+
data: {
82+
userId: user.id,
83+
fooId: bar.id,
84+
},
85+
});
86+
87+
const userFolderB = await db.userFolder.create({
88+
data: {
89+
userId: user.id,
90+
fooId: baz.id,
91+
},
92+
});
93+
94+
await expect(
95+
db.userFolder.findUnique({
96+
where: {
97+
userId_fooId: {
98+
userId: user.id,
99+
fooId: bar.id,
100+
},
101+
},
102+
})
103+
).resolves.toMatchObject(userFolderA);
104+
105+
await expect(
106+
db.userFolder.findUnique({
107+
where: {
108+
userId_fooId: {
109+
userId: user.id,
110+
fooId: baz.id,
111+
},
112+
},
113+
})
114+
).resolves.toMatchObject(userFolderB);
115+
});
116+
});

0 commit comments

Comments
 (0)