Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dataSources store type #807

Merged
merged 2 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions packages/react-redux/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ export {
OauthState,
ViewState,
InitialCarto3State,
Source,
SourceFilters
} from './types';
15 changes: 1 addition & 14 deletions packages/react-redux/src/slices/cartoSlice.d.ts
Original file line number Diff line number Diff line change
@@ -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<Record<_FilterTypes, { values: FilterValues; owner?: string; params?: Record<string, unknown>; }>>
}

type Source = SourceProps & {
id: string;
filters?: SourceFilters;
filtersLogicalOperator?: FiltersLogicalOperators;
isDroppingFeatures?: boolean;
};

type Layer = {
id: string;
source?: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/react-redux/src/slices/cartoSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
19 changes: 16 additions & 3 deletions packages/react-redux/src/types.d.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand All @@ -15,6 +15,19 @@ export type ViewState = {
height?: number,
}

type FilterValues = string[] | number[] | number[][]

export type SourceFilters = {
[column: string]: Partial<Record<_FilterTypes, { values: FilterValues; owner?: string; params?: Record<string, unknown>; }>>
}

export type Source = SourceProps & {
id: string;
filters?: SourceFilters;
filtersLogicalOperator?: FiltersLogicalOperators;
isDroppingFeatures?: boolean;
};

type InitialCarto2State = {
accountsUrl?: string,
viewState: ViewState,
Expand Down Expand Up @@ -45,7 +58,7 @@ export type CartoState = {
geocoderResult: Record<string,any> | 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,
Expand Down