import StateManager from '../state/statemanager.js'; import ServerOgcApi, { HttpMethod, OgcApiLinksResponse } from '../../models/serverogcapi.js'; import ServerOgc from '../../models/serverogc.js'; export type OgcApiClientOptions = { crs?: string; }; /** * This class covers the common part of the OGC API standard described in https://docs.ogc.org/is/19-072/19-072.html. * It contains shared methods between clients of different OGC API standards. * Any OGC API (Maps, Records, Features, STAC...) shall extend this class. */ export default abstract class OgcApiClient { protected readonly serverOgc: ServerOgc; private server?; private readonly stateManager; protected readonly options: OgcApiClientOptions; initialized: boolean; protected get state(): import("../main.js").State; get url(): string; constructor(serverOgc: ServerOgc, opt: OgcApiClientOptions, stateManager: StateManager); getServer(): Promise; protected describeServer(): Promise; protected abstract getUrl(): string; protected abstract loadDescribeServer(): Promise; /** * Load the list of conformance classes, which describe what kind of functionality the server provides. */ loadConformance(): Promise; /** * Fetches and retrieves links from the specified path or URL and returns them in a sanitized format. */ getLinks(path: string | URL): Promise; /** * Retrieves a specific link from the OGC API resource based on the given relation and encoding type. */ getLink(relation: string, path?: string | URL, encodingType?: string): Promise; /** * Fetches all paginated resources from the specified URL until the entire dataset is retrieved. * `dataListName` is the attribute name that holds the list of data items in the response JSON. * For feature items, the attribute name is 'features', for collections, it's 'collections'. */ fetchAll(url: string | URL, dataListName: string, fetchOptions: RequestInit): Promise; protected getFetchOptions(method?: HttpMethod): RequestInit; /** * Sanitizes a list of links by ensuring that their URLs are consistent with the original request URL. * Sanitizes if the original URL does not match the link in the `self` href. * Limitation: Only works if the original URL and the faulty link share at least one common URL path element, e.g.: * '/api/' in (original) https://example.com/api/ and (faulty) https://12345-example.com:8080/mapserv_proxy/api/ * * @param {string} originalPath - The URL of the original request. * @param {OgcApiLinksResponse[] | undefined} links - The array of links to sanitize. * @return {OgcApiLinksResponse[]} The sanitized list of links. */ protected sanitizeLinks(originalPath: string | URL, links: OgcApiLinksResponse[] | undefined): OgcApiLinksResponse[]; /** * Compares two URLs to determine if they are identical, ignoring URL parameters. */ private areIdenticalUrls; /** * Finds the first common path segment between two given URLs. */ private findFirstCommonPath; }