import visStateSchema from './vis-state-schema'; import datasetSchema from './dataset-schema'; import mapStyleSchema from './map-style-schema'; import mapStateSchema from './map-state-schema'; import { VERSIONS } from './versions'; import { InteractionConfig, Filter, TooltipInfo, SplitMap, AnimationConfig, VisState, RGBColor, Merge, RGBAColor } from '../reducers'; import { LayerTextLabel } from '../layers/layer-factory'; export type SavedFilter = { dataId: Filter['dataId']; id: Filter['id']; name: Filter['name']; type: Filter['type']; value: Filter['value']; enlarged: Filter['enlarged']; plotType: Filter['plotType']; yAxis: { name: string; type: string; } | null; speed: Filter['speed']; layerId: Filter['layerId']; }; export type ParsedFilter = Partial; export type SavedInteractionConfig = { tooltip: TooltipInfo['config'] & { enabled: boolean; }; geocoder: InteractionConfig['geocoder'] & { enabled: boolean; }; brush: InteractionConfig['brush'] & { enabled: boolean; }; coordinate: InteractionConfig['coordinate'] & { 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: RGBAColor; columns: { [key: string]: string; }; isVisible: boolean; visConfig: object; hidden: boolean; textLabel: Merge; }; visualChannels: SavedVisualChannels; }; export type ParsedLayer = { id?: string; type?: string; config?: Partial; }; export type SavedAnimationConfig = { currentTime: AnimationConfig['currentTime']; speed: AnimationConfig['speed']; }; export type SavedVisState = { filters: SavedFilter[]; layers: SavedLayer[]; interactionConfig: SavedInteractionConfig; layerBlending: string; splitMaps: SplitMap[]; animationConfig: SavedAnimationConfig; }; export type SavedMapState = { bearing: number; dragRotate: boolean; latitude: number; longitude: number; pitch: number; zoom: number; minZoom: number; isSplit: boolean; }; 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; }; /** Schema for v1 saved configuration */ export type SavedConfigV1 = { version: 'v1'; config: { visState: SavedVisState; mapState: SavedMapState; mapStyle: SavedMapStyle; }; }; /** Schema for a parsed configuration ("normalized" across versions) */ export type ParsedConfig = { version: string; visState?: { layers?: ParsedLayer[]; filters?: ParsedFilter[]; interactionConfig?: Partial; layerBlending?: string; splitMaps?: SplitMap[]; animationConfig?: Partial; }; mapState?: Partial; mapStyle?: Partial; }; export type SavedField = { name: string; type: string; format?: string; analyzerType?: string; }; 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; }; }; export type LoadedMap = { datasets?: ParsedDataset[] | null; config?: ParsedConfig | null; }; export declare const reducerSchema: { [key: string]: typeof mapStateSchema | typeof visStateSchema | typeof mapStyleSchema; }; export declare class KeplerGLSchema { _validVersions: typeof VERSIONS; _version: 'v1'; _reducerSchemas: typeof reducerSchema; _datasetSchema: typeof datasetSchema; _datasetLastSaved: SavedDatasetV1[] | null; _savedDataset: SavedDatasetV1[] | null; constructor({ reducers, datasets, validVersions, version }?: { reducers?: typeof reducerSchema; datasets?: typeof datasetSchema; validVersions?: typeof VERSIONS; version?: 'v1'; }); /** * stateToSave = { * datasets: [ * { * version: 'v0', * data: {id, label, color, allData, fields} * }, * { * version: 'v0', * data: {id, label, color, allData, fields} * } * ], * config: { * version: 'v0', * config: {} * }, * info: { * app: 'kepler.gl', * create_at: 'Mon May 28 2018 21:04:46 GMT-0700 (PDT)' * } * } * * Get config and data of current map to save * @param state * @returns app state to save */ save(state: any): SavedMap; getMapInfo(state: any): VisState['mapInfo']; /** * Load saved map, argument can be (datasets, config) or ({datasets, config}) * @param savedDatasets * @param savedConfig */ load(savedDatasets: SavedMap | SavedMap['datasets'] | any, savedConfig: SavedMap['config'] | any): LoadedMap; /** * Get data to save * @param state - app state * @returns - dataset to save */ getDatasetToSave(state: any): SavedDatasetV1[]; /** * Get App config to save * @param {Object} state - app state * @returns {{version: String, config: Object}} - config to save */ getConfigToSave(state: any): SavedConfigV1; /** * Parse saved data * @param datasets * @returns - dataset to pass to addDataToMap */ parseSavedData(datasets: any): ParsedDataset[] | null; /** * Parse saved App config */ parseSavedConfig({ version, config }: { version: any; config: any; }, state?: {}): ParsedConfig | null; /** * Validate version * @param version * @returns validVersion */ validateVersion(version: any): string | null; /** * Check if data has changed since last save * @param state * @returns - whether data has changed or not */ hasDataChanged(state: any): boolean; } declare const KeplerGLSchemaManager: KeplerGLSchema; export default KeplerGLSchemaManager;