Skip to content

Commit 2966af1

Browse files
authored
Merge pull request #529 from zenstackhq/dev
merge dev to main (v3.0.0)
2 parents e371ec9 + 6891412 commit 2966af1

File tree

35 files changed

+292
-57
lines changed

35 files changed

+292
-57
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ dist
88
*.tgz
99
.pnpm-store
1010
*.vsix
11+
.DS_Store

CONTRIBUTING.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Contributing to ZenStack
2+
3+
I want to thank you first for considering contributing to ZenStack 🙏🏻. It's people like you who make ZenStack a better toolkit that benefits more developers!
4+
5+
Before you start working on anything major, please make sure to open an issue or discuss with us in our [Discord](https://discord.gg/Ykhr738dUe) first. This will help ensure your work aligns with the project's goals and avoid duplication of effort.
6+
7+
## Prerequisites
8+
9+
- Node.js: v20 or above
10+
- PNPM: as specified in [package.json](./package.json)
11+
12+
Test cases are run against both SQLite and Postgres. You should have a postgres server (16 or above) running (either natively or via Docker). The default connection is:
13+
14+
`postgresql://${TEST_PG_USER}:${TEST_PG_PASSWORD}$@${TEST_PG_HOST}$:${TEST_PG_PORT}`
15+
16+
The default values for the environment variables (if not set) are:
17+
18+
- `TEST_PG_HOST`: localhost
19+
- `TEST_PG_PORT`: 5432
20+
- `TEST_PG_USER`: postgres
21+
- `TEST_PG_PASSWORD`: postgres
22+
23+
## Get started
24+
25+
1. Install dependencies: `pnpm install`
26+
2. Build all packages: `pnpm build`
27+
3. Run all tests: `pnpm test`
28+
29+
## Development workflow
30+
31+
ZenStack adopts a very simple development workflow:
32+
33+
1. Changes should be made in branches created off the "dev" branch.
34+
35+
1. Non-trivial changes should include test cases. Bug-fixes should include regression tests that refer to GitHub issues if applicable.
36+
37+
1. After coding and testing, create a PR to merge the changes into the "dev" branch.
38+
39+
1. After code review is done, maintainer will squash and merge the PR into the "dev" branch.
40+
41+
1. Periodically, the "dev" branch is merged back to the "main" branch to create a new release.
42+
43+
## Project structure
44+
45+
ZenStack is a monorepo consisting of multiple NPM packages managed by [pnpm workspace](https://pnpm.io/workspaces).
46+
47+
### Packages
48+
49+
The source and tests of ZenStack npm packages reside in the "packages" folder:
50+
51+
#### [language](./packages/language)
52+
53+
The ZModel language's definition, including its syntax definition and parser/linker implementation. The compiler is implemented with the [Langium](https://github.com/langium/langium) toolkit.
54+
55+
#### [cli](./packages/cli)
56+
57+
The `zen` CLI and built-in plugins.
58+
59+
#### [schema](./packages/schema)
60+
61+
The runtime representation of ZModel schema.
62+
63+
#### [orm](./packages/orm)
64+
65+
The ORM runtime built on top of [Kysely](https://kysely.dev).
66+
67+
#### [server](./packages/server)
68+
69+
The `server` package implements the automatic CRUD services and contains two main parts:
70+
71+
1. Framework-agnostic API handlers: defining input/output format and API routes in a framework-independent way. Currently supports "rpc" and "rest" styles.
72+
73+
1. Framework-specific adapters: translating framework-dependent request and response formats.
74+
75+
#### [clients/tanstack-query](./packages/clients/tanstack-query)
76+
77+
TanStack Query client for consuming the automatic CRUD services.
78+
79+
#### [sdk](./packages/sdk)
80+
81+
Utilities for building ZenStack plugins.
82+
83+
#### [plugins/policy](./plugins/policy)
84+
85+
The access policy plugin implementation.
86+
87+
#### [ide/vscode](./packages/ide/vscode)
88+
89+
VSCode extension for ZModel.
90+
91+
#### [testtools](./packages/testtools)
92+
93+
Test utilities.
94+
95+
### Tests
96+
97+
#### [e2e](./tests/e2e/)
98+
99+
End-to-end tests covering essential features (ORM, access policies, etc.).
100+
101+
#### [regression](./tests/regression/)
102+
103+
Regression tests for previously reported issues.
104+
105+
## Testing changed packages locally
106+
107+
The [samples](./samples) folder contains sample projects that directly reference the packages in the workspace. Once you make changes to a package and rebuild it, the sample projects will automatically pick up the changes. They are handy for quick manual testing.
108+
109+
If you prefer to test against your own project, simply copy the built bundles (from the `dist` folder of each package) to your project's `node_modules` folder to overwrite the installed packages.

README.md

Lines changed: 48 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<img src="https://raw.githubusercontent.com/zenstackhq/zenstack-docs/main/static/img/logo.png" height="128">
66
</picture>
77
</a>
8-
<h1>ZenStack V3</h1>
8+
<h1>ZenStack: Modern Data Layer for TypeScript Apps</h1>
99
<a href="https://www.npmjs.com/package/@zenstackhq/cli?activeTab=versions">
1010
<img src="https://img.shields.io/npm/v/%40zenstackhq%2Fcli/next">
1111
</a>
@@ -21,40 +21,33 @@
2121
</a>
2222
</div>
2323

24-
> V3 is currently in beta phase and not ready for production use. Feedback and bug reports are greatly appreciated. Please visit this dedicated [discord channel](https://discord.com/channels/1035538056146595961/1352359627525718056) for chat and support.
25-
2624
# What's ZenStack
2725

28-
> Read full documentation at 👉🏻 https://zenstack.dev/v3.
26+
> Read full documentation at 👉🏻 https://zenstack.dev/docs.
2927
30-
ZenStack is a TypeScript database toolkit for developing full-stack or backend Node.js/Bun applications. It provides a unified data modeling and access solution with the following features:
28+
ZenStack is a TypeScript database toolkit for developing full-stack or backend Node.js/Bun applications. It provides a unified data modeling and query solution with the following features:
3129

32-
- A modern schema-first ORM that's compatible with [Prisma](https://github.com/prisma/prisma)'s schema and API
33-
- Versatile data access APIs: high-level (Prisma-style) ORM queries + low-level ([Kysely](https://github.com/kysely-org/kysely)) query builder
34-
- Built-in access control and data validation (coming soon)
35-
- Advanced data modeling patterns like [polymorphism](https://zenstack.dev/blog/polymorphism)
36-
- Designed for extensibility and flexibility: plugins, life-cycle hooks, etc.
37-
- Automatic CRUD web APIs with adapters for popular frameworks (coming soon)
38-
- Automatic [TanStack Query](https://github.com/TanStack/query) hooks for easy CRUD from the frontend (coming soon)
30+
- 🔧 Modern schema-first ORM that's compatible with [Prisma](https://github.com/prisma/prisma)'s schema and API
31+
- 📊 Versatile API - high-level ORM queries + low-level [Kysely](https://kysely.dev) query builder
32+
- 🔐 Built-in access control and data validation
33+
- 🚀 Advanced data modeling patterns like [polymorphism](https://zenstack.dev/docs/orm/polymorphism)
34+
- 🧩 Designed for extensibility and flexibility
35+
- ⚙️ Automatic CRUD web APIs with adapters for popular frameworks
36+
- 🏖️ Automatic [TanStack Query](https://github.com/TanStack/query) hooks for easy CRUD from the frontend
3937

4038
# What's New in V3
4139

42-
ZenStack V3 is a major rewrite of [V2](https://github.com/zenstackhq/zenstack). The biggest change is V3 doesn't have a runtime dependency to Prisma anymore. Instead of working as a big wrapper of Prisma as in V2, V3 made a bold move and implemented the entire ORM engine using [Kysely](https://github.com/kysely-org/kysely), while keeping the query API fully compatible with Prisma.
43-
44-
Please check [this blog post](https://zenstack.dev/blog/next-chapter-1) for why we made this big architectural change decision.
40+
ZenStack V3 is a major rewrite of [V2](https://github.com/zenstackhq/zenstack). It replaced Prisma ORM with its own ORM engine built on top of [Kysely](https://kysely.dev) while keeping a Prisma-compatible query API. This architecture change brings the level of flexibility that we couldn't imagine in previous versions. Please check [this blog post](https://zenstack.dev/blog/next-chapter-1) for why we made this bold decision.
4541

4642
Even without using advanced features, ZenStack offers the following benefits as a drop-in replacement to Prisma:
4743

4844
1. Pure TypeScript implementation without any Rust/WASM components.
4945
2. More TypeScript type inference, less code generation.
5046
3. Fully-typed query-builder API as a better escape hatch compared to Prisma's [raw queries](https://www.prisma.io/docs/orm/prisma-client/using-raw-sql/raw-queries) or [typed SQL](https://www.prisma.io/docs/orm/prisma-client/using-raw-sql/typedsql).
5147

52-
> Although ZenStack v3's ORM runtime doesn't depend on Prisma anymore (specifically, `@prisma/client`), it still relies on Prisma to handle database migration. See [database migration](https://zenstack.dev/docs/3.x/orm/migration) for more details.
53-
54-
# Quick Start
48+
# Try It Now
5549

56-
- [ORM](./samples/orm): A simple example demonstrating ZenStack ORM usage.
57-
- [Next.js + TanStack Query](./samples/next.js): A full-stack sample demonstrating using TanStack Query to consume ZenStack's automatic CRUD services in a Next.js app.
50+
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/~/github.com/zenstackhq/v3-doc-quick-start?file=zenstack%2fschema.zmodel&file=main.ts&view=editor&showSidebar=0&hideNavigation=1&hideExplorer=1)
5851

5952
## Installation
6053

@@ -63,28 +56,58 @@ Even without using advanced features, ZenStack offers the following benefits as
6356
Use the following command to scaffold a simple TypeScript command line application with ZenStack configured:
6457

6558
```bash
66-
npm create zenstack@next my-project
59+
npm create zenstack@latest my-project
6760
```
6861

6962
### 2. Setting up an existing project
7063

7164
Or, if you have an existing project, use the CLI to initialize it:
7265

7366
```bash
74-
npx @zenstackhq/cli@next init
67+
npx @zenstackhq/cli@latest init
7568
```
7669

7770
### 3. Setting up manually
7871

7972
Alternatively, you can set it up manually:
8073

8174
```bash
82-
npm install -D @zenstackhq/cli@next
83-
npm install @zenstackhq/orm@next
75+
npm install -D @zenstackhq/cli
76+
npm install @zenstackhq/orm
8477
```
8578

8679
Then create a `zenstack` folder and a `schema.zmodel` file in it.
8780

8881
# Documentation
8982

90-
Please visit the [doc site](https://zenstack.dev/docs/3.x/) for detailed documentation.
83+
[https://zenstack.dev/docs/](https://zenstack.dev/docs/)
84+
85+
# Sponsors
86+
87+
Thank you for your generous support!
88+
89+
## Current Sponsors
90+
91+
<table>
92+
<tr>
93+
<td align="center"><a href="https://suhyl.com/"><img src="https://avatars.githubusercontent.com/u/124434734?s=200&v=4" width="100" style="border-radius:50%" alt="Suhyl"/><br />Suhyl</a></td>
94+
<td align="center"><a href="https://www.marblism.com/"><img src="https://avatars.githubusercontent.com/u/143199531?s=200&v=4" width="100" style="border-radius:50%" alt="Marblism"/><br />Marblism</a></td>
95+
<td align="center"><a href="https://www.mermaidchart.com/"><img src="https://avatars.githubusercontent.com/u/117662492?s=200&v=4" width="100" style="border-radius:50%" alt="Mermaid Chart"/><br />Mermaid Chart</a></td>
96+
<td align="center"><a href="https://coderabbit.ai/"><img src="https://avatars.githubusercontent.com/u/132028505?v=4" width="100" style="border-radius:50%" alt="CodeRabbit"/><br />CodeRabbit</a></td>
97+
<td align="center"><a href="https://github.com/j0hannr"><img src="https://avatars.githubusercontent.com/u/52762073?v=4" width="100" style="border-radius:50%" alt="Johann Rohn"/><br />Johann Rohn</a></td>
98+
</tr>
99+
</table>
100+
101+
## Previous Sponsors
102+
103+
<table>
104+
<tr>
105+
<td align="center"><a href="https://github.com/baenie"><img src="https://avatars.githubusercontent.com/u/58309104?v=4" width="100" style="border-radius:50%" alt="Benjamin Zecirovic"/><br />Benjamin Zecirovic</a></td>
106+
<td align="center"><a href="https://github.com/umussetu"><img src="https://avatars.githubusercontent.com/u/152648499?v=4" width="100" style="border-radius:50%" alt="Ulric"/><br />Ulric</a></td>
107+
<td align="center"><a href="https://github.com/iamfj"><img src="https://avatars.githubusercontent.com/u/24557998?v=4" width="100" style="border-radius:50%" alt="Fabian Jocks"/><br />Fabian Jocks</a></td>
108+
</tr>
109+
</table>
110+
111+
# Community
112+
113+
Join our [discord server](https://discord.gg/Ykhr738dUe) for chat and updates!

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "zenstack-v3",
3-
"version": "3.0.0-beta.34",
3+
"version": "3.0.0",
44
"description": "ZenStack",
55
"packageManager": "pnpm@10.23.0",
66
"type": "module",
@@ -9,12 +9,15 @@
99
"watch": "turbo run watch build",
1010
"lint": "turbo run lint",
1111
"test": "turbo run test",
12+
"test:all": "pnpm run test:sqlite && pnpm run test:pg",
13+
"test:pg": "TEST_DB_PROVIDER=postgresql turbo run test",
14+
"test:sqlite": "TEST_DB_PROVIDER=sqlite turbo run test",
1215
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
1316
"pr": "gh pr create --fill-first --base dev",
1417
"merge-main": "gh pr create --title \"merge dev to main\" --body \"\" --base main --head dev",
1518
"bump-version": "gh workflow run .github/workflows/bump-version.yml --ref dev",
16-
"publish-all": "pnpm --filter \"./packages/**\" -r publish --access public --tag next",
17-
"publish-preview": "pnpm --filter \"./packages/**\" -r publish --tag next --force --registry https://preview.registry.zenstack.dev/",
19+
"publish-all": "pnpm --filter \"./packages/**\" -r publish --access public",
20+
"publish-preview": "pnpm --filter \"./packages/**\" -r publish --force --registry https://preview.registry.zenstack.dev/",
1821
"unpublish-preview": "pnpm --filter \"./packages/**\" -r --shell-mode exec -- npm unpublish -f --registry https://preview.registry.zenstack.dev/ \"\\$PNPM_PACKAGE_NAME\""
1922
},
2023
"keywords": [],

packages/auth-adapters/better-auth/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zenstackhq/better-auth",
3-
"version": "3.0.0-beta.34",
3+
"version": "3.0.0",
44
"description": "ZenStack Better Auth Adapter. This adapter is modified from better-auth's Prisma adapter.",
55
"type": "module",
66
"scripts": {

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"publisher": "zenstack",
44
"displayName": "ZenStack CLI",
55
"description": "FullStack database toolkit with built-in access control and automatic API generation.",
6-
"version": "3.0.0-beta.34",
6+
"version": "3.0.0",
77
"type": "module",
88
"author": {
99
"name": "ZenStack Team"

packages/cli/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function createProgram() {
5050
.description(
5151
`${colors.bold.blue(
5252
'ζ',
53-
)} ZenStack is the data layer for modern TypeScript apps.\n\nDocumentation: https://zenstack.dev/docs/3.x`,
53+
)} ZenStack is the modern data layer for TypeScript apps.\n\nDocumentation: https://zenstack.dev/docs`,
5454
)
5555
.showHelpAfterError()
5656
.showSuggestionAfterError();

packages/clients/tanstack-query/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zenstackhq/tanstack-query",
3-
"version": "3.0.0-beta.34",
3+
"version": "3.0.0",
44
"description": "TanStack Query Client for consuming ZenStack v3's CRUD service",
55
"main": "index.js",
66
"type": "module",

packages/common-helpers/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zenstackhq/common-helpers",
3-
"version": "3.0.0-beta.34",
3+
"version": "3.0.0",
44
"description": "ZenStack Common Helpers",
55
"type": "module",
66
"scripts": {

packages/config/eslint-config/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zenstackhq/eslint-config",
3-
"version": "3.0.0-beta.34",
3+
"version": "3.0.0",
44
"type": "module",
55
"private": true,
66
"license": "MIT"

0 commit comments

Comments
 (0)