@carto/api-client 0.0.42 → 0.0.43
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 +105 -38
- package/build/api-client.cjs.map +1 -1
- package/build/api-client.modern.js +121 -58
- package/build/api-client.modern.js.map +1 -1
- package/build/filters.d.ts +28 -0
- package/build/index.d.ts +1 -0
- package/build/utils.d.ts +1 -0
- package/package.json +1 -1
- package/src/filters.ts +80 -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,125 @@ 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 in 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
|
+
|
|
190
|
+
function _extends() {
|
|
191
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
192
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
193
|
+
var t = arguments[e];
|
|
194
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
195
|
+
}
|
|
196
|
+
return n;
|
|
197
|
+
}, _extends.apply(null, arguments);
|
|
198
|
+
}
|
|
199
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
200
|
+
if (null == r) return {};
|
|
201
|
+
var t = {};
|
|
202
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
203
|
+
if (e.indexOf(n) >= 0) continue;
|
|
204
|
+
t[n] = r[n];
|
|
205
|
+
}
|
|
206
|
+
return t;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/******************************************************************************
|
|
210
|
+
* DEFAULTS
|
|
211
|
+
*/
|
|
212
|
+
/**
|
|
213
|
+
* @internalRemarks Source: @carto/constants
|
|
214
|
+
* @internal
|
|
215
|
+
*/
|
|
216
|
+
const DEFAULT_API_BASE_URL$1 = 'https://gcp-us-east1.api.carto.com';
|
|
217
|
+
/**
|
|
218
|
+
* @internalRemarks Source: @carto/react-api
|
|
219
|
+
* @internal
|
|
220
|
+
*/
|
|
221
|
+
const DEFAULT_GEO_COLUMN = 'geom';
|
|
222
|
+
/******************************************************************************
|
|
223
|
+
* ENUMS
|
|
224
|
+
*/
|
|
225
|
+
/**
|
|
226
|
+
* @internal
|
|
227
|
+
* @internalRemarks Source: @carto/constants
|
|
228
|
+
*/
|
|
229
|
+
var MapType;
|
|
230
|
+
(function (MapType) {
|
|
231
|
+
MapType["TABLE"] = "table";
|
|
232
|
+
MapType["QUERY"] = "query";
|
|
233
|
+
MapType["TILESET"] = "tileset";
|
|
234
|
+
})(MapType || (MapType = {}));
|
|
235
|
+
/**
|
|
236
|
+
* @internal
|
|
237
|
+
* @internalRemarks Source: @carto/constants
|
|
238
|
+
*/
|
|
239
|
+
var ApiVersion;
|
|
240
|
+
(function (ApiVersion) {
|
|
241
|
+
ApiVersion["V1"] = "v1";
|
|
242
|
+
ApiVersion["V2"] = "v2";
|
|
243
|
+
ApiVersion["V3"] = "v3";
|
|
244
|
+
})(ApiVersion || (ApiVersion = {}));
|
|
182
245
|
|
|
183
246
|
/**
|
|
184
247
|
* Return more descriptive error from API
|
|
@@ -762,7 +825,7 @@ const V3_MINOR_VERSION = '3.4';
|
|
|
762
825
|
const MAX_GET_LENGTH = 8192;
|
|
763
826
|
const DEFAULT_PARAMETERS = {
|
|
764
827
|
v: V3_MINOR_VERSION,
|
|
765
|
-
deckglVersion: "0.0.
|
|
828
|
+
deckglVersion: "0.0.43"
|
|
766
829
|
};
|
|
767
830
|
const DEFAULT_HEADERS = {
|
|
768
831
|
Accept: 'application/json',
|
|
@@ -1223,5 +1286,5 @@ function assignDefaultProps(props) {
|
|
|
1223
1286
|
}
|
|
1224
1287
|
}
|
|
1225
1288
|
|
|
1226
|
-
export { FilterType, GroupDateType, WidgetBaseSource, WidgetQuerySource, WidgetTableSource, getClient, h3QuerySource, h3TableSource, quadbinQuerySource, quadbinTableSource, setClient, vectorQuerySource, vectorTableSource };
|
|
1289
|
+
export { FilterType, GroupDateType, WidgetBaseSource, WidgetQuerySource, WidgetTableSource, addFilter, clearFilters, getClient, h3QuerySource, h3TableSource, quadbinQuerySource, quadbinTableSource, removeFilter, setClient, vectorQuerySource, vectorTableSource };
|
|
1227
1290
|
//# sourceMappingURL=api-client.modern.js.map
|