@carto/api-client 0.4.6 → 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 (124) hide show
  1. package/CHANGELOG.md +17 -1
  2. package/build/api/carto-api-error.d.ts +1 -1
  3. package/build/api/query.d.ts +1 -1
  4. package/build/api/request-with-parameters.d.ts +2 -2
  5. package/build/api-client.cjs +2365 -279
  6. package/build/api-client.cjs.map +1 -1
  7. package/build/api-client.modern.js +2274 -298
  8. package/build/api-client.modern.js.map +1 -1
  9. package/build/client.d.ts +2 -2
  10. package/build/constants-internal.d.ts +5 -5
  11. package/build/constants.d.ts +25 -3
  12. package/build/deck/get-data-filter-extension-props.d.ts +28 -0
  13. package/build/deck/index.d.ts +1 -0
  14. package/build/filters/Filter.d.ts +25 -0
  15. package/build/filters/FilterTypes.d.ts +3 -0
  16. package/build/filters/geosjonFeatures.d.ts +8 -0
  17. package/build/filters/index.d.ts +6 -0
  18. package/build/filters/tileFeatures.d.ts +20 -0
  19. package/build/filters/tileFeaturesGeometries.d.ts +13 -0
  20. package/build/filters/tileFeaturesSpatialIndex.d.ts +10 -0
  21. package/build/filters.d.ts +2 -2
  22. package/build/geo.d.ts +1 -1
  23. package/build/index.d.ts +5 -0
  24. package/build/models/common.d.ts +5 -4
  25. package/build/models/index.d.ts +1 -1
  26. package/build/models/model.d.ts +2 -2
  27. package/build/operations/aggregation.d.ts +8 -0
  28. package/build/operations/applySorting.d.ts +20 -0
  29. package/build/operations/groupBy.d.ts +15 -0
  30. package/build/operations/groupByDate.d.ts +11 -0
  31. package/build/operations/histogram.d.ts +13 -0
  32. package/build/operations/index.d.ts +6 -0
  33. package/build/operations/scatterPlot.d.ts +14 -0
  34. package/build/sources/base-source.d.ts +2 -2
  35. package/build/sources/boundary-query-source.d.ts +1 -1
  36. package/build/sources/boundary-table-source.d.ts +1 -1
  37. package/build/sources/h3-query-source.d.ts +2 -2
  38. package/build/sources/h3-table-source.d.ts +2 -2
  39. package/build/sources/h3-tileset-source.d.ts +1 -1
  40. package/build/sources/index.d.ts +26 -26
  41. package/build/sources/quadbin-query-source.d.ts +2 -2
  42. package/build/sources/quadbin-table-source.d.ts +2 -2
  43. package/build/sources/quadbin-tileset-source.d.ts +1 -1
  44. package/build/sources/raster-source.d.ts +1 -1
  45. package/build/sources/types.d.ts +3 -3
  46. package/build/sources/vector-query-source.d.ts +1 -1
  47. package/build/sources/vector-table-source.d.ts +1 -1
  48. package/build/sources/vector-tileset-source.d.ts +1 -1
  49. package/build/spatial-index.d.ts +3 -3
  50. package/build/types-internal.d.ts +9 -5
  51. package/build/types.d.ts +74 -14
  52. package/build/utils/dateUtils.d.ts +10 -0
  53. package/build/utils/getTileFormat.d.ts +3 -0
  54. package/build/utils/makeIntervalComplete.d.ts +2 -0
  55. package/build/utils/transformTileCoordsToWGS84.d.ts +8 -0
  56. package/build/utils/transformToTileCoords.d.ts +9 -0
  57. package/build/utils.d.ts +3 -3
  58. package/build/widget-sources/index.d.ts +3 -1
  59. package/build/widget-sources/types.d.ts +38 -25
  60. package/build/widget-sources/widget-query-source.d.ts +4 -3
  61. package/build/widget-sources/widget-remote-source.d.ts +18 -0
  62. package/build/widget-sources/{widget-base-source.d.ts → widget-source.d.ts} +16 -41
  63. package/build/widget-sources/widget-table-source.d.ts +4 -3
  64. package/build/widget-sources/widget-tileset-source.d.ts +75 -0
  65. package/package.json +46 -29
  66. package/src/api/carto-api-error.ts +1 -1
  67. package/src/api/query.ts +5 -5
  68. package/src/api/request-with-parameters.ts +6 -6
  69. package/src/client.ts +3 -3
  70. package/src/constants-internal.ts +5 -5
  71. package/src/constants.ts +28 -3
  72. package/src/deck/get-data-filter-extension-props.ts +164 -0
  73. package/src/deck/index.ts +1 -0
  74. package/src/filters/Filter.ts +179 -0
  75. package/src/filters/FilterTypes.ts +109 -0
  76. package/src/filters/geosjonFeatures.ts +32 -0
  77. package/src/filters/index.ts +6 -0
  78. package/src/filters/tileFeatures.ts +50 -0
  79. package/src/filters/tileFeaturesGeometries.ts +444 -0
  80. package/src/filters/tileFeaturesSpatialIndex.ts +119 -0
  81. package/src/filters.ts +4 -4
  82. package/src/geo.ts +12 -14
  83. package/src/index.ts +7 -0
  84. package/src/models/common.ts +11 -9
  85. package/src/models/index.ts +1 -1
  86. package/src/models/model.ts +3 -4
  87. package/src/operations/aggregation.ts +154 -0
  88. package/src/operations/applySorting.ts +109 -0
  89. package/src/operations/groupBy.ts +59 -0
  90. package/src/operations/groupByDate.ts +98 -0
  91. package/src/operations/histogram.ts +66 -0
  92. package/src/operations/index.ts +6 -0
  93. package/src/operations/scatterPlot.ts +50 -0
  94. package/src/sources/base-source.ts +8 -8
  95. package/src/sources/boundary-query-source.ts +2 -2
  96. package/src/sources/boundary-table-source.ts +2 -2
  97. package/src/sources/h3-query-source.ts +7 -5
  98. package/src/sources/h3-table-source.ts +7 -5
  99. package/src/sources/h3-tileset-source.ts +2 -2
  100. package/src/sources/index.ts +26 -26
  101. package/src/sources/quadbin-query-source.ts +7 -5
  102. package/src/sources/quadbin-table-source.ts +7 -5
  103. package/src/sources/quadbin-tileset-source.ts +2 -2
  104. package/src/sources/raster-source.ts +3 -2
  105. package/src/sources/types.ts +3 -3
  106. package/src/sources/vector-query-source.ts +7 -5
  107. package/src/sources/vector-table-source.ts +7 -5
  108. package/src/sources/vector-tileset-source.ts +2 -2
  109. package/src/spatial-index.ts +4 -5
  110. package/src/types-internal.ts +11 -5
  111. package/src/types.ts +73 -15
  112. package/src/utils/dateUtils.ts +28 -0
  113. package/src/utils/getTileFormat.ts +9 -0
  114. package/src/utils/makeIntervalComplete.ts +17 -0
  115. package/src/utils/transformTileCoordsToWGS84.ts +77 -0
  116. package/src/utils/transformToTileCoords.ts +85 -0
  117. package/src/utils.ts +3 -3
  118. package/src/widget-sources/index.ts +3 -1
  119. package/src/widget-sources/types.ts +39 -25
  120. package/src/widget-sources/widget-query-source.ts +12 -5
  121. package/src/widget-sources/{widget-base-source.ts → widget-remote-source.ts} +51 -171
  122. package/src/widget-sources/widget-source.ts +173 -0
  123. package/src/widget-sources/widget-table-source.ts +12 -5
  124. package/src/widget-sources/widget-tileset-source.ts +456 -0
