@swell/apps-sdk 1.0.68 → 1.0.70
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 +48 -48
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +48 -48
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +48 -48
- package/dist/index.mjs.map +4 -4
- package/dist/src/api.d.ts +11 -22
- package/dist/src/compatibility/shopify-objects/filter.d.ts +3 -3
- package/dist/src/compatibility/shopify.d.ts +8 -10
- package/dist/src/theme.d.ts +13 -13
- package/dist/src/utils/index.d.ts +1 -1
- package/dist/types/shopify.d.ts +7 -1
- package/dist/types/swell.d.ts +99 -14
- package/package.json +2 -1
package/dist/src/api.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import SwellJS from 'swell-js';
|
|
2
|
-
import
|
|
2
|
+
import qs from 'qs';
|
|
3
|
+
import type { SwellApiParams, SwellAppConfig, SwellErrorOptions, SwellMenu, SwellData, CFThemeEnv, SwellAppShopifyCompatibilityConfig } from '../types/swell';
|
|
3
4
|
export * from './resources';
|
|
4
5
|
export declare class Swell {
|
|
5
6
|
url: URL;
|
|
6
|
-
headers:
|
|
7
|
-
swellHeaders:
|
|
8
|
-
queryParams:
|
|
7
|
+
headers: Record<string, string | undefined>;
|
|
8
|
+
swellHeaders: Record<string, string | undefined>;
|
|
9
|
+
queryParams: qs.ParsedQs;
|
|
9
10
|
workerEnv?: CFThemeEnv;
|
|
10
11
|
config?: SwellAppConfig;
|
|
11
12
|
shopifyCompatibilityConfig?: SwellAppShopifyCompatibilityConfig;
|
|
@@ -17,24 +18,12 @@ export declare class Swell {
|
|
|
17
18
|
isEditor: boolean;
|
|
18
19
|
sentResponse: boolean;
|
|
19
20
|
storefront_url?: string;
|
|
20
|
-
constructor(params:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
headers?: SwellData;
|
|
25
|
-
swellHeaders?: SwellData;
|
|
26
|
-
serverHeaders?: Headers | SwellData;
|
|
27
|
-
queryParams?: URLSearchParams | SwellData;
|
|
28
|
-
workerEnv?: CFThemeEnv;
|
|
29
|
-
getCookie?: (name: string) => string | undefined;
|
|
30
|
-
setCookie?: (name: string, value: string, options: any) => void;
|
|
31
|
-
[key: string]: any;
|
|
32
|
-
});
|
|
33
|
-
static formatHeaders(serverHeaders?: Headers | SwellData): {
|
|
34
|
-
headers: SwellData;
|
|
35
|
-
swellHeaders: SwellData;
|
|
21
|
+
constructor(params: SwellApiParams);
|
|
22
|
+
static formatHeaders(serverHeaders?: Headers | Record<string, string | undefined>): {
|
|
23
|
+
headers: Record<string, string | undefined>;
|
|
24
|
+
swellHeaders: Record<string, string | undefined>;
|
|
36
25
|
};
|
|
37
|
-
static formatQueryParams(queryParams?: URLSearchParams |
|
|
26
|
+
static formatQueryParams(queryParams?: URLSearchParams | Record<string, string | undefined>): qs.ParsedQs;
|
|
38
27
|
/**
|
|
39
28
|
* Fetches a resource.
|
|
40
29
|
* First attempts to fetch from cache.
|
|
@@ -73,7 +62,7 @@ export declare class SwellBackendAPI {
|
|
|
73
62
|
accessToken: string;
|
|
74
63
|
apiHost?: string;
|
|
75
64
|
});
|
|
76
|
-
makeRequest(method: string, url: string, data?: object): Promise<
|
|
65
|
+
makeRequest<T>(method: string, url: string, data?: object): Promise<T>;
|
|
77
66
|
stringifyQuery(queryObject: object, prefix?: string): string;
|
|
78
67
|
get(url: string, query?: SwellData): Promise<SwellData>;
|
|
79
68
|
put(url: string, data: SwellData): Promise<SwellData>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ShopifyCompatibility } from '../shopify';
|
|
2
2
|
import { ShopifyResource } from './resource';
|
|
3
|
-
import type {
|
|
4
|
-
export default function ShopifyFilter(instance: ShopifyCompatibility, filter:
|
|
5
|
-
export declare function ShopifyFilterValue(instance: ShopifyCompatibility, filterOption:
|
|
3
|
+
import type { SwellProductFilter, SwellProductFilterOption } from 'types/swell';
|
|
4
|
+
export default function ShopifyFilter(instance: ShopifyCompatibility, filter: SwellProductFilter): ShopifyResource;
|
|
5
|
+
export declare function ShopifyFilterValue(instance: ShopifyCompatibility, filterOption: SwellProductFilterOption, filter: SwellProductFilter, paramSuffix?: string): ShopifyResource;
|
|
@@ -3,8 +3,8 @@ import { ThemeFont } from '@/liquid/font';
|
|
|
3
3
|
import { ThemeForm } from '@/liquid/form';
|
|
4
4
|
import { SwellTheme } from '@/theme';
|
|
5
5
|
import { ShopifyResource } from './shopify-objects';
|
|
6
|
-
import type { ThemeGlobals, ThemeSettings, ThemePresetSchema, ThemeEditorSchema, ThemeSectionSchemaData, SwellData, SwellMenu,
|
|
7
|
-
import type { ShopifySettingsData, ShopifySettingsSchema, ShopifySectionSchema, ShopifyPageResourceMap, ShopifyObjectResourceMap, ShopifyFormResourceMap, ShopifyQueryParamsMap } from '../../types/shopify';
|
|
6
|
+
import type { ThemeGlobals, ThemeSettings, ThemePresetSchema, ThemeEditorSchema, ThemeSectionSchemaData, SwellData, SwellMenu, SwellAppShopifyCompatibilityConfig, SwellSettingsGeo } from '../../types/swell';
|
|
7
|
+
import type { ShopifySettingsData, ShopifySettingsSchema, ShopifySectionSchema, ShopifyPageResourceMap, ShopifyObjectResourceMap, ShopifyFormResourceMap, ShopifyQueryParamsMap, ShopifyLocalizationConfig } from '../../types/shopify';
|
|
8
8
|
export declare class ShopifyCompatibility {
|
|
9
9
|
theme: SwellTheme;
|
|
10
10
|
swell: Swell;
|
|
@@ -13,10 +13,8 @@ export declare class ShopifyCompatibility {
|
|
|
13
13
|
objectResourceMap: ShopifyObjectResourceMap;
|
|
14
14
|
formResourceMap: ShopifyFormResourceMap;
|
|
15
15
|
queryParamsMap: ShopifyQueryParamsMap;
|
|
16
|
-
editorLocaleConfig: {
|
|
17
|
-
[key: string]: any;
|
|
18
|
-
} | undefined;
|
|
19
16
|
shopifyCompatibilityConfig?: SwellAppShopifyCompatibilityConfig;
|
|
17
|
+
editorLocaleConfig?: Record<string, ShopifyLocalizationConfig | undefined>;
|
|
20
18
|
constructor(theme: SwellTheme);
|
|
21
19
|
adaptGlobals(globals: ThemeGlobals): void;
|
|
22
20
|
/**
|
|
@@ -83,10 +81,10 @@ export declare class ShopifyCompatibility {
|
|
|
83
81
|
getPresetsConfig(settingsData: ShopifySettingsData): ThemePresetSchema[];
|
|
84
82
|
getEditorConfig(settingsSchema: ShopifySettingsSchema): ThemeEditorSchema;
|
|
85
83
|
getSectionConfigSchema(sectionSchema: ShopifySectionSchema): ThemeSectionSchemaData;
|
|
86
|
-
getLocaleConfig(theme: SwellTheme, localeCode?: string, suffix?: string): Promise<
|
|
87
|
-
getEditorLocaleConfig(theme: SwellTheme, localeCode: string): Promise<
|
|
88
|
-
renderSchemaTranslations(theme: SwellTheme, schema:
|
|
89
|
-
renderSchemaTranslationValue(theme: SwellTheme, schemaValue:
|
|
84
|
+
getLocaleConfig(theme: SwellTheme, localeCode?: string, suffix?: string): Promise<ShopifyLocalizationConfig>;
|
|
85
|
+
getEditorLocaleConfig(theme: SwellTheme, localeCode: string): Promise<ShopifyLocalizationConfig>;
|
|
86
|
+
renderSchemaTranslations<T>(theme: SwellTheme, schema: T, localeCode?: string): Promise<T>;
|
|
87
|
+
renderSchemaTranslationValue<T>(theme: SwellTheme, schemaValue: T, localCode: string, editorLocaleConfig: ShopifyLocalizationConfig): Promise<T>;
|
|
90
88
|
getPageType(pageId: string): string;
|
|
91
89
|
getPageRouteUrl(pageId: string): string;
|
|
92
90
|
getPageRoutes(): {
|
|
@@ -115,7 +113,7 @@ export declare class ShopifyCompatibility {
|
|
|
115
113
|
getObjectResourceMap(): ShopifyObjectResourceMap;
|
|
116
114
|
getFormResourceMap(): ShopifyFormResourceMap;
|
|
117
115
|
getQueryParamsMap(): ShopifyQueryParamsMap;
|
|
118
|
-
getAllCountryOptionTags(geoSettings:
|
|
116
|
+
getAllCountryOptionTags(geoSettings: SwellSettingsGeo): string;
|
|
119
117
|
isScriptFormActionUrl(url: string): boolean;
|
|
120
118
|
isScriptUrl(url: string): boolean;
|
|
121
119
|
needRedirectToPageStart(formId: string): boolean;
|
package/dist/src/theme.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Swell, StorefrontResource, SwellStorefrontCollection, SwellStorefrontRecord, SwellStorefrontSingleton } from './api';
|
|
2
2
|
import { ShopifyCompatibility } from './compatibility/shopify';
|
|
3
3
|
import { LiquidSwell, ThemeFont, ThemeForm } from './liquid';
|
|
4
|
-
import type {
|
|
4
|
+
import type { FormatInput } from 'swell-js';
|
|
5
|
+
import type { ThemeGlobals, ThemeConfigs, ThemeSettings, ThemeResources, ThemeFormConfig, ThemeFormErrorMessages, ThemePresetSchema, ThemeSectionGroup, ThemeSectionGroupInfo, ThemeSectionSchema, ThemeSectionConfig, ThemeSectionSettings, ThemeSettingFieldSchema, ThemeSettingSectionSchema, ThemePageSectionSchema, ThemePageTemplateConfig, ThemeLayoutSectionGroupConfig, SwellData, SwellMenu, SwellRecord, SwellAppConfig, SwellThemeConfig, SwellThemeVersion, SwellAppStorefrontThemeProps, SwellAppShopifyCompatibilityConfig, SwellPageRequest, ThemePage } from 'types/swell';
|
|
5
6
|
export declare class SwellTheme {
|
|
6
7
|
swell: Swell;
|
|
7
8
|
props: SwellAppStorefrontThemeProps;
|
|
@@ -10,7 +11,7 @@ export declare class SwellTheme {
|
|
|
10
11
|
resources?: ThemeResources;
|
|
11
12
|
liquidSwell: LiquidSwell;
|
|
12
13
|
themeConfigs: Map<string, SwellThemeConfig> | null;
|
|
13
|
-
page
|
|
14
|
+
page?: ThemeSettings;
|
|
14
15
|
pageId: string | undefined;
|
|
15
16
|
shopifyCompatibility: ShopifyCompatibility | null;
|
|
16
17
|
shopifyCompatibilityClass: typeof ShopifyCompatibility;
|
|
@@ -33,11 +34,11 @@ export declare class SwellTheme {
|
|
|
33
34
|
geo: SwellData;
|
|
34
35
|
configs: ThemeConfigs;
|
|
35
36
|
}>;
|
|
36
|
-
resolvePageData(store: SwellData, configs:
|
|
37
|
+
resolvePageData(store: SwellData, configs: ThemeConfigs, session?: SwellData, pageId?: string): Promise<{
|
|
37
38
|
settings: ThemeSettings;
|
|
38
|
-
request:
|
|
39
|
-
page:
|
|
40
|
-
cart: SwellStorefrontSingleton |
|
|
39
|
+
request: SwellPageRequest;
|
|
40
|
+
page: ThemePage;
|
|
41
|
+
cart: SwellStorefrontSingleton | object;
|
|
41
42
|
account: SwellStorefrontSingleton | null;
|
|
42
43
|
customer?: SwellStorefrontSingleton | null;
|
|
43
44
|
}>;
|
|
@@ -88,7 +89,7 @@ export declare class SwellTheme {
|
|
|
88
89
|
updateSettings(form: Record<string, {
|
|
89
90
|
value: unknown;
|
|
90
91
|
} | undefined>, config: object): ThemeSettings;
|
|
91
|
-
resolveTranslationLocale(translationsConfig: ThemeSettings, localeCode: string):
|
|
92
|
+
resolveTranslationLocale(translationsConfig: ThemeSettings, localeCode: string): ThemeSettings;
|
|
92
93
|
setCompatibilityConfigs(configs: ThemeConfigs, localeCode: string): Promise<void>;
|
|
93
94
|
setCompatibilityData(pageData: SwellData): void;
|
|
94
95
|
resolveLookupSetting(setting: ThemeSettingFieldSchema, value: any): SwellData | SwellStorefrontRecord | SwellStorefrontCollection | null;
|
|
@@ -114,13 +115,13 @@ export declare class SwellTheme {
|
|
|
114
115
|
renderTemplateString(templateString: string, data?: SwellData): Promise<string>;
|
|
115
116
|
getSectionSchema(sectionName: string): Promise<Partial<ThemeSectionSchema> | undefined>;
|
|
116
117
|
getSectionConfigWithSchemaTagOnly(config: SwellThemeConfig): SwellThemeConfig | null;
|
|
118
|
+
renderThemeTemplate(filePath: `${string}.liquid`, data?: SwellData): Promise<string>;
|
|
119
|
+
renderThemeTemplate(filePath: `${string}.json`, data?: SwellData): Promise<ThemePageTemplateConfig>;
|
|
117
120
|
renderThemeTemplate(filePath: string, data?: SwellData): Promise<string | ThemePageTemplateConfig>;
|
|
118
121
|
renderLayoutTemplate(name: string, data?: SwellData): Promise<string>;
|
|
119
122
|
renderPageTemplate(name: string, data?: SwellData, altTemplateId?: string): Promise<string | ThemePageTemplateConfig>;
|
|
120
123
|
renderPage(pageData?: SwellData, altTemplateId?: string): Promise<string | ThemePageTemplateConfig>;
|
|
121
|
-
renderAllSections(sectionsIds: string | Array<string>, pageData?: SwellData): Promise<
|
|
122
|
-
[key: string]: string;
|
|
123
|
-
}>;
|
|
124
|
+
renderAllSections(sectionsIds: string | Array<string>, pageData?: SwellData): Promise<Record<string, string>>;
|
|
124
125
|
renderSection(sectionId: string, pageData?: SwellData): Promise<string | ThemePageTemplateConfig>;
|
|
125
126
|
renderLayout(data?: SwellData): Promise<string>;
|
|
126
127
|
getContentForHeader(): string;
|
|
@@ -146,12 +147,11 @@ export declare class SwellTheme {
|
|
|
146
147
|
renderTemplateSections(sectionGroup: ThemeSectionGroup, data?: SwellData): Promise<string>;
|
|
147
148
|
renderTranslation(key: string, data?: any, fallback?: string): Promise<string>;
|
|
148
149
|
renderTranslationValue(localeCode: string, langConfig: any, key: string, data?: any, fallback?: string): Promise<string>;
|
|
149
|
-
renderCurrency(amount: number, params
|
|
150
|
+
renderCurrency(amount: number, params?: FormatInput): string;
|
|
150
151
|
}
|
|
151
|
-
export declare class PageError {
|
|
152
|
+
export declare class PageError extends Error {
|
|
152
153
|
title: string;
|
|
153
154
|
status: number;
|
|
154
|
-
message: string;
|
|
155
155
|
description?: string;
|
|
156
156
|
constructor(title?: string | Error, status?: number, description?: string);
|
|
157
157
|
toString(): string;
|
|
@@ -16,7 +16,7 @@ export declare function removeCircularReferences(value: any): any;
|
|
|
16
16
|
export declare function dehydrateSwellRefsInStorefrontResources(obj: any): any;
|
|
17
17
|
export declare function resolveAsyncResources(response: any, resolveStorefrontResources?: boolean, resolveWithResourceMetadata?: boolean): Promise<any>;
|
|
18
18
|
export declare function stringifyQueryParams(queryParams: SwellData): string;
|
|
19
|
-
export declare function scopeCustomCSS(custom_css: string, sectionID: string): string;
|
|
19
|
+
export declare function scopeCustomCSS(custom_css: string | string[], sectionID: string): string;
|
|
20
20
|
export declare function extractSettingsFromForm(form: Record<string, {
|
|
21
21
|
value: unknown;
|
|
22
22
|
} | undefined>, preset: object): ThemeSettings;
|
package/dist/types/shopify.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { ShopifyResource } from '../src/compatibility/shopify-objects/resou
|
|
|
3
3
|
import type { ShopifyCompatibility } from '../src/compatibility/shopify';
|
|
4
4
|
import type { StorefrontResource } from '../src/resources';
|
|
5
5
|
export type ShopifyBasicInputType = 'text' | 'textarea' | 'select' | 'checkbox' | 'radio' | 'number' | 'range';
|
|
6
|
-
export type ShopifySpecializedInputType = 'article' | 'blog' | 'collection' | 'collection_list' | 'color' | 'color_background' | 'color_scheme' | 'color_scheme_group' | 'font_picker' | 'header' | 'paragraph' | 'html' | 'image_picker' | 'inline_richtext' | 'link_list' | 'liquid' | 'page' | '
|
|
6
|
+
export type ShopifySpecializedInputType = 'article' | 'blog' | 'collection' | 'collection_list' | 'color' | 'color_background' | 'color_scheme' | 'color_scheme_group' | 'font_picker' | 'header' | 'paragraph' | 'html' | 'image_picker' | 'inline_richtext' | 'link_list' | 'liquid' | 'page' | 'product' | 'product_list' | 'richtext' | 'text_alignment' | 'url' | 'video' | 'video_url';
|
|
7
7
|
export interface ShopifyBgStyleSchema {
|
|
8
8
|
solid: string;
|
|
9
9
|
gradient: string;
|
|
@@ -123,4 +123,10 @@ export interface ShopifyQueryParams {
|
|
|
123
123
|
to: string | ((param: string, value: string) => SwellData);
|
|
124
124
|
}
|
|
125
125
|
export type ShopifyQueryParamsMap = Array<ShopifyQueryParams>;
|
|
126
|
+
export interface ShopifyLocalizationSection {
|
|
127
|
+
[key: string]: string | ShopifyLocalizationSection;
|
|
128
|
+
}
|
|
129
|
+
export interface ShopifyLocalizationConfig {
|
|
130
|
+
[key: string]: ShopifyLocalizationSection;
|
|
131
|
+
}
|
|
126
132
|
export {};
|
package/dist/types/swell.d.ts
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
|
+
import type { FormatInput } from 'swell-js';
|
|
1
2
|
import type { SwellStorefrontRecord, SwellStorefrontResource } from '../src/resources';
|
|
2
3
|
import type { Swell, SwellStorefrontCollection, StorefrontResource } from '../src/api';
|
|
3
|
-
import type { ShopifySettingSchema } from './shopify';
|
|
4
|
+
import type { ShopifySettingSchema, ShopifySettingsData, ShopifySettingsSchema } from './shopify';
|
|
5
|
+
export interface SwellApiParams {
|
|
6
|
+
url: URL | string;
|
|
7
|
+
config?: SwellAppConfig;
|
|
8
|
+
shopifyCompatibilityConfig?: SwellAppShopifyCompatibilityConfig;
|
|
9
|
+
headers?: Record<string, string | undefined>;
|
|
10
|
+
swellHeaders?: Record<string, string | undefined>;
|
|
11
|
+
serverHeaders?: Headers | Record<string, string | undefined>;
|
|
12
|
+
queryParams?: URLSearchParams | Record<string, string | undefined>;
|
|
13
|
+
workerEnv?: CFThemeEnv;
|
|
14
|
+
isEditor?: boolean;
|
|
15
|
+
getCookie?: (name: string) => string | undefined;
|
|
16
|
+
setCookie?: (name: string, value: string, options: object | undefined, swell: Swell) => void;
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
}
|
|
4
19
|
export interface SwellAppConfig {
|
|
5
20
|
id: string;
|
|
6
21
|
name: string;
|
|
@@ -62,6 +77,58 @@ export interface SwellAppStorefrontThemeResources {
|
|
|
62
77
|
singletons: Record<string, string>;
|
|
63
78
|
records: Record<string, string>;
|
|
64
79
|
}
|
|
80
|
+
export interface SwellSettingsGeoItem {
|
|
81
|
+
id: string;
|
|
82
|
+
name: string;
|
|
83
|
+
}
|
|
84
|
+
export interface SwellSettingsGeoCountry extends SwellSettingsGeoItem {
|
|
85
|
+
state_label?: string;
|
|
86
|
+
}
|
|
87
|
+
export interface SwellSettingsGeoState extends SwellSettingsGeoItem {
|
|
88
|
+
country: string;
|
|
89
|
+
}
|
|
90
|
+
export type SwellSettingsGeoTimezone = SwellSettingsGeoItem;
|
|
91
|
+
export type SwellSettingsGeoCurrency = SwellSettingsGeoItem;
|
|
92
|
+
export type SwellSettingsGeoLocale = SwellSettingsGeoItem;
|
|
93
|
+
export interface SwellSettingsGeo {
|
|
94
|
+
id: 'geo';
|
|
95
|
+
countries: SwellSettingsGeoCountry[];
|
|
96
|
+
currencies: SwellSettingsGeoCurrency[];
|
|
97
|
+
locales: SwellSettingsGeoLocale[];
|
|
98
|
+
states: SwellSettingsGeoState[];
|
|
99
|
+
timezones: SwellSettingsGeoTimezone[];
|
|
100
|
+
}
|
|
101
|
+
export interface SwellPageRequest {
|
|
102
|
+
host: string;
|
|
103
|
+
origin: string;
|
|
104
|
+
path: string;
|
|
105
|
+
query: QueryParams;
|
|
106
|
+
locale: string;
|
|
107
|
+
currency: string;
|
|
108
|
+
is_editor: boolean;
|
|
109
|
+
is_preview: boolean;
|
|
110
|
+
design_mode?: boolean;
|
|
111
|
+
visual_section_preview?: boolean;
|
|
112
|
+
page_type?: string;
|
|
113
|
+
}
|
|
114
|
+
export interface SwellProductFilterOption {
|
|
115
|
+
value: unknown;
|
|
116
|
+
label?: string;
|
|
117
|
+
count?: number;
|
|
118
|
+
active?: boolean;
|
|
119
|
+
}
|
|
120
|
+
export interface SwellProductFilter {
|
|
121
|
+
id: string;
|
|
122
|
+
label: string;
|
|
123
|
+
type: string;
|
|
124
|
+
options?: SwellProductFilterOption[];
|
|
125
|
+
interval?: number;
|
|
126
|
+
range_min?: number;
|
|
127
|
+
range_max?: number;
|
|
128
|
+
param_name: string;
|
|
129
|
+
active_options?: SwellProductFilterOption[];
|
|
130
|
+
inactive_options?: SwellProductFilterOption[];
|
|
131
|
+
}
|
|
65
132
|
export interface SwellErrorOptions {
|
|
66
133
|
status?: number;
|
|
67
134
|
method?: string;
|
|
@@ -118,7 +185,7 @@ export declare enum SwellMenuItemType {
|
|
|
118
185
|
Category = "category",
|
|
119
186
|
Page = "page",
|
|
120
187
|
Blog = "blog",
|
|
121
|
-
|
|
188
|
+
BlogCategory = "blog_category",
|
|
122
189
|
Content = "content",
|
|
123
190
|
ContentList = "content_list",
|
|
124
191
|
Url = "url",
|
|
@@ -139,6 +206,7 @@ export interface SwellMenuItem {
|
|
|
139
206
|
child_current?: boolean;
|
|
140
207
|
child_active?: boolean;
|
|
141
208
|
}
|
|
209
|
+
export type QueryParams = import('qs').ParsedQs;
|
|
142
210
|
export type StorefrontResourceGetter<T extends SwellData = SwellData> = (this: SwellStorefrontResource<T>) => Promise<T | null> | T | null;
|
|
143
211
|
export interface ThemeSettings {
|
|
144
212
|
[key: string]: any;
|
|
@@ -154,20 +222,42 @@ export interface ThemeSectionBase {
|
|
|
154
222
|
settings: ThemeSettings;
|
|
155
223
|
blocks?: ThemeSettingsBlock[];
|
|
156
224
|
block_order?: string[];
|
|
157
|
-
custom_css?: string;
|
|
225
|
+
custom_css?: string | string[];
|
|
158
226
|
disabled?: boolean;
|
|
159
227
|
}
|
|
160
228
|
export interface ThemeSectionSettings extends ThemeSettings {
|
|
161
229
|
section: ThemeSectionBase;
|
|
162
230
|
}
|
|
163
|
-
export
|
|
231
|
+
export interface ThemePageSchema {
|
|
232
|
+
layout?: string;
|
|
233
|
+
page?: {
|
|
234
|
+
slug?: string;
|
|
235
|
+
label?: string;
|
|
236
|
+
description?: string;
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
interface ThemePageAdditionalProps {
|
|
240
|
+
description?: string;
|
|
241
|
+
current: number;
|
|
242
|
+
label: string;
|
|
243
|
+
slug?: string;
|
|
244
|
+
}
|
|
245
|
+
export interface ThemeCustomPage extends ThemePageAdditionalProps {
|
|
246
|
+
custom: true;
|
|
247
|
+
id: string;
|
|
248
|
+
}
|
|
249
|
+
export interface ThemeSwellPage extends SwellAppStorefrontThemePage, ThemePageAdditionalProps {
|
|
250
|
+
custom: false;
|
|
251
|
+
}
|
|
252
|
+
export type ThemePage = ThemeSwellPage | ThemeCustomPage;
|
|
164
253
|
export interface ThemeGlobals extends SwellData {
|
|
165
254
|
store: SwellData;
|
|
166
|
-
request:
|
|
255
|
+
request: SwellPageRequest;
|
|
167
256
|
settings: ThemeSettings;
|
|
168
257
|
page: ThemePage;
|
|
169
258
|
configs: ThemeConfigs;
|
|
170
259
|
menus?: Record<string, SwellMenu>;
|
|
260
|
+
translations: Record<string, unknown>;
|
|
171
261
|
[key: string]: any;
|
|
172
262
|
}
|
|
173
263
|
export interface ThemeConfigs {
|
|
@@ -176,8 +266,8 @@ export interface ThemeConfigs {
|
|
|
176
266
|
presets: ThemePresetSchema[];
|
|
177
267
|
translations: ThemeSettings;
|
|
178
268
|
[key: string]: any;
|
|
179
|
-
settings_schema?:
|
|
180
|
-
settings_data?:
|
|
269
|
+
settings_schema?: ShopifySettingsSchema;
|
|
270
|
+
settings_data?: ShopifySettingsData;
|
|
181
271
|
}
|
|
182
272
|
export interface ThemeResourceFactory {
|
|
183
273
|
new (swell: Swell): StorefrontResource;
|
|
@@ -208,6 +298,7 @@ export interface ThemeSection {
|
|
|
208
298
|
interface ThemeSectionGroupBase {
|
|
209
299
|
id?: string;
|
|
210
300
|
type?: string;
|
|
301
|
+
name?: string;
|
|
211
302
|
order?: string[];
|
|
212
303
|
}
|
|
213
304
|
export interface ThemeSectionGroup extends ThemeSectionGroupBase {
|
|
@@ -342,13 +433,7 @@ export type RenderTemplate = (config: SwellThemeConfig | null, data?: SwellData)
|
|
|
342
433
|
export type RenderTemplateString = (templateString: string, data?: SwellData) => Promise<string>;
|
|
343
434
|
export type RenderTemplateSections = (sections: ThemeSectionGroup, data?: SwellData) => Promise<string>;
|
|
344
435
|
export type RenderTranslation = (key: string, data?: unknown, locale?: string) => Promise<string>;
|
|
345
|
-
|
|
346
|
-
code?: string;
|
|
347
|
-
rate?: number;
|
|
348
|
-
locale?: string;
|
|
349
|
-
decimals?: number;
|
|
350
|
-
}
|
|
351
|
-
export type RenderCurrency = (amount: number, params?: RenderCurrencyParams) => string;
|
|
436
|
+
export type RenderCurrency = (amount: number, params?: FormatInput) => string;
|
|
352
437
|
export type ResolveFilePath = (fileName: string, extName?: string) => string;
|
|
353
438
|
export interface ThemeFontConfig {
|
|
354
439
|
family: 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.
|
|
4
|
+
"version": "1.0.70",
|
|
5
5
|
"description": "Swell SDK for building isomorphic apps.",
|
|
6
6
|
"author": "Swell",
|
|
7
7
|
"license": "MIT",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"prebuild": "rimraf dist",
|
|
33
33
|
"build": "node scripts/build.mjs",
|
|
34
34
|
"postbuild": "tsc --project tsconfig.build.json",
|
|
35
|
+
"prepare": "git config core.hooksPath .git-hooks || echo 'Not in a git repo'",
|
|
35
36
|
"prepublishOnly": "npm i && npm run build",
|
|
36
37
|
"watch": "node scripts/build.mjs watch",
|
|
37
38
|
"test": "jest --silent"
|