@carto/api-client 0.4.3 → 0.5.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/api/query.d.ts +1 -1
  3. package/build/api-client.cjs +2388 -261
  4. package/build/api-client.cjs.map +1 -1
  5. package/build/api-client.modern.js +2237 -262
  6. package/build/api-client.modern.js.map +1 -1
  7. package/build/constants.d.ts +22 -0
  8. package/build/filters/Filter.d.ts +13 -0
  9. package/build/filters/FilterTypes.d.ts +3 -0
  10. package/build/filters/geosjonFeatures.d.ts +8 -0
  11. package/build/filters/index.d.ts +6 -0
  12. package/build/filters/tileFeatures.d.ts +20 -0
  13. package/build/filters/tileFeaturesGeometries.d.ts +13 -0
  14. package/build/filters/tileFeaturesSpatialIndex.d.ts +10 -0
  15. package/build/index.d.ts +4 -0
  16. package/build/models/index.d.ts +1 -1
  17. package/build/models/model.d.ts +7 -1
  18. package/build/operations/aggregation.d.ts +8 -0
  19. package/build/operations/applySorting.d.ts +20 -0
  20. package/build/operations/groupBy.d.ts +15 -0
  21. package/build/operations/groupByDate.d.ts +11 -0
  22. package/build/operations/histogram.d.ts +13 -0
  23. package/build/operations/index.d.ts +6 -0
  24. package/build/operations/scatterPlot.d.ts +14 -0
  25. package/build/sources/h3-tileset-source.d.ts +2 -1
  26. package/build/sources/index.d.ts +1 -1
  27. package/build/sources/quadbin-tileset-source.d.ts +2 -1
  28. package/build/sources/types.d.ts +36 -41
  29. package/build/sources/vector-tileset-source.d.ts +2 -1
  30. package/build/spatial-index.d.ts +8 -0
  31. package/build/types-internal.d.ts +4 -0
  32. package/build/types.d.ts +61 -1
  33. package/build/utils/dateUtils.d.ts +10 -0
  34. package/build/utils/getTileFormat.d.ts +3 -0
  35. package/build/utils/makeIntervalComplete.d.ts +2 -0
  36. package/build/utils/transformTileCoordsToWGS84.d.ts +8 -0
  37. package/build/utils/transformToTileCoords.d.ts +9 -0
  38. package/build/utils.d.ts +1 -1
  39. package/build/widget-sources/index.d.ts +2 -1
  40. package/build/widget-sources/types.d.ts +40 -23
  41. package/build/widget-sources/widget-query-source.d.ts +2 -2
  42. package/build/widget-sources/widget-remote-source.d.ts +18 -0
  43. package/build/widget-sources/{widget-base-source.d.ts → widget-source.d.ts} +16 -41
  44. package/build/widget-sources/widget-table-source.d.ts +2 -2
  45. package/build/widget-sources/widget-tileset-source.d.ts +67 -0
  46. package/package.json +36 -35
  47. package/src/api/query.ts +1 -2
  48. package/src/constants.ts +25 -0
  49. package/src/filters/Filter.ts +169 -0
  50. package/src/filters/FilterTypes.ts +109 -0
  51. package/src/filters/geosjonFeatures.ts +32 -0
  52. package/src/filters/index.ts +6 -0
  53. package/src/filters/tileFeatures.ts +56 -0
  54. package/src/filters/tileFeaturesGeometries.ts +444 -0
  55. package/src/filters/tileFeaturesSpatialIndex.ts +119 -0
  56. package/src/index.ts +6 -0
  57. package/src/models/index.ts +1 -1
  58. package/src/models/model.ts +47 -24
  59. package/src/operations/aggregation.ts +154 -0
  60. package/src/operations/applySorting.ts +109 -0
  61. package/src/operations/groupBy.ts +59 -0
  62. package/src/operations/groupByDate.ts +98 -0
  63. package/src/operations/histogram.ts +66 -0
  64. package/src/operations/index.ts +6 -0
  65. package/src/operations/scatterPlot.ts +50 -0
  66. package/src/sources/h3-query-source.ts +7 -1
  67. package/src/sources/h3-table-source.ts +6 -1
  68. package/src/sources/h3-tileset-source.ts +18 -6
  69. package/src/sources/index.ts +1 -1
  70. package/src/sources/quadbin-query-source.ts +6 -1
  71. package/src/sources/quadbin-table-source.ts +6 -1
  72. package/src/sources/quadbin-tileset-source.ts +18 -6
  73. package/src/sources/raster-source.ts +1 -0
  74. package/src/sources/types.ts +41 -45
  75. package/src/sources/vector-query-source.ts +10 -3
  76. package/src/sources/vector-table-source.ts +10 -3
  77. package/src/sources/vector-tileset-source.ts +19 -6
  78. package/src/spatial-index.ts +111 -0
  79. package/src/types-internal.ts +6 -0
  80. package/src/types.ts +60 -2
  81. package/src/utils/dateUtils.ts +28 -0
  82. package/src/utils/getTileFormat.ts +9 -0
  83. package/src/utils/makeIntervalComplete.ts +17 -0
  84. package/src/utils/transformTileCoordsToWGS84.ts +77 -0
  85. package/src/utils/transformToTileCoords.ts +85 -0
  86. package/src/utils.ts +9 -6
  87. package/src/widget-sources/index.ts +2 -1
  88. package/src/widget-sources/types.ts +42 -23
  89. package/src/widget-sources/widget-query-source.ts +6 -3
  90. package/src/widget-sources/{widget-base-source.ts → widget-remote-source.ts} +169 -144
  91. package/src/widget-sources/widget-source.ts +160 -0
  92. package/src/widget-sources/widget-table-source.ts +6 -3
  93. package/src/widget-sources/widget-tileset-source.ts +396 -0
