import { SmrtClassOptions } from '@happyvertical/smrt-core'; import { OperationPermissionCollectionInput, PermissionCatalog } from './PermissionCatalogService.js'; import { PermissionResolutionOptions, PermissionResolver } from './PermissionResolver.js'; export type OperationPermissionDenyReason = 'invalid_operation' | 'missing_principal' | 'resolution_error' | 'unknown_permission' | 'permission_denied'; export type OperationPermissionAllowReason = 'permission_granted' | 'super_admin_bypass' | 'system_context_bypass'; export interface OperationPermissionDecision { allowed: boolean; permission: string | null; reason: OperationPermissionAllowReason | OperationPermissionDenyReason; error?: unknown; } export interface OperationPermissionOptions extends SmrtClassOptions, PermissionResolutionOptions { /** * Collection slug, model class, model instance, or collection instance. */ collection: OperationPermissionCollectionInput; /** * Operation action. `list` and `get` normalize to the catalog's `.read`. */ action: string; /** * Default true. When false, a super-admin tenant context must still hold the * resolved permission. */ allowSuperAdminBypass?: boolean; /** * Default true. System context represents trusted server-side execution. */ allowSystemContextBypass?: boolean; catalog?: PermissionCatalog; onDeny?: 'return' | 'throw'; resolver?: PermissionResolver; tenantId?: string | null; userId?: string | null; /** * When provided, authorize against THIS exact permission set instead of * re-resolving live RBAC. Pass the published principal set * (`context.permissionSet`) so an RLS-off catalog gate enforces the same * snapshot authority the RLS-on session published — keeping the authority * bound adapter-independent. Without it a mid-run role grant, or a reduced * pre-resolved `permissions` set, could let SQLite/dev allow an operation the * Postgres RLS path for the same principal context would deny. */ permissionSet?: ReadonlySet | readonly string[]; } export declare class OperationPermissionError extends Error { readonly decision: OperationPermissionDecision; readonly permission: string | null; readonly status = 403; constructor(decision: OperationPermissionDecision); } export declare function checkOperationPermission(options: OperationPermissionOptions): Promise; export declare function hasOperationPermission(options: OperationPermissionOptions): Promise; export declare function assertOperationPermission(options: OperationPermissionOptions): Promise; //# sourceMappingURL=OperationPermissionService.d.ts.map