@carto/api-client 0.4.0-alpha.0 → 0.4.0-alpha.3
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 +293 -158
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.modern.js +243 -126
- 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/h3-query-source.d.ts +2 -1
- package/build/sources/h3-table-source.d.ts +2 -1
- package/build/sources/index.d.ts +1 -1
- package/build/sources/quadbin-query-source.d.ts +2 -1
- package/build/sources/quadbin-table-source.d.ts +2 -1
- package/build/sources/types.d.ts +2 -1
- package/build/sources/vector-query-source.d.ts +2 -1
- package/build/sources/vector-table-source.d.ts +2 -1
- package/build/types-internal.d.ts +46 -1
- package/build/types.d.ts +11 -0
- package/build/widget-sources/index.d.ts +0 -1
- package/build/widget-sources/widget-base-source.d.ts +1 -1
- package/build/widget-sources/widget-query-source.d.ts +3 -0
- package/build/widget-sources/widget-table-source.d.ts +3 -0
- package/package.json +2 -2
- 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 +4 -8
- package/src/constants-internal.ts +9 -30
- package/src/constants.ts +32 -16
- package/src/index.ts +43 -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 +9 -7
- package/src/sources/h3-table-source.ts +9 -7
- package/src/sources/index.ts +6 -1
- package/src/sources/quadbin-query-source.ts +9 -7
- package/src/sources/quadbin-table-source.ts +9 -7
- package/src/sources/types.ts +2 -6
- package/src/sources/vector-query-source.ts +12 -7
- package/src/sources/vector-table-source.ts +12 -7
- package/src/types-internal.ts +54 -1
- package/src/types.ts +16 -0
- package/src/widget-sources/index.ts +0 -1
- package/src/widget-sources/widget-base-source.ts +5 -5
- package/src/widget-sources/widget-query-source.ts +3 -2
- package/src/widget-sources/widget-table-source.ts +3 -2
- package/build/api/types.d.ts +0 -227
- package/build/widget-sources/wrappers.d.ts +0 -48
- package/src/api/types.ts +0 -301
- package/src/widget-sources/wrappers.ts +0 -121
|
@@ -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,30 +964,12 @@ 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
|
}
|
|
994
971
|
}
|
|
995
972
|
|
|
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
973
|
// deck.gl
|
|
1015
974
|
// SPDX-License-Identifier: MIT
|
|
1016
975
|
// Copyright (c) vis.gl contributors
|
|
@@ -1067,6 +1026,70 @@ function formatErrorKey(key) {
|
|
|
1067
1026
|
return key.replace(/([A-Z])/g, ' $1').replace(/^./, s => s.toUpperCase());
|
|
1068
1027
|
}
|
|
1069
1028
|
|
|
1029
|
+
// deck.gl
|
|
1030
|
+
// SPDX-License-Identifier: MIT
|
|
1031
|
+
// Copyright (c) vis.gl contributors
|
|
1032
|
+
function joinPath() {
|
|
1033
|
+
return [].slice.call(arguments).map(part => part.endsWith('/') ? part.slice(0, -1) : part).join('/');
|
|
1034
|
+
}
|
|
1035
|
+
function buildV3Path(apiBaseUrl, version, endpoint) {
|
|
1036
|
+
return joinPath(apiBaseUrl, version, endpoint, ...[].slice.call(arguments, 3));
|
|
1037
|
+
}
|
|
1038
|
+
/** @internal Required by fetchMap(). */
|
|
1039
|
+
function buildPublicMapUrl(_ref) {
|
|
1040
|
+
let {
|
|
1041
|
+
apiBaseUrl,
|
|
1042
|
+
cartoMapId
|
|
1043
|
+
} = _ref;
|
|
1044
|
+
return buildV3Path(apiBaseUrl, 'v3', 'maps', 'public', cartoMapId);
|
|
1045
|
+
}
|
|
1046
|
+
/** @internal Required by fetchMap(). */
|
|
1047
|
+
function buildStatsUrl(_ref2) {
|
|
1048
|
+
let {
|
|
1049
|
+
attribute,
|
|
1050
|
+
apiBaseUrl,
|
|
1051
|
+
connectionName,
|
|
1052
|
+
source,
|
|
1053
|
+
type
|
|
1054
|
+
} = _ref2;
|
|
1055
|
+
if (type === 'query') {
|
|
1056
|
+
return buildV3Path(apiBaseUrl, 'v3', 'stats', connectionName, attribute);
|
|
1057
|
+
}
|
|
1058
|
+
// type === 'table'
|
|
1059
|
+
return buildV3Path(apiBaseUrl, 'v3', 'stats', connectionName, source, attribute);
|
|
1060
|
+
}
|
|
1061
|
+
function buildSourceUrl(_ref3) {
|
|
1062
|
+
let {
|
|
1063
|
+
apiBaseUrl,
|
|
1064
|
+
connectionName,
|
|
1065
|
+
endpoint
|
|
1066
|
+
} = _ref3;
|
|
1067
|
+
return buildV3Path(apiBaseUrl, 'v3', 'maps', connectionName, endpoint);
|
|
1068
|
+
}
|
|
1069
|
+
function buildQueryUrl(_ref4) {
|
|
1070
|
+
let {
|
|
1071
|
+
apiBaseUrl,
|
|
1072
|
+
connectionName
|
|
1073
|
+
} = _ref4;
|
|
1074
|
+
return buildV3Path(apiBaseUrl, 'v3', 'sql', connectionName, 'query');
|
|
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
|
+
|
|
1070
1093
|
// deck.gl
|
|
1071
1094
|
const requestWithParameters = function (_ref) {
|
|
1072
1095
|
let {
|
|
@@ -1082,7 +1105,7 @@ const requestWithParameters = function (_ref) {
|
|
|
1082
1105
|
// user-provided parameters.
|
|
1083
1106
|
parameters = {
|
|
1084
1107
|
v: V3_MINOR_VERSION,
|
|
1085
|
-
|
|
1108
|
+
client: DEFAULT_CLIENT,
|
|
1086
1109
|
...(typeof deck !== 'undefined' && deck.VERSION && {
|
|
1087
1110
|
deckglVersion: deck.VERSION
|
|
1088
1111
|
}),
|
|
@@ -1262,7 +1285,7 @@ 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: {},
|
|
@@ -1270,7 +1293,61 @@ const SOURCE_DEFAULTS = {
|
|
|
1270
1293
|
};
|
|
1271
1294
|
|
|
1272
1295
|
// deck.gl
|
|
1273
|
-
const
|
|
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 = function (options) {
|
|
1274
1351
|
try {
|
|
1275
1352
|
const {
|
|
1276
1353
|
aggregationExp,
|
|
@@ -1295,14 +1372,17 @@ const h3QuerySource$1 = function (options) {
|
|
|
1295
1372
|
if (filters) {
|
|
1296
1373
|
urlParameters.filters = filters;
|
|
1297
1374
|
}
|
|
1298
|
-
return Promise.resolve(baseSource('query', options, urlParameters)
|
|
1375
|
+
return Promise.resolve(baseSource('query', options, urlParameters).then(result => ({
|
|
1376
|
+
...result,
|
|
1377
|
+
widgetSource: new WidgetQuerySource(options)
|
|
1378
|
+
})));
|
|
1299
1379
|
} catch (e) {
|
|
1300
1380
|
return Promise.reject(e);
|
|
1301
1381
|
}
|
|
1302
1382
|
};
|
|
1303
1383
|
|
|
1304
1384
|
// deck.gl
|
|
1305
|
-
const h3TableSource
|
|
1385
|
+
const h3TableSource = function (options) {
|
|
1306
1386
|
try {
|
|
1307
1387
|
const {
|
|
1308
1388
|
aggregationExp,
|
|
@@ -1323,14 +1403,51 @@ const h3TableSource$1 = function (options) {
|
|
|
1323
1403
|
if (filters) {
|
|
1324
1404
|
urlParameters.filters = filters;
|
|
1325
1405
|
}
|
|
1326
|
-
return Promise.resolve(baseSource('table', options, urlParameters)
|
|
1406
|
+
return Promise.resolve(baseSource('table', options, urlParameters).then(result => ({
|
|
1407
|
+
...result,
|
|
1408
|
+
widgetSource: new WidgetTableSource(options)
|
|
1409
|
+
})));
|
|
1327
1410
|
} catch (e) {
|
|
1328
1411
|
return Promise.reject(e);
|
|
1329
1412
|
}
|
|
1330
1413
|
};
|
|
1331
1414
|
|
|
1332
1415
|
// deck.gl
|
|
1333
|
-
const
|
|
1416
|
+
const h3TilesetSource = function (options) {
|
|
1417
|
+
try {
|
|
1418
|
+
const {
|
|
1419
|
+
tableName
|
|
1420
|
+
} = options;
|
|
1421
|
+
const urlParameters = {
|
|
1422
|
+
name: tableName
|
|
1423
|
+
};
|
|
1424
|
+
return Promise.resolve(baseSource('tileset', options, urlParameters));
|
|
1425
|
+
} catch (e) {
|
|
1426
|
+
return Promise.reject(e);
|
|
1427
|
+
}
|
|
1428
|
+
};
|
|
1429
|
+
|
|
1430
|
+
// deck.gl
|
|
1431
|
+
const rasterSource = function (options) {
|
|
1432
|
+
try {
|
|
1433
|
+
const {
|
|
1434
|
+
tableName,
|
|
1435
|
+
filters
|
|
1436
|
+
} = options;
|
|
1437
|
+
const urlParameters = {
|
|
1438
|
+
name: tableName
|
|
1439
|
+
};
|
|
1440
|
+
if (filters) {
|
|
1441
|
+
urlParameters.filters = filters;
|
|
1442
|
+
}
|
|
1443
|
+
return Promise.resolve(baseSource('raster', options, urlParameters));
|
|
1444
|
+
} catch (e) {
|
|
1445
|
+
return Promise.reject(e);
|
|
1446
|
+
}
|
|
1447
|
+
};
|
|
1448
|
+
|
|
1449
|
+
// deck.gl
|
|
1450
|
+
const quadbinQuerySource = function (options) {
|
|
1334
1451
|
try {
|
|
1335
1452
|
const {
|
|
1336
1453
|
aggregationExp,
|
|
@@ -1355,14 +1472,17 @@ const quadbinQuerySource$1 = function (options) {
|
|
|
1355
1472
|
if (filters) {
|
|
1356
1473
|
urlParameters.filters = filters;
|
|
1357
1474
|
}
|
|
1358
|
-
return Promise.resolve(baseSource('query', options, urlParameters)
|
|
1475
|
+
return Promise.resolve(baseSource('query', options, urlParameters).then(result => ({
|
|
1476
|
+
...result,
|
|
1477
|
+
widgetSource: new WidgetQuerySource(options)
|
|
1478
|
+
})));
|
|
1359
1479
|
} catch (e) {
|
|
1360
1480
|
return Promise.reject(e);
|
|
1361
1481
|
}
|
|
1362
1482
|
};
|
|
1363
1483
|
|
|
1364
1484
|
// deck.gl
|
|
1365
|
-
const quadbinTableSource
|
|
1485
|
+
const quadbinTableSource = function (options) {
|
|
1366
1486
|
try {
|
|
1367
1487
|
const {
|
|
1368
1488
|
aggregationExp,
|
|
@@ -1383,14 +1503,32 @@ const quadbinTableSource$1 = function (options) {
|
|
|
1383
1503
|
if (filters) {
|
|
1384
1504
|
urlParameters.filters = filters;
|
|
1385
1505
|
}
|
|
1386
|
-
return Promise.resolve(baseSource('table', options, urlParameters)
|
|
1506
|
+
return Promise.resolve(baseSource('table', options, urlParameters).then(result => ({
|
|
1507
|
+
...result,
|
|
1508
|
+
widgetSource: new WidgetTableSource(options)
|
|
1509
|
+
})));
|
|
1510
|
+
} catch (e) {
|
|
1511
|
+
return Promise.reject(e);
|
|
1512
|
+
}
|
|
1513
|
+
};
|
|
1514
|
+
|
|
1515
|
+
// deck.gl
|
|
1516
|
+
const quadbinTilesetSource = function (options) {
|
|
1517
|
+
try {
|
|
1518
|
+
const {
|
|
1519
|
+
tableName
|
|
1520
|
+
} = options;
|
|
1521
|
+
const urlParameters = {
|
|
1522
|
+
name: tableName
|
|
1523
|
+
};
|
|
1524
|
+
return Promise.resolve(baseSource('tileset', options, urlParameters));
|
|
1387
1525
|
} catch (e) {
|
|
1388
1526
|
return Promise.reject(e);
|
|
1389
1527
|
}
|
|
1390
1528
|
};
|
|
1391
1529
|
|
|
1392
1530
|
// deck.gl
|
|
1393
|
-
const vectorQuerySource
|
|
1531
|
+
const vectorQuerySource = function (options) {
|
|
1394
1532
|
try {
|
|
1395
1533
|
const {
|
|
1396
1534
|
columns,
|
|
@@ -1415,14 +1553,17 @@ const vectorQuerySource$1 = function (options) {
|
|
|
1415
1553
|
if (queryParameters) {
|
|
1416
1554
|
urlParameters.queryParameters = queryParameters;
|
|
1417
1555
|
}
|
|
1418
|
-
return Promise.resolve(baseSource('query', options, urlParameters)
|
|
1556
|
+
return Promise.resolve(baseSource('query', options, urlParameters).then(result => ({
|
|
1557
|
+
...result,
|
|
1558
|
+
widgetSource: new WidgetQuerySource(options)
|
|
1559
|
+
})));
|
|
1419
1560
|
} catch (e) {
|
|
1420
1561
|
return Promise.reject(e);
|
|
1421
1562
|
}
|
|
1422
1563
|
};
|
|
1423
1564
|
|
|
1424
1565
|
// deck.gl
|
|
1425
|
-
const vectorTableSource
|
|
1566
|
+
const vectorTableSource = function (options) {
|
|
1426
1567
|
try {
|
|
1427
1568
|
const {
|
|
1428
1569
|
columns,
|
|
@@ -1443,105 +1584,93 @@ const vectorTableSource$1 = function (options) {
|
|
|
1443
1584
|
if (filters) {
|
|
1444
1585
|
urlParameters.filters = filters;
|
|
1445
1586
|
}
|
|
1446
|
-
return Promise.resolve(baseSource('table', options, urlParameters)
|
|
1587
|
+
return Promise.resolve(baseSource('table', options, urlParameters).then(result => ({
|
|
1588
|
+
...result,
|
|
1589
|
+
widgetSource: new WidgetTableSource(options)
|
|
1590
|
+
})));
|
|
1447
1591
|
} catch (e) {
|
|
1448
1592
|
return Promise.reject(e);
|
|
1449
1593
|
}
|
|
1450
1594
|
};
|
|
1451
1595
|
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
/** Wrapper adding Widget API support to [quadbinQuerySource](https://deck.gl/docs/api-reference/carto/data-sources). */
|
|
1455
|
-
const quadbinQuerySource = function (props) {
|
|
1456
|
-
try {
|
|
1457
|
-
return Promise.resolve(quadbinQuerySource$1(props)).then(function (response) {
|
|
1458
|
-
return {
|
|
1459
|
-
...response,
|
|
1460
|
-
widgetSource: new WidgetQuerySource(props)
|
|
1461
|
-
};
|
|
1462
|
-
});
|
|
1463
|
-
} catch (e) {
|
|
1464
|
-
return Promise.reject(e);
|
|
1465
|
-
}
|
|
1466
|
-
};
|
|
1467
|
-
/** Wrapper adding Widget API support to [quadbinTableSource](https://deck.gl/docs/api-reference/carto/data-sources). */
|
|
1468
|
-
const quadbinTableSource = function (props) {
|
|
1469
|
-
try {
|
|
1470
|
-
return Promise.resolve(quadbinTableSource$1(props)).then(function (response) {
|
|
1471
|
-
return {
|
|
1472
|
-
...response,
|
|
1473
|
-
widgetSource: new WidgetTableSource(props)
|
|
1474
|
-
};
|
|
1475
|
-
});
|
|
1476
|
-
} catch (e) {
|
|
1477
|
-
return Promise.reject(e);
|
|
1478
|
-
}
|
|
1479
|
-
};
|
|
1480
|
-
/** Wrapper adding Widget API support to [h3QuerySource](https://deck.gl/docs/api-reference/carto/data-sources). */
|
|
1481
|
-
const h3QuerySource = function (props) {
|
|
1482
|
-
try {
|
|
1483
|
-
return Promise.resolve(h3QuerySource$1(props)).then(function (response) {
|
|
1484
|
-
return {
|
|
1485
|
-
...response,
|
|
1486
|
-
widgetSource: new WidgetQuerySource(props)
|
|
1487
|
-
};
|
|
1488
|
-
});
|
|
1489
|
-
} catch (e) {
|
|
1490
|
-
return Promise.reject(e);
|
|
1491
|
-
}
|
|
1492
|
-
};
|
|
1493
|
-
/** Wrapper adding Widget API support to [h3TableSource](https://deck.gl/docs/api-reference/carto/data-sources). */
|
|
1494
|
-
const h3TableSource = function (props) {
|
|
1495
|
-
try {
|
|
1496
|
-
return Promise.resolve(h3TableSource$1(props)).then(function (response) {
|
|
1497
|
-
return {
|
|
1498
|
-
...response,
|
|
1499
|
-
widgetSource: new WidgetTableSource(props)
|
|
1500
|
-
};
|
|
1501
|
-
});
|
|
1502
|
-
} catch (e) {
|
|
1503
|
-
return Promise.reject(e);
|
|
1504
|
-
}
|
|
1505
|
-
};
|
|
1506
|
-
/** Wrapper adding Widget API support to [vectorQuerySource](https://deck.gl/docs/api-reference/carto/data-sources). */
|
|
1507
|
-
const vectorQuerySource = function (props) {
|
|
1596
|
+
// deck.gl
|
|
1597
|
+
const vectorTilesetSource = function (options) {
|
|
1508
1598
|
try {
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
}
|
|
1599
|
+
const {
|
|
1600
|
+
tableName
|
|
1601
|
+
} = options;
|
|
1602
|
+
const urlParameters = {
|
|
1603
|
+
name: tableName
|
|
1604
|
+
};
|
|
1605
|
+
return Promise.resolve(baseSource('tileset', options, urlParameters));
|
|
1515
1606
|
} catch (e) {
|
|
1516
1607
|
return Promise.reject(e);
|
|
1517
1608
|
}
|
|
1518
1609
|
};
|
|
1519
|
-
|
|
1610
|
+
|
|
1611
|
+
// deck.gl
|
|
1612
|
+
const query = function (options) {
|
|
1520
1613
|
try {
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1614
|
+
const {
|
|
1615
|
+
apiBaseUrl = SOURCE_DEFAULTS.apiBaseUrl,
|
|
1616
|
+
clientId = SOURCE_DEFAULTS.clientId,
|
|
1617
|
+
maxLengthURL = SOURCE_DEFAULTS.maxLengthURL,
|
|
1618
|
+
connectionName,
|
|
1619
|
+
sqlQuery,
|
|
1620
|
+
queryParameters
|
|
1621
|
+
} = options;
|
|
1622
|
+
const urlParameters = {
|
|
1623
|
+
q: sqlQuery
|
|
1624
|
+
};
|
|
1625
|
+
if (queryParameters) {
|
|
1626
|
+
urlParameters.queryParameters = JSON.stringify(queryParameters);
|
|
1627
|
+
}
|
|
1628
|
+
const baseUrl = buildQueryUrl({
|
|
1629
|
+
apiBaseUrl,
|
|
1630
|
+
connectionName
|
|
1526
1631
|
});
|
|
1632
|
+
const headers = {
|
|
1633
|
+
Authorization: `Bearer ${options.accessToken}`,
|
|
1634
|
+
...options.headers
|
|
1635
|
+
};
|
|
1636
|
+
const parameters = {
|
|
1637
|
+
client: clientId,
|
|
1638
|
+
...urlParameters
|
|
1639
|
+
};
|
|
1640
|
+
const errorContext = {
|
|
1641
|
+
requestType: 'SQL',
|
|
1642
|
+
connection: options.connectionName,
|
|
1643
|
+
type: 'query',
|
|
1644
|
+
source: JSON.stringify(parameters, undefined, 2)
|
|
1645
|
+
};
|
|
1646
|
+
return Promise.resolve(requestWithParameters({
|
|
1647
|
+
baseUrl,
|
|
1648
|
+
parameters,
|
|
1649
|
+
headers,
|
|
1650
|
+
errorContext,
|
|
1651
|
+
maxLengthURL
|
|
1652
|
+
}));
|
|
1527
1653
|
} catch (e) {
|
|
1528
1654
|
return Promise.reject(e);
|
|
1529
1655
|
}
|
|
1530
1656
|
};
|
|
1531
1657
|
|
|
1532
|
-
exports.
|
|
1533
|
-
exports.
|
|
1534
|
-
exports.DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN = DEFAULT_AGGREGATION_RES_LEVEL_QUADBIN;
|
|
1535
|
-
exports.DEFAULT_API_BASE_URL = DEFAULT_API_BASE_URL$1;
|
|
1658
|
+
exports.CartoAPIError = CartoAPIError;
|
|
1659
|
+
exports.DEFAULT_API_BASE_URL = DEFAULT_API_BASE_URL;
|
|
1536
1660
|
exports.DEFAULT_CLIENT = DEFAULT_CLIENT;
|
|
1661
|
+
exports.DEFAULT_GEO_COLUMN = DEFAULT_GEO_COLUMN;
|
|
1537
1662
|
exports.DEFAULT_MAX_LENGTH_URL = DEFAULT_MAX_LENGTH_URL;
|
|
1538
1663
|
exports.DEFAULT_TILE_RESOLUTION = DEFAULT_TILE_RESOLUTION;
|
|
1539
1664
|
exports.DEFAULT_TILE_SIZE = DEFAULT_TILE_SIZE;
|
|
1540
|
-
exports.
|
|
1665
|
+
exports.SOURCE_DEFAULTS = SOURCE_DEFAULTS;
|
|
1541
1666
|
exports.WidgetBaseSource = WidgetBaseSource;
|
|
1542
1667
|
exports.WidgetQuerySource = WidgetQuerySource;
|
|
1543
1668
|
exports.WidgetTableSource = WidgetTableSource;
|
|
1544
1669
|
exports.addFilter = addFilter;
|
|
1670
|
+
exports.boundaryQuerySource = boundaryQuerySource;
|
|
1671
|
+
exports.boundaryTableSource = boundaryTableSource;
|
|
1672
|
+
exports.buildPublicMapUrl = buildPublicMapUrl;
|
|
1673
|
+
exports.buildStatsUrl = buildStatsUrl;
|
|
1545
1674
|
exports.clearFilters = clearFilters;
|
|
1546
1675
|
exports.createPolygonSpatialFilter = createPolygonSpatialFilter;
|
|
1547
1676
|
exports.createViewportSpatialFilter = createViewportSpatialFilter;
|
|
@@ -1549,11 +1678,17 @@ exports.getClient = getClient;
|
|
|
1549
1678
|
exports.getFilter = getFilter;
|
|
1550
1679
|
exports.h3QuerySource = h3QuerySource;
|
|
1551
1680
|
exports.h3TableSource = h3TableSource;
|
|
1681
|
+
exports.h3TilesetSource = h3TilesetSource;
|
|
1552
1682
|
exports.hasFilter = hasFilter;
|
|
1553
1683
|
exports.quadbinQuerySource = quadbinQuerySource;
|
|
1554
1684
|
exports.quadbinTableSource = quadbinTableSource;
|
|
1685
|
+
exports.quadbinTilesetSource = quadbinTilesetSource;
|
|
1686
|
+
exports.query = query;
|
|
1687
|
+
exports.rasterSource = rasterSource;
|
|
1555
1688
|
exports.removeFilter = removeFilter;
|
|
1689
|
+
exports.requestWithParameters = requestWithParameters;
|
|
1556
1690
|
exports.setClient = setClient;
|
|
1557
1691
|
exports.vectorQuerySource = vectorQuerySource;
|
|
1558
1692
|
exports.vectorTableSource = vectorTableSource;
|
|
1693
|
+
exports.vectorTilesetSource = vectorTilesetSource;
|
|
1559
1694
|
//# sourceMappingURL=api-client.cjs.map
|