mirror of
https://github.com/bknd-io/bknd/
synced 2026-08-02 08:06:00 +00:00
38902ebcba
- Bump `jsonv-ts` dependency to 0.8.6. - Refactor permission checks in the `Guard` class to improve context validation and error handling. - Update tests to reflect changes in permission handling, ensuring robust coverage for new scenarios. - Introduce new test cases for data permissions, enhancing overall test coverage and reliability.
52 lines
1.1 KiB
TypeScript
52 lines
1.1 KiB
TypeScript
import { Permission } from "auth/authorize/Permission";
|
|
import { s } from "bknd/utils";
|
|
|
|
export const entityRead = new Permission(
|
|
"data.entity.read",
|
|
{
|
|
filterable: true,
|
|
},
|
|
s.object({
|
|
entity: s.string(),
|
|
id: s.anyOf([s.number(), s.string()]).optional(),
|
|
}),
|
|
);
|
|
/**
|
|
* Filter filters content given
|
|
*/
|
|
export const entityCreate = new Permission(
|
|
"data.entity.create",
|
|
{
|
|
filterable: true,
|
|
},
|
|
s.object({
|
|
entity: s.string(),
|
|
}),
|
|
);
|
|
/**
|
|
* Filter filters where clause
|
|
*/
|
|
export const entityUpdate = new Permission(
|
|
"data.entity.update",
|
|
{
|
|
filterable: true,
|
|
},
|
|
s.object({
|
|
entity: s.string(),
|
|
id: s.anyOf([s.number(), s.string()]).optional(),
|
|
}),
|
|
);
|
|
export const entityDelete = new Permission(
|
|
"data.entity.delete",
|
|
{
|
|
filterable: true,
|
|
},
|
|
s.object({
|
|
entity: s.string(),
|
|
id: s.anyOf([s.number(), s.string()]).optional(),
|
|
}),
|
|
);
|
|
export const databaseSync = new Permission("data.database.sync");
|
|
export const rawQuery = new Permission("data.raw.query");
|
|
export const rawMutate = new Permission("data.raw.mutate");
|