@carto/api-client 0.4.7-0 → 0.4.7-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 (90) hide show
  1. package/CHANGELOG.md +17 -1
  2. package/build/api/carto-api-error.d.ts +26 -0
  3. package/build/api/endpoints.d.ts +24 -0
  4. package/build/api/index.d.ts +5 -0
  5. package/build/api/query.d.ts +3 -0
  6. package/build/api/request-with-parameters.d.ts +10 -0
  7. package/build/api-client.cjs +2910 -2741
  8. package/build/api-client.cjs.map +1 -1
  9. package/build/api-client.modern.js +3718 -0
  10. package/build/api-client.modern.js.map +1 -0
  11. package/build/client.d.ts +14 -0
  12. package/build/constants-internal.d.ts +26 -0
  13. package/build/constants.d.ts +53 -0
  14. package/build/deck/get-data-filter-extension-props.d.ts +28 -0
  15. package/build/deck/index.d.ts +1 -0
  16. package/build/filters/Filter.d.ts +25 -0
  17. package/build/filters/FilterTypes.d.ts +3 -0
  18. package/build/filters/geosjonFeatures.d.ts +8 -0
  19. package/build/filters/index.d.ts +6 -0
  20. package/build/filters/tileFeatures.d.ts +20 -0
  21. package/build/filters/tileFeaturesGeometries.d.ts +13 -0
  22. package/build/filters/tileFeaturesSpatialIndex.d.ts +10 -0
  23. package/build/filters.d.ts +39 -0
  24. package/build/geo.d.ts +19 -0
  25. package/build/index.d.ts +16 -0
  26. package/build/models/common.d.ts +28 -0
  27. package/build/models/index.d.ts +3 -0
  28. package/build/models/model.d.ts +37 -0
  29. package/build/operations/aggregation.d.ts +8 -0
  30. package/build/operations/applySorting.d.ts +20 -0
  31. package/build/operations/groupBy.d.ts +15 -0
  32. package/build/operations/groupByDate.d.ts +11 -0
  33. package/build/operations/histogram.d.ts +13 -0
  34. package/build/operations/index.d.ts +6 -0
  35. package/build/operations/scatterPlot.d.ts +14 -0
  36. package/build/sources/base-source.d.ts +4 -0
  37. package/build/sources/boundary-query-source.d.ts +10 -0
  38. package/build/sources/boundary-table-source.d.ts +8 -0
  39. package/build/sources/h3-query-source.d.ts +5 -0
  40. package/build/sources/h3-table-source.d.ts +5 -0
  41. package/build/sources/h3-tileset-source.d.ts +4 -0
  42. package/build/sources/index.d.ts +26 -0
  43. package/build/sources/quadbin-query-source.d.ts +5 -0
  44. package/build/sources/quadbin-table-source.d.ts +5 -0
  45. package/build/sources/quadbin-tileset-source.d.ts +4 -0
  46. package/build/sources/raster-source.d.ts +4 -0
  47. package/build/sources/types.d.ts +366 -0
  48. package/build/sources/vector-query-source.d.ts +5 -0
  49. package/build/sources/vector-table-source.d.ts +5 -0
  50. package/build/sources/vector-tileset-source.d.ts +4 -0
  51. package/build/spatial-index.d.ts +14 -0
  52. package/build/types-internal.d.ts +56 -0
  53. package/build/types.d.ts +140 -0
  54. package/build/utils/dateUtils.d.ts +10 -0
  55. package/build/utils/getTileFormat.d.ts +3 -0
  56. package/build/utils/makeIntervalComplete.d.ts +2 -0
  57. package/build/utils/transformTileCoordsToWGS84.d.ts +8 -0
  58. package/build/utils/transformToTileCoords.d.ts +9 -0
  59. package/build/utils.d.ts +32 -0
  60. package/build/widget-sources/index.d.ts +6 -0
  61. package/build/widget-sources/types.d.ts +162 -0
  62. package/build/widget-sources/widget-query-source.d.ts +34 -0
  63. package/build/widget-sources/widget-remote-source.d.ts +18 -0
  64. package/build/widget-sources/widget-source.d.ts +74 -0
  65. package/build/widget-sources/widget-table-source.d.ts +34 -0
  66. package/build/widget-sources/widget-tileset-source.d.ts +75 -0
  67. package/package.json +18 -19
  68. package/src/constants-internal.ts +6 -0
  69. package/src/deck/get-data-filter-extension-props.ts +27 -9
  70. package/src/filters/tileFeatures.ts +0 -1
  71. package/src/global.d.ts +8 -3
  72. package/src/sources/h3-tileset-source.ts +6 -18
  73. package/src/sources/quadbin-tileset-source.ts +6 -18
  74. package/src/sources/types.ts +0 -6
  75. package/src/sources/vector-tileset-source.ts +6 -19
  76. package/src/widget-sources/types.ts +2 -0
  77. package/src/widget-sources/widget-remote-source.ts +16 -42
  78. package/src/widget-sources/widget-source.ts +40 -12
  79. package/src/widget-sources/widget-tileset-source.ts +341 -196
  80. package/build/api-client.d.cts +0 -1389
  81. package/build/api-client.d.ts +0 -1389
  82. package/build/api-client.js +0 -3676
  83. package/build/api-client.js.map +0 -1
  84. package/build/worker.d.ts +0 -2
  85. package/build/worker.js +0 -1949
  86. package/build/worker.js.map +0 -1
  87. package/src/widget-sources/widget-tileset-source-impl.ts +0 -417
  88. package/src/workers/constants.ts +0 -13
  89. package/src/workers/types.ts +0 -19
  90. package/src/workers/widget-tileset-worker.ts +0 -40
