@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
@@ -1,22 +1,32 @@
1
- import { TileResolution } from '../sources/types';
1
+ import { SpatialFilterPolyfillMode, TileResolution } from '../sources/types';
2
2
  import { GroupDateType, SortColumnType, SortDirection, SpatialFilter } from '../types';
3
3
  /******************************************************************************
4
4
  * WIDGET API REQUESTS
5
5
  */
6
- /** Common options for {@link WidgetBaseSource} requests. */
6
+ export interface ViewState {
7
+ zoom: number;
8
+ latitude: number;
9
+ longitude: number;
10
+ }
11
+ /** Common options for {@link WidgetRemoteSource} requests. */
7
12
  interface BaseRequestOptions {
8
13
  spatialFilter?: SpatialFilter;
14
+ spatialFiltersMode?: SpatialFilterPolyfillMode;
15
+ /** Required for table- and query-based spatial index sources (H3, Quadbin). */
16
+ spatialIndexReferenceViewState?: ViewState;
9
17
  abortController?: AbortController;
10
18
  filterOwner?: string;
11
19
  }
12
- /** Options for {@link WidgetBaseSource#getCategories}. */
20
+ /** Options for {@link WidgetRemoteSource#getCategories}. */
13
21
  export interface CategoryRequestOptions extends BaseRequestOptions {
14
22
  column: string;
15
23
  operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
16
24
  operationColumn?: string;
25
+ /** Local only. */
26
+ joinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
17
27
  }
18
28
  /**
19
- * Options for {@link WidgetBaseSource#getFeatures}.
29
+ * Options for {@link WidgetRemoteSource#getFeatures}.
20
30
  * @experimental
21
31
  * @internal
22
32
  */
@@ -52,30 +62,33 @@ export interface FeaturesRequestOptions extends BaseRequestOptions {
52
62
  */
53
63
  tileResolution?: TileResolution;
54
64
  }
55
- /** Options for {@link WidgetBaseSource#getFormula}. */
65
+ /** Options for {@link WidgetRemoteSource#getFormula}. */
56
66
  export interface FormulaRequestOptions extends BaseRequestOptions {
57
67
  column: string;
58
- operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
68
+ operation?: 'count' | 'avg' | 'min' | 'max' | 'sum' | 'custom';
59
69
  operationExp?: string;
70
+ joinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
60
71
  }
61
- /** Options for {@link WidgetBaseSource#getHistogram}. */
72
+ /** Options for {@link WidgetRemoteSource#getHistogram}. */
62
73
  export interface HistogramRequestOptions extends BaseRequestOptions {
63
74
  column: string;
64
75
  ticks: number[];
65
76
  operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
77
+ /** Local only. */
78
+ joinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
66
79
  }
67
- /** Options for {@link WidgetBaseSource#getRange}. */
80
+ /** Options for {@link WidgetRemoteSource#getRange}. */
68
81
  export interface RangeRequestOptions extends BaseRequestOptions {
69
82
  column: string;
70
83
  }
71
- /** Options for {@link WidgetBaseSource#getScatter}. */
84
+ /** Options for {@link WidgetRemoteSource#getScatter}. */
72
85
  export interface ScatterRequestOptions extends BaseRequestOptions {
73
86
  xAxisColumn: string;
74
87
  xAxisJoinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
75
88
  yAxisColumn: string;
76
89
  yAxisJoinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
77
90
  }
