( folderId: string | null | undefined, workspaceId: string )
| 208 | * folder references when a workflow's `folderId` is set from request input. |
| 209 | */ |
| 210 | export async function isFolderInWorkspace( |
| 211 | folderId: string | null | undefined, |
| 212 | workspaceId: string |
| 213 | ): Promise<boolean> { |
| 214 | if (!folderId) return true |
| 215 | |
| 216 | const [folder] = await db |
| 217 | .select({ |
| 218 | workspaceId: workflowFolder.workspaceId, |
| 219 | archivedAt: workflowFolder.archivedAt, |
| 220 | }) |
| 221 | .from(workflowFolder) |
| 222 | .where(eq(workflowFolder.id, folderId)) |
| 223 | .limit(1) |
| 224 | |
| 225 | return Boolean(folder && folder.workspaceId === workspaceId && !folder.archivedAt) |
| 226 | } |
| 227 | |
| 228 | /** |
| 229 | * Throws {@link FolderNotFoundError} (HTTP 400) when `folderId` does not belong to |
no test coverage detected