@carto/api-client 0.0.42 → 0.0.44
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-client.cjs +141 -38
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.modern.js +155 -58
- package/build/api-client.modern.js.map +1 -1
- package/build/filters.d.ts +39 -0
- package/build/index.d.ts +1 -0
- package/build/utils.d.ts +1 -0
- package/package.json +1 -1
- package/src/filters.ts +129 -0
- package/src/index.ts +1 -0
- package/src/utils.ts +7 -0
package/build/api-client.cjs
CHANGED
|
@@ -62,43 +62,6 @@ exports.FilterType = void 0;
|
|
|
62
62
|
FilterType["STRING_SEARCH"] = "stringSearch";
|
|
63
63
|
})(exports.FilterType || (exports.FilterType = {}));
|
|
64
64
|
|
|
65
|
-
/******************************************************************************
|
|
66
|
-
* DEFAULTS
|
|
67
|
-
*/
|
|
68
|
-
/**
|
|
69
|
-
* @internalRemarks Source: @carto/constants
|
|
70
|
-
* @internal
|
|
71
|
-
*/
|
|
72
|
-
const DEFAULT_API_BASE_URL$1 = 'https://gcp-us-east1.api.carto.com';
|
|
73
|
-
/**
|
|
74
|
-
* @internalRemarks Source: @carto/react-api
|
|
75
|
-
* @internal
|
|
76
|
-
*/
|
|
77
|
-
const DEFAULT_GEO_COLUMN = 'geom';
|
|
78
|
-
/******************************************************************************
|
|
79
|
-
* ENUMS
|
|
80
|
-
*/
|
|
81
|
-
/**
|
|
82
|
-
* @internal
|
|
83
|
-
* @internalRemarks Source: @carto/constants
|
|
84
|
-
*/
|
|
85
|
-
var MapType;
|
|
86
|
-
(function (MapType) {
|
|
87
|
-
MapType["TABLE"] = "table";
|
|
88
|
-
MapType["QUERY"] = "query";
|
|
89
|
-
MapType["TILESET"] = "tileset";
|
|
90
|
-
})(MapType || (MapType = {}));
|
|
91
|
-
/**
|
|
92
|
-
* @internal
|
|
93
|
-
* @internalRemarks Source: @carto/constants
|
|
94
|
-
*/
|
|
95
|
-
var ApiVersion;
|
|
96
|
-
(function (ApiVersion) {
|
|
97
|
-
ApiVersion["V1"] = "v1";
|
|
98
|
-
ApiVersion["V2"] = "v2";
|
|
99
|
-
ApiVersion["V3"] = "v3";
|
|
100
|
-
})(ApiVersion || (ApiVersion = {}));
|
|
101
|
-
|
|
102
65
|
const FILTER_TYPES = new Set(Object.values(exports.FilterType));
|
|
103
66
|
const isFilterType = type => FILTER_TYPES.has(type);
|
|
104
67
|
/**
|
|
@@ -160,6 +123,141 @@ class InvalidColumnError extends Error {
|
|
|
160
123
|
}
|
|
161
124
|
}
|
|
162
125
|
InvalidColumnError.NAME = 'InvalidColumnError';
|
|
126
|
+
function isEmptyObject(object) {
|
|
127
|
+
for (const _ in object) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Adds a {@link Filter} to the filter set. Any previous filters with the same
|
|
135
|
+
* `column` and `type` will be replaced.
|
|
136
|
+
*/
|
|
137
|
+
function addFilter(filters, _ref) {
|
|
138
|
+
let {
|
|
139
|
+
column,
|
|
140
|
+
type,
|
|
141
|
+
values,
|
|
142
|
+
owner
|
|
143
|
+
} = _ref;
|
|
144
|
+
if (!filters[column]) {
|
|
145
|
+
filters[column] = {};
|
|
146
|
+
}
|
|
147
|
+
const filter = {
|
|
148
|
+
values,
|
|
149
|
+
owner
|
|
150
|
+
};
|
|
151
|
+
filters[column][type] = filter;
|
|
152
|
+
return filters;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Removes one or more {@link Filter filters} from the filter set. If only
|
|
156
|
+
* `column` is specified, then all filters on that column are removed. If both
|
|
157
|
+
* `column` and `owner` are specified, then only filters for that column
|
|
158
|
+
* associated with the owner are removed.
|
|
159
|
+
*/
|
|
160
|
+
function removeFilter(filters, _ref2) {
|
|
161
|
+
let {
|
|
162
|
+
column,
|
|
163
|
+
owner
|
|
164
|
+
} = _ref2;
|
|
165
|
+
const filter = filters[column];
|
|
166
|
+
if (!filter) {
|
|
167
|
+
return filters;
|
|
168
|
+
}
|
|
169
|
+
if (owner) {
|
|
170
|
+
for (const type of Object.values(exports.FilterType)) {
|
|
171
|
+
if (owner === filter[type]?.owner) {
|
|
172
|
+
delete filter[type];
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (!owner || isEmptyObject(filter)) {
|
|
177
|
+
delete filters[column];
|
|
178
|
+
}
|
|
179
|
+
return filters;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Clears all {@link Filter filters} from the filter set.
|
|
183
|
+
*/
|
|
184
|
+
function clearFilters(filters) {
|
|
185
|
+
for (const column of Object.keys(filters)) {
|
|
186
|
+
delete filters[column];
|
|
187
|
+
}
|
|
188
|
+
return filters;
|
|
189
|
+
}
|
|
190
|
+
function hasFilter(filters, _ref3) {
|
|
191
|
+
let {
|
|
192
|
+
column,
|
|
193
|
+
owner
|
|
194
|
+
} = _ref3;
|
|
195
|
+
const filter = filters[column];
|
|
196
|
+
if (!filter) {
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
if (!owner) {
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
for (const type of Object.values(exports.FilterType)) {
|
|
203
|
+
if (owner === filter[type]?.owner) {
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
function getFilter(filters, _ref4) {
|
|
210
|
+
let {
|
|
211
|
+
column,
|
|
212
|
+
type,
|
|
213
|
+
owner
|
|
214
|
+
} = _ref4;
|
|
215
|
+
const filter = filters[column];
|
|
216
|
+
if (!filter) {
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
if (!owner || owner === filter[type]?.owner) {
|
|
220
|
+
return filter[type] || null;
|
|
221
|
+
}
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/******************************************************************************
|
|
226
|
+
* DEFAULTS
|
|
227
|
+
*/
|
|
228
|
+
/**
|
|
229
|
+
* @internalRemarks Source: @carto/constants
|
|
230
|
+
* @internal
|
|
231
|
+
*/
|
|
232
|
+
const DEFAULT_API_BASE_URL$1 = 'https://gcp-us-east1.api.carto.com';
|
|
233
|
+
/**
|
|
234
|
+
* @internalRemarks Source: @carto/react-api
|
|
235
|
+
* @internal
|
|
236
|
+
*/
|
|
237
|
+
const DEFAULT_GEO_COLUMN = 'geom';
|
|
238
|
+
/******************************************************************************
|
|
239
|
+
* ENUMS
|
|
240
|
+
*/
|
|
241
|
+
/**
|
|
242
|
+
* @internal
|
|
243
|
+
* @internalRemarks Source: @carto/constants
|
|
244
|
+
*/
|
|
245
|
+
var MapType;
|
|
246
|
+
(function (MapType) {
|
|
247
|
+
MapType["TABLE"] = "table";
|
|
248
|
+
MapType["QUERY"] = "query";
|
|
249
|
+
MapType["TILESET"] = "tileset";
|
|
250
|
+
})(MapType || (MapType = {}));
|
|
251
|
+
/**
|
|
252
|
+
* @internal
|
|
253
|
+
* @internalRemarks Source: @carto/constants
|
|
254
|
+
*/
|
|
255
|
+
var ApiVersion;
|
|
256
|
+
(function (ApiVersion) {
|
|
257
|
+
ApiVersion["V1"] = "v1";
|
|
258
|
+
ApiVersion["V2"] = "v2";
|
|
259
|
+
ApiVersion["V3"] = "v3";
|
|
260
|
+
})(ApiVersion || (ApiVersion = {}));
|
|
163
261
|
|
|
164
262
|
/**
|
|
165
263
|
* Return more descriptive error from API
|
|
@@ -817,7 +915,7 @@ const V3_MINOR_VERSION = '3.4';
|
|
|
817
915
|
const MAX_GET_LENGTH = 8192;
|
|
818
916
|
const DEFAULT_PARAMETERS = {
|
|
819
917
|
v: V3_MINOR_VERSION,
|
|
820
|
-
deckglVersion: "0.0.
|
|
918
|
+
deckglVersion: "0.0.44"
|
|
821
919
|
};
|
|
822
920
|
const DEFAULT_HEADERS = {
|
|
823
921
|
Accept: 'application/json',
|
|
@@ -1318,11 +1416,16 @@ function assignDefaultProps(props) {
|
|
|
1318
1416
|
exports.WidgetBaseSource = WidgetBaseSource;
|
|
1319
1417
|
exports.WidgetQuerySource = WidgetQuerySource;
|
|
1320
1418
|
exports.WidgetTableSource = WidgetTableSource;
|
|
1419
|
+
exports.addFilter = addFilter;
|
|
1420
|
+
exports.clearFilters = clearFilters;
|
|
1321
1421
|
exports.getClient = getClient;
|
|
1422
|
+
exports.getFilter = getFilter;
|
|
1322
1423
|
exports.h3QuerySource = h3QuerySource;
|
|
1323
1424
|
exports.h3TableSource = h3TableSource;
|
|
1425
|
+
exports.hasFilter = hasFilter;
|
|
1324
1426
|
exports.quadbinQuerySource = quadbinQuerySource;
|
|
1325
1427
|
exports.quadbinTableSource = quadbinTableSource;
|
|
1428
|
+
exports.removeFilter = removeFilter;
|
|
1326
1429
|
exports.setClient = setClient;
|
|
1327
1430
|
exports.vectorQuerySource = vectorQuerySource;
|
|
1328
1431
|
exports.vectorTableSource = vectorTableSource;
|