-
-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
179 additions
and
39 deletions.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
|
@@ -9,7 +9,7 @@ plugins { | |
} | ||
|
||
group = "dev.zenstack" | ||
version = "2.6.0" | ||
version = "2.6.1" | ||
|
||
repositories { | ||
mavenCentral() | ||
|
This file contains 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 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 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 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 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 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 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 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 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 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 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 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 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 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,107 @@ | ||
import { loadSchema } from '@zenstackhq/testtools'; | ||
describe('issue 1734', () => { | ||
it('regression', async () => { | ||
const { enhance, enhanceRaw, prisma } = await loadSchema( | ||
` | ||
abstract model Base { | ||
id String @id @default(cuid()) | ||
createdAt DateTime @default(now()) | ||
updatedAt DateTime @updatedAt | ||
} | ||
model Profile extends Base { | ||
displayName String | ||
type String | ||
@@allow('read', true) | ||
@@delegate(type) | ||
} | ||
model User extends Profile { | ||
username String @unique | ||
access Access[] | ||
organization Organization[] | ||
} | ||
model Access extends Base { | ||
user User @relation(fields: [userId], references: [id]) | ||
userId String | ||
organization Organization @relation(fields: [organizationId], references: [id]) | ||
organizationId String | ||
manage Boolean @default(false) | ||
superadmin Boolean @default(false) | ||
@@unique([userId,organizationId]) | ||
} | ||
model Organization extends Profile { | ||
owner User @relation(fields: [ownerId], references: [id]) | ||
ownerId String @default(auth().id) | ||
published Boolean @default(false) @allow('read', access?[user == auth()]) | ||
access Access[] | ||
} | ||
` | ||
); | ||
const db = enhance(); | ||
const rootDb = enhanceRaw(prisma, undefined, { | ||
kinds: ['delegate'], | ||
}); | ||
|
||
const user = await rootDb.user.create({ | ||
data: { | ||
username: 'test', | ||
displayName: 'test', | ||
}, | ||
}); | ||
|
||
const organization = await rootDb.organization.create({ | ||
data: { | ||
displayName: 'test', | ||
owner: { | ||
connect: { | ||
id: user.id, | ||
}, | ||
}, | ||
access: { | ||
create: { | ||
user: { | ||
connect: { | ||
id: user.id, | ||
}, | ||
}, | ||
manage: true, | ||
superadmin: true, | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
const foundUser = await db.profile.findFirst({ | ||
where: { | ||
id: user.id, | ||
}, | ||
}); | ||
expect(foundUser).toMatchObject(user); | ||
|
||
const foundOrg = await db.profile.findFirst({ | ||
where: { | ||
id: organization.id, | ||
}, | ||
}); | ||
// published field not readable | ||
expect(foundOrg).toMatchObject({ id: organization.id, displayName: 'test', type: 'Organization' }); | ||
expect(foundOrg.published).toBeUndefined(); | ||
|
||
const foundOrg1 = await enhance({ id: user.id }).profile.findFirst({ | ||
where: { | ||
id: organization.id, | ||
}, | ||
}); | ||
// published field readable | ||
expect(foundOrg1.published).not.toBeUndefined(); | ||
}); | ||
}); |