Skip to content
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
15 changes: 15 additions & 0 deletions .github/workflows/github-releases-to-discord.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
on:
release:
types: [published]
jobs:
github-releases-to-discord:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Github Releases To Discord
uses: SethCohen/github-releases-to-discord@v1.13.1
with:
webhook_url: ${{ secrets.RELEASE_TO_DISCORD_WEBHOOK_URL }}
avatar_url: 'https://cdn.discordapp.com/avatars/1297059323314176051/df91181b3f1cf0ef1592fbe18e0962d7.webp?size=160'
reduce_headings: true
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ The following diagram gives a high-level architecture overview of ZenStack.
- [Fastify](https://zenstack.dev/docs/reference/server-adapters/fastify)
- [ExpressJS](https://zenstack.dev/docs/reference/server-adapters/express)
- [NestJS](https://zenstack.dev/docs/reference/server-adapters/nestjs)
- [Hono](https://zenstack.dev/docs/reference/server-adapters/hono)
- 🙋🏻 [Request for an adapter](https://discord.gg/Ykhr738dUe)

### Prisma schema extensions
Expand Down
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.7.2",
"version": "2.7.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 = "2.7.2"
version = "2.7.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": "2.7.2",
"version": "2.7.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": "2.7.2",
"version": "2.7.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": "2.7.2",
"version": "2.7.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": "2.7.2",
"version": "2.7.3",
"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.7.2",
"version": "2.7.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": "2.7.2",
"version": "2.7.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": "2.7.2",
"version": "2.7.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": "2.7.2",
"version": "2.7.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": "FullStack enhancement for Prisma ORM: seamless integration from database to UI",
"version": "2.7.2",
"version": "2.7.3",
"author": {
"name": "ZenStack Team"
},
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": "2.7.2",
"version": "2.7.3",
"description": "ZenStack plugin development SDK",
"main": "index.js",
"scripts": {
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.7.2",
"version": "2.7.3",
"displayName": "ZenStack Server-side Adapters",
"description": "ZenStack server-side adapters",
"homepage": "https://zenstack.dev",
Expand Down
6 changes: 6 additions & 0 deletions packages/server/src/api/rest/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,9 @@ class RequestHandler extends APIHandlerBase {
}
}

// include IDs of relation fields so that they can be serialized.
this.includeRelationshipIds(type, createPayload, 'include');

const entity = await prisma[type].create(createPayload);
return {
status: 201,
Expand Down Expand Up @@ -970,6 +973,9 @@ class RequestHandler extends APIHandlerBase {
}
}

// include IDs of relation fields so that they can be serialized.
this.includeRelationshipIds(type, updatePayload, 'include');

const entity = await prisma[type].update(updatePayload);
return {
status: 200,
Expand Down
98 changes: 97 additions & 1 deletion packages/server/tests/api/rest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,40 @@ describe('REST server tests', () => {
});
});

it('returns an empty data array when loading empty related resources', async () => {
// Create a user first
await prisma.user.create({
data: { myId: 'user1', email: 'user1@abc.com' },
});

const r = await handler({
method: 'get',
path: '/user/user1',
prisma,
});

expect(r.status).toBe(200);
expect(r.body).toMatchObject({
data: {
type: 'user',
id: 'user1',
attributes: { email: 'user1@abc.com' },
links: {
self: 'http://localhost/api/user/user1',
},
relationships: {
posts: {
links: {
self: 'http://localhost/api/user/user1/relationships/posts',
related: 'http://localhost/api/user/user1/posts',
},
data: [],
},
},
},
});
});

it('fetches a related resource with a compound ID', async () => {
await prisma.user.create({
data: {
Expand Down Expand Up @@ -1427,7 +1461,21 @@ describe('REST server tests', () => {
expect(r.status).toBe(201);
expect(r.body).toMatchObject({
jsonapi: { version: '1.1' },
data: { type: 'user', id: 'user1', attributes: { email: 'user1@abc.com' } },
data: {
type: 'user',
id: 'user1',
attributes: { email: 'user1@abc.com' },
relationships: {
posts: {
links: {
self: 'http://localhost/api/user/user1/relationships/posts',
related: 'http://localhost/api/user/user1/posts',
},
data: [],
},
},
links: { self: 'http://localhost/api/user/user1' },
},
});
});

Expand Down Expand Up @@ -1785,6 +1833,54 @@ describe('REST server tests', () => {
});
});

it("returns an empty data list in relationships if it's empty", async () => {
await prisma.user.create({
data: {
myId: 'user1',
email: 'user1@abc.com',
},
});

const r = await handler({
method: 'put',
path: '/user/user1',
query: {},
requestBody: {
data: {
type: 'user',
attributes: { email: 'user2@abc.com' },
},
},
prisma,
});

expect(r.status).toBe(200);
expect(r.body).toMatchObject({
links: {
self: 'http://localhost/api/user/user1',
},
data: {
type: 'user',
id: 'user1',
attributes: {
email: 'user2@abc.com',
},
links: {
self: 'http://localhost/api/user/user1',
},
relationships: {
posts: {
links: {
self: 'http://localhost/api/user/user1/relationships/posts',
related: 'http://localhost/api/user/user1/posts',
},
data: [],
},
},
},
});
});

it('returns 404 if the user does not exist', async () => {
const r = await handler({
method: 'put',
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.7.2",
"version": "2.7.3",
"description": "ZenStack Test Tools",
"main": "index.js",
"private": true,
Expand Down
Loading