/** * Shared types for profiling execution and bulk execution. * * These types were extracted from ProfilingExecutionService during the * CLI-1415 decomposition to allow BulkExecutionService to use them * without circular dependencies. ProfilingExecutionService re-exports * all types for backward compatibility — no consumer imports change. * * @module models/profiling-execution-types */ import type { ProfilingDefinition } from '../services/ProfilingDefinitionService.js'; import type { ServiceResult } from './service-result.js'; import { type ProfilingRequestStatus, TERMINAL_STATUSES } from './status-types.js'; export { type ProfilingRequestStatus, TERMINAL_STATUSES }; /** * Profiling status information. */ export type ProfilingStatus = { /** The profiling request ID */ requestId: string; /** Current status */ status: ProfilingRequestStatus; /** The associated definition ID */ definitionId: string; /** Error message if status is Rejected */ errorMessage?: string; /** When the request was created (ISO 8601) */ createdDate?: string; /** When the request was last modified (ISO 8601) */ lastModifiedDate?: string; }; /** * Profiling result after completion. */ export type ProfilingResult = { /** The profiling request ID */ requestId: string; /** Final status */ status: ProfilingRequestStatus; /** The associated definition ID */ definitionId: string; /** Whether profiling completed successfully */ success: boolean; /** Error message if profiling failed */ errorMessage?: string; /** When the request started (ISO 8601) */ startedAt?: string; /** When the request completed (ISO 8601) */ completedAt?: string; /** Total duration in milliseconds */ durationMs?: number; }; /** * Options for the execute() method. */ export type ExecuteOptions = { /** Skip definition existence validation. Use when the caller has already verified the definition exists. */ skipValidation?: boolean; }; /** * Callback interface for profiling operations used by BulkExecutionService. * Decouples bulk orchestration from single-execution mechanics. */ export type IProfilingExecutor = { /** Triggers a single profiling execution and returns the request ID */ execute(definitionId: string): Promise>; /** Gets the current status for a profiling request */ getStatus(requestId: string): Promise>; }; /** * Options for bulk execution of profiling definitions. */ export type BulkExecutionOptions = { /** Number of parallel threads (1-10, default 5) */ parallel?: number; /** Skip definitions with no records to profile (default true) */ skipEmpty?: boolean; /** Polling interval for status checks in milliseconds (default 5000ms) */ pollInterval?: number; /** Wait for profiling to complete (default true). Set to false for enqueue-only mode. */ waitForCompletion?: boolean; }; import { type DefinitionExecutionStatus } from './status-types.js'; export { type DefinitionExecutionStatus }; /** * Reason why a definition was skipped. */ export type SkipReason = 'empty' | 'in_progress' | 'error'; /** * Result of executing a single definition in bulk execution. */ export type DefinitionExecutionResult = { /** The profiling definition */ definition: ProfilingDefinition; /** Execution status */ status: DefinitionExecutionStatus; /** The profiling request ID (if execution started) */ requestId?: string; /** Profiling result (if completed) */ result?: ProfilingResult; /** Error message (if failed) */ errorMessage?: string; /** Error code (if failed) */ errorCode?: string; /** Skip reason (if skipped) */ skipReason?: SkipReason; /** User-friendly resolution guidance (if failed) */ resolution?: string; /** Duration in milliseconds */ durationMs: number; }; /** * Summary of bulk execution results. */ export type BulkExecutionSummary = { /** Total number of definitions processed */ total: number; /** Number of successfully completed definitions */ successful: number; /** Number of failed definitions */ failed: number; /** Number of skipped definitions */ skipped: number; }; /** * Complete result of bulk execution. */ export type BulkExecutionResult = { /** Summary statistics */ summary: BulkExecutionSummary; /** Results for each definition */ definitions: DefinitionExecutionResult[]; }; /** * Progress update during bulk execution. */ export type BulkProgressUpdate = { /** Current definition being processed */ current: ProfilingDefinition; /** Current status of the definition */ status: DefinitionExecutionStatus; /** Index of current definition (0-based) */ index: number; /** Total number of definitions */ total: number; /** Running summary of results so far */ summary: BulkExecutionSummary; /** Optional message describing current activity */ message?: string; }; /** * Callback function for progress updates during bulk execution. */ export type ProgressCallback = (update: BulkProgressUpdate) => void;