import type { IActionRdfMetadataExtract, IActorRdfMetadataExtractOutput, IActorRdfMetadataExtractArgs } from '@comunica/bus-rdf-metadata-extract'; import { ActorRdfMetadataExtract } from '@comunica/bus-rdf-metadata-extract'; import type { IActorTest, TestResult } from '@comunica/core'; import type { IActionContext } from '@comunica/types'; import type * as RDF from '@rdfjs/types'; import type { UriTemplate } from 'uritemplate'; /** * An RDF Metadata Extract Actor that extracts all Hydra controls from the metadata stream. */ export declare class ActorRdfMetadataExtractHydraControls extends ActorRdfMetadataExtract { static readonly HYDRA: string; static readonly LINK_TYPES: string[]; protected readonly parsedUriTemplateCache: Record; constructor(args: IActorRdfMetadataExtractArgs); test(_action: IActionRdfMetadataExtract): Promise>; /** * Collect all Hydra page links from the given Hydra properties object. * @param pageUrl The page URL in which the Hydra properties are defined. * @param hydraProperties The collected Hydra properties. * @return The Hydra links */ getLinks(pageUrl: string, hydraProperties: Record>): Record; /** * Determine the URL prefix under which servers with an invalidly configured base URL * expose the controls of the given page. * * Concretely, this is the origin of the page URL with the https protocol replaced by http, * including the trailing slash, so that only URLs on the host of the page are matched. * @param pageUrl The page URL in which the Hydra properties are defined. * @return The invalid URL prefix, or undefined if the page URL is not an https URL with a path. */ getInvalidUrlPrefix(pageUrl: string): string | undefined; /** * Correct all URLs within the given Hydra properties that are exposed under the http protocol, * while the page they were retrieved from is hosted over https. * * Occasionally, TPF servers are hosted over https, while their base URL is configured as http. * This causes all URLs in their metadata to be exposed under the http protocol, * which makes the Hydra controls unusable, as they can not be linked to the current page anymore. * Since this is a common problem, we detect it, correct the invalid URLs, and emit a warning. * * Only URLs on the host of the page are corrected, as the controls legitimately refer to http URLs elsewhere, * such as the rdf:subject, rdf:predicate and rdf:object values of hydra:property. * @param pageUrl The page URL in which the Hydra properties are defined. * @param hydraProperties The collected Hydra properties. * @param context The action context, in which a warning will be logged upon detecting an invalid protocol. * @return The Hydra properties, with all invalidly exposed URLs corrected. */ correctProtocolMismatches(pageUrl: string, hydraProperties: Record>, context: IActionContext): Record>; /** * Check if any URL within the given Hydra properties starts with the given prefix. * @param hydraProperties The collected Hydra properties. * @param invalidPrefix The URL prefix of invalidly exposed controls. */ protected hasInvalidUrl(hydraProperties: Record>, invalidPrefix: string): boolean; /** * Parse a URI template, or retrieve it from a cache. * @param {string} template A URI template string. * @return {} A parsed URI template object. */ parseUriTemplateCached(template: string): UriTemplate; /** * Collect all search forms from the given Hydra properties object. * @param hydraProperties The collected Hydra properties. * @return The search forms. */ getSearchForms(hydraProperties: Record>): ISearchForms; /** * Collect all hydra properties from a given metadata stream * in a nice convenient nested hash (property / subject / objects). * @param {RDF.Stream} metadata * @return The collected Hydra properties. */ getHydraProperties(metadata: RDF.Stream): Promise>>; run(action: IActionRdfMetadataExtract): Promise; } export interface ISearchForm { /** * The dataset in which the search form is defined. */ dataset: string; /** * The URI template containing Hydra variables. */ template: string; /** * The mappings. * With as keys the Hydra properties, * and as values the Hydra variables */ mappings: Record; /** * Instantiate a uri based on the given Hydra variable values. * @param entries Entries with as keys Hydra properties, * and as values Hydra variable values. * @return {string} The instantiated URI */ getUri: (entries: Record) => string; } export interface ISearchForms { /** * All available search forms. */ values: ISearchForm[]; }