(q: string)
| 194 | }; |
| 195 | |
| 196 | async function findMatchWorkspace(q: string): Promise<Workspace | undefined> { |
| 197 | try { |
| 198 | const { workspaces } = await API.getWorkspaces({ q, limit: 1 }); |
| 199 | const matchWorkspace = workspaces.at(0); |
| 200 | if (matchWorkspace) { |
| 201 | return matchWorkspace; |
| 202 | } |
| 203 | } catch (err) { |
| 204 | if (isApiValidationError(err)) { |
| 205 | const firstValidationErrorDetail = |
| 206 | err.response.data.validations?.[0].detail; |
| 207 | throw new DetailedError( |
| 208 | "Invalid match value", |
| 209 | firstValidationErrorDetail, |
| 210 | ); |
| 211 | } |
| 212 | |
| 213 | throw err; |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | export function workspacesKey(req: WorkspacesRequest = {}) { |
| 218 | return [...workspacesQueryKeyPrefix, req] as const; |
no test coverage detected