78
- /** Options for {@link WidgetBaseSource#getTable}. */
91
+ /** Options for {@link WidgetRemoteSource#getTable}. */
79
92
  export interface TableRequestOptions extends BaseRequestOptions {
80
93
  columns: string[];
81
94
  sortBy?: string;
@@ -83,11 +96,15 @@ export interface TableRequestOptions extends BaseRequestOptions {
83
96
  sortByColumnType?: SortColumnType;
84
97
  offset?: number;
85
98
  limit?: number;
99
+ /** Local only. */
100
+ searchFilterColumn?: string;
101
+ /** Local only. */
102
+ searchFilterText?: string;
86
103
  }
87
- /** Options for {@link WidgetBaseSource#getTimeSeries}. */
104
+ /** Options for {@link WidgetRemoteSource#getTimeSeries}. */
88
105
  export interface TimeSeriesRequestOptions extends BaseRequestOptions {
89
106
  column: string;
90
- stepSize?: GroupDateType;
107
+ stepSize: GroupDateType;
91
108
  stepMultiplier?: number;
92
109
  operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
93
110
  operationColumn?: string;
@@ -100,42 +117,42 @@ export interface TimeSeriesRequestOptions extends BaseRequestOptions {
100
117
  * WIDGET API RESPONSES
101
118
  */
102
119
  /**
103
- * Response from {@link WidgetBaseSource#getFeatures}.
120
+ * Response from {@link WidgetRemoteSource#getFeatures}.
104
121
  * @experimental
105
122
  * @internal
106
123
  */
107
124
  export type FeaturesResponse = {
108
125
  rows: Record<string, unknown>[];
109
126
  };
110
- /** Response from {@link WidgetBaseSource#getFormula}. */
127
+ /** Response from {@link WidgetRemoteSource#getFormula}. */
111
128
  export type FormulaResponse = {
112
- value: number;
129
+ value: number | null;
113
130
  };
114
- /** Response from {@link WidgetBaseSource#getCategories}. */
131
+ /** Response from {@link WidgetRemoteSource#getCategories}. */
115
132
  export type CategoryResponse = {
116
133
  name: string;
117
134
  value: number;
118
135
  }[];
119
- /** Response from {@link WidgetBaseSource#getRange}. */
136
+ /** Response from {@link WidgetRemoteSource#getRange}. */
120
137
  export type RangeResponse = {
121
138
  min: number;
122
139
  max: number;
123
- };
124
- /** Response from {@link WidgetBaseSource#getTable}. */
140
+ } | null;
141
+ /** Response from {@link WidgetRemoteSource#getTable}. */
125
142
  export type TableResponse = {
126
143
  totalCount: number;
127
144
  rows: Record<string, number | string>[];
128
145
  };
129
- /** Response from {@link WidgetBaseSource#getScatter}. */
146
+ /** Response from {@link WidgetRemoteSource#getScatter}. */
130
147
  export type ScatterResponse = [number, number][];
131
- /** Response from {@link WidgetBaseSource#getTimeSeries}. */
148
+ /** Response from {@link WidgetRemoteSource#getTimeSeries}. */
132
149
  export type TimeSeriesResponse = {
133
150
  rows: {
134
151
  name: string;
135
152
  value: number;
136
153
  }[];
137
- categories: string[];
154
+ categories?: string[];
138
155
  };
139
- /** Response from {@link WidgetBaseSource#getHistogram}. */
156
+ /** Response from {@link WidgetRemoteSource#getHistogram}. */
140
157
  export type HistogramResponse = number[];
141
158
  export {};
@@ -1,5 +1,5 @@
1
1
  import { H3QuerySourceOptions, QuadbinQuerySourceOptions, VectorQuerySourceOptions } from '../sources/index.js';
2
- import { WidgetBaseSource, WidgetBaseSourceProps } from './widget-base-source.js';
2
+ import { WidgetRemoteSource, WidgetRemoteSourceProps } from './widget-remote-source.js';
3
3
  import { ModelSource } from '../models/model.js';
4
4
  type LayerQuerySourceOptions = Omit<VectorQuerySourceOptions, 'filters'> | Omit<H3QuerySourceOptions, 'filters'> | Omit<QuadbinQuerySourceOptions, 'filters'>;
5
5
  export type WidgetQuerySourceResult = {
@@ -27,7 +27,7 @@ export type WidgetQuerySourceResult = {
27
27
  * const { widgetSource } = await data;
28
28
  * ```
29
29
  */
30
- export declare class WidgetQuerySource extends WidgetBaseSource<LayerQuerySourceOptions & WidgetBaseSourceProps> {
30
+ export declare class WidgetQuerySource extends WidgetRemoteSource<LayerQuerySourceOptions & WidgetRemoteSourceProps> {
31
31
  protected getModelSource(owner: string): ModelSource;
32
32
  }
33
33
  export {};
@@ -0,0 +1,18 @@
1
+ import { CategoryRequestOptions, CategoryResponse, FeaturesRequestOptions, FeaturesResponse, FormulaRequestOptions, FormulaResponse, HistogramRequestOptions, HistogramResponse, RangeRequestOptions, RangeResponse, ScatterRequestOptions, ScatterResponse, TableRequestOptions, TableResponse, TimeSeriesRequestOptions, TimeSeriesResponse } from './types.js';
2
+ import { WidgetSource, WidgetSourceProps } from './widget-source.js';
3
+ export type WidgetRemoteSourceProps = WidgetSourceProps;
4
+ /**
5
+ * Source for Widget API requests.
6
+ *
7
+ * Abstract class. Use {@link WidgetQuerySource} or {@link WidgetTableSource}.
8
+ */
9
+ export declare abstract class WidgetRemoteSource<Props extends WidgetRemoteSourceProps> extends WidgetSource<Props> {
10
+ getCategories(options: CategoryRequestOptions): Promise<CategoryResponse>;
11
+ getFeatures(options: FeaturesRequestOptions): Promise<FeaturesResponse>;
12
+ getFormula(options: FormulaRequestOptions): Promise<FormulaResponse>;
13
+ getHistogram(options: HistogramRequestOptions): Promise<HistogramResponse>;
14
+ getRange(options: RangeRequestOptions): Promise<RangeResponse>;
15
+ getScatter(options: ScatterRequestOptions): Promise<ScatterResponse>;
16
+ getTable(options: TableRequestOptions): Promise<TableResponse>;
17
+ getTimeSeries(options: TimeSeriesRequestOptions): Promise<TimeSeriesResponse>;
18
+ }
@@ -1,43 +1,36 @@
1
- import { CategoryRequestOptions, CategoryResponse, FeaturesRequestOptions, FeaturesResponse, FormulaRequestOptions, FormulaResponse, HistogramRequestOptions, HistogramResponse, RangeRequestOptions, RangeResponse, ScatterRequestOptions, ScatterResponse, TableRequestOptions, TableResponse, TimeSeriesRequestOptions, TimeSeriesResponse } from './types.js';
2
- import { FilterLogicalOperator, Filter } from '../types.js';
1
+ import { CategoryRequestOptions, CategoryResponse, FeaturesRequestOptions, FeaturesResponse, FormulaRequestOptions, FormulaResponse, HistogramRequestOptions, HistogramResponse, RangeRequestOptions, RangeResponse, ScatterRequestOptions, ScatterResponse, TableRequestOptions, TableResponse, TimeSeriesRequestOptions, TimeSeriesResponse, ViewState } from './types.js';
2
+ import { FilterLogicalOperator, Filter, SpatialFilter } from '../types.js';
3
3
  import { ModelSource } from '../models/model.js';
4
4
  import { SourceOptions } from '../sources/index.js';
5
5
  import { ApiVersion } from '../constants.js';
6
- export interface WidgetBaseSourceProps extends Omit<SourceOptions, 'filters'> {
6
+ export interface WidgetSourceProps extends Omit<SourceOptions, 'filters'> {
7
7
  apiVersion?: ApiVersion;
8
- geoColumn?: string;
9
8
  filters?: Record<string, Filter>;
10
9
  filtersLogicalOperator?: FilterLogicalOperator;
11
10
  }
12
- export type WidgetSource = WidgetBaseSource<WidgetBaseSourceProps>;
13
11
  /**
14
12
  * Source for Widget API requests on a data source defined by a SQL query.
15
13
  *
16
14
  * Abstract class. Use {@link WidgetQuerySource} or {@link WidgetTableSource}.
17
15
  */
18
- export declare abstract class WidgetBaseSource<Props extends WidgetBaseSourceProps> {
16
+ export declare abstract class WidgetSource<Props extends WidgetSourceProps> {
19
17
  readonly props: Props;
20
- static defaultProps: Partial<WidgetBaseSourceProps>;
18
+ static defaultProps: Partial<WidgetSourceProps>;
21
19
  constructor(props: Props);
22
20
  /**
23
- * Subclasses of {@link WidgetBaseSource} must implement this method, calling
24
- * {@link WidgetBaseSource.prototype._getModelSource} for common source
21
+ * Subclasses of {@link WidgetRemoteSource} must implement this method, calling
22
+ * {@link WidgetRemoteSource.prototype._getModelSource} for common source
25
23
  * properties, and adding additional required properties including 'type' and
26
24
  * 'data'.
27
25
  */
28
26
  protected abstract getModelSource(owner: string | undefined): ModelSource;
29
27
  protected _getModelSource(owner?: string): Omit<ModelSource, 'type' | 'data'>;
30
- /****************************************************************************
31
- * CATEGORIES
32
- */
28
+ protected _getSpatialFiltersResolution(source: Omit<ModelSource, 'type' | 'data'>, spatialFilter?: SpatialFilter, referenceViewState?: ViewState): number | undefined;
33
29
  /**
34
30
  * Returns a list of labeled datapoints for categorical data. Suitable for
35
31
  * charts including grouped bar charts, pie charts, and tree charts.
36
32
  */
37
- getCategories(options: CategoryRequestOptions): Promise<CategoryResponse>;
38
- /****************************************************************************
39
- * FEATURES
40
- */
33
+ abstract getCategories(options: CategoryRequestOptions): Promise<CategoryResponse>;
41
34
  /**
42
35
  * Given a list of feature IDs (as found in `_carto_feature_id`) returns all
43
36
  * matching features. In datasets containing features with duplicate geometries,
@@ -46,54 +39,36 @@ export declare abstract class WidgetBaseSource<Props extends WidgetBaseSourcePro
46
39
  * @internal
47
40
  * @experimental
48
41
  */
49
- getFeatures(options: FeaturesRequestOptions): Promise<FeaturesResponse>;
50
- /****************************************************************************
51
- * FORMULA
52
- */
42
+ abstract getFeatures(options: FeaturesRequestOptions): Promise<FeaturesResponse>;
53
43
  /**
54
44
  * Returns a scalar numerical statistic over all matching data. Suitable
55
45
  * for 'headline' or 'scorecard' figures such as counts and sums.
56
46
  */
57
- getFormula(options: FormulaRequestOptions): Promise<FormulaResponse>;
58
- /****************************************************************************
59
- * HISTOGRAM
60
- */
47
+ abstract getFormula(options: FormulaRequestOptions): Promise<FormulaResponse>;
61
48
  /**
62
49
  * Returns a list of labeled datapoints for 'bins' of data defined as ticks
63
50
  * over a numerical range. Suitable for histogram charts.
64
51
  */
65
- getHistogram(options: HistogramRequestOptions): Promise<HistogramResponse>;
66
- /****************************************************************************
67
- * RANGE
68
- */
52
+ abstract getHistogram(options: HistogramRequestOptions): Promise<HistogramResponse>;
69
53
  /**
70
54
  * Returns a range (min and max) for a numerical column of matching rows.
71
55
  * Suitable for displaying certain 'headline' or 'scorecard' statistics,
72
56
  * or rendering a range slider UI for filtering.
73
57
  */
74
- getRange(options: RangeRequestOptions): Promise<RangeResponse>;
75
- /****************************************************************************
76
- * SCATTER
77
- */
58
+ abstract getRange(options: RangeRequestOptions): Promise<RangeResponse>;
78
59
  /**
79
60
  * Returns a list of bivariate datapoints defined as numerical 'x' and 'y'
80
61
  * values. Suitable for rendering scatter plots.
81
62
  */
82
- getScatter(options: ScatterRequestOptions): Promise<ScatterResponse>;
83
- /****************************************************************************
84
- * TABLE
85
- */
63
+ abstract getScatter(options: ScatterRequestOptions): Promise<ScatterResponse>;
86
64
  /**
87
65
  * Returns a list of arbitrary data rows, with support for pagination and
88
66
  * sorting. Suitable for displaying tables and lists.
89
67
  */
90
- getTable(options: TableRequestOptions): Promise<TableResponse>;
91
- /****************************************************************************
92
- * TIME SERIES
93
- */
68
+ abstract getTable(options: TableRequestOptions): Promise<TableResponse>;
94
69
  /**
95
70
  * Returns a series of labeled numerical values, grouped into equally-sized
96
71
  * time intervals. Suitable for rendering time series charts.
97
72
  */
98
- getTimeSeries(options: TimeSeriesRequestOptions): Promise<TimeSeriesResponse>;
73
+ abstract getTimeSeries(options: TimeSeriesRequestOptions): Promise<TimeSeriesResponse>;
99
74
  }
@@ -1,5 +1,5 @@
1
1
  import { H3TableSourceOptions, QuadbinTableSourceOptions, VectorTableSourceOptions } from '../sources/index.js';
2
- import { WidgetBaseSource, WidgetBaseSourceProps } from './widget-base-source.js';
2
+ import { WidgetRemoteSource, WidgetRemoteSourceProps } from './widget-remote-source.js';
3
3
  import { ModelSource } from '../models/model.js';
4
4
  type LayerTableSourceOptions = Omit<VectorTableSourceOptions, 'filters'> | Omit<H3TableSourceOptions, 'filters'> | Omit<QuadbinTableSourceOptions, 'filters'>;
5
5
  export type WidgetTableSourceResult = {
@@ -27,7 +27,7 @@ export type WidgetTableSourceResult = {
27
27
  * const { widgetSource } = await data;
28
28
  * ```
29
29
  */
30
- export declare class WidgetTableSource extends WidgetBaseSource<LayerTableSourceOptions & WidgetBaseSourceProps> {
30
+ export declare class WidgetTableSource extends WidgetRemoteSource<LayerTableSourceOptions & WidgetRemoteSourceProps> {
31
31
  protected getModelSource(owner: string): ModelSource;
32
32
  }
33
33
  export {};
@@ -0,0 +1,67 @@
1
+ import { TilesetSourceOptions } from '../sources/index.js';
2
+ import type { ModelSource } from '../models/index.js';
3
+ import { CategoryRequestOptions, CategoryResponse, FeaturesRequestOptions, FeaturesResponse, FormulaRequestOptions, FormulaResponse, HistogramRequestOptions, HistogramResponse, RangeRequestOptions, RangeResponse, ScatterRequestOptions, ScatterResponse, TableRequestOptions, TableResponse, TimeSeriesRequestOptions, TimeSeriesResponse } from './types.js';
4
+ import { TileFormat } from '../constants.js';
5
+ import { SpatialFilter, Tile } from '../types.js';
6
+ import { TileFeatureExtractOptions } from '../filters/index.js';
7
+ import { FeatureCollection } from 'geojson';
8
+ import { SpatialDataType } from '../sources/types.js';
9
+ import { WidgetSource, WidgetSourceProps } from './widget-source.js';
10
+ export type WidgetTilesetSourceProps = WidgetSourceProps & Omit<TilesetSourceOptions, 'filters'> & {
11
+ tileFormat: TileFormat;
12
+ spatialDataType: SpatialDataType;
13
+ };
14
+ export type WidgetTilesetSourceResult = {
15
+ widgetSource: WidgetTilesetSource;
16
+ };
17
+ /**
18
+ * Source for Widget API requests on a data source defined by a tileset.
19
+ *
20
+ * Generally not intended to be constructed directly. Instead, call
21
+ * {@link vectorTilesetSource}, {@link h3TilesetSource}, or {@link quadbinTilesetSource},
22
+ * which can be shared with map layers. Sources contain a `widgetSource`
23
+ * property, for use by widget implementations.
24
+ *
25
+ * Example:
26
+ *
27
+ * ```javascript
28
+ * import { vectorTilesetSource } from '@carto/api-client';
29
+ *
30
+ * const data = vectorTilesetSource({
31
+ * accessToken: '••••',
32
+ * connectionName: 'carto_dw',
33
+ * tableName: 'carto-demo-data.demo_rasters.my_tileset_source'
34
+ * });
35
+ *
36
+ * const { widgetSource } = await data;
37
+ * ```
38
+ */
39
+ export declare class WidgetTilesetSource extends WidgetSource<WidgetTilesetSourceProps> {
40
+ private _features;
41
+ protected getModelSource(owner: string): ModelSource;
42
+ /** Loads features as a list of tiles (typically provided by deck.gl). */
43
+ loadTiles({ tiles, spatialFilter, uniqueIdProperty, options, }: {
44
+ tiles: Tile[];
45
+ spatialFilter: SpatialFilter;
46
+ uniqueIdProperty?: string;
47
+ options?: TileFeatureExtractOptions;
48
+ }): void;
49
+ /** Loads features as GeoJSON (used for testing). */
50
+ loadGeoJSON({ geojson, spatialFilter, uniqueIdProperty, }: {
51
+ geojson: FeatureCollection;
52
+ spatialFilter: SpatialFilter;
53
+ uniqueIdProperty?: string;
54
+ }): void;
55
+ getFeatures(options: FeaturesRequestOptions): Promise<FeaturesResponse>;
56
+ getFormula({ column, operation, joinOperation, filterOwner, }: FormulaRequestOptions): Promise<FormulaResponse>;
57
+ getHistogram({ operation, ticks, column, joinOperation, filterOwner, }: HistogramRequestOptions): Promise<HistogramResponse>;
58
+ getCategories({ column, operation, operationColumn, joinOperation, filterOwner, }: CategoryRequestOptions): Promise<CategoryResponse>;
59
+ getScatter({ xAxisColumn, yAxisColumn, xAxisJoinOperation, yAxisJoinOperation, filterOwner, }: ScatterRequestOptions): Promise<ScatterResponse>;
60
+ getTable(options: TableRequestOptions): Promise<TableResponse>;
61
+ getTimeSeries({ column, stepSize, operation, operationColumn, joinOperation, filterOwner, }: TimeSeriesRequestOptions): Promise<TimeSeriesResponse>;
62
+ getRange({ column, filterOwner, }: RangeRequestOptions): Promise<RangeResponse>;
63
+ /****************************************************************************
64
+ * INTERNAL
65
+ */
66
+ private _getFilteredFeatures;
67
+ }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "repository": "github:CartoDB/carto-api-client",
5
5
  "author": "Don McCurdy <donmccurdy@carto.com>",
6
6
  "packageManager": "yarn@4.3.1",
7
- "version": "0.4.3",
7
+ "version": "0.5.0-alpha.0",
8
8
  "license": "MIT",
9
9
  "publishConfig": {
10
10
  "access": "public",
@@ -52,51 +52,52 @@
52
52
  "LICENSE.md"
53
53
  ],
54
54
  "dependencies": {
55
+ "@loaders.gl/schema": "^4.3.3",
55
56
  "@turf/bbox-clip": "^7.1.0",
56
57
  "@turf/bbox-polygon": "^7.1.0",
58
+ "@turf/boolean-intersects": "^7.1.0",
59
+ "@turf/boolean-within": "^7.1.0",
57
60
  "@turf/helpers": "^7.1.0",
61
+ "@turf/intersect": "^7.1.0",
58
62
  "@turf/invariant": "^7.1.0",
59
63
  "@turf/union": "^7.1.0",
60
- "@types/geojson": "^7946.0.14"
64
+ "@types/geojson": "^7946.0.15",
65
+ "h3-js": "4.1.0"
61
66
  },
62
67
  "devDependencies": {
63
- "@deck.gl/aggregation-layers": "^9.0.30",
64
- "@deck.gl/carto": "^9.0.30",
65
- "@deck.gl/core": "^9.0.30",
66
- "@deck.gl/extensions": "^9.0.30",
67
- "@deck.gl/geo-layers": "^9.0.30",
68
- "@deck.gl/layers": "^9.0.30",
69
- "@deck.gl/mesh-layers": "^9.0.30",
70
- "@deck.gl/react": "^9.0.30",
71
- "@lit/react": "^1.0.5",
68
+ "@deck.gl/aggregation-layers": "^9.0.38",
69
+ "@deck.gl/carto": "^9.0.38",
70
+ "@deck.gl/core": "^9.0.38",
71
+ "@deck.gl/extensions": "^9.0.38",
72
+ "@deck.gl/geo-layers": "^9.0.38",
73
+ "@deck.gl/layers": "^9.0.38",
74
+ "@deck.gl/mesh-layers": "^9.0.38",
75
+ "@lit/react": "^1.0.6",
72
76
  "@lit/task": "^1.0.1",
73
- "@loaders.gl/core": "^4.2.3",
74
- "@luma.gl/core": "^9.0.27",
75
- "@luma.gl/engine": "^9.0.27",
76
- "@sveltejs/vite-plugin-svelte": "^3.1.2",
77
+ "@loaders.gl/core": "^4.3.3",
78
+ "@luma.gl/core": "9.0.27",
79
+ "@luma.gl/engine": "9.0.27",
77
80
  "@types/json-schema": "^7.0.15",
78
- "@types/react": "^18.3.3",
79
- "@types/react-dom": "^18.3.0",
81
+ "@types/react": "^18.3.18",
80
82
  "@types/semver": "^7.5.8",
81
- "@vitejs/plugin-vue": "^5.0.5",
82
- "@vitest/coverage-istanbul": "^1.6.0",
83
+ "@vitest/coverage-istanbul": "^2.1.8",
83
84
  "@webcomponents/webcomponentsjs": "^2.8.0",
84
- "concurrently": "^8.2.2",
85
- "echarts": "^5.5.0",
86
- "lit": "^3.1.4",
87
- "lit-analyzer": "^1.2.1",
88
- "maplibre-gl": "^4.6.0",
85
+ "concurrently": "^9.1.2",
86
+ "echarts": "^5.6.0",
87
+ "lit": "^3.2.1",
88
+ "lit-analyzer": "^2.0.3",
89
+ "maplibre-gl": "^5.0.0",
89
90
  "microbundle": "^0.15.1",
90
- "prettier": "^2.6.2",
91
- "react": "^18.3.1",
92
- "react-dom": "^18.3.1",
93
- "react-map-gl": "^7.1.7",
94
- "rimraf": "^3.0.2",
91
+ "prettier": "^3.4.2",
92
+ "rimraf": "^6.0.1",
95
93
  "semver": "^7.6.3",
96
- "svelte": "^4.2.17",
97
- "typescript": "~5.3.3",
98
- "vite": "^5.2.10",
99
- "vitest": "1.6.0",
100
- "vue": "^3.4.27"
101
- }
94
+ "thenby": "^1.3.4",
95
+ "typescript": "~5.7.3",
96
+ "vite": "^6.0.7",
97
+ "vitest": "2.1.8"
98
+ },
99
+ "resolutions": {
100
+ "rollup": "^4.20.0"
101
+ },
102
+ "stableVersion": "0.4.4"
102
103
  }
package/src/api/query.ts CHANGED
@@ -12,8 +12,7 @@ import {buildQueryUrl} from './endpoints';
12
12
  import {requestWithParameters} from './request-with-parameters';
13
13
  import {APIErrorContext} from './carto-api-error';
14
14
 
15
- export type QueryOptions = SourceOptions &
16
- Omit<QuerySourceOptions, 'spatialDataColumn'>;
15
+ export type QueryOptions = SourceOptions & QuerySourceOptions;
17
16
  type UrlParameters = {q: string; queryParameters?: string};
18
17
 
19
18
  export const query = async function (
package/src/constants.ts CHANGED
@@ -31,3 +31,28 @@ export enum ApiVersion {
31
31
 
32
32
  /** @internalRemarks Source: @carto/constants, @deck.gl/carto */
33
33
  export const DEFAULT_API_BASE_URL = 'https://gcp-us-east1.api.carto.com';
34
+
35
+ /** @internalRemarks Source: @carto/react-core */
36
+ export enum TileFormat {
37
+ MVT = 'mvt',
38
+ JSON = 'json',
39
+ GEOJSON = 'geojson',
40
+ BINARY = 'binary',
41
+ }
42
+
43
+ /** @internalRemarks Source: @carto/react-core */
44
+ export enum SpatialIndex {
45
+ H3 = 'h3',
46
+ S2 = 's2',
47
+ QUADBIN = 'quadbin',
48
+ }
49
+
50
+ /** @internalRemarks Source: @carto/react-core */
51
+ export enum Provider {
52
+ BIGQUERY = 'bigquery',
53
+ REDSHIFT = 'redshift',
54
+ POSTGRES = 'postgres',
55
+ SNOWFLAKE = 'snowflake',
56
+ DATABRICKS = 'databricks',
57
+ DATABRICKS_REST = 'databricksRest',
58
+ }