@swell/apps-sdk 1.0.24 → 1.0.29

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.
Files changed (190) hide show
  1. package/dist/index.cjs +43 -0
  2. package/dist/index.cjs.map +7 -0
  3. package/dist/index.js +43 -0
  4. package/dist/index.js.map +7 -0
  5. package/dist/index.mjs +43 -0
  6. package/dist/index.mjs.map +7 -0
  7. package/dist/jest.config.d.ts +14 -0
  8. package/dist/src/api.d.ts +99 -0
  9. package/dist/src/cache.d.ts +18 -0
  10. package/dist/src/categories.d.ts +5 -0
  11. package/dist/src/compatibility/shopify-configs.d.ts +10 -0
  12. package/dist/src/compatibility/shopify-fonts.d.ts +1 -0
  13. package/dist/src/compatibility/shopify-objects/address.d.ts +6 -0
  14. package/dist/src/compatibility/shopify-objects/article.d.ts +5 -0
  15. package/dist/src/compatibility/shopify-objects/blog.d.ts +5 -0
  16. package/dist/src/compatibility/shopify-objects/cart.d.ts +5 -0
  17. package/dist/src/compatibility/shopify-objects/collection.d.ts +5 -0
  18. package/dist/src/compatibility/shopify-objects/collections.d.ts +11 -0
  19. package/dist/src/compatibility/shopify-objects/customer.d.ts +5 -0
  20. package/dist/src/compatibility/shopify-objects/filter.d.ts +5 -0
  21. package/dist/src/compatibility/shopify-objects/font.d.ts +4 -0
  22. package/dist/src/compatibility/shopify-objects/form.d.ts +28 -0
  23. package/dist/src/compatibility/shopify-objects/image.d.ts +6 -0
  24. package/dist/src/compatibility/shopify-objects/index.d.ts +26 -0
  25. package/dist/src/compatibility/shopify-objects/line_item.d.ts +6 -0
  26. package/dist/src/compatibility/shopify-objects/link.d.ts +4 -0
  27. package/dist/src/compatibility/shopify-objects/localization.d.ts +4 -0
  28. package/dist/src/compatibility/shopify-objects/media.d.ts +4 -0
  29. package/dist/src/compatibility/shopify-objects/order.d.ts +10 -0
  30. package/dist/src/compatibility/shopify-objects/page.d.ts +4 -0
  31. package/dist/src/compatibility/shopify-objects/paginate.d.ts +4 -0
  32. package/dist/src/compatibility/shopify-objects/predictive_search.d.ts +4 -0
  33. package/dist/src/compatibility/shopify-objects/product.d.ts +6 -0
  34. package/dist/src/compatibility/shopify-objects/resource.d.ts +23 -0
  35. package/dist/src/compatibility/shopify-objects/search.d.ts +4 -0
  36. package/dist/src/compatibility/shopify-objects/shop.d.ts +4 -0
  37. package/dist/src/compatibility/shopify-objects/variant.d.ts +5 -0
  38. package/dist/src/compatibility/shopify.d.ts +73 -0
  39. package/dist/src/constants.d.ts +1 -0
  40. package/dist/src/content.d.ts +8 -0
  41. package/dist/src/easyblocks/config.d.ts +140 -0
  42. package/dist/src/easyblocks/index.d.ts +2 -0
  43. package/dist/src/easyblocks/utils.d.ts +37 -0
  44. package/dist/src/editor/resources.d.ts +9 -0
  45. package/dist/src/fonts.d.ts +6 -0
  46. package/dist/src/index.d.ts +15 -0
  47. package/dist/src/liquid/color.d.ts +33 -0
  48. package/dist/src/liquid/filters/asset_url.d.ts +2 -0
  49. package/dist/src/liquid/filters/brightness_difference.d.ts +2 -0
  50. package/dist/src/liquid/filters/color_brightness.d.ts +2 -0
  51. package/dist/src/liquid/filters/color_contrast.d.ts +2 -0
  52. package/dist/src/liquid/filters/color_darken.d.ts +2 -0
  53. package/dist/src/liquid/filters/color_desaturate.d.ts +2 -0
  54. package/dist/src/liquid/filters/color_difference.d.ts +2 -0
  55. package/dist/src/liquid/filters/color_extract.d.ts +4 -0
  56. package/dist/src/liquid/filters/color_lighten.d.ts +2 -0
  57. package/dist/src/liquid/filters/color_mix.d.ts +2 -0
  58. package/dist/src/liquid/filters/color_modify.d.ts +4 -0
  59. package/dist/src/liquid/filters/color_saturate.d.ts +2 -0
  60. package/dist/src/liquid/filters/color_to_hex.d.ts +2 -0
  61. package/dist/src/liquid/filters/color_to_hsl.d.ts +2 -0
  62. package/dist/src/liquid/filters/color_to_rgb.d.ts +2 -0
  63. package/dist/src/liquid/filters/date.d.ts +7 -0
  64. package/dist/src/liquid/filters/default_errors.d.ts +2 -0
  65. package/dist/src/liquid/filters/divided_by.d.ts +2 -0
  66. package/dist/src/liquid/filters/font_face.d.ts +2 -0
  67. package/dist/src/liquid/filters/font_modify.d.ts +3 -0
  68. package/dist/src/liquid/filters/font_url.d.ts +2 -0
  69. package/dist/src/liquid/filters/format_address.d.ts +6 -0
  70. package/dist/src/liquid/filters/image_tag.d.ts +2 -0
  71. package/dist/src/liquid/filters/image_url.d.ts +6 -0
  72. package/dist/src/liquid/filters/index.d.ts +92 -0
  73. package/dist/src/liquid/filters/inline_editable.d.ts +4 -0
  74. package/dist/src/liquid/filters/json.d.ts +2 -0
  75. package/dist/src/liquid/filters/json_pretty.d.ts +2 -0
  76. package/dist/src/liquid/filters/money.d.ts +2 -0
  77. package/dist/src/liquid/filters/money_with_currency.d.ts +2 -0
  78. package/dist/src/liquid/filters/money_without_currency.d.ts +2 -0
  79. package/dist/src/liquid/filters/money_without_trailing_zeros.d.ts +2 -0
  80. package/dist/src/liquid/filters/shopify/default_pagination.d.ts +3 -0
  81. package/dist/src/liquid/filters/shopify/hex_to_rgba.d.ts +2 -0
  82. package/dist/src/liquid/filters/shopify/item_count_for_variant.d.ts +6 -0
  83. package/dist/src/liquid/filters/shopify/payment_button.d.ts +2 -0
  84. package/dist/src/liquid/filters/shopify/payment_terms.d.ts +2 -0
  85. package/dist/src/liquid/filters/shopify/placeholder-svgs/blog-apparel-1.d.ts +2 -0
  86. package/dist/src/liquid/filters/shopify/placeholder-svgs/blog-apparel-2.d.ts +2 -0
  87. package/dist/src/liquid/filters/shopify/placeholder-svgs/blog-apparel-3.d.ts +2 -0
  88. package/dist/src/liquid/filters/shopify/placeholder-svgs/collection-1.d.ts +2 -0
  89. package/dist/src/liquid/filters/shopify/placeholder-svgs/collection-2.d.ts +2 -0
  90. package/dist/src/liquid/filters/shopify/placeholder-svgs/collection-3.d.ts +2 -0
  91. package/dist/src/liquid/filters/shopify/placeholder-svgs/collection-4.d.ts +2 -0
  92. package/dist/src/liquid/filters/shopify/placeholder-svgs/collection-5.d.ts +2 -0
  93. package/dist/src/liquid/filters/shopify/placeholder-svgs/collection-6.d.ts +2 -0
  94. package/dist/src/liquid/filters/shopify/placeholder-svgs/collection-apparel-1.d.ts +2 -0
  95. package/dist/src/liquid/filters/shopify/placeholder-svgs/collection-apparel-2.d.ts +2 -0
  96. package/dist/src/liquid/filters/shopify/placeholder-svgs/collection-apparel-3.d.ts +2 -0
  97. package/dist/src/liquid/filters/shopify/placeholder-svgs/collection-apparel-4.d.ts +2 -0
  98. package/dist/src/liquid/filters/shopify/placeholder-svgs/detailed-apparel-1.d.ts +2 -0
  99. package/dist/src/liquid/filters/shopify/placeholder-svgs/hero-apparel-1.d.ts +2 -0
  100. package/dist/src/liquid/filters/shopify/placeholder-svgs/hero-apparel-2.d.ts +2 -0
  101. package/dist/src/liquid/filters/shopify/placeholder-svgs/hero-apparel-3.d.ts +2 -0
  102. package/dist/src/liquid/filters/shopify/placeholder-svgs/image.d.ts +2 -0
  103. package/dist/src/liquid/filters/shopify/placeholder-svgs/index.d.ts +33 -0
  104. package/dist/src/liquid/filters/shopify/placeholder-svgs/lifestyle-1.d.ts +2 -0
  105. package/dist/src/liquid/filters/shopify/placeholder-svgs/lifestyle-2.d.ts +2 -0
  106. package/dist/src/liquid/filters/shopify/placeholder-svgs/product-1.d.ts +2 -0
  107. package/dist/src/liquid/filters/shopify/placeholder-svgs/product-2.d.ts +2 -0
  108. package/dist/src/liquid/filters/shopify/placeholder-svgs/product-3.d.ts +2 -0
  109. package/dist/src/liquid/filters/shopify/placeholder-svgs/product-4.d.ts +2 -0
  110. package/dist/src/liquid/filters/shopify/placeholder-svgs/product-5.d.ts +2 -0
  111. package/dist/src/liquid/filters/shopify/placeholder-svgs/product-6.d.ts +2 -0
  112. package/dist/src/liquid/filters/shopify/placeholder-svgs/product-apparel-1.d.ts +2 -0
  113. package/dist/src/liquid/filters/shopify/placeholder-svgs/product-apparel-2.d.ts +2 -0
  114. package/dist/src/liquid/filters/shopify/placeholder-svgs/product-apparel-3.d.ts +2 -0
  115. package/dist/src/liquid/filters/shopify/placeholder-svgs/product-apparel-4.d.ts +2 -0
  116. package/dist/src/liquid/filters/shopify/placeholder_svg_tag.d.ts +2 -0
  117. package/dist/src/liquid/filters/stylesheet_tag.d.ts +2 -0
  118. package/dist/src/liquid/filters/time_tag.d.ts +2 -0
  119. package/dist/src/liquid/filters/translate.d.ts +2 -0
  120. package/dist/src/liquid/filters/where.d.ts +2 -0
  121. package/dist/src/liquid/font.d.ts +50 -0
  122. package/dist/src/liquid/form.d.ts +17 -0
  123. package/dist/src/liquid/index.d.ts +53 -0
  124. package/dist/src/liquid/operators.d.ts +4 -0
  125. package/dist/src/liquid/tags/case.d.ts +3 -0
  126. package/dist/src/liquid/tags/for.d.ts +3 -0
  127. package/dist/src/liquid/tags/form.d.ts +3 -0
  128. package/dist/src/liquid/tags/index.d.ts +30 -0
  129. package/dist/src/liquid/tags/inline_editable.d.ts +3 -0
  130. package/dist/src/liquid/tags/javascript.d.ts +3 -0
  131. package/dist/src/liquid/tags/layout.d.ts +3 -0
  132. package/dist/src/liquid/tags/paginate.d.ts +3 -0
  133. package/dist/src/liquid/tags/render.d.ts +3 -0
  134. package/dist/src/liquid/tags/section.d.ts +3 -0
  135. package/dist/src/liquid/tags/sections.d.ts +3 -0
  136. package/dist/src/liquid/tags/shopify/include.d.ts +3 -0
  137. package/dist/src/liquid/tags/shopify/schema.d.ts +3 -0
  138. package/dist/src/liquid/tags/style.d.ts +3 -0
  139. package/dist/src/liquid/utils.d.ts +50 -0
  140. package/dist/src/menus.d.ts +27 -0
  141. package/dist/src/products.d.ts +9 -0
  142. package/dist/src/resources.d.ts +98 -0
  143. package/dist/src/theme.d.ts +120 -0
  144. package/dist/src/utils/index.d.ts +19 -0
  145. package/dist/src/utils/md5.d.ts +1 -0
  146. package/dist/test/liquid/filters/asset_url.test.d.ts +1 -0
  147. package/dist/test/liquid/filters/brightness_difference.test.d.ts +1 -0
  148. package/dist/test/liquid/filters/color_brightness.test.d.ts +1 -0
  149. package/dist/test/liquid/filters/color_contrast.test.d.ts +1 -0
  150. package/dist/test/liquid/filters/color_darken.test.d.ts +1 -0
  151. package/dist/test/liquid/filters/color_desaturate.test.d.ts +1 -0
  152. package/dist/test/liquid/filters/color_difference.test.d.ts +1 -0
  153. package/dist/test/liquid/filters/color_extract.test.d.ts +1 -0
  154. package/dist/test/liquid/filters/color_lighten.test.d.ts +1 -0
  155. package/dist/test/liquid/filters/color_mix.test.d.ts +1 -0
  156. package/dist/test/liquid/filters/color_modify.test.d.ts +1 -0
  157. package/dist/test/liquid/filters/color_saturate.test.d.ts +1 -0
  158. package/dist/test/liquid/filters/color_to_hex.test.d.ts +1 -0
  159. package/dist/test/liquid/filters/color_to_hsl.test.d.ts +1 -0
  160. package/dist/test/liquid/filters/color_to_rgb.test.d.ts +1 -0
  161. package/dist/test/liquid/filters/date.test.d.ts +1 -0
  162. package/dist/test/liquid/filters/default_errors.test.d.ts +1 -0
  163. package/dist/test/liquid/filters/divided_by.test.d.ts +1 -0
  164. package/dist/test/liquid/filters/font_face.test.d.ts +1 -0
  165. package/dist/test/liquid/filters/font_modify.test.d.ts +1 -0
  166. package/dist/test/liquid/filters/font_url.test.d.ts +1 -0
  167. package/dist/test/liquid/filters/format_address.test.d.ts +1 -0
  168. package/dist/test/liquid/filters/image_tag.test.d.ts +1 -0
  169. package/dist/test/liquid/filters/image_url.test.d.ts +1 -0
  170. package/dist/test/liquid/filters/inline_editable.test.d.ts +1 -0
  171. package/dist/test/liquid/filters/json.test.d.ts +1 -0
  172. package/dist/test/liquid/filters/json_pretty.test.d.ts +1 -0
  173. package/dist/test/liquid/filters/money.test.d.ts +1 -0
  174. package/dist/test/liquid/filters/money_with_currency.test.d.ts +1 -0
  175. package/dist/test/liquid/filters/money_without_currency.test.d.ts +1 -0
  176. package/dist/test/liquid/filters/money_without_trailing_zeros.test.d.ts +1 -0
  177. package/dist/test/liquid/filters/stylesheet_tag.test.d.ts +1 -0
  178. package/dist/test/liquid/filters/time_tag.test.d.ts +1 -0
  179. package/dist/test/liquid/filters/translate.test.d.ts +1 -0
  180. package/dist/test/liquid/filters/where.test.d.ts +1 -0
  181. package/dist/test/liquid/helpers.d.ts +6 -0
  182. package/dist/test/liquid/tags/case.test.d.ts +1 -0
  183. package/dist/test/liquid/tags/for.test.d.ts +1 -0
  184. package/dist/test/liquid/tags/form.test.d.ts +1 -0
  185. package/dist/test/liquid/tags/inline_editable.test.d.ts +1 -0
  186. package/dist/test/liquid/tags/javascript.test.d.ts +1 -0
  187. package/dist/test/liquid/tags/style.test.d.ts +1 -0
  188. package/dist/types/shopify.d.ts +126 -0
  189. package/dist/types/swell.d.ts +410 -0
  190. package/package.json +2 -1