@@ -2,8 +2,8 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import {baseSource} from './base-source';
6
- import type {FilterOptions, SourceOptions, TilejsonResult} from './types';
5
+ import {baseSource} from './base-source.js';
6
+ import type {FilterOptions, SourceOptions, TilejsonResult} from './types.js';
7
7
 
8
8
  export type BoundaryTableSourceOptions = SourceOptions &
9
9
  FilterOptions & {
@@ -2,10 +2,12 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- /* eslint-disable camelcase */
6
- import {DEFAULT_AGGREGATION_RES_LEVEL_H3} from '../constants-internal';
7
- import {WidgetQuerySource, WidgetQuerySourceResult} from '../widget-sources';
8
- import {baseSource} from './base-source';
5
+ import {DEFAULT_AGGREGATION_RES_LEVEL_H3} from '../constants-internal.js';
6
+ import {
7
+ WidgetQuerySource,
8
+ WidgetQuerySourceResult,
9
+ } from '../widget-sources/index.js';
10
+ import {baseSource} from './base-source.js';
9
11
  import type {
10
12
  AggregationOptions,
11
13
  FilterOptions,
@@ -13,7 +15,7 @@ import type {
13
15
  SourceOptions,
14
16
  SpatialDataType,
15
17
  TilejsonResult,
16
- } from './types';
18
+ } from './types.js';
17
19
 
18
20
  export type H3QuerySourceOptions = SourceOptions &
19
21
  QuerySourceOptions &
@@ -2,10 +2,12 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- /* eslint-disable camelcase */
6
- import {DEFAULT_AGGREGATION_RES_LEVEL_H3} from '../constants-internal';
7
- import {WidgetTableSource, WidgetTableSourceResult} from '../widget-sources';
8
- import {baseSource} from './base-source';
5
+ import {DEFAULT_AGGREGATION_RES_LEVEL_H3} from '../constants-internal.js';
6
+ import {
7
+ WidgetTableSource,
8
+ WidgetTableSourceResult,
9
+ } from '../widget-sources/index.js';
10
+ import {baseSource} from './base-source.js';
9
11
  import type {
10
12
  AggregationOptions,
11
13
  FilterOptions,
@@ -13,7 +15,7 @@ import type {
13
15
  SpatialDataType,
14
16
  TableSourceOptions,
15
17
  TilejsonResult,
16
- } from './types';
18
+ } from './types.js';
17
19
 
18
20
  export type H3TableSourceOptions = SourceOptions &
19
21
  TableSourceOptions &
@@ -2,12 +2,12 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import {baseSource} from './base-source';
5
+ import {baseSource} from './base-source.js';
6
6
  import type {
7
7
  SourceOptions,
8
8
  TilejsonResult,
9
9
  TilesetSourceOptions,
10
- } from './types';
10
+ } from './types.js';
11
11
 
