@carto/api-client 0.4.2 → 0.4.3

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 (36) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/api-client.cjs +933 -925
  3. package/build/api-client.cjs.map +1 -1
  4. package/build/api-client.modern.js +873 -865
  5. package/build/api-client.modern.js.map +1 -1
  6. package/build/index.d.ts +1 -1
  7. package/build/sources/boundary-query-source.d.ts +2 -1
  8. package/build/sources/boundary-table-source.d.ts +2 -1
  9. package/build/sources/h3-query-source.d.ts +2 -1
  10. package/build/sources/h3-table-source.d.ts +2 -1
  11. package/build/sources/h3-tileset-source.d.ts +2 -1
  12. package/build/sources/index.d.ts +13 -14
  13. package/build/sources/quadbin-query-source.d.ts +2 -1
  14. package/build/sources/quadbin-table-source.d.ts +2 -1
  15. package/build/sources/quadbin-tileset-source.d.ts +2 -1
  16. package/build/sources/raster-source.d.ts +2 -1
  17. package/build/sources/types.d.ts +16 -0
  18. package/build/sources/vector-query-source.d.ts +2 -1
  19. package/build/sources/vector-table-source.d.ts +2 -1
  20. package/build/sources/vector-tileset-source.d.ts +2 -1
  21. package/package.json +1 -1
  22. package/src/index.ts +1 -36
  23. package/src/sources/boundary-query-source.ts +4 -2
  24. package/src/sources/boundary-table-source.ts +4 -2
  25. package/src/sources/h3-query-source.ts +3 -1
  26. package/src/sources/h3-table-source.ts +3 -1
  27. package/src/sources/h3-tileset-source.ts +4 -2
  28. package/src/sources/index.ts +54 -24
  29. package/src/sources/quadbin-query-source.ts +4 -1
  30. package/src/sources/quadbin-table-source.ts +4 -1
  31. package/src/sources/quadbin-tileset-source.ts +4 -2
  32. package/src/sources/raster-source.ts +4 -2
  33. package/src/sources/types.ts +18 -0
  34. package/src/sources/vector-query-source.ts +9 -1
  35. package/src/sources/vector-table-source.ts +10 -1
  36. package/src/sources/vector-tileset-source.ts +4 -2
@@ -1,4 +1,5 @@
1
1
  import { WidgetTableSourceResult } from '../widget-sources';
2
2
  import type { AggregationOptions, FilterOptions, SourceOptions, TableSourceOptions, TilejsonResult } from './types';
3
3
  export type H3TableSourceOptions = SourceOptions & TableSourceOptions & AggregationOptions & FilterOptions;
4
- export declare const h3TableSource: (options: H3TableSourceOptions) => Promise<TilejsonResult & WidgetTableSourceResult>;
4
+ export type H3TableSourceResponse = TilejsonResult & WidgetTableSourceResult;
5
+ export declare const h3TableSource: (options: H3TableSourceOptions) => Promise<H3TableSourceResponse>;
@@ -1,3 +1,4 @@
1
1
  import type { SourceOptions, TilejsonResult, TilesetSourceOptions } from './types';
2
2
  export type H3TilesetSourceOptions = SourceOptions & TilesetSourceOptions;
3
- export declare const h3TilesetSource: (options: H3TilesetSourceOptions) => Promise<TilejsonResult>;
3
+ export type H3TilesetSourceResponse = TilejsonResult;
4
+ export declare const h3TilesetSource: (options: H3TilesetSourceOptions) => Promise<H3TilesetSourceResponse>;
@@ -1,27 +1,26 @@
1
1
  export { SOURCE_DEFAULTS } from './base-source';
2
- export type { VectorLayer, RasterMetadataBandStats, RasterBandColorinterp, RasterMetadataBand, RasterMetadata, TilejsonResult, GeojsonResult, JsonResult, QueryResult, } from './types';
2
+ export type { GeojsonResult, JsonResult, QueryResult, QuerySourceOptions, RasterBandColorinterp, RasterMetadata, RasterMetadataBand, RasterMetadataBandStats, SourceOptions, TableSourceOptions, TilejsonResult, TilesetSourceOptions, VectorLayer, } from './types';
3
3
  export { boundaryQuerySource } from './boundary-query-source';
