@nextgis/ngw-connector 1.16.1 → 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.
- package/lib/index.d.ts +3 -2
- package/lib/ngw-connector.cjs.js +82 -81
- 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 +82 -81
- 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 +82 -81
- 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 +82 -81
- 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: 1.16.
|
|
1
|
+
/** Bundle of @nextgis/ngw-connector; version: 1.16.2; author: NextGIS */
|
|
2
2
|
/******************************************************************************
|
|
3
3
|
Copyright (c) Microsoft Corporation.
|
|
4
4
|
|
|
@@ -1367,6 +1367,65 @@ function template(str, data) {
|
|
|
1367
1367
|
});
|
|
1368
1368
|
}
|
|
1369
1369
|
|
|
1370
|
+
function apiRequest(opt) {
|
|
1371
|
+
var params = opt.params;
|
|
1372
|
+
return new CancelablePromise(function (resolve, reject) {
|
|
1373
|
+
opt.connector
|
|
1374
|
+
.connect()
|
|
1375
|
+
.then(function (apiItems) {
|
|
1376
|
+
var apiItem = apiItems && apiItems[opt.name];
|
|
1377
|
+
if (apiItem) {
|
|
1378
|
+
apiItem = __spreadArray([], apiItem, true);
|
|
1379
|
+
var url = apiItem.shift();
|
|
1380
|
+
if (apiItem.length) {
|
|
1381
|
+
var replaceParams = {};
|
|
1382
|
+
for (var fry = 0; fry < apiItem.length; fry++) {
|
|
1383
|
+
var arg = apiItem[fry];
|
|
1384
|
+
replaceParams[fry] = '{' + arg + '}';
|
|
1385
|
+
if (params[arg] === undefined) {
|
|
1386
|
+
throw new Error('`' + arg + '`' + ' url api argument is not specified');
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
if (url) {
|
|
1390
|
+
url = template(url, replaceParams);
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
// Transfer part of the parameters from `params` to the URL string
|
|
1394
|
+
if (params) {
|
|
1395
|
+
var paramArray_1 = [];
|
|
1396
|
+
var paramList = params.paramList;
|
|
1397
|
+
if (Array.isArray(paramList)) {
|
|
1398
|
+
delete params.paramList;
|
|
1399
|
+
paramList.forEach(function (x) {
|
|
1400
|
+
paramArray_1.push("".concat(x[0], "=").concat(x[1]));
|
|
1401
|
+
});
|
|
1402
|
+
}
|
|
1403
|
+
for (var p in params) {
|
|
1404
|
+
if (apiItem.indexOf(p) === -1) {
|
|
1405
|
+
paramArray_1.push("".concat(p, "=").concat(params[p]));
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
if (paramArray_1.length) {
|
|
1409
|
+
url = url + '?' + paramArray_1.join('&');
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
if (url) {
|
|
1413
|
+
resolve(opt.connector.makeQuery(url, params, opt.requestOptions));
|
|
1414
|
+
}
|
|
1415
|
+
else {
|
|
1416
|
+
reject(new Error('request url is not set'));
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
else {
|
|
1420
|
+
resolve(undefined);
|
|
1421
|
+
}
|
|
1422
|
+
})
|
|
1423
|
+
.catch(function (er) {
|
|
1424
|
+
reject(er);
|
|
1425
|
+
});
|
|
1426
|
+
});
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1370
1429
|
/**
|
|
1371
1430
|
* Thrown when ...
|
|
1372
1431
|
*/
|
|
@@ -1732,65 +1791,6 @@ var ResourcesControl = /** @class */ (function () {
|
|
|
1732
1791
|
return ResourcesControl;
|
|
1733
1792
|
}());
|
|
1734
1793
|
|
|
1735
|
-
function apiRequest(opt) {
|
|
1736
|
-
var params = opt.params;
|
|
1737
|
-
return new CancelablePromise(function (resolve, reject) {
|
|
1738
|
-
opt.connector
|
|
1739
|
-
.connect()
|
|
1740
|
-
.then(function (apiItems) {
|
|
1741
|
-
var apiItem = apiItems && apiItems[opt.name];
|
|
1742
|
-
if (apiItem) {
|
|
1743
|
-
apiItem = __spreadArray([], apiItem, true);
|
|
1744
|
-
var url = apiItem.shift();
|
|
1745
|
-
if (apiItem.length) {
|
|
1746
|
-
var replaceParams = {};
|
|
1747
|
-
for (var fry = 0; fry < apiItem.length; fry++) {
|
|
1748
|
-
var arg = apiItem[fry];
|
|
1749
|
-
replaceParams[fry] = '{' + arg + '}';
|
|
1750
|
-
if (params[arg] === undefined) {
|
|
1751
|
-
throw new Error('`' + arg + '`' + ' url api argument is not specified');
|
|
1752
|
-
}
|
|
1753
|
-
}
|
|
1754
|
-
if (url) {
|
|
1755
|
-
url = template(url, replaceParams);
|
|
1756
|
-
}
|
|
1757
|
-
}
|
|
1758
|
-
// Transfer part of the parameters from `params` to the URL string
|
|
1759
|
-
if (params) {
|
|
1760
|
-
var paramArray_1 = [];
|
|
1761
|
-
var paramList = params.paramList;
|
|
1762
|
-
if (Array.isArray(paramList)) {
|
|
1763
|
-
delete params.paramList;
|
|
1764
|
-
paramList.forEach(function (x) {
|
|
1765
|
-
paramArray_1.push("".concat(x[0], "=").concat(x[1]));
|
|
1766
|
-
});
|
|
1767
|
-
}
|
|
1768
|
-
for (var p in params) {
|
|
1769
|
-
if (apiItem.indexOf(p) === -1) {
|
|
1770
|
-
paramArray_1.push("".concat(p, "=").concat(params[p]));
|
|
1771
|
-
}
|
|
1772
|
-
}
|
|
1773
|
-
if (paramArray_1.length) {
|
|
1774
|
-
url = url + '?' + paramArray_1.join('&');
|
|
1775
|
-
}
|
|
1776
|
-
}
|
|
1777
|
-
if (url) {
|
|
1778
|
-
resolve(opt.connector.makeQuery(url, params, opt.requestOptions));
|
|
1779
|
-
}
|
|
1780
|
-
else {
|
|
1781
|
-
reject(new Error('request url is not set'));
|
|
1782
|
-
}
|
|
1783
|
-
}
|
|
1784
|
-
else {
|
|
1785
|
-
resolve(undefined);
|
|
1786
|
-
}
|
|
1787
|
-
})
|
|
1788
|
-
.catch(function (er) {
|
|
1789
|
-
reject(er);
|
|
1790
|
-
});
|
|
1791
|
-
});
|
|
1792
|
-
}
|
|
1793
|
-
|
|
1794
1794
|
var ID = 0;
|
|
1795
1795
|
var NgwConnector$1 = /** @class */ (function () {
|
|
1796
1796
|
function NgwConnector(options) {
|
|
@@ -1861,9 +1861,9 @@ var NgwConnector$1 = /** @class */ (function () {
|
|
|
1861
1861
|
if (auth) {
|
|
1862
1862
|
var login = auth.login, password = auth.password;
|
|
1863
1863
|
if (login && password) {
|
|
1864
|
-
return _this.
|
|
1864
|
+
return _this._login({ login: login, password: password })
|
|
1865
1865
|
.then(function () {
|
|
1866
|
-
makeQuery();
|
|
1866
|
+
return makeQuery();
|
|
1867
1867
|
})
|
|
1868
1868
|
.catch(function (er) { return reject(er); });
|
|
1869
1869
|
}
|
|
@@ -1881,10 +1881,10 @@ var NgwConnector$1 = /** @class */ (function () {
|
|
|
1881
1881
|
* Quick way to change NextGIS Web user.
|
|
1882
1882
|
* @param credentials - New user credentials
|
|
1883
1883
|
*/
|
|
1884
|
-
NgwConnector.prototype.login = function (credentials) {
|
|
1884
|
+
NgwConnector.prototype.login = function (credentials, options) {
|
|
1885
1885
|
this.logout();
|
|
1886
1886
|
addConnector(this);
|
|
1887
|
-
return this.
|
|
1887
|
+
return this._login(credentials, options);
|
|
1888
1888
|
};
|
|
1889
1889
|
/**
|
|
1890
1890
|
* Disconnecting a user. Aborting all current requests
|
|
@@ -1897,29 +1897,16 @@ var NgwConnector$1 = /** @class */ (function () {
|
|
|
1897
1897
|
this.emitter.emit('logout');
|
|
1898
1898
|
this.resources.cache.clean();
|
|
1899
1899
|
};
|
|
1900
|
-
NgwConnector.prototype.getUserInfo = function (credentials) {
|
|
1901
|
-
var _this = this;
|
|
1900
|
+
NgwConnector.prototype.getUserInfo = function (credentials, options) {
|
|
1902
1901
|
if (this.user && this.user.id) {
|
|
1903
1902
|
return CancelablePromise.resolve(this.user);
|
|
1904
1903
|
}
|
|
1905
1904
|
if (credentials) {
|
|
1906
1905
|
this.options.auth = credentials;
|
|
1907
1906
|
}
|
|
1908
|
-
var
|
|
1909
|
-
headers: this.getAuthorizationHeaders(credentials),
|
|
1910
|
-
// withCredentials: true
|
|
1911
|
-
};
|
|
1907
|
+
var options_ = __assign({ headers: this.getAuthorizationHeaders(credentials) }, options);
|
|
1912
1908
|
// Do not use apiRequest('auth.current_user') to avoid circular-references
|
|
1913
|
-
return this.makeQuery('/api/component/auth/current_user', {},
|
|
1914
|
-
.then(function (data) {
|
|
1915
|
-
_this.user = data;
|
|
1916
|
-
_this.emitter.emit('login', data);
|
|
1917
|
-
return data;
|
|
1918
|
-
})
|
|
1919
|
-
.catch(function (er) {
|
|
1920
|
-
_this.emitter.emit('login:error', er);
|
|
1921
|
-
throw er;
|
|
1922
|
-
});
|
|
1909
|
+
return this.makeQuery('/api/component/auth/current_user', {}, options_);
|
|
1923
1910
|
};
|
|
1924
1911
|
/**
|
|
1925
1912
|
* Obtaining the required Headers for authentication of requests in the NGW.
|
|
@@ -1985,6 +1972,7 @@ var NgwConnector$1 = /** @class */ (function () {
|
|
|
1985
1972
|
*/
|
|
1986
1973
|
NgwConnector.prototype.apiRequest = function (name, params_, requestOptions) {
|
|
1987
1974
|
var _this = this;
|
|
1975
|
+
var _a;
|
|
1988
1976
|
if (params_ === void 0) { params_ = {}; }
|
|
1989
1977
|
if (requestOptions === void 0) { requestOptions = {}; }
|
|
1990
1978
|
var method = requestOptions.method, headers = requestOptions.headers, withCredentials = requestOptions.withCredentials, responseType = requestOptions.responseType;
|
|
@@ -1999,7 +1987,7 @@ var NgwConnector$1 = /** @class */ (function () {
|
|
|
1999
1987
|
withCredentials: withCredentials,
|
|
2000
1988
|
responseType: responseType,
|
|
2001
1989
|
baseUrl: this.options.baseUrl,
|
|
2002
|
-
|
|
1990
|
+
userId: (_a = this.user) === null || _a === void 0 ? void 0 : _a.id,
|
|
2003
1991
|
})));
|
|
2004
1992
|
}
|
|
2005
1993
|
return makeApiRequest();
|
|
@@ -2208,6 +2196,19 @@ var NgwConnector$1 = /** @class */ (function () {
|
|
|
2208
2196
|
this.activeRequests.push(request);
|
|
2209
2197
|
return request;
|
|
2210
2198
|
};
|
|
2199
|
+
NgwConnector.prototype._login = function (credentials, options) {
|
|
2200
|
+
var _this = this;
|
|
2201
|
+
return this.getUserInfo(credentials, options)
|
|
2202
|
+
.then(function (data) {
|
|
2203
|
+
_this.user = data;
|
|
2204
|
+
_this.emitter.emit('login', data);
|
|
2205
|
+
return data;
|
|
2206
|
+
})
|
|
2207
|
+
.catch(function (er) {
|
|
2208
|
+
_this.emitter.emit('login:error', er);
|
|
2209
|
+
throw er;
|
|
2210
|
+
});
|
|
2211
|
+
};
|
|
2211
2212
|
NgwConnector.prototype._cleanActiveRequests = function (request) {
|
|
2212
2213
|
var activeRequestIndex = this.activeRequests.indexOf(request);
|
|
2213
2214
|
if (activeRequestIndex !== -1) {
|