@katlux/providers 0.1.0-beta.71 → 0.1.0-beta.72
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/dist/index.cjs +165 -36
- package/dist/index.d.cts +21 -1
- package/dist/index.d.mts +21 -1
- package/dist/index.d.ts +21 -1
- package/dist/index.mjs +166 -37
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -145,6 +145,9 @@ class ADataProvider {
|
|
|
145
145
|
setPageSize(pageSize) {
|
|
146
146
|
this.pageSize.value = pageSize;
|
|
147
147
|
}
|
|
148
|
+
async refresh(hardRefresh = false) {
|
|
149
|
+
this.loadPageData();
|
|
150
|
+
}
|
|
148
151
|
}
|
|
149
152
|
|
|
150
153
|
const useFilterLogic = () => {
|
|
@@ -403,8 +406,6 @@ class CFlatClientDataProvider extends ADataProvider {
|
|
|
403
406
|
this.pageData.value = this.filteredData.value.slice(startIndex, endIndex);
|
|
404
407
|
}
|
|
405
408
|
}
|
|
406
|
-
refreshData() {
|
|
407
|
-
}
|
|
408
409
|
}
|
|
409
410
|
|
|
410
411
|
class ACacheProvider {
|
|
@@ -1608,6 +1609,9 @@ class RequestProvider {
|
|
|
1608
1609
|
static requestQueue = [];
|
|
1609
1610
|
static executing = false;
|
|
1610
1611
|
static requestsInFlight = /* @__PURE__ */ new Map();
|
|
1612
|
+
lastUrl;
|
|
1613
|
+
lastOptions;
|
|
1614
|
+
dataReceivedCallback;
|
|
1611
1615
|
constructor(provider, lifetime, deduplicate) {
|
|
1612
1616
|
if (provider) this.setCacheProvider(provider);
|
|
1613
1617
|
if (lifetime) this.setCacheLifetime(lifetime);
|
|
@@ -1626,6 +1630,26 @@ class RequestProvider {
|
|
|
1626
1630
|
setDeduplicate(deduplicate) {
|
|
1627
1631
|
this.deduplicate = deduplicate;
|
|
1628
1632
|
}
|
|
1633
|
+
onDataReceived(callback) {
|
|
1634
|
+
this.dataReceivedCallback = callback;
|
|
1635
|
+
}
|
|
1636
|
+
hasLastUrl() {
|
|
1637
|
+
return !!this.lastUrl;
|
|
1638
|
+
}
|
|
1639
|
+
async refresh(hardRefresh = false) {
|
|
1640
|
+
if (!this.dataReceivedCallback) {
|
|
1641
|
+
return null;
|
|
1642
|
+
}
|
|
1643
|
+
if (!this.lastUrl) {
|
|
1644
|
+
console.warn("[RequestProvider] refresh called before any request was made.");
|
|
1645
|
+
return null;
|
|
1646
|
+
}
|
|
1647
|
+
const options = { ...this.lastOptions };
|
|
1648
|
+
if (hardRefresh) {
|
|
1649
|
+
options.disableCache = true;
|
|
1650
|
+
}
|
|
1651
|
+
return this.request(this.lastUrl, options);
|
|
1652
|
+
}
|
|
1629
1653
|
getUniqueKey(url, options) {
|
|
1630
1654
|
if (options?.key) return options.key;
|
|
1631
1655
|
const { query, body, headers, method } = options || {};
|
|
@@ -1642,7 +1666,15 @@ class RequestProvider {
|
|
|
1642
1666
|
const uniqueKey = this.getUniqueKey(url, options);
|
|
1643
1667
|
const shouldDeduplicate = options?.deduplicate ?? this.deduplicate;
|
|
1644
1668
|
if (shouldDeduplicate && RequestProvider.requestsInFlight.has(uniqueKey)) {
|
|
1645
|
-
|
|
1669
|
+
const inflightPromise = RequestProvider.requestsInFlight.get(uniqueKey);
|
|
1670
|
+
return inflightPromise.then((result) => {
|
|
1671
|
+
this.lastUrl = url;
|
|
1672
|
+
this.lastOptions = options;
|
|
1673
|
+
if (this.dataReceivedCallback) {
|
|
1674
|
+
this.dataReceivedCallback(result);
|
|
1675
|
+
}
|
|
1676
|
+
return result;
|
|
1677
|
+
});
|
|
1646
1678
|
}
|
|
1647
1679
|
const promise = new Promise((resolve, reject) => {
|
|
1648
1680
|
RequestProvider.requestQueue.push({
|
|
@@ -1702,6 +1734,11 @@ class RequestProvider {
|
|
|
1702
1734
|
const cached = await provider.get(uniqueKey, nuxtApp);
|
|
1703
1735
|
if (cached) {
|
|
1704
1736
|
console.log(`[RequestProvider] CACHE HIT: ${url}`);
|
|
1737
|
+
this.lastUrl = url;
|
|
1738
|
+
this.lastOptions = options;
|
|
1739
|
+
if (this.dataReceivedCallback) {
|
|
1740
|
+
this.dataReceivedCallback(cached);
|
|
1741
|
+
}
|
|
1705
1742
|
return cached;
|
|
1706
1743
|
}
|
|
1707
1744
|
console.log(`[RequestProvider] CACHE MISS: ${url}`);
|
|
@@ -1716,6 +1753,11 @@ class RequestProvider {
|
|
|
1716
1753
|
if (provider && cacheLifetime && responseData && isGetRequest) {
|
|
1717
1754
|
await provider.set(uniqueKey, responseData, cacheLifetime, nuxtApp);
|
|
1718
1755
|
}
|
|
1756
|
+
this.lastUrl = url;
|
|
1757
|
+
this.lastOptions = options;
|
|
1758
|
+
if (this.dataReceivedCallback) {
|
|
1759
|
+
this.dataReceivedCallback(responseData);
|
|
1760
|
+
}
|
|
1719
1761
|
return responseData;
|
|
1720
1762
|
}
|
|
1721
1763
|
}
|
|
@@ -1733,6 +1775,11 @@ class CAPIFlatClientDataProvider extends CFlatClientDataProvider {
|
|
|
1733
1775
|
if (options?.cacheStrategy) this.cacheStrategy.value = options.cacheStrategy;
|
|
1734
1776
|
if (options?.cacheLifetime) this.cacheLifetime.value = options.cacheLifetime;
|
|
1735
1777
|
if (options?.refreshOnMutation !== void 0) this.refreshOnMutation.value = options.refreshOnMutation;
|
|
1778
|
+
this.requestProvider.onDataReceived((data) => {
|
|
1779
|
+
if (data) {
|
|
1780
|
+
this.setData(data.rows || data);
|
|
1781
|
+
}
|
|
1782
|
+
});
|
|
1736
1783
|
}
|
|
1737
1784
|
setContextKey(key) {
|
|
1738
1785
|
this.contextKey.value = key;
|
|
@@ -1740,21 +1787,34 @@ class CAPIFlatClientDataProvider extends CFlatClientDataProvider {
|
|
|
1740
1787
|
if (this.cacheStrategy.value) this.requestProvider.setCacheProvider(this.cacheStrategy.value);
|
|
1741
1788
|
if (this.cacheLifetime.value) this.requestProvider.setCacheLifetime(this.cacheLifetime.value);
|
|
1742
1789
|
}
|
|
1790
|
+
async refresh(hardRefresh = false) {
|
|
1791
|
+
await this.refreshData({ disableCache: hardRefresh });
|
|
1792
|
+
}
|
|
1743
1793
|
async refreshData(options) {
|
|
1794
|
+
if (!this.requestProvider.hasLastUrl()) {
|
|
1795
|
+
await this._initialFetch(options?.disableCache ?? false);
|
|
1796
|
+
return;
|
|
1797
|
+
}
|
|
1798
|
+
this.loading.value = true;
|
|
1799
|
+
try {
|
|
1800
|
+
await this.requestProvider.refresh(options?.disableCache ?? false);
|
|
1801
|
+
} finally {
|
|
1802
|
+
this.loading.value = false;
|
|
1803
|
+
}
|
|
1804
|
+
}
|
|
1805
|
+
async _initialFetch(disableCache = false) {
|
|
1744
1806
|
if (!this.SSR.value && undefined) return;
|
|
1745
1807
|
const fetcher = async () => {
|
|
1746
1808
|
const promise = this.requestProvider.registerRequest(this.apiUrl.value, {
|
|
1747
1809
|
deduplicate: this.deduplicate.value,
|
|
1748
1810
|
nuxtApp: this.nuxtApp,
|
|
1749
|
-
disableCache
|
|
1811
|
+
disableCache
|
|
1750
1812
|
});
|
|
1751
|
-
if (this.SSR.value && undefined)
|
|
1752
|
-
return await promise;
|
|
1753
|
-
}
|
|
1813
|
+
if (this.SSR.value && undefined) return await promise;
|
|
1754
1814
|
return promise;
|
|
1755
1815
|
};
|
|
1756
1816
|
const key = `${this.contextKey.value}`;
|
|
1757
|
-
if (this.contextKey.value && this.initialLoad.value) {
|
|
1817
|
+
if (this.contextKey.value && this.initialLoad.value && !disableCache) {
|
|
1758
1818
|
const { data } = nuxtAppCompat.getNuxtData(key, this.nuxtApp);
|
|
1759
1819
|
if (data.value) {
|
|
1760
1820
|
const result = data.value;
|
|
@@ -1765,6 +1825,9 @@ class CAPIFlatClientDataProvider extends CFlatClientDataProvider {
|
|
|
1765
1825
|
}
|
|
1766
1826
|
}
|
|
1767
1827
|
if (undefined && this.contextKey.value) {
|
|
1828
|
+
if (disableCache) {
|
|
1829
|
+
nuxtAppCompat.clearNuxtDataKey(key, this.nuxtApp);
|
|
1830
|
+
}
|
|
1768
1831
|
const { data } = await nuxtAppCompat.getAsyncData(key, fetcher, this.nuxtApp);
|
|
1769
1832
|
if (data.value) {
|
|
1770
1833
|
const result = data.value;
|
|
@@ -1778,22 +1841,20 @@ class CAPIFlatClientDataProvider extends CFlatClientDataProvider {
|
|
|
1778
1841
|
const promise = this.requestProvider.registerRequest(this.apiUrl.value, {
|
|
1779
1842
|
deduplicate: this.deduplicate.value,
|
|
1780
1843
|
nuxtApp: this.nuxtApp,
|
|
1781
|
-
disableCache
|
|
1844
|
+
disableCache
|
|
1782
1845
|
});
|
|
1783
|
-
promise.then((
|
|
1846
|
+
promise.then(() => {
|
|
1784
1847
|
this.initialLoad.value = false;
|
|
1785
1848
|
this.loading.value = false;
|
|
1786
|
-
this.setData(returnedData2.rows);
|
|
1787
1849
|
}).catch(() => {
|
|
1788
1850
|
this.initialLoad.value = false;
|
|
1789
1851
|
this.loading.value = false;
|
|
1790
1852
|
});
|
|
1791
1853
|
return;
|
|
1792
1854
|
}
|
|
1793
|
-
|
|
1855
|
+
await fetcher();
|
|
1794
1856
|
this.initialLoad.value = false;
|
|
1795
1857
|
this.loading.value = false;
|
|
1796
|
-
this.setData(returnedData.rows);
|
|
1797
1858
|
}
|
|
1798
1859
|
async setAPIUrl(url) {
|
|
1799
1860
|
this.loading.value = true;
|
|
@@ -1810,13 +1871,12 @@ class CAPIFlatClientDataProvider extends CFlatClientDataProvider {
|
|
|
1810
1871
|
nuxtApp: this.nuxtApp
|
|
1811
1872
|
});
|
|
1812
1873
|
if (this.refreshOnMutation.value) {
|
|
1813
|
-
await this.
|
|
1874
|
+
await this.refresh(true);
|
|
1814
1875
|
} else {
|
|
1815
1876
|
if (result && result.item) {
|
|
1816
1877
|
this.allData.value.push(result.item);
|
|
1817
1878
|
this.loadPageData();
|
|
1818
|
-
|
|
1819
|
-
await this.refreshData({ disableCache: true });
|
|
1879
|
+
await this.refresh(true);
|
|
1820
1880
|
}
|
|
1821
1881
|
if (this.requestProvider.cacheProvider) {
|
|
1822
1882
|
await this.requestProvider.cacheProvider.removeByPrefix(this.apiUrl.value);
|
|
@@ -1834,7 +1894,7 @@ class CAPIFlatClientDataProvider extends CFlatClientDataProvider {
|
|
|
1834
1894
|
nuxtApp: this.nuxtApp
|
|
1835
1895
|
});
|
|
1836
1896
|
if (this.refreshOnMutation.value) {
|
|
1837
|
-
await this.
|
|
1897
|
+
await this.refresh(true);
|
|
1838
1898
|
} else {
|
|
1839
1899
|
const index = this.allData.value.findIndex((row) => row["id"] === item["id"]);
|
|
1840
1900
|
if (index !== -1) {
|
|
@@ -1863,7 +1923,7 @@ class CAPIFlatClientDataProvider extends CFlatClientDataProvider {
|
|
|
1863
1923
|
nuxtApp: this.nuxtApp
|
|
1864
1924
|
});
|
|
1865
1925
|
if (this.refreshOnMutation.value) {
|
|
1866
|
-
await this.
|
|
1926
|
+
await this.refresh(true);
|
|
1867
1927
|
} else {
|
|
1868
1928
|
const idsToDelete = new Set(ids);
|
|
1869
1929
|
this.allData.value = this.allData.value.filter((row) => !idsToDelete.has(row["id"]));
|
|
@@ -1918,7 +1978,7 @@ class CFlatServerDataProvider extends ADataProvider {
|
|
|
1918
1978
|
return;
|
|
1919
1979
|
}
|
|
1920
1980
|
}
|
|
1921
|
-
if (this.SSR.value && this.contextKey.value) {
|
|
1981
|
+
if (this.SSR.value && this.contextKey.value && !options?.disableCache && (undefined || this.initialLoad.value)) {
|
|
1922
1982
|
this.loading.value = true;
|
|
1923
1983
|
const { data } = await nuxtAppCompat.getAsyncData(key, fetcher, this.nuxtApp);
|
|
1924
1984
|
if (data.value) {
|
|
@@ -1952,6 +2012,9 @@ class CFlatServerDataProvider extends ADataProvider {
|
|
|
1952
2012
|
this.initialLoad.value = false;
|
|
1953
2013
|
this.loading.value = false;
|
|
1954
2014
|
}
|
|
2015
|
+
async refresh(hardRefresh = false) {
|
|
2016
|
+
await this.loadPageData(hardRefresh ? { disableCache: true } : void 0);
|
|
2017
|
+
}
|
|
1955
2018
|
}
|
|
1956
2019
|
|
|
1957
2020
|
class CAPIFlatServerDataProvider extends CFlatServerDataProvider {
|
|
@@ -1966,6 +2029,28 @@ class CAPIFlatServerDataProvider extends CFlatServerDataProvider {
|
|
|
1966
2029
|
if (options?.cacheStrategy) this.cacheStrategy.value = options.cacheStrategy;
|
|
1967
2030
|
if (options?.cacheLifetime) this.cacheLifetime.value = options.cacheLifetime;
|
|
1968
2031
|
if (options?.refreshOnMutation !== void 0) this.refreshOnMutation.value = options.refreshOnMutation;
|
|
2032
|
+
this.requestProvider.onDataReceived((data) => {
|
|
2033
|
+
if (data) {
|
|
2034
|
+
this.pageData.value = data.rows || data;
|
|
2035
|
+
if (data.rowCount !== void 0) {
|
|
2036
|
+
this.rowCount.value = data.rowCount;
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
});
|
|
2040
|
+
}
|
|
2041
|
+
async refresh(hardRefresh = false) {
|
|
2042
|
+
if (hardRefresh && this.requestProvider.cacheProvider) {
|
|
2043
|
+
await this.requestProvider.cacheProvider.removeByPrefix(this.apiUrl.value);
|
|
2044
|
+
}
|
|
2045
|
+
this.loading.value = true;
|
|
2046
|
+
try {
|
|
2047
|
+
await this.loadPageData(hardRefresh ? { disableCache: true } : void 0);
|
|
2048
|
+
} finally {
|
|
2049
|
+
this.loading.value = false;
|
|
2050
|
+
}
|
|
2051
|
+
}
|
|
2052
|
+
async refreshData(options) {
|
|
2053
|
+
await this.refresh(options?.disableCache ?? false);
|
|
1969
2054
|
}
|
|
1970
2055
|
async setAPIUrl(url) {
|
|
1971
2056
|
this.apiUrl.value = url;
|
|
@@ -2001,7 +2086,7 @@ class CAPIFlatServerDataProvider extends CFlatServerDataProvider {
|
|
|
2001
2086
|
if (this.requestProvider.cacheProvider) {
|
|
2002
2087
|
await this.requestProvider.cacheProvider.removeByPrefix(this.apiUrl.value);
|
|
2003
2088
|
}
|
|
2004
|
-
this.
|
|
2089
|
+
await this.refresh(true);
|
|
2005
2090
|
}
|
|
2006
2091
|
}
|
|
2007
2092
|
}
|
|
@@ -2276,6 +2361,11 @@ class CAPITreeClientDataProvider extends CTreeClientDataProvider {
|
|
|
2276
2361
|
if (options?.cacheStrategy) this.cacheStrategy.value = options.cacheStrategy;
|
|
2277
2362
|
if (options?.cacheLifetime) this.cacheLifetime.value = options.cacheLifetime;
|
|
2278
2363
|
if (options?.refreshOnMutation !== void 0) this.refreshOnMutation.value = options.refreshOnMutation;
|
|
2364
|
+
this.requestProvider.onDataReceived((data) => {
|
|
2365
|
+
if (data) {
|
|
2366
|
+
this.setData(data.rows || data);
|
|
2367
|
+
}
|
|
2368
|
+
});
|
|
2279
2369
|
}
|
|
2280
2370
|
setContextKey(key) {
|
|
2281
2371
|
this.contextKey.value = key;
|
|
@@ -2283,21 +2373,34 @@ class CAPITreeClientDataProvider extends CTreeClientDataProvider {
|
|
|
2283
2373
|
if (this.cacheStrategy.value) this.requestProvider.setCacheProvider(this.cacheStrategy.value);
|
|
2284
2374
|
if (this.cacheLifetime.value) this.requestProvider.setCacheLifetime(this.cacheLifetime.value);
|
|
2285
2375
|
}
|
|
2376
|
+
async refresh(hardRefresh = false) {
|
|
2377
|
+
await this.refreshData({ disableCache: hardRefresh });
|
|
2378
|
+
}
|
|
2286
2379
|
async refreshData(options) {
|
|
2380
|
+
if (!this.requestProvider.hasLastUrl()) {
|
|
2381
|
+
await this._initialFetch(options?.disableCache ?? false);
|
|
2382
|
+
return;
|
|
2383
|
+
}
|
|
2384
|
+
this.loading.value = true;
|
|
2385
|
+
try {
|
|
2386
|
+
await this.requestProvider.refresh(options?.disableCache ?? false);
|
|
2387
|
+
} finally {
|
|
2388
|
+
this.loading.value = false;
|
|
2389
|
+
}
|
|
2390
|
+
}
|
|
2391
|
+
async _initialFetch(disableCache = false) {
|
|
2287
2392
|
if (!this.SSR.value && undefined) return;
|
|
2288
2393
|
const fetcher = async () => {
|
|
2289
2394
|
const promise = this.requestProvider.registerRequest(this.apiUrl.value, {
|
|
2290
2395
|
deduplicate: this.deduplicate.value,
|
|
2291
2396
|
nuxtApp: this.nuxtApp,
|
|
2292
|
-
disableCache
|
|
2397
|
+
disableCache
|
|
2293
2398
|
});
|
|
2294
|
-
if (this.SSR.value && undefined)
|
|
2295
|
-
return await promise;
|
|
2296
|
-
}
|
|
2399
|
+
if (this.SSR.value && undefined) return await promise;
|
|
2297
2400
|
return promise;
|
|
2298
2401
|
};
|
|
2299
2402
|
const key = `${this.contextKey.value}`;
|
|
2300
|
-
if (this.contextKey.value && this.initialLoad.value) {
|
|
2403
|
+
if (this.contextKey.value && this.initialLoad.value && !disableCache) {
|
|
2301
2404
|
const { data } = nuxtAppCompat.getNuxtData(key, this.nuxtApp);
|
|
2302
2405
|
if (data.value) {
|
|
2303
2406
|
const result = data.value;
|
|
@@ -2308,6 +2411,9 @@ class CAPITreeClientDataProvider extends CTreeClientDataProvider {
|
|
|
2308
2411
|
}
|
|
2309
2412
|
}
|
|
2310
2413
|
if (undefined && this.contextKey.value) {
|
|
2414
|
+
if (disableCache) {
|
|
2415
|
+
nuxtAppCompat.clearNuxtDataKey(key, this.nuxtApp);
|
|
2416
|
+
}
|
|
2311
2417
|
const { data } = await nuxtAppCompat.getAsyncData(key, fetcher, this.nuxtApp);
|
|
2312
2418
|
if (data.value) {
|
|
2313
2419
|
const result = data.value;
|
|
@@ -2321,22 +2427,20 @@ class CAPITreeClientDataProvider extends CTreeClientDataProvider {
|
|
|
2321
2427
|
const promise = this.requestProvider.registerRequest(this.apiUrl.value, {
|
|
2322
2428
|
deduplicate: this.deduplicate.value,
|
|
2323
2429
|
nuxtApp: this.nuxtApp,
|
|
2324
|
-
disableCache
|
|
2430
|
+
disableCache
|
|
2325
2431
|
});
|
|
2326
|
-
promise.then((
|
|
2432
|
+
promise.then(() => {
|
|
2327
2433
|
this.initialLoad.value = false;
|
|
2328
2434
|
this.loading.value = false;
|
|
2329
|
-
this.setData(returnedData2.rows);
|
|
2330
2435
|
}).catch(() => {
|
|
2331
2436
|
this.initialLoad.value = false;
|
|
2332
2437
|
this.loading.value = false;
|
|
2333
2438
|
});
|
|
2334
2439
|
return;
|
|
2335
2440
|
}
|
|
2336
|
-
|
|
2441
|
+
await fetcher();
|
|
2337
2442
|
this.initialLoad.value = false;
|
|
2338
2443
|
this.loading.value = false;
|
|
2339
|
-
this.setData(returnedData.rows);
|
|
2340
2444
|
}
|
|
2341
2445
|
async setAPIUrl(url) {
|
|
2342
2446
|
this.loading.value = true;
|
|
@@ -2353,12 +2457,12 @@ class CAPITreeClientDataProvider extends CTreeClientDataProvider {
|
|
|
2353
2457
|
nuxtApp: this.nuxtApp
|
|
2354
2458
|
});
|
|
2355
2459
|
if (this.refreshOnMutation.value) {
|
|
2356
|
-
await this.
|
|
2460
|
+
await this.refresh(true);
|
|
2357
2461
|
} else {
|
|
2358
2462
|
if (result && result.item) {
|
|
2359
2463
|
this.allData.value.push(result.item);
|
|
2360
2464
|
} else {
|
|
2361
|
-
await this.
|
|
2465
|
+
await this.refresh(true);
|
|
2362
2466
|
}
|
|
2363
2467
|
if (this.requestProvider.cacheProvider) {
|
|
2364
2468
|
await this.requestProvider.cacheProvider.removeByPrefix(this.apiUrl.value);
|
|
@@ -2376,7 +2480,7 @@ class CAPITreeClientDataProvider extends CTreeClientDataProvider {
|
|
|
2376
2480
|
nuxtApp: this.nuxtApp
|
|
2377
2481
|
});
|
|
2378
2482
|
if (this.refreshOnMutation.value) {
|
|
2379
|
-
await this.
|
|
2483
|
+
await this.refresh(true);
|
|
2380
2484
|
} else {
|
|
2381
2485
|
const index = this.allData.value.findIndex((row) => row[this.idKey] === item[this.idKey]);
|
|
2382
2486
|
if (index !== -1) {
|
|
@@ -2405,7 +2509,7 @@ class CAPITreeClientDataProvider extends CTreeClientDataProvider {
|
|
|
2405
2509
|
nuxtApp: this.nuxtApp
|
|
2406
2510
|
});
|
|
2407
2511
|
if (this.refreshOnMutation.value) {
|
|
2408
|
-
await this.
|
|
2512
|
+
await this.refresh(true);
|
|
2409
2513
|
} else {
|
|
2410
2514
|
const idsToDelete = new Set(ids);
|
|
2411
2515
|
this.allData.value = this.allData.value.filter((row) => !idsToDelete.has(row[this.idKey]));
|
|
@@ -2492,7 +2596,7 @@ class CTreeServerDataProvider extends ADataProvider {
|
|
|
2492
2596
|
return;
|
|
2493
2597
|
}
|
|
2494
2598
|
}
|
|
2495
|
-
if (this.SSR.value && this.contextKey.value) {
|
|
2599
|
+
if (this.SSR.value && this.contextKey.value && !options?.disableCache && (undefined || this.initialLoad.value)) {
|
|
2496
2600
|
this.loading.value = true;
|
|
2497
2601
|
const { data } = await nuxtAppCompat.getAsyncData(key, fetcher, this.nuxtApp);
|
|
2498
2602
|
if (data.value) {
|
|
@@ -2526,6 +2630,9 @@ class CTreeServerDataProvider extends ADataProvider {
|
|
|
2526
2630
|
this.initialLoad.value = false;
|
|
2527
2631
|
this.loading.value = false;
|
|
2528
2632
|
}
|
|
2633
|
+
async refresh(hardRefresh = false) {
|
|
2634
|
+
await this.loadPageData(hardRefresh ? { disableCache: true } : void 0);
|
|
2635
|
+
}
|
|
2529
2636
|
// ============================================
|
|
2530
2637
|
// Expand/Collapse API
|
|
2531
2638
|
// ============================================
|
|
@@ -2566,6 +2673,28 @@ class CAPITreeServerDataProvider extends CTreeServerDataProvider {
|
|
|
2566
2673
|
if (options?.cacheStrategy) this.cacheStrategy.value = options.cacheStrategy;
|
|
2567
2674
|
if (options?.cacheLifetime) this.cacheLifetime.value = options.cacheLifetime;
|
|
2568
2675
|
if (options?.refreshOnMutation !== void 0) this.refreshOnMutation.value = options.refreshOnMutation;
|
|
2676
|
+
this.requestProvider.onDataReceived((data) => {
|
|
2677
|
+
if (data) {
|
|
2678
|
+
this.pageData.value = data.rows || data;
|
|
2679
|
+
if (data.rowCount !== void 0) {
|
|
2680
|
+
this.rowCount.value = data.rowCount;
|
|
2681
|
+
}
|
|
2682
|
+
}
|
|
2683
|
+
});
|
|
2684
|
+
}
|
|
2685
|
+
async refresh(hardRefresh = false) {
|
|
2686
|
+
if (hardRefresh && this.requestProvider.cacheProvider) {
|
|
2687
|
+
await this.requestProvider.cacheProvider.removeByPrefix(this.apiUrl.value);
|
|
2688
|
+
}
|
|
2689
|
+
this.loading.value = true;
|
|
2690
|
+
try {
|
|
2691
|
+
await this.loadPageData(hardRefresh ? { disableCache: true } : void 0);
|
|
2692
|
+
} finally {
|
|
2693
|
+
this.loading.value = false;
|
|
2694
|
+
}
|
|
2695
|
+
}
|
|
2696
|
+
async refreshData(options) {
|
|
2697
|
+
await this.refresh(options?.disableCache ?? false);
|
|
2569
2698
|
}
|
|
2570
2699
|
async setAPIUrl(url) {
|
|
2571
2700
|
this.apiUrl.value = url;
|
|
@@ -2607,7 +2736,7 @@ class CAPITreeServerDataProvider extends CTreeServerDataProvider {
|
|
|
2607
2736
|
if (this.requestProvider.cacheProvider) {
|
|
2608
2737
|
await this.requestProvider.cacheProvider.removeByPrefix(this.apiUrl.value);
|
|
2609
2738
|
}
|
|
2610
|
-
this.
|
|
2739
|
+
await this.refresh(true);
|
|
2611
2740
|
}
|
|
2612
2741
|
}
|
|
2613
2742
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -134,6 +134,7 @@ declare abstract class ADataProvider {
|
|
|
134
134
|
setCurrentPage(currentPage: number): void;
|
|
135
135
|
setPageSize(pageSize: number): void;
|
|
136
136
|
abstract loadPageData(): void;
|
|
137
|
+
refresh(hardRefresh?: boolean): Promise<void>;
|
|
137
138
|
}
|
|
138
139
|
|
|
139
140
|
declare class CFlatClientDataProvider extends ADataProvider {
|
|
@@ -142,7 +143,6 @@ declare class CFlatClientDataProvider extends ADataProvider {
|
|
|
142
143
|
constructor(options?: IDataProviderOptions);
|
|
143
144
|
setData(data: TDataRow[]): void;
|
|
144
145
|
loadPageData(): Promise<void>;
|
|
145
|
-
refreshData(): void;
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
declare abstract class ACacheProvider {
|
|
@@ -164,10 +164,16 @@ declare class RequestProvider {
|
|
|
164
164
|
private static requestQueue;
|
|
165
165
|
private static executing;
|
|
166
166
|
private static requestsInFlight;
|
|
167
|
+
private lastUrl?;
|
|
168
|
+
private lastOptions?;
|
|
169
|
+
private dataReceivedCallback?;
|
|
167
170
|
constructor(provider?: ACacheProvider | ECacheStrategy, lifetime?: number, deduplicate?: boolean);
|
|
168
171
|
setCacheProvider(provider?: ACacheProvider | ECacheStrategy): void;
|
|
169
172
|
setCacheLifetime(lifetime: number): void;
|
|
170
173
|
setDeduplicate(deduplicate: boolean): void;
|
|
174
|
+
onDataReceived(callback: (data: any) => void): void;
|
|
175
|
+
hasLastUrl(): boolean;
|
|
176
|
+
refresh(hardRefresh?: boolean): Promise<any>;
|
|
171
177
|
private getUniqueKey;
|
|
172
178
|
registerRequest<T>(url: string, options?: IRequestOptions): Promise<T>;
|
|
173
179
|
static executeAll(): void;
|
|
@@ -197,9 +203,11 @@ declare class CAPIFlatClientDataProvider extends CFlatClientDataProvider impleme
|
|
|
197
203
|
refreshOnMutation: Ref<boolean | undefined>;
|
|
198
204
|
constructor(options?: IDataProviderOptions);
|
|
199
205
|
setContextKey(key: string): void;
|
|
206
|
+
refresh(hardRefresh?: boolean): Promise<void>;
|
|
200
207
|
refreshData(options?: {
|
|
201
208
|
disableCache?: boolean;
|
|
202
209
|
}): Promise<void>;
|
|
210
|
+
private _initialFetch;
|
|
203
211
|
setAPIUrl(url: string): Promise<void>;
|
|
204
212
|
create(item: any): Promise<void>;
|
|
205
213
|
update(item: any): Promise<void>;
|
|
@@ -216,6 +224,7 @@ declare class CFlatServerDataProvider extends ADataProvider {
|
|
|
216
224
|
loadPageData(options?: {
|
|
217
225
|
disableCache?: boolean;
|
|
218
226
|
}): Promise<void>;
|
|
227
|
+
refresh(hardRefresh?: boolean): Promise<void>;
|
|
219
228
|
}
|
|
220
229
|
|
|
221
230
|
declare class CAPIFlatServerDataProvider extends CFlatServerDataProvider implements AAPIDataProvider {
|
|
@@ -225,6 +234,10 @@ declare class CAPIFlatServerDataProvider extends CFlatServerDataProvider impleme
|
|
|
225
234
|
cacheLifetime: Ref<number>;
|
|
226
235
|
refreshOnMutation: Ref<boolean | undefined>;
|
|
227
236
|
constructor(options?: IDataProviderOptions);
|
|
237
|
+
refresh(hardRefresh?: boolean): Promise<void>;
|
|
238
|
+
refreshData(options?: {
|
|
239
|
+
disableCache?: boolean;
|
|
240
|
+
}): Promise<void>;
|
|
228
241
|
setAPIUrl(url: string): Promise<void>;
|
|
229
242
|
delete(items: any[]): Promise<void>;
|
|
230
243
|
}
|
|
@@ -267,9 +280,11 @@ declare class CAPITreeClientDataProvider extends CTreeClientDataProvider impleme
|
|
|
267
280
|
refreshOnMutation: Ref<boolean | undefined>;
|
|
268
281
|
constructor(options?: ITreeDataProviderOptions);
|
|
269
282
|
setContextKey(key: string): void;
|
|
283
|
+
refresh(hardRefresh?: boolean): Promise<void>;
|
|
270
284
|
refreshData(options?: {
|
|
271
285
|
disableCache?: boolean;
|
|
272
286
|
}): Promise<void>;
|
|
287
|
+
private _initialFetch;
|
|
273
288
|
setAPIUrl(url: string): Promise<void>;
|
|
274
289
|
create(item: any): Promise<void>;
|
|
275
290
|
update(item: any): Promise<void>;
|
|
@@ -317,6 +332,7 @@ declare class CTreeServerDataProvider extends ADataProvider {
|
|
|
317
332
|
loadPageData(options?: {
|
|
318
333
|
disableCache?: boolean;
|
|
319
334
|
}): Promise<void>;
|
|
335
|
+
refresh(hardRefresh?: boolean): Promise<void>;
|
|
320
336
|
toggleNode(nodeId: string | number): void;
|
|
321
337
|
expand(nodeId: string | number): void;
|
|
322
338
|
collapse(nodeId: string | number): void;
|
|
@@ -339,6 +355,10 @@ declare class CAPITreeServerDataProvider extends CTreeServerDataProvider impleme
|
|
|
339
355
|
cacheLifetime: Ref<number>;
|
|
340
356
|
refreshOnMutation: Ref<boolean | undefined>;
|
|
341
357
|
constructor(options?: ITreeDataProviderOptions);
|
|
358
|
+
refresh(hardRefresh?: boolean): Promise<void>;
|
|
359
|
+
refreshData(options?: {
|
|
360
|
+
disableCache?: boolean;
|
|
361
|
+
}): Promise<void>;
|
|
342
362
|
setAPIUrl(url: string): Promise<void>;
|
|
343
363
|
delete(items: any[]): Promise<void>;
|
|
344
364
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -134,6 +134,7 @@ declare abstract class ADataProvider {
|
|
|
134
134
|
setCurrentPage(currentPage: number): void;
|
|
135
135
|
setPageSize(pageSize: number): void;
|
|
136
136
|
abstract loadPageData(): void;
|
|
137
|
+
refresh(hardRefresh?: boolean): Promise<void>;
|
|
137
138
|
}
|
|
138
139
|
|
|
139
140
|
declare class CFlatClientDataProvider extends ADataProvider {
|
|
@@ -142,7 +143,6 @@ declare class CFlatClientDataProvider extends ADataProvider {
|
|
|
142
143
|
constructor(options?: IDataProviderOptions);
|
|
143
144
|
setData(data: TDataRow[]): void;
|
|
144
145
|
loadPageData(): Promise<void>;
|
|
145
|
-
refreshData(): void;
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
declare abstract class ACacheProvider {
|
|
@@ -164,10 +164,16 @@ declare class RequestProvider {
|
|
|
164
164
|
private static requestQueue;
|
|
165
165
|
private static executing;
|
|
166
166
|
private static requestsInFlight;
|
|
167
|
+
private lastUrl?;
|
|
168
|
+
private lastOptions?;
|
|
169
|
+
private dataReceivedCallback?;
|
|
167
170
|
constructor(provider?: ACacheProvider | ECacheStrategy, lifetime?: number, deduplicate?: boolean);
|
|
168
171
|
setCacheProvider(provider?: ACacheProvider | ECacheStrategy): void;
|
|
169
172
|
setCacheLifetime(lifetime: number): void;
|
|
170
173
|
setDeduplicate(deduplicate: boolean): void;
|
|
174
|
+
onDataReceived(callback: (data: any) => void): void;
|
|
175
|
+
hasLastUrl(): boolean;
|
|
176
|
+
refresh(hardRefresh?: boolean): Promise<any>;
|
|
171
177
|
private getUniqueKey;
|
|
172
178
|
registerRequest<T>(url: string, options?: IRequestOptions): Promise<T>;
|
|
173
179
|
static executeAll(): void;
|
|
@@ -197,9 +203,11 @@ declare class CAPIFlatClientDataProvider extends CFlatClientDataProvider impleme
|
|
|
197
203
|
refreshOnMutation: Ref<boolean | undefined>;
|
|
198
204
|
constructor(options?: IDataProviderOptions);
|
|
199
205
|
setContextKey(key: string): void;
|
|
206
|
+
refresh(hardRefresh?: boolean): Promise<void>;
|
|
200
207
|
refreshData(options?: {
|
|
201
208
|
disableCache?: boolean;
|
|
202
209
|
}): Promise<void>;
|
|
210
|
+
private _initialFetch;
|
|
203
211
|
setAPIUrl(url: string): Promise<void>;
|
|
204
212
|
create(item: any): Promise<void>;
|
|
205
213
|
update(item: any): Promise<void>;
|
|
@@ -216,6 +224,7 @@ declare class CFlatServerDataProvider extends ADataProvider {
|
|
|
216
224
|
loadPageData(options?: {
|
|
217
225
|
disableCache?: boolean;
|
|
218
226
|
}): Promise<void>;
|
|
227
|
+
refresh(hardRefresh?: boolean): Promise<void>;
|
|
219
228
|
}
|
|
220
229
|
|
|
221
230
|
declare class CAPIFlatServerDataProvider extends CFlatServerDataProvider implements AAPIDataProvider {
|
|
@@ -225,6 +234,10 @@ declare class CAPIFlatServerDataProvider extends CFlatServerDataProvider impleme
|
|
|
225
234
|
cacheLifetime: Ref<number>;
|
|
226
235
|
refreshOnMutation: Ref<boolean | undefined>;
|
|
227
236
|
constructor(options?: IDataProviderOptions);
|
|
237
|
+
refresh(hardRefresh?: boolean): Promise<void>;
|
|
238
|
+
refreshData(options?: {
|
|
239
|
+
disableCache?: boolean;
|
|
240
|
+
}): Promise<void>;
|
|
228
241
|
setAPIUrl(url: string): Promise<void>;
|
|
229
242
|
delete(items: any[]): Promise<void>;
|
|
230
243
|
}
|
|
@@ -267,9 +280,11 @@ declare class CAPITreeClientDataProvider extends CTreeClientDataProvider impleme
|
|
|
267
280
|
refreshOnMutation: Ref<boolean | undefined>;
|
|
268
281
|
constructor(options?: ITreeDataProviderOptions);
|
|
269
282
|
setContextKey(key: string): void;
|
|
283
|
+
refresh(hardRefresh?: boolean): Promise<void>;
|
|
270
284
|
refreshData(options?: {
|
|
271
285
|
disableCache?: boolean;
|
|
272
286
|
}): Promise<void>;
|
|
287
|
+
private _initialFetch;
|
|
273
288
|
setAPIUrl(url: string): Promise<void>;
|
|
274
289
|
create(item: any): Promise<void>;
|
|
275
290
|
update(item: any): Promise<void>;
|
|
@@ -317,6 +332,7 @@ declare class CTreeServerDataProvider extends ADataProvider {
|
|
|
317
332
|
loadPageData(options?: {
|
|
318
333
|
disableCache?: boolean;
|
|
319
334
|
}): Promise<void>;
|
|
335
|
+
refresh(hardRefresh?: boolean): Promise<void>;
|
|
320
336
|
toggleNode(nodeId: string | number): void;
|
|
321
337
|
expand(nodeId: string | number): void;
|
|
322
338
|
collapse(nodeId: string | number): void;
|
|
@@ -339,6 +355,10 @@ declare class CAPITreeServerDataProvider extends CTreeServerDataProvider impleme
|
|
|
339
355
|
cacheLifetime: Ref<number>;
|
|
340
356
|
refreshOnMutation: Ref<boolean | undefined>;
|
|
341
357
|
constructor(options?: ITreeDataProviderOptions);
|
|
358
|
+
refresh(hardRefresh?: boolean): Promise<void>;
|
|
359
|
+
refreshData(options?: {
|
|
360
|
+
disableCache?: boolean;
|
|
361
|
+
}): Promise<void>;
|
|
342
362
|
setAPIUrl(url: string): Promise<void>;
|
|
343
363
|
delete(items: any[]): Promise<void>;
|
|
344
364
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -134,6 +134,7 @@ declare abstract class ADataProvider {
|
|
|
134
134
|
setCurrentPage(currentPage: number): void;
|
|
135
135
|
setPageSize(pageSize: number): void;
|
|
136
136
|
abstract loadPageData(): void;
|
|
137
|
+
refresh(hardRefresh?: boolean): Promise<void>;
|
|
137
138
|
}
|
|
138
139
|
|
|
139
140
|
declare class CFlatClientDataProvider extends ADataProvider {
|
|
@@ -142,7 +143,6 @@ declare class CFlatClientDataProvider extends ADataProvider {
|
|
|
142
143
|
constructor(options?: IDataProviderOptions);
|
|
143
144
|
setData(data: TDataRow[]): void;
|
|
144
145
|
loadPageData(): Promise<void>;
|
|
145
|
-
refreshData(): void;
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
declare abstract class ACacheProvider {
|
|
@@ -164,10 +164,16 @@ declare class RequestProvider {
|
|
|
164
164
|
private static requestQueue;
|
|
165
165
|
private static executing;
|
|
166
166
|
private static requestsInFlight;
|
|
167
|
+
private lastUrl?;
|
|
168
|
+
private lastOptions?;
|
|
169
|
+
private dataReceivedCallback?;
|
|
167
170
|
constructor(provider?: ACacheProvider | ECacheStrategy, lifetime?: number, deduplicate?: boolean);
|
|
168
171
|
setCacheProvider(provider?: ACacheProvider | ECacheStrategy): void;
|
|
169
172
|
setCacheLifetime(lifetime: number): void;
|
|
170
173
|
setDeduplicate(deduplicate: boolean): void;
|
|
174
|
+
onDataReceived(callback: (data: any) => void): void;
|
|
175
|
+
hasLastUrl(): boolean;
|
|
176
|
+
refresh(hardRefresh?: boolean): Promise<any>;
|
|
171
177
|
private getUniqueKey;
|
|
172
178
|
registerRequest<T>(url: string, options?: IRequestOptions): Promise<T>;
|
|
173
179
|
static executeAll(): void;
|
|
@@ -197,9 +203,11 @@ declare class CAPIFlatClientDataProvider extends CFlatClientDataProvider impleme
|
|
|
197
203
|
refreshOnMutation: Ref<boolean | undefined>;
|
|
198
204
|
constructor(options?: IDataProviderOptions);
|
|
199
205
|
setContextKey(key: string): void;
|
|
206
|
+
refresh(hardRefresh?: boolean): Promise<void>;
|
|
200
207
|
refreshData(options?: {
|
|
201
208
|
disableCache?: boolean;
|
|
202
209
|
}): Promise<void>;
|
|
210
|
+
private _initialFetch;
|
|
203
211
|
setAPIUrl(url: string): Promise<void>;
|
|
204
212
|
create(item: any): Promise<void>;
|
|
205
213
|
update(item: any): Promise<void>;
|
|
@@ -216,6 +224,7 @@ declare class CFlatServerDataProvider extends ADataProvider {
|
|
|
216
224
|
loadPageData(options?: {
|
|
217
225
|
disableCache?: boolean;
|
|
218
226
|
}): Promise<void>;
|
|
227
|
+
refresh(hardRefresh?: boolean): Promise<void>;
|
|
219
228
|
}
|
|
220
229
|
|
|
221
230
|
declare class CAPIFlatServerDataProvider extends CFlatServerDataProvider implements AAPIDataProvider {
|
|
@@ -225,6 +234,10 @@ declare class CAPIFlatServerDataProvider extends CFlatServerDataProvider impleme
|
|
|
225
234
|
cacheLifetime: Ref<number>;
|
|
226
235
|
refreshOnMutation: Ref<boolean | undefined>;
|
|
227
236
|
constructor(options?: IDataProviderOptions);
|
|
237
|
+
refresh(hardRefresh?: boolean): Promise<void>;
|
|
238
|
+
refreshData(options?: {
|
|
239
|
+
disableCache?: boolean;
|
|
240
|
+
}): Promise<void>;
|
|
228
241
|
setAPIUrl(url: string): Promise<void>;
|
|
229
242
|
delete(items: any[]): Promise<void>;
|
|
230
243
|
}
|
|
@@ -267,9 +280,11 @@ declare class CAPITreeClientDataProvider extends CTreeClientDataProvider impleme
|
|
|
267
280
|
refreshOnMutation: Ref<boolean | undefined>;
|
|
268
281
|
constructor(options?: ITreeDataProviderOptions);
|
|
269
282
|
setContextKey(key: string): void;
|
|
283
|
+
refresh(hardRefresh?: boolean): Promise<void>;
|
|
270
284
|
refreshData(options?: {
|
|
271
285
|
disableCache?: boolean;
|
|
272
286
|
}): Promise<void>;
|
|
287
|
+
private _initialFetch;
|
|
273
288
|
setAPIUrl(url: string): Promise<void>;
|
|
274
289
|
create(item: any): Promise<void>;
|
|
275
290
|
update(item: any): Promise<void>;
|
|
@@ -317,6 +332,7 @@ declare class CTreeServerDataProvider extends ADataProvider {
|
|
|
317
332
|
loadPageData(options?: {
|
|
318
333
|
disableCache?: boolean;
|
|
319
334
|
}): Promise<void>;
|
|
335
|
+
refresh(hardRefresh?: boolean): Promise<void>;
|
|
320
336
|
toggleNode(nodeId: string | number): void;
|
|
321
337
|
expand(nodeId: string | number): void;
|
|
322
338
|
collapse(nodeId: string | number): void;
|
|
@@ -339,6 +355,10 @@ declare class CAPITreeServerDataProvider extends CTreeServerDataProvider impleme
|
|
|
339
355
|
cacheLifetime: Ref<number>;
|
|
340
356
|
refreshOnMutation: Ref<boolean | undefined>;
|
|
341
357
|
constructor(options?: ITreeDataProviderOptions);
|
|
358
|
+
refresh(hardRefresh?: boolean): Promise<void>;
|
|
359
|
+
refreshData(options?: {
|
|
360
|
+
disableCache?: boolean;
|
|
361
|
+
}): Promise<void>;
|
|
342
362
|
setAPIUrl(url: string): Promise<void>;
|
|
343
363
|
delete(items: any[]): Promise<void>;
|
|
344
364
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ref, watch, computed } from 'vue';
|
|
2
|
-
import { getNuxtApp, getRoute, getRouter, getNuxtData,
|
|
2
|
+
import { getNuxtApp, getRoute, getRouter, getNuxtData, clearNuxtDataKey, getAsyncData, onNuxtReadyCallback } from '@katlux/providers/nuxtAppCompat';
|
|
3
3
|
import { EDataFilterOperator as EDataFilterOperator$1 } from '@katlux/providers';
|
|
4
4
|
import { parseCookies, getCookie, setCookie, deleteCookie } from 'h3';
|
|
5
5
|
import { $fetch } from 'ofetch';
|
|
@@ -143,6 +143,9 @@ class ADataProvider {
|
|
|
143
143
|
setPageSize(pageSize) {
|
|
144
144
|
this.pageSize.value = pageSize;
|
|
145
145
|
}
|
|
146
|
+
async refresh(hardRefresh = false) {
|
|
147
|
+
this.loadPageData();
|
|
148
|
+
}
|
|
146
149
|
}
|
|
147
150
|
|
|
148
151
|
const useFilterLogic = () => {
|
|
@@ -401,8 +404,6 @@ class CFlatClientDataProvider extends ADataProvider {
|
|
|
401
404
|
this.pageData.value = this.filteredData.value.slice(startIndex, endIndex);
|
|
402
405
|
}
|
|
403
406
|
}
|
|
404
|
-
refreshData() {
|
|
405
|
-
}
|
|
406
407
|
}
|
|
407
408
|
|
|
408
409
|
class ACacheProvider {
|
|
@@ -1606,6 +1607,9 @@ class RequestProvider {
|
|
|
1606
1607
|
static requestQueue = [];
|
|
1607
1608
|
static executing = false;
|
|
1608
1609
|
static requestsInFlight = /* @__PURE__ */ new Map();
|
|
1610
|
+
lastUrl;
|
|
1611
|
+
lastOptions;
|
|
1612
|
+
dataReceivedCallback;
|
|
1609
1613
|
constructor(provider, lifetime, deduplicate) {
|
|
1610
1614
|
if (provider) this.setCacheProvider(provider);
|
|
1611
1615
|
if (lifetime) this.setCacheLifetime(lifetime);
|
|
@@ -1624,6 +1628,26 @@ class RequestProvider {
|
|
|
1624
1628
|
setDeduplicate(deduplicate) {
|
|
1625
1629
|
this.deduplicate = deduplicate;
|
|
1626
1630
|
}
|
|
1631
|
+
onDataReceived(callback) {
|
|
1632
|
+
this.dataReceivedCallback = callback;
|
|
1633
|
+
}
|
|
1634
|
+
hasLastUrl() {
|
|
1635
|
+
return !!this.lastUrl;
|
|
1636
|
+
}
|
|
1637
|
+
async refresh(hardRefresh = false) {
|
|
1638
|
+
if (!this.dataReceivedCallback) {
|
|
1639
|
+
return null;
|
|
1640
|
+
}
|
|
1641
|
+
if (!this.lastUrl) {
|
|
1642
|
+
console.warn("[RequestProvider] refresh called before any request was made.");
|
|
1643
|
+
return null;
|
|
1644
|
+
}
|
|
1645
|
+
const options = { ...this.lastOptions };
|
|
1646
|
+
if (hardRefresh) {
|
|
1647
|
+
options.disableCache = true;
|
|
1648
|
+
}
|
|
1649
|
+
return this.request(this.lastUrl, options);
|
|
1650
|
+
}
|
|
1627
1651
|
getUniqueKey(url, options) {
|
|
1628
1652
|
if (options?.key) return options.key;
|
|
1629
1653
|
const { query, body, headers, method } = options || {};
|
|
@@ -1640,7 +1664,15 @@ class RequestProvider {
|
|
|
1640
1664
|
const uniqueKey = this.getUniqueKey(url, options);
|
|
1641
1665
|
const shouldDeduplicate = options?.deduplicate ?? this.deduplicate;
|
|
1642
1666
|
if (shouldDeduplicate && RequestProvider.requestsInFlight.has(uniqueKey)) {
|
|
1643
|
-
|
|
1667
|
+
const inflightPromise = RequestProvider.requestsInFlight.get(uniqueKey);
|
|
1668
|
+
return inflightPromise.then((result) => {
|
|
1669
|
+
this.lastUrl = url;
|
|
1670
|
+
this.lastOptions = options;
|
|
1671
|
+
if (this.dataReceivedCallback) {
|
|
1672
|
+
this.dataReceivedCallback(result);
|
|
1673
|
+
}
|
|
1674
|
+
return result;
|
|
1675
|
+
});
|
|
1644
1676
|
}
|
|
1645
1677
|
const promise = new Promise((resolve, reject) => {
|
|
1646
1678
|
RequestProvider.requestQueue.push({
|
|
@@ -1700,6 +1732,11 @@ class RequestProvider {
|
|
|
1700
1732
|
const cached = await provider.get(uniqueKey, nuxtApp);
|
|
1701
1733
|
if (cached) {
|
|
1702
1734
|
console.log(`[RequestProvider] CACHE HIT: ${url}`);
|
|
1735
|
+
this.lastUrl = url;
|
|
1736
|
+
this.lastOptions = options;
|
|
1737
|
+
if (this.dataReceivedCallback) {
|
|
1738
|
+
this.dataReceivedCallback(cached);
|
|
1739
|
+
}
|
|
1703
1740
|
return cached;
|
|
1704
1741
|
}
|
|
1705
1742
|
console.log(`[RequestProvider] CACHE MISS: ${url}`);
|
|
@@ -1714,6 +1751,11 @@ class RequestProvider {
|
|
|
1714
1751
|
if (provider && cacheLifetime && responseData && isGetRequest) {
|
|
1715
1752
|
await provider.set(uniqueKey, responseData, cacheLifetime, nuxtApp);
|
|
1716
1753
|
}
|
|
1754
|
+
this.lastUrl = url;
|
|
1755
|
+
this.lastOptions = options;
|
|
1756
|
+
if (this.dataReceivedCallback) {
|
|
1757
|
+
this.dataReceivedCallback(responseData);
|
|
1758
|
+
}
|
|
1717
1759
|
return responseData;
|
|
1718
1760
|
}
|
|
1719
1761
|
}
|
|
@@ -1731,6 +1773,11 @@ class CAPIFlatClientDataProvider extends CFlatClientDataProvider {
|
|
|
1731
1773
|
if (options?.cacheStrategy) this.cacheStrategy.value = options.cacheStrategy;
|
|
1732
1774
|
if (options?.cacheLifetime) this.cacheLifetime.value = options.cacheLifetime;
|
|
1733
1775
|
if (options?.refreshOnMutation !== void 0) this.refreshOnMutation.value = options.refreshOnMutation;
|
|
1776
|
+
this.requestProvider.onDataReceived((data) => {
|
|
1777
|
+
if (data) {
|
|
1778
|
+
this.setData(data.rows || data);
|
|
1779
|
+
}
|
|
1780
|
+
});
|
|
1734
1781
|
}
|
|
1735
1782
|
setContextKey(key) {
|
|
1736
1783
|
this.contextKey.value = key;
|
|
@@ -1738,21 +1785,34 @@ class CAPIFlatClientDataProvider extends CFlatClientDataProvider {
|
|
|
1738
1785
|
if (this.cacheStrategy.value) this.requestProvider.setCacheProvider(this.cacheStrategy.value);
|
|
1739
1786
|
if (this.cacheLifetime.value) this.requestProvider.setCacheLifetime(this.cacheLifetime.value);
|
|
1740
1787
|
}
|
|
1788
|
+
async refresh(hardRefresh = false) {
|
|
1789
|
+
await this.refreshData({ disableCache: hardRefresh });
|
|
1790
|
+
}
|
|
1741
1791
|
async refreshData(options) {
|
|
1792
|
+
if (!this.requestProvider.hasLastUrl()) {
|
|
1793
|
+
await this._initialFetch(options?.disableCache ?? false);
|
|
1794
|
+
return;
|
|
1795
|
+
}
|
|
1796
|
+
this.loading.value = true;
|
|
1797
|
+
try {
|
|
1798
|
+
await this.requestProvider.refresh(options?.disableCache ?? false);
|
|
1799
|
+
} finally {
|
|
1800
|
+
this.loading.value = false;
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
async _initialFetch(disableCache = false) {
|
|
1742
1804
|
if (!this.SSR.value && import.meta.server) return;
|
|
1743
1805
|
const fetcher = async () => {
|
|
1744
1806
|
const promise = this.requestProvider.registerRequest(this.apiUrl.value, {
|
|
1745
1807
|
deduplicate: this.deduplicate.value,
|
|
1746
1808
|
nuxtApp: this.nuxtApp,
|
|
1747
|
-
disableCache
|
|
1809
|
+
disableCache
|
|
1748
1810
|
});
|
|
1749
|
-
if (this.SSR.value && import.meta.server)
|
|
1750
|
-
return await promise;
|
|
1751
|
-
}
|
|
1811
|
+
if (this.SSR.value && import.meta.server) return await promise;
|
|
1752
1812
|
return promise;
|
|
1753
1813
|
};
|
|
1754
1814
|
const key = `${this.contextKey.value}`;
|
|
1755
|
-
if (this.contextKey.value && this.initialLoad.value) {
|
|
1815
|
+
if (this.contextKey.value && this.initialLoad.value && !disableCache) {
|
|
1756
1816
|
const { data } = getNuxtData(key, this.nuxtApp);
|
|
1757
1817
|
if (data.value) {
|
|
1758
1818
|
const result = data.value;
|
|
@@ -1763,6 +1823,9 @@ class CAPIFlatClientDataProvider extends CFlatClientDataProvider {
|
|
|
1763
1823
|
}
|
|
1764
1824
|
}
|
|
1765
1825
|
if (import.meta.server && this.contextKey.value) {
|
|
1826
|
+
if (disableCache) {
|
|
1827
|
+
clearNuxtDataKey(key, this.nuxtApp);
|
|
1828
|
+
}
|
|
1766
1829
|
const { data } = await getAsyncData(key, fetcher, this.nuxtApp);
|
|
1767
1830
|
if (data.value) {
|
|
1768
1831
|
const result = data.value;
|
|
@@ -1776,22 +1839,20 @@ class CAPIFlatClientDataProvider extends CFlatClientDataProvider {
|
|
|
1776
1839
|
const promise = this.requestProvider.registerRequest(this.apiUrl.value, {
|
|
1777
1840
|
deduplicate: this.deduplicate.value,
|
|
1778
1841
|
nuxtApp: this.nuxtApp,
|
|
1779
|
-
disableCache
|
|
1842
|
+
disableCache
|
|
1780
1843
|
});
|
|
1781
|
-
promise.then((
|
|
1844
|
+
promise.then(() => {
|
|
1782
1845
|
this.initialLoad.value = false;
|
|
1783
1846
|
this.loading.value = false;
|
|
1784
|
-
this.setData(returnedData2.rows);
|
|
1785
1847
|
}).catch(() => {
|
|
1786
1848
|
this.initialLoad.value = false;
|
|
1787
1849
|
this.loading.value = false;
|
|
1788
1850
|
});
|
|
1789
1851
|
return;
|
|
1790
1852
|
}
|
|
1791
|
-
|
|
1853
|
+
await fetcher();
|
|
1792
1854
|
this.initialLoad.value = false;
|
|
1793
1855
|
this.loading.value = false;
|
|
1794
|
-
this.setData(returnedData.rows);
|
|
1795
1856
|
}
|
|
1796
1857
|
async setAPIUrl(url) {
|
|
1797
1858
|
this.loading.value = true;
|
|
@@ -1808,13 +1869,12 @@ class CAPIFlatClientDataProvider extends CFlatClientDataProvider {
|
|
|
1808
1869
|
nuxtApp: this.nuxtApp
|
|
1809
1870
|
});
|
|
1810
1871
|
if (this.refreshOnMutation.value) {
|
|
1811
|
-
await this.
|
|
1872
|
+
await this.refresh(true);
|
|
1812
1873
|
} else {
|
|
1813
1874
|
if (result && result.item) {
|
|
1814
1875
|
this.allData.value.push(result.item);
|
|
1815
1876
|
this.loadPageData();
|
|
1816
|
-
|
|
1817
|
-
await this.refreshData({ disableCache: true });
|
|
1877
|
+
await this.refresh(true);
|
|
1818
1878
|
}
|
|
1819
1879
|
if (this.requestProvider.cacheProvider) {
|
|
1820
1880
|
await this.requestProvider.cacheProvider.removeByPrefix(this.apiUrl.value);
|
|
@@ -1832,7 +1892,7 @@ class CAPIFlatClientDataProvider extends CFlatClientDataProvider {
|
|
|
1832
1892
|
nuxtApp: this.nuxtApp
|
|
1833
1893
|
});
|
|
1834
1894
|
if (this.refreshOnMutation.value) {
|
|
1835
|
-
await this.
|
|
1895
|
+
await this.refresh(true);
|
|
1836
1896
|
} else {
|
|
1837
1897
|
const index = this.allData.value.findIndex((row) => row["id"] === item["id"]);
|
|
1838
1898
|
if (index !== -1) {
|
|
@@ -1861,7 +1921,7 @@ class CAPIFlatClientDataProvider extends CFlatClientDataProvider {
|
|
|
1861
1921
|
nuxtApp: this.nuxtApp
|
|
1862
1922
|
});
|
|
1863
1923
|
if (this.refreshOnMutation.value) {
|
|
1864
|
-
await this.
|
|
1924
|
+
await this.refresh(true);
|
|
1865
1925
|
} else {
|
|
1866
1926
|
const idsToDelete = new Set(ids);
|
|
1867
1927
|
this.allData.value = this.allData.value.filter((row) => !idsToDelete.has(row["id"]));
|
|
@@ -1916,7 +1976,7 @@ class CFlatServerDataProvider extends ADataProvider {
|
|
|
1916
1976
|
return;
|
|
1917
1977
|
}
|
|
1918
1978
|
}
|
|
1919
|
-
if (this.SSR.value && this.contextKey.value) {
|
|
1979
|
+
if (this.SSR.value && this.contextKey.value && !options?.disableCache && (import.meta.server || this.initialLoad.value)) {
|
|
1920
1980
|
this.loading.value = true;
|
|
1921
1981
|
const { data } = await getAsyncData(key, fetcher, this.nuxtApp);
|
|
1922
1982
|
if (data.value) {
|
|
@@ -1950,6 +2010,9 @@ class CFlatServerDataProvider extends ADataProvider {
|
|
|
1950
2010
|
this.initialLoad.value = false;
|
|
1951
2011
|
this.loading.value = false;
|
|
1952
2012
|
}
|
|
2013
|
+
async refresh(hardRefresh = false) {
|
|
2014
|
+
await this.loadPageData(hardRefresh ? { disableCache: true } : void 0);
|
|
2015
|
+
}
|
|
1953
2016
|
}
|
|
1954
2017
|
|
|
1955
2018
|
class CAPIFlatServerDataProvider extends CFlatServerDataProvider {
|
|
@@ -1964,6 +2027,28 @@ class CAPIFlatServerDataProvider extends CFlatServerDataProvider {
|
|
|
1964
2027
|
if (options?.cacheStrategy) this.cacheStrategy.value = options.cacheStrategy;
|
|
1965
2028
|
if (options?.cacheLifetime) this.cacheLifetime.value = options.cacheLifetime;
|
|
1966
2029
|
if (options?.refreshOnMutation !== void 0) this.refreshOnMutation.value = options.refreshOnMutation;
|
|
2030
|
+
this.requestProvider.onDataReceived((data) => {
|
|
2031
|
+
if (data) {
|
|
2032
|
+
this.pageData.value = data.rows || data;
|
|
2033
|
+
if (data.rowCount !== void 0) {
|
|
2034
|
+
this.rowCount.value = data.rowCount;
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
});
|
|
2038
|
+
}
|
|
2039
|
+
async refresh(hardRefresh = false) {
|
|
2040
|
+
if (hardRefresh && this.requestProvider.cacheProvider) {
|
|
2041
|
+
await this.requestProvider.cacheProvider.removeByPrefix(this.apiUrl.value);
|
|
2042
|
+
}
|
|
2043
|
+
this.loading.value = true;
|
|
2044
|
+
try {
|
|
2045
|
+
await this.loadPageData(hardRefresh ? { disableCache: true } : void 0);
|
|
2046
|
+
} finally {
|
|
2047
|
+
this.loading.value = false;
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2050
|
+
async refreshData(options) {
|
|
2051
|
+
await this.refresh(options?.disableCache ?? false);
|
|
1967
2052
|
}
|
|
1968
2053
|
async setAPIUrl(url) {
|
|
1969
2054
|
this.apiUrl.value = url;
|
|
@@ -1999,7 +2084,7 @@ class CAPIFlatServerDataProvider extends CFlatServerDataProvider {
|
|
|
1999
2084
|
if (this.requestProvider.cacheProvider) {
|
|
2000
2085
|
await this.requestProvider.cacheProvider.removeByPrefix(this.apiUrl.value);
|
|
2001
2086
|
}
|
|
2002
|
-
this.
|
|
2087
|
+
await this.refresh(true);
|
|
2003
2088
|
}
|
|
2004
2089
|
}
|
|
2005
2090
|
}
|
|
@@ -2274,6 +2359,11 @@ class CAPITreeClientDataProvider extends CTreeClientDataProvider {
|
|
|
2274
2359
|
if (options?.cacheStrategy) this.cacheStrategy.value = options.cacheStrategy;
|
|
2275
2360
|
if (options?.cacheLifetime) this.cacheLifetime.value = options.cacheLifetime;
|
|
2276
2361
|
if (options?.refreshOnMutation !== void 0) this.refreshOnMutation.value = options.refreshOnMutation;
|
|
2362
|
+
this.requestProvider.onDataReceived((data) => {
|
|
2363
|
+
if (data) {
|
|
2364
|
+
this.setData(data.rows || data);
|
|
2365
|
+
}
|
|
2366
|
+
});
|
|
2277
2367
|
}
|
|
2278
2368
|
setContextKey(key) {
|
|
2279
2369
|
this.contextKey.value = key;
|
|
@@ -2281,21 +2371,34 @@ class CAPITreeClientDataProvider extends CTreeClientDataProvider {
|
|
|
2281
2371
|
if (this.cacheStrategy.value) this.requestProvider.setCacheProvider(this.cacheStrategy.value);
|
|
2282
2372
|
if (this.cacheLifetime.value) this.requestProvider.setCacheLifetime(this.cacheLifetime.value);
|
|
2283
2373
|
}
|
|
2374
|
+
async refresh(hardRefresh = false) {
|
|
2375
|
+
await this.refreshData({ disableCache: hardRefresh });
|
|
2376
|
+
}
|
|
2284
2377
|
async refreshData(options) {
|
|
2378
|
+
if (!this.requestProvider.hasLastUrl()) {
|
|
2379
|
+
await this._initialFetch(options?.disableCache ?? false);
|
|
2380
|
+
return;
|
|
2381
|
+
}
|
|
2382
|
+
this.loading.value = true;
|
|
2383
|
+
try {
|
|
2384
|
+
await this.requestProvider.refresh(options?.disableCache ?? false);
|
|
2385
|
+
} finally {
|
|
2386
|
+
this.loading.value = false;
|
|
2387
|
+
}
|
|
2388
|
+
}
|
|
2389
|
+
async _initialFetch(disableCache = false) {
|
|
2285
2390
|
if (!this.SSR.value && import.meta.server) return;
|
|
2286
2391
|
const fetcher = async () => {
|
|
2287
2392
|
const promise = this.requestProvider.registerRequest(this.apiUrl.value, {
|
|
2288
2393
|
deduplicate: this.deduplicate.value,
|
|
2289
2394
|
nuxtApp: this.nuxtApp,
|
|
2290
|
-
disableCache
|
|
2395
|
+
disableCache
|
|
2291
2396
|
});
|
|
2292
|
-
if (this.SSR.value && import.meta.server)
|
|
2293
|
-
return await promise;
|
|
2294
|
-
}
|
|
2397
|
+
if (this.SSR.value && import.meta.server) return await promise;
|
|
2295
2398
|
return promise;
|
|
2296
2399
|
};
|
|
2297
2400
|
const key = `${this.contextKey.value}`;
|
|
2298
|
-
if (this.contextKey.value && this.initialLoad.value) {
|
|
2401
|
+
if (this.contextKey.value && this.initialLoad.value && !disableCache) {
|
|
2299
2402
|
const { data } = getNuxtData(key, this.nuxtApp);
|
|
2300
2403
|
if (data.value) {
|
|
2301
2404
|
const result = data.value;
|
|
@@ -2306,6 +2409,9 @@ class CAPITreeClientDataProvider extends CTreeClientDataProvider {
|
|
|
2306
2409
|
}
|
|
2307
2410
|
}
|
|
2308
2411
|
if (import.meta.server && this.contextKey.value) {
|
|
2412
|
+
if (disableCache) {
|
|
2413
|
+
clearNuxtDataKey(key, this.nuxtApp);
|
|
2414
|
+
}
|
|
2309
2415
|
const { data } = await getAsyncData(key, fetcher, this.nuxtApp);
|
|
2310
2416
|
if (data.value) {
|
|
2311
2417
|
const result = data.value;
|
|
@@ -2319,22 +2425,20 @@ class CAPITreeClientDataProvider extends CTreeClientDataProvider {
|
|
|
2319
2425
|
const promise = this.requestProvider.registerRequest(this.apiUrl.value, {
|
|
2320
2426
|
deduplicate: this.deduplicate.value,
|
|
2321
2427
|
nuxtApp: this.nuxtApp,
|
|
2322
|
-
disableCache
|
|
2428
|
+
disableCache
|
|
2323
2429
|
});
|
|
2324
|
-
promise.then((
|
|
2430
|
+
promise.then(() => {
|
|
2325
2431
|
this.initialLoad.value = false;
|
|
2326
2432
|
this.loading.value = false;
|
|
2327
|
-
this.setData(returnedData2.rows);
|
|
2328
2433
|
}).catch(() => {
|
|
2329
2434
|
this.initialLoad.value = false;
|
|
2330
2435
|
this.loading.value = false;
|
|
2331
2436
|
});
|
|
2332
2437
|
return;
|
|
2333
2438
|
}
|
|
2334
|
-
|
|
2439
|
+
await fetcher();
|
|
2335
2440
|
this.initialLoad.value = false;
|
|
2336
2441
|
this.loading.value = false;
|
|
2337
|
-
this.setData(returnedData.rows);
|
|
2338
2442
|
}
|
|
2339
2443
|
async setAPIUrl(url) {
|
|
2340
2444
|
this.loading.value = true;
|
|
@@ -2351,12 +2455,12 @@ class CAPITreeClientDataProvider extends CTreeClientDataProvider {
|
|
|
2351
2455
|
nuxtApp: this.nuxtApp
|
|
2352
2456
|
});
|
|
2353
2457
|
if (this.refreshOnMutation.value) {
|
|
2354
|
-
await this.
|
|
2458
|
+
await this.refresh(true);
|
|
2355
2459
|
} else {
|
|
2356
2460
|
if (result && result.item) {
|
|
2357
2461
|
this.allData.value.push(result.item);
|
|
2358
2462
|
} else {
|
|
2359
|
-
await this.
|
|
2463
|
+
await this.refresh(true);
|
|
2360
2464
|
}
|
|
2361
2465
|
if (this.requestProvider.cacheProvider) {
|
|
2362
2466
|
await this.requestProvider.cacheProvider.removeByPrefix(this.apiUrl.value);
|
|
@@ -2374,7 +2478,7 @@ class CAPITreeClientDataProvider extends CTreeClientDataProvider {
|
|
|
2374
2478
|
nuxtApp: this.nuxtApp
|
|
2375
2479
|
});
|
|
2376
2480
|
if (this.refreshOnMutation.value) {
|
|
2377
|
-
await this.
|
|
2481
|
+
await this.refresh(true);
|
|
2378
2482
|
} else {
|
|
2379
2483
|
const index = this.allData.value.findIndex((row) => row[this.idKey] === item[this.idKey]);
|
|
2380
2484
|
if (index !== -1) {
|
|
@@ -2403,7 +2507,7 @@ class CAPITreeClientDataProvider extends CTreeClientDataProvider {
|
|
|
2403
2507
|
nuxtApp: this.nuxtApp
|
|
2404
2508
|
});
|
|
2405
2509
|
if (this.refreshOnMutation.value) {
|
|
2406
|
-
await this.
|
|
2510
|
+
await this.refresh(true);
|
|
2407
2511
|
} else {
|
|
2408
2512
|
const idsToDelete = new Set(ids);
|
|
2409
2513
|
this.allData.value = this.allData.value.filter((row) => !idsToDelete.has(row[this.idKey]));
|
|
@@ -2490,7 +2594,7 @@ class CTreeServerDataProvider extends ADataProvider {
|
|
|
2490
2594
|
return;
|
|
2491
2595
|
}
|
|
2492
2596
|
}
|
|
2493
|
-
if (this.SSR.value && this.contextKey.value) {
|
|
2597
|
+
if (this.SSR.value && this.contextKey.value && !options?.disableCache && (import.meta.server || this.initialLoad.value)) {
|
|
2494
2598
|
this.loading.value = true;
|
|
2495
2599
|
const { data } = await getAsyncData(key, fetcher, this.nuxtApp);
|
|
2496
2600
|
if (data.value) {
|
|
@@ -2524,6 +2628,9 @@ class CTreeServerDataProvider extends ADataProvider {
|
|
|
2524
2628
|
this.initialLoad.value = false;
|
|
2525
2629
|
this.loading.value = false;
|
|
2526
2630
|
}
|
|
2631
|
+
async refresh(hardRefresh = false) {
|
|
2632
|
+
await this.loadPageData(hardRefresh ? { disableCache: true } : void 0);
|
|
2633
|
+
}
|
|
2527
2634
|
// ============================================
|
|
2528
2635
|
// Expand/Collapse API
|
|
2529
2636
|
// ============================================
|
|
@@ -2564,6 +2671,28 @@ class CAPITreeServerDataProvider extends CTreeServerDataProvider {
|
|
|
2564
2671
|
if (options?.cacheStrategy) this.cacheStrategy.value = options.cacheStrategy;
|
|
2565
2672
|
if (options?.cacheLifetime) this.cacheLifetime.value = options.cacheLifetime;
|
|
2566
2673
|
if (options?.refreshOnMutation !== void 0) this.refreshOnMutation.value = options.refreshOnMutation;
|
|
2674
|
+
this.requestProvider.onDataReceived((data) => {
|
|
2675
|
+
if (data) {
|
|
2676
|
+
this.pageData.value = data.rows || data;
|
|
2677
|
+
if (data.rowCount !== void 0) {
|
|
2678
|
+
this.rowCount.value = data.rowCount;
|
|
2679
|
+
}
|
|
2680
|
+
}
|
|
2681
|
+
});
|
|
2682
|
+
}
|
|
2683
|
+
async refresh(hardRefresh = false) {
|
|
2684
|
+
if (hardRefresh && this.requestProvider.cacheProvider) {
|
|
2685
|
+
await this.requestProvider.cacheProvider.removeByPrefix(this.apiUrl.value);
|
|
2686
|
+
}
|
|
2687
|
+
this.loading.value = true;
|
|
2688
|
+
try {
|
|
2689
|
+
await this.loadPageData(hardRefresh ? { disableCache: true } : void 0);
|
|
2690
|
+
} finally {
|
|
2691
|
+
this.loading.value = false;
|
|
2692
|
+
}
|
|
2693
|
+
}
|
|
2694
|
+
async refreshData(options) {
|
|
2695
|
+
await this.refresh(options?.disableCache ?? false);
|
|
2567
2696
|
}
|
|
2568
2697
|
async setAPIUrl(url) {
|
|
2569
2698
|
this.apiUrl.value = url;
|
|
@@ -2605,7 +2734,7 @@ class CAPITreeServerDataProvider extends CTreeServerDataProvider {
|
|
|
2605
2734
|
if (this.requestProvider.cacheProvider) {
|
|
2606
2735
|
await this.requestProvider.cacheProvider.removeByPrefix(this.apiUrl.value);
|
|
2607
2736
|
}
|
|
2608
|
-
this.
|
|
2737
|
+
await this.refresh(true);
|
|
2609
2738
|
}
|
|
2610
2739
|
}
|
|
2611
2740
|
}
|