@nextgis/ngw-connector 3.0.0-alpha.13 → 3.0.0-alpha.16
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 +71 -14
- package/lib/ngw-connector.cjs.js +33 -28
- 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 +31 -26
- 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 +31 -26
- 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 +31 -26
- 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 +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Bundle of @nextgis/ngw-connector; version: 3.0.0-alpha.
|
|
1
|
+
/** Bundle of @nextgis/ngw-connector; version: 3.0.0-alpha.16; author: NextGIS */
|
|
2
2
|
var NgwConnector = (function () {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -776,7 +776,7 @@ var NgwConnector = (function () {
|
|
|
776
776
|
|
|
777
777
|
var pkg = {
|
|
778
778
|
name: "@nextgis/ngw-connector",
|
|
779
|
-
version: "3.0.0-alpha.
|
|
779
|
+
version: "3.0.0-alpha.16",
|
|
780
780
|
_priority: 12,
|
|
781
781
|
description: "A lightweight HTTP client optimized for use with NextGIS Web API",
|
|
782
782
|
main: "index.js",
|
|
@@ -1172,7 +1172,7 @@ var NgwConnector = (function () {
|
|
|
1172
1172
|
}
|
|
1173
1173
|
function request(path, options, cacheEngine) {
|
|
1174
1174
|
return __async$3(this, null, function* () {
|
|
1175
|
-
var _b;
|
|
1175
|
+
var _b, _c;
|
|
1176
1176
|
const defaults = {
|
|
1177
1177
|
method: "GET",
|
|
1178
1178
|
credentials: "same-origin",
|
|
@@ -1197,6 +1197,7 @@ var NgwConnector = (function () {
|
|
|
1197
1197
|
"query",
|
|
1198
1198
|
"json"
|
|
1199
1199
|
]);
|
|
1200
|
+
opt.method = (_b = opt.method) == null ? void 0 : _b.toUpperCase();
|
|
1200
1201
|
if (withCredentials) {
|
|
1201
1202
|
opt.credentials = "include";
|
|
1202
1203
|
}
|
|
@@ -1254,15 +1255,24 @@ var NgwConnector = (function () {
|
|
|
1254
1255
|
}
|
|
1255
1256
|
return body;
|
|
1256
1257
|
});
|
|
1257
|
-
if (cacheEngine
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1258
|
+
if (cacheEngine) {
|
|
1259
|
+
if (((_c = opt.method) == null ? void 0 : _c.toUpperCase()) === "GET") {
|
|
1260
|
+
if (cache !== false) {
|
|
1261
|
+
const props = cacheProps ? cacheProps : __spreadValues$3({}, objectRemoveEmpty({
|
|
1262
|
+
withCredentials,
|
|
1263
|
+
responseType
|
|
1264
|
+
}));
|
|
1265
|
+
return cacheEngine.add(cacheName || url, makeRequest, {
|
|
1266
|
+
props,
|
|
1267
|
+
expirationTime: cache ? void 0 : 500
|
|
1268
|
+
});
|
|
1269
|
+
}
|
|
1270
|
+
} else {
|
|
1271
|
+
const ignoredForClean = ["api/feature_layer/identify"];
|
|
1272
|
+
if (ignoredForClean.every((part) => !path.includes(part))) {
|
|
1273
|
+
cacheEngine.clean();
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1266
1276
|
}
|
|
1267
1277
|
return makeRequest();
|
|
1268
1278
|
});
|
|
@@ -1567,12 +1577,16 @@ var NgwConnector = (function () {
|
|
|
1567
1577
|
__publicField$2(this, "user");
|
|
1568
1578
|
__publicField$2(this, "cache");
|
|
1569
1579
|
__publicField$2(this, "withCredentials");
|
|
1580
|
+
// Dedicated cache for route requests, as these are executed before any other requests.
|
|
1581
|
+
// This cache does not need to be cleared during the session.
|
|
1582
|
+
__publicField$2(this, "routeCache");
|
|
1570
1583
|
__publicField$2(this, "client", `NextGIS-NGW-Connector/${pkg.version}`);
|
|
1571
1584
|
__publicField$2(this, "routeStr", "/api/component/pyramid/route");
|
|
1572
1585
|
__publicField$2(this, "activeRequests", {});
|
|
1573
1586
|
__publicField$2(this, "requestTransform");
|
|
1574
1587
|
const exist = findConnector(options);
|
|
1575
1588
|
this.cache = new Cache({ namespace: options.cacheId });
|
|
1589
|
+
this.routeCache = new Cache({ namespace: "routecache" });
|
|
1576
1590
|
if (exist) {
|
|
1577
1591
|
return exist;
|
|
1578
1592
|
} else {
|
|
@@ -1633,19 +1647,9 @@ var NgwConnector = (function () {
|
|
|
1633
1647
|
}
|
|
1634
1648
|
}
|
|
1635
1649
|
const routeUrl = `${this.routeStr}?client=${this.client}`;
|
|
1636
|
-
return this.
|
|
1637
|
-
|
|
1638
|
-
{}
|
|
1639
|
-
{
|
|
1640
|
-
cacheName: "route",
|
|
1641
|
-
signal,
|
|
1642
|
-
cache: true,
|
|
1643
|
-
cacheProps: {
|
|
1644
|
-
id: this.id,
|
|
1645
|
-
auth,
|
|
1646
|
-
baseUrl: this.options.baseUrl
|
|
1647
|
-
}
|
|
1648
|
-
}
|
|
1650
|
+
return this.routeCache.add(
|
|
1651
|
+
this.options.baseUrl || String(this.id),
|
|
1652
|
+
() => this.makeQuery(routeUrl, null, { signal, cache: false })
|
|
1649
1653
|
);
|
|
1650
1654
|
});
|
|
1651
1655
|
}
|
|
@@ -1666,6 +1670,7 @@ var NgwConnector = (function () {
|
|
|
1666
1670
|
removeConnector(this);
|
|
1667
1671
|
this.options.auth = void 0;
|
|
1668
1672
|
this.user = void 0;
|
|
1673
|
+
this.routeCache.clean();
|
|
1669
1674
|
this.clearCache();
|
|
1670
1675
|
this.emitter.emit("logout");
|
|
1671
1676
|
}
|
|
@@ -1772,7 +1777,7 @@ var NgwConnector = (function () {
|
|
|
1772
1777
|
this._cleanActiveRequest(id);
|
|
1773
1778
|
}
|
|
1774
1779
|
});
|
|
1775
|
-
if (method === "GET") {
|
|
1780
|
+
if (method === "GET" && cache !== false) {
|
|
1776
1781
|
const cacheOptions = cacheProps ? cacheProps : __spreadProps$1(__spreadValues$1({}, objectRemoveEmpty({
|
|
1777
1782
|
headers,
|
|
1778
1783
|
withCredentials,
|