@nextgis/ngw-connector 1.11.10 → 1.13.2

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,94 @@
1
- /** Bundle of @nextgis/ngw-connector; version: 1.11.10; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-connector; version: 1.13.2; author: NextGIS */
2
+ /*! *****************************************************************************
3
+ Copyright (c) Microsoft Corporation.
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted.
7
+
8
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
+ PERFORMANCE OF THIS SOFTWARE.
15
+ ***************************************************************************** */
16
+ /* global Reflect, Promise */
17
+
18
+ var extendStatics = function(d, b) {
19
+ extendStatics = Object.setPrototypeOf ||
20
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
21
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
22
+ return extendStatics(d, b);
23
+ };
24
+
25
+ function __extends(d, b) {
26
+ if (typeof b !== "function" && b !== null)
27
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
28
+ extendStatics(d, b);
29
+ function __() { this.constructor = d; }
30
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
31
+ }
32
+
33
+ var __assign = function() {
34
+ __assign = Object.assign || function __assign(t) {
35
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
36
+ s = arguments[i];
37
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
38
+ }
39
+ return t;
40
+ };
41
+ return __assign.apply(this, arguments);
42
+ };
43
+
44
+ function __awaiter(thisArg, _arguments, P, generator) {
45
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
46
+ return new (P || (P = Promise))(function (resolve, reject) {
47
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
48
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
49
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
50
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
51
+ });
52
+ }
53
+
54
+ function __generator(thisArg, body) {
55
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
56
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
57
+ function verb(n) { return function (v) { return step([n, v]); }; }
58
+ function step(op) {
59
+ if (f) throw new TypeError("Generator is already executing.");
60
+ while (_) try {
61
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
62
+ if (y = 0, t) op = [op[0] & 2, t.value];
63
+ switch (op[0]) {
64
+ case 0: case 1: t = op; break;
65
+ case 4: _.label++; return { value: op[1], done: false };
66
+ case 5: _.label++; y = op[1]; op = [0]; continue;
67
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
68
+ default:
69
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
70
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
71
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
72
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
73
+ if (t[2]) _.ops.pop();
74
+ _.trys.pop(); continue;
75
+ }
76
+ op = body.call(thisArg, _);
77
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
78
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
79
+ }
80
+ }
81
+
82
+ function __spreadArray(to, from, pack) {
83
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
84
+ if (ar || !(i in from)) {
85
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
86
+ ar[i] = from[i];
87
+ }
88
+ }
89
+ return to.concat(ar || Array.prototype.slice.call(from));
90
+ }
91
+
2
92
  var events = {exports: {}};
3
93
 
4
94
  var R = typeof Reflect === 'object' ? Reflect : null;
@@ -475,34 +565,43 @@ function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
475
565
  }
476
566
  }
477
567
 
