@carto/api-client 0.3.1 → 0.4.0-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.
Files changed (72) hide show
  1. package/build/api/carto-api-error.d.ts +26 -0
  2. package/build/api/endpoints.d.ts +24 -0
  3. package/build/api/index.d.ts +5 -0
  4. package/build/api/query.d.ts +3 -0
  5. package/build/api/request-with-parameters.d.ts +8 -0
  6. package/build/api-client.cjs +724 -65
  7. package/build/api-client.cjs.map +1 -1
  8. package/build/api-client.modern.js +607 -59
  9. package/build/api-client.modern.js.map +1 -1
  10. package/build/constants-internal.d.ts +9 -28
  11. package/build/constants.d.ts +24 -2
  12. package/build/index.d.ts +5 -1
  13. package/build/models/model.d.ts +2 -2
  14. package/build/sources/base-source.d.ts +4 -0
  15. package/build/sources/boundary-query-source.d.ts +9 -0
  16. package/build/sources/boundary-table-source.d.ts +7 -0
  17. package/build/sources/h3-query-source.d.ts +3 -0
  18. package/build/sources/h3-table-source.d.ts +3 -0
  19. package/build/sources/h3-tileset-source.d.ts +3 -0
  20. package/build/sources/index.d.ts +27 -5
  21. package/build/sources/quadbin-query-source.d.ts +3 -0
  22. package/build/sources/quadbin-table-source.d.ts +3 -0
  23. package/build/sources/quadbin-tileset-source.d.ts +3 -0
  24. package/build/sources/raster-source.d.ts +3 -0
  25. package/build/sources/types.d.ts +209 -85
  26. package/build/sources/vector-query-source.d.ts +3 -0
  27. package/build/sources/vector-table-source.d.ts +3 -0
  28. package/build/sources/vector-tileset-source.d.ts +3 -0
  29. package/build/types-internal.d.ts +46 -1
  30. package/build/types.d.ts +11 -0
  31. package/build/utils.d.ts +4 -0
  32. package/build/widget-sources/index.d.ts +5 -0
  33. package/build/widget-sources/types.d.ts +95 -0
  34. package/build/{sources → widget-sources}/widget-base-source.d.ts +2 -2
  35. package/build/{sources → widget-sources}/widget-query-source.d.ts +1 -1
  36. package/build/{sources → widget-sources}/widget-table-source.d.ts +1 -1
  37. package/build/{sources → widget-sources}/wrappers.d.ts +1 -1
  38. package/package.json +4 -3
  39. package/src/api/carto-api-error.ts +88 -0
  40. package/src/api/endpoints.ts +84 -0
  41. package/src/api/index.ts +14 -0
  42. package/src/api/query.ts +56 -0
  43. package/src/api/request-with-parameters.ts +135 -0
  44. package/src/constants-internal.ts +9 -30
  45. package/src/constants.ts +32 -3
  46. package/src/global.d.ts +3 -0
  47. package/src/index.ts +38 -1
  48. package/src/models/model.ts +4 -6
  49. package/src/sources/base-source.ts +101 -0
  50. package/src/sources/boundary-query-source.ts +53 -0
  51. package/src/sources/boundary-table-source.ts +41 -0
  52. package/src/sources/h3-query-source.ts +63 -0
  53. package/src/sources/h3-table-source.ts +59 -0
  54. package/src/sources/h3-tileset-source.ts +26 -0
  55. package/src/sources/index.ts +54 -5
  56. package/src/sources/quadbin-query-source.ts +64 -0
  57. package/src/sources/quadbin-table-source.ts +60 -0
  58. package/src/sources/quadbin-tileset-source.ts +26 -0
  59. package/src/sources/raster-source.ts +34 -0
  60. package/src/sources/types.ts +221 -89
  61. package/src/sources/vector-query-source.ts +65 -0
  62. package/src/sources/vector-table-source.ts +59 -0
  63. package/src/sources/vector-tileset-source.ts +26 -0
  64. package/src/types-internal.ts +54 -1
  65. package/src/types.ts +16 -0
  66. package/src/utils.ts +8 -0
  67. package/src/widget-sources/index.ts +5 -0
  68. package/src/widget-sources/types.ts +105 -0
  69. package/src/{sources → widget-sources}/widget-base-source.ts +5 -5
  70. package/src/{sources → widget-sources}/widget-query-source.ts +2 -3
  71. package/src/{sources → widget-sources}/widget-table-source.ts +2 -3
  72. package/src/{sources → widget-sources}/wrappers.ts +1 -22
