From 920cf982e28a7192d5dfcd63a1b7427571fd0606 Mon Sep 17 00:00:00 2001 From: Don McCurdy Date: Mon, 4 Nov 2024 13:47:06 -0500 Subject: [PATCH] deps(carto): Add @carto/api-client (#9230) --- modules/carto/package.json | 1 + modules/carto/src/api/basemap.ts | 3 +- modules/carto/src/api/carto-api-error.ts | 72 ------ modules/carto/src/api/common.ts | 10 - modules/carto/src/api/endpoints.ts | 73 ------ modules/carto/src/api/fetch-map.ts | 34 +-- modules/carto/src/api/index.ts | 14 +- modules/carto/src/api/query.ts | 46 ---- .../carto/src/api/request-with-parameters.ts | 121 --------- modules/carto/src/api/types.ts | 75 ------ modules/carto/src/basemap.ts | 4 +- modules/carto/src/constants.ts | 4 - modules/carto/src/index.ts | 12 +- .../carto/src/layers/cluster-tile-layer.ts | 3 +- modules/carto/src/layers/h3-tile-layer.ts | 2 +- .../carto/src/layers/heatmap-tile-layer.ts | 4 +- .../carto/src/layers/quadbin-tile-layer.ts | 2 +- modules/carto/src/layers/raster-tile-layer.ts | 2 +- modules/carto/src/layers/utils.ts | 2 +- modules/carto/src/layers/vector-tile-layer.ts | 2 +- modules/carto/src/sources/base-source.ts | 83 ------- .../src/sources/boundary-query-source.ts | 43 ---- .../src/sources/boundary-table-source.ts | 37 --- modules/carto/src/sources/h3-query-source.ts | 59 ----- modules/carto/src/sources/h3-table-source.ts | 55 ---- .../carto/src/sources/h3-tileset-source.ts | 18 -- modules/carto/src/sources/index.ts | 49 ---- .../carto/src/sources/quadbin-query-source.ts | 60 ----- .../carto/src/sources/quadbin-table-source.ts | 56 ----- .../src/sources/quadbin-tileset-source.ts | 18 -- modules/carto/src/sources/raster-source.ts | 21 -- modules/carto/src/sources/types.ts | 235 ------------------ .../carto/src/sources/vector-query-source.ts | 61 ----- .../carto/src/sources/vector-table-source.ts | 55 ---- .../src/sources/vector-tileset-source.ts | 18 -- test/modules/carto/api/basemap.spec.ts | 3 +- .../modules/carto/api/carto-api-error.spec.ts | 121 --------- test/modules/carto/api/query.spec.ts | 30 --- .../carto/api/request-with-parameters.spec.ts | 231 ----------------- test/modules/carto/index.ts | 15 -- .../sources/boundary-query-source.spec.ts | 39 --- .../sources/boundary-table-source.spec.ts | 35 --- .../carto/sources/h3-query-source.spec.ts | 41 --- .../carto/sources/h3-table-source.spec.ts | 39 --- .../carto/sources/h3-tileset-source.spec.ts | 35 --- .../sources/quadbin-query-source.spec.ts | 39 --- .../sources/quadbin-table-source.spec.ts | 39 --- .../sources/quadbin-tileset-source.spec.ts | 35 --- .../carto/sources/raster-source.spec.ts | 49 ---- .../carto/sources/vector-query-source.spec.ts | 46 ---- .../carto/sources/vector-table-source.spec.ts | 40 --- .../sources/vector-tileset-source.spec.ts | 35 --- yarn.lock | 92 ++++++- 53 files changed, 130 insertions(+), 2188 deletions(-) delete mode 100644 modules/carto/src/api/carto-api-error.ts delete mode 100644 modules/carto/src/api/common.ts delete mode 100644 modules/carto/src/api/endpoints.ts delete mode 100644 modules/carto/src/api/query.ts delete mode 100644 modules/carto/src/api/request-with-parameters.ts delete mode 100644 modules/carto/src/sources/base-source.ts delete mode 100644 modules/carto/src/sources/boundary-query-source.ts delete mode 100644 modules/carto/src/sources/boundary-table-source.ts delete mode 100644 modules/carto/src/sources/h3-query-source.ts delete mode 100644 modules/carto/src/sources/h3-table-source.ts delete mode 100644 modules/carto/src/sources/h3-tileset-source.ts delete mode 100644 modules/carto/src/sources/index.ts delete mode 100644 modules/carto/src/sources/quadbin-query-source.ts delete mode 100644 modules/carto/src/sources/quadbin-table-source.ts delete mode 100644 modules/carto/src/sources/quadbin-tileset-source.ts delete mode 100644 modules/carto/src/sources/raster-source.ts delete mode 100644 modules/carto/src/sources/types.ts delete mode 100644 modules/carto/src/sources/vector-query-source.ts delete mode 100644 modules/carto/src/sources/vector-table-source.ts delete mode 100644 modules/carto/src/sources/vector-tileset-source.ts delete mode 100644 test/modules/carto/api/carto-api-error.spec.ts delete mode 100644 test/modules/carto/api/query.spec.ts delete mode 100644 test/modules/carto/api/request-with-parameters.spec.ts delete mode 100644 test/modules/carto/sources/boundary-query-source.spec.ts delete mode 100644 test/modules/carto/sources/boundary-table-source.spec.ts delete mode 100644 test/modules/carto/sources/h3-query-source.spec.ts delete mode 100644 test/modules/carto/sources/h3-table-source.spec.ts delete mode 100644 test/modules/carto/sources/h3-tileset-source.spec.ts delete mode 100644 test/modules/carto/sources/quadbin-query-source.spec.ts delete mode 100644 test/modules/carto/sources/quadbin-table-source.spec.ts delete mode 100644 test/modules/carto/sources/quadbin-tileset-source.spec.ts delete mode 100644 test/modules/carto/sources/raster-source.spec.ts delete mode 100644 test/modules/carto/sources/vector-query-source.spec.ts delete mode 100644 test/modules/carto/sources/vector-table-source.spec.ts delete mode 100644 test/modules/carto/sources/vector-tileset-source.spec.ts diff --git a/modules/carto/package.json b/modules/carto/package.json index 8a537fee5ef..f42955b9aca 100644 --- a/modules/carto/package.json +++ b/modules/carto/package.json @@ -42,6 +42,7 @@ "prepublishOnly": "npm run build-bundle && npm run build-bundle -- --env=dev" }, "dependencies": { + "@carto/api-client": "^0.4.0-alpha.4", "@loaders.gl/gis": "^4.2.0", "@loaders.gl/loader-utils": "^4.2.0", "@loaders.gl/mvt": "^4.2.0", diff --git a/modules/carto/src/api/basemap.ts b/modules/carto/src/api/basemap.ts index 1ec13d2b560..47cd6d0d8dc 100644 --- a/modules/carto/src/api/basemap.ts +++ b/modules/carto/src/api/basemap.ts @@ -11,7 +11,8 @@ import { getStyleUrl, someLayerGroupsDisabled } from '../basemap'; -import {APIErrorContext, Basemap, KeplerMapConfig, MapLibreBasemapProps} from './types'; +import {Basemap, KeplerMapConfig, MapLibreBasemapProps} from './types'; +import {APIErrorContext} from '@carto/api-client'; const CUSTOM_STYLE_ID_PREFIX = 'custom:'; const DEFAULT_CARTO_STYLE = 'positron'; diff --git a/modules/carto/src/api/carto-api-error.ts b/modules/carto/src/api/carto-api-error.ts deleted file mode 100644 index 1d9a3dfb1e9..00000000000 --- a/modules/carto/src/api/carto-api-error.ts +++ /dev/null @@ -1,72 +0,0 @@ -// deck.gl -// SPDX-License-Identifier: MIT -// Copyright (c) vis.gl contributors - -import type {APIErrorContext} from './types'; - -/** - * - * Custom error for reported errors in CARTO Maps API. - * Provides useful debugging information in console and context for applications. - * - */ -export class CartoAPIError extends Error { - /** Source error from server */ - error: Error; - - /** Context (API call & parameters) in which error occured */ - errorContext: APIErrorContext; - - /** Response from server */ - response?: Response; - - /** JSON Response from server */ - responseJson?: any; - - constructor( - error: Error, - errorContext: APIErrorContext, - response?: Response, - responseJson?: any - ) { - let responseString = 'Failed to connect'; - if (response) { - responseString = 'Server returned: '; - if (response.status === 400) { - responseString += 'Bad request'; - } else if (response.status === 401 || response.status === 403) { - responseString += 'Unauthorized access'; - } else if (response.status === 404) { - responseString += 'Not found'; - } else { - responseString += 'Error'; - } - - responseString += ` (${response.status}):`; - } - responseString += ` ${error.message || error}`; - - let message = `${errorContext.requestType} API request failed`; - message += `\n${responseString}`; - for (const key of Object.keys(errorContext)) { - if (key === 'requestType') continue; // eslint-disable-line no-continue - message += `\n${formatErrorKey(key)}: ${errorContext[key]}`; - } - message += '\n'; - - super(message); - - this.name = 'CartoAPIError'; - this.response = response; - this.responseJson = responseJson; - this.error = error; - this.errorContext = errorContext; - } -} - -/** - * Converts camelCase to Camel Case - */ -function formatErrorKey(key) { - return key.replace(/([A-Z])/g, ' $1').replace(/^./, s => s.toUpperCase()); -} diff --git a/modules/carto/src/api/common.ts b/modules/carto/src/api/common.ts deleted file mode 100644 index 8567e5e0d96..00000000000 --- a/modules/carto/src/api/common.ts +++ /dev/null @@ -1,10 +0,0 @@ -// deck.gl -// SPDX-License-Identifier: MIT -// Copyright (c) vis.gl contributors - -export const DEFAULT_API_BASE_URL = 'https://gcp-us-east1.api.carto.com'; -export const DEFAULT_CLIENT = 'deck-gl-carto'; -export const V3_MINOR_VERSION = '3.4'; - -// Fastly default limit is 8192; leave some padding. -export const DEFAULT_MAX_LENGTH_URL = 7000; diff --git a/modules/carto/src/api/endpoints.ts b/modules/carto/src/api/endpoints.ts deleted file mode 100644 index 9eda6bab599..00000000000 --- a/modules/carto/src/api/endpoints.ts +++ /dev/null @@ -1,73 +0,0 @@ -// deck.gl -// SPDX-License-Identifier: MIT -// Copyright (c) vis.gl contributors - -import {MapType} from './types'; - -export type V3Endpoint = 'maps' | 'stats' | 'sql'; - -function joinPath(...args: string[]): string { - return args.map(part => (part.endsWith('/') ? part.slice(0, -1) : part)).join('/'); -} - -function buildV3Path( - apiBaseUrl: string, - version: 'v3', - endpoint: V3Endpoint, - ...rest: string[] -): string { - return joinPath(apiBaseUrl, version, endpoint, ...rest); -} - -export function buildPublicMapUrl({ - apiBaseUrl, - cartoMapId -}: { - apiBaseUrl: string; - cartoMapId: string; -}): string { - return buildV3Path(apiBaseUrl, 'v3', 'maps', 'public', cartoMapId); -} - -export function buildStatsUrl({ - attribute, - apiBaseUrl, - connectionName, - source, - type -}: { - attribute: string; - apiBaseUrl: string; - connectionName: string; - source: string; - type: MapType; -}): string { - if (type === 'query') { - return buildV3Path(apiBaseUrl, 'v3', 'stats', connectionName, attribute); - } - - // type === 'table' - return buildV3Path(apiBaseUrl, 'v3', 'stats', connectionName, source, attribute); -} - -export function buildSourceUrl({ - apiBaseUrl, - connectionName, - endpoint -}: { - apiBaseUrl: string; - connectionName: string; - endpoint: MapType; -}): string { - return buildV3Path(apiBaseUrl, 'v3', 'maps', connectionName, endpoint); -} - -export function buildQueryUrl({ - apiBaseUrl, - connectionName -}: { - apiBaseUrl: string; - connectionName: string; -}): string { - return buildV3Path(apiBaseUrl, 'v3', 'sql', connectionName, 'query'); -} diff --git a/modules/carto/src/api/fetch-map.ts b/modules/carto/src/api/fetch-map.ts index 118ee52852b..06cd7ef6f26 100644 --- a/modules/carto/src/api/fetch-map.ts +++ b/modules/carto/src/api/fetch-map.ts @@ -2,26 +2,30 @@ // SPDX-License-Identifier: MIT // Copyright (c) vis.gl contributors -/* eslint-disable camelcase */ -import {CartoAPIError} from './carto-api-error'; -import {DEFAULT_API_BASE_URL, DEFAULT_CLIENT, DEFAULT_MAX_LENGTH_URL} from './common'; -import {buildPublicMapUrl, buildStatsUrl} from './endpoints'; import { + SOURCE_DEFAULTS, + APIErrorContext, + CartoAPIError, GeojsonResult, JsonResult, TilejsonResult, + Format, + MapType, + QueryParameters, + buildPublicMapUrl, + buildStatsUrl, h3QuerySource, h3TableSource, quadbinQuerySource, quadbinTableSource, vectorQuerySource, vectorTableSource, - vectorTilesetSource -} from '../sources/index'; + vectorTilesetSource, + requestWithParameters +} from '@carto/api-client'; import {ParseMapResult, parseMap} from './parse-map'; -import {requestWithParameters} from './request-with-parameters'; import {assert} from '../utils'; -import type {APIErrorContext, Basemap, Format, MapType, QueryParameters} from './types'; +import type {Basemap} from './types'; import {fetchBasemapProps} from './basemap'; type Dataset = { @@ -47,7 +51,7 @@ async function _fetchMapDataset( apiBaseUrl: string, clientId?: string, headers?: Record, - maxLengthURL = DEFAULT_MAX_LENGTH_URL + maxLengthURL = SOURCE_DEFAULTS.maxLengthURL ) { const { aggregationExp, @@ -121,7 +125,7 @@ async function _fetchTilestats( dataset: Dataset, accessToken: string, apiBaseUrl: string, - maxLengthURL = DEFAULT_MAX_LENGTH_URL + maxLengthURL = SOURCE_DEFAULTS.maxLengthURL ) { const {connectionName, data, id, source, type, queryParameters} = dataset; const errorContext: APIErrorContext = { @@ -167,7 +171,7 @@ async function fillInMapDatasets( clientId: string, apiBaseUrl: string, headers?: Record, - maxLengthURL = DEFAULT_MAX_LENGTH_URL + maxLengthURL = SOURCE_DEFAULTS.maxLengthURL ) { const promises = datasets.map(dataset => _fetchMapDataset(dataset, token, apiBaseUrl, clientId, headers, maxLengthURL) @@ -178,7 +182,7 @@ async function fillInMapDatasets( async function fillInTileStats( {datasets, keplerMapConfig, token}: {datasets: Dataset[]; keplerMapConfig: any; token: string}, apiBaseUrl: string, - maxLengthURL = DEFAULT_MAX_LENGTH_URL + maxLengthURL = SOURCE_DEFAULTS.maxLengthURL ) { const attributes: {attribute: string; dataset: any}[] = []; const {layers} = keplerMapConfig.config.visState; @@ -267,13 +271,13 @@ export type FetchMapResult = ParseMapResult & { /* eslint-disable max-statements */ export async function fetchMap({ accessToken, - apiBaseUrl = DEFAULT_API_BASE_URL, + apiBaseUrl = SOURCE_DEFAULTS.apiBaseUrl, cartoMapId, - clientId = DEFAULT_CLIENT, + clientId = SOURCE_DEFAULTS.clientId, headers = {}, autoRefresh, onNewData, - maxLengthURL = DEFAULT_MAX_LENGTH_URL + maxLengthURL = SOURCE_DEFAULTS.maxLengthURL }: FetchMapOptions): Promise { assert(cartoMapId, 'Must define CARTO map id: fetchMap({cartoMapId: "XXXX-XXXX-XXXX"})'); assert(apiBaseUrl, 'Must define apiBaseUrl'); diff --git a/modules/carto/src/api/index.ts b/modules/carto/src/api/index.ts index c400f99af92..f9cb86b1335 100644 --- a/modules/carto/src/api/index.ts +++ b/modules/carto/src/api/index.ts @@ -2,18 +2,6 @@ // SPDX-License-Identifier: MIT // Copyright (c) vis.gl contributors -export {CartoAPIError} from './carto-api-error'; export {fetchMap} from './fetch-map'; export type {FetchMapOptions, FetchMapResult} from './fetch-map'; -export type { - APIErrorContext, - Format, - MapType, - RequestType, - QueryParameters, - Basemap, - MapLibreBasemap, - GoogleBasemap -} from './types'; -export {query} from './query'; -export type {QueryOptions} from './query'; +export type {Basemap, MapLibreBasemap, GoogleBasemap} from './types'; diff --git a/modules/carto/src/api/query.ts b/modules/carto/src/api/query.ts deleted file mode 100644 index c51f14fad3b..00000000000 --- a/modules/carto/src/api/query.ts +++ /dev/null @@ -1,46 +0,0 @@ -// deck.gl -// SPDX-License-Identifier: MIT -// Copyright (c) vis.gl contributors - -import {SOURCE_DEFAULTS} from '../sources/index'; -import type {SourceOptions, QuerySourceOptions, QueryResult} from '../sources/types'; -import {buildQueryUrl} from './endpoints'; -import {requestWithParameters} from './request-with-parameters'; -import {APIErrorContext} from './types'; - -export type QueryOptions = SourceOptions & Omit; -type UrlParameters = {q: string; queryParameters?: string}; - -export const query = async function (options: QueryOptions): Promise { - const { - apiBaseUrl = SOURCE_DEFAULTS.apiBaseUrl, - clientId = SOURCE_DEFAULTS.clientId, - maxLengthURL = SOURCE_DEFAULTS.maxLengthURL, - connectionName, - sqlQuery, - queryParameters - } = options; - const urlParameters: UrlParameters = {q: sqlQuery}; - - if (queryParameters) { - urlParameters.queryParameters = JSON.stringify(queryParameters); - } - - const baseUrl = buildQueryUrl({apiBaseUrl, connectionName}); - const headers = {Authorization: `Bearer ${options.accessToken}`, ...options.headers}; - const parameters = {client: clientId, ...urlParameters}; - - const errorContext: APIErrorContext = { - requestType: 'SQL', - connection: options.connectionName, - type: 'query', - source: JSON.stringify(parameters, undefined, 2) - }; - return await requestWithParameters({ - baseUrl, - parameters, - headers, - errorContext, - maxLengthURL - }); -}; diff --git a/modules/carto/src/api/request-with-parameters.ts b/modules/carto/src/api/request-with-parameters.ts deleted file mode 100644 index 64740a26bfd..00000000000 --- a/modules/carto/src/api/request-with-parameters.ts +++ /dev/null @@ -1,121 +0,0 @@ -// deck.gl -// SPDX-License-Identifier: MIT -// Copyright (c) vis.gl contributors - -import {VERSION} from '@deck.gl/core'; -import {isPureObject} from '../utils'; -import {CartoAPIError} from './carto-api-error'; -import {DEFAULT_MAX_LENGTH_URL, V3_MINOR_VERSION} from './common'; -import type {APIErrorContext} from './types'; - -/** - * Parameters added to all requests issued with `requestWithParameters()`. - * These parameters override parameters already in the base URL, but not - * user-provided parameters. - */ -const DEFAULT_PARAMETERS = { - v: V3_MINOR_VERSION, - deckglVersion: VERSION -}; - -const DEFAULT_HEADERS = { - Accept: 'application/json', - 'Content-Type': 'application/json' -}; - -const REQUEST_CACHE = new Map>(); - -export async function requestWithParameters({ - baseUrl, - parameters = {}, - headers: customHeaders = {}, - errorContext, - maxLengthURL = DEFAULT_MAX_LENGTH_URL -}: { - baseUrl: string; - parameters?: Record; - headers?: Record; - errorContext: APIErrorContext; - maxLengthURL?: number; -}): Promise { - parameters = {...DEFAULT_PARAMETERS, ...parameters}; - baseUrl = excludeURLParameters(baseUrl, Object.keys(parameters)); - const key = createCacheKey(baseUrl, parameters, customHeaders); - if (REQUEST_CACHE.has(key)) { - return REQUEST_CACHE.get(key) as Promise; - } - - const url = createURLWithParameters(baseUrl, parameters); - const headers = {...DEFAULT_HEADERS, ...customHeaders}; - - /* global fetch */ - const fetchPromise = - url.length > maxLengthURL - ? fetch(baseUrl, {method: 'POST', body: JSON.stringify(parameters), headers}) - : fetch(url, {headers}); - - let response: Response | undefined; - let responseJson; - const jsonPromise: Promise = fetchPromise - .then((_response: Response) => { - response = _response; - return response.json(); - }) - .then((json: any) => { - responseJson = json; - if (!response || !response.ok) { - throw new Error(json.error); - } - return json; - }) - .catch((error: Error) => { - REQUEST_CACHE.delete(key); - throw new CartoAPIError(error, errorContext, response, responseJson); - }); - - REQUEST_CACHE.set(key, jsonPromise); - return jsonPromise; -} - -function createCacheKey( - baseUrl: string, - parameters: Record, - headers: Record -): string { - const parameterEntries = Object.entries(parameters).sort(([a], [b]) => (a > b ? 1 : -1)); - const headerEntries = Object.entries(headers).sort(([a], [b]) => (a > b ? 1 : -1)); - return JSON.stringify({baseUrl, parameters: parameterEntries, headers: headerEntries}); -} - -/** - * Appends query string parameters to a URL. Existing URL parameters are kept, - * unless there is a conflict, in which case the new parameters override - * those already in the URL. - */ -function createURLWithParameters( - baseUrlString: string, - parameters: Record -): string { - const baseUrl = new URL(baseUrlString); - for (const [key, value] of Object.entries(parameters)) { - if (isPureObject(value) || Array.isArray(value)) { - baseUrl.searchParams.set(key, JSON.stringify(value)); - } else { - baseUrl.searchParams.set(key, (value as string | boolean | number).toString()); - } - } - return baseUrl.toString(); -} - -/** - * Deletes query string parameters from a URL. - */ -function excludeURLParameters(baseUrlString: string, parameters: string[]) { - const baseUrl = new URL(baseUrlString); - for (const param of parameters) { - if (baseUrl.searchParams.has(param)) { - baseUrl.searchParams.delete(param); - } - } - return baseUrl.toString(); -} diff --git a/modules/carto/src/api/types.ts b/modules/carto/src/api/types.ts index b06a3f2f7df..94be57f43b9 100644 --- a/modules/carto/src/api/types.ts +++ b/modules/carto/src/api/types.ts @@ -4,87 +4,12 @@ import {SCALE_TYPE} from './layer-map'; -export type Format = 'json' | 'geojson' | 'tilejson'; -export type MapType = 'boundary' | 'query' | 'table' | 'tileset' | 'raster'; -export type RequestType = - | 'Map data' - | 'Map instantiation' - | 'Public map' - | 'Tile stats' - | 'SQL' - | 'Basemap style'; - -export type APIErrorContext = { - requestType: RequestType; - mapId?: string; - connection?: string; - source?: string; - type?: MapType; -}; - -export enum SchemaFieldType { - Number = 'number', - Bigint = 'bigint', - String = 'string', - Geometry = 'geometry', - Timestamp = 'timestamp', - Object = 'object', - Boolean = 'boolean', - Variant = 'variant', - Unknown = 'unknown' -} -export interface SchemaField { - name: string; - type: SchemaFieldType; // Field type in the CARTO stack, common for all providers -} - -export interface MapInstantiation extends MapInstantiationFormats { - nrows: number; - size?: number; - schema: SchemaField[]; -} - -type MapInstantiationFormats = Record< - Format, - { - url: string[]; - error?: any; - } ->; - -export type QueryParameterValue = string | number | boolean | Array | object; - -export type NamedQueryParameter = Record; - -export type PositionalQueryParameter = QueryParameterValue[]; - -export type QueryParameters = NamedQueryParameter | PositionalQueryParameter; export type VisualChannelField = { name: string; type: string; colorColumn?: string; }; -export interface Filters { - [column: string]: Filter; -} - -interface Filter { - [FilterTypes.In]?: number[]; - [FilterTypes.Between]?: number[][]; - [FilterTypes.ClosedOpen]?: number[][]; - [FilterTypes.Time]?: number[][]; - [FilterTypes.StringSearch]?: string[]; -} - -export enum FilterTypes { - In = 'in', - Between = 'between', // [a, b] both are included - ClosedOpen = 'closed_open', // [a, b) a is included, b is not - Time = 'time', - StringSearch = 'stringSearch' -} - export type VisualChannels = { colorField?: VisualChannelField; colorScale?: SCALE_TYPE; diff --git a/modules/carto/src/basemap.ts b/modules/carto/src/basemap.ts index cc337ca3666..e6757bbf507 100644 --- a/modules/carto/src/basemap.ts +++ b/modules/carto/src/basemap.ts @@ -2,8 +2,8 @@ // SPDX-License-Identifier: MIT // Copyright (c) vis.gl contributors -import {CartoAPIError} from './api/carto-api-error'; -import {APIErrorContext, GoogleBasemapProps} from './api/types'; +import {CartoAPIError, APIErrorContext} from '@carto/api-client'; +import {GoogleBasemapProps} from './api/types'; const cartoStyleUrlTemplate = 'https://basemaps.cartocdn.com/gl/{basemap}-gl-style/style.json'; diff --git a/modules/carto/src/constants.ts b/modules/carto/src/constants.ts index 9c78a7c8c08..b9b87f54f90 100644 --- a/modules/carto/src/constants.ts +++ b/modules/carto/src/constants.ts @@ -3,7 +3,3 @@ // Copyright (c) vis.gl contributors export const DEFAULT_TILE_SIZE = 512; -export const DEFAULT_TILE_RESOLUTION = 0.5; - -export const DEFAULT_AGGREGATION_RES_LEVEL_H3 = 4; -export const DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN = 6; diff --git a/modules/carto/src/index.ts b/modules/carto/src/index.ts index c0608298c14..6ce3fe0b219 100644 --- a/modules/carto/src/index.ts +++ b/modules/carto/src/index.ts @@ -40,17 +40,11 @@ export { export {default as colorBins} from './style/color-bins-style'; export {default as colorCategories} from './style/color-categories-style'; export {default as colorContinuous} from './style/color-continuous-style'; -export {CartoAPIError, fetchMap, query} from './api/index'; +export {fetchMap} from './api/index'; export {fetchBasemapProps} from './api/basemap'; export type { - APIErrorContext, FetchMapOptions, FetchMapResult, - Format, - MapType, - RequestType, - QueryParameters, - QueryOptions, Basemap as _Basemap, MapLibreBasemap as _MapLibreBasemap, GoogleBasemap as _GoogleBasemap @@ -70,7 +64,7 @@ import { vectorTableSource, vectorTilesetSource, SOURCE_DEFAULTS -} from './sources/index'; +} from '@carto/api-client'; const CARTO_SOURCES = { boundaryQuerySource, @@ -124,4 +118,4 @@ export type { VectorQuerySourceOptions, VectorTableSourceOptions, VectorTilesetSourceOptions -} from './sources/index'; +} from '@carto/api-client'; diff --git a/modules/carto/src/layers/cluster-tile-layer.ts b/modules/carto/src/layers/cluster-tile-layer.ts index 6f4fea20dfd..49373ecbf08 100644 --- a/modules/carto/src/layers/cluster-tile-layer.ts +++ b/modules/carto/src/layers/cluster-tile-layer.ts @@ -39,7 +39,7 @@ import QuadbinTileset2D from './quadbin-tileset-2d'; import {getQuadbinPolygon} from './quadbin-utils'; import CartoSpatialTileLoader from './schema/carto-spatial-tile-loader'; import {injectAccessToken, TilejsonPropType} from './utils'; -import type {TilejsonResult} from '../sources/types'; +import type {TilejsonResult} from '@carto/api-client'; registerLoaders([CartoSpatialTileLoader]); @@ -118,6 +118,7 @@ class ClusterGeoJsonLayer< this.state.aggregationCache = new WeakMap(); } + // eslint-disable-next-line max-statements renderLayers(): Layer | null | LayersList { const visibleTiles = this.state.tileset?.tiles.filter((tile: Tile2DHeader) => { return tile.isLoaded && tile.content && this.state.tileset!.isTileVisible(tile); diff --git a/modules/carto/src/layers/h3-tile-layer.ts b/modules/carto/src/layers/h3-tile-layer.ts index 1819f8e1339..51f3a83d4b4 100644 --- a/modules/carto/src/layers/h3-tile-layer.ts +++ b/modules/carto/src/layers/h3-tile-layer.ts @@ -6,7 +6,7 @@ import {CompositeLayer, CompositeLayerProps, Layer, LayersList, DefaultProps} fr import {H3HexagonLayer, H3HexagonLayerProps} from '@deck.gl/geo-layers'; import H3Tileset2D, {getHexagonResolution} from './h3-tileset-2d'; import SpatialIndexTileLayer, {SpatialIndexTileLayerProps} from './spatial-index-tile-layer'; -import type {TilejsonResult} from '../sources/types'; +import type {TilejsonResult} from '@carto/api-client'; import {injectAccessToken, TilejsonPropType} from './utils'; import {DEFAULT_TILE_SIZE} from '../constants'; diff --git a/modules/carto/src/layers/heatmap-tile-layer.ts b/modules/carto/src/layers/heatmap-tile-layer.ts index 86727e49f9f..037ca531757 100644 --- a/modules/carto/src/layers/heatmap-tile-layer.ts +++ b/modules/carto/src/layers/heatmap-tile-layer.ts @@ -20,7 +20,7 @@ import {HeatmapProps, heatmap} from './heatmap'; import {RTTModifier, PostProcessModifier} from './post-process-utils'; import QuadbinTileLayer, {QuadbinTileLayerProps} from './quadbin-tile-layer'; import {TilejsonPropType} from './utils'; -import {TilejsonResult} from '../sources'; +import {TilejsonResult} from '@carto/api-client'; import {_Tile2DHeader as Tile2DHeader} from '@deck.gl/geo-layers'; import {Texture, TextureProps} from '@luma.gl/core'; @@ -96,7 +96,7 @@ class RTTSolidPolygonLayer extends RTTModifier(SolidPolygonLayer) { float weight = elevations; // Keep "power" delivered to screen constant when tiles update - // by outputting normalized density + // by outputting normalized density weight *= density.factor; // Pack float into 3 channels to pass to heatmap shader diff --git a/modules/carto/src/layers/quadbin-tile-layer.ts b/modules/carto/src/layers/quadbin-tile-layer.ts index 9cefc57cd5c..09969532a8e 100644 --- a/modules/carto/src/layers/quadbin-tile-layer.ts +++ b/modules/carto/src/layers/quadbin-tile-layer.ts @@ -7,7 +7,7 @@ import QuadbinLayer, {QuadbinLayerProps} from './quadbin-layer'; import QuadbinTileset2D from './quadbin-tileset-2d'; import SpatialIndexTileLayer, {SpatialIndexTileLayerProps} from './spatial-index-tile-layer'; import {hexToBigInt} from 'quadbin'; -import type {TilejsonResult} from '../sources/types'; +import type {TilejsonResult} from '@carto/api-client'; import {injectAccessToken, TilejsonPropType} from './utils'; import {DEFAULT_TILE_SIZE} from '../constants'; diff --git a/modules/carto/src/layers/raster-tile-layer.ts b/modules/carto/src/layers/raster-tile-layer.ts index 463e33ba4f0..6787789ab9a 100644 --- a/modules/carto/src/layers/raster-tile-layer.ts +++ b/modules/carto/src/layers/raster-tile-layer.ts @@ -5,7 +5,7 @@ import {CompositeLayer, CompositeLayerProps, DefaultProps, Layer, LayersList} from '@deck.gl/core'; import RasterLayer, {RasterLayerProps} from './raster-layer'; import QuadbinTileset2D from './quadbin-tileset-2d'; -import type {TilejsonResult} from '../sources/types'; +import type {TilejsonResult} from '@carto/api-client'; import {injectAccessToken, TilejsonPropType} from './utils'; import {DEFAULT_TILE_SIZE} from '../constants'; import {TileLayer, TileLayerProps} from '@deck.gl/geo-layers'; diff --git a/modules/carto/src/layers/utils.ts b/modules/carto/src/layers/utils.ts index e308834c33a..6be8f2f59a2 100644 --- a/modules/carto/src/layers/utils.ts +++ b/modules/carto/src/layers/utils.ts @@ -6,7 +6,7 @@ import {log} from '@deck.gl/core'; import {Tile as PropertiesTile} from './schema/carto-properties-tile'; import {Tile as VectorTile} from './schema/carto-tile'; import {_deepEqual as deepEqual} from '@deck.gl/core'; -import type {TilejsonResult} from '../sources/types'; +import type {TilejsonResult} from '@carto/api-client'; /** * Adds access token to Authorization header in loadOptions diff --git a/modules/carto/src/layers/vector-tile-layer.ts b/modules/carto/src/layers/vector-tile-layer.ts index 76f09a631ab..92a0e99c138 100644 --- a/modules/carto/src/layers/vector-tile-layer.ts +++ b/modules/carto/src/layers/vector-tile-layer.ts @@ -19,7 +19,7 @@ import { } from '@deck.gl/geo-layers'; import {GeoJsonLayer} from '@deck.gl/layers'; -import type {TilejsonResult} from '../sources/types'; +import type {TilejsonResult} from '@carto/api-client'; import {TilejsonPropType, injectAccessToken, mergeBoundaryData} from './utils'; import {DEFAULT_TILE_SIZE} from '../constants'; diff --git a/modules/carto/src/sources/base-source.ts b/modules/carto/src/sources/base-source.ts deleted file mode 100644 index 41b7fa1bea3..00000000000 --- a/modules/carto/src/sources/base-source.ts +++ /dev/null @@ -1,83 +0,0 @@ -// deck.gl -// SPDX-License-Identifier: MIT -// Copyright (c) vis.gl contributors - -/* eslint-disable camelcase */ -import {DEFAULT_API_BASE_URL, DEFAULT_CLIENT, DEFAULT_MAX_LENGTH_URL} from '../api/common'; -import {buildSourceUrl} from '../api/endpoints'; -import {requestWithParameters} from '../api/request-with-parameters'; -import type {APIErrorContext, MapType} from '../api/types'; -import type { - GeojsonResult, - JsonResult, - SourceOptionalOptions, - SourceRequiredOptions, - TilejsonMapInstantiation, - TilejsonResult -} from './types'; - -export const SOURCE_DEFAULTS: SourceOptionalOptions = { - apiBaseUrl: DEFAULT_API_BASE_URL, - clientId: DEFAULT_CLIENT, - format: 'tilejson', - headers: {}, - maxLengthURL: DEFAULT_MAX_LENGTH_URL -}; - -export async function baseSource>( - endpoint: MapType, - options: Partial & SourceRequiredOptions, - urlParameters: UrlParameters -): Promise { - const {accessToken, connectionName, cache, ...optionalOptions} = options; - const mergedOptions = {...SOURCE_DEFAULTS, accessToken, connectionName, endpoint}; - for (const key in optionalOptions) { - if (optionalOptions[key]) { - mergedOptions[key] = optionalOptions[key]; - } - } - const baseUrl = buildSourceUrl(mergedOptions); - const {clientId, maxLengthURL, format} = mergedOptions; - const headers = {Authorization: `Bearer ${options.accessToken}`, ...options.headers}; - const parameters = {client: clientId, ...urlParameters}; - - const errorContext: APIErrorContext = { - requestType: 'Map instantiation', - connection: options.connectionName, - type: endpoint, - source: JSON.stringify(parameters, undefined, 2) - }; - const mapInstantiation = await requestWithParameters({ - baseUrl, - parameters, - headers, - errorContext, - maxLengthURL - }); - - const dataUrl = mapInstantiation[format].url[0]; - if (cache) { - cache.value = parseInt(new URL(dataUrl).searchParams.get('cache') || '', 10); - } - errorContext.requestType = 'Map data'; - - if (format === 'tilejson') { - const json = await requestWithParameters({ - baseUrl: dataUrl, - headers, - errorContext, - maxLengthURL - }); - if (accessToken) { - json.accessToken = accessToken; - } - return json; - } - - return await requestWithParameters({ - baseUrl: dataUrl, - headers, - errorContext, - maxLengthURL - }); -} diff --git a/modules/carto/src/sources/boundary-query-source.ts b/modules/carto/src/sources/boundary-query-source.ts deleted file mode 100644 index 3b64a93626d..00000000000 --- a/modules/carto/src/sources/boundary-query-source.ts +++ /dev/null @@ -1,43 +0,0 @@ -// deck.gl -// SPDX-License-Identifier: MIT -// Copyright (c) vis.gl contributors - -import {QueryParameters} from '../api/index'; -import {baseSource} from './base-source'; -import type {FilterOptions, SourceOptions, TilejsonResult} from './types'; - -export type BoundaryQuerySourceOptions = SourceOptions & - FilterOptions & { - columns?: string[]; - tilesetTableName: string; - propertiesSqlQuery: string; - queryParameters?: QueryParameters; - }; -type UrlParameters = { - columns?: string; - filters?: Record; - tilesetTableName: string; - propertiesSqlQuery: string; - queryParameters?: Record | unknown[]; -}; - -export const boundaryQuerySource = async function ( - options: BoundaryQuerySourceOptions -): Promise { - const {columns, filters, tilesetTableName, propertiesSqlQuery, queryParameters} = options; - const urlParameters: UrlParameters = { - tilesetTableName, - propertiesSqlQuery - }; - - if (columns) { - urlParameters.columns = columns.join(','); - } - if (filters) { - urlParameters.filters = filters; - } - if (queryParameters) { - urlParameters.queryParameters = queryParameters; - } - return baseSource('boundary', options, urlParameters) as Promise; -}; diff --git a/modules/carto/src/sources/boundary-table-source.ts b/modules/carto/src/sources/boundary-table-source.ts deleted file mode 100644 index 68d93d352f2..00000000000 --- a/modules/carto/src/sources/boundary-table-source.ts +++ /dev/null @@ -1,37 +0,0 @@ -// deck.gl -// SPDX-License-Identifier: MIT -// Copyright (c) vis.gl contributors - -import {baseSource} from './base-source'; -import type {FilterOptions, SourceOptions, TilejsonResult} from './types'; - -export type BoundaryTableSourceOptions = SourceOptions & - FilterOptions & { - tilesetTableName: string; - columns?: string[]; - propertiesTableName: string; - }; -type UrlParameters = { - filters?: Record; - tilesetTableName: string; - columns?: string; - propertiesTableName: string; -}; - -export const boundaryTableSource = async function ( - options: BoundaryTableSourceOptions -): Promise { - const {filters, tilesetTableName, columns, propertiesTableName} = options; - const urlParameters: UrlParameters = { - tilesetTableName, - propertiesTableName - }; - - if (columns) { - urlParameters.columns = columns.join(','); - } - if (filters) { - urlParameters.filters = filters; - } - return baseSource('boundary', options, urlParameters) as Promise; -}; diff --git a/modules/carto/src/sources/h3-query-source.ts b/modules/carto/src/sources/h3-query-source.ts deleted file mode 100644 index 0a82487562c..00000000000 --- a/modules/carto/src/sources/h3-query-source.ts +++ /dev/null @@ -1,59 +0,0 @@ -// deck.gl -// SPDX-License-Identifier: MIT -// Copyright (c) vis.gl contributors - -/* eslint-disable camelcase */ -import {DEFAULT_AGGREGATION_RES_LEVEL_H3} from '../constants'; -import {baseSource} from './base-source'; -import type { - AggregationOptions, - FilterOptions, - QuerySourceOptions, - SourceOptions, - SpatialDataType, - TilejsonResult -} from './types'; - -export type H3QuerySourceOptions = SourceOptions & - QuerySourceOptions & - AggregationOptions & - FilterOptions; -type UrlParameters = { - aggregationExp: string; - aggregationResLevel?: string; - spatialDataType: SpatialDataType; - spatialDataColumn?: string; - q: string; - queryParameters?: Record | unknown[]; - filters?: Record; -}; - -export const h3QuerySource = async function ( - options: H3QuerySourceOptions -): Promise { - const { - aggregationExp, - aggregationResLevel = DEFAULT_AGGREGATION_RES_LEVEL_H3, - sqlQuery, - spatialDataColumn = 'h3', - queryParameters, - filters - } = options; - const urlParameters: UrlParameters = { - aggregationExp, - spatialDataColumn, - spatialDataType: 'h3', - q: sqlQuery - }; - - if (aggregationResLevel) { - urlParameters.aggregationResLevel = String(aggregationResLevel); - } - if (queryParameters) { - urlParameters.queryParameters = queryParameters; - } - if (filters) { - urlParameters.filters = filters; - } - return baseSource('query', options, urlParameters) as Promise; -}; diff --git a/modules/carto/src/sources/h3-table-source.ts b/modules/carto/src/sources/h3-table-source.ts deleted file mode 100644 index 652964a4b64..00000000000 --- a/modules/carto/src/sources/h3-table-source.ts +++ /dev/null @@ -1,55 +0,0 @@ -// deck.gl -// SPDX-License-Identifier: MIT -// Copyright (c) vis.gl contributors - -/* eslint-disable camelcase */ -import {DEFAULT_AGGREGATION_RES_LEVEL_H3} from '../constants'; -import {baseSource} from './base-source'; -import type { - AggregationOptions, - FilterOptions, - SourceOptions, - SpatialDataType, - TableSourceOptions, - TilejsonResult -} from './types'; - -export type H3TableSourceOptions = SourceOptions & - TableSourceOptions & - AggregationOptions & - FilterOptions; - -type UrlParameters = { - aggregationExp: string; - aggregationResLevel?: string; - spatialDataType: SpatialDataType; - spatialDataColumn?: string; - name: string; - filters?: Record; -}; - -export const h3TableSource = async function ( - options: H3TableSourceOptions -): Promise { - const { - aggregationExp, - aggregationResLevel = DEFAULT_AGGREGATION_RES_LEVEL_H3, - spatialDataColumn = 'h3', - tableName, - filters - } = options; - const urlParameters: UrlParameters = { - aggregationExp, - name: tableName, - spatialDataColumn, - spatialDataType: 'h3' - }; - - if (aggregationResLevel) { - urlParameters.aggregationResLevel = String(aggregationResLevel); - } - if (filters) { - urlParameters.filters = filters; - } - return baseSource('table', options, urlParameters) as Promise; -}; diff --git a/modules/carto/src/sources/h3-tileset-source.ts b/modules/carto/src/sources/h3-tileset-source.ts deleted file mode 100644 index aae9b8e9b42..00000000000 --- a/modules/carto/src/sources/h3-tileset-source.ts +++ /dev/null @@ -1,18 +0,0 @@ -// deck.gl -// SPDX-License-Identifier: MIT -// Copyright (c) vis.gl contributors - -import {baseSource} from './base-source'; -import type {SourceOptions, TilejsonResult, TilesetSourceOptions} from './types'; - -export type H3TilesetSourceOptions = SourceOptions & TilesetSourceOptions; -type UrlParameters = {name: string}; - -export const h3TilesetSource = async function ( - options: H3TilesetSourceOptions -): Promise { - const {tableName} = options; - const urlParameters: UrlParameters = {name: tableName}; - - return baseSource('tileset', options, urlParameters) as Promise; -}; diff --git a/modules/carto/src/sources/index.ts b/modules/carto/src/sources/index.ts deleted file mode 100644 index 565080ab3b6..00000000000 --- a/modules/carto/src/sources/index.ts +++ /dev/null @@ -1,49 +0,0 @@ -// deck.gl -// SPDX-License-Identifier: MIT -// Copyright (c) vis.gl contributors - -export {SOURCE_DEFAULTS} from './base-source'; -export type {TilejsonResult, GeojsonResult, JsonResult} from './types'; - -export {boundaryQuerySource} from './boundary-query-source'; -export type {BoundaryQuerySourceOptions} from './boundary-query-source'; - -export {boundaryTableSource} from './boundary-table-source'; -export type {BoundaryTableSourceOptions} from './boundary-table-source'; - -export {h3QuerySource} from './h3-query-source'; -export type {H3QuerySourceOptions} from './h3-query-source'; - -export {h3TableSource} from './h3-table-source'; -export type {H3TableSourceOptions} from './h3-table-source'; - -export {h3TilesetSource} from './h3-tileset-source'; -export type {H3TilesetSourceOptions} from './h3-tileset-source'; - -export {rasterSource} from './raster-source'; -export type {RasterSourceOptions} from './raster-source'; - -export {quadbinQuerySource} from './quadbin-query-source'; -export type {QuadbinQuerySourceOptions} from './quadbin-query-source'; - -export {quadbinTableSource} from './quadbin-table-source'; -export type {QuadbinTableSourceOptions} from './quadbin-table-source'; - -export {quadbinTilesetSource} from './quadbin-tileset-source'; -export type {QuadbinTilesetSourceOptions} from './quadbin-tileset-source'; - -export {vectorQuerySource} from './vector-query-source'; -export type {VectorQuerySourceOptions} from './vector-query-source'; - -export {vectorTableSource} from './vector-table-source'; -export type {VectorTableSourceOptions} from './vector-table-source'; - -export {vectorTilesetSource} from './vector-tileset-source'; -export type {VectorTilesetSourceOptions} from './vector-tileset-source'; - -export type { - SourceOptions, - QuerySourceOptions, - TableSourceOptions, - TilesetSourceOptions -} from './types'; diff --git a/modules/carto/src/sources/quadbin-query-source.ts b/modules/carto/src/sources/quadbin-query-source.ts deleted file mode 100644 index e7de09d29bb..00000000000 --- a/modules/carto/src/sources/quadbin-query-source.ts +++ /dev/null @@ -1,60 +0,0 @@ -// deck.gl -// SPDX-License-Identifier: MIT -// Copyright (c) vis.gl contributors - -/* eslint-disable camelcase */ -import {DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN} from '../constants'; -import {baseSource} from './base-source'; -import type { - AggregationOptions, - FilterOptions, - QuerySourceOptions, - SourceOptions, - SpatialDataType, - TilejsonResult -} from './types'; - -export type QuadbinQuerySourceOptions = SourceOptions & - QuerySourceOptions & - AggregationOptions & - FilterOptions; - -type UrlParameters = { - aggregationExp: string; - aggregationResLevel?: string; - spatialDataType: SpatialDataType; - spatialDataColumn?: string; - q: string; - queryParameters?: Record | unknown[]; - filters?: Record; -}; - -export const quadbinQuerySource = async function ( - options: QuadbinQuerySourceOptions -): Promise { - const { - aggregationExp, - aggregationResLevel = DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN, - sqlQuery, - spatialDataColumn = 'quadbin', - queryParameters, - filters - } = options; - const urlParameters: UrlParameters = { - aggregationExp, - q: sqlQuery, - spatialDataColumn, - spatialDataType: 'quadbin' - }; - - if (aggregationResLevel) { - urlParameters.aggregationResLevel = String(aggregationResLevel); - } - if (queryParameters) { - urlParameters.queryParameters = queryParameters; - } - if (filters) { - urlParameters.filters = filters; - } - return baseSource('query', options, urlParameters) as Promise; -}; diff --git a/modules/carto/src/sources/quadbin-table-source.ts b/modules/carto/src/sources/quadbin-table-source.ts deleted file mode 100644 index 60268c2d814..00000000000 --- a/modules/carto/src/sources/quadbin-table-source.ts +++ /dev/null @@ -1,56 +0,0 @@ -// deck.gl -// SPDX-License-Identifier: MIT -// Copyright (c) vis.gl contributors - -/* eslint-disable camelcase */ -import {DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN} from '../constants'; -import {baseSource} from './base-source'; -import type { - AggregationOptions, - FilterOptions, - SourceOptions, - SpatialDataType, - TableSourceOptions, - TilejsonResult -} from './types'; - -export type QuadbinTableSourceOptions = SourceOptions & - TableSourceOptions & - AggregationOptions & - FilterOptions; - -type UrlParameters = { - aggregationExp: string; - aggregationResLevel?: string; - spatialDataType: SpatialDataType; - spatialDataColumn?: string; - name: string; - filters?: Record; -}; - -export const quadbinTableSource = async function ( - options: QuadbinTableSourceOptions -): Promise { - const { - aggregationExp, - aggregationResLevel = DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN, - spatialDataColumn = 'quadbin', - tableName, - filters - } = options; - - const urlParameters: UrlParameters = { - aggregationExp, - name: tableName, - spatialDataColumn, - spatialDataType: 'quadbin' - }; - - if (aggregationResLevel) { - urlParameters.aggregationResLevel = String(aggregationResLevel); - } - if (filters) { - urlParameters.filters = filters; - } - return baseSource('table', options, urlParameters) as Promise; -}; diff --git a/modules/carto/src/sources/quadbin-tileset-source.ts b/modules/carto/src/sources/quadbin-tileset-source.ts deleted file mode 100644 index 8364719d0f8..00000000000 --- a/modules/carto/src/sources/quadbin-tileset-source.ts +++ /dev/null @@ -1,18 +0,0 @@ -// deck.gl -// SPDX-License-Identifier: MIT -// Copyright (c) vis.gl contributors - -import {baseSource} from './base-source'; -import type {SourceOptions, TilejsonResult, TilesetSourceOptions} from './types'; - -export type QuadbinTilesetSourceOptions = SourceOptions & TilesetSourceOptions; -type UrlParameters = {name: string}; - -export const quadbinTilesetSource = async function ( - options: QuadbinTilesetSourceOptions -): Promise { - const {tableName} = options; - const urlParameters: UrlParameters = {name: tableName}; - - return baseSource('tileset', options, urlParameters) as Promise; -}; diff --git a/modules/carto/src/sources/raster-source.ts b/modules/carto/src/sources/raster-source.ts deleted file mode 100644 index a682b41e1eb..00000000000 --- a/modules/carto/src/sources/raster-source.ts +++ /dev/null @@ -1,21 +0,0 @@ -// deck.gl -// SPDX-License-Identifier: MIT -// Copyright (c) vis.gl contributors - -import {baseSource} from './base-source'; -import type {FilterOptions, SourceOptions, TilejsonResult, TilesetSourceOptions} from './types'; - -export type RasterSourceOptions = SourceOptions & TilesetSourceOptions & FilterOptions; -type UrlParameters = { - name: string; - filters?: Record; -}; - -export const rasterSource = async function (options: RasterSourceOptions): Promise { - const {tableName, filters} = options; - const urlParameters: UrlParameters = {name: tableName}; - if (filters) { - urlParameters.filters = filters; - } - return baseSource('raster', options, urlParameters) as Promise; -}; diff --git a/modules/carto/src/sources/types.ts b/modules/carto/src/sources/types.ts deleted file mode 100644 index 0b8d51760dc..00000000000 --- a/modules/carto/src/sources/types.ts +++ /dev/null @@ -1,235 +0,0 @@ -// deck.gl -// SPDX-License-Identifier: MIT -// Copyright (c) vis.gl contributors - -import type {Feature} from 'geojson'; -import type {Filters, Format, MapInstantiation, QueryParameters} from '../api/types'; - -export type SourceRequiredOptions = { - /** Carto platform access token. */ - accessToken: string; - - /** Data warehouse connection name in Carto platform. */ - connectionName: string; -}; - -export type SourceOptionalOptions = { - /** - * Base URL of the CARTO Maps API. - * - * Example for account located in EU-west region: `https://gcp-eu-west1.api.carto.com` - * - * @default https://gcp-us-east1.api.carto.com - */ - apiBaseUrl: string; - - /** - * Custom HTTP headers added to map instantiation and data requests. - */ - headers: Record; - - /** - * Cache buster value returned by map instantiation. - * - * Carto source saves `cache` value of map instantiation response in `cache.value`, so it can be used to - * check if underlying map data has changed between distinct source requests. - */ - cache?: {value?: number}; - - clientId: string; - /** @deprecated use `query` instead **/ - format: Format; - - /** - * Maximum URL character length. Above this limit, requests use POST. - * Used to avoid browser and CDN limits. - * @default {@link DEFAULT_MAX_LENGTH_URL} - */ - maxLengthURL?: number; -}; - -export type SourceOptions = SourceRequiredOptions & Partial; - -export type AggregationOptions = { - /** - * Defines the aggregation expressions that will be calculated from the resulting columns on each grid cell. - * - * Example: - * - * sum(pop) as total_population, avg(rev) as average_revenue - */ - aggregationExp: string; - - /** - * Defines the tile aggregation resolution. - * - * @default 6 for quadbin and 4 for h3 sources - */ - aggregationResLevel?: number; -}; - -export type FilterOptions = { - /** - * Filters to apply to the data source on the server - */ - filters?: Filters; -}; - -export type QuerySourceOptions = { - /** - * The column name and the type of geospatial support. - * - * If not present, defaults to `'geom'` for generic queries, `'quadbin'` for Quadbin sources and `'h3'` for H3 sources. - */ - spatialDataColumn?: string; - - /** SQL query. */ - sqlQuery: string; - - /** - * Relative resolution of a tile. Higher values increase density and data size. At `tileResolution = 1`, tile geometry is - * quantized to a 1024x1024 grid. Increasing or decreasing the resolution will increase or decrease the dimensions of - * the quantization grid proportionately. - * - * Supported `tileResolution` values, with corresponding grid sizes: - * - * - 0.25: 256x256 - * - 0.5: 512x512 - * - 1: 1024x1024 - * - 2: 2048x2048 - * - 4: 4096x4096 - */ - tileResolution?: TileResolution; - - /** - * Values for named or positional paramteres in the query. - * - * The way query parameters are determined by data warehouse. - * - * * BigQuery has named query parameters, specified with a dictionary, and referenced by key (`@key`) - * - * ``` - * sqlQuery: "SELECT * FROM carto-demo-data.demo_tables.retail_stores WHERE storetype = ⁣@type AND revenue > ⁣@minRevenue" - * queryParameters: { type: 'Supermarket', minRevenue: 1000000 } - * ``` - * * Snowflake supports positional parameters, in the form `:1`, `:2`, etc. - * - * ``` - * sqlQuery: "SELECT * FROM demo_db.public.import_retail_stores WHERE storetype = :2 AND revenue > :1 - * queryParameters: [100000, "Supermarket"] - * ``` - * * Postgres and Redhisft supports positional parameters, but in the form `$1`, `$2`, etc. - * - * ``` - * sqlQuery: "SELECT * FROM carto_demo_data.demo_tables.retail_stores WHERE storetype = $2 AND revenue > $1 - * queryParameters: [100000, "Supermarket"] - * ``` - */ - queryParameters?: QueryParameters; -}; - -export type TableSourceOptions = { - /** - * Fully qualified name of table. - */ - tableName: string; - - /** - * The column name and the type of geospatial support. - * - * If not present, defaults to `'geom'` for generic tables, `'quadbin'` for Quadbin sources and `'h3'` for H3 sources. - */ - spatialDataColumn?: string; - - /** - * Relative resolution of a tile. Higher values increase density and data size. At `tileResolution = 1`, tile geometry is - * quantized to a 1024x1024 grid. Increasing or decreasing the resolution will increase or decrease the dimensions of - * the quantization grid proportionately. - * - * Supported `tileResolution` values, with corresponding grid sizes: - * - * - 0.25: 256x256 - * - 0.5: 512x512 - * - 1: 1024x1024 - * - 2: 2048x2048 - * - 4: 4096x4096 - */ - tileResolution?: TileResolution; -}; - -export type TilesetSourceOptions = { - /** - * Fully qualified name of tileset. - */ - tableName: string; -}; - -export type ColumnsOption = { - /** - * Columns to retrieve from the table. - * - * If not present, all columns are returned. - */ - columns?: string[]; -}; - -export type SpatialDataType = 'geo' | 'h3' | 'quadbin'; - -export type TilejsonMapInstantiation = MapInstantiation & { - tilejson: {url: string[]}; -}; - -export type TileResolution = 0.25 | 0.5 | 1 | 2 | 4; - -export interface Tilejson { - tilejson: string; - name: string; - description: string; - version: string; - attribution: string; - scheme: string; - tiles: string[]; - properties_tiles: string[]; - minresolution: number; - maxresolution: number; - minzoom: number; - maxzoom: number; - bounds: [number, number, number, number]; - center: [number, number, number]; - vector_layers: VectorLayer[]; - tilestats: Tilestats; - tileResolution?: TileResolution; -} - -export interface Tilestats { - layerCount: number; - layers: Layer[]; -} - -export interface Layer { - layer: string; - count: number; - attributeCount: number; - attributes: Attribute[]; -} - -export interface Attribute { - attribute: string; - type: string; -} - -export interface VectorLayer { - id: string; - minzoom: number; - maxzoom: number; - fields: Record; -} - -export type TilejsonResult = Tilejson & {accessToken: string}; -export type GeojsonResult = {type: 'FeatureCollection'; features: Feature[]}; -export type JsonResult = any[]; -export type QueryResult = { - meta: {cacheHit: boolean; location: string; totalBytesProcessed: string}; - rows: Record[]; - schema: {name: string; type: string}[]; -}; diff --git a/modules/carto/src/sources/vector-query-source.ts b/modules/carto/src/sources/vector-query-source.ts deleted file mode 100644 index 62d890e8bef..00000000000 --- a/modules/carto/src/sources/vector-query-source.ts +++ /dev/null @@ -1,61 +0,0 @@ -// deck.gl -// SPDX-License-Identifier: MIT -// Copyright (c) vis.gl contributors - -/* eslint-disable camelcase */ -import {DEFAULT_TILE_RESOLUTION} from '../constants'; -import {baseSource} from './base-source'; -import type { - FilterOptions, - SourceOptions, - QuerySourceOptions, - SpatialDataType, - TilejsonResult, - ColumnsOption -} from './types'; - -export type VectorQuerySourceOptions = SourceOptions & - QuerySourceOptions & - FilterOptions & - ColumnsOption; - -type UrlParameters = { - columns?: string; - filters?: Record; - spatialDataType: SpatialDataType; - spatialDataColumn?: string; - tileResolution?: string; - q: string; - queryParameters?: Record | unknown[]; -}; - -export const vectorQuerySource = async function ( - options: VectorQuerySourceOptions -): Promise { - const { - columns, - filters, - spatialDataColumn = 'geom', - sqlQuery, - tileResolution = DEFAULT_TILE_RESOLUTION, - queryParameters - } = options; - - const urlParameters: UrlParameters = { - spatialDataColumn, - spatialDataType: 'geo', - tileResolution: tileResolution.toString(), - q: sqlQuery - }; - - if (columns) { - urlParameters.columns = columns.join(','); - } - if (filters) { - urlParameters.filters = filters; - } - if (queryParameters) { - urlParameters.queryParameters = queryParameters; - } - return baseSource('query', options, urlParameters) as Promise; -}; diff --git a/modules/carto/src/sources/vector-table-source.ts b/modules/carto/src/sources/vector-table-source.ts deleted file mode 100644 index 814f23bba95..00000000000 --- a/modules/carto/src/sources/vector-table-source.ts +++ /dev/null @@ -1,55 +0,0 @@ -// deck.gl -// SPDX-License-Identifier: MIT -// Copyright (c) vis.gl contributors - -/* eslint-disable camelcase */ -import {DEFAULT_TILE_RESOLUTION} from '../constants'; -import {baseSource} from './base-source'; -import type { - FilterOptions, - ColumnsOption, - SourceOptions, - SpatialDataType, - TableSourceOptions, - TilejsonResult -} from './types'; - -export type VectorTableSourceOptions = SourceOptions & - TableSourceOptions & - FilterOptions & - ColumnsOption; -type UrlParameters = { - columns?: string; - filters?: Record; - spatialDataType: SpatialDataType; - spatialDataColumn?: string; - tileResolution?: string; - name: string; -}; - -export const vectorTableSource = async function ( - options: VectorTableSourceOptions -): Promise { - const { - columns, - filters, - spatialDataColumn = 'geom', - tableName, - tileResolution = DEFAULT_TILE_RESOLUTION - } = options; - - const urlParameters: UrlParameters = { - name: tableName, - spatialDataColumn, - spatialDataType: 'geo', - tileResolution: tileResolution.toString() - }; - - if (columns) { - urlParameters.columns = columns.join(','); - } - if (filters) { - urlParameters.filters = filters; - } - return baseSource('table', options, urlParameters) as Promise; -}; diff --git a/modules/carto/src/sources/vector-tileset-source.ts b/modules/carto/src/sources/vector-tileset-source.ts deleted file mode 100644 index 9910aeba9a9..00000000000 --- a/modules/carto/src/sources/vector-tileset-source.ts +++ /dev/null @@ -1,18 +0,0 @@ -// deck.gl -// SPDX-License-Identifier: MIT -// Copyright (c) vis.gl contributors - -import {baseSource} from './base-source'; -import type {SourceOptions, TilesetSourceOptions, TilejsonResult} from './types'; - -export type VectorTilesetSourceOptions = SourceOptions & TilesetSourceOptions; -type UrlParameters = {name: string}; - -export const vectorTilesetSource = async function ( - options: VectorTilesetSourceOptions -): Promise { - const {tableName} = options; - const urlParameters: UrlParameters = {name: tableName}; - - return baseSource('tileset', options, urlParameters) as Promise; -}; diff --git a/test/modules/carto/api/basemap.spec.ts b/test/modules/carto/api/basemap.spec.ts index 4880bc48572..a70eb4dc16d 100644 --- a/test/modules/carto/api/basemap.spec.ts +++ b/test/modules/carto/api/basemap.spec.ts @@ -2,11 +2,12 @@ // SPDX-License-Identifier: MIT // Copyright (c) vis.gl contributors -import {BASEMAP, CartoAPIError, _MapLibreBasemap as MapLibreBasemap} from '@deck.gl/carto'; +import {BASEMAP, _MapLibreBasemap as MapLibreBasemap} from '@deck.gl/carto'; import test from 'tape-catch'; import {withMockFetchMapsV3} from '../mock-fetch'; import {KeplerMapConfig} from '@deck.gl/carto/api/types'; import {fetchBasemapProps} from '@deck.gl/carto'; +import {CartoAPIError} from '@carto/api-client'; const mockedMapConfig: KeplerMapConfig = { mapState: { diff --git a/test/modules/carto/api/carto-api-error.spec.ts b/test/modules/carto/api/carto-api-error.spec.ts deleted file mode 100644 index bd3c4451922..00000000000 --- a/test/modules/carto/api/carto-api-error.spec.ts +++ /dev/null @@ -1,121 +0,0 @@ -// deck.gl -// SPDX-License-Identifier: MIT -// Copyright (c) vis.gl contributors - -import test from 'tape-catch'; - -import {CartoAPIError} from '@deck.gl/carto'; - -[ - { - title: '400 error', - error: new Error('Bad'), - errorContext: {requestType: 'Map data'}, - response: {status: 400}, - message: ` -Map data API request failed -Server returned: Bad request (400): Bad -` - }, - { - title: '401 error', - error: new Error('Unauthorized'), - errorContext: {requestType: 'Map data'}, - response: {status: 401}, - message: ` -Map data API request failed -Server returned: Unauthorized access (401): Unauthorized -` - }, - { - title: '403 error', - error: new Error('Forbidden'), - errorContext: {requestType: 'Map data'}, - response: {status: 403}, - message: ` -Map data API request failed -Server returned: Unauthorized access (403): Forbidden -` - }, - { - title: '404 error', - error: new Error('Not found'), - errorContext: {requestType: 'Map data'}, - response: {status: 404}, - message: ` -Map data API request failed -Server returned: Not found (404): Not found -` - }, - { - title: '500 error', - error: new Error('Source error'), - errorContext: {requestType: 'Map data'}, - response: {status: 500}, - message: ` -Map data API request failed -Server returned: Error (500): Source error -` - }, - { - title: 'Full error context: instantiation', - error: new Error('Source error'), - errorContext: { - requestType: 'Map instantiation', - connection: 'connectionName', - source: 'sourceName', - type: 'query' - }, - response: {status: 500}, - message: ` -Map instantiation API request failed -Server returned: Error (500): Source error -Connection: connectionName -Source: sourceName -Type: query -` - }, - { - title: 'Full error context: public map', - error: new Error('Source error'), - errorContext: { - requestType: 'Public map', - mapId: 'abcd' - }, - response: {status: 500}, - message: ` -Public map API request failed -Server returned: Error (500): Source error -Map Id: abcd -` - }, - { - title: 'Full error context: custom value', - error: new Error('Source error'), - errorContext: { - requestType: 'Tile stats', - connection: 'connectionName', - source: 'sourceName', - type: 'tileset', - customKey: 'customValue' - }, - response: {status: 500}, - message: ` -Tile stats API request failed -Server returned: Error (500): Source error -Connection: connectionName -Source: sourceName -Type: tileset -Custom Key: customValue -` - } -].forEach(({title, error, errorContext, response, message}) => { - test(`CartoAPIError: ${title}`, t => { - const cartoAPIError = new CartoAPIError(error, errorContext, response); - - t.ok(cartoAPIError, 'Error created'); - t.equal(cartoAPIError.message, message.slice(1), 'Correct error message produced'); - - t.end(); - }); -}); diff --git a/test/modules/carto/api/query.spec.ts b/test/modules/carto/api/query.spec.ts deleted file mode 100644 index c051687b7b9..00000000000 --- a/test/modules/carto/api/query.spec.ts +++ /dev/null @@ -1,30 +0,0 @@ -// deck.gl -// SPDX-License-Identifier: MIT -// Copyright (c) vis.gl contributors - -import {query} from '@deck.gl/carto'; -import test from 'tape-catch'; -import {withMockFetchMapsV3, QUERY_RESPONSE} from '../mock-fetch'; - -test('query', async t => { - await withMockFetchMapsV3(async calls => { - const response = await query({ - connectionName: 'carto_dw', - clientId: 'CUSTOM_CLIENT', - accessToken: '', - sqlQuery: 'SELECT * FROM a.b.h3_table' - }); - - t.is(calls.length, 1, 'calls fetch() x1'); - - const [queryCall] = calls; - - t.match(queryCall.url, /v3\/sql\/carto_dw\/query/, 'connection'); - t.match(queryCall.url, /q=SELECT\+\*\+FROM\+a\.b\.h3_table/, 'query'); - t.match(queryCall.url, /client\=CUSTOM_CLIENT/, 'clientId'); - - t.ok(response, 'returns response'); - t.deepEqual(response, QUERY_RESPONSE, 'correct response'); - }).catch(t.fail); - t.end(); -}); diff --git a/test/modules/carto/api/request-with-parameters.spec.ts b/test/modules/carto/api/request-with-parameters.spec.ts deleted file mode 100644 index 84f68ccd207..00000000000 --- a/test/modules/carto/api/request-with-parameters.spec.ts +++ /dev/null @@ -1,231 +0,0 @@ -// deck.gl -// SPDX-License-Identifier: MIT -// Copyright (c) vis.gl contributors - -import test from 'tape-catch'; -import {requestWithParameters} from '@deck.gl/carto/api/request-with-parameters'; -import {V3_MINOR_VERSION} from '@deck.gl/carto/api/common'; -import {withMockFetchMapsV3} from '../mock-fetch'; -import {CartoAPIError} from '@deck.gl/carto'; - -test('requestWithParameters#cacheBaseURL', async t => { - await withMockFetchMapsV3(async calls => { - t.equals(calls.length, 0, '0 initial calls'); - - await Promise.all([ - requestWithParameters({baseUrl: 'https://example.com/v1/baseURL', headers: {}}), - requestWithParameters({baseUrl: 'https://example.com/v2/baseURL', headers: {}}), - requestWithParameters({baseUrl: 'https://example.com/v2/baseURL', headers: {}}) - ]); - - t.equals(calls.length, 2, '2 unique requests'); - }); - t.end(); -}); - -test('requestWithParameters#cacheHeaders', async t => { - await withMockFetchMapsV3(async calls => { - t.equals(calls.length, 0, '0 initial calls'); - - await Promise.all([ - requestWithParameters({baseUrl: 'https://example.com/v1/headers', headers: {a: 1}}), - requestWithParameters({baseUrl: 'https://example.com/v1/headers', headers: {a: 1}}), - requestWithParameters({baseUrl: 'https://example.com/v1/headers', headers: {b: 1}}) - ]); - - t.equals(calls.length, 2, '2 unique requests'); - }); - t.end(); -}); - -test('requestWithParameters#cacheParameters', async t => { - await withMockFetchMapsV3(async calls => { - t.equals(calls.length, 0, '0 initial calls'); - - await Promise.all([ - requestWithParameters({ - baseUrl: 'https://example.com/v1/params', - headers: {}, - parameters: {} - }), - requestWithParameters({ - baseUrl: 'https://example.com/v1/params', - headers: {}, - parameters: {} - }), - requestWithParameters({ - baseUrl: 'https://example.com/v1/params', - headers: {}, - parameters: {a: 1} - }) - ]); - - t.equals(calls.length, 2, '2 unique requests'); - }); - t.end(); -}); - -test('requestWithParameters#nocacheErrorContext', async t => { - await withMockFetchMapsV3( - async calls => { - t.equals(calls.length, 0, '0 initial calls'); - - let error1: Error | undefined; - let error2: Error | undefined; - - try { - await requestWithParameters({ - baseUrl: 'https://example.com/v1/errorContext', - errorContext: {requestType: 'Map data'} - }); - t.fail('request #1 should fail, but did not'); - } catch (error) { - error1 = error as Error; - } - - try { - await requestWithParameters({ - baseUrl: 'https://example.com/v1/errorContext', - errorContext: {requestType: 'SQL'} - }); - t.fail('request #2 should fail, but did not'); - } catch (error) { - error2 = error as Error; - } - - t.deepEquals( - (error1 as CartoAPIError).responseJson, - {error: 'CustomError', customData: {abc: 'def'}}, - 'responseJson', - 'propagates actual JSON error response ' - ); - t.equals(calls.length, 2, '2 unique requests, failures not cached'); - t.true(error1 instanceof CartoAPIError, 'error #1 type'); - t.is((error1 as CartoAPIError).errorContext.requestType, 'Map data', 'error #1 context'); - t.true(error2 instanceof CartoAPIError, 'error #2 type'); - t.is((error2 as CartoAPIError).errorContext.requestType, 'SQL', 'error #2 context'); - }, - // @ts-ignore - (url: string, headers: HeadersInit) => { - return Promise.resolve({ - ok: false, - json: () => Promise.resolve({error: 'CustomError', customData: {abc: 'def'}}) - }); - } - ); - t.end(); -}); - -test('requestWithParameters#method', async t => { - await withMockFetchMapsV3(async calls => { - t.equals(calls.length, 0, '0 initial calls'); - - await Promise.all([ - requestWithParameters({ - baseUrl: 'https://example.com/v1/params', - headers: {}, - parameters: {object: {a: 1, b: 2}, array: [1, 2, 3], string: 'short'} - }), - requestWithParameters({ - baseUrl: `https://example.com/v1/params`, - headers: {}, - parameters: {object: {a: 1, b: 2}, array: [1, 2, 3], string: 'long'.padEnd(10_000, 'g')} - }) - ]); - - t.equals(calls.length, 2, '2 requests'); - - // GET - t.true(calls[0].url.startsWith('https://example.com/v1/params?'), 'get - url'); - t.equals(calls[0].method, undefined, 'get - method'); - t.equals(calls[0].body, undefined, 'get - body'); - t.deepEquals( - Array.from(new URL(calls[0].url).searchParams.entries()), - [ - ['v', '3.4'], - ['deckglVersion', 'untranspiled source'], - ['object', '{"a":1,"b":2}'], - ['array', '[1,2,3]'], - ['string', 'short'] - ], - 'get - params' - ); - - // POST - const postBody = JSON.parse(calls[1].body as string); - t.equals(calls[1].method, 'POST', 'post - method'); - t.equals(postBody.v, '3.4', 'post - body.v'); - t.equals(postBody.deckglVersion, 'untranspiled source', 'post - body.deckglVersion'); - t.deepEquals(postBody.object, {a: 1, b: 2}, 'post - body.object'); - t.deepEquals(postBody.array, [1, 2, 3], 'post - body.array'); - t.true(postBody.string.startsWith('longgg'), 'post - body.string'); - t.equals(calls[1].url, 'https://example.com/v1/params', 'post - url'); - }); - t.end(); -}); - -test('requestWithParameters#precedence', async t => { - await withMockFetchMapsV3(async calls => { - t.equals(calls.length, 0, '0 initial calls'); - - await Promise.all([ - requestWithParameters({ - baseUrl: 'https://example.com/v1/params?test=1', - headers: {}, - parameters: {} - }), - requestWithParameters({ - baseUrl: `https://example.com/v1/params?test=2&v=3.0`, - headers: {}, - parameters: {} - }), - requestWithParameters({ - baseUrl: `https://example.com/v1/params?test=3&v=3.0`, - headers: {}, - parameters: {v: '3.2'} - }) - ]); - - t.equals(calls.length, 3, '3 requests'); - - const [url1, url2, url3] = calls.map(call => new URL(call.url)); - - t.equals(url1.searchParams.get('v'), V3_MINOR_VERSION, 'unset'); - t.equals(url2.searchParams.get('v'), V3_MINOR_VERSION, 'default overrides url'); - t.equals(url3.searchParams.get('v'), '3.2', 'param overrides default'); - }); - t.end(); -}); - -test('requestWithParameters#maxLengthURL', async t => { - await withMockFetchMapsV3(async calls => { - t.equals(calls.length, 0, '0 initial calls'); - - await Promise.all([ - requestWithParameters({ - baseUrl: 'https://example.com/v1/item/1' - }), - requestWithParameters({ - baseUrl: 'https://example.com/v1/item/2', - maxLengthURL: 10 - }), - requestWithParameters({ - baseUrl: `https://example.com/v1/item/3`, - parameters: {content: 'long'.padEnd(10_000, 'g')} // > default limit - }), - requestWithParameters({ - baseUrl: `https://example.com/v1/item/4`, - parameters: {content: 'long'.padEnd(10_000, 'g')}, - maxLengthURL: 15_000 - }) - ]); - - t.equals(calls.length, 4, '4 requests'); - t.deepEquals( - calls.map(({method}) => method ?? 'GET'), - ['GET', 'POST', 'POST', 'GET'], - 'request method' - ); - }); - t.end(); -}); diff --git a/test/modules/carto/index.ts b/test/modules/carto/index.ts index 19d8d65ab02..af11d1a2ab6 100644 --- a/test/modules/carto/index.ts +++ b/test/modules/carto/index.ts @@ -3,12 +3,9 @@ // Copyright (c) vis.gl contributors import './api/basemap.spec'; -import './api/carto-api-error.spec'; import './api/fetch-map.spec'; import './api/layer-map.spec'; import './api/parse-map.spec'; -import './api/query.spec'; -import './api/request-with-parameters.spec'; import './utils.spec'; import './layers/carto-vector-tile.spec'; import './layers/h3-tile-layer.spec'; @@ -21,18 +18,6 @@ import './layers/quadbin-layer.spec'; import './layers/quadbin-tile-layer.spec'; import './layers/quadbin-tileset-2d.spec'; import './layers/vector-tile-layer.spec'; -import './sources/boundary-query-source.spec'; -import './sources/boundary-table-source.spec'; -import './sources/h3-query-source.spec'; -import './sources/h3-table-source.spec'; -import './sources/h3-tileset-source.spec'; -import './sources/quadbin-query-source.spec'; -import './sources/quadbin-table-source.spec'; -import './sources/quadbin-tileset-source.spec'; -import './sources/raster-source.spec'; -import './sources/vector-query-source.spec'; -import './sources/vector-table-source.spec'; -import './sources/vector-tileset-source.spec'; import './style/carto-color-bins.spec'; import './style/carto-color-categories.spec'; import './style/carto-color-continuous.spec'; diff --git a/test/modules/carto/sources/boundary-query-source.spec.ts b/test/modules/carto/sources/boundary-query-source.spec.ts deleted file mode 100644 index ccfed34f01e..00000000000 --- a/test/modules/carto/sources/boundary-query-source.spec.ts +++ /dev/null @@ -1,39 +0,0 @@ -// deck.gl -// SPDX-License-Identifier: MIT -// Copyright (c) vis.gl contributors - -import {boundaryQuerySource} from '@deck.gl/carto'; -import test from 'tape-catch'; -import {withMockFetchMapsV3} from '../mock-fetch'; - -test('boundaryQuerySource', async t => { - await withMockFetchMapsV3(async calls => { - const tilejson = await boundaryQuerySource({ - connectionName: 'carto_dw', - accessToken: '', - tilesetTableName: 'a.b.tileset_table', - columns: ['column1', 'column2'], - propertiesSqlQuery: 'select * from `a.b.properties_table`' - }); - - t.is(calls.length, 2, 'calls fetch() x2'); - - const [initCall, tilesetCall] = calls; - - t.match(initCall.url, /v3\/maps\/carto_dw\/boundary/, 'connection'); - t.match(initCall.url, /tilesetTableName=a.b.tileset_table/, 'tilesetTableName'); - t.match( - initCall.url, - /propertiesSqlQuery=select\+\*\+from\+%60a.b.properties_table%60/, - 'propertiesSqlQuery' - ); - t.match(initCall.url, /columns=column1%2Ccolumn2/, 'columns'); - - t.match(tilesetCall.url, /^https:\/\/xyz\.com\/\?format\=tilejson\&cache\=/, 'tileset URL'); - - t.ok(tilejson, 'returns source'); - t.deepEqual(tilejson.tiles, ['https://xyz.com/{z}/{x}/{y}?formatTiles=binary'], 'source.tiles'); - t.equal(tilejson.accessToken, '', 'source.accessToken'); - }).catch(t.fail); - t.end(); -}); diff --git a/test/modules/carto/sources/boundary-table-source.spec.ts b/test/modules/carto/sources/boundary-table-source.spec.ts deleted file mode 100644 index 6a254fdf00e..00000000000 --- a/test/modules/carto/sources/boundary-table-source.spec.ts +++ /dev/null @@ -1,35 +0,0 @@ -// deck.gl -// SPDX-License-Identifier: MIT -// Copyright (c) vis.gl contributors - -import {boundaryTableSource} from '@deck.gl/carto'; -import test from 'tape-catch'; -import {withMockFetchMapsV3} from '../mock-fetch'; - -test('boundaryTableSource', async t => { - await withMockFetchMapsV3(async calls => { - const tilejson = await boundaryTableSource({ - connectionName: 'carto_dw', - accessToken: '', - tilesetTableName: 'a.b.tileset_table', - columns: ['column1', 'column2'], - propertiesTableName: 'a.b.properties_table' - }); - - t.is(calls.length, 2, 'calls fetch() x2'); - - const [initCall, tilesetCall] = calls; - - t.match(initCall.url, /v3\/maps\/carto_dw\/boundary/, 'connection'); - t.match(initCall.url, /tilesetTableName=a.b.tileset_table/, 'tilesetTableName'); - t.match(initCall.url, /propertiesTableName=a.b.properties_table/, 'propertiesTableName'); - t.match(initCall.url, /columns=column1%2Ccolumn2/, 'columns'); - - t.match(tilesetCall.url, /^https:\/\/xyz\.com\/\?format\=tilejson\&cache\=/, 'tileset URL'); - - t.ok(tilejson, 'returns source'); - t.deepEqual(tilejson.tiles, ['https://xyz.com/{z}/{x}/{y}?formatTiles=binary'], 'source.tiles'); - t.equal(tilejson.accessToken, '', 'source.accessToken'); - }).catch(t.fail); - t.end(); -}); diff --git a/test/modules/carto/sources/h3-query-source.spec.ts b/test/modules/carto/sources/h3-query-source.spec.ts deleted file mode 100644 index 72fc492cd12..00000000000 --- a/test/modules/carto/sources/h3-query-source.spec.ts +++ /dev/null @@ -1,41 +0,0 @@ -// deck.gl -// SPDX-License-Identifier: MIT -// Copyright (c) vis.gl contributors - -import {h3QuerySource} from '@deck.gl/carto'; -import test from 'tape-catch'; -import {withMockFetchMapsV3} from '../mock-fetch'; - -test('h3QuerySource', async t => { - await withMockFetchMapsV3(async calls => { - const tilejson = await h3QuerySource({ - connectionName: 'carto_dw', - clientId: 'CUSTOM_CLIENT', - accessToken: '', - sqlQuery: 'SELECT * FROM a.b.h3_table', - aggregationExp: 'SUM(population) as pop' - }); - - t.is(calls.length, 2, 'calls fetch() x2'); - - const [initCall, tilesetCall] = calls; - - t.match(initCall.url, /v3\/maps\/carto_dw\/query/, 'connection'); - t.match(initCall.url, /aggregationExp=SUM%28population%29\+as\+pop/, 'aggregationExp'); - t.match(initCall.url, /spatialDataColumn=h3/, 'spatialDataColumn'); - t.match(initCall.url, /spatialDataType=h3/, 'spatialDataType'); - t.match(initCall.url, /q=SELECT\+\*\+FROM\+a\.b\.h3_table/, 'query'); - t.match(initCall.url, /client\=CUSTOM_CLIENT/, 'clientId'); - - t.match(tilesetCall.url, /^https:\/\/xyz\.com\/\?format\=tilejson\&cache\=/, 'tileset URL'); - - t.ok(tilejson, 'returns tilejson'); - t.deepEqual( - tilejson.tiles, - ['https://xyz.com/{z}/{x}/{y}?formatTiles=binary'], - 'tilejson.tiles' - ); - t.equal(tilejson.accessToken, '', 'tilejson.accessToken'); - }).catch(t.fail); - t.end(); -}); diff --git a/test/modules/carto/sources/h3-table-source.spec.ts b/test/modules/carto/sources/h3-table-source.spec.ts deleted file mode 100644 index 8810e88e2f5..00000000000 --- a/test/modules/carto/sources/h3-table-source.spec.ts +++ /dev/null @@ -1,39 +0,0 @@ -// deck.gl -// SPDX-License-Identifier: MIT -// Copyright (c) vis.gl contributors - -import {h3TableSource} from '@deck.gl/carto'; -import test from 'tape-catch'; -import {withMockFetchMapsV3} from '../mock-fetch'; - -test('h3TableSource', async t => { - await withMockFetchMapsV3(async calls => { - const tilejson = await h3TableSource({ - connectionName: 'carto_dw', - accessToken: '', - tableName: 'a.b.h3_table', - aggregationExp: 'SUM(population) as pop' - }); - - t.is(calls.length, 2, 'calls fetch() x2'); - - const [initCall, tilesetCall] = calls; - - t.match(initCall.url, /v3\/maps\/carto_dw\/table/, 'connection'); - t.match(initCall.url, /aggregationExp=SUM%28population%29\+as\+pop/, 'aggregationExp'); - t.match(initCall.url, /spatialDataColumn=h3/, 'spatialDataColumn'); - t.match(initCall.url, /spatialDataType=h3/, 'spatialDataType'); - t.match(initCall.url, /name=a.b.h3_table/, 'table'); - - t.match(tilesetCall.url, /^https:\/\/xyz\.com\/\?format\=tilejson\&cache\=/, 'tileset URL'); - - t.ok(tilejson, 'returns tilejson'); - t.deepEqual( - tilejson.tiles, - ['https://xyz.com/{z}/{x}/{y}?formatTiles=binary'], - 'tilejson.tiles' - ); - t.equal(tilejson.accessToken, '', 'tilejson.accessToken'); - }).catch(t.fail); - t.end(); -}); diff --git a/test/modules/carto/sources/h3-tileset-source.spec.ts b/test/modules/carto/sources/h3-tileset-source.spec.ts deleted file mode 100644 index 77d81fa8c97..00000000000 --- a/test/modules/carto/sources/h3-tileset-source.spec.ts +++ /dev/null @@ -1,35 +0,0 @@ -// deck.gl -// SPDX-License-Identifier: MIT -// Copyright (c) vis.gl contributors - -import {h3TilesetSource} from '@deck.gl/carto'; -import test from 'tape-catch'; -import {withMockFetchMapsV3} from '../mock-fetch'; - -test('h3TilesetSource', async t => { - await withMockFetchMapsV3(async calls => { - const tilejson = await h3TilesetSource({ - connectionName: 'carto_dw', - accessToken: '', - tableName: 'a.b.h3_tileset' - }); - - t.is(calls.length, 2, 'calls fetch() x2'); - - const [initCall, tilesetCall] = calls; - - t.match(initCall.url, /v3\/maps\/carto_dw\/tileset/, 'connection'); - t.match(initCall.url, /name=a.b.h3_tileset/, 'tileset'); - - t.match(tilesetCall.url, /^https:\/\/xyz\.com\/\?format\=tilejson\&cache\=/, 'tileset URL'); - - t.ok(tilejson, 'returns tilejson'); - t.deepEqual( - tilejson.tiles, - ['https://xyz.com/{z}/{x}/{y}?formatTiles=binary'], - 'tilejson.tiles' - ); - t.equal(tilejson.accessToken, '', 'tilejson.accessToken'); - }).catch(t.fail); - t.end(); -}); diff --git a/test/modules/carto/sources/quadbin-query-source.spec.ts b/test/modules/carto/sources/quadbin-query-source.spec.ts deleted file mode 100644 index aa6ad2469bc..00000000000 --- a/test/modules/carto/sources/quadbin-query-source.spec.ts +++ /dev/null @@ -1,39 +0,0 @@ -// deck.gl -// SPDX-License-Identifier: MIT -// Copyright (c) vis.gl contributors - -import {quadbinQuerySource} from '@deck.gl/carto'; -import test from 'tape-catch'; -import {withMockFetchMapsV3} from '../mock-fetch'; - -test('quadbinQuerySource', async t => { - await withMockFetchMapsV3(async calls => { - const tilejson = await quadbinQuerySource({ - connectionName: 'carto_dw', - accessToken: '', - sqlQuery: 'SELECT * FROM a.b.quadbin_table', - aggregationExp: 'SUM(population) as pop' - }); - - t.is(calls.length, 2, 'calls fetch() x2'); - - const [initCall, tilesetCall] = calls; - - t.match(initCall.url, /v3\/maps\/carto_dw\/query/, 'connection'); - t.match(initCall.url, /aggregationExp=SUM%28population%29\+as\+pop/, 'aggregationExp'); - t.match(initCall.url, /spatialDataColumn=quadbin/, 'spatialDataColumn'); - t.match(initCall.url, /spatialDataType=quadbin/, 'spatialDataType'); - t.match(initCall.url, /q=SELECT\+\*\+FROM\+a\.b\.quadbin_table/, 'query'); - - t.match(tilesetCall.url, /^https:\/\/xyz\.com\/\?format\=tilejson\&cache\=/, 'tileset URL'); - - t.ok(tilejson, 'returns tilejson'); - t.deepEqual( - tilejson.tiles, - ['https://xyz.com/{z}/{x}/{y}?formatTiles=binary'], - 'tilejson.tiles' - ); - t.equal(tilejson.accessToken, '', 'tilejson.accessToken'); - }).catch(t.fail); - t.end(); -}); diff --git a/test/modules/carto/sources/quadbin-table-source.spec.ts b/test/modules/carto/sources/quadbin-table-source.spec.ts deleted file mode 100644 index 071526f5449..00000000000 --- a/test/modules/carto/sources/quadbin-table-source.spec.ts +++ /dev/null @@ -1,39 +0,0 @@ -// deck.gl -// SPDX-License-Identifier: MIT -// Copyright (c) vis.gl contributors - -import {quadbinTableSource} from '@deck.gl/carto'; -import test from 'tape-catch'; -import {withMockFetchMapsV3} from '../mock-fetch'; - -test('quadbinTableSource', async t => { - await withMockFetchMapsV3(async calls => { - const tilejson = await quadbinTableSource({ - connectionName: 'carto_dw', - accessToken: '', - tableName: 'a.b.quadbin_table', - aggregationExp: 'SUM(population) as pop' - }); - - t.is(calls.length, 2, 'calls fetch() x2'); - - const [initCall, tilesetCall] = calls; - - t.match(initCall.url, /v3\/maps\/carto_dw\/table/, 'connection'); - t.match(initCall.url, /aggregationExp=SUM%28population%29\+as\+pop/, 'aggregationExp'); - t.match(initCall.url, /spatialDataColumn=quadbin/, 'spatialDataColumn'); - t.match(initCall.url, /spatialDataType=quadbin/, 'spatialDataType'); - t.match(initCall.url, /name=a.b.quadbin_table/, 'table'); - - t.match(tilesetCall.url, /^https:\/\/xyz\.com\/\?format\=tilejson\&cache\=/, 'tileset URL'); - - t.ok(tilejson, 'returns tilejson'); - t.deepEqual( - tilejson.tiles, - ['https://xyz.com/{z}/{x}/{y}?formatTiles=binary'], - 'tilejson.tiles' - ); - t.equal(tilejson.accessToken, '', 'tilejson.accessToken'); - }).catch(t.fail); - t.end(); -}); diff --git a/test/modules/carto/sources/quadbin-tileset-source.spec.ts b/test/modules/carto/sources/quadbin-tileset-source.spec.ts deleted file mode 100644 index 479a914caa6..00000000000 --- a/test/modules/carto/sources/quadbin-tileset-source.spec.ts +++ /dev/null @@ -1,35 +0,0 @@ -// deck.gl -// SPDX-License-Identifier: MIT -// Copyright (c) vis.gl contributors - -import {quadbinTilesetSource} from '@deck.gl/carto'; -import test from 'tape-catch'; -import {withMockFetchMapsV3} from '../mock-fetch'; - -test('quadbinTilesetSource', async t => { - await withMockFetchMapsV3(async calls => { - const tilejson = await quadbinTilesetSource({ - connectionName: 'carto_dw', - accessToken: '', - tableName: 'a.b.quadbin_tileset' - }); - - t.is(calls.length, 2, 'calls fetch() x2'); - - const [initCall, tilesetCall] = calls; - - t.match(initCall.url, /v3\/maps\/carto_dw\/tileset/, 'connection'); - t.match(initCall.url, /name=a.b.quadbin_tileset/, 'tileset'); - - t.match(tilesetCall.url, /^https:\/\/xyz\.com\/\?format\=tilejson\&cache\=/, 'tileset URL'); - - t.ok(tilejson, 'returns tilejson'); - t.deepEqual( - tilejson.tiles, - ['https://xyz.com/{z}/{x}/{y}?formatTiles=binary'], - 'tilejson.tiles' - ); - t.equal(tilejson.accessToken, '', 'tilejson.accessToken'); - }).catch(t.fail); - t.end(); -}); diff --git a/test/modules/carto/sources/raster-source.spec.ts b/test/modules/carto/sources/raster-source.spec.ts deleted file mode 100644 index 5ab6dcc955f..00000000000 --- a/test/modules/carto/sources/raster-source.spec.ts +++ /dev/null @@ -1,49 +0,0 @@ -// deck.gl -// SPDX-License-Identifier: MIT -// Copyright (c) vis.gl contributors - -import {rasterSource} from '@deck.gl/carto'; -import test from 'tape-catch'; -import {withMockFetchMapsV3} from '../mock-fetch'; - -test('rasterSource', async t => { - await withMockFetchMapsV3(async calls => { - const tilejson = await rasterSource({ - connectionName: 'carto_dw', - accessToken: '', - tableName: 'a.b.raster_table' - }); - - t.is(calls.length, 2, 'calls fetch() x2'); - - const [initCall, tilesetCall] = calls; - - t.match(initCall.url, /v3\/maps\/carto_dw\/raster/, 'connection'); - t.match(initCall.url, /name=a\.b\.raster_table/, 'table'); - - t.match(tilesetCall.url, /^https:\/\/xyz\.com\/\?format\=tilejson\&cache\=/, 'tileset URL'); - - t.ok(tilejson, 'returns tilejson'); - t.deepEqual( - tilejson.tiles, - ['https://xyz.com/{z}/{x}/{y}?formatTiles=binary'], - 'tilejson.tiles' - ); - t.equal(tilejson.accessToken, '', 'tilejson.accessToken'); - }).catch(t.fail); - t.end(); -}); - -test('rasterSource - filters', async t => { - await withMockFetchMapsV3(async calls => { - const tilejson = await rasterSource({ - connectionName: 'carto_dw', - accessToken: '', - tableName: 'a.b.raster_table', - filters: {type: {in: [1, 2, 3]}} - }); - const url = new URL(calls[0].url); - t.is(url.searchParams.get('filters'), '{"type":{"in":[1,2,3]}}'); - }).catch(t.fail); - t.end(); -}); diff --git a/test/modules/carto/sources/vector-query-source.spec.ts b/test/modules/carto/sources/vector-query-source.spec.ts deleted file mode 100644 index 0b05ef60af9..00000000000 --- a/test/modules/carto/sources/vector-query-source.spec.ts +++ /dev/null @@ -1,46 +0,0 @@ -// deck.gl -// SPDX-License-Identifier: MIT -// Copyright (c) vis.gl contributors - -import {vectorQuerySource} from '@deck.gl/carto'; -import test from 'tape-catch'; -import {withMockFetchMapsV3} from '../mock-fetch'; - -test('vectorQuerySource', async t => { - await withMockFetchMapsV3(async calls => { - const tilejson = await vectorQuerySource({ - connectionName: 'carto_dw', - accessToken: '', - sqlQuery: 'SELECT * FROM a.b.vector_table', - columns: ['a', 'b'], - spatialDataColumn: 'mygeom', - queryParameters: {type: 'Supermarket', minRevenue: 1000000} - }); - - t.is(calls.length, 2, 'calls fetch() x2'); - - const [initCall, tilesetCall] = calls; - - t.match(initCall.url, /v3\/maps\/carto_dw\/query/, 'connection'); - t.match(initCall.url, /q=SELECT\+\*\+FROM\+a\.b\.vector_table/, 'query'); - t.match(initCall.url, /columns=a%2Cb/, 'columns'); - t.match(initCall.url, /spatialDataColumn=mygeom/, 'spatialDataColumn'); - t.match(initCall.url, /spatialDataType=geo/, 'spatialDataType'); - t.match( - initCall.url, - /queryParameters=%7B%22type%22%3A%22Supermarket%22%2C%22minRevenue%22%3A1000000%7D/, - 'queryParameters' - ); - - t.match(tilesetCall.url, /^https:\/\/xyz\.com\/\?format\=tilejson\&cache\=/, 'tileset URL'); - - t.ok(tilejson, 'returns tilejson'); - t.deepEqual( - tilejson.tiles, - ['https://xyz.com/{z}/{x}/{y}?formatTiles=binary'], - 'tilejson.tiles' - ); - t.equal(tilejson.accessToken, '', 'tilejson.accessToken'); - }).catch(t.fail); - t.end(); -}); diff --git a/test/modules/carto/sources/vector-table-source.spec.ts b/test/modules/carto/sources/vector-table-source.spec.ts deleted file mode 100644 index 9e97f9991cb..00000000000 --- a/test/modules/carto/sources/vector-table-source.spec.ts +++ /dev/null @@ -1,40 +0,0 @@ -// deck.gl -// SPDX-License-Identifier: MIT -// Copyright (c) vis.gl contributors - -import {vectorTableSource} from '@deck.gl/carto'; -import test from 'tape-catch'; -import {withMockFetchMapsV3} from '../mock-fetch'; - -test('vectorTableSource', async t => { - await withMockFetchMapsV3(async calls => { - const tilejson = await vectorTableSource({ - connectionName: 'carto_dw', - accessToken: '', - tableName: 'a.b.vector_table', - columns: ['a', 'b'], - spatialDataColumn: 'mygeom' - }); - - t.is(calls.length, 2, 'calls fetch() x2'); - - const [initCall, tilesetCall] = calls; - - t.match(initCall.url, /v3\/maps\/carto_dw\/table/, 'connection'); - t.match(initCall.url, /name=a\.b\.vector_table/, 'table'); - t.match(initCall.url, /columns=a%2Cb/, 'columns'); - t.match(initCall.url, /spatialDataColumn=mygeom/, 'spatialDataColumn'); - t.match(initCall.url, /spatialDataType=geo/, 'spatialDataType'); - - t.match(tilesetCall.url, /^https:\/\/xyz\.com\/\?format\=tilejson\&cache\=/, 'tileset URL'); - - t.ok(tilejson, 'returns tilejson'); - t.deepEqual( - tilejson.tiles, - ['https://xyz.com/{z}/{x}/{y}?formatTiles=binary'], - 'tilejson.tiles' - ); - t.equal(tilejson.accessToken, '', 'tilejson.accessToken'); - }).catch(t.fail); - t.end(); -}); diff --git a/test/modules/carto/sources/vector-tileset-source.spec.ts b/test/modules/carto/sources/vector-tileset-source.spec.ts deleted file mode 100644 index 4fa713579fe..00000000000 --- a/test/modules/carto/sources/vector-tileset-source.spec.ts +++ /dev/null @@ -1,35 +0,0 @@ -// deck.gl -// SPDX-License-Identifier: MIT -// Copyright (c) vis.gl contributors - -import {vectorTilesetSource} from '@deck.gl/carto'; -import test from 'tape-catch'; -import {withMockFetchMapsV3} from '../mock-fetch'; - -test('vectorTilesetSource', async t => { - await withMockFetchMapsV3(async calls => { - const tilejson = await vectorTilesetSource({ - connectionName: 'carto_dw', - accessToken: '', - tableName: 'a.b.vector_tileset' - }); - - t.is(calls.length, 2, 'calls fetch() x2'); - - const [initCall, tilesetCall] = calls; - - t.match(initCall.url, /v3\/maps\/carto_dw\/tileset/, 'connection'); - t.match(initCall.url, /name=a\.b\.vector_tileset/, 'table'); - - t.match(tilesetCall.url, /^https:\/\/xyz\.com\/\?format\=tilejson\&cache\=/, 'tileset URL'); - - t.ok(tilejson, 'returns tilejson'); - t.deepEqual( - tilejson.tiles, - ['https://xyz.com/{z}/{x}/{y}?formatTiles=binary'], - 'tilejson.tiles' - ); - t.equal(tilejson.accessToken, '', 'tilejson.accessToken'); - }).catch(t.fail); - t.end(); -}); diff --git a/yarn.lock b/yarn.lock index 26147ac0615..715d68d8897 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1083,6 +1083,18 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== +"@carto/api-client@^0.4.0-alpha.4": + version "0.4.0-alpha.4" + resolved "https://registry.yarnpkg.com/@carto/api-client/-/api-client-0.4.0-alpha.4.tgz#32af6a903624a1cf1c930002a6640116d756750d" + integrity sha512-Bm+hoKfMwzruFMvbowypB/CoBQUOl8zqE3XmBHodU0akE341xdSLx8B9w7f4jtqYylXh0wk1irz2sFfW37N2HQ== + dependencies: + "@turf/bbox-clip" "^7.1.0" + "@turf/bbox-polygon" "^7.1.0" + "@turf/helpers" "^7.1.0" + "@turf/invariant" "^7.1.0" + "@turf/union" "^7.1.0" + "@types/geojson" "^7946.0.14" + "@cspotcode/source-map-support@^0.8.0": version "0.8.1" resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz#00629c35a688e05a88b1cda684fb9d5e73f000a1" @@ -2838,6 +2850,25 @@ "@tufjs/canonical-json" "2.0.0" minimatch "^9.0.4" +"@turf/bbox-clip@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@turf/bbox-clip/-/bbox-clip-7.1.0.tgz#59dabb04d270949c9111619b54981bea25305f9c" + integrity sha512-PhZubKCzF/afwStUzODqOJluiCbCw244lCtVhXA9F+Pgkhvk8KvbFdgpPquOZ45OwuktrchSB28BrBkSBiadHw== + dependencies: + "@turf/helpers" "^7.1.0" + "@turf/invariant" "^7.1.0" + "@types/geojson" "^7946.0.10" + tslib "^2.6.2" + +"@turf/bbox-polygon@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@turf/bbox-polygon/-/bbox-polygon-7.1.0.tgz#5034eefcae4e497f72763220c191cc2b436649fa" + integrity sha512-fvZB09ErCZOVlWVDop836hmpKaGUmfXnR9naMhS73A/8nn4M3hELbQtMv2R8gXj7UakXCuxS/i9erdpDFZ2O+g== + dependencies: + "@turf/helpers" "^7.1.0" + "@types/geojson" "^7946.0.10" + tslib "^2.6.2" + "@turf/boolean-clockwise@^5.1.5": version "5.1.5" resolved "https://registry.yarnpkg.com/@turf/boolean-clockwise/-/boolean-clockwise-5.1.5.tgz#3302b7dac62c5e291a0789e29af7283387fa9deb" @@ -2858,6 +2889,14 @@ resolved "https://registry.yarnpkg.com/@turf/helpers/-/helpers-5.1.5.tgz#153405227ab933d004a5bb9641a9ed999fcbe0cf" integrity sha512-/lF+JR+qNDHZ8bF9d+Cp58nxtZWJ3sqFe6n3u3Vpj+/0cqkjk4nXKYBSY0azm+GIYB5mWKxUXvuP/m0ZnKj1bw== +"@turf/helpers@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@turf/helpers/-/helpers-7.1.0.tgz#eb734e291c9c205822acdd289fe20e91c3cb1641" + integrity sha512-dTeILEUVeNbaEeoZUOhxH5auv7WWlOShbx7QSd4s0T4Z0/iz90z9yaVCtZOLbU89umKotwKaJQltBNO9CzVgaQ== + dependencies: + "@types/geojson" "^7946.0.10" + tslib "^2.6.2" + "@turf/invariant@^5.1.5": version "5.2.0" resolved "https://registry.yarnpkg.com/@turf/invariant/-/invariant-5.2.0.tgz#f0150ff7290b38577b73d088b7932c1ee0aa90a7" @@ -2865,6 +2904,15 @@ dependencies: "@turf/helpers" "^5.1.5" +"@turf/invariant@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@turf/invariant/-/invariant-7.1.0.tgz#c90cffa093291316b597212396d68bf9e465cf2e" + integrity sha512-OCLNqkItBYIP1nE9lJGuIUatWGtQ4rhBKAyTfFu0z8npVzGEYzvguEeof8/6LkKmTTEHW53tCjoEhSSzdRh08Q== + dependencies: + "@turf/helpers" "^7.1.0" + "@types/geojson" "^7946.0.10" + tslib "^2.6.2" + "@turf/meta@^5.1.5": version "5.2.0" resolved "https://registry.yarnpkg.com/@turf/meta/-/meta-5.2.0.tgz#3b1ad485ee0c3b0b1775132a32c384d53e4ba53d" @@ -2872,6 +2920,14 @@ dependencies: "@turf/helpers" "^5.1.5" +"@turf/meta@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@turf/meta/-/meta-7.1.0.tgz#b2af85afddd0ef08aeae8694a12370a4f06b6d13" + integrity sha512-ZgGpWWiKz797Fe8lfRj7HKCkGR+nSJ/5aKXMyofCvLSc2PuYJs/qyyifDPWjASQQCzseJ7AlF2Pc/XQ/3XkkuA== + dependencies: + "@turf/helpers" "^7.1.0" + "@types/geojson" "^7946.0.10" + "@turf/rewind@^5.1.5": version "5.1.5" resolved "https://registry.yarnpkg.com/@turf/rewind/-/rewind-5.1.5.tgz#9ea3db4a68b73c1fd1dd11f57631b143cfefa1c9" @@ -2883,6 +2939,17 @@ "@turf/invariant" "^5.1.5" "@turf/meta" "^5.1.5" +"@turf/union@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@turf/union/-/union-7.1.0.tgz#7b8f0cc7fd24c1269224eaa5f76946458bbb9c01" + integrity sha512-7VI8jONdBg9qmbfNlLQycPr93l5aU9HGMgWI9M6pb4ERuU2+p8KgffCgs2NyMtP2HxPrKSybzj31g7bnbEKofQ== + dependencies: + "@turf/helpers" "^7.1.0" + "@turf/meta" "^7.1.0" + "@types/geojson" "^7946.0.10" + polygon-clipping "^0.15.3" + tslib "^2.6.2" + "@tybys/wasm-util@^0.9.0": version "0.9.0" resolved "https://registry.yarnpkg.com/@tybys/wasm-util/-/wasm-util-0.9.0.tgz#3e75eb00604c8d6db470bf18c37b7d984a0e3355" @@ -2951,7 +3018,7 @@ resolved "https://registry.yarnpkg.com/@types/d3-time/-/d3-time-2.1.4.tgz#43587aa57d565ab60a1d2201edeebc497d5c1252" integrity sha512-BTfLsxTeo7yFxI/haOOf1ZwJ6xKgQLT9dCp+EcmQv87Gox6X+oKl4mLKfO6fnWm3P22+A6DknMNEZany8ql2Rw== -"@types/geojson@^7946.0.7", "@types/geojson@^7946.0.8": +"@types/geojson@^7946.0.10", "@types/geojson@^7946.0.14", "@types/geojson@^7946.0.7", "@types/geojson@^7946.0.8": version "7946.0.14" resolved "https://registry.yarnpkg.com/@types/geojson/-/geojson-7946.0.14.tgz#319b63ad6df705ee2a65a73ef042c8271e696613" integrity sha512-WCfD5Ht3ZesJUsONdhvm84dmzWOiOzOAqOncN0++w0lBw1o8OuDNJF2McvvCef/yBqb/HYRahp1BYtODFQ8bRg== @@ -8627,6 +8694,14 @@ pngjs@^3.0.0, pngjs@^3.3.3: resolved "https://registry.yarnpkg.com/pngjs/-/pngjs-3.4.0.tgz#99ca7d725965fb655814eaf65f38f12bbdbf555f" integrity sha512-NCrCHhWmnQklfH4MtJMRjZ2a8c80qXeMlQMv2uVp9ISJMTt562SbGd6n2oq0PaPgKm7Z6pL9E2UlLIhC+SHL3w== +polygon-clipping@^0.15.3: + version "0.15.7" + resolved "https://registry.yarnpkg.com/polygon-clipping/-/polygon-clipping-0.15.7.tgz#3823ca1e372566f350795ce9dd9a7b19e97bdaad" + integrity sha512-nhfdr83ECBg6xtqOAJab1tbksbBAOMUltN60bU+llHVOL0e5Onm1WpAXXWXVB39L8AJFssoIhEVuy/S90MmotA== + dependencies: + robust-predicates "^3.0.2" + splaytree "^3.1.0" + possible-typed-array-names@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/possible-typed-array-names/-/possible-typed-array-names-1.0.0.tgz#89bb63c6fada2c3e90adc4a647beeeb39cc7bf8f" @@ -9241,6 +9316,11 @@ rimraf@^4.4.1: dependencies: glob "^9.2.0" +robust-predicates@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/robust-predicates/-/robust-predicates-3.0.2.tgz#d5b28528c4824d20fc48df1928d41d9efa1ad771" + integrity sha512-IXgzBWvWQwE6PrDI05OvmXUIruQTcoMDzRsOd5CDvHCVLcLHMTSYvOK5Cm46kWqlV3yAbuSpBZdJ5oP5OUoStg== + rollup-plugin-inject@^3.0.0: version "3.0.2" resolved "https://registry.yarnpkg.com/rollup-plugin-inject/-/rollup-plugin-inject-3.0.2.tgz#e4233855bfba6c0c12a312fd6649dff9a13ee9f4" @@ -9583,6 +9663,11 @@ spdx-license-ids@^3.0.0: resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.20.tgz#e44ed19ed318dd1e5888f93325cee800f0f51b89" integrity sha512-jg25NiDV/1fLtSgEgyvVyDunvaNHbuwF9lfNV17gSmPFAlYzdfNBlLtLzXTevwkPj7DhGbmN9VnmJIgLnhvaBw== +splaytree@^3.1.0: + version "3.1.2" + resolved "https://registry.yarnpkg.com/splaytree/-/splaytree-3.1.2.tgz#d1db2691665a3c69d630de98d55145a6546dc166" + integrity sha512-4OM2BJgC5UzrhVnnJA4BkHKGtjXNzzUfpQjCO8I05xYPsfS/VuQDwjCGGMi8rYQilHEV4j8NBqTFbls/PZEE7A== + split2@^3.2.2: version "3.2.2" resolved "https://registry.yarnpkg.com/split2/-/split2-3.2.2.tgz#bf2cf2a37d838312c249c89206fd7a17dd12365f" @@ -10189,6 +10274,11 @@ tslib@^2.0.1, tslib@^2.1.0, tslib@^2.3.0, tslib@^2.4.0: resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.7.0.tgz#d9b40c5c40ab59e8738f297df3087bf1a2690c01" integrity sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA== +tslib@^2.6.2: + version "2.8.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.0.tgz#d124c86c3c05a40a91e6fdea4021bd31d377971b" + integrity sha512-jWVzBLplnCmoaTr13V9dYbiQ99wvZRd0vNWaDRg+aVYRcjDF3nDksxFDE/+fkXnKhpnUUkmx5pK/v8mCtLVqZA== + tuf-js@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/tuf-js/-/tuf-js-2.2.1.tgz#fdd8794b644af1a75c7aaa2b197ddffeb2911b56"