( currentWorkspaceId: string, otherWorkspaceId: string, direction: PromoteDirection, userId: string )
| 130 | * current -> other; `pull` brings other -> current. |
| 131 | */ |
| 132 | export async function assertCanPromote( |
| 133 | currentWorkspaceId: string, |
| 134 | otherWorkspaceId: string, |
| 135 | direction: PromoteDirection, |
| 136 | userId: string |
| 137 | ): Promise<PromoteAuthorization> { |
| 138 | const edge = await resolveForkEdge(currentWorkspaceId, otherWorkspaceId) |
| 139 | if (!edge) { |
| 140 | throw new ForkError('These workspaces are not a direct fork edge', 400) |
| 141 | } |
| 142 | const sourceWorkspaceId = direction === 'push' ? currentWorkspaceId : otherWorkspaceId |
| 143 | const targetWorkspaceId = direction === 'push' ? otherWorkspaceId : currentWorkspaceId |
| 144 | const source = await assertWorkspaceAdminAccess(sourceWorkspaceId, userId) |
| 145 | const target = await assertWorkspaceAdminAccess(targetWorkspaceId, userId) |
| 146 | return { edge, source, target, sourceWorkspaceId, targetWorkspaceId } |
| 147 | } |
| 148 | |
| 149 | /** Authorize rolling back the last promote into `targetWorkspaceId` (admin only). */ |
| 150 | export async function assertCanRollback( |
no test coverage detected