@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
|
@@ -62,62 +62,6 @@ var FilterType;
|
|
|
62
62
|
FilterType["STRING_SEARCH"] = "stringSearch";
|
|
63
63
|
})(FilterType || (FilterType = {}));
|
|
64
64
|
|
|
65
|
-
function _extends() {
|
|
66
|
-
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
67
|
-
for (var e = 1; e < arguments.length; e++) {
|
|
68
|
-
var t = arguments[e];
|
|
69
|
-
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
70
|
-
}
|
|
71
|
-
return n;
|
|
72
|
-
}, _extends.apply(null, arguments);
|
|
73
|
-
}
|
|
74
|
-
function _objectWithoutPropertiesLoose(r, e) {
|
|
75
|
-
if (null == r) return {};
|
|
76
|
-
var t = {};
|
|
77
|
-
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
78
|
-
if (e.indexOf(n) >= 0) continue;
|
|
79
|
-
t[n] = r[n];
|
|
80
|
-
}
|
|
81
|
-
return t;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/******************************************************************************
|
|
85
|
-
* DEFAULTS
|
|
86
|
-
*/
|
|
87
|
-
/**
|
|
88
|
-
* @internalRemarks Source: @carto/constants
|
|
89
|
-
* @internal
|
|
90
|
-
*/
|
|
91
|
-
const DEFAULT_API_BASE_URL$1 = 'https://gcp-us-east1.api.carto.com';
|
|
92
|
-
/**
|
|
93
|
-
* @internalRemarks Source: @carto/react-api
|
|
94
|
-
* @internal
|
|
95
|
-
*/
|
|
96
|
-
const DEFAULT_GEO_COLUMN = 'geom';
|
|
97
|
-
/******************************************************************************
|
|
98
|
-
* ENUMS
|
|
99
|
-
*/
|
|
100
|
-
/**
|
|
101
|
-
* @internal
|
|
102
|
-
* @internalRemarks Source: @carto/constants
|
|
103
|
-
*/
|
|
104
|
-
var MapType;
|
|
105
|
-
(function (MapType) {
|
|
106
|
-
MapType["TABLE"] = "table";
|
|
107
|
-
MapType["QUERY"] = "query";
|
|
108
|
-
MapType["TILESET"] = "tileset";
|
|
109
|
-
})(MapType || (MapType = {}));
|
|
110
|
-
/**
|
|
111
|
-
* @internal
|
|
112
|
-
* @internalRemarks Source: @carto/constants
|
|
113
|
-
*/
|
|
114
|
-
var ApiVersion;
|
|
115
|
-
(function (ApiVersion) {
|
|
116
|
-
ApiVersion["V1"] = "v1";
|
|
117
|
-
ApiVersion["V2"] = "v2";
|
|
118
|
-
ApiVersion["V3"] = "v3";
|
|
119
|
-
})(ApiVersion || (ApiVersion = {}));
|
|
120
|
-
|
|
121
65
|
const FILTER_TYPES = new Set(Object.values(FilterType));
|
|
122
66
|
const isFilterType = type => FILTER_TYPES.has(type);
|
|
123
67
|
/**
|
|
@@ -179,6 +123,159 @@ class InvalidColumnError extends Error {
|
|
|
179
123
|
}
|
|
180
124
|
}
|
|
181
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, {
|
|
138
|
+
column,
|
|
139
|
+
type,
|
|
140
|
+
values,
|
|
141
|
+
owner
|
|
142
|
+
}) {
|
|
143
|
+
if (!filters[column]) {
|
|
144
|
+
filters[column] = {};
|
|
145
|
+
}
|
|
146
|
+
const filter = {
|
|
147
|
+
values,
|
|
148
|
+
owner
|
|
149
|
+
};
|
|
150
|
+
filters[column][type] = filter;
|
|
151
|
+
return filters;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Removes one or more {@link Filter filters} from the filter set. If only
|
|
155
|
+
* `column` is specified, then all filters on that column are removed. If both
|
|
156
|
+
* `column` and `owner` are specified, then only filters for that column
|
|
157
|
+
* associated with the owner are removed.
|
|
158
|
+
*/
|
|
159
|
+
function removeFilter(filters, {
|
|
160
|
+
column,
|
|
161
|
+
owner
|
|
162
|
+
}) {
|
|
163
|
+
const filter = filters[column];
|
|
164
|
+
if (!filter) {
|
|
165
|
+
return filters;
|
|
166
|
+
}
|
|
167
|
+
if (owner) {
|
|
168
|
+
for (const type of Object.values(FilterType)) {
|
|
169
|
+
var _filter$type;
|
|
170
|
+
if (owner === ((_filter$type = filter[type]) == null ? void 0 : _filter$type.owner)) {
|
|
171
|
+
delete filter[type];
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (!owner || isEmptyObject(filter)) {
|
|
176
|
+
delete filters[column];
|
|
177
|
+
}
|
|
178
|
+
return filters;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Clears all {@link Filter filters} from the filter set.
|
|
182
|
+
*/
|
|
183
|
+
function clearFilters(filters) {
|
|
184
|
+
for (const column of Object.keys(filters)) {
|
|
185
|
+
delete filters[column];
|
|
186
|
+
}
|
|
187
|
+
return filters;
|
|
188
|
+
}
|
|
189
|
+
function hasFilter(filters, {
|
|
190
|
+
column,
|
|
191
|
+
owner
|
|
192
|
+
}) {
|
|
193
|
+
const filter = filters[column];
|
|
194
|
+
if (!filter) {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
if (!owner) {
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
for (const type of Object.values(FilterType)) {
|
|
201
|
+
var _filter$type2;
|
|
202
|
+
if (owner === ((_filter$type2 = filter[type]) == null ? void 0 : _filter$type2.owner)) {
|
|
203
|
+
return true;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
function getFilter(filters, {
|
|
209
|
+
column,
|
|
210
|
+
type,
|
|
211
|
+
owner
|
|
212
|
+
}) {
|
|
213
|
+
var _filter$type3;
|
|
214
|
+
const filter = filters[column];
|
|
215
|
+
if (!filter) {
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
if (!owner || owner === ((_filter$type3 = filter[type]) == null ? void 0 : _filter$type3.owner)) {
|
|
219
|
+
return filter[type] || null;
|
|
220
|
+
}
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function _extends() {
|
|
225
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
226
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
227
|
+
var t = arguments[e];
|
|
228
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
229
|
+
}
|
|
230
|
+
return n;
|
|
231
|
+
}, _extends.apply(null, arguments);
|
|
232
|
+
}
|
|
233
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
234
|
+
if (null == r) return {};
|
|
235
|
+
var t = {};
|
|
236
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
237
|
+
if (e.indexOf(n) >= 0) continue;
|
|
238
|
+
t[n] = r[n];
|
|
239
|
+
}
|
|
240
|
+
return t;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/******************************************************************************
|
|
244
|
+
* DEFAULTS
|
|
245
|
+
*/
|
|
246
|
+
/**
|
|
247
|
+
* @internalRemarks Source: @carto/constants
|
|
248
|
+
* @internal
|
|
249
|
+
*/
|
|
250
|
+
const DEFAULT_API_BASE_URL$1 = 'https://gcp-us-east1.api.carto.com';
|
|
251
|
+
/**
|
|
252
|
+
* @internalRemarks Source: @carto/react-api
|
|
253
|
+
* @internal
|
|
254
|
+
*/
|
|
255
|
+
const DEFAULT_GEO_COLUMN = 'geom';
|
|
256
|
+
/******************************************************************************
|
|
257
|
+
* ENUMS
|
|
258
|
+
*/
|
|
259
|
+
/**
|
|
260
|
+
* @internal
|
|
261
|
+
* @internalRemarks Source: @carto/constants
|
|
262
|
+
*/
|
|
263
|
+
var MapType;
|
|
264
|
+
(function (MapType) {
|
|
265
|
+
MapType["TABLE"] = "table";
|
|
266
|
+
MapType["QUERY"] = "query";
|
|
267
|
+
MapType["TILESET"] = "tileset";
|
|
268
|
+
})(MapType || (MapType = {}));
|
|
269
|
+
/**
|
|
270
|
+
* @internal
|
|
271
|
+
* @internalRemarks Source: @carto/constants
|
|
272
|
+
*/
|
|
273
|
+
var ApiVersion;
|
|
274
|
+
(function (ApiVersion) {
|
|
275
|
+
ApiVersion["V1"] = "v1";
|
|
276
|
+
ApiVersion["V2"] = "v2";
|
|
277
|
+
ApiVersion["V3"] = "v3";
|
|
278
|
+
})(ApiVersion || (ApiVersion = {}));
|
|
182
279
|
|
|
183
280
|
/**
|
|
184
281
|
* Return more descriptive error from API
|
|
@@ -762,7 +859,7 @@ const V3_MINOR_VERSION = '3.4';
|
|
|
762
859
|
const MAX_GET_LENGTH = 8192;
|
|
763
860
|
const DEFAULT_PARAMETERS = {
|
|
764
861
|
v: V3_MINOR_VERSION,
|
|
765
|
-
deckglVersion: "0.0.
|
|
862
|
+
deckglVersion: "0.0.44"
|
|
766
863
|
};
|
|
767
864
|
const DEFAULT_HEADERS = {
|
|
768
865
|
Accept: 'application/json',
|
|
@@ -1223,5 +1320,5 @@ function assignDefaultProps(props) {
|
|
|
1223
1320
|
}
|
|
1224
1321
|
}
|
|
1225
1322
|
|
|
1226
|
-
export { FilterType, GroupDateType, WidgetBaseSource, WidgetQuerySource, WidgetTableSource, getClient, h3QuerySource, h3TableSource, quadbinQuerySource, quadbinTableSource, setClient, vectorQuerySource, vectorTableSource };
|
|
1323
|
+
export { FilterType, GroupDateType, WidgetBaseSource, WidgetQuerySource, WidgetTableSource, addFilter, clearFilters, getClient, getFilter, h3QuerySource, h3TableSource, hasFilter, quadbinQuerySource, quadbinTableSource, removeFilter, setClient, vectorQuerySource, vectorTableSource };
|
|
1227
1324
|
//# sourceMappingURL=api-client.modern.js.map
|