@nextgis/ngw-connector 1.11.8 → 1.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,49 +1,145 @@
1
- /** Bundle of @nextgis/ngw-connector; version: 1.11.8; author: NextGIS */
1
+ /** Bundle of @nextgis/ngw-connector; version: 1.12.1; author: NextGIS */
2
2
  import { EventEmitter } from 'events';
3
3
  import CancelablePromise from '@nextgis/cancelable-promise';
4
4
  import { objectDeepEqual, defined, objectRemoveEmpty, fixUrlStr } from '@nextgis/utils';
5
5
  import Cache from '@nextgis/cache';
6
6
 
7
+ /*! *****************************************************************************
8
+ Copyright (c) Microsoft Corporation.
9
+
10
+ Permission to use, copy, modify, and/or distribute this software for any
11
+ purpose with or without fee is hereby granted.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
14
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
16
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19
+ PERFORMANCE OF THIS SOFTWARE.
20
+ ***************************************************************************** */
21
+ /* global Reflect, Promise */
22
+
23
+ var extendStatics = function(d, b) {
24
+ extendStatics = Object.setPrototypeOf ||
25
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
26
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
27
+ return extendStatics(d, b);
28
+ };
29
+
30
+ function __extends(d, b) {
31
+ if (typeof b !== "function" && b !== null)
32
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
33
+ extendStatics(d, b);
34
+ function __() { this.constructor = d; }
35
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
36
+ }
37
+
38
+ var __assign = function() {
39
+ __assign = Object.assign || function __assign(t) {
40
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
41
+ s = arguments[i];
42
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
43
+ }
44
+ return t;
45
+ };
46
+ return __assign.apply(this, arguments);
47
+ };
48
+
49
+ function __awaiter(thisArg, _arguments, P, generator) {
50
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
51
+ return new (P || (P = Promise))(function (resolve, reject) {
52
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
53
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
54
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
55
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
56
+ });
57
+ }
58
+
59
+ function __generator(thisArg, body) {
60
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
61
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
62
+ function verb(n) { return function (v) { return step([n, v]); }; }
63
+ function step(op) {
64
+ if (f) throw new TypeError("Generator is already executing.");
65
+ while (_) try {
66
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
67
+ if (y = 0, t) op = [op[0] & 2, t.value];
68
+ switch (op[0]) {
69
+ case 0: case 1: t = op; break;
70
+ case 4: _.label++; return { value: op[1], done: false };
71
+ case 5: _.label++; y = op[1]; op = [0]; continue;
72
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
73
+ default:
74
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
75
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
76
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
77
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
78
+ if (t[2]) _.ops.pop();
79
+ _.trys.pop(); continue;
80
+ }
81
+ op = body.call(thisArg, _);
82
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
83
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
84
+ }
85
+ }
86
+
87
+ function __spreadArray(to, from, pack) {
88
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
89
+ if (ar || !(i in from)) {
90
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
91
+ ar[i] = from[i];
92
+ }
93
+ }
94
+ return to.concat(ar || Array.prototype.slice.call(from));
95
+ }
96
+
7
97
  /**
8
98
  * Thrown when...
9
99
  */
