@swell/apps-sdk 1.0.188 → 1.0.190
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 +19 -2
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +19 -2
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +19 -2
- package/dist/index.mjs.map +2 -2
- package/dist/src/api.d.ts +7 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5097,12 +5097,27 @@
|
|
|
5097
5097
|
shouldBypassCache() {
|
|
5098
5098
|
return this.headers?.["x-cache-bypass"] === "revalidation";
|
|
5099
5099
|
}
|
|
5100
|
+
/**
|
|
5101
|
+
* Returns fields from the current account that may affect requests.
|
|
5102
|
+
* Currently, only the 'group' field is returned.
|
|
5103
|
+
* It is preferable to use the account_id from storefrontContext rather than the swell-session cookie, as the cookie contains a lot of other data
|
|
5104
|
+
* This increases the overall cache size
|
|
5105
|
+
*/
|
|
5106
|
+
getAccountCacheKey() {
|
|
5107
|
+
const storefrontContext = this.storefrontContext;
|
|
5108
|
+
const group = storefrontContext?.account?.group || "";
|
|
5109
|
+
return `${group}`;
|
|
5110
|
+
}
|
|
5100
5111
|
/**
|
|
5101
5112
|
* Fetches a resource.
|
|
5102
5113
|
* First attempts to fetch from cache.
|
|
5103
5114
|
*/
|
|
5104
5115
|
async getCachedResource(key, args, handler, isCacheble = true) {
|
|
5105
|
-
const cacheKey = getCacheKey(key, [
|
|
5116
|
+
const cacheKey = getCacheKey(key, [
|
|
5117
|
+
this.instanceId,
|
|
5118
|
+
this.getAccountCacheKey(),
|
|
5119
|
+
args
|
|
5120
|
+
]);
|
|
5106
5121
|
const cache = this.getResourceCache();
|
|
5107
5122
|
if (this.shouldBypassCache()) {
|
|
5108
5123
|
return cache.fetch(cacheKey, handler, void 0, isCacheble);
|
|
@@ -5269,6 +5284,7 @@
|
|
|
5269
5284
|
if (this.isStorefrontRequestCacheable(method, url, opt)) {
|
|
5270
5285
|
const key = getCacheKey("request", [
|
|
5271
5286
|
this.instanceId,
|
|
5287
|
+
this.getAccountCacheKey(),
|
|
5272
5288
|
method,
|
|
5273
5289
|
url,
|
|
5274
5290
|
id,
|
|
@@ -17891,7 +17907,8 @@ ${injects.join("\n")}<\/script>`;
|
|
|
17891
17907
|
presets: [],
|
|
17892
17908
|
...Array.from(settingConfigs.values()).reduce(
|
|
17893
17909
|
(acc, config) => {
|
|
17894
|
-
const
|
|
17910
|
+
const fileName = config?.file_path?.split("/").pop() || "";
|
|
17911
|
+
const configName = fileName.split(".")[0];
|
|
17895
17912
|
if (configName && config?.file_data) {
|
|
17896
17913
|
let configValue;
|
|
17897
17914
|
try {
|