@@ -2,39 +2,127 @@ import type {Feature} from 'geojson';
22import type { Format , MapInstantiation , QueryParameters } from '../api/types' ;
33
44export type SourceRequiredOptions = {
5+ /** Carto platform access token. */
56 accessToken : string ;
7+
8+ /** Data warehouse connection name in Carto platform. */
69 connectionName : string ;
710} ;
811
912export type SourceOptionalOptions = {
13+ /**
14+ * Base URL of the CARTO Maps API.
15+ *
16+ * Example for account located in EU-west region: `https://gcp-eu-west1.api.carto.com`
17+ *
18+ * @default https://gcp-us-east1.api.carto.com
19+ */
1020 apiBaseUrl : string ;
21+
22+ /**
23+ * Custom HTTP headers added to map instantiation and data requests.
24+ */
25+ headers : Record < string , string > ;
26+
27+ /**
28+ * Cache buster value returned by map instantiation.
29+ *
30+ * Carto source saves `cache` value of map instantiation response in `cache.value`, so it can be used to
31+ * check if underlying map data has changed between distinct source requests.
32+ */
1133 cache ?: { value ?: number } ;
34+
1235 clientId : string ;
1336 /** @deprecated use `query` instead **/
1437 format : Format ;
15- headers : Record < string , string > ;
1638} ;
1739
1840export type SourceOptions = SourceRequiredOptions & Partial < SourceOptionalOptions > ;
1941
2042export type AggregationOptions = {
43+ /**
44+ * Defines the aggregation expressions that will be calculated from the resulting columns on each grid cell.
45+ *
46+ * Example:
47+ *
48+ * sum(pop) as total_population, avg(rev) as average_revenue
49+ */
2150 aggregationExp : string ;
51+
52+ /**
53+ * Defines the tile aggregation resolution.
54+ *
55+ * If not present,
56+ *
57+ * @default 6 for quadbin and 4 for h3 sources
58+ */
2259 aggregationResLevel ?: number ;
2360} ;
2461
2562export type QuerySourceOptions = {
63+ /**
64+ * The column name and the type of geospatial support.
65+ *
66+ * If not present, defaults to `'geom'` for generic queries, `'quadbin'` for Quadbin sources and `'h3'` for H3 sources.
67+ */
2668 spatialDataColumn ?: string ;
69+
70+ /** SQL query. */
2771 sqlQuery : string ;
72+
73+ /**
74+ * Values for named or positional paramteres in the query.
75+ *
76+ *
77+ * The way query parameters are determined by data ware house.
78+ *
79+ * * BigQuery has named query parameters as `@name` and they can be specified as dictionary
80+ *
81+ * ```
82+ * sqlQuery: "SELECT * FROM carto-demo-data.demo_tables.retail_stores WHERE storetype = @type AND revenue > @minRevenue"
83+ * queryParameters: { type: 'Supermarket', minRevenue: 1000000 }
84+ * ```
85+ * * Snowflake supports positional parametes, in form `:1`, `:2`, etc.
86+ *
87+ * ```
88+ * sqlQuery: "SELECT * FROM demo_db.public.import_retail_stores WHERE storetype = :2 AND revenue > :1
89+ * queryParameters: [100000, "Supermarket"]
90+ * ```
91+ * * Postgres and Redhisft supports positional parametes, but in form `$1`, `$2`, etc.
92+ *
93+ * ```
94+ * sqlQuery: "SELECT * FROM carto_demo_data.demo_tables.retail_stores WHERE storetype = $2 AND revenue > $1
95+ * queryParameters: [100000, "Supermarket"]
96+ * ```
97+ */
2898 queryParameters ?: QueryParameters ;
2999} ;
30100
31101export type TableSourceOptions = {
102+ /**
103+ * Fully qualified name of table.
104+ */
105+ tableName : string ;
106+
107+ /**
108+ * Columns to retrieve from the table.
109+ *
110+ * If not specidfied, default all columns are returned.
111+ */
32112 columns ?: string [ ] ;
113+
114+ /**
115+ * The column name and the type of geospatial support.
116+ *
117+ * If not present, defaults to `'geom'` for generic tables, `'quadbin'` for Quadbin sources and `'h3'` for H3 sources.
118+ */
33119 spatialDataColumn ?: string ;
34- tableName : string ;
35120} ;
36121
37122export type TilesetSourceOptions = {
123+ /**
124+ * Fully qualified name of tileset.
125+ */
38126 tableName : string ;
39127} ;
40128
0 commit comments