@carto/ps-react-maps 4.5.2 → 4.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/index.js +2265 -2336
  2. package/dist/index.js.map +1 -1
  3. package/dist/types/editable/lasso-tools/provider/store.test.d.ts +1 -0
  4. package/dist/types/editable/measurement-tools/utils.test.d.ts +1 -0
  5. package/dist/types/helpers.test.d.ts +1 -0
  6. package/dist/types/index.d.ts +1 -1
  7. package/dist/types/models/aggregations.d.ts +15 -5
  8. package/dist/types/models/categories.d.ts +15 -4
  9. package/dist/types/models/features.d.ts +15 -4
  10. package/dist/types/models/formula.d.ts +15 -4
  11. package/dist/types/models/histogram.d.ts +15 -4
  12. package/dist/types/models/range.d.ts +15 -4
  13. package/dist/types/models/scatter.d.ts +15 -4
  14. package/dist/types/models/table.d.ts +15 -4
  15. package/dist/types/models/time-series.d.ts +15 -4
  16. package/dist/types/models/types.d.ts +166 -7
  17. package/dist/types/models/utils/create-model.d.ts +18 -9
  18. package/dist/types/models/utils/resolve-property-for-source.d.ts +19 -0
  19. package/dist/types/models/utils/use-common-model.d.ts +24 -5
  20. package/dist/types/models/utils/use-common-model.test.d.ts +1 -0
  21. package/dist/types/models/utils/use-filters-merged.d.ts +16 -2
  22. package/dist/types/models/utils/use-query-key.d.ts +13 -2
  23. package/dist/types/models/utils/use-query-key.test.d.ts +1 -0
  24. package/dist/types/models/utils/use-widget-model.d.ts +18 -1
  25. package/dist/types/models/utils/use-widget-model.test.d.ts +1 -0
  26. package/dist/types/providers/layers/store.test.d.ts +1 -0
  27. package/dist/types/providers/map/store.test.d.ts +1 -0
  28. package/dist/types/providers/sources/store.d.ts +9 -2
  29. package/dist/types/providers/sources/widgets/geojson-features.test.d.ts +1 -0
  30. package/dist/types/providers/sources/widgets/widget-geojson-source-impl.test.d.ts +1 -0
  31. package/dist/types/providers/sources/widgets/widget-geojson-source.test.d.ts +1 -0
  32. package/dist/types/stats/get-query-stats.test.d.ts +1 -0
  33. package/dist/types/stats/get-table-stats.test.d.ts +1 -0
  34. package/dist/types/utils/mapping-meridian.test.d.ts +1 -0
  35. package/dist/types/utils/sort-layers.test.d.ts +1 -0
  36. package/package.json +2 -2
@@ -0,0 +1 @@
1
+ export {};
@@ -26,7 +26,7 @@ export { createMeasurementToolsStore } from './editable/measurement-tools/provid
26
26
  export { CustomEditableGeojsonLayer } from './editable/custom-editable-geojson-layer';
27
27
  export { getCursorDefault, getTooltipDefault } from './helpers';
28
28
  export { MapComponent } from './maps/map';
29
- export type { ModelProps } from './models/types';
29
+ export type { ModelProps, FormulaWidgetProps, CategoryWidgetProps, TimeSeriesWidgetProps, HistogramWidgetProps, AggregationsWidgetProps, RangeWidgetProps, ScatterWidgetProps, TableWidgetProps, FeaturesWidgetProps, } from './models/types';
30
30
  export { AggregationsModel, useAggregations } from './models/aggregations';
31
31
  export { CategoriesModel, useCategories } from './models/categories';
32
32
  export { FeaturesModel, useFeatures } from './models/features';
