Skip to content

Commit

Permalink
merge dev to main (v1.12.3) (#1247)
Browse files Browse the repository at this point in the history
  • Loading branch information
ymc9 authored Apr 12, 2024
2 parents 254ef39 + 8137481 commit 2ce8b9b
Show file tree
Hide file tree
Showing 22 changed files with 185 additions and 25 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": "1.12.2",
"version": "1.12.3",
"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 = "1.12.2"
version = "1.12.3"

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": "1.12.2",
"version": "1.12.3",
"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": "1.12.2",
"version": "1.12.3",
"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": "1.12.2",
"version": "1.12.3",
"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": "1.12.2",
"version": "1.12.3",
"description": "ZenStack plugin and runtime supporting OpenAPI",
"main": "index.js",
"repository": {
Expand Down
10 changes: 9 additions & 1 deletion packages/plugins/openapi/src/rpc-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,15 @@ export class RPCOpenAPIGenerator extends OpenAPIGeneratorBase {
type: 'object',
required: ['data'],
properties: {
data: this.ref(`${modelName}CreateManyInput`),
data: this.oneOf(
this.ref(`${modelName}CreateManyInput`),
this.array(this.ref(`${modelName}CreateManyInput`))
),
skipDuplicates: {
type: 'boolean',
description:
'Do not insert records with unique fields or ID fields that already exist.',
},
meta: this.ref('_Meta'),
},
},
Expand Down
30 changes: 27 additions & 3 deletions packages/plugins/openapi/tests/baseline/rpc-3.0.0.baseline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3194,7 +3194,15 @@ components:
- data
properties:
data:
$ref: '#/components/schemas/UserCreateManyInput'
oneOf:
- $ref: '#/components/schemas/UserCreateManyInput'
- type: array
items:
$ref: '#/components/schemas/UserCreateManyInput'
skipDuplicates:
type: boolean
description: Do not insert records with unique fields or ID fields that already
exist.
meta:
$ref: '#/components/schemas/_Meta'
UserFindUniqueArgs:
Expand Down Expand Up @@ -3374,7 +3382,15 @@ components:
- data
properties:
data:
$ref: '#/components/schemas/ProfileCreateManyInput'
oneOf:
- $ref: '#/components/schemas/ProfileCreateManyInput'
- type: array
items:
$ref: '#/components/schemas/ProfileCreateManyInput'
skipDuplicates:
type: boolean
description: Do not insert records with unique fields or ID fields that already
exist.
meta:
$ref: '#/components/schemas/_Meta'
ProfileFindUniqueArgs:
Expand Down Expand Up @@ -3554,7 +3570,15 @@ components:
- data
properties:
data:
$ref: '#/components/schemas/Post_ItemCreateManyInput'
oneOf:
- $ref: '#/components/schemas/Post_ItemCreateManyInput'
- type: array
items:
$ref: '#/components/schemas/Post_ItemCreateManyInput'
skipDuplicates:
type: boolean
description: Do not insert records with unique fields or ID fields that already
exist.
meta:
$ref: '#/components/schemas/_Meta'
Post_ItemFindUniqueArgs:
Expand Down
30 changes: 27 additions & 3 deletions packages/plugins/openapi/tests/baseline/rpc-3.1.0.baseline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3248,7 +3248,15 @@ components:
- data
properties:
data:
$ref: '#/components/schemas/UserCreateManyInput'
oneOf:
- $ref: '#/components/schemas/UserCreateManyInput'
- type: array
items:
$ref: '#/components/schemas/UserCreateManyInput'
skipDuplicates:
type: boolean
description: Do not insert records with unique fields or ID fields that already
exist.
meta:
$ref: '#/components/schemas/_Meta'
UserFindUniqueArgs:
Expand Down Expand Up @@ -3428,7 +3436,15 @@ components:
- data
properties:
data:
$ref: '#/components/schemas/ProfileCreateManyInput'
oneOf:
- $ref: '#/components/schemas/ProfileCreateManyInput'
- type: array
items:
$ref: '#/components/schemas/ProfileCreateManyInput'
skipDuplicates:
type: boolean
description: Do not insert records with unique fields or ID fields that already
exist.
meta:
$ref: '#/components/schemas/_Meta'
ProfileFindUniqueArgs:
Expand Down Expand Up @@ -3608,7 +3624,15 @@ components:
- data
properties:
data:
$ref: '#/components/schemas/Post_ItemCreateManyInput'
oneOf:
- $ref: '#/components/schemas/Post_ItemCreateManyInput'
- type: array
items:
$ref: '#/components/schemas/Post_ItemCreateManyInput'
skipDuplicates:
type: boolean
description: Do not insert records with unique fields or ID fields that already
exist.
meta:
$ref: '#/components/schemas/_Meta'
Post_ItemFindUniqueArgs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2017,7 +2017,15 @@ components:
- data
properties:
data:
$ref: '#/components/schemas/FooCreateManyInput'
oneOf:
- $ref: '#/components/schemas/FooCreateManyInput'
- type: array
items:
$ref: '#/components/schemas/FooCreateManyInput'
skipDuplicates:
type: boolean
description: Do not insert records with unique fields or ID fields that already
exist.
meta:
$ref: '#/components/schemas/_Meta'
FooFindUniqueArgs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2049,7 +2049,15 @@ components:
- data
properties:
data:
$ref: '#/components/schemas/FooCreateManyInput'
oneOf:
- $ref: '#/components/schemas/FooCreateManyInput'
- type: array
items:
$ref: '#/components/schemas/FooCreateManyInput'
skipDuplicates:
type: boolean
description: Do not insert records with unique fields or ID fields that already
exist.
meta:
$ref: '#/components/schemas/_Meta'
FooFindUniqueArgs:
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": "1.12.2",
"version": "1.12.3",
"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": "1.12.2",
"version": "1.12.3",
"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": "1.12.2",
"version": "1.12.3",
"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": "1.12.2",
"version": "1.12.3",
"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": "Build scalable web apps with minimum code by defining authorization and validation rules inside the data schema that closer to the database",
"version": "1.12.2",
"version": "1.12.3",
"author": {
"name": "ZenStack Team"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/schema/src/plugins/zod/transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ export const ${this.name}ObjectSchema: SchemaType = ${schema} as SchemaType;`;
imports.push(
`import { ${modelName}CreateManyInputObjectSchema } from '../objects/${modelName}CreateManyInput.schema'`
);
codeBody += `createMany: z.object({ data: z.union([${modelName}CreateManyInputObjectSchema, z.array(${modelName}CreateManyInputObjectSchema)]) }),`;
codeBody += `createMany: z.object({ data: z.union([${modelName}CreateManyInputObjectSchema, z.array(${modelName}CreateManyInputObjectSchema)]), skipDuplicates: z.boolean().optional() }),`;
operations.push(['createMany', origModelName]);
}

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": "1.12.2",
"version": "1.12.3",
"description": "ZenStack plugin development SDK",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/model-meta-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ function getBackLink(field: DataModelField) {
}

function getRelationName(field: DataModelField) {
const relAttr = field.attributes.find((attr) => attr.decl.ref?.name === 'relation');
const relAttr = field.attributes.find((attr) => attr.decl.ref?.name === '@relation');
const relName = relAttr && relAttr.args?.[0] && getLiteral<string>(relAttr.args?.[0].value);
return relName;
}
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": "1.12.2",
"version": "1.12.3",
"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": "1.12.2",
"version": "1.12.3",
"description": "ZenStack Test Tools",
"main": "index.js",
"private": true,
Expand Down
88 changes: 88 additions & 0 deletions tests/integration/tests/regression/issue-1241.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import { loadSchema } from '@zenstackhq/testtools';
import { randomBytes } from 'crypto';

describe('issue 1241', () => {
it('regression', async () => {
const { enhance, prisma } = await loadSchema(
`
model User {
id String @id @default(uuid())
todos Todo[]
@@auth
@@allow('all', true)
}
model Todo {
id String @id @default(uuid())
user_id String
user User @relation(fields: [user_id], references: [id])
images File[] @relation("todo_images")
documents File[] @relation("todo_documents")
@@allow('all', true)
}
model File {
id String @id @default(uuid())
s3_key String @unique
label String
todo_image_id String?
todo_image Todo? @relation("todo_images", fields: [todo_image_id], references: [id])
todo_document_id String?
todo_document Todo? @relation("todo_documents", fields: [todo_document_id], references: [id])
@@allow('all', true)
}
`,
{ logPrismaQuery: true }
);

const user = await prisma.user.create({
data: {},
});
await prisma.todo.create({
data: {
user_id: user.id,

images: {
create: new Array(3).fill(null).map((_, i) => ({
s3_key: randomBytes(8).toString('hex'),
label: `img-label-${i + 1}`,
})),
},

documents: {
create: new Array(3).fill(null).map((_, i) => ({
s3_key: randomBytes(8).toString('hex'),
label: `doc-label-${i + 1}`,
})),
},
},
});

const db = enhance();

const todo = await db.todo.findFirst({ where: {}, include: { documents: true } });
await expect(
db.todo.update({
where: { id: todo.id },
data: {
documents: {
update: todo.documents.map((doc: any) => {
return {
where: { s3_key: doc.s3_key },
data: { label: 'updated' },
};
}),
},
},
include: { documents: true },
})
).toResolveTruthy();
});
});

0 comments on commit 2ce8b9b

Please sign in to comment.