-
-
Notifications
You must be signed in to change notification settings - Fork 12
merge dev to main (v3.0.0-beta.4) #249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
67d35d5
feat: "create" access policy implementation (#242)
ymc9 4ef27c7
feat(policy): support comparing `auth()` with auth model (#244)
ymc9 f01bcde
fix(policy): logical combination issue and more tests for update (#245)
ymc9 fe54e42
chore(policy): more test cases and update (#246)
ymc9 71935e0
fix: Correctly infer optional enum arrays (#243)
genu 3d2e199
chore: bump version 3.0.0-beta.4 (#248)
github-actions[bot] 966018f
fix: add regression project and optimize ts schema generation (#247)
ymc9 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| { | ||
| "name": "zenstack-v3", | ||
| "version": "3.0.0-beta.3", | ||
| "version": "3.0.0-beta.4", | ||
| "description": "ZenStack", | ||
| "packageManager": "[email protected]", | ||
| "scripts": { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| import { describe, it } from 'vitest'; | ||
| import { loadSchema, loadSchemaWithError } from './utils'; | ||
|
|
||
| describe('Expression Validation Tests', () => { | ||
| it('should reject model comparison', async () => { | ||
| await loadSchemaWithError( | ||
| ` | ||
| model User { | ||
| id Int @id | ||
| name String | ||
| posts Post[] | ||
| } | ||
|
|
||
| model Post { | ||
| id Int @id | ||
| title String | ||
| author User @relation(fields: [authorId], references: [id]) | ||
| @@allow('all', author == this) | ||
| } | ||
| `, | ||
| 'comparison between models is not supported', | ||
| ); | ||
| }); | ||
|
|
||
| it('should reject model comparison', async () => { | ||
| await loadSchemaWithError( | ||
| ` | ||
| model User { | ||
| id Int @id | ||
| name String | ||
| profile Profile? | ||
| address Address? | ||
| @@allow('read', profile == this) | ||
| } | ||
|
|
||
| model Profile { | ||
| id Int @id | ||
| bio String | ||
| user User @relation(fields: [userId], references: [id]) | ||
| userId Int @unique | ||
| } | ||
|
|
||
| model Address { | ||
| id Int @id | ||
| street String | ||
| user User @relation(fields: [userId], references: [id]) | ||
| userId Int @unique | ||
| } | ||
| `, | ||
| 'comparison between models is not supported', | ||
| ); | ||
| }); | ||
|
|
||
| it('should allow auth comparison with auth type', async () => { | ||
| await loadSchema( | ||
| ` | ||
| datasource db { | ||
| provider = 'sqlite' | ||
| url = 'file:./dev.db' | ||
| } | ||
|
|
||
| model User { | ||
| id Int @id | ||
| name String | ||
| profile Profile? | ||
| @@allow('read', auth() == this) | ||
| } | ||
|
|
||
| model Profile { | ||
| id Int @id | ||
| bio String | ||
| user User @relation(fields: [userId], references: [id]) | ||
| userId Int @unique | ||
| @@allow('read', auth() == user) | ||
| } | ||
| `, | ||
| ); | ||
| }); | ||
|
|
||
| it('should reject auth comparison with non-auth type', async () => { | ||
| await loadSchemaWithError( | ||
| ` | ||
| model User { | ||
| id Int @id | ||
| name String | ||
| profile Profile? | ||
| } | ||
|
|
||
| model Profile { | ||
| id Int @id | ||
| bio String | ||
| user User @relation(fields: [userId], references: [id]) | ||
| userId Int @unique | ||
| @@allow('read', auth() == this) | ||
| } | ||
| `, | ||
| 'incompatible operand types', | ||
| ); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Relation requires the scalar FK field
authorId.Without
authorId Int, schema validation may fail before reaching the expression validator, making the test flaky for the intended error.model Post { id Int @id title String + authorId Int author User @relation(fields: [authorId], references: [id]) @@allow('all', author == this) }📝 Committable suggestion
🤖 Prompt for AI Agents