@carto/api-client
Advanced tools
Comparing version
# CHANGELOG | ||
## 0.5 (Unreleased) | ||
## 0.5 | ||
### 0.5.0 (Unreleased) | ||
### 0.5.1 | ||
- chore(types): Cleanup for tilesets, rasters, and backward-compatibility (#150) | ||
- feat(fetchMap): Export legendSettings (#153) | ||
### 0.5.0 | ||
- BREAKING CHANGE: Replace 'abortController' with 'signal' parameter (#110) | ||
@@ -8,0 +13,0 @@ - feat: Add widget calculations for tileset sources (#50) |
@@ -11,3 +11,3 @@ { | ||
"packageManager": "yarn@4.3.1", | ||
"version": "0.5.1-alpha.2", | ||
"version": "0.5.1", | ||
"license": "MIT", | ||
@@ -43,3 +43,3 @@ "publishConfig": { | ||
"build:watch": "tsup --watch", | ||
"dev": "concurrently \"yarn build:watch\" \"vite --config examples/vite.config.ts --open\"", | ||
"dev": "yarn build && concurrently --names tsup,vite \"yarn build:watch\" \"vite --config examples/vite.config.ts --open\"", | ||
"test": "vitest run --typecheck", | ||
@@ -132,4 +132,3 @@ "test:watch": "vitest watch --typecheck", | ||
"rollup": "^4.20.0" | ||
}, | ||
"stableVersion": "0.5.0" | ||
} | ||
} |
@@ -1,3 +0,1 @@ | ||
import {TilejsonResult} from '../sources/index.js'; | ||
import {DEFAULT_API_BASE_URL} from '../constants.js'; | ||
@@ -122,7 +120,3 @@ | ||
const dataset = datasets.find((d) => d.id === layer.config.dataId); | ||
if ( | ||
dataset && | ||
dataset.type !== 'tileset' && | ||
(dataset.data as TilejsonResult).tilestats | ||
) { | ||
if (dataset && dataset.type !== 'tileset' && dataset.data.tilestats) { | ||
// Only fetch stats for QUERY & TABLE map types | ||
@@ -129,0 +123,0 @@ attributes.push({attribute, dataset}); |
@@ -60,3 +60,3 @@ import type {ColorParameters} from '@luma.gl/core'; | ||
const config = keplerMapConfig.config as KeplerMapConfig; | ||
const {filters, mapState, mapStyle, popupSettings} = config; | ||
const {filters, mapState, mapStyle, popupSettings, legendSettings} = config; | ||
const {layers, layerBlending, interactionConfig} = config.visState; | ||
@@ -74,2 +74,3 @@ | ||
popupSettings, | ||
legendSettings, | ||
token, | ||
@@ -76,0 +77,0 @@ layers: layers |
@@ -204,2 +204,3 @@ import {Dataset} from './types.js'; | ||
/** | ||
* @internal | ||
* State of `aggregationResLevel` in the UI and backend config is based on an assumption of | ||
@@ -209,3 +210,3 @@ * 512x512px tiles. Because we may change tile resolution for performance goals, the | ||
*/ | ||
function scaleAggregationResLevel( | ||
export function scaleAggregationResLevel( | ||
aggregationResLevel: number, | ||
@@ -218,3 +219,8 @@ tileResolution: number | ||
function getColumnNameFromGeoColumn(geoColumn: string | null | undefined) { | ||
/** | ||
* @internal | ||
*/ | ||
export function getColumnNameFromGeoColumn( | ||
geoColumn: string | null | undefined | ||
) { | ||
if (!geoColumn) { | ||
@@ -227,3 +233,6 @@ return geoColumn; | ||
function getSpatialIndexFromGeoColumn(geoColumn: string) { | ||
/** | ||
* @internal | ||
*/ | ||
export function getSpatialIndexFromGeoColumn(geoColumn: string) { | ||
const spatialIndexToSearch = geoColumn.split(':')[0]; | ||
@@ -230,0 +239,0 @@ |
import {LayerType, SCALE_TYPE} from './layer-map.js'; | ||
import {Format, MapType, ProviderType, QueryParameters} from '../types.js'; | ||
import {TilejsonResult, GeojsonResult, JsonResult} from '../sources/types.js'; | ||
import {TilejsonResult} from '../sources/types.js'; | ||
@@ -120,2 +120,3 @@ export type VisualChannelField = { | ||
}; | ||
legendSettings?: any; | ||
popupSettings: any; | ||
@@ -212,3 +213,3 @@ visState: { | ||
geoColumn: string; | ||
data: TilejsonResult | GeojsonResult | JsonResult; | ||
data: TilejsonResult; | ||
columns: string[]; | ||
@@ -215,0 +216,0 @@ format: Format; |
@@ -29,1 +29,2 @@ export * from './client.js'; | ||
export * from './utils/transformToTileCoords.js'; | ||
export * from './fetch-map/source.js'; |
@@ -10,4 +10,2 @@ // deck.gl | ||
import type { | ||
GeojsonResult, | ||
JsonResult, | ||
SourceOptionalOptions, | ||
@@ -24,3 +22,2 @@ SourceRequiredOptions, | ||
apiBaseUrl: DEFAULT_API_BASE_URL, | ||
format: 'tilejson', | ||
headers: {}, | ||
@@ -34,3 +31,3 @@ maxLengthURL: DEFAULT_MAX_LENGTH_URL, | ||
urlParameters: UrlParameters | ||
): Promise<TilejsonResult | GeojsonResult | JsonResult> { | ||
): Promise<TilejsonResult> { | ||
const {accessToken, connectionName, cache, ...optionalOptions} = options; | ||
@@ -51,3 +48,3 @@ const mergedOptions = { | ||
const baseUrl = buildSourceUrl(mergedOptions); | ||
const {clientId, maxLengthURL, format, localCache} = mergedOptions; | ||
const {clientId, maxLengthURL, localCache} = mergedOptions; | ||
const headers = { | ||
@@ -75,3 +72,3 @@ Authorization: `Bearer ${options.accessToken}`, | ||
const dataUrl = mapInstantiation[format].url[0]; | ||
const dataUrl = mapInstantiation.tilejson.url[0]; | ||
if (cache) { | ||
@@ -85,18 +82,3 @@ cache.value = parseInt( | ||
if (format === 'tilejson') { | ||
const json = await requestWithParameters<TilejsonResult>({ | ||
baseUrl: dataUrl, | ||
parameters: {client: clientId}, | ||
headers, | ||
errorContext, | ||
maxLengthURL, | ||
localCache, | ||
}); | ||
if (accessToken) { | ||
json.accessToken = accessToken; | ||
} | ||
return json; | ||
} | ||
return await requestWithParameters<GeojsonResult | JsonResult>({ | ||
const json = await requestWithParameters<TilejsonResult>({ | ||
baseUrl: dataUrl, | ||
@@ -109,2 +91,6 @@ parameters: {client: clientId}, | ||
}); | ||
if (accessToken) { | ||
json.accessToken = accessToken; | ||
} | ||
return json; | ||
} |
@@ -51,7 +51,3 @@ // deck.gl | ||
return baseSource<UrlParameters>( | ||
'boundary', | ||
options, | ||
urlParameters | ||
) as Promise<BoundaryQuerySourceResponse>; | ||
return baseSource<UrlParameters>('boundary', options, urlParameters); | ||
}; |
@@ -39,7 +39,3 @@ // deck.gl | ||
return baseSource<UrlParameters>( | ||
'boundary', | ||
options, | ||
urlParameters | ||
) as Promise<BoundaryTableSourceResponse>; | ||
return baseSource<UrlParameters>('boundary', options, urlParameters); | ||
}; |
@@ -70,3 +70,3 @@ // deck.gl | ||
(result) => ({ | ||
...(result as TilejsonResult), | ||
...result, | ||
widgetSource: new WidgetQuerySource({ | ||
@@ -73,0 +73,0 @@ ...options, |
@@ -65,3 +65,3 @@ // deck.gl | ||
(result) => ({ | ||
...(result as TilejsonResult), | ||
...result, | ||
widgetSource: new WidgetTableSource({ | ||
@@ -68,0 +68,0 @@ ...options, |
@@ -31,6 +31,6 @@ // deck.gl | ||
(result) => ({ | ||
...(result as TilejsonResult), | ||
...result, | ||
widgetSource: new WidgetTilesetSource({ | ||
...options, | ||
tileFormat: getTileFormat(result as TilejsonResult), | ||
tileFormat: getTileFormat(result), | ||
spatialDataColumn, | ||
@@ -37,0 +37,0 @@ spatialDataType: 'h3', |
@@ -7,17 +7,25 @@ // deck.gl | ||
export type { | ||
GeojsonResult, | ||
JsonResult, | ||
SourceOptions, | ||
SourceRequiredOptions, | ||
SourceOptionalOptions, | ||
TilejsonResult, | ||
QueryResult, | ||
FilterOptions, | ||
QuerySourceOptions, | ||
RasterBandColorinterp, | ||
TableSourceOptions, | ||
TilesetSourceOptions, | ||
ColumnsOption, | ||
SpatialDataType, | ||
SpatialFilterPolyfillMode, | ||
TileResolution, | ||
Tilejson, | ||
Tilestats, | ||
Layer, | ||
Attribute, | ||
VectorLayer, | ||
RasterMetadata, | ||
RasterMetadataBand, | ||
RasterMetadataBandStats, | ||
SourceOptions, | ||
SpatialFilterPolyfillMode, | ||
TableSourceOptions, | ||
TilejsonResult, | ||
TileResolution, | ||
TilesetSourceOptions, | ||
VectorLayer, | ||
RasterBandType, | ||
RasterBandColorinterp, | ||
} from './types.js'; | ||
@@ -24,0 +32,0 @@ |
@@ -71,3 +71,3 @@ // deck.gl | ||
(result) => ({ | ||
...(result as TilejsonResult), | ||
...result, | ||
widgetSource: new WidgetQuerySource({ | ||
@@ -74,0 +74,0 @@ ...options, |
@@ -66,3 +66,3 @@ // deck.gl | ||
(result) => ({ | ||
...(result as TilejsonResult), | ||
...result, | ||
widgetSource: new WidgetTableSource({ | ||
@@ -69,0 +69,0 @@ ...options, |
@@ -31,6 +31,6 @@ // deck.gl | ||
(result) => ({ | ||
...(result as TilejsonResult), | ||
...result, | ||
widgetSource: new WidgetTilesetSource({ | ||
...options, | ||
tileFormat: getTileFormat(result as TilejsonResult), | ||
tileFormat: getTileFormat(result), | ||
spatialDataColumn, | ||
@@ -37,0 +37,0 @@ spatialDataType: 'quadbin', |
@@ -40,9 +40,9 @@ // deck.gl | ||
(result) => ({ | ||
...(result as TilejsonResult), | ||
...result, | ||
widgetSource: new WidgetRasterSource({ | ||
...options, | ||
tileFormat: getTileFormat(result as TilejsonResult), | ||
tileFormat: getTileFormat(result), | ||
spatialDataColumn: 'quadbin', | ||
spatialDataType: 'quadbin', | ||
rasterMetadata: (result as TilejsonResult).raster_metadata!, | ||
rasterMetadata: result.raster_metadata!, | ||
}), | ||
@@ -49,0 +49,0 @@ }) |
@@ -5,5 +5,4 @@ // deck.gl | ||
import type {Feature} from 'geojson'; | ||
import {Filters, Format, QueryParameters} from '../types.js'; | ||
import {MapInstantiation} from '../types-internal.js'; | ||
import {Filters, QueryParameters} from '../types.js'; | ||
import {SchemaField} from '../types-internal.js'; | ||
@@ -42,4 +41,2 @@ export type SourceRequiredOptions = { | ||
clientId: string; | ||
/** @deprecated use `query` instead **/ | ||
format: Format; | ||
@@ -218,3 +215,6 @@ /** | ||
export type TilejsonMapInstantiation = MapInstantiation & { | ||
export type TilejsonMapInstantiation = { | ||
nrows: number; | ||
size?: number; | ||
schema: SchemaField[]; | ||
tilejson: {url: string[]}; | ||
@@ -421,4 +421,2 @@ }; | ||
export type TilejsonResult = Tilejson & {accessToken: string}; | ||
export type GeojsonResult = {type: 'FeatureCollection'; features: Feature[]}; | ||
export type JsonResult = any[]; | ||
export type QueryResult = { | ||
@@ -425,0 +423,0 @@ meta: {cacheHit: boolean; location: string; totalBytesProcessed: string}; |
@@ -79,3 +79,3 @@ // deck.gl | ||
(result) => ({ | ||
...(result as TilejsonResult), | ||
...result, | ||
widgetSource: new WidgetQuerySource({ | ||
@@ -82,0 +82,0 @@ ...options, |
@@ -74,3 +74,3 @@ // deck.gl | ||
(result) => ({ | ||
...(result as TilejsonResult), | ||
...result, | ||
widgetSource: new WidgetTableSource({ | ||
@@ -77,0 +77,0 @@ ...options, |
@@ -32,6 +32,6 @@ // deck.gl | ||
(result) => ({ | ||
...(result as TilejsonResult), | ||
...result, | ||
widgetSource: new WidgetTilesetSource({ | ||
...options, | ||
tileFormat: getTileFormat(result as TilejsonResult), | ||
tileFormat: getTileFormat(result), | ||
spatialDataColumn, | ||
@@ -38,0 +38,0 @@ spatialDataType: 'geo', |
@@ -5,4 +5,2 @@ /****************************************************************************** | ||
import {Format} from './types.js'; | ||
/** @internal */ | ||
@@ -43,24 +41,2 @@ export type $TODO = any; | ||
/** | ||
* @privateRemarks Source: @deck.gl/carto | ||
* @internal | ||
*/ | ||
export interface MapInstantiation extends MapInstantiationFormats { | ||
nrows: number; | ||
size?: number; | ||
schema: SchemaField[]; | ||
} | ||
/** | ||
* @privateRemarks Source: @deck.gl/carto | ||
* @internal | ||
*/ | ||
type MapInstantiationFormats = Record< | ||
Format, | ||
{ | ||
url: string[]; | ||
error?: any; | ||
} | ||
>; | ||
/****************************************************************************** | ||
@@ -67,0 +43,0 @@ * LOCAL CALCULATIONS |
@@ -120,5 +120,5 @@ import {SpatialFilterPolyfillMode, TileResolution} from '../sources/types.js'; | ||
limit?: number; | ||
/** Local only. */ | ||
/** @deprecated Supported for tilesets only. Prefer `filters` (for all sources) instead. */ | ||
searchFilterColumn?: string; | ||
/** Local only. */ | ||
/** @deprecated Supported for tilesets only. Prefer `filters` (for all sources) instead. */ | ||
searchFilterText?: string; | ||
@@ -125,0 +125,0 @@ } |
@@ -274,3 +274,7 @@ /* eslint-disable @typescript-eslint/require-await */ | ||
// Search. | ||
// TODO(v0.6): Remove "searchFilterText" and "searchFilterColumn". | ||
if (searchFilterColumn && searchFilterText) { | ||
console.warn( | ||
'WidgetTilesetSource: "searchFilterText" is deprecated, use "filters" and FilterType.STRING_SEARCH instead.' | ||
); | ||
filteredFeatures = filteredFeatures.filter( | ||
@@ -277,0 +281,0 @@ (row) => |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
7443885
0.02%50971
-0.03%