@@ -29,3 +29,25 @@ export declare enum ApiVersion {
29
29
  }
30
30
  /** @internalRemarks Source: @carto/constants, @deck.gl/carto */
31
31
  export declare const DEFAULT_API_BASE_URL = "https://gcp-us-east1.api.carto.com";
32
+ /** @internalRemarks Source: @carto/react-core */
33
+ export declare enum TileFormat {
34
+ MVT = "mvt",
35
+ JSON = "json",
36
+ GEOJSON = "geojson",
37
+ BINARY = "binary"
38
+ }
39
+ /** @internalRemarks Source: @carto/react-core */
40
+ export declare enum SpatialIndex {
41
+ H3 = "h3",
42
+ S2 = "s2",
43
+ QUADBIN = "quadbin"
44
+ }
45
+ /** @internalRemarks Source: @carto/react-core */
46
+ export declare enum Provider {
47
+ BIGQUERY = "bigquery",
48
+ REDSHIFT = "redshift",
49
+ POSTGRES = "postgres",
50
+ SNOWFLAKE = "snowflake",
51
+ DATABRICKS = "databricks",
52
+ DATABRICKS_REST = "databricksRest"
53
+ }
@@ -0,0 +1,13 @@
1
+ import { FilterLogicalOperator, Filters } from '../types';
2
+ import { Feature } from 'geojson';
3
+ import { FeatureData } from '../types-internal';
4
+ import { BinaryFeature } from '@loaders.gl/schema';
5
+ export declare function buildFeatureFilter({ filters, type, filtersLogicalOperator, }: {
6
+ filters?: Filters;
7
+ type?: 'number' | 'boolean';
8
+ filtersLogicalOperator?: FilterLogicalOperator;
9
+ }): (feature: Feature | FeatureData) => number | boolean;
10
+ export declare function applyFilters(features: FeatureData[], filters: Filters, filtersLogicalOperator: FilterLogicalOperator): FeatureData[];
11
+ export declare function buildBinaryFeatureFilter({ filters }: {
12
+ filters: Filters;
13
+ }): (() => number) | ((featureIdIdx: number, binaryData: BinaryFeature) => boolean);
@@ -0,0 +1,3 @@
1
+ import { FilterType } from '../constants';
2
+ export type FilterFunction = (filterValues: unknown[], featureValue: unknown, params?: Record<string, unknown>) => boolean;
3
+ export declare const filterFunctions: Record<FilterType, FilterFunction>;
@@ -0,0 +1,8 @@
1
+ import { FeatureCollection } from 'geojson';
2
+ import { SpatialFilter } from '..';
3
+ import { FeatureData } from '../types-internal';
4
+ export declare function geojsonFeatures({ geojson, spatialFilter, uniqueIdProperty, }: {
5
+ geojson: FeatureCollection;
6
+ spatialFilter: SpatialFilter;
7
+ uniqueIdProperty?: string;
8
+ }): FeatureData[];
@@ -0,0 +1,6 @@
1
+ export * from './Filter.js';
2
+ export * from './FilterTypes.js';
3
+ export * from './geosjonFeatures.js';
4
+ export * from './tileFeatures.js';
5
+ export * from './tileFeaturesGeometries.js';
6
+ export * from './tileFeaturesSpatialIndex.js';
@@ -0,0 +1,20 @@
1
+ import { SpatialFilter, Tile } from '../types';
2
+ import { TileFormat } from '../constants';
3
+ import { FeatureData } from '../types-internal';
4
+ import { SpatialDataType } from '../sources/types';
5
+ /** @internalRemarks Source: @carto/react-core */
6
+ export type TileFeatures = {
7
+ tiles: Tile[];
8
+ tileFormat: TileFormat;
9
+ spatialDataType: SpatialDataType;
10
+ spatialDataColumn?: string;
11
+ spatialFilter?: SpatialFilter;
12
+ uniqueIdProperty?: string;
13
+ options?: TileFeatureExtractOptions;
14
+ };
15
+ /** @internalRemarks Source: @carto/react-core */
16
+ export type TileFeatureExtractOptions = {
17
+ storeGeometry?: boolean;
18
+ };
19
+ /** @internalRemarks Source: @carto/react-core */
20
+ export declare function tileFeatures({ tiles, spatialFilter, uniqueIdProperty, tileFormat, spatialDataColumn, spatialDataType, options, }: TileFeatures): FeatureData[];
@@ -0,0 +1,13 @@
1
+ import { TileFormat } from '../constants.js';
2
+ import { SpatialFilter, Tile } from '../types.js';
3
+ import { FeatureData } from '../types-internal.js';
4
+ export declare const FEATURE_GEOM_PROPERTY = "__geomValue";
5
+ export declare function tileFeaturesGeometries({ tiles, tileFormat, spatialFilter, uniqueIdProperty, options, }: {
6
+ tiles: Tile[];
7
+ tileFormat?: TileFormat;
8
+ spatialFilter: SpatialFilter;
9
+ uniqueIdProperty?: string;
10
+ options?: {
11
+ storeGeometry?: boolean;
12
+ };
13
+ }): FeatureData[];
@@ -0,0 +1,10 @@
1
+ import { SpatialFilter, SpatialIndexTile } from '../types.js';
2
+ import { FeatureData } from '../types-internal.js';
3
+ import { SpatialDataType } from '../sources/types.js';
4
+ export type TileFeaturesSpatialIndexOptions = {
5
+ tiles: SpatialIndexTile[];
6
+ spatialFilter: SpatialFilter;
7
+ spatialDataColumn: string;
8
+ spatialDataType: SpatialDataType;
9
+ };
10
+ export declare function tileFeaturesSpatialIndex({ tiles, spatialFilter, spatialDataColumn, spatialDataType, }: TileFeaturesSpatialIndexOptions): FeatureData[];
package/build/index.d.ts CHANGED
@@ -8,3 +8,7 @@ export * from './types.js';
8
8
  export { APIErrorContext, APIRequestType, CartoAPIError, QueryOptions, buildPublicMapUrl, // Internal, but required for fetchMap().
9
9
  buildStatsUrl, // Internal, but required for fetchMap().
10
10
  query, requestWithParameters, } from './api/index.js';
