Skip to content

Commit 5c813e3

Browse files
authored
release: v0.2.4
- refactored policy checking and added more integration tests - added new @password and @omit field attributes - cleaned up todo sample's redundant models
1 parent c0cb860 commit 5c813e3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2108
-1355
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ node_modules
22
dist
33
.vercel
44
.DS_Store
5+
.vscode/settings.json

.vscode/settings.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
<div align="center">
2-
<picture>
3-
<source media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/104139426/197796502-1bcb8052-a7b1-42de-bfc8-a14e045ac1c3.png">
4-
<img src="https://user-images.githubusercontent.com/104139426/197796006-52d8d334-413b-4eda-8094-4024c0eaf9b3.png" height="128">
5-
</picture>
2+
<img src="https://user-images.githubusercontent.com/104139426/197796006-52d8d334-413b-4eda-8094-4024c0eaf9b3.png" height="128">
63
<h1>ZenStack</h1>
74
<a href="https://www.npmjs.com/package/zenstack">
85
<img src="https://img.shields.io/npm/v/zenstack">
@@ -13,7 +10,7 @@
1310
<a href="https://discord.gg/6HhebQynfz">
1411
<img src="https://img.shields.io/discord/1035538056146595961">
1512
</a>
16-
<a href="/zenstackhq/zenstack/blob/dev/LICENSE">
13+
<a href="/zenstackhq/zenstack/blob/main/LICENSE">
1714
<img src="https://img.shields.io/badge/license-MIT-green">
1815
</a>
1916
</div>

docs/get-started/learning-the-zmodel-language.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,20 +183,20 @@ You can use `auth()` to:
183183
- Check if a user is logged in
184184

185185
```prisma
186-
deny('all', auth() == null)
186+
@@deny('all', auth() == null)
187187
```
188188

189189
- Access user's fields
190190

191191
```prisma
192-
allow('update', auth().role == 'ADMIN')
192+
@@allow('update', auth().role == 'ADMIN')
193193
```
194194

195195
- Compare user identity
196196

197197
```prisma
198198
// owner is a relation field to User model
199-
allow('update', auth() == owner)
199+
@@allow('update', auth() == owner)
200200
```
201201

202202
### A simple example with Post model

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "zenstack-monorepo",
3-
"version": "0.2.1",
3+
"version": "0.2.4",
44
"description": "",
55
"scripts": {
66
"build": "pnpm -r build",

packages/internal/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zenstackhq/internal",
3-
"version": "0.2.1",
3+
"version": "0.2.4",
44
"displayName": "ZenStack Internal Library",
55
"description": "ZenStack internal runtime library. This package is for supporting runtime functionality of ZenStack and not supposed to be used directly.",
66
"repository": {
@@ -26,9 +26,9 @@
2626
],
2727
"dependencies": {
2828
"bcryptjs": "^2.4.3",
29+
"cuid": "^2.1.8",
2930
"deepcopy": "^2.1.0",
30-
"swr": "^1.3.0",
31-
"uuid": "^9.0.0"
31+
"swr": "^1.3.0"
3232
},
3333
"peerDependencies": {
3434
"@prisma/client": "^4.4.0",

packages/internal/src/constants.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,13 @@
22
* Auxiliary database field for supporting policy check for nested writes
33
*/
44
export const TRANSACTION_FIELD_NAME = 'zenstack_transaction';
5+
6+
/**
7+
* Auxiliary database field for building up policy check queries
8+
*/
9+
export const GUARD_FIELD_NAME = 'zenstack_guard';
10+
11+
/**
12+
* Default length of password hash salt (used by bcryptjs to hash password)
13+
*/
14+
export const DEFAULT_PASSWORD_SALT_LENGTH = 12;

packages/internal/src/handler/data/guard-utils.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)