10
- class NgwError extends Error {
11
- constructor(er) {
12
- super();
13
- this.name = 'NgwError';
14
- Object.assign(this, er);
15
- Object.setPrototypeOf(this, NgwError.prototype);
100
+ var NgwError = /** @class */ (function (_super) {
101
+ __extends(NgwError, _super);
102
+ function NgwError(er) {
103
+ var _this = _super.call(this) || this;
104
+ _this.name = 'NgwError';
105
+ Object.assign(_this, er);
106
+ Object.setPrototypeOf(_this, NgwError.prototype);
107
+ return _this;
16
108
  }
17
- }
109
+ return NgwError;
110
+ }(Error));
18
111
 
19
112
  /**
20
113
  * Thrown when...
21
114
  */
22
- class NetworkError extends Error {
23
- constructor(url) {
24
- super();
25
- this.name = 'NetworkError';
26
- Object.setPrototypeOf(this, NetworkError.prototype);
27
- this.message = `Unable to request ${url}.
28
- Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`; // /control-panel/cors
115
+ var NetworkError = /** @class */ (function (_super) {
116
+ __extends(NetworkError, _super);
117
+ function NetworkError(url) {
118
+ var _this = _super.call(this) || this;
119
+ _this.name = 'NetworkError';
120
+ Object.setPrototypeOf(_this, NetworkError.prototype);
121
+ _this.message = "Unable to request ".concat(url, ".\n Possibly invalid NGW URL entered or CORS not configured to get request from ").concat(location.origin); // /control-panel/cors
122
+ return _this;
29
123
  }
30
- }
124
+ return NetworkError;
125
+ }(Error));
31
126
 
32
127
  function isObject(val) {
33
128
  return Object.prototype.toString.call(val) === '[object Object]';
34
129
  }
35
130
 
36
- let loadData;
131
+ var loadData;
37
132
  // @ts-ignore
38
133
  {
39
- loadData = (url, callback, options = {}, error, onCancel) => {
134
+ loadData = function (url, callback, options, error, onCancel) {
135
+ if (options === void 0) { options = {}; }
40
136
  options.method = options.method || 'GET';
41
- const xhr = new XMLHttpRequest();
137
+ var xhr = new XMLHttpRequest();
42
138
  xhr.open(options.method || 'GET', url, true); // true for asynchronous
43
139
  if (options.responseType === 'blob') {
44
140
  xhr.responseType = options.responseType;
45
141
  }
46
- const getResponseText = () => {
142
+ var getResponseText = function () {
47
143
  try {
48
144
  return JSON.parse(xhr.responseText);
49
145
  }
@@ -51,8 +147,9 @@ let loadData;
51
147
  return xhr.responseText;
52
148
  }
53
149
  };
54
- const processingResponse = (forError = false) => {
55
- const cb = forError ? error : callback;
150
+ var processingResponse = function (forError) {
151
+ if (forError === void 0) { forError = false; }
152
+ var cb = forError ? error : callback;
56
153
  if (options.responseType === 'blob') {
57
154
  cb(xhr.response);
58
155
  }
@@ -65,7 +162,7 @@ let loadData;
65
162
  }
66
163
  }
67
164
  };
68
- xhr.onload = () => {
165
+ xhr.onload = function () {
69
166
  if ([401, 403, 404, 422, 500].indexOf(xhr.status) !== -1) {
70
167
  error(new NgwError(getResponseText()));
71
168
  }
@@ -87,7 +184,7 @@ let loadData;
87
184
  // error('request error');
88
185
  // }
89
186
  // };
90
- xhr.onerror = (er) => {
187
+ xhr.onerror = function (er) {
91
188
  if (xhr.status === 0) {
92
189
  error(new NetworkError(url));
93
190
  }
@@ -97,17 +194,17 @@ let loadData;
97
194
  };
98
195
  xhr.upload.onprogress = function (e) {
99
196
  if (e.lengthComputable) {
100
- const percentComplete = (e.loaded / e.total) * 100;
197
+ var percentComplete = (e.loaded / e.total) * 100;
101
198
  if (options.onProgress) {
102
199
  options.onProgress(percentComplete, e);
103
200
  }
104
201
  // console.log(percentComplete + '% uploaded');
105
202
  }
106
203
  };
107
- const headers = options.headers;
204
+ var headers = options.headers;
108
205
  if (headers) {
109
- for (const h in headers) {
110
- const header = headers[h];
206
+ for (var h in headers) {
207
+ var header = headers[h];
111
208
  if (typeof header === 'string') {
112
209
  xhr.setRequestHeader(h, header);
113
210
  }
@@ -116,12 +213,12 @@ let loadData;
116
213
  if (options.withCredentials !== undefined) {
117
214
  xhr.withCredentials = options.withCredentials;
118
215
  }
119
- let data;
216
+ var data;
120
217
  if (options.file) {
121
218
  data = new FormData();
122
219
  data.append('file', options.file);
123
220
  if (options.data) {
124
- for (const d in options.data) {
221
+ for (var d in options.data) {
125
222
  data.append(d, data[d]);
126
223
  }
127
224
  }
@@ -134,7 +231,12 @@ let loadData;
134
231
  : null;
135
232
  }
136
233
  if (onCancel) {
137
- onCancel(() => {
234
+ onCancel(function () {
235
+ xhr.abort();
236
+ });
237
+ }
238
+ if (options.signal) {
239
+ options.signal.addEventListener('abort', function () {
138
240
  xhr.abort();
139
241
  });
140
242
  }
@@ -143,10 +245,10 @@ let loadData;
143
245
  }
144
246
 
145
247
  // https://github.com/Leaflet/Leaflet/blob/b507e21c510b53cd704fb8d3f89bb46ea925c8eb/src/core/Util.js#L165
146
- const templateRe = /\{ *([\w_-]+) *\}/g;
248
+ var templateRe = /\{ *([\w_-]+) *\}/g;
147
249
  function template(str, data) {
148
- return str.replace(templateRe, (s, key) => {
149
- let value = data[key];
250
+ return str.replace(templateRe, function (s, key) {
251
+ var value = data[key];
150
252
  if (value === undefined) {
151
253
  throw new Error('No value provided for letiable ' + s);
152
254
  }
@@ -160,33 +262,39 @@ function template(str, data) {
160
262
  /**
161
263
  * Thrown when ...
162
264
  */
163
- class ResourceNotFoundError extends NgwError {
164
- constructor(obj) {
165
- super(obj);
166
- this.name = 'ResourceNotFoundError';
167
- this.exception = 'nextgisweb.resource.exception.ResourceNotFound';
168
- Object.setPrototypeOf(this, ResourceNotFoundError.prototype);
265
+ var ResourceNotFoundError = /** @class */ (function (_super) {
266
+ __extends(ResourceNotFoundError, _super);
267
+ function ResourceNotFoundError(obj) {
268
+ var _this = _super.call(this, obj) || this;
269
+ _this.name = 'ResourceNotFoundError';
270
+ _this.exception = 'nextgisweb.resource.exception.ResourceNotFound';
271
+ Object.setPrototypeOf(_this, ResourceNotFoundError.prototype);
272
+ return _this;
169
273
  }
170
- }
274
+ return ResourceNotFoundError;
275
+ }(NgwError));
171
276
 
172
277
  /**
173
278
  * Thrown when ...
174
279
  */
175
- class InsufficientPermissionsError extends NgwError {
176
- constructor(obj) {
177
- super(obj);
178
- this.name = 'InsufficientPermissionsError';
179
- this.exception = 'nextgisweb.core.exception.InsufficientPermissions';
180
- Object.setPrototypeOf(this, InsufficientPermissionsError.prototype);
280
+ var InsufficientPermissionsError = /** @class */ (function (_super) {
281
+ __extends(InsufficientPermissionsError, _super);
282
+ function InsufficientPermissionsError(obj) {
283
+ var _this = _super.call(this, obj) || this;
284
+ _this.name = 'InsufficientPermissionsError';
285
+ _this.exception = 'nextgisweb.core.exception.InsufficientPermissions';
286
+ Object.setPrototypeOf(_this, InsufficientPermissionsError.prototype);
287
+ return _this;
181
288
  }
182
- }
289
+ return InsufficientPermissionsError;
290
+ }(NgwError));
183
291
 
184
- const CONNECTORS = [];
292
+ var CONNECTORS = [];
185
293
  function addConnector(connector) {
186
294
  CONNECTORS.push(connector);
187
295
  }
188
296
  function findConnector(options) {
189
- return CONNECTORS.find((x) => {
297
+ return CONNECTORS.find(function (x) {
190
298
  if (x.options.baseUrl === options.baseUrl) {
191
299
  if (options.auth) {
192
300
  if (x.options.auth) {
@@ -201,13 +309,13 @@ function findConnector(options) {
201
309
  });
202
310
  }
203
311
  function removeConnector(connector) {
204
- const index = CONNECTORS.indexOf(connector);
312
+ var index = CONNECTORS.indexOf(connector);
205
313
  if (index !== -1) {
206
314
  CONNECTORS.splice(index, 1);
207
315
  }
208
316
  }
209
317
 
210
- const exclude = ['description'];
318
+ var exclude = ['description'];
211
319
  /**
212
320
  * @remarks
213
321
  * https://docs.nextgis.ru/docs_ngweb_dev/doc/developer/resource.html#search-resources
@@ -218,14 +326,16 @@ const exclude = ['description'];
218
326
  *
219
327
  * @param resource - Any property from NGW resource item
220
328
  */
221
- function resourceToQuery(resource, prefix = '') {
329
+ function resourceToQuery(resource, prefix) {
330
+ if (prefix === void 0) { prefix = ''; }
222
331
  prefix = prefix ? prefix + '__' : '';
223
- const query = {};
224
- for (const [key, value] of Object.entries(resource)) {
332
+ var query = {};
333
+ for (var _i = 0, _a = Object.entries(resource); _i < _a.length; _i++) {
334
+ var _b = _a[_i], key = _b[0], value = _b[1];
225
335
  if (exclude.indexOf(key) === -1) {
226
336
  if (isObject(value)) {
227
337
  if (key === 'owner_user') {
228
- const children = resourceToQuery(value, key);
338
+ var children = resourceToQuery(value, key);
229
339
  Object.assign(query, children);
230
340
  }
231
341
  else if (key === 'parent' && 'id' in value) {
@@ -244,8 +354,8 @@ function resourceCompare(res1, res2) {
244
354
  return objectDeepEqual(res1, res2);
245
355
  }
246
356
 
247
- class ResourcesControl {
248
- constructor(connector) {
357
+ var ResourcesControl = /** @class */ (function () {
358
+ function ResourcesControl(connector) {
249
359
  this.connector = connector;
250
360
  this.cache = new Cache();
251
361
  }
@@ -259,10 +369,11 @@ class ResourcesControl {
259
369
  * @remarks
260
370
  * Fetching resource would be cached to speed up next call
261
371
  */
262
- getOne(resource, requestOptions) {
263
- const cache = new Cache();
264
- const forCache = {};
265
- const opt = { ...requestOptions, cache: false };
372
+ ResourcesControl.prototype.getOne = function (resource, requestOptions) {
373
+ var _this = this;
374
+ var cache = new Cache();
375
+ var forCache = {};
376
+ var opt = __assign(__assign({}, requestOptions), { cache: false });
266
377
  if (typeof resource === 'string') {
267
378
  forCache.keyname = resource;
268
379
  }
@@ -270,30 +381,35 @@ class ResourcesControl {
270
381
  forCache.id = resource;
271
382
  }
272
383
  else if (isObject(resource)) {
273
- forCache.id = resource.id;
384
+ if (resource.id !== undefined) {
385
+ forCache.id = resource.id;
386
+ }
387
+ else if (resource.keyname) {
388
+ forCache.keyname = resource.keyname;
389
+ }
274
390
  }
275
- const makeRequest = () => {
391
+ var makeRequest = function () {
276
392
  if (typeof resource === 'string') {
277
- return this._fetchResourceBy({ keyname: resource }, opt);
393
+ return _this._fetchResourceBy({ keyname: resource }, opt);
278
394
  }
279
395
  else if (typeof resource === 'number') {
280
- return this._fetchResourceById(resource, opt);
396
+ return _this._fetchResourceById(resource, opt);
281
397
  }
282
398
  else if (isObject(resource)) {
283
- return this._fetchResourceBy(resource, opt);
399
+ return _this._fetchResourceBy(resource, opt);
284
400
  }
285
401
  return CancelablePromise.resolve(undefined);
286
402
  };
287
403
  return cache.addFull('resource', makeRequest, forCache);
288
- }
289
- getOneOrFail(resource, requestOptions) {
290
- return this.getOne(resource, requestOptions).then((res) => {
404
+ };
405
+ ResourcesControl.prototype.getOneOrFail = function (resource, requestOptions) {
406
+ return this.getOne(resource, requestOptions).then(function (res) {
291
407
  if (res) {
292
408
  return res;
293
409
  }
294
410
  throw new ResourceNotFoundError();
295
411
  });
296
- }
412
+ };
297
413
  /**
298
414
  * A fast way to retrieve resource ID for any resource definition.
299
415
  * @param resource - Any available resource definition
@@ -304,19 +420,19 @@ class ResourcesControl {
304
420
  * then this method will come in handy to facilitate the extraction of the identifier
305
421
  * if the resource is specified through a keyname or other parameters.
306
422
  */
307
- getId(resource, requestOptions) {
423
+ ResourcesControl.prototype.getId = function (resource, requestOptions) {
308
424
  if (typeof resource === 'number') {
309
425
  return CancelablePromise.resolve(resource);
310
426
  }
311
427
  else if (typeof resource === 'string' || isObject(resource)) {
312
- return this.getOne(resource, requestOptions).then((res) => {
428
+ return this.getOne(resource, requestOptions).then(function (res) {
313
429
  if (res) {
314
430
  return res.resource.id;
315
431
  }
316
432
  });
317
433
  }
318
434
  return CancelablePromise.resolve(undefined);
319
- }
435
+ };
320
436
  /**
321
437
  * A fast way to retrieve resource ID for any resource definition.
322
438
  * @param resource - Any available resource definition
@@ -325,33 +441,32 @@ class ResourcesControl {
325
441
  * Similar with {@link NgwConnector.getResourceId | getResourceId} but rise error if resource is not exist.
326
442
  * To not make one more checks if the resource is definitely exists
327
443
  */
328
- getIdOrFail(resource, requestOptions) {
329
- return this.getId(resource, requestOptions).then((resp) => {
444
+ ResourcesControl.prototype.getIdOrFail = function (resource, requestOptions) {
445
+ return this.getId(resource, requestOptions).then(function (resp) {
330
446
  if (resp === undefined) {
331
447
  throw new Error();
332
448
  }
333
449
  return resp;
334
450
  });
335
- }
336
- getMany(resource, requestOptions) {
337
- return this._resourceCacheFilter(resource).then((items) => {
451
+ };
452
+ ResourcesControl.prototype.getMany = function (resource, requestOptions) {
453
+ var _this = this;
454
+ return this._resourceCacheFilter(resource).then(function (items) {
338
455
  if (!items.length) {
339
- const query = {};
456
+ var query = {};
340
457
  if (resource.keyname) {
341
458
  query.keyname = resource.keyname;
342
459
  }
343
460
  else {
344
461
  Object.assign(query, resourceToQuery(resource));
345
462
  }
346
- return this.connector
347
- .get('resource.search', requestOptions, {
348
- serialization: 'full',
349
- ...query,
350
- })
351
- .then((resources) => {
463
+ return _this.connector
464
+ .get('resource.search', requestOptions, __assign({ serialization: 'full' }, query))
465
+ .then(function (resources) {
352
466
  if (resources) {
353
- for (const x of resources) {
354
- this.cache.add('resource.item', CancelablePromise.resolve(x), {
467
+ for (var _i = 0, resources_1 = resources; _i < resources_1.length; _i++) {
468
+ var x = resources_1[_i];
469
+ _this.cache.add('resource.item', CancelablePromise.resolve(x), {
355
470
  id: x.resource.id,
356
471
  });
357
472
  }
@@ -361,97 +476,137 @@ class ResourcesControl {
361
476
  }
362
477
  return items;
363
478
  });
364
- }
365
- getParent(resource, requestOptions) {
366
- return this.getOne(resource, requestOptions).then((child) => {
479
+ };
480
+ ResourcesControl.prototype.getParent = function (resource, requestOptions) {
481
+ var _this = this;
482
+ return this.getOne(resource, requestOptions).then(function (child) {
367
483
  if (child) {
368
- return this.getOne(child.resource.parent.id, requestOptions);
484
+ return _this.getOne(child.resource.parent.id, requestOptions);
369
485
  }
370
486
  return CancelablePromise.resolve(undefined);
371
487
  });
372
- }
373
- getChildrenOf(resource, requestOptions) {
374
- return this.getId(resource).then((parent) => {
375
- return this.connector
376
- .get('resource.collection', { cache: true, ...requestOptions }, {
377
- parent,
378
- })
379
- .then((items) => {
380
- for (const i of items) {
381
- this.cache.add('resource.item', CancelablePromise.resolve(i), {
382
- id: i.resource.id,
383
- });
488
+ };
489
+ ResourcesControl.prototype.getChildrenOf = function (resource, requestOptions) {
490
+ var _this = this;
491
+ return this.getIdOrFail(resource).then(function (parent) {
492
+ return _this._getChildrenOf(parent, requestOptions);
493
+ });
494
+ };
495
+ ResourcesControl.prototype._getChildrenOf = function (parent, requestOptions, _items) {
496
+ var _this = this;
497
+ if (_items === void 0) { _items = []; }
498
+ return this.connector
499
+ .get('resource.collection', __assign({ cache: true }, requestOptions), {
500
+ parent: parent,
501
+ })
502
+ .then(function (items) {
503
+ var recursivePromises = [];
504
+ for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
505
+ var item = items_1[_i];
506
+ _this.cache.add('resource.item', CancelablePromise.resolve(item), {
507
+ id: item.resource.id,
508
+ });
509
+ _items.push(item);
510
+ if ((requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.recursive) && item.resource.children) {
511
+ recursivePromises.push(_this._getChildrenOf(item.resource.id, requestOptions, _items));
384
512
  }
385
- return items;
386
- });
513
+ }
514
+ if (recursivePromises.length) {
515
+ return CancelablePromise.all(recursivePromises).then(function () {
516
+ return _items;
517
+ });
518
+ }
519
+ return _items;
387
520
  });
388
- }
389
- update(resource, data) {
390
- return this.getId(resource).then((id) => {
521
+ };
522
+ ResourcesControl.prototype.update = function (resource, data) {
523
+ var _this = this;
524
+ return this.getId(resource).then(function (id) {
391
525
  if (id !== undefined) {
392
- return this.connector.put('resource.item', { data }, { id });
526
+ return _this.connector.put('resource.item', { data: data }, { id: id });
393
527
  }
394
528
  });
395
- }
529
+ };
396
530
  /**
397
531
  * Fast way to delete resource from NGW and clean cache.
398
532
  * @param resource - Resource definition
399
533
  */
400
- delete(resource) {
401
- return this.getId(resource).then((id) => {
534
+ ResourcesControl.prototype.delete = function (resource) {
535
+ var _this = this;
536
+ return this.getId(resource).then(function (id) {
402
537
  if (id !== undefined) {
403
- return this.connector.delete('resource.item', null, { id }).then(() => {
404
- this._cleanResourceItemCache(id);
538
+ return _this.connector.delete('resource.item', null, { id: id }).then(function () {
539
+ _this._cleanResourceItemCache(id);
405
540
  return undefined;
406
541
  });
407
542
  }
408
543
  });
409
- }
410
- async _cleanResourceItemCache(id) {
411
- const all = this.cache.all();
412
- const toDelete = [];
413
- for (const c of all) {
414
- const cid = c.options && c.options.id;
415
- if (['resource.item', 'resource'].includes(c.key) && cid !== undefined) {
416
- if (typeof cid === 'number') {
417
- if (cid === id) {
418
- toDelete.push(c);
419
- }
420
- }
421
- else {
422
- const rid = await this.getId(cid);
423
- if (rid === id) {
424
- toDelete.push(c);
425
- }
544
+ };
545
+ ResourcesControl.prototype._cleanResourceItemCache = function (id) {
546
+ return __awaiter(this, void 0, void 0, function () {
547
+ var all, toDelete, _i, all_1, c, cid, rid, _a, toDelete_1, d;
548
+ return __generator(this, function (_b) {
549
+ switch (_b.label) {
550
+ case 0:
551
+ all = this.cache.all();
552
+ toDelete = [];
553
+ _i = 0, all_1 = all;
554
+ _b.label = 1;
555
+ case 1:
556
+ if (!(_i < all_1.length)) return [3 /*break*/, 5];
557
+ c = all_1[_i];
558
+ cid = c.options && c.options.id;
559
+ if (!(['resource.item', 'resource'].includes(c.key) && cid !== undefined)) return [3 /*break*/, 4];
560
+ if (!(typeof cid === 'number')) return [3 /*break*/, 2];
561
+ if (cid === id) {
562
+ toDelete.push(c);
563
+ }
564
+ return [3 /*break*/, 4];
565
+ case 2: return [4 /*yield*/, this.getId(cid)];
566
+ case 3:
567
+ rid = _b.sent();
568
+ if (rid === id) {
569
+ toDelete.push(c);
570
+ }
571
+ _b.label = 4;
572
+ case 4:
573
+ _i++;
574
+ return [3 /*break*/, 1];
575
+ case 5:
576
+ for (_a = 0, toDelete_1 = toDelete; _a < toDelete_1.length; _a++) {
577
+ d = toDelete_1[_a];
578
+ this.cache.delete(d);
579
+ }
580
+ return [2 /*return*/];
426
581
  }
427
- }
428
- }
429
- for (const d of toDelete) {
430
- this.cache.delete(d);
431
- }
432
- }
433
- _fetchResourceById(id, requestOptions) {
434
- const promise = () => this.connector.get('resource.item', requestOptions, { id });
582
+ });
583
+ });
584
+ };
585
+ ResourcesControl.prototype._fetchResourceById = function (id, requestOptions) {
586
+ var _this = this;
587
+ var promise = function () {
588
+ return _this.connector.get('resource.item', requestOptions, { id: id });
589
+ };
435
590
  return this.cache
436
591
  .add('resource.item', promise, {
437
- id,
592
+ id: id,
438
593
  })
439
- .catch((er) => {
594
+ .catch(function (er) {
440
595
  if (!(er instanceof ResourceNotFoundError)) {
441
596
  throw er;
442
597
  }
443
598
  return undefined;
444
599
  });
445
- }
446
- _fetchResourceBy(resource, requestOptions) {
447
- return this.getMany(resource, requestOptions).then((resources) => {
600
+ };
601
+ ResourcesControl.prototype._fetchResourceBy = function (resource, requestOptions) {
602
+ return this.getMany(resource, requestOptions).then(function (resources) {
448
603
  return resources[0];
449
604
  });
450
- }
451
- _resourceCacheFilter(resource) {
452
- return CancelablePromise.all(this.cache.matchAll('resource.item')).then((resources) => {
453
- const items = [];
454
- resources.filter((x) => {
605
+ };
606
+ ResourcesControl.prototype._resourceCacheFilter = function (resource) {
607
+ return CancelablePromise.all(this.cache.matchAll('resource.item')).then(function (resources) {
608
+ var items = [];
609
+ resources.filter(function (x) {
455
610
  if (x) {
456
611
  // identical by uniq props
457
612
  if (resource.keyname && x.resource.keyname) {
@@ -465,23 +620,24 @@ class ResourcesControl {
465
620
  });
466
621
  return items;
467
622
  });
468
- }
469
- }
623
+ };
624
+ return ResourcesControl;
625
+ }());
470
626
 
471
627
  function apiRequest(opt) {
472
- const params = opt.params;
473
- return new CancelablePromise((resolve, reject) => {
628
+ var params = opt.params;
629
+ return new CancelablePromise(function (resolve, reject) {
474
630
  opt.connector
475
631
  .connect()
476
- .then((apiItems) => {
477
- let apiItem = apiItems && apiItems[opt.name];
632
+ .then(function (apiItems) {
633
+ var apiItem = apiItems && apiItems[opt.name];
478
634
  if (apiItem) {
479
- apiItem = [...apiItem];
480
- let url = apiItem.shift();
635
+ apiItem = __spreadArray([], apiItem, true);
636
+ var url = apiItem.shift();
481
637
  if (apiItem.length) {
482
- const replaceParams = {};
483
- for (let fry = 0; fry < apiItem.length; fry++) {
484
- const arg = apiItem[fry];
638
+ var replaceParams = {};
639
+ for (var fry = 0; fry < apiItem.length; fry++) {
640
+ var arg = apiItem[fry];
485
641
  replaceParams[fry] = '{' + arg + '}';
486
642
  if (params[arg] === undefined) {
487
643
  throw new Error('`' + arg + '`' + ' url api argument is not specified');
@@ -493,21 +649,21 @@ function apiRequest(opt) {
493
649
  }
494
650
  // Transfer part of the parameters from `params` to the URL string
495
651
  if (params) {
496
- const paramArray = [];
497
- const paramList = params.paramList;
652
+ var paramArray_1 = [];
653
+ var paramList = params.paramList;
498
654
  if (Array.isArray(paramList)) {
499
655
  delete params.paramList;
500
- paramList.forEach((x) => {
501
- paramArray.push(`${x[0]}=${x[1]}`);
656
+ paramList.forEach(function (x) {
657
+ paramArray_1.push("".concat(x[0], "=").concat(x[1]));
502
658
  });
503
659
  }
504
- for (const p in params) {
660
+ for (var p in params) {
505
661
  if (apiItem.indexOf(p) === -1) {
506
- paramArray.push(`${p}=${params[p]}`);
662
+ paramArray_1.push("".concat(p, "=").concat(params[p]));
507
663
  }
508
664
  }
509
- if (paramArray.length) {
510
- url = url + '?' + paramArray.join('&');
665
+ if (paramArray_1.length) {
666
+ url = url + '?' + paramArray_1.join('&');
511
667
  }
512
668
  }
513
669
  if (url) {
@@ -521,20 +677,20 @@ function apiRequest(opt) {
521
677
  resolve(undefined);
522
678
  }
523
679
  })
524
- .catch((er) => {
680
+ .catch(function (er) {
525
681
  reject(er);
526
682
  });
527
683
  });
528
684
  }
529
685
 
530
- let ID = 0;
531
- class NgwConnector$1 {
532
- constructor(options) {
686
+ var ID = 0;
687
+ var NgwConnector$1 = /** @class */ (function () {
688
+ function NgwConnector(options) {
533
689
  this.options = options;
534
690
  this.id = ID++;
535
691
  this.emitter = new EventEmitter();
536
692
  this.routeStr = '/api/component/pyramid/route';
537
- const exist = findConnector(options);
693
+ var exist = findConnector(options);
538
694
  if (exist) {
539
695
  return exist;
540
696
  }
@@ -546,19 +702,19 @@ class NgwConnector$1 {
546
702
  addConnector(this);
547
703
  }
548
704
  }
549
- static create(options) {
705
+ NgwConnector.create = function (options) {
550
706
  return new this(options);
551
- }
707
+ };
552
708
  /**
553
709
  * Fast way to specify the connection address to NextGIS Web.
554
710
  * The current connection will be severed.
555
711
  * @param baseUrl - NGW url
556
712
  */
557
- setNgw(baseUrl) {
713
+ NgwConnector.prototype.setNgw = function (baseUrl) {
558
714
  this.logout();
559
715
  this.options.baseUrl = baseUrl;
560
716
  addConnector(this);
561
- }
717
+ };
562
718
  /**
563
719
  * Establishing a connection with NextGIS Web to fulfill all other requests.
564
720
  * @remarks
@@ -572,101 +728,105 @@ class NgwConnector$1 {
572
728
  * .catch((er) => console.log('Connection problem', er));
573
729
  * ```
574
730
  */
575
- connect() {
576
- const cache = new Cache();
577
- const auth = this.options.auth;
578
- const makeConnect = () => new CancelablePromise((resolve, reject) => {
579
- const makeQuery = () => {
580
- return this.makeQuery(this.routeStr, {}, {})
581
- .then((route) => {
582
- resolve(route);
583
- })
584
- .catch((er) => {
585
- reject(er);
586
- });
587
- };
588
- if (auth) {
589
- const { login, password } = auth;
590
- if (login && password) {
591
- return this.getUserInfo({ login, password })
592
- .then(() => {
593
- makeQuery();
731
+ NgwConnector.prototype.connect = function () {
732
+ var _this = this;
733
+ var cache = new Cache();
734
+ var auth = this.options.auth;
735
+ var makeConnect = function () {
736
+ return new CancelablePromise(function (resolve, reject) {
737
+ var makeQuery = function () {
738
+ return _this.makeQuery(_this.routeStr, {}, {})
739
+ .then(function (route) {
740
+ resolve(route);
594
741
  })
595
- .catch((er) => reject(er));
742
+ .catch(function (er) {
743
+ reject(er);
744
+ });
745
+ };
746
+ if (auth) {
747
+ var login = auth.login, password = auth.password;
748
+ if (login && password) {
749
+ return _this.getUserInfo({ login: login, password: password })
750
+ .then(function () {
751
+ makeQuery();
752
+ })
753
+ .catch(function (er) { return reject(er); });
754
+ }
596
755
  }
597
- }
598
- return makeQuery();
599
- });
756
+ return makeQuery();
757
+ });
758
+ };
600
759
  return cache.add('route', makeConnect, {
601
760
  id: this.id,
602
- auth,
761
+ auth: auth,
603
762
  baseUrl: this.options.baseUrl,
604
763
  });
605
- }
764
+ };
606
765
  /**
607
766
  * Quick way to change NextGIS Web user.
608
767
  * @param credentials - New user credentials
609
768
  */
610
- login(credentials) {
769
+ NgwConnector.prototype.login = function (credentials) {
611
770
  this.logout();
612
771
  addConnector(this);
613
772
  return this.getUserInfo(credentials);
614
- }
773
+ };
615
774
  /**
616
775
  * Disconnecting a user. Aborting all current requests
617
776
  */
618
- logout() {
777
+ NgwConnector.prototype.logout = function () {
619
778
  removeConnector(this);
620
779
  this.options.auth = undefined;
621
780
  this.user = undefined;
622
781
  this.emitter.emit('logout');
623
782
  this.resources.cache.clean();
624
- }
625
- getUserInfo(credentials) {
783
+ };
784
+ NgwConnector.prototype.getUserInfo = function (credentials) {
785
+ var _this = this;
626
786
  if (this.user && this.user.id) {
627
787
  return CancelablePromise.resolve(this.user);
628
788
  }
629
789
  if (credentials) {
630
790
  this.options.auth = credentials;
631
791
  }
632
- const options = {
792
+ var options = {
633
793
  headers: this.getAuthorizationHeaders(credentials),
634
794
  // withCredentials: true
635
795
  };
636
796
  // Do not use apiRequest('auth.current_user') to avoid circular-references
637
797
  return this.makeQuery('/api/component/auth/current_user', {}, options)
638
- .then((data) => {
639
- this.user = data;
640
- this.emitter.emit('login', data);
798
+ .then(function (data) {
799
+ _this.user = data;
800
+ _this.emitter.emit('login', data);
641
801
  return data;
642
802
  })
643
- .catch((er) => {
644
- this.emitter.emit('login:error', er);
803
+ .catch(function (er) {
804
+ _this.emitter.emit('login:error', er);
645
805
  throw er;
646
806
  });
647
- }
807
+ };
648
808
  /**
649
809
  * Obtaining the required Headers for authentication of requests in the NGW.
650
810
  */
651
- getAuthorizationHeaders(credentials) {
652
- const client = this.makeClientId(credentials);
811
+ NgwConnector.prototype.getAuthorizationHeaders = function (credentials) {
812
+ var client = this.makeClientId(credentials);
653
813
  if (client) {
654
814
  return {
655
815
  Authorization: 'Basic ' + client,
656
816
  };
657
817
  }
658
- }
659
- makeClientId(credentials) {
818
+ };
819
+ NgwConnector.prototype.makeClientId = function (credentials) {
660
820
  credentials = credentials || this.options.auth;
661
821
  if (credentials) {
662
- const { login, password } = credentials;
663
- const str = unescape(encodeURIComponent(`${login}:${password}`));
822
+ var login = credentials.login, password = credentials.password;
823
+ var str = unescape(encodeURIComponent("".concat(login, ":").concat(password)));
664
824
  // @ts-ignore
665
825
  {
666
826
  return window.btoa(str);
667
827
  }
668
828
  }
669
- }
829
+ };
670
830
  /**
671
831
  * Send request to NGW api router.
672
832
  * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
@@ -696,25 +856,27 @@ class NgwConnector$1 {
696
856
  *
697
857
  * ```
698
858
  */
699
- apiRequest(name, params_ = {}, requestOptions = {}) {
700
- const { method, headers, withCredentials, responseType } = requestOptions;
701
- const params = objectRemoveEmpty(params_);
702
- const makeApiRequest = () => apiRequest({ name, params, requestOptions, connector: this });
859
+ NgwConnector.prototype.apiRequest = function (name, params_, requestOptions) {
860
+ var _this = this;
861
+ if (params_ === void 0) { params_ = {}; }
862
+ if (requestOptions === void 0) { requestOptions = {}; }
863
+ var method = requestOptions.method, headers = requestOptions.headers, withCredentials = requestOptions.withCredentials, responseType = requestOptions.responseType;
864
+ var params = objectRemoveEmpty(params_);
865
+ var makeApiRequest = function () {
866
+ return apiRequest({ name: name, params: params, requestOptions: requestOptions, connector: _this });
867
+ };
703
868
  if (requestOptions.cache && method === 'GET') {
704
- const cache = new Cache();
705
- return cache.add(name, makeApiRequest, {
706
- params,
707
- ...objectRemoveEmpty({
708
- headers,
709
- withCredentials,
710
- responseType,
711
- baseUrl: this.options.baseUrl,
712
- auth: this.options.auth,
713
- }),
714
- });
869
+ var cache = new Cache();
870
+ return cache.add(name, makeApiRequest, __assign({ params: params }, objectRemoveEmpty({
871
+ headers: headers,
872
+ withCredentials: withCredentials,
873
+ responseType: responseType,
874
+ baseUrl: this.options.baseUrl,
875
+ auth: this.options.auth,
876
+ })));
715
877
  }
716
878
  return makeApiRequest();
717
- }
879
+ };
718
880
  /**
719
881
  * Shortcut method for send POST request to NGW.
720
882
  * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
@@ -728,62 +890,63 @@ class NgwConnector$1 {
728
890
  * .catch((error) => console.warn(error));
729
891
  * ```
730
892
  */
731
- post(name, options, params) {
893
+ NgwConnector.prototype.post = function (name, options, params) {
732
894
  options = options || {};
733
895
  options.method = 'POST';
734
896
  return this.apiRequest(name, params, options);
735
- }
897
+ };
736
898
  /**
737
899
  * Shortcut method for send GET request to NGW.
738
900
  * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
739
901
  * @param options - Request options
740
902
  * @param params - Request item params or query params
741
903
  */
742
- get(name, options, params) {
904
+ NgwConnector.prototype.get = function (name, options, params) {
743
905
  options = options || {};
744
906
  options.method = 'GET';
745
907
  return this.apiRequest(name, params, options);
746
- }
908
+ };
747
909
  /**
748
910
  * Shortcut method for send PATCH request to NGW.
749
911
  * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
750
912
  * @param options - Request options
751
913
  * @param params - Request item params or query params
752
914
  */
753
- patch(name, options, params) {
915
+ NgwConnector.prototype.patch = function (name, options, params) {
754
916
  options = options || {};
755
917
  options.method = 'PATCH';
756
918
  return this.apiRequest(name, params, options);
757
- }
919
+ };
758
920
  /**
759
921
  * Shortcut method for send PUT request to NGW.
760
922
  * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
761
923
  * @param options - Request options
762
924
  * @param params - Request item params or query params
763
925
  */
764
- put(name, options, params) {
926
+ NgwConnector.prototype.put = function (name, options, params) {
765
927
  options = options || {};
766
928
  options.method = 'PUT';
767
929
  return this.apiRequest(name, params, options);
768
- }
930
+ };
769
931
  /**
770
932
  * Shortcut method for send DELETE request to NGW.
771
933
  * @param name - NGW route name from {@link https://docs.nextgis.com/docs_ngweb_dev/doc/developer/resource.html#routes | routes}
772
934
  * @param options - Request options
773
935
  * @param params - Request item params or query params
774
936
  */
775
- delete(name, options, params) {
937
+ NgwConnector.prototype.delete = function (name, options, params) {
776
938
  options = options || {};
777
939
  options.method = 'DELETE';
778
940
  return this.apiRequest(name, params, options);
779
- }
941
+ };
780
942
  /**
781
943
  * Send request to NGW.
782
944
  * @param url - URL address to NGW
783
945
  * @param params - Query params
784
946
  * @param options - Request options
785
947
  */
786
- makeQuery(url, params, options = {}) {
948
+ NgwConnector.prototype.makeQuery = function (url, params, options) {
949
+ if (options === void 0) { options = {}; }
787
950
  url = (this.options.baseUrl ? this.options.baseUrl : '') + url;
788
951
  if (url) {
789
952
  if (params) {
@@ -796,112 +959,110 @@ class NgwConnector$1 {
796
959
  else {
797
960
  throw new Error('Empty `url` not allowed');
798
961
  }
799
- }
962
+ };
800
963
  // -------------------------------------------------------------------------
801
964
  // Resource Methods
802
965
  // -------------------------------------------------------------------------
803
966
  /**
804
967
  * {@inheritDoc ResourcesControl.getOne}
805
968
  */
806
- getResource(resource, requestOptions) {
969
+ NgwConnector.prototype.getResource = function (resource, requestOptions) {
807
970
  return this.resources.getOne(resource, requestOptions);
808
- }
971
+ };
809
972
  /**
810
973
  * {@inheritDoc ResourcesControl.getOneOrFail}
811
974
  */
812
- getResourceOrFail(resource, requestOptions) {
975
+ NgwConnector.prototype.getResourceOrFail = function (resource, requestOptions) {
813
976
  return this.resources.getOneOrFail(resource, requestOptions);
814
- }
977
+ };
815
978
  /**
816
979
  * @deprecated - use {@link NgwConnector.getResource}
817
980
  */
818
- getResourceBy(resource) {
981
+ NgwConnector.prototype.getResourceBy = function (resource) {
819
982
  return this.resources.getOne(resource);
820
- }
983
+ };
821
984
  /**
822
985
  * @deprecated - use {@link NgwConnector.getResource}
823
986
  */
824
- getResourceByKeyname(keyname) {
987
+ NgwConnector.prototype.getResourceByKeyname = function (keyname) {
825
988
  return this.resources.getOne(keyname);
826
- }
989
+ };
827
990
  /**
828
991
  * @deprecated - use {@link NgwConnector.getResource}
829
992
  */
830
- getResourceById(id) {
993
+ NgwConnector.prototype.getResourceById = function (id) {
831
994
  return this.resources.getOne(id);
832
- }
995
+ };
833
996
  /**
834
997
  * {@inheritDoc ResourcesControl.getId}
835
998
  */
836
- getResourceId(resource, requestOptions) {
999
+ NgwConnector.prototype.getResourceId = function (resource, requestOptions) {
837
1000
  return this.resources.getId(resource, requestOptions);
838
- }
1001
+ };
839
1002
  /**
840
1003
  * {@inheritDoc ResourcesControl.getIdOrFail}
841
1004
  */
842
- getResourceIdOrFail(resource, requestOptions) {
1005
+ NgwConnector.prototype.getResourceIdOrFail = function (resource, requestOptions) {
843
1006
  return this.resources.getIdOrFail(resource, requestOptions);
844
- }
1007
+ };
845
1008
  /**
846
1009
  * {@inheritDoc ResourcesControl.getMany}
847
1010
  */
848
- getResourcesBy(resource, requestOptions) {
1011
+ NgwConnector.prototype.getResourcesBy = function (resource, requestOptions) {
849
1012
  return this.resources.getMany(resource, requestOptions);
850
- }
1013
+ };
851
1014
  /**
852
1015
  * {@inheritDoc ResourcesControl.getParent}
853
1016
  */
854
- getResourceParent(resource, requestOptions) {
1017
+ NgwConnector.prototype.getResourceParent = function (resource, requestOptions) {
855
1018
  return this.resources.getParent(resource, requestOptions);
856
- }
1019
+ };
857
1020
  /**
858
1021
  * {@inheritDoc ResourcesControl.getChildrenOf}
859
1022
  */
860
- getResourceChildren(resource, requestOptions) {
1023
+ NgwConnector.prototype.getResourceChildren = function (resource, requestOptions) {
861
1024
  return this.resources.getChildrenOf(resource, requestOptions);
862
- }
1025
+ };
863
1026
  /**
864
1027
  * {@inheritDoc ResourcesControl.update}
865
1028
  */
866
- updateResource(resource, data) {
1029
+ NgwConnector.prototype.updateResource = function (resource, data) {
867
1030
  return this.resources.update(resource, data);
868
- }
1031
+ };
869
1032
  /**
870
1033
  * {@inheritDoc ResourcesControl.delete}
871
1034
  */
872
- deleteResource(resource) {
1035
+ NgwConnector.prototype.deleteResource = function (resource) {
873
1036
  return this.resources.delete(resource);
874
- }
1037
+ };
875
1038
  /**
876
1039
  * @internal
877
1040
  */
878
- _loadData(url, options) {
1041
+ NgwConnector.prototype._loadData = function (url, options) {
1042
+ var _this = this;
879
1043
  options.responseType = options.responseType || 'json';
880
- return new CancelablePromise((resolve, reject, onCancel) => {
881
- if (this.user) {
1044
+ return new CancelablePromise(function (resolve, reject, onCancel) {
1045
+ if (_this.user) {
882
1046
  options = options || {};
883
1047
  // options.withCredentials = true;
884
- options.headers = {
885
- ...this.getAuthorizationHeaders(),
886
- ...options.headers,
887
- };
1048
+ options.headers = __assign(__assign({}, _this.getAuthorizationHeaders()), options.headers);
888
1049
  }
889
1050
  loadData(url, resolve, options, reject, onCancel);
890
- }).catch((httpError) => {
1051
+ }).catch(function (httpError) {
891
1052
  if (httpError instanceof CancelablePromise.CancelError) ;
892
1053
  else {
893
1054
  // @ts-ignore
894
1055
  if ((process.env.NODE_ENV !== 'production')) {
895
1056
  console.warn('DEV WARN', httpError);
896
1057
  }
897
- const er = this._handleHttpError(httpError);
1058
+ var er = _this._handleHttpError(httpError);
898
1059
  if (er) {
899
1060
  throw er;
900
1061
  }
901
1062
  }
902
1063
  });
903
- }
904
- _handleHttpError(er) {
1064
+ };
1065
+ NgwConnector.prototype._handleHttpError = function (er) {
905
1066
  if (er) {
906
1067
  if (er instanceof NgwError) {
907
1068
  if (er.exception === 'nextgisweb.resource.exception.ResourceNotFound') {
@@ -913,12 +1074,13 @@ class NgwConnector$1 {
913
1074
  }
914
1075
  }
915
1076
  return er;
916
- }
917
- }
918
- NgwConnector$1.errors = {
919
- NgwError,
920
- ResourceNotFoundError,
921
- };
1077
+ };
1078
+ NgwConnector.errors = {
1079
+ NgwError: NgwError,
1080
+ ResourceNotFoundError: ResourceNotFoundError,
1081
+ };
1082
+ return NgwConnector;
1083
+ }());
922
1084
 
923
1085
  /**
924
1086
  * A lightweight HTTP client optimized for use with {@link http://docs.nextgis.ru/docs_ngweb_dev/doc/developer/toc.html | NextGIS Web} API