11
+ export * from './filters/index.js';
12
+ export * from './operations/index.js';
13
+ export * from './utils/makeIntervalComplete.js';
14
+ export * from './utils/transformToTileCoords.js';
@@ -1,3 +1,3 @@
1
1
  export { executeModel } from './model.js';
2
- export type { Model } from './model.js';
2
+ export type { Model, ModelSource } from './model.js';
3
3
  export type { ModelRequestOptions } from './common.js';
@@ -1,6 +1,7 @@
1
1
  import { Filter, FilterLogicalOperator, MapType, QueryParameters, SpatialFilter } from '../types.js';
2
2
  import { ModelRequestOptions } from './common.js';
3
3
  import { ApiVersion } from '../constants.js';
4
+ import { SpatialDataType, SpatialFilterPolyfillMode } from '../sources/types.js';
4
5
  /** @internalRemarks Source: @carto/react-api */
5
6
  declare const AVAILABLE_MODELS: readonly ["category", "histogram", "formula", "pick", "timeseries", "range", "scatterplot", "table"];
6
7
  export type Model = (typeof AVAILABLE_MODELS)[number];
@@ -14,9 +15,14 @@ export interface ModelSource {
14
15
  data: string;
15
16
  filters?: Record<string, Filter>;
16
17
  filtersLogicalOperator?: FilterLogicalOperator;
17
- geoColumn?: string;
18
18
  spatialFilter?: SpatialFilter;
19
19
  queryParameters?: QueryParameters;
20
+ spatialDataColumn?: string;
21
+ spatialDataType?: SpatialDataType;
22
+ spatialFiltersResolution?: number;
23
+ spatialFiltersMode?: SpatialFilterPolyfillMode;
24
+ /** original resolution of the spatial index data as stored in the DW */
25
+ dataResolution?: number;
20
26
  }
