Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.
[feat] create new dataset action (#2778)
Igor Dykhta5b4f65376c4e
diff --git a/examples/demo-app/package.json b/examples/demo-app/package.jsonindex d2bf40df5..602f7b6a9 100644--- a/examples/demo-app/package.json+++ b/examples/demo-app/package.json@@ -44,6 +44,7 @@"react-virtualized": "^9.21.0","redux": "^4.2.1","redux-actions": "^2.2.1",+ "redux-logger": "^3.0.6","redux-thunk": "^1.0.0","styled-components": "^4.1.3"},diff --git a/examples/demo-app/src/app.js b/examples/demo-app/src/app.tsxsimilarity index 62%rename from examples/demo-app/src/app.jsrename to examples/demo-app/src/app.tsxindex 8be0057a4..500c07699 100644--- a/examples/demo-app/src/app.js+++ b/examples/demo-app/src/app.tsx@@ -1,11 +1,11 @@// SPDX-License-Identifier: MIT// Copyright contributors to the kepler.gl project-import React, {Component} from 'react';+import React, {useCallback, useEffect, useMemo, useState} from 'react';import AutoSizer from 'react-virtualized/dist/commonjs/AutoSizer';import styled, {ThemeProvider} from 'styled-components';import window from 'global/window';-import {connect} from 'react-redux';+import {connect, useDispatch} from 'react-redux';import cloneDeep from 'lodash.clonedeep';import {ScreenshotWrapper} from 'react-ai-assist';@@ -30,7 +30,7 @@ import {onLoadCloudMapSuccess} from './actions';-import {loadCloudMap, addDataToMap, addNotification, replaceDataInMap} from '@kepler.gl/actions';+import {loadCloudMap, addDataToMap, replaceDataInMap} from '@kepler.gl/actions';import {CLOUD_PROVIDERS} from './cloud-providers';const KeplerGl = require('@kepler.gl/components').injectComponents([@@ -48,7 +48,7 @@ import sampleGeojsonConfig from './data/sample-geojson-config';import sampleH3Data, {config as h3MapConfig} from './data/sample-hex-id-csv';import sampleS2Data, {config as s2MapConfig, dataId as s2DataId} from './data/sample-s2-data';import sampleAnimateTrip, {animateTripDataId} from './data/sample-animate-trip-data';-import sampleIconCsv, {config as savedMapConfig} from './data/sample-icon-csv';+import sampleIconCsv from './data/sample-icon-csv';import sampleGpsData from './data/sample-gps-data';import sampleRowData, {config as rowDataConfig} from './data/sample-row-data';import {processCsvData, processGeojson, processRowObject} from '@kepler.gl/processors';@@ -93,24 +93,23 @@ const CONTAINER_STYLE = {width: '100%',height: '100%',left: 0,- top: 0+ top: 0,+ display: 'flex',+ flexDirection: 'row'};-class App extends Component {- state = {- showBanner: false,- width: window.innerWidth,- height: window.innerHeight- };+const App = props => {+ const [showBanner, toggleShowBanner] = useState(false);+ const {params: {id, provider} = {}, location: {query = {}} = {}} = props;+ const dispatch = useDispatch();- componentDidMount() {+ useEffect(() => {// if we pass an id as part of the url// we ry to fetch along map configurations- const {params: {id, provider} = {}, location: {query = {}} = {}} = this.props;const cloudProvider = CLOUD_PROVIDERS.find(c => c.name === provider);if (cloudProvider) {- this.props.dispatch(+ dispatch(loadCloudMap({loadParams: query,provider: cloudProvider,@@ -122,83 +121,56 @@ class App extends Component {// Load sample using its idif (id) {- this.props.dispatch(loadSampleConfigurations(id));+ dispatch(loadSampleConfigurations(id));}// Load map using a customif (query.mapUrl) {// TODO?: validate map url- this.props.dispatch(loadRemoteMap({dataUrl: query.mapUrl}));+ dispatch(loadRemoteMap({dataUrl: query.mapUrl}));}// delay zs to show the banner// if (!window.localStorage.getItem(BannerKey)) {- // window.setTimeout(this._showBanner, 3000);+ // window.setTimeout(_showBanner, 3000);// }// load sample data- // this._loadSampleData();+ // _loadSampleData();// Notifications- // this._loadMockNotifications();- }-- _setStartScreenCapture = flag => {- this.props.dispatch(setStartScreenCapture(flag));- };+ // _loadMockNotifications();+ }, [dispatch, id, provider, query]);++ const _setStartScreenCapture = useCallback(+ flag => {+ dispatch(setStartScreenCapture(flag));+ },+ [dispatch]+ );- _setScreenCaptured = screenshot => {- this.props.dispatch(setScreenCaptured(screenshot));- };+ const _setScreenCaptured = useCallback(+ screenshot => {+ dispatch(setScreenCaptured(screenshot));+ },+ [dispatch]+ );- _showBanner = () => {- this.setState({showBanner: true});- };+ // eslint-disable-next-line no-unused-vars+ const _showBanner = useCallback(() => {+ toggleShowBanner(true);+ }, [toggleShowBanner]);- _hideBanner = () => {- this.setState({showBanner: false});- };+ const hideBanner = useCallback(() => {+ toggleShowBanner(false);+ }, [toggleShowBanner]);- _disableBanner = () => {- this._hideBanner();+ const _disableBanner = useCallback(() => {+ hideBanner();window.localStorage.setItem(BannerKey, 'true');- };-- _loadMockNotifications = () => {- const notifications = [- [{message: 'Welcome to Kepler.gl'}, 3000],- [{message: 'Something is wrong', type: 'error'}, 1000],- [{message: 'I am getting better', type: 'warning'}, 1000],- [{message: 'Everything is fine', type: 'success'}, 1000]- ];-- this._addNotifications(notifications);- };-- _addNotifications(notifications) {- if (notifications && notifications.length) {- const [notification, timeout] = notifications[0];-- window.setTimeout(() => {- this.props.dispatch(addNotification(notification));- this._addNotifications(notifications.slice(1));- }, timeout);- }- }+ }, [hideBanner]);- _loadSampleData() {- // this._loadPointData();- // this._loadGeojsonData();- // this._loadTripGeoJson();- // this._loadIconData();- // this._loadH3HexagonData();- // this._loadS2Data();- // this._loadScenegraphLayer();- // this._loadGpsData();- // this._loadRowData();- }-- _loadRowData() {- this.props.dispatch(+ const _loadRowData = useCallback(() => {+ dispatch(addDataToMap({datasets: [{@@ -212,10 +184,10 @@ class App extends Component {config: rowDataConfig}));- }+ }, [dispatch]);- _loadPointData() {- this.props.dispatch(+ const _loadPointData = useCallback(() => {+ dispatch(addDataToMap({datasets: [{@@ -248,10 +220,10 @@ class App extends Component {config: sampleTripDataConfig}));- }+ }, [dispatch]);- _loadScenegraphLayer() {- this.props.dispatch(+ const _loadScenegraphLayer = useCallback(() => {+ dispatch(addDataToMap({datasets: {info: {@@ -282,11 +254,11 @@ class App extends Component {}}));- }+ }, [dispatch]);- _loadIconData() {+ const _loadIconData = useCallback(() => {// load icon data and config and process csv file- this.props.dispatch(+ dispatch(addDataToMap({datasets: [{@@ -299,10 +271,10 @@ class App extends Component {]}));- }+ }, [dispatch]);- _loadTripGeoJson() {- this.props.dispatch(+ const _loadTripGeoJson = useCallback(() => {+ dispatch(addDataToMap({datasets: [{@@ -312,17 +284,45 @@ class App extends Component {]}));- }+ }, [dispatch]);- _replaceData = () => {+ const _loadGeojsonData = useCallback(() => {+ // load geojson+ const geojsonPoints = processGeojson(sampleGeojsonPoints);+ const geojsonZip = processGeojson(sampleGeojson);+ dispatch(+ addDataToMap({+ datasets: [+ geojsonPoints+ ? {+ info: {label: 'Bart Stops Geo', id: 'bart-stops-geo'},+ data: geojsonPoints+ }+ : null,+ geojsonZip+ ? {+ info: {label: 'SF Zip Geo', id: 'sf-zip-geo'},+ data: geojsonZip+ }+ : null+ ].filter(d => d !== null),+ options: {+ keepExistingConfig: true+ },+ config: sampleGeojsonConfig+ })+ );+ }, [dispatch]);++ const _replaceData = useCallback(() => {// add geojson dataconst sliceData = processGeojson({type: 'FeatureCollection',features: sampleGeojsonPoints.features.slice(0, 5)});- this._loadGeojsonData();+ _loadGeojsonData();window.setTimeout(() => {- this.props.dispatch(+ dispatch(replaceDataInMap({datasetToReplaceId: 'bart-stops-geo',datasetToUse: {@@ -332,33 +332,11 @@ class App extends Component {}));}, 1000);- };-- _loadGeojsonData() {- // load geojson- this.props.dispatch(- addDataToMap({- datasets: [- {- info: {label: 'Bart Stops Geo', id: 'bart-stops-geo'},- data: processGeojson(sampleGeojsonPoints)- }- // {- // info: {label: 'SF Zip Geo', id: 'sf-zip-geo'},- // data: processGeojson(sampleGeojson)- // }- ],- options: {- keepExistingConfig: true- },- config: sampleGeojsonConfig- })- );- }+ }, [dispatch, _loadGeojsonData]);- _loadH3HexagonData() {+ const _loadH3HexagonData = useCallback(() => {// load h3 hexagon- this.props.dispatch(+ dispatch(addDataToMap({datasets: [{@@ -375,11 +353,11 @@ class App extends Component {}}));- }+ }, [dispatch]);- _loadS2Data() {+ const _loadS2Data = useCallback(() => {// load s2- this.props.dispatch(+ dispatch(addDataToMap({datasets: [{@@ -396,10 +374,10 @@ class App extends Component {}}));- }+ }, [dispatch]);- _loadGpsData() {- this.props.dispatch(+ const _loadGpsData = useCallback(() => {+ dispatch(addDataToMap({datasets: [{@@ -415,66 +393,66 @@ class App extends Component {}}));- }- _toggleCloudModal = () => {- // TODO: this lives only in the demo hence we use the state for now- // REFCOTOR using redux- this.setState({- cloudModalOpen: !this.state.cloudModalOpen- });- };-- _getMapboxRef = mapbox => {- if (!mapbox) {- // The ref has been unset.- // https://reactjs.org/docs/refs-and-the-dom.html#callback-refs- // console.log(`Map ${index} has closed`);- } else {- // We expect an Map created by KeplerGl's MapContainer.- // https://visgl.github.io/react-map-gl/docs/api-reference/map- const map = mapbox.getMap();- map.on('zoomend', () => {- // console.log(`Map ${index} zoom level: ${e.target.style.z}`);- });- }- };-- combinedMessages = Object.keys(messages).reduce(- (acc, language) => ({- ...acc,- [language]: {- ...(messages[language] || {}),- ...(aiAssistantMessages[language] || {})- }- }),- {}- );-- render() {- return (- <ThemeProvider theme={theme}>- <GlobalStyle- // this is to apply the same modal style as kepler.gl core- // because styled-components doesn't always return a node- // https://github.com/styled-components/styled-components/issues/617- ref={node => {- node ? (this.root = node) : null;- }}+ }, [dispatch]);++ const combinedMessages = useMemo(() => {+ return Object.keys(messages).reduce(+ (acc, language) => ({+ ...acc,+ [language]: {+ ...(messages[language] || {}),+ ...(aiAssistantMessages[language] || {})+ }+ }),+ {}+ );+ }, []);++ // eslint-disable-next-line no-unused-vars+ const _loadSampleData = useCallback(() => {+ // _loadPointData();+ // _loadGeojsonData();+ // _loadTripGeoJson();+ // _loadIconData();+ // _loadH3HexagonData();+ // _loadS2Data();+ // _loadScenegraphLayer();+ // _loadGpsData();+ // _loadRowData();+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [+ _loadPointData,+ _loadGeojsonData,+ _loadTripGeoJson,+ _loadIconData,+ _loadH3HexagonData,+ _loadS2Data,+ _loadScenegraphLayer,+ _loadGpsData,+ _loadRowData,+ _replaceData+ ]);++ return (+ <ThemeProvider theme={theme}>+ <GlobalStyle+ // this is to apply the same modal style as kepler.gl core+ // because styled-components doesn't always return a node+ // https://github.com/styled-components/styled-components/issues/617+ // ref={node => {+ // node ? (this.root = node) : null;+ // }}+ >+ <ScreenshotWrapper+ startScreenCapture={props.demo.aiAssistant.screenshotToAsk.startScreenCapture}+ setScreenCaptured={_setScreenCaptured}+ setStartScreenCapture={_setStartScreenCapture}>- <ScreenshotWrapper- startScreenCapture={this.props.demo.aiAssistant.screenshotToAsk.startScreenCapture}- setScreenCaptured={this._setScreenCaptured}- setStartScreenCapture={this._setStartScreenCapture}- >- <Banner- show={this.state.showBanner}- height={BannerHeight}- bgColor="#2E7CF6"- onClose={this._hideBanner}- >- <Announcement onDisable={this._disableBanner} />- </Banner>- <div style={CONTAINER_STYLE}>+ <Banner show={showBanner} height={BannerHeight} bgColor="#2E7CF6" onClose={hideBanner}>+ <Announcement onDisable={_disableBanner} />+ </Banner>+ <div style={CONTAINER_STYLE}>+ <div style={{flexGrow: 1}}><AutoSizer>{({height, width}) => (<KeplerGl@@ -487,7 +465,7 @@ class App extends Component {width={width}height={height}cloudProviders={CLOUD_PROVIDERS}- localeMessages={this.combinedMessages}+ localeMessages={combinedMessages}onExportToCloudSuccess={onExportFileSuccess}onLoadCloudMapSuccess={onLoadCloudMapSuccess}featureFlags={DEFAULT_FEATURE_FLAGS}@@ -495,12 +473,12 @@ class App extends Component {)}</AutoSizer></div>- </ScreenshotWrapper>- </GlobalStyle>- </ThemeProvider>- );- }-}+ </div>+ </ScreenshotWrapper>+ </GlobalStyle>+ </ThemeProvider>+ );+};const mapStateToProps = state => state;const dispatchToProps = dispatch => ({dispatch});diff --git a/examples/demo-app/src/store.js b/examples/demo-app/src/store.jsindex 0bff99757..30d07f29f 100644--- a/examples/demo-app/src/store.js+++ b/examples/demo-app/src/store.js@@ -5,7 +5,7 @@ import {combineReducers, createStore, applyMiddleware, compose} from 'redux';import {routerReducer, routerMiddleware} from 'react-router-redux';import {browserHistory} from 'react-router';import {enhanceReduxMiddleware} from '@kepler.gl/reducers';-import thunk from 'redux-thunk';+import {createLogger} from 'redux-logger';// eslint-disable-next-line no-unused-varsimport window from 'global/window';@@ -16,7 +16,16 @@ const reducers = combineReducers({routing: routerReducer});-export const middlewares = enhanceReduxMiddleware([thunk, routerMiddleware(browserHistory)]);+export const middlewares = enhanceReduxMiddleware([routerMiddleware(browserHistory)]);++// eslint-disable-next-line no-process-env+if (NODE_ENV === 'local') {+ // Redux logger+ const logger = createLogger({+ collapsed: () => true // Collapse all actions for more compact log+ });+ middlewares.push(logger);+}export const enhancers = [applyMiddleware(...middlewares)];diff --git a/examples/demo-app/yarn.lock b/examples/demo-app/yarn.lockindex da6bbad79..a0a520c27 100644--- a/examples/demo-app/yarn.lock+++ b/examples/demo-app/yarn.lock@@ -4625,6 +4625,13 @@ __metadata:languageName: nodelinkType: hard+"deep-diff@npm:^0.3.5":+ version: 0.3.8+ resolution: "deep-diff@npm:0.3.8"+ checksum: 10c0/dbb10937ccff21b1ad1ee5e64ad926643a7000cb9837bc2165bacfddf569788c78b8bfd74401c32121af3fb1cb1092b7447319d9f01900676473a1b840c08ade+ languageName: node+ linkType: hard+"deep-equal@npm:^1.0.1":version: 1.1.2resolution: "deep-equal@npm:1.1.2"@@ -7588,6 +7595,15 @@ __metadata:languageName: nodelinkType: hard+"redux-logger@npm:^3.0.6":+ version: 3.0.6+ resolution: "redux-logger@npm:3.0.6"+ dependencies:+ deep-diff: "npm:^0.3.5"+ checksum: 10c0/65eb71a1c72d9636368672a684bde62c746e64c19c8b92e3f00bdf5cf240ea1695eccb95a0fa3d5044f6a86cbf11fd35dc5150fd3351fa53c72721c336e9098f+ languageName: node+ linkType: hard+"redux-thunk@npm:^1.0.0":version: 1.0.3resolution: "redux-thunk@npm:1.0.3"@@ -7769,6 +7785,7 @@ __metadata:react-virtualized: "npm:^9.21.0"redux: "npm:^4.2.1"redux-actions: "npm:^2.2.1"+ redux-logger: "npm:^3.0.6"redux-thunk: "npm:^1.0.0"styled-components: "npm:^4.1.3"languageName: unknowndiff --git a/src/actions/src/action-types.ts b/src/actions/src/action-types.tsindex dfa8f5965..f9e0cf0dc 100644--- a/src/actions/src/action-types.ts+++ b/src/actions/src/action-types.ts@@ -43,6 +43,7 @@ export const ActionTypes = {ADD_DATA: `${ACTION_PREFIX}ADD_DATA`,ADD_FILTER: `${ACTION_PREFIX}ADD_FILTER`,CREATE_OR_UPDATE_FILTER: `${ACTION_PREFIX}CREATE_OR_UPDATE_FILTER`,+ CREATE_NEW_DATASET_SUCCESS: `${ACTION_PREFIX}CREATE_NEW_DATASET_SUCCESS`,ADD_LAYER: `${ACTION_PREFIX}ADD_LAYER`,APPLY_LAYER_CONFIG: `${ACTION_PREFIX}APPLY_LAYER_CONFIG`,DUPLICATE_LAYER: `${ACTION_PREFIX}DUPLICATE_LAYER`,@@ -190,6 +191,7 @@ export const ActionTypes = {};// eslint-disable-next-line prettier/prettier-const assignType = <T>(obj: T): { [K in keyof T]: `${typeof ACTION_PREFIX}${string & K}`; } => obj as any+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/actions/src/vis-state-actions.ts b/src/actions/src/vis-state-actions.tsindex 2775d91ec..73c2b7774 100644--- a/src/actions/src/vis-state-actions.ts+++ b/src/actions/src/vis-state-actions.ts@@ -23,6 +23,9 @@ import {EffectPropsPartial,SyncTimelineMode} from '@kepler.gl/types';+import {createAction} from '@reduxjs/toolkit';++import {KeplerTable} from '@kepler.gl/table';// TODO - import LoaderObject type from @loaders.gl/core when supported// TODO - import LoadOptions type from @loaders.gl/core when supported@@ -1596,6 +1599,21 @@ export function setTimeFilterSyncTimelineMode({};}+export type CreateNewDatasetSuccessPayload = {+ results: (PromiseFulfilledResult<KeplerTable<any>> | PromiseRejectedResult)[];+ addToMapOptions: AddDataToMapPayload['options'];+};++/**+ * Called when a new dataset is created successfully via async table methods+ * @param payload+ * @param payload.results - results of promises.allSettlted+ * @returns+ */+export const createNewDatasetSuccess = createAction<CreateNewDatasetSuccessPayload>(+ ActionTypes.CREATE_NEW_DATASET_SUCCESS+);+/*** This declaration is needed to group actions in docs*/diff --git a/src/components/src/common/field-token.tsx b/src/components/src/common/field-token.tsxindex 49567f05e..e66657eaf 100644--- a/src/components/src/common/field-token.tsx+++ b/src/components/src/common/field-token.tsx@@ -8,30 +8,27 @@ import {FIELD_TYPE_DISPLAY, FIELD_COLORS} from '@kepler.gl/constants';export type FieldTokenProps = {type: string;};+const FieldTag = styled.div`+ background-color: rgba(${props => props.color}, 0.2);+ border-radius: 2px;+ border: 1px solid rgb(${props => props.color});+ color: rgb(${props => props.color});+ display: inline-block;+ font-size: 10px;+ font-weight: 400;+ padding: 0 5px;+ text-align: center;+ width: ${props => props.theme.fieldTokenWidth}px;+ line-height: ${props => props.theme.fieldTokenHeight}px;+`;function FieldTokenFactory(fieldTypeDisplay: ReturnType<typeof getFieldTypes>,fieldColors: ReturnType<typeof getFieldColors>): React.FC<FieldTokenProps> {- const FieldTag = styled.div`- background-color: rgba(${props => props.color}, 0.2);- border-radius: 2px;- border: 1px solid rgb(${props => props.color});- color: rgb(${props => props.color});- display: inline-block;- font-size: 10px;- font-weight: 400;- padding: 0 5px;- text-align: center;- width: ${props => props.theme.fieldTokenWidth}px;- line-height: ${props => props.theme.fieldTokenHeight}px;- `;-const FieldToken = ({type}: FieldTokenProps) => (- <FieldTag- color={(fieldTypeDisplay[type] && fieldTypeDisplay[type].color) || fieldColors.default}- >- {fieldTypeDisplay[type].label}+ <FieldTag color={fieldTypeDisplay[type]?.color || fieldColors.default}>+ {fieldTypeDisplay[type]?.label}</FieldTag>);return FieldToken;diff --git a/src/components/src/common/item-selector/dropdown-select.tsx b/src/components/src/common/item-selector/dropdown-select.tsxindex 45eca3d13..c537830a7 100644--- a/src/components/src/common/item-selector/dropdown-select.tsx+++ b/src/components/src/common/item-selector/dropdown-select.tsx@@ -1,14 +1,14 @@// SPDX-License-Identifier: MIT// Copyright contributors to the kepler.gl project-import React from 'react';+import React, {ComponentType} from 'react';import styled from 'styled-components';import {notNullorUndefined} from '@kepler.gl/common-utils';-import {ComponentType} from 'react';+import {FormattedMessage} from '@kepler.gl/localization';+import {ArrowDown, Delete} from '../icons';import {ListItem} from './dropdown-list';-import {FormattedMessage} from '@kepler.gl/localization';export type ListItemProps<Option> = {value: Option;@@ -100,7 +100,6 @@ function DropdownSelect<Option>({displayOption,disabled,onClick,- error,inputTheme,size,value,diff --git a/src/components/src/container.tsx b/src/components/src/container.tsxindex f7d7f8823..f93af1146 100644--- a/src/components/src/container.tsx+++ b/src/components/src/container.tsx@@ -1,16 +1,15 @@// SPDX-License-Identifier: MIT// Copyright contributors to the kepler.gl project-import React, {Component, ComponentType, Dispatch} from 'react';-import {connect, ConnectedProps} from 'react-redux';-import memoize from 'lodash.memoize';+import React, {useRef, ComponentType, Dispatch, useEffect, useMemo} from 'react';+import {connect, ConnectedProps, useDispatch} from 'react-redux';+import {console as Console} from 'global/window';import {injector, provideRecipesToInjector, flattenDeps} from './injector';import KeplerGlFactory from './kepler-gl';-import {registerEntry, deleteEntry, renameEntry, forwardTo} from '@kepler.gl/actions';-import {notNullorUndefined} from '@kepler.gl/common-utils';import {KeplerGlState} from '@kepler.gl/reducers';+import {getApplicationConfig} from '@kepler.gl/utils';export const ERROR_MSG = {noState:@@ -69,26 +68,32 @@ export function ContainerFactory(* @public*/- class Container extends Component<PropsFromRedux> {- // default id and address if not provided- static defaultProps = {- id: 'map',- getState: state => state.keplerGl,- mint: true- };-- componentDidMount() {- const {- id,- mint,- mapboxApiAccessToken,- mapboxApiUrl,- mapStylesReplaceDefault,- initialUiState- } = this.props;+ function usePreviousId(value) {+ const ref = useRef();+ useEffect(() => {+ ref.current = value;+ });+ return ref.current;+ }+ const Container: React.FC<PropsFromRedux> = props => {+ const {+ // default id and address if not provided+ id = 'map',+ getState = state => state.keplerGl,+ mint = true,+ mapboxApiAccessToken,+ mapboxApiUrl,+ mapStylesReplaceDefault,+ initialUiState,+ state+ } = props;+ const prevId = usePreviousId(id);+ const dispatch = useDispatch();++ useEffect(() => {// add a new entry to reducer- this.props.dispatch(+ dispatch(registerEntry({id,mint,@@ -98,56 +103,53 @@ export function ContainerFactory(initialUiState}));- }- componentDidUpdate(prevProps) {- // check if id has changed, if true, copy state over- if (- notNullorUndefined(prevProps.id) &&- notNullorUndefined(this.props.id) &&- prevProps.id !== this.props.id- ) {- this.props.dispatch(renameEntry(prevProps.id, this.props.id));+ // initialize plugins+ if (getApplicationConfig().plugins.length) {+ getApplicationConfig().plugins.forEach(async plugin => {+ await plugin.init();+ });}- }-- componentWillUnmount() {- if (this.props.mint !== false) {- // delete entry in reducer- this.props.dispatch(deleteEntry(this.props.id));- }- }- getSelector = memoize((id, getState) => state => {- if (!getState(state)) {- // log error- Console.error(ERROR_MSG.noState);+ // cleanup+ return () => {+ if (mint !== false) {+ // delete entry in reducer+ dispatch(deleteEntry(id));+ }+ };+ }, [id]);- return null;- }- return getState(state)[id];- });- getDispatch = memoize((id, dispatch) => forwardTo(id, dispatch));-- render() {- const {id, getState, dispatch, state} = this.props;- const selector = this.getSelector(id, getState);-- if (!selector || !selector(state)) {- // instance state hasn't been mounted yet- return <div />;+ useEffect(() => {+ // check if id has changed, if true, copy state over+ if (prevId && id && prevId !== id) {+ dispatch(renameEntry(prevId, id));}-- return (- <KeplerGl- {...this.props}- id={id}- selector={selector}- dispatch={this.getDispatch(id, dispatch)}- />- );+ }, [dispatch, prevId, id]);++ const stateSelector = useMemo(+ () => keplerState => {+ if (!getState(keplerState)) {+ // log error+ Console.error(ERROR_MSG.noState);++ return null;+ }+ return getState(keplerState)[id];+ },+ [id, getState]+ );+ const forwardDispatch = useMemo(() => forwardTo(id, dispatch), [id, dispatch]);++ // const selector = getSelector(id, getState);++ if (!stateSelector || !stateSelector(state)) {+ // instance state hasn't been mounted yet+ return <div />;}- }++ return <KeplerGl {...props} id={id} selector={stateSelector} dispatch={forwardDispatch} />;+ };return connector(Container);}diff --git a/src/components/src/index.ts b/src/components/src/index.tsindex 3c347295f..2245370a6 100644--- a/src/components/src/index.ts+++ b/src/components/src/index.ts@@ -27,6 +27,7 @@ import {default as LayerColumnModeConfigFactory,ColumnModeConfigFactory} from './side-panel/layer-panel/layer-column-mode-config';+import DataTableFactory from './common/data-table';// Componentsexport {@@ -250,8 +251,8 @@ export {LegendRowFactory,ResetColorLabelFactory} from './common/color-legend';-export {default as DataTableFactory} from './common/data-table';export {default as CanvasHack} from './common/data-table/canvas';+export {renderedSize} from './common/data-table/cell-size';export {default as DataTableConfigFactory,NumberFormatConfig@@ -428,6 +429,7 @@ export {ChannelByValueSelectorFactory,ColorSelectorFactory,ColumnModeConfigFactory,+ DataTableFactory,FieldListItemFactoryFactory,InfoHelperFactory,LayerColorRangeSelectorFactory,@@ -462,6 +464,7 @@ export const ColorSelector = appInjector.get(ColorSelectorFactory);export const LayerColorSelector = appInjector.get(LayerColorSelectorFactory);export const LayerColorRangeSelector = appInjector.get(LayerColorRangeSelectorFactory);export const ArcLayerColorSelector = appInjector.get(ArcLayerColorSelectorFactory);+export const DataTable = appInjector.get(DataTableFactory);// hooksexport {CloudListProvider, useCloudListProvider} from './hooks/use-cloud-list-provider';diff --git a/src/components/src/map-container.tsx b/src/components/src/map-container.tsxindex c7011d65f..82e452cec 100644--- a/src/components/src/map-container.tsx+++ b/src/components/src/map-container.tsx@@ -4,7 +4,7 @@// librariesimport React, {Component, createRef, useMemo} from 'react';import styled, {withTheme} from 'styled-components';-import {Map, MapboxMap, MapRef} from 'react-map-gl';+import {Map, MapRef} from 'react-map-gl';import {PickInfo} from '@deck.gl/core/lib/deck';import DeckGL from '@deck.gl/react';import {createSelector, Selector} from 'reselect';@@ -364,7 +364,7 @@ export default function MapContainerFactory(}_deck: any = null;- _map: MapboxMap | null = null;+ _map: GetMapRef | null = null;_ref = createRef<HTMLDivElement>();_deckGLErrorsElapsed: {[id: string]: number} = {};diff --git a/src/layers/src/geojson-layer/geojson-layer.ts b/src/layers/src/geojson-layer/geojson-layer.tsindex b38ee500f..c7e6bbbb1 100644--- a/src/layers/src/geojson-layer/geojson-layer.ts+++ b/src/layers/src/geojson-layer/geojson-layer.ts@@ -49,7 +49,7 @@ import {VisConfigBoolean,Merge,RGBColor,- Field,+ ProtoDatasetField,LayerColumn} from '@kepler.gl/types';import {KeplerTable} from '@kepler.gl/table';@@ -206,7 +206,7 @@ const getTableModeFieldValue = (field, data) => {const geoFieldAccessor =({geojson}: GeoJsonLayerColumnsConfig) =>- (dc: DataContainerInterface): Field | null =>+ (dc: DataContainerInterface): ProtoDatasetField | null =>dc.getField ? dc.getField(geojson.fieldIdx) : null;// access feature properties from geojson sub layer@@ -377,6 +377,7 @@ export default class GeoJsonLayer extends Layer {.filter(f =>(f.type === 'geojson' || f.type === 'geoarrow') &&+ f.analyzerType &&SUPPORTED_ANALYZER_TYPES[f.analyzerType]).map(f => f.name);@@ -403,7 +404,7 @@ export default class GeoJsonLayer extends Layer {const defaultLayerConfig = super.getDefaultLayerConfig(props ?? {});return {...defaultLayerConfig,-+columnMode: props?.columnMode ?? DEFAULT_COLUMN_MODE,// add height visual channelheightField: null,diff --git a/src/layers/src/layer-utils.ts b/src/layers/src/layer-utils.tsindex a962904f7..2f3dbe71b 100644--- a/src/layers/src/layer-utils.ts+++ b/src/layers/src/layer-utils.ts@@ -5,7 +5,13 @@ import * as arrow from 'apache-arrow';import {Feature, BBox} from 'geojson';import {getGeoMetadata} from '@loaders.gl/gis';-import {Field, FieldPair, SupportedColumnMode, LayerColumn} from '@kepler.gl/types';+import {+ Field,+ ProtoDatasetField,+ FieldPair,+ SupportedColumnMode,+ LayerColumn+} from '@kepler.gl/types';import {DataContainerInterface, ArrowDataContainer} from '@kepler.gl/utils';import {getBinaryGeometriesFromArrow,@@ -150,7 +156,7 @@ export function getGeojsonLayerMetaFromArrow({}: {dataContainer: DataContainerInterface;geoColumn: arrow.Vector;- geoField: Field;+ geoField: ProtoDatasetField;chunkIndex?: number;}): GeojsonLayerMetaProps {const encoding = geoField?.metadata?.get('ARROW:extension:name');diff --git a/src/processors/package.json b/src/processors/package.jsonindex fbc77b2b5..ae460fcea 100644--- a/src/processors/package.json+++ b/src/processors/package.json@@ -34,6 +34,7 @@"@kepler.gl/common-utils": "3.0.0","@kepler.gl/constants": "3.0.0","@kepler.gl/schemas": "3.0.0",+ "@kepler.gl/table": "3.0.0","@kepler.gl/types": "3.0.0","@kepler.gl/utils": "3.0.0","@loaders.gl/arrow": "^4.3.2",diff --git a/src/processors/src/data-processor.ts b/src/processors/src/data-processor.tsindex f6f034528..6e5e34971 100644--- a/src/processors/src/data-processor.ts+++ b/src/processors/src/data-processor.ts@@ -248,7 +248,7 @@ export function processRowObject(rawData: unknown[]): ProcessorResult {const keys = Object.keys(rawData[0]); // [lat, lng, value]const rows = rawData.map(d => keys.map(key => d[key])); // [[31.27, 127.56, 3]]- // row object an still contain values like `Null` or `N/A`+ // row object can still contain values like `Null` or `N/A`cleanUpFalsyCsvValue(rows);return processCsvData(rows, keys);@@ -388,38 +388,39 @@ export function processArrowTable(arrowTable: ArrowTable): ProcessorResult | nulreturn processArrowBatches(arrowTable.data.batches);}-/**- * Parse arrow batches returned from parseInBatches()- *- * @param arrowTable the arrow table to parse- * @returns dataset containing `fields` and `rows` or null- */-export function processArrowBatches(arrowBatches: arrow.RecordBatch[]): ProcessorResult | null {- if (arrowBatches.length === 0) {- return null;- }- const arrowTable = new arrow.Table(arrowBatches);- const fields: Field[] = [];-- // parse fields- arrowTable.schema.fields.forEach((field: arrow.Field, index: number) => {- const isGeometryColumn = field.metadata.get('ARROW:extension:name')?.startsWith('geoarrow');- fields.push({+export function arrowSchemaToFields(schema: arrow.Schema): Field[] {+ return schema.fields.map((field: arrow.Field, index: number) => {+ const isGeoArrowColumn = field.metadata.get('ARROW:extension:name')?.startsWith('geoarrow');+ return {+ ...field,name: field.name,id: field.name,displayName: field.name,format: '',fieldIdx: index,- type: isGeometryColumn ? ALL_FIELD_TYPES.geoarrow : arrowDataTypeToFieldType(field.type),- analyzerType: isGeometryColumn+ type: isGeoArrowColumn ? ALL_FIELD_TYPES.geoarrow : arrowDataTypeToFieldType(field.type),+ analyzerType: isGeoArrowColumn? AnalyzerDATA_TYPES.GEOMETRY: arrowDataTypeToAnalyzerDataType(field.type),valueAccessor: (dc: any) => d => {return dc.valueAt(d.index, index);},metadata: field.metadata- });+ };});+}+/**+ * Parse arrow batches returned from parseInBatches()+ *+ * @param arrowTable the arrow table to parse+ * @returns dataset containing `fields` and `rows` or null+ */+export function processArrowBatches(arrowBatches: arrow.RecordBatch[]): ProcessorResult | null {+ if (arrowBatches.length === 0) {+ return null;+ }+ const arrowTable = new arrow.Table(arrowBatches);+ const fields = arrowSchemaToFields(arrowTable.schema);const cols = [...Array(arrowTable.numCols).keys()].map(i => arrowTable.getChildAt(i));diff --git a/src/processors/src/file-handler.ts b/src/processors/src/file-handler.tsindex 087d2793e..d137f4b30 100644--- a/src/processors/src/file-handler.ts+++ b/src/processors/src/file-handler.ts@@ -8,11 +8,16 @@ import {CSVLoader} from '@loaders.gl/csv';import {GeoArrowLoader} from '@loaders.gl/arrow';import {ParquetWasmLoader} from '@loaders.gl/parquet';import {Loader} from '@loaders.gl/loader-utils';-import {isPlainObject, generateHashIdFromString} from '@kepler.gl/utils';+import {+ isPlainObject,+ generateHashIdFromString,+ getApplicationConfig,+ getError+} from '@kepler.gl/utils';import {generateHashId} from '@kepler.gl/common-utils';import {DATASET_FORMATS} from '@kepler.gl/constants';-import {LoadedMap, ProcessorResult} from '@kepler.gl/types';-import {Feature, AddDataToMapPayload} from '@kepler.gl/types';+import {AddDataToMapPayload, Feature, LoadedMap, ProcessorResult} from '@kepler.gl/types';+import {KeplerTable} from '@kepler.gl/table';import {FeatureCollection} from '@turf/helpers';import {@@ -201,21 +206,29 @@ export async function readFileInBatches({return readBatch(progressIterator, file.name);}-export function processFileData({+export async function processFileData({content,fileCache}: {content: ProcessFileDataContent;fileCache: FileCacheItem[];}): Promise<FileCacheItem[]> {- return new Promise((resolve, reject) => {- const {fileName, data} = content;- let format: string | undefined;- let processor: ((data: any) => ProcessorResult | LoadedMap | null) | undefined;-- // generate unique id with length of 4 using fileName string- const id = generateHashIdFromString(fileName);-+ const {fileName, data} = content;+ let format: string | undefined;+ let processor: ((data: any) => ProcessorResult | LoadedMap | null) | undefined;+ console.log('Processing file', fileName);+ // generate unique id with length of 4 using fileName string+ const id = generateHashIdFromString(fileName);+ // decide on which table class to use based on application config+ const table = getApplicationConfig().table ?? KeplerTable;++ if (typeof table.getFileProcessor === 'function') {+ // use custom processors from table class+ const processorResult = table.getFileProcessor(data);+ format = processorResult.format;+ processor = processorResult.processor;+ } else {+ // use default processorsif (isArrowData(data)) {format = DATASET_FORMATS.arrow;processor = processArrowBatches;@@ -223,31 +236,37 @@ export function processFileData({format = DATASET_FORMATS.keplergl;processor = processKeplerglJSON;} else if (isRowObject(data)) {+ // csv file goes hereformat = DATASET_FORMATS.row;processor = processRowObject;} else if (isGeoJson(data)) {format = DATASET_FORMATS.geojson;processor = processGeojson;}-- if (format && processor) {- const result = processor(data);-- resolve([- ...fileCache,- {- data: result,- info: {- id,- label: content.fileName,- format- }- }- ]);+ }+ if (format && processor) {+ // eslint-disable-next-line no-useless-catch+ let result;+ try {+ result = await processor(data);+ } catch (error) {+ throw new Error(`Can not process uploaded file, ${getError(error as Error)}`);}- reject('Unknown File Format');- });+ return [+ ...fileCache,+ {+ data: result,+ info: {+ id,+ label: content.fileName,+ format+ }+ }+ ];+ } else {+ throw new Error('Can not process uploaded file, unknown file format');+ }}export function filesToDataPayload(fileCache: FileCacheItem[]): AddDataToMapPayload[] {diff --git a/src/reducers/src/combined-updaters.ts b/src/reducers/src/combined-updaters.tsindex 7ce54f149..0be3b1d0d 100644--- a/src/reducers/src/combined-updaters.ts+++ b/src/reducers/src/combined-updaters.ts@@ -143,7 +143,7 @@ export const addDataToMapUpdater = (...payload.options};- // check if progresive loading dataset by bataches, and update visState directly+ // check if progressive loading dataset by batches, and update visState directlyconst isProgressiveLoading =Array.isArray(datasets) &&datasets[0]?.info.format === 'arrow' &&@@ -189,6 +189,8 @@ export const addDataToMapUpdater = (),if_(Boolean(info), pick_('visState')(apply_<VisState, any>(setMapInfoUpdater, {info}))),+ // Note that fit bounds here won't be called in case datasets are created in Tasks.+ // A separate Task to update bounds is created once the datasets are ready.with_(({visState}) =>pick_('mapState')(apply_(diff --git a/src/reducers/src/merger-handler.ts b/src/reducers/src/merger-handler.tsindex db9bf092e..8d46c187c 100644--- a/src/reducers/src/merger-handler.ts+++ b/src/reducers/src/merger-handler.ts@@ -68,7 +68,7 @@ export function mergeStateFromMergers<State extends VisState>(// check if asyncTask was created (time consuming tasks)if (newTasks.length && merger.waitToFinish) {- // skip rest, the async merger will call applyMergerupdater() to continue+ // skip rest, the async merger will call applyMergerUpdater() to continuereturn {mergedState, allMerged: false};}}diff --git a/src/reducers/src/vis-state-updaters.ts b/src/reducers/src/vis-state-updaters.tsindex eda5f74cd..6298109a6 100644--- a/src/reducers/src/vis-state-updaters.ts+++ b/src/reducers/src/vis-state-updaters.ts@@ -11,16 +11,24 @@ import isEqual from 'lodash.isequal';import pick from 'lodash.pick';import uniq from 'lodash.uniq';import xor from 'lodash.xor';-import {disableStackCapturing, withTask} from 'react-palm/tasks';+import Task, {disableStackCapturing, withTask} from 'react-palm/tasks';// Tasks-import {DELAY_TASK, LOAD_FILE_TASK, PROCESS_FILE_DATA, UNWRAP_TASK} from '@kepler.gl/tasks';+import {+ DELAY_TASK,+ ACTION_TASK,+ LOAD_FILE_TASK,+ PROCESS_FILE_DATA,+ UNWRAP_TASK+} from '@kepler.gl/tasks';// Actionsimport {ActionTypes,+ CreateNewDatasetSuccessPayload,MapStateActions,ReceiveMapConfigPayload,VisStateActions,applyLayerConfig,+ createNewDatasetSuccess,layerConfigChange,layerTypeChange,layerVisConfigChange,@@ -30,7 +38,8 @@ import {loadFilesSuccess,loadNextFile,nextFileBatch,- processFileContent+ processFileContent,+ fitBounds as fitMapBounds} from '@kepler.gl/actions';// Utils@@ -62,7 +71,6 @@ import {isLayerAnimatable} from '@kepler.gl/utils';import {generateHashId, toArray} from '@kepler.gl/common-utils';-// Mergersimport {ANIMATION_WINDOW,@@ -136,6 +144,9 @@ import {TIME_INTERVALS_ORDERED} from '@kepler.gl/utils';import {createEffect} from '@kepler.gl/effects';+import {PayloadAction} from '@reduxjs/toolkit';++import {findMapBounds} from './data-utils';// react-palm// disable capture exception for react-palm call to withTask@@ -2122,7 +2133,7 @@ export const updateVisDataUpdater = (const {config, options} = action;// apply config if passed from action- // TODO: we don't handle asyn mergers here yet+ // TODO: we don't handle async mergers here yetconst previousState = config? receiveMapConfigUpdater(state, {payload: {config, options}@@ -2131,19 +2142,37 @@ export const updateVisDataUpdater = (const datasets = toArray(action.datasets);- const newDataEntries = datasets.reduce(- // @ts-expect-error Type '{}' is missing the following properties from type 'ProtoDataset': data, info- (accu, {info = {}, ...rest} = {}) => ({- ...accu,- ...(createNewDataEntry({info, ...rest}, state.datasets) || {})- }),- {}+ const allCreateDatasetsTasks = datasets.map(+ ({info = {}, ...rest}) => createNewDataEntry({info, ...rest}, state.datasets) || {});+ // call all Tasks+ const tasks = Task.allSettled(allCreateDatasetsTasks).map(results =>+ createNewDatasetSuccess({results, addToMapOptions: options})+ );++ return withTask(previousState, tasks);+};+export const createNewDatasetSuccessUpdater = (+ state: VisState,+ action: PayloadAction<CreateNewDatasetSuccessPayload>+): VisState => {+ // console.log('createNewDatasetSuccessUpdater', action.payload);+ const {results, addToMapOptions} = action.payload;+ const newDataEntries = results.reduce((accu, result) => {+ if (result.status === 'fulfilled') {+ const dataset = result.value;+ return {...accu, [dataset.id]: dataset};+ } else {+ // handle create dataset error+ console.error(result.reason);+ return accu;+ }+ }, {} as Datasets);// save new dataset entry to stateconst mergedState = {- ...previousState,- datasets: mergeDatasetsByOrder(previousState, newDataEntries)+ ...state,+ datasets: mergeDatasetsByOrder(state, newDataEntries)};// merge state with config to be merged@@ -2153,7 +2182,7 @@ export const updateVisDataUpdater = (const newDataIds = Object.keys(newDataEntries);const postMergerPayload = {newDataIds,- options,+ options: addToMapOptions,layerMergers};@@ -2258,12 +2287,26 @@ function postMergeUpdater(mergedState: VisState, postMergerPayload: PostMergerPaupdatedState = updateAnimationDomain(updatedState);// try to process layerMergers after dataset+datasetMergers- return layerMergers && layerMergers.length > 0- ? applyMergersUpdater(updatedState, {- mergers: layerMergers,- postMergerPayload: {...postMergerPayload, layerMergers: []}- })- : updatedState;+ updatedState =+ layerMergers && layerMergers.length > 0+ ? applyMergersUpdater(updatedState, {+ mergers: layerMergers,+ postMergerPayload: {...postMergerPayload, layerMergers: []}+ })+ : updatedState;++ // center the map once the dataset is created+ if (newLayers.length && (options || {}).centerMap) {+ const bounds = findMapBounds(newLayers);+ if (bounds) {+ const fitBoundsTask = ACTION_TASK().map(() => {+ return fitMapBounds(bounds);+ });+ updatedState = withTask(updatedState, fitBoundsTask);+ }+ }++ return updatedState;}/**diff --git a/src/reducers/src/vis-state.ts b/src/reducers/src/vis-state.tsindex e0e31dfd8..f6de096dd 100644--- a/src/reducers/src/vis-state.ts+++ b/src/reducers/src/vis-state.ts@@ -153,7 +153,9 @@ const actionHandler = {[ActionTypes.REMOVE_EFFECT]: visStateUpdaters.removeEffectUpdater,- [ActionTypes.UPDATE_EFFECT]: visStateUpdaters.updateEffectUpdater+ [ActionTypes.UPDATE_EFFECT]: visStateUpdaters.updateEffectUpdater,++ [ActionTypes.CREATE_NEW_DATASET_SUCCESS]: visStateUpdaters.createNewDatasetSuccessUpdater};// construct vis-state reducerdiff --git a/src/table/package.json b/src/table/package.jsonindex 960b4e788..4e50370b1 100644--- a/src/table/package.json+++ b/src/table/package.json@@ -40,7 +40,8 @@"d3-array": "^2.8.0","global": "^4.3.0","lodash.uniq": "^4.0.1",- "moment": "^2.10.6"+ "moment": "^2.10.6",+ "react-palm": "^3.3.8"},"nyc": {"sourceMap": false,diff --git a/src/table/src/dataset-utils.ts b/src/table/src/dataset-utils.tsindex 62f845a57..6108eb381 100644--- a/src/table/src/dataset-utils.ts+++ b/src/table/src/dataset-utils.ts@@ -4,8 +4,14 @@import uniq from 'lodash.uniq';import KeplerTable, {Datasets} from './kepler-table';import {ProtoDataset, RGBColor} from '@kepler.gl/types';+import Task from 'react-palm/tasks';-import {hexToRgb, validateInputData, datasetColorMaker} from '@kepler.gl/utils';+import {+ hexToRgb,+ validateInputData,+ datasetColorMaker,+ getApplicationConfig+} from '@kepler.gl/utils';// apply a color for each dataset// to use as label colors@@ -56,17 +62,31 @@ export function createNewDataEntry(// get keplerTable from datasetsconst keplerTable = datasets[info.id];// update the data in keplerTable- keplerTable.update(validatedData);- return {- [keplerTable.id]: keplerTable- };+ return UPDATE_TABLE_TASK({table: keplerTable, data: validatedData});}info = info || {};const color = info.color || getNewDatasetColor(datasets);- const keplerTable = new KeplerTable({info, data: validatedData, color, ...opts});- return {- [keplerTable.id]: keplerTable- };+ return CREATE_TABLE_TASK({+ info,+ color,+ opts,+ data: validatedData+ });}++async function updateTable({table, data}) {+ const updated = await table.update(data); // Assuming `table` has an `update` method+ return updated;+}++async function createTable({info, color, opts, data}) {+ const TableClass = getApplicationConfig().table ?? KeplerTable;+ const table = new TableClass({info, color, ...opts});+ await table.importData({data});++ return table;+}+const UPDATE_TABLE_TASK = Task.fromPromise(updateTable, 'UPDATE_TABLE_TASK');+const CREATE_TABLE_TASK = Task.fromPromise(createTable, 'CREATE_TABLE_TASK');diff --git a/src/table/src/kepler-table.ts b/src/table/src/kepler-table.tsindex d479dcf30..425000b9e 100644--- a/src/table/src/kepler-table.ts+++ b/src/table/src/kepler-table.ts@@ -111,7 +111,7 @@ export function maybeToDate(return dc.valueAt(d.index, fieldIdx);}-class KeplerTable {+class KeplerTable<F extends Field = Field> {readonly id: string;type?: string;@@ -119,15 +119,15 @@ class KeplerTable {color: RGBColor;// fields and data- fields: Field[];+ fields: F[] = [];dataContainer: DataContainerInterface;- allIndexes: number[];- filteredIndex: number[];+ allIndexes: number[] = [];+ filteredIndex: number[] = [];filteredIdxCPU?: number[];- filteredIndexForDomain: number[];- fieldPairs: FieldPair[];+ filteredIndexForDomain: number[] = [];+ fieldPairs: FieldPair[] = [];gpuFilter: GpuFilter;filterRecord?: FilterRecord;filterRecordCPU?: FilterRecord;@@ -149,14 +149,12 @@ class KeplerTable {constructor({info,- data,color,metadata,supportedFilterTypes = null,disableDataOperation = false}: {info?: ProtoDataset['info'];- data: ProtoDataset['data'];color: RGBColor;metadata?: ProtoDataset['metadata'];supportedFilterTypes?: ProtoDataset['supportedFilterTypes'];@@ -168,32 +166,13 @@ class KeplerTable {// return this;// }- const dataContainerData = data.cols ? data.cols : data.rows;- const inputDataFormat = data.cols ? DataForm.COLS_ARRAY : DataForm.ROWS_ARRAY;-- const dataContainer = createDataContainer(dataContainerData, {- // @ts-expect-error ProtoDataset field missing property fieldIdx, valueAccessor- fields: data.fields,- inputDataFormat- });-const datasetInfo = {id: generateHashId(4),label: 'new dataset',type: '',...info};- const dataId = datasetInfo.id;- // @ts-expect-error- const fields: Field[] = data.fields.map((f, i) => ({- ...f,- fieldIdx: i,- id: f.name,- displayName: f.displayName || f.name,- valueAccessor: getFieldValueAccessor(f, i, dataContainer)- }));- const allIndexes = dataContainer.getPlainIndex();const defaultMetadata = {id: datasetInfo.id,// @ts-ignore@@ -210,15 +189,41 @@ class KeplerTable {...metadata};+ this.supportedFilterTypes = supportedFilterTypes;+ this.disableDataOperation = disableDataOperation;++ this.dataContainer = createDataContainer([]);+ this.gpuFilter = getGpuFilterProps([], this.id, [], undefined);+ }++ importData({data}: {data: ProtoDataset['data']}) {+ const dataContainerData = data.cols ? data.cols : data.rows;+ const inputDataFormat = data.cols ? DataForm.COLS_ARRAY : DataForm.ROWS_ARRAY;++ const dataContainer = createDataContainer(dataContainerData, {+ fields: data.fields,+ inputDataFormat+ });++ const fields: Field[] = data.fields.map((f, i) => ({+ ...f,+ fieldIdx: i,+ id: f.name,+ displayName: f.displayName || f.name,+ analyzerType: f.analyzerType || ALL_FIELD_TYPES.string,+ format: f.format || '',+ valueAccessor: getFieldValueAccessor(f, i, dataContainer)+ }));++ const allIndexes = dataContainer.getPlainIndex();this.dataContainer = dataContainer;this.allIndexes = allIndexes;this.filteredIndex = allIndexes;this.filteredIndexForDomain = allIndexes;this.fieldPairs = findPointFieldPairs(fields);+ // @ts-expect-error Make sure that fields satisfies F extends Fieldthis.fields = fields;- this.gpuFilter = getGpuFilterProps([], dataId, fields, undefined);- this.supportedFilterTypes = supportedFilterTypes;- this.disableDataOperation = disableDataOperation;+ this.gpuFilter = getGpuFilterProps([], this.id, fields, undefined);}/**@@ -241,7 +246,7 @@ class KeplerTable {* Get field* @param columnName*/- getColumnField(columnName: string): Field | undefined {+ getColumnField(columnName: string): F | undefined {const field = this.fields.find(fd => fd[FID_KEY] === columnName);this._assetField(columnName, field);return field;@@ -280,7 +285,7 @@ class KeplerTable {* @param fieldIdx* @param newField*/- updateColumnField(fieldIdx: number, newField: Field): void {+ updateColumnField(fieldIdx: number, newField: F): void {this.fields = Object.assign([...this.fields], {[fieldIdx]: newField});}@@ -296,7 +301,7 @@ class KeplerTable {* Save filterProps to field and retrieve it* @param columnName*/- getColumnFilterProps(columnName: string): Field['filterProps'] | null | undefined {+ getColumnFilterProps(columnName: string): F['filterProps'] | null | undefined {const fieldIdx = this.getColumnFieldIdx(columnName);if (fieldIdx < 0) {return null;@@ -328,7 +333,7 @@ class KeplerTable {* @param layers* @param opt*/- filterTable(filters: Filter[], layers: Layer[], opt?: FilterDatasetOpt): KeplerTable {+ filterTable(filters: Filter[], layers: Layer[], opt?: FilterDatasetOpt): KeplerTable<Field> {const {dataContainer, id: dataId, filterRecord: oldFilterRecord, fields} = this;// if there is no filters@@ -384,7 +389,7 @@ class KeplerTable {* @param filters* @param layers*/- filterTableCPU(filters: Filter[], layers: Layer[]): KeplerTable {+ filterTableCPU(filters: Filter[], layers: Layer[]): KeplerTable<Field> {const opt = {cpuOnly: true,ignoreDomain: true@@ -422,7 +427,7 @@ class KeplerTable {* Calculate field domain based on field type and data* for Filter*/- getColumnFilterDomain(field: Field): FieldDomain {+ getColumnFilterDomain(field: F): FieldDomain {const {dataContainer} = this;const {valueAccessor} = field;@@ -453,10 +458,7 @@ class KeplerTable {/*** Get the domain of this column based on scale type*/- getColumnLayerDomain(- field: Field,- scaleType: string- ): number[] | string[] | [number, number] | null {+ getColumnLayerDomain(field: F, scaleType: string): number[] | string[] | [number, number] | null {const {dataContainer, filteredIndexForDomain} = this;if (!SCALE_TYPES[scaleType]) {@@ -515,7 +517,7 @@ class KeplerTable {}export type Datasets = {- [key: string]: KeplerTable;+ [key: string]: KeplerTable<Field>;};// HELPER FUNCTIONS (MAINLY EXPORTED FOR TEST...)@@ -600,10 +602,10 @@ export function findPointFieldPairs(fields: Field[]): FieldPair[] {* @type*/export function sortDatasetByColumn(- dataset: KeplerTable,+ dataset: KeplerTable<Field>,column: string,mode?: string-): KeplerTable {+): KeplerTable<Field> {const {allIndexes, fields, dataContainer} = dataset;const fieldIndex = fields.findIndex(f => f.name === column);if (fieldIndex < 0) {@@ -639,7 +641,7 @@ export function sortDatasetByColumn(return dataset;}-export function pinTableColumns(dataset: KeplerTable, column: string): KeplerTable {+export function pinTableColumns(dataset: KeplerTable<Field>, column: string): KeplerTable<Field> {const field = dataset.getColumnField(column);if (!field) {return dataset;@@ -657,7 +659,7 @@ export function pinTableColumns(dataset: KeplerTable, column: string): KeplerTabreturn copyTableAndUpdate(dataset, {pinnedColumns});}-export function copyTable(original: KeplerTable): KeplerTable {+export function copyTable(original: KeplerTable<Field>): KeplerTable<Field> {return Object.assign(Object.create(Object.getPrototypeOf(original)), original);}@@ -666,9 +668,9 @@ export function copyTable(original: KeplerTable): KeplerTable {* @returns*/export function copyTableAndUpdate(- original: KeplerTable,- options: Partial<KeplerTable> = {}-): KeplerTable {+ original: KeplerTable<Field>,+ options: Partial<KeplerTable<Field>> = {}+): KeplerTable<Field> {return Object.entries(options).reduce((acc, entry) => {acc[entry[0]] = entry[1];return acc;diff --git a/src/types/actions.d.ts b/src/types/actions.d.tsindex add827c2a..5d734dfd4 100644--- a/src/types/actions.d.ts+++ b/src/types/actions.d.ts@@ -31,6 +31,15 @@ export type ExportFileToCloudPayload = {/*** Input dataset parsed to addDataToMap*/+export type ProtoDatasetField = {+ name: string;+ type: string;+ format?: string;+ displayName?: string;+ analyzerType?: string;+ id?: string;+ metadata?: Record<string, any>;+};export type ProtoDataset = {info: {id?: string;@@ -41,14 +50,7 @@ export type ProtoDataset = {hidden?: boolean;};data: {- fields: {- name: string;- type?: string;- format?: string;- displayName?: string;- analyzerType?: string;- id?: string;- }[];+ fields: ProtoDatasetField[];rows: any[][];cols?: any[];};diff --git a/src/types/layers.d.ts b/src/types/layers.d.tsindex 266bf3357..15da495ce 100644--- a/src/types/layers.d.ts+++ b/src/types/layers.d.ts@@ -98,16 +98,16 @@ export type LayerWeightConfig = {};export type Field = {- analyzerType: string;- id?: string;name: string;displayName: string;- format: string;type: string;fieldIdx: number;valueAccessor(v: {index: number}): any;+ analyzerType?: string;+ id?: string;+ format: string;filterProps?: FilterProps;- metadata?: any;+ metadata?: Record<string, any>;displayFormat?: string;};diff --git a/src/utils/src/application-config.ts b/src/utils/src/application-config.tsindex 359152a51..f4640af57 100644--- a/src/utils/src/application-config.ts+++ b/src/utils/src/application-config.ts@@ -23,6 +23,10 @@ export type KeplerApplicationConfig<Map> = {mapLibCssClass?: string;mapLibName?: string;mapLibUrl?: string;+ plugins?: any[];+ // KeplerTable alternative+ // TODO improve typing by exporting KeplerTable interface to @kepler.gl/types+ table?: any;};const DEFAULT_APPLICATION_CONFIG: Required<KeplerApplicationConfig<mapboxgl.Map>> = {@@ -37,7 +41,11 @@ const DEFAULT_APPLICATION_CONFIG: Required<KeplerApplicationConfig<mapboxgl.Map>getMap: (mapRef: MapRef): mapboxgl.Map => mapRef?.getMap(),mapLibCssClass: 'maplibregl',mapLibName: 'MapLibre',- mapLibUrl: 'https://www.maplibre.org/'+ mapLibUrl: 'https://www.maplibre.org/',+ plugins: [],+ // The default table class is KeplerTable.+ // TODO include KeplerTable here when the circular dependency with @kepler.gl/table and @kepler.gl/utils are resolved.+ table: null};const applicationConfig: Required<KeplerApplicationConfig<mapboxgl.Map>> =diff --git a/src/utils/src/arrow-data-container.ts b/src/utils/src/arrow-data-container.tsindex cabefa469..d31034748 100644--- a/src/utils/src/arrow-data-container.ts+++ b/src/utils/src/arrow-data-container.ts@@ -4,7 +4,7 @@import * as arrow from 'apache-arrow';import {console as globalConsole} from 'global/window';import {DATA_TYPES as AnalyzerDATA_TYPES} from 'type-analyzer';-import {Field} from '@kepler.gl/types';+import {ProtoDatasetField} from '@kepler.gl/types';import {ALL_FIELD_TYPES} from '@kepler.gl/constants';import {DataRow, SharedRowOptions} from './data-row';@@ -12,7 +12,7 @@ import {DataContainerInterface, RangeOptions} from './data-container-interface';type ArrowDataContainerInput = {cols: arrow.Vector[];- fields?: Field[];+ fields?: ProtoDatasetField[];};/**@@ -44,7 +44,7 @@ export class ArrowDataContainer implements DataContainerInterface {_cols: arrow.Vector[];_numColumns: number;_numRows: number;- _fields: Field[];+ _fields: ProtoDatasetField[];_numChunks: number;// cache column data to make valueAt() faster// _colData: any[][];@@ -144,7 +144,7 @@ export class ArrowDataContainer implements DataContainerInterface {return this._cols[columnIndex];}- getField(columnIndex: number): Field {+ getField(columnIndex: number): ProtoDatasetField {return this._fields[columnIndex];}diff --git a/src/utils/src/data-container-interface.ts b/src/utils/src/data-container-interface.tsindex 350a2f2e4..37e669d1d 100644--- a/src/utils/src/data-container-interface.ts+++ b/src/utils/src/data-container-interface.ts@@ -1,7 +1,7 @@// SPDX-License-Identifier: MIT// Copyright contributors to the kepler.gl project-import {Field} from '@kepler.gl/types';+import {ProtoDatasetField} from '@kepler.gl/types';import {DataRow, SharedRowOptions} from './data-row';/**@@ -82,7 +82,7 @@ export interface DataContainerInterface {* @param columnIndex Column index.* @returns The field object at the specified index.*/- getField?(columnIndex: number): Field;+ getField?(columnIndex: number): ProtoDatasetField;/*** Returns the underlying data object.diff --git a/src/utils/src/data-container-utils.ts b/src/utils/src/data-container-utils.tsindex 05a5fccea..46f01af1b 100644--- a/src/utils/src/data-container-utils.ts+++ b/src/utils/src/data-container-utils.ts@@ -6,11 +6,11 @@ import {RowDataContainer} from './row-data-container';import {IndexedDataContainer} from './indexed-data-container';import {DataContainerInterface} from './data-container-interface';-import {Field} from '@kepler.gl/types';+import {ProtoDatasetField} from '@kepler.gl/types';export type DataContainerOptions = {inputDataFormat?: string; // one of DataForm- fields?: Field[];+ fields?: ProtoDatasetField[];};export const DataForm = {diff --git a/src/utils/src/dataset-utils.ts b/src/utils/src/dataset-utils.tsindex 5e56b412f..ba7417def 100644--- a/src/utils/src/dataset-utils.ts+++ b/src/utils/src/dataset-utils.ts@@ -246,7 +246,7 @@ export function validateInputData(data: ProtoDataset['data']): ProcessorResult {const allValid = fields.every((f, i) => {if (!isPlainObject(f)) {assert(`fields needs to be an array of object, but find ${typeof f}`);- fields[i] = {name: `column_${i}`};+ fields[i] = {name: `column_${i}`, type: ALL_FIELD_TYPES.string};}if (!f.name) {diff --git a/src/utils/src/row-data-container.ts b/src/utils/src/row-data-container.tsindex 4284ea006..50222a317 100644--- a/src/utils/src/row-data-container.ts+++ b/src/utils/src/row-data-container.ts@@ -2,12 +2,12 @@// Copyright contributors to the kepler.gl projectimport {DataRow, SharedRowOptions} from './data-row';-import {Field} from '@kepler.gl/types';+import {ProtoDatasetField} from '@kepler.gl/types';import {DataContainerInterface, RangeOptions} from './data-container-interface';type RowDataContainerInput = {rows: any[][];- fields?: Field[];+ fields?: ProtoDatasetField[];};/**diff --git a/test/browser/components/container-test.js b/test/browser/components/container-test.jsindex 3fe784d8a..720c20949 100644--- a/test/browser/components/container-test.js+++ b/test/browser/components/container-test.js@@ -244,13 +244,15 @@ test('Components -> Container -> Mount then rename', t => {// mount with mint: falset.doesNotThrow(() => {wrapper = mount(- <Container- getState={s => s.smoothie}- id={testId.id}- mapboxApiAccessToken="hello.world"- dispatch={dispatch}- store={store}- />+ <Provider store={store}>+ <Container+ getState={s => s.smoothie}+ id={testId.id}+ mapboxApiAccessToken="hello.world"+ dispatch={dispatch}+ store={store}+ />+ </Provider>);}, 'Should not throw error when mount');@@ -283,14 +285,24 @@ test('Components -> Container -> Mount then rename', t => {};t.deepEqual(nextState, expectedState, 'should register milkshake to root reducer');- wrapper.setProps({id: 'milkshake-2'});- // actions = store.getActions();+ wrapper.setProps({+ children: (+ <Container+ getState={s => s.smoothie}+ id={'milkshake-2'}+ mapboxApiAccessToken="hello.world"+ dispatch={dispatch}+ store={store}+ />+ )+ });+const expectedActions1 = {type: '@@kepler.gl/RENAME_ENTRY',payload: {oldId: 'milkshake', newId: 'milkshake-2'}};- t.deepEqual(store.getActions().pop(), expectedActions1, 'should rename entry');+ t.deepEqual(store.getActions().pop(), expectedActions1, 'should rename entry ');const nextState1 = appReducer(nextState, expectedActions1);const expectedState1 = {diff --git a/test/browser/components/injector-test.js b/test/browser/components/injector-test.jsindex 7cbf4dc9c..0873e9c4d 100644--- a/test/browser/components/injector-test.js+++ b/test/browser/components/injector-test.js@@ -235,7 +235,7 @@ test('Components -> injector -> withState.lens', t => {});test('Components -> injector -> withState.mapStateToProps', t => {- const CustomHeader = () => <div clssName="my-test-header-3">smoothie</div>;+ const CustomHeader = () => <div className="my-test-header-3">smoothie</div>;const myCustomHeaderFactory = () =>withState([], state => ({ids: Object.keys(state)}))(CustomHeader);diff --git a/test/browser/components/side-panel/channel-by-value-selctor-test.js b/test/browser/components/side-panel/channel-by-value-selctor-test.jsindex c3472ce12..b7797dcfb 100644--- a/test/browser/components/side-panel/channel-by-value-selctor-test.js+++ b/test/browser/components/side-panel/channel-by-value-selctor-test.js@@ -200,7 +200,7 @@ test('Components -> ChannelByValueSelector -> ColorScaleSelector -> disabled', tt.end();});-test.only('Components -> ChannelByValueSelector -> ColorScaleSelector -> ColorBreakDisplay', t => {+test('Components -> ChannelByValueSelector -> ColorScaleSelector -> ColorBreakDisplay', t => {const InitialState = cloneDeep(StateWFilesFiltersLayerColor);const {layers, datasets} = InitialState.visState;const pointLayer = layers[0];diff --git a/test/browser/components/side-panel/layer-list.spec.js b/test/browser/components/side-panel/layer-list.spec.jsindex b06fe30da..aaf310c29 100644--- a/test/browser/components/side-panel/layer-list.spec.js+++ b/test/browser/components/side-panel/layer-list.spec.js@@ -20,19 +20,11 @@ import {keplerGlReducerCore as keplerGlReducer} from '@kepler.gl/reducers';import {renderWithTheme} from '../../../helpers/component-jest-utils';import testLayerData from '../../../fixtures/test-layer-data';import {dataId as csvDataId} from '../../../fixtures/test-csv-data';+import {applyActions} from '../../../helpers/mock-state';// TODO: need to be deleted and imported from raw-statesconst InitialState = keplerGlReducer(undefined, keplerGlInit({}));-function applyActions(reducer, initialState, actions) {- const actionQ = Array.isArray(actions) ? actions : [actions];-- return actionQ.reduce(- (updatedState, {action, payload}) => reducer(updatedState, action(...payload)),- initialState- );-}-function mockStateWithMultipleH3Layers() {const initialState = cloneDeep(InitialState);const prepareState = applyActions(keplerGlReducer, initialState, [diff --git a/test/browser/layer-tests/geojson-layer-specs.js b/test/browser/layer-tests/geojson-layer-specs.jsindex 771fdb95e..80f9e01fd 100644--- a/test/browser/layer-tests/geojson-layer-specs.js+++ b/test/browser/layer-tests/geojson-layer-specs.js@@ -3,7 +3,7 @@import test from 'tape';import {defaultElevation, defaultLineWidth, defaultRadius, KeplerGlLayers} from '@kepler.gl/layers';-import {copyTableAndUpdate, createNewDataEntry} from '@kepler.gl/table';+import {copyTableAndUpdate} from '@kepler.gl/table';const {GeojsonLayer} = KeplerGlLayers;@@ -18,6 +18,7 @@ import {geoFilterDomain0,geojsonFilterDomain0} from 'test/helpers/layer-utils';+import {createNewDataEntryMock} from 'test/helpers/table-utils';import {updatedGeoJsonLayer,geoJsonWithStyle,@@ -48,7 +49,7 @@ test('#GeojsonLayer -> constructor', t => {t.end();});-test('#GeojsonLayer -> formatLayerData', t => {+test('#GeojsonLayer -> formatLayerData', async t => {const filteredIndex = [0, 2, 4];const TEST_CASES = [@@ -400,7 +401,7 @@ test('#GeojsonLayer -> formatLayerData', t => {color: [5, 5, 5]}},- datasets: createNewDataEntry({+ datasets: await createNewDataEntryMock({info: {id: dataId},data: processGeojson(geoJsonWithStyle)}),diff --git a/test/browser/layer-tests/point-layer-specs.js b/test/browser/layer-tests/point-layer-specs.jsindex 58598f88d..ab23683f8 100644--- a/test/browser/layer-tests/point-layer-specs.js+++ b/test/browser/layer-tests/point-layer-specs.js@@ -19,7 +19,8 @@ import {processGeojson} from '@kepler.gl/processors';import {geoJsonWithStyle, geojsonData} from 'test/fixtures/geojson';import testArcData, {pointFromNeighbor} from 'test/fixtures/test-arc-data';import {StateWArcNeighbors} from 'test/helpers/mock-state';-import {copyTableAndUpdate, createNewDataEntry} from '@kepler.gl/table';+import {createNewDataEntryMock} from 'test/helpers/table-utils';+import {copyTableAndUpdate} from '@kepler.gl/table';import {KeplerGlLayers} from '@kepler.gl/layers';import {INITIAL_MAP_STATE} from '@kepler.gl/reducers';import {DEFAULT_TEXT_LABEL, PROJECTED_PIXEL_SIZE_MULTIPLIER} from '@kepler.gl/constants';@@ -732,7 +733,7 @@ test('#PointLayer -> updateLayer', t => {t.end();});-test('#PointLayer -> formatLayerData -> Geojson column mode', t => {+test('#PointLayer -> formatLayerData -> Geojson column mode', async t => {// create a mockup GeoJson dataset with Point and MultiPoint geometryconst geoJsonWithMultiPoint = cloneDeep(geoJsonWithStyle);geoJsonWithMultiPoint.features.push({@@ -809,7 +810,7 @@ test('#PointLayer -> formatLayerData -> Geojson column mode', t => {}}},- datasets: createNewDataEntry({+ datasets: await createNewDataEntryMock({info: {id: dataId},data: geojsonPointDataset}),@@ -873,7 +874,7 @@ test('#PointLayer -> formatLayerData -> Geojson column mode', t => {}}},- datasets: createNewDataEntry({+ datasets: await createNewDataEntryMock({info: {id: dataId},data: geojsonPolygonDataset}),@@ -918,7 +919,7 @@ test('#PointLayer -> formatLayerData -> Geojson column mode', t => {}}},- datasets: createNewDataEntry({+ datasets: await createNewDataEntryMock({info: {id: dataId},data: geojsonMultiPolygonDataset}),@@ -988,7 +989,7 @@ test('#PointLayer -> formatLayerData -> Geojson column mode', t => {}}},- datasets: createNewDataEntry({+ datasets: await createNewDataEntryMock({info: {id: dataId},data: geojsonGeometryCollectionDataset}),@@ -1062,7 +1063,7 @@ test('#PointLayer -> formatLayerData -> Geojson column mode', t => {}}},- datasets: createNewDataEntry({+ datasets: await createNewDataEntryMock({info: {id: dataId},data: geojsonPointWithNullDataset}),diff --git a/test/fixtures/synced-filter-with-trip-layer.js b/test/fixtures/synced-filter-with-trip-layer.jsindex 730ba55ec..9db9ded36 100644--- a/test/fixtures/synced-filter-with-trip-layer.js+++ b/test/fixtures/synced-filter-with-trip-layer.js@@ -5,7 +5,7 @@ import {processKeplerglJSON} from '@kepler.gl/processors';import CloneDeep from 'lodash.clonedeep';import {keplerGlReducerCore as coreReducer} from '@kepler.gl/reducers';import {addDataToMap} from '@kepler.gl/actions';-import {InitialState} from '../helpers/mock-state';+import {InitialState, applyActions} from '../helpers/mock-state';export const syncedFilterWithTripLayerMap = {datasets: [@@ -391,7 +391,13 @@ export const syncedFilterWithTripLayerMap = {export const mockStateWithSyncedFilterAndTripLayer = () => {const initialState = CloneDeep(InitialState);const result = processKeplerglJSON(syncedFilterWithTripLayerMap);- const newState = coreReducer(initialState, addDataToMap(result));++ const newState = applyActions(coreReducer, initialState, [+ {+ action: addDataToMap,+ payload: [result]+ }+ ]);return newState;};diff --git a/test/helpers/layer-utils.js b/test/helpers/layer-utils.jsindex 6e26f2249..737481def 100644--- a/test/helpers/layer-utils.js+++ b/test/helpers/layer-utils.js@@ -291,24 +291,27 @@ export function testUpdateLayer(t, {layerConfig, shouldUpdate}) {value: [3, 8.33]};- const stateWithLayer = keplerGlReducerCore(- initialState,- addDataToMap({- datasets: {- info: {id: dataId},- data: processCsvData(testLayerData)- },+ const addDataToMapPayload = {+ datasets: {+ info: {id: dataId},+ data: processCsvData(testLayerData)+ },+ config: {+ version: 'v1',config: {- version: 'v1',- config: {- visState: {- layers: [layerConfig],- filters: [filter0, filter1]- }+ visState: {+ layers: [layerConfig],+ filters: [filter0, filter1]}}- })- );+ }+ };+ const stateWithLayer = applyActions(keplerGlReducerCore, initialState, [+ {+ action: addDataToMap,+ payload: [addDataToMapPayload]+ }+ ]);const layer = stateWithLayer.visState.layers[0];t.ok(layer, 'should create layer');diff --git a/test/helpers/mock-state.js b/test/helpers/mock-state.jsindex 04773661f..c3121b754 100644--- a/test/helpers/mock-state.js+++ b/test/helpers/mock-state.js@@ -3,7 +3,7 @@import test from 'tape-catch';import cloneDeep from 'lodash.clonedeep';-import {drainTasksForTesting} from 'react-palm/tasks';+import {drainTasksForTesting, succeedTaskWithValues} from 'react-palm/tasks';import {getInitialInputStyle,@@ -29,6 +29,7 @@ import {UIStateActions,ProviderActions} from '@kepler.gl/actions';+import {KeplerTable} from '@kepler.gl/table';// fixturesimport {@@ -80,18 +81,69 @@ export const geojsonInfo = {params: {file: null}};+/**+ * Applies actions one by one using the reducer.+ * After each action drain Tasks and automarically resolve tasks+ * of type CREATE_TABLE_TASK in order to create datasets.+ * @param {Reducer} reducer A reducer to use.+ * @param {State} initialState Initial state.+ * @param {Action | Action[]}actions An array of actions.+ * @returns+ */export function applyActions(reducer, initialState, actions) {const actionQ = Array.isArray(actions) ? actions : [actions];- return actionQ.reduce(- (updatedState, {action, payload}) => reducer(updatedState, action(...payload)),- initialState- );+ // remove any existing tasks before actions+ drainTasksForTesting();++ let updatedState = actionQ.reduce((updatedState, {action, payload}) => {+ let newState = reducer(updatedState, action(...payload));+ const tasks = drainTasksForTesting();+ newState = applyCreateTableTasks(tasks, reducer, newState);+ return newState;+ }, initialState);++ return updatedState;}// TODO: need to be deleted and imported from raw-statesexport const InitialState = keplerGlReducer(undefined, {});+/**+ * Mock instant sync result of createNewDataEntry.+ */+const mockCreateNewDataEntry = ({info, color, opts, data}) => {+ const table = new KeplerTable({info, color, ...opts});+ table.importData({data});+ return table;+};++/**+ * Execute tasks and mock CREATE_TABLE_TASK with success.+ * @param {Task[]} tasks+ * @param {Reducer} reducer+ * @param {VisState} initialState+ * @returns+ */+export const applyCreateTableTasks = (tasks, reducer, initialState) => {+ return tasks.reduce((updatedState, task) => {+ if (!task.label.includes('CREATE_TABLE_TASK')) return updatedState;+ const tables = task.payload.map(payload => mockCreateNewDataEntry(payload));+ return reducer(updatedState, succeedTaskWithValues(task, tables));+ }, initialState);+};++/**+ * Execute existing tasts and mock CREATE_TABLE_TASK with success.+ * @param {VisStateReducer} reducer+ * @param {VisState} initialState+ * @returns+ */+export function applyExistingDatasetTasks(reducer, initialState) {+ const tasks = drainTasksForTesting();+ return applyCreateTableTasks(tasks, reducer, initialState);+}+/*** Mock app state with uploaded geojson and csv file* @returns {Immutable} appState@@ -114,8 +166,7 @@ export function mockStateWithFileUpload() {payload: [[{info: geojsonInfo, data: {fields: geojsonFields, rows: geojsonRows}}]]}]);- // cleanup tasks created during loadMapStyles- drainTasksForTesting();+// replace layer id and color with controlled value for testingupdatedState.visState.layers.forEach((l, i) => {const oldLayerId = l.id;@@ -205,9 +256,6 @@ function mockStateWithLayerCustomColorBreaksLegends() {}]);- // cleanup tasks created during loadMapStyles- drainTasksForTesting();-test(t => {t.equal(updatedState.visState.layers.length, 1, 'should load 1 layer');t.deepEqual(@@ -580,19 +628,22 @@ export function mockStateWithMultipleH3Layers() {function mockStateWithTripData() {const initialState = cloneDeep(InitialState);- return keplerGlReducer(- initialState,- addDataToMap({- datasets: {- info: {- label: 'Sample Trips',- id: tripDataId- },- data: {fields: tripFields, rows: tripRows}+ const addDataPayload = {+ datasets: {+ info: {+ label: 'Sample Trips',+ id: tripDataId},- config: tripConfig- })- );+ data: {fields: tripFields, rows: tripRows}+ },+ config: tripConfig+ };+ return applyActions(keplerGlReducer, initialState, [+ {+ action: addDataToMap,+ payload: [addDataPayload]+ }+ ]);}export function mockStateWithLayerDimensions(state) {diff --git a/test/helpers/table-utils.js b/test/helpers/table-utils.jsnew file mode 100644index 000000000..3c97a17d4--- /dev/null+++ b/test/helpers/table-utils.js@@ -0,0 +1,26 @@+// SPDX-License-Identifier: MIT+// Copyright contributors to the kepler.gl project++import {createNewDataEntry} from '@kepler.gl/table';++/**+ * A test function to execute the task from createNewDataEntry with await syntax.+ * @param {ProtoDataset} props+ * @returns {Datasets}+ */+export const createNewDataEntryMock = async props => {+ const newDataEntry = createNewDataEntry(props);+ let table = null;+ await newDataEntry.run(+ async (effectorPrime, success, error) => {+ const res = effectorPrime(success, error);+ await res;+ },+ value => {+ table = value;+ }+ );+ return {+ [props.info.id]: table+ };+};diff --git a/test/node/reducers/composer-state-test.js b/test/node/reducers/composer-state-test.jsindex a0437f8d2..cab648aac 100644--- a/test/node/reducers/composer-state-test.js+++ b/test/node/reducers/composer-state-test.js@@ -8,10 +8,13 @@ import keplerGlReducer, {addDataToMapUpdater,replaceDataInMapUpdater,fitBoundsUpdater,- INITIAL_UI_STATE+ INITIAL_UI_STATE,+ visStateReducer,+ mapStateReducer} from '@kepler.gl/reducers';import {processCsvData} from '@kepler.gl/processors';import {registerEntry} from '@kepler.gl/actions';+import {drainTasksForTesting, succeedTaskWithValues} from 'react-palm/tasks';import testCsvData, {sampleConfig, dataWithNulls} from 'test/fixtures/test-csv-data';import testHexIdData, {@@ -21,6 +24,8 @@ import testHexIdData, {expectedMergedDataset} from 'test/fixtures/test-hex-id-data';import {cmpLayers, cmpFilters, cmpDataset, cmpInteraction} from 'test/helpers/comparison-utils';+import {applyExistingDatasetTasks} from 'test/helpers/mock-state';+const mockRawData = {fields: [{@@ -81,19 +86,21 @@ test('#composerStateReducer - addDataToMapUpdater: mapStyle', t => {}});+ drainTasksForTesting();+t.equal(newState.mapStyle.styleType, 'light', 'Map style is set correctly');t.end();});-test('#composerStateReducer - addDataToMapUpdater: mapState should be centered', t => {+test('#composerStateReducer - addDataToMapUpdater: mapState should be centered (after dataset tasts are completed)', t => {// init kepler.gl root and instanceconst state = keplerGlReducer({}, registerEntry({id: 'test'})).test;const mapStateProperties = {latitude: 33.88608913680742,longitude: -84.43459130456425};- const newState = addDataToMapUpdater(state, {+ let newState = addDataToMapUpdater(state, {payload: {datasets: {data: mockRawData,@@ -110,6 +117,15 @@ test('#composerStateReducer - addDataToMapUpdater: mapState should be centered',}});+ // create datasets from existing tasks, trigger auto create layers+ newState.visState = applyExistingDatasetTasks(visStateReducer, newState.visState);++ // layers should generate a fit bounds task+ const tasks = drainTasksForTesting();+ t.equal(tasks.length, 1, 'One fit bounds task should be present');++ newState.mapState = mapStateReducer(newState.mapState, succeedTaskWithValues(tasks[0], {}));+t.equal(newState.mapState.latitude, 29.23, 'centerMap: true should override mapState config');t.equal(newState.mapState.longitude, 60.71, 'centerMap: true should override mapState config');@@ -131,6 +147,8 @@ test('#composerStateReducer - addDataToMapUpdater: uiState', t => {}});+ drainTasksForTesting();+const expectedUIState = {...INITIAL_UI_STATE,initialState: {},@@ -153,7 +171,7 @@ test('#composerStateReducer - addDataToMapUpdater: keepExistingConfig', t => {const state = keplerGlReducer({}, registerEntry({id: 'test'})).test;// old state contain splitMaps- const oldState = addDataToMapUpdater(state, {+ let oldState = addDataToMapUpdater(state, {payload: {datasets: {data,@@ -165,6 +183,9 @@ test('#composerStateReducer - addDataToMapUpdater: keepExistingConfig', t => {}});+ // create datasets from existing tasks, trigger auto create layers+ oldState = {...oldState, visState: applyExistingDatasetTasks(visStateReducer, oldState.visState)};+const {layers: oldLayers,filters: oldFilters,@@ -177,7 +198,7 @@ test('#composerStateReducer - addDataToMapUpdater: keepExistingConfig', t => {const hexDataId = hexIdDataConfig.dataId;// keepExistingConfig is not defined, default to false- const nextState1 = addDataToMapUpdater(oldState, {+ let nextState1 = addDataToMapUpdater(oldState, {payload: {datasets: {data: hexData,@@ -189,6 +210,12 @@ test('#composerStateReducer - addDataToMapUpdater: keepExistingConfig', t => {}});+ // create datasets from existing tasks, trigger auto create layers+ nextState1 = {+ ...nextState1,+ visState: applyExistingDatasetTasks(visStateReducer, nextState1.visState)+ };+t.deepEqual(nextState1.visState.layerOrder, ['avlgol'], 'Should contain nextState1 layer order');cmpDataset(t, expectedMergedDataset, nextState1.visState.datasets[hexDataId]);@@ -199,7 +226,7 @@ test('#composerStateReducer - addDataToMapUpdater: keepExistingConfig', t => {cmpFilters(t, mergedFilters, nextState1.visState.filters);// add data and config keep existing data and config- const nextState2 = addDataToMapUpdater(oldState, {+ let nextState2 = addDataToMapUpdater(oldState, {payload: {datasets: {data: hexData,@@ -214,6 +241,12 @@ test('#composerStateReducer - addDataToMapUpdater: keepExistingConfig', t => {}});+ // create datasets from existing tasks, trigger auto create layers+ nextState2 = {+ ...nextState2,+ visState: applyExistingDatasetTasks(visStateReducer, nextState2.visState)+ };+const actualVisState = nextState2.visState;const newLayers = [...oldLayers, mergedH3Layer];@@ -378,20 +411,37 @@ test('#composerStateReducer - replaceDataInMapUpdater', t => {const state = keplerGlReducer({}, registerEntry({id: 'test'})).test;// old state contain splitMaps- const oldState = addDataToMapUpdater(state, {+ let oldState = addDataToMapUpdater(state, {payload: {datasets,config: sampleConfig.config}});+ // create datasets from existing tasks, trigger auto create layers+ oldState = {...oldState, visState: applyExistingDatasetTasks(visStateReducer, oldState.visState)};+const oldSavedConfig = state.visState.schema.getConfigToSave(oldState).config;- const nextState = replaceDataInMapUpdater(oldState, {+ let nextState = replaceDataInMapUpdater(oldState, {payload: {datasetToReplaceId: sampleConfig.dataId,datasetToUse}});+ // create datasets from existing tasks, trigger auto create layers+ nextState = {+ ...nextState,+ visState: applyExistingDatasetTasks(visStateReducer, nextState.visState)+ };++ // layers should generate a fit bounds task+ const tasks = drainTasksForTesting();+ t.equal(tasks.length, 1, 'A fit bounds Task should be present');+ nextState = {+ ...nextState,+ mapState: mapStateReducer(nextState.mapState, succeedTaskWithValues(tasks[0], {}))+ };+const nextSavedConfig = nextState.visState.schema.getConfigToSave(nextState).config;const expectedLayers = oldSavedConfig.visState.layers.map(l => ({@@ -492,21 +542,28 @@ test('#composerStateReducer - replaceDataInMapUpdater: same dataId', t => {const state = keplerGlReducer({}, registerEntry({id: 'test'})).test;// old state contain splitMaps- const oldState = addDataToMapUpdater(state, {+ let oldState = addDataToMapUpdater(state, {payload: {datasets,config: sampleConfig.config}});+ // create datasets from existing tasks, trigger auto create layers+ oldState = {...oldState, visState: applyExistingDatasetTasks(visStateReducer, oldState.visState)};const oldSavedConfig = state.visState.schema.getConfigToSave(oldState).config;- const nextState = replaceDataInMapUpdater(oldState, {+ let nextState = replaceDataInMapUpdater(oldState, {payload: {datasetToReplaceId: sampleConfig.dataId,datasetToUse}});+ // create datasets from existing tasks, trigger auto create layers+ nextState = {+ ...nextState,+ visState: applyExistingDatasetTasks(visStateReducer, nextState.visState)+ };// dataset should be replacedt.ok(nextState.visState.datasets[sampleConfig.dataId], ' dataset should be replaced');diff --git a/test/node/reducers/root-test.js b/test/node/reducers/root-test.jsindex 1e70a5e54..5a96151d5 100644--- a/test/node/reducers/root-test.js+++ b/test/node/reducers/root-test.js@@ -14,6 +14,7 @@ import {ActionTypes} from '@kepler.gl/actions';import {createAction, handleActions} from 'redux-actions';+import {applyActions} from 'test/helpers/mock-state';test('keplerGlReducer.initialState', t => {const test1Reducer = keplerGlReducer.initialState({@@ -318,17 +319,20 @@ test('keplerGlReducer.plugin override', t => {let nextState = testReducer(undefined, registerEntry({id: 'test3'}));- nextState = testReducer(- nextState,- addDataToMap({- datasets: {- data: mockRawData,- info: {- id: 'foo'- }+ const addDataToMapPayload = {+ datasets: {+ data: mockRawData,+ info: {+ id: 'foo'}- })- );+ }+ };+ nextState = applyActions(testReducer, nextState, [+ {+ action: addDataToMap,+ payload: [addDataToMapPayload]+ }+ ]);t.equal(nextState.test3.visState.layers.length, 4, 'Should have 4 layer');diff --git a/test/node/reducers/vis-state-merger-test.js b/test/node/reducers/vis-state-merger-test.jsindex 30ef16a33..8862e48ec 100644--- a/test/node/reducers/vis-state-merger-test.js+++ b/test/node/reducers/vis-state-merger-test.js@@ -81,7 +81,8 @@ import {StateWSplitMaps,testCsvDataId,testGeoJsonDataId,- StateWFiles+ StateWFiles,+ applyActions} from 'test/helpers/mock-state';import {@@ -131,7 +132,9 @@ test('VisStateMerger.v0 -> mergeFilters -> toEmptyState', t => {const parsedData = SchemaManager.parseSavedData(savedConfig.datasets);// load data into reducer- const stateWData = visStateReducer(mergedState, updateVisData(parsedData));+ const stateWData = applyActions(visStateReducer, mergedState, [+ {action: updateVisData, payload: [parsedData]}+ ]);// test parsed filterscmpFilters(t, mergedFiltersV0, stateWData.filters);@@ -164,7 +167,9 @@ test('VisStateMerger.v1 -> mergeFilters -> toEmptyState', t => {const parsedData = SchemaManager.parseSavedData(savedConfig.datasets);// load data into reducer- const stateWData = visStateReducer(mergedState, updateVisData(parsedData));+ const stateWData = applyActions(visStateReducer, mergedState, [+ {action: updateVisData, payload: [parsedData]}+ ]);// test parsed filterscmpFilters(t, expectedMergedFilterV1, stateWData.filters);@@ -198,7 +203,9 @@ test('VisStateMerger.v0 -> mergeFilters -> toWorkingState', t => {const parsedData = SchemaManager.parseSavedData(savedConfig.datasets);// load data into reducer- const stateWData = visStateReducer(mergedState, updateVisData(parsedData));+ const stateWData = applyActions(visStateReducer, mergedState, [+ {action: updateVisData, payload: [parsedData]}+ ]);// test parsed filterscmpFilters(t, [...oldFilters, ...mergedFiltersV0], stateWData.filters);@@ -235,7 +242,9 @@ test('VisStateMerger.v1 -> mergeFilters -> toWorkingState', t => {const parsedData = SchemaManager.parseSavedData(savedConfig.datasets);// load data into reducer- const stateWData = visStateReducer(mergedState, updateVisData(parsedData));+ const stateWData = applyActions(visStateReducer, mergedState, [+ {action: updateVisData, payload: [parsedData]}+ ]);// test parsed filterscmpFilters(t, [...oldFilters, ...mergedFiltersV1], stateWData.filters);@@ -330,7 +339,9 @@ test('VisStateMerger.current -> mergeLayers -> toEmptyState', t => {const parsedData = SchemaManager.parseSavedData(appStateToSave.datasets);// load data into reducer- const stateWData = visStateReducer(mergedState, updateVisData(parsedData));+ const stateWData = applyActions(visStateReducer, mergedState, [+ {action: updateVisData, payload: [parsedData]}+ ]);// test parsed layersconst genericLayersByOrder = stateToSave.visState.layerOrder.map(id =>@@ -364,7 +375,10 @@ test('visStateMerger -> mergeLayer -> incremental load', t => {// load dataset2const parsedData2 = SchemaManager.parseSavedData([dataset2]);- const stateWithData2 = coreReducer(stateWithConfig, addDataToMap({datasets: parsedData2}));+ const stateWithData2 = applyActions(coreReducer, stateWithConfig, [+ {action: addDataToMap, payload: [{datasets: parsedData2}]}+ ]);+t.deepEqual(stateWithData2.visState.preserveLayerOrder,['hexagon-2', 'point-0', 'geojson-1'],@@ -390,7 +404,10 @@ test('visStateMerger -> mergeLayer -> incremental load', t => {// load dataset1const parsedData1 = SchemaManager.parseSavedData([dataset1]);- const stateWithData1 = coreReducer(stateWithData2, addDataToMap({datasets: parsedData1}));+ const stateWithData1 = applyActions(coreReducer, stateWithData2, [+ {action: addDataToMap, payload: [{datasets: parsedData1}]}+ ]);+t.deepEqual(stateWithData1.visState.preserveLayerOrder,['hexagon-2', 'point-0', 'geojson-1'],@@ -445,7 +462,9 @@ test('VisStateMerger.v1 -> mergeLayers -> toEmptyState', t => {const parsedData = SchemaManager.parseSavedData(savedStateV1.datasets);// load data into reducer- const stateWData = visStateReducer(mergedState, updateVisData(parsedData));+ const stateWData = applyActions(visStateReducer, mergedState, [+ {action: updateVisData, payload: [parsedData]}+ ]);// test parsed layerscmpLayers(t, mergedLayersV1, stateWData.layers, {id: true, color: true});@@ -478,7 +497,9 @@ test('VisStateMerger.v1.label -> mergeLayers -> toEmptyState', t => {const parsedData = SchemaManager.parseSavedData(savedStateV1Label.datasets);// load data into reducer- const stateWData = visStateReducer(mergedState, updateVisData(parsedData));+ const stateWData = applyActions(visStateReducer, mergedState, [+ {action: updateVisData, payload: [parsedData]}+ ]);// test parsed layerscmpLayers(t, mergedLayersV1Label, stateWData.layers, {id: true});@@ -527,7 +548,9 @@ test('VisStateMerger.v1.split -> mergeLayers -> toEmptyState', t => {const parsedData = SchemaManager.parseSavedData(savedConfig.datasets);// load data into reducer- const stateWData = visStateReducer(mergedState, updateVisData(parsedData));+ const stateWData = applyActions(visStateReducer, mergedState, [+ {action: updateVisData, payload: [parsedData]}+ ]);// test split Mapst.deepEqual(stateWData.splitMaps, expectedConfig, 'should merge splitMaps');@@ -578,7 +601,9 @@ test('VisStateMerger.v0 -> mergeLayers -> toWorkingState', t => {const parsedData = SchemaManager.parseSavedData(savedConfig.datasets);// load data into reducer- const stateWData = visStateReducer(mergedState, updateVisData(parsedData));+ const stateWData = applyActions(visStateReducer, mergedState, [+ {action: updateVisData, payload: [parsedData]}+ ]);// test parsed layerscmpLayers(t, [...oldLayers, ...mergedLayersV0], stateWData.layers);@@ -633,7 +658,9 @@ test('VisStateMerger.v1 -> mergeLayers -> toWorkingState', t => {const parsedData = SchemaManager.parseSavedData(savedConfig.datasets);// load data into reducer- const stateWData = visStateReducer(mergedState, updateVisData(parsedData));+ const stateWData = applyActions(visStateReducer, mergedState, [+ {action: updateVisData, payload: [parsedData]}+ ]);// test parsed filterscmpLayers(t, [...oldLayers, ...mergedLayersV1], stateWData.layers);@@ -717,7 +744,9 @@ test('VisStateMerger.v0 -> mergeInteractions -> toEmptyState', t => {const parsedData = SchemaManager.parseSavedData(savedConfig.datasets);// load data into reducer- const stateWData = visStateReducer(mergedState, updateVisData(parsedData));+ const stateWData = applyActions(visStateReducer, mergedState, [+ {action: updateVisData, payload: [parsedData]}+ ]);// test parsed interactionst.deepEqual(stateWData.interactionConfig, mergedInteractionsV0, 'should merge interactionConfig');@@ -814,7 +843,9 @@ test('VisStateMerger.v0 -> mergeInteractions -> toWorkingState', t => {const parsedData = SchemaManager.parseSavedData(savedConfig.datasets);// load data into reducer- const stateWData = visStateReducer(mergedState, updateVisData(parsedData));+ const stateWData = applyActions(visStateReducer, mergedState, [+ {action: updateVisData, payload: [parsedData]}+ ]);const expectedInteractions = {...defaultInteractionConfig,@@ -986,7 +1017,9 @@ test('VisStateMerger.v1 -> mergeInteractions -> toEmptyState', t => {const parsedData = SchemaManager.parseSavedData(savedConfig.datasets);// load data into reducer- const stateWData = visStateReducer(mergedState, updateVisData(parsedData));+ const stateWData = applyActions(visStateReducer, mergedState, [+ {action: updateVisData, payload: [parsedData]}+ ]);// test parsed interactionst.deepEqual(stateWData.interactionConfig, MergedInteractionV1, 'should merge interactionConfig');@@ -1119,7 +1152,9 @@ test('VisStateMerger.v1 -> mergeInteractions -> toWorkingState', t => {const parsedData = SchemaManager.parseSavedData(savedConfig.datasets);// load data into reducer- const stateWData = visStateReducer(mergedState, updateVisData(parsedData));+ const stateWData = applyActions(visStateReducer, mergedState, [+ {action: updateVisData, payload: [parsedData]}+ ]);const expectedInteractions = {...defaultInteractionConfig,@@ -1259,7 +1294,9 @@ test('VisStateMerger.v1 -> mergeInteractions -> coordinate', t => {const parsedData = SchemaManager.parseSavedData(savedConfig.datasets);// load data into reducer- const stateWData = visStateReducer(mergedState, updateVisData(parsedData));+ const stateWData = applyActions(visStateReducer, mergedState, [+ {action: updateVisData, payload: [parsedData]}+ ]);const expectedInteractions = {...defaultInteractionConfig,@@ -1403,7 +1440,9 @@ test('VisStateMerger - mergeSplitMaps -> split to split', t => {const parsedData = SchemaManager.parseSavedData(savedConfig.datasets);// 3. load data into reducer- const mergedState3 = visStateReducer(mergedState2, updateVisData(parsedData));+ const mergedState3 = applyActions(visStateReducer, mergedState2, [+ {action: updateVisData, payload: [parsedData]}+ ]);t.deepEqual(mergedState3.splitMaps, expectedToMergeAll, 'Should merge all splitMaps');t.deepEqual(mergedState3.splitMapsToBeMerged, [], 'Should empty splitMapsToBeMerged');@@ -1490,7 +1529,9 @@ test('VisStateMerger - mergeTripGeojson', t => {// processKeplerglJSONconst result = processKeplerglJSON(savedStateV1TripGeoJson);- const updatedCore = coreReducer(initialState, addDataToMap(result));+ const updatedCore = applyActions(coreReducer, initialState, [+ {action: addDataToMap, payload: [result]}+ ]);const mergedVieState = updatedCore.visState;@@ -1566,10 +1607,9 @@ test('VisStateMerger.v1 -> mergeFilters -> multiFilters', t => {const oldState = cloneDeep(InitialState);const oldVisState = oldState.visState;- const mergedState = visStateReducer(- oldVisState,- updateVisData(stateParsed.datasets, {}, stateParsed.config)- );+ const mergedState = applyActions(visStateReducer, oldVisState, [+ {action: updateVisData, payload: [stateParsed.datasets, {}, stateParsed.config]}+ ]);// check datasets is filtered// and field has filterProps@@ -1725,7 +1765,9 @@ test('VisStateMerger.v1 -> mergeFilters -> syncedFilters', t => {t.equal(datasets.length, 2, 'should save 2 datasets');// load config to initial state- const stateWithConfig = coreReducer(InitialState, addDataToMap({config}));+ const stateWithConfig = applyActions(coreReducer, InitialState, [+ {action: addDataToMap, payload: [{config}]}+ ]);t.equal(stateWithConfig.visState.filters.length, 0, 'should not load filter without data');t.equal(@@ -1737,12 +1779,17 @@ test('VisStateMerger.v1 -> mergeFilters -> syncedFilters', t => {const parsedDatasets = SchemaManager.parseSavedData(datasets);// load data 1- const stateWithData1 = coreReducer(stateWithConfig, addDataToMap({datasets: parsedDatasets[0]}));+ const stateWithData1 = applyActions(coreReducer, stateWithConfig, [+ {action: addDataToMap, payload: [{datasets: parsedDatasets[0]}]}+ ]);+t.equal(Object.keys(stateWithData1.visState.datasets).length, 1, 'should load 1 dataset');t.equal(stateWithData1.visState.filters.length, 0, 'should not load filter without all datasets');// load data 2- const stateWithData2 = coreReducer(stateWithData1, addDataToMap({datasets: parsedDatasets[1]}));+ const stateWithData2 = applyActions(coreReducer, stateWithData1, [+ {action: addDataToMap, payload: [{datasets: parsedDatasets[1]}]}+ ]);t.equal(Object.keys(stateWithData2.visState.datasets).length, 2, 'should load 2 datasets');t.equal(stateWithData2.visState.filters.length,@@ -1991,10 +2038,9 @@ test('VisStateMerger -> load time filter/trip layer synced map', t => {const initialState = cloneDeep(InitialState);const initialVisState = initialState.visState;- const visState = visStateReducer(- initialVisState,- updateVisData(stateParsed.datasets, {}, stateParsed.config)- );+ const visState = applyActions(visStateReducer, initialVisState, [+ {action: updateVisData, payload: [stateParsed.datasets, {}, stateParsed.config]}+ ]);const newFilter = visState.filters[0];@@ -2131,7 +2177,7 @@ const mockReducer = keplerGlReducer});// eslint-disable-next-line max-statements-test('VisStateMerger -> asyne mergers', t => {+test('VisStateMerger -> asynс mergers', t => {// adding mock process to stateconst stateToSave = cloneDeep(StateWMultiFilters);const appStateToSave = SchemaManager.save(stateToSave);@@ -2148,15 +2194,13 @@ test('VisStateMerger -> asyne mergers', t => {const initialState = mockReducer(undefined, registerEntry({id: 'test'}));// apply config with process to merge- const nextState = mockReducer(- initialState,- // add csv data first- updateVisData(- stateParsed.datasets.find(d => d.info.id === testCsvDataId),- {},- configWithProcess- )- );+ const nextState = applyActions(mockReducer, initialState, [+ {+ // add csv data first+ action: updateVisData,+ payload: [stateParsed.datasets.find(d => d.info.id === testCsvDataId), {}, configWithProcess]+ }+ ]);t.deepEqual(nextState.test.visState.isMergingDatasets,@@ -2177,11 +2221,13 @@ test('VisStateMerger -> asyne mergers', t => {t.equal(tasks[0].type, 'MOCK_MERGE_TASK', 'should create merger task');// add another dataset will async merger is in process- const nextState1 = mockReducer(- nextState,- // add geojson data- updateVisData(stateParsed.datasets.find(d => d.info.id === testGeoJsonDataId))- );+ const nextState1 = applyActions(mockReducer, nextState, [+ {+ // add geojson data+ action: updateVisData,+ payload: [stateParsed.datasets.find(d => d.info.id === testGeoJsonDataId)]+ }+ ]);t.ok(nextState1.test.visState.datasets[testGeoJsonDataId], 'should add geojson data');diff --git a/test/node/reducers/vis-state-test.js b/test/node/reducers/vis-state-test.jsindex ea7d74365..7309d7b56 100644--- a/test/node/reducers/vis-state-test.js+++ b/test/node/reducers/vis-state-test.js@@ -27,7 +27,7 @@ import {import {processCsvData, processGeojson} from '@kepler.gl/processors';import {Layer, KeplerGlLayers, COLUMN_MODE_TABLE} from '@kepler.gl/layers';-import {createNewDataEntry, maybeToDate} from '@kepler.gl/table';+import {maybeToDate} from '@kepler.gl/table';import {createDataContainer,applyFilterFieldName,@@ -107,6 +107,7 @@ import {testCsvDataSlice2Id} from '../../fixtures/test-csv-data';import {mockStateWithSyncedFilterAndTripLayer} from '../../fixtures/synced-filter-with-trip-layer';+import {createNewDataEntryMock} from 'test/helpers/table-utils';const mockData = {fields: [@@ -361,11 +362,11 @@ test('#visStateReducer -> LAYER_TYPE_CHANGE.0', t => {t.end();});-test('#visStateReducer -> LAYER_TYPE_CHANGE.1', t => {+test('#visStateReducer -> LAYER_TYPE_CHANGE.1', async t => {const layer = new Layer({id: 'more_layer'});const oldState = {...INITIAL_VIS_STATE,- datasets: createNewDataEntry({+ datasets: await createNewDataEntryMock({info: {id: 'puppy', label: 'puppy'},data: {rows: mockData.data,@@ -432,14 +433,14 @@ test('#visStateReducer -> LAYER_TYPE_CHANGE.1', t => {t.end();});-test('#visStateReducer -> LAYER_TYPE_CHANGE.2', t => {+test('#visStateReducer -> LAYER_TYPE_CHANGE.2', async t => {const pointLayer = new PointLayer({id: 'a', dataId: 'smoothie'});const mockColorRange = {name: 'abc',isReversed: true,colors: ['a', 'b', 'c']};- const datasets = createNewDataEntry({+ const datasets = await createNewDataEntryMock({info: {id: 'smoothie'},data: {rows: testAllData,@@ -543,7 +544,7 @@ test('#visStateReducer -> LAYER_TYPE_CHANGE.2', t => {t.end();});-test('#visStateReducer -> LAYER_TYPE_CHANGE.3 -> animationConfig', t => {+test('#visStateReducer -> LAYER_TYPE_CHANGE.3 -> animationConfig', async t => {const layer = new GeojsonLayer({label: 'taro and blue',dataId: 'taro',@@ -553,7 +554,7 @@ test('#visStateReducer -> LAYER_TYPE_CHANGE.3 -> animationConfig', t => {id: 'taro'});- const dataset = createNewDataEntry({+ const dataset = await createNewDataEntryMock({info: {id: 'taro'},data: processGeojson(tripGeojson)});@@ -698,10 +699,12 @@ test('#visStateReducer -> LAYER_CONFIG_CHANGE -> isVisible -> splitMaps', t => {test('#visStateReducer -> LAYER_CONFIG_CHANGE -> columnMode', t => {const initialState = InitialState.visState;// const initialState = cloneDeep(state || InitialState);- const updatedState = reducer(- initialState,- VisStateActions.updateVisData({info: tripCsvDataInfo, data: processCsvData(tripCsvData)})- );+ const updatedState = applyActions(reducer, initialState, [+ {+ action: VisStateActions.updateVisData,+ payload: [{info: tripCsvDataInfo, data: processCsvData(tripCsvData)}]+ }+ ]);const pointLayer = updatedState.layers[0];// change layer type to trip@@ -824,16 +827,20 @@ test('visStateReducer -> layerDataIdChangeUpdater', t => {test('visStateReducer -> layerDataIdChangeUpdater -> geojson', t => {const initialState = CloneDeep(StateWFilesFiltersLayerColor).visState;- const nextState = reducer(- initialState,+ const nextState = applyActions(reducer, initialState, [// add another geojson- VisStateActions.updateVisData([- {- info: {id: 'geojson2', label: 'Some Geojson'},- data: {fields: geojsonFields, rows: geojsonRows.slice(0, 3)}- }- ])- );+ {+ action: VisStateActions.updateVisData,+ payload: [+ [+ {+ info: {id: 'geojson2', label: 'Some Geojson'},+ data: {fields: geojsonFields, rows: geojsonRows.slice(0, 3)}+ }+ ]+ ]+ }+ ]);// find geojson layerconst index = nextState.layers.findIndex(l => l.type === 'geojson');@@ -874,10 +881,12 @@ test('visStateReducer -> layerDataIdChangeUpdater -> validation', t => {...row.slice(fieldIdx + 1, row.length)]);// add another dataset- const nextState = reducer(- initialState,- VisStateActions.updateVisData([{info: newDataInfo, data: {fields, rows}}])- );+ const nextState = applyActions(reducer, initialState, [+ {+ action: VisStateActions.updateVisData,+ payload: [[{info: newDataInfo, data: {fields, rows}}]]+ }+ ]);const nextState1 = reducer(nextState,@@ -1361,16 +1370,20 @@ test('#visStateReducer -> UPDATE_VIS_DATA.1 -> No data', t => {test('#visStateReducer -> UPDATE_VIS_DATA.2 -> to empty state', t => {const oldState = INITIAL_VIS_STATE;- const newState = reducer(- oldState,- VisStateActions.updateVisData([- {- data: mockRawData,- info: {id: 'smoothie', label: 'exciting dataset'},- metadata: {album: 'taro_and_blue'}- }- ])- );+ const newState = applyActions(reducer, oldState, [+ {+ action: VisStateActions.updateVisData,+ payload: [+ [+ {+ data: mockRawData,+ info: {id: 'smoothie', label: 'exciting dataset'},+ metadata: {album: 'taro_and_blue'}+ }+ ]+ ]+ }+ ]);const expectedDatasets = {smoothie: {@@ -1547,15 +1560,19 @@ test('#visStateReducer -> UPDATE_VIS_DATA.3 -> merge w/ existing state', t => {smoothie: []};- const newState = reducer(- oldState,- VisStateActions.updateVisData([- {- data: mockRawData,- info: {id: 'smoothie', label: 'smoothie and milkshake'}- }- ])- );+ const newState = applyActions(reducer, oldState, [+ {+ action: VisStateActions.updateVisData,+ payload: [+ [+ {+ data: mockRawData,+ info: {id: 'smoothie', label: 'smoothie and milkshake'}+ }+ ]+ ]+ }+ ]);Object.keys(expectedDatasets).forEach(key =>cmpDataset(t, expectedDatasets[key], newState.datasets[key])@@ -1607,7 +1624,12 @@ test('#visStateReducer -> UPDATE_VIS_DATA.4.Geojson -> geojson data', t => {const [layer1Color, layer1StrokeColor] = getNextColorMakerValue(2);// receive data- const initialState = reducer(initialVisState, VisStateActions.updateVisData(payload));+ const initialState = applyActions(reducer, initialVisState, [+ {+ action: VisStateActions.updateVisData,+ payload: [payload]+ }+ ]);const expectedDatasets = {metadata: {@@ -1706,7 +1728,12 @@ test('#visStateReducer -> UPDATE_VIS_DATA.4.Geojson -> with config', t => {];// receive data- const initialState = reducer(initialVisState, VisStateActions.updateVisData(payload));+ const initialState = applyActions(reducer, initialVisState, [+ {+ action: VisStateActions.updateVisData,+ payload: [payload]+ }+ ]);t.equal(initialState.layers.length, 1, 'should create 1 layer');@@ -1740,7 +1767,12 @@ test('#visStateReducer -> UPDATE_VIS_DATA.4.Geojson -> with config', t => {}};- const testState = reducer(initialState, VisStateActions.updateVisData(datasets, {}, config));+ const testState = applyActions(reducer, initialState, [+ {+ action: VisStateActions.updateVisData,+ payload: [datasets, {}, config]+ }+ ]);t.deepEqual(Object.keys(testState.datasets),@@ -1804,15 +1836,19 @@ test('#visStateReducer -> UPDATE_VIS_DATA -> mergeFilters', t => {value: mockFilter.value};- const newState = reducer(- oldState,- VisStateActions.updateVisData([- {- data: mockRawData,- info: {id: 'smoothie', label: 'smoothie and milkshake'}- }- ])- );+ const newState = applyActions(reducer, oldState, [+ {+ action: VisStateActions.updateVisData,+ payload: [+ [+ {+ data: mockRawData,+ info: {id: 'smoothie', label: 'smoothie and milkshake'}+ }+ ]+ ]+ }+ ]);const dc = createDataContainer(mockRawData.rows, {fields: mockRawData.fields});const allIndexes = dc.getPlainIndex();@@ -1951,15 +1987,19 @@ test('#visStateReducer -> UPDATE_VIS_DATA.SPLIT_MAPS', t => {layerOrder: [layers[2].id, layers[1].id, layers[0].id, layers[3].id]};- const newState = reducer(- oldState,- VisStateActions.updateVisData([- {- data: mockRawData,- info: {id: 'smoothie', label: 'smoothie and milkshake'}- }- ])- );+ const newState = applyActions(reducer, oldState, [+ {+ action: VisStateActions.updateVisData,+ payload: [+ [+ {+ data: mockRawData,+ info: {id: 'smoothie', label: 'smoothie and milkshake'}+ }+ ]+ ]+ }+ ]);// first visible layer should be pointconst id1 = newState.layers[4].id;@@ -2018,7 +2058,12 @@ test('#visStateReducer -> setFilter.dynamicDomain & cpu', t => {];// receive data- const initialState = reducer(INITIAL_VIS_STATE, VisStateActions.updateVisData(payload));+ const initialState = applyActions(reducer, INITIAL_VIS_STATE, [+ {+ action: VisStateActions.updateVisData,+ payload: [payload]+ }+ ]);const expectedLayer1 = new PointLayer({isVisible: true,@@ -2650,7 +2695,12 @@ function testSetFilterDynamicDomainGPU(t, setFilter) {];// receive data- const initialState = reducer(INITIAL_VIS_STATE, VisStateActions.updateVisData(payload));+ const initialState = applyActions(reducer, INITIAL_VIS_STATE, [+ {+ action: VisStateActions.updateVisData,+ payload: [payload]+ }+ ]);// add filterconst stateWithFilter = reducer(initialState, VisStateActions.addFilter('milkshake'));@@ -2827,7 +2877,7 @@ test('#visStateReducer -> UPDATE_FILTER_ANIMATION_SPEED', t => {t.end();});-test('#visStateReducer -> setFilter.fixedDomain & DynamicDomain & gpu & cpu', t => {+test('#visStateReducer -> setFilter.fixedDomain & DynamicDomain & gpu & cpu', async t => {// get test dataconst {fields, rows} = processCsvData(testData);const payload = [@@ -2840,13 +2890,15 @@ test('#visStateReducer -> setFilter.fixedDomain & DynamicDomain & gpu & cpu', t}];- const datasetSmoothie = createNewDataEntry({- info: {id: 'smoothie', label: 'queen smoothie'},- data: {- rows: testAllData,- fields: testFields- }- }).smoothie;+ const datasetSmoothie = (+ await createNewDataEntryMock({+ info: {id: 'smoothie', label: 'queen smoothie'},+ data: {+ rows: testAllData,+ fields: testFields+ }+ })+ ).smoothie;// add fixedDomain & gpu filterconst stateWidthTsFilter = applyActions(reducer, INITIAL_VIS_STATE, [@@ -3178,7 +3230,12 @@ test('#visStateReducer -> SET_FILTER_PLOT.yAxis', t => {];// receive data- const initialState = reducer(INITIAL_VIS_STATE, VisStateActions.updateVisData(payload));+ const initialState = applyActions(reducer, INITIAL_VIS_STATE, [+ {+ action: VisStateActions.updateVisData,+ payload: [payload]+ }+ ]);// add filterconst stateWithFilter = reducer(initialState, VisStateActions.addFilter('smoothie'));@@ -4834,7 +4891,12 @@ test('#visStateReducer -> POLYGON: Create polygon filter', t => {};// visStateUpdateVisDataUpdater - creates 4 layers- let newReducer = reducer(state, VisStateActions.updateVisData(datasets, options, {}));+ let newReducer = applyActions(reducer, state, [+ {+ action: VisStateActions.updateVisData,+ payload: [datasets, options, {}]+ }+ ]);// add new polygon featurenewReducer = reducer(newReducer, VisStateActions.setFeatures([mockPolygonFeature]));@@ -4901,7 +4963,12 @@ test('#visStateReducer -> POLYGON: Create polygon filter', t => {t.equal(newReducer.layerData[1].data.length, 0, 'Layer Point 2 show show 0 points');// Adding a new dataset - creates extra 4 layers- newReducer = reducer(newReducer, VisStateActions.updateVisData(datasets, options, {}));+ newReducer = applyActions(reducer, newReducer, [+ {+ action: VisStateActions.updateVisData,+ payload: [datasets, options, {}]+ }+ ]);t.equal(newReducer.layerData[4].data.length, 4, 'Layer Point 5 should full data');@@ -5038,7 +5105,12 @@ test('#visStateReducer -> POLYGON: Toggle filter feature', t => {};// visStateUpdateVisDataUpdater - creates 4 layers- let newReducer = reducer(state, VisStateActions.updateVisData(datasets, options, {}));+ let newReducer = applyActions(reducer, state, [+ {+ action: VisStateActions.updateVisData,+ payload: [datasets, options, {}]+ }+ ]);newReducer = reducer(newReducer, VisStateActions.addLayer());@@ -5208,7 +5280,12 @@ test('#visStateReducer -> POLYGON: delete polygon filter', t => {};// visStateUpdateVisDataUpdater - creates 4 layers- let newReducer = reducer(state, VisStateActions.updateVisData(datasets, options, {}));+ let newReducer = applyActions(reducer, state, [+ {+ action: VisStateActions.updateVisData,+ payload: [datasets, options, {}]+ }+ ]);newReducer = reducer(newReducer, VisStateActions.addLayer());@@ -5598,9 +5675,10 @@ test('#visStateReducer -> LOAD_FILES', async t => {}const nextState = reducer(initialState, VisStateActions.loadFiles(mockFiles));- const [task1, ...more] = drainTasksForTesting();- t.equal(more.length, 0, 'should ceate 1 task');+ const tasks = drainTasksForTesting();+ t.equal(tasks.length, 2, 'should ceate 2 tasks');+ const task1 = tasks[1];const expectedTask1 = {type: 'LOAD_FILE_TASK',diff --git a/test/node/utils/index.js b/test/node/utils/index.jsindex 2a857792a..5ee5b38a3 100644--- a/test/node/utils/index.js+++ b/test/node/utils/index.js@@ -4,6 +4,7 @@import './data-utils-test';import './data-processor-test';import './kepler-table-test';+import './kepler-table-utils-test';import './data-container-test';import './filter-utils-test';import './gpu-filter-utils-test';diff --git a/test/node/utils/kepler-table-test.js b/test/node/utils/kepler-table-test.jsindex 833d7b0fe..10fba3e36 100644--- a/test/node/utils/kepler-table-test.js+++ b/test/node/utils/kepler-table-test.js@@ -6,12 +6,13 @@ import moment from 'moment';import testData, {numericRangesCsv, testFields} from 'test/fixtures/test-csv-data';import {preciseRound, getFilterFunction} from '@kepler.gl/utils';-import {createNewDataEntry, findPointFieldPairs} from '@kepler.gl/table';-+import {findPointFieldPairs} from '@kepler.gl/table';import {processCsvData} from '@kepler.gl/processors';-import {cmpFields} from '../../helpers/comparison-utils';import {FILTER_TYPES} from '@kepler.gl/constants';+import {cmpFields} from '../../helpers/comparison-utils';+import {createNewDataEntryMock} from '../../helpers/table-utils';+function testGetTimeFieldDomain(table, t) {const test_cases = [{@@ -215,15 +216,16 @@ function testGetFilterFunction({fields, dataContainer}, t) {);}-test('KeplerTable -> getColumnFilterDomain -> time', t => {+test('KeplerTable -> getColumnFilterDomain -> time', async t => {const expectedFields = testFields;const data = processCsvData(testData);- const newDataEntry = createNewDataEntry({- info: {id: 'test'},- data- });- const dataset = newDataEntry.test;+ const dataset = (+ await createNewDataEntryMock({+ info: {id: 'test'},+ data+ })+ ).test;cmpFields(t, expectedFields, dataset.fields, dataset.id);testGetTimeFieldDomain(dataset, t);testGetFilterFunction(dataset, t);@@ -233,11 +235,12 @@ test('KeplerTable -> getColumnFilterDomain -> time', t => {test('KeplerTable -> getColumnFilterDomain -> numeric', async t => {const data = processCsvData(numericRangesCsv);- const newDataEntry = createNewDataEntry({- info: {id: 'test'},- data- });- const dataset = newDataEntry.test;+ const dataset = (+ await createNewDataEntryMock({+ info: {id: 'test'},+ data+ })+ ).test;testGetNumericFieldStep(dataset, t);diff --git a/test/node/utils/kepler-table-utils-test.js b/test/node/utils/kepler-table-utils-test.jsnew file mode 100644index 000000000..3d934f61b--- /dev/null+++ b/test/node/utils/kepler-table-utils-test.js@@ -0,0 +1,31 @@+// SPDX-License-Identifier: MIT+// Copyright contributors to the kepler.gl project++import test from 'tape';++import {createNewDataEntry} from '@kepler.gl/table';++test('Dataset Utils -> createNewDataEntry', t => {+ const task = createNewDataEntry({+ info: {id: 'test', color: [0, 92, 255]},+ data: {+ rows: [[10], [20]],+ fields: []+ }+ });++ t.equal(task.label, 'CREATE_TABLE_TASK', 'should create CREATE_TABLE_TASK task');+ t.equal(task.type, 'CREATE_TABLE_TASK', 'should create CREATE_TABLE_TASK task');+ t.deepEqual(+ task.payload,+ {+ info: {id: 'test', color: [0, 92, 255]},+ color: [0, 92, 255],+ opts: {},+ data: {rows: [[10], [20]], fields: [], cols: undefined}+ },+ 'should create correct CREATE_TABLE_TASK task payload'+ );++ t.end();+});diff --git a/test/node/utils/layer-utils-test.js b/test/node/utils/layer-utils-test.jsindex 740b785ef..61e2cb012 100644--- a/test/node/utils/layer-utils-test.js+++ b/test/node/utils/layer-utils-test.js@@ -14,9 +14,10 @@ const {PointLayer, ArcLayer, GeojsonLayer, LineLayer} = KeplerGlLayers;import {wktCsv} from 'test/fixtures/test-csv-data';import {cmpLayers} from 'test/helpers/comparison-utils';import {getNextColorMakerValue} from 'test/helpers/layer-utils';+import {createNewDataEntryMock} from 'test/helpers/table-utils';import tripGeojson, {timeStampDomain, tripBounds} from 'test/fixtures/trip-geojson';import {geoJsonWithStyle} from 'test/fixtures/geojson';-import {KeplerTable, findPointFieldPairs, createNewDataEntry} from '@kepler.gl/table';+import {KeplerTable, findPointFieldPairs} from '@kepler.gl/table';import {createDataContainer} from '@kepler.gl/utils';test('layerUtils -> findDefaultLayer.1', t => {@@ -282,7 +283,9 @@ test('layerUtils -> findDefaultLayer.2', t => {info: {id: dataId,label: 'sf_zip_geo'- },+ }+ });+ dataset.importData({data: {rows: [[@@ -531,7 +534,9 @@ test('layerUtils -> findDefaultLayer:GeojsonLayer', t => {const dataset = new KeplerTable({info: {label: 'sf_zip_geo'- },+ }+ });+ dataset.importData({data: {rows: [[@@ -811,7 +816,7 @@ test('layerUtils -> findDefaultLayer: TripLayer', t => {t.end();});-test('layerUtils -> findDefaultLayer: TripLayer.1 -> no ts', t => {+test('layerUtils -> findDefaultLayer: TripLayer.1 -> no ts', async t => {// change 3rd coordinate to stringconst modified = tripGeojson.features.map(f => ({...f,@@ -826,7 +831,7 @@ test('layerUtils -> findDefaultLayer: TripLayer.1 -> no ts', t => {features: modified};- const dataset = createNewDataEntry({+ const dataset = await createNewDataEntryMock({info: {id: 'taro'},data: processGeojson(noTripGeojson)});@@ -839,7 +844,7 @@ test('layerUtils -> findDefaultLayer: TripLayer.1 -> no ts', t => {t.end();});-test('layerUtils -> findDefaultLayer: TripLayer.1 -> ts as string', t => {+test('layerUtils -> findDefaultLayer: TripLayer.1 -> ts as string', async t => {const tripData = {type: 'FeatureCollection',features: [@@ -858,7 +863,7 @@ test('layerUtils -> findDefaultLayer: TripLayer.1 -> ts as string', t => {]};- const dataset = createNewDataEntry({+ const dataset = await createNewDataEntryMock({info: {id: 'taro'},data: processGeojson(tripData)});diff --git a/yarn.lock b/yarn.lockindex 93309124b..d758cbe5f 100644--- a/yarn.lock+++ b/yarn.lock@@ -3297,6 +3297,7 @@ __metadata:"@kepler.gl/common-utils": "npm:3.0.0""@kepler.gl/constants": "npm:3.0.0""@kepler.gl/schemas": "npm:3.0.0"+ "@kepler.gl/table": "npm:3.0.0""@kepler.gl/types": "npm:3.0.0""@kepler.gl/utils": "npm:3.0.0""@loaders.gl/arrow": "npm:^4.3.2"@@ -3406,6 +3407,7 @@ __metadata:global: "npm:^4.3.0"lodash.uniq: "npm:^4.0.1"moment: "npm:^2.10.6"+ react-palm: "npm:^3.3.8"languageName: unknownlinkType: soft