@carto/api-client 0.3.1 → 0.4.0-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.
- package/build/api/carto-api-error.d.ts +18 -0
- package/build/api/endpoints.d.ts +22 -0
- package/build/api/index.d.ts +4 -0
- package/build/api/query.d.ts +3 -0
- package/build/api/request-with-parameters.d.ts +8 -0
- package/build/api/types.d.ts +227 -0
- package/build/api-client.cjs +484 -22
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.modern.js +413 -19
- package/build/api-client.modern.js.map +1 -1
- package/build/constants.d.ts +8 -0
- package/build/index.d.ts +6 -1
- package/build/sources/base-source.d.ts +4 -0
- package/build/sources/boundary-query-source.d.ts +9 -0
- package/build/sources/boundary-table-source.d.ts +7 -0
- package/build/sources/h3-query-source.d.ts +3 -0
- package/build/sources/h3-table-source.d.ts +3 -0
- package/build/sources/h3-tileset-source.d.ts +3 -0
- package/build/sources/index.d.ts +27 -5
- package/build/sources/quadbin-query-source.d.ts +3 -0
- package/build/sources/quadbin-table-source.d.ts +3 -0
- package/build/sources/quadbin-tileset-source.d.ts +3 -0
- package/build/sources/raster-source.d.ts +3 -0
- package/build/sources/types.d.ts +208 -85
- package/build/sources/vector-query-source.d.ts +3 -0
- package/build/sources/vector-table-source.d.ts +3 -0
- package/build/sources/vector-tileset-source.d.ts +3 -0
- package/build/utils.d.ts +4 -0
- package/build/widget-sources/index.d.ts +5 -0
- package/build/widget-sources/types.d.ts +95 -0
- package/build/{sources → widget-sources}/widget-base-source.d.ts +1 -1
- package/build/{sources → widget-sources}/widget-query-source.d.ts +1 -1
- package/build/{sources → widget-sources}/widget-table-source.d.ts +1 -1
- package/build/{sources → widget-sources}/wrappers.d.ts +1 -1
- package/package.json +4 -3
- package/src/api/carto-api-error.ts +72 -0
- package/src/api/endpoints.ts +82 -0
- package/src/api/index.ts +17 -0
- package/src/api/query.ts +56 -0
- package/src/api/request-with-parameters.ts +139 -0
- package/src/api/types.ts +301 -0
- package/src/constants.ts +13 -0
- package/src/global.d.ts +3 -0
- package/src/index.ts +10 -1
- package/src/sources/base-source.ts +100 -0
- package/src/sources/boundary-query-source.ts +53 -0
- package/src/sources/boundary-table-source.ts +41 -0
- package/src/sources/h3-query-source.ts +63 -0
- package/src/sources/h3-table-source.ts +59 -0
- package/src/sources/h3-tileset-source.ts +26 -0
- package/src/sources/index.ts +49 -5
- package/src/sources/quadbin-query-source.ts +64 -0
- package/src/sources/quadbin-table-source.ts +60 -0
- package/src/sources/quadbin-tileset-source.ts +26 -0
- package/src/sources/raster-source.ts +34 -0
- package/src/sources/types.ts +226 -90
- package/src/sources/vector-query-source.ts +65 -0
- package/src/sources/vector-table-source.ts +59 -0
- package/src/sources/vector-tileset-source.ts +26 -0
- package/src/utils.ts +8 -0
- package/src/widget-sources/index.ts +5 -0
- package/src/widget-sources/types.ts +105 -0
- package/src/{sources → widget-sources}/widget-base-source.ts +1 -1
- package/src/{sources → widget-sources}/widget-query-source.ts +1 -1
- package/src/{sources → widget-sources}/widget-table-source.ts +1 -1
- package/src/{sources → widget-sources}/wrappers.ts +1 -21
package/build/api-client.cjs
CHANGED
|
@@ -3,7 +3,6 @@ var bboxPolygon = require('@turf/bbox-polygon');
|
|
|
3
3
|
var union = require('@turf/union');
|
|
4
4
|
var invariant = require('@turf/invariant');
|
|
5
5
|
var helpers = require('@turf/helpers');
|
|
6
|
-
var carto = require('@deck.gl/carto');
|
|
7
6
|
|
|
8
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
8
|
|
|
@@ -36,7 +35,16 @@ function setClient(c) {
|
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
/** Current version of @carto/api-client. */
|
|
39
|
-
const API_CLIENT_VERSION = "0.
|
|
38
|
+
const API_CLIENT_VERSION = "0.4.0-alpha.0";
|
|
39
|
+
const DEFAULT_API_BASE_URL$1 = 'https://gcp-us-east1.api.carto.com';
|
|
40
|
+
const DEFAULT_CLIENT = 'deck-gl-carto';
|
|
41
|
+
const V3_MINOR_VERSION = '3.4';
|
|
42
|
+
// Fastly default limit is 8192; leave some padding.
|
|
43
|
+
const DEFAULT_MAX_LENGTH_URL = 7000;
|
|
44
|
+
const DEFAULT_TILE_SIZE = 512;
|
|
45
|
+
const DEFAULT_TILE_RESOLUTION = 0.5;
|
|
46
|
+
const DEFAULT_AGGREGATION_RES_LEVEL_H3 = 4;
|
|
47
|
+
const DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN = 6;
|
|
40
48
|
/**
|
|
41
49
|
* Defines a comparator used when matching a column's values against given filter values.
|
|
42
50
|
*
|
|
@@ -129,6 +137,10 @@ function isEmptyObject(object) {
|
|
|
129
137
|
}
|
|
130
138
|
return true;
|
|
131
139
|
}
|
|
140
|
+
/** @internal */
|
|
141
|
+
const isObject = x => x !== null && typeof x === 'object';
|
|
142
|
+
/** @internal */
|
|
143
|
+
const isPureObject = x => isObject(x) && x.constructor === {}.constructor;
|
|
132
144
|
|
|
133
145
|
/**
|
|
134
146
|
* Adds a {@link Filter} to the filter set. Any previous filters with the same
|
|
@@ -981,13 +993,468 @@ class WidgetTableSource extends WidgetBaseSource {
|
|
|
981
993
|
}
|
|
982
994
|
}
|
|
983
995
|
|
|
996
|
+
// deck.gl
|
|
997
|
+
// SPDX-License-Identifier: MIT
|
|
998
|
+
// Copyright (c) vis.gl contributors
|
|
999
|
+
function joinPath() {
|
|
1000
|
+
return [].slice.call(arguments).map(part => part.endsWith('/') ? part.slice(0, -1) : part).join('/');
|
|
1001
|
+
}
|
|
1002
|
+
function buildV3Path(apiBaseUrl, version, endpoint) {
|
|
1003
|
+
return joinPath(apiBaseUrl, version, endpoint, ...[].slice.call(arguments, 3));
|
|
1004
|
+
}
|
|
1005
|
+
function buildSourceUrl(_ref3) {
|
|
1006
|
+
let {
|
|
1007
|
+
apiBaseUrl,
|
|
1008
|
+
connectionName,
|
|
1009
|
+
endpoint
|
|
1010
|
+
} = _ref3;
|
|
1011
|
+
return buildV3Path(apiBaseUrl, 'v3', 'maps', connectionName, endpoint);
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
// deck.gl
|
|
1015
|
+
// SPDX-License-Identifier: MIT
|
|
1016
|
+
// Copyright (c) vis.gl contributors
|
|
1017
|
+
/**
|
|
1018
|
+
*
|
|
1019
|
+
* Custom error for reported errors in CARTO Maps API.
|
|
1020
|
+
* Provides useful debugging information in console and context for applications.
|
|
1021
|
+
*
|
|
1022
|
+
*/
|
|
1023
|
+
class CartoAPIError extends Error {
|
|
1024
|
+
constructor(error, errorContext, response, responseJson) {
|
|
1025
|
+
let responseString = 'Failed to connect';
|
|
1026
|
+
if (response) {
|
|
1027
|
+
responseString = 'Server returned: ';
|
|
1028
|
+
if (response.status === 400) {
|
|
1029
|
+
responseString += 'Bad request';
|
|
1030
|
+
} else if (response.status === 401 || response.status === 403) {
|
|
1031
|
+
responseString += 'Unauthorized access';
|
|
1032
|
+
} else if (response.status === 404) {
|
|
1033
|
+
responseString += 'Not found';
|
|
1034
|
+
} else {
|
|
1035
|
+
responseString += 'Error';
|
|
1036
|
+
}
|
|
1037
|
+
responseString += ` (${response.status}):`;
|
|
1038
|
+
}
|
|
1039
|
+
responseString += ` ${error.message || error}`;
|
|
1040
|
+
let message = `${errorContext.requestType} API request failed`;
|
|
1041
|
+
message += `\n${responseString}`;
|
|
1042
|
+
for (const key of Object.keys(errorContext)) {
|
|
1043
|
+
if (key === 'requestType') continue;
|
|
1044
|
+
message += `\n${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
1045
|
+
}
|
|
1046
|
+
message += '\n';
|
|
1047
|
+
super(message);
|
|
1048
|
+
/** Source error from server */
|
|
1049
|
+
this.error = void 0;
|
|
1050
|
+
/** Context (API call & parameters) in which error occured */
|
|
1051
|
+
this.errorContext = void 0;
|
|
1052
|
+
/** Response from server */
|
|
1053
|
+
this.response = void 0;
|
|
1054
|
+
/** JSON Response from server */
|
|
1055
|
+
this.responseJson = void 0;
|
|
1056
|
+
this.name = 'CartoAPIError';
|
|
1057
|
+
this.response = response;
|
|
1058
|
+
this.responseJson = responseJson;
|
|
1059
|
+
this.error = error;
|
|
1060
|
+
this.errorContext = errorContext;
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
/**
|
|
1064
|
+
* Converts camelCase to Camel Case
|
|
1065
|
+
*/
|
|
1066
|
+
function formatErrorKey(key) {
|
|
1067
|
+
return key.replace(/([A-Z])/g, ' $1').replace(/^./, s => s.toUpperCase());
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
// deck.gl
|
|
1071
|
+
const requestWithParameters = function (_ref) {
|
|
1072
|
+
let {
|
|
1073
|
+
baseUrl,
|
|
1074
|
+
parameters = {},
|
|
1075
|
+
headers: customHeaders = {},
|
|
1076
|
+
errorContext,
|
|
1077
|
+
maxLengthURL = DEFAULT_MAX_LENGTH_URL
|
|
1078
|
+
} = _ref;
|
|
1079
|
+
try {
|
|
1080
|
+
// Parameters added to all requests issued with `requestWithParameters()`.
|
|
1081
|
+
// These parameters override parameters already in the base URL, but not
|
|
1082
|
+
// user-provided parameters.
|
|
1083
|
+
parameters = {
|
|
1084
|
+
v: V3_MINOR_VERSION,
|
|
1085
|
+
clientId: DEFAULT_CLIENT,
|
|
1086
|
+
...(typeof deck !== 'undefined' && deck.VERSION && {
|
|
1087
|
+
deckglVersion: deck.VERSION
|
|
1088
|
+
}),
|
|
1089
|
+
...parameters
|
|
1090
|
+
};
|
|
1091
|
+
baseUrl = excludeURLParameters(baseUrl, Object.keys(parameters));
|
|
1092
|
+
const key = createCacheKey(baseUrl, parameters, customHeaders);
|
|
1093
|
+
if (REQUEST_CACHE.has(key)) {
|
|
1094
|
+
return Promise.resolve(REQUEST_CACHE.get(key));
|
|
1095
|
+
}
|
|
1096
|
+
const url = createURLWithParameters(baseUrl, parameters);
|
|
1097
|
+
const headers = {
|
|
1098
|
+
...DEFAULT_HEADERS,
|
|
1099
|
+
...customHeaders
|
|
1100
|
+
};
|
|
1101
|
+
/* global fetch */
|
|
1102
|
+
const fetchPromise = url.length > maxLengthURL ? fetch(baseUrl, {
|
|
1103
|
+
method: 'POST',
|
|
1104
|
+
body: JSON.stringify(parameters),
|
|
1105
|
+
headers
|
|
1106
|
+
}) : fetch(url, {
|
|
1107
|
+
headers
|
|
1108
|
+
});
|
|
1109
|
+
let response;
|
|
1110
|
+
let responseJson;
|
|
1111
|
+
const jsonPromise = fetchPromise.then(_response => {
|
|
1112
|
+
response = _response;
|
|
1113
|
+
return response.json();
|
|
1114
|
+
}).then(json => {
|
|
1115
|
+
responseJson = json;
|
|
1116
|
+
if (!response || !response.ok) {
|
|
1117
|
+
throw new Error(json.error);
|
|
1118
|
+
}
|
|
1119
|
+
return json;
|
|
1120
|
+
}).catch(error => {
|
|
1121
|
+
REQUEST_CACHE.delete(key);
|
|
1122
|
+
throw new CartoAPIError(error, errorContext, response, responseJson);
|
|
1123
|
+
});
|
|
1124
|
+
REQUEST_CACHE.set(key, jsonPromise);
|
|
1125
|
+
return Promise.resolve(jsonPromise);
|
|
1126
|
+
} catch (e) {
|
|
1127
|
+
return Promise.reject(e);
|
|
1128
|
+
}
|
|
1129
|
+
};
|
|
1130
|
+
const DEFAULT_HEADERS = {
|
|
1131
|
+
Accept: 'application/json',
|
|
1132
|
+
'Content-Type': 'application/json'
|
|
1133
|
+
};
|
|
1134
|
+
const REQUEST_CACHE = new Map();
|
|
1135
|
+
function createCacheKey(baseUrl, parameters, headers) {
|
|
1136
|
+
const parameterEntries = Object.entries(parameters).sort((_ref2, _ref3) => {
|
|
1137
|
+
let [a] = _ref2;
|
|
1138
|
+
let [b] = _ref3;
|
|
1139
|
+
return a > b ? 1 : -1;
|
|
1140
|
+
});
|
|
1141
|
+
const headerEntries = Object.entries(headers).sort((_ref4, _ref5) => {
|
|
1142
|
+
let [a] = _ref4;
|
|
1143
|
+
let [b] = _ref5;
|
|
1144
|
+
return a > b ? 1 : -1;
|
|
1145
|
+
});
|
|
1146
|
+
return JSON.stringify({
|
|
1147
|
+
baseUrl,
|
|
1148
|
+
parameters: parameterEntries,
|
|
1149
|
+
headers: headerEntries
|
|
1150
|
+
});
|
|
1151
|
+
}
|
|
1152
|
+
/**
|
|
1153
|
+
* Appends query string parameters to a URL. Existing URL parameters are kept,
|
|
1154
|
+
* unless there is a conflict, in which case the new parameters override
|
|
1155
|
+
* those already in the URL.
|
|
1156
|
+
*/
|
|
1157
|
+
function createURLWithParameters(baseUrlString, parameters) {
|
|
1158
|
+
const baseUrl = new URL(baseUrlString);
|
|
1159
|
+
for (const [key, value] of Object.entries(parameters)) {
|
|
1160
|
+
if (isPureObject(value) || Array.isArray(value)) {
|
|
1161
|
+
baseUrl.searchParams.set(key, JSON.stringify(value));
|
|
1162
|
+
} else {
|
|
1163
|
+
baseUrl.searchParams.set(key, value.toString());
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
return baseUrl.toString();
|
|
1167
|
+
}
|
|
1168
|
+
/**
|
|
1169
|
+
* Deletes query string parameters from a URL.
|
|
1170
|
+
*/
|
|
1171
|
+
function excludeURLParameters(baseUrlString, parameters) {
|
|
1172
|
+
const baseUrl = new URL(baseUrlString);
|
|
1173
|
+
for (const param of parameters) {
|
|
1174
|
+
if (baseUrl.searchParams.has(param)) {
|
|
1175
|
+
baseUrl.searchParams.delete(param);
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
return baseUrl.toString();
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
// deck.gl
|
|
1182
|
+
const baseSource = function (endpoint, options, urlParameters) {
|
|
1183
|
+
try {
|
|
1184
|
+
const {
|
|
1185
|
+
accessToken,
|
|
1186
|
+
connectionName,
|
|
1187
|
+
cache,
|
|
1188
|
+
...optionalOptions
|
|
1189
|
+
} = options;
|
|
1190
|
+
const mergedOptions = {
|
|
1191
|
+
...SOURCE_DEFAULTS,
|
|
1192
|
+
accessToken,
|
|
1193
|
+
connectionName,
|
|
1194
|
+
endpoint
|
|
1195
|
+
};
|
|
1196
|
+
for (const key in optionalOptions) {
|
|
1197
|
+
if (optionalOptions[key]) {
|
|
1198
|
+
mergedOptions[key] = optionalOptions[key];
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
const baseUrl = buildSourceUrl(mergedOptions);
|
|
1202
|
+
const {
|
|
1203
|
+
clientId,
|
|
1204
|
+
maxLengthURL,
|
|
1205
|
+
format
|
|
1206
|
+
} = mergedOptions;
|
|
1207
|
+
const headers = {
|
|
1208
|
+
Authorization: `Bearer ${options.accessToken}`,
|
|
1209
|
+
...options.headers
|
|
1210
|
+
};
|
|
1211
|
+
const parameters = {
|
|
1212
|
+
client: clientId,
|
|
1213
|
+
...urlParameters
|
|
1214
|
+
};
|
|
1215
|
+
const errorContext = {
|
|
1216
|
+
requestType: 'Map instantiation',
|
|
1217
|
+
connection: options.connectionName,
|
|
1218
|
+
type: endpoint,
|
|
1219
|
+
source: JSON.stringify(parameters, undefined, 2)
|
|
1220
|
+
};
|
|
1221
|
+
return Promise.resolve(requestWithParameters({
|
|
1222
|
+
baseUrl,
|
|
1223
|
+
parameters,
|
|
1224
|
+
headers,
|
|
1225
|
+
errorContext,
|
|
1226
|
+
maxLengthURL
|
|
1227
|
+
})).then(function (mapInstantiation) {
|
|
1228
|
+
let _exit;
|
|
1229
|
+
function _temp2(_result) {
|
|
1230
|
+
return _exit ? _result : Promise.resolve(requestWithParameters({
|
|
1231
|
+
baseUrl: dataUrl,
|
|
1232
|
+
headers,
|
|
1233
|
+
errorContext,
|
|
1234
|
+
maxLengthURL
|
|
1235
|
+
}));
|
|
1236
|
+
}
|
|
1237
|
+
const dataUrl = mapInstantiation[format].url[0];
|
|
1238
|
+
if (cache) {
|
|
1239
|
+
cache.value = parseInt(new URL(dataUrl).searchParams.get('cache') || '', 10);
|
|
1240
|
+
}
|
|
1241
|
+
errorContext.requestType = 'Map data';
|
|
1242
|
+
const _temp = function () {
|
|
1243
|
+
if (format === 'tilejson') {
|
|
1244
|
+
return Promise.resolve(requestWithParameters({
|
|
1245
|
+
baseUrl: dataUrl,
|
|
1246
|
+
headers,
|
|
1247
|
+
errorContext,
|
|
1248
|
+
maxLengthURL
|
|
1249
|
+
})).then(function (json) {
|
|
1250
|
+
if (accessToken) {
|
|
1251
|
+
json.accessToken = accessToken;
|
|
1252
|
+
}
|
|
1253
|
+
_exit = 1;
|
|
1254
|
+
return json;
|
|
1255
|
+
});
|
|
1256
|
+
}
|
|
1257
|
+
}();
|
|
1258
|
+
return _temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp);
|
|
1259
|
+
});
|
|
1260
|
+
} catch (e) {
|
|
1261
|
+
return Promise.reject(e);
|
|
1262
|
+
}
|
|
1263
|
+
};
|
|
1264
|
+
const SOURCE_DEFAULTS = {
|
|
1265
|
+
apiBaseUrl: DEFAULT_API_BASE_URL$1,
|
|
1266
|
+
clientId: DEFAULT_CLIENT,
|
|
1267
|
+
format: 'tilejson',
|
|
1268
|
+
headers: {},
|
|
1269
|
+
maxLengthURL: DEFAULT_MAX_LENGTH_URL
|
|
1270
|
+
};
|
|
1271
|
+
|
|
1272
|
+
// deck.gl
|
|
1273
|
+
const h3QuerySource$1 = function (options) {
|
|
1274
|
+
try {
|
|
1275
|
+
const {
|
|
1276
|
+
aggregationExp,
|
|
1277
|
+
aggregationResLevel = DEFAULT_AGGREGATION_RES_LEVEL_H3,
|
|
1278
|
+
sqlQuery,
|
|
1279
|
+
spatialDataColumn = 'h3',
|
|
1280
|
+
queryParameters,
|
|
1281
|
+
filters
|
|
1282
|
+
} = options;
|
|
1283
|
+
const urlParameters = {
|
|
1284
|
+
aggregationExp,
|
|
1285
|
+
spatialDataColumn,
|
|
1286
|
+
spatialDataType: 'h3',
|
|
1287
|
+
q: sqlQuery
|
|
1288
|
+
};
|
|
1289
|
+
if (aggregationResLevel) {
|
|
1290
|
+
urlParameters.aggregationResLevel = String(aggregationResLevel);
|
|
1291
|
+
}
|
|
1292
|
+
if (queryParameters) {
|
|
1293
|
+
urlParameters.queryParameters = queryParameters;
|
|
1294
|
+
}
|
|
1295
|
+
if (filters) {
|
|
1296
|
+
urlParameters.filters = filters;
|
|
1297
|
+
}
|
|
1298
|
+
return Promise.resolve(baseSource('query', options, urlParameters));
|
|
1299
|
+
} catch (e) {
|
|
1300
|
+
return Promise.reject(e);
|
|
1301
|
+
}
|
|
1302
|
+
};
|
|
1303
|
+
|
|
1304
|
+
// deck.gl
|
|
1305
|
+
const h3TableSource$1 = function (options) {
|
|
1306
|
+
try {
|
|
1307
|
+
const {
|
|
1308
|
+
aggregationExp,
|
|
1309
|
+
aggregationResLevel = DEFAULT_AGGREGATION_RES_LEVEL_H3,
|
|
1310
|
+
spatialDataColumn = 'h3',
|
|
1311
|
+
tableName,
|
|
1312
|
+
filters
|
|
1313
|
+
} = options;
|
|
1314
|
+
const urlParameters = {
|
|
1315
|
+
aggregationExp,
|
|
1316
|
+
name: tableName,
|
|
1317
|
+
spatialDataColumn,
|
|
1318
|
+
spatialDataType: 'h3'
|
|
1319
|
+
};
|
|
1320
|
+
if (aggregationResLevel) {
|
|
1321
|
+
urlParameters.aggregationResLevel = String(aggregationResLevel);
|
|
1322
|
+
}
|
|
1323
|
+
if (filters) {
|
|
1324
|
+
urlParameters.filters = filters;
|
|
1325
|
+
}
|
|
1326
|
+
return Promise.resolve(baseSource('table', options, urlParameters));
|
|
1327
|
+
} catch (e) {
|
|
1328
|
+
return Promise.reject(e);
|
|
1329
|
+
}
|
|
1330
|
+
};
|
|
1331
|
+
|
|
1332
|
+
// deck.gl
|
|
1333
|
+
const quadbinQuerySource$1 = function (options) {
|
|
1334
|
+
try {
|
|
1335
|
+
const {
|
|
1336
|
+
aggregationExp,
|
|
1337
|
+
aggregationResLevel = DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN,
|
|
1338
|
+
sqlQuery,
|
|
1339
|
+
spatialDataColumn = 'quadbin',
|
|
1340
|
+
queryParameters,
|
|
1341
|
+
filters
|
|
1342
|
+
} = options;
|
|
1343
|
+
const urlParameters = {
|
|
1344
|
+
aggregationExp,
|
|
1345
|
+
q: sqlQuery,
|
|
1346
|
+
spatialDataColumn,
|
|
1347
|
+
spatialDataType: 'quadbin'
|
|
1348
|
+
};
|
|
1349
|
+
if (aggregationResLevel) {
|
|
1350
|
+
urlParameters.aggregationResLevel = String(aggregationResLevel);
|
|
1351
|
+
}
|
|
1352
|
+
if (queryParameters) {
|
|
1353
|
+
urlParameters.queryParameters = queryParameters;
|
|
1354
|
+
}
|
|
1355
|
+
if (filters) {
|
|
1356
|
+
urlParameters.filters = filters;
|
|
1357
|
+
}
|
|
1358
|
+
return Promise.resolve(baseSource('query', options, urlParameters));
|
|
1359
|
+
} catch (e) {
|
|
1360
|
+
return Promise.reject(e);
|
|
1361
|
+
}
|
|
1362
|
+
};
|
|
1363
|
+
|
|
1364
|
+
// deck.gl
|
|
1365
|
+
const quadbinTableSource$1 = function (options) {
|
|
1366
|
+
try {
|
|
1367
|
+
const {
|
|
1368
|
+
aggregationExp,
|
|
1369
|
+
aggregationResLevel = DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN,
|
|
1370
|
+
spatialDataColumn = 'quadbin',
|
|
1371
|
+
tableName,
|
|
1372
|
+
filters
|
|
1373
|
+
} = options;
|
|
1374
|
+
const urlParameters = {
|
|
1375
|
+
aggregationExp,
|
|
1376
|
+
name: tableName,
|
|
1377
|
+
spatialDataColumn,
|
|
1378
|
+
spatialDataType: 'quadbin'
|
|
1379
|
+
};
|
|
1380
|
+
if (aggregationResLevel) {
|
|
1381
|
+
urlParameters.aggregationResLevel = String(aggregationResLevel);
|
|
1382
|
+
}
|
|
1383
|
+
if (filters) {
|
|
1384
|
+
urlParameters.filters = filters;
|
|
1385
|
+
}
|
|
1386
|
+
return Promise.resolve(baseSource('table', options, urlParameters));
|
|
1387
|
+
} catch (e) {
|
|
1388
|
+
return Promise.reject(e);
|
|
1389
|
+
}
|
|
1390
|
+
};
|
|
1391
|
+
|
|
1392
|
+
// deck.gl
|
|
1393
|
+
const vectorQuerySource$1 = function (options) {
|
|
1394
|
+
try {
|
|
1395
|
+
const {
|
|
1396
|
+
columns,
|
|
1397
|
+
filters,
|
|
1398
|
+
spatialDataColumn = 'geom',
|
|
1399
|
+
sqlQuery,
|
|
1400
|
+
tileResolution = DEFAULT_TILE_RESOLUTION,
|
|
1401
|
+
queryParameters
|
|
1402
|
+
} = options;
|
|
1403
|
+
const urlParameters = {
|
|
1404
|
+
spatialDataColumn,
|
|
1405
|
+
spatialDataType: 'geo',
|
|
1406
|
+
tileResolution: tileResolution.toString(),
|
|
1407
|
+
q: sqlQuery
|
|
1408
|
+
};
|
|
1409
|
+
if (columns) {
|
|
1410
|
+
urlParameters.columns = columns.join(',');
|
|
1411
|
+
}
|
|
1412
|
+
if (filters) {
|
|
1413
|
+
urlParameters.filters = filters;
|
|
1414
|
+
}
|
|
1415
|
+
if (queryParameters) {
|
|
1416
|
+
urlParameters.queryParameters = queryParameters;
|
|
1417
|
+
}
|
|
1418
|
+
return Promise.resolve(baseSource('query', options, urlParameters));
|
|
1419
|
+
} catch (e) {
|
|
1420
|
+
return Promise.reject(e);
|
|
1421
|
+
}
|
|
1422
|
+
};
|
|
1423
|
+
|
|
1424
|
+
// deck.gl
|
|
1425
|
+
const vectorTableSource$1 = function (options) {
|
|
1426
|
+
try {
|
|
1427
|
+
const {
|
|
1428
|
+
columns,
|
|
1429
|
+
filters,
|
|
1430
|
+
spatialDataColumn = 'geom',
|
|
1431
|
+
tableName,
|
|
1432
|
+
tileResolution = DEFAULT_TILE_RESOLUTION
|
|
1433
|
+
} = options;
|
|
1434
|
+
const urlParameters = {
|
|
1435
|
+
name: tableName,
|
|
1436
|
+
spatialDataColumn,
|
|
1437
|
+
spatialDataType: 'geo',
|
|
1438
|
+
tileResolution: tileResolution.toString()
|
|
1439
|
+
};
|
|
1440
|
+
if (columns) {
|
|
1441
|
+
urlParameters.columns = columns.join(',');
|
|
1442
|
+
}
|
|
1443
|
+
if (filters) {
|
|
1444
|
+
urlParameters.filters = filters;
|
|
1445
|
+
}
|
|
1446
|
+
return Promise.resolve(baseSource('table', options, urlParameters));
|
|
1447
|
+
} catch (e) {
|
|
1448
|
+
return Promise.reject(e);
|
|
1449
|
+
}
|
|
1450
|
+
};
|
|
1451
|
+
|
|
984
1452
|
/** Wrapper adding Widget API support to [vectorTableSource](https://deck.gl/docs/api-reference/carto/data-sources). */
|
|
985
1453
|
|
|
986
1454
|
/** Wrapper adding Widget API support to [quadbinQuerySource](https://deck.gl/docs/api-reference/carto/data-sources). */
|
|
987
1455
|
const quadbinQuerySource = function (props) {
|
|
988
1456
|
try {
|
|
989
|
-
|
|
990
|
-
return Promise.resolve(carto.quadbinQuerySource(props)).then(function (response) {
|
|
1457
|
+
return Promise.resolve(quadbinQuerySource$1(props)).then(function (response) {
|
|
991
1458
|
return {
|
|
992
1459
|
...response,
|
|
993
1460
|
widgetSource: new WidgetQuerySource(props)
|
|
@@ -1000,8 +1467,7 @@ const quadbinQuerySource = function (props) {
|
|
|
1000
1467
|
/** Wrapper adding Widget API support to [quadbinTableSource](https://deck.gl/docs/api-reference/carto/data-sources). */
|
|
1001
1468
|
const quadbinTableSource = function (props) {
|
|
1002
1469
|
try {
|
|
1003
|
-
|
|
1004
|
-
return Promise.resolve(carto.quadbinTableSource(props)).then(function (response) {
|
|
1470
|
+
return Promise.resolve(quadbinTableSource$1(props)).then(function (response) {
|
|
1005
1471
|
return {
|
|
1006
1472
|
...response,
|
|
1007
1473
|
widgetSource: new WidgetTableSource(props)
|
|
@@ -1014,8 +1480,7 @@ const quadbinTableSource = function (props) {
|
|
|
1014
1480
|
/** Wrapper adding Widget API support to [h3QuerySource](https://deck.gl/docs/api-reference/carto/data-sources). */
|
|
1015
1481
|
const h3QuerySource = function (props) {
|
|
1016
1482
|
try {
|
|
1017
|
-
|
|
1018
|
-
return Promise.resolve(carto.h3QuerySource(props)).then(function (response) {
|
|
1483
|
+
return Promise.resolve(h3QuerySource$1(props)).then(function (response) {
|
|
1019
1484
|
return {
|
|
1020
1485
|
...response,
|
|
1021
1486
|
widgetSource: new WidgetQuerySource(props)
|
|
@@ -1028,8 +1493,7 @@ const h3QuerySource = function (props) {
|
|
|
1028
1493
|
/** Wrapper adding Widget API support to [h3TableSource](https://deck.gl/docs/api-reference/carto/data-sources). */
|
|
1029
1494
|
const h3TableSource = function (props) {
|
|
1030
1495
|
try {
|
|
1031
|
-
|
|
1032
|
-
return Promise.resolve(carto.h3TableSource(props)).then(function (response) {
|
|
1496
|
+
return Promise.resolve(h3TableSource$1(props)).then(function (response) {
|
|
1033
1497
|
return {
|
|
1034
1498
|
...response,
|
|
1035
1499
|
widgetSource: new WidgetTableSource(props)
|
|
@@ -1042,8 +1506,7 @@ const h3TableSource = function (props) {
|
|
|
1042
1506
|
/** Wrapper adding Widget API support to [vectorQuerySource](https://deck.gl/docs/api-reference/carto/data-sources). */
|
|
1043
1507
|
const vectorQuerySource = function (props) {
|
|
1044
1508
|
try {
|
|
1045
|
-
|
|
1046
|
-
return Promise.resolve(carto.vectorQuerySource(props)).then(function (response) {
|
|
1509
|
+
return Promise.resolve(vectorQuerySource$1(props)).then(function (response) {
|
|
1047
1510
|
return {
|
|
1048
1511
|
...response,
|
|
1049
1512
|
widgetSource: new WidgetQuerySource(props)
|
|
@@ -1055,8 +1518,7 @@ const vectorQuerySource = function (props) {
|
|
|
1055
1518
|
};
|
|
1056
1519
|
const vectorTableSource = function (props) {
|
|
1057
1520
|
try {
|
|
1058
|
-
|
|
1059
|
-
return Promise.resolve(carto.vectorTableSource(props)).then(function (response) {
|
|
1521
|
+
return Promise.resolve(vectorTableSource$1(props)).then(function (response) {
|
|
1060
1522
|
return {
|
|
1061
1523
|
...response,
|
|
1062
1524
|
widgetSource: new WidgetTableSource(props)
|
|
@@ -1066,16 +1528,16 @@ const vectorTableSource = function (props) {
|
|
|
1066
1528
|
return Promise.reject(e);
|
|
1067
1529
|
}
|
|
1068
1530
|
};
|
|
1069
|
-
function assignDefaultProps(props) {
|
|
1070
|
-
if (typeof deck !== 'undefined' && deck && deck.VERSION) {
|
|
1071
|
-
props.clientId ||= 'deck-gl-carto';
|
|
1072
|
-
// TODO: Uncomment if/when `@deck.gl/carto` devDependency is removed,
|
|
1073
|
-
// and source functions are moved here rather than wrapped.
|
|
1074
|
-
// props.deckglVersion ||= deck.VERSION;
|
|
1075
|
-
}
|
|
1076
|
-
}
|
|
1077
1531
|
|
|
1078
1532
|
exports.API_CLIENT_VERSION = API_CLIENT_VERSION;
|
|
1533
|
+
exports.DEFAULT_AGGREGATION_RES_LEVEL_H3 = DEFAULT_AGGREGATION_RES_LEVEL_H3;
|
|
1534
|
+
exports.DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN = DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN;
|
|
1535
|
+
exports.DEFAULT_API_BASE_URL = DEFAULT_API_BASE_URL$1;
|
|
1536
|
+
exports.DEFAULT_CLIENT = DEFAULT_CLIENT;
|
|
1537
|
+
exports.DEFAULT_MAX_LENGTH_URL = DEFAULT_MAX_LENGTH_URL;
|
|
1538
|
+
exports.DEFAULT_TILE_RESOLUTION = DEFAULT_TILE_RESOLUTION;
|
|
1539
|
+
exports.DEFAULT_TILE_SIZE = DEFAULT_TILE_SIZE;
|
|
1540
|
+
exports.V3_MINOR_VERSION = V3_MINOR_VERSION;
|
|
1079
1541
|
exports.WidgetBaseSource = WidgetBaseSource;
|
|
1080
1542
|
exports.WidgetQuerySource = WidgetQuerySource;
|
|
1081
1543
|
exports.WidgetTableSource = WidgetTableSource;
|