import type { ID } from '../common/types.js';
import { type PolicyDiffResult } from './diff.js';
import type { Policy, PolicyVersion, PolicyDefinition, PolicyStatus, CreatePolicyInput, UpdatePolicyInput, PolicyListFilters, PolicyValidationResult, PolicyValidationError } from './types.js';
/**
 * Input for updating a policy with versioning
 */
export interface UpdateWithVersioningInput {
    definition?: PolicyDefinition;
    description?: string;
    status?: PolicyStatus;
    changeSummary?: string;
    changedBy?: string;
}
/**
 * Extended policy version with additional metadata
 */
export interface PolicyVersionWithMeta extends PolicyVersion {
    isCurrent: boolean;
}
/**
 * Result of comparing two policy versions
 */
export interface PolicyVersionCompareResult {
    policyId: ID;
    version1: number;
    version2: number;
    diff: PolicyDiffResult;
}
/**
 * Validate a policy definition
 */
export declare function validatePolicyDefinition(definition: unknown): PolicyValidationResult;
/**
 * Policy Service class
 */
export declare class PolicyService {
    /**
     * Create a new policy
     */
    create(tenantId: ID, input: CreatePolicyInput): Promise<Policy>;
    /**
     * Get a policy by ID
     */
    findById(id: ID, tenantId: ID): Promise<Policy | null>;
    /**
     * Get a policy by name and namespace
     */
    findByName(tenantId: ID, name: string, namespace?: string): Promise<Policy | null>;
    /**
     * Update a policy (creates new version)
     */
    update(id: ID, tenantId: ID, input: UpdatePolicyInput): Promise<Policy | null>;
    /**
     * Publish a policy (makes it active)
     */
    publish(id: ID, tenantId: ID): Promise<Policy | null>;
    /**
     * Deprecate a policy
     */
    deprecate(id: ID, tenantId: ID): Promise<Policy | null>;
    /**
     * Archive a policy
     */
    archive(id: ID, tenantId: ID): Promise<Policy | null>;
    /**
     * List policies with filters
     */
    list(filters: PolicyListFilters): Promise<Policy[]>;
    /**
     * Get published policies for evaluation
     */
    getPublishedPolicies(tenantId: ID, namespace?: string): Promise<Policy[]>;
    /**
     * Update a policy with explicit versioning.
     * Creates a new version record before applying changes.
     *
     * @param id - Policy ID
     * @param tenantId - Tenant ID for access control
     * @param changes - Changes to apply
     * @returns Updated policy with new version number
     */
    updateWithVersioning(id: ID, tenantId: ID, changes: UpdateWithVersioningInput): Promise<Policy | null>;
    /**
     * Get complete version history for a policy.
     * Returns all historical versions plus the current version.
     *
     * @param id - Policy ID
     * @param tenantId - Tenant ID for access control
     * @returns List of all versions, newest first
     */
    getVersionHistory(id: ID, tenantId: ID): Promise<PolicyVersionWithMeta[]>;
    /**
     * Get a specific version of a policy.
     *
     * @param id - Policy ID
     * @param version - Version number to retrieve
     * @param tenantId - Tenant ID for access control
     * @returns The policy version or null if not found
     */
    getVersion(id: ID, version: number, tenantId: ID): Promise<PolicyVersion | null>;
    /**
     * Rollback a policy to a previous version.
     * Creates a new version with the definition from the target version.
     *
     * @param id - Policy ID
     * @param targetVersion - Version number to rollback to
     * @param tenantId - Tenant ID for access control
     * @param userId - User performing the rollback
     * @returns Updated policy with new version number
     */
    rollbackToVersion(id: ID, targetVersion: number, tenantId: ID, userId?: string): Promise<Policy | null>;
    /**
     * Compare two versions of a policy.
     *
     * @param id - Policy ID
     * @param version1 - First version to compare
     * @param version2 - Second version to compare
     * @param tenantId - Tenant ID for access control
     * @returns Diff result between the two versions
     */
    compareVersions(id: ID, version1: number, version2: number, tenantId: ID): Promise<PolicyVersionCompareResult | null>;
    /**
     * Delete a policy (soft delete - archives it)
     */
    delete(id: ID, tenantId: ID): Promise<boolean>;
    /**
     * Convert database row to Policy object
     */
    private rowToPolicy;
}
/**
 * Custom error for policy validation failures
 */
export declare class PolicyValidationException extends Error {
    readonly errors: PolicyValidationError[];
    constructor(message: string, errors: PolicyValidationError[]);
}
/**
 * Create a new policy service instance
 */
export declare function createPolicyService(): PolicyService;
//# sourceMappingURL=service.d.ts.map