@nextgis/ngw-connector 3.0.0-alpha.12 → 3.0.0-alpha.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/ngw-connector; version: 3.0.0-alpha.8; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-connector; version: 3.0.0-alpha.13; author: NextGIS */
2
2
  function defined(val) {
3
3
  return val !== void 0 && val !== null;
4
4
  }
@@ -60,6 +60,245 @@ function fixUrlStr(url) {
60
60
  return url.replace(/([^:]\/)\/+/g, "$1");
61
61
  }
62
62
 
63
+ const templateRe = /\{ *([\w_-]+) *\}/g;
64
+ function template(str, data) {
65
+ return str.replace(templateRe, (s, key) => {
66
+ let value = data[key];
67
+ if (value === void 0) {
68
+ throw new Error("No value provided for letiable " + s);
69
+ } else if (typeof value === "function") {
70
+ value = value(data);
71
+ }
72
+ return value;
73
+ });
74
+ }
75
+
76
+ var __defProp$c = Object.defineProperty;
77
+ var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
78
+ var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
79
+ var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
80
+ var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
81
+ var __spreadValues$4 = (a, b) => {
82
+ for (var prop in b || (b = {}))
83
+ if (__hasOwnProp$4.call(b, prop))
84
+ __defNormalProp$c(a, prop, b[prop]);
85
+ if (__getOwnPropSymbols$4)
86
+ for (var prop of __getOwnPropSymbols$4(b)) {
87
+ if (__propIsEnum$4.call(b, prop))
88
+ __defNormalProp$c(a, prop, b[prop]);
89
+ }
90
+ return a;
91
+ };
92
+ var __async$4 = (__this, __arguments, generator) => {
93
+ return new Promise((resolve, reject) => {
94
+ var fulfilled = (value) => {
95
+ try {
96
+ step(generator.next(value));
97
+ } catch (e) {
98
+ reject(e);
99
+ }
100
+ };
101
+ var rejected = (value) => {
102
+ try {
103
+ step(generator.throw(value));
104
+ } catch (e) {
105
+ reject(e);
106
+ }
107
+ };
108
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
109
+ step((generator = generator.apply(__this, __arguments)).next());
110
+ });
111
+ };
112
+ function apiRequest(opt) {
113
+ return __async$4(this, null, function* () {
114
+ const { params, name, connector, requestOptions } = opt;
115
+ const apiItems = yield connector.connect();
116
+ let apiItem = apiItems && apiItems[name];
117
+ if (apiItem) {
118
+ apiItem = [...apiItem];
119
+ let url = apiItem.shift();
120
+ if (apiItem.length) {
121
+ const replaceParams = {};
122
+ for (let fry = 0; fry < apiItem.length; fry++) {
123
+ const arg = apiItem[fry];
124
+ replaceParams[fry] = `{${arg}}`;
125
+ if (params[arg] === void 0) {
126
+ throw new Error(`\`${arg}\` URL API argument is not specified`);
127
+ }
128
+ }
129
+ if (url) {
130
+ url = template(url, replaceParams);
131
+ }
132
+ }
133
+ if (params) {
134
+ const paramArray = [];
135
+ const paramList = params.paramList;
136
+ if (Array.isArray(paramList)) {
137
+ paramList.forEach(([key, value]) => {
138
+ paramArray.push(`${key}=${value}`);
139
+ });
140
+ }
141
+ for (const p in params) {
142
+ if (apiItem.indexOf(p) === -1) {
143
+ paramArray.push(`${p}=${params[p]}`);
144
+ }
145
+ }
146
+ if (paramArray.length) {
147
+ url = `${url}?${paramArray.join("&")}`;
148
+ }
149
+ }
150
+ if (url) {
151
+ return connector.makeQuery(url, params, __spreadValues$4({
152
+ cacheName: name
153
+ }, requestOptions));
154
+ } else {
155
+ throw new Error("Request URL is not set");
156
+ }
157
+ } else {
158
+ return void 0;
159
+ }
160
+ });
161
+ }
162
+
163
+ var __defProp$b = Object.defineProperty;
164
+ var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
165
+ var __publicField$9 = (obj, key, value) => __defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
166
+ const _Cache = class _Cache {
167
+ constructor(options = {}) {
168
+ __publicField$9(this, "cache", []);
169
+ var _a;
170
+ const namespace = (_a = options.namespace) != null ? _a : "default";
171
+ if (_Cache.instance[namespace]) {
172
+ return _Cache.instance[namespace];
173
+ }
174
+ _Cache.instance[namespace] = this;
175
+ return this;
176
+ }
177
+ clean() {
178
+ this.cache.length = 0;
179
+ }
180
+ all() {
181
+ return this.cache;
182
+ }
183
+ /**
184
+ * Caching only a non-empty value.
185
+ *
186
+ * Useful for get or create strategy
187
+ * @example
188
+ * ```javascript
189
+ * const cache = new Cache();
190
+ * const getItemFunc = () => fetch(url).then((data) => {
191
+ * return data.json(); // undefined
192
+ * });
193
+ * const item = await cache.addFull('foo', getItemFunc);
194
+ * if (!item) {
195
+ * await createItem(); // 'New item'
196
+ * }
197
+ *
198
+ * // somewhere else in the code
199
+ * const item = await cache.addFull('foo', getItemFunc).then((resp) => {
200
+ * console.log(resp); // 'New item'
201
+ * });
202
+ * ```
203
+ */
204
+ addFull(key, valueToSet, propsOrOptions, expirationTime) {
205
+ if (typeof propsOrOptions === "object" && "valueToSet" in propsOrOptions) {
206
+ propsOrOptions.onlyFull = true;
207
+ }
208
+ return this.add(key, valueToSet, propsOrOptions, true, expirationTime);
209
+ }
210
+ add(key, valueToSet, propsOrOptions, onlyFull, expirationTime) {
211
+ let opt;
212
+ let props;
213
+ if (typeof propsOrOptions === "object" && "valueToSet" in propsOrOptions) {
214
+ opt = propsOrOptions;
215
+ onlyFull = opt.onlyFull;
216
+ expirationTime = opt.expirationTime;
217
+ props = opt.props;
218
+ } else {
219
+ props = propsOrOptions;
220
+ }
221
+ const exist = this._find(key, props);
222
+ if (!exist) {
223
+ let value;
224
+ if (valueToSet instanceof Function) {
225
+ value = valueToSet();
226
+ } else {
227
+ value = valueToSet;
228
+ }
229
+ const nonEmptyProps = props && JSON.parse(JSON.stringify(objectRemoveEmpty(props)));
230
+ expirationTime = expirationTime ? Date.now() + expirationTime : void 0;
231
+ const cacheItem = {
232
+ key,
233
+ value,
234
+ props: nonEmptyProps,
235
+ expirationTime
236
+ };
237
+ if (onlyFull && !full(value)) {
238
+ return value;
239
+ }
240
+ this.cache.push(cacheItem);
241
+ if (value instanceof Promise) {
242
+ value.catch(() => {
243
+ this.delete(key, props);
244
+ });
245
+ if (onlyFull) {
246
+ value.then((x) => {
247
+ if (!full(x)) {
248
+ this.delete(key, props);
249
+ }
250
+ return x;
251
+ });
252
+ }
253
+ return value;
254
+ }
255
+ return value;
256
+ } else {
257
+ return exist.value;
258
+ }
259
+ }
260
+ match(key, props) {
261
+ const cacheRecord = this._find(key, props);
262
+ if (cacheRecord && cacheRecord.expirationTime && Date.now() > cacheRecord.expirationTime) {
263
+ this.delete(cacheRecord);
264
+ return void 0;
265
+ }
266
+ return cacheRecord == null ? void 0 : cacheRecord.value;
267
+ }
268
+ matchAll(key, props) {
269
+ const now = Date.now();
270
+ this.cache.forEach((item) => {
271
+ if (item.expirationTime && now > item.expirationTime) {
272
+ this.delete(item);
273
+ }
274
+ });
275
+ if (key) {
276
+ return this.cache.filter((x) => this._filter(x, key, props)).map((x) => x.value);
277
+ }
278
+ return this.cache.map((x) => x.value);
279
+ }
280
+ delete(keyOrItem, props) {
281
+ const itemsToDelete = typeof keyOrItem === "string" ? this.cache.filter((x) => this._filter(x, keyOrItem, props)) : [keyOrItem];
282
+ for (const item of itemsToDelete) {
283
+ const index = this.cache.indexOf(item);
284
+ if (index !== -1) {
285
+ this.cache.splice(index, 1);
286
+ }
287
+ }
288
+ }
289
+ _find(key, props) {
290
+ return this.cache.find((x) => this._filter(x, key, props));
291
+ }
292
+ _filter(item, key, props) {
293
+ if (item.key !== key) return false;
294
+ if (!props) return true;
295
+ const itemProps = item.props;
296
+ return objectDeepEqual(itemProps || {}, objectRemoveEmpty(props));
297
+ }
298
+ };
299
+ __publicField$9(_Cache, "instance", {});
300
+ let Cache = _Cache;
301
+
63
302
  var domain;
