/**
 * Resource Observer Types for Declarative Infrastructure API
 *
 * This module defines the interfaces for the Observer pattern,
 * enabling automatic reactions to resource lifecycle events.
 *
 * @module declarative-api/observer.types
 */
import type { ResourceCreatedEvent, ResourceModifiedEvent, ResourceDeletedEvent } from './event.types';
/**
 * Observer priority constants.
 *
 * Lower values execute earlier. Use these constants for consistent ordering.
 */
export declare const OBSERVER_PRIORITIES: {
    /** Highest priority - executes first (e.g., validation) */
    readonly HIGHEST: 0;
    /** High priority - executes early (e.g., auto-grant) */
    readonly HIGH: 100;
    /** Normal priority - default execution order */
    readonly NORMAL: 500;
    /** Low priority - executes late (e.g., logging) */
    readonly LOW: 900;
    /** Lowest priority - executes last (e.g., metrics) */
    readonly LOWEST: 1000;
};
/**
 * Type for observer priority values.
 */
export type ObserverPriority = (typeof OBSERVER_PRIORITIES)[keyof typeof OBSERVER_PRIORITIES] | number;
/**
 * Observer type discriminator for built-in observers.
 */
export type ObserverType = 'auto-grant' | 'auto-inject' | 'logging' | 'metrics' | 'custom';
/**
 * All observer type strings.
 */
export declare const OBSERVER_TYPES: readonly ObserverType[];
/**
 * Type guard to check if a value is a valid ObserverType.
 *
 * @param value - The value to check
 * @returns True if the value is a valid ObserverType
 */
export declare function isObserverType(value: unknown): value is ObserverType;
/**
 * Resource Observer interface.
 *
 * Observers react to resource lifecycle events (creation, modification, deletion).
 * They enable automatic configuration of related components.
 *
 * Implements: Observer Pattern
 *
 * @example
 * ```typescript
 * class LoggingObserver implements IResourceObserver {
 *   readonly priority = OBSERVER_PRIORITIES.LOW;
 *   readonly observerId = 'logging-observer';
 *   readonly observerType = 'logging';
 *
 *   onResourceCreated(event: ResourceCreatedEvent): void {
 *     console.log(`Resource created: ${event.resource.id}`);
 *   }
 *
 *   onResourceModified(event: ResourceModifiedEvent): void {
 *     console.log(`Resource modified: ${event.resource.id}`);
 *   }
 *
 *   onResourceDeleted(event: ResourceDeletedEvent): void {
 *     console.log(`Resource deleted: ${event.resourceId}`);
 *   }
 * }
 * ```
 *
 * Validates: Requirements 6.1, 6.2, 6.3, 6.4, 6.5, 6.6
 */
export interface IResourceObserver {
    /**
     * Observer priority (lower = earlier execution).
     *
     * Use OBSERVER_PRIORITIES constants for consistent ordering.
     */
    readonly priority: ObserverPriority;
    /**
     * Unique identifier for this observer instance.
     */
    readonly observerId: string;
    /**
     * Observer type discriminator.
     */
    readonly observerType: ObserverType;
    /**
     * React to resource creation.
     *
     * Called when a new resource is created in the infrastructure context.
     * Can be synchronous or asynchronous.
     *
     * @param event - The resource created event
     */
    onResourceCreated(event: ResourceCreatedEvent): void | Promise<void>;
    /**
     * React to resource modification.
     *
     * Called when an existing resource is modified.
     * Can be synchronous or asynchronous.
     *
     * @param event - The resource modified event
     */
    onResourceModified(event: ResourceModifiedEvent): void | Promise<void>;
    /**
     * React to resource deletion.
     *
     * Called when a resource is deleted from the infrastructure context.
     * Can be synchronous or asynchronous.
     *
     * @param event - The resource deleted event
     */
    onResourceDeleted(event: ResourceDeletedEvent): void | Promise<void>;
}
/**
 * Observer registry interface for managing observers.
 *
 * Provides methods to register, unregister, and query observers.
 *
 * Validates: Requirements 6.4, 6.5
 */
