(
extDoc: Pick<ExternalDocument, 'content' | 'contentDeferred' | 'contentHash' | 'skippedReason'>,
existing: { id: string; contentHash: string | null } | undefined
)
| 88 | * - `add` / `update` / `unchanged`: normal content reconciliation by content hash. |
| 89 | */ |
| 90 | export function classifyExternalDoc( |
| 91 | extDoc: Pick<ExternalDocument, 'content' | 'contentDeferred' | 'contentHash' | 'skippedReason'>, |
| 92 | existing: { id: string; contentHash: string | null } | undefined |
| 93 | ): DocClassification { |
| 94 | if (extDoc.skippedReason) { |
| 95 | return existing ? { type: 'unchanged' } : { type: 'skip' } |
| 96 | } |
| 97 | if (!extDoc.content.trim() && !extDoc.contentDeferred) { |
| 98 | return { type: 'drop' } |
| 99 | } |
| 100 | if (!existing) { |
| 101 | return { type: 'add' } |
| 102 | } |
| 103 | if (existing.contentHash !== extDoc.contentHash) { |
| 104 | return { type: 'update', existingId: existing.id } |
| 105 | } |
| 106 | return { type: 'unchanged' } |
| 107 | } |
| 108 | |
| 109 | /** Estimated source bytes for a pending op, taken from its listing metadata. */ |
| 110 | function estimateOpSizeBytes(op: DocOp): number { |
no outgoing calls
no test coverage detected