@zenstackhq/runtime 3.0.0-alpha.12 → 3.0.0-alpha.14
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/dist/{contract-BEAyf7Es.d.cts → contract-BYc34jr_.d.cts} +78 -54
- package/dist/{contract-BEAyf7Es.d.ts → contract-BYc34jr_.d.ts} +78 -54
- package/dist/index.cjs +821 -311
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +821 -311
- package/dist/index.js.map +1 -1
- package/dist/plugins/{policy.cjs → policy/index.cjs} +225 -125
- package/dist/plugins/policy/index.cjs.map +1 -0
- package/dist/plugins/{policy.d.ts → policy/index.d.cts} +1 -1
- package/dist/plugins/{policy.d.cts → policy/index.d.ts} +1 -1
- package/dist/plugins/{policy.js → policy/index.js} +225 -125
- package/dist/plugins/policy/index.js.map +1 -0
- package/dist/plugins/policy/plugin.zmodel +33 -0
- package/package.json +12 -12
- package/dist/plugins/policy.cjs.map +0 -1
- package/dist/plugins/policy.js.map +0 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines an access policy that allows a set of operations when the given condition is true.
|
|
3
|
+
*
|
|
4
|
+
* @param operation: comma-separated list of "create", "read", "update", "delete". Use "all" to denote all operations.
|
|
5
|
+
* @param condition: a boolean expression that controls if the operation should be allowed.
|
|
6
|
+
*/
|
|
7
|
+
attribute @@allow(_ operation: String @@@completionHint(["'create'", "'read'", "'update'", "'delete'", "'all'"]), _ condition: Boolean)
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Defines an access policy that allows the annotated field to be read or updated.
|
|
11
|
+
* You can pass a third argument as `true` to make it override the model-level policies.
|
|
12
|
+
*
|
|
13
|
+
* @param operation: comma-separated list of "create", "read", "update", "delete". Use "all" to denote all operations.
|
|
14
|
+
* @param condition: a boolean expression that controls if the operation should be allowed.
|
|
15
|
+
* @param override: a boolean value that controls if the field-level policy should override the model-level policy.
|
|
16
|
+
*/
|
|
17
|
+
attribute @allow(_ operation: String @@@completionHint(["'create'", "'read'", "'update'", "'delete'", "'all'"]), _ condition: Boolean, _ override: Boolean?)
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Defines an access policy that denies a set of operations when the given condition is true.
|
|
21
|
+
*
|
|
22
|
+
* @param operation: comma-separated list of "create", "read", "update", "delete". Use "all" to denote all operations.
|
|
23
|
+
* @param condition: a boolean expression that controls if the operation should be denied.
|
|
24
|
+
*/
|
|
25
|
+
attribute @@deny(_ operation: String @@@completionHint(["'create'", "'read'", "'update'", "'delete'", "'all'"]), _ condition: Boolean)
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Defines an access policy that denies the annotated field to be read or updated.
|
|
29
|
+
*
|
|
30
|
+
* @param operation: comma-separated list of "create", "read", "update", "delete". Use "all" to denote all operations.
|
|
31
|
+
* @param condition: a boolean expression that controls if the operation should be denied.
|
|
32
|
+
*/
|
|
33
|
+
attribute @deny(_ operation: String @@@completionHint(["'create'", "'read'", "'update'", "'delete'", "'all'"]), _ condition: Boolean)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zenstackhq/runtime",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.14",
|
|
4
4
|
"description": "ZenStack Runtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [],
|
|
@@ -64,12 +64,12 @@
|
|
|
64
64
|
"ts-pattern": "^5.7.1",
|
|
65
65
|
"ulid": "^3.0.0",
|
|
66
66
|
"uuid": "^11.0.5",
|
|
67
|
-
"
|
|
68
|
-
"@zenstackhq/common-helpers": "3.0.0-alpha.12"
|
|
67
|
+
"@zenstackhq/common-helpers": "3.0.0-alpha.14"
|
|
69
68
|
},
|
|
70
69
|
"peerDependencies": {
|
|
71
70
|
"better-sqlite3": "^11.8.1",
|
|
72
|
-
"pg": "^8.13.1"
|
|
71
|
+
"pg": "^8.13.1",
|
|
72
|
+
"zod": "^4.0.0"
|
|
73
73
|
},
|
|
74
74
|
"peerDependenciesMeta": {
|
|
75
75
|
"better-sqlite3": {
|
|
@@ -83,18 +83,18 @@
|
|
|
83
83
|
"@types/better-sqlite3": "^7.0.0",
|
|
84
84
|
"@types/pg": "^8.0.0",
|
|
85
85
|
"tsx": "^4.19.2",
|
|
86
|
-
"@zenstackhq/eslint-config": "3.0.0-alpha.
|
|
87
|
-
"@zenstackhq/
|
|
88
|
-
"@zenstackhq/
|
|
89
|
-
"@zenstackhq/
|
|
90
|
-
"@zenstackhq/
|
|
86
|
+
"@zenstackhq/eslint-config": "3.0.0-alpha.14",
|
|
87
|
+
"@zenstackhq/language": "3.0.0-alpha.14",
|
|
88
|
+
"@zenstackhq/sdk": "3.0.0-alpha.14",
|
|
89
|
+
"@zenstackhq/typescript-config": "3.0.0-alpha.14",
|
|
90
|
+
"@zenstackhq/testtools": "3.0.0-alpha.14"
|
|
91
91
|
},
|
|
92
92
|
"scripts": {
|
|
93
|
-
"build": "tsup-node",
|
|
93
|
+
"build": "tsup-node && pnpm test:generate",
|
|
94
94
|
"watch": "tsup-node --watch",
|
|
95
95
|
"lint": "eslint src --ext ts",
|
|
96
|
-
"test": "vitest run && pnpm test:
|
|
97
|
-
"test:generate": "tsx test/
|
|
96
|
+
"test": "vitest run && pnpm test:typecheck",
|
|
97
|
+
"test:generate": "tsx test/scripts/generate.ts",
|
|
98
98
|
"test:typecheck": "tsc --project tsconfig.test.json",
|
|
99
99
|
"pack": "pnpm pack"
|
|
100
100
|
}
|