Skip to content

Commit 00250ea

Browse files
authored
chore(perm-checker): rename filter clause to where (#1413)
1 parent 0aa6ee9 commit 00250ea

File tree

4 files changed

+78
-78
lines changed

4 files changed

+78
-78
lines changed

packages/runtime/src/enhancements/policy/handler.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ type FindOperations = 'findUnique' | 'findUniqueOrThrow' | 'findFirst' | 'findFi
4141
// input arg type for `check` API
4242
type PermissionCheckArgs = {
4343
operation: PolicyCrudKind;
44-
filter?: Record<string, number | string | boolean>;
44+
where?: Record<string, number | string | boolean>;
4545
};
4646

4747
/**
@@ -1466,11 +1466,11 @@ export class PolicyProxyHandler<DbClient extends DbClientContract> implements Pr
14661466
return constraint;
14671467
}
14681468

1469-
if (args.filter) {
1469+
if (args.where) {
14701470
// combine runtime filters with generated constraints
14711471

14721472
const extraConstraints: CheckerConstraint[] = [];
1473-
for (const [field, value] of Object.entries(args.filter)) {
1473+
for (const [field, value] of Object.entries(args.where)) {
14741474
if (value === undefined) {
14751475
continue;
14761476
}

packages/schema/src/plugins/enhancer/enhance/checker-type-generator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export interface ModelCheckers {
3131

3232
function generateDataModelChecker(dataModel: DataModel) {
3333
return `{
34-
check(args: { operation: PolicyCrudKind, filter?: ${generateDataModelArgs(dataModel)} }): Promise<boolean>
34+
check(args: { operation: PolicyCrudKind, where?: ${generateDataModelArgs(dataModel)} }): Promise<boolean>
3535
}`;
3636
}
3737

packages/server/tests/api/rpc.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ describe('RPC API Handler Tests', () => {
146146
r = await handleRequest({
147147
method: 'get',
148148
path: '/post/check',
149-
query: { q: JSON.stringify({ operation: 'read', filter: { published: false } }) },
149+
query: { q: JSON.stringify({ operation: 'read', where: { published: false } }) },
150150
prisma: enhance(),
151151
});
152152
expect(r.status).toBe(200);
@@ -155,7 +155,7 @@ describe('RPC API Handler Tests', () => {
155155
r = await handleRequest({
156156
method: 'get',
157157
path: '/post/check',
158-
query: { q: JSON.stringify({ operation: 'read', filter: { authorId: '1', published: false } }) },
158+
query: { q: JSON.stringify({ operation: 'read', where: { authorId: '1', published: false } }) },
159159
prisma: enhance({ id: '1' }),
160160
});
161161
expect(r.status).toBe(200);

0 commit comments

Comments
 (0)