import { ReactElement } from 'react' ; import { Adapters } from 'src/plugins/inspector/public' ; import { GeoJsonProperties } from 'geojson' ; import { copyPersistentState } from '../../reducers/copy_persistent_state' ; import { IField } from '../fields/field' ; import { FieldFormatter , LAYER_TYPE , MAX_ZOOM , MIN_ZOOM } from '../../../common/constants' ; import { AbstractSourceDescriptor , Attribution , DataRequestMeta , Timeslice , } from '../../../common/descriptor_types' ; import { LICENSED_FEATURES } from '../../licensed_features' ; import { PreIndexedShape } from '../../../common/elasticsearch_util' ; export type OnSourceChangeArgs = { propName : string ; value : unknown ; newLayerType ? : LAYER_TYPE ; } ; export type SourceEditorArgs = { clearJoins : ( ) => void ; currentLayerType : string ; hasJoins : boolean ; onChange : ( ... args : OnSourceChangeArgs [ ] ) => Promise < void > ; } ; export type ImmutableSourceProperty = { label : string ; value : string ; link ? : string ; } ; export interface ISource { destroy ( ) : void ; getDisplayName ( ) : Promise < string > ; getInspectorAdapters ( ) : Adapters | undefined ; getType ( ) : string ; isFieldAware ( ) : boolean ; isFilterByMapBounds ( ) : boolean ; isGeoGridPrecisionAware ( ) : boolean ; isQueryAware ( ) : boolean ; isTimeAware ( ) : Promise < boolean > ; getImmutableProperties ( ) : Promise < ImmutableSourceProperty [ ] > ; getAttributionProvider ( ) : ( ( ) => Promise < Attribution [ ] > ) | null ; isESSource ( ) : boolean ; renderSourceSettingsEditor ( sourceEditorArgs ) : ReactElement < any > | null ; supportsFitToBounds ( ) : Promise < boolean > ; cloneDescriptor ( ) : AbstractSourceDescriptor ; getFieldNames ( ) : string [ ] ; getApplyGlobalQuery ( ) : boolean ; getApplyGlobalTime ( ) : boolean ; getApplyForceRefresh ( ) : boolean ; getIndexPatternIds ( ) : string [ ] ; getQueryableIndexPatternIds ( ) : string [ ] ; getGeoGridPrecision ( zoom ) : number ; getPreIndexedShape ( properties ) : Promise < PreIndexedShape | null > ; createFieldFormatter ( field ) : Promise < FieldFormatter | null > ; getValueSuggestions ( field , query ) : Promise < string [ ] > ; getMinZoom ( ) : number ; getMaxZoom ( ) : number ; getLicensedFeatures ( ) : Promise < LICENSED_FEATURES [ ] > ; getUpdateDueToTimeslice ( prevMeta , timeslice ? ) : boolean ; } export class AbstractSource implements ISource { readonly _descriptor : AbstractSourceDescriptor ; private readonly _inspectorAdapters ? : Adapters ; constructor ( descriptor , inspectorAdapters ? ) { this . _descriptor = descriptor ; this . _inspectorAdapters = inspectorAdapters ; } destroy ( ) { } cloneDescriptor ( ) { return copyPersistentState ( this . _descriptor ) ; } async supportsFitToBounds ( ) { return false ; } /**
     * return list of immutable source properties.
     * Immutable source properties are properties that can not be edited by the user.
     */ async getImmutableProperties ( ) { return [ ] ; } getInspectorAdapters ( ) { return this . _inspectorAdapters ; } getType ( ) { return this . _descriptor . type ; } async getDisplayName ( ) { return '' ; } getAttributionProvider ( ) { return null ; } isFieldAware ( ) { return false ; } isGeoGridPrecisionAware ( ) { return false ; } isQueryAware ( ) { return false ; } getFieldNames ( ) { return [ ] ; } renderSourceSettingsEditor ( sourceEditorArgs ) { return null ; } getApplyGlobalQuery ( ) { return false ; } getApplyGlobalTime ( ) { return false ; } getApplyForceRefresh ( ) { return false ; } getIndexPatternIds ( ) { return [ ] ; } getQueryableIndexPatternIds ( ) { return [ ] ; } getGeoGridPrecision ( zoom ) { return 0 ; } isESSource ( ) { return false ; } async getPreIndexedShape ( properties ) { return null ; } async createFieldFormatter ( field ) { return null ; } async getValueSuggestions ( field , query ) { return [ ] ; } async isTimeAware ( ) { return false ; } isFilterByMapBounds ( ) { return false ; } getMinZoom ( ) { return MIN_ZOOM ; } getMaxZoom ( ) { return MAX_ZOOM ; } async getLicensedFeatures ( ) { return [ ] ; } getUpdateDueToTimeslice ( prevMeta , timeslice ? ) { return true ; } }