21
27
  /**
22
28
  * Execute a SQL model request.
@@ -0,0 +1,8 @@
1
+ import { AggregationType } from '../types';
2
+ import { FeatureData } from '../types-internal';
3
+ /** @internalRemarks Source: @carto/react-core */
4
+ export type AggregationFunction = (values: unknown[] | FeatureData[], keys?: string[] | string, joinOperation?: AggregationType) => number;
5
+ /** @internalRemarks Source: @carto/react-core */
6
+ export declare const aggregationFunctions: Record<Exclude<AggregationType, 'custom'>, AggregationFunction>;
7
+ /** @internalRemarks Source: @carto/react-core */
8
+ export declare function aggregate(feature: FeatureData, keys?: string[], operation?: AggregationType): unknown;
@@ -0,0 +1,20 @@
1
+ import { SortDirection } from '../types';
2
+ import { FeatureData } from '../types-internal';
3
+ type SortColumns = string | string[] | object[];
4
+ interface SortOptions {
5
+ sortBy?: SortColumns;
6
+ sortByDirection?: SortDirection;
7
+ sortByColumnType?: 'number' | 'string' | 'date';
8
+ }
9
+ /**
10
+ * Apply sort structure to a collection of features
11
+ * @param features
12
+ * @param [sortOptions]
13
+ * @param [sortOptions.sortBy] - One or more columns to sort by
14
+ * @param [sortOptions.sortByDirection] - Direction by the columns will be sorted
15
+ * @param [sortOptions.sortByColumnType] - Column type
16
+ * @internal
17
+ * @internalRemarks Source: @carto/react-core
18
+ */
19
+ export declare function applySorting(features: FeatureData[], { sortBy, sortByDirection, sortByColumnType, }?: SortOptions): FeatureData[];
20
+ export {};
@@ -0,0 +1,15 @@
1
+ import { AggregationType } from '../types';
2
+ import { FeatureData } from '../types-internal';
3
+ /** @internalRemarks Source: @carto/react-core */
4
+ export type GroupByFeature = {
5
+ name: string;
6
+ value: number;
7
+ }[];
8
+ /** @internalRemarks Source: @carto/react-core */
9
+ export declare function groupValuesByColumn({ data, valuesColumns, joinOperation, keysColumn, operation, }: {
10
+ data: FeatureData[];
11
+ valuesColumns?: string[];
12
+ joinOperation?: AggregationType;
13
+ keysColumn: string;
14
+ operation: AggregationType;
15
+ }): GroupByFeature | null;
@@ -0,0 +1,11 @@
1
+ import { AggregationType, GroupDateType } from '../types.js';
2
+ import { GroupByFeature } from './groupBy.js';
3
+ /** @internalRemarks Source: @carto/react-core */
4
+ export declare function groupValuesByDateColumn({ data, valuesColumns, joinOperation, keysColumn, groupType, operation, }: {
5
+ data: Record<string, unknown>[];
6
+ valuesColumns?: string[];
7
+ joinOperation?: Exclude<AggregationType, 'custom'>;
8
+ keysColumn: string;
9
+ groupType: GroupDateType;
10
+ operation?: Exclude<AggregationType, 'custom'>;
11
+ }): GroupByFeature | null;
@@ -0,0 +1,13 @@
1
+ import { AggregationType } from '../types';
2
+ import { FeatureData } from '../types-internal';
3
+ /**
4
+ * Histogram computation.
5
+ * @internalRemarks Source: @carto/react-core
6
+ */
7
+ export declare function histogram({ data, valuesColumns, joinOperation, ticks, operation, }: {
8
+ data: FeatureData[];
9
+ valuesColumns?: string[];
10
+ joinOperation?: Exclude<AggregationType, 'custom'>;
11
+ ticks: number[];
12
+ operation: Exclude<AggregationType, 'custom'>;
13
+ }): number[];
@@ -0,0 +1,6 @@
1
+ export * from './aggregation.js';
2
+ export * from './applySorting.js';
3
+ export * from './groupBy.js';
4
+ export * from './groupByDate.js';
5
+ export * from './histogram.js';
6
+ export * from './scatterPlot.js';
@@ -0,0 +1,14 @@
1
+ import { FeatureData } from '../types-internal';
2
+ import { AggregationType } from '../types';
3
+ export type ScatterPlotFeature = [number, number][];
4
+ /**
5
+ * Filters invalid features and formats data.
6
+ * @internalRemarks Source: @carto/react-core
7
+ */
8
+ export declare function scatterPlot({ data, xAxisColumns, xAxisJoinOperation, yAxisColumns, yAxisJoinOperation, }: {
9
+ data: FeatureData[];
10
+ xAxisColumns: string[];
11
+ xAxisJoinOperation?: AggregationType;
12
+ yAxisColumns: string[];
13
+ yAxisJoinOperation?: AggregationType;
14
+ }): ScatterPlotFeature;
@@ -1,4 +1,5 @@
1
+ import { WidgetTilesetSourceResult } from '../widget-sources';
1
2
  import type { SourceOptions, TilejsonResult, TilesetSourceOptions } from './types';
