@carto/api-client 0.4.4 → 0.5.0-alpha.0

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 (79) hide show
  1. package/build/api-client.cjs +2223 -240
  2. package/build/api-client.cjs.map +1 -1
  3. package/build/api-client.modern.js +2075 -237
  4. package/build/api-client.modern.js.map +1 -1
  5. package/build/constants.d.ts +22 -0
  6. package/build/filters/Filter.d.ts +13 -0
  7. package/build/filters/FilterTypes.d.ts +3 -0
  8. package/build/filters/geosjonFeatures.d.ts +8 -0
  9. package/build/filters/index.d.ts +6 -0
  10. package/build/filters/tileFeatures.d.ts +20 -0
  11. package/build/filters/tileFeaturesGeometries.d.ts +13 -0
  12. package/build/filters/tileFeaturesSpatialIndex.d.ts +10 -0
  13. package/build/index.d.ts +4 -0
  14. package/build/models/index.d.ts +1 -1
  15. package/build/operations/aggregation.d.ts +8 -0
  16. package/build/operations/applySorting.d.ts +20 -0
  17. package/build/operations/groupBy.d.ts +15 -0
  18. package/build/operations/groupByDate.d.ts +11 -0
  19. package/build/operations/histogram.d.ts +13 -0
  20. package/build/operations/index.d.ts +6 -0
  21. package/build/operations/scatterPlot.d.ts +14 -0
  22. package/build/sources/h3-tileset-source.d.ts +2 -1
  23. package/build/sources/index.d.ts +1 -1
  24. package/build/sources/quadbin-tileset-source.d.ts +2 -1
  25. package/build/sources/vector-tileset-source.d.ts +2 -1
  26. package/build/types-internal.d.ts +4 -0
  27. package/build/types.d.ts +61 -1
  28. package/build/utils/dateUtils.d.ts +10 -0
  29. package/build/utils/getTileFormat.d.ts +3 -0
  30. package/build/utils/makeIntervalComplete.d.ts +2 -0
  31. package/build/utils/transformTileCoordsToWGS84.d.ts +8 -0
  32. package/build/utils/transformToTileCoords.d.ts +9 -0
  33. package/build/widget-sources/index.d.ts +2 -1
  34. package/build/widget-sources/types.d.ts +31 -22
  35. package/build/widget-sources/widget-query-source.d.ts +2 -2
  36. package/build/widget-sources/widget-remote-source.d.ts +18 -0
  37. package/build/widget-sources/{widget-base-source.d.ts → widget-source.d.ts} +13 -38
  38. package/build/widget-sources/widget-table-source.d.ts +2 -2
  39. package/build/widget-sources/widget-tileset-source.d.ts +67 -0
  40. package/package.json +36 -35
  41. package/src/constants.ts +25 -0
  42. package/src/filters/Filter.ts +169 -0
  43. package/src/filters/FilterTypes.ts +109 -0
  44. package/src/filters/geosjonFeatures.ts +32 -0
  45. package/src/filters/index.ts +6 -0
  46. package/src/filters/tileFeatures.ts +56 -0
  47. package/src/filters/tileFeaturesGeometries.ts +444 -0
  48. package/src/filters/tileFeaturesSpatialIndex.ts +119 -0
  49. package/src/index.ts +6 -0
  50. package/src/models/index.ts +1 -1
  51. package/src/operations/aggregation.ts +154 -0
  52. package/src/operations/applySorting.ts +109 -0
  53. package/src/operations/groupBy.ts +59 -0
  54. package/src/operations/groupByDate.ts +98 -0
  55. package/src/operations/histogram.ts +66 -0
  56. package/src/operations/index.ts +6 -0
  57. package/src/operations/scatterPlot.ts +50 -0
  58. package/src/sources/h3-tileset-source.ts +18 -6
  59. package/src/sources/index.ts +1 -1
  60. package/src/sources/quadbin-tileset-source.ts +18 -6
  61. package/src/sources/raster-source.ts +1 -0
  62. package/src/sources/vector-query-source.ts +6 -2
  63. package/src/sources/vector-table-source.ts +6 -2
  64. package/src/sources/vector-tileset-source.ts +19 -6
  65. package/src/types-internal.ts +6 -0
  66. package/src/types.ts +60 -2
  67. package/src/utils/dateUtils.ts +28 -0
  68. package/src/utils/getTileFormat.ts +9 -0
  69. package/src/utils/makeIntervalComplete.ts +17 -0
  70. package/src/utils/transformTileCoordsToWGS84.ts +77 -0
  71. package/src/utils/transformToTileCoords.ts +85 -0
  72. package/src/utils.ts +8 -5
  73. package/src/widget-sources/index.ts +2 -1
  74. package/src/widget-sources/types.ts +32 -22
  75. package/src/widget-sources/widget-query-source.ts +6 -3
  76. package/src/widget-sources/{widget-base-source.ts → widget-remote-source.ts} +12 -147
  77. package/src/widget-sources/widget-source.ts +160 -0
  78. package/src/widget-sources/widget-table-source.ts +6 -3
  79. package/src/widget-sources/widget-tileset-source.ts +396 -0
