@nextgis/geocoder 1.16.1 → 1.16.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/geocoder; version: 1.16.1; author: NextGIS */
1
+ /** Bundle of @nextgis/geocoder; version: 1.16.5; author: NextGIS */
2
2
  'use strict';
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
@@ -1,4 +1,4 @@
1
- /** Bundle of @nextgis/geocoder; version: 1.16.1; author: NextGIS */
1
+ /** Bundle of @nextgis/geocoder; version: 1.16.5; author: NextGIS */
2
2
  /******************************************************************************
3
3
  Copyright (c) Microsoft Corporation.
4
4
 
@@ -363,8 +363,9 @@ var CancelablePromise$1 = /** @class */ (function () {
363
363
  if (er instanceof _this.CancelError) {
364
364
  for (var _i = 0, values_1 = values; _i < values_1.length; _i++) {
365
365
  var v = values_1[_i];
366
- if ('cancel' in v) {
367
- v.cancel();
366
+ var v_ = v;
367
+ if ('cancel' in v_) {
368
+ v_.cancel();
368
369
  }
369
370
  }
370
371
  }
@@ -1527,6 +1528,65 @@ function template(str, data) {
1527
1528
  });
1528
1529
  }
1529
1530
 
1531
+ function apiRequest(opt) {
1532
+ var params = opt.params;
1533
+ return new CancelablePromise(function (resolve, reject) {
1534
+ opt.connector
1535
+ .connect()
1536
+ .then(function (apiItems) {
1537
+ var apiItem = apiItems && apiItems[opt.name];
1538
+ if (apiItem) {
1539
+ apiItem = __spreadArray([], apiItem, true);
1540
+ var url = apiItem.shift();
1541
+ if (apiItem.length) {
1542
+ var replaceParams = {};
1543
+ for (var fry = 0; fry < apiItem.length; fry++) {
1544
+ var arg = apiItem[fry];
1545
+ replaceParams[fry] = '{' + arg + '}';
1546
+ if (params[arg] === undefined) {
1547
+ throw new Error('`' + arg + '`' + ' url api argument is not specified');
1548
+ }
1549
+ }
1550
+ if (url) {
1551
+ url = template(url, replaceParams);
1552
+ }
1553
+ }
1554
+ // Transfer part of the parameters from `params` to the URL string
1555
+ if (params) {
1556
+ var paramArray_1 = [];
1557
+ var paramList = params.paramList;
1558
+ if (Array.isArray(paramList)) {
1559
+ delete params.paramList;
1560
+ paramList.forEach(function (x) {
1561
+ paramArray_1.push("".concat(x[0], "=").concat(x[1]));
1562
+ });
1563
+ }
1564
+ for (var p in params) {
1565
+ if (apiItem.indexOf(p) === -1) {
1566
+ paramArray_1.push("".concat(p, "=").concat(params[p]));
1567
+ }
1568
+ }
1569
+ if (paramArray_1.length) {
1570
+ url = url + '?' + paramArray_1.join('&');
1571
+ }
1572
+ }
1573
+ if (url) {
1574
+ resolve(opt.connector.makeQuery(url, params, opt.requestOptions));
1575
+ }
1576
+ else {
1577
+ reject(new Error('request url is not set'));
1578
+ }
1579
+ }
1580
+ else {
1581
+ resolve(undefined);
1582
+ }
1583
+ })
1584
+ .catch(function (er) {
1585
+ reject(er);
1586
+ });
1587
+ });
1588
+ }
1589
+
1530
1590
  /**
1531
1591
  * Thrown when ...
1532
1592
  */
@@ -1892,65 +1952,6 @@ var ResourcesControl = /** @class */ (function () {
1892
1952
  return ResourcesControl;
1893
1953
  }());
1894
1954
 
1895
- function apiRequest(opt) {
1896
- var params = opt.params;
1897
- return new CancelablePromise(function (resolve, reject) {
1898
- opt.connector
1899
- .connect()
1900
- .then(function (apiItems) {
1901
- var apiItem = apiItems && apiItems[opt.name];
1902
- if (apiItem) {
1903
- apiItem = __spreadArray([], apiItem, true);
1904
- var url = apiItem.shift();
1905
- if (apiItem.length) {
1906
- var replaceParams = {};
1907
- for (var fry = 0; fry < apiItem.length; fry++) {
1908
- var arg = apiItem[fry];
1909
- replaceParams[fry] = '{' + arg + '}';
1910
- if (params[arg] === undefined) {
1911
- throw new Error('`' + arg + '`' + ' url api argument is not specified');
1912
- }
1913
- }
1914
- if (url) {
1915
- url = template(url, replaceParams);
1916
- }
1917
- }
1918
- // Transfer part of the parameters from `params` to the URL string
1919
- if (params) {
1920
- var paramArray_1 = [];
1921
- var paramList = params.paramList;
1922
- if (Array.isArray(paramList)) {
1923
- delete params.paramList;
1924
- paramList.forEach(function (x) {
1925
- paramArray_1.push("".concat(x[0], "=").concat(x[1]));
1926
- });
1927
- }
1928
- for (var p in params) {
1929
- if (apiItem.indexOf(p) === -1) {
1930
- paramArray_1.push("".concat(p, "=").concat(params[p]));
1931
- }
1932
- }
1933
- if (paramArray_1.length) {
1934
- url = url + '?' + paramArray_1.join('&');
1935
- }
1936
- }
1937
- if (url) {
1938
- resolve(opt.connector.makeQuery(url, params, opt.requestOptions));
1939
- }
1940
- else {
1941
- reject(new Error('request url is not set'));
1942
- }
1943
- }
1944
- else {
1945
- resolve(undefined);
1946
- }
1947
- })
1948
- .catch(function (er) {
1949
- reject(er);
1950
- });
1951
- });
1952
- }
1953
-
1954
1955
  var ID = 0;
1955
1956
  var NgwConnector$1 = /** @class */ (function () {
1956
1957
  function NgwConnector(options) {
@@ -2021,9 +2022,9 @@ var NgwConnector$1 = /** @class */ (function () {
2021
2022
  if (auth) {
2022
2023
  var login = auth.login, password = auth.password;
2023
2024
  if (login && password) {
2024
- return _this.getUserInfo({ login: login, password: password })
2025
+ return _this._login({ login: login, password: password })
2025
2026
  .then(function () {
2026
- makeQuery();
2027
+ return makeQuery();
2027
2028
  })
2028
2029
  .catch(function (er) { return reject(er); });
2029
2030
  }
@@ -2041,10 +2042,10 @@ var NgwConnector$1 = /** @class */ (function () {
2041
2042
  * Quick way to change NextGIS Web user.
2042
2043
  * @param credentials - New user credentials
2043
2044
  */
2044
- NgwConnector.prototype.login = function (credentials) {
2045
+ NgwConnector.prototype.login = function (credentials, options) {
2045
2046
  this.logout();
2046
2047
  addConnector(this);
2047
- return this.getUserInfo(credentials);
2048
+ return this._login(credentials, options);
2048
2049
  };
2049
2050
  /**
2050
2051
  * Disconnecting a user. Aborting all current requests
@@ -2057,29 +2058,16 @@ var NgwConnector$1 = /** @class */ (function () {
2057
2058
  this.emitter.emit('logout');
2058
2059
  this.resources.cache.clean();
2059
2060
  };
2060
- NgwConnector.prototype.getUserInfo = function (credentials) {
2061
- var _this = this;
2061
+ NgwConnector.prototype.getUserInfo = function (credentials, options) {
2062
2062
  if (this.user && this.user.id) {
2063
2063
  return CancelablePromise.resolve(this.user);
2064
2064
  }
2065
2065
  if (credentials) {
2066
2066
  this.options.auth = credentials;
2067
2067
  }
2068
- var options = {
2069
- headers: this.getAuthorizationHeaders(credentials),
2070
- // withCredentials: true
2071
- };
2068
+ var options_ = __assign({ headers: this.getAuthorizationHeaders(credentials) }, options);
2072
2069
  // Do not use apiRequest('auth.current_user') to avoid circular-references
2073
- return this.makeQuery('/api/component/auth/current_user', {}, options)
2074
- .then(function (data) {
2075
- _this.user = data;
2076
- _this.emitter.emit('login', data);
2077
- return data;
2078
- })
2079
- .catch(function (er) {
2080
- _this.emitter.emit('login:error', er);
2081
- throw er;
2082
- });
2070
+ return this.makeQuery('/api/component/auth/current_user', {}, options_);
2083
2071
  };
2084
2072
  /**
2085
2073
  * Obtaining the required Headers for authentication of requests in the NGW.
@@ -2145,6 +2133,7 @@ var NgwConnector$1 = /** @class */ (function () {
2145
2133
  */
2146
2134
  NgwConnector.prototype.apiRequest = function (name, params_, requestOptions) {
2147
2135
  var _this = this;
2136
+ var _a;
2148
2137
  if (params_ === void 0) { params_ = {}; }
2149
2138
  if (requestOptions === void 0) { requestOptions = {}; }
2150
2139
  var method = requestOptions.method, headers = requestOptions.headers, withCredentials = requestOptions.withCredentials, responseType = requestOptions.responseType;
@@ -2159,7 +2148,7 @@ var NgwConnector$1 = /** @class */ (function () {
2159
2148
  withCredentials: withCredentials,
2160
2149
  responseType: responseType,
2161
2150
  baseUrl: this.options.baseUrl,
2162
- auth: this.options.auth,
2151
+ userId: (_a = this.user) === null || _a === void 0 ? void 0 : _a.id,
2163
2152
  })));
2164
2153
  }
2165
2154
  return makeApiRequest();
@@ -2368,6 +2357,19 @@ var NgwConnector$1 = /** @class */ (function () {
2368
2357
  this.activeRequests.push(request);
2369
2358
  return request;
2370
2359
  };
2360
+ NgwConnector.prototype._login = function (credentials, options) {
2361
+ var _this = this;
2362
+ return this.getUserInfo(credentials, options)
2363
+ .then(function (data) {
2364
+ _this.user = data;
2365
+ _this.emitter.emit('login', data);
2366
+ return data;
2367
+ })
2368
+ .catch(function (er) {
2369
+ _this.emitter.emit('login:error', er);
2370
+ throw er;
2371
+ });
2372
+ };
2371
2373
  NgwConnector.prototype._cleanActiveRequests = function (request) {
2372
2374
  var activeRequestIndex = this.activeRequests.indexOf(request);
2373
2375
  if (activeRequestIndex !== -1) {