Skip to content
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

merge dev to main (v2.7.0) #1782

Merged
merged 18 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
b4418ac
feat(server): implementing hono adapter (#1739)
svetch Sep 30, 2024
8cbda73
RESTApiHandler support compound ids (@@id) (#1754)
thomassnielsen Oct 7, 2024
2a8f4df
feat(trpc): support client helpers for Nuxt (#1762)
ymc9 Oct 8, 2024
a2c78a1
OpenApi @@id support (#1757)
thomassnielsen Oct 8, 2024
2d42606
fix: generated code fails to compile when prisma's output path overla…
ymc9 Oct 8, 2024
a800fe6
fix: generated prisma schema contains error when using "@@unique" wit…
ymc9 Oct 9, 2024
fc940eb
fix(delegate): remove `createManyAndReturn` API from delegate model c…
ymc9 Oct 9, 2024
374e962
fix(hooks): support optimistic update for "upsert" (#1767)
ymc9 Oct 9, 2024
aae9b60
fix(policy): allow `auth().` calls in filter functions (#1771)
ymc9 Oct 10, 2024
178f697
fix(tanstack-query): non-zenstack queries are accidentally visited du…
ymc9 Oct 14, 2024
383b8fe
feat: create Zod's `default` function for entity's booleans (#1773)
Arkanii Oct 14, 2024
ff997e7
Mark openapi attributes as required for reads (#1772)
thomassnielsen Oct 14, 2024
4f00cf1
fix(delegate): policies inherited from delegate base models are not i…
ymc9 Oct 15, 2024
8a5e25f
chore: upgrade to Prisma 5.21 (#1777)
ymc9 Oct 15, 2024
f7ccc89
chore: bump version (#1778)
ymc9 Oct 15, 2024
d83b7ee
fix: VSCode extension fails to resolve imports from npm packages in p…
ymc9 Oct 15, 2024
c0ab830
fix(server): pass custom logger to api handler (#1783)
ymc9 Oct 16, 2024
4fc4cf7
fix(server): rest handler not returning correct id when model with co…
ymc9 Oct 16, 2024
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.6.2",
"version": "2.7.0",
"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 = "2.6.2"
version = "2.7.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.6.2",
"version": "2.7.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.6.2",
"version": "2.7.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.6.2",
"version": "2.7.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.6.2",
"version": "2.7.0",
"description": "ZenStack plugin and runtime supporting OpenAPI",
"main": "index.js",
"repository": {
Expand Down
16 changes: 12 additions & 4 deletions packages/plugins/openapi/src/rest-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -409,14 +409,17 @@ export class RESTfulOpenAPIGenerator extends OpenAPIGeneratorBase {
private generateFilterParameters(model: DataModel) {
const result: OAPI.ParameterObject[] = [];

const hasMultipleIds = model.fields.filter((f) => isIdField(f)).length > 1;

for (const field of model.fields) {
if (isForeignKeyField(field)) {
// no filtering with foreign keys because one can filter
// directly on the relationship
continue;
}

if (isIdField(field)) {
// For multiple ids, make each id field filterable like a regular field
if (isIdField(field) && !hasMultipleIds) {
// id filter
result.push(this.makeFilterParameter(field, 'id', 'Id filter'));
continue;
Expand Down Expand Up @@ -843,7 +846,9 @@ export class RESTfulOpenAPIGenerator extends OpenAPIGeneratorBase {
}

private generateModelEntity(model: DataModel, mode: 'read' | 'create' | 'update'): OAPI.SchemaObject {
const fields = model.fields.filter((f) => !isIdField(f));
const idFields = model.fields.filter((f) => isIdField(f));
// For compound ids, each component is also exposed as a separate field
const fields = idFields.length > 1 ? model.fields : model.fields.filter((f) => !isIdField(f));

const attributes: Record<string, OAPI.SchemaObject> = {};
const relationships: Record<string, OAPI.ReferenceObject | OAPI.SchemaObject> = {};
Expand All @@ -869,6 +874,9 @@ export class RESTfulOpenAPIGenerator extends OpenAPIGeneratorBase {
!(isDataModel(field.$resolvedType?.decl) && field.type.array)
) {
required.push(field.name);
} else if (mode === 'read') {
// Until we support sparse fieldsets, all fields are required for read operations
required.push(field.name);
}
}
}
Expand All @@ -886,8 +894,8 @@ export class RESTfulOpenAPIGenerator extends OpenAPIGeneratorBase {

if (mode === 'create') {
// 'id' is required if there's no default value
const idField = model.fields.find((f) => isIdField(f));
if (idField && !hasAttribute(idField, '@default')) {
const idFields = model.fields.filter((f) => isIdField(f));
if (idFields.length && idFields.every((f) => !hasAttribute(f, '@default'))) {
properties = { id: { type: 'string' }, ...properties };
toplevelRequired.unshift('id');
}
Expand Down
Loading
Loading