@carto/api-client 0.4.6 → 0.4.7-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.
- package/CHANGELOG.md +17 -1
- package/build/api/carto-api-error.d.ts +1 -1
- package/build/api/query.d.ts +1 -1
- package/build/api/request-with-parameters.d.ts +2 -2
- package/build/api-client.cjs +2365 -279
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.modern.js +2274 -298
- package/build/api-client.modern.js.map +1 -1
- package/build/client.d.ts +2 -2
- package/build/constants-internal.d.ts +5 -5
- package/build/constants.d.ts +25 -3
- package/build/deck/get-data-filter-extension-props.d.ts +28 -0
- package/build/deck/index.d.ts +1 -0
- package/build/filters/Filter.d.ts +25 -0
- package/build/filters/FilterTypes.d.ts +3 -0
- package/build/filters/geosjonFeatures.d.ts +8 -0
- package/build/filters/index.d.ts +6 -0
- package/build/filters/tileFeatures.d.ts +20 -0
- package/build/filters/tileFeaturesGeometries.d.ts +13 -0
- package/build/filters/tileFeaturesSpatialIndex.d.ts +10 -0
- package/build/filters.d.ts +2 -2
- package/build/geo.d.ts +1 -1
- package/build/index.d.ts +5 -0
- package/build/models/common.d.ts +5 -4
- package/build/models/index.d.ts +1 -1
- package/build/models/model.d.ts +2 -2
- package/build/operations/aggregation.d.ts +8 -0
- package/build/operations/applySorting.d.ts +20 -0
- package/build/operations/groupBy.d.ts +15 -0
- package/build/operations/groupByDate.d.ts +11 -0
- package/build/operations/histogram.d.ts +13 -0
- package/build/operations/index.d.ts +6 -0
- package/build/operations/scatterPlot.d.ts +14 -0
- package/build/sources/base-source.d.ts +2 -2
- package/build/sources/boundary-query-source.d.ts +1 -1
- package/build/sources/boundary-table-source.d.ts +1 -1
- package/build/sources/h3-query-source.d.ts +2 -2
- package/build/sources/h3-table-source.d.ts +2 -2
- package/build/sources/h3-tileset-source.d.ts +1 -1
- package/build/sources/index.d.ts +26 -26
- package/build/sources/quadbin-query-source.d.ts +2 -2
- package/build/sources/quadbin-table-source.d.ts +2 -2
- package/build/sources/quadbin-tileset-source.d.ts +1 -1
- package/build/sources/raster-source.d.ts +1 -1
- package/build/sources/types.d.ts +3 -3
- package/build/sources/vector-query-source.d.ts +1 -1
- package/build/sources/vector-table-source.d.ts +1 -1
- package/build/sources/vector-tileset-source.d.ts +1 -1
- package/build/spatial-index.d.ts +3 -3
- package/build/types-internal.d.ts +9 -5
- package/build/types.d.ts +74 -14
- package/build/utils/dateUtils.d.ts +10 -0
- package/build/utils/getTileFormat.d.ts +3 -0
- package/build/utils/makeIntervalComplete.d.ts +2 -0
- package/build/utils/transformTileCoordsToWGS84.d.ts +8 -0
- package/build/utils/transformToTileCoords.d.ts +9 -0
- package/build/utils.d.ts +3 -3
- package/build/widget-sources/index.d.ts +3 -1
- package/build/widget-sources/types.d.ts +38 -25
- package/build/widget-sources/widget-query-source.d.ts +4 -3
- package/build/widget-sources/widget-remote-source.d.ts +18 -0
- package/build/widget-sources/{widget-base-source.d.ts → widget-source.d.ts} +16 -41
- package/build/widget-sources/widget-table-source.d.ts +4 -3
- package/build/widget-sources/widget-tileset-source.d.ts +75 -0
- package/package.json +46 -29
- package/src/api/carto-api-error.ts +1 -1
- package/src/api/query.ts +5 -5
- package/src/api/request-with-parameters.ts +6 -6
- package/src/client.ts +3 -3
- package/src/constants-internal.ts +5 -5
- package/src/constants.ts +28 -3
- package/src/deck/get-data-filter-extension-props.ts +164 -0
- package/src/deck/index.ts +1 -0
- package/src/filters/Filter.ts +179 -0
- package/src/filters/FilterTypes.ts +109 -0
- package/src/filters/geosjonFeatures.ts +32 -0
- package/src/filters/index.ts +6 -0
- package/src/filters/tileFeatures.ts +50 -0
- package/src/filters/tileFeaturesGeometries.ts +444 -0
- package/src/filters/tileFeaturesSpatialIndex.ts +119 -0
- package/src/filters.ts +4 -4
- package/src/geo.ts +12 -14
- package/src/index.ts +7 -0
- package/src/models/common.ts +11 -9
- package/src/models/index.ts +1 -1
- package/src/models/model.ts +3 -4
- package/src/operations/aggregation.ts +154 -0
- package/src/operations/applySorting.ts +109 -0
- package/src/operations/groupBy.ts +59 -0
- package/src/operations/groupByDate.ts +98 -0
- package/src/operations/histogram.ts +66 -0
- package/src/operations/index.ts +6 -0
- package/src/operations/scatterPlot.ts +50 -0
- package/src/sources/base-source.ts +8 -8
- package/src/sources/boundary-query-source.ts +2 -2
- package/src/sources/boundary-table-source.ts +2 -2
- package/src/sources/h3-query-source.ts +7 -5
- package/src/sources/h3-table-source.ts +7 -5
- package/src/sources/h3-tileset-source.ts +2 -2
- package/src/sources/index.ts +26 -26
- package/src/sources/quadbin-query-source.ts +7 -5
- package/src/sources/quadbin-table-source.ts +7 -5
- package/src/sources/quadbin-tileset-source.ts +2 -2
- package/src/sources/raster-source.ts +3 -2
- package/src/sources/types.ts +3 -3
- package/src/sources/vector-query-source.ts +7 -5
- package/src/sources/vector-table-source.ts +7 -5
- package/src/sources/vector-tileset-source.ts +2 -2
- package/src/spatial-index.ts +4 -5
- package/src/types-internal.ts +11 -5
- package/src/types.ts +73 -15
- package/src/utils/dateUtils.ts +28 -0
- package/src/utils/getTileFormat.ts +9 -0
- package/src/utils/makeIntervalComplete.ts +17 -0
- package/src/utils/transformTileCoordsToWGS84.ts +77 -0
- package/src/utils/transformToTileCoords.ts +85 -0
- package/src/utils.ts +3 -3
- package/src/widget-sources/index.ts +3 -1
- package/src/widget-sources/types.ts +39 -25
- package/src/widget-sources/widget-query-source.ts +12 -5
- package/src/widget-sources/{widget-base-source.ts → widget-remote-source.ts} +51 -171
- package/src/widget-sources/widget-source.ts +173 -0
- package/src/widget-sources/widget-table-source.ts +12 -5
- package/src/widget-sources/widget-tileset-source.ts +456 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {FilterInterval, FilterIntervalComplete} from '../types.js';
|
|
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
|
@@ -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
|
-
* @
|
|
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
|
-
/** @
|
|
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
|
-
* @
|
|
70
|
+
* @privateRemarks Source: @carto/react-core
|
|
71
71
|
* @internal
|
|
72
72
|
*/
|
|
73
73
|
export class InvalidColumnError extends Error {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export * from './widget-
|
|
1
|
+
export * from './widget-source.js';
|
|
2
2
|
export * from './widget-query-source.js';
|
|
3
|
+
export * from './widget-remote-source.js';
|
|
3
4
|
export * from './widget-table-source.js';
|
|
5
|
+
export * from './widget-tileset-source.js';
|
|
4
6
|
export * from './types.js';
|
|
@@ -1,10 +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
|
+
} from '../types.js';
|
|
8
9
|
|
|
9
10
|
/******************************************************************************
|
|
10
11
|
* WIDGET API REQUESTS
|
|
@@ -16,25 +17,31 @@ export interface ViewState {
|
|
|
16
17
|
longitude: number;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
/** Common options for {@link
|
|
20
|
+
/** Common options for {@link WidgetRemoteSource} requests. */
|
|
20
21
|
interface BaseRequestOptions {
|
|
22
|
+
/** @deprecated */
|
|
23
|
+
abortController?: AbortController;
|
|
24
|
+
signal?: AbortSignal;
|
|
21
25
|
spatialFilter?: SpatialFilter;
|
|
22
26
|
spatialFiltersMode?: SpatialFilterPolyfillMode;
|
|
23
27
|
/** Required for table- and query-based spatial index sources (H3, Quadbin). */
|
|
24
28
|
spatialIndexReferenceViewState?: ViewState;
|
|
25
|
-
|
|
29
|
+
/** Overrides source filters, if any. */
|
|
30
|
+
filters?: Filters;
|
|
26
31
|
filterOwner?: string;
|
|
27
32
|
}
|
|
28
33
|
|
|
29
|
-
/** Options for {@link
|
|
34
|
+
/** Options for {@link WidgetRemoteSource#getCategories}. */
|
|
30
35
|
export interface CategoryRequestOptions extends BaseRequestOptions {
|
|
31
36
|
column: string;
|
|
32
37
|
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
33
38
|
operationColumn?: string;
|
|
39
|
+
/** Local only. */
|
|
40
|
+
joinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
34
41
|
}
|
|
35
42
|
|
|
36
43
|
/**
|
|
37
|
-
* Options for {@link
|
|
44
|
+
* Options for {@link WidgetRemoteSource#getFeatures}.
|
|
38
45
|
* @experimental
|
|
39
46
|
* @internal
|
|
40
47
|
*/
|
|
@@ -76,26 +83,29 @@ export interface FeaturesRequestOptions extends BaseRequestOptions {
|
|
|
76
83
|
tileResolution?: TileResolution;
|
|
77
84
|
}
|
|
78
85
|
|
|
79
|
-
/** Options for {@link
|
|
86
|
+
/** Options for {@link WidgetRemoteSource#getFormula}. */
|
|
80
87
|
export interface FormulaRequestOptions extends BaseRequestOptions {
|
|
81
88
|
column: string;
|
|
82
|
-
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
89
|
+
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum' | 'custom';
|
|
83
90
|
operationExp?: string;
|
|
91
|
+
joinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
84
92
|
}
|
|
85
93
|
|
|
86
|
-
/** Options for {@link
|
|
94
|
+
/** Options for {@link WidgetRemoteSource#getHistogram}. */
|
|
87
95
|
export interface HistogramRequestOptions extends BaseRequestOptions {
|
|
88
96
|
column: string;
|
|
89
97
|
ticks: number[];
|
|
90
98
|
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
99
|
+
/** Local only. */
|
|
100
|
+
joinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
91
101
|
}
|
|
92
102
|
|
|
93
|
-
/** Options for {@link
|
|
103
|
+
/** Options for {@link WidgetRemoteSource#getRange}. */
|
|
94
104
|
export interface RangeRequestOptions extends BaseRequestOptions {
|
|
95
105
|
column: string;
|
|
96
106
|
}
|
|
97
107
|
|
|
98
|
-
/** Options for {@link
|
|
108
|
+
/** Options for {@link WidgetRemoteSource#getScatter}. */
|
|
99
109
|
export interface ScatterRequestOptions extends BaseRequestOptions {
|
|
100
110
|
xAxisColumn: string;
|
|
101
111
|
xAxisJoinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
@@ -103,7 +113,7 @@ export interface ScatterRequestOptions extends BaseRequestOptions {
|
|
|
103
113
|
yAxisJoinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
104
114
|
}
|
|
105
115
|
|
|
106
|
-
/** Options for {@link
|
|
116
|
+
/** Options for {@link WidgetRemoteSource#getTable}. */
|
|
107
117
|
export interface TableRequestOptions extends BaseRequestOptions {
|
|
108
118
|
columns: string[];
|
|
109
119
|
sortBy?: string;
|
|
@@ -111,12 +121,16 @@ export interface TableRequestOptions extends BaseRequestOptions {
|
|
|
111
121
|
sortByColumnType?: SortColumnType;
|
|
112
122
|
offset?: number;
|
|
113
123
|
limit?: number;
|
|
124
|
+
/** Local only. */
|
|
125
|
+
searchFilterColumn?: string;
|
|
126
|
+
/** Local only. */
|
|
127
|
+
searchFilterText?: string;
|
|
114
128
|
}
|
|
115
129
|
|
|
116
|
-
/** Options for {@link
|
|
130
|
+
/** Options for {@link WidgetRemoteSource#getTimeSeries}. */
|
|
117
131
|
export interface TimeSeriesRequestOptions extends BaseRequestOptions {
|
|
118
132
|
column: string;
|
|
119
|
-
stepSize
|
|
133
|
+
stepSize: GroupDateType;
|
|
120
134
|
stepMultiplier?: number;
|
|
121
135
|
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
122
136
|
operationColumn?: string;
|
|
@@ -131,35 +145,35 @@ export interface TimeSeriesRequestOptions extends BaseRequestOptions {
|
|
|
131
145
|
*/
|
|
132
146
|
|
|
133
147
|
/**
|
|
134
|
-
* Response from {@link
|
|
148
|
+
* Response from {@link WidgetRemoteSource#getFeatures}.
|
|
135
149
|
* @experimental
|
|
136
150
|
* @internal
|
|
137
151
|
*/
|
|
138
152
|
export type FeaturesResponse = {rows: Record<string, unknown>[]};
|
|
139
153
|
|
|
140
|
-
/** Response from {@link
|
|
141
|
-
export type FormulaResponse = {value: number};
|
|
154
|
+
/** Response from {@link WidgetRemoteSource#getFormula}. */
|
|
155
|
+
export type FormulaResponse = {value: number | null};
|
|
142
156
|
|
|
143
|
-
/** Response from {@link
|
|
157
|
+
/** Response from {@link WidgetRemoteSource#getCategories}. */
|
|
144
158
|
export type CategoryResponse = {name: string; value: number}[];
|
|
145
159
|
|
|
146
|
-
/** Response from {@link
|
|
147
|
-
export type RangeResponse = {min: number; max: number};
|
|
160
|
+
/** Response from {@link WidgetRemoteSource#getRange}. */
|
|
161
|
+
export type RangeResponse = {min: number; max: number} | null;
|
|
148
162
|
|
|
149
|
-
/** Response from {@link
|
|
163
|
+
/** Response from {@link WidgetRemoteSource#getTable}. */
|
|
150
164
|
export type TableResponse = {
|
|
151
165
|
totalCount: number;
|
|
152
166
|
rows: Record<string, number | string>[];
|
|
153
167
|
};
|
|
154
168
|
|
|
155
|
-
/** Response from {@link
|
|
169
|
+
/** Response from {@link WidgetRemoteSource#getScatter}. */
|
|
156
170
|
export type ScatterResponse = [number, number][];
|
|
157
171
|
|
|
158
|
-
/** Response from {@link
|
|
172
|
+
/** Response from {@link WidgetRemoteSource#getTimeSeries}. */
|
|
159
173
|
export type TimeSeriesResponse = {
|
|
160
174
|
rows: {name: string; value: number}[];
|
|
161
|
-
categories
|
|
175
|
+
categories?: string[];
|
|
162
176
|
};
|
|
163
177
|
|
|
164
|
-
/** Response from {@link
|
|
178
|
+
/** Response from {@link WidgetRemoteSource#getHistogram}. */
|
|
165
179
|
export type HistogramResponse = number[];
|
|
@@ -3,8 +3,12 @@ import {
|
|
|
3
3
|
QuadbinQuerySourceOptions,
|
|
4
4
|
VectorQuerySourceOptions,
|
|
5
5
|
} from '../sources/index.js';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
WidgetRemoteSource,
|
|
8
|
+
WidgetRemoteSourceProps,
|
|
9
|
+
} from './widget-remote-source.js';
|
|
7
10
|
import {ModelSource} from '../models/model.js';
|
|
11
|
+
import {Filters} from '../types.js';
|
|
8
12
|
|
|
9
13
|
type LayerQuerySourceOptions =
|
|
10
14
|
| Omit<VectorQuerySourceOptions, 'filters'>
|
|
@@ -35,12 +39,15 @@ export type WidgetQuerySourceResult = {widgetSource: WidgetQuerySource};
|
|
|
35
39
|
* const { widgetSource } = await data;
|
|
36
40
|
* ```
|
|
37
41
|
*/
|
|
38
|
-
export class WidgetQuerySource extends
|
|
39
|
-
LayerQuerySourceOptions &
|
|
42
|
+
export class WidgetQuerySource extends WidgetRemoteSource<
|
|
43
|
+
LayerQuerySourceOptions & WidgetRemoteSourceProps
|
|
40
44
|
> {
|
|
41
|
-
protected override getModelSource(
|
|
45
|
+
protected override getModelSource(
|
|
46
|
+
filters: Filters | undefined,
|
|
47
|
+
filterOwner?: string
|
|
48
|
+
): ModelSource {
|
|
42
49
|
return {
|
|
43
|
-
...super._getModelSource(
|
|
50
|
+
...super._getModelSource(filters, filterOwner),
|
|
44
51
|
type: 'query',
|
|
45
52
|
data: this.props.sqlQuery,
|
|
46
53
|
queryParameters: this.props.queryParameters,
|