ag-common 0.0.127 → 0.0.128
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.
|
@@ -41,16 +41,18 @@ const callOpenApiCachedRaw = (p) => {
|
|
|
41
41
|
if (!callOpenApiCache) {
|
|
42
42
|
callOpenApiCache = new node_cache_1.default({ stdTTL: p.cacheTtl || 120 });
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
//get ssr cache value
|
|
45
|
+
const ssrCached = (_c = (_b = (_a = p.ssrCacheItems) === null || _a === void 0 ? void 0 : _a.find((s) => s.cacheKey === p.cacheKey)) === null || _b === void 0 ? void 0 : _b.prefillData) === null || _c === void 0 ? void 0 : _c.data;
|
|
46
|
+
//if we have ssr cache and there is no existing cache then set
|
|
47
|
+
if (!callOpenApiCache.get(userPrefixedCacheKey) && ssrCached) {
|
|
48
|
+
callOpenApiCache.set(userPrefixedCacheKey, ssrCached);
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
//return cached data, or ssr data if that has already expired (ttl <=0)
|
|
51
|
+
const data = callOpenApiCache.get(userPrefixedCacheKey) || ssrCached;
|
|
52
|
+
if (!data) {
|
|
53
|
+
return undefined;
|
|
52
54
|
}
|
|
53
|
-
return
|
|
55
|
+
return { data };
|
|
54
56
|
};
|
|
55
57
|
exports.callOpenApiCachedRaw = callOpenApiCachedRaw;
|
|
56
58
|
const callOpenApiCached = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.useCallOpenApi = void 0;
|
|
13
13
|
const react_1 = require("react");
|
|
14
14
|
const cached_1 = require("./cached");
|
|
15
|
+
const direct_1 = require("./direct");
|
|
15
16
|
/**
|
|
16
17
|
* hooks+cached call to callOpenApi
|
|
17
18
|
* @param p
|
|
@@ -33,7 +34,7 @@ const useCallOpenApi = (p) => {
|
|
|
33
34
|
(0, react_1.useEffect)(() => {
|
|
34
35
|
function run() {
|
|
35
36
|
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
const resp = yield (0,
|
|
37
|
+
const resp = yield (0, direct_1.callOpenApi)(p);
|
|
37
38
|
setData((d) => (Object.assign(Object.assign({}, resp), { loaded: true, loading: false, loadcount: d.loadcount + 1, reFetch: () => __awaiter(this, void 0, void 0, function* () { }), url: '', datetime: new Date().getTime() })));
|
|
38
39
|
});
|
|
39
40
|
}
|