zenstack 0.2.15 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  <a href="https://twitter.com/intent/tweet?text=Wow%20%40zenstackhq">
8
8
  <img src="https://img.shields.io/twitter/url?style=social&url=https%3A%2F%2Fgithub.com%2Fzenstackhq%2Fzenstack">
9
9
  </a>
10
- <a href="https://discord.gg/6HhebQynfz">
10
+ <a href="https://go.zenstack.dev/chat">
11
11
  <img src="https://img.shields.io/discord/1035538056146595961">
12
12
  </a>
13
13
  <a href="https://github.com/zenstackhq/zenstack/blob/main/LICENSE">
@@ -15,21 +15,19 @@
15
15
  </a>
16
16
  </div>
17
17
 
18
- ## What is ZenStack?
18
+ ## 📣 Our Discord Server is Live
19
+
20
+ [JOIN US](https://go.zenstack.dev/chat) to chat about questions, bugs, plans, or anything off the top of your head.
19
21
 
20
- ZenStack is a toolkit for simplifying full-stack development with Node.js web frameworks like [Next.js](https://nextjs.org/), [Nuxt.js](https://nuxtjs.org/) <img src="https://img.shields.io/badge/-Coming%20Soon-lightgray" height="12" align="top">, and [SvelteKit](https://kit.svelte.dev/) <img src="https://img.shields.io/badge/-Coming%20Soon-lightgray" height="12" align="top">, using Typescript language.
22
+ ## What is ZenStack?
21
23
 
22
- Thanks to the increasing power of frameworks, building a complex web app within one unified framework is becoming more practical than ever. However, you'll still need to spend a significant amount of energy designing and building up your app's server-side part.
24
+ [![ZenStack Full-stack Development Toolkit Introduction](https://cdn.loom.com/sessions/thumbnails/76ba1308fb734af993765a6696b62c96-1668251534738-with-play.gif)](https://www.loom.com/share/76ba1308fb734af993765a6696b62c96)
23
25
 
24
- Things that make you stressed include:
26
+ ZenStack is a toolkit for modeling data and access policies in full-stack development with [Next.js](https://nextjs.org/) and Typescript.
25
27
 
26
- - What kind of API to use? RESTful or GraphQL?
27
- - How to model your data and map the model to both source code and database (ORM)?
28
- - How to implement CRUD operations? Manually construct it or use a generator?
29
- - How to evolve your data model?
30
- - How to authenticate users and authorize their requests?
28
+ Next.js is an excellent full-stack framework. However, building the backend part of a web app is still quite challenging. For example, implementing CRUD services efficiently and securely is tricky and not fun.
31
29
 
32
- ZenStack aims to simplify these tasks by providing:
30
+ ZenStack simplifies it by providing:
33
31
 
34
32
  - An intuitive data modeling language for defining data types, relations, and access policies
35
33
 
@@ -60,7 +58,7 @@ model Post {
60
58
  }
61
59
  ```
62
60
 
63
- - Auto-generated CRUD services and strongly typed front-end library
61
+ - Auto-generated CRUD services and strongly typed React hooks
64
62
 
65
63
  ```jsx
66
64
  // React example
@@ -77,26 +75,24 @@ return (
77
75
  );
78
76
  ```
79
77
 
80
- Since CRUD APIs are automatically generated with access policies injected, you can safely implement most of your business logic in your front-end code. Read operations never return data that's not supposed to be visible to the current user, and writes will be rejected if unauthorized. The generated front-end library also supports nested writes, allowing you to make a batch of creates/updates atomically, eliminating the need for explicitly using a transaction.
78
+ Since CRUD APIs are automatically generated with access policies injected, you can safely implement most of your business logic in your front-end code. Read operations never return data that's not supposed to be visible to the current user, and writes will be rejected if unauthorized.
81
79
 
82
- ZenStack is heavily inspired and built over [Prisma](https://www.prisma.io) ORM, which is, in our opinion, the best ORM toolkit in the market. Familiarity with Prisma should make it easy to pick up ZenStack, but it's not a prerequisite since the modeling language is intuitive and the development workflow is straightforward.
80
+ ZenStack is heavily inspired and built above [Prisma](https://www.prisma.io) ORM, which is, in our opinion, the best ORM toolkit in the market. Familiarity with Prisma should make it easy to pick up ZenStack, but it's not a prerequisite since the modeling language is intuitive and the development workflow is straightforward.
83
81
 
84
82
  ## Getting started
85
83
 
86
- ### [For Next.js](docs/get-started/next-js.md)
87
-
88
- ### For Nuxt.js <img src="https://img.shields.io/badge/-Coming%20Soon-lightgray" height="12" align="top">
84
+ [A step by step guide for getting started](docs/get-started/next-js.md)
89
85
 
90
- ### For SvelteKit <img src="https://img.shields.io/badge/-Coming%20Soon-lightgray" height="12" align="top">
86
+ [A complete sample with a collaborative todo app](tree/main/samples/todo)
91
87
 
92
88
  ## How does it work?
93
89
 
94
90
  ZenStack has four essential responsibilities:
95
91
 
96
- 1. Modeling data and mapping the model to DB schema and program types
92
+ 1. Modeling data and mapping the model to DB schema and programmable client library
97
93
  1. Integrating with authentication
98
94
  1. Generating CRUD APIs and enforcing data access policies
99
- 1. Providing type-safe client CRUD library
95
+ 1. Providing type-safe React hooks
100
96
 
101
97
  Let's briefly go through each of them in this section.
102
98
 
@@ -158,9 +154,11 @@ When client code sends a query to list all `Post`s, ZenStack's generated code in
158
154
 
159
155
  Similar procedures are applied to write operations and more complex queries involving nested reads and writes. To ensure good performance, ZenStack generates conditions statically, so it doesn't need to introspect ZModel at runtime. The engine also makes the best effort to push down policy constraints to the database to avoid fetching data unnecessarily and discarding afterward.
160
156
 
161
- Please **beware** that policy checking is only applied when data access is done using the generated client-side hooks or, equivalently, the RESTful API. If you use `service.db` to access the database directly from server-side code, policies are bypassed, and you have to do all necessary checking by yourself. We've planned to add helper functions for "injecting" the policy checking on the server side in the future.
157
+ Please **BEWARE** that policy checking is only applied when data access is done using the generated client-side hooks or, equivalently, the RESTful API. If you use `service.db` to access the database directly from server-side code, policies are bypassed, and you have to do all necessary checking by yourself. We've planned to add helper functions for "injecting" the policy checking on the server side in the future.
162
158
 
163
- ### Type-safe client library
159
+ ### Type-safe React hooks
160
+
161
+ Strongly-typed React hooks are generated for CRUD operations, saving the need to write boilerplate code.
164
162
 
165
163
  Thanks to Prisma's power, ZenStack generates accurate Typescript types for your data models:
166
164
 
@@ -174,11 +172,7 @@ The cool thing is that the generated types are shared between client-side and se
174
172
 
175
173
  ### Client-side
176
174
 
177
- #### For Next.js
178
-
179
- The generated CRUD services should be mounted at `/api/zenstack` route. React hooks are generated for calling these services without explicitly writing Http requests.
180
-
181
- The following hooks methods are generated:
175
+ The generated CRUD services should be mounted at `/api/zenstack` route. The following React hooks are generated for each data model:
182
176
 
183
177
  - find: listing entities with filtering, ordering, pagination, and nested relations
184
178
 
@@ -276,5 +270,5 @@ export const getServerSideProps: GetServerSideProps = async () => {
276
270
 
277
271
  ## Reach out to us for issues, feedback and ideas!
278
272
 
279
- [Discord](https://discord.gg/dbuC9ZWc) [Twitter](https://twitter.com/zenstackhq)
280
- [Discussions](../discussions) [Issues](../issues)
273
+ [Discord](https://go.zenstack.dev/chat) | [Twitter](https://twitter.com/zenstackhq) |
274
+ [Discussions](../discussions) | [Issues](../issues)