Charlie Tran 843a6c5bbb
feat(frontend): update datahub-web client UI code (#1806)
* Releases updated version of datahub-web client UI code

* Fix typo in yarn lock

* Change yarn lock to match yarn registry directories

* Previous commit missed some paths

* Even more changes to yarnlock missing in previous commit

* Include codegen file for typings

* Add files to get parity for datahub-web and current OS datahub-midtier

* Add in typo fix from previous commit - change to proper license

* Implement proper OS fix for person entity picture url

* Workarounds for open source DH issues

* Fixes institutional memory api and removes unopensourced tabs for datasets

* Fixes search dataset deprecation and user search issue as a result of changes

* Remove internal only options in the avatar menu
2020-08-26 15:44:50 -07:00

71 lines
3.8 KiB
TypeScript

import { IFeatureEntity } from '@datahub/metadata-types/types/entity/feature/feature-entity';
import { encodeUrn } from '@datahub/utils/validators/urn';
import { getJSON, postJSON } from '@datahub/utils/api/fetcher';
import { ApiVersion } from '@datahub/utils/api/shared';
import { featureUrlRoot } from '@datahub/data-models/api/feature';
import { IFrameFeatureStatusConfig } from '@datahub/metadata-types/types/entity/feature/frame/frame-feature-status-config';
import { IFrameFeatureEditableConfig } from '@datahub/metadata-types/types/entity/feature/frame/frame-feature-editable-config';
import { IFrameFeatureTierConfig } from '@datahub/metadata-types/types/entity/feature/frame/frame-feature-tier-config';
/**
* Constructs the url for a Feature identified by the provided string urn
* @param {string} urn the urn to use in querying for Feature entity
* @returns {string}
*/
export const featureUrlByUrn = (urn: string): string => `${featureUrlRoot(ApiVersion.v2)}/${encodeUrn(urn)}`;
/**
* Constructs the url to the Feature endpoint to update it's statusConfig metadata aspect
* @param {string} urn the string urn for the Feature
*/
export const featureStatusConfigUrlByUrn = (urn: string): string => `${featureUrlByUrn(urn)}/statusconfig`;
/**
* Constructs the url to the Feature endpoint to update it's tierConfig metadata aspect
* @param {string} urn the string urn for the Feature Tier endpoint
*/
export const featureTierConfigUrlByUrn = (urn: string): string => `${featureUrlByUrn(urn)}/tierconfig`;
/**
* Constructs the url to the Feature endpoint to update it's editableConfig metadata aspect
* @param {string} urn the string urn for the Feature
*/
export const featureEditableConfigUrlByUrn = (urn: string): string => `${featureUrlByUrn(urn)}/editableconfig`;
/**
* Queries the Feature endpoint with the urn provided to retrieve entity information
* @param {string} urn
* @returns {Promise<IFeatureEntity>}
*/
export const readFeature = (urn: string): Promise<IFeatureEntity> => getJSON({ url: featureUrlByUrn(urn) });
/**
* Updates the Feature represented by the urn, by making a POST request to the endpoint at the url
* @param {string} urn the string urn for the Feature to be updated
* @param {IFrameFeatureStatusConfig} statusConfig the full statusConfig metadata aspect with updated values
* @returns {Promise<{updated: true}>} if update is successful a response string with value of `updated` will be returned
*/
export const updateFeatureStatusConfig = (
urn: string,
statusConfig: IFrameFeatureStatusConfig
): Promise<{ updated: true }> => postJSON({ url: featureStatusConfigUrlByUrn(urn), data: statusConfig });
/**
* Updates the Feature represented by the urn, by making a POST request to the endpoint at the url
* @param {string} urn the string urn for the Feature to be updated
* @param {IFrameFeatureEditableConfig} editableConfig the full editableConfig metadata aspect with the updated values for this Feature
* @returns {Promise<{updated: true}>} if update is successful a response string with value of `updated` will be returned
*/
export const updateFeatureEditableConfig = (
urn: string,
editableConfig: IFrameFeatureEditableConfig
): Promise<{ updated: true }> => postJSON({ url: featureEditableConfigUrlByUrn(urn), data: editableConfig });
/**
* Updates the Feature represented by the urn, by making a POST request to the endpoint at the url
* @param {string} urn the string urn for the Feature to be updated
* @param {IFrameFeatureTierConfig} tierConfig the tierConfig aspect with the updated value of `tier` for this Feature
* @returns {Promise<{updated: true}>} if update is successful a response string with value of `updated` will be returned
*/
export const updateFeatureTierConfig = (urn: string, tierConfig: IFrameFeatureTierConfig): Promise<{ update: true }> =>
postJSON({ url: featureTierConfigUrlByUrn(urn), data: tierConfig });