@nextgis/geocoder 3.0.0-alpha.12 → 3.0.0-alpha.13

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-alpha.13; 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
  }
@@ -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
  });
@@ -304,6 +304,245 @@ class BaseProvider extends BaseGeocoder {
304
304
  }
305
305
  }
306
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));
541
+ }
542
+ };
543
+ __publicField$b(_Cache, "instance", {});
544
+ let Cache = _Cache;
545
+
307
546
  var domain;
308
547
 
309
548
  // This constructor is used to store event handlers. Instantiating this is
@@ -776,148 +1015,9 @@ function unwrapListeners(arr) {
776
1015
  return ret;
777
1016
  }
778
1017
 
779
- var __defProp$g = Object.defineProperty;
780
- var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
781
- var __publicField$b = (obj, key, value) => __defNormalProp$g(obj, typeof key !== "symbol" ? key + "" : key, value);
782
- const _Cache = class _Cache {
783
- constructor(options = {}) {
784
- __publicField$b(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$b(_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-alpha.13",
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-alpha.13",
1030
+ "@nextgis/cancelable-promise": "^3.0.0-alpha.13",
1031
+ "@nextgis/utils": "^3.0.0-alpha.13",
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-alpha.13"
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);
@@ -1005,9 +1081,9 @@ class AbortError extends Error {
1005
1081
  }
1006
1082
  }
1007
1083
 
1008
- var __defProp$f = Object.defineProperty;
1009
- var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1010
- var __publicField$a = (obj, key, value) => __defNormalProp$f(obj, typeof key !== "symbol" ? key + "" : key, value);
1084
+ var __defProp$e = Object.defineProperty;
1085
+ var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[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();
@@ -1024,9 +1100,9 @@ class NgwError extends Error {
1024
1100
  }
1025
1101
  }
1026
1102
 
1027
- var __defProp$e = Object.defineProperty;
1028
- var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1029
- var __publicField$9 = (obj, key, value) => __defNormalProp$e(obj, typeof key !== "symbol" ? key + "" : key, value);
1103
+ var __defProp$d = Object.defineProperty;
1104
+ var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[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);
@@ -1036,51 +1112,19 @@ class InsufficientPermissionsError extends NgwError {
1036
1112
  }
1037
1113
  }
1038
1114
 
1039
- var __defProp$d = Object.defineProperty;
1040
- var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1041
- var __publicField$8 = (obj, key, value) => __defNormalProp$d(obj, key + "" , value);
1042
- class NetworkError extends Error {
1043
- constructor(url) {
1044
- super();
1045
- __publicField$8(this, "name", "NetworkError");
1046
- Object.setPrototypeOf(this, NetworkError.prototype);
1047
- this.message = `Unable to request ${url}.
1048
- Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`;
1049
- }
1050
- }
1051
-
1052
1115
  var __defProp$c = Object.defineProperty;
1053
1116
  var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1054
- var __publicField$7 = (obj, key, value) => __defNormalProp$c(obj, typeof key !== "symbol" ? key + "" : key, value);
1117
+ var __publicField$8 = (obj, key, value) => __defNormalProp$c(obj, typeof key !== "symbol" ? key + "" : key, value);
1055
1118
  let NetworksResponseError$1 = class NetworksResponseError extends NgwError {
1056
1119
  constructor(obj) {
1057
1120
  super(obj);
1058
- __publicField$7(this, "message", "There is no response from the server or problem connecting to server.");
1059
- __publicField$7(this, "title", "Network error");
1060
- __publicField$7(this, "detail", "Check network connectivity and try again later.");
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.");
1061
1124
  Object.setPrototypeOf(this, NetworksResponseError.prototype);
1062
1125
  }
1063
1126
  };
1064
1127
 
1065
- var __defProp$b = Object.defineProperty;
1066
- var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1067
- var __publicField$6 = (obj, key, value) => __defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
1068
- class ResourceNotFoundError extends NgwError {
1069
- constructor(obj) {
1070
- super(obj);
1071
- __publicField$6(this, "name", "ResourceNotFoundError");
1072
- __publicField$6(this, "exception", "nextgisweb.resource.exception.ResourceNotFound");
1073
- Object.setPrototypeOf(this, ResourceNotFoundError.prototype);
1074
- }
1075
- }
1076
-
1077
- function isError(error) {
1078
- if (isObject$1(error)) {
1079
- return error.status_code && error.exception && error.title;
1080
- }
1081
- return false;
1082
- }
1083
-
1084
1128
  function extractError(error) {
1085
1129
  if (isObject$1(error)) {
1086
1130
  if (error.name && error.message && error.title) {
@@ -1106,6 +1150,38 @@ function extractError(error) {
1106
1150
  }
1107
1151
  }
1108
1152
 
1153
+ function isError(error) {
1154
+ if (isObject$1(error)) {
1155
+ return error.status_code && error.exception && error.title;
1156
+ }
1157
+ return false;
1158
+ }
1159
+
1160
+ var __defProp$b = Object.defineProperty;
1161
+ var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[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
+
1109
1185
  var errors = /*#__PURE__*/Object.freeze({
1110
1186
  __proto__: null,
1111
1187
  AbortError: AbortError,
@@ -1118,9 +1194,9 @@ var errors = /*#__PURE__*/Object.freeze({
1118
1194
  isError: isError
1119
1195
  });
1120
1196
 
1121
- var __defProp$a = Object.defineProperty;
1122
- var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1123
- var __publicField$5 = (obj, key, value) => __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
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);
1124
1200
  class BaseAPIError extends Error {
1125
1201
  constructor(message) {
1126
1202
  super(message || "Something went wrong.");
@@ -1177,40 +1253,40 @@ class LunkwillRequestCancelled extends LunkwillError {
1177
1253
  }
1178
1254
  }
1179
1255
  class LunkwillRequestFailed extends LunkwillError {
1180
- constructor(data) {
1181
- super(void 0, data);
1182
- }
1183
- }
1184
-
1185
- var __defProp$9 = Object.defineProperty;
1186
- var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
1187
- var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
1188
- var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
1189
- var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1190
- var __spreadValues$7 = (a, b) => {
1256
+ constructor(data) {
1257
+ super(void 0, data);
1258
+ }
1259
+ }
1260
+
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) => {
1191
1267
  for (var prop in b || (b = {}))
1192
- if (__hasOwnProp$7.call(b, prop))
1193
- __defNormalProp$9(a, prop, b[prop]);
1194
- if (__getOwnPropSymbols$7)
1195
- for (var prop of __getOwnPropSymbols$7(b)) {
1196
- if (__propIsEnum$7.call(b, prop))
1197
- __defNormalProp$9(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]);
1198
1274
  }
1199
1275
  return a;
1200
1276
  };
1201
1277
  var __objRest$2 = (source, exclude) => {
1202
1278
  var target = {};
1203
1279
  for (var prop in source)
1204
- if (__hasOwnProp$7.call(source, prop) && exclude.indexOf(prop) < 0)
1280
+ if (__hasOwnProp$6.call(source, prop) && exclude.indexOf(prop) < 0)
1205
1281
  target[prop] = source[prop];
1206
- if (source != null && __getOwnPropSymbols$7)
1207
- for (var prop of __getOwnPropSymbols$7(source)) {
1208
- 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))
1209
1285
  target[prop] = source[prop];
1210
1286
  }
1211
1287
  return target;
1212
1288
  };
1213
- var __async$6 = (__this, __arguments, generator) => {
1289
+ var __async$5 = (__this, __arguments, generator) => {
1214
1290
  return new Promise((resolve, reject) => {
1215
1291
  var fulfilled = (value) => {
1216
1292
  try {
@@ -1235,7 +1311,7 @@ function lunkwillCheckResponse(lwResp) {
1235
1311
  return ct !== void 0 && ct !== null && ct.includes("application/vnd.lunkwill.request-summary+json");
1236
1312
  }
1237
1313
  function responseJson(response) {
1238
- return __async$6(this, null, function* () {
1314
+ return __async$5(this, null, function* () {
1239
1315
  try {
1240
1316
  return response.json();
1241
1317
  } catch (e) {
@@ -1244,7 +1320,7 @@ function responseJson(response) {
1244
1320
  });
1245
1321
  }
1246
1322
  function lunkwillResponseUrl(lwResp) {
1247
- return __async$6(this, null, function* () {
1323
+ return __async$5(this, null, function* () {
1248
1324
  const lwData = yield responseJson(lwResp);
1249
1325
  let delay = lwData.delay_ms;
1250
1326
  const retry = lwData.retry_ms !== void 0 ? lwData.retry_ms : 2e3;
@@ -1288,7 +1364,7 @@ function lunkwillResponseUrl(lwResp) {
1288
1364
  });
1289
1365
  }
1290
1366
  function lunkwillFetch(lwRespUrl) {
1291
- return __async$6(this, null, function* () {
1367
+ return __async$5(this, null, function* () {
1292
1368
  try {
1293
1369
  return yield window.fetch(lwRespUrl, { credentials: "same-origin" });
1294
1370
  } catch (e) {
@@ -1336,14 +1412,14 @@ function generateUrl(path, query) {
1336
1412
  return path + urlParams;
1337
1413
  }
1338
1414
  function request(path, options, cacheEngine) {
1339
- return __async$6(this, null, function* () {
1415
+ return __async$5(this, null, function* () {
1340
1416
  var _b;
1341
1417
  const defaults = {
1342
1418
  method: "GET",
1343
1419
  credentials: "same-origin",
1344
1420
  headers: {}
1345
1421
  };
1346
- const _a = __spreadValues$7(__spreadValues$7({}, defaults), options), {
1422
+ const _a = __spreadValues$6(__spreadValues$6({}, defaults), options), {
1347
1423
  withCredentials,
1348
1424
  responseType,
1349
1425
  cacheProps,
@@ -1379,7 +1455,7 @@ function request(path, options, cacheEngine) {
1379
1455
  opt.headers = headers;
1380
1456
  }
1381
1457
  const url = generateUrl(path, query);
1382
- const makeRequest = () => __async$6(this, null, function* () {
1458
+ const makeRequest = () => __async$5(this, null, function* () {
1383
1459
  let response;
1384
1460
  try {
1385
1461
  response = yield fetch(url, opt);
@@ -1419,8 +1495,8 @@ function request(path, options, cacheEngine) {
1419
1495
  }
1420
1496
  return body;
1421
1497
  });
1422
- if (cacheEngine && ((_b = opt.method) == null ? void 0 : _b.toUpperCase()) === "GET") {
1423
- const props = cacheProps ? cacheProps : __spreadValues$7({}, objectRemoveEmpty({
1498
+ if (cacheEngine && cache !== false && ((_b = opt.method) == null ? void 0 : _b.toUpperCase()) === "GET") {
1499
+ const props = cacheProps ? cacheProps : __spreadValues$6({}, objectRemoveEmpty({
1424
1500
  withCredentials,
1425
1501
  responseType
1426
1502
  }));
@@ -1433,21 +1509,21 @@ function request(path, options, cacheEngine) {
1433
1509
  });
1434
1510
  }
1435
1511
 
1436
- var __defProp$8 = Object.defineProperty;
1512
+ var __defProp$7 = Object.defineProperty;
1437
1513
  var __defProps$4 = Object.defineProperties;
1438
1514
  var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
1439
- var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
1440
- var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
1441
- var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
1442
- var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1443
- var __spreadValues$6 = (a, b) => {
1515
+ var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
1516
+ var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
1517
+ var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
1518
+ var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1519
+ var __spreadValues$5 = (a, b) => {
1444
1520
  for (var prop in b || (b = {}))
1445
- if (__hasOwnProp$6.call(b, prop))
1446
- __defNormalProp$8(a, prop, b[prop]);
1447
- if (__getOwnPropSymbols$6)
1448
- for (var prop of __getOwnPropSymbols$6(b)) {
1449
- if (__propIsEnum$6.call(b, prop))
1450
- __defNormalProp$8(a, prop, b[prop]);
1521
+ if (__hasOwnProp$5.call(b, prop))
1522
+ __defNormalProp$7(a, prop, b[prop]);
1523
+ if (__getOwnPropSymbols$5)
1524
+ for (var prop of __getOwnPropSymbols$5(b)) {
1525
+ if (__propIsEnum$5.call(b, prop))
1526
+ __defNormalProp$7(a, prop, b[prop]);
1451
1527
  }
1452
1528
  return a;
1453
1529
  };
@@ -1455,16 +1531,16 @@ var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
1455
1531
  var __objRest$1 = (source, exclude) => {
1456
1532
  var target = {};
1457
1533
  for (var prop in source)
1458
- if (__hasOwnProp$6.call(source, prop) && exclude.indexOf(prop) < 0)
1534
+ if (__hasOwnProp$5.call(source, prop) && exclude.indexOf(prop) < 0)
1459
1535
  target[prop] = source[prop];
1460
- if (source != null && __getOwnPropSymbols$6)
1461
- for (var prop of __getOwnPropSymbols$6(source)) {
1462
- if (exclude.indexOf(prop) < 0 && __propIsEnum$6.call(source, prop))
1536
+ if (source != null && __getOwnPropSymbols$5)
1537
+ for (var prop of __getOwnPropSymbols$5(source)) {
1538
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$5.call(source, prop))
1463
1539
  target[prop] = source[prop];
1464
1540
  }
1465
1541
  return target;
1466
1542
  };
1467
- var __async$5 = (__this, __arguments, generator) => {
1543
+ var __async$4 = (__this, __arguments, generator) => {
1468
1544
  return new Promise((resolve, reject) => {
1469
1545
  var fulfilled = (value) => {
1470
1546
  try {
@@ -1515,7 +1591,7 @@ function routeURL(name, baseUrl, routeData, ...rest) {
1515
1591
  }
1516
1592
  function route(name, connector, ...rest) {
1517
1593
  const result = {
1518
- url: (opt) => __async$5(this, null, function* () {
1594
+ url: (opt) => __async$4(this, null, function* () {
1519
1595
  var _a;
1520
1596
  const routeData = yield connector.connect();
1521
1597
  const template = routeURL(
@@ -1529,27 +1605,32 @@ function route(name, connector, ...rest) {
1529
1605
  };
1530
1606
  const methods = ["get", "post", "put", "delete", "patch"];
1531
1607
  for (const method of methods) {
1532
- const methodResp = (requestOptions) => __async$5(this, null, function* () {
1608
+ const methodResp = (requestOptions) => {
1533
1609
  var _b;
1534
1610
  const _a = requestOptions || {}, { headers: optHeaders } = _a, restOpt = __objRest$1(_a, ["headers"]);
1535
- const routeData = yield connector.connect();
1536
- const template = routeURL(
1537
- name,
1538
- (_b = connector.options.baseUrl) != null ? _b : "",
1539
- routeData,
1540
- ...rest
1541
- );
1542
- const headers = objectRemoveEmpty(__spreadValues$6(__spreadValues$6({}, connector.getAuthorizationHeaders()), optHeaders != null ? optHeaders : {}));
1543
- return request(
1544
- template,
1545
- __spreadProps$4(__spreadValues$6({
1546
- headers
1547
- }, restOpt), {
1548
- method
1549
- }),
1550
- connector.cache
1551
- );
1552
- });
1611
+ if ((_b = requestOptions == null ? void 0 : requestOptions.signal) == null ? void 0 : _b.aborted) {
1612
+ throw new AbortError();
1613
+ }
1614
+ return connector.connect().then((routeData) => {
1615
+ var _a2;
1616
+ const template = routeURL(
1617
+ name,
1618
+ (_a2 = connector.options.baseUrl) != null ? _a2 : "",
1619
+ routeData,
1620
+ ...rest
1621
+ );
1622
+ const headers = objectRemoveEmpty(__spreadValues$5(__spreadValues$5({}, connector.getAuthorizationHeaders()), optHeaders != null ? optHeaders : {}));
1623
+ return request(
1624
+ template,
1625
+ __spreadProps$4(__spreadValues$5({
1626
+ headers
1627
+ }, restOpt), {
1628
+ method
1629
+ }),
1630
+ connector.cache
1631
+ );
1632
+ });
1633
+ };
1553
1634
  result[method] = methodResp;
1554
1635
  }
1555
1636
  return result;
@@ -1571,7 +1652,7 @@ let loadData;
1571
1652
  const getResponseText = () => {
1572
1653
  try {
1573
1654
  return JSON.parse(xhr.responseText);
1574
- } catch (er) {
1655
+ } catch (e) {
1575
1656
  return xhr.responseText;
1576
1657
  }
1577
1658
  };
@@ -1641,34 +1722,45 @@ let loadData;
1641
1722
  };
1642
1723
  }
1643
1724
 
1644
- const templateRe = /\{ *([\w_-]+) *\}/g;
1645
- function template(str, data) {
1646
- return str.replace(templateRe, (s, key) => {
1647
- let value = data[key];
1648
- if (value === void 0) {
1649
- throw new Error("No value provided for letiable " + s);
1650
- } else if (typeof value === "function") {
1651
- value = value(data);
1725
+ const CONNECTORS = [];
1726
+ function addConnector(connector) {
1727
+ CONNECTORS.push(connector);
1728
+ }
1729
+ function findConnector(options) {
1730
+ return CONNECTORS.find((x) => {
1731
+ if (x.options.baseUrl === options.baseUrl) {
1732
+ if (options.auth) {
1733
+ if (x.options.auth) {
1734
+ return objectDeepEqual(x.options.auth, options.auth);
1735
+ }
1736
+ } else {
1737
+ return true;
1738
+ }
1652
1739
  }
1653
- return value;
1654
1740
  });
1655
1741
  }
1742
+ function removeConnector(connector) {
1743
+ const index = CONNECTORS.indexOf(connector);
1744
+ if (index !== -1) {
1745
+ CONNECTORS.splice(index, 1);
1746
+ }
1747
+ }
1656
1748
 
1657
- var __defProp$7 = Object.defineProperty;
1749
+ var __defProp$6 = Object.defineProperty;
1658
1750
  var __defProps$3 = Object.defineProperties;
1659
1751
  var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
1660
- var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
1661
- var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
1662
- var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
1663
- var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1664
- var __spreadValues$5 = (a, b) => {
1752
+ var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
1753
+ var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
1754
+ var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
1755
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1756
+ var __spreadValues$4 = (a, b) => {
1665
1757
  for (var prop in b || (b = {}))
1666
- if (__hasOwnProp$5.call(b, prop))
1667
- __defNormalProp$7(a, prop, b[prop]);
1668
- if (__getOwnPropSymbols$5)
1669
- for (var prop of __getOwnPropSymbols$5(b)) {
1670
- if (__propIsEnum$5.call(b, prop))
1671
- __defNormalProp$7(a, prop, b[prop]);
1758
+ if (__hasOwnProp$4.call(b, prop))
1759
+ __defNormalProp$6(a, prop, b[prop]);
1760
+ if (__getOwnPropSymbols$4)
1761
+ for (var prop of __getOwnPropSymbols$4(b)) {
1762
+ if (__propIsEnum$4.call(b, prop))
1763
+ __defNormalProp$6(a, prop, b[prop]);
1672
1764
  }
1673
1765
  return a;
1674
1766
  };
@@ -1676,17 +1768,17 @@ var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
1676
1768
  var __objRest = (source, exclude) => {
1677
1769
  var target = {};
1678
1770
  for (var prop in source)
1679
- if (__hasOwnProp$5.call(source, prop) && exclude.indexOf(prop) < 0)
1771
+ if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
1680
1772
  target[prop] = source[prop];
1681
- if (source != null && __getOwnPropSymbols$5)
1682
- for (var prop of __getOwnPropSymbols$5(source)) {
1683
- if (exclude.indexOf(prop) < 0 && __propIsEnum$5.call(source, prop))
1773
+ if (source != null && __getOwnPropSymbols$4)
1774
+ for (var prop of __getOwnPropSymbols$4(source)) {
1775
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
1684
1776
  target[prop] = source[prop];
1685
1777
  }
1686
1778
  return target;
1687
1779
  };
1688
- var __publicField$4 = (obj, key, value) => __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
1689
- var __async$4 = (__this, __arguments, generator) => {
1780
+ var __publicField$4 = (obj, key, value) => __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
1781
+ var __async$3 = (__this, __arguments, generator) => {
1690
1782
  return new Promise((resolve, reject) => {
1691
1783
  var fulfilled = (value) => {
1692
1784
  try {
@@ -1771,7 +1863,9 @@ class NgwConnector {
1771
1863
  * ```
1772
1864
  */
1773
1865
  connect() {
1774
- return __async$4(this, null, function* () {
1866
+ return __async$3(this, arguments, function* ({
1867
+ signal
1868
+ } = {}) {
1775
1869
  const auth = this.options.auth;
1776
1870
  if (auth) {
1777
1871
  const { login, password } = auth;
@@ -1780,11 +1874,12 @@ class NgwConnector {
1780
1874
  }
1781
1875
  }
1782
1876
  const routeUrl = `${this.routeStr}?client=${this.client}`;
1783
- return yield this.makeQuery(
1877
+ return this.makeQuery(
1784
1878
  routeUrl,
1785
1879
  {},
1786
1880
  {
1787
1881
  cacheName: "route",
1882
+ signal,
1788
1883
  cache: true,
1789
1884
  cacheProps: {
1790
1885
  id: this.id,
@@ -1816,14 +1911,14 @@ class NgwConnector {
1816
1911
  this.emitter.emit("logout");
1817
1912
  }
1818
1913
  getUserInfo(credentials, options) {
1819
- return __async$4(this, null, function* () {
1914
+ return __async$3(this, null, function* () {
1820
1915
  if (this.user && this.user.id) {
1821
1916
  return this.user;
1822
1917
  }
1823
1918
  if (credentials) {
1824
1919
  this.options.auth = credentials;
1825
1920
  }
1826
- const options_ = __spreadValues$5({
1921
+ const options_ = __spreadValues$4({
1827
1922
  headers: this.getAuthorizationHeaders(credentials),
1828
1923
  cache: true
1829
1924
  }, options);
@@ -1864,7 +1959,7 @@ class NgwConnector {
1864
1959
  this.activeRequests = {};
1865
1960
  }
1866
1961
  getActiveApiRequests() {
1867
- return __spreadValues$5({}, this.activeRequests);
1962
+ return __spreadValues$4({}, this.activeRequests);
1868
1963
  }
1869
1964
  route(name, ...rest) {
1870
1965
  return route(name, this, ...rest);
@@ -1876,7 +1971,7 @@ class NgwConnector {
1876
1971
  * @param options - Request options
1877
1972
  */
1878
1973
  makeQuery(_0, _1) {
1879
- return __async$4(this, arguments, function* (url, params, options = {}) {
1974
+ return __async$3(this, arguments, function* (url, params, options = {}) {
1880
1975
  var _b;
1881
1976
  url = (this.options.baseUrl ? this.options.baseUrl : "") + url;
1882
1977
  if (!url) {
@@ -1887,7 +1982,7 @@ class NgwConnector {
1887
1982
  url = template(url, restParams);
1888
1983
  }
1889
1984
  url = encodeURI(fixUrlStr(url));
1890
- options = __spreadValues$5({ withCredentials: this.withCredentials }, options);
1985
+ options = __spreadValues$4({ withCredentials: this.withCredentials }, options);
1891
1986
  const {
1892
1987
  cache,
1893
1988
  signal: externalSignal,
@@ -1909,7 +2004,7 @@ class NgwConnector {
1909
2004
  });
1910
2005
  }
1911
2006
  options.signal = internalSignal;
1912
- const createPromise = () => __async$4(this, null, function* () {
2007
+ const createPromise = () => __async$3(this, null, function* () {
1913
2008
  const id = REQUEST_ID++;
1914
2009
  this.activeRequests[id] = internalAbortController;
1915
2010
  try {
@@ -1919,7 +2014,7 @@ class NgwConnector {
1919
2014
  }
1920
2015
  });
1921
2016
  if (method === "GET") {
1922
- const cacheOptions = cacheProps ? cacheProps : __spreadProps$3(__spreadValues$5({}, objectRemoveEmpty({
2017
+ const cacheOptions = cacheProps ? cacheProps : __spreadProps$3(__spreadValues$4({}, objectRemoveEmpty({
1923
2018
  headers,
1924
2019
  withCredentials,
1925
2020
  responseType,
@@ -1942,7 +2037,7 @@ class NgwConnector {
1942
2037
  var _a;
1943
2038
  if (this.user) {
1944
2039
  options = options || {};
1945
- options.headers = __spreadValues$5(__spreadValues$5({}, this.getAuthorizationHeaders()), options.headers);
2040
+ options.headers = __spreadValues$4(__spreadValues$4({}, this.getAuthorizationHeaders()), options.headers);
1946
2041
  }
1947
2042
  if (this.requestTransform) {
1948
2043
  const [transUrl, transOptions] = this.requestTransform(url, options);
@@ -1973,7 +2068,7 @@ class NgwConnector {
1973
2068
  });
1974
2069
  }
1975
2070
  _login(credentials, options) {
1976
- return __async$4(this, null, function* () {
2071
+ return __async$3(this, null, function* () {
1977
2072
  try {
1978
2073
  const data = yield this.getUserInfo(credentials, options);
1979
2074
  this.user = data;
@@ -2031,27 +2126,27 @@ function resourceToQuery(resource, prefix = "") {
2031
2126
  return query;
2032
2127
  }
2033
2128
 
2034
- var __defProp$6 = Object.defineProperty;
2129
+ var __defProp$5 = Object.defineProperty;
2035
2130
  var __defProps$2 = Object.defineProperties;
2036
2131
  var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
2037
- var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
2038
- var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
2039
- var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
2040
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2041
- var __spreadValues$4 = (a, b) => {
2132
+ var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
2133
+ var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
2134
+ var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
2135
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2136
+ var __spreadValues$3 = (a, b) => {
2042
2137
  for (var prop in b || (b = {}))
2043
- if (__hasOwnProp$4.call(b, prop))
2044
- __defNormalProp$6(a, prop, b[prop]);
2045
- if (__getOwnPropSymbols$4)
2046
- for (var prop of __getOwnPropSymbols$4(b)) {
2047
- if (__propIsEnum$4.call(b, prop))
2048
- __defNormalProp$6(a, prop, b[prop]);
2138
+ if (__hasOwnProp$3.call(b, prop))
2139
+ __defNormalProp$5(a, prop, b[prop]);
2140
+ if (__getOwnPropSymbols$3)
2141
+ for (var prop of __getOwnPropSymbols$3(b)) {
2142
+ if (__propIsEnum$3.call(b, prop))
2143
+ __defNormalProp$5(a, prop, b[prop]);
2049
2144
  }
2050
2145
  return a;
2051
2146
  };
2052
2147
  var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
2053
- var __publicField$3 = (obj, key, value) => __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
2054
- var __async$3 = (__this, __arguments, generator) => {
2148
+ var __publicField$3 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
2149
+ var __async$2 = (__this, __arguments, generator) => {
2055
2150
  return new Promise((resolve, reject) => {
2056
2151
  var fulfilled = (value) => {
2057
2152
  try {
@@ -2092,7 +2187,7 @@ class ResourcesControl {
2092
2187
  * Fetching resource would be cached to speed up next call
2093
2188
  */
2094
2189
  getOne(resource, requestOptions) {
2095
- const opt = __spreadValues$4({}, requestOptions);
2190
+ const opt = __spreadValues$3({}, requestOptions);
2096
2191
  if (typeof resource === "string") ; else if (typeof resource === "number") ; else if (isObject(resource)) {
2097
2192
  if (resource.id !== void 0) {
2098
2193
  resource.id;
@@ -2169,8 +2264,8 @@ class ResourcesControl {
2169
2264
  } else {
2170
2265
  Object.assign(query, resourceToQuery(resource));
2171
2266
  }
2172
- return this.connector.route("resource.search").get(__spreadProps$2(__spreadValues$4({}, requestOptions), {
2173
- query: __spreadValues$4({
2267
+ return this.connector.route("resource.search").get(__spreadProps$2(__spreadValues$3({}, requestOptions), {
2268
+ query: __spreadValues$3({
2174
2269
  serialization: "full"
2175
2270
  }, query)
2176
2271
  })).then((resources) => {
@@ -2223,7 +2318,7 @@ class ResourcesControl {
2223
2318
  });
2224
2319
  }
2225
2320
  _getChildrenOf(_0, _1) {
2226
- return __async$3(this, arguments, function* (parentDef, requestOptions, _items = []) {
2321
+ return __async$2(this, arguments, function* (parentDef, requestOptions, _items = []) {
2227
2322
  let parent = void 0;
2228
2323
  if (typeof parentDef === "string") {
2229
2324
  parent = yield this.getId(parentDef, requestOptions);
@@ -2232,7 +2327,7 @@ class ResourcesControl {
2232
2327
  } else {
2233
2328
  parent = parentDef;
2234
2329
  }
2235
- const items = yield this.connector.route("resource.collection").get(__spreadProps$2(__spreadValues$4({}, requestOptions), {
2330
+ const items = yield this.connector.route("resource.collection").get(__spreadProps$2(__spreadValues$3({}, requestOptions), {
2236
2331
  query: {
2237
2332
  parent
2238
2333
  }
@@ -2260,7 +2355,7 @@ class ResourcesControl {
2260
2355
  });
2261
2356
  }
2262
2357
  _cleanResourceItemCache(id) {
2263
- return __async$3(this, null, function* () {
2358
+ return __async$2(this, null, function* () {
2264
2359
  var _a;
2265
2360
  const all = this.cache.all();
2266
2361
  const toDelete = [];
@@ -2313,93 +2408,6 @@ class ResourcesControl {
2313
2408
  }
2314
2409
  }
2315
2410
 
2316
- var __defProp$5 = Object.defineProperty;
2317
- var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
2318
- var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
2319
- var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
2320
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2321
- var __spreadValues$3 = (a, b) => {
2322
- for (var prop in b || (b = {}))
2323
- if (__hasOwnProp$3.call(b, prop))
2324
- __defNormalProp$5(a, prop, b[prop]);
2325
- if (__getOwnPropSymbols$3)
2326
- for (var prop of __getOwnPropSymbols$3(b)) {
2327
- if (__propIsEnum$3.call(b, prop))
2328
- __defNormalProp$5(a, prop, b[prop]);
2329
- }
2330
- return a;
2331
- };
2332
- var __async$2 = (__this, __arguments, generator) => {
2333
- return new Promise((resolve, reject) => {
2334
- var fulfilled = (value) => {
2335
- try {
2336
- step(generator.next(value));
2337
- } catch (e) {
2338
- reject(e);
2339
- }
2340
- };
2341
- var rejected = (value) => {
2342
- try {
2343
- step(generator.throw(value));
2344
- } catch (e) {
2345
- reject(e);
2346
- }
2347
- };
2348
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
2349
- step((generator = generator.apply(__this, __arguments)).next());
2350
- });
2351
- };
2352
- function apiRequest(opt) {
2353
- return __async$2(this, null, function* () {
2354
- const { params, name, connector, requestOptions } = opt;
2355
- const apiItems = yield connector.connect();
2356
- let apiItem = apiItems && apiItems[name];
2357
- if (apiItem) {
2358
- apiItem = [...apiItem];
2359
- let url = apiItem.shift();
2360
- if (apiItem.length) {
2361
- const replaceParams = {};
2362
- for (let fry = 0; fry < apiItem.length; fry++) {
2363
- const arg = apiItem[fry];
2364
- replaceParams[fry] = `{${arg}}`;
2365
- if (params[arg] === void 0) {
2366
- throw new Error(`\`${arg}\` URL API argument is not specified`);
2367
- }
2368
- }
2369
- if (url) {
2370
- url = template(url, replaceParams);
2371
- }
2372
- }
2373
- if (params) {
2374
- const paramArray = [];
2375
- const paramList = params.paramList;
2376
- if (Array.isArray(paramList)) {
2377
- paramList.forEach(([key, value]) => {
2378
- paramArray.push(`${key}=${value}`);
2379
- });
2380
- }
2381
- for (const p in params) {
2382
- if (apiItem.indexOf(p) === -1) {
2383
- paramArray.push(`${p}=${params[p]}`);
2384
- }
2385
- }
2386
- if (paramArray.length) {
2387
- url = `${url}?${paramArray.join("&")}`;
2388
- }
2389
- }
2390
- if (url) {
2391
- return connector.makeQuery(url, params, __spreadValues$3({
2392
- cacheName: name
2393
- }, requestOptions));
2394
- } else {
2395
- throw new Error("Request URL is not set");
2396
- }
2397
- } else {
2398
- return void 0;
2399
- }
2400
- });
2401
- }
2402
-
2403
2411
  var __defProp$4 = Object.defineProperty;
2404
2412
  var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2405
2413
  var __publicField$2 = (obj, key, value) => __defNormalProp$4(obj, key + "" , value);