@nextgis/ngw-connector 3.0.0-alpha.8 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -138
- package/lib/index.d.ts +154 -86
- package/lib/ngw-connector.cjs.js +285 -192
- package/lib/ngw-connector.cjs.js.map +1 -1
- package/lib/ngw-connector.cjs.prod.js +1 -1
- package/lib/ngw-connector.cjs.prod.js.map +1 -1
- package/lib/ngw-connector.esm-browser.js +542 -448
- package/lib/ngw-connector.esm-browser.js.map +1 -1
- package/lib/ngw-connector.esm-browser.prod.js +1 -1
- package/lib/ngw-connector.esm-browser.prod.js.map +1 -1
- package/lib/ngw-connector.esm-bundler.js +401 -311
- package/lib/ngw-connector.esm-bundler.js.map +1 -1
- package/lib/ngw-connector.esm-bundler.prod.js +1 -1
- package/lib/ngw-connector.esm-bundler.prod.js.map +1 -1
- package/lib/ngw-connector.global.js +542 -448
- package/lib/ngw-connector.global.js.map +1 -1
- package/lib/ngw-connector.global.prod.js +1 -1
- package/lib/ngw-connector.global.prod.js.map +1 -1
- package/package.json +6 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Bundle of @nextgis/ngw-connector; version: 3.0.0
|
|
1
|
+
/** Bundle of @nextgis/ngw-connector; version: 3.0.0; author: NextGIS */
|
|
2
2
|
function defined(val) {
|
|
3
3
|
return val !== void 0 && val !== null;
|
|
4
4
|
}
|
|
@@ -52,10 +52,253 @@ function objectRemoveEmpty(obj) {
|
|
|
52
52
|
return newObj;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
function isObject$1(val) {
|
|
56
|
+
return Object.prototype.toString.call(val) === "[object Object]";
|
|
57
|
+
}
|
|
58
|
+
|
|
55
59
|
function fixUrlStr(url) {
|
|
56
60
|
return url.replace(/([^:]\/)\/+/g, "$1");
|
|
57
61
|
}
|
|
58
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
|
+
|
|
59
302
|
var domain;
|
|
60
303
|
|
|
61
304
|
// This constructor is used to store event handlers. Instantiating this is
|
|
@@ -528,148 +771,9 @@ function unwrapListeners(arr) {
|
|
|
528
771
|
return ret;
|
|
529
772
|
}
|
|
530
773
|
|
|
531
|
-
var __defProp$b = Object.defineProperty;
|
|
532
|
-
var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
533
|
-
var __publicField$8 = (obj, key, value) => __defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
534
|
-
const _Cache = class _Cache {
|
|
535
|
-
constructor(options = {}) {
|
|
536
|
-
__publicField$8(this, "cache", []);
|
|
537
|
-
var _a;
|
|
538
|
-
const namespace = (_a = options.namespace) != null ? _a : "default";
|
|
539
|
-
if (_Cache.instance[namespace]) {
|
|
540
|
-
return _Cache.instance[namespace];
|
|
541
|
-
}
|
|
542
|
-
_Cache.instance[namespace] = this;
|
|
543
|
-
return this;
|
|
544
|
-
}
|
|
545
|
-
clean() {
|
|
546
|
-
this.cache.length = 0;
|
|
547
|
-
}
|
|
548
|
-
all() {
|
|
549
|
-
return this.cache;
|
|
550
|
-
}
|
|
551
|
-
/**
|
|
552
|
-
* Caching only a non-empty value.
|
|
553
|
-
*
|
|
554
|
-
* Useful for get or create strategy
|
|
555
|
-
* @example
|
|
556
|
-
* ```javascript
|
|
557
|
-
* const cache = new Cache();
|
|
558
|
-
* const getItemFunc = () => fetch(url).then((data) => {
|
|
559
|
-
* return data.json(); // undefined
|
|
560
|
-
* });
|
|
561
|
-
* const item = await cache.addFull('foo', getItemFunc);
|
|
562
|
-
* if (!item) {
|
|
563
|
-
* await createItem(); // 'New item'
|
|
564
|
-
* }
|
|
565
|
-
*
|
|
566
|
-
* // somewhere else in the code
|
|
567
|
-
* const item = await cache.addFull('foo', getItemFunc).then((resp) => {
|
|
568
|
-
* console.log(resp); // 'New item'
|
|
569
|
-
* });
|
|
570
|
-
* ```
|
|
571
|
-
*/
|
|
572
|
-
addFull(key, valueToSet, propsOrOptions, expirationTime) {
|
|
573
|
-
if (typeof propsOrOptions === "object" && "valueToSet" in propsOrOptions) {
|
|
574
|
-
propsOrOptions.onlyFull = true;
|
|
575
|
-
}
|
|
576
|
-
return this.add(key, valueToSet, propsOrOptions, true, expirationTime);
|
|
577
|
-
}
|
|
578
|
-
add(key, valueToSet, propsOrOptions, onlyFull, expirationTime) {
|
|
579
|
-
let opt;
|
|
580
|
-
let props;
|
|
581
|
-
if (typeof propsOrOptions === "object" && "valueToSet" in propsOrOptions) {
|
|
582
|
-
opt = propsOrOptions;
|
|
583
|
-
onlyFull = opt.onlyFull;
|
|
584
|
-
expirationTime = opt.expirationTime;
|
|
585
|
-
props = opt.props;
|
|
586
|
-
} else {
|
|
587
|
-
props = propsOrOptions;
|
|
588
|
-
}
|
|
589
|
-
const exist = this._find(key, props);
|
|
590
|
-
if (!exist) {
|
|
591
|
-
let value;
|
|
592
|
-
if (valueToSet instanceof Function) {
|
|
593
|
-
value = valueToSet();
|
|
594
|
-
} else {
|
|
595
|
-
value = valueToSet;
|
|
596
|
-
}
|
|
597
|
-
const nonEmptyProps = props && JSON.parse(JSON.stringify(objectRemoveEmpty(props)));
|
|
598
|
-
expirationTime = expirationTime ? Date.now() + expirationTime : void 0;
|
|
599
|
-
const cacheItem = {
|
|
600
|
-
key,
|
|
601
|
-
value,
|
|
602
|
-
props: nonEmptyProps,
|
|
603
|
-
expirationTime
|
|
604
|
-
};
|
|
605
|
-
if (onlyFull && !full(value)) {
|
|
606
|
-
return value;
|
|
607
|
-
}
|
|
608
|
-
this.cache.push(cacheItem);
|
|
609
|
-
if (value instanceof Promise) {
|
|
610
|
-
value.catch((er) => {
|
|
611
|
-
this.delete(key, props);
|
|
612
|
-
});
|
|
613
|
-
if (onlyFull) {
|
|
614
|
-
value.then((x) => {
|
|
615
|
-
if (!full(x)) {
|
|
616
|
-
this.delete(key, props);
|
|
617
|
-
}
|
|
618
|
-
return x;
|
|
619
|
-
});
|
|
620
|
-
}
|
|
621
|
-
return value;
|
|
622
|
-
}
|
|
623
|
-
return value;
|
|
624
|
-
} else {
|
|
625
|
-
return exist.value;
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
match(key, props) {
|
|
629
|
-
const cacheRecord = this._find(key, props);
|
|
630
|
-
if (cacheRecord && cacheRecord.expirationTime && Date.now() > cacheRecord.expirationTime) {
|
|
631
|
-
this.delete(cacheRecord);
|
|
632
|
-
return void 0;
|
|
633
|
-
}
|
|
634
|
-
return cacheRecord == null ? void 0 : cacheRecord.value;
|
|
635
|
-
}
|
|
636
|
-
matchAll(key, props) {
|
|
637
|
-
const now = Date.now();
|
|
638
|
-
this.cache.forEach((item) => {
|
|
639
|
-
if (item.expirationTime && now > item.expirationTime) {
|
|
640
|
-
this.delete(item);
|
|
641
|
-
}
|
|
642
|
-
});
|
|
643
|
-
if (key) {
|
|
644
|
-
return this.cache.filter((x) => this._filter(x, key, props)).map((x) => x.value);
|
|
645
|
-
}
|
|
646
|
-
return this.cache.map((x) => x.value);
|
|
647
|
-
}
|
|
648
|
-
delete(keyOrItem, props) {
|
|
649
|
-
const itemsToDelete = typeof keyOrItem === "string" ? this.cache.filter((x) => this._filter(x, keyOrItem, props)) : [keyOrItem];
|
|
650
|
-
for (const item of itemsToDelete) {
|
|
651
|
-
const index = this.cache.indexOf(item);
|
|
652
|
-
if (index !== -1) {
|
|
653
|
-
this.cache.splice(index, 1);
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
_find(key, props) {
|
|
658
|
-
return this.cache.find((x) => this._filter(x, key, props));
|
|
659
|
-
}
|
|
660
|
-
_filter(item, key, props) {
|
|
661
|
-
if (item.key !== key) return false;
|
|
662
|
-
if (!props) return true;
|
|
663
|
-
const itemProps = item.props;
|
|
664
|
-
return objectDeepEqual(itemProps || {}, objectRemoveEmpty(props));
|
|
665
|
-
}
|
|
666
|
-
};
|
|
667
|
-
__publicField$8(_Cache, "instance", {});
|
|
668
|
-
let Cache = _Cache;
|
|
669
|
-
|
|
670
774
|
var pkg = {
|
|
671
775
|
name: "@nextgis/ngw-connector",
|
|
672
|
-
version: "3.0.0
|
|
776
|
+
version: "3.0.0",
|
|
673
777
|
_priority: 12,
|
|
674
778
|
description: "A lightweight HTTP client optimized for use with NextGIS Web API",
|
|
675
779
|
main: "index.js",
|
|
@@ -678,15 +782,15 @@ var pkg = {
|
|
|
678
782
|
jsdelivr: "lib/ngw-connector.global.prod.js",
|
|
679
783
|
types: "lib/index.d.ts",
|
|
680
784
|
dependencies: {
|
|
681
|
-
"@nextgis/cache": "
|
|
682
|
-
"@nextgis/cancelable-promise": "
|
|
683
|
-
"@nextgis/utils": "
|
|
785
|
+
"@nextgis/cache": "3.0.0",
|
|
786
|
+
"@nextgis/cancelable-promise": "3.0.0",
|
|
787
|
+
"@nextgis/utils": "3.0.0",
|
|
684
788
|
"@types/events": "^3.0.0",
|
|
685
789
|
events: "*",
|
|
686
790
|
"form-data": "^4.0.0"
|
|
687
791
|
},
|
|
688
792
|
devDependencies: {
|
|
689
|
-
"@nextgis/build-tools": "
|
|
793
|
+
"@nextgis/build-tools": "3.0.0"
|
|
690
794
|
},
|
|
691
795
|
scripts: {
|
|
692
796
|
clean: "rimraf ./lib",
|
|
@@ -726,30 +830,6 @@ var pkg = {
|
|
|
726
830
|
gitHead: "edc68033f914f6c95c4125b9738bba6d36e990b4"
|
|
727
831
|
};
|
|
728
832
|
|
|
729
|
-
const CONNECTORS = [];
|
|
730
|
-
function addConnector(connector) {
|
|
731
|
-
CONNECTORS.push(connector);
|
|
732
|
-
}
|
|
733
|
-
function findConnector(options) {
|
|
734
|
-
return CONNECTORS.find((x) => {
|
|
735
|
-
if (x.options.baseUrl === options.baseUrl) {
|
|
736
|
-
if (options.auth) {
|
|
737
|
-
if (x.options.auth) {
|
|
738
|
-
return objectDeepEqual(x.options.auth, options.auth);
|
|
739
|
-
}
|
|
740
|
-
} else {
|
|
741
|
-
return true;
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
});
|
|
745
|
-
}
|
|
746
|
-
function removeConnector(connector) {
|
|
747
|
-
const index = CONNECTORS.indexOf(connector);
|
|
748
|
-
if (index !== -1) {
|
|
749
|
-
CONNECTORS.splice(index, 1);
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
|
|
753
833
|
class AbortError extends Error {
|
|
754
834
|
constructor(message = "AbortError") {
|
|
755
835
|
super(message);
|
|
@@ -759,18 +839,18 @@ class AbortError extends Error {
|
|
|
759
839
|
|
|
760
840
|
var __defProp$a = Object.defineProperty;
|
|
761
841
|
var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
762
|
-
var __publicField$
|
|
842
|
+
var __publicField$8 = (obj, key, value) => __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
763
843
|
class NgwError extends Error {
|
|
764
844
|
constructor(er) {
|
|
765
845
|
super();
|
|
766
|
-
__publicField$
|
|
767
|
-
__publicField$
|
|
768
|
-
__publicField$
|
|
769
|
-
__publicField$
|
|
770
|
-
__publicField$
|
|
771
|
-
__publicField$
|
|
772
|
-
__publicField$
|
|
773
|
-
__publicField$
|
|
846
|
+
__publicField$8(this, "name", "NgwError");
|
|
847
|
+
__publicField$8(this, "title");
|
|
848
|
+
__publicField$8(this, "message");
|
|
849
|
+
__publicField$8(this, "detail");
|
|
850
|
+
__publicField$8(this, "exception");
|
|
851
|
+
__publicField$8(this, "status_code");
|
|
852
|
+
__publicField$8(this, "data");
|
|
853
|
+
__publicField$8(this, "guru_meditation");
|
|
774
854
|
Object.assign(this, er);
|
|
775
855
|
Object.setPrototypeOf(this, NgwError.prototype);
|
|
776
856
|
}
|
|
@@ -778,35 +858,105 @@ class NgwError extends Error {
|
|
|
778
858
|
|
|
779
859
|
var __defProp$9 = Object.defineProperty;
|
|
780
860
|
var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
781
|
-
var __publicField$
|
|
861
|
+
var __publicField$7 = (obj, key, value) => __defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
782
862
|
class InsufficientPermissionsError extends NgwError {
|
|
783
863
|
constructor(obj) {
|
|
784
864
|
super(obj);
|
|
785
|
-
__publicField$
|
|
786
|
-
__publicField$
|
|
865
|
+
__publicField$7(this, "name", "InsufficientPermissionsError");
|
|
866
|
+
__publicField$7(this, "exception", "nextgisweb.core.exception.InsufficientPermissions");
|
|
787
867
|
Object.setPrototypeOf(this, InsufficientPermissionsError.prototype);
|
|
788
868
|
}
|
|
789
869
|
}
|
|
790
870
|
|
|
791
871
|
var __defProp$8 = Object.defineProperty;
|
|
792
872
|
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
793
|
-
var __publicField$
|
|
794
|
-
class
|
|
873
|
+
var __publicField$6 = (obj, key, value) => __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
874
|
+
let NetworksResponseError$1 = class NetworksResponseError extends NgwError {
|
|
795
875
|
constructor(obj) {
|
|
796
876
|
super(obj);
|
|
797
|
-
__publicField$
|
|
798
|
-
__publicField$
|
|
799
|
-
|
|
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.");
|
|
880
|
+
Object.setPrototypeOf(this, NetworksResponseError.prototype);
|
|
881
|
+
}
|
|
882
|
+
};
|
|
883
|
+
|
|
884
|
+
function extractError(error) {
|
|
885
|
+
if (isObject$1(error)) {
|
|
886
|
+
if (error.name && error.message && error.title) {
|
|
887
|
+
return {
|
|
888
|
+
title: error.title,
|
|
889
|
+
message: error.message,
|
|
890
|
+
detail: error.detail || null,
|
|
891
|
+
data: error.data && error.data.data ? error.data.data : null
|
|
892
|
+
};
|
|
893
|
+
} else if (error.exception) {
|
|
894
|
+
if (error.status === void 0 || error.status === 0 || error.data === void 0) {
|
|
895
|
+
return new NetworksResponseError$1({
|
|
896
|
+
title: error.title,
|
|
897
|
+
status_code: error.status_code,
|
|
898
|
+
exception: error.exception
|
|
899
|
+
});
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
return {
|
|
903
|
+
title: typeof error.title === "string" ? error.title : "Unexpected error",
|
|
904
|
+
message: typeof error.message === "string" ? error.message : "Something went wrong."
|
|
905
|
+
};
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
function isError(error) {
|
|
910
|
+
if (isObject$1(error)) {
|
|
911
|
+
return error.status_code && error.exception && error.title;
|
|
800
912
|
}
|
|
913
|
+
return false;
|
|
801
914
|
}
|
|
802
915
|
|
|
803
916
|
var __defProp$7 = Object.defineProperty;
|
|
804
917
|
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
805
|
-
var __publicField$
|
|
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
|
+
|
|
941
|
+
var errors = /*#__PURE__*/Object.freeze({
|
|
942
|
+
__proto__: null,
|
|
943
|
+
AbortError: AbortError,
|
|
944
|
+
InsufficientPermissionsError: InsufficientPermissionsError,
|
|
945
|
+
NetworkError: NetworkError,
|
|
946
|
+
NetworksResponseError: NetworksResponseError$1,
|
|
947
|
+
NgwError: NgwError,
|
|
948
|
+
ResourceNotFoundError: ResourceNotFoundError,
|
|
949
|
+
extractError: extractError,
|
|
950
|
+
isError: isError
|
|
951
|
+
});
|
|
952
|
+
|
|
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);
|
|
806
956
|
class BaseAPIError extends Error {
|
|
807
957
|
constructor(message) {
|
|
808
958
|
super(message || "Something went wrong.");
|
|
809
|
-
__publicField$
|
|
959
|
+
__publicField$3(this, "title");
|
|
810
960
|
this.name = "BaseAPIError";
|
|
811
961
|
this.title = "Unknown API error";
|
|
812
962
|
if (Error.captureStackTrace) {
|
|
@@ -818,7 +968,7 @@ class NetworksResponseError extends BaseAPIError {
|
|
|
818
968
|
// prettier-ignore
|
|
819
969
|
constructor(message) {
|
|
820
970
|
super(message || "There is no response from the server or problem connecting to server.");
|
|
821
|
-
__publicField$
|
|
971
|
+
__publicField$3(this, "detail");
|
|
822
972
|
this.title = "Network error";
|
|
823
973
|
this.detail = "Check network connectivity and try again later.";
|
|
824
974
|
}
|
|
@@ -832,8 +982,8 @@ class InvalidResponseError extends BaseAPIError {
|
|
|
832
982
|
class ServerResponseError extends BaseAPIError {
|
|
833
983
|
constructor(data) {
|
|
834
984
|
super(data.message);
|
|
835
|
-
__publicField$
|
|
836
|
-
__publicField$
|
|
985
|
+
__publicField$3(this, "detail");
|
|
986
|
+
__publicField$3(this, "data");
|
|
837
987
|
this.title = data.title || this.title;
|
|
838
988
|
this.detail = data.detail || null;
|
|
839
989
|
this.data = data;
|
|
@@ -843,8 +993,8 @@ class LunkwillError extends Error {
|
|
|
843
993
|
// prettier-ignore
|
|
844
994
|
constructor(message, data = {}) {
|
|
845
995
|
super(message || "Unexpected error while processing long-running request.");
|
|
846
|
-
__publicField$
|
|
847
|
-
__publicField$
|
|
996
|
+
__publicField$3(this, "title");
|
|
997
|
+
__publicField$3(this, "data");
|
|
848
998
|
this.name = "LunkwillError";
|
|
849
999
|
this.title = "Long-running request error";
|
|
850
1000
|
this.data = data;
|
|
@@ -864,35 +1014,35 @@ class LunkwillRequestFailed extends LunkwillError {
|
|
|
864
1014
|
}
|
|
865
1015
|
}
|
|
866
1016
|
|
|
867
|
-
var __defProp$
|
|
868
|
-
var __getOwnPropSymbols$
|
|
869
|
-
var __hasOwnProp$
|
|
870
|
-
var __propIsEnum$
|
|
871
|
-
var __defNormalProp$
|
|
872
|
-
var __spreadValues$
|
|
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) => {
|
|
873
1023
|
for (var prop in b || (b = {}))
|
|
874
|
-
if (__hasOwnProp$
|
|
875
|
-
__defNormalProp$
|
|
876
|
-
if (__getOwnPropSymbols$
|
|
877
|
-
for (var prop of __getOwnPropSymbols$
|
|
878
|
-
if (__propIsEnum$
|
|
879
|
-
__defNormalProp$
|
|
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]);
|
|
880
1030
|
}
|
|
881
1031
|
return a;
|
|
882
1032
|
};
|
|
883
1033
|
var __objRest$2 = (source, exclude) => {
|
|
884
1034
|
var target = {};
|
|
885
1035
|
for (var prop in source)
|
|
886
|
-
if (__hasOwnProp$
|
|
1036
|
+
if (__hasOwnProp$3.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
887
1037
|
target[prop] = source[prop];
|
|
888
|
-
if (source != null && __getOwnPropSymbols$
|
|
889
|
-
for (var prop of __getOwnPropSymbols$
|
|
890
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
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))
|
|
891
1041
|
target[prop] = source[prop];
|
|
892
1042
|
}
|
|
893
1043
|
return target;
|
|
894
1044
|
};
|
|
895
|
-
var __async$
|
|
1045
|
+
var __async$3 = (__this, __arguments, generator) => {
|
|
896
1046
|
return new Promise((resolve, reject) => {
|
|
897
1047
|
var fulfilled = (value) => {
|
|
898
1048
|
try {
|
|
@@ -917,7 +1067,7 @@ function lunkwillCheckResponse(lwResp) {
|
|
|
917
1067
|
return ct !== void 0 && ct !== null && ct.includes("application/vnd.lunkwill.request-summary+json");
|
|
918
1068
|
}
|
|
919
1069
|
function responseJson(response) {
|
|
920
|
-
return __async$
|
|
1070
|
+
return __async$3(this, null, function* () {
|
|
921
1071
|
try {
|
|
922
1072
|
return response.json();
|
|
923
1073
|
} catch (e) {
|
|
@@ -926,7 +1076,7 @@ function responseJson(response) {
|
|
|
926
1076
|
});
|
|
927
1077
|
}
|
|
928
1078
|
function lunkwillResponseUrl(lwResp) {
|
|
929
|
-
return __async$
|
|
1079
|
+
return __async$3(this, null, function* () {
|
|
930
1080
|
const lwData = yield responseJson(lwResp);
|
|
931
1081
|
let delay = lwData.delay_ms;
|
|
932
1082
|
const retry = lwData.retry_ms !== void 0 ? lwData.retry_ms : 2e3;
|
|
@@ -970,7 +1120,7 @@ function lunkwillResponseUrl(lwResp) {
|
|
|
970
1120
|
});
|
|
971
1121
|
}
|
|
972
1122
|
function lunkwillFetch(lwRespUrl) {
|
|
973
|
-
return __async$
|
|
1123
|
+
return __async$3(this, null, function* () {
|
|
974
1124
|
try {
|
|
975
1125
|
return yield window.fetch(lwRespUrl, { credentials: "same-origin" });
|
|
976
1126
|
} catch (e) {
|
|
@@ -1018,14 +1168,14 @@ function generateUrl(path, query) {
|
|
|
1018
1168
|
return path + urlParams;
|
|
1019
1169
|
}
|
|
1020
1170
|
function request(path, options, cacheEngine) {
|
|
1021
|
-
return __async$
|
|
1022
|
-
var _b;
|
|
1171
|
+
return __async$3(this, null, function* () {
|
|
1172
|
+
var _b, _c;
|
|
1023
1173
|
const defaults = {
|
|
1024
1174
|
method: "GET",
|
|
1025
1175
|
credentials: "same-origin",
|
|
1026
1176
|
headers: {}
|
|
1027
1177
|
};
|
|
1028
|
-
const _a = __spreadValues$
|
|
1178
|
+
const _a = __spreadValues$3(__spreadValues$3({}, defaults), options), {
|
|
1029
1179
|
withCredentials,
|
|
1030
1180
|
responseType,
|
|
1031
1181
|
cacheProps,
|
|
@@ -1044,6 +1194,7 @@ function request(path, options, cacheEngine) {
|
|
|
1044
1194
|
"query",
|
|
1045
1195
|
"json"
|
|
1046
1196
|
]);
|
|
1197
|
+
opt.method = (_b = opt.method) == null ? void 0 : _b.toUpperCase();
|
|
1047
1198
|
if (withCredentials) {
|
|
1048
1199
|
opt.credentials = "include";
|
|
1049
1200
|
}
|
|
@@ -1061,12 +1212,12 @@ function request(path, options, cacheEngine) {
|
|
|
1061
1212
|
opt.headers = headers;
|
|
1062
1213
|
}
|
|
1063
1214
|
const url = generateUrl(path, query);
|
|
1064
|
-
const makeRequest = () => __async$
|
|
1215
|
+
const makeRequest = () => __async$3(null, null, function* () {
|
|
1065
1216
|
let response;
|
|
1066
1217
|
try {
|
|
1067
1218
|
response = yield fetch(url, opt);
|
|
1068
1219
|
} catch (e) {
|
|
1069
|
-
if (
|
|
1220
|
+
if (opt.signal && opt.signal.aborted) {
|
|
1070
1221
|
throw e;
|
|
1071
1222
|
}
|
|
1072
1223
|
throw new NetworksResponseError();
|
|
@@ -1101,49 +1252,61 @@ function request(path, options, cacheEngine) {
|
|
|
1101
1252
|
}
|
|
1102
1253
|
return body;
|
|
1103
1254
|
});
|
|
1104
|
-
if (cacheEngine
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1255
|
+
if (cacheEngine) {
|
|
1256
|
+
if (((_c = opt.method) == null ? void 0 : _c.toUpperCase()) === "GET") {
|
|
1257
|
+
if (cache !== false) {
|
|
1258
|
+
const props = cacheProps ? cacheProps : __spreadValues$3({}, objectRemoveEmpty({
|
|
1259
|
+
withCredentials,
|
|
1260
|
+
responseType
|
|
1261
|
+
}));
|
|
1262
|
+
return cacheEngine.add(cacheName || url, makeRequest, {
|
|
1263
|
+
props,
|
|
1264
|
+
expirationTime: cache ? void 0 : 500
|
|
1265
|
+
});
|
|
1266
|
+
}
|
|
1267
|
+
} else {
|
|
1268
|
+
const ignoredForClean = ["api/feature_layer/identify"];
|
|
1269
|
+
if (ignoredForClean.every((part) => !path.includes(part))) {
|
|
1270
|
+
cacheEngine.clean();
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1110
1273
|
}
|
|
1111
1274
|
return makeRequest();
|
|
1112
1275
|
});
|
|
1113
1276
|
}
|
|
1114
1277
|
|
|
1115
|
-
var __defProp$
|
|
1116
|
-
var __defProps$
|
|
1117
|
-
var __getOwnPropDescs$
|
|
1118
|
-
var __getOwnPropSymbols$
|
|
1119
|
-
var __hasOwnProp$
|
|
1120
|
-
var __propIsEnum$
|
|
1121
|
-
var __defNormalProp$
|
|
1122
|
-
var __spreadValues$
|
|
1278
|
+
var __defProp$3 = Object.defineProperty;
|
|
1279
|
+
var __defProps$2 = Object.defineProperties;
|
|
1280
|
+
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
1281
|
+
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
1282
|
+
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
1283
|
+
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
1284
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1285
|
+
var __spreadValues$2 = (a, b) => {
|
|
1123
1286
|
for (var prop in b || (b = {}))
|
|
1124
|
-
if (__hasOwnProp$
|
|
1125
|
-
__defNormalProp$
|
|
1126
|
-
if (__getOwnPropSymbols$
|
|
1127
|
-
for (var prop of __getOwnPropSymbols$
|
|
1128
|
-
if (__propIsEnum$
|
|
1129
|
-
__defNormalProp$
|
|
1287
|
+
if (__hasOwnProp$2.call(b, prop))
|
|
1288
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
1289
|
+
if (__getOwnPropSymbols$2)
|
|
1290
|
+
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
1291
|
+
if (__propIsEnum$2.call(b, prop))
|
|
1292
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
1130
1293
|
}
|
|
1131
1294
|
return a;
|
|
1132
1295
|
};
|
|
1133
|
-
var __spreadProps$
|
|
1296
|
+
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
|
1134
1297
|
var __objRest$1 = (source, exclude) => {
|
|
1135
1298
|
var target = {};
|
|
1136
1299
|
for (var prop in source)
|
|
1137
|
-
if (__hasOwnProp$
|
|
1300
|
+
if (__hasOwnProp$2.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
1138
1301
|
target[prop] = source[prop];
|
|
1139
|
-
if (source != null && __getOwnPropSymbols$
|
|
1140
|
-
for (var prop of __getOwnPropSymbols$
|
|
1141
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
1302
|
+
if (source != null && __getOwnPropSymbols$2)
|
|
1303
|
+
for (var prop of __getOwnPropSymbols$2(source)) {
|
|
1304
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$2.call(source, prop))
|
|
1142
1305
|
target[prop] = source[prop];
|
|
1143
1306
|
}
|
|
1144
1307
|
return target;
|
|
1145
1308
|
};
|
|
1146
|
-
var __async$
|
|
1309
|
+
var __async$2 = (__this, __arguments, generator) => {
|
|
1147
1310
|
return new Promise((resolve, reject) => {
|
|
1148
1311
|
var fulfilled = (value) => {
|
|
1149
1312
|
try {
|
|
@@ -1194,7 +1357,7 @@ function routeURL(name, baseUrl, routeData, ...rest) {
|
|
|
1194
1357
|
}
|
|
1195
1358
|
function route(name, connector, ...rest) {
|
|
1196
1359
|
const result = {
|
|
1197
|
-
url: (opt) => __async$
|
|
1360
|
+
url: (opt) => __async$2(null, null, function* () {
|
|
1198
1361
|
var _a;
|
|
1199
1362
|
const routeData = yield connector.connect();
|
|
1200
1363
|
const template = routeURL(
|
|
@@ -1208,45 +1371,37 @@ function route(name, connector, ...rest) {
|
|
|
1208
1371
|
};
|
|
1209
1372
|
const methods = ["get", "post", "put", "delete", "patch"];
|
|
1210
1373
|
for (const method of methods) {
|
|
1211
|
-
const methodResp = (requestOptions) =>
|
|
1374
|
+
const methodResp = (requestOptions) => {
|
|
1212
1375
|
var _b;
|
|
1213
1376
|
const _a = requestOptions || {}, { headers: optHeaders } = _a, restOpt = __objRest$1(_a, ["headers"]);
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1377
|
+
if ((_b = requestOptions == null ? void 0 : requestOptions.signal) == null ? void 0 : _b.aborted) {
|
|
1378
|
+
throw new AbortError();
|
|
1379
|
+
}
|
|
1380
|
+
return connector.connect().then((routeData) => {
|
|
1381
|
+
var _a2;
|
|
1382
|
+
const template = routeURL(
|
|
1383
|
+
name,
|
|
1384
|
+
(_a2 = connector.options.baseUrl) != null ? _a2 : "",
|
|
1385
|
+
routeData,
|
|
1386
|
+
...rest
|
|
1387
|
+
);
|
|
1388
|
+
const headers = objectRemoveEmpty(__spreadValues$2(__spreadValues$2({}, connector.getAuthorizationHeaders()), optHeaders != null ? optHeaders : {}));
|
|
1389
|
+
return request(
|
|
1390
|
+
template,
|
|
1391
|
+
__spreadProps$2(__spreadValues$2({
|
|
1392
|
+
headers
|
|
1393
|
+
}, restOpt), {
|
|
1394
|
+
method
|
|
1395
|
+
}),
|
|
1396
|
+
connector.cache
|
|
1397
|
+
);
|
|
1398
|
+
});
|
|
1399
|
+
};
|
|
1232
1400
|
result[method] = methodResp;
|
|
1233
1401
|
}
|
|
1234
1402
|
return result;
|
|
1235
1403
|
}
|
|
1236
1404
|
|
|
1237
|
-
var __defProp$4 = Object.defineProperty;
|
|
1238
|
-
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1239
|
-
var __publicField$3 = (obj, key, value) => __defNormalProp$4(obj, key + "" , value);
|
|
1240
|
-
class NetworkError extends Error {
|
|
1241
|
-
constructor(url) {
|
|
1242
|
-
super();
|
|
1243
|
-
__publicField$3(this, "name", "NetworkError");
|
|
1244
|
-
Object.setPrototypeOf(this, NetworkError.prototype);
|
|
1245
|
-
this.message = `Unable to request ${url}.
|
|
1246
|
-
Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`;
|
|
1247
|
-
}
|
|
1248
|
-
}
|
|
1249
|
-
|
|
1250
1405
|
function isObject(val) {
|
|
1251
1406
|
return Object.prototype.toString.call(val) === "[object Object]";
|
|
1252
1407
|
}
|
|
@@ -1263,7 +1418,7 @@ let loadData;
|
|
|
1263
1418
|
const getResponseText = () => {
|
|
1264
1419
|
try {
|
|
1265
1420
|
return JSON.parse(xhr.responseText);
|
|
1266
|
-
} catch (
|
|
1421
|
+
} catch (e) {
|
|
1267
1422
|
return xhr.responseText;
|
|
1268
1423
|
}
|
|
1269
1424
|
};
|
|
@@ -1333,52 +1488,63 @@ let loadData;
|
|
|
1333
1488
|
};
|
|
1334
1489
|
}
|
|
1335
1490
|
|
|
1336
|
-
const
|
|
1337
|
-
function
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1491
|
+
const CONNECTORS = [];
|
|
1492
|
+
function addConnector(connector) {
|
|
1493
|
+
CONNECTORS.push(connector);
|
|
1494
|
+
}
|
|
1495
|
+
function findConnector(options) {
|
|
1496
|
+
return CONNECTORS.find((x) => {
|
|
1497
|
+
if (x.options.baseUrl === options.baseUrl) {
|
|
1498
|
+
if (options.auth) {
|
|
1499
|
+
if (x.options.auth) {
|
|
1500
|
+
return objectDeepEqual(x.options.auth, options.auth);
|
|
1501
|
+
}
|
|
1502
|
+
} else {
|
|
1503
|
+
return true;
|
|
1504
|
+
}
|
|
1344
1505
|
}
|
|
1345
|
-
return value;
|
|
1346
1506
|
});
|
|
1347
1507
|
}
|
|
1508
|
+
function removeConnector(connector) {
|
|
1509
|
+
const index = CONNECTORS.indexOf(connector);
|
|
1510
|
+
if (index !== -1) {
|
|
1511
|
+
CONNECTORS.splice(index, 1);
|
|
1512
|
+
}
|
|
1513
|
+
}
|
|
1348
1514
|
|
|
1349
|
-
var __defProp$
|
|
1350
|
-
var __defProps = Object.defineProperties;
|
|
1351
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
1352
|
-
var __getOwnPropSymbols$
|
|
1353
|
-
var __hasOwnProp$
|
|
1354
|
-
var __propIsEnum$
|
|
1355
|
-
var __defNormalProp$
|
|
1356
|
-
var __spreadValues$
|
|
1515
|
+
var __defProp$2 = Object.defineProperty;
|
|
1516
|
+
var __defProps$1 = Object.defineProperties;
|
|
1517
|
+
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
1518
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
1519
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
1520
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
1521
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1522
|
+
var __spreadValues$1 = (a, b) => {
|
|
1357
1523
|
for (var prop in b || (b = {}))
|
|
1358
|
-
if (__hasOwnProp$
|
|
1359
|
-
__defNormalProp$
|
|
1360
|
-
if (__getOwnPropSymbols$
|
|
1361
|
-
for (var prop of __getOwnPropSymbols$
|
|
1362
|
-
if (__propIsEnum$
|
|
1363
|
-
__defNormalProp$
|
|
1524
|
+
if (__hasOwnProp$1.call(b, prop))
|
|
1525
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
1526
|
+
if (__getOwnPropSymbols$1)
|
|
1527
|
+
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
1528
|
+
if (__propIsEnum$1.call(b, prop))
|
|
1529
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
1364
1530
|
}
|
|
1365
1531
|
return a;
|
|
1366
1532
|
};
|
|
1367
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
1533
|
+
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
1368
1534
|
var __objRest = (source, exclude) => {
|
|
1369
1535
|
var target = {};
|
|
1370
1536
|
for (var prop in source)
|
|
1371
|
-
if (__hasOwnProp$
|
|
1537
|
+
if (__hasOwnProp$1.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
1372
1538
|
target[prop] = source[prop];
|
|
1373
|
-
if (source != null && __getOwnPropSymbols$
|
|
1374
|
-
for (var prop of __getOwnPropSymbols$
|
|
1375
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
1539
|
+
if (source != null && __getOwnPropSymbols$1)
|
|
1540
|
+
for (var prop of __getOwnPropSymbols$1(source)) {
|
|
1541
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$1.call(source, prop))
|
|
1376
1542
|
target[prop] = source[prop];
|
|
1377
1543
|
}
|
|
1378
1544
|
return target;
|
|
1379
1545
|
};
|
|
1380
|
-
var __publicField$2 = (obj, key, value) => __defNormalProp$
|
|
1381
|
-
var __async$
|
|
1546
|
+
var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1547
|
+
var __async$1 = (__this, __arguments, generator) => {
|
|
1382
1548
|
return new Promise((resolve, reject) => {
|
|
1383
1549
|
var fulfilled = (value) => {
|
|
1384
1550
|
try {
|
|
@@ -1408,12 +1574,16 @@ class NgwConnector {
|
|
|
1408
1574
|
__publicField$2(this, "user");
|
|
1409
1575
|
__publicField$2(this, "cache");
|
|
1410
1576
|
__publicField$2(this, "withCredentials");
|
|
1577
|
+
// Dedicated cache for route requests, as these are executed before any other requests.
|
|
1578
|
+
// This cache does not need to be cleared during the session.
|
|
1579
|
+
__publicField$2(this, "routeCache");
|
|
1411
1580
|
__publicField$2(this, "client", `NextGIS-NGW-Connector/${pkg.version}`);
|
|
1412
1581
|
__publicField$2(this, "routeStr", "/api/component/pyramid/route");
|
|
1413
1582
|
__publicField$2(this, "activeRequests", {});
|
|
1414
1583
|
__publicField$2(this, "requestTransform");
|
|
1415
1584
|
const exist = findConnector(options);
|
|
1416
1585
|
this.cache = new Cache({ namespace: options.cacheId });
|
|
1586
|
+
this.routeCache = new Cache({ namespace: "routecache" });
|
|
1417
1587
|
if (exist) {
|
|
1418
1588
|
return exist;
|
|
1419
1589
|
} else {
|
|
@@ -1463,7 +1633,9 @@ class NgwConnector {
|
|
|
1463
1633
|
* ```
|
|
1464
1634
|
*/
|
|
1465
1635
|
connect() {
|
|
1466
|
-
return __async$
|
|
1636
|
+
return __async$1(this, arguments, function* ({
|
|
1637
|
+
signal
|
|
1638
|
+
} = {}) {
|
|
1467
1639
|
const auth = this.options.auth;
|
|
1468
1640
|
if (auth) {
|
|
1469
1641
|
const { login, password } = auth;
|
|
@@ -1472,18 +1644,9 @@ class NgwConnector {
|
|
|
1472
1644
|
}
|
|
1473
1645
|
}
|
|
1474
1646
|
const routeUrl = `${this.routeStr}?client=${this.client}`;
|
|
1475
|
-
return
|
|
1476
|
-
|
|
1477
|
-
{}
|
|
1478
|
-
{
|
|
1479
|
-
cacheName: "route",
|
|
1480
|
-
cache: true,
|
|
1481
|
-
cacheProps: {
|
|
1482
|
-
id: this.id,
|
|
1483
|
-
auth,
|
|
1484
|
-
baseUrl: this.options.baseUrl
|
|
1485
|
-
}
|
|
1486
|
-
}
|
|
1647
|
+
return this.routeCache.add(
|
|
1648
|
+
this.options.baseUrl || String(this.id),
|
|
1649
|
+
() => this.makeQuery(routeUrl, null, { signal, cache: false })
|
|
1487
1650
|
);
|
|
1488
1651
|
});
|
|
1489
1652
|
}
|
|
@@ -1504,18 +1667,19 @@ class NgwConnector {
|
|
|
1504
1667
|
removeConnector(this);
|
|
1505
1668
|
this.options.auth = void 0;
|
|
1506
1669
|
this.user = void 0;
|
|
1670
|
+
this.routeCache.clean();
|
|
1507
1671
|
this.clearCache();
|
|
1508
1672
|
this.emitter.emit("logout");
|
|
1509
1673
|
}
|
|
1510
1674
|
getUserInfo(credentials, options) {
|
|
1511
|
-
return __async$
|
|
1675
|
+
return __async$1(this, null, function* () {
|
|
1512
1676
|
if (this.user && this.user.id) {
|
|
1513
1677
|
return this.user;
|
|
1514
1678
|
}
|
|
1515
1679
|
if (credentials) {
|
|
1516
1680
|
this.options.auth = credentials;
|
|
1517
1681
|
}
|
|
1518
|
-
const options_ = __spreadValues$
|
|
1682
|
+
const options_ = __spreadValues$1({
|
|
1519
1683
|
headers: this.getAuthorizationHeaders(credentials),
|
|
1520
1684
|
cache: true
|
|
1521
1685
|
}, options);
|
|
@@ -1556,7 +1720,7 @@ class NgwConnector {
|
|
|
1556
1720
|
this.activeRequests = {};
|
|
1557
1721
|
}
|
|
1558
1722
|
getActiveApiRequests() {
|
|
1559
|
-
return __spreadValues$
|
|
1723
|
+
return __spreadValues$1({}, this.activeRequests);
|
|
1560
1724
|
}
|
|
1561
1725
|
route(name, ...rest) {
|
|
1562
1726
|
return route(name, this, ...rest);
|
|
@@ -1568,7 +1732,7 @@ class NgwConnector {
|
|
|
1568
1732
|
* @param options - Request options
|
|
1569
1733
|
*/
|
|
1570
1734
|
makeQuery(_0, _1) {
|
|
1571
|
-
return __async$
|
|
1735
|
+
return __async$1(this, arguments, function* (url, params, options = {}) {
|
|
1572
1736
|
var _b;
|
|
1573
1737
|
url = (this.options.baseUrl ? this.options.baseUrl : "") + url;
|
|
1574
1738
|
if (!url) {
|
|
@@ -1579,7 +1743,7 @@ class NgwConnector {
|
|
|
1579
1743
|
url = template(url, restParams);
|
|
1580
1744
|
}
|
|
1581
1745
|
url = encodeURI(fixUrlStr(url));
|
|
1582
|
-
options = __spreadValues$
|
|
1746
|
+
options = __spreadValues$1({ withCredentials: this.withCredentials }, options);
|
|
1583
1747
|
const {
|
|
1584
1748
|
cache,
|
|
1585
1749
|
signal: externalSignal,
|
|
@@ -1601,7 +1765,7 @@ class NgwConnector {
|
|
|
1601
1765
|
});
|
|
1602
1766
|
}
|
|
1603
1767
|
options.signal = internalSignal;
|
|
1604
|
-
const createPromise = () => __async$
|
|
1768
|
+
const createPromise = () => __async$1(this, null, function* () {
|
|
1605
1769
|
const id = REQUEST_ID++;
|
|
1606
1770
|
this.activeRequests[id] = internalAbortController;
|
|
1607
1771
|
try {
|
|
@@ -1610,8 +1774,8 @@ class NgwConnector {
|
|
|
1610
1774
|
this._cleanActiveRequest(id);
|
|
1611
1775
|
}
|
|
1612
1776
|
});
|
|
1613
|
-
if (method === "GET") {
|
|
1614
|
-
const cacheOptions = cacheProps ? cacheProps : __spreadProps(__spreadValues$
|
|
1777
|
+
if (method === "GET" && cache !== false) {
|
|
1778
|
+
const cacheOptions = cacheProps ? cacheProps : __spreadProps$1(__spreadValues$1({}, objectRemoveEmpty({
|
|
1615
1779
|
headers,
|
|
1616
1780
|
withCredentials,
|
|
1617
1781
|
responseType,
|
|
@@ -1634,7 +1798,7 @@ class NgwConnector {
|
|
|
1634
1798
|
var _a;
|
|
1635
1799
|
if (this.user) {
|
|
1636
1800
|
options = options || {};
|
|
1637
|
-
options.headers = __spreadValues$
|
|
1801
|
+
options.headers = __spreadValues$1(__spreadValues$1({}, this.getAuthorizationHeaders()), options.headers);
|
|
1638
1802
|
}
|
|
1639
1803
|
if (this.requestTransform) {
|
|
1640
1804
|
const [transUrl, transOptions] = this.requestTransform(url, options);
|
|
@@ -1665,7 +1829,7 @@ class NgwConnector {
|
|
|
1665
1829
|
});
|
|
1666
1830
|
}
|
|
1667
1831
|
_login(credentials, options) {
|
|
1668
|
-
return __async$
|
|
1832
|
+
return __async$1(this, null, function* () {
|
|
1669
1833
|
try {
|
|
1670
1834
|
const data = yield this.getUserInfo(credentials, options);
|
|
1671
1835
|
this.user = data;
|
|
@@ -1693,10 +1857,7 @@ class NgwConnector {
|
|
|
1693
1857
|
return er;
|
|
1694
1858
|
}
|
|
1695
1859
|
}
|
|
1696
|
-
__publicField$2(NgwConnector, "errors",
|
|
1697
|
-
NgwError,
|
|
1698
|
-
ResourceNotFoundError
|
|
1699
|
-
});
|
|
1860
|
+
__publicField$2(NgwConnector, "errors", errors);
|
|
1700
1861
|
|
|
1701
1862
|
function resourceCompare(res1, res2) {
|
|
1702
1863
|
return objectDeepEqual(res1, res2);
|
|
@@ -1710,7 +1871,10 @@ function resourceToQuery(resource, prefix = "") {
|
|
|
1710
1871
|
if (exclude.indexOf(key) === -1) {
|
|
1711
1872
|
if (isObject(value)) {
|
|
1712
1873
|
if (key === "owner_user") {
|
|
1713
|
-
const children = resourceToQuery(
|
|
1874
|
+
const children = resourceToQuery(
|
|
1875
|
+
value,
|
|
1876
|
+
key
|
|
1877
|
+
);
|
|
1714
1878
|
Object.assign(query, children);
|
|
1715
1879
|
} else if (key === "parent" && "id" in value) {
|
|
1716
1880
|
query.parent_id = value.id;
|
|
@@ -1723,24 +1887,27 @@ function resourceToQuery(resource, prefix = "") {
|
|
|
1723
1887
|
return query;
|
|
1724
1888
|
}
|
|
1725
1889
|
|
|
1726
|
-
var __defProp$
|
|
1727
|
-
var
|
|
1728
|
-
var
|
|
1729
|
-
var
|
|
1730
|
-
var
|
|
1731
|
-
var
|
|
1890
|
+
var __defProp$1 = Object.defineProperty;
|
|
1891
|
+
var __defProps = Object.defineProperties;
|
|
1892
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
1893
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
1894
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
1895
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
1896
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1897
|
+
var __spreadValues = (a, b) => {
|
|
1732
1898
|
for (var prop in b || (b = {}))
|
|
1733
|
-
if (__hasOwnProp
|
|
1734
|
-
__defNormalProp$
|
|
1735
|
-
if (__getOwnPropSymbols
|
|
1736
|
-
for (var prop of __getOwnPropSymbols
|
|
1737
|
-
if (__propIsEnum
|
|
1738
|
-
__defNormalProp$
|
|
1899
|
+
if (__hasOwnProp.call(b, prop))
|
|
1900
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
1901
|
+
if (__getOwnPropSymbols)
|
|
1902
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
1903
|
+
if (__propIsEnum.call(b, prop))
|
|
1904
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
1739
1905
|
}
|
|
1740
1906
|
return a;
|
|
1741
1907
|
};
|
|
1742
|
-
var
|
|
1743
|
-
var
|
|
1908
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
1909
|
+
var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1910
|
+
var __async = (__this, __arguments, generator) => {
|
|
1744
1911
|
return new Promise((resolve, reject) => {
|
|
1745
1912
|
var fulfilled = (value) => {
|
|
1746
1913
|
try {
|
|
@@ -1781,7 +1948,7 @@ class ResourcesControl {
|
|
|
1781
1948
|
* Fetching resource would be cached to speed up next call
|
|
1782
1949
|
*/
|
|
1783
1950
|
getOne(resource, requestOptions) {
|
|
1784
|
-
const opt = __spreadValues
|
|
1951
|
+
const opt = __spreadValues({}, requestOptions);
|
|
1785
1952
|
if (typeof resource === "string") ; else if (typeof resource === "number") ; else if (isObject(resource)) {
|
|
1786
1953
|
if (resource.id !== void 0) {
|
|
1787
1954
|
resource.id;
|
|
@@ -1858,9 +2025,11 @@ class ResourcesControl {
|
|
|
1858
2025
|
} else {
|
|
1859
2026
|
Object.assign(query, resourceToQuery(resource));
|
|
1860
2027
|
}
|
|
1861
|
-
return this.connector.
|
|
1862
|
-
|
|
1863
|
-
|
|
2028
|
+
return this.connector.route("resource.search").get(__spreadProps(__spreadValues({}, requestOptions), {
|
|
2029
|
+
query: __spreadValues({
|
|
2030
|
+
serialization: "full"
|
|
2031
|
+
}, query)
|
|
2032
|
+
})).then((resources) => {
|
|
1864
2033
|
if ((requestOptions == null ? void 0 : requestOptions.cache) && resources) {
|
|
1865
2034
|
for (const x of resources) {
|
|
1866
2035
|
this.cache.add("resource.item", Promise.resolve(x), {
|
|
@@ -1876,7 +2045,8 @@ class ResourcesControl {
|
|
|
1876
2045
|
}
|
|
1877
2046
|
getParent(resource, requestOptions) {
|
|
1878
2047
|
return this.getOne(resource, requestOptions).then((child) => {
|
|
1879
|
-
|
|
2048
|
+
var _a, _b;
|
|
2049
|
+
if ((_b = (_a = child == null ? void 0 : child.resource) == null ? void 0 : _a.parent) == null ? void 0 : _b.id) {
|
|
1880
2050
|
return this.getOne(child.resource.parent.id, requestOptions);
|
|
1881
2051
|
}
|
|
1882
2052
|
return Promise.resolve(void 0);
|
|
@@ -1908,10 +2078,21 @@ class ResourcesControl {
|
|
|
1908
2078
|
}
|
|
1909
2079
|
});
|
|
1910
2080
|
}
|
|
1911
|
-
_getChildrenOf(
|
|
1912
|
-
return this
|
|
1913
|
-
parent
|
|
1914
|
-
|
|
2081
|
+
_getChildrenOf(_0, _1) {
|
|
2082
|
+
return __async(this, arguments, function* (parentDef, requestOptions, _items = []) {
|
|
2083
|
+
let parent = void 0;
|
|
2084
|
+
if (typeof parentDef === "string") {
|
|
2085
|
+
parent = yield this.getId(parentDef, requestOptions);
|
|
2086
|
+
} else if (typeof parentDef === "object") {
|
|
2087
|
+
parent = parentDef.id;
|
|
2088
|
+
} else {
|
|
2089
|
+
parent = parentDef;
|
|
2090
|
+
}
|
|
2091
|
+
const items = yield this.connector.route("resource.collection").get(__spreadProps(__spreadValues({}, requestOptions), {
|
|
2092
|
+
query: {
|
|
2093
|
+
parent
|
|
2094
|
+
}
|
|
2095
|
+
}));
|
|
1915
2096
|
const recursivePromises = [];
|
|
1916
2097
|
for (const item of items) {
|
|
1917
2098
|
if (requestOptions == null ? void 0 : requestOptions.cache) {
|
|
@@ -1935,7 +2116,7 @@ class ResourcesControl {
|
|
|
1935
2116
|
});
|
|
1936
2117
|
}
|
|
1937
2118
|
_cleanResourceItemCache(id) {
|
|
1938
|
-
return __async
|
|
2119
|
+
return __async(this, null, function* () {
|
|
1939
2120
|
var _a;
|
|
1940
2121
|
const all = this.cache.all();
|
|
1941
2122
|
const toDelete = [];
|
|
@@ -1960,7 +2141,7 @@ class ResourcesControl {
|
|
|
1960
2141
|
});
|
|
1961
2142
|
}
|
|
1962
2143
|
_fetchResourceById(id, requestOptions) {
|
|
1963
|
-
return this.connector.
|
|
2144
|
+
return this.connector.route("resource.item", { id }).get(requestOptions);
|
|
1964
2145
|
}
|
|
1965
2146
|
_fetchResourceBy(resource, requestOptions) {
|
|
1966
2147
|
return this.getMany(resource, requestOptions).then((resources) => {
|
|
@@ -1988,93 +2169,6 @@ class ResourcesControl {
|
|
|
1988
2169
|
}
|
|
1989
2170
|
}
|
|
1990
2171
|
|
|
1991
|
-
var __defProp$1 = Object.defineProperty;
|
|
1992
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
1993
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
1994
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
1995
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1996
|
-
var __spreadValues = (a, b) => {
|
|
1997
|
-
for (var prop in b || (b = {}))
|
|
1998
|
-
if (__hasOwnProp.call(b, prop))
|
|
1999
|
-
__defNormalProp$1(a, prop, b[prop]);
|
|
2000
|
-
if (__getOwnPropSymbols)
|
|
2001
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
2002
|
-
if (__propIsEnum.call(b, prop))
|
|
2003
|
-
__defNormalProp$1(a, prop, b[prop]);
|
|
2004
|
-
}
|
|
2005
|
-
return a;
|
|
2006
|
-
};
|
|
2007
|
-
var __async = (__this, __arguments, generator) => {
|
|
2008
|
-
return new Promise((resolve, reject) => {
|
|
2009
|
-
var fulfilled = (value) => {
|
|
2010
|
-
try {
|
|
2011
|
-
step(generator.next(value));
|
|
2012
|
-
} catch (e) {
|
|
2013
|
-
reject(e);
|
|
2014
|
-
}
|
|
2015
|
-
};
|
|
2016
|
-
var rejected = (value) => {
|
|
2017
|
-
try {
|
|
2018
|
-
step(generator.throw(value));
|
|
2019
|
-
} catch (e) {
|
|
2020
|
-
reject(e);
|
|
2021
|
-
}
|
|
2022
|
-
};
|
|
2023
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
2024
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
2025
|
-
});
|
|
2026
|
-
};
|
|
2027
|
-
function apiRequest(opt) {
|
|
2028
|
-
return __async(this, null, function* () {
|
|
2029
|
-
const { params, name, connector, requestOptions } = opt;
|
|
2030
|
-
const apiItems = yield connector.connect();
|
|
2031
|
-
let apiItem = apiItems && apiItems[name];
|
|
2032
|
-
if (apiItem) {
|
|
2033
|
-
apiItem = [...apiItem];
|
|
2034
|
-
let url = apiItem.shift();
|
|
2035
|
-
if (apiItem.length) {
|
|
2036
|
-
const replaceParams = {};
|
|
2037
|
-
for (let fry = 0; fry < apiItem.length; fry++) {
|
|
2038
|
-
const arg = apiItem[fry];
|
|
2039
|
-
replaceParams[fry] = `{${arg}}`;
|
|
2040
|
-
if (params[arg] === void 0) {
|
|
2041
|
-
throw new Error(`\`${arg}\` URL API argument is not specified`);
|
|
2042
|
-
}
|
|
2043
|
-
}
|
|
2044
|
-
if (url) {
|
|
2045
|
-
url = template(url, replaceParams);
|
|
2046
|
-
}
|
|
2047
|
-
}
|
|
2048
|
-
if (params) {
|
|
2049
|
-
const paramArray = [];
|
|
2050
|
-
const paramList = params.paramList;
|
|
2051
|
-
if (Array.isArray(paramList)) {
|
|
2052
|
-
paramList.forEach(([key, value]) => {
|
|
2053
|
-
paramArray.push(`${key}=${value}`);
|
|
2054
|
-
});
|
|
2055
|
-
}
|
|
2056
|
-
for (const p in params) {
|
|
2057
|
-
if (apiItem.indexOf(p) === -1) {
|
|
2058
|
-
paramArray.push(`${p}=${params[p]}`);
|
|
2059
|
-
}
|
|
2060
|
-
}
|
|
2061
|
-
if (paramArray.length) {
|
|
2062
|
-
url = `${url}?${paramArray.join("&")}`;
|
|
2063
|
-
}
|
|
2064
|
-
}
|
|
2065
|
-
if (url) {
|
|
2066
|
-
return connector.makeQuery(url, params, __spreadValues({
|
|
2067
|
-
cacheName: name
|
|
2068
|
-
}, requestOptions));
|
|
2069
|
-
} else {
|
|
2070
|
-
throw new Error("Request URL is not set");
|
|
2071
|
-
}
|
|
2072
|
-
} else {
|
|
2073
|
-
return void 0;
|
|
2074
|
-
}
|
|
2075
|
-
});
|
|
2076
|
-
}
|
|
2077
|
-
|
|
2078
2172
|
var __defProp = Object.defineProperty;
|
|
2079
2173
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2080
2174
|
var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
|