@gem-sdk/core 1.14.0-next.96 → 1.14.0
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/cjs/components/AddOn.js +18 -1
- package/dist/cjs/components/ComponentWrapper.js +28 -1
- package/dist/cjs/components/ComponentWrapperPreview.js +72 -1
- package/dist/cjs/components/Empty.js +7 -1
- package/dist/cjs/components/Render.js +65 -1
- package/dist/cjs/components/Render.liquid.js +158 -3
- package/dist/cjs/components/RenderBlock.js +54 -1
- package/dist/cjs/components/RenderPreview.js +66 -1
- package/dist/cjs/components/RenderSection.js +23 -1
- package/dist/cjs/components/constant.js +39 -1
- package/dist/cjs/contexts/AddonContext.js +36 -1
- package/dist/cjs/contexts/BuilderComponent.js +34 -1
- package/dist/cjs/contexts/BuilderContext.js +35 -1
- package/dist/cjs/contexts/BuilderPreviewContext.js +370 -1
- package/dist/cjs/contexts/CartLineContext.js +29 -1
- package/dist/cjs/contexts/CollectionContext.js +38 -1
- package/dist/cjs/contexts/ModalContext.js +47 -1
- package/dist/cjs/contexts/ProductContext.js +149 -1
- package/dist/cjs/contexts/ProductListContext.js +32 -1
- package/dist/cjs/contexts/SectionContext.js +53 -1
- package/dist/cjs/contexts/ShopContext.js +70 -1
- package/dist/cjs/graphql/fragments/analytic.generated.js +6 -2
- package/dist/cjs/graphql/fragments/collection-detail.generated.js +6 -2
- package/dist/cjs/graphql/fragments/collection-product.generated.js +6 -2
- package/dist/cjs/graphql/fragments/collection.generated.js +6 -2
- package/dist/cjs/graphql/fragments/custom-code.generated.js +6 -2
- package/dist/cjs/graphql/fragments/data-seo.generated.js +6 -2
- package/dist/cjs/graphql/fragments/media.generated.js +6 -3
- package/dist/cjs/graphql/fragments/product-little.generated.js +6 -2
- package/dist/cjs/graphql/fragments/product-option-value.generated.js +6 -2
- package/dist/cjs/graphql/fragments/product-option.generated.js +6 -2
- package/dist/cjs/graphql/fragments/product.generated.js +6 -2
- package/dist/cjs/graphql/fragments/published-custom-section.generated.js +6 -2
- package/dist/cjs/graphql/fragments/published-page-section.generated.js +6 -2
- package/dist/cjs/graphql/fragments/published-theme-page.generated.js +6 -2
- package/dist/cjs/graphql/fragments/published-theme-style.generated.js +6 -2
- package/dist/cjs/graphql/fragments/selected-option.generated.js +6 -2
- package/dist/cjs/graphql/fragments/variant.generated.js +6 -2
- package/dist/cjs/graphql/mutations/page-view-up.generated.js +7 -3
- package/dist/cjs/graphql/queries/collection-detail-filter.generated.js +16 -2
- package/dist/cjs/graphql/queries/collection.generated.js +14 -2
- package/dist/cjs/graphql/queries/collections.generated.js +9 -2
- package/dist/cjs/graphql/queries/preview-page.generated.js +14 -2
- package/dist/cjs/graphql/queries/product-little-detail.generated.js +11 -2
- package/dist/cjs/graphql/queries/product-medias.generated.js +8 -2
- package/dist/cjs/graphql/queries/product-variants.generated.js +10 -2
- package/dist/cjs/graphql/queries/products.generated.js +17 -3
- package/dist/cjs/graphql/queries/published-theme-pages.generated.js +14 -2
- package/dist/cjs/graphql/queries/store-property.generated.js +6 -2
- package/dist/cjs/helpers/GlobalEvent.js +19 -1
- package/dist/cjs/helpers/background.js +109 -1
- package/dist/cjs/helpers/borders.js +183 -4
- package/dist/cjs/helpers/clone-deep.js +5 -1
- package/dist/cjs/helpers/cls.js +16 -1
- package/dist/cjs/helpers/colors.js +183 -1
- package/dist/cjs/helpers/compose-advance-style.js +188 -1
- package/dist/cjs/helpers/constant.js +23 -1
- package/dist/cjs/helpers/convert.js +7 -1
- package/dist/cjs/helpers/css-variable.js +7 -1
- package/dist/cjs/helpers/email.js +11 -1
- package/dist/cjs/helpers/flatten-connection.js +9 -1
- package/dist/cjs/helpers/get-resonsive-value.js +31 -1
- package/dist/cjs/helpers/get-shortname.js +92 -1
- package/dist/cjs/helpers/is-browser.js +9 -1
- package/dist/cjs/helpers/is-defined.js +7 -1
- package/dist/cjs/helpers/is-empty-children.js +12 -1
- package/dist/cjs/helpers/is-safari.js +9 -1
- package/dist/cjs/helpers/layout.js +59 -1
- package/dist/cjs/helpers/load-script.js +31 -1
- package/dist/cjs/helpers/make-style.js +128 -1
- package/dist/cjs/helpers/normalize-builder-data.js +23 -1
- package/dist/cjs/helpers/prefetch-queries.js +78 -1
- package/dist/cjs/helpers/product.js +45 -1
- package/dist/cjs/helpers/queries/get-collection.js +220 -1
- package/dist/cjs/helpers/queries/get-collections.js +21 -1
- package/dist/cjs/helpers/queries/get-product-by-slug.js +125 -1
- package/dist/cjs/helpers/queries/get-product.js +154 -1
- package/dist/cjs/helpers/queries/get-products.js +161 -1
- package/dist/cjs/helpers/query.js +29 -1
- package/dist/cjs/helpers/radius.js +131 -6
- package/dist/cjs/helpers/render.js +71 -1
- package/dist/cjs/helpers/shadow.js +56 -1
- package/dist/cjs/helpers/size.js +35 -4
- package/dist/cjs/helpers/spacing.js +43 -1
- package/dist/cjs/helpers/tracking/fpixel.js +28 -1
- package/dist/cjs/helpers/tracking/gtag.js +93 -1
- package/dist/cjs/helpers/tracking/tiktokpixel.js +17 -1
- package/dist/cjs/helpers/typography.js +105 -17
- package/dist/cjs/helpers/variant.js +8 -1
- package/dist/cjs/hooks/cart/use-add-to-cart.js +20 -1
- package/dist/cjs/hooks/cart/use-cart-data.js +28 -1
- package/dist/cjs/hooks/cart/use-cart-discount-codes-update.js +20 -1
- package/dist/cjs/hooks/cart/use-cart-note-update.js +20 -1
- package/dist/cjs/hooks/cart/use-create-cart.js +22 -1
- package/dist/cjs/hooks/cart/use-remove-cart-item.js +20 -1
- package/dist/cjs/hooks/cart/use-update-cart-item.js +20 -1
- package/dist/cjs/hooks/shop/use-collection-query.js +22 -1
- package/dist/cjs/hooks/shop/use-collections-query.js +17 -1
- package/dist/cjs/hooks/shop/use-product-query.js +22 -1
- package/dist/cjs/hooks/shop/use-products-query.js +22 -1
- package/dist/cjs/hooks/shop.js +126 -1
- package/dist/cjs/hooks/use-current-device.js +21 -1
- package/dist/cjs/hooks/use-lazy-video.js +15 -1
- package/dist/cjs/hooks/useCartId.js +44 -1
- package/dist/cjs/hooks/useCartLine.js +11 -1
- package/dist/cjs/hooks/useCartUI.js +48 -1
- package/dist/cjs/hooks/useCollection.js +9 -1
- package/dist/cjs/hooks/useFetchHandle.js +13 -1
- package/dist/cjs/hooks/useFormatMoney.js +58 -1
- package/dist/cjs/hooks/useIsomorphicLayoutEffect.js +10 -1
- package/dist/cjs/hooks/useLoadScript.js +32 -1
- package/dist/cjs/hooks/useMoney.js +84 -1
- package/dist/cjs/hooks/usePrevious.js +19 -1
- package/dist/cjs/hooks/useProduct.js +124 -1
- package/dist/cjs/hooks/useProductList.js +21 -1
- package/dist/cjs/hooks/useSuspenseFetch.js +27 -1
- package/dist/cjs/hooks/useSwatchesOptions.js +41 -1
- package/dist/cjs/index.js +291 -1
- package/dist/cjs/types/global-style.js +14 -1
- package/dist/cjs/types/shop.js +2 -1
- package/dist/esm/components/AddOn.js +14 -1
- package/dist/esm/components/ComponentWrapper.js +24 -1
- package/dist/esm/components/ComponentWrapperPreview.js +68 -1
- package/dist/esm/components/Empty.js +3 -1
- package/dist/esm/components/Render.js +61 -1
- package/dist/esm/components/Render.liquid.js +153 -3
- package/dist/esm/components/RenderBlock.js +50 -1
- package/dist/esm/components/RenderPreview.js +62 -1
- package/dist/esm/components/RenderSection.js +19 -1
- package/dist/esm/components/constant.js +37 -1
- package/dist/esm/contexts/AddonContext.js +32 -1
- package/dist/esm/contexts/BuilderComponent.js +31 -1
- package/dist/esm/contexts/BuilderContext.js +32 -1
- package/dist/esm/contexts/BuilderPreviewContext.js +367 -1
- package/dist/esm/contexts/CartLineContext.js +26 -1
- package/dist/esm/contexts/CollectionContext.js +35 -1
- package/dist/esm/contexts/ModalContext.js +44 -1
- package/dist/esm/contexts/ProductContext.js +146 -1
- package/dist/esm/contexts/ProductListContext.js +28 -1
- package/dist/esm/contexts/SectionContext.js +49 -1
- package/dist/esm/contexts/ShopContext.js +67 -1
- package/dist/esm/graphql/fragments/analytic.generated.js +4 -2
- package/dist/esm/graphql/fragments/collection-detail.generated.js +4 -2
- package/dist/esm/graphql/fragments/collection-product.generated.js +4 -2
- package/dist/esm/graphql/fragments/collection.generated.js +4 -2
- package/dist/esm/graphql/fragments/custom-code.generated.js +4 -2
- package/dist/esm/graphql/fragments/data-seo.generated.js +4 -2
- package/dist/esm/graphql/fragments/media.generated.js +4 -3
- package/dist/esm/graphql/fragments/product-little.generated.js +4 -2
- package/dist/esm/graphql/fragments/product-option-value.generated.js +4 -2
- package/dist/esm/graphql/fragments/product-option.generated.js +4 -2
- package/dist/esm/graphql/fragments/product.generated.js +4 -2
- package/dist/esm/graphql/fragments/published-custom-section.generated.js +4 -2
- package/dist/esm/graphql/fragments/published-page-section.generated.js +4 -2
- package/dist/esm/graphql/fragments/published-theme-page.generated.js +4 -2
- package/dist/esm/graphql/fragments/published-theme-style.generated.js +4 -2
- package/dist/esm/graphql/fragments/selected-option.generated.js +4 -2
- package/dist/esm/graphql/fragments/variant.generated.js +4 -2
- package/dist/esm/graphql/mutations/page-view-up.generated.js +5 -3
- package/dist/esm/graphql/queries/collection-detail-filter.generated.js +22 -10
- package/dist/esm/graphql/queries/collection.generated.js +18 -8
- package/dist/esm/graphql/queries/collections.generated.js +8 -3
- package/dist/esm/graphql/queries/preview-page.generated.js +18 -8
- package/dist/esm/graphql/queries/product-little-detail.generated.js +12 -5
- package/dist/esm/graphql/queries/product-medias.generated.js +6 -2
- package/dist/esm/graphql/queries/product-variants.generated.js +10 -4
- package/dist/esm/graphql/queries/products.generated.js +20 -9
- package/dist/esm/graphql/queries/published-theme-pages.generated.js +18 -8
- package/dist/esm/graphql/queries/store-property.generated.js +4 -2
- package/dist/esm/helpers/GlobalEvent.js +15 -1
- package/dist/esm/helpers/background.js +106 -1
- package/dist/esm/helpers/borders.js +175 -4
- package/dist/esm/helpers/clone-deep.js +3 -1
- package/dist/esm/helpers/cls.js +14 -1
- package/dist/esm/helpers/colors.js +168 -1
- package/dist/esm/helpers/compose-advance-style.js +185 -1
- package/dist/esm/helpers/constant.js +19 -1
- package/dist/esm/helpers/convert.js +4 -1
- package/dist/esm/helpers/css-variable.js +5 -1
- package/dist/esm/helpers/email.js +6 -1
- package/dist/esm/helpers/flatten-connection.js +7 -1
- package/dist/esm/helpers/get-resonsive-value.js +27 -1
- package/dist/esm/helpers/get-shortname.js +90 -1
- package/dist/esm/helpers/is-browser.js +5 -1
- package/dist/esm/helpers/is-defined.js +5 -1
- package/dist/esm/helpers/is-empty-children.js +7 -1
- package/dist/esm/helpers/is-safari.js +5 -1
- package/dist/esm/helpers/layout.js +54 -1
- package/dist/esm/helpers/load-script.js +29 -1
- package/dist/esm/helpers/make-style.js +117 -1
- package/dist/esm/helpers/normalize-builder-data.js +21 -1
- package/dist/esm/helpers/prefetch-queries.js +76 -1
- package/dist/esm/helpers/product.js +41 -1
- package/dist/esm/helpers/queries/get-collection.js +217 -1
- package/dist/esm/helpers/queries/get-collections.js +19 -1
- package/dist/esm/helpers/queries/get-product-by-slug.js +123 -1
- package/dist/esm/helpers/queries/get-product.js +150 -1
- package/dist/esm/helpers/queries/get-products.js +159 -1
- package/dist/esm/helpers/query.js +25 -1
- package/dist/esm/helpers/radius.js +124 -6
- package/dist/esm/helpers/render.js +64 -1
- package/dist/esm/helpers/shadow.js +51 -1
- package/dist/esm/helpers/size.js +31 -4
- package/dist/esm/helpers/spacing.js +40 -1
- package/dist/esm/helpers/tracking/fpixel.js +24 -1
- package/dist/esm/helpers/tracking/gtag.js +87 -1
- package/dist/esm/helpers/tracking/tiktokpixel.js +15 -1
- package/dist/esm/helpers/typography.js +96 -17
- package/dist/esm/helpers/variant.js +6 -1
- package/dist/esm/hooks/cart/use-add-to-cart.js +18 -1
- package/dist/esm/hooks/cart/use-cart-data.js +26 -1
- package/dist/esm/hooks/cart/use-cart-discount-codes-update.js +18 -1
- package/dist/esm/hooks/cart/use-cart-note-update.js +18 -1
- package/dist/esm/hooks/cart/use-create-cart.js +20 -1
- package/dist/esm/hooks/cart/use-remove-cart-item.js +18 -1
- package/dist/esm/hooks/cart/use-update-cart-item.js +18 -1
- package/dist/esm/hooks/shop/use-collection-query.js +20 -1
- package/dist/esm/hooks/shop/use-collections-query.js +15 -1
- package/dist/esm/hooks/shop/use-product-query.js +20 -1
- package/dist/esm/hooks/shop/use-products-query.js +20 -1
- package/dist/esm/hooks/shop.js +111 -1
- package/dist/esm/hooks/use-current-device.js +19 -1
- package/dist/esm/hooks/use-lazy-video.js +13 -1
- package/dist/esm/hooks/useCartId.js +40 -1
- package/dist/esm/hooks/useCartLine.js +7 -1
- package/dist/esm/hooks/useCartUI.js +44 -1
- package/dist/esm/hooks/useCollection.js +7 -1
- package/dist/esm/hooks/useFetchHandle.js +11 -1
- package/dist/esm/hooks/useFormatMoney.js +56 -1
- package/dist/esm/hooks/useIsomorphicLayoutEffect.js +6 -1
- package/dist/esm/hooks/useLoadScript.js +28 -1
- package/dist/esm/hooks/useMoney.js +80 -1
- package/dist/esm/hooks/usePrevious.js +17 -1
- package/dist/esm/hooks/useProduct.js +111 -1
- package/dist/esm/hooks/useProductList.js +16 -1
- package/dist/esm/hooks/useSuspenseFetch.js +23 -1
- package/dist/esm/hooks/useSwatchesOptions.js +37 -1
- package/dist/esm/index.js +92 -1
- package/dist/esm/types/global-style.js +11 -1
- package/dist/types/index.d.ts +26 -28
- package/package.json +2 -2
|
@@ -1 +1,59 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var constant = require('./constant.js');
|
|
4
|
+
var getResonsiveValue = require('./get-resonsive-value.js');
|
|
5
|
+
|
|
6
|
+
const gridToArrayRegex = // eslint-disable-next-line regexp/no-super-linear-backtracking
|
|
7
|
+
/[^\s()]+(?:\([^\s()]+(?:\([^()]+\))?(?:, *[^\s()]+(?:\([^()]+\))?)*\))?/g; // Regex convert css grid to array
|
|
8
|
+
const optionLayoutStyle = (column)=>{
|
|
9
|
+
if (!column) return {};
|
|
10
|
+
const style = {};
|
|
11
|
+
for (const [key, value] of Object.entries(column)){
|
|
12
|
+
Object.assign(style, {
|
|
13
|
+
[`--gtc${constant.devicesMapping?.[key]}`]: `repeat(${parseFloat(value + '') || 1}, minmax(0, 1fr))`
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return style;
|
|
17
|
+
};
|
|
18
|
+
const composeGridLayout = (layout)=>{
|
|
19
|
+
const display = getResonsiveValue.getResponsiveValue(layout, 'display');
|
|
20
|
+
const desktop = (getResonsiveValue.getResponsiveValueByScreen(display, 'desktop') === 'fit' ? layout?.desktop?.cols?.map(()=>`minmax(0, auto)`) : layout?.desktop?.cols?.map((col)=>`minmax(0, ${col}fr)`))?.join(' ');
|
|
21
|
+
const tablet = (getResonsiveValue.getResponsiveValueByScreen(display, 'tablet') === 'fit' ? layout?.tablet?.cols?.map(()=>`minmax(0, auto)`) : layout?.tablet?.cols?.map((col)=>`minmax(0, ${col}fr)`))?.join(' ');
|
|
22
|
+
const mobile = (getResonsiveValue.getResponsiveValueByScreen(display, 'mobile') === 'fit' ? layout?.mobile?.cols?.map(()=>`minmax(0, auto)`) : layout?.mobile?.cols?.map((col)=>`minmax(0, ${col}fr)`))?.join(' ');
|
|
23
|
+
return {
|
|
24
|
+
[`--gtc`]: desktop,
|
|
25
|
+
[`--gtc-tablet`]: tablet,
|
|
26
|
+
[`--gtc-mobile`]: mobile
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
const gridToArray = (layout)=>{
|
|
30
|
+
return layout ? layout.match(gridToArrayRegex) ?? [] : [];
|
|
31
|
+
};
|
|
32
|
+
const convertOldLayout = (layout)=>{
|
|
33
|
+
const desktopCol = gridToArray(layout?.desktop).length;
|
|
34
|
+
const tabletCol = gridToArray(layout?.tablet).length;
|
|
35
|
+
const mobileCol = gridToArray(layout?.mobile).length;
|
|
36
|
+
return {
|
|
37
|
+
desktop: {
|
|
38
|
+
cols: desktopCol ? Array.from({
|
|
39
|
+
length: desktopCol
|
|
40
|
+
}, ()=>12 / desktopCol) : undefined,
|
|
41
|
+
display: 'fill'
|
|
42
|
+
},
|
|
43
|
+
tablet: {
|
|
44
|
+
cols: tabletCol ? Array.from({
|
|
45
|
+
length: tabletCol
|
|
46
|
+
}, ()=>12 / tabletCol) : undefined
|
|
47
|
+
},
|
|
48
|
+
mobile: {
|
|
49
|
+
cols: mobileCol ? Array.from({
|
|
50
|
+
length: mobileCol
|
|
51
|
+
}, ()=>12 / mobileCol) : undefined
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
exports.composeGridLayout = composeGridLayout;
|
|
57
|
+
exports.convertOldLayout = convertOldLayout;
|
|
58
|
+
exports.gridToArrayRegex = gridToArrayRegex;
|
|
59
|
+
exports.optionLayoutStyle = optionLayoutStyle;
|
|
@@ -1 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const SCRIPTS_LOADED = {};
|
|
4
|
+
function loadScript(src, options) {
|
|
5
|
+
const isScriptLoaded = SCRIPTS_LOADED[src];
|
|
6
|
+
if (isScriptLoaded) {
|
|
7
|
+
return isScriptLoaded;
|
|
8
|
+
}
|
|
9
|
+
const promise = new Promise((resolve, reject)=>{
|
|
10
|
+
const script = document.createElement('script');
|
|
11
|
+
if (options?.module) {
|
|
12
|
+
script.type = 'module';
|
|
13
|
+
}
|
|
14
|
+
script.src = src;
|
|
15
|
+
script.onload = ()=>{
|
|
16
|
+
resolve(true);
|
|
17
|
+
};
|
|
18
|
+
script.onerror = ()=>{
|
|
19
|
+
reject(false);
|
|
20
|
+
};
|
|
21
|
+
if (options?.in === 'head') {
|
|
22
|
+
document.head.appendChild(script);
|
|
23
|
+
} else {
|
|
24
|
+
document.body.appendChild(script);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
SCRIPTS_LOADED[src] = promise;
|
|
28
|
+
return promise;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
exports.loadScript = loadScript;
|
|
@@ -1 +1,128 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var getResonsiveValue = require('./get-resonsive-value.js');
|
|
4
|
+
|
|
5
|
+
const removeNullUndefined = (obj)=>Object.entries(obj).reduce((a, [k, v])=>{
|
|
6
|
+
if (v === null || v === undefined) return a;
|
|
7
|
+
return {
|
|
8
|
+
...a,
|
|
9
|
+
[k]: v
|
|
10
|
+
};
|
|
11
|
+
}, {});
|
|
12
|
+
const makeStyleKey = (name)=>{
|
|
13
|
+
return [
|
|
14
|
+
name,
|
|
15
|
+
`hvr-${name}`,
|
|
16
|
+
`focus-${name}`,
|
|
17
|
+
`${name}-tablet`,
|
|
18
|
+
`hvr-${name}-tablet`,
|
|
19
|
+
`focus-${name}-tablet`,
|
|
20
|
+
`${name}-mobile`,
|
|
21
|
+
`hvr-${name}-mobile`,
|
|
22
|
+
`focus-${name}-mobile`
|
|
23
|
+
].map((key)=>`--${key}`);
|
|
24
|
+
};
|
|
25
|
+
const makeStyle = (style)=>{
|
|
26
|
+
return removeNullUndefined(Object.fromEntries(Object.entries(style).map(([key, value])=>[
|
|
27
|
+
`--${key}`,
|
|
28
|
+
value
|
|
29
|
+
])));
|
|
30
|
+
};
|
|
31
|
+
const makeStyleState = (name, value)=>{
|
|
32
|
+
if (!value) return {};
|
|
33
|
+
return {
|
|
34
|
+
[`--${name}`]: value?.normal,
|
|
35
|
+
[`--hvr-${name}`]: value?.hover,
|
|
36
|
+
[`--focus-${name}`]: value?.focus
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
const makeStyleResponsiveState = (name, value)=>{
|
|
40
|
+
if (!value) return {};
|
|
41
|
+
return {
|
|
42
|
+
[`--${name}`]: value?.desktop?.normal,
|
|
43
|
+
[`--hvr-${name}`]: value?.desktop?.hover,
|
|
44
|
+
[`--focus-${name}`]: value?.desktop?.focus,
|
|
45
|
+
[`--${name}-tablet`]: value?.tablet?.normal,
|
|
46
|
+
[`--hvr-${name}-tablet`]: value?.tablet?.hover,
|
|
47
|
+
[`--focus-${name}-tablet`]: value?.tablet?.focus,
|
|
48
|
+
[`--${name}-mobile`]: value?.mobile?.normal,
|
|
49
|
+
[`--hvr-${name}-mobile`]: value?.mobile?.hover,
|
|
50
|
+
[`--focus-${name}-mobile`]: value?.mobile?.focus
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
const makeStyleResponsive = (name, value)=>{
|
|
54
|
+
return {
|
|
55
|
+
[`--${name}`]: value?.desktop,
|
|
56
|
+
[`--${name}-tablet`]: value?.tablet,
|
|
57
|
+
[`--${name}-mobile`]: value?.mobile
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
const makeWidth = (widthValue, fullWidthValue)=>{
|
|
61
|
+
const getVal = (deviceValue, widthValue, fullWidthValue)=>{
|
|
62
|
+
const widthVal = widthValue?.[deviceValue] === undefined ? widthValue?.['desktop'] : widthValue?.[deviceValue];
|
|
63
|
+
const fullWidthVal = fullWidthValue?.[deviceValue] === undefined ? fullWidthValue?.['desktop'] : fullWidthValue?.[deviceValue];
|
|
64
|
+
if (fullWidthVal) {
|
|
65
|
+
return '100%';
|
|
66
|
+
} else if (fullWidthVal === false) {
|
|
67
|
+
return widthVal ?? widthVal;
|
|
68
|
+
} else {
|
|
69
|
+
return widthVal || 'auto';
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
return {
|
|
73
|
+
desktop: getVal('desktop', widthValue, fullWidthValue),
|
|
74
|
+
tablet: getVal('tablet', widthValue, fullWidthValue),
|
|
75
|
+
mobile: getVal('mobile', widthValue, fullWidthValue)
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
const makeHeight = (heighValue, autoHeight)=>{
|
|
79
|
+
const getVal = (deviceValue, heighValue, autoHeight)=>{
|
|
80
|
+
const heightVal = heighValue?.[deviceValue];
|
|
81
|
+
const isAuto = autoHeight?.[deviceValue];
|
|
82
|
+
if (isAuto) {
|
|
83
|
+
return 'auto';
|
|
84
|
+
} else if (isAuto === false) {
|
|
85
|
+
return heightVal ?? heightVal;
|
|
86
|
+
} else {
|
|
87
|
+
return heightVal;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
return {
|
|
91
|
+
desktop: getVal('desktop', heighValue, autoHeight),
|
|
92
|
+
tablet: getVal('tablet', heighValue, autoHeight),
|
|
93
|
+
mobile: getVal('mobile', heighValue, autoHeight)
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
const makeAspectRatio = (aspectRatio, aspectWidth, aspectHeight)=>{
|
|
97
|
+
return {
|
|
98
|
+
desktop: aspectRatio?.desktop === 'custom' ? `${getResonsiveValue.getResponsiveValueByScreen(aspectWidth, 'desktop')}/${getResonsiveValue.getResponsiveValueByScreen(aspectHeight, 'desktop')}` : aspectRatio?.desktop,
|
|
99
|
+
tablet: aspectRatio?.tablet === 'custom' ? `${getResonsiveValue.getResponsiveValueByScreen(aspectWidth, 'tablet')}/${getResonsiveValue.getResponsiveValueByScreen(aspectHeight, 'tablet')}` : aspectRatio?.tablet,
|
|
100
|
+
mobile: aspectRatio?.mobile === 'custom' ? `${getResonsiveValue.getResponsiveValueByScreen(aspectWidth, 'mobile')}/${getResonsiveValue.getResponsiveValueByScreen(aspectHeight, 'mobile')}` : aspectRatio?.mobile
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
const makeLineClamp = (lineClampValue, hasLineClampValue)=>{
|
|
104
|
+
const getVal = (deviceValue, lineClampValue, hasLineClampValue)=>{
|
|
105
|
+
const lineClamp = lineClampValue?.[deviceValue];
|
|
106
|
+
const hasLineClamp = hasLineClampValue?.[deviceValue] || hasLineClampValue?.['desktop'];
|
|
107
|
+
if (hasLineClamp || hasLineClamp === undefined) {
|
|
108
|
+
return lineClamp;
|
|
109
|
+
}
|
|
110
|
+
return 'unset';
|
|
111
|
+
};
|
|
112
|
+
return {
|
|
113
|
+
desktop: getVal('desktop', lineClampValue, hasLineClampValue),
|
|
114
|
+
tablet: getVal('tablet', lineClampValue, hasLineClampValue),
|
|
115
|
+
mobile: getVal('mobile', lineClampValue, hasLineClampValue)
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
exports.makeAspectRatio = makeAspectRatio;
|
|
120
|
+
exports.makeHeight = makeHeight;
|
|
121
|
+
exports.makeLineClamp = makeLineClamp;
|
|
122
|
+
exports.makeStyle = makeStyle;
|
|
123
|
+
exports.makeStyleKey = makeStyleKey;
|
|
124
|
+
exports.makeStyleResponsive = makeStyleResponsive;
|
|
125
|
+
exports.makeStyleResponsiveState = makeStyleResponsiveState;
|
|
126
|
+
exports.makeStyleState = makeStyleState;
|
|
127
|
+
exports.makeWidth = makeWidth;
|
|
128
|
+
exports.removeNullUndefined = removeNullUndefined;
|
|
@@ -1 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function normalizeBuilderData(data) {
|
|
4
|
+
const result = {};
|
|
5
|
+
function compose(data, res = {}) {
|
|
6
|
+
const childrens = data.childrens;
|
|
7
|
+
const items = childrens?.map((child)=>child.uid) ?? [];
|
|
8
|
+
res[data.uid] = {
|
|
9
|
+
...data,
|
|
10
|
+
childrens: items,
|
|
11
|
+
type: 'component'
|
|
12
|
+
};
|
|
13
|
+
if (childrens) {
|
|
14
|
+
childrens.map((child)=>compose(child, res));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
compose(data, result);
|
|
18
|
+
return {
|
|
19
|
+
...result
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
exports.normalizeBuilderData = normalizeBuilderData;
|
|
@@ -1 +1,78 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var useSWR = require('swr');
|
|
4
|
+
var getCollection = require('./queries/get-collection.js');
|
|
5
|
+
var getProduct = require('./queries/get-product.js');
|
|
6
|
+
var getProducts = require('./queries/get-products.js');
|
|
7
|
+
var query = require('./query.js');
|
|
8
|
+
|
|
9
|
+
const prefetchQueries = (input, options)=>{
|
|
10
|
+
const queries = [];
|
|
11
|
+
Object.keys(input).forEach((key)=>{
|
|
12
|
+
const item = input[key];
|
|
13
|
+
let data = undefined;
|
|
14
|
+
switch(item.tag){
|
|
15
|
+
case 'Product':
|
|
16
|
+
{
|
|
17
|
+
if (item.settings?.isAuto) break;
|
|
18
|
+
const variables = {
|
|
19
|
+
id: item.settings?.productSetting?.productId ?? 'latest',
|
|
20
|
+
isSample: options?.isSample,
|
|
21
|
+
isStorefront: options?.isStorefront
|
|
22
|
+
};
|
|
23
|
+
data = {
|
|
24
|
+
key: useSWR.unstable_serialize(query.generateProductQueryKey(variables)),
|
|
25
|
+
func: getProduct.getProduct,
|
|
26
|
+
variables
|
|
27
|
+
};
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
case 'ProductList':
|
|
31
|
+
{
|
|
32
|
+
const productSetting = item.settings?.productSetting;
|
|
33
|
+
if (productSetting?.productSrc === 'Collection') {
|
|
34
|
+
const variables = {
|
|
35
|
+
id: productSetting?.collectionId ?? 'latest',
|
|
36
|
+
numberOfProducts: item.settings?.numberOfProducts ?? 4,
|
|
37
|
+
orderBy: item.settings?.orderBy,
|
|
38
|
+
isSample: options?.isSample,
|
|
39
|
+
isStorefront: options?.isStorefront
|
|
40
|
+
};
|
|
41
|
+
data = {
|
|
42
|
+
key: useSWR.unstable_serialize(query.generateCollectionQueryKey(variables)),
|
|
43
|
+
func: getCollection.getCollection,
|
|
44
|
+
variables
|
|
45
|
+
};
|
|
46
|
+
} else {
|
|
47
|
+
const variables = {
|
|
48
|
+
ids: [
|
|
49
|
+
...productSetting?.productIds ?? []
|
|
50
|
+
].sort(),
|
|
51
|
+
isSample: options?.isSample,
|
|
52
|
+
isStorefront: options?.isStorefront
|
|
53
|
+
};
|
|
54
|
+
data = {
|
|
55
|
+
key: useSWR.unstable_serialize(query.generateProductsQueryKey(variables)),
|
|
56
|
+
func: getProducts.getProducts,
|
|
57
|
+
variables
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (data) {
|
|
64
|
+
queries.push(data);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
return queries.reduce((accumulator, current)=>{
|
|
68
|
+
if (!accumulator.some((x)=>x.key === current.key)) {
|
|
69
|
+
return [
|
|
70
|
+
...accumulator,
|
|
71
|
+
current
|
|
72
|
+
];
|
|
73
|
+
}
|
|
74
|
+
return accumulator;
|
|
75
|
+
}, []);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
exports.prefetchQueries = prefetchQueries;
|
|
@@ -1 +1,45 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var variant = require('./variant.js');
|
|
4
|
+
|
|
5
|
+
function getSelectedVariant(variants, choices) {
|
|
6
|
+
/**
|
|
7
|
+
* Ensure the user has selected all the required options, not just some.
|
|
8
|
+
*/ if (!variants || !variants.length || !choices || variants[0]?.selectedOptions.length !== Object.keys(choices).length) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
return variants.find((variant)=>{
|
|
12
|
+
return Object.entries(choices).every(([name, value])=>{
|
|
13
|
+
return variant?.selectedOptions.some((option)=>option.name === name && option.value === value);
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function parseSelectedOption(options) {
|
|
18
|
+
if (!options || options && options.length === 0) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
return options.reduce((acc, { name, value })=>{
|
|
22
|
+
if (name && value) {
|
|
23
|
+
return {
|
|
24
|
+
...acc,
|
|
25
|
+
[name]: value
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
return acc;
|
|
29
|
+
}, {});
|
|
30
|
+
}
|
|
31
|
+
function checkAvailableVariantInStock(variants, optionId, optionValue) {
|
|
32
|
+
return variants ? variants.some((item)=>{
|
|
33
|
+
if (item) {
|
|
34
|
+
const { selectedOptions } = item;
|
|
35
|
+
const opt = selectedOptions?.some((option)=>option?.name === optionId && option.value === optionValue);
|
|
36
|
+
const isInStock = variant.checkInStock(item);
|
|
37
|
+
return opt && isInStock;
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
}) : false;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
exports.checkAvailableVariantInStock = checkAvailableVariantInStock;
|
|
44
|
+
exports.getSelectedVariant = getSelectedVariant;
|
|
45
|
+
exports.parseSelectedOption = parseSelectedOption;
|
|
@@ -1 +1,220 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var collectionDetailFilter_generated = require('../../graphql/queries/collection-detail-filter.generated.js');
|
|
4
|
+
var productVariants_generated = require('../../graphql/queries/product-variants.generated.js');
|
|
5
|
+
var isDefined = require('../is-defined.js');
|
|
6
|
+
|
|
7
|
+
const PRODUCT_PER_PAGE = 8; // number of products per page
|
|
8
|
+
function productSortedByOrder(key) {
|
|
9
|
+
switch(key){
|
|
10
|
+
case 'TITLE_ASC':
|
|
11
|
+
return {
|
|
12
|
+
direction: 'ASC',
|
|
13
|
+
field: 'TITLE'
|
|
14
|
+
};
|
|
15
|
+
case 'TITLE_DESC':
|
|
16
|
+
return {
|
|
17
|
+
direction: 'DESC',
|
|
18
|
+
field: 'TITLE'
|
|
19
|
+
};
|
|
20
|
+
case 'CREATED_AT_ASC':
|
|
21
|
+
return {
|
|
22
|
+
direction: 'ASC',
|
|
23
|
+
field: 'CREATED_AT'
|
|
24
|
+
};
|
|
25
|
+
case 'CREATED_AT_DESC':
|
|
26
|
+
return {
|
|
27
|
+
direction: 'DESC',
|
|
28
|
+
field: 'CREATED_AT'
|
|
29
|
+
};
|
|
30
|
+
case 'none':
|
|
31
|
+
default:
|
|
32
|
+
return {
|
|
33
|
+
direction: 'ASC',
|
|
34
|
+
field: 'TITLE'
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const getCollection = async (fetcher, arg)=>{
|
|
39
|
+
const collections = await loopFetchCollection(fetcher, arg);
|
|
40
|
+
if (!collections) {
|
|
41
|
+
throw new Error('collections not found');
|
|
42
|
+
}
|
|
43
|
+
// merge product collection variant
|
|
44
|
+
const mergeProducts = await mergeProductCollectionVariant(fetcher, collections, arg.isSample);
|
|
45
|
+
return mergeProducts;
|
|
46
|
+
};
|
|
47
|
+
const fetchCollection = async (fetcher, variables)=>{
|
|
48
|
+
return fetcher([
|
|
49
|
+
collectionDetailFilter_generated.CollectionDetailFilterDocument,
|
|
50
|
+
variables
|
|
51
|
+
]);
|
|
52
|
+
};
|
|
53
|
+
const calculateFirstProduct = (numberOfProducts, currentPage, productsPerPage)=>{
|
|
54
|
+
const remainingProducts = numberOfProducts - productsPerPage * currentPage;
|
|
55
|
+
if (numberOfProducts < productsPerPage) return numberOfProducts;
|
|
56
|
+
return remainingProducts > 0 ? productsPerPage : productsPerPage + remainingProducts;
|
|
57
|
+
};
|
|
58
|
+
const chunkArray = (array, size)=>{
|
|
59
|
+
const chunked_arr = [];
|
|
60
|
+
let index = 0;
|
|
61
|
+
while(index < array.length){
|
|
62
|
+
chunked_arr.push(array.slice(index, size + index));
|
|
63
|
+
index += size;
|
|
64
|
+
}
|
|
65
|
+
return chunked_arr;
|
|
66
|
+
};
|
|
67
|
+
const loopFetchCollection = async (fetcher, arg)=>{
|
|
68
|
+
let variables; // variables of collection query
|
|
69
|
+
let productAfterFetcher; // product after of collection query
|
|
70
|
+
let dataCollection; // data of collection query
|
|
71
|
+
let hasNextPage; //
|
|
72
|
+
let firstCollection;
|
|
73
|
+
let currentPage = 1;
|
|
74
|
+
if (arg.numberOfProducts) {
|
|
75
|
+
const pages = Math.ceil(arg.numberOfProducts / PRODUCT_PER_PAGE);
|
|
76
|
+
while(currentPage <= pages && hasNextPage !== false){
|
|
77
|
+
variables = {
|
|
78
|
+
firstVariant: 1,
|
|
79
|
+
firstMedia: 30,
|
|
80
|
+
orderBy: {
|
|
81
|
+
field: 'PLATFORM_CREATED_AT',
|
|
82
|
+
direction: 'DESC'
|
|
83
|
+
},
|
|
84
|
+
orderByMedia: {
|
|
85
|
+
field: 'POSITION',
|
|
86
|
+
direction: 'ASC'
|
|
87
|
+
},
|
|
88
|
+
firstProduct: calculateFirstProduct(arg.numberOfProducts, currentPage, PRODUCT_PER_PAGE),
|
|
89
|
+
...!arg.id || arg.id.toLowerCase() === 'latest' ? {
|
|
90
|
+
where: {
|
|
91
|
+
hasCollectionProducts: true,
|
|
92
|
+
isSample: arg.isSample
|
|
93
|
+
}
|
|
94
|
+
} : {
|
|
95
|
+
where: {
|
|
96
|
+
baseID: arg.id
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
orderByProduct: productSortedByOrder(arg.orderBy),
|
|
100
|
+
whereProduct: {
|
|
101
|
+
status: 'ACTIVE',
|
|
102
|
+
...arg.isStorefront && {
|
|
103
|
+
isStorefront: arg.isStorefront
|
|
104
|
+
},
|
|
105
|
+
isSample: arg.isSample
|
|
106
|
+
},
|
|
107
|
+
...productAfterFetcher ? {
|
|
108
|
+
productsAfter: productAfterFetcher
|
|
109
|
+
} : undefined
|
|
110
|
+
};
|
|
111
|
+
const pageData = await fetchCollection(fetcher, variables);
|
|
112
|
+
productAfterFetcher = pageData?.collections?.edges?.[0]?.node?.products?.pageInfo?.endCursor;
|
|
113
|
+
if (currentPage === 1) {
|
|
114
|
+
dataCollection = pageData; // set data of first page
|
|
115
|
+
firstCollection = dataCollection?.collections?.edges?.[0];
|
|
116
|
+
} else if (firstCollection?.node?.products && pageData?.collections?.edges?.[0]?.node?.products?.edges) {
|
|
117
|
+
// concat new values to the old ones
|
|
118
|
+
firstCollection.node.products = {
|
|
119
|
+
pageInfo: pageData?.collections?.edges?.[0]?.node?.products?.pageInfo,
|
|
120
|
+
edges: firstCollection.node?.products?.edges.concat(pageData?.collections?.edges?.[0]?.node?.products?.edges)
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
currentPage++;
|
|
124
|
+
// hasNextPage = false if there is no more pages then break the loop
|
|
125
|
+
if (!firstCollection?.node?.products?.pageInfo?.hasNextPage) {
|
|
126
|
+
hasNextPage = false;
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return dataCollection;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
const mergeProductCollectionVariant = async (fetcher, collection, isSample)=>{
|
|
134
|
+
const node = collection?.collections?.edges?.[0]?.node;
|
|
135
|
+
if (!node) return collection;
|
|
136
|
+
const productList = node?.products?.edges;
|
|
137
|
+
const listBaseId = productList?.map((product)=>product?.node?.baseID).filter(isDefined.isDefined);
|
|
138
|
+
const ProductListWithVariants = await fetchVariantsByBaseIds(fetcher, {
|
|
139
|
+
ids: listBaseId,
|
|
140
|
+
isSample
|
|
141
|
+
});
|
|
142
|
+
// mapping variant to product list in collections
|
|
143
|
+
const newProductList = productList?.map((product)=>{
|
|
144
|
+
const productVariants = ProductListWithVariants?.variants?.edges?.filter((productV)=>productV?.node?.id === product?.node?.id);
|
|
145
|
+
return {
|
|
146
|
+
...product,
|
|
147
|
+
node: product.node ? {
|
|
148
|
+
...product.node,
|
|
149
|
+
variants: product.node?.variants ? {
|
|
150
|
+
...product.node?.variants,
|
|
151
|
+
edges: productVariants?.[0]?.node?.variants?.edges ?? []
|
|
152
|
+
} : undefined
|
|
153
|
+
} : undefined
|
|
154
|
+
};
|
|
155
|
+
}) ?? [];
|
|
156
|
+
const newCollection = {
|
|
157
|
+
...collection,
|
|
158
|
+
collections: {
|
|
159
|
+
edges: [
|
|
160
|
+
{
|
|
161
|
+
node: {
|
|
162
|
+
...node,
|
|
163
|
+
products: {
|
|
164
|
+
edges: newProductList
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
cursor: undefined
|
|
168
|
+
}
|
|
169
|
+
]
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
return newCollection;
|
|
173
|
+
};
|
|
174
|
+
const fetchVariantsByBaseIds = async (fetcher, { ids, isSample, isStorefront })=>{
|
|
175
|
+
const chunkedIds = chunkArray(ids ?? [], 8);
|
|
176
|
+
const defaultEdges = [];
|
|
177
|
+
const query = async (variables)=>{
|
|
178
|
+
try {
|
|
179
|
+
return await fetcher([
|
|
180
|
+
productVariants_generated.ProductVariantsDocument,
|
|
181
|
+
variables
|
|
182
|
+
]);
|
|
183
|
+
} catch {
|
|
184
|
+
return {};
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
const promises = chunkedIds.map((chunkedId)=>{
|
|
188
|
+
const variables = {
|
|
189
|
+
firstVariant: 100,
|
|
190
|
+
first: chunkedId.length,
|
|
191
|
+
orderBy: {
|
|
192
|
+
field: 'TITLE',
|
|
193
|
+
direction: 'ASC'
|
|
194
|
+
},
|
|
195
|
+
where: {
|
|
196
|
+
status: 'ACTIVE',
|
|
197
|
+
isSample,
|
|
198
|
+
...isStorefront && {
|
|
199
|
+
isStorefront
|
|
200
|
+
},
|
|
201
|
+
...chunkedId.length && {
|
|
202
|
+
baseIDIn: chunkedId.sort()
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
return query(variables);
|
|
207
|
+
});
|
|
208
|
+
const responses = await Promise.all(promises);
|
|
209
|
+
const edges = responses?.reduce((acc, response)=>{
|
|
210
|
+
return acc.concat(response?.variants?.edges ?? []);
|
|
211
|
+
}, defaultEdges);
|
|
212
|
+
return {
|
|
213
|
+
variants: {
|
|
214
|
+
edges
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
exports.calculateFirstProduct = calculateFirstProduct;
|
|
220
|
+
exports.getCollection = getCollection;
|
|
@@ -1 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var collections_generated = require('../../graphql/queries/collections.generated.js');
|
|
4
|
+
|
|
5
|
+
const getCollections = async (fetcher, variable)=>{
|
|
6
|
+
const collections = await fetchCollections(fetcher, variable ?? {});
|
|
7
|
+
if (!collections) {
|
|
8
|
+
throw new Error('Collection not found');
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
...collections
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
const fetchCollections = async (fetcher, variables)=>{
|
|
15
|
+
return fetcher([
|
|
16
|
+
collections_generated.CollectionsDocument,
|
|
17
|
+
variables
|
|
18
|
+
]);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.getCollections = getCollections;
|