// SPDX-License-Identifier: MIT // Copyright contributors to the kepler.gl project import {RGBColor, Merge, RequireFrom} from './types'; import { Filter, InteractionConfig, AnimationConfig, SplitMap, Feature, MapLegendControlSettings } from './reducers'; import {LayerTextLabel, LayerPropertyTransition} from './layers'; import {ChartConfig} from './charts'; import {CameraBookmark, CameraTour} from './camera'; export type SavedFilter = { dataId: Filter['dataId']; id: Filter['id']; name: Filter['name']; endName?: Filter['endName']; type: Filter['type']; value: Filter['value']; // deprecated enlarged?: Filter['enlarged']; view?: Filter['view']; plotType: Filter['plotType']; yAxis: { name: string; type: string; } | null; speed: Filter['speed']; layerId: Filter['layerId']; syncedWithLayerTimeline: Filter['syncedWithLayerTimeline']; syncTimelineMode: Filter['syncTimelineMode']; /** Hide rows that match the filter instead of keeping them. */ inverted?: boolean; }; export type MinSavedFilter = RequireFrom; export type ParsedFilter = SavedFilter | MinSavedFilter; export type SavedInteractionConfig = { tooltip: InteractionConfig['tooltip']['config'] & { enabled: boolean; }; geocoder: { enabled: boolean; limitSearch?: boolean; color?: RGBColor; }; brush: InteractionConfig['brush']['config'] & { enabled: boolean; }; coordinate: { enabled: boolean; }; annotation?: { enabled: boolean; }; legend?: { enabled: boolean; hideInvisibleLayers?: boolean; }; zoomOpacity?: InteractionConfig['zoomOpacity']['config'] & { enabled: boolean; }; }; export type SavedScale = string; export type SavedVisualChannels = { [key: string]: SavedField | SavedScale; }; export type SavedLayer = { id: string; type: string; config: { dataId: string; label: string; color: RGBColor; highlightColor?: RGBColor; uniqueIdField?: string | null; columns: { [key: string]: string; }; columnMode: string; isVisible: boolean; visConfig: Record; hidden: boolean; isIncludedInLegend?: boolean; propertyTransitions?: Record; textLabel: Merge; }; visualChannels: SavedVisualChannels; }; export type MinSavedLayerConfig = RequireFrom; export type MinSavedLayer = { id: string; type: string; config: MinSavedLayerConfig; visualChannels?: SavedVisualChannels; }; export type ParsedLayer = SavedLayer | MinSavedLayer; export type ParsedEffect = { id: string; type: string; isEnabled: boolean; parameters: Record; }; export type SavedEffect = ParsedEffect; export type SavedAnimationConfig = { currentTime: AnimationConfig['currentTime']; speed: AnimationConfig['speed']; timeFormat?: AnimationConfig['timeFormat']; timezone?: AnimationConfig['timezone']; }; export type SavedEditor = { features: Feature[]; visible: boolean; }; export type SavedVisState = { cameraTour?: CameraTour; cameraBookmarks?: CameraBookmark[]; filters: SavedFilter[]; layers: SavedLayer[]; effects: SavedEffect[]; charts?: ChartConfig[]; interactionConfig: SavedInteractionConfig; layerBlending: string; overlayBlending?: string; splitMaps: SplitMap[]; animationConfig: SavedAnimationConfig; editor?: SavedEditor; layerOrder?: any[]; groupBys?: any[]; joins?: any[]; }; // Min saved config can be passed to addDataToMap export type MinSavedVisStateV1 = { cameraTour?: CameraTour; cameraBookmarks?: CameraBookmark[]; filters?: MinSavedFilter[]; layers?: MinSavedLayer[]; effects?: SavedEffect[]; charts?: ChartConfig[]; interactionConfig?: Partial; layerBlending?: string; overlayBlending?: string; splitMaps?: SplitMap[]; animationConfig?: SavedAnimationConfig; editor?: SavedEditor; }; export type ParsedVisState = { cameraTour?: CameraTour | null; cameraBookmarks?: CameraBookmark[]; layers?: ParsedLayer[]; effects?: ParsedEffect[]; charts?: ChartConfig[]; filters?: ParsedFilter[]; interactionConfig?: Partial; layerBlending?: string; overlayBlending?: string; splitMaps?: SplitMap[]; animationConfig?: Partial; layerOrder?: any[]; groupBys?: any[]; joins?: any[]; }; export type ParsedUiState = { mapControls?: { mapLegend?: { active?: boolean; settings?: { position?: { x: number; y: number; anchorX: 'left' | 'right'; anchorY: 'top' | 'bottom'; }; contentHeight?: number; }; }; chart?: { active?: boolean; }; mapInfo?: { active?: boolean; show?: boolean; }; cameraBookmarks?: { show?: boolean; settings?: Partial; }; }; locale?: string; theme?: string; }; export type SavedMapState = { bearing: number; dragRotate: boolean; latitude: number; longitude: number; pitch: number; zoom: number; isSplit: boolean; }; export type SavedMapStateV1 = SavedMapState; export type MinSavedMapStateV1 = Partial; export type ParsedMapState = Partial; export type SavedLayerGroups = { [key: string]: boolean; }; export type SavedCustomMapStyle = { [key: string]: { accessToken?: string; custom: boolean; icon: string; id: string; label: string; url: string; }; }; export type SavedMapStyle = { styleType: string; topLayerGroups: SavedLayerGroups; visibleLayerGroups: SavedLayerGroups; threeDBuildingColor: RGBColor; mapStyles: SavedCustomMapStyle; }; export type SavedMapStyleV1 = SavedMapStyle; export type MinSavedMapStyleV1 = Partial; export type ParsedMapStyle = Partial; /** Schema for v1 saved configuration */ export type SavedConfigV1 = { version: 'v1'; config: { visState: SavedVisState; mapState: SavedMapState; mapStyle: SavedMapStyle; }; }; // supported by addDataToMap export type MinSavedConfigV1 = { version: 'v1'; config: { visState?: MinSavedVisStateV1; mapState?: MinSavedMapStateV1; mapStyle?: MinSavedMapStyleV1; }; }; /** Schema for a parsed configuration ("normalized" across versions) */ export type ParsedConfig = { visState?: ParsedVisState; mapState?: ParsedMapState; mapStyle?: ParsedMapStyle; uiState?: ParsedUiState; }; export type SavedField = { name: string; type: string; } | null; export type ParsedField = { name: string; type: string; format: string; analyzerType: string; }; export type SavedDatasetV1 = { version: 'v1'; data: { id: string; label: string; color: RGBColor; allData: any[][]; fields: SavedField[]; }; }; export type ParsedDataset = { data: { fields: ParsedField[]; rows: any[][]; }; info: { id?: string; label?: string; color?: RGBColor; }; }; export type SavedMap = { datasets: SavedDatasetV1[]; config: SavedConfigV1; info: { app: string; created_at: string; title?: string; description?: string; source?: string; appName?: string; appWebsite?: string; appIcon?: string; appNameColor?: string; }; }; export type LoadedMap = { datasets?: ParsedDataset[] | null; config?: ParsedConfig | null; info?: { title?: string; description?: string; }; };