/**
 * Resource Composite Pattern Types
 *
 * This module defines the interfaces for the Composite pattern implementation,
 * enabling tree structures of resources with recursive operations.
 *
 * @module declarative-api/composite.types
 */
import type { IResourceEntity, IResourceVisitor } from './resource.types';
/**
 * Composite group types for logical resource grouping.
 *
 * Resources can be grouped by their functional purpose:
 * - database: DynamoDB tables, GSIs, streams
 * - messaging: SQS queues, SNS topics
 * - auth: Cognito user pools, clients
 * - storage: S3 buckets
 * - events: EventBridge event buses, rules
 * - custom: User-defined groupings
 *
 * Validates: Requirements 8.4
 */
export type CompositeGroupType = 'database' | 'messaging' | 'auth' | 'storage' | 'events' | 'custom';
/**
 * All valid composite group type values as a readonly array.
 * Useful for validation and iteration.
 */
export declare const COMPOSITE_GROUP_TYPES: readonly CompositeGroupType[];
/**
 * Type guard to check if a value is a valid CompositeGroupType.
 *
 * @param value - The value to check
 * @returns True if the value is a valid CompositeGroupType
 */
export declare function isValidCompositeGroupType(value: unknown): value is CompositeGroupType;
/**
 * Options for adding a child resource to a composite.
 */
export interface AddChildOptions {
    /** Whether to allow duplicate IDs (default: false) */
    readonly allowDuplicates?: boolean;
    /** Position to insert the child (default: end) */
    readonly position?: number;
}
/**
 * Result of a composite operation.
 */
export interface CompositeOperationResult<T> {
    /** Whether the operation was successful */
    readonly success: boolean;
    /** The result value if successful */
    readonly value?: T;
    /** Error message if unsuccessful */
    readonly error?: string;
}
/**
 * Resource Composite interface for grouping related resources.
 *
 * Implements the Composite pattern for tree structure of resources.
 * Operations on composite apply recursively to all children.
 *
 * Implements: Composite Pattern
 *
 * @example
 * ```typescript
 * const databaseGroup = new ResourceComposite('database-resources', 'database');
 * databaseGroup.add(usersTable);
 * databaseGroup.add(ordersTable);
 *
 * // Apply operation to all children
 * databaseGroup.forEach(resource => {
 *   console.log(`Resource: ${resource.id}`);
 * });
 *
 * // Use visitor for type-safe traversal
 * const result = databaseGroup.accept(new ResourceCountVisitor());
 * ```
 *
 * Validates: Requirements 8.1, 8.2, 8.3, 8.4, 8.5, 8.6
 */
