29 lines
1.0 KiB
TypeScript
Raw Normal View History

2019-08-31 20:51:14 -07:00
import { datasetUrlByUrn } from '@datahub/data-models/api/dataset/dataset';
import { DatasetLineageList } from '@datahub/metadata-types/types/entity/dataset/lineage';
import { getJSON } from '@datahub/utils/api/fetcher';
/**
* Constructs the url for a datasets upstreams
* @param urn the urn for the child dataset
*/
const datasetUpstreamUrlByUrn = (urn: string): string => `${datasetUrlByUrn(urn)}/upstreams`;
/**
* Constructs the url for a datasets downstreams
* @param urn
*/
const datasetDownstreamUrlByUrn = (urn: string): string => `${datasetUrlByUrn(urn)}/downstreams`;
/**
* Fetches the list of upstream datasets for a dataset by urn
*/
2019-08-31 20:51:14 -07:00
export const readUpstreamDatasets = (urn: string): Promise<DatasetLineageList> =>
getJSON({ url: datasetUpstreamUrlByUrn(urn) });
/**
* Requests the downstream datasets for the dataset identified by urn
* @param urn string urn for the dataset
*/
2019-08-31 20:51:14 -07:00
export const readDownstreamDatasets = (urn: string): Promise<DatasetLineageList> =>
getJSON({ url: datasetDownstreamUrlByUrn(urn) });