@nextgis/geocoder 3.0.0-alpha.9 → 3.0.0

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: 3.0.0-alpha.9; author: NextGIS */
1
+ /** Bundle of @nextgis/geocoder; version: 3.0.0; author: NextGIS */
2
2
  function defined(val) {
3
3
  return val !== void 0 && val !== null;
4
4
  }
@@ -6,14 +6,6 @@ function full(val) {
6
6
  return typeof val === "string" ? !!val : defined(val);
7
7
  }
8
8
 
9
- function getBoundsCoordinates(b) {
10
- const westNorth = [b[0], b[1]];
11
- const eastNorth = [b[2], b[1]];
12
- const eastSouth = [b[2], b[3]];
13
- const westSouth = [b[0], b[3]];
14
- return [westNorth, eastNorth, eastSouth, westSouth, westNorth];
15
- }
16
-
17
9
  function degrees2meters(lng, lat) {
18
10
  lat = lat > 85.06 ? 85.06 : lat < -85.06 ? -85.06 : lat;
19
11
  const x = lng * 2003750834e-2 / 180;
@@ -22,10 +14,23 @@ function degrees2meters(lng, lat) {
22
14
  return [x, y];
23
15
  }
24
16
 
17
+ function getBoundsCoordinates(b) {
18
+ const westNorth = [b[0], b[1]];
19
+ const eastNorth = [b[2], b[1]];
20
+ const eastSouth = [b[2], b[3]];
21
+ const westSouth = [b[0], b[3]];
22
+ return [westNorth, eastNorth, eastSouth, westSouth, westNorth];
23
+ }
24
+
25
25
  function isLngLatBoundsArray(array) {
26
26
  return Array.isArray(array) && array.length === 4 && array.every((x) => typeof x === "number");
27
27
  }
28
28
 
29
+ function round(val, toFixed) {
30
+ const n = 1;
31
+ return Math.round((val + Number.EPSILON) * n) / n;
32
+ }
33
+
29
34
  function objectAssign(target, ...sources) {
30
35
  for (const source of sources) {
31
36
  for (const prop of Object.getOwnPropertyNames(source)) {
@@ -80,11 +85,6 @@ function objectRemoveEmpty(obj) {
80
85
  return newObj;
81
86
  }
82
87
 
83
- function round(val, toFixed) {
84
- const n = 1;
85
- return Math.round((val + Number.EPSILON) * n) / n;
86
- }
87
-
88
88
  function isObject$1(val) {
89
89
  return Object.prototype.toString.call(val) === "[object Object]";
90
90
  }
@@ -104,27 +104,27 @@ class BaseGeocoder {
104
104
  }
105
105
  }
106
106
 
107
- var __defProp$h = Object.defineProperty;
108
- var __defProps$4 = Object.defineProperties;
109
- var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
107
+ var __defProp$i = Object.defineProperty;
108
+ var __defProps$5 = Object.defineProperties;
109
+ var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
110
110
  var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
111
111
  var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
112
112
  var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
113
113
  var __knownSymbol$2 = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
114
- var __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$h(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
114
+ var __defNormalProp$i = (obj, key, value) => key in obj ? __defProp$i(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
115
115
  var __spreadValues$8 = (a, b) => {
116
116
  for (var prop in b || (b = {}))
117
117
  if (__hasOwnProp$8.call(b, prop))
118
- __defNormalProp$h(a, prop, b[prop]);
118
+ __defNormalProp$i(a, prop, b[prop]);
119
119
  if (__getOwnPropSymbols$8)
120
120
  for (var prop of __getOwnPropSymbols$8(b)) {
121
121
  if (__propIsEnum$8.call(b, prop))
122
- __defNormalProp$h(a, prop, b[prop]);
122
+ __defNormalProp$i(a, prop, b[prop]);
123
123
  }
124
124
  return a;
125
125
  };
126
- var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
127
- var __publicField$c = (obj, key, value) => __defNormalProp$h(obj, key + "" , value);
126
+ var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
127
+ var __publicField$d = (obj, key, value) => __defNormalProp$i(obj, key + "" , value);
128
128
  var __async$7 = (__this, __arguments, generator) => {
129
129
  return new Promise((resolve, reject) => {
130
130
  var fulfilled = (value) => {
@@ -165,7 +165,7 @@ let ID$1 = 0;
165
165
  class Geocoder extends BaseGeocoder {
166
166
  constructor(options) {
167
167
  super(options);
168
- __publicField$c(this, "providers", []);
168
+ __publicField$d(this, "providers", []);
169
169
  if (options && options.providers) {
170
170
  this.providers = options.providers;
171
171
  }
@@ -189,7 +189,7 @@ class Geocoder extends BaseGeocoder {
189
189
  for (var iter = __forAwait(results), more, temp, error; more = !(temp = yield new __await$2(iter.next())).done; more = false) {
190
190
  const r = temp.value;
191
191
  allProvidersFailed = false;
192
- yield __spreadProps$4(__spreadValues$8({}, r), { provider, _id: ID$1++ });
192
+ yield __spreadProps$5(__spreadValues$8({}, r), { provider, _id: ID$1++ });
193
193
  }
194
194
  } catch (temp) {
195
195
  error = [temp];
@@ -203,7 +203,7 @@ class Geocoder extends BaseGeocoder {
203
203
  }
204
204
  } catch (err) {
205
205
  const er = err;
206
- if (er.name !== "CancelError") {
206
+ if (er.name !== "AbortError") {
207
207
  errors.push(er);
208
208
  }
209
209
  }
@@ -232,7 +232,7 @@ class Geocoder extends BaseGeocoder {
232
232
  try {
233
233
  for (var iter = __forAwait(results), more, temp, error; more = !(temp = yield new __await$2(iter.next())).done; more = false) {
234
234
  const r = temp.value;
235
- yield __spreadProps$4(__spreadValues$8({}, r), { provider, _id: ID$1++ });
235
+ yield __spreadProps$5(__spreadValues$8({}, r), { provider, _id: ID$1++ });
236
236
  }
237
237
  } catch (temp) {
238
238
  error = [temp];
@@ -244,7 +244,7 @@ class Geocoder extends BaseGeocoder {
244
244
  throw error[0];
245
245
  }
246
246
  }
247
- } catch (er) {
247
+ } catch (e) {
248
248
  }
249
249
  }
250
250
  });
@@ -285,9 +285,9 @@ class Geocoder extends BaseGeocoder {
285
285
  }
286
286
  }
287
287
 
288
- var __defProp$g = Object.defineProperty;
289
- var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
290
- var __publicField$b = (obj, key, value) => __defNormalProp$g(obj, typeof key !== "symbol" ? key + "" : key, value);
288
+ var __defProp$h = Object.defineProperty;
289
+ var __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$h(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
290
+ var __publicField$c = (obj, key, value) => __defNormalProp$h(obj, typeof key !== "symbol" ? key + "" : key, value);
291
291
  class BaseProvider extends BaseGeocoder {
292
292
  constructor() {
293
293
  super(...arguments);
@@ -295,14 +295,253 @@ class BaseProvider extends BaseGeocoder {
295
295
  * URL endpoint for the search service.
296
296
  * This is where queries will be sent to obtain search results.
297
297
  */
298
- __publicField$b(this, "searchUrl");
298
+ __publicField$c(this, "searchUrl");
299
299
  /**
300
300
  * Label to represent the provider.
301
301
  * Useful for user interfaces to display the source of search results.
302
302
  */
303
- __publicField$b(this, "label");
303
+ __publicField$c(this, "label");
304
+ }
305
+ }
306
+
307
+ const templateRe = /\{ *([\w_-]+) *\}/g;
308
+ function template(str, data) {
309
+ return str.replace(templateRe, (s, key) => {
310
+ let value = data[key];
311
+ if (value === void 0) {
312
+ throw new Error("No value provided for letiable " + s);
313
+ } else if (typeof value === "function") {
314
+ value = value(data);
315
+ }
316
+ return value;
317
+ });
318
+ }
319
+
320
+ var __defProp$g = Object.defineProperty;
321
+ var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
322
+ var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
323
+ var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
324
+ var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
325
+ var __spreadValues$7 = (a, b) => {
326
+ for (var prop in b || (b = {}))
327
+ if (__hasOwnProp$7.call(b, prop))
328
+ __defNormalProp$g(a, prop, b[prop]);
329
+ if (__getOwnPropSymbols$7)
330
+ for (var prop of __getOwnPropSymbols$7(b)) {
331
+ if (__propIsEnum$7.call(b, prop))
332
+ __defNormalProp$g(a, prop, b[prop]);
333
+ }
334
+ return a;
335
+ };
336
+ var __async$6 = (__this, __arguments, generator) => {
337
+ return new Promise((resolve, reject) => {
338
+ var fulfilled = (value) => {
339
+ try {
340
+ step(generator.next(value));
341
+ } catch (e) {
342
+ reject(e);
343
+ }
344
+ };
345
+ var rejected = (value) => {
346
+ try {
347
+ step(generator.throw(value));
348
+ } catch (e) {
349
+ reject(e);
350
+ }
351
+ };
352
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
353
+ step((generator = generator.apply(__this, __arguments)).next());
354
+ });
355
+ };
356
+ function apiRequest(opt) {
357
+ return __async$6(this, null, function* () {
358
+ const { params, name, connector, requestOptions } = opt;
359
+ const apiItems = yield connector.connect();
360
+ let apiItem = apiItems && apiItems[name];
361
+ if (apiItem) {
362
+ apiItem = [...apiItem];
363
+ let url = apiItem.shift();
364
+ if (apiItem.length) {
365
+ const replaceParams = {};
366
+ for (let fry = 0; fry < apiItem.length; fry++) {
367
+ const arg = apiItem[fry];
368
+ replaceParams[fry] = `{${arg}}`;
369
+ if (params[arg] === void 0) {
370
+ throw new Error(`\`${arg}\` URL API argument is not specified`);
371
+ }
372
+ }
373
+ if (url) {
374
+ url = template(url, replaceParams);
375
+ }
376
+ }
377
+ if (params) {
378
+ const paramArray = [];
379
+ const paramList = params.paramList;
380
+ if (Array.isArray(paramList)) {
381
+ paramList.forEach(([key, value]) => {
382
+ paramArray.push(`${key}=${value}`);
383
+ });
384
+ }
385
+ for (const p in params) {
386
+ if (apiItem.indexOf(p) === -1) {
387
+ paramArray.push(`${p}=${params[p]}`);
388
+ }
389
+ }
390
+ if (paramArray.length) {
391
+ url = `${url}?${paramArray.join("&")}`;
392
+ }
393
+ }
394
+ if (url) {
395
+ return connector.makeQuery(url, params, __spreadValues$7({
396
+ cacheName: name
397
+ }, requestOptions));
398
+ } else {
399
+ throw new Error("Request URL is not set");
400
+ }
401
+ } else {
402
+ return void 0;
403
+ }
404
+ });
405
+ }
406
+
407
+ var __defProp$f = Object.defineProperty;
408
+ var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
409
+ var __publicField$b = (obj, key, value) => __defNormalProp$f(obj, typeof key !== "symbol" ? key + "" : key, value);
410
+ const _Cache = class _Cache {
411
+ constructor(options = {}) {
412
+ __publicField$b(this, "cache", []);
413
+ var _a;
414
+ const namespace = (_a = options.namespace) != null ? _a : "default";
415
+ if (_Cache.instance[namespace]) {
416
+ return _Cache.instance[namespace];
417
+ }
418
+ _Cache.instance[namespace] = this;
419
+ return this;
420
+ }
421
+ clean() {
422
+ this.cache.length = 0;
423
+ }
424
+ all() {
425
+ return this.cache;
426
+ }
427
+ /**
428
+ * Caching only a non-empty value.
429
+ *
430
+ * Useful for get or create strategy
431
+ * @example
432
+ * ```javascript
433
+ * const cache = new Cache();
434
+ * const getItemFunc = () => fetch(url).then((data) => {
435
+ * return data.json(); // undefined
436
+ * });
437
+ * const item = await cache.addFull('foo', getItemFunc);
438
+ * if (!item) {
439
+ * await createItem(); // 'New item'
440
+ * }
441
+ *
442
+ * // somewhere else in the code
443
+ * const item = await cache.addFull('foo', getItemFunc).then((resp) => {
444
+ * console.log(resp); // 'New item'
445
+ * });
446
+ * ```
447
+ */
448
+ addFull(key, valueToSet, propsOrOptions, expirationTime) {
449
+ if (typeof propsOrOptions === "object" && "valueToSet" in propsOrOptions) {
450
+ propsOrOptions.onlyFull = true;
451
+ }
452
+ return this.add(key, valueToSet, propsOrOptions, true, expirationTime);
453
+ }
454
+ add(key, valueToSet, propsOrOptions, onlyFull, expirationTime) {
455
+ let opt;
456
+ let props;
457
+ if (typeof propsOrOptions === "object" && "valueToSet" in propsOrOptions) {
458
+ opt = propsOrOptions;
459
+ onlyFull = opt.onlyFull;
460
+ expirationTime = opt.expirationTime;
461
+ props = opt.props;
462
+ } else {
463
+ props = propsOrOptions;
464
+ }
465
+ const exist = this._find(key, props);
466
+ if (!exist) {
467
+ let value;
468
+ if (valueToSet instanceof Function) {
469
+ value = valueToSet();
470
+ } else {
471
+ value = valueToSet;
472
+ }
473
+ const nonEmptyProps = props && JSON.parse(JSON.stringify(objectRemoveEmpty(props)));
474
+ expirationTime = expirationTime ? Date.now() + expirationTime : void 0;
475
+ const cacheItem = {
476
+ key,
477
+ value,
478
+ props: nonEmptyProps,
479
+ expirationTime
480
+ };
481
+ if (onlyFull && !full(value)) {
482
+ return value;
483
+ }
484
+ this.cache.push(cacheItem);
485
+ if (value instanceof Promise) {
486
+ value.catch(() => {
487
+ this.delete(key, props);
488
+ });
489
+ if (onlyFull) {
490
+ value.then((x) => {
491
+ if (!full(x)) {
492
+ this.delete(key, props);
493
+ }
494
+ return x;
495
+ });
496
+ }
497
+ return value;
498
+ }
499
+ return value;
500
+ } else {
501
+ return exist.value;
502
+ }
503
+ }
504
+ match(key, props) {
505
+ const cacheRecord = this._find(key, props);
506
+ if (cacheRecord && cacheRecord.expirationTime && Date.now() > cacheRecord.expirationTime) {
507
+ this.delete(cacheRecord);
508
+ return void 0;
509
+ }
510
+ return cacheRecord == null ? void 0 : cacheRecord.value;
511
+ }
512
+ matchAll(key, props) {
513
+ const now = Date.now();
514
+ this.cache.forEach((item) => {
515
+ if (item.expirationTime && now > item.expirationTime) {
516
+ this.delete(item);
517
+ }
518
+ });
519
+ if (key) {
520
+ return this.cache.filter((x) => this._filter(x, key, props)).map((x) => x.value);
521
+ }
522
+ return this.cache.map((x) => x.value);
523
+ }
524
+ delete(keyOrItem, props) {
525
+ const itemsToDelete = typeof keyOrItem === "string" ? this.cache.filter((x) => this._filter(x, keyOrItem, props)) : [keyOrItem];
526
+ for (const item of itemsToDelete) {
527
+ const index = this.cache.indexOf(item);
528
+ if (index !== -1) {
529
+ this.cache.splice(index, 1);
530
+ }
531
+ }
532
+ }
533
+ _find(key, props) {
534
+ return this.cache.find((x) => this._filter(x, key, props));
535
+ }
536
+ _filter(item, key, props) {
537
+ if (item.key !== key) return false;
538
+ if (!props) return true;
539
+ const itemProps = item.props;
540
+ return objectDeepEqual(itemProps || {}, objectRemoveEmpty(props));
304
541
  }
305
- }
542
+ };
543
+ __publicField$b(_Cache, "instance", {});
544
+ let Cache = _Cache;
306
545
 
307
546
  var domain;
308
547
 
@@ -776,148 +1015,9 @@ function unwrapListeners(arr) {
776
1015
  return ret;
777
1016
  }
778
1017
 
779
- var __defProp$f = Object.defineProperty;
780
- var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
781
- var __publicField$a = (obj, key, value) => __defNormalProp$f(obj, typeof key !== "symbol" ? key + "" : key, value);
782
- const _Cache = class _Cache {
783
- constructor(options = {}) {
784
- __publicField$a(this, "cache", []);
785
- var _a;
786
- const namespace = (_a = options.namespace) != null ? _a : "default";
787
- if (_Cache.instance[namespace]) {
788
- return _Cache.instance[namespace];
789
- }
790
- _Cache.instance[namespace] = this;
791
- return this;
792
- }
793
- clean() {
794
- this.cache.length = 0;
795
- }
796
- all() {
797
- return this.cache;
798
- }
799
- /**
800
- * Caching only a non-empty value.
801
- *
802
- * Useful for get or create strategy
803
- * @example
804
- * ```javascript
805
- * const cache = new Cache();
806
- * const getItemFunc = () => fetch(url).then((data) => {
807
- * return data.json(); // undefined
808
- * });
809
- * const item = await cache.addFull('foo', getItemFunc);
810
- * if (!item) {
811
- * await createItem(); // 'New item'
812
- * }
813
- *
814
- * // somewhere else in the code
815
- * const item = await cache.addFull('foo', getItemFunc).then((resp) => {
816
- * console.log(resp); // 'New item'
817
- * });
818
- * ```
819
- */
820
- addFull(key, valueToSet, propsOrOptions, expirationTime) {
821
- if (typeof propsOrOptions === "object" && "valueToSet" in propsOrOptions) {
822
- propsOrOptions.onlyFull = true;
823
- }
824
- return this.add(key, valueToSet, propsOrOptions, true, expirationTime);
825
- }
826
- add(key, valueToSet, propsOrOptions, onlyFull, expirationTime) {
827
- let opt;
828
- let props;
829
- if (typeof propsOrOptions === "object" && "valueToSet" in propsOrOptions) {
830
- opt = propsOrOptions;
831
- onlyFull = opt.onlyFull;
832
- expirationTime = opt.expirationTime;
833
- props = opt.props;
834
- } else {
835
- props = propsOrOptions;
836
- }
837
- const exist = this._find(key, props);
838
- if (!exist) {
839
- let value;
840
- if (valueToSet instanceof Function) {
841
- value = valueToSet();
842
- } else {
843
- value = valueToSet;
844
- }
845
- const nonEmptyProps = props && JSON.parse(JSON.stringify(objectRemoveEmpty(props)));
846
- expirationTime = expirationTime ? Date.now() + expirationTime : void 0;
847
- const cacheItem = {
848
- key,
849
- value,
850
- props: nonEmptyProps,
851
- expirationTime
852
- };
853
- if (onlyFull && !full(value)) {
854
- return value;
855
- }
856
- this.cache.push(cacheItem);
857
- if (value instanceof Promise) {
858
- value.catch((er) => {
859
- this.delete(key, props);
860
- });
861
- if (onlyFull) {
862
- value.then((x) => {
863
- if (!full(x)) {
864
- this.delete(key, props);
865
- }
866
- return x;
867
- });
868
- }
869
- return value;
870
- }
871
- return value;
872
- } else {
873
- return exist.value;
874
- }
875
- }
876
- match(key, props) {
877
- const cacheRecord = this._find(key, props);
878
- if (cacheRecord && cacheRecord.expirationTime && Date.now() > cacheRecord.expirationTime) {
879
- this.delete(cacheRecord);
880
- return void 0;
881
- }
882
- return cacheRecord == null ? void 0 : cacheRecord.value;
883
- }
884
- matchAll(key, props) {
885
- const now = Date.now();
886
- this.cache.forEach((item) => {
887
- if (item.expirationTime && now > item.expirationTime) {
888
- this.delete(item);
889
- }
890
- });
891
- if (key) {
892
- return this.cache.filter((x) => this._filter(x, key, props)).map((x) => x.value);
893
- }
894
- return this.cache.map((x) => x.value);
895
- }
896
- delete(keyOrItem, props) {
897
- const itemsToDelete = typeof keyOrItem === "string" ? this.cache.filter((x) => this._filter(x, keyOrItem, props)) : [keyOrItem];
898
- for (const item of itemsToDelete) {
899
- const index = this.cache.indexOf(item);
900
- if (index !== -1) {
901
- this.cache.splice(index, 1);
902
- }
903
- }
904
- }
905
- _find(key, props) {
906
- return this.cache.find((x) => this._filter(x, key, props));
907
- }
908
- _filter(item, key, props) {
909
- if (item.key !== key) return false;
910
- if (!props) return true;
911
- const itemProps = item.props;
912
- return objectDeepEqual(itemProps || {}, objectRemoveEmpty(props));
913
- }
914
- };
915
- __publicField$a(_Cache, "instance", {});
916
- let Cache = _Cache;
917
-
918
1018
  var pkg = {
919
1019
  name: "@nextgis/ngw-connector",
920
- version: "3.0.0-alpha.8",
1020
+ version: "3.0.0",
921
1021
  _priority: 12,
922
1022
  description: "A lightweight HTTP client optimized for use with NextGIS Web API",
923
1023
  main: "index.js",
@@ -926,15 +1026,15 @@ var pkg = {
926
1026
  jsdelivr: "lib/ngw-connector.global.prod.js",
927
1027
  types: "lib/index.d.ts",
928
1028
  dependencies: {
929
- "@nextgis/cache": "^3.0.0-alpha.7",
930
- "@nextgis/cancelable-promise": "^3.0.0-alpha.5",
931
- "@nextgis/utils": "^3.0.0-alpha.5",
1029
+ "@nextgis/cache": "3.0.0",
1030
+ "@nextgis/cancelable-promise": "3.0.0",
1031
+ "@nextgis/utils": "3.0.0",
932
1032
  "@types/events": "^3.0.0",
933
1033
  events: "*",
934
1034
  "form-data": "^4.0.0"
935
1035
  },
936
1036
  devDependencies: {
937
- "@nextgis/build-tools": "^3.0.0-alpha.5"
1037
+ "@nextgis/build-tools": "3.0.0"
938
1038
  },
939
1039
  scripts: {
940
1040
  clean: "rimraf ./lib",
@@ -974,30 +1074,6 @@ var pkg = {
974
1074
  gitHead: "edc68033f914f6c95c4125b9738bba6d36e990b4"
975
1075
  };
976
1076
 
977
- const CONNECTORS = [];
978
- function addConnector(connector) {
979
- CONNECTORS.push(connector);
980
- }
981
- function findConnector(options) {
982
- return CONNECTORS.find((x) => {
983
- if (x.options.baseUrl === options.baseUrl) {
984
- if (options.auth) {
985
- if (x.options.auth) {
986
- return objectDeepEqual(x.options.auth, options.auth);
987
- }
988
- } else {
989
- return true;
990
- }
991
- }
992
- });
993
- }
994
- function removeConnector(connector) {
995
- const index = CONNECTORS.indexOf(connector);
996
- if (index !== -1) {
997
- CONNECTORS.splice(index, 1);
998
- }
999
- }
1000
-
1001
1077
  class AbortError extends Error {
1002
1078
  constructor(message = "AbortError") {
1003
1079
  super(message);
@@ -1007,18 +1083,18 @@ class AbortError extends Error {
1007
1083
 
1008
1084
  var __defProp$e = Object.defineProperty;
1009
1085
  var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1010
- var __publicField$9 = (obj, key, value) => __defNormalProp$e(obj, typeof key !== "symbol" ? key + "" : key, value);
1086
+ var __publicField$a = (obj, key, value) => __defNormalProp$e(obj, typeof key !== "symbol" ? key + "" : key, value);
1011
1087
  class NgwError extends Error {
1012
1088
  constructor(er) {
1013
1089
  super();
1014
- __publicField$9(this, "name", "NgwError");
1015
- __publicField$9(this, "title");
1016
- __publicField$9(this, "message");
1017
- __publicField$9(this, "detail");
1018
- __publicField$9(this, "exception");
1019
- __publicField$9(this, "status_code");
1020
- __publicField$9(this, "data");
1021
- __publicField$9(this, "guru_meditation");
1090
+ __publicField$a(this, "name", "NgwError");
1091
+ __publicField$a(this, "title");
1092
+ __publicField$a(this, "message");
1093
+ __publicField$a(this, "detail");
1094
+ __publicField$a(this, "exception");
1095
+ __publicField$a(this, "status_code");
1096
+ __publicField$a(this, "data");
1097
+ __publicField$a(this, "guru_meditation");
1022
1098
  Object.assign(this, er);
1023
1099
  Object.setPrototypeOf(this, NgwError.prototype);
1024
1100
  }
@@ -1026,35 +1102,105 @@ class NgwError extends Error {
1026
1102
 
1027
1103
  var __defProp$d = Object.defineProperty;
1028
1104
  var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1029
- var __publicField$8 = (obj, key, value) => __defNormalProp$d(obj, typeof key !== "symbol" ? key + "" : key, value);
1105
+ var __publicField$9 = (obj, key, value) => __defNormalProp$d(obj, typeof key !== "symbol" ? key + "" : key, value);
1030
1106
  class InsufficientPermissionsError extends NgwError {
1031
1107
  constructor(obj) {
1032
1108
  super(obj);
1033
- __publicField$8(this, "name", "InsufficientPermissionsError");
1034
- __publicField$8(this, "exception", "nextgisweb.core.exception.InsufficientPermissions");
1109
+ __publicField$9(this, "name", "InsufficientPermissionsError");
1110
+ __publicField$9(this, "exception", "nextgisweb.core.exception.InsufficientPermissions");
1035
1111
  Object.setPrototypeOf(this, InsufficientPermissionsError.prototype);
1036
1112
  }
1037
1113
  }
1038
1114
 
1039
1115
  var __defProp$c = Object.defineProperty;
1040
1116
  var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1041
- var __publicField$7 = (obj, key, value) => __defNormalProp$c(obj, typeof key !== "symbol" ? key + "" : key, value);
1042
- class ResourceNotFoundError extends NgwError {
1117
+ var __publicField$8 = (obj, key, value) => __defNormalProp$c(obj, typeof key !== "symbol" ? key + "" : key, value);
1118
+ let NetworksResponseError$1 = class NetworksResponseError extends NgwError {
1043
1119
  constructor(obj) {
1044
1120
  super(obj);
1045
- __publicField$7(this, "name", "ResourceNotFoundError");
1046
- __publicField$7(this, "exception", "nextgisweb.resource.exception.ResourceNotFound");
1047
- Object.setPrototypeOf(this, ResourceNotFoundError.prototype);
1121
+ __publicField$8(this, "message", "There is no response from the server or problem connecting to server.");
1122
+ __publicField$8(this, "title", "Network error");
1123
+ __publicField$8(this, "detail", "Check network connectivity and try again later.");
1124
+ Object.setPrototypeOf(this, NetworksResponseError.prototype);
1125
+ }
1126
+ };
1127
+
1128
+ function extractError(error) {
1129
+ if (isObject$1(error)) {
1130
+ if (error.name && error.message && error.title) {
1131
+ return {
1132
+ title: error.title,
1133
+ message: error.message,
1134
+ detail: error.detail || null,
1135
+ data: error.data && error.data.data ? error.data.data : null
1136
+ };
1137
+ } else if (error.exception) {
1138
+ if (error.status === void 0 || error.status === 0 || error.data === void 0) {
1139
+ return new NetworksResponseError$1({
1140
+ title: error.title,
1141
+ status_code: error.status_code,
1142
+ exception: error.exception
1143
+ });
1144
+ }
1145
+ }
1146
+ return {
1147
+ title: typeof error.title === "string" ? error.title : "Unexpected error",
1148
+ message: typeof error.message === "string" ? error.message : "Something went wrong."
1149
+ };
1150
+ }
1151
+ }
1152
+
1153
+ function isError(error) {
1154
+ if (isObject$1(error)) {
1155
+ return error.status_code && error.exception && error.title;
1048
1156
  }
1157
+ return false;
1049
1158
  }
1050
1159
 
1051
1160
  var __defProp$b = Object.defineProperty;
1052
1161
  var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1053
- var __publicField$6 = (obj, key, value) => __defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
1162
+ var __publicField$7 = (obj, key, value) => __defNormalProp$b(obj, key + "" , value);
1163
+ class NetworkError extends Error {
1164
+ constructor(url) {
1165
+ super();
1166
+ __publicField$7(this, "name", "NetworkError");
1167
+ Object.setPrototypeOf(this, NetworkError.prototype);
1168
+ this.message = `Unable to request ${url}.
1169
+ Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`;
1170
+ }
1171
+ }
1172
+
1173
+ var __defProp$a = Object.defineProperty;
1174
+ var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1175
+ var __publicField$6 = (obj, key, value) => __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
1176
+ class ResourceNotFoundError extends NgwError {
1177
+ constructor(obj) {
1178
+ super(obj);
1179
+ __publicField$6(this, "name", "ResourceNotFoundError");
1180
+ __publicField$6(this, "exception", "nextgisweb.resource.exception.ResourceNotFound");
1181
+ Object.setPrototypeOf(this, ResourceNotFoundError.prototype);
1182
+ }
1183
+ }
1184
+
1185
+ var errors = /*#__PURE__*/Object.freeze({
1186
+ __proto__: null,
1187
+ AbortError: AbortError,
1188
+ InsufficientPermissionsError: InsufficientPermissionsError,
1189
+ NetworkError: NetworkError,
1190
+ NetworksResponseError: NetworksResponseError$1,
1191
+ NgwError: NgwError,
1192
+ ResourceNotFoundError: ResourceNotFoundError,
1193
+ extractError: extractError,
1194
+ isError: isError
1195
+ });
1196
+
1197
+ var __defProp$9 = Object.defineProperty;
1198
+ var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1199
+ var __publicField$5 = (obj, key, value) => __defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
1054
1200
  class BaseAPIError extends Error {
1055
1201
  constructor(message) {
1056
1202
  super(message || "Something went wrong.");
1057
- __publicField$6(this, "title");
1203
+ __publicField$5(this, "title");
1058
1204
  this.name = "BaseAPIError";
1059
1205
  this.title = "Unknown API error";
1060
1206
  if (Error.captureStackTrace) {
@@ -1066,7 +1212,7 @@ class NetworksResponseError extends BaseAPIError {
1066
1212
  // prettier-ignore
1067
1213
  constructor(message) {
1068
1214
  super(message || "There is no response from the server or problem connecting to server.");
1069
- __publicField$6(this, "detail");
1215
+ __publicField$5(this, "detail");
1070
1216
  this.title = "Network error";
1071
1217
  this.detail = "Check network connectivity and try again later.";
1072
1218
  }
@@ -1080,8 +1226,8 @@ class InvalidResponseError extends BaseAPIError {
1080
1226
  class ServerResponseError extends BaseAPIError {
1081
1227
  constructor(data) {
1082
1228
  super(data.message);
1083
- __publicField$6(this, "detail");
1084
- __publicField$6(this, "data");
1229
+ __publicField$5(this, "detail");
1230
+ __publicField$5(this, "data");
1085
1231
  this.title = data.title || this.title;
1086
1232
  this.detail = data.detail || null;
1087
1233
  this.data = data;
@@ -1091,8 +1237,8 @@ class LunkwillError extends Error {
1091
1237
  // prettier-ignore
1092
1238
  constructor(message, data = {}) {
1093
1239
  super(message || "Unexpected error while processing long-running request.");
1094
- __publicField$6(this, "title");
1095
- __publicField$6(this, "data");
1240
+ __publicField$5(this, "title");
1241
+ __publicField$5(this, "data");
1096
1242
  this.name = "LunkwillError";
1097
1243
  this.title = "Long-running request error";
1098
1244
  this.data = data;
@@ -1112,35 +1258,35 @@ class LunkwillRequestFailed extends LunkwillError {
1112
1258
  }
1113
1259
  }
1114
1260
 
1115
- var __defProp$a = Object.defineProperty;
1116
- var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
1117
- var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
1118
- var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
1119
- var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1120
- var __spreadValues$7 = (a, b) => {
1261
+ var __defProp$8 = Object.defineProperty;
1262
+ var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
1263
+ var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
1264
+ var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
1265
+ var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1266
+ var __spreadValues$6 = (a, b) => {
1121
1267
  for (var prop in b || (b = {}))
1122
- if (__hasOwnProp$7.call(b, prop))
1123
- __defNormalProp$a(a, prop, b[prop]);
1124
- if (__getOwnPropSymbols$7)
1125
- for (var prop of __getOwnPropSymbols$7(b)) {
1126
- if (__propIsEnum$7.call(b, prop))
1127
- __defNormalProp$a(a, prop, b[prop]);
1268
+ if (__hasOwnProp$6.call(b, prop))
1269
+ __defNormalProp$8(a, prop, b[prop]);
1270
+ if (__getOwnPropSymbols$6)
1271
+ for (var prop of __getOwnPropSymbols$6(b)) {
1272
+ if (__propIsEnum$6.call(b, prop))
1273
+ __defNormalProp$8(a, prop, b[prop]);
1128
1274
  }
1129
1275
  return a;
1130
1276
  };
1131
1277
  var __objRest$2 = (source, exclude) => {
1132
1278
  var target = {};
1133
1279
  for (var prop in source)
1134
- if (__hasOwnProp$7.call(source, prop) && exclude.indexOf(prop) < 0)
1280
+ if (__hasOwnProp$6.call(source, prop) && exclude.indexOf(prop) < 0)
1135
1281
  target[prop] = source[prop];
1136
- if (source != null && __getOwnPropSymbols$7)
1137
- for (var prop of __getOwnPropSymbols$7(source)) {
1138
- if (exclude.indexOf(prop) < 0 && __propIsEnum$7.call(source, prop))
1282
+ if (source != null && __getOwnPropSymbols$6)
1283
+ for (var prop of __getOwnPropSymbols$6(source)) {
1284
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$6.call(source, prop))
1139
1285
  target[prop] = source[prop];
1140
1286
  }
1141
1287
  return target;
1142
1288
  };
1143
- var __async$6 = (__this, __arguments, generator) => {
1289
+ var __async$5 = (__this, __arguments, generator) => {
1144
1290
  return new Promise((resolve, reject) => {
1145
1291
  var fulfilled = (value) => {
1146
1292
  try {
@@ -1165,7 +1311,7 @@ function lunkwillCheckResponse(lwResp) {
1165
1311
  return ct !== void 0 && ct !== null && ct.includes("application/vnd.lunkwill.request-summary+json");
1166
1312
  }
1167
1313
  function responseJson(response) {
1168
- return __async$6(this, null, function* () {
1314
+ return __async$5(this, null, function* () {
1169
1315
  try {
1170
1316
  return response.json();
1171
1317
  } catch (e) {
@@ -1174,7 +1320,7 @@ function responseJson(response) {
1174
1320
  });
1175
1321
  }
1176
1322
  function lunkwillResponseUrl(lwResp) {
1177
- return __async$6(this, null, function* () {
1323
+ return __async$5(this, null, function* () {
1178
1324
  const lwData = yield responseJson(lwResp);
1179
1325
  let delay = lwData.delay_ms;
1180
1326
  const retry = lwData.retry_ms !== void 0 ? lwData.retry_ms : 2e3;
@@ -1218,7 +1364,7 @@ function lunkwillResponseUrl(lwResp) {
1218
1364
  });
1219
1365
  }
1220
1366
  function lunkwillFetch(lwRespUrl) {
1221
- return __async$6(this, null, function* () {
1367
+ return __async$5(this, null, function* () {
1222
1368
  try {
1223
1369
  return yield window.fetch(lwRespUrl, { credentials: "same-origin" });
1224
1370
  } catch (e) {
@@ -1266,14 +1412,14 @@ function generateUrl(path, query) {
1266
1412
  return path + urlParams;
1267
1413
  }
1268
1414
  function request(path, options, cacheEngine) {
1269
- return __async$6(this, null, function* () {
1270
- var _b;
1415
+ return __async$5(this, null, function* () {
1416
+ var _b, _c;
1271
1417
  const defaults = {
1272
1418
  method: "GET",
1273
1419
  credentials: "same-origin",
1274
1420
  headers: {}
1275
1421
  };
1276
- const _a = __spreadValues$7(__spreadValues$7({}, defaults), options), {
1422
+ const _a = __spreadValues$6(__spreadValues$6({}, defaults), options), {
1277
1423
  withCredentials,
1278
1424
  responseType,
1279
1425
  cacheProps,
@@ -1292,6 +1438,7 @@ function request(path, options, cacheEngine) {
1292
1438
  "query",
1293
1439
  "json"
1294
1440
  ]);
1441
+ opt.method = (_b = opt.method) == null ? void 0 : _b.toUpperCase();
1295
1442
  if (withCredentials) {
1296
1443
  opt.credentials = "include";
1297
1444
  }
@@ -1309,12 +1456,12 @@ function request(path, options, cacheEngine) {
1309
1456
  opt.headers = headers;
1310
1457
  }
1311
1458
  const url = generateUrl(path, query);
1312
- const makeRequest = () => __async$6(this, null, function* () {
1459
+ const makeRequest = () => __async$5(null, null, function* () {
1313
1460
  let response;
1314
1461
  try {
1315
1462
  response = yield fetch(url, opt);
1316
1463
  } catch (e) {
1317
- if (e.name === "AbortError") {
1464
+ if (opt.signal && opt.signal.aborted) {
1318
1465
  throw e;
1319
1466
  }
1320
1467
  throw new NetworksResponseError();
@@ -1349,49 +1496,61 @@ function request(path, options, cacheEngine) {
1349
1496
  }
1350
1497
  return body;
1351
1498
  });
1352
- if (cacheEngine && cache && ((_b = opt.method) == null ? void 0 : _b.toUpperCase()) === "GET") {
1353
- const cacheOptions = cacheProps ? cacheProps : __spreadValues$7({}, objectRemoveEmpty({
1354
- withCredentials,
1355
- responseType
1356
- }));
1357
- return cacheEngine.add(cacheName || url, makeRequest, cacheOptions, false);
1499
+ if (cacheEngine) {
1500
+ if (((_c = opt.method) == null ? void 0 : _c.toUpperCase()) === "GET") {
1501
+ if (cache !== false) {
1502
+ const props = cacheProps ? cacheProps : __spreadValues$6({}, objectRemoveEmpty({
1503
+ withCredentials,
1504
+ responseType
1505
+ }));
1506
+ return cacheEngine.add(cacheName || url, makeRequest, {
1507
+ props,
1508
+ expirationTime: cache ? void 0 : 500
1509
+ });
1510
+ }
1511
+ } else {
1512
+ const ignoredForClean = ["api/feature_layer/identify"];
1513
+ if (ignoredForClean.every((part) => !path.includes(part))) {
1514
+ cacheEngine.clean();
1515
+ }
1516
+ }
1358
1517
  }
1359
1518
  return makeRequest();
1360
1519
  });
1361
1520
  }
1362
1521
 
1363
- var __defProp$9 = Object.defineProperty;
1364
- var __defProps$3 = Object.defineProperties;
1365
- var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
1366
- var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
1367
- var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
1368
- var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
1369
- var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1370
- var __spreadValues$6 = (a, b) => {
1371
- for (var prop in b || (b = {}))
1372
- if (__hasOwnProp$6.call(b, prop))
1373
- __defNormalProp$9(a, prop, b[prop]);
1374
- if (__getOwnPropSymbols$6)
1375
- for (var prop of __getOwnPropSymbols$6(b)) {
1376
- if (__propIsEnum$6.call(b, prop))
1377
- __defNormalProp$9(a, prop, b[prop]);
1522
+ var __defProp$7 = Object.defineProperty;
1523
+ var __defProps$4 = Object.defineProperties;
1524
+ var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
1525
+ var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
1526
+ var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
1527
+ var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
1528
+ var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1529
+ var __spreadValues$5 = (a, b) => {
1530
+ for (var prop in b || (b = {}))
1531
+ if (__hasOwnProp$5.call(b, prop))
1532
+ __defNormalProp$7(a, prop, b[prop]);
1533
+ if (__getOwnPropSymbols$5)
1534
+ for (var prop of __getOwnPropSymbols$5(b)) {
1535
+ if (__propIsEnum$5.call(b, prop))
1536
+ __defNormalProp$7(a, prop, b[prop]);
1378
1537
  }
1379
1538
  return a;
1380
1539
  };
1381
- var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
1540
+ var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
1382
1541
  var __objRest$1 = (source, exclude) => {
1383
1542
  var target = {};
1384
1543
  for (var prop in source)
1385
- if (__hasOwnProp$6.call(source, prop) && exclude.indexOf(prop) < 0)
1544
+ if (__hasOwnProp$5.call(source, prop) && exclude.indexOf(prop) < 0)
1386
1545
  target[prop] = source[prop];
1387
- if (source != null && __getOwnPropSymbols$6)
1388
- for (var prop of __getOwnPropSymbols$6(source)) {
1389
- if (exclude.indexOf(prop) < 0 && __propIsEnum$6.call(source, prop))
1546
+ if (source != null && __getOwnPropSymbols$5)
1547
+ for (var prop of __getOwnPropSymbols$5(source)) {
1548
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$5.call(source, prop))
1390
1549
  target[prop] = source[prop];
1391
1550
  }
1392
1551
  return target;
1393
1552
  };
1394
- var __async$5 = (__this, __arguments, generator) => {
1553
+ var __async$4 = (__this, __arguments, generator) => {
1395
1554
  return new Promise((resolve, reject) => {
1396
1555
  var fulfilled = (value) => {
1397
1556
  try {
@@ -1442,7 +1601,7 @@ function routeURL(name, baseUrl, routeData, ...rest) {
1442
1601
  }
1443
1602
  function route(name, connector, ...rest) {
1444
1603
  const result = {
1445
- url: (opt) => __async$5(this, null, function* () {
1604
+ url: (opt) => __async$4(null, null, function* () {
1446
1605
  var _a;
1447
1606
  const routeData = yield connector.connect();
1448
1607
  const template = routeURL(
@@ -1456,45 +1615,37 @@ function route(name, connector, ...rest) {
1456
1615
  };
1457
1616
  const methods = ["get", "post", "put", "delete", "patch"];
1458
1617
  for (const method of methods) {
1459
- const methodResp = (requestOptions) => __async$5(this, null, function* () {
1618
+ const methodResp = (requestOptions) => {
1460
1619
  var _b;
1461
1620
  const _a = requestOptions || {}, { headers: optHeaders } = _a, restOpt = __objRest$1(_a, ["headers"]);
1462
- const routeData = yield connector.connect();
1463
- const template = routeURL(
1464
- name,
1465
- (_b = connector.options.baseUrl) != null ? _b : "",
1466
- routeData,
1467
- ...rest
1468
- );
1469
- const headers = objectRemoveEmpty(__spreadValues$6(__spreadValues$6({}, connector.getAuthorizationHeaders()), optHeaders != null ? optHeaders : {}));
1470
- return request(
1471
- template,
1472
- __spreadProps$3(__spreadValues$6({
1473
- headers
1474
- }, restOpt), {
1475
- method
1476
- }),
1477
- connector.cache
1478
- );
1479
- });
1621
+ if ((_b = requestOptions == null ? void 0 : requestOptions.signal) == null ? void 0 : _b.aborted) {
1622
+ throw new AbortError();
1623
+ }
1624
+ return connector.connect().then((routeData) => {
1625
+ var _a2;
1626
+ const template = routeURL(
1627
+ name,
1628
+ (_a2 = connector.options.baseUrl) != null ? _a2 : "",
1629
+ routeData,
1630
+ ...rest
1631
+ );
1632
+ const headers = objectRemoveEmpty(__spreadValues$5(__spreadValues$5({}, connector.getAuthorizationHeaders()), optHeaders != null ? optHeaders : {}));
1633
+ return request(
1634
+ template,
1635
+ __spreadProps$4(__spreadValues$5({
1636
+ headers
1637
+ }, restOpt), {
1638
+ method
1639
+ }),
1640
+ connector.cache
1641
+ );
1642
+ });
1643
+ };
1480
1644
  result[method] = methodResp;
1481
1645
  }
1482
1646
  return result;
1483
1647
  }
1484
1648
 
1485
- var __defProp$8 = Object.defineProperty;
1486
- var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1487
- var __publicField$5 = (obj, key, value) => __defNormalProp$8(obj, key + "" , value);
1488
- class NetworkError extends Error {
1489
- constructor(url) {
1490
- super();
1491
- __publicField$5(this, "name", "NetworkError");
1492
- Object.setPrototypeOf(this, NetworkError.prototype);
1493
- this.message = `Unable to request ${url}.
1494
- Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`;
1495
- }
1496
- }
1497
-
1498
1649
  function isObject(val) {
1499
1650
  return Object.prototype.toString.call(val) === "[object Object]";
1500
1651
  }
@@ -1511,7 +1662,7 @@ let loadData;
1511
1662
  const getResponseText = () => {
1512
1663
  try {
1513
1664
  return JSON.parse(xhr.responseText);
1514
- } catch (er) {
1665
+ } catch (e) {
1515
1666
  return xhr.responseText;
1516
1667
  }
1517
1668
  };
@@ -1581,52 +1732,63 @@ let loadData;
1581
1732
  };
1582
1733
  }
1583
1734
 
1584
- const templateRe = /\{ *([\w_-]+) *\}/g;
1585
- function template(str, data) {
1586
- return str.replace(templateRe, (s, key) => {
1587
- let value = data[key];
1588
- if (value === void 0) {
1589
- throw new Error("No value provided for letiable " + s);
1590
- } else if (typeof value === "function") {
1591
- value = value(data);
1735
+ const CONNECTORS = [];
1736
+ function addConnector(connector) {
1737
+ CONNECTORS.push(connector);
1738
+ }
1739
+ function findConnector(options) {
1740
+ return CONNECTORS.find((x) => {
1741
+ if (x.options.baseUrl === options.baseUrl) {
1742
+ if (options.auth) {
1743
+ if (x.options.auth) {
1744
+ return objectDeepEqual(x.options.auth, options.auth);
1745
+ }
1746
+ } else {
1747
+ return true;
1748
+ }
1592
1749
  }
1593
- return value;
1594
1750
  });
1595
1751
  }
1752
+ function removeConnector(connector) {
1753
+ const index = CONNECTORS.indexOf(connector);
1754
+ if (index !== -1) {
1755
+ CONNECTORS.splice(index, 1);
1756
+ }
1757
+ }
1596
1758
 
1597
- var __defProp$7 = Object.defineProperty;
1598
- var __defProps$2 = Object.defineProperties;
1599
- var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
1600
- var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
1601
- var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
1602
- var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
1603
- var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1604
- var __spreadValues$5 = (a, b) => {
1759
+ var __defProp$6 = Object.defineProperty;
1760
+ var __defProps$3 = Object.defineProperties;
1761
+ var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
1762
+ var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
1763
+ var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
1764
+ var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
1765
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1766
+ var __spreadValues$4 = (a, b) => {
1605
1767
  for (var prop in b || (b = {}))
1606
- if (__hasOwnProp$5.call(b, prop))
1607
- __defNormalProp$7(a, prop, b[prop]);
1608
- if (__getOwnPropSymbols$5)
1609
- for (var prop of __getOwnPropSymbols$5(b)) {
1610
- if (__propIsEnum$5.call(b, prop))
1611
- __defNormalProp$7(a, prop, b[prop]);
1768
+ if (__hasOwnProp$4.call(b, prop))
1769
+ __defNormalProp$6(a, prop, b[prop]);
1770
+ if (__getOwnPropSymbols$4)
1771
+ for (var prop of __getOwnPropSymbols$4(b)) {
1772
+ if (__propIsEnum$4.call(b, prop))
1773
+ __defNormalProp$6(a, prop, b[prop]);
1612
1774
  }
1613
1775
  return a;
1614
1776
  };
1615
- var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
1777
+ var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
1616
1778
  var __objRest = (source, exclude) => {
1617
1779
  var target = {};
1618
1780
  for (var prop in source)
1619
- if (__hasOwnProp$5.call(source, prop) && exclude.indexOf(prop) < 0)
1781
+ if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
1620
1782
  target[prop] = source[prop];
1621
- if (source != null && __getOwnPropSymbols$5)
1622
- for (var prop of __getOwnPropSymbols$5(source)) {
1623
- if (exclude.indexOf(prop) < 0 && __propIsEnum$5.call(source, prop))
1783
+ if (source != null && __getOwnPropSymbols$4)
1784
+ for (var prop of __getOwnPropSymbols$4(source)) {
1785
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
1624
1786
  target[prop] = source[prop];
1625
1787
  }
1626
1788
  return target;
1627
1789
  };
1628
- var __publicField$4 = (obj, key, value) => __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
1629
- var __async$4 = (__this, __arguments, generator) => {
1790
+ var __publicField$4 = (obj, key, value) => __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
1791
+ var __async$3 = (__this, __arguments, generator) => {
1630
1792
  return new Promise((resolve, reject) => {
1631
1793
  var fulfilled = (value) => {
1632
1794
  try {
@@ -1656,12 +1818,16 @@ class NgwConnector {
1656
1818
  __publicField$4(this, "user");
1657
1819
  __publicField$4(this, "cache");
1658
1820
  __publicField$4(this, "withCredentials");
1821
+ // Dedicated cache for route requests, as these are executed before any other requests.
1822
+ // This cache does not need to be cleared during the session.
1823
+ __publicField$4(this, "routeCache");
1659
1824
  __publicField$4(this, "client", `NextGIS-NGW-Connector/${pkg.version}`);
1660
1825
  __publicField$4(this, "routeStr", "/api/component/pyramid/route");
1661
1826
  __publicField$4(this, "activeRequests", {});
1662
1827
  __publicField$4(this, "requestTransform");
1663
1828
  const exist = findConnector(options);
1664
1829
  this.cache = new Cache({ namespace: options.cacheId });
1830
+ this.routeCache = new Cache({ namespace: "routecache" });
1665
1831
  if (exist) {
1666
1832
  return exist;
1667
1833
  } else {
@@ -1711,7 +1877,9 @@ class NgwConnector {
1711
1877
  * ```
1712
1878
  */
1713
1879
  connect() {
1714
- return __async$4(this, null, function* () {
1880
+ return __async$3(this, arguments, function* ({
1881
+ signal
1882
+ } = {}) {
1715
1883
  const auth = this.options.auth;
1716
1884
  if (auth) {
1717
1885
  const { login, password } = auth;
@@ -1720,18 +1888,9 @@ class NgwConnector {
1720
1888
  }
1721
1889
  }
1722
1890
  const routeUrl = `${this.routeStr}?client=${this.client}`;
1723
- return yield this.makeQuery(
1724
- routeUrl,
1725
- {},
1726
- {
1727
- cacheName: "route",
1728
- cache: true,
1729
- cacheProps: {
1730
- id: this.id,
1731
- auth,
1732
- baseUrl: this.options.baseUrl
1733
- }
1734
- }
1891
+ return this.routeCache.add(
1892
+ this.options.baseUrl || String(this.id),
1893
+ () => this.makeQuery(routeUrl, null, { signal, cache: false })
1735
1894
  );
1736
1895
  });
1737
1896
  }
@@ -1752,18 +1911,19 @@ class NgwConnector {
1752
1911
  removeConnector(this);
1753
1912
  this.options.auth = void 0;
1754
1913
  this.user = void 0;
1914
+ this.routeCache.clean();
1755
1915
  this.clearCache();
1756
1916
  this.emitter.emit("logout");
1757
1917
  }
1758
1918
  getUserInfo(credentials, options) {
1759
- return __async$4(this, null, function* () {
1919
+ return __async$3(this, null, function* () {
1760
1920
  if (this.user && this.user.id) {
1761
1921
  return this.user;
1762
1922
  }
1763
1923
  if (credentials) {
1764
1924
  this.options.auth = credentials;
1765
1925
  }
1766
- const options_ = __spreadValues$5({
1926
+ const options_ = __spreadValues$4({
1767
1927
  headers: this.getAuthorizationHeaders(credentials),
1768
1928
  cache: true
1769
1929
  }, options);
@@ -1804,7 +1964,7 @@ class NgwConnector {
1804
1964
  this.activeRequests = {};
1805
1965
  }
1806
1966
  getActiveApiRequests() {
1807
- return __spreadValues$5({}, this.activeRequests);
1967
+ return __spreadValues$4({}, this.activeRequests);
1808
1968
  }
1809
1969
  route(name, ...rest) {
1810
1970
  return route(name, this, ...rest);
@@ -1816,7 +1976,7 @@ class NgwConnector {
1816
1976
  * @param options - Request options
1817
1977
  */
1818
1978
  makeQuery(_0, _1) {
1819
- return __async$4(this, arguments, function* (url, params, options = {}) {
1979
+ return __async$3(this, arguments, function* (url, params, options = {}) {
1820
1980
  var _b;
1821
1981
  url = (this.options.baseUrl ? this.options.baseUrl : "") + url;
1822
1982
  if (!url) {
@@ -1827,7 +1987,7 @@ class NgwConnector {
1827
1987
  url = template(url, restParams);
1828
1988
  }
1829
1989
  url = encodeURI(fixUrlStr(url));
1830
- options = __spreadValues$5({ withCredentials: this.withCredentials }, options);
1990
+ options = __spreadValues$4({ withCredentials: this.withCredentials }, options);
1831
1991
  const {
1832
1992
  cache,
1833
1993
  signal: externalSignal,
@@ -1849,7 +2009,7 @@ class NgwConnector {
1849
2009
  });
1850
2010
  }
1851
2011
  options.signal = internalSignal;
1852
- const createPromise = () => __async$4(this, null, function* () {
2012
+ const createPromise = () => __async$3(this, null, function* () {
1853
2013
  const id = REQUEST_ID++;
1854
2014
  this.activeRequests[id] = internalAbortController;
1855
2015
  try {
@@ -1858,8 +2018,8 @@ class NgwConnector {
1858
2018
  this._cleanActiveRequest(id);
1859
2019
  }
1860
2020
  });
1861
- if (method === "GET") {
1862
- const cacheOptions = cacheProps ? cacheProps : __spreadProps$2(__spreadValues$5({}, objectRemoveEmpty({
2021
+ if (method === "GET" && cache !== false) {
2022
+ const cacheOptions = cacheProps ? cacheProps : __spreadProps$3(__spreadValues$4({}, objectRemoveEmpty({
1863
2023
  headers,
1864
2024
  withCredentials,
1865
2025
  responseType,
@@ -1882,7 +2042,7 @@ class NgwConnector {
1882
2042
  var _a;
1883
2043
  if (this.user) {
1884
2044
  options = options || {};
1885
- options.headers = __spreadValues$5(__spreadValues$5({}, this.getAuthorizationHeaders()), options.headers);
2045
+ options.headers = __spreadValues$4(__spreadValues$4({}, this.getAuthorizationHeaders()), options.headers);
1886
2046
  }
1887
2047
  if (this.requestTransform) {
1888
2048
  const [transUrl, transOptions] = this.requestTransform(url, options);
@@ -1913,7 +2073,7 @@ class NgwConnector {
1913
2073
  });
1914
2074
  }
1915
2075
  _login(credentials, options) {
1916
- return __async$4(this, null, function* () {
2076
+ return __async$3(this, null, function* () {
1917
2077
  try {
1918
2078
  const data = yield this.getUserInfo(credentials, options);
1919
2079
  this.user = data;
@@ -1941,10 +2101,7 @@ class NgwConnector {
1941
2101
  return er;
1942
2102
  }
1943
2103
  }
1944
- __publicField$4(NgwConnector, "errors", {
1945
- NgwError,
1946
- ResourceNotFoundError
1947
- });
2104
+ __publicField$4(NgwConnector, "errors", errors);
1948
2105
 
1949
2106
  function resourceCompare(res1, res2) {
1950
2107
  return objectDeepEqual(res1, res2);
@@ -1958,7 +2115,10 @@ function resourceToQuery(resource, prefix = "") {
1958
2115
  if (exclude.indexOf(key) === -1) {
1959
2116
  if (isObject(value)) {
1960
2117
  if (key === "owner_user") {
1961
- const children = resourceToQuery(value, key);
2118
+ const children = resourceToQuery(
2119
+ value,
2120
+ key
2121
+ );
1962
2122
  Object.assign(query, children);
1963
2123
  } else if (key === "parent" && "id" in value) {
1964
2124
  query.parent_id = value.id;
@@ -1971,24 +2131,27 @@ function resourceToQuery(resource, prefix = "") {
1971
2131
  return query;
1972
2132
  }
1973
2133
 
1974
- var __defProp$6 = Object.defineProperty;
1975
- var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
1976
- var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
1977
- var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
1978
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1979
- var __spreadValues$4 = (a, b) => {
2134
+ var __defProp$5 = Object.defineProperty;
2135
+ var __defProps$2 = Object.defineProperties;
2136
+ var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
2137
+ var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
2138
+ var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
2139
+ var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
2140
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2141
+ var __spreadValues$3 = (a, b) => {
1980
2142
  for (var prop in b || (b = {}))
1981
- if (__hasOwnProp$4.call(b, prop))
1982
- __defNormalProp$6(a, prop, b[prop]);
1983
- if (__getOwnPropSymbols$4)
1984
- for (var prop of __getOwnPropSymbols$4(b)) {
1985
- if (__propIsEnum$4.call(b, prop))
1986
- __defNormalProp$6(a, prop, b[prop]);
2143
+ if (__hasOwnProp$3.call(b, prop))
2144
+ __defNormalProp$5(a, prop, b[prop]);
2145
+ if (__getOwnPropSymbols$3)
2146
+ for (var prop of __getOwnPropSymbols$3(b)) {
2147
+ if (__propIsEnum$3.call(b, prop))
2148
+ __defNormalProp$5(a, prop, b[prop]);
1987
2149
  }
1988
2150
  return a;
1989
2151
  };
1990
- var __publicField$3 = (obj, key, value) => __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
1991
- var __async$3 = (__this, __arguments, generator) => {
2152
+ var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
2153
+ var __publicField$3 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
2154
+ var __async$2 = (__this, __arguments, generator) => {
1992
2155
  return new Promise((resolve, reject) => {
1993
2156
  var fulfilled = (value) => {
1994
2157
  try {
@@ -2029,7 +2192,7 @@ class ResourcesControl {
2029
2192
  * Fetching resource would be cached to speed up next call
2030
2193
  */
2031
2194
  getOne(resource, requestOptions) {
2032
- const opt = __spreadValues$4({}, requestOptions);
2195
+ const opt = __spreadValues$3({}, requestOptions);
2033
2196
  if (typeof resource === "string") ; else if (typeof resource === "number") ; else if (isObject(resource)) {
2034
2197
  if (resource.id !== void 0) {
2035
2198
  resource.id;
@@ -2106,9 +2269,11 @@ class ResourcesControl {
2106
2269
  } else {
2107
2270
  Object.assign(query, resourceToQuery(resource));
2108
2271
  }
2109
- return this.connector.get("resource.search", requestOptions, __spreadValues$4({
2110
- serialization: "full"
2111
- }, query)).then((resources) => {
2272
+ return this.connector.route("resource.search").get(__spreadProps$2(__spreadValues$3({}, requestOptions), {
2273
+ query: __spreadValues$3({
2274
+ serialization: "full"
2275
+ }, query)
2276
+ })).then((resources) => {
2112
2277
  if ((requestOptions == null ? void 0 : requestOptions.cache) && resources) {
2113
2278
  for (const x of resources) {
2114
2279
  this.cache.add("resource.item", Promise.resolve(x), {
@@ -2124,7 +2289,8 @@ class ResourcesControl {
2124
2289
  }
2125
2290
  getParent(resource, requestOptions) {
2126
2291
  return this.getOne(resource, requestOptions).then((child) => {
2127
- if (child) {
2292
+ var _a, _b;
2293
+ if ((_b = (_a = child == null ? void 0 : child.resource) == null ? void 0 : _a.parent) == null ? void 0 : _b.id) {
2128
2294
  return this.getOne(child.resource.parent.id, requestOptions);
2129
2295
  }
2130
2296
  return Promise.resolve(void 0);
@@ -2156,10 +2322,21 @@ class ResourcesControl {
2156
2322
  }
2157
2323
  });
2158
2324
  }
2159
- _getChildrenOf(parent, requestOptions, _items = []) {
2160
- return this.connector.get("resource.collection", requestOptions, {
2161
- parent
2162
- }).then((items) => {
2325
+ _getChildrenOf(_0, _1) {
2326
+ return __async$2(this, arguments, function* (parentDef, requestOptions, _items = []) {
2327
+ let parent = void 0;
2328
+ if (typeof parentDef === "string") {
2329
+ parent = yield this.getId(parentDef, requestOptions);
2330
+ } else if (typeof parentDef === "object") {
2331
+ parent = parentDef.id;
2332
+ } else {
2333
+ parent = parentDef;
2334
+ }
2335
+ const items = yield this.connector.route("resource.collection").get(__spreadProps$2(__spreadValues$3({}, requestOptions), {
2336
+ query: {
2337
+ parent
2338
+ }
2339
+ }));
2163
2340
  const recursivePromises = [];
2164
2341
  for (const item of items) {
2165
2342
  if (requestOptions == null ? void 0 : requestOptions.cache) {
@@ -2183,7 +2360,7 @@ class ResourcesControl {
2183
2360
  });
2184
2361
  }
2185
2362
  _cleanResourceItemCache(id) {
2186
- return __async$3(this, null, function* () {
2363
+ return __async$2(this, null, function* () {
2187
2364
  var _a;
2188
2365
  const all = this.cache.all();
2189
2366
  const toDelete = [];
@@ -2208,7 +2385,7 @@ class ResourcesControl {
2208
2385
  });
2209
2386
  }
2210
2387
  _fetchResourceById(id, requestOptions) {
2211
- return this.connector.get("resource.item", requestOptions, { id });
2388
+ return this.connector.route("resource.item", { id }).get(requestOptions);
2212
2389
  }
2213
2390
  _fetchResourceBy(resource, requestOptions) {
2214
2391
  return this.getMany(resource, requestOptions).then((resources) => {
@@ -2236,93 +2413,6 @@ class ResourcesControl {
2236
2413
  }
2237
2414
  }
2238
2415
 
2239
- var __defProp$5 = Object.defineProperty;
2240
- var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
2241
- var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
2242
- var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
2243
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2244
- var __spreadValues$3 = (a, b) => {
2245
- for (var prop in b || (b = {}))
2246
- if (__hasOwnProp$3.call(b, prop))
2247
- __defNormalProp$5(a, prop, b[prop]);
2248
- if (__getOwnPropSymbols$3)
2249
- for (var prop of __getOwnPropSymbols$3(b)) {
2250
- if (__propIsEnum$3.call(b, prop))
2251
- __defNormalProp$5(a, prop, b[prop]);
2252
- }
2253
- return a;
2254
- };
2255
- var __async$2 = (__this, __arguments, generator) => {
2256
- return new Promise((resolve, reject) => {
2257
- var fulfilled = (value) => {
2258
- try {
2259
- step(generator.next(value));
2260
- } catch (e) {
2261
- reject(e);
2262
- }
2263
- };
2264
- var rejected = (value) => {
2265
- try {
2266
- step(generator.throw(value));
2267
- } catch (e) {
2268
- reject(e);
2269
- }
2270
- };
2271
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
2272
- step((generator = generator.apply(__this, __arguments)).next());
2273
- });
2274
- };
2275
- function apiRequest(opt) {
2276
- return __async$2(this, null, function* () {
2277
- const { params, name, connector, requestOptions } = opt;
2278
- const apiItems = yield connector.connect();
2279
- let apiItem = apiItems && apiItems[name];
2280
- if (apiItem) {
2281
- apiItem = [...apiItem];
2282
- let url = apiItem.shift();
2283
- if (apiItem.length) {
2284
- const replaceParams = {};
2285
- for (let fry = 0; fry < apiItem.length; fry++) {
2286
- const arg = apiItem[fry];
2287
- replaceParams[fry] = `{${arg}}`;
2288
- if (params[arg] === void 0) {
2289
- throw new Error(`\`${arg}\` URL API argument is not specified`);
2290
- }
2291
- }
2292
- if (url) {
2293
- url = template(url, replaceParams);
2294
- }
2295
- }
2296
- if (params) {
2297
- const paramArray = [];
2298
- const paramList = params.paramList;
2299
- if (Array.isArray(paramList)) {
2300
- paramList.forEach(([key, value]) => {
2301
- paramArray.push(`${key}=${value}`);
2302
- });
2303
- }
2304
- for (const p in params) {
2305
- if (apiItem.indexOf(p) === -1) {
2306
- paramArray.push(`${p}=${params[p]}`);
2307
- }
2308
- }
2309
- if (paramArray.length) {
2310
- url = `${url}?${paramArray.join("&")}`;
2311
- }
2312
- }
2313
- if (url) {
2314
- return connector.makeQuery(url, params, __spreadValues$3({
2315
- cacheName: name
2316
- }, requestOptions));
2317
- } else {
2318
- throw new Error("Request URL is not set");
2319
- }
2320
- } else {
2321
- return void 0;
2322
- }
2323
- });
2324
- }
2325
-
2326
2416
  var __defProp$4 = Object.defineProperty;
2327
2417
  var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2328
2418
  var __publicField$2 = (obj, key, value) => __defNormalProp$4(obj, key + "" , value);
@@ -2650,19 +2740,17 @@ var __async$1 = (__this, __arguments, generator) => {
2650
2740
  };
2651
2741
  const FEATURE_REQUEST_PARAMS = {
2652
2742
  srs: 4326,
2653
- geom_format: "geojson"
2743
+ geom_format: "geojson",
2744
+ dt_format: "iso"
2654
2745
  };
2655
2746
  function updateItemRequestParam(params, options) {
2656
2747
  const { extensions, geom, fields, srs, ilike, like } = options;
2657
- const extensionsStr = extensions ? extensions.join(",") : "";
2658
- if (extensionsStr !== "*") {
2659
- params.extensions = extensionsStr;
2660
- }
2661
- if (fields !== void 0 && fields !== null) {
2662
- params.fields = Array.isArray(fields) ? fields.join(",") : "";
2748
+ params.extensions = extensions ? extensions : [];
2749
+ if (fields) {
2750
+ params.fields = fields;
2663
2751
  }
2664
2752
  if (geom !== void 0) {
2665
- params.geom = geom ? "yes" : "no";
2753
+ params.geom = geom;
2666
2754
  if (!geom) {
2667
2755
  delete params.srs;
2668
2756
  delete params.geom_format;
@@ -2677,6 +2765,15 @@ function updateItemRequestParam(params, options) {
2677
2765
  params.srs = srs;
2678
2766
  }
2679
2767
  }
2768
+ function paramListToQuery(paramList) {
2769
+ return paramList.reduce(
2770
+ (acc, [key, value]) => {
2771
+ acc[key] = value;
2772
+ return acc;
2773
+ },
2774
+ {}
2775
+ );
2776
+ }
2680
2777
  function createFeatureFieldFilterQueries(opt) {
2681
2778
  return __async$1(this, null, function* () {
2682
2779
  const queries = getQueries(opt);
@@ -2727,13 +2824,7 @@ function getQueries(opt, _queries = [], _parentAllParams = []) {
2727
2824
  }))
2728
2825
  );
2729
2826
  } else {
2730
- getQueries(
2731
- __spreadProps$1(__spreadValues$2({}, opt), {
2732
- filters: f
2733
- }),
2734
- _queries,
2735
- [..._parentAllParams]
2736
- );
2827
+ getQueries(__spreadProps$1(__spreadValues$2({}, opt), { filters: f }), _queries, [..._parentAllParams]);
2737
2828
  }
2738
2829
  }
2739
2830
  } else if (logic === "all") {
@@ -2748,13 +2839,10 @@ function getQueries(opt, _queries = [], _parentAllParams = []) {
2748
2839
  }
2749
2840
  if (propertiesFilterList.length) {
2750
2841
  for (const x of propertiesFilterList) {
2751
- getQueries(
2752
- __spreadProps$1(__spreadValues$2({}, opt), {
2753
- filters: x
2754
- }),
2755
- _queries,
2756
- [..._parentAllParams, ...filters2]
2757
- );
2842
+ getQueries(__spreadProps$1(__spreadValues$2({}, opt), { filters: x }), _queries, [
2843
+ ..._parentAllParams,
2844
+ ...filters2
2845
+ ]);
2758
2846
  }
2759
2847
  } else {
2760
2848
  _queries.push(
@@ -2777,6 +2865,7 @@ function fetchNgwLayerItemsRequest(options) {
2777
2865
  const params = __spreadValues$2({}, FEATURE_REQUEST_PARAMS);
2778
2866
  const {
2779
2867
  limit,
2868
+ query,
2780
2869
  cache,
2781
2870
  signal,
2782
2871
  offset,
@@ -2787,12 +2876,8 @@ function fetchNgwLayerItemsRequest(options) {
2787
2876
  intersects,
2788
2877
  resourceId
2789
2878
  } = options;
2790
- if (limit) {
2791
- if (limit !== Number.POSITIVE_INFINITY) {
2792
- params.limit = limit;
2793
- }
2794
- } else {
2795
- params.limit = 7e3;
2879
+ if (typeof limit === "number" && limit !== Number.POSITIVE_INFINITY) {
2880
+ params.limit = limit;
2796
2881
  }
2797
2882
  if (offset) {
2798
2883
  params.offset = offset;
@@ -2811,16 +2896,9 @@ function fetchNgwLayerItemsRequest(options) {
2811
2896
  params.intersects = intersects;
2812
2897
  }
2813
2898
  if (paramList) {
2814
- params.paramList = paramList;
2815
- }
2816
- const reqParams = __spreadValues$2({
2817
- id: resourceId
2818
- }, params);
2819
- return connector.get(
2820
- "feature_layer.feature.collection",
2821
- { cache, signal },
2822
- reqParams
2823
- );
2899
+ Object.assign(params, paramListToQuery(paramList));
2900
+ }
2901
+ return connector.route("feature_layer.feature.collection", { id: Number(resourceId) }).get({ query: __spreadValues$2(__spreadValues$2({}, params), query), cache, signal });
2824
2902
  }
2825
2903
 
2826
2904
  function prepareNgwFieldsToPropertiesFilter(fields) {
@@ -3022,7 +3100,7 @@ const _NgwProvider = class _NgwProvider extends BaseProvider {
3022
3100
  yield item;
3023
3101
  }
3024
3102
  } catch (er) {
3025
- if (er && "name" in er && er.name !== "CancelError") {
3103
+ if (er && "name" in er && er.name !== "AbortError") {
3026
3104
  console.warn(er);
3027
3105
  }
3028
3106
  }
@@ -3031,15 +3109,16 @@ const _NgwProvider = class _NgwProvider extends BaseProvider {
3031
3109
  }
3032
3110
  result(item) {
3033
3111
  const signal = this._makeSignal();
3034
- const req = this.connector.get(
3035
- "feature_layer.feature.item_extent",
3036
- { signal },
3037
- {
3038
- id: item.resourceId,
3039
- fid: item.featureId
3040
- }
3041
- ).then((x) => {
3042
- const e = x.extent;
3112
+ const req = this.connector.route("feature_layer.feature.item_extent", {
3113
+ id: item.resourceId,
3114
+ fid: item.featureId
3115
+ }).get({ signal }).then((x) => {
3116
+ const e = x.extent || {
3117
+ minLon: 0,
3118
+ minLat: 0,
3119
+ maxLon: 0,
3120
+ maxLat: 0
3121
+ };
3043
3122
  return {
3044
3123
  text: item.text,
3045
3124
  extent: [e.minLon, e.minLat, e.maxLon, e.maxLat]