Skip to content

merge dev to main (v2.17.0) #2191

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 12 commits into from
Jul 20, 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
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.16.1",
"version": "2.17.0",
"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.16.1"
version = "2.17.0"

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.16.1",
"version": "2.17.0",
"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.16.1",
"version": "2.17.0",
"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.16.1",
"version": "2.17.0",
"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.16.1",
"version": "2.17.0",
"description": "ZenStack plugin and runtime supporting OpenAPI",
"main": "index.js",
"repository": {
Expand Down
21 changes: 15 additions & 6 deletions packages/plugins/openapi/src/rest-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,16 @@ type Policies = ReturnType<typeof analyzePolicies>;
*/
export class RESTfulOpenAPIGenerator extends OpenAPIGeneratorBase {
private warnings: string[] = [];
private modelNameMapping: Record<string, string>;

constructor(protected model: Model, protected options: PluginOptions, protected dmmf: DMMF.Document) {
super(model, options, dmmf);

if (this.options.omitInputDetails !== undefined) {
throw new PluginError(name, '"omitInputDetails" option is not supported for "rest" flavor');
}

this.modelNameMapping = this.getOption('modelNameMapping', {} as Record<string, string>);
}

generate() {
Expand Down Expand Up @@ -126,6 +129,10 @@ export class RESTfulOpenAPIGenerator extends OpenAPIGeneratorBase {
return result;
}

private mapModelName(modelName: string): string {
return this.modelNameMapping[modelName] ?? modelName;
}

private generatePathsForModel(model: DMMF.Model, zmodel: DataModel): OAPI.PathItemObject | undefined {
const result: Record<string, OAPI.PathItemObject> = {};

Expand All @@ -139,9 +146,11 @@ export class RESTfulOpenAPIGenerator extends OpenAPIGeneratorBase {

const resourceMeta = getModelResourceMeta(zmodel);

const modelName = this.mapModelName(model.name);

// GET /resource
// POST /resource
result[`${prefix}/${lowerCaseFirst(model.name)}`] = {
result[`${prefix}/${lowerCaseFirst(modelName)}`] = {
get: this.makeResourceList(zmodel, policies, resourceMeta),
post: this.makeResourceCreate(zmodel, policies, resourceMeta),
};
Expand All @@ -150,10 +159,10 @@ export class RESTfulOpenAPIGenerator extends OpenAPIGeneratorBase {
// PUT /resource/{id}
// PATCH /resource/{id}
// DELETE /resource/{id}
result[`${prefix}/${lowerCaseFirst(model.name)}/{id}`] = {
result[`${prefix}/${lowerCaseFirst(modelName)}/{id}`] = {
get: this.makeResourceFetch(zmodel, policies, resourceMeta),
put: this.makeResourceUpdate(zmodel, policies, `update-${model.name}-put`, resourceMeta),
patch: this.makeResourceUpdate(zmodel, policies, `update-${model.name}-patch`, resourceMeta),
put: this.makeResourceUpdate(zmodel, policies, `update-${modelName}-put`, resourceMeta),
patch: this.makeResourceUpdate(zmodel, policies, `update-${modelName}-patch`, resourceMeta),
delete: this.makeResourceDelete(zmodel, policies, resourceMeta),
};

Expand All @@ -165,14 +174,14 @@ export class RESTfulOpenAPIGenerator extends OpenAPIGeneratorBase {
}

// GET /resource/{id}/{relationship}
const relatedDataPath = `${prefix}/${lowerCaseFirst(model.name)}/{id}/${field.name}`;
const relatedDataPath = `${prefix}/${lowerCaseFirst(modelName)}/{id}/${field.name}`;
let container = result[relatedDataPath];
if (!container) {
container = result[relatedDataPath] = {};
}
container.get = this.makeRelatedFetch(zmodel, field, relationDecl, resourceMeta);

const relationshipPath = `${prefix}/${lowerCaseFirst(model.name)}/{id}/relationships/${field.name}`;
const relationshipPath = `${prefix}/${lowerCaseFirst(modelName)}/{id}/relationships/${field.name}`;
container = result[relationshipPath];
if (!container) {
container = result[relationshipPath] = {};
Expand Down
35 changes: 34 additions & 1 deletion packages/plugins/openapi/tests/openapi-restful.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ model Bar {
}
});

it('options', async () => {
it('common options', async () => {
const { model, dmmf, modelFile } = await loadZModelAndDmmf(`
plugin openapi {
provider = '${normalizePath(path.resolve(__dirname, '../dist'))}'
Expand Down Expand Up @@ -396,6 +396,39 @@ model User {
expect.arrayContaining(['role', 'company'])
);
});

it('works with mapped model name', async () => {
const { model, dmmf, modelFile } = await loadZModelAndDmmf(`
plugin openapi {
provider = '${normalizePath(path.resolve(__dirname, '../dist'))}'
title = 'My Awesome API'
prefix = '/api'
modelNameMapping = {
User: 'myUser'
}
}

model User {
id String @id
posts Post[]
}

model Post {
id String @id
author User @relation(fields: [authorId], references: [id])
authorId String
}
`);

const { name: output } = tmp.fileSync({ postfix: '.yaml' });
const options = buildOptions(model, modelFile, output);
await generate(model, options, dmmf);
console.log('OpenAPI specification generated:', output);
const api = await OpenAPIParser.validate(output);
expect(api.paths?.['/api/myUser']).toBeTruthy();
expect(api.paths?.['/api/user']).toBeFalsy();
expect(api.paths?.['/api/post']).toBeTruthy();
});
});

function buildOptions(model: Model, modelFile: string, output: string, specVersion = '3.0.0') {
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.16.1",
"version": "2.17.0",
"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.16.1",
"version": "2.17.0",
"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.16.1",
"version": "2.17.0",
"description": "ZenStack plugin for tRPC",
"main": "index.js",
"repository": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"postinstall": "nuxt prepare"
},
"dependencies": {
"@prisma/client": "6.10.x",
"@prisma/client": "6.11.x",
"@trpc/client": "^10.45.2",
"@trpc/server": "^10.45.2",
"nuxt": "^3.14.1592",
Expand All @@ -21,7 +21,7 @@
},
"devDependencies": {
"esbuild": "^0.24.0",
"prisma": "6.10.x",
"prisma": "6.11.x",
"typescript": "^5.6.2",
"vue-tsc": "^2.1.10"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"postinstall": "nuxt prepare"
},
"dependencies": {
"@prisma/client": "6.10.x",
"@prisma/client": "6.11.x",
"@trpc/client": "^11.0.0-rc.563",
"@trpc/server": "^11.0.0-rc.563",
"nuxt": "^3.14.1592",
Expand All @@ -21,7 +21,7 @@
},
"devDependencies": {
"esbuild": "^0.24.0",
"prisma": "6.10.x",
"prisma": "6.11.x",
"typescript": "^5.6.2",
"vue-tsc": "^2.1.10"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/trpc/tests/projects/t3-trpc-v11/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"start": "next start"
},
"dependencies": {
"@prisma/client": "6.10.x",
"@prisma/client": "6.11.x",
"@t3-oss/env-nextjs": "^0.10.1",
"@tanstack/react-query": "^5.50.0",
"@trpc/client": "^11.0.0-rc.446",
Expand All @@ -39,7 +39,7 @@
"@typescript-eslint/parser": "^8.1.0",
"eslint": "^8.57.0",
"eslint-config-next": "^14.2.4",
"prisma": "6.10.x",
"prisma": "6.11.x",
"typescript": "^5.5.3"
},
"ct3aMetadata": {
Expand Down
4 changes: 2 additions & 2 deletions 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.16.1",
"version": "2.17.0",
"description": "Runtime of ZenStack for both client-side and server-side environments.",
"repository": {
"type": "git",
Expand Down Expand Up @@ -114,7 +114,7 @@
"zod-validation-error": "^1.5.0"
},
"peerDependencies": {
"@prisma/client": "5.0.0 - 6.10.x"
"@prisma/client": "5.0.0 - 6.11.x"
},
"author": {
"name": "ZenStack Team"
Expand Down
6 changes: 3 additions & 3 deletions 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.16.1",
"version": "2.17.0",
"author": {
"name": "ZenStack Team"
},
Expand Down Expand Up @@ -118,10 +118,10 @@
"zod-validation-error": "^1.5.0"
},
"peerDependencies": {
"prisma": "5.0.0 - 6.10.x"
"prisma": "5.0.0 - 6.11.x"
},
"devDependencies": {
"@prisma/client": "6.10.x",
"@prisma/client": "6.11.x",
"@types/async-exit-hook": "^2.0.0",
"@types/pluralize": "^0.0.29",
"@types/semver": "^7.3.13",
Expand Down
Loading
Loading