@carto/api-client 0.5.0-alpha.3 → 0.5.0-alpha.5
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 +3332 -3100
- package/build/api-client.d.cts +1373 -0
- package/build/api-client.d.ts +1373 -0
- package/build/api-client.js +1712 -0
- package/build/chunk-V3E7BKVR.js +2063 -0
- package/build/worker.d.ts +2 -0
- package/build/worker.js +25 -0
- package/package.json +51 -45
- 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 -11
- package/src/constants.ts +6 -6
- package/src/deck/get-data-filter-extension-props.ts +146 -0
- package/src/deck/index.ts +1 -0
- package/src/filters/Filter.ts +18 -8
- package/src/filters/FilterTypes.ts +2 -2
- package/src/filters/geosjonFeatures.ts +2 -2
- package/src/filters/tileFeatures.ts +19 -41
- package/src/filters.ts +4 -4
- package/src/geo.ts +12 -14
- package/src/global.d.ts +3 -8
- package/src/index.ts +1 -0
- package/src/models/common.ts +9 -7
- package/src/models/model.ts +3 -4
- package/src/operations/aggregation.ts +5 -5
- package/src/operations/applySorting.ts +4 -4
- package/src/operations/groupBy.ts +4 -4
- package/src/operations/groupByDate.ts +1 -1
- package/src/operations/histogram.ts +4 -4
- package/src/operations/scatterPlot.ts +4 -4
- 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 +12 -5
- 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 +12 -5
- package/src/sources/raster-source.ts +7 -16
- package/src/sources/types.ts +10 -4
- package/src/sources/vector-query-source.ts +2 -3
- package/src/sources/vector-table-source.ts +2 -3
- package/src/sources/vector-tileset-source.ts +13 -6
- package/src/spatial-index.ts +4 -4
- package/src/types-internal.ts +5 -5
- package/src/types.ts +15 -21
- package/src/utils/makeIntervalComplete.ts +1 -1
- package/src/utils.ts +3 -3
- package/src/widget-sources/index.ts +1 -1
- package/src/widget-sources/types.ts +5 -3
- package/src/widget-sources/widget-query-source.ts +6 -2
- package/src/widget-sources/widget-remote-source.ts +66 -18
- package/src/widget-sources/widget-source.ts +0 -28
- package/src/widget-sources/widget-table-source.ts +6 -2
- package/src/widget-sources/widget-tileset-source.ts +130 -90
- package/src/widget-sources/widget-tileset-worker-source.ts +238 -0
- package/src/workers/constants.ts +13 -0
- package/src/workers/types.ts +20 -0
- package/src/workers/utils.ts +33 -0
- package/src/workers/widget-tileset-worker.ts +36 -0
- package/build/api/carto-api-error.d.ts +0 -26
- package/build/api/endpoints.d.ts +0 -24
- package/build/api/index.d.ts +0 -5
- package/build/api/query.d.ts +0 -3
- package/build/api/request-with-parameters.d.ts +0 -10
- package/build/api-client.cjs.map +0 -1
- package/build/api-client.modern.js +0 -3304
- package/build/api-client.modern.js.map +0 -1
- package/build/client.d.ts +0 -14
- package/build/constants-internal.d.ts +0 -26
- package/build/constants.d.ts +0 -53
- 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 -21
- package/build/filters/tileFeaturesGeometries.d.ts +0 -13
- package/build/filters/tileFeaturesRaster.d.ts +0 -16
- package/build/filters/tileFeaturesSpatialIndex.d.ts +0 -10
- package/build/filters.d.ts +0 -39
- package/build/geo.d.ts +0 -19
- package/build/index.d.ts +0 -15
- package/build/models/common.d.ts +0 -27
- package/build/models/index.d.ts +0 -3
- package/build/models/model.d.ts +0 -37
- 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/sources/base-source.d.ts +0 -4
- package/build/sources/boundary-query-source.d.ts +0 -10
- package/build/sources/boundary-table-source.d.ts +0 -8
- package/build/sources/h3-query-source.d.ts +0 -5
- package/build/sources/h3-table-source.d.ts +0 -5
- package/build/sources/h3-tileset-source.d.ts +0 -5
- package/build/sources/index.d.ts +0 -26
- package/build/sources/quadbin-query-source.d.ts +0 -5
- package/build/sources/quadbin-table-source.d.ts +0 -5
- package/build/sources/quadbin-tileset-source.d.ts +0 -5
- package/build/sources/raster-source.d.ts +0 -5
- package/build/sources/types.d.ts +0 -366
- package/build/sources/vector-query-source.d.ts +0 -5
- package/build/sources/vector-table-source.d.ts +0 -5
- package/build/sources/vector-tileset-source.d.ts +0 -5
- package/build/spatial-index.d.ts +0 -14
- package/build/types-internal.d.ts +0 -56
- package/build/types.d.ts +0 -148
- 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/utils.d.ts +0 -32
- package/build/widget-sources/index.d.ts +0 -7
- package/build/widget-sources/types.d.ts +0 -158
- package/build/widget-sources/widget-query-source.d.ts +0 -33
- package/build/widget-sources/widget-raster-source.d.ts +0 -11
- package/build/widget-sources/widget-remote-source.d.ts +0 -18
- package/build/widget-sources/widget-source.d.ts +0 -74
- package/build/widget-sources/widget-table-source.d.ts +0 -33
- package/build/widget-sources/widget-tileset-source.d.ts +0 -77
- package/src/filters/tileFeaturesRaster.ts +0 -111
- package/src/widget-sources/widget-raster-source.ts +0 -14
|
@@ -2,17 +2,19 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {getTileFormat} from '../utils/getTileFormat';
|
|
5
|
+
import {getTileFormat} from '../utils/getTileFormat.js';
|
|
6
6
|
import {
|
|
7
7
|
WidgetTilesetSource,
|
|
8
8
|
WidgetTilesetSourceResult,
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
WidgetTilesetWorkerSource,
|
|
10
|
+
} from '../widget-sources/index.js';
|
|
11
|
+
import {isModuleWorkerSupported} from '../workers/utils.js';
|
|
12
|
+
import {baseSource} from './base-source.js';
|
|
11
13
|
import type {
|
|
12
14
|
SourceOptions,
|
|
13
15
|
TilejsonResult,
|
|
14
16
|
TilesetSourceOptions,
|
|
15
|
-
} from './types';
|
|
17
|
+
} from './types.js';
|
|
16
18
|
|
|
17
19
|
export type QuadbinTilesetSourceOptions = SourceOptions & TilesetSourceOptions;
|
|
18
20
|
type UrlParameters = {name: string};
|
|
@@ -26,10 +28,15 @@ export const quadbinTilesetSource = async function (
|
|
|
26
28
|
const {tableName, spatialDataColumn = 'quadbin'} = options;
|
|
27
29
|
const urlParameters: UrlParameters = {name: tableName};
|
|
28
30
|
|
|
31
|
+
const WidgetSourceClass =
|
|
32
|
+
options.widgetSourceWorker !== false && isModuleWorkerSupported()
|
|
33
|
+
? WidgetTilesetWorkerSource
|
|
34
|
+
: WidgetTilesetSource;
|
|
35
|
+
|
|
29
36
|
return baseSource<UrlParameters>('tileset', options, urlParameters).then(
|
|
30
37
|
(result) => ({
|
|
31
38
|
...(result as TilejsonResult),
|
|
32
|
-
widgetSource: new
|
|
39
|
+
widgetSource: new WidgetSourceClass({
|
|
33
40
|
...options,
|
|
34
41
|
tileFormat: getTileFormat(result as TilejsonResult),
|
|
35
42
|
spatialDataColumn,
|
|
@@ -2,15 +2,13 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import {WidgetRasterSource, WidgetRasterSourceResult} from '../widget-sources';
|
|
7
|
-
import {baseSource} from './base-source';
|
|
5
|
+
import {baseSource} from './base-source.js';
|
|
8
6
|
import type {
|
|
9
7
|
FilterOptions,
|
|
10
8
|
SourceOptions,
|
|
11
9
|
TilejsonResult,
|
|
12
10
|
TilesetSourceOptions,
|
|
13
|
-
} from './types';
|
|
11
|
+
} from './types.js';
|
|
14
12
|
|
|
15
13
|
export type RasterSourceOptions = SourceOptions &
|
|
16
14
|
TilesetSourceOptions &
|
|
@@ -20,7 +18,7 @@ type UrlParameters = {
|
|
|
20
18
|
filters?: Record<string, unknown>;
|
|
21
19
|
};
|
|
22
20
|
|
|
23
|
-
export type RasterSourceResponse = TilejsonResult
|
|
21
|
+
export type RasterSourceResponse = TilejsonResult;
|
|
24
22
|
|
|
25
23
|
export const rasterSource = async function (
|
|
26
24
|
options: RasterSourceOptions
|
|
@@ -31,16 +29,9 @@ export const rasterSource = async function (
|
|
|
31
29
|
urlParameters.filters = filters;
|
|
32
30
|
}
|
|
33
31
|
|
|
34
|
-
return baseSource<UrlParameters>(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
...options,
|
|
39
|
-
tileFormat: getTileFormat(result as TilejsonResult),
|
|
40
|
-
spatialDataColumn: 'quadbin',
|
|
41
|
-
spatialDataType: 'quadbin',
|
|
42
|
-
rasterMetadata: (result as TilejsonResult).raster_metadata!,
|
|
43
|
-
}),
|
|
44
|
-
})
|
|
32
|
+
return baseSource<UrlParameters>(
|
|
33
|
+
'raster',
|
|
34
|
+
options,
|
|
35
|
+
urlParameters
|
|
45
36
|
) as Promise<RasterSourceResponse>;
|
|
46
37
|
};
|
package/src/sources/types.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import type {Feature} from 'geojson';
|
|
6
|
-
import {Filters, Format, QueryParameters} from '../types';
|
|
7
|
-
import {MapInstantiation} from '../types-internal';
|
|
6
|
+
import {Filters, Format, QueryParameters} from '../types.js';
|
|
7
|
+
import {MapInstantiation} from '../types-internal.js';
|
|
8
8
|
|
|
9
9
|
export type SourceRequiredOptions = {
|
|
10
10
|
/** Carto platform access token. */
|
|
@@ -191,6 +191,12 @@ export type TilesetSourceOptions = {
|
|
|
191
191
|
* Fully qualified name of tileset.
|
|
192
192
|
*/
|
|
193
193
|
tableName: string;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Whether to use Web Workers for local widget calculations. Workers
|
|
197
|
+
* are used by default if the runtime environment supports ES Module Workers.
|
|
198
|
+
*/
|
|
199
|
+
widgetSourceWorker?: boolean;
|
|
194
200
|
};
|
|
195
201
|
|
|
196
202
|
export type ColumnsOption = {
|
|
@@ -208,7 +214,7 @@ export type SpatialDataType = 'geo' | 'h3' | 'quadbin';
|
|
|
208
214
|
* Strategy used for covering spatial filter geometry with spatial indexes.
|
|
209
215
|
* See https://docs.carto.com/data-and-analysis/analytics-toolbox-for-bigquery/sql-reference/quadbin#quadbin_polyfill_mode
|
|
210
216
|
* or https://docs.carto.com/data-and-analysis/analytics-toolbox-for-bigquery/sql-reference/h3#h3_polyfill_mode for more information.
|
|
211
|
-
* @
|
|
217
|
+
* @privateRemarks Source: cloud-native maps-api
|
|
212
218
|
* */
|
|
213
219
|
export type SpatialFilterPolyfillMode = 'center' | 'intersects' | 'contains';
|
|
214
220
|
|
|
@@ -373,7 +379,7 @@ export type RasterMetadataBand = {
|
|
|
373
379
|
/**
|
|
374
380
|
* Default color mapping for unique values (or if coloprinterp is `palette`)
|
|
375
381
|
*/
|
|
376
|
-
colortable?: Record<string, [
|
|
382
|
+
colortable?: Record<string, number[]>;
|
|
377
383
|
|
|
378
384
|
/**
|
|
379
385
|
* No value representation.
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
/* eslint-disable camelcase */
|
|
6
5
|
import {
|
|
7
6
|
DEFAULT_GEO_COLUMN,
|
|
8
7
|
DEFAULT_TILE_RESOLUTION,
|
|
@@ -11,7 +10,7 @@ import {
|
|
|
11
10
|
WidgetQuerySource,
|
|
12
11
|
WidgetQuerySourceResult,
|
|
13
12
|
} from '../widget-sources/index.js';
|
|
14
|
-
import {baseSource} from './base-source';
|
|
13
|
+
import {baseSource} from './base-source.js';
|
|
15
14
|
import type {
|
|
16
15
|
FilterOptions,
|
|
17
16
|
SourceOptions,
|
|
@@ -19,7 +18,7 @@ import type {
|
|
|
19
18
|
SpatialDataType,
|
|
20
19
|
TilejsonResult,
|
|
21
20
|
ColumnsOption,
|
|
22
|
-
} from './types';
|
|
21
|
+
} from './types.js';
|
|
23
22
|
|
|
24
23
|
export type VectorQuerySourceOptions = SourceOptions &
|
|
25
24
|
QuerySourceOptions &
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
/* eslint-disable camelcase */
|
|
6
5
|
import {
|
|
7
6
|
DEFAULT_GEO_COLUMN,
|
|
8
7
|
DEFAULT_TILE_RESOLUTION,
|
|
@@ -11,7 +10,7 @@ import {
|
|
|
11
10
|
WidgetTableSource,
|
|
12
11
|
WidgetTableSourceResult,
|
|
13
12
|
} from '../widget-sources/index.js';
|
|
14
|
-
import {baseSource} from './base-source';
|
|
13
|
+
import {baseSource} from './base-source.js';
|
|
15
14
|
import type {
|
|
16
15
|
FilterOptions,
|
|
17
16
|
ColumnsOption,
|
|
@@ -19,7 +18,7 @@ import type {
|
|
|
19
18
|
SpatialDataType,
|
|
20
19
|
TableSourceOptions,
|
|
21
20
|
TilejsonResult,
|
|
22
|
-
} from './types';
|
|
21
|
+
} from './types.js';
|
|
23
22
|
|
|
24
23
|
export type VectorTableSourceOptions = SourceOptions &
|
|
25
24
|
TableSourceOptions &
|
|
@@ -2,18 +2,20 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {DEFAULT_GEO_COLUMN} from '../constants-internal';
|
|
6
|
-
import {getTileFormat} from '../utils/getTileFormat';
|
|
5
|
+
import {DEFAULT_GEO_COLUMN} from '../constants-internal.js';
|
|
6
|
+
import {getTileFormat} from '../utils/getTileFormat.js';
|
|
7
7
|
import {
|
|
8
8
|
WidgetTilesetSource,
|
|
9
9
|
WidgetTilesetSourceResult,
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
WidgetTilesetWorkerSource,
|
|
11
|
+
} from '../widget-sources/index.js';
|
|
12
|
+
import {isModuleWorkerSupported} from '../workers/utils.js';
|
|
13
|
+
import {baseSource} from './base-source.js';
|
|
12
14
|
import type {
|
|
13
15
|
SourceOptions,
|
|
14
16
|
TilesetSourceOptions,
|
|
15
17
|
TilejsonResult,
|
|
16
|
-
} from './types';
|
|
18
|
+
} from './types.js';
|
|
17
19
|
|
|
18
20
|
export type VectorTilesetSourceOptions = SourceOptions & TilesetSourceOptions;
|
|
19
21
|
type UrlParameters = {name: string};
|
|
@@ -27,10 +29,15 @@ export const vectorTilesetSource = async function (
|
|
|
27
29
|
const {tableName, spatialDataColumn = DEFAULT_GEO_COLUMN} = options;
|
|
28
30
|
const urlParameters: UrlParameters = {name: tableName};
|
|
29
31
|
|
|
32
|
+
const WidgetSourceClass =
|
|
33
|
+
options.widgetSourceWorker !== false && isModuleWorkerSupported()
|
|
34
|
+
? WidgetTilesetWorkerSource
|
|
35
|
+
: WidgetTilesetSource;
|
|
36
|
+
|
|
30
37
|
return baseSource<UrlParameters>('tileset', options, urlParameters).then(
|
|
31
38
|
(result) => ({
|
|
32
39
|
...(result as TilejsonResult),
|
|
33
|
-
widgetSource: new
|
|
40
|
+
widgetSource: new WidgetSourceClass({
|
|
34
41
|
...options,
|
|
35
42
|
tileFormat: getTileFormat(result as TilejsonResult),
|
|
36
43
|
spatialDataColumn,
|
package/src/spatial-index.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DEFAULT_AGGREGATION_RES_LEVEL_H3,
|
|
3
3
|
DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN,
|
|
4
|
-
} from './constants-internal';
|
|
5
|
-
import type {ModelSource} from './models/model';
|
|
6
|
-
import type {AggregationOptions} from './sources/types';
|
|
7
|
-
import type {ViewState} from './widget-sources';
|
|
4
|
+
} from './constants-internal.js';
|
|
5
|
+
import type {ModelSource} from './models/model.js';
|
|
6
|
+
import type {AggregationOptions} from './sources/types.js';
|
|
7
|
+
import type {ViewState} from './widget-sources/index.js';
|
|
8
8
|
|
|
9
9
|
const DEFAULT_TILE_SIZE = 512;
|
|
10
10
|
const QUADBIN_ZOOM_MAX_OFFSET = 4;
|
package/src/types-internal.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* COMMON
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import {Format} from './types';
|
|
5
|
+
import {Format} from './types.js';
|
|
6
6
|
|
|
7
7
|
/** @internal */
|
|
8
8
|
export type $TODO = any;
|
|
@@ -15,7 +15,7 @@ export type $IntentionalAny = any;
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* @
|
|
18
|
+
* @privateRemarks Source: @deck.gl/carto
|
|
19
19
|
* @internal
|
|
20
20
|
*/
|
|
21
21
|
export enum SchemaFieldType {
|
|
@@ -31,7 +31,7 @@ export enum SchemaFieldType {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
* @
|
|
34
|
+
* @privateRemarks Source: @deck.gl/carto
|
|
35
35
|
* @internal
|
|
36
36
|
*/
|
|
37
37
|
export interface SchemaField {
|
|
@@ -40,7 +40,7 @@ export interface SchemaField {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
|
-
* @
|
|
43
|
+
* @privateRemarks Source: @deck.gl/carto
|
|
44
44
|
* @internal
|
|
45
45
|
*/
|
|
46
46
|
export interface MapInstantiation extends MapInstantiationFormats {
|
|
@@ -50,7 +50,7 @@ export interface MapInstantiation extends MapInstantiationFormats {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
|
-
* @
|
|
53
|
+
* @privateRemarks Source: @deck.gl/carto
|
|
54
54
|
* @internal
|
|
55
55
|
*/
|
|
56
56
|
type MapInstantiationFormats = Record<
|
package/src/types.ts
CHANGED
|
@@ -6,10 +6,10 @@ import type {BinaryFeature, BinaryFeatureCollection} from '@loaders.gl/schema';
|
|
|
6
6
|
* MAPS AND TILES
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
/** @
|
|
9
|
+
/** @privateRemarks Source: @deck.gl/carto */
|
|
10
10
|
export type Format = 'json' | 'geojson' | 'tilejson';
|
|
11
11
|
|
|
12
|
-
/** @
|
|
12
|
+
/** @privateRemarks Source: @carto/constants, @deck.gl/carto */
|
|
13
13
|
export type MapType = 'boundary' | 'query' | 'table' | 'tileset' | 'raster';
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -23,7 +23,7 @@ export type Viewport = [number, number, number, number];
|
|
|
23
23
|
* required for local widget calculations. Deeper dependencies on deck.gl
|
|
24
24
|
* APIs should be minimized within this library: @deck.gl/carto depends
|
|
25
25
|
* on the API client, not the other way around.
|
|
26
|
-
* @
|
|
26
|
+
* @privateRemarks Source: @deck.gl/geo-layers
|
|
27
27
|
*/
|
|
28
28
|
export type Tile = {
|
|
29
29
|
index: {x: number; y: number; z: number};
|
|
@@ -40,13 +40,7 @@ export type SpatialIndexTile = Tile & {
|
|
|
40
40
|
data?: (Feature & {id: bigint})[];
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
id: string;
|
|
45
|
-
index: {q: bigint; i: string};
|
|
46
|
-
data?: Raster;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
/** @internalRemarks Source: @deck.gl/carto */
|
|
43
|
+
/** @privateRemarks Source: @deck.gl/carto */
|
|
50
44
|
export type Raster = {
|
|
51
45
|
blockSize: number;
|
|
52
46
|
cells: {
|
|
@@ -62,8 +56,8 @@ export type Raster = {
|
|
|
62
56
|
/**
|
|
63
57
|
* Enum for the different types of aggregations available for widgets.
|
|
64
58
|
*
|
|
65
|
-
* @
|
|
66
|
-
* @
|
|
59
|
+
* @privateRemarks Source: @carto/constants
|
|
60
|
+
* @privateRemarks Converted from enum to type union, for improved declarative API.
|
|
67
61
|
*/
|
|
68
62
|
export type AggregationType =
|
|
69
63
|
| 'count'
|
|
@@ -77,15 +71,15 @@ export type AggregationType =
|
|
|
77
71
|
* FILTERS
|
|
78
72
|
*/
|
|
79
73
|
|
|
80
|
-
/** @
|
|
74
|
+
/** @privateRemarks Source: @carto/react-api */
|
|
81
75
|
export type SpatialFilter = Polygon | MultiPolygon;
|
|
82
76
|
|
|
83
|
-
/** @
|
|
77
|
+
/** @privateRemarks Source: @deck.gl/carto */
|
|
84
78
|
export interface Filters {
|
|
85
79
|
[column: string]: Filter;
|
|
86
80
|
}
|
|
87
81
|
|
|
88
|
-
/** @
|
|
82
|
+
/** @privateRemarks Source: @carto/react-api, @deck.gl/carto */
|
|
89
83
|
export interface Filter {
|
|
90
84
|
[FilterType.IN]?: {owner?: string; values: number[] | string[]};
|
|
91
85
|
/** [a, b] both are included. */
|
|
@@ -100,7 +94,7 @@ export interface Filter {
|
|
|
100
94
|
};
|
|
101
95
|
}
|
|
102
96
|
|
|
103
|
-
/** @
|
|
97
|
+
/** @privateRemarks Source: @carto/react-core */
|
|
104
98
|
export type FilterLogicalOperator = 'and' | 'or';
|
|
105
99
|
|
|
106
100
|
/**
|
|
@@ -126,7 +120,7 @@ export type StringSearchOptions = {
|
|
|
126
120
|
/**
|
|
127
121
|
* Defines a step size increment for use with {@link TimeSeriesRequestOptions}.
|
|
128
122
|
*
|
|
129
|
-
* @
|
|
123
|
+
* @privateRemarks Source: @carto/react-core
|
|
130
124
|
*/
|
|
131
125
|
export type GroupDateType =
|
|
132
126
|
| 'year'
|
|
@@ -148,7 +142,7 @@ export type SortColumnType = 'number' | 'string' | 'date';
|
|
|
148
142
|
* SQL QUERY PARAMETERS
|
|
149
143
|
*/
|
|
150
144
|
|
|
151
|
-
/** @
|
|
145
|
+
/** @privateRemarks Source: @deck.gl/carto */
|
|
152
146
|
export type QueryParameterValue =
|
|
153
147
|
| string
|
|
154
148
|
| number
|
|
@@ -156,11 +150,11 @@ export type QueryParameterValue =
|
|
|
156
150
|
| Array<QueryParameterValue>
|
|
157
151
|
| object;
|
|
158
152
|
|
|
159
|
-
/** @
|
|
153
|
+
/** @privateRemarks Source: @deck.gl/carto */
|
|
160
154
|
export type NamedQueryParameter = Record<string, QueryParameterValue>;
|
|
161
155
|
|
|
162
|
-
/** @
|
|
156
|
+
/** @privateRemarks Source: @deck.gl/carto */
|
|
163
157
|
export type PositionalQueryParameter = QueryParameterValue[];
|
|
164
158
|
|
|
165
|
-
/** @
|
|
159
|
+
/** @privateRemarks Source: @deck.gl/carto */
|
|
166
160
|
export type QueryParameters = NamedQueryParameter | PositionalQueryParameter;
|
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,7 +1,7 @@
|
|
|
1
1
|
export * from './widget-source.js';
|
|
2
2
|
export * from './widget-query-source.js';
|
|
3
|
-
export * from './widget-raster-source.js';
|
|
4
3
|
export * from './widget-remote-source.js';
|
|
5
4
|
export * from './widget-table-source.js';
|
|
6
5
|
export * from './widget-tileset-source.js';
|
|
6
|
+
export * from './widget-tileset-worker-source.js';
|
|
7
7
|
export * from './types.js';
|
|
@@ -1,11 +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
|
-
import type {WidgetRemoteSource} from './widget-remote-source';
|
|
8
|
+
} from '../types.js';
|
|
9
9
|
|
|
10
10
|
/******************************************************************************
|
|
11
11
|
* WIDGET API REQUESTS
|
|
@@ -24,6 +24,8 @@ interface BaseRequestOptions {
|
|
|
24
24
|
/** Required for table- and query-based spatial index sources (H3, Quadbin). */
|
|
25
25
|
spatialIndexReferenceViewState?: ViewState;
|
|
26
26
|
abortController?: AbortController;
|
|
27
|
+
/** Overrides source filters, if any. */
|
|
28
|
+
filters?: Filters;
|
|
27
29
|
filterOwner?: string;
|
|
28
30
|
}
|
|
29
31
|
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
WidgetRemoteSourceProps,
|
|
9
9
|
} from './widget-remote-source.js';
|
|
10
10
|
import {ModelSource} from '../models/model.js';
|
|
11
|
+
import {Filters} from '../types.js';
|
|
11
12
|
|
|
12
13
|
type LayerQuerySourceOptions =
|
|
13
14
|
| Omit<VectorQuerySourceOptions, 'filters'>
|
|
@@ -41,9 +42,12 @@ export type WidgetQuerySourceResult = {widgetSource: WidgetQuerySource};
|
|
|
41
42
|
export class WidgetQuerySource extends WidgetRemoteSource<
|
|
42
43
|
LayerQuerySourceOptions & WidgetRemoteSourceProps
|
|
43
44
|
> {
|
|
44
|
-
protected override getModelSource(
|
|
45
|
+
protected override getModelSource(
|
|
46
|
+
filters: Filters | undefined,
|
|
47
|
+
filterOwner?: string
|
|
48
|
+
): ModelSource {
|
|
45
49
|
return {
|
|
46
|
-
...super._getModelSource(
|
|
50
|
+
...super._getModelSource(filters, filterOwner),
|
|
47
51
|
type: 'query',
|
|
48
52
|
data: this.props.sqlQuery,
|
|
49
53
|
queryParameters: this.props.queryParameters,
|