@carto/api-client 0.4.0-alpha.0 → 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 +9 -1
- package/build/api/endpoints.d.ts +3 -1
- package/build/api/index.d.ts +5 -4
- package/build/api/request-with-parameters.d.ts +1 -1
- package/build/api-client.cjs +256 -59
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.modern.js +207 -53
- package/build/api-client.modern.js.map +1 -1
- package/build/constants-internal.d.ts +9 -28
- package/build/constants.d.ts +24 -10
- package/build/index.d.ts +4 -5
- package/build/models/model.d.ts +2 -2
- package/build/sources/base-source.d.ts +1 -1
- package/build/sources/boundary-query-source.d.ts +1 -1
- package/build/sources/index.d.ts +1 -1
- package/build/sources/types.d.ts +2 -1
- package/build/types-internal.d.ts +46 -1
- package/build/types.d.ts +11 -0
- package/build/widget-sources/widget-base-source.d.ts +1 -1
- package/package.json +1 -1
- package/src/api/carto-api-error.ts +17 -1
- package/src/api/endpoints.ts +3 -1
- package/src/api/index.ts +9 -12
- package/src/api/query.ts +1 -1
- package/src/api/request-with-parameters.ts +3 -7
- package/src/constants-internal.ts +9 -30
- package/src/constants.ts +32 -16
- package/src/index.ts +33 -5
- package/src/models/model.ts +4 -6
- package/src/sources/base-source.ts +2 -1
- package/src/sources/boundary-query-source.ts +1 -1
- package/src/sources/h3-query-source.ts +1 -1
- package/src/sources/h3-table-source.ts +1 -1
- package/src/sources/index.ts +6 -1
- package/src/sources/quadbin-query-source.ts +1 -1
- package/src/sources/quadbin-table-source.ts +1 -1
- package/src/sources/types.ts +2 -6
- package/src/sources/vector-query-source.ts +1 -1
- package/src/sources/vector-table-source.ts +1 -1
- package/src/types-internal.ts +54 -1
- package/src/types.ts +16 -0
- package/src/widget-sources/widget-base-source.ts +5 -5
- package/src/widget-sources/widget-query-source.ts +1 -2
- package/src/widget-sources/widget-table-source.ts +1 -2
- package/src/widget-sources/wrappers.ts +0 -1
- package/build/api/types.d.ts +0 -227
- package/src/api/types.ts +0 -301
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { MapType } from '../types';
|
|
2
|
+
export type APIRequestType = 'Map data' | 'Map instantiation' | 'Public map' | 'Tile stats' | 'SQL' | 'Basemap style';
|
|
3
|
+
export type APIErrorContext = {
|
|
4
|
+
requestType: APIRequestType;
|
|
5
|
+
mapId?: string;
|
|
6
|
+
connection?: string;
|
|
7
|
+
source?: string;
|
|
8
|
+
type?: MapType;
|
|
9
|
+
};
|
|
2
10
|
/**
|
|
3
11
|
*
|
|
4
12
|
* Custom error for reported errors in CARTO Maps API.
|
package/build/api/endpoints.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { MapType } from '
|
|
1
|
+
import { MapType } from '../types.js';
|
|
2
2
|
export type V3Endpoint = 'maps' | 'stats' | 'sql';
|
|
3
|
+
/** @internal Required by fetchMap(). */
|
|
3
4
|
export declare function buildPublicMapUrl({ apiBaseUrl, cartoMapId, }: {
|
|
4
5
|
apiBaseUrl: string;
|
|
5
6
|
cartoMapId: string;
|
|
6
7
|
}): string;
|
|
8
|
+
/** @internal Required by fetchMap(). */
|
|
7
9
|
export declare function buildStatsUrl({ attribute, apiBaseUrl, connectionName, source, type, }: {
|
|
8
10
|
attribute: string;
|
|
9
11
|
apiBaseUrl: string;
|
package/build/api/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { CartoAPIError } from './carto-api-error';
|
|
2
|
-
export
|
|
3
|
-
export { query } from './query';
|
|
4
|
-
export type { QueryOptions } from './query';
|
|
1
|
+
export { CartoAPIError, APIErrorContext, APIRequestType, } from './carto-api-error.js';
|
|
2
|
+
export { buildPublicMapUrl, buildStatsUrl } from './endpoints.js';
|
|
3
|
+
export { query } from './query.js';
|
|
4
|
+
export type { QueryOptions } from './query.js';
|
|
5
|
+
export { requestWithParameters } from './request-with-parameters.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { APIErrorContext } from './carto-api-error';
|
|
2
2
|
export declare function requestWithParameters<T = any>({ baseUrl, parameters, headers: customHeaders, errorContext, maxLengthURL, }: {
|
|
3
3
|
baseUrl: string;
|
|
4
4
|
parameters?: Record<string, unknown>;
|
package/build/api-client.cjs
CHANGED
|
@@ -34,17 +34,6 @@ function setClient(c) {
|
|
|
34
34
|
client = c;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
/** Current version of @carto/api-client. */
|
|
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;
|
|
48
37
|
/**
|
|
49
38
|
* Defines a comparator used when matching a column's values against given filter values.
|
|
50
39
|
*
|
|
@@ -69,6 +58,31 @@ exports.FilterType = void 0;
|
|
|
69
58
|
FilterType["TIME"] = "time";
|
|
70
59
|
FilterType["STRING_SEARCH"] = "stringSearch";
|
|
71
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;
|
|
72
86
|
|
|
73
87
|
const FILTER_TYPES = new Set(Object.values(exports.FilterType));
|
|
74
88
|
const isFilterType = type => FILTER_TYPES.has(type);
|
|
@@ -357,43 +371,6 @@ function _isMultiPolygon(geometry) {
|
|
|
357
371
|
return invariant.getType(geometry) === 'MultiPolygon';
|
|
358
372
|
}
|
|
359
373
|
|
|
360
|
-
/******************************************************************************
|
|
361
|
-
* DEFAULTS
|
|
362
|
-
*/
|
|
363
|
-
/**
|
|
364
|
-
* @internalRemarks Source: @carto/constants
|
|
365
|
-
* @internal
|
|
366
|
-
*/
|
|
367
|
-
const DEFAULT_API_BASE_URL = 'https://gcp-us-east1.api.carto.com';
|
|
368
|
-
/**
|
|
369
|
-
* @internalRemarks Source: @carto/react-api
|
|
370
|
-
* @internal
|
|
371
|
-
*/
|
|
372
|
-
const DEFAULT_GEO_COLUMN = 'geom';
|
|
373
|
-
/******************************************************************************
|
|
374
|
-
* ENUMS
|
|
375
|
-
*/
|
|
376
|
-
/**
|
|
377
|
-
* @internal
|
|
378
|
-
* @internalRemarks Source: @carto/constants
|
|
379
|
-
*/
|
|
380
|
-
var MapType;
|
|
381
|
-
(function (MapType) {
|
|
382
|
-
MapType["TABLE"] = "table";
|
|
383
|
-
MapType["QUERY"] = "query";
|
|
384
|
-
MapType["TILESET"] = "tileset";
|
|
385
|
-
})(MapType || (MapType = {}));
|
|
386
|
-
/**
|
|
387
|
-
* @internal
|
|
388
|
-
* @internalRemarks Source: @carto/constants
|
|
389
|
-
*/
|
|
390
|
-
var ApiVersion;
|
|
391
|
-
(function (ApiVersion) {
|
|
392
|
-
ApiVersion["V1"] = "v1";
|
|
393
|
-
ApiVersion["V2"] = "v2";
|
|
394
|
-
ApiVersion["V3"] = "v3";
|
|
395
|
-
})(ApiVersion || (ApiVersion = {}));
|
|
396
|
-
|
|
397
374
|
/**
|
|
398
375
|
* Return more descriptive error from API
|
|
399
376
|
* @internalRemarks Source: @carto/react-api
|
|
@@ -488,7 +465,7 @@ function dealWithApiError(_ref) {
|
|
|
488
465
|
const AVAILABLE_MODELS = ['category', 'histogram', 'formula', 'timeseries', 'range', 'scatterplot', 'table'];
|
|
489
466
|
const {
|
|
490
467
|
V3
|
|
491
|
-
} = ApiVersion;
|
|
468
|
+
} = exports.ApiVersion;
|
|
492
469
|
const REQUEST_GET_MAX_URL_LENGTH = 2048;
|
|
493
470
|
/**
|
|
494
471
|
* Execute a SQL model request.
|
|
@@ -516,7 +493,7 @@ function executeModel(props) {
|
|
|
516
493
|
assert(apiBaseUrl, 'executeModel: missing apiBaseUrl');
|
|
517
494
|
assert(accessToken, 'executeModel: missing accessToken');
|
|
518
495
|
assert(apiVersion === V3, 'executeModel: SQL Model API requires CARTO 3+');
|
|
519
|
-
assert(type !==
|
|
496
|
+
assert(type !== 'tileset', 'executeModel: Tilesets not supported');
|
|
520
497
|
let url = `${apiBaseUrl}/v3/sql/${connectionName}/model/${model}`;
|
|
521
498
|
const {
|
|
522
499
|
filters,
|
|
@@ -920,7 +897,7 @@ class WidgetBaseSource {
|
|
|
920
897
|
}
|
|
921
898
|
}
|
|
922
899
|
WidgetBaseSource.defaultProps = {
|
|
923
|
-
apiVersion: ApiVersion.V3,
|
|
900
|
+
apiVersion: exports.ApiVersion.V3,
|
|
924
901
|
apiBaseUrl: DEFAULT_API_BASE_URL,
|
|
925
902
|
clientId: getClient(),
|
|
926
903
|
filters: {},
|
|
@@ -954,7 +931,7 @@ class WidgetQuerySource extends WidgetBaseSource {
|
|
|
954
931
|
getModelSource(owner) {
|
|
955
932
|
return {
|
|
956
933
|
...super._getModelSource(owner),
|
|
957
|
-
type:
|
|
934
|
+
type: 'query',
|
|
958
935
|
data: this.props.sqlQuery,
|
|
959
936
|
queryParameters: this.props.queryParameters
|
|
960
937
|
};
|
|
@@ -987,7 +964,7 @@ class WidgetTableSource extends WidgetBaseSource {
|
|
|
987
964
|
getModelSource(owner) {
|
|
988
965
|
return {
|
|
989
966
|
...super._getModelSource(owner),
|
|
990
|
-
type:
|
|
967
|
+
type: 'table',
|
|
991
968
|
data: this.props.tableName
|
|
992
969
|
};
|
|
993
970
|
}
|
|
@@ -1002,6 +979,29 @@ function joinPath() {
|
|
|
1002
979
|
function buildV3Path(apiBaseUrl, version, endpoint) {
|
|
1003
980
|
return joinPath(apiBaseUrl, version, endpoint, ...[].slice.call(arguments, 3));
|
|
1004
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
1005
|
function buildSourceUrl(_ref3) {
|
|
1006
1006
|
let {
|
|
1007
1007
|
apiBaseUrl,
|
|
@@ -1010,6 +1010,13 @@ function buildSourceUrl(_ref3) {
|
|
|
1010
1010
|
} = _ref3;
|
|
1011
1011
|
return buildV3Path(apiBaseUrl, 'v3', 'maps', connectionName, endpoint);
|
|
1012
1012
|
}
|
|
1013
|
+
function buildQueryUrl(_ref4) {
|
|
1014
|
+
let {
|
|
1015
|
+
apiBaseUrl,
|
|
1016
|
+
connectionName
|
|
1017
|
+
} = _ref4;
|
|
1018
|
+
return buildV3Path(apiBaseUrl, 'v3', 'sql', connectionName, 'query');
|
|
1019
|
+
}
|
|
1013
1020
|
|
|
1014
1021
|
// deck.gl
|
|
1015
1022
|
// SPDX-License-Identifier: MIT
|
|
@@ -1067,6 +1074,22 @@ function formatErrorKey(key) {
|
|
|
1067
1074
|
return key.replace(/([A-Z])/g, ' $1').replace(/^./, s => s.toUpperCase());
|
|
1068
1075
|
}
|
|
1069
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
|
+
|
|
1070
1093
|
// deck.gl
|
|
1071
1094
|
const requestWithParameters = function (_ref) {
|
|
1072
1095
|
let {
|
|
@@ -1262,13 +1285,67 @@ const baseSource = function (endpoint, options, urlParameters) {
|
|
|
1262
1285
|
}
|
|
1263
1286
|
};
|
|
1264
1287
|
const SOURCE_DEFAULTS = {
|
|
1265
|
-
apiBaseUrl: DEFAULT_API_BASE_URL
|
|
1288
|
+
apiBaseUrl: DEFAULT_API_BASE_URL,
|
|
1266
1289
|
clientId: DEFAULT_CLIENT,
|
|
1267
1290
|
format: 'tilejson',
|
|
1268
1291
|
headers: {},
|
|
1269
1292
|
maxLengthURL: DEFAULT_MAX_LENGTH_URL
|
|
1270
1293
|
};
|
|
1271
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
|
+
|
|
1272
1349
|
// deck.gl
|
|
1273
1350
|
const h3QuerySource$1 = function (options) {
|
|
1274
1351
|
try {
|
|
@@ -1329,6 +1406,40 @@ const h3TableSource$1 = function (options) {
|
|
|
1329
1406
|
}
|
|
1330
1407
|
};
|
|
1331
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
|
+
|
|
1332
1443
|
// deck.gl
|
|
1333
1444
|
const quadbinQuerySource$1 = function (options) {
|
|
1334
1445
|
try {
|
|
@@ -1389,6 +1500,21 @@ const quadbinTableSource$1 = function (options) {
|
|
|
1389
1500
|
}
|
|
1390
1501
|
};
|
|
1391
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
|
+
|
|
1392
1518
|
// deck.gl
|
|
1393
1519
|
const vectorQuerySource$1 = function (options) {
|
|
1394
1520
|
try {
|
|
@@ -1449,6 +1575,21 @@ const vectorTableSource$1 = function (options) {
|
|
|
1449
1575
|
}
|
|
1450
1576
|
};
|
|
1451
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
|
+
|
|
1452
1593
|
/** Wrapper adding Widget API support to [vectorTableSource](https://deck.gl/docs/api-reference/carto/data-sources). */
|
|
1453
1594
|
|
|
1454
1595
|
/** Wrapper adding Widget API support to [quadbinQuerySource](https://deck.gl/docs/api-reference/carto/data-sources). */
|
|
@@ -1529,19 +1670,69 @@ const vectorTableSource = function (props) {
|
|
|
1529
1670
|
}
|
|
1530
1671
|
};
|
|
1531
1672
|
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
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);
|
|
1717
|
+
}
|
|
1718
|
+
};
|
|
1719
|
+
|
|
1720
|
+
exports.CartoAPIError = CartoAPIError;
|
|
1721
|
+
exports.DEFAULT_API_BASE_URL = DEFAULT_API_BASE_URL;
|
|
1536
1722
|
exports.DEFAULT_CLIENT = DEFAULT_CLIENT;
|
|
1723
|
+
exports.DEFAULT_GEO_COLUMN = DEFAULT_GEO_COLUMN;
|
|
1537
1724
|
exports.DEFAULT_MAX_LENGTH_URL = DEFAULT_MAX_LENGTH_URL;
|
|
1538
1725
|
exports.DEFAULT_TILE_RESOLUTION = DEFAULT_TILE_RESOLUTION;
|
|
1539
1726
|
exports.DEFAULT_TILE_SIZE = DEFAULT_TILE_SIZE;
|
|
1540
|
-
exports.
|
|
1727
|
+
exports.SOURCE_DEFAULTS = SOURCE_DEFAULTS;
|
|
1541
1728
|
exports.WidgetBaseSource = WidgetBaseSource;
|
|
1542
1729
|
exports.WidgetQuerySource = WidgetQuerySource;
|
|
1543
1730
|
exports.WidgetTableSource = WidgetTableSource;
|
|
1544
1731
|
exports.addFilter = addFilter;
|
|
1732
|
+
exports.boundaryQuerySource = boundaryQuerySource;
|
|
1733
|
+
exports.boundaryTableSource = boundaryTableSource;
|
|
1734
|
+
exports.buildPublicMapUrl = buildPublicMapUrl;
|
|
1735
|
+
exports.buildStatsUrl = buildStatsUrl;
|
|
1545
1736
|
exports.clearFilters = clearFilters;
|
|
1546
1737
|
exports.createPolygonSpatialFilter = createPolygonSpatialFilter;
|
|
1547
1738
|
exports.createViewportSpatialFilter = createViewportSpatialFilter;
|
|
@@ -1549,11 +1740,17 @@ exports.getClient = getClient;
|
|
|
1549
1740
|
exports.getFilter = getFilter;
|
|
1550
1741
|
exports.h3QuerySource = h3QuerySource;
|
|
1551
1742
|
exports.h3TableSource = h3TableSource;
|
|
1743
|
+
exports.h3TilesetSource = h3TilesetSource;
|
|
1552
1744
|
exports.hasFilter = hasFilter;
|
|
1553
1745
|
exports.quadbinQuerySource = quadbinQuerySource;
|
|
1554
1746
|
exports.quadbinTableSource = quadbinTableSource;
|
|
1747
|
+
exports.quadbinTilesetSource = quadbinTilesetSource;
|
|
1748
|
+
exports.query = query;
|
|
1749
|
+
exports.rasterSource = rasterSource;
|
|
1555
1750
|
exports.removeFilter = removeFilter;
|
|
1751
|
+
exports.requestWithParameters = requestWithParameters;
|
|
1556
1752
|
exports.setClient = setClient;
|
|
1557
1753
|
exports.vectorQuerySource = vectorQuerySource;
|
|
1558
1754
|
exports.vectorTableSource = vectorTableSource;
|
|
1755
|
+
exports.vectorTilesetSource = vectorTilesetSource;
|
|
1559
1756
|
//# sourceMappingURL=api-client.cjs.map
|