Skip to content

Commit 73dd0d2

Browse files
authored
Merge pull request #465 from Permify/next
Next
2 parents fa3cf41 + fa108fe commit 73dd0d2

File tree

14 files changed

+465
-263
lines changed

14 files changed

+465
-263
lines changed

docs/documentation/docs/getting-started/examples/facebook-groups.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -513,9 +513,18 @@ relationships:
513513
- event:1#owner@user:3
514514
- event:1#group@group:1
515515

516-
assertions:
517-
- "can user:4 RSVP_to_event event:1": false
518-
- "can user:5 view_comment comment:1": true
516+
scenarios:
517+
- name: "scenario 1"
518+
description: "test description"
519+
checks:
520+
- entity: "event:1"
521+
subject: "user:4"
522+
assertions:
523+
RSVP_to_event : false
524+
- entity: "comment:1"
525+
subject: "user:5"
526+
assertions:
527+
view_comment : true
519528
```
520529
521530
### Using Schema Validator in Local

docs/documentation/docs/getting-started/examples/google-docs.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,22 @@ relationships:
279279
- resource:hr_documents#manager@group:hr#manager
280280
- resource:hr_documents#viewer@group:hr#member
281281

282-
assertions:
283-
- "can user:ashley edit resource:product_database": true
284-
- "can user:joe view resource:hr_documents": true
285-
- "can user:david view resource:marketing_materials": false
282+
scenarios:
283+
- name: "scenario 1"
284+
description: "test description"
285+
checks:
286+
- entity: "resource:product_database"
287+
subject: "user:ashley"
288+
assertions:
289+
edit : true
290+
- entity: "resource:hr_documents"
291+
subject: "user:joe"
292+
assertions:
293+
view : true
294+
- entity: "resource:marketing_materials"
295+
subject: "user:david"
296+
assertions:
297+
view : false
286298
```
287299
288300
### Using Schema Validator in Local

docs/documentation/docs/getting-started/examples/notion.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -515,9 +515,18 @@ relationships:
515515
- comment:task_list_2_comment_2#block@block:task_list_2
516516
- comment:task_list_2_comment_2#author@user:charlie
517517

518-
assertions:
519-
- "can user:alice write database:task_list": true
520-
- "user:charlie write page:product_spec": false
518+
scenarios:
519+
- name: "scenario 1"
520+
description: "test description"
521+
checks:
522+
- entity: "database:task_list"
523+
subject: "user:alice"
524+
assertions:
525+
write : true
526+
- entity: "page:product_spec"
527+
subject: "user:charlie"
528+
assertions:
529+
write : false
521530
```
522531
523532
### Using Schema Validator in Local

docs/documentation/docs/getting-started/testing.md

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,45 @@ relationships:
7878
- "organization:1#member@user:43"
7979
- "repository:1#owner@user:43"
8080
81-
assertions:
82-
- "can user:1 push repository:1": true
83-
- "can user:1 push repository:2": false
84-
- "can user:1 push repository:3": false
85-
- "can user:43 edit repository:1": false
81+
scenarios:
82+
- name: "scenario 1"
83+
description: "test description"
84+
checks:
85+
- entity: "repository:1"
86+
subject: "user:1"
87+
assertions:
88+
push : true
89+
owner : true
90+
- entity: "repository:2"
91+
subject: "user:1"
92+
assertions:
93+
push : false
94+
- entity: "repository:3"
95+
subject: "user:1"
96+
assertions:
97+
push : false
98+
- entity: "repository:1"
99+
subject: "user:43"
100+
assertions:
101+
edit : false
102+
entity_filters:
103+
- entity_type: "repository"
104+
subject: "user:1"
105+
assertions:
106+
push : ["1"]
107+
edit : []
108+
86109
```
87110

111+
## Coverage Analysis
112+
113+
By using the command `permify coverage {path of your schema validation file}`, you can measure the coverage for your schema.
114+
The coverage is calculated by analyzing the relationships and assertions in your created model, identifying any missing elements.
115+
The output of the example provided above is as follows.
116+
117+
![schema-coverage](https://user-images.githubusercontent.com/39353278/236303688-15cc2673-05e6-42d3-9ad4-0c538f546fb0.png)
118+
119+
88120
## Testing in Local
89121

90122
You can also test your new authorization model in your local (Permify clone) without using [permify-validate-action] at all.
@@ -93,7 +125,7 @@ For that open up a new file and add a schema yaml file inside. Then build your p
93125

94126
If we use the above example schema validation file, after running `./permify validate {path of your schema validation file}` it gives a result on the terminal as:
95127

96-
![schema-validation](https://user-images.githubusercontent.com/34595361/207110538-9837b09d-26b4-409a-a309-a21f66e6677a.png)
128+
![schema-validation](https://user-images.githubusercontent.com/39353278/236303542-930de83f-ebdd-4b0a-a09e-5c069744cc5c.png)
97129

98130
[permify-validate-action]: https://github.com/Permify/permify-validate-action
99131

docs/documentation/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
},
1717
"dependencies": {
1818
"@cmfcmf/docusaurus-search-local": "^1.1.0",
19-
"@docusaurus/core": "^2.0.0-beta.17",
20-
"@docusaurus/plugin-client-redirects": "^2.3.1",
21-
"@docusaurus/plugin-google-analytics": "^2.0.0-beta.17",
22-
"@docusaurus/plugin-google-gtag": "^2.0.0-beta.17",
23-
"@docusaurus/preset-classic": "^2.3.1",
19+
"@docusaurus/core": "^2.4.0",
20+
"@docusaurus/plugin-client-redirects": "^2.4.0",
21+
"@docusaurus/plugin-google-analytics": "^2.4.0",
22+
"@docusaurus/plugin-google-gtag": "^2.4.0",
23+
"@docusaurus/preset-classic": "^2.4.0",
2424
"@glidejs/glide": "^3.6.0",
2525
"@reach/accordion": "^0.18.0",
2626
"@redq/reuse-modal": "^2.0.0",
@@ -72,7 +72,7 @@
7272
"swiper": "^9.1.0"
7373
},
7474
"devDependencies": {
75-
"@docusaurus/module-type-aliases": "^2.3.1",
75+
"@docusaurus/module-type-aliases": "^2.4.0",
7676
"@tsconfig/docusaurus": "^1.0.4",
7777
"typescript": "^4.9.5"
7878
},

docs/documentation/src/theme/prism-perm-lang.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
(function (Prism) {
22
Prism.languages.perm = Prism.languages.extend('clike', {
33
'class-name': [
4+
{
5+
pattern: /\\B@\\w+#?\\w+/,
6+
lookbehind: true
7+
},
48
{
59
pattern: /(\b(?:entity)\s+)(\w+\/)?\w*(?=\s*\{)/,
610
lookbehind: true
@@ -9,6 +13,10 @@
913
pattern: /(\b(?:action)\s+)\w+(?=\s*\=)/,
1014
lookbehind: true
1115
},
16+
{
17+
pattern: /(\b(?:permission)\s+)\w+(?=\s*\=)/,
18+
lookbehind: true
19+
},
1220
{
1321
pattern: /(\b(?:relation)\s+)\w+(?=\s*\:)/,
1422
lookbehind: true
@@ -26,6 +34,6 @@
2634
lookbehind: true
2735
},
2836
],
29-
'keyword': /\b(?:entity|relation|action|or|not|and)\b(?!\s*=\s*\d)/,
37+
'keyword': /\b(?:entity|permission|relation|action|or|not|and)\b(?!\s*=\s*\d)/,
3038
});
3139
}(Prism));

0 commit comments

Comments
 (0)