@swell/apps-sdk 1.0.35 → 1.0.37
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/eslint.config.d.mts +2 -0
- package/dist/index.cjs +13 -13
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +13 -13
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +13 -13
- package/dist/index.mjs.map +4 -4
- package/dist/src/api.d.ts +27 -36
- package/dist/src/cache/cache.d.ts +15 -0
- package/dist/src/cache/cf-worker-kv-keyv-adapter.d.ts +19 -0
- package/dist/src/cache/index.d.ts +5 -0
- package/dist/src/cache/request-cache.d.ts +4 -0
- package/dist/src/cache/resource-cache.d.ts +5 -0
- package/dist/src/cache/theme-cache.d.ts +9 -0
- package/dist/src/compatibility/shopify-configs.d.ts +2 -2
- package/dist/src/compatibility/shopify.d.ts +48 -2
- package/dist/src/easyblocks/utils.d.ts +3 -3
- package/dist/src/resources.d.ts +0 -1
- package/dist/src/theme.d.ts +34 -1
- package/dist/src/utils/index.d.ts +5 -2
- package/dist/types/shopify.d.ts +1 -1
- package/dist/types/swell.d.ts +5 -3
- package/package.json +30 -18
- package/dist/jest.config.d.ts +0 -14
- package/dist/src/cache.d.ts +0 -18
package/dist/src/api.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import SwellJS from 'swell-js';
|
|
2
|
-
import { Cache } from './cache';
|
|
3
|
-
export * from './resources';
|
|
4
2
|
import type { SwellAppConfig, SwellErrorOptions, SwellMenu, SwellData, CFThemeEnv, SwellAppShopifyCompatibilityConfig } from '../types/swell';
|
|
3
|
+
export * from './resources';
|
|
5
4
|
export declare class Swell {
|
|
6
5
|
url: URL;
|
|
7
6
|
headers: SwellData;
|
|
@@ -16,7 +15,6 @@ export declare class Swell {
|
|
|
16
15
|
isPreview: boolean;
|
|
17
16
|
isEditor: boolean;
|
|
18
17
|
sentResponse: boolean;
|
|
19
|
-
static cache: Map<string, Cache>;
|
|
20
18
|
storefront_url?: string;
|
|
21
19
|
constructor(params: {
|
|
22
20
|
url: URL | string;
|
|
@@ -36,40 +34,17 @@ export declare class Swell {
|
|
|
36
34
|
swellHeaders: SwellData;
|
|
37
35
|
};
|
|
38
36
|
static formatQueryParams(queryParams?: URLSearchParams | SwellData): SwellData;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
state: any;
|
|
50
|
-
menuState: any;
|
|
51
|
-
paymentState: any;
|
|
52
|
-
subscriptionState: any;
|
|
53
|
-
sessionState: any;
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
getStorefrontInstance(params: SwellData): typeof SwellJS;
|
|
57
|
-
isStorefrontRequestCacheable(method: string, url: string): boolean;
|
|
58
|
-
getCacheableStorefrontRequestHandler<T>(storefront: typeof SwellJS): (method: string, url: string, id?: any, data?: any, opt?: any) => T | Promise<T | undefined> | undefined;
|
|
59
|
-
getCacheInstance(): Cache;
|
|
60
|
-
setCacheValues(values: any[]): void;
|
|
61
|
-
getCacheKeyPrefix(): string;
|
|
62
|
-
getCacheKey(key: string, args?: unknown[]): string;
|
|
63
|
-
setCachedSync(key: string, args: unknown[], value: unknown, timeout?: number, isSync?: boolean): void | Promise<void>;
|
|
64
|
-
getCachedSync<T>(key: string, args?: unknown[] | (() => Promise<T> | T), handler?: () => Promise<T> | T, timeout?: number, isSync?: boolean): Promise<T | undefined> | T | undefined;
|
|
65
|
-
resolveCacheHandler<T>(cacheInstance: Cache, cacheKey: string, cacheHandler: () => Promise<T> | T, timeout?: number, isSync?: boolean): Promise<T> | T | undefined;
|
|
66
|
-
setCached(key: string, args: unknown[], value: unknown, timeout?: number): Promise<any>;
|
|
67
|
-
getCached<T>(key: string, args?: unknown[] | (() => Promise<T> | T), handler?: () => Promise<T> | T, timeout?: number): Promise<T | undefined>;
|
|
68
|
-
getCachedVersion<T>(key: string[], version: string, handler: () => Promise<T> | T, timeout?: number): Promise<T | undefined>;
|
|
69
|
-
getCachedResource<T>(key: string, args: unknown[] | (() => Promise<T>), handler?: () => Promise<T>, timeout?: number): Promise<T | undefined>;
|
|
37
|
+
/**
|
|
38
|
+
* Fetches a theme version resource
|
|
39
|
+
* First attempts to fetch from cache.
|
|
40
|
+
*/
|
|
41
|
+
getCachedThemeVersion<T>(key: string, version: string, handler: () => T | Promise<T>): Promise<T>;
|
|
42
|
+
/**
|
|
43
|
+
* Fetches a resource.
|
|
44
|
+
* First attempts to fetch from cache.
|
|
45
|
+
*/
|
|
46
|
+
getCachedResource<T>(key: string, args: unknown[], handler: () => T | Promise<T>): Promise<T | undefined>;
|
|
70
47
|
updateCacheModified(cacheModified: string): Promise<void>;
|
|
71
|
-
deleteCachedVersion(key: string): Promise<void>;
|
|
72
|
-
clearCache(prefix: string): Promise<void>;
|
|
73
48
|
getAppSettings(): Promise<SwellData>;
|
|
74
49
|
getStorefrontSettings(): Promise<SwellData>;
|
|
75
50
|
getStorefrontMenus(): SwellMenu[];
|
|
@@ -77,6 +52,22 @@ export declare class Swell {
|
|
|
77
52
|
put(...args: Parameters<SwellBackendAPI['put']>): Promise<SwellData | undefined>;
|
|
78
53
|
post(...args: Parameters<SwellBackendAPI['post']>): Promise<SwellData | undefined>;
|
|
79
54
|
delete(...args: Parameters<SwellBackendAPI['delete']>): Promise<SwellData | undefined>;
|
|
55
|
+
private getStorefrontInstance;
|
|
56
|
+
private isStorefrontRequestCacheable;
|
|
57
|
+
private getCacheableStorefrontRequestHandler;
|
|
58
|
+
/**
|
|
59
|
+
* Caches client theme in perstent cache + in memory.
|
|
60
|
+
*/
|
|
61
|
+
private getThemeCache;
|
|
62
|
+
/**
|
|
63
|
+
* Caches client resources in memory.
|
|
64
|
+
*/
|
|
65
|
+
private getResourceCache;
|
|
66
|
+
/**
|
|
67
|
+
* Caches client storefront API requests in memory.
|
|
68
|
+
*/
|
|
69
|
+
private getRequestCache;
|
|
70
|
+
private getCacheKey;
|
|
80
71
|
}
|
|
81
72
|
export declare class SwellBackendAPI {
|
|
82
73
|
apiHost: string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type CreateCacheOptions } from 'cache-manager';
|
|
2
|
+
export declare class Cache {
|
|
3
|
+
private client;
|
|
4
|
+
constructor(options?: CreateCacheOptions);
|
|
5
|
+
fetch<T>(key: string, fetchFn: () => T | Promise<T>): Promise<T>;
|
|
6
|
+
get<T>(key: string): Promise<T | null>;
|
|
7
|
+
set<T>(key: string, value: T, ttl?: number): Promise<T>;
|
|
8
|
+
flush(key: string): Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* Flushes the entire cache.
|
|
11
|
+
* Warning: If the cache store is shared among many cache clients,
|
|
12
|
+
* this will flush entries for other clients.
|
|
13
|
+
*/
|
|
14
|
+
flushAll(): Promise<void>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CFWorkerKV } from 'types/swell';
|
|
2
|
+
/**
|
|
3
|
+
* CloudFlare Workers KV adapter for Keyv.
|
|
4
|
+
* Includes namespacing to prevent conflicts within shared storage.
|
|
5
|
+
*/
|
|
6
|
+
export declare class CFWorkerKVKeyvAdapter {
|
|
7
|
+
private namespace;
|
|
8
|
+
private store;
|
|
9
|
+
constructor(namespace: string, store: CFWorkerKV);
|
|
10
|
+
has(key: string): Promise<boolean>;
|
|
11
|
+
get(key: string): Promise<any>;
|
|
12
|
+
set(key: string, value: any): Promise<any>;
|
|
13
|
+
delete(key: string): Promise<void>;
|
|
14
|
+
clear(): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Generates a namespaced cache key.
|
|
17
|
+
*/
|
|
18
|
+
private cacheKey;
|
|
19
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
*/
|
|
7
|
+
export declare class ThemeCache extends Cache {
|
|
8
|
+
constructor(namespace: string, store?: CFWorkerKV);
|
|
9
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ShopifySectionBlockSchema, ShopifySectionPresetSchema, ShopifySectionSchema, ShopifySettingSchema, ShopifySettingsData, ShopifySettingSection, ShopifySettingsSchema } from 'types/shopify';
|
|
2
|
-
import type { ThemeBlockSchema, ThemeEditorSchema, ThemePresetSchema,
|
|
2
|
+
import type { ThemeBlockSchema, ThemeEditorSchema, ThemePresetSchema, ThemeSectionSchemaData, ThemeSettingFieldSchema, ThemeSettings, ThemeSettingSectionSchema } from 'types/swell';
|
|
3
3
|
export declare function convertShopifySettingsSchema(settingsSchema: ShopifySettingsSchema): 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):
|
|
6
|
+
export declare function convertShopifySectionSchema(sectionSchema: ShopifySectionSchema): ThemeSectionSchemaData;
|
|
7
7
|
export declare function shopifySchemaBlockToSwellBlockSchema(block: ShopifySectionBlockSchema): ThemeBlockSchema;
|
|
8
8
|
export declare function shopifySchemaPresetToSwellPresetSchema(preset: ShopifySectionPresetSchema): ThemePresetSchema;
|
|
9
9
|
export declare function shopifySchemaSectionToSwellSettingSection(section: ShopifySettingSection): ThemeSettingSectionSchema;
|
|
@@ -3,7 +3,7 @@ import { SwellTheme } from '../theme';
|
|
|
3
3
|
import { ThemeFont } from '../liquid/font';
|
|
4
4
|
import { ThemeForm } from '../liquid/form';
|
|
5
5
|
import { ShopifyResource } from './shopify-objects';
|
|
6
|
-
import type { ThemeGlobals, ThemeSettings, ThemePresetSchema, ThemeEditorSchema,
|
|
6
|
+
import type { ThemeGlobals, ThemeSettings, ThemePresetSchema, ThemeEditorSchema, ThemeSectionSchemaData, SwellData, SwellMenu, SwellRecord, SwellAppShopifyCompatibilityConfig } from '../../types/swell';
|
|
7
7
|
import type { ShopifySettingsData, ShopifySettingsSchema, ShopifySectionSchema, ShopifyPageResourceMap, ShopifyObjectResourceMap, ShopifyFormResourceMap, ShopifyQueryParamsMap } from '../../types/shopify';
|
|
8
8
|
export declare class ShopifyCompatibility {
|
|
9
9
|
theme: SwellTheme;
|
|
@@ -19,6 +19,52 @@ export declare class ShopifyCompatibility {
|
|
|
19
19
|
shopifyCompatibilityConfig?: SwellAppShopifyCompatibilityConfig;
|
|
20
20
|
constructor(theme: SwellTheme);
|
|
21
21
|
adaptGlobals(globals: ThemeGlobals): void;
|
|
22
|
+
/**
|
|
23
|
+
* Extracts values from the form according to the passed settings config
|
|
24
|
+
*
|
|
25
|
+
* @input
|
|
26
|
+
* ```js
|
|
27
|
+
* form = {
|
|
28
|
+
* field1: { value: 'value1' },
|
|
29
|
+
* field2: { value: 'value2' },
|
|
30
|
+
* field3: { value: null },
|
|
31
|
+
* extra: { value: 'value3' },
|
|
32
|
+
* }
|
|
33
|
+
* config = {
|
|
34
|
+
* current: {
|
|
35
|
+
* field1: 'old1',
|
|
36
|
+
* field2: 'old2',
|
|
37
|
+
* field3: 'old3',
|
|
38
|
+
* field4: 'old4',
|
|
39
|
+
* },
|
|
40
|
+
* presets: {},
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @output
|
|
45
|
+
* ```js
|
|
46
|
+
* return {
|
|
47
|
+
* current: {
|
|
48
|
+
* field1: 'value1',
|
|
49
|
+
* field2: 'value2',
|
|
50
|
+
* field3: 'old3',
|
|
51
|
+
* field4: 'old4',
|
|
52
|
+
* },
|
|
53
|
+
* presets: {},
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
adaptSettings(form: Record<string, {
|
|
58
|
+
value: unknown;
|
|
59
|
+
} | undefined>, config: ShopifySettingsData): {
|
|
60
|
+
current: ThemeSettings;
|
|
61
|
+
presets: Record<string, Record<string, any>>;
|
|
62
|
+
} | {
|
|
63
|
+
current: string;
|
|
64
|
+
presets: {
|
|
65
|
+
[x: string]: Record<string, any> | ThemeSettings;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
22
68
|
adaptPageData(pageData: SwellData): void;
|
|
23
69
|
adaptObjectData(objectData: SwellData): void;
|
|
24
70
|
adaptQueryParams(): void;
|
|
@@ -36,7 +82,7 @@ export declare class ShopifyCompatibility {
|
|
|
36
82
|
getThemeConfig(settingsData: ShopifySettingsData): ThemeSettings;
|
|
37
83
|
getPresetsConfig(settingsData: ShopifySettingsData): ThemePresetSchema[];
|
|
38
84
|
getEditorConfig(settingsSchema: ShopifySettingsSchema): ThemeEditorSchema;
|
|
39
|
-
getSectionConfigSchema(sectionSchema: ShopifySectionSchema):
|
|
85
|
+
getSectionConfigSchema(sectionSchema: ShopifySectionSchema): ThemeSectionSchemaData;
|
|
40
86
|
getLocaleConfig(theme: SwellTheme, localeCode?: string, suffix?: string): Promise<any>;
|
|
41
87
|
getEditorLocaleConfig(theme: SwellTheme, localeCode: string): Promise<any>;
|
|
42
88
|
renderSchemaTranslations(theme: SwellTheme, schema: SwellData, localeCode?: string): Promise<any>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { SwellRecord, SwellThemeConfig, ThemeLayoutSectionGroupConfig, ThemeSectionConfig, ThemeSectionGroup, ThemeSectionSchema, ThemeSettingFieldSchema } from 'types/swell';
|
|
1
|
+
import type { SwellRecord, SwellThemeConfig, ThemeLayoutSectionGroupConfig, ThemeSectionConfig, ThemeSectionGroup, ThemeSectionSchema, ThemeSectionSchemaData, ThemeSettingFieldSchema } from 'types/swell';
|
|
2
2
|
import type { SwellTheme } from '../theme';
|
|
3
3
|
export declare function getAllSections(theme: SwellTheme, themeConfigs: SwellThemeConfig[]): Promise<ThemeSectionSchema[]>;
|
|
4
4
|
export declare function getPageSections(theme: SwellTheme, sectionGroup: ThemeSectionGroup | SwellRecord, getSectionSchemaHandler?: any): Promise<ThemeSectionConfig[]>;
|
|
5
5
|
export declare function getLayoutSectionGroups(theme: SwellTheme, themeConfigs: SwellThemeConfig[]): Promise<ThemeLayoutSectionGroupConfig[]>;
|
|
6
|
-
export declare function getSectionSchema(theme: SwellTheme, sectionName: string): Promise<
|
|
7
|
-
export declare function renderTemplateSchema(theme: SwellTheme, config: SwellThemeConfig): Promise<
|
|
6
|
+
export declare function getSectionSchema(theme: SwellTheme, sectionName: string): Promise<ThemeSectionSchemaData | undefined>;
|
|
7
|
+
export declare function renderTemplateSchema(theme: SwellTheme, config: SwellThemeConfig): Promise<ThemeSectionSchemaData | undefined>;
|
|
8
8
|
export declare function filterSectionConfig(config: SwellThemeConfig, themeConfigs: SwellThemeConfig[]): boolean;
|
|
9
9
|
export declare function filterAllLayoutSectionGroupConfigs(config: SwellThemeConfig, themeConfigs: SwellThemeConfig[]): boolean;
|
|
10
10
|
export declare function filterLayoutSectionGroupConfig(config: SwellThemeConfig, themeConfigs: SwellThemeConfig[], type: string): boolean;
|
package/dist/src/resources.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { ShopifyCompatibility } from './compatibility/shopify';
|
|
|
3
3
|
import type { SwellData, SwellRecord, SwellCollection, InferSwellCollection, SwellCollectionPages, StorefrontResourceGetter } from '../types/swell';
|
|
4
4
|
export declare const MAX_QUERY_PAGE_LIMIT = 100;
|
|
5
5
|
export declare const DEFAULT_QUERY_PAGE_LIMIT = 15;
|
|
6
|
-
export declare const CACHE_TIMEOUT_RESOURCES: number;
|
|
7
6
|
export declare class StorefrontResource<T extends SwellData = SwellData> {
|
|
8
7
|
_getter?: StorefrontResourceGetter<T>;
|
|
9
8
|
_getterHash?: string;
|
package/dist/src/theme.d.ts
CHANGED
|
@@ -55,6 +55,38 @@ export declare class SwellTheme {
|
|
|
55
55
|
serializeFormData(): SwellData | null;
|
|
56
56
|
setGlobalData(data?: SwellData): void;
|
|
57
57
|
serializeGlobalData(): SwellData | null;
|
|
58
|
+
/**
|
|
59
|
+
* Extracts values from the form according to the passed settings config
|
|
60
|
+
*
|
|
61
|
+
* @input
|
|
62
|
+
* ```js
|
|
63
|
+
* form = {
|
|
64
|
+
* field1: { value: 'value1' },
|
|
65
|
+
* field2: { value: 'value2' },
|
|
66
|
+
* field3: { value: null },
|
|
67
|
+
* extra: { value: 'value3' },
|
|
68
|
+
* }
|
|
69
|
+
* config = {
|
|
70
|
+
* field1: 'old1',
|
|
71
|
+
* field2: 'old2',
|
|
72
|
+
* field3: 'old3',
|
|
73
|
+
* field4: 'old4',
|
|
74
|
+
* }
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* @output
|
|
78
|
+
* ```js
|
|
79
|
+
* return {
|
|
80
|
+
* field1: 'value1',
|
|
81
|
+
* field2: 'value2',
|
|
82
|
+
* field3: 'old3',
|
|
83
|
+
* field4: 'old4',
|
|
84
|
+
* }
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
updateSettings(form: Record<string, {
|
|
88
|
+
value: unknown;
|
|
89
|
+
} | undefined>, config: object): ThemeSettings;
|
|
58
90
|
resolveTranslationLocale(translationsConfig: ThemeSettings, localeCode: string): any;
|
|
59
91
|
setCompatibilityConfigs(configs: ThemeConfigs, localeCode: string): Promise<void>;
|
|
60
92
|
setCompatibilityData(pageData: SwellData): void;
|
|
@@ -66,6 +98,7 @@ export declare class SwellTheme {
|
|
|
66
98
|
resolveUrlSetting(value: string): string;
|
|
67
99
|
themeConfigQuery(): Record<string, unknown>;
|
|
68
100
|
getAllThemeConfigs(): Promise<Map<string, SwellThemeConfig>>;
|
|
101
|
+
getPageConfigPath(pageId: string): string | null;
|
|
69
102
|
getThemeConfig(filePath: string): Promise<SwellThemeConfig | null>;
|
|
70
103
|
getThemeTemplateConfig(filePath: string): Promise<SwellThemeConfig | null>;
|
|
71
104
|
getThemeTemplateConfigByType(type: string, name: string): Promise<SwellThemeConfig | null>;
|
|
@@ -85,7 +118,7 @@ export declare class SwellTheme {
|
|
|
85
118
|
renderLayout(data?: SwellData): Promise<string>;
|
|
86
119
|
getContentForHeader(): string;
|
|
87
120
|
renderFontHeaderLinks(): string;
|
|
88
|
-
getTemplateSchema(config: SwellThemeConfig): Promise<
|
|
121
|
+
getTemplateSchema(config: SwellThemeConfig): Promise<ThemeSectionSchema | undefined>;
|
|
89
122
|
resolveSectionDefaultSettings(sectionSchema: ThemeSectionSchema, presetSchema?: ThemePresetSchema): Promise<SwellData>;
|
|
90
123
|
getAllSections(): Promise<ThemePageSectionSchema[]>;
|
|
91
124
|
getPageSections(sectionGroup: ThemeSectionGroup, resolveSettings?: boolean): Promise<ThemeSectionConfig[]>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { SwellData, SwellRecord, SwellThemeConfig, ThemeLayoutSectionGroupConfig, ThemePageSectionSchema, ThemeSectionConfig, ThemeSectionGroup, ThemeSectionSchema } from 'types/swell';
|
|
1
|
+
import type { SwellData, SwellRecord, SwellThemeConfig, ThemeLayoutSectionGroupConfig, ThemePageSectionSchema, ThemeSectionConfig, ThemeSectionGroup, ThemeSectionSchema, ThemeSettings } from 'types/swell';
|
|
2
2
|
export * from './md5';
|
|
3
3
|
export declare function themeConfigQuery(swellHeaders: Record<string, unknown>): Record<string, unknown>;
|
|
4
|
-
export declare function getAllSections(themeConfigs: Map<string, SwellThemeConfig>, renderTemplateSchema: (config: SwellThemeConfig) => Promise<
|
|
4
|
+
export declare function getAllSections(themeConfigs: Map<string, SwellThemeConfig>, renderTemplateSchema: (config: SwellThemeConfig) => Promise<ThemeSectionSchema | undefined>): Promise<ThemePageSectionSchema[]>;
|
|
5
5
|
export declare function getLayoutSectionGroups(allSections: Map<string, SwellThemeConfig>, renderTemplateSchema: (config: SwellThemeConfig) => Promise<Partial<ThemeSectionSchema> | undefined>): Promise<ThemeLayoutSectionGroupConfig[]>;
|
|
6
6
|
export declare function getPageSections(sectionGroup: ThemeSectionGroup | SwellRecord, getSchema: (type: string) => Promise<Partial<ThemeSectionSchema> | undefined>): Promise<ThemeSectionConfig[]>;
|
|
7
7
|
export declare function isArray(value: any): boolean;
|
|
@@ -18,5 +18,8 @@ export declare function dehydrateSwellRefsInStorefrontResources(obj: any): any;
|
|
|
18
18
|
export declare function resolveAsyncResources(response: any, resolveStorefrontResources?: boolean, resolveWithResourceMetadata?: boolean): Promise<any>;
|
|
19
19
|
export declare function stringifyQueryParams(queryParams: SwellData): string;
|
|
20
20
|
export declare function scopeCustomCSS(custom_css: string, sectionID: string): string;
|
|
21
|
+
export declare function extractSettingsFromForm(form: Record<string, {
|
|
22
|
+
value: unknown;
|
|
23
|
+
} | undefined>, preset: object): ThemeSettings;
|
|
21
24
|
export declare const SECTION_GROUP_CONTENT = "ContentSections";
|
|
22
25
|
export declare function getSectionGroupProp(sectionId: string): string;
|
package/dist/types/shopify.d.ts
CHANGED
|
@@ -53,7 +53,7 @@ export interface ShopifySettingSection {
|
|
|
53
53
|
}
|
|
54
54
|
export type ShopifySettingsSchema = Array<ShopifySettingSection>;
|
|
55
55
|
export interface ShopifySettingsData {
|
|
56
|
-
current: Record<string, any
|
|
56
|
+
current: Record<string, any> | string;
|
|
57
57
|
presets: Record<string, Record<string, any>>;
|
|
58
58
|
}
|
|
59
59
|
export interface ShopifySectionBlockSchema {
|
package/dist/types/swell.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export interface SwellAppShopifyCompatibilityConfig {
|
|
|
15
15
|
page_types: Record<string, string>;
|
|
16
16
|
page_routes: Record<string, {
|
|
17
17
|
page_id?: string;
|
|
18
|
-
} | string>;
|
|
18
|
+
} | string | null>;
|
|
19
19
|
page_resources: Array<{
|
|
20
20
|
page: string;
|
|
21
21
|
resources: Array<{
|
|
@@ -206,8 +206,7 @@ export interface ThemeSectionConfig {
|
|
|
206
206
|
blocks?: ThemeSettingsBlock[];
|
|
207
207
|
class?: string;
|
|
208
208
|
}
|
|
209
|
-
export interface
|
|
210
|
-
id: string;
|
|
209
|
+
export interface ThemeSectionSchemaData {
|
|
211
210
|
label: string;
|
|
212
211
|
fields: ThemeSettingFieldSchema[];
|
|
213
212
|
type?: string;
|
|
@@ -219,6 +218,9 @@ export interface ThemeSectionSchema {
|
|
|
219
218
|
presets?: ThemePresetSchema[];
|
|
220
219
|
default?: ShopifySettingSchema;
|
|
221
220
|
}
|
|
221
|
+
export interface ThemeSectionSchema extends ThemeSectionSchemaData {
|
|
222
|
+
id: string;
|
|
223
|
+
}
|
|
222
224
|
export type ThemeSettingBasicInputType = 'short_text' | 'long_text' | 'paragraph' | 'boolean' | 'number' | 'date' | 'select' | 'asset' | 'tags' | 'collection' | 'color' | 'color_scheme' | 'color_scheme_group' | 'font' | 'header' | 'lookup' | 'generic_lookup' | 'menu' | 'icon' | 'field_group';
|
|
223
225
|
export type ThemeSettingAliasInputType = 'text' | 'textarea' | 'rich_text' | 'asset' | 'phone' | 'email' | 'url' | 'slug' | 'basic_html' | 'rich_html' | 'markdown' | 'liquid' | 'checkbox' | 'toggle' | 'image' | 'document' | 'video' | 'radio' | 'dropdown' | 'checkboxes' | 'integer' | 'float' | 'currency' | 'percent' | 'slider' | 'time' | 'datetime' | 'child_collection' | 'product_lookup' | 'category_lookup' | 'customer_lookup';
|
|
224
226
|
export interface OptionItem {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swell/apps-sdk",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.37",
|
|
5
5
|
"description": "Swell SDK for building isomorphic apps.",
|
|
6
6
|
"author": "Swell",
|
|
7
7
|
"license": "MIT",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"types": "./types/index.d.ts",
|
|
20
20
|
"exports": {
|
|
21
21
|
".": {
|
|
22
|
+
"types": "./types/index.d.ts",
|
|
22
23
|
"require": "./dist/index.cjs",
|
|
23
|
-
"import": "./dist/index.mjs"
|
|
24
|
-
"types": "./types/index.d.ts"
|
|
24
|
+
"import": "./dist/index.mjs"
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
@@ -34,9 +34,25 @@
|
|
|
34
34
|
"postbuild": "tsc --project tsconfig.build.json",
|
|
35
35
|
"prepublishOnly": "npm i && npm run build",
|
|
36
36
|
"watch": "node scripts/build.mjs watch",
|
|
37
|
-
"test": "jest
|
|
37
|
+
"test": "jest"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@keyv/compress-brotli": "^2.0.3",
|
|
41
|
+
"@swell/easyblocks-core": "^1.0.10",
|
|
42
|
+
"@types/lodash": "^4.17.5",
|
|
43
|
+
"cache-manager": "^6.3.2",
|
|
44
|
+
"color": "^4.2.3",
|
|
45
|
+
"keyv": "^5.2.3",
|
|
46
|
+
"liquidjs": "^10.16.1",
|
|
47
|
+
"lodash": "^4.17.21",
|
|
48
|
+
"lodash-es": "^4.17.21",
|
|
49
|
+
"qs": "^6.12.3",
|
|
50
|
+
"quick-lru": "^7.0.0",
|
|
51
|
+
"strftime": "^0.10.3",
|
|
52
|
+
"swell-js": "^4.2.3"
|
|
38
53
|
},
|
|
39
54
|
"devDependencies": {
|
|
55
|
+
"@eslint/js": "^9.18.0",
|
|
40
56
|
"@kruining/waterlogged": "^1.1.45",
|
|
41
57
|
"@types/color": "^3.0.6",
|
|
42
58
|
"@types/jest": "29.5.14",
|
|
@@ -45,21 +61,17 @@
|
|
|
45
61
|
"@types/react": "^18.2.64",
|
|
46
62
|
"@types/react-dom": "^18.2.21",
|
|
47
63
|
"@types/strftime": "^0.9.8",
|
|
48
|
-
"esbuild": "0.
|
|
49
|
-
"esbuild-jest": "0.5.0",
|
|
64
|
+
"esbuild": "^0.24.2",
|
|
65
|
+
"esbuild-jest": "^0.5.0",
|
|
66
|
+
"eslint": "^9.18.0",
|
|
67
|
+
"eslint-config-prettier": "^10.0.1",
|
|
68
|
+
"eslint-plugin-jest": "^28.11.0",
|
|
69
|
+
"eslint-plugin-prettier": "^5.2.2",
|
|
50
70
|
"jest": "29.7.0",
|
|
71
|
+
"prettier": "^3.4.2",
|
|
51
72
|
"rimraf": "^6.0.1",
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
"@swell/easyblocks-core": "^1.0.10",
|
|
56
|
-
"@types/lodash": "^4.17.5",
|
|
57
|
-
"color": "^4.2.3",
|
|
58
|
-
"liquidjs": "^10.16.1",
|
|
59
|
-
"lodash": "^4.17.21",
|
|
60
|
-
"lodash-es": "^4.17.21",
|
|
61
|
-
"qs": "^6.12.3",
|
|
62
|
-
"strftime": "^0.10.3",
|
|
63
|
-
"swell-js": "^4.2.3"
|
|
73
|
+
"ts-jest": "^29.2.5",
|
|
74
|
+
"typescript": "^5.3.3",
|
|
75
|
+
"typescript-eslint": "^8.20.0"
|
|
64
76
|
}
|
|
65
77
|
}
|
package/dist/jest.config.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
declare namespace _default {
|
|
2
|
-
let roots: string[];
|
|
3
|
-
let transform: {
|
|
4
|
-
'^.+\\.(ts|js)$': string;
|
|
5
|
-
};
|
|
6
|
-
let testEnvironment: string;
|
|
7
|
-
let moduleFileExtensions: string[];
|
|
8
|
-
let moduleNameMapper: {
|
|
9
|
-
'^@/(.*)$': string;
|
|
10
|
-
};
|
|
11
|
-
let extensionsToTreatAsEsm: string[];
|
|
12
|
-
let transformIgnorePatterns: string[];
|
|
13
|
-
}
|
|
14
|
-
export default _default;
|
package/dist/src/cache.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { CFWorkerKV } from 'types/swell';
|
|
2
|
-
export declare class Cache {
|
|
3
|
-
private map;
|
|
4
|
-
private kvStore?;
|
|
5
|
-
private timeoutDefault;
|
|
6
|
-
constructor(kvStore?: CFWorkerKV, timeoutDefault?: number);
|
|
7
|
-
setValues(values: Array<[string, unknown]>): void;
|
|
8
|
-
getValues(): unknown[][];
|
|
9
|
-
get<T>(key: string): Promise<T | undefined>;
|
|
10
|
-
getSync<T>(key: string): T | undefined;
|
|
11
|
-
set(key: string, value: any, timeout?: number): Promise<void>;
|
|
12
|
-
setSync(key: string, value: any, timeout?: number): void;
|
|
13
|
-
delete(key: string): Promise<void>;
|
|
14
|
-
deleteSync(key: string): void;
|
|
15
|
-
has(key: string): Promise<boolean>;
|
|
16
|
-
hasSync(key: string): boolean;
|
|
17
|
-
clear(prefix?: string): Promise<void>;
|
|
18
|
-
}
|