@carto/api-client 0.5.0 → 0.5.1-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "homepage": "https://github.com/CartoDB/carto-api-client#readme",
9
9
  "author": "Don McCurdy <donmccurdy@carto.com>",
10
10
  "packageManager": "yarn@4.3.1",
11
- "version": "0.5.0",
11
+ "version": "0.5.1-alpha.1",
12
12
  "license": "MIT",
13
13
  "publishConfig": {
14
14
  "access": "public"
@@ -117,15 +117,16 @@
117
117
  "rimraf": "^6.0.1",
118
118
  "semver": "^7.7.1",
119
119
  "thenby": "^1.3.4",
120
- "tinybench": "^3.1.1",
120
+ "tinybench": "^4.0.1",
121
121
  "tsup": "^8.3.6",
122
122
  "typescript": "~5.8.2",
123
123
  "typescript-eslint": "^8.26.1",
124
124
  "vite": "^6.2.2",
125
- "vitest": "3.0.9"
125
+ "vitest": "3.1.1"
126
126
  },
127
127
  "resolutions": {
128
128
  "@carto/api-client": "portal:./",
129
129
  "rollup": "^4.20.0"
130
- }
130
+ },
131
+ "stableVersion": "0.5.0"
131
132
  }
@@ -23,7 +23,9 @@ import {
23
23
  BinaryAttribute,
24
24
  BinaryFeature,
25
25
  BinaryGeometryType,
26
+ BinaryLineFeature,
26
27
  BinaryPointFeature,
28
+ BinaryPolygonFeature,
27
29
  TypedArrayConstructor,
28
30
  } from '@loaders.gl/schema';
29
31
 
@@ -89,8 +91,6 @@ export function tileFeaturesGeometries({
89
91
  ? transformToTileCoords(clippedGeometryToIntersect.geometry, bbox)
90
92
  : clippedGeometryToIntersect.geometry;
91
93
 
92
- createIndicesForPoints(tile.data.points!);
93
-
94
94
  calculateFeatures({
95
95
  map,
96
96
  tileIsFullyVisible,
@@ -214,7 +214,7 @@ function addIntersectedFeaturesInTile({
214
214
  uniqueIdProperty?: string;
215
215
  options?: TileFeatureExtractOptions;
216
216
  }) {
217
- const indices = getIndices(data);
217
+ const indices = getIndices(data, type);
218
218
  const storeGeometry = options?.storeGeometry || false;
219
219
 
220
220
  for (let i = 0; i < indices.length - 1; i++) {
@@ -235,21 +235,24 @@ function addIntersectedFeaturesInTile({
235
235
  }
236
236
  }
237
237
 
238
- function getIndices(data: BinaryFeature) {
238
+ // Despite TypeScript, 'data.type' is OPTIONAL. So 'type' must be passed in
239
+ // separately. Observed missing .type for Redshift tilesets, 2025-04-09.
240
+ function getIndices(data: BinaryFeature, type: BinaryGeometryType) {
239
241
  let indices: BinaryAttribute;
240
- switch (data.type) {
241
- case 'Point':
242
- // @ts-expect-error Missing or changed types?
243
- indices = data.pointIndices;
242
+ switch (type) {
243
+ case 'Polygon':
244
+ indices = (data as BinaryPolygonFeature).primitivePolygonIndices;
244
245
  break;
245
246
  case 'LineString':
246
- indices = data.pathIndices;
247
+ indices = (data as BinaryLineFeature).pathIndices;
247
248
  break;
248
- case 'Polygon':
249
- indices = data.primitivePolygonIndices;
249
+ case 'Point':
250
+ indices = createIndicesForPoints(data as BinaryPointFeature);
250
251
  break;
251
252
  default:
252
- throw new Error(`Unexpected type, "${(data as BinaryFeature).type}"`);
253
+ throw new Error(
254
+ `Unsupported geometry type: ${type as unknown as string}`
255
+ );
253
256
  }
254
257
  return indices.value;
255
258
  }
@@ -408,7 +411,7 @@ function addAllFeaturesInTile({
408
411
  uniqueIdProperty?: string;
409
412
  options?: TileFeatureExtractOptions;
410
413
  }) {
411
- const indices = getIndices(data);
414
+ const indices = getIndices(data, type);
412
415
  const storeGeometry = options?.storeGeometry || false;
413
416
  for (let i = 0; i < indices.length - 1; i++) {
414
417
  const startIndex = indices[i];
@@ -427,7 +430,11 @@ function addAllFeaturesInTile({
427
430
  }
428
431
  }
429
432
 
430
- function createIndicesForPoints(data: BinaryPointFeature) {
433
+ /**
434
+ * BinaryPointFeature does not include indices, so we generate in-memory
435
+ * indices to allow processing points similarly to other topologies.
436
+ */
437
+ function createIndicesForPoints(data: BinaryPointFeature): BinaryAttribute {
431
438
  const featureIds = data.featureIds.value;
432
439
  const lastFeatureId = featureIds[featureIds.length - 1];
433
440
  const PointIndicesArray = featureIds.constructor as TypedArrayConstructor;
@@ -438,7 +445,5 @@ function createIndicesForPoints(data: BinaryPointFeature) {
438
445
  };
439
446
  pointIndices.value.set(featureIds);
440
447
  pointIndices.value.set([lastFeatureId + 1], featureIds.length);
441
-
442
- // @ts-expect-error Missing or changed types?
443
- data.pointIndices = pointIndices;
448
+ return pointIndices;
444
449
  }
@@ -18,7 +18,7 @@ export interface ViewState {
18
18
  }
19
19
 
20
20
  /** Common options for {@link WidgetRemoteSource} requests. */
21
- interface BaseRequestOptions {
21
+ export interface BaseRequestOptions {
22
22
  signal?: AbortSignal;
23
23
  spatialFilter?: SpatialFilter;
24
24
  spatialFiltersMode?: SpatialFilterPolyfillMode;
@@ -387,15 +387,15 @@ function assertColumn(
387
387
  features: FeatureData[],
388
388
  ...columnArgs: string[] | string[][]
389
389
  ) {
390
- // TODO(cleanup): Can drop support for multiple column shapes here?
391
-
392
390
  // Due to the multiple column shape, we normalise it as an array with normalizeColumns
393
391
  const columns = Array.from(new Set(columnArgs.map(normalizeColumns).flat()));
394
392
 
395
393
  const featureKeys = Object.keys(features[0]);
396
394
 
395
+ // For backward compatibility, '' should pass column validation. For example,
396
+ // operation='count',operationColumn='' is accepted.
397
397
  const invalidColumns = columns.filter(
398
- (column) => !featureKeys.includes(column)
398
+ (column) => column && !featureKeys.includes(column)
399
399
  );
400
400
 
401
401
  if (invalidColumns.length) {