/** * ABAC Policy Loader Utilities * * Optional helper functions for loading and saving policies from common sources. * These are convenience utilities - users can load/save policies however they want. */ import { PolicyValidationResult } from './policyValidator'; import { ABACPolicy } from './types'; /** * Export a single policy to JSON string * * @param policy - The policy to export * @param pretty - Whether to format the JSON with indentation (default: true) * @returns JSON string representation of the policy */ export declare function exportPolicyToJSON(policy: ABACPolicy, pretty?: boolean): string; /** * Export multiple policies to JSON string * * @param policies - The policies to export * @param pretty - Whether to format the JSON with indentation (default: true) * @returns JSON string representation of the policies array */ export declare function exportPoliciesToJSON(policies: ABACPolicy[], pretty?: boolean): string; /** * Save a single policy to a JSON file * * @param policy - The policy to save * @param filePath - Path to the file where the policy should be saved * @param pretty - Whether to format the JSON with indentation (default: true) */ export declare function savePolicyToFile(policy: ABACPolicy, filePath: string, pretty?: boolean): Promise; /** * Save multiple policies to a JSON file * * @param policies - The policies to save * @param filePath - Path to the file where the policies should be saved * @param pretty - Whether to format the JSON with indentation (default: true) */ export declare function savePoliciesToFile(policies: ABACPolicy[], filePath: string, pretty?: boolean): Promise; /** * Save and validate a single policy to a JSON file * * @param policy - The policy to save * @param filePath - Path to the file where the policy should be saved * @param pretty - Whether to format the JSON with indentation (default: true) * @throws ValidationError if the policy is invalid */ export declare function saveAndValidatePolicyToFile(policy: ABACPolicy, filePath: string, pretty?: boolean): Promise; /** * Save and validate multiple policies to a JSON file * * @param policies - The policies to save * @param filePath - Path to the file where the policies should be saved * @param pretty - Whether to format the JSON with indentation (default: true) * @throws ValidationError if any policy is invalid */ export declare function saveAndValidatePoliciesToFile(policies: ABACPolicy[], filePath: string, pretty?: boolean): Promise; /** * Load policies from JSON file */ export declare function loadPoliciesFromFile(filePath: string): Promise; /** * Load and validate policies from JSON file */ export declare function loadAndValidatePoliciesFromFile(filePath: string): Promise<{ policies: ABACPolicy[]; validationResults: PolicyValidationResult[]; }>; /** * Load policies from JSON string */ export declare function loadPoliciesFromJSON(json: string): ABACPolicy[]; /** * Helper adapter for Prisma * * @example * ```typescript * const policies = await prismaAdapter(prisma.abacPolicy.findMany({ * where: { active: true } * })); * ``` */ export declare function prismaAdapter(query: Promise, mapper?: (row: T) => ABACPolicy): Promise; /** * Helper for caching policies */ export declare class PolicyCache { private policies; private lastLoaded; private ttl; constructor(ttlSeconds?: number); /** * Get cached policies or load fresh ones */ get(loader: () => Promise): Promise; /** * Invalidate cache */ invalidate(): void; /** * Manually set policies */ set(policies: ABACPolicy[]): void; } /** * Filter policies by target criteria * Useful for optimizing policy evaluation */ export declare function filterPoliciesByTarget(policies: ABACPolicy[], criteria: { resourceType?: string; actionId?: string; subjectAttributes?: Record; }): ABACPolicy[]; /** * Group policies by effect for optimization */ export declare function groupPoliciesByEffect(policies: ABACPolicy[]): { permit: ABACPolicy[]; deny: ABACPolicy[]; }; //# sourceMappingURL=policyLoaders.d.ts.map