@deck.gl/carto 8.10.0-alpha.7 → 9.0.0-alpha.4

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 (365) hide show
  1. package/dist/cartoRasterTile-worker.js +32 -24
  2. package/dist/cartoSpatialTile-worker.js +32 -24
  3. package/dist/cartoVectorTile-worker.js +69 -63
  4. package/dist/dist.dev.js +12061 -12560
  5. package/dist/es5/api/carto-api-error.js.map +1 -1
  6. package/dist/es5/api/common.js +25 -0
  7. package/dist/es5/api/common.js.map +1 -0
  8. package/dist/es5/api/endpoints.js +40 -0
  9. package/dist/es5/api/endpoints.js.map +1 -0
  10. package/dist/es5/api/fetch-map.js +568 -0
  11. package/dist/es5/api/fetch-map.js.map +1 -0
  12. package/dist/es5/api/index.js +5 -49
  13. package/dist/es5/api/index.js.map +1 -1
  14. package/dist/es5/api/layer-map.js +43 -45
  15. package/dist/es5/api/layer-map.js.map +1 -1
  16. package/dist/es5/api/{parseMap.js → parse-map.js} +5 -3
  17. package/dist/es5/api/parse-map.js.map +1 -0
  18. package/dist/es5/api/query.js +78 -0
  19. package/dist/es5/api/query.js.map +1 -0
  20. package/dist/es5/{sources/utils.js → api/request-with-parameters.js} +60 -46
  21. package/dist/es5/api/request-with-parameters.js.map +1 -0
  22. package/dist/es5/api/types.js +19 -0
  23. package/dist/es5/api/types.js.map +1 -1
  24. package/dist/es5/index.js +66 -80
  25. package/dist/es5/index.js.map +1 -1
  26. package/dist/es5/layers/h3-tile-layer.js +3 -5
  27. package/dist/es5/layers/h3-tile-layer.js.map +1 -1
  28. package/dist/es5/layers/point-label-layer.js.map +1 -1
  29. package/dist/es5/layers/quadbin-layer.js.map +1 -1
  30. package/dist/es5/layers/quadbin-tile-layer.js +1 -4
  31. package/dist/es5/layers/quadbin-tile-layer.js.map +1 -1
  32. package/dist/es5/layers/raster-layer.js +2 -0
  33. package/dist/es5/layers/raster-layer.js.map +1 -1
  34. package/dist/es5/layers/raster-tile-layer.js +1 -3
  35. package/dist/es5/layers/raster-tile-layer.js.map +1 -1
  36. package/dist/es5/layers/schema/carto-properties-tile-loader.js +60 -0
  37. package/dist/es5/layers/schema/carto-properties-tile-loader.js.map +1 -0
  38. package/dist/es5/layers/schema/carto-properties-tile.js +38 -0
  39. package/dist/es5/layers/schema/carto-properties-tile.js.map +1 -0
  40. package/dist/es5/layers/schema/carto-raster-tile-loader.js +1 -1
  41. package/dist/es5/layers/schema/carto-raster-tile-loader.js.map +1 -1
  42. package/dist/es5/layers/schema/carto-spatial-tile-loader.js +1 -1
  43. package/dist/es5/layers/schema/carto-spatial-tile-loader.js.map +1 -1
  44. package/dist/es5/layers/schema/carto-vector-tile-loader.js +1 -2
  45. package/dist/es5/layers/schema/carto-vector-tile-loader.js.map +1 -1
  46. package/dist/es5/layers/spatial-index-tile-layer.js +16 -26
  47. package/dist/es5/layers/spatial-index-tile-layer.js.map +1 -1
  48. package/dist/es5/layers/utils.js +102 -0
  49. package/dist/es5/layers/utils.js.map +1 -1
  50. package/dist/es5/layers/vector-tile-layer.js +112 -27
  51. package/dist/es5/layers/vector-tile-layer.js.map +1 -1
  52. package/dist/es5/sources/base-source.js +56 -28
  53. package/dist/es5/sources/base-source.js.map +1 -1
  54. package/dist/es5/sources/boundary-query-source.js +51 -0
  55. package/dist/es5/sources/boundary-query-source.js.map +1 -0
  56. package/dist/es5/sources/boundary-table-source.js +51 -0
  57. package/dist/es5/sources/boundary-table-source.js.map +1 -0
  58. package/dist/es5/sources/boundary-tileset-source.js +43 -0
  59. package/dist/es5/sources/boundary-tileset-source.js.map +1 -0
  60. package/dist/es5/sources/h3-query-source.js +9 -11
  61. package/dist/es5/sources/h3-query-source.js.map +1 -1
  62. package/dist/es5/sources/h3-table-source.js +10 -12
  63. package/dist/es5/sources/h3-table-source.js.map +1 -1
  64. package/dist/es5/sources/h3-tileset-source.js +5 -5
  65. package/dist/es5/sources/h3-tileset-source.js.map +1 -1
  66. package/dist/es5/sources/index.js +46 -22
  67. package/dist/es5/sources/index.js.map +1 -1
  68. package/dist/es5/sources/quadbin-query-source.js +10 -12
  69. package/dist/es5/sources/quadbin-query-source.js.map +1 -1
  70. package/dist/es5/sources/quadbin-table-source.js +10 -12
  71. package/dist/es5/sources/quadbin-table-source.js.map +1 -1
  72. package/dist/es5/sources/quadbin-tileset-source.js +5 -5
  73. package/dist/es5/sources/quadbin-tileset-source.js.map +1 -1
  74. package/dist/es5/sources/raster-source.js +5 -5
  75. package/dist/es5/sources/raster-source.js.map +1 -1
  76. package/dist/es5/sources/types.js +2 -0
  77. package/dist/es5/sources/types.js.map +1 -0
  78. package/dist/es5/sources/vector-query-source.js +11 -12
  79. package/dist/es5/sources/vector-query-source.js.map +1 -1
  80. package/dist/es5/sources/vector-table-source.js +12 -13
  81. package/dist/es5/sources/vector-table-source.js.map +1 -1
  82. package/dist/es5/sources/vector-tileset-source.js +5 -5
  83. package/dist/es5/sources/vector-tileset-source.js.map +1 -1
  84. package/dist/es5/style/color-bins-style.js +4 -2
  85. package/dist/es5/style/color-bins-style.js.map +1 -1
  86. package/dist/es5/style/color-categories-style.js +4 -2
  87. package/dist/es5/style/color-categories-style.js.map +1 -1
  88. package/dist/es5/style/color-continuous-style.js +4 -2
  89. package/dist/es5/style/color-continuous-style.js.map +1 -1
  90. package/dist/es5/style/palette.js +1 -1
  91. package/dist/es5/style/palette.js.map +1 -1
  92. package/dist/es5/style/utils.js +4 -11
  93. package/dist/es5/style/utils.js.map +1 -1
  94. package/dist/es5/utils.js +30 -1
  95. package/dist/es5/utils.js.map +1 -1
  96. package/dist/esm/api/carto-api-error.js.map +1 -1
  97. package/dist/esm/api/common.js +13 -0
  98. package/dist/esm/api/common.js.map +1 -0
  99. package/dist/esm/api/endpoints.js +28 -0
  100. package/dist/esm/api/endpoints.js.map +1 -0
  101. package/dist/esm/api/fetch-map.js +300 -0
  102. package/dist/esm/api/fetch-map.js.map +1 -0
  103. package/dist/esm/api/index.js +2 -3
  104. package/dist/esm/api/index.js.map +1 -1
  105. package/dist/esm/api/layer-map.js +43 -35
  106. package/dist/esm/api/layer-map.js.map +1 -1
  107. package/dist/esm/api/{parseMap.js → parse-map.js} +3 -2
  108. package/dist/esm/api/parse-map.js.map +1 -0
  109. package/dist/esm/api/query.js +38 -0
  110. package/dist/esm/api/query.js.map +1 -0
  111. package/dist/esm/{sources/utils.js → api/request-with-parameters.js} +25 -12
  112. package/dist/esm/api/request-with-parameters.js.map +1 -0
  113. package/dist/esm/api/types.js +13 -1
  114. package/dist/esm/api/types.js.map +1 -1
  115. package/dist/esm/index.js +31 -9
  116. package/dist/esm/index.js.map +1 -1
  117. package/dist/esm/layers/h3-tile-layer.js +2 -6
  118. package/dist/esm/layers/h3-tile-layer.js.map +1 -1
  119. package/dist/esm/layers/point-label-layer.js.map +1 -1
  120. package/dist/esm/layers/quadbin-layer.js.map +1 -1
  121. package/dist/esm/layers/quadbin-tile-layer.js +1 -3
  122. package/dist/esm/layers/quadbin-tile-layer.js.map +1 -1
  123. package/dist/esm/layers/raster-layer.js +1 -0
  124. package/dist/esm/layers/raster-layer.js.map +1 -1
  125. package/dist/esm/layers/raster-tile-layer.js +1 -2
  126. package/dist/esm/layers/raster-tile-layer.js.map +1 -1
  127. package/dist/esm/layers/schema/carto-properties-tile-loader.js +23 -0
  128. package/dist/esm/layers/schema/carto-properties-tile-loader.js.map +1 -0
  129. package/dist/esm/layers/schema/carto-properties-tile.js +18 -0
  130. package/dist/esm/layers/schema/carto-properties-tile.js.map +1 -0
  131. package/dist/esm/layers/schema/carto-raster-tile-loader.js +1 -1
  132. package/dist/esm/layers/schema/carto-raster-tile-loader.js.map +1 -1
  133. package/dist/esm/layers/schema/carto-spatial-tile-loader.js +1 -1
  134. package/dist/esm/layers/schema/carto-spatial-tile-loader.js.map +1 -1
  135. package/dist/esm/layers/schema/carto-vector-tile-loader.js +1 -2
  136. package/dist/esm/layers/schema/carto-vector-tile-loader.js.map +1 -1
  137. package/dist/esm/layers/spatial-index-tile-layer.js +9 -24
  138. package/dist/esm/layers/spatial-index-tile-layer.js.map +1 -1
  139. package/dist/esm/layers/utils.js +71 -0
  140. package/dist/esm/layers/utils.js.map +1 -1
  141. package/dist/esm/layers/vector-tile-layer.js +40 -12
  142. package/dist/esm/layers/vector-tile-layer.js.map +1 -1
  143. package/dist/esm/sources/base-source.js +33 -10
  144. package/dist/esm/sources/base-source.js.map +1 -1
  145. package/dist/esm/sources/boundary-query-source.js +21 -0
  146. package/dist/esm/sources/boundary-query-source.js.map +1 -0
  147. package/dist/esm/sources/boundary-table-source.js +21 -0
  148. package/dist/esm/sources/boundary-table-source.js.map +1 -0
  149. package/dist/esm/sources/boundary-tileset-source.js +11 -0
  150. package/dist/esm/sources/boundary-tileset-source.js.map +1 -0
  151. package/dist/esm/sources/h3-query-source.js +6 -11
  152. package/dist/esm/sources/h3-query-source.js.map +1 -1
  153. package/dist/esm/sources/h3-table-source.js +7 -12
  154. package/dist/esm/sources/h3-table-source.js.map +1 -1
  155. package/dist/esm/sources/h3-tileset-source.js +3 -6
  156. package/dist/esm/sources/h3-tileset-source.js.map +1 -1
  157. package/dist/esm/sources/index.js +14 -11
  158. package/dist/esm/sources/index.js.map +1 -1
  159. package/dist/esm/sources/quadbin-query-source.js +7 -12
  160. package/dist/esm/sources/quadbin-query-source.js.map +1 -1
  161. package/dist/esm/sources/quadbin-table-source.js +7 -12
  162. package/dist/esm/sources/quadbin-table-source.js.map +1 -1
  163. package/dist/esm/sources/quadbin-tileset-source.js +3 -6
  164. package/dist/esm/sources/quadbin-tileset-source.js.map +1 -1
  165. package/dist/esm/sources/raster-source.js +3 -6
  166. package/dist/esm/sources/raster-source.js.map +1 -1
  167. package/dist/esm/sources/types.js +2 -0
  168. package/dist/esm/sources/types.js.map +1 -0
  169. package/dist/esm/sources/vector-query-source.js +6 -11
  170. package/dist/esm/sources/vector-query-source.js.map +1 -1
  171. package/dist/esm/sources/vector-table-source.js +7 -12
  172. package/dist/esm/sources/vector-table-source.js.map +1 -1
  173. package/dist/esm/sources/vector-tileset-source.js +3 -6
  174. package/dist/esm/sources/vector-tileset-source.js.map +1 -1
  175. package/dist/esm/style/color-bins-style.js +2 -1
  176. package/dist/esm/style/color-bins-style.js.map +1 -1
  177. package/dist/esm/style/color-categories-style.js +2 -1
  178. package/dist/esm/style/color-categories-style.js.map +1 -1
  179. package/dist/esm/style/color-continuous-style.js +2 -1
  180. package/dist/esm/style/color-continuous-style.js.map +1 -1
  181. package/dist/esm/style/palette.js +1 -1
  182. package/dist/esm/style/palette.js.map +1 -1
  183. package/dist/esm/style/utils.js +1 -5
  184. package/dist/esm/style/utils.js.map +1 -1
  185. package/dist/esm/utils.js +24 -1
  186. package/dist/esm/utils.js.map +1 -1
  187. package/dist.min.js +42 -41
  188. package/package.json +10 -9
  189. package/src/api/carto-api-error.ts +1 -9
  190. package/src/api/common.ts +14 -0
  191. package/src/api/endpoints.ts +38 -0
  192. package/src/api/fetch-map.ts +294 -0
  193. package/src/api/index.ts +5 -5
  194. package/src/api/layer-map.ts +40 -36
  195. package/src/api/{parseMap.ts → parse-map.ts} +2 -2
  196. package/src/api/query.ts +34 -0
  197. package/src/{sources/utils.ts → api/request-with-parameters.ts} +22 -17
  198. package/src/api/types.ts +49 -0
  199. package/src/index.ts +93 -41
  200. package/src/layers/h3-tile-layer.ts +13 -18
  201. package/src/layers/point-label-layer.ts +1 -1
  202. package/src/layers/quadbin-layer.ts +3 -2
  203. package/src/layers/quadbin-tile-layer.ts +10 -11
  204. package/src/layers/raster-layer.ts +2 -2
  205. package/src/layers/raster-tile-layer.ts +11 -9
  206. package/src/layers/schema/carto-properties-tile-loader.ts +25 -0
  207. package/src/layers/schema/carto-properties-tile.ts +21 -0
  208. package/src/layers/schema/carto-vector-tile-loader.ts +1 -1
  209. package/src/layers/spatial-index-tile-layer.ts +18 -26
  210. package/src/layers/utils.ts +73 -0
  211. package/src/layers/vector-tile-layer.ts +40 -21
  212. package/src/sources/base-source.ts +35 -18
  213. package/src/sources/boundary-query-source.ts +31 -0
  214. package/src/sources/boundary-table-source.ts +31 -0
  215. package/src/sources/boundary-tileset-source.ts +14 -0
  216. package/src/sources/h3-query-source.ts +22 -22
  217. package/src/sources/h3-table-source.ts +22 -22
  218. package/src/sources/h3-tileset-source.ts +7 -9
  219. package/src/sources/index.ts +31 -22
  220. package/src/sources/quadbin-query-source.ts +22 -22
  221. package/src/sources/quadbin-table-source.ts +23 -22
  222. package/src/sources/quadbin-tileset-source.ts +7 -9
  223. package/src/sources/raster-source.ts +5 -9
  224. package/src/sources/types.ts +98 -0
  225. package/src/sources/vector-query-source.ts +15 -15
  226. package/src/sources/vector-table-source.ts +15 -15
  227. package/src/sources/vector-tileset-source.ts +7 -9
  228. package/src/style/color-bins-style.ts +2 -1
  229. package/src/style/color-categories-style.ts +2 -1
  230. package/src/style/color-continuous-style.ts +2 -1
  231. package/src/style/palette.ts +1 -1
  232. package/src/style/utils.ts +1 -6
  233. package/src/utils.ts +25 -1
  234. package/typed/api/carto-api-error.d.ts +1 -8
  235. package/typed/api/carto-api-error.d.ts.map +1 -1
  236. package/typed/api/common.d.ts +13 -0
  237. package/typed/api/common.d.ts.map +1 -0
  238. package/typed/api/endpoints.d.ts +12 -0
  239. package/typed/api/endpoints.d.ts.map +1 -0
  240. package/typed/api/fetch-map.d.ts +22 -0
  241. package/typed/api/fetch-map.d.ts.map +1 -0
  242. package/typed/api/index.d.ts +5 -5
  243. package/typed/api/index.d.ts.map +1 -1
  244. package/typed/api/layer-map.d.ts +6 -9
  245. package/typed/api/layer-map.d.ts.map +1 -1
  246. package/typed/api/{parseMap.d.ts → parse-map.d.ts} +1 -1
  247. package/typed/api/parse-map.d.ts.map +1 -0
  248. package/typed/api/query.d.ts +4 -0
  249. package/typed/api/query.d.ts.map +1 -0
  250. package/typed/api/request-with-parameters.d.ts +9 -0
  251. package/typed/api/request-with-parameters.d.ts.map +1 -0
  252. package/typed/api/types.d.ts +40 -0
  253. package/typed/api/types.d.ts.map +1 -1
  254. package/typed/index.d.ts +33 -12
  255. package/typed/index.d.ts.map +1 -1
  256. package/typed/layers/h3-tile-layer.d.ts +12 -7
  257. package/typed/layers/h3-tile-layer.d.ts.map +1 -1
  258. package/typed/layers/point-label-layer.d.ts +2 -2
  259. package/typed/layers/point-label-layer.d.ts.map +1 -1
  260. package/typed/layers/quadbin-layer.d.ts +2 -2
  261. package/typed/layers/quadbin-layer.d.ts.map +1 -1
  262. package/typed/layers/quadbin-tile-layer.d.ts +6 -6
  263. package/typed/layers/quadbin-tile-layer.d.ts.map +1 -1
  264. package/typed/layers/raster-layer.d.ts +2 -2
  265. package/typed/layers/raster-layer.d.ts.map +1 -1
  266. package/typed/layers/raster-tile-layer.d.ts +6 -5
  267. package/typed/layers/raster-tile-layer.d.ts.map +1 -1
  268. package/typed/layers/schema/carto-properties-tile-loader.d.ts +4 -0
  269. package/typed/layers/schema/carto-properties-tile-loader.d.ts.map +1 -0
  270. package/typed/layers/schema/carto-properties-tile.d.ts +10 -0
  271. package/typed/layers/schema/carto-properties-tile.d.ts.map +1 -0
  272. package/typed/layers/spatial-index-tile-layer.d.ts +10 -9
  273. package/typed/layers/spatial-index-tile-layer.d.ts.map +1 -1
  274. package/typed/layers/utils.d.ts +11 -0
  275. package/typed/layers/utils.d.ts.map +1 -1
  276. package/typed/layers/vector-tile-layer.d.ts +6 -11
  277. package/typed/layers/vector-tile-layer.d.ts.map +1 -1
  278. package/typed/sources/base-source.d.ts +4 -3
  279. package/typed/sources/base-source.d.ts.map +1 -1
  280. package/typed/sources/boundary-query-source.d.ts +10 -0
  281. package/typed/sources/boundary-query-source.d.ts.map +1 -0
  282. package/typed/sources/boundary-table-source.d.ts +9 -0
  283. package/typed/sources/boundary-table-source.d.ts.map +1 -0
  284. package/typed/sources/boundary-tileset-source.d.ts +6 -0
  285. package/typed/sources/boundary-tileset-source.d.ts.map +1 -0
  286. package/typed/sources/h3-query-source.d.ts +3 -4
  287. package/typed/sources/h3-query-source.d.ts.map +1 -1
  288. package/typed/sources/h3-table-source.d.ts +3 -4
  289. package/typed/sources/h3-table-source.d.ts.map +1 -1
  290. package/typed/sources/h3-tileset-source.d.ts +3 -4
  291. package/typed/sources/h3-tileset-source.d.ts.map +1 -1
  292. package/typed/sources/index.d.ts +28 -22
  293. package/typed/sources/index.d.ts.map +1 -1
  294. package/typed/sources/quadbin-query-source.d.ts +3 -4
  295. package/typed/sources/quadbin-query-source.d.ts.map +1 -1
  296. package/typed/sources/quadbin-table-source.d.ts +3 -4
  297. package/typed/sources/quadbin-table-source.d.ts.map +1 -1
  298. package/typed/sources/quadbin-tileset-source.d.ts +3 -4
  299. package/typed/sources/quadbin-tileset-source.d.ts.map +1 -1
  300. package/typed/sources/raster-source.d.ts +3 -4
  301. package/typed/sources/raster-source.d.ts.map +1 -1
  302. package/typed/sources/{common.d.ts → types.d.ts} +26 -42
  303. package/typed/sources/types.d.ts.map +1 -0
  304. package/typed/sources/vector-query-source.d.ts +3 -4
  305. package/typed/sources/vector-query-source.d.ts.map +1 -1
  306. package/typed/sources/vector-table-source.d.ts +3 -4
  307. package/typed/sources/vector-table-source.d.ts.map +1 -1
  308. package/typed/sources/vector-tileset-source.d.ts +3 -4
  309. package/typed/sources/vector-tileset-source.d.ts.map +1 -1
  310. package/typed/style/color-bins-style.d.ts.map +1 -1
  311. package/typed/style/color-categories-style.d.ts.map +1 -1
  312. package/typed/style/color-continuous-style.d.ts.map +1 -1
  313. package/typed/style/utils.d.ts +0 -1
  314. package/typed/style/utils.d.ts.map +1 -1
  315. package/typed/utils.d.ts +8 -0
  316. package/typed/utils.d.ts.map +1 -1
  317. package/LICENSE +0 -19
  318. package/dist/es5/api/maps-api-common.js +0 -77
  319. package/dist/es5/api/maps-api-common.js.map +0 -1
  320. package/dist/es5/api/maps-client.js +0 -220
  321. package/dist/es5/api/maps-client.js.map +0 -1
  322. package/dist/es5/api/maps-v3-client.js +0 -959
  323. package/dist/es5/api/maps-v3-client.js.map +0 -1
  324. package/dist/es5/api/parseMap.js.map +0 -1
  325. package/dist/es5/config.js +0 -84
  326. package/dist/es5/config.js.map +0 -1
  327. package/dist/es5/layers/carto-layer.js +0 -329
  328. package/dist/es5/layers/carto-layer.js.map +0 -1
  329. package/dist/es5/sources/common.js +0 -48
  330. package/dist/es5/sources/common.js.map +0 -1
  331. package/dist/es5/sources/utils.js.map +0 -1
  332. package/dist/esm/api/maps-api-common.js +0 -54
  333. package/dist/esm/api/maps-api-common.js.map +0 -1
  334. package/dist/esm/api/maps-client.js +0 -148
  335. package/dist/esm/api/maps-client.js.map +0 -1
  336. package/dist/esm/api/maps-v3-client.js +0 -638
  337. package/dist/esm/api/maps-v3-client.js.map +0 -1
  338. package/dist/esm/api/parseMap.js.map +0 -1
  339. package/dist/esm/config.js +0 -60
  340. package/dist/esm/config.js.map +0 -1
  341. package/dist/esm/layers/carto-layer.js +0 -233
  342. package/dist/esm/layers/carto-layer.js.map +0 -1
  343. package/dist/esm/sources/common.js +0 -26
  344. package/dist/esm/sources/common.js.map +0 -1
  345. package/dist/esm/sources/utils.js.map +0 -1
  346. package/src/api/maps-api-common.ts +0 -95
  347. package/src/api/maps-client.ts +0 -196
  348. package/src/api/maps-v3-client.ts +0 -659
  349. package/src/config.ts +0 -70
  350. package/src/layers/carto-layer.ts +0 -340
  351. package/src/sources/common.ts +0 -132
  352. package/typed/api/maps-api-common.d.ts +0 -76
  353. package/typed/api/maps-api-common.d.ts.map +0 -1
  354. package/typed/api/maps-client.d.ts +0 -18
  355. package/typed/api/maps-client.d.ts.map +0 -1
  356. package/typed/api/maps-v3-client.d.ts +0 -49
  357. package/typed/api/maps-v3-client.d.ts.map +0 -1
  358. package/typed/api/parseMap.d.ts.map +0 -1
  359. package/typed/config.d.ts +0 -28
  360. package/typed/config.d.ts.map +0 -1
  361. package/typed/layers/carto-layer.d.ts +0 -126
  362. package/typed/layers/carto-layer.d.ts.map +0 -1
  363. package/typed/sources/common.d.ts.map +0 -1
  364. package/typed/sources/utils.d.ts +0 -15
  365. package/typed/sources/utils.d.ts.map +0 -1
