complexqa_frontend_core 1.18.6 → 1.18.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "complexqa_frontend_core",
3
- "version": "1.18.6",
3
+ "version": "1.18.7",
4
4
  "description": "core of web ",
5
5
  "type": "module",
6
6
  "exports": {
@@ -67,6 +67,32 @@ export function isDefaultSearchPayload(payload)
67
67
  }
68
68
 
69
69
 
70
+ /**
71
+ * @param {{ response: Promise<*>|*, payload: * }} result
72
+ * @returns {Promise<{ response: *, payload: * }>}
73
+ */
74
+ async function materializeSearchResult(result)
75
+ {
76
+ return {
77
+ response: await result.response,
78
+ payload : result.payload,
79
+ };
80
+ }
81
+
82
+
83
+ /**
84
+ * @param {{ response: *, payload: * }} result
85
+ * @returns {{ response: Promise<*>, payload: * }}
86
+ */
87
+ function wrapSearchResult(result)
88
+ {
89
+ return {
90
+ response: Promise.resolve(result.response),
91
+ payload : result.payload,
92
+ };
93
+ }
94
+
95
+
70
96
  /**
71
97
  * @param {object} apiInstance
72
98
  * @param {string} methodName
@@ -100,11 +126,13 @@ export async function resolveCachedSearch(
100
126
 
101
127
  if (cached !== undefined)
102
128
  {
103
- return Promise.resolve(clone_object(cached));
129
+ return wrapSearchResult(clone_object(cached));
104
130
  }
105
131
 
106
- const result = await searchFn(payload);
107
- cacheStore.set(cacheKey, clone_object(result), ttlMs);
132
+ const result = await searchFn(payload);
133
+ const materialized = await materializeSearchResult(result);
134
+
135
+ cacheStore.set(cacheKey, clone_object(materialized), ttlMs);
108
136
 
109
- return result;
137
+ return wrapSearchResult(materialized);
110
138
  }