2
3
  export type H3TilesetSourceOptions = SourceOptions & TilesetSourceOptions;
3
- export type H3TilesetSourceResponse = TilejsonResult;
4
+ export type H3TilesetSourceResponse = TilejsonResult & WidgetTilesetSourceResult;
4
5
  export declare const h3TilesetSource: (options: H3TilesetSourceOptions) => Promise<H3TilesetSourceResponse>;
@@ -11,7 +11,7 @@ export type { H3TableSourceOptions, H3TableSourceResponse, } from './h3-table-so
11
11
  export { h3TilesetSource } from './h3-tileset-source';
12
12
  export type { H3TilesetSourceOptions, H3TilesetSourceResponse, } from './h3-tileset-source';
13
13
  export { rasterSource } from './raster-source';
14
- export type { RasterSourceOptions, RasterSourceResponse } from './raster-source';
14
+ export type { RasterSourceOptions } from './raster-source';
15
15
  export { quadbinQuerySource } from './quadbin-query-source';
16
16
  export type { QuadbinQuerySourceOptions, QuadbinQuerySourceResponse, } from './quadbin-query-source';
17
17
  export { quadbinTableSource } from './quadbin-table-source';
@@ -1,4 +1,5 @@
1
+ import { WidgetTilesetSourceResult } from '../widget-sources';
1
2
  import type { SourceOptions, TilejsonResult, TilesetSourceOptions } from './types';
2
3
  export type QuadbinTilesetSourceOptions = SourceOptions & TilesetSourceOptions;
3
- export type QuadbinTilesetSourceResponse = TilejsonResult;
4
+ export type QuadbinTilesetSourceResponse = TilejsonResult & WidgetTilesetSourceResult;
4
5
  export declare const quadbinTilesetSource: (options: QuadbinTilesetSourceOptions) => Promise<QuadbinTilesetSourceResponse>;
