MCPcopy Index your code
hub / github.com/simstudioai/sim / listWikis

Function listWikis

apps/sim/connectors/azure-devops/azure-devops.ts:308–348  ·  view source on GitHub ↗

* Fetches the list of wikis in the configured project. Returns an empty list on * 401/403/404 so a missing or inaccessible wiki feature degrades gracefully * rather than aborting the sync.

(
  accessToken: string,
  organization: string,
  project: string,
  retryOptions?: Parameters<typeof fetchWithRetry>[2],
  syncContext?: Record<string, unknown>
)

Source from the content-addressed store, hash-verified

306 * rather than aborting the sync.
307 */
308async function listWikis(
309 accessToken: string,
310 organization: string,
311 project: string,
312 retryOptions?: Parameters<typeof fetchWithRetry>[2],
313 syncContext?: Record<string, unknown>
314): Promise<WikiV2[]> {
315 const url = `${ADO_BASE_URL}/${encodeURIComponent(organization)}/${encodeURIComponent(project)}/_apis/wiki/wikis?api-version=${WIKIS_LIST_API_VERSION}`
316 const response = await fetchWithRetry(
317 url,
318 {
319 method: 'GET',
320 headers: { Accept: 'application/json', Authorization: patAuthHeader(accessToken) },
321 },
322 retryOptions
323 )
324 if (!response.ok) {
325 if (response.status === 401 || response.status === 403 || response.status === 404) {
326 /**
327 * 401/403 mean the wikis still exist but this PAT cannot read them right
328 * now — flag the listing as incomplete so reconciliation does not delete
329 * previously synced wiki pages. A 404 means the wiki feature/content is
330 * genuinely absent, so reconciliation stays enabled.
331 */
332 if ((response.status === 401 || response.status === 403) && syncContext) {
333 syncContext.listingCapped = true
334 }
335 logger.warn('Azure DevOps wikis unavailable; skipping wiki listing', {
336 organization,
337 project,
338 status: response.status,
339 })
340 return []
341 }
342 const errorText = await response.text().catch(() => '')
343 logger.error('Failed to list Azure DevOps wikis', { status: response.status, error: errorText })
344 throw new Error(`Failed to list wikis: ${response.status}`)
345 }
346 const data = await response.json()
347 return (data.value as WikiV2[] | undefined) ?? []
348}
349
350/**
351 * Resolves the wikis for the project, caching them on the sync context so a

Callers 1

resolveWikisFunction · 0.85

Calls 5

fetchWithRetryFunction · 0.90
patAuthHeaderFunction · 0.85
textMethod · 0.80
errorMethod · 0.80
warnMethod · 0.65

Tested by

no test coverage detected