mirror of
https://github.com/datahub-project/datahub.git
synced 2025-08-09 17:58:03 +00:00

* 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
90 lines
2.5 KiB
TypeScript
90 lines
2.5 KiB
TypeScript
import { DatasetClassifiers } from 'datahub-web/constants';
|
|
import { arrayMap } from '@datahub/utils/array/index';
|
|
import { keysEquiv } from '@datahub/data-models/entity/dataset/helpers/validators/base';
|
|
import { IComplianceEntity } from 'datahub-web/typings/api/datasets/compliance';
|
|
import { IMetadataType } from '@datahub/data-models/types/entity/validators';
|
|
|
|
/**
|
|
* Maps a datasetClassification property to the expected type of boolean
|
|
* @param {string} prop
|
|
* @returns {IMetadataType}
|
|
*/
|
|
const datasetClassificationPropType = (prop: string): IMetadataType => ({
|
|
'@type': 'boolean',
|
|
'@name': prop
|
|
});
|
|
|
|
/**
|
|
* Lists the types for objects or instances in the the compliance metadata entities list
|
|
* @type Array<IMetadataType>
|
|
*/
|
|
const complianceEntitiesTaxonomy: Array<IMetadataType> = [
|
|
{
|
|
'@type': 'array',
|
|
'@name': 'complianceEntities',
|
|
'@props': [
|
|
{
|
|
'@name': 'identifierField',
|
|
'@type': 'string'
|
|
},
|
|
{
|
|
'@name': 'identifierType',
|
|
'@type': ['string', 'null']
|
|
},
|
|
{
|
|
'@type': ['string', 'null'],
|
|
'@name': 'logicalType'
|
|
},
|
|
{
|
|
'@name': 'nonOwner',
|
|
'@type': ['boolean', 'null']
|
|
},
|
|
{
|
|
'@name': 'readonly',
|
|
'@type': 'boolean'
|
|
},
|
|
{
|
|
'@name': 'valuePattern',
|
|
'@type': ['string', 'null']
|
|
}
|
|
]
|
|
}
|
|
];
|
|
|
|
/**
|
|
* Defines the shape of the dataset compliance metadata json object using the IMetadataType interface
|
|
* @type {Array<IMetadataType>}
|
|
*/
|
|
const complianceMetadataTaxonomy: Array<IMetadataType> = [
|
|
{
|
|
'@type': 'object',
|
|
'@name': 'datasetClassification',
|
|
'@props': arrayMap(datasetClassificationPropType)(Object.keys(DatasetClassifiers))
|
|
},
|
|
...complianceEntitiesTaxonomy,
|
|
{
|
|
'@type': ['string', 'null'],
|
|
'@name': 'compliancePurgeNote'
|
|
},
|
|
{
|
|
'@type': 'string',
|
|
'@name': 'complianceType'
|
|
},
|
|
{
|
|
'@type': ['string', 'null'],
|
|
'@name': 'confidentiality'
|
|
}
|
|
];
|
|
|
|
export default keysEquiv;
|
|
|
|
/**
|
|
* Type guard asserts that object is assignable to { complianceEntities: Array<IComplianceEntity> }
|
|
* @param {*} object object to be tested against complianceEntitiesTaxonomy
|
|
* @returns {(object is { complianceEntities: Array<IComplianceEntity> })}
|
|
*/
|
|
const isMetadataObject = (object: unknown): object is { complianceEntities: Array<IComplianceEntity> } =>
|
|
keysEquiv(object as Record<string, unknown>, complianceEntitiesTaxonomy);
|
|
|
|
export { complianceMetadataTaxonomy, complianceEntitiesTaxonomy, isMetadataObject };
|