import * as Rdf from '../rdf/rdfModel';
import { ElementTypeModel, ElementTypeGraph, LinkTypeModel, ElementModel, LinkModel, PropertyTypeModel, ElementIri, ElementTypeIri, LinkTypeIri, PropertyTypeIri } from '../model';
import { DataProvider, DataProviderLinkCount, DataProviderLookupParams, DataProviderLookupItem } from '../provider';
import { SparqlResponse } from './sparqlModels';
import { SparqlDataProviderSettings } from './sparqlDataProviderSettings';
/**
 * Options for {@link SparqlDataProvider}.
 *
 * @see {@link SparqlDataProvider}
 */
export interface SparqlDataProviderOptions {
    /**
     * [RDF/JS-compatible term factory](https://rdf.js.org/data-model-spec/#datafactory-interface)
     * to create RDF terms.
     */
    factory?: Rdf.DataFactory;
    /**
     * SPARQL endpoint URL to send queries to.
     */
    endpointUrl: string;
    /**
     * Query method for SPARQL queries to use:
     *  - `GET` - more compatible, may have issues with large request URLs;
     *  - `POST` - less compatible, better on large data sets.
     *
     * @default "GET"
     */
    queryMethod?: 'GET' | 'POST';
    /**
     * Custom function to send SPARQL requests.
     *
     * By default, a global [fetch()](https://developer.mozilla.org/en-US/docs/Web/API/fetch)
     * is used with the following options:
     * ```js
     * {
     *     ...params,
     *     credentials: 'same-origin',
     *     mode: 'cors',
     *     cache: 'default',
     * }
     * ```
     */
    queryFunction?: SparqlQueryFunction;
    /**
     * Chunk size to split each SPARQL request with multiple input IRIs into.
     *
     * To disable batch splitting pass `null`.
     *
     * **Default** is `{maxSize: 2500, unit: 'totalLength'}` when `queryMethod` is `GET`,
     * otherwise `null`.
     */
    chunk?: SparqlProviderChunkOptions | null;
    /**
     * Element property type IRIs to use to get image URLs for elements.
     *
     * If needed, image URL extraction can be customized via
     * {@link SparqlDataProviderOptions.prepareImages prepareImages}.
     */
    imagePropertyUris?: ReadonlyArray<string>;
    /**
     * Allows to extract/fetch image URLs externally instead of using
     * {@link SparqlDataProviderOptions.imagePropertyUris imagePropertyUris} option.
     */
    prepareImages?: (elementInfo: Iterable<ElementModel>, signal: AbortSignal | undefined) => Promise<Map<ElementIri, string>>;
    /**
     * Allows to extract/fetch labels separately from SPARQL query as an alternative or
     * in addition to `label` output binding.
     */
    prepareLabels?: (resources: Set<string>, signal: AbortSignal | undefined) => Promise<Map<string, Rdf.Literal[]>>;
}
/**
 * Custom function to send SPARQL HTTP requests.
 */
export type SparqlQueryFunction = (params: {
    url: string;
    body?: string;
    headers: {
        [header: string]: string;
    };
    method: string;
    signal?: AbortSignal;
}) => Promise<Response>;
/**
 * Options for request chunking in {@link SparqlDataProvider}.
 *
 * @see {@link SparqlDataProviderOptions.chunk}
 */
export interface SparqlProviderChunkOptions {
    /**
     * Maximum allowed chunk size.
     *
     * This value must be a non-negative integer.
     *
     * Note that the provider may form the chunk which is larger than
     * specified if it cannot be split into smaller sub-chunks.
     */
    readonly maxSize: number;
    /**
     * Unit of measure for {@link SparqlProviderChunkOptions.maxSize maxSize}:
     *   - `itemCount` - count of IRIs in the chunk;
     *   - `totalLength` - total length of IRIs with separators in the chunk.
     */
    readonly unit: 'itemCount' | 'totalLength';
}
/**
 * Provides graph data by requesting it from a SPARQL endpoint.
 *
 * @category Data
 */
export declare class SparqlDataProvider implements DataProvider {
    readonly factory: Rdf.DataFactory;
    private readonly options;
    private readonly settings;
    private readonly queryFunction;
    private readonly acceptBlankNodes;
    private readonly chunkMeasure;
    private linkByPredicate;
    private linkById;
    private openWorldLinks;
    private propertyByPredicate;
    private openWorldProperties;
    constructor(options: SparqlDataProviderOptions, settings?: SparqlDataProviderSettings);
    private queryChunked;
    knownElementTypes(params: {
        signal?: AbortSignal;
    }): Promise<ElementTypeGraph>;
    propertyTypes(params: {
        propertyIds: ReadonlyArray<PropertyTypeIri>;
        signal?: AbortSignal;
    }): Promise<Map<PropertyTypeIri, PropertyTypeModel>>;
    elementTypes(params: {
        classIds: ReadonlyArray<ElementTypeIri>;
        signal?: AbortSignal;
    }): Promise<Map<ElementTypeIri, ElementTypeModel>>;
    linkTypes(params: {
        linkTypeIds: ReadonlyArray<LinkTypeIri>;
        signal?: AbortSignal;
    }): Promise<Map<LinkTypeIri, LinkTypeModel>>;
    knownLinkTypes(params: {
        signal?: AbortSignal;
    }): Promise<LinkTypeModel[]>;
    elements(params: {
        elementIds: ReadonlyArray<ElementIri>;
        signal?: AbortSignal;
    }): Promise<Map<ElementIri, ElementModel>>;
    private attachImages;
    links(params: {
        primary: ReadonlyArray<ElementIri>;
        secondary: ReadonlyArray<ElementIri>;
        linkTypeIds?: ReadonlyArray<LinkTypeIri>;
        signal?: AbortSignal;
    }): Promise<LinkModel[]>;
    private queryUndirectedLinks;
    private queryDirectedLinks;
    connectedLinkStats(params: {
        elementId: ElementIri;
        inexactCount?: boolean;
        signal?: AbortSignal;
    }): Promise<DataProviderLinkCount[]>;
    lookup(baseParams: DataProviderLookupParams): Promise<DataProviderLookupItem[]>;
    private createFilterQuery;
    /**
     * Executes arbitrary SPARQL SELECT query and returns the result tuples.
     */
    executeSparqlSelect<Binding>(query: string, options?: {
        signal?: AbortSignal;
    }): Promise<SparqlResponse<Binding>>;
    /**
     * Executes arbitrary SPARQL CONSTRUCT query and returns the result RDF graph.
     */
    executeSparqlConstruct(query: string, options?: {
        signal?: AbortSignal;
    }): Promise<Rdf.Quad[]>;
    protected createRefQueryPart(params: {
        elementId: ElementIri;
        linkId?: LinkTypeIri;
        direction?: 'in' | 'out';
    }): string;
    private formatLinkUnion;
    private formatLinkLinks;
    private formatLinkPath;
    private formatPropertyInfo;
    private formatPropertyPath;
    private querySingleElementTypes;
    private queryManyElementTypes;
}
//# sourceMappingURL=sparqlDataProvider.d.ts.map