@nextgis/geocoder 4.0.0-alpha.5 → 4.0.0-alpha.6

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.
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/geocoder; version: 4.0.0-alpha.5; author: NextGIS */
1
+ /** Bundle of @nextgis/geocoder; version: 4.0.0-alpha.6; author: NextGIS */
2
2
  function defined(val) {
3
3
  return val !== void 0 && val !== null;
4
4
  }
@@ -88,9 +88,6 @@ function objectRemoveEmpty(obj) {
88
88
  function isObject$1(val) {
89
89
  return Object.prototype.toString.call(val) === "[object Object]";
90
90
  }
91
- function isArray(val) {
92
- return Object.prototype.toString.call(val) === "[object Array]";
93
- }
94
91
 
95
92
  function fixUrlStr(url) {
96
93
  return url.replace(/([^:]\/)\/+/g, "$1");
@@ -105,12 +102,12 @@ class BaseGeocoder {
105
102
  }
106
103
 
107
104
  var __defProp$i = Object.defineProperty;
108
- var __defProps$5 = Object.defineProperties;
109
- var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
105
+ var __defProps$4 = Object.defineProperties;
106
+ var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
110
107
  var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
111
108
  var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
112
109
  var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
113
- var __knownSymbol$2 = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
110
+ var __knownSymbol$2 = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
114
111
  var __defNormalProp$i = (obj, key, value) => key in obj ? __defProp$i(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
115
112
  var __spreadValues$8 = (a, b) => {
116
113
  for (var prop in b || (b = {}))
@@ -123,9 +120,9 @@ var __spreadValues$8 = (a, b) => {
123
120
  }
124
121
  return a;
125
122
  };
126
- var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
123
+ var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
127
124
  var __publicField$d = (obj, key, value) => __defNormalProp$i(obj, key + "" , value);
128
- var __async$7 = (__this, __arguments, generator) => {
125
+ var __async$6 = (__this, __arguments, generator) => {
129
126
  return new Promise((resolve, reject) => {
130
127
  var fulfilled = (value) => {
131
128
  try {
@@ -157,7 +154,7 @@ var __asyncGenerator$2 = (__this, __arguments, generator) => {
157
154
  } catch (e) {
158
155
  no(e);
159
156
  }
160
- }, method = (k) => it[k] = (x) => new Promise((yes, no) => resume(k, x, yes, no)), it = {};
157
+ }, method = (k, call, wait, clear) => it[k] = (x) => (call = new Promise((yes, no, run) => (run = () => resume(k, x, yes, no), q ? q.then(run) : run())), clear = () => q === wait && (q = 0), q = wait = call.then(clear, clear), call), q, it = {};
161
158
  return generator = generator.apply(__this, __arguments), it[__knownSymbol$2("asyncIterator")] = () => it, method("next"), method("throw"), method("return"), it;
162
159
  };
163
160
  var __forAwait = (obj, it, method) => (it = obj[__knownSymbol$2("asyncIterator")]) ? it.call(obj) : (obj = obj[__knownSymbol$2("iterator")](), it = {}, method = (key, fn) => (fn = obj[key]) && (it[key] = (arg) => new Promise((yes, no, done) => (arg = fn.call(obj, arg), done = arg.done, Promise.resolve(arg.value).then((value) => yes({ value, done }), no)))), method("next"), method("return"), it);
@@ -189,7 +186,7 @@ class Geocoder extends BaseGeocoder {
189
186
  for (var iter = __forAwait(results), more, temp, error; more = !(temp = yield new __await$2(iter.next())).done; more = false) {
190
187
  const r = temp.value;
191
188
  allProvidersFailed = false;
192
- yield __spreadProps$5(__spreadValues$8({}, r), { provider, _id: ID$1++ });
189
+ yield __spreadProps$4(__spreadValues$8({}, r), { provider, _id: ID$1++ });
193
190
  }
194
191
  } catch (temp) {
195
192
  error = [temp];
@@ -232,7 +229,7 @@ class Geocoder extends BaseGeocoder {
232
229
  try {
233
230
  for (var iter = __forAwait(results), more, temp, error; more = !(temp = yield new __await$2(iter.next())).done; more = false) {
234
231
  const r = temp.value;
235
- yield __spreadProps$5(__spreadValues$8({}, r), { provider, _id: ID$1++ });
232
+ yield __spreadProps$4(__spreadValues$8({}, r), { provider, _id: ID$1++ });
236
233
  }
237
234
  } catch (temp) {
238
235
  error = [temp];
@@ -256,7 +253,7 @@ class Geocoder extends BaseGeocoder {
256
253
  * @returns A promise that resolves to the first reverse geocoding result, or undefined if no results are found.
257
254
  */
258
255
  reverseGeocodeFirstResult(coordinates) {
259
- return __async$7(this, null, function* () {
256
+ return __async$6(this, null, function* () {
260
257
  for (const provider of this.providers) {
261
258
  if (typeof provider.reverse === "function") {
262
259
  try {
@@ -333,7 +330,7 @@ var __spreadValues$7 = (a, b) => {
333
330
  }
334
331
  return a;
335
332
  };
336
- var __async$6 = (__this, __arguments, generator) => {
333
+ var __async$5 = (__this, __arguments, generator) => {
337
334
  return new Promise((resolve, reject) => {
338
335
  var fulfilled = (value) => {
339
336
  try {
@@ -354,7 +351,7 @@ var __async$6 = (__this, __arguments, generator) => {
354
351
  });
355
352
  };
356
353
  function apiRequest(opt) {
357
- return __async$6(this, null, function* () {
354
+ return __async$5(this, null, function* () {
358
355
  const { params, name, connector, requestOptions } = opt;
359
356
  const apiItems = yield connector.connect();
360
357
  let apiItem = apiItems && apiItems[name];
@@ -1018,7 +1015,7 @@ function unwrapListeners(arr) {
1018
1015
  }
1019
1016
 
1020
1017
  var pkg = {
1021
- version: "4.0.0-alpha.5"};
1018
+ version: "4.0.0-alpha.6"};
1022
1019
 
1023
1020
  class AbortError extends Error {
1024
1021
  constructor(message = "AbortError") {
@@ -1232,7 +1229,7 @@ var __objRest$2 = (source, exclude) => {
1232
1229
  }
1233
1230
  return target;
1234
1231
  };
1235
- var __async$5 = (__this, __arguments, generator) => {
1232
+ var __async$4 = (__this, __arguments, generator) => {
1236
1233
  return new Promise((resolve, reject) => {
1237
1234
  var fulfilled = (value) => {
1238
1235
  try {
@@ -1257,7 +1254,7 @@ function lunkwillCheckResponse(lwResp) {
1257
1254
  return ct !== void 0 && ct !== null && ct.includes("application/vnd.lunkwill.request-summary+json");
1258
1255
  }
1259
1256
  function responseJson(response) {
1260
- return __async$5(this, null, function* () {
1257
+ return __async$4(this, null, function* () {
1261
1258
  try {
1262
1259
  return response.json();
1263
1260
  } catch (e) {
@@ -1266,7 +1263,7 @@ function responseJson(response) {
1266
1263
  });
1267
1264
  }
1268
1265
  function lunkwillResponseUrl(lwResp) {
1269
- return __async$5(this, null, function* () {
1266
+ return __async$4(this, null, function* () {
1270
1267
  const lwData = yield responseJson(lwResp);
1271
1268
  let delay = lwData.delay_ms;
1272
1269
  const retry = lwData.retry_ms !== void 0 ? lwData.retry_ms : 2e3;
@@ -1310,7 +1307,7 @@ function lunkwillResponseUrl(lwResp) {
1310
1307
  });
1311
1308
  }
1312
1309
  function lunkwillFetch(lwRespUrl) {
1313
- return __async$5(this, null, function* () {
1310
+ return __async$4(this, null, function* () {
1314
1311
  try {
1315
1312
  return yield window.fetch(lwRespUrl, { credentials: "same-origin" });
1316
1313
  } catch (e) {
@@ -1358,7 +1355,7 @@ function generateUrl(path, query) {
1358
1355
  return path + urlParams;
1359
1356
  }
1360
1357
  function request(path, options, cacheEngine) {
1361
- return __async$5(this, null, function* () {
1358
+ return __async$4(this, null, function* () {
1362
1359
  var _b, _c;
1363
1360
  const defaults = {
1364
1361
  method: "GET",
@@ -1402,7 +1399,7 @@ function request(path, options, cacheEngine) {
1402
1399
  opt.headers = headers;
1403
1400
  }
1404
1401
  const url = generateUrl(path, query);
1405
- const makeRequest = () => __async$5(null, null, function* () {
1402
+ const makeRequest = () => __async$4(null, null, function* () {
1406
1403
  let response;
1407
1404
  try {
1408
1405
  response = yield fetch(url, opt);
@@ -1466,8 +1463,8 @@ function request(path, options, cacheEngine) {
1466
1463
  }
1467
1464
 
1468
1465
  var __defProp$7 = Object.defineProperty;
1469
- var __defProps$4 = Object.defineProperties;
1470
- var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
1466
+ var __defProps$3 = Object.defineProperties;
1467
+ var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
1471
1468
  var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
1472
1469
  var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
1473
1470
  var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
@@ -1483,7 +1480,7 @@ var __spreadValues$5 = (a, b) => {
1483
1480
  }
1484
1481
  return a;
1485
1482
  };
1486
- var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
1483
+ var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
1487
1484
  var __objRest$1 = (source, exclude) => {
1488
1485
  var target = {};
1489
1486
  for (var prop in source)
@@ -1496,7 +1493,7 @@ var __objRest$1 = (source, exclude) => {
1496
1493
  }
1497
1494
  return target;
1498
1495
  };
1499
- var __async$4 = (__this, __arguments, generator) => {
1496
+ var __async$3 = (__this, __arguments, generator) => {
1500
1497
  return new Promise((resolve, reject) => {
1501
1498
  var fulfilled = (value) => {
1502
1499
  try {
@@ -1547,7 +1544,7 @@ function routeURL(name, baseUrl, routeData, ...rest) {
1547
1544
  }
1548
1545
  function route(name, connector, ...rest) {
1549
1546
  const result = {
1550
- url: (opt) => __async$4(null, null, function* () {
1547
+ url: (opt) => __async$3(null, null, function* () {
1551
1548
  var _a;
1552
1549
  const routeData = yield connector.connect();
1553
1550
  const template = routeURL(
@@ -1578,7 +1575,7 @@ function route(name, connector, ...rest) {
1578
1575
  const headers = objectRemoveEmpty(__spreadValues$5(__spreadValues$5({}, connector.getAuthorizationHeaders()), optHeaders != null ? optHeaders : {}));
1579
1576
  return request(
1580
1577
  template,
1581
- __spreadProps$4(__spreadValues$5({
1578
+ __spreadProps$3(__spreadValues$5({
1582
1579
  headers
1583
1580
  }, restOpt), {
1584
1581
  method
@@ -1703,8 +1700,8 @@ function removeConnector(connector) {
1703
1700
  }
1704
1701
 
1705
1702
  var __defProp$6 = Object.defineProperty;
1706
- var __defProps$3 = Object.defineProperties;
1707
- var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
1703
+ var __defProps$2 = Object.defineProperties;
1704
+ var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
1708
1705
  var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
1709
1706
  var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
1710
1707
  var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
@@ -1720,7 +1717,7 @@ var __spreadValues$4 = (a, b) => {
1720
1717
  }
1721
1718
  return a;
1722
1719
  };
1723
- var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
1720
+ var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
1724
1721
  var __objRest = (source, exclude) => {
1725
1722
  var target = {};
1726
1723
  for (var prop in source)
@@ -1734,7 +1731,7 @@ var __objRest = (source, exclude) => {
1734
1731
  return target;
1735
1732
  };
1736
1733
  var __publicField$4 = (obj, key, value) => __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
1737
- var __async$3 = (__this, __arguments, generator) => {
1734
+ var __async$2 = (__this, __arguments, generator) => {
1738
1735
  return new Promise((resolve, reject) => {
1739
1736
  var fulfilled = (value) => {
1740
1737
  try {
@@ -1758,7 +1755,7 @@ let ID = 0;
1758
1755
  let REQUEST_ID = 0;
1759
1756
  class NgwConnector {
1760
1757
  constructor(options) {
1761
- this.options = options;
1758
+ __publicField$4(this, "options", options);
1762
1759
  __publicField$4(this, "id", ID++);
1763
1760
  __publicField$4(this, "emitter", new EventEmitter());
1764
1761
  __publicField$4(this, "user");
@@ -1823,7 +1820,7 @@ class NgwConnector {
1823
1820
  * ```
1824
1821
  */
1825
1822
  connect() {
1826
- return __async$3(this, arguments, function* ({
1823
+ return __async$2(this, arguments, function* ({
1827
1824
  signal
1828
1825
  } = {}) {
1829
1826
  const auth = this.options.auth;
@@ -1862,7 +1859,7 @@ class NgwConnector {
1862
1859
  this.emitter.emit("logout");
1863
1860
  }
1864
1861
  getUserInfo(credentials, options) {
1865
- return __async$3(this, null, function* () {
1862
+ return __async$2(this, null, function* () {
1866
1863
  if (this.user && this.user.id) {
1867
1864
  return this.user;
1868
1865
  }
@@ -1922,7 +1919,7 @@ class NgwConnector {
1922
1919
  * @param options - Request options
1923
1920
  */
1924
1921
  makeQuery(_0, _1) {
1925
- return __async$3(this, arguments, function* (url, params, options = {}) {
1922
+ return __async$2(this, arguments, function* (url, params, options = {}) {
1926
1923
  var _b;
1927
1924
  url = (this.options.baseUrl ? this.options.baseUrl : "") + url;
1928
1925
  if (!url) {
@@ -1955,7 +1952,7 @@ class NgwConnector {
1955
1952
  });
1956
1953
  }
1957
1954
  options.signal = internalSignal;
1958
- const createPromise = () => __async$3(this, null, function* () {
1955
+ const createPromise = () => __async$2(this, null, function* () {
1959
1956
  const id = REQUEST_ID++;
1960
1957
  this.activeRequests[id] = internalAbortController;
1961
1958
  try {
@@ -1965,7 +1962,7 @@ class NgwConnector {
1965
1962
  }
1966
1963
  });
1967
1964
  if (method === "GET" && cache !== false) {
1968
- const cacheOptions = cacheProps ? cacheProps : __spreadProps$3(__spreadValues$4({}, objectRemoveEmpty({
1965
+ const cacheOptions = cacheProps ? cacheProps : __spreadProps$2(__spreadValues$4({}, objectRemoveEmpty({
1969
1966
  headers,
1970
1967
  withCredentials,
1971
1968
  responseType,
@@ -2019,7 +2016,7 @@ class NgwConnector {
2019
2016
  });
2020
2017
  }
2021
2018
  _login(credentials, options) {
2022
- return __async$3(this, null, function* () {
2019
+ return __async$2(this, null, function* () {
2023
2020
  try {
2024
2021
  const data = yield this.getUserInfo(credentials, options);
2025
2022
  this.user = data;
@@ -2078,8 +2075,8 @@ function resourceToQuery(resource, prefix = "") {
2078
2075
  }
2079
2076
 
2080
2077
  var __defProp$5 = Object.defineProperty;
2081
- var __defProps$2 = Object.defineProperties;
2082
- var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
2078
+ var __defProps$1 = Object.defineProperties;
2079
+ var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
2083
2080
  var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
2084
2081
  var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
2085
2082
  var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
@@ -2095,9 +2092,9 @@ var __spreadValues$3 = (a, b) => {
2095
2092
  }
2096
2093
  return a;
2097
2094
  };
2098
- var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
2095
+ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
2099
2096
  var __publicField$3 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
2100
- var __async$2 = (__this, __arguments, generator) => {
2097
+ var __async$1 = (__this, __arguments, generator) => {
2101
2098
  return new Promise((resolve, reject) => {
2102
2099
  var fulfilled = (value) => {
2103
2100
  try {
@@ -2215,19 +2212,20 @@ class ResourcesControl {
2215
2212
  } else {
2216
2213
  Object.assign(query, resourceToQuery(resource));
2217
2214
  }
2218
- return this.connector.route("resource.search").get(__spreadProps$2(__spreadValues$3({}, requestOptions), {
2215
+ return this.connector.route("resource.search").get(__spreadProps$1(__spreadValues$3({}, requestOptions), {
2219
2216
  query: __spreadValues$3({
2220
2217
  serialization: "full"
2221
2218
  }, query)
2222
2219
  })).then((resources) => {
2223
- if ((requestOptions == null ? void 0 : requestOptions.cache) && resources) {
2224
- for (const x of resources) {
2220
+ const items2 = Array.isArray(resources) ? resources : resources.items;
2221
+ if (requestOptions == null ? void 0 : requestOptions.cache) {
2222
+ for (const x of items2) {
2225
2223
  this.cache.add("resource.item", Promise.resolve(x), {
2226
2224
  id: x.resource.id
2227
2225
  });
2228
2226
  }
2229
2227
  }
2230
- return resources;
2228
+ return items2;
2231
2229
  });
2232
2230
  }
2233
2231
  return items;
@@ -2269,7 +2267,7 @@ class ResourcesControl {
2269
2267
  });
2270
2268
  }
2271
2269
  _getChildrenOf(_0, _1) {
2272
- return __async$2(this, arguments, function* (parentDef, requestOptions, _items = []) {
2270
+ return __async$1(this, arguments, function* (parentDef, requestOptions, _items = []) {
2273
2271
  let parent = void 0;
2274
2272
  if (typeof parentDef === "string") {
2275
2273
  parent = yield this.getId(parentDef, requestOptions);
@@ -2278,7 +2276,7 @@ class ResourcesControl {
2278
2276
  } else {
2279
2277
  parent = parentDef;
2280
2278
  }
2281
- const items = yield this.connector.route("resource.collection").get(__spreadProps$2(__spreadValues$3({}, requestOptions), {
2279
+ const items = yield this.connector.route("resource.collection").get(__spreadProps$1(__spreadValues$3({}, requestOptions), {
2282
2280
  query: {
2283
2281
  parent
2284
2282
  }
@@ -2306,7 +2304,7 @@ class ResourcesControl {
2306
2304
  });
2307
2305
  }
2308
2306
  _cleanResourceItemCache(id) {
2309
- return __async$2(this, null, function* () {
2307
+ return __async$1(this, null, function* () {
2310
2308
  var _a;
2311
2309
  const all = this.cache.all();
2312
2310
  const toDelete = [];
@@ -2610,7 +2608,7 @@ const operationsAliases = {
2610
2608
  return like(a, b, true);
2611
2609
  }
2612
2610
  };
2613
- function isPropertyFilter(filter) {
2611
+ function isPropertyFilter$1(filter) {
2614
2612
  const pf = filter;
2615
2613
  if (pf.length === 3 && typeof pf[0] === "string" && typeof pf[1] === "string") {
2616
2614
  return true;
@@ -2620,7 +2618,7 @@ function isPropertyFilter(filter) {
2620
2618
  function propertiesFilter(properties, filters) {
2621
2619
  const logic = typeof filters[0] === "string" ? filters[0] : "all";
2622
2620
  const filterFunction = (p) => {
2623
- if (isPropertyFilter(p)) {
2621
+ if (isPropertyFilter$1(p)) {
2624
2622
  const [field, operation, value] = p;
2625
2623
  const operationExec = operationsAliases[operation];
2626
2624
  if (operationExec) {
@@ -2646,8 +2644,6 @@ function propertiesFilter(properties, filters) {
2646
2644
  }
2647
2645
 
2648
2646
  var __defProp$3 = Object.defineProperty;
2649
- var __defProps$1 = Object.defineProperties;
2650
- var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
2651
2647
  var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
2652
2648
  var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
2653
2649
  var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
@@ -2663,27 +2659,6 @@ var __spreadValues$2 = (a, b) => {
2663
2659
  }
2664
2660
  return a;
2665
2661
  };
2666
- var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
2667
- var __async$1 = (__this, __arguments, generator) => {
2668
- return new Promise((resolve, reject) => {
2669
- var fulfilled = (value) => {
2670
- try {
2671
- step(generator.next(value));
2672
- } catch (e) {
2673
- reject(e);
2674
- }
2675
- };
2676
- var rejected = (value) => {
2677
- try {
2678
- step(generator.throw(value));
2679
- } catch (e) {
2680
- reject(e);
2681
- }
2682
- };
2683
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
2684
- step((generator = generator.apply(__this, __arguments)).next());
2685
- });
2686
- };
2687
2662
  const FEATURE_REQUEST_PARAMS = {
2688
2663
  srs: 4326,
2689
2664
  geom_format: "geojson",
@@ -2720,86 +2695,6 @@ function paramListToQuery(paramList) {
2720
2695
  {}
2721
2696
  );
2722
2697
  }
2723
- function createFeatureFieldFilterQueries(opt) {
2724
- return __async$1(this, null, function* () {
2725
- const queries = getQueries(opt);
2726
- const itemsParts = yield Promise.all(queries);
2727
- const ids = [];
2728
- const items = [];
2729
- for (const part of itemsParts) {
2730
- for (const item of part) {
2731
- if (!ids.includes(item.id)) {
2732
- items.push(item);
2733
- ids.push(item.id);
2734
- }
2735
- }
2736
- }
2737
- const offset = opt.offset !== void 0 ? opt.offset : 0;
2738
- const limit = opt.limit !== void 0 ? opt.limit : items.length;
2739
- if (opt.offset || opt.limit) {
2740
- return items.splice(offset, limit);
2741
- }
2742
- return items;
2743
- });
2744
- }
2745
- function createParam(pf) {
2746
- const [field, operation, value] = pf;
2747
- const isFldStr = field !== "id" ? "fld_" : "";
2748
- let vStart = "";
2749
- let vEnd = "";
2750
- const field_ = String(field).trim().replace(/^(%?)(.+?)(%?)$/, (m, a, b, c) => {
2751
- vStart = a;
2752
- vEnd = c;
2753
- return b;
2754
- });
2755
- const v = vStart + value + vEnd;
2756
- return [`${isFldStr}${field_}__${operation}`, v];
2757
- }
2758
- function getQueries(opt, _queries = [], _parentAllParams = []) {
2759
- var _a;
2760
- const { filters } = opt;
2761
- const paramList = (_a = opt.paramList) != null ? _a : [];
2762
- const logic = typeof filters[0] === "string" ? filters[0] : "all";
2763
- const filters_ = filters.filter((x) => Array.isArray(x));
2764
- if (logic === "any") {
2765
- for (const f of filters_) {
2766
- if (isPropertyFilter(f)) {
2767
- _queries.push(
2768
- fetchNgwLayerItemsRequest(__spreadProps$1(__spreadValues$2({}, opt), {
2769
- paramList: [..._parentAllParams, ...paramList, createParam(f)]
2770
- }))
2771
- );
2772
- } else {
2773
- getQueries(__spreadProps$1(__spreadValues$2({}, opt), { filters: f }), _queries, [..._parentAllParams]);
2774
- }
2775
- }
2776
- } else if (logic === "all") {
2777
- const filters2 = [];
2778
- const propertiesFilterList = [];
2779
- for (const f of filters_) {
2780
- if (isPropertyFilter(f)) {
2781
- filters2.push(createParam(f));
2782
- } else {
2783
- propertiesFilterList.push(f);
2784
- }
2785
- }
2786
- if (propertiesFilterList.length) {
2787
- for (const x of propertiesFilterList) {
2788
- getQueries(__spreadProps$1(__spreadValues$2({}, opt), { filters: x }), _queries, [
2789
- ..._parentAllParams,
2790
- ...filters2
2791
- ]);
2792
- }
2793
- } else {
2794
- _queries.push(
2795
- fetchNgwLayerItemsRequest(__spreadProps$1(__spreadValues$2({}, opt), {
2796
- paramList: [..._parentAllParams, ...paramList, ...filters2]
2797
- }))
2798
- );
2799
- }
2800
- }
2801
- return _queries;
2802
- }
2803
2698
  function createWktFromCoordArray(coord) {
2804
2699
  const polygon = coord.map(([lng, lat]) => {
2805
2700
  const [x, y] = degrees2meters(lng, lat).map((c) => round(c));
@@ -2873,6 +2768,147 @@ function prepareNgwFieldsToPropertiesFilter(fields) {
2873
2768
  return fields;
2874
2769
  }
2875
2770
 
2771
+ function isPropertyFilter(value) {
2772
+ return Array.isArray(value) && value.length === 3 && typeof value[0] === "string" && typeof value[1] === "string";
2773
+ }
2774
+ function isPropertiesFilterGroup(value) {
2775
+ return Array.isArray(value) && !isPropertyFilter(value);
2776
+ }
2777
+ function toGetExpr(field) {
2778
+ return field === "id" ? ["fid"] : ["get", field];
2779
+ }
2780
+ function parseWildcardField(field) {
2781
+ const leadingWildcard = field.startsWith("%");
2782
+ const trailingWildcard = field.endsWith("%");
2783
+ return {
2784
+ field: field.slice(
2785
+ leadingWildcard ? 1 : 0,
2786
+ trailingWildcard ? -1 : void 0
2787
+ ),
2788
+ leadingWildcard,
2789
+ trailingWildcard
2790
+ };
2791
+ }
2792
+ function toConditionExpr(filter) {
2793
+ const [fieldRaw, op, value] = filter;
2794
+ const field = String(fieldRaw);
2795
+ const getExpr = toGetExpr(field);
2796
+ switch (op) {
2797
+ case "eq":
2798
+ if (value === null) {
2799
+ return ["is_null", getExpr];
2800
+ }
2801
+ return ["==", getExpr, value];
2802
+ case "ne":
2803
+ if (value === null) {
2804
+ return ["!is_null", getExpr];
2805
+ }
2806
+ return ["!=", getExpr, value];
2807
+ case "gt":
2808
+ if (typeof value !== "number" && typeof value !== "string") {
2809
+ throw new Error(
2810
+ `Operator "gt" requires number or string for "${field}"`
2811
+ );
2812
+ }
2813
+ return [">", getExpr, value];
2814
+ case "lt":
2815
+ if (typeof value !== "number" && typeof value !== "string") {
2816
+ throw new Error(
2817
+ `Operator "lt" requires number or string for "${field}"`
2818
+ );
2819
+ }
2820
+ return ["<", getExpr, value];
2821
+ case "ge":
2822
+ if (typeof value !== "number" && typeof value !== "string") {
2823
+ throw new Error(
2824
+ `Operator "ge" requires number or string for "${field}"`
2825
+ );
2826
+ }
2827
+ return [">=", getExpr, value];
2828
+ case "le":
2829
+ if (typeof value !== "number" && typeof value !== "string") {
2830
+ throw new Error(
2831
+ `Operator "le" requires number or string for "${field}"`
2832
+ );
2833
+ }
2834
+ return ["<=", getExpr, value];
2835
+ case "in":
2836
+ if (!Array.isArray(value) || !value.every((x) => typeof x === "string" || typeof x === "number")) {
2837
+ throw new Error(
2838
+ `Operator "in" requires (string | number)[] for "${field}"`
2839
+ );
2840
+ }
2841
+ if (!value.length) {
2842
+ throw new Error(
2843
+ `Operator "in" requires non-empty array for "${field}"`
2844
+ );
2845
+ }
2846
+ return ["in", getExpr, ...value];
2847
+ case "notin":
2848
+ if (!Array.isArray(value) || !value.every((x) => typeof x === "string" || typeof x === "number")) {
2849
+ throw new Error(
2850
+ `Operator "notin" requires (string | number)[] for "${field}"`
2851
+ );
2852
+ }
2853
+ if (!value.length) {
2854
+ throw new Error(
2855
+ `Operator "notin" requires non-empty array for "${field}"`
2856
+ );
2857
+ }
2858
+ return ["!in", getExpr, ...value];
2859
+ case "ilike": {
2860
+ if (typeof value !== "string") {
2861
+ throw new Error(`Operator "ilike" requires string for "${field}"`);
2862
+ }
2863
+ const parsed = parseWildcardField(field);
2864
+ const pattern = `${parsed.leadingWildcard ? "%" : ""}${value}${parsed.trailingWildcard ? "%" : ""}`;
2865
+ return ["ilike", toGetExpr(parsed.field), pattern];
2866
+ }
2867
+ case "like":
2868
+ throw new Error(
2869
+ `Operator "${op}" is not supported by server FilterExpression`
2870
+ );
2871
+ default: {
2872
+ const exhaustive = op;
2873
+ throw new Error(`Unsupported operator: ${exhaustive}`);
2874
+ }
2875
+ }
2876
+ }
2877
+ function toGroupExpr(filters) {
2878
+ let logicalOp = "all";
2879
+ const children = [];
2880
+ for (const item of filters) {
2881
+ if (item === "all" || item === "any") {
2882
+ logicalOp = item;
2883
+ continue;
2884
+ }
2885
+ if (isPropertyFilter(item)) {
2886
+ children.push(toConditionExpr(item));
2887
+ continue;
2888
+ }
2889
+ if (isPropertiesFilterGroup(item)) {
2890
+ children.push(toGroupExpr(item));
2891
+ continue;
2892
+ }
2893
+ throw new Error("Invalid PropertiesFilter node");
2894
+ }
2895
+ return [logicalOp, ...children];
2896
+ }
2897
+ function propertiesFilterToExpression(filters) {
2898
+ if (!(filters == null ? void 0 : filters.length)) {
2899
+ return [];
2900
+ }
2901
+ return toGroupExpr(filters);
2902
+ }
2903
+ function propertiesFilterToExpressionString(filters) {
2904
+ if (!(filters == null ? void 0 : filters.length)) {
2905
+ return void 0;
2906
+ }
2907
+ return JSON.stringify(
2908
+ propertiesFilterToExpression(filters)
2909
+ );
2910
+ }
2911
+
2876
2912
  var __defProp$2 = Object.defineProperty;
2877
2913
  var __defProps = Object.defineProperties;
2878
2914
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
@@ -2917,10 +2953,12 @@ function fetchNgwLayerItems(options) {
2917
2953
  var _a;
2918
2954
  const filters = options.filters;
2919
2955
  if (filters) {
2920
- let data = yield createFeatureFieldFilterQueries(__spreadProps(__spreadValues$1({}, options), {
2921
- filters
2956
+ let data = yield fetchNgwLayerItemsRequest(__spreadProps(__spreadValues$1({}, options), {
2957
+ query: __spreadProps(__spreadValues$1({}, options.query), {
2958
+ filter: propertiesFilterToExpressionString(filters)
2959
+ })
2922
2960
  }));
2923
- const clientFilterValidate = (_a = options.clientFilterValidate) != null ? _a : isFilterWithAnyCase(filters);
2961
+ const clientFilterValidate = (_a = options.clientFilterValidate) != null ? _a : false;
2924
2962
  if (clientFilterValidate) {
2925
2963
  data = data.filter((y) => {
2926
2964
  const fields = prepareNgwFieldsToPropertiesFilter(__spreadProps(__spreadValues$1({}, y.fields), {
@@ -2936,27 +2974,12 @@ function fetchNgwLayerItems(options) {
2936
2974
  }
2937
2975
  });
2938
2976
  }
2939
- function isFilterWithAnyCase(filters) {
2940
- if (filters[0] === "any") {
2941
- return true;
2942
- }
2943
- for (let i = 1; i < filters.length; i++) {
2944
- const p = filters[i];
2945
- if (isArray(p)) {
2946
- const deep = isFilterWithAnyCase(p);
2947
- if (deep) {
2948
- return true;
2949
- }
2950
- }
2951
- }
2952
- return false;
2953
- }
2954
2977
 
2955
2978
  var __defProp$1 = Object.defineProperty;
2956
2979
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
2957
2980
  var __hasOwnProp = Object.prototype.hasOwnProperty;
2958
2981
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
2959
- var __knownSymbol$1 = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
2982
+ var __knownSymbol$1 = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
2960
2983
  var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2961
2984
  var __spreadValues = (a, b) => {
2962
2985
  for (var prop in b || (b = {}))
@@ -2982,7 +3005,7 @@ var __asyncGenerator$1 = (__this, __arguments, generator) => {
2982
3005
  } catch (e) {
2983
3006
  no(e);
2984
3007
  }
2985
- }, method = (k) => it[k] = (x) => new Promise((yes, no) => resume(k, x, yes, no)), it = {};
3008
+ }, method = (k, call, wait, clear) => it[k] = (x) => (call = new Promise((yes, no, run) => (run = () => resume(k, x, yes, no), q ? q.then(run) : run())), clear = () => q === wait && (q = 0), q = wait = call.then(clear, clear), call), q, it = {};
2986
3009
  return generator = generator.apply(__this, __arguments), it[__knownSymbol$1("asyncIterator")] = () => it, method("next"), method("throw"), method("return"), it;
2987
3010
  };
2988
3011
  const _NgwProvider = class _NgwProvider extends BaseProvider {
@@ -3130,7 +3153,7 @@ __publicField$1(_NgwProvider, "limit", 300);
3130
3153
  let NgwProvider = _NgwProvider;
3131
3154
 
3132
3155
  var __defProp = Object.defineProperty;
3133
- var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
3156
+ var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
3134
3157
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3135
3158
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
3136
3159
  var __await = function(promise, isYieldStar) {
@@ -3145,13 +3168,13 @@ var __asyncGenerator = (__this, __arguments, generator) => {
3145
3168
  } catch (e) {
3146
3169
  no(e);
3147
3170
  }
3148
- }, method = (k) => it[k] = (x) => new Promise((yes, no) => resume(k, x, yes, no)), it = {};
3171
+ }, method = (k, call, wait, clear) => it[k] = (x) => (call = new Promise((yes, no, run) => (run = () => resume(k, x, yes, no), q ? q.then(run) : run())), clear = () => q === wait && (q = 0), q = wait = call.then(clear, clear), call), q, it = {};
3149
3172
  return generator = generator.apply(__this, __arguments), it[__knownSymbol("asyncIterator")] = () => it, method("next"), method("throw"), method("return"), it;
3150
3173
  };
3151
3174
  class NominatimProvider extends BaseProvider {
3152
3175
  constructor(options) {
3153
3176
  super();
3154
- this.options = options;
3177
+ __publicField(this, "options", options);
3155
3178
  __publicField(this, "searchUrl", "https://nominatim.openstreetmap.org");
3156
3179
  __publicField(this, "_abortControllers", []);
3157
3180
  if (options && options.searchUrl) {