Skip to content

Commit

Permalink
merge dev to main (v2.11.4) (#1966)
Browse files Browse the repository at this point in the history
  • Loading branch information
ymc9 authored Jan 17, 2025
2 parents b220213 + da50917 commit ff393da
Show file tree
Hide file tree
Showing 16 changed files with 91 additions and 59 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.11.3",
"version": "2.11.4",
"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.11.3"
version = "2.11.4"

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.11.3",
"version": "2.11.4",
"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.11.3",
"version": "2.11.4",
"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.11.3",
"version": "2.11.4",
"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.11.3",
"version": "2.11.4",
"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.11.3",
"version": "2.11.4",
"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.11.3",
"version": "2.11.4",
"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.11.3",
"version": "2.11.4",
"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.11.3",
"version": "2.11.4",
"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.11.3",
"version": "2.11.4",
"author": {
"name": "ZenStack Team"
},
Expand Down
97 changes: 54 additions & 43 deletions packages/schema/tests/schema/all-features.zmodel
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ abstract model Base {
* Model for a space in which users can collaborate on Lists and Todos
*/
model Space extends Base {
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
name String @length(4, 50)
slug String @length(4, 16)
owner User? @relation(fields: [ownerId], references: [id])
ownerId String?
members SpaceUser[]
lists List[]
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
name String @length(4, 50)
slug String @length(4, 16)
owner User? @relation(fields: [ownerId], references: [id])
ownerId String?
members SpaceUser[]
lists List[]
unsupported Unsupported('foo')

// require login
Expand All @@ -66,14 +66,14 @@ model Space extends Base {
* Model representing membership of a user in a space
*/
model SpaceUser {
id String @id @default(uuid())
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
space Space @relation(fields: [spaceId], references: [id], onDelete: Cascade)
spaceId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
userId String
role UserRole
space Space @relation(fields: [spaceId], references: [id], onDelete: Cascade)
spaceId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
userId String
role UserRole
@@unique([userId, spaceId])

// require login
Expand All @@ -92,18 +92,18 @@ model SpaceUser {
* Model for a user
*/
model User {
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
email String @unique @email
password String? @password @omit
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
email String @unique @email
password String? @password @omit
emailVerified DateTime?
name String?
ownedSpaces Space[]
spaces SpaceUser[]
image String? @url
lists List[]
todos Todo[]
name String?
ownedSpaces Space[]
spaces SpaceUser[]
image String? @url
lists List[]
todos Todo[]

// can be created by anyone, even not logged in
@@allow('create', true)
Expand All @@ -119,16 +119,16 @@ model User {
* Model for a Todo list
*/
model List {
id String @id @default(uuid())
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
space Space @relation(fields: [spaceId], references: [id], onDelete: Cascade)
spaceId String
owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
ownerId String
title String @length(1, 100)
private Boolean @default(false)
todos Todo[]
space Space @relation(fields: [spaceId], references: [id], onDelete: Cascade)
spaceId String
owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
ownerId String
title String @length(1, 100)
private Boolean @default(false)
todos Todo[]

// require login
@@deny('all', auth() == null)
Expand All @@ -151,14 +151,14 @@ model List {
* Model for a single Todo
*/
model Todo {
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
ownerId String
list List @relation(fields: [listId], references: [id], onDelete: Cascade)
listId String
title String @length(1, 100)
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
ownerId String
list List @relation(fields: [listId], references: [id], onDelete: Cascade)
listId String
title String @length(1, 100)
completedAt DateTime?

// require login
Expand All @@ -173,7 +173,18 @@ model Todo {
}

view SpaceWithMembers {
id String @unique
id String @unique
name String
slug String
}

model Image {
id Int @id @default(autoincrement())
metadata Json
}

type Metadata {
width Int
height Int
format String
}
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.11.3",
"version": "2.11.4",
"description": "ZenStack plugin development SDK",
"main": "index.js",
"scripts": {
Expand Down
25 changes: 23 additions & 2 deletions packages/sdk/src/zmodel-code-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ import {
StringLiteral,
ThisExpr,
UnaryExpr,
TypeDef,
TypeDefField,
TypeDefFieldType,
} from './ast';
import { resolved } from './utils';

Expand Down Expand Up @@ -177,10 +180,10 @@ ${ast.fields.map((x) => this.indent + this.generate(x)).join('\n')}${
}`;
}

private fieldType(type: DataModelFieldType) {
private fieldType(type: DataModelFieldType | TypeDefFieldType) {
const baseType = type.type
? type.type
: type.unsupported
: type.$type == 'DataModelFieldType' && type.unsupported
? 'Unsupported(' + this.generate(type.unsupported.value) + ')'
: type.reference?.$refText;
return `${baseType}${type.array ? '[]' : ''}${type.optional ? '?' : ''}`;
Expand Down Expand Up @@ -322,6 +325,24 @@ ${ast.fields.map((x) => this.indent + this.generate(x)).join('\n')}${
return `${ast.type ?? ast.reference?.$refText}${ast.array ? '[]' : ''}`;
}

@gen(TypeDef)
private _generateTypeDef(ast: TypeDef) {
return `type ${ast.name} {
${ast.fields.map((x) => this.indent + this.generate(x)).join('\n')}${
ast.attributes.length > 0
? '\n\n' + ast.attributes.map((x) => this.indent + this.generate(x)).join('\n')
: ''
}
}`;
}

@gen(TypeDefField)
private _generateTypeDefField(ast: TypeDefField) {
return `${ast.name} ${this.fieldType(ast.type)}${
ast.attributes.length > 0 ? ' ' + ast.attributes.map((x) => this.generate(x)).join(' ') : ''
}`;
}

private argument(ast: Argument) {
return this.generate(ast.value);
}
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.11.3",
"version": "2.11.4",
"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.11.3",
"version": "2.11.4",
"description": "ZenStack Test Tools",
"main": "index.js",
"private": true,
Expand Down

0 comments on commit ff393da

Please sign in to comment.