Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(permissions): circular dependency (#18986)
* fix(permissions): circular dependency * Apply suggestions from code review Co-authored-by: Ben Irvin <ben@innerdvations.com> * Apply suggestions from code review Co-authored-by: Jean-S茅bastien Herbaux <jean-sebastien.herbaux@epitech.eu> --------- Co-authored-by: Ben Irvin <ben@innerdvations.com> Co-authored-by: Jean-S茅bastien Herbaux <jean-sebastien.herbaux@epitech.eu>
- Loading branch information
1 parent
2951783
commit e85a23d
Showing
6 changed files
with
39 additions
and
31 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
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,19 @@ | ||
/** | ||
* These were imported from `@strapi/types` but if we do that | ||
* it becomes a circular dependency. This is the source of truth, | ||
* they're re-exported from `@strapi/types` for convenience. | ||
*/ | ||
import type { Subject } from '@casl/ability'; | ||
|
||
export interface ParametrizedAction { | ||
name: string; | ||
params: Record<string, unknown>; | ||
} | ||
export interface PermissionRule { | ||
action: string | ParametrizedAction; | ||
subject?: Subject | null; | ||
properties?: { | ||
fields?: string[]; | ||
}; | ||
condition?: Record<string, unknown>; | ||
} |
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 |
---|---|---|
@@ -1,14 +1,8 @@ | ||
import { Subject } from '@casl/ability'; | ||
import type { engine } from '@strapi/permissions'; | ||
|
||
export interface ParametrizedAction { | ||
name: string; | ||
params: Record<string, unknown>; | ||
} | ||
export interface PermissionRule { | ||
action: string | ParametrizedAction; | ||
subject?: Subject | null; | ||
properties?: { | ||
fields?: string[]; | ||
}; | ||
condition?: Record<string, unknown>; | ||
} | ||
type PermissionRule = Parameters<engine.abilities.CustomAbilityBuilder['can']>[0]; | ||
type ParametrizedAction = Parameters< | ||
engine.abilities.CustomAbilityBuilder['buildParametrizedAction'] | ||
>[0]; | ||
|
||
export type { PermissionRule, ParametrizedAction }; |