4
- export type { BoundaryQuerySourceOptions } from './boundary-query-source';
4
+ export type { BoundaryQuerySourceOptions, BoundaryQuerySourceResponse, } from './boundary-query-source';
5
5
  export { boundaryTableSource } from './boundary-table-source';
6
- export type { BoundaryTableSourceOptions } from './boundary-table-source';
6
+ export type { BoundaryTableSourceOptions, BoundaryTableSourceResponse, } from './boundary-table-source';
7
7
  export { h3QuerySource } from './h3-query-source';
8
- export type { H3QuerySourceOptions } from './h3-query-source';
8
+ export type { H3QuerySourceOptions, H3QuerySourceResponse, } from './h3-query-source';
9
9
  export { h3TableSource } from './h3-table-source';
10
- export type { H3TableSourceOptions } from './h3-table-source';
10
+ export type { H3TableSourceOptions, H3TableSourceResponse, } from './h3-table-source';
11
11
  export { h3TilesetSource } from './h3-tileset-source';
12
- export type { H3TilesetSourceOptions } from './h3-tileset-source';
12
+ export type { H3TilesetSourceOptions, H3TilesetSourceResponse, } from './h3-tileset-source';
13
13
  export { rasterSource } from './raster-source';
14
- export type { RasterSourceOptions } from './raster-source';
14
+ export type { RasterSourceOptions, RasterSourceResponse } from './raster-source';
15
15
  export { quadbinQuerySource } from './quadbin-query-source';
16
- export type { QuadbinQuerySourceOptions } from './quadbin-query-source';
16
+ export type { QuadbinQuerySourceOptions, QuadbinQuerySourceResponse, } from './quadbin-query-source';
17
17
  export { quadbinTableSource } from './quadbin-table-source';
18
- export type { QuadbinTableSourceOptions } from './quadbin-table-source';
18
+ export type { QuadbinTableSourceOptions, QuadbinTableSourceResponse, } from './quadbin-table-source';
19
19
  export { quadbinTilesetSource } from './quadbin-tileset-source';
20
- export type { QuadbinTilesetSourceOptions } from './quadbin-tileset-source';
20
+ export type { QuadbinTilesetSourceOptions, QuadbinTilesetSourceResponse, } from './quadbin-tileset-source';
21
21
  export { vectorQuerySource } from './vector-query-source';
22
- export type { VectorQuerySourceOptions } from './vector-query-source';
22
+ export type { VectorQuerySourceOptions, VectorQuerySourceResponse, } from './vector-query-source';
23
23
  export { vectorTableSource } from './vector-table-source';
24
- export type { VectorTableSourceOptions } from './vector-table-source';
24
+ export type { VectorTableSourceOptions, VectorTableSourceResponse, } from './vector-table-source';
25
25
  export { vectorTilesetSource } from './vector-tileset-source';
26
- export type { VectorTilesetSourceOptions } from './vector-tileset-source';
27
- export type { SourceOptions, QuerySourceOptions, TableSourceOptions, TilesetSourceOptions, } from './types';
26
+ export type { VectorTilesetSourceOptions, VectorTilesetSourceResponse, } from './vector-tileset-source';
@@ -1,4 +1,5 @@
1
1
  import { WidgetQuerySourceResult } from '../widget-sources';
2
2
  import type { AggregationOptions, FilterOptions, QuerySourceOptions, SourceOptions, TilejsonResult } from './types';
3
3
  export type QuadbinQuerySourceOptions = SourceOptions & QuerySourceOptions & AggregationOptions & FilterOptions;
4
- export declare const quadbinQuerySource: (options: QuadbinQuerySourceOptions) => Promise<TilejsonResult & WidgetQuerySourceResult>;
4
+ export type QuadbinQuerySourceResponse = TilejsonResult & WidgetQuerySourceResult;
5
+ export declare const quadbinQuerySource: (options: QuadbinQuerySourceOptions) => Promise<QuadbinQuerySourceResponse>;
@@ -1,4 +1,5 @@
1
1
  import { WidgetTableSourceResult } from '../widget-sources';
