@carto/api-client 0.5.1-alpha.1 → 0.5.1
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 +7 -2
- package/build/api-client.cjs +33 -31
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.d.cts +40 -15
- package/build/api-client.d.ts +40 -15
- package/build/api-client.js +29 -31
- package/build/api-client.js.map +1 -1
- package/build/worker.js +14 -2
- package/build/worker.js.map +1 -1
- package/package.json +3 -4
- package/src/fetch-map/fetch-map.ts +1 -7
- package/src/fetch-map/parse-map.ts +2 -1
- package/src/fetch-map/source.ts +12 -3
- package/src/fetch-map/types.ts +3 -2
- package/src/filters/tileFeatures.ts +2 -0
- package/src/index.ts +1 -0
- package/src/sources/base-source.ts +8 -22
- package/src/sources/boundary-query-source.ts +1 -5
- package/src/sources/boundary-table-source.ts +1 -5
- package/src/sources/h3-query-source.ts +1 -1
- package/src/sources/h3-table-source.ts +1 -1
- package/src/sources/h3-tileset-source.ts +2 -2
- package/src/sources/index.ts +18 -10
- package/src/sources/quadbin-query-source.ts +1 -1
- package/src/sources/quadbin-table-source.ts +1 -1
- package/src/sources/quadbin-tileset-source.ts +2 -2
- package/src/sources/raster-source.ts +3 -3
- package/src/sources/types.ts +6 -8
- package/src/sources/vector-query-source.ts +1 -1
- package/src/sources/vector-table-source.ts +1 -1
- package/src/sources/vector-tileset-source.ts +2 -2
- package/src/types-internal.ts +0 -24
- package/src/utils.ts +27 -0
- package/src/widget-sources/types.ts +2 -2
- package/src/widget-sources/widget-tileset-source-impl.ts +11 -3
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"homepage": "https://github.com/CartoDB/carto-api-client#readme",
|
|
9
9
|
"author": "Don McCurdy <donmccurdy@carto.com>",
|
|
10
10
|
"packageManager": "yarn@4.3.1",
|
|
11
|
-
"version": "0.5.1
|
|
11
|
+
"version": "0.5.1",
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"publishConfig": {
|
|
14
14
|
"access": "public"
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build": "tsup",
|
|
41
41
|
"build:watch": "tsup --watch",
|
|
42
|
-
"dev": "concurrently \"yarn build:watch\" \"vite --config examples/vite.config.ts --open\"",
|
|
42
|
+
"dev": "yarn build && concurrently --names tsup,vite \"yarn build:watch\" \"vite --config examples/vite.config.ts --open\"",
|
|
43
43
|
"test": "vitest run --typecheck",
|
|
44
44
|
"test:watch": "vitest watch --typecheck",
|
|
45
45
|
"coverage": "vitest run --coverage.enabled --coverage.all false",
|
|
@@ -127,6 +127,5 @@
|
|
|
127
127
|
"resolutions": {
|
|
128
128
|
"@carto/api-client": "portal:./",
|
|
129
129
|
"rollup": "^4.20.0"
|
|
130
|
-
}
|
|
131
|
-
"stableVersion": "0.5.0"
|
|
130
|
+
}
|
|
132
131
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import {TilejsonResult} from '../sources/index.js';
|
|
2
|
-
|
|
3
1
|
import {DEFAULT_API_BASE_URL} from '../constants.js';
|
|
4
2
|
|
|
5
3
|
import {
|
|
@@ -119,11 +117,7 @@ async function fillInTileStats(
|
|
|
119
117
|
const attribute = layer.visualChannels[channel]?.name;
|
|
120
118
|
if (attribute) {
|
|
121
119
|
const dataset = datasets.find((d) => d.id === layer.config.dataId);
|
|
122
|
-
if (
|
|
123
|
-
dataset &&
|
|
124
|
-
dataset.type !== 'tileset' &&
|
|
125
|
-
(dataset.data as TilejsonResult).tilestats
|
|
126
|
-
) {
|
|
120
|
+
if (dataset && dataset.type !== 'tileset' && dataset.data.tilestats) {
|
|
127
121
|
// Only fetch stats for QUERY & TABLE map types
|
|
128
122
|
attributes.push({attribute, dataset});
|
|
129
123
|
}
|
|
@@ -57,7 +57,7 @@ export function parseMap(json: any) {
|
|
|
57
57
|
const {keplerMapConfig, datasets, token} = json;
|
|
58
58
|
assert(keplerMapConfig.version === 'v1', 'Only support Kepler v1');
|
|
59
59
|
const config = keplerMapConfig.config as KeplerMapConfig;
|
|
60
|
-
const {filters, mapState, mapStyle, popupSettings} = config;
|
|
60
|
+
const {filters, mapState, mapStyle, popupSettings, legendSettings} = config;
|
|
61
61
|
const {layers, layerBlending, interactionConfig} = config.visState;
|
|
62
62
|
|
|
63
63
|
return {
|
|
@@ -70,6 +70,7 @@ export function parseMap(json: any) {
|
|
|
70
70
|
/** @deprecated Use `basemap`. */
|
|
71
71
|
mapStyle,
|
|
72
72
|
popupSettings,
|
|
73
|
+
legendSettings,
|
|
73
74
|
token,
|
|
74
75
|
layers: layers
|
|
75
76
|
.reverse()
|
package/src/fetch-map/source.ts
CHANGED
|
@@ -201,11 +201,12 @@ function getDynamicTileResolution(
|
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
/**
|
|
204
|
+
* @internal
|
|
204
205
|
* State of `aggregationResLevel` in the UI and backend config is based on an assumption of
|
|
205
206
|
* 512x512px tiles. Because we may change tile resolution for performance goals, the
|
|
206
207
|
* `aggregationResLevel` passed to the deck.gl layer must be scaled with tile resolution.
|
|
207
208
|
*/
|
|
208
|
-
function scaleAggregationResLevel(
|
|
209
|
+
export function scaleAggregationResLevel(
|
|
209
210
|
aggregationResLevel: number,
|
|
210
211
|
tileResolution: number
|
|
211
212
|
): number | undefined {
|
|
@@ -213,7 +214,12 @@ function scaleAggregationResLevel(
|
|
|
213
214
|
return aggregationResLevel - Math.log2(0.5 / tileResolution);
|
|
214
215
|
}
|
|
215
216
|
|
|
216
|
-
|
|
217
|
+
/**
|
|
218
|
+
* @internal
|
|
219
|
+
*/
|
|
220
|
+
export function getColumnNameFromGeoColumn(
|
|
221
|
+
geoColumn: string | null | undefined
|
|
222
|
+
) {
|
|
217
223
|
if (!geoColumn) {
|
|
218
224
|
return geoColumn;
|
|
219
225
|
}
|
|
@@ -221,7 +227,10 @@ function getColumnNameFromGeoColumn(geoColumn: string | null | undefined) {
|
|
|
221
227
|
return parts.length === 1 ? parts[0] : parts.length === 2 ? parts[1] : null;
|
|
222
228
|
}
|
|
223
229
|
|
|
224
|
-
|
|
230
|
+
/**
|
|
231
|
+
* @internal
|
|
232
|
+
*/
|
|
233
|
+
export function getSpatialIndexFromGeoColumn(geoColumn: string) {
|
|
225
234
|
const spatialIndexToSearch = geoColumn.split(':')[0];
|
|
226
235
|
|
|
227
236
|
for (const index of Object.values(SpatialIndex)) {
|
package/src/fetch-map/types.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {LayerType, SCALE_TYPE} from './layer-map.js';
|
|
2
2
|
import {Format, MapType, ProviderType, QueryParameters} from '../types.js';
|
|
3
|
-
import {TilejsonResult
|
|
3
|
+
import {TilejsonResult} from '../sources/types.js';
|
|
4
4
|
|
|
5
5
|
export type VisualChannelField = {
|
|
6
6
|
name: string;
|
|
@@ -117,6 +117,7 @@ export type KeplerMapConfig = {
|
|
|
117
117
|
styleType: string;
|
|
118
118
|
visibleLayerGroups: Record<string, boolean>;
|
|
119
119
|
};
|
|
120
|
+
legendSettings?: any;
|
|
120
121
|
popupSettings: any;
|
|
121
122
|
visState: {
|
|
122
123
|
layers: MapConfigLayer[];
|
|
@@ -208,7 +209,7 @@ export type Dataset = {
|
|
|
208
209
|
cache?: number;
|
|
209
210
|
connectionName: string;
|
|
210
211
|
geoColumn: string;
|
|
211
|
-
data: TilejsonResult
|
|
212
|
+
data: TilejsonResult;
|
|
212
213
|
columns: string[];
|
|
213
214
|
format: Format;
|
|
214
215
|
aggregationExp: string;
|
|
@@ -23,6 +23,8 @@ export type TileFeatures = {
|
|
|
23
23
|
/** @privateRemarks Source: @carto/react-core */
|
|
24
24
|
export type TileFeatureExtractOptions = {
|
|
25
25
|
storeGeometry?: boolean;
|
|
26
|
+
spatialDataType?: SpatialDataType;
|
|
27
|
+
spatialDataColumn?: string;
|
|
26
28
|
uniqueIdProperty?: string;
|
|
27
29
|
};
|
|
28
30
|
|
package/src/index.ts
CHANGED
|
@@ -7,8 +7,6 @@ import {DEFAULT_MAX_LENGTH_URL} from '../constants-internal.js';
|
|
|
7
7
|
import {buildSourceUrl} from '../api/endpoints.js';
|
|
8
8
|
import {requestWithParameters} from '../api/request-with-parameters.js';
|
|
9
9
|
import type {
|
|
10
|
-
GeojsonResult,
|
|
11
|
-
JsonResult,
|
|
12
10
|
SourceOptionalOptions,
|
|
13
11
|
SourceRequiredOptions,
|
|
14
12
|
TilejsonMapInstantiation,
|
|
@@ -20,7 +18,6 @@ import {getClient} from '../client.js';
|
|
|
20
18
|
|
|
21
19
|
export const SOURCE_DEFAULTS: Omit<SourceOptionalOptions, 'clientId'> = {
|
|
22
20
|
apiBaseUrl: DEFAULT_API_BASE_URL,
|
|
23
|
-
format: 'tilejson',
|
|
24
21
|
headers: {},
|
|
25
22
|
maxLengthURL: DEFAULT_MAX_LENGTH_URL,
|
|
26
23
|
};
|
|
@@ -29,7 +26,7 @@ export async function baseSource<UrlParameters extends Record<string, unknown>>(
|
|
|
29
26
|
endpoint: MapType,
|
|
30
27
|
options: Partial<SourceOptionalOptions> & SourceRequiredOptions,
|
|
31
28
|
urlParameters: UrlParameters
|
|
32
|
-
): Promise<TilejsonResult
|
|
29
|
+
): Promise<TilejsonResult> {
|
|
33
30
|
const {accessToken, connectionName, cache, ...optionalOptions} = options;
|
|
34
31
|
const mergedOptions = {
|
|
35
32
|
...SOURCE_DEFAULTS,
|
|
@@ -45,7 +42,7 @@ export async function baseSource<UrlParameters extends Record<string, unknown>>(
|
|
|
45
42
|
}
|
|
46
43
|
}
|
|
47
44
|
const baseUrl = buildSourceUrl(mergedOptions);
|
|
48
|
-
const {clientId, maxLengthURL,
|
|
45
|
+
const {clientId, maxLengthURL, localCache} = mergedOptions;
|
|
49
46
|
const headers = {
|
|
50
47
|
Authorization: `Bearer ${options.accessToken}`,
|
|
51
48
|
...options.headers,
|
|
@@ -68,7 +65,7 @@ export async function baseSource<UrlParameters extends Record<string, unknown>>(
|
|
|
68
65
|
localCache,
|
|
69
66
|
});
|
|
70
67
|
|
|
71
|
-
const dataUrl = mapInstantiation
|
|
68
|
+
const dataUrl = mapInstantiation.tilejson.url[0];
|
|
72
69
|
if (cache) {
|
|
73
70
|
cache.value = parseInt(
|
|
74
71
|
new URL(dataUrl).searchParams.get('cache') || '',
|
|
@@ -77,22 +74,7 @@ export async function baseSource<UrlParameters extends Record<string, unknown>>(
|
|
|
77
74
|
}
|
|
78
75
|
errorContext.requestType = 'Map data';
|
|
79
76
|
|
|
80
|
-
|
|
81
|
-
const json = await requestWithParameters<TilejsonResult>({
|
|
82
|
-
baseUrl: dataUrl,
|
|
83
|
-
parameters: {client: clientId},
|
|
84
|
-
headers,
|
|
85
|
-
errorContext,
|
|
86
|
-
maxLengthURL,
|
|
87
|
-
localCache,
|
|
88
|
-
});
|
|
89
|
-
if (accessToken) {
|
|
90
|
-
json.accessToken = accessToken;
|
|
91
|
-
}
|
|
92
|
-
return json;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return await requestWithParameters<GeojsonResult | JsonResult>({
|
|
77
|
+
const json = await requestWithParameters<TilejsonResult>({
|
|
96
78
|
baseUrl: dataUrl,
|
|
97
79
|
parameters: {client: clientId},
|
|
98
80
|
headers,
|
|
@@ -100,4 +82,8 @@ export async function baseSource<UrlParameters extends Record<string, unknown>>(
|
|
|
100
82
|
maxLengthURL,
|
|
101
83
|
localCache,
|
|
102
84
|
});
|
|
85
|
+
if (accessToken) {
|
|
86
|
+
json.accessToken = accessToken;
|
|
87
|
+
}
|
|
88
|
+
return json;
|
|
103
89
|
}
|
|
@@ -48,9 +48,5 @@ export const boundaryQuerySource = async function (
|
|
|
48
48
|
urlParameters.queryParameters = queryParameters;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
return baseSource<UrlParameters>(
|
|
52
|
-
'boundary',
|
|
53
|
-
options,
|
|
54
|
-
urlParameters
|
|
55
|
-
) as Promise<BoundaryQuerySourceResponse>;
|
|
51
|
+
return baseSource<UrlParameters>('boundary', options, urlParameters);
|
|
56
52
|
};
|
|
@@ -36,9 +36,5 @@ export const boundaryTableSource = async function (
|
|
|
36
36
|
urlParameters.filters = filters;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
return baseSource<UrlParameters>(
|
|
40
|
-
'boundary',
|
|
41
|
-
options,
|
|
42
|
-
urlParameters
|
|
43
|
-
) as Promise<BoundaryTableSourceResponse>;
|
|
39
|
+
return baseSource<UrlParameters>('boundary', options, urlParameters);
|
|
44
40
|
};
|
|
@@ -67,7 +67,7 @@ export const h3QuerySource = async function (
|
|
|
67
67
|
|
|
68
68
|
return baseSource<UrlParameters>('query', options, urlParameters).then(
|
|
69
69
|
(result) => ({
|
|
70
|
-
...
|
|
70
|
+
...result,
|
|
71
71
|
widgetSource: new WidgetQuerySource({
|
|
72
72
|
...options,
|
|
73
73
|
// NOTE: Parameters with default values above must be explicitly passed here.
|
|
@@ -62,7 +62,7 @@ export const h3TableSource = async function (
|
|
|
62
62
|
|
|
63
63
|
return baseSource<UrlParameters>('table', options, urlParameters).then(
|
|
64
64
|
(result) => ({
|
|
65
|
-
...
|
|
65
|
+
...result,
|
|
66
66
|
widgetSource: new WidgetTableSource({
|
|
67
67
|
...options,
|
|
68
68
|
// NOTE: Parameters with default values above must be explicitly passed here.
|
|
@@ -28,10 +28,10 @@ export const h3TilesetSource = async function (
|
|
|
28
28
|
|
|
29
29
|
return baseSource<UrlParameters>('tileset', options, urlParameters).then(
|
|
30
30
|
(result) => ({
|
|
31
|
-
...
|
|
31
|
+
...result,
|
|
32
32
|
widgetSource: new WidgetTilesetSource({
|
|
33
33
|
...options,
|
|
34
|
-
tileFormat: getTileFormat(result
|
|
34
|
+
tileFormat: getTileFormat(result),
|
|
35
35
|
spatialDataColumn,
|
|
36
36
|
spatialDataType: 'h3',
|
|
37
37
|
}),
|
package/src/sources/index.ts
CHANGED
|
@@ -4,21 +4,29 @@
|
|
|
4
4
|
|
|
5
5
|
export {SOURCE_DEFAULTS} from './base-source.js';
|
|
6
6
|
export type {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
SourceOptions,
|
|
8
|
+
SourceRequiredOptions,
|
|
9
|
+
SourceOptionalOptions,
|
|
10
|
+
TilejsonResult,
|
|
9
11
|
QueryResult,
|
|
12
|
+
FilterOptions,
|
|
10
13
|
QuerySourceOptions,
|
|
11
|
-
RasterBandColorinterp,
|
|
12
|
-
RasterMetadata,
|
|
13
|
-
RasterMetadataBand,
|
|
14
|
-
RasterMetadataBandStats,
|
|
15
|
-
SourceOptions,
|
|
16
|
-
SpatialFilterPolyfillMode,
|
|
17
14
|
TableSourceOptions,
|
|
18
|
-
TilejsonResult,
|
|
19
|
-
TileResolution,
|
|
20
15
|
TilesetSourceOptions,
|
|
16
|
+
ColumnsOption,
|
|
17
|
+
SpatialDataType,
|
|
18
|
+
SpatialFilterPolyfillMode,
|
|
19
|
+
TileResolution,
|
|
20
|
+
Tilejson,
|
|
21
|
+
Tilestats,
|
|
22
|
+
Layer,
|
|
23
|
+
Attribute,
|
|
21
24
|
VectorLayer,
|
|
25
|
+
RasterMetadata,
|
|
26
|
+
RasterMetadataBand,
|
|
27
|
+
RasterMetadataBandStats,
|
|
28
|
+
RasterBandType,
|
|
29
|
+
RasterBandColorinterp,
|
|
22
30
|
} from './types.js';
|
|
23
31
|
|
|
24
32
|
export {boundaryQuerySource} from './boundary-query-source.js';
|
|
@@ -68,7 +68,7 @@ export const quadbinQuerySource = async function (
|
|
|
68
68
|
|
|
69
69
|
return baseSource<UrlParameters>('query', options, urlParameters).then(
|
|
70
70
|
(result) => ({
|
|
71
|
-
...
|
|
71
|
+
...result,
|
|
72
72
|
widgetSource: new WidgetQuerySource({
|
|
73
73
|
...options,
|
|
74
74
|
// NOTE: Parameters with default values above must be explicitly passed here.
|
|
@@ -63,7 +63,7 @@ export const quadbinTableSource = async function (
|
|
|
63
63
|
|
|
64
64
|
return baseSource<UrlParameters>('table', options, urlParameters).then(
|
|
65
65
|
(result) => ({
|
|
66
|
-
...
|
|
66
|
+
...result,
|
|
67
67
|
widgetSource: new WidgetTableSource({
|
|
68
68
|
...options,
|
|
69
69
|
// NOTE: Parameters with default values above must be explicitly passed here.
|
|
@@ -28,10 +28,10 @@ export const quadbinTilesetSource = async function (
|
|
|
28
28
|
|
|
29
29
|
return baseSource<UrlParameters>('tileset', options, urlParameters).then(
|
|
30
30
|
(result) => ({
|
|
31
|
-
...
|
|
31
|
+
...result,
|
|
32
32
|
widgetSource: new WidgetTilesetSource({
|
|
33
33
|
...options,
|
|
34
|
-
tileFormat: getTileFormat(result
|
|
34
|
+
tileFormat: getTileFormat(result),
|
|
35
35
|
spatialDataColumn,
|
|
36
36
|
spatialDataType: 'quadbin',
|
|
37
37
|
}),
|
|
@@ -37,13 +37,13 @@ export const rasterSource = async function (
|
|
|
37
37
|
|
|
38
38
|
return baseSource<UrlParameters>('raster', options, urlParameters).then(
|
|
39
39
|
(result) => ({
|
|
40
|
-
...
|
|
40
|
+
...result,
|
|
41
41
|
widgetSource: new WidgetRasterSource({
|
|
42
42
|
...options,
|
|
43
|
-
tileFormat: getTileFormat(result
|
|
43
|
+
tileFormat: getTileFormat(result),
|
|
44
44
|
spatialDataColumn: 'quadbin',
|
|
45
45
|
spatialDataType: 'quadbin',
|
|
46
|
-
rasterMetadata:
|
|
46
|
+
rasterMetadata: result.raster_metadata!,
|
|
47
47
|
}),
|
|
48
48
|
})
|
|
49
49
|
) as Promise<RasterSourceResponse>;
|
package/src/sources/types.ts
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {MapInstantiation} from '../types-internal.js';
|
|
5
|
+
import {Filters, QueryParameters} from '../types.js';
|
|
6
|
+
import {SchemaField} from '../types-internal.js';
|
|
8
7
|
|
|
9
8
|
export type SourceRequiredOptions = {
|
|
10
9
|
/** Carto platform access token. */
|
|
@@ -38,8 +37,6 @@ export type SourceOptionalOptions = {
|
|
|
38
37
|
cache?: {value?: number};
|
|
39
38
|
|
|
40
39
|
clientId: string;
|
|
41
|
-
/** @deprecated use `query` instead **/
|
|
42
|
-
format: Format;
|
|
43
40
|
|
|
44
41
|
/**
|
|
45
42
|
* Maximum URL character length. Above this limit, requests use POST.
|
|
@@ -213,7 +210,10 @@ export type SpatialDataType = 'geo' | 'h3' | 'quadbin';
|
|
|
213
210
|
* */
|
|
214
211
|
export type SpatialFilterPolyfillMode = 'center' | 'intersects' | 'contains';
|
|
215
212
|
|
|
216
|
-
export type TilejsonMapInstantiation =
|
|
213
|
+
export type TilejsonMapInstantiation = {
|
|
214
|
+
nrows: number;
|
|
215
|
+
size?: number;
|
|
216
|
+
schema: SchemaField[];
|
|
217
217
|
tilejson: {url: string[]};
|
|
218
218
|
};
|
|
219
219
|
|
|
@@ -415,8 +415,6 @@ export type RasterMetadata = {
|
|
|
415
415
|
};
|
|
416
416
|
|
|
417
417
|
export type TilejsonResult = Tilejson & {accessToken: string};
|
|
418
|
-
export type GeojsonResult = {type: 'FeatureCollection'; features: Feature[]};
|
|
419
|
-
export type JsonResult = any[];
|
|
420
418
|
export type QueryResult = {
|
|
421
419
|
meta: {cacheHit: boolean; location: string; totalBytesProcessed: string};
|
|
422
420
|
rows: Record<string, any>[];
|
|
@@ -76,7 +76,7 @@ export const vectorQuerySource = async function (
|
|
|
76
76
|
|
|
77
77
|
return baseSource<UrlParameters>('query', options, urlParameters).then(
|
|
78
78
|
(result) => ({
|
|
79
|
-
...
|
|
79
|
+
...result,
|
|
80
80
|
widgetSource: new WidgetQuerySource({
|
|
81
81
|
...options,
|
|
82
82
|
// NOTE: Parameters with default values above must be explicitly passed here.
|
|
@@ -71,7 +71,7 @@ export const vectorTableSource = async function (
|
|
|
71
71
|
|
|
72
72
|
return baseSource<UrlParameters>('table', options, urlParameters).then(
|
|
73
73
|
(result) => ({
|
|
74
|
-
...
|
|
74
|
+
...result,
|
|
75
75
|
widgetSource: new WidgetTableSource({
|
|
76
76
|
...options,
|
|
77
77
|
// NOTE: Parameters with default values above must be explicitly passed here.
|
|
@@ -29,10 +29,10 @@ export const vectorTilesetSource = async function (
|
|
|
29
29
|
|
|
30
30
|
return baseSource<UrlParameters>('tileset', options, urlParameters).then(
|
|
31
31
|
(result) => ({
|
|
32
|
-
...
|
|
32
|
+
...result,
|
|
33
33
|
widgetSource: new WidgetTilesetSource({
|
|
34
34
|
...options,
|
|
35
|
-
tileFormat: getTileFormat(result
|
|
35
|
+
tileFormat: getTileFormat(result),
|
|
36
36
|
spatialDataColumn,
|
|
37
37
|
spatialDataType: 'geo',
|
|
38
38
|
}),
|
package/src/types-internal.ts
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
* COMMON
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import {Format} from './types.js';
|
|
6
|
-
|
|
7
5
|
/** @internal */
|
|
8
6
|
export type $TODO = any;
|
|
9
7
|
|
|
@@ -39,28 +37,6 @@ export interface SchemaField {
|
|
|
39
37
|
type: SchemaFieldType; // Field type in the CARTO stack, common for all providers
|
|
40
38
|
}
|
|
41
39
|
|
|
42
|
-
/**
|
|
43
|
-
* @privateRemarks Source: @deck.gl/carto
|
|
44
|
-
* @internal
|
|
45
|
-
*/
|
|
46
|
-
export interface MapInstantiation extends MapInstantiationFormats {
|
|
47
|
-
nrows: number;
|
|
48
|
-
size?: number;
|
|
49
|
-
schema: SchemaField[];
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* @privateRemarks Source: @deck.gl/carto
|
|
54
|
-
* @internal
|
|
55
|
-
*/
|
|
56
|
-
type MapInstantiationFormats = Record<
|
|
57
|
-
Format,
|
|
58
|
-
{
|
|
59
|
-
url: string[];
|
|
60
|
-
error?: any;
|
|
61
|
-
}
|
|
62
|
-
>;
|
|
63
|
-
|
|
64
40
|
/******************************************************************************
|
|
65
41
|
* LOCAL CALCULATIONS
|
|
66
42
|
*/
|
package/src/utils.ts
CHANGED
|
@@ -100,3 +100,30 @@ export const isObject: (x: unknown) => boolean = (x) =>
|
|
|
100
100
|
/** @internal */
|
|
101
101
|
export const isPureObject: (x: any) => boolean = (x) =>
|
|
102
102
|
isObject(x) && x.constructor === {}.constructor;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Merges one or more source objects into a target object. Unlike `Object.assign`, does not
|
|
106
|
+
* assign properties with undefined values. Null values will overwrite existing properties.
|
|
107
|
+
*/
|
|
108
|
+
export function assignOptional<T extends object, U, V>(
|
|
109
|
+
target: T,
|
|
110
|
+
source1: U,
|
|
111
|
+
source2: V
|
|
112
|
+
): T & U & V;
|
|
113
|
+
export function assignOptional<T extends object, U>(
|
|
114
|
+
target: T,
|
|
115
|
+
source: U
|
|
116
|
+
): T & U;
|
|
117
|
+
export function assignOptional<T extends object, U>(
|
|
118
|
+
target: T,
|
|
119
|
+
...sources: any[]
|
|
120
|
+
): any {
|
|
121
|
+
for (const source of sources) {
|
|
122
|
+
for (const key in source) {
|
|
123
|
+
if (source[key] !== undefined) {
|
|
124
|
+
(target as Record<string, unknown>)[key] = source[key];
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return target as T & U;
|
|
129
|
+
}
|
|
@@ -117,9 +117,9 @@ export interface TableRequestOptions extends BaseRequestOptions {
|
|
|
117
117
|
sortByColumnType?: SortColumnType;
|
|
118
118
|
offset?: number;
|
|
119
119
|
limit?: number;
|
|
120
|
-
/**
|
|
120
|
+
/** @deprecated Supported for tilesets only. Prefer `filters` (for all sources) instead. */
|
|
121
121
|
searchFilterColumn?: string;
|
|
122
|
-
/**
|
|
122
|
+
/** @deprecated Supported for tilesets only. Prefer `filters` (for all sources) instead. */
|
|
123
123
|
searchFilterText?: string;
|
|
124
124
|
}
|
|
125
125
|
|
|
@@ -16,7 +16,12 @@ import {
|
|
|
16
16
|
TimeSeriesRequestOptions,
|
|
17
17
|
TimeSeriesResponse,
|
|
18
18
|
} from './types.js';
|
|
19
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
InvalidColumnError,
|
|
21
|
+
assert,
|
|
22
|
+
assignOptional,
|
|
23
|
+
getApplicableFilters,
|
|
24
|
+
} from '../utils.js';
|
|
20
25
|
import {Filter, SpatialFilter, Tile} from '../types.js';
|
|
21
26
|
import {
|
|
22
27
|
TileFeatureExtractOptions,
|
|
@@ -84,8 +89,7 @@ export class WidgetTilesetSourceImpl extends WidgetSource<WidgetTilesetSourcePro
|
|
|
84
89
|
}
|
|
85
90
|
|
|
86
91
|
this._features = tileFeatures({
|
|
87
|
-
...this.props,
|
|
88
|
-
...this._tileFeatureExtractOptions,
|
|
92
|
+
...assignOptional({}, this.props, this._tileFeatureExtractOptions),
|
|
89
93
|
tiles: this._tiles,
|
|
90
94
|
spatialFilter,
|
|
91
95
|
});
|
|
@@ -267,7 +271,11 @@ export class WidgetTilesetSourceImpl extends WidgetSource<WidgetTilesetSourcePro
|
|
|
267
271
|
}
|
|
268
272
|
|
|
269
273
|
// Search.
|
|
274
|
+
// TODO(v0.6): Remove "searchFilterText" and "searchFilterColumn".
|
|
270
275
|
if (searchFilterColumn && searchFilterText) {
|
|
276
|
+
console.warn(
|
|
277
|
+
'WidgetTilesetSource: "searchFilterText" is deprecated, use "filters" and FilterType.STRING_SEARCH instead.'
|
|
278
|
+
);
|
|
271
279
|
filteredFeatures = filteredFeatures.filter(
|
|
272
280
|
(row) =>
|
|
273
281
|
row[searchFilterColumn] &&
|