12
12
  export type H3TilesetSourceOptions = SourceOptions & TilesetSourceOptions;
13
13
  type UrlParameters = {name: string};
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- export {SOURCE_DEFAULTS} from './base-source';
5
+ export {SOURCE_DEFAULTS} from './base-source.js';
6
6
  export type {
7
7
  GeojsonResult,
8
8
  JsonResult,
@@ -19,73 +19,73 @@ export type {
19
19
  TileResolution,
20
20
  TilesetSourceOptions,
21
21
  VectorLayer,
22
- } from './types';
22
+ } from './types.js';
23
23
 
24
- export {boundaryQuerySource} from './boundary-query-source';
24
+ export {boundaryQuerySource} from './boundary-query-source.js';
25
25
  export type {
26
26
  BoundaryQuerySourceOptions,
27
27
  BoundaryQuerySourceResponse,
28
- } from './boundary-query-source';
28
+ } from './boundary-query-source.js';
29
29
 
30
- export {boundaryTableSource} from './boundary-table-source';
30
+ export {boundaryTableSource} from './boundary-table-source.js';
31
31
  export type {
32
32
  BoundaryTableSourceOptions,
33
33
  BoundaryTableSourceResponse,
34
- } from './boundary-table-source';
34
+ } from './boundary-table-source.js';
35
35
 
36
- export {h3QuerySource} from './h3-query-source';
36
+ export {h3QuerySource} from './h3-query-source.js';
37
37
  export type {
38
38
  H3QuerySourceOptions,
39
39
  H3QuerySourceResponse,
40
- } from './h3-query-source';
40
+ } from './h3-query-source.js';
41
41
 
42
- export {h3TableSource} from './h3-table-source';
42
+ export {h3TableSource} from './h3-table-source.js';
43
43
  export type {
44
44
  H3TableSourceOptions,
45
45
  H3TableSourceResponse,
46
- } from './h3-table-source';
46
+ } from './h3-table-source.js';
47
47
 
48
- export {h3TilesetSource} from './h3-tileset-source';
48
+ export {h3TilesetSource} from './h3-tileset-source.js';
49
49
  export type {
50
50
  H3TilesetSourceOptions,
51
51
  H3TilesetSourceResponse,
52
- } from './h3-tileset-source';
52
+ } from './h3-tileset-source.js';
53
53
 