@@ -1,5 +1,5 @@
1
- import { AggregationsRequestOptions as _AggregationsRequestOptions, AggregationsResponse, AggregationType } from '@carto/api-client';
2
- export type AggregationsRequestOptions = Omit<_AggregationsRequestOptions, 'aggregations'> & {
1
+ import { AggregationsRequestOptions, AggregationsResponse, AggregationType } from '@carto/api-client';
2
+ export type AggregationsWidgetProps = Omit<AggregationsRequestOptions, 'aggregations'> & {
3
3
  aggregations: ({
4
4
  operation: 'custom';
5
5
  aggregationExp: string;
@@ -10,7 +10,17 @@ export type AggregationsRequestOptions = Omit<_AggregationsRequestOptions, 'aggr
10
10
  alias: string;
11
11
  })[];
12
12
  };
13
- declare const useAggregations: ({ accessToken, sourceId, widgetProps, additionalFilter, useQueryProps: { enabled, ...useQueryProps }, }: import('./types').ModelProps<AggregationsRequestOptions, AggregationsResponse>) => import('@tanstack/react-query').UseQueryResult<AggregationsResponse, Error>, AggregationsModel: ({ children, ...modelProps }: import('./types').ModelProps<AggregationsRequestOptions, AggregationsResponse> & {
14
- children: (props: import('@tanstack/react-query').UseQueryResult<AggregationsResponse, Error>) => React.ReactNode;
15
- }) => import('react').ReactNode;
13
+ declare const useAggregations: <P extends import('./types').ModelProps<AggregationsWidgetProps, AggregationsResponse>>(props: P) => P extends {
14
+ sourceId: string;
15
+ sourcesId?: string[];
16
+ } ? import('./types').ModelResponse<AggregationsResponse> : import('./types').ModelResponse<AggregationsResponse[]>, AggregationsModel: {
17
+ (props: import('./types').ModelProps<AggregationsWidgetProps, AggregationsResponse> & {
18
+ sourceId: string;
19
+ children: (props: import('./types').ModelResponse<AggregationsResponse>) => React.ReactNode;
20
+ }): React.ReactElement;
21
+ (props: import('./types').ModelProps<AggregationsWidgetProps, AggregationsResponse> & {
22
+ sourcesId: string[];
23
+ children: (props: import('./types').ModelResponse<AggregationsResponse[]>) => React.ReactNode;
24
+ }): React.ReactElement;
25
+ };
16
26
  export { useAggregations, AggregationsModel };
@@ -1,5 +1,16 @@
1
- import { CategoryRequestOptions, CategoryResponse } from '@carto/api-client';
2
- declare const useCategories: ({ accessToken, sourceId, widgetProps, additionalFilter, useQueryProps: { enabled, ...useQueryProps }, }: import('./types').ModelProps<CategoryRequestOptions, CategoryResponse>) => import('@tanstack/react-query').UseQueryResult<CategoryResponse, Error>, CategoriesModel: ({ children, ...modelProps }: import('./types').ModelProps<CategoryRequestOptions, CategoryResponse> & {
3
- children: (props: import('@tanstack/react-query').UseQueryResult<CategoryResponse, Error>) => React.ReactNode;
4
- }) => import('react').ReactNode;
1
+ import { CategoryResponse } from '@carto/api-client';
2
+ import { CategoryWidgetProps } from './types';
3
+ declare const useCategories: <P extends import('./types').ModelProps<CategoryWidgetProps, CategoryResponse>>(props: P) => P extends {
4
+ sourceId: string;
5
+ sourcesId?: string[];
6
+ } ? import('./types').ModelResponse<CategoryResponse> : import('./types').ModelResponse<CategoryResponse[]>, CategoriesModel: {
7
+ (props: import('./types').ModelProps<CategoryWidgetProps, CategoryResponse> & {
8
+ sourceId: string;
9
+ children: (props: import('./types').ModelResponse<CategoryResponse>) => React.ReactNode;
10
+ }): React.ReactElement;
11
+ (props: import('./types').ModelProps<CategoryWidgetProps, CategoryResponse> & {
12
+ sourcesId: string[];
13
+ children: (props: import('./types').ModelResponse<CategoryResponse[]>) => React.ReactNode;
14
+ }): React.ReactElement;
15
+ };
5
16
  export { useCategories, CategoriesModel };
@@ -1,5 +1,16 @@
1
- import { FeaturesRequestOptions, FeaturesResponse } from '@carto/api-client';
2
- declare const useFeatures: ({ accessToken, sourceId, widgetProps, additionalFilter, useQueryProps: { enabled, ...useQueryProps }, }: import('./types').ModelProps<FeaturesRequestOptions, FeaturesResponse>) => import('@tanstack/react-query').UseQueryResult<FeaturesResponse, Error>, FeaturesModel: ({ children, ...modelProps }: import('./types').ModelProps<FeaturesRequestOptions, FeaturesResponse> & {
3
- children: (props: import('@tanstack/react-query').UseQueryResult<FeaturesResponse, Error>) => React.ReactNode;
4
- }) => import('react').ReactNode;
1
+ import { FeaturesResponse } from '@carto/api-client';
2
+ import { FeaturesWidgetProps } from './types';
3
+ declare const useFeatures: <P extends import('./types').ModelProps<FeaturesWidgetProps, FeaturesResponse>>(props: P) => P extends {
4
+ sourceId: string;
5
+ sourcesId?: string[];
6
+ } ? import('./types').ModelResponse<FeaturesResponse> : import('./types').ModelResponse<FeaturesResponse[]>, FeaturesModel: {
7
+ (props: import('./types').ModelProps<FeaturesWidgetProps, FeaturesResponse> & {
8
+ sourceId: string;
9
+ children: (props: import('./types').ModelResponse<FeaturesResponse>) => React.ReactNode;
10
+ }): React.ReactElement;
11
+ (props: import('./types').ModelProps<FeaturesWidgetProps, FeaturesResponse> & {
12
+ sourcesId: string[];
13
+ children: (props: import('./types').ModelResponse<FeaturesResponse[]>) => React.ReactNode;
14
+ }): React.ReactElement;
15
+ };
5
16
  export { useFeatures, FeaturesModel };
@@ -1,5 +1,16 @@
1
- import { FormulaRequestOptions, FormulaResponse } from '@carto/api-client';
2
- declare const useFormula: ({ accessToken, sourceId, widgetProps, additionalFilter, useQueryProps: { enabled, ...useQueryProps }, }: import('./types').ModelProps<FormulaRequestOptions, FormulaResponse>) => import('@tanstack/react-query').UseQueryResult<FormulaResponse, Error>, FormulaModel: ({ children, ...modelProps }: import('./types').ModelProps<FormulaRequestOptions, FormulaResponse> & {
3
- children: (props: import('@tanstack/react-query').UseQueryResult<FormulaResponse, Error>) => React.ReactNode;
4
- }) => import('react').ReactNode;
1
+ import { FormulaResponse } from '@carto/api-client';
2
+ import { FormulaWidgetProps } from './types';
3
+ declare const useFormula: <P extends import('./types').ModelProps<FormulaWidgetProps, FormulaResponse>>(props: P) => P extends {
4
+ sourceId: string;
5
+ sourcesId?: string[];
6
+ } ? import('./types').ModelResponse<FormulaResponse> : import('./types').ModelResponse<FormulaResponse[]>, FormulaModel: {
7
+ (props: import('./types').ModelProps<FormulaWidgetProps, FormulaResponse> & {
8
+ sourceId: string;
9
+ children: (props: import('./types').ModelResponse<FormulaResponse>) => React.ReactNode;
10
+ }): React.ReactElement;
11
+ (props: import('./types').ModelProps<FormulaWidgetProps, FormulaResponse> & {
12
+ sourcesId: string[];
13
+ children: (props: import('./types').ModelResponse<FormulaResponse[]>) => React.ReactNode;
14
+ }): React.ReactElement;
15
+ };
5
16
  export { useFormula, FormulaModel };
@@ -1,5 +1,16 @@
1
- import { HistogramRequestOptions, HistogramResponse } from '@carto/api-client';
2
- declare const useHistogram: ({ accessToken, sourceId, widgetProps, additionalFilter, useQueryProps: { enabled, ...useQueryProps }, }: import('./types').ModelProps<HistogramRequestOptions, HistogramResponse>) => import('@tanstack/react-query').UseQueryResult<HistogramResponse, Error>, HistogramModel: ({ children, ...modelProps }: import('./types').ModelProps<HistogramRequestOptions, HistogramResponse> & {
3
- children: (props: import('@tanstack/react-query').UseQueryResult<HistogramResponse, Error>) => React.ReactNode;
4
- }) => import('react').ReactNode;
1
+ import { HistogramResponse } from '@carto/api-client';
2
+ import { HistogramWidgetProps } from './types';
3
+ declare const useHistogram: <P extends import('./types').ModelProps<HistogramWidgetProps, HistogramResponse>>(props: P) => P extends {
4
+ sourceId: string;
5
+ sourcesId?: string[];
6
+ } ? import('./types').ModelResponse<HistogramResponse> : import('./types').ModelResponse<HistogramResponse[]>, HistogramModel: {
7
+ (props: import('./types').ModelProps<HistogramWidgetProps, HistogramResponse> & {
8
+ sourceId: string;
9
+ children: (props: import('./types').ModelResponse<HistogramResponse>) => React.ReactNode;
10
+ }): React.ReactElement;
11
+ (props: import('./types').ModelProps<HistogramWidgetProps, HistogramResponse> & {
12
+ sourcesId: string[];
13
+ children: (props: import('./types').ModelResponse<HistogramResponse[]>) => React.ReactNode;
14
+ }): React.ReactElement;
15
+ };
5
16
  export { useHistogram, HistogramModel };
@@ -1,5 +1,16 @@
1
- import { RangeRequestOptions, RangeResponse } from '@carto/api-client';
2
- declare const useRange: ({ accessToken, sourceId, widgetProps, additionalFilter, useQueryProps: { enabled, ...useQueryProps }, }: import('./types').ModelProps<RangeRequestOptions, RangeResponse>) => import('@tanstack/react-query').UseQueryResult<RangeResponse, Error>, RangeModel: ({ children, ...modelProps }: import('./types').ModelProps<RangeRequestOptions, RangeResponse> & {
3
- children: (props: import('@tanstack/react-query').UseQueryResult<RangeResponse, Error>) => React.ReactNode;
4
- }) => import('react').ReactNode;
1
+ import { RangeResponse } from '@carto/api-client';
2
+ import { RangeWidgetProps } from './types';
3
+ declare const useRange: <P extends import('./types').ModelProps<RangeWidgetProps, RangeResponse>>(props: P) => P extends {
4
+ sourceId: string;
5
+ sourcesId?: string[];
6
+ } ? import('./types').ModelResponse<RangeResponse> : import('./types').ModelResponse<RangeResponse[]>, RangeModel: {
7
+ (props: import('./types').ModelProps<RangeWidgetProps, RangeResponse> & {
8
+ sourceId: string;
9
+ children: (props: import('./types').ModelResponse<RangeResponse>) => React.ReactNode;
10
+ }): React.ReactElement;
11
+ (props: import('./types').ModelProps<RangeWidgetProps, RangeResponse> & {
12
+ sourcesId: string[];
13
+ children: (props: import('./types').ModelResponse<RangeResponse[]>) => React.ReactNode;
14
+ }): React.ReactElement;
15
+ };
5
16
  export { useRange, RangeModel };
@@ -1,5 +1,16 @@
1
- import { ScatterRequestOptions, ScatterResponse } from '@carto/api-client';
2
- declare const useScatter: ({ accessToken, sourceId, widgetProps, additionalFilter, useQueryProps: { enabled, ...useQueryProps }, }: import('./types').ModelProps<ScatterRequestOptions, ScatterResponse>) => import('@tanstack/react-query').UseQueryResult<ScatterResponse, Error>, ScatterModel: ({ children, ...modelProps }: import('./types').ModelProps<ScatterRequestOptions, ScatterResponse> & {
3
- children: (props: import('@tanstack/react-query').UseQueryResult<ScatterResponse, Error>) => React.ReactNode;
4
- }) => import('react').ReactNode;
1
+ import { ScatterResponse } from '@carto/api-client';
2
+ import { ScatterWidgetProps } from './types';
3
+ declare const useScatter: <P extends import('./types').ModelProps<ScatterWidgetProps, ScatterResponse>>(props: P) => P extends {
4
+ sourceId: string;
5
+ sourcesId?: string[];
6
+ } ? import('./types').ModelResponse<ScatterResponse> : import('./types').ModelResponse<ScatterResponse[]>, ScatterModel: {
7
+ (props: import('./types').ModelProps<ScatterWidgetProps, ScatterResponse> & {
8
+ sourceId: string;
9
+ children: (props: import('./types').ModelResponse<ScatterResponse>) => React.ReactNode;
10
+ }): React.ReactElement;
11
+ (props: import('./types').ModelProps<ScatterWidgetProps, ScatterResponse> & {
12
+ sourcesId: string[];
13
+ children: (props: import('./types').ModelResponse<ScatterResponse[]>) => React.ReactNode;
14
+ }): React.ReactElement;
15
+ };
5
16
  export { useScatter, ScatterModel };
@@ -1,5 +1,16 @@
1
- import { TableRequestOptions, TableResponse } from '@carto/api-client';
2
- declare const useTable: ({ accessToken, sourceId, widgetProps, additionalFilter, useQueryProps: { enabled, ...useQueryProps }, }: import('./types').ModelProps<TableRequestOptions, TableResponse>) => import('@tanstack/react-query').UseQueryResult<TableResponse, Error>, TableModel: ({ children, ...modelProps }: import('./types').ModelProps<TableRequestOptions, TableResponse> & {
3
- children: (props: import('@tanstack/react-query').UseQueryResult<TableResponse, Error>) => React.ReactNode;
4
- }) => import('react').ReactNode;
1
+ import { TableResponse } from '@carto/api-client';
2
+ import { TableWidgetProps } from './types';
3
+ declare const useTable: <P extends import('./types').ModelProps<TableWidgetProps, TableResponse>>(props: P) => P extends {
4
+ sourceId: string;
5
+ sourcesId?: string[];
6
+ } ? import('./types').ModelResponse<TableResponse> : import('./types').ModelResponse<TableResponse[]>, TableModel: {
7
+ (props: import('./types').ModelProps<TableWidgetProps, TableResponse> & {
8
+ sourceId: string;
9
+ children: (props: import('./types').ModelResponse<TableResponse>) => React.ReactNode;
10
+ }): React.ReactElement;
11
+ (props: import('./types').ModelProps<TableWidgetProps, TableResponse> & {
12
+ sourcesId: string[];
13
+ children: (props: import('./types').ModelResponse<TableResponse[]>) => React.ReactNode;
14
+ }): React.ReactElement;
15
+ };
5
16
  export { useTable, TableModel };
@@ -1,5 +1,16 @@
1
- import { TimeSeriesRequestOptions, TimeSeriesResponse } from '@carto/api-client';
2
- declare const useTimeSeries: ({ accessToken, sourceId, widgetProps, additionalFilter, useQueryProps: { enabled, ...useQueryProps }, }: import('./types').ModelProps<TimeSeriesRequestOptions, TimeSeriesResponse>) => import('@tanstack/react-query').UseQueryResult<TimeSeriesResponse, Error>, TimeSeriesModel: ({ children, ...modelProps }: import('./types').ModelProps<TimeSeriesRequestOptions, TimeSeriesResponse> & {
3
- children: (props: import('@tanstack/react-query').UseQueryResult<TimeSeriesResponse, Error>) => React.ReactNode;
4
- }) => import('react').ReactNode;
1
+ import { TimeSeriesResponse } from '@carto/api-client';
2
+ import { TimeSeriesWidgetProps } from './types';
3
+ declare const useTimeSeries: <P extends import('./types').ModelProps<TimeSeriesWidgetProps, TimeSeriesResponse>>(props: P) => P extends {
4
+ sourceId: string;
5
+ sourcesId?: string[];
6
+ } ? import('./types').ModelResponse<TimeSeriesResponse> : import('./types').ModelResponse<TimeSeriesResponse[]>, TimeSeriesModel: {
7
+ (props: import('./types').ModelProps<TimeSeriesWidgetProps, TimeSeriesResponse> & {
8
+ sourceId: string;
9
+ children: (props: import('./types').ModelResponse<TimeSeriesResponse>) => React.ReactNode;
10
+ }): React.ReactElement;
11
+ (props: import('./types').ModelProps<TimeSeriesWidgetProps, TimeSeriesResponse> & {
12
+ sourcesId: string[];
13
+ children: (props: import('./types').ModelResponse<TimeSeriesResponse[]>) => React.ReactNode;
14
+ }): React.ReactElement;
15
+ };
5
16
  export { useTimeSeries, TimeSeriesModel };
@@ -1,9 +1,168 @@
1
- import { AddFilterOptions } from '@carto/api-client';
2
- import { UseQueryOptions } from '@tanstack/react-query';
3
- export interface ModelProps<T, R> {
1
+ import { RefetchOptions, UseQueryResult, UseQueryOptions } from '@tanstack/react-query';
2
+ import { AddFilterOptions, FormulaRequestOptions, CategoryRequestOptions, TimeSeriesRequestOptions, HistogramRequestOptions, AggregationsRequestOptions, RangeRequestOptions, ScatterRequestOptions, TableRequestOptions, FeaturesRequestOptions } from '@carto/api-client';
3
+ /**
4
+ * Helper type for multi-value support in Formula widget props.
5
+ * Formula has: column (optional), operationExp (optional)
6
+ *
7
+ * @since 4.6.0
8
+ */
9
+ export type FormulaWidgetProps = Omit<FormulaRequestOptions, 'filters' | 'column' | 'operationExp'> & {
10
+ column?: string | string[];
11
+ operationExp?: string | string[];
12
+ };
13
+ /**
14
+ * Helper type for multi-value support in Category widget props.
15
+ * Category has: column (required), operationExp (optional), operationColumn (optional)
16
+ *
17
+ * @since 4.6.0
18
+ */
19
+ export type CategoryWidgetProps = Omit<CategoryRequestOptions, 'filters' | 'column' | 'operationExp' | 'operationColumn'> & {
20
+ column: string | string[];
21
+ operationExp?: string | string[];
22
+ operationColumn?: string | string[];
23
+ };
24
+ /**
25
+ * Helper type for multi-value support in TimeSeries widget props.
26
+ * TimeSeries has: column (required), operationExp (optional), operationColumn (optional)
27
+ *
28
+ * @since 4.6.0
29
+ */
30
+ export type TimeSeriesWidgetProps = Omit<TimeSeriesRequestOptions, 'filters' | 'column' | 'operationExp' | 'operationColumn'> & {
31
+ column: string | string[];
32
+ operationExp?: string | string[];
33
+ operationColumn?: string | string[];
34
+ };
35
+ /**
36
+ * Helper type for multi-value support in Histogram widget props.
37
+ * Histogram has: column (required), NO operationExp, NO operationColumn
38
+ *
39
+ * @since 4.6.0
40
+ */
41
+ export type HistogramWidgetProps = Omit<HistogramRequestOptions, 'filters' | 'column'> & {
42
+ column: string | string[];
43
+ };
44
+ /**
45
+ * Helper type for multi-value support in Aggregations widget props.
46
+ * Aggregations has: aggregations (array/string), NO column, NO operationExp
47
+ *
48
+ * @since 4.6.0
49
+ */
50
+ export type AggregationsWidgetProps = Omit<AggregationsRequestOptions, 'filters'>;
51
+ /**
52
+ * Helper type for multi-value support in Range widget props.
53
+ * Range has: column (required), NO operationExp, NO operationColumn
54
+ *
55
+ * @since 4.6.0
56
+ */
57
+ export type RangeWidgetProps = Omit<RangeRequestOptions, 'filters' | 'column'> & {
58
+ column: string | string[];
59
+ };
60
+ /**
61
+ * Helper type for multi-value support in Scatter widget props.
62
+ * Scatter has: xColumn, yColumn (both required), NO operationExp
63
+ *
64
+ * @since 4.6.0
65
+ */
66
+ export type ScatterWidgetProps = Omit<ScatterRequestOptions, 'filters' | 'xColumn' | 'yColumn'> & {
67
+ xColumn: string | string[];
68
+ yColumn: string | string[];
69
+ };
70
+ /**
71
+ * Helper type for multi-value support in Table widget props.
72
+ * Table has: columns (optional array), NO operationExp
73
+ *
74
+ * @since 4.6.0
75
+ */
76
+ export type TableWidgetProps = Omit<TableRequestOptions, 'filters'>;
77
+ /**
78
+ * Helper type for multi-value support in Features widget props.
79
+ * Features has: NO column, NO operationExp
80
+ *
81
+ * @since 4.6.0
82
+ */
83
+ export type FeaturesWidgetProps = Omit<FeaturesRequestOptions, 'filters'>;
84
+ /**
85
+ * @deprecated Use specific widget props types (FormulaWidgetProps, CategoryWidgetProps, etc.) instead.
86
+ * This generic type assumes all widgets have the same properties, which is incorrect.
87
+ * @since 4.5.0
88
+ */
89
+ export type WidgetPropsWithMultiColumn<T> = Omit<T, 'filters' | 'column' | 'operationExp' | 'operationColumn'> & {
90
+ column?: string | string[];
91
+ operationExp?: string | string[];
92
+ operationColumn?: string | string[];
93
+ };
94
+ /**
95
+ * Props for CARTO model components and hooks.
96
+ *
97
+ * @template W - Widget-specific props type (FormulaWidgetProps, CategoryWidgetProps, etc.)
98
+ * @template R - Widget response data type
99
+ *
100
+ * @remarks
101
+ * All CARTO model components (FormulaModel, CategoriesModel, etc.) use these props.
102
+ * Supports both single-source and multi-source queries with flexible column configuration.
103
+ *
104
+ * @example
105
+ * ```tsx
106
+ * Single source (deprecated)
107
+ * <FormulaModel
108
+ * accessToken={token}
109
+ * sourceId="sales"
110
+ * widgetProps={{ column: 'revenue', operation: 'sum' }}
111
+ * />
112
+ *
113
+ * Multiple sources (recommended)
114
+ * <FormulaModel
115
+ * accessToken={token}
116
+ * sourcesId={['sales_2023', 'sales_2024']}
117
+ * widgetProps={{ column: 'revenue', operation: 'sum' }}
118
+ * />
119
+ *
120
+ * Multiple sources with different columns
121
+ * <FormulaModel
122
+ * accessToken={token}
123
+ * sourcesId={['sales', 'inventory', 'customers']}
124
+ * widgetProps={{
125
+ * column: ['total_sales', 'stock_count', 'active_users'],
126
+ * operation: 'sum'
127
+ * }}
128
+ * />
129
+ * ```
130
+ *
131
+ * @since 4.6.0 - Changed to use specific widget props types
132
+ */
133
+ export type ModelProps<W, R> = {
134
+ /** CARTO API access token for authentication */
4
135
  accessToken: string;
5
- sourceId: string;
6
- widgetProps: Omit<T, 'filters'>;
7
- additionalFilter?: AddFilterOptions[];
136
+ /** Widget-specific configuration with multi-value support for applicable properties */
137
+ widgetProps: W;
138
+ /** Optional additional filters to apply to the query */
139
+ additionalFilter?: AddFilterOptions[] | AddFilterOptions[][];
140
+ /** React Query configuration options */
8
141
  useQueryProps?: Omit<UseQueryOptions<R>, 'queryKey' | 'queryFn'>;
9
- }
142
+ } & ({
143
+ /**
144
+ * @deprecated Use `sourcesId` instead. Will be removed in v5.0.0.
145
+ * @see {@link sourcesId}
146
+ */
147
+ sourceId: string;
148
+ /**
149
+ * Array of source identifiers for multi-source queries (recommended).
150
+ * @since 4.0.0
151
+ */
152
+ sourcesId?: string[];
153
+ } | {
154
+ /**
155
+ * @deprecated Use `sourcesId` instead. Will be removed in v5.0.0.
156
+ * @see {@link sourcesId}
157
+ */
158
+ sourceId?: string;
159
+ /**
160
+ * Array of source identifiers for multi-source queries (recommended).
161
+ * @since 4.0.0
162
+ */
163
+ sourcesId: string[];
164
+ });
165
+ export type ModelResponse<T = unknown[]> = Pick<UseQueryResult<T, Error>, 'data' | 'error' | 'isLoading' | 'isFetching' | 'isError' | 'isSuccess' | 'status' | 'fetchStatus' | 'isPending' | 'isStale' | 'isRefetching' | 'isFetched' | 'isFetchedAfterMount' | 'isRefetchError' | 'isLoadingError' | 'isPlaceholderData' | 'failureCount' | 'dataUpdatedAt' | 'errorUpdatedAt' | 'isPaused' | 'failureReason' | 'errorUpdateCount' | 'isEnabled'> & {
166
+ promise: Promise<T[]>[];
167
+ refetch: () => Promise<RefetchOptions[]>;
168
+ };
@@ -1,17 +1,26 @@
1
- import { UseQueryResult } from '@tanstack/react-query';
2
- import { ModelProps } from '../types';
1
+ import { ModelProps, ModelResponse } from '../types';
3
2
  import { useCommonModel } from './use-common-model';
4
- interface ModelConfig<TRequestOptions, TResponse> {
3
+ interface ModelConfig<TRequestOptions extends object, TResponse> {
5
4
  queryKeyPrefix: string[];
6
- getWidgetMethod: (widgetModel: NonNullable<ReturnType<typeof useCommonModel>['widgetModel']>) => (params: TRequestOptions & {
5
+ getWidgetMethod: (widgetModel: NonNullable<NonNullable<ReturnType<typeof useCommonModel>['widgetModel']>[0]>) => (params: TRequestOptions & {
7
6
  filters?: unknown;
8
7
  signal?: AbortSignal;
9
8
  }) => Promise<TResponse>;
10
9
  }
11
- export declare function createModel<TRequestOptions, TResponse>({ queryKeyPrefix, getWidgetMethod, }: ModelConfig<TRequestOptions, TResponse>): {
12
- useModelHook: ({ accessToken, sourceId, widgetProps, additionalFilter, useQueryProps: { enabled, ...useQueryProps }, }: ModelProps<TRequestOptions, TResponse>) => UseQueryResult<import('@tanstack/react-query').NoInfer<TResponse>, Error>;
13
- ModelComponent: ({ children, ...modelProps }: ModelProps<TRequestOptions, TResponse> & {
14
- children: (props: UseQueryResult<TResponse, Error>) => React.ReactNode;
15
- }) => import('react').ReactNode;
10
+ export declare function createModel<TWidgetProps extends object, TResponse>({ queryKeyPrefix, getWidgetMethod, }: ModelConfig<TWidgetProps, TResponse>): {
11
+ useModelHook: <P extends ModelProps<TWidgetProps, TResponse>>(props: P) => P extends {
12
+ sourceId: string;
13
+ sourcesId?: string[];
14
+ } ? ModelResponse<TResponse> : ModelResponse<TResponse[]>;
15
+ ModelComponent: {
16
+ (props: ModelProps<TWidgetProps, TResponse> & {
17
+ sourceId: string;
18
+ children: (props: ModelResponse<TResponse>) => React.ReactNode;
19
+ }): React.ReactElement;
20
+ (props: ModelProps<TWidgetProps, TResponse> & {
21
+ sourcesId: string[];
22
+ children: (props: ModelResponse<TResponse[]>) => React.ReactNode;
23
+ }): React.ReactElement;
24
+ };
16
25
  };
17
26
  export {};
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Resolves a property value for a specific source index
3
+ * @param value - Single string value or array of values
4
+ * @param sourceIndex - Index of the current source
5
+ * @param totalSources - Total number of sources
6
+ * @param propertyName - Name of the property being resolved (for error messages)
7
+ * @returns The resolved string value for the source
8
+ * @internal
9
+ */
10
+ export declare function resolvePropertyForSource(value: string | string[] | undefined, sourceIndex: number, totalSources: number, propertyName: string): string | undefined;
11
+ /**
12
+ * Resolves the column value for a specific source index
13
+ * @param column - Single column string or array of columns
14
+ * @param sourceIndex - Index of the current source
15
+ * @param totalSources - Total number of sources
16
+ * @returns The resolved column string for the source
17
+ * @internal
18
+ */
19
+ export declare function resolveColumnForSource(column: string | string[] | undefined, sourceIndex: number, totalSources: number): string | undefined;
@@ -1,8 +1,27 @@
1
1
  import { ModelProps } from '../types';
2
- export declare function useCommonModel<TRequestOptions, TResponse>({ queryKeyPrefix, accessToken, sourceId, widgetProps, additionalFilter, }: Pick<ModelProps<TRequestOptions, TResponse>, 'accessToken' | 'sourceId' | 'additionalFilter' | 'widgetProps'> & {
2
+ import { useWidgetModel } from './use-widget-model';
3
+ import { Filter } from '@carto/api-client';
4
+ type CommonModelArgs<TRequestOptions, TResponse> = Pick<ModelProps<TRequestOptions, TResponse>, 'accessToken' | 'widgetProps' | 'additionalFilter'> & {
3
5
  queryKeyPrefix: string[];
4
- }): {
5
- mergedFilters: {} | undefined;
6
- widgetModel: import('@carto/api-client').WidgetQuerySource | import('@carto/api-client').WidgetTilesetSource<import('@carto/api-client').WidgetTilesetSourceProps> | import('@carto/api-client').WidgetTableSource | null;
7
- queryKey: unknown[];
8
6
  };
7
+ type SingleSourceArgs<TRequestOptions, TResponse> = CommonModelArgs<TRequestOptions, TResponse> & {
8
+ sourceId: string;
9
+ sourcesId?: never;
10
+ };
11
+ type MultiSourceArgs<TRequestOptions, TResponse> = CommonModelArgs<TRequestOptions, TResponse> & {
12
+ sourceId?: never;
13
+ sourcesId: string[];
14
+ };
15
+ interface SingleSourceResult {
16
+ mergedFilters: Filter | undefined;
17
+ widgetModel: ReturnType<typeof useWidgetModel>[0] | null;
18
+ queryKey: readonly unknown[];
19
+ }
20
+ interface MultiSourceResult {
21
+ mergedFilters: (Filter | undefined)[];
22
+ widgetModel: ReturnType<typeof useWidgetModel>;
23
+ queryKey: unknown[][];
24
+ }
25
+ export declare function useCommonModel<TRequestOptions extends object, TResponse>(args: SingleSourceArgs<TRequestOptions, TResponse>): SingleSourceResult;
26
+ export declare function useCommonModel<TRequestOptions extends object, TResponse>(args: MultiSourceArgs<TRequestOptions, TResponse>): MultiSourceResult;
27
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,2 +1,16 @@
1
- import { AddFilterOptions } from '@carto/api-client';
2
- export declare function useFiltersMerged(sourceId: string, additionalFilter?: AddFilterOptions[]): {} | undefined;
1
+ import { Filter, AddFilterOptions } from '@carto/api-client';
2
+ interface SingleSourceFilterArgs {
3
+ sourceId: string;
4
+ sourcesId?: never;
5
+ additionalFilter?: AddFilterOptions[];
6
+ }
7
+ interface MultiSourceFilterArgs {
8
+ sourceId?: never;
9
+ sourcesId: string[];
10
+ additionalFilter?: AddFilterOptions[] | AddFilterOptions[][];
11
+ }
12
+ export declare function useFiltersMerged(sourceId: string, additionalFilter?: AddFilterOptions[]): Filter | undefined;
13
+ export declare function useFiltersMerged(sourcesId: string[], additionalFilter?: AddFilterOptions[] | AddFilterOptions[][]): Filter[] | undefined;
14
+ export declare function useFiltersMerged(args: SingleSourceFilterArgs): Filter | undefined;
15
+ export declare function useFiltersMerged(args: MultiSourceFilterArgs): Filter[] | undefined;
16
+ export {};
@@ -1,4 +1,15 @@
1
1
  import { ModelProps } from '../types';
2
- export declare function useQueryKey<TRequestOptions, TResponse>({ queryKeyPrefix, sourceId, }: Pick<ModelProps<TRequestOptions, TResponse>, 'sourceId'> & {
2
+ type QueryKeyArgs<TRequestOptions, TResponse> = Pick<ModelProps<TRequestOptions, TResponse>, never> & {
3
3
  queryKeyPrefix: string[];
4
- }): unknown[];
4
+ };
5
+ type SingleSourceQueryArgs<TRequestOptions, TResponse> = QueryKeyArgs<TRequestOptions, TResponse> & {
6
+ sourceId: string | undefined;
7
+ sourcesId?: never;
8
+ };
9
+ type MultiSourceQueryArgs<TRequestOptions, TResponse> = QueryKeyArgs<TRequestOptions, TResponse> & {
10
+ sourceId?: never;
11
+ sourcesId: string[];
12
+ };
13
+ export declare function useQueryKey<TRequestOptions, TResponse>(args: SingleSourceQueryArgs<TRequestOptions, TResponse>): readonly unknown[];
14
+ export declare function useQueryKey<TRequestOptions, TResponse>(args: MultiSourceQueryArgs<TRequestOptions, TResponse>): unknown[][];
15
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +1,18 @@
1
- export declare function useWidgetModel(accessToken: string, sourceId: string): import('@carto/api-client').WidgetQuerySource | import('@carto/api-client').WidgetTilesetSource<import('@carto/api-client').WidgetTilesetSourceProps> | import('@carto/api-client').WidgetTableSource | null;
1
+ import { useSources } from '../../providers/sources/store';
2
+ type SourceWidget = ReturnType<typeof useSources>[0]['widgets'];
3
+ type WidgetModelResult = SourceWidget | null;
4
+ interface SingleSourceWidgetArgs {
5
+ accessToken: string;
6
+ sourceId: string;
7
+ sourcesId?: never;
8
+ }
9
+ interface MultiSourceWidgetArgs {
10
+ accessToken: string;
11
+ sourceId?: never;
12
+ sourcesId: string[];
13
+ }
14
+ export declare function useWidgetModel(accessToken: string, sourceId: string): WidgetModelResult;
15
+ export declare function useWidgetModel(accessToken: string, sourcesId: string[]): WidgetModelResult[];
16
+ export declare function useWidgetModel(args: SingleSourceWidgetArgs): WidgetModelResult;
17
+ export declare function useWidgetModel(args: MultiSourceWidgetArgs): WidgetModelResult[];
18
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -23,12 +23,19 @@ export declare const useSourceStore: import('zustand').UseBoundStore<Omit<import
23
23
  * @returns source object without filters
24
24
  */
25
25
  export declare function useSource<T extends AllSources = AllExternalSources>(id: string): Source<T>;
26
+ /**
27
+ * Shortcut to grabbing the source from the sources store object
28
+ * @param ids - the ids of the sources you want to grab
29
+ * @returns source object without filters
30
+ */
31
+ export declare function useSources<T extends AllSources = AllExternalSources>(ids: string[]): Source<T>[];
26
32
  /**
27
33
  * Shortcut to grabbing the filters from the filters store object
28
- * @param id - the id of the source the filters are applied to
34
+ * @param ids - the ids of the sources the filters are applied to
29
35
  * @returns filters object as used in the `@carto/api-client` methods calls
30
36
  */
31
- export declare function useFilters(id: string): Filters | undefined;
37
+ export declare function useFilters(ids: string): Filters | undefined;
38
+ export declare function useFilters(ids: string[]): (Filters | undefined)[];
32
39
  /**
33
40
  * Returns a source together with its filters, pulling from the separate `sources` and `filters` state objects
34
41
  * @param id - the id of the source
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};