Skip to content

Commit

Permalink
chore(perm-checker): rename filter clause to where
Browse files Browse the repository at this point in the history
  • Loading branch information
ymc9 committed May 7, 2024
1 parent 0aa6ee9 commit d6ea541
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 76 deletions.
6 changes: 3 additions & 3 deletions packages/runtime/src/enhancements/policy/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type FindOperations = 'findUnique' | 'findUniqueOrThrow' | 'findFirst' | 'findFi
// input arg type for `check` API
type PermissionCheckArgs = {
operation: PolicyCrudKind;
filter?: Record<string, number | string | boolean>;
where?: Record<string, number | string | boolean>;
};

/**
Expand Down Expand Up @@ -1466,11 +1466,11 @@ export class PolicyProxyHandler<DbClient extends DbClientContract> implements Pr
return constraint;
}

if (args.filter) {
if (args.where) {
// combine runtime filters with generated constraints

const extraConstraints: CheckerConstraint[] = [];
for (const [field, value] of Object.entries(args.filter)) {
for (const [field, value] of Object.entries(args.where)) {
if (value === undefined) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export interface ModelCheckers {

function generateDataModelChecker(dataModel: DataModel) {
return `{
check(args: { operation: PolicyCrudKind, filter?: ${generateDataModelArgs(dataModel)} }): Promise<boolean>
check(args: { operation: PolicyCrudKind, where?: ${generateDataModelArgs(dataModel)} }): Promise<boolean>
}`;
}

Expand Down
Loading

0 comments on commit d6ea541

Please sign in to comment.