mirror of
https://github.com/datahub-project/datahub.git
synced 2025-07-15 05:04:45 +00:00
23 lines
786 B
TypeScript
23 lines
786 B
TypeScript
import { IDatasetSchema, IDatasetSchemaGetResponse } from 'wherehows-web/typings/api/datasets/schema';
|
|
import { datasetUrlByUrn } from 'wherehows-web/utils/api/datasets/shared';
|
|
import { getJSON } from 'wherehows-web/utils/api/fetcher';
|
|
|
|
/**
|
|
* Returns the url for a dataset schema by urn
|
|
* @param {string} urn
|
|
* @return {string}
|
|
*/
|
|
const datasetSchemaUrlByUrn = (urn: string): string => `${datasetUrlByUrn(urn)}/schema`;
|
|
|
|
/**
|
|
* Reads the schema for a dataset with the related urn
|
|
* @param {string} urn
|
|
* @return {Promise<IDatasetSchema>}
|
|
*/
|
|
const readDatasetSchemaByUrn = async (urn: string): Promise<IDatasetSchema> => {
|
|
const { schema } = await getJSON<IDatasetSchemaGetResponse>({ url: datasetSchemaUrlByUrn(urn) });
|
|
return schema;
|
|
};
|
|
|
|
export { readDatasetSchemaByUrn };
|