@avonjs/avonjs
Version:
A fluent Node.js API generator.
63 lines (62 loc) • 2.6 kB
TypeScript
import type { Ability, AbstractMixable, AnyArray, Model } from '../Contracts';
import type AvonRequest from '../Http/Requests/AvonRequest';
declare const _default: <T extends AbstractMixable = AbstractMixable>(Parent: T) => (abstract new (...args: import("../Contracts").Args) => {
/**
* Determine if the current user has a given ability or throw exception.
* @throws {ForbiddenException}
*/
authorizeTo(request: AvonRequest, ability: Ability, args?: AnyArray): Promise<void>;
/**
* Determine if the current user has a given ability.
*/
authorizedTo(request: AvonRequest, ability: Ability, args?: AnyArray): Promise<boolean>;
/**
* Determine if need to perform authorization.
*/
authorizable(): boolean;
/**
* Guess custom authorization callback name for the given ability.
*/
makeAuthorizationCallback(ability: string): string;
/**
* Determine if the current user has ability to `viewAny` a resource.
*/
authorizedToViewAny(request: AvonRequest): Promise<boolean>;
/**
* Determine if the current user has ability to `view` a resource.
*/
authorizedToView(request: AvonRequest): Promise<boolean>;
/**
* Determine if the current user has ability to `create` a resource.
*/
authorizedToCreate(request: AvonRequest): Promise<boolean>;
/**
* Determine if the current user has ability to `update` a resource.
*/
authorizedToUpdate(request: AvonRequest): Promise<boolean>;
/**
* Determine if the current user has ability to `delete` a resource.
*/
authorizedToDelete(request: AvonRequest): Promise<boolean>;
/**
* Determine if the current user has ability to `forceDelete` a resource.
*/
authorizedToForceDelete(request: AvonRequest): Promise<boolean>;
/**
* Determine if the current user has ability to `restore` a resource.
*/
authorizedToRestore(request: AvonRequest): Promise<boolean>;
/**
* Determine if the current user has ability to `add` a resource to the current resource.
*/
authorizedToAdd(request: AvonRequest, resource: Model): Promise<boolean>;
/**
* Determine if the current user has ability to `attach` a resource to the current resource.
*/
authorizedToAttach(request: AvonRequest, resource: Model): Promise<boolean>;
/**
* Determine if the current user has ability to `detach` a resource from the current resource.
*/
authorizedToDetach(request: AvonRequest, resource: Model): Promise<boolean>;
}) & T;
export default _default;