@carto/api-client 0.5.10-alpha.PR193.4 → 0.5.11

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.10-alpha.PR193.4",
11
+ "version": "0.5.11",
12
12
  "license": "MIT",
13
13
  "publishConfig": {
14
14
  "access": "public"
package/src/api/query.ts CHANGED
@@ -13,17 +13,7 @@ import {requestWithParameters} from './request-with-parameters.js';
13
13
  import type {APIErrorContext} from './carto-api-error.js';
14
14
  import {getClient} from '../client.js';
15
15
 
16
- export type QueryOptions = SourceOptions &
17
- QuerySourceOptions & {
18
- /**
19
- * @internal
20
- * @experimental
21
- * Used to append additional parameters to the SQL API request for features specific to providers or integrations.
22
- */
23
- internalParameters?: Record<string, string | boolean | number>;
24
- /** Used to abort the request. */
25
- signal?: AbortSignal;
26
- };
16
+ export type QueryOptions = SourceOptions & QuerySourceOptions;
27
17
  type UrlParameters = {q: string; queryParameters?: string};
28
18
 
29
19
  export const query = async function (
@@ -37,7 +27,6 @@ export const query = async function (
37
27
  connectionName,
38
28
  sqlQuery,
39
29
  queryParameters,
40
- internalParameters,
41
30
  } = options;
42
31
  const urlParameters: UrlParameters = {q: sqlQuery};
43
32
 
@@ -50,12 +39,7 @@ export const query = async function (
50
39
  Authorization: `Bearer ${options.accessToken}`,
51
40
  ...options.headers,
52
41
  };
53
- const parameters = {
54
- client: clientId,
55
- ...options.tags,
56
- ...internalParameters,
57
- ...urlParameters,
58
- };
42
+ const parameters = {client: clientId, ...urlParameters};
59
43
 
60
44
  const errorContext: APIErrorContext = {
61
45
  requestType: 'SQL',
@@ -70,6 +54,5 @@ export const query = async function (
70
54
  errorContext,
71
55
  maxLengthURL,
72
56
  localCache,
73
- signal: options.signal,
74
57
  });
75
58
  };
@@ -23,7 +23,6 @@ export async function requestWithParameters<T = any>({
23
23
  errorContext,
24
24
  maxLengthURL = DEFAULT_MAX_LENGTH_URL,
25
25
  localCache,
26
- signal,
27
26
  }: {
28
27
  baseUrl: string;
29
28
  parameters?: Record<string, unknown>;
@@ -31,7 +30,6 @@ export async function requestWithParameters<T = any>({
31
30
  errorContext: APIErrorContext;
32
31
  maxLengthURL?: number;
33
32
  localCache?: LocalCacheOptions;
34
- signal?: AbortSignal;
35
33
  }): Promise<T> {
36
34
  // Parameters added to all requests issued with `requestWithParameters()`.
37
35
  // These parameters override parameters already in the base URL, but not
@@ -67,9 +65,8 @@ export async function requestWithParameters<T = any>({
67
65
  method: 'POST',
68
66
  body: JSON.stringify(parameters),
69
67
  headers,
70
- signal,
71
68
  })
72
- : fetch(url, {headers, signal});
69
+ : fetch(url, {headers});
73
70
 
74
71
  let response: Response | undefined;
75
72
  let responseJson: unknown;
@@ -146,12 +143,10 @@ function createURLWithParameters(
146
143
  if (isPureObject(value) || Array.isArray(value)) {
147
144
  baseUrl.searchParams.set(key, JSON.stringify(value));
148
145
  } else {
149
- if (value !== null && value !== undefined) {
150
- baseUrl.searchParams.set(
151
- key,
152
- (value as string | boolean | number).toString()
153
- );
154
- }
146
+ baseUrl.searchParams.set(
147
+ key,
148
+ (value as string | boolean | number).toString()
149
+ );
155
150
  }
156
151
  }
157
152
  return baseUrl.toString();
@@ -43,7 +43,6 @@ export interface ModelSource {
43
43
  spatialDataColumn?: string;
44
44
  spatialDataType?: SpatialDataType;
45
45
  spatialFiltersMode?: SpatialFilterPolyfillMode;
46
- tags?: Record<string, string>;
47
46
  }
48
47
 
49
48
  const {V3} = ApiVersion;
@@ -88,7 +87,6 @@ export function executeModel(props: {
88
87
  spatialDataType = 'geo',
89
88
  spatialDataColumn = DEFAULT_GEO_COLUMN,
90
89
  spatialFiltersMode = 'intersects',
91
- tags,
92
90
  } = source;
93
91
 
94
92
  const queryParams: Record<string, unknown> = {
@@ -99,7 +97,6 @@ export function executeModel(props: {
99
97
  queryParameters: source.queryParameters || '',
100
98
  filters,
101
99
  filtersLogicalOperator,
102
- ...(tags ?? {}),
103
100
  };
104
101
 
105
102
  queryParams.spatialDataType = spatialDataType;
@@ -85,19 +85,27 @@ export function getSorter(
85
85
  switch (orderBy) {
86
86
  case 'frequency_asc':
87
87
  // 'value ASC, name ASC'
88
- return (a, b) => a.value - b.value || localeCompare(a.name, b.name);
88
+ return (a, b) => a.value - b.value || nameCompare(a.name, b.name);
89
89
  case 'frequency_desc':
90
90
  // 'value DESC, name ASC'
91
- return (a, b) => b.value - a.value || localeCompare(a.name, b.name);
91
+ return (a, b) => b.value - a.value || nameCompare(a.name, b.name);
92
92
  case 'alphabetical_asc':
93
93
  // 'name ASC, value DESC'
94
- return (a, b) => localeCompare(a.name, b.name) || b.value - a.value;
94
+ return (a, b) => nameCompare(a.name, b.name) || b.value - a.value;
95
95
  case 'alphabetical_desc':
96
96
  // 'name DESC, value DESC'
97
- return (a, b) => localeCompare(b.name, a.name) || b.value - a.value;
97
+ return (a, b) => nameCompare(b.name, a.name) || b.value - a.value;
98
98
  }
99
99
  }
100
100
 
101
- function localeCompare(a?: string | null, b?: string | null) {
102
- return (a ?? 'null').localeCompare(b ?? 'null');
101
+ function nameCompare(
102
+ a?: CategoryResponseEntry['name'],
103
+ b?: CategoryResponseEntry['name']
104
+ ) {
105
+ // Despite the naming of 'alphabetical_*' sort options, we still want to
106
+ // sort numeric category names (usually raster datasets) numerically.
107
+ if (typeof a === 'number' && typeof b === 'number') {
108
+ return a - b;
109
+ }
110
+ return String(a ?? 'null').localeCompare(String(b ?? 'null'));
103
111
  }
@@ -47,7 +47,7 @@ export async function baseSource<UrlParameters extends Record<string, unknown>>(
47
47
  Authorization: `Bearer ${options.accessToken}`,
48
48
  ...options.headers,
49
49
  };
50
- const parameters = {client: clientId, ...options.tags, ...urlParameters};
50
+ const parameters = {client: clientId, ...urlParameters};
51
51
 
52
52
  const errorContext: APIErrorContext = {
53
53
  requestType: 'Map instantiation',
@@ -75,9 +75,6 @@ export type SourceOptionalOptions = {
75
75
  * By default, local in-memory caching is enabled.
76
76
  */
77
77
  localCache?: LocalCacheOptions;
78
-
79
- /** Additional tags appended to HTTP requests, available for analytics and audits. */
80
- tags?: Record<string, string>;
81
78
  };
82
79
 
83
80
  export type LocalCacheOptions = {
@@ -240,7 +237,7 @@ export interface Tilejson {
240
237
  minzoom: number;
241
238
  maxzoom: number;
242
239
  bounds: [left: number, bottom: number, right: number, top: number];
243
- center: [longitute: number, latitude: number, zoom: number];
240
+ center: [longitude: number, latitude: number, zoom: number];
244
241
  vector_layers: VectorLayer[];
245
242
 
246
243
  //
@@ -385,6 +382,13 @@ export type RasterMetadataBand = {
385
382
  type: RasterBandType;
386
383
  name: string;
387
384
  stats: RasterMetadataBandStats;
385
+
386
+ /**
387
+ * Optional table of mappings from (integer) band values to (string) human
388
+ * readable labels. Values found in tiles are NOT guaranteed to have labels.
389
+ */
390
+ valuelabels?: Record<string, string>;
391
+
388
392
  /**
389
393
  * Known values:
390
394
  * * `palette`: use unique value and `colortable` ad default mapping
@@ -411,10 +415,11 @@ export type RasterMetadata = {
411
415
  block_resolution: number;
412
416
  minresolution: number;
413
417
  maxresolution: number;
418
+ /** @deprecated Use {@link RasterMetadataBand.nodata} from {@link RasterMetadata.bands}. */
414
419
  nodata: number | string;
415
420
  bands: RasterMetadataBand[];
416
421
  bounds: [left: number, bottom: number, right: number, top: number];
417
- center: [longitute: number, latitude: number, zoom: number];
422
+ center: [longitude: number, latitude: number, zoom: number];
418
423
  width: number;
419
424
  height: number;
420
425
  block_width: number;
@@ -221,7 +221,11 @@ export type FeaturesResponse = {rows: Record<string, unknown>[]};
221
221
  export type FormulaResponse = {value: number | null};
222
222
 
223
223
  /** Entry in the category widget response, see {@link WidgetRemoteSource#getCategories}. */
224
- export type CategoryResponseEntry = {name: string | null; value: number};
224
+ export type CategoryResponseEntry = {
225
+ name: string | number | null;
226
+ value: number;
227
+ };
228
+
225
229
  /** Response from {@link WidgetRemoteSource#getCategories}. */
226
230
  export type CategoryResponse = CategoryResponseEntry[];
227
231
 
@@ -61,7 +61,6 @@ export abstract class WidgetRemoteSource<
61
61
  filtersLogicalOperator: props.filtersLogicalOperator,
62
62
  spatialDataType: props.spatialDataType,
63
63
  spatialDataColumn: props.spatialDataColumn,
64
- tags: props.tags,
65
64
  };
66
65
  }
67
66