import type { Entity, IEntityClass } from '../Entity.ts'; import type { EntityPrivacyPolicy } from '../EntityPrivacyPolicy.ts'; import type { EntityQueryContext } from '../EntityQueryContext.ts'; import type { ViewerContext } from '../ViewerContext.ts'; import { EntityNotAuthorizedError } from '../errors/EntityNotAuthorizedError.ts'; export type EntityPrivacyEvaluationResultSuccess = { allowed: true; }; export type EntityPrivacyEvaluationResultFailure = { allowed: false; authorizationErrors: EntityNotAuthorizedError[]; }; export type EntityPrivacyEvaluationResult = EntityPrivacyEvaluationResultSuccess | EntityPrivacyEvaluationResultFailure; /** * Check whether an entity loaded by a viewer can be updated by that same viewer. * * @remarks * * This may be useful in situations relying upon the thrown privacy policy thrown authorization error * is insufficient for the task at hand. When dealing with purely a sequence of mutations it is easy * to roll back all mutations given a single authorization error by wrapping them in a single transaction. * When certain portions of a mutation cannot be rolled back transactionally (third pary calls, * legacy code, etc), using this method can help decide whether the sequence of mutations will fail before * attempting them. Note that if any privacy policy rules use a piece of data being updated in the mutations * the result of this method and the update mutation itself may differ. * * @param entityClass - class of entity * @param sourceEntity - entity loaded by viewer * @param queryContext - query context in which to perform the check */ export declare function canViewerUpdateAsync, TIDField extends keyof NonNullable>, TViewerContext extends ViewerContext, TEntity extends Entity, TPrivacyPolicy extends EntityPrivacyPolicy, TSelectedFields extends keyof TFields = keyof TFields>(entityClass: IEntityClass, sourceEntity: TEntity, queryContext?: EntityQueryContext): Promise; /** * Check whether an entity loaded by a viewer can be updated by that same viewer and return the evaluation result. * * @see canViewerUpdateAsync * * @param entityClass - class of entity * @param sourceEntity - entity loaded by viewer * @param queryContext - query context in which to perform the check */ export declare function getCanViewerUpdateResultAsync, TIDField extends keyof NonNullable>, TViewerContext extends ViewerContext, TEntity extends Entity, TPrivacyPolicy extends EntityPrivacyPolicy, TSelectedFields extends keyof TFields = keyof TFields>(entityClass: IEntityClass, sourceEntity: TEntity, queryContext?: EntityQueryContext): Promise; /** * Check whether a single entity loaded by a viewer can be deleted by that same viewer. * This recursively checks edge cascade permissions (EntityEdgeDeletionBehavior) as well. * * @see canViewerUpdateAsync * * @param entityClass - class of entity * @param sourceEntity - entity loaded by viewer * @param queryContext - query context in which to perform the check */ export declare function canViewerDeleteAsync, TIDField extends keyof NonNullable>, TViewerContext extends ViewerContext, TEntity extends Entity, TPrivacyPolicy extends EntityPrivacyPolicy, TSelectedFields extends keyof TFields = keyof TFields>(entityClass: IEntityClass, sourceEntity: TEntity, queryContext?: EntityQueryContext): Promise; /** * Check whether a single entity loaded by a viewer can be deleted by that same viewer and return the evaluation result. * * @see canViewerDeleteAsync * * @param entityClass - class of entity * @param sourceEntity - entity loaded by viewer * @param queryContext - query context in which to perform the check */ export declare function getCanViewerDeleteResultAsync, TIDField extends keyof NonNullable>, TViewerContext extends ViewerContext, TEntity extends Entity, TPrivacyPolicy extends EntityPrivacyPolicy, TSelectedFields extends keyof TFields = keyof TFields>(entityClass: IEntityClass, sourceEntity: TEntity, queryContext?: EntityQueryContext): Promise;