Charlie Tran 10aab5c7a7
feat(frontend): Catchup frontend for internal development changes (#1933)
* Catchup frontend for internal development changes

* Revert accidental change to test file
2020-10-11 11:40:32 -07:00

31 lines
1.1 KiB
TypeScript

import { ApiVersion, getApiRoot } from '@datahub/utils/api/shared';
import { getJSON } from '@datahub/utils/api/fetcher';
import { encodeUrn } from '@datahub/utils/validators/urn';
/**
* Constructs the Dataset url root endpoint
* @param {ApiVersion} version the version of the api applicable to retrieve the Dataset
* @returns {string}
*/
const datasetUrlRoot = (version: ApiVersion): string => `${getApiRoot(version)}/datasets`;
/**
* Constructs the url for a dataset identified by the provided string urn
* @param {string} urn the urn to use in querying for dataset entity
* @returns {string}
*/
export const datasetUrlByUrn = (urn: string): string => `${datasetUrlRoot(ApiVersion.v2)}/${encodeUrn(urn)}`;
/**
* Constructs the url for a dataset identified by the provided string urn
* @param {string} urn the urn to use in querying for dataset entity
* @returns {string}
*/
export const datasetV1UrlByUrn = (urn: string): string => `${datasetUrlRoot(ApiVersion.v1)}/${encodeUrn(urn)}`;
/**
* Reads a dataset entity from api
*/
export const readDataset = (urn: string): Promise<Com.Linkedin.Dataset.Dataset> =>
getJSON({ url: datasetUrlByUrn(urn) });