import { PartitionFieldsType } from './anomalies' ; import { ANNOTATION_TYPE } from '../constants/annotations' ; export type AnnotationFieldName = 'partition_field_name' | 'over_field_name' | 'by_field_name' ; export type AnnotationFieldValue = 'partition_field_value' | 'over_field_value' | 'by_field_value' ; export function getAnnotationFieldName ( fieldType ) { return `${ fieldType }_name` as AnnotationFieldName ; } export function getAnnotationFieldValue ( fieldType ) { return `${ fieldType }_value` as AnnotationFieldValue ; } export interface Annotation { _id ? : string ; create_time ? : number ; create_username ? : string ; modified_time ? : number ; modified_username ? : string ; key ? : string ; timestamp : number ; end_timestamp ? : number ; annotation : string ; job_id : string ; type : ANNOTATION_TYPE . ANNOTATION | ANNOTATION_TYPE . COMMENT ; event ? : 'user' | 'delayed_data' | 'model_snapshot_stored' | 'model_change' | 'categorization_status_change' ; detector_index ? : number ; partition_field_name ? : string ; partition_field_value ? : string ; over_field_name ? : string ; over_field_value ? : string ; by_field_name ? : string ; by_field_value ? : string ; } export function isAnnotation ( arg ) { return ( arg . timestamp !== undefined && typeof arg . annotation === 'string' && typeof arg . job_id === 'string' && ( arg . type === ANNOTATION_TYPE . ANNOTATION || arg . type === ANNOTATION_TYPE . COMMENT ) ) ; } export type Annotations = Annotation [ ] ; export function isAnnotations ( arg ) { if ( Array . isArray ( arg ) === false ) { return false ; } return arg . every ( ( d ) => isAnnotation ( d ) ) ; } export interface GetAnnotationsResponse { totalCount : number ; annotations : Record < string , Annotations > ; error ? : string ; success : boolean ; } export interface AnnotationsTable { annotationsData : Annotations ; error ? : string ; }