@@ -191,12 +191,6 @@ export type TilesetSourceOptions = {
191
191
  * Fully qualified name of tileset.
192
192
  */
193
193
  tableName: string;
194
-
195
- /**
196
- * Whether to use Web Workers for local widget calculations. Workers
197
- * are used by default if the runtime environment supports ES Module Workers.
198
- */
199
- widgetWorker?: boolean;
200
194
  };
201
195
 
202
196
  export type ColumnsOption = {
@@ -2,12 +2,6 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import {DEFAULT_GEO_COLUMN} from '../constants-internal.js';
6
- import {getTileFormat} from '../utils/getTileFormat.js';
7
- import {
8
- WidgetTilesetSource,
9
- WidgetTilesetSourceResult,
10
- } from '../widget-sources/index.js';
11
5
  import {baseSource} from './base-source.js';
12
6
  import type {
13
7
  SourceOptions,
@@ -18,24 +12,17 @@ import type {
18
12
  export type VectorTilesetSourceOptions = SourceOptions & TilesetSourceOptions;
19
13
  type UrlParameters = {name: string};
20
14
 
21
- export type VectorTilesetSourceResponse = TilejsonResult &
22
- WidgetTilesetSourceResult;
15
+ export type VectorTilesetSourceResponse = TilejsonResult;
23
16
 
24
17
  export const vectorTilesetSource = async function (
25
18
  options: VectorTilesetSourceOptions
26
19
  ): Promise<VectorTilesetSourceResponse> {
27
- const {tableName, spatialDataColumn = DEFAULT_GEO_COLUMN} = options;
20
+ const {tableName} = options;
28
21
  const urlParameters: UrlParameters = {name: tableName};
29
22
 
30
- return baseSource<UrlParameters>('tileset', options, urlParameters).then(
31
- (result) => ({
32
- ...(result as TilejsonResult),
33
- widgetSource: new WidgetTilesetSource({
34
- ...options,
35
- tileFormat: getTileFormat(result as TilejsonResult),
36
- spatialDataColumn,
37
- spatialDataType: 'geo',
38
- }),
39
- })
23
+ return baseSource<UrlParameters>(
24
+ 'tileset',
25
+ options,
26
+ urlParameters
40
27
  ) as Promise<VectorTilesetSourceResponse>;
41
28
  };
@@ -19,6 +19,8 @@ export interface ViewState {
19
19
 
20
20
  /** Common options for {@link WidgetRemoteSource} requests. */
21
21
  interface BaseRequestOptions {
22
+ /** @deprecated */
23
+ abortController?: AbortController;
22
24
  signal?: AbortSignal;
23
25
  spatialFilter?: SpatialFilter;
24
26
  spatialFiltersMode?: SpatialFilterPolyfillMode;
@@ -1,4 +1,4 @@
1
- import {executeModel, ModelSource} from '../models/index.js';
1
+ import {executeModel} from '../models/index.js';
2
2
  import {
3
3
  CategoryRequestOptions,
4
4
  CategoryResponse,
@@ -17,12 +17,9 @@ import {
17
17
  TimeSeriesRequestOptions,
18
18
  TimeSeriesResponse,
19
19
  } from './types.js';
20
- import {getApplicableFilters, normalizeObjectKeys} from '../utils.js';
20
+ import {normalizeObjectKeys} from '../utils.js';
21
21
  import {DEFAULT_TILE_RESOLUTION} from '../constants-internal.js';
22
22
  import {WidgetSource, WidgetSourceProps} from './widget-source.js';
23
- import {Filters} from '../types.js';
24
- import {ApiVersion} from '../constants.js';
25
- import {AggregationOptions} from '../sources/types.js';
26
23
 
27
24
  export type WidgetRemoteSourceProps = WidgetSourceProps;
28
25
 
@@ -34,36 +31,6 @@ export type WidgetRemoteSourceProps = WidgetSourceProps;
34
31
  export abstract class WidgetRemoteSource<
35
32
  Props extends WidgetRemoteSourceProps,
36
33
  > extends WidgetSource<Props> {
37
- /**
38
- * Subclasses of {@link WidgetRemoteSource} must implement this method, calling
39
- * {@link WidgetRemoteSource.prototype._getModelSource} for common source
40
- * properties, and adding additional required properties including 'type' and
41
- * 'data'.
42
- */
43
- protected abstract getModelSource(
44
- filters: Filters | undefined,
45
- filterOwner?: string
46
- ): ModelSource;
47
-
48
- protected _getModelSource(
49
- filters: Filters | undefined,
50
- filterOwner?: string
51
- ): Omit<ModelSource, 'type' | 'data'> {
52
- const props = this.props;
53
- return {
54
- apiVersion: props.apiVersion as ApiVersion,
55
- apiBaseUrl: props.apiBaseUrl as string,
56
- clientId: props.clientId as string,
57
- accessToken: props.accessToken,
58
- connectionName: props.connectionName,
59
- filters: getApplicableFilters(filterOwner, filters || props.filters),
60
- filtersLogicalOperator: props.filtersLogicalOperator,
61
- spatialDataType: props.spatialDataType,
62
- spatialDataColumn: props.spatialDataColumn,
63
- dataResolution: (props as Partial<AggregationOptions>).dataResolution,
64
- };
65
- }
66
-
67
34
  async getCategories(
68
35
  options: CategoryRequestOptions
69
36
  ): Promise<CategoryResponse> {
@@ -107,7 +74,8 @@ export abstract class WidgetRemoteSource<
107
74
  options: FeaturesRequestOptions
108
75
  ): Promise<FeaturesResponse> {
109
76
  const {
110
- signal,
77
+ abortController,
78
+ signal = abortController?.signal,
111
79
  filters = this.props.filters,
112
80
  filterOwner,
113
81
  spatialFilter,
@@ -148,7 +116,8 @@ export abstract class WidgetRemoteSource<
148
116
 
149
117
  async getFormula(options: FormulaRequestOptions): Promise<FormulaResponse> {
150
118
  const {
151
- signal,
119
+ abortController,
120
+ signal = abortController?.signal,
152
121
  filters = this.props.filters,
153
122
  filterOwner,
154
123
  spatialFilter,
@@ -188,7 +157,8 @@ export abstract class WidgetRemoteSource<
188
157
  options: HistogramRequestOptions
189
158
  ): Promise<HistogramResponse> {
190
159
  const {
191
- signal,
160
+ abortController,
161
+ signal = abortController?.signal,
192
162
  filters = this.props.filters,
193
163
  filterOwner,
194
164
  spatialFilter,
@@ -233,7 +203,8 @@ export abstract class WidgetRemoteSource<
233
203
 
234
204
  async getRange(options: RangeRequestOptions): Promise<RangeResponse> {
235
205
  const {
236
- signal,
206
+ abortController,
207
+ signal = abortController?.signal,
237
208
  filters = this.props.filters,
238
209
  filterOwner,
239
210
  spatialFilter,
@@ -266,7 +237,8 @@ export abstract class WidgetRemoteSource<
266
237
 
267
238
  async getScatter(options: ScatterRequestOptions): Promise<ScatterResponse> {
268
239
  const {
269
- signal,
240
+ abortController,
241
+ signal = abortController?.signal,
270
242
  filters = this.props.filters,
271
243
  filterOwner,
272
244
  spatialFilter,
@@ -312,7 +284,8 @@ export abstract class WidgetRemoteSource<
312
284
 
313
285
  async getTable(options: TableRequestOptions): Promise<TableResponse> {
314
286
  const {
315
- signal,
287
+ abortController,
288
+ signal = abortController?.signal,
316
289
  filters = this.props.filters,
317
290
  filterOwner,
318
291
  spatialFilter,
@@ -360,7 +333,8 @@ export abstract class WidgetRemoteSource<
360
333
  options: TimeSeriesRequestOptions
361
334
  ): Promise<TimeSeriesResponse> {
362
335
  const {
363
- signal,
336
+ abortController,
337
+ signal = abortController?.signal,
364
338
  filters = this.props.filters,
365
339
  filterOwner,
366
340
  spatialFilter,
@@ -17,12 +17,19 @@ import {
17
17
  TimeSeriesResponse,
18
18
  ViewState,
19
19
  } from './types.js';
20
- import {FilterLogicalOperator, Filter, SpatialFilter} from '../types.js';
20
+ import {
21
+ FilterLogicalOperator,
22
+ Filter,
23
+ SpatialFilter,
24
+ Filters,
25
+ } from '../types.js';
26
+ import {getApplicableFilters} from '../utils.js';
21
27
  import {getClient} from '../client.js';
22
28
  import {ModelSource} from '../models/model.js';
23
29
  import {SourceOptions} from '../sources/index.js';
24
30
  import {ApiVersion, DEFAULT_API_BASE_URL} from '../constants.js';
25
31
  import {getSpatialFiltersResolution} from '../spatial-index.js';
32
+ import {AggregationOptions} from '../sources/types.js';
26
33
 
27
34
  export interface WidgetSourceProps extends Omit<SourceOptions, 'filters'> {
28
35
  apiVersion?: ApiVersion;
@@ -35,9 +42,7 @@ export interface WidgetSourceProps extends Omit<SourceOptions, 'filters'> {
35
42
  *
36
43
  * Abstract class. Use {@link WidgetQuerySource} or {@link WidgetTableSource}.
37
44
  */
38
- export abstract class WidgetSource<
39
- Props extends WidgetSourceProps = WidgetSourceProps,
40
- > {
45
+ export abstract class WidgetSource<Props extends WidgetSourceProps> {
41
46
  readonly props: Props;
42
47
 
43
48
  static defaultProps: Partial<WidgetSourceProps> = {
@@ -49,18 +54,41 @@ export abstract class WidgetSource<
49
54
  };
50
55
 
51
56
  constructor(props: Props) {
52
- this.props = {...WidgetSource.defaultProps, ...props};
57
+ this.props = {
58
+ ...WidgetSource.defaultProps,
59
+ clientId: getClient(), // Refresh clientId, default may have changed.
60
+ ...props,
61
+ };
53
62
  }
54
63
 
55
64
  /**
56
- * Destroys the widget source and releases allocated resources.
57
- *
58
- * For remote sources (tables, queries) this has no effect, but for local
59
- * sources (tilesets, rasters) these resources will affect performance
60
- * and stability if many (10+) sources are created and not released.
65
+ * Subclasses of {@link WidgetRemoteSource} must implement this method, calling
66
+ * {@link WidgetRemoteSource.prototype._getModelSource} for common source
67
+ * properties, and adding additional required properties including 'type' and
68
+ * 'data'.
61
69
  */
62
- destroy() {
63
- // no-op in most cases, but required for worker sources.
70
+ protected abstract getModelSource(
71
+ filters: Filters | undefined,
72
+ filterOwner?: string
73
+ ): ModelSource;
74
+
75
+ protected _getModelSource(
76
+ filters: Filters | undefined,
77
+ filterOwner?: string
78
+ ): Omit<ModelSource, 'type' | 'data'> {
79
+ const props = this.props;
80
+ return {
81
+ apiVersion: props.apiVersion as ApiVersion,
82
+ apiBaseUrl: props.apiBaseUrl as string,
83
+ clientId: props.clientId as string,
84
+ accessToken: props.accessToken,
85
+ connectionName: props.connectionName,
86
+ filters: getApplicableFilters(filterOwner, filters || props.filters),
87
+ filtersLogicalOperator: props.filtersLogicalOperator,
88
+ spatialDataType: props.spatialDataType,
89
+ spatialDataColumn: props.spatialDataColumn,
90
+ dataResolution: (props as Partial<AggregationOptions>).dataResolution,
91
+ };
64
92
  }
65
93
 
66
94
  protected _getSpatialFiltersResolution(