@carto/api-client 0.4.6-0 → 0.4.6
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 +4 -0
- package/build/api-client.cjs +208 -2167
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.modern.js +208 -2040
- package/build/api-client.modern.js.map +1 -1
- package/build/constants.d.ts +0 -22
- package/build/index.d.ts +1 -4
- package/build/models/index.d.ts +1 -1
- package/build/sources/h3-tileset-source.d.ts +1 -2
- package/build/sources/index.d.ts +1 -1
- package/build/sources/quadbin-tileset-source.d.ts +1 -2
- package/build/sources/vector-tileset-source.d.ts +1 -2
- package/build/spatial-index.d.ts +7 -1
- package/build/types-internal.d.ts +0 -4
- package/build/types.d.ts +1 -61
- package/build/widget-sources/index.d.ts +1 -3
- package/build/widget-sources/types.d.ts +22 -31
- package/build/widget-sources/{widget-source.d.ts → widget-base-source.d.ts} +38 -13
- package/build/widget-sources/widget-query-source.d.ts +2 -2
- package/build/widget-sources/widget-table-source.d.ts +2 -2
- package/package.json +11 -14
- package/src/constants.ts +0 -25
- package/src/index.ts +1 -5
- package/src/models/index.ts +1 -1
- package/src/sources/h3-tileset-source.ts +6 -18
- package/src/sources/index.ts +1 -1
- package/src/sources/quadbin-tileset-source.ts +6 -18
- package/src/sources/raster-source.ts +0 -1
- package/src/sources/vector-query-source.ts +2 -5
- package/src/sources/vector-table-source.ts +2 -5
- package/src/sources/vector-tileset-source.ts +6 -19
- package/src/spatial-index.ts +8 -5
- package/src/types-internal.ts +0 -6
- package/src/types.ts +2 -60
- package/src/widget-sources/index.ts +1 -3
- package/src/widget-sources/types.ts +22 -32
- package/src/widget-sources/{widget-remote-source.ts → widget-base-source.ts} +147 -12
- package/src/widget-sources/widget-query-source.ts +3 -6
- package/src/widget-sources/widget-table-source.ts +3 -6
- package/build/filters/Filter.d.ts +0 -13
- package/build/filters/FilterTypes.d.ts +0 -3
- package/build/filters/geosjonFeatures.d.ts +0 -8
- package/build/filters/index.d.ts +0 -6
- package/build/filters/tileFeatures.d.ts +0 -20
- package/build/filters/tileFeaturesGeometries.d.ts +0 -13
- package/build/filters/tileFeaturesSpatialIndex.d.ts +0 -10
- package/build/operations/aggregation.d.ts +0 -8
- package/build/operations/applySorting.d.ts +0 -20
- package/build/operations/groupBy.d.ts +0 -15
- package/build/operations/groupByDate.d.ts +0 -11
- package/build/operations/histogram.d.ts +0 -13
- package/build/operations/index.d.ts +0 -6
- package/build/operations/scatterPlot.d.ts +0 -14
- package/build/utils/dateUtils.d.ts +0 -10
- package/build/utils/getTileFormat.d.ts +0 -3
- package/build/utils/makeIntervalComplete.d.ts +0 -2
- package/build/utils/transformTileCoordsToWGS84.d.ts +0 -8
- package/build/utils/transformToTileCoords.d.ts +0 -9
- package/build/widget-sources/widget-remote-source.d.ts +0 -18
- package/build/widget-sources/widget-tileset-source.d.ts +0 -76
- package/src/filters/Filter.ts +0 -169
- package/src/filters/FilterTypes.ts +0 -109
- package/src/filters/geosjonFeatures.ts +0 -32
- package/src/filters/index.ts +0 -6
- package/src/filters/tileFeatures.ts +0 -56
- package/src/filters/tileFeaturesGeometries.ts +0 -444
- package/src/filters/tileFeaturesSpatialIndex.ts +0 -119
- package/src/operations/aggregation.ts +0 -154
- package/src/operations/applySorting.ts +0 -109
- package/src/operations/groupBy.ts +0 -59
- package/src/operations/groupByDate.ts +0 -98
- package/src/operations/histogram.ts +0 -66
- package/src/operations/index.ts +0 -6
- package/src/operations/scatterPlot.ts +0 -50
- package/src/utils/dateUtils.ts +0 -28
- package/src/utils/getTileFormat.ts +0 -9
- package/src/utils/makeIntervalComplete.ts +0 -17
- package/src/utils/transformTileCoordsToWGS84.ts +0 -77
- package/src/utils/transformToTileCoords.ts +0 -85
- package/src/widget-sources/widget-source.ts +0 -160
- package/src/widget-sources/widget-tileset-source.ts +0 -407
package/build/constants.d.ts
CHANGED
|
@@ -29,25 +29,3 @@ export declare enum ApiVersion {
|
|
|
29
29
|
}
|
|
30
30
|
/** @internalRemarks Source: @carto/constants, @deck.gl/carto */
|
|
31
31
|
export declare const DEFAULT_API_BASE_URL = "https://gcp-us-east1.api.carto.com";
|
|
32
|
-
/** @internalRemarks Source: @carto/react-core */
|
|
33
|
-
export declare enum TileFormat {
|
|
34
|
-
MVT = "mvt",
|
|
35
|
-
JSON = "json",
|
|
36
|
-
GEOJSON = "geojson",
|
|
37
|
-
BINARY = "binary"
|
|
38
|
-
}
|
|
39
|
-
/** @internalRemarks Source: @carto/react-core */
|
|
40
|
-
export declare enum SpatialIndex {
|
|
41
|
-
H3 = "h3",
|
|
42
|
-
S2 = "s2",
|
|
43
|
-
QUADBIN = "quadbin"
|
|
44
|
-
}
|
|
45
|
-
/** @internalRemarks Source: @carto/react-core */
|
|
46
|
-
export declare enum Provider {
|
|
47
|
-
BIGQUERY = "bigquery",
|
|
48
|
-
REDSHIFT = "redshift",
|
|
49
|
-
POSTGRES = "postgres",
|
|
50
|
-
SNOWFLAKE = "snowflake",
|
|
51
|
-
DATABRICKS = "databricks",
|
|
52
|
-
DATABRICKS_REST = "databricksRest"
|
|
53
|
-
}
|
package/build/index.d.ts
CHANGED
|
@@ -8,7 +8,4 @@ export * from './types.js';
|
|
|
8
8
|
export { APIErrorContext, APIRequestType, CartoAPIError, QueryOptions, buildPublicMapUrl, // Internal, but required for fetchMap().
|
|
9
9
|
buildStatsUrl, // Internal, but required for fetchMap().
|
|
10
10
|
query, requestWithParameters, } from './api/index.js';
|
|
11
|
-
export
|
|
12
|
-
export * from './operations/index.js';
|
|
13
|
-
export * from './utils/makeIntervalComplete.js';
|
|
14
|
-
export * from './utils/transformToTileCoords.js';
|
|
11
|
+
export { _getHexagonResolution } from './spatial-index.js';
|
package/build/models/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { WidgetTilesetSourceResult } from '../widget-sources';
|
|
2
1
|
import type { SourceOptions, TilejsonResult, TilesetSourceOptions } from './types';
|
|
3
2
|
export type H3TilesetSourceOptions = SourceOptions & TilesetSourceOptions;
|
|
4
|
-
export type H3TilesetSourceResponse = TilejsonResult
|
|
3
|
+
export type H3TilesetSourceResponse = TilejsonResult;
|
|
5
4
|
export declare const h3TilesetSource: (options: H3TilesetSourceOptions) => Promise<H3TilesetSourceResponse>;
|
package/build/sources/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export type { H3TableSourceOptions, H3TableSourceResponse, } from './h3-table-so
|
|
|
11
11
|
export { h3TilesetSource } from './h3-tileset-source';
|
|
12
12
|
export type { H3TilesetSourceOptions, H3TilesetSourceResponse, } from './h3-tileset-source';
|
|
13
13
|
export { rasterSource } from './raster-source';
|
|
14
|
-
export type { RasterSourceOptions } from './raster-source';
|
|
14
|
+
export type { RasterSourceOptions, RasterSourceResponse } from './raster-source';
|
|
15
15
|
export { quadbinQuerySource } from './quadbin-query-source';
|
|
16
16
|
export type { QuadbinQuerySourceOptions, QuadbinQuerySourceResponse, } from './quadbin-query-source';
|
|
17
17
|
export { quadbinTableSource } from './quadbin-table-source';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { WidgetTilesetSourceResult } from '../widget-sources';
|
|
2
1
|
import type { SourceOptions, TilejsonResult, TilesetSourceOptions } from './types';
|
|
3
2
|
export type QuadbinTilesetSourceOptions = SourceOptions & TilesetSourceOptions;
|
|
4
|
-
export type QuadbinTilesetSourceResponse = TilejsonResult
|
|
3
|
+
export type QuadbinTilesetSourceResponse = TilejsonResult;
|
|
5
4
|
export declare const quadbinTilesetSource: (options: QuadbinTilesetSourceOptions) => Promise<QuadbinTilesetSourceResponse>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { WidgetTilesetSourceResult } from '../widget-sources';
|
|
2
1
|
import type { SourceOptions, TilesetSourceOptions, TilejsonResult } from './types';
|
|
3
2
|
export type VectorTilesetSourceOptions = SourceOptions & TilesetSourceOptions;
|
|
4
|
-
export type VectorTilesetSourceResponse = TilejsonResult
|
|
3
|
+
export type VectorTilesetSourceResponse = TilejsonResult;
|
|
5
4
|
export declare const vectorTilesetSource: (options: VectorTilesetSourceOptions) => Promise<VectorTilesetSourceResponse>;
|
package/build/spatial-index.d.ts
CHANGED
|
@@ -2,7 +2,13 @@ import type { ModelSource } from './models/model';
|
|
|
2
2
|
import type { AggregationOptions } from './sources/types';
|
|
3
3
|
import type { ViewState } from './widget-sources';
|
|
4
4
|
export declare function getSpatialFiltersResolution(source: Partial<ModelSource & AggregationOptions>, viewState: ViewState): number | undefined;
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Resolution conversion function. Takes a WebMercatorViewport and returns
|
|
7
|
+
* a H3 resolution such that the screen space size of the hexagons is
|
|
8
|
+
* "similar" to the given tileSize on screen. Intended for use with deck.gl.
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare function _getHexagonResolution(viewport: {
|
|
6
12
|
zoom: number;
|
|
7
13
|
latitude: number;
|
|
8
14
|
}, tileSize: number): number;
|
|
@@ -49,8 +49,4 @@ 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>;
|
|
56
52
|
export {};
|
package/build/types.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { FilterType } from './constants.js';
|
|
2
|
-
import type { Polygon, MultiPolygon
|
|
3
|
-
import type { BinaryFeature, BinaryFeatureCollection } from '@loaders.gl/schema';
|
|
2
|
+
import type { Polygon, MultiPolygon } from 'geojson';
|
|
4
3
|
/******************************************************************************
|
|
5
4
|
* MAPS AND TILES
|
|
6
5
|
*/
|
|
@@ -8,50 +7,6 @@ import type { BinaryFeature, BinaryFeatureCollection } from '@loaders.gl/schema'
|
|
|
8
7
|
export type Format = 'json' | 'geojson' | 'tilejson';
|
|
9
8
|
/** @internalRemarks Source: @carto/constants, @deck.gl/carto */
|
|
10
9
|
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
|
-
* @internalRemarks 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
|
-
/** @internalRemarks Source: @deck.gl/carto */
|
|
48
|
-
export type Raster = {
|
|
49
|
-
blockSize: number;
|
|
50
|
-
cells: {
|
|
51
|
-
numericProps: BinaryFeature['numericProps'];
|
|
52
|
-
properties: BinaryFeature['properties'];
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
10
|
/******************************************************************************
|
|
56
11
|
* AGGREGATION
|
|
57
12
|
*/
|
|
@@ -94,25 +49,10 @@ export interface Filter {
|
|
|
94
49
|
[FilterType.STRING_SEARCH]?: {
|
|
95
50
|
owner?: string;
|
|
96
51
|
values: string[];
|
|
97
|
-
params?: StringSearchOptions;
|
|
98
52
|
};
|
|
99
53
|
}
|
|
100
54
|
/** @internalRemarks Source: @carto/react-core */
|
|
101
55
|
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
|
-
};
|
|
116
56
|
/******************************************************************************
|
|
117
57
|
* GROUPING
|
|
118
58
|
*/
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
export * from './widget-source.js';
|
|
1
|
+
export * from './widget-base-source.js';
|
|
2
2
|
export * from './widget-query-source.js';
|
|
3
|
-
export * from './widget-remote-source.js';
|
|
4
3
|
export * from './widget-table-source.js';
|
|
5
|
-
export * from './widget-tileset-source.js';
|
|
6
4
|
export * from './types.js';
|
|
@@ -8,7 +8,7 @@ export interface ViewState {
|
|
|
8
8
|
latitude: number;
|
|
9
9
|
longitude: number;
|
|
10
10
|
}
|
|
11
|
-
/** Common options for {@link
|
|
11
|
+
/** Common options for {@link WidgetBaseSource} requests. */
|
|
12
12
|
interface BaseRequestOptions {
|
|
13
13
|
spatialFilter?: SpatialFilter;
|
|
14
14
|
spatialFiltersMode?: SpatialFilterPolyfillMode;
|
|
@@ -17,16 +17,14 @@ interface BaseRequestOptions {
|
|
|
17
17
|
abortController?: AbortController;
|
|
18
18
|
filterOwner?: string;
|
|
19
19
|
}
|
|
20
|
-
/** Options for {@link
|
|
20
|
+
/** Options for {@link WidgetBaseSource#getCategories}. */
|
|
21
21
|
export interface CategoryRequestOptions extends BaseRequestOptions {
|
|
22
22
|
column: string;
|
|
23
23
|
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
24
24
|
operationColumn?: string;
|
|
25
|
-
/** Local only. */
|
|
26
|
-
joinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
27
25
|
}
|
|
28
26
|
/**
|
|
29
|
-
* Options for {@link
|
|
27
|
+
* Options for {@link WidgetBaseSource#getFeatures}.
|
|
30
28
|
* @experimental
|
|
31
29
|
* @internal
|
|
32
30
|
*/
|
|
@@ -62,33 +60,30 @@ export interface FeaturesRequestOptions extends BaseRequestOptions {
|
|
|
62
60
|
*/
|
|
63
61
|
tileResolution?: TileResolution;
|
|
64
62
|
}
|
|
65
|
-
/** Options for {@link
|
|
63
|
+
/** Options for {@link WidgetBaseSource#getFormula}. */
|
|
66
64
|
export interface FormulaRequestOptions extends BaseRequestOptions {
|
|
67
65
|
column: string;
|
|
68
|
-
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum'
|
|
66
|
+
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
69
67
|
operationExp?: string;
|
|
70
|
-
joinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
71
68
|
}
|
|
72
|
-
/** Options for {@link
|
|
69
|
+
/** Options for {@link WidgetBaseSource#getHistogram}. */
|
|
73
70
|
export interface HistogramRequestOptions extends BaseRequestOptions {
|
|
74
71
|
column: string;
|
|
75
72
|
ticks: number[];
|
|
76
73
|
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
77
|
-
/** Local only. */
|
|
78
|
-
joinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
79
74
|
}
|
|
80
|
-
/** Options for {@link
|
|
75
|
+
/** Options for {@link WidgetBaseSource#getRange}. */
|
|
81
76
|
export interface RangeRequestOptions extends BaseRequestOptions {
|
|
82
77
|
column: string;
|
|
83
78
|
}
|
|
84
|
-
/** Options for {@link
|
|
79
|
+
/** Options for {@link WidgetBaseSource#getScatter}. */
|
|
85
80
|
export interface ScatterRequestOptions extends BaseRequestOptions {
|
|
86
81
|
xAxisColumn: string;
|
|
87
82
|
xAxisJoinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
88
83
|
yAxisColumn: string;
|
|
89
84
|
yAxisJoinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
90
85
|
}
|
|
91
|
-
/** Options for {@link
|
|
86
|
+
/** Options for {@link WidgetBaseSource#getTable}. */
|
|
92
87
|
export interface TableRequestOptions extends BaseRequestOptions {
|
|
93
88
|
columns: string[];
|
|
94
89
|
sortBy?: string;
|
|
@@ -96,15 +91,11 @@ export interface TableRequestOptions extends BaseRequestOptions {
|
|
|
96
91
|
sortByColumnType?: SortColumnType;
|
|
97
92
|
offset?: number;
|
|
98
93
|
limit?: number;
|
|
99
|
-
/** Local only. */
|
|
100
|
-
searchFilterColumn?: string;
|
|
101
|
-
/** Local only. */
|
|
102
|
-
searchFilterText?: string;
|
|
103
94
|
}
|
|
104
|
-
/** Options for {@link
|
|
95
|
+
/** Options for {@link WidgetBaseSource#getTimeSeries}. */
|
|
105
96
|
export interface TimeSeriesRequestOptions extends BaseRequestOptions {
|
|
106
97
|
column: string;
|
|
107
|
-
stepSize
|
|
98
|
+
stepSize?: GroupDateType;
|
|
108
99
|
stepMultiplier?: number;
|
|
109
100
|
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
|
|
110
101
|
operationColumn?: string;
|
|
@@ -117,42 +108,42 @@ export interface TimeSeriesRequestOptions extends BaseRequestOptions {
|
|
|
117
108
|
* WIDGET API RESPONSES
|
|
118
109
|
*/
|
|
119
110
|
/**
|
|
120
|
-
* Response from {@link
|
|
111
|
+
* Response from {@link WidgetBaseSource#getFeatures}.
|
|
121
112
|
* @experimental
|
|
122
113
|
* @internal
|
|
123
114
|
*/
|
|
124
115
|
export type FeaturesResponse = {
|
|
125
116
|
rows: Record<string, unknown>[];
|
|
126
117
|
};
|
|
127
|
-
/** Response from {@link
|
|
118
|
+
/** Response from {@link WidgetBaseSource#getFormula}. */
|
|
128
119
|
export type FormulaResponse = {
|
|
129
|
-
value: number
|
|
120
|
+
value: number;
|
|
130
121
|
};
|
|
131
|
-
/** Response from {@link
|
|
122
|
+
/** Response from {@link WidgetBaseSource#getCategories}. */
|
|
132
123
|
export type CategoryResponse = {
|
|
133
124
|
name: string;
|
|
134
125
|
value: number;
|
|
135
126
|
}[];
|
|
136
|
-
/** Response from {@link
|
|
127
|
+
/** Response from {@link WidgetBaseSource#getRange}. */
|
|
137
128
|
export type RangeResponse = {
|
|
138
129
|
min: number;
|
|
139
130
|
max: number;
|
|
140
|
-
}
|
|
141
|
-
/** Response from {@link
|
|
131
|
+
};
|
|
132
|
+
/** Response from {@link WidgetBaseSource#getTable}. */
|
|
142
133
|
export type TableResponse = {
|
|
143
134
|
totalCount: number;
|
|
144
135
|
rows: Record<string, number | string>[];
|
|
145
136
|
};
|
|
146
|
-
/** Response from {@link
|
|
137
|
+
/** Response from {@link WidgetBaseSource#getScatter}. */
|
|
147
138
|
export type ScatterResponse = [number, number][];
|
|
148
|
-
/** Response from {@link
|
|
139
|
+
/** Response from {@link WidgetBaseSource#getTimeSeries}. */
|
|
149
140
|
export type TimeSeriesResponse = {
|
|
150
141
|
rows: {
|
|
151
142
|
name: string;
|
|
152
143
|
value: number;
|
|
153
144
|
}[];
|
|
154
|
-
categories
|
|
145
|
+
categories: string[];
|
|
155
146
|
};
|
|
156
|
-
/** Response from {@link
|
|
147
|
+
/** Response from {@link WidgetBaseSource#getHistogram}. */
|
|
157
148
|
export type HistogramResponse = number[];
|
|
158
149
|
export {};
|
|
@@ -3,34 +3,41 @@ import { FilterLogicalOperator, Filter, SpatialFilter } 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 WidgetBaseSourceProps 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>;
|
|
11
12
|
/**
|
|
12
13
|
* Source for Widget API requests on a data source defined by a SQL query.
|
|
13
14
|
*
|
|
14
15
|
* Abstract class. Use {@link WidgetQuerySource} or {@link WidgetTableSource}.
|
|
15
16
|
*/
|
|
16
|
-
export declare abstract class
|
|
17
|
+
export declare abstract class WidgetBaseSource<Props extends WidgetBaseSourceProps> {
|
|
17
18
|
readonly props: Props;
|
|
18
|
-
static defaultProps: Partial<
|
|
19
|
+
static defaultProps: Partial<WidgetBaseSourceProps>;
|
|
19
20
|
constructor(props: Props);
|
|
20
21
|
/**
|
|
21
|
-
* Subclasses of {@link
|
|
22
|
-
* {@link
|
|
22
|
+
* Subclasses of {@link WidgetBaseSource} must implement this method, calling
|
|
23
|
+
* {@link WidgetBaseSource.prototype._getModelSource} for common source
|
|
23
24
|
* properties, and adding additional required properties including 'type' and
|
|
24
25
|
* 'data'.
|
|
25
26
|
*/
|
|
26
27
|
protected abstract getModelSource(owner: string | undefined): ModelSource;
|
|
27
28
|
protected _getModelSource(owner?: string): Omit<ModelSource, 'type' | 'data'>;
|
|
28
29
|
protected _getSpatialFiltersResolution(source: Omit<ModelSource, 'type' | 'data'>, spatialFilter?: SpatialFilter, referenceViewState?: ViewState): number | undefined;
|
|
30
|
+
/****************************************************************************
|
|
31
|
+
* CATEGORIES
|
|
32
|
+
*/
|
|
29
33
|
/**
|
|
30
34
|
* Returns a list of labeled datapoints for categorical data. Suitable for
|
|
31
35
|
* charts including grouped bar charts, pie charts, and tree charts.
|
|
32
36
|
*/
|
|
33
|
-
|
|
37
|
+
getCategories(options: CategoryRequestOptions): Promise<CategoryResponse>;
|
|
38
|
+
/****************************************************************************
|
|
39
|
+
* FEATURES
|
|
40
|
+
*/
|
|
34
41
|
/**
|
|
35
42
|
* Given a list of feature IDs (as found in `_carto_feature_id`) returns all
|
|
36
43
|
* matching features. In datasets containing features with duplicate geometries,
|
|
@@ -39,36 +46,54 @@ export declare abstract class WidgetSource<Props extends WidgetSourceProps> {
|
|
|
39
46
|
* @internal
|
|
40
47
|
* @experimental
|
|
41
48
|
*/
|
|
42
|
-
|
|
49
|
+
getFeatures(options: FeaturesRequestOptions): Promise<FeaturesResponse>;
|
|
50
|
+
/****************************************************************************
|
|
51
|
+
* FORMULA
|
|
52
|
+
*/
|
|
43
53
|
/**
|
|
44
54
|
* Returns a scalar numerical statistic over all matching data. Suitable
|
|
45
55
|
* for 'headline' or 'scorecard' figures such as counts and sums.
|
|
46
56
|
*/
|
|
47
|
-
|
|
57
|
+
getFormula(options: FormulaRequestOptions): Promise<FormulaResponse>;
|
|
58
|
+
/****************************************************************************
|
|
59
|
+
* HISTOGRAM
|
|
60
|
+
*/
|
|
48
61
|
/**
|
|
49
62
|
* Returns a list of labeled datapoints for 'bins' of data defined as ticks
|
|
50
63
|
* over a numerical range. Suitable for histogram charts.
|
|
51
64
|
*/
|
|
52
|
-
|
|
65
|
+
getHistogram(options: HistogramRequestOptions): Promise<HistogramResponse>;
|
|
66
|
+
/****************************************************************************
|
|
67
|
+
* RANGE
|
|
68
|
+
*/
|
|
53
69
|
/**
|
|
54
70
|
* Returns a range (min and max) for a numerical column of matching rows.
|
|
55
71
|
* Suitable for displaying certain 'headline' or 'scorecard' statistics,
|
|
56
72
|
* or rendering a range slider UI for filtering.
|
|
57
73
|
*/
|
|
58
|
-
|
|
74
|
+
getRange(options: RangeRequestOptions): Promise<RangeResponse>;
|
|
75
|
+
/****************************************************************************
|
|
76
|
+
* SCATTER
|
|
77
|
+
*/
|
|
59
78
|
/**
|
|
60
79
|
* Returns a list of bivariate datapoints defined as numerical 'x' and 'y'
|
|
61
80
|
* values. Suitable for rendering scatter plots.
|
|
62
81
|
*/
|
|
63
|
-
|
|
82
|
+
getScatter(options: ScatterRequestOptions): Promise<ScatterResponse>;
|
|
83
|
+
/****************************************************************************
|
|
84
|
+
* TABLE
|
|
85
|
+
*/
|
|
64
86
|
/**
|
|
65
87
|
* Returns a list of arbitrary data rows, with support for pagination and
|
|
66
88
|
* sorting. Suitable for displaying tables and lists.
|
|
67
89
|
*/
|
|
68
|
-
|
|
90
|
+
getTable(options: TableRequestOptions): Promise<TableResponse>;
|
|
91
|
+
/****************************************************************************
|
|
92
|
+
* TIME SERIES
|
|
93
|
+
*/
|
|
69
94
|
/**
|
|
70
95
|
* Returns a series of labeled numerical values, grouped into equally-sized
|
|
71
96
|
* time intervals. Suitable for rendering time series charts.
|
|
72
97
|
*/
|
|
73
|
-
|
|
98
|
+
getTimeSeries(options: TimeSeriesRequestOptions): Promise<TimeSeriesResponse>;
|
|
74
99
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { H3QuerySourceOptions, QuadbinQuerySourceOptions, VectorQuerySourceOptions } from '../sources/index.js';
|
|
2
|
-
import {
|
|
2
|
+
import { WidgetBaseSource, WidgetBaseSourceProps } from './widget-base-source.js';
|
|
3
3
|
import { ModelSource } from '../models/model.js';
|
|
4
4
|
type LayerQuerySourceOptions = Omit<VectorQuerySourceOptions, 'filters'> | Omit<H3QuerySourceOptions, 'filters'> | Omit<QuadbinQuerySourceOptions, 'filters'>;
|
|
5
5
|
export type WidgetQuerySourceResult = {
|
|
@@ -27,7 +27,7 @@ export type WidgetQuerySourceResult = {
|
|
|
27
27
|
* const { widgetSource } = await data;
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
|
-
export declare class WidgetQuerySource extends
|
|
30
|
+
export declare class WidgetQuerySource extends WidgetBaseSource<LayerQuerySourceOptions & WidgetBaseSourceProps> {
|
|
31
31
|
protected getModelSource(owner: string): ModelSource;
|
|
32
32
|
}
|
|
33
33
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { H3TableSourceOptions, QuadbinTableSourceOptions, VectorTableSourceOptions } from '../sources/index.js';
|
|
2
|
-
import {
|
|
2
|
+
import { WidgetBaseSource, WidgetBaseSourceProps } from './widget-base-source.js';
|
|
3
3
|
import { ModelSource } from '../models/model.js';
|
|
4
4
|
type LayerTableSourceOptions = Omit<VectorTableSourceOptions, 'filters'> | Omit<H3TableSourceOptions, 'filters'> | Omit<QuadbinTableSourceOptions, 'filters'>;
|
|
5
5
|
export type WidgetTableSourceResult = {
|
|
@@ -27,7 +27,7 @@ export type WidgetTableSourceResult = {
|
|
|
27
27
|
* const { widgetSource } = await data;
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
|
-
export declare class WidgetTableSource extends
|
|
30
|
+
export declare class WidgetTableSource extends WidgetBaseSource<LayerTableSourceOptions & WidgetBaseSourceProps> {
|
|
31
31
|
protected getModelSource(owner: string): ModelSource;
|
|
32
32
|
}
|
|
33
33
|
export {};
|
package/package.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carto/api-client",
|
|
3
3
|
"description": "Client library for CARTO APIs and framework-agnostic CARTO + deck.gl applications",
|
|
4
|
-
"repository":
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/CartoDB/carto-api-client.git"
|
|
7
|
+
},
|
|
8
|
+
"homepage": "https://github.com/CartoDB/carto-api-client#readme",
|
|
5
9
|
"author": "Don McCurdy <donmccurdy@carto.com>",
|
|
6
10
|
"packageManager": "yarn@4.3.1",
|
|
7
|
-
"version": "0.4.6
|
|
11
|
+
"version": "0.4.6",
|
|
8
12
|
"license": "MIT",
|
|
9
13
|
"publishConfig": {
|
|
10
14
|
"access": "public",
|
|
@@ -52,17 +56,12 @@
|
|
|
52
56
|
"LICENSE.md"
|
|
53
57
|
],
|
|
54
58
|
"dependencies": {
|
|
55
|
-
"@loaders.gl/schema": "^4.3.3",
|
|
56
59
|
"@turf/bbox-clip": "^7.1.0",
|
|
57
60
|
"@turf/bbox-polygon": "^7.1.0",
|
|
58
|
-
"@turf/boolean-intersects": "^7.1.0",
|
|
59
|
-
"@turf/boolean-within": "^7.1.0",
|
|
60
61
|
"@turf/helpers": "^7.1.0",
|
|
61
|
-
"@turf/intersect": "^7.1.0",
|
|
62
62
|
"@turf/invariant": "^7.1.0",
|
|
63
63
|
"@turf/union": "^7.1.0",
|
|
64
|
-
"@types/geojson": "^7946.0.15"
|
|
65
|
-
"h3-js": "4.1.0"
|
|
64
|
+
"@types/geojson": "^7946.0.15"
|
|
66
65
|
},
|
|
67
66
|
"devDependencies": {
|
|
68
67
|
"@deck.gl/aggregation-layers": "^9.0.38",
|
|
@@ -75,12 +74,12 @@
|
|
|
75
74
|
"@lit/react": "^1.0.6",
|
|
76
75
|
"@lit/task": "^1.0.1",
|
|
77
76
|
"@loaders.gl/core": "^4.3.3",
|
|
78
|
-
"@luma.gl/core": "9.0.
|
|
79
|
-
"@luma.gl/engine": "9.0.
|
|
77
|
+
"@luma.gl/core": "9.0.28",
|
|
78
|
+
"@luma.gl/engine": "9.0.28",
|
|
80
79
|
"@types/json-schema": "^7.0.15",
|
|
81
80
|
"@types/react": "^18.3.18",
|
|
82
81
|
"@types/semver": "^7.5.8",
|
|
83
|
-
"@vitest/coverage-istanbul": "^
|
|
82
|
+
"@vitest/coverage-istanbul": "^3.0.2",
|
|
84
83
|
"@webcomponents/webcomponentsjs": "^2.8.0",
|
|
85
84
|
"concurrently": "^9.1.2",
|
|
86
85
|
"echarts": "^5.6.0",
|
|
@@ -91,13 +90,11 @@
|
|
|
91
90
|
"prettier": "^3.4.2",
|
|
92
91
|
"rimraf": "^6.0.1",
|
|
93
92
|
"semver": "^7.6.3",
|
|
94
|
-
"thenby": "^1.3.4",
|
|
95
93
|
"typescript": "~5.7.3",
|
|
96
94
|
"vite": "^6.0.7",
|
|
97
95
|
"vitest": "2.1.8"
|
|
98
96
|
},
|
|
99
97
|
"resolutions": {
|
|
100
98
|
"rollup": "^4.20.0"
|
|
101
|
-
}
|
|
102
|
-
"stableVersion": "0.4.5"
|
|
99
|
+
}
|
|
103
100
|
}
|
package/src/constants.ts
CHANGED
|
@@ -31,28 +31,3 @@ export enum ApiVersion {
|
|
|
31
31
|
|
|
32
32
|
/** @internalRemarks Source: @carto/constants, @deck.gl/carto */
|
|
33
33
|
export const DEFAULT_API_BASE_URL = 'https://gcp-us-east1.api.carto.com';
|
|
34
|
-
|
|
35
|
-
/** @internalRemarks Source: @carto/react-core */
|
|
36
|
-
export enum TileFormat {
|
|
37
|
-
MVT = 'mvt',
|
|
38
|
-
JSON = 'json',
|
|
39
|
-
GEOJSON = 'geojson',
|
|
40
|
-
BINARY = 'binary',
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/** @internalRemarks Source: @carto/react-core */
|
|
44
|
-
export enum SpatialIndex {
|
|
45
|
-
H3 = 'h3',
|
|
46
|
-
S2 = 's2',
|
|
47
|
-
QUADBIN = 'quadbin',
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/** @internalRemarks Source: @carto/react-core */
|
|
51
|
-
export enum Provider {
|
|
52
|
-
BIGQUERY = 'bigquery',
|
|
53
|
-
REDSHIFT = 'redshift',
|
|
54
|
-
POSTGRES = 'postgres',
|
|
55
|
-
SNOWFLAKE = 'snowflake',
|
|
56
|
-
DATABRICKS = 'databricks',
|
|
57
|
-
DATABRICKS_REST = 'databricksRest',
|
|
58
|
-
}
|
package/src/index.ts
CHANGED
|
@@ -17,8 +17,4 @@ export {
|
|
|
17
17
|
requestWithParameters,
|
|
18
18
|
} from './api/index.js';
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
export * from './filters/index.js';
|
|
22
|
-
export * from './operations/index.js';
|
|
23
|
-
export * from './utils/makeIntervalComplete.js';
|
|
24
|
-
export * from './utils/transformToTileCoords.js';
|
|
20
|
+
export {_getHexagonResolution} from './spatial-index.js';
|
package/src/models/index.ts
CHANGED
|
@@ -2,11 +2,6 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {getTileFormat} from '../utils/getTileFormat';
|
|
6
|
-
import {
|
|
7
|
-
WidgetTilesetSource,
|
|
8
|
-
WidgetTilesetSourceResult,
|
|
9
|
-
} from '../widget-sources';
|
|
10
5
|
import {baseSource} from './base-source';
|
|
11
6
|
import type {
|
|
12
7
|
SourceOptions,
|
|
@@ -17,24 +12,17 @@ import type {
|
|
|
17
12
|
export type H3TilesetSourceOptions = SourceOptions & TilesetSourceOptions;
|
|
18
13
|
type UrlParameters = {name: string};
|
|
19
14
|
|
|
20
|
-
export type H3TilesetSourceResponse = TilejsonResult
|
|
21
|
-
WidgetTilesetSourceResult;
|
|
15
|
+
export type H3TilesetSourceResponse = TilejsonResult;
|
|
22
16
|
|
|
23
17
|
export const h3TilesetSource = async function (
|
|
24
18
|
options: H3TilesetSourceOptions
|
|
25
19
|
): Promise<H3TilesetSourceResponse> {
|
|
26
|
-
const {tableName
|
|
20
|
+
const {tableName} = options;
|
|
27
21
|
const urlParameters: UrlParameters = {name: tableName};
|
|
28
22
|
|
|
29
|
-
return baseSource<UrlParameters>(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
...options,
|
|
34
|
-
tileFormat: getTileFormat(result as TilejsonResult),
|
|
35
|
-
spatialDataColumn,
|
|
36
|
-
spatialDataType: 'h3',
|
|
37
|
-
}),
|
|
38
|
-
})
|
|
23
|
+
return baseSource<UrlParameters>(
|
|
24
|
+
'tileset',
|
|
25
|
+
options,
|
|
26
|
+
urlParameters
|
|
39
27
|
) as Promise<H3TilesetSourceResponse>;
|
|
40
28
|
};
|
package/src/sources/index.ts
CHANGED
|
@@ -52,7 +52,7 @@ export type {
|
|
|
52
52
|
} from './h3-tileset-source';
|
|
53
53
|
|
|
54
54
|
export {rasterSource} from './raster-source';
|
|
55
|
-
export type {RasterSourceOptions} from './raster-source';
|
|
55
|
+
export type {RasterSourceOptions, RasterSourceResponse} from './raster-source';
|
|
56
56
|
|
|
57
57
|
export {quadbinQuerySource} from './quadbin-query-source';
|
|
58
58
|
export type {
|