478
- class CancelError extends Error {
479
- constructor() {
480
- super();
481
- this.name = 'CancelError';
482
- Object.setPrototypeOf(this, CancelError.prototype);
568
+ var CancelError = /** @class */ (function (_super) {
569
+ __extends(CancelError, _super);
570
+ function CancelError() {
571
+ var _this = _super.call(this) || this;
572
+ _this.name = 'CancelError';
573
+ Object.setPrototypeOf(_this, CancelError.prototype);
574
+ return _this;
483
575
  }
484
- }
576
+ return CancelError;
577
+ }(Error));
485
578
 
486
- class PromiseControl {
487
- constructor(options = {}) {
579
+ var PromiseControl = /** @class */ (function () {
580
+ function PromiseControl(options) {
581
+ if (options === void 0) { options = {}; }
488
582
  this.options = options;
489
583
  this._promises = new Map();
490
584
  }
491
- get isLoaded() {
492
- return this._promises.size > 0;
493
- }
494
- remove(promise) {
585
+ Object.defineProperty(PromiseControl.prototype, "isLoaded", {
586
+ get: function () {
587
+ return this._promises.size > 0;
588
+ },
589
+ enumerable: false,
590
+ configurable: true
591
+ });
592
+ PromiseControl.prototype.remove = function (promise) {
495
593
  if (this._promises.has(promise)) {
496
594
  this._promises.delete(promise);
497
595
  this._onStop();
498
596
  }
499
- }
500
- get(promise) {
597
+ };
598
+ PromiseControl.prototype.get = function (promise) {
501
599
  return this._promises.get(promise);
502
- }
503
- add(promise, name) {
504
- const key = name ? name : promise;
505
- const exist = this._promises.get(key);
600
+ };
601
+ PromiseControl.prototype.add = function (promise, name) {
602
+ var _this = this;
603
+ var key = name ? name : promise;
604
+ var exist = this._promises.get(key);
506
605
  if (this.options.onStart && !this.isLoaded) {
507
606
  this.options.onStart();
508
607
  }
@@ -510,14 +609,14 @@ class PromiseControl {
510
609
  return exist;
511
610
  }
512
611
  this._promises.set(key, promise);
513
- promise.finally(() => {
514
- this.remove(key);
612
+ promise.finally(function () {
613
+ _this.remove(key);
515
614
  });
516
615
  return promise;
517
- }
518
- abort() {
616
+ };
617
+ PromiseControl.prototype.abort = function () {
519
618
  if (this.isLoaded) {
520
- this._promises.forEach((x) => {
619
+ this._promises.forEach(function (x) {
521
620
  if (x.cancel) {
522
621
  x.cancel();
523
622
  }
@@ -525,52 +624,63 @@ class PromiseControl {
525
624
  this._promises.clear();
526
625
  this._onStop();
527
626
  }
528
- }
529
- waitFunc(func, name = '') {
627
+ };
628
+ PromiseControl.prototype.waitFunc = function (func, name) {
629
+ if (name === void 0) { name = ''; }
530
630
  name = name || func.name;
531
- const exist = this.get(name);
631
+ var exist = this.get(name);
532
632
  if (exist) {
533
633
  return exist;
534
634
  }
535
635
  return this.add(func(), name);
536
- }
537
- WaitForMe(name = '') {
538
- const get = this.get.bind(this);
539
- const add = this.add.bind(this);
636
+ };
637
+ PromiseControl.prototype.WaitForMe = function (name) {
638
+ if (name === void 0) { name = ''; }
639
+ var get = this.get.bind(this);
640
+ var add = this.add.bind(this);
540
641
  return function (target, key, descriptor) {
541
- const originalMethod = descriptor.value;
642
+ var originalMethod = descriptor.value;
542
643
  name = name || key;
543
- descriptor.value = function (...args) {
544
- const exist = get(name);
644
+ descriptor.value = function () {
645
+ var args = [];
646
+ for (var _i = 0; _i < arguments.length; _i++) {
647
+ args[_i] = arguments[_i];
648
+ }
649
+ var exist = get(name);
545
650
  if (exist) {
546
651
  return exist;
547
652
  }
548
- const result = add(originalMethod.apply(this, args), name);
653
+ var result = add(originalMethod.apply(this, args), name);
549
654
  return result;
550
655
  };
551
656
  return descriptor;
552
657
  };
553
- }
658
+ };
554
659
  /** @deprecated use {@link PromiseControl.WaitForMe } instead */
555
- GetOrCreateDecorator(name = '') {
660
+ PromiseControl.prototype.GetOrCreateDecorator = function (name) {
661
+ if (name === void 0) { name = ''; }
556
662
  return this.WaitForMe(name);
557
- }
558
- _onStop() {
663
+ };
664
+ PromiseControl.prototype._onStop = function () {
559
665
  if (this.options.onStop && !this.isLoaded) {
560
666
  this.options.onStop();
561
667
  }
562
- }
563
- }
668
+ };
669
+ return PromiseControl;
670
+ }());
564
671
 
565
- class TimeoutError extends Error {
566
- constructor() {
567
- super();
568
- this.name = 'TimeoutError';
569
- Object.setPrototypeOf(this, TimeoutError.prototype);
672
+ var TimeoutError = /** @class */ (function (_super) {
673
+ __extends(TimeoutError, _super);
674
+ function TimeoutError() {
675
+ var _this = _super.call(this) || this;
676
+ _this.name = 'TimeoutError';
677
+ Object.setPrototypeOf(_this, TimeoutError.prototype);
678
+ return _this;
570
679
  }
571
- }
680
+ return TimeoutError;
681
+ }(Error));
572
682
 
573
- const handleCallback = (resolve, reject, callback, r) => {
683
+ var handleCallback = function (resolve, reject, callback, r) {
574
684
  try {
575
685
  resolve(callback(r));
576
686
  }
@@ -578,7 +688,7 @@ const handleCallback = (resolve, reject, callback, r) => {
578
688
  reject(e);
579
689
  }
580
690
  };
581
- let ID$1 = 0;
691
+ var ID$1 = 0;
582
692
  /**
583
693
  * Promise that can be canceled
584
694
  *
@@ -623,48 +733,49 @@ let ID$1 = 0;
623
733
  * promise.cancel();
624
734
  * ```
625
735
  */
626
- class CancelablePromise$1 {
627
- constructor(executor, timeout) {
736
+ var CancelablePromise$1 = /** @class */ (function () {
737
+ function CancelablePromise(executor, timeout) {
738
+ var _this = this;
628
739
  this.id = ID$1++;
629
740
  this._isCanceled = false;
630
741
  this._isPending = true;
631
742
  this._cancelHandlers = [];
632
743
  this._children = [];
633
- this._cancelPromise = new Promise((resolve_, reject_) => {
634
- this._setCanceledCallback = (er) => resolve_(er || new CancelError());
744
+ this._cancelPromise = new Promise(function (resolve_, reject_) {
745
+ _this._setCanceledCallback = function (er) { return resolve_(er || new CancelError()); };
635
746
  });
636
- const promises = [
747
+ var promises = [
637
748
  this._cancelPromise,
638
- new Promise((resolve, reject) => {
639
- const onResolve = (value) => {
640
- if (value instanceof CancelablePromise$1) {
641
- this.attach(value);
749
+ new Promise(function (resolve, reject) {
750
+ var onResolve = function (value) {
751
+ if (value instanceof CancelablePromise) {
752
+ _this.attach(value);
642
753
  }
643
754
  else {
644
- this._isPending = false;
755
+ _this._isPending = false;
645
756
  }
646
757
  // TODO: fix types, `undefined` not allowed since 19.12.2020
647
758
  resolve(value);
648
759
  };
649
- const onReject = (error) => {
650
- this._isPending = false;
760
+ var onReject = function (error) {
761
+ _this._isPending = false;
651
762
  reject(error);
652
763
  };
653
- const onCancel = (handler) => {
654
- if (!this._isPending) {
764
+ var onCancel = function (handler) {
765
+ if (!_this._isPending) {
655
766
  throw new Error('The `onCancel` handler was attached after the promise settled.');
656
767
  }
657
- this._cancelHandlers.push(handler);
768
+ _this._cancelHandlers.push(handler);
658
769
  };
659
770
  return executor(onResolve, onReject, onCancel);
660
771
  }),
661
772
  ];
662
773
  if (timeout) {
663
- promises.push(new Promise((resolve, reject) => {
664
- setTimeout(() => {
665
- if (this._isPending) {
774
+ promises.push(new Promise(function (resolve, reject) {
775
+ setTimeout(function () {
776
+ if (_this._isPending) {
666
777
  try {
667
- this.cancel();
778
+ _this.cancel();
668
779
  }
669
780
  finally {
670
781
  reject(new TimeoutError());
@@ -675,21 +786,23 @@ class CancelablePromise$1 {
675
786
  }
676
787
  this._promise = Promise.race(promises);
677
788
  }
678
- static createControl(opt) {
789
+ CancelablePromise.createControl = function (opt) {
679
790
  return new PromiseControl(opt);
680
- }
681
- static resolve(value) {
682
- return new CancelablePromise$1((resolve) => resolve(value));
683
- }
684
- static reject(value) {
685
- return new CancelablePromise$1((resolve, reject) => reject(value));
686
- }
687
- static all(values) {
688
- return new CancelablePromise$1((resolve, reject) => {
791
+ };
792
+ CancelablePromise.resolve = function (value) {
793
+ return new CancelablePromise(function (resolve) { return resolve(value); });
794
+ };
795
+ CancelablePromise.reject = function (value) {
796
+ return new CancelablePromise(function (resolve, reject) { return reject(value); });
797
+ };
798
+ CancelablePromise.all = function (values) {
799
+ var _this = this;
800
+ return new CancelablePromise(function (resolve, reject) {
689
801
  Promise.all(values).then(resolve).catch(reject);
690
- }).catch((er) => {
691
- if (er instanceof this.CancelError) {
692
- for (const v of values) {
802
+ }).catch(function (er) {
803
+ if (er instanceof _this.CancelError) {
804
+ for (var _i = 0, values_1 = values; _i < values_1.length; _i++) {
805
+ var v = values_1[_i];
693
806
  if ('cancel' in v) {
694
807
  v.cancel();
695
808
  }
@@ -697,19 +810,20 @@ class CancelablePromise$1 {
697
810
  }
698
811
  throw er;
699
812
  });
700
- }
701
- attach(p) {
813
+ };
814
+ CancelablePromise.prototype.attach = function (p) {
702
815
  if (this._isCanceled) {
703
816
  p.cancel();
704
817
  }
705
818
  else {
706
819
  this._children.push(p);
707
820
  }
708
- }
709
- then(onfulfilled, onrejected) {
710
- const p = new CancelablePromise$1((resolve, reject) => {
711
- if (this._promise) {
712
- const reject_ = (r) => {
821
+ };
822
+ CancelablePromise.prototype.then = function (onfulfilled, onrejected) {
823
+ var _this = this;
824
+ var p = new CancelablePromise(function (resolve, reject) {
825
+ if (_this._promise) {
826
+ var reject_1 = function (r) {
713
827
  if (onrejected) {
714
828
  handleCallback(resolve, reject, onrejected, r);
715
829
  }
@@ -717,9 +831,9 @@ class CancelablePromise$1 {
717
831
  reject(r);
718
832
  }
719
833
  };
720
- this._promise.then((r) => {
721
- if (this._isCanceled) {
722
- reject_(r);
834
+ _this._promise.then(function (r) {
835
+ if (_this._isCanceled) {
836
+ reject_1(r);
723
837
  }
724
838
  else {
725
839
  if (onfulfilled) {
@@ -729,20 +843,20 @@ class CancelablePromise$1 {
729
843
  resolve(r);
730
844
  }
731
845
  }
732
- }, reject_);
846
+ }, reject_1);
733
847
  }
734
848
  });
735
849
  p._parentPromise = this;
736
850
  this._children.push(p);
737
851
  return p;
738
- }
739
- catch(onrejected) {
852
+ };
853
+ CancelablePromise.prototype.catch = function (onrejected) {
740
854
  if (this._isCanceled && onrejected) {
741
855
  onrejected(new CancelError());
742
856
  }
743
857
  return this.then(undefined, onrejected);
744
- }
745
- finally(onfinally) {
858
+ };
859
+ CancelablePromise.prototype.finally = function (onfinally) {
746
860
  if (this._promise) {
747
861
  return this._promise.finally(onfinally);
748
862
  }
@@ -750,24 +864,25 @@ class CancelablePromise$1 {
750
864
  return Promise.reject(new CancelError());
751
865
  }
752
866
  return Promise.reject(onfinally);
753
- }
754
- cancel() {
867
+ };
868
+ CancelablePromise.prototype.cancel = function () {
755
869
  // No reason to run cancel action if promise is already complete
756
870
  if (this._isCanceled || !this._isPending) {
757
871
  return this;
758
872
  }
759
873
  this._isCanceled = true;
760
- const parent = this._getTopParent();
874
+ var parent = this._getTopParent();
761
875
  if (parent) {
762
876
  parent.cancel();
763
877
  }
764
878
  if (this._children) {
765
- this._children.forEach((x) => x.cancel());
879
+ this._children.forEach(function (x) { return x.cancel(); });
766
880
  }
767
881
  if (this._isPending) {
768
882
  if (this._cancelHandlers.length) {
769
883
  try {
770
- for (const handler of this._cancelHandlers) {
884
+ for (var _i = 0, _a = this._cancelHandlers; _i < _a.length; _i++) {
885
+ var handler = _a[_i];
771
886
  handler();
772
887
  }
773
888
  }
@@ -781,10 +896,10 @@ class CancelablePromise$1 {
781
896
  }
782
897
  this._destroy();
783
898
  return this;
784
- }
785
- _getTopParent() {
786
- let parent = this._parentPromise;
787
- let hasParent = !!parent;
899
+ };
900
+ CancelablePromise.prototype._getTopParent = function () {
901
+ var parent = this._parentPromise;
902
+ var hasParent = !!parent;
788
903
  while (hasParent) {
789
904
  if (parent && parent._parentPromise) {
790
905
  parent = parent._parentPromise;
@@ -795,16 +910,17 @@ class CancelablePromise$1 {
795
910
  }
796
911
  }
797
912
  return parent;
798
- }
799
- _destroy() {
913
+ };
914
+ CancelablePromise.prototype._destroy = function () {
800
915
  this._setCanceledCallback = undefined;
801
916
  this._cancelPromise = undefined;
802
917
  this._promise = undefined;
803
- }
804
- }
805
- CancelablePromise$1.CancelError = CancelError;
806
- CancelablePromise$1.TimeoutError = TimeoutError;
807
- CancelablePromise$1.PromiseControl = PromiseControl;
918
+ };
919
+ CancelablePromise.CancelError = CancelError;
920
+ CancelablePromise.TimeoutError = TimeoutError;
921
+ CancelablePromise.PromiseControl = PromiseControl;
922
+ return CancelablePromise;
923
+ }());
808
924
  Object.setPrototypeOf(CancelablePromise$1.prototype, Promise.prototype);
809
925
 
810
926
  /**
@@ -883,15 +999,15 @@ function isEqual(a, b, o, p) {
883
999
  }
884
1000
  // based on https://stackoverflow.com/a/13143059
885
1001
  function objectDeepEqual(o, p) {
886
- const keysO = Object.keys(o).sort();
887
- const keysP = Object.keys(p).sort();
1002
+ var keysO = Object.keys(o).sort();
1003
+ var keysP = Object.keys(p).sort();
888
1004
  if (keysO.length !== keysP.length)
889
1005
  return false;
890
1006
  if (keysO.join('') !== keysP.join(''))
891
1007
  return false;
892
- for (let i = 0; i < keysO.length; i++) {
893
- const oVal = o[keysO[i]];
894
- const pVal = p[keysP[i]];
1008
+ for (var i = 0; i < keysO.length; i++) {
1009
+ var oVal = o[keysO[i]];
1010
+ var pVal = p[keysP[i]];
895
1011
  if (!isEqual(oVal, pVal, o, p)) {
896
1012
  return false;
897
1013
  }
@@ -900,8 +1016,8 @@ function objectDeepEqual(o, p) {
900
1016
  }
901
1017
 
902
1018
  function objectRemoveEmpty(obj) {
903
- const newObj = {};
904
- Object.keys(obj).forEach((key) => {
1019
+ var newObj = {};
1020
+ Object.keys(obj).forEach(function (key) {
905
1021
  if (!(obj[key] instanceof Array) && obj[key] === Object(obj[key])) {
906
1022
  newObj[key] = objectRemoveEmpty(obj[key]);
907
1023
  }
@@ -947,23 +1063,24 @@ function fixUrlStr(url) {
947
1063
  * console.log(COUNTER); // 1
948
1064
  * ```
949
1065
  */
950
- class Cache$1 {
951
- constructor(options = {}) {
1066
+ var Cache$1 = /** @class */ (function () {
1067
+ function Cache(options) {
1068
+ if (options === void 0) { options = {}; }
952
1069
  var _a;
953
1070
  this.cache = [];
954
- const namespace = (_a = options.namespace) !== null && _a !== void 0 ? _a : 'default';
955
- if (Cache$1.instance[namespace]) {
956
- return Cache$1.instance[namespace];
1071
+ var namespace = (_a = options.namespace) !== null && _a !== void 0 ? _a : 'default';
1072
+ if (Cache.instance[namespace]) {
1073
+ return Cache.instance[namespace];
957
1074
  }
958
- Cache$1.instance[namespace] = this;
1075
+ Cache.instance[namespace] = this;
959
1076
  return this;
960
1077
  }
961
- clean() {
1078
+ Cache.prototype.clean = function () {
962
1079
  this.cache.length = 0;
963
- }
964
- all() {
1080
+ };
1081
+ Cache.prototype.all = function () {
965
1082
  return this.cache;
966
- }
1083
+ };
967
1084
  /**
968
1085
  * Caching only a non-empty value.
969
1086
  *
@@ -986,23 +1103,24 @@ class Cache$1 {
986
1103
  *
987
1104
  * ```
988
1105
  */
989
- addFull(key, valueToSet, props) {
1106
+ Cache.prototype.addFull = function (key, valueToSet, props) {
990
1107
  return this.add(key, valueToSet, props, true);
991
- }
992
- add(key, valueToSet, props, onlyFull) {
993
- const exist = this._find(key, props);
1108
+ };
1109
+ Cache.prototype.add = function (key, valueToSet, props, onlyFull) {
1110
+ var _this = this;
1111
+ var exist = this._find(key, props);
994
1112
  if (!exist) {
995
- let value;
1113
+ var value = void 0;
996
1114
  if (valueToSet instanceof Function) {
997
1115
  value = valueToSet();
998
1116
  }
999
1117
  else {
1000
1118
  value = valueToSet;
1001
1119
  }
1002
- const props_ = props && JSON.parse(JSON.stringify(objectRemoveEmpty(props)));
1003
- const cacheItem = {
1004
- key,
1005
- value,
1120
+ var props_ = props && JSON.parse(JSON.stringify(objectRemoveEmpty(props)));
1121
+ var cacheItem = {
1122
+ key: key,
1123
+ value: value,
1006
1124
  props: props_,
1007
1125
  // TODO: remove backward compatibility use only props
1008
1126
  options: props_,
@@ -1012,14 +1130,14 @@ class Cache$1 {
1012
1130
  }
1013
1131
  this.cache.push(cacheItem);
1014
1132
  if (value instanceof Promise) {
1015
- value.catch((er) => {
1016
- this.delete(key, props);
1133
+ value.catch(function (er) {
1134
+ _this.delete(key, props);
1017
1135
  throw er;
1018
1136
  });
1019
1137
  if (onlyFull) {
1020
- value.then((x) => {
1138
+ value.then(function (x) {
1021
1139
  if (!full(x)) {
1022
- this.delete(key, props);
1140
+ _this.delete(key, props);
1023
1141
  }
1024
1142
  return x;
1025
1143
  });
@@ -1031,50 +1149,55 @@ class Cache$1 {
1031
1149
  else {
1032
1150
  return exist.value;
1033
1151
  }
1034
- }
1035
- match(key, props) {
1036
- const cacheRecord = this._find(key, props);
1152
+ };
1153
+ Cache.prototype.match = function (key, props) {
1154
+ var cacheRecord = this._find(key, props);
1037
1155
  if (cacheRecord) {
1038
1156
  return cacheRecord.value;
1039
1157
  }
1040
- }
1041
- matchAll(key, props) {
1158
+ };
1159
+ Cache.prototype.matchAll = function (key, props) {
1160
+ var _this = this;
1042
1161
  if (key) {
1043
1162
  return this.cache
1044
- .filter((x) => this._filter(x, key, props))
1045
- .map((x) => x.value);
1163
+ .filter(function (x) { return _this._filter(x, key, props); })
1164
+ .map(function (x) { return x.value; });
1046
1165
  }
1047
- return this.cache.map((x) => x.value);
1048
- }
1049
- delete(keyOrItem, props) {
1050
- let exist = [];
1166
+ return this.cache.map(function (x) { return x.value; });
1167
+ };
1168
+ Cache.prototype.delete = function (keyOrItem, props) {
1169
+ var _this = this;
1170
+ var exist = [];
1051
1171
  if (typeof keyOrItem === 'string') {
1052
- exist = this.cache.filter((x) => this._filter(x, keyOrItem, props));
1172
+ exist = this.cache.filter(function (x) { return _this._filter(x, keyOrItem, props); });
1053
1173
  }
1054
1174
  else {
1055
1175
  exist.push(keyOrItem);
1056
1176
  }
1057
- for (const e of exist) {
1058
- const index = this.cache.indexOf(e);
1177
+ for (var _i = 0, exist_1 = exist; _i < exist_1.length; _i++) {
1178
+ var e = exist_1[_i];
1179
+ var index = this.cache.indexOf(e);
1059
1180
  this.cache.splice(index, 1);
1060
1181
  }
1061
- }
1062
- _find(key, props) {
1063
- return this.cache.find((x) => this._filter(x, key, props));
1064
- }
1065
- _filter(item, key, props) {
1182
+ };
1183
+ Cache.prototype._find = function (key, props) {
1184
+ var _this = this;
1185
+ return this.cache.find(function (x) { return _this._filter(x, key, props); });
1186
+ };
1187
+ Cache.prototype._filter = function (item, key, props) {
1066
1188
  if (item.key === key) {
1067
1189
  if (props) {
1068
1190
  // TODO: remove backward compatibility
1069
- const itemProps = item.props || item.options;
1191
+ var itemProps = item.props || item.options;
1070
1192
  return objectDeepEqual(itemProps || {}, objectRemoveEmpty(props));
1071
1193
  }
1072
1194
  return true;
1073
1195
  }
1074
1196
  return false;
1075
- }
1076
- }
1077
- Cache$1.instance = {};
1197
+ };
1198
+ Cache.instance = {};
1199
+ return Cache;
1200
+ }());
1078
1201
 
1079
1202
  /**
1080
1203
  * Caching for asynchronous functions
@@ -1087,43 +1210,49 @@ var Cache = Cache$1;
1087
1210
  /**
1088
1211
  * Thrown when...
1089
1212
  */
1090
- class NgwError extends Error {
1091
- constructor(er) {
1092
- super();
1093
- this.name = 'NgwError';
1094
- Object.assign(this, er);
1095
- Object.setPrototypeOf(this, NgwError.prototype);
1096
- }
1097
- }
1213
+ var NetworkError = /** @class */ (function (_super) {
1214
+ __extends(NetworkError, _super);
1215
+ function NetworkError(url) {
1216
+ var _this = _super.call(this) || this;
1217
+ _this.name = 'NetworkError';
1218
+ Object.setPrototypeOf(_this, NetworkError.prototype);
1219
+ _this.message = "Unable to request ".concat(url, ".\n Possibly invalid NGW URL entered or CORS not configured to get request from ").concat(location.origin); // /control-panel/cors
1220
+ return _this;
1221
+ }
1222
+ return NetworkError;
1223
+ }(Error));
1098
1224
 
1099
1225
  /**
1100
1226
  * Thrown when...
1101
1227
  */
1102
- class NetworkError extends Error {
1103
- constructor(url) {
1104
- super();
1105
- this.name = 'NetworkError';
1106
- Object.setPrototypeOf(this, NetworkError.prototype);
1107
- this.message = `Unable to request ${url}.
1108
- Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`; // /control-panel/cors
1109
- }
1110
- }
1228
+ var NgwError = /** @class */ (function (_super) {
1229
+ __extends(NgwError, _super);
1230
+ function NgwError(er) {
1231
+ var _this = _super.call(this) || this;
1232
+ _this.name = 'NgwError';
1233
+ Object.assign(_this, er);
1234
+ Object.setPrototypeOf(_this, NgwError.prototype);
1235
+ return _this;
1236
+ }
1237
+ return NgwError;
1238
+ }(Error));
1111
1239
 
1112
1240
  function isObject(val) {
1113
1241
  return Object.prototype.toString.call(val) === '[object Object]';
1114
1242
  }
1115
1243
 
1116
- let loadData;
1244
+ var loadData;
1117
1245
  // @ts-ignore
1118
1246
  {
1119
- loadData = (url, callback, options = {}, error, onCancel) => {
1247
+ loadData = function (url, callback, options, error, onCancel) {
1248
+ if (options === void 0) { options = {}; }
1120
1249
  options.method = options.method || 'GET';
1121
- const xhr = new XMLHttpRequest();
1250
+ var xhr = new XMLHttpRequest();
1122
1251
  xhr.open(options.method || 'GET', url, true); // true for asynchronous
1123
1252
  if (options.responseType === 'blob') {
1124
1253
  xhr.responseType = options.responseType;
1125
1254
  }
1126
- const getResponseText = () => {
1255
+ var getResponseText = function () {
1127
1256
  try {
1128
1257
  return JSON.parse(xhr.responseText);
1129
1258
  }
@@ -1131,8 +1260,9 @@ let loadData;
1131
1260
  return xhr.responseText;
1132
1261
  }
1133
1262
  };
1134
- const processingResponse = (forError = false) => {
1135
- const cb = forError ? error : callback;
1263
+ var processingResponse = function (forError) {
1264
+ if (forError === void 0) { forError = false; }
1265
+ var cb = forError ? error : callback;
1136
1266
  if (options.responseType === 'blob') {
1137
1267
  cb(xhr.response);
1138
1268
  }
@@ -1145,7 +1275,7 @@ let loadData;
1145
1275
  }
1146
1276
  }
1147
1277
  };
1148
- xhr.onload = () => {
1278
+ xhr.onload = function () {
1149
1279
  if ([401, 403, 404, 422, 500].indexOf(xhr.status) !== -1) {
1150
1280
  error(new NgwError(getResponseText()));
1151
1281
  }
@@ -1167,7 +1297,7 @@ let loadData;
1167
1297
  // error('request error');
1168
1298
  // }
1169
1299
  // };
1170
- xhr.onerror = (er) => {
1300
+ xhr.onerror = function (er) {
1171
1301
  if (xhr.status === 0) {
1172
1302
  error(new NetworkError(url));
1173
1303
  }
@@ -1177,17 +1307,17 @@ let loadData;
1177
1307
  };
1178
1308
  xhr.upload.onprogress = function (e) {
1179
1309
  if (e.lengthComputable) {
1180
- const percentComplete = (e.loaded / e.total) * 100;
1310
+ var percentComplete = (e.loaded / e.total) * 100;
1181
1311
  if (options.onProgress) {
1182
1312
  options.onProgress(percentComplete, e);
1183
1313
  }
1184
1314
  // console.log(percentComplete + '% uploaded');
1185
1315
  }
1186
1316
  };
1187
- const headers = options.headers;
1317
+ var headers = options.headers;
1188
1318
  if (headers) {
1189
- for (const h in headers) {
1190
- const header = headers[h];
1319
+ for (var h in headers) {
1320
+ var header = headers[h];
1191
1321
  if (typeof header === 'string') {
1192
1322
  xhr.setRequestHeader(h, header);
1193
1323
  }
@@ -1196,12 +1326,12 @@ let loadData;
1196
1326
  if (options.withCredentials !== undefined) {
1197
1327
  xhr.withCredentials = options.withCredentials;
1198
1328
  }
1199
- let data;
1329
+ var data;
1200
1330
  if (options.file) {
1201
1331
  data = new FormData();
1202
1332
  data.append('file', options.file);
1203
1333
  if (options.data) {
1204
- for (const d in options.data) {
1334
+ for (var d in options.data) {
1205
1335
  data.append(d, data[d]);
1206
1336
  }
1207
1337
  }
@@ -1214,7 +1344,7 @@ let loadData;
1214
1344
  : null;
1215
1345
  }
1216
1346
  if (onCancel) {
1217
- onCancel(() => {
1347
+ onCancel(function () {
1218
1348
  xhr.abort();
1219
1349
  });
1220
1350
  }
@@ -1223,10 +1353,10 @@ let loadData;
1223
1353
  }
1224
1354
 
1225
1355
  // https://github.com/Leaflet/Leaflet/blob/b507e21c510b53cd704fb8d3f89bb46ea925c8eb/src/core/Util.js#L165
1226
- const templateRe = /\{ *([\w_-]+) *\}/g;
1356
+ var templateRe = /\{ *([\w_-]+) *\}/g;
1227
1357
  function template(str, data) {
1228
- return str.replace(templateRe, (s, key) => {
1229
- let value = data[key];
1358
+ return str.replace(templateRe, function (s, key) {
1359
+ var value = data[key];
1230
1360
  if (value === undefined) {
1231
1361
  throw new Error('No value provided for letiable ' + s);
1232
1362
  }
@@ -1240,33 +1370,39 @@ function template(str, data) {
1240
1370
  /**
1241
1371
  * Thrown when ...
1242
1372
  */
1243
- class ResourceNotFoundError extends NgwError {
1244
- constructor(obj) {
1245
- super(obj);
1246
- this.name = 'ResourceNotFoundError';
1247
- this.exception = 'nextgisweb.resource.exception.ResourceNotFound';
1248
- Object.setPrototypeOf(this, ResourceNotFoundError.prototype);
1249
- }
1250
- }
1373
+ var ResourceNotFoundError = /** @class */ (function (_super) {
1374
+ __extends(ResourceNotFoundError, _super);
1375
+ function ResourceNotFoundError(obj) {
1376
+ var _this = _super.call(this, obj) || this;
1377
+ _this.name = 'ResourceNotFoundError';
1378
+ _this.exception = 'nextgisweb.resource.exception.ResourceNotFound';
1379
+ Object.setPrototypeOf(_this, ResourceNotFoundError.prototype);
1380
+ return _this;
1381
+ }
1382
+ return ResourceNotFoundError;
1383
+ }(NgwError));
1251
1384
 
1252
1385
  /**
1253
1386
  * Thrown when ...
1254
1387
  */
1255
- class InsufficientPermissionsError extends NgwError {
1256
- constructor(obj) {
1257
- super(obj);
1258
- this.name = 'InsufficientPermissionsError';
1259
- this.exception = 'nextgisweb.core.exception.InsufficientPermissions';
1260
- Object.setPrototypeOf(this, InsufficientPermissionsError.prototype);
1261
- }
1262
- }
1263
-
1264
- const CONNECTORS = [];
1388
+ var InsufficientPermissionsError = /** @class */ (function (_super) {
1389
+ __extends(InsufficientPermissionsError, _super);
1390
+ function InsufficientPermissionsError(obj) {
1391
+ var _this = _super.call(this, obj) || this;
1392
+ _this.name = 'InsufficientPermissionsError';
1393
+ _this.exception = 'nextgisweb.core.exception.InsufficientPermissions';
1394
+ Object.setPrototypeOf(_this, InsufficientPermissionsError.prototype);
1395
+ return _this;
1396
+ }
1397
+ return InsufficientPermissionsError;
1398
+ }(NgwError));
1399
+
1400
+ var CONNECTORS = [];
1265
1401
  function addConnector(connector) {
1266
1402
  CONNECTORS.push(connector);
1267
1403
  }
1268
1404
  function findConnector(options) {
1269
- return CONNECTORS.find((x) => {
1405
+ return CONNECTORS.find(function (x) {
1270
1406
  if (x.options.baseUrl === options.baseUrl) {
1271
1407
  if (options.auth) {
1272
1408
  if (x.options.auth) {
@@ -1281,13 +1417,13 @@ function findConnector(options) {
1281
1417
  });
1282
1418
  }
1283
1419
  function removeConnector(connector) {
1284
- const index = CONNECTORS.indexOf(connector);
1420
+ var index = CONNECTORS.indexOf(connector);
1285
1421
  if (index !== -1) {
1286
1422
  CONNECTORS.splice(index, 1);
1287
1423
  }
1288
1424
  }
1289
1425
 
1290
- const exclude = ['description'];
1426
+ var exclude = ['description'];
1291
1427
  /**
1292
1428
  * @remarks
1293
1429
  * https://docs.nextgis.ru/docs_ngweb_dev/doc/developer/resource.html#search-resources
@@ -1298,14 +1434,16 @@ const exclude = ['description'];
1298
1434
  *
1299
1435
  * @param resource - Any property from NGW resource item
1300
1436
  */
1301
- function resourceToQuery(resource, prefix = '') {
1437
+ function resourceToQuery(resource, prefix) {
1438
+ if (prefix === void 0) { prefix = ''; }
1302
1439
  prefix = prefix ? prefix + '__' : '';
1303
- const query = {};
1304
- for (const [key, value] of Object.entries(resource)) {
1440
+ var query = {};
1441
+ for (var _i = 0, _a = Object.entries(resource); _i < _a.length; _i++) {
1442
+ var _b = _a[_i], key = _b[0], value = _b[1];
1305
1443
  if (exclude.indexOf(key) === -1) {
1306
1444
  if (isObject(value)) {
1307
1445
  if (key === 'owner_user') {
1308
- const children = resourceToQuery(value, key);
1446
+ var children = resourceToQuery(value, key);
1309
1447
  Object.assign(query, children);
1310
1448
  }
1311
1449
  else if (key === 'parent' && 'id' in value) {
@@ -1324,8 +1462,8 @@ function resourceCompare(res1, res2) {
1324
1462
  return objectDeepEqual(res1, res2);
1325
1463
  }
1326
1464
 
1327
- class ResourcesControl {
1328
- constructor(connector) {
1465
+ var ResourcesControl = /** @class */ (function () {
1466
+ function ResourcesControl(connector) {
1329
1467
  this.connector = connector;
1330
1468
  this.cache = new Cache();
1331
1469
  }
@@ -1339,10 +1477,11 @@ class ResourcesControl {
1339
1477
  * @remarks
1340
1478
  * Fetching resource would be cached to speed up next call
1341
1479
  */
1342
- getOne(resource, requestOptions) {
1343
- const cache = new Cache();
1344
- const forCache = {};
1345
- const opt = { ...requestOptions, cache: false };
1480
+ ResourcesControl.prototype.getOne = function (resource, requestOptions) {
1481
+ var _this = this;
1482
+ var cache = new Cache();
1483
+ var forCache = {};
1484
+ var opt = __assign(__assign({}, requestOptions), { cache: false });
1346
1485
  if (typeof resource === 'string') {
1347
1486
  forCache.keyname = resource;
1348
1487
  }
@@ -1350,30 +1489,35 @@ class ResourcesControl {
1350
1489
  forCache.id = resource;
1351
1490
  }
1352
1491
  else if (isObject(resource)) {
1353
- forCache.id = resource.id;
1492
+ if (resource.id !== undefined) {
1493
+ forCache.id = resource.id;
1494
+ }
1495
+ else if (resource.keyname) {
1496
+ forCache.keyname = resource.keyname;
1497
+ }
1354
1498
  }
1355
- const makeRequest = () => {
1499
+ var makeRequest = function () {
1356
1500
  if (typeof resource === 'string') {
1357
- return this._fetchResourceBy({ keyname: resource }, opt);
1501
+ return _this._fetchResourceBy({ keyname: resource }, opt);
1358
1502
  }
1359
1503
  else if (typeof resource === 'number') {
1360
- return this._fetchResourceById(resource, opt);
1504
+ return _this._fetchResourceById(resource, opt);
1361
1505
  }
1362
1506
  else if (isObject(resource)) {
1363
- return this._fetchResourceBy(resource, opt);
1507
+ return _this._fetchResourceBy(resource, opt);
1364
1508
  }
1365
1509
  return CancelablePromise.resolve(undefined);
1366
1510
  };
1367
1511
  return cache.addFull('resource', makeRequest, forCache);
1368
- }
1369
- getOneOrFail(resource, requestOptions) {
1370
- return this.getOne(resource, requestOptions).then((res) => {
1512
+ };
1513
+ ResourcesControl.prototype.getOneOrFail = function (resource, requestOptions) {
1514
+ return this.getOne(resource, requestOptions).then(function (res) {
1371
1515
  if (res) {
1372
1516
  return res;
1373
1517
  }
1374
1518
  throw new ResourceNotFoundError();
1375
1519
  });
1376
- }
1520
+ };
1377
1521
  /**
1378
1522
  * A fast way to retrieve resource ID for any resource definition.
1379
1523
  * @param resource - Any available resource definition
@@ -1384,19 +1528,19 @@ class ResourcesControl {
1384
1528
  * then this method will come in handy to facilitate the extraction of the identifier
1385
1529
  * if the resource is specified through a keyname or other parameters.
1386
1530
  */
1387
- getId(resource, requestOptions) {
1531
+ ResourcesControl.prototype.getId = function (resource, requestOptions) {
1388
1532
  if (typeof resource === 'number') {
1389
1533
  return CancelablePromise.resolve(resource);
1390
1534
  }
1391
1535
  else if (typeof resource === 'string' || isObject(resource)) {
1392
- return this.getOne(resource, requestOptions).then((res) => {
1536
+ return this.getOne(resource, requestOptions).then(function (res) {
1393
1537
  if (res) {
1394
1538
  return res.resource.id;
1395
1539
  }
1396
1540
  });
1397
1541
  }
1398
1542
  return CancelablePromise.resolve(undefined);
1399
- }
1543
+ };
1400
1544
  /**
1401
1545
  * A fast way to retrieve resource ID for any resource definition.
1402
1546
  * @param resource - Any available resource definition
@@ -1405,33 +1549,32 @@ class ResourcesControl {
1405
1549
  * Similar with {@link NgwConnector.getResourceId | getResourceId} but rise error if resource is not exist.
1406
1550
  * To not make one more checks if the resource is definitely exists
1407
1551
  */
1408
- getIdOrFail(resource, requestOptions) {
1409
- return this.getId(resource, requestOptions).then((resp) => {
1552
+ ResourcesControl.prototype.getIdOrFail = function (resource, requestOptions) {
1553
+ return this.getId(resource, requestOptions).then(function (resp) {
1410
1554
  if (resp === undefined) {
1411
1555
  throw new Error();
1412
1556
  }
1413
1557
  return resp;
1414
1558
  });
1415
- }
1416
- getMany(resource, requestOptions) {
1417
- return this._resourceCacheFilter(resource).then((items) => {
1559
+ };
1560
+ ResourcesControl.prototype.getMany = function (resource, requestOptions) {
1561
+ var _this = this;
1562
+ return this._resourceCacheFilter(resource).then(function (items) {
1418
1563
  if (!items.length) {
1419
- const query = {};
1564
+ var query = {};
1420
1565
  if (resource.keyname) {
1421
1566
  query.keyname = resource.keyname;
1422
1567
  }
1423
1568
  else {
1424
1569
  Object.assign(query, resourceToQuery(resource));
1425
1570
  }
1426
- return this.connector
1427
- .get('resource.search', requestOptions, {
1428
- serialization: 'full',
1429
- ...query,
1430
- })
1431
- .then((resources) => {
1571
+ return _this.connector
1572
+ .get('resource.search', requestOptions, __assign({ serialization: 'full' }, query))
1573
+ .then(function (resources) {
1432
1574
  if (resources) {
1433
- for (const x of resources) {
1434
- this.cache.add('resource.item', CancelablePromise.resolve(x), {
1575
+ for (var _i = 0, resources_1 = resources; _i < resources_1.length; _i++) {
1576
+ var x = resources_1[_i];
1577
+ _this.cache.add('resource.item', CancelablePromise.resolve(x), {
1435
1578
  id: x.resource.id,
1436
1579
  });
1437
1580
  }
@@ -1441,97 +1584,137 @@ class ResourcesControl {
1441
1584
  }
1442
1585
  return items;
1443
1586
  });
1444
- }
1445
- getParent(resource, requestOptions) {
1446
- return this.getOne(resource, requestOptions).then((child) => {
1587
+ };
1588
+ ResourcesControl.prototype.getParent = function (resource, requestOptions) {
1589
+ var _this = this;
1590
+ return this.getOne(resource, requestOptions).then(function (child) {
1447
1591
  if (child) {
1448
- return this.getOne(child.resource.parent.id, requestOptions);
1592
+ return _this.getOne(child.resource.parent.id, requestOptions);
1449
1593
  }
1450
1594
  return CancelablePromise.resolve(undefined);
1451
1595
  });
1452
- }
1453
- getChildrenOf(resource, requestOptions) {
1454
- return this.getId(resource).then((parent) => {
1455
- return this.connector
1456
- .get('resource.collection', { cache: true, ...requestOptions }, {
1457
- parent,
1458
- })
1459
- .then((items) => {
1460
- for (const i of items) {
1461
- this.cache.add('resource.item', CancelablePromise.resolve(i), {
1462
- id: i.resource.id,
1463
- });
1596
+ };
1597
+ ResourcesControl.prototype.getChildrenOf = function (resource, requestOptions) {
1598
+ var _this = this;
1599
+ return this.getIdOrFail(resource).then(function (parent) {
1600
+ return _this._getChildrenOf(parent, requestOptions);
1601
+ });
1602
+ };
1603
+ ResourcesControl.prototype._getChildrenOf = function (parent, requestOptions, _items) {
1604
+ var _this = this;
1605
+ if (_items === void 0) { _items = []; }
1606
+ return this.connector
1607
+ .get('resource.collection', __assign({ cache: true }, requestOptions), {
1608
+ parent: parent,
1609
+ })
1610
+ .then(function (items) {
1611
+ var recursivePromises = [];
1612
+ for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
1613
+ var item = items_1[_i];
1614
+ _this.cache.add('resource.item', CancelablePromise.resolve(item), {
1615
+ id: item.resource.id,
1616
+ });
1617
+ _items.push(item);
1618
+ if ((requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.recursive) && item.resource.children) {
1619
+ recursivePromises.push(_this._getChildrenOf(item.resource.id, requestOptions, _items));
1464
1620
  }
1465
- return items;
1466
- });
1621
+ }
1622
+ if (recursivePromises.length) {
1623
+ return CancelablePromise.all(recursivePromises).then(function () {
1624
+ return _items;
1625
+ });
1626
+ }
1627
+ return _items;
1467
1628
  });
1468
- }
1469
- update(resource, data) {
1470
- return this.getId(resource).then((id) => {
1629
+ };
1630
+ ResourcesControl.prototype.update = function (resource, data) {
1631
+ var _this = this;
1632
+ return this.getId(resource).then(function (id) {
1471
1633
  if (id !== undefined) {
1472
- return this.connector.put('resource.item', { data }, { id });
1634
+ return _this.connector.put('resource.item', { data: data }, { id: id });
1473
1635
  }
1474
1636
  });
1475
- }
1637
+ };
1476
1638
  /**
1477
1639
  * Fast way to delete resource from NGW and clean cache.
1478
1640
  * @param resource - Resource definition
1479
1641
  */
1480
- delete(resource) {
1481
- return this.getId(resource).then((id) => {
1642
+ ResourcesControl.prototype.delete = function (resource) {
1643
+ var _this = this;
1644
+ return this.getId(resource).then(function (id) {
1482
1645
  if (id !== undefined) {
1483
- return this.connector.delete('resource.item', null, { id }).then(() => {
1484
- this._cleanResourceItemCache(id);
1646
+ return _this.connector.delete('resource.item', null, { id: id }).then(function () {
1647
+ _this._cleanResourceItemCache(id);
1485
1648
  return undefined;
1486
1649
  });
1487
1650
  }
1488
1651
  });
1489
- }
1490
- async _cleanResourceItemCache(id) {
1491
- const all = this.cache.all();
1492
- const toDelete = [];
1493
- for (const c of all) {
1494
- const cid = c.options && c.options.id;
1495
- if (['resource.item', 'resource'].includes(c.key) && cid !== undefined) {
1496
- if (typeof cid === 'number') {
1497
- if (cid === id) {
1498
- toDelete.push(c);
1499
- }
1500
- }
1501
- else {
1502
- const rid = await this.getId(cid);
1503
- if (rid === id) {
1504
- toDelete.push(c);
1505
- }
1652
+ };
1653
+ ResourcesControl.prototype._cleanResourceItemCache = function (id) {
1654
+ return __awaiter(this, void 0, void 0, function () {
1655
+ var all, toDelete, _i, all_1, c, cid, rid, _a, toDelete_1, d;
1656
+ return __generator(this, function (_b) {
1657
+ switch (_b.label) {
1658
+ case 0:
1659
+ all = this.cache.all();
1660
+ toDelete = [];
1661
+ _i = 0, all_1 = all;
1662
+ _b.label = 1;
1663
+ case 1:
1664
+ if (!(_i < all_1.length)) return [3 /*break*/, 5];
1665
+ c = all_1[_i];
1666
+ cid = c.options && c.options.id;
1667
+ if (!(['resource.item', 'resource'].includes(c.key) && cid !== undefined)) return [3 /*break*/, 4];
1668
+ if (!(typeof cid === 'number')) return [3 /*break*/, 2];
1669
+ if (cid === id) {
1670
+ toDelete.push(c);
1671
+ }
1672
+ return [3 /*break*/, 4];
1673
+ case 2: return [4 /*yield*/, this.getId(cid)];
1674
+ case 3:
1675
+ rid = _b.sent();
1676
+ if (rid === id) {
1677
+ toDelete.push(c);
1678
+ }
1679
+ _b.label = 4;
1680
+ case 4:
1681
+ _i++;
1682
+ return [3 /*break*/, 1];
1683
+ case 5:
1684
+ for (_a = 0, toDelete_1 = toDelete; _a < toDelete_1.length; _a++) {
1685
+ d = toDelete_1[_a];
1686
+ this.cache.delete(d);
1687
+ }
1688
+ return [2 /*return*/];
1506
1689
  }
1507
- }
1508
- }
1509
- for (const d of toDelete) {
1510
- this.cache.delete(d);
1511
- }
1512
- }
1513
- _fetchResourceById(id, requestOptions) {
1514
- const promise = () => this.connector.get('resource.item', requestOptions, { id });
1690
+ });
1691
+ });
1692
+ };
1693
+ ResourcesControl.prototype._fetchResourceById = function (id, requestOptions) {
1694
+ var _this = this;
1695
+ var promise = function () {
1696
+ return _this.connector.get('resource.item', requestOptions, { id: id });
1697
+ };
1515
1698
  return this.cache
1516
1699
  .add('resource.item', promise, {
1517
- id,
1700
+ id: id,
1518
1701
  })
1519
- .catch((er) => {
1702
+ .catch(function (er) {
1520
1703
  if (!(er instanceof ResourceNotFoundError)) {
1521
1704
  throw er;
1522
1705
  }
1523
1706
  return undefined;
1524
1707
  });
1525
- }
1526
- _fetchResourceBy(resource, requestOptions) {
1527
- return this.getMany(resource, requestOptions).then((resources) => {
1708
+ };
1709
+ ResourcesControl.prototype._fetchResourceBy = function (resource, requestOptions) {
1710
+ return this.getMany(resource, requestOptions).then(function (resources) {
1528
1711
  return resources[0];
1529
1712
  });
1530
- }
1531
- _resourceCacheFilter(resource) {
1532
- return CancelablePromise.all(this.cache.matchAll('resource.item')).then((resources) => {
1533
- const items = [];
1534
- resources.filter((x) => {
1713
+ };
1714
+ ResourcesControl.prototype._resourceCacheFilter = function (resource) {
1715
+ return CancelablePromise.all(this.cache.matchAll('resource.item')).then(function (resources) {
1716
+ var items = [];
1717
+ resources.filter(function (x) {
1535
1718
  if (x) {
1536
1719
  // identical by uniq props
1537
1720
  if (resource.keyname && x.resource.keyname) {
@@ -1545,23 +1728,24 @@ class ResourcesControl {
1545
1728
  });
1546
1729
  return items;
1547
1730
  });
1548
- }
1549
- }
1731
+ };
1732
+ return ResourcesControl;
1733
+ }());
1550
1734
 
1551
1735
  function apiRequest(opt) {
1552
- const params = opt.params;
1553
- return new CancelablePromise((resolve, reject) => {
1736
+ var params = opt.params;
1737
+ return new CancelablePromise(function (resolve, reject) {
1554
1738
  opt.connector
1555
1739
  .connect()
1556
- .then((apiItems) => {
1557
- let apiItem = apiItems && apiItems[opt.name];
1740
+ .then(function (apiItems) {
1741
+ var apiItem = apiItems && apiItems[opt.name];
1558
1742
  if (apiItem) {
1559
- apiItem = [...apiItem];
1560
- let url = apiItem.shift();
1743
+ apiItem = __spreadArray([], apiItem, true);
1744
+ var url = apiItem.shift();
1561
1745
  if (apiItem.length) {
1562
- const replaceParams = {};
1563
- for (let fry = 0; fry < apiItem.length; fry++) {
1564
- const arg = apiItem[fry];
1746
+ var replaceParams = {};
1747
+ for (var fry = 0; fry < apiItem.length; fry++) {
1748
+ var arg = apiItem[fry];
1565
1749
  replaceParams[fry] = '{' + arg + '}';
1566
1750
  if (params[arg] === undefined) {
1567
1751
  throw new Error('`' + arg + '`' + ' url api argument is not specified');
@@ -1573,21 +1757,21 @@ function apiRequest(opt) {
1573
1757
  }
1574
1758
  // Transfer part of the parameters from `params` to the URL string
1575
1759
  if (params) {
1576
- const paramArray = [];
1577
- const paramList = params.paramList;
1760
+ var paramArray_1 = [];
1761
+ var paramList = params.paramList;
1578
1762
  if (Array.isArray(paramList)) {
1579
1763
  delete params.paramList;
1580
- paramList.forEach((x) => {
1581
- paramArray.push(`${x[0]}=${x[1]}`);
1764
+ paramList.forEach(function (x) {
1765
+ paramArray_1.push("".concat(x[0], "=").concat(x[1]));
1582
1766
  });
1583
1767
  }
1584
- for (const p in params) {
1768
+ for (var p in params) {
1585
1769
  if (apiItem.indexOf(p) === -1) {
1586
- paramArray.push(`${p}=${params[p]}`);
1770
+ paramArray_1.push("".concat(p, "=").concat(params[p]));
1587
1771
  }
1588
1772
  }
1589
- if (paramArray.length) {
1590
- url = url + '?' + paramArray.join('&');
1773
+ if (paramArray_1.length) {
1774
+ url = url + '?' + paramArray_1.join('&');
1591
1775
  }
1592
1776
  }
1593
1777
  if (url) {
@@ -1601,20 +1785,20 @@ function apiRequest(opt) {
1601
1785
  resolve(undefined);
1602
1786
  }
1603
1787
  })
1604
- .catch((er) => {
1788
+ .catch(function (er) {
1605
1789
  reject(er);
1606
1790
  });
1607
1791
  });
1608
1792
  }
1609
1793
 
1610
- let ID = 0;
1611
- class NgwConnector$1 {
1612
- constructor(options) {
1794
+ var ID = 0;
1795
+ var NgwConnector$1 = /** @class */ (function () {
1796
+ function NgwConnector(options) {
1613
1797
  this.options = options;
1614
1798
  this.id = ID++;
1615
1799
  this.emitter = new events.exports.EventEmitter();
1616
1800
  this.routeStr = '/api/component/pyramid/route';
1617
- const exist = findConnector(options);
1801
+ var exist = findConnector(options);
1618
1802
  if (exist) {
1619
1803
  return exist;
1620
1804
  }
@@ -1626,19 +1810,19 @@ class NgwConnector$1 {
1626
1810
  addConnector(this);
1627
1811
  }
1628
1812
  }
1629
- static create(options) {
1813
+ NgwConnector.create = function (options) {
1630
1814
  return new this(options);
1631
- }
1815
+ };
1632
1816
  /**
1633
1817
  * Fast way to specify the connection address to NextGIS Web.
1634
1818
  * The current connection will be severed.
1635
1819
  * @param baseUrl - NGW url
1636
1820
  */
1637
- setNgw(baseUrl) {
1821
+ NgwConnector.prototype.setNgw = function (baseUrl) {
1638
1822
  this.logout();
1639
1823
  this.options.baseUrl = baseUrl;
1640
1824
  addConnector(this);
1641
- }
1825
+ };
1642
1826
  /**
1643
1827
  * Establishing a connection with NextGIS Web to fulfill all other requests.
1644
1828
  * @remarks
@@ -1652,101 +1836,105 @@ class NgwConnector$1 {
1652
1836
  * .catch((er) => console.log('Connection problem', er));
1653
1837
  * ```
1654
1838
  */
1655
- connect() {
1656
- const cache = new Cache();
1657
- const auth = this.options.auth;
1658
- const makeConnect = () => new CancelablePromise((resolve, reject) => {
1659
- const makeQuery = () => {
1660
- return this.makeQuery(this.routeStr, {}, {})
1661
- .then((route) => {
1662
- resolve(route);
1663
- })
1664
- .catch((er) => {
1665
- reject(er);
1666
- });
1667
- };
1668
- if (auth) {
1669
- const { login, password } = auth;
1670
- if (login && password) {
1671
- return this.getUserInfo({ login, password })
1672
- .then(() => {
1673
- makeQuery();
1839
+ NgwConnector.prototype.connect = function () {
1840
+ var _this = this;
1841
+ var cache = new Cache();
1842
+ var auth = this.options.auth;
1843
+ var makeConnect = function () {
1844
+ return new CancelablePromise(function (resolve, reject) {
1845
+ var makeQuery = function () {
1846
+ return _this.makeQuery(_this.routeStr, {}, {})
1847
+ .then(function (route) {
1848
+ resolve(route);
1674
1849
  })
1675
- .catch((er) => reject(er));
1850
+ .catch(function (er) {
1851
+ reject(er);
1852
+ });
1853
+ };
1854
+ if (auth) {
1855
+ var login = auth.login, password = auth.password;
1856
+ if (login && password) {
1857
+ return _this.getUserInfo({ login: login, password: password })
1858
+ .then(function () {
1859
+ makeQuery();
1860
+ })
1861
+ .catch(function (er) { return reject(er); });
1862
+ }
1676
1863
  }
1677
- }
1678
- return makeQuery();
1679
- });
1864
+ return makeQuery();
1865
+ });
1866
+ };
1680
1867
  return cache.add('route', makeConnect, {
1681
1868
  id: this.id,
1682
- auth,
1869
+ auth: auth,
1683
1870
  baseUrl: this.options.baseUrl,
1684
1871
  });
1685
- }
1872
+ };
1686
1873
  /**
1687
1874
  * Quick way to change NextGIS Web user.
1688
1875
  * @param credentials - New user credentials
1689
1876
  */
1690
- login(credentials) {
1877
+ NgwConnector.prototype.login = function (credentials) {
1691
1878
  this.logout();
1692
1879
  addConnector(this);
1693
1880
  return this.getUserInfo(credentials);
1694
- }
1881
+ };
1695
1882
  /**
1696
1883
  * Disconnecting a user. Aborting all current requests
1697
1884
  */
1698
- logout() {
1885
+ NgwConnector.prototype.logout = function () {
1699
1886
  removeConnector(this);
1700
1887
  this.options.auth = undefined;
1701
1888
  this.user = undefined;
1702
1889
  this.emitter.emit('logout');
1703
1890
  this.resources.cache.clean();
1704
- }
1705
- getUserInfo(credentials) {
1891
+ };
1892
+ NgwConnector.prototype.getUserInfo = function (credentials) {
1893
+ var _this = this;
1706
1894
  if (this.user && this.user.id) {
1707
1895
  return CancelablePromise.resolve(this.user);
1708
1896
  }
1709
1897
  if (credentials) {
1710
1898
  this.options.auth = credentials;
1711
1899
  }
1712
- const options = {
1900
+ var options = {
1713
1901
  headers: this.getAuthorizationHeaders(credentials),
1714
1902
  // withCredentials: true
1715
1903
  };
1716
1904
  // Do not use apiRequest('auth.current_user') to avoid circular-references
1717
1905
  return this.makeQuery('/api/component/auth/current_user', {}, options)
1718
- .then((data) => {
1719
- this.user = data;
1720
- this.emitter.emit('login', data);
1906
+ .then(function (data) {
1907
+ _this.user = data;
1908
+ _this.emitter.emit('login', data);
1721
1909
  return data;
1722
1910
  })
1723
- .catch((er) => {
1724
- this.emitter.emit('login:error', er);
1911
+ .catch(function (er) {
1912
+ _this.emitter.emit('login:error', er);
1725
1913
  throw er;
1726
1914
  });
1727
- }
1915
+ };
1728
1916
  /**
1729
1917
  * Obtaining the required Headers for authentication of requests in the NGW.
1730
1918
  */
1731
- getAuthorizationHeaders(credentials) {
1732
- const client = this.makeClientId(credentials);
1919
+ NgwConnector.prototype.getAuthorizationHeaders = function (credentials) {
1920
+ var client = this.makeClientId(credentials);
1733
1921
  if (client) {
1734
1922
  return {
1735
1923
  Authorization: 'Basic ' + client,
1736
1924
  };
1737
1925
  }
1738
- }
1739
- makeClientId(credentials) {
1926
+ };
1927
+ NgwConnector.prototype.makeClientId = function (credentials) {
1740
1928
  credentials = credentials || this.options.auth;
1741
1929
  if (credentials) {
1742
- const { login, password } = credentials;
1743
- const str = unescape(encodeURIComponent(`${login}:${password}`));
1930
+ var login = credentials.login, password = credentials.password;
1931
+ var str = unescape(encodeURIComponent("".concat(login, ":").concat(password)));
1744
1932
  // @ts-ignore
1745
1933
  {
1746
1934
  return window.btoa(str);
1747
1935
  }
1748
1936
  }
1749
- }
1937
+ };
1750
1938
  /**
1751
1939
  * Send request to NGW api router.
1752
1940
  * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
@@ -1776,25 +1964,27 @@ class NgwConnector$1 {
1776
1964
  *
1777
1965
  * ```
1778
1966
  */
1779
- apiRequest(name, params_ = {}, requestOptions = {}) {
1780
- const { method, headers, withCredentials, responseType } = requestOptions;
1781
- const params = objectRemoveEmpty(params_);
1782
- const makeApiRequest = () => apiRequest({ name, params, requestOptions, connector: this });
1967
+ NgwConnector.prototype.apiRequest = function (name, params_, requestOptions) {
1968
+ var _this = this;
1969
+ if (params_ === void 0) { params_ = {}; }
1970
+ if (requestOptions === void 0) { requestOptions = {}; }
1971
+ var method = requestOptions.method, headers = requestOptions.headers, withCredentials = requestOptions.withCredentials, responseType = requestOptions.responseType;
1972
+ var params = objectRemoveEmpty(params_);
1973
+ var makeApiRequest = function () {
1974
+ return apiRequest({ name: name, params: params, requestOptions: requestOptions, connector: _this });
1975
+ };
1783
1976
  if (requestOptions.cache && method === 'GET') {
1784
- const cache = new Cache();
1785
- return cache.add(name, makeApiRequest, {
1786
- params,
1787
- ...objectRemoveEmpty({
1788
- headers,
1789
- withCredentials,
1790
- responseType,
1791
- baseUrl: this.options.baseUrl,
1792
- auth: this.options.auth,
1793
- }),
1794
- });
1977
+ var cache = new Cache();
1978
+ return cache.add(name, makeApiRequest, __assign({ params: params }, objectRemoveEmpty({
1979
+ headers: headers,
1980
+ withCredentials: withCredentials,
1981
+ responseType: responseType,
1982
+ baseUrl: this.options.baseUrl,
1983
+ auth: this.options.auth,
1984
+ })));
1795
1985
  }
1796
1986
  return makeApiRequest();
1797
- }
1987
+ };
1798
1988
  /**
1799
1989
  * Shortcut method for send POST request to NGW.
1800
1990
  * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
@@ -1808,62 +1998,63 @@ class NgwConnector$1 {
1808
1998
  * .catch((error) => console.warn(error));
1809
1999
  * ```
1810
2000
  */
1811
- post(name, options, params) {
2001
+ NgwConnector.prototype.post = function (name, options, params) {
1812
2002
  options = options || {};
1813
2003
  options.method = 'POST';
1814
2004
  return this.apiRequest(name, params, options);
1815
- }
2005
+ };
1816
2006
  /**
1817
2007
  * Shortcut method for send GET request to NGW.
1818
2008
  * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
1819
2009
  * @param options - Request options
1820
2010
  * @param params - Request item params or query params
1821
2011
  */
1822
- get(name, options, params) {
2012
+ NgwConnector.prototype.get = function (name, options, params) {
1823
2013
  options = options || {};
1824
2014
  options.method = 'GET';
1825
2015
  return this.apiRequest(name, params, options);
1826
- }
2016
+ };
1827
2017
  /**
1828
2018
  * Shortcut method for send PATCH request to NGW.
1829
2019
  * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
1830
2020
  * @param options - Request options
1831
2021
  * @param params - Request item params or query params
1832
2022
  */
1833
- patch(name, options, params) {
2023
+ NgwConnector.prototype.patch = function (name, options, params) {
1834
2024
  options = options || {};
1835
2025
  options.method = 'PATCH';
1836
2026
  return this.apiRequest(name, params, options);
1837
- }
2027
+ };
1838
2028
  /**
1839
2029
  * Shortcut method for send PUT request to NGW.
1840
2030
  * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
1841
2031
  * @param options - Request options
1842
2032
  * @param params - Request item params or query params
1843
2033
  */
1844
- put(name, options, params) {
2034
+ NgwConnector.prototype.put = function (name, options, params) {
1845
2035
  options = options || {};
1846
2036
  options.method = 'PUT';
1847
2037
  return this.apiRequest(name, params, options);
1848
- }
2038
+ };
1849
2039
  /**
1850
2040
  * Shortcut method for send DELETE request to NGW.
1851
2041
  * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
1852
2042
  * @param options - Request options
1853
2043
  * @param params - Request item params or query params
1854
2044
  */
1855
- delete(name, options, params) {
2045
+ NgwConnector.prototype.delete = function (name, options, params) {
1856
2046
  options = options || {};
1857
2047
  options.method = 'DELETE';
1858
2048
  return this.apiRequest(name, params, options);
1859
- }
2049
+ };
1860
2050
  /**
1861
2051
  * Send request to NGW.
1862
2052
  * @param url - URL address to NGW
1863
2053
  * @param params - Query params
1864
2054
  * @param options - Request options
1865
2055
  */
1866
- makeQuery(url, params, options = {}) {
2056
+ NgwConnector.prototype.makeQuery = function (url, params, options) {
2057
+ if (options === void 0) { options = {}; }
1867
2058
  url = (this.options.baseUrl ? this.options.baseUrl : '') + url;
1868
2059
  if (url) {
1869
2060
  if (params) {
@@ -1876,112 +2067,117 @@ class NgwConnector$1 {
1876
2067
  else {
1877
2068
  throw new Error('Empty `url` not allowed');
1878
2069
  }
1879
- }
2070
+ };
1880
2071
  // -------------------------------------------------------------------------
1881
2072
  // Resource Methods
1882
2073
  // -------------------------------------------------------------------------
1883
2074
  /**
1884
2075
  * {@inheritDoc ResourcesControl.getOne}
1885
2076
  */
1886
- getResource(resource, requestOptions) {
2077
+ NgwConnector.prototype.getResource = function (resource, requestOptions) {
1887
2078
  return this.resources.getOne(resource, requestOptions);
1888
- }
2079
+ };
1889
2080
  /**
1890
2081
  * {@inheritDoc ResourcesControl.getOneOrFail}
1891
2082
  */
1892
- getResourceOrFail(resource, requestOptions) {
2083
+ NgwConnector.prototype.getResourceOrFail = function (resource, requestOptions) {
1893
2084
  return this.resources.getOneOrFail(resource, requestOptions);
1894
- }
2085
+ };
1895
2086
  /**
1896
2087
  * @deprecated - use {@link NgwConnector.getResource}
1897
2088
  */
1898
- getResourceBy(resource) {
2089
+ NgwConnector.prototype.getResourceBy = function (resource) {
1899
2090
  return this.resources.getOne(resource);
1900
- }
2091
+ };
1901
2092
  /**
1902
2093
  * @deprecated - use {@link NgwConnector.getResource}
1903
2094
  */
1904
- getResourceByKeyname(keyname) {
2095
+ NgwConnector.prototype.getResourceByKeyname = function (keyname) {
1905
2096
  return this.resources.getOne(keyname);
1906
- }
2097
+ };
1907
2098
  /**
1908
2099
  * @deprecated - use {@link NgwConnector.getResource}
1909
2100
  */
1910
- getResourceById(id) {
2101
+ NgwConnector.prototype.getResourceById = function (id) {
1911
2102
  return this.resources.getOne(id);
1912
- }
2103
+ };
1913
2104
  /**
1914
2105
  * {@inheritDoc ResourcesControl.getId}
1915
2106
  */
1916
- getResourceId(resource, requestOptions) {
2107
+ NgwConnector.prototype.getResourceId = function (resource, requestOptions) {
1917
2108
  return this.resources.getId(resource, requestOptions);
1918
- }
2109
+ };
1919
2110
  /**
1920
2111
  * {@inheritDoc ResourcesControl.getIdOrFail}
1921
2112
  */
1922
- getResourceIdOrFail(resource, requestOptions) {
2113
+ NgwConnector.prototype.getResourceIdOrFail = function (resource, requestOptions) {
1923
2114
  return this.resources.getIdOrFail(resource, requestOptions);
1924
- }
2115
+ };
1925
2116
  /**
1926
2117
  * {@inheritDoc ResourcesControl.getMany}
1927
2118
  */
1928
- getResourcesBy(resource, requestOptions) {
2119
+ NgwConnector.prototype.getResourcesBy = function (resource, requestOptions) {
1929
2120
  return this.resources.getMany(resource, requestOptions);
1930
- }
2121
+ };
1931
2122
  /**
1932
2123
  * {@inheritDoc ResourcesControl.getParent}
1933
2124
  */
1934
- getResourceParent(resource, requestOptions) {
2125
+ NgwConnector.prototype.getResourceParent = function (resource, requestOptions) {
1935
2126
  return this.resources.getParent(resource, requestOptions);
1936
- }
2127
+ };
1937
2128
  /**
1938
2129
  * {@inheritDoc ResourcesControl.getChildrenOf}
1939
2130
  */
1940
- getResourceChildren(resource, requestOptions) {
2131
+ NgwConnector.prototype.getResourceChildren = function (resource, requestOptions) {
1941
2132
  return this.resources.getChildrenOf(resource, requestOptions);
1942
- }
2133
+ };
1943
2134
  /**
1944
2135
  * {@inheritDoc ResourcesControl.update}
1945
2136
  */
1946
- updateResource(resource, data) {
2137
+ NgwConnector.prototype.updateResource = function (resource, data) {
1947
2138
  return this.resources.update(resource, data);
1948
- }
2139
+ };
1949
2140
  /**
1950
2141
  * {@inheritDoc ResourcesControl.delete}
1951
2142
  */
1952
- deleteResource(resource) {
2143
+ NgwConnector.prototype.deleteResource = function (resource) {
1953
2144
  return this.resources.delete(resource);
1954
- }
2145
+ };
1955
2146
  /**
1956
2147
  * @internal
1957
2148
  */
1958
- _loadData(url, options) {
2149
+ NgwConnector.prototype._loadData = function (url, options) {
2150
+ var _this = this;
1959
2151
  options.responseType = options.responseType || 'json';
1960
- return new CancelablePromise((resolve, reject, onCancel) => {
1961
- if (this.user) {
2152
+ var request = new CancelablePromise(function (resolve, reject, onCancel) {
2153
+ if (_this.user) {
1962
2154
  options = options || {};
1963
2155
  // options.withCredentials = true;
1964
- options.headers = {
1965
- ...this.getAuthorizationHeaders(),
1966
- ...options.headers,
1967
- };
2156
+ options.headers = __assign(__assign({}, _this.getAuthorizationHeaders()), options.headers);
1968
2157
  }
1969
2158
  loadData(url, resolve, options, reject, onCancel);
1970
- }).catch((httpError) => {
2159
+ }).catch(function (httpError) {
1971
2160
  if (httpError instanceof CancelablePromise.CancelError) ;
1972
2161
  else {
1973
2162
  // @ts-ignore
1974
2163
  {
1975
2164
  console.warn('DEV WARN', httpError);
1976
2165
  }
1977
- const er = this._handleHttpError(httpError);
2166
+ var er = _this._handleHttpError(httpError);
1978
2167
  if (er) {
1979
2168
  throw er;
1980
2169
  }
1981
2170
  }
1982
2171
  });
1983
- }
1984
- _handleHttpError(er) {
2172
+ if (options.signal &&
2173
+ typeof options.signal.addEventListener === 'function') {
2174
+ options.signal.addEventListener('abort', function () {
2175
+ request.cancel();
2176
+ });
2177
+ }
2178
+ return request;
2179
+ };
2180
+ NgwConnector.prototype._handleHttpError = function (er) {
1985
2181
  if (er) {
1986
2182
  if (er instanceof NgwError) {
1987
2183
  if (er.exception === 'nextgisweb.resource.exception.ResourceNotFound') {
@@ -1993,12 +2189,13 @@ class NgwConnector$1 {
1993
2189
  }
1994
2190
  }
1995
2191
  return er;
1996
- }
1997
- }
1998
- NgwConnector$1.errors = {
1999
- NgwError,
2000
- ResourceNotFoundError,
2001
- };
2192
+ };
2193
+ NgwConnector.errors = {
2194
+ NgwError: NgwError,
2195
+ ResourceNotFoundError: ResourceNotFoundError,
2196
+ };
2197
+ return NgwConnector;
2198
+ }());
2002
2199
 
2003
2200
  /**
2004
2201
  * A lightweight HTTP client optimized for use with {@link http://docs.nextgis.ru/docs_ngweb_dev/doc/developer/toc.html | NextGIS Web} API