1import { Field, FieldType, DataFrame } from '../../types/dataFrame'; 2import { FieldMatcherID } from './ids'; 3import { FieldMatcherInfo } from '../../types/transformations'; 4 5const firstFieldMatcher: FieldMatcherInfo = { 6 id: FieldMatcherID.first, 7 name: 'First Field', 8 description: 'The first field in the frame', 9 10 get: (type: FieldType) => { 11 return (field: Field, frame: DataFrame, allFrames: DataFrame[]) => { 12 return field === frame.fields[0]; 13 }; 14 }, 15 16 getOptionsDisplayText: () => { 17 return `First field`; 18 }, 19}; 20 21const firstTimeFieldMatcher: FieldMatcherInfo = { 22 id: FieldMatcherID.firstTimeField, 23 name: 'First time field', 24 description: 'The first field of type time in a frame', 25 26 get: (type: FieldType) => { 27 return (field: Field, frame: DataFrame, allFrames: DataFrame[]) => { 28 return field.type === FieldType.time && field === frame.fields.find((f) => f.type === FieldType.time); 29 }; 30 }, 31 32 getOptionsDisplayText: () => { 33 return `First time field`; 34 }, 35}; 36 37/** 38 * Registry Initialization 39 */ 40export function getSimpleFieldMatchers(): FieldMatcherInfo[] { 41 return [firstFieldMatcher, firstTimeFieldMatcher]; 42} 43