2
2
  import type { AggregationOptions, FilterOptions, SourceOptions, TableSourceOptions, TilejsonResult } from './types';
3
3
  export type QuadbinTableSourceOptions = SourceOptions & TableSourceOptions & AggregationOptions & FilterOptions;
4
- export declare const quadbinTableSource: (options: QuadbinTableSourceOptions) => Promise<TilejsonResult & WidgetTableSourceResult>;
4
+ export type QuadbinTableSourceResponse = TilejsonResult & WidgetTableSourceResult;
5
+ export declare const quadbinTableSource: (options: QuadbinTableSourceOptions) => Promise<QuadbinTableSourceResponse>;
@@ -1,3 +1,4 @@
1
1
  import type { SourceOptions, TilejsonResult, TilesetSourceOptions } from './types';
2
2
  export type QuadbinTilesetSourceOptions = SourceOptions & TilesetSourceOptions;
3
- export declare const quadbinTilesetSource: (options: QuadbinTilesetSourceOptions) => Promise<TilejsonResult>;
3
+ export type QuadbinTilesetSourceResponse = TilejsonResult;
4
+ export declare const quadbinTilesetSource: (options: QuadbinTilesetSourceOptions) => Promise<QuadbinTilesetSourceResponse>;
@@ -1,3 +1,4 @@
1
1
  import type { FilterOptions, SourceOptions, TilejsonResult, TilesetSourceOptions } from './types';
2
2
  export type RasterSourceOptions = SourceOptions & TilesetSourceOptions & FilterOptions;
