mirror of
https://github.com/strapi/strapi.git
synced 2025-11-13 00:29:51 +00:00
43 lines
982 B
TypeScript
43 lines
982 B
TypeScript
import { hooks, providerFactory } from '@strapi/utils';
|
|
|
|
interface Permission {
|
|
action: string;
|
|
subject?: string | object | null;
|
|
properties?: object;
|
|
conditions?: string[];
|
|
}
|
|
|
|
type Provider = ReturnType<typeof providerFactory>;
|
|
|
|
interface BaseAction {
|
|
actionId: string;
|
|
}
|
|
|
|
interface BaseCondition {
|
|
name: string;
|
|
handler(...params: unknown[]): boolean | object;
|
|
}
|
|
|
|
interface ActionProvider<T extends Action = Action> extends Provider {}
|
|
interface ConditionProvider<T extends Condition = Condition> extends Provider {}
|
|
|
|
interface PermissionEngine {
|
|
hooks: object;
|
|
|
|
generateAbility(permissions: Permission[], options?: object): Ability;
|
|
}
|
|
|
|
interface BaseAbility {
|
|
can: Function;
|
|
}
|
|
|
|
interface AbilityBuilder {
|
|
can(permission: Permission): void | Promise<void>;
|
|
build(): BaseAbility | Promise<BaseAbility>;
|
|
}
|
|
|
|
interface PermissionEngineParams {
|
|
providers: { action: ActionProvider; condition: ConditionProvider };
|
|
abilityBuilderFactory(): AbilityBuilder;
|
|
}
|