( executor: DbOrTx, childWorkspaceId: string )
| 19 | * block id then derives, exactly as before). |
| 20 | */ |
| 21 | export async function loadForkBlockMap( |
| 22 | executor: DbOrTx, |
| 23 | childWorkspaceId: string |
| 24 | ): Promise<ForkBlockMap> { |
| 25 | const rows = await executor |
| 26 | .select({ |
| 27 | parentWorkflowId: workspaceForkBlockMap.parentWorkflowId, |
| 28 | parentBlockId: workspaceForkBlockMap.parentBlockId, |
| 29 | childWorkflowId: workspaceForkBlockMap.childWorkflowId, |
| 30 | childBlockId: workspaceForkBlockMap.childBlockId, |
| 31 | }) |
| 32 | .from(workspaceForkBlockMap) |
| 33 | .where(eq(workspaceForkBlockMap.childWorkspaceId, childWorkspaceId)) |
| 34 | const parentToChild = new Map<string, { targetBlockId: string; targetWorkflowId: string }>() |
| 35 | const childToParent = new Map<string, { targetBlockId: string; targetWorkflowId: string }>() |
| 36 | for (const row of rows) { |
| 37 | parentToChild.set(row.parentBlockId, { |
| 38 | targetBlockId: row.childBlockId, |
| 39 | targetWorkflowId: row.childWorkflowId, |
| 40 | }) |
| 41 | childToParent.set(row.childBlockId, { |
| 42 | targetBlockId: row.parentBlockId, |
| 43 | targetWorkflowId: row.parentWorkflowId, |
| 44 | }) |
| 45 | } |
| 46 | return { parentToChild, childToParent } |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Orient one workflow's copy mapping (`sourceBlockId -> targetBlockId`) into block pairs. |
no test coverage detected