import { AccessPassport } from "../access-control/accessPassport"; import { Document, DocumentFragment } from "../document/document"; import { CallbackManager } from "../utils/callbacks"; import { BaseRetriever, BaseRetrieverQueryParams } from "./retriever"; import { DocumentMetadataDB } from "../document/metadata/documentMetadataDB"; /** * Abstract base class for retrieving data R from documents retrieved from an underlying source. * Each document retriever implementation should override `getFragmentsUnsafe` to implement their * custom retrieval logic and `processDocuments` to implement desired post-processing logic. * The DocumentRetriever class provides a `retrieveData` method that wraps `getFragmentsUnsafe` with * default access control logic. It is OK to override `retrieveData` if additional access control * handling is required (e.g. if the underlying source can perform optimized RBAC), but the quality * and correctness of the access control logic is the responsibility of the retriever implementation. */ export declare abstract class DocumentRetriever extends BaseRetriever { metadataDB: DocumentMetadataDB; constructor(metadataDB: DocumentMetadataDB, callbackManager?: CallbackManager); /** * Get the DocumentFragments relevant to the given query without performing any access control checks. * @param query The query string to obtain relevant DocumentFragments for. * @returns A promise that resolves to array of retrieved DocumentFragments. */ protected abstract getFragmentsUnsafe(_params: BaseRetrieverQueryParams): Promise; /** * Simple filtering of DocumentFragments with respect to access policies. * @param fragments The DocumentFragments to filter. * @param accessPassport The AccessPassport for the current identity. * @returns A promise that resolves to array of DocumentFragments accessible to the current identity. */ protected filterAccessibleFragments(fragments: DocumentFragment[], accessPassport?: AccessPassport): Promise; /** * Constructs Documents from the given DocumentFragments. Fragments with the same documentId will * be grouped into a single Document. * @param fragments * @returns */ protected getDocumentsForFragments(fragments: DocumentFragment[]): Promise; /** * Perform any post-processing on the retrieved Documents. * @param documents The array of retrieved Documents to post-process. * @returns A promise that resolves to post-processed data. */ protected abstract processDocuments(_documents: Document[]): Promise; /** * Get the data relevant to the given query and which the current identity can access. * @param params The retriever query params to use for the query. * @returns A promise that resolves to the retrieved data. */ retrieveData(params: BaseRetrieverQueryParams): Promise; }