@@ -0,0 +1,50 @@
1
+ import { Context } from 'liquidjs';
2
+ export declare const toString: () => string;
3
+ export declare const hasOwnProperty: (v: PropertyKey) => boolean;
4
+ /**
5
+ * Utils used by liquidjs tags and filters
6
+ */
7
+ export declare class Drop {
8
+ liquidMethodMissing(key: string): undefined;
9
+ }
10
+ export declare class ForloopDrop extends Drop {
11
+ i: number;
12
+ length: number;
13
+ name: string;
14
+ test: string;
15
+ index: number;
16
+ index0: number;
17
+ first: boolean;
18
+ last: boolean;
19
+ rindex: number;
20
+ rindex0: number;
21
+ constructor(length: number, collection: string, variable: string);
22
+ next(): void;
23
+ valueOf(): string;
24
+ }
25
+ export declare function toValue(value: any): any;
26
+ export declare function isString(value: unknown): value is string;
27
+ export declare function isNumber(value: unknown): value is number;
28
+ export declare function isFunction(value: unknown): value is Function;
29
+ export declare function toLiquid(value: unknown): unknown;
30
+ export declare function isNil(value: unknown): value is undefined | null;
31
+ export declare function isUndefined(value: unknown): value is undefined;
32
+ export declare function isArray<T>(value: unknown): value is Array<T>;
33
+ export declare function isObject(value: unknown): value is Record<string, unknown>;
34
+ export declare function isIterable<T>(value: unknown): value is Iterable<T>;
35
+ export declare function isLikePromise(value: unknown): value is PromiseLike<unknown>;
36
+ export declare function isTruthy(val: any, ctx: Context): boolean;
37
+ export declare function isFalsy(val: any, ctx: Context): boolean;
38
+ export interface Comparable {
39
+ equals(rhs: unknown): boolean;
40
+ gt(rhs: unknown): boolean;
41
+ geq(rhs: unknown): boolean;
42
+ lt(rhs: unknown): boolean;
43
+ leq(rhs: unknown): boolean;
44
+ }
45
+ export declare function isComparable(arg: unknown): arg is Comparable;
46
+ export declare function toArray<T>(val: unknown): T[];
47
+ export declare function toEnumerable<T>(val: unknown): T[];
48
+ export declare function stringify(value: unknown): string;
49
+ export declare function paramsToProps(params: string[] | Record<string, string>): Record<string, unknown>;
50
+ export declare function jsonStringifyAsync(input: unknown, space?: number): Promise<string>;
@@ -0,0 +1,27 @@
1
+ import { SwellTheme } from './theme';
2
+ import { SwellStorefrontRecord, SwellStorefrontCollection } from './api';
3
+ import type { SwellMenu, SwellMenuItem } from '../types/swell';
4
+ export declare function resolveMenuSettings(theme: SwellTheme, menus: SwellMenu[], options?: {
5
+ currentUrl?: string;
6
+ }): Promise<{
7
+ [key: string]: any;
8
+ }>;
9
+ export declare function resolveMenuItems(theme: SwellTheme, menuItems: SwellMenuItem[], options?: {
10
+ currentUrl?: string;
11
+ }): Promise<SwellMenuItem[]>;
12
+ export declare function resolveMenuItemUrlAndResource(theme: SwellTheme, item: SwellMenuItem, options?: {
13
+ trailingSlash?: boolean;
14
+ }): Promise<{
15
+ url: string;
16
+ resource?: SwellStorefrontRecord | SwellStorefrontCollection;
17
+ }>;
18
+ export declare function getMenuItemValueId(value: unknown): string;
19
+ export declare function getMenuItemUrlAndResource(theme: SwellTheme, menuItem: SwellMenuItem): Promise<{
20
+ url: string;
21
+ resource?: SwellStorefrontRecord | SwellStorefrontCollection;
22
+ }>;
23
+ export declare function getMenuItemStorefrontUrl(theme: SwellTheme, pageId: string, slug?: string, collectionSlug?: string): string;
24
+ export declare function deferMenuItemUrlAndResource(theme: SwellTheme, pageId: string, id: string, collectionSlugOrHandler?: string | ((resource: SwellStorefrontRecord) => Promise<string>)): Promise<{
25
+ url: string;
26
+ resource?: SwellStorefrontRecord;
27
+ }>;
@@ -0,0 +1,9 @@
1
+ import { Swell, SwellStorefrontCollection, SwellStorefrontRecord } from './api';
2
+ import type { SwellData } from '../types/swell';
3
+ export declare function getProducts(swell: Swell, query?: SwellData): SwellStorefrontCollection;
4
+ export declare function getProduct(swell: Swell, id: string, query?: SwellData): SwellStorefrontRecord;
5
+ export declare function getProductsFiltered(swell: Swell, { search, filter, sort, }: {
6
+ search?: string | null;
7
+ filter?: any;
8
+ sort?: string | null;
9
+ }): SwellStorefrontCollection;
@@ -0,0 +1,98 @@
1
+ import { Swell } from './api';
2
+ import { ShopifyCompatibility } from './compatibility/shopify';
3
+ import type { SwellData, SwellRecord, SwellCollection, InferSwellCollection, SwellCollectionPages, StorefrontResourceGetter } from '../types/swell';
4
+ export declare const MAX_QUERY_PAGE_LIMIT = 100;
5
+ export declare const DEFAULT_QUERY_PAGE_LIMIT = 15;
6
+ export declare const CACHE_TIMEOUT_RESOURCES: number;
7
+ export declare class StorefrontResource<T extends SwellData = SwellData> {
8
+ _getter?: StorefrontResourceGetter<T>;
9
+ _getterHash?: string;
10
+ _result?: T | null;
11
+ _compatibilityProps: SwellData;
12
+ [key: string]: any;
13
+ constructor(getter?: StorefrontResourceGetter<T>);
14
+ _getProxy(): StorefrontResource<T>;
15
+ _getCollectionResultOrProp(instance: StorefrontResource<T>, prop: string | number): any;
16
+ _get(..._args: any[]): Promise<T | null | undefined>;
17
+ _setGetter(getter: StorefrontResourceGetter<T>): void;
18
+ _resolve(): Promise<T | null | undefined>;
19
+ _isResultResolved(): boolean;
20
+ resolve(resolveStorefrontResources?: boolean, resourceMetadata?: boolean): Promise<any>;
21
+ toObject(): {} | null;
22
+ toJSON(): {} | null;
23
+ valueOf(): Promise<any>;
24
+ setCompatibilityProps(props: SwellData): void;
25
+ getCompatibilityProp<T extends keyof StorefrontResource['_compatibilityProps']>(prop: T): StorefrontResource['_compatibilityProps'][T];
26
+ }
27
+ export declare class SwellStorefrontResource<T extends SwellData = SwellData> extends StorefrontResource<T> {
28
+ _swell: Swell;
29
+ _resource: any;
30
+ readonly _collection: string;
31
+ _query: SwellData;
32
+ _compatibilityInstance: ShopifyCompatibility | null;
33
+ constructor(swell: Swell, collection: string, getter?: StorefrontResourceGetter<T>);
34
+ _getProxy(): SwellStorefrontResource<T>;
35
+ getResourceObject(): {
36
+ get: (id?: string, query?: SwellData) => Promise<InferSwellCollection<T> | null>;
37
+ list: (query?: SwellData) => Promise<T extends SwellCollection ? T : SwellCollection<T>>;
38
+ };
39
+ }
40
+ export declare class SwellStorefrontCollection<T extends SwellCollection = SwellCollection> extends SwellStorefrontResource<T> {
41
+ length: number;
42
+ results?: InferSwellCollection<T>[];
43
+ count?: number;
44
+ page?: number;
45
+ pages?: SwellCollectionPages;
46
+ page_count?: number;
47
+ limit: number;
48
+ name?: string;
49
+ constructor(swell: Swell, collection: string, query?: SwellData, getter?: StorefrontResourceGetter<T>);
50
+ _getProxy(): SwellStorefrontCollection<T>;
51
+ _initQuery(query: SwellData): SwellData;
52
+ _defaultGetter(): StorefrontResourceGetter<T>;
53
+ _get(query?: SwellData): Promise<T | null | undefined>;
54
+ [Symbol.iterator](): Generator<InferSwellCollection<T>, void, unknown>;
55
+ iterator(): Generator<InferSwellCollection<T>, void, unknown>;
56
+ _clone(newProps?: SwellData): SwellStorefrontCollection<T>;
57
+ _cloneWithCompatibilityResult(compatibilityGetter: (result: T) => SwellData): SwellStorefrontCollection<T>;
58
+ }
59
+ export declare class SwellStorefrontRecord<T extends SwellData = SwellRecord> extends SwellStorefrontResource<T> {
60
+ _id: string;
61
+ id?: string;
62
+ constructor(swell: Swell, collection: string, id: string, query?: SwellData, getter?: StorefrontResourceGetter<T>);
63
+ _getProxy(): SwellStorefrontRecord<T>;
64
+ _defaultGetter(): StorefrontResourceGetter<T>;
65
+ _get(id: string, query?: SwellData): Promise<T | null | undefined>;
66
+ }
67
+ export declare class SwellStorefrontSingleton<T extends SwellData = SwellData> extends SwellStorefrontResource<T> {
68
+ constructor(swell: Swell, collection: string, getter?: StorefrontResourceGetter<T>);
69
+ _getProxy(): SwellStorefrontSingleton<T>;
70
+ _defaultGetter(): StorefrontResourceGetter<T>;
71
+ _get(): Promise<T | null | undefined>;
72
+ }
73
+ export declare class SwellStorefrontPagination<T extends SwellCollection = SwellCollection> {
74
+ _resource: SwellStorefrontCollection<T>;
75
+ count: number;
76
+ page: number;
77
+ page_count: number;
78
+ limit: number;
79
+ pages: Record<string, {
80
+ start: number;
81
+ end: number;
82
+ url: string;
83
+ }>;
84
+ next?: {
85
+ start: number;
86
+ end: number;
87
+ url: string;
88
+ };
89
+ previous?: {
90
+ start: number;
91
+ end: number;
92
+ url: string;
93
+ };
94
+ constructor(resource: SwellStorefrontCollection<T>);
95
+ setPaginationProps(): void;
96
+ getPageUrl(page: number): string;
97
+ setCompatibilityProps(props: SwellData): void;
98
+ }
@@ -0,0 +1,120 @@
1
+ import { Swell, StorefrontResource, SwellStorefrontCollection, SwellStorefrontRecord, SwellStorefrontSingleton } from './api';
2
+ import { LiquidSwell, ThemeFont, ThemeForm } from './liquid';
3
+ import { ShopifyCompatibility } from './compatibility/shopify';
4
+ import type { ThemeGlobals, ThemeConfigs, ThemeSettings, ThemeResources, ThemeFormConfig, ThemeFormErrorMessages, ThemePresetSchema, ThemeSectionGroup, ThemeSectionSchema, ThemeSectionConfig, ThemeSectionSettings, ThemeSettingFieldSchema, ThemeSettingSectionSchema, ThemePageSectionSchema, ThemePageTemplateConfig, ThemeLayoutSectionGroupConfig, SwellData, SwellMenu, SwellAppConfig, SwellThemeConfig, SwellAppStorefrontThemeProps, SwellAppShopifyCompatibilityConfig } from '../types/swell';
5
+ export declare class SwellTheme {
6
+ swell: Swell;
7
+ props: SwellAppStorefrontThemeProps;
8
+ globals: ThemeGlobals;
9
+ forms?: ThemeFormConfig[];
10
+ resources?: ThemeResources;
11
+ liquidSwell: LiquidSwell;
12
+ themeConfigs: Map<string, SwellThemeConfig> | null;
13
+ page: any;
14
+ pageId: string | undefined;
15
+ shopifyCompatibility: ShopifyCompatibility | null;
16
+ shopifyCompatibilityClass: typeof ShopifyCompatibility;
17
+ shopifyCompatibilityConfig: SwellAppShopifyCompatibilityConfig | null;
18
+ formData: Record<string, ThemeForm>;
19
+ globalData: SwellData;
20
+ constructor(swell: Swell, options?: {
21
+ forms?: ThemeFormConfig[];
22
+ resources?: ThemeResources;
23
+ globals?: ThemeGlobals;
24
+ shopifyCompatibilityClass?: typeof ShopifyCompatibility;
25
+ });
26
+ getSwellAppThemeProps(swellConfig?: SwellAppConfig): SwellAppStorefrontThemeProps;
27
+ initGlobals(pageId: string): Promise<void>;
28
+ setGlobals(globals: SwellData): void;
29
+ getSettingsAndConfigs(): Promise<{
30
+ store: SwellData;
31
+ session: SwellData;
32
+ menus: Record<string, SwellMenu>;
33
+ geo?: SwellData;
34
+ configs: ThemeConfigs;
35
+ }>;
36
+ resolvePageData(store: SwellData, configs: SwellData, session?: SwellData, pageId?: string): Promise<{
37
+ settings: ThemeSettings;
38
+ request: ThemeSettings;
39
+ page: ThemeSettings;
40
+ cart: SwellStorefrontSingleton | {};
41
+ account: SwellStorefrontSingleton | null;
42
+ customer?: SwellStorefrontSingleton | null;
43
+ }>;
44
+ fetchSingletonResourceCached<R>(key: string, handler: () => Promise<R>, defaultValue: R): Promise<R | undefined>;
45
+ fetchCart(): Promise<StorefrontResource>;
46
+ fetchAccount(): Promise<StorefrontResource | null>;
47
+ getFormConfig(formType: string): ThemeFormConfig | undefined;
48
+ setFormData(formId: string, options: {
49
+ params?: any;
50
+ success?: boolean;
51
+ withoutErrors?: boolean;
52
+ errors?: ThemeFormErrorMessages;
53
+ }): void;
54
+ setFormSuccessWithoutErrors(formId: string): void;
55
+ serializeFormData(): SwellData | null;
56
+ setGlobalData(data?: SwellData): void;
57
+ serializeGlobalData(): SwellData | null;
58
+ resolveTranslationLocale(translationsConfig: ThemeSettings, localeCode: string): any;
59
+ setCompatibilityConfigs(configs: ThemeConfigs, localeCode: string): Promise<void>;
60
+ setCompatibilityData(pageData: SwellData): void;
61
+ resolveLookupSetting(setting: ThemeSettingFieldSchema, value: any): SwellData | SwellStorefrontRecord | SwellStorefrontCollection | null;
62
+ resolveLookupResource(collection: string, id: string): StorefrontResource;
63
+ resolveMenuSetting(value: string): SwellMenu | null;
64
+ lang(key: string, data?: any, fallback?: string): Promise<string>;
65
+ resolveFontSetting(value: string): ThemeFont | null;
66
+ resolveUrlSetting(value: string): string;
67
+ themeConfigQuery(): Record<string, unknown>;
68
+ getGeoSettings(): Promise<SwellData | undefined>;
69
+ getAllThemeConfigs(): Promise<Map<string, SwellThemeConfig>>;
70
+ getThemeConfig(filePath: string): Promise<SwellThemeConfig | null>;
71
+ getThemeTemplateConfig(filePath: string): Promise<SwellThemeConfig | null>;
72
+ getThemeTemplateConfigByType(type: string, name: string): Promise<SwellThemeConfig | null>;
73
+ getAssetUrl(filePath: string): Promise<string | null>;
74
+ renderTemplate(config: SwellThemeConfig | null, data?: SwellData): Promise<string>;
75
+ renderTemplateString(templateString: string, data?: SwellData): Promise<string>;
76
+ getSectionSchema(sectionName: string): Promise<Partial<ThemeSectionSchema> | undefined>;
77
+ getSectionConfigWithSchemaTagOnly(config: SwellThemeConfig): SwellThemeConfig | null;
78
+ renderThemeTemplate(filePath: string, data?: SwellData): Promise<string | ThemePageTemplateConfig>;
79
+ renderLayoutTemplate(name: string, data?: SwellData): Promise<string>;
80
+ renderPageTemplate(name: string, data?: SwellData, altTemplateId?: string): Promise<string | ThemePageTemplateConfig>;
81
+ renderPage(pageData?: SwellData, altTemplateId?: string): Promise<string | ThemePageTemplateConfig>;
82
+ renderAllSections(sectionsIds: string | Array<string>, pageData?: SwellData): Promise<{
83
+ [key: string]: string;
84
+ }>;
85
+ renderSection(sectionId: string, pageData?: SwellData): Promise<string | ThemePageTemplateConfig>;
86
+ renderLayout(data?: SwellData): Promise<string>;
87
+ getContentForHeader(): string;
88
+ renderFontHeaderLinks(): string;
89
+ getTemplateSchema(config: SwellThemeConfig): Promise<Partial<ThemeSectionSchema> | undefined>;
90
+ resolveSectionDefaultSettings(sectionSchema: ThemeSectionSchema, presetSchema?: ThemePresetSchema): Promise<SwellData>;
91
+ getAllSections(): Promise<ThemePageSectionSchema[]>;
92
+ getPageSections(sectionGroup: ThemeSectionGroup, resolveSettings?: boolean): Promise<ThemeSectionConfig[]>;
93
+ getLayoutSectionGroups(resolveSettings?: boolean): Promise<ThemeLayoutSectionGroupConfig[]>;
94
+ renderPageSections(sectionGroup: ThemeSectionGroup, data?: SwellData): Promise<ThemeSectionConfig[]>;
95
+ renderSectionConfigs(sectionConfigs: ThemeSectionConfig[], data?: SwellData): Promise<ThemeSectionConfig[]>;
96
+ renderTemplateSections(sectionGroup: ThemeSectionGroup, data?: SwellData): Promise<string>;
97
+ renderTranslation(key: string, data?: any, fallback?: string): Promise<string>;
98
+ renderTranslationValue(localeCode: string, langConfig: any, key: string, data?: any, fallback?: string): Promise<string>;
99
+ renderCurrency(amount: number, params: any): string;
100
+ }
101
+ export declare class PageError {
102
+ title: string;
103
+ status: number;
104
+ message: string;
105
+ description?: string;
106
+ constructor(title?: string | Error, status?: number, description?: string);
107
+ toString(): string;
108
+ }
109
+ export declare class PageNotFound extends PageError {
110
+ constructor(title?: string, status?: number, description?: string);
111
+ }
112
+ export declare function resolveSectionSettings(theme: SwellTheme, sectionConfig: ThemeSectionConfig): ThemeSectionSettings | undefined;
113
+ export declare function resolveThemeSettings(theme: SwellTheme, themeSettings: ThemeSettings, editorSchemaSettings?: ThemeSettingSectionSchema[]): ThemeSettings;
114
+ export interface ThemeSettingFieldValue {
115
+ setting: ThemeSettingFieldSchema;
116
+ value: any;
117
+ }
118
+ export declare function findThemeSettingsByType(type: string, themeSettings: ThemeSettings, editorSchemaSettings: ThemeSettingSectionSchema[]): ThemeSettingFieldValue[];
119
+ export declare function resolveLookupCollection(setting: ThemeSettingFieldSchema): string | null | undefined;
120
+ export declare function findEditorSetting(editorSchemaSettings: ThemeSettingSectionSchema[], key: string): ThemeSettingFieldSchema | null;
@@ -0,0 +1,19 @@
1
+ import type { SwellData, SwellRecord, SwellThemeConfig, ThemeLayoutSectionGroupConfig, ThemePageSectionSchema, ThemeSectionConfig, ThemeSectionGroup, ThemeSectionSchema } from 'types/swell';
2
+ export * from './md5';
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<Partial<ThemeSectionSchema> | undefined>): Promise<ThemePageSectionSchema[]>;
5
+ export declare function getLayoutSectionGroups(allSections: Map<string, SwellThemeConfig>, renderTemplateSchema: (config: SwellThemeConfig) => Promise<Partial<ThemeSectionSchema> | undefined>): Promise<ThemeLayoutSectionGroupConfig[]>;
6
+ export declare function getPageSections(sectionGroup: ThemeSectionGroup | SwellRecord, getSchema: (type: string) => Promise<Partial<ThemeSectionSchema> | undefined>): Promise<ThemeSectionConfig[]>;
7
+ export declare function isArray(value: any): boolean;
8
+ export declare function isObject(value: any): boolean;
9
+ export declare function toBase64(inputString: string): string;
10
+ export declare function arrayToObject(arr: Array<any>, key?: string): {
11
+ [key: string]: any;
12
+ };
13
+ export declare function getCountryCodeFromLocale(locale: string): string;
14
+ export declare function forEachKeyDeep(obj: any, fn: (key: string, value: any) => boolean | void): void;
15
+ export declare function findCircularReferences(value: any): unknown[];
16
+ export declare function removeCircularReferences(value: any): any;
17
+ export declare function dehydrateSwellRefsInStorefrontResources(obj: any): any;
18
+ export declare function resolveAsyncResources(response: any, resolveStorefrontResources?: boolean, resolveWithResourceMetadata?: boolean): Promise<any>;
19
+ export declare function stringifyQueryParams(queryParams: SwellData): string;
@@ -0,0 +1 @@
1
+ export declare function md5(inputString: string): string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import { LiquidSwell } from '@/liquid';
2
+ type DescribeLiquidCallbackType = (render: (template: string, data?: any) => Promise<string>, liquid: LiquidSwell) => void;
3
+ export declare function describeFilter(name: string, callback: DescribeLiquidCallbackType): void;
4
+ export declare function describeTag(name: string, callback: DescribeLiquidCallbackType): void;
5
+ export declare function removeSpaces(value: string): string;
6
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,126 @@
1
+ import type { SwellData, OptionItem, ThemeSectionEnabledDisabled } from './swell';
2
+ import type { ShopifyResource } from '../src/compatibility/shopify-objects/resource';
3
+ import type { ShopifyCompatibility } from '../src/compatibility/shopify';
4
+ import type { StorefrontResource } from '../src/resources';
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' | 'page' | 'product' | 'product_list' | 'richtext' | 'text_alignment' | 'url' | 'video' | 'video_url';
7
+ export interface ShopifyBgStyleSchema {
8
+ solid: string;
9
+ gradient: string;
10
+ }
11
+ export interface ShopifySettingRoleSchema {
12
+ background: string | ShopifyBgStyleSchema;
13
+ primary_button: string | ShopifyBgStyleSchema;
14
+ secondary_button: string | ShopifyBgStyleSchema;
15
+ text: string;
16
+ on_primary_button: string;
17
+ primary_button_border: string;
18
+ on_secondary_button: string;
19
+ secondary_button_border: string;
20
+ icons: string;
21
+ links: string;
22
+ }
23
+ export interface ShopifySettingDefinitionSchema {
24
+ type: 'header' | 'color' | 'color_background';
25
+ label: string;
26
+ id?: string;
27
+ info?: string;
28
+ default?: any;
29
+ placeholder?: string;
30
+ }
31
+ export interface ShopifySettingSchema {
32
+ type: ShopifyBasicInputType | ShopifySpecializedInputType;
33
+ label: string;
34
+ id?: string;
35
+ info?: string;
36
+ default?: any;
37
+ placeholder?: string;
38
+ content?: string;
39
+ options?: Array<OptionItem>;
40
+ group?: string;
41
+ min?: number;
42
+ max?: number;
43
+ step?: number;
44
+ unit?: string;
45
+ limit?: number;
46
+ definition?: Array<ShopifySettingDefinitionSchema>;
47
+ role?: ShopifySettingRoleSchema;
48
+ accept?: Array<string>;
49
+ }
50
+ export interface ShopifySettingSection {
51
+ name: string;
52
+ settings?: Array<ShopifySettingSchema>;
53
+ }
54
+ export type ShopifySettingsSchema = Array<ShopifySettingSection>;
55
+ export interface ShopifySettingsData {
56
+ current: Record<string, any>;
57
+ presets: Record<string, Record<string, any>>;
58
+ }
59
+ export interface ShopifySectionBlockSchema {
60
+ type: string;
61
+ name: string;
62
+ limit?: number;
63
+ settings: ShopifySettingSchema[];
64
+ }
65
+ export interface ShopifySectionPresetSchema {
66
+ name: string;
67
+ settings: ShopifySettingSchema[];
68
+ blocks?: ShopifySectionBlockSchema[];
69
+ }
70
+ export interface ShopifySettingSection {
71
+ name: string;
72
+ settings?: Array<ShopifySettingSchema>;
73
+ }
74
+ export interface ShopifySectionGroupItem {
75
+ type: string;
76
+ settings: Record<string, any>;
77
+ blocks: Record<string, ShopifySectionBlockSchema>;
78
+ }
79
+ export interface ShopifySectionGroupSchema {
80
+ name: string;
81
+ type: string;
82
+ sections: Record<string, ShopifySectionGroupItem>;
83
+ order: string[];
84
+ }
85
+ export interface ShopifySectionSchema {
86
+ type?: string;
87
+ name: string;
88
+ tag?: string;
89
+ class?: string;
90
+ enabled_on?: ThemeSectionEnabledDisabled;
91
+ disabled_on?: ThemeSectionEnabledDisabled;
92
+ settings: ShopifySettingSchema[];
93
+ blocks?: ShopifySectionBlockSchema[];
94
+ presets?: ShopifySectionPresetSchema[];
95
+ default?: ShopifySettingSchema;
96
+ }
97
+ export interface ShopifyPageResource {
98
+ from: string;
99
+ to: string;
100
+ object(shopify: ShopifyCompatibility, value: StorefrontResource): ShopifyResource;
101
+ }
102
+ export interface ShopifyPage {
103
+ page: string;
104
+ resources: Array<ShopifyPageResource>;
105
+ }
106
+ export type ShopifyPageResourceMap = Array<ShopifyPage>;
107
+ interface ShopifyObject {
108
+ from: any;
109
+ object(shopify: ShopifyCompatibility, value: SwellData): ShopifyResource;
110
+ }
111
+ export type ShopifyObjectResourceMap = Array<ShopifyObject>;
112
+ export interface ShopifyForm {
113
+ type: string;
114
+ shopifyType?: string;
115
+ clientParams?(scope: SwellData, arg?: unknown): SwellData;
116
+ clientHtml?(scope: SwellData, arg?: unknown): string;
117
+ serverParams?(context: SwellData): SwellData;
118
+ serverResponse?(context: SwellData): SwellData;
119
+ }
120
+ export type ShopifyFormResourceMap = Array<ShopifyForm>;
121
+ export interface ShopifyQueryParams {
122
+ from: string | ((param: string) => boolean);
123
+ to: string | ((param: string, value: string) => SwellData);
124
+ }
125
+ export type ShopifyQueryParamsMap = Array<ShopifyQueryParams>;
126
+ export {};