@carto/api-client 0.5.0-alpha.2 → 0.5.0-alpha.4

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 (110) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/api/carto-api-error.d.ts +1 -1
  3. package/build/api/query.d.ts +1 -1
  4. package/build/api/request-with-parameters.d.ts +2 -2
  5. package/build/api-client.cjs +2380 -2508
  6. package/build/api-client.cjs.map +1 -1
  7. package/build/api-client.modern.js +2220 -2349
  8. package/build/api-client.modern.js.map +1 -1
  9. package/build/client.d.ts +2 -2
  10. package/build/constants-internal.d.ts +5 -5
  11. package/build/constants.d.ts +6 -6
  12. package/build/deck/get-data-filter-extension-props.d.ts +18 -0
  13. package/build/deck/index.d.ts +1 -0
  14. package/build/filters/Filter.d.ts +15 -3
  15. package/build/filters/FilterTypes.d.ts +1 -1
  16. package/build/filters/geosjonFeatures.d.ts +2 -2
  17. package/build/filters/tileFeatures.d.ts +10 -9
  18. package/build/filters/tileFeaturesRaster.d.ts +16 -0
  19. package/build/filters.d.ts +2 -2
  20. package/build/geo.d.ts +1 -1
  21. package/build/index.d.ts +2 -0
  22. package/build/models/common.d.ts +4 -3
  23. package/build/models/model.d.ts +2 -2
  24. package/build/operations/aggregation.d.ts +5 -5
  25. package/build/operations/applySorting.d.ts +3 -3
  26. package/build/operations/groupBy.d.ts +4 -4
  27. package/build/operations/groupByDate.d.ts +1 -1
  28. package/build/operations/histogram.d.ts +3 -3
  29. package/build/operations/scatterPlot.d.ts +3 -3
  30. package/build/sources/base-source.d.ts +2 -2
  31. package/build/sources/boundary-query-source.d.ts +1 -1
  32. package/build/sources/boundary-table-source.d.ts +1 -1
  33. package/build/sources/h3-query-source.d.ts +2 -2
  34. package/build/sources/h3-table-source.d.ts +2 -2
  35. package/build/sources/h3-tileset-source.d.ts +2 -2
  36. package/build/sources/index.d.ts +26 -26
  37. package/build/sources/quadbin-query-source.d.ts +2 -2
  38. package/build/sources/quadbin-table-source.d.ts +2 -2
  39. package/build/sources/quadbin-tileset-source.d.ts +2 -2
  40. package/build/sources/raster-source.d.ts +3 -2
  41. package/build/sources/types.d.ts +4 -4
  42. package/build/sources/vector-query-source.d.ts +1 -1
  43. package/build/sources/vector-table-source.d.ts +1 -1
  44. package/build/sources/vector-tileset-source.d.ts +2 -2
  45. package/build/spatial-index.d.ts +10 -4
  46. package/build/types-internal.d.ts +5 -5
  47. package/build/types.d.ts +23 -15
  48. package/build/utils/makeIntervalComplete.d.ts +1 -1
  49. package/build/utils.d.ts +3 -3
  50. package/build/widget-sources/index.d.ts +1 -0
  51. package/build/widget-sources/types.d.ts +4 -2
  52. package/build/widget-sources/widget-query-source.d.ts +2 -1
  53. package/build/widget-sources/widget-raster-source.d.ts +11 -0
  54. package/build/widget-sources/widget-remote-source.d.ts +3 -0
  55. package/build/widget-sources/widget-source.d.ts +3 -3
  56. package/build/widget-sources/widget-table-source.d.ts +2 -1
  57. package/build/widget-sources/widget-tileset-source.d.ts +21 -22
  58. package/package.json +44 -32
  59. package/src/api/carto-api-error.ts +1 -1
  60. package/src/api/query.ts +5 -5
  61. package/src/api/request-with-parameters.ts +6 -6
  62. package/src/client.ts +3 -3
  63. package/src/constants-internal.ts +5 -5
  64. package/src/constants.ts +6 -6
  65. package/src/deck/get-data-filter-extension-props.ts +146 -0
  66. package/src/deck/index.ts +1 -0
  67. package/src/filters/Filter.ts +18 -8
  68. package/src/filters/FilterTypes.ts +2 -2
  69. package/src/filters/geosjonFeatures.ts +2 -2
  70. package/src/filters/tileFeatures.ts +33 -23
  71. package/src/filters/tileFeaturesRaster.ts +111 -0
  72. package/src/filters.ts +4 -4
  73. package/src/geo.ts +12 -14
  74. package/src/index.ts +3 -0
  75. package/src/models/common.ts +9 -7
  76. package/src/models/model.ts +3 -4
  77. package/src/operations/aggregation.ts +5 -5
  78. package/src/operations/applySorting.ts +4 -4
  79. package/src/operations/groupBy.ts +4 -4
  80. package/src/operations/groupByDate.ts +1 -1
  81. package/src/operations/histogram.ts +4 -4
  82. package/src/operations/scatterPlot.ts +4 -4
  83. package/src/sources/base-source.ts +8 -8
  84. package/src/sources/boundary-query-source.ts +2 -2
  85. package/src/sources/boundary-table-source.ts +2 -2
  86. package/src/sources/h3-query-source.ts +7 -5
  87. package/src/sources/h3-table-source.ts +7 -5
  88. package/src/sources/h3-tileset-source.ts +4 -4
  89. package/src/sources/index.ts +26 -26
  90. package/src/sources/quadbin-query-source.ts +7 -5
  91. package/src/sources/quadbin-table-source.ts +7 -5
  92. package/src/sources/quadbin-tileset-source.ts +4 -4
  93. package/src/sources/raster-source.ts +20 -7
  94. package/src/sources/types.ts +4 -4
  95. package/src/sources/vector-query-source.ts +2 -3
  96. package/src/sources/vector-table-source.ts +2 -3
  97. package/src/sources/vector-tileset-source.ts +5 -5
  98. package/src/spatial-index.ts +12 -10
  99. package/src/types-internal.ts +5 -5
  100. package/src/types.ts +21 -15
  101. package/src/utils/makeIntervalComplete.ts +1 -1
  102. package/src/utils.ts +3 -3
  103. package/src/widget-sources/index.ts +1 -0
  104. package/src/widget-sources/types.ts +5 -3
  105. package/src/widget-sources/widget-query-source.ts +6 -2
  106. package/src/widget-sources/widget-raster-source.ts +14 -0
  107. package/src/widget-sources/widget-remote-source.ts +31 -16
  108. package/src/widget-sources/widget-source.ts +13 -4
  109. package/src/widget-sources/widget-table-source.ts +6 -2
  110. package/src/widget-sources/widget-tileset-source.ts +133 -85
