@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
|
@@ -3,7 +3,6 @@ import bboxPolygon from '@turf/bbox-polygon';
|
|
|
3
3
|
import union from '@turf/union';
|
|
4
4
|
import { getType } from '@turf/invariant';
|
|
5
5
|
import { featureCollection, feature, polygon, multiPolygon } from '@turf/helpers';
|
|
6
|
-
import { vectorTableSource as vectorTableSource$1, vectorQuerySource as vectorQuerySource$1, h3TableSource as h3TableSource$1, h3QuerySource as h3QuerySource$1, quadbinTableSource as quadbinTableSource$1, quadbinQuerySource as quadbinQuerySource$1 } from '@deck.gl/carto';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* @internal
|
|
@@ -30,7 +29,16 @@ function setClient(c) {
|
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
/** Current version of @carto/api-client. */
|
|
33
|
-
const API_CLIENT_VERSION = "0.
|
|
32
|
+
const API_CLIENT_VERSION = "0.4.0-alpha.0";
|
|
33
|
+
const DEFAULT_API_BASE_URL$1 = 'https://gcp-us-east1.api.carto.com';
|
|
34
|
+
const DEFAULT_CLIENT = 'deck-gl-carto';
|
|
35
|
+
const V3_MINOR_VERSION = '3.4';
|
|
36
|
+
// Fastly default limit is 8192; leave some padding.
|
|
37
|
+
const DEFAULT_MAX_LENGTH_URL = 7000;
|
|
38
|
+
const DEFAULT_TILE_SIZE = 512;
|
|
39
|
+
const DEFAULT_TILE_RESOLUTION = 0.5;
|
|
40
|
+
const DEFAULT_AGGREGATION_RES_LEVEL_H3 = 4;
|
|
41
|
+
const DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN = 6;
|
|
34
42
|
/**
|
|
35
43
|
* Defines a comparator used when matching a column's values against given filter values.
|
|
36
44
|
*
|
|
@@ -123,6 +131,10 @@ function isEmptyObject(object) {
|
|
|
123
131
|
}
|
|
124
132
|
return true;
|
|
125
133
|
}
|
|
134
|
+
/** @internal */
|
|
135
|
+
const isObject = x => x !== null && typeof x === 'object';
|
|
136
|
+
/** @internal */
|
|
137
|
+
const isPureObject = x => isObject(x) && x.constructor === {}.constructor;
|
|
126
138
|
|
|
127
139
|
/**
|
|
128
140
|
* Adds a {@link Filter} to the filter set. Any previous filters with the same
|
|
@@ -536,7 +548,7 @@ function executeModel(props) {
|
|
|
536
548
|
});
|
|
537
549
|
}
|
|
538
550
|
|
|
539
|
-
const _excluded = ["filterOwner", "spatialFilter", "abortController"],
|
|
551
|
+
const _excluded$1 = ["filterOwner", "spatialFilter", "abortController"],
|
|
540
552
|
_excluded2 = ["filterOwner", "spatialFilter", "abortController", "operationExp"],
|
|
541
553
|
_excluded3 = ["filterOwner", "spatialFilter", "abortController"],
|
|
542
554
|
_excluded4 = ["filterOwner", "spatialFilter", "abortController"],
|
|
@@ -579,7 +591,7 @@ class WidgetBaseSource {
|
|
|
579
591
|
spatialFilter,
|
|
580
592
|
abortController
|
|
581
593
|
} = options,
|
|
582
|
-
params = _objectWithoutPropertiesLoose(options, _excluded);
|
|
594
|
+
params = _objectWithoutPropertiesLoose(options, _excluded$1);
|
|
583
595
|
const {
|
|
584
596
|
column,
|
|
585
597
|
operation,
|
|
@@ -922,9 +934,404 @@ class WidgetTableSource extends WidgetBaseSource {
|
|
|
922
934
|
}
|
|
923
935
|
}
|
|
924
936
|
|
|
937
|
+
// deck.gl
|
|
938
|
+
// SPDX-License-Identifier: MIT
|
|
939
|
+
// Copyright (c) vis.gl contributors
|
|
940
|
+
function joinPath(...args) {
|
|
941
|
+
return args.map(part => part.endsWith('/') ? part.slice(0, -1) : part).join('/');
|
|
942
|
+
}
|
|
943
|
+
function buildV3Path(apiBaseUrl, version, endpoint, ...rest) {
|
|
944
|
+
return joinPath(apiBaseUrl, version, endpoint, ...rest);
|
|
945
|
+
}
|
|
946
|
+
function buildSourceUrl({
|
|
947
|
+
apiBaseUrl,
|
|
948
|
+
connectionName,
|
|
949
|
+
endpoint
|
|
950
|
+
}) {
|
|
951
|
+
return buildV3Path(apiBaseUrl, 'v3', 'maps', connectionName, endpoint);
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
// deck.gl
|
|
955
|
+
// SPDX-License-Identifier: MIT
|
|
956
|
+
// Copyright (c) vis.gl contributors
|
|
957
|
+
/**
|
|
958
|
+
*
|
|
959
|
+
* Custom error for reported errors in CARTO Maps API.
|
|
960
|
+
* Provides useful debugging information in console and context for applications.
|
|
961
|
+
*
|
|
962
|
+
*/
|
|
963
|
+
class CartoAPIError extends Error {
|
|
964
|
+
constructor(error, errorContext, response, responseJson) {
|
|
965
|
+
let responseString = 'Failed to connect';
|
|
966
|
+
if (response) {
|
|
967
|
+
responseString = 'Server returned: ';
|
|
968
|
+
if (response.status === 400) {
|
|
969
|
+
responseString += 'Bad request';
|
|
970
|
+
} else if (response.status === 401 || response.status === 403) {
|
|
971
|
+
responseString += 'Unauthorized access';
|
|
972
|
+
} else if (response.status === 404) {
|
|
973
|
+
responseString += 'Not found';
|
|
974
|
+
} else {
|
|
975
|
+
responseString += 'Error';
|
|
976
|
+
}
|
|
977
|
+
responseString += ` (${response.status}):`;
|
|
978
|
+
}
|
|
979
|
+
responseString += ` ${error.message || error}`;
|
|
980
|
+
let message = `${errorContext.requestType} API request failed`;
|
|
981
|
+
message += `\n${responseString}`;
|
|
982
|
+
for (const key of Object.keys(errorContext)) {
|
|
983
|
+
if (key === 'requestType') continue;
|
|
984
|
+
message += `\n${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
985
|
+
}
|
|
986
|
+
message += '\n';
|
|
987
|
+
super(message);
|
|
988
|
+
/** Source error from server */
|
|
989
|
+
this.error = void 0;
|
|
990
|
+
/** Context (API call & parameters) in which error occured */
|
|
991
|
+
this.errorContext = void 0;
|
|
992
|
+
/** Response from server */
|
|
993
|
+
this.response = void 0;
|
|
994
|
+
/** JSON Response from server */
|
|
995
|
+
this.responseJson = void 0;
|
|
996
|
+
this.name = 'CartoAPIError';
|
|
997
|
+
this.response = response;
|
|
998
|
+
this.responseJson = responseJson;
|
|
999
|
+
this.error = error;
|
|
1000
|
+
this.errorContext = errorContext;
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
/**
|
|
1004
|
+
* Converts camelCase to Camel Case
|
|
1005
|
+
*/
|
|
1006
|
+
function formatErrorKey(key) {
|
|
1007
|
+
return key.replace(/([A-Z])/g, ' $1').replace(/^./, s => s.toUpperCase());
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
const DEFAULT_HEADERS = {
|
|
1011
|
+
Accept: 'application/json',
|
|
1012
|
+
'Content-Type': 'application/json'
|
|
1013
|
+
};
|
|
1014
|
+
const REQUEST_CACHE = new Map();
|
|
1015
|
+
async function requestWithParameters({
|
|
1016
|
+
baseUrl,
|
|
1017
|
+
parameters = {},
|
|
1018
|
+
headers: customHeaders = {},
|
|
1019
|
+
errorContext,
|
|
1020
|
+
maxLengthURL = DEFAULT_MAX_LENGTH_URL
|
|
1021
|
+
}) {
|
|
1022
|
+
// Parameters added to all requests issued with `requestWithParameters()`.
|
|
1023
|
+
// These parameters override parameters already in the base URL, but not
|
|
1024
|
+
// user-provided parameters.
|
|
1025
|
+
parameters = _extends({
|
|
1026
|
+
v: V3_MINOR_VERSION,
|
|
1027
|
+
clientId: DEFAULT_CLIENT
|
|
1028
|
+
}, typeof deck !== 'undefined' && deck.VERSION && {
|
|
1029
|
+
deckglVersion: deck.VERSION
|
|
1030
|
+
}, parameters);
|
|
1031
|
+
baseUrl = excludeURLParameters(baseUrl, Object.keys(parameters));
|
|
1032
|
+
const key = createCacheKey(baseUrl, parameters, customHeaders);
|
|
1033
|
+
if (REQUEST_CACHE.has(key)) {
|
|
1034
|
+
return REQUEST_CACHE.get(key);
|
|
1035
|
+
}
|
|
1036
|
+
const url = createURLWithParameters(baseUrl, parameters);
|
|
1037
|
+
const headers = _extends({}, DEFAULT_HEADERS, customHeaders);
|
|
1038
|
+
/* global fetch */
|
|
1039
|
+
const fetchPromise = url.length > maxLengthURL ? fetch(baseUrl, {
|
|
1040
|
+
method: 'POST',
|
|
1041
|
+
body: JSON.stringify(parameters),
|
|
1042
|
+
headers
|
|
1043
|
+
}) : fetch(url, {
|
|
1044
|
+
headers
|
|
1045
|
+
});
|
|
1046
|
+
let response;
|
|
1047
|
+
let responseJson;
|
|
1048
|
+
const jsonPromise = fetchPromise.then(_response => {
|
|
1049
|
+
response = _response;
|
|
1050
|
+
return response.json();
|
|
1051
|
+
}).then(json => {
|
|
1052
|
+
responseJson = json;
|
|
1053
|
+
if (!response || !response.ok) {
|
|
1054
|
+
throw new Error(json.error);
|
|
1055
|
+
}
|
|
1056
|
+
return json;
|
|
1057
|
+
}).catch(error => {
|
|
1058
|
+
REQUEST_CACHE.delete(key);
|
|
1059
|
+
throw new CartoAPIError(error, errorContext, response, responseJson);
|
|
1060
|
+
});
|
|
1061
|
+
REQUEST_CACHE.set(key, jsonPromise);
|
|
1062
|
+
return jsonPromise;
|
|
1063
|
+
}
|
|
1064
|
+
function createCacheKey(baseUrl, parameters, headers) {
|
|
1065
|
+
const parameterEntries = Object.entries(parameters).sort(([a], [b]) => a > b ? 1 : -1);
|
|
1066
|
+
const headerEntries = Object.entries(headers).sort(([a], [b]) => a > b ? 1 : -1);
|
|
1067
|
+
return JSON.stringify({
|
|
1068
|
+
baseUrl,
|
|
1069
|
+
parameters: parameterEntries,
|
|
1070
|
+
headers: headerEntries
|
|
1071
|
+
});
|
|
1072
|
+
}
|
|
1073
|
+
/**
|
|
1074
|
+
* Appends query string parameters to a URL. Existing URL parameters are kept,
|
|
1075
|
+
* unless there is a conflict, in which case the new parameters override
|
|
1076
|
+
* those already in the URL.
|
|
1077
|
+
*/
|
|
1078
|
+
function createURLWithParameters(baseUrlString, parameters) {
|
|
1079
|
+
const baseUrl = new URL(baseUrlString);
|
|
1080
|
+
for (const [key, value] of Object.entries(parameters)) {
|
|
1081
|
+
if (isPureObject(value) || Array.isArray(value)) {
|
|
1082
|
+
baseUrl.searchParams.set(key, JSON.stringify(value));
|
|
1083
|
+
} else {
|
|
1084
|
+
baseUrl.searchParams.set(key, value.toString());
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
return baseUrl.toString();
|
|
1088
|
+
}
|
|
1089
|
+
/**
|
|
1090
|
+
* Deletes query string parameters from a URL.
|
|
1091
|
+
*/
|
|
1092
|
+
function excludeURLParameters(baseUrlString, parameters) {
|
|
1093
|
+
const baseUrl = new URL(baseUrlString);
|
|
1094
|
+
for (const param of parameters) {
|
|
1095
|
+
if (baseUrl.searchParams.has(param)) {
|
|
1096
|
+
baseUrl.searchParams.delete(param);
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
return baseUrl.toString();
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
const _excluded = ["accessToken", "connectionName", "cache"];
|
|
1103
|
+
const SOURCE_DEFAULTS = {
|
|
1104
|
+
apiBaseUrl: DEFAULT_API_BASE_URL$1,
|
|
1105
|
+
clientId: DEFAULT_CLIENT,
|
|
1106
|
+
format: 'tilejson',
|
|
1107
|
+
headers: {},
|
|
1108
|
+
maxLengthURL: DEFAULT_MAX_LENGTH_URL
|
|
1109
|
+
};
|
|
1110
|
+
async function baseSource(endpoint, options, urlParameters) {
|
|
1111
|
+
const {
|
|
1112
|
+
accessToken,
|
|
1113
|
+
connectionName,
|
|
1114
|
+
cache
|
|
1115
|
+
} = options,
|
|
1116
|
+
optionalOptions = _objectWithoutPropertiesLoose(options, _excluded);
|
|
1117
|
+
const mergedOptions = _extends({}, SOURCE_DEFAULTS, {
|
|
1118
|
+
accessToken,
|
|
1119
|
+
connectionName,
|
|
1120
|
+
endpoint
|
|
1121
|
+
});
|
|
1122
|
+
for (const key in optionalOptions) {
|
|
1123
|
+
if (optionalOptions[key]) {
|
|
1124
|
+
mergedOptions[key] = optionalOptions[key];
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
const baseUrl = buildSourceUrl(mergedOptions);
|
|
1128
|
+
const {
|
|
1129
|
+
clientId,
|
|
1130
|
+
maxLengthURL,
|
|
1131
|
+
format
|
|
1132
|
+
} = mergedOptions;
|
|
1133
|
+
const headers = _extends({
|
|
1134
|
+
Authorization: `Bearer ${options.accessToken}`
|
|
1135
|
+
}, options.headers);
|
|
1136
|
+
const parameters = _extends({
|
|
1137
|
+
client: clientId
|
|
1138
|
+
}, urlParameters);
|
|
1139
|
+
const errorContext = {
|
|
1140
|
+
requestType: 'Map instantiation',
|
|
1141
|
+
connection: options.connectionName,
|
|
1142
|
+
type: endpoint,
|
|
1143
|
+
source: JSON.stringify(parameters, undefined, 2)
|
|
1144
|
+
};
|
|
1145
|
+
const mapInstantiation = await requestWithParameters({
|
|
1146
|
+
baseUrl,
|
|
1147
|
+
parameters,
|
|
1148
|
+
headers,
|
|
1149
|
+
errorContext,
|
|
1150
|
+
maxLengthURL
|
|
1151
|
+
});
|
|
1152
|
+
const dataUrl = mapInstantiation[format].url[0];
|
|
1153
|
+
if (cache) {
|
|
1154
|
+
cache.value = parseInt(new URL(dataUrl).searchParams.get('cache') || '', 10);
|
|
1155
|
+
}
|
|
1156
|
+
errorContext.requestType = 'Map data';
|
|
1157
|
+
if (format === 'tilejson') {
|
|
1158
|
+
const json = await requestWithParameters({
|
|
1159
|
+
baseUrl: dataUrl,
|
|
1160
|
+
headers,
|
|
1161
|
+
errorContext,
|
|
1162
|
+
maxLengthURL
|
|
1163
|
+
});
|
|
1164
|
+
if (accessToken) {
|
|
1165
|
+
json.accessToken = accessToken;
|
|
1166
|
+
}
|
|
1167
|
+
return json;
|
|
1168
|
+
}
|
|
1169
|
+
return await requestWithParameters({
|
|
1170
|
+
baseUrl: dataUrl,
|
|
1171
|
+
headers,
|
|
1172
|
+
errorContext,
|
|
1173
|
+
maxLengthURL
|
|
1174
|
+
});
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
// deck.gl
|
|
1178
|
+
const h3QuerySource$1 = async function h3QuerySource(options) {
|
|
1179
|
+
const {
|
|
1180
|
+
aggregationExp,
|
|
1181
|
+
aggregationResLevel = DEFAULT_AGGREGATION_RES_LEVEL_H3,
|
|
1182
|
+
sqlQuery,
|
|
1183
|
+
spatialDataColumn = 'h3',
|
|
1184
|
+
queryParameters,
|
|
1185
|
+
filters
|
|
1186
|
+
} = options;
|
|
1187
|
+
const urlParameters = {
|
|
1188
|
+
aggregationExp,
|
|
1189
|
+
spatialDataColumn,
|
|
1190
|
+
spatialDataType: 'h3',
|
|
1191
|
+
q: sqlQuery
|
|
1192
|
+
};
|
|
1193
|
+
if (aggregationResLevel) {
|
|
1194
|
+
urlParameters.aggregationResLevel = String(aggregationResLevel);
|
|
1195
|
+
}
|
|
1196
|
+
if (queryParameters) {
|
|
1197
|
+
urlParameters.queryParameters = queryParameters;
|
|
1198
|
+
}
|
|
1199
|
+
if (filters) {
|
|
1200
|
+
urlParameters.filters = filters;
|
|
1201
|
+
}
|
|
1202
|
+
return baseSource('query', options, urlParameters);
|
|
1203
|
+
};
|
|
1204
|
+
|
|
1205
|
+
// deck.gl
|
|
1206
|
+
const h3TableSource$1 = async function h3TableSource(options) {
|
|
1207
|
+
const {
|
|
1208
|
+
aggregationExp,
|
|
1209
|
+
aggregationResLevel = DEFAULT_AGGREGATION_RES_LEVEL_H3,
|
|
1210
|
+
spatialDataColumn = 'h3',
|
|
1211
|
+
tableName,
|
|
1212
|
+
filters
|
|
1213
|
+
} = options;
|
|
1214
|
+
const urlParameters = {
|
|
1215
|
+
aggregationExp,
|
|
1216
|
+
name: tableName,
|
|
1217
|
+
spatialDataColumn,
|
|
1218
|
+
spatialDataType: 'h3'
|
|
1219
|
+
};
|
|
1220
|
+
if (aggregationResLevel) {
|
|
1221
|
+
urlParameters.aggregationResLevel = String(aggregationResLevel);
|
|
1222
|
+
}
|
|
1223
|
+
if (filters) {
|
|
1224
|
+
urlParameters.filters = filters;
|
|
1225
|
+
}
|
|
1226
|
+
return baseSource('table', options, urlParameters);
|
|
1227
|
+
};
|
|
1228
|
+
|
|
1229
|
+
// deck.gl
|
|
1230
|
+
const quadbinQuerySource$1 = async function quadbinQuerySource(options) {
|
|
1231
|
+
const {
|
|
1232
|
+
aggregationExp,
|
|
1233
|
+
aggregationResLevel = DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN,
|
|
1234
|
+
sqlQuery,
|
|
1235
|
+
spatialDataColumn = 'quadbin',
|
|
1236
|
+
queryParameters,
|
|
1237
|
+
filters
|
|
1238
|
+
} = options;
|
|
1239
|
+
const urlParameters = {
|
|
1240
|
+
aggregationExp,
|
|
1241
|
+
q: sqlQuery,
|
|
1242
|
+
spatialDataColumn,
|
|
1243
|
+
spatialDataType: 'quadbin'
|
|
1244
|
+
};
|
|
1245
|
+
if (aggregationResLevel) {
|
|
1246
|
+
urlParameters.aggregationResLevel = String(aggregationResLevel);
|
|
1247
|
+
}
|
|
1248
|
+
if (queryParameters) {
|
|
1249
|
+
urlParameters.queryParameters = queryParameters;
|
|
1250
|
+
}
|
|
1251
|
+
if (filters) {
|
|
1252
|
+
urlParameters.filters = filters;
|
|
1253
|
+
}
|
|
1254
|
+
return baseSource('query', options, urlParameters);
|
|
1255
|
+
};
|
|
1256
|
+
|
|
1257
|
+
// deck.gl
|
|
1258
|
+
const quadbinTableSource$1 = async function quadbinTableSource(options) {
|
|
1259
|
+
const {
|
|
1260
|
+
aggregationExp,
|
|
1261
|
+
aggregationResLevel = DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN,
|
|
1262
|
+
spatialDataColumn = 'quadbin',
|
|
1263
|
+
tableName,
|
|
1264
|
+
filters
|
|
1265
|
+
} = options;
|
|
1266
|
+
const urlParameters = {
|
|
1267
|
+
aggregationExp,
|
|
1268
|
+
name: tableName,
|
|
1269
|
+
spatialDataColumn,
|
|
1270
|
+
spatialDataType: 'quadbin'
|
|
1271
|
+
};
|
|
1272
|
+
if (aggregationResLevel) {
|
|
1273
|
+
urlParameters.aggregationResLevel = String(aggregationResLevel);
|
|
1274
|
+
}
|
|
1275
|
+
if (filters) {
|
|
1276
|
+
urlParameters.filters = filters;
|
|
1277
|
+
}
|
|
1278
|
+
return baseSource('table', options, urlParameters);
|
|
1279
|
+
};
|
|
1280
|
+
|
|
1281
|
+
// deck.gl
|
|
1282
|
+
const vectorQuerySource$1 = async function vectorQuerySource(options) {
|
|
1283
|
+
const {
|
|
1284
|
+
columns,
|
|
1285
|
+
filters,
|
|
1286
|
+
spatialDataColumn = 'geom',
|
|
1287
|
+
sqlQuery,
|
|
1288
|
+
tileResolution = DEFAULT_TILE_RESOLUTION,
|
|
1289
|
+
queryParameters
|
|
1290
|
+
} = options;
|
|
1291
|
+
const urlParameters = {
|
|
1292
|
+
spatialDataColumn,
|
|
1293
|
+
spatialDataType: 'geo',
|
|
1294
|
+
tileResolution: tileResolution.toString(),
|
|
1295
|
+
q: sqlQuery
|
|
1296
|
+
};
|
|
1297
|
+
if (columns) {
|
|
1298
|
+
urlParameters.columns = columns.join(',');
|
|
1299
|
+
}
|
|
1300
|
+
if (filters) {
|
|
1301
|
+
urlParameters.filters = filters;
|
|
1302
|
+
}
|
|
1303
|
+
if (queryParameters) {
|
|
1304
|
+
urlParameters.queryParameters = queryParameters;
|
|
1305
|
+
}
|
|
1306
|
+
return baseSource('query', options, urlParameters);
|
|
1307
|
+
};
|
|
1308
|
+
|
|
1309
|
+
// deck.gl
|
|
1310
|
+
const vectorTableSource$1 = async function vectorTableSource(options) {
|
|
1311
|
+
const {
|
|
1312
|
+
columns,
|
|
1313
|
+
filters,
|
|
1314
|
+
spatialDataColumn = 'geom',
|
|
1315
|
+
tableName,
|
|
1316
|
+
tileResolution = DEFAULT_TILE_RESOLUTION
|
|
1317
|
+
} = options;
|
|
1318
|
+
const urlParameters = {
|
|
1319
|
+
name: tableName,
|
|
1320
|
+
spatialDataColumn,
|
|
1321
|
+
spatialDataType: 'geo',
|
|
1322
|
+
tileResolution: tileResolution.toString()
|
|
1323
|
+
};
|
|
1324
|
+
if (columns) {
|
|
1325
|
+
urlParameters.columns = columns.join(',');
|
|
1326
|
+
}
|
|
1327
|
+
if (filters) {
|
|
1328
|
+
urlParameters.filters = filters;
|
|
1329
|
+
}
|
|
1330
|
+
return baseSource('table', options, urlParameters);
|
|
1331
|
+
};
|
|
1332
|
+
|
|
925
1333
|
/** Wrapper adding Widget API support to [vectorTableSource](https://deck.gl/docs/api-reference/carto/data-sources). */
|
|
926
1334
|
async function vectorTableSource(props) {
|
|
927
|
-
assignDefaultProps(props);
|
|
928
1335
|
const response = await vectorTableSource$1(props);
|
|
929
1336
|
return _extends({}, response, {
|
|
930
1337
|
widgetSource: new WidgetTableSource(props)
|
|
@@ -932,7 +1339,6 @@ async function vectorTableSource(props) {
|
|
|
932
1339
|
}
|
|
933
1340
|
/** Wrapper adding Widget API support to [vectorQuerySource](https://deck.gl/docs/api-reference/carto/data-sources). */
|
|
934
1341
|
async function vectorQuerySource(props) {
|
|
935
|
-
assignDefaultProps(props);
|
|
936
1342
|
const response = await vectorQuerySource$1(props);
|
|
937
1343
|
return _extends({}, response, {
|
|
938
1344
|
widgetSource: new WidgetQuerySource(props)
|
|
@@ -940,7 +1346,6 @@ async function vectorQuerySource(props) {
|
|
|
940
1346
|
}
|
|
941
1347
|
/** Wrapper adding Widget API support to [h3TableSource](https://deck.gl/docs/api-reference/carto/data-sources). */
|
|
942
1348
|
async function h3TableSource(props) {
|
|
943
|
-
assignDefaultProps(props);
|
|
944
1349
|
const response = await h3TableSource$1(props);
|
|
945
1350
|
return _extends({}, response, {
|
|
946
1351
|
widgetSource: new WidgetTableSource(props)
|
|
@@ -948,7 +1353,6 @@ async function h3TableSource(props) {
|
|
|
948
1353
|
}
|
|
949
1354
|
/** Wrapper adding Widget API support to [h3QuerySource](https://deck.gl/docs/api-reference/carto/data-sources). */
|
|
950
1355
|
async function h3QuerySource(props) {
|
|
951
|
-
assignDefaultProps(props);
|
|
952
1356
|
const response = await h3QuerySource$1(props);
|
|
953
1357
|
return _extends({}, response, {
|
|
954
1358
|
widgetSource: new WidgetQuerySource(props)
|
|
@@ -956,7 +1360,6 @@ async function h3QuerySource(props) {
|
|
|
956
1360
|
}
|
|
957
1361
|
/** Wrapper adding Widget API support to [quadbinTableSource](https://deck.gl/docs/api-reference/carto/data-sources). */
|
|
958
1362
|
async function quadbinTableSource(props) {
|
|
959
|
-
assignDefaultProps(props);
|
|
960
1363
|
const response = await quadbinTableSource$1(props);
|
|
961
1364
|
return _extends({}, response, {
|
|
962
1365
|
widgetSource: new WidgetTableSource(props)
|
|
@@ -964,20 +1367,11 @@ async function quadbinTableSource(props) {
|
|
|
964
1367
|
}
|
|
965
1368
|
/** Wrapper adding Widget API support to [quadbinQuerySource](https://deck.gl/docs/api-reference/carto/data-sources). */
|
|
966
1369
|
async function quadbinQuerySource(props) {
|
|
967
|
-
assignDefaultProps(props);
|
|
968
1370
|
const response = await quadbinQuerySource$1(props);
|
|
969
1371
|
return _extends({}, response, {
|
|
970
1372
|
widgetSource: new WidgetQuerySource(props)
|
|
971
1373
|
});
|
|
972
1374
|
}
|
|
973
|
-
function assignDefaultProps(props) {
|
|
974
|
-
if (typeof deck !== 'undefined' && deck && deck.VERSION) {
|
|
975
|
-
props.clientId || (props.clientId = 'deck-gl-carto');
|
|
976
|
-
// TODO: Uncomment if/when `@deck.gl/carto` devDependency is removed,
|
|
977
|
-
// and source functions are moved here rather than wrapped.
|
|
978
|
-
// props.deckglVersion ||= deck.VERSION;
|
|
979
|
-
}
|
|
980
|
-
}
|
|
981
1375
|
|
|
982
|
-
export { API_CLIENT_VERSION, FilterType, WidgetBaseSource, WidgetQuerySource, WidgetTableSource, addFilter, clearFilters, createPolygonSpatialFilter, createViewportSpatialFilter, getClient, getFilter, h3QuerySource, h3TableSource, hasFilter, quadbinQuerySource, quadbinTableSource, removeFilter, setClient, vectorQuerySource, vectorTableSource };
|
|
1376
|
+
export { API_CLIENT_VERSION, DEFAULT_AGGREGATION_RES_LEVEL_H3, DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN, DEFAULT_API_BASE_URL$1 as DEFAULT_API_BASE_URL, DEFAULT_CLIENT, DEFAULT_MAX_LENGTH_URL, DEFAULT_TILE_RESOLUTION, DEFAULT_TILE_SIZE, FilterType, V3_MINOR_VERSION, WidgetBaseSource, WidgetQuerySource, WidgetTableSource, addFilter, clearFilters, createPolygonSpatialFilter, createViewportSpatialFilter, getClient, getFilter, h3QuerySource, h3TableSource, hasFilter, quadbinQuerySource, quadbinTableSource, removeFilter, setClient, vectorQuerySource, vectorTableSource };
|
|
983
1377
|
//# sourceMappingURL=api-client.modern.js.map
|