@carto/api-client 0.3.1 → 0.4.0-alpha.1
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 +26 -0
- package/build/api/endpoints.d.ts +24 -0
- package/build/api/index.d.ts +5 -0
- package/build/api/query.d.ts +3 -0
- package/build/api/request-with-parameters.d.ts +8 -0
- package/build/api-client.cjs +724 -65
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.modern.js +607 -59
- package/build/api-client.modern.js.map +1 -1
- package/build/constants-internal.d.ts +9 -28
- package/build/constants.d.ts +24 -2
- package/build/index.d.ts +5 -1
- package/build/models/model.d.ts +2 -2
- 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 +209 -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/types-internal.d.ts +46 -1
- package/build/types.d.ts +11 -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 +2 -2
- 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 +88 -0
- package/src/api/endpoints.ts +84 -0
- package/src/api/index.ts +14 -0
- package/src/api/query.ts +56 -0
- package/src/api/request-with-parameters.ts +135 -0
- package/src/constants-internal.ts +9 -30
- package/src/constants.ts +32 -3
- package/src/global.d.ts +3 -0
- package/src/index.ts +38 -1
- package/src/models/model.ts +4 -6
- package/src/sources/base-source.ts +101 -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 +54 -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 +221 -89
- 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/types-internal.ts +54 -1
- package/src/types.ts +16 -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 +5 -5
- package/src/{sources → widget-sources}/widget-query-source.ts +2 -3
- package/src/{sources → widget-sources}/widget-table-source.ts +2 -3
- package/src/{sources → widget-sources}/wrappers.ts +1 -22
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
|
|
|
@@ -35,8 +34,6 @@ function setClient(c) {
|
|
|
35
34
|
client = c;
|
|
36
35
|
}
|
|
37
36
|
|
|
38
|
-
/** Current version of @carto/api-client. */
|
|
39
|
-
const API_CLIENT_VERSION = "0.3.1";
|
|
40
37
|
/**
|
|
41
38
|
* Defines a comparator used when matching a column's values against given filter values.
|
|
42
39
|
*
|
|
@@ -61,6 +58,31 @@ exports.FilterType = void 0;
|
|
|
61
58
|
FilterType["TIME"] = "time";
|
|
62
59
|
FilterType["STRING_SEARCH"] = "stringSearch";
|
|
63
60
|
})(exports.FilterType || (exports.FilterType = {}));
|
|
61
|
+
/** @internalRemarks Source: @carto/constants */
|
|
62
|
+
exports.ApiVersion = void 0;
|
|
63
|
+
(function (ApiVersion) {
|
|
64
|
+
ApiVersion["V1"] = "v1";
|
|
65
|
+
ApiVersion["V2"] = "v2";
|
|
66
|
+
ApiVersion["V3"] = "v3";
|
|
67
|
+
})(exports.ApiVersion || (exports.ApiVersion = {}));
|
|
68
|
+
/******************************************************************************
|
|
69
|
+
* DEFAULTS
|
|
70
|
+
*/
|
|
71
|
+
/** @internalRemarks Source: @carto/constants, @deck.gl/carto */
|
|
72
|
+
const DEFAULT_API_BASE_URL = 'https://gcp-us-east1.api.carto.com';
|
|
73
|
+
/** @internalRemarks Source: @carto/constants, @deck.gl/carto */
|
|
74
|
+
const DEFAULT_CLIENT = 'deck-gl-carto';
|
|
75
|
+
/** @internalRemarks Source: @carto/constants, @deck.gl/carto */
|
|
76
|
+
const DEFAULT_GEO_COLUMN = 'geom';
|
|
77
|
+
/**
|
|
78
|
+
* Fastly default limit is 8192; leave some padding.
|
|
79
|
+
* @internalRemarks Source: @deck.gl/carto
|
|
80
|
+
*/
|
|
81
|
+
const DEFAULT_MAX_LENGTH_URL = 7000;
|
|
82
|
+
/** @internalRemarks Source: @deck.gl/carto */
|
|
83
|
+
const DEFAULT_TILE_SIZE = 512;
|
|
84
|
+
/** @internalRemarks Source: @deck.gl/carto */
|
|
85
|
+
const DEFAULT_TILE_RESOLUTION = 0.5;
|
|
64
86
|
|
|
65
87
|
const FILTER_TYPES = new Set(Object.values(exports.FilterType));
|
|
66
88
|
const isFilterType = type => FILTER_TYPES.has(type);
|
|
@@ -129,6 +151,10 @@ function isEmptyObject(object) {
|
|
|
129
151
|
}
|
|
130
152
|
return true;
|
|
131
153
|
}
|
|
154
|
+
/** @internal */
|
|
155
|
+
const isObject = x => x !== null && typeof x === 'object';
|
|
156
|
+
/** @internal */
|
|
157
|
+
const isPureObject = x => isObject(x) && x.constructor === {}.constructor;
|
|
132
158
|
|
|
133
159
|
/**
|
|
134
160
|
* Adds a {@link Filter} to the filter set. Any previous filters with the same
|
|
@@ -345,43 +371,6 @@ function _isMultiPolygon(geometry) {
|
|
|
345
371
|
return invariant.getType(geometry) === 'MultiPolygon';
|
|
346
372
|
}
|
|
347
373
|
|
|
348
|
-
/******************************************************************************
|
|
349
|
-
* DEFAULTS
|
|
350
|
-
*/
|
|
351
|
-
/**
|
|
352
|
-
* @internalRemarks Source: @carto/constants
|
|
353
|
-
* @internal
|
|
354
|
-
*/
|
|
355
|
-
const DEFAULT_API_BASE_URL = 'https://gcp-us-east1.api.carto.com';
|
|
356
|
-
/**
|
|
357
|
-
* @internalRemarks Source: @carto/react-api
|
|
358
|
-
* @internal
|
|
359
|
-
*/
|
|
360
|
-
const DEFAULT_GEO_COLUMN = 'geom';
|
|
361
|
-
/******************************************************************************
|
|
362
|
-
* ENUMS
|
|
363
|
-
*/
|
|
364
|
-
/**
|
|
365
|
-
* @internal
|
|
366
|
-
* @internalRemarks Source: @carto/constants
|
|
367
|
-
*/
|
|
368
|
-
var MapType;
|
|
369
|
-
(function (MapType) {
|
|
370
|
-
MapType["TABLE"] = "table";
|
|
371
|
-
MapType["QUERY"] = "query";
|
|
372
|
-
MapType["TILESET"] = "tileset";
|
|
373
|
-
})(MapType || (MapType = {}));
|
|
374
|
-
/**
|
|
375
|
-
* @internal
|
|
376
|
-
* @internalRemarks Source: @carto/constants
|
|
377
|
-
*/
|
|
378
|
-
var ApiVersion;
|
|
379
|
-
(function (ApiVersion) {
|
|
380
|
-
ApiVersion["V1"] = "v1";
|
|
381
|
-
ApiVersion["V2"] = "v2";
|
|
382
|
-
ApiVersion["V3"] = "v3";
|
|
383
|
-
})(ApiVersion || (ApiVersion = {}));
|
|
384
|
-
|
|
385
374
|
/**
|
|
386
375
|
* Return more descriptive error from API
|
|
387
376
|
* @internalRemarks Source: @carto/react-api
|
|
@@ -476,7 +465,7 @@ function dealWithApiError(_ref) {
|
|
|
476
465
|
const AVAILABLE_MODELS = ['category', 'histogram', 'formula', 'timeseries', 'range', 'scatterplot', 'table'];
|
|
477
466
|
const {
|
|
478
467
|
V3
|
|
479
|
-
} = ApiVersion;
|
|
468
|
+
} = exports.ApiVersion;
|
|
480
469
|
const REQUEST_GET_MAX_URL_LENGTH = 2048;
|
|
481
470
|
/**
|
|
482
471
|
* Execute a SQL model request.
|
|
@@ -504,7 +493,7 @@ function executeModel(props) {
|
|
|
504
493
|
assert(apiBaseUrl, 'executeModel: missing apiBaseUrl');
|
|
505
494
|
assert(accessToken, 'executeModel: missing accessToken');
|
|
506
495
|
assert(apiVersion === V3, 'executeModel: SQL Model API requires CARTO 3+');
|
|
507
|
-
assert(type !==
|
|
496
|
+
assert(type !== 'tileset', 'executeModel: Tilesets not supported');
|
|
508
497
|
let url = `${apiBaseUrl}/v3/sql/${connectionName}/model/${model}`;
|
|
509
498
|
const {
|
|
510
499
|
filters,
|
|
@@ -908,7 +897,7 @@ class WidgetBaseSource {
|
|
|
908
897
|
}
|
|
909
898
|
}
|
|
910
899
|
WidgetBaseSource.defaultProps = {
|
|
911
|
-
apiVersion: ApiVersion.V3,
|
|
900
|
+
apiVersion: exports.ApiVersion.V3,
|
|
912
901
|
apiBaseUrl: DEFAULT_API_BASE_URL,
|
|
913
902
|
clientId: getClient(),
|
|
914
903
|
filters: {},
|
|
@@ -942,7 +931,7 @@ class WidgetQuerySource extends WidgetBaseSource {
|
|
|
942
931
|
getModelSource(owner) {
|
|
943
932
|
return {
|
|
944
933
|
...super._getModelSource(owner),
|
|
945
|
-
type:
|
|
934
|
+
type: 'query',
|
|
946
935
|
data: this.props.sqlQuery,
|
|
947
936
|
queryParameters: this.props.queryParameters
|
|
948
937
|
};
|
|
@@ -975,19 +964,638 @@ class WidgetTableSource extends WidgetBaseSource {
|
|
|
975
964
|
getModelSource(owner) {
|
|
976
965
|
return {
|
|
977
966
|
...super._getModelSource(owner),
|
|
978
|
-
type:
|
|
967
|
+
type: 'table',
|
|
979
968
|
data: this.props.tableName
|
|
980
969
|
};
|
|
981
970
|
}
|
|
982
971
|
}
|
|
983
972
|
|
|
973
|
+
// deck.gl
|
|
974
|
+
// SPDX-License-Identifier: MIT
|
|
975
|
+
// Copyright (c) vis.gl contributors
|
|
976
|
+
function joinPath() {
|
|
977
|
+
return [].slice.call(arguments).map(part => part.endsWith('/') ? part.slice(0, -1) : part).join('/');
|
|
978
|
+
}
|
|
979
|
+
function buildV3Path(apiBaseUrl, version, endpoint) {
|
|
980
|
+
return joinPath(apiBaseUrl, version, endpoint, ...[].slice.call(arguments, 3));
|
|
981
|
+
}
|
|
982
|
+
/** @internal Required by fetchMap(). */
|
|
983
|
+
function buildPublicMapUrl(_ref) {
|
|
984
|
+
let {
|
|
985
|
+
apiBaseUrl,
|
|
986
|
+
cartoMapId
|
|
987
|
+
} = _ref;
|
|
988
|
+
return buildV3Path(apiBaseUrl, 'v3', 'maps', 'public', cartoMapId);
|
|
989
|
+
}
|
|
990
|
+
/** @internal Required by fetchMap(). */
|
|
991
|
+
function buildStatsUrl(_ref2) {
|
|
992
|
+
let {
|
|
993
|
+
attribute,
|
|
994
|
+
apiBaseUrl,
|
|
995
|
+
connectionName,
|
|
996
|
+
source,
|
|
997
|
+
type
|
|
998
|
+
} = _ref2;
|
|
999
|
+
if (type === 'query') {
|
|
1000
|
+
return buildV3Path(apiBaseUrl, 'v3', 'stats', connectionName, attribute);
|
|
1001
|
+
}
|
|
1002
|
+
// type === 'table'
|
|
1003
|
+
return buildV3Path(apiBaseUrl, 'v3', 'stats', connectionName, source, attribute);
|
|
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
|
+
function buildQueryUrl(_ref4) {
|
|
1014
|
+
let {
|
|
1015
|
+
apiBaseUrl,
|
|
1016
|
+
connectionName
|
|
1017
|
+
} = _ref4;
|
|
1018
|
+
return buildV3Path(apiBaseUrl, 'v3', 'sql', connectionName, 'query');
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
// deck.gl
|
|
1022
|
+
// SPDX-License-Identifier: MIT
|
|
1023
|
+
// Copyright (c) vis.gl contributors
|
|
1024
|
+
/**
|
|
1025
|
+
*
|
|
1026
|
+
* Custom error for reported errors in CARTO Maps API.
|
|
1027
|
+
* Provides useful debugging information in console and context for applications.
|
|
1028
|
+
*
|
|
1029
|
+
*/
|
|
1030
|
+
class CartoAPIError extends Error {
|
|
1031
|
+
constructor(error, errorContext, response, responseJson) {
|
|
1032
|
+
let responseString = 'Failed to connect';
|
|
1033
|
+
if (response) {
|
|
1034
|
+
responseString = 'Server returned: ';
|
|
1035
|
+
if (response.status === 400) {
|
|
1036
|
+
responseString += 'Bad request';
|
|
1037
|
+
} else if (response.status === 401 || response.status === 403) {
|
|
1038
|
+
responseString += 'Unauthorized access';
|
|
1039
|
+
} else if (response.status === 404) {
|
|
1040
|
+
responseString += 'Not found';
|
|
1041
|
+
} else {
|
|
1042
|
+
responseString += 'Error';
|
|
1043
|
+
}
|
|
1044
|
+
responseString += ` (${response.status}):`;
|
|
1045
|
+
}
|
|
1046
|
+
responseString += ` ${error.message || error}`;
|
|
1047
|
+
let message = `${errorContext.requestType} API request failed`;
|
|
1048
|
+
message += `\n${responseString}`;
|
|
1049
|
+
for (const key of Object.keys(errorContext)) {
|
|
1050
|
+
if (key === 'requestType') continue;
|
|
1051
|
+
message += `\n${formatErrorKey(key)}: ${errorContext[key]}`;
|
|
1052
|
+
}
|
|
1053
|
+
message += '\n';
|
|
1054
|
+
super(message);
|
|
1055
|
+
/** Source error from server */
|
|
1056
|
+
this.error = void 0;
|
|
1057
|
+
/** Context (API call & parameters) in which error occured */
|
|
1058
|
+
this.errorContext = void 0;
|
|
1059
|
+
/** Response from server */
|
|
1060
|
+
this.response = void 0;
|
|
1061
|
+
/** JSON Response from server */
|
|
1062
|
+
this.responseJson = void 0;
|
|
1063
|
+
this.name = 'CartoAPIError';
|
|
1064
|
+
this.response = response;
|
|
1065
|
+
this.responseJson = responseJson;
|
|
1066
|
+
this.error = error;
|
|
1067
|
+
this.errorContext = errorContext;
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
/**
|
|
1071
|
+
* Converts camelCase to Camel Case
|
|
1072
|
+
*/
|
|
1073
|
+
function formatErrorKey(key) {
|
|
1074
|
+
return key.replace(/([A-Z])/g, ' $1').replace(/^./, s => s.toUpperCase());
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
/******************************************************************************
|
|
1078
|
+
* VERSIONS
|
|
1079
|
+
*/
|
|
1080
|
+
/** @internal */
|
|
1081
|
+
const V3_MINOR_VERSION = '3.4';
|
|
1082
|
+
/**
|
|
1083
|
+
* @internalRemarks Source: @deck.gl/carto
|
|
1084
|
+
* @internal
|
|
1085
|
+
*/
|
|
1086
|
+
const DEFAULT_AGGREGATION_RES_LEVEL_H3 = 4;
|
|
1087
|
+
/**
|
|
1088
|
+
* @internalRemarks Source: @deck.gl/carto
|
|
1089
|
+
* @internal
|
|
1090
|
+
*/
|
|
1091
|
+
const DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN = 6;
|
|
1092
|
+
|
|
1093
|
+
// deck.gl
|
|
1094
|
+
const requestWithParameters = function (_ref) {
|
|
1095
|
+
let {
|
|
1096
|
+
baseUrl,
|
|
1097
|
+
parameters = {},
|
|
1098
|
+
headers: customHeaders = {},
|
|
1099
|
+
errorContext,
|
|
1100
|
+
maxLengthURL = DEFAULT_MAX_LENGTH_URL
|
|
1101
|
+
} = _ref;
|
|
1102
|
+
try {
|
|
1103
|
+
// Parameters added to all requests issued with `requestWithParameters()`.
|
|
1104
|
+
// These parameters override parameters already in the base URL, but not
|
|
1105
|
+
// user-provided parameters.
|
|
1106
|
+
parameters = {
|
|
1107
|
+
v: V3_MINOR_VERSION,
|
|
1108
|
+
clientId: DEFAULT_CLIENT,
|
|
1109
|
+
...(typeof deck !== 'undefined' && deck.VERSION && {
|
|
1110
|
+
deckglVersion: deck.VERSION
|
|
1111
|
+
}),
|
|
1112
|
+
...parameters
|
|
1113
|
+
};
|
|
1114
|
+
baseUrl = excludeURLParameters(baseUrl, Object.keys(parameters));
|
|
1115
|
+
const key = createCacheKey(baseUrl, parameters, customHeaders);
|
|
1116
|
+
if (REQUEST_CACHE.has(key)) {
|
|
1117
|
+
return Promise.resolve(REQUEST_CACHE.get(key));
|
|
1118
|
+
}
|
|
1119
|
+
const url = createURLWithParameters(baseUrl, parameters);
|
|
1120
|
+
const headers = {
|
|
1121
|
+
...DEFAULT_HEADERS,
|
|
1122
|
+
...customHeaders
|
|
1123
|
+
};
|
|
1124
|
+
/* global fetch */
|
|
1125
|
+
const fetchPromise = url.length > maxLengthURL ? fetch(baseUrl, {
|
|
1126
|
+
method: 'POST',
|
|
1127
|
+
body: JSON.stringify(parameters),
|
|
1128
|
+
headers
|
|
1129
|
+
}) : fetch(url, {
|
|
1130
|
+
headers
|
|
1131
|
+
});
|
|
1132
|
+
let response;
|
|
1133
|
+
let responseJson;
|
|
1134
|
+
const jsonPromise = fetchPromise.then(_response => {
|
|
1135
|
+
response = _response;
|
|
1136
|
+
return response.json();
|
|
1137
|
+
}).then(json => {
|
|
1138
|
+
responseJson = json;
|
|
1139
|
+
if (!response || !response.ok) {
|
|
1140
|
+
throw new Error(json.error);
|
|
1141
|
+
}
|
|
1142
|
+
return json;
|
|
1143
|
+
}).catch(error => {
|
|
1144
|
+
REQUEST_CACHE.delete(key);
|
|
1145
|
+
throw new CartoAPIError(error, errorContext, response, responseJson);
|
|
1146
|
+
});
|
|
1147
|
+
REQUEST_CACHE.set(key, jsonPromise);
|
|
1148
|
+
return Promise.resolve(jsonPromise);
|
|
1149
|
+
} catch (e) {
|
|
1150
|
+
return Promise.reject(e);
|
|
1151
|
+
}
|
|
1152
|
+
};
|
|
1153
|
+
const DEFAULT_HEADERS = {
|
|
1154
|
+
Accept: 'application/json',
|
|
1155
|
+
'Content-Type': 'application/json'
|
|
1156
|
+
};
|
|
1157
|
+
const REQUEST_CACHE = new Map();
|
|
1158
|
+
function createCacheKey(baseUrl, parameters, headers) {
|
|
1159
|
+
const parameterEntries = Object.entries(parameters).sort((_ref2, _ref3) => {
|
|
1160
|
+
let [a] = _ref2;
|
|
1161
|
+
let [b] = _ref3;
|
|
1162
|
+
return a > b ? 1 : -1;
|
|
1163
|
+
});
|
|
1164
|
+
const headerEntries = Object.entries(headers).sort((_ref4, _ref5) => {
|
|
1165
|
+
let [a] = _ref4;
|
|
1166
|
+
let [b] = _ref5;
|
|
1167
|
+
return a > b ? 1 : -1;
|
|
1168
|
+
});
|
|
1169
|
+
return JSON.stringify({
|
|
1170
|
+
baseUrl,
|
|
1171
|
+
parameters: parameterEntries,
|
|
1172
|
+
headers: headerEntries
|
|
1173
|
+
});
|
|
1174
|
+
}
|
|
1175
|
+
/**
|
|
1176
|
+
* Appends query string parameters to a URL. Existing URL parameters are kept,
|
|
1177
|
+
* unless there is a conflict, in which case the new parameters override
|
|
1178
|
+
* those already in the URL.
|
|
1179
|
+
*/
|
|
1180
|
+
function createURLWithParameters(baseUrlString, parameters) {
|
|
1181
|
+
const baseUrl = new URL(baseUrlString);
|
|
1182
|
+
for (const [key, value] of Object.entries(parameters)) {
|
|
1183
|
+
if (isPureObject(value) || Array.isArray(value)) {
|
|
1184
|
+
baseUrl.searchParams.set(key, JSON.stringify(value));
|
|
1185
|
+
} else {
|
|
1186
|
+
baseUrl.searchParams.set(key, value.toString());
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
return baseUrl.toString();
|
|
1190
|
+
}
|
|
1191
|
+
/**
|
|
1192
|
+
* Deletes query string parameters from a URL.
|
|
1193
|
+
*/
|
|
1194
|
+
function excludeURLParameters(baseUrlString, parameters) {
|
|
1195
|
+
const baseUrl = new URL(baseUrlString);
|
|
1196
|
+
for (const param of parameters) {
|
|
1197
|
+
if (baseUrl.searchParams.has(param)) {
|
|
1198
|
+
baseUrl.searchParams.delete(param);
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
return baseUrl.toString();
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
// deck.gl
|
|
1205
|
+
const baseSource = function (endpoint, options, urlParameters) {
|
|
1206
|
+
try {
|
|
1207
|
+
const {
|
|
1208
|
+
accessToken,
|
|
1209
|
+
connectionName,
|
|
1210
|
+
cache,
|
|
1211
|
+
...optionalOptions
|
|
1212
|
+
} = options;
|
|
1213
|
+
const mergedOptions = {
|
|
1214
|
+
...SOURCE_DEFAULTS,
|
|
1215
|
+
accessToken,
|
|
1216
|
+
connectionName,
|
|
1217
|
+
endpoint
|
|
1218
|
+
};
|
|
1219
|
+
for (const key in optionalOptions) {
|
|
1220
|
+
if (optionalOptions[key]) {
|
|
1221
|
+
mergedOptions[key] = optionalOptions[key];
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
const baseUrl = buildSourceUrl(mergedOptions);
|
|
1225
|
+
const {
|
|
1226
|
+
clientId,
|
|
1227
|
+
maxLengthURL,
|
|
1228
|
+
format
|
|
1229
|
+
} = mergedOptions;
|
|
1230
|
+
const headers = {
|
|
1231
|
+
Authorization: `Bearer ${options.accessToken}`,
|
|
1232
|
+
...options.headers
|
|
1233
|
+
};
|
|
1234
|
+
const parameters = {
|
|
1235
|
+
client: clientId,
|
|
1236
|
+
...urlParameters
|
|
1237
|
+
};
|
|
1238
|
+
const errorContext = {
|
|
1239
|
+
requestType: 'Map instantiation',
|
|
1240
|
+
connection: options.connectionName,
|
|
1241
|
+
type: endpoint,
|
|
1242
|
+
source: JSON.stringify(parameters, undefined, 2)
|
|
1243
|
+
};
|
|
1244
|
+
return Promise.resolve(requestWithParameters({
|
|
1245
|
+
baseUrl,
|
|
1246
|
+
parameters,
|
|
1247
|
+
headers,
|
|
1248
|
+
errorContext,
|
|
1249
|
+
maxLengthURL
|
|
1250
|
+
})).then(function (mapInstantiation) {
|
|
1251
|
+
let _exit;
|
|
1252
|
+
function _temp2(_result) {
|
|
1253
|
+
return _exit ? _result : Promise.resolve(requestWithParameters({
|
|
1254
|
+
baseUrl: dataUrl,
|
|
1255
|
+
headers,
|
|
1256
|
+
errorContext,
|
|
1257
|
+
maxLengthURL
|
|
1258
|
+
}));
|
|
1259
|
+
}
|
|
1260
|
+
const dataUrl = mapInstantiation[format].url[0];
|
|
1261
|
+
if (cache) {
|
|
1262
|
+
cache.value = parseInt(new URL(dataUrl).searchParams.get('cache') || '', 10);
|
|
1263
|
+
}
|
|
1264
|
+
errorContext.requestType = 'Map data';
|
|
1265
|
+
const _temp = function () {
|
|
1266
|
+
if (format === 'tilejson') {
|
|
1267
|
+
return Promise.resolve(requestWithParameters({
|
|
1268
|
+
baseUrl: dataUrl,
|
|
1269
|
+
headers,
|
|
1270
|
+
errorContext,
|
|
1271
|
+
maxLengthURL
|
|
1272
|
+
})).then(function (json) {
|
|
1273
|
+
if (accessToken) {
|
|
1274
|
+
json.accessToken = accessToken;
|
|
1275
|
+
}
|
|
1276
|
+
_exit = 1;
|
|
1277
|
+
return json;
|
|
1278
|
+
});
|
|
1279
|
+
}
|
|
1280
|
+
}();
|
|
1281
|
+
return _temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp);
|
|
1282
|
+
});
|
|
1283
|
+
} catch (e) {
|
|
1284
|
+
return Promise.reject(e);
|
|
1285
|
+
}
|
|
1286
|
+
};
|
|
1287
|
+
const SOURCE_DEFAULTS = {
|
|
1288
|
+
apiBaseUrl: DEFAULT_API_BASE_URL,
|
|
1289
|
+
clientId: DEFAULT_CLIENT,
|
|
1290
|
+
format: 'tilejson',
|
|
1291
|
+
headers: {},
|
|
1292
|
+
maxLengthURL: DEFAULT_MAX_LENGTH_URL
|
|
1293
|
+
};
|
|
1294
|
+
|
|
1295
|
+
// deck.gl
|
|
1296
|
+
const boundaryQuerySource = function (options) {
|
|
1297
|
+
try {
|
|
1298
|
+
const {
|
|
1299
|
+
columns,
|
|
1300
|
+
filters,
|
|
1301
|
+
tilesetTableName,
|
|
1302
|
+
propertiesSqlQuery,
|
|
1303
|
+
queryParameters
|
|
1304
|
+
} = options;
|
|
1305
|
+
const urlParameters = {
|
|
1306
|
+
tilesetTableName,
|
|
1307
|
+
propertiesSqlQuery
|
|
1308
|
+
};
|
|
1309
|
+
if (columns) {
|
|
1310
|
+
urlParameters.columns = columns.join(',');
|
|
1311
|
+
}
|
|
1312
|
+
if (filters) {
|
|
1313
|
+
urlParameters.filters = filters;
|
|
1314
|
+
}
|
|
1315
|
+
if (queryParameters) {
|
|
1316
|
+
urlParameters.queryParameters = queryParameters;
|
|
1317
|
+
}
|
|
1318
|
+
return Promise.resolve(baseSource('boundary', options, urlParameters));
|
|
1319
|
+
} catch (e) {
|
|
1320
|
+
return Promise.reject(e);
|
|
1321
|
+
}
|
|
1322
|
+
};
|
|
1323
|
+
|
|
1324
|
+
// deck.gl
|
|
1325
|
+
const boundaryTableSource = function (options) {
|
|
1326
|
+
try {
|
|
1327
|
+
const {
|
|
1328
|
+
filters,
|
|
1329
|
+
tilesetTableName,
|
|
1330
|
+
columns,
|
|
1331
|
+
propertiesTableName
|
|
1332
|
+
} = options;
|
|
1333
|
+
const urlParameters = {
|
|
1334
|
+
tilesetTableName,
|
|
1335
|
+
propertiesTableName
|
|
1336
|
+
};
|
|
1337
|
+
if (columns) {
|
|
1338
|
+
urlParameters.columns = columns.join(',');
|
|
1339
|
+
}
|
|
1340
|
+
if (filters) {
|
|
1341
|
+
urlParameters.filters = filters;
|
|
1342
|
+
}
|
|
1343
|
+
return Promise.resolve(baseSource('boundary', options, urlParameters));
|
|
1344
|
+
} catch (e) {
|
|
1345
|
+
return Promise.reject(e);
|
|
1346
|
+
}
|
|
1347
|
+
};
|
|
1348
|
+
|
|
1349
|
+
// deck.gl
|
|
1350
|
+
const h3QuerySource$1 = function (options) {
|
|
1351
|
+
try {
|
|
1352
|
+
const {
|
|
1353
|
+
aggregationExp,
|
|
1354
|
+
aggregationResLevel = DEFAULT_AGGREGATION_RES_LEVEL_H3,
|
|
1355
|
+
sqlQuery,
|
|
1356
|
+
spatialDataColumn = 'h3',
|
|
1357
|
+
queryParameters,
|
|
1358
|
+
filters
|
|
1359
|
+
} = options;
|
|
1360
|
+
const urlParameters = {
|
|
1361
|
+
aggregationExp,
|
|
1362
|
+
spatialDataColumn,
|
|
1363
|
+
spatialDataType: 'h3',
|
|
1364
|
+
q: sqlQuery
|
|
1365
|
+
};
|
|
1366
|
+
if (aggregationResLevel) {
|
|
1367
|
+
urlParameters.aggregationResLevel = String(aggregationResLevel);
|
|
1368
|
+
}
|
|
1369
|
+
if (queryParameters) {
|
|
1370
|
+
urlParameters.queryParameters = queryParameters;
|
|
1371
|
+
}
|
|
1372
|
+
if (filters) {
|
|
1373
|
+
urlParameters.filters = filters;
|
|
1374
|
+
}
|
|
1375
|
+
return Promise.resolve(baseSource('query', options, urlParameters));
|
|
1376
|
+
} catch (e) {
|
|
1377
|
+
return Promise.reject(e);
|
|
1378
|
+
}
|
|
1379
|
+
};
|
|
1380
|
+
|
|
1381
|
+
// deck.gl
|
|
1382
|
+
const h3TableSource$1 = function (options) {
|
|
1383
|
+
try {
|
|
1384
|
+
const {
|
|
1385
|
+
aggregationExp,
|
|
1386
|
+
aggregationResLevel = DEFAULT_AGGREGATION_RES_LEVEL_H3,
|
|
1387
|
+
spatialDataColumn = 'h3',
|
|
1388
|
+
tableName,
|
|
1389
|
+
filters
|
|
1390
|
+
} = options;
|
|
1391
|
+
const urlParameters = {
|
|
1392
|
+
aggregationExp,
|
|
1393
|
+
name: tableName,
|
|
1394
|
+
spatialDataColumn,
|
|
1395
|
+
spatialDataType: 'h3'
|
|
1396
|
+
};
|
|
1397
|
+
if (aggregationResLevel) {
|
|
1398
|
+
urlParameters.aggregationResLevel = String(aggregationResLevel);
|
|
1399
|
+
}
|
|
1400
|
+
if (filters) {
|
|
1401
|
+
urlParameters.filters = filters;
|
|
1402
|
+
}
|
|
1403
|
+
return Promise.resolve(baseSource('table', options, urlParameters));
|
|
1404
|
+
} catch (e) {
|
|
1405
|
+
return Promise.reject(e);
|
|
1406
|
+
}
|
|
1407
|
+
};
|
|
1408
|
+
|
|
1409
|
+
// deck.gl
|
|
1410
|
+
const h3TilesetSource = function (options) {
|
|
1411
|
+
try {
|
|
1412
|
+
const {
|
|
1413
|
+
tableName
|
|
1414
|
+
} = options;
|
|
1415
|
+
const urlParameters = {
|
|
1416
|
+
name: tableName
|
|
1417
|
+
};
|
|
1418
|
+
return Promise.resolve(baseSource('tileset', options, urlParameters));
|
|
1419
|
+
} catch (e) {
|
|
1420
|
+
return Promise.reject(e);
|
|
1421
|
+
}
|
|
1422
|
+
};
|
|
1423
|
+
|
|
1424
|
+
// deck.gl
|
|
1425
|
+
const rasterSource = function (options) {
|
|
1426
|
+
try {
|
|
1427
|
+
const {
|
|
1428
|
+
tableName,
|
|
1429
|
+
filters
|
|
1430
|
+
} = options;
|
|
1431
|
+
const urlParameters = {
|
|
1432
|
+
name: tableName
|
|
1433
|
+
};
|
|
1434
|
+
if (filters) {
|
|
1435
|
+
urlParameters.filters = filters;
|
|
1436
|
+
}
|
|
1437
|
+
return Promise.resolve(baseSource('raster', options, urlParameters));
|
|
1438
|
+
} catch (e) {
|
|
1439
|
+
return Promise.reject(e);
|
|
1440
|
+
}
|
|
1441
|
+
};
|
|
1442
|
+
|
|
1443
|
+
// deck.gl
|
|
1444
|
+
const quadbinQuerySource$1 = function (options) {
|
|
1445
|
+
try {
|
|
1446
|
+
const {
|
|
1447
|
+
aggregationExp,
|
|
1448
|
+
aggregationResLevel = DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN,
|
|
1449
|
+
sqlQuery,
|
|
1450
|
+
spatialDataColumn = 'quadbin',
|
|
1451
|
+
queryParameters,
|
|
1452
|
+
filters
|
|
1453
|
+
} = options;
|
|
1454
|
+
const urlParameters = {
|
|
1455
|
+
aggregationExp,
|
|
1456
|
+
q: sqlQuery,
|
|
1457
|
+
spatialDataColumn,
|
|
1458
|
+
spatialDataType: 'quadbin'
|
|
1459
|
+
};
|
|
1460
|
+
if (aggregationResLevel) {
|
|
1461
|
+
urlParameters.aggregationResLevel = String(aggregationResLevel);
|
|
1462
|
+
}
|
|
1463
|
+
if (queryParameters) {
|
|
1464
|
+
urlParameters.queryParameters = queryParameters;
|
|
1465
|
+
}
|
|
1466
|
+
if (filters) {
|
|
1467
|
+
urlParameters.filters = filters;
|
|
1468
|
+
}
|
|
1469
|
+
return Promise.resolve(baseSource('query', options, urlParameters));
|
|
1470
|
+
} catch (e) {
|
|
1471
|
+
return Promise.reject(e);
|
|
1472
|
+
}
|
|
1473
|
+
};
|
|
1474
|
+
|
|
1475
|
+
// deck.gl
|
|
1476
|
+
const quadbinTableSource$1 = function (options) {
|
|
1477
|
+
try {
|
|
1478
|
+
const {
|
|
1479
|
+
aggregationExp,
|
|
1480
|
+
aggregationResLevel = DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN,
|
|
1481
|
+
spatialDataColumn = 'quadbin',
|
|
1482
|
+
tableName,
|
|
1483
|
+
filters
|
|
1484
|
+
} = options;
|
|
1485
|
+
const urlParameters = {
|
|
1486
|
+
aggregationExp,
|
|
1487
|
+
name: tableName,
|
|
1488
|
+
spatialDataColumn,
|
|
1489
|
+
spatialDataType: 'quadbin'
|
|
1490
|
+
};
|
|
1491
|
+
if (aggregationResLevel) {
|
|
1492
|
+
urlParameters.aggregationResLevel = String(aggregationResLevel);
|
|
1493
|
+
}
|
|
1494
|
+
if (filters) {
|
|
1495
|
+
urlParameters.filters = filters;
|
|
1496
|
+
}
|
|
1497
|
+
return Promise.resolve(baseSource('table', options, urlParameters));
|
|
1498
|
+
} catch (e) {
|
|
1499
|
+
return Promise.reject(e);
|
|
1500
|
+
}
|
|
1501
|
+
};
|
|
1502
|
+
|
|
1503
|
+
// deck.gl
|
|
1504
|
+
const quadbinTilesetSource = function (options) {
|
|
1505
|
+
try {
|
|
1506
|
+
const {
|
|
1507
|
+
tableName
|
|
1508
|
+
} = options;
|
|
1509
|
+
const urlParameters = {
|
|
1510
|
+
name: tableName
|
|
1511
|
+
};
|
|
1512
|
+
return Promise.resolve(baseSource('tileset', options, urlParameters));
|
|
1513
|
+
} catch (e) {
|
|
1514
|
+
return Promise.reject(e);
|
|
1515
|
+
}
|
|
1516
|
+
};
|
|
1517
|
+
|
|
1518
|
+
// deck.gl
|
|
1519
|
+
const vectorQuerySource$1 = function (options) {
|
|
1520
|
+
try {
|
|
1521
|
+
const {
|
|
1522
|
+
columns,
|
|
1523
|
+
filters,
|
|
1524
|
+
spatialDataColumn = 'geom',
|
|
1525
|
+
sqlQuery,
|
|
1526
|
+
tileResolution = DEFAULT_TILE_RESOLUTION,
|
|
1527
|
+
queryParameters
|
|
1528
|
+
} = options;
|
|
1529
|
+
const urlParameters = {
|
|
1530
|
+
spatialDataColumn,
|
|
1531
|
+
spatialDataType: 'geo',
|
|
1532
|
+
tileResolution: tileResolution.toString(),
|
|
1533
|
+
q: sqlQuery
|
|
1534
|
+
};
|
|
1535
|
+
if (columns) {
|
|
1536
|
+
urlParameters.columns = columns.join(',');
|
|
1537
|
+
}
|
|
1538
|
+
if (filters) {
|
|
1539
|
+
urlParameters.filters = filters;
|
|
1540
|
+
}
|
|
1541
|
+
if (queryParameters) {
|
|
1542
|
+
urlParameters.queryParameters = queryParameters;
|
|
1543
|
+
}
|
|
1544
|
+
return Promise.resolve(baseSource('query', options, urlParameters));
|
|
1545
|
+
} catch (e) {
|
|
1546
|
+
return Promise.reject(e);
|
|
1547
|
+
}
|
|
1548
|
+
};
|
|
1549
|
+
|
|
1550
|
+
// deck.gl
|
|
1551
|
+
const vectorTableSource$1 = function (options) {
|
|
1552
|
+
try {
|
|
1553
|
+
const {
|
|
1554
|
+
columns,
|
|
1555
|
+
filters,
|
|
1556
|
+
spatialDataColumn = 'geom',
|
|
1557
|
+
tableName,
|
|
1558
|
+
tileResolution = DEFAULT_TILE_RESOLUTION
|
|
1559
|
+
} = options;
|
|
1560
|
+
const urlParameters = {
|
|
1561
|
+
name: tableName,
|
|
1562
|
+
spatialDataColumn,
|
|
1563
|
+
spatialDataType: 'geo',
|
|
1564
|
+
tileResolution: tileResolution.toString()
|
|
1565
|
+
};
|
|
1566
|
+
if (columns) {
|
|
1567
|
+
urlParameters.columns = columns.join(',');
|
|
1568
|
+
}
|
|
1569
|
+
if (filters) {
|
|
1570
|
+
urlParameters.filters = filters;
|
|
1571
|
+
}
|
|
1572
|
+
return Promise.resolve(baseSource('table', options, urlParameters));
|
|
1573
|
+
} catch (e) {
|
|
1574
|
+
return Promise.reject(e);
|
|
1575
|
+
}
|
|
1576
|
+
};
|
|
1577
|
+
|
|
1578
|
+
// deck.gl
|
|
1579
|
+
const vectorTilesetSource = function (options) {
|
|
1580
|
+
try {
|
|
1581
|
+
const {
|
|
1582
|
+
tableName
|
|
1583
|
+
} = options;
|
|
1584
|
+
const urlParameters = {
|
|
1585
|
+
name: tableName
|
|
1586
|
+
};
|
|
1587
|
+
return Promise.resolve(baseSource('tileset', options, urlParameters));
|
|
1588
|
+
} catch (e) {
|
|
1589
|
+
return Promise.reject(e);
|
|
1590
|
+
}
|
|
1591
|
+
};
|
|
1592
|
+
|
|
984
1593
|
/** Wrapper adding Widget API support to [vectorTableSource](https://deck.gl/docs/api-reference/carto/data-sources). */
|
|
985
1594
|
|
|
986
1595
|
/** Wrapper adding Widget API support to [quadbinQuerySource](https://deck.gl/docs/api-reference/carto/data-sources). */
|
|
987
1596
|
const quadbinQuerySource = function (props) {
|
|
988
1597
|
try {
|
|
989
|
-
|
|
990
|
-
return Promise.resolve(carto.quadbinQuerySource(props)).then(function (response) {
|
|
1598
|
+
return Promise.resolve(quadbinQuerySource$1(props)).then(function (response) {
|
|
991
1599
|
return {
|
|
992
1600
|
...response,
|
|
993
1601
|
widgetSource: new WidgetQuerySource(props)
|
|
@@ -1000,8 +1608,7 @@ const quadbinQuerySource = function (props) {
|
|
|
1000
1608
|
/** Wrapper adding Widget API support to [quadbinTableSource](https://deck.gl/docs/api-reference/carto/data-sources). */
|
|
1001
1609
|
const quadbinTableSource = function (props) {
|
|
1002
1610
|
try {
|
|
1003
|
-
|
|
1004
|
-
return Promise.resolve(carto.quadbinTableSource(props)).then(function (response) {
|
|
1611
|
+
return Promise.resolve(quadbinTableSource$1(props)).then(function (response) {
|
|
1005
1612
|
return {
|
|
1006
1613
|
...response,
|
|
1007
1614
|
widgetSource: new WidgetTableSource(props)
|
|
@@ -1014,8 +1621,7 @@ const quadbinTableSource = function (props) {
|
|
|
1014
1621
|
/** Wrapper adding Widget API support to [h3QuerySource](https://deck.gl/docs/api-reference/carto/data-sources). */
|
|
1015
1622
|
const h3QuerySource = function (props) {
|
|
1016
1623
|
try {
|
|
1017
|
-
|
|
1018
|
-
return Promise.resolve(carto.h3QuerySource(props)).then(function (response) {
|
|
1624
|
+
return Promise.resolve(h3QuerySource$1(props)).then(function (response) {
|
|
1019
1625
|
return {
|
|
1020
1626
|
...response,
|
|
1021
1627
|
widgetSource: new WidgetQuerySource(props)
|
|
@@ -1028,8 +1634,7 @@ const h3QuerySource = function (props) {
|
|
|
1028
1634
|
/** Wrapper adding Widget API support to [h3TableSource](https://deck.gl/docs/api-reference/carto/data-sources). */
|
|
1029
1635
|
const h3TableSource = function (props) {
|
|
1030
1636
|
try {
|
|
1031
|
-
|
|
1032
|
-
return Promise.resolve(carto.h3TableSource(props)).then(function (response) {
|
|
1637
|
+
return Promise.resolve(h3TableSource$1(props)).then(function (response) {
|
|
1033
1638
|
return {
|
|
1034
1639
|
...response,
|
|
1035
1640
|
widgetSource: new WidgetTableSource(props)
|
|
@@ -1042,8 +1647,7 @@ const h3TableSource = function (props) {
|
|
|
1042
1647
|
/** Wrapper adding Widget API support to [vectorQuerySource](https://deck.gl/docs/api-reference/carto/data-sources). */
|
|
1043
1648
|
const vectorQuerySource = function (props) {
|
|
1044
1649
|
try {
|
|
1045
|
-
|
|
1046
|
-
return Promise.resolve(carto.vectorQuerySource(props)).then(function (response) {
|
|
1650
|
+
return Promise.resolve(vectorQuerySource$1(props)).then(function (response) {
|
|
1047
1651
|
return {
|
|
1048
1652
|
...response,
|
|
1049
1653
|
widgetSource: new WidgetQuerySource(props)
|
|
@@ -1055,8 +1659,7 @@ const vectorQuerySource = function (props) {
|
|
|
1055
1659
|
};
|
|
1056
1660
|
const vectorTableSource = function (props) {
|
|
1057
1661
|
try {
|
|
1058
|
-
|
|
1059
|
-
return Promise.resolve(carto.vectorTableSource(props)).then(function (response) {
|
|
1662
|
+
return Promise.resolve(vectorTableSource$1(props)).then(function (response) {
|
|
1060
1663
|
return {
|
|
1061
1664
|
...response,
|
|
1062
1665
|
widgetSource: new WidgetTableSource(props)
|
|
@@ -1066,20 +1669,70 @@ const vectorTableSource = function (props) {
|
|
|
1066
1669
|
return Promise.reject(e);
|
|
1067
1670
|
}
|
|
1068
1671
|
};
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1672
|
+
|
|
1673
|
+
// deck.gl
|
|
1674
|
+
const query = function (options) {
|
|
1675
|
+
try {
|
|
1676
|
+
const {
|
|
1677
|
+
apiBaseUrl = SOURCE_DEFAULTS.apiBaseUrl,
|
|
1678
|
+
clientId = SOURCE_DEFAULTS.clientId,
|
|
1679
|
+
maxLengthURL = SOURCE_DEFAULTS.maxLengthURL,
|
|
1680
|
+
connectionName,
|
|
1681
|
+
sqlQuery,
|
|
1682
|
+
queryParameters
|
|
1683
|
+
} = options;
|
|
1684
|
+
const urlParameters = {
|
|
1685
|
+
q: sqlQuery
|
|
1686
|
+
};
|
|
1687
|
+
if (queryParameters) {
|
|
1688
|
+
urlParameters.queryParameters = JSON.stringify(queryParameters);
|
|
1689
|
+
}
|
|
1690
|
+
const baseUrl = buildQueryUrl({
|
|
1691
|
+
apiBaseUrl,
|
|
1692
|
+
connectionName
|
|
1693
|
+
});
|
|
1694
|
+
const headers = {
|
|
1695
|
+
Authorization: `Bearer ${options.accessToken}`,
|
|
1696
|
+
...options.headers
|
|
1697
|
+
};
|
|
1698
|
+
const parameters = {
|
|
1699
|
+
client: clientId,
|
|
1700
|
+
...urlParameters
|
|
1701
|
+
};
|
|
1702
|
+
const errorContext = {
|
|
1703
|
+
requestType: 'SQL',
|
|
1704
|
+
connection: options.connectionName,
|
|
1705
|
+
type: 'query',
|
|
1706
|
+
source: JSON.stringify(parameters, undefined, 2)
|
|
1707
|
+
};
|
|
1708
|
+
return Promise.resolve(requestWithParameters({
|
|
1709
|
+
baseUrl,
|
|
1710
|
+
parameters,
|
|
1711
|
+
headers,
|
|
1712
|
+
errorContext,
|
|
1713
|
+
maxLengthURL
|
|
1714
|
+
}));
|
|
1715
|
+
} catch (e) {
|
|
1716
|
+
return Promise.reject(e);
|
|
1075
1717
|
}
|
|
1076
|
-
}
|
|
1718
|
+
};
|
|
1077
1719
|
|
|
1078
|
-
exports.
|
|
1720
|
+
exports.CartoAPIError = CartoAPIError;
|
|
1721
|
+
exports.DEFAULT_API_BASE_URL = DEFAULT_API_BASE_URL;
|
|
1722
|
+
exports.DEFAULT_CLIENT = DEFAULT_CLIENT;
|
|
1723
|
+
exports.DEFAULT_GEO_COLUMN = DEFAULT_GEO_COLUMN;
|
|
1724
|
+
exports.DEFAULT_MAX_LENGTH_URL = DEFAULT_MAX_LENGTH_URL;
|
|
1725
|
+
exports.DEFAULT_TILE_RESOLUTION = DEFAULT_TILE_RESOLUTION;
|
|
1726
|
+
exports.DEFAULT_TILE_SIZE = DEFAULT_TILE_SIZE;
|
|
1727
|
+
exports.SOURCE_DEFAULTS = SOURCE_DEFAULTS;
|
|
1079
1728
|
exports.WidgetBaseSource = WidgetBaseSource;
|
|
1080
1729
|
exports.WidgetQuerySource = WidgetQuerySource;
|
|
1081
1730
|
exports.WidgetTableSource = WidgetTableSource;
|
|
1082
1731
|
exports.addFilter = addFilter;
|
|
1732
|
+
exports.boundaryQuerySource = boundaryQuerySource;
|
|
1733
|
+
exports.boundaryTableSource = boundaryTableSource;
|
|
1734
|
+
exports.buildPublicMapUrl = buildPublicMapUrl;
|
|
1735
|
+
exports.buildStatsUrl = buildStatsUrl;
|
|
1083
1736
|
exports.clearFilters = clearFilters;
|
|
1084
1737
|
exports.createPolygonSpatialFilter = createPolygonSpatialFilter;
|
|
1085
1738
|
exports.createViewportSpatialFilter = createViewportSpatialFilter;
|
|
@@ -1087,11 +1740,17 @@ exports.getClient = getClient;
|
|
|
1087
1740
|
exports.getFilter = getFilter;
|
|
1088
1741
|
exports.h3QuerySource = h3QuerySource;
|
|
1089
1742
|
exports.h3TableSource = h3TableSource;
|
|
1743
|
+
exports.h3TilesetSource = h3TilesetSource;
|
|
1090
1744
|
exports.hasFilter = hasFilter;
|
|
1091
1745
|
exports.quadbinQuerySource = quadbinQuerySource;
|
|
1092
1746
|
exports.quadbinTableSource = quadbinTableSource;
|
|
1747
|
+
exports.quadbinTilesetSource = quadbinTilesetSource;
|
|
1748
|
+
exports.query = query;
|
|
1749
|
+
exports.rasterSource = rasterSource;
|
|
1093
1750
|
exports.removeFilter = removeFilter;
|
|
1751
|
+
exports.requestWithParameters = requestWithParameters;
|
|
1094
1752
|
exports.setClient = setClient;
|
|
1095
1753
|
exports.vectorQuerySource = vectorQuerySource;
|
|
1096
1754
|
exports.vectorTableSource = vectorTableSource;
|
|
1755
|
+
exports.vectorTilesetSource = vectorTilesetSource;
|
|
1097
1756
|
//# sourceMappingURL=api-client.cjs.map
|