import type { PlayRuntimeBackendId } from './backend'; import type { PlayArtifactKind } from './backend'; import type { PlaySchedulerBackendId } from './scheduler-backend'; import { PLAY_RUNTIME_PROVIDERS, PLAY_RUNTIME_PROVIDER_IDS, defaultPlayRuntimeProvider, resolveEnabledPlayRuntimeProvider, resolvePlayRuntimeProvider, type PlayRuntimeProviderId, } from './providers'; export type PlayExecutionProfile = { id: PlayExecutionProfileId; scheduler: PlaySchedulerBackendId; runner: PlayRuntimeBackendId; artifactKind: PlayArtifactKind; label: string; }; export const PLAY_EXECUTION_PROFILE_IDS = { ...PLAY_RUNTIME_PROVIDER_IDS, }; export type PlayExecutionProfileId = PlayRuntimeProviderId; export const PLAY_EXECUTION_PROFILES: Record< PlayExecutionProfileId, PlayExecutionProfile > = PLAY_RUNTIME_PROVIDERS; export function defaultExecutionProfile(): PlayExecutionProfile { return defaultPlayRuntimeProvider(); } export function resolveExecutionProfile( override?: string | null, ): PlayExecutionProfile { try { return resolvePlayRuntimeProvider(override); } catch (error) { if (override?.trim()) { throw new Error( `Unknown execution profile "${override.trim()}". Expected one of: ${Object.keys( PLAY_EXECUTION_PROFILES, ).join(', ')}.`, ); } throw error; } } export function resolveEnabledExecutionProfile( override?: string | null, ): PlayExecutionProfile { try { return resolveEnabledPlayRuntimeProvider(override); } catch (error) { if ( override?.trim() && error instanceof Error && /Unsupported play runtime provider/.test(error.message) ) { throw new Error( `Unknown execution profile "${override.trim()}". Expected one of: ${Object.keys( PLAY_EXECUTION_PROFILES, ).join(', ')}.`, ); } throw error; } }