3
- export declare const rasterSource: (options: RasterSourceOptions) => Promise<TilejsonResult>;
3
+ export type RasterSourceResponse = TilejsonResult;
4
+ export declare const rasterSource: (options: RasterSourceOptions) => Promise<RasterSourceResponse>;
@@ -128,6 +128,14 @@ export type QuerySourceOptions = {
128
128
  * ```
129
129
  */
130
130
  queryParameters?: QueryParameters;
131
+ /**
132
+ * Comma-separated aggregation expressions. If assigned on a vector source, source is grouped by geometry and then aggregated.
133
+ *
134
+ * Example:
135
+ *
136
+ * 1 as value, avg(rev) as average_revenue
137
+ */
138
+ aggregationExp?: string;
131
139
  };
132
140
  export type TableSourceOptions = {
133
141
  /**
@@ -154,6 +162,14 @@ export type TableSourceOptions = {
154
162
  * - 4: 4096x4096
155
163
  */
156
164
  tileResolution?: TileResolution;
165
+ /**
166
+ * Comma-separated aggregation expressions. If assigned on a vector source, source is grouped by geometry and then aggregated.
167
+ *
168
+ * Example:
169
+ *
170
+ * 1 as value, avg(rev) as average_revenue
171
+ */
172
+ aggregationExp?: string;
157
173
  };
158
174
  export type TilesetSourceOptions = {
159
175
  /**
@@ -1,4 +1,5 @@
1
1
  import { WidgetQuerySourceResult } from '../widget-sources/index.js';
2
2
  import type { FilterOptions, SourceOptions, QuerySourceOptions, TilejsonResult, ColumnsOption } from './types';
3
3
  export type VectorQuerySourceOptions = SourceOptions & QuerySourceOptions & FilterOptions & ColumnsOption;
4
- export declare const vectorQuerySource: (options: VectorQuerySourceOptions) => Promise<TilejsonResult & WidgetQuerySourceResult>;
4
+ export type VectorQuerySourceResponse = TilejsonResult & WidgetQuerySourceResult;
5
+ export declare const vectorQuerySource: (options: VectorQuerySourceOptions) => Promise<VectorQuerySourceResponse>;
@@ -1,4 +1,5 @@
1
1
  import { WidgetTableSourceResult } from '../widget-sources/index.js';
2
2
  import type { FilterOptions, ColumnsOption, SourceOptions, TableSourceOptions, TilejsonResult } from './types';
3
3
  export type VectorTableSourceOptions = SourceOptions & TableSourceOptions & FilterOptions & ColumnsOption;
4
- export declare const vectorTableSource: (options: VectorTableSourceOptions) => Promise<TilejsonResult & WidgetTableSourceResult>;
4
+ export type VectorTableSourceResponse = TilejsonResult & WidgetTableSourceResult;
5
+ export declare const vectorTableSource: (options: VectorTableSourceOptions) => Promise<VectorTableSourceResponse>;
@@ -1,3 +1,4 @@
1
1
  import type { SourceOptions, TilesetSourceOptions, TilejsonResult } from './types';
2
2
  export type VectorTilesetSourceOptions = SourceOptions & TilesetSourceOptions;
3
- export declare const vectorTilesetSource: (options: VectorTilesetSourceOptions) => Promise<TilejsonResult>;
3
+ export type VectorTilesetSourceResponse = TilejsonResult;
4
+ export declare const vectorTilesetSource: (options: VectorTilesetSourceOptions) => Promise<VectorTilesetSourceResponse>;
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.2",
7
+ "version": "0.4.3",
8
8
  "license": "MIT",
9
9
  "publishConfig": {
10
10
  "access": "public",
package/src/index.ts CHANGED
@@ -2,6 +2,7 @@ export * from './client.js';
2
2
  export * from './constants.js';
3
3
  export * from './filters.js';
4
4
  export * from './geo.js';
5
+ export * from './sources/index.js';
5
6
  export * from './widget-sources/index.js';
6
7
  export * from './types.js';
7
8
 
@@ -15,39 +16,3 @@ export {
15
16
  query,
16
17
  requestWithParameters,
17
18
  } from './api/index.js';
18
-
19
- export {
20
- BoundaryQuerySourceOptions,
21
- BoundaryTableSourceOptions,
22
- GeojsonResult,
23
- H3QuerySourceOptions,
24
- H3TableSourceOptions,
25
- H3TilesetSourceOptions,
26
- JsonResult,
27
- QuadbinQuerySourceOptions,
28
- QuadbinTableSourceOptions,
29
- QuadbinTilesetSourceOptions,
30
- QueryResult,
31
- QuerySourceOptions,
32
- RasterSourceOptions,
33
- SOURCE_DEFAULTS,
34
- SourceOptions,
35
- TableSourceOptions,
36
- TilejsonResult,
37
- TilesetSourceOptions,
38
- VectorQuerySourceOptions,
39
- VectorTableSourceOptions,
40
- VectorTilesetSourceOptions,
41
- boundaryQuerySource,
42
- boundaryTableSource,
43
- h3QuerySource,
44
- h3TableSource,
45
- h3TilesetSource,
46
- quadbinQuerySource,
47
- quadbinTableSource,
48
- quadbinTilesetSource,
49
- rasterSource,
50
- vectorQuerySource,
51
- vectorTableSource,
52
- vectorTilesetSource,
53
- } from './sources/index.js';
@@ -21,9 +21,11 @@ type UrlParameters = {
21
21
  queryParameters?: Record<string, unknown> | unknown[];
22
22
  };
23
23
 
24
+ export type BoundaryQuerySourceResponse = TilejsonResult;
25
+
24
26
  export const boundaryQuerySource = async function (
25
27
  options: BoundaryQuerySourceOptions
26
- ): Promise<TilejsonResult> {
28
+ ): Promise<BoundaryQuerySourceResponse> {
27
29
  const {
28
30
  columns,
29
31
  filters,
@@ -49,5 +51,5 @@ export const boundaryQuerySource = async function (
49
51
  'boundary',
50
52
  options,
51
53
  urlParameters
52
- ) as Promise<TilejsonResult>;
54
+ ) as Promise<BoundaryQuerySourceResponse>;
53
55
  };
@@ -18,9 +18,11 @@ type UrlParameters = {
18
18
  propertiesTableName: string;
19
19
  };
20
20
 
21
+ export type BoundaryTableSourceResponse = TilejsonResult;
22
+
21
23
  export const boundaryTableSource = async function (
22
24
  options: BoundaryTableSourceOptions
23
- ): Promise<TilejsonResult> {
25
+ ): Promise<BoundaryTableSourceResponse> {
24
26
  const {filters, tilesetTableName, columns, propertiesTableName} = options;
25
27
  const urlParameters: UrlParameters = {
26
28
  tilesetTableName,
@@ -37,5 +39,5 @@ export const boundaryTableSource = async function (
37
39
  'boundary',
38
40
  options,
39
41
  urlParameters
40
- ) as Promise<TilejsonResult>;
42
+ ) as Promise<BoundaryTableSourceResponse>;
41
43
  };
@@ -29,9 +29,11 @@ type UrlParameters = {
29
29
  filters?: Record<string, unknown>;
30
30
  };
31
31
 
32
+ export type H3QuerySourceResponse = TilejsonResult & WidgetQuerySourceResult;
33
+
32
34
  export const h3QuerySource = async function (
33
35
  options: H3QuerySourceOptions
34
- ): Promise<TilejsonResult & WidgetQuerySourceResult> {
36
+ ): Promise<H3QuerySourceResponse> {
35
37
  const {
36
38
  aggregationExp,
37
39
  aggregationResLevel = DEFAULT_AGGREGATION_RES_LEVEL_H3,
@@ -29,9 +29,11 @@ type UrlParameters = {
29
29
  filters?: Record<string, unknown>;
30
30
  };
31
31
 
32
+ export type H3TableSourceResponse = TilejsonResult & WidgetTableSourceResult;
33
+
32
34
  export const h3TableSource = async function (
33
35
  options: H3TableSourceOptions
34
- ): Promise<TilejsonResult & WidgetTableSourceResult> {
36
+ ): Promise<H3TableSourceResponse> {
35
37
  const {
36
38
  aggregationExp,
37
39
  aggregationResLevel = DEFAULT_AGGREGATION_RES_LEVEL_H3,
@@ -12,9 +12,11 @@ import type {
12
12
  export type H3TilesetSourceOptions = SourceOptions & TilesetSourceOptions;
13
13
  type UrlParameters = {name: string};
14
14
 
15
+ export type H3TilesetSourceResponse = TilejsonResult;
16
+
15
17
  export const h3TilesetSource = async function (
16
18
  options: H3TilesetSourceOptions
17
- ): Promise<TilejsonResult> {
19
+ ): Promise<H3TilesetSourceResponse> {
18
20
  const {tableName} = options;
19
21
  const urlParameters: UrlParameters = {name: tableName};
20
22
 
@@ -22,5 +24,5 @@ export const h3TilesetSource = async function (
22
24
  'tileset',
23
25
  options,
24
26
  urlParameters
25
- ) as Promise<TilejsonResult>;
27
+ ) as Promise<H3TilesetSourceResponse>;
26
28
  };
@@ -4,56 +4,86 @@
4
4
 
5
5
  export {SOURCE_DEFAULTS} from './base-source';
6
6
  export type {
7
- VectorLayer,
8
- RasterMetadataBandStats,
9
- RasterBandColorinterp,
10
- RasterMetadataBand,
11
- RasterMetadata,
12
- TilejsonResult,
13
7
  GeojsonResult,
14
8
  JsonResult,
15
9
  QueryResult,
10
+ QuerySourceOptions,
11
+ RasterBandColorinterp,
12
+ RasterMetadata,
13
+ RasterMetadataBand,
14
+ RasterMetadataBandStats,
15
+ SourceOptions,
16
+ TableSourceOptions,
17
+ TilejsonResult,
18
+ TilesetSourceOptions,
19
+ VectorLayer,
16
20
  } from './types';
17
21
 
18
22
  export {boundaryQuerySource} from './boundary-query-source';
19
- export type {BoundaryQuerySourceOptions} from './boundary-query-source';
23
+ export type {
24
+ BoundaryQuerySourceOptions,
25
+ BoundaryQuerySourceResponse,
26
+ } from './boundary-query-source';
20
27
 
21
28
  export {boundaryTableSource} from './boundary-table-source';
22
- export type {BoundaryTableSourceOptions} from './boundary-table-source';
29
+ export type {
30
+ BoundaryTableSourceOptions,
31
+ BoundaryTableSourceResponse,
32
+ } from './boundary-table-source';
23
33
 
24
34
  export {h3QuerySource} from './h3-query-source';
25
- export type {H3QuerySourceOptions} from './h3-query-source';
35
+ export type {
36
+ H3QuerySourceOptions,
37
+ H3QuerySourceResponse,
38
+ } from './h3-query-source';
26
39
 
27
40
  export {h3TableSource} from './h3-table-source';
28
- export type {H3TableSourceOptions} from './h3-table-source';
41
+ export type {
42
+ H3TableSourceOptions,
43
+ H3TableSourceResponse,
44
+ } from './h3-table-source';
29
45
 
30
46
  export {h3TilesetSource} from './h3-tileset-source';
31
- export type {H3TilesetSourceOptions} from './h3-tileset-source';
47
+ export type {
48
+ H3TilesetSourceOptions,
49
+ H3TilesetSourceResponse,
50
+ } from './h3-tileset-source';
32
51
 
33
52
  export {rasterSource} from './raster-source';
34
- export type {RasterSourceOptions} from './raster-source';
53
+ export type {RasterSourceOptions, RasterSourceResponse} from './raster-source';
35
54
 
36
55
  export {quadbinQuerySource} from './quadbin-query-source';
37
- export type {QuadbinQuerySourceOptions} from './quadbin-query-source';
56
+ export type {
57
+ QuadbinQuerySourceOptions,
58
+ QuadbinQuerySourceResponse,
59
+ } from './quadbin-query-source';
38
60
 
39
61
  export {quadbinTableSource} from './quadbin-table-source';
40
- export type {QuadbinTableSourceOptions} from './quadbin-table-source';
62
+ export type {
63
+ QuadbinTableSourceOptions,
64
+ QuadbinTableSourceResponse,
65
+ } from './quadbin-table-source';
41
66
 
42
67
  export {quadbinTilesetSource} from './quadbin-tileset-source';
43
- export type {QuadbinTilesetSourceOptions} from './quadbin-tileset-source';
68
+ export type {
69
+ QuadbinTilesetSourceOptions,
70
+ QuadbinTilesetSourceResponse,
71
+ } from './quadbin-tileset-source';
44
72
 
45
73
  export {vectorQuerySource} from './vector-query-source';
46
- export type {VectorQuerySourceOptions} from './vector-query-source';
74
+ export type {
75
+ VectorQuerySourceOptions,
76
+ VectorQuerySourceResponse,
77
+ } from './vector-query-source';
47
78
 
48
79
  export {vectorTableSource} from './vector-table-source';
49
- export type {VectorTableSourceOptions} from './vector-table-source';
80
+ export type {
81
+ VectorTableSourceOptions,
82
+ VectorTableSourceResponse,
83
+ } from './vector-table-source';
50
84
 
51
85
  export {vectorTilesetSource} from './vector-tileset-source';
52
- export type {VectorTilesetSourceOptions} from './vector-tileset-source';
53
-
54
86
  export type {
55
- SourceOptions,
56
- QuerySourceOptions,
57
- TableSourceOptions,
58
- TilesetSourceOptions,
59
- } from './types';
87
+ VectorTilesetSourceOptions,
88
+ VectorTilesetSourceResponse,
89
+ } from './vector-tileset-source';
@@ -30,9 +30,12 @@ type UrlParameters = {
30
30
  filters?: Record<string, unknown>;
31
31
  };
32
32
 
33
+ export type QuadbinQuerySourceResponse = TilejsonResult &
34
+ WidgetQuerySourceResult;
35
+
33
36
  export const quadbinQuerySource = async function (
34
37
  options: QuadbinQuerySourceOptions
35
- ): Promise<TilejsonResult & WidgetQuerySourceResult> {
38
+ ): Promise<QuadbinQuerySourceResponse> {
36
39
  const {
37
40
  aggregationExp,
38
41
  aggregationResLevel = DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN,
@@ -29,9 +29,12 @@ type UrlParameters = {
29
29
  filters?: Record<string, unknown>;
30
30
  };
31
31
 
32
+ export type QuadbinTableSourceResponse = TilejsonResult &
33
+ WidgetTableSourceResult;
34
+
32
35
  export const quadbinTableSource = async function (
33
36
  options: QuadbinTableSourceOptions
34
- ): Promise<TilejsonResult & WidgetTableSourceResult> {
37
+ ): Promise<QuadbinTableSourceResponse> {
35
38
  const {
36
39
  aggregationExp,
37
40
  aggregationResLevel = DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN,
@@ -12,9 +12,11 @@ import type {
12
12
  export type QuadbinTilesetSourceOptions = SourceOptions & TilesetSourceOptions;
13
13
  type UrlParameters = {name: string};
14
14
 
15
+ export type QuadbinTilesetSourceResponse = TilejsonResult;
16
+
15
17
  export const quadbinTilesetSource = async function (
16
18
  options: QuadbinTilesetSourceOptions
17
- ): Promise<TilejsonResult> {
19
+ ): Promise<QuadbinTilesetSourceResponse> {
18
20
  const {tableName} = options;
19
21
  const urlParameters: UrlParameters = {name: tableName};
20
22
 
@@ -22,5 +24,5 @@ export const quadbinTilesetSource = async function (
22
24
  'tileset',
23
25
  options,
24
26
  urlParameters
25
- ) as Promise<TilejsonResult>;
27
+ ) as Promise<QuadbinTilesetSourceResponse>;
26
28
  };
@@ -18,9 +18,11 @@ type UrlParameters = {
18
18
  filters?: Record<string, unknown>;
19
19
  };
20
20
 
21
+ export type RasterSourceResponse = TilejsonResult;
22
+
21
23
  export const rasterSource = async function (
22
24
  options: RasterSourceOptions
23
- ): Promise<TilejsonResult> {
25
+ ): Promise<RasterSourceResponse> {
24
26
  const {tableName, filters} = options;
25
27
  const urlParameters: UrlParameters = {name: tableName};
26
28
  if (filters) {
@@ -30,5 +32,5 @@ export const rasterSource = async function (
30
32
  'raster',
31
33
  options,
32
34
  urlParameters
33
- ) as Promise<TilejsonResult>;
35
+ ) as Promise<RasterSourceResponse>;
34
36
  };
@@ -149,6 +149,15 @@ export type QuerySourceOptions = {
149
149
  * ```
150
150
  */
151
151
  queryParameters?: QueryParameters;
152
+
153
+ /**
154
+ * Comma-separated aggregation expressions. If assigned on a vector source, source is grouped by geometry and then aggregated.
155
+ *
156
+ * Example:
157
+ *
158
+ * 1 as value, avg(rev) as average_revenue
159
+ */
160
+ aggregationExp?: string;
152
161
  };