@@ -38,6 +38,30 @@ export type SourceOptionalOptions = {
38
38
  * @default {@link DEFAULT_MAX_LENGTH_URL}
39
39
  */
40
40
  maxLengthURL?: number;
41
+ /**
42
+ * The column name and the type of geospatial support.
43
+ *
44
+ * If not present, defaults to `'geom'` for generic queries, `'quadbin'` for Quadbin sources and `'h3'` for H3 sources.
45
+ */
46
+ spatialDataColumn?: string;
47
+ /**
48
+ * The type of geospatial support. Defaults to `'geo'`.
49
+ */
50
+ spatialDataType?: SpatialDataType;
51
+ /**
52
+ * Relative resolution of a tile. Higher values increase density and data size. At `tileResolution = 1`, tile geometry is
53
+ * quantized to a 1024x1024 grid. Increasing or decreasing the resolution will increase or decrease the dimensions of
54
+ * the quantization grid proportionately.
55
+ *
56
+ * Supported `tileResolution` values, with corresponding grid sizes:
57
+ *
58
+ * - 0.25: 256x256
59
+ * - 0.5: 512x512
60
+ * - 1: 1024x1024
61
+ * - 2: 2048x2048
62
+ * - 4: 4096x4096
63
+ */
64
+ tileResolution?: TileResolution;
41
65
  /**
42
66
  * By default, local in-memory caching is enabled.
43
67
  */
@@ -73,6 +97,10 @@ export type AggregationOptions = {
73
97
  * @default 6 for quadbin and 4 for h3 sources
74
98
  */
75
99
  aggregationResLevel?: number;
100
+ /**
101
+ * Original resolution of the spatial index data as stored in the DW
102
+ */
103
+ dataResolution?: number;
76
104
  };
77
105
  export type FilterOptions = {
78
106
  /**
@@ -81,28 +109,8 @@ export type FilterOptions = {
81
109
  filters?: Filters;
82
110
  };
83
111
  export type QuerySourceOptions = {
84
- /**
85
- * The column name and the type of geospatial support.
86
- *
87
- * If not present, defaults to `'geom'` for generic queries, `'quadbin'` for Quadbin sources and `'h3'` for H3 sources.
88
- */
89
- spatialDataColumn?: string;
90
- /** SQL query. */
112
+ /** Full SQL query with query paremeter placeholders (if any). */
91
113
  sqlQuery: string;
92
- /**
93
- * Relative resolution of a tile. Higher values increase density and data size. At `tileResolution = 1`, tile geometry is
94
- * quantized to a 1024x1024 grid. Increasing or decreasing the resolution will increase or decrease the dimensions of
95
- * the quantization grid proportionately.
96
- *
97
- * Supported `tileResolution` values, with corresponding grid sizes:
98
- *
99
- * - 0.25: 256x256
100
- * - 0.5: 512x512
101
- * - 1: 1024x1024
102
- * - 2: 2048x2048
103
- * - 4: 4096x4096
104
- */
105
- tileResolution?: TileResolution;
106
114
  /**
107
115
  * Values for named or positional paramteres in the query.
108
116
  *
@@ -142,26 +150,6 @@ export type TableSourceOptions = {
142
150
  * Fully qualified name of table.
143
151
  */
144
152
  tableName: string;
145
- /**
146
- * The column name and the type of geospatial support.
147
- *
148
- * If not present, defaults to `'geom'` for generic tables, `'quadbin'` for Quadbin sources and `'h3'` for H3 sources.
149
- */
150
- spatialDataColumn?: string;
151
- /**
152
- * Relative resolution of a tile. Higher values increase density and data size. At `tileResolution = 1`, tile geometry is
153
- * quantized to a 1024x1024 grid. Increasing or decreasing the resolution will increase or decrease the dimensions of
154
- * the quantization grid proportionately.
155
- *
156
- * Supported `tileResolution` values, with corresponding grid sizes:
157
- *
158
- * - 0.25: 256x256
159
- * - 0.5: 512x512
160
- * - 1: 1024x1024
161
- * - 2: 2048x2048
162
- * - 4: 4096x4096
163
- */
164
- tileResolution?: TileResolution;
165
153
  /**
166
154
  * Comma-separated aggregation expressions. If assigned on a vector source, source is grouped by geometry and then aggregated.
167
155
  *
@@ -186,6 +174,13 @@ export type ColumnsOption = {
186
174
  columns?: string[];
187
175
  };
188
176
  export type SpatialDataType = 'geo' | 'h3' | 'quadbin';
177
+ /**
178
+ * Strategy used for covering spatial filter geometry with spatial indexes.
179
+ * See https://docs.carto.com/data-and-analysis/analytics-toolbox-for-bigquery/sql-reference/quadbin#quadbin_polyfill_mode
180
+ * or https://docs.carto.com/data-and-analysis/analytics-toolbox-for-bigquery/sql-reference/h3#h3_polyfill_mode for more information.
181
+ * @internalRemarks Source: cloud-native maps-api
182
+ * */
183
+ export type SpatialFilterPolyfillMode = 'center' | 'intersects' | 'contains';
189
184
  export type TilejsonMapInstantiation = MapInstantiation & {
190
185
  tilejson: {
191
186
  url: string[];
@@ -1,4 +1,5 @@
1
+ import { WidgetTilesetSourceResult } from '../widget-sources';
1
2
  import type { SourceOptions, TilesetSourceOptions, TilejsonResult } from './types';
2
3
  export type VectorTilesetSourceOptions = SourceOptions & TilesetSourceOptions;
3
- export type VectorTilesetSourceResponse = TilejsonResult;
4
+ export type VectorTilesetSourceResponse = TilejsonResult & WidgetTilesetSourceResult;
4
5
  export declare const vectorTilesetSource: (options: VectorTilesetSourceOptions) => Promise<VectorTilesetSourceResponse>;
@@ -0,0 +1,8 @@
1
+ import type { ModelSource } from './models/model';
2
+ import type { AggregationOptions } from './sources/types';
3
+ import type { ViewState } from './widget-sources';
4
+ export declare function getSpatialFiltersResolution(source: Partial<ModelSource & AggregationOptions>, viewState: ViewState): number | undefined;
5
+ export declare function getHexagonResolution(viewport: {
6
+ zoom: number;
7
+ latitude: number;
8
+ }, tileSize: number): number;
@@ -49,4 +49,8 @@ type MapInstantiationFormats = Record<Format, {
49
49
  url: string[];
50
50
  error?: any;
51
51
  }>;
52
+ /******************************************************************************
53
+ * LOCAL CALCULATIONS
54
+ */
55
+ export type FeatureData = Record<string, unknown>;
52
56
  export {};
package/build/types.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { FilterType } from './constants.js';
2
- import type { Polygon, MultiPolygon } from 'geojson';
2
+ import type { Polygon, MultiPolygon, Feature } from 'geojson';
3
+ import type { BinaryFeature, BinaryFeatureCollection } from '@loaders.gl/schema';
3
4
  /******************************************************************************
4
5
  * MAPS AND TILES
5
6
  */
@@ -7,6 +8,50 @@ import type { Polygon, MultiPolygon } from 'geojson';
7
8
  export type Format = 'json' | 'geojson' | 'tilejson';
8
9
  /** @internalRemarks Source: @carto/constants, @deck.gl/carto */
9
10
  export type MapType = 'boundary' | 'query' | 'table' | 'tileset' | 'raster';
11
+ /**
12
+ * Alias for GeoJSON 'BBox' type, semantically representing a viewport.
13
+ * Order of values is "west", "south", "east", "north".
14
+ */
15
+ export type Viewport = [number, number, number, number];
16
+ /**
17
+ * Subset of deck.gl's Tile2DHeader type, containing only the properties
18
+ * required for local widget calculations. Deeper dependencies on deck.gl
19
+ * APIs should be minimized within this library: @deck.gl/carto depends
20
+ * on the API client, not the other way around.
21
+ * @internalRemarks Source: @deck.gl/geo-layers
22
+ */
23
+ export type Tile = {
24
+ index: {
25
+ x: number;
26
+ y: number;
27
+ z: number;
28
+ };
29
+ id: string;
30
+ content: unknown;
31
+ zoom: number;
32
+ bbox: {
33
+ west: number;
34
+ east: number;
35
+ north: number;
36
+ south: number;
37
+ };
38
+ isVisible: boolean;
39
+ data?: BinaryFeatureCollection;
40
+ };
41
+ /** Subset of deck.gl's Tile2DHeader type, for spatial indexes. */
42
+ export type SpatialIndexTile = Tile & {
43
+ data?: (Feature & {
44
+ id: bigint;
45
+ })[];
46
+ };
47
+ /** @internalRemarks Source: @deck.gl/carto */
48
+ export type Raster = {
49
+ blockSize: number;
50
+ cells: {
51
+ numericProps: BinaryFeature['numericProps'];
52
+ properties: BinaryFeature['properties'];
53
+ };
54
+ };
10
55
  /******************************************************************************
11
56
  * AGGREGATION
12
57
  */
@@ -49,10 +94,25 @@ export interface Filter {
49
94
  [FilterType.STRING_SEARCH]?: {
50
95
  owner?: string;
51
96
  values: string[];
97
+ params?: StringSearchOptions;
52
98
  };
53
99
  }
54
100
  /** @internalRemarks Source: @carto/react-core */
55
101
  export type FilterLogicalOperator = 'and' | 'or';
102
+ /**
103
+ * Type for minimum or maximum value of an interval. Values 'null' and
104
+ * 'undefined' are intentionally allowed, and represent an unbounded value.
105
+ */
106
+ export type FilterIntervalExtremum = number | null | undefined;
107
+ export type FilterInterval = [FilterIntervalExtremum, FilterIntervalExtremum];
108
+ export type FilterIntervalComplete = [number, number];
109
+ export type StringSearchOptions = {
110
+ useRegExp?: boolean;
111
+ mustStart?: boolean;
112
+ mustEnd?: boolean;
113
+ caseSensitive?: boolean;
114
+ keepSpecialCharacters?: boolean;
115
+ };
56
116
  /******************************************************************************
57
117
  * GROUPING
58
118
  */
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Returns midnight (local time) on the Monday preceeding a given date, in
3
+ * milliseconds since the UNIX epoch.
4
+ */
5
+ export declare function getMonday(date: number | Date): number;
6
+ /**
7
+ * Returns midnight (UTC) on the Monday preceeding a given date, in
8
+ * milliseconds since the UNIX epoch.
9
+ */
10
+ export declare function getUTCMonday(date: number | Date): number;
@@ -0,0 +1,3 @@
1
+ import { TileFormat } from '../constants.js';
2
+ import { Tilejson } from '../sources/types.js';
3
+ export declare function getTileFormat(tilejson: Tilejson): TileFormat;
@@ -0,0 +1,2 @@
1
+ import { FilterInterval, FilterIntervalComplete } from '../types';
2
+ export declare function makeIntervalComplete(intervals: FilterInterval[]): FilterIntervalComplete[];
@@ -0,0 +1,8 @@
1
+ import { BBox, Geometry } from 'geojson';
2
+ /**
3
+ * Transform tile coords to WGS84 coordinates.
4
+ *
5
+ * @param geometry - any valid geojson geometry
6
+ * @param bbox - geojson bbox
7
+ */
8
+ export declare function transformTileCoordsToWGS84<T extends Geometry>(geometry: T, bbox: BBox): T;
@@ -0,0 +1,9 @@
1
+ import { BBox, Geometry } from 'geojson';
2
+ /**
3
+ * Transform WGS84 coordinates to tile coords.
4
+ * It's the inverse of deck.gl coordinate-transform (https://github.com/visgl/deck.gl/blob/master/modules/geo-layers/src/mvt-layer/coordinate-transform.js)
5
+ *
6
+ * @param geometry - any valid geojson geometry
7
+ * @param bbox - geojson bbox
8
+ */
9
+ export declare function transformToTileCoords<T extends Geometry>(geometry: T, bbox: BBox): T;
package/build/utils.d.ts CHANGED
@@ -14,7 +14,7 @@ type Row<T> = Record<string, T> | Record<string, T>[] | T[] | T;
14
14
  */
15
15
  export declare function normalizeObjectKeys<T, R extends Row<T>>(el: R): R;
16
16
  /** @internalRemarks Source: @carto/react-core */
17
- export declare function assert(condition: unknown, message: string): void;
17
+ export declare function assert(condition: unknown, message: string): asserts condition;
18
18
  /**
19
19
  * @internalRemarks Source: @carto/react-core
20
20
  * @internal
@@ -1,4 +1,5 @@
1
- export * from './widget-base-source.js';
2
1
  export * from './widget-query-source.js';
2
+ export * from './widget-remote-source.js';
3
3
  export * from './widget-table-source.js';
4
+ export * from './widget-tileset-source.js';
4
5
  export * from './types.js';