@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.mjs CHANGED
@@ -5070,12 +5070,27 @@ var Swell = class _Swell {
5070
5070
  shouldBypassCache() {
5071
5071
  return this.headers?.["x-cache-bypass"] === "revalidation";
5072
5072
  }
5073
+ /**
5074
+ * Returns fields from the current account that may affect requests.
5075
+ * Currently, only the 'group' field is returned.
5076
+ * 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
5077
+ * This increases the overall cache size
5078
+ */
5079
+ getAccountCacheKey() {
5080
+ const storefrontContext = this.storefrontContext;
5081
+ const group = storefrontContext?.account?.group || "";
5082
+ return `${group}`;
5083
+ }
5073
5084
  /**
5074
5085
  * Fetches a resource.
5075
5086
  * First attempts to fetch from cache.
5076
5087
  */
5077
5088
  async getCachedResource(key, args, handler, isCacheble = true) {
5078
- const cacheKey = getCacheKey(key, [this.instanceId, args]);
5089
+ const cacheKey = getCacheKey(key, [
5090
+ this.instanceId,
5091
+ this.getAccountCacheKey(),
5092
+ args
5093
+ ]);
5079
5094
  const cache = this.getResourceCache();
5080
5095
  if (this.shouldBypassCache()) {
5081
5096
  return cache.fetch(cacheKey, handler, void 0, isCacheble);
@@ -5242,6 +5257,7 @@ var Swell = class _Swell {
5242
5257
  if (this.isStorefrontRequestCacheable(method, url, opt)) {
5243
5258
  const key = getCacheKey("request", [
5244
5259
  this.instanceId,
5260
+ this.getAccountCacheKey(),
5245
5261
  method,
5246
5262
  url,
5247
5263
  id,
@@ -17872,7 +17888,8 @@ var SwellTheme3 = class {
17872
17888
  presets: [],
17873
17889
  ...Array.from(settingConfigs.values()).reduce(
17874
17890
  (acc, config) => {
17875
- const configName = String(config?.name || "").split(".")[0];
17891
+ const fileName = config?.file_path?.split("/").pop() || "";
17892
+ const configName = fileName.split(".")[0];
17876
17893
  if (configName && config?.file_data) {
17877
17894
  let configValue;
17878
17895
  try {