153
162
 
154
163
  export type TableSourceOptions = {
@@ -178,6 +187,15 @@ export type TableSourceOptions = {
178
187
  * - 4: 4096x4096
179
188
  */
180
189
  tileResolution?: TileResolution;
190
+
191
+ /**
192
+ * Comma-separated aggregation expressions. If assigned on a vector source, source is grouped by geometry and then aggregated.
193
+ *
194
+ * Example:
195
+ *
196
+ * 1 as value, avg(rev) as average_revenue
197
+ */
198
+ aggregationExp?: string;
181
199
  };
182
200
 
183
201
  export type TilesetSourceOptions = {
@@ -31,11 +31,15 @@ type UrlParameters = {
31
31
  tileResolution?: string;
32
32
  q: string;
33
33
  queryParameters?: Record<string, unknown> | unknown[];
34
+ aggregationExp?: string;
34
35
  };
35
36
 
37
+ export type VectorQuerySourceResponse = TilejsonResult &
38
+ WidgetQuerySourceResult;
39
+
36
40
  export const vectorQuerySource = async function (
37
41
  options: VectorQuerySourceOptions
38
- ): Promise<TilejsonResult & WidgetQuerySourceResult> {
42
+ ): Promise<VectorQuerySourceResponse> {
39
43
  const {
40
44
  columns,
41
45
  filters,
@@ -43,6 +47,7 @@ export const vectorQuerySource = async function (
43
47
  sqlQuery,
44
48
  tileResolution = DEFAULT_TILE_RESOLUTION,
45
49
  queryParameters,
50
+ aggregationExp,
46
51
  } = options;
47
52
 
48
53
  const urlParameters: UrlParameters = {
@@ -61,6 +66,9 @@ export const vectorQuerySource = async function (
61
66
  if (queryParameters) {
62
67
  urlParameters.queryParameters = queryParameters;
63
68
  }
69
+ if (aggregationExp) {
70
+ urlParameters.aggregationExp = aggregationExp;
71
+ }
64
72
  return baseSource<UrlParameters>('query', options, urlParameters).then(
65
73
  (result) => ({
66
74
  ...(result as TilejsonResult),
@@ -22,6 +22,7 @@ export type VectorTableSourceOptions = SourceOptions &
22
22
  TableSourceOptions &
23
23
  FilterOptions &
24
24
  ColumnsOption;
25
+
25
26
  type UrlParameters = {
26
27
  columns?: string;
27
28
  filters?: Record<string, unknown>;
@@ -29,17 +30,22 @@ type UrlParameters = {
29
30
  spatialDataColumn?: string;
30
31
  tileResolution?: string;
31
32
  name: string;
33
+ aggregationExp?: string;
32
34
  };
33
35
 
36
+ export type VectorTableSourceResponse = TilejsonResult &
37
+ WidgetTableSourceResult;
38
+
34
39
  export const vectorTableSource = async function (
35
40
  options: VectorTableSourceOptions
36
- ): Promise<TilejsonResult & WidgetTableSourceResult> {
41
+ ): Promise<VectorTableSourceResponse> {
37
42
  const {
38
43
  columns,
39
44
  filters,
40
45
  spatialDataColumn = 'geom',
41
46
  tableName,
42
47
  tileResolution = DEFAULT_TILE_RESOLUTION,
48
+ aggregationExp,
43
49
  } = options;
44
50
 
45
51
  const urlParameters: UrlParameters = {
@@ -55,6 +61,9 @@ export const vectorTableSource = async function (
55
61
  if (filters) {
56
62
  urlParameters.filters = filters;
57
63
  }
64
+ if (aggregationExp) {
65
+ urlParameters.aggregationExp = aggregationExp;
66
+ }
58
67
  return baseSource<UrlParameters>('table', options, urlParameters).then(
59
68
  (result) => ({
60
69
  ...(result as TilejsonResult),
@@ -12,9 +12,11 @@ import type {
12
12
  export type VectorTilesetSourceOptions = SourceOptions & TilesetSourceOptions;
13
13
  type UrlParameters = {name: string};
14
14
 
15
+ export type VectorTilesetSourceResponse = TilejsonResult;
16
+
15
17
  export const vectorTilesetSource = async function (
16
18
  options: VectorTilesetSourceOptions
17
- ): Promise<TilejsonResult> {
19
+ ): Promise<VectorTilesetSourceResponse> {
18
20
  const {tableName} = options;
19
21
  const urlParameters: UrlParameters = {name: tableName};
20
22
 
@@ -22,5 +24,5 @@ export const vectorTilesetSource = async function (
22
24
  'tileset',
23
25
  options,
24
26
  urlParameters
25
- ) as Promise<TilejsonResult>;
27
+ ) as Promise<VectorTilesetSourceResponse>;
26
28
  };