@nextgis/geocoder 4.0.0-alpha.4 → 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.4; author: NextGIS */
1
+ /** Bundle of @nextgis/geocoder; version: 4.0.0-alpha.6; author: NextGIS */
2
2
  var Geocoder = (function (exports) {
3
3
  'use strict';
4
4
 
@@ -91,9 +91,6 @@ var Geocoder = (function (exports) {
91
91
  function isObject$1(val) {
92
92
  return Object.prototype.toString.call(val) === "[object Object]";
93
93
  }
94
- function isArray(val) {
95
- return Object.prototype.toString.call(val) === "[object Array]";
96
- }
97
94
 
98
95
  function fixUrlStr(url) {
99
96
  return url.replace(/([^:]\/)\/+/g, "$1");
@@ -108,12 +105,12 @@ var Geocoder = (function (exports) {
108
105
  }
109
106
 
110
107
  var __defProp$i = Object.defineProperty;
111
- var __defProps$5 = Object.defineProperties;
112
- var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
108
+ var __defProps$4 = Object.defineProperties;
109
+ var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
113
110
  var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
114
111
  var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
115
112
  var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
116
- var __knownSymbol$2 = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
113
+ var __knownSymbol$2 = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
117
114
  var __defNormalProp$i = (obj, key, value) => key in obj ? __defProp$i(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
118
115
  var __spreadValues$8 = (a, b) => {
119
116
  for (var prop in b || (b = {}))
@@ -126,9 +123,9 @@ var Geocoder = (function (exports) {
126
123
  }
127
124
  return a;
128
125
  };
129
- var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
126
+ var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
130
127
  var __publicField$d = (obj, key, value) => __defNormalProp$i(obj, key + "" , value);
131
- var __async$7 = (__this, __arguments, generator) => {
128
+ var __async$6 = (__this, __arguments, generator) => {
132
129
  return new Promise((resolve, reject) => {
133
130
  var fulfilled = (value) => {
134
131
  try {
@@ -160,7 +157,7 @@ var Geocoder = (function (exports) {
160
157
  } catch (e) {
161
158
  no(e);
162
159
  }
163
- }, method = (k) => it[k] = (x) => new Promise((yes, no) => resume(k, x, yes, no)), it = {};
160
+ }, 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 = {};
164
161
  return generator = generator.apply(__this, __arguments), it[__knownSymbol$2("asyncIterator")] = () => it, method("next"), method("throw"), method("return"), it;
165
162
  };
166
163
  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);
@@ -192,7 +189,7 @@ var Geocoder = (function (exports) {
192
189
  for (var iter = __forAwait(results), more, temp, error; more = !(temp = yield new __await$2(iter.next())).done; more = false) {
193
190
  const r = temp.value;
194
191
  allProvidersFailed = false;
195
- yield __spreadProps$5(__spreadValues$8({}, r), { provider, _id: ID$1++ });
192
+ yield __spreadProps$4(__spreadValues$8({}, r), { provider, _id: ID$1++ });
196
193
  }
197
194
  } catch (temp) {
198
195
  error = [temp];
@@ -235,7 +232,7 @@ var Geocoder = (function (exports) {
235
232
  try {
236
233
  for (var iter = __forAwait(results), more, temp, error; more = !(temp = yield new __await$2(iter.next())).done; more = false) {
237
234
  const r = temp.value;
238
- yield __spreadProps$5(__spreadValues$8({}, r), { provider, _id: ID$1++ });
235
+ yield __spreadProps$4(__spreadValues$8({}, r), { provider, _id: ID$1++ });
239
236
  }
240
237
  } catch (temp) {
241
238
  error = [temp];
@@ -259,7 +256,7 @@ var Geocoder = (function (exports) {
259
256
  * @returns A promise that resolves to the first reverse geocoding result, or undefined if no results are found.
260
257
  */
261
258
  reverseGeocodeFirstResult(coordinates) {
262
- return __async$7(this, null, function* () {
259
+ return __async$6(this, null, function* () {
263
260
  for (const provider of this.providers) {
264
261
  if (typeof provider.reverse === "function") {
265
262
  try {
@@ -336,7 +333,7 @@ var Geocoder = (function (exports) {
336
333
  }
337
334
  return a;
338
335
  };
339
- var __async$6 = (__this, __arguments, generator) => {
336
+ var __async$5 = (__this, __arguments, generator) => {
340
337
  return new Promise((resolve, reject) => {
341
338
  var fulfilled = (value) => {
342
339
  try {
@@ -357,7 +354,7 @@ var Geocoder = (function (exports) {
357
354
  });
358
355
  };
359
356
  function apiRequest(opt) {
360
- return __async$6(this, null, function* () {
357
+ return __async$5(this, null, function* () {
361
358
  const { params, name, connector, requestOptions } = opt;
362
359
  const apiItems = yield connector.connect();
363
360
  let apiItem = apiItems && apiItems[name];
@@ -1021,7 +1018,7 @@ var Geocoder = (function (exports) {
1021
1018
  }
1022
1019
 
1023
1020
  var pkg = {
1024
- version: "4.0.0-alpha.2"};
1021
+ version: "4.0.0-alpha.6"};
1025
1022
 
1026
1023
  class AbortError extends Error {
1027
1024
  constructor(message = "AbortError") {
@@ -1235,7 +1232,7 @@ var Geocoder = (function (exports) {
1235
1232
  }
1236
1233
  return target;
1237
1234
  };
1238
- var __async$5 = (__this, __arguments, generator) => {
1235
+ var __async$4 = (__this, __arguments, generator) => {
1239
1236
  return new Promise((resolve, reject) => {
1240
1237
  var fulfilled = (value) => {
1241
1238
  try {
@@ -1260,7 +1257,7 @@ var Geocoder = (function (exports) {
1260
1257
  return ct !== void 0 && ct !== null && ct.includes("application/vnd.lunkwill.request-summary+json");
1261
1258
  }
1262
1259
  function responseJson(response) {
1263
- return __async$5(this, null, function* () {
1260
+ return __async$4(this, null, function* () {
1264
1261
  try {
1265
1262
  return response.json();
1266
1263
  } catch (e) {
@@ -1269,7 +1266,7 @@ var Geocoder = (function (exports) {
1269
1266
  });
1270
1267
  }
1271
1268
  function lunkwillResponseUrl(lwResp) {
1272
- return __async$5(this, null, function* () {
1269
+ return __async$4(this, null, function* () {
1273
1270
  const lwData = yield responseJson(lwResp);
1274
1271
  let delay = lwData.delay_ms;
1275
1272
  const retry = lwData.retry_ms !== void 0 ? lwData.retry_ms : 2e3;
@@ -1313,7 +1310,7 @@ var Geocoder = (function (exports) {
1313
1310
  });
1314
1311
  }
1315
1312
  function lunkwillFetch(lwRespUrl) {
1316
- return __async$5(this, null, function* () {
1313
+ return __async$4(this, null, function* () {
1317
1314
  try {
1318
1315
  return yield window.fetch(lwRespUrl, { credentials: "same-origin" });
1319
1316
  } catch (e) {
@@ -1361,7 +1358,7 @@ var Geocoder = (function (exports) {
1361
1358
  return path + urlParams;
1362
1359
  }
1363
1360
  function request(path, options, cacheEngine) {
1364
- return __async$5(this, null, function* () {
1361
+ return __async$4(this, null, function* () {
1365
1362
  var _b, _c;
1366
1363
  const defaults = {
1367
1364
  method: "GET",
@@ -1405,7 +1402,7 @@ var Geocoder = (function (exports) {
1405
1402
  opt.headers = headers;
1406
1403
  }
1407
1404
  const url = generateUrl(path, query);
1408
- const makeRequest = () => __async$5(null, null, function* () {
1405
+ const makeRequest = () => __async$4(null, null, function* () {
1409
1406
  let response;
1410
1407
  try {
1411
1408
  response = yield fetch(url, opt);
@@ -1469,8 +1466,8 @@ var Geocoder = (function (exports) {
1469
1466
  }
1470
1467
 
1471
1468
  var __defProp$7 = Object.defineProperty;
1472
- var __defProps$4 = Object.defineProperties;
1473
- var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
1469
+ var __defProps$3 = Object.defineProperties;
1470
+ var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
1474
1471
  var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
1475
1472
  var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
1476
1473
  var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
@@ -1486,7 +1483,7 @@ var Geocoder = (function (exports) {
1486
1483
  }
1487
1484
  return a;
1488
1485
  };
1489
- var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
1486
+ var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
1490
1487
  var __objRest$1 = (source, exclude) => {
1491
1488
  var target = {};
1492
1489
  for (var prop in source)
@@ -1499,7 +1496,7 @@ var Geocoder = (function (exports) {
1499
1496
  }
1500
1497
  return target;
1501
1498
  };
1502
- var __async$4 = (__this, __arguments, generator) => {
1499
+ var __async$3 = (__this, __arguments, generator) => {
1503
1500
  return new Promise((resolve, reject) => {
1504
1501
  var fulfilled = (value) => {
1505
1502
  try {
@@ -1550,7 +1547,7 @@ var Geocoder = (function (exports) {
1550
1547
  }
1551
1548
  function route(name, connector, ...rest) {
1552
1549
  const result = {
1553
- url: (opt) => __async$4(null, null, function* () {
1550
+ url: (opt) => __async$3(null, null, function* () {
1554
1551
  var _a;
1555
1552
  const routeData = yield connector.connect();
1556
1553
  const template = routeURL(
@@ -1581,7 +1578,7 @@ var Geocoder = (function (exports) {
1581
1578
  const headers = objectRemoveEmpty(__spreadValues$5(__spreadValues$5({}, connector.getAuthorizationHeaders()), optHeaders != null ? optHeaders : {}));
1582
1579
  return request(
1583
1580
  template,
1584
- __spreadProps$4(__spreadValues$5({
1581
+ __spreadProps$3(__spreadValues$5({
1585
1582
  headers
1586
1583
  }, restOpt), {
1587
1584
  method
@@ -1706,8 +1703,8 @@ var Geocoder = (function (exports) {
1706
1703
  }
1707
1704
 
1708
1705
  var __defProp$6 = Object.defineProperty;
1709
- var __defProps$3 = Object.defineProperties;
1710
- var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
1706
+ var __defProps$2 = Object.defineProperties;
1707
+ var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
1711
1708
  var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
1712
1709
  var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
1713
1710
  var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
@@ -1723,7 +1720,7 @@ var Geocoder = (function (exports) {
1723
1720
  }
1724
1721
  return a;
1725
1722
  };
1726
- var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
1723
+ var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
1727
1724
  var __objRest = (source, exclude) => {
1728
1725
  var target = {};
1729
1726
  for (var prop in source)
@@ -1737,7 +1734,7 @@ var Geocoder = (function (exports) {
1737
1734
  return target;
1738
1735
  };
1739
1736
  var __publicField$4 = (obj, key, value) => __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
1740
- var __async$3 = (__this, __arguments, generator) => {
1737
+ var __async$2 = (__this, __arguments, generator) => {
1741
1738
  return new Promise((resolve, reject) => {
1742
1739
  var fulfilled = (value) => {
1743
1740
  try {
@@ -1761,7 +1758,7 @@ var Geocoder = (function (exports) {
1761
1758
  let REQUEST_ID = 0;
1762
1759
  class NgwConnector {
1763
1760
  constructor(options) {
1764
- this.options = options;
1761
+ __publicField$4(this, "options", options);
1765
1762
  __publicField$4(this, "id", ID++);
1766
1763
  __publicField$4(this, "emitter", new EventEmitter());
1767
1764
  __publicField$4(this, "user");
@@ -1826,7 +1823,7 @@ var Geocoder = (function (exports) {
1826
1823
  * ```
1827
1824
  */
1828
1825
  connect() {
1829
- return __async$3(this, arguments, function* ({
1826
+ return __async$2(this, arguments, function* ({
1830
1827
  signal
1831
1828
  } = {}) {
1832
1829
  const auth = this.options.auth;
@@ -1865,7 +1862,7 @@ var Geocoder = (function (exports) {
1865
1862
  this.emitter.emit("logout");
1866
1863
  }
1867
1864
  getUserInfo(credentials, options) {
1868
- return __async$3(this, null, function* () {
1865
+ return __async$2(this, null, function* () {
1869
1866
  if (this.user && this.user.id) {
1870
1867
  return this.user;
1871
1868
  }
@@ -1925,7 +1922,7 @@ var Geocoder = (function (exports) {
1925
1922
  * @param options - Request options
1926
1923
  */
1927
1924
  makeQuery(_0, _1) {
1928
- return __async$3(this, arguments, function* (url, params, options = {}) {
1925
+ return __async$2(this, arguments, function* (url, params, options = {}) {
1929
1926
  var _b;
1930
1927
  url = (this.options.baseUrl ? this.options.baseUrl : "") + url;
1931
1928
  if (!url) {
@@ -1958,7 +1955,7 @@ var Geocoder = (function (exports) {
1958
1955
  });
1959
1956
  }
1960
1957
  options.signal = internalSignal;
1961
- const createPromise = () => __async$3(this, null, function* () {
1958
+ const createPromise = () => __async$2(this, null, function* () {
1962
1959
  const id = REQUEST_ID++;
1963
1960
  this.activeRequests[id] = internalAbortController;
1964
1961
  try {
@@ -1968,7 +1965,7 @@ var Geocoder = (function (exports) {
1968
1965
  }
1969
1966
  });
1970
1967
  if (method === "GET" && cache !== false) {
1971
- const cacheOptions = cacheProps ? cacheProps : __spreadProps$3(__spreadValues$4({}, objectRemoveEmpty({
1968
+ const cacheOptions = cacheProps ? cacheProps : __spreadProps$2(__spreadValues$4({}, objectRemoveEmpty({
1972
1969
  headers,
1973
1970
  withCredentials,
1974
1971
  responseType,
@@ -2022,7 +2019,7 @@ var Geocoder = (function (exports) {
2022
2019
  });
2023
2020
  }
2024
2021
  _login(credentials, options) {
2025
- return __async$3(this, null, function* () {
2022
+ return __async$2(this, null, function* () {
2026
2023
  try {
2027
2024
  const data = yield this.getUserInfo(credentials, options);
2028
2025
  this.user = data;
@@ -2081,8 +2078,8 @@ var Geocoder = (function (exports) {
2081
2078
  }
2082
2079
 
2083
2080
  var __defProp$5 = Object.defineProperty;
2084
- var __defProps$2 = Object.defineProperties;
2085
- var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
2081
+ var __defProps$1 = Object.defineProperties;
2082
+ var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
2086
2083
  var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
2087
2084
  var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
2088
2085
  var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
@@ -2098,9 +2095,9 @@ var Geocoder = (function (exports) {
2098
2095
  }
2099
2096
  return a;
2100
2097
  };
2101
- var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
2098
+ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
2102
2099
  var __publicField$3 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
2103
- var __async$2 = (__this, __arguments, generator) => {
2100
+ var __async$1 = (__this, __arguments, generator) => {
2104
2101
  return new Promise((resolve, reject) => {
2105
2102
  var fulfilled = (value) => {
2106
2103
  try {
@@ -2218,19 +2215,20 @@ var Geocoder = (function (exports) {
2218
2215
  } else {
2219
2216
  Object.assign(query, resourceToQuery(resource));
2220
2217
  }
2221
- return this.connector.route("resource.search").get(__spreadProps$2(__spreadValues$3({}, requestOptions), {
2218
+ return this.connector.route("resource.search").get(__spreadProps$1(__spreadValues$3({}, requestOptions), {
2222
2219
  query: __spreadValues$3({
2223
2220
  serialization: "full"
2224
2221
  }, query)
2225
2222
  })).then((resources) => {
2226
- if ((requestOptions == null ? void 0 : requestOptions.cache) && resources) {
2227
- for (const x of resources) {
2223
+ const items2 = Array.isArray(resources) ? resources : resources.items;
2224
+ if (requestOptions == null ? void 0 : requestOptions.cache) {
2225
+ for (const x of items2) {
2228
2226
  this.cache.add("resource.item", Promise.resolve(x), {
2229
2227
  id: x.resource.id
2230
2228
  });
2231
2229
  }
2232
2230
  }
2233
- return resources;
2231
+ return items2;
2234
2232
  });
2235
2233
  }
2236
2234
  return items;
@@ -2272,7 +2270,7 @@ var Geocoder = (function (exports) {
2272
2270
  });
2273
2271
  }
2274
2272
  _getChildrenOf(_0, _1) {
2275
- return __async$2(this, arguments, function* (parentDef, requestOptions, _items = []) {
2273
+ return __async$1(this, arguments, function* (parentDef, requestOptions, _items = []) {
2276
2274
  let parent = void 0;
2277
2275
  if (typeof parentDef === "string") {
2278
2276
  parent = yield this.getId(parentDef, requestOptions);
@@ -2281,7 +2279,7 @@ var Geocoder = (function (exports) {
2281
2279
  } else {
2282
2280
  parent = parentDef;
2283
2281
  }
2284
- const items = yield this.connector.route("resource.collection").get(__spreadProps$2(__spreadValues$3({}, requestOptions), {
2282
+ const items = yield this.connector.route("resource.collection").get(__spreadProps$1(__spreadValues$3({}, requestOptions), {
2285
2283
  query: {
2286
2284
  parent
2287
2285
  }
@@ -2309,7 +2307,7 @@ var Geocoder = (function (exports) {
2309
2307
  });
2310
2308
  }
2311
2309
  _cleanResourceItemCache(id) {
2312
- return __async$2(this, null, function* () {
2310
+ return __async$1(this, null, function* () {
2313
2311
  var _a;
2314
2312
  const all = this.cache.all();
2315
2313
  const toDelete = [];
@@ -2613,7 +2611,7 @@ var Geocoder = (function (exports) {
2613
2611
  return like(a, b, true);
2614
2612
  }
2615
2613
  };
2616
- function isPropertyFilter(filter) {
2614
+ function isPropertyFilter$1(filter) {
2617
2615
  const pf = filter;
2618
2616
  if (pf.length === 3 && typeof pf[0] === "string" && typeof pf[1] === "string") {
2619
2617
  return true;
@@ -2623,7 +2621,7 @@ var Geocoder = (function (exports) {
2623
2621
  function propertiesFilter(properties, filters) {
2624
2622
  const logic = typeof filters[0] === "string" ? filters[0] : "all";
2625
2623
  const filterFunction = (p) => {
2626
- if (isPropertyFilter(p)) {
2624
+ if (isPropertyFilter$1(p)) {
2627
2625
  const [field, operation, value] = p;
2628
2626
  const operationExec = operationsAliases[operation];
2629
2627
  if (operationExec) {
@@ -2649,8 +2647,6 @@ var Geocoder = (function (exports) {
2649
2647
  }
2650
2648
 
2651
2649
  var __defProp$3 = Object.defineProperty;
2652
- var __defProps$1 = Object.defineProperties;
2653
- var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
2654
2650
  var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
2655
2651
  var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
2656
2652
  var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
@@ -2666,27 +2662,6 @@ var Geocoder = (function (exports) {
2666
2662
  }
2667
2663
  return a;
2668
2664
  };
2669
- var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
2670
- var __async$1 = (__this, __arguments, generator) => {
2671
- return new Promise((resolve, reject) => {
2672
- var fulfilled = (value) => {
2673
- try {
2674
- step(generator.next(value));
2675
- } catch (e) {
2676
- reject(e);
2677
- }
2678
- };
2679
- var rejected = (value) => {
2680
- try {
2681
- step(generator.throw(value));
2682
- } catch (e) {
2683
- reject(e);
2684
- }
2685
- };
2686
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
2687
- step((generator = generator.apply(__this, __arguments)).next());
2688
- });
2689
- };
2690
2665
  const FEATURE_REQUEST_PARAMS = {
2691
2666
  srs: 4326,
2692
2667
  geom_format: "geojson",
@@ -2723,86 +2698,6 @@ var Geocoder = (function (exports) {
2723
2698
  {}
2724
2699
  );
2725
2700
  }
2726
- function createFeatureFieldFilterQueries(opt) {
2727
- return __async$1(this, null, function* () {
2728
- const queries = getQueries(opt);
2729
- const itemsParts = yield Promise.all(queries);
2730
- const ids = [];
2731
- const items = [];
2732
- for (const part of itemsParts) {
2733
- for (const item of part) {
2734
- if (!ids.includes(item.id)) {
2735
- items.push(item);
2736
- ids.push(item.id);
2737
- }
2738
- }
2739
- }
2740
- const offset = opt.offset !== void 0 ? opt.offset : 0;
2741
- const limit = opt.limit !== void 0 ? opt.limit : items.length;
2742
- if (opt.offset || opt.limit) {
2743
- return items.splice(offset, limit);
2744
- }
2745
- return items;
2746
- });
2747
- }
2748
- function createParam(pf) {
2749
- const [field, operation, value] = pf;
2750
- const isFldStr = field !== "id" ? "fld_" : "";
2751
- let vStart = "";
2752
- let vEnd = "";
2753
- const field_ = String(field).trim().replace(/^(%?)(.+?)(%?)$/, (m, a, b, c) => {
2754
- vStart = a;
2755
- vEnd = c;
2756
- return b;
2757
- });
2758
- const v = vStart + value + vEnd;
2759
- return [`${isFldStr}${field_}__${operation}`, v];
2760
- }
2761
- function getQueries(opt, _queries = [], _parentAllParams = []) {
2762
- var _a;
2763
- const { filters } = opt;
2764
- const paramList = (_a = opt.paramList) != null ? _a : [];
2765
- const logic = typeof filters[0] === "string" ? filters[0] : "all";
2766
- const filters_ = filters.filter((x) => Array.isArray(x));
2767
- if (logic === "any") {
2768
- for (const f of filters_) {
2769
- if (isPropertyFilter(f)) {
2770
- _queries.push(
2771
- fetchNgwLayerItemsRequest(__spreadProps$1(__spreadValues$2({}, opt), {
2772
- paramList: [..._parentAllParams, ...paramList, createParam(f)]
2773
- }))
2774
- );
2775
- } else {
2776
- getQueries(__spreadProps$1(__spreadValues$2({}, opt), { filters: f }), _queries, [..._parentAllParams]);
2777
- }
2778
- }
2779
- } else if (logic === "all") {
2780
- const filters2 = [];
2781
- const propertiesFilterList = [];
2782
- for (const f of filters_) {
2783
- if (isPropertyFilter(f)) {
2784
- filters2.push(createParam(f));
2785
- } else {
2786
- propertiesFilterList.push(f);
2787
- }
2788
- }
2789
- if (propertiesFilterList.length) {
2790
- for (const x of propertiesFilterList) {
2791
- getQueries(__spreadProps$1(__spreadValues$2({}, opt), { filters: x }), _queries, [
2792
- ..._parentAllParams,
2793
- ...filters2
2794
- ]);
2795
- }
2796
- } else {
2797
- _queries.push(
2798
- fetchNgwLayerItemsRequest(__spreadProps$1(__spreadValues$2({}, opt), {
2799
- paramList: [..._parentAllParams, ...paramList, ...filters2]
2800
- }))
2801
- );
2802
- }
2803
- }
2804
- return _queries;
2805
- }
2806
2701
  function createWktFromCoordArray(coord) {
2807
2702
  const polygon = coord.map(([lng, lat]) => {
2808
2703
  const [x, y] = degrees2meters(lng, lat).map((c) => round(c));
@@ -2876,6 +2771,147 @@ var Geocoder = (function (exports) {
2876
2771
  return fields;
2877
2772
  }
2878
2773
 
2774
+ function isPropertyFilter(value) {
2775
+ return Array.isArray(value) && value.length === 3 && typeof value[0] === "string" && typeof value[1] === "string";
2776
+ }
2777
+ function isPropertiesFilterGroup(value) {
2778
+ return Array.isArray(value) && !isPropertyFilter(value);
2779
+ }
2780
+ function toGetExpr(field) {
2781
+ return field === "id" ? ["fid"] : ["get", field];
2782
+ }
2783
+ function parseWildcardField(field) {
2784
+ const leadingWildcard = field.startsWith("%");
2785
+ const trailingWildcard = field.endsWith("%");
2786
+ return {
2787
+ field: field.slice(
2788
+ leadingWildcard ? 1 : 0,
2789
+ trailingWildcard ? -1 : void 0
2790
+ ),
2791
+ leadingWildcard,
2792
+ trailingWildcard
2793
+ };
2794
+ }
2795
+ function toConditionExpr(filter) {
2796
+ const [fieldRaw, op, value] = filter;
2797
+ const field = String(fieldRaw);
2798
+ const getExpr = toGetExpr(field);
2799
+ switch (op) {
2800
+ case "eq":
2801
+ if (value === null) {
2802
+ return ["is_null", getExpr];
2803
+ }
2804
+ return ["==", getExpr, value];
2805
+ case "ne":
2806
+ if (value === null) {
2807
+ return ["!is_null", getExpr];
2808
+ }
2809
+ return ["!=", getExpr, value];
2810
+ case "gt":
2811
+ if (typeof value !== "number" && typeof value !== "string") {
2812
+ throw new Error(
2813
+ `Operator "gt" requires number or string for "${field}"`
2814
+ );
2815
+ }
2816
+ return [">", getExpr, value];
2817
+ case "lt":
2818
+ if (typeof value !== "number" && typeof value !== "string") {
2819
+ throw new Error(
2820
+ `Operator "lt" requires number or string for "${field}"`
2821
+ );
2822
+ }
2823
+ return ["<", getExpr, value];
2824
+ case "ge":
2825
+ if (typeof value !== "number" && typeof value !== "string") {
2826
+ throw new Error(
2827
+ `Operator "ge" requires number or string for "${field}"`
2828
+ );
2829
+ }
2830
+ return [">=", getExpr, value];
2831
+ case "le":
2832
+ if (typeof value !== "number" && typeof value !== "string") {
2833
+ throw new Error(
2834
+ `Operator "le" requires number or string for "${field}"`
2835
+ );
2836
+ }
2837
+ return ["<=", getExpr, value];
2838
+ case "in":
2839
+ if (!Array.isArray(value) || !value.every((x) => typeof x === "string" || typeof x === "number")) {
2840
+ throw new Error(
2841
+ `Operator "in" requires (string | number)[] for "${field}"`
2842
+ );
2843
+ }
2844
+ if (!value.length) {
2845
+ throw new Error(
2846
+ `Operator "in" requires non-empty array for "${field}"`
2847
+ );
2848
+ }
2849
+ return ["in", getExpr, ...value];
2850
+ case "notin":
2851
+ if (!Array.isArray(value) || !value.every((x) => typeof x === "string" || typeof x === "number")) {
2852
+ throw new Error(
2853
+ `Operator "notin" requires (string | number)[] for "${field}"`
2854
+ );
2855
+ }
2856
+ if (!value.length) {
2857
+ throw new Error(
2858
+ `Operator "notin" requires non-empty array for "${field}"`
2859
+ );
2860
+ }
2861
+ return ["!in", getExpr, ...value];
2862
+ case "ilike": {
2863
+ if (typeof value !== "string") {
2864
+ throw new Error(`Operator "ilike" requires string for "${field}"`);
2865
+ }
2866
+ const parsed = parseWildcardField(field);
2867
+ const pattern = `${parsed.leadingWildcard ? "%" : ""}${value}${parsed.trailingWildcard ? "%" : ""}`;
2868
+ return ["ilike", toGetExpr(parsed.field), pattern];
2869
+ }
2870
+ case "like":
2871
+ throw new Error(
2872
+ `Operator "${op}" is not supported by server FilterExpression`
2873
+ );
2874
+ default: {
2875
+ const exhaustive = op;
2876
+ throw new Error(`Unsupported operator: ${exhaustive}`);
2877
+ }
2878
+ }
2879
+ }
2880
+ function toGroupExpr(filters) {
2881
+ let logicalOp = "all";
2882
+ const children = [];
2883
+ for (const item of filters) {
2884
+ if (item === "all" || item === "any") {
2885
+ logicalOp = item;
2886
+ continue;
2887
+ }
2888
+ if (isPropertyFilter(item)) {
2889
+ children.push(toConditionExpr(item));
2890
+ continue;
2891
+ }
2892
+ if (isPropertiesFilterGroup(item)) {
2893
+ children.push(toGroupExpr(item));
2894
+ continue;
2895
+ }
2896
+ throw new Error("Invalid PropertiesFilter node");
2897
+ }
2898
+ return [logicalOp, ...children];
2899
+ }
2900
+ function propertiesFilterToExpression(filters) {
2901
+ if (!(filters == null ? void 0 : filters.length)) {
2902
+ return [];
2903
+ }
2904
+ return toGroupExpr(filters);
2905
+ }
2906
+ function propertiesFilterToExpressionString(filters) {
2907
+ if (!(filters == null ? void 0 : filters.length)) {
2908
+ return void 0;
2909
+ }
2910
+ return JSON.stringify(
2911
+ propertiesFilterToExpression(filters)
2912
+ );
2913
+ }
2914
+
2879
2915
  var __defProp$2 = Object.defineProperty;
2880
2916
  var __defProps = Object.defineProperties;
2881
2917
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
@@ -2920,10 +2956,12 @@ var Geocoder = (function (exports) {
2920
2956
  var _a;
2921
2957
  const filters = options.filters;
2922
2958
  if (filters) {
2923
- let data = yield createFeatureFieldFilterQueries(__spreadProps(__spreadValues$1({}, options), {
2924
- filters
2959
+ let data = yield fetchNgwLayerItemsRequest(__spreadProps(__spreadValues$1({}, options), {
2960
+ query: __spreadProps(__spreadValues$1({}, options.query), {
2961
+ filter: propertiesFilterToExpressionString(filters)
2962
+ })
2925
2963
  }));
2926
- const clientFilterValidate = (_a = options.clientFilterValidate) != null ? _a : isFilterWithAnyCase(filters);
2964
+ const clientFilterValidate = (_a = options.clientFilterValidate) != null ? _a : false;
2927
2965
  if (clientFilterValidate) {
2928
2966
  data = data.filter((y) => {
2929
2967
  const fields = prepareNgwFieldsToPropertiesFilter(__spreadProps(__spreadValues$1({}, y.fields), {
@@ -2939,27 +2977,12 @@ var Geocoder = (function (exports) {
2939
2977
  }
2940
2978
  });
2941
2979
  }
2942
- function isFilterWithAnyCase(filters) {
2943
- if (filters[0] === "any") {
2944
- return true;
2945
- }
2946
- for (let i = 1; i < filters.length; i++) {
2947
- const p = filters[i];
2948
- if (isArray(p)) {
2949
- const deep = isFilterWithAnyCase(p);
2950
- if (deep) {
2951
- return true;
2952
- }
2953
- }
2954
- }
2955
- return false;
2956
- }
2957
2980
 
2958
2981
  var __defProp$1 = Object.defineProperty;
2959
2982
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
2960
2983
  var __hasOwnProp = Object.prototype.hasOwnProperty;
2961
2984
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
2962
- var __knownSymbol$1 = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
2985
+ var __knownSymbol$1 = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
2963
2986
  var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2964
2987
  var __spreadValues = (a, b) => {
2965
2988
  for (var prop in b || (b = {}))
@@ -2985,7 +3008,7 @@ var Geocoder = (function (exports) {
2985
3008
  } catch (e) {
2986
3009
  no(e);
2987
3010
  }
2988
- }, method = (k) => it[k] = (x) => new Promise((yes, no) => resume(k, x, yes, no)), it = {};
3011
+ }, 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 = {};
2989
3012
  return generator = generator.apply(__this, __arguments), it[__knownSymbol$1("asyncIterator")] = () => it, method("next"), method("throw"), method("return"), it;
2990
3013
  };
2991
3014
  const _NgwProvider = class _NgwProvider extends BaseProvider {
@@ -3133,7 +3156,7 @@ var Geocoder = (function (exports) {
3133
3156
  let NgwProvider = _NgwProvider;
3134
3157
 
3135
3158
  var __defProp = Object.defineProperty;
3136
- var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
3159
+ var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
3137
3160
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3138
3161
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
3139
3162
  var __await = function(promise, isYieldStar) {
@@ -3148,13 +3171,13 @@ var Geocoder = (function (exports) {
3148
3171
  } catch (e) {
3149
3172
  no(e);
3150
3173
  }
3151
- }, method = (k) => it[k] = (x) => new Promise((yes, no) => resume(k, x, yes, no)), it = {};
3174
+ }, 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 = {};
3152
3175
  return generator = generator.apply(__this, __arguments), it[__knownSymbol("asyncIterator")] = () => it, method("next"), method("throw"), method("return"), it;
3153
3176
  };
3154
3177
  class NominatimProvider extends BaseProvider {
3155
3178
  constructor(options) {
3156
3179
  super();
3157
- this.options = options;
3180
+ __publicField(this, "options", options);
3158
3181
  __publicField(this, "searchUrl", "https://nominatim.openstreetmap.org");
3159
3182
  __publicField(this, "_abortControllers", []);
3160
3183
  if (options && options.searchUrl) {