MCPcopy Index your code
hub / github.com/coder/coder / findMatchWorkspace

Function findMatchWorkspace

site/src/api/queries/workspaces.ts:196–215  ·  view source on GitHub ↗
(q: string)

Source from the content-addressed store, hash-verified

194};
195
196async 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
217export function workspacesKey(req: WorkspacesRequest = {}) {
218 return [...workspacesQueryKeyPrefix, req] as const;

Callers 1

autoCreateWorkspaceFunction · 0.85

Calls 1

isApiValidationErrorFunction · 0.90

Tested by

no test coverage detected