export interface IObserverRegistry {
    /**
     * Register an observer.
     *
     * @param observer - The observer to register
     * @throws DuplicateObserverError if observer with same ID already registered
     */
    register(observer: IResourceObserver): void;
    /**
     * Unregister an observer by ID.
     *
     * @param observerId - The observer ID to unregister
     * @returns True if observer was unregistered, false if not found
     */
    unregister(observerId: string): boolean;
    /**
     * Get all registered observers sorted by priority.
     *
     * @returns Array of observers sorted by priority (ascending)
     */
    getAll(): readonly IResourceObserver[];
    /**
     * Get observers by type.
     *
     * @param type - The observer type to filter by
     * @returns Array of observers of the specified type
     */
    getByType(type: ObserverType): readonly IResourceObserver[];
    /**
     * Check if an observer is registered.
     *
     * @param observerId - The observer ID to check
     * @returns True if observer is registered
     */
    has(observerId: string): boolean;
    /**
     * Get the number of registered observers.
     *
     * @returns The count of registered observers
     */
    count(): number;
    /**
     * Clear all registered observers.
     */
    clear(): void;
}
/**
 * Observer notification result for tracking execution.
 */
export interface ObserverNotificationResult {
    /** Observer ID that was notified */
    readonly observerId: string;
    /** Whether the notification was successful */
    readonly success: boolean;
    /** Error message if notification failed */
    readonly error?: string;
    /** Execution duration in milliseconds */
    readonly durationMs: number;
}
/**
 * Batch notification result for all observers.
 */
export interface BatchNotificationResult {
    /** Total number of observers notified */
    readonly totalObservers: number;
    /** Number of successful notifications */
    readonly successCount: number;
    /** Number of failed notifications */
    readonly failureCount: number;
    /** Individual results for each observer */
    readonly results: readonly ObserverNotificationResult[];
    /** Total execution duration in milliseconds */
    readonly totalDurationMs: number;
}
/**
 * Observer notifier interface for dispatching events to observers.
 *
 * Handles the actual notification of observers with proper ordering
 * and error handling.
 *
 * Validates: Requirements 6.4, 6.5, 6.6
 */
export interface IObserverNotifier {
    /**
     * Notify all observers of a resource creation event.
     *
     * Observers are notified in priority order (ascending).
     * Errors in one observer do not prevent notification of others.
     *
     * @param event - The resource created event
     * @returns Batch notification result
     */
    notifyCreated(event: ResourceCreatedEvent): BatchNotificationResult;
    /**
     * Notify all observers of a resource modification event.
     *
     * @param event - The resource modified event
     * @returns Batch notification result
     */
    notifyModified(event: ResourceModifiedEvent): BatchNotificationResult;
    /**
     * Notify all observers of a resource deletion event.
     *
     * @param event - The resource deleted event
     * @returns Batch notification result
     */
    notifyDeleted(event: ResourceDeletedEvent): BatchNotificationResult;
    /**
     * Notify all observers asynchronously of a resource creation event.
     *
     * @param event - The resource created event
     * @returns Promise resolving to batch notification result
     */
    notifyCreatedAsync(event: ResourceCreatedEvent): Promise<BatchNotificationResult>;
    /**
     * Notify all observers asynchronously of a resource modification event.
     *
     * @param event - The resource modified event
     * @returns Promise resolving to batch notification result
     */
    notifyModifiedAsync(event: ResourceModifiedEvent): Promise<BatchNotificationResult>;
    /**
     * Notify all observers asynchronously of a resource deletion event.
     *
     * @param event - The resource deleted event
     * @returns Promise resolving to batch notification result
     */
    notifyDeletedAsync(event: ResourceDeletedEvent): Promise<BatchNotificationResult>;
}