54
- export {rasterSource} from './raster-source';
55
- export type {RasterSourceOptions, RasterSourceResponse} from './raster-source';
54
+ export {rasterSource} from './raster-source.js';
55
+ export type {RasterSourceOptions} from './raster-source.js';
56
56
 
57
- export {quadbinQuerySource} from './quadbin-query-source';
57
+ export {quadbinQuerySource} from './quadbin-query-source.js';
58
58
  export type {
59
59
  QuadbinQuerySourceOptions,
60
60
  QuadbinQuerySourceResponse,
61
- } from './quadbin-query-source';
61
+ } from './quadbin-query-source.js';
62
62
 
63
- export {quadbinTableSource} from './quadbin-table-source';
63
+ export {quadbinTableSource} from './quadbin-table-source.js';
64
64
  export type {
65
65
  QuadbinTableSourceOptions,
66
66
  QuadbinTableSourceResponse,
67
- } from './quadbin-table-source';
67
+ } from './quadbin-table-source.js';
68
68
 
69
- export {quadbinTilesetSource} from './quadbin-tileset-source';
69
+ export {quadbinTilesetSource} from './quadbin-tileset-source.js';
70
70
  export type {
71
71
  QuadbinTilesetSourceOptions,
72
72
  QuadbinTilesetSourceResponse,
73
- } from './quadbin-tileset-source';
73
+ } from './quadbin-tileset-source.js';
74
74
 
75
- export {vectorQuerySource} from './vector-query-source';
75
+ export {vectorQuerySource} from './vector-query-source.js';
76
76
  export type {
77
77
  VectorQuerySourceOptions,
78
78
  VectorQuerySourceResponse,
79
- } from './vector-query-source';
79
+ } from './vector-query-source.js';
80
80
 
81
- export {vectorTableSource} from './vector-table-source';
81
+ export {vectorTableSource} from './vector-table-source.js';
82
82
  export type {
83
83
  VectorTableSourceOptions,
84
84
  VectorTableSourceResponse,
85
- } from './vector-table-source';
85
+ } from './vector-table-source.js';
86
86
 
87
- export {vectorTilesetSource} from './vector-tileset-source';
87
+ export {vectorTilesetSource} from './vector-tileset-source.js';
88
88
  export type {
89
89
  VectorTilesetSourceOptions,
90
90
  VectorTilesetSourceResponse,
91
- } from './vector-tileset-source';
91
+ } from './vector-tileset-source.js';
@@ -2,10 +2,12 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- /* eslint-disable camelcase */
6
- import {DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN} from '../constants-internal';
7
- import {WidgetQuerySource, WidgetQuerySourceResult} from '../widget-sources';
8
- import {baseSource} from './base-source';
5
+ import {DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN} from '../constants-internal.js';
6
+ import {
7
+ WidgetQuerySource,
8
+ WidgetQuerySourceResult,
9
+ } from '../widget-sources/index.js';
10
+ import {baseSource} from './base-source.js';
9
11
  import type {
10
12
  AggregationOptions,
11
13
  FilterOptions,
@@ -13,7 +15,7 @@ import type {
13
15
  SourceOptions,
14
16
  SpatialDataType,
15
17
  TilejsonResult,
16
- } from './types';
18
+ } from './types.js';
17
19
 
18
20
  export type QuadbinQuerySourceOptions = SourceOptions &
19
21
  QuerySourceOptions &
@@ -2,10 +2,12 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- /* eslint-disable camelcase */
6
- import {DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN} from '../constants-internal';
7
- import {WidgetTableSource, WidgetTableSourceResult} from '../widget-sources';
8
- import {baseSource} from './base-source';
5
+ import {DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN} from '../constants-internal.js';
6
+ import {
7
+ WidgetTableSource,
8
+ WidgetTableSourceResult,
9
+ } from '../widget-sources/index.js';
10
+ import {baseSource} from './base-source.js';
9
11
  import type {
10
12
  AggregationOptions,
11
13
  FilterOptions,
@@ -13,7 +15,7 @@ import type {
13
15
  SpatialDataType,
14
16
  TableSourceOptions,
15
17
  TilejsonResult,
16
- } from './types';
18
+ } from './types.js';
17
19
 
18
20
  export type QuadbinTableSourceOptions = SourceOptions &
19
21
  TableSourceOptions &
