* Produces a canonical metadata stub with a deterministic contentHash that * does not depend on which API surface (v1 CQL or v2) returned the page.
(
page: Record<string, unknown>,
options: {
spaceId?: unknown
labels?: string[]
sourceUrl?: string
} = {}
)
| 96 | * does not depend on which API surface (v1 CQL or v2) returned the page. |
| 97 | */ |
| 98 | function pageToStub( |
| 99 | page: Record<string, unknown>, |
| 100 | options: { |
| 101 | spaceId?: unknown |
| 102 | labels?: string[] |
| 103 | sourceUrl?: string |
| 104 | } = {} |
| 105 | ): ExternalDocument { |
| 106 | const version = page.version as Record<string, unknown> | undefined |
| 107 | const versionNumber = version?.number as number | undefined |
| 108 | const lastModified = (version?.createdAt ?? version?.when ?? '') as string |
| 109 | const versionKey = versionNumber ?? lastModified |
| 110 | |
| 111 | return { |
| 112 | externalId: String(page.id), |
| 113 | title: (page.title as string) || 'Untitled', |
| 114 | content: '', |
| 115 | contentDeferred: true, |
| 116 | mimeType: 'text/plain', |
| 117 | sourceUrl: options.sourceUrl, |
| 118 | contentHash: `confluence:${page.id}:${versionKey}`, |
| 119 | metadata: { |
| 120 | spaceId: options.spaceId, |
| 121 | status: page.status, |
| 122 | version: versionNumber, |
| 123 | labels: options.labels ?? [], |
| 124 | lastModified, |
| 125 | }, |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * Converts a v1 CQL search result item to a lightweight metadata stub. |
no outgoing calls
no test coverage detected