( columnOrder: string[], groups: WorkflowGroup[] )
| 1050 | * given columnOrder. Empty array means all groups are cohesive. |
| 1051 | */ |
| 1052 | export function findSplitGroups( |
| 1053 | columnOrder: string[], |
| 1054 | groups: WorkflowGroup[] |
| 1055 | ): SplitGroupReport[] { |
| 1056 | const positions = new Map<string, number>() |
| 1057 | columnOrder.forEach((name, idx) => positions.set(name, idx)) |
| 1058 | const reports: SplitGroupReport[] = [] |
| 1059 | for (const group of groups) { |
| 1060 | const indices = group.outputs |
| 1061 | .map((o) => positions.get(o.columnName)) |
| 1062 | .filter((i): i is number => i !== undefined) |
| 1063 | .sort((a, b) => a - b) |
| 1064 | if (indices.length < 2) continue |
| 1065 | const min = indices[0] |
| 1066 | const max = indices[indices.length - 1] |
| 1067 | if (max - min + 1 !== indices.length) { |
| 1068 | reports.push({ |
| 1069 | groupId: group.id, |
| 1070 | groupName: group.name ?? group.id, |
| 1071 | actual: indices, |
| 1072 | }) |
| 1073 | } |
| 1074 | } |
| 1075 | return reports |
| 1076 | } |
| 1077 | |
| 1078 | /** Throws if the schema has any invariant violations. Convenience for callers. */ |
| 1079 | export function assertValidSchema(schema: TableSchema, columnOrder: string[] | undefined): void { |
no test coverage detected