package/src/types.ts CHANGED
@@ -6,10 +6,10 @@ import type {BinaryFeature, BinaryFeatureCollection} from '@loaders.gl/schema';
6
6
  * MAPS AND TILES
7
7
  */
8
8
 
9
- /** @internalRemarks Source: @deck.gl/carto */
9
+ /** @privateRemarks Source: @deck.gl/carto */
10
10
  export type Format = 'json' | 'geojson' | 'tilejson';
11
11
 
12
- /** @internalRemarks Source: @carto/constants, @deck.gl/carto */
12
+ /** @privateRemarks Source: @carto/constants, @deck.gl/carto */
13
13
  export type MapType = 'boundary' | 'query' | 'table' | 'tileset' | 'raster';
14
14
 
15
15
  /**
@@ -23,7 +23,7 @@ export type Viewport = [number, number, number, number];
23
23
  * required for local widget calculations. Deeper dependencies on deck.gl
24
24
  * APIs should be minimized within this library: @deck.gl/carto depends
25
25
  * on the API client, not the other way around.
26
- * @internalRemarks Source: @deck.gl/geo-layers
26
+ * @privateRemarks Source: @deck.gl/geo-layers
27
27
  */
28
28
  export type Tile = {
29
29
  index: {x: number; y: number; z: number};
@@ -40,7 +40,13 @@ export type SpatialIndexTile = Tile & {
40
40
  data?: (Feature & {id: bigint})[];
41
41
  };
42
42
 
43
- /** @internalRemarks Source: @deck.gl/carto */
43
+ export type RasterTile = Tile & {
44
+ id: string;
45
+ index: {q: bigint; i: string};
46
+ data?: Raster;
47
+ };
48
+
49
+ /** @privateRemarks Source: @deck.gl/carto */
44
50
  export type Raster = {
45
51
  blockSize: number;
46
52
  cells: {
@@ -56,8 +62,8 @@ export type Raster = {
56
62
  /**
57
63
  * Enum for the different types of aggregations available for widgets.
58
64
  *
59
- * @internalRemarks Source: @carto/constants
60
- * @internalRemarks Converted from enum to type union, for improved declarative API.
65
+ * @privateRemarks Source: @carto/constants
66
+ * @privateRemarks Converted from enum to type union, for improved declarative API.
61
67
  */
62
68
  export type AggregationType =
63
69
  | 'count'
@@ -71,15 +77,15 @@ export type AggregationType =
71
77
  * FILTERS
72
78
  */
73
79
 
74
- /** @internalRemarks Source: @carto/react-api */
80
+ /** @privateRemarks Source: @carto/react-api */
75
81
  export type SpatialFilter = Polygon | MultiPolygon;
76
82
 
77
- /** @internalRemarks Source: @deck.gl/carto */
83
+ /** @privateRemarks Source: @deck.gl/carto */
78
84
  export interface Filters {
79
85
  [column: string]: Filter;
80
86
  }
81
87
 
82
- /** @internalRemarks Source: @carto/react-api, @deck.gl/carto */
88
+ /** @privateRemarks Source: @carto/react-api, @deck.gl/carto */
83
89
  export interface Filter {
84
90
  [FilterType.IN]?: {owner?: string; values: number[] | string[]};
85
91
  /** [a, b] both are included. */
@@ -94,7 +100,7 @@ export interface Filter {
94
100
  };
95
101
  }
96
102
 
97
- /** @internalRemarks Source: @carto/react-core */
103
+ /** @privateRemarks Source: @carto/react-core */
98
104
  export type FilterLogicalOperator = 'and' | 'or';
99
105
 
100
106
  /**
@@ -120,7 +126,7 @@ export type StringSearchOptions = {
120
126
  /**
121
127
  * Defines a step size increment for use with {@link TimeSeriesRequestOptions}.
122
128
  *
123
- * @internalRemarks Source: @carto/react-core
129
+ * @privateRemarks Source: @carto/react-core
124
130
  */
125
131
  export type GroupDateType =
126
132
  | 'year'
@@ -142,7 +148,7 @@ export type SortColumnType = 'number' | 'string' | 'date';
142
148
  * SQL QUERY PARAMETERS
143
149
  */
144
150
 
145
- /** @internalRemarks Source: @deck.gl/carto */
151
+ /** @privateRemarks Source: @deck.gl/carto */
146
152
  export type QueryParameterValue =
147
153
  | string
148
154
  | number
@@ -150,11 +156,11 @@ export type QueryParameterValue =
150
156
  | Array<QueryParameterValue>
151
157
  | object;
152
158
 
153
- /** @internalRemarks Source: @deck.gl/carto */
159
+ /** @privateRemarks Source: @deck.gl/carto */
154
160
  export type NamedQueryParameter = Record<string, QueryParameterValue>;
155
161
 
156
- /** @internalRemarks Source: @deck.gl/carto */
162
+ /** @privateRemarks Source: @deck.gl/carto */
157
163
  export type PositionalQueryParameter = QueryParameterValue[];
158
164
 
159
- /** @internalRemarks Source: @deck.gl/carto */
165
+ /** @privateRemarks Source: @deck.gl/carto */
160
166
  export type QueryParameters = NamedQueryParameter | PositionalQueryParameter;
@@ -1,4 +1,4 @@
1
- import {FilterInterval, FilterIntervalComplete} from '../types';
1
+ import {FilterInterval, FilterIntervalComplete} from '../types.js';
2
2
 
3
3
  export function makeIntervalComplete(
4
4
  intervals: FilterInterval[]
package/src/utils.ts CHANGED
@@ -39,7 +39,7 @@ type Row<T> = Record<string, T> | Record<string, T>[] | T[] | T;
39
39
  * Due to each data warehouse having its own behavior with columns,
40
40
  * we need to normalize them and transform every key to lowercase.
41
41
  *
42
- * @internalRemarks Source: @carto/react-widgets
42
+ * @privateRemarks Source: @carto/react-widgets
43
43
  * @internal
44
44
  */
45
45
  export function normalizeObjectKeys<T, R extends Row<T>>(el: R): R {
@@ -59,7 +59,7 @@ export function normalizeObjectKeys<T, R extends Row<T>>(el: R): R {
59
59
  ) as R;
60
60
  }
61
61
 
62
- /** @internalRemarks Source: @carto/react-core */
62
+ /** @privateRemarks Source: @carto/react-core */
63
63
  export function assert(condition: unknown, message: string): asserts condition {
64
64
  if (!condition) {
65
65
  throw new Error(message);
@@ -67,7 +67,7 @@ export function assert(condition: unknown, message: string): asserts condition {
67
67
  }
68
68
 
69
69
  /**
70
- * @internalRemarks Source: @carto/react-core
70
+ * @privateRemarks Source: @carto/react-core
71
71
  * @internal
72
72
  */
73
73
  export class InvalidColumnError extends Error {
@@ -1,5 +1,6 @@
1
1
  export * from './widget-source.js';
2
2
  export * from './widget-query-source.js';
3
+ export * from './widget-raster-source.js';
3
4
  export * from './widget-remote-source.js';
4
5
  export * from './widget-table-source.js';
5
6
  export * from './widget-tileset-source.js';
@@ -1,11 +1,11 @@
1
- import {SpatialFilterPolyfillMode, TileResolution} from '../sources/types';
1
+ import {SpatialFilterPolyfillMode, TileResolution} from '../sources/types.js';
2
2
  import {
3
+ Filters,
3
4
  GroupDateType,
4
5
  SortColumnType,
5
6
  SortDirection,
6
7
  SpatialFilter,
7
- } from '../types';
8
- import type {WidgetRemoteSource} from './widget-remote-source';
8
+ } from '../types.js';
9
9
 
10
10
  /******************************************************************************
11
11
  * WIDGET API REQUESTS
@@ -24,6 +24,8 @@ interface BaseRequestOptions {
24
24
  /** Required for table- and query-based spatial index sources (H3, Quadbin). */
25
25
  spatialIndexReferenceViewState?: ViewState;
26
26
  abortController?: AbortController;
27
+ /** Overrides source filters, if any. */
28
+ filters?: Filters;
27
29
  filterOwner?: string;
28
30
  }
29
31
 
@@ -8,6 +8,7 @@ import {
8
8
  WidgetRemoteSourceProps,
9
9
  } from './widget-remote-source.js';
10
10
  import {ModelSource} from '../models/model.js';
11
+ import {Filters} from '../types.js';
11
12
 
12
13
  type LayerQuerySourceOptions =
13
14
  | Omit<VectorQuerySourceOptions, 'filters'>
@@ -41,9 +42,12 @@ export type WidgetQuerySourceResult = {widgetSource: WidgetQuerySource};
41
42
  export class WidgetQuerySource extends WidgetRemoteSource<
42
43
  LayerQuerySourceOptions & WidgetRemoteSourceProps
43
44
  > {
44
- protected override getModelSource(owner: string): ModelSource {
45
+ protected override getModelSource(
46
+ filters: Filters | undefined,
47
+ filterOwner?: string
48
+ ): ModelSource {
45
49
  return {
46
- ...super._getModelSource(owner),
50
+ ...super._getModelSource(filters, filterOwner),
47
51
  type: 'query',
48
52
  data: this.props.sqlQuery,
49
53
  queryParameters: this.props.queryParameters,
@@ -0,0 +1,14 @@
1
+ import {RasterMetadata} from '../sources/index.js';
2
+ import {
3
+ WidgetTilesetSource,
4
+ WidgetTilesetSourceProps,
5
+ } from './widget-tileset-source.js';
6
+
7
+ export type WidgetRasterSourceProps = WidgetTilesetSourceProps & {
8
+ rasterMetadata: RasterMetadata;
9
+ spatialDataType: 'quadbin';
10
+ };
11
+
12
+ export type WidgetRasterSourceResult = {widgetSource: WidgetRasterSource};
13
+
14
+ export class WidgetRasterSource extends WidgetTilesetSource<WidgetRasterSourceProps> {}
@@ -31,10 +31,18 @@ export type WidgetRemoteSourceProps = WidgetSourceProps;
31
31
  export abstract class WidgetRemoteSource<
32
32
  Props extends WidgetRemoteSourceProps,
33
33
  > extends WidgetSource<Props> {
34
+ protected _headers: Record<string, string> = {};
35
+
36
+ /** Assigns HTTP headers to be included on API requests from this source. */
37
+ setRequestHeaders(headers: Record<string, string>): void {
38
+ this._headers = headers;
39
+ }
40
+
34
41
  async getCategories(
35
42
  options: CategoryRequestOptions
36
43
  ): Promise<CategoryResponse> {
37
44
  const {
45
+ filters = this.props.filters,
38
46
  filterOwner,
39
47
  spatialFilter,
40
48
  spatialFiltersMode,
@@ -43,7 +51,7 @@ export abstract class WidgetRemoteSource<
43
51
  ...params
44
52
  } = options;
45
53
  const {column, operation, operationColumn} = params;
46
- const source = this.getModelSource(filterOwner);
54
+ const source = this.getModelSource(filters, filterOwner);
47
55
  const spatialFiltersResolution = this._getSpatialFiltersResolution(
48
56
  source,
49
57
  spatialFilter,
@@ -65,7 +73,7 @@ export abstract class WidgetRemoteSource<
65
73
  operation,
66
74
  operationColumn: operationColumn || column,
67
75
  },
68
- opts: {abortController},
76
+ opts: {abortController, headers: this._headers},
69
77
  }).then((res: CategoriesModelResponse) => normalizeObjectKeys(res.rows));
70
78
  }
71
79
 
@@ -73,6 +81,7 @@ export abstract class WidgetRemoteSource<
73
81
  options: FeaturesRequestOptions
74
82
  ): Promise<FeaturesResponse> {
75
83
  const {
84
+ filters = this.props.filters,
76
85
  filterOwner,
77
86
  spatialFilter,
78
87
  spatialFiltersMode,
@@ -81,7 +90,7 @@ export abstract class WidgetRemoteSource<
81
90
  ...params
82
91
  } = options;
83
92
  const {columns, dataType, featureIds, z, limit, tileResolution} = params;
84
- const source = this.getModelSource(filterOwner);
93
+ const source = this.getModelSource(filters, filterOwner);
85
94
  const spatialFiltersResolution = this._getSpatialFiltersResolution(
86
95
  source,
87
96
  spatialFilter,
@@ -106,13 +115,14 @@ export abstract class WidgetRemoteSource<
106
115
  limit: limit || 1000,
107
116
  tileResolution: tileResolution || DEFAULT_TILE_RESOLUTION,
108
117
  },
109
- opts: {abortController},
118
+ opts: {abortController, headers: this._headers},
110
119
  // Avoid `normalizeObjectKeys()`, which changes column names.
111
120
  }).then(({rows}: FeaturesModelResponse) => ({rows}));
112
121
  }
113
122
 
114
123
  async getFormula(options: FormulaRequestOptions): Promise<FormulaResponse> {
115
124
  const {
125
+ filters = this.props.filters,
116
126
  filterOwner,
117
127
  spatialFilter,
118
128
  spatialFiltersMode,
@@ -122,7 +132,7 @@ export abstract class WidgetRemoteSource<
122
132
  ...params
123
133
  } = options;
124
134
  const {column, operation} = params;
125
- const source = this.getModelSource(filterOwner);
135
+ const source = this.getModelSource(filters, filterOwner);
126
136
  const spatialFiltersResolution = this._getSpatialFiltersResolution(
127
137
  source,
128
138
  spatialFilter,
@@ -144,7 +154,7 @@ export abstract class WidgetRemoteSource<
144
154
  operation: operation ?? 'count',
145
155
  operationExp,
146
156
  },
147
- opts: {abortController},
157
+ opts: {abortController, headers: this._headers},
148
158
  }).then((res: FormulaModelResponse) => normalizeObjectKeys(res.rows[0]));
149
159
  }
150
160
 
@@ -152,6 +162,7 @@ export abstract class WidgetRemoteSource<
152
162
  options: HistogramRequestOptions
153
163
  ): Promise<HistogramResponse> {
154
164
  const {
165
+ filters = this.props.filters,
155
166
  filterOwner,
156
167
  spatialFilter,
157
168
  spatialFiltersMode,
@@ -160,7 +171,7 @@ export abstract class WidgetRemoteSource<
160
171
  ...params
161
172
  } = options;
162
173
  const {column, operation, ticks} = params;
163
- const source = this.getModelSource(filterOwner);
174
+ const source = this.getModelSource(filters, filterOwner);
164
175
  const spatialFiltersResolution = this._getSpatialFiltersResolution(
165
176
  source,
166
177
  spatialFilter,
@@ -178,7 +189,7 @@ export abstract class WidgetRemoteSource<
178
189
  spatialFilter,
179
190
  },
180
191
  params: {column, operation, ticks},
181
- opts: {abortController},
192
+ opts: {abortController, headers: this._headers},
182
193
  }).then((res: HistogramModelResponse) => normalizeObjectKeys(res.rows));
183
194
 
184
195
  if (data.length) {
@@ -196,6 +207,7 @@ export abstract class WidgetRemoteSource<
196
207
 
197
208
  async getRange(options: RangeRequestOptions): Promise<RangeResponse> {
198
209
  const {
210
+ filters = this.props.filters,
199
211
  filterOwner,
200
212
  spatialFilter,
201
213
  spatialFiltersMode,
@@ -204,7 +216,7 @@ export abstract class WidgetRemoteSource<
204
216
  ...params
205
217
  } = options;
206
218
  const {column} = params;
207
- const source = this.getModelSource(filterOwner);
219
+ const source = this.getModelSource(filters, filterOwner);
208
220
  const spatialFiltersResolution = this._getSpatialFiltersResolution(
209
221
  source,
210
222
  spatialFilter,
@@ -222,12 +234,13 @@ export abstract class WidgetRemoteSource<
222
234
  spatialFilter,
223
235
  },
224
236
  params: {column},
225
- opts: {abortController},
237
+ opts: {abortController, headers: this._headers},
226
238
  }).then((res: RangeModelResponse) => normalizeObjectKeys(res.rows[0]));
227
239
  }
228
240
 
229
241
  async getScatter(options: ScatterRequestOptions): Promise<ScatterResponse> {
230
242
  const {
243
+ filters = this.props.filters,
231
244
  filterOwner,
232
245
  spatialFilter,
233
246
  spatialFiltersMode,
@@ -238,7 +251,7 @@ export abstract class WidgetRemoteSource<
238
251
  const {xAxisColumn, xAxisJoinOperation, yAxisColumn, yAxisJoinOperation} =
239
252
  params;
240
253
 
241
- const source = this.getModelSource(filterOwner);
254
+ const source = this.getModelSource(filters, filterOwner);
242
255
  const spatialFiltersResolution = this._getSpatialFiltersResolution(
243
256
  source,
244
257
  spatialFilter,
@@ -265,7 +278,7 @@ export abstract class WidgetRemoteSource<
265
278
  yAxisJoinOperation,
266
279
  limit: HARD_LIMIT,
267
280
  },
268
- opts: {abortController},
281
+ opts: {abortController, headers: this._headers},
269
282
  })
270
283
  .then((res: ScatterModelResponse) => normalizeObjectKeys(res.rows))
271
284
  .then((res) => res.map(({x, y}: {x: number; y: number}) => [x, y]));
@@ -273,6 +286,7 @@ export abstract class WidgetRemoteSource<
273
286
 
274
287
  async getTable(options: TableRequestOptions): Promise<TableResponse> {
275
288
  const {
289
+ filters = this.props.filters,
276
290
  filterOwner,
277
291
  spatialFilter,
278
292
  spatialFiltersMode,
@@ -281,7 +295,7 @@ export abstract class WidgetRemoteSource<
281
295
  ...params
282
296
  } = options;
283
297
  const {columns, sortBy, sortDirection, offset = 0, limit = 10} = params;
284
- const source = this.getModelSource(filterOwner);
298
+ const source = this.getModelSource(filters, filterOwner);
285
299
  const spatialFiltersResolution = this._getSpatialFiltersResolution(
286
300
  source,
287
301
  spatialFilter,
@@ -308,7 +322,7 @@ export abstract class WidgetRemoteSource<
308
322
  limit,
309
323
  offset,
310
324
  },
311
- opts: {abortController},
325
+ opts: {abortController, headers: this._headers},
312
326
  }).then((res: TableModelResponse) => ({
313
327
  // Avoid `normalizeObjectKeys()`, which changes column names.
314
328
  rows: res.rows ?? (res as any).ROWS,
@@ -320,6 +334,7 @@ export abstract class WidgetRemoteSource<
320
334
  options: TimeSeriesRequestOptions
321
335
  ): Promise<TimeSeriesResponse> {
322
336
  const {
337
+ filters = this.props.filters,
323
338
  filterOwner,
324
339
  abortController,
325
340
  spatialFilter,
@@ -339,7 +354,7 @@ export abstract class WidgetRemoteSource<
339
354
  splitByCategoryValues,
340
355
  } = params;
341
356
 
342
- const source = this.getModelSource(filterOwner);
357
+ const source = this.getModelSource(filters, filterOwner);
343
358
  const spatialFiltersResolution = this._getSpatialFiltersResolution(
344
359
  source,
345
360
  spatialFilter,
@@ -370,7 +385,7 @@ export abstract class WidgetRemoteSource<
370
385
  splitByCategoryLimit,
371
386
  splitByCategoryValues,
372
387
  },
373
- opts: {abortController},
388
+ opts: {abortController, headers: this._headers},
374
389
  }).then((res: TimeSeriesModelResponse) => ({
375
390
  rows: normalizeObjectKeys(res.rows),
376
391
  categories: res.metadata?.categories,
@@ -17,7 +17,12 @@ import {
17
17
  TimeSeriesResponse,
18
18
  ViewState,
19
19
  } from './types.js';
20
- import {FilterLogicalOperator, Filter, SpatialFilter} from '../types.js';
20
+ import {
21
+ FilterLogicalOperator,
22
+ Filter,
23
+ SpatialFilter,
24
+ Filters,
25
+ } from '../types.js';
21
26
  import {getApplicableFilters} from '../utils.js';
22
27
  import {getClient} from '../client.js';
23
28
  import {ModelSource} from '../models/model.js';
@@ -58,10 +63,14 @@ export abstract class WidgetSource<Props extends WidgetSourceProps> {
58
63
  * properties, and adding additional required properties including 'type' and
59
64
  * 'data'.
60
65
  */
61
- protected abstract getModelSource(owner: string | undefined): ModelSource;
66
+ protected abstract getModelSource(
67
+ filters: Filters | undefined,
68
+ filterOwner?: string
69
+ ): ModelSource;
62
70
 
63
71
  protected _getModelSource(
64
- owner?: string
72
+ filters: Filters | undefined,
73
+ filterOwner?: string
65
74
  ): Omit<ModelSource, 'type' | 'data'> {
66
75
  const props = this.props;
67
76
  return {
@@ -70,7 +79,7 @@ export abstract class WidgetSource<Props extends WidgetSourceProps> {
70
79
  clientId: props.clientId as string,
71
80
  accessToken: props.accessToken,
72
81
  connectionName: props.connectionName,
73
- filters: getApplicableFilters(owner, props.filters),
82
+ filters: getApplicableFilters(filterOwner, filters || props.filters),
74
83
  filtersLogicalOperator: props.filtersLogicalOperator,
75
84
  spatialDataType: props.spatialDataType,
76
85
  spatialDataColumn: props.spatialDataColumn,
@@ -8,6 +8,7 @@ import {
8
8
  WidgetRemoteSourceProps,
9
9
  } from './widget-remote-source.js';
10
10
  import {ModelSource} from '../models/model.js';
11
+ import {Filters} from '../types.js';
11
12
 
12
13
  type LayerTableSourceOptions =
13
14
  | Omit<VectorTableSourceOptions, 'filters'>
@@ -41,9 +42,12 @@ export type WidgetTableSourceResult = {widgetSource: WidgetTableSource};
41
42
  export class WidgetTableSource extends WidgetRemoteSource<
42
43
  LayerTableSourceOptions & WidgetRemoteSourceProps
43
44
  > {
44
- protected override getModelSource(owner: string): ModelSource {
45
+ protected override getModelSource(
46
+ filters: Filters | undefined,
47
+ filterOwner?: string
48
+ ): ModelSource {
45
49
  return {
46
- ...super._getModelSource(owner),
50
+ ...super._getModelSource(filters, filterOwner),
47
51
  type: 'table',
48
52
  data: this.props.tableName,
49
53
  };