@@ -2,12 +2,12 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import {baseSource} from './base-source';
5
+ import {baseSource} from './base-source.js';
6
6
  import type {
7
7
  SourceOptions,
8
8
  TilejsonResult,
9
9
  TilesetSourceOptions,
10
- } from './types';
10
+ } from './types.js';
11
11
 
12
12
  export type QuadbinTilesetSourceOptions = SourceOptions & TilesetSourceOptions;
13
13
  type UrlParameters = {name: string};
@@ -2,13 +2,13 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import {baseSource} from './base-source';
5
+ import {baseSource} from './base-source.js';
6
6
  import type {
7
7
  FilterOptions,
8
8
  SourceOptions,
9
9
  TilejsonResult,
10
10
  TilesetSourceOptions,
11
- } from './types';
11
+ } from './types.js';
12
12
 
13
13
  export type RasterSourceOptions = SourceOptions &
14
14
  TilesetSourceOptions &
@@ -28,6 +28,7 @@ export const rasterSource = async function (
28
28
  if (filters) {
29
29
  urlParameters.filters = filters;
30
30
  }
31
+
31
32
  return baseSource<UrlParameters>(
32
33
  'raster',
33
34
  options,
@@ -3,8 +3,8 @@
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
5
  import type {Feature} from 'geojson';
6
- import {Filters, Format, QueryParameters} from '../types';
7
- import {MapInstantiation} from '../types-internal';
6
+ import {Filters, Format, QueryParameters} from '../types.js';
7
+ import {MapInstantiation} from '../types-internal.js';
8
8
 
9
9
  export type SourceRequiredOptions = {
10
10
  /** Carto platform access token. */
@@ -208,7 +208,7 @@ export type SpatialDataType = 'geo' | 'h3' | 'quadbin';
208
208
  * Strategy used for covering spatial filter geometry with spatial indexes.
209
209
  * See https://docs.carto.com/data-and-analysis/analytics-toolbox-for-bigquery/sql-reference/quadbin#quadbin_polyfill_mode
210
210
  * or https://docs.carto.com/data-and-analysis/analytics-toolbox-for-bigquery/sql-reference/h3#h3_polyfill_mode for more information.
211
- * @internalRemarks Source: cloud-native maps-api
211
+ * @privateRemarks Source: cloud-native maps-api
212
212
  * */
213
213
  export type SpatialFilterPolyfillMode = 'center' | 'intersects' | 'contains';
214
214
 
@@ -2,13 +2,15 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- /* eslint-disable camelcase */
6
- import {DEFAULT_TILE_RESOLUTION} from '../constants-internal.js';
5
+ import {
6
+ DEFAULT_GEO_COLUMN,
7
+ DEFAULT_TILE_RESOLUTION,
8
+ } from '../constants-internal.js';
7
9
  import {
8
10
  WidgetQuerySource,
9
11
  WidgetQuerySourceResult,
10
12
  } from '../widget-sources/index.js';
11
- import {baseSource} from './base-source';
13
+ import {baseSource} from './base-source.js';
12
14
  import type {
13
15
  FilterOptions,
14
16
  SourceOptions,
@@ -16,7 +18,7 @@ import type {
16
18
  SpatialDataType,
17
19
  TilejsonResult,
18
20
  ColumnsOption,
19
- } from './types';
21
+ } from './types.js';
20
22
 
21
23
  export type VectorQuerySourceOptions = SourceOptions &
22
24
  QuerySourceOptions &
@@ -43,7 +45,7 @@ export const vectorQuerySource = async function (
43
45
  const {
44
46
  columns,
45
47
  filters,
46
- spatialDataColumn = 'geom',
48
+ spatialDataColumn = DEFAULT_GEO_COLUMN,
47
49
  sqlQuery,
48
50
  tileResolution = DEFAULT_TILE_RESOLUTION,
49
51
  queryParameters,
@@ -2,13 +2,15 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- /* eslint-disable camelcase */
6
- import {DEFAULT_TILE_RESOLUTION} from '../constants-internal.js';
5
+ import {
6
+ DEFAULT_GEO_COLUMN,
7
+ DEFAULT_TILE_RESOLUTION,
8
+ } from '../constants-internal.js';
7
9
  import {
8
10
  WidgetTableSource,
9
11
  WidgetTableSourceResult,
10
12
  } from '../widget-sources/index.js';
11
- import {baseSource} from './base-source';
13
+ import {baseSource} from './base-source.js';
12
14
  import type {
13
15
  FilterOptions,
14
16
  ColumnsOption,
@@ -16,7 +18,7 @@ import type {
16
18
  SpatialDataType,
17
19
  TableSourceOptions,
18
20
  TilejsonResult,
19
- } from './types';
21
+ } from './types.js';
20
22
 
21
23
  export type VectorTableSourceOptions = SourceOptions &
22
24
  TableSourceOptions &
@@ -42,7 +44,7 @@ export const vectorTableSource = async function (
42
44
  const {
43
45
  columns,
44
46
  filters,
45
- spatialDataColumn = 'geom',
47
+ spatialDataColumn = DEFAULT_GEO_COLUMN,
46
48
  tableName,
47
49
  tileResolution = DEFAULT_TILE_RESOLUTION,
48
50
  aggregationExp,
@@ -2,12 +2,12 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import {baseSource} from './base-source';
5
+ import {baseSource} from './base-source.js';
6
6
  import type {
7
7
  SourceOptions,
8
8
  TilesetSourceOptions,
9
9
  TilejsonResult,
10
- } from './types';
10
+ } from './types.js';
11
11
 
12
12
  export type VectorTilesetSourceOptions = SourceOptions & TilesetSourceOptions;
13
13
  type UrlParameters = {name: string};
@@ -1,11 +1,10 @@
1
1
  import {
2
2
  DEFAULT_AGGREGATION_RES_LEVEL_H3,
3
3
  DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN,
4
- } from './constants-internal';
5
- import type {ModelSource} from './models/model';
6
- import type {AggregationOptions} from './sources/types';
7
- import {assert} from './utils';
8
- import type {ViewState} from './widget-sources';
4
+ } from './constants-internal.js';
5
+ import type {ModelSource} from './models/model.js';
6
+ import type {AggregationOptions} from './sources/types.js';
7
+ import type {ViewState} from './widget-sources/index.js';
9
8
 
10
9
  const DEFAULT_TILE_SIZE = 512;
11
10
  const QUADBIN_ZOOM_MAX_OFFSET = 4;
@@ -2,7 +2,7 @@
2
2
  * COMMON
3
3
  */
4
4
 
5
- import {Format} from './types';
5
+ import {Format} from './types.js';
6
6
 
7
7
  /** @internal */
8
8
  export type $TODO = any;
@@ -15,7 +15,7 @@ export type $IntentionalAny = any;
15
15
  */
16
16
 
17
17
  /**
18
- * @internalRemarks Source: @deck.gl/carto
18
+ * @privateRemarks Source: @deck.gl/carto
19
19
  * @internal
20
20
  */
21
21
  export enum SchemaFieldType {
@@ -31,7 +31,7 @@ export enum SchemaFieldType {
31
31
  }
32
32
 
33
33
  /**
34
- * @internalRemarks Source: @deck.gl/carto
34
+ * @privateRemarks Source: @deck.gl/carto
35
35
  * @internal
36
36
  */
37
37
  export interface SchemaField {
@@ -40,7 +40,7 @@ export interface SchemaField {
40
40
  }
41
41
 
42
42
  /**
43
- * @internalRemarks Source: @deck.gl/carto
43
+ * @privateRemarks Source: @deck.gl/carto
44
44
  * @internal
45
45
  */
46
46
  export interface MapInstantiation extends MapInstantiationFormats {
@@ -50,7 +50,7 @@ export interface MapInstantiation extends MapInstantiationFormats {
50
50
  }
51
51
 
52
52
  /**
53
- * @internalRemarks Source: @deck.gl/carto
53
+ * @privateRemarks Source: @deck.gl/carto
54
54
  * @internal
55
55
  */
56
56
  type MapInstantiationFormats = Record<
@@ -60,3 +60,9 @@ type MapInstantiationFormats = Record<
60
60
  error?: any;
61
61
  }
62
62
  >;
63
+
64
+ /******************************************************************************
65
+ * LOCAL CALCULATIONS
66
+ */
67
+
68
+ export type FeatureData = Record<string, unknown>;
package/src/types.ts CHANGED
@@ -1,16 +1,54 @@
1
1
  import type {FilterType} from './constants.js';
2
- import type {Polygon, MultiPolygon} from 'geojson';
2
+ import type {Polygon, MultiPolygon, Feature} from 'geojson';
3
+ import type {BinaryFeature, BinaryFeatureCollection} from '@loaders.gl/schema';
3
4
 
4
5
  /******************************************************************************
5
6
  * MAPS AND TILES
6
7
  */
7
8
 
8
- /** @internalRemarks Source: @deck.gl/carto */
9
+ /** @privateRemarks Source: @deck.gl/carto */
9
10
  export type Format = 'json' | 'geojson' | 'tilejson';
10
11
 
11
- /** @internalRemarks Source: @carto/constants, @deck.gl/carto */
12
+ /** @privateRemarks Source: @carto/constants, @deck.gl/carto */
12
13
  export type MapType = 'boundary' | 'query' | 'table' | 'tileset' | 'raster';
13
14
 
15
+ /**
16
+ * Alias for GeoJSON 'BBox' type, semantically representing a viewport.
17
+ * Order of values is "west", "south", "east", "north".
18
+ */
19
+ export type Viewport = [number, number, number, number];
20
+
21
+ /**
22
+ * Subset of deck.gl's Tile2DHeader type, containing only the properties
23
+ * required for local widget calculations. Deeper dependencies on deck.gl
24
+ * APIs should be minimized within this library: @deck.gl/carto depends
25
+ * on the API client, not the other way around.
26
+ * @privateRemarks Source: @deck.gl/geo-layers
27
+ */
28
+ export type Tile = {
29
+ index: {x: number; y: number; z: number};
30
+ id: string;
31
+ content: unknown;
32
+ zoom: number;
33
+ bbox: {west: number; east: number; north: number; south: number};
34
+ isVisible: boolean;
35
+ data?: BinaryFeatureCollection;
36
+ };
37
+
38
+ /** Subset of deck.gl's Tile2DHeader type, for spatial indexes. */
39
+ export type SpatialIndexTile = Tile & {
40
+ data?: (Feature & {id: bigint})[];
41
+ };
42
+
43
+ /** @privateRemarks Source: @deck.gl/carto */
44
+ export type Raster = {
45
+ blockSize: number;
46
+ cells: {
47
+ numericProps: BinaryFeature['numericProps'];
48
+ properties: BinaryFeature['properties'];
49
+ };
50
+ };
51
+
14
52
  /******************************************************************************
15
53
  * AGGREGATION
16
54
  */
@@ -18,8 +56,8 @@ export type MapType = 'boundary' | 'query' | 'table' | 'tileset' | 'raster';
18
56
  /**
19
57
  * Enum for the different types of aggregations available for widgets.
20
58
  *
21
- * @internalRemarks Source: @carto/constants
22
- * @internalRemarks Converted from enum to type union, for improved declarative API.
59
+ * @privateRemarks Source: @carto/constants
60
+ * @privateRemarks Converted from enum to type union, for improved declarative API.
23
61
  */
24
62
  export type AggregationType =
25
63
  | 'count'
@@ -33,15 +71,15 @@ export type AggregationType =
33
71
  * FILTERS
34
72
  */
35
73
 
36
- /** @internalRemarks Source: @carto/react-api */
74
+ /** @privateRemarks Source: @carto/react-api */
37
75
  export type SpatialFilter = Polygon | MultiPolygon;
38
76
 
39
- /** @internalRemarks Source: @deck.gl/carto */
77
+ /** @privateRemarks Source: @deck.gl/carto */
40
78
  export interface Filters {
41
79
  [column: string]: Filter;
42
80
  }
43
81
 
44
- /** @internalRemarks Source: @carto/react-api, @deck.gl/carto */
82
+ /** @privateRemarks Source: @carto/react-api, @deck.gl/carto */
45
83
  export interface Filter {
46
84
  [FilterType.IN]?: {owner?: string; values: number[] | string[]};
47
85
  /** [a, b] both are included. */
@@ -49,12 +87,32 @@ export interface Filter {
49
87
  /** [a, b) a is included, b is not. */
50
88
  [FilterType.CLOSED_OPEN]?: {owner?: string; values: number[][]};
51
89
  [FilterType.TIME]?: {owner?: string; values: number[][]};
52
- [FilterType.STRING_SEARCH]?: {owner?: string; values: string[]};
90
+ [FilterType.STRING_SEARCH]?: {
91
+ owner?: string;
92
+ values: string[];
93
+ params?: StringSearchOptions;
94
+ };
53
95
  }
54
96
 
55
- /** @internalRemarks Source: @carto/react-core */
97
+ /** @privateRemarks Source: @carto/react-core */
56
98
  export type FilterLogicalOperator = 'and' | 'or';
57
99
 
100
+ /**
101
+ * Type for minimum or maximum value of an interval. Values 'null' and
102
+ * 'undefined' are intentionally allowed, and represent an unbounded value.
103
+ */
104
+ export type FilterIntervalExtremum = number | null | undefined;
105
+ export type FilterInterval = [FilterIntervalExtremum, FilterIntervalExtremum];
106
+ export type FilterIntervalComplete = [number, number];
107
+
108
+ export type StringSearchOptions = {
109
+ useRegExp?: boolean;
110
+ mustStart?: boolean;
111
+ mustEnd?: boolean;
112
+ caseSensitive?: boolean;
113
+ keepSpecialCharacters?: boolean;
114
+ };
115
+
58
116
  /******************************************************************************
59
117
  * GROUPING
60
118
  */
@@ -62,7 +120,7 @@ export type FilterLogicalOperator = 'and' | 'or';
62
120
  /**
63
121
  * Defines a step size increment for use with {@link TimeSeriesRequestOptions}.
64
122
  *
65
- * @internalRemarks Source: @carto/react-core
123
+ * @privateRemarks Source: @carto/react-core
66
124
  */
67
125
  export type GroupDateType =
68
126
  | 'year'
@@ -84,7 +142,7 @@ export type SortColumnType = 'number' | 'string' | 'date';
84
142
  * SQL QUERY PARAMETERS
85
143
  */
86
144
 
87
- /** @internalRemarks Source: @deck.gl/carto */
145
+ /** @privateRemarks Source: @deck.gl/carto */
88
146
  export type QueryParameterValue =
89
147
  | string
90
148
  | number
@@ -92,11 +150,11 @@ export type QueryParameterValue =
92
150
  | Array<QueryParameterValue>
93
151
  | object;
94
152
 
95
- /** @internalRemarks Source: @deck.gl/carto */
153
+ /** @privateRemarks Source: @deck.gl/carto */
96
154
  export type NamedQueryParameter = Record<string, QueryParameterValue>;
97
155
 
98
- /** @internalRemarks Source: @deck.gl/carto */
156
+ /** @privateRemarks Source: @deck.gl/carto */
99
157
  export type PositionalQueryParameter = QueryParameterValue[];
100
158
 
101
- /** @internalRemarks Source: @deck.gl/carto */
159
+ /** @privateRemarks Source: @deck.gl/carto */
102
160
  export type QueryParameters = NamedQueryParameter | PositionalQueryParameter;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Returns midnight (local time) on the Monday preceeding a given date, in
3
+ * milliseconds since the UNIX epoch.
4
+ */
5
+ export function getMonday(date: number | Date): number {
6
+ const dateCp = new Date(date);
7
+ const day = dateCp.getDay();
8
+ const diff = dateCp.getDate() - day + (day ? 1 : -6); // adjust when day is sunday
9
+ dateCp.setDate(diff);
10
+ dateCp.setHours(0, 0, 0, 0);
11
+ return dateCp.getTime();
12
+ }
13
+
14
+ /**
15
+ * Returns midnight (UTC) on the Monday preceeding a given date, in
16
+ * milliseconds since the UNIX epoch.
17
+ */
18
+ export function getUTCMonday(date: number | Date): number {
19
+ const dateCp = new Date(date);
20
+ const day = dateCp.getUTCDay();
21
+ const diff = dateCp.getUTCDate() - day + (day ? 1 : -6); // adjust when day is sunday
22
+ dateCp.setUTCDate(diff);
23
+ return Date.UTC(
24
+ dateCp.getUTCFullYear(),
25
+ dateCp.getUTCMonth(),
26
+ dateCp.getUTCDate()
27
+ );
28
+ }
@@ -0,0 +1,9 @@
1
+ import {TileFormat} from '../constants.js';
2
+ import {Tilejson} from '../sources/types.js';
3
+
4
+ export function getTileFormat(tilejson: Tilejson): TileFormat {
5
+ const tileParams = new URL(tilejson.tiles[0]).searchParams;
6
+ return tileParams.get('formatTiles') === 'mvt'
7
+ ? TileFormat.MVT
8
+ : TileFormat.BINARY;
9
+ }