UNPKG

@knora/api

Version:

JavaScript library that handles API requests to Knora

97 lines (96 loc) 3.54 kB
import { Observable } from "rxjs"; import { KnoraApiConfig } from "../../../knora-api-config"; import { ApiResponseError } from "../../../models/api-response-error"; import { ReadResource } from "../../../models/v2/resources/read/read-resource"; import { CountQueryResponse } from "../../../models/v2/search/count-query-response"; import { Endpoint } from "../../endpoint"; import { V2Endpoint } from "../v2-endpoint"; /** * Params for fulltext search. */ export interface IFulltextSearchParams { /** * Iri of resource class the fulltext search is restricted to, if any. */ limitToResourceClass?: string; /** * Iri of the project the fulltext search is restricted to, if any. */ limitToProject?: string; /** * Iri of standoff class the fulltext search is restricted to, if any. */ limitToStandoffClass?: string; } /** * Params for search by label */ export interface ILabelSearchParams { /** * Iri of the project the search by label is restricted to, if any. */ limitToResourceClass?: string; /** * Iri of the project the search by label is restricted to, if any. */ limitToProject?: string; } /** * Handles requests to the search route of the Knora API. */ export declare class SearchEndpoint extends Endpoint { protected readonly knoraApiConfig: KnoraApiConfig; protected readonly path: string; private readonly v2Endpoint; constructor(knoraApiConfig: KnoraApiConfig, path: string, v2Endpoint: V2Endpoint); /** * URL encodes fulltext search params. * * @param offset offset to be used for paging, zero-based. * @param params parameters for fulltext search. */ private static encodeFulltextParams; /** * URL encodes search by label params. * * @param offset offset to be used for paging, zero-based. * @param params parameters for search by label. */ private static encodeLabelParams; /** * Performs a fulltext search. * * @param searchTerm the term to search for. * @param offset offset to be used for paging, zero-based. * @param params parameters for fulltext search, if any. */ doFulltextSearch(searchTerm: string, offset?: number, params?: IFulltextSearchParams): Observable<ReadResource[] | ApiResponseError>; /** * Performs a fulltext search count query. * * @param searchTerm the term to search for. * @param offset offset to be used for paging, zero-based. * @param params parameters for fulltext search, if any. */ doFulltextSearchCountQuery(searchTerm: string, offset?: number, params?: IFulltextSearchParams): Observable<CountQueryResponse | ApiResponseError>; /** * Performs a Gravsearch query. * * @param gravsearchQuery the given Gravsearch query. */ doExtendedSearch(gravsearchQuery: string): Observable<ReadResource[] | ApiResponseError>; /** * Performs a Gravsearch count query. * * @param gravsearchQuery the given Gravsearch query. */ doExtendedSearchCountQuery(gravsearchQuery: string): Observable<CountQueryResponse | ApiResponseError>; /** * Performs a search by label. * * @param searchTerm the label to search for. * @param offset offset to be used for paging, zero-based. * @param params parameters for fulltext search, if any. */ doSearchByLabel(searchTerm: string, offset?: number, params?: ILabelSearchParams): Observable<ReadResource[] | ApiResponseError>; }