( parallel: Parallel | null | undefined )
| 156 | * @returns Normalized parallel with only relevant fields |
| 157 | */ |
| 158 | export function normalizeParallel( |
| 159 | parallel: Parallel | null | undefined |
| 160 | ): NormalizedParallel | null | undefined { |
| 161 | if (!parallel) return undefined // Normalize null to undefined |
| 162 | const { id, nodes, parallelType, count, distribution } = parallel |
| 163 | |
| 164 | // Sort nodes for consistent comparison (parallel execution doesn't depend on array order) |
| 165 | const sortedNodes = [...nodes].sort() |
| 166 | const base: NormalizedParallel = { |
| 167 | id, |
| 168 | nodes: sortedNodes, |
| 169 | parallelType, |
| 170 | } |
| 171 | |
| 172 | // Only add optional fields if they have non-null/undefined values |
| 173 | switch (parallelType) { |
| 174 | case 'count': |
| 175 | if (count != null) base.count = count |
| 176 | break |
| 177 | case 'collection': |
| 178 | if (distribution != null) base.distribution = distribution |
| 179 | break |
| 180 | } |
| 181 | |
| 182 | return base |
| 183 | } |
| 184 | |
| 185 | /** Tool configuration with optional UI-only isExpanded field */ |
| 186 | type ToolWithExpanded = Record<string, unknown> & { isExpanded?: boolean } |
no outgoing calls
no test coverage detected