@swell/apps-sdk 1.0.96 → 1.0.97

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/src/api.d.ts CHANGED
@@ -29,13 +29,12 @@ export declare class Swell {
29
29
  * First attempts to fetch from cache.
30
30
  */
31
31
  getCachedResource<T>(key: string, args: unknown[], handler: () => T | Promise<T>): Promise<T | undefined>;
32
- updateCacheModified(cacheModified: string): Promise<void>;
33
32
  getAppSettings(): Promise<SwellData>;
34
33
  getStorefrontSettings(force?: boolean): Promise<SwellData>;
35
34
  getStorefrontMenus(): SwellMenu[];
36
35
  getStorefrontLocalization(): {
37
- currency: string;
38
36
  locale: string;
37
+ currency: string;
39
38
  };
40
39
  get<T = SwellData>(...args: Parameters<SwellBackendAPI['get']>): Promise<T | undefined>;
41
40
  put<T = SwellData>(...args: Parameters<SwellBackendAPI['put']>): Promise<T | undefined>;
@@ -56,7 +55,6 @@ export declare class Swell {
56
55
  * Caches client storefront API requests in memory.
57
56
  */
58
57
  private getRequestCache;
59
- private getCacheKey;
60
58
  }
61
59
  export declare class SwellBackendAPI {
62
60
  apiHost: string;
@@ -1,14 +1,24 @@
1
- import { type CreateCacheOptions } from 'cache-manager';
1
+ import { type CreateCacheOptions as OriginalCreateCacheOptions } from 'cache-manager';
2
+ import type { CFWorkerKV } from 'types/swell';
3
+ export type CreateCacheOptions = OriginalCreateCacheOptions & {
4
+ kvStore?: CFWorkerKV;
5
+ };
6
+ export declare const CF_KV_NAMESPACE = "THEME";
7
+ /**
8
+ * Cache supports memory or KV
9
+ * The KV layer supports namespacing and compression
10
+ */
2
11
  export declare class Cache {
3
12
  private client;
4
13
  constructor(options?: CreateCacheOptions);
5
14
  fetch<T>(key: string, fetchFn: () => T | Promise<T>): Promise<T>;
15
+ fetchSWR<T>(key: string, fetchFn: () => T | Promise<T>): Promise<T>;
6
16
  get<T>(key: string): Promise<T | null>;
7
17
  set<T>(key: string, value: T, ttl?: number): Promise<T>;
8
18
  flush(key: string): Promise<void>;
9
19
  /**
10
20
  * Flushes the entire cache.
11
- * Warning: If the cache store is shared among many cache clients,
21
+ * WARNING: If the cache store is shared among many cache clients,
12
22
  * this will flush entries for other clients.
13
23
  */
14
24
  flushAll(): Promise<void>;
@@ -1,4 +1,5 @@
1
+ import { type CreateCacheOptions } from './cache';
1
2
  import { Cache } from './cache';
2
3
  export declare class RequestCache extends Cache {
3
- constructor();
4
+ constructor(options?: CreateCacheOptions);
4
5
  }
@@ -1,5 +1,4 @@
1
- import { type CreateCacheOptions } from 'cache-manager';
2
- import { Cache } from './cache';
1
+ import { Cache, type CreateCacheOptions } from './cache';
3
2
  export declare class ResourceCache extends Cache {
4
3
  constructor(options?: CreateCacheOptions);
5
4
  }
@@ -1,9 +1,4 @@
1
- import type { CFWorkerKV } from 'types/swell';
2
- import { Cache } from './cache';
3
- /**
4
- * Theme cache is a 2-layer cache (memory, KV*)
5
- * The KV layer supports namespacing and compression.
6
- */
1
+ import { Cache, type CreateCacheOptions } from './cache';
7
2
  export declare class ThemeCache extends Cache {
8
- constructor(store?: CFWorkerKV);
3
+ constructor(options?: CreateCacheOptions);
9
4
  }
@@ -3,4 +3,4 @@ import type { ThemeEditorSchema, ThemePresetSchema, ThemeSectionSchemaData, Them
3
3
  export declare function convertShopifySettingsSchema(settingsSchema: ShopifySettingsSchema, locale: string): ThemeEditorSchema;
4
4
  export declare function convertShopifySettingsData(settingsData: ShopifySettingsData): ThemeSettings;
5
5
  export declare function convertShopifySettingsPresets(settingsData: ShopifySettingsData): ThemePresetSchema[];
6
- export declare function convertShopifySectionSchema(sectionSchema: ShopifySectionSchema, locale: string): ThemeSectionSchemaData;
6
+ export declare function convertShopifySectionSchema(sectionSchema: ShopifySectionSchema, locale?: string): ThemeSectionSchemaData;
@@ -1,4 +1,5 @@
1
1
  import { Swell } from '@/api';
2
+ import { ThemeCache } from '../cache';
2
3
  import type { SwellThemeConfig, SwellThemeVersion } from 'types/swell';
3
4
  /**
4
5
  * Responsible for loading a theme.
@@ -15,6 +16,10 @@ export declare class ThemeLoader {
15
16
  * Loads theme configs for this version.
16
17
  */
17
18
  loadTheme(): Promise<SwellThemeConfig[]>;
19
+ /**
20
+ * Returns the cache instance for this theme loader.
21
+ */
22
+ getCache(): ThemeCache;
18
23
  /**
19
24
  * Load theme configs from internal data, typically in the editor.
20
25
  */
@@ -67,5 +72,4 @@ export declare class ThemeLoader {
67
72
  * Generates a Swell API query filter for this theme version.
68
73
  */
69
74
  private themeVersionQueryFilter;
70
- private getCache;
71
75
  }
@@ -388,6 +388,7 @@ export interface ThemeSettingFieldSchema {
388
388
  params?: SwellData;
389
389
  limit?: number;
390
390
  role?: ShopifySettingRoleSchema;
391
+ conditions?: Record<string, any>;
391
392
  }
392
393
  export interface ThemeSettingSectionSchema {
393
394
  id?: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@swell/apps-sdk",
3
3
  "type": "module",
4
- "version": "1.0.96",
4
+ "version": "1.0.97",
5
5
  "description": "Swell SDK for building isomorphic apps.",
6
6
  "author": "Swell",
7
7
  "license": "MIT",