diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ffdad89a..adbf5c617 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Not released +- Fix dataSources store type [#807](https://github.com/CartoDB/carto-react/pull/807) + ## 2.3 ### 2.3.1 (2023-11-27) diff --git a/packages/react-redux/src/index.d.ts b/packages/react-redux/src/index.d.ts index 770e69f36..5612e6a3d 100644 --- a/packages/react-redux/src/index.d.ts +++ b/packages/react-redux/src/index.d.ts @@ -8,4 +8,6 @@ export { OauthState, ViewState, InitialCarto3State, + Source, + SourceFilters } from './types'; diff --git a/packages/react-redux/src/slices/cartoSlice.d.ts b/packages/react-redux/src/slices/cartoSlice.d.ts index dd54ca2d9..9913f7128 100644 --- a/packages/react-redux/src/slices/cartoSlice.d.ts +++ b/packages/react-redux/src/slices/cartoSlice.d.ts @@ -1,23 +1,10 @@ import { Credentials, SourceProps } from '@carto/react-api/'; import { FiltersLogicalOperators, Viewport, _FilterTypes } from '@carto/react-core'; import { CartoBasemapsNames, GMapsBasemapsNames } from '@carto/react-basemaps/'; -import { InitialCartoState, CartoState, ViewState } from '../types'; +import { InitialCartoState, CartoState, ViewState, Source, FilterValues } from '../types'; import { AnyAction, Reducer } from 'redux'; import { Feature, Polygon, MultiPolygon } from 'geojson'; -type FilterValues = string[] | number[] | number[][] - -export type SourceFilters = { - [column: string]: Partial; }>> -} - -type Source = SourceProps & { - id: string; - filters?: SourceFilters; - filtersLogicalOperator?: FiltersLogicalOperators; - isDroppingFeatures?: boolean; -}; - type Layer = { id: string; source?: string; diff --git a/packages/react-redux/src/slices/cartoSlice.js b/packages/react-redux/src/slices/cartoSlice.js index b7b79af9c..21e96824a 100644 --- a/packages/react-redux/src/slices/cartoSlice.js +++ b/packages/react-redux/src/slices/cartoSlice.js @@ -206,7 +206,7 @@ export const createCartoSlice = (initialState) => { * @param {string} data.type - type of source. Possible values are sql or bigquery. * @param {object=} data.credentials - (optional) Custom credentials to be used in the source. * @param {string} data.connection - connection name for CARTO 3 source. - * @param {import('./cartoSlice').SourceFilters=} data.filters - logical operator that defines how filters for different columns are joined together. + * @param {import('../types').SourceFilters=} data.filters - logical operator that defines how filters for different columns are joined together. * @param {FiltersLogicalOperators=} data.filtersLogicalOperator - logical operator that defines how filters for different columns are joined together. * @param {import('@deck.gl/carto/typed').QueryParameters} data.queryParameters - SQL query parameters. * @param {string=} data.geoColumn - (optional) name of column containing geometries or spatial index data. diff --git a/packages/react-redux/src/types.d.ts b/packages/react-redux/src/types.d.ts index 439609dce..6331823c9 100644 --- a/packages/react-redux/src/types.d.ts +++ b/packages/react-redux/src/types.d.ts @@ -1,7 +1,7 @@ -import { Credentials } from '@carto/react-api'; +import { Credentials, SourceProps } from '@carto/react-api'; import { OauthApp } from '@carto/react-auth'; import { CartoBasemapsNames, GMapsBasemaps } from '@carto/react-basemaps'; -import { Viewport } from '@carto/react-core'; +import { Viewport, FiltersLogicalOperators, _FilterTypes } from '@carto/react-core'; import { Geometry } from 'geojson'; export type ViewState = { @@ -15,6 +15,19 @@ export type ViewState = { height?: number, } +type FilterValues = string[] | number[] | number[][] + +export type SourceFilters = { + [column: string]: Partial; }>> +} + +export type Source = SourceProps & { + id: string; + filters?: SourceFilters; + filtersLogicalOperator?: FiltersLogicalOperators; + isDroppingFeatures?: boolean; +}; + type InitialCarto2State = { accountsUrl?: string, viewState: ViewState, @@ -45,7 +58,7 @@ export type CartoState = { geocoderResult: Record | null, error: null, // TODO: remove from state? layers: { [key: string]: string }, - dataSources: { [key: string]: string }, + dataSources: { [key: string]: Source }, spatialFilter: Geometry, featuresReady: { [key: string]: boolean }, featureSelectionEnabled: boolean,