@@ -3,7 +3,10 @@
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
5
  /* eslint-disable camelcase */
6
- import {DEFAULT_TILE_RESOLUTION} from '../constants-internal.js';
6
+ import {
7
+ DEFAULT_GEO_COLUMN,
8
+ DEFAULT_TILE_RESOLUTION,
9
+ } from '../constants-internal.js';
7
10
  import {
8
11
  WidgetTableSource,
9
12
  WidgetTableSourceResult,
@@ -42,7 +45,7 @@ export const vectorTableSource = async function (
42
45
  const {
43
46
  columns,
44
47
  filters,
45
- spatialDataColumn = 'geom',
48
+ spatialDataColumn = DEFAULT_GEO_COLUMN,
46
49
  tableName,
47
50
  tileResolution = DEFAULT_TILE_RESOLUTION,
48
51
  aggregationExp,
@@ -69,6 +72,7 @@ export const vectorTableSource = async function (
69
72
  ...(result as TilejsonResult),
70
73
  widgetSource: new WidgetTableSource({
71
74
  ...options,
75
+ spatialDataColumn,
72
76
  spatialDataType: 'geo',
73
77
  }),
74
78
  })
@@ -2,6 +2,12 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
+ import {DEFAULT_GEO_COLUMN} from '../constants-internal';
6
+ import {getTileFormat} from '../utils/getTileFormat';
7
+ import {
8
+ WidgetTilesetSource,
9
+ WidgetTilesetSourceResult,
10
+ } from '../widget-sources';
5
11
  import {baseSource} from './base-source';
6
12
  import type {
7
13
  SourceOptions,
@@ -12,17 +18,24 @@ import type {
12
18
  export type VectorTilesetSourceOptions = SourceOptions & TilesetSourceOptions;
13
19
  type UrlParameters = {name: string};
14
20
 
15
- export type VectorTilesetSourceResponse = TilejsonResult;
21
+ export type VectorTilesetSourceResponse = TilejsonResult &
22
+ WidgetTilesetSourceResult;
16
23
 
17
24
  export const vectorTilesetSource = async function (
18
25
  options: VectorTilesetSourceOptions
19
26
  ): Promise<VectorTilesetSourceResponse> {
20
- const {tableName} = options;
27
+ const {tableName, spatialDataColumn = DEFAULT_GEO_COLUMN} = options;
21
28
  const urlParameters: UrlParameters = {name: tableName};
22
29
 
23
- return baseSource<UrlParameters>(
24
- 'tileset',
25
- options,
26
- urlParameters
30
+ return baseSource<UrlParameters>('tileset', options, urlParameters).then(
31
+ (result) => ({
32
+ ...(result as TilejsonResult),
33
+ widgetSource: new WidgetTilesetSource({
34
+ ...options,
35
+ tileFormat: getTileFormat(result as TilejsonResult),
36
+ spatialDataColumn,
37
+ spatialDataType: 'geo',
38
+ }),
39
+ })
27
40
  ) as Promise<VectorTilesetSourceResponse>;
28
41
  };
@@ -60,3 +60,9 @@ type MapInstantiationFormats = Record<
60
60
  error?: any;
61
61
  }
62
62
  >;
63
+
64
+ /******************************************************************************
65
+ * LOCAL CALCULATIONS
66
+ */
67
+
68
+ export type FeatureData = Record<string, unknown>;
package/src/types.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type {FilterType} from './constants.js';
2
- import type {Polygon, MultiPolygon} from 'geojson';
2
+ import type {Polygon, MultiPolygon, Feature} from 'geojson';
3
+ import type {BinaryFeature, BinaryFeatureCollection} from '@loaders.gl/schema';
3
4
 
4
5
  /******************************************************************************
5
6
  * MAPS AND TILES
@@ -11,6 +12,43 @@ export type Format = 'json' | 'geojson' | 'tilejson';
11
12
  /** @internalRemarks Source: @carto/constants, @deck.gl/carto */
12
13
  export type MapType = 'boundary' | 'query' | 'table' | 'tileset' | 'raster';
13
14
 
15
+ /**
16
+ * Alias for GeoJSON 'BBox' type, semantically representing a viewport.
17
+ * Order of values is "west", "south", "east", "north".
18
+ */
19
+ export type Viewport = [number, number, number, number];
20
+
21
+ /**
22
+ * Subset of deck.gl's Tile2DHeader type, containing only the properties
23
+ * required for local widget calculations. Deeper dependencies on deck.gl
24
+ * APIs should be minimized within this library: @deck.gl/carto depends
25
+ * on the API client, not the other way around.
26
+ * @internalRemarks Source: @deck.gl/geo-layers
27
+ */
28
+ export type Tile = {
29
+ index: {x: number; y: number; z: number};
30
+ id: string;
31
+ content: unknown;
32
+ zoom: number;
33
+ bbox: {west: number; east: number; north: number; south: number};
34
+ isVisible: boolean;
35
+ data?: BinaryFeatureCollection;
36
+ };
37
+
38
+ /** Subset of deck.gl's Tile2DHeader type, for spatial indexes. */
39
+ export type SpatialIndexTile = Tile & {
40
+ data?: (Feature & {id: bigint})[];
41
+ };
42
+
43
+ /** @internalRemarks Source: @deck.gl/carto */
44
+ export type Raster = {
45
+ blockSize: number;
46
+ cells: {
47
+ numericProps: BinaryFeature['numericProps'];
48
+ properties: BinaryFeature['properties'];
49
+ };
50
+ };
51
+
14
52
  /******************************************************************************
15
53
  * AGGREGATION
16
54
  */
@@ -49,12 +87,32 @@ export interface Filter {
49
87
  /** [a, b) a is included, b is not. */
50
88
  [FilterType.CLOSED_OPEN]?: {owner?: string; values: number[][]};
51
89
  [FilterType.TIME]?: {owner?: string; values: number[][]};
52
- [FilterType.STRING_SEARCH]?: {owner?: string; values: string[]};
90
+ [FilterType.STRING_SEARCH]?: {
91
+ owner?: string;
92
+ values: string[];
93
+ params?: StringSearchOptions;
94
+ };
53
95
  }
54
96
 
55
97
  /** @internalRemarks Source: @carto/react-core */
56
98
  export type FilterLogicalOperator = 'and' | 'or';
57
99
 
100
+ /**
101
+ * Type for minimum or maximum value of an interval. Values 'null' and
102
+ * 'undefined' are intentionally allowed, and represent an unbounded value.
103
+ */
104
+ export type FilterIntervalExtremum = number | null | undefined;
105
+ export type FilterInterval = [FilterIntervalExtremum, FilterIntervalExtremum];
106
+ export type FilterIntervalComplete = [number, number];
107
+
108
+ export type StringSearchOptions = {
109
+ useRegExp?: boolean;
110
+ mustStart?: boolean;
111
+ mustEnd?: boolean;
112
+ caseSensitive?: boolean;
113
+ keepSpecialCharacters?: boolean;
114
+ };
115
+
58
116
  /******************************************************************************
59
117
  * GROUPING
60
118
  */
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Returns midnight (local time) on the Monday preceeding a given date, in
3
+ * milliseconds since the UNIX epoch.
4
+ */
5
+ export function getMonday(date: number | Date): number {
6
+ const dateCp = new Date(date);
7
+ const day = dateCp.getDay();
8
+ const diff = dateCp.getDate() - day + (day ? 1 : -6); // adjust when day is sunday
9
+ dateCp.setDate(diff);
10
+ dateCp.setHours(0, 0, 0, 0);
11
+ return dateCp.getTime();
12
+ }
13
+
14
+ /**
15
+ * Returns midnight (UTC) on the Monday preceeding a given date, in
16
+ * milliseconds since the UNIX epoch.
17
+ */
18
+ export function getUTCMonday(date: number | Date): number {
19
+ const dateCp = new Date(date);
20
+ const day = dateCp.getUTCDay();
21
+ const diff = dateCp.getUTCDate() - day + (day ? 1 : -6); // adjust when day is sunday
22
+ dateCp.setUTCDate(diff);
23
+ return Date.UTC(
24
+ dateCp.getUTCFullYear(),
25
+ dateCp.getUTCMonth(),
26
+ dateCp.getUTCDate()
27
+ );
28
+ }
@@ -0,0 +1,9 @@
1
+ import {TileFormat} from '../constants.js';
2
+ import {Tilejson} from '../sources/types.js';
3
+
4
+ export function getTileFormat(tilejson: Tilejson): TileFormat {
5
+ const tileParams = new URL(tilejson.tiles[0]).searchParams;
6
+ return tileParams.get('formatTiles') === 'mvt'
7
+ ? TileFormat.MVT
8
+ : TileFormat.BINARY;
9
+ }
@@ -0,0 +1,17 @@
1
+ import {FilterInterval, FilterIntervalComplete} from '../types';
2
+
3
+ export function makeIntervalComplete(
4
+ intervals: FilterInterval[]
5
+ ): FilterIntervalComplete[] {
6
+ return intervals.map((val) => {
7
+ if (val[0] === undefined || val[0] === null) {
8
+ return [Number.MIN_SAFE_INTEGER, val[1]];
9
+ }
10
+
11
+ if (val[1] === undefined || val[1] === null) {
12
+ return [val[0], Number.MAX_SAFE_INTEGER];
13
+ }
14
+
15
+ return val;
16
+ }) as FilterIntervalComplete[];
17
+ }
@@ -0,0 +1,77 @@
1
+ import {lerp} from '@math.gl/core';
2
+ import {lngLatToWorld, worldToLngLat} from '@math.gl/web-mercator';
3
+ import {BBox, GeoJsonGeometryTypes, Geometry, Position} from 'geojson';
4
+
5
+ type TransformFn = (coordinates: any[], bbox: Position[]) => any[];
6
+
7
+ const TRANSFORM_FN: Record<
8
+ Exclude<GeoJsonGeometryTypes, 'GeometryCollection'>,
9
+ TransformFn
10
+ > = {
11
+ Point: transformPoint,
12
+ MultiPoint: transformMultiPoint,
13
+ LineString: transformLineString,
14
+ MultiLineString: transformMultiLineString,
15
+ Polygon: transformPolygon,
16
+ MultiPolygon: transformMultiPolygon,
17
+ };
18
+
19
+ /**
20
+ * Transform tile coords to WGS84 coordinates.
21
+ *
22
+ * @param geometry - any valid geojson geometry
23
+ * @param bbox - geojson bbox
24
+ */
25
+ export function transformTileCoordsToWGS84<T extends Geometry>(
26
+ geometry: T,
27
+ bbox: BBox
28
+ ): T {
29
+ const [west, south, east, north] = bbox;
30
+ const nw = lngLatToWorld([west, north]);
31
+ const se = lngLatToWorld([east, south]);
32
+ const projectedBbox = [nw, se];
33
+
34
+ if (geometry.type === 'GeometryCollection') {
35
+ throw new Error('Unsupported geometry type GeometryCollection');
36
+ }
37
+
38
+ const transformFn = TRANSFORM_FN[geometry.type];
39
+ const coordinates = transformFn(geometry.coordinates, projectedBbox);
40
+ return {...geometry, coordinates};
41
+ }
42
+
43
+ function transformPoint([pointX, pointY]: Position, [nw, se]: Position[]) {
44
+ const x = lerp(nw[0], se[0], pointX);
45
+ const y = lerp(nw[1], se[1], pointY);
46
+
47
+ return worldToLngLat([x, y]);
48
+ }
49
+
50
+ function getPoints(geometry: Position[], bbox: Position[]) {
51
+ return geometry.map((g) => transformPoint(g, bbox));
52
+ }
53
+
54
+ function transformMultiPoint(multiPoint: Position[], bbox: Position[]) {
55
+ return getPoints(multiPoint, bbox);
56
+ }
57
+
58
+ function transformLineString(line: Position[], bbox: Position[]) {
59
+ return getPoints(line, bbox);
60
+ }
61
+
62
+ function transformMultiLineString(
63
+ multiLineString: Position[][],
64
+ bbox: Position[]
65
+ ) {
66
+ return multiLineString.map((lineString) =>
67
+ transformLineString(lineString, bbox)
68
+ );
69
+ }
70
+
71
+ function transformPolygon(polygon: Position[][], bbox: Position[]) {
72
+ return polygon.map((polygonRing) => getPoints(polygonRing, bbox));
73
+ }
74
+
75
+ function transformMultiPolygon(multiPolygon: Position[][][], bbox: Position[]) {
76
+ return multiPolygon.map((polygon) => transformPolygon(polygon, bbox));
77
+ }
@@ -0,0 +1,85 @@
1
+ import {lngLatToWorld} from '@math.gl/web-mercator';
2
+ import {BBox, GeoJsonGeometryTypes, Geometry, Position} from 'geojson';
3
+
4
+ type TransformFn = (coordinates: any[], bbox: Position[]) => any[];
5
+
6
+ const TRANSFORM_FN: Record<
7
+ Exclude<GeoJsonGeometryTypes, 'GeometryCollection'>,
8
+ TransformFn
9
+ > = {
10
+ Point: transformPoint,
11
+ MultiPoint: transformMultiPoint,
12
+ LineString: transformLineString,
13
+ MultiLineString: transformMultiLineString,
14
+ Polygon: transformPolygon,
15
+ MultiPolygon: transformMultiPolygon,
16
+ };
17
+
18
+ /**
19
+ * Transform WGS84 coordinates to tile coords.
20
+ * It's the inverse of deck.gl coordinate-transform (https://github.com/visgl/deck.gl/blob/master/modules/geo-layers/src/mvt-layer/coordinate-transform.js)
21
+ *
22
+ * @param geometry - any valid geojson geometry
23
+ * @param bbox - geojson bbox
24
+ */
25
+ export function transformToTileCoords<T extends Geometry>(
26
+ geometry: T,
27
+ bbox: BBox
28
+ ): T {
29
+ const [west, south, east, north] = bbox;
30
+ const nw = projectFlat([west, north]);
31
+ const se = projectFlat([east, south]);
32
+ const projectedBbox = [nw, se];
33
+
34
+ if (geometry.type === 'GeometryCollection') {
35
+ throw new Error('Unsupported geometry type GeometryCollection');
36
+ }
37
+
38
+ const transformFn = TRANSFORM_FN[geometry.type];
39
+ const coordinates = transformFn(geometry.coordinates, projectedBbox);
40
+ return {...geometry, coordinates};
41
+ }
42
+
43
+ function transformPoint([pointX, pointY]: Position, [nw, se]: Position[]) {
44
+ const x = inverseLerp(nw[0], se[0], pointX);
45
+ const y = inverseLerp(nw[1], se[1], pointY);
46
+
47
+ return [x, y];
48
+ }
49
+
50
+ function getPoints(geometry: Position[], bbox: Position[]) {
51
+ return geometry.map((g) => transformPoint(projectFlat(g), bbox));
52
+ }
53
+
54
+ function transformMultiPoint(multiPoint: Position[], bbox: Position[]) {
55
+ return getPoints(multiPoint, bbox);
56
+ }
57
+
58
+ function transformLineString(line: Position[], bbox: Position[]) {
59
+ return getPoints(line, bbox);
60
+ }
61
+
62
+ function transformMultiLineString(
63
+ multiLineString: Position[][],
64
+ bbox: Position[]
65
+ ) {
66
+ return multiLineString.map((lineString) =>
67
+ transformLineString(lineString, bbox)
68
+ );
69
+ }
70
+
71
+ function transformPolygon(polygon: Position[][], bbox: Position[]) {
72
+ return polygon.map((polygonRing) => getPoints(polygonRing, bbox));
73
+ }
74
+
75
+ function transformMultiPolygon(multiPolygon: Position[][][], bbox: Position[]) {
76
+ return multiPolygon.map((polygon) => transformPolygon(polygon, bbox));
77
+ }
78
+
79
+ function projectFlat(xyz: Position): Position {
80
+ return lngLatToWorld(xyz);
81
+ }
82
+
83
+ function inverseLerp(a: number, b: number, x: number): number {
84
+ return (x - a) / (b - a);
85
+ }
package/src/utils.ts CHANGED
@@ -49,11 +49,14 @@ export function normalizeObjectKeys<T, R extends Row<T>>(el: R): R {
49
49
  return el;
50
50
  }
51
51
 
52
- return Object.entries(el as Record<string, T>).reduce((acc, [key, value]) => {
53
- acc[key.toLowerCase()] =
54
- typeof value === 'object' && value ? normalizeObjectKeys(value) : value;
55
- return acc;
56
- }, {} as Record<string, T>) as R;
52
+ return Object.entries(el as Record<string, T>).reduce(
53
+ (acc, [key, value]) => {
54
+ acc[key.toLowerCase()] =
55
+ typeof value === 'object' && value ? normalizeObjectKeys(value) : value;
56
+ return acc;
57
+ },
58
+ {} as Record<string, T>
59
+ ) as R;
57
60
  }
58
61
 
59
62
  /** @internalRemarks Source: @carto/react-core */
@@ -1,4 +1,5 @@
1
- export * from './widget-base-source.js';
2
1
  export * from './widget-query-source.js';
2
+ export * from './widget-remote-source.js';
3
3
  export * from './widget-table-source.js';
4
+ export * from './widget-tileset-source.js';
4
5
  export * from './types.js';
@@ -5,6 +5,7 @@ import {
5
5
  SortDirection,
6
6
  SpatialFilter,
7
7
  } from '../types';
8
+ import type {WidgetRemoteSource} from './widget-remote-source';
8
9
 
9
10
  /******************************************************************************
10
11
  * WIDGET API REQUESTS
@@ -16,7 +17,7 @@ export interface ViewState {
16
17
  longitude: number;
17
18
  }
18
19
 
19
- /** Common options for {@link WidgetBaseSource} requests. */
20
+ /** Common options for {@link WidgetRemoteSource} requests. */
20
21
  interface BaseRequestOptions {
21
22
  spatialFilter?: SpatialFilter;
22
23
  spatialFiltersMode?: SpatialFilterPolyfillMode;
@@ -26,15 +27,17 @@ interface BaseRequestOptions {
26
27
  filterOwner?: string;
27
28
  }
28
29
 
29
- /** Options for {@link WidgetBaseSource#getCategories}. */
30
+ /** Options for {@link WidgetRemoteSource#getCategories}. */
30
31
  export interface CategoryRequestOptions extends BaseRequestOptions {
31
32
  column: string;
32
33
  operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
33
34
  operationColumn?: string;
35
+ /** Local only. */
36
+ joinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
34
37
  }
35
38
 
36
39
  /**
37
- * Options for {@link WidgetBaseSource#getFeatures}.
40
+ * Options for {@link WidgetRemoteSource#getFeatures}.
38
41
  * @experimental
39
42
  * @internal
40
43
  */
@@ -76,26 +79,29 @@ export interface FeaturesRequestOptions extends BaseRequestOptions {
76
79
  tileResolution?: TileResolution;
77
80
  }
78
81
 
79
- /** Options for {@link WidgetBaseSource#getFormula}. */
82
+ /** Options for {@link WidgetRemoteSource#getFormula}. */
80
83
  export interface FormulaRequestOptions extends BaseRequestOptions {
81
84
  column: string;
82
- operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
85
+ operation?: 'count' | 'avg' | 'min' | 'max' | 'sum' | 'custom';
83
86
  operationExp?: string;
87
+ joinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
84
88
  }
85
89
 
86
- /** Options for {@link WidgetBaseSource#getHistogram}. */
90
+ /** Options for {@link WidgetRemoteSource#getHistogram}. */
87
91
  export interface HistogramRequestOptions extends BaseRequestOptions {
88
92
  column: string;
89
93
  ticks: number[];
90
94
  operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
95
+ /** Local only. */
96
+ joinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
91
97
  }
92
98
 
93
- /** Options for {@link WidgetBaseSource#getRange}. */
99
+ /** Options for {@link WidgetRemoteSource#getRange}. */
94
100
  export interface RangeRequestOptions extends BaseRequestOptions {
95
101
  column: string;
96
102
  }
97
103
 
98
- /** Options for {@link WidgetBaseSource#getScatter}. */
104
+ /** Options for {@link WidgetRemoteSource#getScatter}. */
99
105
  export interface ScatterRequestOptions extends BaseRequestOptions {
100
106
  xAxisColumn: string;
101
107
  xAxisJoinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
@@ -103,7 +109,7 @@ export interface ScatterRequestOptions extends BaseRequestOptions {
103
109
  yAxisJoinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
104
110
  }
105
111
 
106
- /** Options for {@link WidgetBaseSource#getTable}. */
112
+ /** Options for {@link WidgetRemoteSource#getTable}. */
107
113
  export interface TableRequestOptions extends BaseRequestOptions {
108
114
  columns: string[];
109
115
  sortBy?: string;
@@ -111,12 +117,16 @@ export interface TableRequestOptions extends BaseRequestOptions {
111
117
  sortByColumnType?: SortColumnType;
112
118
  offset?: number;
113
119
  limit?: number;
120
+ /** Local only. */
121
+ searchFilterColumn?: string;
122
+ /** Local only. */
123
+ searchFilterText?: string;
114
124
  }
115
125
 
116
- /** Options for {@link WidgetBaseSource#getTimeSeries}. */
126
+ /** Options for {@link WidgetRemoteSource#getTimeSeries}. */
117
127
  export interface TimeSeriesRequestOptions extends BaseRequestOptions {
118
128
  column: string;
119
- stepSize?: GroupDateType;
129
+ stepSize: GroupDateType;
120
130
  stepMultiplier?: number;
121
131
  operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
122
132
  operationColumn?: string;
@@ -131,35 +141,35 @@ export interface TimeSeriesRequestOptions extends BaseRequestOptions {
131
141
  */
132
142
 
133
143
  /**
134
- * Response from {@link WidgetBaseSource#getFeatures}.
144
+ * Response from {@link WidgetRemoteSource#getFeatures}.
135
145
  * @experimental
136
146
  * @internal
137
147
  */
138
148
  export type FeaturesResponse = {rows: Record<string, unknown>[]};
139
149
 
140
- /** Response from {@link WidgetBaseSource#getFormula}. */
141
- export type FormulaResponse = {value: number};
150
+ /** Response from {@link WidgetRemoteSource#getFormula}. */
151
+ export type FormulaResponse = {value: number | null};
142
152
 
143
- /** Response from {@link WidgetBaseSource#getCategories}. */
153
+ /** Response from {@link WidgetRemoteSource#getCategories}. */
144
154
  export type CategoryResponse = {name: string; value: number}[];
145
155
 
146
- /** Response from {@link WidgetBaseSource#getRange}. */
147
- export type RangeResponse = {min: number; max: number};
156
+ /** Response from {@link WidgetRemoteSource#getRange}. */
157
+ export type RangeResponse = {min: number; max: number} | null;
148
158
 
149
- /** Response from {@link WidgetBaseSource#getTable}. */
159
+ /** Response from {@link WidgetRemoteSource#getTable}. */
150
160
  export type TableResponse = {
151
161
  totalCount: number;
152
162
  rows: Record<string, number | string>[];
153
163
  };
154
164
 
155
- /** Response from {@link WidgetBaseSource#getScatter}. */
165
+ /** Response from {@link WidgetRemoteSource#getScatter}. */
156
166
  export type ScatterResponse = [number, number][];
157
167
 
158
- /** Response from {@link WidgetBaseSource#getTimeSeries}. */
168
+ /** Response from {@link WidgetRemoteSource#getTimeSeries}. */
159
169
  export type TimeSeriesResponse = {
160
170
  rows: {name: string; value: number}[];
161
- categories: string[];
171
+ categories?: string[];
162
172
  };
163
173
 
164
- /** Response from {@link WidgetBaseSource#getHistogram}. */
174
+ /** Response from {@link WidgetRemoteSource#getHistogram}. */
165
175
  export type HistogramResponse = number[];
@@ -3,7 +3,10 @@ import {
3
3
  QuadbinQuerySourceOptions,
4
4
  VectorQuerySourceOptions,
5
5
  } from '../sources/index.js';
6
- import {WidgetBaseSource, WidgetBaseSourceProps} from './widget-base-source.js';
6
+ import {
7
+ WidgetRemoteSource,
8
+ WidgetRemoteSourceProps,
9
+ } from './widget-remote-source.js';
7
10
  import {ModelSource} from '../models/model.js';
8
11
 
9
12
  type LayerQuerySourceOptions =
@@ -35,8 +38,8 @@ export type WidgetQuerySourceResult = {widgetSource: WidgetQuerySource};
35
38
  * const { widgetSource } = await data;
36
39
  * ```
37
40
  */
38
- export class WidgetQuerySource extends WidgetBaseSource<
39
- LayerQuerySourceOptions & WidgetBaseSourceProps
41
+ export class WidgetQuerySource extends WidgetRemoteSource<
42
+ LayerQuerySourceOptions & WidgetRemoteSourceProps
40
43
  > {
41
44
  protected override getModelSource(owner: string): ModelSource {
42
45
  return {