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

Function wikiPageToDocument

apps/sim/connectors/gitlab/gitlab.ts:400–430  ·  view source on GitHub ↗

* Builds a wiki page document (full content) from a fetched page.

(
  apiBase: string,
  encodedProject: string,
  host: string,
  projectPath: string,
  page: GitLabWikiPage
)

Source from the content-addressed store, hash-verified

398 * Builds a wiki page document (full content) from a fetched page.
399 */
400async function wikiPageToDocument(
401 apiBase: string,
402 encodedProject: string,
403 host: string,
404 projectPath: string,
405 page: GitLabWikiPage
406): Promise<ExternalDocument | null> {
407 const content = typeof page.content === 'string' ? page.content : ''
408 const title = page.title?.trim() || page.slug
409 const body = composeBody(title, content)
410 if (!body.trim()) return null
411
412 const contentHash = await buildWikiContentHash(encodedProject, page.slug, content)
413
414 return {
415 externalId: `${WIKI_PREFIX}${page.slug}`,
416 title,
417 content: body,
418 contentDeferred: false,
419 mimeType: 'text/plain',
420 sourceUrl: projectPath
421 ? `https://${host}/${projectPath}/-/wikis/${page.slug}`
422 : `${apiBase}/projects/${encodedProject}/wikis/${page.slug}`,
423 contentHash,
424 metadata: {
425 contentType: 'wiki',
426 title,
427 slug: page.slug,
428 },
429 }
430}
431
432/**
433 * Builds an issue document from a fetched issue.

Callers 1

gitlab.tsFile · 0.85

Calls 2

composeBodyFunction · 0.85
buildWikiContentHashFunction · 0.85

Tested by

no test coverage detected