@carto/api-client
Advanced tools
Comparing version 0.4.6-0 to 0.4.6
@@ -32,23 +32,1 @@ /** | ||
export declare const DEFAULT_API_BASE_URL = "https://gcp-us-east1.api.carto.com"; | ||
/** @internalRemarks Source: @carto/react-core */ | ||
export declare enum TileFormat { | ||
MVT = "mvt", | ||
JSON = "json", | ||
GEOJSON = "geojson", | ||
BINARY = "binary" | ||
} | ||
/** @internalRemarks Source: @carto/react-core */ | ||
export declare enum SpatialIndex { | ||
H3 = "h3", | ||
S2 = "s2", | ||
QUADBIN = "quadbin" | ||
} | ||
/** @internalRemarks Source: @carto/react-core */ | ||
export declare enum Provider { | ||
BIGQUERY = "bigquery", | ||
REDSHIFT = "redshift", | ||
POSTGRES = "postgres", | ||
SNOWFLAKE = "snowflake", | ||
DATABRICKS = "databricks", | ||
DATABRICKS_REST = "databricksRest" | ||
} |
@@ -11,5 +11,2 @@ export * from './client.js'; | ||
query, requestWithParameters, } from './api/index.js'; | ||
export * from './filters/index.js'; | ||
export * from './operations/index.js'; | ||
export * from './utils/makeIntervalComplete.js'; | ||
export * from './utils/transformToTileCoords.js'; | ||
export { _getHexagonResolution } from './spatial-index.js'; |
export { executeModel } from './model.js'; | ||
export type { Model, ModelSource } from './model.js'; | ||
export type { Model } from './model.js'; | ||
export type { ModelRequestOptions } from './common.js'; |
@@ -1,5 +0,4 @@ | ||
import { WidgetTilesetSourceResult } from '../widget-sources'; | ||
import type { SourceOptions, TilejsonResult, TilesetSourceOptions } from './types'; | ||
export type H3TilesetSourceOptions = SourceOptions & TilesetSourceOptions; | ||
export type H3TilesetSourceResponse = TilejsonResult & WidgetTilesetSourceResult; | ||
export type H3TilesetSourceResponse = TilejsonResult; | ||
export declare const h3TilesetSource: (options: H3TilesetSourceOptions) => Promise<H3TilesetSourceResponse>; |
@@ -14,3 +14,3 @@ export { SOURCE_DEFAULTS } from './base-source'; | ||
export { rasterSource } from './raster-source'; | ||
export type { RasterSourceOptions } from './raster-source'; | ||
export type { RasterSourceOptions, RasterSourceResponse } from './raster-source'; | ||
export { quadbinQuerySource } from './quadbin-query-source'; | ||
@@ -17,0 +17,0 @@ export type { QuadbinQuerySourceOptions, QuadbinQuerySourceResponse, } from './quadbin-query-source'; |
@@ -1,5 +0,4 @@ | ||
import { WidgetTilesetSourceResult } from '../widget-sources'; | ||
import type { SourceOptions, TilejsonResult, TilesetSourceOptions } from './types'; | ||
export type QuadbinTilesetSourceOptions = SourceOptions & TilesetSourceOptions; | ||
export type QuadbinTilesetSourceResponse = TilejsonResult & WidgetTilesetSourceResult; | ||
export type QuadbinTilesetSourceResponse = TilejsonResult; | ||
export declare const quadbinTilesetSource: (options: QuadbinTilesetSourceOptions) => Promise<QuadbinTilesetSourceResponse>; |
@@ -1,5 +0,4 @@ | ||
import { WidgetTilesetSourceResult } from '../widget-sources'; | ||
import type { SourceOptions, TilesetSourceOptions, TilejsonResult } from './types'; | ||
export type VectorTilesetSourceOptions = SourceOptions & TilesetSourceOptions; | ||
export type VectorTilesetSourceResponse = TilejsonResult & WidgetTilesetSourceResult; | ||
export type VectorTilesetSourceResponse = TilejsonResult; | ||
export declare const vectorTilesetSource: (options: VectorTilesetSourceOptions) => Promise<VectorTilesetSourceResponse>; |
@@ -5,5 +5,11 @@ import type { ModelSource } from './models/model'; | ||
export declare function getSpatialFiltersResolution(source: Partial<ModelSource & AggregationOptions>, viewState: ViewState): number | undefined; | ||
export declare function getHexagonResolution(viewport: { | ||
/** | ||
* Resolution conversion function. Takes a WebMercatorViewport and returns | ||
* a H3 resolution such that the screen space size of the hexagons is | ||
* "similar" to the given tileSize on screen. Intended for use with deck.gl. | ||
* @internal | ||
*/ | ||
export declare function _getHexagonResolution(viewport: { | ||
zoom: number; | ||
latitude: number; | ||
}, tileSize: number): number; |
@@ -52,6 +52,2 @@ /****************************************************************************** | ||
}>; | ||
/****************************************************************************** | ||
* LOCAL CALCULATIONS | ||
*/ | ||
export type FeatureData = Record<string, unknown>; | ||
export {}; |
import type { FilterType } from './constants.js'; | ||
import type { Polygon, MultiPolygon, Feature } from 'geojson'; | ||
import type { BinaryFeature, BinaryFeatureCollection } from '@loaders.gl/schema'; | ||
import type { Polygon, MultiPolygon } from 'geojson'; | ||
/****************************************************************************** | ||
@@ -11,46 +10,2 @@ * MAPS AND TILES | ||
export type MapType = 'boundary' | 'query' | 'table' | 'tileset' | 'raster'; | ||
/** | ||
* Alias for GeoJSON 'BBox' type, semantically representing a viewport. | ||
* Order of values is "west", "south", "east", "north". | ||
*/ | ||
export type Viewport = [number, number, number, number]; | ||
/** | ||
* Subset of deck.gl's Tile2DHeader type, containing only the properties | ||
* required for local widget calculations. Deeper dependencies on deck.gl | ||
* APIs should be minimized within this library: @deck.gl/carto depends | ||
* on the API client, not the other way around. | ||
* @internalRemarks Source: @deck.gl/geo-layers | ||
*/ | ||
export type Tile = { | ||
index: { | ||
x: number; | ||
y: number; | ||
z: number; | ||
}; | ||
id: string; | ||
content: unknown; | ||
zoom: number; | ||
bbox: { | ||
west: number; | ||
east: number; | ||
north: number; | ||
south: number; | ||
}; | ||
isVisible: boolean; | ||
data?: BinaryFeatureCollection; | ||
}; | ||
/** Subset of deck.gl's Tile2DHeader type, for spatial indexes. */ | ||
export type SpatialIndexTile = Tile & { | ||
data?: (Feature & { | ||
id: bigint; | ||
})[]; | ||
}; | ||
/** @internalRemarks Source: @deck.gl/carto */ | ||
export type Raster = { | ||
blockSize: number; | ||
cells: { | ||
numericProps: BinaryFeature['numericProps']; | ||
properties: BinaryFeature['properties']; | ||
}; | ||
}; | ||
/****************************************************************************** | ||
@@ -98,3 +53,2 @@ * AGGREGATION | ||
values: string[]; | ||
params?: StringSearchOptions; | ||
}; | ||
@@ -104,16 +58,2 @@ } | ||
export type FilterLogicalOperator = 'and' | 'or'; | ||
/** | ||
* Type for minimum or maximum value of an interval. Values 'null' and | ||
* 'undefined' are intentionally allowed, and represent an unbounded value. | ||
*/ | ||
export type FilterIntervalExtremum = number | null | undefined; | ||
export type FilterInterval = [FilterIntervalExtremum, FilterIntervalExtremum]; | ||
export type FilterIntervalComplete = [number, number]; | ||
export type StringSearchOptions = { | ||
useRegExp?: boolean; | ||
mustStart?: boolean; | ||
mustEnd?: boolean; | ||
caseSensitive?: boolean; | ||
keepSpecialCharacters?: boolean; | ||
}; | ||
/****************************************************************************** | ||
@@ -120,0 +60,0 @@ * GROUPING |
@@ -1,6 +0,4 @@ | ||
export * from './widget-source.js'; | ||
export * from './widget-base-source.js'; | ||
export * from './widget-query-source.js'; | ||
export * from './widget-remote-source.js'; | ||
export * from './widget-table-source.js'; | ||
export * from './widget-tileset-source.js'; | ||
export * from './types.js'; |
@@ -11,3 +11,3 @@ import { SpatialFilterPolyfillMode, TileResolution } from '../sources/types'; | ||
} | ||
/** Common options for {@link WidgetRemoteSource} requests. */ | ||
/** Common options for {@link WidgetBaseSource} requests. */ | ||
interface BaseRequestOptions { | ||
@@ -21,3 +21,3 @@ spatialFilter?: SpatialFilter; | ||
} | ||
/** Options for {@link WidgetRemoteSource#getCategories}. */ | ||
/** Options for {@link WidgetBaseSource#getCategories}. */ | ||
export interface CategoryRequestOptions extends BaseRequestOptions { | ||
@@ -27,7 +27,5 @@ column: string; | ||
operationColumn?: string; | ||
/** Local only. */ | ||
joinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum'; | ||
} | ||
/** | ||
* Options for {@link WidgetRemoteSource#getFeatures}. | ||
* Options for {@link WidgetBaseSource#getFeatures}. | ||
* @experimental | ||
@@ -68,10 +66,9 @@ * @internal | ||
} | ||
/** Options for {@link WidgetRemoteSource#getFormula}. */ | ||
/** Options for {@link WidgetBaseSource#getFormula}. */ | ||
export interface FormulaRequestOptions extends BaseRequestOptions { | ||
column: string; | ||
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum' | 'custom'; | ||
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum'; | ||
operationExp?: string; | ||
joinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum'; | ||
} | ||
/** Options for {@link WidgetRemoteSource#getHistogram}. */ | ||
/** Options for {@link WidgetBaseSource#getHistogram}. */ | ||
export interface HistogramRequestOptions extends BaseRequestOptions { | ||
@@ -81,10 +78,8 @@ column: string; | ||
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum'; | ||
/** Local only. */ | ||
joinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum'; | ||
} | ||
/** Options for {@link WidgetRemoteSource#getRange}. */ | ||
/** Options for {@link WidgetBaseSource#getRange}. */ | ||
export interface RangeRequestOptions extends BaseRequestOptions { | ||
column: string; | ||
} | ||
/** Options for {@link WidgetRemoteSource#getScatter}. */ | ||
/** Options for {@link WidgetBaseSource#getScatter}. */ | ||
export interface ScatterRequestOptions extends BaseRequestOptions { | ||
@@ -96,3 +91,3 @@ xAxisColumn: string; | ||
} | ||
/** Options for {@link WidgetRemoteSource#getTable}. */ | ||
/** Options for {@link WidgetBaseSource#getTable}. */ | ||
export interface TableRequestOptions extends BaseRequestOptions { | ||
@@ -105,11 +100,7 @@ columns: string[]; | ||
limit?: number; | ||
/** Local only. */ | ||
searchFilterColumn?: string; | ||
/** Local only. */ | ||
searchFilterText?: string; | ||
} | ||
/** Options for {@link WidgetRemoteSource#getTimeSeries}. */ | ||
/** Options for {@link WidgetBaseSource#getTimeSeries}. */ | ||
export interface TimeSeriesRequestOptions extends BaseRequestOptions { | ||
column: string; | ||
stepSize: GroupDateType; | ||
stepSize?: GroupDateType; | ||
stepMultiplier?: number; | ||
@@ -127,3 +118,3 @@ operation?: 'count' | 'avg' | 'min' | 'max' | 'sum'; | ||
/** | ||
* Response from {@link WidgetRemoteSource#getFeatures}. | ||
* Response from {@link WidgetBaseSource#getFeatures}. | ||
* @experimental | ||
@@ -135,7 +126,7 @@ * @internal | ||
}; | ||
/** Response from {@link WidgetRemoteSource#getFormula}. */ | ||
/** Response from {@link WidgetBaseSource#getFormula}. */ | ||
export type FormulaResponse = { | ||
value: number | null; | ||
value: number; | ||
}; | ||
/** Response from {@link WidgetRemoteSource#getCategories}. */ | ||
/** Response from {@link WidgetBaseSource#getCategories}. */ | ||
export type CategoryResponse = { | ||
@@ -145,8 +136,8 @@ name: string; | ||
}[]; | ||
/** Response from {@link WidgetRemoteSource#getRange}. */ | ||
/** Response from {@link WidgetBaseSource#getRange}. */ | ||
export type RangeResponse = { | ||
min: number; | ||
max: number; | ||
} | null; | ||
/** Response from {@link WidgetRemoteSource#getTable}. */ | ||
}; | ||
/** Response from {@link WidgetBaseSource#getTable}. */ | ||
export type TableResponse = { | ||
@@ -156,5 +147,5 @@ totalCount: number; | ||
}; | ||
/** Response from {@link WidgetRemoteSource#getScatter}. */ | ||
/** Response from {@link WidgetBaseSource#getScatter}. */ | ||
export type ScatterResponse = [number, number][]; | ||
/** Response from {@link WidgetRemoteSource#getTimeSeries}. */ | ||
/** Response from {@link WidgetBaseSource#getTimeSeries}. */ | ||
export type TimeSeriesResponse = { | ||
@@ -165,6 +156,6 @@ rows: { | ||
}[]; | ||
categories?: string[]; | ||
categories: string[]; | ||
}; | ||
/** Response from {@link WidgetRemoteSource#getHistogram}. */ | ||
/** Response from {@link WidgetBaseSource#getHistogram}. */ | ||
export type HistogramResponse = number[]; | ||
export {}; |
import { H3QuerySourceOptions, QuadbinQuerySourceOptions, VectorQuerySourceOptions } from '../sources/index.js'; | ||
import { WidgetRemoteSource, WidgetRemoteSourceProps } from './widget-remote-source.js'; | ||
import { WidgetBaseSource, WidgetBaseSourceProps } from './widget-base-source.js'; | ||
import { ModelSource } from '../models/model.js'; | ||
@@ -30,5 +30,5 @@ type LayerQuerySourceOptions = Omit<VectorQuerySourceOptions, 'filters'> | Omit<H3QuerySourceOptions, 'filters'> | Omit<QuadbinQuerySourceOptions, 'filters'>; | ||
*/ | ||
export declare class WidgetQuerySource extends WidgetRemoteSource<LayerQuerySourceOptions & WidgetRemoteSourceProps> { | ||
export declare class WidgetQuerySource extends WidgetBaseSource<LayerQuerySourceOptions & WidgetBaseSourceProps> { | ||
protected getModelSource(owner: string): ModelSource; | ||
} | ||
export {}; |
import { H3TableSourceOptions, QuadbinTableSourceOptions, VectorTableSourceOptions } from '../sources/index.js'; | ||
import { WidgetRemoteSource, WidgetRemoteSourceProps } from './widget-remote-source.js'; | ||
import { WidgetBaseSource, WidgetBaseSourceProps } from './widget-base-source.js'; | ||
import { ModelSource } from '../models/model.js'; | ||
@@ -30,5 +30,5 @@ type LayerTableSourceOptions = Omit<VectorTableSourceOptions, 'filters'> | Omit<H3TableSourceOptions, 'filters'> | Omit<QuadbinTableSourceOptions, 'filters'>; | ||
*/ | ||
export declare class WidgetTableSource extends WidgetRemoteSource<LayerTableSourceOptions & WidgetRemoteSourceProps> { | ||
export declare class WidgetTableSource extends WidgetBaseSource<LayerTableSourceOptions & WidgetBaseSourceProps> { | ||
protected getModelSource(owner: string): ModelSource; | ||
} | ||
export {}; |
@@ -7,2 +7,6 @@ # CHANGELOG | ||
### 0.4.6 | ||
- chore: Add repository and homepage in npm package metadata | ||
### 0.4.5 | ||
@@ -9,0 +13,0 @@ |
{ | ||
"name": "@carto/api-client", | ||
"description": "Client library for CARTO APIs and framework-agnostic CARTO + deck.gl applications", | ||
"repository": "github:CartoDB/carto-api-client", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/CartoDB/carto-api-client.git" | ||
}, | ||
"homepage": "https://github.com/CartoDB/carto-api-client#readme", | ||
"author": "Don McCurdy <donmccurdy@carto.com>", | ||
"packageManager": "yarn@4.3.1", | ||
"version": "0.4.6-0", | ||
"version": "0.4.6", | ||
"license": "MIT", | ||
@@ -55,13 +59,8 @@ "publishConfig": { | ||
"dependencies": { | ||
"@loaders.gl/schema": "^4.3.3", | ||
"@turf/bbox-clip": "^7.1.0", | ||
"@turf/bbox-polygon": "^7.1.0", | ||
"@turf/boolean-intersects": "^7.1.0", | ||
"@turf/boolean-within": "^7.1.0", | ||
"@turf/helpers": "^7.1.0", | ||
"@turf/intersect": "^7.1.0", | ||
"@turf/invariant": "^7.1.0", | ||
"@turf/union": "^7.1.0", | ||
"@types/geojson": "^7946.0.15", | ||
"h3-js": "4.1.0" | ||
"@types/geojson": "^7946.0.15" | ||
}, | ||
@@ -79,8 +78,8 @@ "devDependencies": { | ||
"@loaders.gl/core": "^4.3.3", | ||
"@luma.gl/core": "9.0.27", | ||
"@luma.gl/engine": "9.0.27", | ||
"@luma.gl/core": "9.0.28", | ||
"@luma.gl/engine": "9.0.28", | ||
"@types/json-schema": "^7.0.15", | ||
"@types/react": "^18.3.18", | ||
"@types/semver": "^7.5.8", | ||
"@vitest/coverage-istanbul": "^2.1.8", | ||
"@vitest/coverage-istanbul": "^3.0.2", | ||
"@webcomponents/webcomponentsjs": "^2.8.0", | ||
@@ -96,3 +95,2 @@ "concurrently": "^9.1.2", | ||
"semver": "^7.6.3", | ||
"thenby": "^1.3.4", | ||
"typescript": "~5.7.3", | ||
@@ -104,4 +102,3 @@ "vite": "^6.0.7", | ||
"rollup": "^4.20.0" | ||
}, | ||
"stableVersion": "0.4.5" | ||
} | ||
} |
@@ -34,26 +34,1 @@ /** | ||
export const DEFAULT_API_BASE_URL = 'https://gcp-us-east1.api.carto.com'; | ||
/** @internalRemarks Source: @carto/react-core */ | ||
export enum TileFormat { | ||
MVT = 'mvt', | ||
JSON = 'json', | ||
GEOJSON = 'geojson', | ||
BINARY = 'binary', | ||
} | ||
/** @internalRemarks Source: @carto/react-core */ | ||
export enum SpatialIndex { | ||
H3 = 'h3', | ||
S2 = 's2', | ||
QUADBIN = 'quadbin', | ||
} | ||
/** @internalRemarks Source: @carto/react-core */ | ||
export enum Provider { | ||
BIGQUERY = 'bigquery', | ||
REDSHIFT = 'redshift', | ||
POSTGRES = 'postgres', | ||
SNOWFLAKE = 'snowflake', | ||
DATABRICKS = 'databricks', | ||
DATABRICKS_REST = 'databricksRest', | ||
} |
@@ -20,6 +20,2 @@ export * from './client.js'; | ||
// For unit testing only. | ||
export * from './filters/index.js'; | ||
export * from './operations/index.js'; | ||
export * from './utils/makeIntervalComplete.js'; | ||
export * from './utils/transformToTileCoords.js'; | ||
export {_getHexagonResolution} from './spatial-index.js'; |
export {executeModel} from './model.js'; | ||
export type {Model, ModelSource} from './model.js'; | ||
export type {Model} from './model.js'; | ||
export type {ModelRequestOptions} from './common.js'; |
@@ -5,7 +5,2 @@ // deck.gl | ||
import {getTileFormat} from '../utils/getTileFormat'; | ||
import { | ||
WidgetTilesetSource, | ||
WidgetTilesetSourceResult, | ||
} from '../widget-sources'; | ||
import {baseSource} from './base-source'; | ||
@@ -21,4 +16,3 @@ import type { | ||
export type H3TilesetSourceResponse = TilejsonResult & | ||
WidgetTilesetSourceResult; | ||
export type H3TilesetSourceResponse = TilejsonResult; | ||
@@ -28,16 +22,10 @@ export const h3TilesetSource = async function ( | ||
): Promise<H3TilesetSourceResponse> { | ||
const {tableName, spatialDataColumn = 'h3'} = options; | ||
const {tableName} = options; | ||
const urlParameters: UrlParameters = {name: tableName}; | ||
return baseSource<UrlParameters>('tileset', options, urlParameters).then( | ||
(result) => ({ | ||
...(result as TilejsonResult), | ||
widgetSource: new WidgetTilesetSource({ | ||
...options, | ||
tileFormat: getTileFormat(result as TilejsonResult), | ||
spatialDataColumn, | ||
spatialDataType: 'h3', | ||
}), | ||
}) | ||
return baseSource<UrlParameters>( | ||
'tileset', | ||
options, | ||
urlParameters | ||
) as Promise<H3TilesetSourceResponse>; | ||
}; |
@@ -55,3 +55,3 @@ // deck.gl | ||
export {rasterSource} from './raster-source'; | ||
export type {RasterSourceOptions} from './raster-source'; | ||
export type {RasterSourceOptions, RasterSourceResponse} from './raster-source'; | ||
@@ -58,0 +58,0 @@ export {quadbinQuerySource} from './quadbin-query-source'; |
@@ -5,7 +5,2 @@ // deck.gl | ||
import {getTileFormat} from '../utils/getTileFormat'; | ||
import { | ||
WidgetTilesetSource, | ||
WidgetTilesetSourceResult, | ||
} from '../widget-sources'; | ||
import {baseSource} from './base-source'; | ||
@@ -21,4 +16,3 @@ import type { | ||
export type QuadbinTilesetSourceResponse = TilejsonResult & | ||
WidgetTilesetSourceResult; | ||
export type QuadbinTilesetSourceResponse = TilejsonResult; | ||
@@ -28,16 +22,10 @@ export const quadbinTilesetSource = async function ( | ||
): Promise<QuadbinTilesetSourceResponse> { | ||
const {tableName, spatialDataColumn = 'quadbin'} = options; | ||
const {tableName} = options; | ||
const urlParameters: UrlParameters = {name: tableName}; | ||
return baseSource<UrlParameters>('tileset', options, urlParameters).then( | ||
(result) => ({ | ||
...(result as TilejsonResult), | ||
widgetSource: new WidgetTilesetSource({ | ||
...options, | ||
tileFormat: getTileFormat(result as TilejsonResult), | ||
spatialDataColumn, | ||
spatialDataType: 'quadbin', | ||
}), | ||
}) | ||
return baseSource<UrlParameters>( | ||
'tileset', | ||
options, | ||
urlParameters | ||
) as Promise<QuadbinTilesetSourceResponse>; | ||
}; |
@@ -31,3 +31,2 @@ // deck.gl | ||
} | ||
return baseSource<UrlParameters>( | ||
@@ -34,0 +33,0 @@ 'raster', |
@@ -6,7 +6,4 @@ // deck.gl | ||
/* eslint-disable camelcase */ | ||
import {DEFAULT_TILE_RESOLUTION} from '../constants-internal.js'; | ||
import { | ||
DEFAULT_GEO_COLUMN, | ||
DEFAULT_TILE_RESOLUTION, | ||
} from '../constants-internal.js'; | ||
import { | ||
WidgetQuerySource, | ||
@@ -50,3 +47,3 @@ WidgetQuerySourceResult, | ||
filters, | ||
spatialDataColumn = DEFAULT_GEO_COLUMN, | ||
spatialDataColumn = 'geom', | ||
sqlQuery, | ||
@@ -53,0 +50,0 @@ tileResolution = DEFAULT_TILE_RESOLUTION, |
@@ -6,7 +6,4 @@ // deck.gl | ||
/* eslint-disable camelcase */ | ||
import {DEFAULT_TILE_RESOLUTION} from '../constants-internal.js'; | ||
import { | ||
DEFAULT_GEO_COLUMN, | ||
DEFAULT_TILE_RESOLUTION, | ||
} from '../constants-internal.js'; | ||
import { | ||
WidgetTableSource, | ||
@@ -49,3 +46,3 @@ WidgetTableSourceResult, | ||
filters, | ||
spatialDataColumn = DEFAULT_GEO_COLUMN, | ||
spatialDataColumn = 'geom', | ||
tableName, | ||
@@ -52,0 +49,0 @@ tileResolution = DEFAULT_TILE_RESOLUTION, |
@@ -5,8 +5,2 @@ // deck.gl | ||
import {DEFAULT_GEO_COLUMN} from '../constants-internal'; | ||
import {getTileFormat} from '../utils/getTileFormat'; | ||
import { | ||
WidgetTilesetSource, | ||
WidgetTilesetSourceResult, | ||
} from '../widget-sources'; | ||
import {baseSource} from './base-source'; | ||
@@ -22,4 +16,3 @@ import type { | ||
export type VectorTilesetSourceResponse = TilejsonResult & | ||
WidgetTilesetSourceResult; | ||
export type VectorTilesetSourceResponse = TilejsonResult; | ||
@@ -29,16 +22,10 @@ export const vectorTilesetSource = async function ( | ||
): Promise<VectorTilesetSourceResponse> { | ||
const {tableName, spatialDataColumn = DEFAULT_GEO_COLUMN} = options; | ||
const {tableName} = options; | ||
const urlParameters: UrlParameters = {name: tableName}; | ||
return baseSource<UrlParameters>('tileset', options, urlParameters).then( | ||
(result) => ({ | ||
...(result as TilejsonResult), | ||
widgetSource: new WidgetTilesetSource({ | ||
...options, | ||
tileFormat: getTileFormat(result as TilejsonResult), | ||
spatialDataColumn, | ||
spatialDataType: 'geo', | ||
}), | ||
}) | ||
return baseSource<UrlParameters>( | ||
'tileset', | ||
options, | ||
urlParameters | ||
) as Promise<VectorTilesetSourceResponse>; | ||
}; |
@@ -43,3 +43,3 @@ import { | ||
const hexagonResolution = | ||
getHexagonResolution(viewState, tileSize) + aggregationResLevelOffset; | ||
_getHexagonResolution(viewState, tileSize) + aggregationResLevelOffset; | ||
@@ -92,6 +92,9 @@ return Math.min(hexagonResolution, maxSpatialFiltersResolution); | ||
// Resolution conversion function. Takes a WebMercatorViewport and returns | ||
// a H3 resolution such that the screen space size of the hexagons is | ||
// similar | ||
export function getHexagonResolution( | ||
/** | ||
* Resolution conversion function. Takes a WebMercatorViewport and returns | ||
* a H3 resolution such that the screen space size of the hexagons is | ||
* "similar" to the given tileSize on screen. Intended for use with deck.gl. | ||
* @internal | ||
*/ | ||
export function _getHexagonResolution( | ||
viewport: {zoom: number; latitude: number}, | ||
@@ -98,0 +101,0 @@ tileSize: number |
@@ -63,7 +63,1 @@ /****************************************************************************** | ||
>; | ||
/****************************************************************************** | ||
* LOCAL CALCULATIONS | ||
*/ | ||
export type FeatureData = Record<string, unknown>; |
import type {FilterType} from './constants.js'; | ||
import type {Polygon, MultiPolygon, Feature} from 'geojson'; | ||
import type {BinaryFeature, BinaryFeatureCollection} from '@loaders.gl/schema'; | ||
import type {Polygon, MultiPolygon} from 'geojson'; | ||
@@ -15,39 +14,2 @@ /****************************************************************************** | ||
/** | ||
* Alias for GeoJSON 'BBox' type, semantically representing a viewport. | ||
* Order of values is "west", "south", "east", "north". | ||
*/ | ||
export type Viewport = [number, number, number, number]; | ||
/** | ||
* Subset of deck.gl's Tile2DHeader type, containing only the properties | ||
* required for local widget calculations. Deeper dependencies on deck.gl | ||
* APIs should be minimized within this library: @deck.gl/carto depends | ||
* on the API client, not the other way around. | ||
* @internalRemarks Source: @deck.gl/geo-layers | ||
*/ | ||
export type Tile = { | ||
index: {x: number; y: number; z: number}; | ||
id: string; | ||
content: unknown; | ||
zoom: number; | ||
bbox: {west: number; east: number; north: number; south: number}; | ||
isVisible: boolean; | ||
data?: BinaryFeatureCollection; | ||
}; | ||
/** Subset of deck.gl's Tile2DHeader type, for spatial indexes. */ | ||
export type SpatialIndexTile = Tile & { | ||
data?: (Feature & {id: bigint})[]; | ||
}; | ||
/** @internalRemarks Source: @deck.gl/carto */ | ||
export type Raster = { | ||
blockSize: number; | ||
cells: { | ||
numericProps: BinaryFeature['numericProps']; | ||
properties: BinaryFeature['properties']; | ||
}; | ||
}; | ||
/****************************************************************************** | ||
@@ -91,7 +53,3 @@ * AGGREGATION | ||
[FilterType.TIME]?: {owner?: string; values: number[][]}; | ||
[FilterType.STRING_SEARCH]?: { | ||
owner?: string; | ||
values: string[]; | ||
params?: StringSearchOptions; | ||
}; | ||
[FilterType.STRING_SEARCH]?: {owner?: string; values: string[]}; | ||
} | ||
@@ -102,18 +60,2 @@ | ||
/** | ||
* Type for minimum or maximum value of an interval. Values 'null' and | ||
* 'undefined' are intentionally allowed, and represent an unbounded value. | ||
*/ | ||
export type FilterIntervalExtremum = number | null | undefined; | ||
export type FilterInterval = [FilterIntervalExtremum, FilterIntervalExtremum]; | ||
export type FilterIntervalComplete = [number, number]; | ||
export type StringSearchOptions = { | ||
useRegExp?: boolean; | ||
mustStart?: boolean; | ||
mustEnd?: boolean; | ||
caseSensitive?: boolean; | ||
keepSpecialCharacters?: boolean; | ||
}; | ||
/****************************************************************************** | ||
@@ -120,0 +62,0 @@ * GROUPING |
@@ -1,6 +0,4 @@ | ||
export * from './widget-source.js'; | ||
export * from './widget-base-source.js'; | ||
export * from './widget-query-source.js'; | ||
export * from './widget-remote-source.js'; | ||
export * from './widget-table-source.js'; | ||
export * from './widget-tileset-source.js'; | ||
export * from './types.js'; |
@@ -8,3 +8,2 @@ import {SpatialFilterPolyfillMode, TileResolution} from '../sources/types'; | ||
} from '../types'; | ||
import type {WidgetRemoteSource} from './widget-remote-source'; | ||
@@ -21,3 +20,3 @@ /****************************************************************************** | ||
/** Common options for {@link WidgetRemoteSource} requests. */ | ||
/** Common options for {@link WidgetBaseSource} requests. */ | ||
interface BaseRequestOptions { | ||
@@ -32,3 +31,3 @@ spatialFilter?: SpatialFilter; | ||
/** Options for {@link WidgetRemoteSource#getCategories}. */ | ||
/** Options for {@link WidgetBaseSource#getCategories}. */ | ||
export interface CategoryRequestOptions extends BaseRequestOptions { | ||
@@ -38,8 +37,6 @@ column: string; | ||
operationColumn?: string; | ||
/** Local only. */ | ||
joinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum'; | ||
} | ||
/** | ||
* Options for {@link WidgetRemoteSource#getFeatures}. | ||
* Options for {@link WidgetBaseSource#getFeatures}. | ||
* @experimental | ||
@@ -86,11 +83,10 @@ * @internal | ||
/** Options for {@link WidgetRemoteSource#getFormula}. */ | ||
/** Options for {@link WidgetBaseSource#getFormula}. */ | ||
export interface FormulaRequestOptions extends BaseRequestOptions { | ||
column: string; | ||
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum' | 'custom'; | ||
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum'; | ||
operationExp?: string; | ||
joinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum'; | ||
} | ||
/** Options for {@link WidgetRemoteSource#getHistogram}. */ | ||
/** Options for {@link WidgetBaseSource#getHistogram}. */ | ||
export interface HistogramRequestOptions extends BaseRequestOptions { | ||
@@ -100,7 +96,5 @@ column: string; | ||
operation?: 'count' | 'avg' | 'min' | 'max' | 'sum'; | ||
/** Local only. */ | ||
joinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum'; | ||
} | ||
/** Options for {@link WidgetRemoteSource#getRange}. */ | ||
/** Options for {@link WidgetBaseSource#getRange}. */ | ||
export interface RangeRequestOptions extends BaseRequestOptions { | ||
@@ -110,3 +104,3 @@ column: string; | ||
/** Options for {@link WidgetRemoteSource#getScatter}. */ | ||
/** Options for {@link WidgetBaseSource#getScatter}. */ | ||
export interface ScatterRequestOptions extends BaseRequestOptions { | ||
@@ -119,3 +113,3 @@ xAxisColumn: string; | ||
/** Options for {@link WidgetRemoteSource#getTable}. */ | ||
/** Options for {@link WidgetBaseSource#getTable}. */ | ||
export interface TableRequestOptions extends BaseRequestOptions { | ||
@@ -128,12 +122,8 @@ columns: string[]; | ||
limit?: number; | ||
/** Local only. */ | ||
searchFilterColumn?: string; | ||
/** Local only. */ | ||
searchFilterText?: string; | ||
} | ||
/** Options for {@link WidgetRemoteSource#getTimeSeries}. */ | ||
/** Options for {@link WidgetBaseSource#getTimeSeries}. */ | ||
export interface TimeSeriesRequestOptions extends BaseRequestOptions { | ||
column: string; | ||
stepSize: GroupDateType; | ||
stepSize?: GroupDateType; | ||
stepMultiplier?: number; | ||
@@ -153,3 +143,3 @@ operation?: 'count' | 'avg' | 'min' | 'max' | 'sum'; | ||
/** | ||
* Response from {@link WidgetRemoteSource#getFeatures}. | ||
* Response from {@link WidgetBaseSource#getFeatures}. | ||
* @experimental | ||
@@ -160,12 +150,12 @@ * @internal | ||
/** Response from {@link WidgetRemoteSource#getFormula}. */ | ||
export type FormulaResponse = {value: number | null}; | ||
/** Response from {@link WidgetBaseSource#getFormula}. */ | ||
export type FormulaResponse = {value: number}; | ||
/** Response from {@link WidgetRemoteSource#getCategories}. */ | ||
/** Response from {@link WidgetBaseSource#getCategories}. */ | ||
export type CategoryResponse = {name: string; value: number}[]; | ||
/** Response from {@link WidgetRemoteSource#getRange}. */ | ||
export type RangeResponse = {min: number; max: number} | null; | ||
/** Response from {@link WidgetBaseSource#getRange}. */ | ||
export type RangeResponse = {min: number; max: number}; | ||
/** Response from {@link WidgetRemoteSource#getTable}. */ | ||
/** Response from {@link WidgetBaseSource#getTable}. */ | ||
export type TableResponse = { | ||
@@ -176,12 +166,12 @@ totalCount: number; | ||
/** Response from {@link WidgetRemoteSource#getScatter}. */ | ||
/** Response from {@link WidgetBaseSource#getScatter}. */ | ||
export type ScatterResponse = [number, number][]; | ||
/** Response from {@link WidgetRemoteSource#getTimeSeries}. */ | ||
/** Response from {@link WidgetBaseSource#getTimeSeries}. */ | ||
export type TimeSeriesResponse = { | ||
rows: {name: string; value: number}[]; | ||
categories?: string[]; | ||
categories: string[]; | ||
}; | ||
/** Response from {@link WidgetRemoteSource#getHistogram}. */ | ||
/** Response from {@link WidgetBaseSource#getHistogram}. */ | ||
export type HistogramResponse = number[]; |
@@ -6,6 +6,3 @@ import { | ||
} from '../sources/index.js'; | ||
import { | ||
WidgetRemoteSource, | ||
WidgetRemoteSourceProps, | ||
} from './widget-remote-source.js'; | ||
import {WidgetBaseSource, WidgetBaseSourceProps} from './widget-base-source.js'; | ||
import {ModelSource} from '../models/model.js'; | ||
@@ -42,4 +39,4 @@ | ||
*/ | ||
export class WidgetQuerySource extends WidgetRemoteSource< | ||
LayerQuerySourceOptions & WidgetRemoteSourceProps | ||
export class WidgetQuerySource extends WidgetBaseSource< | ||
LayerQuerySourceOptions & WidgetBaseSourceProps | ||
> { | ||
@@ -46,0 +43,0 @@ protected override getModelSource(owner: string): ModelSource { |
@@ -6,6 +6,3 @@ import { | ||
} from '../sources/index.js'; | ||
import { | ||
WidgetRemoteSource, | ||
WidgetRemoteSourceProps, | ||
} from './widget-remote-source.js'; | ||
import {WidgetBaseSource, WidgetBaseSourceProps} from './widget-base-source.js'; | ||
import {ModelSource} from '../models/model.js'; | ||
@@ -42,4 +39,4 @@ | ||
*/ | ||
export class WidgetTableSource extends WidgetRemoteSource< | ||
LayerTableSourceOptions & WidgetRemoteSourceProps | ||
export class WidgetTableSource extends WidgetBaseSource< | ||
LayerTableSourceOptions & WidgetBaseSourceProps | ||
> { | ||
@@ -46,0 +43,0 @@ protected override getModelSource(owner: string): ModelSource { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
6
29
1
0
519552
85
8005
- Removed@loaders.gl/schema@^4.3.3
- Removed@turf/boolean-intersects@^7.1.0
- Removed@turf/boolean-within@^7.1.0
- Removed@turf/intersect@^7.1.0
- Removedh3-js@4.1.0
- Removed@loaders.gl/core@4.3.3(transitive)
- Removed@loaders.gl/loader-utils@4.3.3(transitive)
- Removed@loaders.gl/schema@4.3.3(transitive)
- Removed@loaders.gl/worker-utils@4.3.3(transitive)
- Removed@probe.gl/env@4.1.0(transitive)
- Removed@probe.gl/log@4.1.0(transitive)
- Removed@probe.gl/stats@4.1.0(transitive)
- Removed@turf/bbox@7.2.0(transitive)
- Removed@turf/boolean-disjoint@7.2.0(transitive)
- Removed@turf/boolean-intersects@7.2.0(transitive)
- Removed@turf/boolean-point-in-polygon@7.2.0(transitive)
- Removed@turf/boolean-point-on-line@7.2.0(transitive)
- Removed@turf/boolean-within@7.2.0(transitive)
- Removed@turf/intersect@7.2.0(transitive)
- Removed@turf/line-intersect@7.2.0(transitive)
- Removed@turf/polygon-to-line@7.2.0(transitive)
- Removedh3-js@4.1.0(transitive)
- Removedpoint-in-polygon-hao@1.2.4(transitive)
- Removedrobust-predicates@3.0.2(transitive)
- Removedsweepline-intersections@1.5.0(transitive)
- Removedtinyqueue@2.0.3(transitive)