import { getJSON } from '@datahub/utils/api/fetcher'; /** * Describes the type for map of urn endpoint names to functions */ export type UrnEndpointUrlMap = Record string>; /** * Returns a curried function that requests JSON from an endpoint by a urn * It receives a mapping of jsonEndpoints which is a key value pair, where the key references an endpoint * and the value is a function that returns the url to the endpoint * @template T types that are assignable to the type UrnEndpointUrlMap * @template K the set of properties K in T * @param {T} jsonEndpoints instance of type T * @returns {(urn: string, endpoint: K) => Promise} */ //TODO // eslint-disable-next-line export const readJsonFromEndpoint = , K extends keyof T>(jsonEndpoints: T) => ( urn: string, endpoint: K ): Promise => getJSON({ url: jsonEndpoints[endpoint](urn) });