Skip to content

Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.

[Feat]: Technical: Translate actions to typescript (#1704)

Maksim Suslovfb170ae03faf
diff --git a/package.json b/package.json
index 14d525e60..568af69b6 100644
--- a/package.json
+++ b/package.json
@@ -98,6 +98,7 @@
"@mapbox/geo-viewport": "^0.4.1",
"@mapbox/geojson-normalize": "0.0.1",
"@mapbox/vector-tile": "^1.3.1",
+ "@reduxjs/toolkit": "^1.7.2",
"@tippyjs/react": "^4.2.0",
"@turf/bbox": "^6.0.1",
"@turf/boolean-within": "^6.0.1",
@@ -193,6 +194,7 @@
"@types/d3-array": "^2.0.0",
"@types/d3-scale": "^3.2.2",
"@types/geojson": "^7946.0.7",
+ "@types/redux-actions": "^2.6.2",
"@typescript-eslint/eslint-plugin": "^5.12.0",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.0.0",
diff --git a/src/actions/action-wrapper.js b/src/actions/action-wrapper.ts
similarity index 100%
rename from src/actions/action-wrapper.js
rename to src/actions/action-wrapper.ts
diff --git a/src/actions/actions.d.ts b/src/actions/actions.d.ts
deleted file mode 100644
index 8778d26c7..000000000
--- a/src/actions/actions.d.ts
+++ /dev/null
@@ -1,104 +0,0 @@
-// Copyright (c) 2020 Uber Technologies, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-import ActionTypes from 'constants/action-types';
-import {ParsedConfig} from 'schemas';
-import {RGBColor} from 'reducers/types';
-import {Bounds} from 'reducers/map-state-updaters';
-import {MapInfo} from 'reducers/vis-state-updaters';
-import {UiState} from 'reducers/ui-state-updaters';
-
-/**
- * Input dataest parsed to addDataToMap
- */
-export type ProtoDataset = {
- info: {
- id?: string;
- label?: string;
- format?: string;
- color?: RGBColor;
- };
- data: {
- fields: {
- name: string;
- type?: string;
- format?: string;
- displayName?: string;
- id?: string;
- }[];
- rows: any[][];
- };
-
- // table-injected metadata
- metadata?: any;
- supportedFilterTypes?: string[];
-};
-
-export type AddDataToMapOptions = {
- centerMap?: boolean;
- readOnly?: boolean;
- keepExistingConfig?: boolean;
- autoCreateLayers?: boolean;
-};
-
-export type AddDataToMapPayload = {
- // TODO/ib - internally the code calls `toArray` a couple of layers deep
- // so this function can actually accept both an array and an object
- // recommend dropping such "sloppy typing" and enforcing array type
- // as the field is called `datasets`
- datasets: ProtoDataset[] | ProtoDataset;
- options?: AddDataToMapOptions;
- config?: ParsedConfig;
- info?: Partial<MapInfo>;
-};
-
-export function addDataToMap(
- data: AddDataToMapPayload
-): {type: ActionTypes.ADD_DATA_TO_MAP; payload: AddDataToMapPayload};
-
-export function resetMapConfig(): {type: ActionTypes.RESET_MAP_CONFIG};
-
-export type ReceiveMapConfigPayload = {
- config: ParsedConfig;
- options?: AddDataToMapOptions;
- bounds?: Bounds;
-};
-
-export function receiveMapConfig(
- config: ParsedConfig,
- options: AddDataToMapOptions
-): {
- type: ActionTypes.RECEIVE_MAP_CONFIG;
- payload: ReceiveMapConfigPayload;
-};
-
-export type KeplerGlInitPayload = {
- mapboxApiAccessToken?: string;
- mapboxApiUrl?: string;
- mapStylesReplaceDefault?: boolean;
- initialUiState?: Partial<UiState>;
-};
-
-export function keplerGlInit(
- options?: KeplerGlInitPayload
-): {
- type: ActionTypes.INIT;
- payload: KeplerGlInitPayload;
-};
diff --git a/src/actions/actions.js b/src/actions/actions.ts
similarity index 74%
rename from src/actions/actions.js
rename to src/actions/actions.ts
index 22fd37b4f..fa326bc9c 100644
--- a/src/actions/actions.js
+++ b/src/actions/actions.ts
@@ -19,7 +19,57 @@
// THE SOFTWARE.
import ActionTypes from 'constants/action-types';
-import {createAction} from 'redux-actions';
+import {createAction} from '@reduxjs/toolkit';
+
+import {ParsedConfig} from '../schemas';
+import {RGBColor} from 'reducers/types';
+import {Bounds} from 'reducers/map-state-updaters';
+import {MapInfo} from 'reducers/vis-state-updaters';
+import {UiState} from 'reducers/ui-state-updaters';
+
+/**
+ * Input dataest parsed to addDataToMap
+ */
+export type ProtoDataset = {
+ info: {
+ id?: string;
+ label?: string;
+ format?: string;
+ color?: RGBColor;
+ };
+ data: {
+ fields: {
+ name: string;
+ type?: string;
+ format?: string;
+ displayName?: string;
+ id?: string;
+ }[];
+ rows: any[][];
+ };
+
+ // table-injected metadata
+ metadata?: any;
+ supportedFilterTypes?: string[];
+};
+
+export type AddDataToMapOptions = {
+ centerMap?: boolean;
+ readOnly?: boolean;
+ keepExistingConfig?: boolean;
+ autoCreateLayers?: boolean;
+};
+
+export type AddDataToMapPayload = {
+ // TODO/ib - internally the code calls `toArray` a couple of layers deep
+ // so this function can actually accept both an array and an object
+ // recommend dropping such "sloppy typing" and enforcing array type
+ // as the field is called `datasets`
+ datasets: ProtoDataset[] | ProtoDataset;
+ options?: AddDataToMapOptions;
+ config?: ParsedConfig;
+ info?: Partial<MapInfo>;
+};
/**
* Add data to kepler.gl reducer, prepare map with preset configuration if config is passed.
@@ -105,15 +155,27 @@ import {createAction} from 'redux-actions';
* })
* );
*/
-export const addDataToMap = createAction(ActionTypes.ADD_DATA_TO_MAP, data => data);
+export const addDataToMap: (
+ data: AddDataToMapPayload
+) => {
+ type: typeof ActionTypes.ADD_DATA_TO_MAP;
+ payload: AddDataToMapPayload;
+} = createAction(ActionTypes.ADD_DATA_TO_MAP, (data: AddDataToMapPayload) => ({payload: data}));
/**
* Reset all sub-reducers to its initial state. This can be used to clear out all configuration in the reducer.
* @memberof main
* @public
*/
-export const resetMapConfig = createAction(ActionTypes.RESET_MAP_CONFIG);
+export const resetMapConfig: () => {type: typeof ActionTypes.RESET_MAP_CONFIG} = createAction(
+ ActionTypes.RESET_MAP_CONFIG
+);
+export type ReceiveMapConfigPayload = {
+ config: ParsedConfig;
+ options?: AddDataToMapOptions;
+ bounds?: Bounds;
+};
/**
* Pass config to kepler.gl instance, prepare the state with preset configs.
* Calling `KeplerGlSchema.parseSavedConfig` to convert saved config before passing it in is required.
@@ -142,11 +204,28 @@ export const resetMapConfig = createAction(ActionTypes.RESET_MAP_CONFIG);
* const parsedConfig = KeplerGlSchema.parseSavedConfig(config);
* this.props.dispatch(receiveMapConfig(parsedConfig));
*/
-export const receiveMapConfig = createAction(ActionTypes.RECEIVE_MAP_CONFIG, (config, options) => ({
- config,
- options
-}));
+export const receiveMapConfig: (
+ config: ReceiveMapConfigPayload['config'],
+ options: ReceiveMapConfigPayload['options']
+) => {
+ type: typeof ActionTypes.RECEIVE_MAP_CONFIG;
+ payload: ReceiveMapConfigPayload;
+} = createAction(
+ ActionTypes.RECEIVE_MAP_CONFIG,
+ (config: ReceiveMapConfigPayload['config'], options: ReceiveMapConfigPayload['options']) => ({
+ payload: {
+ config,
+ options
+ }
+ })
+);
+export type KeplerGlInitPayload = {
+ mapboxApiAccessToken?: string;
+ mapboxApiUrl?: string;
+ mapStylesReplaceDefault?: boolean;
+ initialUiState?: Partial<UiState>;
+};
/**
* Initialize kepler.gl reducer. It is used to pass in `mapboxApiAccessToken` to `mapStyle` reducer.
* @memberof main
@@ -155,14 +234,15 @@ export const receiveMapConfig = createAction(ActionTypes.RECEIVE_MAP_CONFIG, (co
* @param payload.mapboxApiUrl - mapboxApiUrl to be saved to mapStyle reducer.
* @param payload.mapStylesReplaceDefault - mapStylesReplaceDefault to be saved to mapStyle reducer
* @param payload.initialUiState - initial ui state
- * @type {typeof import('./actions').keplerGlInit}
* @public
*/
-export const keplerGlInit = createAction(
- ActionTypes.INIT,
- // @ts-ignore
- payload => payload
-);
+// @ts-expect-error
+export const keplerGlInit: (
+ options?: KeplerGlInitPayload
+) => {
+ type: typeof ActionTypes.INIT;
+ payload: KeplerGlInitPayload;
+} = createAction(ActionTypes.INIT, (payload: KeplerGlInitPayload) => ({payload}));
/**
* This declaration is needed to group actions in docs
diff --git a/src/actions/identity-actions.d.ts b/src/actions/identity-actions.d.ts
deleted file mode 100644
index 5c0a62550..000000000
--- a/src/actions/identity-actions.d.ts
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright (c) 2020 Uber Technologies, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-import ActionTypes from 'constants/action-types';
-import {UiState} from 'reducers/ui-state-updaters';
-
-export type RegisterEntryUpdaterAction = {
- payload: {
- id: string;
- mint?: boolean;
- mapboxApiAccessToken?: string;
- mapboxApiUrl?: string;
- mapStylesReplaceDefault?: boolean;
- initialUiState?:Partial<UiState>;
- };
-};
-
-export function registerEntry(
- entry: RegisterEntryUpdaterAction['payload']
-): {
- type: ActionTypes.REGISTER_ENTRY;
- payload: RegisterEntryUpdaterAction['payload'];
-};
-
-export function deleteEntry(id: string): {type: ActionTypes.DELETE_ENTRY; payload: string};
-
-export function renameEntry(
- oldId: string,
- newId: string
-): {
- type: ActionTypes.RENAME_ENTRY;
- payload: {
- oldId: string;
- newId: string;
- };
-};
diff --git a/src/actions/identity-actions.js b/src/actions/identity-actions.ts
similarity index 76%
rename from src/actions/identity-actions.js
rename to src/actions/identity-actions.ts
index 74be386fd..c28e86ac4 100644
--- a/src/actions/identity-actions.js
+++ b/src/actions/identity-actions.ts
@@ -18,9 +18,20 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-import {createAction} from 'redux-actions';
+import {createAction} from '@reduxjs/toolkit';
import ActionTypes from 'constants/action-types';
+import {UiState} from 'reducers/ui-state-updaters';
+export type RegisterEntryUpdaterAction = {
+ payload: {
+ id: string;
+ mint?: boolean;
+ mapboxApiAccessToken?: string;
+ mapboxApiUrl?: string;
+ mapStylesReplaceDefault?: boolean;
+ initialUiState?: Partial<UiState>;
+ };
+};
/**
*
* Add a new kepler.gl instance in `keplerGlReducer`. This action is called under-the-hood when a `KeplerGl` component is **mounted** to the dom.
@@ -35,10 +46,16 @@ import ActionTypes from 'constants/action-types';
* @param payload.mapboxApiUrl - mapboxApiUrl to be saved in `map-style` reducer.
* @param payload.mapStylesReplaceDefault - mapStylesReplaceDefault to be saved in `map-style` reducer.
* @param payload.initialUiState - initial ui state
- * @type {typeof import('./identity-actions').registerEntry}
* @public
*/
-export const registerEntry = createAction(ActionTypes.REGISTER_ENTRY, payload => payload);
+export const registerEntry: (
+ entry: RegisterEntryUpdaterAction['payload']
+) => {
+ type: typeof ActionTypes.REGISTER_ENTRY;
+ payload: RegisterEntryUpdaterAction['payload'];
+} = createAction(ActionTypes.REGISTER_ENTRY, (payload: RegisterEntryUpdaterAction['payload']) => ({
+ payload
+}));
/**
*
@@ -49,7 +66,12 @@ export const registerEntry = createAction(ActionTypes.REGISTER_ENTRY, payload =>
* @param {string} id - the id of the instance to be deleted
* @public
*/
-export const deleteEntry = createAction(ActionTypes.DELETE_ENTRY, id => id);
+export const deleteEntry: (
+ id: string
+) => {
+ type: typeof ActionTypes.DELETE_ENTRY;
+ payload: string;
+} = createAction(ActionTypes.DELETE_ENTRY, (id: string) => ({payload: id}));
/**
*
@@ -60,9 +82,20 @@ export const deleteEntry = createAction(ActionTypes.DELETE_ENTRY, id => id);
* @param {string} newId - ***required** new id
* @public
*/
-export const renameEntry = createAction(ActionTypes.RENAME_ENTRY, (oldId, newId) => ({
- oldId,
- newId
+export const renameEntry: (
+ oldId: string,
+ newId: string
+) => {
+ type: typeof ActionTypes.RENAME_ENTRY;
+ payload: {
+ oldId: string;
+ newId: string;
+ };
+} = createAction(ActionTypes.RENAME_ENTRY, (oldId: string, newId: string) => ({
+ payload: {
+ oldId,
+ newId
+ }
}));
/**
diff --git a/src/actions/index.d.ts b/src/actions/index.d.ts
deleted file mode 100644
index dd7c0eddb..000000000
--- a/src/actions/index.d.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-// Actions
-export * from './actions';
-
-// kepler.gl actions accessible outside component
-export * from './vis-state-actions';
-export * from './ui-state-actions';
-export * from './map-state-actions';
-export * from './map-style-actions';
-export * from './identity-actions';
-export * from './provider-actions';
-
-// TODO - Add typescript defs for these functions
-// Dispatch
-// export {
-// _actionFor,
-// forwardTo,
-// getActionForwardAddress,
-// isForwardAction,
-// unwrap,
-// wrapTo
-// } from './action-wrapper';
-
-export {default as ActionTypes} from '../constants/action-types';
diff --git a/src/actions/index.js b/src/actions/index.ts
similarity index 100%
rename from src/actions/index.js
rename to src/actions/index.ts
diff --git a/src/actions/map-state-actions.d.ts b/src/actions/map-state-actions.d.ts
deleted file mode 100644
index ad6aeefc1..000000000
--- a/src/actions/map-state-actions.d.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (c) 2020 Uber Technologies, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-import ActionTypes from 'constants/action-types';
-import {ValueOf, Merge} from '../reducers/types';
-import {Bounds, Viewport} from '../reducers/map-state-updaters';
-
-export type TogglePerspectiveUpdaterAction = {};
-export function togglePerspective(): Merge<
- TogglePerspectiveUpdaterAction,
- {type: ActionTypes.TOGGLE_PERSPECTIVE}
->;
-
-export type FitBoundsUpdaterAction = {payload: Bounds};
-export function fitBounds(
- payload: Bounds
-): Merge<FitBoundsUpdaterAction, {type: ActionTypes.FIT_BOUNDS}>;
-
-export type UpdateMapUpdaterAction = {payload: Viewport};
-export function updateMap(
- payload: Viewport
-): Merge<UpdateMapUpdaterAction, {type: ActionTypes.UPDATE_MAP}>;
-
-export type ToggleSplitMapUpdaterAction = {
- payload: number;
-};
-export function toggleSplitMap(
- payload: number
-): Merge<ToggleSplitMapUpdaterAction, {type: ActionTypes.TOGGLE_SPLIT_MAP}>;
diff --git a/src/actions/map-state-actions.js b/src/actions/map-state-actions.ts
similarity index 73%
rename from src/actions/map-state-actions.js
rename to src/actions/map-state-actions.ts
index acf8e1727..9f5c48fb9 100644
--- a/src/actions/map-state-actions.js
+++ b/src/actions/map-state-actions.ts
@@ -18,9 +18,12 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-import {createAction} from 'redux-actions';
+import {createAction} from '@reduxjs/toolkit';
import ActionTypes from 'constants/action-types';
+import {Merge} from '../reducers/types';
+import {Bounds, Viewport} from '../reducers/map-state-updaters';
+export type TogglePerspectiveUpdaterAction = {};
/**
*
* Toggle between 3d and 2d map.
@@ -30,8 +33,12 @@ import ActionTypes from 'constants/action-types';
* import {togglePerspective} from 'kepler.gl/actions';
* this.props.dispatch(togglePerspective());
*/
-export const togglePerspective = createAction(ActionTypes.TOGGLE_PERSPECTIVE);
+export const togglePerspective: () => Merge<
+ TogglePerspectiveUpdaterAction,
+ {type: typeof ActionTypes.TOGGLE_PERSPECTIVE}
+> = createAction(ActionTypes.TOGGLE_PERSPECTIVE);
+export type FitBoundsUpdaterAction = {payload: Bounds};
/**
* Fit map viewport to bounds
* @memberof mapStateActions
@@ -41,8 +48,14 @@ export const togglePerspective = createAction(ActionTypes.TOGGLE_PERSPECTIVE);
* import {fitBounds} from 'kepler.gl/actions';
* this.props.dispatch(fitBounds([-122.23, 37.127, -122.11, 37.456]));
*/
-export const fitBounds = createAction(ActionTypes.FIT_BOUNDS, bounds => bounds);
+export const fitBounds: (
+ payload: Bounds
+) => Merge<
+ FitBoundsUpdaterAction,
+ {type: typeof ActionTypes.FIT_BOUNDS}
+> = createAction(ActionTypes.FIT_BOUNDS, (bounds: Bounds) => ({payload: bounds}));
+export type UpdateMapUpdaterAction = {payload: Viewport};
/**
* Update map viewport
* @memberof mapStateActions
@@ -61,8 +74,16 @@ export const fitBounds = createAction(ActionTypes.FIT_BOUNDS, bounds => bounds);
* this.props.dispatch(updateMap({latitude: 37.75043, longitude: -122.34679, width: 800, height: 1200}));
*/
-export const updateMap = createAction(ActionTypes.UPDATE_MAP, viewport => viewport);
+export const updateMap: (
+ payload: Viewport
+) => Merge<
+ UpdateMapUpdaterAction,
+ {type: typeof ActionTypes.UPDATE_MAP}
+> = createAction(ActionTypes.UPDATE_MAP, (viewport: Viewport) => ({payload: viewport}));
+export type ToggleSplitMapUpdaterAction = {
+ payload: number;
+};
/**
* Toggle between single map or split maps
* @memberof mapStateActions
@@ -72,7 +93,12 @@ export const updateMap = createAction(ActionTypes.UPDATE_MAP, viewport => viewpo
* import {toggleSplitMap} from 'kepler.gl/actions';
* this.props.dispatch(toggleSplitMap());
*/
-export const toggleSplitMap = createAction(ActionTypes.TOGGLE_SPLIT_MAP, index => index);
+export const toggleSplitMap: (
+ payload: number
+) => Merge<
+ ToggleSplitMapUpdaterAction,
+ {type: typeof ActionTypes.TOGGLE_SPLIT_MAP}
+> = createAction(ActionTypes.TOGGLE_SPLIT_MAP, (index: number) => ({payload: index}));
/**
* This declaration is needed to group actions in docs
diff --git a/src/actions/map-style-actions.d.ts b/src/actions/map-style-actions.d.ts
index 0c9c18314..025d8a2c1 100644
--- a/src/actions/map-style-actions.d.ts
+++ b/src/actions/map-style-actions.d.ts
@@ -18,6 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
+// @ts-nocheck
import ActionTypes from 'constants/action-types';
import {Merge, RGBColor} from '../reducers/types';
import {
diff --git a/src/actions/map-style-actions.js b/src/actions/map-style-actions.ts
similarity index 100%
rename from src/actions/map-style-actions.js
rename to src/actions/map-style-actions.ts
diff --git a/src/actions/provider-actions.d.ts b/src/actions/provider-actions.d.ts
index 1d22b8778..a0c576b63 100644
--- a/src/actions/provider-actions.d.ts
+++ b/src/actions/provider-actions.d.ts
@@ -17,6 +17,7 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
+// @ts-nocheck
import {SavedMap} from 'schemas';
import {MapListItem, Provider} from 'cloud-providers';
diff --git a/src/actions/provider-actions.js b/src/actions/provider-actions.ts
similarity index 100%
rename from src/actions/provider-actions.js
rename to src/actions/provider-actions.ts
diff --git a/src/actions/ui-state-actions.d.ts b/src/actions/ui-state-actions.d.ts
index a01c67458..c374bb19d 100644
--- a/src/actions/ui-state-actions.d.ts
+++ b/src/actions/ui-state-actions.d.ts
@@ -18,6 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
+// @ts-nocheck
import ActionTypes from 'constants/action-types';
import {Merge} from '../reducers/types';
import {ExportImage} from '../reducers/ui-state-updaters';
diff --git a/src/actions/ui-state-actions.js b/src/actions/ui-state-actions.ts
similarity index 100%
rename from src/actions/ui-state-actions.js
rename to src/actions/ui-state-actions.ts
diff --git a/src/actions/vis-state-actions.d.ts b/src/actions/vis-state-actions.d.ts
deleted file mode 100644
index e3f3af5cc..000000000
--- a/src/actions/vis-state-actions.d.ts
+++ /dev/null
@@ -1,515 +0,0 @@
-// Copyright (c) 2020 Uber Technologies, Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-// vis-state-reducer
-import ActionTypes, {ActionType} from 'constants/action-types';
-import {ProtoDataset, AddDataToMapPayload} from '../actions/actions';
-import {ParsedConfig} from 'schemas';
-import {FileCacheItem} from '../processors/file-handler';
-import {Layer, LayerConfig, LayerVisConfig} from 'layers';
-import {Feature, InteractionConfig} from 'reducers/vis-state-updaters';
-import {ValueOf, Merge} from '../reducers/types';
-// TODO - import LoaderObject type from @loaders.gl/core when supported
-// TODO - import LoadOptions type from @loaders.gl/core when supported
-import {LoaderObject} from '@loaders.gl/loader-utils';
-
-export type LayerConfigChangeUpdaterAction = {
- oldLayer: Layer;
- newConfig: Partial<LayerConfig>;
-};
-
-export function layerConfigChange(
- oldLayer: Layer,
- newConfig: Partial<LayerConfig>
-): Merge<LayerConfigChangeUpdaterAction, {type: ActionTypes.LAYER_CONFIG_CHANGE}>;
-
-export type LayerTextLabelChangeUpdaterAction = {
- oldLayer: Layer;
- idx: number | 'all';
- prop: string;
- value: any;
-};
-
-export function layerTextLabelChange(
- oldLayer: Layer,
- idx: number | 'all',
- prop: string,
- value: any
-): Merge<LayerTextLabelChangeUpdaterAction, {type: ActionTypes.LAYER_TEXT_LABEL_CHANGE}>;
-
-export type LayerTypeChangeUpdaterAction = {
- oldLayer: Layer;
- newType: string;
-};
-export function layerTypeChange(
- oldLayer: Layer,
- newType: string
-): Merge<LayerTypeChangeUpdaterAction, {type: ActionTypes.LAYER_TYPE_CHANGE}>;
-
-export type LayerVisualChannelConfigChangeUpdaterAction = {
- oldLayer: Layer;
- newConfig: Partial<LayerConfig>;
- channel: string;
-};
-export function layerVisualChannelConfigChange(
- oldLayer: Layer,
- newConfig: Partial<LayerConfig>,
- channel: string
-): Merge<
- LayerVisualChannelConfigChangeUpdaterAction,
- {type: ActionTypes.LAYER_VISUAL_CHANNEL_CHANGE}
->;
-
-export type LayerVisConfigChangeUpdaterAction = {
- oldLayer: Layer;
- newVisConfig: Partial<LayerVisConfig>;
-};
-export function layerVisConfigChange(
- oldLayer: Layer,
- newVisConfig: Partial<LayerVisConfig>
-): Merge<LayerVisConfigChangeUpdaterAction, {type: ActionTypes.LAYER_VIS_CONFIG_CHANGE}>;
-
-export type LayerColorUIChangeUpdaterAction = {
- oldLayer: Layer;
- prop: string;
- newConfig: object;
-};
-export function layerColorUIChange(
- oldLayer: Layer,
- prop: string,
- newConfig: object
-): Merge<LayerColorUIChangeUpdaterAction, {type: ActionTypes.LAYER_COLOR_UI_CHANGE}>;
-
-export type UpdateLayerBlendingUpdaterAction = {
- mode: string;
-};
-export function updateLayerBlending(
- mode: 'additive' | 'normal' | 'subtractive'
-): Merge<UpdateLayerBlendingUpdaterAction, {type: ActionTypes.UPDATE_LAYER_BLENDING}>;
-
-export type InteractionConfigChangeUpdaterAction = {
- config: ValueOf<InteractionConfig>;
-};
-export function interactionConfigChange(
- config: ValueOf<InteractionConfig>
-): Merge<InteractionConfigChangeUpdaterAction, {type: ActionTypes.INTERACTION_CONFIG_CHANGE}>;
-
-export type SetFilterUpdaterAction = {
- idx: number;
- prop: string;
- value: any;
- valueIndex?: number;
-};
-export function setFilter(
- idx: number,
- prop: string,
- value: any,
- valueIndex: number
-): Merge<SetFilterUpdaterAction, {type: ActionTypes.SET_FILTER}>;
-
-export type SetFilterAnimationTimeUpdaterAction = {
- idx: number;
- prop: string;
- value: any;
- valueIndex?: number;
-};
-export function setFilterAnimationTime(
- idx: number,
- prop: string,
- value: any,
- valueIndex?: number
-): Merge<SetFilterAnimationTimeUpdaterAction, {type: ActionTypes.SET_FILTER_ANIMATION_TIME}>;
-
-export type SetFilterAnimationWindowUpdaterAction = {
- id: string;
- animationWindow: string;
-};
-export function setFilterAnimationWindow({
- id: string,
- animationWindow: string
-}): Merge<SetFilterAnimationWindowUpdaterAction, {type: ActionTypes.SET_FILTER_ANIMATION_WINDOW}>;
-
-export type AddFilterUpdaterAction = {
- dataId: string;
-};
-export function addFilter(
- dataId: string
-): Merge<AddFilterUpdaterAction, {type: ActionTypes.ADD_FILTER}>;
-
-export type AddLayerUpdaterAction = {
- config: object;
- datasetId?: string;
-};
-export function addLayer(
- config: object,
- datasetId?: string
-): Merge<AddLayerUpdaterAction, {type: ActionTypes.ADD_LAYER}>;
-
-export type ReorderLayerUpdaterAction = {
- order: number[];
-};
-export function reorderLayer(
- order: number[]
-): Merge<ReorderLayerUpdaterAction, {type: ActionTypes.REORDER_LAYER}>;
-
-export type RemoveFilterUpdaterAction = {
- idx: number;
-};
-export function removeFilter(
- idx: number
-): Merge<RemoveFilterUpdaterAction, {type: ActionTypes.REMOVE_FILTER}>;
-
-export type RemoveLayerUpdaterAction = {
- idx: number;
-};
-export function removeLayer(
- idx: number
-): Merge<RemoveLayerUpdaterAction, {type: ActionTypes.REMOVE_LAYER}>;
-
-export type DuplicateLayerUpdaterAction = {
- idx: number;
-};
-export function duplicateLayer(
- idx: number
-): Merge<DuplicateLayerUpdaterAction, {type: ActionTypes.DUPLICATE_LAYER}>;
-
-export type RemoveDatasetUpdaterAction = {
- dataId: string;
-};
-export function removeDataset(
- dataId: string
-): Merge<RemoveDatasetUpdaterAction, {type: ActionTypes.REMOVE_DATASET}>;
-
-export type ShowDatasetTableUpdaterAction = {
- dataId: string;
-};
-export function showDatasetTable(
- dataId: string
-): Merge<ShowDatasetTableUpdaterAction, {type: ActionTypes.SHOW_DATASET_TABLE}>;
-
-export type UpdateDatasetColorUpdater = {
- dataId: string;
- newColor: RGBColor;
-};
-export function updateTableColor(
- dataId: string,
- newColor: RGBColor
-): Merge<UpdateDatasetColorUpdater, {type: ActionTypes.UPDATE_TABLE_COLOR}>;
-
-export type SortTableColumnUpdaterAction = {
- dataId: string;
- column: string;
- mode: string;
-};
-export function sortTableColumn(
- dataId: string,
- column: string,
- mode: string
-): Merge<SortTableColumnUpdaterAction, {type: ActionTypes.SORT_TABLE_COLUMN}>;
-
-export type PinTableColumnUpdaterAction = {
- dataId: string;
- column: string;
-};
-export function pinTableColumn(
- dataId: string,
- column: string
-): Merge<PinTableColumnUpdaterAction, {type: ActionTypes.PIN_TABLE_COLUMN}>;
-
-export type CopyTableColumnUpdaterAction = {
- dataId: string;
- column: string;
-};
-export function copyTableColumn(
- dataId: string,
- column: string
-): Merge<CopyTableColumnUpdaterAction, {type: ActionTypes.COPY_TABLE_COLUMN}>;
-
-export type AddDataToMapUpdaterOptions = {
- centrMap?: boolean;
- readOnly?: boolean;
- keepExistingConfig?: boolean;
-};
-
-export type UpdateVisDataUpdaterAction = {
- datasets: AddDataToMapPayload['datasets'];
- options: AddDataToMapPayload['options'];
- config: AddDataToMapPayload['config'];
-} & AddDataToMapPayload;
-export function updateVisData(
- datasets: AddDataToMapPayload['datasets'],
- options: AddDataToMapPayload['options'],
- config: AddDataToMapPayload['config']
-): Merge<UpdateVisDataUpdaterAction, {type: ActionTypes.UPDATE_VIS_DATA}>;
-
-export type RenameDatasetUpdaterAction = {
- dataId: string;
- label: string;
-};
-export function renameDataset(
- dataId: string,
- label: string
-): Merge<RenameDatasetUpdaterAction, {type: ActionTypes.RENAME_DATASET}>;
-
-export type ToggleFilterAnimationUpdaterAction = {
- idx;
-};
-export function toggleFilterAnimation(
- idx: number
-): Merge<ToggleFilterAnimationUpdaterAction, {type: ActionTypes.TOGGLE_FILTER_ANIMATION}>;
-
-export type UpdateFilterAnimationSpeedUpdaterAction = {
- idx: number;
- speed: number;
-};
-export function updateFilterAnimationSpeed(
- idx: number,
- speed: number
-): Merge<
- UpdateFilterAnimationSpeedUpdaterAction,
- {type: ActionTypes.UPDATE_FILTER_ANIMATION_SPEED}
->;
-
-export type SetLayerAnimationTimeUpdaterAction = {
- value: number;
-};
-export function setLayerAnimationTime(
- value: number
-): Merge<SetLayerAnimationTimeUpdaterAction, {type: ActionTypes.SET_LAYER_ANIMATION_TIME}>;
-
-export type UpdateLayerAnimationSpeedUpdaterAction = {
- speed: number;
-};
-export function updateLayerAnimationSpeed(
- speed: number
-): Merge<UpdateLayerAnimationSpeedUpdaterAction, {type: ActionTypes.UPDATE_LAYER_ANIMATION_SPEED}>;
-
-export type ToggleLayerAnimationUpdaterAction = {};
-export function toggleLayerAnimation(): Merge<
- ToggleLayerAnimationUpdaterAction,
- {type: ActionTypes.TOGGLE_LAYER_ANIMATION}
->;
-
-export type ToggleLayerAnimationControlUpdaterAction = {};
-export function toggleLayerAnimationControl(): Merge<
- ToggleLayerAnimationControlUpdaterAction,
- {type: ActionTypes.TOGGLE_LAYER_ANIMATION_CONTROL}
->;
-
-export type EnlargeFilterUpdaterAction = {
- idx: number;
-};
-export function enlargeFilter(
- idx: number
-): Merge<EnlargeFilterUpdaterAction, {type: ActionTypes.ENLARGE_FILTER}>;
-
-export type ToggleFilterFeatureUpdaterAction = {
- idx: number;
-};
-export function toggleFilterFeature(
- idx: number
-): Merge<ToggleFilterFeatureUpdaterAction, {type: ActionTypes.TOGGLE_FILTER_FEATURE}>;
-
-export type OnLayerHoverUpdaterAction = {
- info: {picked?: boolean} | null;
-};
-export function onLayerHover(
- info: {picked?: boolean} | null
-): Merge<OnLayerHoverUpdaterAction, {type: ActionTypes.LAYER_HOVER}>;
-
-export type OnLayerClickUpdaterAction = {
- info: {picked?: boolean} | null;
-};
-export function onLayerClick(
- info: {picked?: boolean} | null
-): Merge<OnLayerClickUpdaterAction, {type: ActionTypes.LAYER_CLICK}>;
-
-export type OnMapClickUpdaterAction = {};
-
-export function onMapClick(): Merge<OnMapClickUpdaterAction, {type: ActionTypes.MAP_CLICK}>;
-export type OnMouseMoveUpdaterAction = {
- evt;
-};
-export function onMouseMove(evt): Merge<OnMouseMoveUpdaterAction, {type: ActionTypes.MOUSE_MOVE}>;
-
-export type ToggleLayerForMapUpdaterAction = {
- mapIndex: number;
- layerId: string;
-};
-export function toggleLayerForMap(
- mapIndex: number,
- layerId: string
-): Merge<ToggleLayerForMapUpdaterAction, {type: ActionTypes.TOGGLE_LAYER_FOR_MAP}>;
-
-export type SetFilterPlotUpdaterAction = {
- idx: number;
- newProp: object;
- valueIndex?: number;
-};
-export function setFilterPlot(
- idx: number,
- newProp: object,
- valueIndex?: number
-): Merge<SetFilterPlotUpdaterAction, {type: ActionTypes.SET_FILTER_PLOT}>;
-
-export type SetMapInfoUpdaterAction = {
- info: any;
-};
-export function setMapInfo(
- info: any
-): Merge<SetMapInfoUpdaterAction, {type: ActionTypes.SET_MAP_INFO}>;
-
-export type LoadFilesUpdaterAction = {
- files: File[];
- onFinish?(result: any): any;
-};
-export function loadFiles(
- files: File[],
- onFinish?: (result: any) => any
-): Merge<LoadFilesUpdaterAction, {type: ActionTypes.LOAD_FILES}>;
-
-export type SetFeaturesUpdaterAction = {
- features: Feature[];
-};
-export function setFeatures(
- features: Feature[]
-): Merge<SetFeaturesUpdaterAction, {type: ActionTypes.SET_FEATURES}>;
-
-export type SetPolygonFilterLayerUpdaterAction = {
- layer: Layer;
- feature: Feature;
-};
-export function setPolygonFilterLayer(
- layer: Layer,
- feature: Feature
-): Merge<SetPolygonFilterLayerUpdaterAction, {type: ActionTypes.SET_POLYGON_FILTER_LAYER}>;
-
-export type SetSelectedFeatureUpdaterAction = {
- feature: Feature;
-};
-export function setSelectedFeature(
- feature: Feature
-): Merge<SetSelectedFeatureUpdaterAction, {type: ActionTypes.SET_SELECTED_FEATURE}>;
-
-export type DeleteFeatureUpdaterAction = {
- feature: Feature;
-};
-export function deleteFeature(
- feature: Feature
-): Merge<DeleteFeatureUpdaterAction, {type: ActionTypes.DELETE_FEATURE}>;
-
-export type SetEditorModeUpdaterAction = {
- mode: string;
-};
-export function setEditorMode(
- mode: string
-): Merge<SetEditorModeUpdaterAction, {type: ActionTypes.SET_EDITOR_MODE}>;
-
-export type ApplyCPUFilterUpdaterAction = {
- dataId: string | string[];
-};
-export function applyCPUFilter(
- dataId: string | string[]
-): Merge<ApplyCPUFilterUpdaterAction, {type: ActionTypes.APPLY_CPU_FILTER}>;
-
-export type ToggleEditorVisibilityUpdaterAction = {};
-export function toggleEditorVisibility(): Merge<
- ToggleEditorVisibilityUpdaterAction,
- {type: ActionTypes.TOGGLE_EDITOR_VISIBILITY}
->;
-
-export function loadNextFile(): Merge<{type: ActionTypes.LOAD_NEXT_FILE}>;
-
-export type loadFilesSuccessUpdaterAction = {
- result: FileCacheItem[];
-};
-export function loadFilesSuccess(
- result: FileCacheItem[]
-): Merge<loadFilesSuccessUpdaterAction, {type: ActionTypes.LOAD_FILES_SUCCESS}>;
-
-export type loadFilesErrUpdaterAction = {
- fileName: string;
- error: any;
-};
-export function loadFilesErr(
- fileName: string,
- error: any
-): Merge<loadFilesErrUpdaterAction, {type: ActionTypes.LOAD_FILES_ERR}>;
-
-export type LoadFileStepSuccessAction = {
- fileName: string;
- fileCache: FileCacheItem[];
-};
-export function loadFileStepSuccess(payload: {
- fileName: string;
- fileCache: FileCacheItem[];
-}): Merge<LoadFileStepSuccessAction, {type: ActionTypes.LOAD_FILE_STEP_SUCCESS}>;
-
-type FileContent = {
- fileName: string;
- header: string[];
- data: any;
-};
-export type NextFileBatchUpdaterAction = {
- payload: {
- gen: AsyncGenerator<FileContent>;
- fileName: string;
- progress?: any;
- accumulated?: any;
- onFinish: (result: any) => any;
- };
-};
-export function nextFileBatch(
- payload: NextFileBatchAction['payload']
-): Merge<NextFileBatchUpdaterAction, {type: ActionTypes.NEXT_FILE_BATCH}>;
-
-export type ProcessFileContentUpdaterAction = {
- payload: {
- content: FileContent;
- fileCache: FileCacheItem[];
- };
-};
-
-export function processFileContent(
- payload: ProcessFileContentUpdaterAction['payload']
-): Merge<ProcessFileContentUpdaterAction, {type: ActionTypes.PROCESS_FILE_CONTENT}>;
-
-export type SetLayerAnimationTimeConfigAction = {
- config: {
- timezone?: string;
- timeFormat?: string;
- };
-};
-
-export function setLayerAnimationTimeConfig(
- config: SetLayerAnimationTimeConfigAction['config']
-): Merge<SetLayerAnimationTimeConfigAction, {type: ActionTypes.SET_TIME_FORMAT}>;
-
-export type SetFilterAnimationTimeConfigAction = {
- idx: number;
- config: {
- timezone?: string;
- timeFormat?: string;
- };
-};
-export function setFilterAnimationTimeConfig(
- idx: SetFilterAnimationTimeConfigAction['idx'],
- config: SetFilterAnimationTimeConfigAction['config']
-): Merge<timeFormatAction, {type: ActionTypes.SET_TIME_FORMAT}>;
diff --git a/src/actions/vis-state-actions.js b/src/actions/vis-state-actions.ts
similarity index 53%
rename from src/actions/vis-state-actions.js
rename to src/actions/vis-state-actions.ts
index b1f8dcefc..bdca4d94f 100644
--- a/src/actions/vis-state-actions.js
+++ b/src/actions/vis-state-actions.ts
@@ -20,22 +20,41 @@
// vis-state-reducer
import ActionTypes from 'constants/action-types';
+import {AddDataToMapPayload} from '../actions/actions';
+import {FileCacheItem} from '../processors/file-handler';
+import {Layer, LayerConfig, LayerVisConfig} from 'layers';
+import {Feature, InteractionConfig} from 'reducers/vis-state-updaters';
+import {ValueOf, Merge, RGBColor} from '../reducers/types';
+// TODO - import LoaderObject type from @loaders.gl/core when supported
+// TODO - import LoadOptions type from @loaders.gl/core when supported
+type LayerConfigChangeUpdaterAction = {
+ oldLayer: Layer;
+ newConfig: Partial<LayerConfig>;
+};
/**
* Update layer base config: dataId, label, column, isVisible
* @param oldLayer - layer to be updated
* @param newConfig - new config to be merged with old config
* @returns action
- * @type {typeof import('./vis-state-actions').layerConfigChange}
* @public
*/
-export function layerConfigChange(oldLayer, newConfig) {
+export function layerConfigChange(
+ oldLayer: Layer,
+ newConfig: Partial<LayerConfig>
+): Merge<LayerConfigChangeUpdaterAction, {type: typeof ActionTypes.LAYER_CONFIG_CHANGE}> {
return {
type: ActionTypes.LAYER_CONFIG_CHANGE,
oldLayer,
newConfig
};
}
+export type LayerTextLabelChangeUpdaterAction = {
+ oldLayer: Layer;
+ idx: number | 'all';
+ prop: string;
+ value: any;
+};
/**
* Update layer text label
@@ -44,10 +63,14 @@ export function layerConfigChange(oldLayer, newConfig) {
* @param prop - `prop` of text label, e,g, `anchor`, `alignment`, `color`, `size`, `field`
* @param value - new value
* @returns action
- * @type {typeof import('./vis-state-actions').layerTextLabelChange}
* @public
*/
-export function layerTextLabelChange(oldLayer, idx, prop, value) {
+export function layerTextLabelChange(
+ oldLayer: Layer,
+ idx: number | 'all',
+ prop: string,
+ value: any
+): Merge<LayerTextLabelChangeUpdaterAction, {type: typeof ActionTypes.LAYER_TEXT_LABEL_CHANGE}> {
return {
type: ActionTypes.LAYER_TEXT_LABEL_CHANGE,
oldLayer,
@@ -56,23 +79,32 @@ export function layerTextLabelChange(oldLayer, idx, prop, value) {
value
};
}
-
+export type LayerTypeChangeUpdaterAction = {
+ oldLayer: Layer;
+ newType: string;
+};
/**
* Update layer type. Previews layer config will be copied if applicable.
* @param oldLayer - layer to be updated
* @param newType - new type
* @returns action
- * @type {typeof import('./vis-state-actions').layerTypeChange}
* @public
*/
-export function layerTypeChange(oldLayer, newType) {
+export function layerTypeChange(
+ oldLayer: Layer,
+ newType: string
+): Merge<LayerTypeChangeUpdaterAction, {type: typeof ActionTypes.LAYER_TYPE_CHANGE}> {
return {
type: ActionTypes.LAYER_TYPE_CHANGE,
oldLayer,
newType
};
}
-
+export type LayerVisualChannelConfigChangeUpdaterAction = {
+ oldLayer: Layer;
+ newConfig: Partial<LayerConfig>;
+ channel: string;
+};
/**
* Update layer visual channel
* @memberof visStateActions
@@ -80,10 +112,16 @@ export function layerTypeChange(oldLayer, newType) {
* @param newConfig - new visual channel config
* @param channel - channel to be updated
* @returns action
- * @type {typeof import('./vis-state-actions').layerVisualChannelConfigChange}
* @public
*/
-export function layerVisualChannelConfigChange(oldLayer, newConfig, channel) {
+export function layerVisualChannelConfigChange(
+ oldLayer: Layer,
+ newConfig: Partial<LayerConfig>,
+ channel: string
+): Merge<
+ LayerVisualChannelConfigChangeUpdaterAction,
+ {type: typeof ActionTypes.LAYER_VISUAL_CHANNEL_CHANGE}
+> {
return {
type: ActionTypes.LAYER_VISUAL_CHANNEL_CHANGE,
oldLayer,
@@ -91,23 +129,33 @@ export function layerVisualChannelConfigChange(oldLayer, newConfig, channel) {
channel
};
}
-
+export type LayerVisConfigChangeUpdaterAction = {
+ oldLayer: Layer;
+ newVisConfig: Partial<LayerVisConfig>;
+};
/**
* Update layer `visConfig`
* @memberof visStateActions
* @param oldLayer - layer to be updated
* @param newVisConfig - new visConfig as a key value map: e.g. `{opacity: 0.8}`
* @returns action
- * @type {typeof import('./vis-state-actions').layerVisConfigChange}
* @public
*/
-export function layerVisConfigChange(oldLayer, newVisConfig) {
+export function layerVisConfigChange(
+ oldLayer: Layer,
+ newVisConfig: Partial<LayerVisConfig>
+): Merge<LayerVisConfigChangeUpdaterAction, {type: typeof ActionTypes.LAYER_VIS_CONFIG_CHANGE}> {
return {
type: ActionTypes.LAYER_VIS_CONFIG_CHANGE,
oldLayer,
newVisConfig
};
}
+export type LayerColorUIChangeUpdaterAction = {
+ oldLayer: Layer;
+ prop: string;
+ newConfig: object;
+};
/**
* Set the color palette ui for layer color
@@ -116,10 +164,13 @@ export function layerVisConfigChange(oldLayer, newVisConfig) {
* @param prop - which color prop
* @param newConfig - to be merged
* @returns action
- * @type {typeof import('./vis-state-actions').layerColorUIChange}
* @public
*/
-export function layerColorUIChange(oldLayer, prop, newConfig) {
+export function layerColorUIChange(
+ oldLayer: Layer,
+ prop: string,
+ newConfig: object
+): Merge<LayerColorUIChangeUpdaterAction, {type: typeof ActionTypes.LAYER_COLOR_UI_CHANGE}> {
return {
type: ActionTypes.LAYER_COLOR_UI_CHANGE,
oldLayer,
@@ -128,36 +179,53 @@ export function layerColorUIChange(oldLayer, prop, newConfig) {
};
}
+export type UpdateLayerBlendingUpdaterAction = {
+ mode: 'additive' | 'normal' | 'subtractive';
+};
/**
* Update layer blending mode
* @memberof visStateActions
* @param mode one of `additive`, `normal` and `subtractive`
* @returns action
- * @type {typeof import('./vis-state-actions').updateLayerBlending}
* @public
*/
-export function updateLayerBlending(mode) {
+export function updateLayerBlending(
+ mode: 'additive' | 'normal' | 'subtractive'
+): Merge<UpdateLayerBlendingUpdaterAction, {type: typeof ActionTypes.UPDATE_LAYER_BLENDING}> {
return {
type: ActionTypes.UPDATE_LAYER_BLENDING,
mode
};
}
+export type InteractionConfigChangeUpdaterAction = {
+ config: ValueOf<InteractionConfig>;
+};
/**
* Update `interactionConfig`
* @memberof visStateActions
* @param config - new config as key value map: `{tooltip: {enabled: true}}`
* @returns action
- * @type {typeof import('./vis-state-actions').interactionConfigChange}
* @public
*/
-export function interactionConfigChange(config) {
+export function interactionConfigChange(
+ config: ValueOf<InteractionConfig>
+): Merge<
+ InteractionConfigChangeUpdaterAction,
+ {type: typeof ActionTypes.INTERACTION_CONFIG_CHANGE}
+> {
return {
type: ActionTypes.INTERACTION_CONFIG_CHANGE,
config
};
}
+export type SetFilterUpdaterAction = {
+ idx: number;
+ prop: string;
+ value: any;
+ valueIndex?: number;
+};
/**
* Update filter property
* @memberof visStateActions
@@ -166,10 +234,14 @@ export function interactionConfigChange(config) {
* @param value - new value
* @param valueIndex - dataId index
* @returns action
- * @type {typeof import('./vis-state-actions').setFilter}
* @public
*/
-export function setFilter(idx, prop, value, valueIndex) {
+export function setFilter(
+ idx: number,
+ prop: string,
+ value: any,
+ valueIndex: number
+): Merge<SetFilterUpdaterAction, {type: typeof ActionTypes.SET_FILTER}> {
return {
type: ActionTypes.SET_FILTER,
idx,
@@ -179,6 +251,12 @@ export function setFilter(idx, prop, value, valueIndex) {
};
}
+export type SetFilterAnimationTimeUpdaterAction = {
+ idx: number;
+ prop: string;
+ value: any;
+ valueIndex?: number;
+};
/**
* Same as Update filter
* @memberof visStateActions
@@ -187,10 +265,17 @@ export function setFilter(idx, prop, value, valueIndex) {
* @param value - new value
* @param valueIndex - dataId index
* @returns action
- * @type {typeof import('./vis-state-actions').setFilterAnimationTime}
* @public
*/
-export function setFilterAnimationTime(idx, prop, value, valueIndex) {
+export function setFilterAnimationTime(
+ idx: number,
+ prop: string,
+ value: any,
+ valueIndex?: number
+): Merge<
+ SetFilterAnimationTimeUpdaterAction,
+ {type: typeof ActionTypes.SET_FILTER_ANIMATION_TIME}
+> {
return {
type: ActionTypes.SET_FILTER_ANIMATION_TIME,
idx,
@@ -200,44 +285,64 @@ export function setFilterAnimationTime(idx, prop, value, valueIndex) {
};
}
+export type SetFilterAnimationWindowUpdaterAction = {
+ id: string;
+ animationWindow: string;
+};
/**
* Same as Update filter
* @memberof visStateActions
- * @type {typeof import('./vis-state-actions').setFilterAnimationWindow}
* @public
*/
-export function setFilterAnimationWindow({id, animationWindow}) {
+export function setFilterAnimationWindow({
+ id,
+ animationWindow
+}: SetFilterAnimationWindowUpdaterAction): Merge<
+ SetFilterAnimationWindowUpdaterAction,
+ {type: typeof ActionTypes.SET_FILTER_ANIMATION_WINDOW}
+> {
return {
type: ActionTypes.SET_FILTER_ANIMATION_WINDOW,
id,
animationWindow
};
}
+
+export type AddFilterUpdaterAction = {
+ dataId: string;
+};
/**
* Add a new filter
* @memberof visStateActions
* @param dataId - dataset `id` this new filter is associated with
* @returns action
- * @type {typeof import('./vis-state-actions').addFilter}
* @public
*/
-export function addFilter(dataId) {
+export function addFilter(
+ dataId: string
+): Merge<AddFilterUpdaterAction, {type: typeof ActionTypes.ADD_FILTER}> {
return {
type: ActionTypes.ADD_FILTER,
dataId
};
}
+export type AddLayerUpdaterAction = {
+ config: object;
+ datasetId?: string;
+};
/**
* Add a new layer
* @memberof visStateActions
* @param config - new layer config
* @param datasetId - dataset id used for creating an empty layer
* @returns action
- * @type {typeof import('./vis-state-actions').addLayer}
* @public
*/
-export function addLayer(config, datasetId) {
+export function addLayer(
+ config: object,
+ datasetId?: string
+): Merge<AddLayerUpdaterAction, {type: typeof ActionTypes.ADD_LAYER}> {
return {
type: ActionTypes.ADD_LAYER,
config,
@@ -245,12 +350,14 @@ export function addLayer(config, datasetId) {
};
}
+export type ReorderLayerUpdaterAction = {
+ order: number[];
+};
/**
* Reorder layer, order is an array of layer indexes, index 0 will be the one at the bottom
* @memberof visStateActions
* @param order an array of layer indexes
* @returns action
- * @type {typeof import('./vis-state-actions').reorderLayer}
* @public
* @example
*
@@ -258,98 +365,126 @@ export function addLayer(config, datasetId) {
* // `1` will be at the bottom, `3` will be at the top.
* this.props.dispatch(reorderLayer([1, 0, 2, 3]));
*/
-export function reorderLayer(order) {
+export function reorderLayer(
+ order: number[]
+): Merge<ReorderLayerUpdaterAction, {type: typeof ActionTypes.REORDER_LAYER}> {
return {
type: ActionTypes.REORDER_LAYER,
order
};
}
+export type RemoveFilterUpdaterAction = {
+ idx: number;
+};
/**
* Remove a filter from `visState.filters`, once a filter is removed, data will be re-filtered and layer will be updated
* @memberof visStateActions
* @param idx idx of filter to be removed
* @returns action
- * @type {typeof import('./vis-state-actions').removeFilter}
* @public
*/
-export function removeFilter(idx) {
+export function removeFilter(
+ idx: number
+): Merge<RemoveFilterUpdaterAction, {type: typeof ActionTypes.REMOVE_FILTER}> {
return {
type: ActionTypes.REMOVE_FILTER,
idx
};
}
+export type RemoveLayerUpdaterAction = {
+ idx: number;
+};
/**
* Remove a layer
* @memberof visStateActions
* @param idx idx of layer to be removed
* @returns action
- * @type {typeof import('./vis-state-actions').removeLayer}
* @public
*/
-export function removeLayer(idx) {
+export function removeLayer(
+ idx: number
+): Merge<RemoveLayerUpdaterAction, {type: typeof ActionTypes.REMOVE_LAYER}> {
return {
type: ActionTypes.REMOVE_LAYER,
idx
};
}
+export type DuplicateLayerUpdaterAction = {
+ idx: number;
+};
/**
* Duplicate a layer
* @memberof visStateActions
* @param idx idx of layer to be duplicated
* @returns action
- * @type {typeof import('./vis-state-actions').duplicateLayer}
* @public
*/
-export function duplicateLayer(idx) {
+export function duplicateLayer(
+ idx: number
+): Merge<DuplicateLayerUpdaterAction, {type: typeof ActionTypes.DUPLICATE_LAYER}> {
return {
type: ActionTypes.DUPLICATE_LAYER,
idx
};
}
+export type RemoveDatasetUpdaterAction = {
+ dataId: string;
+};
/**
* Remove a dataset and all layers, filters, tooltip configs that based on it
* @memberof visStateActions
* @param dataId dataset id
* @returns action
- * @type {typeof import('./vis-state-actions').removeDataset}
* @public
*/
-export function removeDataset(dataId) {
+export function removeDataset(
+ dataId: string
+): Merge<RemoveDatasetUpdaterAction, {type: typeof ActionTypes.REMOVE_DATASET}> {
return {
type: ActionTypes.REMOVE_DATASET,
dataId
};
}
+export type ShowDatasetTableUpdaterAction = {
+ dataId: string;
+};
/**
* Display dataset table in a modal
* @memberof visStateActions
* @param dataId dataset id to show in table
* @returns action
- * @type {typeof import('./vis-state-actions').showDatasetTable}
* @public
*/
-export function showDatasetTable(dataId) {
+export function showDatasetTable(
+ dataId: string
+): Merge<ShowDatasetTableUpdaterAction, {type: typeof ActionTypes.SHOW_DATASET_TABLE}> {
return {
type: ActionTypes.SHOW_DATASET_TABLE,
dataId
};
}
+export type UpdateDatasetColorUpdater = {
+ dataId: string;
+ newColor: RGBColor;
+};
/**
* Update dataset color to custom by means of color picker
* @memberof visStateActions
* @param dataId dataset `id` this custom color is associated with
* @param newColor custom color in RGBformat
* @returns action
- * @type {typeof import('./vis-state-actions').updateTableColor}
* @public
*/
-export function updateTableColor(dataId, newColor) {
+export function updateTableColor(
+ dataId: string,
+ newColor: RGBColor
+): Merge<UpdateDatasetColorUpdater, {type: typeof ActionTypes.UPDATE_TABLE_COLOR}> {
return {
type: ActionTypes.UPDATE_TABLE_COLOR,
dataId,
@@ -357,6 +492,11 @@ export function updateTableColor(dataId, newColor) {
};
}
+export type SortTableColumnUpdaterAction = {
+ dataId: string;
+ column: string;
+ mode: string;
+};
/**
* Sort dataset column, for table display
* @memberof visStateActions
@@ -364,10 +504,13 @@ export function updateTableColor(dataId, newColor) {
* @param column
* @param mode
* @returns action
- * @type {typeof import('./vis-state-actions').sortTableColumn}
* @public
*/
-export function sortTableColumn(dataId, column, mode) {
+export function sortTableColumn(
+ dataId: string,
+ column: string,
+ mode: string
+): Merge<SortTableColumnUpdaterAction, {type: typeof ActionTypes.SORT_TABLE_COLUMN}> {
return {
type: ActionTypes.SORT_TABLE_COLUMN,
dataId,
@@ -376,15 +519,21 @@ export function sortTableColumn(dataId, column, mode) {
};
}
+export type PinTableColumnUpdaterAction = {
+ dataId: string;
+ column: string;
+};
/**
* Pin dataset column, for table display
* @param dataId
* @param column
* @returns action
- * @type {typeof import('./vis-state-actions').pinTableColumn}
* @public
*/
-export function pinTableColumn(dataId, column) {
+export function pinTableColumn(
+ dataId: string,
+ column: string
+): Merge<PinTableColumnUpdaterAction, {type: typeof ActionTypes.PIN_TABLE_COLUMN}> {
return {
type: ActionTypes.PIN_TABLE_COLUMN,
dataId,
@@ -392,15 +541,21 @@ export function pinTableColumn(dataId, column) {
};
}
+export type CopyTableColumnUpdaterAction = {
+ dataId: string;
+ column: string;
+};
/**
* Copy column, for table display
* @param dataId
* @param column
* @returns action
- * @type {typeof import('./vis-state-actions').copyTableColumn}
* @public
*/
-export function copyTableColumn(dataId, column) {
+export function copyTableColumn(
+ dataId: string,
+ column: string
+): Merge<CopyTableColumnUpdaterAction, {type: typeof ActionTypes.COPY_TABLE_COLUMN}> {
return {
type: ActionTypes.COPY_TABLE_COLUMN,
dataId,
@@ -408,6 +563,17 @@ export function copyTableColumn(dataId, column) {
};
}
+export type AddDataToMapUpdaterOptions = {
+ centrMap?: boolean;
+ readOnly?: boolean;
+ keepExistingConfig?: boolean;
+};
+
+export type UpdateVisDataUpdaterAction = {
+ datasets: AddDataToMapPayload['datasets'];
+ options: AddDataToMapPayload['options'];
+ config: AddDataToMapPayload['config'];
+} & AddDataToMapPayload;
// * @param dataset.info -info of a dataset
// * @param dataset.info.id - id of this dataset. If config is defined, `id` should matches the `dataId` in config.
// * @param dataset.info.label - A display name of this dataset
@@ -427,10 +593,13 @@ export function copyTableColumn(dataId, column) {
* the left setting panel will be hidden
* @param config this object will contain the full kepler.gl instance configuration {mapState, mapStyle, visState}
* @returns action
- * @type {typeof import('./vis-state-actions').updateVisData}
* @public
*/
-export function updateVisData(datasets, options, config) {
+export function updateVisData(
+ datasets: AddDataToMapPayload['datasets'],
+ options: AddDataToMapPayload['options'],
+ config: AddDataToMapPayload['config']
+): Merge<UpdateVisDataUpdaterAction, {type: typeof ActionTypes.UPDATE_VIS_DATA}> {
return {
type: ActionTypes.UPDATE_VIS_DATA,
datasets,
@@ -439,16 +608,22 @@ export function updateVisData(datasets, options, config) {
};
}
+export type RenameDatasetUpdaterAction = {
+ dataId: string;
+ label: string;
+};
/**
* Rename an existing dataset in `visState`
* @memberof visStateActions
* @param dataId - ***required** Id of the dataset to update
* @param label - ***required** New name for the dataset
* @returns action
- * @type {typeof import('./vis-state-actions').renameDataset}
* @public
*/
-export function renameDataset(dataId, label) {
+export function renameDataset(
+ dataId: string,
+ label: string
+): Merge<RenameDatasetUpdaterAction, {type: typeof ActionTypes.RENAME_DATASET}> {
return {
type: ActionTypes.RENAME_DATASET,
dataId,
@@ -456,31 +631,44 @@ export function renameDataset(dataId, label) {
};
}
+export type ToggleFilterAnimationUpdaterAction = {
+ idx: number;
+};
/**
* Start and end filter animation
* @memberof visStateActions
* @param {Number} idx of filter
- * @type {typeof import('./vis-state-actions').toggleFilterAnimation}
* @returns action
* @public
*/
-export function toggleFilterAnimation(idx) {
+export function toggleFilterAnimation(
+ idx: number
+): Merge<ToggleFilterAnimationUpdaterAction, {type: typeof ActionTypes.TOGGLE_FILTER_ANIMATION}> {
return {
type: ActionTypes.TOGGLE_FILTER_ANIMATION,
idx
};
}
+export type UpdateFilterAnimationSpeedUpdaterAction = {
+ idx: number;
+ speed: number;
+};
/**
* Change filter animation speed
* @memberof visStateActions
* @param idx - `idx` of filter
* @param speed - `speed` to change it to. `speed` is a multiplier
- * @type {typeof import('./vis-state-actions').updateFilterAnimationSpeed}
* @returns action
* @public
*/
-export function updateFilterAnimationSpeed(idx, speed) {
+export function updateFilterAnimationSpeed(
+ idx: number,
+ speed: number
+): Merge<
+ UpdateFilterAnimationSpeedUpdaterAction,
+ {type: typeof ActionTypes.UPDATE_FILTER_ANIMATION_SPEED}
+> {
return {
type: ActionTypes.UPDATE_FILTER_ANIMATION_SPEED,
idx,
@@ -488,134 +676,169 @@ export function updateFilterAnimationSpeed(idx, speed) {
};
}
+export type SetLayerAnimationTimeUpdaterAction = {
+ value: number;
+};
/**
* Reset animation
* @memberof visStateActions
* @param value - Current value of the slider
- * @type {typeof import('./vis-state-actions').setLayerAnimationTime}
* @returns action
* @public
*/
-export function setLayerAnimationTime(value) {
+export function setLayerAnimationTime(
+ value: number
+): Merge<SetLayerAnimationTimeUpdaterAction, {type: typeof ActionTypes.SET_LAYER_ANIMATION_TIME}> {
return {
type: ActionTypes.SET_LAYER_ANIMATION_TIME,
value
};
}
+export type UpdateLayerAnimationSpeedUpdaterAction = {
+ speed: number;
+};
/**
* update trip layer animation speed
* @memberof visStateActions
* @param speed - `speed` to change it to. `speed` is a multiplier
- * @type {typeof import('./vis-state-actions').updateLayerAnimationSpeed}
* @returns action
* @public
*/
-export function updateLayerAnimationSpeed(speed) {
+export function updateLayerAnimationSpeed(
+ speed: number
+): Merge<
+ UpdateLayerAnimationSpeedUpdaterAction,
+ {type: typeof ActionTypes.UPDATE_LAYER_ANIMATION_SPEED}
+> {
return {
type: ActionTypes.UPDATE_LAYER_ANIMATION_SPEED,
speed
};
}
-
+export type ToggleLayerAnimationUpdaterAction = {};
/**
* start end end layer animation
* @memberof visStateActions
- * @type {typeof import('./vis-state-actions').toggleLayerAnimation}
* @returns action
* @public
*/
-export function toggleLayerAnimation() {
+export function toggleLayerAnimation(): Merge<
+ ToggleLayerAnimationUpdaterAction,
+ {type: typeof ActionTypes.TOGGLE_LAYER_ANIMATION}
+> {
return {
type: ActionTypes.TOGGLE_LAYER_ANIMATION
};
}
+export type ToggleLayerAnimationControlUpdaterAction = {};
/**
* hide and show layer animation control
* @memberof visStateActions
- * @type {typeof import('./vis-state-actions').toggleLayerAnimationControl}
* @returns action
* @public
*/
-export function toggleLayerAnimationControl() {
+export function toggleLayerAnimationControl(): Merge<
+ ToggleLayerAnimationControlUpdaterAction,
+ {type: typeof ActionTypes.TOGGLE_LAYER_ANIMATION_CONTROL}
+> {
return {
type: ActionTypes.TOGGLE_LAYER_ANIMATION_CONTROL
};
}
+export type EnlargeFilterUpdaterAction = {
+ idx: number;
+};
/**
* Show larger time filter at bottom for time playback (apply to time filter only)
* @memberof visStateActions
* @param idx - index of filter to enlarge
- * @type {typeof import('./vis-state-actions').enlargeFilter}
* @returns action
* @public
*/
-export function enlargeFilter(idx) {
+export function enlargeFilter(
+ idx: number
+): Merge<EnlargeFilterUpdaterAction, {type: typeof ActionTypes.ENLARGE_FILTER}> {
return {
type: ActionTypes.ENLARGE_FILTER,
idx
};
}
+export type ToggleFilterFeatureUpdaterAction = {
+ idx: number;
+};
/**
* Show/hide filter feature on map
* @memberof visStateActions
* @param idx - index of filter feature to show/hide
- * @type {typeof import('./vis-state-actions').toggleFilterFeature}
* @return action
*/
-export function toggleFilterFeature(idx) {
+export function toggleFilterFeature(
+ idx: number
+): Merge<ToggleFilterFeatureUpdaterAction, {type: typeof ActionTypes.TOGGLE_FILTER_FEATURE}> {
return {
type: ActionTypes.TOGGLE_FILTER_FEATURE,
idx
};
}
+export type OnLayerHoverUpdaterAction = {
+ info: {picked?: boolean} | null;
+};
/**
* Trigger layer hover event with hovered object
* @memberof visStateActions
* @param info - Object hovered, returned by deck.gl
- * @type {typeof import('./vis-state-actions').onLayerHover}
* @returns action
* @public
*/
-export function onLayerHover(info) {
+export function onLayerHover(
+ info: {picked?: boolean} | null
+): Merge<OnLayerHoverUpdaterAction, {type: typeof ActionTypes.LAYER_HOVER}> {
return {
type: ActionTypes.LAYER_HOVER,
info
};
}
+export type OnLayerClickUpdaterAction = {
+ info: {picked?: boolean} | null;
+};
/**
* Trigger layer click event with clicked object
* @memberof visStateActions
* @param info - Object clicked, returned by deck.gl
- * @type {typeof import('./vis-state-actions').onLayerClick}
* @returns action
* @public
*/
-export function onLayerClick(info) {
+export function onLayerClick(
+ info: {picked?: boolean} | null
+): Merge<OnLayerClickUpdaterAction, {type: typeof ActionTypes.LAYER_CLICK}> {
return {
type: ActionTypes.LAYER_CLICK,
info
};
}
+export type OnMapClickUpdaterAction = {};
/**
* Trigger map click event, unselect clicked object
* @memberof visStateActions
- * @type {typeof import('./vis-state-actions').onMapClick}
* @returns action
* @public
*/
-export function onMapClick() {
+export function onMapClick(): Merge<OnMapClickUpdaterAction, {type: typeof ActionTypes.MAP_CLICK}> {
return {
type: ActionTypes.MAP_CLICK
};
}
+export type OnMouseMoveUpdaterAction = {
+ evt;
+};
/**
* Trigger map mouse moveevent, payload would be
* React-map-gl PointerEvent
@@ -623,27 +846,34 @@ export function onMapClick() {
*
* @memberof visStateActions
* @param evt - PointerEvent
- * @type {typeof import('./vis-state-actions').onMouseMove}
* @returns action
* @public
*/
-export function onMouseMove(evt) {
+export function onMouseMove(
+ evt
+): Merge<OnMouseMoveUpdaterAction, {type: typeof ActionTypes.MOUSE_MOVE}> {
return {
type: ActionTypes.MOUSE_MOVE,
evt
};
}
+export type ToggleLayerForMapUpdaterAction = {
+ mapIndex: number;
+ layerId: string;
+};
/**
* Toggle visibility of a layer in a split map
* @memberof visStateActions
* @param mapIndex - index of the split map
* @param layerId - id of the layer
- * @type {typeof import('./vis-state-actions').toggleLayerForMap}
* @returns action
* @public
*/
-export function toggleLayerForMap(mapIndex, layerId) {
+export function toggleLayerForMap(
+ mapIndex: number,
+ layerId: string
+): Merge<ToggleLayerForMapUpdaterAction, {type: typeof ActionTypes.TOGGLE_LAYER_FOR_MAP}> {
return {
type: ActionTypes.TOGGLE_LAYER_FOR_MAP,
mapIndex,
@@ -651,17 +881,25 @@ export function toggleLayerForMap(mapIndex, layerId) {
};
}
+export type SetFilterPlotUpdaterAction = {
+ idx: number;
+ newProp: object;
+ valueIndex?: number;
+};
/**
* Set the property of a filter plot
* @memberof visStateActions
* @param idx
* @param newProp key value mapping of new prop `{yAxis: 'histogram'}`
* @param valueIndex dataId index
- * @type {typeof import('./vis-state-actions').setFilterPlot}
* @returns action
* @public
*/
-export function setFilterPlot(idx, newProp, valueIndex) {
+export function setFilterPlot(
+ idx: number,
+ newProp: object,
+ valueIndex?: number
+): Merge<SetFilterPlotUpdaterAction, {type: typeof ActionTypes.SET_FILTER_PLOT}> {
return {
type: ActionTypes.SET_FILTER_PLOT,
idx,
@@ -670,30 +908,40 @@ export function setFilterPlot(idx, newProp, valueIndex) {
};
}
+export type SetMapInfoUpdaterAction = {
+ info: any;
+};
/**
* Set the property of a filter plot
* @memberof visStateActions
* @param info
- * @type {typeof import('./vis-state-actions').setMapInfo}
* @returns action
* @public
*/
-export function setMapInfo(info) {
+export function setMapInfo(
+ info: any
+): Merge<SetMapInfoUpdaterAction, {type: typeof ActionTypes.SET_MAP_INFO}> {
return {
type: ActionTypes.SET_MAP_INFO,
info
};
}
+export type LoadFilesUpdaterAction = {
+ files: File[];
+ onFinish?(result: any): any;
+};
/**
* Trigger file loading dispatch `addDataToMap` if succeed, or `loadFilesErr` if failed
* @memberof visStateActions
* @param files array of fileblob
- * @type {typeof import('./vis-state-actions').loadFiles}
* @returns action
* @public
*/
-export function loadFiles(files, onFinish) {
+export function loadFiles(
+ files: File[],
+ onFinish?: (result: any) => any
+): Merge<LoadFilesUpdaterAction, {type: typeof ActionTypes.LOAD_FILES}> {
return {
type: ActionTypes.LOAD_FILES,
files,
@@ -704,38 +952,50 @@ export function loadFiles(files, onFinish) {
/**
* Called with next file to load
* @memberof visStateActions
- * @type {typeof import('./vis-state-actions').loadNextFile}
* @returns action
* @public
*/
-export function loadNextFile() {
+export function loadNextFile(): {type: typeof ActionTypes.LOAD_NEXT_FILE} {
return {
type: ActionTypes.LOAD_NEXT_FILE
};
}
+export type loadFilesSuccessUpdaterAction = {
+ result: FileCacheItem[];
+};
/**
* called when all files are processed and loaded
* @memberof visStateActions
* @param result
- * @type {typeof import('./vis-state-actions').loadFilesSuccess}
* @returns action
*/
-export function loadFilesSuccess(result) {
+export function loadFilesSuccess(
+ result: FileCacheItem[]
+): Merge<loadFilesSuccessUpdaterAction, {type: typeof ActionTypes.LOAD_FILES_SUCCESS}> {
return {
type: ActionTypes.LOAD_FILES_SUCCESS,
result
};
}
+export type LoadFileStepSuccessAction = {
+ fileName: string;
+ fileCache: FileCacheItem[];
+};
/**
* called when successfully loaded one file, ready to move on to the next one
* @memberof visStateActions
* @param result
- * @type {typeof import('./vis-state-actions').loadFileStepSuccess}
* @returns action
*/
-export function loadFileStepSuccess({fileName, fileCache}) {
+export function loadFileStepSuccess({
+ fileName,
+ fileCache
+}: {
+ fileName: string;
+ fileCache: FileCacheItem[];
+}): Merge<LoadFileStepSuccessAction, {type: typeof ActionTypes.LOAD_FILE_STEP_SUCCESS}> {
return {
type: ActionTypes.LOAD_FILE_STEP_SUCCESS,
fileName,
@@ -743,15 +1003,22 @@ export function loadFileStepSuccess({fileName, fileCache}) {
};
}
+export type loadFilesErrUpdaterAction = {
+ fileName: string;
+ error: any;
+};
/**
* Trigger loading file error
* @memberof visStateActions
* @param error
- * @type {typeof import('./vis-state-actions').loadFilesErr}
* @returns action
* @public
*/
-export function loadFilesErr(fileName, error) {
+
+export function loadFilesErr(
+ fileName: string,
+ error: any
+): Merge<loadFilesErrUpdaterAction, {type: typeof ActionTypes.LOAD_FILES_ERR}> {
return {
type: ActionTypes.LOAD_FILES_ERR,
fileName,
@@ -759,30 +1026,40 @@ export function loadFilesErr(fileName, error) {
};
}
+export type SetFeaturesUpdaterAction = {
+ features: Feature[];
+};
/**
* Store features to state
* @memberof visStateActions
* @param features
- * @type {typeof import('./vis-state-actions').setFeatures}
* @returns action
*/
-export function setFeatures(features) {
+export function setFeatures(
+ features: Feature[]
+): Merge<SetFeaturesUpdaterAction, {type: typeof ActionTypes.SET_FEATURES}> {
return {
type: ActionTypes.SET_FEATURES,
features
};
}
+export type SetPolygonFilterLayerUpdaterAction = {
+ layer: Layer;
+ feature: Feature;
+};
/**
* It will apply the provide feature as filter to the given layer.
* If the given feature is already applied as filter to the layer, it will remove the layer from the filter
* @memberof visStateActions
* @param layer
* @param feature
- * @type {typeof import('./vis-state-actions').setPolygonFilterLayer}
* @returns action
*/
-export function setPolygonFilterLayer(layer, feature) {
+export function setPolygonFilterLayer(
+ layer: Layer,
+ feature: Feature
+): Merge<SetPolygonFilterLayerUpdaterAction, {type: typeof ActionTypes.SET_POLYGON_FILTER_LAYER}> {
return {
type: ActionTypes.SET_POLYGON_FILTER_LAYER,
layer,
@@ -790,38 +1067,48 @@ export function setPolygonFilterLayer(layer, feature) {
};
}
+export type SetSelectedFeatureUpdaterAction = {
+ feature: Feature;
+};
/**
* Set the current feature to be edited/deleted
* @memberof visStateActions
* @param feature
- * @type {typeof import('./vis-state-actions').setSelectedFeature}
* @returns action
*/
-export function setSelectedFeature(feature) {
+export function setSelectedFeature(
+ feature: Feature
+): Merge<SetSelectedFeatureUpdaterAction, {type: typeof ActionTypes.SET_SELECTED_FEATURE}> {
return {
type: ActionTypes.SET_SELECTED_FEATURE,
feature
};
}
+export type DeleteFeatureUpdaterAction = {
+ feature: Feature;
+};
/**
* Delete the given feature
* @memberof visStateActions
* @param feature
- * @type {typeof import('./vis-state-actions').deleteFeature}
* @returns action
*/
-export function deleteFeature(feature) {
+export function deleteFeature(
+ feature: Feature
+): Merge<DeleteFeatureUpdaterAction, {type: typeof ActionTypes.DELETE_FEATURE}> {
return {
type: ActionTypes.DELETE_FEATURE,
feature
};
}
+export type SetEditorModeUpdaterAction = {
+ mode: string;
+};
/** Set the map mode
* @memberof visStateActions
* @param mode one of EDITOR_MODES
- * @type {typeof import('./vis-state-actions').setEditorMode}
* @returns action
* @public
* @example
@@ -830,91 +1117,144 @@ export function deleteFeature(feature) {
*
* this.props.dispatch(setMapMode(EDITOR_MODES.DRAW_POLYGON));
*/
-export function setEditorMode(mode) {
+export function setEditorMode(
+ mode: string
+): Merge<SetEditorModeUpdaterAction, {type: typeof ActionTypes.SET_EDITOR_MODE}> {
return {
type: ActionTypes.SET_EDITOR_MODE,
mode
};
}
+export type ApplyCPUFilterUpdaterAction = {
+ dataId: string | string[];
+};
/**
* Trigger CPU filter of selected dataset
* @memberof visStateActions
* @param dataId - single dataId or an array of dataIds
- * @type {typeof import('./vis-state-actions').applyCPUFilter}
* @returns action
* @public
*/
-export function applyCPUFilter(dataId) {
+export function applyCPUFilter(
+ dataId: string | string[]
+): Merge<ApplyCPUFilterUpdaterAction, {type: typeof ActionTypes.APPLY_CPU_FILTER}> {
return {
type: ActionTypes.APPLY_CPU_FILTER,
dataId
};
}
+export type ToggleEditorVisibilityUpdaterAction = {};
/**
* Toggle editor layer visibility
* @memberof visStateActions
- * @type {typeof import('./vis-state-actions').toggleEditorVisibility}
* @return action
*/
-export function toggleEditorVisibility() {
+export function toggleEditorVisibility(): Merge<
+ ToggleEditorVisibilityUpdaterAction,
+ {type: typeof ActionTypes.TOGGLE_EDITOR_VISIBILITY}
+> {
return {
type: ActionTypes.TOGGLE_EDITOR_VISIBILITY
};
}
+type FileContent = {
+ fileName: string;
+ header: string[];
+ data: any;
+};
+export type NextFileBatchUpdaterAction = {
+ payload: {
+ gen: AsyncGenerator<FileContent>;
+ fileName: string;
+ progress?: any;
+ accumulated?: any;
+ onFinish: (result: any) => any;
+ };
+};
/**
* Process the next file batch
* @memberof visStateActions
* @param payload - batch payload
- * @type {typeof import('./vis-state-actions').nextFileBatch}
* @return action
*/
-export function nextFileBatch(payload) {
+export function nextFileBatch(
+ payload: NextFileBatchUpdaterAction['payload']
+): Merge<NextFileBatchUpdaterAction, {type: typeof ActionTypes.NEXT_FILE_BATCH}> {
return {
type: ActionTypes.NEXT_FILE_BATCH,
payload
};
}
+export type ProcessFileContentUpdaterAction = {
+ payload: {
+ content: FileContent;
+ fileCache: FileCacheItem[];
+ };
+};
/**
* Process the file content
* @memberof visStateActions
* @param payload - the file content
- * @type {typeof import('./vis-state-actions').processFileContent}
* @return action
*/
-export function processFileContent(payload) {
+export function processFileContent(
+ payload: ProcessFileContentUpdaterAction['payload']
+): Merge<ProcessFileContentUpdaterAction, {type: typeof ActionTypes.PROCESS_FILE_CONTENT}> {
return {
type: ActionTypes.PROCESS_FILE_CONTENT,
payload
};
}
+export type SetLayerAnimationTimeConfigAction = {
+ config: {
+ timezone?: string;
+ timeFormat?: string;
+ };
+};
/**
* Set layer animation time format and timezone
* @memberof visStateActions
* @param config - {timeFormat: string, timezone: string}
- * @type {typeof import('./vis-state-actions').setLayerAnimationTimeConfig}
* @return action
*/
-export function setLayerAnimationTimeConfig(config) {
+export function setLayerAnimationTimeConfig(
+ config: SetLayerAnimationTimeConfigAction['config']
+): Merge<
+ SetLayerAnimationTimeConfigAction,
+ {type: typeof ActionTypes.SET_LAYER_ANIMATION_TIME_CONFIG}
+> {
return {
type: ActionTypes.SET_LAYER_ANIMATION_TIME_CONFIG,
config
};
}
+export type SetFilterAnimationTimeConfigAction = {
+ idx: number;
+ config: {
+ timezone?: string;
+ timeFormat?: string;
+ };
+};
/**
* Set Filter animation time format and timezone
* @memberof visStateActions
* @param idx
* @param config
- * @type {typeof import('./vis-state-actions').setFilterAnimationTimeConfig}
* @return action
*/
-export function setFilterAnimationTimeConfig(idx, config) {
+export function setFilterAnimationTimeConfig(
+ idx: SetFilterAnimationTimeConfigAction['idx'],
+ config: SetFilterAnimationTimeConfigAction['config']
+): Merge<
+ SetFilterAnimationTimeConfigAction,
+ {type: typeof ActionTypes.SET_FILTER_ANIMATION_TIME_CONFIG}
+> {
return {
type: ActionTypes.SET_FILTER_ANIMATION_TIME_CONFIG,
idx,
diff --git a/src/constants/action-types.ts b/src/constants/action-types.ts
index 0c1d302ec..7f3c58a96 100644
--- a/src/constants/action-types.ts
+++ b/src/constants/action-types.ts
@@ -183,4 +183,6 @@ const ActionTypes = {
START_SAVE_STORAGE: `${ACTION_PREFIX}START_SAVE_STORAGE`
};
-export default ActionTypes;
+const assignType = <T>(obj: T): { [K in keyof T]: `${typeof ACTION_PREFIX}${string & K}`; } => obj as any
+
+export default assignType(ActionTypes);
diff --git a/src/constants/color-ranges.ts b/src/constants/color-ranges.ts
index 984158338..2ea4e15d2 100644
--- a/src/constants/color-ranges.ts
+++ b/src/constants/color-ranges.ts
@@ -19,6 +19,7 @@
// THE SOFTWARE.
import colorbrewer from 'colorbrewer';
+import {HexColor} from 'reducers';
import {VizColorPalette} from './custom-color-ranges';
// Add colorbrewer color schemes (Data Science requirement)
@@ -47,7 +48,7 @@ for (const [keyName, colorScheme] of Object.entries(colorbrewer)) {
name: `ColorBrewer ${keyName}-${lenKey}`,
type: colorBrewerMap[keyName],
category: 'ColorBrewer',
- colors: colors as any
+ colors: colors as HexColor[]
});
}
}
diff --git a/src/index.d.ts b/src/index.d.ts
index 3c46ed49d..07635cbbc 100644
--- a/src/index.d.ts
+++ b/src/index.d.ts
@@ -1,2 +1 @@
-export * from './actions';
export * from './components';
diff --git a/src/reducers/map-state.ts b/src/reducers/map-state.ts
index f8d6d503e..794b31ae7 100644
--- a/src/reducers/map-state.ts
+++ b/src/reducers/map-state.ts
@@ -37,6 +37,7 @@ const actionHandler = {
/* Reducer */
export const mapStateReducerFactory = (initialState = {}) =>
+ // @ts-expect-error
handleActions(actionHandler, {
...mapStateUpdaters.INITIAL_MAP_STATE,
...initialState,
diff --git a/src/reducers/map-style-updaters.ts b/src/reducers/map-style-updaters.ts
index 344c778a7..09fb34255 100644
--- a/src/reducers/map-style-updaters.ts
+++ b/src/reducers/map-style-updaters.ts
@@ -18,6 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
+// @ts-nocheck
import Task, {withTask} from 'react-palm/tasks';
import cloneDeep from 'lodash.clonedeep';
diff --git a/src/reducers/map-style.ts b/src/reducers/map-style.ts
index 51e7717e2..cc75fc61a 100644
--- a/src/reducers/map-style.ts
+++ b/src/reducers/map-style.ts
@@ -43,6 +43,7 @@ const actionHandler = {
};
export const mapStyleReducerFactory = (initialState = {}) =>
+ // @ts-expect-error
handleActions(actionHandler, {
...mapStyleUpdaters.INITIAL_MAP_STYLE,
...initialState,
diff --git a/src/reducers/ui-state.js b/src/reducers/ui-state.js
index 0557a45ed..d0dec158e 100644
--- a/src/reducers/ui-state.js
+++ b/src/reducers/ui-state.js
@@ -68,6 +68,7 @@ export const uiStateReducerFactory = (initialState = {}) =>
handleActions(actionHandler, {
...uiStateUpdaters.INITIAL_UI_STATE,
...initialState,
+ // @ts-ignore
initialState
});
diff --git a/yarn.lock b/yarn.lock
index 4706c4ea5..370336f83 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2031,6 +2031,13 @@
dependencies:
regenerator-runtime "^0.13.4"
+"@babel/runtime@^7.9.2":
+ version "7.17.0"
+ resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.17.0.tgz#b8d142fc0f7664fb3d9b5833fd40dcbab89276c0"
+ integrity sha512-etcO/ohMNaNA2UBdaXBBSX/3aEzFMRrVfaPv8Ptc0k+cWpWW0QFiGZ2XnVqQZI1Cf734LbPGmqBKWESfW4x/dQ==
+ dependencies:
+ regenerator-runtime "^0.13.4"
+
"@babel/template@^7.10.4", "@babel/template@^7.12.7", "@babel/template@^7.3.3":
version "7.12.7"
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.12.7.tgz#c817233696018e39fbb6c491d2fb684e05ed43bc"
@@ -2977,6 +2984,16 @@
probe.gl "3.3.0"
puppeteer "^1.16.0"
+"@reduxjs/toolkit@^1.7.2":
+ version "1.7.2"
+ resolved "https://registry.yarnpkg.com/@reduxjs/toolkit/-/toolkit-1.7.2.tgz#b428aaef92582379464f9de698dbb71957eafb02"
+ integrity sha512-wwr3//Ar8ZhM9bS58O+HCIaMlR4Y6SNHfuszz9hKnQuFIKvwaL3Kmjo6fpDKUOjo4Lv54Yi299ed8rofCJ/Vjw==
+ dependencies:
+ immer "^9.0.7"
+ redux "^4.1.2"
+ redux-thunk "^2.4.1"
+ reselect "^4.1.5"
+
"@sinonjs/commons@^1.7.0":
version "1.8.1"
resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.1.tgz#e7df00f98a203324f6dc7cc606cad9d4a8ab2217"
@@ -3294,6 +3311,11 @@
"@types/prop-types" "*"
csstype "^3.0.2"
+"@types/redux-actions@^2.6.2":
+ version "2.6.2"
+ resolved "https://registry.yarnpkg.com/@types/redux-actions/-/redux-actions-2.6.2.tgz#5956d9e7b9a644358e2c0610f47b1fa3060edc21"
+ integrity sha512-TvcINy8rWFANcpc3EiEQX9Yv3owM3d3KIrqr2ryUIOhYIYzXA/bhDZeGSSSuai62iVR2qMZUgz9tQ5kr0Kl+Tg==
+
"@types/source-list-map@*":
version "0.1.2"
resolved "https://registry.yarnpkg.com/@types/source-list-map/-/source-list-map-0.1.2.tgz#0078836063ffaf17412349bba364087e0ac02ec9"
@@ -8487,6 +8509,11 @@ ignore@^5.2.0:
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a"
integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==
+immer@^9.0.7:
+ version "9.0.12"
+ resolved "https://registry.yarnpkg.com/immer/-/immer-9.0.12.tgz#2d33ddf3ee1d247deab9d707ca472c8c942a0f20"
+ integrity sha512-lk7UNmSbAukB5B6dh9fnh5D0bJTOFKxVg2cyJWTYrWRfhLrLMBquONcUs3aFq507hNoIZEDDh8lb8UtOizSMhA==
+
import-fresh@^3.0.0, import-fresh@^3.2.1:
version "3.2.2"
resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.2.2.tgz#fc129c160c5d68235507f4331a6baad186bdbc3e"
@@ -12790,6 +12817,11 @@ redux-mock-store@^1.2.1:
dependencies:
lodash.isplainobject "^4.0.6"
+redux-thunk@^2.4.1:
+ version "2.4.1"
+ resolved "https://registry.yarnpkg.com/redux-thunk/-/redux-thunk-2.4.1.tgz#0dd8042cf47868f4b29699941de03c9301a75714"
+ integrity sha512-OOYGNY5Jy2TWvTL1KgAlVy6dcx3siPJ1wTq741EPyUKfn6W6nChdICjZwCd0p8AZBs5kWpZlbkXW2nE/zjUa+Q==
+
redux@^4.0.5:
version "4.0.5"
resolved "https://registry.yarnpkg.com/redux/-/redux-4.0.5.tgz#4db5de5816e17891de8a80c424232d06f051d93f"
@@ -12798,6 +12830,13 @@ redux@^4.0.5:
loose-envify "^1.4.0"
symbol-observable "^1.2.0"
+redux@^4.1.2:
+ version "4.1.2"
+ resolved "https://registry.yarnpkg.com/redux/-/redux-4.1.2.tgz#140f35426d99bb4729af760afcf79eaaac407104"
+ integrity sha512-SH8PglcebESbd/shgf6mii6EIoRM0zrQyjcuQ+ojmfxjTtE0z9Y8pa62iA/OJ58qjP6j27uyW4kUF4jl/jd6sw==
+ dependencies:
+ "@babel/runtime" "^7.9.2"
+
reflect.ownkeys@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/reflect.ownkeys/-/reflect.ownkeys-0.2.0.tgz#749aceec7f3fdf8b63f927a04809e90c5c0b3460"
@@ -13150,6 +13189,11 @@ reselect@^4.0.0:
resolved "https://registry.yarnpkg.com/reselect/-/reselect-4.0.0.tgz#f2529830e5d3d0e021408b246a206ef4ea4437f7"
integrity sha512-qUgANli03jjAyGlnbYVAV5vvnOmJnODyABz51RdBN7M4WaVu8mecZWgyQNkG8Yqe3KRGRt0l4K4B3XVEULC4CA==
+reselect@^4.1.5:
+ version "4.1.5"
+ resolved "https://registry.yarnpkg.com/reselect/-/reselect-4.1.5.tgz#852c361247198da6756d07d9296c2b51eddb79f6"
+ integrity sha512-uVdlz8J7OO+ASpBYoz1Zypgx0KasCY20H+N8JD13oUMtPvSHQuscrHop4KbXrbsBcdB9Ds7lVK7eRkBIfO43vQ==
+
resize-observer-polyfill@^1.5.1:
version "1.5.1"
resolved "https://registry.yarnpkg.com/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz#0e9020dd3d21024458d4ebd27e23e40269810464"