@@ -1,5 +1,27 @@
1
- export * from './widget-base-source.js';
2
- export * from './widget-query-source.js';
3
- export * from './widget-table-source.js';
4
- export * from './wrappers.js';
5
- export * from './types.js';
1
+ export { SOURCE_DEFAULTS } from './base-source';
2
+ export type { TilejsonResult, GeojsonResult, JsonResult, QueryResult, } from './types';
3
+ export { boundaryQuerySource } from './boundary-query-source';
4
+ export type { BoundaryQuerySourceOptions } from './boundary-query-source';
5
+ export { boundaryTableSource } from './boundary-table-source';
6
+ export type { BoundaryTableSourceOptions } from './boundary-table-source';
7
+ export { h3QuerySource } from './h3-query-source';
8
+ export type { H3QuerySourceOptions } from './h3-query-source';
9
+ export { h3TableSource } from './h3-table-source';
10
+ export type { H3TableSourceOptions } from './h3-table-source';
11
+ export { h3TilesetSource } from './h3-tileset-source';
12
+ export type { H3TilesetSourceOptions } from './h3-tileset-source';
13
+ export { rasterSource } from './raster-source';
14
+ export type { RasterSourceOptions } from './raster-source';
15
+ export { quadbinQuerySource } from './quadbin-query-source';
16
+ export type { QuadbinQuerySourceOptions } from './quadbin-query-source';
17
+ export { quadbinTableSource } from './quadbin-table-source';
18
+ export type { QuadbinTableSourceOptions } from './quadbin-table-source';
19
+ export { quadbinTilesetSource } from './quadbin-tileset-source';
20
+ export type { QuadbinTilesetSourceOptions } from './quadbin-tileset-source';
21
+ export { vectorQuerySource } from './vector-query-source';
22
+ export type { VectorQuerySourceOptions } from './vector-query-source';
23
+ export { vectorTableSource } from './vector-table-source';
24
+ export type { VectorTableSourceOptions } from './vector-table-source';
25
+ export { vectorTilesetSource } from './vector-tileset-source';
26
+ export type { VectorTilesetSourceOptions } from './vector-tileset-source';
27
+ export type { SourceOptions, QuerySourceOptions, TableSourceOptions, TilesetSourceOptions, } from './types';
@@ -0,0 +1,3 @@
1
+ import type { AggregationOptions, FilterOptions, QuerySourceOptions, SourceOptions, TilejsonResult } from './types';
2
+ export type QuadbinQuerySourceOptions = SourceOptions & QuerySourceOptions & AggregationOptions & FilterOptions;
3
+ export declare const quadbinQuerySource: (options: QuadbinQuerySourceOptions) => Promise<TilejsonResult>;
@@ -0,0 +1,3 @@
1
+ import type { AggregationOptions, FilterOptions, SourceOptions, TableSourceOptions, TilejsonResult } from './types';
2
+ export type QuadbinTableSourceOptions = SourceOptions & TableSourceOptions & AggregationOptions & FilterOptions;
3
+ export declare const quadbinTableSource: (options: QuadbinTableSourceOptions) => Promise<TilejsonResult>;
@@ -0,0 +1,3 @@
1
+ import type { SourceOptions, TilejsonResult, TilesetSourceOptions } from './types';
2
+ export type QuadbinTilesetSourceOptions = SourceOptions & TilesetSourceOptions;
3
+ export declare const quadbinTilesetSource: (options: QuadbinTilesetSourceOptions) => Promise<TilejsonResult>;
@@ -0,0 +1,3 @@
1
+ import type { FilterOptions, SourceOptions, TilejsonResult, TilesetSourceOptions } from './types';
2
+ export type RasterSourceOptions = SourceOptions & TilesetSourceOptions & FilterOptions;
3
+ export declare const rasterSource: (options: RasterSourceOptions) => Promise<TilejsonResult>;
@@ -1,95 +1,219 @@
1
- import { GroupDateType, SortColumnType, SortDirection, SpatialFilter } from '../types';
2
- /******************************************************************************
3
- * WIDGET API REQUESTS
4
- */
5
- /** Common options for {@link WidgetBaseSource} requests. */
6
- interface BaseRequestOptions {
7
- spatialFilter?: SpatialFilter;
8
- abortController?: AbortController;
9
- filterOwner?: string;
10
- }
11
- /** Options for {@link WidgetBaseSource#getCategories}. */
12
- export interface CategoryRequestOptions extends BaseRequestOptions {
13
- column: string;
14
- operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
15
- operationColumn?: string;
16
- }
17
- /** Options for {@link WidgetBaseSource#getFormula}. */
18
- export interface FormulaRequestOptions extends BaseRequestOptions {
19
- column: string;
20
- operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
21
- operationExp?: string;
22
- }
23
- /** Options for {@link WidgetBaseSource#getHistogram}. */
24
- export interface HistogramRequestOptions extends BaseRequestOptions {
25
- column: string;
26
- ticks: number[];
27
- operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
1
+ import type { Feature } from 'geojson';
2
+ import { Filters, Format, QueryParameters } from '../types';
3
+ import { MapInstantiation } from '../types-internal';
4
+ export type SourceRequiredOptions = {
5
+ /** Carto platform access token. */
6
+ accessToken: string;
7
+ /** Data warehouse connection name in Carto platform. */
8
+ connectionName: string;
9
+ };
10
+ export type SourceOptionalOptions = {
11
+ /**
12
+ * Base URL of the CARTO Maps API.
13
+ *
14
+ * Example for account located in EU-west region: `https://gcp-eu-west1.api.carto.com`
15
+ *
16
+ * @default https://gcp-us-east1.api.carto.com
17
+ */
18
+ apiBaseUrl: string;
19
+ /**
20
+ * Custom HTTP headers added to map instantiation and data requests.
21
+ */
22
+ headers: Record<string, string>;
23
+ /**
24
+ * Cache buster value returned by map instantiation.
25
+ *
26
+ * Carto source saves `cache` value of map instantiation response in `cache.value`, so it can be used to
27
+ * check if underlying map data has changed between distinct source requests.
28
+ */
29
+ cache?: {
30
+ value?: number;
31
+ };
32
+ clientId: string;
33
+ /** @deprecated use `query` instead **/
34
+ format: Format;
35
+ /**
36
+ * Maximum URL character length. Above this limit, requests use POST.
37
+ * Used to avoid browser and CDN limits.
38
+ * @default {@link DEFAULT_MAX_LENGTH_URL}
39
+ */
40
+ maxLengthURL?: number;
41
+ };
42
+ export type SourceOptions = SourceRequiredOptions & Partial<SourceOptionalOptions>;
43
+ export type AggregationOptions = {
44
+ /**
45
+ * Defines the aggregation expressions that will be calculated from the resulting columns on each grid cell.
46
+ *
47
+ * Example:
48
+ *
49
+ * sum(pop) as total_population, avg(rev) as average_revenue
50
+ */
51
+ aggregationExp: string;
52
+ /**
53
+ * Defines the tile aggregation resolution.
54
+ *
55
+ * @default 6 for quadbin and 4 for h3 sources
56
+ */
57
+ aggregationResLevel?: number;
58
+ };
59
+ export type FilterOptions = {
60
+ /**
61
+ * Filters to apply to the data source on the server
62
+ */
63
+ filters?: Filters;
64
+ };
65
+ export type QuerySourceOptions = {
66
+ /**
67
+ * The column name and the type of geospatial support.
68
+ *
69
+ * If not present, defaults to `'geom'` for generic queries, `'quadbin'` for Quadbin sources and `'h3'` for H3 sources.
70
+ */
71
+ spatialDataColumn?: string;
72
+ /** SQL query. */
73
+ sqlQuery: string;
74
+ /**
75
+ * Relative resolution of a tile. Higher values increase density and data size. At `tileResolution = 1`, tile geometry is
76
+ * quantized to a 1024x1024 grid. Increasing or decreasing the resolution will increase or decrease the dimensions of
77
+ * the quantization grid proportionately.
78
+ *
79
+ * Supported `tileResolution` values, with corresponding grid sizes:
80
+ *
81
+ * - 0.25: 256x256
82
+ * - 0.5: 512x512
83
+ * - 1: 1024x1024
84
+ * - 2: 2048x2048
85
+ * - 4: 4096x4096
86
+ */
87
+ tileResolution?: TileResolution;
88
+ /**
89
+ * Values for named or positional paramteres in the query.
90
+ *
91
+ * The way query parameters are determined by data warehouse.
92
+ *
93
+ * * BigQuery has named query parameters, specified with a dictionary, and referenced by key (`@key`)
94
+ *
95
+ * ```
96
+ * sqlQuery: "SELECT * FROM carto-demo-data.demo_tables.retail_stores WHERE storetype = ⁣@type AND revenue > ⁣@minRevenue"
97
+ * queryParameters: { type: 'Supermarket', minRevenue: 1000000 }
98
+ * ```
99
+ * * Snowflake supports positional parameters, in the form `:1`, `:2`, etc.
100
+ *
101
+ * ```
102
+ * sqlQuery: "SELECT * FROM demo_db.public.import_retail_stores WHERE storetype = :2 AND revenue > :1
103
+ * queryParameters: [100000, "Supermarket"]
104
+ * ```
105
+ * * Postgres and Redhisft supports positional parameters, but in the form `$1`, `$2`, etc.
106
+ *
107
+ * ```
108
+ * sqlQuery: "SELECT * FROM carto_demo_data.demo_tables.retail_stores WHERE storetype = $2 AND revenue > $1
109
+ * queryParameters: [100000, "Supermarket"]
110
+ * ```
111
+ */
112
+ queryParameters?: QueryParameters;
113
+ };
114
+ export type TableSourceOptions = {
115
+ /**
116
+ * Fully qualified name of table.
117
+ */
118
+ tableName: string;
119
+ /**
120
+ * The column name and the type of geospatial support.
121
+ *
122
+ * If not present, defaults to `'geom'` for generic tables, `'quadbin'` for Quadbin sources and `'h3'` for H3 sources.
123
+ */
124
+ spatialDataColumn?: string;
125
+ /**
126
+ * Relative resolution of a tile. Higher values increase density and data size. At `tileResolution = 1`, tile geometry is
127
+ * quantized to a 1024x1024 grid. Increasing or decreasing the resolution will increase or decrease the dimensions of
128
+ * the quantization grid proportionately.
129
+ *
130
+ * Supported `tileResolution` values, with corresponding grid sizes:
131
+ *
132
+ * - 0.25: 256x256
133
+ * - 0.5: 512x512
134
+ * - 1: 1024x1024
135
+ * - 2: 2048x2048
136
+ * - 4: 4096x4096
137
+ */
138
+ tileResolution?: TileResolution;
139
+ };
140
+ export type TilesetSourceOptions = {
141
+ /**
142
+ * Fully qualified name of tileset.
143
+ */
144
+ tableName: string;
145
+ };
146
+ export type ColumnsOption = {
147
+ /**
148
+ * Columns to retrieve from the table.
149
+ *
150
+ * If not present, all columns are returned.
151
+ */
152
+ columns?: string[];
153
+ };
154
+ export type SpatialDataType = 'geo' | 'h3' | 'quadbin';
155
+ export type TilejsonMapInstantiation = MapInstantiation & {
156
+ tilejson: {
157
+ url: string[];
158
+ };
159
+ };
160
+ export type TileResolution = 0.25 | 0.5 | 1 | 2 | 4;
161
+ export interface Tilejson {
162
+ tilejson: string;
163
+ name: string;
164
+ description: string;
165
+ version: string;
166
+ attribution: string;
167
+ scheme: string;
168
+ tiles: string[];
169
+ properties_tiles: string[];
170
+ minresolution: number;
171
+ maxresolution: number;
172
+ minzoom: number;
173
+ maxzoom: number;
174
+ bounds: [number, number, number, number];
175
+ center: [number, number, number];
176
+ vector_layers: VectorLayer[];
177
+ tilestats: Tilestats;
178
+ tileResolution?: TileResolution;
28
179
  }
29
- /** Options for {@link WidgetBaseSource#getRange}. */
30
- export interface RangeRequestOptions extends BaseRequestOptions {
31
- column: string;
180
+ export interface Tilestats {
181
+ layerCount: number;
182
+ layers: Layer[];
32
183
  }
33
- /** Options for {@link WidgetBaseSource#getScatter}. */
34
- export interface ScatterRequestOptions extends BaseRequestOptions {
35
- xAxisColumn: string;
36
- xAxisJoinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
37
- yAxisColumn: string;
38
- yAxisJoinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
184
+ export interface Layer {
185
+ layer: string;
186
+ count: number;
187
+ attributeCount: number;
188
+ attributes: Attribute[];
39
189
  }
40
- /** Options for {@link WidgetBaseSource#getTable}. */
41
- export interface TableRequestOptions extends BaseRequestOptions {
42
- columns: string[];
43
- sortBy?: string;
44
- sortDirection?: SortDirection;
45
- sortByColumnType?: SortColumnType;
46
- offset?: number;
47
- limit?: number;
190
+ export interface Attribute {
191
+ attribute: string;
192
+ type: string;
48
193
  }
49
- /** Options for {@link WidgetBaseSource#getTimeSeries}. */
50
- export interface TimeSeriesRequestOptions extends BaseRequestOptions {
51
- column: string;
52
- stepSize?: GroupDateType;
53
- stepMultiplier?: number;
54
- operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
55
- operationColumn?: string;
56
- joinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
57
- splitByCategory?: string;
58
- splitByCategoryLimit?: number;
59
- splitByCategoryValues?: string[];
194
+ export interface VectorLayer {
195
+ id: string;
196
+ minzoom: number;
197
+ maxzoom: number;
198
+ fields: Record<string, string>;
60
199
  }
61
- /******************************************************************************
62
- * WIDGET API RESPONSES
63
- */
64
- /** Response from {@link WidgetBaseSource#getFormula}. */
65
- export type FormulaResponse = {
66
- value: number;
67
- };
68
- /** Response from {@link WidgetBaseSource#getCategories}. */
69
- export type CategoryResponse = {
70
- name: string;
71
- value: number;
72
- }[];
73
- /** Response from {@link WidgetBaseSource#getRange}. */
74
- export type RangeResponse = {
75
- min: number;
76
- max: number;
200
+ export type TilejsonResult = Tilejson & {
201
+ accessToken: string;
77
202
  };
78
- /** Response from {@link WidgetBaseSource#getTable}. */
79
- export type TableResponse = {
80
- totalCount: number;
81
- rows: Record<string, number | string>[];
203
+ export type GeojsonResult = {
204
+ type: 'FeatureCollection';
205
+ features: Feature[];
82
206
  };
83
- /** Response from {@link WidgetBaseSource#getScatter}. */
84
- export type ScatterResponse = [number, number][];
85
- /** Response from {@link WidgetBaseSource#getTimeSeries}. */
86
- export type TimeSeriesResponse = {
87
- rows: {
207
+ export type JsonResult = any[];
208
+ export type QueryResult = {
209
+ meta: {
210
+ cacheHit: boolean;
211
+ location: string;
212
+ totalBytesProcessed: string;
213
+ };
214
+ rows: Record<string, any>[];
215
+ schema: {
88
216
  name: string;
89
- value: number;
217
+ type: string;
90
218
  }[];
91
- categories: string[];
92
219
  };
93
- /** Response from {@link WidgetBaseSource#getHistogram}. */
94
- export type HistogramResponse = number[];
95
- export {};
@@ -0,0 +1,3 @@
1
+ import type { FilterOptions, SourceOptions, QuerySourceOptions, TilejsonResult, ColumnsOption } from './types';
2
+ export type VectorQuerySourceOptions = SourceOptions & QuerySourceOptions & FilterOptions & ColumnsOption;
3
+ export declare const vectorQuerySource: (options: VectorQuerySourceOptions) => Promise<TilejsonResult>;
@@ -0,0 +1,3 @@
1
+ import type { FilterOptions, ColumnsOption, SourceOptions, TableSourceOptions, TilejsonResult } from './types';
2
+ export type VectorTableSourceOptions = SourceOptions & TableSourceOptions & FilterOptions & ColumnsOption;
3
+ export declare const vectorTableSource: (options: VectorTableSourceOptions) => Promise<TilejsonResult>;
@@ -0,0 +1,3 @@
1
+ import type { SourceOptions, TilesetSourceOptions, TilejsonResult } from './types';
2
+ export type VectorTilesetSourceOptions = SourceOptions & TilesetSourceOptions;
3
+ export declare const vectorTilesetSource: (options: VectorTilesetSourceOptions) => Promise<TilejsonResult>;
@@ -1,7 +1,52 @@
1
1
  /******************************************************************************
2
- * INTERNAL
2
+ * COMMON
3
3
  */
4
+ import { Format } from './types';
4
5
  /** @internal */
5
6
  export type $TODO = any;
6
7
  /** @internal */
7
8
  export type $IntentionalAny = any;
9
+ /******************************************************************************
10
+ * MAP INSTANTIATION
11
+ */
12
+ /**
13
+ * @internalRemarks Source: @deck.gl/carto
14
+ * @internal
15
+ */
16
+ export declare enum SchemaFieldType {
17
+ Number = "number",
18
+ Bigint = "bigint",
19
+ String = "string",
20
+ Geometry = "geometry",
21
+ Timestamp = "timestamp",
22
+ Object = "object",
23
+ Boolean = "boolean",
24
+ Variant = "variant",
25
+ Unknown = "unknown"
26
+ }
27
+ /**
28
+ * @internalRemarks Source: @deck.gl/carto
29
+ * @internal
30
+ */
31
+ export interface SchemaField {
32
+ name: string;
33
+ type: SchemaFieldType;
34
+ }
35
+ /**
36
+ * @internalRemarks Source: @deck.gl/carto
37
+ * @internal
38
+ */
39
+ export interface MapInstantiation extends MapInstantiationFormats {
40
+ nrows: number;
41
+ size?: number;
42
+ schema: SchemaField[];
43
+ }
44
+ /**
45
+ * @internalRemarks Source: @deck.gl/carto
46
+ * @internal
47
+ */
48
+ type MapInstantiationFormats = Record<Format, {
49
+ url: string[];
50
+ error?: any;
51
+ }>;
52
+ export {};
package/build/types.d.ts CHANGED
@@ -1,5 +1,12 @@
1
1
  import type { FilterType } from './constants.js';
2
2
  import type { Polygon, MultiPolygon } from 'geojson';
3
+ /******************************************************************************
4
+ * MAPS AND TILES
5
+ */
6
+ /** @internalRemarks Source: @deck.gl/carto */
7
+ export type Format = 'json' | 'geojson' | 'tilejson';
8
+ /** @internalRemarks Source: @carto/constants, @deck.gl/carto */
9
+ export type MapType = 'boundary' | 'query' | 'table' | 'tileset' | 'raster';
3
10
  /******************************************************************************
4
11
  * AGGREGATION
5
12
  */
@@ -15,6 +22,10 @@ export type AggregationType = 'count' | 'avg' | 'min' | 'max' | 'sum' | 'custom'
15
22
  */
16
23
  /** @internalRemarks Source: @carto/react-api */
17
24
  export type SpatialFilter = Polygon | MultiPolygon;
25
+ /** @internalRemarks Source: @deck.gl/carto */
26
+ export interface Filters {
27
+ [column: string]: Filter;
28
+ }
18
29
  /** @internalRemarks Source: @carto/react-api, @deck.gl/carto */
19
30
  export interface Filter {
20
31
  [FilterType.IN]?: {
package/build/utils.d.ts CHANGED
@@ -25,4 +25,8 @@ export declare class InvalidColumnError extends Error {
25
25
  static is(error: unknown): boolean;
26
26
  }
27
27
  export declare function isEmptyObject(object: object): boolean;
28
+ /** @internal */
29
+ export declare const isObject: (x: unknown) => boolean;
30
+ /** @internal */
31
+ export declare const isPureObject: (x: any) => boolean;
28
32
  export {};
@@ -0,0 +1,5 @@
1
+ export * from './widget-base-source.js';
2
+ export * from './widget-query-source.js';
3
+ export * from './widget-table-source.js';
4
+ export * from './wrappers.js';
5
+ export * from './types.js';
@@ -0,0 +1,95 @@
1
+ import { GroupDateType, SortColumnType, SortDirection, SpatialFilter } from '../types';
2
+ /******************************************************************************
3
+ * WIDGET API REQUESTS
4
+ */
5
+ /** Common options for {@link WidgetBaseSource} requests. */
6
+ interface BaseRequestOptions {
7
+ spatialFilter?: SpatialFilter;
8
+ abortController?: AbortController;
9
+ filterOwner?: string;
10
+ }
11
+ /** Options for {@link WidgetBaseSource#getCategories}. */
12
+ export interface CategoryRequestOptions extends BaseRequestOptions {
13
+ column: string;
14
+ operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
15
+ operationColumn?: string;
16
+ }
17
+ /** Options for {@link WidgetBaseSource#getFormula}. */
18
+ export interface FormulaRequestOptions extends BaseRequestOptions {
19
+ column: string;
20
+ operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
21
+ operationExp?: string;
22
+ }
23
+ /** Options for {@link WidgetBaseSource#getHistogram}. */
24
+ export interface HistogramRequestOptions extends BaseRequestOptions {
25
+ column: string;
26
+ ticks: number[];
27
+ operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
28
+ }
29
+ /** Options for {@link WidgetBaseSource#getRange}. */
30
+ export interface RangeRequestOptions extends BaseRequestOptions {
31
+ column: string;
32
+ }
33
+ /** Options for {@link WidgetBaseSource#getScatter}. */
34
+ export interface ScatterRequestOptions extends BaseRequestOptions {
35
+ xAxisColumn: string;
36
+ xAxisJoinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
37
+ yAxisColumn: string;
38
+ yAxisJoinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
39
+ }
40
+ /** Options for {@link WidgetBaseSource#getTable}. */
41
+ export interface TableRequestOptions extends BaseRequestOptions {
42
+ columns: string[];
43
+ sortBy?: string;
44
+ sortDirection?: SortDirection;
45
+ sortByColumnType?: SortColumnType;
46
+ offset?: number;
47
+ limit?: number;
48
+ }
49
+ /** Options for {@link WidgetBaseSource#getTimeSeries}. */
50
+ export interface TimeSeriesRequestOptions extends BaseRequestOptions {
51
+ column: string;
52
+ stepSize?: GroupDateType;
53
+ stepMultiplier?: number;
54
+ operation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
55
+ operationColumn?: string;
56
+ joinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
57
+ splitByCategory?: string;
58
+ splitByCategoryLimit?: number;
59
+ splitByCategoryValues?: string[];
60
+ }
61
+ /******************************************************************************
62
+ * WIDGET API RESPONSES
63
+ */
64
+ /** Response from {@link WidgetBaseSource#getFormula}. */
65
+ export type FormulaResponse = {
66
+ value: number;
67
+ };
68
+ /** Response from {@link WidgetBaseSource#getCategories}. */
69
+ export type CategoryResponse = {
70
+ name: string;
71
+ value: number;
72
+ }[];
73
+ /** Response from {@link WidgetBaseSource#getRange}. */
74
+ export type RangeResponse = {
75
+ min: number;
76
+ max: number;
77
+ };
78
+ /** Response from {@link WidgetBaseSource#getTable}. */
79
+ export type TableResponse = {
80
+ totalCount: number;
81
+ rows: Record<string, number | string>[];
82
+ };
83
+ /** Response from {@link WidgetBaseSource#getScatter}. */
84
+ export type ScatterResponse = [number, number][];
85
+ /** Response from {@link WidgetBaseSource#getTimeSeries}. */
86
+ export type TimeSeriesResponse = {
87
+ rows: {
88
+ name: string;
89
+ value: number;
90
+ }[];
91
+ categories: string[];
92
+ };
93
+ /** Response from {@link WidgetBaseSource#getHistogram}. */
94
+ export type HistogramResponse = number[];
95
+ export {};
@@ -1,8 +1,8 @@
1
1
  import { CategoryRequestOptions, CategoryResponse, FormulaRequestOptions, FormulaResponse, HistogramRequestOptions, HistogramResponse, RangeRequestOptions, RangeResponse, ScatterRequestOptions, ScatterResponse, TableRequestOptions, TableResponse, TimeSeriesRequestOptions, TimeSeriesResponse } from './types.js';
2
2
  import { FilterLogicalOperator, Filter } from '../types.js';
3
- import { SourceOptions } from '@deck.gl/carto';
4
- import { ApiVersion } from '../constants-internal.js';
5
3
  import { ModelSource } from '../models/model.js';
4
+ import { SourceOptions } from '../sources/index.js';
5
+ import { ApiVersion } from '../constants.js';
6
6
  export interface WidgetBaseSourceProps extends Omit<SourceOptions, 'filters'> {
7
7
  apiVersion?: ApiVersion;
8
8
  geoColumn?: string;
@@ -1,4 +1,4 @@
1
- import { H3QuerySourceOptions, QuadbinQuerySourceOptions, VectorQuerySourceOptions } from '@deck.gl/carto';
1
+ import { H3QuerySourceOptions, QuadbinQuerySourceOptions, VectorQuerySourceOptions } from '../sources/index.js';
2
2
  import { WidgetBaseSource, WidgetBaseSourceProps } from './widget-base-source.js';
3
3
  import { ModelSource } from '../models/model.js';
4
4
  type LayerQuerySourceOptions = Omit<VectorQuerySourceOptions, 'filters'> | Omit<H3QuerySourceOptions, 'filters'> | Omit<QuadbinQuerySourceOptions, 'filters'>;
@@ -1,4 +1,4 @@
1
- import { H3TableSourceOptions, QuadbinTableSourceOptions, VectorTableSourceOptions } from '@deck.gl/carto';
1
+ import { H3TableSourceOptions, QuadbinTableSourceOptions, VectorTableSourceOptions } from '../sources/index.js';
2
2
  import { WidgetBaseSource, WidgetBaseSourceProps } from './widget-base-source.js';
3
3
  import { ModelSource } from '../models/model.js';
4
4
  type LayerTableSourceOptions = Omit<VectorTableSourceOptions, 'filters'> | Omit<H3TableSourceOptions, 'filters'> | Omit<QuadbinTableSourceOptions, 'filters'>;
@@ -1,4 +1,4 @@
1
- import { h3TableSource as _h3TableSource, h3QuerySource as _h3QuerySource, vectorTableSource as _vectorTableSource, vectorQuerySource as _vectorQuerySource, quadbinTableSource as _quadbinTableSource, quadbinQuerySource as _quadbinQuerySource, VectorTableSourceOptions as _VectorTableSourceOptions, VectorQuerySourceOptions as _VectorQuerySourceOptions, H3TableSourceOptions as _H3TableSourceOptions, H3QuerySourceOptions as _H3QuerySourceOptions, QuadbinTableSourceOptions as _QuadbinTableSourceOptions, QuadbinQuerySourceOptions as _QuadbinQuerySourceOptions } from '@deck.gl/carto';
1
+ import { h3TableSource as _h3TableSource, h3QuerySource as _h3QuerySource, vectorTableSource as _vectorTableSource, vectorQuerySource as _vectorQuerySource, quadbinTableSource as _quadbinTableSource, quadbinQuerySource as _quadbinQuerySource, VectorTableSourceOptions as _VectorTableSourceOptions, VectorQuerySourceOptions as _VectorQuerySourceOptions, H3TableSourceOptions as _H3TableSourceOptions, H3QuerySourceOptions as _H3QuerySourceOptions, QuadbinTableSourceOptions as _QuadbinTableSourceOptions, QuadbinQuerySourceOptions as _QuadbinQuerySourceOptions } from '../sources/index.js';
2
2
  import { WidgetBaseSourceProps } from './widget-base-source.js';
3
3
  import { WidgetQuerySource } from './widget-query-source.js';
4
4
  import { WidgetTableSource } from './widget-table-source.js';
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.3.1",
7
+ "version": "0.4.0-alpha.1",
8
8
  "license": "MIT",
9
9
  "publishConfig": {
10
10
  "access": "public",
@@ -52,7 +52,6 @@
52
52
  "LICENSE.md"
53
53
  ],
54
54
  "dependencies": {
55
- "@deck.gl/carto": "^9.0.30",
56
55
  "@turf/bbox-clip": "^7.1.0",
57
56
  "@turf/bbox-polygon": "^7.1.0",
58
57
  "@turf/helpers": "^7.1.0",
@@ -62,6 +61,7 @@
62
61
  },
63
62
  "devDependencies": {
64
63
  "@deck.gl/aggregation-layers": "^9.0.30",
64
+ "@deck.gl/carto": "^9.0.30",
65
65
  "@deck.gl/core": "^9.0.30",
66
66
  "@deck.gl/extensions": "^9.0.30",
67
67
  "@deck.gl/geo-layers": "^9.0.30",
@@ -98,5 +98,6 @@
98
98
  "vite": "^5.2.10",
99
99
  "vitest": "1.6.0",
100
100
  "vue": "^3.4.27"
101
- }
101
+ },
102
+ "stableVersion": "0.3.1"
102
103
  }