?
ReaderDocument
TypeA built document as read receives it: its id, source, metadata, and entities, with chunks() and bytes().
The document that read and relinked receive. It carries the document's id, its sourceId (key your rows by it so cleared can drop them), filename, content type, external id on a mapped source, metadata, the entities it asserts, and counts. url is a short-lived link to the file the document came from, valid for the delivery. chunks() returns the document's passages as indexed, each with its entities. bytes() returns the original file, for a reader that needs the drawing itself rather than its text. Each loads on first call and keeps the result.
ReaderDocument.ts
interface ReaderDocument { id: string sourceId: string filename: string | null contentType: string | null externalId: string | null metadata: DocumentMetadata | null entities: string[] pageCount: number | null chunkCount: number | null createdAt: string url: string | null chunks(): Promise<DataSourceChunk[]> bytes(): Promise<Uint8Array> }
Fields
id
string
The document id. Key your rows by it.
sourceId
string
The data source it belongs to, so cleared can drop its rows.
externalId
string | null
The identity a mapped source replaces by; null on unmapped sources.
entities
string[]
The entities the document asserts, sorted.
url
string | null
A short-lived link to the file it came from, valid for the delivery.
chunks()
() => Promise<DataSourceChunk[]>
Its passages as indexed, each with its entities.
bytes()
() => Promise<Uint8Array>
The original file, for a reader that needs the drawing rather than its text.
Read text or bytes
read: async (document) => { const chunks = await document.chunks(); const image = document.contentType?.startsWith('image/') ? await document.bytes() : null; }