export interface IResourceComposite extends IResourceEntity {
    /** Resource type is always 'composite' for composites */
    readonly type: 'composite';
    /** The logical group type for this composite */
    readonly groupType: CompositeGroupType;
    /**
     * Add a child resource to this composite.
     *
     * @param resource - The resource to add
     * @param options - Optional configuration for adding
     * @returns This composite for method chaining
     * @throws DuplicateChildError if resource with same ID exists and allowDuplicates is false
     */
    add(resource: IResourceEntity, options?: AddChildOptions): this;
    /**
     * Remove a child resource by ID.
     *
     * @param resourceId - The ID of the resource to remove
     * @returns True if the resource was removed, false if not found
     */
    remove(resourceId: string): boolean;
    /**
     * Get all direct children of this composite.
     *
     * @returns Array of child resources
     */
    getChildren(): readonly IResourceEntity[];
    /**
     * Get a specific child by ID.
     *
     * @param id - The ID of the child to retrieve
     * @returns The child resource or undefined if not found
     */
    getChild(id: string): IResourceEntity | undefined;
    /**
     * Check if this composite has a child with the given ID.
     *
     * @param id - The ID to check
     * @returns True if a child with the ID exists
     */
    hasChild(id: string): boolean;
    /**
     * Get the number of direct children.
     *
     * @returns The count of direct children
     */
    childCount(): number;
    /**
     * Execute a callback for each resource in the tree (depth-first).
     *
     * @param callback - Function to execute for each resource
     */
    forEach(callback: (resource: IResourceEntity) => void): void;
    /**
     * Map each resource in the tree to a new value (depth-first).
     *
     * @typeParam T - The type of mapped values
     * @param callback - Function to transform each resource
     * @returns Array of transformed values
     */
    map<T>(callback: (resource: IResourceEntity) => T): T[];
    /**
     * Filter resources in the tree by a predicate (depth-first).
     *
     * @param predicate - Function to test each resource
     * @returns Array of resources that pass the test
     */
    filter(predicate: (resource: IResourceEntity) => boolean): IResourceEntity[];
    /**
     * Find a resource in the tree by predicate (depth-first).
     *
     * @param predicate - Function to test each resource
     * @returns The first matching resource or undefined
     */
    find(predicate: (resource: IResourceEntity) => boolean): IResourceEntity | undefined;
    /**
     * Check if any resource in the tree satisfies the predicate.
     *
     * @param predicate - Function to test each resource
     * @returns True if any resource passes the test
     */
    some(predicate: (resource: IResourceEntity) => boolean): boolean;
    /**
     * Check if all resources in the tree satisfy the predicate.
     *
     * @param predicate - Function to test each resource
     * @returns True if all resources pass the test
     */
    every(predicate: (resource: IResourceEntity) => boolean): boolean;
    /**
     * Get all resources in the tree flattened to an array (depth-first).
     *
     * @returns Array of all resources including this composite
     */
    flatten(): IResourceEntity[];
    /**
     * Accept a visitor for traversal operations.
     *
     * @typeParam T - The return type of the visitor
     * @param visitor - The visitor to accept
     * @returns The result of the visitor operation
     */
    accept<T>(visitor: IResourceVisitor<T>): T;
}
/**
 * Lazy loading provider for composite children.
 *
 * Used to implement lazy loading of children through Proxy pattern.
 * Children are only loaded when first accessed.
 *
 * Validates: Requirements 8.6
 */
export interface ILazyChildrenProvider {
    /**
     * Load children for a composite.
     *
     * @param compositeId - The ID of the composite
     * @returns Promise resolving to array of child resources
     */
    loadChildren(compositeId: string): Promise<readonly IResourceEntity[]>;
    /**
     * Check if children have been loaded.
     *
     * @param compositeId - The ID of the composite
     * @returns True if children are already loaded
     */
    isLoaded(compositeId: string): boolean;
}
/**
 * Options for creating a resource composite.
 */
export interface ResourceCompositeOptions {
    /** The logical group type */
    readonly groupType: CompositeGroupType;
    /** Initial children to add */
    readonly children?: readonly IResourceEntity[];
    /** Lazy loading provider for deferred child loading */
    readonly lazyProvider?: ILazyChildrenProvider;
}
/**
 * Extended visitor interface with additional traversal control.
 *
 * Allows visitors to control traversal behavior (skip children, stop early).
 *
 * @typeParam T - The return type of visit operations
 */
export interface IResourceVisitorExtended<T> extends IResourceVisitor<T> {
    /**
     * Called before visiting children of a composite.
     *
     * @param composite - The composite being visited
     * @returns False to skip visiting children
     */
    beforeChildren?(composite: IResourceComposite): boolean;
    /**
     * Called after visiting all children of a composite.
     *
     * @param composite - The composite that was visited
     * @param childResults - Results from visiting children
     */
    afterChildren?(composite: IResourceComposite, childResults: T[]): void;
    /**
     * Check if traversal should stop.
     *
     * @returns True to stop traversal early
     */
    shouldStop?(): boolean;
}
/**
 * Type guard to check if a visitor is an extended visitor.
 *
 * @param visitor - The visitor to check
 * @returns True if the visitor is an extended visitor
 */
export declare function isExtendedVisitor<T>(visitor: IResourceVisitor<T>): visitor is IResourceVisitorExtended<T>;
