import { WithId } from "../../../../../../fd-toolbox-core/types/resource-with-id";
import { CrudAction } from "../../../../../../fd-toolbox/enums/enums";
/**
 * Type for a function that checks if a user has permission to perform a CRUD action on a resource.
 * Used to implement resource-level access control logic. The function can be synchronous or asynchronous.
 *
 * @example
 * ```typescript
    const canEdit: ResourcePermissionChecker = (resource, userId, action) => {
        return resource[createdByDateProps.createdByUserId] === userId && action === crudActions.update;
    };
 * ```
 */
export type ResourcePermissionChecker = (resource: WithId, userId: string, crudAction: CrudAction) => Promise<boolean | undefined> | boolean | undefined;
