import { type ServiceResult } from '../models/service-result.js'; import { ProfilingDefinitionService, type DefinitionType, type ProfilingStatus } from '../services/ProfilingDefinitionService.js'; import { ProfilingExecutionService } from '../services/ProfilingExecutionService.js'; /** * Execution mode: single definition or bulk. */ export type ProfileMode = 'single' | 'bulk'; /** * Options for the profile execution operation. */ export type ProfileOptions = { /** Target org username or alias */ targetOrg: string; /** Profile by definition key(s) (e.g., PD-0001). Accepts multiple keys. */ keys?: string[]; /** Profile by Salesforce definition ID */ definitionId?: string; /** Bulk profile by type */ type?: DefinitionType; /** Filter by current status (e.g., "NOT PROFILED", "ERROR") */ status?: ProfilingStatus; /** Object namespace filter */ namespace?: string; /** Filter by definition category (e.g., "Baseline", "Record Types") */ category?: string; /** Filter by time category (e.g., "Lifetime", "2026 vs 2025") */ timeCategory?: string; /** Filter by segment category (e.g., "Historical", "Enterprise Sales") */ segmentCategory?: string; /** Limit number of definitions processed */ limit?: number; /** Skip definitions with zero records (default: true) */ skipEmpty?: boolean; /** Parallel execution threads 1-10 (default: 5) */ parallel?: number; /** Progress callback for bulk execution */ onProgress?: (message: string) => void; logger?: Console; }; /** * Result of a single profiling execution. */ export type ProfileExecutionResult = { /** Definition key (e.g., PD-0001) */ definitionKey: string; /** Definition ID */ definitionId: string; /** Object API name */ objectName: string; /** Execution status */ status: 'success' | 'failed' | 'skipped'; /** Request ID (if execution started) */ requestId?: string; /** Error message (if failed) */ errorMessage?: string; /** Error code (if failed) */ errorCode?: string; /** Skip reason (if skipped) */ skipReason?: string; /** Resolution guidance (if failed) */ resolution?: string; /** Duration in ms */ durationMs: number; }; /** * Result of profile execution operation. */ export type ProfileResult = { /** Execution mode */ mode: ProfileMode; /** Individual execution results */ executions: ProfileExecutionResult[]; /** Summary statistics */ summary: { total: number; successful: number; failed: number; skipped: number; }; }; /** * Error codes specific to profile operations. */ export declare const ProfileErrorCodes: { /** No selection provided (key/id/type) */ readonly NO_SELECTION: "PROFILE_NO_SELECTION"; /** Multiple selection flags provided */ readonly INVALID_SELECTION: "PROFILE_INVALID_SELECTION"; /** Definition not found */ readonly DEFINITION_NOT_FOUND: "PROFILE_DEFINITION_NOT_FOUND"; /** Definition ID has invalid Salesforce ID format */ readonly INVALID_ID: "PROFILE_INVALID_ID"; /** Parallel out of range (1-10) */ readonly INVALID_PARALLEL: "PROFILE_INVALID_PARALLEL"; /** Query for definitions failed */ readonly QUERY_FAILED: "PROFILE_QUERY_FAILED"; /** No definitions found matching filters */ readonly NO_DEFINITIONS_FOUND: "PROFILE_NO_DEFINITIONS_FOUND"; /** Execution failed */ readonly EXECUTION_FAILED: "PROFILE_EXECUTION_FAILED"; /** Operation failed unexpectedly */ readonly OPERATION_FAILED: "PROFILE_OPERATION_FAILED"; }; /** * Orchestrates profiling execution for single and bulk modes. * * Follows the 4-layer architecture: Command → Operation → Service → API * This operation layer handles business logic orchestration: * 1. Validates options (must have exactly one of key/id/type) * 2. Routes to single or bulk execution * 3. Transforms service results to spec-compliant ProfileResult format * 4. Handles partial failures (return success if any succeeded) * * @example * ```typescript * const operation = new ProfileOperation(executionService, definitionService); * * // Single mode * const result = await operation.execute({ * targetOrg: 'myOrg', * key: 'PD-0001', * }); * * // Bulk mode * const result = await operation.execute({ * targetOrg: 'myOrg', * type: 'metadata', * parallel: 5, * onProgress: (msg) => console.log(msg), * }); * ``` */ export declare class ProfileOperation { private readonly executionService; private readonly definitionService; private readonly logger?; /** * Creates a new ProfileOperation instance. * * @param executionService - Service for executing and monitoring profiling operations * @param definitionService - Service for querying profiling definitions * @param logger - Optional logger for debug output */ constructor(executionService: ProfilingExecutionService, definitionService: ProfilingDefinitionService, logger?: Console | undefined); /** * Validates profile operation options. * * @param options - The profile options to validate * @returns Error code if invalid, undefined if valid */ private static validateOptions; /** * Creates an empty ProfileResult for failure cases. * * @param mode - The execution mode * @returns Empty ProfileResult */ private static createEmptyResult; /** * Executes the profile operation. * * @param options - Profile operation options * @returns ServiceResult containing ProfileResult */ execute(options: ProfileOptions): Promise>; /** * Executes profiling for a single definition by key or ID. * * @param options - Profile operation options (key or definitionId must be set) * @returns ServiceResult containing ProfileResult */ private executeSingle; /** * Executes profiling for multiple keys by iterating and aggregating results. * * @param options - Profile operation options (keys must have 2+ entries) * @returns ServiceResult containing aggregated ProfileResult */ private executeMultipleKeys; /** * Executes profiling for multiple definitions matching type and filters. * * @param options - Profile operation options (type must be set) * @returns ServiceResult containing ProfileResult */ private executeBulk; }