* Builds a wiki page stub. The contentHash is derived from the page ETag * (falls back to the page id when no ETag is available), guaranteeing the * hash is identical between listing and content fetch.
( organization: string, project: string, wiki: WikiV2, page: WikiPageDetail, etag: string | null )
| 406 | * hash is identical between listing and content fetch. |
| 407 | */ |
| 408 | function wikiPageToStub( |
| 409 | organization: string, |
| 410 | project: string, |
| 411 | wiki: WikiV2, |
| 412 | page: WikiPageDetail, |
| 413 | etag: string | null |
| 414 | ): ExternalDocument { |
| 415 | const title = page.path.split('/').filter(Boolean).pop() || page.path || 'Untitled' |
| 416 | const sourceUrl = wiki.remoteUrl |
| 417 | ? `${wiki.remoteUrl}?pagePath=${encodeURIComponent(page.path)}` |
| 418 | : undefined |
| 419 | return { |
| 420 | externalId: wikiPageExternalId(wiki.id, page.path), |
| 421 | title, |
| 422 | content: '', |
| 423 | contentDeferred: true, |
| 424 | mimeType: 'text/plain', |
| 425 | sourceUrl, |
| 426 | contentHash: `ado:wiki:${wiki.id}:${page.path}:${etag ?? page.id}`, |
| 427 | metadata: { |
| 428 | kind: 'wiki', |
| 429 | organization, |
| 430 | project, |
| 431 | wikiId: wiki.id, |
| 432 | wikiName: wiki.name, |
| 433 | pageId: page.id, |
| 434 | pagePath: page.path, |
| 435 | }, |
| 436 | } |
| 437 | } |
| 438 | |
| 439 | /** |
| 440 | * Builds a work item document. Work items are returned inline (not deferred) |
no test coverage detected