@@ -1,659 +0,0 @@
1
- /* eslint-disable camelcase */
2
- /**
3
- * Maps API Client for Carto 3
4
- */
5
- import {
6
- getDefaultCredentials,
7
- buildMapsUrlFromBase,
8
- buildStatsUrlFromBase,
9
- CloudNativeCredentials
10
- } from '../config';
11
- import {
12
- API_VERSIONS,
13
- COLUMNS_SUPPORT,
14
- encodeParameter,
15
- Format,
16
- FORMATS,
17
- GEO_COLUMN_SUPPORT,
18
- MapInstantiation,
19
- MapType,
20
- MAP_TYPES,
21
- QueryParameters,
22
- REQUEST_TYPES,
23
- SchemaField,
24
- TileFormat,
25
- TILE_FORMATS
26
- } from './maps-api-common';
27
-
28
- import {APIErrorContext, CartoAPIError} from './carto-api-error';
29
-
30
- import {parseMap} from './parseMap';
31
- import {log} from '@deck.gl/core';
32
- import {assert} from '../utils';
33
-
34
- const MAX_GET_LENGTH = 8192;
35
- const DEFAULT_CLIENT = 'deck-gl-carto';
36
- const V3_MINOR_VERSION = '3.2';
37
-
38
- export type Headers = Record<string, string>;
39
- interface RequestParams {
40
- method?: string;
41
- url: string;
42
- headers?: Headers;
43
- accessToken?: string;
44
- body?: any;
45
- errorContext: APIErrorContext;
46
- }
47
-
48
- /**
49
- * Request against Maps API
50
- */
51
- async function request({
52
- method,
53
- url,
54
- headers: customHeaders,
55
- accessToken,
56
- body,
57
- errorContext
58
- }: RequestParams): Promise<Response> {
59
- const headers: Headers = {
60
- ...customHeaders,
61
- Accept: 'application/json'
62
- };
63
-
64
- if (accessToken) {
65
- headers.Authorization = `Bearer ${accessToken}`;
66
- }
67
-
68
- if (method === 'POST') {
69
- headers['Content-Type'] = 'application/json';
70
- }
71
-
72
- try {
73
- /* global fetch */
74
- return await fetch(url, {
75
- method,
76
- headers,
77
- body
78
- });
79
- } catch (error) {
80
- throw new CartoAPIError(error as Error, errorContext);
81
- }
82
- }
83
-
84
- async function requestJson<T = unknown>({
85
- method,
86
- url,
87
- headers,
88
- accessToken,
89
- body,
90
- errorContext
91
- }: RequestParams): Promise<T> {
92
- const response = await request({method, url, headers, accessToken, body, errorContext});
93
- let json;
94
- try {
95
- json = await response.json();
96
- } catch (error) {
97
- json = {error: ''};
98
- }
99
-
100
- if (!response.ok) {
101
- throw new CartoAPIError(json.error, errorContext, response);
102
- }
103
- return json as T;
104
- }
105
-
106
- async function requestData({
107
- method,
108
- url,
109
- accessToken,
110
- format,
111
- body,
112
- errorContext
113
- }: RequestParams & {
114
- format: Format;
115
- }): Promise<Response | unknown> {
116
- // if (format === FORMATS.NDJSON) {
117
- // return request({method, url, accessToken, body, errorContext});
118
- // }
119
-
120
- const data = await requestJson<any>({method, url, accessToken, body, errorContext});
121
- return data.rows ? data.rows : data;
122
- }
123
-
124
- type FetchLayerDataParams = {
125
- type: MapType;
126
- source: string;
127
- connection: string;
128
- credentials: CloudNativeCredentials;
129
- geoColumn?: string;
130
- columns?: string[];
131
- clientId?: string;
132
- format?: Format;
133
- formatTiles?: TileFormat;
134
- headers?: Headers;
135
- aggregationExp?: string;
136
- aggregationResLevel?: number;
137
- queryParameters?: QueryParameters;
138
- };
139
-
140
- type MapsAPIParameters = {
141
- client: string;
142
- v: string;
143
- q?: string;
144
- name?: string;
145
- queryParameters?: QueryParameters;
146
- /* eslint-disable-next-line camelcase */
147
- geo_column?: string;
148
- columns?: string;
149
- aggregationExp?: string;
150
- aggregationResLevel?: number;
151
- };
152
-
153
- /**
154
- * Build a URL with all required parameters
155
- */
156
- function getParameters({
157
- type,
158
- source,
159
- geoColumn,
160
- columns,
161
- clientId,
162
- aggregationExp,
163
- aggregationResLevel,
164
- queryParameters
165
- }: Omit<FetchLayerDataParams, 'connection' | 'credentials'>): MapsAPIParameters {
166
- const parameters: MapsAPIParameters = {
167
- client: clientId || DEFAULT_CLIENT,
168
- v: V3_MINOR_VERSION
169
- };
170
-
171
- const sourceName = type === MAP_TYPES.QUERY ? 'q' : 'name';
172
- parameters[sourceName] = source;
173
-
174
- if (queryParameters) {
175
- parameters.queryParameters = queryParameters;
176
- }
177
-
178
- if (geoColumn) {
179
- /* eslint-disable-next-line camelcase */
180
- parameters.geo_column = geoColumn;
181
- }
182
- if (columns) {
183
- parameters.columns = columns.join(',');
184
- }
185
- if (aggregationExp) {
186
- parameters.aggregationExp = aggregationExp;
187
- } else if (isSpatialIndexGeoColumn(geoColumn)) {
188
- // Default aggregationExp required for spatial index layers
189
- parameters.aggregationExp = '1 AS value';
190
- }
191
- if (aggregationResLevel) {
192
- parameters.aggregationResLevel = aggregationResLevel;
193
- }
194
-
195
- return parameters;
196
- }
197
-
198
- function isSpatialIndexGeoColumn(geoColumn: string | undefined) {
199
- const spatialIndex = geoColumn?.split(':')[0];
200
- return spatialIndex === 'h3' || spatialIndex === 'quadbin';
201
- }
202
-
203
- export async function mapInstantiation({
204
- type,
205
- source,
206
- connection,
207
- credentials,
208
- geoColumn,
209
- columns,
210
- clientId,
211
- headers,
212
- aggregationExp,
213
- aggregationResLevel,
214
- queryParameters
215
- }: FetchLayerDataParams): Promise<MapInstantiation> {
216
- const baseUrl = `${credentials.mapsUrl}/${connection}/${type}`;
217
- const parameters = getParameters({
218
- type,
219
- source,
220
- geoColumn,
221
- columns,
222
- clientId,
223
- aggregationResLevel,
224
- aggregationExp,
225
- queryParameters
226
- });
227
- const encodedParameters = Object.entries(parameters).map(([key, value]) => {
228
- if (typeof value !== 'string') {
229
- value = JSON.stringify(value);
230
- }
231
- return encodeParameter(key, value);
232
- });
233
- const url = `${baseUrl}?${encodedParameters.join('&')}`;
234
- const {accessToken} = credentials;
235
-
236
- const errorContext = {requestType: REQUEST_TYPES.INSTANTIATION, connection, type, source};
237
- if (url.length > MAX_GET_LENGTH && type === MAP_TYPES.QUERY) {
238
- return await requestJson({
239
- method: 'POST',
240
- url: baseUrl,
241
- headers,
242
- accessToken,
243
- body: JSON.stringify(parameters),
244
- errorContext
245
- });
246
- }
247
-
248
- return await requestJson({url, headers, accessToken, errorContext});
249
- }
250
-
251
- function getUrlFromMetadata(metadata: MapInstantiation, format: Format): string | null {
252
- const m = metadata[format];
253
-
254
- if (m && !m.error && m.url) {
255
- return m.url[0];
256
- }
257
-
258
- return null;
259
- }
260
-
261
- function checkFetchLayerDataParameters({
262
- type,
263
- source,
264
- connection,
265
- credentials,
266
- geoColumn,
267
- columns,
268
- aggregationExp,
269
- aggregationResLevel
270
- }: FetchLayerDataParams) {
271
- assert(connection, 'Must define connection');
272
- assert(type, 'Must define a type');
273
- assert(source, 'Must define a source');
274
-
275
- assert(credentials.apiVersion === API_VERSIONS.V3, 'Method only available for v3');
276
- assert(credentials.apiBaseUrl, 'Must define apiBaseUrl');
277
- assert(credentials.accessToken, 'Must define an accessToken');
278
-
279
- if (columns) {
280
- assert(
281
- COLUMNS_SUPPORT.includes(type),
282
- `The columns parameter is not supported by type ${type}`
283
- );
284
- }
285
- if (geoColumn) {
286
- assert(
287
- GEO_COLUMN_SUPPORT.includes(type),
288
- `The geoColumn parameter is not supported by type ${type}`
289
- );
290
- } else {
291
- assert(!aggregationExp, 'Have aggregationExp, but geoColumn parameter is missing');
292
- assert(!aggregationResLevel, 'Have aggregationResLevel, but geoColumn parameter is missing');
293
- }
294
- }
295
-
296
- export interface FetchLayerDataResult {
297
- data: any;
298
- format?: Format;
299
- schema: SchemaField[];
300
- }
301
- export async function fetchLayerData({
302
- type,
303
- source,
304
- connection,
305
- credentials,
306
- geoColumn,
307
- columns,
308
- format,
309
- formatTiles,
310
- clientId,
311
- headers,
312
- aggregationExp,
313
- aggregationResLevel,
314
- queryParameters
315
- }: FetchLayerDataParams): Promise<FetchLayerDataResult> {
316
- // Internally we split data fetching into two parts to allow us to
317
- // conditionally fetch the actual data, depending on the metadata state
318
- const {url, accessToken, mapFormat, metadata} = await _fetchDataUrl({
319
- type,
320
- source,
321
- connection,
322
- credentials,
323
- geoColumn,
324
- columns,
325
- format,
326
- formatTiles,
327
- clientId,
328
- headers,
329
- aggregationExp,
330
- aggregationResLevel,
331
- queryParameters
332
- });
333
-
334
- const errorContext = {requestType: REQUEST_TYPES.DATA, connection, type, source};
335
- const data = await requestData({url, format: mapFormat, accessToken, errorContext});
336
- const result: FetchLayerDataResult = {data, format: mapFormat, schema: metadata.schema};
337
- return result;
338
- }
339
-
340
- async function _fetchDataUrl({
341
- type,
342
- source,
343
- connection,
344
- credentials,
345
- geoColumn,
346
- columns,
347
- format,
348
- formatTiles,
349
- clientId,
350
- headers,
351
- aggregationExp,
352
- aggregationResLevel,
353
- queryParameters
354
- }: FetchLayerDataParams) {
355
- const defaultCredentials = getDefaultCredentials();
356
- // Only pick up default credentials if they have been defined for
357
- // correct API version
358
- const localCreds = {
359
- ...(defaultCredentials.apiVersion === API_VERSIONS.V3 && defaultCredentials),
360
- ...credentials
361
- };
362
- checkFetchLayerDataParameters({
363
- type,
364
- source,
365
- connection,
366
- credentials: localCreds,
367
- geoColumn,
368
- columns,
369
- aggregationExp,
370
- aggregationResLevel
371
- });
372
-
373
- if (!localCreds.mapsUrl) {
374
- localCreds.mapsUrl = buildMapsUrlFromBase(localCreds.apiBaseUrl);
375
- }
376
-
377
- const metadata = await mapInstantiation({
378
- type,
379
- source,
380
- connection,
381
- credentials: localCreds,
382
- geoColumn,
383
- columns,
384
- clientId,
385
- headers,
386
- aggregationExp,
387
- aggregationResLevel,
388
- queryParameters
389
- });
390
- let url: string | null = null;
391
- let mapFormat: Format | undefined;
392
-
393
- if (format) {
394
- mapFormat = format;
395
- url = getUrlFromMetadata(metadata, format);
396
- assert(url, `Format ${format} not available`);
397
- } else {
398
- // guess map format
399
- const prioritizedFormats = [FORMATS.GEOJSON, FORMATS.JSON, FORMATS.TILEJSON];
400
- for (const f of prioritizedFormats) {
401
- url = getUrlFromMetadata(metadata, f);
402
- if (url) {
403
- mapFormat = f;
404
- break;
405
- }
406
- }
407
- assert(url && mapFormat, 'Unsupported data formats received from backend.');
408
- }
409
-
410
- if (format === FORMATS.TILEJSON && formatTiles) {
411
- log.assert(
412
- Object.values(TILE_FORMATS).includes(formatTiles),
413
- `Invalid value for formatTiles: ${formatTiles}. Use value from TILE_FORMATS`
414
- );
415
- url += `&${encodeParameter('formatTiles', formatTiles)}`;
416
- }
417
-
418
- const {accessToken} = localCreds;
419
- return {url, accessToken, mapFormat, metadata};
420
- }
421
-
422
- /* global clearInterval, setInterval, URL */
423
- async function _fetchMapDataset(
424
- dataset,
425
- accessToken: string,
426
- credentials: CloudNativeCredentials,
427
- clientId?: string,
428
- headers?: Headers
429
- ) {
430
- const {
431
- aggregationExp,
432
- aggregationResLevel,
433
- connectionName: connection,
434
- columns,
435
- format,
436
- geoColumn,
437
- source,
438
- type,
439
- queryParameters
440
- } = dataset;
441
- // First fetch metadata
442
- const {url, mapFormat} = await _fetchDataUrl({
443
- aggregationExp,
444
- aggregationResLevel,
445
- clientId,
446
- credentials: {...credentials, accessToken},
447
- connection,
448
- columns,
449
- format,
450
- geoColumn,
451
- headers,
452
- source,
453
- type,
454
- queryParameters
455
- });
456
-
457
- // Extract the last time the data changed
458
- const cache = parseInt(new URL(url).searchParams.get('cache') || '', 10);
459
- if (cache && dataset.cache === cache) {
460
- return false;
461
- }
462
- dataset.cache = cache;
463
-
464
- // Only fetch if the data has changed
465
- const errorContext = {requestType: REQUEST_TYPES.DATA, connection, type, source};
466
- dataset.data = await requestData({url, format: mapFormat, accessToken, errorContext});
467
-
468
- return true;
469
- }
470
-
471
- async function _fetchTilestats(
472
- attribute,
473
- dataset,
474
- accessToken: string,
475
- credentials: CloudNativeCredentials
476
- ) {
477
- const {connectionName: connection, source, type} = dataset;
478
-
479
- const statsUrl = buildStatsUrlFromBase(credentials.apiBaseUrl);
480
- let baseUrl = `${statsUrl}/${connection}/`;
481
- if (type === MAP_TYPES.QUERY) {
482
- baseUrl += attribute;
483
- } else {
484
- // MAP_TYPE.TABLE
485
- baseUrl += `${source}/${attribute}`;
486
- }
487
-
488
- const errorContext = {requestType: REQUEST_TYPES.TILE_STATS, connection, type, source};
489
- let url = baseUrl;
490
- if (type === MAP_TYPES.QUERY) {
491
- url += `?${encodeParameter('q', source)}`;
492
- }
493
- let stats;
494
- if (url.length > MAX_GET_LENGTH && type === MAP_TYPES.QUERY) {
495
- stats = await requestJson({
496
- method: 'POST',
497
- url: baseUrl,
498
- accessToken,
499
- body: JSON.stringify({q: source}),
500
- errorContext
501
- });
502
- } else {
503
- stats = await requestJson({url, accessToken, errorContext});
504
- }
505
-
506
- // Replace tilestats for attribute with value from API
507
- const {attributes} = dataset.data.tilestats.layers[0];
508
- const index = attributes.findIndex(d => d.attribute === attribute);
509
- attributes[index] = stats;
510
- return true;
511
- }
512
-
513
- async function fillInMapDatasets(
514
- {datasets, token},
515
- clientId: string,
516
- credentials: CloudNativeCredentials,
517
- headers?: Headers
518
- ) {
519
- const promises = datasets.map(dataset =>
520
- _fetchMapDataset(dataset, token, credentials, clientId, headers)
521
- );
522
- return await Promise.all(promises);
523
- }
524
-
525
- async function fillInTileStats(
526
- {datasets, keplerMapConfig, token},
527
- credentials: CloudNativeCredentials
528
- ) {
529
- const attributes: {attribute?: string; dataset?: any}[] = [];
530
- const {layers} = keplerMapConfig.config.visState;
531
- for (const layer of layers) {
532
- for (const channel of Object.keys(layer.visualChannels)) {
533
- const attribute = layer.visualChannels[channel]?.name;
534
- if (attribute) {
535
- const dataset = datasets.find(d => d.id === layer.config.dataId);
536
- if (dataset.data.tilestats && dataset.type !== MAP_TYPES.TILESET) {
537
- // Only fetch stats for QUERY & TABLE map types
538
- attributes.push({attribute, dataset});
539
- }
540
- }
541
- }
542
- }
543
- // Remove duplicates to avoid repeated requests
544
- const filteredAttributes: {attribute?: string; dataset?: any}[] = [];
545
- for (const a of attributes) {
546
- if (
547
- !filteredAttributes.find(
548
- ({attribute, dataset}) => attribute === a.attribute && dataset === a.dataset
549
- )
550
- ) {
551
- filteredAttributes.push(a);
552
- }
553
- }
554
-
555
- const promises = filteredAttributes.map(({attribute, dataset}) =>
556
- _fetchTilestats(attribute, dataset, token, credentials)
557
- );
558
- return await Promise.all(promises);
559
- }
560
-
561
- /* eslint-disable max-statements */
562
- export async function fetchMap({
563
- cartoMapId,
564
- clientId,
565
- credentials,
566
- headers,
567
- autoRefresh,
568
- onNewData
569
- }: {
570
- cartoMapId: string;
571
- clientId: string;
572
- credentials?: CloudNativeCredentials;
573
- headers?: Headers;
574
- autoRefresh?: number;
575
- onNewData?: (map: any) => void;
576
- }) {
577
- const defaultCredentials = getDefaultCredentials();
578
- const localCreds = {
579
- ...(defaultCredentials.apiVersion === API_VERSIONS.V3 && defaultCredentials),
580
- ...credentials
581
- } as CloudNativeCredentials;
582
- const {accessToken} = localCreds;
583
-
584
- assert(cartoMapId, 'Must define CARTO map id: fetchMap({cartoMapId: "XXXX-XXXX-XXXX"})');
585
-
586
- assert(localCreds.apiVersion === API_VERSIONS.V3, 'Method only available for v3');
587
- assert(localCreds.apiBaseUrl, 'Must define apiBaseUrl');
588
- if (!localCreds.mapsUrl) {
589
- localCreds.mapsUrl = buildMapsUrlFromBase(localCreds.apiBaseUrl);
590
- }
591
-
592
- if (autoRefresh || onNewData) {
593
- assert(onNewData, 'Must define `onNewData` when using autoRefresh');
594
- assert(typeof onNewData === 'function', '`onNewData` must be a function');
595
- assert(
596
- typeof autoRefresh === 'number' && autoRefresh > 0,
597
- '`autoRefresh` must be a positive number'
598
- );
599
- }
600
-
601
- const url = `${localCreds.mapsUrl}/public/${cartoMapId}`;
602
- const errorContext = {requestType: REQUEST_TYPES.PUBLIC_MAP, mapId: cartoMapId};
603
- const map = await requestJson<any>({url, headers, accessToken, errorContext});
604
-
605
- // Periodically check if the data has changed. Note that this
606
- // will not update when a map is published.
607
- let stopAutoRefresh: (() => void) | undefined;
608
- if (autoRefresh) {
609
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
610
- const intervalId = setInterval(async () => {
611
- const changed = await fillInMapDatasets(map, clientId, localCreds, headers);
612
- if (onNewData && changed.some(v => v === true)) {
613
- onNewData(parseMap(map));
614
- }
615
- }, autoRefresh * 1000);
616
- stopAutoRefresh = () => {
617
- clearInterval(intervalId);
618
- };
619
- }
620
-
621
- const geojsonLayers = map.keplerMapConfig.config.visState.layers.filter(
622
- ({type}) => type === 'geojson' || type === 'point'
623
- );
624
- const geojsonDatasetIds = geojsonLayers.map(({config}) => config.dataId);
625
- map.datasets.forEach(dataset => {
626
- if (geojsonDatasetIds.includes(dataset.id)) {
627
- const {config} = geojsonLayers.find(({config}) => config.dataId === dataset.id);
628
- dataset.format = 'geojson';
629
- // Support for very old maps. geoColumn was not stored in the past
630
- if (!dataset.geoColumn && config.columns.geojson) {
631
- dataset.geoColumn = config.columns.geojson;
632
- }
633
- }
634
- });
635
-
636
- // Mutates map.datasets so that dataset.data contains data
637
- await fillInMapDatasets(map, clientId, localCreds, headers);
638
-
639
- // Mutates attributes in visualChannels to contain tile stats
640
- await fillInTileStats(map, localCreds);
641
- const out = {...parseMap(map), ...{stopAutoRefresh}};
642
-
643
- const textLayers = out.layers.filter(layer => {
644
- const pointType = layer.props.pointType || '';
645
- return pointType.includes('text');
646
- });
647
-
648
- /* global FontFace, window, document */
649
- if (textLayers.length && window.FontFace && !document.fonts.check('12px Inter')) {
650
- // Fetch font needed for labels
651
- const font = new FontFace(
652
- 'Inter',
653
- 'url(https://fonts.gstatic.com/s/inter/v12/UcC73FwrK3iLTeHuS_fvQtMwCp50KnMa1ZL7W0Q5nw.woff2)'
654
- );
655
- await font.load().then(f => document.fonts.add(f));
656
- }
657
-
658
- return out;
659
- }
package/src/config.ts DELETED
@@ -1,70 +0,0 @@
1
- import {API_VERSIONS} from './api/maps-api-common';
2
-
3
- export const defaultClassicCredentials = {
4
- apiKey: 'default_public',
5
- region: 'us',
6
- username: 'public'
7
- } as const;
8
-
9
- export const defaultCloudNativeCredentials = {
10
- apiBaseUrl: 'https://gcp-us-east1.api.carto.com'
11
- } as const;
12
-
13
- export interface ClassicCredentials {
14
- apiVersion: 'v1' | 'v2';
15
- apiKey: string;
16
- region: string;
17
- username: string;
18
- mapsUrl?: string;
19
- }
20
-
21
- export interface CloudNativeCredentials {
22
- apiVersion: 'v3';
23
- apiBaseUrl: string;
24
- accessToken?: string;
25
- mapsUrl?: string;
26
- }
27
-
28
- export type Credentials = ClassicCredentials | CloudNativeCredentials;
29
- let credentials: Credentials = {} as Credentials;
30
-
31
- setDefaultCredentials({});
32
-
33
- export function setDefaultCredentials({apiVersion, ...rest}: Partial<Credentials>) {
34
- apiVersion = apiVersion || API_VERSIONS.V3;
35
-
36
- switch (apiVersion) {
37
- case API_VERSIONS.V1:
38
- case API_VERSIONS.V2:
39
- credentials = {apiVersion, ...defaultClassicCredentials, ...rest};
40
- break;
41
- case API_VERSIONS.V3:
42
- credentials = {apiVersion, ...defaultCloudNativeCredentials, ...rest};
43
- break;
44
- default:
45
- throw new Error(`Invalid API version ${apiVersion}. Use API_VERSIONS enum.`);
46
- }
47
- }
48
-
49
- export function getDefaultCredentials(): Credentials {
50
- return credentials;
51
- }
52
-
53
- export type V3Endpoint = 'maps' | 'stats';
54
-
55
- function buildUrlFromBase(apiBaseUrl: string, endpoint: V3Endpoint) {
56
- let suffix = `/v3/${endpoint}`;
57
- if (apiBaseUrl.endsWith('/')) {
58
- suffix = suffix.substring(1);
59
- }
60
-
61
- return `${apiBaseUrl}${suffix}`;
62
- }
63
-
64
- export function buildMapsUrlFromBase(apiBaseUrl: string): string {
65
- return buildUrlFromBase(apiBaseUrl, 'maps');
66
- }
67
-
68
- export function buildStatsUrlFromBase(apiBaseUrl: string): string {
69
- return buildUrlFromBase(apiBaseUrl, 'stats');
70
- }