64
303
 
65
304
  // This constructor is used to store event handlers. Instantiating this is
@@ -532,148 +771,9 @@ function unwrapListeners(arr) {
532
771
  return ret;
533
772
  }
534
773
 
535
- var __defProp$c = Object.defineProperty;
536
- var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
537
- var __publicField$9 = (obj, key, value) => __defNormalProp$c(obj, typeof key !== "symbol" ? key + "" : key, value);
538
- const _Cache = class _Cache {
539
- constructor(options = {}) {
540
- __publicField$9(this, "cache", []);
541
- var _a;
542
- const namespace = (_a = options.namespace) != null ? _a : "default";
543
- if (_Cache.instance[namespace]) {
544
- return _Cache.instance[namespace];
545
- }
546
- _Cache.instance[namespace] = this;
547
- return this;
548
- }
549
- clean() {
550
- this.cache.length = 0;
551
- }
552
- all() {
553
- return this.cache;
554
- }
555
- /**
556
- * Caching only a non-empty value.
557
- *
558
- * Useful for get or create strategy
559
- * @example
560
- * ```javascript
561
- * const cache = new Cache();
562
- * const getItemFunc = () => fetch(url).then((data) => {
563
- * return data.json(); // undefined
564
- * });
565
- * const item = await cache.addFull('foo', getItemFunc);
566
- * if (!item) {
567
- * await createItem(); // 'New item'
568
- * }
569
- *
570
- * // somewhere else in the code
571
- * const item = await cache.addFull('foo', getItemFunc).then((resp) => {
572
- * console.log(resp); // 'New item'
573
- * });
574
- * ```
575
- */
576
- addFull(key, valueToSet, propsOrOptions, expirationTime) {
577
- if (typeof propsOrOptions === "object" && "valueToSet" in propsOrOptions) {
578
- propsOrOptions.onlyFull = true;
579
- }
580
- return this.add(key, valueToSet, propsOrOptions, true, expirationTime);
581
- }
582
- add(key, valueToSet, propsOrOptions, onlyFull, expirationTime) {
583
- let opt;
584
- let props;
585
- if (typeof propsOrOptions === "object" && "valueToSet" in propsOrOptions) {
586
- opt = propsOrOptions;
587
- onlyFull = opt.onlyFull;
588
- expirationTime = opt.expirationTime;
589
- props = opt.props;
590
- } else {
591
- props = propsOrOptions;
592
- }
593
- const exist = this._find(key, props);
594
- if (!exist) {
595
- let value;
596
- if (valueToSet instanceof Function) {
597
- value = valueToSet();
598
- } else {
599
- value = valueToSet;
600
- }
601
- const nonEmptyProps = props && JSON.parse(JSON.stringify(objectRemoveEmpty(props)));
602
- expirationTime = expirationTime ? Date.now() + expirationTime : void 0;
603
- const cacheItem = {
604
- key,
605
- value,
606
- props: nonEmptyProps,
607
- expirationTime
608
- };
609
- if (onlyFull && !full(value)) {
610
- return value;
611
- }
612
- this.cache.push(cacheItem);
613
- if (value instanceof Promise) {
614
- value.catch((er) => {
615
- this.delete(key, props);
616
- });
617
- if (onlyFull) {
618
- value.then((x) => {
619
- if (!full(x)) {
620
- this.delete(key, props);
621
- }
622
- return x;
623
- });
624
- }
625
- return value;
626
- }
627
- return value;
628
- } else {
629
- return exist.value;
630
- }
631
- }
632
- match(key, props) {
633
- const cacheRecord = this._find(key, props);
634
- if (cacheRecord && cacheRecord.expirationTime && Date.now() > cacheRecord.expirationTime) {
635
- this.delete(cacheRecord);
636
- return void 0;
637
- }
638
- return cacheRecord == null ? void 0 : cacheRecord.value;
639
- }
640
- matchAll(key, props) {
641
- const now = Date.now();
642
- this.cache.forEach((item) => {
643
- if (item.expirationTime && now > item.expirationTime) {
644
- this.delete(item);
645
- }
646
- });
647
- if (key) {
648
- return this.cache.filter((x) => this._filter(x, key, props)).map((x) => x.value);
649
- }
650
- return this.cache.map((x) => x.value);
651
- }
652
- delete(keyOrItem, props) {
653
- const itemsToDelete = typeof keyOrItem === "string" ? this.cache.filter((x) => this._filter(x, keyOrItem, props)) : [keyOrItem];
654
- for (const item of itemsToDelete) {
655
- const index = this.cache.indexOf(item);
656
- if (index !== -1) {
657
- this.cache.splice(index, 1);
658
- }
659
- }
660
- }
661
- _find(key, props) {
662
- return this.cache.find((x) => this._filter(x, key, props));
663
- }
664
- _filter(item, key, props) {
665
- if (item.key !== key) return false;
666
- if (!props) return true;
667
- const itemProps = item.props;
668
- return objectDeepEqual(itemProps || {}, objectRemoveEmpty(props));
669
- }
670
- };
671
- __publicField$9(_Cache, "instance", {});
672
- let Cache = _Cache;
673
-
674
774
  var pkg = {
675
775
  name: "@nextgis/ngw-connector",
676
- version: "3.0.0-alpha.8",
776
+ version: "3.0.0-alpha.13",
677
777
  _priority: 12,
678
778
  description: "A lightweight HTTP client optimized for use with NextGIS Web API",
679
779
  main: "index.js",
@@ -682,15 +782,15 @@ var pkg = {
682
782
  jsdelivr: "lib/ngw-connector.global.prod.js",
683
783
  types: "lib/index.d.ts",
684
784
  dependencies: {
685
- "@nextgis/cache": "^3.0.0-alpha.7",
686
- "@nextgis/cancelable-promise": "^3.0.0-alpha.5",
687
- "@nextgis/utils": "^3.0.0-alpha.5",
785
+ "@nextgis/cache": "^3.0.0-alpha.13",
786
+ "@nextgis/cancelable-promise": "^3.0.0-alpha.13",
787
+ "@nextgis/utils": "^3.0.0-alpha.13",
688
788
  "@types/events": "^3.0.0",
689
789
  events: "*",
690
790
  "form-data": "^4.0.0"
691
791
  },
692
792
  devDependencies: {
693
- "@nextgis/build-tools": "^3.0.0-alpha.5"
793
+ "@nextgis/build-tools": "^3.0.0-alpha.13"
694
794
  },
695
795
  scripts: {
696
796
  clean: "rimraf ./lib",
@@ -730,30 +830,6 @@ var pkg = {
730
830
  gitHead: "edc68033f914f6c95c4125b9738bba6d36e990b4"
731
831
  };
732
832
 
733
- const CONNECTORS = [];
734
- function addConnector(connector) {
735
- CONNECTORS.push(connector);
736
- }
737
- function findConnector(options) {
738
- return CONNECTORS.find((x) => {
739
- if (x.options.baseUrl === options.baseUrl) {
740
- if (options.auth) {
741
- if (x.options.auth) {
742
- return objectDeepEqual(x.options.auth, options.auth);
743
- }
744
- } else {
745
- return true;
746
- }
747
- }
748
- });
749
- }
750
- function removeConnector(connector) {
751
- const index = CONNECTORS.indexOf(connector);
752
- if (index !== -1) {
753
- CONNECTORS.splice(index, 1);
754
- }
755
- }
756
-
757
833
  class AbortError extends Error {
758
834
  constructor(message = "AbortError") {
759
835
  super(message);
@@ -761,9 +837,9 @@ class AbortError extends Error {
761
837
  }
762
838
  }
763
839
 
764
- var __defProp$b = Object.defineProperty;
765
- var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
766
- var __publicField$8 = (obj, key, value) => __defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
840
+ var __defProp$a = Object.defineProperty;
841
+ var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
842
+ var __publicField$8 = (obj, key, value) => __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
767
843
  class NgwError extends Error {
768
844
  constructor(er) {
769
845
  super();
@@ -780,9 +856,9 @@ class NgwError extends Error {
780
856
  }
781
857
  }
782
858
 
783
- var __defProp$a = Object.defineProperty;
784
- var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
785
- var __publicField$7 = (obj, key, value) => __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
859
+ var __defProp$9 = Object.defineProperty;
860
+ var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
861
+ var __publicField$7 = (obj, key, value) => __defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
786
862
  class InsufficientPermissionsError extends NgwError {
787
863
  constructor(obj) {
788
864
  super(obj);
@@ -792,51 +868,19 @@ class InsufficientPermissionsError extends NgwError {
792
868
  }
793
869
  }
794
870
 
795
- var __defProp$9 = Object.defineProperty;
796
- var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
797
- var __publicField$6 = (obj, key, value) => __defNormalProp$9(obj, key + "" , value);
798
- class NetworkError extends Error {
799
- constructor(url) {
800
- super();
801
- __publicField$6(this, "name", "NetworkError");
802
- Object.setPrototypeOf(this, NetworkError.prototype);
803
- this.message = `Unable to request ${url}.
804
- Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`;
805
- }
806
- }
807
-
808
871
  var __defProp$8 = Object.defineProperty;
809
872
  var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
810
- var __publicField$5 = (obj, key, value) => __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
873
+ var __publicField$6 = (obj, key, value) => __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
811
874
  let NetworksResponseError$1 = class NetworksResponseError extends NgwError {
812
875
  constructor(obj) {
813
876
  super(obj);
814
- __publicField$5(this, "message", "There is no response from the server or problem connecting to server.");
815
- __publicField$5(this, "title", "Network error");
816
- __publicField$5(this, "detail", "Check network connectivity and try again later.");
877
+ __publicField$6(this, "message", "There is no response from the server or problem connecting to server.");
878
+ __publicField$6(this, "title", "Network error");
879
+ __publicField$6(this, "detail", "Check network connectivity and try again later.");
817
880
  Object.setPrototypeOf(this, NetworksResponseError.prototype);
818
881
  }
819
882
  };
820
883
 
821
- var __defProp$7 = Object.defineProperty;
822
- var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
823
- var __publicField$4 = (obj, key, value) => __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
824
- class ResourceNotFoundError extends NgwError {
825
- constructor(obj) {
826
- super(obj);
827
- __publicField$4(this, "name", "ResourceNotFoundError");
828
- __publicField$4(this, "exception", "nextgisweb.resource.exception.ResourceNotFound");
829
- Object.setPrototypeOf(this, ResourceNotFoundError.prototype);
830
- }
831
- }
832
-
833
- function isError(error) {
834
- if (isObject$1(error)) {
835
- return error.status_code && error.exception && error.title;
836
- }
837
- return false;
838
- }
839
-
840
884
  function extractError(error) {
841
885
  if (isObject$1(error)) {
842
886
  if (error.name && error.message && error.title) {
@@ -862,6 +906,38 @@ function extractError(error) {
862
906
  }
863
907
  }
864
908
 
909
+ function isError(error) {
910
+ if (isObject$1(error)) {
911
+ return error.status_code && error.exception && error.title;
912
+ }
913
+ return false;
914
+ }
915
+
916
+ var __defProp$7 = Object.defineProperty;
917
+ var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
918
+ var __publicField$5 = (obj, key, value) => __defNormalProp$7(obj, key + "" , value);
919
+ class NetworkError extends Error {
920
+ constructor(url) {
921
+ super();
922
+ __publicField$5(this, "name", "NetworkError");
923
+ Object.setPrototypeOf(this, NetworkError.prototype);
924
+ this.message = `Unable to request ${url}.
925
+ Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`;
926
+ }
927
+ }
928
+
929
+ var __defProp$6 = Object.defineProperty;
930
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
931
+ var __publicField$4 = (obj, key, value) => __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
932
+ class ResourceNotFoundError extends NgwError {
933
+ constructor(obj) {
934
+ super(obj);
935
+ __publicField$4(this, "name", "ResourceNotFoundError");
936
+ __publicField$4(this, "exception", "nextgisweb.resource.exception.ResourceNotFound");
937
+ Object.setPrototypeOf(this, ResourceNotFoundError.prototype);
938
+ }
939
+ }
940
+
865
941
  var errors = /*#__PURE__*/Object.freeze({
866
942
  __proto__: null,
867
943
  AbortError: AbortError,
@@ -874,9 +950,9 @@ var errors = /*#__PURE__*/Object.freeze({
874
950
  isError: isError
875
951
  });
876
952
 
877
- var __defProp$6 = Object.defineProperty;
878
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
879
- var __publicField$3 = (obj, key, value) => __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
953
+ var __defProp$5 = Object.defineProperty;
954
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
955
+ var __publicField$3 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
880
956
  class BaseAPIError extends Error {
881
957
  constructor(message) {
882
958
  super(message || "Something went wrong.");
@@ -938,35 +1014,35 @@ class LunkwillRequestFailed extends LunkwillError {
938
1014
  }
939
1015
  }
940
1016
 
941
- var __defProp$5 = Object.defineProperty;
942
- var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
943
- var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
944
- var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
945
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
946
- var __spreadValues$4 = (a, b) => {
1017
+ var __defProp$4 = Object.defineProperty;
1018
+ var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
1019
+ var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
1020
+ var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
1021
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1022
+ var __spreadValues$3 = (a, b) => {
947
1023
  for (var prop in b || (b = {}))
948
- if (__hasOwnProp$4.call(b, prop))
949
- __defNormalProp$5(a, prop, b[prop]);
950
- if (__getOwnPropSymbols$4)
951
- for (var prop of __getOwnPropSymbols$4(b)) {
952
- if (__propIsEnum$4.call(b, prop))
953
- __defNormalProp$5(a, prop, b[prop]);
1024
+ if (__hasOwnProp$3.call(b, prop))
1025
+ __defNormalProp$4(a, prop, b[prop]);
1026
+ if (__getOwnPropSymbols$3)
1027
+ for (var prop of __getOwnPropSymbols$3(b)) {
1028
+ if (__propIsEnum$3.call(b, prop))
1029
+ __defNormalProp$4(a, prop, b[prop]);
954
1030
  }
955
1031
  return a;
956
1032
  };
957
1033
  var __objRest$2 = (source, exclude) => {
958
1034
  var target = {};
959
1035
  for (var prop in source)
960
- if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
1036
+ if (__hasOwnProp$3.call(source, prop) && exclude.indexOf(prop) < 0)
961
1037
  target[prop] = source[prop];
962
- if (source != null && __getOwnPropSymbols$4)
963
- for (var prop of __getOwnPropSymbols$4(source)) {
964
- if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
1038
+ if (source != null && __getOwnPropSymbols$3)
1039
+ for (var prop of __getOwnPropSymbols$3(source)) {
1040
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$3.call(source, prop))
965
1041
  target[prop] = source[prop];
966
1042
  }
967
1043
  return target;
968
1044
  };
969
- var __async$4 = (__this, __arguments, generator) => {
1045
+ var __async$3 = (__this, __arguments, generator) => {
970
1046
  return new Promise((resolve, reject) => {
971
1047
  var fulfilled = (value) => {
972
1048
  try {
@@ -991,7 +1067,7 @@ function lunkwillCheckResponse(lwResp) {
991
1067
  return ct !== void 0 && ct !== null && ct.includes("application/vnd.lunkwill.request-summary+json");
992
1068
  }
993
1069
  function responseJson(response) {
994
- return __async$4(this, null, function* () {
1070
+ return __async$3(this, null, function* () {
995
1071
  try {
996
1072
  return response.json();
997
1073
  } catch (e) {
@@ -1000,7 +1076,7 @@ function responseJson(response) {
1000
1076
  });
1001
1077
  }
1002
1078
  function lunkwillResponseUrl(lwResp) {
1003
- return __async$4(this, null, function* () {
1079
+ return __async$3(this, null, function* () {
1004
1080
  const lwData = yield responseJson(lwResp);
1005
1081
  let delay = lwData.delay_ms;
1006
1082
  const retry = lwData.retry_ms !== void 0 ? lwData.retry_ms : 2e3;
@@ -1044,7 +1120,7 @@ function lunkwillResponseUrl(lwResp) {
1044
1120
  });
1045
1121
  }
1046
1122
  function lunkwillFetch(lwRespUrl) {
1047
- return __async$4(this, null, function* () {
1123
+ return __async$3(this, null, function* () {
1048
1124
  try {
1049
1125
  return yield window.fetch(lwRespUrl, { credentials: "same-origin" });
1050
1126
  } catch (e) {
@@ -1092,14 +1168,14 @@ function generateUrl(path, query) {
1092
1168
  return path + urlParams;
1093
1169
  }
1094
1170
  function request(path, options, cacheEngine) {
1095
- return __async$4(this, null, function* () {
1171
+ return __async$3(this, null, function* () {
1096
1172
  var _b;
1097
1173
  const defaults = {
1098
1174
  method: "GET",
1099
1175
  credentials: "same-origin",
1100
1176
  headers: {}
1101
1177
  };
1102
- const _a = __spreadValues$4(__spreadValues$4({}, defaults), options), {
1178
+ const _a = __spreadValues$3(__spreadValues$3({}, defaults), options), {
1103
1179
  withCredentials,
1104
1180
  responseType,
1105
1181
  cacheProps,
@@ -1135,7 +1211,7 @@ function request(path, options, cacheEngine) {
1135
1211
  opt.headers = headers;
1136
1212
  }
1137
1213
  const url = generateUrl(path, query);
1138
- const makeRequest = () => __async$4(this, null, function* () {
1214
+ const makeRequest = () => __async$3(this, null, function* () {
1139
1215
  let response;
1140
1216
  try {
1141
1217
  response = yield fetch(url, opt);
@@ -1175,8 +1251,8 @@ function request(path, options, cacheEngine) {
1175
1251
  }
1176
1252
  return body;
1177
1253
  });
1178
- if (cacheEngine && ((_b = opt.method) == null ? void 0 : _b.toUpperCase()) === "GET") {
1179
- const props = cacheProps ? cacheProps : __spreadValues$4({}, objectRemoveEmpty({
1254
+ if (cacheEngine && cache !== false && ((_b = opt.method) == null ? void 0 : _b.toUpperCase()) === "GET") {
1255
+ const props = cacheProps ? cacheProps : __spreadValues$3({}, objectRemoveEmpty({
1180
1256
  withCredentials,
1181
1257
  responseType
1182
1258
  }));
@@ -1189,21 +1265,21 @@ function request(path, options, cacheEngine) {
1189
1265
  });
1190
1266
  }
1191
1267
 
1192
- var __defProp$4 = Object.defineProperty;
1268
+ var __defProp$3 = Object.defineProperty;
1193
1269
  var __defProps$2 = Object.defineProperties;
1194
1270
  var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
1195
- var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
1196
- var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
1197
- var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
1198
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1199
- var __spreadValues$3 = (a, b) => {
1271
+ var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
1272
+ var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
1273
+ var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
1274
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1275
+ var __spreadValues$2 = (a, b) => {
1200
1276
  for (var prop in b || (b = {}))
1201
- if (__hasOwnProp$3.call(b, prop))
1202
- __defNormalProp$4(a, prop, b[prop]);
1203
- if (__getOwnPropSymbols$3)
1204
- for (var prop of __getOwnPropSymbols$3(b)) {
1205
- if (__propIsEnum$3.call(b, prop))
1206
- __defNormalProp$4(a, prop, b[prop]);
1277
+ if (__hasOwnProp$2.call(b, prop))
1278
+ __defNormalProp$3(a, prop, b[prop]);
1279
+ if (__getOwnPropSymbols$2)
1280
+ for (var prop of __getOwnPropSymbols$2(b)) {
1281
+ if (__propIsEnum$2.call(b, prop))
1282
+ __defNormalProp$3(a, prop, b[prop]);
1207
1283
  }
1208
1284
  return a;
1209
1285
  };
@@ -1211,16 +1287,16 @@ var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
1211
1287
  var __objRest$1 = (source, exclude) => {
1212
1288
  var target = {};
1213
1289
  for (var prop in source)
1214
- if (__hasOwnProp$3.call(source, prop) && exclude.indexOf(prop) < 0)
1290
+ if (__hasOwnProp$2.call(source, prop) && exclude.indexOf(prop) < 0)
1215
1291
  target[prop] = source[prop];
1216
- if (source != null && __getOwnPropSymbols$3)
1217
- for (var prop of __getOwnPropSymbols$3(source)) {
1218
- if (exclude.indexOf(prop) < 0 && __propIsEnum$3.call(source, prop))
1292
+ if (source != null && __getOwnPropSymbols$2)
1293
+ for (var prop of __getOwnPropSymbols$2(source)) {
1294
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$2.call(source, prop))
1219
1295
  target[prop] = source[prop];
1220
1296
  }
1221
1297
  return target;
1222
1298
  };
1223
- var __async$3 = (__this, __arguments, generator) => {
1299
+ var __async$2 = (__this, __arguments, generator) => {
1224
1300
  return new Promise((resolve, reject) => {
1225
1301
  var fulfilled = (value) => {
1226
1302
  try {
@@ -1271,7 +1347,7 @@ function routeURL(name, baseUrl, routeData, ...rest) {
1271
1347
  }
1272
1348
  function route(name, connector, ...rest) {
1273
1349
  const result = {
1274
- url: (opt) => __async$3(this, null, function* () {
1350
+ url: (opt) => __async$2(this, null, function* () {
1275
1351
  var _a;
1276
1352
  const routeData = yield connector.connect();
1277
1353
  const template = routeURL(
@@ -1285,27 +1361,32 @@ function route(name, connector, ...rest) {
1285
1361
  };
1286
1362
  const methods = ["get", "post", "put", "delete", "patch"];
1287
1363
  for (const method of methods) {
1288
- const methodResp = (requestOptions) => __async$3(this, null, function* () {
1364
+ const methodResp = (requestOptions) => {
1289
1365
  var _b;
1290
1366
  const _a = requestOptions || {}, { headers: optHeaders } = _a, restOpt = __objRest$1(_a, ["headers"]);
1291
- const routeData = yield connector.connect();
1292
- const template = routeURL(
1293
- name,
1294
- (_b = connector.options.baseUrl) != null ? _b : "",
1295
- routeData,
1296
- ...rest
1297
- );
1298
- const headers = objectRemoveEmpty(__spreadValues$3(__spreadValues$3({}, connector.getAuthorizationHeaders()), optHeaders != null ? optHeaders : {}));
1299
- return request(
1300
- template,
1301
- __spreadProps$2(__spreadValues$3({
1302
- headers
1303
- }, restOpt), {
1304
- method
1305
- }),
1306
- connector.cache
1307
- );
1308
- });
1367
+ if ((_b = requestOptions == null ? void 0 : requestOptions.signal) == null ? void 0 : _b.aborted) {
1368
+ throw new AbortError();
1369
+ }
1370
+ return connector.connect().then((routeData) => {
1371
+ var _a2;
1372
+ const template = routeURL(
1373
+ name,
1374
+ (_a2 = connector.options.baseUrl) != null ? _a2 : "",
1375
+ routeData,
1376
+ ...rest
1377
+ );
1378
+ const headers = objectRemoveEmpty(__spreadValues$2(__spreadValues$2({}, connector.getAuthorizationHeaders()), optHeaders != null ? optHeaders : {}));
1379
+ return request(
1380
+ template,
1381
+ __spreadProps$2(__spreadValues$2({
1382
+ headers
1383
+ }, restOpt), {
1384
+ method
1385
+ }),
1386
+ connector.cache
1387
+ );
1388
+ });
1389
+ };
1309
1390
  result[method] = methodResp;
1310
1391
  }
1311
1392
  return result;
@@ -1327,7 +1408,7 @@ let loadData;
1327
1408
  const getResponseText = () => {
1328
1409
  try {
1329
1410
  return JSON.parse(xhr.responseText);
1330
- } catch (er) {
1411
+ } catch (e) {
1331
1412
  return xhr.responseText;
1332
1413
  }
1333
1414
  };
@@ -1397,34 +1478,45 @@ let loadData;
1397
1478
  };
1398
1479
  }
1399
1480
 
1400
- const templateRe = /\{ *([\w_-]+) *\}/g;
1401
- function template(str, data) {
1402
- return str.replace(templateRe, (s, key) => {
1403
- let value = data[key];
1404
- if (value === void 0) {
1405
- throw new Error("No value provided for letiable " + s);
1406
- } else if (typeof value === "function") {
1407
- value = value(data);
1481
+ const CONNECTORS = [];
1482
+ function addConnector(connector) {
1483
+ CONNECTORS.push(connector);
1484
+ }
1485
+ function findConnector(options) {
1486
+ return CONNECTORS.find((x) => {
1487
+ if (x.options.baseUrl === options.baseUrl) {
1488
+ if (options.auth) {
1489
+ if (x.options.auth) {
1490
+ return objectDeepEqual(x.options.auth, options.auth);
1491
+ }
1492
+ } else {
1493
+ return true;
1494
+ }
1408
1495
  }
1409
- return value;
1410
1496
  });
1411
1497
  }
1498
+ function removeConnector(connector) {
1499
+ const index = CONNECTORS.indexOf(connector);
1500
+ if (index !== -1) {
1501
+ CONNECTORS.splice(index, 1);
1502
+ }
1503
+ }
1412
1504
 
1413
- var __defProp$3 = Object.defineProperty;
1505
+ var __defProp$2 = Object.defineProperty;
1414
1506
  var __defProps$1 = Object.defineProperties;
1415
1507
  var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
1416
- var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
1417
- var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
1418
- var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
1419
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1420
- var __spreadValues$2 = (a, b) => {
1508
+ var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
1509
+ var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
1510
+ var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
1511
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1512
+ var __spreadValues$1 = (a, b) => {
1421
1513
  for (var prop in b || (b = {}))
1422
- if (__hasOwnProp$2.call(b, prop))
1423
- __defNormalProp$3(a, prop, b[prop]);
1424
- if (__getOwnPropSymbols$2)
1425
- for (var prop of __getOwnPropSymbols$2(b)) {
1426
- if (__propIsEnum$2.call(b, prop))
1427
- __defNormalProp$3(a, prop, b[prop]);
1514
+ if (__hasOwnProp$1.call(b, prop))
1515
+ __defNormalProp$2(a, prop, b[prop]);
1516
+ if (__getOwnPropSymbols$1)
1517
+ for (var prop of __getOwnPropSymbols$1(b)) {
1518
+ if (__propIsEnum$1.call(b, prop))
1519
+ __defNormalProp$2(a, prop, b[prop]);
1428
1520
  }
1429
1521
  return a;
1430
1522
  };
@@ -1432,17 +1524,17 @@ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
1432
1524
  var __objRest = (source, exclude) => {
1433
1525
  var target = {};
1434
1526
  for (var prop in source)
1435
- if (__hasOwnProp$2.call(source, prop) && exclude.indexOf(prop) < 0)
1527
+ if (__hasOwnProp$1.call(source, prop) && exclude.indexOf(prop) < 0)
1436
1528
  target[prop] = source[prop];
1437
- if (source != null && __getOwnPropSymbols$2)
1438
- for (var prop of __getOwnPropSymbols$2(source)) {
1439
- if (exclude.indexOf(prop) < 0 && __propIsEnum$2.call(source, prop))
1529
+ if (source != null && __getOwnPropSymbols$1)
1530
+ for (var prop of __getOwnPropSymbols$1(source)) {
1531
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$1.call(source, prop))
1440
1532
  target[prop] = source[prop];
1441
1533
  }
1442
1534
  return target;
1443
1535
  };
1444
- var __publicField$2 = (obj, key, value) => __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
1445
- var __async$2 = (__this, __arguments, generator) => {
1536
+ var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
1537
+ var __async$1 = (__this, __arguments, generator) => {
1446
1538
  return new Promise((resolve, reject) => {
1447
1539
  var fulfilled = (value) => {
1448
1540
  try {
@@ -1527,7 +1619,9 @@ class NgwConnector {
1527
1619
  * ```
1528
1620
  */
1529
1621
  connect() {
1530
- return __async$2(this, null, function* () {
1622
+ return __async$1(this, arguments, function* ({
1623
+ signal
1624
+ } = {}) {
1531
1625
  const auth = this.options.auth;
1532
1626
  if (auth) {
1533
1627
  const { login, password } = auth;
@@ -1536,11 +1630,12 @@ class NgwConnector {
1536
1630
  }
1537
1631
  }
1538
1632
  const routeUrl = `${this.routeStr}?client=${this.client}`;
1539
- return yield this.makeQuery(
1633
+ return this.makeQuery(
1540
1634
  routeUrl,
1541
1635
  {},
1542
1636
  {
1543
1637
  cacheName: "route",
1638
+ signal,
1544
1639
  cache: true,
1545
1640
  cacheProps: {
1546
1641
  id: this.id,
@@ -1572,14 +1667,14 @@ class NgwConnector {
1572
1667
  this.emitter.emit("logout");
1573
1668
  }
1574
1669
  getUserInfo(credentials, options) {
1575
- return __async$2(this, null, function* () {
1670
+ return __async$1(this, null, function* () {
1576
1671
  if (this.user && this.user.id) {
1577
1672
  return this.user;
1578
1673
  }
1579
1674
  if (credentials) {
1580
1675
  this.options.auth = credentials;
1581
1676
  }
1582
- const options_ = __spreadValues$2({
1677
+ const options_ = __spreadValues$1({
1583
1678
  headers: this.getAuthorizationHeaders(credentials),
1584
1679
  cache: true
1585
1680
  }, options);
@@ -1620,7 +1715,7 @@ class NgwConnector {
1620
1715
  this.activeRequests = {};
1621
1716
  }
1622
1717
  getActiveApiRequests() {
1623
- return __spreadValues$2({}, this.activeRequests);
1718
+ return __spreadValues$1({}, this.activeRequests);
1624
1719
  }
1625
1720
  route(name, ...rest) {
1626
1721
  return route(name, this, ...rest);
@@ -1632,7 +1727,7 @@ class NgwConnector {
1632
1727
  * @param options - Request options
1633
1728
  */
1634
1729
  makeQuery(_0, _1) {
1635
- return __async$2(this, arguments, function* (url, params, options = {}) {
1730
+ return __async$1(this, arguments, function* (url, params, options = {}) {
1636
1731
  var _b;
1637
1732
  url = (this.options.baseUrl ? this.options.baseUrl : "") + url;
1638
1733
  if (!url) {
@@ -1643,7 +1738,7 @@ class NgwConnector {
1643
1738
  url = template(url, restParams);
1644
1739
  }
1645
1740
  url = encodeURI(fixUrlStr(url));
1646
- options = __spreadValues$2({ withCredentials: this.withCredentials }, options);
1741
+ options = __spreadValues$1({ withCredentials: this.withCredentials }, options);
1647
1742
  const {
1648
1743
  cache,
1649
1744
  signal: externalSignal,
@@ -1665,7 +1760,7 @@ class NgwConnector {
1665
1760
  });
1666
1761
  }
1667
1762
  options.signal = internalSignal;
1668
- const createPromise = () => __async$2(this, null, function* () {
1763
+ const createPromise = () => __async$1(this, null, function* () {
1669
1764
  const id = REQUEST_ID++;
1670
1765
  this.activeRequests[id] = internalAbortController;
1671
1766
  try {
@@ -1675,7 +1770,7 @@ class NgwConnector {
1675
1770
  }
1676
1771
  });
1677
1772
  if (method === "GET") {
1678
- const cacheOptions = cacheProps ? cacheProps : __spreadProps$1(__spreadValues$2({}, objectRemoveEmpty({
1773
+ const cacheOptions = cacheProps ? cacheProps : __spreadProps$1(__spreadValues$1({}, objectRemoveEmpty({
1679
1774
  headers,
1680
1775
  withCredentials,
1681
1776
  responseType,
@@ -1698,7 +1793,7 @@ class NgwConnector {
1698
1793
  var _a;
1699
1794
  if (this.user) {
1700
1795
  options = options || {};
1701
- options.headers = __spreadValues$2(__spreadValues$2({}, this.getAuthorizationHeaders()), options.headers);
1796
+ options.headers = __spreadValues$1(__spreadValues$1({}, this.getAuthorizationHeaders()), options.headers);
1702
1797
  }
1703
1798
  if (this.requestTransform) {
1704
1799
  const [transUrl, transOptions] = this.requestTransform(url, options);
@@ -1729,7 +1824,7 @@ class NgwConnector {
1729
1824
  });
1730
1825
  }
1731
1826
  _login(credentials, options) {
1732
- return __async$2(this, null, function* () {
1827
+ return __async$1(this, null, function* () {
1733
1828
  try {
1734
1829
  const data = yield this.getUserInfo(credentials, options);
1735
1830
  this.user = data;
@@ -1787,27 +1882,27 @@ function resourceToQuery(resource, prefix = "") {
1787
1882
  return query;
1788
1883
  }
1789
1884
 
1790
- var __defProp$2 = Object.defineProperty;
1885
+ var __defProp$1 = Object.defineProperty;
1791
1886
  var __defProps = Object.defineProperties;
1792
1887
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
1793
- var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
1794
- var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
1795
- var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
1796
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1797
- var __spreadValues$1 = (a, b) => {
1888
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
1889
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
1890
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
1891
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1892
+ var __spreadValues = (a, b) => {
1798
1893
  for (var prop in b || (b = {}))
1799
- if (__hasOwnProp$1.call(b, prop))
1800
- __defNormalProp$2(a, prop, b[prop]);
1801
- if (__getOwnPropSymbols$1)
1802
- for (var prop of __getOwnPropSymbols$1(b)) {
1803
- if (__propIsEnum$1.call(b, prop))
1804
- __defNormalProp$2(a, prop, b[prop]);
1894
+ if (__hasOwnProp.call(b, prop))
1895
+ __defNormalProp$1(a, prop, b[prop]);
1896
+ if (__getOwnPropSymbols)
1897
+ for (var prop of __getOwnPropSymbols(b)) {
1898
+ if (__propIsEnum.call(b, prop))
1899
+ __defNormalProp$1(a, prop, b[prop]);
1805
1900
  }
1806
1901
  return a;
1807
1902
  };
1808
1903
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
1809
- var __publicField$1 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
1810
- var __async$1 = (__this, __arguments, generator) => {
1904
+ var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
1905
+ var __async = (__this, __arguments, generator) => {
1811
1906
  return new Promise((resolve, reject) => {
1812
1907
  var fulfilled = (value) => {
1813
1908
  try {
@@ -1848,7 +1943,7 @@ class ResourcesControl {
1848
1943
  * Fetching resource would be cached to speed up next call
1849
1944
  */
1850
1945
  getOne(resource, requestOptions) {
1851
- const opt = __spreadValues$1({}, requestOptions);
1946
+ const opt = __spreadValues({}, requestOptions);
1852
1947
  if (typeof resource === "string") ; else if (typeof resource === "number") ; else if (isObject(resource)) {
1853
1948
  if (resource.id !== void 0) {
1854
1949
  resource.id;
@@ -1925,8 +2020,8 @@ class ResourcesControl {
1925
2020
  } else {
1926
2021
  Object.assign(query, resourceToQuery(resource));
1927
2022
  }
1928
- return this.connector.route("resource.search").get(__spreadProps(__spreadValues$1({}, requestOptions), {
1929
- query: __spreadValues$1({
2023
+ return this.connector.route("resource.search").get(__spreadProps(__spreadValues({}, requestOptions), {
2024
+ query: __spreadValues({
1930
2025
  serialization: "full"
1931
2026
  }, query)
1932
2027
  })).then((resources) => {
@@ -1979,7 +2074,7 @@ class ResourcesControl {
1979
2074
  });
1980
2075
  }
1981
2076
  _getChildrenOf(_0, _1) {
1982
- return __async$1(this, arguments, function* (parentDef, requestOptions, _items = []) {
2077
+ return __async(this, arguments, function* (parentDef, requestOptions, _items = []) {
1983
2078
  let parent = void 0;
1984
2079
  if (typeof parentDef === "string") {
1985
2080
  parent = yield this.getId(parentDef, requestOptions);
@@ -1988,7 +2083,7 @@ class ResourcesControl {
1988
2083
  } else {
1989
2084
  parent = parentDef;
1990
2085
  }
1991
- const items = yield this.connector.route("resource.collection").get(__spreadProps(__spreadValues$1({}, requestOptions), {
2086
+ const items = yield this.connector.route("resource.collection").get(__spreadProps(__spreadValues({}, requestOptions), {
1992
2087
  query: {
1993
2088
  parent
1994
2089
  }
@@ -2016,7 +2111,7 @@ class ResourcesControl {
2016
2111
  });
2017
2112
  }
2018
2113
  _cleanResourceItemCache(id) {
2019
- return __async$1(this, null, function* () {
2114
+ return __async(this, null, function* () {
2020
2115
  var _a;
2021
2116
  const all = this.cache.all();
2022
2117
  const toDelete = [];
@@ -2069,93 +2164,6 @@ class ResourcesControl {
2069
2164
  }
2070
2165
  }
2071
2166
 
2072
- var __defProp$1 = Object.defineProperty;
2073
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
2074
- var __hasOwnProp = Object.prototype.hasOwnProperty;
2075
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
2076
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2077
- var __spreadValues = (a, b) => {
2078
- for (var prop in b || (b = {}))
2079
- if (__hasOwnProp.call(b, prop))
2080
- __defNormalProp$1(a, prop, b[prop]);
2081
- if (__getOwnPropSymbols)
2082
- for (var prop of __getOwnPropSymbols(b)) {
2083
- if (__propIsEnum.call(b, prop))
2084
- __defNormalProp$1(a, prop, b[prop]);
2085
- }
2086
- return a;
2087
- };
2088
- var __async = (__this, __arguments, generator) => {
2089
- return new Promise((resolve, reject) => {
2090
- var fulfilled = (value) => {
2091
- try {
2092
- step(generator.next(value));
2093
- } catch (e) {
2094
- reject(e);
2095
- }
2096
- };
2097
- var rejected = (value) => {
2098
- try {
2099
- step(generator.throw(value));
2100
- } catch (e) {
2101
- reject(e);
2102
- }
2103
- };
2104
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
2105
- step((generator = generator.apply(__this, __arguments)).next());
2106
- });
2107
- };
2108
- function apiRequest(opt) {
2109
- return __async(this, null, function* () {
2110
- const { params, name, connector, requestOptions } = opt;
2111
- const apiItems = yield connector.connect();
2112
- let apiItem = apiItems && apiItems[name];
2113
- if (apiItem) {
2114
- apiItem = [...apiItem];
2115
- let url = apiItem.shift();
2116
- if (apiItem.length) {
2117
- const replaceParams = {};
2118
- for (let fry = 0; fry < apiItem.length; fry++) {
2119
- const arg = apiItem[fry];
2120
- replaceParams[fry] = `{${arg}}`;
2121
- if (params[arg] === void 0) {
2122
- throw new Error(`\`${arg}\` URL API argument is not specified`);
2123
- }
2124
- }
2125
- if (url) {
2126
- url = template(url, replaceParams);
2127
- }
2128
- }
2129
- if (params) {
2130
- const paramArray = [];
2131
- const paramList = params.paramList;
2132
- if (Array.isArray(paramList)) {
2133
- paramList.forEach(([key, value]) => {
2134
- paramArray.push(`${key}=${value}`);
2135
- });
2136
- }
2137
- for (const p in params) {
2138
- if (apiItem.indexOf(p) === -1) {
2139
- paramArray.push(`${p}=${params[p]}`);
2140
- }
2141
- }
2142
- if (paramArray.length) {
2143
- url = `${url}?${paramArray.join("&")}`;
2144
- }
2145
- }
2146
- if (url) {
2147
- return connector.makeQuery(url, params, __spreadValues({
2148
- cacheName: name
2149
- }, requestOptions));
2150
- } else {
2151
- throw new Error("Request URL is not set");
2152
- }
2153
- } else {
2154
- return void 0;
2155
- }
2156
- });
2157
- }
2158
-
2159
2167
  var __defProp = Object.defineProperty;
2160
2168
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2161
2169
  var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);