@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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/******************************************************************************
|
|
2
2
|
* COMMON
|
|
3
3
|
*/
|
|
4
|
-
import { Format } from './types';
|
|
4
|
+
import { Format } from './types.js';
|
|
5
5
|
/** @internal */
|
|
6
6
|
export type $TODO = any;
|
|
7
7
|
/** @internal */
|
|
@@ -10,7 +10,7 @@ export type $IntentionalAny = any;
|
|
|
10
10
|
* MAP INSTANTIATION
|
|
11
11
|
*/
|
|
12
12
|
/**
|
|
13
|
-
* @
|
|
13
|
+
* @privateRemarks Source: @deck.gl/carto
|
|
14
14
|
* @internal
|
|
15
15
|
*/
|
|
16
16
|
export declare enum SchemaFieldType {
|
|
@@ -25,7 +25,7 @@ export declare enum SchemaFieldType {
|
|
|
25
25
|
Unknown = "unknown"
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
|
-
* @
|
|
28
|
+
* @privateRemarks Source: @deck.gl/carto
|
|
29
29
|
* @internal
|
|
30
30
|
*/
|
|
31
31
|
export interface SchemaField {
|
|
@@ -33,7 +33,7 @@ export interface SchemaField {
|
|
|
33
33
|
type: SchemaFieldType;
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
|
-
* @
|
|
36
|
+
* @privateRemarks Source: @deck.gl/carto
|
|
37
37
|
* @internal
|
|
38
38
|
*/
|
|
39
39
|
export interface MapInstantiation extends MapInstantiationFormats {
|
|
@@ -42,11 +42,15 @@ export interface MapInstantiation extends MapInstantiationFormats {
|
|
|
42
42
|
schema: SchemaField[];
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
|
-
* @
|
|
45
|
+
* @privateRemarks Source: @deck.gl/carto
|
|
46
46
|
* @internal
|
|
47
47
|
*/
|
|
48
48
|
type MapInstantiationFormats = Record<Format, {
|
|
49
49
|
url: string[];
|
|
50
50
|
error?: any;
|
|
51
51
|
}>;
|
|
52
|
+
/******************************************************************************
|
|
53
|
+
* LOCAL CALCULATIONS
|
|
54
|
+
*/
|
|
55
|
+
export type FeatureData = Record<string, unknown>;
|
|
52
56
|
export {};
|
package/build/types.d.ts
CHANGED
|
@@ -1,32 +1,77 @@
|
|
|
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
|
* MAPS AND TILES
|
|
5
6
|
*/
|
|
6
|
-
/** @
|
|
7
|
+
/** @privateRemarks Source: @deck.gl/carto */
|
|
7
8
|
export type Format = 'json' | 'geojson' | 'tilejson';
|
|
8
|
-
/** @
|
|
9
|
+
/** @privateRemarks Source: @carto/constants, @deck.gl/carto */
|
|
9
10
|
export type MapType = 'boundary' | 'query' | 'table' | 'tileset' | 'raster';
|
|
11
|
+
/**
|
|
12
|
+
* Alias for GeoJSON 'BBox' type, semantically representing a viewport.
|
|
13
|
+
* Order of values is "west", "south", "east", "north".
|
|
14
|
+
*/
|
|
15
|
+
export type Viewport = [number, number, number, number];
|
|
16
|
+
/**
|
|
17
|
+
* Subset of deck.gl's Tile2DHeader type, containing only the properties
|
|
18
|
+
* required for local widget calculations. Deeper dependencies on deck.gl
|
|
19
|
+
* APIs should be minimized within this library: @deck.gl/carto depends
|
|
20
|
+
* on the API client, not the other way around.
|
|
21
|
+
* @privateRemarks Source: @deck.gl/geo-layers
|
|
22
|
+
*/
|
|
23
|
+
export type Tile = {
|
|
24
|
+
index: {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
z: number;
|
|
28
|
+
};
|
|
29
|
+
id: string;
|
|
30
|
+
content: unknown;
|
|
31
|
+
zoom: number;
|
|
32
|
+
bbox: {
|
|
33
|
+
west: number;
|
|
34
|
+
east: number;
|
|
35
|
+
north: number;
|
|
36
|
+
south: number;
|
|
37
|
+
};
|
|
38
|
+
isVisible: boolean;
|
|
39
|
+
data?: BinaryFeatureCollection;
|
|
40
|
+
};
|
|
41
|
+
/** Subset of deck.gl's Tile2DHeader type, for spatial indexes. */
|
|
42
|
+
export type SpatialIndexTile = Tile & {
|
|
43
|
+
data?: (Feature & {
|
|
44
|
+
id: bigint;
|
|
45
|
+
})[];
|
|
46
|
+
};
|
|
47
|
+
/** @privateRemarks Source: @deck.gl/carto */
|
|
48
|
+
export type Raster = {
|
|
49
|
+
blockSize: number;
|
|
50
|
+
cells: {
|
|
51
|
+
numericProps: BinaryFeature['numericProps'];
|
|
52
|
+
properties: BinaryFeature['properties'];
|
|
53
|
+
};
|
|
54
|
+
};
|
|
10
55
|
/******************************************************************************
|
|
11
56
|
* AGGREGATION
|
|
12
57
|
*/
|
|
13
58
|
/**
|
|
14
59
|
* Enum for the different types of aggregations available for widgets.
|
|
15
60
|
*
|
|
16
|
-
* @
|
|
17
|
-
* @
|
|
61
|
+
* @privateRemarks Source: @carto/constants
|
|
62
|
+
* @privateRemarks Converted from enum to type union, for improved declarative API.
|
|
18
63
|
*/
|
|
19
64
|
export type AggregationType = 'count' | 'avg' | 'min' | 'max' | 'sum' | 'custom';
|
|
20
65
|
/******************************************************************************
|
|
21
66
|
* FILTERS
|
|
22
67
|
*/
|
|
23
|
-
/** @
|
|
68
|
+
/** @privateRemarks Source: @carto/react-api */
|
|
24
69
|
export type SpatialFilter = Polygon | MultiPolygon;
|
|
25
|
-
/** @
|
|
70
|
+
/** @privateRemarks Source: @deck.gl/carto */
|
|
26
71
|
export interface Filters {
|
|
27
72
|
[column: string]: Filter;
|
|
28
73
|
}
|
|
29
|
-
/** @
|
|
74
|
+
/** @privateRemarks Source: @carto/react-api, @deck.gl/carto */
|
|
30
75
|
export interface Filter {
|
|
31
76
|
[FilterType.IN]?: {
|
|
32
77
|
owner?: string;
|
|
@@ -49,17 +94,32 @@ export interface Filter {
|
|
|
49
94
|
[FilterType.STRING_SEARCH]?: {
|
|
50
95
|
owner?: string;
|
|
51
96
|
values: string[];
|
|
97
|
+
params?: StringSearchOptions;
|
|
52
98
|
};
|
|
53
99
|
}
|
|
54
|
-
/** @
|
|
100
|
+
/** @privateRemarks Source: @carto/react-core */
|
|
55
101
|
export type FilterLogicalOperator = 'and' | 'or';
|
|
102
|
+
/**
|
|
103
|
+
* Type for minimum or maximum value of an interval. Values 'null' and
|
|
104
|
+
* 'undefined' are intentionally allowed, and represent an unbounded value.
|
|
105
|
+
*/
|
|
106
|
+
export type FilterIntervalExtremum = number | null | undefined;
|
|
107
|
+
export type FilterInterval = [FilterIntervalExtremum, FilterIntervalExtremum];
|
|
108
|
+
export type FilterIntervalComplete = [number, number];
|
|
109
|
+
export type StringSearchOptions = {
|
|
110
|
+
useRegExp?: boolean;
|
|
111
|
+
mustStart?: boolean;
|
|
112
|
+
mustEnd?: boolean;
|
|
113
|
+
caseSensitive?: boolean;
|
|
114
|
+
keepSpecialCharacters?: boolean;
|
|
115
|
+
};
|
|
56
116
|
/******************************************************************************
|
|
57
117
|
* GROUPING
|
|
58
118
|
*/
|
|
59
119
|
/**
|
|
60
120
|
* Defines a step size increment for use with {@link TimeSeriesRequestOptions}.
|
|
61
121
|
*
|
|
62
|
-
* @
|
|
122
|
+
* @privateRemarks Source: @carto/react-core
|
|
63
123
|
*/
|
|
64
124
|
export type GroupDateType = 'year' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second';
|
|
65
125
|
/******************************************************************************
|
|
@@ -70,11 +130,11 @@ export type SortColumnType = 'number' | 'string' | 'date';
|
|
|
70
130
|
/******************************************************************************
|
|
71
131
|
* SQL QUERY PARAMETERS
|
|
72
132
|
*/
|
|
73
|
-
/** @
|
|
133
|
+
/** @privateRemarks Source: @deck.gl/carto */
|
|
74
134
|
export type QueryParameterValue = string | number | boolean | Array<QueryParameterValue> | object;
|
|
75
|
-
/** @
|
|
135
|
+
/** @privateRemarks Source: @deck.gl/carto */
|
|
76
136
|
export type NamedQueryParameter = Record<string, QueryParameterValue>;
|
|
77
|
-
/** @
|
|
137
|
+
/** @privateRemarks Source: @deck.gl/carto */
|
|
78
138
|
export type PositionalQueryParameter = QueryParameterValue[];
|
|
79
|
-
/** @
|
|
139
|
+
/** @privateRemarks Source: @deck.gl/carto */
|
|
80
140
|
export type QueryParameters = NamedQueryParameter | PositionalQueryParameter;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns midnight (local time) on the Monday preceeding a given date, in
|
|
3
|
+
* milliseconds since the UNIX epoch.
|
|
4
|
+
*/
|
|
5
|
+
export declare function getMonday(date: number | Date): number;
|
|
6
|
+
/**
|
|
7
|
+
* Returns midnight (UTC) on the Monday preceeding a given date, in
|
|
8
|
+
* milliseconds since the UNIX epoch.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getUTCMonday(date: number | Date): number;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BBox, Geometry } from 'geojson';
|
|
2
|
+
/**
|
|
3
|
+
* Transform tile coords to WGS84 coordinates.
|
|
4
|
+
*
|
|
5
|
+
* @param geometry - any valid geojson geometry
|
|
6
|
+
* @param bbox - geojson bbox
|
|
7
|
+
*/
|
|
8
|
+
export declare function transformTileCoordsToWGS84<T extends Geometry>(geometry: T, bbox: BBox): T;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BBox, Geometry } from 'geojson';
|
|
2
|
+
/**
|
|
3
|
+
* Transform WGS84 coordinates to tile coords.
|
|
4
|
+
* 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)
|
|
5
|
+
*
|
|
6
|
+
* @param geometry - any valid geojson geometry
|
|
7
|
+
* @param bbox - geojson bbox
|
|
8
|
+
*/
|
|
9
|
+
export declare function transformToTileCoords<T extends Geometry>(geometry: T, bbox: BBox): T;
|
package/build/utils.d.ts
CHANGED
|
@@ -9,14 +9,14 @@ type Row<T> = Record<string, T> | Record<string, T>[] | T[] | T;
|
|
|
9
9
|
* Due to each data warehouse having its own behavior with columns,
|
|
10
10
|
* we need to normalize them and transform every key to lowercase.
|
|
11
11
|
*
|
|
12
|
-
* @
|
|
12
|
+
* @privateRemarks Source: @carto/react-widgets
|
|
13
13
|
* @internal
|
|
14
14
|
*/
|
|
15
15
|
export declare function normalizeObjectKeys<T, R extends Row<T>>(el: R): R;
|
|
16
|
-
/** @
|
|
16
|
+
/** @privateRemarks Source: @carto/react-core */
|
|
17
17
|
export declare function assert(condition: unknown, message: string): asserts condition;
|
|
18
18
|
/**
|
|
19
|
-
* @
|
|
19
|
+
* @privateRemarks Source: @carto/react-core
|
|
20
20
|
* @internal
|
|
21
21
|
*/
|
|
22
22
|
export declare 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,5 +1,5 @@
|
|
|
1
|
-
import { SpatialFilterPolyfillMode, TileResolution } from '../sources/types';
|
|
2
|
-
import { GroupDateType, SortColumnType, SortDirection, SpatialFilter } from '../types';
|
|
1
|
+
import { SpatialFilterPolyfillMode, TileResolution } from '../sources/types.js';
|
|
2
|
+
import { Filters, GroupDateType, SortColumnType, SortDirection, SpatialFilter } from '../types.js';
|
|
3
3
|
/******************************************************************************
|
|
4
4
|
* WIDGET API REQUESTS
|
|
5
5
|
*/
|
|
@@ -8,23 +8,29 @@ export interface ViewState {
|
|
|
8
8
|
latitude: number;
|
|
9
9
|
longitude: number;
|
|
10
10
|
}
|
|
11
|
-
/** Common options for {@link
|
|
11
|
+
/** Common options for {@link WidgetRemoteSource} requests. */
|
|
12
12
|
interface BaseRequestOptions {
|
|
13
|
+
/** @deprecated */
|
|
14
|
+
abortController?: AbortController;
|
|
15
|
+
signal?: AbortSignal;
|
|
13
16
|
spatialFilter?: SpatialFilter;
|
|
14
17
|
spatialFiltersMode?: SpatialFilterPolyfillMode;
|
|
15
18
|
/** Required for table- and query-based spatial index sources (H3, Quadbin). */
|
|
16
19
|
spatialIndexReferenceViewState?: ViewState;
|
|
17
|
-
|
|
20
|
+
/** Overrides source filters, if any. */
|
|
21
|
+
filters?: Filters;
|
|
18
22
|
filterOwner?: string;
|
|
19
23
|
}
|
|
20
|
-
/** Options for {@link
|
|
24
|
+
/** Options for {@link WidgetRemoteSource#getCategories}. */
|
|
21
25
|
export interface CategoryRequestOptions extends BaseRequestOptions {
|
|
22
26
|
column: string;
|
|
23
27
|
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
24
28
|
operationColumn?: string;
|
|
29
|
+
/** Local only. */
|
|
30
|
+
joinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
25
31
|
}
|
|
26
32
|
/**
|
|
27
|
-
* Options for {@link
|
|
33
|
+
* Options for {@link WidgetRemoteSource#getFeatures}.
|
|
28
34
|
* @experimental
|
|
29
35
|
* @internal
|
|
30
36
|
*/
|
|
@@ -60,30 +66,33 @@ export interface FeaturesRequestOptions extends BaseRequestOptions {
|
|
|
60
66
|
*/
|
|
61
67
|
tileResolution?: TileResolution;
|
|
62
68
|
}
|
|
63
|
-
/** Options for {@link
|
|
69
|
+
/** Options for {@link WidgetRemoteSource#getFormula}. */
|
|
64
70
|
export interface FormulaRequestOptions extends BaseRequestOptions {
|
|
65
71
|
column: string;
|
|
66
|
-
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
72
|
+
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum' | 'custom';
|
|
67
73
|
operationExp?: string;
|
|
74
|
+
joinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
68
75
|
}
|
|
69
|
-
/** Options for {@link
|
|
76
|
+
/** Options for {@link WidgetRemoteSource#getHistogram}. */
|
|
70
77
|
export interface HistogramRequestOptions extends BaseRequestOptions {
|
|
71
78
|
column: string;
|
|
72
79
|
ticks: number[];
|
|
73
80
|
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
81
|
+
/** Local only. */
|
|
82
|
+
joinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
74
83
|
}
|
|
75
|
-
/** Options for {@link
|
|
84
|
+
/** Options for {@link WidgetRemoteSource#getRange}. */
|
|
76
85
|
export interface RangeRequestOptions extends BaseRequestOptions {
|
|
77
86
|
column: string;
|
|
78
87
|
}
|
|
79
|
-
/** Options for {@link
|
|
88
|
+
/** Options for {@link WidgetRemoteSource#getScatter}. */
|
|
80
89
|
export interface ScatterRequestOptions extends BaseRequestOptions {
|
|
81
90
|
xAxisColumn: string;
|
|
82
91
|
xAxisJoinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
83
92
|
yAxisColumn: string;
|
|
84
93
|
yAxisJoinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
85
94
|
}
|
|
86
|
-
/** Options for {@link
|
|
95
|
+
/** Options for {@link WidgetRemoteSource#getTable}. */
|
|
87
96
|
export interface TableRequestOptions extends BaseRequestOptions {
|
|
88
97
|
columns: string[];
|
|
89
98
|
sortBy?: string;
|
|
@@ -91,11 +100,15 @@ export interface TableRequestOptions extends BaseRequestOptions {
|
|
|
91
100
|
sortByColumnType?: SortColumnType;
|
|
92
101
|
offset?: number;
|
|
93
102
|
limit?: number;
|
|
103
|
+
/** Local only. */
|
|
104
|
+
searchFilterColumn?: string;
|
|
105
|
+
/** Local only. */
|
|
106
|
+
searchFilterText?: string;
|
|
94
107
|
}
|
|
95
|
-
/** Options for {@link
|
|
108
|
+
/** Options for {@link WidgetRemoteSource#getTimeSeries}. */
|
|
96
109
|
export interface TimeSeriesRequestOptions extends BaseRequestOptions {
|
|
97
110
|
column: string;
|
|
98
|
-
stepSize
|
|
111
|
+
stepSize: GroupDateType;
|
|
99
112
|
stepMultiplier?: number;
|
|
100
113
|
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
101
114
|
operationColumn?: string;
|
|
@@ -108,42 +121,42 @@ export interface TimeSeriesRequestOptions extends BaseRequestOptions {
|
|
|
108
121
|
* WIDGET API RESPONSES
|
|
109
122
|
*/
|
|
110
123
|
/**
|
|
111
|
-
* Response from {@link
|
|
124
|
+
* Response from {@link WidgetRemoteSource#getFeatures}.
|
|
112
125
|
* @experimental
|
|
113
126
|
* @internal
|
|
114
127
|
*/
|
|
115
128
|
export type FeaturesResponse = {
|
|
116
129
|
rows: Record<string, unknown>[];
|
|
117
130
|
};
|
|
118
|
-
/** Response from {@link
|
|
131
|
+
/** Response from {@link WidgetRemoteSource#getFormula}. */
|
|
119
132
|
export type FormulaResponse = {
|
|
120
|
-
value: number;
|
|
133
|
+
value: number | null;
|
|
121
134
|
};
|
|
122
|
-
/** Response from {@link
|
|
135
|
+
/** Response from {@link WidgetRemoteSource#getCategories}. */
|
|
123
136
|
export type CategoryResponse = {
|
|
124
137
|
name: string;
|
|
125
138
|
value: number;
|
|
126
139
|
}[];
|
|
127
|
-
/** Response from {@link
|
|
140
|
+
/** Response from {@link WidgetRemoteSource#getRange}. */
|
|
128
141
|
export type RangeResponse = {
|
|
129
142
|
min: number;
|
|
130
143
|
max: number;
|
|
131
|
-
};
|
|
132
|
-
/** Response from {@link
|
|
144
|
+
} | null;
|
|
145
|
+
/** Response from {@link WidgetRemoteSource#getTable}. */
|
|
133
146
|
export type TableResponse = {
|
|
134
147
|
totalCount: number;
|
|
135
148
|
rows: Record<string, number | string>[];
|
|
136
149
|
};
|
|
137
|
-
/** Response from {@link
|
|
150
|
+
/** Response from {@link WidgetRemoteSource#getScatter}. */
|
|
138
151
|
export type ScatterResponse = [number, number][];
|
|
139
|
-
/** Response from {@link
|
|
152
|
+
/** Response from {@link WidgetRemoteSource#getTimeSeries}. */
|
|
140
153
|
export type TimeSeriesResponse = {
|
|
141
154
|
rows: {
|
|
142
155
|
name: string;
|
|
143
156
|
value: number;
|
|
144
157
|
}[];
|
|
145
|
-
categories
|
|
158
|
+
categories?: string[];
|
|
146
159
|
};
|
|
147
|
-
/** Response from {@link
|
|
160
|
+
/** Response from {@link WidgetRemoteSource#getHistogram}. */
|
|
148
161
|
export type HistogramResponse = number[];
|
|
149
162
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { H3QuerySourceOptions, QuadbinQuerySourceOptions, VectorQuerySourceOptions } from '../sources/index.js';
|
|
2
|
-
import {
|
|
2
|
+
import { WidgetRemoteSource, WidgetRemoteSourceProps } from './widget-remote-source.js';
|
|
3
3
|
import { ModelSource } from '../models/model.js';
|
|
4
|
+
import { Filters } from '../types.js';
|
|
4
5
|
type LayerQuerySourceOptions = Omit<VectorQuerySourceOptions, 'filters'> | Omit<H3QuerySourceOptions, 'filters'> | Omit<QuadbinQuerySourceOptions, 'filters'>;
|
|
5
6
|
export type WidgetQuerySourceResult = {
|
|
6
7
|
widgetSource: WidgetQuerySource;
|
|
@@ -27,7 +28,7 @@ export type WidgetQuerySourceResult = {
|
|
|
27
28
|
* const { widgetSource } = await data;
|
|
28
29
|
* ```
|
|
29
30
|
*/
|
|
30
|
-
export declare class WidgetQuerySource extends
|
|
31
|
-
protected getModelSource(
|
|
31
|
+
export declare class WidgetQuerySource extends WidgetRemoteSource<LayerQuerySourceOptions & WidgetRemoteSourceProps> {
|
|
32
|
+
protected getModelSource(filters: Filters | undefined, filterOwner?: string): ModelSource;
|
|
32
33
|
}
|
|
33
34
|
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CategoryRequestOptions, CategoryResponse, FeaturesRequestOptions, FeaturesResponse, FormulaRequestOptions, FormulaResponse, HistogramRequestOptions, HistogramResponse, RangeRequestOptions, RangeResponse, ScatterRequestOptions, ScatterResponse, TableRequestOptions, TableResponse, TimeSeriesRequestOptions, TimeSeriesResponse } from './types.js';
|
|
2
|
+
import { WidgetSource, WidgetSourceProps } from './widget-source.js';
|
|
3
|
+
export type WidgetRemoteSourceProps = WidgetSourceProps;
|
|
4
|
+
/**
|
|
5
|
+
* Source for Widget API requests.
|
|
6
|
+
*
|
|
7
|
+
* Abstract class. Use {@link WidgetQuerySource} or {@link WidgetTableSource}.
|
|
8
|
+
*/
|
|
9
|
+
export declare abstract class WidgetRemoteSource<Props extends WidgetRemoteSourceProps> extends WidgetSource<Props> {
|
|
10
|
+
getCategories(options: CategoryRequestOptions): Promise<CategoryResponse>;
|
|
11
|
+
getFeatures(options: FeaturesRequestOptions): Promise<FeaturesResponse>;
|
|
12
|
+
getFormula(options: FormulaRequestOptions): Promise<FormulaResponse>;
|
|
13
|
+
getHistogram(options: HistogramRequestOptions): Promise<HistogramResponse>;
|
|
14
|
+
getRange(options: RangeRequestOptions): Promise<RangeResponse>;
|
|
15
|
+
getScatter(options: ScatterRequestOptions): Promise<ScatterResponse>;
|
|
16
|
+
getTable(options: TableRequestOptions): Promise<TableResponse>;
|
|
17
|
+
getTimeSeries(options: TimeSeriesRequestOptions): Promise<TimeSeriesResponse>;
|
|
18
|
+
}
|
|
@@ -1,43 +1,36 @@
|
|
|
1
1
|
import { CategoryRequestOptions, CategoryResponse, FeaturesRequestOptions, FeaturesResponse, FormulaRequestOptions, FormulaResponse, HistogramRequestOptions, HistogramResponse, RangeRequestOptions, RangeResponse, ScatterRequestOptions, ScatterResponse, TableRequestOptions, TableResponse, TimeSeriesRequestOptions, TimeSeriesResponse, ViewState } from './types.js';
|
|
2
|
-
import { FilterLogicalOperator, Filter, SpatialFilter } from '../types.js';
|
|
2
|
+
import { FilterLogicalOperator, Filter, SpatialFilter, Filters } from '../types.js';
|
|
3
3
|
import { ModelSource } from '../models/model.js';
|
|
4
4
|
import { SourceOptions } from '../sources/index.js';
|
|
5
5
|
import { ApiVersion } from '../constants.js';
|
|
6
|
-
export interface
|
|
6
|
+
export interface WidgetSourceProps extends Omit<SourceOptions, 'filters'> {
|
|
7
7
|
apiVersion?: ApiVersion;
|
|
8
8
|
filters?: Record<string, Filter>;
|
|
9
9
|
filtersLogicalOperator?: FilterLogicalOperator;
|
|
10
10
|
}
|
|
11
|
-
export type WidgetSource = WidgetBaseSource<WidgetBaseSourceProps>;
|
|
12
11
|
/**
|
|
13
12
|
* Source for Widget API requests on a data source defined by a SQL query.
|
|
14
13
|
*
|
|
15
14
|
* Abstract class. Use {@link WidgetQuerySource} or {@link WidgetTableSource}.
|
|
16
15
|
*/
|
|
17
|
-
export declare abstract class
|
|
16
|
+
export declare abstract class WidgetSource<Props extends WidgetSourceProps> {
|
|
18
17
|
readonly props: Props;
|
|
19
|
-
static defaultProps: Partial<
|
|
18
|
+
static defaultProps: Partial<WidgetSourceProps>;
|
|
20
19
|
constructor(props: Props);
|
|
21
20
|
/**
|
|
22
|
-
* Subclasses of {@link
|
|
23
|
-
* {@link
|
|
21
|
+
* Subclasses of {@link WidgetRemoteSource} must implement this method, calling
|
|
22
|
+
* {@link WidgetRemoteSource.prototype._getModelSource} for common source
|
|
24
23
|
* properties, and adding additional required properties including 'type' and
|
|
25
24
|
* 'data'.
|
|
26
25
|
*/
|
|
27
|
-
protected abstract getModelSource(
|
|
28
|
-
protected _getModelSource(
|
|
26
|
+
protected abstract getModelSource(filters: Filters | undefined, filterOwner?: string): ModelSource;
|
|
27
|
+
protected _getModelSource(filters: Filters | undefined, filterOwner?: string): Omit<ModelSource, 'type' | 'data'>;
|
|
29
28
|
protected _getSpatialFiltersResolution(source: Omit<ModelSource, 'type' | 'data'>, spatialFilter?: SpatialFilter, referenceViewState?: ViewState): number | undefined;
|
|
30
|
-
/****************************************************************************
|
|
31
|
-
* CATEGORIES
|
|
32
|
-
*/
|
|
33
29
|
/**
|
|
34
30
|
* Returns a list of labeled datapoints for categorical data. Suitable for
|
|
35
31
|
* charts including grouped bar charts, pie charts, and tree charts.
|
|
36
32
|
*/
|
|
37
|
-
getCategories(options: CategoryRequestOptions): Promise<CategoryResponse>;
|
|
38
|
-
/****************************************************************************
|
|
39
|
-
* FEATURES
|
|
40
|
-
*/
|
|
33
|
+
abstract getCategories(options: CategoryRequestOptions): Promise<CategoryResponse>;
|
|
41
34
|
/**
|
|
42
35
|
* Given a list of feature IDs (as found in `_carto_feature_id`) returns all
|
|
43
36
|
* matching features. In datasets containing features with duplicate geometries,
|
|
@@ -46,54 +39,36 @@ export declare abstract class WidgetBaseSource<Props extends WidgetBaseSourcePro
|
|
|
46
39
|
* @internal
|
|
47
40
|
* @experimental
|
|
48
41
|
*/
|
|
49
|
-
getFeatures(options: FeaturesRequestOptions): Promise<FeaturesResponse>;
|
|
50
|
-
/****************************************************************************
|
|
51
|
-
* FORMULA
|
|
52
|
-
*/
|
|
42
|
+
abstract getFeatures(options: FeaturesRequestOptions): Promise<FeaturesResponse>;
|
|
53
43
|
/**
|
|
54
44
|
* Returns a scalar numerical statistic over all matching data. Suitable
|
|
55
45
|
* for 'headline' or 'scorecard' figures such as counts and sums.
|
|
56
46
|
*/
|
|
57
|
-
getFormula(options: FormulaRequestOptions): Promise<FormulaResponse>;
|
|
58
|
-
/****************************************************************************
|
|
59
|
-
* HISTOGRAM
|
|
60
|
-
*/
|
|
47
|
+
abstract getFormula(options: FormulaRequestOptions): Promise<FormulaResponse>;
|
|
61
48
|
/**
|
|
62
49
|
* Returns a list of labeled datapoints for 'bins' of data defined as ticks
|
|
63
50
|
* over a numerical range. Suitable for histogram charts.
|
|
64
51
|
*/
|
|
65
|
-
getHistogram(options: HistogramRequestOptions): Promise<HistogramResponse>;
|
|
66
|
-
/****************************************************************************
|
|
67
|
-
* RANGE
|
|
68
|
-
*/
|
|
52
|
+
abstract getHistogram(options: HistogramRequestOptions): Promise<HistogramResponse>;
|
|
69
53
|
/**
|
|
70
54
|
* Returns a range (min and max) for a numerical column of matching rows.
|
|
71
55
|
* Suitable for displaying certain 'headline' or 'scorecard' statistics,
|
|
72
56
|
* or rendering a range slider UI for filtering.
|
|
73
57
|
*/
|
|
74
|
-
getRange(options: RangeRequestOptions): Promise<RangeResponse>;
|
|
75
|
-
/****************************************************************************
|
|
76
|
-
* SCATTER
|
|
77
|
-
*/
|
|
58
|
+
abstract getRange(options: RangeRequestOptions): Promise<RangeResponse>;
|
|
78
59
|
/**
|
|
79
60
|
* Returns a list of bivariate datapoints defined as numerical 'x' and 'y'
|
|
80
61
|
* values. Suitable for rendering scatter plots.
|
|
81
62
|
*/
|
|
82
|
-
getScatter(options: ScatterRequestOptions): Promise<ScatterResponse>;
|
|
83
|
-
/****************************************************************************
|
|
84
|
-
* TABLE
|
|
85
|
-
*/
|
|
63
|
+
abstract getScatter(options: ScatterRequestOptions): Promise<ScatterResponse>;
|
|
86
64
|
/**
|
|
87
65
|
* Returns a list of arbitrary data rows, with support for pagination and
|
|
88
66
|
* sorting. Suitable for displaying tables and lists.
|
|
89
67
|
*/
|
|
90
|
-
getTable(options: TableRequestOptions): Promise<TableResponse>;
|
|
91
|
-
/****************************************************************************
|
|
92
|
-
* TIME SERIES
|
|
93
|
-
*/
|
|
68
|
+
abstract getTable(options: TableRequestOptions): Promise<TableResponse>;
|
|
94
69
|
/**
|
|
95
70
|
* Returns a series of labeled numerical values, grouped into equally-sized
|
|
96
71
|
* time intervals. Suitable for rendering time series charts.
|
|
97
72
|
*/
|
|
98
|
-
getTimeSeries(options: TimeSeriesRequestOptions): Promise<TimeSeriesResponse>;
|
|
73
|
+
abstract getTimeSeries(options: TimeSeriesRequestOptions): Promise<TimeSeriesResponse>;
|
|
99
74
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { H3TableSourceOptions, QuadbinTableSourceOptions, VectorTableSourceOptions } from '../sources/index.js';
|
|
2
|
-
import {
|
|
2
|
+
import { WidgetRemoteSource, WidgetRemoteSourceProps } from './widget-remote-source.js';
|
|
3
3
|
import { ModelSource } from '../models/model.js';
|
|
4
|
+
import { Filters } from '../types.js';
|
|
4
5
|
type LayerTableSourceOptions = Omit<VectorTableSourceOptions, 'filters'> | Omit<H3TableSourceOptions, 'filters'> | Omit<QuadbinTableSourceOptions, 'filters'>;
|
|
5
6
|
export type WidgetTableSourceResult = {
|
|
6
7
|
widgetSource: WidgetTableSource;
|
|
@@ -27,7 +28,7 @@ export type WidgetTableSourceResult = {
|
|
|
27
28
|
* const { widgetSource } = await data;
|
|
28
29
|
* ```
|
|
29
30
|
*/
|
|
30
|
-
export declare class WidgetTableSource extends
|
|
31
|
-
protected getModelSource(
|
|
31
|
+
export declare class WidgetTableSource extends WidgetRemoteSource<LayerTableSourceOptions & WidgetRemoteSourceProps> {
|
|
32
|
+
protected getModelSource(filters: Filters | undefined, filterOwner?: string): ModelSource;
|
|
32
33
|
}
|
|
33
34
|
export {};
|