@nextgis/ngw-connector 1.11.8 → 1.12.1

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.8; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-connector; version: 1.12.1; 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 NgwError = /** @class */ (function (_super) {
1214
+ __extends(NgwError, _super);
1215
+ function NgwError(er) {
1216
+ var _this = _super.call(this) || this;
1217
+ _this.name = 'NgwError';
1218
+ Object.assign(_this, er);
1219
+ Object.setPrototypeOf(_this, NgwError.prototype);
1220
+ return _this;
1221
+ }
1222
+ return NgwError;
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 NetworkError = /** @class */ (function (_super) {
1229
+ __extends(NetworkError, _super);
1230
+ function NetworkError(url) {
1231
+ var _this = _super.call(this) || this;
1232
+ _this.name = 'NetworkError';
1233
+ Object.setPrototypeOf(_this, NetworkError.prototype);
1234
+ _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
1235
+ return _this;
1236
+ }
1237
+ return NetworkError;
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,12 @@ let loadData;
1214
1344
  : null;
1215
1345
  }
1216
1346
  if (onCancel) {
1217
- onCancel(() => {
1347
+ onCancel(function () {
1348
+ xhr.abort();
1349
+ });
1350
+ }
1351
+ if (options.signal) {
1352
+ options.signal.addEventListener('abort', function () {
1218
1353
  xhr.abort();
1219
1354
  });
1220
1355
  }
@@ -1223,10 +1358,10 @@ let loadData;
1223
1358
  }
1224
1359
 
1225
1360
  // https://github.com/Leaflet/Leaflet/blob/b507e21c510b53cd704fb8d3f89bb46ea925c8eb/src/core/Util.js#L165
1226
- const templateRe = /\{ *([\w_-]+) *\}/g;
1361
+ var templateRe = /\{ *([\w_-]+) *\}/g;
1227
1362
  function template(str, data) {
1228
- return str.replace(templateRe, (s, key) => {
1229
- let value = data[key];
1363
+ return str.replace(templateRe, function (s, key) {
1364
+ var value = data[key];
1230
1365
  if (value === undefined) {
1231
1366
  throw new Error('No value provided for letiable ' + s);
1232
1367
  }
@@ -1240,33 +1375,39 @@ function template(str, data) {
1240
1375
  /**
1241
1376
  * Thrown when ...
1242
1377
  */
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
- }
1378
+ var ResourceNotFoundError = /** @class */ (function (_super) {
1379
+ __extends(ResourceNotFoundError, _super);
1380
+ function ResourceNotFoundError(obj) {
1381
+ var _this = _super.call(this, obj) || this;
1382
+ _this.name = 'ResourceNotFoundError';
1383
+ _this.exception = 'nextgisweb.resource.exception.ResourceNotFound';
1384
+ Object.setPrototypeOf(_this, ResourceNotFoundError.prototype);
1385
+ return _this;
1386
+ }
1387
+ return ResourceNotFoundError;
1388
+ }(NgwError));
1251
1389
 
1252
1390
  /**
1253
1391
  * Thrown when ...
1254
1392
  */
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 = [];
1393
+ var InsufficientPermissionsError = /** @class */ (function (_super) {
1394
+ __extends(InsufficientPermissionsError, _super);
1395
+ function InsufficientPermissionsError(obj) {
1396
+ var _this = _super.call(this, obj) || this;
1397
+ _this.name = 'InsufficientPermissionsError';
1398
+ _this.exception = 'nextgisweb.core.exception.InsufficientPermissions';
1399
+ Object.setPrototypeOf(_this, InsufficientPermissionsError.prototype);
1400
+ return _this;
1401
+ }
1402
+ return InsufficientPermissionsError;
1403
+ }(NgwError));
1404
+
1405
+ var CONNECTORS = [];
1265
1406
  function addConnector(connector) {
1266
1407
  CONNECTORS.push(connector);
1267
1408
  }
1268
1409
  function findConnector(options) {
1269
- return CONNECTORS.find((x) => {
1410
+ return CONNECTORS.find(function (x) {
1270
1411
  if (x.options.baseUrl === options.baseUrl) {
1271
1412
  if (options.auth) {
1272
1413
  if (x.options.auth) {
@@ -1281,13 +1422,13 @@ function findConnector(options) {
1281
1422
  });
1282
1423
  }
1283
1424
  function removeConnector(connector) {
1284
- const index = CONNECTORS.indexOf(connector);
1425
+ var index = CONNECTORS.indexOf(connector);
1285
1426
  if (index !== -1) {
1286
1427
  CONNECTORS.splice(index, 1);
1287
1428
  }
1288
1429
  }
1289
1430
 
1290
- const exclude = ['description'];
1431
+ var exclude = ['description'];
1291
1432
  /**
1292
1433
  * @remarks
1293
1434
  * https://docs.nextgis.ru/docs_ngweb_dev/doc/developer/resource.html#search-resources
@@ -1298,14 +1439,16 @@ const exclude = ['description'];
1298
1439
  *
1299
1440
  * @param resource - Any property from NGW resource item
1300
1441
  */
1301
- function resourceToQuery(resource, prefix = '') {
1442
+ function resourceToQuery(resource, prefix) {
1443
+ if (prefix === void 0) { prefix = ''; }
1302
1444
  prefix = prefix ? prefix + '__' : '';
1303
- const query = {};
1304
- for (const [key, value] of Object.entries(resource)) {
1445
+ var query = {};
1446
+ for (var _i = 0, _a = Object.entries(resource); _i < _a.length; _i++) {
1447
+ var _b = _a[_i], key = _b[0], value = _b[1];
1305
1448
  if (exclude.indexOf(key) === -1) {
1306
1449
  if (isObject(value)) {
1307
1450
  if (key === 'owner_user') {
1308
- const children = resourceToQuery(value, key);
1451
+ var children = resourceToQuery(value, key);
1309
1452
  Object.assign(query, children);
1310
1453
  }
1311
1454
  else if (key === 'parent' && 'id' in value) {
@@ -1324,8 +1467,8 @@ function resourceCompare(res1, res2) {
1324
1467
  return objectDeepEqual(res1, res2);
1325
1468
  }
1326
1469
 
1327
- class ResourcesControl {
1328
- constructor(connector) {
1470
+ var ResourcesControl = /** @class */ (function () {
1471
+ function ResourcesControl(connector) {
1329
1472
  this.connector = connector;
1330
1473
  this.cache = new Cache();
1331
1474
  }
@@ -1339,10 +1482,11 @@ class ResourcesControl {
1339
1482
  * @remarks
1340
1483
  * Fetching resource would be cached to speed up next call
1341
1484
  */
1342
- getOne(resource, requestOptions) {
1343
- const cache = new Cache();
1344
- const forCache = {};
1345
- const opt = { ...requestOptions, cache: false };
1485
+ ResourcesControl.prototype.getOne = function (resource, requestOptions) {
1486
+ var _this = this;
1487
+ var cache = new Cache();
1488
+ var forCache = {};
1489
+ var opt = __assign(__assign({}, requestOptions), { cache: false });
1346
1490
  if (typeof resource === 'string') {
1347
1491
  forCache.keyname = resource;
1348
1492
  }
@@ -1350,30 +1494,35 @@ class ResourcesControl {
1350
1494
  forCache.id = resource;
1351
1495
  }
1352
1496
  else if (isObject(resource)) {
1353
- forCache.id = resource.id;
1497
+ if (resource.id !== undefined) {
1498
+ forCache.id = resource.id;
1499
+ }
1500
+ else if (resource.keyname) {
1501
+ forCache.keyname = resource.keyname;
1502
+ }
1354
1503
  }
1355
- const makeRequest = () => {
1504
+ var makeRequest = function () {
1356
1505
  if (typeof resource === 'string') {
1357
- return this._fetchResourceBy({ keyname: resource }, opt);
1506
+ return _this._fetchResourceBy({ keyname: resource }, opt);
1358
1507
  }
1359
1508
  else if (typeof resource === 'number') {
1360
- return this._fetchResourceById(resource, opt);
1509
+ return _this._fetchResourceById(resource, opt);
1361
1510
  }
1362
1511
  else if (isObject(resource)) {
1363
- return this._fetchResourceBy(resource, opt);
1512
+ return _this._fetchResourceBy(resource, opt);
1364
1513
  }
1365
1514
  return CancelablePromise.resolve(undefined);
1366
1515
  };
1367
1516
  return cache.addFull('resource', makeRequest, forCache);
1368
- }
1369
- getOneOrFail(resource, requestOptions) {
1370
- return this.getOne(resource, requestOptions).then((res) => {
1517
+ };
1518
+ ResourcesControl.prototype.getOneOrFail = function (resource, requestOptions) {
1519
+ return this.getOne(resource, requestOptions).then(function (res) {
1371
1520
  if (res) {
1372
1521
  return res;
1373
1522
  }
1374
1523
  throw new ResourceNotFoundError();
1375
1524
  });
1376
- }
1525
+ };
1377
1526
  /**
1378
1527
  * A fast way to retrieve resource ID for any resource definition.
1379
1528
  * @param resource - Any available resource definition
@@ -1384,19 +1533,19 @@ class ResourcesControl {
1384
1533
  * then this method will come in handy to facilitate the extraction of the identifier
1385
1534
  * if the resource is specified through a keyname or other parameters.
1386
1535
  */
1387
- getId(resource, requestOptions) {
1536
+ ResourcesControl.prototype.getId = function (resource, requestOptions) {
1388
1537
  if (typeof resource === 'number') {
1389
1538
  return CancelablePromise.resolve(resource);
1390
1539
  }
1391
1540
  else if (typeof resource === 'string' || isObject(resource)) {
1392
- return this.getOne(resource, requestOptions).then((res) => {
1541
+ return this.getOne(resource, requestOptions).then(function (res) {
1393
1542
  if (res) {
1394
1543
  return res.resource.id;
1395
1544
  }
1396
1545
  });
1397
1546
  }
1398
1547
  return CancelablePromise.resolve(undefined);
1399
- }
1548
+ };
1400
1549
  /**
1401
1550
  * A fast way to retrieve resource ID for any resource definition.
1402
1551
  * @param resource - Any available resource definition
@@ -1405,33 +1554,32 @@ class ResourcesControl {
1405
1554
  * Similar with {@link NgwConnector.getResourceId | getResourceId} but rise error if resource is not exist.
1406
1555
  * To not make one more checks if the resource is definitely exists
1407
1556
  */
1408
- getIdOrFail(resource, requestOptions) {
1409
- return this.getId(resource, requestOptions).then((resp) => {
1557
+ ResourcesControl.prototype.getIdOrFail = function (resource, requestOptions) {
1558
+ return this.getId(resource, requestOptions).then(function (resp) {
1410
1559
  if (resp === undefined) {
1411
1560
  throw new Error();
1412
1561
  }
1413
1562
  return resp;
1414
1563
  });
1415
- }
1416
- getMany(resource, requestOptions) {
1417
- return this._resourceCacheFilter(resource).then((items) => {
1564
+ };
1565
+ ResourcesControl.prototype.getMany = function (resource, requestOptions) {
1566
+ var _this = this;
1567
+ return this._resourceCacheFilter(resource).then(function (items) {
1418
1568
  if (!items.length) {
1419
- const query = {};
1569
+ var query = {};
1420
1570
  if (resource.keyname) {
1421
1571
  query.keyname = resource.keyname;
1422
1572
  }
1423
1573
  else {
1424
1574
  Object.assign(query, resourceToQuery(resource));
1425
1575
  }
1426
- return this.connector
1427
- .get('resource.search', requestOptions, {
1428
- serialization: 'full',
1429
- ...query,
1430
- })
1431
- .then((resources) => {
1576
+ return _this.connector
1577
+ .get('resource.search', requestOptions, __assign({ serialization: 'full' }, query))
1578
+ .then(function (resources) {
1432
1579
  if (resources) {
1433
- for (const x of resources) {
1434
- this.cache.add('resource.item', CancelablePromise.resolve(x), {
1580
+ for (var _i = 0, resources_1 = resources; _i < resources_1.length; _i++) {
1581
+ var x = resources_1[_i];
1582
+ _this.cache.add('resource.item', CancelablePromise.resolve(x), {
1435
1583
  id: x.resource.id,
1436
1584
  });
1437
1585
  }
@@ -1441,97 +1589,137 @@ class ResourcesControl {
1441
1589
  }
1442
1590
  return items;
1443
1591
  });
1444
- }
1445
- getParent(resource, requestOptions) {
1446
- return this.getOne(resource, requestOptions).then((child) => {
1592
+ };
1593
+ ResourcesControl.prototype.getParent = function (resource, requestOptions) {
1594
+ var _this = this;
1595
+ return this.getOne(resource, requestOptions).then(function (child) {
1447
1596
  if (child) {
1448
- return this.getOne(child.resource.parent.id, requestOptions);
1597
+ return _this.getOne(child.resource.parent.id, requestOptions);
1449
1598
  }
1450
1599
  return CancelablePromise.resolve(undefined);
1451
1600
  });
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
- });
1601
+ };
1602
+ ResourcesControl.prototype.getChildrenOf = function (resource, requestOptions) {
1603
+ var _this = this;
1604
+ return this.getIdOrFail(resource).then(function (parent) {
1605
+ return _this._getChildrenOf(parent, requestOptions);
1606
+ });
1607
+ };
1608
+ ResourcesControl.prototype._getChildrenOf = function (parent, requestOptions, _items) {
1609
+ var _this = this;
1610
+ if (_items === void 0) { _items = []; }
1611
+ return this.connector
1612
+ .get('resource.collection', __assign({ cache: true }, requestOptions), {
1613
+ parent: parent,
1614
+ })
1615
+ .then(function (items) {
1616
+ var recursivePromises = [];
1617
+ for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
1618
+ var item = items_1[_i];
1619
+ _this.cache.add('resource.item', CancelablePromise.resolve(item), {
1620
+ id: item.resource.id,
1621
+ });
1622
+ _items.push(item);
1623
+ if ((requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.recursive) && item.resource.children) {
1624
+ recursivePromises.push(_this._getChildrenOf(item.resource.id, requestOptions, _items));
1464
1625
  }
1465
- return items;
1466
- });
1626
+ }
1627
+ if (recursivePromises.length) {
1628
+ return CancelablePromise.all(recursivePromises).then(function () {
1629
+ return _items;
1630
+ });
1631
+ }
1632
+ return _items;
1467
1633
  });
1468
- }
1469
- update(resource, data) {
1470
- return this.getId(resource).then((id) => {
1634
+ };
1635
+ ResourcesControl.prototype.update = function (resource, data) {
1636
+ var _this = this;
1637
+ return this.getId(resource).then(function (id) {
1471
1638
  if (id !== undefined) {
1472
- return this.connector.put('resource.item', { data }, { id });
1639
+ return _this.connector.put('resource.item', { data: data }, { id: id });
1473
1640
  }
1474
1641
  });
1475
- }
1642
+ };
1476
1643
  /**
1477
1644
  * Fast way to delete resource from NGW and clean cache.
1478
1645
  * @param resource - Resource definition
1479
1646
  */
1480
- delete(resource) {
1481
- return this.getId(resource).then((id) => {
1647
+ ResourcesControl.prototype.delete = function (resource) {
1648
+ var _this = this;
1649
+ return this.getId(resource).then(function (id) {
1482
1650
  if (id !== undefined) {
1483
- return this.connector.delete('resource.item', null, { id }).then(() => {
1484
- this._cleanResourceItemCache(id);
1651
+ return _this.connector.delete('resource.item', null, { id: id }).then(function () {
1652
+ _this._cleanResourceItemCache(id);
1485
1653
  return undefined;
1486
1654
  });
1487
1655
  }
1488
1656
  });
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
- }
1657
+ };
1658
+ ResourcesControl.prototype._cleanResourceItemCache = function (id) {
1659
+ return __awaiter(this, void 0, void 0, function () {
1660
+ var all, toDelete, _i, all_1, c, cid, rid, _a, toDelete_1, d;
1661
+ return __generator(this, function (_b) {
1662
+ switch (_b.label) {
1663
+ case 0:
1664
+ all = this.cache.all();
1665
+ toDelete = [];
1666
+ _i = 0, all_1 = all;
1667
+ _b.label = 1;
1668
+ case 1:
1669
+ if (!(_i < all_1.length)) return [3 /*break*/, 5];
1670
+ c = all_1[_i];
1671
+ cid = c.options && c.options.id;
1672
+ if (!(['resource.item', 'resource'].includes(c.key) && cid !== undefined)) return [3 /*break*/, 4];
1673
+ if (!(typeof cid === 'number')) return [3 /*break*/, 2];
1674
+ if (cid === id) {
1675
+ toDelete.push(c);
1676
+ }
1677
+ return [3 /*break*/, 4];
1678
+ case 2: return [4 /*yield*/, this.getId(cid)];
1679
+ case 3:
1680
+ rid = _b.sent();
1681
+ if (rid === id) {
1682
+ toDelete.push(c);
1683
+ }
1684
+ _b.label = 4;
1685
+ case 4:
1686
+ _i++;
1687
+ return [3 /*break*/, 1];
1688
+ case 5:
1689
+ for (_a = 0, toDelete_1 = toDelete; _a < toDelete_1.length; _a++) {
1690
+ d = toDelete_1[_a];
1691
+ this.cache.delete(d);
1692
+ }
1693
+ return [2 /*return*/];
1506
1694
  }
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 });
1695
+ });
1696
+ });
1697
+ };
1698
+ ResourcesControl.prototype._fetchResourceById = function (id, requestOptions) {
1699
+ var _this = this;
1700
+ var promise = function () {
1701
+ return _this.connector.get('resource.item', requestOptions, { id: id });
1702
+ };
1515
1703
  return this.cache
1516
1704
  .add('resource.item', promise, {
1517
- id,
1705
+ id: id,
1518
1706
  })
1519
- .catch((er) => {
1707
+ .catch(function (er) {
1520
1708
  if (!(er instanceof ResourceNotFoundError)) {
1521
1709
  throw er;
1522
1710
  }
1523
1711
  return undefined;
1524
1712
  });
1525
- }
1526
- _fetchResourceBy(resource, requestOptions) {
1527
- return this.getMany(resource, requestOptions).then((resources) => {
1713
+ };
1714
+ ResourcesControl.prototype._fetchResourceBy = function (resource, requestOptions) {
1715
+ return this.getMany(resource, requestOptions).then(function (resources) {
1528
1716
  return resources[0];
1529
1717
  });
1530
- }
1531
- _resourceCacheFilter(resource) {
1532
- return CancelablePromise.all(this.cache.matchAll('resource.item')).then((resources) => {
1533
- const items = [];
1534
- resources.filter((x) => {
1718
+ };
1719
+ ResourcesControl.prototype._resourceCacheFilter = function (resource) {
1720
+ return CancelablePromise.all(this.cache.matchAll('resource.item')).then(function (resources) {
1721
+ var items = [];
1722
+ resources.filter(function (x) {
1535
1723
  if (x) {
1536
1724
  // identical by uniq props
1537
1725
  if (resource.keyname && x.resource.keyname) {
@@ -1545,23 +1733,24 @@ class ResourcesControl {
1545
1733
  });
1546
1734
  return items;
1547
1735
  });
1548
- }
1549
- }
1736
+ };
1737
+ return ResourcesControl;
1738
+ }());
1550
1739
 
1551
1740
  function apiRequest(opt) {
1552
- const params = opt.params;
1553
- return new CancelablePromise((resolve, reject) => {
1741
+ var params = opt.params;
1742
+ return new CancelablePromise(function (resolve, reject) {
1554
1743
  opt.connector
1555
1744
  .connect()
1556
- .then((apiItems) => {
1557
- let apiItem = apiItems && apiItems[opt.name];
1745
+ .then(function (apiItems) {
1746
+ var apiItem = apiItems && apiItems[opt.name];
1558
1747
  if (apiItem) {
1559
- apiItem = [...apiItem];
1560
- let url = apiItem.shift();
1748
+ apiItem = __spreadArray([], apiItem, true);
1749
+ var url = apiItem.shift();
1561
1750
  if (apiItem.length) {
1562
- const replaceParams = {};
1563
- for (let fry = 0; fry < apiItem.length; fry++) {
1564
- const arg = apiItem[fry];
1751
+ var replaceParams = {};
1752
+ for (var fry = 0; fry < apiItem.length; fry++) {
1753
+ var arg = apiItem[fry];
1565
1754
  replaceParams[fry] = '{' + arg + '}';
1566
1755
  if (params[arg] === undefined) {
1567
1756
  throw new Error('`' + arg + '`' + ' url api argument is not specified');
@@ -1573,21 +1762,21 @@ function apiRequest(opt) {
1573
1762
  }
1574
1763
  // Transfer part of the parameters from `params` to the URL string
1575
1764
  if (params) {
1576
- const paramArray = [];
1577
- const paramList = params.paramList;
1765
+ var paramArray_1 = [];
1766
+ var paramList = params.paramList;
1578
1767
  if (Array.isArray(paramList)) {
1579
1768
  delete params.paramList;
1580
- paramList.forEach((x) => {
1581
- paramArray.push(`${x[0]}=${x[1]}`);
1769
+ paramList.forEach(function (x) {
1770
+ paramArray_1.push("".concat(x[0], "=").concat(x[1]));
1582
1771
  });
1583
1772
  }
1584
- for (const p in params) {
1773
+ for (var p in params) {
1585
1774
  if (apiItem.indexOf(p) === -1) {
1586
- paramArray.push(`${p}=${params[p]}`);
1775
+ paramArray_1.push("".concat(p, "=").concat(params[p]));
1587
1776
  }
1588
1777
  }
1589
- if (paramArray.length) {
1590
- url = url + '?' + paramArray.join('&');
1778
+ if (paramArray_1.length) {
1779
+ url = url + '?' + paramArray_1.join('&');
1591
1780
  }
1592
1781
  }
1593
1782
  if (url) {
@@ -1601,20 +1790,20 @@ function apiRequest(opt) {
1601
1790
  resolve(undefined);
1602
1791
  }
1603
1792
  })
1604
- .catch((er) => {
1793
+ .catch(function (er) {
1605
1794
  reject(er);
1606
1795
  });
1607
1796
  });
1608
1797
  }
1609
1798
 
1610
- let ID = 0;
1611
- class NgwConnector$1 {
1612
- constructor(options) {
1799
+ var ID = 0;
1800
+ var NgwConnector$1 = /** @class */ (function () {
1801
+ function NgwConnector(options) {
1613
1802
  this.options = options;
1614
1803
  this.id = ID++;
1615
1804
  this.emitter = new events.exports.EventEmitter();
1616
1805
  this.routeStr = '/api/component/pyramid/route';
1617
- const exist = findConnector(options);
1806
+ var exist = findConnector(options);
1618
1807
  if (exist) {
1619
1808
  return exist;
1620
1809
  }
@@ -1626,19 +1815,19 @@ class NgwConnector$1 {
1626
1815
  addConnector(this);
1627
1816
  }
1628
1817
  }
1629
- static create(options) {
1818
+ NgwConnector.create = function (options) {
1630
1819
  return new this(options);
1631
- }
1820
+ };
1632
1821
  /**
1633
1822
  * Fast way to specify the connection address to NextGIS Web.
1634
1823
  * The current connection will be severed.
1635
1824
  * @param baseUrl - NGW url
1636
1825
  */
1637
- setNgw(baseUrl) {
1826
+ NgwConnector.prototype.setNgw = function (baseUrl) {
1638
1827
  this.logout();
1639
1828
  this.options.baseUrl = baseUrl;
1640
1829
  addConnector(this);
1641
- }
1830
+ };
1642
1831
  /**
1643
1832
  * Establishing a connection with NextGIS Web to fulfill all other requests.
1644
1833
  * @remarks
@@ -1652,101 +1841,105 @@ class NgwConnector$1 {
1652
1841
  * .catch((er) => console.log('Connection problem', er));
1653
1842
  * ```
1654
1843
  */
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();
1844
+ NgwConnector.prototype.connect = function () {
1845
+ var _this = this;
1846
+ var cache = new Cache();
1847
+ var auth = this.options.auth;
1848
+ var makeConnect = function () {
1849
+ return new CancelablePromise(function (resolve, reject) {
1850
+ var makeQuery = function () {
1851
+ return _this.makeQuery(_this.routeStr, {}, {})
1852
+ .then(function (route) {
1853
+ resolve(route);
1674
1854
  })
1675
- .catch((er) => reject(er));
1855
+ .catch(function (er) {
1856
+ reject(er);
1857
+ });
1858
+ };
1859
+ if (auth) {
1860
+ var login = auth.login, password = auth.password;
1861
+ if (login && password) {
1862
+ return _this.getUserInfo({ login: login, password: password })
1863
+ .then(function () {
1864
+ makeQuery();
1865
+ })
1866
+ .catch(function (er) { return reject(er); });
1867
+ }
1676
1868
  }
1677
- }
1678
- return makeQuery();
1679
- });
1869
+ return makeQuery();
1870
+ });
1871
+ };
1680
1872
  return cache.add('route', makeConnect, {
1681
1873
  id: this.id,
1682
- auth,
1874
+ auth: auth,
1683
1875
  baseUrl: this.options.baseUrl,
1684
1876
  });
1685
- }
1877
+ };
1686
1878
  /**
1687
1879
  * Quick way to change NextGIS Web user.
1688
1880
  * @param credentials - New user credentials
1689
1881
  */
1690
- login(credentials) {
1882
+ NgwConnector.prototype.login = function (credentials) {
1691
1883
  this.logout();
1692
1884
  addConnector(this);
1693
1885
  return this.getUserInfo(credentials);
1694
- }
1886
+ };
1695
1887
  /**
1696
1888
  * Disconnecting a user. Aborting all current requests
1697
1889
  */
1698
- logout() {
1890
+ NgwConnector.prototype.logout = function () {
1699
1891
  removeConnector(this);
1700
1892
  this.options.auth = undefined;
1701
1893
  this.user = undefined;
1702
1894
  this.emitter.emit('logout');
1703
1895
  this.resources.cache.clean();
1704
- }
1705
- getUserInfo(credentials) {
1896
+ };
1897
+ NgwConnector.prototype.getUserInfo = function (credentials) {
1898
+ var _this = this;
1706
1899
  if (this.user && this.user.id) {
1707
1900
  return CancelablePromise.resolve(this.user);
1708
1901
  }
1709
1902
  if (credentials) {
1710
1903
  this.options.auth = credentials;
1711
1904
  }
1712
- const options = {
1905
+ var options = {
1713
1906
  headers: this.getAuthorizationHeaders(credentials),
1714
1907
  // withCredentials: true
1715
1908
  };
1716
1909
  // Do not use apiRequest('auth.current_user') to avoid circular-references
1717
1910
  return this.makeQuery('/api/component/auth/current_user', {}, options)
1718
- .then((data) => {
1719
- this.user = data;
1720
- this.emitter.emit('login', data);
1911
+ .then(function (data) {
1912
+ _this.user = data;
1913
+ _this.emitter.emit('login', data);
1721
1914
  return data;
1722
1915
  })
1723
- .catch((er) => {
1724
- this.emitter.emit('login:error', er);
1916
+ .catch(function (er) {
1917
+ _this.emitter.emit('login:error', er);
1725
1918
  throw er;
1726
1919
  });
1727
- }
1920
+ };
1728
1921
  /**
1729
1922
  * Obtaining the required Headers for authentication of requests in the NGW.
1730
1923
  */
1731
- getAuthorizationHeaders(credentials) {
1732
- const client = this.makeClientId(credentials);
1924
+ NgwConnector.prototype.getAuthorizationHeaders = function (credentials) {
1925
+ var client = this.makeClientId(credentials);
1733
1926
  if (client) {
1734
1927
  return {
1735
1928
  Authorization: 'Basic ' + client,
1736
1929
  };
1737
1930
  }
1738
- }
1739
- makeClientId(credentials) {
1931
+ };
1932
+ NgwConnector.prototype.makeClientId = function (credentials) {
1740
1933
  credentials = credentials || this.options.auth;
1741
1934
  if (credentials) {
1742
- const { login, password } = credentials;
1743
- const str = unescape(encodeURIComponent(`${login}:${password}`));
1935
+ var login = credentials.login, password = credentials.password;
1936
+ var str = unescape(encodeURIComponent("".concat(login, ":").concat(password)));
1744
1937
  // @ts-ignore
1745
1938
  {
1746
1939
  return window.btoa(str);
1747
1940
  }
1748
1941
  }
1749
- }
1942
+ };
1750
1943
  /**
1751
1944
  * Send request to NGW api router.
1752
1945
  * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
@@ -1776,25 +1969,27 @@ class NgwConnector$1 {
1776
1969
  *
1777
1970
  * ```
1778
1971
  */
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 });
1972
+ NgwConnector.prototype.apiRequest = function (name, params_, requestOptions) {
1973
+ var _this = this;
1974
+ if (params_ === void 0) { params_ = {}; }
1975
+ if (requestOptions === void 0) { requestOptions = {}; }
1976
+ var method = requestOptions.method, headers = requestOptions.headers, withCredentials = requestOptions.withCredentials, responseType = requestOptions.responseType;
1977
+ var params = objectRemoveEmpty(params_);
1978
+ var makeApiRequest = function () {
1979
+ return apiRequest({ name: name, params: params, requestOptions: requestOptions, connector: _this });
1980
+ };
1783
1981
  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
- });
1982
+ var cache = new Cache();
1983
+ return cache.add(name, makeApiRequest, __assign({ params: params }, objectRemoveEmpty({
1984
+ headers: headers,
1985
+ withCredentials: withCredentials,
1986
+ responseType: responseType,
1987
+ baseUrl: this.options.baseUrl,
1988
+ auth: this.options.auth,
1989
+ })));
1795
1990
  }
1796
1991
  return makeApiRequest();
1797
- }
1992
+ };
1798
1993
  /**
1799
1994
  * Shortcut method for send POST request to NGW.
1800
1995
  * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
@@ -1808,62 +2003,63 @@ class NgwConnector$1 {
1808
2003
  * .catch((error) => console.warn(error));
1809
2004
  * ```
1810
2005
  */
1811
- post(name, options, params) {
2006
+ NgwConnector.prototype.post = function (name, options, params) {
1812
2007
  options = options || {};
1813
2008
  options.method = 'POST';
1814
2009
  return this.apiRequest(name, params, options);
1815
- }
2010
+ };
1816
2011
  /**
1817
2012
  * Shortcut method for send GET request to NGW.
1818
2013
  * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
1819
2014
  * @param options - Request options
1820
2015
  * @param params - Request item params or query params
1821
2016
  */
1822
- get(name, options, params) {
2017
+ NgwConnector.prototype.get = function (name, options, params) {
1823
2018
  options = options || {};
1824
2019
  options.method = 'GET';
1825
2020
  return this.apiRequest(name, params, options);
1826
- }
2021
+ };
1827
2022
  /**
1828
2023
  * Shortcut method for send PATCH request to NGW.
1829
2024
  * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
1830
2025
  * @param options - Request options
1831
2026
  * @param params - Request item params or query params
1832
2027
  */
1833
- patch(name, options, params) {
2028
+ NgwConnector.prototype.patch = function (name, options, params) {
1834
2029
  options = options || {};
1835
2030
  options.method = 'PATCH';
1836
2031
  return this.apiRequest(name, params, options);
1837
- }
2032
+ };
1838
2033
  /**
1839
2034
  * Shortcut method for send PUT request to NGW.
1840
2035
  * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
1841
2036
  * @param options - Request options
1842
2037
  * @param params - Request item params or query params
1843
2038
  */
1844
- put(name, options, params) {
2039
+ NgwConnector.prototype.put = function (name, options, params) {
1845
2040
  options = options || {};
1846
2041
  options.method = 'PUT';
1847
2042
  return this.apiRequest(name, params, options);
1848
- }
2043
+ };
1849
2044
  /**
1850
2045
  * Shortcut method for send DELETE request to NGW.
1851
2046
  * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
1852
2047
  * @param options - Request options
1853
2048
  * @param params - Request item params or query params
1854
2049
  */
1855
- delete(name, options, params) {
2050
+ NgwConnector.prototype.delete = function (name, options, params) {
1856
2051
  options = options || {};
1857
2052
  options.method = 'DELETE';
1858
2053
  return this.apiRequest(name, params, options);
1859
- }
2054
+ };
1860
2055
  /**
1861
2056
  * Send request to NGW.
1862
2057
  * @param url - URL address to NGW
1863
2058
  * @param params - Query params
1864
2059
  * @param options - Request options
1865
2060
  */
1866
- makeQuery(url, params, options = {}) {
2061
+ NgwConnector.prototype.makeQuery = function (url, params, options) {
2062
+ if (options === void 0) { options = {}; }
1867
2063
  url = (this.options.baseUrl ? this.options.baseUrl : '') + url;
1868
2064
  if (url) {
1869
2065
  if (params) {
@@ -1876,112 +2072,110 @@ class NgwConnector$1 {
1876
2072
  else {
1877
2073
  throw new Error('Empty `url` not allowed');
1878
2074
  }
1879
- }
2075
+ };
1880
2076
  // -------------------------------------------------------------------------
1881
2077
  // Resource Methods
1882
2078
  // -------------------------------------------------------------------------
1883
2079
  /**
1884
2080
  * {@inheritDoc ResourcesControl.getOne}
1885
2081
  */
1886
- getResource(resource, requestOptions) {
2082
+ NgwConnector.prototype.getResource = function (resource, requestOptions) {
1887
2083
  return this.resources.getOne(resource, requestOptions);
1888
- }
2084
+ };
1889
2085
  /**
1890
2086
  * {@inheritDoc ResourcesControl.getOneOrFail}
1891
2087
  */
1892
- getResourceOrFail(resource, requestOptions) {
2088
+ NgwConnector.prototype.getResourceOrFail = function (resource, requestOptions) {
1893
2089
  return this.resources.getOneOrFail(resource, requestOptions);
1894
- }
2090
+ };
1895
2091
  /**
1896
2092
  * @deprecated - use {@link NgwConnector.getResource}
1897
2093
  */
1898
- getResourceBy(resource) {
2094
+ NgwConnector.prototype.getResourceBy = function (resource) {
1899
2095
  return this.resources.getOne(resource);
1900
- }
2096
+ };
1901
2097
  /**
1902
2098
  * @deprecated - use {@link NgwConnector.getResource}
1903
2099
  */
1904
- getResourceByKeyname(keyname) {
2100
+ NgwConnector.prototype.getResourceByKeyname = function (keyname) {
1905
2101
  return this.resources.getOne(keyname);
1906
- }
2102
+ };
1907
2103
  /**
1908
2104
  * @deprecated - use {@link NgwConnector.getResource}
1909
2105
  */
1910
- getResourceById(id) {
2106
+ NgwConnector.prototype.getResourceById = function (id) {
1911
2107
  return this.resources.getOne(id);
1912
- }
2108
+ };
1913
2109
  /**
1914
2110
  * {@inheritDoc ResourcesControl.getId}
1915
2111
  */
1916
- getResourceId(resource, requestOptions) {
2112
+ NgwConnector.prototype.getResourceId = function (resource, requestOptions) {
1917
2113
  return this.resources.getId(resource, requestOptions);
1918
- }
2114
+ };
1919
2115
  /**
1920
2116
  * {@inheritDoc ResourcesControl.getIdOrFail}
1921
2117
  */
1922
- getResourceIdOrFail(resource, requestOptions) {
2118
+ NgwConnector.prototype.getResourceIdOrFail = function (resource, requestOptions) {
1923
2119
  return this.resources.getIdOrFail(resource, requestOptions);
1924
- }
2120
+ };
1925
2121
  /**
1926
2122
  * {@inheritDoc ResourcesControl.getMany}
1927
2123
  */
1928
- getResourcesBy(resource, requestOptions) {
2124
+ NgwConnector.prototype.getResourcesBy = function (resource, requestOptions) {
1929
2125
  return this.resources.getMany(resource, requestOptions);
1930
- }
2126
+ };
1931
2127
  /**
1932
2128
  * {@inheritDoc ResourcesControl.getParent}
1933
2129
  */
1934
- getResourceParent(resource, requestOptions) {
2130
+ NgwConnector.prototype.getResourceParent = function (resource, requestOptions) {
1935
2131
  return this.resources.getParent(resource, requestOptions);
1936
- }
2132
+ };
1937
2133
  /**
1938
2134
  * {@inheritDoc ResourcesControl.getChildrenOf}
1939
2135
  */
1940
- getResourceChildren(resource, requestOptions) {
2136
+ NgwConnector.prototype.getResourceChildren = function (resource, requestOptions) {
1941
2137
  return this.resources.getChildrenOf(resource, requestOptions);
1942
- }
2138
+ };
1943
2139
  /**
1944
2140
  * {@inheritDoc ResourcesControl.update}
1945
2141
  */
1946
- updateResource(resource, data) {
2142
+ NgwConnector.prototype.updateResource = function (resource, data) {
1947
2143
  return this.resources.update(resource, data);
1948
- }
2144
+ };
1949
2145
  /**
1950
2146
  * {@inheritDoc ResourcesControl.delete}
1951
2147
  */
1952
- deleteResource(resource) {
2148
+ NgwConnector.prototype.deleteResource = function (resource) {
1953
2149
  return this.resources.delete(resource);
1954
- }
2150
+ };
1955
2151
  /**
1956
2152
  * @internal
1957
2153
  */
1958
- _loadData(url, options) {
2154
+ NgwConnector.prototype._loadData = function (url, options) {
2155
+ var _this = this;
1959
2156
  options.responseType = options.responseType || 'json';
1960
- return new CancelablePromise((resolve, reject, onCancel) => {
1961
- if (this.user) {
2157
+ return new CancelablePromise(function (resolve, reject, onCancel) {
2158
+ if (_this.user) {
1962
2159
  options = options || {};
1963
2160
  // options.withCredentials = true;
1964
- options.headers = {
1965
- ...this.getAuthorizationHeaders(),
1966
- ...options.headers,
1967
- };
2161
+ options.headers = __assign(__assign({}, _this.getAuthorizationHeaders()), options.headers);
1968
2162
  }
1969
2163
  loadData(url, resolve, options, reject, onCancel);
1970
- }).catch((httpError) => {
2164
+ }).catch(function (httpError) {
1971
2165
  if (httpError instanceof CancelablePromise.CancelError) ;
1972
2166
  else {
1973
2167
  // @ts-ignore
1974
2168
  {
1975
2169
  console.warn('DEV WARN', httpError);
1976
2170
  }
1977
- const er = this._handleHttpError(httpError);
2171
+ var er = _this._handleHttpError(httpError);
1978
2172
  if (er) {
1979
2173
  throw er;
1980
2174
  }
1981
2175
  }
1982
2176
  });
1983
- }
1984
- _handleHttpError(er) {
2177
+ };
2178
+ NgwConnector.prototype._handleHttpError = function (er) {
1985
2179
  if (er) {
1986
2180
  if (er instanceof NgwError) {
1987
2181
  if (er.exception === 'nextgisweb.resource.exception.ResourceNotFound') {
@@ -1993,12 +2187,13 @@ class NgwConnector$1 {
1993
2187
  }
1994
2188
  }
1995
2189
  return er;
1996
- }
1997
- }
1998
- NgwConnector$1.errors = {
1999
- NgwError,
2000
- ResourceNotFoundError,
2001
- };
2190
+ };
2191
+ NgwConnector.errors = {
2192
+ NgwError: NgwError,
2193
+ ResourceNotFoundError: ResourceNotFoundError,
2194
+ };
2195
+ return NgwConnector;
2196
+ }());
2002
2197
 
2003
2198
  /**
2004
2199
  * A lightweight HTTP client optimized for use with {@link http://docs.nextgis.ru/docs_ngweb_dev/doc/developer/toc.html | NextGIS Web} API