@nextgis/geocoder 1.16.0 → 1.16.2

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.0; author: NextGIS */
1
+ /** Bundle of @nextgis/geocoder; version: 1.16.2; 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.0; author: NextGIS */
1
+ /** Bundle of @nextgis/geocoder; version: 1.16.2; author: NextGIS */
2
2
  /******************************************************************************
3
3
  Copyright (c) Microsoft Corporation.
4
4
 
@@ -1527,6 +1527,65 @@ function template(str, data) {
1527
1527
  });
1528
1528
  }
1529
1529
 
1530
+ function apiRequest(opt) {
1531
+ var params = opt.params;
1532
+ return new CancelablePromise(function (resolve, reject) {
1533
+ opt.connector
1534
+ .connect()
1535
+ .then(function (apiItems) {
1536
+ var apiItem = apiItems && apiItems[opt.name];
1537
+ if (apiItem) {
1538
+ apiItem = __spreadArray([], apiItem, true);
1539
+ var url = apiItem.shift();
1540
+ if (apiItem.length) {
1541
+ var replaceParams = {};
1542
+ for (var fry = 0; fry < apiItem.length; fry++) {
1543
+ var arg = apiItem[fry];
1544
+ replaceParams[fry] = '{' + arg + '}';
1545
+ if (params[arg] === undefined) {
1546
+ throw new Error('`' + arg + '`' + ' url api argument is not specified');
1547
+ }
1548
+ }
1549
+ if (url) {
1550
+ url = template(url, replaceParams);
1551
+ }
1552
+ }
1553
+ // Transfer part of the parameters from `params` to the URL string
1554
+ if (params) {
1555
+ var paramArray_1 = [];
1556
+ var paramList = params.paramList;
1557
+ if (Array.isArray(paramList)) {
1558
+ delete params.paramList;
1559
+ paramList.forEach(function (x) {
1560
+ paramArray_1.push("".concat(x[0], "=").concat(x[1]));
1561
+ });
1562
+ }
1563
+ for (var p in params) {
1564
+ if (apiItem.indexOf(p) === -1) {
1565
+ paramArray_1.push("".concat(p, "=").concat(params[p]));
1566
+ }
1567
+ }
1568
+ if (paramArray_1.length) {
1569
+ url = url + '?' + paramArray_1.join('&');
1570
+ }
1571
+ }
1572
+ if (url) {
1573
+ resolve(opt.connector.makeQuery(url, params, opt.requestOptions));
1574
+ }
1575
+ else {
1576
+ reject(new Error('request url is not set'));
1577
+ }
1578
+ }
1579
+ else {
1580
+ resolve(undefined);
1581
+ }
1582
+ })
1583
+ .catch(function (er) {
1584
+ reject(er);
1585
+ });
1586
+ });
1587
+ }
1588
+
1530
1589
  /**
1531
1590
  * Thrown when ...
1532
1591
  */
@@ -1892,65 +1951,6 @@ var ResourcesControl = /** @class */ (function () {
1892
1951
  return ResourcesControl;
1893
1952
  }());
1894
1953
 
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
1954
  var ID = 0;
1955
1955
  var NgwConnector$1 = /** @class */ (function () {
1956
1956
  function NgwConnector(options) {
@@ -2021,9 +2021,9 @@ var NgwConnector$1 = /** @class */ (function () {
2021
2021
  if (auth) {
2022
2022
  var login = auth.login, password = auth.password;
2023
2023
  if (login && password) {
2024
- return _this.getUserInfo({ login: login, password: password })
2024
+ return _this._login({ login: login, password: password })
2025
2025
  .then(function () {
2026
- makeQuery();
2026
+ return makeQuery();
2027
2027
  })
2028
2028
  .catch(function (er) { return reject(er); });
2029
2029
  }
@@ -2041,10 +2041,10 @@ var NgwConnector$1 = /** @class */ (function () {
2041
2041
  * Quick way to change NextGIS Web user.
2042
2042
  * @param credentials - New user credentials
2043
2043
  */
2044
- NgwConnector.prototype.login = function (credentials) {
2044
+ NgwConnector.prototype.login = function (credentials, options) {
2045
2045
  this.logout();
2046
2046
  addConnector(this);
2047
- return this.getUserInfo(credentials);
2047
+ return this._login(credentials, options);
2048
2048
  };
2049
2049
  /**
2050
2050
  * Disconnecting a user. Aborting all current requests
@@ -2057,29 +2057,16 @@ var NgwConnector$1 = /** @class */ (function () {
2057
2057
  this.emitter.emit('logout');
2058
2058
  this.resources.cache.clean();
2059
2059
  };
2060
- NgwConnector.prototype.getUserInfo = function (credentials) {
2061
- var _this = this;
2060
+ NgwConnector.prototype.getUserInfo = function (credentials, options) {
2062
2061
  if (this.user && this.user.id) {
2063
2062
  return CancelablePromise.resolve(this.user);
2064
2063
  }
2065
2064
  if (credentials) {
2066
2065
  this.options.auth = credentials;
2067
2066
  }
2068
- var options = {
2069
- headers: this.getAuthorizationHeaders(credentials),
2070
- // withCredentials: true
2071
- };
2067
+ var options_ = __assign({ headers: this.getAuthorizationHeaders(credentials) }, options);
2072
2068
  // 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
- });
2069
+ return this.makeQuery('/api/component/auth/current_user', {}, options_);
2083
2070
  };
2084
2071
  /**
2085
2072
  * Obtaining the required Headers for authentication of requests in the NGW.
@@ -2145,6 +2132,7 @@ var NgwConnector$1 = /** @class */ (function () {
2145
2132
  */
2146
2133
  NgwConnector.prototype.apiRequest = function (name, params_, requestOptions) {
2147
2134
  var _this = this;
2135
+ var _a;
2148
2136
  if (params_ === void 0) { params_ = {}; }
2149
2137
  if (requestOptions === void 0) { requestOptions = {}; }
2150
2138
  var method = requestOptions.method, headers = requestOptions.headers, withCredentials = requestOptions.withCredentials, responseType = requestOptions.responseType;
@@ -2159,7 +2147,7 @@ var NgwConnector$1 = /** @class */ (function () {
2159
2147
  withCredentials: withCredentials,
2160
2148
  responseType: responseType,
2161
2149
  baseUrl: this.options.baseUrl,
2162
- auth: this.options.auth,
2150
+ userId: (_a = this.user) === null || _a === void 0 ? void 0 : _a.id,
2163
2151
  })));
2164
2152
  }
2165
2153
  return makeApiRequest();
@@ -2368,6 +2356,19 @@ var NgwConnector$1 = /** @class */ (function () {
2368
2356
  this.activeRequests.push(request);
2369
2357
  return request;
2370
2358
  };
2359
+ NgwConnector.prototype._login = function (credentials, options) {
2360
+ var _this = this;
2361
+ return this.getUserInfo(credentials, options)
2362
+ .then(function (data) {
2363
+ _this.user = data;
2364
+ _this.emitter.emit('login', data);
2365
+ return data;
2366
+ })
2367
+ .catch(function (er) {
2368
+ _this.emitter.emit('login:error', er);
2369
+ throw er;
2370
+ });
2371
+ };
2371
2372
  NgwConnector.prototype._cleanActiveRequests = function (request) {
2372
2373
  var activeRequestIndex = this.activeRequests.indexOf(request);
2373
2374
  if (activeRequestIndex !== -1) {